dp_rx.h 47 KB

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