dp_internal.h 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _DP_INTERNAL_H_
  20. #define _DP_INTERNAL_H_
  21. #include "dp_types.h"
  22. #define RX_BUFFER_SIZE_PKTLOG_LITE 1024
  23. #define DP_PEER_WDS_COUNT_INVALID UINT_MAX
  24. /* Alignment for consistent memory for DP rings*/
  25. #define DP_RING_BASE_ALIGN 32
  26. #define DP_RSSI_INVAL 0x80
  27. #define DP_RSSI_AVG_WEIGHT 2
  28. /*
  29. * Formula to derive avg_rssi is taken from wifi2.o firmware
  30. */
  31. #define DP_GET_AVG_RSSI(avg_rssi, last_rssi) \
  32. (((avg_rssi) - (((uint8_t)(avg_rssi)) >> DP_RSSI_AVG_WEIGHT)) \
  33. + ((((uint8_t)(last_rssi)) >> DP_RSSI_AVG_WEIGHT)))
  34. /* Macro For NYSM value received in VHT TLV */
  35. #define VHT_SGI_NYSM 3
  36. /* struct htt_dbgfs_cfg - structure to maintain required htt data
  37. * @msg_word: htt msg sent to upper layer
  38. * @m: qdf debugfs file pointer
  39. */
  40. struct htt_dbgfs_cfg {
  41. uint32_t *msg_word;
  42. qdf_debugfs_file_t m;
  43. };
  44. /* Cookie MSB bits assigned for different use case.
  45. * Note: User can't use last 3 bits, as it is reserved for pdev_id.
  46. * If in future number of pdev are more than 3.
  47. */
  48. /* Reserve for default case */
  49. #define DBG_STATS_COOKIE_DEFAULT 0x0
  50. /* Reserve for DP Stats: 3rd bit */
  51. #define DBG_STATS_COOKIE_DP_STATS BIT(3)
  52. /* Reserve for HTT Stats debugfs support: 4th bit */
  53. #define DBG_STATS_COOKIE_HTT_DBGFS BIT(4)
  54. /*Reserve for HTT Stats debugfs support: 5th bit */
  55. #define DBG_SYSFS_STATS_COOKIE BIT(5)
  56. /**
  57. * Bitmap of HTT PPDU TLV types for Default mode
  58. */
  59. #define HTT_PPDU_DEFAULT_TLV_BITMAP \
  60. (1 << HTT_PPDU_STATS_COMMON_TLV) | \
  61. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  62. (1 << HTT_PPDU_STATS_USR_RATE_TLV) | \
  63. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV) | \
  64. (1 << HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV) | \
  65. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)
  66. /* PPDU STATS CFG */
  67. #define DP_PPDU_STATS_CFG_ALL 0xFFFF
  68. /* PPDU stats mask sent to FW to enable enhanced stats */
  69. #define DP_PPDU_STATS_CFG_ENH_STATS \
  70. (HTT_PPDU_DEFAULT_TLV_BITMAP) | \
  71. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) | \
  72. (1 << HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV) | \
  73. (1 << HTT_PPDU_STATS_USERS_INFO_TLV)
  74. /* PPDU stats mask sent to FW to support debug sniffer feature */
  75. #define DP_PPDU_STATS_CFG_SNIFFER \
  76. (HTT_PPDU_DEFAULT_TLV_BITMAP) | \
  77. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV) | \
  78. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV) | \
  79. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV) | \
  80. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV) | \
  81. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) | \
  82. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV) | \
  83. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) | \
  84. (1 << HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV) | \
  85. (1 << HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) | \
  86. (1 << HTT_PPDU_STATS_USERS_INFO_TLV)
  87. /* PPDU stats mask sent to FW to support BPR feature*/
  88. #define DP_PPDU_STATS_CFG_BPR \
  89. (1 << HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) | \
  90. (1 << HTT_PPDU_STATS_USERS_INFO_TLV)
  91. /* PPDU stats mask sent to FW to support BPR and enhanced stats feature */
  92. #define DP_PPDU_STATS_CFG_BPR_ENH (DP_PPDU_STATS_CFG_BPR | \
  93. DP_PPDU_STATS_CFG_ENH_STATS)
  94. /* PPDU stats mask sent to FW to support BPR and pcktlog stats feature */
  95. #define DP_PPDU_STATS_CFG_BPR_PKTLOG (DP_PPDU_STATS_CFG_BPR | \
  96. DP_PPDU_TXLITE_STATS_BITMASK_CFG)
  97. /**
  98. * Bitmap of HTT PPDU delayed ba TLV types for Default mode
  99. */
  100. #define HTT_PPDU_DELAYED_BA_TLV_BITMAP \
  101. (1 << HTT_PPDU_STATS_COMMON_TLV) | \
  102. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  103. (1 << HTT_PPDU_STATS_USR_RATE_TLV)
  104. /**
  105. * Bitmap of HTT PPDU TLV types for Delayed BA
  106. */
  107. #define HTT_PPDU_STATUS_TLV_BITMAP \
  108. (1 << HTT_PPDU_STATS_COMMON_TLV) | \
  109. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)
  110. /**
  111. * Bitmap of HTT PPDU TLV types for Sniffer mode bitmap 64
  112. */
  113. #define HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_64 \
  114. ((1 << HTT_PPDU_STATS_COMMON_TLV) | \
  115. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  116. (1 << HTT_PPDU_STATS_USR_RATE_TLV) | \
  117. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV) | \
  118. (1 << HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV) | \
  119. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) | \
  120. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV) | \
  121. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV))
  122. /**
  123. * Bitmap of HTT PPDU TLV types for Sniffer mode bitmap 256
  124. */
  125. #define HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_256 \
  126. ((1 << HTT_PPDU_STATS_COMMON_TLV) | \
  127. (1 << HTT_PPDU_STATS_USR_COMMON_TLV) | \
  128. (1 << HTT_PPDU_STATS_USR_RATE_TLV) | \
  129. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV) | \
  130. (1 << HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV) | \
  131. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) | \
  132. (1 << HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV) | \
  133. (1 << HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV))
  134. QDF_STATUS dp_mon_soc_attach(struct dp_soc *soc);
  135. QDF_STATUS dp_mon_soc_detach(struct dp_soc *soc);
  136. #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_MAC0_LMAC_ID 0
  844. #define DP_MAC1_LMAC_ID 1
  845. #ifdef FEATURE_TSO_STATS
  846. /**
  847. * dp_init_tso_stats() - Clear tso stats
  848. * @pdev: pdev handle
  849. *
  850. * Return: None
  851. */
  852. static inline
  853. void dp_init_tso_stats(struct dp_pdev *pdev)
  854. {
  855. if (pdev) {
  856. qdf_mem_zero(&((pdev)->stats.tso_stats),
  857. sizeof((pdev)->stats.tso_stats));
  858. qdf_atomic_init(&pdev->tso_idx);
  859. }
  860. }
  861. /**
  862. * dp_stats_tso_segment_histogram_update() - TSO Segment Histogram
  863. * @pdev: pdev handle
  864. * @_p_cntrs: number of tso segments for a tso packet
  865. *
  866. * Return: None
  867. */
  868. void dp_stats_tso_segment_histogram_update(struct dp_pdev *pdev,
  869. uint8_t _p_cntrs);
  870. /**
  871. * dp_tso_segment_update() - Collect tso segment information
  872. * @pdev: pdev handle
  873. * @stats_idx: tso packet number
  874. * @idx: tso segment number
  875. * @seg: tso segment
  876. *
  877. * Return: None
  878. */
  879. void dp_tso_segment_update(struct dp_pdev *pdev,
  880. uint32_t stats_idx,
  881. uint8_t idx,
  882. struct qdf_tso_seg_t seg);
  883. /**
  884. * dp_tso_packet_update() - TSO Packet information
  885. * @pdev: pdev handle
  886. * @stats_idx: tso packet number
  887. * @msdu: nbuf handle
  888. * @num_segs: tso segments
  889. *
  890. * Return: None
  891. */
  892. void dp_tso_packet_update(struct dp_pdev *pdev, uint32_t stats_idx,
  893. qdf_nbuf_t msdu, uint16_t num_segs);
  894. /**
  895. * dp_tso_segment_stats_update() - TSO Segment stats
  896. * @pdev: pdev handle
  897. * @stats_seg: tso segment list
  898. * @stats_idx: tso packet number
  899. *
  900. * Return: None
  901. */
  902. void dp_tso_segment_stats_update(struct dp_pdev *pdev,
  903. struct qdf_tso_seg_elem_t *stats_seg,
  904. uint32_t stats_idx);
  905. /**
  906. * dp_print_tso_stats() - dump tso statistics
  907. * @soc:soc handle
  908. * @level: verbosity level
  909. *
  910. * Return: None
  911. */
  912. void dp_print_tso_stats(struct dp_soc *soc,
  913. enum qdf_stats_verbosity_level level);
  914. /**
  915. * dp_txrx_clear_tso_stats() - clear tso stats
  916. * @soc: soc handle
  917. *
  918. * Return: None
  919. */
  920. void dp_txrx_clear_tso_stats(struct dp_soc *soc);
  921. #else
  922. static inline
  923. void dp_init_tso_stats(struct dp_pdev *pdev)
  924. {
  925. }
  926. static inline
  927. void dp_stats_tso_segment_histogram_update(struct dp_pdev *pdev,
  928. uint8_t _p_cntrs)
  929. {
  930. }
  931. static inline
  932. void dp_tso_segment_update(struct dp_pdev *pdev,
  933. uint32_t stats_idx,
  934. uint32_t idx,
  935. struct qdf_tso_seg_t seg)
  936. {
  937. }
  938. static inline
  939. void dp_tso_packet_update(struct dp_pdev *pdev, uint32_t stats_idx,
  940. qdf_nbuf_t msdu, uint16_t num_segs)
  941. {
  942. }
  943. static inline
  944. void dp_tso_segment_stats_update(struct dp_pdev *pdev,
  945. struct qdf_tso_seg_elem_t *stats_seg,
  946. uint32_t stats_idx)
  947. {
  948. }
  949. static inline
  950. void dp_print_tso_stats(struct dp_soc *soc,
  951. enum qdf_stats_verbosity_level level)
  952. {
  953. }
  954. static inline
  955. void dp_txrx_clear_tso_stats(struct dp_soc *soc)
  956. {
  957. }
  958. #endif /* FEATURE_TSO_STATS */
  959. #define DP_HTT_T2H_HP_PIPE 5
  960. /**
  961. * dp_update_pdev_stats(): Update the pdev stats
  962. * @tgtobj: pdev handle
  963. * @srcobj: vdev stats structure
  964. *
  965. * Update the pdev stats from the specified vdev stats
  966. *
  967. * return: None
  968. */
  969. void dp_update_pdev_stats(struct dp_pdev *tgtobj,
  970. struct cdp_vdev_stats *srcobj);
  971. /**
  972. * dp_update_vdev_ingress_stats(): Update the vdev ingress stats
  973. * @tgtobj: vdev handle
  974. *
  975. * Update the vdev ingress stats
  976. *
  977. * return: None
  978. */
  979. void dp_update_vdev_ingress_stats(struct dp_vdev *tgtobj);
  980. /**
  981. * dp_update_pdev_ingress_stats(): Update the pdev ingress stats
  982. * @tgtobj: pdev handle
  983. * @srcobj: vdev stats structure
  984. *
  985. * Update the pdev ingress stats from the specified vdev stats
  986. *
  987. * return: None
  988. */
  989. void dp_update_pdev_ingress_stats(struct dp_pdev *tgtobj,
  990. struct dp_vdev *srcobj);
  991. /**
  992. * dp_update_vdev_stats(): Update the vdev stats
  993. * @soc: soc handle
  994. * @srcobj: DP_PEER object
  995. * @arg: point to vdev stats structure
  996. *
  997. * Update the vdev stats from the specified peer stats
  998. *
  999. * return: None
  1000. */
  1001. void dp_update_vdev_stats(struct dp_soc *soc,
  1002. struct dp_peer *srcobj,
  1003. void *arg);
  1004. #define DP_UPDATE_STATS(_tgtobj, _srcobj) \
  1005. do { \
  1006. uint8_t i; \
  1007. uint8_t pream_type; \
  1008. for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) { \
  1009. for (i = 0; i < MAX_MCS; i++) { \
  1010. DP_STATS_AGGR(_tgtobj, _srcobj, \
  1011. tx.pkt_type[pream_type].mcs_count[i]); \
  1012. DP_STATS_AGGR(_tgtobj, _srcobj, \
  1013. rx.pkt_type[pream_type].mcs_count[i]); \
  1014. } \
  1015. } \
  1016. \
  1017. for (i = 0; i < MAX_BW; i++) { \
  1018. DP_STATS_AGGR(_tgtobj, _srcobj, tx.bw[i]); \
  1019. DP_STATS_AGGR(_tgtobj, _srcobj, rx.bw[i]); \
  1020. } \
  1021. \
  1022. for (i = 0; i < SS_COUNT; i++) { \
  1023. DP_STATS_AGGR(_tgtobj, _srcobj, rx.nss[i]); \
  1024. DP_STATS_AGGR(_tgtobj, _srcobj, tx.nss[i]); \
  1025. } \
  1026. for (i = 0; i < WME_AC_MAX; i++) { \
  1027. DP_STATS_AGGR(_tgtobj, _srcobj, tx.wme_ac_type[i]); \
  1028. DP_STATS_AGGR(_tgtobj, _srcobj, rx.wme_ac_type[i]); \
  1029. DP_STATS_AGGR(_tgtobj, _srcobj, tx.excess_retries_per_ac[i]); \
  1030. \
  1031. } \
  1032. \
  1033. for (i = 0; i < MAX_GI; i++) { \
  1034. DP_STATS_AGGR(_tgtobj, _srcobj, tx.sgi_count[i]); \
  1035. DP_STATS_AGGR(_tgtobj, _srcobj, rx.sgi_count[i]); \
  1036. } \
  1037. \
  1038. for (i = 0; i < MAX_RECEPTION_TYPES; i++) \
  1039. DP_STATS_AGGR(_tgtobj, _srcobj, rx.reception_type[i]); \
  1040. \
  1041. if (!wlan_cfg_get_vdev_stats_hw_offload_config(soc->wlan_cfg_ctx)) { \
  1042. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.comp_pkt); \
  1043. DP_STATS_AGGR(_tgtobj, _srcobj, tx.tx_failed); \
  1044. } \
  1045. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.ucast); \
  1046. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.mcast); \
  1047. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.bcast); \
  1048. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.tx_success); \
  1049. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.nawds_mcast); \
  1050. DP_STATS_AGGR(_tgtobj, _srcobj, tx.nawds_mcast_drop); \
  1051. DP_STATS_AGGR(_tgtobj, _srcobj, tx.ofdma); \
  1052. DP_STATS_AGGR(_tgtobj, _srcobj, tx.stbc); \
  1053. DP_STATS_AGGR(_tgtobj, _srcobj, tx.ldpc); \
  1054. DP_STATS_AGGR(_tgtobj, _srcobj, tx.retries); \
  1055. DP_STATS_AGGR(_tgtobj, _srcobj, tx.non_amsdu_cnt); \
  1056. DP_STATS_AGGR(_tgtobj, _srcobj, tx.amsdu_cnt); \
  1057. DP_STATS_AGGR(_tgtobj, _srcobj, tx.non_ampdu_cnt); \
  1058. DP_STATS_AGGR(_tgtobj, _srcobj, tx.ampdu_cnt); \
  1059. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.dropped.fw_rem); \
  1060. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_tx); \
  1061. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_notx); \
  1062. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason1); \
  1063. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason2); \
  1064. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason3); \
  1065. DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.age_out); \
  1066. \
  1067. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.mic_err); \
  1068. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.decrypt_err); \
  1069. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.fcserr); \
  1070. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.pn_err); \
  1071. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.oor_err); \
  1072. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.jump_2k_err); \
  1073. DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.rxdma_wifi_parse_err); \
  1074. if (_srcobj->stats.rx.snr != 0) \
  1075. DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.snr); \
  1076. DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.rx_rate); \
  1077. DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_ampdu_cnt); \
  1078. DP_STATS_AGGR(_tgtobj, _srcobj, rx.ampdu_cnt); \
  1079. DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_amsdu_cnt); \
  1080. DP_STATS_AGGR(_tgtobj, _srcobj, rx.amsdu_cnt); \
  1081. DP_STATS_AGGR(_tgtobj, _srcobj, rx.nawds_mcast_drop); \
  1082. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.to_stack); \
  1083. \
  1084. for (i = 0; i < CDP_MAX_RX_RINGS; i++) \
  1085. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.rcvd_reo[i]); \
  1086. \
  1087. _srcobj->stats.rx.unicast.num = \
  1088. _srcobj->stats.rx.to_stack.num - \
  1089. _srcobj->stats.rx.multicast.num; \
  1090. _srcobj->stats.rx.unicast.bytes = \
  1091. _srcobj->stats.rx.to_stack.bytes - \
  1092. _srcobj->stats.rx.multicast.bytes; \
  1093. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.unicast); \
  1094. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.multicast); \
  1095. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.bcast); \
  1096. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.raw); \
  1097. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.pkts); \
  1098. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.fail); \
  1099. DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.mec_drop); \
  1100. \
  1101. _tgtobj->stats.tx.last_ack_rssi = \
  1102. _srcobj->stats.tx.last_ack_rssi; \
  1103. DP_STATS_AGGR(_tgtobj, _srcobj, rx.multipass_rx_pkt_drop); \
  1104. DP_STATS_AGGR(_tgtobj, _srcobj, rx.peer_unauth_rx_pkt_drop); \
  1105. DP_STATS_AGGR(_tgtobj, _srcobj, rx.policy_check_drop); \
  1106. } while (0)
  1107. /**
  1108. * dp_peer_find_attach() - Allocates memory for peer objects
  1109. * @soc: SoC handle
  1110. *
  1111. * Return: QDF_STATUS
  1112. */
  1113. QDF_STATUS dp_peer_find_attach(struct dp_soc *soc);
  1114. extern void dp_peer_find_detach(struct dp_soc *soc);
  1115. extern void dp_peer_find_hash_add(struct dp_soc *soc, struct dp_peer *peer);
  1116. extern void dp_peer_find_hash_remove(struct dp_soc *soc, struct dp_peer *peer);
  1117. extern void dp_peer_find_hash_erase(struct dp_soc *soc);
  1118. void dp_peer_vdev_list_add(struct dp_soc *soc, struct dp_vdev *vdev,
  1119. struct dp_peer *peer);
  1120. void dp_peer_vdev_list_remove(struct dp_soc *soc, struct dp_vdev *vdev,
  1121. struct dp_peer *peer);
  1122. void dp_peer_find_id_to_obj_add(struct dp_soc *soc,
  1123. struct dp_peer *peer,
  1124. uint16_t peer_id);
  1125. void dp_txrx_peer_attach_add(struct dp_soc *soc,
  1126. struct dp_peer *peer,
  1127. struct dp_txrx_peer *txrx_peer);
  1128. void dp_peer_find_id_to_obj_remove(struct dp_soc *soc,
  1129. uint16_t peer_id);
  1130. void dp_vdev_unref_delete(struct dp_soc *soc, struct dp_vdev *vdev,
  1131. enum dp_mod_id mod_id);
  1132. /*
  1133. * dp_peer_ppdu_delayed_ba_cleanup() free ppdu allocated in peer
  1134. * @peer: Datapath peer
  1135. *
  1136. * return: void
  1137. */
  1138. void dp_peer_ppdu_delayed_ba_cleanup(struct dp_peer *peer);
  1139. extern void dp_peer_rx_init(struct dp_pdev *pdev, struct dp_peer *peer);
  1140. void dp_peer_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  1141. void dp_peer_rx_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
  1142. #ifdef DP_PEER_EXTENDED_API
  1143. /**
  1144. * dp_register_peer() - Register peer into physical device
  1145. * @soc_hdl - data path soc handle
  1146. * @pdev_id - device instance id
  1147. * @sta_desc - peer description
  1148. *
  1149. * Register peer into physical device
  1150. *
  1151. * Return: QDF_STATUS_SUCCESS registration success
  1152. * QDF_STATUS_E_FAULT peer not found
  1153. */
  1154. QDF_STATUS dp_register_peer(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  1155. struct ol_txrx_desc_type *sta_desc);
  1156. /**
  1157. * dp_clear_peer() - remove peer from physical device
  1158. * @soc_hdl - data path soc handle
  1159. * @pdev_id - device instance id
  1160. * @peer_addr - peer mac address
  1161. *
  1162. * remove peer from physical device
  1163. *
  1164. * Return: QDF_STATUS_SUCCESS registration success
  1165. * QDF_STATUS_E_FAULT peer not found
  1166. */
  1167. QDF_STATUS dp_clear_peer(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  1168. struct qdf_mac_addr peer_addr);
  1169. /*
  1170. * dp_find_peer_exist - find peer if already exists
  1171. * @soc: datapath soc handle
  1172. * @pdev_id: physical device instance id
  1173. * @peer_mac_addr: peer mac address
  1174. *
  1175. * Return: true or false
  1176. */
  1177. bool dp_find_peer_exist(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  1178. uint8_t *peer_addr);
  1179. /*
  1180. * dp_find_peer_exist_on_vdev - find if peer exists on the given vdev
  1181. * @soc: datapath soc handle
  1182. * @vdev_id: vdev instance id
  1183. * @peer_mac_addr: peer mac address
  1184. *
  1185. * Return: true or false
  1186. */
  1187. bool dp_find_peer_exist_on_vdev(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  1188. uint8_t *peer_addr);
  1189. /*
  1190. * dp_find_peer_exist_on_other_vdev - find if peer exists
  1191. * on other than the given vdev
  1192. * @soc: datapath soc handle
  1193. * @vdev_id: vdev instance id
  1194. * @peer_mac_addr: peer mac address
  1195. * @max_bssid: max number of bssids
  1196. *
  1197. * Return: true or false
  1198. */
  1199. bool dp_find_peer_exist_on_other_vdev(struct cdp_soc_t *soc_hdl,
  1200. uint8_t vdev_id, uint8_t *peer_addr,
  1201. uint16_t max_bssid);
  1202. /**
  1203. * dp_peer_state_update() - update peer local state
  1204. * @pdev - data path device instance
  1205. * @peer_addr - peer mac address
  1206. * @state - new peer local state
  1207. *
  1208. * update peer local state
  1209. *
  1210. * Return: QDF_STATUS_SUCCESS registration success
  1211. */
  1212. QDF_STATUS dp_peer_state_update(struct cdp_soc_t *soc, uint8_t *peer_mac,
  1213. enum ol_txrx_peer_state state);
  1214. /**
  1215. * dp_get_vdevid() - Get virtual interface id which peer registered
  1216. * @soc - datapath soc handle
  1217. * @peer_mac - peer mac address
  1218. * @vdev_id - virtual interface id which peer registered
  1219. *
  1220. * Get virtual interface id which peer registered
  1221. *
  1222. * Return: QDF_STATUS_SUCCESS registration success
  1223. */
  1224. QDF_STATUS dp_get_vdevid(struct cdp_soc_t *soc_hdl, uint8_t *peer_mac,
  1225. uint8_t *vdev_id);
  1226. struct cdp_vdev *dp_get_vdev_by_peer_addr(struct cdp_pdev *pdev_handle,
  1227. struct qdf_mac_addr peer_addr);
  1228. struct cdp_vdev *dp_get_vdev_for_peer(void *peer);
  1229. uint8_t *dp_peer_get_peer_mac_addr(void *peer);
  1230. /**
  1231. * dp_get_peer_state() - Get local peer state
  1232. * @soc - datapath soc handle
  1233. * @vdev_id - vdev id
  1234. * @peer_mac - peer mac addr
  1235. *
  1236. * Get local peer state
  1237. *
  1238. * Return: peer status
  1239. */
  1240. int dp_get_peer_state(struct cdp_soc_t *soc, uint8_t vdev_id,
  1241. uint8_t *peer_mac);
  1242. void dp_local_peer_id_pool_init(struct dp_pdev *pdev);
  1243. void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer);
  1244. void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer);
  1245. #else
  1246. /**
  1247. * dp_get_vdevid() - Get virtual interface id which peer registered
  1248. * @soc - datapath soc handle
  1249. * @peer_mac - peer mac address
  1250. * @vdev_id - virtual interface id which peer registered
  1251. *
  1252. * Get virtual interface id which peer registered
  1253. *
  1254. * Return: QDF_STATUS_SUCCESS registration success
  1255. */
  1256. static inline
  1257. QDF_STATUS dp_get_vdevid(struct cdp_soc_t *soc_hdl, uint8_t *peer_mac,
  1258. uint8_t *vdev_id)
  1259. {
  1260. return QDF_STATUS_E_NOSUPPORT;
  1261. }
  1262. static inline void dp_local_peer_id_pool_init(struct dp_pdev *pdev)
  1263. {
  1264. }
  1265. static inline
  1266. void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer)
  1267. {
  1268. }
  1269. static inline
  1270. void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer)
  1271. {
  1272. }
  1273. #endif
  1274. int dp_addba_resp_tx_completion_wifi3(struct cdp_soc_t *cdp_soc,
  1275. uint8_t *peer_mac, uint16_t vdev_id,
  1276. uint8_t tid,
  1277. int status);
  1278. int dp_addba_requestprocess_wifi3(struct cdp_soc_t *cdp_soc,
  1279. uint8_t *peer_mac, uint16_t vdev_id,
  1280. uint8_t dialogtoken, uint16_t tid,
  1281. uint16_t batimeout,
  1282. uint16_t buffersize,
  1283. uint16_t startseqnum);
  1284. QDF_STATUS dp_addba_responsesetup_wifi3(struct cdp_soc_t *cdp_soc,
  1285. uint8_t *peer_mac, uint16_t vdev_id,
  1286. uint8_t tid, uint8_t *dialogtoken,
  1287. uint16_t *statuscode,
  1288. uint16_t *buffersize,
  1289. uint16_t *batimeout);
  1290. QDF_STATUS dp_set_addba_response(struct cdp_soc_t *cdp_soc,
  1291. uint8_t *peer_mac,
  1292. uint16_t vdev_id, uint8_t tid,
  1293. uint16_t statuscode);
  1294. int dp_delba_process_wifi3(struct cdp_soc_t *cdp_soc, uint8_t *peer_mac,
  1295. uint16_t vdev_id, int tid,
  1296. uint16_t reasoncode);
  1297. /*
  1298. * dp_delba_tx_completion_wifi3() - Handle delba tx completion
  1299. *
  1300. * @cdp_soc: soc handle
  1301. * @vdev_id: id of the vdev handle
  1302. * @peer_mac: peer mac address
  1303. * @tid: Tid number
  1304. * @status: Tx completion status
  1305. * Indicate status of delba Tx to DP for stats update and retry
  1306. * delba if tx failed.
  1307. *
  1308. */
  1309. int dp_delba_tx_completion_wifi3(struct cdp_soc_t *cdp_soc, uint8_t *peer_mac,
  1310. uint16_t vdev_id, uint8_t tid,
  1311. int status);
  1312. extern QDF_STATUS dp_rx_tid_setup_wifi3(struct dp_peer *peer, int tid,
  1313. uint32_t ba_window_size,
  1314. uint32_t start_seq);
  1315. extern QDF_STATUS dp_reo_send_cmd(struct dp_soc *soc,
  1316. enum hal_reo_cmd_type type, struct hal_reo_cmd_params *params,
  1317. void (*callback_fn), void *data);
  1318. extern void dp_reo_cmdlist_destroy(struct dp_soc *soc);
  1319. /**
  1320. * dp_reo_status_ring_handler - Handler for REO Status ring
  1321. * @int_ctx: pointer to DP interrupt context
  1322. * @soc: DP Soc handle
  1323. *
  1324. * Returns: Number of descriptors reaped
  1325. */
  1326. uint32_t dp_reo_status_ring_handler(struct dp_intr *int_ctx,
  1327. struct dp_soc *soc);
  1328. void dp_aggregate_vdev_stats(struct dp_vdev *vdev,
  1329. struct cdp_vdev_stats *vdev_stats);
  1330. void dp_rx_tid_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  1331. union hal_reo_status *reo_status);
  1332. void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  1333. union hal_reo_status *reo_status);
  1334. uint16_t dp_tx_me_send_convert_ucast(struct cdp_soc_t *soc, uint8_t vdev_id,
  1335. qdf_nbuf_t nbuf,
  1336. uint8_t newmac[][QDF_MAC_ADDR_SIZE],
  1337. uint8_t new_mac_cnt, uint8_t tid,
  1338. bool is_igmp, bool is_dms_pkt);
  1339. void dp_tx_me_alloc_descriptor(struct cdp_soc_t *soc, uint8_t pdev_id);
  1340. void dp_tx_me_free_descriptor(struct cdp_soc_t *soc, uint8_t pdev_id);
  1341. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  1342. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  1343. uint32_t config_param_1, uint32_t config_param_2,
  1344. uint32_t config_param_3, int cookie, int cookie_msb,
  1345. uint8_t mac_id);
  1346. void dp_htt_stats_print_tag(struct dp_pdev *pdev,
  1347. uint8_t tag_type, uint32_t *tag_buf);
  1348. void dp_htt_stats_copy_tag(struct dp_pdev *pdev, uint8_t tag_type, uint32_t *tag_buf);
  1349. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev, uint32_t tuple_mask,
  1350. uint8_t mac_id);
  1351. /**
  1352. * dp_rxtid_stats_cmd_cb - function pointer for peer
  1353. * rx tid stats cmd call_back
  1354. */
  1355. typedef void (*dp_rxtid_stats_cmd_cb)(struct dp_soc *soc, void *cb_ctxt,
  1356. union hal_reo_status *reo_status);
  1357. int dp_peer_rxtid_stats(struct dp_peer *peer,
  1358. dp_rxtid_stats_cmd_cb dp_stats_cmd_cb,
  1359. void *cb_ctxt);
  1360. QDF_STATUS
  1361. dp_set_pn_check_wifi3(struct cdp_soc_t *soc, uint8_t vdev_id,
  1362. uint8_t *peer_mac, enum cdp_sec_type sec_type,
  1363. uint32_t *rx_pn);
  1364. QDF_STATUS
  1365. dp_set_key_sec_type_wifi3(struct cdp_soc_t *soc, uint8_t vdev_id,
  1366. uint8_t *peer_mac, enum cdp_sec_type sec_type,
  1367. bool is_unicast);
  1368. void *dp_get_pdev_for_mac_id(struct dp_soc *soc, uint32_t mac_id);
  1369. QDF_STATUS
  1370. dp_set_michael_key(struct cdp_soc_t *soc, uint8_t vdev_id,
  1371. uint8_t *peer_mac,
  1372. bool is_unicast, uint32_t *key);
  1373. /**
  1374. * dp_check_pdev_exists() - Validate pdev before use
  1375. * @soc - dp soc handle
  1376. * @data - pdev handle
  1377. *
  1378. * Return: 0 - success/invalid - failure
  1379. */
  1380. bool dp_check_pdev_exists(struct dp_soc *soc, struct dp_pdev *data);
  1381. /**
  1382. * dp_update_delay_stats() - Update delay statistics in structure
  1383. * and fill min, max and avg delay
  1384. * @pdev: pdev handle
  1385. * @delay: delay in ms
  1386. * @tid: tid value
  1387. * @mode: type of tx delay mode
  1388. * @ring id: ring number
  1389. *
  1390. * Return: none
  1391. */
  1392. void dp_update_delay_stats(struct dp_pdev *pdev, uint32_t delay,
  1393. uint8_t tid, uint8_t mode, uint8_t ring_id);
  1394. /**
  1395. * dp_print_ring_stats(): Print tail and head pointer
  1396. * @pdev: DP_PDEV handle
  1397. *
  1398. * Return:void
  1399. */
  1400. void dp_print_ring_stats(struct dp_pdev *pdev);
  1401. /**
  1402. * dp_print_pdev_cfg_params() - Print the pdev cfg parameters
  1403. * @pdev_handle: DP pdev handle
  1404. *
  1405. * Return - void
  1406. */
  1407. void dp_print_pdev_cfg_params(struct dp_pdev *pdev);
  1408. /**
  1409. * dp_print_soc_cfg_params()- Dump soc wlan config parameters
  1410. * @soc_handle: Soc handle
  1411. *
  1412. * Return: void
  1413. */
  1414. void dp_print_soc_cfg_params(struct dp_soc *soc);
  1415. /**
  1416. * dp_srng_get_str_from_ring_type() - Return string name for a ring
  1417. * @ring_type: Ring
  1418. *
  1419. * Return: char const pointer
  1420. */
  1421. const
  1422. char *dp_srng_get_str_from_hal_ring_type(enum hal_ring_type ring_type);
  1423. /*
  1424. * dp_txrx_path_stats() - Function to display dump stats
  1425. * @soc - soc handle
  1426. *
  1427. * return: none
  1428. */
  1429. void dp_txrx_path_stats(struct dp_soc *soc);
  1430. /*
  1431. * dp_print_per_ring_stats(): Packet count per ring
  1432. * @soc - soc handle
  1433. *
  1434. * Return - None
  1435. */
  1436. void dp_print_per_ring_stats(struct dp_soc *soc);
  1437. /**
  1438. * dp_aggregate_pdev_stats(): Consolidate stats at PDEV level
  1439. * @pdev: DP PDEV handle
  1440. *
  1441. * return: void
  1442. */
  1443. void dp_aggregate_pdev_stats(struct dp_pdev *pdev);
  1444. /**
  1445. * dp_print_rx_rates(): Print Rx rate stats
  1446. * @vdev: DP_VDEV handle
  1447. *
  1448. * Return:void
  1449. */
  1450. void dp_print_rx_rates(struct dp_vdev *vdev);
  1451. /**
  1452. * dp_print_tx_rates(): Print tx rates
  1453. * @vdev: DP_VDEV handle
  1454. *
  1455. * Return:void
  1456. */
  1457. void dp_print_tx_rates(struct dp_vdev *vdev);
  1458. /**
  1459. * dp_print_peer_stats():print peer stats
  1460. * @peer: DP_PEER handle
  1461. *
  1462. * return void
  1463. */
  1464. void dp_print_peer_stats(struct dp_peer *peer);
  1465. /**
  1466. * dp_print_pdev_tx_stats(): Print Pdev level TX stats
  1467. * @pdev: DP_PDEV Handle
  1468. *
  1469. * Return:void
  1470. */
  1471. void
  1472. dp_print_pdev_tx_stats(struct dp_pdev *pdev);
  1473. /**
  1474. * dp_print_pdev_rx_stats(): Print Pdev level RX stats
  1475. * @pdev: DP_PDEV Handle
  1476. *
  1477. * Return: void
  1478. */
  1479. void
  1480. dp_print_pdev_rx_stats(struct dp_pdev *pdev);
  1481. /**
  1482. * dp_print_soc_tx_stats(): Print SOC level stats
  1483. * @soc DP_SOC Handle
  1484. *
  1485. * Return: void
  1486. */
  1487. void dp_print_soc_tx_stats(struct dp_soc *soc);
  1488. /**
  1489. * dp_print_soc_interrupt_stats() - Print interrupt stats for the soc
  1490. * @soc: dp_soc handle
  1491. *
  1492. * Return: None
  1493. */
  1494. void dp_print_soc_interrupt_stats(struct dp_soc *soc);
  1495. /**
  1496. * dp_print_soc_rx_stats: Print SOC level Rx stats
  1497. * @soc: DP_SOC Handle
  1498. *
  1499. * Return:void
  1500. */
  1501. void dp_print_soc_rx_stats(struct dp_soc *soc);
  1502. /**
  1503. * dp_get_mac_id_for_pdev() - Return mac corresponding to pdev for mac
  1504. *
  1505. * @mac_id: MAC id
  1506. * @pdev_id: pdev_id corresponding to pdev, 0 for MCL
  1507. *
  1508. * Single pdev using both MACs will operate on both MAC rings,
  1509. * which is the case for MCL.
  1510. * For WIN each PDEV will operate one ring, so index is zero.
  1511. *
  1512. */
  1513. static inline int dp_get_mac_id_for_pdev(uint32_t mac_id, uint32_t pdev_id)
  1514. {
  1515. if (mac_id && pdev_id) {
  1516. qdf_print("Both mac_id and pdev_id cannot be non zero");
  1517. QDF_BUG(0);
  1518. return 0;
  1519. }
  1520. return (mac_id + pdev_id);
  1521. }
  1522. /**
  1523. * dp_get_lmac_id_for_pdev_id() - Return lmac id corresponding to host pdev id
  1524. * @soc: soc pointer
  1525. * @mac_id: MAC id
  1526. * @pdev_id: pdev_id corresponding to pdev, 0 for MCL
  1527. *
  1528. * For MCL, Single pdev using both MACs will operate on both MAC rings.
  1529. *
  1530. * For WIN, each PDEV will operate one ring.
  1531. *
  1532. */
  1533. static inline int
  1534. dp_get_lmac_id_for_pdev_id
  1535. (struct dp_soc *soc, uint32_t mac_id, uint32_t pdev_id)
  1536. {
  1537. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx)) {
  1538. if (mac_id && pdev_id) {
  1539. qdf_print("Both mac_id and pdev_id cannot be non zero");
  1540. QDF_BUG(0);
  1541. return 0;
  1542. }
  1543. return (mac_id + pdev_id);
  1544. }
  1545. return soc->pdev_list[pdev_id]->lmac_id;
  1546. }
  1547. /**
  1548. * dp_get_pdev_for_lmac_id() - Return pdev pointer corresponding to lmac id
  1549. * @soc: soc pointer
  1550. * @lmac_id: LMAC id
  1551. *
  1552. * For MCL, Single pdev exists
  1553. *
  1554. * For WIN, each PDEV will operate one ring.
  1555. *
  1556. */
  1557. static inline struct dp_pdev *
  1558. dp_get_pdev_for_lmac_id(struct dp_soc *soc, uint32_t lmac_id)
  1559. {
  1560. uint8_t i = 0;
  1561. if (wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx)) {
  1562. i = wlan_cfg_get_pdev_idx(soc->wlan_cfg_ctx, lmac_id);
  1563. return ((i < MAX_PDEV_CNT) ? soc->pdev_list[i] : NULL);
  1564. }
  1565. /* Typically for MCL as there only 1 PDEV*/
  1566. return soc->pdev_list[0];
  1567. }
  1568. /**
  1569. * dp_calculate_target_pdev_id_from_host_pdev_id() - Return target pdev
  1570. * corresponding to host pdev id
  1571. * @soc: soc pointer
  1572. * @mac_for_pdev: pdev_id corresponding to host pdev for WIN, mac id for MCL
  1573. *
  1574. * returns target pdev_id for host pdev id. For WIN, this is derived through
  1575. * a two step process:
  1576. * 1. Get lmac_id corresponding to host pdev_id (lmac_id can change
  1577. * during mode switch)
  1578. * 2. Get target pdev_id (set up during WMI ready) from lmac_id
  1579. *
  1580. * For MCL, return the offset-1 translated mac_id
  1581. */
  1582. static inline int
  1583. dp_calculate_target_pdev_id_from_host_pdev_id
  1584. (struct dp_soc *soc, uint32_t mac_for_pdev)
  1585. {
  1586. struct dp_pdev *pdev;
  1587. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  1588. return DP_SW2HW_MACID(mac_for_pdev);
  1589. pdev = soc->pdev_list[mac_for_pdev];
  1590. /*non-MCL case, get original target_pdev mapping*/
  1591. return wlan_cfg_get_target_pdev_id(soc->wlan_cfg_ctx, pdev->lmac_id);
  1592. }
  1593. /**
  1594. * dp_get_target_pdev_id_for_host_pdev_id() - Return target pdev corresponding
  1595. * to host pdev id
  1596. * @soc: soc pointer
  1597. * @mac_for_pdev: pdev_id corresponding to host pdev for WIN, mac id for MCL
  1598. *
  1599. * returns target pdev_id for host pdev id.
  1600. * For WIN, return the value stored in pdev object.
  1601. * For MCL, return the offset-1 translated mac_id.
  1602. */
  1603. static inline int
  1604. dp_get_target_pdev_id_for_host_pdev_id
  1605. (struct dp_soc *soc, uint32_t mac_for_pdev)
  1606. {
  1607. struct dp_pdev *pdev;
  1608. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  1609. return DP_SW2HW_MACID(mac_for_pdev);
  1610. pdev = soc->pdev_list[mac_for_pdev];
  1611. return pdev->target_pdev_id;
  1612. }
  1613. /**
  1614. * dp_get_host_pdev_id_for_target_pdev_id() - Return host pdev corresponding
  1615. * to target pdev id
  1616. * @soc: soc pointer
  1617. * @pdev_id: pdev_id corresponding to target pdev
  1618. *
  1619. * returns host pdev_id for target pdev id. For WIN, this is derived through
  1620. * a two step process:
  1621. * 1. Get lmac_id corresponding to target pdev_id
  1622. * 2. Get host pdev_id (set up during WMI ready) from lmac_id
  1623. *
  1624. * For MCL, return the 0-offset pdev_id
  1625. */
  1626. static inline int
  1627. dp_get_host_pdev_id_for_target_pdev_id
  1628. (struct dp_soc *soc, uint32_t pdev_id)
  1629. {
  1630. struct dp_pdev *pdev;
  1631. int lmac_id;
  1632. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  1633. return DP_HW2SW_MACID(pdev_id);
  1634. /*non-MCL case, get original target_lmac mapping from target pdev*/
  1635. lmac_id = wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx,
  1636. DP_HW2SW_MACID(pdev_id));
  1637. /*Get host pdev from lmac*/
  1638. pdev = dp_get_pdev_for_lmac_id(soc, lmac_id);
  1639. return pdev ? pdev->pdev_id : INVALID_PDEV_ID;
  1640. }
  1641. /*
  1642. * dp_get_mac_id_for_mac() - Return mac corresponding WIN and MCL mac_ids
  1643. *
  1644. * @soc: handle to DP soc
  1645. * @mac_id: MAC id
  1646. *
  1647. * Single pdev using both MACs will operate on both MAC rings,
  1648. * which is the case for MCL.
  1649. * For WIN each PDEV will operate one ring, so index is zero.
  1650. *
  1651. */
  1652. static inline int dp_get_mac_id_for_mac(struct dp_soc *soc, uint32_t mac_id)
  1653. {
  1654. /*
  1655. * Single pdev using both MACs will operate on both MAC rings,
  1656. * which is the case for MCL.
  1657. */
  1658. if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  1659. return mac_id;
  1660. /* For WIN each PDEV will operate one ring, so index is zero. */
  1661. return 0;
  1662. }
  1663. /*
  1664. * dp_is_subtype_data() - check if the frame subtype is data
  1665. *
  1666. * @frame_ctrl: Frame control field
  1667. *
  1668. * check the frame control field and verify if the packet
  1669. * is a data packet.
  1670. *
  1671. * Return: true or false
  1672. */
  1673. static inline bool dp_is_subtype_data(uint16_t frame_ctrl)
  1674. {
  1675. if (((qdf_cpu_to_le16(frame_ctrl) & QDF_IEEE80211_FC0_TYPE_MASK) ==
  1676. QDF_IEEE80211_FC0_TYPE_DATA) &&
  1677. (((qdf_cpu_to_le16(frame_ctrl) & QDF_IEEE80211_FC0_SUBTYPE_MASK) ==
  1678. QDF_IEEE80211_FC0_SUBTYPE_DATA) ||
  1679. ((qdf_cpu_to_le16(frame_ctrl) & QDF_IEEE80211_FC0_SUBTYPE_MASK) ==
  1680. QDF_IEEE80211_FC0_SUBTYPE_QOS))) {
  1681. return true;
  1682. }
  1683. return false;
  1684. }
  1685. #ifdef WDI_EVENT_ENABLE
  1686. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  1687. uint32_t stats_type_upload_mask,
  1688. uint8_t mac_id);
  1689. int dp_wdi_event_unsub(struct cdp_soc_t *soc, uint8_t pdev_id,
  1690. wdi_event_subscribe *event_cb_sub_handle,
  1691. uint32_t event);
  1692. int dp_wdi_event_sub(struct cdp_soc_t *soc, uint8_t pdev_id,
  1693. wdi_event_subscribe *event_cb_sub_handle,
  1694. uint32_t event);
  1695. void dp_wdi_event_handler(enum WDI_EVENT event, struct dp_soc *soc,
  1696. void *data, u_int16_t peer_id,
  1697. int status, u_int8_t pdev_id);
  1698. int dp_wdi_event_attach(struct dp_pdev *txrx_pdev);
  1699. int dp_wdi_event_detach(struct dp_pdev *txrx_pdev);
  1700. static inline void
  1701. dp_hif_update_pipe_callback(struct dp_soc *dp_soc,
  1702. void *cb_context,
  1703. QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t),
  1704. uint8_t pipe_id)
  1705. {
  1706. struct hif_msg_callbacks hif_pipe_callbacks;
  1707. /* TODO: Temporary change to bypass HTC connection for this new
  1708. * HIF pipe, which will be used for packet log and other high-
  1709. * priority HTT messages. Proper HTC connection to be added
  1710. * later once required FW changes are available
  1711. */
  1712. hif_pipe_callbacks.rxCompletionHandler = callback;
  1713. hif_pipe_callbacks.Context = cb_context;
  1714. hif_update_pipe_callback(dp_soc->hif_handle,
  1715. DP_HTT_T2H_HP_PIPE, &hif_pipe_callbacks);
  1716. }
  1717. #else
  1718. static inline int dp_wdi_event_unsub(struct cdp_soc_t *soc, uint8_t pdev_id,
  1719. wdi_event_subscribe *event_cb_sub_handle,
  1720. uint32_t event)
  1721. {
  1722. return 0;
  1723. }
  1724. static inline int dp_wdi_event_sub(struct cdp_soc_t *soc, uint8_t pdev_id,
  1725. wdi_event_subscribe *event_cb_sub_handle,
  1726. uint32_t event)
  1727. {
  1728. return 0;
  1729. }
  1730. static inline
  1731. void dp_wdi_event_handler(enum WDI_EVENT event,
  1732. struct dp_soc *soc,
  1733. void *data, u_int16_t peer_id,
  1734. int status, u_int8_t pdev_id)
  1735. {
  1736. }
  1737. static inline int dp_wdi_event_attach(struct dp_pdev *txrx_pdev)
  1738. {
  1739. return 0;
  1740. }
  1741. static inline int dp_wdi_event_detach(struct dp_pdev *txrx_pdev)
  1742. {
  1743. return 0;
  1744. }
  1745. static inline QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  1746. uint32_t stats_type_upload_mask, uint8_t mac_id)
  1747. {
  1748. return 0;
  1749. }
  1750. static inline void
  1751. dp_hif_update_pipe_callback(struct dp_soc *dp_soc, void *cb_context,
  1752. QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t),
  1753. uint8_t pipe_id)
  1754. {
  1755. }
  1756. #endif /* CONFIG_WIN */
  1757. #ifdef VDEV_PEER_PROTOCOL_COUNT
  1758. /**
  1759. * dp_vdev_peer_stats_update_protocol_cnt() - update per-peer protocol counters
  1760. * @vdev: VDEV DP object
  1761. * @nbuf: data packet
  1762. * @peer: Peer DP object
  1763. * @is_egress: whether egress or ingress
  1764. * @is_rx: whether rx or tx
  1765. *
  1766. * This function updates the per-peer protocol counters
  1767. * Return: void
  1768. */
  1769. void dp_vdev_peer_stats_update_protocol_cnt(struct dp_vdev *vdev,
  1770. qdf_nbuf_t nbuf,
  1771. struct dp_peer *peer,
  1772. bool is_egress,
  1773. bool is_rx);
  1774. /**
  1775. * dp_vdev_peer_stats_update_protocol_cnt() - update per-peer protocol counters
  1776. * @soc: SOC DP object
  1777. * @vdev_id: vdev_id
  1778. * @nbuf: data packet
  1779. * @is_egress: whether egress or ingress
  1780. * @is_rx: whether rx or tx
  1781. *
  1782. * This function updates the per-peer protocol counters
  1783. * Return: void
  1784. */
  1785. void dp_peer_stats_update_protocol_cnt(struct cdp_soc_t *soc,
  1786. int8_t vdev_id,
  1787. qdf_nbuf_t nbuf,
  1788. bool is_egress,
  1789. bool is_rx);
  1790. void dp_vdev_peer_stats_update_protocol_cnt_tx(struct dp_vdev *vdev_hdl,
  1791. qdf_nbuf_t nbuf);
  1792. #else
  1793. #define dp_vdev_peer_stats_update_protocol_cnt(vdev, nbuf, peer, \
  1794. is_egress, is_rx)
  1795. static inline
  1796. void dp_vdev_peer_stats_update_protocol_cnt_tx(struct dp_vdev *vdev_hdl,
  1797. qdf_nbuf_t nbuf)
  1798. {
  1799. }
  1800. #endif
  1801. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  1802. void dp_tx_dump_flow_pool_info(struct cdp_soc_t *soc_hdl);
  1803. /**
  1804. * dp_tx_dump_flow_pool_info_compact() - dump flow pool info
  1805. * @soc: DP soc context
  1806. *
  1807. * Return: none
  1808. */
  1809. void dp_tx_dump_flow_pool_info_compact(struct dp_soc *soc);
  1810. int dp_tx_delete_flow_pool(struct dp_soc *soc, struct dp_tx_desc_pool_s *pool,
  1811. bool force);
  1812. #else
  1813. static inline void dp_tx_dump_flow_pool_info_compact(struct dp_soc *soc)
  1814. {
  1815. }
  1816. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
  1817. #ifdef QCA_OL_DP_SRNG_LOCK_LESS_ACCESS
  1818. static inline int
  1819. dp_hal_srng_access_start(hal_soc_handle_t soc, hal_ring_handle_t hal_ring_hdl)
  1820. {
  1821. return hal_srng_access_start_unlocked(soc, hal_ring_hdl);
  1822. }
  1823. static inline void
  1824. dp_hal_srng_access_end(hal_soc_handle_t soc, hal_ring_handle_t hal_ring_hdl)
  1825. {
  1826. hal_srng_access_end_unlocked(soc, hal_ring_hdl);
  1827. }
  1828. #else
  1829. static inline int
  1830. dp_hal_srng_access_start(hal_soc_handle_t soc, hal_ring_handle_t hal_ring_hdl)
  1831. {
  1832. return hal_srng_access_start(soc, hal_ring_hdl);
  1833. }
  1834. static inline void
  1835. dp_hal_srng_access_end(hal_soc_handle_t soc, hal_ring_handle_t hal_ring_hdl)
  1836. {
  1837. hal_srng_access_end(soc, hal_ring_hdl);
  1838. }
  1839. #endif
  1840. #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
  1841. /**
  1842. * dp_srng_access_start() - Wrapper function to log access start of a hal ring
  1843. * @int_ctx: pointer to DP interrupt context. This should not be NULL
  1844. * @soc: DP Soc handle
  1845. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  1846. *
  1847. * Return: 0 on success; error on failure
  1848. */
  1849. int dp_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *dp_soc,
  1850. hal_ring_handle_t hal_ring_hdl);
  1851. /**
  1852. * dp_srng_access_end() - Wrapper function to log access end of a hal ring
  1853. * @int_ctx: pointer to DP interrupt context. This should not be NULL
  1854. * @soc: DP Soc handle
  1855. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  1856. *
  1857. * Return: void
  1858. */
  1859. void dp_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *dp_soc,
  1860. hal_ring_handle_t hal_ring_hdl);
  1861. #else
  1862. static inline int dp_srng_access_start(struct dp_intr *int_ctx,
  1863. struct dp_soc *dp_soc,
  1864. hal_ring_handle_t hal_ring_hdl)
  1865. {
  1866. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1867. return dp_hal_srng_access_start(hal_soc, hal_ring_hdl);
  1868. }
  1869. static inline void dp_srng_access_end(struct dp_intr *int_ctx,
  1870. struct dp_soc *dp_soc,
  1871. hal_ring_handle_t hal_ring_hdl)
  1872. {
  1873. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1874. return dp_hal_srng_access_end(hal_soc, hal_ring_hdl);
  1875. }
  1876. #endif /* WLAN_FEATURE_DP_EVENT_HISTORY */
  1877. #ifdef QCA_CACHED_RING_DESC
  1878. /**
  1879. * dp_srng_dst_get_next() - Wrapper function to get next ring desc
  1880. * @dp_socsoc: DP Soc handle
  1881. * @hal_ring: opaque pointer to the HAL Destination Ring
  1882. *
  1883. * Return: HAL ring descriptor
  1884. */
  1885. static inline void *dp_srng_dst_get_next(struct dp_soc *dp_soc,
  1886. hal_ring_handle_t hal_ring_hdl)
  1887. {
  1888. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1889. return hal_srng_dst_get_next_cached(hal_soc, hal_ring_hdl);
  1890. }
  1891. /**
  1892. * dp_srng_dst_inv_cached_descs() - Wrapper function to invalidate cached
  1893. * descriptors
  1894. * @dp_socsoc: DP Soc handle
  1895. * @hal_ring: opaque pointer to the HAL Rx Destination ring
  1896. * @num_entries: Entry count
  1897. *
  1898. * Return: None
  1899. */
  1900. static inline void dp_srng_dst_inv_cached_descs(struct dp_soc *dp_soc,
  1901. hal_ring_handle_t hal_ring_hdl,
  1902. uint32_t num_entries)
  1903. {
  1904. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1905. hal_srng_dst_inv_cached_descs(hal_soc, hal_ring_hdl, num_entries);
  1906. }
  1907. #else
  1908. static inline void *dp_srng_dst_get_next(struct dp_soc *dp_soc,
  1909. hal_ring_handle_t hal_ring_hdl)
  1910. {
  1911. hal_soc_handle_t hal_soc = dp_soc->hal_soc;
  1912. return hal_srng_dst_get_next(hal_soc, hal_ring_hdl);
  1913. }
  1914. static inline void dp_srng_dst_inv_cached_descs(struct dp_soc *dp_soc,
  1915. hal_ring_handle_t hal_ring_hdl,
  1916. uint32_t num_entries)
  1917. {
  1918. }
  1919. #endif /* QCA_CACHED_RING_DESC */
  1920. #if defined(QCA_CACHED_RING_DESC) && \
  1921. (defined(QCA_DP_RX_HW_SW_NBUF_DESC_PREFETCH) || \
  1922. defined(QCA_DP_TX_HW_SW_NBUF_DESC_PREFETCH))
  1923. /**
  1924. * dp_srng_dst_prefetch() - Wrapper function to prefetch descs from dest ring
  1925. * @hal_soc_hdl: HAL SOC handle
  1926. * @hal_ring: opaque pointer to the HAL Rx Destination ring
  1927. * @num_entries: Entry count
  1928. *
  1929. * Return: None
  1930. */
  1931. static inline void *dp_srng_dst_prefetch(hal_soc_handle_t hal_soc,
  1932. hal_ring_handle_t hal_ring_hdl,
  1933. uint32_t num_entries)
  1934. {
  1935. return hal_srng_dst_prefetch(hal_soc, hal_ring_hdl, num_entries);
  1936. }
  1937. #else
  1938. static inline void *dp_srng_dst_prefetch(hal_soc_handle_t hal_soc,
  1939. hal_ring_handle_t hal_ring_hdl,
  1940. uint32_t num_entries)
  1941. {
  1942. return NULL;
  1943. }
  1944. #endif
  1945. #ifdef QCA_ENH_V3_STATS_SUPPORT
  1946. /**
  1947. * dp_pdev_print_delay_stats(): Print pdev level delay stats
  1948. * @pdev: DP_PDEV handle
  1949. *
  1950. * Return:void
  1951. */
  1952. void dp_pdev_print_delay_stats(struct dp_pdev *pdev);
  1953. /**
  1954. * dp_pdev_print_tid_stats(): Print pdev level tid stats
  1955. * @pdev: DP_PDEV handle
  1956. *
  1957. * Return:void
  1958. */
  1959. void dp_pdev_print_tid_stats(struct dp_pdev *pdev);
  1960. /**
  1961. * dp_pdev_print_rx_error_stats(): Print pdev level rx error stats
  1962. * @pdev: DP_PDEV handle
  1963. *
  1964. * Return:void
  1965. */
  1966. void dp_pdev_print_rx_error_stats(struct dp_pdev *pdev);
  1967. #endif /* CONFIG_WIN */
  1968. void dp_soc_set_txrx_ring_map(struct dp_soc *soc);
  1969. /**
  1970. * dp_vdev_to_cdp_vdev() - typecast dp vdev to cdp vdev
  1971. * @vdev: DP vdev handle
  1972. *
  1973. * Return: struct cdp_vdev pointer
  1974. */
  1975. static inline
  1976. struct cdp_vdev *dp_vdev_to_cdp_vdev(struct dp_vdev *vdev)
  1977. {
  1978. return (struct cdp_vdev *)vdev;
  1979. }
  1980. /**
  1981. * dp_pdev_to_cdp_pdev() - typecast dp pdev to cdp pdev
  1982. * @pdev: DP pdev handle
  1983. *
  1984. * Return: struct cdp_pdev pointer
  1985. */
  1986. static inline
  1987. struct cdp_pdev *dp_pdev_to_cdp_pdev(struct dp_pdev *pdev)
  1988. {
  1989. return (struct cdp_pdev *)pdev;
  1990. }
  1991. /**
  1992. * dp_soc_to_cdp_soc() - typecast dp psoc to cdp psoc
  1993. * @psoc: DP psoc handle
  1994. *
  1995. * Return: struct cdp_soc pointer
  1996. */
  1997. static inline
  1998. struct cdp_soc *dp_soc_to_cdp_soc(struct dp_soc *psoc)
  1999. {
  2000. return (struct cdp_soc *)psoc;
  2001. }
  2002. /**
  2003. * dp_soc_to_cdp_soc_t() - typecast dp psoc to
  2004. * ol txrx soc handle
  2005. * @psoc: DP psoc handle
  2006. *
  2007. * Return: struct cdp_soc_t pointer
  2008. */
  2009. static inline
  2010. struct cdp_soc_t *dp_soc_to_cdp_soc_t(struct dp_soc *psoc)
  2011. {
  2012. return (struct cdp_soc_t *)psoc;
  2013. }
  2014. #if defined(WLAN_SUPPORT_RX_FLOW_TAG) || defined(WLAN_SUPPORT_RX_FISA)
  2015. /**
  2016. * dp_rx_flow_update_fse_stats() - Update a flow's statistics
  2017. * @pdev: pdev handle
  2018. * @flow_id: flow index (truncated hash) in the Rx FST
  2019. *
  2020. * Return: Success when flow statistcs is updated, error on failure
  2021. */
  2022. QDF_STATUS dp_rx_flow_get_fse_stats(struct dp_pdev *pdev,
  2023. struct cdp_rx_flow_info *rx_flow_info,
  2024. struct cdp_flow_stats *stats);
  2025. /**
  2026. * dp_rx_flow_delete_entry() - Delete a flow entry from flow search table
  2027. * @pdev: pdev handle
  2028. * @rx_flow_info: DP flow parameters
  2029. *
  2030. * Return: Success when flow is deleted, error on failure
  2031. */
  2032. QDF_STATUS dp_rx_flow_delete_entry(struct dp_pdev *pdev,
  2033. struct cdp_rx_flow_info *rx_flow_info);
  2034. /**
  2035. * dp_rx_flow_add_entry() - Add a flow entry to flow search table
  2036. * @pdev: DP pdev instance
  2037. * @rx_flow_info: DP flow paramaters
  2038. *
  2039. * Return: Success when flow is added, no-memory or already exists on error
  2040. */
  2041. QDF_STATUS dp_rx_flow_add_entry(struct dp_pdev *pdev,
  2042. struct cdp_rx_flow_info *rx_flow_info);
  2043. /**
  2044. * dp_rx_fst_attach() - Initialize Rx FST and setup necessary parameters
  2045. * @soc: SoC handle
  2046. * @pdev: Pdev handle
  2047. *
  2048. * Return: Handle to flow search table entry
  2049. */
  2050. QDF_STATUS dp_rx_fst_attach(struct dp_soc *soc, struct dp_pdev *pdev);
  2051. /**
  2052. * dp_rx_fst_detach() - De-initialize Rx FST
  2053. * @soc: SoC handle
  2054. * @pdev: Pdev handle
  2055. *
  2056. * Return: None
  2057. */
  2058. void dp_rx_fst_detach(struct dp_soc *soc, struct dp_pdev *pdev);
  2059. /**
  2060. * dp_rx_flow_send_fst_fw_setup() - Program FST parameters in FW/HW post-attach
  2061. * @soc: SoC handle
  2062. * @pdev: Pdev handle
  2063. *
  2064. * Return: Success when fst parameters are programmed in FW, error otherwise
  2065. */
  2066. QDF_STATUS dp_rx_flow_send_fst_fw_setup(struct dp_soc *soc,
  2067. struct dp_pdev *pdev);
  2068. #else /* !((WLAN_SUPPORT_RX_FLOW_TAG) || defined(WLAN_SUPPORT_RX_FISA)) */
  2069. /**
  2070. * dp_rx_fst_attach() - Initialize Rx FST and setup necessary parameters
  2071. * @soc: SoC handle
  2072. * @pdev: Pdev handle
  2073. *
  2074. * Return: Handle to flow search table entry
  2075. */
  2076. static inline
  2077. QDF_STATUS dp_rx_fst_attach(struct dp_soc *soc, struct dp_pdev *pdev)
  2078. {
  2079. return QDF_STATUS_SUCCESS;
  2080. }
  2081. /**
  2082. * dp_rx_fst_detach() - De-initialize Rx FST
  2083. * @soc: SoC handle
  2084. * @pdev: Pdev handle
  2085. *
  2086. * Return: None
  2087. */
  2088. static inline
  2089. void dp_rx_fst_detach(struct dp_soc *soc, struct dp_pdev *pdev)
  2090. {
  2091. }
  2092. #endif
  2093. /**
  2094. * dp_vdev_get_ref() - API to take a reference for VDEV object
  2095. *
  2096. * @soc : core DP soc context
  2097. * @vdev : DP vdev
  2098. * @mod_id : module id
  2099. *
  2100. * Return: QDF_STATUS_SUCCESS if reference held successfully
  2101. * else QDF_STATUS_E_INVAL
  2102. */
  2103. static inline
  2104. QDF_STATUS dp_vdev_get_ref(struct dp_soc *soc, struct dp_vdev *vdev,
  2105. enum dp_mod_id mod_id)
  2106. {
  2107. if (!qdf_atomic_inc_not_zero(&vdev->ref_cnt))
  2108. return QDF_STATUS_E_INVAL;
  2109. qdf_atomic_inc(&vdev->mod_refs[mod_id]);
  2110. return QDF_STATUS_SUCCESS;
  2111. }
  2112. /**
  2113. * dp_vdev_get_ref_by_id() - Returns vdev object given the vdev id
  2114. * @soc: core DP soc context
  2115. * @vdev_id: vdev id from vdev object can be retrieved
  2116. * @mod_id: module id which is requesting the reference
  2117. *
  2118. * Return: struct dp_vdev*: Pointer to DP vdev object
  2119. */
  2120. static inline struct dp_vdev *
  2121. dp_vdev_get_ref_by_id(struct dp_soc *soc, uint8_t vdev_id,
  2122. enum dp_mod_id mod_id)
  2123. {
  2124. struct dp_vdev *vdev = NULL;
  2125. if (qdf_unlikely(vdev_id >= MAX_VDEV_CNT))
  2126. return NULL;
  2127. qdf_spin_lock_bh(&soc->vdev_map_lock);
  2128. vdev = soc->vdev_id_map[vdev_id];
  2129. if (!vdev || dp_vdev_get_ref(soc, vdev, mod_id) != QDF_STATUS_SUCCESS) {
  2130. qdf_spin_unlock_bh(&soc->vdev_map_lock);
  2131. return NULL;
  2132. }
  2133. qdf_spin_unlock_bh(&soc->vdev_map_lock);
  2134. return vdev;
  2135. }
  2136. /**
  2137. * dp_get_pdev_from_soc_pdev_id_wifi3() - Returns pdev object given the pdev id
  2138. * @soc: core DP soc context
  2139. * @pdev_id: pdev id from pdev object can be retrieved
  2140. *
  2141. * Return: struct dp_pdev*: Pointer to DP pdev object
  2142. */
  2143. static inline struct dp_pdev *
  2144. dp_get_pdev_from_soc_pdev_id_wifi3(struct dp_soc *soc,
  2145. uint8_t pdev_id)
  2146. {
  2147. if (qdf_unlikely(pdev_id >= MAX_PDEV_CNT))
  2148. return NULL;
  2149. return soc->pdev_list[pdev_id];
  2150. }
  2151. /*
  2152. * dp_rx_tid_update_wifi3() – Update receive TID state
  2153. * @peer: Datapath peer handle
  2154. * @tid: TID
  2155. * @ba_window_size: BlockAck window size
  2156. * @start_seq: Starting sequence number
  2157. * @bar_update: BAR update triggered
  2158. *
  2159. * Return: QDF_STATUS code
  2160. */
  2161. QDF_STATUS dp_rx_tid_update_wifi3(struct dp_peer *peer, int tid, uint32_t
  2162. ba_window_size, uint32_t start_seq,
  2163. bool bar_update);
  2164. /**
  2165. * dp_get_peer_mac_list(): function to get peer mac list of vdev
  2166. * @soc: Datapath soc handle
  2167. * @vdev_id: vdev id
  2168. * @newmac: Table of the clients mac
  2169. * @mac_cnt: No. of MACs required
  2170. * @limit: Limit the number of clients
  2171. *
  2172. * return: no of clients
  2173. */
  2174. uint16_t dp_get_peer_mac_list(ol_txrx_soc_handle soc, uint8_t vdev_id,
  2175. u_int8_t newmac[][QDF_MAC_ADDR_SIZE],
  2176. u_int16_t mac_cnt, bool limit);
  2177. /*
  2178. * dp_is_hw_dbs_enable() - Procedure to check if DBS is supported
  2179. * @soc: DP SoC context
  2180. * @max_mac_rings: No of MAC rings
  2181. *
  2182. * Return: None
  2183. */
  2184. void dp_is_hw_dbs_enable(struct dp_soc *soc,
  2185. int *max_mac_rings);
  2186. #if defined(WLAN_SUPPORT_RX_FISA)
  2187. void dp_rx_dump_fisa_table(struct dp_soc *soc);
  2188. /*
  2189. * dp_rx_fst_update_cmem_params() - Update CMEM FST params
  2190. * @soc: DP SoC context
  2191. * @num_entries: Number of flow search entries
  2192. * @cmem_ba_lo: CMEM base address low
  2193. * @cmem_ba_hi: CMEM base address high
  2194. *
  2195. * Return: None
  2196. */
  2197. void dp_rx_fst_update_cmem_params(struct dp_soc *soc, uint16_t num_entries,
  2198. uint32_t cmem_ba_lo, uint32_t cmem_ba_hi);
  2199. void
  2200. dp_rx_fst_update_pm_suspend_status(struct dp_soc *soc, bool suspended);
  2201. #else
  2202. static inline void
  2203. dp_rx_fst_update_cmem_params(struct dp_soc *soc, uint16_t num_entries,
  2204. uint32_t cmem_ba_lo, uint32_t cmem_ba_hi)
  2205. {
  2206. }
  2207. static inline void
  2208. dp_rx_fst_update_pm_suspend_status(struct dp_soc *soc, bool suspended)
  2209. {
  2210. }
  2211. #endif /* WLAN_SUPPORT_RX_FISA */
  2212. #ifdef MAX_ALLOC_PAGE_SIZE
  2213. /**
  2214. * dp_set_page_size() - Set the max page size for hw link desc.
  2215. * For MCL the page size is set to OS defined value and for WIN
  2216. * the page size is set to the max_alloc_size cfg ini
  2217. * param.
  2218. * This is to ensure that WIN gets contiguous memory allocations
  2219. * as per requirement.
  2220. * @pages: link desc page handle
  2221. * @max_alloc_size: max_alloc_size
  2222. *
  2223. * Return: None
  2224. */
  2225. static inline
  2226. void dp_set_max_page_size(struct qdf_mem_multi_page_t *pages,
  2227. uint32_t max_alloc_size)
  2228. {
  2229. pages->page_size = qdf_page_size;
  2230. }
  2231. #else
  2232. static inline
  2233. void dp_set_max_page_size(struct qdf_mem_multi_page_t *pages,
  2234. uint32_t max_alloc_size)
  2235. {
  2236. pages->page_size = max_alloc_size;
  2237. }
  2238. #endif /* MAX_ALLOC_PAGE_SIZE */
  2239. /**
  2240. * dp_history_get_next_index() - get the next entry to record an entry
  2241. * in the history.
  2242. * @curr_idx: Current index where the last entry is written.
  2243. * @max_entries: Max number of entries in the history
  2244. *
  2245. * This function assumes that the max number os entries is a power of 2.
  2246. *
  2247. * Returns: The index where the next entry is to be written.
  2248. */
  2249. static inline uint32_t dp_history_get_next_index(qdf_atomic_t *curr_idx,
  2250. uint32_t max_entries)
  2251. {
  2252. uint32_t idx = qdf_atomic_inc_return(curr_idx);
  2253. return idx & (max_entries - 1);
  2254. }
  2255. /**
  2256. * dp_rx_skip_tlvs() - Skip TLVs len + L2 hdr_offset, save in nbuf->cb
  2257. * @nbuf: nbuf cb to be updated
  2258. * @l2_hdr_offset: l2_hdr_offset
  2259. *
  2260. * Return: None
  2261. */
  2262. void dp_rx_skip_tlvs(struct dp_soc *soc, qdf_nbuf_t nbuf, uint32_t l3_padding);
  2263. #ifndef FEATURE_WDS
  2264. static inline void
  2265. dp_hmwds_ast_add_notify(struct dp_peer *peer,
  2266. uint8_t *mac_addr,
  2267. enum cdp_txrx_ast_entry_type type,
  2268. QDF_STATUS err,
  2269. bool is_peer_map)
  2270. {
  2271. }
  2272. #endif
  2273. #ifdef HTT_STATS_DEBUGFS_SUPPORT
  2274. /* dp_pdev_htt_stats_dbgfs_init() - Function to allocate memory and initialize
  2275. * debugfs for HTT stats
  2276. * @pdev: dp pdev handle
  2277. *
  2278. * Return: QDF_STATUS
  2279. */
  2280. QDF_STATUS dp_pdev_htt_stats_dbgfs_init(struct dp_pdev *pdev);
  2281. /* dp_pdev_htt_stats_dbgfs_deinit() - Function to remove debugfs entry for
  2282. * HTT stats
  2283. * @pdev: dp pdev handle
  2284. *
  2285. * Return: none
  2286. */
  2287. void dp_pdev_htt_stats_dbgfs_deinit(struct dp_pdev *pdev);
  2288. #else
  2289. /* dp_pdev_htt_stats_dbgfs_init() - Function to allocate memory and initialize
  2290. * debugfs for HTT stats
  2291. * @pdev: dp pdev handle
  2292. *
  2293. * Return: QDF_STATUS
  2294. */
  2295. static inline QDF_STATUS
  2296. dp_pdev_htt_stats_dbgfs_init(struct dp_pdev *pdev)
  2297. {
  2298. return QDF_STATUS_SUCCESS;
  2299. }
  2300. /* dp_pdev_htt_stats_dbgfs_deinit() - Function to remove debugfs entry for
  2301. * HTT stats
  2302. * @pdev: dp pdev handle
  2303. *
  2304. * Return: none
  2305. */
  2306. static inline void
  2307. dp_pdev_htt_stats_dbgfs_deinit(struct dp_pdev *pdev)
  2308. {
  2309. }
  2310. #endif /* HTT_STATS_DEBUGFS_SUPPORT */
  2311. #ifndef WLAN_DP_FEATURE_SW_LATENCY_MGR
  2312. /**
  2313. * dp_soc_swlm_attach() - attach the software latency manager resources
  2314. * @soc: Datapath global soc handle
  2315. *
  2316. * Returns: QDF_STATUS
  2317. */
  2318. static inline QDF_STATUS dp_soc_swlm_attach(struct dp_soc *soc)
  2319. {
  2320. return QDF_STATUS_SUCCESS;
  2321. }
  2322. /**
  2323. * dp_soc_swlm_detach() - detach the software latency manager resources
  2324. * @soc: Datapath global soc handle
  2325. *
  2326. * Returns: QDF_STATUS
  2327. */
  2328. static inline QDF_STATUS dp_soc_swlm_detach(struct dp_soc *soc)
  2329. {
  2330. return QDF_STATUS_SUCCESS;
  2331. }
  2332. #endif /* !WLAN_DP_FEATURE_SW_LATENCY_MGR */
  2333. #ifdef QCA_SUPPORT_WDS_EXTENDED
  2334. /**
  2335. * dp_wds_ext_get_peer_id(): function to get peer id by mac
  2336. * This API is called from control path when wds extended
  2337. * device is created, hence it also updates wds extended
  2338. * peer state to up, which will be referred in rx processing.
  2339. * @soc: Datapath soc handle
  2340. * @vdev_id: vdev id
  2341. * @mac: Peer mac address
  2342. *
  2343. * return: valid peer id on success
  2344. * HTT_INVALID_PEER on failure
  2345. */
  2346. uint16_t dp_wds_ext_get_peer_id(ol_txrx_soc_handle soc,
  2347. uint8_t vdev_id,
  2348. uint8_t *mac);
  2349. /**
  2350. * dp_wds_ext_set_peer_state(): function to set peer state
  2351. * @soc: Datapath soc handle
  2352. * @vdev_id: vdev id
  2353. * @mac: Peer mac address
  2354. * @rx: rx function pointer
  2355. *
  2356. * return: QDF_STATUS_SUCCESS on success
  2357. * QDF_STATUS_E_INVAL if peer is not found
  2358. * QDF_STATUS_E_ALREADY if rx is already set/unset
  2359. */
  2360. QDF_STATUS dp_wds_ext_set_peer_rx(ol_txrx_soc_handle soc,
  2361. uint8_t vdev_id,
  2362. uint8_t *mac,
  2363. ol_txrx_rx_fp rx,
  2364. ol_osif_peer_handle osif_peer);
  2365. #endif /* QCA_SUPPORT_WDS_EXTENDED */
  2366. #ifdef DP_MEM_PRE_ALLOC
  2367. /**
  2368. * dp_context_alloc_mem() - allocate memory for DP context
  2369. * @soc: datapath soc handle
  2370. * @ctxt_type: DP context type
  2371. * @ctxt_size: DP context size
  2372. *
  2373. * Return: DP context address
  2374. */
  2375. void *dp_context_alloc_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
  2376. size_t ctxt_size);
  2377. /**
  2378. * dp_context_free_mem() - Free memory of DP context
  2379. * @soc: datapath soc handle
  2380. * @ctxt_type: DP context type
  2381. * @vaddr: Address of context memory
  2382. *
  2383. * Return: None
  2384. */
  2385. void dp_context_free_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
  2386. void *vaddr);
  2387. /**
  2388. * dp_desc_multi_pages_mem_alloc() - alloc memory over multiple pages
  2389. * @soc: datapath soc handle
  2390. * @desc_type: memory request source type
  2391. * @pages: multi page information storage
  2392. * @element_size: each element size
  2393. * @element_num: total number of elements should be allocated
  2394. * @memctxt: memory context
  2395. * @cacheable: coherent memory or cacheable memory
  2396. *
  2397. * This function is a wrapper for memory allocation over multiple
  2398. * pages, if dp prealloc method is registered, then will try prealloc
  2399. * firstly. if prealloc failed, fall back to regular way over
  2400. * qdf_mem_multi_pages_alloc().
  2401. *
  2402. * Return: None
  2403. */
  2404. void dp_desc_multi_pages_mem_alloc(struct dp_soc *soc,
  2405. enum dp_desc_type desc_type,
  2406. struct qdf_mem_multi_page_t *pages,
  2407. size_t element_size,
  2408. uint16_t element_num,
  2409. qdf_dma_context_t memctxt,
  2410. bool cacheable);
  2411. /**
  2412. * dp_desc_multi_pages_mem_free() - free multiple pages memory
  2413. * @soc: datapath soc handle
  2414. * @desc_type: memory request source type
  2415. * @pages: multi page information storage
  2416. * @memctxt: memory context
  2417. * @cacheable: coherent memory or cacheable memory
  2418. *
  2419. * This function is a wrapper for multiple pages memory free,
  2420. * if memory is got from prealloc pool, put it back to pool.
  2421. * otherwise free by qdf_mem_multi_pages_free().
  2422. *
  2423. * Return: None
  2424. */
  2425. void dp_desc_multi_pages_mem_free(struct dp_soc *soc,
  2426. enum dp_desc_type desc_type,
  2427. struct qdf_mem_multi_page_t *pages,
  2428. qdf_dma_context_t memctxt,
  2429. bool cacheable);
  2430. #else
  2431. static inline
  2432. void *dp_context_alloc_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
  2433. size_t ctxt_size)
  2434. {
  2435. return qdf_mem_malloc(ctxt_size);
  2436. }
  2437. static inline
  2438. void dp_context_free_mem(struct dp_soc *soc, enum dp_ctxt_type ctxt_type,
  2439. void *vaddr)
  2440. {
  2441. qdf_mem_free(vaddr);
  2442. }
  2443. static inline
  2444. void dp_desc_multi_pages_mem_alloc(struct dp_soc *soc,
  2445. enum dp_desc_type desc_type,
  2446. struct qdf_mem_multi_page_t *pages,
  2447. size_t element_size,
  2448. uint16_t element_num,
  2449. qdf_dma_context_t memctxt,
  2450. bool cacheable)
  2451. {
  2452. qdf_mem_multi_pages_alloc(soc->osdev, pages, element_size,
  2453. element_num, memctxt, cacheable);
  2454. }
  2455. static inline
  2456. void dp_desc_multi_pages_mem_free(struct dp_soc *soc,
  2457. enum dp_desc_type desc_type,
  2458. struct qdf_mem_multi_page_t *pages,
  2459. qdf_dma_context_t memctxt,
  2460. bool cacheable)
  2461. {
  2462. qdf_mem_multi_pages_free(soc->osdev, pages,
  2463. memctxt, cacheable);
  2464. }
  2465. #endif
  2466. #ifdef FEATURE_RUNTIME_PM
  2467. /**
  2468. * dp_runtime_get() - Get dp runtime refcount
  2469. * @soc: Datapath soc handle
  2470. *
  2471. * Get dp runtime refcount by increment of an atomic variable, which can block
  2472. * dp runtime resume to wait to flush pending tx by runtime suspend.
  2473. *
  2474. * Return: Current refcount
  2475. */
  2476. static inline int32_t dp_runtime_get(struct dp_soc *soc)
  2477. {
  2478. return qdf_atomic_inc_return(&soc->dp_runtime_refcount);
  2479. }
  2480. /**
  2481. * dp_runtime_put() - Return dp runtime refcount
  2482. * @soc: Datapath soc handle
  2483. *
  2484. * Return dp runtime refcount by decrement of an atomic variable, allow dp
  2485. * runtime resume finish.
  2486. *
  2487. * Return: Current refcount
  2488. */
  2489. static inline int32_t dp_runtime_put(struct dp_soc *soc)
  2490. {
  2491. return qdf_atomic_dec_return(&soc->dp_runtime_refcount);
  2492. }
  2493. /**
  2494. * dp_runtime_get_refcount() - Get dp runtime refcount
  2495. * @soc: Datapath soc handle
  2496. *
  2497. * Get dp runtime refcount by returning an atomic variable
  2498. *
  2499. * Return: Current refcount
  2500. */
  2501. static inline int32_t dp_runtime_get_refcount(struct dp_soc *soc)
  2502. {
  2503. return qdf_atomic_read(&soc->dp_runtime_refcount);
  2504. }
  2505. /**
  2506. * dp_runtime_init() - Init dp runtime refcount when dp soc init
  2507. * @soc: Datapath soc handle
  2508. *
  2509. * Return: QDF_STATUS
  2510. */
  2511. static inline QDF_STATUS dp_runtime_init(struct dp_soc *soc)
  2512. {
  2513. return qdf_atomic_init(&soc->dp_runtime_refcount);
  2514. }
  2515. #else
  2516. static inline int32_t dp_runtime_get(struct dp_soc *soc)
  2517. {
  2518. return 0;
  2519. }
  2520. static inline int32_t dp_runtime_put(struct dp_soc *soc)
  2521. {
  2522. return 0;
  2523. }
  2524. static inline QDF_STATUS dp_runtime_init(struct dp_soc *soc)
  2525. {
  2526. return QDF_STATUS_SUCCESS;
  2527. }
  2528. #endif
  2529. static inline enum QDF_GLOBAL_MODE dp_soc_get_con_mode(struct dp_soc *soc)
  2530. {
  2531. if (soc->cdp_soc.ol_ops->get_con_mode)
  2532. return soc->cdp_soc.ol_ops->get_con_mode();
  2533. return QDF_GLOBAL_MAX_MODE;
  2534. }
  2535. /*
  2536. * dp_pdev_bkp_stats_detach() - detach resources for back pressure stats
  2537. * processing
  2538. * @pdev: Datapath PDEV handle
  2539. *
  2540. */
  2541. void dp_pdev_bkp_stats_detach(struct dp_pdev *pdev);
  2542. /*
  2543. * dp_pdev_bkp_stats_attach() - attach resources for back pressure stats
  2544. * processing
  2545. * @pdev: Datapath PDEV handle
  2546. *
  2547. * Return: QDF_STATUS_SUCCESS: Success
  2548. * QDF_STATUS_E_NOMEM: Error
  2549. */
  2550. QDF_STATUS dp_pdev_bkp_stats_attach(struct dp_pdev *pdev);
  2551. /**
  2552. * dp_peer_flush_frags() - Flush all fragments for a particular
  2553. * peer
  2554. * @soc_hdl - data path soc handle
  2555. * @vdev_id - vdev id
  2556. * @peer_addr - peer mac address
  2557. *
  2558. * Return: None
  2559. */
  2560. void dp_peer_flush_frags(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2561. uint8_t *peer_mac);
  2562. /**
  2563. * dp_soc_reset_mon_intr_mask() - reset mon intr mask
  2564. * @soc: pointer to dp_soc handle
  2565. *
  2566. * Return:
  2567. */
  2568. void dp_soc_reset_mon_intr_mask(struct dp_soc *soc);
  2569. /**
  2570. * dp_txrx_get_soc_stats() - will return cdp_soc_stats
  2571. * @soc_hdl: soc handle
  2572. * @soc_stats: buffer to hold the values
  2573. *
  2574. * Return: QDF_STATUS_SUCCESS: Success
  2575. * QDF_STATUS_E_FAILURE: Error
  2576. */
  2577. QDF_STATUS dp_txrx_get_soc_stats(struct cdp_soc_t *soc_hdl,
  2578. struct cdp_soc_stats *soc_stats);
  2579. /**
  2580. * dp_txrx_get_peer_delay_stats() - to get peer delay stats per TIDs
  2581. * @soc: soc handle
  2582. * @vdev_id: id of vdev handle
  2583. * @peer_mac: mac of DP_PEER handle
  2584. * @delay_stats: pointer to delay stats array
  2585. *
  2586. * Return: QDF_STATUS_SUCCESS: Success
  2587. * QDF_STATUS_E_FAILURE: Error
  2588. */
  2589. QDF_STATUS
  2590. dp_txrx_get_peer_delay_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2591. uint8_t *peer_mac,
  2592. struct cdp_delay_tid_stats *delay_stats);
  2593. /**
  2594. * dp_txrx_get_peer_jitter_stats() - to get peer jitter stats per TIDs
  2595. * @soc: soc handle
  2596. * @pdev_id: id of pdev handle
  2597. * @vdev_id: id of vdev handle
  2598. * @peer_mac: mac of DP_PEER handle
  2599. * @tid_stats: pointer to jitter stats array
  2600. *
  2601. * Return: QDF_STATUS_SUCCESS: Success
  2602. * QDF_STATUS_E_FAILURE: Error
  2603. */
  2604. QDF_STATUS
  2605. dp_txrx_get_peer_jitter_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  2606. uint8_t vdev_id, uint8_t *peer_mac,
  2607. struct cdp_peer_tid_stats *tid_stats);
  2608. #endif /* #ifndef _DP_INTERNAL_H_ */