ena_eth_io_defs.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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_ETH_IO_H_
  33. #define _ENA_ETH_IO_H_
  34. enum ena_eth_io_l3_proto_index {
  35. ENA_ETH_IO_L3_PROTO_UNKNOWN = 0,
  36. ENA_ETH_IO_L3_PROTO_IPV4 = 8,
  37. ENA_ETH_IO_L3_PROTO_IPV6 = 11,
  38. ENA_ETH_IO_L3_PROTO_FCOE = 21,
  39. ENA_ETH_IO_L3_PROTO_ROCE = 22,
  40. };
  41. enum ena_eth_io_l4_proto_index {
  42. ENA_ETH_IO_L4_PROTO_UNKNOWN = 0,
  43. ENA_ETH_IO_L4_PROTO_TCP = 12,
  44. ENA_ETH_IO_L4_PROTO_UDP = 13,
  45. ENA_ETH_IO_L4_PROTO_ROUTEABLE_ROCE = 23,
  46. };
  47. struct ena_eth_io_tx_desc {
  48. /* 15:0 : length - Buffer length in bytes, must
  49. * include any packet trailers that the ENA supposed
  50. * to update like End-to-End CRC, Authentication GMAC
  51. * etc. This length must not include the
  52. * 'Push_Buffer' length. This length must not include
  53. * the 4-byte added in the end for 802.3 Ethernet FCS
  54. * 21:16 : req_id_hi - Request ID[15:10]
  55. * 22 : reserved22 - MBZ
  56. * 23 : meta_desc - MBZ
  57. * 24 : phase
  58. * 25 : reserved1 - MBZ
  59. * 26 : first - Indicates first descriptor in
  60. * transaction
  61. * 27 : last - Indicates last descriptor in
  62. * transaction
  63. * 28 : comp_req - Indicates whether completion
  64. * should be posted, after packet is transmitted.
  65. * Valid only for first descriptor
  66. * 30:29 : reserved29 - MBZ
  67. * 31 : reserved31 - MBZ
  68. */
  69. u32 len_ctrl;
  70. /* 3:0 : l3_proto_idx - L3 protocol. This field
  71. * required when l3_csum_en,l3_csum or tso_en are set.
  72. * 4 : DF - IPv4 DF, must be 0 if packet is IPv4 and
  73. * DF flags of the IPv4 header is 0. Otherwise must
  74. * be set to 1
  75. * 6:5 : reserved5
  76. * 7 : tso_en - Enable TSO, For TCP only.
  77. * 12:8 : l4_proto_idx - L4 protocol. This field need
  78. * to be set when l4_csum_en or tso_en are set.
  79. * 13 : l3_csum_en - enable IPv4 header checksum.
  80. * 14 : l4_csum_en - enable TCP/UDP checksum.
  81. * 15 : ethernet_fcs_dis - when set, the controller
  82. * will not append the 802.3 Ethernet Frame Check
  83. * Sequence to the packet
  84. * 16 : reserved16
  85. * 17 : l4_csum_partial - L4 partial checksum. when
  86. * set to 0, the ENA calculates the L4 checksum,
  87. * where the Destination Address required for the
  88. * TCP/UDP pseudo-header is taken from the actual
  89. * packet L3 header. when set to 1, the ENA doesn't
  90. * calculate the sum of the pseudo-header, instead,
  91. * the checksum field of the L4 is used instead. When
  92. * TSO enabled, the checksum of the pseudo-header
  93. * must not include the tcp length field. L4 partial
  94. * checksum should be used for IPv6 packet that
  95. * contains Routing Headers.
  96. * 20:18 : reserved18 - MBZ
  97. * 21 : reserved21 - MBZ
  98. * 31:22 : req_id_lo - Request ID[9:0]
  99. */
  100. u32 meta_ctrl;
  101. u32 buff_addr_lo;
  102. /* address high and header size
  103. * 15:0 : addr_hi - Buffer Pointer[47:32]
  104. * 23:16 : reserved16_w2
  105. * 31:24 : header_length - Header length. For Low
  106. * Latency Queues, this fields indicates the number
  107. * of bytes written to the headers' memory. For
  108. * normal queues, if packet is TCP or UDP, and longer
  109. * than max_header_size, then this field should be
  110. * set to the sum of L4 header offset and L4 header
  111. * size(without options), otherwise, this field
  112. * should be set to 0. For both modes, this field
  113. * must not exceed the max_header_size.
  114. * max_header_size value is reported by the Max
  115. * Queues Feature descriptor
  116. */
  117. u32 buff_addr_hi_hdr_sz;
  118. };
  119. struct ena_eth_io_tx_meta_desc {
  120. /* 9:0 : req_id_lo - Request ID[9:0]
  121. * 11:10 : reserved10 - MBZ
  122. * 12 : reserved12 - MBZ
  123. * 13 : reserved13 - MBZ
  124. * 14 : ext_valid - if set, offset fields in Word2
  125. * are valid Also MSS High in Word 0 and bits [31:24]
  126. * in Word 3
  127. * 15 : reserved15
  128. * 19:16 : mss_hi
  129. * 20 : eth_meta_type - 0: Tx Metadata Descriptor, 1:
  130. * Extended Metadata Descriptor
  131. * 21 : meta_store - Store extended metadata in queue
  132. * cache
  133. * 22 : reserved22 - MBZ
  134. * 23 : meta_desc - MBO
  135. * 24 : phase
  136. * 25 : reserved25 - MBZ
  137. * 26 : first - Indicates first descriptor in
  138. * transaction
  139. * 27 : last - Indicates last descriptor in
  140. * transaction
  141. * 28 : comp_req - Indicates whether completion
  142. * should be posted, after packet is transmitted.
  143. * Valid only for first descriptor
  144. * 30:29 : reserved29 - MBZ
  145. * 31 : reserved31 - MBZ
  146. */
  147. u32 len_ctrl;
  148. /* 5:0 : req_id_hi
  149. * 31:6 : reserved6 - MBZ
  150. */
  151. u32 word1;
  152. /* 7:0 : l3_hdr_len
  153. * 15:8 : l3_hdr_off
  154. * 21:16 : l4_hdr_len_in_words - counts the L4 header
  155. * length in words. there is an explicit assumption
  156. * that L4 header appears right after L3 header and
  157. * L4 offset is based on l3_hdr_off+l3_hdr_len
  158. * 31:22 : mss_lo
  159. */
  160. u32 word2;
  161. u32 reserved;
  162. };
  163. struct ena_eth_io_tx_cdesc {
  164. /* Request ID[15:0] */
  165. u16 req_id;
  166. u8 status;
  167. /* flags
  168. * 0 : phase
  169. * 7:1 : reserved1
  170. */
  171. u8 flags;
  172. u16 sub_qid;
  173. u16 sq_head_idx;
  174. };
  175. struct ena_eth_io_rx_desc {
  176. /* In bytes. 0 means 64KB */
  177. u16 length;
  178. /* MBZ */
  179. u8 reserved2;
  180. /* 0 : phase
  181. * 1 : reserved1 - MBZ
  182. * 2 : first - Indicates first descriptor in
  183. * transaction
  184. * 3 : last - Indicates last descriptor in transaction
  185. * 4 : comp_req
  186. * 5 : reserved5 - MBO
  187. * 7:6 : reserved6 - MBZ
  188. */
  189. u8 ctrl;
  190. u16 req_id;
  191. /* MBZ */
  192. u16 reserved6;
  193. u32 buff_addr_lo;
  194. u16 buff_addr_hi;
  195. /* MBZ */
  196. u16 reserved16_w3;
  197. };
  198. /* 4-word format Note: all ethernet parsing information are valid only when
  199. * last=1
  200. */
  201. struct ena_eth_io_rx_cdesc_base {
  202. /* 4:0 : l3_proto_idx
  203. * 6:5 : src_vlan_cnt
  204. * 7 : reserved7 - MBZ
  205. * 12:8 : l4_proto_idx
  206. * 13 : l3_csum_err - when set, either the L3
  207. * checksum error detected, or, the controller didn't
  208. * validate the checksum. This bit is valid only when
  209. * l3_proto_idx indicates IPv4 packet
  210. * 14 : l4_csum_err - when set, either the L4
  211. * checksum error detected, or, the controller didn't
  212. * validate the checksum. This bit is valid only when
  213. * l4_proto_idx indicates TCP/UDP packet, and,
  214. * ipv4_frag is not set
  215. * 15 : ipv4_frag - Indicates IPv4 fragmented packet
  216. * 23:16 : reserved16
  217. * 24 : phase
  218. * 25 : l3_csum2 - second checksum engine result
  219. * 26 : first - Indicates first descriptor in
  220. * transaction
  221. * 27 : last - Indicates last descriptor in
  222. * transaction
  223. * 29:28 : reserved28
  224. * 30 : buffer - 0: Metadata descriptor. 1: Buffer
  225. * Descriptor was used
  226. * 31 : reserved31
  227. */
  228. u32 status;
  229. u16 length;
  230. u16 req_id;
  231. /* 32-bit hash result */
  232. u32 hash;
  233. u16 sub_qid;
  234. u16 reserved;
  235. };
  236. /* 8-word format */
  237. struct ena_eth_io_rx_cdesc_ext {
  238. struct ena_eth_io_rx_cdesc_base base;
  239. u32 buff_addr_lo;
  240. u16 buff_addr_hi;
  241. u16 reserved16;
  242. u32 reserved_w6;
  243. u32 reserved_w7;
  244. };
  245. struct ena_eth_io_intr_reg {
  246. /* 14:0 : rx_intr_delay
  247. * 29:15 : tx_intr_delay
  248. * 30 : intr_unmask
  249. * 31 : reserved
  250. */
  251. u32 intr_control;
  252. };
  253. struct ena_eth_io_numa_node_cfg_reg {
  254. /* 7:0 : numa
  255. * 30:8 : reserved
  256. * 31 : enabled
  257. */
  258. u32 numa_cfg;
  259. };
  260. /* tx_desc */
  261. #define ENA_ETH_IO_TX_DESC_LENGTH_MASK GENMASK(15, 0)
  262. #define ENA_ETH_IO_TX_DESC_REQ_ID_HI_SHIFT 16
  263. #define ENA_ETH_IO_TX_DESC_REQ_ID_HI_MASK GENMASK(21, 16)
  264. #define ENA_ETH_IO_TX_DESC_META_DESC_SHIFT 23
  265. #define ENA_ETH_IO_TX_DESC_META_DESC_MASK BIT(23)
  266. #define ENA_ETH_IO_TX_DESC_PHASE_SHIFT 24
  267. #define ENA_ETH_IO_TX_DESC_PHASE_MASK BIT(24)
  268. #define ENA_ETH_IO_TX_DESC_FIRST_SHIFT 26
  269. #define ENA_ETH_IO_TX_DESC_FIRST_MASK BIT(26)
  270. #define ENA_ETH_IO_TX_DESC_LAST_SHIFT 27
  271. #define ENA_ETH_IO_TX_DESC_LAST_MASK BIT(27)
  272. #define ENA_ETH_IO_TX_DESC_COMP_REQ_SHIFT 28
  273. #define ENA_ETH_IO_TX_DESC_COMP_REQ_MASK BIT(28)
  274. #define ENA_ETH_IO_TX_DESC_L3_PROTO_IDX_MASK GENMASK(3, 0)
  275. #define ENA_ETH_IO_TX_DESC_DF_SHIFT 4
  276. #define ENA_ETH_IO_TX_DESC_DF_MASK BIT(4)
  277. #define ENA_ETH_IO_TX_DESC_TSO_EN_SHIFT 7
  278. #define ENA_ETH_IO_TX_DESC_TSO_EN_MASK BIT(7)
  279. #define ENA_ETH_IO_TX_DESC_L4_PROTO_IDX_SHIFT 8
  280. #define ENA_ETH_IO_TX_DESC_L4_PROTO_IDX_MASK GENMASK(12, 8)
  281. #define ENA_ETH_IO_TX_DESC_L3_CSUM_EN_SHIFT 13
  282. #define ENA_ETH_IO_TX_DESC_L3_CSUM_EN_MASK BIT(13)
  283. #define ENA_ETH_IO_TX_DESC_L4_CSUM_EN_SHIFT 14
  284. #define ENA_ETH_IO_TX_DESC_L4_CSUM_EN_MASK BIT(14)
  285. #define ENA_ETH_IO_TX_DESC_ETHERNET_FCS_DIS_SHIFT 15
  286. #define ENA_ETH_IO_TX_DESC_ETHERNET_FCS_DIS_MASK BIT(15)
  287. #define ENA_ETH_IO_TX_DESC_L4_CSUM_PARTIAL_SHIFT 17
  288. #define ENA_ETH_IO_TX_DESC_L4_CSUM_PARTIAL_MASK BIT(17)
  289. #define ENA_ETH_IO_TX_DESC_REQ_ID_LO_SHIFT 22
  290. #define ENA_ETH_IO_TX_DESC_REQ_ID_LO_MASK GENMASK(31, 22)
  291. #define ENA_ETH_IO_TX_DESC_ADDR_HI_MASK GENMASK(15, 0)
  292. #define ENA_ETH_IO_TX_DESC_HEADER_LENGTH_SHIFT 24
  293. #define ENA_ETH_IO_TX_DESC_HEADER_LENGTH_MASK GENMASK(31, 24)
  294. /* tx_meta_desc */
  295. #define ENA_ETH_IO_TX_META_DESC_REQ_ID_LO_MASK GENMASK(9, 0)
  296. #define ENA_ETH_IO_TX_META_DESC_EXT_VALID_SHIFT 14
  297. #define ENA_ETH_IO_TX_META_DESC_EXT_VALID_MASK BIT(14)
  298. #define ENA_ETH_IO_TX_META_DESC_MSS_HI_SHIFT 16
  299. #define ENA_ETH_IO_TX_META_DESC_MSS_HI_MASK GENMASK(19, 16)
  300. #define ENA_ETH_IO_TX_META_DESC_ETH_META_TYPE_SHIFT 20
  301. #define ENA_ETH_IO_TX_META_DESC_ETH_META_TYPE_MASK BIT(20)
  302. #define ENA_ETH_IO_TX_META_DESC_META_STORE_SHIFT 21
  303. #define ENA_ETH_IO_TX_META_DESC_META_STORE_MASK BIT(21)
  304. #define ENA_ETH_IO_TX_META_DESC_META_DESC_SHIFT 23
  305. #define ENA_ETH_IO_TX_META_DESC_META_DESC_MASK BIT(23)
  306. #define ENA_ETH_IO_TX_META_DESC_PHASE_SHIFT 24
  307. #define ENA_ETH_IO_TX_META_DESC_PHASE_MASK BIT(24)
  308. #define ENA_ETH_IO_TX_META_DESC_FIRST_SHIFT 26
  309. #define ENA_ETH_IO_TX_META_DESC_FIRST_MASK BIT(26)
  310. #define ENA_ETH_IO_TX_META_DESC_LAST_SHIFT 27
  311. #define ENA_ETH_IO_TX_META_DESC_LAST_MASK BIT(27)
  312. #define ENA_ETH_IO_TX_META_DESC_COMP_REQ_SHIFT 28
  313. #define ENA_ETH_IO_TX_META_DESC_COMP_REQ_MASK BIT(28)
  314. #define ENA_ETH_IO_TX_META_DESC_REQ_ID_HI_MASK GENMASK(5, 0)
  315. #define ENA_ETH_IO_TX_META_DESC_L3_HDR_LEN_MASK GENMASK(7, 0)
  316. #define ENA_ETH_IO_TX_META_DESC_L3_HDR_OFF_SHIFT 8
  317. #define ENA_ETH_IO_TX_META_DESC_L3_HDR_OFF_MASK GENMASK(15, 8)
  318. #define ENA_ETH_IO_TX_META_DESC_L4_HDR_LEN_IN_WORDS_SHIFT 16
  319. #define ENA_ETH_IO_TX_META_DESC_L4_HDR_LEN_IN_WORDS_MASK GENMASK(21, 16)
  320. #define ENA_ETH_IO_TX_META_DESC_MSS_LO_SHIFT 22
  321. #define ENA_ETH_IO_TX_META_DESC_MSS_LO_MASK GENMASK(31, 22)
  322. /* tx_cdesc */
  323. #define ENA_ETH_IO_TX_CDESC_PHASE_MASK BIT(0)
  324. /* rx_desc */
  325. #define ENA_ETH_IO_RX_DESC_PHASE_MASK BIT(0)
  326. #define ENA_ETH_IO_RX_DESC_FIRST_SHIFT 2
  327. #define ENA_ETH_IO_RX_DESC_FIRST_MASK BIT(2)
  328. #define ENA_ETH_IO_RX_DESC_LAST_SHIFT 3
  329. #define ENA_ETH_IO_RX_DESC_LAST_MASK BIT(3)
  330. #define ENA_ETH_IO_RX_DESC_COMP_REQ_SHIFT 4
  331. #define ENA_ETH_IO_RX_DESC_COMP_REQ_MASK BIT(4)
  332. /* rx_cdesc_base */
  333. #define ENA_ETH_IO_RX_CDESC_BASE_L3_PROTO_IDX_MASK GENMASK(4, 0)
  334. #define ENA_ETH_IO_RX_CDESC_BASE_SRC_VLAN_CNT_SHIFT 5
  335. #define ENA_ETH_IO_RX_CDESC_BASE_SRC_VLAN_CNT_MASK GENMASK(6, 5)
  336. #define ENA_ETH_IO_RX_CDESC_BASE_L4_PROTO_IDX_SHIFT 8
  337. #define ENA_ETH_IO_RX_CDESC_BASE_L4_PROTO_IDX_MASK GENMASK(12, 8)
  338. #define ENA_ETH_IO_RX_CDESC_BASE_L3_CSUM_ERR_SHIFT 13
  339. #define ENA_ETH_IO_RX_CDESC_BASE_L3_CSUM_ERR_MASK BIT(13)
  340. #define ENA_ETH_IO_RX_CDESC_BASE_L4_CSUM_ERR_SHIFT 14
  341. #define ENA_ETH_IO_RX_CDESC_BASE_L4_CSUM_ERR_MASK BIT(14)
  342. #define ENA_ETH_IO_RX_CDESC_BASE_IPV4_FRAG_SHIFT 15
  343. #define ENA_ETH_IO_RX_CDESC_BASE_IPV4_FRAG_MASK BIT(15)
  344. #define ENA_ETH_IO_RX_CDESC_BASE_PHASE_SHIFT 24
  345. #define ENA_ETH_IO_RX_CDESC_BASE_PHASE_MASK BIT(24)
  346. #define ENA_ETH_IO_RX_CDESC_BASE_L3_CSUM2_SHIFT 25
  347. #define ENA_ETH_IO_RX_CDESC_BASE_L3_CSUM2_MASK BIT(25)
  348. #define ENA_ETH_IO_RX_CDESC_BASE_FIRST_SHIFT 26
  349. #define ENA_ETH_IO_RX_CDESC_BASE_FIRST_MASK BIT(26)
  350. #define ENA_ETH_IO_RX_CDESC_BASE_LAST_SHIFT 27
  351. #define ENA_ETH_IO_RX_CDESC_BASE_LAST_MASK BIT(27)
  352. #define ENA_ETH_IO_RX_CDESC_BASE_BUFFER_SHIFT 30
  353. #define ENA_ETH_IO_RX_CDESC_BASE_BUFFER_MASK BIT(30)
  354. /* intr_reg */
  355. #define ENA_ETH_IO_INTR_REG_RX_INTR_DELAY_MASK GENMASK(14, 0)
  356. #define ENA_ETH_IO_INTR_REG_TX_INTR_DELAY_SHIFT 15
  357. #define ENA_ETH_IO_INTR_REG_TX_INTR_DELAY_MASK GENMASK(29, 15)
  358. #define ENA_ETH_IO_INTR_REG_INTR_UNMASK_SHIFT 30
  359. #define ENA_ETH_IO_INTR_REG_INTR_UNMASK_MASK BIT(30)
  360. /* numa_node_cfg_reg */
  361. #define ENA_ETH_IO_NUMA_NODE_CFG_REG_NUMA_MASK GENMASK(7, 0)
  362. #define ENA_ETH_IO_NUMA_NODE_CFG_REG_ENABLED_SHIFT 31
  363. #define ENA_ETH_IO_NUMA_NODE_CFG_REG_ENABLED_MASK BIT(31)
  364. #endif /*_ENA_ETH_IO_H_ */