1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2019
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 {
49 enum ice_sw_tunnel_type {
55 ICE_SW_TUN_UDP, /* This means all "UDP" tunnel types: VXLAN-GPE, VXLAN
58 ICE_ALL_TUNNELS /* All tunnel types including NVGRE */
61 /* Decoders for ice_prot_id:
69 ICE_PROT_ID_INVAL = 0,
70 ICE_PROT_MAC_OF_OR_S = 1,
73 ICE_PROT_MAC_IN_MAC = 7,
74 ICE_PROT_ETYPE_OL = 9,
75 ICE_PROT_ETYPE_IL = 10,
77 ICE_PROT_EVLAN_O = 16,
79 ICE_PROT_VLAN_IF = 18,
80 ICE_PROT_MPLS_OL_MINUS_1 = 27,
81 ICE_PROT_MPLS_OL_OR_OS = 28,
82 ICE_PROT_MPLS_IL = 29,
83 ICE_PROT_IPV4_OF_OR_S = 32,
84 ICE_PROT_IPV4_IL = 33,
85 ICE_PROT_IPV6_OF_OR_S = 40,
86 ICE_PROT_IPV6_IL = 41,
87 ICE_PROT_IPV6_FRAG = 47,
90 ICE_PROT_UDP_IL_OR_S = 53,
95 ICE_PROT_SCTP_IL = 96,
96 ICE_PROT_ICMP_IL = 98,
97 ICE_PROT_ICMPV6_IL = 100,
98 ICE_PROT_VRRP_F = 101,
100 ICE_PROT_ATAOE_OF = 114,
101 ICE_PROT_CTRL_OF = 116,
102 ICE_PROT_LLDP_OF = 117,
103 ICE_PROT_ARP_OF = 118,
104 ICE_PROT_EAPOL_OF = 120,
105 ICE_PROT_META_ID = 255, /* when offset == metaddata */
106 ICE_PROT_INVALID = 255 /* when offset == 0xFF */
110 #define ICE_MAC_OFOS_HW 1
111 #define ICE_MAC_IL_HW 4
112 #define ICE_ETYPE_OL_HW 9
113 #define ICE_IPV4_OFOS_HW 32
114 #define ICE_IPV4_IL_HW 33
115 #define ICE_IPV6_OFOS_HW 40
116 #define ICE_IPV6_IL_HW 41
117 #define ICE_TCP_IL_HW 49
118 #define ICE_UDP_OF_HW 52
119 #define ICE_UDP_ILOS_HW 53
120 #define ICE_SCTP_IL_HW 96
122 /* ICE_UDP_OF is used to identify all 3 tunnel types
123 * VXLAN, GENEVE and VXLAN_GPE. To differentiate further
124 * need to use flags from the field vector
126 #define ICE_UDP_OF_HW 52 /* UDP Tunnels */
127 #define ICE_GRE_OF_HW 64 /* NVGRE */
128 #define ICE_META_DATA_ID_HW 255 /* this is used for tunnel type */
130 #define ICE_TUN_FLAG_MASK 0xFF
131 #define ICE_TUN_FLAG_FV_IND 2
133 #define ICE_PROTOCOL_MAX_ENTRIES 16
135 /* Mapping of software defined protocol ID to hardware defined protocol ID */
136 struct ice_protocol_entry {
137 enum ice_protocol_type type;
142 struct ice_ether_hdr {
143 u8 dst_addr[ETH_ALEN];
144 u8 src_addr[ETH_ALEN];
147 struct ice_ethtype_hdr {
151 struct ice_ether_vlan_hdr {
152 u8 dst_addr[ETH_ALEN];
153 u8 src_addr[ETH_ALEN];
157 struct ice_ipv4_hdr {
170 struct ice_ipv6_hdr {
177 u8 src_addr[ICE_IPV6_ADDR_LENGTH];
178 u8 dst_addr[ICE_IPV6_ADDR_LENGTH];
181 struct ice_sctp_hdr {
184 u32 verification_tag;
195 struct ice_udp_tnl_hdr {
198 u32 vni; /* only use lower 24-bits */
208 struct ice_ether_hdr eth_hdr;
209 struct ice_ethtype_hdr ethertype;
210 struct ice_ipv4_hdr ipv4_hdr;
211 struct ice_ipv6_hdr ipv6_hdr;
212 struct ice_l4_hdr l4_hdr;
213 struct ice_sctp_hdr sctp_hdr;
214 struct ice_udp_tnl_hdr tnl_hdr;
215 struct ice_nvgre nvgre_hdr;
218 /* This is mapping table entry that maps every word within a given protocol
219 * structure to the real byte offset as per the specification of that
221 * for e.g. dst address is 3 words in ethertype header and corresponding bytes
222 * are 0, 2, 3 in the actual packet header and src address is at 4, 6, 8
224 struct ice_prot_ext_tbl_entry {
225 enum ice_protocol_type prot_type;
226 /* Byte offset into header of given protocol type */
227 u8 offs[sizeof(union ice_prot_hdr)];
230 /* Extractions to be looked up for a given recipe */
231 struct ice_prot_lkup_ext {
234 /* create a buffer to hold max words per recipe */
235 u16 field_off[ICE_MAX_CHAIN_WORDS];
236 u16 field_mask[ICE_MAX_CHAIN_WORDS];
238 struct ice_fv_word fv_words[ICE_MAX_CHAIN_WORDS];
240 /* Indicate field offsets that have field vector indices assigned */
241 ice_declare_bitmap(done, ICE_MAX_CHAIN_WORDS);
244 struct ice_pref_recipe_group {
245 u8 n_val_pairs; /* Number of valid pairs */
246 struct ice_fv_word pairs[ICE_NUM_WORDS_RECIPE];
247 u16 mask[ICE_NUM_WORDS_RECIPE];
250 struct ice_recp_grp_entry {
251 struct LIST_ENTRY_TYPE l_entry;
253 #define ICE_INVAL_CHAIN_IND 0xFF
256 u16 fv_idx[ICE_NUM_WORDS_RECIPE];
257 u16 fv_mask[ICE_NUM_WORDS_RECIPE];
258 struct ice_pref_recipe_group r_group;
260 #endif /* _ICE_PROTOCOL_TYPE_H_ */