1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2022, Intel Corporation. */
9 /* Package minimal version supported */
10 #define ICE_PKG_SUPP_VER_MAJ 1
11 #define ICE_PKG_SUPP_VER_MNR 3
13 /* Package format version */
14 #define ICE_PKG_FMT_VER_MAJ 1
15 #define ICE_PKG_FMT_VER_MNR 0
16 #define ICE_PKG_FMT_VER_UPD 0
17 #define ICE_PKG_FMT_VER_DFT 0
21 #define ICE_FV_OFFSET_INVAL 0x1FF
23 /* Extraction Sequence (Field Vector) Table */
26 u16 off; /* Offset within the protocol header */
30 #define ICE_MAX_NUM_PROFILES 256
32 #define ICE_MAX_FV_WORDS 48
34 struct ice_fv_word ew[ICE_MAX_FV_WORDS];
38 /* Indicates that this call to ice_init_pkg
39 * successfully loaded the requested DDP package
41 ICE_DDP_PKG_SUCCESS = 0,
43 /* Generic error for already loaded errors, it is mapped later to
44 * the more specific one (one of the next 3)
46 ICE_DDP_PKG_ALREADY_LOADED = -1,
48 /* Indicates that a DDP package of the same version has already been
49 * loaded onto the device by a previous call or by another PF
51 ICE_DDP_PKG_SAME_VERSION_ALREADY_LOADED = -2,
53 /* The device has a DDP package that is not supported by the driver */
54 ICE_DDP_PKG_ALREADY_LOADED_NOT_SUPPORTED = -3,
56 /* The device has a compatible package
57 * (but different from the request) already loaded
59 ICE_DDP_PKG_COMPATIBLE_ALREADY_LOADED = -4,
61 /* The firmware loaded on the device is not compatible with
62 * the DDP package loaded
64 ICE_DDP_PKG_FW_MISMATCH = -5,
66 /* The DDP package file is invalid */
67 ICE_DDP_PKG_INVALID_FILE = -6,
69 /* The version of the DDP package provided is higher than
72 ICE_DDP_PKG_FILE_VERSION_TOO_HIGH = -7,
74 /* The version of the DDP package provided is lower than the
77 ICE_DDP_PKG_FILE_VERSION_TOO_LOW = -8,
79 /* The signature of the DDP package file provided is invalid */
80 ICE_DDP_PKG_FILE_SIGNATURE_INVALID = -9,
82 /* The DDP package file security revision is too low and not
83 * supported by firmware
85 ICE_DDP_PKG_FILE_REVISION_TOO_LOW = -10,
87 /* An error occurred in firmware while loading the DDP package */
88 ICE_DDP_PKG_LOAD_ERROR = -11,
94 /* Package and segment headers and tables */
96 struct ice_pkg_ver pkg_format_ver;
101 /* generic segment */
102 struct ice_generic_seg_hdr {
103 #define SEGMENT_TYPE_METADATA 0x00000001
104 #define SEGMENT_TYPE_ICE 0x00000010
106 struct ice_pkg_ver seg_format_ver;
108 char seg_id[ICE_PKG_NAME_SIZE];
111 /* ice specific segment */
113 union ice_device_id {
121 struct ice_device_id_entry {
122 union ice_device_id device;
123 union ice_device_id sub_device;
127 struct ice_generic_seg_hdr hdr;
128 __le32 device_table_count;
129 struct ice_device_id_entry device_table[];
132 struct ice_nvm_table {
138 #define ICE_PKG_BUF_SIZE 4096
139 u8 buf[ICE_PKG_BUF_SIZE];
142 struct ice_buf_table {
144 struct ice_buf buf_array[];
147 struct ice_run_time_cfg_seg {
148 struct ice_generic_seg_hdr hdr;
150 struct ice_buf_table buf_table;
153 /* global metadata specific segment */
154 struct ice_global_metadata_seg {
155 struct ice_generic_seg_hdr hdr;
156 struct ice_pkg_ver pkg_ver;
158 char pkg_name[ICE_PKG_NAME_SIZE];
161 #define ICE_MIN_S_OFF 12
162 #define ICE_MAX_S_OFF 4095
163 #define ICE_MIN_S_SZ 1
164 #define ICE_MAX_S_SZ 4084
166 /* section information */
167 struct ice_section_entry {
173 #define ICE_MIN_S_COUNT 1
174 #define ICE_MAX_S_COUNT 511
175 #define ICE_MIN_S_DATA_END 12
176 #define ICE_MAX_S_DATA_END 4096
178 #define ICE_METADATA_BUF 0x80000000
181 __le16 section_count;
183 struct ice_section_entry section_entry[];
186 #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) \
187 ((ICE_PKG_BUF_SIZE - \
188 struct_size_t(struct ice_buf_hdr, section_entry, 1) - (hd_sz)) / \
191 /* ice package section IDs */
192 #define ICE_SID_METADATA 1
193 #define ICE_SID_XLT0_SW 10
194 #define ICE_SID_XLT_KEY_BUILDER_SW 11
195 #define ICE_SID_XLT1_SW 12
196 #define ICE_SID_XLT2_SW 13
197 #define ICE_SID_PROFID_TCAM_SW 14
198 #define ICE_SID_PROFID_REDIR_SW 15
199 #define ICE_SID_FLD_VEC_SW 16
200 #define ICE_SID_CDID_KEY_BUILDER_SW 17
202 struct ice_meta_sect {
203 struct ice_pkg_ver ver;
204 #define ICE_META_SECT_NAME_SIZE 28
205 char name[ICE_META_SECT_NAME_SIZE];
209 #define ICE_SID_CDID_REDIR_SW 18
211 #define ICE_SID_XLT0_ACL 20
212 #define ICE_SID_XLT_KEY_BUILDER_ACL 21
213 #define ICE_SID_XLT1_ACL 22
214 #define ICE_SID_XLT2_ACL 23
215 #define ICE_SID_PROFID_TCAM_ACL 24
216 #define ICE_SID_PROFID_REDIR_ACL 25
217 #define ICE_SID_FLD_VEC_ACL 26
218 #define ICE_SID_CDID_KEY_BUILDER_ACL 27
219 #define ICE_SID_CDID_REDIR_ACL 28
221 #define ICE_SID_XLT0_FD 30
222 #define ICE_SID_XLT_KEY_BUILDER_FD 31
223 #define ICE_SID_XLT1_FD 32
224 #define ICE_SID_XLT2_FD 33
225 #define ICE_SID_PROFID_TCAM_FD 34
226 #define ICE_SID_PROFID_REDIR_FD 35
227 #define ICE_SID_FLD_VEC_FD 36
228 #define ICE_SID_CDID_KEY_BUILDER_FD 37
229 #define ICE_SID_CDID_REDIR_FD 38
231 #define ICE_SID_XLT0_RSS 40
232 #define ICE_SID_XLT_KEY_BUILDER_RSS 41
233 #define ICE_SID_XLT1_RSS 42
234 #define ICE_SID_XLT2_RSS 43
235 #define ICE_SID_PROFID_TCAM_RSS 44
236 #define ICE_SID_PROFID_REDIR_RSS 45
237 #define ICE_SID_FLD_VEC_RSS 46
238 #define ICE_SID_CDID_KEY_BUILDER_RSS 47
239 #define ICE_SID_CDID_REDIR_RSS 48
241 #define ICE_SID_RXPARSER_MARKER_PTYPE 55
242 #define ICE_SID_RXPARSER_BOOST_TCAM 56
243 #define ICE_SID_RXPARSER_METADATA_INIT 58
244 #define ICE_SID_TXPARSER_BOOST_TCAM 66
246 #define ICE_SID_XLT0_PE 80
247 #define ICE_SID_XLT_KEY_BUILDER_PE 81
248 #define ICE_SID_XLT1_PE 82
249 #define ICE_SID_XLT2_PE 83
250 #define ICE_SID_PROFID_TCAM_PE 84
251 #define ICE_SID_PROFID_REDIR_PE 85
252 #define ICE_SID_FLD_VEC_PE 86
253 #define ICE_SID_CDID_KEY_BUILDER_PE 87
254 #define ICE_SID_CDID_REDIR_PE 88
256 /* Label Metadata section IDs */
257 #define ICE_SID_LBL_FIRST 0x80000010
258 #define ICE_SID_LBL_RXPARSER_TMEM 0x80000018
259 /* The following define MUST be updated to reflect the last label section ID */
260 #define ICE_SID_LBL_LAST 0x80000038
262 /* Label ICE runtime configuration section IDs */
263 #define ICE_SID_TX_5_LAYER_TOPO 0x10
290 #define ICE_PKG_LABEL_SIZE 64
291 char name[ICE_PKG_LABEL_SIZE];
294 struct ice_label_section {
296 struct ice_label label[];
299 #define ICE_MAX_LABELS_IN_BUF \
300 ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_label_section, \
302 sizeof(struct ice_label), \
303 sizeof(struct ice_label))
305 struct ice_sw_fv_section {
311 struct ice_sw_fv_list_entry {
312 struct list_head list_entry;
314 struct ice_fv *fv_ptr;
317 /* The BOOST TCAM stores the match packet header in reverse order, meaning
318 * the fields are reversed; in addition, this means that the normally big endian
319 * fields of the packet are now little endian.
321 struct ice_boost_key_value {
322 #define ICE_BOOST_REMAINING_HV_KEY 15
323 u8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY];
324 __le16 hv_dst_port_key;
325 __le16 hv_src_port_key;
329 struct ice_boost_key {
330 struct ice_boost_key_value key;
331 struct ice_boost_key_value key2;
334 /* package Boost TCAM entry */
335 struct ice_boost_tcam_entry {
338 /* break up the 40 bytes of key into different fields */
339 struct ice_boost_key key;
340 u8 boost_hit_index_group;
341 /* The following contains bitfields which are not on byte boundaries.
342 * These fields are currently unused by driver software.
344 #define ICE_BOOST_BIT_FIELDS 43
345 u8 bit_fields[ICE_BOOST_BIT_FIELDS];
348 struct ice_boost_tcam_section {
351 struct ice_boost_tcam_entry tcam[];
354 #define ICE_MAX_BST_TCAMS_IN_BUF \
355 ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_boost_tcam_section, \
357 sizeof(struct ice_boost_tcam_entry), \
358 sizeof(struct ice_boost_tcam_entry))
360 /* package Marker Ptype TCAM entry */
361 struct ice_marker_ptype_tcam_entry {
362 #define ICE_MARKER_PTYPE_TCAM_ADDR_MAX 1024
368 struct ice_marker_ptype_tcam_section {
371 struct ice_marker_ptype_tcam_entry tcam[];
374 #define ICE_MAX_MARKER_PTYPE_TCAMS_IN_BUF \
375 ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_marker_ptype_tcam_section, tcam, \
377 sizeof(struct ice_marker_ptype_tcam_entry), \
378 sizeof(struct ice_marker_ptype_tcam_entry))
380 struct ice_xlt1_section {
386 struct ice_xlt2_section {
392 struct ice_prof_redir_section {
398 /* package buffer building */
400 struct ice_buf_build {
402 u16 reserved_section_table_entries;
405 struct ice_pkg_enum {
406 struct ice_buf_table *buf_table;
410 struct ice_buf_hdr *buf;
416 void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);
419 int ice_aq_upload_section(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf,
420 u16 buf_size, struct ice_sq_cd *cd);
422 void *ice_pkg_buf_alloc_section(struct ice_buf_build *bld, u32 type, u16 size);
424 struct ice_buf_build *ice_pkg_buf_alloc(struct ice_hw *hw);
426 int ice_update_pkg_no_lock(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
427 int ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
429 int ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count);
430 u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld);
431 void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,