cdp_txrx_host_stats.h 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 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. /**
  20. * @file cdp_txrx_host_stats.h
  21. * @brief Define the host data path stats API functions
  22. * called by the host control SW and the OS interface module
  23. */
  24. #ifndef _CDP_TXRX_HOST_STATS_H_
  25. #define _CDP_TXRX_HOST_STATS_H_
  26. #include "cdp_txrx_handle.h"
  27. #include <cdp_txrx_cmn.h>
  28. #include <wmi_unified_api.h>
  29. /**
  30. * cdp_host_stats_get: cdp call to get host stats
  31. * @soc: SOC handle
  32. * @vdev_id: vdev id of vdev
  33. * @req: Requirement type
  34. *
  35. * return: 0 for Success, Failure returns error message
  36. */
  37. static inline int cdp_host_stats_get(ol_txrx_soc_handle soc,
  38. uint8_t vdev_id,
  39. struct ol_txrx_stats_req *req)
  40. {
  41. if (!soc || !soc->ops) {
  42. dp_cdp_debug("Invalid Instance");
  43. QDF_BUG(0);
  44. return 0;
  45. }
  46. if (!soc->ops->host_stats_ops ||
  47. !soc->ops->host_stats_ops->txrx_host_stats_get)
  48. return 0;
  49. return soc->ops->host_stats_ops->txrx_host_stats_get(soc, vdev_id, req);
  50. }
  51. /**
  52. * cdp_host_stats_get_ratekbps: cdp call to get rate in kbps
  53. * @soc: SOC handle
  54. * @preamb: Preamble
  55. * @mcs: Modulation and Coding scheme index
  56. * @htflag: Flag to identify HT or VHT
  57. * @gintval: Guard Interval value
  58. *
  59. * return: 0 for Failure, Returns rate on Success
  60. */
  61. static inline int cdp_host_stats_get_ratekbps(ol_txrx_soc_handle soc,
  62. int preamb, int mcs,
  63. int htflag, int gintval)
  64. {
  65. if (!soc || !soc->ops) {
  66. dp_cdp_debug("Invalid Instance");
  67. QDF_BUG(0);
  68. return 0;
  69. }
  70. if (!soc->ops->host_stats_ops ||
  71. !soc->ops->host_stats_ops->txrx_get_ratekbps)
  72. return 0;
  73. return soc->ops->host_stats_ops->txrx_get_ratekbps(preamb,
  74. mcs, htflag,
  75. gintval);
  76. }
  77. /**
  78. * cdp_host_stats_clr: cdp call to clear host stats
  79. * @soc: soc handle
  80. * @vdev_id: vdev handle id
  81. *
  82. * return: QDF_STATUS
  83. */
  84. static inline QDF_STATUS
  85. cdp_host_stats_clr(ol_txrx_soc_handle soc, uint8_t vdev_id)
  86. {
  87. if (!soc || !soc->ops) {
  88. dp_cdp_debug("Invalid Instance");
  89. QDF_BUG(0);
  90. return QDF_STATUS_E_FAILURE;
  91. }
  92. if (!soc->ops->host_stats_ops ||
  93. !soc->ops->host_stats_ops->txrx_host_stats_clr)
  94. return QDF_STATUS_E_FAILURE;
  95. return soc->ops->host_stats_ops->txrx_host_stats_clr(soc, vdev_id);
  96. }
  97. static inline QDF_STATUS
  98. cdp_host_ce_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  99. {
  100. if (!soc || !soc->ops) {
  101. dp_cdp_debug("Invalid Instance");
  102. QDF_BUG(0);
  103. return QDF_STATUS_E_FAILURE;
  104. }
  105. if (!soc->ops->host_stats_ops ||
  106. !soc->ops->host_stats_ops->txrx_host_ce_stats)
  107. return QDF_STATUS_E_FAILURE;
  108. return soc->ops->host_stats_ops->txrx_host_ce_stats(soc, vdev_id);
  109. }
  110. static inline int cdp_stats_publish
  111. (ol_txrx_soc_handle soc, uint8_t pdev_id,
  112. struct cdp_stats_extd *buf)
  113. {
  114. if (!soc || !soc->ops) {
  115. dp_cdp_debug("Invalid Instance");
  116. QDF_BUG(0);
  117. return 0;
  118. }
  119. if (!soc->ops->host_stats_ops ||
  120. !soc->ops->host_stats_ops->txrx_stats_publish)
  121. return 0;
  122. return soc->ops->host_stats_ops->txrx_stats_publish(soc, pdev_id, buf);
  123. }
  124. /**
  125. * @brief Enable enhanced stats functionality.
  126. *
  127. * @param soc - the soc object
  128. * @param pdev_id - id of the physical device object
  129. * @return - QDF_STATUS
  130. */
  131. static inline QDF_STATUS
  132. cdp_enable_enhanced_stats(ol_txrx_soc_handle soc, uint8_t pdev_id)
  133. {
  134. if (!soc || !soc->ops) {
  135. dp_cdp_debug("Invalid Instance");
  136. QDF_BUG(0);
  137. return QDF_STATUS_E_FAILURE;
  138. }
  139. if (!soc->ops->host_stats_ops ||
  140. !soc->ops->host_stats_ops->txrx_enable_enhanced_stats)
  141. return QDF_STATUS_E_FAILURE;
  142. return soc->ops->host_stats_ops->txrx_enable_enhanced_stats
  143. (soc, pdev_id);
  144. }
  145. /**
  146. * @brief Disable enhanced stats functionality.
  147. *
  148. * @param soc - the soc object
  149. * @param pdev_id - id of the physical device object
  150. * @return - QDF_STATUS
  151. */
  152. static inline QDF_STATUS
  153. cdp_disable_enhanced_stats(ol_txrx_soc_handle soc, uint8_t pdev_id)
  154. {
  155. if (!soc || !soc->ops) {
  156. dp_cdp_debug("Invalid Instance");
  157. QDF_BUG(0);
  158. return QDF_STATUS_E_FAILURE;
  159. }
  160. if (!soc->ops->host_stats_ops ||
  161. !soc->ops->host_stats_ops->txrx_disable_enhanced_stats)
  162. return QDF_STATUS_E_FAILURE;
  163. return soc->ops->host_stats_ops->txrx_disable_enhanced_stats
  164. (soc, pdev_id);
  165. }
  166. static inline QDF_STATUS
  167. cdp_tx_print_tso_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  168. {
  169. if (!soc || !soc->ops) {
  170. dp_cdp_debug("Invalid Instance");
  171. QDF_BUG(0);
  172. return QDF_STATUS_E_FAILURE;
  173. }
  174. if (!soc->ops->host_stats_ops ||
  175. !soc->ops->host_stats_ops->tx_print_tso_stats)
  176. return QDF_STATUS_E_FAILURE;
  177. return soc->ops->host_stats_ops->tx_print_tso_stats(soc, vdev_id);
  178. }
  179. static inline QDF_STATUS
  180. cdp_tx_rst_tso_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  181. {
  182. if (!soc || !soc->ops) {
  183. dp_cdp_debug("Invalid Instance");
  184. QDF_BUG(0);
  185. return QDF_STATUS_E_FAILURE;
  186. }
  187. if (!soc->ops->host_stats_ops ||
  188. !soc->ops->host_stats_ops->tx_rst_tso_stats)
  189. return QDF_STATUS_E_FAILURE;
  190. return soc->ops->host_stats_ops->tx_rst_tso_stats(soc, vdev_id);
  191. }
  192. static inline QDF_STATUS
  193. cdp_tx_print_sg_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  194. {
  195. if (!soc || !soc->ops) {
  196. dp_cdp_debug("Invalid Instance");
  197. QDF_BUG(0);
  198. return QDF_STATUS_E_FAILURE;
  199. }
  200. if (!soc->ops->host_stats_ops ||
  201. !soc->ops->host_stats_ops->tx_print_sg_stats)
  202. return QDF_STATUS_E_FAILURE;
  203. return soc->ops->host_stats_ops->tx_print_sg_stats(soc, vdev_id);
  204. }
  205. static inline QDF_STATUS
  206. cdp_tx_rst_sg_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  207. {
  208. if (!soc || !soc->ops) {
  209. dp_cdp_debug("Invalid Instance");
  210. QDF_BUG(0);
  211. return QDF_STATUS_E_FAILURE;
  212. }
  213. if (!soc->ops->host_stats_ops ||
  214. !soc->ops->host_stats_ops->tx_rst_sg_stats)
  215. return QDF_STATUS_E_FAILURE;
  216. return soc->ops->host_stats_ops->tx_rst_sg_stats(soc, vdev_id);
  217. }
  218. static inline QDF_STATUS
  219. cdp_print_rx_cksum_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  220. {
  221. if (!soc || !soc->ops) {
  222. dp_cdp_debug("Invalid Instance");
  223. QDF_BUG(0);
  224. return QDF_STATUS_E_FAILURE;
  225. }
  226. if (!soc->ops->host_stats_ops ||
  227. !soc->ops->host_stats_ops->print_rx_cksum_stats)
  228. return QDF_STATUS_E_FAILURE;
  229. return soc->ops->host_stats_ops->print_rx_cksum_stats(soc, vdev_id);
  230. }
  231. static inline QDF_STATUS
  232. cdp_rst_rx_cksum_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  233. {
  234. if (!soc || !soc->ops) {
  235. dp_cdp_debug("Invalid Instance");
  236. QDF_BUG(0);
  237. return QDF_STATUS_E_FAILURE;
  238. }
  239. if (!soc->ops->host_stats_ops ||
  240. !soc->ops->host_stats_ops->rst_rx_cksum_stats)
  241. return QDF_STATUS_E_FAILURE;
  242. return soc->ops->host_stats_ops->rst_rx_cksum_stats(soc, vdev_id);
  243. }
  244. static inline QDF_STATUS
  245. cdp_host_me_stats(ol_txrx_soc_handle soc, uint8_t vdev_id)
  246. {
  247. if (!soc || !soc->ops) {
  248. dp_cdp_debug("Invalid Instance");
  249. QDF_BUG(0);
  250. return QDF_STATUS_E_FAILURE;
  251. }
  252. if (!soc->ops->host_stats_ops ||
  253. !soc->ops->host_stats_ops->txrx_host_me_stats)
  254. return QDF_STATUS_E_FAILURE;
  255. return soc->ops->host_stats_ops->txrx_host_me_stats(soc, vdev_id);
  256. }
  257. /**
  258. * cdp_per_peer_stats(): function to print per peer REO Queue stats
  259. * @soc: soc handle
  260. * @pdev: physical device
  261. * @addr: peer address
  262. *
  263. * return: status
  264. */
  265. static inline QDF_STATUS cdp_per_peer_stats(ol_txrx_soc_handle soc,
  266. uint8_t *addr)
  267. {
  268. if (!soc || !soc->ops) {
  269. dp_cdp_debug("Invalid Instance");
  270. QDF_BUG(0);
  271. return QDF_STATUS_E_FAILURE;
  272. }
  273. if (!soc->ops->host_stats_ops ||
  274. !soc->ops->host_stats_ops->txrx_per_peer_stats)
  275. return QDF_STATUS_E_FAILURE;
  276. return soc->ops->host_stats_ops->txrx_per_peer_stats(soc, addr);
  277. }
  278. static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc,
  279. uint8_t vdev_id,
  280. struct ol_txrx_stats_req *req)
  281. {
  282. if (!soc || !soc->ops) {
  283. dp_cdp_debug("Invalid Instance");
  284. QDF_BUG(0);
  285. return 0;
  286. }
  287. if (!soc->ops->host_stats_ops ||
  288. !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats)
  289. return 0;
  290. return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats
  291. (soc, vdev_id, req);
  292. }
  293. static inline QDF_STATUS cdp_update_peer_stats(ol_txrx_soc_handle soc,
  294. uint8_t vdev_id, uint8_t *mac,
  295. void *stats,
  296. uint32_t last_tx_rate_mcs,
  297. uint32_t stats_id)
  298. {
  299. if (!soc || !soc->ops) {
  300. dp_cdp_debug("Invalid Instance");
  301. QDF_BUG(0);
  302. return QDF_STATUS_E_FAILURE;
  303. }
  304. if (!soc->ops->host_stats_ops ||
  305. !soc->ops->host_stats_ops->txrx_update_peer_stats)
  306. return QDF_STATUS_E_FAILURE;
  307. return soc->ops->host_stats_ops->txrx_update_peer_stats
  308. (soc, vdev_id, mac, stats, last_tx_rate_mcs, stats_id);
  309. }
  310. static inline QDF_STATUS cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc,
  311. uint8_t pdev_id,
  312. uint8_t *mac, uint32_t caps,
  313. uint32_t copy_stats)
  314. {
  315. if (!soc || !soc->ops) {
  316. dp_cdp_debug("Invalid Instance");
  317. QDF_BUG(0);
  318. return QDF_STATUS_E_FAILURE;
  319. }
  320. if (!soc->ops->host_stats_ops ||
  321. !soc->ops->host_stats_ops->get_fw_peer_stats)
  322. return QDF_STATUS_E_FAILURE;
  323. return soc->ops->host_stats_ops->get_fw_peer_stats
  324. (soc, pdev_id, mac, caps, copy_stats);
  325. }
  326. static inline QDF_STATUS cdp_get_dp_htt_stats(ol_txrx_soc_handle soc,
  327. uint8_t pdev_id,
  328. void *data, uint32_t data_len)
  329. {
  330. if (!soc || !soc->ops) {
  331. dp_cdp_debug("Invalid Instance");
  332. QDF_BUG(0);
  333. return QDF_STATUS_E_FAILURE;
  334. }
  335. if (!soc->ops->host_stats_ops ||
  336. !soc->ops->host_stats_ops->get_htt_stats)
  337. return QDF_STATUS_E_FAILURE;
  338. return soc->ops->host_stats_ops->get_htt_stats(soc, pdev_id, data,
  339. data_len);
  340. }
  341. /**
  342. * @brief Update pdev host stats received from firmware
  343. * (wmi_host_pdev_stats and wmi_host_pdev_ext_stats) into dp
  344. *
  345. * @param soc - soc handle
  346. * @param pdev_id - id of the physical device object
  347. * @param data - pdev stats
  348. * @return - QDF_STATUS
  349. */
  350. static inline QDF_STATUS
  351. cdp_update_pdev_host_stats(ol_txrx_soc_handle soc,
  352. uint8_t pdev_id,
  353. void *data,
  354. uint16_t stats_id)
  355. {
  356. if (!soc || !soc->ops) {
  357. dp_cdp_debug("Invalid Instance");
  358. QDF_BUG(0);
  359. return QDF_STATUS_E_FAILURE;
  360. }
  361. if (!soc->ops->host_stats_ops ||
  362. !soc->ops->host_stats_ops->txrx_update_pdev_stats)
  363. return QDF_STATUS_E_FAILURE;
  364. return soc->ops->host_stats_ops->txrx_update_pdev_stats(soc, pdev_id,
  365. data,
  366. stats_id);
  367. }
  368. /**
  369. * @brief Update vdev host stats
  370. *
  371. * @soc: soc handle
  372. * @vdev_id: id of the virtual device object
  373. * @data: pdev stats
  374. * @stats_id: type of stats
  375. *
  376. * Return: QDF_STATUS
  377. */
  378. static inline QDF_STATUS
  379. cdp_update_vdev_host_stats(ol_txrx_soc_handle soc,
  380. uint8_t vdev_id,
  381. void *data,
  382. uint16_t stats_id)
  383. {
  384. if (!soc || !soc->ops) {
  385. dp_cdp_debug("Invalid Instance");
  386. QDF_BUG(0);
  387. return QDF_STATUS_E_FAILURE;
  388. }
  389. if (!soc->ops->host_stats_ops ||
  390. !soc->ops->host_stats_ops->txrx_update_vdev_stats)
  391. return QDF_STATUS_E_FAILURE;
  392. return soc->ops->host_stats_ops->txrx_update_vdev_stats(soc, vdev_id,
  393. data,
  394. stats_id);
  395. }
  396. /**
  397. * @brief Call to get specified peer stats
  398. *
  399. * @param soc - soc handle
  400. * @param vdev_id - vdev_id of vdev object
  401. * @param peer_mac - mac address of the peer
  402. * @param type - enum of required stats
  403. * @param buf - buffer to hold the value
  404. * @return - QDF_STATUS
  405. */
  406. static inline QDF_STATUS
  407. cdp_txrx_get_peer_stats_param(ol_txrx_soc_handle soc, uint8_t vdev_id,
  408. uint8_t *peer_mac,
  409. enum cdp_peer_stats_type type,
  410. cdp_peer_stats_param_t *buf)
  411. {
  412. if (!soc || !soc->ops) {
  413. dp_cdp_debug("Invalid Instance");
  414. QDF_BUG(0);
  415. return QDF_STATUS_E_FAILURE;
  416. }
  417. if (!soc->ops->host_stats_ops ||
  418. !soc->ops->host_stats_ops->txrx_get_peer_stats_param)
  419. return QDF_STATUS_E_FAILURE;
  420. return soc->ops->host_stats_ops->txrx_get_peer_stats_param(soc,
  421. vdev_id,
  422. peer_mac,
  423. type,
  424. buf);
  425. }
  426. /**
  427. * @brief Call to get soc stats
  428. *
  429. * @param soc - soc handle
  430. * @soc_stats - buffer for cdp soc stats
  431. * @return - QDF_STATUS
  432. */
  433. static inline QDF_STATUS
  434. cdp_host_get_soc_stats(ol_txrx_soc_handle soc, struct cdp_soc_stats *soc_stats)
  435. {
  436. if (!soc || !soc->ops) {
  437. dp_cdp_debug("Invalid Instance");
  438. QDF_BUG(0);
  439. return QDF_STATUS_E_FAILURE;
  440. }
  441. if (!soc->ops->host_stats_ops ||
  442. !soc->ops->host_stats_ops->txrx_get_soc_stats)
  443. return QDF_STATUS_E_FAILURE;
  444. return soc->ops->host_stats_ops->txrx_get_soc_stats(soc, soc_stats);
  445. }
  446. /**
  447. * @brief Call to get peer stats
  448. *
  449. * @param soc - soc handle
  450. * @param vdev_id - vdev_id of vdev object
  451. * @param peer_mac - mac address of the peer
  452. * @return - struct cdp_peer_stats
  453. */
  454. static inline QDF_STATUS
  455. cdp_host_get_peer_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
  456. uint8_t *peer_mac,
  457. struct cdp_peer_stats *peer_stats)
  458. {
  459. if (!soc || !soc->ops) {
  460. dp_cdp_debug("Invalid Instance");
  461. QDF_BUG(0);
  462. return QDF_STATUS_E_FAILURE;
  463. }
  464. if (!soc->ops->host_stats_ops ||
  465. !soc->ops->host_stats_ops->txrx_get_peer_stats)
  466. return QDF_STATUS_E_FAILURE;
  467. return soc->ops->host_stats_ops->txrx_get_peer_stats(soc, vdev_id,
  468. peer_mac,
  469. peer_stats);
  470. }
  471. /**
  472. * @brief Call to reset ald stats
  473. *
  474. * @param soc - soc handle
  475. * @param vdev_id - vdev_id of vdev object
  476. * @param peer_mac - mac address of the peer
  477. * @return - void
  478. */
  479. static inline QDF_STATUS
  480. cdp_host_reset_peer_ald_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
  481. uint8_t *peer_mac)
  482. {
  483. if (!soc || !soc->ops) {
  484. dp_cdp_debug("Invalid Instance");
  485. QDF_BUG(0);
  486. return QDF_STATUS_E_FAILURE;
  487. }
  488. if (!soc->ops->host_stats_ops ||
  489. !soc->ops->host_stats_ops->txrx_reset_peer_ald_stats)
  490. return QDF_STATUS_E_FAILURE;
  491. return soc->ops->host_stats_ops->txrx_reset_peer_ald_stats(soc,
  492. vdev_id,
  493. peer_mac);
  494. }
  495. /**
  496. * @brief Call to reset peer stats
  497. *
  498. * @param soc - soc handle
  499. * @param vdev_id - vdev_id of vdev object
  500. * @param peer_mac - mac address of the peer
  501. * @return - QDF_STATUS
  502. */
  503. static inline QDF_STATUS
  504. cdp_host_reset_peer_stats(ol_txrx_soc_handle soc,
  505. uint8_t vdev_id, uint8_t *peer_mac)
  506. {
  507. if (!soc || !soc->ops) {
  508. dp_cdp_debug("Invalid Instance");
  509. QDF_BUG(0);
  510. return QDF_STATUS_E_FAILURE;
  511. }
  512. if (!soc->ops->host_stats_ops ||
  513. !soc->ops->host_stats_ops->txrx_reset_peer_stats)
  514. return QDF_STATUS_E_FAILURE;
  515. return soc->ops->host_stats_ops->txrx_reset_peer_stats(soc,
  516. vdev_id,
  517. peer_mac);
  518. }
  519. /**
  520. * @brief Call to get vdev stats
  521. *
  522. * @param soc - dp soc object
  523. * @param vdev_id - id of dp vdev object
  524. * @param buf - buffer
  525. * @return - int
  526. */
  527. static inline int
  528. cdp_host_get_vdev_stats(ol_txrx_soc_handle soc,
  529. uint8_t vdev_id,
  530. struct cdp_vdev_stats *buf,
  531. bool is_aggregate)
  532. {
  533. if (!soc || !soc->ops) {
  534. dp_cdp_debug("Invalid Instance");
  535. QDF_BUG(0);
  536. return 0;
  537. }
  538. if (!soc->ops->host_stats_ops ||
  539. !soc->ops->host_stats_ops->txrx_get_vdev_stats)
  540. return 0;
  541. return soc->ops->host_stats_ops->txrx_get_vdev_stats(soc, vdev_id,
  542. buf,
  543. is_aggregate);
  544. }
  545. /**
  546. * @brief Call to update vdev stats received from firmware
  547. * (wmi_host_vdev_stats and wmi_host_vdev_extd_stats) into dp
  548. *
  549. * @param data - stats data to be updated
  550. * @param size - size of stats data
  551. * @param stats_id - stats id
  552. * @return - int
  553. */
  554. static inline int
  555. cdp_update_host_vdev_stats(ol_txrx_soc_handle soc,
  556. void *data,
  557. uint32_t size,
  558. uint32_t stats_id)
  559. {
  560. if (!soc || !soc->ops) {
  561. dp_cdp_debug("Invalid Instance");
  562. QDF_BUG(0);
  563. return 0;
  564. }
  565. if (!soc->ops->host_stats_ops ||
  566. !soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats)
  567. return 0;
  568. return soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats
  569. (soc,
  570. data,
  571. size,
  572. stats_id);
  573. }
  574. /**
  575. * @brief Call to get vdev extd stats
  576. *
  577. * @param soc - soc handle
  578. * @param vdev_id - id of dp vdev object
  579. * @param buf - buffer
  580. * @return - int
  581. */
  582. static inline int
  583. cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc,
  584. uint8_t vdev_id,
  585. wmi_host_vdev_extd_stats *buf)
  586. {
  587. if (!soc || !soc->ops) {
  588. dp_cdp_debug("Invalid Instance");
  589. QDF_BUG(0);
  590. return 0;
  591. }
  592. if (!soc->ops->host_stats_ops ||
  593. !soc->ops->host_stats_ops->txrx_get_vdev_extd_stats)
  594. return 0;
  595. return soc->ops->host_stats_ops->txrx_get_vdev_extd_stats(soc, vdev_id,
  596. buf);
  597. }
  598. /**
  599. * @brief Call to get cdp_pdev_stats
  600. *
  601. * @param soc - soc handle
  602. * @param pdev_id - id of dp pdev object
  603. * @param buf - buffer to hold cdp_pdev_stats
  604. * @return - success/failure
  605. */
  606. static inline int
  607. cdp_host_get_pdev_stats(ol_txrx_soc_handle soc,
  608. uint8_t pdev_id, struct cdp_pdev_stats *buf)
  609. {
  610. if (!soc || !soc->ops) {
  611. dp_cdp_debug("Invalid Instance");
  612. QDF_BUG(0);
  613. return 0;
  614. }
  615. if (!soc->ops->host_stats_ops ||
  616. !soc->ops->host_stats_ops->txrx_get_pdev_stats)
  617. return 0;
  618. return soc->ops->host_stats_ops->txrx_get_pdev_stats(soc, pdev_id, buf);
  619. }
  620. /**
  621. * @brief Call to get radio stats
  622. *
  623. * @param soc - soc handle
  624. * @param pdev_id - id of dp pdev object
  625. * @param scn_stats_user - stats buffer
  626. * @return - int
  627. */
  628. static inline int
  629. cdp_host_get_radio_stats(ol_txrx_soc_handle soc,
  630. uint8_t pdev_id,
  631. void *buf)
  632. {
  633. if (!soc || !soc->ops) {
  634. dp_cdp_debug("Invalid Instance");
  635. QDF_BUG(0);
  636. return 0;
  637. }
  638. if (!soc->ops->host_stats_ops ||
  639. !soc->ops->host_stats_ops->txrx_get_radio_stats)
  640. return 0;
  641. return soc->ops->host_stats_ops->txrx_get_radio_stats(soc, pdev_id,
  642. buf);
  643. }
  644. #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS
  645. static inline int
  646. cdp_get_scan_spcl_vap_stats(ol_txrx_soc_handle soc,
  647. uint8_t vdev_id,
  648. struct cdp_scan_spcl_vap_stats *stats)
  649. {
  650. if (!soc || !soc->ops) {
  651. dp_cdp_debug("Invalid Instance");
  652. QDF_BUG(0);
  653. return QDF_STATUS_E_FAILURE;
  654. }
  655. if (!soc->ops->host_stats_ops ||
  656. !soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats)
  657. return QDF_STATUS_E_FAILURE;
  658. return soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats(soc,
  659. vdev_id,
  660. stats);
  661. }
  662. #endif
  663. /**
  664. * cdp_get_peer_delay_stats() - Call to get per peer delay stats
  665. * @soc: soc handle
  666. * @vdev_id: id of dp_vdev handle
  667. * @peer_mac: peer mac address
  668. * @delay_stats: user allocated buffer for peer delay stats
  669. *
  670. * return: status Success/Failure
  671. */
  672. static inline QDF_STATUS
  673. cdp_get_peer_delay_stats(ol_txrx_soc_handle soc,
  674. uint8_t vdev_id,
  675. uint8_t *peer_mac,
  676. struct cdp_delay_tid_stats *delay_stats)
  677. {
  678. if (!soc || !soc->ops) {
  679. dp_cdp_debug("Invalid Instance");
  680. QDF_BUG(0);
  681. return QDF_STATUS_E_FAILURE;
  682. }
  683. if (!soc->ops->host_stats_ops ||
  684. !soc->ops->host_stats_ops->txrx_get_peer_delay_stats)
  685. return QDF_STATUS_E_FAILURE;
  686. return soc->ops->host_stats_ops->txrx_get_peer_delay_stats(soc,
  687. vdev_id,
  688. peer_mac,
  689. delay_stats);
  690. }
  691. /**
  692. * cdp_get_peer_jitter_stats() - Call to get per peer jitter stats
  693. * @soc: soc handle
  694. * @pdev_id: id of dp_pdev handle
  695. * @vdev_id: id of dp_vdev handle
  696. * @peer_mac: peer mac address
  697. * @tid_stats: user allocated buffer for tid_stats
  698. *
  699. * return: status Success/Failure
  700. */
  701. static inline QDF_STATUS
  702. cdp_get_peer_jitter_stats(ol_txrx_soc_handle soc,
  703. uint8_t pdev_id,
  704. uint8_t vdev_id,
  705. uint8_t *peer_mac,
  706. struct cdp_peer_tid_stats *tid_stats)
  707. {
  708. if (!soc || !soc->ops) {
  709. dp_cdp_debug("Invalid Instance");
  710. QDF_BUG(0);
  711. return QDF_STATUS_E_FAILURE;
  712. }
  713. if (!soc->ops->host_stats_ops ||
  714. !soc->ops->host_stats_ops->txrx_get_peer_jitter_stats)
  715. return QDF_STATUS_E_FAILURE;
  716. return soc->ops->host_stats_ops->txrx_get_peer_jitter_stats(soc,
  717. pdev_id,
  718. vdev_id,
  719. peer_mac,
  720. tid_stats);
  721. }
  722. /**
  723. * cdp_mon_pdev_get_rx_stats() - Call to get monitor pdev rx stats
  724. * @soc: soc handle
  725. * @pdev_id: id of dp_pdev handle
  726. * @stats: user allocated buffer for dp pdev mon stats
  727. *
  728. * return: status Success/Failure
  729. */
  730. static inline QDF_STATUS
  731. cdp_mon_pdev_get_rx_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
  732. struct cdp_pdev_mon_stats *stats)
  733. {
  734. if (!soc || !soc->ops) {
  735. dp_cdp_debug("Invalid Instance");
  736. QDF_BUG(0);
  737. return QDF_STATUS_E_FAILURE;
  738. }
  739. if (!soc->ops->mon_ops ||
  740. !soc->ops->mon_ops->get_mon_pdev_rx_stats)
  741. return QDF_STATUS_E_FAILURE;
  742. return soc->ops->mon_ops->get_mon_pdev_rx_stats(soc, pdev_id, stats);
  743. }
  744. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  745. /**
  746. * cdp_get_peer_tx_capture_stats() - Call to get peer tx capture stats
  747. * @soc: soc handle
  748. * @vdev_id: id of dp_vdev handle
  749. * @peer_mac: peer mac address
  750. * @stats: pointer to peer tx capture stats
  751. *
  752. * return: status Success/Failure
  753. */
  754. static inline QDF_STATUS
  755. cdp_get_peer_tx_capture_stats(ol_txrx_soc_handle soc,
  756. uint8_t vdev_id,
  757. uint8_t *peer_mac,
  758. struct cdp_peer_tx_capture_stats *stats)
  759. {
  760. if (!soc || !soc->ops) {
  761. dp_cdp_debug("Invalid Instance");
  762. QDF_BUG(0);
  763. return QDF_STATUS_E_FAILURE;
  764. }
  765. if (!soc->ops->host_stats_ops ||
  766. !soc->ops->host_stats_ops->get_peer_tx_capture_stats)
  767. return QDF_STATUS_E_FAILURE;
  768. return soc->ops->host_stats_ops->get_peer_tx_capture_stats(soc, vdev_id,
  769. peer_mac,
  770. stats);
  771. }
  772. /**
  773. * cdp_get_pdev_tx_capture_stats() - Call to get pdev tx capture stats
  774. * @soc: soc handle
  775. * @pdev_id: id of dp_pdev handle
  776. * @stats: pointer to pdev tx capture stats
  777. *
  778. * return: status Success/Failure
  779. */
  780. static inline QDF_STATUS
  781. cdp_get_pdev_tx_capture_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
  782. struct cdp_pdev_tx_capture_stats *stats)
  783. {
  784. if (!soc || !soc->ops) {
  785. dp_cdp_debug("Invalid Instance");
  786. QDF_BUG(0);
  787. return QDF_STATUS_E_FAILURE;
  788. }
  789. if (!soc->ops->host_stats_ops ||
  790. !soc->ops->host_stats_ops->get_pdev_tx_capture_stats)
  791. return QDF_STATUS_E_FAILURE;
  792. return soc->ops->host_stats_ops->get_pdev_tx_capture_stats(soc, pdev_id,
  793. stats);
  794. }
  795. #endif /* WLAN_TX_PKT_CAPTURE_ENH */
  796. #ifdef HW_TX_DELAY_STATS_ENABLE
  797. /**
  798. * cdp_enable_disable_vdev_tx_delay_stats() - Start/Stop tx delay stats capture
  799. * @soc: soc handle
  800. * @vdev_id: vdev id
  801. * @value: value to be set
  802. *
  803. * Return: None
  804. */
  805. static inline void
  806. cdp_enable_disable_vdev_tx_delay_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
  807. uint8_t value)
  808. {
  809. if (!soc || !soc->ops) {
  810. dp_cdp_debug("Invalid Instance");
  811. return;
  812. }
  813. if (!soc->ops->host_stats_ops ||
  814. !soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats)
  815. return;
  816. soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats(soc,
  817. vdev_id,
  818. value);
  819. }
  820. /**
  821. * cdp_vdev_is_tx_delay_stats_enabled() - Check if the Tx delay stats
  822. * is enabled or not for the given vdev_id
  823. * @soc: soc handle
  824. * @vdev_id: vdev_id
  825. *
  826. * Returns: 1 if enabled, 0 if disabled
  827. */
  828. static inline uint8_t
  829. cdp_vdev_is_tx_delay_stats_enabled(ol_txrx_soc_handle soc, uint8_t vdev_id)
  830. {
  831. if (!soc || !soc->ops || !soc->ops->host_stats_ops) {
  832. dp_cdp_debug("Invalid Instance:");
  833. return 0;
  834. }
  835. if (soc->ops->host_stats_ops->is_tx_delay_stats_enabled)
  836. return soc->ops->host_stats_ops->is_tx_delay_stats_enabled(soc,
  837. vdev_id);
  838. return 0;
  839. }
  840. #endif
  841. /**
  842. * cdp_get_pdev_tid_stats() - Get pdev tid stats
  843. * @soc: soc handle
  844. * @pdev_id: Pdev id
  845. * @tid_stats: Pointer to cdp_tid_stats_intf
  846. *
  847. * Return: status Success/Failure
  848. */
  849. static inline QDF_STATUS
  850. cdp_get_pdev_tid_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
  851. struct cdp_tid_stats_intf *tid_stats)
  852. {
  853. if (!soc || !soc->ops || !soc->ops->host_stats_ops) {
  854. dp_cdp_debug("Invalid Instance:");
  855. return QDF_STATUS_E_FAILURE;
  856. }
  857. if (!soc->ops->host_stats_ops->txrx_get_pdev_tid_stats)
  858. return QDF_STATUS_E_FAILURE;
  859. return soc->ops->host_stats_ops->txrx_get_pdev_tid_stats(soc, pdev_id,
  860. tid_stats);
  861. }
  862. #ifdef WLAN_TELEMETRY_STATS_SUPPORT
  863. /**
  864. * cdp_get_pdev_telemetry_stats(): function to get pdev telemetry stats
  865. * @soc: soc handle
  866. * @pdev_id: pdev id
  867. * @stats: pointer to pdev telemetry stats
  868. *
  869. * return: status
  870. */
  871. static inline QDF_STATUS cdp_get_pdev_telemetry_stats(
  872. ol_txrx_soc_handle soc,
  873. uint8_t pdev_id,
  874. struct cdp_pdev_telemetry_stats *stats)
  875. {
  876. if (!soc || !soc->ops) {
  877. dp_cdp_debug("Invalid Instance");
  878. QDF_BUG(0);
  879. return QDF_STATUS_E_FAILURE;
  880. }
  881. if (!soc->ops->host_stats_ops ||
  882. !soc->ops->host_stats_ops->txrx_pdev_telemetry_stats)
  883. return QDF_STATUS_E_FAILURE;
  884. return soc->ops->host_stats_ops->txrx_pdev_telemetry_stats(
  885. soc, pdev_id, stats);
  886. }
  887. /**
  888. * cdp_get_peer_telemetry_stats(): function to get peer telemetry stats
  889. * @soc: soc handle
  890. * @addr: peer address
  891. * @stats: pointer to peer telemetry stats
  892. *
  893. * return: status
  894. */
  895. static inline QDF_STATUS cdp_get_peer_telemetry_stats(
  896. ol_txrx_soc_handle soc,
  897. uint8_t *addr,
  898. struct cdp_peer_telemetry_stats *stats)
  899. {
  900. if (!soc || !soc->ops) {
  901. dp_cdp_debug("Invalid Instance");
  902. QDF_BUG(0);
  903. return QDF_STATUS_E_FAILURE;
  904. }
  905. if (!soc->ops->host_stats_ops ||
  906. !soc->ops->host_stats_ops->txrx_peer_telemetry_stats)
  907. return QDF_STATUS_E_FAILURE;
  908. return soc->ops->host_stats_ops->txrx_peer_telemetry_stats(
  909. soc, addr, stats);
  910. }
  911. /**
  912. * cdp_get_pdev_deter_stats(): function to get pdev deterministic stats
  913. * @soc: soc handle
  914. * @pdev_id: pdev id
  915. * @stats: pointer to pdev deterministic stats
  916. *
  917. * return: status
  918. */
  919. static inline QDF_STATUS cdp_get_pdev_deter_stats(
  920. ol_txrx_soc_handle soc,
  921. uint8_t pdev_id,
  922. struct cdp_pdev_deter_stats *stats)
  923. {
  924. if (!soc || !soc->ops) {
  925. dp_cdp_debug("Invalid Instance");
  926. QDF_BUG(0);
  927. return QDF_STATUS_E_FAILURE;
  928. }
  929. if (!soc->ops->host_stats_ops ||
  930. !soc->ops->host_stats_ops->txrx_pdev_deter_stats)
  931. return QDF_STATUS_E_FAILURE;
  932. return soc->ops->host_stats_ops->txrx_pdev_deter_stats(
  933. soc, pdev_id, stats);
  934. }
  935. /**
  936. * cdp_get_peer_deter_stats(): function to get peer deterministic stats
  937. * @soc: soc handle
  938. * @addr: peer address
  939. * @stats: pointer to peer telemetry stats
  940. *
  941. * return: status
  942. */
  943. static inline QDF_STATUS cdp_get_peer_deter_stats(
  944. ol_txrx_soc_handle soc,
  945. uint8_t *addr,
  946. struct cdp_peer_deter_stats *stats)
  947. {
  948. if (!soc || !soc->ops) {
  949. dp_cdp_debug("Invalid Instance");
  950. QDF_BUG(0);
  951. return QDF_STATUS_E_FAILURE;
  952. }
  953. if (!soc->ops->host_stats_ops ||
  954. !soc->ops->host_stats_ops->txrx_peer_deter_stats)
  955. return QDF_STATUS_E_FAILURE;
  956. return soc->ops->host_stats_ops->txrx_peer_deter_stats(
  957. soc, addr, stats);
  958. }
  959. /**
  960. * cdp_update_pdev_chan_util_stats(): function to update pdev channel util stats
  961. * @soc: soc handle
  962. * @pdev_id: pdev id
  963. * @ch_util: pointer to pdev ch util stats
  964. *
  965. * return: status
  966. */
  967. static inline QDF_STATUS cdp_update_pdev_chan_util_stats(
  968. ol_txrx_soc_handle soc,
  969. uint8_t pdev_id,
  970. struct cdp_pdev_chan_util_stats *ch_util)
  971. {
  972. if (!soc || !soc->ops) {
  973. dp_cdp_debug("Invalid Instance");
  974. QDF_BUG(0);
  975. return QDF_STATUS_E_FAILURE;
  976. }
  977. if (!soc->ops->host_stats_ops ||
  978. !soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats)
  979. return QDF_STATUS_E_FAILURE;
  980. return soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats(
  981. soc, pdev_id, ch_util);
  982. }
  983. #endif
  984. /**
  985. * cdp_get_peer_extd_rate_link_stats(): cdp function to get peer
  986. * extended rate and link stats
  987. * @soc: soc handle
  988. * @addr: mac address
  989. *
  990. * return: status
  991. */
  992. static inline QDF_STATUS cdp_get_peer_extd_rate_link_stats(
  993. ol_txrx_soc_handle soc,
  994. uint8_t *mac_addr)
  995. {
  996. if (!soc || !soc->ops) {
  997. dp_cdp_debug("Invalid Instance");
  998. QDF_BUG(0);
  999. return QDF_STATUS_E_FAILURE;
  1000. }
  1001. if (!soc->ops->host_stats_ops ||
  1002. !soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats)
  1003. return QDF_STATUS_E_FAILURE;
  1004. return soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats(
  1005. soc, mac_addr);
  1006. }
  1007. /*
  1008. * cdp_get_pdev_obss_pd_stats(): function to get pdev obss stats
  1009. * @soc: soc handle
  1010. * @pdev_id: pdev id
  1011. * @stats: pointer to pdev obss stats
  1012. * @req: Pointer to CDP TxRx stats
  1013. *
  1014. * return: status
  1015. */
  1016. static inline QDF_STATUS cdp_get_pdev_obss_pd_stats(
  1017. ol_txrx_soc_handle soc,
  1018. uint8_t pdev_id,
  1019. struct cdp_pdev_obss_pd_stats_tlv *stats,
  1020. struct cdp_txrx_stats_req *req)
  1021. {
  1022. if (!soc || !soc->ops) {
  1023. dp_cdp_debug("Invalid Instance");
  1024. QDF_BUG(0);
  1025. return QDF_STATUS_E_FAILURE;
  1026. }
  1027. if (!soc->ops->host_stats_ops ||
  1028. !soc->ops->host_stats_ops->get_pdev_obss_stats)
  1029. return QDF_STATUS_E_FAILURE;
  1030. return soc->ops->host_stats_ops->get_pdev_obss_stats(
  1031. soc, pdev_id, stats, req);
  1032. }
  1033. /**
  1034. * cdp_clear_pdev_obss_pd_stats(): function to clear pdev obss stats
  1035. * @soc: soc handle
  1036. * @pdev_id: pdev id
  1037. * @req: Pointer to CDP TxRx stats request. mac_id will be pre-filled
  1038. * and should not be overwritten
  1039. *
  1040. * return: status
  1041. */
  1042. static inline QDF_STATUS cdp_clear_pdev_obss_pd_stats(
  1043. ol_txrx_soc_handle soc,
  1044. uint8_t pdev_id, struct cdp_txrx_stats_req *req)
  1045. {
  1046. if (!soc || !soc->ops) {
  1047. dp_cdp_debug("Invalid Instance");
  1048. QDF_BUG(0);
  1049. return QDF_STATUS_E_FAILURE;
  1050. }
  1051. if (!soc->ops->host_stats_ops ||
  1052. !soc->ops->host_stats_ops->clear_pdev_obss_pd_stats)
  1053. return QDF_STATUS_E_FAILURE;
  1054. return soc->ops->host_stats_ops->clear_pdev_obss_pd_stats(
  1055. soc, pdev_id, req);
  1056. }
  1057. #endif /* _CDP_TXRX_HOST_STATS_H_ */