cdp_txrx_sawf.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. /*
  2. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. 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. #ifndef _CDP_TXRX_SAWF_H_
  19. #define _CDP_TXRX_SAWF_H_
  20. #include <cdp_txrx_cmn_struct.h>
  21. #include <cdp_txrx_cmn.h>
  22. static inline QDF_STATUS
  23. cdp_sawf_peer_svcid_map(ol_txrx_soc_handle soc,
  24. uint8_t *mac, uint8_t svc_id)
  25. {
  26. if (!soc || !soc->ops) {
  27. dp_cdp_debug("Invalid Instance");
  28. QDF_BUG(0);
  29. return QDF_STATUS_E_FAILURE;
  30. }
  31. if (!soc->ops->sawf_ops ||
  32. !soc->ops->sawf_ops->sawf_def_queues_map_req) {
  33. return QDF_STATUS_E_FAILURE;
  34. }
  35. return soc->ops->sawf_ops->sawf_def_queues_map_req(soc, mac, svc_id);
  36. }
  37. static inline QDF_STATUS
  38. cdp_sawf_peer_unmap(ol_txrx_soc_handle soc,
  39. uint8_t *mac, uint8_t svc_id)
  40. {
  41. if (!soc || !soc->ops) {
  42. dp_cdp_debug("Invalid Instance");
  43. QDF_BUG(0);
  44. return QDF_STATUS_E_FAILURE;
  45. }
  46. if (!soc->ops->sawf_ops ||
  47. !soc->ops->sawf_ops->sawf_def_queues_unmap_req) {
  48. return QDF_STATUS_E_FAILURE;
  49. }
  50. return soc->ops->sawf_ops->sawf_def_queues_unmap_req(soc, mac, svc_id);
  51. }
  52. static inline QDF_STATUS
  53. cdp_sawf_peer_get_map_conf(ol_txrx_soc_handle soc,
  54. uint8_t *mac)
  55. {
  56. if (!soc || !soc->ops) {
  57. dp_cdp_debug("Invalid Instance");
  58. QDF_BUG(0);
  59. return QDF_STATUS_E_FAILURE;
  60. }
  61. if (!soc->ops->sawf_ops ||
  62. !soc->ops->sawf_ops->sawf_def_queues_get_map_report) {
  63. return QDF_STATUS_E_FAILURE;
  64. }
  65. return soc->ops->sawf_ops->sawf_def_queues_get_map_report(soc, mac);
  66. }
  67. #ifdef CONFIG_SAWF
  68. /**
  69. * cdp_get_peer_sawf_delay_stats() - Call to get SAWF delay stats
  70. * @soc: soc handle
  71. * @svc_id: service class ID
  72. * @mac: peer mac address
  73. * @data: opaque pointer
  74. *
  75. * return: status Success/Failure
  76. */
  77. static inline QDF_STATUS
  78. cdp_get_peer_sawf_delay_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
  79. uint8_t *mac, void *data)
  80. {
  81. if (!soc || !soc->ops) {
  82. dp_cdp_debug("Invalid Instance");
  83. QDF_BUG(0);
  84. return QDF_STATUS_E_FAILURE;
  85. }
  86. if (!soc->ops->sawf_ops ||
  87. !soc->ops->sawf_ops->txrx_get_peer_sawf_delay_stats)
  88. return QDF_STATUS_E_FAILURE;
  89. return soc->ops->sawf_ops->txrx_get_peer_sawf_delay_stats(soc, svc_id,
  90. mac, data);
  91. }
  92. /**
  93. * cdp_get_peer_sawf_tx_stats() - Call to get SAWF Tx stats
  94. * @soc: soc handle
  95. * @svc_id: service class ID
  96. * @mac: peer mac address
  97. * @data: opaque pointer
  98. *
  99. * return: status Success/Failure
  100. */
  101. static inline QDF_STATUS
  102. cdp_get_peer_sawf_tx_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
  103. uint8_t *mac, void *data)
  104. {
  105. if (!soc || !soc->ops) {
  106. dp_cdp_debug("Invalid Instance");
  107. QDF_BUG(0);
  108. return QDF_STATUS_E_FAILURE;
  109. }
  110. if (!soc->ops->sawf_ops ||
  111. !soc->ops->sawf_ops->txrx_get_peer_sawf_tx_stats)
  112. return QDF_STATUS_E_FAILURE;
  113. return soc->ops->sawf_ops->txrx_get_peer_sawf_tx_stats(soc, svc_id,
  114. mac, data);
  115. }
  116. /**
  117. * cdp_sawf_mpdu_stats_req() - Call to subscribe to MPDU stats TLV
  118. * @soc: soc handle
  119. * @enable: 1: enable 0: disable
  120. *
  121. * return: status Success/Failure
  122. */
  123. static inline QDF_STATUS
  124. cdp_sawf_mpdu_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
  125. {
  126. if (!soc || !soc->ops) {
  127. dp_cdp_debug("Invalid Instance");
  128. QDF_BUG(0);
  129. return QDF_STATUS_E_FAILURE;
  130. }
  131. if (!soc->ops->sawf_ops ||
  132. !soc->ops->sawf_ops->sawf_mpdu_stats_req)
  133. return QDF_STATUS_E_FAILURE;
  134. return soc->ops->sawf_ops->sawf_mpdu_stats_req(soc, enable);
  135. }
  136. /**
  137. * cdp_sawf_mpdu_details_stats_req - Call to subscribe to MPDU details stats TLV
  138. * @soc: soc handle
  139. * @enable: 1: enable 0: disable
  140. *
  141. * return: status Success/Failure
  142. */
  143. static inline QDF_STATUS
  144. cdp_sawf_mpdu_details_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
  145. {
  146. if (!soc || !soc->ops) {
  147. dp_cdp_debug("Invalid Instance");
  148. QDF_BUG(0);
  149. return QDF_STATUS_E_FAILURE;
  150. }
  151. if (!soc->ops->sawf_ops ||
  152. !soc->ops->sawf_ops->sawf_mpdu_details_stats_req)
  153. return QDF_STATUS_E_FAILURE;
  154. return soc->ops->sawf_ops->sawf_mpdu_details_stats_req(soc, enable);
  155. }
  156. /**
  157. * cdp_sawf_set_mov_avg_params - Set moving average pararms
  158. * @soc: SOC handle
  159. * @num_pkt: No of packets per window to calucalte moving average
  160. * @num_win: No of windows to calucalte moving average
  161. *
  162. * Return: QDF_STATUS
  163. */
  164. static inline QDF_STATUS
  165. cdp_sawf_set_mov_avg_params(ol_txrx_soc_handle soc,
  166. uint32_t num_pkt,
  167. uint32_t num_win)
  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->sawf_ops ||
  175. !soc->ops->sawf_ops->txrx_sawf_set_mov_avg_params)
  176. return QDF_STATUS_E_FAILURE;
  177. return soc->ops->sawf_ops->txrx_sawf_set_mov_avg_params(num_pkt,
  178. num_win);
  179. }
  180. /**
  181. * cdp_sawf_set_sla_params - Set SLA pararms
  182. * @soc: SOC handle
  183. * @num_pkt: No of packets to detect SLA breach
  184. * @time_secs: Time ins secs to detect breach
  185. *
  186. * Return: QDF_STATUS
  187. */
  188. static inline QDF_STATUS
  189. cdp_sawf_set_sla_params(ol_txrx_soc_handle soc,
  190. uint32_t num_pkt,
  191. uint32_t time_secs)
  192. {
  193. if (!soc || !soc->ops) {
  194. dp_cdp_debug("Invalid Instance");
  195. QDF_BUG(0);
  196. return QDF_STATUS_E_FAILURE;
  197. }
  198. if (!soc->ops->sawf_ops ||
  199. !soc->ops->sawf_ops->txrx_sawf_set_sla_params)
  200. return QDF_STATUS_E_FAILURE;
  201. return soc->ops->sawf_ops->txrx_sawf_set_sla_params(num_pkt,
  202. time_secs);
  203. }
  204. /**
  205. * cdp_sawf_init_telemtery_params() - Initialize telemetry pararms
  206. * @soc: SOC handle
  207. *
  208. * Return: none
  209. */
  210. static inline QDF_STATUS
  211. cdp_sawf_init_telemtery_params(ol_txrx_soc_handle soc)
  212. {
  213. if (!soc || !soc->ops) {
  214. dp_cdp_debug("Invalid Instance");
  215. QDF_BUG(0);
  216. return QDF_STATUS_E_FAILURE;
  217. }
  218. if (!soc->ops->sawf_ops ||
  219. !soc->ops->sawf_ops->txrx_sawf_init_telemtery_params)
  220. return QDF_STATUS_E_FAILURE;
  221. return soc->ops->sawf_ops->txrx_sawf_init_telemtery_params();
  222. }
  223. static inline QDF_STATUS
  224. cdp_get_throughput_stats(ol_txrx_soc_handle soc, void *arg,
  225. uint64_t *in_bytes, uint64_t *in_cnt,
  226. uint64_t *tx_bytes, uint64_t *tx_cnt,
  227. uint8_t tid, uint8_t msduq)
  228. {
  229. if (!soc || !soc->ops) {
  230. dp_cdp_debug("Invalid Instance");
  231. QDF_BUG(0);
  232. return QDF_STATUS_E_FAILURE;
  233. }
  234. if (!soc->ops->sawf_ops ||
  235. !soc->ops->sawf_ops->telemetry_get_throughput_stats)
  236. return QDF_STATUS_E_FAILURE;
  237. return soc->ops->sawf_ops->telemetry_get_throughput_stats(
  238. arg, in_bytes, in_cnt, tx_bytes,
  239. tx_cnt, tid, msduq);
  240. }
  241. static inline QDF_STATUS
  242. cdp_get_mpdu_stats(ol_txrx_soc_handle soc, void *arg,
  243. uint64_t *svc_int_pass, uint64_t *svc_int_fail,
  244. uint64_t *burst_pass, uint64_t *burst_fail,
  245. uint8_t tid, uint8_t msduq)
  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->sawf_ops ||
  253. !soc->ops->sawf_ops->telemetry_get_mpdu_stats)
  254. return QDF_STATUS_E_FAILURE;
  255. return soc->ops->sawf_ops->telemetry_get_mpdu_stats(
  256. arg, svc_int_pass, svc_int_fail, burst_pass,
  257. burst_fail, tid, msduq);
  258. }
  259. static inline QDF_STATUS
  260. cdp_get_drop_stats(ol_txrx_soc_handle soc, void *arg,
  261. uint64_t *pass, uint64_t *drop,
  262. uint64_t *drop_ttl,
  263. uint8_t tid, uint8_t msduq)
  264. {
  265. if (!soc || !soc->ops) {
  266. dp_cdp_debug("Invalid Instance");
  267. QDF_BUG(0);
  268. return QDF_STATUS_E_FAILURE;
  269. }
  270. if (!soc->ops->sawf_ops ||
  271. !soc->ops->sawf_ops->telemetry_get_drop_stats)
  272. return QDF_STATUS_E_FAILURE;
  273. return soc->ops->sawf_ops->telemetry_get_drop_stats(
  274. arg, pass, drop, drop_ttl, tid, msduq);
  275. }
  276. /**
  277. * cdp_sawf_peer_config_ul - Config uplink QoS parameters
  278. * @soc: SOC handle
  279. * @mac_addr: MAC address
  280. * @tid: TID
  281. * @service_interval: Service Interval
  282. * @burst_size: Burst Size
  283. * @min_tput: Min throughput
  284. * @max_latency: Max latency
  285. * @add_or_sub: Add or Sub parameters
  286. *
  287. * Return: QDF_STATUS
  288. */
  289. static inline QDF_STATUS
  290. cdp_sawf_peer_config_ul(ol_txrx_soc_handle soc, uint8_t *mac_addr, uint8_t tid,
  291. uint32_t service_interval, uint32_t burst_size,
  292. uint32_t min_tput, uint32_t max_latency,
  293. uint8_t add_or_sub)
  294. {
  295. if (!soc || !soc->ops || !soc->ops->sawf_ops ||
  296. !soc->ops->sawf_ops->peer_config_ul) {
  297. dp_cdp_debug("Invalid Instance");
  298. QDF_BUG(0);
  299. return false;
  300. }
  301. return soc->ops->sawf_ops->peer_config_ul(soc, mac_addr, tid,
  302. service_interval, burst_size,
  303. min_tput, max_latency,
  304. add_or_sub);
  305. }
  306. /**
  307. * cdp_swaf_peer_is_sla_configured() - Check if sla is configured for a peer
  308. * @soc: SOC handle
  309. * @mac_addr: peer mac address
  310. *
  311. * Return: true is peer is sla configured
  312. */
  313. static inline bool
  314. cdp_swaf_peer_is_sla_configured(ol_txrx_soc_handle soc, uint8_t *mac_addr)
  315. {
  316. if (!soc || !soc->ops || !soc->ops->sawf_ops ||
  317. !soc->ops->sawf_ops->swaf_peer_is_sla_configured) {
  318. dp_cdp_debug("Invalid Instance");
  319. QDF_BUG(0);
  320. return false;
  321. }
  322. return soc->ops->sawf_ops->swaf_peer_is_sla_configured(soc, mac_addr);
  323. }
  324. #else
  325. static inline QDF_STATUS
  326. cdp_sawf_mpdu_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
  327. {
  328. return QDF_STATUS_E_FAILURE;
  329. }
  330. static inline QDF_STATUS
  331. cdp_sawf_mpdu_details_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
  332. {
  333. return QDF_STATUS_E_FAILURE;
  334. }
  335. static inline QDF_STATUS
  336. cdp_get_peer_sawf_delay_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
  337. uint8_t *mac, void *data)
  338. {
  339. return QDF_STATUS_E_FAILURE;
  340. }
  341. static inline QDF_STATUS
  342. cdp_get_peer_sawf_tx_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
  343. uint8_t *mac, void *data)
  344. {
  345. return QDF_STATUS_E_FAILURE;
  346. }
  347. static inline bool
  348. cdp_swaf_peer_is_sla_configured(ol_txrx_soc_handle soc, uint8_t *mac_addr)
  349. {
  350. return false;
  351. }
  352. #endif
  353. #endif /* _CDP_TXRX_SAWF_H_ */