cdp_txrx_host_stats.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /*
  2. * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * @file cdp_txrx_host_stats.h
  20. * @brief Define the host data path stats API functions
  21. * called by the host control SW and the OS interface module
  22. */
  23. #ifndef _CDP_TXRX_HOST_STATS_H_
  24. #define _CDP_TXRX_HOST_STATS_H_
  25. #include "cdp_txrx_handle.h"
  26. /**
  27. * cdp_host_stats_get: cdp call to get host stats
  28. * @soc: SOC handle
  29. * @req: Requirement type
  30. *
  31. * return: 0 for Success, Failure returns error message
  32. */
  33. static inline int cdp_host_stats_get(ol_txrx_soc_handle soc,
  34. struct cdp_vdev *vdev,
  35. struct ol_txrx_stats_req *req)
  36. {
  37. if (!soc || !soc->ops) {
  38. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  39. "%s: Invalid Instance", __func__);
  40. QDF_BUG(0);
  41. return 0;
  42. }
  43. if (!soc->ops->host_stats_ops ||
  44. !soc->ops->host_stats_ops->txrx_host_stats_get)
  45. return 0;
  46. return soc->ops->host_stats_ops->txrx_host_stats_get(vdev, req);
  47. }
  48. /**
  49. * cdp_host_stats_clr: cdp call to clear host stats
  50. * @vdev: vdev handle
  51. *
  52. * return: void
  53. */
  54. static inline void
  55. cdp_host_stats_clr(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  56. {
  57. if (!soc || !soc->ops) {
  58. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  59. "%s: Invalid Instance", __func__);
  60. QDF_BUG(0);
  61. return;
  62. }
  63. if (!soc->ops->host_stats_ops ||
  64. !soc->ops->host_stats_ops->txrx_host_stats_clr)
  65. return;
  66. soc->ops->host_stats_ops->txrx_host_stats_clr(vdev);
  67. }
  68. static inline void
  69. cdp_host_ce_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  70. {
  71. if (!soc || !soc->ops) {
  72. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  73. "%s: Invalid Instance", __func__);
  74. QDF_BUG(0);
  75. return;
  76. }
  77. if (!soc->ops->host_stats_ops ||
  78. !soc->ops->host_stats_ops->txrx_host_ce_stats)
  79. return;
  80. soc->ops->host_stats_ops->txrx_host_ce_stats(vdev);
  81. }
  82. static inline int cdp_stats_publish
  83. (ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  84. struct ol_txrx_stats *buf)
  85. {
  86. if (!soc || !soc->ops) {
  87. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  88. "%s: Invalid Instance", __func__);
  89. QDF_BUG(0);
  90. return 0;
  91. }
  92. if (!soc->ops->host_stats_ops ||
  93. !soc->ops->host_stats_ops->txrx_stats_publish)
  94. return 0;
  95. return soc->ops->host_stats_ops->txrx_stats_publish(pdev, buf);
  96. }
  97. /**
  98. * @brief Enable enhanced stats functionality.
  99. *
  100. * @param pdev - the physical device object
  101. * @return - void
  102. */
  103. static inline void
  104. cdp_enable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  105. {
  106. if (!soc || !soc->ops) {
  107. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  108. "%s: Invalid Instance", __func__);
  109. QDF_BUG(0);
  110. return;
  111. }
  112. if (!soc->ops->host_stats_ops ||
  113. !soc->ops->host_stats_ops->txrx_enable_enhanced_stats)
  114. return;
  115. soc->ops->host_stats_ops->txrx_enable_enhanced_stats
  116. (pdev);
  117. }
  118. /**
  119. * @brief Disable enhanced stats functionality.
  120. *
  121. * @param pdev - the physical device object
  122. * @return - void
  123. */
  124. static inline void
  125. cdp_disable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  126. {
  127. if (!soc || !soc->ops) {
  128. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  129. "%s: Invalid Instance", __func__);
  130. QDF_BUG(0);
  131. return;
  132. }
  133. if (!soc->ops->host_stats_ops ||
  134. !soc->ops->host_stats_ops->txrx_disable_enhanced_stats)
  135. return;
  136. soc->ops->host_stats_ops->txrx_disable_enhanced_stats
  137. (pdev);
  138. }
  139. /**
  140. * @brief Get the desired stats from the message.
  141. *
  142. * @param pdev - the physical device object
  143. * @param stats_base - stats buffer received from FW
  144. * @param type - stats type.
  145. * @return - pointer to requested stat identified by type
  146. */
  147. static inline uint32_t *cdp_get_stats_base
  148. (ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  149. uint32_t *stats_base, uint32_t msg_len, uint8_t type)
  150. {
  151. if (!soc || !soc->ops) {
  152. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  153. "%s: Invalid Instance", __func__);
  154. QDF_BUG(0);
  155. return 0;
  156. }
  157. if (!soc->ops->host_stats_ops ||
  158. !soc->ops->host_stats_ops->txrx_get_stats_base)
  159. return 0;
  160. return (uint32_t *)soc->ops->host_stats_ops->txrx_get_stats_base
  161. (pdev, stats_base, msg_len, type);
  162. }
  163. static inline void
  164. cdp_tx_print_tso_stats(ol_txrx_soc_handle soc,
  165. struct cdp_vdev *vdev)
  166. {
  167. if (!soc || !soc->ops) {
  168. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  169. "%s: Invalid Instance", __func__);
  170. QDF_BUG(0);
  171. return;
  172. }
  173. if (!soc->ops->host_stats_ops ||
  174. !soc->ops->host_stats_ops->tx_print_tso_stats)
  175. return;
  176. soc->ops->host_stats_ops->tx_print_tso_stats(vdev);
  177. }
  178. static inline void
  179. cdp_tx_rst_tso_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  180. {
  181. if (!soc || !soc->ops) {
  182. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  183. "%s: Invalid Instance", __func__);
  184. QDF_BUG(0);
  185. return;
  186. }
  187. if (!soc->ops->host_stats_ops ||
  188. !soc->ops->host_stats_ops->tx_rst_tso_stats)
  189. return;
  190. soc->ops->host_stats_ops->tx_rst_tso_stats(vdev);
  191. }
  192. static inline void
  193. cdp_tx_print_sg_stats(ol_txrx_soc_handle soc,
  194. struct cdp_vdev *vdev)
  195. {
  196. if (!soc || !soc->ops) {
  197. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  198. "%s: Invalid Instance", __func__);
  199. QDF_BUG(0);
  200. return;
  201. }
  202. if (!soc->ops->host_stats_ops ||
  203. !soc->ops->host_stats_ops->tx_print_sg_stats)
  204. return;
  205. soc->ops->host_stats_ops->tx_print_sg_stats(vdev);
  206. }
  207. static inline void
  208. cdp_tx_rst_sg_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  209. {
  210. if (!soc || !soc->ops) {
  211. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  212. "%s: Invalid Instance", __func__);
  213. QDF_BUG(0);
  214. return;
  215. }
  216. if (!soc->ops->host_stats_ops ||
  217. !soc->ops->host_stats_ops->tx_rst_sg_stats)
  218. return;
  219. soc->ops->host_stats_ops->tx_rst_sg_stats(vdev);
  220. }
  221. static inline void
  222. cdp_print_rx_cksum_stats(ol_txrx_soc_handle soc,
  223. struct cdp_vdev *vdev)
  224. {
  225. if (!soc || !soc->ops) {
  226. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  227. "%s: Invalid Instance", __func__);
  228. QDF_BUG(0);
  229. return;
  230. }
  231. if (!soc->ops->host_stats_ops ||
  232. !soc->ops->host_stats_ops->print_rx_cksum_stats)
  233. return;
  234. soc->ops->host_stats_ops->print_rx_cksum_stats(vdev);
  235. }
  236. static inline void
  237. cdp_rst_rx_cksum_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  238. {
  239. if (!soc || !soc->ops) {
  240. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  241. "%s: Invalid Instance", __func__);
  242. QDF_BUG(0);
  243. return;
  244. }
  245. if (!soc->ops->host_stats_ops ||
  246. !soc->ops->host_stats_ops->rst_rx_cksum_stats)
  247. return;
  248. soc->ops->host_stats_ops->rst_rx_cksum_stats(vdev);
  249. }
  250. static inline A_STATUS
  251. cdp_host_me_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  252. {
  253. if (!soc || !soc->ops) {
  254. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  255. "%s: Invalid Instance", __func__);
  256. QDF_BUG(0);
  257. return 0;
  258. }
  259. if (!soc->ops->host_stats_ops ||
  260. !soc->ops->host_stats_ops->txrx_host_me_stats)
  261. return 0;
  262. return soc->ops->host_stats_ops->txrx_host_me_stats(vdev);
  263. }
  264. /**
  265. * cdp_per_peer_stats(): function to print per peer REO Queue stats
  266. * @soc: soc handle
  267. * @pdev: physical device
  268. * @addr: peer address
  269. *
  270. * return: status
  271. */
  272. static inline void cdp_per_peer_stats(ol_txrx_soc_handle soc,
  273. struct cdp_pdev *pdev, char *addr)
  274. {
  275. if (!soc || !soc->ops) {
  276. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  277. "%s: Invalid Instance", __func__);
  278. QDF_BUG(0);
  279. return;
  280. }
  281. if (!soc->ops->host_stats_ops ||
  282. !soc->ops->host_stats_ops->txrx_per_peer_stats)
  283. return;
  284. soc->ops->host_stats_ops->txrx_per_peer_stats(pdev, addr);
  285. }
  286. static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc,
  287. struct cdp_vdev *vdev,
  288. struct ol_txrx_stats_req *req)
  289. {
  290. if (!soc || !soc->ops) {
  291. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  292. "%s: Invalid Instance", __func__);
  293. QDF_BUG(0);
  294. return 0;
  295. }
  296. if (!soc->ops->host_stats_ops ||
  297. !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats)
  298. return 0;
  299. return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats
  300. (vdev, req);
  301. }
  302. static inline void
  303. cdp_print_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  304. {
  305. if (!soc || !soc->ops) {
  306. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  307. "%s: Invalid Instance", __func__);
  308. QDF_BUG(0);
  309. return;
  310. }
  311. if (!soc->ops->host_stats_ops ||
  312. !soc->ops->host_stats_ops->print_lro_stats)
  313. return;
  314. soc->ops->host_stats_ops->print_lro_stats(vdev);
  315. }
  316. static inline void
  317. cdp_reset_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  318. {
  319. if (!soc || !soc->ops) {
  320. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  321. "%s: Invalid Instance", __func__);
  322. QDF_BUG(0);
  323. return;
  324. }
  325. if (!soc->ops->host_stats_ops ||
  326. !soc->ops->host_stats_ops->reset_lro_stats)
  327. return;
  328. soc->ops->host_stats_ops->reset_lro_stats(vdev);
  329. }
  330. static inline void cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc,
  331. struct cdp_pdev *pdev, uint8_t *mac, uint32_t caps)
  332. {
  333. if (!soc || !soc->ops) {
  334. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  335. "%s: Invalid Instance", __func__);
  336. QDF_BUG(0);
  337. return;
  338. }
  339. if (!soc->ops->host_stats_ops ||
  340. !soc->ops->host_stats_ops->get_fw_peer_stats)
  341. return;
  342. soc->ops->host_stats_ops->get_fw_peer_stats
  343. (pdev, mac, caps);
  344. }
  345. static inline void cdp_get_dp_htt_stats(ol_txrx_soc_handle soc,
  346. struct cdp_pdev *pdev,
  347. void *data, uint32_t data_len)
  348. {
  349. if (soc && soc->ops && soc->ops->host_stats_ops &&
  350. soc->ops->host_stats_ops->get_htt_stats)
  351. return soc->ops->host_stats_ops->get_htt_stats
  352. (pdev, data, data_len);
  353. return;
  354. }
  355. /**
  356. * @brief Update pdev host stats received from firmware
  357. * (wmi_host_pdev_stats and wmi_host_pdev_ext_stats) into dp
  358. *
  359. * @param pdev - the physical device object
  360. * @param data - pdev stats
  361. * @return - void
  362. */
  363. static inline void
  364. cdp_update_pdev_host_stats(ol_txrx_soc_handle soc,
  365. struct cdp_pdev *pdev,
  366. void *data,
  367. uint16_t stats_id)
  368. {
  369. if (soc && soc->ops && soc->ops->host_stats_ops &&
  370. soc->ops->host_stats_ops->txrx_update_pdev_stats)
  371. return soc->ops->host_stats_ops->txrx_update_pdev_stats
  372. (pdev, data, stats_id);
  373. }
  374. /**
  375. * @brief Call to get peer stats
  376. *
  377. * @param peer - dp peer object
  378. * @return - struct cdp_peer_stats
  379. */
  380. static inline struct cdp_peer_stats *
  381. cdp_host_get_peer_stats(ol_txrx_soc_handle soc, struct cdp_peer *peer)
  382. {
  383. if (!soc || !soc->ops) {
  384. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  385. "%s: Invalid Instance", __func__);
  386. QDF_BUG(0);
  387. return NULL;
  388. }
  389. if (!soc->ops->host_stats_ops ||
  390. !soc->ops->host_stats_ops->txrx_get_peer_stats)
  391. return NULL;
  392. return soc->ops->host_stats_ops->txrx_get_peer_stats(peer);
  393. }
  394. /**
  395. * @brief Call to reset ald stats
  396. *
  397. * @param peer - dp peer object
  398. * @return - void
  399. */
  400. static inline void
  401. cdp_host_reset_peer_ald_stats(ol_txrx_soc_handle soc,
  402. struct cdp_peer *peer)
  403. {
  404. if (!soc || !soc->ops) {
  405. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  406. "%s: Invalid Instance", __func__);
  407. QDF_BUG(0);
  408. return;
  409. }
  410. if (!soc->ops->host_stats_ops ||
  411. !soc->ops->host_stats_ops->txrx_reset_peer_ald_stats)
  412. return;
  413. return soc->ops->host_stats_ops->txrx_reset_peer_ald_stats(peer);
  414. }
  415. /**
  416. * @brief Call to reset peer stats
  417. *
  418. * @param peer - dp peer object
  419. * @return - void
  420. */
  421. static inline void
  422. cdp_host_reset_peer_stats(ol_txrx_soc_handle soc,
  423. struct cdp_peer *peer)
  424. {
  425. if (!soc || !soc->ops) {
  426. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  427. "%s: Invalid Instance", __func__);
  428. QDF_BUG(0);
  429. return;
  430. }
  431. if (!soc->ops->host_stats_ops ||
  432. !soc->ops->host_stats_ops->txrx_reset_peer_stats)
  433. return;
  434. return soc->ops->host_stats_ops->txrx_reset_peer_stats(peer);
  435. }
  436. /**
  437. * @brief Call to get vdev stats
  438. *
  439. * @param vdev - dp vdev object
  440. * @param buf - buffer
  441. * @return - int
  442. */
  443. static inline int
  444. cdp_host_get_vdev_stats(ol_txrx_soc_handle soc,
  445. struct cdp_vdev *vdev,
  446. struct cdp_vdev_stats *buf,
  447. bool is_aggregate)
  448. {
  449. if (!soc || !soc->ops) {
  450. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  451. "%s: Invalid Instance", __func__);
  452. QDF_BUG(0);
  453. return 0;
  454. }
  455. if (!soc->ops->host_stats_ops ||
  456. !soc->ops->host_stats_ops->txrx_get_vdev_stats)
  457. return 0;
  458. return soc->ops->host_stats_ops->txrx_get_vdev_stats(vdev,
  459. buf,
  460. is_aggregate);
  461. }
  462. /**
  463. * @brief Call to update vdev stats received from firmware
  464. * (wmi_host_vdev_stats and wmi_host_vdev_extd_stats) into dp
  465. *
  466. * @param data - stats data to be updated
  467. * @param size - size of stats data
  468. * @param stats_id - stats id
  469. * @return - int
  470. */
  471. static inline int
  472. cdp_update_host_vdev_stats(ol_txrx_soc_handle soc,
  473. void *data,
  474. uint32_t size,
  475. uint32_t stats_id)
  476. {
  477. if (!soc || !soc->ops) {
  478. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  479. "%s: Invalid Instance", __func__);
  480. QDF_BUG(0);
  481. return 0;
  482. }
  483. if (!soc->ops->host_stats_ops ||
  484. !soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats)
  485. return 0;
  486. return soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats
  487. (soc,
  488. data,
  489. size,
  490. stats_id);
  491. }
  492. /**
  493. * @brief Call to get vdev extd stats
  494. *
  495. * @param vdev - dp vdev object
  496. * @param buf - buffer
  497. * @return - int
  498. */
  499. static inline int
  500. cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc,
  501. struct cdp_vdev *vdev,
  502. void *buf)
  503. {
  504. if (!soc || !soc->ops) {
  505. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  506. "%s: Invalid Instance", __func__);
  507. QDF_BUG(0);
  508. return 0;
  509. }
  510. if (!soc->ops->host_stats_ops ||
  511. !soc->ops->host_stats_ops->txrx_get_vdev_extd_stats)
  512. return 0;
  513. return soc->ops->host_stats_ops->txrx_get_vdev_extd_stats(vdev, buf);
  514. }
  515. /**
  516. * @brief Parse the stats header and get the payload from the message.
  517. *
  518. * @param pdev - the physical device object
  519. * @param msg_word - stats buffer received from FW
  520. * @param msg_len - length of the message
  521. * @param type - place holder for parsed message type
  522. * @param status - place holder for parsed message status
  523. * @return - pointer to received stat payload
  524. */
  525. #if defined(QCA_SUPPORT_SON) || defined(ENHANCED_STATS)
  526. uint32_t *ol_txrx_get_en_stats_base(struct cdp_pdev *pdev, uint32_t *msg_word,
  527. uint32_t msg_len, enum htt_cmn_t2h_en_stats_type *type, enum htt_cmn_t2h_en_stats_status *status);
  528. #endif
  529. #endif /* _CDP_TXRX_HOST_STATS_H_ */