dp_rx.h 49 KB

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