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