1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright (c) 2024, Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Intel Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _ICE_DDP_COMMON_H_
33 #define _ICE_DDP_COMMON_H_
35 #include "ice_osdep.h"
36 #include "ice_adminq_cmd.h"
37 #include "ice_controlq.h"
38 #include "ice_status.h"
39 #include "ice_flex_type.h"
40 #include "ice_protocol_type.h"
42 /* Package minimal version supported */
43 #define ICE_PKG_SUPP_VER_MAJ 1
44 #define ICE_PKG_SUPP_VER_MNR 3
46 /* Package format version */
47 #define ICE_PKG_FMT_VER_MAJ 1
48 #define ICE_PKG_FMT_VER_MNR 0
49 #define ICE_PKG_FMT_VER_UPD 0
50 #define ICE_PKG_FMT_VER_DFT 0
55 /* Indicates that this call to ice_init_pkg
56 * successfully loaded the requested DDP package
58 ICE_DDP_PKG_SUCCESS = 0,
60 /* Generic error for already loaded errors, it is mapped later to
61 * the more specific one (one of the next 3)
63 ICE_DDP_PKG_ALREADY_LOADED = -1,
65 /* Indicates that a DDP package of the same version has already been
66 * loaded onto the device by a previous call or by another PF
68 ICE_DDP_PKG_SAME_VERSION_ALREADY_LOADED = -2,
70 /* The device has a DDP package that is not supported by the driver */
71 ICE_DDP_PKG_ALREADY_LOADED_NOT_SUPPORTED = -3,
73 /* The device has a compatible package
74 * (but different from the request) already loaded
76 ICE_DDP_PKG_COMPATIBLE_ALREADY_LOADED = -4,
78 /* The firmware loaded on the device is not compatible with
79 * the DDP package loaded
81 ICE_DDP_PKG_FW_MISMATCH = -5,
83 /* The DDP package file is invalid */
84 ICE_DDP_PKG_INVALID_FILE = -6,
86 /* The version of the DDP package provided is higher than
89 ICE_DDP_PKG_FILE_VERSION_TOO_HIGH = -7,
91 /* The version of the DDP package provided is lower than the
94 ICE_DDP_PKG_FILE_VERSION_TOO_LOW = -8,
96 /* Missing security manifest in DDP pkg */
97 ICE_DDP_PKG_NO_SEC_MANIFEST = -9,
99 /* The RSA signature of the DDP package file provided is invalid */
100 ICE_DDP_PKG_FILE_SIGNATURE_INVALID = -10,
102 /* The DDP package file security revision is too low and not
103 * supported by firmware
105 ICE_DDP_PKG_SECURE_VERSION_NBR_TOO_LOW = -11,
107 /* Manifest hash mismatch */
108 ICE_DDP_PKG_MANIFEST_INVALID = -12,
110 /* Buffer hash mismatches manifest */
111 ICE_DDP_PKG_BUFFER_INVALID = -13,
114 ICE_DDP_PKG_ERR = -14,
117 /* Package and segment headers and tables */
119 struct ice_pkg_ver pkg_format_ver;
121 __le32 seg_offset[STRUCT_HACK_VAR_LEN];
124 /* Package signing algorithm types */
125 #define SEGMENT_SIGN_TYPE_INVALID 0x00000000
126 #define SEGMENT_SIGN_TYPE_RSA2K 0x00000001
127 #define SEGMENT_SIGN_TYPE_RSA3K 0x00000002
128 #define SEGMENT_SIGN_TYPE_RSA3K_SBB 0x00000003 /* Secure Boot Block */
129 #define SEGMENT_SIGN_TYPE_RSA3K_E825 0x00000005
131 /* generic segment */
132 struct ice_generic_seg_hdr {
133 #define SEGMENT_TYPE_INVALID 0x00000000
134 #define SEGMENT_TYPE_METADATA 0x00000001
135 #define SEGMENT_TYPE_ICE_E810 0x00000010
136 #define SEGMENT_TYPE_SIGNING 0x00001001
137 #define SEGMENT_TYPE_ICE_RUN_TIME_CFG 0x00000020
139 struct ice_pkg_ver seg_format_ver;
141 char seg_id[ICE_PKG_NAME_SIZE];
144 /* ice specific segment */
146 union ice_device_id {
154 struct ice_device_id_entry {
155 union ice_device_id device;
156 union ice_device_id sub_device;
160 struct ice_generic_seg_hdr hdr;
161 __le32 device_table_count;
162 struct ice_device_id_entry device_table[STRUCT_HACK_VAR_LEN];
165 struct ice_nvm_table {
167 __le32 vers[STRUCT_HACK_VAR_LEN];
171 #define ICE_PKG_BUF_SIZE 4096
172 u8 buf[ICE_PKG_BUF_SIZE];
175 struct ice_buf_table {
177 struct ice_buf buf_array[STRUCT_HACK_VAR_LEN];
180 struct ice_run_time_cfg_seg {
181 struct ice_generic_seg_hdr hdr;
183 struct ice_buf_table buf_table;
186 /* global metadata specific segment */
187 struct ice_global_metadata_seg {
188 struct ice_generic_seg_hdr hdr;
189 struct ice_pkg_ver pkg_ver;
191 char pkg_name[ICE_PKG_NAME_SIZE];
194 #define ICE_MIN_S_OFF 12
195 #define ICE_MAX_S_OFF 4095
196 #define ICE_MIN_S_SZ 1
197 #define ICE_MAX_S_SZ 4084
199 struct ice_sign_seg {
200 struct ice_generic_seg_hdr hdr;
203 __le32 signed_seg_idx;
204 __le32 signed_buf_start;
205 __le32 signed_buf_count;
206 #define ICE_SIGN_SEG_RESERVED_COUNT 44
207 u8 reserved[ICE_SIGN_SEG_RESERVED_COUNT];
208 struct ice_buf_table buf_tbl;
211 /* section information */
212 struct ice_section_entry {
218 #define ICE_MIN_S_COUNT 1
219 #define ICE_MAX_S_COUNT 511
220 #define ICE_MIN_S_DATA_END 12
221 #define ICE_MAX_S_DATA_END 4096
223 #define ICE_METADATA_BUF 0x80000000
226 __le16 section_count;
228 struct ice_section_entry section_entry[STRUCT_HACK_VAR_LEN];
231 #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) ((ICE_PKG_BUF_SIZE - \
232 ice_struct_size((struct ice_buf_hdr *)0, section_entry, 1) - (hd_sz)) /\
235 /* ice package section IDs */
236 #define ICE_SID_METADATA 1
237 #define ICE_SID_XLT0_SW 10
238 #define ICE_SID_XLT_KEY_BUILDER_SW 11
239 #define ICE_SID_XLT1_SW 12
240 #define ICE_SID_XLT2_SW 13
241 #define ICE_SID_PROFID_TCAM_SW 14
242 #define ICE_SID_PROFID_REDIR_SW 15
243 #define ICE_SID_FLD_VEC_SW 16
244 #define ICE_SID_CDID_KEY_BUILDER_SW 17
245 #define ICE_SID_CDID_REDIR_SW 18
247 #define ICE_SID_XLT0_ACL 20
248 #define ICE_SID_XLT_KEY_BUILDER_ACL 21
249 #define ICE_SID_XLT1_ACL 22
250 #define ICE_SID_XLT2_ACL 23
251 #define ICE_SID_PROFID_TCAM_ACL 24
252 #define ICE_SID_PROFID_REDIR_ACL 25
253 #define ICE_SID_FLD_VEC_ACL 26
254 #define ICE_SID_CDID_KEY_BUILDER_ACL 27
255 #define ICE_SID_CDID_REDIR_ACL 28
257 #define ICE_SID_XLT0_FD 30
258 #define ICE_SID_XLT_KEY_BUILDER_FD 31
259 #define ICE_SID_XLT1_FD 32
260 #define ICE_SID_XLT2_FD 33
261 #define ICE_SID_PROFID_TCAM_FD 34
262 #define ICE_SID_PROFID_REDIR_FD 35
263 #define ICE_SID_FLD_VEC_FD 36
264 #define ICE_SID_CDID_KEY_BUILDER_FD 37
265 #define ICE_SID_CDID_REDIR_FD 38
267 #define ICE_SID_XLT0_RSS 40
268 #define ICE_SID_XLT_KEY_BUILDER_RSS 41
269 #define ICE_SID_XLT1_RSS 42
270 #define ICE_SID_XLT2_RSS 43
271 #define ICE_SID_PROFID_TCAM_RSS 44
272 #define ICE_SID_PROFID_REDIR_RSS 45
273 #define ICE_SID_FLD_VEC_RSS 46
274 #define ICE_SID_CDID_KEY_BUILDER_RSS 47
275 #define ICE_SID_CDID_REDIR_RSS 48
277 #define ICE_SID_RXPARSER_CAM 50
278 #define ICE_SID_RXPARSER_NOMATCH_CAM 51
279 #define ICE_SID_RXPARSER_IMEM 52
280 #define ICE_SID_RXPARSER_XLT0_BUILDER 53
281 #define ICE_SID_RXPARSER_NODE_PTYPE 54
282 #define ICE_SID_RXPARSER_MARKER_PTYPE 55
283 #define ICE_SID_RXPARSER_BOOST_TCAM 56
284 #define ICE_SID_RXPARSER_PROTO_GRP 57
285 #define ICE_SID_RXPARSER_METADATA_INIT 58
286 #define ICE_SID_RXPARSER_XLT0 59
288 #define ICE_SID_TXPARSER_CAM 60
289 #define ICE_SID_TXPARSER_NOMATCH_CAM 61
290 #define ICE_SID_TXPARSER_IMEM 62
291 #define ICE_SID_TXPARSER_XLT0_BUILDER 63
292 #define ICE_SID_TXPARSER_NODE_PTYPE 64
293 #define ICE_SID_TXPARSER_MARKER_PTYPE 65
294 #define ICE_SID_TXPARSER_BOOST_TCAM 66
295 #define ICE_SID_TXPARSER_PROTO_GRP 67
296 #define ICE_SID_TXPARSER_METADATA_INIT 68
297 #define ICE_SID_TXPARSER_XLT0 69
299 #define ICE_SID_RXPARSER_INIT_REDIR 70
300 #define ICE_SID_TXPARSER_INIT_REDIR 71
301 #define ICE_SID_RXPARSER_MARKER_GRP 72
302 #define ICE_SID_TXPARSER_MARKER_GRP 73
303 #define ICE_SID_RXPARSER_LAST_PROTO 74
304 #define ICE_SID_TXPARSER_LAST_PROTO 75
305 #define ICE_SID_RXPARSER_PG_SPILL 76
306 #define ICE_SID_TXPARSER_PG_SPILL 77
307 #define ICE_SID_RXPARSER_NOMATCH_SPILL 78
308 #define ICE_SID_TXPARSER_NOMATCH_SPILL 79
310 #define ICE_SID_XLT0_PE 80
311 #define ICE_SID_XLT_KEY_BUILDER_PE 81
312 #define ICE_SID_XLT1_PE 82
313 #define ICE_SID_XLT2_PE 83
314 #define ICE_SID_PROFID_TCAM_PE 84
315 #define ICE_SID_PROFID_REDIR_PE 85
316 #define ICE_SID_FLD_VEC_PE 86
317 #define ICE_SID_CDID_KEY_BUILDER_PE 87
318 #define ICE_SID_CDID_REDIR_PE 88
320 #define ICE_SID_RXPARSER_FLAG_REDIR 97
322 /* Label Metadata section IDs */
323 #define ICE_SID_LBL_FIRST 0x80000010
324 #define ICE_SID_LBL_RXPARSER_IMEM 0x80000010
325 #define ICE_SID_LBL_TXPARSER_IMEM 0x80000011
326 #define ICE_SID_LBL_RESERVED_12 0x80000012
327 #define ICE_SID_LBL_RESERVED_13 0x80000013
328 #define ICE_SID_LBL_RXPARSER_MARKER 0x80000014
329 #define ICE_SID_LBL_TXPARSER_MARKER 0x80000015
330 #define ICE_SID_LBL_PTYPE 0x80000016
331 #define ICE_SID_LBL_PROTOCOL_ID 0x80000017
332 #define ICE_SID_LBL_RXPARSER_TMEM 0x80000018
333 #define ICE_SID_LBL_TXPARSER_TMEM 0x80000019
334 #define ICE_SID_LBL_RXPARSER_PG 0x8000001A
335 #define ICE_SID_LBL_TXPARSER_PG 0x8000001B
336 #define ICE_SID_LBL_RXPARSER_M_TCAM 0x8000001C
337 #define ICE_SID_LBL_TXPARSER_M_TCAM 0x8000001D
338 #define ICE_SID_LBL_SW_PROFID_TCAM 0x8000001E
339 #define ICE_SID_LBL_ACL_PROFID_TCAM 0x8000001F
340 #define ICE_SID_LBL_PE_PROFID_TCAM 0x80000020
341 #define ICE_SID_LBL_RSS_PROFID_TCAM 0x80000021
342 #define ICE_SID_LBL_FD_PROFID_TCAM 0x80000022
343 #define ICE_SID_LBL_FLAG 0x80000023
344 #define ICE_SID_LBL_REG 0x80000024
345 #define ICE_SID_LBL_SW_PTG 0x80000025
346 #define ICE_SID_LBL_ACL_PTG 0x80000026
347 #define ICE_SID_LBL_PE_PTG 0x80000027
348 #define ICE_SID_LBL_RSS_PTG 0x80000028
349 #define ICE_SID_LBL_FD_PTG 0x80000029
350 #define ICE_SID_LBL_SW_VSIG 0x8000002A
351 #define ICE_SID_LBL_ACL_VSIG 0x8000002B
352 #define ICE_SID_LBL_PE_VSIG 0x8000002C
353 #define ICE_SID_LBL_RSS_VSIG 0x8000002D
354 #define ICE_SID_LBL_FD_VSIG 0x8000002E
355 #define ICE_SID_LBL_PTYPE_META 0x8000002F
356 #define ICE_SID_LBL_SW_PROFID 0x80000030
357 #define ICE_SID_LBL_ACL_PROFID 0x80000031
358 #define ICE_SID_LBL_PE_PROFID 0x80000032
359 #define ICE_SID_LBL_RSS_PROFID 0x80000033
360 #define ICE_SID_LBL_FD_PROFID 0x80000034
361 #define ICE_SID_LBL_RXPARSER_MARKER_GRP 0x80000035
362 #define ICE_SID_LBL_TXPARSER_MARKER_GRP 0x80000036
363 #define ICE_SID_LBL_RXPARSER_PROTO 0x80000037
364 #define ICE_SID_LBL_TXPARSER_PROTO 0x80000038
365 /* The following define MUST be updated to reflect the last label section ID */
366 #define ICE_SID_LBL_LAST 0x80000038
368 /* Label ICE runtime configuration section IDs */
369 #define ICE_SID_TX_5_LAYER_TOPO 0x10
393 /* package buffer building */
395 struct ice_buf_build {
397 u16 reserved_section_table_entries;
400 struct ice_pkg_enum {
401 struct ice_buf_table *buf_table;
405 struct ice_buf_hdr *buf;
411 void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);
417 ice_acquire_change_lock(struct ice_hw *hw, enum ice_aq_res_access_type access);
418 void ice_release_change_lock(struct ice_hw *hw);
420 struct ice_buf_build *ice_pkg_buf_alloc(struct ice_hw *hw);
422 ice_pkg_buf_alloc_section(struct ice_buf_build *bld, u32 type, u16 size);
424 ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count);
426 ice_get_sw_fv_list(struct ice_hw *hw, struct ice_prot_lkup_ext *lkups,
427 ice_bitmap_t *bm, struct LIST_HEAD_TYPE *fv_list);
429 ice_pkg_buf_unreserve_section(struct ice_buf_build *bld, u16 count);
430 u16 ice_pkg_buf_get_free_space(struct ice_buf_build *bld);
431 u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld);
434 ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
436 ice_update_pkg_no_lock(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
437 void ice_release_global_cfg_lock(struct ice_hw *hw);
438 struct ice_generic_seg_hdr *
439 ice_find_seg_in_pkg(struct ice_hw *hw, u32 seg_type,
440 struct ice_pkg_hdr *pkg_hdr);
442 ice_verify_pkg(struct ice_pkg_hdr *pkg, u32 len);
444 ice_get_pkg_info(struct ice_hw *hw);
445 void ice_init_pkg_hints(struct ice_hw *hw, struct ice_seg *ice_seg);
446 struct ice_buf_table *ice_find_buf_table(struct ice_seg *ice_seg);
448 ice_acquire_global_cfg_lock(struct ice_hw *hw,
449 enum ice_aq_res_access_type access);
451 struct ice_buf_table *ice_find_buf_table(struct ice_seg *ice_seg);
453 ice_pkg_enum_buf(struct ice_seg *ice_seg, struct ice_pkg_enum *state);
455 ice_pkg_advance_sect(struct ice_seg *ice_seg, struct ice_pkg_enum *state);
457 ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
458 u32 sect_type, u32 *offset,
459 void *(*handler)(u32 sect_type, void *section,
460 u32 index, u32 *offset));
462 ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
464 enum ice_ddp_state ice_init_pkg(struct ice_hw *hw, u8 *buff, u32 len);
466 ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
467 bool ice_is_init_pkg_successful(enum ice_ddp_state state);
468 void ice_free_seg(struct ice_hw *hw);
470 struct ice_buf_build *
471 ice_pkg_buf_alloc_single_section(struct ice_hw *hw, u32 type, u16 size,
473 struct ice_buf *ice_pkg_buf(struct ice_buf_build *bld);
474 void ice_pkg_buf_free(struct ice_hw *hw, struct ice_buf_build *bld);
476 enum ice_status ice_cfg_tx_topo(struct ice_hw *hw, u8 *buf, u32 len);
478 #endif /* _ICE_DDP_COMMON_H_ */