xref: /wlan-driver/qca-wifi-host-cmn/dp/inc/cdp_txrx_sawf.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
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 
19 #ifndef _CDP_TXRX_SAWF_H_
20 #define _CDP_TXRX_SAWF_H_
21 
22 #include <cdp_txrx_cmn_struct.h>
23 #include <cdp_txrx_cmn.h>
24 
25 static inline QDF_STATUS
cdp_sawf_peer_svcid_map(ol_txrx_soc_handle soc,uint8_t * mac,uint8_t svc_id)26 cdp_sawf_peer_svcid_map(ol_txrx_soc_handle soc,
27 			uint8_t *mac, uint8_t svc_id)
28 {
29 	if (!soc || !soc->ops) {
30 		dp_cdp_debug("Invalid Instance");
31 		QDF_BUG(0);
32 		return QDF_STATUS_E_FAILURE;
33 	}
34 
35 	if (!soc->ops->sawf_ops ||
36 	    !soc->ops->sawf_ops->sawf_def_queues_map_req) {
37 		return QDF_STATUS_E_FAILURE;
38 	}
39 
40 	return soc->ops->sawf_ops->sawf_def_queues_map_req(soc, mac, svc_id);
41 }
42 
43 static inline QDF_STATUS
cdp_sawf_peer_unmap(ol_txrx_soc_handle soc,uint8_t * mac,uint8_t svc_id)44 cdp_sawf_peer_unmap(ol_txrx_soc_handle soc,
45 		    uint8_t *mac, uint8_t svc_id)
46 {
47 	if (!soc || !soc->ops) {
48 		dp_cdp_debug("Invalid Instance");
49 		QDF_BUG(0);
50 		return QDF_STATUS_E_FAILURE;
51 	}
52 
53 	if (!soc->ops->sawf_ops ||
54 	    !soc->ops->sawf_ops->sawf_def_queues_unmap_req) {
55 		return QDF_STATUS_E_FAILURE;
56 	}
57 
58 	return soc->ops->sawf_ops->sawf_def_queues_unmap_req(soc, mac, svc_id);
59 }
60 
61 static inline QDF_STATUS
cdp_sawf_peer_get_map_conf(ol_txrx_soc_handle soc,uint8_t * mac)62 cdp_sawf_peer_get_map_conf(ol_txrx_soc_handle soc,
63 			   uint8_t *mac)
64 {
65 	if (!soc || !soc->ops) {
66 		dp_cdp_debug("Invalid Instance");
67 		QDF_BUG(0);
68 		return QDF_STATUS_E_FAILURE;
69 	}
70 
71 	if (!soc->ops->sawf_ops ||
72 	    !soc->ops->sawf_ops->sawf_def_queues_get_map_report) {
73 		return QDF_STATUS_E_FAILURE;
74 	}
75 
76 	return soc->ops->sawf_ops->sawf_def_queues_get_map_report(soc, mac);
77 }
78 
79 static inline QDF_STATUS
cdp_sawf_peer_get_msduq_info(ol_txrx_soc_handle soc,uint8_t * mac)80 cdp_sawf_peer_get_msduq_info(ol_txrx_soc_handle soc, uint8_t *mac)
81 {
82 	if (!soc || !soc->ops) {
83 		dp_cdp_debug("Invalid Instance");
84 		QDF_BUG(0);
85 		return QDF_STATUS_E_FAILURE;
86 	}
87 
88 	if (!soc->ops->sawf_ops ||
89 	    !soc->ops->sawf_ops->sawf_get_peer_msduq_info) {
90 		return QDF_STATUS_E_FAILURE;
91 	}
92 
93 	return soc->ops->sawf_ops->sawf_get_peer_msduq_info(soc, mac);
94 }
95 
96 #ifdef CONFIG_SAWF
97 /**
98  * cdp_get_peer_sawf_delay_stats() - Call to get SAWF delay stats
99  * @soc: soc handle
100  * @svc_id: service class ID
101  * @mac: peer mac address
102  * @data: opaque pointer
103  *
104  * return: status Success/Failure
105  */
106 static inline QDF_STATUS
cdp_get_peer_sawf_delay_stats(ol_txrx_soc_handle soc,uint32_t svc_id,uint8_t * mac,void * data)107 cdp_get_peer_sawf_delay_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
108 			      uint8_t *mac, void *data)
109 {
110 	if (!soc || !soc->ops) {
111 		dp_cdp_debug("Invalid Instance");
112 		QDF_BUG(0);
113 		return QDF_STATUS_E_FAILURE;
114 	}
115 
116 	if (!soc->ops->sawf_ops ||
117 	    !soc->ops->sawf_ops->txrx_get_peer_sawf_delay_stats)
118 		return QDF_STATUS_E_FAILURE;
119 
120 	return soc->ops->sawf_ops->txrx_get_peer_sawf_delay_stats(soc, svc_id,
121 								  mac, data);
122 }
123 
124 /**
125  * cdp_get_peer_sawf_tx_stats() - Call to get SAWF Tx stats
126  * @soc: soc handle
127  * @svc_id: service class ID
128  * @mac: peer mac address
129  * @data: opaque pointer
130  *
131  * return: status Success/Failure
132  */
133 static inline QDF_STATUS
cdp_get_peer_sawf_tx_stats(ol_txrx_soc_handle soc,uint32_t svc_id,uint8_t * mac,void * data)134 cdp_get_peer_sawf_tx_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
135 			   uint8_t *mac, void *data)
136 {
137 	if (!soc || !soc->ops) {
138 		dp_cdp_debug("Invalid Instance");
139 		QDF_BUG(0);
140 		return QDF_STATUS_E_FAILURE;
141 	}
142 
143 	if (!soc->ops->sawf_ops ||
144 	    !soc->ops->sawf_ops->txrx_get_peer_sawf_tx_stats)
145 		return QDF_STATUS_E_FAILURE;
146 
147 	return soc->ops->sawf_ops->txrx_get_peer_sawf_tx_stats(soc, svc_id,
148 							       mac, data);
149 }
150 
151 /**
152  * cdp_sawf_mpdu_stats_req() - Call to subscribe to MPDU stats TLV
153  * @soc: soc handle
154  * @enable: 1: enable 0: disable
155  *
156  * return: status Success/Failure
157  */
158 static inline QDF_STATUS
cdp_sawf_mpdu_stats_req(ol_txrx_soc_handle soc,uint8_t enable)159 cdp_sawf_mpdu_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
160 {
161 	if (!soc || !soc->ops) {
162 		dp_cdp_debug("Invalid Instance");
163 		QDF_BUG(0);
164 		return QDF_STATUS_E_FAILURE;
165 	}
166 
167 	if (!soc->ops->sawf_ops ||
168 	    !soc->ops->sawf_ops->sawf_mpdu_stats_req)
169 		return QDF_STATUS_E_FAILURE;
170 
171 	return soc->ops->sawf_ops->sawf_mpdu_stats_req(soc, enable);
172 }
173 
174 /**
175  * cdp_sawf_mpdu_details_stats_req - Call to subscribe to MPDU details stats TLV
176  * @soc: soc handle
177  * @enable: 1: enable 0: disable
178  *
179  * return: status Success/Failure
180  */
181 static inline QDF_STATUS
cdp_sawf_mpdu_details_stats_req(ol_txrx_soc_handle soc,uint8_t enable)182 cdp_sawf_mpdu_details_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
183 {
184 	if (!soc || !soc->ops) {
185 		dp_cdp_debug("Invalid Instance");
186 		QDF_BUG(0);
187 		return QDF_STATUS_E_FAILURE;
188 	}
189 
190 	if (!soc->ops->sawf_ops ||
191 	    !soc->ops->sawf_ops->sawf_mpdu_details_stats_req)
192 		return QDF_STATUS_E_FAILURE;
193 
194 	return soc->ops->sawf_ops->sawf_mpdu_details_stats_req(soc, enable);
195 }
196 
197 /**
198  * cdp_sawf_set_mov_avg_params - Set moving average pararms
199  * @soc: SOC handle
200  * @num_pkt: No of packets per window to calucalte moving average
201  * @num_win: No of windows to calucalte moving average
202  *
203  * Return: QDF_STATUS
204  */
205 static inline QDF_STATUS
cdp_sawf_set_mov_avg_params(ol_txrx_soc_handle soc,uint32_t num_pkt,uint32_t num_win)206 cdp_sawf_set_mov_avg_params(ol_txrx_soc_handle soc,
207 			    uint32_t num_pkt,
208 			    uint32_t num_win)
209 {
210 	if (!soc || !soc->ops) {
211 		dp_cdp_debug("Invalid Instance");
212 		QDF_BUG(0);
213 		return QDF_STATUS_E_FAILURE;
214 	}
215 
216 	if (!soc->ops->sawf_ops ||
217 	    !soc->ops->sawf_ops->txrx_sawf_set_mov_avg_params)
218 		return QDF_STATUS_E_FAILURE;
219 
220 	return soc->ops->sawf_ops->txrx_sawf_set_mov_avg_params(num_pkt,
221 								num_win);
222 }
223 
224 /**
225  * cdp_sawf_set_sla_params - Set SLA pararms
226  * @soc: SOC handle
227  * @num_pkt: No of packets to detect SLA breach
228  * @time_secs: Time ins secs to detect breach
229  *
230  * Return: QDF_STATUS
231  */
232 static inline QDF_STATUS
cdp_sawf_set_sla_params(ol_txrx_soc_handle soc,uint32_t num_pkt,uint32_t time_secs)233 cdp_sawf_set_sla_params(ol_txrx_soc_handle soc,
234 			uint32_t num_pkt,
235 			uint32_t time_secs)
236 {
237 	if (!soc || !soc->ops) {
238 		dp_cdp_debug("Invalid Instance");
239 		QDF_BUG(0);
240 		return QDF_STATUS_E_FAILURE;
241 	}
242 
243 	if (!soc->ops->sawf_ops ||
244 	    !soc->ops->sawf_ops->txrx_sawf_set_sla_params)
245 		return QDF_STATUS_E_FAILURE;
246 
247 	return soc->ops->sawf_ops->txrx_sawf_set_sla_params(num_pkt,
248 							    time_secs);
249 }
250 
251 /**
252  * cdp_sawf_init_telemtery_params() - Initialize telemetry pararms
253  * @soc: SOC handle
254  *
255  * Return: none
256  */
257 static inline QDF_STATUS
cdp_sawf_init_telemtery_params(ol_txrx_soc_handle soc)258 cdp_sawf_init_telemtery_params(ol_txrx_soc_handle soc)
259 {
260 	if (!soc || !soc->ops) {
261 		dp_cdp_debug("Invalid Instance");
262 		QDF_BUG(0);
263 		return QDF_STATUS_E_FAILURE;
264 	}
265 
266 	if (!soc->ops->sawf_ops ||
267 	    !soc->ops->sawf_ops->txrx_sawf_init_telemtery_params)
268 		return QDF_STATUS_E_FAILURE;
269 
270 	return soc->ops->sawf_ops->txrx_sawf_init_telemtery_params();
271 }
272 
273 static inline QDF_STATUS
cdp_get_throughput_stats(ol_txrx_soc_handle soc,void * arg,uint64_t * in_bytes,uint64_t * in_cnt,uint64_t * tx_bytes,uint64_t * tx_cnt,uint8_t tid,uint8_t msduq)274 cdp_get_throughput_stats(ol_txrx_soc_handle soc, void *arg,
275 			 uint64_t *in_bytes, uint64_t *in_cnt,
276 			 uint64_t *tx_bytes, uint64_t *tx_cnt,
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 
285 	if (!soc->ops->sawf_ops ||
286 	    !soc->ops->sawf_ops->telemetry_get_throughput_stats)
287 		return QDF_STATUS_E_FAILURE;
288 
289 	return soc->ops->sawf_ops->telemetry_get_throughput_stats(
290 			arg, in_bytes, in_cnt, tx_bytes,
291 			tx_cnt, tid, msduq);
292 }
293 
294 static inline QDF_STATUS
cdp_get_mpdu_stats(ol_txrx_soc_handle soc,void * arg,uint64_t * svc_int_pass,uint64_t * svc_int_fail,uint64_t * burst_pass,uint64_t * burst_fail,uint8_t tid,uint8_t msduq)295 cdp_get_mpdu_stats(ol_txrx_soc_handle soc, void *arg,
296 		   uint64_t *svc_int_pass, uint64_t *svc_int_fail,
297 		   uint64_t *burst_pass, uint64_t *burst_fail,
298 		   uint8_t tid, uint8_t msduq)
299 {
300 	if (!soc || !soc->ops) {
301 		dp_cdp_debug("Invalid Instance");
302 		QDF_BUG(0);
303 		return QDF_STATUS_E_FAILURE;
304 	}
305 
306 	if (!soc->ops->sawf_ops ||
307 	    !soc->ops->sawf_ops->telemetry_get_mpdu_stats)
308 		return QDF_STATUS_E_FAILURE;
309 
310 	return soc->ops->sawf_ops->telemetry_get_mpdu_stats(
311 			arg, svc_int_pass, svc_int_fail, burst_pass,
312 			burst_fail, tid, msduq);
313 }
314 
315 static inline QDF_STATUS
cdp_get_drop_stats(ol_txrx_soc_handle soc,void * arg,uint64_t * pass,uint64_t * drop,uint64_t * drop_ttl,uint8_t tid,uint8_t msduq)316 cdp_get_drop_stats(ol_txrx_soc_handle soc, void *arg,
317 		   uint64_t *pass, uint64_t *drop,
318 		   uint64_t *drop_ttl,
319 		   uint8_t tid, uint8_t msduq)
320 {
321 	if (!soc || !soc->ops) {
322 		dp_cdp_debug("Invalid Instance");
323 		QDF_BUG(0);
324 		return QDF_STATUS_E_FAILURE;
325 	}
326 
327 	if (!soc->ops->sawf_ops ||
328 	    !soc->ops->sawf_ops->telemetry_get_drop_stats)
329 		return QDF_STATUS_E_FAILURE;
330 
331 	return soc->ops->sawf_ops->telemetry_get_drop_stats(
332 			arg, pass, drop, drop_ttl, tid, msduq);
333 }
334 
335 /**
336  * cdp_sawf_peer_config_ul - Config uplink QoS parameters
337  * @soc: SOC handle
338  * @mac_addr: MAC address
339  * @tid: TID
340  * @service_interval: Service Interval
341  * @burst_size: Burst Size
342  * @min_tput: Min throughput
343  * @max_latency: Max latency
344  * @add_or_sub: Add or Sub parameters
345  * @peer_id: peer id
346  *
347  * Return: QDF_STATUS
348  */
349 static inline QDF_STATUS
cdp_sawf_peer_config_ul(ol_txrx_soc_handle soc,uint8_t * mac_addr,uint8_t tid,uint32_t service_interval,uint32_t burst_size,uint32_t min_tput,uint32_t max_latency,uint8_t add_or_sub,uint16_t peer_id)350 cdp_sawf_peer_config_ul(ol_txrx_soc_handle soc, uint8_t *mac_addr, uint8_t tid,
351 			uint32_t service_interval, uint32_t burst_size,
352 			uint32_t min_tput, uint32_t max_latency,
353 			uint8_t add_or_sub, uint16_t peer_id)
354 {
355 	if (!soc || !soc->ops || !soc->ops->sawf_ops ||
356 	    !soc->ops->sawf_ops->peer_config_ul) {
357 		dp_cdp_debug("Invalid Instance");
358 		QDF_BUG(0);
359 		return false;
360 	}
361 
362 	return soc->ops->sawf_ops->peer_config_ul(soc, mac_addr, tid,
363 						  service_interval, burst_size,
364 						  min_tput, max_latency,
365 						  add_or_sub, peer_id);
366 }
367 
368 /**
369  * cdp_sawf_peer_flow_count - Peer flow count in SAWF
370  * @soc: SOC handle
371  * @mac_addr: MAC address
372  * @svc_id: Service Class ID
373  * @direction: Indication of forward or reverse service class match
374  * @start_or_stop: Indication of start or stop
375  * @peer_mac: Peer MAC address
376  * @peer_id: peer id
377  *
378  * Return: QDF_STATUS
379  */
380 static inline QDF_STATUS
cdp_sawf_peer_flow_count(ol_txrx_soc_handle soc,uint8_t * mac_addr,uint8_t svc_id,uint8_t direction,uint8_t start_or_stop,uint8_t * peer_mac,uint16_t peer_id)381 cdp_sawf_peer_flow_count(ol_txrx_soc_handle soc, uint8_t *mac_addr,
382 			 uint8_t svc_id, uint8_t direction,
383 			 uint8_t start_or_stop, uint8_t *peer_mac,
384 			 uint16_t peer_id)
385 {
386 	if (!soc || !soc->ops || !soc->ops->sawf_ops ||
387 	    !soc->ops->sawf_ops->sawf_peer_flow_count) {
388 		dp_cdp_debug("Invalid Instance");
389 		QDF_BUG(0);
390 		return false;
391 	}
392 
393 	return soc->ops->sawf_ops->sawf_peer_flow_count
394 		(soc, mac_addr, svc_id, direction, start_or_stop, peer_mac,
395 								peer_id);
396 }
397 
398 /**
399  * cdp_swaf_peer_sla_configuration() - Check if sla is configured for a peer
400  * @soc: SOC handle
401  * @mac_addr: peer mac address
402  * @sla_mask: pointer to SLA mask
403  * Return: QDF_STATUS
404  */
405 static inline QDF_STATUS
cdp_swaf_peer_sla_configuration(ol_txrx_soc_handle soc,uint8_t * mac_addr,uint16_t * sla_mask)406 cdp_swaf_peer_sla_configuration(ol_txrx_soc_handle soc, uint8_t *mac_addr,
407 				uint16_t *sla_mask)
408 {
409 	if (!soc || !soc->ops || !soc->ops->sawf_ops ||
410 	    !soc->ops->sawf_ops->swaf_peer_sla_configuration) {
411 		dp_cdp_debug("Invalid Instance");
412 		QDF_BUG(0);
413 		return QDF_STATUS_E_INVAL;
414 	}
415 
416 	return soc->ops->sawf_ops->swaf_peer_sla_configuration(soc, mac_addr,
417 							       sla_mask);
418 }
419 
420 #else
421 static inline QDF_STATUS
cdp_sawf_mpdu_stats_req(ol_txrx_soc_handle soc,uint8_t enable)422 cdp_sawf_mpdu_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
423 {
424 	return QDF_STATUS_E_FAILURE;
425 }
426 
427 static inline QDF_STATUS
cdp_sawf_mpdu_details_stats_req(ol_txrx_soc_handle soc,uint8_t enable)428 cdp_sawf_mpdu_details_stats_req(ol_txrx_soc_handle soc, uint8_t enable)
429 {
430 	return QDF_STATUS_E_FAILURE;
431 }
432 
433 static inline QDF_STATUS
cdp_get_peer_sawf_delay_stats(ol_txrx_soc_handle soc,uint32_t svc_id,uint8_t * mac,void * data)434 cdp_get_peer_sawf_delay_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
435 			      uint8_t *mac, void *data)
436 {
437 	return QDF_STATUS_E_FAILURE;
438 }
439 
440 static inline QDF_STATUS
cdp_get_peer_sawf_tx_stats(ol_txrx_soc_handle soc,uint32_t svc_id,uint8_t * mac,void * data)441 cdp_get_peer_sawf_tx_stats(ol_txrx_soc_handle soc, uint32_t svc_id,
442 			   uint8_t *mac, void *data)
443 {
444 	return QDF_STATUS_E_FAILURE;
445 }
446 
447 static inline QDF_STATUS
cdp_swaf_peer_sla_configuration(ol_txrx_soc_handle soc,uint8_t * mac_addr,uint16_t * sla_mask)448 cdp_swaf_peer_sla_configuration(ol_txrx_soc_handle soc, uint8_t *mac_addr,
449 				uint16_t *sla_mask)
450 {
451 	return QDF_STATUS_E_FAILURE;
452 }
453 #endif
454 
455 #ifdef WLAN_FEATURE_11BE_MLO_3_LINK_TX
456 static inline
cdp_sawf_get_peer_msduq(ol_txrx_soc_handle soc,struct net_device * netdev,uint8_t * dest_mac,uint32_t dscp_pcp,bool pcp)457 uint16_t cdp_sawf_get_peer_msduq(ol_txrx_soc_handle soc,
458 				 struct net_device *netdev, uint8_t *dest_mac,
459 				 uint32_t dscp_pcp, bool pcp)
460 {
461 	if (!soc || !soc->ops || !soc->ops->sawf_ops ||
462 	    !soc->ops->sawf_ops->get_peer_msduq) {
463 		dp_cdp_debug("Invalid Instance");
464 		QDF_BUG(0);
465 		return false;
466 	}
467 
468 	return soc->ops->sawf_ops->get_peer_msduq
469 		(netdev, dest_mac, dscp_pcp, pcp);
470 }
471 
472 static inline QDF_STATUS
cdp_sawf_3_link_peer_flow_count(ol_txrx_soc_handle soc,uint8_t * mac_addr,uint16_t peer_id,uint32_t mark_metadata)473 cdp_sawf_3_link_peer_flow_count(ol_txrx_soc_handle soc, uint8_t *mac_addr,
474 				uint16_t peer_id, uint32_t mark_metadata)
475 {
476 	if (!soc || !soc->ops || !soc->ops->sawf_ops ||
477 	    !soc->ops->sawf_ops->sawf_3_link_peer_flow_count) {
478 		dp_cdp_debug("Invalid Instance");
479 		QDF_BUG(0);
480 		return false;
481 	}
482 
483 	return soc->ops->sawf_ops->sawf_3_link_peer_flow_count
484 		(soc, mac_addr, peer_id, mark_metadata);
485 }
486 #endif
487 #endif /* _CDP_TXRX_SAWF_H_ */
488