1 /* 2 * Copyright (c) 2011-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_cmn.h 29 * @brief Define the host data path converged API functions 30 * called by the host control SW and the OS interface module 31 */ 32 #ifndef _CDP_TXRX_CMN_H_ 33 #define _CDP_TXRX_CMN_H_ 34 35 #include "qdf_types.h" 36 #include "qdf_nbuf.h" 37 #include "cdp_txrx_ops.h" 38 #include "cdp_txrx_handle.h" 39 #include "cdp_txrx_cmn_struct.h" 40 /****************************************************************************** 41 * 42 * Common Data Path Header File 43 * 44 *****************************************************************************/ 45 46 static inline int 47 cdp_soc_attach_target(ol_txrx_soc_handle soc) 48 { 49 if (soc->ops->cmn_drv_ops->txrx_soc_attach_target) 50 return soc->ops->cmn_drv_ops->txrx_soc_attach_target(soc); 51 return 0; 52 } 53 54 static inline struct cdp_vdev * 55 cdp_vdev_attach(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 56 uint8_t *vdev_mac_addr, uint8_t vdev_id, enum wlan_op_mode op_mode) 57 { 58 if (soc->ops->cmn_drv_ops->txrx_vdev_attach) 59 return soc->ops->cmn_drv_ops->txrx_vdev_attach(pdev, 60 vdev_mac_addr, vdev_id, op_mode); 61 return NULL; 62 } 63 64 static inline void 65 cdp_vdev_detach(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 66 ol_txrx_vdev_delete_cb callback, void *cb_context) 67 { 68 if (soc->ops->cmn_drv_ops->txrx_vdev_detach) 69 return soc->ops->cmn_drv_ops->txrx_vdev_detach(vdev, 70 callback, cb_context); 71 return; 72 } 73 74 static inline int 75 cdp_pdev_attach_target(ol_txrx_soc_handle soc, struct cdp_pdev *pdev) 76 { 77 if (soc->ops->cmn_drv_ops->txrx_pdev_attach_target) 78 return soc->ops->cmn_drv_ops->txrx_pdev_attach_target(pdev); 79 return 0; 80 } 81 82 static inline struct cdp_pdev *cdp_pdev_attach 83 (ol_txrx_soc_handle soc, struct cdp_cfg *ctrl_pdev, 84 HTC_HANDLE htc_pdev, qdf_device_t osdev, uint8_t pdev_id) 85 { 86 if (soc->ops->cmn_drv_ops->txrx_pdev_attach) 87 return soc->ops->cmn_drv_ops->txrx_pdev_attach(soc, ctrl_pdev, 88 htc_pdev, osdev, pdev_id); 89 return NULL; 90 } 91 92 static inline int cdp_pdev_post_attach(ol_txrx_soc_handle soc, 93 struct cdp_pdev *pdev) 94 { 95 if (soc->ops->cmn_drv_ops->txrx_pdev_post_attach) 96 return soc->ops->cmn_drv_ops->txrx_pdev_post_attach(pdev); 97 return 0; 98 } 99 100 static inline void 101 cdp_pdev_pre_detach(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, int force) 102 { 103 if (soc->ops->cmn_drv_ops->txrx_pdev_pre_detach) 104 return soc->ops->cmn_drv_ops->txrx_pdev_pre_detach(pdev, force); 105 return; 106 } 107 108 static inline void 109 cdp_pdev_detach(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, int force) 110 { 111 if (soc->ops->cmn_drv_ops->txrx_pdev_detach) 112 return soc->ops->cmn_drv_ops->txrx_pdev_detach(pdev, force); 113 return; 114 } 115 116 static inline void *cdp_peer_create 117 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 118 uint8_t *peer_mac_addr) 119 { 120 if (soc->ops->cmn_drv_ops->txrx_peer_create) 121 return soc->ops->cmn_drv_ops->txrx_peer_create(vdev, 122 peer_mac_addr); 123 return NULL; 124 } 125 126 static inline void cdp_peer_setup 127 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, void *peer) 128 { 129 if (soc->ops->cmn_drv_ops->txrx_peer_setup) 130 return soc->ops->cmn_drv_ops->txrx_peer_setup(vdev, 131 peer); 132 return; 133 } 134 135 static inline void cdp_peer_teardown 136 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, void *peer) 137 { 138 if (soc->ops->cmn_drv_ops->txrx_peer_teardown) 139 return soc->ops->cmn_drv_ops->txrx_peer_teardown(vdev, 140 peer); 141 return; 142 } 143 144 static inline void 145 cdp_peer_delete(ol_txrx_soc_handle soc, void *peer) 146 { 147 if (soc->ops->cmn_drv_ops->txrx_peer_delete) 148 return soc->ops->cmn_drv_ops->txrx_peer_delete(peer); 149 return; 150 } 151 152 static inline int 153 cdp_set_monitor_mode(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 154 uint8_t smart_monitor) 155 { 156 if (soc->ops->cmn_drv_ops->txrx_set_monitor_mode) 157 return soc->ops->cmn_drv_ops->txrx_set_monitor_mode(vdev, 158 smart_monitor); 159 return 0; 160 } 161 162 static inline void 163 cdp_set_curchan(ol_txrx_soc_handle soc, 164 struct cdp_pdev *pdev, 165 uint32_t chan_mhz) 166 { 167 if (soc->ops->cmn_drv_ops->txrx_set_curchan) 168 return soc->ops->cmn_drv_ops->txrx_set_curchan(pdev, chan_mhz); 169 return; 170 } 171 172 static inline void 173 cdp_set_privacy_filters(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 174 void *filter, uint32_t num) 175 { 176 if (soc->ops->cmn_drv_ops->txrx_set_privacy_filters) 177 return soc->ops->cmn_drv_ops->txrx_set_privacy_filters(vdev, 178 filter, num); 179 return; 180 } 181 182 /****************************************************************************** 183 * Data Interface (B Interface) 184 *****************************************************************************/ 185 static inline void 186 cdp_vdev_register(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 187 void *osif_vdev, struct ol_txrx_ops *txrx_ops) 188 { 189 if (soc->ops->cmn_drv_ops->txrx_vdev_register) 190 return soc->ops->cmn_drv_ops->txrx_vdev_register(vdev, 191 osif_vdev, txrx_ops); 192 return; 193 } 194 195 static inline int 196 cdp_mgmt_send(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 197 qdf_nbuf_t tx_mgmt_frm, uint8_t type) 198 { 199 if (soc->ops->cmn_drv_ops->txrx_mgmt_send) 200 return soc->ops->cmn_drv_ops->txrx_mgmt_send(vdev, 201 tx_mgmt_frm, type); 202 return 0; 203 } 204 205 static inline int 206 cdp_mgmt_send_ext(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 207 qdf_nbuf_t tx_mgmt_frm, uint8_t type, 208 uint8_t use_6mbps, uint16_t chanfreq) 209 { 210 if (soc->ops->cmn_drv_ops->txrx_mgmt_send_ext) 211 return soc->ops->cmn_drv_ops->txrx_mgmt_send_ext 212 (vdev, tx_mgmt_frm, type, use_6mbps, chanfreq); 213 return 0; 214 } 215 216 217 static inline void 218 cdp_mgmt_tx_cb_set(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 219 uint8_t type, 220 ol_txrx_mgmt_tx_cb download_cb, 221 ol_txrx_mgmt_tx_cb ota_ack_cb, void *ctxt) 222 { 223 if (soc->ops->cmn_drv_ops->txrx_mgmt_tx_cb_set) 224 return soc->ops->cmn_drv_ops->txrx_mgmt_tx_cb_set 225 (pdev, type, download_cb, ota_ack_cb, ctxt); 226 return; 227 } 228 229 static inline int cdp_get_tx_pending(ol_txrx_soc_handle soc, 230 struct cdp_pdev *pdev) 231 { 232 if (soc->ops->cmn_drv_ops->txrx_get_tx_pending) 233 return soc->ops->cmn_drv_ops->txrx_get_tx_pending(pdev); 234 return 0; 235 } 236 237 static inline void 238 cdp_data_tx_cb_set(ol_txrx_soc_handle soc, struct cdp_vdev *data_vdev, 239 ol_txrx_data_tx_cb callback, void *ctxt) 240 { 241 if (soc->ops->cmn_drv_ops->txrx_data_tx_cb_set) 242 return soc->ops->cmn_drv_ops->txrx_data_tx_cb_set(data_vdev, 243 callback, ctxt); 244 return; 245 } 246 247 /****************************************************************************** 248 * Statistics and Debugging Interface (C Inteface) 249 *****************************************************************************/ 250 /** 251 * External Device physical address types 252 * 253 * Currently, both MAC and IPA uController use the same size addresses 254 * and descriptors are exchanged between these two depending on the mode. 255 * 256 * Rationale: qdf_dma_addr_t is the type used internally on the host for DMA 257 * operations. However, external device physical address sizes 258 * may be different from host-specific physical address sizes. 259 * This calls for the following definitions for target devices 260 * (MAC, IPA uc). 261 */ 262 #if HTT_PADDR64 263 typedef uint64_t target_paddr_t; 264 #else 265 typedef uint32_t target_paddr_t; 266 #endif /*HTT_PADDR64 */ 267 268 static inline int 269 cdp_aggr_cfg(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 270 int max_subfrms_ampdu, 271 int max_subfrms_amsdu) 272 { 273 if (soc->ops->cmn_drv_ops->txrx_aggr_cfg) 274 return soc->ops->cmn_drv_ops->txrx_aggr_cfg(vdev, 275 max_subfrms_ampdu, max_subfrms_amsdu); 276 return 0; 277 } 278 279 static inline int 280 cdp_fw_stats_get(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 281 struct ol_txrx_stats_req *req, bool per_vdev, 282 bool response_expected) 283 { 284 if (soc->ops->cmn_drv_ops->txrx_fw_stats_get) 285 return soc->ops->cmn_drv_ops->txrx_fw_stats_get(vdev, req, 286 per_vdev, response_expected); 287 return 0; 288 } 289 290 static inline int 291 cdp_debug(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, int debug_specs) 292 { 293 if (soc->ops->cmn_drv_ops->txrx_debug) 294 return soc->ops->cmn_drv_ops->txrx_debug(vdev, debug_specs); 295 return 0; 296 } 297 298 static inline void cdp_fw_stats_cfg(ol_txrx_soc_handle soc, 299 struct cdp_vdev *vdev, uint8_t cfg_stats_type, uint32_t cfg_val) 300 { 301 if (soc->ops->cmn_drv_ops->txrx_fw_stats_cfg) 302 return soc->ops->cmn_drv_ops->txrx_fw_stats_cfg(vdev, 303 cfg_stats_type, cfg_val); 304 return; 305 } 306 307 static inline void cdp_print_level_set(ol_txrx_soc_handle soc, unsigned level) 308 { 309 if (soc->ops->cmn_drv_ops->txrx_print_level_set) 310 return soc->ops->cmn_drv_ops->txrx_print_level_set(level); 311 return; 312 } 313 314 static inline uint8_t * 315 cdp_get_vdev_mac_addr(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 316 { 317 if (soc->ops->cmn_drv_ops->txrx_get_vdev_mac_addr) 318 return soc->ops->cmn_drv_ops->txrx_get_vdev_mac_addr(vdev); 319 return NULL; 320 } 321 322 /** 323 * cdp_get_vdev_struct_mac_addr() - Return handle to struct qdf_mac_addr of 324 * vdev 325 * @vdev: vdev handle 326 * 327 * Return: Handle to struct qdf_mac_addr 328 */ 329 static inline struct qdf_mac_addr *cdp_get_vdev_struct_mac_addr 330 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 331 { 332 if (soc->ops->cmn_drv_ops->txrx_get_vdev_struct_mac_addr) 333 return soc->ops->cmn_drv_ops->txrx_get_vdev_struct_mac_addr 334 (vdev); 335 return NULL; 336 } 337 338 /** 339 * cdp_get_pdev_from_vdev() - Return handle to pdev of vdev 340 * @vdev: vdev handle 341 * 342 * Return: Handle to pdev 343 */ 344 static inline struct cdp_pdev *cdp_get_pdev_from_vdev 345 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 346 { 347 if (soc->ops->cmn_drv_ops->txrx_get_pdev_from_vdev) 348 return soc->ops->cmn_drv_ops->txrx_get_pdev_from_vdev(vdev); 349 return NULL; 350 } 351 352 /** 353 * cdp_get_ctrl_pdev_from_vdev() - Return control pdev of vdev 354 * @vdev: vdev handle 355 * 356 * Return: Handle to control pdev 357 */ 358 static inline struct cdp_cfg * 359 cdp_get_ctrl_pdev_from_vdev(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 360 { 361 if (soc->ops->cmn_drv_ops->txrx_get_ctrl_pdev_from_vdev) 362 return soc->ops->cmn_drv_ops->txrx_get_ctrl_pdev_from_vdev 363 (vdev); 364 return NULL; 365 } 366 367 static inline struct cdp_vdev * 368 cdp_get_vdev_from_vdev_id(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 369 uint8_t vdev_id) 370 { 371 if (soc->ops->cmn_drv_ops->txrx_get_vdev_from_vdev_id) 372 return soc->ops->cmn_drv_ops->txrx_get_vdev_from_vdev_id 373 (pdev, vdev_id); 374 return NULL; 375 } 376 377 static inline void 378 cdp_soc_detach(ol_txrx_soc_handle soc) 379 { 380 if (soc->ops->cmn_drv_ops->txrx_soc_detach) 381 return soc->ops->cmn_drv_ops->txrx_soc_detach((void *)soc); 382 return; 383 } 384 385 static inline int cdp_addba_requestprocess(ol_txrx_soc_handle soc, 386 void *peer_handle, uint8_t dialogtoken, uint16_t tid, 387 uint16_t batimeout, uint16_t buffersize, uint16_t startseqnum) 388 { 389 if (soc->ops->cmn_drv_ops->addba_requestprocess) 390 return soc->ops->cmn_drv_ops->addba_requestprocess(peer_handle, 391 dialogtoken, tid, batimeout, buffersize, startseqnum); 392 return 0; 393 } 394 395 static inline void cdp_addba_responsesetup(ol_txrx_soc_handle soc, 396 void *peer_handle, uint8_t tid, uint8_t *dialogtoken, 397 uint16_t *statuscode, uint16_t *buffersize, uint16_t *batimeout) 398 { 399 if (soc->ops->cmn_drv_ops->addba_responsesetup) 400 soc->ops->cmn_drv_ops->addba_responsesetup(peer_handle, tid, 401 dialogtoken, statuscode, buffersize, batimeout); 402 } 403 404 static inline int cdp_delba_process(ol_txrx_soc_handle soc, 405 void *peer_handle, int tid, uint16_t reasoncode) 406 { 407 if (soc->ops->cmn_drv_ops->delba_process) 408 return soc->ops->cmn_drv_ops->delba_process(peer_handle, 409 tid, reasoncode); 410 return 0; 411 } 412 413 /** 414 * cdp_get_peer_mac_addr_frm_id: function to return vdev id and and peer 415 * mac address 416 * @soc: SOC handle 417 * @peer_id: peer id of the peer for which mac_address is required 418 * @mac_addr: reference to mac address 419 * 420 * reutm: vdev_id of the vap 421 */ 422 static inline uint8_t 423 cdp_get_peer_mac_addr_frm_id(ol_txrx_soc_handle soc, uint16_t peer_id, 424 uint8_t *mac_addr) 425 { 426 if (soc->ops->cmn_drv_ops->get_peer_mac_addr_frm_id) 427 return soc->ops->cmn_drv_ops->get_peer_mac_addr_frm_id(soc, 428 peer_id, mac_addr); 429 return CDP_INVALID_VDEV_ID; 430 } 431 432 /** 433 * cdp_set_vdev_dscp_tid_map(): function to set DSCP-tid map in the vap 434 * @vdev: vdev handle 435 * @map_id: id of the tid map 436 * 437 * Return: void 438 */ 439 static inline void cdp_set_vdev_dscp_tid_map(ol_txrx_soc_handle soc, 440 struct cdp_vdev *vdev, uint8_t map_id) 441 { 442 if (soc->ops->cmn_drv_ops->set_vdev_dscp_tid_map) 443 return soc->ops->cmn_drv_ops->set_vdev_dscp_tid_map(vdev, 444 map_id); 445 return; 446 } 447 448 /** 449 * cdp_set_pdev_dscp_tid_map(): function to change tid values in DSCP-tid map 450 * @pdev: pdev handle 451 * @map_id: id of the tid map 452 * @tos: index value in map that needs to be changed 453 * @tid: tid value passed by user 454 * 455 * Return: void 456 */ 457 static inline void cdp_set_pdev_dscp_tid_map(ol_txrx_soc_handle soc, 458 struct cdp_pdev *pdev, uint8_t map_id, uint8_t tos, uint8_t tid) 459 { 460 if (soc->ops->cmn_drv_ops->set_pdev_dscp_tid_map) { 461 return soc->ops->cmn_drv_ops->set_pdev_dscp_tid_map(pdev, 462 map_id, tos, tid); 463 } 464 return; 465 } 466 467 /** 468 * cdp_flush_cache_rx_queue() - flush cache rx queue frame 469 * 470 * Return: None 471 */ 472 static inline void cdp_flush_cache_rx_queue(ol_txrx_soc_handle soc) 473 { 474 if (soc->ops->cmn_drv_ops->flush_cache_rx_queue) 475 soc->ops->cmn_drv_ops->flush_cache_rx_queue(); 476 } 477 478 /** 479 * cdp_txrx_stats(): function to map to host and firmware statistics 480 * @soc: soc handle 481 * @vdev: virtual device 482 * @req: statistics request handle 483 * @stats: statistics option 484 * 485 * return: status 486 */ 487 static inline 488 int cdp_txrx_stats(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 489 struct ol_txrx_stats_req *req, enum cdp_stats stats) 490 { 491 if (soc->ops->cmn_drv_ops->txrx_stats) 492 return soc->ops->cmn_drv_ops->txrx_stats(vdev, req, stats); 493 return 0; 494 } 495 496 /** 497 * cdp_display_stats(): function to map to dump stats 498 * @soc: soc handle 499 * @value: statistics option 500 */ 501 static inline QDF_STATUS 502 cdp_display_stats(ol_txrx_soc_handle soc, uint16_t value) 503 { 504 if (soc->ops->cmn_drv_ops->display_stats) 505 return soc->ops->cmn_drv_ops->display_stats(soc, value); 506 507 return 0; 508 } 509 #endif /* _CDP_TXRX_CMN_H_ */ 510