1 /* 2 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved. 3 * 4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc. 5 * 6 * 7 * Permission to use, copy, modify, and/or distribute this software for 8 * any purpose with or without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 * PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22 /* 23 * This file was originally distributed by Qualcomm Atheros, Inc. 24 * under proprietary terms before Copyright ownership was assigned 25 * to the Linux Foundation. 26 */ 27 /** 28 * @file cdp_txrx_misc.h 29 * @brief Define the host data path miscelleneous API functions 30 * called by the host control SW and the OS interface module 31 */ 32 #ifndef _CDP_TXRX_MISC_H_ 33 #define _CDP_TXRX_MISC_H_ 34 35 #include "cdp_txrx_handle.h" 36 /** 37 * cdp_tx_non_std() - Allow the control-path SW to send data frames 38 * 39 * @soc - data path soc handle 40 * @data_vdev - which vdev should transmit the tx data frames 41 * @tx_spec - what non-standard handling to apply to the tx data frames 42 * @msdu_list - NULL-terminated list of tx MSDUs 43 * 44 * Generally, all tx data frames come from the OS shim into the txrx layer. 45 * However, there are rare cases such as TDLS messaging where the UMAC 46 * control-path SW creates tx data frames. 47 * This UMAC SW can call this function to provide the tx data frames to 48 * the txrx layer. 49 * The UMAC SW can request a callback for these data frames after their 50 * transmission completes, by using the ol_txrx_data_tx_cb_set function 51 * to register a tx completion callback, and by specifying 52 * ol_tx_spec_no_free as the tx_spec arg when giving the frames to 53 * ol_tx_non_std. 54 * The MSDUs need to have the appropriate L2 header type (802.3 vs. 802.11), 55 * as specified by ol_cfg_frame_type(). 56 * 57 * Return: null - success, skb - failure 58 */ 59 static inline qdf_nbuf_t 60 cdp_tx_non_std(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 61 enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list) 62 { 63 if (!soc || !soc->ops || !soc->ops->misc_ops) { 64 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 65 "%s invalid instance", __func__); 66 return NULL; 67 } 68 69 if (soc->ops->misc_ops->tx_non_std) 70 return soc->ops->misc_ops->tx_non_std( 71 vdev, tx_spec, msdu_list); 72 return NULL; 73 } 74 75 /** 76 * cdp_set_ibss_vdev_heart_beat_timer() - Update ibss vdev heart 77 * beat timer 78 * @soc - data path soc handle 79 * @vdev - vdev handle 80 * @timer_value_sec - new heart beat timer value 81 * 82 * Return: Old timer value set in vdev. 83 */ 84 static inline uint16_t 85 cdp_set_ibss_vdev_heart_beat_timer(ol_txrx_soc_handle soc, 86 struct cdp_vdev *vdev, uint16_t timer_value_sec) 87 { 88 if (!soc || !soc->ops || !soc->ops->misc_ops) { 89 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 90 "%s invalid instance", __func__); 91 return 0; 92 } 93 94 if (soc->ops->misc_ops->set_ibss_vdev_heart_beat_timer) 95 return soc->ops->misc_ops->set_ibss_vdev_heart_beat_timer( 96 vdev, timer_value_sec); 97 98 return 0; 99 } 100 101 /** 102 * cdp_set_wisa_mode() - set wisa mode 103 * @soc - data path soc handle 104 * @vdev - vdev handle 105 * @enable - enable or disable 106 * 107 * Return: QDF_STATUS_SUCCESS mode enable success 108 */ 109 static inline QDF_STATUS 110 cdp_set_wisa_mode(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, bool enable) 111 { 112 if (!soc || !soc->ops || !soc->ops->misc_ops) { 113 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 114 "%s invalid instance", __func__); 115 return QDF_STATUS_E_INVAL; 116 } 117 118 if (soc->ops->misc_ops->set_wisa_mode) 119 return soc->ops->misc_ops->set_wisa_mode(vdev, enable); 120 return QDF_STATUS_SUCCESS; 121 } 122 123 /** 124 * cdp_set_wmm_param() - set wmm parameter 125 * @soc - data path soc handle 126 * @pdev - device instance pointer 127 * @wmm_param - wmm parameter 128 * 129 * Return: none 130 */ 131 static inline void 132 cdp_set_wmm_param(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 133 struct ol_tx_wmm_param_t wmm_param) 134 { 135 if (!soc || !soc->ops || !soc->ops->misc_ops) { 136 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 137 "%s invalid instance", __func__); 138 return; 139 } 140 141 if (soc->ops->misc_ops->set_wmm_param) 142 return soc->ops->misc_ops->set_wmm_param( 143 pdev, wmm_param); 144 145 return; 146 } 147 148 /** 149 * cdp_runtime_suspend() - suspend 150 * @soc - data path soc handle 151 * @pdev - device instance pointer 152 * 153 * Return: QDF_STATUS_SUCCESS suspend success 154 */ 155 static inline QDF_STATUS cdp_runtime_suspend(ol_txrx_soc_handle soc, 156 struct cdp_pdev *pdev) 157 { 158 if (!soc || !soc->ops || !soc->ops->misc_ops) { 159 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 160 "%s invalid instance", __func__); 161 return QDF_STATUS_E_INVAL; 162 } 163 164 if (soc->ops->misc_ops->runtime_suspend) 165 return soc->ops->misc_ops->runtime_suspend(pdev); 166 167 return QDF_STATUS_SUCCESS; 168 } 169 170 /** 171 * cdp_runtime_resume() - resume 172 * @soc - data path soc handle 173 * @pdev - device instance pointer 174 * 175 * Return: QDF_STATUS_SUCCESS suspend success 176 */ 177 static inline QDF_STATUS cdp_runtime_resume(ol_txrx_soc_handle soc, 178 struct cdp_pdev *pdev) 179 { 180 if (!soc || !soc->ops || !soc->ops->misc_ops) { 181 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 182 "%s invalid instance", __func__); 183 return QDF_STATUS_E_INVAL; 184 } 185 186 if (soc->ops->misc_ops->runtime_resume) 187 return soc->ops->misc_ops->runtime_resume(pdev); 188 189 return QDF_STATUS_SUCCESS; 190 } 191 192 /** 193 * cdp_hl_tdls_flag_reset() - tdls flag reset 194 * @soc - data path soc handle 195 * @vdev - virtual interface handle pointer 196 * @flag 197 * 198 * Return: none 199 */ 200 static inline void 201 cdp_hl_tdls_flag_reset(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, bool flag) 202 { 203 if (!soc || !soc->ops || !soc->ops->misc_ops) { 204 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 205 "%s invalid instance", __func__); 206 return; 207 } 208 209 if (soc->ops->misc_ops->hl_tdls_flag_reset) 210 return soc->ops->misc_ops->hl_tdls_flag_reset(vdev, flag); 211 212 return; 213 } 214 215 /** 216 * cdp_get_opmode() - get vdev operation mode 217 * @soc - data path soc handle 218 * @vdev - virtual interface instance 219 * 220 * Return virtual device operational mode 221 * op_mode_ap, 222 * op_mode_ibss, 223 * op_mode_sta, 224 * op_mode_monitor, 225 * op_mode_ocb, 226 * 227 * return interface id 228 * 0 unknown interface 229 */ 230 static inline int 231 cdp_get_opmode(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 232 { 233 if (!soc || !soc->ops || !soc->ops->misc_ops) { 234 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 235 "%s invalid instance", __func__); 236 return 0; 237 } 238 239 if (soc->ops->misc_ops->get_opmode) 240 return soc->ops->misc_ops->get_opmode(vdev); 241 return 0; 242 } 243 244 /** 245 * cdp_get_vdev_id() - get vdev id 246 * @soc - data path soc handle 247 * @vdev - virtual interface instance 248 * 249 * get virtual interface id 250 * 251 * return interface id 252 * 0 unknown interface 253 */ 254 static inline uint16_t 255 cdp_get_vdev_id(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 256 { 257 if (!soc || !soc->ops || !soc->ops->misc_ops) { 258 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 259 "%s invalid instance", __func__); 260 return 0; 261 } 262 263 if (soc->ops->misc_ops->get_vdev_id) 264 return soc->ops->misc_ops->get_vdev_id(vdev); 265 return 0; 266 } 267 268 /** 269 * cdp_bad_peer_txctl_set_setting() - TBD 270 * @soc - data path soc handle 271 * @pdev - data path device instance 272 * @enable - 273 * @period - 274 * @txq_limit - 275 * 276 * TBD 277 * 278 * Return: none 279 */ 280 static inline void 281 cdp_bad_peer_txctl_set_setting(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 282 int enable, int period, int txq_limit) 283 { 284 if (!soc || !soc->ops || !soc->ops->misc_ops) { 285 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 286 "%s invalid instance", __func__); 287 return; 288 } 289 290 if (soc->ops->misc_ops->bad_peer_txctl_set_setting) 291 return soc->ops->misc_ops->bad_peer_txctl_set_setting(pdev, 292 enable, period, txq_limit); 293 return; 294 } 295 296 /** 297 * cdp_bad_peer_txctl_update_threshold() - TBD 298 * @soc - data path soc handle 299 * @pdev - data path device instance 300 * @level - 301 * @tput_thresh - 302 * @tx_limit - 303 * 304 * TBD 305 * 306 * Return: none 307 */ 308 static inline void 309 cdp_bad_peer_txctl_update_threshold(ol_txrx_soc_handle soc, 310 struct cdp_pdev *pdev, 311 int level, int tput_thresh, int tx_limit) 312 { 313 if (!soc || !soc->ops || !soc->ops->misc_ops) { 314 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 315 "%s invalid instance", __func__); 316 return; 317 } 318 319 if (soc->ops->misc_ops->bad_peer_txctl_update_threshold) 320 return soc->ops->misc_ops->bad_peer_txctl_update_threshold( 321 pdev, level, tput_thresh, tx_limit); 322 return; 323 } 324 325 /** 326 * cdp_mark_first_wakeup_packet() - set flag to indicate that 327 * fw is compatible for marking first packet after wow wakeup 328 * @soc - data path soc handle 329 * @value: 1 for enabled/ 0 for disabled 330 * 331 * Return: None 332 */ 333 static inline void cdp_mark_first_wakeup_packet(ol_txrx_soc_handle soc, 334 uint8_t value) 335 { 336 if (!soc || !soc->ops || !soc->ops->misc_ops) { 337 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 338 "%s invalid instance", __func__); 339 return; 340 } 341 342 if (soc->ops->misc_ops->mark_first_wakeup_packet) 343 return soc->ops->misc_ops->mark_first_wakeup_packet(value); 344 return; 345 } 346 347 348 /** 349 * cds_update_mac_id() - update mac_id for vdev 350 * @soc - data path soc handle 351 * @vdev_id: vdev id 352 * @mac_id: mac id 353 * 354 * Return: none 355 */ 356 static inline void cdp_update_mac_id(void *psoc, uint8_t vdev_id, 357 uint8_t mac_id) 358 { 359 ol_txrx_soc_handle soc = psoc; 360 361 if (!soc || !soc->ops || !soc->ops->misc_ops) { 362 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 363 "%s invalid instance", __func__); 364 return; 365 } 366 367 if (soc->ops->misc_ops->update_mac_id) 368 return soc->ops->misc_ops->update_mac_id(vdev_id, mac_id); 369 return; 370 } 371 372 /** 373 * cdp_flush_rx_frames() - flush cached rx frames 374 * @soc - data path soc handle 375 * @peer: peer 376 * @drop: set flag to drop frames 377 * 378 * Return: None 379 */ 380 static inline void cdp_flush_rx_frames(ol_txrx_soc_handle soc, void *peer, 381 bool drop) 382 { 383 if (!soc || !soc->ops || !soc->ops->misc_ops) { 384 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 385 "%s invalid instance", __func__); 386 return; 387 } 388 389 if (soc->ops->misc_ops->flush_rx_frames) 390 return soc->ops->misc_ops->flush_rx_frames(peer, drop); 391 return; 392 } 393 394 /* 395 * cdp_get_intra_bss_fwd_pkts_count() - to get the total tx and rx packets 396 * that has been forwarded from txrx layer without going to upper layers. 397 * @vdev_id: vdev id 398 * @fwd_tx_packets: pointer to forwarded tx packets count parameter 399 * @fwd_rx_packets: pointer to forwarded rx packets count parameter 400 * 401 * Return: status -> A_OK - success, A_ERROR - failure 402 */ 403 static inline A_STATUS cdp_get_intra_bss_fwd_pkts_count( 404 ol_txrx_soc_handle soc, uint8_t vdev_id, 405 uint64_t *fwd_tx_packets, uint64_t *fwd_rx_packets) 406 { 407 if (!soc || !soc->ops || !soc->ops->misc_ops) { 408 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 409 "%s invalid instance", __func__); 410 return 0; 411 } 412 413 if (soc->ops->misc_ops->get_intra_bss_fwd_pkts_count) 414 return soc->ops->misc_ops->get_intra_bss_fwd_pkts_count( 415 vdev_id, fwd_tx_packets, fwd_rx_packets); 416 417 return 0; 418 } 419 420 /** 421 * cdp_pkt_log_init() - API to initialize packet log 422 * @handle: pdev handle 423 * @scn: HIF context 424 * 425 * Return: void 426 */ 427 static inline void cdp_pkt_log_init(ol_txrx_soc_handle soc, 428 struct cdp_pdev *pdev, void *scn) 429 { 430 if (!soc || !soc->ops || !soc->ops->misc_ops) { 431 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 432 "%s invalid instance", __func__); 433 return; 434 } 435 436 if (soc->ops->misc_ops->pkt_log_init) 437 return soc->ops->misc_ops->pkt_log_init(pdev, scn); 438 439 return; 440 } 441 442 /** 443 * cdp_pkt_log_con_service() - API to connect packet log service 444 * @handle: pdev handle 445 * @scn: HIF context 446 * 447 * Return: void 448 */ 449 static inline void cdp_pkt_log_con_service(ol_txrx_soc_handle soc, 450 struct cdp_pdev *pdev, void *scn) 451 { 452 if (!soc || !soc->ops || !soc->ops->misc_ops) { 453 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 454 "%s invalid instance", __func__); 455 return; 456 } 457 458 if (soc->ops->misc_ops->pkt_log_con_service) 459 return soc->ops->misc_ops->pkt_log_con_service(pdev, scn); 460 461 return; 462 } 463 #endif /* _CDP_TXRX_MISC_H_ */ 464 465