dp_rx.h 47 KB

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