1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2019, Intel Corporation. */
4 #ifndef _ICE_PROTOCOL_TYPE_H_
5 #define _ICE_PROTOCOL_TYPE_H_
6 #define ICE_IPV6_ADDR_LENGTH 16
8 /* Each recipe can match up to 5 different fields. Fields to match can be meta-
9 * data, values extracted from packet headers, or results from other recipes.
10 * One of the 5 fields is reserved for matching the switch ID. So, up to 4
11 * recipes can provide intermediate results to another one through chaining,
12 * e.g. recipes 0, 1, 2, and 3 can provide intermediate results to recipe 4.
14 #define ICE_NUM_WORDS_RECIPE 4
16 /* Max recipes that can be chained */
17 #define ICE_MAX_CHAIN_RECIPE 5
19 /* 1 word reserved for switch ID from allowed 5 words.
20 * So a recipe can have max 4 words. And you can chain 5 such recipes
21 * together. So maximum words that can be programmed for look up is 5 * 4.
23 #define ICE_MAX_CHAIN_WORDS (ICE_NUM_WORDS_RECIPE * ICE_MAX_CHAIN_RECIPE)
25 /* Field vector index corresponding to chaining */
26 #define ICE_CHAIN_FV_INDEX_START 47
28 enum ice_protocol_type {
54 enum ice_sw_tunnel_type {
56 ICE_SW_TUN_AND_NON_TUN,
62 ICE_ALL_TUNNELS /* All tunnel types including NVGRE */
65 /* Decoders for ice_prot_id:
73 ICE_PROT_ID_INVAL = 0,
74 ICE_PROT_MAC_OF_OR_S = 1,
76 ICE_PROT_ETYPE_OL = 9,
77 ICE_PROT_ETYPE_IL = 10,
78 ICE_PROT_IPV4_OF_OR_S = 32,
79 ICE_PROT_IPV4_IL = 33,
80 ICE_PROT_IPV6_OF_OR_S = 40,
81 ICE_PROT_IPV6_IL = 41,
84 ICE_PROT_UDP_IL_OR_S = 53,
88 ICE_PROT_SCTP_IL = 96,
89 ICE_PROT_ICMP_IL = 98,
90 ICE_PROT_ICMPV6_IL = 100,
92 ICE_PROT_L2TPV3 = 104,
93 ICE_PROT_ARP_OF = 118,
94 ICE_PROT_META_ID = 255, /* when offset == metadata */
95 ICE_PROT_INVALID = 255 /* when offset == ICE_FV_OFFSET_INVAL */
98 #define ICE_VNI_OFFSET 12 /* offset of VNI from ICE_PROT_UDP_OF */
100 #define ICE_MAC_OFOS_HW 1
101 #define ICE_MAC_IL_HW 4
102 #define ICE_ETYPE_OL_HW 9
103 #define ICE_ETYPE_IL_HW 10
104 #define ICE_VLAN_OF_HW 16
105 #define ICE_VLAN_OL_HW 17
106 #define ICE_IPV4_OFOS_HW 32
107 #define ICE_IPV4_IL_HW 33
108 #define ICE_IPV6_OFOS_HW 40
109 #define ICE_IPV6_IL_HW 41
110 #define ICE_TCP_IL_HW 49
111 #define ICE_UDP_ILOS_HW 53
112 #define ICE_GRE_OF_HW 64
113 #define ICE_PPPOE_HW 103
115 #define ICE_UDP_OF_HW 52 /* UDP Tunnels */
116 #define ICE_META_DATA_ID_HW 255 /* this is used for tunnel and VLAN type */
118 #define ICE_MDID_SIZE 2
120 #define ICE_TUN_FLAG_MDID 21
121 #define ICE_TUN_FLAG_MDID_OFF (ICE_MDID_SIZE * ICE_TUN_FLAG_MDID)
122 #define ICE_TUN_FLAG_MASK 0xFF
124 #define ICE_VLAN_FLAG_MDID 20
125 #define ICE_VLAN_FLAG_MDID_OFF (ICE_MDID_SIZE * ICE_VLAN_FLAG_MDID)
126 #define ICE_PKT_FLAGS_0_TO_15_VLAN_FLAGS_MASK 0xD000
128 #define ICE_TUN_FLAG_FV_IND 2
130 /* Mapping of software defined protocol ID to hardware defined protocol ID */
131 struct ice_protocol_entry {
132 enum ice_protocol_type type;
136 struct ice_ether_hdr {
137 u8 dst_addr[ETH_ALEN];
138 u8 src_addr[ETH_ALEN];
141 struct ice_ethtype_hdr {
145 struct ice_ether_vlan_hdr {
146 u8 dst_addr[ETH_ALEN];
147 u8 src_addr[ETH_ALEN];
151 struct ice_vlan_hdr {
156 struct ice_ipv4_hdr {
169 struct ice_ipv6_hdr {
170 __be32 be_ver_tc_flow;
174 u8 src_addr[ICE_IPV6_ADDR_LENGTH];
175 u8 dst_addr[ICE_IPV6_ADDR_LENGTH];
178 struct ice_sctp_hdr {
181 __be32 verification_tag;
192 struct ice_udp_tnl_hdr {
195 __be32 vni; /* only use lower 24-bits */
198 struct ice_udp_gtp_hdr {
203 __be16 rsrvd_seq_nbr;
212 struct ice_pppoe_hdr {
217 __be16 ppp_prot_id; /* control and data only */
220 struct ice_nvgre_hdr {
227 struct ice_ether_hdr eth_hdr;
228 struct ice_ethtype_hdr ethertype;
229 struct ice_vlan_hdr vlan_hdr;
230 struct ice_ipv4_hdr ipv4_hdr;
231 struct ice_ipv6_hdr ipv6_hdr;
232 struct ice_l4_hdr l4_hdr;
233 struct ice_sctp_hdr sctp_hdr;
234 struct ice_udp_tnl_hdr tnl_hdr;
235 struct ice_nvgre_hdr nvgre_hdr;
236 struct ice_udp_gtp_hdr gtp_hdr;
237 struct ice_pppoe_hdr pppoe_hdr;
240 /* This is mapping table entry that maps every word within a given protocol
241 * structure to the real byte offset as per the specification of that
243 * for e.g. dst address is 3 words in ethertype header and corresponding bytes
244 * are 0, 2, 3 in the actual packet header and src address is at 4, 6, 8
246 struct ice_prot_ext_tbl_entry {
247 enum ice_protocol_type prot_type;
248 /* Byte offset into header of given protocol type */
249 u8 offs[sizeof(union ice_prot_hdr)];
252 /* Extractions to be looked up for a given recipe */
253 struct ice_prot_lkup_ext {
256 /* create a buffer to hold max words per recipe */
257 u16 field_off[ICE_MAX_CHAIN_WORDS];
258 u16 field_mask[ICE_MAX_CHAIN_WORDS];
260 struct ice_fv_word fv_words[ICE_MAX_CHAIN_WORDS];
262 /* Indicate field offsets that have field vector indices assigned */
263 DECLARE_BITMAP(done, ICE_MAX_CHAIN_WORDS);
266 struct ice_pref_recipe_group {
267 u8 n_val_pairs; /* Number of valid pairs */
268 struct ice_fv_word pairs[ICE_NUM_WORDS_RECIPE];
269 u16 mask[ICE_NUM_WORDS_RECIPE];
272 struct ice_recp_grp_entry {
273 struct list_head l_entry;
275 #define ICE_INVAL_CHAIN_IND 0xFF
278 u16 fv_idx[ICE_NUM_WORDS_RECIPE];
279 u16 fv_mask[ICE_NUM_WORDS_RECIPE];
280 struct ice_pref_recipe_group r_group;
282 #endif /* _ICE_PROTOCOL_TYPE_H_ */