1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright (c) 2020, Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Intel Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _ICE_PROTOCOL_TYPE_H_
34 #define _ICE_PROTOCOL_TYPE_H_
35 #include "ice_flex_type.h"
36 #define ICE_IPV6_ADDR_LENGTH 16
38 /* Each recipe can match up to 5 different fields. Fields to match can be meta-
39 * data, values extracted from packet headers, or results from other recipes.
40 * One of the 5 fields is reserved for matching the switch ID. So, up to 4
41 * recipes can provide intermediate results to another one through chaining,
42 * e.g. recipes 0, 1, 2, and 3 can provide intermediate results to recipe 4.
44 #define ICE_NUM_WORDS_RECIPE 4
46 /* Max recipes that can be chained */
47 #define ICE_MAX_CHAIN_RECIPE 5
49 /* 1 word reserved for switch ID from allowed 5 words.
50 * So a recipe can have max 4 words. And you can chain 5 such recipes
51 * together. So maximum words that can be programmed for look up is 5 * 4.
53 #define ICE_MAX_CHAIN_WORDS (ICE_NUM_WORDS_RECIPE * ICE_MAX_CHAIN_RECIPE)
55 /* Field vector index corresponding to chaining */
56 #define ICE_CHAIN_FV_INDEX_START 47
58 enum ice_protocol_type {
78 enum ice_sw_tunnel_type {
80 ICE_SW_TUN_AND_NON_TUN,
85 ICE_SW_TUN_UDP, /* This means all "UDP" tunnel types: VXLAN-GPE, VXLAN
88 ICE_ALL_TUNNELS /* All tunnel types including NVGRE */
91 /* Decoders for ice_prot_id:
99 ICE_PROT_ID_INVAL = 0,
100 ICE_PROT_MAC_OF_OR_S = 1,
103 ICE_PROT_MAC_IN_MAC = 7,
104 ICE_PROT_ETYPE_OL = 9,
105 ICE_PROT_ETYPE_IL = 10,
107 ICE_PROT_EVLAN_O = 16,
108 ICE_PROT_VLAN_O = 17,
109 ICE_PROT_VLAN_IF = 18,
110 ICE_PROT_MPLS_OL_MINUS_1 = 27,
111 ICE_PROT_MPLS_OL_OR_OS = 28,
112 ICE_PROT_MPLS_IL = 29,
113 ICE_PROT_IPV4_OF_OR_S = 32,
114 ICE_PROT_IPV4_IL = 33,
115 ICE_PROT_IPV6_OF_OR_S = 40,
116 ICE_PROT_IPV6_IL = 41,
117 ICE_PROT_IPV6_FRAG = 47,
118 ICE_PROT_TCP_IL = 49,
119 ICE_PROT_UDP_OF = 52,
120 ICE_PROT_UDP_IL_OR_S = 53,
121 ICE_PROT_GRE_OF = 64,
125 ICE_PROT_SCTP_IL = 96,
126 ICE_PROT_ICMP_IL = 98,
127 ICE_PROT_ICMPV6_IL = 100,
128 ICE_PROT_VRRP_F = 101,
130 ICE_PROT_ATAOE_OF = 114,
131 ICE_PROT_CTRL_OF = 116,
132 ICE_PROT_LLDP_OF = 117,
133 ICE_PROT_ARP_OF = 118,
134 ICE_PROT_EAPOL_OF = 120,
135 ICE_PROT_META_ID = 255, /* when offset == metaddata */
136 ICE_PROT_INVALID = 255 /* when offset == ICE_FV_OFFSET_INVAL */
139 #define ICE_VNI_OFFSET 12 /* offset of VNI from ICE_PROT_UDP_OF */
141 #define ICE_MAC_OFOS_HW 1
142 #define ICE_MAC_IL_HW 4
143 #define ICE_ETYPE_OL_HW 9
144 #define ICE_VLAN_OL_HW 17
145 #define ICE_IPV4_OFOS_HW 32
146 #define ICE_IPV4_IL_HW 33
147 #define ICE_IPV6_OFOS_HW 40
148 #define ICE_IPV6_IL_HW 41
149 #define ICE_TCP_IL_HW 49
150 #define ICE_UDP_ILOS_HW 53
151 #define ICE_SCTP_IL_HW 96
153 /* ICE_UDP_OF is used to identify all 3 tunnel types
154 * VXLAN, GENEVE and VXLAN_GPE. To differentiate further
155 * need to use flags from the field vector
157 #define ICE_UDP_OF_HW 52 /* UDP Tunnels */
158 #define ICE_GRE_OF_HW 64 /* NVGRE */
159 #define ICE_META_DATA_ID_HW 255 /* this is used for tunnel type */
161 #define ICE_MDID_SIZE 2
162 #define ICE_TUN_FLAG_MDID 21
163 #define ICE_TUN_FLAG_MASK 0xFF
164 #define ICE_TUN_FLAG_FV_IND 2
166 #define ICE_PROTOCOL_MAX_ENTRIES 16
168 /* Mapping of software defined protocol ID to hardware defined protocol ID */
169 struct ice_protocol_entry {
170 enum ice_protocol_type type;
174 struct ice_ether_hdr {
175 u8 dst_addr[ETH_ALEN];
176 u8 src_addr[ETH_ALEN];
179 struct ice_ethtype_hdr {
183 struct ice_ether_vlan_hdr {
184 u8 dst_addr[ETH_ALEN];
185 u8 src_addr[ETH_ALEN];
189 struct ice_vlan_hdr {
194 struct ice_ipv4_hdr {
207 struct ice_le_ver_tc_flow {
218 struct ice_ipv6_hdr {
219 __be32 be_ver_tc_flow;
223 u8 src_addr[ICE_IPV6_ADDR_LENGTH];
224 u8 dst_addr[ICE_IPV6_ADDR_LENGTH];
227 struct ice_sctp_hdr {
230 __be32 verification_tag;
241 struct ice_udp_tnl_hdr {
244 __be32 vni; /* only use lower 24-bits */
254 struct ice_ether_hdr eth_hdr;
255 struct ice_ethtype_hdr ethertype;
256 struct ice_vlan_hdr vlan_hdr;
257 struct ice_ipv4_hdr ipv4_hdr;
258 struct ice_ipv6_hdr ipv6_hdr;
259 struct ice_l4_hdr l4_hdr;
260 struct ice_sctp_hdr sctp_hdr;
261 struct ice_udp_tnl_hdr tnl_hdr;
262 struct ice_nvgre nvgre_hdr;
265 /* This is mapping table entry that maps every word within a given protocol
266 * structure to the real byte offset as per the specification of that
268 * for e.g. dst address is 3 words in ethertype header and corresponding bytes
269 * are 0, 2, 3 in the actual packet header and src address is at 4, 6, 8
271 struct ice_prot_ext_tbl_entry {
272 enum ice_protocol_type prot_type;
273 /* Byte offset into header of given protocol type */
274 u8 offs[sizeof(union ice_prot_hdr)];
277 /* Extractions to be looked up for a given recipe */
278 struct ice_prot_lkup_ext {
281 /* create a buffer to hold max words per recipe */
282 u16 field_off[ICE_MAX_CHAIN_WORDS];
283 u16 field_mask[ICE_MAX_CHAIN_WORDS];
285 struct ice_fv_word fv_words[ICE_MAX_CHAIN_WORDS];
287 /* Indicate field offsets that have field vector indices assigned */
288 ice_declare_bitmap(done, ICE_MAX_CHAIN_WORDS);
291 struct ice_pref_recipe_group {
292 u8 n_val_pairs; /* Number of valid pairs */
293 struct ice_fv_word pairs[ICE_NUM_WORDS_RECIPE];
294 u16 mask[ICE_NUM_WORDS_RECIPE];
297 struct ice_recp_grp_entry {
298 struct LIST_ENTRY_TYPE l_entry;
300 #define ICE_INVAL_CHAIN_IND 0xFF
303 u16 fv_idx[ICE_NUM_WORDS_RECIPE];
304 u16 fv_mask[ICE_NUM_WORDS_RECIPE];
305 struct ice_pref_recipe_group r_group;
307 #endif /* _ICE_PROTOCOL_TYPE_H_ */