dp_rx.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /*
  2. * Copyright (c) 2016-2018 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. #define RX_BUFFER_ALIGNMENT 128
  26. #else /* RXDMA_OPTIMIZATION */
  27. #define RX_BUFFER_ALIGNMENT 4
  28. #endif /* RXDMA_OPTIMIZATION */
  29. #define RX_BUFFER_SIZE 2048
  30. #define RX_BUFFER_RESERVATION 0
  31. #define DP_PEER_METADATA_PEER_ID_MASK 0x0000ffff
  32. #define DP_PEER_METADATA_PEER_ID_SHIFT 0
  33. #define DP_PEER_METADATA_VDEV_ID_MASK 0x00070000
  34. #define DP_PEER_METADATA_VDEV_ID_SHIFT 16
  35. #define DP_PEER_METADATA_PEER_ID_GET(_peer_metadata) \
  36. (((_peer_metadata) & DP_PEER_METADATA_PEER_ID_MASK) \
  37. >> DP_PEER_METADATA_PEER_ID_SHIFT)
  38. #define DP_PEER_METADATA_ID_GET(_peer_metadata) \
  39. (((_peer_metadata) & DP_PEER_METADATA_VDEV_ID_MASK) \
  40. >> DP_PEER_METADATA_VDEV_ID_SHIFT)
  41. #define DP_RX_DESC_MAGIC 0xdec0de
  42. /**
  43. * struct dp_rx_desc
  44. *
  45. * @nbuf : VA of the "skb" posted
  46. * @rx_buf_start : VA of the original Rx buffer, before
  47. * movement of any skb->data pointer
  48. * @cookie : index into the sw array which holds
  49. * the sw Rx descriptors
  50. * Cookie space is 21 bits:
  51. * lower 18 bits -- index
  52. * upper 3 bits -- pool_id
  53. * @pool_id : pool Id for which this allocated.
  54. * Can only be used if there is no flow
  55. * steering
  56. * @in_use rx_desc is in use
  57. * @unmapped used to mark rx_desc an unmapped if the corresponding
  58. * nbuf is already unmapped
  59. */
  60. struct dp_rx_desc {
  61. qdf_nbuf_t nbuf;
  62. uint8_t *rx_buf_start;
  63. uint32_t cookie;
  64. uint8_t pool_id;
  65. #ifdef RX_DESC_DEBUG_CHECK
  66. uint32_t magic;
  67. #endif
  68. uint8_t in_use:1,
  69. unmapped:1;
  70. };
  71. #define RX_DESC_COOKIE_INDEX_SHIFT 0
  72. #define RX_DESC_COOKIE_INDEX_MASK 0x3ffff /* 18 bits */
  73. #define RX_DESC_COOKIE_POOL_ID_SHIFT 18
  74. #define RX_DESC_COOKIE_POOL_ID_MASK 0x1c0000
  75. #define DP_RX_DESC_COOKIE_POOL_ID_GET(_cookie) \
  76. (((_cookie) & RX_DESC_COOKIE_POOL_ID_MASK) >> \
  77. RX_DESC_COOKIE_POOL_ID_SHIFT)
  78. #define DP_RX_DESC_COOKIE_INDEX_GET(_cookie) \
  79. (((_cookie) & RX_DESC_COOKIE_INDEX_MASK) >> \
  80. RX_DESC_COOKIE_INDEX_SHIFT)
  81. /*
  82. *dp_rx_xor_block() - xor block of data
  83. *@b: destination data block
  84. *@a: source data block
  85. *@len: length of the data to process
  86. *
  87. *Returns: None
  88. */
  89. static inline void dp_rx_xor_block(uint8_t *b, const uint8_t *a, qdf_size_t len)
  90. {
  91. qdf_size_t i;
  92. for (i = 0; i < len; i++)
  93. b[i] ^= a[i];
  94. }
  95. /*
  96. *dp_rx_rotl() - rotate the bits left
  97. *@val: unsigned integer input value
  98. *@bits: number of bits
  99. *
  100. *Returns: Integer with left rotated by number of 'bits'
  101. */
  102. static inline uint32_t dp_rx_rotl(uint32_t val, int bits)
  103. {
  104. return (val << bits) | (val >> (32 - bits));
  105. }
  106. /*
  107. *dp_rx_rotr() - rotate the bits right
  108. *@val: unsigned integer input value
  109. *@bits: number of bits
  110. *
  111. *Returns: Integer with right rotated by number of 'bits'
  112. */
  113. static inline uint32_t dp_rx_rotr(uint32_t val, int bits)
  114. {
  115. return (val >> bits) | (val << (32 - bits));
  116. }
  117. /*
  118. *dp_rx_xswap() - swap the bits left
  119. *@val: unsigned integer input value
  120. *
  121. *Returns: Integer with bits swapped
  122. */
  123. static inline uint32_t dp_rx_xswap(uint32_t val)
  124. {
  125. return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
  126. }
  127. /*
  128. *dp_rx_get_le32_split() - get little endian 32 bits split
  129. *@b0: byte 0
  130. *@b1: byte 1
  131. *@b2: byte 2
  132. *@b3: byte 3
  133. *
  134. *Returns: Integer with split little endian 32 bits
  135. */
  136. static inline uint32_t dp_rx_get_le32_split(uint8_t b0, uint8_t b1, uint8_t b2,
  137. uint8_t b3)
  138. {
  139. return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
  140. }
  141. /*
  142. *dp_rx_get_le32() - get little endian 32 bits
  143. *@b0: byte 0
  144. *@b1: byte 1
  145. *@b2: byte 2
  146. *@b3: byte 3
  147. *
  148. *Returns: Integer with little endian 32 bits
  149. */
  150. static inline uint32_t dp_rx_get_le32(const uint8_t *p)
  151. {
  152. return dp_rx_get_le32_split(p[0], p[1], p[2], p[3]);
  153. }
  154. /*
  155. * dp_rx_put_le32() - put little endian 32 bits
  156. * @p: destination char array
  157. * @v: source 32-bit integer
  158. *
  159. * Returns: None
  160. */
  161. static inline void dp_rx_put_le32(uint8_t *p, uint32_t v)
  162. {
  163. p[0] = (v) & 0xff;
  164. p[1] = (v >> 8) & 0xff;
  165. p[2] = (v >> 16) & 0xff;
  166. p[3] = (v >> 24) & 0xff;
  167. }
  168. /* Extract michal mic block of data */
  169. #define dp_rx_michael_block(l, r) \
  170. do { \
  171. r ^= dp_rx_rotl(l, 17); \
  172. l += r; \
  173. r ^= dp_rx_xswap(l); \
  174. l += r; \
  175. r ^= dp_rx_rotl(l, 3); \
  176. l += r; \
  177. r ^= dp_rx_rotr(l, 2); \
  178. l += r; \
  179. } while (0)
  180. /**
  181. * struct dp_rx_desc_list_elem_t
  182. *
  183. * @next : Next pointer to form free list
  184. * @rx_desc : DP Rx descriptor
  185. */
  186. union dp_rx_desc_list_elem_t {
  187. union dp_rx_desc_list_elem_t *next;
  188. struct dp_rx_desc rx_desc;
  189. };
  190. /**
  191. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  192. * the Rx descriptor on Rx DMA source ring buffer
  193. * @soc: core txrx main context
  194. * @cookie: cookie used to lookup virtual address
  195. *
  196. * Return: void *: Virtual Address of the Rx descriptor
  197. */
  198. static inline
  199. void *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc, uint32_t cookie)
  200. {
  201. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  202. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  203. /* TODO */
  204. /* Add sanity for pool_id & index */
  205. return &(soc->rx_desc_buf[pool_id].array[index].rx_desc);
  206. }
  207. /**
  208. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  209. * the Rx descriptor on monitor ring buffer
  210. * @soc: core txrx main context
  211. * @cookie: cookie used to lookup virtual address
  212. *
  213. * Return: void *: Virtual Address of the Rx descriptor
  214. */
  215. static inline
  216. void *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc, uint32_t cookie)
  217. {
  218. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  219. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  220. /* TODO */
  221. /* Add sanity for pool_id & index */
  222. return &(soc->rx_desc_mon[pool_id].array[index].rx_desc);
  223. }
  224. /**
  225. * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of
  226. * the Rx descriptor on monitor status ring buffer
  227. * @soc: core txrx main context
  228. * @cookie: cookie used to lookup virtual address
  229. *
  230. * Return: void *: Virtual Address of the Rx descriptor
  231. */
  232. static inline
  233. void *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc, uint32_t cookie)
  234. {
  235. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  236. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  237. /* TODO */
  238. /* Add sanity for pool_id & index */
  239. return &(soc->rx_desc_status[pool_id].array[index].rx_desc);
  240. }
  241. void dp_rx_add_desc_list_to_free_list(struct dp_soc *soc,
  242. union dp_rx_desc_list_elem_t **local_desc_list,
  243. union dp_rx_desc_list_elem_t **tail,
  244. uint16_t pool_id,
  245. struct rx_desc_pool *rx_desc_pool);
  246. uint16_t dp_rx_get_free_desc_list(struct dp_soc *soc, uint32_t pool_id,
  247. struct rx_desc_pool *rx_desc_pool,
  248. uint16_t num_descs,
  249. union dp_rx_desc_list_elem_t **desc_list,
  250. union dp_rx_desc_list_elem_t **tail);
  251. QDF_STATUS dp_rx_pdev_attach(struct dp_pdev *pdev);
  252. void dp_rx_pdev_detach(struct dp_pdev *pdev);
  253. uint32_t
  254. dp_rx_process(struct dp_intr *int_ctx, void *hal_ring, uint32_t quota);
  255. uint32_t dp_rx_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota);
  256. uint32_t
  257. dp_rx_wbm_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota);
  258. void
  259. dp_rx_sg_create(qdf_nbuf_t nbuf,
  260. uint8_t *rx_tlv_hdr,
  261. uint16_t *mpdu_len,
  262. bool *is_first_frag,
  263. uint16_t *frag_list_len,
  264. qdf_nbuf_t *head_frag_nbuf,
  265. qdf_nbuf_t *frag_list_head,
  266. qdf_nbuf_t *frag_list_tail);
  267. QDF_STATUS dp_rx_desc_pool_alloc(struct dp_soc *soc,
  268. uint32_t pool_id,
  269. uint32_t pool_size,
  270. struct rx_desc_pool *rx_desc_pool);
  271. void dp_rx_desc_pool_free(struct dp_soc *soc,
  272. uint32_t pool_id,
  273. struct rx_desc_pool *rx_desc_pool);
  274. void dp_rx_deliver_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf_list,
  275. struct dp_peer *peer);
  276. /**
  277. * dp_rx_add_to_free_desc_list() - Adds to a local free descriptor list
  278. *
  279. * @head: pointer to the head of local free list
  280. * @tail: pointer to the tail of local free list
  281. * @new: new descriptor that is added to the free list
  282. *
  283. * Return: void:
  284. */
  285. static inline
  286. void dp_rx_add_to_free_desc_list(union dp_rx_desc_list_elem_t **head,
  287. union dp_rx_desc_list_elem_t **tail,
  288. struct dp_rx_desc *new)
  289. {
  290. qdf_assert(head && new);
  291. new->nbuf = NULL;
  292. new->in_use = 0;
  293. new->unmapped = 0;
  294. ((union dp_rx_desc_list_elem_t *)new)->next = *head;
  295. *head = (union dp_rx_desc_list_elem_t *)new;
  296. if (*tail == NULL)
  297. *tail = *head;
  298. }
  299. /**
  300. * dp_rx_wds_srcport_learn() - Add or update the STA PEER which
  301. * is behind the WDS repeater.
  302. *
  303. * @soc: core txrx main context
  304. * @rx_tlv_hdr: base address of RX TLV header
  305. * @ta_peer: WDS repeater peer
  306. * @nbuf: rx pkt
  307. *
  308. * Return: void:
  309. */
  310. #ifdef FEATURE_WDS
  311. static inline void
  312. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  313. uint8_t *rx_tlv_hdr,
  314. struct dp_peer *ta_peer,
  315. qdf_nbuf_t nbuf)
  316. {
  317. uint16_t sa_sw_peer_id = hal_rx_msdu_end_sa_sw_peer_id_get(rx_tlv_hdr);
  318. uint32_t flags = IEEE80211_NODE_F_WDS_HM;
  319. uint32_t ret = 0;
  320. uint8_t wds_src_mac[IEEE80211_ADDR_LEN];
  321. /* Do wds source port learning only if it is a 4-address mpdu */
  322. if (!(qdf_nbuf_is_rx_chfrag_start(nbuf) &&
  323. hal_rx_get_mpdu_mac_ad4_valid(rx_tlv_hdr)))
  324. return;
  325. memcpy(wds_src_mac, (qdf_nbuf_data(nbuf) + IEEE80211_ADDR_LEN),
  326. IEEE80211_ADDR_LEN);
  327. if (qdf_unlikely(!hal_rx_msdu_end_sa_is_valid_get(rx_tlv_hdr))) {
  328. ret = dp_peer_add_ast(soc,
  329. ta_peer,
  330. wds_src_mac,
  331. CDP_TXRX_AST_TYPE_WDS,
  332. flags);
  333. } else {
  334. /*
  335. * Get the AST entry from HW SA index and mark it as active
  336. */
  337. struct dp_ast_entry *ast;
  338. uint16_t sa_idx = hal_rx_msdu_end_sa_idx_get(rx_tlv_hdr);
  339. ast = soc->ast_table[sa_idx];
  340. /*
  341. * Ensure we are updating the right AST entry by
  342. * validating ast_idx.
  343. * There is a possibility we might arrive here without
  344. * AST MAP event , so this check is mandatory
  345. */
  346. if (ast && (ast->ast_idx == sa_idx)) {
  347. ast->is_active = TRUE;
  348. }
  349. if (ast && sa_sw_peer_id != ta_peer->peer_ids[0])
  350. dp_peer_update_ast(soc, ta_peer, ast, flags);
  351. }
  352. return;
  353. }
  354. #else
  355. static inline void
  356. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  357. uint8_t *rx_tlv_hdr,
  358. struct dp_peer *ta_peer,
  359. qdf_nbuf_t nbuf)
  360. {
  361. }
  362. #endif
  363. uint8_t dp_rx_process_invalid_peer(struct dp_soc *soc, qdf_nbuf_t nbuf);
  364. void dp_rx_process_invalid_peer_wrapper(struct dp_soc *soc,
  365. qdf_nbuf_t mpdu, bool mpdu_done);
  366. void dp_rx_process_mic_error(struct dp_soc *soc, qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr);
  367. #define DP_RX_LIST_APPEND(head, tail, elem) \
  368. do { \
  369. if (!(head)) { \
  370. (head) = (elem); \
  371. } else { \
  372. qdf_nbuf_set_next((tail), (elem)); \
  373. } \
  374. (tail) = (elem); \
  375. qdf_nbuf_set_next((tail), NULL); \
  376. } while (0)
  377. #ifndef BUILD_X86
  378. static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf,
  379. qdf_dma_addr_t *paddr, struct dp_pdev *pdev)
  380. {
  381. return QDF_STATUS_SUCCESS;
  382. }
  383. #else
  384. #define MAX_RETRY 100
  385. static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf,
  386. qdf_dma_addr_t *paddr, struct dp_pdev *pdev)
  387. {
  388. uint32_t nbuf_retry = 0;
  389. int32_t ret;
  390. const uint32_t x86_phy_addr = 0x50000000;
  391. /*
  392. * in M2M emulation platforms (x86) the memory below 0x50000000
  393. * is reserved for target use, so any memory allocated in this
  394. * region should not be used by host
  395. */
  396. do {
  397. if (qdf_likely(*paddr > x86_phy_addr))
  398. return QDF_STATUS_SUCCESS;
  399. else {
  400. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  401. "phy addr %pK exceded 0x50000000 trying again\n",
  402. paddr);
  403. nbuf_retry++;
  404. if ((*rx_netbuf)) {
  405. qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf,
  406. QDF_DMA_BIDIRECTIONAL);
  407. /* Not freeing buffer intentionally.
  408. * Observed that same buffer is getting
  409. * re-allocated resulting in longer load time
  410. * WMI init timeout.
  411. * This buffer is anyway not useful so skip it.
  412. **/
  413. }
  414. *rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev,
  415. RX_BUFFER_SIZE,
  416. RX_BUFFER_RESERVATION,
  417. RX_BUFFER_ALIGNMENT,
  418. FALSE);
  419. if (qdf_unlikely(!(*rx_netbuf)))
  420. return QDF_STATUS_E_FAILURE;
  421. ret = qdf_nbuf_map_single(dp_soc->osdev, *rx_netbuf,
  422. QDF_DMA_BIDIRECTIONAL);
  423. if (qdf_unlikely(ret == QDF_STATUS_E_FAILURE)) {
  424. qdf_nbuf_free(*rx_netbuf);
  425. *rx_netbuf = NULL;
  426. continue;
  427. }
  428. *paddr = qdf_nbuf_get_frag_paddr(*rx_netbuf, 0);
  429. }
  430. } while (nbuf_retry < MAX_RETRY);
  431. if ((*rx_netbuf)) {
  432. qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf,
  433. QDF_DMA_BIDIRECTIONAL);
  434. qdf_nbuf_free(*rx_netbuf);
  435. }
  436. return QDF_STATUS_E_FAILURE;
  437. }
  438. #endif
  439. /**
  440. * dp_rx_cookie_2_link_desc_va() - Converts cookie to a virtual address of
  441. * the MSDU Link Descriptor
  442. * @soc: core txrx main context
  443. * @buf_info: buf_info include cookie that used to lookup virtual address of
  444. * link descriptor Normally this is just an index into a per SOC array.
  445. *
  446. * This is the VA of the link descriptor, that HAL layer later uses to
  447. * retrieve the list of MSDU's for a given MPDU.
  448. *
  449. * Return: void *: Virtual Address of the Rx descriptor
  450. */
  451. static inline
  452. void *dp_rx_cookie_2_link_desc_va(struct dp_soc *soc,
  453. struct hal_buf_info *buf_info)
  454. {
  455. void *link_desc_va;
  456. uint32_t bank_id = LINK_DESC_COOKIE_BANK_ID(buf_info->sw_cookie);
  457. /* TODO */
  458. /* Add sanity for cookie */
  459. link_desc_va = soc->link_desc_banks[bank_id].base_vaddr +
  460. (buf_info->paddr -
  461. soc->link_desc_banks[bank_id].base_paddr);
  462. return link_desc_va;
  463. }
  464. /**
  465. * dp_rx_cookie_2_mon_link_desc_va() - Converts cookie to a virtual address of
  466. * the MSDU Link Descriptor
  467. * @pdev: core txrx pdev context
  468. * @buf_info: buf_info includes cookie that used to lookup virtual address of
  469. * link descriptor. Normally this is just an index into a per pdev array.
  470. *
  471. * This is the VA of the link descriptor in monitor mode destination ring,
  472. * that HAL layer later uses to retrieve the list of MSDU's for a given MPDU.
  473. *
  474. * Return: void *: Virtual Address of the Rx descriptor
  475. */
  476. static inline
  477. void *dp_rx_cookie_2_mon_link_desc_va(struct dp_pdev *pdev,
  478. struct hal_buf_info *buf_info,
  479. int mac_id)
  480. {
  481. void *link_desc_va;
  482. int mac_for_pdev = dp_get_mac_id_for_mac(pdev->soc, mac_id);
  483. /* TODO */
  484. /* Add sanity for cookie */
  485. link_desc_va =
  486. pdev->link_desc_banks[mac_for_pdev][buf_info->sw_cookie].base_vaddr +
  487. (buf_info->paddr -
  488. pdev->link_desc_banks[mac_for_pdev][buf_info->sw_cookie].base_paddr);
  489. return link_desc_va;
  490. }
  491. /**
  492. * dp_rx_defrag_concat() - Concatenate the fragments
  493. *
  494. * @dst: destination pointer to the buffer
  495. * @src: source pointer from where the fragment payload is to be copied
  496. *
  497. * Return: QDF_STATUS
  498. */
  499. static inline QDF_STATUS dp_rx_defrag_concat(qdf_nbuf_t dst, qdf_nbuf_t src)
  500. {
  501. /*
  502. * Inside qdf_nbuf_cat, if it is necessary to reallocate dst
  503. * to provide space for src, the headroom portion is copied from
  504. * the original dst buffer to the larger new dst buffer.
  505. * (This is needed, because the headroom of the dst buffer
  506. * contains the rx desc.)
  507. */
  508. if (qdf_nbuf_cat(dst, src))
  509. return QDF_STATUS_E_DEFRAG_ERROR;
  510. return QDF_STATUS_SUCCESS;
  511. }
  512. /*
  513. * dp_rx_ast_set_active() - set the active flag of the astentry
  514. * corresponding to a hw index.
  515. * @soc: core txrx main context
  516. * @sa_idx: hw idx
  517. * @is_active: active flag
  518. *
  519. */
  520. #ifdef FEATURE_WDS
  521. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
  522. {
  523. struct dp_ast_entry *ast;
  524. qdf_spin_lock_bh(&soc->ast_lock);
  525. ast = soc->ast_table[sa_idx];
  526. /*
  527. * Ensure we are updating the right AST entry by
  528. * validating ast_idx.
  529. * There is a possibility we might arrive here without
  530. * AST MAP event , so this check is mandatory
  531. */
  532. if (ast && (ast->ast_idx == sa_idx)) {
  533. ast->is_active = is_active;
  534. qdf_spin_unlock_bh(&soc->ast_lock);
  535. return QDF_STATUS_SUCCESS;
  536. }
  537. qdf_spin_unlock_bh(&soc->ast_lock);
  538. return QDF_STATUS_E_FAILURE;
  539. }
  540. #else
  541. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
  542. {
  543. return QDF_STATUS_SUCCESS;
  544. }
  545. #endif
  546. /*
  547. * check_qwrap_multicast_loopback() - Check if rx packet is a loopback packet.
  548. * In qwrap mode, packets originated from
  549. * any vdev should not loopback and
  550. * should be dropped.
  551. * @vdev: vdev on which rx packet is received
  552. * @nbuf: rx pkt
  553. *
  554. */
  555. #if ATH_SUPPORT_WRAP
  556. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  557. qdf_nbuf_t nbuf)
  558. {
  559. struct dp_vdev *psta_vdev;
  560. struct dp_pdev *pdev = vdev->pdev;
  561. uint8_t *data = qdf_nbuf_data(nbuf);
  562. if (qdf_unlikely(vdev->proxysta_vdev)) {
  563. /* In qwrap isolation mode, allow loopback packets as all
  564. * packets go to RootAP and Loopback on the mpsta.
  565. */
  566. if (vdev->isolation_vdev)
  567. return false;
  568. TAILQ_FOREACH(psta_vdev, &pdev->vdev_list, vdev_list_elem) {
  569. if (qdf_unlikely(psta_vdev->proxysta_vdev &&
  570. !qdf_mem_cmp(psta_vdev->mac_addr.raw,
  571. &data[DP_MAC_ADDR_LEN], DP_MAC_ADDR_LEN))) {
  572. /* Drop packet if source address is equal to
  573. * any of the vdev addresses.
  574. */
  575. return true;
  576. }
  577. }
  578. }
  579. return false;
  580. }
  581. #else
  582. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  583. qdf_nbuf_t nbuf)
  584. {
  585. return false;
  586. }
  587. #endif
  588. /*
  589. * dp_rx_buffers_replenish() - replenish rxdma ring with rx nbufs
  590. * called during dp rx initialization
  591. * and at the end of dp_rx_process.
  592. *
  593. * @soc: core txrx main context
  594. * @mac_id: mac_id which is one of 3 mac_ids
  595. * @dp_rxdma_srng: dp rxdma circular ring
  596. * @rx_desc_pool: Poiter to free Rx descriptor pool
  597. * @num_req_buffers: number of buffer to be replenished
  598. * @desc_list: list of descs if called from dp_rx_process
  599. * or NULL during dp rx initialization or out of buffer
  600. * interrupt.
  601. * @tail: tail of descs list
  602. * @owner: who owns the nbuf (host, NSS etc...)
  603. * Return: return success or failure
  604. */
  605. QDF_STATUS dp_rx_buffers_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  606. struct dp_srng *dp_rxdma_srng,
  607. struct rx_desc_pool *rx_desc_pool,
  608. uint32_t num_req_buffers,
  609. union dp_rx_desc_list_elem_t **desc_list,
  610. union dp_rx_desc_list_elem_t **tail,
  611. uint8_t owner);
  612. /**
  613. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  614. * (WBM), following error handling
  615. *
  616. * @soc: core DP main context
  617. * @buf_addr_info: opaque pointer to the REO error ring descriptor
  618. * @buf_addr_info: void pointer to the buffer_addr_info
  619. * @bm_action: put to idle_list or release to msdu_list
  620. * Return: QDF_STATUS
  621. */
  622. QDF_STATUS
  623. dp_rx_link_desc_return(struct dp_soc *soc, void *ring_desc, uint8_t bm_action);
  624. QDF_STATUS
  625. dp_rx_link_desc_buf_return(struct dp_soc *soc, struct dp_srng *dp_rxdma_srng,
  626. void *buf_addr_info, uint8_t bm_action);
  627. /**
  628. * dp_rx_link_desc_return_by_addr - Return a MPDU link descriptor to
  629. * (WBM) by address
  630. *
  631. * @soc: core DP main context
  632. * @link_desc_addr: link descriptor addr
  633. *
  634. * Return: QDF_STATUS
  635. */
  636. QDF_STATUS
  637. dp_rx_link_desc_return_by_addr(struct dp_soc *soc, void *link_desc_addr,
  638. uint8_t bm_action);
  639. uint32_t
  640. dp_rxdma_err_process(struct dp_soc *soc, uint32_t mac_id,
  641. uint32_t quota);
  642. void dp_rx_fill_mesh_stats(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  643. uint8_t *rx_tlv_hdr, struct dp_peer *peer);
  644. QDF_STATUS dp_rx_filter_mesh_packets(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  645. uint8_t *rx_tlv_hdr);
  646. int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr, struct dp_vdev *vdev,
  647. struct dp_peer *peer, int rx_mcast);
  648. qdf_nbuf_t
  649. dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev);
  650. #endif /* _DP_RX_H */