dp_rx.h 34 KB

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