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 /* Package signing algorithm types */
102 #define SEGMENT_SIGN_TYPE_INVALID 0x00000000
103 #define SEGMENT_SIGN_TYPE_RSA2K 0x00000001
104 #define SEGMENT_SIGN_TYPE_RSA3K 0x00000002
105 #define SEGMENT_SIGN_TYPE_RSA3K_SBB 0x00000003 /* Secure Boot Block */
106 #define SEGMENT_SIGN_TYPE_RSA3K_E825 0x00000005
108 /* generic segment */
109 struct ice_generic_seg_hdr {
110 #define SEGMENT_TYPE_INVALID 0x00000000
111 #define SEGMENT_TYPE_METADATA 0x00000001
112 #define SEGMENT_TYPE_ICE_E810 0x00000010
113 #define SEGMENT_TYPE_SIGNING 0x00001001
114 #define SEGMENT_TYPE_ICE_RUN_TIME_CFG 0x00000020
115 #define SEGMENT_TYPE_ICE_E830 0x00000017
117 struct ice_pkg_ver seg_format_ver;
119 char seg_id[ICE_PKG_NAME_SIZE];
122 /* ice specific segment */
124 union ice_device_id {
132 struct ice_device_id_entry {
133 union ice_device_id device;
134 union ice_device_id sub_device;
138 struct ice_generic_seg_hdr hdr;
139 __le32 device_table_count;
140 struct ice_device_id_entry device_table[];
143 struct ice_nvm_table {
149 #define ICE_PKG_BUF_SIZE 4096
150 u8 buf[ICE_PKG_BUF_SIZE];
153 struct ice_buf_table {
155 struct ice_buf buf_array[];
158 struct ice_run_time_cfg_seg {
159 struct ice_generic_seg_hdr hdr;
161 struct ice_buf_table buf_table;
164 /* global metadata specific segment */
165 struct ice_global_metadata_seg {
166 struct ice_generic_seg_hdr hdr;
167 struct ice_pkg_ver pkg_ver;
169 char pkg_name[ICE_PKG_NAME_SIZE];
172 #define ICE_MIN_S_OFF 12
173 #define ICE_MAX_S_OFF 4095
174 #define ICE_MIN_S_SZ 1
175 #define ICE_MAX_S_SZ 4084
177 struct ice_sign_seg {
178 struct ice_generic_seg_hdr hdr;
181 __le32 signed_seg_idx;
182 __le32 signed_buf_start;
183 __le32 signed_buf_count;
184 #define ICE_SIGN_SEG_FLAGS_VALID 0x80000000
185 #define ICE_SIGN_SEG_FLAGS_LAST 0x00000001
187 #define ICE_SIGN_SEG_RESERVED_COUNT 40
188 u8 reserved[ICE_SIGN_SEG_RESERVED_COUNT];
189 struct ice_buf_table buf_tbl;
192 /* section information */
193 struct ice_section_entry {
199 #define ICE_MIN_S_COUNT 1
200 #define ICE_MAX_S_COUNT 511
201 #define ICE_MIN_S_DATA_END 12
202 #define ICE_MAX_S_DATA_END 4096
204 #define ICE_METADATA_BUF 0x80000000
207 __le16 section_count;
209 struct ice_section_entry section_entry[];
212 #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) \
213 ((ICE_PKG_BUF_SIZE - \
214 struct_size_t(struct ice_buf_hdr, section_entry, 1) - (hd_sz)) / \
217 /* ice package section IDs */
218 #define ICE_SID_METADATA 1
219 #define ICE_SID_XLT0_SW 10
220 #define ICE_SID_XLT_KEY_BUILDER_SW 11
221 #define ICE_SID_XLT1_SW 12
222 #define ICE_SID_XLT2_SW 13
223 #define ICE_SID_PROFID_TCAM_SW 14
224 #define ICE_SID_PROFID_REDIR_SW 15
225 #define ICE_SID_FLD_VEC_SW 16
226 #define ICE_SID_CDID_KEY_BUILDER_SW 17
228 struct ice_meta_sect {
229 struct ice_pkg_ver ver;
230 #define ICE_META_SECT_NAME_SIZE 28
231 char name[ICE_META_SECT_NAME_SIZE];
235 #define ICE_SID_CDID_REDIR_SW 18
237 #define ICE_SID_XLT0_ACL 20
238 #define ICE_SID_XLT_KEY_BUILDER_ACL 21
239 #define ICE_SID_XLT1_ACL 22
240 #define ICE_SID_XLT2_ACL 23
241 #define ICE_SID_PROFID_TCAM_ACL 24
242 #define ICE_SID_PROFID_REDIR_ACL 25
243 #define ICE_SID_FLD_VEC_ACL 26
244 #define ICE_SID_CDID_KEY_BUILDER_ACL 27
245 #define ICE_SID_CDID_REDIR_ACL 28
247 #define ICE_SID_XLT0_FD 30
248 #define ICE_SID_XLT_KEY_BUILDER_FD 31
249 #define ICE_SID_XLT1_FD 32
250 #define ICE_SID_XLT2_FD 33
251 #define ICE_SID_PROFID_TCAM_FD 34
252 #define ICE_SID_PROFID_REDIR_FD 35
253 #define ICE_SID_FLD_VEC_FD 36
254 #define ICE_SID_CDID_KEY_BUILDER_FD 37
255 #define ICE_SID_CDID_REDIR_FD 38
257 #define ICE_SID_XLT0_RSS 40
258 #define ICE_SID_XLT_KEY_BUILDER_RSS 41
259 #define ICE_SID_XLT1_RSS 42
260 #define ICE_SID_XLT2_RSS 43
261 #define ICE_SID_PROFID_TCAM_RSS 44
262 #define ICE_SID_PROFID_REDIR_RSS 45
263 #define ICE_SID_FLD_VEC_RSS 46
264 #define ICE_SID_CDID_KEY_BUILDER_RSS 47
265 #define ICE_SID_CDID_REDIR_RSS 48
267 #define ICE_SID_RXPARSER_CAM 50
268 #define ICE_SID_RXPARSER_NOMATCH_CAM 51
269 #define ICE_SID_RXPARSER_IMEM 52
270 #define ICE_SID_RXPARSER_MARKER_PTYPE 55
271 #define ICE_SID_RXPARSER_BOOST_TCAM 56
272 #define ICE_SID_RXPARSER_PROTO_GRP 57
273 #define ICE_SID_RXPARSER_METADATA_INIT 58
274 #define ICE_SID_TXPARSER_BOOST_TCAM 66
275 #define ICE_SID_RXPARSER_MARKER_GRP 72
276 #define ICE_SID_RXPARSER_PG_SPILL 76
277 #define ICE_SID_RXPARSER_NOMATCH_SPILL 78
279 #define ICE_SID_XLT0_PE 80
280 #define ICE_SID_XLT_KEY_BUILDER_PE 81
281 #define ICE_SID_XLT1_PE 82
282 #define ICE_SID_XLT2_PE 83
283 #define ICE_SID_PROFID_TCAM_PE 84
284 #define ICE_SID_PROFID_REDIR_PE 85
285 #define ICE_SID_FLD_VEC_PE 86
286 #define ICE_SID_CDID_KEY_BUILDER_PE 87
287 #define ICE_SID_CDID_REDIR_PE 88
289 #define ICE_SID_RXPARSER_FLAG_REDIR 97
290 /* Label Metadata section IDs */
291 #define ICE_SID_LBL_FIRST 0x80000010
292 #define ICE_SID_LBL_RXPARSER_TMEM 0x80000018
293 /* The following define MUST be updated to reflect the last label section ID */
294 #define ICE_SID_LBL_LAST 0x80000038
296 /* Label ICE runtime configuration section IDs */
297 #define ICE_SID_TX_5_LAYER_TOPO 0x10
324 #define ICE_PKG_LABEL_SIZE 64
325 char name[ICE_PKG_LABEL_SIZE];
328 struct ice_label_section {
330 struct ice_label label[];
333 #define ICE_MAX_LABELS_IN_BUF \
334 ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_label_section, \
336 sizeof(struct ice_label), \
337 sizeof(struct ice_label))
339 struct ice_sw_fv_section {
345 struct ice_sw_fv_list_entry {
346 struct list_head list_entry;
348 struct ice_fv *fv_ptr;
351 /* The BOOST TCAM stores the match packet header in reverse order, meaning
352 * the fields are reversed; in addition, this means that the normally big endian
353 * fields of the packet are now little endian.
355 struct ice_boost_key_value {
356 #define ICE_BOOST_REMAINING_HV_KEY 15
357 u8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY];
358 __le16 hv_dst_port_key;
359 __le16 hv_src_port_key;
363 struct ice_boost_key {
364 struct ice_boost_key_value key;
365 struct ice_boost_key_value key2;
368 /* package Boost TCAM entry */
369 struct ice_boost_tcam_entry {
372 /* break up the 40 bytes of key into different fields */
373 struct ice_boost_key key;
374 u8 boost_hit_index_group;
375 /* The following contains bitfields which are not on byte boundaries.
376 * These fields are currently unused by driver software.
378 #define ICE_BOOST_BIT_FIELDS 43
379 u8 bit_fields[ICE_BOOST_BIT_FIELDS];
382 struct ice_boost_tcam_section {
385 struct ice_boost_tcam_entry tcam[];
388 #define ICE_MAX_BST_TCAMS_IN_BUF \
389 ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_boost_tcam_section, \
391 sizeof(struct ice_boost_tcam_entry), \
392 sizeof(struct ice_boost_tcam_entry))
394 /* package Marker Ptype TCAM entry */
395 struct ice_marker_ptype_tcam_entry {
396 #define ICE_MARKER_PTYPE_TCAM_ADDR_MAX 1024
402 struct ice_marker_ptype_tcam_section {
405 struct ice_marker_ptype_tcam_entry tcam[];
408 #define ICE_MAX_MARKER_PTYPE_TCAMS_IN_BUF \
409 ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_marker_ptype_tcam_section, tcam, \
411 sizeof(struct ice_marker_ptype_tcam_entry), \
412 sizeof(struct ice_marker_ptype_tcam_entry))
414 struct ice_xlt1_section {
420 struct ice_xlt2_section {
426 struct ice_prof_redir_section {
432 /* package buffer building */
434 struct ice_buf_build {
436 u16 reserved_section_table_entries;
439 struct ice_pkg_enum {
440 struct ice_buf_table *buf_table;
444 const struct ice_buf_hdr *buf;
450 void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);
453 int ice_aq_upload_section(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf,
454 u16 buf_size, struct ice_sq_cd *cd);
456 void *ice_pkg_buf_alloc_section(struct ice_buf_build *bld, u32 type, u16 size);
458 struct ice_buf_build *ice_pkg_buf_alloc(struct ice_hw *hw);
460 int ice_update_pkg_no_lock(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
461 int ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
463 int ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count);
464 u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld);
466 ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
467 u32 sect_type, u32 *offset,
468 void *(*handler)(u32 sect_type, void *section,
469 u32 index, u32 *offset));
470 void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
473 int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len);