hal_rx.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  1. /*
  2. * Copyright (c) 2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _HAL_RX_H_
  19. #define _HAL_RX_H_
  20. #include <hal_internal.h>
  21. /**
  22. * enum hal_reo_error_code: Enum which encapsulates "reo_push_reason"
  23. *
  24. * @ HAL_REO_ERROR_DETECTED: Packets arrived because of an error detected
  25. * @ HAL_REO_ROUTING_INSTRUCTION: Packets arrived because of REO routing
  26. */
  27. enum hal_reo_error_status {
  28. HAL_REO_ERROR_DETECTED = 0,
  29. HAL_REO_ROUTING_INSTRUCTION = 1,
  30. };
  31. /**
  32. * @msdu_flags: [0] first_msdu_in_mpdu
  33. * [1] last_msdu_in_mpdu
  34. * [2] msdu_continuation - MSDU spread across buffers
  35. * [23] sa_is_valid - SA match in peer table
  36. * [24] sa_idx_timeout - Timeout while searching for SA match
  37. * [25] da_is_valid - Used to identtify intra-bss forwarding
  38. * [26] da_is_MCBC
  39. * [27] da_idx_timeout - Timeout while searching for DA match
  40. *
  41. */
  42. struct hal_rx_msdu_desc_info {
  43. uint32_t msdu_flags;
  44. uint16_t msdu_len; /* 14 bits for length */
  45. };
  46. /**
  47. * enum hal_rx_msdu_desc_flags: Enum for flags in MSDU_DESC_INFO
  48. *
  49. * @ HAL_MSDU_F_FIRST_MSDU_IN_MPDU: First MSDU in MPDU
  50. * @ HAL_MSDU_F_LAST_MSDU_IN_MPDU: Last MSDU in MPDU
  51. * @ HAL_MSDU_F_MSDU_CONTINUATION: MSDU continuation
  52. * @ HAL_MSDU_F_SA_IS_VALID: Found match for SA in AST
  53. * @ HAL_MSDU_F_SA_IDX_TIMEOUT: AST search for SA timed out
  54. * @ HAL_MSDU_F_DA_IS_VALID: Found match for DA in AST
  55. * @ HAL_MSDU_F_DA_IS_MCBC: DA is MC/BC address
  56. * @ HAL_MSDU_F_DA_IDX_TIMEOUT: AST search for DA timed out
  57. */
  58. enum hal_rx_msdu_desc_flags {
  59. HAL_MSDU_F_FIRST_MSDU_IN_MPDU = (0x1 << 0),
  60. HAL_MSDU_F_LAST_MSDU_IN_MPDU = (0x1 << 1),
  61. HAL_MSDU_F_MSDU_CONTINUATION = (0x1 << 2),
  62. HAL_MSDU_F_SA_IS_VALID = (0x1 << 23),
  63. HAL_MSDU_F_SA_IDX_TIMEOUT = (0x1 << 24),
  64. HAL_MSDU_F_DA_IS_VALID = (0x1 << 25),
  65. HAL_MSDU_F_DA_IS_MCBC = (0x1 << 26),
  66. HAL_MSDU_F_DA_IDX_TIMEOUT = (0x1 << 27)
  67. };
  68. /*
  69. * @msdu_count: no. of msdus in the MPDU
  70. * @mpdu_seq: MPDU sequence number
  71. * @mpdu_flags [0] Fragment flag
  72. * [1] MPDU_retry_bit
  73. * [2] AMPDU flag
  74. * [3] raw_ampdu
  75. * @peer_meta_data: Upper bits containing peer id, vdev id
  76. */
  77. struct hal_rx_mpdu_desc_info {
  78. uint16_t msdu_count;
  79. uint16_t mpdu_seq; /* 12 bits for length */
  80. uint32_t mpdu_flags;
  81. uint32_t peer_meta_data; /* sw progamed meta-data:MAC Id & peer Id */
  82. };
  83. /**
  84. * enum hal_rx_mpdu_desc_flags: Enum for flags in MPDU_DESC_INFO
  85. *
  86. * @ HAL_MPDU_F_FRAGMENT: Fragmented MPDU (802.11 fragemtation)
  87. * @ HAL_MPDU_F_RETRY_BIT: Retry bit is set in FC of MPDU
  88. * @ HAL_MPDU_F_AMPDU_FLAG: MPDU received as part of A-MPDU
  89. * @ HAL_MPDU_F_RAW_AMPDU: MPDU is a Raw MDPU
  90. */
  91. enum hal_rx_mpdu_desc_flags {
  92. HAL_MPDU_F_FRAGMENT = (0x1 << 20),
  93. HAL_MPDU_F_RETRY_BIT = (0x1 << 21),
  94. HAL_MPDU_F_AMPDU_FLAG = (0x1 << 22),
  95. HAL_MPDU_F_RAW_AMPDU = (0x1 << 30)
  96. };
  97. /**
  98. * enum hal_rx_ret_buf_manager: Enum for return_buffer_manager field in
  99. * BUFFER_ADDR_INFO structure
  100. *
  101. * @ HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST: Buffer returned to WBM idle buffer list
  102. * @ HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST: Descriptor returned to WBM idle
  103. * descriptor list
  104. * @ HAL_RX_BUF_RBM_FW_BM: Buffer returned to FW
  105. * @ HAL_RX_BUF_RBM_SW0_BM: For Tx completion -- returned to host
  106. * @ HAL_RX_BUF_RBM_SW1_BM: For Tx completion -- returned to host
  107. * @ HAL_RX_BUF_RBM_SW2_BM: For Tx completion -- returned to host
  108. * @ HAL_RX_BUF_RBM_SW3_BM: For Rx release -- returned to host
  109. */
  110. enum hal_rx_ret_buf_manager {
  111. HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST = 0,
  112. HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST = 1,
  113. HAL_RX_BUF_RBM_FW_BM = 2,
  114. HAL_RX_BUF_RBM_SW0_BM = 3,
  115. HAL_RX_BUF_RBM_SW1_BM = 4,
  116. HAL_RX_BUF_RBM_SW2_BM = 5,
  117. HAL_RX_BUF_RBM_SW3_BM = 6,
  118. };
  119. /*
  120. * Given the offset of a field in bytes, returns uint8_t *
  121. */
  122. #define _OFFSET_TO_BYTE_PTR(_ptr, _off_in_bytes) \
  123. (((uint8_t *)(_ptr)) + (_off_in_bytes))
  124. /*
  125. * Given the offset of a field in bytes, returns uint32_t *
  126. */
  127. #define _OFFSET_TO_WORD_PTR(_ptr, _off_in_bytes) \
  128. (((uint32_t *)(_ptr)) + ((_off_in_bytes) >> 2))
  129. #define _HAL_MS(_word, _mask, _shift) \
  130. (((_word) & (_mask)) >> (_shift))
  131. /*
  132. * macro to set the LSW of the nbuf data physical address
  133. * to the rxdma ring entry
  134. */
  135. #define HAL_RXDMA_PADDR_LO_SET(buff_addr_info, paddr_lo) \
  136. ((*(((unsigned int *) buff_addr_info) + \
  137. (BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET >> 2))) = \
  138. (paddr_lo << BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_LSB) & \
  139. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK)
  140. /*
  141. * macro to set the LSB of MSW of the nbuf data physical address
  142. * to the rxdma ring entry
  143. */
  144. #define HAL_RXDMA_PADDR_HI_SET(buff_addr_info, paddr_hi) \
  145. ((*(((unsigned int *) buff_addr_info) + \
  146. (BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET >> 2))) = \
  147. (paddr_hi << BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB) & \
  148. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK)
  149. /*
  150. * macro to set the cookie into the rxdma ring entry
  151. */
  152. #define HAL_RXDMA_COOKIE_SET(buff_addr_info, cookie) \
  153. ((*(((unsigned int *) buff_addr_info) + \
  154. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) &= \
  155. ~((cookie << BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB) & \
  156. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK)); \
  157. ((*(((unsigned int *) buff_addr_info) + \
  158. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) |= \
  159. (cookie << BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB) & \
  160. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK)
  161. /*
  162. * macro to set the manager into the rxdma ring entry
  163. */
  164. #define HAL_RXDMA_MANAGER_SET(buff_addr_info, manager) \
  165. ((*(((unsigned int *) buff_addr_info) + \
  166. (BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET >> 2))) &= \
  167. ~((manager << BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_LSB) & \
  168. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK)); \
  169. ((*(((unsigned int *) buff_addr_info) + \
  170. (BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET >> 2))) |= \
  171. (manager << BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_LSB) & \
  172. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK)
  173. #define HAL_RX_ERROR_STATUS_GET(reo_desc) \
  174. (_HAL_MS((*_OFFSET_TO_WORD_PTR(reo_desc, \
  175. REO_DESTINATION_RING_7_REO_PUSH_REASON_OFFSET)),\
  176. REO_DESTINATION_RING_7_REO_PUSH_REASON_MASK, \
  177. REO_DESTINATION_RING_7_REO_PUSH_REASON_LSB))
  178. #define HAL_RX_BUF_COOKIE_GET(buff_addr_info) \
  179. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  180. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET)), \
  181. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK, \
  182. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB))
  183. #define HAL_RX_BUFFER_ADDR_39_32_GET(buff_addr_info) \
  184. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  185. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET)), \
  186. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK, \
  187. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB))
  188. #define HAL_RX_BUFFER_ADDR_31_0_GET(buff_addr_info) \
  189. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  190. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET)), \
  191. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK, \
  192. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_LSB))
  193. #define HAL_RX_BUF_RBM_GET(buff_addr_info) \
  194. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  195. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET)),\
  196. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK, \
  197. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_LSB))
  198. /* TODO: Convert the following structure fields accesseses to offsets */
  199. #define HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_desc) \
  200. (HAL_RX_BUFFER_ADDR_39_32_GET(& \
  201. (((struct reo_destination_ring *) \
  202. reo_desc)->buf_or_link_desc_addr_info)))
  203. #define HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_desc) \
  204. (HAL_RX_BUFFER_ADDR_31_0_GET(& \
  205. (((struct reo_destination_ring *) \
  206. reo_desc)->buf_or_link_desc_addr_info)))
  207. #define HAL_RX_REO_BUF_COOKIE_GET(reo_desc) \
  208. (HAL_RX_BUF_COOKIE_GET(& \
  209. (((struct reo_destination_ring *) \
  210. reo_desc)->buf_or_link_desc_addr_info)))
  211. #define HAL_RX_MPDU_SEQUENCE_NUMBER_GET(mpdu_info_ptr) \
  212. ((mpdu_info_ptr \
  213. [RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_OFFSET >> 2] & \
  214. RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_MASK) >> \
  215. RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_LSB)
  216. #define HAL_RX_MPDU_DESC_PEER_META_DATA_GET(mpdu_info_ptr) \
  217. ((mpdu_info_ptr \
  218. [RX_MPDU_DESC_INFO_1_PEER_META_DATA_OFFSET >> 2] & \
  219. RX_MPDU_DESC_INFO_1_PEER_META_DATA_MASK) >> \
  220. RX_MPDU_DESC_INFO_1_PEER_META_DATA_LSB)
  221. #define HAL_RX_MPDU_MSDU_COUNT_GET(mpdu_info_ptr) \
  222. ((mpdu_info_ptr[RX_MPDU_DESC_INFO_0_MSDU_COUNT_OFFSET >> 2] & \
  223. RX_MPDU_DESC_INFO_0_MSDU_COUNT_MASK) >> \
  224. RX_MPDU_DESC_INFO_0_MSDU_COUNT_LSB)
  225. #define HAL_RX_MPDU_FRAGMENT_FLAG_GET(mpdu_info_ptr) \
  226. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_FRAGMENT_FLAG_OFFSET >> 2] & \
  227. RX_MPDU_DESC_INFO_0_FRAGMENT_FLAG_MASK)
  228. #define HAL_RX_MPDU_RETRY_BIT_GET(mpdu_info_ptr) \
  229. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_MPDU_RETRY_BIT_OFFSET >> 2] & \
  230. RX_MPDU_DESC_INFO_0_MPDU_RETRY_BIT_MASK)
  231. #define HAL_RX_MPDU_AMPDU_FLAG_GET(mpdu_info_ptr) \
  232. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_AMPDU_FLAG_OFFSET >> 2] & \
  233. RX_MPDU_DESC_INFO_0_AMPDU_FLAG_MASK)
  234. #define HAL_RX_MPDU_RAW_MPDU_GET(mpdu_info_ptr) \
  235. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_RAW_MPDU_OFFSET >> 2] & \
  236. RX_MPDU_DESC_INFO_0_RAW_MPDU_MASK)
  237. #define HAL_RX_MPDU_FLAGS_GET(mpdu_info_ptr) \
  238. (HAL_RX_MPDU_FRAGMENT_FLAG_GET(mpdu_info_ptr) | \
  239. HAL_RX_MPDU_RETRY_BIT_GET(mpdu_info_ptr) | \
  240. HAL_RX_MPDU_AMPDU_FLAG_GET(mpdu_info_ptr) | \
  241. HAL_RX_MPDU_RAW_MPDU_GET(mpdu_info_ptr))
  242. #define HAL_RX_MSDU_PKT_LENGTH_GET(msdu_info_ptr) \
  243. (_HAL_MS((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  244. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_OFFSET)), \
  245. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_MASK, \
  246. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_LSB))
  247. /*
  248. * NOTE: None of the following _GET macros need a right
  249. * shift by the corresponding _LSB. This is because, they are
  250. * finally taken and "OR'ed" into a single word again.
  251. */
  252. #define HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  253. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  254. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  255. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK)
  256. #define HAL_RX_LAST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  257. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  258. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  259. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK)
  260. #define HAL_RX_MSDU_CONTINUATION_FLAG_GET(msdu_info_ptr) \
  261. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  262. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_OFFSET)) & \
  263. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK)
  264. #define HAL_RX_MSDU_SA_IS_VALID_FLAG_GET(msdu_info_ptr) \
  265. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  266. RX_MSDU_DESC_INFO_0_SA_IS_VALID_OFFSET)) & \
  267. RX_MSDU_DESC_INFO_0_SA_IS_VALID_MASK)
  268. #define HAL_RX_MSDU_SA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) \
  269. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  270. RX_MSDU_DESC_INFO_0_SA_IDX_TIMEOUT_OFFSET)) & \
  271. RX_MSDU_DESC_INFO_0_SA_IDX_TIMEOUT_MASK)
  272. #define HAL_RX_MSDU_DA_IS_VALID_FLAG_GET(msdu_info_ptr) \
  273. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  274. RX_MSDU_DESC_INFO_0_DA_IS_VALID_OFFSET)) & \
  275. RX_MSDU_DESC_INFO_0_DA_IS_VALID_MASK)
  276. #define HAL_RX_MSDU_DA_IS_MCBC_FLAG_GET(msdu_info_ptr) \
  277. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  278. RX_MSDU_DESC_INFO_0_DA_IS_MCBC_OFFSET)) & \
  279. RX_MSDU_DESC_INFO_0_DA_IS_MCBC_MASK)
  280. #define HAL_RX_MSDU_DA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) \
  281. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  282. RX_MSDU_DESC_INFO_0_DA_IDX_TIMEOUT_OFFSET)) & \
  283. RX_MSDU_DESC_INFO_0_DA_IDX_TIMEOUT_MASK)
  284. #define HAL_RX_MSDU_FLAGS_GET(msdu_info_ptr) \
  285. (HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) | \
  286. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) | \
  287. HAL_RX_MSDU_CONTINUATION_FLAG_GET(msdu_info_ptr) | \
  288. HAL_RX_MSDU_SA_IS_VALID_FLAG_GET(msdu_info_ptr) | \
  289. HAL_RX_MSDU_SA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) | \
  290. HAL_RX_MSDU_DA_IS_VALID_FLAG_GET(msdu_info_ptr) | \
  291. HAL_RX_MSDU_DA_IS_MCBC_FLAG_GET(msdu_info_ptr) | \
  292. HAL_RX_MSDU_DA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr))
  293. #define HAL_RX_MSDU_DESC_INFO_GET(msdu_details_ptr) \
  294. ((struct rx_msdu_desc_info *) \
  295. _OFFSET_TO_BYTE_PTR(msdu_details_ptr, \
  296. RX_MSDU_DETAILS_2_RX_MSDU_DESC_INFO_RX_MSDU_DESC_INFO_DETAILS_OFFSET))
  297. static inline void hal_rx_mpdu_desc_info_get(void *desc_addr,
  298. struct hal_rx_mpdu_desc_info *mpdu_desc_info)
  299. {
  300. struct reo_destination_ring *reo_dst_ring;
  301. uint32_t mpdu_info[NUM_OF_DWORDS_RX_MPDU_DESC_INFO];
  302. reo_dst_ring = (struct reo_destination_ring *) desc_addr;
  303. qdf_mem_copy(&mpdu_info,
  304. (const void *)&reo_dst_ring->rx_mpdu_desc_info_details,
  305. sizeof(struct rx_mpdu_desc_info));
  306. mpdu_desc_info->msdu_count = HAL_RX_MPDU_MSDU_COUNT_GET(mpdu_info);
  307. mpdu_desc_info->mpdu_seq = HAL_RX_MPDU_SEQUENCE_NUMBER_GET(mpdu_info);
  308. mpdu_desc_info->mpdu_flags = HAL_RX_MPDU_FLAGS_GET(mpdu_info);
  309. mpdu_desc_info->peer_meta_data =
  310. HAL_RX_MPDU_DESC_PEER_META_DATA_GET(mpdu_info);
  311. }
  312. /*
  313. * @ hal_rx_msdu_desc_info_get: Gets the flags related to MSDU desciptor.
  314. * @ Specifically flags needed are:
  315. * @ first_msdu_in_mpdu, last_msdu_in_mpdu,
  316. * @ msdu_continuation, sa_is_valid,
  317. * @ sa_idx_timeout, da_is_valid, da_idx_timeout,
  318. * @ da_is_MCBC
  319. *
  320. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to the current
  321. * @ descriptor
  322. * @ msdu_desc_info: Holds MSDU descriptor info from HAL Rx descriptor
  323. * @ Return: void
  324. */
  325. static inline void hal_rx_msdu_desc_info_get(void *desc_addr,
  326. struct hal_rx_msdu_desc_info *msdu_desc_info)
  327. {
  328. struct reo_destination_ring *reo_dst_ring;
  329. uint32_t msdu_info[NUM_OF_DWORDS_RX_MSDU_DESC_INFO];
  330. reo_dst_ring = (struct reo_destination_ring *) desc_addr;
  331. qdf_mem_copy(&msdu_info,
  332. (const void *)&reo_dst_ring->rx_msdu_desc_info_details,
  333. sizeof(struct rx_msdu_desc_info));
  334. msdu_desc_info->msdu_flags = HAL_RX_MSDU_FLAGS_GET(msdu_info);
  335. msdu_desc_info->msdu_len = HAL_RX_MSDU_PKT_LENGTH_GET(msdu_info);
  336. }
  337. /*
  338. * hal_rxdma_buff_addr_info_set() - set the buffer_addr_info of the
  339. * rxdma ring entry.
  340. * @rxdma_entry: descriptor entry
  341. * @paddr: physical address of nbuf data pointer.
  342. * @cookie: SW cookie used as a index to SW rx desc.
  343. * @manager: who owns the nbuf (host, NSS, etc...).
  344. *
  345. */
  346. static inline void hal_rxdma_buff_addr_info_set(void *rxdma_entry,
  347. qdf_dma_addr_t paddr, uint16_t cookie, uint8_t manager)
  348. {
  349. uint32_t paddr_lo = ((u64)paddr & 0x00000000ffffffff);
  350. uint32_t paddr_hi = ((u64)paddr & 0xffffffff00000000) >> 32;
  351. HAL_RXDMA_PADDR_LO_SET(rxdma_entry, paddr_lo);
  352. HAL_RXDMA_PADDR_HI_SET(rxdma_entry, paddr_hi);
  353. HAL_RXDMA_COOKIE_SET(rxdma_entry, cookie);
  354. HAL_RXDMA_MANAGER_SET(rxdma_entry, manager);
  355. }
  356. /*
  357. * Structures & Macros to obtain fields from the TLV's in the Rx packet
  358. * pre-header.
  359. */
  360. /*
  361. * Every Rx packet starts at an offset from the top of the buffer.
  362. * If the host hasn't subscribed to any specific TLV, there is
  363. * still space reserved for the following TLV's from the start of
  364. * the buffer:
  365. * -- RX ATTENTION
  366. * -- RX MPDU START
  367. * -- RX MSDU START
  368. * -- RX MSDU END
  369. * -- RX MPDU END
  370. * -- RX PACKET HEADER (802.11)
  371. * If the host subscribes to any of the TLV's above, that TLV
  372. * if populated by the HW
  373. */
  374. #define NUM_DWORDS_TAG 1
  375. /* By default the packet header TLV is 128 bytes */
  376. #define NUM_OF_BYTES_RX_802_11_HDR_TLV 128
  377. #define NUM_OF_DWORDS_RX_802_11_HDR_TLV \
  378. (NUM_OF_BYTES_RX_802_11_HDR_TLV >> 2)
  379. #define RX_PKT_OFFSET_WORDS \
  380. ( \
  381. NUM_OF_DWORDS_RX_ATTENTION + NUM_DWORDS_TAG \
  382. NUM_OF_DWORDS_RX_MPDU_START + NUM_DWORDS_TAG \
  383. NUM_OF_DWORDS_RX_MSDU_START + NUM_DWORDS_TAG \
  384. NUM_OF_DWORDS_RX_MSDU_END + NUM_DWORDS_TAG \
  385. NUM_OF_DWORDS_RX_MPDU_END + NUM_DWORDS_TAG \
  386. NUM_OF_DWORDS_RX_802_11_HDR_TLV + NUM_DWORDS_TAG \
  387. )
  388. #define RX_PKT_OFFSET_BYTES \
  389. (RX_PKT_OFFSET_WORDS << 2)
  390. #define RX_PKT_HDR_TLV_LEN 120
  391. /*
  392. * Each RX descriptor TLV is preceded by 1 DWORD "tag"
  393. */
  394. struct rx_attention_tlv {
  395. uint32_t tag;
  396. struct rx_attention rx_attn;
  397. };
  398. struct rx_mpdu_start_tlv {
  399. uint32_t tag;
  400. struct rx_mpdu_start rx_mpdu_start;
  401. };
  402. struct rx_msdu_start_tlv {
  403. uint32_t tag;
  404. struct rx_msdu_start rx_msdu_start;
  405. };
  406. struct rx_msdu_end_tlv {
  407. uint32_t tag;
  408. struct rx_msdu_end rx_msdu_end;
  409. };
  410. struct rx_mpdu_end_tlv {
  411. uint32_t tag;
  412. struct rx_mpdu_end rx_mpdu_end;
  413. };
  414. struct rx_pkt_hdr_tlv {
  415. uint32_t tag; /* 4 B */
  416. uint32_t phy_ppdu_id; /* 4 B */
  417. char rx_pkt_hdr[RX_PKT_HDR_TLV_LEN]; /* 120 B */
  418. };
  419. #define RXDMA_OPTIMIZATION
  420. #ifdef RXDMA_OPTIMIZATION
  421. /*
  422. * The RX_PADDING_BYTES is required so that the TLV's don't
  423. * spread across the 128 byte boundary
  424. * RXDMA optimization requires:
  425. * 1) MSDU_END & ATTENTION TLV's follow in that order
  426. * 2) TLV's don't span across 128 byte lines
  427. * 3) Rx Buffer is nicely aligned on the 128 byte boundary
  428. */
  429. #if defined(WCSS_VERSION) && (WCSS_VERSION >= 96)
  430. #define RX_PADDING0_BYTES 4
  431. #endif
  432. #define RX_PADDING1_BYTES 16
  433. struct rx_pkt_tlvs {
  434. struct rx_msdu_end_tlv msdu_end_tlv; /* 72 bytes */
  435. struct rx_attention_tlv attn_tlv; /* 16 bytes */
  436. struct rx_msdu_start_tlv msdu_start_tlv;/* 40 bytes */
  437. #if defined(WCSS_VERSION) && (WCSS_VERSION >= 96)
  438. uint8_t rx_padding0[RX_PADDING0_BYTES]; /* 4 bytes */
  439. #endif
  440. struct rx_mpdu_start_tlv mpdu_start_tlv;/* 96 bytes */
  441. struct rx_mpdu_end_tlv mpdu_end_tlv; /* 12 bytes */
  442. uint8_t rx_padding1[RX_PADDING1_BYTES]; /* 16 bytes */
  443. struct rx_pkt_hdr_tlv pkt_hdr_tlv; /* 128 bytes */
  444. };
  445. #else /* RXDMA_OPTIMIZATION */
  446. struct rx_pkt_tlvs {
  447. struct rx_attention_tlv attn_tlv;
  448. struct rx_mpdu_start_tlv mpdu_start_tlv;
  449. struct rx_msdu_start_tlv msdu_start_tlv;
  450. struct rx_msdu_end_tlv msdu_end_tlv;
  451. struct rx_mpdu_end_tlv mpdu_end_tlv;
  452. struct rx_pkt_hdr_tlv pkt_hdr_tlv;
  453. };
  454. #endif /* RXDMA_OPTIMIZATION */
  455. #define RX_PKT_TLVS_LEN (sizeof(struct rx_pkt_tlvs))
  456. /*
  457. * Get msdu_done bit from the RX_ATTENTION TLV
  458. */
  459. #define HAL_RX_ATTN_MSDU_DONE_GET(_rx_attn) \
  460. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  461. RX_ATTENTION_2_MSDU_DONE_OFFSET)), \
  462. RX_ATTENTION_2_MSDU_DONE_MASK, \
  463. RX_ATTENTION_2_MSDU_DONE_LSB))
  464. static inline uint32_t
  465. hal_rx_attn_msdu_done_get(uint8_t *buf)
  466. {
  467. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  468. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  469. uint32_t msdu_done;
  470. msdu_done = HAL_RX_ATTN_MSDU_DONE_GET(rx_attn);
  471. return msdu_done;
  472. }
  473. /*
  474. * Get peer_meta_data from RX_MPDU_INFO within RX_MPDU_START
  475. */
  476. #define HAL_RX_MPDU_PEER_META_DATA_GET(_rx_mpdu_info) \
  477. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  478. RX_MPDU_INFO_8_PEER_META_DATA_OFFSET)), \
  479. RX_MPDU_INFO_8_PEER_META_DATA_MASK, \
  480. RX_MPDU_INFO_8_PEER_META_DATA_LSB))
  481. static inline uint32_t
  482. hal_rx_mpdu_peer_meta_data_get(uint8_t *buf)
  483. {
  484. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  485. struct rx_mpdu_start *mpdu_start =
  486. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  487. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  488. uint32_t peer_meta_data;
  489. peer_meta_data = HAL_RX_MPDU_PEER_META_DATA_GET(mpdu_info);
  490. return peer_meta_data;
  491. }
  492. #if defined(WCSS_VERSION) && (WCSS_VERSION > 81)
  493. #define HAL_RX_MSDU_END_L3_HEADER_PADDING_GET(_rx_msdu_end) \
  494. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  495. RX_MSDU_END_5_L3_HEADER_PADDING_OFFSET)), \
  496. RX_MSDU_END_5_L3_HEADER_PADDING_MASK, \
  497. RX_MSDU_END_5_L3_HEADER_PADDING_LSB))
  498. #else
  499. #define HAL_RX_MSDU_END_L3_HEADER_PADDING_GET(_rx_msdu_end) \
  500. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  501. RX_MSDU_END_9_L3_HEADER_PADDING_OFFSET)), \
  502. RX_MSDU_END_9_L3_HEADER_PADDING_MASK, \
  503. RX_MSDU_END_9_L3_HEADER_PADDING_LSB))
  504. #endif
  505. /**
  506. * hal_rx_msdu_end_l3_hdr_padding_get: API to get the
  507. * l3_header padding from rx_msdu_end TLV
  508. *
  509. * @ buf: pointer to the start of RX PKT TLV headers
  510. * Return: number of l3 header padding bytes
  511. */
  512. static inline uint32_t
  513. hal_rx_msdu_end_l3_hdr_padding_get(uint8_t *buf)
  514. {
  515. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  516. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  517. uint32_t l3_header_padding;
  518. l3_header_padding = HAL_RX_MSDU_END_L3_HEADER_PADDING_GET(msdu_end);
  519. return l3_header_padding;
  520. }
  521. #define HAL_RX_MSDU_START_MSDU_LEN_GET(_rx_msdu_start) \
  522. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  523. RX_MSDU_START_1_MSDU_LENGTH_OFFSET)), \
  524. RX_MSDU_START_1_MSDU_LENGTH_MASK, \
  525. RX_MSDU_START_1_MSDU_LENGTH_LSB))
  526. /**
  527. * hal_rx_msdu_start_msdu_len_get: API to get the MSDU length
  528. * from rx_msdu_start TLV
  529. *
  530. * @ buf: pointer to the start of RX PKT TLV headers
  531. * Return: msdu length
  532. */
  533. static inline uint32_t
  534. hal_rx_msdu_start_msdu_len_get(uint8_t *buf)
  535. {
  536. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  537. struct rx_msdu_start *msdu_start =
  538. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  539. uint32_t msdu_len;
  540. msdu_len = HAL_RX_MSDU_START_MSDU_LEN_GET(msdu_start);
  541. return msdu_len;
  542. }
  543. /*******************************************************************************
  544. * RX ERROR APIS
  545. ******************************************************************************/
  546. /*******************************************************************************
  547. * RX REO ERROR APIS
  548. ******************************************************************************/
  549. #define HAL_RX_LINK_DESC_MSDU0_PTR(link_desc) \
  550. ((struct rx_msdu_details *) \
  551. _OFFSET_TO_BYTE_PTR((link_desc),\
  552. RX_MSDU_LINK_8_RX_MSDU_DETAILS_MSDU_0_OFFSET))
  553. #define HAL_RX_NUM_MSDU_DESC 6
  554. struct hal_rx_msdu_list {
  555. struct hal_rx_msdu_desc_info msdu_info[HAL_RX_NUM_MSDU_DESC];
  556. uint32_t sw_cookie[HAL_RX_NUM_MSDU_DESC];
  557. };
  558. struct hal_buf_info {
  559. uint64_t paddr;
  560. uint32_t sw_cookie;
  561. };
  562. /**
  563. * hal_rx_msdu_link_desc_get: API to get the MSDU information
  564. * from the MSDU link descriptor
  565. *
  566. * @ msdu_link_desc: Opaque pointer used by HAL to get to the
  567. * MSDU link descriptor (struct rx_msdu_link)
  568. * @ msdu_list: Return the list of MSDUs contained in this link descriptor
  569. * Return: void
  570. */
  571. static inline void hal_rx_msdu_list_get(void *msdu_link_desc,
  572. struct hal_rx_msdu_list *msdu_list, uint8_t *num_msdus)
  573. {
  574. struct rx_msdu_details *msdu_details;
  575. struct rx_msdu_desc_info *msdu_desc_info;
  576. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  577. int i;
  578. *num_msdus = 0;
  579. msdu_details = HAL_RX_LINK_DESC_MSDU0_PTR(msdu_link);
  580. for (i = 0; i < HAL_RX_NUM_MSDU_DESC; i++) {
  581. msdu_desc_info = HAL_RX_MSDU_DESC_INFO_GET(&msdu_details[i]);
  582. msdu_list->msdu_info[i].msdu_flags =
  583. HAL_RX_MSDU_FLAGS_GET(msdu_desc_info);
  584. msdu_list->msdu_info[i].msdu_len =
  585. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  586. msdu_list->sw_cookie[i] =
  587. HAL_RX_BUF_COOKIE_GET(
  588. &msdu_details[i].buffer_addr_info_details);
  589. }
  590. *num_msdus = i;
  591. }
  592. /**
  593. * hal_rx_reo_buf_paddr_get: Gets the physical address and
  594. * cookie from the REO destination ring element
  595. *
  596. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  597. * the current descriptor
  598. * @ buf_info: structure to return the buffer information
  599. * Return: void
  600. */
  601. static inline void hal_rx_reo_buf_paddr_get(void *rx_desc,
  602. struct hal_buf_info *buf_info)
  603. {
  604. struct reo_destination_ring *reo_ring =
  605. (struct reo_destination_ring *)rx_desc;
  606. buf_info->paddr =
  607. (HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_ring) |
  608. ((uint64_t)(HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_ring)) << 32));
  609. buf_info->sw_cookie = HAL_RX_REO_BUF_COOKIE_GET(reo_ring);
  610. }
  611. /**
  612. * enum hal_reo_error_code: Indicates that type of buffer or descriptor
  613. *
  614. * @ HAL_RX_MSDU_BUF_ADDR_TYPE : Reo buffer address points to the MSDU buffer
  615. * @ HAL_RX_MSDU_LINK_DESC_TYPE: Reo buffer address points to the link
  616. * descriptor
  617. */
  618. enum hal_rx_reo_buf_type {
  619. HAL_RX_REO_MSDU_BUF_ADDR_TYPE = 0,
  620. HAL_RX_REO_MSDU_LINK_DESC_TYPE,
  621. };
  622. #define HAL_RX_REO_BUF_TYPE_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  623. (REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_OFFSET >> 2))) & \
  624. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_MASK) >> \
  625. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_LSB)
  626. /**
  627. * enum hal_reo_error_code: Error code describing the type of error detected
  628. *
  629. * @ HAL_REO_ERR_QUEUE_DESC_ADDR_0 : Reo queue descriptor provided in the
  630. * REO_ENTRANCE ring is set to 0
  631. * @ HAL_REO_ERR_QUEUE_DESC_INVALID: Reo queue descriptor valid bit is NOT set
  632. * @ HAL_REO_ERR_AMPDU_IN_NON_BA : AMPDU frame received without BA session
  633. * having been setup
  634. * @ HAL_REO_ERR_NON_BA_DUPLICATE : Non-BA session, SN equal to SSN,
  635. * Retry bit set: duplicate frame
  636. * @ HAL_REO_ERR_BA_DUPLICATE : BA session, duplicate frame
  637. * @ HAL_REO_ERR_REGULAR_FRAME_2K_JUMP : A normal (management/data frame)
  638. * received with 2K jump in SN
  639. * @ HAL_REO_ERR_BAR_FRAME_2K_JUMP : A bar received with 2K jump in SSN
  640. * @ HAL_REO_ERR_REGULAR_FRAME_OOR : A normal (management/data frame) received
  641. * with SN falling within the OOR window
  642. * @ HAL_REO_ERR_BAR_FRAME_OOR : A bar received with SSN falling within the
  643. * OOR window
  644. * @ HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION : A bar received without a BA session
  645. * @ HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN : A bar received with SSN equal to SN
  646. * @ HAL_REO_ERR_PN_CHECK_FAILED : PN Check Failed packet
  647. * @ HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  648. * of the ‘Seq_2k_error_detected_flag’ been set in the REO Queue descriptor
  649. * @ HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  650. * of the ‘pn_error_detected_flag’ been set in the REO Queue descriptor
  651. * @ HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET : Frame is forwarded as a result of
  652. * the queue descriptor(address) being blocked as SW/FW seems to be currently
  653. * in the process of making updates to this descriptor
  654. */
  655. enum hal_reo_error_code {
  656. HAL_REO_ERR_QUEUE_DESC_ADDR_0 = 0,
  657. HAL_REO_ERR_QUEUE_DESC_INVALID,
  658. HAL_REO_ERR_AMPDU_IN_NON_BA,
  659. HAL_REO_ERR_NON_BA_DUPLICATE,
  660. HAL_REO_ERR_BA_DUPLICATE,
  661. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP,
  662. HAL_REO_ERR_BAR_FRAME_2K_JUMP,
  663. HAL_REO_ERR_REGULAR_FRAME_OOR,
  664. HAL_REO_ERR_BAR_FRAME_OOR,
  665. HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION,
  666. HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN,
  667. HAL_REO_ERR_PN_CHECK_FAILED,
  668. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET,
  669. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET,
  670. HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET
  671. };
  672. #define HAL_RX_REO_ERROR_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  673. (REO_DESTINATION_RING_7_REO_ERROR_CODE_OFFSET >> 2))) & \
  674. REO_DESTINATION_RING_7_REO_ERROR_CODE_MASK) >> \
  675. REO_DESTINATION_RING_7_REO_ERROR_CODE_LSB)
  676. /**
  677. * hal_rx_is_pn_error() - Indicate if this error was caused by a
  678. * PN check failure
  679. *
  680. * @reo_desc: opaque pointer used by HAL to get the REO destination entry
  681. *
  682. * Return: true: error caused by PN check, false: other error
  683. */
  684. static inline bool hal_rx_reo_is_pn_error(void *rx_desc)
  685. {
  686. struct reo_destination_ring *reo_desc =
  687. (struct reo_destination_ring *)rx_desc;
  688. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  689. HAL_REO_ERR_PN_CHECK_FAILED) |
  690. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  691. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET)) ?
  692. true : false;
  693. }
  694. /**
  695. * hal_rx_is_2k_jump() - Indicate if this error was caused by a 2K jump in
  696. * the sequence number
  697. *
  698. * @ring_desc: opaque pointer used by HAL to get the REO destination entry
  699. *
  700. * Return: true: error caused by 2K jump, false: other error
  701. */
  702. static inline bool hal_rx_reo_is_2k_jump(void *rx_desc)
  703. {
  704. struct reo_destination_ring *reo_desc =
  705. (struct reo_destination_ring *)rx_desc;
  706. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  707. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP) |
  708. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  709. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET)) ?
  710. true : false;
  711. }
  712. /**
  713. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  714. *
  715. * @ soc : HAL version of the SOC pointer
  716. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  717. * @ buf_addr_info : void pointer to the buffer_addr_info
  718. *
  719. * Return: void
  720. */
  721. /* look at implementation at dp_hw_link_desc_pool_setup()*/
  722. static inline void hal_rx_msdu_link_desc_set(struct hal_soc *soc,
  723. void *src_srng_desc, void *buf_addr_info)
  724. {
  725. struct wbm_release_ring *wbm_rel_srng =
  726. (struct wbm_release_ring *)src_srng_desc;
  727. /* Structure copy !!! */
  728. wbm_rel_srng->released_buff_or_desc_addr_info =
  729. *((struct buffer_addr_info *)buf_addr_info);
  730. }
  731. /*
  732. * hal_rx_msdu_link_desc_reinject: Re-injects the MSDU link descriptor to
  733. * REO entrance ring
  734. *
  735. * @ soc: HAL version of the SOC pointer
  736. * @ pa: Physical address of the MSDU Link Descriptor
  737. * @ cookie: SW cookie to get to the virtual address
  738. * @ error_enabled_reo_q: Argument to determine whether this needs to go
  739. * to the error enabled REO queue
  740. *
  741. * Return: void
  742. */
  743. static inline void hal_rx_msdu_link_desc_reinject(struct hal_soc *soc,
  744. uint64_t pa, uint32_t cookie, bool error_enabled_reo_q)
  745. {
  746. /* TODO */
  747. }
  748. /**
  749. * HAL_RX_BUF_ADDR_INFO_GET: Returns the address of the
  750. * BUFFER_ADDR_INFO, give the RX descriptor
  751. * (Assumption -- BUFFER_ADDR_INFO is the
  752. * first field in the descriptor structure)
  753. */
  754. #define HAL_RX_BUF_ADDR_INFO_GET(ring_desc) ((void *)(ring_desc))
  755. #define HAL_RX_REO_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  756. #define HAL_RX_WBM_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  757. /**
  758. * hal_rx_ret_buf_manager_get: Returns the "return_buffer_manager"
  759. * from the BUFFER_ADDR_INFO structure
  760. * given a REO destination ring descriptor.
  761. * @ ring_desc: RX(REO/WBM release) destination ring descriptor
  762. *
  763. * Return: uint8_t (value of the return_buffer_manager)
  764. */
  765. static inline
  766. uint8_t hal_rx_ret_buf_manager_get(void *ring_desc)
  767. {
  768. /*
  769. * The following macro takes buf_addr_info as argument,
  770. * but since buf_addr_info is the first field in ring_desc
  771. * Hence the following call is OK
  772. */
  773. return HAL_RX_BUF_RBM_GET(ring_desc);
  774. }
  775. /*******************************************************************************
  776. * RX WBM ERROR APIS
  777. ******************************************************************************/
  778. /**
  779. * enum hal_rx_wbm_error_source: Indicates which module initiated the
  780. * release of this buffer or descriptor
  781. *
  782. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  783. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  784. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  785. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  786. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  787. */
  788. enum hal_rx_wbm_error_source {
  789. HAL_RX_WBM_ERR_SRC_TQM = 0,
  790. HAL_RX_WBM_ERR_SRC_RXDMA,
  791. HAL_RX_WBM_ERR_SRC_REO,
  792. HAL_RX_WBM_ERR_SRC_FW,
  793. HAL_RX_WBM_ERR_SRC_SW,
  794. };
  795. #define HAL_RX_WBM_ERR_SRC_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  796. (WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_OFFSET >> 2))) & \
  797. WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_MASK) >> \
  798. WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_LSB)
  799. /**
  800. * enum hal_rx_wbm_buf_type: Indicates that type of buffer or descriptor
  801. * released
  802. *
  803. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  804. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  805. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  806. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  807. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  808. */
  809. enum hal_rx_wbm_buf_type {
  810. HAL_RX_WBM_BUF_TYPE_REL_BUF = 0,
  811. HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC,
  812. HAL_RX_WBM_BUF_TYPE_MPDU_LINK_DESC,
  813. HAL_RX_WBM_BUF_TYPE_MSDU_EXT_DESC,
  814. HAL_RX_WBM_BUF_TYPE_Q_EXT_DESC,
  815. };
  816. #define HAL_RX_WBM_BUF_TYPE_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  817. (WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_OFFSET >> 2))) & \
  818. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_MASK) >> \
  819. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_LSB)
  820. /**
  821. * enum - hal_rx_wbm_reo_push_reason: Indicates why REO pushed
  822. * the frame to this release ring
  823. *
  824. * @ HAL_RX_WBM_REO_PSH_RSN_ERROR : Reo detected an error and pushed this
  825. * frame to this queue
  826. * @ HAL_RX_WBM_REO_PSH_RSN_ROUTE: Reo pushed the frame to this queue per
  827. * received routing instructions. No error within REO was detected
  828. */
  829. enum hal_rx_wbm_reo_push_reason {
  830. HAL_RX_WBM_REO_PSH_RSN_ERROR = 0,
  831. HAL_RX_WBM_REO_PSH_RSN_ROUTE,
  832. };
  833. #define HAL_RX_WBM_REO_PUSH_REASON_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  834. (WBM_RELEASE_RING_2_REO_PUSH_REASON_OFFSET >> 2))) & \
  835. WBM_RELEASE_RING_2_REO_PUSH_REASON_MASK) >> \
  836. WBM_RELEASE_RING_2_REO_PUSH_REASON_LSB)
  837. #define HAL_RX_WBM_REO_ERROR_CODE_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  838. (WBM_RELEASE_RING_2_REO_ERROR_CODE_OFFSET >> 2))) & \
  839. WBM_RELEASE_RING_2_REO_ERROR_CODE_MASK) >> \
  840. WBM_RELEASE_RING_2_REO_ERROR_CODE_LSB)
  841. /**
  842. * enum hal_rx_wbm_rxdma_push_reason: Indicates why REO pushed the frame to
  843. * this release ring
  844. *
  845. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ERROR : RXDMA detected an error and pushed
  846. * this frame to this queue
  847. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE: RXDMA pushed the frame to this queue
  848. * per received routing instructions. No error within RXDMA was detected
  849. */
  850. enum hal_rx_wbm_rxdma_push_reason {
  851. HAL_RX_WBM_RXDMA_PSH_RSN_ERROR = 0,
  852. HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE,
  853. };
  854. #define HAL_RX_WBM_RXDMA_PUSH_REASON_GET(wbm_desc) \
  855. (((*(((uint32_t *) wbm_desc) + \
  856. (WBM_RELEASE_RING_2_RXDMA_PUSH_REASON_OFFSET >> 2))) & \
  857. WBM_RELEASE_RING_2_RXDMA_PUSH_REASON_MASK) >> \
  858. WBM_RELEASE_RING_2_RXDMA_PUSH_REASON_LSB)
  859. #define HAL_RX_WBM_RXDMA_ERROR_CODE_GET(wbm_desc) \
  860. (((*(((uint32_t *) wbm_desc) + \
  861. (WBM_RELEASE_RING_2_RXDMA_ERROR_CODE_OFFSET >> 2))) & \
  862. WBM_RELEASE_RING_2_RXDMA_ERROR_CODE_MASK) >> \
  863. WBM_RELEASE_RING_2_RXDMA_ERROR_CODE_LSB)
  864. #define HAL_RX_WBM_BUF_COOKIE_GET(wbm_desc) \
  865. HAL_RX_BUF_COOKIE_GET(&((struct wbm_release_ring *) \
  866. wbm_desc)->released_buff_or_desc_addr_info)
  867. #endif /* _HAL_RX_H */