blob: 538a1c5475b685c6280a1308a3e9e223fd45535a [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;
John Fastabend9d35cf02016-02-16 21:18:28 -080035 int (*val)(struct ixgbe_fdir_filter *input,
36 union ixgbe_atr_input *mask,
John Fastabendfa477f42016-02-17 14:34:53 -080037 u32 val, u32 m);
John Fastabend9d35cf02016-02-16 21:18:28 -080038 unsigned int type;
39};
40
Amritha Nambiar1cdaaf52016-04-14 19:08:53 -040041struct ixgbe_jump_table {
42 struct ixgbe_mat_field *mat;
43 struct ixgbe_fdir_filter *input;
44 union ixgbe_atr_input *mask;
Amritha Nambiar1ecedc92016-05-06 19:09:51 -070045 u32 link_hdl;
46 unsigned long child_loc_map[32];
Amritha Nambiar1cdaaf52016-04-14 19:08:53 -040047};
48
Amritha Nambiar1ecedc92016-05-06 19:09:51 -070049#define IXGBE_MAX_HW_ENTRIES 2045
50
John Fastabend9d35cf02016-02-16 21:18:28 -080051static inline int ixgbe_mat_prgm_sip(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.src_ip[0] = val;
56 mask->formatted.src_ip[0] = m;
57 return 0;
58}
59
60static inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input,
61 union ixgbe_atr_input *mask,
John Fastabendfa477f42016-02-17 14:34:53 -080062 u32 val, u32 m)
John Fastabend9d35cf02016-02-16 21:18:28 -080063{
64 input->filter.formatted.dst_ip[0] = val;
65 mask->formatted.dst_ip[0] = m;
66 return 0;
67}
68
69static struct ixgbe_mat_field ixgbe_ipv4_fields[] = {
Sridhar Samudralaebd83ad2016-03-07 09:41:48 -080070 { .off = 12, .val = ixgbe_mat_prgm_sip,
John Fastabend9d35cf02016-02-16 21:18:28 -080071 .type = IXGBE_ATR_FLOW_TYPE_IPV4},
Sridhar Samudralaebd83ad2016-03-07 09:41:48 -080072 { .off = 16, .val = ixgbe_mat_prgm_dip,
John Fastabend9d35cf02016-02-16 21:18:28 -080073 .type = IXGBE_ATR_FLOW_TYPE_IPV4},
74 { .val = NULL } /* terminal node */
75};
76
Sridhar Samudralab5aea3d2016-03-07 09:41:49 -080077static inline int ixgbe_mat_prgm_ports(struct ixgbe_fdir_filter *input,
John Fastabend9d35cf02016-02-16 21:18:28 -080078 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.src_port = val & 0xffff;
82 mask->formatted.src_port = m & 0xffff;
Sridhar Samudralab5aea3d2016-03-07 09:41:49 -080083 input->filter.formatted.dst_port = val >> 16;
84 mask->formatted.dst_port = m >> 16;
John Fastabend9d35cf02016-02-16 21:18:28 -080085
John Fastabend9d35cf02016-02-16 21:18:28 -080086 return 0;
87};
88
89static struct ixgbe_mat_field ixgbe_tcp_fields[] = {
Sridhar Samudralab5aea3d2016-03-07 09:41:49 -080090 {.off = 0, .val = ixgbe_mat_prgm_ports,
John Fastabend9d35cf02016-02-16 21:18:28 -080091 .type = IXGBE_ATR_FLOW_TYPE_TCPV4},
92 { .val = NULL } /* terminal node */
93};
94
Amritha Nambiar4ae78342016-03-09 18:32:16 -050095static struct ixgbe_mat_field ixgbe_udp_fields[] = {
96 {.off = 0, .val = ixgbe_mat_prgm_ports,
97 .type = IXGBE_ATR_FLOW_TYPE_UDPV4},
98 { .val = NULL } /* terminal node */
99};
100
John Fastabend9d35cf02016-02-16 21:18:28 -0800101struct ixgbe_nexthdr {
102 /* offset, shift, and mask of position to next header */
103 unsigned int o;
John Fastabendfa477f42016-02-17 14:34:53 -0800104 u32 s;
105 u32 m;
John Fastabend9d35cf02016-02-16 21:18:28 -0800106 /* match criteria to make this jump*/
107 unsigned int off;
John Fastabendfa477f42016-02-17 14:34:53 -0800108 u32 val;
109 u32 mask;
John Fastabend9d35cf02016-02-16 21:18:28 -0800110 /* location of jump to make */
111 struct ixgbe_mat_field *jump;
112};
113
114static struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = {
115 { .o = 0, .s = 6, .m = 0xf,
116 .off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields},
Amritha Nambiar4ae78342016-03-09 18:32:16 -0500117 { .o = 0, .s = 6, .m = 0xf,
118 .off = 8, .val = 0x1100, .mask = 0xff00, .jump = ixgbe_udp_fields},
John Fastabend9d35cf02016-02-16 21:18:28 -0800119 { .jump = NULL } /* terminal node */
120};
121#endif /* _IXGBE_MODEL_H_ */