txrx_edma.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. /*
  2. * Copyright (c) 2012-2016,2018, The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef WIL6210_TXRX_EDMA_H
  17. #define WIL6210_TXRX_EDMA_H
  18. #include "wil6210.h"
  19. /* limit status ring size in range [ring size..max ring size] */
  20. #define WIL_SRING_SIZE_ORDER_MIN (WIL_RING_SIZE_ORDER_MIN)
  21. #define WIL_SRING_SIZE_ORDER_MAX (WIL_RING_SIZE_ORDER_MAX)
  22. /* RX sring order should be bigger than RX ring order */
  23. #define WIL_RX_SRING_SIZE_ORDER_DEFAULT (11)
  24. #define WIL_TX_SRING_SIZE_ORDER_DEFAULT (12)
  25. #define WIL_RX_BUFF_ARR_SIZE_DEFAULT (1536)
  26. #define WIL_DEFAULT_RX_STATUS_RING_ID 0
  27. #define WIL_RX_DESC_RING_ID 0
  28. #define WIL_RX_STATUS_IRQ_IDX 0
  29. #define WIL_TX_STATUS_IRQ_IDX 1
  30. #define WIL_EDMA_AGG_WATERMARK (0xffff)
  31. #define WIL_EDMA_AGG_WATERMARK_POS (16)
  32. #define WIL_EDMA_IDLE_TIME_LIMIT_USEC (50)
  33. #define WIL_EDMA_TIME_UNIT_CLK_CYCLES (330) /* fits 1 usec */
  34. /* Error field */
  35. #define WIL_RX_EDMA_ERROR_MIC (1)
  36. #define WIL_RX_EDMA_ERROR_KEY (2) /* Key missing */
  37. #define WIL_RX_EDMA_ERROR_REPLAY (3)
  38. #define WIL_RX_EDMA_ERROR_AMSDU (4)
  39. #define WIL_RX_EDMA_ERROR_FCS (7)
  40. #define WIL_RX_EDMA_ERROR_L3_ERR (BIT(0) | BIT(1))
  41. #define WIL_RX_EDMA_ERROR_L4_ERR (BIT(0) | BIT(1))
  42. #define WIL_RX_EDMA_DLPF_LU_MISS_BIT BIT(11)
  43. #define WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK 0x7
  44. #define WIL_RX_EDMA_DLPF_LU_HIT_CID_TID_MASK 0xf
  45. #define WIL_RX_EDMA_DLPF_LU_MISS_CID_POS 2
  46. #define WIL_RX_EDMA_DLPF_LU_HIT_CID_POS 4
  47. #define WIL_RX_EDMA_DLPF_LU_MISS_TID_POS 5
  48. #define WIL_RX_EDMA_MID_VALID_BIT BIT(22)
  49. #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_POS 16
  50. #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_LEN 6
  51. #define WIL_EDMA_DESC_TX_CFG_EOP_POS 0
  52. #define WIL_EDMA_DESC_TX_CFG_EOP_LEN 1
  53. #define WIL_EDMA_DESC_TX_CFG_TSO_DESC_TYPE_POS 3
  54. #define WIL_EDMA_DESC_TX_CFG_TSO_DESC_TYPE_LEN 2
  55. #define WIL_EDMA_DESC_TX_CFG_SEG_EN_POS 5
  56. #define WIL_EDMA_DESC_TX_CFG_SEG_EN_LEN 1
  57. #define WIL_EDMA_DESC_TX_CFG_INSERT_IP_CHKSUM_POS 6
  58. #define WIL_EDMA_DESC_TX_CFG_INSERT_IP_CHKSUM_LEN 1
  59. #define WIL_EDMA_DESC_TX_CFG_INSERT_TCP_CHKSUM_POS 7
  60. #define WIL_EDMA_DESC_TX_CFG_INSERT_TCP_CHKSUM_LEN 1
  61. #define WIL_EDMA_DESC_TX_CFG_L4_TYPE_POS 15
  62. #define WIL_EDMA_DESC_TX_CFG_L4_TYPE_LEN 1
  63. #define WIL_EDMA_DESC_TX_CFG_PSEUDO_HEADER_CALC_EN_POS 5
  64. #define WIL_EDMA_DESC_TX_CFG_PSEUDO_HEADER_CALC_EN_LEN 1
  65. /* Enhanced Rx descriptor - MAC part
  66. * [dword 0] : Reserved
  67. * [dword 1] : Reserved
  68. * [dword 2] : Reserved
  69. * [dword 3]
  70. * bit 0..15 : Buffer ID
  71. * bit 16..31 : Reserved
  72. */
  73. struct wil_ring_rx_enhanced_mac {
  74. u32 d[3];
  75. __le16 buff_id;
  76. u16 reserved;
  77. } __packed;
  78. /* Enhanced Rx descriptor - DMA part
  79. * [dword 0] - Reserved
  80. * [dword 1]
  81. * bit 0..31 : addr_low:32 The payload buffer address, bits 0-31
  82. * [dword 2]
  83. * bit 0..15 : addr_high_low:16 The payload buffer address, bits 32-47
  84. * bit 16..31 : Reserved
  85. * [dword 3]
  86. * bit 0..15 : addr_high_high:16 The payload buffer address, bits 48-63
  87. * bit 16..31 : length
  88. */
  89. struct wil_ring_rx_enhanced_dma {
  90. u32 d0;
  91. struct wil_ring_dma_addr addr;
  92. u16 w5;
  93. __le16 addr_high_high;
  94. __le16 length;
  95. } __packed;
  96. struct wil_rx_enhanced_desc {
  97. struct wil_ring_rx_enhanced_mac mac;
  98. struct wil_ring_rx_enhanced_dma dma;
  99. } __packed;
  100. /* Enhanced Tx descriptor - DMA part
  101. * [dword 0]
  102. * Same as legacy
  103. * [dword 1]
  104. * bit 0..31 : addr_low:32 The payload buffer address, bits 0-31
  105. * [dword 2]
  106. * bit 0..15 : addr_high_low:16 The payload buffer address, bits 32-47
  107. * bit 16..23 : ip_length:8 The IP header length for the TX IP checksum
  108. * offload feature
  109. * bit 24..30 : mac_length:7
  110. * bit 31 : ip_version:1 1 - IPv4, 0 - IPv6
  111. * [dword 3]
  112. * bit 0..15 : addr_high_high:16 The payload buffer address, bits 48-63
  113. * bit 16..31 : length
  114. */
  115. struct wil_ring_tx_enhanced_dma {
  116. u8 l4_hdr_len;
  117. u8 cmd;
  118. u16 w1;
  119. struct wil_ring_dma_addr addr;
  120. u8 ip_length;
  121. u8 b11; /* 0..6: mac_length; 7:ip_version */
  122. __le16 addr_high_high;
  123. __le16 length;
  124. } __packed;
  125. /* Enhanced Tx descriptor - MAC part
  126. * [dword 0]
  127. * bit 0.. 9 : lifetime_expiry_value:10
  128. * bit 10 : interrupt_en:1
  129. * bit 11 : status_en:1
  130. * bit 12..13 : txss_override:2
  131. * bit 14 : timestamp_insertion:1
  132. * bit 15 : duration_preserve:1
  133. * bit 16..21 : reserved0:6
  134. * bit 22..26 : mcs_index:5
  135. * bit 27 : mcs_en:1
  136. * bit 28..30 : reserved1:3
  137. * bit 31 : sn_preserved:1
  138. * [dword 1]
  139. * bit 0.. 3 : pkt_mode:4
  140. * bit 4 : pkt_mode_en:1
  141. * bit 5..14 : reserved0:10
  142. * bit 15 : ack_policy_en:1
  143. * bit 16..19 : dst_index:4
  144. * bit 20 : dst_index_en:1
  145. * bit 21..22 : ack_policy:2
  146. * bit 23 : lifetime_en:1
  147. * bit 24..30 : max_retry:7
  148. * bit 31 : max_retry_en:1
  149. * [dword 2]
  150. * bit 0.. 7 : num_of_descriptors:8
  151. * bit 8..17 : reserved:10
  152. * bit 18..19 : l2_translation_type:2 00 - bypass, 01 - 802.3, 10 - 802.11
  153. * bit 20 : snap_hdr_insertion_en:1
  154. * bit 21 : vlan_removal_en:1
  155. * bit 22..23 : reserved0:2
  156. * bit 24 : Dest ID extension:1
  157. * bit 25..31 : reserved0:7
  158. * [dword 3]
  159. * bit 0..15 : tso_mss:16
  160. * bit 16..31 : descriptor_scratchpad:16 - mailbox between driver and ucode
  161. */
  162. struct wil_ring_tx_enhanced_mac {
  163. u32 d[3];
  164. __le16 tso_mss;
  165. u16 scratchpad;
  166. } __packed;
  167. struct wil_tx_enhanced_desc {
  168. struct wil_ring_tx_enhanced_mac mac;
  169. struct wil_ring_tx_enhanced_dma dma;
  170. } __packed;
  171. #define TX_STATUS_DESC_READY_POS 7
  172. /* Enhanced TX status message
  173. * [dword 0]
  174. * bit 0.. 7 : Number of Descriptor:8 - The number of descriptors that
  175. * are used to form the packets. It is needed for WB when
  176. * releasing the packet
  177. * bit 8..15 : tx_ring_id:8 The transmission ring ID that is related to
  178. * the message
  179. * bit 16..23 : Status:8 - The TX status Code
  180. * 0x0 - A successful transmission
  181. * 0x1 - Retry expired
  182. * 0x2 - Lifetime Expired
  183. * 0x3 - Released
  184. * 0x4-0xFF - Reserved
  185. * bit 24..30 : Reserved:7
  186. * bit 31 : Descriptor Ready bit:1 - It is initiated to
  187. * zero by the driver when the ring is created. It is set by the HW
  188. * to one for each completed status message. Each wrap around,
  189. * the DR bit value is flipped.
  190. * [dword 1]
  191. * bit 0..31 : timestamp:32 - Set when MPDU is transmitted.
  192. * [dword 2]
  193. * bit 0.. 4 : MCS:5 - The transmitted MCS value
  194. * bit 5 : Reserved:1
  195. * bit 6.. 7 : CB mode:2 - 0-DMG 1-EDMG 2-Wide
  196. * bit 8..12 : QID:5 - The QID that was used for the transmission
  197. * bit 13..15 : Reserved:3
  198. * bit 16..20 : Num of MSDUs:5 - Number of MSDUs in the aggregation
  199. * bit 21..22 : Reserved:2
  200. * bit 23 : Retry:1 - An indication that the transmission was retried
  201. * bit 24..31 : TX-Sector:8 - the antenna sector that was used for
  202. * transmission
  203. * [dword 3]
  204. * bit 0..11 : Sequence number:12 - The Sequence Number that was used
  205. * for the MPDU transmission
  206. * bit 12..31 : Reserved:20
  207. */
  208. struct wil_ring_tx_status {
  209. u8 num_descriptors;
  210. u8 ring_id;
  211. u8 status;
  212. u8 desc_ready; /* Only the last bit should be set */
  213. u32 timestamp;
  214. u32 d2;
  215. u16 seq_number; /* Only the first 12 bits */
  216. u16 w7;
  217. } __packed;
  218. /* Enhanced Rx status message - compressed part
  219. * [dword 0]
  220. * bit 0.. 2 : L2 Rx Status:3 - The L2 packet reception Status
  221. * 0-Success, 1-MIC Error, 2-Key Error, 3-Replay Error,
  222. * 4-A-MSDU Error, 5-Reserved, 6-Reserved, 7-FCS Error
  223. * bit 3.. 4 : L3 Rx Status:2 - Bit0 - L3I - L3 identified and checksum
  224. * calculated, Bit1- L3Err - IPv4 Checksum Error
  225. * bit 5.. 6 : L4 Rx Status:2 - Bit0 - L4I - L4 identified and checksum
  226. * calculated, Bit1- L4Err - TCP/UDP Checksum Error
  227. * bit 7 : Reserved:1
  228. * bit 8..19 : Flow ID:12 - MSDU flow ID
  229. * bit 20..21 : MID:2 - The MAC ID
  230. * bit 22 : MID_V:1 - The MAC ID field is valid
  231. * bit 23 : L3T:1 - IP types: 0-IPv6, 1-IPv4
  232. * bit 24 : L4T:1 - Layer 4 Type: 0-UDP, 1-TCP
  233. * bit 25 : BC:1 - The received MPDU is broadcast
  234. * bit 26 : MC:1 - The received MPDU is multicast
  235. * bit 27 : Raw:1 - The MPDU received with no translation
  236. * bit 28 : Sec:1 - The FC control (b14) - Frame Protected
  237. * bit 29 : Error:1 - An error is set when (L2 status != 0) ||
  238. * (L3 status == 3) || (L4 status == 3)
  239. * bit 30 : EOP:1 - End of MSDU signaling. It is set to mark the end
  240. * of the transfer, otherwise the status indicates buffer
  241. * only completion.
  242. * bit 31 : Descriptor Ready bit:1 - It is initiated to
  243. * zero by the driver when the ring is created. It is set
  244. * by the HW to one for each completed status message.
  245. * Each wrap around, the DR bit value is flipped.
  246. * [dword 1]
  247. * bit 0.. 5 : MAC Len:6 - The number of bytes that are used for L2 header
  248. * bit 6..11 : IPLEN:6 - The number of DW that are used for L3 header
  249. * bit 12..15 : I4Len:4 - The number of DW that are used for L4 header
  250. * bit 16..21 : MCS:6 - The received MCS field from the PLCP Header
  251. * bit 22..23 : CB mode:2 - The CB Mode: 0-DMG, 1-EDMG, 2-Wide
  252. * bit 24..27 : Data Offset:4 - The data offset, a code that describe the
  253. * payload shift from the beginning of the buffer:
  254. * 0 - 0 Bytes, 3 - 2 Bytes
  255. * bit 28 : A-MSDU Present:1 - The QoS (b7) A-MSDU present field
  256. * bit 29 : A-MSDU Type:1 The QoS (b8) A-MSDU Type field
  257. * bit 30 : A-MPDU:1 - Packet is part of aggregated MPDU
  258. * bit 31 : Key ID:1 - The extracted Key ID from the encryption header
  259. * [dword 2]
  260. * bit 0..15 : Buffer ID:16 - The Buffer Identifier
  261. * bit 16..31 : Length:16 - It indicates the valid bytes that are stored
  262. * in the current descriptor buffer. For multiple buffer
  263. * descriptor, SW need to sum the total descriptor length
  264. * in all buffers to produce the packet length
  265. * [dword 3]
  266. * bit 0..31 : timestamp:32 - The MPDU Timestamp.
  267. */
  268. struct wil_rx_status_compressed {
  269. u32 d0;
  270. u32 d1;
  271. __le16 buff_id;
  272. __le16 length;
  273. u32 timestamp;
  274. } __packed;
  275. /* Enhanced Rx status message - extension part
  276. * [dword 0]
  277. * bit 0.. 4 : QID:5 - The Queue Identifier that the packet is received
  278. * from
  279. * bit 5.. 7 : Reserved:3
  280. * bit 8..11 : TID:4 - The QoS (b3-0) TID Field
  281. * bit 12..15 Source index:4 - The Source index that was found
  282. during Parsing the TA. This field is used to define the
  283. source of the packet
  284. * bit 16..18 : Destination index:3 - The Destination index that
  285. was found during Parsing the RA.
  286. * bit 19..20 : DS Type:2 - The FC Control (b9-8) - From / To DS
  287. * bit 21..22 : MIC ICR:2 - this signal tells the DMA to assert an
  288. interrupt after it writes the packet
  289. * bit 23 : ESOP:1 - The QoS (b4) ESOP field
  290. * bit 24 : RDG:1
  291. * bit 25..31 : Reserved:7
  292. * [dword 1]
  293. * bit 0.. 1 : Frame Type:2 - The FC Control (b3-2) - MPDU Type
  294. (management, data, control and extension)
  295. * bit 2.. 5 : Syb type:4 - The FC Control (b7-4) - Frame Subtype
  296. * bit 6..11 : Ext sub type:6 - The FC Control (b11-8) - Frame Extended
  297. * Subtype
  298. * bit 12..13 : ACK Policy:2 - The QoS (b6-5) ACK Policy fields
  299. * bit 14 : DECRYPT_BYP:1 - The MPDU is bypass by the decryption unit
  300. * bit 15..23 : Reserved:9
  301. * bit 24..31 : RSSI/SNR:8 - The RSSI / SNR measurement for the received
  302. * MPDU
  303. * [dword 2]
  304. * bit 0..11 : SN:12 - The received Sequence number field
  305. * bit 12..15 : Reserved:4
  306. * bit 16..31 : PN bits [15:0]:16
  307. * [dword 3]
  308. * bit 0..31 : PN bits [47:16]:32
  309. */
  310. struct wil_rx_status_extension {
  311. u32 d0;
  312. u32 d1;
  313. __le16 seq_num; /* only lower 12 bits */
  314. u16 pn_15_0;
  315. u32 pn_47_16;
  316. } __packed;
  317. struct wil_rx_status_extended {
  318. struct wil_rx_status_compressed comp;
  319. struct wil_rx_status_extension ext;
  320. } __packed;
  321. static inline void *wil_skb_rxstatus(struct sk_buff *skb)
  322. {
  323. return (void *)skb->cb;
  324. }
  325. static inline __le16 wil_rx_status_get_length(void *msg)
  326. {
  327. return ((struct wil_rx_status_compressed *)msg)->length;
  328. }
  329. static inline u8 wil_rx_status_get_mcs(void *msg)
  330. {
  331. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
  332. 16, 21);
  333. }
  334. static inline u16 wil_rx_status_get_flow_id(void *msg)
  335. {
  336. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  337. 8, 19);
  338. }
  339. static inline u8 wil_rx_status_get_mcast(void *msg)
  340. {
  341. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  342. 26, 26);
  343. }
  344. /**
  345. * In case of DLPF miss the parsing of flow Id should be as follows:
  346. * dest_id:2
  347. * src_id :3 - cid
  348. * tid:3
  349. * Otherwise:
  350. * tid:4
  351. * cid:4
  352. */
  353. static inline u8 wil_rx_status_get_cid(void *msg)
  354. {
  355. u16 val = wil_rx_status_get_flow_id(msg);
  356. if (val & WIL_RX_EDMA_DLPF_LU_MISS_BIT)
  357. /* CID is in bits 2..4 */
  358. return (val >> WIL_RX_EDMA_DLPF_LU_MISS_CID_POS) &
  359. WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
  360. else
  361. /* CID is in bits 4..7 */
  362. return (val >> WIL_RX_EDMA_DLPF_LU_HIT_CID_POS) &
  363. WIL_RX_EDMA_DLPF_LU_HIT_CID_TID_MASK;
  364. }
  365. static inline u8 wil_rx_status_get_tid(void *msg)
  366. {
  367. u16 val = wil_rx_status_get_flow_id(msg);
  368. if (val & WIL_RX_EDMA_DLPF_LU_MISS_BIT)
  369. /* TID is in bits 5..7 */
  370. return (val >> WIL_RX_EDMA_DLPF_LU_MISS_TID_POS) &
  371. WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
  372. else
  373. /* TID is in bits 0..3 */
  374. return val & WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
  375. }
  376. static inline int wil_rx_status_get_desc_rdy_bit(void *msg)
  377. {
  378. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  379. 31, 31);
  380. }
  381. static inline int wil_rx_status_get_eop(void *msg) /* EoP = End of Packet */
  382. {
  383. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  384. 30, 30);
  385. }
  386. static inline __le16 wil_rx_status_get_buff_id(void *msg)
  387. {
  388. return ((struct wil_rx_status_compressed *)msg)->buff_id;
  389. }
  390. static inline u8 wil_rx_status_get_data_offset(void *msg)
  391. {
  392. u8 val = WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
  393. 24, 27);
  394. switch (val) {
  395. case 0: return 0;
  396. case 3: return 2;
  397. default: return 0xFF;
  398. }
  399. }
  400. static inline int wil_rx_status_get_frame_type(struct wil6210_priv *wil,
  401. void *msg)
  402. {
  403. if (wil->use_compressed_rx_status)
  404. return IEEE80211_FTYPE_DATA;
  405. return WIL_GET_BITS(((struct wil_rx_status_extended *)msg)->ext.d1,
  406. 0, 1) << 2;
  407. }
  408. static inline int wil_rx_status_get_fc1(struct wil6210_priv *wil, void *msg)
  409. {
  410. if (wil->use_compressed_rx_status)
  411. return 0;
  412. return WIL_GET_BITS(((struct wil_rx_status_extended *)msg)->ext.d1,
  413. 0, 5) << 2;
  414. }
  415. static inline __le16 wil_rx_status_get_seq(struct wil6210_priv *wil, void *msg)
  416. {
  417. if (wil->use_compressed_rx_status)
  418. return 0;
  419. return ((struct wil_rx_status_extended *)msg)->ext.seq_num;
  420. }
  421. static inline u8 wil_rx_status_get_retry(void *msg)
  422. {
  423. /* retry bit is missing in EDMA HW. return 1 to be on the safe side */
  424. return 1;
  425. }
  426. static inline int wil_rx_status_get_mid(void *msg)
  427. {
  428. if (!(((struct wil_rx_status_compressed *)msg)->d0 &
  429. WIL_RX_EDMA_MID_VALID_BIT))
  430. return 0; /* use the default MID */
  431. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  432. 20, 21);
  433. }
  434. static inline int wil_rx_status_get_error(void *msg)
  435. {
  436. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  437. 29, 29);
  438. }
  439. static inline int wil_rx_status_get_l2_rx_status(void *msg)
  440. {
  441. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  442. 0, 2);
  443. }
  444. static inline int wil_rx_status_get_l3_rx_status(void *msg)
  445. {
  446. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  447. 3, 4);
  448. }
  449. static inline int wil_rx_status_get_l4_rx_status(void *msg)
  450. {
  451. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  452. 5, 6);
  453. }
  454. static inline int wil_rx_status_get_security(void *msg)
  455. {
  456. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
  457. 28, 28);
  458. }
  459. static inline u8 wil_rx_status_get_key_id(void *msg)
  460. {
  461. return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1,
  462. 31, 31);
  463. }
  464. static inline u8 wil_tx_status_get_mcs(struct wil_ring_tx_status *msg)
  465. {
  466. return WIL_GET_BITS(msg->d2, 0, 4);
  467. }
  468. static inline u32 wil_ring_next_head(struct wil_ring *ring)
  469. {
  470. return (ring->swhead + 1) % ring->size;
  471. }
  472. static inline void wil_desc_set_addr_edma(struct wil_ring_dma_addr *addr,
  473. __le16 *addr_high_high,
  474. dma_addr_t pa)
  475. {
  476. addr->addr_low = cpu_to_le32(lower_32_bits(pa));
  477. addr->addr_high = cpu_to_le16((u16)upper_32_bits(pa));
  478. *addr_high_high = cpu_to_le16((u16)(upper_32_bits(pa) >> 16));
  479. }
  480. static inline
  481. dma_addr_t wil_tx_desc_get_addr_edma(struct wil_ring_tx_enhanced_dma *dma)
  482. {
  483. return le32_to_cpu(dma->addr.addr_low) |
  484. ((u64)le16_to_cpu(dma->addr.addr_high) << 32) |
  485. ((u64)le16_to_cpu(dma->addr_high_high) << 48);
  486. }
  487. static inline
  488. dma_addr_t wil_rx_desc_get_addr_edma(struct wil_ring_rx_enhanced_dma *dma)
  489. {
  490. return le32_to_cpu(dma->addr.addr_low) |
  491. ((u64)le16_to_cpu(dma->addr.addr_high) << 32) |
  492. ((u64)le16_to_cpu(dma->addr_high_high) << 48);
  493. }
  494. void wil_configure_interrupt_moderation_edma(struct wil6210_priv *wil);
  495. int wil_tx_sring_handler(struct wil6210_priv *wil,
  496. struct wil_status_ring *sring);
  497. void wil_rx_handle_edma(struct wil6210_priv *wil, int *quota);
  498. void wil_init_txrx_ops_edma(struct wil6210_priv *wil);
  499. #endif /* WIL6210_TXRX_EDMA_H */