ena_admin_defs.h 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129
  1. /*
  2. * Copyright 2015 - 2016 Amazon.com, Inc. or its affiliates.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef _ENA_ADMIN_H_
  33. #define _ENA_ADMIN_H_
  34. enum ena_admin_aq_opcode {
  35. ENA_ADMIN_CREATE_SQ = 1,
  36. ENA_ADMIN_DESTROY_SQ = 2,
  37. ENA_ADMIN_CREATE_CQ = 3,
  38. ENA_ADMIN_DESTROY_CQ = 4,
  39. ENA_ADMIN_GET_FEATURE = 8,
  40. ENA_ADMIN_SET_FEATURE = 9,
  41. ENA_ADMIN_GET_STATS = 11,
  42. };
  43. enum ena_admin_aq_completion_status {
  44. ENA_ADMIN_SUCCESS = 0,
  45. ENA_ADMIN_RESOURCE_ALLOCATION_FAILURE = 1,
  46. ENA_ADMIN_BAD_OPCODE = 2,
  47. ENA_ADMIN_UNSUPPORTED_OPCODE = 3,
  48. ENA_ADMIN_MALFORMED_REQUEST = 4,
  49. /* Additional status is provided in ACQ entry extended_status */
  50. ENA_ADMIN_ILLEGAL_PARAMETER = 5,
  51. ENA_ADMIN_UNKNOWN_ERROR = 6,
  52. ENA_ADMIN_RESOURCE_BUSY = 7,
  53. };
  54. enum ena_admin_aq_feature_id {
  55. ENA_ADMIN_DEVICE_ATTRIBUTES = 1,
  56. ENA_ADMIN_MAX_QUEUES_NUM = 2,
  57. ENA_ADMIN_HW_HINTS = 3,
  58. ENA_ADMIN_LLQ = 4,
  59. ENA_ADMIN_MAX_QUEUES_EXT = 7,
  60. ENA_ADMIN_RSS_HASH_FUNCTION = 10,
  61. ENA_ADMIN_STATELESS_OFFLOAD_CONFIG = 11,
  62. ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG = 12,
  63. ENA_ADMIN_MTU = 14,
  64. ENA_ADMIN_RSS_HASH_INPUT = 18,
  65. ENA_ADMIN_INTERRUPT_MODERATION = 20,
  66. ENA_ADMIN_AENQ_CONFIG = 26,
  67. ENA_ADMIN_LINK_CONFIG = 27,
  68. ENA_ADMIN_HOST_ATTR_CONFIG = 28,
  69. ENA_ADMIN_FEATURES_OPCODE_NUM = 32,
  70. };
  71. enum ena_admin_placement_policy_type {
  72. /* descriptors and headers are in host memory */
  73. ENA_ADMIN_PLACEMENT_POLICY_HOST = 1,
  74. /* descriptors and headers are in device memory (a.k.a Low Latency
  75. * Queue)
  76. */
  77. ENA_ADMIN_PLACEMENT_POLICY_DEV = 3,
  78. };
  79. enum ena_admin_link_types {
  80. ENA_ADMIN_LINK_SPEED_1G = 0x1,
  81. ENA_ADMIN_LINK_SPEED_2_HALF_G = 0x2,
  82. ENA_ADMIN_LINK_SPEED_5G = 0x4,
  83. ENA_ADMIN_LINK_SPEED_10G = 0x8,
  84. ENA_ADMIN_LINK_SPEED_25G = 0x10,
  85. ENA_ADMIN_LINK_SPEED_40G = 0x20,
  86. ENA_ADMIN_LINK_SPEED_50G = 0x40,
  87. ENA_ADMIN_LINK_SPEED_100G = 0x80,
  88. ENA_ADMIN_LINK_SPEED_200G = 0x100,
  89. ENA_ADMIN_LINK_SPEED_400G = 0x200,
  90. };
  91. enum ena_admin_completion_policy_type {
  92. /* completion queue entry for each sq descriptor */
  93. ENA_ADMIN_COMPLETION_POLICY_DESC = 0,
  94. /* completion queue entry upon request in sq descriptor */
  95. ENA_ADMIN_COMPLETION_POLICY_DESC_ON_DEMAND = 1,
  96. /* current queue head pointer is updated in OS memory upon sq
  97. * descriptor request
  98. */
  99. ENA_ADMIN_COMPLETION_POLICY_HEAD_ON_DEMAND = 2,
  100. /* current queue head pointer is updated in OS memory for each sq
  101. * descriptor
  102. */
  103. ENA_ADMIN_COMPLETION_POLICY_HEAD = 3,
  104. };
  105. /* basic stats return ena_admin_basic_stats while extanded stats return a
  106. * buffer (string format) with additional statistics per queue and per
  107. * device id
  108. */
  109. enum ena_admin_get_stats_type {
  110. ENA_ADMIN_GET_STATS_TYPE_BASIC = 0,
  111. ENA_ADMIN_GET_STATS_TYPE_EXTENDED = 1,
  112. };
  113. enum ena_admin_get_stats_scope {
  114. ENA_ADMIN_SPECIFIC_QUEUE = 0,
  115. ENA_ADMIN_ETH_TRAFFIC = 1,
  116. };
  117. struct ena_admin_aq_common_desc {
  118. /* 11:0 : command_id
  119. * 15:12 : reserved12
  120. */
  121. u16 command_id;
  122. /* as appears in ena_admin_aq_opcode */
  123. u8 opcode;
  124. /* 0 : phase
  125. * 1 : ctrl_data - control buffer address valid
  126. * 2 : ctrl_data_indirect - control buffer address
  127. * points to list of pages with addresses of control
  128. * buffers
  129. * 7:3 : reserved3
  130. */
  131. u8 flags;
  132. };
  133. /* used in ena_admin_aq_entry. Can point directly to control data, or to a
  134. * page list chunk. Used also at the end of indirect mode page list chunks,
  135. * for chaining.
  136. */
  137. struct ena_admin_ctrl_buff_info {
  138. u32 length;
  139. struct ena_common_mem_addr address;
  140. };
  141. struct ena_admin_sq {
  142. u16 sq_idx;
  143. /* 4:0 : reserved
  144. * 7:5 : sq_direction - 0x1 - Tx; 0x2 - Rx
  145. */
  146. u8 sq_identity;
  147. u8 reserved1;
  148. };
  149. struct ena_admin_aq_entry {
  150. struct ena_admin_aq_common_desc aq_common_descriptor;
  151. union {
  152. u32 inline_data_w1[3];
  153. struct ena_admin_ctrl_buff_info control_buffer;
  154. } u;
  155. u32 inline_data_w4[12];
  156. };
  157. struct ena_admin_acq_common_desc {
  158. /* command identifier to associate it with the aq descriptor
  159. * 11:0 : command_id
  160. * 15:12 : reserved12
  161. */
  162. u16 command;
  163. u8 status;
  164. /* 0 : phase
  165. * 7:1 : reserved1
  166. */
  167. u8 flags;
  168. u16 extended_status;
  169. /* indicates to the driver which AQ entry has been consumed by the
  170. * device and could be reused
  171. */
  172. u16 sq_head_indx;
  173. };
  174. struct ena_admin_acq_entry {
  175. struct ena_admin_acq_common_desc acq_common_descriptor;
  176. u32 response_specific_data[14];
  177. };
  178. struct ena_admin_aq_create_sq_cmd {
  179. struct ena_admin_aq_common_desc aq_common_descriptor;
  180. /* 4:0 : reserved0_w1
  181. * 7:5 : sq_direction - 0x1 - Tx, 0x2 - Rx
  182. */
  183. u8 sq_identity;
  184. u8 reserved8_w1;
  185. /* 3:0 : placement_policy - Describing where the SQ
  186. * descriptor ring and the SQ packet headers reside:
  187. * 0x1 - descriptors and headers are in OS memory,
  188. * 0x3 - descriptors and headers in device memory
  189. * (a.k.a Low Latency Queue)
  190. * 6:4 : completion_policy - Describing what policy
  191. * to use for generation completion entry (cqe) in
  192. * the CQ associated with this SQ: 0x0 - cqe for each
  193. * sq descriptor, 0x1 - cqe upon request in sq
  194. * descriptor, 0x2 - current queue head pointer is
  195. * updated in OS memory upon sq descriptor request
  196. * 0x3 - current queue head pointer is updated in OS
  197. * memory for each sq descriptor
  198. * 7 : reserved15_w1
  199. */
  200. u8 sq_caps_2;
  201. /* 0 : is_physically_contiguous - Described if the
  202. * queue ring memory is allocated in physical
  203. * contiguous pages or split.
  204. * 7:1 : reserved17_w1
  205. */
  206. u8 sq_caps_3;
  207. /* associated completion queue id. This CQ must be created prior to
  208. * SQ creation
  209. */
  210. u16 cq_idx;
  211. /* submission queue depth in entries */
  212. u16 sq_depth;
  213. /* SQ physical base address in OS memory. This field should not be
  214. * used for Low Latency queues. Has to be page aligned.
  215. */
  216. struct ena_common_mem_addr sq_ba;
  217. /* specifies queue head writeback location in OS memory. Valid if
  218. * completion_policy is set to completion_policy_head_on_demand or
  219. * completion_policy_head. Has to be cache aligned
  220. */
  221. struct ena_common_mem_addr sq_head_writeback;
  222. u32 reserved0_w7;
  223. u32 reserved0_w8;
  224. };
  225. enum ena_admin_sq_direction {
  226. ENA_ADMIN_SQ_DIRECTION_TX = 1,
  227. ENA_ADMIN_SQ_DIRECTION_RX = 2,
  228. };
  229. struct ena_admin_acq_create_sq_resp_desc {
  230. struct ena_admin_acq_common_desc acq_common_desc;
  231. u16 sq_idx;
  232. u16 reserved;
  233. /* queue doorbell address as an offset to PCIe MMIO REG BAR */
  234. u32 sq_doorbell_offset;
  235. /* low latency queue ring base address as an offset to PCIe MMIO
  236. * LLQ_MEM BAR
  237. */
  238. u32 llq_descriptors_offset;
  239. /* low latency queue headers' memory as an offset to PCIe MMIO
  240. * LLQ_MEM BAR
  241. */
  242. u32 llq_headers_offset;
  243. };
  244. struct ena_admin_aq_destroy_sq_cmd {
  245. struct ena_admin_aq_common_desc aq_common_descriptor;
  246. struct ena_admin_sq sq;
  247. };
  248. struct ena_admin_acq_destroy_sq_resp_desc {
  249. struct ena_admin_acq_common_desc acq_common_desc;
  250. };
  251. struct ena_admin_aq_create_cq_cmd {
  252. struct ena_admin_aq_common_desc aq_common_descriptor;
  253. /* 4:0 : reserved5
  254. * 5 : interrupt_mode_enabled - if set, cq operates
  255. * in interrupt mode, otherwise - polling
  256. * 7:6 : reserved6
  257. */
  258. u8 cq_caps_1;
  259. /* 4:0 : cq_entry_size_words - size of CQ entry in
  260. * 32-bit words, valid values: 4, 8.
  261. * 7:5 : reserved7
  262. */
  263. u8 cq_caps_2;
  264. /* completion queue depth in # of entries. must be power of 2 */
  265. u16 cq_depth;
  266. /* msix vector assigned to this cq */
  267. u32 msix_vector;
  268. /* cq physical base address in OS memory. CQ must be physically
  269. * contiguous
  270. */
  271. struct ena_common_mem_addr cq_ba;
  272. };
  273. struct ena_admin_acq_create_cq_resp_desc {
  274. struct ena_admin_acq_common_desc acq_common_desc;
  275. u16 cq_idx;
  276. /* actual cq depth in number of entries */
  277. u16 cq_actual_depth;
  278. u32 numa_node_register_offset;
  279. u32 cq_head_db_register_offset;
  280. u32 cq_interrupt_unmask_register_offset;
  281. };
  282. struct ena_admin_aq_destroy_cq_cmd {
  283. struct ena_admin_aq_common_desc aq_common_descriptor;
  284. u16 cq_idx;
  285. u16 reserved1;
  286. };
  287. struct ena_admin_acq_destroy_cq_resp_desc {
  288. struct ena_admin_acq_common_desc acq_common_desc;
  289. };
  290. /* ENA AQ Get Statistics command. Extended statistics are placed in control
  291. * buffer pointed by AQ entry
  292. */
  293. struct ena_admin_aq_get_stats_cmd {
  294. struct ena_admin_aq_common_desc aq_common_descriptor;
  295. union {
  296. /* command specific inline data */
  297. u32 inline_data_w1[3];
  298. struct ena_admin_ctrl_buff_info control_buffer;
  299. } u;
  300. /* stats type as defined in enum ena_admin_get_stats_type */
  301. u8 type;
  302. /* stats scope defined in enum ena_admin_get_stats_scope */
  303. u8 scope;
  304. u16 reserved3;
  305. /* queue id. used when scope is specific_queue */
  306. u16 queue_idx;
  307. /* device id, value 0xFFFF means mine. only privileged device can get
  308. * stats of other device
  309. */
  310. u16 device_id;
  311. };
  312. /* Basic Statistics Command. */
  313. struct ena_admin_basic_stats {
  314. u32 tx_bytes_low;
  315. u32 tx_bytes_high;
  316. u32 tx_pkts_low;
  317. u32 tx_pkts_high;
  318. u32 rx_bytes_low;
  319. u32 rx_bytes_high;
  320. u32 rx_pkts_low;
  321. u32 rx_pkts_high;
  322. u32 rx_drops_low;
  323. u32 rx_drops_high;
  324. };
  325. struct ena_admin_acq_get_stats_resp {
  326. struct ena_admin_acq_common_desc acq_common_desc;
  327. struct ena_admin_basic_stats basic_stats;
  328. };
  329. struct ena_admin_get_set_feature_common_desc {
  330. /* 1:0 : select - 0x1 - current value; 0x3 - default
  331. * value
  332. * 7:3 : reserved3
  333. */
  334. u8 flags;
  335. /* as appears in ena_admin_aq_feature_id */
  336. u8 feature_id;
  337. /* The driver specifies the max feature version it supports and the
  338. * device responds with the currently supported feature version. The
  339. * field is zero based
  340. */
  341. u8 feature_version;
  342. u8 reserved8;
  343. };
  344. struct ena_admin_device_attr_feature_desc {
  345. u32 impl_id;
  346. u32 device_version;
  347. /* bitmap of ena_admin_aq_feature_id */
  348. u32 supported_features;
  349. u32 reserved3;
  350. /* Indicates how many bits are used physical address access. */
  351. u32 phys_addr_width;
  352. /* Indicates how many bits are used virtual address access. */
  353. u32 virt_addr_width;
  354. /* unicast MAC address (in Network byte order) */
  355. u8 mac_addr[6];
  356. u8 reserved7[2];
  357. u32 max_mtu;
  358. };
  359. enum ena_admin_llq_header_location {
  360. /* header is in descriptor list */
  361. ENA_ADMIN_INLINE_HEADER = 1,
  362. /* header in a separate ring, implies 16B descriptor list entry */
  363. ENA_ADMIN_HEADER_RING = 2,
  364. };
  365. enum ena_admin_llq_ring_entry_size {
  366. ENA_ADMIN_LIST_ENTRY_SIZE_128B = 1,
  367. ENA_ADMIN_LIST_ENTRY_SIZE_192B = 2,
  368. ENA_ADMIN_LIST_ENTRY_SIZE_256B = 4,
  369. };
  370. enum ena_admin_llq_num_descs_before_header {
  371. ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_0 = 0,
  372. ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_1 = 1,
  373. ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_2 = 2,
  374. ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_4 = 4,
  375. ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8 = 8,
  376. };
  377. /* packet descriptor list entry always starts with one or more descriptors,
  378. * followed by a header. The rest of the descriptors are located in the
  379. * beginning of the subsequent entry. Stride refers to how the rest of the
  380. * descriptors are placed. This field is relevant only for inline header
  381. * mode
  382. */
  383. enum ena_admin_llq_stride_ctrl {
  384. ENA_ADMIN_SINGLE_DESC_PER_ENTRY = 1,
  385. ENA_ADMIN_MULTIPLE_DESCS_PER_ENTRY = 2,
  386. };
  387. struct ena_admin_feature_llq_desc {
  388. u32 max_llq_num;
  389. u32 max_llq_depth;
  390. /* specify the header locations the device supports. bitfield of
  391. * enum ena_admin_llq_header_location.
  392. */
  393. u16 header_location_ctrl_supported;
  394. /* the header location the driver selected to use. */
  395. u16 header_location_ctrl_enabled;
  396. /* if inline header is specified - this is the size of descriptor
  397. * list entry. If header in a separate ring is specified - this is
  398. * the size of header ring entry. bitfield of enum
  399. * ena_admin_llq_ring_entry_size. specify the entry sizes the device
  400. * supports
  401. */
  402. u16 entry_size_ctrl_supported;
  403. /* the entry size the driver selected to use. */
  404. u16 entry_size_ctrl_enabled;
  405. /* valid only if inline header is specified. First entry associated
  406. * with the packet includes descriptors and header. Rest of the
  407. * entries occupied by descriptors. This parameter defines the max
  408. * number of descriptors precedding the header in the first entry.
  409. * The field is bitfield of enum
  410. * ena_admin_llq_num_descs_before_header and specify the values the
  411. * device supports
  412. */
  413. u16 desc_num_before_header_supported;
  414. /* the desire field the driver selected to use */
  415. u16 desc_num_before_header_enabled;
  416. /* valid only if inline was chosen. bitfield of enum
  417. * ena_admin_llq_stride_ctrl
  418. */
  419. u16 descriptors_stride_ctrl_supported;
  420. /* the stride control the driver selected to use */
  421. u16 descriptors_stride_ctrl_enabled;
  422. /* Maximum size in bytes taken by llq entries in a single tx burst.
  423. * Set to 0 when there is no such limit.
  424. */
  425. u32 max_tx_burst_size;
  426. };
  427. struct ena_admin_queue_ext_feature_fields {
  428. u32 max_tx_sq_num;
  429. u32 max_tx_cq_num;
  430. u32 max_rx_sq_num;
  431. u32 max_rx_cq_num;
  432. u32 max_tx_sq_depth;
  433. u32 max_tx_cq_depth;
  434. u32 max_rx_sq_depth;
  435. u32 max_rx_cq_depth;
  436. u32 max_tx_header_size;
  437. /* Maximum Descriptors number, including meta descriptor, allowed for
  438. * a single Tx packet
  439. */
  440. u16 max_per_packet_tx_descs;
  441. /* Maximum Descriptors number allowed for a single Rx packet */
  442. u16 max_per_packet_rx_descs;
  443. };
  444. struct ena_admin_queue_feature_desc {
  445. u32 max_sq_num;
  446. u32 max_sq_depth;
  447. u32 max_cq_num;
  448. u32 max_cq_depth;
  449. u32 max_legacy_llq_num;
  450. u32 max_legacy_llq_depth;
  451. u32 max_header_size;
  452. /* Maximum Descriptors number, including meta descriptor, allowed for
  453. * a single Tx packet
  454. */
  455. u16 max_packet_tx_descs;
  456. /* Maximum Descriptors number allowed for a single Rx packet */
  457. u16 max_packet_rx_descs;
  458. };
  459. struct ena_admin_set_feature_mtu_desc {
  460. /* exclude L2 */
  461. u32 mtu;
  462. };
  463. struct ena_admin_set_feature_host_attr_desc {
  464. /* host OS info base address in OS memory. host info is 4KB of
  465. * physically contiguous
  466. */
  467. struct ena_common_mem_addr os_info_ba;
  468. /* host debug area base address in OS memory. debug area must be
  469. * physically contiguous
  470. */
  471. struct ena_common_mem_addr debug_ba;
  472. /* debug area size */
  473. u32 debug_area_size;
  474. };
  475. struct ena_admin_feature_intr_moder_desc {
  476. /* interrupt delay granularity in usec */
  477. u16 intr_delay_resolution;
  478. u16 reserved;
  479. };
  480. struct ena_admin_get_feature_link_desc {
  481. /* Link speed in Mb */
  482. u32 speed;
  483. /* bit field of enum ena_admin_link types */
  484. u32 supported;
  485. /* 0 : autoneg
  486. * 1 : duplex - Full Duplex
  487. * 31:2 : reserved2
  488. */
  489. u32 flags;
  490. };
  491. struct ena_admin_feature_aenq_desc {
  492. /* bitmask for AENQ groups the device can report */
  493. u32 supported_groups;
  494. /* bitmask for AENQ groups to report */
  495. u32 enabled_groups;
  496. };
  497. struct ena_admin_feature_offload_desc {
  498. /* 0 : TX_L3_csum_ipv4
  499. * 1 : TX_L4_ipv4_csum_part - The checksum field
  500. * should be initialized with pseudo header checksum
  501. * 2 : TX_L4_ipv4_csum_full
  502. * 3 : TX_L4_ipv6_csum_part - The checksum field
  503. * should be initialized with pseudo header checksum
  504. * 4 : TX_L4_ipv6_csum_full
  505. * 5 : tso_ipv4
  506. * 6 : tso_ipv6
  507. * 7 : tso_ecn
  508. */
  509. u32 tx;
  510. /* Receive side supported stateless offload
  511. * 0 : RX_L3_csum_ipv4 - IPv4 checksum
  512. * 1 : RX_L4_ipv4_csum - TCP/UDP/IPv4 checksum
  513. * 2 : RX_L4_ipv6_csum - TCP/UDP/IPv6 checksum
  514. * 3 : RX_hash - Hash calculation
  515. */
  516. u32 rx_supported;
  517. u32 rx_enabled;
  518. };
  519. enum ena_admin_hash_functions {
  520. ENA_ADMIN_TOEPLITZ = 1,
  521. ENA_ADMIN_CRC32 = 2,
  522. };
  523. struct ena_admin_feature_rss_flow_hash_control {
  524. u32 keys_num;
  525. u32 reserved;
  526. u32 key[10];
  527. };
  528. struct ena_admin_feature_rss_flow_hash_function {
  529. /* 7:0 : funcs - bitmask of ena_admin_hash_functions */
  530. u32 supported_func;
  531. /* 7:0 : selected_func - bitmask of
  532. * ena_admin_hash_functions
  533. */
  534. u32 selected_func;
  535. /* initial value */
  536. u32 init_val;
  537. };
  538. /* RSS flow hash protocols */
  539. enum ena_admin_flow_hash_proto {
  540. ENA_ADMIN_RSS_TCP4 = 0,
  541. ENA_ADMIN_RSS_UDP4 = 1,
  542. ENA_ADMIN_RSS_TCP6 = 2,
  543. ENA_ADMIN_RSS_UDP6 = 3,
  544. ENA_ADMIN_RSS_IP4 = 4,
  545. ENA_ADMIN_RSS_IP6 = 5,
  546. ENA_ADMIN_RSS_IP4_FRAG = 6,
  547. ENA_ADMIN_RSS_NOT_IP = 7,
  548. /* TCPv6 with extension header */
  549. ENA_ADMIN_RSS_TCP6_EX = 8,
  550. /* IPv6 with extension header */
  551. ENA_ADMIN_RSS_IP6_EX = 9,
  552. ENA_ADMIN_RSS_PROTO_NUM = 16,
  553. };
  554. /* RSS flow hash fields */
  555. enum ena_admin_flow_hash_fields {
  556. /* Ethernet Dest Addr */
  557. ENA_ADMIN_RSS_L2_DA = BIT(0),
  558. /* Ethernet Src Addr */
  559. ENA_ADMIN_RSS_L2_SA = BIT(1),
  560. /* ipv4/6 Dest Addr */
  561. ENA_ADMIN_RSS_L3_DA = BIT(2),
  562. /* ipv4/6 Src Addr */
  563. ENA_ADMIN_RSS_L3_SA = BIT(3),
  564. /* tcp/udp Dest Port */
  565. ENA_ADMIN_RSS_L4_DP = BIT(4),
  566. /* tcp/udp Src Port */
  567. ENA_ADMIN_RSS_L4_SP = BIT(5),
  568. };
  569. struct ena_admin_proto_input {
  570. /* flow hash fields (bitwise according to ena_admin_flow_hash_fields) */
  571. u16 fields;
  572. u16 reserved2;
  573. };
  574. struct ena_admin_feature_rss_hash_control {
  575. struct ena_admin_proto_input supported_fields[ENA_ADMIN_RSS_PROTO_NUM];
  576. struct ena_admin_proto_input selected_fields[ENA_ADMIN_RSS_PROTO_NUM];
  577. struct ena_admin_proto_input reserved2[ENA_ADMIN_RSS_PROTO_NUM];
  578. struct ena_admin_proto_input reserved3[ENA_ADMIN_RSS_PROTO_NUM];
  579. };
  580. struct ena_admin_feature_rss_flow_hash_input {
  581. /* supported hash input sorting
  582. * 1 : L3_sort - support swap L3 addresses if DA is
  583. * smaller than SA
  584. * 2 : L4_sort - support swap L4 ports if DP smaller
  585. * SP
  586. */
  587. u16 supported_input_sort;
  588. /* enabled hash input sorting
  589. * 1 : enable_L3_sort - enable swap L3 addresses if
  590. * DA smaller than SA
  591. * 2 : enable_L4_sort - enable swap L4 ports if DP
  592. * smaller than SP
  593. */
  594. u16 enabled_input_sort;
  595. };
  596. enum ena_admin_os_type {
  597. ENA_ADMIN_OS_LINUX = 1,
  598. ENA_ADMIN_OS_WIN = 2,
  599. ENA_ADMIN_OS_DPDK = 3,
  600. ENA_ADMIN_OS_FREEBSD = 4,
  601. ENA_ADMIN_OS_IPXE = 5,
  602. ENA_ADMIN_OS_ESXI = 6,
  603. ENA_ADMIN_OS_GROUPS_NUM = 6,
  604. };
  605. struct ena_admin_host_info {
  606. /* defined in enum ena_admin_os_type */
  607. u32 os_type;
  608. /* os distribution string format */
  609. u8 os_dist_str[128];
  610. /* OS distribution numeric format */
  611. u32 os_dist;
  612. /* kernel version string format */
  613. u8 kernel_ver_str[32];
  614. /* Kernel version numeric format */
  615. u32 kernel_ver;
  616. /* 7:0 : major
  617. * 15:8 : minor
  618. * 23:16 : sub_minor
  619. * 31:24 : module_type
  620. */
  621. u32 driver_version;
  622. /* features bitmap */
  623. u32 supported_network_features[2];
  624. /* ENA spec version of driver */
  625. u16 ena_spec_version;
  626. /* ENA device's Bus, Device and Function
  627. * 2:0 : function
  628. * 7:3 : device
  629. * 15:8 : bus
  630. */
  631. u16 bdf;
  632. /* Number of CPUs */
  633. u16 num_cpus;
  634. u16 reserved;
  635. /* 1 :0 : reserved
  636. * 2 : interrupt_moderation
  637. * 31:3 : reserved
  638. */
  639. u32 driver_supported_features;
  640. };
  641. struct ena_admin_rss_ind_table_entry {
  642. u16 cq_idx;
  643. u16 reserved;
  644. };
  645. struct ena_admin_feature_rss_ind_table {
  646. /* min supported table size (2^min_size) */
  647. u16 min_size;
  648. /* max supported table size (2^max_size) */
  649. u16 max_size;
  650. /* table size (2^size) */
  651. u16 size;
  652. u16 reserved;
  653. /* index of the inline entry. 0xFFFFFFFF means invalid */
  654. u32 inline_index;
  655. /* used for updating single entry, ignored when setting the entire
  656. * table through the control buffer.
  657. */
  658. struct ena_admin_rss_ind_table_entry inline_entry;
  659. };
  660. /* When hint value is 0, driver should use it's own predefined value */
  661. struct ena_admin_ena_hw_hints {
  662. /* value in ms */
  663. u16 mmio_read_timeout;
  664. /* value in ms */
  665. u16 driver_watchdog_timeout;
  666. /* Per packet tx completion timeout. value in ms */
  667. u16 missing_tx_completion_timeout;
  668. u16 missed_tx_completion_count_threshold_to_reset;
  669. /* value in ms */
  670. u16 admin_completion_tx_timeout;
  671. u16 netdev_wd_timeout;
  672. u16 max_tx_sgl_size;
  673. u16 max_rx_sgl_size;
  674. u16 reserved[8];
  675. };
  676. struct ena_admin_get_feat_cmd {
  677. struct ena_admin_aq_common_desc aq_common_descriptor;
  678. struct ena_admin_ctrl_buff_info control_buffer;
  679. struct ena_admin_get_set_feature_common_desc feat_common;
  680. u32 raw[11];
  681. };
  682. struct ena_admin_queue_ext_feature_desc {
  683. /* version */
  684. u8 version;
  685. u8 reserved1[3];
  686. union {
  687. struct ena_admin_queue_ext_feature_fields max_queue_ext;
  688. u32 raw[10];
  689. };
  690. };
  691. struct ena_admin_get_feat_resp {
  692. struct ena_admin_acq_common_desc acq_common_desc;
  693. union {
  694. u32 raw[14];
  695. struct ena_admin_device_attr_feature_desc dev_attr;
  696. struct ena_admin_feature_llq_desc llq;
  697. struct ena_admin_queue_feature_desc max_queue;
  698. struct ena_admin_queue_ext_feature_desc max_queue_ext;
  699. struct ena_admin_feature_aenq_desc aenq;
  700. struct ena_admin_get_feature_link_desc link;
  701. struct ena_admin_feature_offload_desc offload;
  702. struct ena_admin_feature_rss_flow_hash_function flow_hash_func;
  703. struct ena_admin_feature_rss_flow_hash_input flow_hash_input;
  704. struct ena_admin_feature_rss_ind_table ind_table;
  705. struct ena_admin_feature_intr_moder_desc intr_moderation;
  706. struct ena_admin_ena_hw_hints hw_hints;
  707. } u;
  708. };
  709. struct ena_admin_set_feat_cmd {
  710. struct ena_admin_aq_common_desc aq_common_descriptor;
  711. struct ena_admin_ctrl_buff_info control_buffer;
  712. struct ena_admin_get_set_feature_common_desc feat_common;
  713. union {
  714. u32 raw[11];
  715. /* mtu size */
  716. struct ena_admin_set_feature_mtu_desc mtu;
  717. /* host attributes */
  718. struct ena_admin_set_feature_host_attr_desc host_attr;
  719. /* AENQ configuration */
  720. struct ena_admin_feature_aenq_desc aenq;
  721. /* rss flow hash function */
  722. struct ena_admin_feature_rss_flow_hash_function flow_hash_func;
  723. /* rss flow hash input */
  724. struct ena_admin_feature_rss_flow_hash_input flow_hash_input;
  725. /* rss indirection table */
  726. struct ena_admin_feature_rss_ind_table ind_table;
  727. /* LLQ configuration */
  728. struct ena_admin_feature_llq_desc llq;
  729. } u;
  730. };
  731. struct ena_admin_set_feat_resp {
  732. struct ena_admin_acq_common_desc acq_common_desc;
  733. union {
  734. u32 raw[14];
  735. } u;
  736. };
  737. struct ena_admin_aenq_common_desc {
  738. u16 group;
  739. u16 syndrom;
  740. /* 0 : phase
  741. * 7:1 : reserved - MBZ
  742. */
  743. u8 flags;
  744. u8 reserved1[3];
  745. u32 timestamp_low;
  746. u32 timestamp_high;
  747. };
  748. /* asynchronous event notification groups */
  749. enum ena_admin_aenq_group {
  750. ENA_ADMIN_LINK_CHANGE = 0,
  751. ENA_ADMIN_FATAL_ERROR = 1,
  752. ENA_ADMIN_WARNING = 2,
  753. ENA_ADMIN_NOTIFICATION = 3,
  754. ENA_ADMIN_KEEP_ALIVE = 4,
  755. ENA_ADMIN_AENQ_GROUPS_NUM = 5,
  756. };
  757. enum ena_admin_aenq_notification_syndrom {
  758. ENA_ADMIN_SUSPEND = 0,
  759. ENA_ADMIN_RESUME = 1,
  760. ENA_ADMIN_UPDATE_HINTS = 2,
  761. };
  762. struct ena_admin_aenq_entry {
  763. struct ena_admin_aenq_common_desc aenq_common_desc;
  764. /* command specific inline data */
  765. u32 inline_data_w4[12];
  766. };
  767. struct ena_admin_aenq_link_change_desc {
  768. struct ena_admin_aenq_common_desc aenq_common_desc;
  769. /* 0 : link_status */
  770. u32 flags;
  771. };
  772. struct ena_admin_aenq_keep_alive_desc {
  773. struct ena_admin_aenq_common_desc aenq_common_desc;
  774. u32 rx_drops_low;
  775. u32 rx_drops_high;
  776. };
  777. struct ena_admin_ena_mmio_req_read_less_resp {
  778. u16 req_id;
  779. u16 reg_off;
  780. /* value is valid when poll is cleared */
  781. u32 reg_val;
  782. };
  783. /* aq_common_desc */
  784. #define ENA_ADMIN_AQ_COMMON_DESC_COMMAND_ID_MASK GENMASK(11, 0)
  785. #define ENA_ADMIN_AQ_COMMON_DESC_PHASE_MASK BIT(0)
  786. #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_SHIFT 1
  787. #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_MASK BIT(1)
  788. #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_SHIFT 2
  789. #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_MASK BIT(2)
  790. /* sq */
  791. #define ENA_ADMIN_SQ_SQ_DIRECTION_SHIFT 5
  792. #define ENA_ADMIN_SQ_SQ_DIRECTION_MASK GENMASK(7, 5)
  793. /* acq_common_desc */
  794. #define ENA_ADMIN_ACQ_COMMON_DESC_COMMAND_ID_MASK GENMASK(11, 0)
  795. #define ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK BIT(0)
  796. /* aq_create_sq_cmd */
  797. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_SHIFT 5
  798. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_MASK GENMASK(7, 5)
  799. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_PLACEMENT_POLICY_MASK GENMASK(3, 0)
  800. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_SHIFT 4
  801. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_MASK GENMASK(6, 4)
  802. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_IS_PHYSICALLY_CONTIGUOUS_MASK BIT(0)
  803. /* aq_create_cq_cmd */
  804. #define ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_SHIFT 5
  805. #define ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_MASK BIT(5)
  806. #define ENA_ADMIN_AQ_CREATE_CQ_CMD_CQ_ENTRY_SIZE_WORDS_MASK GENMASK(4, 0)
  807. /* get_set_feature_common_desc */
  808. #define ENA_ADMIN_GET_SET_FEATURE_COMMON_DESC_SELECT_MASK GENMASK(1, 0)
  809. /* get_feature_link_desc */
  810. #define ENA_ADMIN_GET_FEATURE_LINK_DESC_AUTONEG_MASK BIT(0)
  811. #define ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_SHIFT 1
  812. #define ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_MASK BIT(1)
  813. /* feature_offload_desc */
  814. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L3_CSUM_IPV4_MASK BIT(0)
  815. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_SHIFT 1
  816. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_MASK BIT(1)
  817. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_SHIFT 2
  818. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_MASK BIT(2)
  819. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_SHIFT 3
  820. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_MASK BIT(3)
  821. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_SHIFT 4
  822. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_MASK BIT(4)
  823. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_SHIFT 5
  824. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK BIT(5)
  825. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_SHIFT 6
  826. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_MASK BIT(6)
  827. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_SHIFT 7
  828. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_MASK BIT(7)
  829. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L3_CSUM_IPV4_MASK BIT(0)
  830. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_SHIFT 1
  831. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_MASK BIT(1)
  832. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_SHIFT 2
  833. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_MASK BIT(2)
  834. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_SHIFT 3
  835. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_MASK BIT(3)
  836. /* feature_rss_flow_hash_function */
  837. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_FUNCS_MASK GENMASK(7, 0)
  838. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_SELECTED_FUNC_MASK GENMASK(7, 0)
  839. /* feature_rss_flow_hash_input */
  840. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_SHIFT 1
  841. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_MASK BIT(1)
  842. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_SHIFT 2
  843. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_MASK BIT(2)
  844. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_SHIFT 1
  845. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_MASK BIT(1)
  846. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_SHIFT 2
  847. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_MASK BIT(2)
  848. /* host_info */
  849. #define ENA_ADMIN_HOST_INFO_MAJOR_MASK GENMASK(7, 0)
  850. #define ENA_ADMIN_HOST_INFO_MINOR_SHIFT 8
  851. #define ENA_ADMIN_HOST_INFO_MINOR_MASK GENMASK(15, 8)
  852. #define ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT 16
  853. #define ENA_ADMIN_HOST_INFO_SUB_MINOR_MASK GENMASK(23, 16)
  854. #define ENA_ADMIN_HOST_INFO_MODULE_TYPE_SHIFT 24
  855. #define ENA_ADMIN_HOST_INFO_MODULE_TYPE_MASK GENMASK(31, 24)
  856. #define ENA_ADMIN_HOST_INFO_FUNCTION_MASK GENMASK(2, 0)
  857. #define ENA_ADMIN_HOST_INFO_DEVICE_SHIFT 3
  858. #define ENA_ADMIN_HOST_INFO_DEVICE_MASK GENMASK(7, 3)
  859. #define ENA_ADMIN_HOST_INFO_BUS_SHIFT 8
  860. #define ENA_ADMIN_HOST_INFO_BUS_MASK GENMASK(15, 8)
  861. #define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_SHIFT 2
  862. #define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_MASK BIT(2)
  863. /* aenq_common_desc */
  864. #define ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK BIT(0)
  865. /* aenq_link_change_desc */
  866. #define ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK BIT(0)
  867. #endif /*_ENA_ADMIN_H_ */