1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) 2019, Intel Corporation. */ 3 4 #ifndef _ICE_FLEX_TYPE_H_ 5 #define _ICE_FLEX_TYPE_H_ 6 #include "ice_ddp.h" 7 8 /* Packet Type (PTYPE) values */ 9 #define ICE_PTYPE_MAC_PAY 1 10 #define ICE_PTYPE_IPV4_PAY 23 11 #define ICE_PTYPE_IPV4_UDP_PAY 24 12 #define ICE_PTYPE_IPV4_TCP_PAY 26 13 #define ICE_PTYPE_IPV4_SCTP_PAY 27 14 #define ICE_PTYPE_IPV6_PAY 89 15 #define ICE_PTYPE_IPV6_UDP_PAY 90 16 #define ICE_PTYPE_IPV6_TCP_PAY 92 17 #define ICE_PTYPE_IPV6_SCTP_PAY 93 18 #define ICE_MAC_IPV4_ESP 160 19 #define ICE_MAC_IPV6_ESP 161 20 #define ICE_MAC_IPV4_AH 162 21 #define ICE_MAC_IPV6_AH 163 22 #define ICE_MAC_IPV4_NAT_T_ESP 164 23 #define ICE_MAC_IPV6_NAT_T_ESP 165 24 #define ICE_MAC_IPV4_GTPU 329 25 #define ICE_MAC_IPV6_GTPU 330 26 #define ICE_MAC_IPV4_GTPU_IPV4_FRAG 331 27 #define ICE_MAC_IPV4_GTPU_IPV4_PAY 332 28 #define ICE_MAC_IPV4_GTPU_IPV4_UDP_PAY 333 29 #define ICE_MAC_IPV4_GTPU_IPV4_TCP 334 30 #define ICE_MAC_IPV4_GTPU_IPV4_ICMP 335 31 #define ICE_MAC_IPV6_GTPU_IPV4_FRAG 336 32 #define ICE_MAC_IPV6_GTPU_IPV4_PAY 337 33 #define ICE_MAC_IPV6_GTPU_IPV4_UDP_PAY 338 34 #define ICE_MAC_IPV6_GTPU_IPV4_TCP 339 35 #define ICE_MAC_IPV6_GTPU_IPV4_ICMP 340 36 #define ICE_MAC_IPV4_GTPU_IPV6_FRAG 341 37 #define ICE_MAC_IPV4_GTPU_IPV6_PAY 342 38 #define ICE_MAC_IPV4_GTPU_IPV6_UDP_PAY 343 39 #define ICE_MAC_IPV4_GTPU_IPV6_TCP 344 40 #define ICE_MAC_IPV4_GTPU_IPV6_ICMPV6 345 41 #define ICE_MAC_IPV6_GTPU_IPV6_FRAG 346 42 #define ICE_MAC_IPV6_GTPU_IPV6_PAY 347 43 #define ICE_MAC_IPV6_GTPU_IPV6_UDP_PAY 348 44 #define ICE_MAC_IPV6_GTPU_IPV6_TCP 349 45 #define ICE_MAC_IPV6_GTPU_IPV6_ICMPV6 350 46 #define ICE_MAC_IPV4_PFCP_SESSION 352 47 #define ICE_MAC_IPV6_PFCP_SESSION 354 48 #define ICE_MAC_IPV4_L2TPV3 360 49 #define ICE_MAC_IPV6_L2TPV3 361 50 51 /* Attributes that can modify PTYPE definitions. 52 * 53 * These values will represent special attributes for PTYPEs, which will 54 * resolve into metadata packet flags definitions that can be used in the TCAM 55 * for identifying a PTYPE with specific characteristics. 56 */ 57 enum ice_ptype_attrib_type { 58 /* GTP PTYPEs */ 59 ICE_PTYPE_ATTR_GTP_PDU_EH, 60 ICE_PTYPE_ATTR_GTP_SESSION, 61 ICE_PTYPE_ATTR_GTP_DOWNLINK, 62 ICE_PTYPE_ATTR_GTP_UPLINK, 63 }; 64 65 struct ice_ptype_attrib_info { 66 u16 flags; 67 u16 mask; 68 }; 69 70 /* TCAM flag definitions */ 71 #define ICE_GTP_PDU BIT(14) 72 #define ICE_GTP_PDU_LINK BIT(13) 73 74 /* GTP attributes */ 75 #define ICE_GTP_PDU_FLAG_MASK (ICE_GTP_PDU) 76 #define ICE_GTP_PDU_EH ICE_GTP_PDU 77 78 #define ICE_GTP_FLAGS_MASK (ICE_GTP_PDU | ICE_GTP_PDU_LINK) 79 #define ICE_GTP_SESSION 0 80 #define ICE_GTP_DOWNLINK ICE_GTP_PDU 81 #define ICE_GTP_UPLINK (ICE_GTP_PDU | ICE_GTP_PDU_LINK) 82 83 struct ice_ptype_attributes { 84 u16 ptype; 85 enum ice_ptype_attrib_type attrib; 86 }; 87 88 /* Tunnel enabling */ 89 90 enum ice_tunnel_type { 91 TNL_VXLAN = 0, 92 TNL_GENEVE, 93 TNL_GRETAP, 94 TNL_GTPC, 95 TNL_GTPU, 96 TNL_PFCP, 97 __TNL_TYPE_CNT, 98 TNL_LAST = 0xFF, 99 TNL_ALL = 0xFF, 100 }; 101 102 struct ice_tunnel_type_scan { 103 enum ice_tunnel_type type; 104 const char *label_prefix; 105 }; 106 107 struct ice_tunnel_entry { 108 enum ice_tunnel_type type; 109 u16 boost_addr; 110 u16 port; 111 struct ice_boost_tcam_entry *boost_entry; 112 u8 valid; 113 }; 114 115 #define ICE_TUNNEL_MAX_ENTRIES 16 116 117 struct ice_tunnel_table { 118 struct ice_tunnel_entry tbl[ICE_TUNNEL_MAX_ENTRIES]; 119 u16 count; 120 u16 valid_count[__TNL_TYPE_CNT]; 121 }; 122 123 struct ice_dvm_entry { 124 u16 boost_addr; 125 u16 enable; 126 struct ice_boost_tcam_entry *boost_entry; 127 }; 128 129 #define ICE_DVM_MAX_ENTRIES 48 130 131 struct ice_dvm_table { 132 struct ice_dvm_entry tbl[ICE_DVM_MAX_ENTRIES]; 133 u16 count; 134 }; 135 136 struct ice_pkg_es { 137 __le16 count; 138 __le16 offset; 139 struct ice_fv_word es[]; 140 }; 141 142 struct ice_es { 143 u32 sid; 144 u16 count; 145 u16 fvw; 146 u16 *ref_count; 147 u32 *mask_ena; 148 struct list_head prof_map; 149 struct ice_fv_word *t; 150 u8 *symm; /* symmetric setting per profile (RSS blk)*/ 151 struct mutex prof_map_lock; /* protect access to profiles list */ 152 u8 *written; 153 u8 reverse; /* set to true to reverse FV order */ 154 }; 155 156 /* PTYPE Group management */ 157 158 /* Note: XLT1 table takes 13-bit as input, and results in an 8-bit packet type 159 * group (PTG) ID as output. 160 * 161 * Note: PTG 0 is the default packet type group and it is assumed that all PTYPE 162 * are a part of this group until moved to a new PTG. 163 */ 164 #define ICE_DEFAULT_PTG 0 165 166 struct ice_ptg_entry { 167 struct ice_ptg_ptype *first_ptype; 168 u8 in_use; 169 }; 170 171 struct ice_ptg_ptype { 172 struct ice_ptg_ptype *next_ptype; 173 u8 ptg; 174 }; 175 176 #define ICE_MAX_TCAM_PER_PROFILE 32 177 #define ICE_MAX_PTG_PER_PROFILE 32 178 179 struct ice_prof_map { 180 struct list_head list; 181 u64 profile_cookie; 182 u64 context; 183 u8 prof_id; 184 u8 ptg_cnt; 185 u8 ptg[ICE_MAX_PTG_PER_PROFILE]; 186 struct ice_ptype_attrib_info attr[ICE_MAX_PTG_PER_PROFILE]; 187 }; 188 189 #define ICE_INVALID_TCAM 0xFFFF 190 #define ICE_MAX_PTG_ATTRS 1024 191 192 struct ice_tcam_inf { 193 u16 tcam_idx; 194 struct ice_ptype_attrib_info attr; 195 u8 ptg; 196 u8 prof_id; 197 u8 in_use; 198 }; 199 200 struct ice_vsig_prof { 201 struct list_head list; 202 u64 profile_cookie; 203 u8 prof_id; 204 u8 tcam_count; 205 struct ice_tcam_inf tcam[ICE_MAX_TCAM_PER_PROFILE]; 206 }; 207 208 struct ice_vsig_entry { 209 struct list_head prop_lst; 210 struct ice_vsig_vsi *first_vsi; 211 u8 in_use; 212 }; 213 214 struct ice_vsig_vsi { 215 struct ice_vsig_vsi *next_vsi; 216 u32 prop_mask; 217 u16 changed; 218 u16 vsig; 219 }; 220 221 #define ICE_XLT1_CNT 1024 222 #define ICE_MAX_PTGS 256 223 224 /* XLT1 Table */ 225 struct ice_xlt1 { 226 struct ice_ptg_entry *ptg_tbl; 227 struct ice_ptg_ptype *ptypes; 228 u8 *t; 229 u32 sid; 230 u16 count; 231 }; 232 233 #define ICE_XLT2_CNT 768 234 #define ICE_MAX_VSIGS 768 235 236 /* VSIG bit layout: 237 * [0:12]: incremental VSIG index 1 to ICE_MAX_VSIGS 238 * [13:15]: PF number of device 239 */ 240 #define ICE_VSIG_IDX_M (0x1FFF) 241 #define ICE_PF_NUM_S 13 242 #define ICE_PF_NUM_M (0x07 << ICE_PF_NUM_S) 243 #define ICE_VSIG_VALUE(vsig, pf_id) \ 244 ((u16)((((u16)(vsig)) & ICE_VSIG_IDX_M) | \ 245 (((u16)(pf_id) << ICE_PF_NUM_S) & ICE_PF_NUM_M))) 246 #define ICE_DEFAULT_VSIG 0 247 248 /* XLT2 Table */ 249 struct ice_xlt2 { 250 struct ice_vsig_entry *vsig_tbl; 251 struct ice_vsig_vsi *vsis; 252 u16 *t; 253 u32 sid; 254 u16 count; 255 }; 256 257 /* Profile ID Management */ 258 struct ice_prof_id_key { 259 __le16 flags; 260 u8 xlt1; 261 __le16 xlt2_cdid; 262 } __packed; 263 264 /* Keys are made up of two values, each one-half the size of the key. 265 * For TCAM, the entire key is 80 bits wide (or 2, 40-bit wide values) 266 */ 267 #define ICE_TCAM_KEY_VAL_SZ 5 268 #define ICE_TCAM_KEY_SZ (2 * ICE_TCAM_KEY_VAL_SZ) 269 270 struct ice_prof_tcam_entry { 271 __le16 addr; 272 u8 key[ICE_TCAM_KEY_SZ]; 273 u8 prof_id; 274 } __packed; 275 276 struct ice_prof_id_section { 277 __le16 count; 278 struct ice_prof_tcam_entry entry[]; 279 }; 280 281 struct ice_prof_tcam { 282 u32 sid; 283 u16 count; 284 u16 max_prof_id; 285 struct ice_prof_tcam_entry *t; 286 u8 cdid_bits; /* # CDID bits to use in key, 0, 2, 4, or 8 */ 287 }; 288 289 struct ice_prof_redir { 290 u8 *t; 291 u32 sid; 292 u16 count; 293 }; 294 295 struct ice_mask { 296 u16 mask; /* 16-bit mask */ 297 u16 idx; /* index */ 298 u16 ref; /* reference count */ 299 u8 in_use; /* non-zero if used */ 300 }; 301 302 struct ice_masks { 303 struct mutex lock; /* lock to protect this structure */ 304 u16 first; /* first mask owned by the PF */ 305 u16 count; /* number of masks owned by the PF */ 306 #define ICE_PROF_MASK_COUNT 32 307 struct ice_mask masks[ICE_PROF_MASK_COUNT]; 308 }; 309 310 struct ice_prof_id { 311 unsigned long *id; 312 int count; 313 }; 314 315 /* Tables per block */ 316 struct ice_blk_info { 317 struct ice_xlt1 xlt1; 318 struct ice_xlt2 xlt2; 319 struct ice_prof_id prof_id; 320 struct ice_prof_tcam prof; 321 struct ice_prof_redir prof_redir; 322 struct ice_es es; 323 struct ice_masks masks; 324 u8 overwrite; /* set to true to allow overwrite of table entries */ 325 u8 is_list_init; 326 }; 327 328 enum ice_chg_type { 329 ICE_TCAM_NONE = 0, 330 ICE_PTG_ES_ADD, 331 ICE_TCAM_ADD, 332 ICE_VSIG_ADD, 333 ICE_VSIG_REM, 334 ICE_VSI_MOVE, 335 }; 336 337 struct ice_chs_chg { 338 struct list_head list_entry; 339 enum ice_chg_type type; 340 341 u8 add_ptg; 342 u8 add_vsig; 343 u8 add_tcam_idx; 344 u8 add_prof; 345 u16 ptype; 346 u8 ptg; 347 u8 prof_id; 348 u16 vsi; 349 u16 vsig; 350 u16 orig_vsig; 351 u16 tcam_idx; 352 struct ice_ptype_attrib_info attr; 353 }; 354 355 #define ICE_FLOW_PTYPE_MAX ICE_XLT1_CNT 356 357 enum ice_prof_type { 358 ICE_PROF_NON_TUN = 0x1, 359 ICE_PROF_TUN_UDP = 0x2, 360 ICE_PROF_TUN_GRE = 0x4, 361 ICE_PROF_TUN_GTPU = 0x8, 362 ICE_PROF_TUN_GTPC = 0x10, 363 ICE_PROF_TUN_PFCP = 0x20, 364 ICE_PROF_TUN_ALL = 0x3E, 365 ICE_PROF_ALL = 0xFF, 366 }; 367 368 /* Number of bits/bytes contained in meta init entry. Note, this should be a 369 * multiple of 32 bits. 370 */ 371 #define ICE_META_INIT_BITS 192 372 #define ICE_META_INIT_DW_CNT (ICE_META_INIT_BITS / (sizeof(__le32) * \ 373 BITS_PER_BYTE)) 374 375 /* The meta init Flag field starts at this bit */ 376 #define ICE_META_FLAGS_ST 123 377 378 /* The entry and bit to check for Double VLAN Mode (DVM) support */ 379 #define ICE_META_VLAN_MODE_ENTRY 0 380 #define ICE_META_FLAG_VLAN_MODE 60 381 #define ICE_META_VLAN_MODE_BIT (ICE_META_FLAGS_ST + \ 382 ICE_META_FLAG_VLAN_MODE) 383 384 struct ice_meta_init_entry { 385 __le32 bm[ICE_META_INIT_DW_CNT]; 386 }; 387 388 struct ice_meta_init_section { 389 __le16 count; 390 __le16 offset; 391 struct ice_meta_init_entry entry; 392 }; 393 #endif /* _ICE_FLEX_TYPE_H_ */ 394