cdp_txrx_host_stats.h 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  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. * DOC: cdp_txrx_host_stats.h
  21. * 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. * cdp_enable_enhanced_stats() - Enable enhanced stats functionality.
  126. * @soc: the soc object
  127. * @pdev_id: id of the physical device object
  128. *
  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->mon_ops ||
  140. !soc->ops->mon_ops->txrx_enable_enhanced_stats)
  141. return QDF_STATUS_E_FAILURE;
  142. return soc->ops->mon_ops->txrx_enable_enhanced_stats
  143. (soc, pdev_id);
  144. }
  145. /**
  146. * cdp_disable_enhanced_stats() - Disable enhanced stats functionality.
  147. * @soc: the soc object
  148. * @pdev_id: id of the physical device object
  149. *
  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->mon_ops ||
  161. !soc->ops->mon_ops->txrx_disable_enhanced_stats)
  162. return QDF_STATUS_E_FAILURE;
  163. return soc->ops->mon_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. * @addr: peer address
  261. *
  262. * Return: status
  263. */
  264. static inline QDF_STATUS cdp_per_peer_stats(ol_txrx_soc_handle soc,
  265. uint8_t *addr)
  266. {
  267. if (!soc || !soc->ops) {
  268. dp_cdp_debug("Invalid Instance");
  269. QDF_BUG(0);
  270. return QDF_STATUS_E_FAILURE;
  271. }
  272. if (!soc->ops->host_stats_ops ||
  273. !soc->ops->host_stats_ops->txrx_per_peer_stats)
  274. return QDF_STATUS_E_FAILURE;
  275. return soc->ops->host_stats_ops->txrx_per_peer_stats(soc, addr);
  276. }
  277. static inline int cdp_host_msdu_ttl_stats(ol_txrx_soc_handle soc,
  278. uint8_t vdev_id,
  279. struct ol_txrx_stats_req *req)
  280. {
  281. if (!soc || !soc->ops) {
  282. dp_cdp_debug("Invalid Instance");
  283. QDF_BUG(0);
  284. return 0;
  285. }
  286. if (!soc->ops->host_stats_ops ||
  287. !soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats)
  288. return 0;
  289. return soc->ops->host_stats_ops->txrx_host_msdu_ttl_stats
  290. (soc, vdev_id, req);
  291. }
  292. static inline QDF_STATUS cdp_update_peer_stats(ol_txrx_soc_handle soc,
  293. uint8_t vdev_id, uint8_t *mac,
  294. void *stats,
  295. uint32_t last_tx_rate_mcs,
  296. uint32_t stats_id)
  297. {
  298. if (!soc || !soc->ops) {
  299. dp_cdp_debug("Invalid Instance");
  300. QDF_BUG(0);
  301. return QDF_STATUS_E_FAILURE;
  302. }
  303. if (!soc->ops->host_stats_ops ||
  304. !soc->ops->host_stats_ops->txrx_update_peer_stats)
  305. return QDF_STATUS_E_FAILURE;
  306. return soc->ops->host_stats_ops->txrx_update_peer_stats
  307. (soc, vdev_id, mac, stats, last_tx_rate_mcs, stats_id);
  308. }
  309. static inline QDF_STATUS cdp_get_dp_fw_peer_stats(ol_txrx_soc_handle soc,
  310. uint8_t pdev_id,
  311. uint8_t *mac, uint32_t caps,
  312. uint32_t copy_stats)
  313. {
  314. if (!soc || !soc->ops) {
  315. dp_cdp_debug("Invalid Instance");
  316. QDF_BUG(0);
  317. return QDF_STATUS_E_FAILURE;
  318. }
  319. if (!soc->ops->host_stats_ops ||
  320. !soc->ops->host_stats_ops->get_fw_peer_stats)
  321. return QDF_STATUS_E_FAILURE;
  322. return soc->ops->host_stats_ops->get_fw_peer_stats
  323. (soc, pdev_id, mac, caps, copy_stats);
  324. }
  325. static inline QDF_STATUS cdp_get_dp_htt_stats(ol_txrx_soc_handle soc,
  326. uint8_t pdev_id,
  327. void *data, uint32_t data_len)
  328. {
  329. if (!soc || !soc->ops) {
  330. dp_cdp_debug("Invalid Instance");
  331. QDF_BUG(0);
  332. return QDF_STATUS_E_FAILURE;
  333. }
  334. if (!soc->ops->host_stats_ops ||
  335. !soc->ops->host_stats_ops->get_htt_stats)
  336. return QDF_STATUS_E_FAILURE;
  337. return soc->ops->host_stats_ops->get_htt_stats(soc, pdev_id, data,
  338. data_len);
  339. }
  340. /**
  341. * cdp_update_pdev_host_stats() - Update pdev host stats received from firmware
  342. * (wmi_host_pdev_stats and wmi_host_pdev_ext_stats) into dp
  343. * @soc: soc handle
  344. * @pdev_id: id of the physical device object
  345. * @data: pdev stats
  346. * @stats_id: statistics to be updated
  347. *
  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. * cdp_update_vdev_host_stats() - Update vdev host stats
  370. * @soc: soc handle
  371. * @vdev_id: id of the virtual device object
  372. * @data: pdev stats
  373. * @stats_id: type of stats
  374. *
  375. * Return: QDF_STATUS
  376. */
  377. static inline QDF_STATUS
  378. cdp_update_vdev_host_stats(ol_txrx_soc_handle soc,
  379. uint8_t vdev_id,
  380. void *data,
  381. uint16_t stats_id)
  382. {
  383. if (!soc || !soc->ops) {
  384. dp_cdp_debug("Invalid Instance");
  385. QDF_BUG(0);
  386. return QDF_STATUS_E_FAILURE;
  387. }
  388. if (!soc->ops->host_stats_ops ||
  389. !soc->ops->host_stats_ops->txrx_update_vdev_stats)
  390. return QDF_STATUS_E_FAILURE;
  391. return soc->ops->host_stats_ops->txrx_update_vdev_stats(soc, vdev_id,
  392. data,
  393. stats_id);
  394. }
  395. /**
  396. * cdp_txrx_get_peer_stats_param() - Call to get specified peer stats
  397. * @soc: soc handle
  398. * @vdev_id: vdev_id of vdev object
  399. * @peer_mac: mac address of the peer
  400. * @type: enum of required stats
  401. * @buf: buffer to hold the value
  402. *
  403. * Return: QDF_STATUS
  404. */
  405. static inline QDF_STATUS
  406. cdp_txrx_get_peer_stats_param(ol_txrx_soc_handle soc, uint8_t vdev_id,
  407. uint8_t *peer_mac,
  408. enum cdp_peer_stats_type type,
  409. cdp_peer_stats_param_t *buf)
  410. {
  411. if (!soc || !soc->ops) {
  412. dp_cdp_debug("Invalid Instance");
  413. QDF_BUG(0);
  414. return QDF_STATUS_E_FAILURE;
  415. }
  416. if (!soc->ops->host_stats_ops ||
  417. !soc->ops->host_stats_ops->txrx_get_peer_stats_param)
  418. return QDF_STATUS_E_FAILURE;
  419. return soc->ops->host_stats_ops->txrx_get_peer_stats_param(soc,
  420. vdev_id,
  421. peer_mac,
  422. type,
  423. buf);
  424. }
  425. /**
  426. * cdp_host_get_soc_stats() - Call to get soc stats
  427. * @soc: soc handle
  428. * @soc_stats: buffer for cdp soc stats
  429. *
  430. * Return: QDF_STATUS
  431. */
  432. static inline QDF_STATUS
  433. cdp_host_get_soc_stats(ol_txrx_soc_handle soc, struct cdp_soc_stats *soc_stats)
  434. {
  435. if (!soc || !soc->ops) {
  436. dp_cdp_debug("Invalid Instance");
  437. QDF_BUG(0);
  438. return QDF_STATUS_E_FAILURE;
  439. }
  440. if (!soc->ops->host_stats_ops ||
  441. !soc->ops->host_stats_ops->txrx_get_soc_stats)
  442. return QDF_STATUS_E_FAILURE;
  443. return soc->ops->host_stats_ops->txrx_get_soc_stats(soc, soc_stats);
  444. }
  445. /**
  446. * cdp_host_get_peer_stats() - Call to get peer stats
  447. * @soc: soc handle
  448. * @vdev_id: vdev_id of vdev object
  449. * @peer_mac: mac address of the peer
  450. * @peer_stats: destination buffer
  451. *
  452. * Return: QDF_STATUS
  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. * cdp_host_reset_peer_ald_stats() - Call to reset ald stats
  473. * @soc: soc handle
  474. * @vdev_id: vdev_id of vdev object
  475. * @peer_mac: mac address of the peer
  476. *
  477. * Return: QDF_STATUS
  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. * cdp_host_reset_peer_stats() - Call to reset peer stats
  497. * @soc: soc handle
  498. * @vdev_id: vdev_id of vdev object
  499. * @peer_mac: mac address of the peer
  500. *
  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. * cdp_host_get_vdev_stats() - Call to get vdev stats
  521. * @soc: dp soc object
  522. * @vdev_id: id of dp vdev object
  523. * @buf: buffer
  524. * @is_aggregate:
  525. *
  526. * Return: int
  527. */
  528. static inline int
  529. cdp_host_get_vdev_stats(ol_txrx_soc_handle soc,
  530. uint8_t vdev_id,
  531. struct cdp_vdev_stats *buf,
  532. bool is_aggregate)
  533. {
  534. if (!soc || !soc->ops) {
  535. dp_cdp_debug("Invalid Instance");
  536. QDF_BUG(0);
  537. return 0;
  538. }
  539. if (!soc->ops->host_stats_ops ||
  540. !soc->ops->host_stats_ops->txrx_get_vdev_stats)
  541. return 0;
  542. return soc->ops->host_stats_ops->txrx_get_vdev_stats(soc, vdev_id,
  543. buf,
  544. is_aggregate);
  545. }
  546. /**
  547. * cdp_update_host_vdev_stats() - Call to update vdev stats received from
  548. * firmware (wmi_host_vdev_stats and wmi_host_vdev_extd_stats) into dp
  549. * @soc: soc handle
  550. * @data: stats data to be updated
  551. * @size: size of stats data
  552. * @stats_id: stats id
  553. *
  554. * Return: int
  555. */
  556. static inline int
  557. cdp_update_host_vdev_stats(ol_txrx_soc_handle soc,
  558. void *data,
  559. uint32_t size,
  560. uint32_t stats_id)
  561. {
  562. if (!soc || !soc->ops) {
  563. dp_cdp_debug("Invalid Instance");
  564. QDF_BUG(0);
  565. return 0;
  566. }
  567. if (!soc->ops->host_stats_ops ||
  568. !soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats)
  569. return 0;
  570. return soc->ops->host_stats_ops->txrx_process_wmi_host_vdev_stats
  571. (soc,
  572. data,
  573. size,
  574. stats_id);
  575. }
  576. /**
  577. * cdp_get_vdev_extd_stats() - Call to get vdev extd stats
  578. * @soc: soc handle
  579. * @vdev_id: id of dp vdev object
  580. * @buf: buffer
  581. *
  582. * Return: int
  583. */
  584. static inline int
  585. cdp_get_vdev_extd_stats(ol_txrx_soc_handle soc,
  586. uint8_t vdev_id,
  587. wmi_host_vdev_extd_stats *buf)
  588. {
  589. if (!soc || !soc->ops) {
  590. dp_cdp_debug("Invalid Instance");
  591. QDF_BUG(0);
  592. return 0;
  593. }
  594. if (!soc->ops->host_stats_ops ||
  595. !soc->ops->host_stats_ops->txrx_get_vdev_extd_stats)
  596. return 0;
  597. return soc->ops->host_stats_ops->txrx_get_vdev_extd_stats(soc, vdev_id,
  598. buf);
  599. }
  600. /**
  601. * cdp_host_get_pdev_stats() - Call to get cdp_pdev_stats
  602. * @soc: soc handle
  603. * @pdev_id: id of dp pdev object
  604. * @buf: buffer to hold cdp_pdev_stats
  605. *
  606. * Return: success/failure
  607. */
  608. static inline int
  609. cdp_host_get_pdev_stats(ol_txrx_soc_handle soc,
  610. uint8_t pdev_id, struct cdp_pdev_stats *buf)
  611. {
  612. if (!soc || !soc->ops) {
  613. dp_cdp_debug("Invalid Instance");
  614. QDF_BUG(0);
  615. return 0;
  616. }
  617. if (!soc->ops->host_stats_ops ||
  618. !soc->ops->host_stats_ops->txrx_get_pdev_stats)
  619. return 0;
  620. return soc->ops->host_stats_ops->txrx_get_pdev_stats(soc, pdev_id, buf);
  621. }
  622. /**
  623. * cdp_host_get_radio_stats() - Call to get radio stats
  624. * @soc: soc handle
  625. * @pdev_id: id of dp pdev object
  626. * @buf: stats buffer
  627. *
  628. * Return: int
  629. */
  630. static inline int
  631. cdp_host_get_radio_stats(ol_txrx_soc_handle soc,
  632. uint8_t pdev_id,
  633. void *buf)
  634. {
  635. if (!soc || !soc->ops) {
  636. dp_cdp_debug("Invalid Instance");
  637. QDF_BUG(0);
  638. return 0;
  639. }
  640. if (!soc->ops->host_stats_ops ||
  641. !soc->ops->host_stats_ops->txrx_get_radio_stats)
  642. return 0;
  643. return soc->ops->host_stats_ops->txrx_get_radio_stats(soc, pdev_id,
  644. buf);
  645. }
  646. #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS
  647. static inline int
  648. cdp_get_scan_spcl_vap_stats(ol_txrx_soc_handle soc,
  649. uint8_t vdev_id,
  650. struct cdp_scan_spcl_vap_stats *stats)
  651. {
  652. if (!soc || !soc->ops) {
  653. dp_cdp_debug("Invalid Instance");
  654. QDF_BUG(0);
  655. return QDF_STATUS_E_FAILURE;
  656. }
  657. if (!soc->ops->host_stats_ops ||
  658. !soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats)
  659. return QDF_STATUS_E_FAILURE;
  660. return soc->ops->host_stats_ops->txrx_get_scan_spcl_vap_stats(soc,
  661. vdev_id,
  662. stats);
  663. }
  664. #endif
  665. /**
  666. * cdp_get_peer_delay_stats() - Call to get per peer delay stats
  667. * @soc: soc handle
  668. * @vdev_id: id of dp_vdev handle
  669. * @peer_mac: peer mac address
  670. * @delay_stats: user allocated buffer for peer delay stats
  671. *
  672. * Return: status Success/Failure
  673. */
  674. static inline QDF_STATUS
  675. cdp_get_peer_delay_stats(ol_txrx_soc_handle soc,
  676. uint8_t vdev_id,
  677. uint8_t *peer_mac,
  678. struct cdp_delay_tid_stats *delay_stats)
  679. {
  680. if (!soc || !soc->ops) {
  681. dp_cdp_debug("Invalid Instance");
  682. QDF_BUG(0);
  683. return QDF_STATUS_E_FAILURE;
  684. }
  685. if (!soc->ops->host_stats_ops ||
  686. !soc->ops->host_stats_ops->txrx_get_peer_delay_stats)
  687. return QDF_STATUS_E_FAILURE;
  688. return soc->ops->host_stats_ops->txrx_get_peer_delay_stats(soc,
  689. vdev_id,
  690. peer_mac,
  691. delay_stats);
  692. }
  693. /**
  694. * cdp_get_peer_jitter_stats() - Call to get per peer jitter stats
  695. * @soc: soc handle
  696. * @pdev_id: id of dp_pdev handle
  697. * @vdev_id: id of dp_vdev handle
  698. * @peer_mac: peer mac address
  699. * @tid_stats: user allocated buffer for tid_stats
  700. *
  701. * Return: status Success/Failure
  702. */
  703. static inline QDF_STATUS
  704. cdp_get_peer_jitter_stats(ol_txrx_soc_handle soc,
  705. uint8_t pdev_id,
  706. uint8_t vdev_id,
  707. uint8_t *peer_mac,
  708. struct cdp_peer_tid_stats *tid_stats)
  709. {
  710. if (!soc || !soc->ops) {
  711. dp_cdp_debug("Invalid Instance");
  712. QDF_BUG(0);
  713. return QDF_STATUS_E_FAILURE;
  714. }
  715. if (!soc->ops->host_stats_ops ||
  716. !soc->ops->host_stats_ops->txrx_get_peer_jitter_stats)
  717. return QDF_STATUS_E_FAILURE;
  718. return soc->ops->host_stats_ops->txrx_get_peer_jitter_stats(soc,
  719. pdev_id,
  720. vdev_id,
  721. peer_mac,
  722. tid_stats);
  723. }
  724. /**
  725. * cdp_mon_pdev_get_rx_stats() - Call to get monitor pdev rx stats
  726. * @soc: soc handle
  727. * @pdev_id: id of dp_pdev handle
  728. * @stats: user allocated buffer for dp pdev mon stats
  729. *
  730. * Return: status Success/Failure
  731. */
  732. static inline QDF_STATUS
  733. cdp_mon_pdev_get_rx_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
  734. struct cdp_pdev_mon_stats *stats)
  735. {
  736. if (!soc || !soc->ops) {
  737. dp_cdp_debug("Invalid Instance");
  738. QDF_BUG(0);
  739. return QDF_STATUS_E_FAILURE;
  740. }
  741. if (!soc->ops->mon_ops ||
  742. !soc->ops->mon_ops->get_mon_pdev_rx_stats)
  743. return QDF_STATUS_E_FAILURE;
  744. return soc->ops->mon_ops->get_mon_pdev_rx_stats(soc, pdev_id, stats);
  745. }
  746. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  747. /**
  748. * cdp_get_peer_tx_capture_stats() - Call to get peer tx capture stats
  749. * @soc: soc handle
  750. * @vdev_id: id of dp_vdev handle
  751. * @peer_mac: peer mac address
  752. * @stats: pointer to peer tx capture stats
  753. *
  754. * Return: status Success/Failure
  755. */
  756. static inline QDF_STATUS
  757. cdp_get_peer_tx_capture_stats(ol_txrx_soc_handle soc,
  758. uint8_t vdev_id,
  759. uint8_t *peer_mac,
  760. struct cdp_peer_tx_capture_stats *stats)
  761. {
  762. if (!soc || !soc->ops) {
  763. dp_cdp_debug("Invalid Instance");
  764. QDF_BUG(0);
  765. return QDF_STATUS_E_FAILURE;
  766. }
  767. if (!soc->ops->host_stats_ops ||
  768. !soc->ops->host_stats_ops->get_peer_tx_capture_stats)
  769. return QDF_STATUS_E_FAILURE;
  770. return soc->ops->host_stats_ops->get_peer_tx_capture_stats(soc, vdev_id,
  771. peer_mac,
  772. stats);
  773. }
  774. /**
  775. * cdp_get_pdev_tx_capture_stats() - Call to get pdev tx capture stats
  776. * @soc: soc handle
  777. * @pdev_id: id of dp_pdev handle
  778. * @stats: pointer to pdev tx capture stats
  779. *
  780. * Return: status Success/Failure
  781. */
  782. static inline QDF_STATUS
  783. cdp_get_pdev_tx_capture_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
  784. struct cdp_pdev_tx_capture_stats *stats)
  785. {
  786. if (!soc || !soc->ops) {
  787. dp_cdp_debug("Invalid Instance");
  788. QDF_BUG(0);
  789. return QDF_STATUS_E_FAILURE;
  790. }
  791. if (!soc->ops->host_stats_ops ||
  792. !soc->ops->host_stats_ops->get_pdev_tx_capture_stats)
  793. return QDF_STATUS_E_FAILURE;
  794. return soc->ops->host_stats_ops->get_pdev_tx_capture_stats(soc, pdev_id,
  795. stats);
  796. }
  797. #endif /* WLAN_TX_PKT_CAPTURE_ENH */
  798. #ifdef HW_TX_DELAY_STATS_ENABLE
  799. /**
  800. * cdp_enable_disable_vdev_tx_delay_stats() - Start/Stop tx delay stats capture
  801. * @soc: soc handle
  802. * @vdev_id: vdev id
  803. * @value: value to be set
  804. *
  805. * Return: None
  806. */
  807. static inline void
  808. cdp_enable_disable_vdev_tx_delay_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
  809. uint8_t value)
  810. {
  811. if (!soc || !soc->ops) {
  812. dp_cdp_debug("Invalid Instance");
  813. return;
  814. }
  815. if (!soc->ops->host_stats_ops ||
  816. !soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats)
  817. return;
  818. soc->ops->host_stats_ops->enable_disable_vdev_tx_delay_stats(soc,
  819. vdev_id,
  820. value);
  821. }
  822. /**
  823. * cdp_vdev_is_tx_delay_stats_enabled() - Check if the Tx delay stats
  824. * is enabled or not for the given vdev_id
  825. * @soc: soc handle
  826. * @vdev_id: vdev_id
  827. *
  828. * Return: 1 if enabled, 0 if disabled
  829. */
  830. static inline uint8_t
  831. cdp_vdev_is_tx_delay_stats_enabled(ol_txrx_soc_handle soc, uint8_t vdev_id)
  832. {
  833. if (!soc || !soc->ops || !soc->ops->host_stats_ops) {
  834. dp_cdp_debug("Invalid Instance:");
  835. return 0;
  836. }
  837. if (soc->ops->host_stats_ops->is_tx_delay_stats_enabled)
  838. return soc->ops->host_stats_ops->is_tx_delay_stats_enabled(soc,
  839. vdev_id);
  840. return 0;
  841. }
  842. #endif
  843. /**
  844. * cdp_get_pdev_tid_stats() - Get pdev tid stats
  845. * @soc: soc handle
  846. * @pdev_id: Pdev id
  847. * @tid_stats: Pointer to cdp_tid_stats_intf
  848. *
  849. * Return: status Success/Failure
  850. */
  851. static inline QDF_STATUS
  852. cdp_get_pdev_tid_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
  853. struct cdp_tid_stats_intf *tid_stats)
  854. {
  855. if (!soc || !soc->ops || !soc->ops->host_stats_ops) {
  856. dp_cdp_debug("Invalid Instance:");
  857. return QDF_STATUS_E_FAILURE;
  858. }
  859. if (!soc->ops->host_stats_ops->txrx_get_pdev_tid_stats)
  860. return QDF_STATUS_E_FAILURE;
  861. return soc->ops->host_stats_ops->txrx_get_pdev_tid_stats(soc, pdev_id,
  862. tid_stats);
  863. }
  864. #ifdef WLAN_TELEMETRY_STATS_SUPPORT
  865. /**
  866. * cdp_get_pdev_telemetry_stats() - function to get pdev telemetry stats
  867. * @soc: soc handle
  868. * @pdev_id: pdev id
  869. * @stats: pointer to pdev telemetry stats
  870. *
  871. * Return: status
  872. */
  873. static inline QDF_STATUS cdp_get_pdev_telemetry_stats(
  874. ol_txrx_soc_handle soc,
  875. uint8_t pdev_id,
  876. struct cdp_pdev_telemetry_stats *stats)
  877. {
  878. if (!soc || !soc->ops) {
  879. dp_cdp_debug("Invalid Instance");
  880. QDF_BUG(0);
  881. return QDF_STATUS_E_FAILURE;
  882. }
  883. if (!soc->ops->host_stats_ops ||
  884. !soc->ops->host_stats_ops->txrx_pdev_telemetry_stats)
  885. return QDF_STATUS_E_FAILURE;
  886. return soc->ops->host_stats_ops->txrx_pdev_telemetry_stats(
  887. soc, pdev_id, stats);
  888. }
  889. /**
  890. * cdp_get_peer_telemetry_stats() - function to get peer telemetry stats
  891. * @soc: soc handle
  892. * @addr: peer address
  893. * @stats: pointer to peer telemetry stats
  894. *
  895. * Return: status
  896. */
  897. static inline QDF_STATUS cdp_get_peer_telemetry_stats(
  898. ol_txrx_soc_handle soc,
  899. uint8_t *addr,
  900. struct cdp_peer_telemetry_stats *stats)
  901. {
  902. if (!soc || !soc->ops) {
  903. dp_cdp_debug("Invalid Instance");
  904. QDF_BUG(0);
  905. return QDF_STATUS_E_FAILURE;
  906. }
  907. if (!soc->ops->host_stats_ops ||
  908. !soc->ops->host_stats_ops->txrx_peer_telemetry_stats)
  909. return QDF_STATUS_E_FAILURE;
  910. return soc->ops->host_stats_ops->txrx_peer_telemetry_stats(
  911. soc, addr, stats);
  912. }
  913. /**
  914. * cdp_get_pdev_deter_stats(): function to get pdev deterministic stats
  915. * @soc: soc handle
  916. * @pdev_id: pdev id
  917. * @stats: pointer to pdev deterministic stats
  918. *
  919. * return: status
  920. */
  921. static inline QDF_STATUS cdp_get_pdev_deter_stats(
  922. ol_txrx_soc_handle soc,
  923. uint8_t pdev_id,
  924. struct cdp_pdev_deter_stats *stats)
  925. {
  926. if (!soc || !soc->ops) {
  927. dp_cdp_debug("Invalid Instance");
  928. QDF_BUG(0);
  929. return QDF_STATUS_E_FAILURE;
  930. }
  931. if (!soc->ops->host_stats_ops ||
  932. !soc->ops->host_stats_ops->txrx_pdev_deter_stats)
  933. return QDF_STATUS_E_FAILURE;
  934. return soc->ops->host_stats_ops->txrx_pdev_deter_stats(
  935. soc, pdev_id, stats);
  936. }
  937. /**
  938. * cdp_get_peer_deter_stats(): function to get peer deterministic stats
  939. * @soc: soc handle
  940. * @vdev_id: id of vdev handle
  941. * @addr: peer address
  942. * @stats: pointer to peer telemetry stats
  943. *
  944. * return: status
  945. */
  946. static inline QDF_STATUS cdp_get_peer_deter_stats(
  947. ol_txrx_soc_handle soc,
  948. uint8_t vdev_id,
  949. uint8_t *addr,
  950. struct cdp_peer_deter_stats *stats)
  951. {
  952. if (!soc || !soc->ops) {
  953. dp_cdp_debug("Invalid Instance");
  954. QDF_BUG(0);
  955. return QDF_STATUS_E_FAILURE;
  956. }
  957. if (!soc->ops->host_stats_ops ||
  958. !soc->ops->host_stats_ops->txrx_peer_deter_stats)
  959. return QDF_STATUS_E_FAILURE;
  960. return soc->ops->host_stats_ops->txrx_peer_deter_stats(
  961. soc, vdev_id, addr, stats);
  962. }
  963. /**
  964. * cdp_update_pdev_chan_util_stats(): function to update pdev channel util stats
  965. * @soc: soc handle
  966. * @pdev_id: pdev id
  967. * @ch_util: pointer to pdev ch util stats
  968. *
  969. * return: status
  970. */
  971. static inline QDF_STATUS cdp_update_pdev_chan_util_stats(
  972. ol_txrx_soc_handle soc,
  973. uint8_t pdev_id,
  974. struct cdp_pdev_chan_util_stats *ch_util)
  975. {
  976. if (!soc || !soc->ops) {
  977. dp_cdp_debug("Invalid Instance");
  978. QDF_BUG(0);
  979. return QDF_STATUS_E_FAILURE;
  980. }
  981. if (!soc->ops->host_stats_ops ||
  982. !soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats)
  983. return QDF_STATUS_E_FAILURE;
  984. return soc->ops->host_stats_ops->txrx_update_pdev_chan_util_stats(
  985. soc, pdev_id, ch_util);
  986. }
  987. #endif
  988. /**
  989. * cdp_get_peer_extd_rate_link_stats() - cdp function to get peer
  990. * extended rate and link stats
  991. * @soc: soc handle
  992. * @mac_addr: mac address
  993. *
  994. * Return: status
  995. */
  996. static inline QDF_STATUS cdp_get_peer_extd_rate_link_stats(
  997. ol_txrx_soc_handle soc,
  998. uint8_t *mac_addr)
  999. {
  1000. if (!soc || !soc->ops) {
  1001. dp_cdp_debug("Invalid Instance");
  1002. QDF_BUG(0);
  1003. return QDF_STATUS_E_FAILURE;
  1004. }
  1005. if (!soc->ops->host_stats_ops ||
  1006. !soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats)
  1007. return QDF_STATUS_E_FAILURE;
  1008. return soc->ops->host_stats_ops->txrx_get_peer_extd_rate_link_stats(
  1009. soc, mac_addr);
  1010. }
  1011. /**
  1012. * cdp_get_pdev_obss_pd_stats() - function to get pdev obss stats
  1013. * @soc: soc handle
  1014. * @pdev_id: pdev id
  1015. * @stats: pointer to pdev obss stats
  1016. * @req: Pointer to CDP TxRx stats
  1017. *
  1018. * Return: status
  1019. */
  1020. static inline QDF_STATUS cdp_get_pdev_obss_pd_stats(
  1021. ol_txrx_soc_handle soc,
  1022. uint8_t pdev_id,
  1023. struct cdp_pdev_obss_pd_stats_tlv *stats,
  1024. struct cdp_txrx_stats_req *req)
  1025. {
  1026. if (!soc || !soc->ops) {
  1027. dp_cdp_debug("Invalid Instance");
  1028. QDF_BUG(0);
  1029. return QDF_STATUS_E_FAILURE;
  1030. }
  1031. if (!soc->ops->host_stats_ops ||
  1032. !soc->ops->host_stats_ops->get_pdev_obss_stats)
  1033. return QDF_STATUS_E_FAILURE;
  1034. return soc->ops->host_stats_ops->get_pdev_obss_stats(
  1035. soc, pdev_id, stats, req);
  1036. }
  1037. /**
  1038. * cdp_clear_pdev_obss_pd_stats() - function to clear pdev obss stats
  1039. * @soc: soc handle
  1040. * @pdev_id: pdev id
  1041. * @req: Pointer to CDP TxRx stats request. mac_id will be pre-filled
  1042. * and should not be overwritten
  1043. *
  1044. * Return: status
  1045. */
  1046. static inline QDF_STATUS cdp_clear_pdev_obss_pd_stats(
  1047. ol_txrx_soc_handle soc,
  1048. uint8_t pdev_id, struct cdp_txrx_stats_req *req)
  1049. {
  1050. if (!soc || !soc->ops) {
  1051. dp_cdp_debug("Invalid Instance");
  1052. QDF_BUG(0);
  1053. return QDF_STATUS_E_FAILURE;
  1054. }
  1055. if (!soc->ops->host_stats_ops ||
  1056. !soc->ops->host_stats_ops->clear_pdev_obss_pd_stats)
  1057. return QDF_STATUS_E_FAILURE;
  1058. return soc->ops->host_stats_ops->clear_pdev_obss_pd_stats(
  1059. soc, pdev_id, req);
  1060. }
  1061. #endif /* _CDP_TXRX_HOST_STATS_H_ */