dp_rx.h 36 KB

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