1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2021 Intel Corporation
5 #ifndef _ICE_PROTOCOL_TYPE_H_
6 #define _ICE_PROTOCOL_TYPE_H_
7 #include "ice_flex_type.h"
8 #define ICE_IPV6_ADDR_LENGTH 16
10 /* Each recipe can match up to 5 different fields. Fields to match can be meta-
11 * data, values extracted from packet headers, or results from other recipes.
12 * One of the 5 fields is reserved for matching the switch ID. So, up to 4
13 * recipes can provide intermediate results to another one through chaining,
14 * e.g. recipes 0, 1, 2, and 3 can provide intermediate results to recipe 4.
16 #define ICE_NUM_WORDS_RECIPE 4
18 /* Max recipes that can be chained */
19 #define ICE_MAX_CHAIN_RECIPE 5
21 /* 1 word reserved for switch ID from allowed 5 words.
22 * So a recipe can have max 4 words. And you can chain 5 such recipes
23 * together. So maximum words that can be programmed for look up is 5 * 4.
25 #define ICE_MAX_CHAIN_WORDS (ICE_NUM_WORDS_RECIPE * ICE_MAX_CHAIN_RECIPE)
27 /* Field vector index corresponding to chaining */
28 #define ICE_CHAIN_FV_INDEX_START 47
30 enum ice_protocol_type {
60 enum ice_sw_tunnel_type {
62 ICE_SW_TUN_AND_NON_TUN,
64 ICE_SW_TUN_GENEVE, /* GENEVE matches only non-VLAN pkts */
65 ICE_SW_TUN_GENEVE_VLAN, /* GENEVE matches both VLAN and non-VLAN pkts */
66 ICE_SW_TUN_VXLAN, /* VXLAN matches only non-VLAN pkts */
67 ICE_SW_TUN_VXLAN_VLAN, /* VXLAN matches both VLAN and non-VLAN pkts */
69 ICE_SW_TUN_UDP, /* This means all "UDP" tunnel types: VXLAN-GPE, VXLAN
77 ICE_SW_TUN_IPV4_GTPU_NO_PAY,
78 ICE_SW_TUN_IPV6_GTPU_NO_PAY,
81 ICE_SW_TUN_PPPOE_IPV4,
82 ICE_SW_TUN_PPPOE_IPV4_TCP,
83 ICE_SW_TUN_PPPOE_IPV4_UDP,
84 ICE_SW_TUN_PPPOE_IPV6,
85 ICE_SW_TUN_PPPOE_IPV6_TCP,
86 ICE_SW_TUN_PPPOE_IPV6_UDP,
91 ICE_SW_TUN_IPV4_NAT_T,
92 ICE_SW_TUN_IPV6_NAT_T,
93 ICE_SW_TUN_IPV4_L2TPV3,
94 ICE_SW_TUN_IPV6_L2TPV3,
95 ICE_SW_TUN_PROFID_IPV6_ESP,
96 ICE_SW_TUN_PROFID_IPV6_AH,
97 ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3,
98 ICE_SW_TUN_PROFID_IPV6_NAT_T,
99 ICE_SW_TUN_PROFID_IPV4_PFCP_NODE,
100 ICE_SW_TUN_PROFID_IPV4_PFCP_SESSION,
101 ICE_SW_TUN_PROFID_IPV6_PFCP_NODE,
102 ICE_SW_TUN_PROFID_IPV6_PFCP_SESSION,
103 ICE_SW_TUN_AND_NON_TUN_QINQ,
105 ICE_SW_TUN_PPPOE_QINQ,
106 ICE_SW_TUN_PPPOE_PAY_QINQ,
107 ICE_SW_TUN_PPPOE_IPV4_QINQ,
108 ICE_SW_TUN_PPPOE_IPV6_QINQ,
109 ICE_SW_TUN_IPV4_GTPU_IPV4,
110 ICE_SW_TUN_IPV4_GTPU_IPV6,
111 ICE_SW_TUN_IPV6_GTPU_IPV4,
112 ICE_SW_TUN_IPV6_GTPU_IPV6,
115 ICE_ALL_TUNNELS /* All tunnel types including NVGRE */
118 /* Decoders for ice_prot_id:
126 ICE_PROT_ID_INVAL = 0,
127 ICE_PROT_MAC_OF_OR_S = 1,
130 ICE_PROT_MAC_IN_MAC = 7,
131 ICE_PROT_ETYPE_OL = 9,
132 ICE_PROT_ETYPE_IL = 10,
134 ICE_PROT_EVLAN_O = 16,
135 ICE_PROT_VLAN_O = 17,
136 ICE_PROT_VLAN_IF = 18,
137 ICE_PROT_MPLS_OL_MINUS_1 = 27,
138 ICE_PROT_MPLS_OL_OR_OS = 28,
139 ICE_PROT_MPLS_IL = 29,
140 ICE_PROT_IPV4_OF_OR_S = 32,
141 ICE_PROT_IPV4_IL = 33,
142 ICE_PROT_IPV6_OF_OR_S = 40,
143 ICE_PROT_IPV6_IL = 41,
144 ICE_PROT_IPV6_FRAG = 47,
145 ICE_PROT_TCP_IL = 49,
146 ICE_PROT_UDP_OF = 52,
147 ICE_PROT_UDP_IL_OR_S = 53,
148 ICE_PROT_GRE_OF = 64,
152 ICE_PROT_SCTP_IL = 96,
153 ICE_PROT_ICMP_IL = 98,
154 ICE_PROT_ICMPV6_IL = 100,
155 ICE_PROT_VRRP_F = 101,
157 ICE_PROT_PPPOE = 103,
158 ICE_PROT_L2TPV3 = 104,
159 ICE_PROT_ECPRI = 105,
161 ICE_PROT_ATAOE_OF = 114,
162 ICE_PROT_CTRL_OF = 116,
163 ICE_PROT_LLDP_OF = 117,
164 ICE_PROT_ARP_OF = 118,
165 ICE_PROT_EAPOL_OF = 120,
166 ICE_PROT_META_ID = 255, /* when offset == metaddata */
167 ICE_PROT_INVALID = 255 /* when offset == ICE_FV_OFFSET_INVAL */
170 #define ICE_VNI_OFFSET 12 /* offset of VNI from ICE_PROT_UDP_OF */
172 #define ICE_MAC_OFOS_HW 1
173 #define ICE_MAC_IL_HW 4
174 #define ICE_ETYPE_OL_HW 9
175 #define ICE_VLAN_OF_HW 16
176 #define ICE_VLAN_OL_HW 17
177 #define ICE_IPV4_OFOS_HW 32
178 #define ICE_IPV4_IL_HW 33
179 #define ICE_IPV6_OFOS_HW 40
180 #define ICE_IPV6_IL_HW 41
181 #define ICE_TCP_IL_HW 49
182 #define ICE_UDP_ILOS_HW 53
183 #define ICE_ESP_HW 88
185 #define ICE_SCTP_IL_HW 96
186 #define ICE_PPPOE_HW 103
187 #define ICE_L2TPV3_HW 104
189 /* ICE_UDP_OF is used to identify all 3 tunnel types
190 * VXLAN, GENEVE and VXLAN_GPE. To differentiate further
191 * need to use flags from the field vector
193 #define ICE_UDP_OF_HW 52 /* UDP Tunnels */
194 #define ICE_GRE_OF_HW 64 /* NVGRE */
195 #define ICE_META_DATA_ID_HW 255 /* this is used for tunnel type */
197 #define ICE_MDID_SIZE 2
198 #define ICE_TUN_FLAG_MDID 21
199 #define ICE_TUN_FLAG_MDID_OFF (ICE_MDID_SIZE * ICE_TUN_FLAG_MDID)
200 #define ICE_TUN_FLAG_MASK 0xFF
201 #define ICE_TUN_FLAG_VLAN_MASK 0x01
202 #define ICE_TUN_FLAG_FV_IND 2
204 #define ICE_PROTOCOL_MAX_ENTRIES 16
206 /* Mapping of software defined protocol ID to hardware defined protocol ID */
207 struct ice_protocol_entry {
208 enum ice_protocol_type type;
212 struct ice_ether_hdr {
213 u8 dst_addr[ETH_ALEN];
214 u8 src_addr[ETH_ALEN];
217 struct ice_ethtype_hdr {
221 struct ice_ether_vlan_hdr {
222 u8 dst_addr[ETH_ALEN];
223 u8 src_addr[ETH_ALEN];
227 struct ice_vlan_hdr {
232 struct ice_ipv4_hdr {
245 struct ice_le_ver_tc_flow {
256 struct ice_ipv6_hdr {
257 __be32 be_ver_tc_flow;
261 u8 src_addr[ICE_IPV6_ADDR_LENGTH];
262 u8 dst_addr[ICE_IPV6_ADDR_LENGTH];
265 struct ice_sctp_hdr {
268 __be32 verification_tag;
279 struct ice_udp_tnl_hdr {
282 __be32 vni; /* only use lower 24-bits */
285 struct ice_udp_gtp_hdr {
290 __be16 rsrvd_seq_nbr;
299 struct ice_pppoe_hdr {
304 __be16 ppp_prot_id; /* control and data only */
307 struct ice_pfcp_hdr {
316 struct ice_l2tpv3_sess_hdr {
334 struct ice_nat_t_hdr {
335 struct ice_esp_hdr esp;
345 struct ice_ether_hdr eth_hdr;
346 struct ice_ethtype_hdr ethertype;
347 struct ice_vlan_hdr vlan_hdr;
348 struct ice_ipv4_hdr ipv4_hdr;
349 struct ice_ipv6_hdr ipv6_hdr;
350 struct ice_l4_hdr l4_hdr;
351 struct ice_sctp_hdr sctp_hdr;
352 struct ice_udp_tnl_hdr tnl_hdr;
353 struct ice_nvgre nvgre_hdr;
354 struct ice_udp_gtp_hdr gtp_hdr;
355 struct ice_pppoe_hdr pppoe_hdr;
356 struct ice_pfcp_hdr pfcp_hdr;
357 struct ice_l2tpv3_sess_hdr l2tpv3_sess_hdr;
358 struct ice_esp_hdr esp_hdr;
359 struct ice_ah_hdr ah_hdr;
360 struct ice_nat_t_hdr nat_t_hdr;
363 /* This is mapping table entry that maps every word within a given protocol
364 * structure to the real byte offset as per the specification of that
366 * for e.g. dst address is 3 words in ethertype header and corresponding bytes
367 * are 0, 2, 3 in the actual packet header and src address is at 4, 6, 8
369 struct ice_prot_ext_tbl_entry {
370 enum ice_protocol_type prot_type;
371 /* Byte offset into header of given protocol type */
372 u8 offs[sizeof(union ice_prot_hdr)];
375 /* Extractions to be looked up for a given recipe */
376 struct ice_prot_lkup_ext {
379 /* create a buffer to hold max words per recipe */
380 u16 field_off[ICE_MAX_CHAIN_WORDS];
381 u16 field_mask[ICE_MAX_CHAIN_WORDS];
383 struct ice_fv_word fv_words[ICE_MAX_CHAIN_WORDS];
385 /* Indicate field offsets that have field vector indices assigned */
386 ice_declare_bitmap(done, ICE_MAX_CHAIN_WORDS);
389 struct ice_pref_recipe_group {
390 u8 n_val_pairs; /* Number of valid pairs */
391 struct ice_fv_word pairs[ICE_NUM_WORDS_RECIPE];
392 u16 mask[ICE_NUM_WORDS_RECIPE];
395 struct ice_recp_grp_entry {
396 struct LIST_ENTRY_TYPE l_entry;
398 #define ICE_INVAL_CHAIN_IND 0xFF
401 u16 fv_idx[ICE_NUM_WORDS_RECIPE];
402 u16 fv_mask[ICE_NUM_WORDS_RECIPE];
403 struct ice_pref_recipe_group r_group;
405 #endif /* _ICE_PROTOCOL_TYPE_H_ */