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 7 #define ICE_FV_OFFSET_INVAL 0x1FF 8 9 /* Extraction Sequence (Field Vector) Table */ 10 struct ice_fv_word { 11 u8 prot_id; 12 u16 off; /* Offset within the protocol header */ 13 u8 resvrd; 14 } __packed; 15 16 #define ICE_MAX_FV_WORDS 48 17 struct ice_fv { 18 struct ice_fv_word ew[ICE_MAX_FV_WORDS]; 19 }; 20 21 /* Package and segment headers and tables */ 22 struct ice_pkg_hdr { 23 struct ice_pkg_ver format_ver; 24 __le32 seg_count; 25 __le32 seg_offset[1]; 26 }; 27 28 /* generic segment */ 29 struct ice_generic_seg_hdr { 30 #define SEGMENT_TYPE_METADATA 0x00000001 31 #define SEGMENT_TYPE_ICE 0x00000010 32 __le32 seg_type; 33 struct ice_pkg_ver seg_ver; 34 __le32 seg_size; 35 char seg_name[ICE_PKG_NAME_SIZE]; 36 }; 37 38 /* ice specific segment */ 39 40 union ice_device_id { 41 struct { 42 __le16 device_id; 43 __le16 vendor_id; 44 } dev_vend_id; 45 __le32 id; 46 }; 47 48 struct ice_device_id_entry { 49 union ice_device_id device; 50 union ice_device_id sub_device; 51 }; 52 53 struct ice_seg { 54 struct ice_generic_seg_hdr hdr; 55 __le32 device_table_count; 56 struct ice_device_id_entry device_table[1]; 57 }; 58 59 struct ice_nvm_table { 60 __le32 table_count; 61 __le32 vers[1]; 62 }; 63 64 struct ice_buf { 65 #define ICE_PKG_BUF_SIZE 4096 66 u8 buf[ICE_PKG_BUF_SIZE]; 67 }; 68 69 struct ice_buf_table { 70 __le32 buf_count; 71 struct ice_buf buf_array[1]; 72 }; 73 74 /* global metadata specific segment */ 75 struct ice_global_metadata_seg { 76 struct ice_generic_seg_hdr hdr; 77 struct ice_pkg_ver pkg_ver; 78 __le32 track_id; 79 char pkg_name[ICE_PKG_NAME_SIZE]; 80 }; 81 82 #define ICE_MIN_S_OFF 12 83 #define ICE_MAX_S_OFF 4095 84 #define ICE_MIN_S_SZ 1 85 #define ICE_MAX_S_SZ 4084 86 87 /* section information */ 88 struct ice_section_entry { 89 __le32 type; 90 __le16 offset; 91 __le16 size; 92 }; 93 94 #define ICE_MIN_S_COUNT 1 95 #define ICE_MAX_S_COUNT 511 96 #define ICE_MIN_S_DATA_END 12 97 #define ICE_MAX_S_DATA_END 4096 98 99 #define ICE_METADATA_BUF 0x80000000 100 101 struct ice_buf_hdr { 102 __le16 section_count; 103 __le16 data_end; 104 struct ice_section_entry section_entry[1]; 105 }; 106 107 #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) ((ICE_PKG_BUF_SIZE - \ 108 sizeof(struct ice_buf_hdr) - (hd_sz)) / (ent_sz)) 109 110 /* ice package section IDs */ 111 #define ICE_SID_XLT1_SW 12 112 #define ICE_SID_XLT2_SW 13 113 #define ICE_SID_PROFID_TCAM_SW 14 114 #define ICE_SID_PROFID_REDIR_SW 15 115 #define ICE_SID_FLD_VEC_SW 16 116 117 #define ICE_SID_XLT1_ACL 22 118 #define ICE_SID_XLT2_ACL 23 119 #define ICE_SID_PROFID_TCAM_ACL 24 120 #define ICE_SID_PROFID_REDIR_ACL 25 121 #define ICE_SID_FLD_VEC_ACL 26 122 123 #define ICE_SID_XLT1_FD 32 124 #define ICE_SID_XLT2_FD 33 125 #define ICE_SID_PROFID_TCAM_FD 34 126 #define ICE_SID_PROFID_REDIR_FD 35 127 #define ICE_SID_FLD_VEC_FD 36 128 129 #define ICE_SID_XLT1_RSS 42 130 #define ICE_SID_XLT2_RSS 43 131 #define ICE_SID_PROFID_TCAM_RSS 44 132 #define ICE_SID_PROFID_REDIR_RSS 45 133 #define ICE_SID_FLD_VEC_RSS 46 134 135 #define ICE_SID_RXPARSER_BOOST_TCAM 56 136 137 #define ICE_SID_XLT1_PE 82 138 #define ICE_SID_XLT2_PE 83 139 #define ICE_SID_PROFID_TCAM_PE 84 140 #define ICE_SID_PROFID_REDIR_PE 85 141 #define ICE_SID_FLD_VEC_PE 86 142 143 /* Label Metadata section IDs */ 144 #define ICE_SID_LBL_FIRST 0x80000010 145 #define ICE_SID_LBL_RXPARSER_TMEM 0x80000018 146 /* The following define MUST be updated to reflect the last label section ID */ 147 #define ICE_SID_LBL_LAST 0x80000038 148 149 enum ice_block { 150 ICE_BLK_SW = 0, 151 ICE_BLK_ACL, 152 ICE_BLK_FD, 153 ICE_BLK_RSS, 154 ICE_BLK_PE, 155 ICE_BLK_COUNT 156 }; 157 158 /* package labels */ 159 struct ice_label { 160 __le16 value; 161 #define ICE_PKG_LABEL_SIZE 64 162 char name[ICE_PKG_LABEL_SIZE]; 163 }; 164 165 struct ice_label_section { 166 __le16 count; 167 struct ice_label label[1]; 168 }; 169 170 #define ICE_MAX_LABELS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \ 171 sizeof(struct ice_label_section) - sizeof(struct ice_label), \ 172 sizeof(struct ice_label)) 173 174 struct ice_sw_fv_section { 175 __le16 count; 176 __le16 base_offset; 177 struct ice_fv fv[1]; 178 }; 179 180 /* The BOOST TCAM stores the match packet header in reverse order, meaning 181 * the fields are reversed; in addition, this means that the normally big endian 182 * fields of the packet are now little endian. 183 */ 184 struct ice_boost_key_value { 185 #define ICE_BOOST_REMAINING_HV_KEY 15 186 u8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY]; 187 __le16 hv_dst_port_key; 188 __le16 hv_src_port_key; 189 u8 tcam_search_key; 190 } __packed; 191 192 struct ice_boost_key { 193 struct ice_boost_key_value key; 194 struct ice_boost_key_value key2; 195 }; 196 197 /* package Boost TCAM entry */ 198 struct ice_boost_tcam_entry { 199 __le16 addr; 200 __le16 reserved; 201 /* break up the 40 bytes of key into different fields */ 202 struct ice_boost_key key; 203 u8 boost_hit_index_group; 204 /* The following contains bitfields which are not on byte boundaries. 205 * These fields are currently unused by driver software. 206 */ 207 #define ICE_BOOST_BIT_FIELDS 43 208 u8 bit_fields[ICE_BOOST_BIT_FIELDS]; 209 }; 210 211 struct ice_boost_tcam_section { 212 __le16 count; 213 __le16 reserved; 214 struct ice_boost_tcam_entry tcam[1]; 215 }; 216 217 #define ICE_MAX_BST_TCAMS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \ 218 sizeof(struct ice_boost_tcam_section) - \ 219 sizeof(struct ice_boost_tcam_entry), \ 220 sizeof(struct ice_boost_tcam_entry)) 221 222 struct ice_xlt1_section { 223 __le16 count; 224 __le16 offset; 225 u8 value[1]; 226 } __packed; 227 228 struct ice_xlt2_section { 229 __le16 count; 230 __le16 offset; 231 __le16 value[1]; 232 }; 233 234 struct ice_prof_redir_section { 235 __le16 count; 236 __le16 offset; 237 u8 redir_value[1]; 238 }; 239 240 struct ice_pkg_enum { 241 struct ice_buf_table *buf_table; 242 u32 buf_idx; 243 244 u32 type; 245 struct ice_buf_hdr *buf; 246 u32 sect_idx; 247 void *sect; 248 u32 sect_type; 249 250 u32 entry_idx; 251 void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset); 252 }; 253 254 struct ice_es { 255 u32 sid; 256 u16 count; 257 u16 fvw; 258 u16 *ref_count; 259 struct list_head prof_map; 260 struct ice_fv_word *t; 261 struct mutex prof_map_lock; /* protect access to profiles list */ 262 u8 *written; 263 u8 reverse; /* set to true to reverse FV order */ 264 }; 265 266 /* PTYPE Group management */ 267 268 /* Note: XLT1 table takes 13-bit as input, and results in an 8-bit packet type 269 * group (PTG) ID as output. 270 * 271 * Note: PTG 0 is the default packet type group and it is assumed that all PTYPE 272 * are a part of this group until moved to a new PTG. 273 */ 274 #define ICE_DEFAULT_PTG 0 275 276 struct ice_ptg_entry { 277 struct ice_ptg_ptype *first_ptype; 278 u8 in_use; 279 }; 280 281 struct ice_ptg_ptype { 282 struct ice_ptg_ptype *next_ptype; 283 u8 ptg; 284 }; 285 286 #define ICE_MAX_PTG_PER_PROFILE 32 287 288 struct ice_prof_map { 289 struct list_head list; 290 u64 profile_cookie; 291 u64 context; 292 u8 prof_id; 293 u8 ptg_cnt; 294 u8 ptg[ICE_MAX_PTG_PER_PROFILE]; 295 }; 296 297 struct ice_vsig_entry { 298 struct list_head prop_lst; 299 struct ice_vsig_vsi *first_vsi; 300 u8 in_use; 301 }; 302 303 struct ice_vsig_vsi { 304 struct ice_vsig_vsi *next_vsi; 305 u32 prop_mask; 306 u16 changed; 307 u16 vsig; 308 }; 309 310 #define ICE_XLT1_CNT 1024 311 #define ICE_MAX_PTGS 256 312 313 /* XLT1 Table */ 314 struct ice_xlt1 { 315 struct ice_ptg_entry *ptg_tbl; 316 struct ice_ptg_ptype *ptypes; 317 u8 *t; 318 u32 sid; 319 u16 count; 320 }; 321 322 #define ICE_XLT2_CNT 768 323 #define ICE_MAX_VSIGS 768 324 325 /* VSIG bit layout: 326 * [0:12]: incremental VSIG index 1 to ICE_MAX_VSIGS 327 * [13:15]: PF number of device 328 */ 329 #define ICE_VSIG_IDX_M (0x1FFF) 330 #define ICE_PF_NUM_S 13 331 #define ICE_PF_NUM_M (0x07 << ICE_PF_NUM_S) 332 #define ICE_VSIG_VALUE(vsig, pf_id) \ 333 (u16)((((u16)(vsig)) & ICE_VSIG_IDX_M) | \ 334 (((u16)(pf_id) << ICE_PF_NUM_S) & ICE_PF_NUM_M)) 335 #define ICE_DEFAULT_VSIG 0 336 337 /* XLT2 Table */ 338 struct ice_xlt2 { 339 struct ice_vsig_entry *vsig_tbl; 340 struct ice_vsig_vsi *vsis; 341 u16 *t; 342 u32 sid; 343 u16 count; 344 }; 345 346 /* Keys are made up of two values, each one-half the size of the key. 347 * For TCAM, the entire key is 80 bits wide (or 2, 40-bit wide values) 348 */ 349 #define ICE_TCAM_KEY_VAL_SZ 5 350 #define ICE_TCAM_KEY_SZ (2 * ICE_TCAM_KEY_VAL_SZ) 351 352 struct ice_prof_tcam_entry { 353 __le16 addr; 354 u8 key[ICE_TCAM_KEY_SZ]; 355 u8 prof_id; 356 } __packed; 357 358 struct ice_prof_id_section { 359 __le16 count; 360 struct ice_prof_tcam_entry entry[1]; 361 } __packed; 362 363 struct ice_prof_tcam { 364 u32 sid; 365 u16 count; 366 u16 max_prof_id; 367 struct ice_prof_tcam_entry *t; 368 u8 cdid_bits; /* # CDID bits to use in key, 0, 2, 4, or 8 */ 369 }; 370 371 struct ice_prof_redir { 372 u8 *t; 373 u32 sid; 374 u16 count; 375 }; 376 377 /* Tables per block */ 378 struct ice_blk_info { 379 struct ice_xlt1 xlt1; 380 struct ice_xlt2 xlt2; 381 struct ice_prof_tcam prof; 382 struct ice_prof_redir prof_redir; 383 struct ice_es es; 384 u8 overwrite; /* set to true to allow overwrite of table entries */ 385 u8 is_list_init; 386 }; 387 388 #define ICE_FLOW_PTYPE_MAX ICE_XLT1_CNT 389 #endif /* _ICE_FLEX_TYPE_H_ */ 390