dp_internal.h 80 KB

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