cdp_txrx_host_stats.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. /*
  2. * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * @file cdp_txrx_host_stats.h
  28. * @brief Define the host data path stats API functions
  29. * called by the host control SW and the OS interface module
  30. */
  31. #ifndef _CDP_TXRX_HOST_STATS_H_
  32. #define _CDP_TXRX_HOST_STATS_H_
  33. #include "cdp_txrx_handle.h"
  34. /**
  35. * cdp_host_stats_get: cdp call to get host stats
  36. * @soc: SOC handle
  37. * @req: Requirement type
  38. *
  39. * return: 0 for Success, Failure returns error message
  40. */
  41. static inline int cdp_host_stats_get(ol_txrx_soc_handle soc,
  42. struct cdp_vdev *vdev,
  43. struct ol_txrx_stats_req *req)
  44. {
  45. if (!soc || !soc->ops) {
  46. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  47. "%s: Invalid Instance", __func__);
  48. QDF_BUG(0);
  49. return 0;
  50. }
  51. if (!soc->ops->host_stats_ops ||
  52. !soc->ops->host_stats_ops->txrx_host_stats_get)
  53. return 0;
  54. return soc->ops->host_stats_ops->txrx_host_stats_get(vdev, req);
  55. }
  56. /**
  57. * cdp_host_stats_clr: cdp call to clear host stats
  58. * @vdev: vdev handle
  59. *
  60. * return: void
  61. */
  62. static inline void
  63. cdp_host_stats_clr(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  64. {
  65. if (!soc || !soc->ops) {
  66. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  67. "%s: Invalid Instance", __func__);
  68. QDF_BUG(0);
  69. return;
  70. }
  71. if (!soc->ops->host_stats_ops ||
  72. !soc->ops->host_stats_ops->txrx_host_stats_clr)
  73. return;
  74. soc->ops->host_stats_ops->txrx_host_stats_clr(vdev);
  75. }
  76. static inline void
  77. cdp_host_ce_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  78. {
  79. if (!soc || !soc->ops) {
  80. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  81. "%s: Invalid Instance", __func__);
  82. QDF_BUG(0);
  83. return;
  84. }
  85. if (!soc->ops->host_stats_ops ||
  86. !soc->ops->host_stats_ops->txrx_host_ce_stats)
  87. return;
  88. soc->ops->host_stats_ops->txrx_host_ce_stats(vdev);
  89. }
  90. static inline int cdp_stats_publish
  91. (ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  92. struct ol_txrx_stats *buf)
  93. {
  94. if (!soc || !soc->ops) {
  95. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  96. "%s: Invalid Instance", __func__);
  97. QDF_BUG(0);
  98. return 0;
  99. }
  100. if (!soc->ops->host_stats_ops ||
  101. !soc->ops->host_stats_ops->txrx_stats_publish)
  102. return 0;
  103. return soc->ops->host_stats_ops->txrx_stats_publish(pdev, buf);
  104. }
  105. /**
  106. * @brief Enable enhanced stats functionality.
  107. *
  108. * @param pdev - the physical device object
  109. * @return - void
  110. */
  111. static inline void
  112. cdp_enable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  113. {
  114. if (!soc || !soc->ops) {
  115. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  116. "%s: Invalid Instance", __func__);
  117. QDF_BUG(0);
  118. return;
  119. }
  120. if (!soc->ops->host_stats_ops ||
  121. !soc->ops->host_stats_ops->txrx_enable_enhanced_stats)
  122. return;
  123. soc->ops->host_stats_ops->txrx_enable_enhanced_stats
  124. (pdev);
  125. }
  126. /**
  127. * @brief Disable enhanced stats functionality.
  128. *
  129. * @param pdev - the physical device object
  130. * @return - void
  131. */
  132. static inline void
  133. cdp_disable_enhanced_stats(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
  134. {
  135. if (!soc || !soc->ops) {
  136. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  137. "%s: Invalid Instance", __func__);
  138. QDF_BUG(0);
  139. return;
  140. }
  141. if (!soc->ops->host_stats_ops ||
  142. !soc->ops->host_stats_ops->txrx_disable_enhanced_stats)
  143. return;
  144. soc->ops->host_stats_ops->txrx_disable_enhanced_stats
  145. (pdev);
  146. }
  147. /**
  148. * @brief Get the desired stats from the message.
  149. *
  150. * @param pdev - the physical device object
  151. * @param stats_base - stats buffer recieved from FW
  152. * @param type - stats type.
  153. * @return - pointer to requested stat identified by type
  154. */
  155. static inline uint32_t *cdp_get_stats_base
  156. (ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  157. uint32_t *stats_base, uint32_t msg_len, uint8_t type)
  158. {
  159. if (!soc || !soc->ops) {
  160. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  161. "%s: Invalid Instance", __func__);
  162. QDF_BUG(0);
  163. return 0;
  164. }
  165. if (!soc->ops->host_stats_ops ||
  166. !soc->ops->host_stats_ops->txrx_get_stats_base)
  167. return 0;
  168. return (uint32_t *)soc->ops->host_stats_ops->txrx_get_stats_base
  169. (pdev, stats_base, msg_len, type);
  170. }
  171. static inline void
  172. cdp_tx_print_tso_stats(ol_txrx_soc_handle soc,
  173. struct cdp_vdev *vdev)
  174. {
  175. if (!soc || !soc->ops) {
  176. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  177. "%s: Invalid Instance", __func__);
  178. QDF_BUG(0);
  179. return;
  180. }
  181. if (!soc->ops->host_stats_ops ||
  182. !soc->ops->host_stats_ops->tx_print_tso_stats)
  183. return;
  184. soc->ops->host_stats_ops->tx_print_tso_stats(vdev);
  185. }
  186. static inline void
  187. cdp_tx_rst_tso_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  188. {
  189. if (!soc || !soc->ops) {
  190. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  191. "%s: Invalid Instance", __func__);
  192. QDF_BUG(0);
  193. return;
  194. }
  195. if (!soc->ops->host_stats_ops ||
  196. !soc->ops->host_stats_ops->tx_rst_tso_stats)
  197. return;
  198. soc->ops->host_stats_ops->tx_rst_tso_stats(vdev);
  199. }
  200. static inline void
  201. cdp_tx_print_sg_stats(ol_txrx_soc_handle soc,
  202. struct cdp_vdev *vdev)
  203. {
  204. if (!soc || !soc->ops) {
  205. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  206. "%s: Invalid Instance", __func__);
  207. QDF_BUG(0);
  208. return;
  209. }
  210. if (!soc->ops->host_stats_ops ||
  211. !soc->ops->host_stats_ops->tx_print_sg_stats)
  212. return;
  213. soc->ops->host_stats_ops->tx_print_sg_stats(vdev);
  214. }
  215. static inline void
  216. cdp_tx_rst_sg_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  217. {
  218. if (!soc || !soc->ops) {
  219. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  220. "%s: Invalid Instance", __func__);
  221. QDF_BUG(0);
  222. return;
  223. }
  224. if (!soc->ops->host_stats_ops ||
  225. !soc->ops->host_stats_ops->tx_rst_sg_stats)
  226. return;
  227. soc->ops->host_stats_ops->tx_rst_sg_stats(vdev);
  228. }
  229. static inline void
  230. cdp_print_rx_cksum_stats(ol_txrx_soc_handle soc,
  231. struct cdp_vdev *vdev)
  232. {
  233. if (!soc || !soc->ops) {
  234. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  235. "%s: Invalid Instance", __func__);
  236. QDF_BUG(0);
  237. return;
  238. }
  239. if (!soc->ops->host_stats_ops ||
  240. !soc->ops->host_stats_ops->print_rx_cksum_stats)
  241. return;
  242. soc->ops->host_stats_ops->print_rx_cksum_stats(vdev);
  243. }
  244. static inline void
  245. cdp_rst_rx_cksum_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  246. {
  247. if (!soc || !soc->ops) {
  248. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  249. "%s: Invalid Instance", __func__);
  250. QDF_BUG(0);
  251. return;
  252. }
  253. if (!soc->ops->host_stats_ops ||
  254. !soc->ops->host_stats_ops->rst_rx_cksum_stats)
  255. return;
  256. soc->ops->host_stats_ops->rst_rx_cksum_stats(vdev);
  257. }
  258. static inline A_STATUS
  259. cdp_host_me_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  260. {
  261. if (!soc || !soc->ops) {
  262. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  263. "%s: Invalid Instance", __func__);
  264. QDF_BUG(0);
  265. return 0;
  266. }
  267. if (!soc->ops->host_stats_ops ||
  268. !soc->ops->host_stats_ops->txrx_host_me_stats)
  269. return 0;
  270. return soc->ops->host_stats_ops->txrx_host_me_stats(vdev);
  271. }
  272. static inline void cdp_per_peer_stats
  273. (ol_txrx_soc_handle soc, 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
  285. (pdev, addr);
  286. }
  287. static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc,
  288. struct cdp_vdev *vdev,
  289. struct ol_txrx_stats_req *req)
  290. {
  291. if (!soc || !soc->ops) {
  292. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  293. "%s: Invalid Instance", __func__);
  294. QDF_BUG(0);
  295. return 0;
  296. }
  297. if (!soc->ops->host_stats_ops ||
  298. !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats)
  299. return 0;
  300. return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats
  301. (vdev, req);
  302. }
  303. static inline void
  304. cdp_print_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  305. {
  306. if (!soc || !soc->ops) {
  307. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  308. "%s: Invalid Instance", __func__);
  309. QDF_BUG(0);
  310. return;
  311. }
  312. if (!soc->ops->host_stats_ops ||
  313. !soc->ops->host_stats_ops->print_lro_stats)
  314. return;
  315. soc->ops->host_stats_ops->print_lro_stats(vdev);
  316. }
  317. static inline void
  318. cdp_reset_lro_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  319. {
  320. if (!soc || !soc->ops) {
  321. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  322. "%s: Invalid Instance", __func__);
  323. QDF_BUG(0);
  324. return;
  325. }
  326. if (!soc->ops->host_stats_ops ||
  327. !soc->ops->host_stats_ops->reset_lro_stats)
  328. return;
  329. soc->ops->host_stats_ops->reset_lro_stats(vdev);
  330. }
  331. static inline void cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc,
  332. struct cdp_pdev *pdev, uint8_t *mac, uint32_t caps)
  333. {
  334. if (!soc || !soc->ops) {
  335. QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
  336. "%s: Invalid Instance", __func__);
  337. QDF_BUG(0);
  338. return;
  339. }
  340. if (!soc->ops->host_stats_ops ||
  341. !soc->ops->host_stats_ops->get_fw_peer_stats)
  342. return;
  343. soc->ops->host_stats_ops->get_fw_peer_stats
  344. (pdev, mac, caps);
  345. }
  346. static inline void cdp_get_dp_htt_stats(ol_txrx_soc_handle soc,
  347. struct cdp_pdev *pdev,
  348. void *data, uint32_t data_len)
  349. {
  350. if (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 Parse the stats header and get the payload from the message.
  357. *
  358. * @param pdev - the physical device object
  359. * @param msg_word - stats buffer recieved from FW
  360. * @param msg_len - length of the message
  361. * @param type - place holder for parsed message type
  362. * @param status - place holder for parsed message status
  363. * @return - pointer to received stat payload
  364. */
  365. #if defined(QCA_SUPPORT_SON) || defined(ENHANCED_STATS)
  366. uint32_t *ol_txrx_get_en_stats_base(ol_txrx_pdev_handle txrx_pdev, uint32_t *msg_word,
  367. uint32_t msg_len, enum htt_cmn_t2h_en_stats_type *type, enum htt_cmn_t2h_en_stats_status *status);
  368. #endif
  369. #endif /* _CDP_TXRX_HOST_STATS_H_ */