blob: 72446644f9fa0efd45eb79c3fddd3567b8f51433 [file] [log] [blame]
Jeff Kirsherae06c702018-03-22 10:08:48 -07001/* SPDX-License-Identifier: GPL-2.0 */
John Fastabend9d35cf02016-02-16 21:18:28 -08002/*******************************************************************************
3 *
4 * Intel 10 Gigabit PCI Express Linux drive
John Fastabenda92265c2016-02-17 14:35:23 -08005 * Copyright(c) 2016 Intel Corporation.
John Fastabend9d35cf02016-02-16 21:18:28 -08006 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * The full GNU General Public License is included in this distribution in
20 * the file called "COPYING".
21 *
22 * Contact Information:
23 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *
26 ******************************************************************************/
27
28#ifndef _IXGBE_MODEL_H_
29#define _IXGBE_MODEL_H_
30
31#include "ixgbe.h"
32#include "ixgbe_type.h"
33
34struct ixgbe_mat_field {
35 unsigned int off;
John Fastabend9d35cf02016-02-16 21:18:28 -080036 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
Amritha Nambiar1cdaaf52016-04-14 19:08:53 -040042struct ixgbe_jump_table {
43 struct ixgbe_mat_field *mat;
44 struct ixgbe_fdir_filter *input;
45 union ixgbe_atr_input *mask;
Amritha Nambiar1ecedc92016-05-06 19:09:51 -070046 u32 link_hdl;
47 unsigned long child_loc_map[32];
Amritha Nambiar1cdaaf52016-04-14 19:08:53 -040048};
49
Amritha Nambiar1ecedc92016-05-06 19:09:51 -070050#define IXGBE_MAX_HW_ENTRIES 2045
51
John Fastabend9d35cf02016-02-16 21:18:28 -080052static inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input,
53 union ixgbe_atr_input *mask,
John Fastabendfa477f42016-02-17 14:34:53 -080054 u32 val, u32 m)
John Fastabend9d35cf02016-02-16 21:18:28 -080055{
56 input->filter.formatted.src_ip[0] = val;
57 mask->formatted.src_ip[0] = m;
58 return 0;
59}
60
61static inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input,
62 union ixgbe_atr_input *mask,
John Fastabendfa477f42016-02-17 14:34:53 -080063 u32 val, u32 m)
John Fastabend9d35cf02016-02-16 21:18:28 -080064{
65 input->filter.formatted.dst_ip[0] = val;
66 mask->formatted.dst_ip[0] = m;
67 return 0;
68}
69
70static struct ixgbe_mat_field ixgbe_ipv4_fields[] = {
Sridhar Samudralaebd83ad2016-03-07 09:41:48 -080071 { .off = 12, .val = ixgbe_mat_prgm_sip,
John Fastabend9d35cf02016-02-16 21:18:28 -080072 .type = IXGBE_ATR_FLOW_TYPE_IPV4},
Sridhar Samudralaebd83ad2016-03-07 09:41:48 -080073 { .off = 16, .val = ixgbe_mat_prgm_dip,
John Fastabend9d35cf02016-02-16 21:18:28 -080074 .type = IXGBE_ATR_FLOW_TYPE_IPV4},
75 { .val = NULL } /* terminal node */
76};
77
Sridhar Samudralab5aea3d2016-03-07 09:41:49 -080078static inline int ixgbe_mat_prgm_ports(struct ixgbe_fdir_filter *input,
John Fastabend9d35cf02016-02-16 21:18:28 -080079 union ixgbe_atr_input *mask,
John Fastabendfa477f42016-02-17 14:34:53 -080080 u32 val, u32 m)
John Fastabend9d35cf02016-02-16 21:18:28 -080081{
82 input->filter.formatted.src_port = val & 0xffff;
83 mask->formatted.src_port = m & 0xffff;
Sridhar Samudralab5aea3d2016-03-07 09:41:49 -080084 input->filter.formatted.dst_port = val >> 16;
85 mask->formatted.dst_port = m >> 16;
John Fastabend9d35cf02016-02-16 21:18:28 -080086
John Fastabend9d35cf02016-02-16 21:18:28 -080087 return 0;
88};
89
90static struct ixgbe_mat_field ixgbe_tcp_fields[] = {
Sridhar Samudralab5aea3d2016-03-07 09:41:49 -080091 {.off = 0, .val = ixgbe_mat_prgm_ports,
John Fastabend9d35cf02016-02-16 21:18:28 -080092 .type = IXGBE_ATR_FLOW_TYPE_TCPV4},
93 { .val = NULL } /* terminal node */
94};
95
Amritha Nambiar4ae78342016-03-09 18:32:16 -050096static struct ixgbe_mat_field ixgbe_udp_fields[] = {
97 {.off = 0, .val = ixgbe_mat_prgm_ports,
98 .type = IXGBE_ATR_FLOW_TYPE_UDPV4},
99 { .val = NULL } /* terminal node */
100};
101
John Fastabend9d35cf02016-02-16 21:18:28 -0800102struct ixgbe_nexthdr {
103 /* offset, shift, and mask of position to next header */
104 unsigned int o;
John Fastabendfa477f42016-02-17 14:34:53 -0800105 u32 s;
106 u32 m;
John Fastabend9d35cf02016-02-16 21:18:28 -0800107 /* match criteria to make this jump*/
108 unsigned int off;
John Fastabendfa477f42016-02-17 14:34:53 -0800109 u32 val;
110 u32 mask;
John Fastabend9d35cf02016-02-16 21:18:28 -0800111 /* location of jump to make */
112 struct ixgbe_mat_field *jump;
113};
114
115static struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = {
116 { .o = 0, .s = 6, .m = 0xf,
117 .off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields},
Amritha Nambiar4ae78342016-03-09 18:32:16 -0500118 { .o = 0, .s = 6, .m = 0xf,
119 .off = 8, .val = 0x1100, .mask = 0xff00, .jump = ixgbe_udp_fields},
John Fastabend9d35cf02016-02-16 21:18:28 -0800120 { .jump = NULL } /* terminal node */
121};
122#endif /* _IXGBE_MODEL_H_ */