dp_rx.h 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. /*
  2. * Copyright (c) 2016-2019 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 _DP_RX_H
  19. #define _DP_RX_H
  20. #include "hal_rx.h"
  21. #include "dp_tx.h"
  22. #include "dp_peer.h"
  23. #include "dp_internal.h"
  24. #ifdef RXDMA_OPTIMIZATION
  25. #ifdef NO_RX_PKT_HDR_TLV
  26. #define RX_BUFFER_ALIGNMENT 0
  27. #else
  28. #define RX_BUFFER_ALIGNMENT 128
  29. #endif /* NO_RX_PKT_HDR_TLV */
  30. #else /* RXDMA_OPTIMIZATION */
  31. #define RX_BUFFER_ALIGNMENT 4
  32. #endif /* RXDMA_OPTIMIZATION */
  33. #ifdef QCA_HOST2FW_RXBUF_RING
  34. #define DP_WBM2SW_RBM HAL_RX_BUF_RBM_SW1_BM
  35. /**
  36. * For MCL cases, allocate as many RX descriptors as buffers in the SW2RXDMA
  37. * ring. This value may need to be tuned later.
  38. */
  39. #define DP_RX_DESC_ALLOC_MULTIPLIER 1
  40. #else
  41. #define DP_WBM2SW_RBM HAL_RX_BUF_RBM_SW3_BM
  42. /**
  43. * AP use cases need to allocate more RX Descriptors than the number of
  44. * entries avaialable in the SW2RXDMA buffer replenish ring. This is to account
  45. * for frames sitting in REO queues, HW-HW DMA rings etc. Hence using a
  46. * multiplication factor of 3, to allocate three times as many RX descriptors
  47. * as RX buffers.
  48. */
  49. #define DP_RX_DESC_ALLOC_MULTIPLIER 3
  50. #endif /* QCA_HOST2FW_RXBUF_RING */
  51. #define RX_BUFFER_RESERVATION 0
  52. #define DP_PEER_METADATA_PEER_ID_MASK 0x0000ffff
  53. #define DP_PEER_METADATA_PEER_ID_SHIFT 0
  54. #define DP_PEER_METADATA_VDEV_ID_MASK 0x00070000
  55. #define DP_PEER_METADATA_VDEV_ID_SHIFT 16
  56. #define DP_PEER_METADATA_PEER_ID_GET(_peer_metadata) \
  57. (((_peer_metadata) & DP_PEER_METADATA_PEER_ID_MASK) \
  58. >> DP_PEER_METADATA_PEER_ID_SHIFT)
  59. #define DP_PEER_METADATA_ID_GET(_peer_metadata) \
  60. (((_peer_metadata) & DP_PEER_METADATA_VDEV_ID_MASK) \
  61. >> DP_PEER_METADATA_VDEV_ID_SHIFT)
  62. #define DP_RX_DESC_MAGIC 0xdec0de
  63. /**
  64. * struct dp_rx_desc
  65. *
  66. * @nbuf : VA of the "skb" posted
  67. * @rx_buf_start : VA of the original Rx buffer, before
  68. * movement of any skb->data pointer
  69. * @cookie : index into the sw array which holds
  70. * the sw Rx descriptors
  71. * Cookie space is 21 bits:
  72. * lower 18 bits -- index
  73. * upper 3 bits -- pool_id
  74. * @pool_id : pool Id for which this allocated.
  75. * Can only be used if there is no flow
  76. * steering
  77. * @in_use rx_desc is in use
  78. * @unmapped used to mark rx_desc an unmapped if the corresponding
  79. * nbuf is already unmapped
  80. */
  81. struct dp_rx_desc {
  82. qdf_nbuf_t nbuf;
  83. uint8_t *rx_buf_start;
  84. uint32_t cookie;
  85. uint8_t pool_id;
  86. #ifdef RX_DESC_DEBUG_CHECK
  87. uint32_t magic;
  88. #endif
  89. uint8_t in_use:1,
  90. unmapped:1;
  91. };
  92. /* RX Descriptor Multi Page memory alloc related */
  93. #define DP_RX_DESC_OFFSET_NUM_BITS 8
  94. #define DP_RX_DESC_PAGE_ID_NUM_BITS 8
  95. #define DP_RX_DESC_POOL_ID_NUM_BITS 4
  96. #define DP_RX_DESC_PAGE_ID_SHIFT DP_RX_DESC_OFFSET_NUM_BITS
  97. #define DP_RX_DESC_POOL_ID_SHIFT \
  98. (DP_RX_DESC_OFFSET_NUM_BITS + DP_RX_DESC_PAGE_ID_NUM_BITS)
  99. #define RX_DESC_MULTI_PAGE_COOKIE_POOL_ID_MASK \
  100. (((1 << DP_RX_DESC_POOL_ID_NUM_BITS) - 1) << DP_RX_DESC_POOL_ID_SHIFT)
  101. #define RX_DESC_MULTI_PAGE_COOKIE_PAGE_ID_MASK \
  102. (((1 << DP_RX_DESC_PAGE_ID_NUM_BITS) - 1) << \
  103. DP_RX_DESC_PAGE_ID_SHIFT)
  104. #define RX_DESC_MULTI_PAGE_COOKIE_OFFSET_MASK \
  105. ((1 << DP_RX_DESC_OFFSET_NUM_BITS) - 1)
  106. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(_cookie) \
  107. (((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_POOL_ID_MASK) >> \
  108. DP_RX_DESC_POOL_ID_SHIFT)
  109. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(_cookie) \
  110. (((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_PAGE_ID_MASK) >> \
  111. DP_RX_DESC_PAGE_ID_SHIFT)
  112. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(_cookie) \
  113. ((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_OFFSET_MASK)
  114. #define RX_DESC_COOKIE_INDEX_SHIFT 0
  115. #define RX_DESC_COOKIE_INDEX_MASK 0x3ffff /* 18 bits */
  116. #define RX_DESC_COOKIE_POOL_ID_SHIFT 18
  117. #define RX_DESC_COOKIE_POOL_ID_MASK 0x1c0000
  118. #define DP_RX_DESC_COOKIE_MAX \
  119. (RX_DESC_COOKIE_INDEX_MASK | RX_DESC_COOKIE_POOL_ID_MASK)
  120. #define DP_RX_DESC_COOKIE_POOL_ID_GET(_cookie) \
  121. (((_cookie) & RX_DESC_COOKIE_POOL_ID_MASK) >> \
  122. RX_DESC_COOKIE_POOL_ID_SHIFT)
  123. #define DP_RX_DESC_COOKIE_INDEX_GET(_cookie) \
  124. (((_cookie) & RX_DESC_COOKIE_INDEX_MASK) >> \
  125. RX_DESC_COOKIE_INDEX_SHIFT)
  126. /* DOC: Offset to obtain LLC hdr
  127. *
  128. * In the case of Wifi parse error
  129. * to reach LLC header from beginning
  130. * of VLAN tag we need to skip 8 bytes.
  131. * Vlan_tag(4)+length(2)+length added
  132. * by HW(2) = 8 bytes.
  133. */
  134. #define DP_SKIP_VLAN 8
  135. /**
  136. * struct dp_rx_cached_buf - rx cached buffer
  137. * @list: linked list node
  138. * @buf: skb buffer
  139. */
  140. struct dp_rx_cached_buf {
  141. qdf_list_node_t node;
  142. qdf_nbuf_t buf;
  143. };
  144. /*
  145. *dp_rx_xor_block() - xor block of data
  146. *@b: destination data block
  147. *@a: source data block
  148. *@len: length of the data to process
  149. *
  150. *Returns: None
  151. */
  152. static inline void dp_rx_xor_block(uint8_t *b, const uint8_t *a, qdf_size_t len)
  153. {
  154. qdf_size_t i;
  155. for (i = 0; i < len; i++)
  156. b[i] ^= a[i];
  157. }
  158. /*
  159. *dp_rx_rotl() - rotate the bits left
  160. *@val: unsigned integer input value
  161. *@bits: number of bits
  162. *
  163. *Returns: Integer with left rotated by number of 'bits'
  164. */
  165. static inline uint32_t dp_rx_rotl(uint32_t val, int bits)
  166. {
  167. return (val << bits) | (val >> (32 - bits));
  168. }
  169. /*
  170. *dp_rx_rotr() - rotate the bits right
  171. *@val: unsigned integer input value
  172. *@bits: number of bits
  173. *
  174. *Returns: Integer with right rotated by number of 'bits'
  175. */
  176. static inline uint32_t dp_rx_rotr(uint32_t val, int bits)
  177. {
  178. return (val >> bits) | (val << (32 - bits));
  179. }
  180. /*
  181. * dp_set_rx_queue() - set queue_mapping in skb
  182. * @nbuf: skb
  183. * @queue_id: rx queue_id
  184. *
  185. * Return: void
  186. */
  187. #ifdef QCA_OL_RX_MULTIQ_SUPPORT
  188. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  189. {
  190. qdf_nbuf_record_rx_queue(nbuf, queue_id);
  191. return;
  192. }
  193. #else
  194. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  195. {
  196. }
  197. #endif
  198. /*
  199. *dp_rx_xswap() - swap the bits left
  200. *@val: unsigned integer input value
  201. *
  202. *Returns: Integer with bits swapped
  203. */
  204. static inline uint32_t dp_rx_xswap(uint32_t val)
  205. {
  206. return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
  207. }
  208. /*
  209. *dp_rx_get_le32_split() - get little endian 32 bits split
  210. *@b0: byte 0
  211. *@b1: byte 1
  212. *@b2: byte 2
  213. *@b3: byte 3
  214. *
  215. *Returns: Integer with split little endian 32 bits
  216. */
  217. static inline uint32_t dp_rx_get_le32_split(uint8_t b0, uint8_t b1, uint8_t b2,
  218. uint8_t b3)
  219. {
  220. return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
  221. }
  222. /*
  223. *dp_rx_get_le32() - get little endian 32 bits
  224. *@b0: byte 0
  225. *@b1: byte 1
  226. *@b2: byte 2
  227. *@b3: byte 3
  228. *
  229. *Returns: Integer with little endian 32 bits
  230. */
  231. static inline uint32_t dp_rx_get_le32(const uint8_t *p)
  232. {
  233. return dp_rx_get_le32_split(p[0], p[1], p[2], p[3]);
  234. }
  235. /*
  236. * dp_rx_put_le32() - put little endian 32 bits
  237. * @p: destination char array
  238. * @v: source 32-bit integer
  239. *
  240. * Returns: None
  241. */
  242. static inline void dp_rx_put_le32(uint8_t *p, uint32_t v)
  243. {
  244. p[0] = (v) & 0xff;
  245. p[1] = (v >> 8) & 0xff;
  246. p[2] = (v >> 16) & 0xff;
  247. p[3] = (v >> 24) & 0xff;
  248. }
  249. /* Extract michal mic block of data */
  250. #define dp_rx_michael_block(l, r) \
  251. do { \
  252. r ^= dp_rx_rotl(l, 17); \
  253. l += r; \
  254. r ^= dp_rx_xswap(l); \
  255. l += r; \
  256. r ^= dp_rx_rotl(l, 3); \
  257. l += r; \
  258. r ^= dp_rx_rotr(l, 2); \
  259. l += r; \
  260. } while (0)
  261. /**
  262. * struct dp_rx_desc_list_elem_t
  263. *
  264. * @next : Next pointer to form free list
  265. * @rx_desc : DP Rx descriptor
  266. */
  267. union dp_rx_desc_list_elem_t {
  268. union dp_rx_desc_list_elem_t *next;
  269. struct dp_rx_desc rx_desc;
  270. };
  271. #ifdef RX_DESC_MULTI_PAGE_ALLOC
  272. /**
  273. * dp_rx_desc_find() - find dp rx descriptor from page ID and offset
  274. * @page_id: Page ID
  275. * @offset: Offset of the descriptor element
  276. *
  277. * Return: RX descriptor element
  278. */
  279. union dp_rx_desc_list_elem_t *dp_rx_desc_find(uint16_t page_id, uint16_t offset,
  280. struct rx_desc_pool *rx_pool);
  281. static inline
  282. struct dp_rx_desc *dp_get_rx_desc_from_cookie(struct dp_soc *soc,
  283. struct rx_desc_pool *pool,
  284. uint32_t cookie)
  285. {
  286. uint8_t pool_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(cookie);
  287. uint16_t page_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(cookie);
  288. uint8_t offset = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(cookie);
  289. struct rx_desc_pool *rx_desc_pool;
  290. union dp_rx_desc_list_elem_t *rx_desc_elem;
  291. if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS))
  292. return NULL;
  293. rx_desc_pool = &pool[pool_id];
  294. rx_desc_elem = (union dp_rx_desc_list_elem_t *)
  295. (rx_desc_pool->desc_pages.cacheable_pages[page_id] +
  296. rx_desc_pool->elem_size * offset);
  297. return &rx_desc_elem->rx_desc;
  298. }
  299. /**
  300. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  301. * the Rx descriptor on Rx DMA source ring buffer
  302. * @soc: core txrx main context
  303. * @cookie: cookie used to lookup virtual address
  304. *
  305. * Return: Pointer to the Rx descriptor
  306. */
  307. static inline
  308. struct dp_rx_desc *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc,
  309. uint32_t cookie)
  310. {
  311. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_buf[0], cookie);
  312. }
  313. /**
  314. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  315. * the Rx descriptor on monitor ring buffer
  316. * @soc: core txrx main context
  317. * @cookie: cookie used to lookup virtual address
  318. *
  319. * Return: Pointer to the Rx descriptor
  320. */
  321. static inline
  322. struct dp_rx_desc *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc,
  323. uint32_t cookie)
  324. {
  325. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_mon[0], cookie);
  326. }
  327. /**
  328. * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of
  329. * the Rx descriptor on monitor status ring buffer
  330. * @soc: core txrx main context
  331. * @cookie: cookie used to lookup virtual address
  332. *
  333. * Return: Pointer to the Rx descriptor
  334. */
  335. static inline
  336. struct dp_rx_desc *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc,
  337. uint32_t cookie)
  338. {
  339. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_status[0], cookie);
  340. }
  341. #else
  342. /**
  343. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  344. * the Rx descriptor on Rx DMA source ring buffer
  345. * @soc: core txrx main context
  346. * @cookie: cookie used to lookup virtual address
  347. *
  348. * Return: void *: Virtual Address of the Rx descriptor
  349. */
  350. static inline
  351. void *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc, uint32_t cookie)
  352. {
  353. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  354. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  355. struct rx_desc_pool *rx_desc_pool;
  356. if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS))
  357. return NULL;
  358. rx_desc_pool = &soc->rx_desc_buf[pool_id];
  359. if (qdf_unlikely(index >= rx_desc_pool->pool_size))
  360. return NULL;
  361. return &(soc->rx_desc_buf[pool_id].array[index].rx_desc);
  362. }
  363. /**
  364. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  365. * the Rx descriptor on monitor ring buffer
  366. * @soc: core txrx main context
  367. * @cookie: cookie used to lookup virtual address
  368. *
  369. * Return: void *: Virtual Address of the Rx descriptor
  370. */
  371. static inline
  372. void *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc, uint32_t cookie)
  373. {
  374. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  375. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  376. /* TODO */
  377. /* Add sanity for pool_id & index */
  378. return &(soc->rx_desc_mon[pool_id].array[index].rx_desc);
  379. }
  380. /**
  381. * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of
  382. * the Rx descriptor on monitor status ring buffer
  383. * @soc: core txrx main context
  384. * @cookie: cookie used to lookup virtual address
  385. *
  386. * Return: void *: Virtual Address of the Rx descriptor
  387. */
  388. static inline
  389. void *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc, uint32_t cookie)
  390. {
  391. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  392. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  393. /* TODO */
  394. /* Add sanity for pool_id & index */
  395. return &(soc->rx_desc_status[pool_id].array[index].rx_desc);
  396. }
  397. #endif /* RX_DESC_MULTI_PAGE_ALLOC */
  398. void dp_rx_add_desc_list_to_free_list(struct dp_soc *soc,
  399. union dp_rx_desc_list_elem_t **local_desc_list,
  400. union dp_rx_desc_list_elem_t **tail,
  401. uint16_t pool_id,
  402. struct rx_desc_pool *rx_desc_pool);
  403. uint16_t dp_rx_get_free_desc_list(struct dp_soc *soc, uint32_t pool_id,
  404. struct rx_desc_pool *rx_desc_pool,
  405. uint16_t num_descs,
  406. union dp_rx_desc_list_elem_t **desc_list,
  407. union dp_rx_desc_list_elem_t **tail);
  408. QDF_STATUS dp_rx_pdev_attach(struct dp_pdev *pdev);
  409. void dp_rx_pdev_detach(struct dp_pdev *pdev);
  410. uint32_t
  411. dp_rx_process(struct dp_intr *int_ctx, void *hal_ring, uint8_t reo_ring_num,
  412. uint32_t quota);
  413. uint32_t dp_rx_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota);
  414. uint32_t
  415. dp_rx_wbm_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota);
  416. /**
  417. * dp_rx_sg_create() - create a frag_list for MSDUs which are spread across
  418. * multiple nbufs.
  419. * @nbuf: pointer to the first msdu of an amsdu.
  420. * @rx_tlv_hdr: pointer to the start of RX TLV headers.
  421. *
  422. * This function implements the creation of RX frag_list for cases
  423. * where an MSDU is spread across multiple nbufs.
  424. *
  425. * Return: returns the head nbuf which contains complete frag_list.
  426. */
  427. qdf_nbuf_t dp_rx_sg_create(qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr);
  428. /*
  429. * dp_rx_desc_pool_alloc() - create a pool of software rx_descs
  430. * at the time of dp rx initialization
  431. *
  432. * @soc: core txrx main context
  433. * @pool_id: pool_id which is one of 3 mac_ids
  434. * @pool_size: number of Rx descriptor in the pool
  435. * @rx_desc_pool: rx descriptor pool pointer
  436. *
  437. * Return: QDF status
  438. */
  439. QDF_STATUS dp_rx_desc_pool_alloc(struct dp_soc *soc, uint32_t pool_id,
  440. uint32_t pool_size, struct rx_desc_pool *pool);
  441. /*
  442. * dp_rx_desc_nbuf_and_pool_free() - free the sw rx desc pool called during
  443. * de-initialization of wifi module.
  444. *
  445. * @soc: core txrx main context
  446. * @pool_id: pool_id which is one of 3 mac_ids
  447. * @rx_desc_pool: rx descriptor pool pointer
  448. *
  449. * Return: None
  450. */
  451. void dp_rx_desc_nbuf_and_pool_free(struct dp_soc *soc, uint32_t pool_id,
  452. struct rx_desc_pool *rx_desc_pool);
  453. /*
  454. * dp_rx_desc_nbuf_free() - free the sw rx desc nbufs called during
  455. * de-initialization of wifi module.
  456. *
  457. * @soc: core txrx main context
  458. * @pool_id: pool_id which is one of 3 mac_ids
  459. * @rx_desc_pool: rx descriptor pool pointer
  460. *
  461. * Return: None
  462. */
  463. void dp_rx_desc_nbuf_free(struct dp_soc *soc,
  464. struct rx_desc_pool *rx_desc_pool);
  465. /*
  466. * dp_rx_desc_pool_free() - free the sw rx desc array called during
  467. * de-initialization of wifi module.
  468. *
  469. * @soc: core txrx main context
  470. * @rx_desc_pool: rx descriptor pool pointer
  471. *
  472. * Return: None
  473. */
  474. void dp_rx_desc_pool_free(struct dp_soc *soc,
  475. struct rx_desc_pool *rx_desc_pool);
  476. void dp_rx_deliver_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf_list,
  477. struct dp_peer *peer);
  478. /**
  479. * dp_rx_add_to_free_desc_list() - Adds to a local free descriptor list
  480. *
  481. * @head: pointer to the head of local free list
  482. * @tail: pointer to the tail of local free list
  483. * @new: new descriptor that is added to the free list
  484. *
  485. * Return: void:
  486. */
  487. static inline
  488. void dp_rx_add_to_free_desc_list(union dp_rx_desc_list_elem_t **head,
  489. union dp_rx_desc_list_elem_t **tail,
  490. struct dp_rx_desc *new)
  491. {
  492. qdf_assert(head && new);
  493. new->nbuf = NULL;
  494. new->in_use = 0;
  495. ((union dp_rx_desc_list_elem_t *)new)->next = *head;
  496. *head = (union dp_rx_desc_list_elem_t *)new;
  497. if (!*tail)
  498. *tail = *head;
  499. }
  500. uint8_t dp_rx_process_invalid_peer(struct dp_soc *soc, qdf_nbuf_t nbuf);
  501. void dp_rx_process_invalid_peer_wrapper(struct dp_soc *soc,
  502. qdf_nbuf_t mpdu, bool mpdu_done);
  503. void dp_rx_process_mic_error(struct dp_soc *soc, qdf_nbuf_t nbuf,
  504. uint8_t *rx_tlv_hdr, struct dp_peer *peer);
  505. void dp_2k_jump_handle(struct dp_soc *soc, qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  506. uint16_t peer_id, uint8_t tid);
  507. #define DP_RX_LIST_APPEND(head, tail, elem) \
  508. do { \
  509. if (!(head)) { \
  510. (head) = (elem); \
  511. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head) = 1;\
  512. } else { \
  513. qdf_nbuf_set_next((tail), (elem)); \
  514. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head)++; \
  515. } \
  516. (tail) = (elem); \
  517. qdf_nbuf_set_next((tail), NULL); \
  518. } while (0)
  519. #ifndef BUILD_X86
  520. static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf,
  521. qdf_dma_addr_t *paddr, struct dp_pdev *pdev)
  522. {
  523. return QDF_STATUS_SUCCESS;
  524. }
  525. #else
  526. #define MAX_RETRY 100
  527. static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf,
  528. qdf_dma_addr_t *paddr, struct dp_pdev *pdev)
  529. {
  530. uint32_t nbuf_retry = 0;
  531. int32_t ret;
  532. const uint32_t x86_phy_addr = 0x50000000;
  533. /*
  534. * in M2M emulation platforms (x86) the memory below 0x50000000
  535. * is reserved for target use, so any memory allocated in this
  536. * region should not be used by host
  537. */
  538. do {
  539. if (qdf_likely(*paddr > x86_phy_addr))
  540. return QDF_STATUS_SUCCESS;
  541. else {
  542. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  543. "phy addr %pK exceeded 0x50000000 trying again",
  544. paddr);
  545. nbuf_retry++;
  546. if ((*rx_netbuf)) {
  547. qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf,
  548. QDF_DMA_FROM_DEVICE);
  549. /* Not freeing buffer intentionally.
  550. * Observed that same buffer is getting
  551. * re-allocated resulting in longer load time
  552. * WMI init timeout.
  553. * This buffer is anyway not useful so skip it.
  554. **/
  555. }
  556. *rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev,
  557. RX_BUFFER_SIZE,
  558. RX_BUFFER_RESERVATION,
  559. RX_BUFFER_ALIGNMENT,
  560. FALSE);
  561. if (qdf_unlikely(!(*rx_netbuf)))
  562. return QDF_STATUS_E_FAILURE;
  563. ret = qdf_nbuf_map_single(dp_soc->osdev, *rx_netbuf,
  564. QDF_DMA_FROM_DEVICE);
  565. if (qdf_unlikely(ret == QDF_STATUS_E_FAILURE)) {
  566. qdf_nbuf_free(*rx_netbuf);
  567. *rx_netbuf = NULL;
  568. continue;
  569. }
  570. *paddr = qdf_nbuf_get_frag_paddr(*rx_netbuf, 0);
  571. }
  572. } while (nbuf_retry < MAX_RETRY);
  573. if ((*rx_netbuf)) {
  574. qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf,
  575. QDF_DMA_FROM_DEVICE);
  576. qdf_nbuf_free(*rx_netbuf);
  577. }
  578. return QDF_STATUS_E_FAILURE;
  579. }
  580. #endif
  581. /**
  582. * dp_rx_cookie_2_link_desc_va() - Converts cookie to a virtual address of
  583. * the MSDU Link Descriptor
  584. * @soc: core txrx main context
  585. * @buf_info: buf_info include cookie that used to lookup virtual address of
  586. * link descriptor Normally this is just an index into a per SOC array.
  587. *
  588. * This is the VA of the link descriptor, that HAL layer later uses to
  589. * retrieve the list of MSDU's for a given MPDU.
  590. *
  591. * Return: void *: Virtual Address of the Rx descriptor
  592. */
  593. static inline
  594. void *dp_rx_cookie_2_link_desc_va(struct dp_soc *soc,
  595. struct hal_buf_info *buf_info)
  596. {
  597. void *link_desc_va;
  598. uint32_t bank_id = LINK_DESC_COOKIE_BANK_ID(buf_info->sw_cookie);
  599. /* TODO */
  600. /* Add sanity for cookie */
  601. link_desc_va = soc->link_desc_banks[bank_id].base_vaddr +
  602. (buf_info->paddr -
  603. soc->link_desc_banks[bank_id].base_paddr);
  604. return link_desc_va;
  605. }
  606. /**
  607. * dp_rx_cookie_2_mon_link_desc_va() - Converts cookie to a virtual address of
  608. * the MSDU Link Descriptor
  609. * @pdev: core txrx pdev context
  610. * @buf_info: buf_info includes cookie that used to lookup virtual address of
  611. * link descriptor. Normally this is just an index into a per pdev array.
  612. *
  613. * This is the VA of the link descriptor in monitor mode destination ring,
  614. * that HAL layer later uses to retrieve the list of MSDU's for a given MPDU.
  615. *
  616. * Return: void *: Virtual Address of the Rx descriptor
  617. */
  618. static inline
  619. void *dp_rx_cookie_2_mon_link_desc_va(struct dp_pdev *pdev,
  620. struct hal_buf_info *buf_info,
  621. int mac_id)
  622. {
  623. void *link_desc_va;
  624. int mac_for_pdev = dp_get_mac_id_for_mac(pdev->soc, mac_id);
  625. /* TODO */
  626. /* Add sanity for cookie */
  627. link_desc_va =
  628. pdev->link_desc_banks[mac_for_pdev][buf_info->sw_cookie].base_vaddr +
  629. (buf_info->paddr -
  630. pdev->link_desc_banks[mac_for_pdev][buf_info->sw_cookie].base_paddr);
  631. return link_desc_va;
  632. }
  633. /**
  634. * dp_rx_defrag_concat() - Concatenate the fragments
  635. *
  636. * @dst: destination pointer to the buffer
  637. * @src: source pointer from where the fragment payload is to be copied
  638. *
  639. * Return: QDF_STATUS
  640. */
  641. static inline QDF_STATUS dp_rx_defrag_concat(qdf_nbuf_t dst, qdf_nbuf_t src)
  642. {
  643. /*
  644. * Inside qdf_nbuf_cat, if it is necessary to reallocate dst
  645. * to provide space for src, the headroom portion is copied from
  646. * the original dst buffer to the larger new dst buffer.
  647. * (This is needed, because the headroom of the dst buffer
  648. * contains the rx desc.)
  649. */
  650. if (!qdf_nbuf_cat(dst, src)) {
  651. /*
  652. * qdf_nbuf_cat does not free the src memory.
  653. * Free src nbuf before returning
  654. * For failure case the caller takes of freeing the nbuf
  655. */
  656. qdf_nbuf_free(src);
  657. return QDF_STATUS_SUCCESS;
  658. }
  659. return QDF_STATUS_E_DEFRAG_ERROR;
  660. }
  661. #ifndef FEATURE_WDS
  662. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
  663. {
  664. return QDF_STATUS_SUCCESS;
  665. }
  666. static inline void
  667. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  668. uint8_t *rx_tlv_hdr,
  669. struct dp_peer *ta_peer,
  670. qdf_nbuf_t nbuf)
  671. {
  672. }
  673. #endif
  674. /*
  675. * dp_rx_desc_dump() - dump the sw rx descriptor
  676. *
  677. * @rx_desc: sw rx descriptor
  678. */
  679. static inline void dp_rx_desc_dump(struct dp_rx_desc *rx_desc)
  680. {
  681. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  682. "rx_desc->nbuf: %pK, rx_desc->cookie: %d, rx_desc->pool_id: %d, rx_desc->in_use: %d, rx_desc->unmapped: %d",
  683. rx_desc->nbuf, rx_desc->cookie, rx_desc->pool_id,
  684. rx_desc->in_use, rx_desc->unmapped);
  685. }
  686. /*
  687. * check_qwrap_multicast_loopback() - Check if rx packet is a loopback packet.
  688. * In qwrap mode, packets originated from
  689. * any vdev should not loopback and
  690. * should be dropped.
  691. * @vdev: vdev on which rx packet is received
  692. * @nbuf: rx pkt
  693. *
  694. */
  695. #if ATH_SUPPORT_WRAP
  696. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  697. qdf_nbuf_t nbuf)
  698. {
  699. struct dp_vdev *psta_vdev;
  700. struct dp_pdev *pdev = vdev->pdev;
  701. uint8_t *data = qdf_nbuf_data(nbuf);
  702. if (qdf_unlikely(vdev->proxysta_vdev)) {
  703. /* In qwrap isolation mode, allow loopback packets as all
  704. * packets go to RootAP and Loopback on the mpsta.
  705. */
  706. if (vdev->isolation_vdev)
  707. return false;
  708. TAILQ_FOREACH(psta_vdev, &pdev->vdev_list, vdev_list_elem) {
  709. if (qdf_unlikely(psta_vdev->proxysta_vdev &&
  710. !qdf_mem_cmp(psta_vdev->mac_addr.raw,
  711. &data[QDF_MAC_ADDR_SIZE],
  712. QDF_MAC_ADDR_SIZE))) {
  713. /* Drop packet if source address is equal to
  714. * any of the vdev addresses.
  715. */
  716. return true;
  717. }
  718. }
  719. }
  720. return false;
  721. }
  722. #else
  723. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  724. qdf_nbuf_t nbuf)
  725. {
  726. return false;
  727. }
  728. #endif
  729. #if defined(WLAN_SUPPORT_RX_TAG_STATISTICS) && \
  730. defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG)
  731. /**
  732. * dp_rx_update_rx_protocol_tag_stats() - Increments the protocol tag stats
  733. * for the given protocol type
  734. * @soc: core txrx main context
  735. * @pdev: TXRX pdev context for which stats should be incremented
  736. * @protocol_index: Protocol index for which the stats should be incremented
  737. * @ring_index: REO ring number from which this tag was received.
  738. *
  739. * Since HKv2 is a SMP, two or more cores may simultaneously receive packets
  740. * of same type, and hence attempt to increment counters for the same protocol
  741. * type at the same time. This creates the possibility of missing stats.
  742. *
  743. * For example, when two or more CPUs have each read the old tag value, V,
  744. * for protocol type, P and each increment the value to V+1. Instead, the
  745. * operations should have been sequenced to achieve a final value of V+2.
  746. *
  747. * In order to avoid this scenario, we can either use locks or store stats
  748. * on a per-CPU basis. Since tagging happens in the core data path, locks
  749. * are not preferred. Instead, we use a per-ring counter, since each CPU
  750. * operates on a REO ring.
  751. *
  752. * Return: void
  753. */
  754. static inline void dp_rx_update_rx_protocol_tag_stats(struct dp_pdev *pdev,
  755. uint16_t protocol_index,
  756. uint16_t ring_index)
  757. {
  758. if (ring_index >= MAX_REO_DEST_RINGS)
  759. return;
  760. pdev->reo_proto_tag_stats[ring_index][protocol_index].tag_ctr++;
  761. }
  762. #else
  763. static inline void dp_rx_update_rx_protocol_tag_stats(struct dp_pdev *pdev,
  764. uint16_t protocol_index,
  765. uint16_t ring_index)
  766. {
  767. }
  768. #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
  769. #if defined(WLAN_SUPPORT_RX_TAG_STATISTICS) && \
  770. defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG)
  771. /**
  772. * dp_rx_update_rx_err_protocol_tag_stats() - Increments the protocol tag stats
  773. * for the given protocol type
  774. * received from exception ring
  775. * @soc: core txrx main context
  776. * @pdev: TXRX pdev context for which stats should be incremented
  777. * @protocol_index: Protocol index for which the stats should be incremented
  778. *
  779. * In HKv2, all exception packets are received on Ring-0 (along with normal
  780. * Rx). Hence tags are maintained separately for exception ring as well.
  781. *
  782. * Return: void
  783. */
  784. static inline
  785. void dp_rx_update_rx_err_protocol_tag_stats(struct dp_pdev *pdev,
  786. uint16_t protocol_index)
  787. {
  788. pdev->rx_err_proto_tag_stats[protocol_index].tag_ctr++;
  789. }
  790. #else
  791. static inline
  792. void dp_rx_update_rx_err_protocol_tag_stats(struct dp_pdev *pdev,
  793. uint16_t protocol_index)
  794. {
  795. }
  796. #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
  797. /**
  798. * dp_rx_update_protocol_tag() - Reads CCE metadata from the RX MSDU end TLV
  799. * and set the corresponding tag in QDF packet
  800. * @soc: core txrx main context
  801. * @vdev: vdev on which the packet is received
  802. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  803. * @rx_tlv_hdr: rBbase address where the RX TLVs starts
  804. * @ring_index: REO ring number, not used for error & monitor ring
  805. * @is_reo_exception: flag to indicate if rx from REO ring or exception ring
  806. * @is_update_stats: flag to indicate whether to update stats or not
  807. * Return: void
  808. */
  809. #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  810. static inline void
  811. dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  812. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  813. uint16_t ring_index,
  814. bool is_reo_exception, bool is_update_stats)
  815. {
  816. uint16_t cce_metadata = RX_PROTOCOL_TAG_START_OFFSET;
  817. bool cce_match = false;
  818. struct dp_pdev *pdev;
  819. uint16_t protocol_tag = 0;
  820. if (qdf_unlikely(!vdev))
  821. return;
  822. pdev = vdev->pdev;
  823. if (qdf_likely(!pdev->is_rx_protocol_tagging_enabled))
  824. return;
  825. /*
  826. * In case of raw frames, rx_attention and rx_msdu_end tlv
  827. * may be stale or invalid. Do not tag such frames.
  828. * Default decap_type is set to ethernet for monitor vdev,
  829. * therefore, cannot check decap_type for monitor mode.
  830. * We will call this only for eth frames from dp_rx_mon_dest.c.
  831. */
  832. if (qdf_likely(!(pdev->monitor_vdev && pdev->monitor_vdev == vdev) &&
  833. (vdev->rx_decap_type != htt_cmn_pkt_type_ethernet)))
  834. return;
  835. /*
  836. * Check whether HW has filled in the CCE metadata in
  837. * this packet, if not filled, just return
  838. */
  839. if (qdf_likely(!hal_rx_msdu_cce_match_get(rx_tlv_hdr)))
  840. return;
  841. cce_match = true;
  842. /* Get the cce_metadata from RX MSDU TLV */
  843. cce_metadata = (hal_rx_msdu_cce_metadata_get(rx_tlv_hdr) &
  844. RX_MSDU_END_16_CCE_METADATA_MASK);
  845. /*
  846. * Received CCE metadata should be within the
  847. * valid limits
  848. */
  849. qdf_assert_always((cce_metadata >= RX_PROTOCOL_TAG_START_OFFSET) &&
  850. (cce_metadata < (RX_PROTOCOL_TAG_START_OFFSET +
  851. RX_PROTOCOL_TAG_MAX)));
  852. /*
  853. * The CCE metadata received is just the
  854. * packet_type + RX_PROTOCOL_TAG_START_OFFSET
  855. */
  856. cce_metadata -= RX_PROTOCOL_TAG_START_OFFSET;
  857. /*
  858. * Update the QDF packet with the user-specified
  859. * tag/metadata by looking up tag value for
  860. * received protocol type.
  861. */
  862. protocol_tag = pdev->rx_proto_tag_map[cce_metadata].tag;
  863. qdf_nbuf_set_rx_protocol_tag(nbuf, protocol_tag);
  864. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
  865. "Seq:%u decap:%u CCE Match:%d ProtoID:%u Tag:%u US:%d",
  866. hal_rx_get_rx_sequence(rx_tlv_hdr),
  867. vdev->rx_decap_type, cce_match, cce_metadata,
  868. protocol_tag, is_update_stats);
  869. if (qdf_likely(!is_update_stats))
  870. return;
  871. if (qdf_unlikely(is_reo_exception)) {
  872. dp_rx_update_rx_err_protocol_tag_stats(pdev,
  873. cce_metadata);
  874. } else {
  875. dp_rx_update_rx_protocol_tag_stats(pdev,
  876. cce_metadata,
  877. ring_index);
  878. }
  879. }
  880. #else
  881. static inline void
  882. dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  883. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  884. uint16_t ring_index,
  885. bool is_reo_exception, bool is_update_stats)
  886. {
  887. /* Stub API */
  888. }
  889. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  890. /**
  891. * dp_rx_mon_update_protocol_tag() - Performs necessary checks for monitor mode
  892. * and then tags appropriate packets
  893. * @soc: core txrx main context
  894. * @vdev: pdev on which packet is received
  895. * @msdu: QDF packet buffer on which the protocol tag should be set
  896. * @rx_desc: base address where the RX TLVs start
  897. * Return: void
  898. */
  899. #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  900. static inline
  901. void dp_rx_mon_update_protocol_tag(struct dp_soc *soc, struct dp_pdev *dp_pdev,
  902. qdf_nbuf_t msdu, void *rx_desc)
  903. {
  904. uint32_t msdu_ppdu_id = 0;
  905. struct mon_rx_status *mon_recv_status;
  906. if (qdf_likely(!dp_pdev->is_rx_protocol_tagging_enabled))
  907. return;
  908. if (qdf_likely(!dp_pdev->monitor_vdev))
  909. return;
  910. if (qdf_likely(1 != dp_pdev->ppdu_info.rx_status.rxpcu_filter_pass))
  911. return;
  912. msdu_ppdu_id = HAL_RX_HW_DESC_GET_PPDUID_GET(rx_desc);
  913. if (msdu_ppdu_id != dp_pdev->ppdu_info.com_info.ppdu_id) {
  914. QDF_TRACE(QDF_MODULE_ID_DP,
  915. QDF_TRACE_LEVEL_ERROR,
  916. "msdu_ppdu_id=%x,com_info.ppdu_id=%x",
  917. msdu_ppdu_id,
  918. dp_pdev->ppdu_info.com_info.ppdu_id);
  919. return;
  920. }
  921. /*
  922. * Update the protocol tag in SKB for packets received on BSS.
  923. * Do not update tag stats since it would double actual received count
  924. */
  925. mon_recv_status = &dp_pdev->ppdu_info.rx_status;
  926. if (mon_recv_status->frame_control_info_valid &&
  927. ((mon_recv_status->frame_control & IEEE80211_FC0_TYPE_MASK) ==
  928. IEEE80211_FC0_TYPE_DATA)) {
  929. dp_rx_update_protocol_tag(soc,
  930. dp_pdev->monitor_vdev,
  931. msdu, rx_desc,
  932. MAX_REO_DEST_RINGS,
  933. false, false);
  934. }
  935. }
  936. #else
  937. static inline
  938. void dp_rx_mon_update_protocol_tag(struct dp_soc *soc, struct dp_pdev *dp_pdev,
  939. qdf_nbuf_t msdu, void *rx_desc)
  940. {
  941. /* Stub API */
  942. }
  943. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  944. /*
  945. * dp_rx_buffers_replenish() - replenish rxdma ring with rx nbufs
  946. * called during dp rx initialization
  947. * and at the end of dp_rx_process.
  948. *
  949. * @soc: core txrx main context
  950. * @mac_id: mac_id which is one of 3 mac_ids
  951. * @dp_rxdma_srng: dp rxdma circular ring
  952. * @rx_desc_pool: Pointer to free Rx descriptor pool
  953. * @num_req_buffers: number of buffer to be replenished
  954. * @desc_list: list of descs if called from dp_rx_process
  955. * or NULL during dp rx initialization or out of buffer
  956. * interrupt.
  957. * @tail: tail of descs list
  958. * Return: return success or failure
  959. */
  960. QDF_STATUS dp_rx_buffers_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  961. struct dp_srng *dp_rxdma_srng,
  962. struct rx_desc_pool *rx_desc_pool,
  963. uint32_t num_req_buffers,
  964. union dp_rx_desc_list_elem_t **desc_list,
  965. union dp_rx_desc_list_elem_t **tail);
  966. /**
  967. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  968. * (WBM), following error handling
  969. *
  970. * @soc: core DP main context
  971. * @buf_addr_info: opaque pointer to the REO error ring descriptor
  972. * @buf_addr_info: void pointer to the buffer_addr_info
  973. * @bm_action: put to idle_list or release to msdu_list
  974. * Return: QDF_STATUS
  975. */
  976. QDF_STATUS
  977. dp_rx_link_desc_return(struct dp_soc *soc, void *ring_desc, uint8_t bm_action);
  978. QDF_STATUS
  979. dp_rx_link_desc_buf_return(struct dp_soc *soc, struct dp_srng *dp_rxdma_srng,
  980. void *buf_addr_info, uint8_t bm_action);
  981. /**
  982. * dp_rx_link_desc_return_by_addr - Return a MPDU link descriptor to
  983. * (WBM) by address
  984. *
  985. * @soc: core DP main context
  986. * @link_desc_addr: link descriptor addr
  987. *
  988. * Return: QDF_STATUS
  989. */
  990. QDF_STATUS
  991. dp_rx_link_desc_return_by_addr(struct dp_soc *soc, void *link_desc_addr,
  992. uint8_t bm_action);
  993. uint32_t
  994. dp_rxdma_err_process(struct dp_soc *soc, uint32_t mac_id,
  995. uint32_t quota);
  996. void dp_rx_fill_mesh_stats(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  997. uint8_t *rx_tlv_hdr, struct dp_peer *peer);
  998. QDF_STATUS dp_rx_filter_mesh_packets(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  999. uint8_t *rx_tlv_hdr);
  1000. int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr, struct dp_vdev *vdev,
  1001. struct dp_peer *peer);
  1002. qdf_nbuf_t
  1003. dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev);
  1004. void dp_rx_dump_info_and_assert(struct dp_soc *soc, void *hal_ring,
  1005. void *ring_desc, struct dp_rx_desc *rx_desc);
  1006. void dp_rx_compute_delay(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  1007. #ifdef RX_DESC_DEBUG_CHECK
  1008. /**
  1009. * dp_rx_desc_check_magic() - check the magic value in dp_rx_desc
  1010. * @rx_desc: rx descriptor pointer
  1011. *
  1012. * Return: true, if magic is correct, else false.
  1013. */
  1014. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1015. {
  1016. if (qdf_unlikely(rx_desc->magic != DP_RX_DESC_MAGIC))
  1017. return false;
  1018. rx_desc->magic = 0;
  1019. return true;
  1020. }
  1021. /**
  1022. * dp_rx_desc_prep() - prepare rx desc
  1023. * @rx_desc: rx descriptor pointer to be prepared
  1024. * @nbuf: nbuf to be associated with rx_desc
  1025. *
  1026. * Note: assumption is that we are associating a nbuf which is mapped
  1027. *
  1028. * Return: none
  1029. */
  1030. static inline void dp_rx_desc_prep(struct dp_rx_desc *rx_desc, qdf_nbuf_t nbuf)
  1031. {
  1032. rx_desc->magic = DP_RX_DESC_MAGIC;
  1033. rx_desc->nbuf = nbuf;
  1034. rx_desc->unmapped = 0;
  1035. }
  1036. #else
  1037. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1038. {
  1039. return true;
  1040. }
  1041. static inline void dp_rx_desc_prep(struct dp_rx_desc *rx_desc, qdf_nbuf_t nbuf)
  1042. {
  1043. rx_desc->nbuf = nbuf;
  1044. rx_desc->unmapped = 0;
  1045. }
  1046. #endif /* RX_DESC_DEBUG_CHECK */
  1047. void dp_rx_process_rxdma_err(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1048. uint8_t *rx_tlv_hdr, struct dp_peer *peer,
  1049. uint8_t err_code);
  1050. #ifdef PEER_CACHE_RX_PKTS
  1051. /**
  1052. * dp_rx_flush_rx_cached() - flush cached rx frames
  1053. * @peer: peer
  1054. * @drop: set flag to drop frames
  1055. *
  1056. * Return: None
  1057. */
  1058. void dp_rx_flush_rx_cached(struct dp_peer *peer, bool drop);
  1059. #else
  1060. static inline void dp_rx_flush_rx_cached(struct dp_peer *peer, bool drop)
  1061. {
  1062. }
  1063. #endif
  1064. #endif /* _DP_RX_H */