dp_internal.h 77 KB

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