dp_rx.h 36 KB

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