dp_internal.h 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _DP_INTERNAL_H_
  20. #define _DP_INTERNAL_H_
  21. #include "dp_types.h"
  22. #define RX_BUFFER_SIZE_PKTLOG_LITE 1024
  23. #define DP_PEER_WDS_COUNT_INVALID UINT_MAX
  24. /* Alignment for consistent memory for DP rings*/
  25. #define DP_RING_BASE_ALIGN 32
  26. #define DP_RSSI_INVAL 0x80
  27. #define DP_RSSI_AVG_WEIGHT 2
  28. /*
  29. * Formula to derive avg_rssi is taken from wifi2.o firmware
  30. */
  31. #define DP_GET_AVG_RSSI(avg_rssi, last_rssi) \
  32. (((avg_rssi) - (((uint8_t)(avg_rssi)) >> DP_RSSI_AVG_WEIGHT)) \
  33. + ((((uint8_t)(last_rssi)) >> DP_RSSI_AVG_WEIGHT)))
  34. /* Macro For NYSM value received in VHT TLV */
  35. #define VHT_SGI_NYSM 3
  36. /* struct htt_dbgfs_cfg - structure to maintain required htt data
  37. * @msg_word: htt msg sent to upper layer
  38. * @m: qdf debugfs file pointer
  39. */
  40. struct htt_dbgfs_cfg {
  41. uint32_t *msg_word;
  42. qdf_debugfs_file_t m;
  43. };
  44. /* Cookie MSB bits assigned for different use case.
  45. * Note: User can't use last 3 bits, as it is reserved for pdev_id.
  46. * If in future number of pdev are more than 3.
  47. */
  48. /* Reserve for default case */
  49. #define DBG_STATS_COOKIE_DEFAULT 0x0
  50. /* Reserve for DP Stats: 3rd bit */
  51. #define DBG_STATS_COOKIE_DP_STATS BIT(3)
  52. /* Reserve for HTT Stats debugfs support: 4th bit */
  53. #define DBG_STATS_COOKIE_HTT_DBGFS BIT(4)
  54. /*Reserve for HTT Stats debugfs support: 5th bit */
  55. #define DBG_SYSFS_STATS_COOKIE BIT(5)
  56. /**
  57. * Bitmap of HTT PPDU TLV types for Default mode
  58. */
  59. #define HTT_PPDU_DEFAULT_TLV_BITMAP \
  60. (1 << HTT_PPDU_STATS_COMMON_TLV) | \
  61. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  62. (1 << HTT_PPDU_STATS_USR_RATE_TLV) | \
  63. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV) | \
  64. (1 << HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV) | \
  65. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)
  66. /* PPDU STATS CFG */
  67. #define DP_PPDU_STATS_CFG_ALL 0xFFFF
  68. /* PPDU stats mask sent to FW to enable enhanced stats */
  69. #define DP_PPDU_STATS_CFG_ENH_STATS \
  70. (HTT_PPDU_DEFAULT_TLV_BITMAP) | \
  71. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) | \
  72. (1 << HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV) | \
  73. (1 << HTT_PPDU_STATS_USERS_INFO_TLV)
  74. /* PPDU stats mask sent to FW to support debug sniffer feature */
  75. #define DP_PPDU_STATS_CFG_SNIFFER \
  76. (HTT_PPDU_DEFAULT_TLV_BITMAP) | \
  77. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV) | \
  78. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV) | \
  79. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV) | \
  80. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV) | \
  81. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) | \
  82. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV) | \
  83. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) | \
  84. (1 << HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV) | \
  85. (1 << HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) | \
  86. (1 << HTT_PPDU_STATS_USERS_INFO_TLV)
  87. /* PPDU stats mask sent to FW to support BPR feature*/
  88. #define DP_PPDU_STATS_CFG_BPR \
  89. (1 << HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) | \
  90. (1 << HTT_PPDU_STATS_USERS_INFO_TLV)
  91. /* PPDU stats mask sent to FW to support BPR and enhanced stats feature */
  92. #define DP_PPDU_STATS_CFG_BPR_ENH (DP_PPDU_STATS_CFG_BPR | \
  93. DP_PPDU_STATS_CFG_ENH_STATS)
  94. /* PPDU stats mask sent to FW to support BPR and pcktlog stats feature */
  95. #define DP_PPDU_STATS_CFG_BPR_PKTLOG (DP_PPDU_STATS_CFG_BPR | \
  96. DP_PPDU_TXLITE_STATS_BITMASK_CFG)
  97. /**
  98. * Bitmap of HTT PPDU delayed ba TLV types for Default mode
  99. */
  100. #define HTT_PPDU_DELAYED_BA_TLV_BITMAP \
  101. (1 << HTT_PPDU_STATS_COMMON_TLV) | \
  102. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  103. (1 << HTT_PPDU_STATS_USR_RATE_TLV)
  104. /**
  105. * Bitmap of HTT PPDU TLV types for Delayed BA
  106. */
  107. #define HTT_PPDU_STATUS_TLV_BITMAP \
  108. (1 << HTT_PPDU_STATS_COMMON_TLV) | \
  109. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)
  110. /**
  111. * Bitmap of HTT PPDU TLV types for Sniffer mode bitmap 64
  112. */
  113. #define HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_64 \
  114. ((1 << HTT_PPDU_STATS_COMMON_TLV) | \
  115. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  116. (1 << HTT_PPDU_STATS_USR_RATE_TLV) | \
  117. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV) | \
  118. (1 << HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV) | \
  119. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) | \
  120. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV) | \
  121. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV))
  122. /**
  123. * Bitmap of HTT PPDU TLV types for Sniffer mode bitmap 256
  124. */
  125. #define HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_256 \
  126. ((1 << HTT_PPDU_STATS_COMMON_TLV) | \
  127. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  128. (1 << HTT_PPDU_STATS_USR_RATE_TLV) | \
  129. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV) | \
  130. (1 << HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV) | \
  131. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) | \
  132. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV) | \
  133. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV))
  134. QDF_STATUS dp_mon_soc_attach(struct dp_soc *soc);
  135. QDF_STATUS dp_mon_soc_detach(struct dp_soc *soc);
  136. /*
  137. * dp_rx_err_match_dhost() - function to check whether dest-mac is correct
  138. * @eh: Ethernet header of incoming packet
  139. * @vdev: dp_vdev object of the VAP on which this data packet is received
  140. *
  141. * Return: 1 if the destination mac is correct,
  142. * 0 if this frame is not correctly destined to this VAP/MLD
  143. */
  144. int dp_rx_err_match_dhost(qdf_ether_header_t *eh, struct dp_vdev *vdev);
  145. #ifdef MONITOR_MODULARIZED_ENABLE
  146. static inline bool dp_monitor_modularized_enable(void)
  147. {
  148. return TRUE;
  149. }
  150. static inline QDF_STATUS
  151. dp_mon_soc_attach_wrapper(struct dp_soc *soc) { return QDF_STATUS_SUCCESS; }
  152. static inline QDF_STATUS
  153. dp_mon_soc_detach_wrapper(struct dp_soc *soc) { return QDF_STATUS_SUCCESS; }
  154. #else
  155. static inline bool dp_monitor_modularized_enable(void)
  156. {
  157. return FALSE;
  158. }
  159. static inline QDF_STATUS dp_mon_soc_attach_wrapper(struct dp_soc *soc)
  160. {
  161. return dp_mon_soc_attach(soc);
  162. }
  163. static inline QDF_STATUS dp_mon_soc_detach_wrapper(struct dp_soc *soc)
  164. {
  165. return dp_mon_soc_detach(soc);
  166. }
  167. #endif
  168. #ifndef WIFI_MONITOR_SUPPORT
  169. #define MON_BUF_MIN_ENTRIES 64
  170. static inline QDF_STATUS dp_monitor_pdev_attach(struct dp_pdev *pdev)
  171. {
  172. return QDF_STATUS_SUCCESS;
  173. }
  174. static inline QDF_STATUS dp_monitor_pdev_detach(struct dp_pdev *pdev)
  175. {
  176. return QDF_STATUS_SUCCESS;
  177. }
  178. static inline QDF_STATUS dp_monitor_vdev_attach(struct dp_vdev *vdev)
  179. {
  180. return QDF_STATUS_E_FAILURE;
  181. }
  182. static inline QDF_STATUS dp_monitor_vdev_detach(struct dp_vdev *vdev)
  183. {
  184. return QDF_STATUS_E_FAILURE;
  185. }
  186. static inline QDF_STATUS dp_monitor_peer_attach(struct dp_soc *soc,
  187. struct dp_peer *peer)
  188. {
  189. return QDF_STATUS_SUCCESS;
  190. }
  191. static inline QDF_STATUS dp_monitor_peer_detach(struct dp_soc *soc,
  192. struct dp_peer *peer)
  193. {
  194. return QDF_STATUS_E_FAILURE;
  195. }
  196. static inline QDF_STATUS dp_monitor_pdev_init(struct dp_pdev *pdev)
  197. {
  198. return QDF_STATUS_SUCCESS;
  199. }
  200. static inline QDF_STATUS dp_monitor_pdev_deinit(struct dp_pdev *pdev)
  201. {
  202. return QDF_STATUS_SUCCESS;
  203. }
  204. static inline QDF_STATUS dp_monitor_soc_cfg_init(struct dp_soc *soc)
  205. {
  206. return QDF_STATUS_SUCCESS;
  207. }
  208. static inline QDF_STATUS dp_monitor_config_debug_sniffer(struct dp_pdev *pdev,
  209. int val)
  210. {
  211. return QDF_STATUS_E_FAILURE;
  212. }
  213. static inline void dp_monitor_flush_rings(struct dp_soc *soc)
  214. {
  215. }
  216. static inline QDF_STATUS dp_monitor_htt_srng_setup(struct dp_soc *soc,
  217. struct dp_pdev *pdev,
  218. int mac_id,
  219. int mac_for_pdev)
  220. {
  221. return QDF_STATUS_SUCCESS;
  222. }
  223. static inline void dp_monitor_service_mon_rings(struct dp_soc *soc,
  224. uint32_t quota)
  225. {
  226. }
  227. static inline
  228. uint32_t dp_monitor_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  229. uint32_t mac_id, uint32_t quota)
  230. {
  231. return 0;
  232. }
  233. static inline
  234. uint32_t dp_monitor_drop_packets_for_mac(struct dp_pdev *pdev,
  235. uint32_t mac_id, uint32_t quota)
  236. {
  237. return 0;
  238. }
  239. static inline void dp_monitor_peer_tx_init(struct dp_pdev *pdev,
  240. struct dp_peer *peer)
  241. {
  242. }
  243. static inline void dp_monitor_peer_tx_cleanup(struct dp_vdev *vdev,
  244. struct dp_peer *peer)
  245. {
  246. }
  247. static inline
  248. void dp_monitor_peer_tid_peer_id_update(struct dp_soc *soc,
  249. struct dp_peer *peer,
  250. uint16_t peer_id)
  251. {
  252. }
  253. static inline void dp_monitor_tx_ppdu_stats_attach(struct dp_pdev *pdev)
  254. {
  255. }
  256. static inline void dp_monitor_tx_ppdu_stats_detach(struct dp_pdev *pdev)
  257. {
  258. }
  259. static inline
  260. QDF_STATUS dp_monitor_tx_capture_debugfs_init(struct dp_pdev *pdev)
  261. {
  262. return QDF_STATUS_SUCCESS;
  263. }
  264. static inline void dp_monitor_peer_tx_capture_filter_check(struct dp_pdev *pdev,
  265. struct dp_peer *peer)
  266. {
  267. }
  268. static inline
  269. QDF_STATUS dp_monitor_tx_add_to_comp_queue(struct dp_soc *soc,
  270. struct dp_tx_desc_s *desc,
  271. struct hal_tx_completion_status *ts,
  272. uint16_t peer_id)
  273. {
  274. return QDF_STATUS_E_FAILURE;
  275. }
  276. static inline
  277. QDF_STATUS monitor_update_msdu_to_list(struct dp_soc *soc,
  278. struct dp_pdev *pdev,
  279. struct dp_peer *peer,
  280. struct hal_tx_completion_status *ts,
  281. qdf_nbuf_t netbuf)
  282. {
  283. return QDF_STATUS_E_FAILURE;
  284. }
  285. static inline bool dp_monitor_ppdu_stats_ind_handler(struct htt_soc *soc,
  286. uint32_t *msg_word,
  287. qdf_nbuf_t htt_t2h_msg)
  288. {
  289. return true;
  290. }
  291. static inline QDF_STATUS dp_monitor_htt_ppdu_stats_attach(struct dp_pdev *pdev)
  292. {
  293. return QDF_STATUS_SUCCESS;
  294. }
  295. static inline void dp_monitor_htt_ppdu_stats_detach(struct dp_pdev *pdev)
  296. {
  297. }
  298. static inline void dp_monitor_print_pdev_rx_mon_stats(struct dp_pdev *pdev)
  299. {
  300. }
  301. static inline QDF_STATUS dp_monitor_config_enh_tx_capture(struct dp_pdev *pdev,
  302. uint32_t val)
  303. {
  304. return QDF_STATUS_E_INVAL;
  305. }
  306. static inline QDF_STATUS dp_monitor_tx_peer_filter(struct dp_pdev *pdev,
  307. struct dp_peer *peer,
  308. uint8_t is_tx_pkt_cap_enable,
  309. uint8_t *peer_mac)
  310. {
  311. return QDF_STATUS_E_INVAL;
  312. }
  313. static inline QDF_STATUS dp_monitor_config_enh_rx_capture(struct dp_pdev *pdev,
  314. uint32_t val)
  315. {
  316. return QDF_STATUS_E_INVAL;
  317. }
  318. static inline
  319. QDF_STATUS dp_monitor_set_bpr_enable(struct dp_pdev *pdev, uint32_t val)
  320. {
  321. return QDF_STATUS_E_FAILURE;
  322. }
  323. static inline
  324. int dp_monitor_set_filter_neigh_peers(struct dp_pdev *pdev, bool val)
  325. {
  326. return 0;
  327. }
  328. static inline
  329. void dp_monitor_set_atf_stats_enable(struct dp_pdev *pdev, bool value)
  330. {
  331. }
  332. static inline
  333. void dp_monitor_set_bsscolor(struct dp_pdev *pdev, uint8_t bsscolor)
  334. {
  335. }
  336. static inline
  337. bool dp_monitor_pdev_get_filter_mcast_data(struct cdp_pdev *pdev_handle)
  338. {
  339. return false;
  340. }
  341. static inline
  342. bool dp_monitor_pdev_get_filter_non_data(struct cdp_pdev *pdev_handle)
  343. {
  344. return false;
  345. }
  346. static inline
  347. bool dp_monitor_pdev_get_filter_ucast_data(struct cdp_pdev *pdev_handle)
  348. {
  349. return false;
  350. }
  351. static inline
  352. int dp_monitor_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
  353. bool enable)
  354. {
  355. return 0;
  356. }
  357. static inline void dp_monitor_pktlogmod_exit(struct dp_pdev *pdev)
  358. {
  359. }
  360. static inline
  361. void dp_monitor_vdev_set_monitor_mode_buf_rings(struct dp_pdev *pdev)
  362. {
  363. }
  364. static inline
  365. void dp_monitor_neighbour_peers_detach(struct dp_pdev *pdev)
  366. {
  367. }
  368. static inline QDF_STATUS dp_monitor_filter_neighbour_peer(struct dp_pdev *pdev,
  369. uint8_t *rx_pkt_hdr)
  370. {
  371. return QDF_STATUS_E_FAILURE;
  372. }
  373. static inline void dp_monitor_print_pdev_tx_capture_stats(struct dp_pdev *pdev)
  374. {
  375. }
  376. static inline
  377. void dp_monitor_reap_timer_init(struct dp_soc *soc)
  378. {
  379. }
  380. static inline
  381. void dp_monitor_reap_timer_deinit(struct dp_soc *soc)
  382. {
  383. }
  384. static inline
  385. void dp_monitor_reap_timer_start(struct dp_soc *soc)
  386. {
  387. }
  388. static inline
  389. bool dp_monitor_reap_timer_stop(struct dp_soc *soc)
  390. {
  391. return false;
  392. }
  393. static inline
  394. void dp_monitor_vdev_timer_init(struct dp_soc *soc)
  395. {
  396. }
  397. static inline
  398. void dp_monitor_vdev_timer_deinit(struct dp_soc *soc)
  399. {
  400. }
  401. static inline
  402. void dp_monitor_vdev_timer_start(struct dp_soc *soc)
  403. {
  404. }
  405. static inline
  406. bool dp_monitor_vdev_timer_stop(struct dp_soc *soc)
  407. {
  408. return false;
  409. }
  410. static inline struct qdf_mem_multi_page_t*
  411. dp_monitor_get_link_desc_pages(struct dp_soc *soc, uint32_t mac_id)
  412. {
  413. return NULL;
  414. }
  415. static inline uint32_t *
  416. dp_monitor_get_total_link_descs(struct dp_soc *soc, uint32_t mac_id)
  417. {
  418. return NULL;
  419. }
  420. static inline QDF_STATUS dp_monitor_drop_inv_peer_pkts(struct dp_vdev *vdev)
  421. {
  422. return QDF_STATUS_E_FAILURE;
  423. }
  424. static inline bool dp_is_enable_reap_timer_non_pkt(struct dp_pdev *pdev)
  425. {
  426. return false;
  427. }
  428. static inline void dp_monitor_vdev_register_osif(struct dp_vdev *vdev,
  429. struct ol_txrx_ops *txrx_ops)
  430. {
  431. }
  432. static inline bool dp_monitor_is_vdev_timer_running(struct dp_soc *soc)
  433. {
  434. return false;
  435. }
  436. static inline
  437. void dp_monitor_pdev_set_mon_vdev(struct dp_pdev *pdev)
  438. {
  439. }
  440. static inline void dp_monitor_vdev_delete(struct dp_soc *soc,
  441. struct dp_vdev *vdev)
  442. {
  443. }
  444. static inline void dp_peer_ppdu_delayed_ba_init(struct dp_peer *peer)
  445. {
  446. }
  447. static inline void dp_monitor_neighbour_peer_add_ast(struct dp_pdev *pdev,
  448. struct dp_peer *ta_peer,
  449. uint8_t *mac_addr,
  450. qdf_nbuf_t nbuf,
  451. uint32_t flags)
  452. {
  453. }
  454. static inline void
  455. dp_monitor_set_chan_band(struct dp_pdev *pdev, enum reg_wifi_band chan_band)
  456. {
  457. }
  458. static inline void
  459. dp_monitor_set_chan_freq(struct dp_pdev *pdev, qdf_freq_t chan_freq)
  460. {
  461. }
  462. static inline void dp_monitor_set_chan_num(struct dp_pdev *pdev, int chan_num)
  463. {
  464. }
  465. static inline bool dp_monitor_is_enable_mcopy_mode(struct dp_pdev *pdev)
  466. {
  467. return false;
  468. }
  469. static inline
  470. void dp_monitor_neighbour_peer_list_remove(struct dp_pdev *pdev,
  471. struct dp_vdev *vdev,
  472. struct dp_neighbour_peer *peer)
  473. {
  474. }
  475. static inline bool dp_monitor_is_chan_band_known(struct dp_pdev *pdev)
  476. {
  477. return false;
  478. }
  479. static inline enum reg_wifi_band
  480. dp_monitor_get_chan_band(struct dp_pdev *pdev)
  481. {
  482. return 0;
  483. }
  484. static inline void dp_monitor_get_mpdu_status(struct dp_pdev *pdev,
  485. struct dp_soc *soc,
  486. uint8_t *rx_tlv_hdr)
  487. {
  488. }
  489. static inline void dp_monitor_print_tx_stats(struct dp_pdev *pdev)
  490. {
  491. }
  492. static inline
  493. QDF_STATUS dp_monitor_mcopy_check_deliver(struct dp_pdev *pdev,
  494. uint16_t peer_id, uint32_t ppdu_id,
  495. uint8_t first_msdu)
  496. {
  497. return QDF_STATUS_SUCCESS;
  498. }
  499. static inline bool dp_monitor_is_enable_tx_sniffer(struct dp_pdev *pdev)
  500. {
  501. return false;
  502. }
  503. static inline struct dp_vdev*
  504. dp_monitor_get_monitor_vdev_from_pdev(struct dp_pdev *pdev)
  505. {
  506. return NULL;
  507. }
  508. static inline QDF_STATUS dp_monitor_check_com_info_ppdu_id(struct dp_pdev *pdev,
  509. void *rx_desc)
  510. {
  511. return QDF_STATUS_E_FAILURE;
  512. }
  513. static inline struct mon_rx_status*
  514. dp_monitor_get_rx_status(struct dp_pdev *pdev)
  515. {
  516. return NULL;
  517. }
  518. static inline
  519. void dp_monitor_pdev_config_scan_spcl_vap(struct dp_pdev *pdev)
  520. {
  521. }
  522. static inline
  523. void dp_monitor_pdev_reset_scan_spcl_vap_stats_enable(struct dp_pdev *pdev,
  524. bool val)
  525. {
  526. }
  527. static inline QDF_STATUS
  528. dp_monitor_peer_tx_capture_get_stats(struct dp_soc *soc, struct dp_peer *peer,
  529. struct cdp_peer_tx_capture_stats *stats)
  530. {
  531. return QDF_STATUS_E_FAILURE;
  532. }
  533. static inline QDF_STATUS
  534. dp_monitor_pdev_tx_capture_get_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  535. struct cdp_pdev_tx_capture_stats *stats)
  536. {
  537. return QDF_STATUS_E_FAILURE;
  538. }
  539. #endif
  540. /**
  541. * cdp_soc_t_to_dp_soc() - typecast cdp_soc_t to
  542. * dp soc handle
  543. * @psoc: CDP psoc handle
  544. *
  545. * Return: struct dp_soc pointer
  546. */
  547. static inline
  548. struct dp_soc *cdp_soc_t_to_dp_soc(struct cdp_soc_t *psoc)
  549. {
  550. return (struct dp_soc *)psoc;
  551. }
  552. #define DP_MAX_TIMER_EXEC_TIME_TICKS \
  553. (QDF_LOG_TIMESTAMP_CYCLES_PER_10_US * 100 * 20)
  554. /**
  555. * enum timer_yield_status - yield status code used in monitor mode timer.
  556. * @DP_TIMER_NO_YIELD: do not yield
  557. * @DP_TIMER_WORK_DONE: yield because work is done
  558. * @DP_TIMER_WORK_EXHAUST: yield because work quota is exhausted
  559. * @DP_TIMER_TIME_EXHAUST: yield due to time slot exhausted
  560. */
  561. enum timer_yield_status {
  562. DP_TIMER_NO_YIELD,
  563. DP_TIMER_WORK_DONE,
  564. DP_TIMER_WORK_EXHAUST,
  565. DP_TIMER_TIME_EXHAUST,
  566. };
  567. #if DP_PRINT_ENABLE
  568. #include <stdarg.h> /* va_list */
  569. #include <qdf_types.h> /* qdf_vprint */
  570. #include <cdp_txrx_handle.h>
  571. enum {
  572. /* FATAL_ERR - print only irrecoverable error messages */
  573. DP_PRINT_LEVEL_FATAL_ERR,
  574. /* ERR - include non-fatal err messages */
  575. DP_PRINT_LEVEL_ERR,
  576. /* WARN - include warnings */
  577. DP_PRINT_LEVEL_WARN,
  578. /* INFO1 - include fundamental, infrequent events */
  579. DP_PRINT_LEVEL_INFO1,
  580. /* INFO2 - include non-fundamental but infrequent events */
  581. DP_PRINT_LEVEL_INFO2,
  582. };
  583. #define dp_print(level, fmt, ...) do { \
  584. if (level <= g_txrx_print_level) \
  585. qdf_print(fmt, ## __VA_ARGS__); \
  586. while (0)
  587. #define DP_PRINT(level, fmt, ...) do { \
  588. dp_print(level, "DP: " fmt, ## __VA_ARGS__); \
  589. while (0)
  590. #else
  591. #define DP_PRINT(level, fmt, ...)
  592. #endif /* DP_PRINT_ENABLE */
  593. #define DP_TRACE(LVL, fmt, args ...) \
  594. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL, \
  595. fmt, ## args)
  596. #ifdef WLAN_SYSFS_DP_STATS
  597. void DP_PRINT_STATS(const char *fmt, ...);
  598. #else /* WLAN_SYSFS_DP_STATS */
  599. #ifdef DP_PRINT_NO_CONSOLE
  600. /* Stat prints should not go to console or kernel logs.*/
  601. #define DP_PRINT_STATS(fmt, args ...)\
  602. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, \
  603. fmt, ## args)
  604. #else
  605. #define DP_PRINT_STATS(fmt, args ...)\
  606. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,\
  607. fmt, ## args)
  608. #endif
  609. #endif /* WLAN_SYSFS_DP_STATS */
  610. #define DP_STATS_INIT(_handle) \
  611. qdf_mem_zero(&((_handle)->stats), sizeof((_handle)->stats))
  612. #define DP_STATS_CLR(_handle) \
  613. qdf_mem_zero(&((_handle)->stats), sizeof((_handle)->stats))
  614. #ifndef DISABLE_DP_STATS
  615. #define DP_STATS_INC(_handle, _field, _delta) \
  616. { \
  617. if (likely(_handle)) \
  618. _handle->stats._field += _delta; \
  619. }
  620. #define DP_STATS_INCC(_handle, _field, _delta, _cond) \
  621. { \
  622. if (_cond && likely(_handle)) \
  623. _handle->stats._field += _delta; \
  624. }
  625. #define DP_STATS_DEC(_handle, _field, _delta) \
  626. { \
  627. if (likely(_handle)) \
  628. _handle->stats._field -= _delta; \
  629. }
  630. #define DP_STATS_UPD(_handle, _field, _delta) \
  631. { \
  632. if (likely(_handle)) \
  633. _handle->stats._field = _delta; \
  634. }
  635. #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes) \
  636. { \
  637. DP_STATS_INC(_handle, _field.num, _count); \
  638. DP_STATS_INC(_handle, _field.bytes, _bytes) \
  639. }
  640. #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond) \
  641. { \
  642. DP_STATS_INCC(_handle, _field.num, _count, _cond); \
  643. DP_STATS_INCC(_handle, _field.bytes, _bytes, _cond) \
  644. }
  645. #define DP_STATS_AGGR(_handle_a, _handle_b, _field) \
  646. { \
  647. _handle_a->stats._field += _handle_b->stats._field; \
  648. }
  649. #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field) \
  650. { \
  651. DP_STATS_AGGR(_handle_a, _handle_b, _field.num); \
  652. DP_STATS_AGGR(_handle_a, _handle_b, _field.bytes);\
  653. }
  654. #define DP_STATS_UPD_STRUCT(_handle_a, _handle_b, _field) \
  655. { \
  656. _handle_a->stats._field = _handle_b->stats._field; \
  657. }
  658. #else
  659. #define DP_STATS_INC(_handle, _field, _delta)
  660. #define DP_STATS_INCC(_handle, _field, _delta, _cond)
  661. #define DP_STATS_DEC(_handle, _field, _delta)
  662. #define DP_STATS_UPD(_handle, _field, _delta)
  663. #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes)
  664. #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond)
  665. #define DP_STATS_AGGR(_handle_a, _handle_b, _field)
  666. #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field)
  667. #endif
  668. #if defined(QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT) && \
  669. defined(QCA_ENHANCED_STATS_SUPPORT)
  670. #define DP_PEER_TO_STACK_INCC_PKT(_handle, _count, _bytes, _cond) \
  671. { \
  672. if (!(_handle->hw_txrx_stats_en) || _cond) \
  673. DP_STATS_INC_PKT(_handle, rx.to_stack, _count, _bytes); \
  674. }
  675. #define DP_PEER_TO_STACK_DECC(_handle, _count, _cond) \
  676. { \
  677. if (!(_handle->hw_txrx_stats_en) || _cond) \
  678. DP_STATS_DEC(_handle, rx.to_stack.num, _count); \
  679. }
  680. #define DP_PEER_MC_INCC_PKT(_handle, _count, _bytes, _cond) \
  681. { \
  682. if (!(_handle->hw_txrx_stats_en) || _cond) \
  683. DP_STATS_INC_PKT(_handle, rx.multicast, _count, _bytes); \
  684. }
  685. #define DP_PEER_BC_INCC_PKT(_handle, _count, _bytes, _cond) \
  686. { \
  687. if (!(_handle->hw_txrx_stats_en) || _cond) \
  688. DP_STATS_INC_PKT(_handle, rx.bcast, _count, _bytes); \
  689. }
  690. #elif defined(QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT)
  691. #define DP_PEER_TO_STACK_INCC_PKT(_handle, _count, _bytes, _cond) \
  692. { \
  693. if (!(_handle->hw_txrx_stats_en)) \
  694. DP_STATS_INC_PKT(_handle, rx.to_stack, _count, _bytes); \
  695. }
  696. #define DP_PEER_TO_STACK_DECC(_handle, _count, _cond) \
  697. { \
  698. if (!(_handle->hw_txrx_stats_en)) \
  699. DP_STATS_DEC(_handle, rx.to_stack.num, _count); \
  700. }
  701. #define DP_PEER_MC_INCC_PKT(_handle, _count, _bytes, _cond) \
  702. { \
  703. if (!(_handle->hw_txrx_stats_en)) \
  704. DP_STATS_INC_PKT(_handle, rx.multicast, _count, _bytes); \
  705. }
  706. #define DP_PEER_BC_INCC_PKT(_handle, _count, _bytes, _cond) \
  707. { \
  708. if (!(_handle->hw_txrx_stats_en)) \
  709. DP_STATS_INC_PKT(_handle, rx.bcast, _count, _bytes); \
  710. }
  711. #else
  712. #define DP_PEER_TO_STACK_INCC_PKT(_handle, _count, _bytes, _cond) \
  713. DP_STATS_INC_PKT(_handle, rx.to_stack, _count, _bytes);
  714. #define DP_PEER_TO_STACK_DECC(_handle, _count, _cond) \
  715. DP_STATS_DEC(_handle, rx.to_stack.num, _count);
  716. #define DP_PEER_MC_INCC_PKT(_handle, _count, _bytes, _cond) \
  717. DP_STATS_INC_PKT(_handle, rx.multicast, _count, _bytes);
  718. #define DP_PEER_BC_INCC_PKT(_handle, _count, _bytes, _cond) \
  719. DP_STATS_INC_PKT(_handle, rx.bcast, _count, _bytes);
  720. #endif
  721. #ifdef ENABLE_DP_HIST_STATS
  722. #define DP_HIST_INIT() \
  723. uint32_t num_of_packets[MAX_PDEV_CNT] = {0};
  724. #define DP_HIST_PACKET_COUNT_INC(_pdev_id) \
  725. { \
  726. ++num_of_packets[_pdev_id]; \
  727. }
  728. #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
  729. do { \
  730. if (_p_cntrs == 1) { \
  731. DP_STATS_INC(_pdev, \
  732. tx_comp_histogram.pkts_1, 1); \
  733. } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \
  734. DP_STATS_INC(_pdev, \
  735. tx_comp_histogram.pkts_2_20, 1); \
  736. } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \
  737. DP_STATS_INC(_pdev, \
  738. tx_comp_histogram.pkts_21_40, 1); \
  739. } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \
  740. DP_STATS_INC(_pdev, \
  741. tx_comp_histogram.pkts_41_60, 1); \
  742. } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \
  743. DP_STATS_INC(_pdev, \
  744. tx_comp_histogram.pkts_61_80, 1); \
  745. } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \
  746. DP_STATS_INC(_pdev, \
  747. tx_comp_histogram.pkts_81_100, 1); \
  748. } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \
  749. DP_STATS_INC(_pdev, \
  750. tx_comp_histogram.pkts_101_200, 1); \
  751. } else if (_p_cntrs > 200) { \
  752. DP_STATS_INC(_pdev, \
  753. tx_comp_histogram.pkts_201_plus, 1); \
  754. } \
  755. } while (0)
  756. #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
  757. do { \
  758. if (_p_cntrs == 1) { \
  759. DP_STATS_INC(_pdev, \
  760. rx_ind_histogram.pkts_1, 1); \
  761. } else if (_p_cntrs > 1 && _p_cntrs <= 20) { \
  762. DP_STATS_INC(_pdev, \
  763. rx_ind_histogram.pkts_2_20, 1); \
  764. } else if (_p_cntrs > 20 && _p_cntrs <= 40) { \
  765. DP_STATS_INC(_pdev, \
  766. rx_ind_histogram.pkts_21_40, 1); \
  767. } else if (_p_cntrs > 40 && _p_cntrs <= 60) { \
  768. DP_STATS_INC(_pdev, \
  769. rx_ind_histogram.pkts_41_60, 1); \
  770. } else if (_p_cntrs > 60 && _p_cntrs <= 80) { \
  771. DP_STATS_INC(_pdev, \
  772. rx_ind_histogram.pkts_61_80, 1); \
  773. } else if (_p_cntrs > 80 && _p_cntrs <= 100) { \
  774. DP_STATS_INC(_pdev, \
  775. rx_ind_histogram.pkts_81_100, 1); \
  776. } else if (_p_cntrs > 100 && _p_cntrs <= 200) { \
  777. DP_STATS_INC(_pdev, \
  778. rx_ind_histogram.pkts_101_200, 1); \
  779. } else if (_p_cntrs > 200) { \
  780. DP_STATS_INC(_pdev, \
  781. rx_ind_histogram.pkts_201_plus, 1); \
  782. } \
  783. } while (0)
  784. #define DP_TX_HIST_STATS_PER_PDEV() \
  785. do { \
  786. uint8_t hist_stats = 0; \
  787. for (hist_stats = 0; hist_stats < soc->pdev_count; \
  788. hist_stats++) { \
  789. DP_TX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
  790. num_of_packets[hist_stats]); \
  791. } \
  792. } while (0)
  793. #define DP_RX_HIST_STATS_PER_PDEV() \
  794. do { \
  795. uint8_t hist_stats = 0; \
  796. for (hist_stats = 0; hist_stats < soc->pdev_count; \
  797. hist_stats++) { \
  798. DP_RX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
  799. num_of_packets[hist_stats]); \
  800. } \
  801. } while (0)
  802. #else
  803. #define DP_HIST_INIT()
  804. #define DP_HIST_PACKET_COUNT_INC(_pdev_id)
  805. #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
  806. #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
  807. #define DP_RX_HIST_STATS_PER_PDEV()
  808. #define DP_TX_HIST_STATS_PER_PDEV()
  809. #endif /* DISABLE_DP_STATS */
  810. #define FRAME_MASK_IPV4_ARP 1
  811. #define FRAME_MASK_IPV4_DHCP 2
  812. #define FRAME_MASK_IPV4_EAPOL 4
  813. #define FRAME_MASK_IPV6_DHCP 8
  814. static inline int dp_log2_ceil(unsigned int value)
  815. {
  816. unsigned int tmp = value;
  817. int log2 = -1;
  818. while (tmp) {
  819. log2++;
  820. tmp >>= 1;
  821. }
  822. if (1 << log2 != value)
  823. log2++;
  824. return log2;
  825. }
  826. #ifdef QCA_SUPPORT_PEER_ISOLATION
  827. #define dp_get_peer_isolation(_peer) ((_peer)->isolation)
  828. static inline void dp_set_peer_isolation(struct dp_txrx_peer *txrx_peer,
  829. bool val)
  830. {
  831. txrx_peer->isolation = val;
  832. }
  833. #else
  834. #define dp_get_peer_isolation(_peer) (0)
  835. static inline void dp_set_peer_isolation(struct dp_txrx_peer *peer, bool val)
  836. {
  837. }
  838. #endif /* QCA_SUPPORT_PEER_ISOLATION */
  839. #ifdef QCA_SUPPORT_WDS_EXTENDED
  840. static inline void dp_wds_ext_peer_init(struct dp_txrx_peer *txrx_peer)
  841. {
  842. txrx_peer->wds_ext.init = 0;
  843. }
  844. #else
  845. static inline void dp_wds_ext_peer_init(struct dp_txrx_peer *txrx_peer)
  846. {
  847. }
  848. #endif /* QCA_SUPPORT_WDS_EXTENDED */
  849. #ifdef QCA_HOST2FW_RXBUF_RING
  850. static inline
  851. struct dp_srng *dp_get_rxdma_ring(struct dp_pdev *pdev, int lmac_id)
  852. {
  853. return &pdev->rx_mac_buf_ring[lmac_id];
  854. }
  855. #else
  856. static inline
  857. struct dp_srng *dp_get_rxdma_ring(struct dp_pdev *pdev, int lmac_id)
  858. {
  859. return &pdev->soc->rx_refill_buf_ring[lmac_id];
  860. }
  861. #endif
  862. /**
  863. * The lmac ID for a particular channel band is fixed.
  864. * 2.4GHz band uses lmac_id = 1
  865. * 5GHz/6GHz band uses lmac_id=0
  866. */
  867. #define DP_INVALID_LMAC_ID (-1)
  868. #define DP_MON_INVALID_LMAC_ID (-1)
  869. #define DP_MAC0_LMAC_ID 0
  870. #define DP_MAC1_LMAC_ID 1
  871. #ifdef FEATURE_TSO_STATS
  872. /**
  873. * dp_init_tso_stats() - Clear tso stats
  874. * @pdev: pdev handle
  875. *
  876. * Return: None
  877. */
  878. static inline
  879. void dp_init_tso_stats(struct dp_pdev *pdev)
  880. {
  881. if (pdev) {
  882. qdf_mem_zero(&((pdev)->stats.tso_stats),
  883. sizeof((pdev)->stats.tso_stats));
  884. qdf_atomic_init(&pdev->tso_idx);
  885. }
  886. }
  887. /**
  888. * dp_stats_tso_segment_histogram_update() - TSO Segment Histogram
  889. * @pdev: pdev handle
  890. * @_p_cntrs: number of tso segments for a tso packet
  891. *
  892. * Return: None
  893. */
  894. void dp_stats_tso_segment_histogram_update(struct dp_pdev *pdev,
  895. uint8_t _p_cntrs);
  896. /**
  897. * dp_tso_segment_update() - Collect tso segment information
  898. * @pdev: pdev handle
  899. * @stats_idx: tso packet number
  900. * @idx: tso segment number
  901. * @seg: tso segment
  902. *
  903. * Return: None
  904. */
  905. void dp_tso_segment_update(struct dp_pdev *pdev,
  906. uint32_t stats_idx,
  907. uint8_t idx,
  908. struct qdf_tso_seg_t seg);
  909. /**
  910. * dp_tso_packet_update() - TSO Packet information
  911. * @pdev: pdev handle
  912. * @stats_idx: tso packet number
  913. * @msdu: nbuf handle
  914. * @num_segs: tso segments
  915. *
  916. * Return: None
  917. */
  918. void dp_tso_packet_update(struct dp_pdev *pdev, uint32_t stats_idx,
  919. qdf_nbuf_t msdu, uint16_t num_segs);
  920. /**
  921. * dp_tso_segment_stats_update() - TSO Segment stats
  922. * @pdev: pdev handle
  923. * @stats_seg: tso segment list
  924. * @stats_idx: tso packet number
  925. *
  926. * Return: None
  927. */
  928. void dp_tso_segment_stats_update(struct dp_pdev *pdev,
  929. struct qdf_tso_seg_elem_t *stats_seg,
  930. uint32_t stats_idx);
  931. /**
  932. * dp_print_tso_stats() - dump tso statistics
  933. * @soc:soc handle
  934. * @level: verbosity level
  935. *
  936. * Return: None
  937. */
  938. void dp_print_tso_stats(struct dp_soc *soc,
  939. enum qdf_stats_verbosity_level level);
  940. /**
  941. * dp_txrx_clear_tso_stats() - clear tso stats
  942. * @soc: soc handle
  943. *
  944. * Return: None
  945. */
  946. void dp_txrx_clear_tso_stats(struct dp_soc *soc);
  947. #else
  948. static inline
  949. void dp_init_tso_stats(struct dp_pdev *pdev)
  950. {
  951. }
  952. static inline
  953. void dp_stats_tso_segment_histogram_update(struct dp_pdev *pdev,
  954. uint8_t _p_cntrs)
  955. {
  956. }
  957. static inline
  958. void dp_tso_segment_update(struct dp_pdev *pdev,
  959. uint32_t stats_idx,
  960. uint32_t idx,
  961. struct qdf_tso_seg_t seg)
  962. {
  963. }
  964. static inline
  965. void dp_tso_packet_update(struct dp_pdev *pdev, uint32_t stats_idx,
  966. qdf_nbuf_t msdu, uint16_t num_segs)
  967. {
  968. }
  969. static inline
  970. void dp_tso_segment_stats_update(struct dp_pdev *pdev,
  971. struct qdf_tso_seg_elem_t *stats_seg,
  972. uint32_t stats_idx)
  973. {
  974. }
  975. static inline
  976. void dp_print_tso_stats(struct dp_soc *soc,
  977. enum qdf_stats_verbosity_level level)
  978. {
  979. }
  980. static inline
  981. void dp_txrx_clear_tso_stats(struct dp_soc *soc)
  982. {
  983. }
  984. #endif /* FEATURE_TSO_STATS */
  985. #define DP_HTT_T2H_HP_PIPE 5
  986. /**
  987. * dp_update_pdev_stats(): Update the pdev stats
  988. * @tgtobj: pdev handle
  989. * @srcobj: vdev stats structure
  990. *
  991. * Update the pdev stats from the specified vdev stats
  992. *
  993. * return: None
  994. */
  995. void dp_update_pdev_stats(struct dp_pdev *tgtobj,
  996. struct cdp_vdev_stats *srcobj);
  997. /**
  998. * dp_update_vdev_ingress_stats(): Update the vdev ingress stats
  999. * @tgtobj: vdev handle
  1000. *
  1001. * Update the vdev ingress stats
  1002. *
  1003. * return: None
  1004. */
  1005. void dp_update_vdev_ingress_stats(struct dp_vdev *tgtobj);
  1006. /**
  1007. * dp_update_pdev_ingress_stats(): Update the pdev ingress stats
  1008. * @tgtobj: pdev handle
  1009. * @srcobj: vdev stats structure
  1010. *
  1011. * Update the pdev ingress stats from the specified vdev stats
  1012. *
  1013. * return: None
  1014. */
  1015. void dp_update_pdev_ingress_stats(struct dp_pdev *tgtobj,
  1016. struct dp_vdev *srcobj);
  1017. /**
  1018. * dp_update_vdev_stats(): Update the vdev stats
  1019. * @soc: soc handle
  1020. * @srcobj: DP_PEER object
  1021. * @arg: point to vdev stats structure
  1022. *
  1023. * Update the vdev stats from the specified peer stats
  1024. *
  1025. * return: None
  1026. */
  1027. void dp_update_vdev_stats(struct dp_soc *soc,
  1028. struct dp_peer *srcobj,
  1029. void *arg);
  1030. #define DP_UPDATE_STATS(_tgtobj, _srcobj) \
  1031. do { \
  1032. uint8_t i; \
  1033. uint8_t pream_type; \
  1034. for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) { \
  1035. for (i = 0; i < MAX_MCS; i++) { \
  1036. DP_STATS_AGGR(_tgtobj, _srcobj, \
  1037. tx.pkt_type[pream_type].mcs_count[i]); \
  1038. DP_STATS_AGGR(_tgtobj, _srcobj, \
  1039. rx.pkt_type[pream_type].mcs_count[i]); \
  1040. } \
  1041. } \
  1042. \
  1043. for (i = 0; i < MAX_BW; i++) { \
  1044. DP_STATS_AGGR(_tgtobj, _srcobj, tx.bw[i]); \
  1045. DP_STATS_AGGR(_tgtobj, _srcobj, rx.bw[i]); \
  1046. } \
  1047. \
  1048. for (i = 0; i < SS_COUNT; i++) { \
  1049. DP_STATS_AGGR(_tgtobj, _srcobj, rx.nss[i]); \
  1050. DP_STATS_AGGR(_tgtobj, _srcobj, tx.nss[i]); \
  1051. } \
  1052. for (i = 0; i < WME_AC_MAX; i++) { \
  1053. DP_STATS_AGGR(_tgtobj, _srcobj, tx.wme_ac_type[i]); \
  1054. DP_STATS_AGGR(_tgtobj, _srcobj, rx.wme_ac_type[i]); \
  1055. DP_STATS_AGGR(_tgtobj, _srcobj, tx.excess_retries_per_ac[i]); \
  1056. \
  1057. } \
  1058. \
  1059. for (i = 0; i < MAX_GI; i++) { \
  1060. DP_STATS_AGGR(_tgtobj, _srcobj, tx.sgi_count[i]); \
  1061. DP_STATS_AGGR(_tgtobj, _srcobj, rx.sgi_count[i]); \
  1062. } \
  1063. \
  1064. for (i = 0; i < MAX_RECEPTION_TYPES; i++) \
  1065. DP_STATS_AGGR(_tgtobj, _srcobj, rx.reception_type[i]); \
  1066. \
  1067. if (!wlan_cfg_get_vdev_stats_hw_offload_config(soc->wlan_cfg_ctx)) { \
  1068. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.comp_pkt); \
  1069. DP_STATS_AGGR(_tgtobj, _srcobj, tx.tx_failed); \
  1070. } \
  1071. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.ucast); \
  1072. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.mcast); \
  1073. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.bcast); \
  1074. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.tx_success); \
  1075. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.nawds_mcast); \
  1076. DP_STATS_AGGR(_tgtobj, _srcobj, tx.nawds_mcast_drop); \
  1077. DP_STATS_AGGR(_tgtobj, _srcobj, tx.ofdma); \
  1078. DP_STATS_AGGR(_tgtobj, _srcobj, tx.stbc); \
  1079. DP_STATS_AGGR(_tgtobj, _srcobj, tx.ldpc); \
  1080. DP_STATS_AGGR(_tgtobj, _srcobj, tx.retries); \
  1081. DP_STATS_AGGR(_tgtobj, _srcobj, tx.non_amsdu_cnt); \
  1082. DP_STATS_AGGR(_tgtobj, _srcobj, tx.amsdu_cnt); \
  1083. DP_STATS_AGGR(_tgtobj, _srcobj, tx.non_ampdu_cnt); \
  1084. DP_STATS_AGGR(_tgtobj, _srcobj, tx.ampdu_cnt); \
  1085. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.dropped.fw_rem); \
  1086. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_tx); \
  1087. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_notx); \
  1088. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason1); \
  1089. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason2); \
  1090. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason3); \
  1091. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.age_out); \
  1092. \
  1093. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.mic_err); \
  1094. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.decrypt_err); \
  1095. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.fcserr); \
  1096. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.pn_err); \
  1097. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.oor_err); \
  1098. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.jump_2k_err); \
  1099. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.rxdma_wifi_parse_err); \
  1100. if (_srcobj->stats.rx.snr != 0) \
  1101. DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.snr); \
  1102. DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.rx_rate); \
  1103. DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_ampdu_cnt); \
  1104. DP_STATS_AGGR(_tgtobj, _srcobj, rx.ampdu_cnt); \
  1105. DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_amsdu_cnt); \
  1106. DP_STATS_AGGR(_tgtobj, _srcobj, rx.amsdu_cnt); \
  1107. DP_STATS_AGGR(_tgtobj, _srcobj, rx.nawds_mcast_drop); \
  1108. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.to_stack); \
  1109. \
  1110. for (i = 0; i < CDP_MAX_RX_RINGS; i++) \
  1111. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.rcvd_reo[i]); \
  1112. \
  1113. _srcobj->stats.rx.unicast.num = \
  1114. _srcobj->stats.rx.to_stack.num - \
  1115. _srcobj->stats.rx.multicast.num; \
  1116. _srcobj->stats.rx.unicast.bytes = \
  1117. _srcobj->stats.rx.to_stack.bytes - \
  1118. _srcobj->stats.rx.multicast.bytes; \
  1119. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.unicast); \
  1120. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.multicast); \
  1121. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.bcast); \
  1122. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.raw); \
  1123. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.pkts); \
  1124. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.fail); \
  1125. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.mec_drop); \
  1126. \
  1127. _tgtobj->stats.tx.last_ack_rssi = \
  1128. _srcobj->stats.tx.last_ack_rssi; \
  1129. DP_STATS_AGGR(_tgtobj, _srcobj, rx.multipass_rx_pkt_drop); \
  1130. DP_STATS_AGGR(_tgtobj, _srcobj, rx.peer_unauth_rx_pkt_drop); \
  1131. DP_STATS_AGGR(_tgtobj, _srcobj, rx.policy_check_drop); \
  1132. } while (0)
  1133. /**
  1134. * dp_peer_find_attach() - Allocates memory for peer objects
  1135. * @soc: SoC handle
  1136. *
  1137. * Return: QDF_STATUS
  1138. */
  1139. QDF_STATUS dp_peer_find_attach(struct dp_soc *soc);
  1140. extern void dp_peer_find_detach(struct dp_soc *soc);
  1141. extern void dp_peer_find_hash_add(struct dp_soc *soc, struct dp_peer *peer);
  1142. extern void dp_peer_find_hash_remove(struct dp_soc *soc, struct dp_peer *peer);
  1143. extern void dp_peer_find_hash_erase(struct dp_soc *soc);
  1144. void dp_peer_vdev_list_add(struct dp_soc *soc, struct dp_vdev *vdev,
  1145. struct dp_peer *peer);
  1146. void dp_peer_vdev_list_remove(struct dp_soc *soc, struct dp_vdev *vdev,
  1147. struct dp_peer *peer);
  1148. void dp_peer_find_id_to_obj_add(struct dp_soc *soc,
  1149. struct dp_peer *peer,
  1150. uint16_t peer_id);
  1151. void dp_txrx_peer_attach_add(struct dp_soc *soc,
  1152. struct dp_peer *peer,
  1153. struct dp_txrx_peer *txrx_peer);
  1154. void dp_peer_find_id_to_obj_remove(struct dp_soc *soc,
  1155. uint16_t peer_id);
  1156. void dp_vdev_unref_delete(struct dp_soc *soc, struct dp_vdev *vdev,
  1157. enum dp_mod_id mod_id);
  1158. /*
  1159. * dp_peer_ppdu_delayed_ba_cleanup() free ppdu allocated in peer
  1160. * @peer: Datapath peer
  1161. *
  1162. * return: void
  1163. */
  1164. void dp_peer_ppdu_delayed_ba_cleanup(struct dp_peer *peer);
  1165. extern void dp_peer_rx_init(struct dp_pdev *pdev, struct dp_peer *peer);
  1166. void dp_peer_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  1167. void dp_peer_rx_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  1168. #ifdef DP_PEER_EXTENDED_API
  1169. /**
  1170. * dp_register_peer() - Register peer into physical device
  1171. * @soc_hdl - data path soc handle
  1172. * @pdev_id - device instance id
  1173. * @sta_desc - peer description
  1174. *
  1175. * Register peer into physical device
  1176. *
  1177. * Return: QDF_STATUS_SUCCESS registration success
  1178. * QDF_STATUS_E_FAULT peer not found
  1179. */
  1180. QDF_STATUS dp_register_peer(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  1181. struct ol_txrx_desc_type *sta_desc);
  1182. /**
  1183. * dp_clear_peer() - remove peer from physical device
  1184. * @soc_hdl - data path soc handle
  1185. * @pdev_id - device instance id
  1186. * @peer_addr - peer mac address
  1187. *
  1188. * remove peer from physical device
  1189. *
  1190. * Return: QDF_STATUS_SUCCESS registration success
  1191. * QDF_STATUS_E_FAULT peer not found
  1192. */
  1193. QDF_STATUS dp_clear_peer(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  1194. struct qdf_mac_addr peer_addr);
  1195. /*
  1196. * dp_find_peer_exist - find peer if already exists
  1197. * @soc: datapath soc handle
  1198. * @pdev_id: physical device instance id
  1199. * @peer_mac_addr: peer mac address
  1200. *
  1201. * Return: true or false
  1202. */
  1203. bool dp_find_peer_exist(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  1204. uint8_t *peer_addr);
  1205. /*
  1206. * dp_find_peer_exist_on_vdev - find if peer exists on the given vdev
  1207. * @soc: datapath soc handle
  1208. * @vdev_id: vdev instance id
  1209. * @peer_mac_addr: peer mac address
  1210. *
  1211. * Return: true or false
  1212. */
  1213. bool dp_find_peer_exist_on_vdev(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  1214. uint8_t *peer_addr);
  1215. /*
  1216. * dp_find_peer_exist_on_other_vdev - find if peer exists
  1217. * on other than the given vdev
  1218. * @soc: datapath soc handle
  1219. * @vdev_id: vdev instance id
  1220. * @peer_mac_addr: peer mac address
  1221. * @max_bssid: max number of bssids
  1222. *
  1223. * Return: true or false
  1224. */
  1225. bool dp_find_peer_exist_on_other_vdev(struct cdp_soc_t *soc_hdl,
  1226. uint8_t vdev_id, uint8_t *peer_addr,
  1227. uint16_t max_bssid);
  1228. /**
  1229. * dp_peer_state_update() - update peer local state
  1230. * @pdev - data path device instance
  1231. * @peer_addr - peer mac address
  1232. * @state - new peer local state
  1233. *
  1234. * update peer local state
  1235. *
  1236. * Return: QDF_STATUS_SUCCESS registration success
  1237. */
  1238. QDF_STATUS dp_peer_state_update(struct cdp_soc_t *soc, uint8_t *peer_mac,
  1239. enum ol_txrx_peer_state state);
  1240. /**
  1241. * dp_get_vdevid() - Get virtual interface id which peer registered
  1242. * @soc - datapath soc handle
  1243. * @peer_mac - peer mac address
  1244. * @vdev_id - virtual interface id which peer registered
  1245. *
  1246. * Get virtual interface id which peer registered
  1247. *
  1248. * Return: QDF_STATUS_SUCCESS registration success
  1249. */
  1250. QDF_STATUS dp_get_vdevid(struct cdp_soc_t *soc_hdl, uint8_t *peer_mac,
  1251. uint8_t *vdev_id);
  1252. struct cdp_vdev *dp_get_vdev_by_peer_addr(struct cdp_pdev *pdev_handle,
  1253. struct qdf_mac_addr peer_addr);
  1254. struct cdp_vdev *dp_get_vdev_for_peer(void *peer);
  1255. uint8_t *dp_peer_get_peer_mac_addr(void *peer);
  1256. /**
  1257. * dp_get_peer_state() - Get local peer state
  1258. * @soc - datapath soc handle
  1259. * @vdev_id - vdev id
  1260. * @peer_mac - peer mac addr
  1261. *
  1262. * Get local peer state
  1263. *
  1264. * Return: peer status
  1265. */
  1266. int dp_get_peer_state(struct cdp_soc_t *soc, uint8_t vdev_id,
  1267. uint8_t *peer_mac);
  1268. void dp_local_peer_id_pool_init(struct dp_pdev *pdev);
  1269. void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer);
  1270. void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer);
  1271. #else
  1272. /**
  1273. * dp_get_vdevid() - Get virtual interface id which peer registered
  1274. * @soc - datapath soc handle
  1275. * @peer_mac - peer mac address
  1276. * @vdev_id - virtual interface id which peer registered
  1277. *
  1278. * Get virtual interface id which peer registered
  1279. *
  1280. * Return: QDF_STATUS_SUCCESS registration success
  1281. */
  1282. static inline
  1283. QDF_STATUS dp_get_vdevid(struct cdp_soc_t *soc_hdl, uint8_t *peer_mac,
  1284. uint8_t *vdev_id)
  1285. {
  1286. return QDF_STATUS_E_NOSUPPORT;
  1287. }
  1288. static inline void dp_local_peer_id_pool_init(struct dp_pdev *pdev)
  1289. {
  1290. }
  1291. static inline
  1292. void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer)
  1293. {
  1294. }
  1295. static inline
  1296. void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer)
  1297. {
  1298. }
  1299. #endif
  1300. int dp_addba_resp_tx_completion_wifi3(struct cdp_soc_t *cdp_soc,
  1301. uint8_t *peer_mac, uint16_t vdev_id,
  1302. uint8_t tid,
  1303. int status);
  1304. int dp_addba_requestprocess_wifi3(struct cdp_soc_t *cdp_soc,
  1305. uint8_t *peer_mac, uint16_t vdev_id,
  1306. uint8_t dialogtoken, uint16_t tid,
  1307. uint16_t batimeout,
  1308. uint16_t buffersize,
  1309. uint16_t startseqnum);
  1310. QDF_STATUS dp_addba_responsesetup_wifi3(struct cdp_soc_t *cdp_soc,
  1311. uint8_t *peer_mac, uint16_t vdev_id,
  1312. uint8_t tid, uint8_t *dialogtoken,
  1313. uint16_t *statuscode,
  1314. uint16_t *buffersize,
  1315. uint16_t *batimeout);
  1316. QDF_STATUS dp_set_addba_response(struct cdp_soc_t *cdp_soc,
  1317. uint8_t *peer_mac,
  1318. uint16_t vdev_id, uint8_t tid,
  1319. uint16_t statuscode);
  1320. int dp_delba_process_wifi3(struct cdp_soc_t *cdp_soc, uint8_t *peer_mac,
  1321. uint16_t vdev_id, int tid,
  1322. uint16_t reasoncode);
  1323. /*
  1324. * dp_delba_tx_completion_wifi3() - Handle delba tx completion
  1325. *
  1326. * @cdp_soc: soc handle
  1327. * @vdev_id: id of the vdev handle
  1328. * @peer_mac: peer mac address
  1329. * @tid: Tid number
  1330. * @status: Tx completion status
  1331. * Indicate status of delba Tx to DP for stats update and retry
  1332. * delba if tx failed.
  1333. *
  1334. */
  1335. int dp_delba_tx_completion_wifi3(struct cdp_soc_t *cdp_soc, uint8_t *peer_mac,
  1336. uint16_t vdev_id, uint8_t tid,
  1337. int status);
  1338. extern QDF_STATUS dp_rx_tid_setup_wifi3(struct dp_peer *peer, int tid,
  1339. uint32_t ba_window_size,
  1340. uint32_t start_seq);
  1341. extern QDF_STATUS dp_reo_send_cmd(struct dp_soc *soc,
  1342. enum hal_reo_cmd_type type, struct hal_reo_cmd_params *params,
  1343. void (*callback_fn), void *data);
  1344. extern void dp_reo_cmdlist_destroy(struct dp_soc *soc);
  1345. /**
  1346. * dp_reo_status_ring_handler - Handler for REO Status ring
  1347. * @int_ctx: pointer to DP interrupt context
  1348. * @soc: DP Soc handle
  1349. *
  1350. * Returns: Number of descriptors reaped
  1351. */
  1352. uint32_t dp_reo_status_ring_handler(struct dp_intr *int_ctx,
  1353. struct dp_soc *soc);
  1354. void dp_aggregate_vdev_stats(struct dp_vdev *vdev,
  1355. struct cdp_vdev_stats *vdev_stats);
  1356. void dp_rx_tid_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  1357. union hal_reo_status *reo_status);
  1358. void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  1359. union hal_reo_status *reo_status);
  1360. uint16_t dp_tx_me_send_convert_ucast(struct cdp_soc_t *soc, uint8_t vdev_id,
  1361. qdf_nbuf_t nbuf,
  1362. uint8_t newmac[][QDF_MAC_ADDR_SIZE],
  1363. uint8_t new_mac_cnt, uint8_t tid,
  1364. bool is_igmp, bool is_dms_pkt);
  1365. void dp_tx_me_alloc_descriptor(struct cdp_soc_t *soc, uint8_t pdev_id);
  1366. void dp_tx_me_free_descriptor(struct cdp_soc_t *soc, uint8_t pdev_id);
  1367. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  1368. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  1369. uint32_t config_param_1, uint32_t config_param_2,
  1370. uint32_t config_param_3, int cookie, int cookie_msb,
  1371. uint8_t mac_id);
  1372. void dp_htt_stats_print_tag(struct dp_pdev *pdev,
  1373. uint8_t tag_type, uint32_t *tag_buf);
  1374. void dp_htt_stats_copy_tag(struct dp_pdev *pdev, uint8_t tag_type, uint32_t *tag_buf);
  1375. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev, uint32_t tuple_mask,
  1376. uint8_t mac_id);
  1377. /**
  1378. * dp_rxtid_stats_cmd_cb - function pointer for peer
  1379. * rx tid stats cmd call_back
  1380. */
  1381. typedef void (*dp_rxtid_stats_cmd_cb)(struct dp_soc *soc, void *cb_ctxt,
  1382. union hal_reo_status *reo_status);
  1383. int dp_peer_rxtid_stats(struct dp_peer *peer,
  1384. dp_rxtid_stats_cmd_cb dp_stats_cmd_cb,
  1385. void *cb_ctxt);
  1386. QDF_STATUS
  1387. dp_set_pn_check_wifi3(struct cdp_soc_t *soc, uint8_t vdev_id,
  1388. uint8_t *peer_mac, enum cdp_sec_type sec_type,
  1389. uint32_t *rx_pn);
  1390. QDF_STATUS
  1391. dp_set_key_sec_type_wifi3(struct cdp_soc_t *soc, uint8_t vdev_id,
  1392. uint8_t *peer_mac, enum cdp_sec_type sec_type,
  1393. bool is_unicast);
  1394. void *dp_get_pdev_for_mac_id(struct dp_soc *soc, uint32_t mac_id);
  1395. QDF_STATUS
  1396. dp_set_michael_key(struct cdp_soc_t *soc, uint8_t vdev_id,
  1397. uint8_t *peer_mac,
  1398. bool is_unicast, uint32_t *key);
  1399. /**
  1400. * dp_check_pdev_exists() - Validate pdev before use
  1401. * @soc - dp soc handle
  1402. * @data - pdev handle
  1403. *
  1404. * Return: 0 - success/invalid - failure
  1405. */
  1406. bool dp_check_pdev_exists(struct dp_soc *soc, struct dp_pdev *data);
  1407. /**
  1408. * dp_update_delay_stats() - Update delay statistics in structure
  1409. * and fill min, max and avg delay
  1410. * @pdev: pdev handle
  1411. * @delay: delay in ms
  1412. * @tid: tid value
  1413. * @mode: type of tx delay mode
  1414. * @ring id: ring number
  1415. *
  1416. * Return: none
  1417. */
  1418. void dp_update_delay_stats(struct dp_pdev *pdev, uint32_t delay,
  1419. uint8_t tid, uint8_t mode, uint8_t ring_id);
  1420. /**
  1421. * dp_print_ring_stats(): Print tail and head pointer
  1422. * @pdev: DP_PDEV handle
  1423. *
  1424. * Return:void
  1425. */
  1426. void dp_print_ring_stats(struct dp_pdev *pdev);
  1427. /**
  1428. * dp_print_pdev_cfg_params() - Print the pdev cfg parameters
  1429. * @pdev_handle: DP pdev handle
  1430. *
  1431. * Return - void
  1432. */
  1433. void dp_print_pdev_cfg_params(struct dp_pdev *pdev);
  1434. /**
  1435. * dp_print_soc_cfg_params()- Dump soc wlan config parameters
  1436. * @soc_handle: Soc handle
  1437. *
  1438. * Return: void
  1439. */
  1440. void dp_print_soc_cfg_params(struct dp_soc *soc);
  1441. /**
  1442. * dp_srng_get_str_from_ring_type() - Return string name for a ring
  1443. * @ring_type: Ring
  1444. *
  1445. * Return: char const pointer
  1446. */
  1447. const
  1448. char *dp_srng_get_str_from_hal_ring_type(enum hal_ring_type ring_type);
  1449. /*
  1450. * dp_txrx_path_stats() - Function to display dump stats
  1451. * @soc - soc handle
  1452. *
  1453. * return: none
  1454. */
  1455. void dp_txrx_path_stats(struct dp_soc *soc);
  1456. /*
  1457. * dp_print_per_ring_stats(): Packet count per ring
  1458. * @soc - soc handle
  1459. *
  1460. * Return - None
  1461. */
  1462. void dp_print_per_ring_stats(struct dp_soc *soc);
  1463. /**
  1464. * dp_aggregate_pdev_stats(): Consolidate stats at PDEV level
  1465. * @pdev: DP PDEV handle
  1466. *
  1467. * return: void
  1468. */
  1469. void dp_aggregate_pdev_stats(struct dp_pdev *pdev);
  1470. /**
  1471. * dp_print_rx_rates(): Print Rx rate stats
  1472. * @vdev: DP_VDEV handle
  1473. *
  1474. * Return:void
  1475. */
  1476. void dp_print_rx_rates(struct dp_vdev *vdev);
  1477. /**
  1478. * dp_print_tx_rates(): Print tx rates
  1479. * @vdev: DP_VDEV handle
  1480. *
  1481. * Return:void
  1482. */
  1483. void dp_print_tx_rates(struct dp_vdev *vdev);
  1484. /**
  1485. * dp_print_peer_stats():print peer stats
  1486. * @peer: DP_PEER handle
  1487. *
  1488. * return void
  1489. */
  1490. void dp_print_peer_stats(struct dp_peer *peer);
  1491. /**
  1492. * dp_print_pdev_tx_stats(): Print Pdev level TX stats
  1493. * @pdev: DP_PDEV Handle
  1494. *
  1495. * Return:void
  1496. */
  1497. void
  1498. dp_print_pdev_tx_stats(struct dp_pdev *pdev);
  1499. /**
  1500. * dp_print_pdev_rx_stats(): Print Pdev level RX stats
  1501. * @pdev: DP_PDEV Handle
  1502. *
  1503. * Return: void
  1504. */
  1505. void
  1506. dp_print_pdev_rx_stats(struct dp_pdev *pdev);
  1507. /**
  1508. * dp_print_soc_tx_stats(): Print SOC level stats
  1509. * @soc DP_SOC Handle
  1510. *
  1511. * Return: void
  1512. */
  1513. void dp_print_soc_tx_stats(struct dp_soc *soc);
  1514. /**
  1515. * dp_print_soc_interrupt_stats() - Print interrupt stats for the soc
  1516. * @soc: dp_soc handle
  1517. *
  1518. * Return: None
  1519. */
  1520. void dp_print_soc_interrupt_stats(struct dp_soc *soc);
  1521. /**
  1522. * dp_print_soc_rx_stats: Print SOC level Rx stats
  1523. * @soc: DP_SOC Handle
  1524. *
  1525. * Return:void
  1526. */
  1527. void dp_print_soc_rx_stats(struct dp_soc *soc);
  1528. /**
  1529. * dp_get_mac_id_for_pdev() - Return mac corresponding to pdev for mac
  1530. *
  1531. * @mac_id: MAC id
  1532. * @pdev_id: pdev_id corresponding to pdev, 0 for MCL
  1533. *
  1534. * Single pdev using both MACs will operate on both MAC rings,
  1535. * which is the case for MCL.
  1536. * For WIN each PDEV will operate one ring, so index is zero.
  1537. *
  1538. */
  1539. static inline int dp_get_mac_id_for_pdev(uint32_t mac_id, uint32_t pdev_id)
  1540. {
  1541. if (mac_id && pdev_id) {
  1542. qdf_print("Both mac_id and pdev_id cannot be non zero");
  1543. QDF_BUG(0);
  1544. return 0;
  1545. }
  1546. return (mac_id + pdev_id);
  1547. }
  1548. /**
  1549. * dp_get_lmac_id_for_pdev_id() - Return lmac id corresponding to host pdev id
  1550. * @soc: soc pointer
  1551. * @mac_id: MAC id
  1552. * @pdev_id: pdev_id corresponding to pdev, 0 for MCL
  1553. *
  1554. * For MCL, Single pdev using both MACs will operate on both MAC rings.
  1555. *
  1556. * For WIN, each PDEV will operate one ring.
  1557. *
  1558. */
  1559. static inline int
  1560. dp_get_lmac_id_for_pdev_id
  1561. (struct dp_soc *soc, uint32_t mac_id, uint32_t pdev_id)
  1562. {
  1563. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx)) {
  1564. if (mac_id && pdev_id) {
  1565. qdf_print("Both mac_id and pdev_id cannot be non zero");
  1566. QDF_BUG(0);
  1567. return 0;
  1568. }
  1569. return (mac_id + pdev_id);
  1570. }
  1571. return soc->pdev_list[pdev_id]->lmac_id;
  1572. }
  1573. /**
  1574. * dp_get_pdev_for_lmac_id() - Return pdev pointer corresponding to lmac id
  1575. * @soc: soc pointer
  1576. * @lmac_id: LMAC id
  1577. *
  1578. * For MCL, Single pdev exists
  1579. *
  1580. * For WIN, each PDEV will operate one ring.
  1581. *
  1582. */
  1583. static inline struct dp_pdev *
  1584. dp_get_pdev_for_lmac_id(struct dp_soc *soc, uint32_t lmac_id)
  1585. {
  1586. uint8_t i = 0;
  1587. if (wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx)) {
  1588. i = wlan_cfg_get_pdev_idx(soc->wlan_cfg_ctx, lmac_id);
  1589. return ((i < MAX_PDEV_CNT) ? soc->pdev_list[i] : NULL);
  1590. }
  1591. /* Typically for MCL as there only 1 PDEV*/
  1592. return soc->pdev_list[0];
  1593. }
  1594. /**
  1595. * dp_calculate_target_pdev_id_from_host_pdev_id() - Return target pdev
  1596. * corresponding to host pdev id
  1597. * @soc: soc pointer
  1598. * @mac_for_pdev: pdev_id corresponding to host pdev for WIN, mac id for MCL
  1599. *
  1600. * returns target pdev_id for host pdev id. For WIN, this is derived through
  1601. * a two step process:
  1602. * 1. Get lmac_id corresponding to host pdev_id (lmac_id can change
  1603. * during mode switch)
  1604. * 2. Get target pdev_id (set up during WMI ready) from lmac_id
  1605. *
  1606. * For MCL, return the offset-1 translated mac_id
  1607. */
  1608. static inline int
  1609. dp_calculate_target_pdev_id_from_host_pdev_id
  1610. (struct dp_soc *soc, uint32_t mac_for_pdev)
  1611. {
  1612. struct dp_pdev *pdev;
  1613. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  1614. return DP_SW2HW_MACID(mac_for_pdev);
  1615. pdev = soc->pdev_list[mac_for_pdev];
  1616. /*non-MCL case, get original target_pdev mapping*/
  1617. return wlan_cfg_get_target_pdev_id(soc->wlan_cfg_ctx, pdev->lmac_id);
  1618. }
  1619. /**
  1620. * dp_get_target_pdev_id_for_host_pdev_id() - Return target pdev corresponding
  1621. * to host pdev id
  1622. * @soc: soc pointer
  1623. * @mac_for_pdev: pdev_id corresponding to host pdev for WIN, mac id for MCL
  1624. *
  1625. * returns target pdev_id for host pdev id.
  1626. * For WIN, return the value stored in pdev object.
  1627. * For MCL, return the offset-1 translated mac_id.
  1628. */
  1629. static inline int
  1630. dp_get_target_pdev_id_for_host_pdev_id
  1631. (struct dp_soc *soc, uint32_t mac_for_pdev)
  1632. {
  1633. struct dp_pdev *pdev;
  1634. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  1635. return DP_SW2HW_MACID(mac_for_pdev);
  1636. pdev = soc->pdev_list[mac_for_pdev];
  1637. return pdev->target_pdev_id;
  1638. }
  1639. /**
  1640. * dp_get_host_pdev_id_for_target_pdev_id() - Return host pdev corresponding
  1641. * to target pdev id
  1642. * @soc: soc pointer
  1643. * @pdev_id: pdev_id corresponding to target pdev
  1644. *
  1645. * returns host pdev_id for target pdev id. For WIN, this is derived through
  1646. * a two step process:
  1647. * 1. Get lmac_id corresponding to target pdev_id
  1648. * 2. Get host pdev_id (set up during WMI ready) from lmac_id
  1649. *
  1650. * For MCL, return the 0-offset pdev_id
  1651. */
  1652. static inline int
  1653. dp_get_host_pdev_id_for_target_pdev_id
  1654. (struct dp_soc *soc, uint32_t pdev_id)
  1655. {
  1656. struct dp_pdev *pdev;
  1657. int lmac_id;
  1658. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  1659. return DP_HW2SW_MACID(pdev_id);
  1660. /*non-MCL case, get original target_lmac mapping from target pdev*/
  1661. lmac_id = wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx,
  1662. DP_HW2SW_MACID(pdev_id));
  1663. /*Get host pdev from lmac*/
  1664. pdev = dp_get_pdev_for_lmac_id(soc, lmac_id);
  1665. return pdev ? pdev->pdev_id : INVALID_PDEV_ID;
  1666. }
  1667. /*
  1668. * dp_get_mac_id_for_mac() - Return mac corresponding WIN and MCL mac_ids
  1669. *
  1670. * @soc: handle to DP soc
  1671. * @mac_id: MAC id
  1672. *
  1673. * Single pdev using both MACs will operate on both MAC rings,
  1674. * which is the case for MCL.
  1675. * For WIN each PDEV will operate one ring, so index is zero.
  1676. *
  1677. */
  1678. static inline int dp_get_mac_id_for_mac(struct dp_soc *soc, uint32_t mac_id)
  1679. {
  1680. /*
  1681. * Single pdev using both MACs will operate on both MAC rings,
  1682. * which is the case for MCL.
  1683. */
  1684. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  1685. return mac_id;
  1686. /* For WIN each PDEV will operate one ring, so index is zero. */
  1687. return 0;
  1688. }
  1689. /*
  1690. * dp_is_subtype_data() - check if the frame subtype is data
  1691. *
  1692. * @frame_ctrl: Frame control field
  1693. *
  1694. * check the frame control field and verify if the packet
  1695. * is a data packet.
  1696. *
  1697. * Return: true or false
  1698. */
  1699. static inline bool dp_is_subtype_data(uint16_t frame_ctrl)
  1700. {
  1701. if (((qdf_cpu_to_le16(frame_ctrl) & QDF_IEEE80211_FC0_TYPE_MASK) ==
  1702. QDF_IEEE80211_FC0_TYPE_DATA) &&
  1703. (((qdf_cpu_to_le16(frame_ctrl) & QDF_IEEE80211_FC0_SUBTYPE_MASK) ==
  1704. QDF_IEEE80211_FC0_SUBTYPE_DATA) ||
  1705. ((qdf_cpu_to_le16(frame_ctrl) & QDF_IEEE80211_FC0_SUBTYPE_MASK) ==
  1706. QDF_IEEE80211_FC0_SUBTYPE_QOS))) {
  1707. return true;
  1708. }
  1709. return false;
  1710. }
  1711. #ifdef WDI_EVENT_ENABLE
  1712. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  1713. uint32_t stats_type_upload_mask,
  1714. uint8_t mac_id);
  1715. int dp_wdi_event_unsub(struct cdp_soc_t *soc, uint8_t pdev_id,
  1716. wdi_event_subscribe *event_cb_sub_handle,
  1717. uint32_t event);
  1718. int dp_wdi_event_sub(struct cdp_soc_t *soc, uint8_t pdev_id,
  1719. wdi_event_subscribe *event_cb_sub_handle,
  1720. uint32_t event);
  1721. void dp_wdi_event_handler(enum WDI_EVENT event, struct dp_soc *soc,
  1722. void *data, u_int16_t peer_id,
  1723. int status, u_int8_t pdev_id);
  1724. int dp_wdi_event_attach(struct dp_pdev *txrx_pdev);
  1725. int dp_wdi_event_detach(struct dp_pdev *txrx_pdev);
  1726. static inline void
  1727. dp_hif_update_pipe_callback(struct dp_soc *dp_soc,
  1728. void *cb_context,
  1729. QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t),
  1730. uint8_t pipe_id)
  1731. {
  1732. struct hif_msg_callbacks hif_pipe_callbacks;
  1733. /* TODO: Temporary change to bypass HTC connection for this new
  1734. * HIF pipe, which will be used for packet log and other high-
  1735. * priority HTT messages. Proper HTC connection to be added
  1736. * later once required FW changes are available
  1737. */
  1738. hif_pipe_callbacks.rxCompletionHandler = callback;
  1739. hif_pipe_callbacks.Context = cb_context;
  1740. hif_update_pipe_callback(dp_soc->hif_handle,
  1741. DP_HTT_T2H_HP_PIPE, &hif_pipe_callbacks);
  1742. }
  1743. #else
  1744. static inline int dp_wdi_event_unsub(struct cdp_soc_t *soc, uint8_t pdev_id,
  1745. wdi_event_subscribe *event_cb_sub_handle,
  1746. uint32_t event)
  1747. {
  1748. return 0;
  1749. }
  1750. static inline int dp_wdi_event_sub(struct cdp_soc_t *soc, uint8_t pdev_id,
  1751. wdi_event_subscribe *event_cb_sub_handle,
  1752. uint32_t event)
  1753. {
  1754. return 0;
  1755. }
  1756. static inline
  1757. void dp_wdi_event_handler(enum WDI_EVENT event,
  1758. struct dp_soc *soc,
  1759. void *data, u_int16_t peer_id,
  1760. int status, u_int8_t pdev_id)
  1761. {
  1762. }
  1763. static inline int dp_wdi_event_attach(struct dp_pdev *txrx_pdev)
  1764. {
  1765. return 0;
  1766. }
  1767. static inline int dp_wdi_event_detach(struct dp_pdev *txrx_pdev)
  1768. {
  1769. return 0;
  1770. }
  1771. static inline QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  1772. uint32_t stats_type_upload_mask, uint8_t mac_id)
  1773. {
  1774. return 0;
  1775. }
  1776. static inline void
  1777. dp_hif_update_pipe_callback(struct dp_soc *dp_soc, void *cb_context,
  1778. QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t),
  1779. uint8_t pipe_id)
  1780. {
  1781. }
  1782. #endif /* CONFIG_WIN */
  1783. #ifdef VDEV_PEER_PROTOCOL_COUNT
  1784. /**
  1785. * dp_vdev_peer_stats_update_protocol_cnt() - update per-peer protocol counters
  1786. * @vdev: VDEV DP object
  1787. * @nbuf: data packet
  1788. * @peer: Peer DP object
  1789. * @is_egress: whether egress or ingress
  1790. * @is_rx: whether rx or tx
  1791. *
  1792. * This function updates the per-peer protocol counters
  1793. * Return: void
  1794. */
  1795. void dp_vdev_peer_stats_update_protocol_cnt(struct dp_vdev *vdev,
  1796. qdf_nbuf_t nbuf,
  1797. struct dp_peer *peer,
  1798. bool is_egress,
  1799. bool is_rx);
  1800. /**
  1801. * dp_vdev_peer_stats_update_protocol_cnt() - update per-peer protocol counters
  1802. * @soc: SOC DP object
  1803. * @vdev_id: vdev_id
  1804. * @nbuf: data packet
  1805. * @is_egress: whether egress or ingress
  1806. * @is_rx: whether rx or tx
  1807. *
  1808. * This function updates the per-peer protocol counters
  1809. * Return: void
  1810. */
  1811. void dp_peer_stats_update_protocol_cnt(struct cdp_soc_t *soc,
  1812. int8_t vdev_id,
  1813. qdf_nbuf_t nbuf,
  1814. bool is_egress,
  1815. bool is_rx);
  1816. void dp_vdev_peer_stats_update_protocol_cnt_tx(struct dp_vdev *vdev_hdl,
  1817. qdf_nbuf_t nbuf);
  1818. #else
  1819. #define dp_vdev_peer_stats_update_protocol_cnt(vdev, nbuf, peer, \
  1820. is_egress, is_rx)
  1821. static inline
  1822. void dp_vdev_peer_stats_update_protocol_cnt_tx(struct dp_vdev *vdev_hdl,
  1823. qdf_nbuf_t nbuf)
  1824. {
  1825. }
  1826. #endif
  1827. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  1828. void dp_tx_dump_flow_pool_info(struct cdp_soc_t *soc_hdl);
  1829. /**
  1830. * dp_tx_dump_flow_pool_info_compact() - dump flow pool info
  1831. * @soc: DP soc context
  1832. *
  1833. * Return: none
  1834. */
  1835. void dp_tx_dump_flow_pool_info_compact(struct dp_soc *soc);
  1836. int dp_tx_delete_flow_pool(struct dp_soc *soc, struct dp_tx_desc_pool_s *pool,
  1837. bool force);
  1838. #else
  1839. static inline void dp_tx_dump_flow_pool_info_compact(struct dp_soc *soc)
  1840. {
  1841. }
  1842. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
  1843. #ifdef QCA_OL_DP_SRNG_LOCK_LESS_ACCESS
  1844. static inline int
  1845. dp_hal_srng_access_start(hal_soc_handle_t soc, hal_ring_handle_t hal_ring_hdl)
  1846. {
  1847. return hal_srng_access_start_unlocked(soc, hal_ring_hdl);
  1848. }
  1849. static inline void
  1850. dp_hal_srng_access_end(hal_soc_handle_t soc, hal_ring_handle_t hal_ring_hdl)
  1851. {
  1852. hal_srng_access_end_unlocked(soc, hal_ring_hdl);
  1853. }
  1854. #else
  1855. static inline int
  1856. dp_hal_srng_access_start(hal_soc_handle_t soc, hal_ring_handle_t hal_ring_hdl)
  1857. {
  1858. return hal_srng_access_start(soc, hal_ring_hdl);
  1859. }
  1860. static inline void
  1861. dp_hal_srng_access_end(hal_soc_handle_t soc, hal_ring_handle_t hal_ring_hdl)
  1862. {
  1863. hal_srng_access_end(soc, hal_ring_hdl);
  1864. }
  1865. #endif
  1866. #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
  1867. /**
  1868. * dp_srng_access_start() - Wrapper function to log access start of a hal ring
  1869. * @int_ctx: pointer to DP interrupt context. This should not be NULL
  1870. * @soc: DP Soc handle
  1871. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  1872. *
  1873. * Return: 0 on success; error on failure
  1874. */
  1875. int dp_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *dp_soc,
  1876. hal_ring_handle_t hal_ring_hdl);
  1877. /**
  1878. * dp_srng_access_end() - Wrapper function to log access end of a hal ring
  1879. * @int_ctx: pointer to DP interrupt context. This should not be NULL
  1880. * @soc: DP Soc handle
  1881. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  1882. *
  1883. * Return: void
  1884. */
  1885. void dp_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *dp_soc,
  1886. hal_ring_handle_t hal_ring_hdl);
  1887. #else
  1888. static inline int dp_srng_access_start(struct dp_intr *int_ctx,
  1889. struct dp_soc *dp_soc,
  1890. hal_ring_handle_t hal_ring_hdl)
  1891. {
  1892. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1893. return dp_hal_srng_access_start(hal_soc, hal_ring_hdl);
  1894. }
  1895. static inline void dp_srng_access_end(struct dp_intr *int_ctx,
  1896. struct dp_soc *dp_soc,
  1897. hal_ring_handle_t hal_ring_hdl)
  1898. {
  1899. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1900. return dp_hal_srng_access_end(hal_soc, hal_ring_hdl);
  1901. }
  1902. #endif /* WLAN_FEATURE_DP_EVENT_HISTORY */
  1903. #ifdef QCA_CACHED_RING_DESC
  1904. /**
  1905. * dp_srng_dst_get_next() - Wrapper function to get next ring desc
  1906. * @dp_socsoc: DP Soc handle
  1907. * @hal_ring: opaque pointer to the HAL Destination Ring
  1908. *
  1909. * Return: HAL ring descriptor
  1910. */
  1911. static inline void *dp_srng_dst_get_next(struct dp_soc *dp_soc,
  1912. hal_ring_handle_t hal_ring_hdl)
  1913. {
  1914. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1915. return hal_srng_dst_get_next_cached(hal_soc, hal_ring_hdl);
  1916. }
  1917. /**
  1918. * dp_srng_dst_inv_cached_descs() - Wrapper function to invalidate cached
  1919. * descriptors
  1920. * @dp_socsoc: DP Soc handle
  1921. * @hal_ring: opaque pointer to the HAL Rx Destination ring
  1922. * @num_entries: Entry count
  1923. *
  1924. * Return: None
  1925. */
  1926. static inline void dp_srng_dst_inv_cached_descs(struct dp_soc *dp_soc,
  1927. hal_ring_handle_t hal_ring_hdl,
  1928. uint32_t num_entries)
  1929. {
  1930. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1931. hal_srng_dst_inv_cached_descs(hal_soc, hal_ring_hdl, num_entries);
  1932. }
  1933. #else
  1934. static inline void *dp_srng_dst_get_next(struct dp_soc *dp_soc,
  1935. hal_ring_handle_t hal_ring_hdl)
  1936. {
  1937. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1938. return hal_srng_dst_get_next(hal_soc, hal_ring_hdl);
  1939. }
  1940. static inline void dp_srng_dst_inv_cached_descs(struct dp_soc *dp_soc,
  1941. hal_ring_handle_t hal_ring_hdl,
  1942. uint32_t num_entries)
  1943. {
  1944. }
  1945. #endif /* QCA_CACHED_RING_DESC */
  1946. #if defined(QCA_CACHED_RING_DESC) && \
  1947. (defined(QCA_DP_RX_HW_SW_NBUF_DESC_PREFETCH) || \
  1948. defined(QCA_DP_TX_HW_SW_NBUF_DESC_PREFETCH))
  1949. /**
  1950. * dp_srng_dst_prefetch() - Wrapper function to prefetch descs from dest ring
  1951. * @hal_soc_hdl: HAL SOC handle
  1952. * @hal_ring: opaque pointer to the HAL Rx Destination ring
  1953. * @num_entries: Entry count
  1954. *
  1955. * Return: None
  1956. */
  1957. static inline void *dp_srng_dst_prefetch(hal_soc_handle_t hal_soc,
  1958. hal_ring_handle_t hal_ring_hdl,
  1959. uint32_t num_entries)
  1960. {
  1961. return hal_srng_dst_prefetch(hal_soc, hal_ring_hdl, num_entries);
  1962. }
  1963. #else
  1964. static inline void *dp_srng_dst_prefetch(hal_soc_handle_t hal_soc,
  1965. hal_ring_handle_t hal_ring_hdl,
  1966. uint32_t num_entries)
  1967. {
  1968. return NULL;
  1969. }
  1970. #endif
  1971. #ifdef QCA_ENH_V3_STATS_SUPPORT
  1972. /**
  1973. * dp_pdev_print_delay_stats(): Print pdev level delay stats
  1974. * @pdev: DP_PDEV handle
  1975. *
  1976. * Return:void
  1977. */
  1978. void dp_pdev_print_delay_stats(struct dp_pdev *pdev);
  1979. /**
  1980. * dp_pdev_print_tid_stats(): Print pdev level tid stats
  1981. * @pdev: DP_PDEV handle
  1982. *
  1983. * Return:void
  1984. */
  1985. void dp_pdev_print_tid_stats(struct dp_pdev *pdev);
  1986. /**
  1987. * dp_pdev_print_rx_error_stats(): Print pdev level rx error stats
  1988. * @pdev: DP_PDEV handle
  1989. *
  1990. * Return:void
  1991. */
  1992. void dp_pdev_print_rx_error_stats(struct dp_pdev *pdev);
  1993. #endif /* CONFIG_WIN */
  1994. void dp_soc_set_txrx_ring_map(struct dp_soc *soc);
  1995. /**
  1996. * dp_vdev_to_cdp_vdev() - typecast dp vdev to cdp vdev
  1997. * @vdev: DP vdev handle
  1998. *
  1999. * Return: struct cdp_vdev pointer
  2000. */
  2001. static inline
  2002. struct cdp_vdev *dp_vdev_to_cdp_vdev(struct dp_vdev *vdev)
  2003. {
  2004. return (struct cdp_vdev *)vdev;
  2005. }
  2006. /**
  2007. * dp_pdev_to_cdp_pdev() - typecast dp pdev to cdp pdev
  2008. * @pdev: DP pdev handle
  2009. *
  2010. * Return: struct cdp_pdev pointer
  2011. */
  2012. static inline
  2013. struct cdp_pdev *dp_pdev_to_cdp_pdev(struct dp_pdev *pdev)
  2014. {
  2015. return (struct cdp_pdev *)pdev;
  2016. }
  2017. /**
  2018. * dp_soc_to_cdp_soc() - typecast dp psoc to cdp psoc
  2019. * @psoc: DP psoc handle
  2020. *
  2021. * Return: struct cdp_soc pointer
  2022. */
  2023. static inline
  2024. struct cdp_soc *dp_soc_to_cdp_soc(struct dp_soc *psoc)
  2025. {
  2026. return (struct cdp_soc *)psoc;
  2027. }
  2028. /**
  2029. * dp_soc_to_cdp_soc_t() - typecast dp psoc to
  2030. * ol txrx soc handle
  2031. * @psoc: DP psoc handle
  2032. *
  2033. * Return: struct cdp_soc_t pointer
  2034. */
  2035. static inline
  2036. struct cdp_soc_t *dp_soc_to_cdp_soc_t(struct dp_soc *psoc)
  2037. {
  2038. return (struct cdp_soc_t *)psoc;
  2039. }
  2040. #if defined(WLAN_SUPPORT_RX_FLOW_TAG) || defined(WLAN_SUPPORT_RX_FISA)
  2041. /**
  2042. * dp_rx_flow_update_fse_stats() - Update a flow's statistics
  2043. * @pdev: pdev handle
  2044. * @flow_id: flow index (truncated hash) in the Rx FST
  2045. *
  2046. * Return: Success when flow statistcs is updated, error on failure
  2047. */
  2048. QDF_STATUS dp_rx_flow_get_fse_stats(struct dp_pdev *pdev,
  2049. struct cdp_rx_flow_info *rx_flow_info,
  2050. struct cdp_flow_stats *stats);
  2051. /**
  2052. * dp_rx_flow_delete_entry() - Delete a flow entry from flow search table
  2053. * @pdev: pdev handle
  2054. * @rx_flow_info: DP flow parameters
  2055. *
  2056. * Return: Success when flow is deleted, error on failure
  2057. */
  2058. QDF_STATUS dp_rx_flow_delete_entry(struct dp_pdev *pdev,
  2059. struct cdp_rx_flow_info *rx_flow_info);
  2060. /**
  2061. * dp_rx_flow_add_entry() - Add a flow entry to flow search table
  2062. * @pdev: DP pdev instance
  2063. * @rx_flow_info: DP flow paramaters
  2064. *
  2065. * Return: Success when flow is added, no-memory or already exists on error
  2066. */
  2067. QDF_STATUS dp_rx_flow_add_entry(struct dp_pdev *pdev,
  2068. struct cdp_rx_flow_info *rx_flow_info);
  2069. /**
  2070. * dp_rx_fst_attach() - Initialize Rx FST and setup necessary parameters
  2071. * @soc: SoC handle
  2072. * @pdev: Pdev handle
  2073. *
  2074. * Return: Handle to flow search table entry
  2075. */
  2076. QDF_STATUS dp_rx_fst_attach(struct dp_soc *soc, struct dp_pdev *pdev);
  2077. /**
  2078. * dp_rx_fst_detach() - De-initialize Rx FST
  2079. * @soc: SoC handle
  2080. * @pdev: Pdev handle
  2081. *
  2082. * Return: None
  2083. */
  2084. void dp_rx_fst_detach(struct dp_soc *soc, struct dp_pdev *pdev);
  2085. /**
  2086. * dp_rx_flow_send_fst_fw_setup() - Program FST parameters in FW/HW post-attach
  2087. * @soc: SoC handle
  2088. * @pdev: Pdev handle
  2089. *
  2090. * Return: Success when fst parameters are programmed in FW, error otherwise
  2091. */
  2092. QDF_STATUS dp_rx_flow_send_fst_fw_setup(struct dp_soc *soc,
  2093. struct dp_pdev *pdev);
  2094. #else /* !((WLAN_SUPPORT_RX_FLOW_TAG) || defined(WLAN_SUPPORT_RX_FISA)) */
  2095. /**
  2096. * dp_rx_fst_attach() - Initialize Rx FST and setup necessary parameters
  2097. * @soc: SoC handle
  2098. * @pdev: Pdev handle
  2099. *
  2100. * Return: Handle to flow search table entry
  2101. */
  2102. static inline
  2103. QDF_STATUS dp_rx_fst_attach(struct dp_soc *soc, struct dp_pdev *pdev)
  2104. {
  2105. return QDF_STATUS_SUCCESS;
  2106. }
  2107. /**
  2108. * dp_rx_fst_detach() - De-initialize Rx FST
  2109. * @soc: SoC handle
  2110. * @pdev: Pdev handle
  2111. *
  2112. * Return: None
  2113. */
  2114. static inline
  2115. void dp_rx_fst_detach(struct dp_soc *soc, struct dp_pdev *pdev)
  2116. {
  2117. }
  2118. #endif
  2119. /**
  2120. * dp_vdev_get_ref() - API to take a reference for VDEV object
  2121. *
  2122. * @soc : core DP soc context
  2123. * @vdev : DP vdev
  2124. * @mod_id : module id
  2125. *
  2126. * Return: QDF_STATUS_SUCCESS if reference held successfully
  2127. * else QDF_STATUS_E_INVAL
  2128. */
  2129. static inline
  2130. QDF_STATUS dp_vdev_get_ref(struct dp_soc *soc, struct dp_vdev *vdev,
  2131. enum dp_mod_id mod_id)
  2132. {
  2133. if (!qdf_atomic_inc_not_zero(&vdev->ref_cnt))
  2134. return QDF_STATUS_E_INVAL;
  2135. qdf_atomic_inc(&vdev->mod_refs[mod_id]);
  2136. return QDF_STATUS_SUCCESS;
  2137. }
  2138. /**
  2139. * dp_vdev_get_ref_by_id() - Returns vdev object given the vdev id
  2140. * @soc: core DP soc context
  2141. * @vdev_id: vdev id from vdev object can be retrieved
  2142. * @mod_id: module id which is requesting the reference
  2143. *
  2144. * Return: struct dp_vdev*: Pointer to DP vdev object
  2145. */
  2146. static inline struct dp_vdev *
  2147. dp_vdev_get_ref_by_id(struct dp_soc *soc, uint8_t vdev_id,
  2148. enum dp_mod_id mod_id)
  2149. {
  2150. struct dp_vdev *vdev = NULL;
  2151. if (qdf_unlikely(vdev_id >= MAX_VDEV_CNT))
  2152. return NULL;
  2153. qdf_spin_lock_bh(&soc->vdev_map_lock);
  2154. vdev = soc->vdev_id_map[vdev_id];
  2155. if (!vdev || dp_vdev_get_ref(soc, vdev, mod_id) != QDF_STATUS_SUCCESS) {
  2156. qdf_spin_unlock_bh(&soc->vdev_map_lock);
  2157. return NULL;
  2158. }
  2159. qdf_spin_unlock_bh(&soc->vdev_map_lock);
  2160. return vdev;
  2161. }
  2162. /**
  2163. * dp_get_pdev_from_soc_pdev_id_wifi3() - Returns pdev object given the pdev id
  2164. * @soc: core DP soc context
  2165. * @pdev_id: pdev id from pdev object can be retrieved
  2166. *
  2167. * Return: struct dp_pdev*: Pointer to DP pdev object
  2168. */
  2169. static inline struct dp_pdev *
  2170. dp_get_pdev_from_soc_pdev_id_wifi3(struct dp_soc *soc,
  2171. uint8_t pdev_id)
  2172. {
  2173. if (qdf_unlikely(pdev_id >= MAX_PDEV_CNT))
  2174. return NULL;
  2175. return soc->pdev_list[pdev_id];
  2176. }
  2177. /*
  2178. * dp_rx_tid_update_wifi3() – Update receive TID state
  2179. * @peer: Datapath peer handle
  2180. * @tid: TID
  2181. * @ba_window_size: BlockAck window size
  2182. * @start_seq: Starting sequence number
  2183. * @bar_update: BAR update triggered
  2184. *
  2185. * Return: QDF_STATUS code
  2186. */
  2187. QDF_STATUS dp_rx_tid_update_wifi3(struct dp_peer *peer, int tid, uint32_t
  2188. ba_window_size, uint32_t start_seq,
  2189. bool bar_update);
  2190. /**
  2191. * dp_get_peer_mac_list(): function to get peer mac list of vdev
  2192. * @soc: Datapath soc handle
  2193. * @vdev_id: vdev id
  2194. * @newmac: Table of the clients mac
  2195. * @mac_cnt: No. of MACs required
  2196. * @limit: Limit the number of clients
  2197. *
  2198. * return: no of clients
  2199. */
  2200. uint16_t dp_get_peer_mac_list(ol_txrx_soc_handle soc, uint8_t vdev_id,
  2201. u_int8_t newmac[][QDF_MAC_ADDR_SIZE],
  2202. u_int16_t mac_cnt, bool limit);
  2203. /*
  2204. * dp_is_hw_dbs_enable() - Procedure to check if DBS is supported
  2205. * @soc: DP SoC context
  2206. * @max_mac_rings: No of MAC rings
  2207. *
  2208. * Return: None
  2209. */
  2210. void dp_is_hw_dbs_enable(struct dp_soc *soc,
  2211. int *max_mac_rings);
  2212. #if defined(WLAN_SUPPORT_RX_FISA)
  2213. void dp_rx_dump_fisa_table(struct dp_soc *soc);
  2214. /*
  2215. * dp_rx_fst_update_cmem_params() - Update CMEM FST params
  2216. * @soc: DP SoC context
  2217. * @num_entries: Number of flow search entries
  2218. * @cmem_ba_lo: CMEM base address low
  2219. * @cmem_ba_hi: CMEM base address high
  2220. *
  2221. * Return: None
  2222. */
  2223. void dp_rx_fst_update_cmem_params(struct dp_soc *soc, uint16_t num_entries,
  2224. uint32_t cmem_ba_lo, uint32_t cmem_ba_hi);
  2225. void
  2226. dp_rx_fst_update_pm_suspend_status(struct dp_soc *soc, bool suspended);
  2227. #else
  2228. static inline void
  2229. dp_rx_fst_update_cmem_params(struct dp_soc *soc, uint16_t num_entries,
  2230. uint32_t cmem_ba_lo, uint32_t cmem_ba_hi)
  2231. {
  2232. }
  2233. static inline void
  2234. dp_rx_fst_update_pm_suspend_status(struct dp_soc *soc, bool suspended)
  2235. {
  2236. }
  2237. #endif /* WLAN_SUPPORT_RX_FISA */
  2238. #ifdef MAX_ALLOC_PAGE_SIZE
  2239. /**
  2240. * dp_set_page_size() - Set the max page size for hw link desc.
  2241. * For MCL the page size is set to OS defined value and for WIN
  2242. * the page size is set to the max_alloc_size cfg ini
  2243. * param.
  2244. * This is to ensure that WIN gets contiguous memory allocations
  2245. * as per requirement.
  2246. * @pages: link desc page handle
  2247. * @max_alloc_size: max_alloc_size
  2248. *
  2249. * Return: None
  2250. */
  2251. static inline
  2252. void dp_set_max_page_size(struct qdf_mem_multi_page_t *pages,
  2253. uint32_t max_alloc_size)
  2254. {
  2255. pages->page_size = qdf_page_size;
  2256. }
  2257. #else
  2258. static inline
  2259. void dp_set_max_page_size(struct qdf_mem_multi_page_t *pages,
  2260. uint32_t max_alloc_size)
  2261. {
  2262. pages->page_size = max_alloc_size;
  2263. }
  2264. #endif /* MAX_ALLOC_PAGE_SIZE */
  2265. /**
  2266. * dp_history_get_next_index() - get the next entry to record an entry
  2267. * in the history.
  2268. * @curr_idx: Current index where the last entry is written.
  2269. * @max_entries: Max number of entries in the history
  2270. *
  2271. * This function assumes that the max number os entries is a power of 2.
  2272. *
  2273. * Returns: The index where the next entry is to be written.
  2274. */
  2275. static inline uint32_t dp_history_get_next_index(qdf_atomic_t *curr_idx,
  2276. uint32_t max_entries)
  2277. {
  2278. uint32_t idx = qdf_atomic_inc_return(curr_idx);
  2279. return idx & (max_entries - 1);
  2280. }
  2281. /**
  2282. * dp_rx_skip_tlvs() - Skip TLVs len + L2 hdr_offset, save in nbuf->cb
  2283. * @nbuf: nbuf cb to be updated
  2284. * @l2_hdr_offset: l2_hdr_offset
  2285. *
  2286. * Return: None
  2287. */
  2288. void dp_rx_skip_tlvs(struct dp_soc *soc, qdf_nbuf_t nbuf, uint32_t l3_padding);
  2289. #ifndef FEATURE_WDS
  2290. static inline void
  2291. dp_hmwds_ast_add_notify(struct dp_peer *peer,
  2292. uint8_t *mac_addr,
  2293. enum cdp_txrx_ast_entry_type type,
  2294. QDF_STATUS err,
  2295. bool is_peer_map)
  2296. {
  2297. }
  2298. #endif
  2299. #ifdef HTT_STATS_DEBUGFS_SUPPORT
  2300. /* dp_pdev_htt_stats_dbgfs_init() - Function to allocate memory and initialize
  2301. * debugfs for HTT stats
  2302. * @pdev: dp pdev handle
  2303. *
  2304. * Return: QDF_STATUS
  2305. */
  2306. QDF_STATUS dp_pdev_htt_stats_dbgfs_init(struct dp_pdev *pdev);
  2307. /* dp_pdev_htt_stats_dbgfs_deinit() - Function to remove debugfs entry for
  2308. * HTT stats
  2309. * @pdev: dp pdev handle
  2310. *
  2311. * Return: none
  2312. */
  2313. void dp_pdev_htt_stats_dbgfs_deinit(struct dp_pdev *pdev);
  2314. #else
  2315. /* dp_pdev_htt_stats_dbgfs_init() - Function to allocate memory and initialize
  2316. * debugfs for HTT stats
  2317. * @pdev: dp pdev handle
  2318. *
  2319. * Return: QDF_STATUS
  2320. */
  2321. static inline QDF_STATUS
  2322. dp_pdev_htt_stats_dbgfs_init(struct dp_pdev *pdev)
  2323. {
  2324. return QDF_STATUS_SUCCESS;
  2325. }
  2326. /* dp_pdev_htt_stats_dbgfs_deinit() - Function to remove debugfs entry for
  2327. * HTT stats
  2328. * @pdev: dp pdev handle
  2329. *
  2330. * Return: none
  2331. */
  2332. static inline void
  2333. dp_pdev_htt_stats_dbgfs_deinit(struct dp_pdev *pdev)
  2334. {
  2335. }
  2336. #endif /* HTT_STATS_DEBUGFS_SUPPORT */
  2337. #ifndef WLAN_DP_FEATURE_SW_LATENCY_MGR
  2338. /**
  2339. * dp_soc_swlm_attach() - attach the software latency manager resources
  2340. * @soc: Datapath global soc handle
  2341. *
  2342. * Returns: QDF_STATUS
  2343. */
  2344. static inline QDF_STATUS dp_soc_swlm_attach(struct dp_soc *soc)
  2345. {
  2346. return QDF_STATUS_SUCCESS;
  2347. }
  2348. /**
  2349. * dp_soc_swlm_detach() - detach the software latency manager resources
  2350. * @soc: Datapath global soc handle
  2351. *
  2352. * Returns: QDF_STATUS
  2353. */
  2354. static inline QDF_STATUS dp_soc_swlm_detach(struct dp_soc *soc)
  2355. {
  2356. return QDF_STATUS_SUCCESS;
  2357. }
  2358. #endif /* !WLAN_DP_FEATURE_SW_LATENCY_MGR */
  2359. #ifdef QCA_SUPPORT_WDS_EXTENDED
  2360. /**
  2361. * dp_wds_ext_get_peer_id(): function to get peer id by mac
  2362. * This API is called from control path when wds extended
  2363. * device is created, hence it also updates wds extended
  2364. * peer state to up, which will be referred in rx processing.
  2365. * @soc: Datapath soc handle
  2366. * @vdev_id: vdev id
  2367. * @mac: Peer mac address
  2368. *
  2369. * return: valid peer id on success
  2370. * HTT_INVALID_PEER on failure
  2371. */
  2372. uint16_t dp_wds_ext_get_peer_id(ol_txrx_soc_handle soc,
  2373. uint8_t vdev_id,
  2374. uint8_t *mac);
  2375. /**
  2376. * dp_wds_ext_set_peer_state(): function to set peer state
  2377. * @soc: Datapath soc handle
  2378. * @vdev_id: vdev id
  2379. * @mac: Peer mac address
  2380. * @rx: rx function pointer
  2381. *
  2382. * return: QDF_STATUS_SUCCESS on success
  2383. * QDF_STATUS_E_INVAL if peer is not found
  2384. * QDF_STATUS_E_ALREADY if rx is already set/unset
  2385. */
  2386. QDF_STATUS dp_wds_ext_set_peer_rx(ol_txrx_soc_handle soc,
  2387. uint8_t vdev_id,
  2388. uint8_t *mac,
  2389. ol_txrx_rx_fp rx,
  2390. ol_osif_peer_handle osif_peer);
  2391. #endif /* QCA_SUPPORT_WDS_EXTENDED */
  2392. #ifdef DP_MEM_PRE_ALLOC
  2393. /**
  2394. * dp_context_alloc_mem() - allocate memory for DP context
  2395. * @soc: datapath soc handle
  2396. * @ctxt_type: DP context type
  2397. * @ctxt_size: DP context size
  2398. *
  2399. * Return: DP context address
  2400. */
  2401. void *dp_context_alloc_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
  2402. size_t ctxt_size);
  2403. /**
  2404. * dp_context_free_mem() - Free memory of DP context
  2405. * @soc: datapath soc handle
  2406. * @ctxt_type: DP context type
  2407. * @vaddr: Address of context memory
  2408. *
  2409. * Return: None
  2410. */
  2411. void dp_context_free_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
  2412. void *vaddr);
  2413. /**
  2414. * dp_desc_multi_pages_mem_alloc() - alloc memory over multiple pages
  2415. * @soc: datapath soc handle
  2416. * @desc_type: memory request source type
  2417. * @pages: multi page information storage
  2418. * @element_size: each element size
  2419. * @element_num: total number of elements should be allocated
  2420. * @memctxt: memory context
  2421. * @cacheable: coherent memory or cacheable memory
  2422. *
  2423. * This function is a wrapper for memory allocation over multiple
  2424. * pages, if dp prealloc method is registered, then will try prealloc
  2425. * firstly. if prealloc failed, fall back to regular way over
  2426. * qdf_mem_multi_pages_alloc().
  2427. *
  2428. * Return: None
  2429. */
  2430. void dp_desc_multi_pages_mem_alloc(struct dp_soc *soc,
  2431. enum dp_desc_type desc_type,
  2432. struct qdf_mem_multi_page_t *pages,
  2433. size_t element_size,
  2434. uint16_t element_num,
  2435. qdf_dma_context_t memctxt,
  2436. bool cacheable);
  2437. /**
  2438. * dp_desc_multi_pages_mem_free() - free multiple pages memory
  2439. * @soc: datapath soc handle
  2440. * @desc_type: memory request source type
  2441. * @pages: multi page information storage
  2442. * @memctxt: memory context
  2443. * @cacheable: coherent memory or cacheable memory
  2444. *
  2445. * This function is a wrapper for multiple pages memory free,
  2446. * if memory is got from prealloc pool, put it back to pool.
  2447. * otherwise free by qdf_mem_multi_pages_free().
  2448. *
  2449. * Return: None
  2450. */
  2451. void dp_desc_multi_pages_mem_free(struct dp_soc *soc,
  2452. enum dp_desc_type desc_type,
  2453. struct qdf_mem_multi_page_t *pages,
  2454. qdf_dma_context_t memctxt,
  2455. bool cacheable);
  2456. #else
  2457. static inline
  2458. void *dp_context_alloc_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
  2459. size_t ctxt_size)
  2460. {
  2461. return qdf_mem_malloc(ctxt_size);
  2462. }
  2463. static inline
  2464. void dp_context_free_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
  2465. void *vaddr)
  2466. {
  2467. qdf_mem_free(vaddr);
  2468. }
  2469. static inline
  2470. void dp_desc_multi_pages_mem_alloc(struct dp_soc *soc,
  2471. enum dp_desc_type desc_type,
  2472. struct qdf_mem_multi_page_t *pages,
  2473. size_t element_size,
  2474. uint16_t element_num,
  2475. qdf_dma_context_t memctxt,
  2476. bool cacheable)
  2477. {
  2478. qdf_mem_multi_pages_alloc(soc->osdev, pages, element_size,
  2479. element_num, memctxt, cacheable);
  2480. }
  2481. static inline
  2482. void dp_desc_multi_pages_mem_free(struct dp_soc *soc,
  2483. enum dp_desc_type desc_type,
  2484. struct qdf_mem_multi_page_t *pages,
  2485. qdf_dma_context_t memctxt,
  2486. bool cacheable)
  2487. {
  2488. qdf_mem_multi_pages_free(soc->osdev, pages,
  2489. memctxt, cacheable);
  2490. }
  2491. #endif
  2492. #ifdef FEATURE_RUNTIME_PM
  2493. /**
  2494. * dp_runtime_get() - Get dp runtime refcount
  2495. * @soc: Datapath soc handle
  2496. *
  2497. * Get dp runtime refcount by increment of an atomic variable, which can block
  2498. * dp runtime resume to wait to flush pending tx by runtime suspend.
  2499. *
  2500. * Return: Current refcount
  2501. */
  2502. static inline int32_t dp_runtime_get(struct dp_soc *soc)
  2503. {
  2504. return qdf_atomic_inc_return(&soc->dp_runtime_refcount);
  2505. }
  2506. /**
  2507. * dp_runtime_put() - Return dp runtime refcount
  2508. * @soc: Datapath soc handle
  2509. *
  2510. * Return dp runtime refcount by decrement of an atomic variable, allow dp
  2511. * runtime resume finish.
  2512. *
  2513. * Return: Current refcount
  2514. */
  2515. static inline int32_t dp_runtime_put(struct dp_soc *soc)
  2516. {
  2517. return qdf_atomic_dec_return(&soc->dp_runtime_refcount);
  2518. }
  2519. /**
  2520. * dp_runtime_get_refcount() - Get dp runtime refcount
  2521. * @soc: Datapath soc handle
  2522. *
  2523. * Get dp runtime refcount by returning an atomic variable
  2524. *
  2525. * Return: Current refcount
  2526. */
  2527. static inline int32_t dp_runtime_get_refcount(struct dp_soc *soc)
  2528. {
  2529. return qdf_atomic_read(&soc->dp_runtime_refcount);
  2530. }
  2531. /**
  2532. * dp_runtime_init() - Init dp runtime refcount when dp soc init
  2533. * @soc: Datapath soc handle
  2534. *
  2535. * Return: QDF_STATUS
  2536. */
  2537. static inline QDF_STATUS dp_runtime_init(struct dp_soc *soc)
  2538. {
  2539. return qdf_atomic_init(&soc->dp_runtime_refcount);
  2540. }
  2541. #else
  2542. static inline int32_t dp_runtime_get(struct dp_soc *soc)
  2543. {
  2544. return 0;
  2545. }
  2546. static inline int32_t dp_runtime_put(struct dp_soc *soc)
  2547. {
  2548. return 0;
  2549. }
  2550. static inline QDF_STATUS dp_runtime_init(struct dp_soc *soc)
  2551. {
  2552. return QDF_STATUS_SUCCESS;
  2553. }
  2554. #endif
  2555. static inline enum QDF_GLOBAL_MODE dp_soc_get_con_mode(struct dp_soc *soc)
  2556. {
  2557. if (soc->cdp_soc.ol_ops->get_con_mode)
  2558. return soc->cdp_soc.ol_ops->get_con_mode();
  2559. return QDF_GLOBAL_MAX_MODE;
  2560. }
  2561. /*
  2562. * dp_pdev_bkp_stats_detach() - detach resources for back pressure stats
  2563. * processing
  2564. * @pdev: Datapath PDEV handle
  2565. *
  2566. */
  2567. void dp_pdev_bkp_stats_detach(struct dp_pdev *pdev);
  2568. /*
  2569. * dp_pdev_bkp_stats_attach() - attach resources for back pressure stats
  2570. * processing
  2571. * @pdev: Datapath PDEV handle
  2572. *
  2573. * Return: QDF_STATUS_SUCCESS: Success
  2574. * QDF_STATUS_E_NOMEM: Error
  2575. */
  2576. QDF_STATUS dp_pdev_bkp_stats_attach(struct dp_pdev *pdev);
  2577. /**
  2578. * dp_peer_flush_frags() - Flush all fragments for a particular
  2579. * peer
  2580. * @soc_hdl - data path soc handle
  2581. * @vdev_id - vdev id
  2582. * @peer_addr - peer mac address
  2583. *
  2584. * Return: None
  2585. */
  2586. void dp_peer_flush_frags(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2587. uint8_t *peer_mac);
  2588. /**
  2589. * dp_soc_reset_mon_intr_mask() - reset mon intr mask
  2590. * @soc: pointer to dp_soc handle
  2591. *
  2592. * Return:
  2593. */
  2594. void dp_soc_reset_mon_intr_mask(struct dp_soc *soc);
  2595. /**
  2596. * dp_txrx_get_soc_stats() - will return cdp_soc_stats
  2597. * @soc_hdl: soc handle
  2598. * @soc_stats: buffer to hold the values
  2599. *
  2600. * Return: QDF_STATUS_SUCCESS: Success
  2601. * QDF_STATUS_E_FAILURE: Error
  2602. */
  2603. QDF_STATUS dp_txrx_get_soc_stats(struct cdp_soc_t *soc_hdl,
  2604. struct cdp_soc_stats *soc_stats);
  2605. /**
  2606. * dp_txrx_get_peer_delay_stats() - to get peer delay stats per TIDs
  2607. * @soc: soc handle
  2608. * @vdev_id: id of vdev handle
  2609. * @peer_mac: mac of DP_PEER handle
  2610. * @delay_stats: pointer to delay stats array
  2611. *
  2612. * Return: QDF_STATUS_SUCCESS: Success
  2613. * QDF_STATUS_E_FAILURE: Error
  2614. */
  2615. QDF_STATUS
  2616. dp_txrx_get_peer_delay_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2617. uint8_t *peer_mac,
  2618. struct cdp_delay_tid_stats *delay_stats);
  2619. /**
  2620. * dp_txrx_get_peer_jitter_stats() - to get peer jitter stats per TIDs
  2621. * @soc: soc handle
  2622. * @pdev_id: id of pdev handle
  2623. * @vdev_id: id of vdev handle
  2624. * @peer_mac: mac of DP_PEER handle
  2625. * @tid_stats: pointer to jitter stats array
  2626. *
  2627. * Return: QDF_STATUS_SUCCESS: Success
  2628. * QDF_STATUS_E_FAILURE: Error
  2629. */
  2630. QDF_STATUS
  2631. dp_txrx_get_peer_jitter_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  2632. uint8_t vdev_id, uint8_t *peer_mac,
  2633. struct cdp_peer_tid_stats *tid_stats);
  2634. /* dp_peer_get_tx_capture_stats - to get peer Tx Capture stats
  2635. * @soc_hdl: soc handle
  2636. * @vdev_id: id of vdev handle
  2637. * @peer_mac: mac of DP_PEER handle
  2638. * @stats: pointer to peer tx capture stats
  2639. *
  2640. * Return: QDF_STATUS_SUCCESS: Success
  2641. * QDF_STATUS_E_FAILURE: Error
  2642. */
  2643. QDF_STATUS
  2644. dp_peer_get_tx_capture_stats(struct cdp_soc_t *soc_hdl,
  2645. uint8_t vdev_id, uint8_t *peer_mac,
  2646. struct cdp_peer_tx_capture_stats *stats);
  2647. /* dp_pdev_get_tx_capture_stats - to get pdev Tx Capture stats
  2648. * @soc_hdl: soc handle
  2649. * @pdev_id: id of pdev handle
  2650. * @stats: pointer to pdev tx capture stats
  2651. *
  2652. * Return: QDF_STATUS_SUCCESS: Success
  2653. * QDF_STATUS_E_FAILURE: Error
  2654. */
  2655. QDF_STATUS
  2656. dp_pdev_get_tx_capture_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  2657. struct cdp_pdev_tx_capture_stats *stats);
  2658. #endif /* #ifndef _DP_INTERNAL_H_ */