dp_rx.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322
  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. #define RX_DESC_COOKIE_INDEX_SHIFT 0
  93. #define RX_DESC_COOKIE_INDEX_MASK 0x3ffff /* 18 bits */
  94. #define RX_DESC_COOKIE_POOL_ID_SHIFT 18
  95. #define RX_DESC_COOKIE_POOL_ID_MASK 0x1c0000
  96. #define DP_RX_DESC_COOKIE_MAX \
  97. (RX_DESC_COOKIE_INDEX_MASK | RX_DESC_COOKIE_POOL_ID_MASK)
  98. #define DP_RX_DESC_COOKIE_POOL_ID_GET(_cookie) \
  99. (((_cookie) & RX_DESC_COOKIE_POOL_ID_MASK) >> \
  100. RX_DESC_COOKIE_POOL_ID_SHIFT)
  101. #define DP_RX_DESC_COOKIE_INDEX_GET(_cookie) \
  102. (((_cookie) & RX_DESC_COOKIE_INDEX_MASK) >> \
  103. RX_DESC_COOKIE_INDEX_SHIFT)
  104. /* DOC: Offset to obtain LLC hdr
  105. *
  106. * In the case of Wifi parse error
  107. * to reach LLC header from beginning
  108. * of VLAN tag we need to skip 8 bytes.
  109. * Vlan_tag(4)+length(2)+length added
  110. * by HW(2) = 8 bytes.
  111. */
  112. #define DP_SKIP_VLAN 8
  113. /**
  114. * struct dp_rx_cached_buf - rx cached buffer
  115. * @list: linked list node
  116. * @buf: skb buffer
  117. */
  118. struct dp_rx_cached_buf {
  119. qdf_list_node_t node;
  120. qdf_nbuf_t buf;
  121. };
  122. /*
  123. *dp_rx_xor_block() - xor block of data
  124. *@b: destination data block
  125. *@a: source data block
  126. *@len: length of the data to process
  127. *
  128. *Returns: None
  129. */
  130. static inline void dp_rx_xor_block(uint8_t *b, const uint8_t *a, qdf_size_t len)
  131. {
  132. qdf_size_t i;
  133. for (i = 0; i < len; i++)
  134. b[i] ^= a[i];
  135. }
  136. /*
  137. *dp_rx_rotl() - rotate the bits left
  138. *@val: unsigned integer input value
  139. *@bits: number of bits
  140. *
  141. *Returns: Integer with left rotated by number of 'bits'
  142. */
  143. static inline uint32_t dp_rx_rotl(uint32_t val, int bits)
  144. {
  145. return (val << bits) | (val >> (32 - bits));
  146. }
  147. /*
  148. *dp_rx_rotr() - rotate the bits right
  149. *@val: unsigned integer input value
  150. *@bits: number of bits
  151. *
  152. *Returns: Integer with right rotated by number of 'bits'
  153. */
  154. static inline uint32_t dp_rx_rotr(uint32_t val, int bits)
  155. {
  156. return (val >> bits) | (val << (32 - bits));
  157. }
  158. /*
  159. * dp_set_rx_queue() - set queue_mapping in skb
  160. * @nbuf: skb
  161. * @queue_id: rx queue_id
  162. *
  163. * Return: void
  164. */
  165. #ifdef QCA_OL_RX_MULTIQ_SUPPORT
  166. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  167. {
  168. qdf_nbuf_record_rx_queue(nbuf, queue_id);
  169. return;
  170. }
  171. #else
  172. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  173. {
  174. }
  175. #endif
  176. /*
  177. *dp_rx_xswap() - swap the bits left
  178. *@val: unsigned integer input value
  179. *
  180. *Returns: Integer with bits swapped
  181. */
  182. static inline uint32_t dp_rx_xswap(uint32_t val)
  183. {
  184. return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
  185. }
  186. /*
  187. *dp_rx_get_le32_split() - get little endian 32 bits split
  188. *@b0: byte 0
  189. *@b1: byte 1
  190. *@b2: byte 2
  191. *@b3: byte 3
  192. *
  193. *Returns: Integer with split little endian 32 bits
  194. */
  195. static inline uint32_t dp_rx_get_le32_split(uint8_t b0, uint8_t b1, uint8_t b2,
  196. uint8_t b3)
  197. {
  198. return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
  199. }
  200. /*
  201. *dp_rx_get_le32() - get little endian 32 bits
  202. *@b0: byte 0
  203. *@b1: byte 1
  204. *@b2: byte 2
  205. *@b3: byte 3
  206. *
  207. *Returns: Integer with little endian 32 bits
  208. */
  209. static inline uint32_t dp_rx_get_le32(const uint8_t *p)
  210. {
  211. return dp_rx_get_le32_split(p[0], p[1], p[2], p[3]);
  212. }
  213. /*
  214. * dp_rx_put_le32() - put little endian 32 bits
  215. * @p: destination char array
  216. * @v: source 32-bit integer
  217. *
  218. * Returns: None
  219. */
  220. static inline void dp_rx_put_le32(uint8_t *p, uint32_t v)
  221. {
  222. p[0] = (v) & 0xff;
  223. p[1] = (v >> 8) & 0xff;
  224. p[2] = (v >> 16) & 0xff;
  225. p[3] = (v >> 24) & 0xff;
  226. }
  227. /* Extract michal mic block of data */
  228. #define dp_rx_michael_block(l, r) \
  229. do { \
  230. r ^= dp_rx_rotl(l, 17); \
  231. l += r; \
  232. r ^= dp_rx_xswap(l); \
  233. l += r; \
  234. r ^= dp_rx_rotl(l, 3); \
  235. l += r; \
  236. r ^= dp_rx_rotr(l, 2); \
  237. l += r; \
  238. } while (0)
  239. /**
  240. * struct dp_rx_desc_list_elem_t
  241. *
  242. * @next : Next pointer to form free list
  243. * @rx_desc : DP Rx descriptor
  244. */
  245. union dp_rx_desc_list_elem_t {
  246. union dp_rx_desc_list_elem_t *next;
  247. struct dp_rx_desc rx_desc;
  248. };
  249. /**
  250. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  251. * the Rx descriptor on Rx DMA source ring buffer
  252. * @soc: core txrx main context
  253. * @cookie: cookie used to lookup virtual address
  254. *
  255. * Return: void *: Virtual Address of the Rx descriptor
  256. */
  257. static inline
  258. void *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc, uint32_t cookie)
  259. {
  260. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  261. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  262. struct rx_desc_pool *rx_desc_pool;
  263. if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS))
  264. return NULL;
  265. rx_desc_pool = &soc->rx_desc_buf[pool_id];
  266. if (qdf_unlikely(index >= rx_desc_pool->pool_size))
  267. return NULL;
  268. return &(soc->rx_desc_buf[pool_id].array[index].rx_desc);
  269. }
  270. /**
  271. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  272. * the Rx descriptor on monitor ring buffer
  273. * @soc: core txrx main context
  274. * @cookie: cookie used to lookup virtual address
  275. *
  276. * Return: void *: Virtual Address of the Rx descriptor
  277. */
  278. static inline
  279. void *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc, uint32_t cookie)
  280. {
  281. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  282. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  283. /* TODO */
  284. /* Add sanity for pool_id & index */
  285. return &(soc->rx_desc_mon[pool_id].array[index].rx_desc);
  286. }
  287. /**
  288. * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of
  289. * the Rx descriptor on monitor status ring buffer
  290. * @soc: core txrx main context
  291. * @cookie: cookie used to lookup virtual address
  292. *
  293. * Return: void *: Virtual Address of the Rx descriptor
  294. */
  295. static inline
  296. void *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc, uint32_t cookie)
  297. {
  298. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  299. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  300. /* TODO */
  301. /* Add sanity for pool_id & index */
  302. return &(soc->rx_desc_status[pool_id].array[index].rx_desc);
  303. }
  304. void dp_rx_add_desc_list_to_free_list(struct dp_soc *soc,
  305. union dp_rx_desc_list_elem_t **local_desc_list,
  306. union dp_rx_desc_list_elem_t **tail,
  307. uint16_t pool_id,
  308. struct rx_desc_pool *rx_desc_pool);
  309. uint16_t dp_rx_get_free_desc_list(struct dp_soc *soc, uint32_t pool_id,
  310. struct rx_desc_pool *rx_desc_pool,
  311. uint16_t num_descs,
  312. union dp_rx_desc_list_elem_t **desc_list,
  313. union dp_rx_desc_list_elem_t **tail);
  314. QDF_STATUS dp_rx_pdev_attach(struct dp_pdev *pdev);
  315. void dp_rx_pdev_detach(struct dp_pdev *pdev);
  316. uint32_t
  317. dp_rx_process(struct dp_intr *int_ctx, void *hal_ring, uint8_t reo_ring_num,
  318. uint32_t quota);
  319. uint32_t dp_rx_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota);
  320. uint32_t
  321. dp_rx_wbm_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota);
  322. /**
  323. * dp_rx_sg_create() - create a frag_list for MSDUs which are spread across
  324. * multiple nbufs.
  325. * @nbuf: pointer to the first msdu of an amsdu.
  326. * @rx_tlv_hdr: pointer to the start of RX TLV headers.
  327. *
  328. * This function implements the creation of RX frag_list for cases
  329. * where an MSDU is spread across multiple nbufs.
  330. *
  331. * Return: returns the head nbuf which contains complete frag_list.
  332. */
  333. qdf_nbuf_t dp_rx_sg_create(qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr);
  334. QDF_STATUS dp_rx_desc_pool_alloc(struct dp_soc *soc,
  335. uint32_t pool_id,
  336. uint32_t pool_size,
  337. struct rx_desc_pool *rx_desc_pool);
  338. void dp_rx_desc_pool_free(struct dp_soc *soc,
  339. uint32_t pool_id,
  340. struct rx_desc_pool *rx_desc_pool);
  341. void dp_rx_desc_nbuf_pool_free(struct dp_soc *soc,
  342. struct rx_desc_pool *rx_desc_pool);
  343. void dp_rx_desc_free_array(struct dp_soc *soc,
  344. struct rx_desc_pool *rx_desc_pool);
  345. void dp_rx_deliver_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf_list,
  346. struct dp_peer *peer);
  347. /**
  348. * dp_rx_add_to_free_desc_list() - Adds to a local free descriptor list
  349. *
  350. * @head: pointer to the head of local free list
  351. * @tail: pointer to the tail of local free list
  352. * @new: new descriptor that is added to the free list
  353. *
  354. * Return: void:
  355. */
  356. static inline
  357. void dp_rx_add_to_free_desc_list(union dp_rx_desc_list_elem_t **head,
  358. union dp_rx_desc_list_elem_t **tail,
  359. struct dp_rx_desc *new)
  360. {
  361. qdf_assert(head && new);
  362. new->nbuf = NULL;
  363. new->in_use = 0;
  364. ((union dp_rx_desc_list_elem_t *)new)->next = *head;
  365. *head = (union dp_rx_desc_list_elem_t *)new;
  366. if (!*tail)
  367. *tail = *head;
  368. }
  369. /**
  370. * dp_rx_wds_add_or_update_ast() - Add or update the ast entry.
  371. *
  372. * @soc: core txrx main context
  373. * @ta_peer: WDS repeater peer
  374. * @mac_addr: mac address of the peer
  375. * @is_ad4_valid: 4-address valid flag
  376. * @is_sa_valid: source address valid flag
  377. * @is_chfrag_start: frag start flag
  378. * @sa_idx: source-address index for peer
  379. * @sa_sw_peer_id: software source-address peer-id
  380. *
  381. * Return: void:
  382. */
  383. #ifdef FEATURE_WDS
  384. static inline void
  385. dp_rx_wds_add_or_update_ast(struct dp_soc *soc, struct dp_peer *ta_peer,
  386. qdf_nbuf_t nbuf, uint8_t is_ad4_valid,
  387. uint8_t is_sa_valid, uint8_t is_chfrag_start,
  388. uint16_t sa_idx, uint16_t sa_sw_peer_id)
  389. {
  390. struct dp_peer *sa_peer;
  391. struct dp_ast_entry *ast;
  392. uint32_t flags = IEEE80211_NODE_F_WDS_HM;
  393. uint32_t ret = 0;
  394. struct dp_neighbour_peer *neighbour_peer = NULL;
  395. struct dp_pdev *pdev = ta_peer->vdev->pdev;
  396. uint8_t wds_src_mac[QDF_MAC_ADDR_SIZE];
  397. /* For AP mode : Do wds source port learning only if it is a
  398. * 4-address mpdu
  399. *
  400. * For STA mode : Frames from RootAP backend will be in 3-address mode,
  401. * till RootAP does the WDS source port learning; Hence in repeater/STA
  402. * mode, we enable learning even in 3-address mode , to avoid RootAP
  403. * backbone getting wrongly learnt as MEC on repeater
  404. */
  405. if (ta_peer->vdev->opmode != wlan_op_mode_sta) {
  406. if (!(is_chfrag_start && is_ad4_valid))
  407. return;
  408. } else {
  409. /* For HKv2 Source port learing is not needed in STA mode
  410. * as we have support in HW
  411. */
  412. if (soc->ast_override_support)
  413. return;
  414. }
  415. if (qdf_unlikely(!is_sa_valid)) {
  416. qdf_mem_copy(wds_src_mac,
  417. (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
  418. QDF_MAC_ADDR_SIZE);
  419. ret = dp_peer_add_ast(soc,
  420. ta_peer,
  421. wds_src_mac,
  422. CDP_TXRX_AST_TYPE_WDS,
  423. flags);
  424. return;
  425. }
  426. qdf_spin_lock_bh(&soc->ast_lock);
  427. ast = soc->ast_table[sa_idx];
  428. qdf_spin_unlock_bh(&soc->ast_lock);
  429. if (!ast) {
  430. /*
  431. * In HKv1, it is possible that HW retains the AST entry in
  432. * GSE cache on 1 radio , even after the AST entry is deleted
  433. * (on another radio).
  434. *
  435. * Due to this, host might still get sa_is_valid indications
  436. * for frames with SA not really present in AST table.
  437. *
  438. * So we go ahead and send an add_ast command to FW in such
  439. * cases where sa is reported still as valid, so that FW will
  440. * invalidate this GSE cache entry and new AST entry gets
  441. * cached.
  442. */
  443. if (!soc->ast_override_support) {
  444. qdf_mem_copy(wds_src_mac,
  445. (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
  446. QDF_MAC_ADDR_SIZE);
  447. ret = dp_peer_add_ast(soc,
  448. ta_peer,
  449. wds_src_mac,
  450. CDP_TXRX_AST_TYPE_WDS,
  451. flags);
  452. return;
  453. } else {
  454. /* In HKv2 smart monitor case, when NAC client is
  455. * added first and this client roams within BSS to
  456. * connect to RE, since we have an AST entry for
  457. * NAC we get sa_is_valid bit set. So we check if
  458. * smart monitor is enabled and send add_ast command
  459. * to FW.
  460. */
  461. if (pdev->neighbour_peers_added) {
  462. qdf_mem_copy(wds_src_mac,
  463. (qdf_nbuf_data(nbuf) +
  464. QDF_MAC_ADDR_SIZE),
  465. QDF_MAC_ADDR_SIZE);
  466. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  467. TAILQ_FOREACH(neighbour_peer,
  468. &pdev->neighbour_peers_list,
  469. neighbour_peer_list_elem) {
  470. if (!qdf_mem_cmp(&neighbour_peer->neighbour_peers_macaddr,
  471. wds_src_mac,
  472. QDF_MAC_ADDR_SIZE)) {
  473. ret = dp_peer_add_ast(soc,
  474. ta_peer,
  475. wds_src_mac,
  476. CDP_TXRX_AST_TYPE_WDS,
  477. flags);
  478. QDF_TRACE(QDF_MODULE_ID_DP,
  479. QDF_TRACE_LEVEL_INFO,
  480. "sa valid and nac roamed to wds");
  481. break;
  482. }
  483. }
  484. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  485. }
  486. return;
  487. }
  488. }
  489. if ((ast->type == CDP_TXRX_AST_TYPE_WDS_HM) ||
  490. (ast->type == CDP_TXRX_AST_TYPE_WDS_HM_SEC))
  491. return;
  492. /*
  493. * Ensure we are updating the right AST entry by
  494. * validating ast_idx.
  495. * There is a possibility we might arrive here without
  496. * AST MAP event , so this check is mandatory
  497. */
  498. if (ast->is_mapped && (ast->ast_idx == sa_idx))
  499. ast->is_active = TRUE;
  500. if (sa_sw_peer_id != ta_peer->peer_ids[0]) {
  501. sa_peer = ast->peer;
  502. if ((ast->type != CDP_TXRX_AST_TYPE_STATIC) &&
  503. (ast->type != CDP_TXRX_AST_TYPE_SELF) &&
  504. (ast->type != CDP_TXRX_AST_TYPE_STA_BSS)) {
  505. if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
  506. /* This case is when a STA roams from one
  507. * repeater to another repeater, but these
  508. * repeaters are connected to root AP on
  509. * different radios.
  510. * Ex: rptr1 connected to ROOT AP over 5G
  511. * and rptr2 connected to ROOT AP over 2G
  512. * radio
  513. */
  514. qdf_spin_lock_bh(&soc->ast_lock);
  515. dp_peer_del_ast(soc, ast);
  516. qdf_spin_unlock_bh(&soc->ast_lock);
  517. } else {
  518. /* this case is when a STA roams from one
  519. * reapter to another repeater, but inside
  520. * same radio.
  521. */
  522. qdf_spin_lock_bh(&soc->ast_lock);
  523. dp_peer_update_ast(soc, ta_peer, ast, flags);
  524. qdf_spin_unlock_bh(&soc->ast_lock);
  525. return;
  526. }
  527. }
  528. /*
  529. * Do not kickout STA if it belongs to a different radio.
  530. * For DBDC repeater, it is possible to arrive here
  531. * for multicast loopback frames originated from connected
  532. * clients and looped back (intrabss) by Root AP
  533. */
  534. if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
  535. return;
  536. }
  537. /*
  538. * Kickout, when direct associated peer(SA) roams
  539. * to another AP and reachable via TA peer
  540. */
  541. if ((sa_peer->vdev->opmode == wlan_op_mode_ap) &&
  542. !sa_peer->delete_in_progress) {
  543. sa_peer->delete_in_progress = true;
  544. if (soc->cdp_soc.ol_ops->peer_sta_kickout) {
  545. soc->cdp_soc.ol_ops->peer_sta_kickout(
  546. sa_peer->vdev->pdev->ctrl_pdev,
  547. wds_src_mac);
  548. }
  549. }
  550. }
  551. }
  552. /**
  553. * dp_rx_wds_srcport_learn() - Add or update the STA PEER which
  554. * is behind the WDS repeater.
  555. *
  556. * @soc: core txrx main context
  557. * @rx_tlv_hdr: base address of RX TLV header
  558. * @ta_peer: WDS repeater peer
  559. * @nbuf: rx pkt
  560. *
  561. * Return: void:
  562. */
  563. static inline void
  564. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  565. uint8_t *rx_tlv_hdr,
  566. struct dp_peer *ta_peer,
  567. qdf_nbuf_t nbuf)
  568. {
  569. uint16_t sa_sw_peer_id = hal_rx_msdu_end_sa_sw_peer_id_get(rx_tlv_hdr);
  570. uint8_t sa_is_valid = hal_rx_msdu_end_sa_is_valid_get(rx_tlv_hdr);
  571. uint16_t sa_idx;
  572. uint8_t is_chfrag_start = 0;
  573. uint8_t is_ad4_valid = 0;
  574. if (qdf_unlikely(!ta_peer))
  575. return;
  576. is_chfrag_start = qdf_nbuf_is_rx_chfrag_start(nbuf);
  577. if (is_chfrag_start)
  578. is_ad4_valid = hal_rx_get_mpdu_mac_ad4_valid(rx_tlv_hdr);
  579. /*
  580. * Get the AST entry from HW SA index and mark it as active
  581. */
  582. sa_idx = hal_rx_msdu_end_sa_idx_get(rx_tlv_hdr);
  583. dp_rx_wds_add_or_update_ast(soc, ta_peer, nbuf, is_ad4_valid,
  584. sa_is_valid, is_chfrag_start,
  585. sa_idx, sa_sw_peer_id);
  586. return;
  587. }
  588. #else
  589. static inline void
  590. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  591. uint8_t *rx_tlv_hdr,
  592. struct dp_peer *ta_peer,
  593. qdf_nbuf_t nbuf)
  594. {
  595. }
  596. #endif
  597. uint8_t dp_rx_process_invalid_peer(struct dp_soc *soc, qdf_nbuf_t nbuf);
  598. void dp_rx_process_invalid_peer_wrapper(struct dp_soc *soc,
  599. qdf_nbuf_t mpdu, bool mpdu_done);
  600. void dp_rx_process_mic_error(struct dp_soc *soc, qdf_nbuf_t nbuf,
  601. uint8_t *rx_tlv_hdr, struct dp_peer *peer);
  602. void dp_2k_jump_handle(struct dp_soc *soc, qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  603. uint16_t peer_id, uint8_t tid);
  604. #define DP_RX_LIST_APPEND(head, tail, elem) \
  605. do { \
  606. if (!(head)) { \
  607. (head) = (elem); \
  608. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head) = 1;\
  609. } else { \
  610. qdf_nbuf_set_next((tail), (elem)); \
  611. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head)++; \
  612. } \
  613. (tail) = (elem); \
  614. qdf_nbuf_set_next((tail), NULL); \
  615. } while (0)
  616. #ifndef BUILD_X86
  617. static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf,
  618. qdf_dma_addr_t *paddr, struct dp_pdev *pdev)
  619. {
  620. return QDF_STATUS_SUCCESS;
  621. }
  622. #else
  623. #define MAX_RETRY 100
  624. static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf,
  625. qdf_dma_addr_t *paddr, struct dp_pdev *pdev)
  626. {
  627. uint32_t nbuf_retry = 0;
  628. int32_t ret;
  629. const uint32_t x86_phy_addr = 0x50000000;
  630. /*
  631. * in M2M emulation platforms (x86) the memory below 0x50000000
  632. * is reserved for target use, so any memory allocated in this
  633. * region should not be used by host
  634. */
  635. do {
  636. if (qdf_likely(*paddr > x86_phy_addr))
  637. return QDF_STATUS_SUCCESS;
  638. else {
  639. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  640. "phy addr %pK exceeded 0x50000000 trying again",
  641. paddr);
  642. nbuf_retry++;
  643. if ((*rx_netbuf)) {
  644. qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf,
  645. QDF_DMA_FROM_DEVICE);
  646. /* Not freeing buffer intentionally.
  647. * Observed that same buffer is getting
  648. * re-allocated resulting in longer load time
  649. * WMI init timeout.
  650. * This buffer is anyway not useful so skip it.
  651. **/
  652. }
  653. *rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev,
  654. RX_BUFFER_SIZE,
  655. RX_BUFFER_RESERVATION,
  656. RX_BUFFER_ALIGNMENT,
  657. FALSE);
  658. if (qdf_unlikely(!(*rx_netbuf)))
  659. return QDF_STATUS_E_FAILURE;
  660. ret = qdf_nbuf_map_single(dp_soc->osdev, *rx_netbuf,
  661. QDF_DMA_FROM_DEVICE);
  662. if (qdf_unlikely(ret == QDF_STATUS_E_FAILURE)) {
  663. qdf_nbuf_free(*rx_netbuf);
  664. *rx_netbuf = NULL;
  665. continue;
  666. }
  667. *paddr = qdf_nbuf_get_frag_paddr(*rx_netbuf, 0);
  668. }
  669. } while (nbuf_retry < MAX_RETRY);
  670. if ((*rx_netbuf)) {
  671. qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf,
  672. QDF_DMA_FROM_DEVICE);
  673. qdf_nbuf_free(*rx_netbuf);
  674. }
  675. return QDF_STATUS_E_FAILURE;
  676. }
  677. #endif
  678. /**
  679. * dp_rx_cookie_2_link_desc_va() - Converts cookie to a virtual address of
  680. * the MSDU Link Descriptor
  681. * @soc: core txrx main context
  682. * @buf_info: buf_info include cookie that used to lookup virtual address of
  683. * link descriptor Normally this is just an index into a per SOC array.
  684. *
  685. * This is the VA of the link descriptor, that HAL layer later uses to
  686. * retrieve the list of MSDU's for a given MPDU.
  687. *
  688. * Return: void *: Virtual Address of the Rx descriptor
  689. */
  690. static inline
  691. void *dp_rx_cookie_2_link_desc_va(struct dp_soc *soc,
  692. struct hal_buf_info *buf_info)
  693. {
  694. void *link_desc_va;
  695. uint32_t bank_id = LINK_DESC_COOKIE_BANK_ID(buf_info->sw_cookie);
  696. /* TODO */
  697. /* Add sanity for cookie */
  698. link_desc_va = soc->link_desc_banks[bank_id].base_vaddr +
  699. (buf_info->paddr -
  700. soc->link_desc_banks[bank_id].base_paddr);
  701. return link_desc_va;
  702. }
  703. /**
  704. * dp_rx_cookie_2_mon_link_desc_va() - Converts cookie to a virtual address of
  705. * the MSDU Link Descriptor
  706. * @pdev: core txrx pdev context
  707. * @buf_info: buf_info includes cookie that used to lookup virtual address of
  708. * link descriptor. Normally this is just an index into a per pdev array.
  709. *
  710. * This is the VA of the link descriptor in monitor mode destination ring,
  711. * that HAL layer later uses to retrieve the list of MSDU's for a given MPDU.
  712. *
  713. * Return: void *: Virtual Address of the Rx descriptor
  714. */
  715. static inline
  716. void *dp_rx_cookie_2_mon_link_desc_va(struct dp_pdev *pdev,
  717. struct hal_buf_info *buf_info,
  718. int mac_id)
  719. {
  720. void *link_desc_va;
  721. int mac_for_pdev = dp_get_mac_id_for_mac(pdev->soc, mac_id);
  722. /* TODO */
  723. /* Add sanity for cookie */
  724. link_desc_va =
  725. pdev->link_desc_banks[mac_for_pdev][buf_info->sw_cookie].base_vaddr +
  726. (buf_info->paddr -
  727. pdev->link_desc_banks[mac_for_pdev][buf_info->sw_cookie].base_paddr);
  728. return link_desc_va;
  729. }
  730. /**
  731. * dp_rx_defrag_concat() - Concatenate the fragments
  732. *
  733. * @dst: destination pointer to the buffer
  734. * @src: source pointer from where the fragment payload is to be copied
  735. *
  736. * Return: QDF_STATUS
  737. */
  738. static inline QDF_STATUS dp_rx_defrag_concat(qdf_nbuf_t dst, qdf_nbuf_t src)
  739. {
  740. /*
  741. * Inside qdf_nbuf_cat, if it is necessary to reallocate dst
  742. * to provide space for src, the headroom portion is copied from
  743. * the original dst buffer to the larger new dst buffer.
  744. * (This is needed, because the headroom of the dst buffer
  745. * contains the rx desc.)
  746. */
  747. if (!qdf_nbuf_cat(dst, src)) {
  748. /*
  749. * qdf_nbuf_cat does not free the src memory.
  750. * Free src nbuf before returning
  751. * For failure case the caller takes of freeing the nbuf
  752. */
  753. qdf_nbuf_free(src);
  754. return QDF_STATUS_SUCCESS;
  755. }
  756. return QDF_STATUS_E_DEFRAG_ERROR;
  757. }
  758. /*
  759. * dp_rx_ast_set_active() - set the active flag of the astentry
  760. * corresponding to a hw index.
  761. * @soc: core txrx main context
  762. * @sa_idx: hw idx
  763. * @is_active: active flag
  764. *
  765. */
  766. #ifdef FEATURE_WDS
  767. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
  768. {
  769. struct dp_ast_entry *ast;
  770. qdf_spin_lock_bh(&soc->ast_lock);
  771. ast = soc->ast_table[sa_idx];
  772. /*
  773. * Ensure we are updating the right AST entry by
  774. * validating ast_idx.
  775. * There is a possibility we might arrive here without
  776. * AST MAP event , so this check is mandatory
  777. */
  778. if (ast && ast->is_mapped && (ast->ast_idx == sa_idx)) {
  779. ast->is_active = is_active;
  780. qdf_spin_unlock_bh(&soc->ast_lock);
  781. return QDF_STATUS_SUCCESS;
  782. }
  783. qdf_spin_unlock_bh(&soc->ast_lock);
  784. return QDF_STATUS_E_FAILURE;
  785. }
  786. #else
  787. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
  788. {
  789. return QDF_STATUS_SUCCESS;
  790. }
  791. #endif
  792. /*
  793. * dp_rx_desc_dump() - dump the sw rx descriptor
  794. *
  795. * @rx_desc: sw rx descriptor
  796. */
  797. static inline void dp_rx_desc_dump(struct dp_rx_desc *rx_desc)
  798. {
  799. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  800. "rx_desc->nbuf: %pK, rx_desc->cookie: %d, rx_desc->pool_id: %d, rx_desc->in_use: %d, rx_desc->unmapped: %d",
  801. rx_desc->nbuf, rx_desc->cookie, rx_desc->pool_id,
  802. rx_desc->in_use, rx_desc->unmapped);
  803. }
  804. /*
  805. * check_qwrap_multicast_loopback() - Check if rx packet is a loopback packet.
  806. * In qwrap mode, packets originated from
  807. * any vdev should not loopback and
  808. * should be dropped.
  809. * @vdev: vdev on which rx packet is received
  810. * @nbuf: rx pkt
  811. *
  812. */
  813. #if ATH_SUPPORT_WRAP
  814. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  815. qdf_nbuf_t nbuf)
  816. {
  817. struct dp_vdev *psta_vdev;
  818. struct dp_pdev *pdev = vdev->pdev;
  819. uint8_t *data = qdf_nbuf_data(nbuf);
  820. if (qdf_unlikely(vdev->proxysta_vdev)) {
  821. /* In qwrap isolation mode, allow loopback packets as all
  822. * packets go to RootAP and Loopback on the mpsta.
  823. */
  824. if (vdev->isolation_vdev)
  825. return false;
  826. TAILQ_FOREACH(psta_vdev, &pdev->vdev_list, vdev_list_elem) {
  827. if (qdf_unlikely(psta_vdev->proxysta_vdev &&
  828. !qdf_mem_cmp(psta_vdev->mac_addr.raw,
  829. &data[QDF_MAC_ADDR_SIZE],
  830. QDF_MAC_ADDR_SIZE))) {
  831. /* Drop packet if source address is equal to
  832. * any of the vdev addresses.
  833. */
  834. return true;
  835. }
  836. }
  837. }
  838. return false;
  839. }
  840. #else
  841. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  842. qdf_nbuf_t nbuf)
  843. {
  844. return false;
  845. }
  846. #endif
  847. #if defined(WLAN_SUPPORT_RX_TAG_STATISTICS) && \
  848. defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG)
  849. /**
  850. * dp_rx_update_rx_protocol_tag_stats() - Increments the protocol tag stats
  851. * for the given protocol type
  852. * @soc: core txrx main context
  853. * @pdev: TXRX pdev context for which stats should be incremented
  854. * @protocol_index: Protocol index for which the stats should be incremented
  855. * @ring_index: REO ring number from which this tag was received.
  856. *
  857. * Since HKv2 is a SMP, two or more cores may simultaneously receive packets
  858. * of same type, and hence attempt to increment counters for the same protocol
  859. * type at the same time. This creates the possibility of missing stats.
  860. *
  861. * For example, when two or more CPUs have each read the old tag value, V,
  862. * for protocol type, P and each increment the value to V+1. Instead, the
  863. * operations should have been sequenced to achieve a final value of V+2.
  864. *
  865. * In order to avoid this scenario, we can either use locks or store stats
  866. * on a per-CPU basis. Since tagging happens in the core data path, locks
  867. * are not preferred. Instead, we use a per-ring counter, since each CPU
  868. * operates on a REO ring.
  869. *
  870. * Return: void
  871. */
  872. static inline void dp_rx_update_rx_protocol_tag_stats(struct dp_pdev *pdev,
  873. uint16_t protocol_index,
  874. uint16_t ring_index)
  875. {
  876. if (ring_index >= MAX_REO_DEST_RINGS)
  877. return;
  878. pdev->reo_proto_tag_stats[ring_index][protocol_index].tag_ctr++;
  879. }
  880. #else
  881. static inline void dp_rx_update_rx_protocol_tag_stats(struct dp_pdev *pdev,
  882. uint16_t protocol_index,
  883. uint16_t ring_index)
  884. {
  885. }
  886. #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
  887. #if defined(WLAN_SUPPORT_RX_TAG_STATISTICS) && \
  888. defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG)
  889. /**
  890. * dp_rx_update_rx_err_protocol_tag_stats() - Increments the protocol tag stats
  891. * for the given protocol type
  892. * received from exception ring
  893. * @soc: core txrx main context
  894. * @pdev: TXRX pdev context for which stats should be incremented
  895. * @protocol_index: Protocol index for which the stats should be incremented
  896. *
  897. * In HKv2, all exception packets are received on Ring-0 (along with normal
  898. * Rx). Hence tags are maintained separately for exception ring as well.
  899. *
  900. * Return: void
  901. */
  902. static inline
  903. void dp_rx_update_rx_err_protocol_tag_stats(struct dp_pdev *pdev,
  904. uint16_t protocol_index)
  905. {
  906. pdev->rx_err_proto_tag_stats[protocol_index].tag_ctr++;
  907. }
  908. #else
  909. static inline
  910. void dp_rx_update_rx_err_protocol_tag_stats(struct dp_pdev *pdev,
  911. uint16_t protocol_index)
  912. {
  913. }
  914. #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */
  915. /**
  916. * dp_rx_update_protocol_tag() - Reads CCE metadata from the RX MSDU end TLV
  917. * and set the corresponding tag in QDF packet
  918. * @soc: core txrx main context
  919. * @vdev: vdev on which the packet is received
  920. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  921. * @rx_tlv_hdr: rBbase address where the RX TLVs starts
  922. * @ring_index: REO ring number, not used for error & monitor ring
  923. * @is_reo_exception: flag to indicate if rx from REO ring or exception ring
  924. * @is_update_stats: flag to indicate whether to update stats or not
  925. * Return: void
  926. */
  927. #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  928. static inline void
  929. dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  930. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  931. uint16_t ring_index,
  932. bool is_reo_exception, bool is_update_stats)
  933. {
  934. uint16_t cce_metadata = RX_PROTOCOL_TAG_START_OFFSET;
  935. bool cce_match = false;
  936. struct dp_pdev *pdev;
  937. uint16_t protocol_tag = 0;
  938. if (qdf_unlikely(!vdev))
  939. return;
  940. pdev = vdev->pdev;
  941. if (qdf_likely(!pdev->is_rx_protocol_tagging_enabled))
  942. return;
  943. /*
  944. * In case of raw frames, rx_attention and rx_msdu_end tlv
  945. * may be stale or invalid. Do not tag such frames.
  946. * Default decap_type is set to ethernet for monitor vdev,
  947. * therefore, cannot check decap_type for monitor mode.
  948. * We will call this only for eth frames from dp_rx_mon_dest.c.
  949. */
  950. if (qdf_likely(!(pdev->monitor_vdev && pdev->monitor_vdev == vdev) &&
  951. (vdev->rx_decap_type != htt_cmn_pkt_type_ethernet)))
  952. return;
  953. /*
  954. * Check whether HW has filled in the CCE metadata in
  955. * this packet, if not filled, just return
  956. */
  957. if (qdf_likely(!hal_rx_msdu_cce_match_get(rx_tlv_hdr)))
  958. return;
  959. cce_match = true;
  960. /* Get the cce_metadata from RX MSDU TLV */
  961. cce_metadata = (hal_rx_msdu_cce_metadata_get(rx_tlv_hdr) &
  962. RX_MSDU_END_16_CCE_METADATA_MASK);
  963. /*
  964. * Received CCE metadata should be within the
  965. * valid limits
  966. */
  967. qdf_assert_always((cce_metadata >= RX_PROTOCOL_TAG_START_OFFSET) &&
  968. (cce_metadata < (RX_PROTOCOL_TAG_START_OFFSET +
  969. RX_PROTOCOL_TAG_MAX)));
  970. /*
  971. * The CCE metadata received is just the
  972. * packet_type + RX_PROTOCOL_TAG_START_OFFSET
  973. */
  974. cce_metadata -= RX_PROTOCOL_TAG_START_OFFSET;
  975. /*
  976. * Update the QDF packet with the user-specified
  977. * tag/metadata by looking up tag value for
  978. * received protocol type.
  979. */
  980. protocol_tag = pdev->rx_proto_tag_map[cce_metadata].tag;
  981. qdf_nbuf_set_rx_protocol_tag(nbuf, protocol_tag);
  982. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
  983. "Seq:%u decap:%u CCE Match:%d ProtoID:%u Tag:%u US:%d",
  984. hal_rx_get_rx_sequence(rx_tlv_hdr),
  985. vdev->rx_decap_type, cce_match, cce_metadata,
  986. protocol_tag, is_update_stats);
  987. if (qdf_likely(!is_update_stats))
  988. return;
  989. if (qdf_unlikely(is_reo_exception)) {
  990. dp_rx_update_rx_err_protocol_tag_stats(pdev,
  991. cce_metadata);
  992. } else {
  993. dp_rx_update_rx_protocol_tag_stats(pdev,
  994. cce_metadata,
  995. ring_index);
  996. }
  997. }
  998. #else
  999. static inline void
  1000. dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  1001. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  1002. uint16_t ring_index,
  1003. bool is_reo_exception, bool is_update_stats)
  1004. {
  1005. /* Stub API */
  1006. }
  1007. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  1008. /**
  1009. * dp_rx_mon_update_protocol_tag() - Performs necessary checks for monitor mode
  1010. * and then tags appropriate packets
  1011. * @soc: core txrx main context
  1012. * @vdev: pdev on which packet is received
  1013. * @msdu: QDF packet buffer on which the protocol tag should be set
  1014. * @rx_desc: base address where the RX TLVs start
  1015. * Return: void
  1016. */
  1017. #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  1018. static inline
  1019. void dp_rx_mon_update_protocol_tag(struct dp_soc *soc, struct dp_pdev *dp_pdev,
  1020. qdf_nbuf_t msdu, void *rx_desc)
  1021. {
  1022. uint32_t msdu_ppdu_id = 0;
  1023. struct mon_rx_status *mon_recv_status;
  1024. if (qdf_likely(!dp_pdev->is_rx_protocol_tagging_enabled))
  1025. return;
  1026. if (qdf_likely(!dp_pdev->monitor_vdev))
  1027. return;
  1028. if (qdf_likely(1 != dp_pdev->ppdu_info.rx_status.rxpcu_filter_pass))
  1029. return;
  1030. msdu_ppdu_id = HAL_RX_HW_DESC_GET_PPDUID_GET(rx_desc);
  1031. if (msdu_ppdu_id != dp_pdev->ppdu_info.com_info.ppdu_id) {
  1032. QDF_TRACE(QDF_MODULE_ID_DP,
  1033. QDF_TRACE_LEVEL_ERROR,
  1034. "msdu_ppdu_id=%x,com_info.ppdu_id=%x",
  1035. msdu_ppdu_id,
  1036. dp_pdev->ppdu_info.com_info.ppdu_id);
  1037. return;
  1038. }
  1039. /*
  1040. * Update the protocol tag in SKB for packets received on BSS.
  1041. * Do not update tag stats since it would double actual received count
  1042. */
  1043. mon_recv_status = &dp_pdev->ppdu_info.rx_status;
  1044. if (mon_recv_status->frame_control_info_valid &&
  1045. ((mon_recv_status->frame_control & IEEE80211_FC0_TYPE_MASK) ==
  1046. IEEE80211_FC0_TYPE_DATA)) {
  1047. dp_rx_update_protocol_tag(soc,
  1048. dp_pdev->monitor_vdev,
  1049. msdu, rx_desc,
  1050. MAX_REO_DEST_RINGS,
  1051. false, false);
  1052. }
  1053. }
  1054. #else
  1055. static inline
  1056. void dp_rx_mon_update_protocol_tag(struct dp_soc *soc, struct dp_pdev *dp_pdev,
  1057. qdf_nbuf_t msdu, void *rx_desc)
  1058. {
  1059. /* Stub API */
  1060. }
  1061. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  1062. /*
  1063. * dp_rx_buffers_replenish() - replenish rxdma ring with rx nbufs
  1064. * called during dp rx initialization
  1065. * and at the end of dp_rx_process.
  1066. *
  1067. * @soc: core txrx main context
  1068. * @mac_id: mac_id which is one of 3 mac_ids
  1069. * @dp_rxdma_srng: dp rxdma circular ring
  1070. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1071. * @num_req_buffers: number of buffer to be replenished
  1072. * @desc_list: list of descs if called from dp_rx_process
  1073. * or NULL during dp rx initialization or out of buffer
  1074. * interrupt.
  1075. * @tail: tail of descs list
  1076. * Return: return success or failure
  1077. */
  1078. QDF_STATUS dp_rx_buffers_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  1079. struct dp_srng *dp_rxdma_srng,
  1080. struct rx_desc_pool *rx_desc_pool,
  1081. uint32_t num_req_buffers,
  1082. union dp_rx_desc_list_elem_t **desc_list,
  1083. union dp_rx_desc_list_elem_t **tail);
  1084. /**
  1085. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  1086. * (WBM), following error handling
  1087. *
  1088. * @soc: core DP main context
  1089. * @buf_addr_info: opaque pointer to the REO error ring descriptor
  1090. * @buf_addr_info: void pointer to the buffer_addr_info
  1091. * @bm_action: put to idle_list or release to msdu_list
  1092. * Return: QDF_STATUS
  1093. */
  1094. QDF_STATUS
  1095. dp_rx_link_desc_return(struct dp_soc *soc, void *ring_desc, uint8_t bm_action);
  1096. QDF_STATUS
  1097. dp_rx_link_desc_buf_return(struct dp_soc *soc, struct dp_srng *dp_rxdma_srng,
  1098. void *buf_addr_info, uint8_t bm_action);
  1099. /**
  1100. * dp_rx_link_desc_return_by_addr - Return a MPDU link descriptor to
  1101. * (WBM) by address
  1102. *
  1103. * @soc: core DP main context
  1104. * @link_desc_addr: link descriptor addr
  1105. *
  1106. * Return: QDF_STATUS
  1107. */
  1108. QDF_STATUS
  1109. dp_rx_link_desc_return_by_addr(struct dp_soc *soc, void *link_desc_addr,
  1110. uint8_t bm_action);
  1111. uint32_t
  1112. dp_rxdma_err_process(struct dp_soc *soc, uint32_t mac_id,
  1113. uint32_t quota);
  1114. void dp_rx_fill_mesh_stats(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1115. uint8_t *rx_tlv_hdr, struct dp_peer *peer);
  1116. QDF_STATUS dp_rx_filter_mesh_packets(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1117. uint8_t *rx_tlv_hdr);
  1118. int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr, struct dp_vdev *vdev,
  1119. struct dp_peer *peer);
  1120. qdf_nbuf_t
  1121. dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev);
  1122. void dp_rx_dump_info_and_assert(struct dp_soc *soc, void *hal_ring,
  1123. void *ring_desc, struct dp_rx_desc *rx_desc);
  1124. void dp_rx_compute_delay(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  1125. #ifdef RX_DESC_DEBUG_CHECK
  1126. /**
  1127. * dp_rx_desc_check_magic() - check the magic value in dp_rx_desc
  1128. * @rx_desc: rx descriptor pointer
  1129. *
  1130. * Return: true, if magic is correct, else false.
  1131. */
  1132. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1133. {
  1134. if (qdf_unlikely(rx_desc->magic != DP_RX_DESC_MAGIC))
  1135. return false;
  1136. rx_desc->magic = 0;
  1137. return true;
  1138. }
  1139. /**
  1140. * dp_rx_desc_prep() - prepare rx desc
  1141. * @rx_desc: rx descriptor pointer to be prepared
  1142. * @nbuf: nbuf to be associated with rx_desc
  1143. *
  1144. * Note: assumption is that we are associating a nbuf which is mapped
  1145. *
  1146. * Return: none
  1147. */
  1148. static inline void dp_rx_desc_prep(struct dp_rx_desc *rx_desc, qdf_nbuf_t nbuf)
  1149. {
  1150. rx_desc->magic = DP_RX_DESC_MAGIC;
  1151. rx_desc->nbuf = nbuf;
  1152. rx_desc->unmapped = 0;
  1153. }
  1154. #else
  1155. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1156. {
  1157. return true;
  1158. }
  1159. static inline void dp_rx_desc_prep(struct dp_rx_desc *rx_desc, qdf_nbuf_t nbuf)
  1160. {
  1161. rx_desc->nbuf = nbuf;
  1162. rx_desc->unmapped = 0;
  1163. }
  1164. #endif /* RX_DESC_DEBUG_CHECK */
  1165. void dp_rx_process_rxdma_err(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1166. uint8_t *rx_tlv_hdr, struct dp_peer *peer,
  1167. uint8_t err_code);
  1168. #ifdef PEER_CACHE_RX_PKTS
  1169. /**
  1170. * dp_rx_flush_rx_cached() - flush cached rx frames
  1171. * @peer: peer
  1172. * @drop: set flag to drop frames
  1173. *
  1174. * Return: None
  1175. */
  1176. void dp_rx_flush_rx_cached(struct dp_peer *peer, bool drop);
  1177. #else
  1178. static inline void dp_rx_flush_rx_cached(struct dp_peer *peer, bool drop)
  1179. {
  1180. }
  1181. #endif
  1182. #endif /* _DP_RX_H */