Loading...
Note: File does not exist in v5.4.
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2022, Intel Corporation. */
3
4#ifndef _ICE_DDP_H_
5#define _ICE_DDP_H_
6
7#include "ice_type.h"
8
9/* Package minimal version supported */
10#define ICE_PKG_SUPP_VER_MAJ 1
11#define ICE_PKG_SUPP_VER_MNR 3
12
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
18
19#define ICE_PKG_CNT 4
20
21#define ICE_FV_OFFSET_INVAL 0x1FF
22
23/* Extraction Sequence (Field Vector) Table */
24struct ice_fv_word {
25 u8 prot_id;
26 u16 off; /* Offset within the protocol header */
27 u8 resvrd;
28} __packed;
29
30#define ICE_MAX_NUM_PROFILES 256
31
32#define ICE_MAX_FV_WORDS 48
33struct ice_fv {
34 struct ice_fv_word ew[ICE_MAX_FV_WORDS];
35};
36
37enum ice_ddp_state {
38 /* Indicates that this call to ice_init_pkg
39 * successfully loaded the requested DDP package
40 */
41 ICE_DDP_PKG_SUCCESS = 0,
42
43 /* Generic error for already loaded errors, it is mapped later to
44 * the more specific one (one of the next 3)
45 */
46 ICE_DDP_PKG_ALREADY_LOADED = -1,
47
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
50 */
51 ICE_DDP_PKG_SAME_VERSION_ALREADY_LOADED = -2,
52
53 /* The device has a DDP package that is not supported by the driver */
54 ICE_DDP_PKG_ALREADY_LOADED_NOT_SUPPORTED = -3,
55
56 /* The device has a compatible package
57 * (but different from the request) already loaded
58 */
59 ICE_DDP_PKG_COMPATIBLE_ALREADY_LOADED = -4,
60
61 /* The firmware loaded on the device is not compatible with
62 * the DDP package loaded
63 */
64 ICE_DDP_PKG_FW_MISMATCH = -5,
65
66 /* The DDP package file is invalid */
67 ICE_DDP_PKG_INVALID_FILE = -6,
68
69 /* The version of the DDP package provided is higher than
70 * the driver supports
71 */
72 ICE_DDP_PKG_FILE_VERSION_TOO_HIGH = -7,
73
74 /* The version of the DDP package provided is lower than the
75 * driver supports
76 */
77 ICE_DDP_PKG_FILE_VERSION_TOO_LOW = -8,
78
79 /* The signature of the DDP package file provided is invalid */
80 ICE_DDP_PKG_FILE_SIGNATURE_INVALID = -9,
81
82 /* The DDP package file security revision is too low and not
83 * supported by firmware
84 */
85 ICE_DDP_PKG_FILE_REVISION_TOO_LOW = -10,
86
87 /* An error occurred in firmware while loading the DDP package */
88 ICE_DDP_PKG_LOAD_ERROR = -11,
89
90 /* Other errors */
91 ICE_DDP_PKG_ERR = -12
92};
93
94/* Package and segment headers and tables */
95struct ice_pkg_hdr {
96 struct ice_pkg_ver pkg_format_ver;
97 __le32 seg_count;
98 __le32 seg_offset[];
99};
100
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
107
108/* generic segment */
109struct 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
116 __le32 seg_type;
117 struct ice_pkg_ver seg_format_ver;
118 __le32 seg_size;
119 char seg_id[ICE_PKG_NAME_SIZE];
120};
121
122/* ice specific segment */
123
124union ice_device_id {
125 struct {
126 __le16 device_id;
127 __le16 vendor_id;
128 } dev_vend_id;
129 __le32 id;
130};
131
132struct ice_device_id_entry {
133 union ice_device_id device;
134 union ice_device_id sub_device;
135};
136
137struct ice_seg {
138 struct ice_generic_seg_hdr hdr;
139 __le32 device_table_count;
140 struct ice_device_id_entry device_table[];
141};
142
143struct ice_nvm_table {
144 __le32 table_count;
145 __le32 vers[];
146};
147
148struct ice_buf {
149#define ICE_PKG_BUF_SIZE 4096
150 u8 buf[ICE_PKG_BUF_SIZE];
151};
152
153struct ice_buf_table {
154 __le32 buf_count;
155 struct ice_buf buf_array[];
156};
157
158struct ice_run_time_cfg_seg {
159 struct ice_generic_seg_hdr hdr;
160 u8 rsvd[8];
161 struct ice_buf_table buf_table;
162};
163
164/* global metadata specific segment */
165struct ice_global_metadata_seg {
166 struct ice_generic_seg_hdr hdr;
167 struct ice_pkg_ver pkg_ver;
168 __le32 rsvd;
169 char pkg_name[ICE_PKG_NAME_SIZE];
170};
171
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
176
177struct ice_sign_seg {
178 struct ice_generic_seg_hdr hdr;
179 __le32 seg_id;
180 __le32 sign_type;
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
186 __le32 flags;
187#define ICE_SIGN_SEG_RESERVED_COUNT 40
188 u8 reserved[ICE_SIGN_SEG_RESERVED_COUNT];
189 struct ice_buf_table buf_tbl;
190};
191
192/* section information */
193struct ice_section_entry {
194 __le32 type;
195 __le16 offset;
196 __le16 size;
197};
198
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
203
204#define ICE_METADATA_BUF 0x80000000
205
206struct ice_buf_hdr {
207 __le16 section_count;
208 __le16 data_end;
209 struct ice_section_entry section_entry[];
210};
211
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)) / \
215 (ent_sz))
216
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
227
228struct 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];
232 __le32 track_id;
233};
234
235#define ICE_SID_CDID_REDIR_SW 18
236
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
246
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
256
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
266
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
278
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
288
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
295
296/* Label ICE runtime configuration section IDs */
297#define ICE_SID_TX_5_LAYER_TOPO 0x10
298
299enum ice_block {
300 ICE_BLK_SW = 0,
301 ICE_BLK_ACL,
302 ICE_BLK_FD,
303 ICE_BLK_RSS,
304 ICE_BLK_PE,
305 ICE_BLK_COUNT
306};
307
308enum ice_sect {
309 ICE_XLT0 = 0,
310 ICE_XLT_KB,
311 ICE_XLT1,
312 ICE_XLT2,
313 ICE_PROF_TCAM,
314 ICE_PROF_REDIR,
315 ICE_VEC_TBL,
316 ICE_CDID_KB,
317 ICE_CDID_REDIR,
318 ICE_SECT_COUNT
319};
320
321/* package labels */
322struct ice_label {
323 __le16 value;
324#define ICE_PKG_LABEL_SIZE 64
325 char name[ICE_PKG_LABEL_SIZE];
326};
327
328struct ice_label_section {
329 __le16 count;
330 struct ice_label label[];
331};
332
333#define ICE_MAX_LABELS_IN_BUF \
334 ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_label_section, \
335 label, 1) - \
336 sizeof(struct ice_label), \
337 sizeof(struct ice_label))
338
339struct ice_sw_fv_section {
340 __le16 count;
341 __le16 base_offset;
342 struct ice_fv fv[];
343};
344
345struct ice_sw_fv_list_entry {
346 struct list_head list_entry;
347 u32 profile_id;
348 struct ice_fv *fv_ptr;
349};
350
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.
354 */
355struct 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;
360 u8 tcam_search_key;
361} __packed;
362
363struct ice_boost_key {
364 struct ice_boost_key_value key;
365 struct ice_boost_key_value key2;
366};
367
368/* package Boost TCAM entry */
369struct ice_boost_tcam_entry {
370 __le16 addr;
371 __le16 reserved;
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.
377 */
378#define ICE_BOOST_BIT_FIELDS 43
379 u8 bit_fields[ICE_BOOST_BIT_FIELDS];
380};
381
382struct ice_boost_tcam_section {
383 __le16 count;
384 __le16 reserved;
385 struct ice_boost_tcam_entry tcam[];
386};
387
388#define ICE_MAX_BST_TCAMS_IN_BUF \
389 ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_boost_tcam_section, \
390 tcam, 1) - \
391 sizeof(struct ice_boost_tcam_entry), \
392 sizeof(struct ice_boost_tcam_entry))
393
394/* package Marker Ptype TCAM entry */
395struct ice_marker_ptype_tcam_entry {
396#define ICE_MARKER_PTYPE_TCAM_ADDR_MAX 1024
397 __le16 addr;
398 __le16 ptype;
399 u8 keys[20];
400};
401
402struct ice_marker_ptype_tcam_section {
403 __le16 count;
404 __le16 reserved;
405 struct ice_marker_ptype_tcam_entry tcam[];
406};
407
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, \
410 1) - \
411 sizeof(struct ice_marker_ptype_tcam_entry), \
412 sizeof(struct ice_marker_ptype_tcam_entry))
413
414struct ice_xlt1_section {
415 __le16 count;
416 __le16 offset;
417 u8 value[];
418};
419
420struct ice_xlt2_section {
421 __le16 count;
422 __le16 offset;
423 __le16 value[];
424};
425
426struct ice_prof_redir_section {
427 __le16 count;
428 __le16 offset;
429 u8 redir_value[];
430};
431
432/* package buffer building */
433
434struct ice_buf_build {
435 struct ice_buf buf;
436 u16 reserved_section_table_entries;
437};
438
439struct ice_pkg_enum {
440 struct ice_buf_table *buf_table;
441 u32 buf_idx;
442
443 u32 type;
444 const struct ice_buf_hdr *buf;
445 u32 sect_idx;
446 void *sect;
447 u32 sect_type;
448
449 u32 entry_idx;
450 void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);
451};
452
453int ice_aq_upload_section(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf,
454 u16 buf_size, struct ice_sq_cd *cd);
455
456void *ice_pkg_buf_alloc_section(struct ice_buf_build *bld, u32 type, u16 size);
457
458struct ice_buf_build *ice_pkg_buf_alloc(struct ice_hw *hw);
459
460int ice_update_pkg_no_lock(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
461int ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
462
463int ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count);
464u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld);
465void *
466ice_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));
470void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
471 u32 sect_type);
472
473int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len);
474
475#endif