dp_rx.h 49 KB

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