dp_rx.h 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636
  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. #define dp_rx_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_RX, params)
  56. #define dp_rx_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_RX, params)
  57. #define dp_rx_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_RX, params)
  58. #define dp_rx_info(params...) \
  59. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_RX, ## params)
  60. #define dp_rx_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_RX, params)
  61. /**
  62. * enum dp_rx_desc_state
  63. *
  64. * @RX_DESC_REPLENISH: rx desc replenished
  65. * @RX_DESC_FREELIST: rx desc in freelist
  66. */
  67. enum dp_rx_desc_state {
  68. RX_DESC_REPLENISHED,
  69. RX_DESC_IN_FREELIST,
  70. };
  71. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  72. /**
  73. * struct dp_rx_desc_dbg_info
  74. *
  75. * @freelist_caller: name of the function that put the
  76. * the rx desc in freelist
  77. * @freelist_ts: timestamp when the rx desc is put in
  78. * a freelist
  79. * @replenish_caller: name of the function that last
  80. * replenished the rx desc
  81. * @replenish_ts: last replenish timestamp
  82. * @prev_nbuf: previous nbuf info
  83. * @prev_nbuf_data_addr: previous nbuf data address
  84. */
  85. struct dp_rx_desc_dbg_info {
  86. char freelist_caller[QDF_MEM_FUNC_NAME_SIZE];
  87. uint64_t freelist_ts;
  88. char replenish_caller[QDF_MEM_FUNC_NAME_SIZE];
  89. uint64_t replenish_ts;
  90. qdf_nbuf_t prev_nbuf;
  91. uint8_t *prev_nbuf_data_addr;
  92. };
  93. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  94. /**
  95. * struct dp_rx_desc
  96. *
  97. * @nbuf : VA of the "skb" posted
  98. * @rx_buf_start : VA of the original Rx buffer, before
  99. * movement of any skb->data pointer
  100. * @paddr_buf_start : PA of the original Rx buffer, before
  101. * movement of any frag pointer
  102. * @cookie : index into the sw array which holds
  103. * the sw Rx descriptors
  104. * Cookie space is 21 bits:
  105. * lower 18 bits -- index
  106. * upper 3 bits -- pool_id
  107. * @pool_id : pool Id for which this allocated.
  108. * Can only be used if there is no flow
  109. * steering
  110. * @in_use rx_desc is in use
  111. * @unmapped used to mark rx_desc an unmapped if the corresponding
  112. * nbuf is already unmapped
  113. * @in_err_state : Nbuf sanity failed for this descriptor.
  114. * @nbuf_data_addr : VA of nbuf data posted
  115. */
  116. struct dp_rx_desc {
  117. qdf_nbuf_t nbuf;
  118. uint8_t *rx_buf_start;
  119. qdf_dma_addr_t paddr_buf_start;
  120. uint32_t cookie;
  121. uint8_t pool_id;
  122. #ifdef RX_DESC_DEBUG_CHECK
  123. uint32_t magic;
  124. uint8_t *nbuf_data_addr;
  125. struct dp_rx_desc_dbg_info *dbg_info;
  126. #endif
  127. uint8_t in_use:1,
  128. unmapped:1,
  129. in_err_state:1;
  130. };
  131. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  132. /* RX Descriptor Multi Page memory alloc related */
  133. #define DP_RX_DESC_OFFSET_NUM_BITS 8
  134. #define DP_RX_DESC_PAGE_ID_NUM_BITS 8
  135. #define DP_RX_DESC_POOL_ID_NUM_BITS 4
  136. #define DP_RX_DESC_PAGE_ID_SHIFT DP_RX_DESC_OFFSET_NUM_BITS
  137. #define DP_RX_DESC_POOL_ID_SHIFT \
  138. (DP_RX_DESC_OFFSET_NUM_BITS + DP_RX_DESC_PAGE_ID_NUM_BITS)
  139. #define RX_DESC_MULTI_PAGE_COOKIE_POOL_ID_MASK \
  140. (((1 << DP_RX_DESC_POOL_ID_NUM_BITS) - 1) << DP_RX_DESC_POOL_ID_SHIFT)
  141. #define RX_DESC_MULTI_PAGE_COOKIE_PAGE_ID_MASK \
  142. (((1 << DP_RX_DESC_PAGE_ID_NUM_BITS) - 1) << \
  143. DP_RX_DESC_PAGE_ID_SHIFT)
  144. #define RX_DESC_MULTI_PAGE_COOKIE_OFFSET_MASK \
  145. ((1 << DP_RX_DESC_OFFSET_NUM_BITS) - 1)
  146. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(_cookie) \
  147. (((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_POOL_ID_MASK) >> \
  148. DP_RX_DESC_POOL_ID_SHIFT)
  149. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(_cookie) \
  150. (((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_PAGE_ID_MASK) >> \
  151. DP_RX_DESC_PAGE_ID_SHIFT)
  152. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(_cookie) \
  153. ((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_OFFSET_MASK)
  154. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  155. #define RX_DESC_COOKIE_INDEX_SHIFT 0
  156. #define RX_DESC_COOKIE_INDEX_MASK 0x3ffff /* 18 bits */
  157. #define RX_DESC_COOKIE_POOL_ID_SHIFT 18
  158. #define RX_DESC_COOKIE_POOL_ID_MASK 0x1c0000
  159. #define DP_RX_DESC_COOKIE_MAX \
  160. (RX_DESC_COOKIE_INDEX_MASK | RX_DESC_COOKIE_POOL_ID_MASK)
  161. #define DP_RX_DESC_COOKIE_POOL_ID_GET(_cookie) \
  162. (((_cookie) & RX_DESC_COOKIE_POOL_ID_MASK) >> \
  163. RX_DESC_COOKIE_POOL_ID_SHIFT)
  164. #define DP_RX_DESC_COOKIE_INDEX_GET(_cookie) \
  165. (((_cookie) & RX_DESC_COOKIE_INDEX_MASK) >> \
  166. RX_DESC_COOKIE_INDEX_SHIFT)
  167. #define dp_rx_add_to_free_desc_list(head, tail, new) \
  168. __dp_rx_add_to_free_desc_list(head, tail, new, __func__)
  169. #define dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool, \
  170. num_buffers, desc_list, tail) \
  171. __dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool, \
  172. num_buffers, desc_list, tail, __func__)
  173. #ifdef DP_RX_SPECIAL_FRAME_NEED
  174. /**
  175. * dp_rx_is_special_frame() - check is RX frame special needed
  176. *
  177. * @nbuf: RX skb pointer
  178. * @frame_mask: the mask for speical frame needed
  179. *
  180. * Check is RX frame wanted matched with mask
  181. *
  182. * Return: true - special frame needed, false - no
  183. */
  184. static inline
  185. bool dp_rx_is_special_frame(qdf_nbuf_t nbuf, uint32_t frame_mask)
  186. {
  187. if (((frame_mask & FRAME_MASK_IPV4_ARP) &&
  188. qdf_nbuf_is_ipv4_arp_pkt(nbuf)) ||
  189. ((frame_mask & FRAME_MASK_IPV4_DHCP) &&
  190. qdf_nbuf_is_ipv4_dhcp_pkt(nbuf)) ||
  191. ((frame_mask & FRAME_MASK_IPV4_EAPOL) &&
  192. qdf_nbuf_is_ipv4_eapol_pkt(nbuf)) ||
  193. ((frame_mask & FRAME_MASK_IPV6_DHCP) &&
  194. qdf_nbuf_is_ipv6_dhcp_pkt(nbuf)))
  195. return true;
  196. return false;
  197. }
  198. /**
  199. * dp_rx_deliver_special_frame() - Deliver the RX special frame to stack
  200. * if matches mask
  201. *
  202. * @soc: Datapath soc handler
  203. * @peer: pointer to DP peer
  204. * @nbuf: pointer to the skb of RX frame
  205. * @frame_mask: the mask for speical frame needed
  206. * @rx_tlv_hdr: start of rx tlv header
  207. *
  208. * note: Msdu_len must have been stored in QDF_NBUF_CB_RX_PKT_LEN(nbuf) and
  209. * single nbuf is expected.
  210. *
  211. * return: true - nbuf has been delivered to stack, false - not.
  212. */
  213. bool dp_rx_deliver_special_frame(struct dp_soc *soc, struct dp_peer *peer,
  214. qdf_nbuf_t nbuf, uint32_t frame_mask,
  215. uint8_t *rx_tlv_hdr);
  216. #else
  217. static inline
  218. bool dp_rx_is_special_frame(qdf_nbuf_t nbuf, uint32_t frame_mask)
  219. {
  220. return false;
  221. }
  222. static inline
  223. bool dp_rx_deliver_special_frame(struct dp_soc *soc, struct dp_peer *peer,
  224. qdf_nbuf_t nbuf, uint32_t frame_mask,
  225. uint8_t *rx_tlv_hdr)
  226. {
  227. return false;
  228. }
  229. #endif
  230. /* DOC: Offset to obtain LLC hdr
  231. *
  232. * In the case of Wifi parse error
  233. * to reach LLC header from beginning
  234. * of VLAN tag we need to skip 8 bytes.
  235. * Vlan_tag(4)+length(2)+length added
  236. * by HW(2) = 8 bytes.
  237. */
  238. #define DP_SKIP_VLAN 8
  239. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  240. /**
  241. * struct dp_rx_cached_buf - rx cached buffer
  242. * @list: linked list node
  243. * @buf: skb buffer
  244. */
  245. struct dp_rx_cached_buf {
  246. qdf_list_node_t node;
  247. qdf_nbuf_t buf;
  248. };
  249. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  250. /*
  251. *dp_rx_xor_block() - xor block of data
  252. *@b: destination data block
  253. *@a: source data block
  254. *@len: length of the data to process
  255. *
  256. *Returns: None
  257. */
  258. static inline void dp_rx_xor_block(uint8_t *b, const uint8_t *a, qdf_size_t len)
  259. {
  260. qdf_size_t i;
  261. for (i = 0; i < len; i++)
  262. b[i] ^= a[i];
  263. }
  264. /*
  265. *dp_rx_rotl() - rotate the bits left
  266. *@val: unsigned integer input value
  267. *@bits: number of bits
  268. *
  269. *Returns: Integer with left rotated by number of 'bits'
  270. */
  271. static inline uint32_t dp_rx_rotl(uint32_t val, int bits)
  272. {
  273. return (val << bits) | (val >> (32 - bits));
  274. }
  275. /*
  276. *dp_rx_rotr() - rotate the bits right
  277. *@val: unsigned integer input value
  278. *@bits: number of bits
  279. *
  280. *Returns: Integer with right rotated by number of 'bits'
  281. */
  282. static inline uint32_t dp_rx_rotr(uint32_t val, int bits)
  283. {
  284. return (val >> bits) | (val << (32 - bits));
  285. }
  286. /*
  287. * dp_set_rx_queue() - set queue_mapping in skb
  288. * @nbuf: skb
  289. * @queue_id: rx queue_id
  290. *
  291. * Return: void
  292. */
  293. #ifdef QCA_OL_RX_MULTIQ_SUPPORT
  294. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  295. {
  296. qdf_nbuf_record_rx_queue(nbuf, queue_id);
  297. return;
  298. }
  299. #else
  300. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  301. {
  302. }
  303. #endif
  304. /*
  305. *dp_rx_xswap() - swap the bits left
  306. *@val: unsigned integer input value
  307. *
  308. *Returns: Integer with bits swapped
  309. */
  310. static inline uint32_t dp_rx_xswap(uint32_t val)
  311. {
  312. return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
  313. }
  314. /*
  315. *dp_rx_get_le32_split() - get little endian 32 bits split
  316. *@b0: byte 0
  317. *@b1: byte 1
  318. *@b2: byte 2
  319. *@b3: byte 3
  320. *
  321. *Returns: Integer with split little endian 32 bits
  322. */
  323. static inline uint32_t dp_rx_get_le32_split(uint8_t b0, uint8_t b1, uint8_t b2,
  324. uint8_t b3)
  325. {
  326. return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
  327. }
  328. /*
  329. *dp_rx_get_le32() - get little endian 32 bits
  330. *@b0: byte 0
  331. *@b1: byte 1
  332. *@b2: byte 2
  333. *@b3: byte 3
  334. *
  335. *Returns: Integer with little endian 32 bits
  336. */
  337. static inline uint32_t dp_rx_get_le32(const uint8_t *p)
  338. {
  339. return dp_rx_get_le32_split(p[0], p[1], p[2], p[3]);
  340. }
  341. /*
  342. * dp_rx_put_le32() - put little endian 32 bits
  343. * @p: destination char array
  344. * @v: source 32-bit integer
  345. *
  346. * Returns: None
  347. */
  348. static inline void dp_rx_put_le32(uint8_t *p, uint32_t v)
  349. {
  350. p[0] = (v) & 0xff;
  351. p[1] = (v >> 8) & 0xff;
  352. p[2] = (v >> 16) & 0xff;
  353. p[3] = (v >> 24) & 0xff;
  354. }
  355. /* Extract michal mic block of data */
  356. #define dp_rx_michael_block(l, r) \
  357. do { \
  358. r ^= dp_rx_rotl(l, 17); \
  359. l += r; \
  360. r ^= dp_rx_xswap(l); \
  361. l += r; \
  362. r ^= dp_rx_rotl(l, 3); \
  363. l += r; \
  364. r ^= dp_rx_rotr(l, 2); \
  365. l += r; \
  366. } while (0)
  367. /**
  368. * struct dp_rx_desc_list_elem_t
  369. *
  370. * @next : Next pointer to form free list
  371. * @rx_desc : DP Rx descriptor
  372. */
  373. union dp_rx_desc_list_elem_t {
  374. union dp_rx_desc_list_elem_t *next;
  375. struct dp_rx_desc rx_desc;
  376. };
  377. #ifdef RX_DESC_MULTI_PAGE_ALLOC
  378. /**
  379. * dp_rx_desc_find() - find dp rx descriptor from page ID and offset
  380. * @page_id: Page ID
  381. * @offset: Offset of the descriptor element
  382. *
  383. * Return: RX descriptor element
  384. */
  385. union dp_rx_desc_list_elem_t *dp_rx_desc_find(uint16_t page_id, uint16_t offset,
  386. struct rx_desc_pool *rx_pool);
  387. static inline
  388. struct dp_rx_desc *dp_get_rx_desc_from_cookie(struct dp_soc *soc,
  389. struct rx_desc_pool *pool,
  390. uint32_t cookie)
  391. {
  392. uint8_t pool_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(cookie);
  393. uint16_t page_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(cookie);
  394. uint8_t offset = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(cookie);
  395. struct rx_desc_pool *rx_desc_pool;
  396. union dp_rx_desc_list_elem_t *rx_desc_elem;
  397. if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS))
  398. return NULL;
  399. rx_desc_pool = &pool[pool_id];
  400. rx_desc_elem = (union dp_rx_desc_list_elem_t *)
  401. (rx_desc_pool->desc_pages.cacheable_pages[page_id] +
  402. rx_desc_pool->elem_size * offset);
  403. return &rx_desc_elem->rx_desc;
  404. }
  405. /**
  406. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  407. * the Rx descriptor on Rx DMA source ring buffer
  408. * @soc: core txrx main context
  409. * @cookie: cookie used to lookup virtual address
  410. *
  411. * Return: Pointer to the Rx descriptor
  412. */
  413. static inline
  414. struct dp_rx_desc *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc,
  415. uint32_t cookie)
  416. {
  417. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_buf[0], cookie);
  418. }
  419. /**
  420. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  421. * the Rx descriptor on monitor ring buffer
  422. * @soc: core txrx main context
  423. * @cookie: cookie used to lookup virtual address
  424. *
  425. * Return: Pointer to the Rx descriptor
  426. */
  427. static inline
  428. struct dp_rx_desc *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc,
  429. uint32_t cookie)
  430. {
  431. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_mon[0], cookie);
  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: Pointer to the Rx descriptor
  440. */
  441. static inline
  442. struct dp_rx_desc *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc,
  443. uint32_t cookie)
  444. {
  445. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_status[0], cookie);
  446. }
  447. #else
  448. void dp_rx_desc_pool_init(struct dp_soc *soc, uint32_t pool_id,
  449. uint32_t pool_size,
  450. struct rx_desc_pool *rx_desc_pool);
  451. /**
  452. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  453. * the Rx descriptor on Rx DMA source ring buffer
  454. * @soc: core txrx main context
  455. * @cookie: cookie used to lookup virtual address
  456. *
  457. * Return: void *: Virtual Address of the Rx descriptor
  458. */
  459. static inline
  460. void *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc, uint32_t cookie)
  461. {
  462. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  463. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  464. struct rx_desc_pool *rx_desc_pool;
  465. if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS))
  466. return NULL;
  467. rx_desc_pool = &soc->rx_desc_buf[pool_id];
  468. if (qdf_unlikely(index >= rx_desc_pool->pool_size))
  469. return NULL;
  470. return &(soc->rx_desc_buf[pool_id].array[index].rx_desc);
  471. }
  472. /**
  473. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  474. * the Rx descriptor on monitor ring buffer
  475. * @soc: core txrx main context
  476. * @cookie: cookie used to lookup virtual address
  477. *
  478. * Return: void *: Virtual Address of the Rx descriptor
  479. */
  480. static inline
  481. void *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc, uint32_t cookie)
  482. {
  483. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  484. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  485. /* TODO */
  486. /* Add sanity for pool_id & index */
  487. return &(soc->rx_desc_mon[pool_id].array[index].rx_desc);
  488. }
  489. /**
  490. * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of
  491. * the Rx descriptor on monitor status ring buffer
  492. * @soc: core txrx main context
  493. * @cookie: cookie used to lookup virtual address
  494. *
  495. * Return: void *: Virtual Address of the Rx descriptor
  496. */
  497. static inline
  498. void *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc, uint32_t cookie)
  499. {
  500. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  501. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  502. /* TODO */
  503. /* Add sanity for pool_id & index */
  504. return &(soc->rx_desc_status[pool_id].array[index].rx_desc);
  505. }
  506. #endif /* RX_DESC_MULTI_PAGE_ALLOC */
  507. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  508. #ifdef DP_RX_DESC_COOKIE_INVALIDATE
  509. static inline QDF_STATUS
  510. dp_rx_cookie_check_and_invalidate(hal_ring_desc_t ring_desc)
  511. {
  512. if (qdf_unlikely(HAL_RX_REO_BUF_COOKIE_INVALID_GET(ring_desc)))
  513. return QDF_STATUS_E_FAILURE;
  514. HAL_RX_REO_BUF_COOKIE_INVALID_SET(ring_desc);
  515. return QDF_STATUS_SUCCESS;
  516. }
  517. #else
  518. static inline QDF_STATUS
  519. dp_rx_cookie_check_and_invalidate(hal_ring_desc_t ring_desc)
  520. {
  521. return QDF_STATUS_SUCCESS;
  522. }
  523. #endif
  524. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  525. QDF_STATUS dp_rx_desc_pool_is_allocated(struct rx_desc_pool *rx_desc_pool);
  526. QDF_STATUS dp_rx_desc_pool_alloc(struct dp_soc *soc,
  527. uint32_t pool_size,
  528. struct rx_desc_pool *rx_desc_pool);
  529. void dp_rx_desc_pool_init(struct dp_soc *soc, uint32_t pool_id,
  530. uint32_t pool_size,
  531. struct rx_desc_pool *rx_desc_pool);
  532. void dp_rx_pdev_mon_buf_buffers_free(struct dp_pdev *pdev, uint32_t mac_id);
  533. void dp_rx_add_desc_list_to_free_list(struct dp_soc *soc,
  534. union dp_rx_desc_list_elem_t **local_desc_list,
  535. union dp_rx_desc_list_elem_t **tail,
  536. uint16_t pool_id,
  537. struct rx_desc_pool *rx_desc_pool);
  538. uint16_t dp_rx_get_free_desc_list(struct dp_soc *soc, uint32_t pool_id,
  539. struct rx_desc_pool *rx_desc_pool,
  540. uint16_t num_descs,
  541. union dp_rx_desc_list_elem_t **desc_list,
  542. union dp_rx_desc_list_elem_t **tail);
  543. QDF_STATUS dp_rx_pdev_desc_pool_alloc(struct dp_pdev *pdev);
  544. void dp_rx_pdev_desc_pool_free(struct dp_pdev *pdev);
  545. QDF_STATUS dp_rx_pdev_desc_pool_init(struct dp_pdev *pdev);
  546. void dp_rx_pdev_desc_pool_deinit(struct dp_pdev *pdev);
  547. void dp_rx_desc_pool_deinit(struct dp_soc *soc,
  548. struct rx_desc_pool *rx_desc_pool);
  549. QDF_STATUS dp_rx_pdev_attach(struct dp_pdev *pdev);
  550. QDF_STATUS dp_rx_pdev_buffers_alloc(struct dp_pdev *pdev);
  551. void dp_rx_pdev_buffers_free(struct dp_pdev *pdev);
  552. void dp_rx_pdev_detach(struct dp_pdev *pdev);
  553. void dp_print_napi_stats(struct dp_soc *soc);
  554. /**
  555. * dp_rx_vdev_detach() - detach vdev from dp rx
  556. * @vdev: virtual device instance
  557. *
  558. * Return: QDF_STATUS_SUCCESS: success
  559. * QDF_STATUS_E_RESOURCES: Error return
  560. */
  561. QDF_STATUS dp_rx_vdev_detach(struct dp_vdev *vdev);
  562. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  563. uint32_t
  564. dp_rx_process(struct dp_intr *int_ctx, hal_ring_handle_t hal_ring_hdl,
  565. uint8_t reo_ring_num,
  566. uint32_t quota);
  567. /**
  568. * dp_rx_err_process() - Processes error frames routed to REO error ring
  569. * @int_ctx: pointer to DP interrupt context
  570. * @soc: core txrx main context
  571. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  572. * @quota: No. of units (packets) that can be serviced in one shot.
  573. *
  574. * This function implements error processing and top level demultiplexer
  575. * for all the frames routed to REO error ring.
  576. *
  577. * Return: uint32_t: No. of elements processed
  578. */
  579. uint32_t dp_rx_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  580. hal_ring_handle_t hal_ring_hdl, uint32_t quota);
  581. /**
  582. * dp_rx_wbm_err_process() - Processes error frames routed to WBM release ring
  583. * @int_ctx: pointer to DP interrupt context
  584. * @soc: core txrx main context
  585. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  586. * @quota: No. of units (packets) that can be serviced in one shot.
  587. *
  588. * This function implements error processing and top level demultiplexer
  589. * for all the frames routed to WBM2HOST sw release ring.
  590. *
  591. * Return: uint32_t: No. of elements processed
  592. */
  593. uint32_t
  594. dp_rx_wbm_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  595. hal_ring_handle_t hal_ring_hdl, uint32_t quota);
  596. /**
  597. * dp_rx_sg_create() - create a frag_list for MSDUs which are spread across
  598. * multiple nbufs.
  599. * @soc: core txrx main context
  600. * @nbuf: pointer to the first msdu of an amsdu.
  601. *
  602. * This function implements the creation of RX frag_list for cases
  603. * where an MSDU is spread across multiple nbufs.
  604. *
  605. * Return: returns the head nbuf which contains complete frag_list.
  606. */
  607. qdf_nbuf_t dp_rx_sg_create(struct dp_soc *soc, qdf_nbuf_t nbuf);
  608. /*
  609. * dp_rx_desc_nbuf_and_pool_free() - free the sw rx desc pool called during
  610. * de-initialization of wifi module.
  611. *
  612. * @soc: core txrx main context
  613. * @pool_id: pool_id which is one of 3 mac_ids
  614. * @rx_desc_pool: rx descriptor pool pointer
  615. *
  616. * Return: None
  617. */
  618. void dp_rx_desc_nbuf_and_pool_free(struct dp_soc *soc, uint32_t pool_id,
  619. struct rx_desc_pool *rx_desc_pool);
  620. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  621. /*
  622. * dp_rx_desc_nbuf_free() - free the sw rx desc nbufs called during
  623. * de-initialization of wifi module.
  624. *
  625. * @soc: core txrx main context
  626. * @pool_id: pool_id which is one of 3 mac_ids
  627. * @rx_desc_pool: rx descriptor pool pointer
  628. *
  629. * Return: None
  630. */
  631. void dp_rx_desc_nbuf_free(struct dp_soc *soc,
  632. struct rx_desc_pool *rx_desc_pool);
  633. #ifdef DP_RX_MON_MEM_FRAG
  634. /*
  635. * dp_rx_desc_frag_free() - free the sw rx desc frag called during
  636. * de-initialization of wifi module.
  637. *
  638. * @soc: core txrx main context
  639. * @rx_desc_pool: rx descriptor pool pointer
  640. *
  641. * Return: None
  642. */
  643. void dp_rx_desc_frag_free(struct dp_soc *soc,
  644. struct rx_desc_pool *rx_desc_pool);
  645. #else
  646. static inline
  647. void dp_rx_desc_frag_free(struct dp_soc *soc,
  648. struct rx_desc_pool *rx_desc_pool)
  649. {
  650. }
  651. #endif
  652. /*
  653. * dp_rx_desc_pool_free() - free the sw rx desc array called during
  654. * de-initialization of wifi module.
  655. *
  656. * @soc: core txrx main context
  657. * @rx_desc_pool: rx descriptor pool pointer
  658. *
  659. * Return: None
  660. */
  661. void dp_rx_desc_pool_free(struct dp_soc *soc,
  662. struct rx_desc_pool *rx_desc_pool);
  663. void dp_rx_deliver_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf_list,
  664. struct dp_peer *peer);
  665. #ifdef RX_DESC_DEBUG_CHECK
  666. /**
  667. * dp_rx_desc_paddr_sanity_check() - paddr sanity for ring desc vs rx_desc
  668. * @rx_desc: rx descriptor
  669. * @ring_paddr: paddr obatined from the ring
  670. *
  671. * Returns: QDF_STATUS
  672. */
  673. static inline
  674. bool dp_rx_desc_paddr_sanity_check(struct dp_rx_desc *rx_desc,
  675. uint64_t ring_paddr)
  676. {
  677. return (ring_paddr == qdf_nbuf_get_frag_paddr(rx_desc->nbuf, 0));
  678. }
  679. /*
  680. * dp_rx_desc_alloc_dbg_info() - Alloc memory for rx descriptor debug
  681. * structure
  682. * @rx_desc: rx descriptor pointer
  683. *
  684. * Return: None
  685. */
  686. static inline
  687. void dp_rx_desc_alloc_dbg_info(struct dp_rx_desc *rx_desc)
  688. {
  689. rx_desc->dbg_info = qdf_mem_malloc(sizeof(struct dp_rx_desc_dbg_info));
  690. }
  691. /*
  692. * dp_rx_desc_free_dbg_info() - Free rx descriptor debug
  693. * structure memory
  694. * @rx_desc: rx descriptor pointer
  695. *
  696. * Return: None
  697. */
  698. static inline
  699. void dp_rx_desc_free_dbg_info(struct dp_rx_desc *rx_desc)
  700. {
  701. qdf_mem_free(rx_desc->dbg_info);
  702. }
  703. /*
  704. * dp_rx_desc_update_dbg_info() - Update rx descriptor debug info
  705. * structure memory
  706. * @rx_desc: rx descriptor pointer
  707. *
  708. * Return: None
  709. */
  710. static
  711. void dp_rx_desc_update_dbg_info(struct dp_rx_desc *rx_desc,
  712. const char *func_name, uint8_t flag)
  713. {
  714. struct dp_rx_desc_dbg_info *info = rx_desc->dbg_info;
  715. if (!info)
  716. return;
  717. if (flag == RX_DESC_REPLENISHED) {
  718. qdf_str_lcopy(info->replenish_caller, func_name,
  719. QDF_MEM_FUNC_NAME_SIZE);
  720. info->replenish_ts = qdf_get_log_timestamp();
  721. } else {
  722. qdf_str_lcopy(info->freelist_caller, func_name,
  723. QDF_MEM_FUNC_NAME_SIZE);
  724. info->freelist_ts = qdf_get_log_timestamp();
  725. info->prev_nbuf = rx_desc->nbuf;
  726. info->prev_nbuf_data_addr = rx_desc->nbuf_data_addr;
  727. rx_desc->nbuf_data_addr = NULL;
  728. }
  729. }
  730. #else
  731. static inline
  732. bool dp_rx_desc_paddr_sanity_check(struct dp_rx_desc *rx_desc,
  733. uint64_t ring_paddr)
  734. {
  735. return true;
  736. }
  737. static inline
  738. void dp_rx_desc_alloc_dbg_info(struct dp_rx_desc *rx_desc)
  739. {
  740. }
  741. static inline
  742. void dp_rx_desc_free_dbg_info(struct dp_rx_desc *rx_desc)
  743. {
  744. }
  745. static inline
  746. void dp_rx_desc_update_dbg_info(struct dp_rx_desc *rx_desc,
  747. const char *func_name, uint8_t flag)
  748. {
  749. }
  750. #endif /* RX_DESC_DEBUG_CHECK */
  751. /**
  752. * dp_rx_add_to_free_desc_list() - Adds to a local free descriptor list
  753. *
  754. * @head: pointer to the head of local free list
  755. * @tail: pointer to the tail of local free list
  756. * @new: new descriptor that is added to the free list
  757. * @func_name: caller func name
  758. *
  759. * Return: void:
  760. */
  761. static inline
  762. void __dp_rx_add_to_free_desc_list(union dp_rx_desc_list_elem_t **head,
  763. union dp_rx_desc_list_elem_t **tail,
  764. struct dp_rx_desc *new, const char *func_name)
  765. {
  766. qdf_assert(head && new);
  767. dp_rx_desc_update_dbg_info(new, func_name, RX_DESC_IN_FREELIST);
  768. new->nbuf = NULL;
  769. new->in_use = 0;
  770. ((union dp_rx_desc_list_elem_t *)new)->next = *head;
  771. *head = (union dp_rx_desc_list_elem_t *)new;
  772. /* reset tail if head->next is NULL */
  773. if (!*tail || !(*head)->next)
  774. *tail = *head;
  775. }
  776. uint8_t dp_rx_process_invalid_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  777. uint8_t mac_id);
  778. void dp_rx_process_invalid_peer_wrapper(struct dp_soc *soc,
  779. qdf_nbuf_t mpdu, bool mpdu_done, uint8_t mac_id);
  780. void dp_rx_process_mic_error(struct dp_soc *soc, qdf_nbuf_t nbuf,
  781. uint8_t *rx_tlv_hdr, struct dp_peer *peer);
  782. void dp_2k_jump_handle(struct dp_soc *soc, qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  783. uint16_t peer_id, uint8_t tid);
  784. #define DP_RX_HEAD_APPEND(head, elem) \
  785. do { \
  786. qdf_nbuf_set_next((elem), (head)); \
  787. (head) = (elem); \
  788. } while (0)
  789. #define DP_RX_LIST_APPEND(head, tail, elem) \
  790. do { \
  791. if (!(head)) { \
  792. (head) = (elem); \
  793. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head) = 1;\
  794. } else { \
  795. qdf_nbuf_set_next((tail), (elem)); \
  796. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head)++; \
  797. } \
  798. (tail) = (elem); \
  799. qdf_nbuf_set_next((tail), NULL); \
  800. } while (0)
  801. #define DP_RX_MERGE_TWO_LIST(phead, ptail, chead, ctail) \
  802. do { \
  803. if (!(phead)) { \
  804. (phead) = (chead); \
  805. } else { \
  806. qdf_nbuf_set_next((ptail), (chead)); \
  807. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(phead) += \
  808. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(chead); \
  809. } \
  810. (ptail) = (ctail); \
  811. qdf_nbuf_set_next((ptail), NULL); \
  812. } while (0)
  813. /*for qcn9000 emulation the pcie is complete phy and no address restrictions*/
  814. #if !defined(BUILD_X86) || defined(QCA_WIFI_QCN9000)
  815. static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf,
  816. qdf_dma_addr_t *paddr, struct rx_desc_pool *rx_desc_pool)
  817. {
  818. return QDF_STATUS_SUCCESS;
  819. }
  820. #else
  821. #define MAX_RETRY 100
  822. static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf,
  823. qdf_dma_addr_t *paddr, struct rx_desc_pool *rx_desc_pool)
  824. {
  825. uint32_t nbuf_retry = 0;
  826. int32_t ret;
  827. const uint32_t x86_phy_addr = 0x50000000;
  828. /*
  829. * in M2M emulation platforms (x86) the memory below 0x50000000
  830. * is reserved for target use, so any memory allocated in this
  831. * region should not be used by host
  832. */
  833. do {
  834. if (qdf_likely(*paddr > x86_phy_addr))
  835. return QDF_STATUS_SUCCESS;
  836. else {
  837. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  838. "phy addr %pK exceeded 0x50000000 trying again",
  839. paddr);
  840. nbuf_retry++;
  841. if ((*rx_netbuf)) {
  842. qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf,
  843. QDF_DMA_FROM_DEVICE);
  844. /* Not freeing buffer intentionally.
  845. * Observed that same buffer is getting
  846. * re-allocated resulting in longer load time
  847. * WMI init timeout.
  848. * This buffer is anyway not useful so skip it.
  849. **/
  850. }
  851. *rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev,
  852. rx_desc_pool->buf_size,
  853. RX_BUFFER_RESERVATION,
  854. rx_desc_pool->buf_alignment,
  855. FALSE);
  856. if (qdf_unlikely(!(*rx_netbuf)))
  857. return QDF_STATUS_E_FAILURE;
  858. ret = qdf_nbuf_map_single(dp_soc->osdev, *rx_netbuf,
  859. QDF_DMA_FROM_DEVICE);
  860. if (qdf_unlikely(ret == QDF_STATUS_E_FAILURE)) {
  861. qdf_nbuf_free(*rx_netbuf);
  862. *rx_netbuf = NULL;
  863. continue;
  864. }
  865. *paddr = qdf_nbuf_get_frag_paddr(*rx_netbuf, 0);
  866. }
  867. } while (nbuf_retry < MAX_RETRY);
  868. if ((*rx_netbuf)) {
  869. qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf,
  870. QDF_DMA_FROM_DEVICE);
  871. qdf_nbuf_free(*rx_netbuf);
  872. }
  873. return QDF_STATUS_E_FAILURE;
  874. }
  875. #endif
  876. /**
  877. * dp_rx_cookie_2_link_desc_va() - Converts cookie to a virtual address of
  878. * the MSDU Link Descriptor
  879. * @soc: core txrx main context
  880. * @buf_info: buf_info includes cookie that is used to lookup
  881. * virtual address of link descriptor after deriving the page id
  882. * and the offset or index of the desc on the associatde page.
  883. *
  884. * This is the VA of the link descriptor, that HAL layer later uses to
  885. * retrieve the list of MSDU's for a given MPDU.
  886. *
  887. * Return: void *: Virtual Address of the Rx descriptor
  888. */
  889. static inline
  890. void *dp_rx_cookie_2_link_desc_va(struct dp_soc *soc,
  891. struct hal_buf_info *buf_info)
  892. {
  893. void *link_desc_va;
  894. struct qdf_mem_multi_page_t *pages;
  895. uint16_t page_id = LINK_DESC_COOKIE_PAGE_ID(buf_info->sw_cookie);
  896. pages = &soc->link_desc_pages;
  897. if (!pages)
  898. return NULL;
  899. if (qdf_unlikely(page_id >= pages->num_pages))
  900. return NULL;
  901. link_desc_va = pages->dma_pages[page_id].page_v_addr_start +
  902. (buf_info->paddr - pages->dma_pages[page_id].page_p_addr);
  903. return link_desc_va;
  904. }
  905. /**
  906. * dp_rx_cookie_2_mon_link_desc_va() - Converts cookie to a virtual address of
  907. * the MSDU Link Descriptor
  908. * @pdev: core txrx pdev context
  909. * @buf_info: buf_info includes cookie that used to lookup virtual address of
  910. * link descriptor. Normally this is just an index into a per pdev array.
  911. *
  912. * This is the VA of the link descriptor in monitor mode destination ring,
  913. * that HAL layer later uses to retrieve the list of MSDU's for a given MPDU.
  914. *
  915. * Return: void *: Virtual Address of the Rx descriptor
  916. */
  917. static inline
  918. void *dp_rx_cookie_2_mon_link_desc_va(struct dp_pdev *pdev,
  919. struct hal_buf_info *buf_info,
  920. int mac_id)
  921. {
  922. void *link_desc_va;
  923. struct qdf_mem_multi_page_t *pages;
  924. uint16_t page_id = LINK_DESC_COOKIE_PAGE_ID(buf_info->sw_cookie);
  925. pages = &pdev->soc->mon_link_desc_pages[mac_id];
  926. if (!pages)
  927. return NULL;
  928. if (qdf_unlikely(page_id >= pages->num_pages))
  929. return NULL;
  930. link_desc_va = pages->dma_pages[page_id].page_v_addr_start +
  931. (buf_info->paddr - pages->dma_pages[page_id].page_p_addr);
  932. return link_desc_va;
  933. }
  934. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  935. /**
  936. * dp_rx_defrag_concat() - Concatenate the fragments
  937. *
  938. * @dst: destination pointer to the buffer
  939. * @src: source pointer from where the fragment payload is to be copied
  940. *
  941. * Return: QDF_STATUS
  942. */
  943. static inline QDF_STATUS dp_rx_defrag_concat(qdf_nbuf_t dst, qdf_nbuf_t src)
  944. {
  945. /*
  946. * Inside qdf_nbuf_cat, if it is necessary to reallocate dst
  947. * to provide space for src, the headroom portion is copied from
  948. * the original dst buffer to the larger new dst buffer.
  949. * (This is needed, because the headroom of the dst buffer
  950. * contains the rx desc.)
  951. */
  952. if (!qdf_nbuf_cat(dst, src)) {
  953. /*
  954. * qdf_nbuf_cat does not free the src memory.
  955. * Free src nbuf before returning
  956. * For failure case the caller takes of freeing the nbuf
  957. */
  958. qdf_nbuf_free(src);
  959. return QDF_STATUS_SUCCESS;
  960. }
  961. return QDF_STATUS_E_DEFRAG_ERROR;
  962. }
  963. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  964. #ifndef FEATURE_WDS
  965. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
  966. {
  967. return QDF_STATUS_SUCCESS;
  968. }
  969. static inline void
  970. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  971. uint8_t *rx_tlv_hdr,
  972. struct dp_peer *ta_peer,
  973. qdf_nbuf_t nbuf,
  974. struct hal_rx_msdu_metadata msdu_metadata)
  975. {
  976. }
  977. #endif
  978. /*
  979. * dp_rx_desc_dump() - dump the sw rx descriptor
  980. *
  981. * @rx_desc: sw rx descriptor
  982. */
  983. static inline void dp_rx_desc_dump(struct dp_rx_desc *rx_desc)
  984. {
  985. dp_info("rx_desc->nbuf: %pK, rx_desc->cookie: %d, rx_desc->pool_id: %d, rx_desc->in_use: %d, rx_desc->unmapped: %d",
  986. rx_desc->nbuf, rx_desc->cookie, rx_desc->pool_id,
  987. rx_desc->in_use, rx_desc->unmapped);
  988. }
  989. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  990. /*
  991. * check_qwrap_multicast_loopback() - Check if rx packet is a loopback packet.
  992. * In qwrap mode, packets originated from
  993. * any vdev should not loopback and
  994. * should be dropped.
  995. * @vdev: vdev on which rx packet is received
  996. * @nbuf: rx pkt
  997. *
  998. */
  999. #if ATH_SUPPORT_WRAP
  1000. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  1001. qdf_nbuf_t nbuf)
  1002. {
  1003. struct dp_vdev *psta_vdev;
  1004. struct dp_pdev *pdev = vdev->pdev;
  1005. uint8_t *data = qdf_nbuf_data(nbuf);
  1006. if (qdf_unlikely(vdev->proxysta_vdev)) {
  1007. /* In qwrap isolation mode, allow loopback packets as all
  1008. * packets go to RootAP and Loopback on the mpsta.
  1009. */
  1010. if (vdev->isolation_vdev)
  1011. return false;
  1012. TAILQ_FOREACH(psta_vdev, &pdev->vdev_list, vdev_list_elem) {
  1013. if (qdf_unlikely(psta_vdev->proxysta_vdev &&
  1014. !qdf_mem_cmp(psta_vdev->mac_addr.raw,
  1015. &data[QDF_MAC_ADDR_SIZE],
  1016. QDF_MAC_ADDR_SIZE))) {
  1017. /* Drop packet if source address is equal to
  1018. * any of the vdev addresses.
  1019. */
  1020. return true;
  1021. }
  1022. }
  1023. }
  1024. return false;
  1025. }
  1026. #else
  1027. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  1028. qdf_nbuf_t nbuf)
  1029. {
  1030. return false;
  1031. }
  1032. #endif
  1033. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1034. #if defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) ||\
  1035. defined(WLAN_SUPPORT_RX_TAG_STATISTICS) ||\
  1036. defined(WLAN_SUPPORT_RX_FLOW_TAG)
  1037. #include "dp_rx_tag.h"
  1038. #endif
  1039. #ifndef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  1040. /**
  1041. * dp_rx_update_protocol_tag() - Reads CCE metadata from the RX MSDU end TLV
  1042. * and set the corresponding tag in QDF packet
  1043. * @soc: core txrx main context
  1044. * @vdev: vdev on which the packet is received
  1045. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1046. * @rx_tlv_hdr: rBbase address where the RX TLVs starts
  1047. * @ring_index: REO ring number, not used for error & monitor ring
  1048. * @is_reo_exception: flag to indicate if rx from REO ring or exception ring
  1049. * @is_update_stats: flag to indicate whether to update stats or not
  1050. * Return: void
  1051. */
  1052. static inline void
  1053. dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  1054. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  1055. uint16_t ring_index,
  1056. bool is_reo_exception, bool is_update_stats)
  1057. {
  1058. }
  1059. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  1060. #ifndef WLAN_SUPPORT_RX_FLOW_TAG
  1061. /**
  1062. * dp_rx_update_flow_tag() - Reads FSE metadata from the RX MSDU end TLV
  1063. * and set the corresponding tag in QDF packet
  1064. * @soc: core txrx main context
  1065. * @vdev: vdev on which the packet is received
  1066. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1067. * @rx_tlv_hdr: base address where the RX TLVs starts
  1068. * @is_update_stats: flag to indicate whether to update stats or not
  1069. *
  1070. * Return: void
  1071. */
  1072. static inline void
  1073. dp_rx_update_flow_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  1074. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr, bool update_stats)
  1075. {
  1076. }
  1077. #endif /* WLAN_SUPPORT_RX_FLOW_TAG */
  1078. #if !defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) &&\
  1079. !defined(WLAN_SUPPORT_RX_FLOW_TAG)
  1080. /**
  1081. * dp_rx_mon_update_protocol_flow_tag() - Performs necessary checks for monitor
  1082. * mode and then tags appropriate packets
  1083. * @soc: core txrx main context
  1084. * @vdev: pdev on which packet is received
  1085. * @msdu: QDF packet buffer on which the protocol tag should be set
  1086. * @rx_desc: base address where the RX TLVs start
  1087. * Return: void
  1088. */
  1089. static inline
  1090. void dp_rx_mon_update_protocol_flow_tag(struct dp_soc *soc,
  1091. struct dp_pdev *dp_pdev,
  1092. qdf_nbuf_t msdu, void *rx_desc)
  1093. {
  1094. }
  1095. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG || WLAN_SUPPORT_RX_FLOW_TAG */
  1096. /*
  1097. * dp_rx_buffers_replenish() - replenish rxdma ring with rx nbufs
  1098. * called during dp rx initialization
  1099. * and at the end of dp_rx_process.
  1100. *
  1101. * @soc: core txrx main context
  1102. * @mac_id: mac_id which is one of 3 mac_ids
  1103. * @dp_rxdma_srng: dp rxdma circular ring
  1104. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1105. * @num_req_buffers: number of buffer to be replenished
  1106. * @desc_list: list of descs if called from dp_rx_process
  1107. * or NULL during dp rx initialization or out of buffer
  1108. * interrupt.
  1109. * @tail: tail of descs list
  1110. * @func_name: name of the caller function
  1111. * Return: return success or failure
  1112. */
  1113. QDF_STATUS __dp_rx_buffers_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  1114. struct dp_srng *dp_rxdma_srng,
  1115. struct rx_desc_pool *rx_desc_pool,
  1116. uint32_t num_req_buffers,
  1117. union dp_rx_desc_list_elem_t **desc_list,
  1118. union dp_rx_desc_list_elem_t **tail,
  1119. const char *func_name);
  1120. /*
  1121. * dp_pdev_rx_buffers_attach() - replenish rxdma ring with rx nbufs
  1122. * called during dp rx initialization
  1123. *
  1124. * @soc: core txrx main context
  1125. * @mac_id: mac_id which is one of 3 mac_ids
  1126. * @dp_rxdma_srng: dp rxdma circular ring
  1127. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1128. * @num_req_buffers: number of buffer to be replenished
  1129. *
  1130. * Return: return success or failure
  1131. */
  1132. QDF_STATUS
  1133. dp_pdev_rx_buffers_attach(struct dp_soc *dp_soc, uint32_t mac_id,
  1134. struct dp_srng *dp_rxdma_srng,
  1135. struct rx_desc_pool *rx_desc_pool,
  1136. uint32_t num_req_buffers);
  1137. /**
  1138. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  1139. * (WBM), following error handling
  1140. *
  1141. * @soc: core DP main context
  1142. * @buf_addr_info: opaque pointer to the REO error ring descriptor
  1143. * @buf_addr_info: void pointer to the buffer_addr_info
  1144. * @bm_action: put to idle_list or release to msdu_list
  1145. *
  1146. * Return: QDF_STATUS_E_FAILURE for failure else QDF_STATUS_SUCCESS
  1147. */
  1148. QDF_STATUS
  1149. dp_rx_link_desc_return(struct dp_soc *soc, hal_ring_desc_t ring_desc,
  1150. uint8_t bm_action);
  1151. /**
  1152. * dp_rx_link_desc_return_by_addr - Return a MPDU link descriptor to
  1153. * (WBM) by address
  1154. *
  1155. * @soc: core DP main context
  1156. * @link_desc_addr: link descriptor addr
  1157. *
  1158. * Return: QDF_STATUS_E_FAILURE for failure else QDF_STATUS_SUCCESS
  1159. */
  1160. QDF_STATUS
  1161. dp_rx_link_desc_return_by_addr(struct dp_soc *soc,
  1162. hal_buff_addrinfo_t link_desc_addr,
  1163. uint8_t bm_action);
  1164. /**
  1165. * dp_rxdma_err_process() - RxDMA error processing functionality
  1166. * @soc: core txrx main contex
  1167. * @mac_id: mac id which is one of 3 mac_ids
  1168. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  1169. * @quota: No. of units (packets) that can be serviced in one shot.
  1170. *
  1171. * Return: num of buffers processed
  1172. */
  1173. uint32_t
  1174. dp_rxdma_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  1175. uint32_t mac_id, uint32_t quota);
  1176. void dp_rx_fill_mesh_stats(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1177. uint8_t *rx_tlv_hdr, struct dp_peer *peer);
  1178. QDF_STATUS dp_rx_filter_mesh_packets(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1179. uint8_t *rx_tlv_hdr);
  1180. int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr, struct dp_vdev *vdev,
  1181. struct dp_peer *peer);
  1182. /*
  1183. * dp_rx_dump_info_and_assert() - dump RX Ring info and Rx Desc info
  1184. *
  1185. * @soc: core txrx main context
  1186. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  1187. * @ring_desc: opaque pointer to the RX ring descriptor
  1188. * @rx_desc: host rx descriptor
  1189. *
  1190. * Return: void
  1191. */
  1192. void dp_rx_dump_info_and_assert(struct dp_soc *soc,
  1193. hal_ring_handle_t hal_ring_hdl,
  1194. hal_ring_desc_t ring_desc,
  1195. struct dp_rx_desc *rx_desc);
  1196. void dp_rx_compute_delay(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  1197. #ifdef QCA_PEER_EXT_STATS
  1198. void dp_rx_compute_tid_delay(struct cdp_delay_tid_stats *stats,
  1199. qdf_nbuf_t nbuf);
  1200. #endif /* QCA_PEER_EXT_STATS */
  1201. #ifdef RX_DESC_DEBUG_CHECK
  1202. /**
  1203. * dp_rx_desc_check_magic() - check the magic value in dp_rx_desc
  1204. * @rx_desc: rx descriptor pointer
  1205. *
  1206. * Return: true, if magic is correct, else false.
  1207. */
  1208. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1209. {
  1210. if (qdf_unlikely(rx_desc->magic != DP_RX_DESC_MAGIC))
  1211. return false;
  1212. rx_desc->magic = 0;
  1213. return true;
  1214. }
  1215. /**
  1216. * dp_rx_desc_prep() - prepare rx desc
  1217. * @rx_desc: rx descriptor pointer to be prepared
  1218. * @nbuf_frag_info_t: struct dp_rx_nbuf_frag_info *
  1219. *
  1220. * Note: assumption is that we are associating a nbuf which is mapped
  1221. *
  1222. * Return: none
  1223. */
  1224. static inline
  1225. void dp_rx_desc_prep(struct dp_rx_desc *rx_desc,
  1226. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1227. {
  1228. rx_desc->magic = DP_RX_DESC_MAGIC;
  1229. rx_desc->nbuf = (nbuf_frag_info_t->virt_addr).nbuf;
  1230. rx_desc->unmapped = 0;
  1231. rx_desc->nbuf_data_addr = (uint8_t *)qdf_nbuf_data(rx_desc->nbuf);
  1232. }
  1233. /**
  1234. * dp_rx_desc_frag_prep() - prepare rx desc
  1235. * @rx_desc: rx descriptor pointer to be prepared
  1236. * @nbuf_frag_info_t: struct dp_rx_nbuf_frag_info *
  1237. *
  1238. * Note: assumption is that we frag address is mapped
  1239. *
  1240. * Return: none
  1241. */
  1242. #ifdef DP_RX_MON_MEM_FRAG
  1243. static inline
  1244. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1245. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1246. {
  1247. rx_desc->magic = DP_RX_DESC_MAGIC;
  1248. rx_desc->rx_buf_start =
  1249. (uint8_t *)((nbuf_frag_info_t->virt_addr).vaddr);
  1250. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1251. rx_desc->unmapped = 0;
  1252. }
  1253. #else
  1254. static inline
  1255. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1256. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1257. {
  1258. }
  1259. #endif /* DP_RX_MON_MEM_FRAG */
  1260. #else
  1261. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1262. {
  1263. return true;
  1264. }
  1265. static inline
  1266. void dp_rx_desc_prep(struct dp_rx_desc *rx_desc,
  1267. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1268. {
  1269. rx_desc->nbuf = (nbuf_frag_info_t->virt_addr).nbuf;
  1270. rx_desc->unmapped = 0;
  1271. }
  1272. #ifdef DP_RX_MON_MEM_FRAG
  1273. static inline
  1274. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1275. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1276. {
  1277. rx_desc->rx_buf_start =
  1278. (uint8_t *)((nbuf_frag_info_t->virt_addr).vaddr);
  1279. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1280. rx_desc->unmapped = 0;
  1281. }
  1282. #else
  1283. static inline
  1284. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1285. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1286. {
  1287. }
  1288. #endif /* DP_RX_MON_MEM_FRAG */
  1289. #endif /* RX_DESC_DEBUG_CHECK */
  1290. void dp_rx_enable_mon_dest_frag(struct rx_desc_pool *rx_desc_pool,
  1291. bool is_mon_dest_desc);
  1292. void dp_rx_process_rxdma_err(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1293. uint8_t *rx_tlv_hdr, struct dp_peer *peer,
  1294. uint8_t err_code, uint8_t mac_id);
  1295. #ifndef QCA_MULTIPASS_SUPPORT
  1296. static inline
  1297. bool dp_rx_multipass_process(struct dp_peer *peer, qdf_nbuf_t nbuf, uint8_t tid)
  1298. {
  1299. return false;
  1300. }
  1301. #else
  1302. bool dp_rx_multipass_process(struct dp_peer *peer, qdf_nbuf_t nbuf,
  1303. uint8_t tid);
  1304. #endif
  1305. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1306. #ifndef WLAN_RX_PKT_CAPTURE_ENH
  1307. static inline
  1308. QDF_STATUS dp_peer_set_rx_capture_enabled(struct dp_pdev *pdev,
  1309. struct dp_peer *peer_handle,
  1310. bool value, uint8_t *mac_addr)
  1311. {
  1312. return QDF_STATUS_SUCCESS;
  1313. }
  1314. #endif
  1315. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1316. /**
  1317. * dp_rx_deliver_to_stack() - deliver pkts to network stack
  1318. * Caller to hold peer refcount and check for valid peer
  1319. * @soc: soc
  1320. * @vdev: vdev
  1321. * @peer: peer
  1322. * @nbuf_head: skb list head
  1323. * @nbuf_tail: skb list tail
  1324. *
  1325. * Return: None
  1326. */
  1327. void dp_rx_deliver_to_stack(struct dp_soc *soc,
  1328. struct dp_vdev *vdev,
  1329. struct dp_peer *peer,
  1330. qdf_nbuf_t nbuf_head,
  1331. qdf_nbuf_t nbuf_tail);
  1332. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1333. #ifdef QCA_OL_RX_LOCK_LESS_ACCESS
  1334. /*
  1335. * dp_rx_ring_access_start()- Wrapper function to log access start of a hal ring
  1336. * @int_ctx: pointer to DP interrupt context
  1337. * @dp_soc - DP soc structure pointer
  1338. * @hal_ring_hdl - HAL ring handle
  1339. *
  1340. * Return: 0 on success; error on failure
  1341. */
  1342. static inline int
  1343. dp_rx_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *soc,
  1344. hal_ring_handle_t hal_ring_hdl)
  1345. {
  1346. return hal_srng_access_start_unlocked(soc->hal_soc, hal_ring_hdl);
  1347. }
  1348. /*
  1349. * dp_rx_ring_access_end()- Wrapper function to log access end of a hal ring
  1350. * @int_ctx: pointer to DP interrupt context
  1351. * @dp_soc - DP soc structure pointer
  1352. * @hal_ring_hdl - HAL ring handle
  1353. *
  1354. * Return - None
  1355. */
  1356. static inline void
  1357. dp_rx_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *soc,
  1358. hal_ring_handle_t hal_ring_hdl)
  1359. {
  1360. hal_srng_access_end_unlocked(soc->hal_soc, hal_ring_hdl);
  1361. }
  1362. #else
  1363. static inline int
  1364. dp_rx_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *soc,
  1365. hal_ring_handle_t hal_ring_hdl)
  1366. {
  1367. return dp_srng_access_start(int_ctx, soc, hal_ring_hdl);
  1368. }
  1369. static inline void
  1370. dp_rx_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *soc,
  1371. hal_ring_handle_t hal_ring_hdl)
  1372. {
  1373. dp_srng_access_end(int_ctx, soc, hal_ring_hdl);
  1374. }
  1375. #endif
  1376. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1377. /*
  1378. * dp_rx_wbm_sg_list_reset() - Initialize sg list
  1379. *
  1380. * This api should be called at soc init and afterevery sg processing.
  1381. *@soc: DP SOC handle
  1382. */
  1383. static inline void dp_rx_wbm_sg_list_reset(struct dp_soc *soc)
  1384. {
  1385. if (soc) {
  1386. soc->wbm_sg_param.wbm_is_first_msdu_in_sg = false;
  1387. soc->wbm_sg_param.wbm_sg_nbuf_head = NULL;
  1388. soc->wbm_sg_param.wbm_sg_nbuf_tail = NULL;
  1389. soc->wbm_sg_param.wbm_sg_desc_msdu_len = 0;
  1390. }
  1391. }
  1392. /*
  1393. * dp_rx_wbm_sg_list_deinit() - De-initialize sg list
  1394. *
  1395. * This api should be called in down path, to avoid any leak.
  1396. *@soc: DP SOC handle
  1397. */
  1398. static inline void dp_rx_wbm_sg_list_deinit(struct dp_soc *soc)
  1399. {
  1400. if (soc) {
  1401. if (soc->wbm_sg_param.wbm_sg_nbuf_head)
  1402. qdf_nbuf_list_free(soc->wbm_sg_param.wbm_sg_nbuf_head);
  1403. dp_rx_wbm_sg_list_reset(soc);
  1404. }
  1405. }
  1406. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1407. #ifdef WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL
  1408. #define DP_RX_PROCESS_NBUF(soc, head, tail, ebuf_head, ebuf_tail, rx_desc) \
  1409. do { \
  1410. if (!soc->rx_buff_pool[rx_desc->pool_id].is_initialized) { \
  1411. DP_RX_LIST_APPEND(head, tail, rx_desc->nbuf); \
  1412. break; \
  1413. } \
  1414. DP_RX_LIST_APPEND(ebuf_head, ebuf_tail, rx_desc->nbuf); \
  1415. if (!qdf_nbuf_is_rx_chfrag_cont(rx_desc->nbuf)) { \
  1416. if (!dp_rx_buffer_pool_refill(soc, ebuf_head, \
  1417. rx_desc->pool_id)) \
  1418. DP_RX_MERGE_TWO_LIST(head, tail, \
  1419. ebuf_head, ebuf_tail);\
  1420. ebuf_head = NULL; \
  1421. ebuf_tail = NULL; \
  1422. } \
  1423. } while (0)
  1424. #else
  1425. #define DP_RX_PROCESS_NBUF(soc, head, tail, ebuf_head, ebuf_tail, rx_desc) \
  1426. DP_RX_LIST_APPEND(head, tail, rx_desc->nbuf)
  1427. #endif /* WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL */
  1428. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1429. /*
  1430. * dp_rx_link_desc_refill_duplicate_check() - check if link desc duplicate
  1431. to refill
  1432. * @soc: DP SOC handle
  1433. * @buf_info: the last link desc buf info
  1434. * @ring_buf_info: current buf address pointor including link desc
  1435. *
  1436. * return: none.
  1437. */
  1438. void dp_rx_link_desc_refill_duplicate_check(
  1439. struct dp_soc *soc,
  1440. struct hal_buf_info *buf_info,
  1441. hal_buff_addrinfo_t ring_buf_info);
  1442. #ifdef WLAN_FEATURE_PKT_CAPTURE_LITHIUM
  1443. /**
  1444. * dp_rx_deliver_to_pkt_capture() - deliver rx packet to packet capture
  1445. * @soc : dp_soc handle
  1446. * @pdev: dp_pdev handle
  1447. * @peer_id: peer_id of the peer for which completion came
  1448. * @ppdu_id: ppdu_id
  1449. * @netbuf: Buffer pointer
  1450. *
  1451. * This function is used to deliver rx packet to packet capture
  1452. */
  1453. void dp_rx_deliver_to_pkt_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  1454. uint16_t peer_id, uint32_t ppdu_id,
  1455. qdf_nbuf_t netbuf);
  1456. #else
  1457. static inline void
  1458. dp_rx_deliver_to_pkt_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  1459. uint16_t peer_id, uint32_t ppdu_id,
  1460. qdf_nbuf_t netbuf)
  1461. {
  1462. }
  1463. #endif
  1464. #endif /* _DP_RX_H */