cdp_txrx_sawf.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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. static inline QDF_STATUS
  68. cdp_sawf_peer_get_msduq_info(ol_txrx_soc_handle soc, uint8_t *mac)
  69. {
  70. if (!soc || !soc->ops) {
  71. dp_cdp_debug("Invalid Instance");
  72. QDF_BUG(0);
  73. return QDF_STATUS_E_FAILURE;
  74. }
  75. if (!soc->ops->sawf_ops ||
  76. !soc->ops->sawf_ops->sawf_get_peer_msduq_info) {
  77. return QDF_STATUS_E_FAILURE;
  78. }
  79. return soc->ops->sawf_ops->sawf_get_peer_msduq_info(soc, mac);
  80. }
  81. #ifdef CONFIG_SAWF
  82. /**
  83. * cdp_get_peer_sawf_delay_stats() - Call to get SAWF delay stats
  84. * @soc: soc handle
  85. * @svc_id: service class ID
  86. * @mac: peer mac address
  87. * @data: opaque pointer
  88. *
  89. * return: status Success/Failure
  90. */
  91. static inline QDF_STATUS
  92. cdp_get_peer_sawf_delay_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
  93. uint8_t *mac, void *data)
  94. {
  95. if (!soc || !soc->ops) {
  96. dp_cdp_debug("Invalid Instance");
  97. QDF_BUG(0);
  98. return QDF_STATUS_E_FAILURE;
  99. }
  100. if (!soc->ops->sawf_ops ||
  101. !soc->ops->sawf_ops->txrx_get_peer_sawf_delay_stats)
  102. return QDF_STATUS_E_FAILURE;
  103. return soc->ops->sawf_ops->txrx_get_peer_sawf_delay_stats(soc, svc_id,
  104. mac, data);
  105. }
  106. /**
  107. * cdp_get_peer_sawf_tx_stats() - Call to get SAWF Tx stats
  108. * @soc: soc handle
  109. * @svc_id: service class ID
  110. * @mac: peer mac address
  111. * @data: opaque pointer
  112. *
  113. * return: status Success/Failure
  114. */
  115. static inline QDF_STATUS
  116. cdp_get_peer_sawf_tx_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
  117. uint8_t *mac, void *data)
  118. {
  119. if (!soc || !soc->ops) {
  120. dp_cdp_debug("Invalid Instance");
  121. QDF_BUG(0);
  122. return QDF_STATUS_E_FAILURE;
  123. }
  124. if (!soc->ops->sawf_ops ||
  125. !soc->ops->sawf_ops->txrx_get_peer_sawf_tx_stats)
  126. return QDF_STATUS_E_FAILURE;
  127. return soc->ops->sawf_ops->txrx_get_peer_sawf_tx_stats(soc, svc_id,
  128. mac, data);
  129. }
  130. /**
  131. * cdp_sawf_mpdu_stats_req() - Call to subscribe to MPDU stats TLV
  132. * @soc: soc handle
  133. * @enable: 1: enable 0: disable
  134. *
  135. * return: status Success/Failure
  136. */
  137. static inline QDF_STATUS
  138. cdp_sawf_mpdu_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
  139. {
  140. if (!soc || !soc->ops) {
  141. dp_cdp_debug("Invalid Instance");
  142. QDF_BUG(0);
  143. return QDF_STATUS_E_FAILURE;
  144. }
  145. if (!soc->ops->sawf_ops ||
  146. !soc->ops->sawf_ops->sawf_mpdu_stats_req)
  147. return QDF_STATUS_E_FAILURE;
  148. return soc->ops->sawf_ops->sawf_mpdu_stats_req(soc, enable);
  149. }
  150. /**
  151. * cdp_sawf_mpdu_details_stats_req - Call to subscribe to MPDU details stats TLV
  152. * @soc: soc handle
  153. * @enable: 1: enable 0: disable
  154. *
  155. * return: status Success/Failure
  156. */
  157. static inline QDF_STATUS
  158. cdp_sawf_mpdu_details_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
  159. {
  160. if (!soc || !soc->ops) {
  161. dp_cdp_debug("Invalid Instance");
  162. QDF_BUG(0);
  163. return QDF_STATUS_E_FAILURE;
  164. }
  165. if (!soc->ops->sawf_ops ||
  166. !soc->ops->sawf_ops->sawf_mpdu_details_stats_req)
  167. return QDF_STATUS_E_FAILURE;
  168. return soc->ops->sawf_ops->sawf_mpdu_details_stats_req(soc, enable);
  169. }
  170. /**
  171. * cdp_sawf_set_mov_avg_params - Set moving average pararms
  172. * @soc: SOC handle
  173. * @num_pkt: No of packets per window to calucalte moving average
  174. * @num_win: No of windows to calucalte moving average
  175. *
  176. * Return: QDF_STATUS
  177. */
  178. static inline QDF_STATUS
  179. cdp_sawf_set_mov_avg_params(ol_txrx_soc_handle soc,
  180. uint32_t num_pkt,
  181. uint32_t num_win)
  182. {
  183. if (!soc || !soc->ops) {
  184. dp_cdp_debug("Invalid Instance");
  185. QDF_BUG(0);
  186. return QDF_STATUS_E_FAILURE;
  187. }
  188. if (!soc->ops->sawf_ops ||
  189. !soc->ops->sawf_ops->txrx_sawf_set_mov_avg_params)
  190. return QDF_STATUS_E_FAILURE;
  191. return soc->ops->sawf_ops->txrx_sawf_set_mov_avg_params(num_pkt,
  192. num_win);
  193. }
  194. /**
  195. * cdp_sawf_set_sla_params - Set SLA pararms
  196. * @soc: SOC handle
  197. * @num_pkt: No of packets to detect SLA breach
  198. * @time_secs: Time ins secs to detect breach
  199. *
  200. * Return: QDF_STATUS
  201. */
  202. static inline QDF_STATUS
  203. cdp_sawf_set_sla_params(ol_txrx_soc_handle soc,
  204. uint32_t num_pkt,
  205. uint32_t time_secs)
  206. {
  207. if (!soc || !soc->ops) {
  208. dp_cdp_debug("Invalid Instance");
  209. QDF_BUG(0);
  210. return QDF_STATUS_E_FAILURE;
  211. }
  212. if (!soc->ops->sawf_ops ||
  213. !soc->ops->sawf_ops->txrx_sawf_set_sla_params)
  214. return QDF_STATUS_E_FAILURE;
  215. return soc->ops->sawf_ops->txrx_sawf_set_sla_params(num_pkt,
  216. time_secs);
  217. }
  218. /**
  219. * cdp_sawf_init_telemtery_params() - Initialize telemetry pararms
  220. * @soc: SOC handle
  221. *
  222. * Return: none
  223. */
  224. static inline QDF_STATUS
  225. cdp_sawf_init_telemtery_params(ol_txrx_soc_handle soc)
  226. {
  227. if (!soc || !soc->ops) {
  228. dp_cdp_debug("Invalid Instance");
  229. QDF_BUG(0);
  230. return QDF_STATUS_E_FAILURE;
  231. }
  232. if (!soc->ops->sawf_ops ||
  233. !soc->ops->sawf_ops->txrx_sawf_init_telemtery_params)
  234. return QDF_STATUS_E_FAILURE;
  235. return soc->ops->sawf_ops->txrx_sawf_init_telemtery_params();
  236. }
  237. static inline QDF_STATUS
  238. cdp_get_throughput_stats(ol_txrx_soc_handle soc, void *arg,
  239. uint64_t *in_bytes, uint64_t *in_cnt,
  240. uint64_t *tx_bytes, uint64_t *tx_cnt,
  241. uint8_t tid, uint8_t msduq)
  242. {
  243. if (!soc || !soc->ops) {
  244. dp_cdp_debug("Invalid Instance");
  245. QDF_BUG(0);
  246. return QDF_STATUS_E_FAILURE;
  247. }
  248. if (!soc->ops->sawf_ops ||
  249. !soc->ops->sawf_ops->telemetry_get_throughput_stats)
  250. return QDF_STATUS_E_FAILURE;
  251. return soc->ops->sawf_ops->telemetry_get_throughput_stats(
  252. arg, in_bytes, in_cnt, tx_bytes,
  253. tx_cnt, tid, msduq);
  254. }
  255. static inline QDF_STATUS
  256. cdp_get_mpdu_stats(ol_txrx_soc_handle soc, void *arg,
  257. uint64_t *svc_int_pass, uint64_t *svc_int_fail,
  258. uint64_t *burst_pass, uint64_t *burst_fail,
  259. uint8_t tid, uint8_t msduq)
  260. {
  261. if (!soc || !soc->ops) {
  262. dp_cdp_debug("Invalid Instance");
  263. QDF_BUG(0);
  264. return QDF_STATUS_E_FAILURE;
  265. }
  266. if (!soc->ops->sawf_ops ||
  267. !soc->ops->sawf_ops->telemetry_get_mpdu_stats)
  268. return QDF_STATUS_E_FAILURE;
  269. return soc->ops->sawf_ops->telemetry_get_mpdu_stats(
  270. arg, svc_int_pass, svc_int_fail, burst_pass,
  271. burst_fail, tid, msduq);
  272. }
  273. static inline QDF_STATUS
  274. cdp_get_drop_stats(ol_txrx_soc_handle soc, void *arg,
  275. uint64_t *pass, uint64_t *drop,
  276. uint64_t *drop_ttl,
  277. uint8_t tid, uint8_t msduq)
  278. {
  279. if (!soc || !soc->ops) {
  280. dp_cdp_debug("Invalid Instance");
  281. QDF_BUG(0);
  282. return QDF_STATUS_E_FAILURE;
  283. }
  284. if (!soc->ops->sawf_ops ||
  285. !soc->ops->sawf_ops->telemetry_get_drop_stats)
  286. return QDF_STATUS_E_FAILURE;
  287. return soc->ops->sawf_ops->telemetry_get_drop_stats(
  288. arg, pass, drop, drop_ttl, tid, msduq);
  289. }
  290. /**
  291. * cdp_sawf_peer_config_ul - Config uplink QoS parameters
  292. * @soc: SOC handle
  293. * @mac_addr: MAC address
  294. * @tid: TID
  295. * @service_interval: Service Interval
  296. * @burst_size: Burst Size
  297. * @min_tput: Min throughput
  298. * @max_latency: Max latency
  299. * @add_or_sub: Add or Sub parameters
  300. * @peer_id: peer id
  301. *
  302. * Return: QDF_STATUS
  303. */
  304. static inline QDF_STATUS
  305. cdp_sawf_peer_config_ul(ol_txrx_soc_handle soc, uint8_t *mac_addr, uint8_t tid,
  306. uint32_t service_interval, uint32_t burst_size,
  307. uint32_t min_tput, uint32_t max_latency,
  308. uint8_t add_or_sub, uint16_t peer_id)
  309. {
  310. if (!soc || !soc->ops || !soc->ops->sawf_ops ||
  311. !soc->ops->sawf_ops->peer_config_ul) {
  312. dp_cdp_debug("Invalid Instance");
  313. QDF_BUG(0);
  314. return false;
  315. }
  316. return soc->ops->sawf_ops->peer_config_ul(soc, mac_addr, tid,
  317. service_interval, burst_size,
  318. min_tput, max_latency,
  319. add_or_sub, peer_id);
  320. }
  321. /**
  322. * cdp_sawf_peer_flow_count - Peer flow count in SAWF
  323. * @soc: SOC handle
  324. * @mac_addr: MAC address
  325. * @svc_id: Service Class ID
  326. * @direction: Indication of forward or reverse service class match
  327. * @start_or_stop: Indication of start or stop
  328. * @peer_mac: Peer MAC address
  329. * @peer_id: peer id
  330. *
  331. * Return: QDF_STATUS
  332. */
  333. static inline QDF_STATUS
  334. cdp_sawf_peer_flow_count(ol_txrx_soc_handle soc, uint8_t *mac_addr,
  335. uint8_t svc_id, uint8_t direction,
  336. uint8_t start_or_stop, uint8_t *peer_mac,
  337. uint16_t peer_id)
  338. {
  339. if (!soc || !soc->ops || !soc->ops->sawf_ops ||
  340. !soc->ops->sawf_ops->sawf_peer_flow_count) {
  341. dp_cdp_debug("Invalid Instance");
  342. QDF_BUG(0);
  343. return false;
  344. }
  345. return soc->ops->sawf_ops->sawf_peer_flow_count
  346. (soc, mac_addr, svc_id, direction, start_or_stop, peer_mac,
  347. peer_id);
  348. }
  349. /**
  350. * cdp_swaf_peer_sla_configuration() - Check if sla is configured for a peer
  351. * @soc: SOC handle
  352. * @mac_addr: peer mac address
  353. * @sla_mask: pointer to SLA mask
  354. * Return: QDF_STATUS
  355. */
  356. static inline QDF_STATUS
  357. cdp_swaf_peer_sla_configuration(ol_txrx_soc_handle soc, uint8_t *mac_addr,
  358. uint16_t *sla_mask)
  359. {
  360. if (!soc || !soc->ops || !soc->ops->sawf_ops ||
  361. !soc->ops->sawf_ops->swaf_peer_sla_configuration) {
  362. dp_cdp_debug("Invalid Instance");
  363. QDF_BUG(0);
  364. return QDF_STATUS_E_INVAL;
  365. }
  366. return soc->ops->sawf_ops->swaf_peer_sla_configuration(soc, mac_addr,
  367. sla_mask);
  368. }
  369. #else
  370. static inline QDF_STATUS
  371. cdp_sawf_mpdu_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
  372. {
  373. return QDF_STATUS_E_FAILURE;
  374. }
  375. static inline QDF_STATUS
  376. cdp_sawf_mpdu_details_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
  377. {
  378. return QDF_STATUS_E_FAILURE;
  379. }
  380. static inline QDF_STATUS
  381. cdp_get_peer_sawf_delay_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
  382. uint8_t *mac, void *data)
  383. {
  384. return QDF_STATUS_E_FAILURE;
  385. }
  386. static inline QDF_STATUS
  387. cdp_get_peer_sawf_tx_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
  388. uint8_t *mac, void *data)
  389. {
  390. return QDF_STATUS_E_FAILURE;
  391. }
  392. static inline QDF_STATUS
  393. cdp_swaf_peer_sla_configuration(ol_txrx_soc_handle soc, uint8_t *mac_addr,
  394. uint16_t *sla_mask)
  395. {
  396. return QDF_STATUS_E_FAILURE;
  397. }
  398. #endif
  399. #ifdef WLAN_FEATURE_11BE_MLO_3_LINK_TX
  400. static inline
  401. uint16_t cdp_sawf_get_peer_msduq(ol_txrx_soc_handle soc,
  402. struct net_device *netdev, uint8_t *dest_mac,
  403. uint32_t dscp_pcp, bool pcp)
  404. {
  405. if (!soc || !soc->ops || !soc->ops->sawf_ops ||
  406. !soc->ops->sawf_ops->get_peer_msduq) {
  407. dp_cdp_debug("Invalid Instance");
  408. QDF_BUG(0);
  409. return false;
  410. }
  411. return soc->ops->sawf_ops->get_peer_msduq
  412. (netdev, dest_mac, dscp_pcp, pcp);
  413. }
  414. static inline QDF_STATUS
  415. cdp_sawf_3_link_peer_flow_count(ol_txrx_soc_handle soc, uint8_t *mac_addr,
  416. uint16_t peer_id, uint32_t mark_metadata)
  417. {
  418. if (!soc || !soc->ops || !soc->ops->sawf_ops ||
  419. !soc->ops->sawf_ops->sawf_3_link_peer_flow_count) {
  420. dp_cdp_debug("Invalid Instance");
  421. QDF_BUG(0);
  422. return false;
  423. }
  424. return soc->ops->sawf_ops->sawf_3_link_peer_flow_count
  425. (soc, mac_addr, peer_id, mark_metadata);
  426. }
  427. #endif
  428. #endif /* _CDP_TXRX_SAWF_H_ */