brintos

brintos / linux-shallow public Read only

0
0
Text · 11.6 KiB · 79551da Raw
473 lines · c
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 111#define ICE_PKG_SUPP_VER_MNR 312 13/* Package format version */14#define ICE_PKG_FMT_VER_MAJ 115#define ICE_PKG_FMT_VER_MNR 016#define ICE_PKG_FMT_VER_UPD 017#define ICE_PKG_FMT_VER_DFT 018 19#define ICE_PKG_CNT 420 21#define ICE_FV_OFFSET_INVAL 0x1FF22 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 25631 32#define ICE_MAX_FV_WORDS 4833struct 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_pkg39	 * successfully loaded the requested DDP package40	 */41	ICE_DDP_PKG_SUCCESS = 0,42 43	/* Generic error for already loaded errors, it is mapped later to44	 * 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 been49	 * loaded onto the device by a previous call or by another PF50	 */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 package57	 * (but different from the request) already loaded58	 */59	ICE_DDP_PKG_COMPATIBLE_ALREADY_LOADED = -4,60 61	/* The firmware loaded on the device is not compatible with62	 * the DDP package loaded63	 */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 than70	 * the driver supports71	 */72	ICE_DDP_PKG_FILE_VERSION_TOO_HIGH = -7,73 74	/* The version of the DDP package provided is lower than the75	 * driver supports76	 */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 not83	 * supported by firmware84	 */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 = -1292};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	0x00000000103#define SEGMENT_SIGN_TYPE_RSA2K		0x00000001104#define SEGMENT_SIGN_TYPE_RSA3K		0x00000002105#define SEGMENT_SIGN_TYPE_RSA3K_SBB	0x00000003 /* Secure Boot Block */106#define SEGMENT_SIGN_TYPE_RSA3K_E825	0x00000005107 108/* generic segment */109struct ice_generic_seg_hdr {110#define SEGMENT_TYPE_INVALID	0x00000000111#define SEGMENT_TYPE_METADATA	0x00000001112#define SEGMENT_TYPE_ICE_E810	0x00000010113#define SEGMENT_TYPE_SIGNING	0x00001001114#define SEGMENT_TYPE_ICE_RUN_TIME_CFG 0x00000020115#define SEGMENT_TYPE_ICE_E830	0x00000017116	__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 4096150	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 12173#define ICE_MAX_S_OFF 4095174#define ICE_MIN_S_SZ 1175#define ICE_MAX_S_SZ 4084176 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_RESERVED_COUNT	44185	u8 reserved[ICE_SIGN_SEG_RESERVED_COUNT];186	struct ice_buf_table buf_tbl;187};188 189/* section information */190struct ice_section_entry {191	__le32 type;192	__le16 offset;193	__le16 size;194};195 196#define ICE_MIN_S_COUNT 1197#define ICE_MAX_S_COUNT 511198#define ICE_MIN_S_DATA_END 12199#define ICE_MAX_S_DATA_END 4096200 201#define ICE_METADATA_BUF 0x80000000202 203struct ice_buf_hdr {204	__le16 section_count;205	__le16 data_end;206	struct ice_section_entry section_entry[];207};208 209#define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz)                                 \210	((ICE_PKG_BUF_SIZE -                                                  \211	  struct_size_t(struct ice_buf_hdr,  section_entry, 1) - (hd_sz)) / \212	 (ent_sz))213 214/* ice package section IDs */215#define ICE_SID_METADATA 1216#define ICE_SID_XLT0_SW 10217#define ICE_SID_XLT_KEY_BUILDER_SW 11218#define ICE_SID_XLT1_SW 12219#define ICE_SID_XLT2_SW 13220#define ICE_SID_PROFID_TCAM_SW 14221#define ICE_SID_PROFID_REDIR_SW 15222#define ICE_SID_FLD_VEC_SW 16223#define ICE_SID_CDID_KEY_BUILDER_SW 17224 225struct ice_meta_sect {226	struct ice_pkg_ver ver;227#define ICE_META_SECT_NAME_SIZE 28228	char name[ICE_META_SECT_NAME_SIZE];229	__le32 track_id;230};231 232#define ICE_SID_CDID_REDIR_SW 18233 234#define ICE_SID_XLT0_ACL 20235#define ICE_SID_XLT_KEY_BUILDER_ACL 21236#define ICE_SID_XLT1_ACL 22237#define ICE_SID_XLT2_ACL 23238#define ICE_SID_PROFID_TCAM_ACL 24239#define ICE_SID_PROFID_REDIR_ACL 25240#define ICE_SID_FLD_VEC_ACL 26241#define ICE_SID_CDID_KEY_BUILDER_ACL 27242#define ICE_SID_CDID_REDIR_ACL 28243 244#define ICE_SID_XLT0_FD 30245#define ICE_SID_XLT_KEY_BUILDER_FD 31246#define ICE_SID_XLT1_FD 32247#define ICE_SID_XLT2_FD 33248#define ICE_SID_PROFID_TCAM_FD 34249#define ICE_SID_PROFID_REDIR_FD 35250#define ICE_SID_FLD_VEC_FD 36251#define ICE_SID_CDID_KEY_BUILDER_FD 37252#define ICE_SID_CDID_REDIR_FD 38253 254#define ICE_SID_XLT0_RSS 40255#define ICE_SID_XLT_KEY_BUILDER_RSS 41256#define ICE_SID_XLT1_RSS 42257#define ICE_SID_XLT2_RSS 43258#define ICE_SID_PROFID_TCAM_RSS 44259#define ICE_SID_PROFID_REDIR_RSS 45260#define ICE_SID_FLD_VEC_RSS 46261#define ICE_SID_CDID_KEY_BUILDER_RSS 47262#define ICE_SID_CDID_REDIR_RSS 48263 264#define ICE_SID_RXPARSER_CAM           50265#define ICE_SID_RXPARSER_NOMATCH_CAM   51266#define ICE_SID_RXPARSER_IMEM          52267#define ICE_SID_RXPARSER_MARKER_PTYPE 55268#define ICE_SID_RXPARSER_BOOST_TCAM 56269#define ICE_SID_RXPARSER_PROTO_GRP     57270#define ICE_SID_RXPARSER_METADATA_INIT 58271#define ICE_SID_TXPARSER_BOOST_TCAM 66272#define ICE_SID_RXPARSER_MARKER_GRP    72273#define ICE_SID_RXPARSER_PG_SPILL      76274#define ICE_SID_RXPARSER_NOMATCH_SPILL 78275 276#define ICE_SID_XLT0_PE 80277#define ICE_SID_XLT_KEY_BUILDER_PE 81278#define ICE_SID_XLT1_PE 82279#define ICE_SID_XLT2_PE 83280#define ICE_SID_PROFID_TCAM_PE 84281#define ICE_SID_PROFID_REDIR_PE 85282#define ICE_SID_FLD_VEC_PE 86283#define ICE_SID_CDID_KEY_BUILDER_PE 87284#define ICE_SID_CDID_REDIR_PE 88285 286#define ICE_SID_RXPARSER_FLAG_REDIR	97287/* Label Metadata section IDs */288#define ICE_SID_LBL_FIRST 0x80000010289#define ICE_SID_LBL_RXPARSER_TMEM 0x80000018290/* The following define MUST be updated to reflect the last label section ID */291#define ICE_SID_LBL_LAST 0x80000038292 293/* Label ICE runtime configuration section IDs */294#define ICE_SID_TX_5_LAYER_TOPO 0x10295 296enum ice_block {297	ICE_BLK_SW = 0,298	ICE_BLK_ACL,299	ICE_BLK_FD,300	ICE_BLK_RSS,301	ICE_BLK_PE,302	ICE_BLK_COUNT303};304 305enum ice_sect {306	ICE_XLT0 = 0,307	ICE_XLT_KB,308	ICE_XLT1,309	ICE_XLT2,310	ICE_PROF_TCAM,311	ICE_PROF_REDIR,312	ICE_VEC_TBL,313	ICE_CDID_KB,314	ICE_CDID_REDIR,315	ICE_SECT_COUNT316};317 318/* package labels */319struct ice_label {320	__le16 value;321#define ICE_PKG_LABEL_SIZE 64322	char name[ICE_PKG_LABEL_SIZE];323};324 325struct ice_label_section {326	__le16 count;327	struct ice_label label[];328};329 330#define ICE_MAX_LABELS_IN_BUF                                             \331	ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_label_section,  \332					   label, 1) -                    \333				       sizeof(struct ice_label),          \334			       sizeof(struct ice_label))335 336struct ice_sw_fv_section {337	__le16 count;338	__le16 base_offset;339	struct ice_fv fv[];340};341 342struct ice_sw_fv_list_entry {343	struct list_head list_entry;344	u32 profile_id;345	struct ice_fv *fv_ptr;346};347 348/* The BOOST TCAM stores the match packet header in reverse order, meaning349 * the fields are reversed; in addition, this means that the normally big endian350 * fields of the packet are now little endian.351 */352struct ice_boost_key_value {353#define ICE_BOOST_REMAINING_HV_KEY 15354	u8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY];355	__le16 hv_dst_port_key;356	__le16 hv_src_port_key;357	u8 tcam_search_key;358} __packed;359 360struct ice_boost_key {361	struct ice_boost_key_value key;362	struct ice_boost_key_value key2;363};364 365/* package Boost TCAM entry */366struct ice_boost_tcam_entry {367	__le16 addr;368	__le16 reserved;369	/* break up the 40 bytes of key into different fields */370	struct ice_boost_key key;371	u8 boost_hit_index_group;372	/* The following contains bitfields which are not on byte boundaries.373	 * These fields are currently unused by driver software.374	 */375#define ICE_BOOST_BIT_FIELDS 43376	u8 bit_fields[ICE_BOOST_BIT_FIELDS];377};378 379struct ice_boost_tcam_section {380	__le16 count;381	__le16 reserved;382	struct ice_boost_tcam_entry tcam[];383};384 385#define ICE_MAX_BST_TCAMS_IN_BUF                                               \386	ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_boost_tcam_section,  \387					   tcam, 1) -                          \388				       sizeof(struct ice_boost_tcam_entry),    \389			       sizeof(struct ice_boost_tcam_entry))390 391/* package Marker Ptype TCAM entry */392struct ice_marker_ptype_tcam_entry {393#define ICE_MARKER_PTYPE_TCAM_ADDR_MAX 1024394	__le16 addr;395	__le16 ptype;396	u8 keys[20];397};398 399struct ice_marker_ptype_tcam_section {400	__le16 count;401	__le16 reserved;402	struct ice_marker_ptype_tcam_entry tcam[];403};404 405#define ICE_MAX_MARKER_PTYPE_TCAMS_IN_BUF                                    \406	ICE_MAX_ENTRIES_IN_BUF(struct_size_t(struct ice_marker_ptype_tcam_section,  tcam, \407			    1) -                                             \408			sizeof(struct ice_marker_ptype_tcam_entry),          \409		sizeof(struct ice_marker_ptype_tcam_entry))410 411struct ice_xlt1_section {412	__le16 count;413	__le16 offset;414	u8 value[];415};416 417struct ice_xlt2_section {418	__le16 count;419	__le16 offset;420	__le16 value[];421};422 423struct ice_prof_redir_section {424	__le16 count;425	__le16 offset;426	u8 redir_value[];427};428 429/* package buffer building */430 431struct ice_buf_build {432	struct ice_buf buf;433	u16 reserved_section_table_entries;434};435 436struct ice_pkg_enum {437	struct ice_buf_table *buf_table;438	u32 buf_idx;439 440	u32 type;441	const struct ice_buf_hdr *buf;442	u32 sect_idx;443	void *sect;444	u32 sect_type;445 446	u32 entry_idx;447	void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);448};449 450int ice_aq_upload_section(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf,451			  u16 buf_size, struct ice_sq_cd *cd);452 453void *ice_pkg_buf_alloc_section(struct ice_buf_build *bld, u32 type, u16 size);454 455struct ice_buf_build *ice_pkg_buf_alloc(struct ice_hw *hw);456 457int ice_update_pkg_no_lock(struct ice_hw *hw, struct ice_buf *bufs, u32 count);458int ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count);459 460int ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count);461u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld);462void *463ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,464		   u32 sect_type, u32 *offset,465		   void *(*handler)(u32 sect_type, void *section,466				    u32 index, u32 *offset));467void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,468			   u32 sect_type);469 470int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len);471 472#endif473