ena_admin_defs.h 23 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  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. };
  53. enum ena_admin_aq_feature_id {
  54. ENA_ADMIN_DEVICE_ATTRIBUTES = 1,
  55. ENA_ADMIN_MAX_QUEUES_NUM = 2,
  56. ENA_ADMIN_HW_HINTS = 3,
  57. ENA_ADMIN_RSS_HASH_FUNCTION = 10,
  58. ENA_ADMIN_STATELESS_OFFLOAD_CONFIG = 11,
  59. ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG = 12,
  60. ENA_ADMIN_MTU = 14,
  61. ENA_ADMIN_RSS_HASH_INPUT = 18,
  62. ENA_ADMIN_INTERRUPT_MODERATION = 20,
  63. ENA_ADMIN_AENQ_CONFIG = 26,
  64. ENA_ADMIN_LINK_CONFIG = 27,
  65. ENA_ADMIN_HOST_ATTR_CONFIG = 28,
  66. ENA_ADMIN_FEATURES_OPCODE_NUM = 32,
  67. };
  68. enum ena_admin_placement_policy_type {
  69. /* descriptors and headers are in host memory */
  70. ENA_ADMIN_PLACEMENT_POLICY_HOST = 1,
  71. /* descriptors and headers are in device memory (a.k.a Low Latency
  72. * Queue)
  73. */
  74. ENA_ADMIN_PLACEMENT_POLICY_DEV = 3,
  75. };
  76. enum ena_admin_link_types {
  77. ENA_ADMIN_LINK_SPEED_1G = 0x1,
  78. ENA_ADMIN_LINK_SPEED_2_HALF_G = 0x2,
  79. ENA_ADMIN_LINK_SPEED_5G = 0x4,
  80. ENA_ADMIN_LINK_SPEED_10G = 0x8,
  81. ENA_ADMIN_LINK_SPEED_25G = 0x10,
  82. ENA_ADMIN_LINK_SPEED_40G = 0x20,
  83. ENA_ADMIN_LINK_SPEED_50G = 0x40,
  84. ENA_ADMIN_LINK_SPEED_100G = 0x80,
  85. ENA_ADMIN_LINK_SPEED_200G = 0x100,
  86. ENA_ADMIN_LINK_SPEED_400G = 0x200,
  87. };
  88. enum ena_admin_completion_policy_type {
  89. /* completion queue entry for each sq descriptor */
  90. ENA_ADMIN_COMPLETION_POLICY_DESC = 0,
  91. /* completion queue entry upon request in sq descriptor */
  92. ENA_ADMIN_COMPLETION_POLICY_DESC_ON_DEMAND = 1,
  93. /* current queue head pointer is updated in OS memory upon sq
  94. * descriptor request
  95. */
  96. ENA_ADMIN_COMPLETION_POLICY_HEAD_ON_DEMAND = 2,
  97. /* current queue head pointer is updated in OS memory for each sq
  98. * descriptor
  99. */
  100. ENA_ADMIN_COMPLETION_POLICY_HEAD = 3,
  101. };
  102. /* basic stats return ena_admin_basic_stats while extanded stats return a
  103. * buffer (string format) with additional statistics per queue and per
  104. * device id
  105. */
  106. enum ena_admin_get_stats_type {
  107. ENA_ADMIN_GET_STATS_TYPE_BASIC = 0,
  108. ENA_ADMIN_GET_STATS_TYPE_EXTENDED = 1,
  109. };
  110. enum ena_admin_get_stats_scope {
  111. ENA_ADMIN_SPECIFIC_QUEUE = 0,
  112. ENA_ADMIN_ETH_TRAFFIC = 1,
  113. };
  114. struct ena_admin_aq_common_desc {
  115. /* 11:0 : command_id
  116. * 15:12 : reserved12
  117. */
  118. u16 command_id;
  119. /* as appears in ena_admin_aq_opcode */
  120. u8 opcode;
  121. /* 0 : phase
  122. * 1 : ctrl_data - control buffer address valid
  123. * 2 : ctrl_data_indirect - control buffer address
  124. * points to list of pages with addresses of control
  125. * buffers
  126. * 7:3 : reserved3
  127. */
  128. u8 flags;
  129. };
  130. /* used in ena_admin_aq_entry. Can point directly to control data, or to a
  131. * page list chunk. Used also at the end of indirect mode page list chunks,
  132. * for chaining.
  133. */
  134. struct ena_admin_ctrl_buff_info {
  135. u32 length;
  136. struct ena_common_mem_addr address;
  137. };
  138. struct ena_admin_sq {
  139. u16 sq_idx;
  140. /* 4:0 : reserved
  141. * 7:5 : sq_direction - 0x1 - Tx; 0x2 - Rx
  142. */
  143. u8 sq_identity;
  144. u8 reserved1;
  145. };
  146. struct ena_admin_aq_entry {
  147. struct ena_admin_aq_common_desc aq_common_descriptor;
  148. union {
  149. u32 inline_data_w1[3];
  150. struct ena_admin_ctrl_buff_info control_buffer;
  151. } u;
  152. u32 inline_data_w4[12];
  153. };
  154. struct ena_admin_acq_common_desc {
  155. /* command identifier to associate it with the aq descriptor
  156. * 11:0 : command_id
  157. * 15:12 : reserved12
  158. */
  159. u16 command;
  160. u8 status;
  161. /* 0 : phase
  162. * 7:1 : reserved1
  163. */
  164. u8 flags;
  165. u16 extended_status;
  166. /* serves as a hint what AQ entries can be revoked */
  167. u16 sq_head_indx;
  168. };
  169. struct ena_admin_acq_entry {
  170. struct ena_admin_acq_common_desc acq_common_descriptor;
  171. u32 response_specific_data[14];
  172. };
  173. struct ena_admin_aq_create_sq_cmd {
  174. struct ena_admin_aq_common_desc aq_common_descriptor;
  175. /* 4:0 : reserved0_w1
  176. * 7:5 : sq_direction - 0x1 - Tx, 0x2 - Rx
  177. */
  178. u8 sq_identity;
  179. u8 reserved8_w1;
  180. /* 3:0 : placement_policy - Describing where the SQ
  181. * descriptor ring and the SQ packet headers reside:
  182. * 0x1 - descriptors and headers are in OS memory,
  183. * 0x3 - descriptors and headers in device memory
  184. * (a.k.a Low Latency Queue)
  185. * 6:4 : completion_policy - Describing what policy
  186. * to use for generation completion entry (cqe) in
  187. * the CQ associated with this SQ: 0x0 - cqe for each
  188. * sq descriptor, 0x1 - cqe upon request in sq
  189. * descriptor, 0x2 - current queue head pointer is
  190. * updated in OS memory upon sq descriptor request
  191. * 0x3 - current queue head pointer is updated in OS
  192. * memory for each sq descriptor
  193. * 7 : reserved15_w1
  194. */
  195. u8 sq_caps_2;
  196. /* 0 : is_physically_contiguous - Described if the
  197. * queue ring memory is allocated in physical
  198. * contiguous pages or split.
  199. * 7:1 : reserved17_w1
  200. */
  201. u8 sq_caps_3;
  202. /* associated completion queue id. This CQ must be created prior to
  203. * SQ creation
  204. */
  205. u16 cq_idx;
  206. /* submission queue depth in entries */
  207. u16 sq_depth;
  208. /* SQ physical base address in OS memory. This field should not be
  209. * used for Low Latency queues. Has to be page aligned.
  210. */
  211. struct ena_common_mem_addr sq_ba;
  212. /* specifies queue head writeback location in OS memory. Valid if
  213. * completion_policy is set to completion_policy_head_on_demand or
  214. * completion_policy_head. Has to be cache aligned
  215. */
  216. struct ena_common_mem_addr sq_head_writeback;
  217. u32 reserved0_w7;
  218. u32 reserved0_w8;
  219. };
  220. enum ena_admin_sq_direction {
  221. ENA_ADMIN_SQ_DIRECTION_TX = 1,
  222. ENA_ADMIN_SQ_DIRECTION_RX = 2,
  223. };
  224. struct ena_admin_acq_create_sq_resp_desc {
  225. struct ena_admin_acq_common_desc acq_common_desc;
  226. u16 sq_idx;
  227. u16 reserved;
  228. /* queue doorbell address as an offset to PCIe MMIO REG BAR */
  229. u32 sq_doorbell_offset;
  230. /* low latency queue ring base address as an offset to PCIe MMIO
  231. * LLQ_MEM BAR
  232. */
  233. u32 llq_descriptors_offset;
  234. /* low latency queue headers' memory as an offset to PCIe MMIO
  235. * LLQ_MEM BAR
  236. */
  237. u32 llq_headers_offset;
  238. };
  239. struct ena_admin_aq_destroy_sq_cmd {
  240. struct ena_admin_aq_common_desc aq_common_descriptor;
  241. struct ena_admin_sq sq;
  242. };
  243. struct ena_admin_acq_destroy_sq_resp_desc {
  244. struct ena_admin_acq_common_desc acq_common_desc;
  245. };
  246. struct ena_admin_aq_create_cq_cmd {
  247. struct ena_admin_aq_common_desc aq_common_descriptor;
  248. /* 4:0 : reserved5
  249. * 5 : interrupt_mode_enabled - if set, cq operates
  250. * in interrupt mode, otherwise - polling
  251. * 7:6 : reserved6
  252. */
  253. u8 cq_caps_1;
  254. /* 4:0 : cq_entry_size_words - size of CQ entry in
  255. * 32-bit words, valid values: 4, 8.
  256. * 7:5 : reserved7
  257. */
  258. u8 cq_caps_2;
  259. /* completion queue depth in # of entries. must be power of 2 */
  260. u16 cq_depth;
  261. /* msix vector assigned to this cq */
  262. u32 msix_vector;
  263. /* cq physical base address in OS memory. CQ must be physically
  264. * contiguous
  265. */
  266. struct ena_common_mem_addr cq_ba;
  267. };
  268. struct ena_admin_acq_create_cq_resp_desc {
  269. struct ena_admin_acq_common_desc acq_common_desc;
  270. u16 cq_idx;
  271. /* actual cq depth in number of entries */
  272. u16 cq_actual_depth;
  273. u32 numa_node_register_offset;
  274. u32 cq_head_db_register_offset;
  275. u32 cq_interrupt_unmask_register_offset;
  276. };
  277. struct ena_admin_aq_destroy_cq_cmd {
  278. struct ena_admin_aq_common_desc aq_common_descriptor;
  279. u16 cq_idx;
  280. u16 reserved1;
  281. };
  282. struct ena_admin_acq_destroy_cq_resp_desc {
  283. struct ena_admin_acq_common_desc acq_common_desc;
  284. };
  285. /* ENA AQ Get Statistics command. Extended statistics are placed in control
  286. * buffer pointed by AQ entry
  287. */
  288. struct ena_admin_aq_get_stats_cmd {
  289. struct ena_admin_aq_common_desc aq_common_descriptor;
  290. union {
  291. /* command specific inline data */
  292. u32 inline_data_w1[3];
  293. struct ena_admin_ctrl_buff_info control_buffer;
  294. } u;
  295. /* stats type as defined in enum ena_admin_get_stats_type */
  296. u8 type;
  297. /* stats scope defined in enum ena_admin_get_stats_scope */
  298. u8 scope;
  299. u16 reserved3;
  300. /* queue id. used when scope is specific_queue */
  301. u16 queue_idx;
  302. /* device id, value 0xFFFF means mine. only privileged device can get
  303. * stats of other device
  304. */
  305. u16 device_id;
  306. };
  307. /* Basic Statistics Command. */
  308. struct ena_admin_basic_stats {
  309. u32 tx_bytes_low;
  310. u32 tx_bytes_high;
  311. u32 tx_pkts_low;
  312. u32 tx_pkts_high;
  313. u32 rx_bytes_low;
  314. u32 rx_bytes_high;
  315. u32 rx_pkts_low;
  316. u32 rx_pkts_high;
  317. u32 rx_drops_low;
  318. u32 rx_drops_high;
  319. };
  320. struct ena_admin_acq_get_stats_resp {
  321. struct ena_admin_acq_common_desc acq_common_desc;
  322. struct ena_admin_basic_stats basic_stats;
  323. };
  324. struct ena_admin_get_set_feature_common_desc {
  325. /* 1:0 : select - 0x1 - current value; 0x3 - default
  326. * value
  327. * 7:3 : reserved3
  328. */
  329. u8 flags;
  330. /* as appears in ena_admin_aq_feature_id */
  331. u8 feature_id;
  332. u16 reserved16;
  333. };
  334. struct ena_admin_device_attr_feature_desc {
  335. u32 impl_id;
  336. u32 device_version;
  337. /* bitmap of ena_admin_aq_feature_id */
  338. u32 supported_features;
  339. u32 reserved3;
  340. /* Indicates how many bits are used physical address access. */
  341. u32 phys_addr_width;
  342. /* Indicates how many bits are used virtual address access. */
  343. u32 virt_addr_width;
  344. /* unicast MAC address (in Network byte order) */
  345. u8 mac_addr[6];
  346. u8 reserved7[2];
  347. u32 max_mtu;
  348. };
  349. struct ena_admin_queue_feature_desc {
  350. /* including LLQs */
  351. u32 max_sq_num;
  352. u32 max_sq_depth;
  353. u32 max_cq_num;
  354. u32 max_cq_depth;
  355. u32 max_llq_num;
  356. u32 max_llq_depth;
  357. u32 max_header_size;
  358. /* Maximum Descriptors number, including meta descriptor, allowed for
  359. * a single Tx packet
  360. */
  361. u16 max_packet_tx_descs;
  362. /* Maximum Descriptors number allowed for a single Rx packet */
  363. u16 max_packet_rx_descs;
  364. };
  365. struct ena_admin_set_feature_mtu_desc {
  366. /* exclude L2 */
  367. u32 mtu;
  368. };
  369. struct ena_admin_set_feature_host_attr_desc {
  370. /* host OS info base address in OS memory. host info is 4KB of
  371. * physically contiguous
  372. */
  373. struct ena_common_mem_addr os_info_ba;
  374. /* host debug area base address in OS memory. debug area must be
  375. * physically contiguous
  376. */
  377. struct ena_common_mem_addr debug_ba;
  378. /* debug area size */
  379. u32 debug_area_size;
  380. };
  381. struct ena_admin_feature_intr_moder_desc {
  382. /* interrupt delay granularity in usec */
  383. u16 intr_delay_resolution;
  384. u16 reserved;
  385. };
  386. struct ena_admin_get_feature_link_desc {
  387. /* Link speed in Mb */
  388. u32 speed;
  389. /* bit field of enum ena_admin_link types */
  390. u32 supported;
  391. /* 0 : autoneg
  392. * 1 : duplex - Full Duplex
  393. * 31:2 : reserved2
  394. */
  395. u32 flags;
  396. };
  397. struct ena_admin_feature_aenq_desc {
  398. /* bitmask for AENQ groups the device can report */
  399. u32 supported_groups;
  400. /* bitmask for AENQ groups to report */
  401. u32 enabled_groups;
  402. };
  403. struct ena_admin_feature_offload_desc {
  404. /* 0 : TX_L3_csum_ipv4
  405. * 1 : TX_L4_ipv4_csum_part - The checksum field
  406. * should be initialized with pseudo header checksum
  407. * 2 : TX_L4_ipv4_csum_full
  408. * 3 : TX_L4_ipv6_csum_part - The checksum field
  409. * should be initialized with pseudo header checksum
  410. * 4 : TX_L4_ipv6_csum_full
  411. * 5 : tso_ipv4
  412. * 6 : tso_ipv6
  413. * 7 : tso_ecn
  414. */
  415. u32 tx;
  416. /* Receive side supported stateless offload
  417. * 0 : RX_L3_csum_ipv4 - IPv4 checksum
  418. * 1 : RX_L4_ipv4_csum - TCP/UDP/IPv4 checksum
  419. * 2 : RX_L4_ipv6_csum - TCP/UDP/IPv6 checksum
  420. * 3 : RX_hash - Hash calculation
  421. */
  422. u32 rx_supported;
  423. u32 rx_enabled;
  424. };
  425. enum ena_admin_hash_functions {
  426. ENA_ADMIN_TOEPLITZ = 1,
  427. ENA_ADMIN_CRC32 = 2,
  428. };
  429. struct ena_admin_feature_rss_flow_hash_control {
  430. u32 keys_num;
  431. u32 reserved;
  432. u32 key[10];
  433. };
  434. struct ena_admin_feature_rss_flow_hash_function {
  435. /* 7:0 : funcs - bitmask of ena_admin_hash_functions */
  436. u32 supported_func;
  437. /* 7:0 : selected_func - bitmask of
  438. * ena_admin_hash_functions
  439. */
  440. u32 selected_func;
  441. /* initial value */
  442. u32 init_val;
  443. };
  444. /* RSS flow hash protocols */
  445. enum ena_admin_flow_hash_proto {
  446. ENA_ADMIN_RSS_TCP4 = 0,
  447. ENA_ADMIN_RSS_UDP4 = 1,
  448. ENA_ADMIN_RSS_TCP6 = 2,
  449. ENA_ADMIN_RSS_UDP6 = 3,
  450. ENA_ADMIN_RSS_IP4 = 4,
  451. ENA_ADMIN_RSS_IP6 = 5,
  452. ENA_ADMIN_RSS_IP4_FRAG = 6,
  453. ENA_ADMIN_RSS_NOT_IP = 7,
  454. /* TCPv6 with extension header */
  455. ENA_ADMIN_RSS_TCP6_EX = 8,
  456. /* IPv6 with extension header */
  457. ENA_ADMIN_RSS_IP6_EX = 9,
  458. ENA_ADMIN_RSS_PROTO_NUM = 16,
  459. };
  460. /* RSS flow hash fields */
  461. enum ena_admin_flow_hash_fields {
  462. /* Ethernet Dest Addr */
  463. ENA_ADMIN_RSS_L2_DA = BIT(0),
  464. /* Ethernet Src Addr */
  465. ENA_ADMIN_RSS_L2_SA = BIT(1),
  466. /* ipv4/6 Dest Addr */
  467. ENA_ADMIN_RSS_L3_DA = BIT(2),
  468. /* ipv4/6 Src Addr */
  469. ENA_ADMIN_RSS_L3_SA = BIT(3),
  470. /* tcp/udp Dest Port */
  471. ENA_ADMIN_RSS_L4_DP = BIT(4),
  472. /* tcp/udp Src Port */
  473. ENA_ADMIN_RSS_L4_SP = BIT(5),
  474. };
  475. struct ena_admin_proto_input {
  476. /* flow hash fields (bitwise according to ena_admin_flow_hash_fields) */
  477. u16 fields;
  478. u16 reserved2;
  479. };
  480. struct ena_admin_feature_rss_hash_control {
  481. struct ena_admin_proto_input supported_fields[ENA_ADMIN_RSS_PROTO_NUM];
  482. struct ena_admin_proto_input selected_fields[ENA_ADMIN_RSS_PROTO_NUM];
  483. struct ena_admin_proto_input reserved2[ENA_ADMIN_RSS_PROTO_NUM];
  484. struct ena_admin_proto_input reserved3[ENA_ADMIN_RSS_PROTO_NUM];
  485. };
  486. struct ena_admin_feature_rss_flow_hash_input {
  487. /* supported hash input sorting
  488. * 1 : L3_sort - support swap L3 addresses if DA is
  489. * smaller than SA
  490. * 2 : L4_sort - support swap L4 ports if DP smaller
  491. * SP
  492. */
  493. u16 supported_input_sort;
  494. /* enabled hash input sorting
  495. * 1 : enable_L3_sort - enable swap L3 addresses if
  496. * DA smaller than SA
  497. * 2 : enable_L4_sort - enable swap L4 ports if DP
  498. * smaller than SP
  499. */
  500. u16 enabled_input_sort;
  501. };
  502. enum ena_admin_os_type {
  503. ENA_ADMIN_OS_LINUX = 1,
  504. ENA_ADMIN_OS_WIN = 2,
  505. ENA_ADMIN_OS_DPDK = 3,
  506. ENA_ADMIN_OS_FREEBSD = 4,
  507. ENA_ADMIN_OS_IPXE = 5,
  508. };
  509. struct ena_admin_host_info {
  510. /* defined in enum ena_admin_os_type */
  511. u32 os_type;
  512. /* os distribution string format */
  513. u8 os_dist_str[128];
  514. /* OS distribution numeric format */
  515. u32 os_dist;
  516. /* kernel version string format */
  517. u8 kernel_ver_str[32];
  518. /* Kernel version numeric format */
  519. u32 kernel_ver;
  520. /* 7:0 : major
  521. * 15:8 : minor
  522. * 23:16 : sub_minor
  523. */
  524. u32 driver_version;
  525. /* features bitmap */
  526. u32 supported_network_features[4];
  527. };
  528. struct ena_admin_rss_ind_table_entry {
  529. u16 cq_idx;
  530. u16 reserved;
  531. };
  532. struct ena_admin_feature_rss_ind_table {
  533. /* min supported table size (2^min_size) */
  534. u16 min_size;
  535. /* max supported table size (2^max_size) */
  536. u16 max_size;
  537. /* table size (2^size) */
  538. u16 size;
  539. u16 reserved;
  540. /* index of the inline entry. 0xFFFFFFFF means invalid */
  541. u32 inline_index;
  542. /* used for updating single entry, ignored when setting the entire
  543. * table through the control buffer.
  544. */
  545. struct ena_admin_rss_ind_table_entry inline_entry;
  546. };
  547. /* When hint value is 0, driver should use it's own predefined value */
  548. struct ena_admin_ena_hw_hints {
  549. /* value in ms */
  550. u16 mmio_read_timeout;
  551. /* value in ms */
  552. u16 driver_watchdog_timeout;
  553. /* Per packet tx completion timeout. value in ms */
  554. u16 missing_tx_completion_timeout;
  555. u16 missed_tx_completion_count_threshold_to_reset;
  556. /* value in ms */
  557. u16 admin_completion_tx_timeout;
  558. u16 netdev_wd_timeout;
  559. u16 max_tx_sgl_size;
  560. u16 max_rx_sgl_size;
  561. u16 reserved[8];
  562. };
  563. struct ena_admin_get_feat_cmd {
  564. struct ena_admin_aq_common_desc aq_common_descriptor;
  565. struct ena_admin_ctrl_buff_info control_buffer;
  566. struct ena_admin_get_set_feature_common_desc feat_common;
  567. u32 raw[11];
  568. };
  569. struct ena_admin_get_feat_resp {
  570. struct ena_admin_acq_common_desc acq_common_desc;
  571. union {
  572. u32 raw[14];
  573. struct ena_admin_device_attr_feature_desc dev_attr;
  574. struct ena_admin_queue_feature_desc max_queue;
  575. struct ena_admin_feature_aenq_desc aenq;
  576. struct ena_admin_get_feature_link_desc link;
  577. struct ena_admin_feature_offload_desc offload;
  578. struct ena_admin_feature_rss_flow_hash_function flow_hash_func;
  579. struct ena_admin_feature_rss_flow_hash_input flow_hash_input;
  580. struct ena_admin_feature_rss_ind_table ind_table;
  581. struct ena_admin_feature_intr_moder_desc intr_moderation;
  582. struct ena_admin_ena_hw_hints hw_hints;
  583. } u;
  584. };
  585. struct ena_admin_set_feat_cmd {
  586. struct ena_admin_aq_common_desc aq_common_descriptor;
  587. struct ena_admin_ctrl_buff_info control_buffer;
  588. struct ena_admin_get_set_feature_common_desc feat_common;
  589. union {
  590. u32 raw[11];
  591. /* mtu size */
  592. struct ena_admin_set_feature_mtu_desc mtu;
  593. /* host attributes */
  594. struct ena_admin_set_feature_host_attr_desc host_attr;
  595. /* AENQ configuration */
  596. struct ena_admin_feature_aenq_desc aenq;
  597. /* rss flow hash function */
  598. struct ena_admin_feature_rss_flow_hash_function flow_hash_func;
  599. /* rss flow hash input */
  600. struct ena_admin_feature_rss_flow_hash_input flow_hash_input;
  601. /* rss indirection table */
  602. struct ena_admin_feature_rss_ind_table ind_table;
  603. } u;
  604. };
  605. struct ena_admin_set_feat_resp {
  606. struct ena_admin_acq_common_desc acq_common_desc;
  607. union {
  608. u32 raw[14];
  609. } u;
  610. };
  611. struct ena_admin_aenq_common_desc {
  612. u16 group;
  613. u16 syndrom;
  614. /* 0 : phase */
  615. u8 flags;
  616. u8 reserved1[3];
  617. u32 timestamp_low;
  618. u32 timestamp_high;
  619. };
  620. /* asynchronous event notification groups */
  621. enum ena_admin_aenq_group {
  622. ENA_ADMIN_LINK_CHANGE = 0,
  623. ENA_ADMIN_FATAL_ERROR = 1,
  624. ENA_ADMIN_WARNING = 2,
  625. ENA_ADMIN_NOTIFICATION = 3,
  626. ENA_ADMIN_KEEP_ALIVE = 4,
  627. ENA_ADMIN_AENQ_GROUPS_NUM = 5,
  628. };
  629. enum ena_admin_aenq_notification_syndrom {
  630. ENA_ADMIN_SUSPEND = 0,
  631. ENA_ADMIN_RESUME = 1,
  632. ENA_ADMIN_UPDATE_HINTS = 2,
  633. };
  634. struct ena_admin_aenq_entry {
  635. struct ena_admin_aenq_common_desc aenq_common_desc;
  636. /* command specific inline data */
  637. u32 inline_data_w4[12];
  638. };
  639. struct ena_admin_aenq_link_change_desc {
  640. struct ena_admin_aenq_common_desc aenq_common_desc;
  641. /* 0 : link_status */
  642. u32 flags;
  643. };
  644. struct ena_admin_aenq_keep_alive_desc {
  645. struct ena_admin_aenq_common_desc aenq_common_desc;
  646. u32 rx_drops_low;
  647. u32 rx_drops_high;
  648. };
  649. struct ena_admin_ena_mmio_req_read_less_resp {
  650. u16 req_id;
  651. u16 reg_off;
  652. /* value is valid when poll is cleared */
  653. u32 reg_val;
  654. };
  655. /* aq_common_desc */
  656. #define ENA_ADMIN_AQ_COMMON_DESC_COMMAND_ID_MASK GENMASK(11, 0)
  657. #define ENA_ADMIN_AQ_COMMON_DESC_PHASE_MASK BIT(0)
  658. #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_SHIFT 1
  659. #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_MASK BIT(1)
  660. #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_SHIFT 2
  661. #define ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_MASK BIT(2)
  662. /* sq */
  663. #define ENA_ADMIN_SQ_SQ_DIRECTION_SHIFT 5
  664. #define ENA_ADMIN_SQ_SQ_DIRECTION_MASK GENMASK(7, 5)
  665. /* acq_common_desc */
  666. #define ENA_ADMIN_ACQ_COMMON_DESC_COMMAND_ID_MASK GENMASK(11, 0)
  667. #define ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK BIT(0)
  668. /* aq_create_sq_cmd */
  669. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_SHIFT 5
  670. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_SQ_DIRECTION_MASK GENMASK(7, 5)
  671. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_PLACEMENT_POLICY_MASK GENMASK(3, 0)
  672. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_SHIFT 4
  673. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_COMPLETION_POLICY_MASK GENMASK(6, 4)
  674. #define ENA_ADMIN_AQ_CREATE_SQ_CMD_IS_PHYSICALLY_CONTIGUOUS_MASK BIT(0)
  675. /* aq_create_cq_cmd */
  676. #define ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_SHIFT 5
  677. #define ENA_ADMIN_AQ_CREATE_CQ_CMD_INTERRUPT_MODE_ENABLED_MASK BIT(5)
  678. #define ENA_ADMIN_AQ_CREATE_CQ_CMD_CQ_ENTRY_SIZE_WORDS_MASK GENMASK(4, 0)
  679. /* get_set_feature_common_desc */
  680. #define ENA_ADMIN_GET_SET_FEATURE_COMMON_DESC_SELECT_MASK GENMASK(1, 0)
  681. /* get_feature_link_desc */
  682. #define ENA_ADMIN_GET_FEATURE_LINK_DESC_AUTONEG_MASK BIT(0)
  683. #define ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_SHIFT 1
  684. #define ENA_ADMIN_GET_FEATURE_LINK_DESC_DUPLEX_MASK BIT(1)
  685. /* feature_offload_desc */
  686. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L3_CSUM_IPV4_MASK BIT(0)
  687. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_SHIFT 1
  688. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_PART_MASK BIT(1)
  689. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_SHIFT 2
  690. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV4_CSUM_FULL_MASK BIT(2)
  691. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_SHIFT 3
  692. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_PART_MASK BIT(3)
  693. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_SHIFT 4
  694. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TX_L4_IPV6_CSUM_FULL_MASK BIT(4)
  695. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_SHIFT 5
  696. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV4_MASK BIT(5)
  697. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_SHIFT 6
  698. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_IPV6_MASK BIT(6)
  699. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_SHIFT 7
  700. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_TSO_ECN_MASK BIT(7)
  701. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L3_CSUM_IPV4_MASK BIT(0)
  702. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_SHIFT 1
  703. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV4_CSUM_MASK BIT(1)
  704. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_SHIFT 2
  705. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_L4_IPV6_CSUM_MASK BIT(2)
  706. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_SHIFT 3
  707. #define ENA_ADMIN_FEATURE_OFFLOAD_DESC_RX_HASH_MASK BIT(3)
  708. /* feature_rss_flow_hash_function */
  709. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_FUNCS_MASK GENMASK(7, 0)
  710. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_FUNCTION_SELECTED_FUNC_MASK GENMASK(7, 0)
  711. /* feature_rss_flow_hash_input */
  712. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_SHIFT 1
  713. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L3_SORT_MASK BIT(1)
  714. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_SHIFT 2
  715. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_L4_SORT_MASK BIT(2)
  716. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_SHIFT 1
  717. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L3_SORT_MASK BIT(1)
  718. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_SHIFT 2
  719. #define ENA_ADMIN_FEATURE_RSS_FLOW_HASH_INPUT_ENABLE_L4_SORT_MASK BIT(2)
  720. /* host_info */
  721. #define ENA_ADMIN_HOST_INFO_MAJOR_MASK GENMASK(7, 0)
  722. #define ENA_ADMIN_HOST_INFO_MINOR_SHIFT 8
  723. #define ENA_ADMIN_HOST_INFO_MINOR_MASK GENMASK(15, 8)
  724. #define ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT 16
  725. #define ENA_ADMIN_HOST_INFO_SUB_MINOR_MASK GENMASK(23, 16)
  726. /* aenq_common_desc */
  727. #define ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK BIT(0)
  728. /* aenq_link_change_desc */
  729. #define ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK BIT(0)
  730. #endif /*_ENA_ADMIN_H_ */