Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cascardo/linux.git] / drivers / net / ethernet / intel / ixgbe / ixgbe_model.h
1 /*******************************************************************************
2  *
3  * Intel 10 Gigabit PCI Express Linux drive
4  * Copyright(c) 2016 Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  * The full GNU General Public License is included in this distribution in
19  * the file called "COPYING".
20  *
21  * Contact Information:
22  * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24  *
25  ******************************************************************************/
26
27 #ifndef _IXGBE_MODEL_H_
28 #define _IXGBE_MODEL_H_
29
30 #include "ixgbe.h"
31 #include "ixgbe_type.h"
32
33 struct ixgbe_mat_field {
34         unsigned int off;
35         unsigned int mask;
36         int (*val)(struct ixgbe_fdir_filter *input,
37                    union ixgbe_atr_input *mask,
38                    u32 val, u32 m);
39         unsigned int type;
40 };
41
42 static inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input,
43                                      union ixgbe_atr_input *mask,
44                                      u32 val, u32 m)
45 {
46         input->filter.formatted.src_ip[0] = val;
47         mask->formatted.src_ip[0] = m;
48         return 0;
49 }
50
51 static inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input,
52                                      union ixgbe_atr_input *mask,
53                                      u32 val, u32 m)
54 {
55         input->filter.formatted.dst_ip[0] = val;
56         mask->formatted.dst_ip[0] = m;
57         return 0;
58 }
59
60 static struct ixgbe_mat_field ixgbe_ipv4_fields[] = {
61         { .off = 12, .mask = -1, .val = ixgbe_mat_prgm_sip,
62           .type = IXGBE_ATR_FLOW_TYPE_IPV4},
63         { .off = 16, .mask = -1, .val = ixgbe_mat_prgm_dip,
64           .type = IXGBE_ATR_FLOW_TYPE_IPV4},
65         { .val = NULL } /* terminal node */
66 };
67
68 static inline int ixgbe_mat_prgm_sport(struct ixgbe_fdir_filter *input,
69                                        union ixgbe_atr_input *mask,
70                                        u32 val, u32 m)
71 {
72         input->filter.formatted.src_port = val & 0xffff;
73         mask->formatted.src_port = m & 0xffff;
74         return 0;
75 };
76
77 static inline int ixgbe_mat_prgm_dport(struct ixgbe_fdir_filter *input,
78                                        union ixgbe_atr_input *mask,
79                                        u32 val, u32 m)
80 {
81         input->filter.formatted.dst_port = val & 0xffff;
82         mask->formatted.dst_port = m & 0xffff;
83         return 0;
84 };
85
86 static struct ixgbe_mat_field ixgbe_tcp_fields[] = {
87         {.off = 0, .mask = 0xffff, .val = ixgbe_mat_prgm_sport,
88          .type = IXGBE_ATR_FLOW_TYPE_TCPV4},
89         {.off = 2, .mask = 0xffff, .val = ixgbe_mat_prgm_dport,
90          .type = IXGBE_ATR_FLOW_TYPE_TCPV4},
91         { .val = NULL } /* terminal node */
92 };
93
94 struct ixgbe_nexthdr {
95         /* offset, shift, and mask of position to next header */
96         unsigned int o;
97         u32 s;
98         u32 m;
99         /* match criteria to make this jump*/
100         unsigned int off;
101         u32 val;
102         u32 mask;
103         /* location of jump to make */
104         struct ixgbe_mat_field *jump;
105 };
106
107 static struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = {
108         { .o = 0, .s = 6, .m = 0xf,
109           .off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields},
110         { .jump = NULL } /* terminal node */
111 };
112 #endif /* _IXGBE_MODEL_H_ */