hal_rx.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. /*
  2. * Copyright (c) 2016 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_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_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_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. #if defined(WCSS_VERSION) && (WCSS_VERSION > 81)
  474. #define HAL_RX_MSDU_END_L3_HEADER_PADDING_GET(_rx_msdu_end) \
  475. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  476. RX_MSDU_END_5_L3_HEADER_PADDING_OFFSET)), \
  477. RX_MSDU_END_5_L3_HEADER_PADDING_MASK, \
  478. RX_MSDU_END_5_L3_HEADER_PADDING_LSB))
  479. #else
  480. #define HAL_RX_MSDU_END_L3_HEADER_PADDING_GET(_rx_msdu_end) \
  481. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  482. RX_MSDU_END_9_L3_HEADER_PADDING_OFFSET)), \
  483. RX_MSDU_END_9_L3_HEADER_PADDING_MASK, \
  484. RX_MSDU_END_9_L3_HEADER_PADDING_LSB))
  485. #endif
  486. /**
  487. * hal_rx_msdu_end_l3_hdr_padding_get: API to get the
  488. * l3_header padding from rx_msdu_end TLV
  489. *
  490. * @ buf: pointer to the start of RX PKT TLV headers
  491. * Return: number of l3 header padding bytes
  492. */
  493. static inline uint32_t
  494. hal_rx_msdu_end_l3_hdr_padding_get(uint8_t *buf)
  495. {
  496. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  497. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  498. uint32_t l3_header_padding;
  499. l3_header_padding = HAL_RX_MSDU_END_L3_HEADER_PADDING_GET(msdu_end);
  500. return l3_header_padding;
  501. }
  502. #define HAL_RX_MSDU_START_MSDU_LEN_GET(_rx_msdu_start) \
  503. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  504. RX_MSDU_START_1_MSDU_LENGTH_OFFSET)), \
  505. RX_MSDU_START_1_MSDU_LENGTH_MASK, \
  506. RX_MSDU_START_1_MSDU_LENGTH_LSB))
  507. /**
  508. * hal_rx_msdu_start_msdu_len_get: API to get the MSDU length
  509. * from rx_msdu_start TLV
  510. *
  511. * @ buf: pointer to the start of RX PKT TLV headers
  512. * Return: msdu length
  513. */
  514. static inline uint32_t
  515. hal_rx_msdu_start_msdu_len_get(uint8_t *buf)
  516. {
  517. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  518. struct rx_msdu_start *msdu_start =
  519. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  520. uint32_t msdu_len;
  521. msdu_len = HAL_RX_MSDU_START_MSDU_LEN_GET(msdu_start);
  522. return msdu_len;
  523. }
  524. /*******************************************************************************
  525. * RX ERROR APIS
  526. ******************************************************************************/
  527. /*******************************************************************************
  528. * RX REO ERROR APIS
  529. ******************************************************************************/
  530. #define HAL_RX_LINK_DESC_MSDU0_PTR(link_desc) \
  531. ((struct rx_msdu_details *) \
  532. _OFFSET_TO_BYTE_PTR((link_desc),\
  533. RX_MSDU_LINK_8_RX_MSDU_DETAILS_MSDU_0_OFFSET))
  534. #define HAL_RX_NUM_MSDU_DESC 6
  535. struct hal_rx_msdu_list {
  536. struct hal_rx_msdu_desc_info msdu_info[HAL_RX_NUM_MSDU_DESC];
  537. uint32_t sw_cookie[HAL_RX_NUM_MSDU_DESC];
  538. };
  539. struct hal_buf_info {
  540. uint64_t paddr;
  541. uint32_t sw_cookie;
  542. };
  543. /**
  544. * hal_rx_msdu_link_desc_get: API to get the MSDU information
  545. * from the MSDU link descriptor
  546. *
  547. * @ msdu_link_desc: Opaque pointer used by HAL to get to the
  548. * MSDU link descriptor (struct rx_msdu_link)
  549. * @ msdu_list: Return the list of MSDUs contained in this link descriptor
  550. * Return: void
  551. */
  552. static inline void hal_rx_msdu_list_get(void *msdu_link_desc,
  553. struct hal_rx_msdu_list *msdu_list, uint8_t *num_msdus)
  554. {
  555. struct rx_msdu_details *msdu_details;
  556. struct rx_msdu_desc_info *msdu_desc_info;
  557. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  558. int i;
  559. *num_msdus = 0;
  560. msdu_details = HAL_RX_LINK_DESC_MSDU0_PTR(msdu_link);
  561. for (i = 0; i < HAL_RX_NUM_MSDU_DESC; i++) {
  562. msdu_desc_info = HAL_RX_MSDU_DESC_INFO_GET(&msdu_details[i]);
  563. msdu_list->msdu_info[i].msdu_flags =
  564. HAL_RX_MSDU_FLAGS_GET(msdu_desc_info);
  565. msdu_list->msdu_info[i].msdu_len =
  566. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  567. msdu_list->sw_cookie[i] =
  568. HAL_RX_BUF_COOKIE_GET(
  569. &msdu_details[i].buffer_addr_info_details);
  570. }
  571. *num_msdus = i;
  572. }
  573. /**
  574. * hal_rx_reo_buf_paddr_get: Gets the physical address and
  575. * cookie from the REO destination ring element
  576. *
  577. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  578. * the current descriptor
  579. * @ buf_info: structure to return the buffer information
  580. * Return: void
  581. */
  582. static inline void hal_rx_reo_buf_paddr_get(void *rx_desc,
  583. struct hal_buf_info *buf_info)
  584. {
  585. struct reo_destination_ring *reo_ring =
  586. (struct reo_destination_ring *)rx_desc;
  587. buf_info->paddr =
  588. (HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_ring) |
  589. ((uint64_t)(HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_ring)) << 32));
  590. buf_info->sw_cookie = HAL_RX_REO_BUF_COOKIE_GET(reo_ring);
  591. }
  592. /**
  593. * enum hal_reo_error_code: Indicates that type of buffer or descriptor
  594. *
  595. * @ HAL_RX_MSDU_BUF_ADDR_TYPE : Reo buffer address points to the MSDU buffer
  596. * @ HAL_RX_MSDU_LINK_DESC_TYPE: Reo buffer address points to the link
  597. * descriptor
  598. */
  599. enum hal_rx_reo_buf_type {
  600. HAL_RX_REO_MSDU_BUF_ADDR_TYPE = 0,
  601. HAL_RX_REO_MSDU_LINK_DESC_TYPE,
  602. };
  603. #define HAL_RX_REO_BUF_TYPE_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  604. (REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_OFFSET >> 2))) & \
  605. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_MASK) >> \
  606. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_LSB)
  607. /**
  608. * enum hal_reo_error_code: Error code describing the type of error detected
  609. *
  610. * @ HAL_REO_ERR_QUEUE_DESC_ADDR_0 : Reo queue descriptor provided in the
  611. * REO_ENTRANCE ring is set to 0
  612. * @ HAL_REO_ERR_QUEUE_DESC_INVALID: Reo queue descriptor valid bit is NOT set
  613. * @ HAL_REO_ERR_AMPDU_IN_NON_BA : AMPDU frame received without BA session
  614. * having been setup
  615. * @ HAL_REO_ERR_NON_BA_DUPLICATE : Non-BA session, SN equal to SSN,
  616. * Retry bit set: duplicate frame
  617. * @ HAL_REO_ERR_BA_DUPLICATE : BA session, duplicate frame
  618. * @ HAL_REO_ERR_REGULAR_FRAME_2K_JUMP : A normal (management/data frame)
  619. * received with 2K jump in SN
  620. * @ HAL_REO_ERR_BAR_FRAME_2K_JUMP : A bar received with 2K jump in SSN
  621. * @ HAL_REO_ERR_REGULAR_FRAME_OOR : A normal (management/data frame) received
  622. * with SN falling within the OOR window
  623. * @ HAL_REO_ERR_BAR_FRAME_OOR : A bar received with SSN falling within the
  624. * OOR window
  625. * @ HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION : A bar received without a BA session
  626. * @ HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN : A bar received with SSN equal to SN
  627. * @ HAL_REO_ERR_PN_CHECK_FAILED : PN Check Failed packet
  628. * @ HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  629. * of the ‘Seq_2k_error_detected_flag’ been set in the REO Queue descriptor
  630. * @ HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  631. * of the ‘pn_error_detected_flag’ been set in the REO Queue descriptor
  632. * @ HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET : Frame is forwarded as a result of
  633. * the queue descriptor(address) being blocked as SW/FW seems to be currently
  634. * in the process of making updates to this descriptor
  635. */
  636. enum hal_reo_error_code {
  637. HAL_REO_ERR_QUEUE_DESC_ADDR_0 = 0,
  638. HAL_REO_ERR_QUEUE_DESC_INVALID,
  639. HAL_REO_ERR_AMPDU_IN_NON_BA,
  640. HAL_REO_ERR_NON_BA_DUPLICATE,
  641. HAL_REO_ERR_BA_DUPLICATE,
  642. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP,
  643. HAL_REO_ERR_BAR_FRAME_2K_JUMP,
  644. HAL_REO_ERR_REGULAR_FRAME_OOR,
  645. HAL_REO_ERR_BAR_FRAME_OOR,
  646. HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION,
  647. HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN,
  648. HAL_REO_ERR_PN_CHECK_FAILED,
  649. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET,
  650. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET,
  651. HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET
  652. };
  653. #define HAL_RX_REO_ERROR_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  654. (REO_DESTINATION_RING_7_REO_ERROR_CODE_OFFSET >> 2))) & \
  655. REO_DESTINATION_RING_7_REO_ERROR_CODE_MASK) >> \
  656. REO_DESTINATION_RING_7_REO_ERROR_CODE_LSB)
  657. /**
  658. * hal_rx_is_pn_error() - Indicate if this error was caused by a
  659. * PN check failure
  660. *
  661. * @reo_desc: opaque pointer used by HAL to get the REO destination entry
  662. *
  663. * Return: true: error caused by PN check, false: other error
  664. */
  665. static inline bool hal_rx_reo_is_pn_error(void *rx_desc)
  666. {
  667. struct reo_destination_ring *reo_desc =
  668. (struct reo_destination_ring *)rx_desc;
  669. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  670. HAL_REO_ERR_PN_CHECK_FAILED) |
  671. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  672. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET)) ?
  673. true : false;
  674. }
  675. /**
  676. * hal_rx_is_2k_jump() - Indicate if this error was caused by a 2K jump in
  677. * the sequence number
  678. *
  679. * @ring_desc: opaque pointer used by HAL to get the REO destination entry
  680. *
  681. * Return: true: error caused by 2K jump, false: other error
  682. */
  683. static inline bool hal_rx_reo_is_2k_jump(void *rx_desc)
  684. {
  685. struct reo_destination_ring *reo_desc =
  686. (struct reo_destination_ring *)rx_desc;
  687. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  688. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP) |
  689. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  690. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET)) ?
  691. true : false;
  692. }
  693. /**
  694. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  695. *
  696. * @ soc : HAL version of the SOC pointer
  697. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  698. * @ buf_addr_info : void pointer to the buffer_addr_info
  699. *
  700. * Return: void
  701. */
  702. /* look at implementation at dp_hw_link_desc_pool_setup()*/
  703. static inline void hal_rx_msdu_link_desc_set(struct hal_soc *soc,
  704. void *src_srng_desc, void *buf_addr_info)
  705. {
  706. struct wbm_release_ring *wbm_rel_srng =
  707. (struct wbm_release_ring *)src_srng_desc;
  708. /* Structure copy !!! */
  709. wbm_rel_srng->released_buff_or_desc_addr_info =
  710. *((struct buffer_addr_info *)buf_addr_info);
  711. }
  712. /*
  713. * hal_rx_msdu_link_desc_reinject: Re-injects the MSDU link descriptor to
  714. * REO entrance ring
  715. *
  716. * @ soc: HAL version of the SOC pointer
  717. * @ pa: Physical address of the MSDU Link Descriptor
  718. * @ cookie: SW cookie to get to the virtual address
  719. * @ error_enabled_reo_q: Argument to determine whether this needs to go
  720. * to the error enabled REO queue
  721. *
  722. * Return: void
  723. */
  724. static inline void hal_rx_msdu_link_desc_reinject(struct hal_soc *soc,
  725. uint64_t pa, uint32_t cookie, bool error_enabled_reo_q)
  726. {
  727. /* TODO */
  728. }
  729. /**
  730. * HAL_RX_BUF_ADDR_INFO_GET: Returns the address of the
  731. * BUFFER_ADDR_INFO, give the RX descriptor
  732. * (Assumption -- BUFFER_ADDR_INFO is the
  733. * first field in the descriptor structure)
  734. */
  735. #define HAL_RX_BUF_ADDR_INFO_GET(ring_desc) ((void *)(ring_desc))
  736. #define HAL_RX_REO_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  737. #define HAL_RX_WBM_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  738. /**
  739. * hal_rx_ret_buf_manager_get: Returns the "return_buffer_manager"
  740. * from the BUFFER_ADDR_INFO structure
  741. * given a REO destination ring descriptor.
  742. * @ ring_desc: RX(REO/WBM release) destination ring descriptor
  743. *
  744. * Return: uint8_t (value of the return_buffer_manager)
  745. */
  746. static inline
  747. uint8_t hal_rx_ret_buf_manager_get(void *ring_desc)
  748. {
  749. /*
  750. * The following macro takes buf_addr_info as argument,
  751. * but since buf_addr_info is the first field in ring_desc
  752. * Hence the following call is OK
  753. */
  754. return HAL_RX_BUF_RBM_GET(ring_desc);
  755. }
  756. /*******************************************************************************
  757. * RX WBM ERROR APIS
  758. ******************************************************************************/
  759. /**
  760. * enum hal_rx_wbm_error_source: Indicates which module initiated the
  761. * release of this buffer or descriptor
  762. *
  763. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  764. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  765. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  766. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  767. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  768. */
  769. enum hal_rx_wbm_error_source {
  770. HAL_RX_WBM_ERR_SRC_TQM = 0,
  771. HAL_RX_WBM_ERR_SRC_RXDMA,
  772. HAL_RX_WBM_ERR_SRC_REO,
  773. HAL_RX_WBM_ERR_SRC_FW,
  774. HAL_RX_WBM_ERR_SRC_SW,
  775. };
  776. #define HAL_RX_WBM_ERR_SRC_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  777. (WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_OFFSET >> 2))) & \
  778. WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_MASK) >> \
  779. WBM_RELEASE_RING_2_RELEASE_SOURCE_MODULE_LSB)
  780. /**
  781. * enum hal_rx_wbm_buf_type: Indicates that type of buffer or descriptor
  782. * released
  783. *
  784. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  785. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  786. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  787. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  788. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  789. */
  790. enum hal_rx_wbm_buf_type {
  791. HAL_RX_WBM_BUF_TYPE_REL_BUF = 0,
  792. HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC,
  793. HAL_RX_WBM_BUF_TYPE_MPDU_LINK_DESC,
  794. HAL_RX_WBM_BUF_TYPE_MSDU_EXT_DESC,
  795. HAL_RX_WBM_BUF_TYPE_Q_EXT_DESC,
  796. };
  797. #define HAL_RX_WBM_BUF_TYPE_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  798. (WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_OFFSET >> 2))) & \
  799. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_MASK) >> \
  800. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_LSB)
  801. /**
  802. * enum - hal_rx_wbm_reo_push_reason: Indicates why REO pushed
  803. * the frame to this release ring
  804. *
  805. * @ HAL_RX_WBM_REO_PSH_RSN_ERROR : Reo detected an error and pushed this
  806. * frame to this queue
  807. * @ HAL_RX_WBM_REO_PSH_RSN_ROUTE: Reo pushed the frame to this queue per
  808. * received routing instructions. No error within REO was detected
  809. */
  810. enum hal_rx_wbm_reo_push_reason {
  811. HAL_RX_WBM_REO_PSH_RSN_ERROR = 0,
  812. HAL_RX_WBM_REO_PSH_RSN_ROUTE,
  813. };
  814. #define HAL_RX_WBM_REO_PUSH_REASON_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  815. (WBM_RELEASE_RING_2_REO_PUSH_REASON_OFFSET >> 2))) & \
  816. WBM_RELEASE_RING_2_REO_PUSH_REASON_MASK) >> \
  817. WBM_RELEASE_RING_2_REO_PUSH_REASON_LSB)
  818. #define HAL_RX_WBM_REO_ERROR_CODE_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  819. (WBM_RELEASE_RING_2_REO_ERROR_CODE_OFFSET >> 2))) & \
  820. WBM_RELEASE_RING_2_REO_ERROR_CODE_MASK) >> \
  821. WBM_RELEASE_RING_2_REO_ERROR_CODE_LSB)
  822. /**
  823. * enum hal_rx_wbm_rxdma_push_reason: Indicates why REO pushed the frame to
  824. * this release ring
  825. *
  826. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ERROR : RXDMA detected an error and pushed
  827. * this frame to this queue
  828. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE: RXDMA pushed the frame to this queue
  829. * per received routing instructions. No error within RXDMA was detected
  830. */
  831. enum hal_rx_wbm_rxdma_push_reason {
  832. HAL_RX_WBM_RXDMA_PSH_RSN_ERROR = 0,
  833. HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE,
  834. };
  835. #define HAL_RX_WBM_RXDMA_PUSH_REASON_GET(wbm_desc) \
  836. (((*(((uint32_t *) wbm_desc) + \
  837. (WBM_RELEASE_RING_2_RXDMA_PUSH_REASON_OFFSET >> 2))) & \
  838. WBM_RELEASE_RING_2_RXDMA_PUSH_REASON_MASK) >> \
  839. WBM_RELEASE_RING_2_RXDMA_PUSH_REASON_LSB)
  840. #define HAL_RX_WBM_RXDMA_ERROR_CODE_GET(wbm_desc) \
  841. (((*(((uint32_t *) wbm_desc) + \
  842. (WBM_RELEASE_RING_2_RXDMA_ERROR_CODE_OFFSET >> 2))) & \
  843. WBM_RELEASE_RING_2_RXDMA_ERROR_CODE_MASK) >> \
  844. WBM_RELEASE_RING_2_RXDMA_ERROR_CODE_LSB)
  845. #define HAL_RX_WBM_BUF_COOKIE_GET(wbm_desc) \
  846. HAL_RX_BUF_COOKIE_GET(&((struct wbm_release_ring *) \
  847. wbm_desc)->released_buff_or_desc_addr_info)
  848. #endif /* _HAL_RX_H */