blob: ce48872d47821f54311aa838b58401f9bbd3be74 [file] [log] [blame]
John Fastabend9d35cf02016-02-16 21:18:28 -08001/*******************************************************************************
2 *
3 * Intel 10 Gigabit PCI Express Linux drive
John Fastabenda92265c2016-02-17 14:35:23 -08004 * Copyright(c) 2016 Intel Corporation.
John Fastabend9d35cf02016-02-16 21:18:28 -08005 *
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
33struct 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,
John Fastabendfa477f42016-02-17 14:34:53 -080038 u32 val, u32 m);
John Fastabend9d35cf02016-02-16 21:18:28 -080039 unsigned int type;
40};
41
42static inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input,
43 union ixgbe_atr_input *mask,
John Fastabendfa477f42016-02-17 14:34:53 -080044 u32 val, u32 m)
John Fastabend9d35cf02016-02-16 21:18:28 -080045{
46 input->filter.formatted.src_ip[0] = val;
47 mask->formatted.src_ip[0] = m;
48 return 0;
49}
50
51static inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input,
52 union ixgbe_atr_input *mask,
John Fastabendfa477f42016-02-17 14:34:53 -080053 u32 val, u32 m)
John Fastabend9d35cf02016-02-16 21:18:28 -080054{
55 input->filter.formatted.dst_ip[0] = val;
56 mask->formatted.dst_ip[0] = m;
57 return 0;
58}
59
60static 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
68static inline int ixgbe_mat_prgm_sport(struct ixgbe_fdir_filter *input,
69 union ixgbe_atr_input *mask,
John Fastabendfa477f42016-02-17 14:34:53 -080070 u32 val, u32 m)
John Fastabend9d35cf02016-02-16 21:18:28 -080071{
72 input->filter.formatted.src_port = val & 0xffff;
73 mask->formatted.src_port = m & 0xffff;
74 return 0;
75};
76
77static inline int ixgbe_mat_prgm_dport(struct ixgbe_fdir_filter *input,
78 union ixgbe_atr_input *mask,
John Fastabendfa477f42016-02-17 14:34:53 -080079 u32 val, u32 m)
John Fastabend9d35cf02016-02-16 21:18:28 -080080{
81 input->filter.formatted.dst_port = val & 0xffff;
82 mask->formatted.dst_port = m & 0xffff;
83 return 0;
84};
85
86static 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
94struct ixgbe_nexthdr {
95 /* offset, shift, and mask of position to next header */
96 unsigned int o;
John Fastabendfa477f42016-02-17 14:34:53 -080097 u32 s;
98 u32 m;
John Fastabend9d35cf02016-02-16 21:18:28 -080099 /* match criteria to make this jump*/
100 unsigned int off;
John Fastabendfa477f42016-02-17 14:34:53 -0800101 u32 val;
102 u32 mask;
John Fastabend9d35cf02016-02-16 21:18:28 -0800103 /* location of jump to make */
104 struct ixgbe_mat_field *jump;
105};
106
107static 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_ */