dp_internal.h 79 KB

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