ice_adminq_cmd.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2018, Intel Corporation. */
  3. #ifndef _ICE_ADMINQ_CMD_H_
  4. #define _ICE_ADMINQ_CMD_H_
  5. /* This header file defines the Admin Queue commands, error codes and
  6. * descriptor format. It is shared between Firmware and Software.
  7. */
  8. #define ICE_AQC_TOPO_MAX_LEVEL_NUM 0x9
  9. struct ice_aqc_generic {
  10. __le32 param0;
  11. __le32 param1;
  12. __le32 addr_high;
  13. __le32 addr_low;
  14. };
  15. /* Get version (direct 0x0001) */
  16. struct ice_aqc_get_ver {
  17. __le32 rom_ver;
  18. __le32 fw_build;
  19. u8 fw_branch;
  20. u8 fw_major;
  21. u8 fw_minor;
  22. u8 fw_patch;
  23. u8 api_branch;
  24. u8 api_major;
  25. u8 api_minor;
  26. u8 api_patch;
  27. };
  28. /* Queue Shutdown (direct 0x0003) */
  29. struct ice_aqc_q_shutdown {
  30. #define ICE_AQC_DRIVER_UNLOADING BIT(0)
  31. __le32 driver_unloading;
  32. u8 reserved[12];
  33. };
  34. /* Request resource ownership (direct 0x0008)
  35. * Release resource ownership (direct 0x0009)
  36. */
  37. struct ice_aqc_req_res {
  38. __le16 res_id;
  39. #define ICE_AQC_RES_ID_NVM 1
  40. #define ICE_AQC_RES_ID_SDP 2
  41. #define ICE_AQC_RES_ID_CHNG_LOCK 3
  42. #define ICE_AQC_RES_ID_GLBL_LOCK 4
  43. __le16 access_type;
  44. #define ICE_AQC_RES_ACCESS_READ 1
  45. #define ICE_AQC_RES_ACCESS_WRITE 2
  46. /* Upon successful completion, FW writes this value and driver is
  47. * expected to release resource before timeout. This value is provided
  48. * in milliseconds.
  49. */
  50. __le32 timeout;
  51. #define ICE_AQ_RES_NVM_READ_DFLT_TIMEOUT_MS 3000
  52. #define ICE_AQ_RES_NVM_WRITE_DFLT_TIMEOUT_MS 180000
  53. #define ICE_AQ_RES_CHNG_LOCK_DFLT_TIMEOUT_MS 1000
  54. #define ICE_AQ_RES_GLBL_LOCK_DFLT_TIMEOUT_MS 3000
  55. /* For SDP: pin id of the SDP */
  56. __le32 res_number;
  57. /* Status is only used for ICE_AQC_RES_ID_GLBL_LOCK */
  58. __le16 status;
  59. #define ICE_AQ_RES_GLBL_SUCCESS 0
  60. #define ICE_AQ_RES_GLBL_IN_PROG 1
  61. #define ICE_AQ_RES_GLBL_DONE 2
  62. u8 reserved[2];
  63. };
  64. /* Get function capabilities (indirect 0x000A)
  65. * Get device capabilities (indirect 0x000B)
  66. */
  67. struct ice_aqc_list_caps {
  68. u8 cmd_flags;
  69. u8 pf_index;
  70. u8 reserved[2];
  71. __le32 count;
  72. __le32 addr_high;
  73. __le32 addr_low;
  74. };
  75. /* Device/Function buffer entry, repeated per reported capability */
  76. struct ice_aqc_list_caps_elem {
  77. __le16 cap;
  78. #define ICE_AQC_CAPS_VSI 0x0017
  79. #define ICE_AQC_CAPS_RSS 0x0040
  80. #define ICE_AQC_CAPS_RXQS 0x0041
  81. #define ICE_AQC_CAPS_TXQS 0x0042
  82. #define ICE_AQC_CAPS_MSIX 0x0043
  83. #define ICE_AQC_CAPS_MAX_MTU 0x0047
  84. u8 major_ver;
  85. u8 minor_ver;
  86. /* Number of resources described by this capability */
  87. __le32 number;
  88. /* Only meaningful for some types of resources */
  89. __le32 logical_id;
  90. /* Only meaningful for some types of resources */
  91. __le32 phys_id;
  92. __le64 rsvd1;
  93. __le64 rsvd2;
  94. };
  95. /* Clear PXE Command and response (direct 0x0110) */
  96. struct ice_aqc_clear_pxe {
  97. u8 rx_cnt;
  98. #define ICE_AQC_CLEAR_PXE_RX_CNT 0x2
  99. u8 reserved[15];
  100. };
  101. /* Get switch configuration (0x0200) */
  102. struct ice_aqc_get_sw_cfg {
  103. /* Reserved for command and copy of request flags for response */
  104. __le16 flags;
  105. /* First desc in case of command and next_elem in case of response
  106. * In case of response, if it is not zero, means all the configuration
  107. * was not returned and new command shall be sent with this value in
  108. * the 'first desc' field
  109. */
  110. __le16 element;
  111. /* Reserved for command, only used for response */
  112. __le16 num_elems;
  113. __le16 rsvd;
  114. __le32 addr_high;
  115. __le32 addr_low;
  116. };
  117. /* Each entry in the response buffer is of the following type: */
  118. struct ice_aqc_get_sw_cfg_resp_elem {
  119. /* VSI/Port Number */
  120. __le16 vsi_port_num;
  121. #define ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_S 0
  122. #define ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_M \
  123. (0x3FF << ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_S)
  124. #define ICE_AQC_GET_SW_CONF_RESP_TYPE_S 14
  125. #define ICE_AQC_GET_SW_CONF_RESP_TYPE_M (0x3 << ICE_AQC_GET_SW_CONF_RESP_TYPE_S)
  126. #define ICE_AQC_GET_SW_CONF_RESP_PHYS_PORT 0
  127. #define ICE_AQC_GET_SW_CONF_RESP_VIRT_PORT 1
  128. #define ICE_AQC_GET_SW_CONF_RESP_VSI 2
  129. /* SWID VSI/Port belongs to */
  130. __le16 swid;
  131. /* Bit 14..0 : PF/VF number VSI belongs to
  132. * Bit 15 : VF indication bit
  133. */
  134. __le16 pf_vf_num;
  135. #define ICE_AQC_GET_SW_CONF_RESP_FUNC_NUM_S 0
  136. #define ICE_AQC_GET_SW_CONF_RESP_FUNC_NUM_M \
  137. (0x7FFF << ICE_AQC_GET_SW_CONF_RESP_FUNC_NUM_S)
  138. #define ICE_AQC_GET_SW_CONF_RESP_IS_VF BIT(15)
  139. };
  140. /* The response buffer is as follows. Note that the length of the
  141. * elements array varies with the length of the command response.
  142. */
  143. struct ice_aqc_get_sw_cfg_resp {
  144. struct ice_aqc_get_sw_cfg_resp_elem elements[1];
  145. };
  146. /* Add TSE (indirect 0x0401)
  147. * Delete TSE (indirect 0x040F)
  148. * Move TSE (indirect 0x0408)
  149. */
  150. struct ice_aqc_add_move_delete_elem {
  151. __le16 num_grps_req;
  152. __le16 num_grps_updated;
  153. __le32 reserved;
  154. __le32 addr_high;
  155. __le32 addr_low;
  156. };
  157. struct ice_aqc_elem_info_bw {
  158. __le16 bw_profile_idx;
  159. __le16 bw_alloc;
  160. };
  161. struct ice_aqc_txsched_elem {
  162. u8 elem_type; /* Special field, reserved for some aq calls */
  163. #define ICE_AQC_ELEM_TYPE_UNDEFINED 0x0
  164. #define ICE_AQC_ELEM_TYPE_ROOT_PORT 0x1
  165. #define ICE_AQC_ELEM_TYPE_TC 0x2
  166. #define ICE_AQC_ELEM_TYPE_SE_GENERIC 0x3
  167. #define ICE_AQC_ELEM_TYPE_ENTRY_POINT 0x4
  168. #define ICE_AQC_ELEM_TYPE_LEAF 0x5
  169. #define ICE_AQC_ELEM_TYPE_SE_PADDED 0x6
  170. u8 valid_sections;
  171. #define ICE_AQC_ELEM_VALID_GENERIC BIT(0)
  172. #define ICE_AQC_ELEM_VALID_CIR BIT(1)
  173. #define ICE_AQC_ELEM_VALID_EIR BIT(2)
  174. #define ICE_AQC_ELEM_VALID_SHARED BIT(3)
  175. u8 generic;
  176. #define ICE_AQC_ELEM_GENERIC_MODE_M 0x1
  177. #define ICE_AQC_ELEM_GENERIC_PRIO_S 0x1
  178. #define ICE_AQC_ELEM_GENERIC_PRIO_M (0x7 << ICE_AQC_ELEM_GENERIC_PRIO_S)
  179. #define ICE_AQC_ELEM_GENERIC_SP_S 0x4
  180. #define ICE_AQC_ELEM_GENERIC_SP_M (0x1 << ICE_AQC_ELEM_GENERIC_SP_S)
  181. #define ICE_AQC_ELEM_GENERIC_ADJUST_VAL_S 0x5
  182. #define ICE_AQC_ELEM_GENERIC_ADJUST_VAL_M \
  183. (0x3 << ICE_AQC_ELEM_GENERIC_ADJUST_VAL_S)
  184. u8 flags; /* Special field, reserved for some aq calls */
  185. #define ICE_AQC_ELEM_FLAG_SUSPEND_M 0x1
  186. struct ice_aqc_elem_info_bw cir_bw;
  187. struct ice_aqc_elem_info_bw eir_bw;
  188. __le16 srl_id;
  189. __le16 reserved2;
  190. };
  191. struct ice_aqc_txsched_elem_data {
  192. __le32 parent_teid;
  193. __le32 node_teid;
  194. struct ice_aqc_txsched_elem data;
  195. };
  196. struct ice_aqc_txsched_topo_grp_info_hdr {
  197. __le32 parent_teid;
  198. __le16 num_elems;
  199. __le16 reserved2;
  200. };
  201. struct ice_aqc_delete_elem {
  202. struct ice_aqc_txsched_topo_grp_info_hdr hdr;
  203. __le32 teid[1];
  204. };
  205. /* Query Scheduler Resource Allocation (indirect 0x0412)
  206. * This indirect command retrieves the scheduler resources allocated by
  207. * EMP Firmware to the given PF.
  208. */
  209. struct ice_aqc_query_txsched_res {
  210. u8 reserved[8];
  211. __le32 addr_high;
  212. __le32 addr_low;
  213. };
  214. struct ice_aqc_generic_sched_props {
  215. __le16 phys_levels;
  216. __le16 logical_levels;
  217. u8 flattening_bitmap;
  218. u8 max_device_cgds;
  219. u8 max_pf_cgds;
  220. u8 rsvd0;
  221. __le16 rdma_qsets;
  222. u8 rsvd1[22];
  223. };
  224. struct ice_aqc_layer_props {
  225. u8 logical_layer;
  226. u8 chunk_size;
  227. __le16 max_device_nodes;
  228. __le16 max_pf_nodes;
  229. u8 rsvd0[2];
  230. __le16 max_shared_rate_lmtr;
  231. __le16 max_children;
  232. __le16 max_cir_rl_profiles;
  233. __le16 max_eir_rl_profiles;
  234. __le16 max_srl_profiles;
  235. u8 rsvd1[14];
  236. };
  237. struct ice_aqc_query_txsched_res_resp {
  238. struct ice_aqc_generic_sched_props sched_props;
  239. struct ice_aqc_layer_props layer_props[ICE_AQC_TOPO_MAX_LEVEL_NUM];
  240. };
  241. /* NVM Read command (indirect 0x0701)
  242. * NVM Erase commands (direct 0x0702)
  243. * NVM Update commands (indirect 0x0703)
  244. */
  245. struct ice_aqc_nvm {
  246. u8 cmd_flags;
  247. #define ICE_AQC_NVM_LAST_CMD BIT(0)
  248. #define ICE_AQC_NVM_PCIR_REQ BIT(0) /* Used by NVM Update reply */
  249. #define ICE_AQC_NVM_PRESERVATION_S 1
  250. #define ICE_AQC_NVM_PRESERVATION_M (3 << CSR_AQ_NVM_PRESERVATION_S)
  251. #define ICE_AQC_NVM_NO_PRESERVATION (0 << CSR_AQ_NVM_PRESERVATION_S)
  252. #define ICE_AQC_NVM_PRESERVE_ALL BIT(1)
  253. #define ICE_AQC_NVM_PRESERVE_SELECTED (3 << CSR_AQ_NVM_PRESERVATION_S)
  254. #define ICE_AQC_NVM_FLASH_ONLY BIT(7)
  255. u8 module_typeid;
  256. __le16 length;
  257. #define ICE_AQC_NVM_ERASE_LEN 0xFFFF
  258. __le32 offset;
  259. __le32 addr_high;
  260. __le32 addr_low;
  261. };
  262. /**
  263. * struct ice_aq_desc - Admin Queue (AQ) descriptor
  264. * @flags: ICE_AQ_FLAG_* flags
  265. * @opcode: AQ command opcode
  266. * @datalen: length in bytes of indirect/external data buffer
  267. * @retval: return value from firmware
  268. * @cookie_h: opaque data high-half
  269. * @cookie_l: opaque data low-half
  270. * @params: command-specific parameters
  271. *
  272. * Descriptor format for commands the driver posts on the Admin Transmit Queue
  273. * (ATQ). The firmware writes back onto the command descriptor and returns
  274. * the result of the command. Asynchronous events that are not an immediate
  275. * result of the command are written to the Admin Receive Queue (ARQ) using
  276. * the same descriptor format. Descriptors are in little-endian notation with
  277. * 32-bit words.
  278. */
  279. struct ice_aq_desc {
  280. __le16 flags;
  281. __le16 opcode;
  282. __le16 datalen;
  283. __le16 retval;
  284. __le32 cookie_high;
  285. __le32 cookie_low;
  286. union {
  287. u8 raw[16];
  288. struct ice_aqc_generic generic;
  289. struct ice_aqc_get_ver get_ver;
  290. struct ice_aqc_q_shutdown q_shutdown;
  291. struct ice_aqc_req_res res_owner;
  292. struct ice_aqc_clear_pxe clear_pxe;
  293. struct ice_aqc_list_caps get_cap;
  294. struct ice_aqc_get_sw_cfg get_sw_conf;
  295. struct ice_aqc_query_txsched_res query_sched_res;
  296. struct ice_aqc_add_move_delete_elem add_move_delete_elem;
  297. struct ice_aqc_nvm nvm;
  298. } params;
  299. };
  300. /* FW defined boundary for a large buffer, 4k >= Large buffer > 512 bytes */
  301. #define ICE_AQ_LG_BUF 512
  302. #define ICE_AQ_FLAG_LB_S 9
  303. #define ICE_AQ_FLAG_RD_S 10
  304. #define ICE_AQ_FLAG_BUF_S 12
  305. #define ICE_AQ_FLAG_SI_S 13
  306. #define ICE_AQ_FLAG_LB BIT(ICE_AQ_FLAG_LB_S) /* 0x200 */
  307. #define ICE_AQ_FLAG_RD BIT(ICE_AQ_FLAG_RD_S) /* 0x400 */
  308. #define ICE_AQ_FLAG_BUF BIT(ICE_AQ_FLAG_BUF_S) /* 0x1000 */
  309. #define ICE_AQ_FLAG_SI BIT(ICE_AQ_FLAG_SI_S) /* 0x2000 */
  310. /* error codes */
  311. enum ice_aq_err {
  312. ICE_AQ_RC_OK = 0, /* success */
  313. ICE_AQ_RC_ENOMEM = 9, /* Out of memory */
  314. ICE_AQ_RC_EBUSY = 12, /* Device or resource busy */
  315. ICE_AQ_RC_EEXIST = 13, /* object already exists */
  316. };
  317. /* Admin Queue command opcodes */
  318. enum ice_adminq_opc {
  319. /* AQ commands */
  320. ice_aqc_opc_get_ver = 0x0001,
  321. ice_aqc_opc_q_shutdown = 0x0003,
  322. /* resource ownership */
  323. ice_aqc_opc_req_res = 0x0008,
  324. ice_aqc_opc_release_res = 0x0009,
  325. /* device/function capabilities */
  326. ice_aqc_opc_list_func_caps = 0x000A,
  327. ice_aqc_opc_list_dev_caps = 0x000B,
  328. /* PXE */
  329. ice_aqc_opc_clear_pxe_mode = 0x0110,
  330. /* internal switch commands */
  331. ice_aqc_opc_get_sw_cfg = 0x0200,
  332. ice_aqc_opc_clear_pf_cfg = 0x02A4,
  333. /* transmit scheduler commands */
  334. ice_aqc_opc_delete_sched_elems = 0x040F,
  335. ice_aqc_opc_query_sched_res = 0x0412,
  336. /* NVM commands */
  337. ice_aqc_opc_nvm_read = 0x0701,
  338. };
  339. #endif /* _ICE_ADMINQ_CMD_H_ */