File Index
Files and directories
Sign in
FILE

adminq.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/net/intel/libie/adminq.h C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/* Copyright (C) 2025 Intel Corporation */
  3
  4#ifndef __LIBIE_ADMINQ_H
  5#define __LIBIE_ADMINQ_H
  6
  7#include <linux/build_bug.h>
  8#include <linux/types.h>
  9
 10#define LIBIE_CHECK_STRUCT_LEN(n, X)	\
 11	static_assert((n) == sizeof(struct X))
 12#define LIBIE_AQ_MAX_BUF_LEN 4096
 13
 14/**
 15 * struct libie_aqc_generic - Generic structure used in adminq communication
 16 * @param0: generic parameter high 32bit
 17 * @param1: generic parameter lower 32bit
 18 * @addr_high: generic address high 32bit
 19 * @addr_low: generic address lower 32bit
 20 */
 21struct libie_aqc_generic {
 22	__le32 param0;
 23	__le32 param1;
 24	__le32 addr_high;
 25	__le32 addr_low;
 26};
 27LIBIE_CHECK_STRUCT_LEN(16, libie_aqc_generic);
 28
 29/**
 30 * struct libie_aqc_get_ver -  Used in command get version (direct 0x0001)
 31 * @rom_ver: rom version
 32 * @fw_build: number coressponding to firmware build
 33 * @fw_branch: branch identifier of firmware version
 34 * @fw_major: major number of firmware version
 35 * @fw_minor: minor number of firmware version
 36 * @fw_patch: patch of firmware version
 37 * @api_branch: brancch identifier of API version
 38 * @api_major: major number of API version
 39 * @api_minor: minor number of API version
 40 * @api_patch: patch of API version
 41 */
 42struct libie_aqc_get_ver {
 43	__le32	rom_ver;
 44	__le32	fw_build;
 45	u8	fw_branch;
 46	u8	fw_major;
 47	u8	fw_minor;
 48	u8	fw_patch;
 49	u8	api_branch;
 50	u8	api_major;
 51	u8	api_minor;
 52	u8	api_patch;
 53};
 54LIBIE_CHECK_STRUCT_LEN(16, libie_aqc_get_ver);
 55
 56/**
 57 * struct libie_aqc_driver_ver - Used in command send driver version
 58 *				 (indirect 0x0002)
 59 * @major_ver: driver major version
 60 * @minor_ver: driver minor version
 61 * @build_ver: driver build version
 62 * @subbuild_ver: driver subbuild version
 63 * @reserved: for feature use
 64 * @addr_high: high part of response address buff
 65 * @addr_low: low part of response address buff
 66 */
 67struct libie_aqc_driver_ver {
 68	u8	major_ver;
 69	u8	minor_ver;
 70	u8	build_ver;
 71	u8	subbuild_ver;
 72	u8	reserved[4];
 73	__le32	addr_high;
 74	__le32	addr_low;
 75};
 76LIBIE_CHECK_STRUCT_LEN(16, libie_aqc_driver_ver);
 77
 78enum libie_aq_res_id {
 79	LIBIE_AQC_RES_ID_NVM				= 1,
 80	LIBIE_AQC_RES_ID_SDP				= 2,
 81	LIBIE_AQC_RES_ID_CHNG_LOCK			= 3,
 82	LIBIE_AQC_RES_ID_GLBL_LOCK			= 4,
 83};
 84
 85enum libie_aq_res_access_type {
 86	LIBIE_AQC_RES_ACCESS_READ			= 1,
 87	LIBIE_AQC_RES_ACCESS_WRITE			= 2,
 88};
 89
 90#define LIBIE_AQ_RES_NVM_READ_DFLT_TIMEOUT_MS		3000
 91#define LIBIE_AQ_RES_NVM_WRITE_DFLT_TIMEOUT_MS		180000
 92#define LIBIE_AQ_RES_CHNG_LOCK_DFLT_TIMEOUT_MS		1000
 93#define LIBIE_AQ_RES_GLBL_LOCK_DFLT_TIMEOUT_MS		3000
 94
 95#define LIBIE_AQ_RES_GLBL_SUCCESS			0
 96#define LIBIE_AQ_RES_GLBL_IN_PROG			1
 97#define LIBIE_AQ_RES_GLBL_DONE				2
 98
 99/**
100 * struct libie_aqc_req_res - Request resource ownership
101 * @res_id: resource ID (look at enum definition above)
102 * @access_type: read or write (enum definition above)
103 * @timeout: Upon successful completion, FW writes this value and driver is
104 * expected to release resource before timeout. This value is provided in
105 * milliseconds.
106 * @res_number: for SDP, this is the pin ID of the SDP
107 * @status: status only used for LIBIE_AQC_RES_ID_GLBL_LOCK, for others reserved
108 * @reserved: reserved for future use
109 *
110 * Used in commands:
111 * request resource ownership (direct 0x0008)
112 * request resource ownership (direct 0x0009)
113 */
114struct libie_aqc_req_res {
115	__le16	res_id;
116	__le16	access_type;
117
118	__le32	timeout;
119	__le32	res_number;
120	__le16	status;
121	u8	reserved[2];
122};
123LIBIE_CHECK_STRUCT_LEN(16, libie_aqc_req_res);
124
125/**
126 * struct libie_aqc_list_caps - Getting capabilities
127 * @cmd_flags: command flags
128 * @pf_index: index of PF to get caps from
129 * @reserved: reserved for future use
130 * @count: number of capabilities records
131 * @addr_high: high part of response address buff
132 * @addr_low: low part of response address buff
133 *
134 * Used in commands:
135 * get function capabilities (indirect 0x000A)
136 * get device capabilities (indirect 0x000B)
137 */
138struct libie_aqc_list_caps {
139	u8	cmd_flags;
140	u8	pf_index;
141	u8	reserved[2];
142	__le32	count;
143	__le32	addr_high;
144	__le32	addr_low;
145};
146LIBIE_CHECK_STRUCT_LEN(16, libie_aqc_list_caps);
147
148/* Device/Function buffer entry, repeated per reported capability */
149#define LIBIE_AQC_CAPS_SWITCH_MODE			0x0001
150#define LIBIE_AQC_CAPS_MNG_MODE				0x0002
151#define LIBIE_AQC_CAPS_NPAR_ACTIVE			0x0003
152#define LIBIE_AQC_CAPS_OS2BMC_CAP			0x0004
153#define LIBIE_AQC_CAPS_VALID_FUNCTIONS			0x0005
154#define LIBIE_AQC_MAX_VALID_FUNCTIONS			0x8
155#define LIBIE_AQC_CAPS_SRIOV				0x0012
156#define LIBIE_AQC_CAPS_VF				0x0013
157#define LIBIE_AQC_CAPS_VMDQ				0x0014
158#define LIBIE_AQC_CAPS_8021QBG				0x0015
159#define LIBIE_AQC_CAPS_8021QBR				0x0016
160#define LIBIE_AQC_CAPS_VSI				0x0017
161#define LIBIE_AQC_CAPS_DCB				0x0018
162#define LIBIE_AQC_CAPS_FCOE				0x0021
163#define LIBIE_AQC_CAPS_ISCSI				0x0022
164#define LIBIE_AQC_CAPS_RSS				0x0040
165#define LIBIE_AQC_CAPS_RXQS				0x0041
166#define LIBIE_AQC_CAPS_TXQS				0x0042
167#define LIBIE_AQC_CAPS_MSIX				0x0043
168#define LIBIE_AQC_CAPS_VF_MSIX				0x0044
169#define LIBIE_AQC_CAPS_FD				0x0045
170#define LIBIE_AQC_CAPS_1588				0x0046
171#define LIBIE_AQC_CAPS_MAX_MTU				0x0047
172#define LIBIE_AQC_CAPS_NVM_VER				0x0048
173#define LIBIE_AQC_CAPS_PENDING_NVM_VER			0x0049
174#define LIBIE_AQC_CAPS_OROM_VER				0x004A
175#define LIBIE_AQC_CAPS_PENDING_OROM_VER			0x004B
176#define LIBIE_AQC_CAPS_NET_VER				0x004C
177#define LIBIE_AQC_CAPS_PENDING_NET_VER			0x004D
178#define LIBIE_AQC_CAPS_RDMA				0x0051
179#define LIBIE_AQC_CAPS_LED				0x0061
180#define LIBIE_AQC_CAPS_SDP				0x0062
181#define LIBIE_AQC_CAPS_MDIO				0x0063
182#define LIBIE_AQC_CAPS_WSR_PROT				0x0064
183#define LIBIE_AQC_CAPS_SENSOR_READING			0x0067
184#define LIBIE_AQC_INLINE_IPSEC				0x0070
185#define LIBIE_AQC_CAPS_NUM_ENABLED_PORTS		0x0072
186#define LIBIE_AQC_CAPS_PCIE_RESET_AVOIDANCE		0x0076
187#define LIBIE_AQC_CAPS_POST_UPDATE_RESET_RESTRICT	0x0077
188#define LIBIE_AQC_CAPS_NVM_MGMT				0x0080
189#define LIBIE_AQC_CAPS_EXT_TOPO_DEV_IMG0		0x0081
190#define LIBIE_AQC_CAPS_EXT_TOPO_DEV_IMG1		0x0082
191#define LIBIE_AQC_CAPS_EXT_TOPO_DEV_IMG2		0x0083
192#define LIBIE_AQC_CAPS_EXT_TOPO_DEV_IMG3		0x0084
193#define LIBIE_AQC_CAPS_TX_SCHED_TOPO_COMP_MODE		0x0085
194#define LIBIE_AQC_CAPS_NAC_TOPOLOGY			0x0087
195#define LIBIE_AQC_CAPS_FW_LAG_SUPPORT			0x0092
196#define LIBIE_AQC_BIT_ROCEV2_LAG			BIT(0)
197#define LIBIE_AQC_BIT_SRIOV_LAG				BIT(1)
198#define LIBIE_AQC_BIT_SRIOV_AA_LAG			BIT(2)
199#define LIBIE_AQC_CAPS_FLEX10				0x00F1
200#define LIBIE_AQC_CAPS_CEM				0x00F2
201
202/**
203 * struct libie_aqc_list_caps_elem - Getting list of caps elements
204 * @cap: one from the defines list above
205 * @major_ver: major version
206 * @minor_ver: minor version
207 * @number: number of resources described by this capability
208 * @logical_id: logical ID, only meaningful for some types of resources
209 * @phys_id: physical ID, only meaningful for some types of resources
210 * @rsvd1: reserved for future use
211 * @rsvd2: reserved for future use
212 */
213struct libie_aqc_list_caps_elem {
214	__le16	cap;
215
216	u8	major_ver;
217	u8	minor_ver;
218	__le32	number;
219	__le32	logical_id;
220	__le32	phys_id;
221	__le64	rsvd1;
222	__le64	rsvd2;
223};
224LIBIE_CHECK_STRUCT_LEN(32, libie_aqc_list_caps_elem);
225
226/* Admin Queue command opcodes */
227enum libie_adminq_opc {
228	/* FW Logging Commands */
229	libie_aqc_opc_fw_logs_config			= 0xFF30,
230	libie_aqc_opc_fw_logs_register			= 0xFF31,
231	libie_aqc_opc_fw_logs_query			= 0xFF32,
232	libie_aqc_opc_fw_logs_event			= 0xFF33,
233};
234
235enum libie_aqc_fw_logging_mod {
236	LIBIE_AQC_FW_LOG_ID_GENERAL = 0,
237	LIBIE_AQC_FW_LOG_ID_CTRL,
238	LIBIE_AQC_FW_LOG_ID_LINK,
239	LIBIE_AQC_FW_LOG_ID_LINK_TOPO,
240	LIBIE_AQC_FW_LOG_ID_DNL,
241	LIBIE_AQC_FW_LOG_ID_I2C,
242	LIBIE_AQC_FW_LOG_ID_SDP,
243	LIBIE_AQC_FW_LOG_ID_MDIO,
244	LIBIE_AQC_FW_LOG_ID_ADMINQ,
245	LIBIE_AQC_FW_LOG_ID_HDMA,
246	LIBIE_AQC_FW_LOG_ID_LLDP,
247	LIBIE_AQC_FW_LOG_ID_DCBX,
248	LIBIE_AQC_FW_LOG_ID_DCB,
249	LIBIE_AQC_FW_LOG_ID_XLR,
250	LIBIE_AQC_FW_LOG_ID_NVM,
251	LIBIE_AQC_FW_LOG_ID_AUTH,
252	LIBIE_AQC_FW_LOG_ID_VPD,
253	LIBIE_AQC_FW_LOG_ID_IOSF,
254	LIBIE_AQC_FW_LOG_ID_PARSER,
255	LIBIE_AQC_FW_LOG_ID_SW,
256	LIBIE_AQC_FW_LOG_ID_SCHEDULER,
257	LIBIE_AQC_FW_LOG_ID_TXQ,
258	LIBIE_AQC_FW_LOG_ID_RSVD,
259	LIBIE_AQC_FW_LOG_ID_POST,
260	LIBIE_AQC_FW_LOG_ID_WATCHDOG,
261	LIBIE_AQC_FW_LOG_ID_TASK_DISPATCH,
262	LIBIE_AQC_FW_LOG_ID_MNG,
263	LIBIE_AQC_FW_LOG_ID_SYNCE,
264	LIBIE_AQC_FW_LOG_ID_HEALTH,
265	LIBIE_AQC_FW_LOG_ID_TSDRV,
266	LIBIE_AQC_FW_LOG_ID_PFREG,
267	LIBIE_AQC_FW_LOG_ID_MDLVER,
268	LIBIE_AQC_FW_LOG_ID_MAX
269};
270
271/* Set FW Logging configuration (indirect 0xFF30)
272 * Register for FW Logging (indirect 0xFF31)
273 * Query FW Logging (indirect 0xFF32)
274 * FW Log Event (indirect 0xFF33)
275 */
276#define LIBIE_AQC_FW_LOG_CONF_UART_EN		BIT(0)
277#define LIBIE_AQC_FW_LOG_CONF_AQ_EN		BIT(1)
278#define LIBIE_AQC_FW_LOG_QUERY_REGISTERED	BIT(2)
279#define LIBIE_AQC_FW_LOG_CONF_SET_VALID		BIT(3)
280#define LIBIE_AQC_FW_LOG_AQ_REGISTER		BIT(0)
281#define LIBIE_AQC_FW_LOG_AQ_QUERY		BIT(2)
282
283#define LIBIE_AQC_FW_LOG_MIN_RESOLUTION		1
284#define LIBIE_AQC_FW_LOG_MAX_RESOLUTION		128
285
286struct libie_aqc_fw_log {
287	u8 cmd_flags;
288
289	u8 rsp_flag;
290	__le16 fw_rt_msb;
291	union {
292		struct {
293			__le32 fw_rt_lsb;
294		} sync;
295		struct {
296			__le16 log_resolution;
297			__le16 mdl_cnt;
298		} cfg;
299	} ops;
300	__le32 addr_high;
301	__le32 addr_low;
302};
303
304/* Response Buffer for:
305 *    Set Firmware Logging Configuration (0xFF30)
306 *    Query FW Logging (0xFF32)
307 */
308struct libie_aqc_fw_log_cfg_resp {
309	__le16 module_identifier;
310	u8 log_level;
311	u8 rsvd0;
312};
313
314/**
315 * struct libie_aq_desc - Admin Queue (AQ) descriptor
316 * @flags: LIBIE_AQ_FLAG_* flags
317 * @opcode: AQ command opcode
318 * @datalen: length in bytes of indirect/external data buffer
319 * @retval: return value from firmware
320 * @cookie_high: opaque data high-half
321 * @cookie_low: opaque data low-half
322 * @params: command-specific parameters
323 *
324 * Descriptor format for commands the driver posts on the Admin Transmit Queue
325 * (ATQ). The firmware writes back onto the command descriptor and returns
326 * the result of the command. Asynchronous events that are not an immediate
327 * result of the command are written to the Admin Receive Queue (ARQ) using
328 * the same descriptor format. Descriptors are in little-endian notation with
329 * 32-bit words.
330 */
331struct libie_aq_desc {
332	__le16	flags;
333	__le16	opcode;
334	__le16	datalen;
335	__le16	retval;
336	__le32	cookie_high;
337	__le32	cookie_low;
338	union {
339		u8	raw[16];
340		struct	libie_aqc_generic generic;
341		struct	libie_aqc_get_ver get_ver;
342		struct	libie_aqc_driver_ver driver_ver;
343		struct	libie_aqc_req_res res_owner;
344		struct	libie_aqc_list_caps get_cap;
345		struct	libie_aqc_fw_log fw_log;
346	} params;
347};
348LIBIE_CHECK_STRUCT_LEN(32, libie_aq_desc);
349
350/* FW defined boundary for a large buffer, 4k >= Large buffer > 512 bytes */
351#define LIBIE_AQ_LG_BUF				512
352
353/* Flags sub-structure
354 * |0  |1  |2  |3  |4  |5  |6  |7  |8  |9  |10 |11 |12 |13 |14 |15 |
355 * |DD |CMP|ERR|VFE| * *  RESERVED * * |LB |RD |VFC|BUF|SI |EI |FE |
356 */
357#define LIBIE_AQ_FLAG_DD			BIT(0)	/* 0x1    */
358#define LIBIE_AQ_FLAG_CMP			BIT(1)	/* 0x2    */
359#define LIBIE_AQ_FLAG_ERR			BIT(2)	/* 0x4    */
360#define LIBIE_AQ_FLAG_VFE			BIT(3)	/* 0x8    */
361#define LIBIE_AQ_FLAG_LB			BIT(9)	/* 0x200  */
362#define LIBIE_AQ_FLAG_RD			BIT(10)	/* 0x400  */
363#define LIBIE_AQ_FLAG_VFC			BIT(11) /* 0x800  */
364#define LIBIE_AQ_FLAG_BUF			BIT(12)	/* 0x1000 */
365#define LIBIE_AQ_FLAG_SI			BIT(13)	/* 0x2000 */
366#define LIBIE_AQ_FLAG_EI			BIT(14)	/* 0x4000 */
367#define LIBIE_AQ_FLAG_FE			BIT(15)	/* 0x8000 */
368
369/* error codes */
370enum libie_aq_err {
371	LIBIE_AQ_RC_OK		= 0,  /* Success */
372	LIBIE_AQ_RC_EPERM	= 1,  /* Operation not permitted */
373	LIBIE_AQ_RC_ENOENT	= 2,  /* No such element */
374	LIBIE_AQ_RC_ESRCH	= 3,  /* Bad opcode */
375	LIBIE_AQ_RC_EIO		= 5,  /* I/O error */
376	LIBIE_AQ_RC_EAGAIN	= 8,  /* Try again */
377	LIBIE_AQ_RC_ENOMEM	= 9,  /* Out of memory */
378	LIBIE_AQ_RC_EACCES	= 10, /* Permission denied */
379	LIBIE_AQ_RC_EBUSY	= 12, /* Device or resource busy */
380	LIBIE_AQ_RC_EEXIST	= 13, /* Object already exists */
381	LIBIE_AQ_RC_EINVAL	= 14, /* Invalid argument */
382	LIBIE_AQ_RC_ENOSPC	= 16, /* No space left or allocation failure */
383	LIBIE_AQ_RC_ENOSYS	= 17, /* Function not implemented */
384	LIBIE_AQ_RC_EMODE	= 21, /* Op not allowed in current dev mode */
385	LIBIE_AQ_RC_ENOSEC	= 24, /* Missing security manifest */
386	LIBIE_AQ_RC_EBADSIG	= 25, /* Bad RSA signature */
387	LIBIE_AQ_RC_ESVN	= 26, /* SVN number prohibits this package */
388	LIBIE_AQ_RC_EBADMAN	= 27, /* Manifest hash mismatch */
389	LIBIE_AQ_RC_EBADBUF	= 28, /* Buffer hash mismatches manifest */
390};
391
392static inline void *libie_aq_raw(struct libie_aq_desc *desc)
393{
394	return &desc->params.raw;
395}
396
397const char *libie_aq_str(enum libie_aq_err err);
398
399#endif /* __LIBIE_ADMINQ_H */
~/ Read-only file preview.