dp_rx.h 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725
  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_LOGGING
  672. /*
  673. * dp_rx_desc_alloc_dbg_info() - Alloc memory for rx descriptor debug
  674. * structure
  675. * @rx_desc: rx descriptor pointer
  676. *
  677. * Return: None
  678. */
  679. static inline
  680. void dp_rx_desc_alloc_dbg_info(struct dp_rx_desc *rx_desc)
  681. {
  682. rx_desc->dbg_info = qdf_mem_malloc(sizeof(struct dp_rx_desc_dbg_info));
  683. }
  684. /*
  685. * dp_rx_desc_free_dbg_info() - Free rx descriptor debug
  686. * structure memory
  687. * @rx_desc: rx descriptor pointer
  688. *
  689. * Return: None
  690. */
  691. static inline
  692. void dp_rx_desc_free_dbg_info(struct dp_rx_desc *rx_desc)
  693. {
  694. qdf_mem_free(rx_desc->dbg_info);
  695. }
  696. /*
  697. * dp_rx_desc_update_dbg_info() - Update rx descriptor debug info
  698. * structure memory
  699. * @rx_desc: rx descriptor pointer
  700. *
  701. * Return: None
  702. */
  703. static
  704. void dp_rx_desc_update_dbg_info(struct dp_rx_desc *rx_desc,
  705. const char *func_name, uint8_t flag)
  706. {
  707. struct dp_rx_desc_dbg_info *info = rx_desc->dbg_info;
  708. if (!info)
  709. return;
  710. if (flag == RX_DESC_REPLENISHED) {
  711. qdf_str_lcopy(info->replenish_caller, func_name,
  712. QDF_MEM_FUNC_NAME_SIZE);
  713. info->replenish_ts = qdf_get_log_timestamp();
  714. } else {
  715. qdf_str_lcopy(info->freelist_caller, func_name,
  716. QDF_MEM_FUNC_NAME_SIZE);
  717. info->freelist_ts = qdf_get_log_timestamp();
  718. info->prev_nbuf = rx_desc->nbuf;
  719. info->prev_nbuf_data_addr = rx_desc->nbuf_data_addr;
  720. rx_desc->nbuf_data_addr = NULL;
  721. }
  722. }
  723. #else
  724. static inline
  725. void dp_rx_desc_alloc_dbg_info(struct dp_rx_desc *rx_desc)
  726. {
  727. }
  728. static inline
  729. void dp_rx_desc_free_dbg_info(struct dp_rx_desc *rx_desc)
  730. {
  731. }
  732. static inline
  733. void dp_rx_desc_update_dbg_info(struct dp_rx_desc *rx_desc,
  734. const char *func_name, uint8_t flag)
  735. {
  736. }
  737. #endif /* RX_DESC_LOGGING */
  738. /**
  739. * dp_rx_add_to_free_desc_list() - Adds to a local free descriptor list
  740. *
  741. * @head: pointer to the head of local free list
  742. * @tail: pointer to the tail of local free list
  743. * @new: new descriptor that is added to the free list
  744. * @func_name: caller func name
  745. *
  746. * Return: void:
  747. */
  748. static inline
  749. void __dp_rx_add_to_free_desc_list(union dp_rx_desc_list_elem_t **head,
  750. union dp_rx_desc_list_elem_t **tail,
  751. struct dp_rx_desc *new, const char *func_name)
  752. {
  753. qdf_assert(head && new);
  754. dp_rx_desc_update_dbg_info(new, func_name, RX_DESC_IN_FREELIST);
  755. new->nbuf = NULL;
  756. new->in_use = 0;
  757. ((union dp_rx_desc_list_elem_t *)new)->next = *head;
  758. *head = (union dp_rx_desc_list_elem_t *)new;
  759. /* reset tail if head->next is NULL */
  760. if (!*tail || !(*head)->next)
  761. *tail = *head;
  762. }
  763. uint8_t dp_rx_process_invalid_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  764. uint8_t mac_id);
  765. void dp_rx_process_invalid_peer_wrapper(struct dp_soc *soc,
  766. qdf_nbuf_t mpdu, bool mpdu_done, uint8_t mac_id);
  767. void dp_rx_process_mic_error(struct dp_soc *soc, qdf_nbuf_t nbuf,
  768. uint8_t *rx_tlv_hdr, struct dp_peer *peer);
  769. void dp_2k_jump_handle(struct dp_soc *soc, qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  770. uint16_t peer_id, uint8_t tid);
  771. #define DP_RX_HEAD_APPEND(head, elem) \
  772. do { \
  773. qdf_nbuf_set_next((elem), (head)); \
  774. (head) = (elem); \
  775. } while (0)
  776. #define DP_RX_LIST_APPEND(head, tail, elem) \
  777. do { \
  778. if (!(head)) { \
  779. (head) = (elem); \
  780. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head) = 1;\
  781. } else { \
  782. qdf_nbuf_set_next((tail), (elem)); \
  783. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head)++; \
  784. } \
  785. (tail) = (elem); \
  786. qdf_nbuf_set_next((tail), NULL); \
  787. } while (0)
  788. #define DP_RX_MERGE_TWO_LIST(phead, ptail, chead, ctail) \
  789. do { \
  790. if (!(phead)) { \
  791. (phead) = (chead); \
  792. } else { \
  793. qdf_nbuf_set_next((ptail), (chead)); \
  794. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(phead) += \
  795. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(chead); \
  796. } \
  797. (ptail) = (ctail); \
  798. qdf_nbuf_set_next((ptail), NULL); \
  799. } while (0)
  800. #if defined(QCA_PADDR_CHECK_ON_3TH_PLATFORM)
  801. /*
  802. * on some third-party platform, the memory below 0x2000
  803. * is reserved for target use, so any memory allocated in this
  804. * region should not be used by host
  805. */
  806. #define MAX_RETRY 50
  807. #define DP_PHY_ADDR_RESERVED 0x2000
  808. #elif defined(BUILD_X86)
  809. /*
  810. * in M2M emulation platforms (x86) the memory below 0x50000000
  811. * is reserved for target use, so any memory allocated in this
  812. * region should not be used by host
  813. */
  814. #define MAX_RETRY 100
  815. #define DP_PHY_ADDR_RESERVED 0x50000000
  816. #endif
  817. #if defined(QCA_PADDR_CHECK_ON_3TH_PLATFORM) || defined(BUILD_X86)
  818. /**
  819. * dp_check_paddr() - check if current phy address is valid or not
  820. * @dp_soc: core txrx main context
  821. * @rx_netbuf: skb buffer
  822. * @paddr: physical address
  823. * @rx_desc_pool: struct of rx descriptor pool
  824. * check if the physical address of the nbuf->data is less
  825. * than DP_PHY_ADDR_RESERVED then free the nbuf and try
  826. * allocating new nbuf. We can try for 100 times.
  827. *
  828. * This is a temp WAR till we fix it properly.
  829. *
  830. * Return: success or failure.
  831. */
  832. static inline
  833. int dp_check_paddr(struct dp_soc *dp_soc,
  834. qdf_nbuf_t *rx_netbuf,
  835. qdf_dma_addr_t *paddr,
  836. struct rx_desc_pool *rx_desc_pool)
  837. {
  838. uint32_t nbuf_retry = 0;
  839. int32_t ret;
  840. if (qdf_likely(*paddr > DP_PHY_ADDR_RESERVED))
  841. return QDF_STATUS_SUCCESS;
  842. do {
  843. dp_debug("invalid phy addr 0x%llx, trying again",
  844. (uint64_t)(*paddr));
  845. nbuf_retry++;
  846. if ((*rx_netbuf)) {
  847. /* Not freeing buffer intentionally.
  848. * Observed that same buffer is getting
  849. * re-allocated resulting in longer load time
  850. * WMI init timeout.
  851. * This buffer is anyway not useful so skip it.
  852. *.Add such buffer to invalid list and free
  853. *.them when driver unload.
  854. **/
  855. qdf_nbuf_unmap_nbytes_single(dp_soc->osdev,
  856. *rx_netbuf,
  857. QDF_DMA_FROM_DEVICE,
  858. rx_desc_pool->buf_size);
  859. qdf_nbuf_queue_add(&dp_soc->invalid_buf_queue,
  860. *rx_netbuf);
  861. }
  862. *rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev,
  863. rx_desc_pool->buf_size,
  864. RX_BUFFER_RESERVATION,
  865. rx_desc_pool->buf_alignment,
  866. FALSE);
  867. if (qdf_unlikely(!(*rx_netbuf)))
  868. return QDF_STATUS_E_FAILURE;
  869. ret = qdf_nbuf_map_nbytes_single(dp_soc->osdev,
  870. *rx_netbuf,
  871. QDF_DMA_FROM_DEVICE,
  872. rx_desc_pool->buf_size);
  873. if (qdf_unlikely(ret == QDF_STATUS_E_FAILURE)) {
  874. qdf_nbuf_free(*rx_netbuf);
  875. *rx_netbuf = NULL;
  876. continue;
  877. }
  878. *paddr = qdf_nbuf_get_frag_paddr(*rx_netbuf, 0);
  879. if (qdf_likely(*paddr > DP_PHY_ADDR_RESERVED))
  880. return QDF_STATUS_SUCCESS;
  881. } while (nbuf_retry < MAX_RETRY);
  882. if ((*rx_netbuf)) {
  883. qdf_nbuf_unmap_nbytes_single(dp_soc->osdev,
  884. *rx_netbuf,
  885. QDF_DMA_FROM_DEVICE,
  886. rx_desc_pool->buf_size);
  887. qdf_nbuf_queue_add(&dp_soc->invalid_buf_queue,
  888. *rx_netbuf);
  889. }
  890. return QDF_STATUS_E_FAILURE;
  891. }
  892. #else
  893. static inline
  894. int dp_check_paddr(struct dp_soc *dp_soc,
  895. qdf_nbuf_t *rx_netbuf,
  896. qdf_dma_addr_t *paddr,
  897. struct rx_desc_pool *rx_desc_pool)
  898. {
  899. return QDF_STATUS_SUCCESS;
  900. }
  901. #endif
  902. /**
  903. * dp_rx_cookie_2_link_desc_va() - Converts cookie to a virtual address of
  904. * the MSDU Link Descriptor
  905. * @soc: core txrx main context
  906. * @buf_info: buf_info includes cookie that is used to lookup
  907. * virtual address of link descriptor after deriving the page id
  908. * and the offset or index of the desc on the associatde page.
  909. *
  910. * This is the VA of the link descriptor, that HAL layer later uses to
  911. * retrieve the list of MSDU's for a given MPDU.
  912. *
  913. * Return: void *: Virtual Address of the Rx descriptor
  914. */
  915. static inline
  916. void *dp_rx_cookie_2_link_desc_va(struct dp_soc *soc,
  917. struct hal_buf_info *buf_info)
  918. {
  919. void *link_desc_va;
  920. struct qdf_mem_multi_page_t *pages;
  921. uint16_t page_id = LINK_DESC_COOKIE_PAGE_ID(buf_info->sw_cookie);
  922. pages = &soc->link_desc_pages;
  923. if (!pages)
  924. return NULL;
  925. if (qdf_unlikely(page_id >= pages->num_pages))
  926. return NULL;
  927. link_desc_va = pages->dma_pages[page_id].page_v_addr_start +
  928. (buf_info->paddr - pages->dma_pages[page_id].page_p_addr);
  929. return link_desc_va;
  930. }
  931. /**
  932. * dp_rx_cookie_2_mon_link_desc_va() - Converts cookie to a virtual address of
  933. * the MSDU Link Descriptor
  934. * @pdev: core txrx pdev context
  935. * @buf_info: buf_info includes cookie that used to lookup virtual address of
  936. * link descriptor. Normally this is just an index into a per pdev array.
  937. *
  938. * This is the VA of the link descriptor in monitor mode destination ring,
  939. * that HAL layer later uses to retrieve the list of MSDU's for a given MPDU.
  940. *
  941. * Return: void *: Virtual Address of the Rx descriptor
  942. */
  943. static inline
  944. void *dp_rx_cookie_2_mon_link_desc_va(struct dp_pdev *pdev,
  945. struct hal_buf_info *buf_info,
  946. int mac_id)
  947. {
  948. void *link_desc_va;
  949. struct qdf_mem_multi_page_t *pages;
  950. uint16_t page_id = LINK_DESC_COOKIE_PAGE_ID(buf_info->sw_cookie);
  951. pages = &pdev->soc->mon_link_desc_pages[mac_id];
  952. if (!pages)
  953. return NULL;
  954. if (qdf_unlikely(page_id >= pages->num_pages))
  955. return NULL;
  956. link_desc_va = pages->dma_pages[page_id].page_v_addr_start +
  957. (buf_info->paddr - pages->dma_pages[page_id].page_p_addr);
  958. return link_desc_va;
  959. }
  960. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  961. /**
  962. * dp_rx_defrag_concat() - Concatenate the fragments
  963. *
  964. * @dst: destination pointer to the buffer
  965. * @src: source pointer from where the fragment payload is to be copied
  966. *
  967. * Return: QDF_STATUS
  968. */
  969. static inline QDF_STATUS dp_rx_defrag_concat(qdf_nbuf_t dst, qdf_nbuf_t src)
  970. {
  971. /*
  972. * Inside qdf_nbuf_cat, if it is necessary to reallocate dst
  973. * to provide space for src, the headroom portion is copied from
  974. * the original dst buffer to the larger new dst buffer.
  975. * (This is needed, because the headroom of the dst buffer
  976. * contains the rx desc.)
  977. */
  978. if (!qdf_nbuf_cat(dst, src)) {
  979. /*
  980. * qdf_nbuf_cat does not free the src memory.
  981. * Free src nbuf before returning
  982. * For failure case the caller takes of freeing the nbuf
  983. */
  984. qdf_nbuf_free(src);
  985. return QDF_STATUS_SUCCESS;
  986. }
  987. return QDF_STATUS_E_DEFRAG_ERROR;
  988. }
  989. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  990. #ifndef FEATURE_WDS
  991. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
  992. {
  993. return QDF_STATUS_SUCCESS;
  994. }
  995. static inline void
  996. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  997. uint8_t *rx_tlv_hdr,
  998. struct dp_peer *ta_peer,
  999. qdf_nbuf_t nbuf,
  1000. struct hal_rx_msdu_metadata msdu_metadata)
  1001. {
  1002. }
  1003. #endif
  1004. /*
  1005. * dp_rx_desc_dump() - dump the sw rx descriptor
  1006. *
  1007. * @rx_desc: sw rx descriptor
  1008. */
  1009. static inline void dp_rx_desc_dump(struct dp_rx_desc *rx_desc)
  1010. {
  1011. dp_info("rx_desc->nbuf: %pK, rx_desc->cookie: %d, rx_desc->pool_id: %d, rx_desc->in_use: %d, rx_desc->unmapped: %d",
  1012. rx_desc->nbuf, rx_desc->cookie, rx_desc->pool_id,
  1013. rx_desc->in_use, rx_desc->unmapped);
  1014. }
  1015. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1016. /*
  1017. * check_qwrap_multicast_loopback() - Check if rx packet is a loopback packet.
  1018. * In qwrap mode, packets originated from
  1019. * any vdev should not loopback and
  1020. * should be dropped.
  1021. * @vdev: vdev on which rx packet is received
  1022. * @nbuf: rx pkt
  1023. *
  1024. */
  1025. #if ATH_SUPPORT_WRAP
  1026. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  1027. qdf_nbuf_t nbuf)
  1028. {
  1029. struct dp_vdev *psta_vdev;
  1030. struct dp_pdev *pdev = vdev->pdev;
  1031. uint8_t *data = qdf_nbuf_data(nbuf);
  1032. if (qdf_unlikely(vdev->proxysta_vdev)) {
  1033. /* In qwrap isolation mode, allow loopback packets as all
  1034. * packets go to RootAP and Loopback on the mpsta.
  1035. */
  1036. if (vdev->isolation_vdev)
  1037. return false;
  1038. TAILQ_FOREACH(psta_vdev, &pdev->vdev_list, vdev_list_elem) {
  1039. if (qdf_unlikely(psta_vdev->proxysta_vdev &&
  1040. !qdf_mem_cmp(psta_vdev->mac_addr.raw,
  1041. &data[QDF_MAC_ADDR_SIZE],
  1042. QDF_MAC_ADDR_SIZE))) {
  1043. /* Drop packet if source address is equal to
  1044. * any of the vdev addresses.
  1045. */
  1046. return true;
  1047. }
  1048. }
  1049. }
  1050. return false;
  1051. }
  1052. #else
  1053. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  1054. qdf_nbuf_t nbuf)
  1055. {
  1056. return false;
  1057. }
  1058. #endif
  1059. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1060. #if defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) ||\
  1061. defined(WLAN_SUPPORT_RX_TAG_STATISTICS) ||\
  1062. defined(WLAN_SUPPORT_RX_FLOW_TAG)
  1063. #include "dp_rx_tag.h"
  1064. #endif
  1065. #ifndef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  1066. /**
  1067. * dp_rx_update_protocol_tag() - Reads CCE metadata from the RX MSDU end TLV
  1068. * and set the corresponding tag in QDF packet
  1069. * @soc: core txrx main context
  1070. * @vdev: vdev on which the packet is received
  1071. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1072. * @rx_tlv_hdr: rBbase address where the RX TLVs starts
  1073. * @ring_index: REO ring number, not used for error & monitor ring
  1074. * @is_reo_exception: flag to indicate if rx from REO ring or exception ring
  1075. * @is_update_stats: flag to indicate whether to update stats or not
  1076. * Return: void
  1077. */
  1078. static inline void
  1079. dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  1080. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  1081. uint16_t ring_index,
  1082. bool is_reo_exception, bool is_update_stats)
  1083. {
  1084. }
  1085. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  1086. #ifndef WLAN_SUPPORT_RX_FLOW_TAG
  1087. /**
  1088. * dp_rx_update_flow_tag() - Reads FSE metadata from the RX MSDU end TLV
  1089. * and set the corresponding tag in QDF packet
  1090. * @soc: core txrx main context
  1091. * @vdev: vdev on which the packet is received
  1092. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1093. * @rx_tlv_hdr: base address where the RX TLVs starts
  1094. * @is_update_stats: flag to indicate whether to update stats or not
  1095. *
  1096. * Return: void
  1097. */
  1098. static inline void
  1099. dp_rx_update_flow_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  1100. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr, bool update_stats)
  1101. {
  1102. }
  1103. #endif /* WLAN_SUPPORT_RX_FLOW_TAG */
  1104. #if !defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) &&\
  1105. !defined(WLAN_SUPPORT_RX_FLOW_TAG)
  1106. /**
  1107. * dp_rx_mon_update_protocol_flow_tag() - Performs necessary checks for monitor
  1108. * mode and then tags appropriate packets
  1109. * @soc: core txrx main context
  1110. * @vdev: pdev on which packet is received
  1111. * @msdu: QDF packet buffer on which the protocol tag should be set
  1112. * @rx_desc: base address where the RX TLVs start
  1113. * Return: void
  1114. */
  1115. static inline
  1116. void dp_rx_mon_update_protocol_flow_tag(struct dp_soc *soc,
  1117. struct dp_pdev *dp_pdev,
  1118. qdf_nbuf_t msdu, void *rx_desc)
  1119. {
  1120. }
  1121. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG || WLAN_SUPPORT_RX_FLOW_TAG */
  1122. /*
  1123. * dp_rx_buffers_replenish() - replenish rxdma ring with rx nbufs
  1124. * called during dp rx initialization
  1125. * and at the end of dp_rx_process.
  1126. *
  1127. * @soc: core txrx main context
  1128. * @mac_id: mac_id which is one of 3 mac_ids
  1129. * @dp_rxdma_srng: dp rxdma circular ring
  1130. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1131. * @num_req_buffers: number of buffer to be replenished
  1132. * @desc_list: list of descs if called from dp_rx_process
  1133. * or NULL during dp rx initialization or out of buffer
  1134. * interrupt.
  1135. * @tail: tail of descs list
  1136. * @func_name: name of the caller function
  1137. * Return: return success or failure
  1138. */
  1139. QDF_STATUS __dp_rx_buffers_replenish(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. union dp_rx_desc_list_elem_t **desc_list,
  1144. union dp_rx_desc_list_elem_t **tail,
  1145. const char *func_name);
  1146. /*
  1147. * dp_pdev_rx_buffers_attach() - replenish rxdma ring with rx nbufs
  1148. * called during dp rx initialization
  1149. *
  1150. * @soc: core txrx main context
  1151. * @mac_id: mac_id which is one of 3 mac_ids
  1152. * @dp_rxdma_srng: dp rxdma circular ring
  1153. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1154. * @num_req_buffers: number of buffer to be replenished
  1155. *
  1156. * Return: return success or failure
  1157. */
  1158. QDF_STATUS
  1159. dp_pdev_rx_buffers_attach(struct dp_soc *dp_soc, uint32_t mac_id,
  1160. struct dp_srng *dp_rxdma_srng,
  1161. struct rx_desc_pool *rx_desc_pool,
  1162. uint32_t num_req_buffers);
  1163. /**
  1164. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  1165. * (WBM), following error handling
  1166. *
  1167. * @soc: core DP main context
  1168. * @buf_addr_info: opaque pointer to the REO error ring descriptor
  1169. * @buf_addr_info: void pointer to the buffer_addr_info
  1170. * @bm_action: put to idle_list or release to msdu_list
  1171. *
  1172. * Return: QDF_STATUS_E_FAILURE for failure else QDF_STATUS_SUCCESS
  1173. */
  1174. QDF_STATUS
  1175. dp_rx_link_desc_return(struct dp_soc *soc, hal_ring_desc_t ring_desc,
  1176. uint8_t bm_action);
  1177. /**
  1178. * dp_rx_link_desc_return_by_addr - Return a MPDU link descriptor to
  1179. * (WBM) by address
  1180. *
  1181. * @soc: core DP main context
  1182. * @link_desc_addr: link descriptor addr
  1183. *
  1184. * Return: QDF_STATUS_E_FAILURE for failure else QDF_STATUS_SUCCESS
  1185. */
  1186. QDF_STATUS
  1187. dp_rx_link_desc_return_by_addr(struct dp_soc *soc,
  1188. hal_buff_addrinfo_t link_desc_addr,
  1189. uint8_t bm_action);
  1190. /**
  1191. * dp_rxdma_err_process() - RxDMA error processing functionality
  1192. * @soc: core txrx main contex
  1193. * @mac_id: mac id which is one of 3 mac_ids
  1194. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  1195. * @quota: No. of units (packets) that can be serviced in one shot.
  1196. *
  1197. * Return: num of buffers processed
  1198. */
  1199. uint32_t
  1200. dp_rxdma_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  1201. uint32_t mac_id, uint32_t quota);
  1202. void dp_rx_fill_mesh_stats(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1203. uint8_t *rx_tlv_hdr, struct dp_peer *peer);
  1204. QDF_STATUS dp_rx_filter_mesh_packets(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1205. uint8_t *rx_tlv_hdr);
  1206. int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr, struct dp_vdev *vdev,
  1207. struct dp_peer *peer);
  1208. /*
  1209. * dp_rx_dump_info_and_assert() - dump RX Ring info and Rx Desc info
  1210. *
  1211. * @soc: core txrx main context
  1212. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  1213. * @ring_desc: opaque pointer to the RX ring descriptor
  1214. * @rx_desc: host rx descriptor
  1215. *
  1216. * Return: void
  1217. */
  1218. void dp_rx_dump_info_and_assert(struct dp_soc *soc,
  1219. hal_ring_handle_t hal_ring_hdl,
  1220. hal_ring_desc_t ring_desc,
  1221. struct dp_rx_desc *rx_desc);
  1222. void dp_rx_compute_delay(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  1223. #ifdef QCA_PEER_EXT_STATS
  1224. void dp_rx_compute_tid_delay(struct cdp_delay_tid_stats *stats,
  1225. qdf_nbuf_t nbuf);
  1226. #endif /* QCA_PEER_EXT_STATS */
  1227. #ifdef RX_DESC_DEBUG_CHECK
  1228. /**
  1229. * dp_rx_desc_check_magic() - check the magic value in dp_rx_desc
  1230. * @rx_desc: rx descriptor pointer
  1231. *
  1232. * Return: true, if magic is correct, else false.
  1233. */
  1234. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1235. {
  1236. if (qdf_unlikely(rx_desc->magic != DP_RX_DESC_MAGIC))
  1237. return false;
  1238. rx_desc->magic = 0;
  1239. return true;
  1240. }
  1241. /**
  1242. * dp_rx_desc_prep() - prepare rx desc
  1243. * @rx_desc: rx descriptor pointer to be prepared
  1244. * @nbuf_frag_info_t: struct dp_rx_nbuf_frag_info *
  1245. *
  1246. * Note: assumption is that we are associating a nbuf which is mapped
  1247. *
  1248. * Return: none
  1249. */
  1250. static inline
  1251. void dp_rx_desc_prep(struct dp_rx_desc *rx_desc,
  1252. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1253. {
  1254. rx_desc->magic = DP_RX_DESC_MAGIC;
  1255. rx_desc->nbuf = (nbuf_frag_info_t->virt_addr).nbuf;
  1256. rx_desc->unmapped = 0;
  1257. rx_desc->nbuf_data_addr = (uint8_t *)qdf_nbuf_data(rx_desc->nbuf);
  1258. }
  1259. /**
  1260. * dp_rx_desc_frag_prep() - prepare rx desc
  1261. * @rx_desc: rx descriptor pointer to be prepared
  1262. * @nbuf_frag_info_t: struct dp_rx_nbuf_frag_info *
  1263. *
  1264. * Note: assumption is that we frag address is mapped
  1265. *
  1266. * Return: none
  1267. */
  1268. #ifdef DP_RX_MON_MEM_FRAG
  1269. static inline
  1270. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1271. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1272. {
  1273. rx_desc->magic = DP_RX_DESC_MAGIC;
  1274. rx_desc->rx_buf_start =
  1275. (uint8_t *)((nbuf_frag_info_t->virt_addr).vaddr);
  1276. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1277. rx_desc->unmapped = 0;
  1278. }
  1279. #else
  1280. static inline
  1281. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1282. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1283. {
  1284. }
  1285. #endif /* DP_RX_MON_MEM_FRAG */
  1286. /**
  1287. * dp_rx_desc_paddr_sanity_check() - paddr sanity for ring desc vs rx_desc
  1288. * @rx_desc: rx descriptor
  1289. * @ring_paddr: paddr obatined from the ring
  1290. *
  1291. * Returns: QDF_STATUS
  1292. */
  1293. static inline
  1294. bool dp_rx_desc_paddr_sanity_check(struct dp_rx_desc *rx_desc,
  1295. uint64_t ring_paddr)
  1296. {
  1297. return (ring_paddr == qdf_nbuf_get_frag_paddr(rx_desc->nbuf, 0));
  1298. }
  1299. #else
  1300. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1301. {
  1302. return true;
  1303. }
  1304. static inline
  1305. void dp_rx_desc_prep(struct dp_rx_desc *rx_desc,
  1306. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1307. {
  1308. rx_desc->nbuf = (nbuf_frag_info_t->virt_addr).nbuf;
  1309. rx_desc->unmapped = 0;
  1310. }
  1311. #ifdef DP_RX_MON_MEM_FRAG
  1312. static inline
  1313. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1314. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1315. {
  1316. rx_desc->rx_buf_start =
  1317. (uint8_t *)((nbuf_frag_info_t->virt_addr).vaddr);
  1318. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1319. rx_desc->unmapped = 0;
  1320. }
  1321. #else
  1322. static inline
  1323. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1324. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1325. {
  1326. }
  1327. #endif /* DP_RX_MON_MEM_FRAG */
  1328. static inline
  1329. bool dp_rx_desc_paddr_sanity_check(struct dp_rx_desc *rx_desc,
  1330. uint64_t ring_paddr)
  1331. {
  1332. return true;
  1333. }
  1334. #endif /* RX_DESC_DEBUG_CHECK */
  1335. void dp_rx_enable_mon_dest_frag(struct rx_desc_pool *rx_desc_pool,
  1336. bool is_mon_dest_desc);
  1337. void dp_rx_process_rxdma_err(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1338. uint8_t *rx_tlv_hdr, struct dp_peer *peer,
  1339. uint8_t err_code, uint8_t mac_id);
  1340. #ifndef QCA_MULTIPASS_SUPPORT
  1341. static inline
  1342. bool dp_rx_multipass_process(struct dp_peer *peer, qdf_nbuf_t nbuf, uint8_t tid)
  1343. {
  1344. return false;
  1345. }
  1346. #else
  1347. bool dp_rx_multipass_process(struct dp_peer *peer, qdf_nbuf_t nbuf,
  1348. uint8_t tid);
  1349. #endif
  1350. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1351. #ifndef WLAN_RX_PKT_CAPTURE_ENH
  1352. static inline
  1353. QDF_STATUS dp_peer_set_rx_capture_enabled(struct dp_pdev *pdev,
  1354. struct dp_peer *peer_handle,
  1355. bool value, uint8_t *mac_addr)
  1356. {
  1357. return QDF_STATUS_SUCCESS;
  1358. }
  1359. #endif
  1360. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1361. /**
  1362. * dp_rx_deliver_to_stack() - deliver pkts to network stack
  1363. * Caller to hold peer refcount and check for valid peer
  1364. * @soc: soc
  1365. * @vdev: vdev
  1366. * @peer: peer
  1367. * @nbuf_head: skb list head
  1368. * @nbuf_tail: skb list tail
  1369. *
  1370. * Return: None
  1371. */
  1372. void dp_rx_deliver_to_stack(struct dp_soc *soc,
  1373. struct dp_vdev *vdev,
  1374. struct dp_peer *peer,
  1375. qdf_nbuf_t nbuf_head,
  1376. qdf_nbuf_t nbuf_tail);
  1377. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1378. #ifdef QCA_OL_RX_LOCK_LESS_ACCESS
  1379. /*
  1380. * dp_rx_ring_access_start()- Wrapper function to log access start of a hal ring
  1381. * @int_ctx: pointer to DP interrupt context
  1382. * @dp_soc - DP soc structure pointer
  1383. * @hal_ring_hdl - HAL ring handle
  1384. *
  1385. * Return: 0 on success; error on failure
  1386. */
  1387. static inline int
  1388. dp_rx_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *soc,
  1389. hal_ring_handle_t hal_ring_hdl)
  1390. {
  1391. return hal_srng_access_start_unlocked(soc->hal_soc, hal_ring_hdl);
  1392. }
  1393. /*
  1394. * dp_rx_ring_access_end()- Wrapper function to log access end of a hal ring
  1395. * @int_ctx: pointer to DP interrupt context
  1396. * @dp_soc - DP soc structure pointer
  1397. * @hal_ring_hdl - HAL ring handle
  1398. *
  1399. * Return - None
  1400. */
  1401. static inline void
  1402. dp_rx_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *soc,
  1403. hal_ring_handle_t hal_ring_hdl)
  1404. {
  1405. hal_srng_access_end_unlocked(soc->hal_soc, hal_ring_hdl);
  1406. }
  1407. #else
  1408. static inline int
  1409. dp_rx_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *soc,
  1410. hal_ring_handle_t hal_ring_hdl)
  1411. {
  1412. return dp_srng_access_start(int_ctx, soc, hal_ring_hdl);
  1413. }
  1414. static inline void
  1415. dp_rx_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *soc,
  1416. hal_ring_handle_t hal_ring_hdl)
  1417. {
  1418. dp_srng_access_end(int_ctx, soc, hal_ring_hdl);
  1419. }
  1420. #endif
  1421. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1422. /*
  1423. * dp_rx_wbm_sg_list_reset() - Initialize sg list
  1424. *
  1425. * This api should be called at soc init and afterevery sg processing.
  1426. *@soc: DP SOC handle
  1427. */
  1428. static inline void dp_rx_wbm_sg_list_reset(struct dp_soc *soc)
  1429. {
  1430. if (soc) {
  1431. soc->wbm_sg_param.wbm_is_first_msdu_in_sg = false;
  1432. soc->wbm_sg_param.wbm_sg_nbuf_head = NULL;
  1433. soc->wbm_sg_param.wbm_sg_nbuf_tail = NULL;
  1434. soc->wbm_sg_param.wbm_sg_desc_msdu_len = 0;
  1435. }
  1436. }
  1437. /*
  1438. * dp_rx_wbm_sg_list_deinit() - De-initialize sg list
  1439. *
  1440. * This api should be called in down path, to avoid any leak.
  1441. *@soc: DP SOC handle
  1442. */
  1443. static inline void dp_rx_wbm_sg_list_deinit(struct dp_soc *soc)
  1444. {
  1445. if (soc) {
  1446. if (soc->wbm_sg_param.wbm_sg_nbuf_head)
  1447. qdf_nbuf_list_free(soc->wbm_sg_param.wbm_sg_nbuf_head);
  1448. dp_rx_wbm_sg_list_reset(soc);
  1449. }
  1450. }
  1451. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1452. #ifdef WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL
  1453. #define DP_RX_PROCESS_NBUF(soc, head, tail, ebuf_head, ebuf_tail, rx_desc) \
  1454. do { \
  1455. if (!soc->rx_buff_pool[rx_desc->pool_id].is_initialized) { \
  1456. DP_RX_LIST_APPEND(head, tail, rx_desc->nbuf); \
  1457. break; \
  1458. } \
  1459. DP_RX_LIST_APPEND(ebuf_head, ebuf_tail, rx_desc->nbuf); \
  1460. if (!qdf_nbuf_is_rx_chfrag_cont(rx_desc->nbuf)) { \
  1461. if (!dp_rx_buffer_pool_refill(soc, ebuf_head, \
  1462. rx_desc->pool_id)) \
  1463. DP_RX_MERGE_TWO_LIST(head, tail, \
  1464. ebuf_head, ebuf_tail);\
  1465. ebuf_head = NULL; \
  1466. ebuf_tail = NULL; \
  1467. } \
  1468. } while (0)
  1469. #else
  1470. #define DP_RX_PROCESS_NBUF(soc, head, tail, ebuf_head, ebuf_tail, rx_desc) \
  1471. DP_RX_LIST_APPEND(head, tail, rx_desc->nbuf)
  1472. #endif /* WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL */
  1473. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1474. /*
  1475. * dp_rx_link_desc_refill_duplicate_check() - check if link desc duplicate
  1476. to refill
  1477. * @soc: DP SOC handle
  1478. * @buf_info: the last link desc buf info
  1479. * @ring_buf_info: current buf address pointor including link desc
  1480. *
  1481. * return: none.
  1482. */
  1483. void dp_rx_link_desc_refill_duplicate_check(
  1484. struct dp_soc *soc,
  1485. struct hal_buf_info *buf_info,
  1486. hal_buff_addrinfo_t ring_buf_info);
  1487. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  1488. /**
  1489. * dp_rx_deliver_to_pkt_capture() - deliver rx packet to packet capture
  1490. * @soc : dp_soc handle
  1491. * @pdev: dp_pdev handle
  1492. * @peer_id: peer_id of the peer for which completion came
  1493. * @ppdu_id: ppdu_id
  1494. * @netbuf: Buffer pointer
  1495. *
  1496. * This function is used to deliver rx packet to packet capture
  1497. */
  1498. void dp_rx_deliver_to_pkt_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  1499. uint16_t peer_id, uint32_t is_offload,
  1500. qdf_nbuf_t netbuf);
  1501. void dp_rx_deliver_to_pkt_capture_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1502. uint32_t is_offload);
  1503. #else
  1504. static inline void
  1505. dp_rx_deliver_to_pkt_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  1506. uint16_t peer_id, uint32_t is_offload,
  1507. qdf_nbuf_t netbuf)
  1508. {
  1509. }
  1510. static inline void
  1511. dp_rx_deliver_to_pkt_capture_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1512. uint32_t is_offload)
  1513. {
  1514. }
  1515. #endif
  1516. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1517. #ifdef FEATURE_MEC
  1518. /**
  1519. * dp_rx_mcast_echo_check() - check if the mcast pkt is a loop
  1520. * back on same vap or a different vap.
  1521. * @soc: core DP main context
  1522. * @peer: dp peer handler
  1523. * @rx_tlv_hdr: start of the rx TLV header
  1524. * @nbuf: pkt buffer
  1525. *
  1526. * Return: bool (true if it is a looped back pkt else false)
  1527. *
  1528. */
  1529. bool dp_rx_mcast_echo_check(struct dp_soc *soc,
  1530. struct dp_peer *peer,
  1531. uint8_t *rx_tlv_hdr,
  1532. qdf_nbuf_t nbuf);
  1533. #else
  1534. static inline bool dp_rx_mcast_echo_check(struct dp_soc *soc,
  1535. struct dp_peer *peer,
  1536. uint8_t *rx_tlv_hdr,
  1537. qdf_nbuf_t nbuf)
  1538. {
  1539. return false;
  1540. }
  1541. #endif /* FEATURE_MEC */
  1542. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1543. #endif /* _DP_RX_H */