1 /* 2 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. 3 * 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #include "qdf_mem.h" 21 #include "wlan_lmac_if_def.h" 22 #include "wlan_lmac_if_api.h" 23 #include "wlan_mgmt_txrx_tgt_api.h" 24 #include "wlan_scan_tgt_api.h" 25 #include <wlan_reg_services_api.h> 26 #include <wlan_reg_ucfg_api.h> 27 #ifdef WLAN_ATF_ENABLE 28 #include "wlan_atf_tgt_api.h" 29 #endif 30 #ifdef WLAN_SA_API_ENABLE 31 #include "wlan_sa_api_tgt_api.h" 32 #endif 33 #ifdef WIFI_POS_CONVERGED 34 #include "target_if_wifi_pos.h" 35 #endif /* WIFI_POS_CONVERGED */ 36 #ifdef WLAN_FEATURE_NAN_CONVERGENCE 37 #include "target_if_nan.h" 38 #endif /* WLAN_FEATURE_NAN_CONVERGENCE */ 39 #include "wlan_reg_tgt_api.h" 40 #ifdef CONVERGED_P2P_ENABLE 41 #include "wlan_p2p_tgt_api.h" 42 #endif 43 #ifdef CONVERGED_TDLS_ENABLE 44 #include "wlan_tdls_tgt_api.h" 45 #endif 46 47 #ifdef WLAN_CONV_CRYPTO_SUPPORTED 48 #include "wlan_crypto_global_api.h" 49 #endif 50 #ifdef DFS_COMPONENT_ENABLE 51 #include <wlan_dfs_tgt_api.h> 52 #include <wlan_dfs_utils_api.h> 53 #endif 54 55 #ifdef WLAN_SUPPORT_GREEN_AP 56 #include <wlan_green_ap_api.h> 57 #include <wlan_green_ap_ucfg_api.h> 58 #endif 59 #include <wlan_ftm_ucfg_api.h> 60 61 #ifdef WLAN_SUPPORT_FILS 62 #include <wlan_fd_tgt_api.h> 63 #endif 64 65 /* Function pointer for OL/WMA specific UMAC tx_ops 66 * registration. 67 */ 68 QDF_STATUS (*wlan_lmac_if_umac_tx_ops_register) 69 (struct wlan_lmac_if_tx_ops *tx_ops); 70 EXPORT_SYMBOL(wlan_lmac_if_umac_tx_ops_register); 71 72 #ifdef WLAN_ATF_ENABLE 73 /** 74 * wlan_lmac_if_atf_rx_ops_register() - Function to register ATF RX ops. 75 */ 76 static void 77 wlan_lmac_if_atf_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 78 { 79 struct wlan_lmac_if_atf_rx_ops *atf_rx_ops = &rx_ops->atf_rx_ops; 80 81 /* ATF rx ops */ 82 atf_rx_ops->atf_get_atf_commit = tgt_atf_get_atf_commit; 83 atf_rx_ops->atf_get_fmcap = tgt_atf_get_fmcap; 84 atf_rx_ops->atf_get_obss_scale = tgt_atf_get_obss_scale; 85 atf_rx_ops->atf_get_mode = tgt_atf_get_mode; 86 atf_rx_ops->atf_get_msdu_desc = tgt_atf_get_msdu_desc; 87 atf_rx_ops->atf_get_max_vdevs = tgt_atf_get_max_vdevs; 88 atf_rx_ops->atf_get_peers = tgt_atf_get_peers; 89 atf_rx_ops->atf_get_tput_based = tgt_atf_get_tput_based; 90 atf_rx_ops->atf_get_logging = tgt_atf_get_logging; 91 atf_rx_ops->atf_get_txbuf_share = tgt_atf_get_txbuf_share; 92 atf_rx_ops->atf_get_txbuf_max = tgt_atf_get_txbuf_max; 93 atf_rx_ops->atf_get_txbuf_min = tgt_atf_get_txbuf_min; 94 atf_rx_ops->atf_get_ssidgroup = tgt_atf_get_ssidgroup; 95 atf_rx_ops->atf_get_tx_block_count = tgt_atf_get_tx_block_count; 96 atf_rx_ops->atf_get_peer_blk_txtraffic = tgt_atf_get_peer_blk_txtraffic; 97 atf_rx_ops->atf_get_vdev_blk_txtraffic = tgt_atf_get_vdev_blk_txtraffic; 98 atf_rx_ops->atf_get_sched = tgt_atf_get_sched; 99 atf_rx_ops->atf_get_tx_tokens = tgt_atf_get_tx_tokens; 100 atf_rx_ops->atf_get_shadow_tx_tokens = tgt_atf_get_shadow_tx_tokens; 101 atf_rx_ops->atf_get_shadow_alloted_tx_tokens = 102 tgt_atf_get_shadow_alloted_tx_tokens; 103 atf_rx_ops->atf_get_txtokens_common = tgt_atf_get_txtokens_common; 104 atf_rx_ops->atf_get_peer_stats = tgt_atf_get_peer_stats; 105 atf_rx_ops->atf_get_token_allocated = tgt_atf_get_token_allocated; 106 atf_rx_ops->atf_get_token_utilized = tgt_atf_get_token_utilized; 107 108 atf_rx_ops->atf_set_sched = tgt_atf_set_sched; 109 atf_rx_ops->atf_set_fmcap = tgt_atf_set_fmcap; 110 atf_rx_ops->atf_set_obss_scale = tgt_atf_set_obss_scale; 111 atf_rx_ops->atf_set_mode = tgt_atf_set_mode; 112 atf_rx_ops->atf_set_msdu_desc = tgt_atf_set_msdu_desc; 113 atf_rx_ops->atf_set_max_vdevs = tgt_atf_set_max_vdevs; 114 atf_rx_ops->atf_set_peers = tgt_atf_set_peers; 115 atf_rx_ops->atf_set_peer_stats = tgt_atf_set_peer_stats; 116 atf_rx_ops->atf_set_vdev_blk_txtraffic = tgt_atf_set_vdev_blk_txtraffic; 117 atf_rx_ops->atf_set_peer_blk_txtraffic = tgt_atf_set_peer_blk_txtraffic; 118 atf_rx_ops->atf_set_tx_block_count = tgt_atf_set_tx_block_count; 119 atf_rx_ops->atf_set_token_allocated = tgt_atf_set_token_allocated; 120 atf_rx_ops->atf_set_token_utilized = tgt_atf_set_token_utilized; 121 } 122 #else 123 static void 124 wlan_lmac_if_atf_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 125 { 126 } 127 #endif 128 129 #ifdef WLAN_SUPPORT_FILS 130 static void 131 wlan_lmac_if_fd_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 132 { 133 struct wlan_lmac_if_fd_rx_ops *fd_rx_ops = &rx_ops->fd_rx_ops; 134 135 fd_rx_ops->fd_is_fils_enable = tgt_fd_is_fils_enable; 136 fd_rx_ops->fd_alloc = tgt_fd_alloc; 137 fd_rx_ops->fd_stop = tgt_fd_stop; 138 fd_rx_ops->fd_free = tgt_fd_free; 139 fd_rx_ops->fd_get_valid_fd_period = tgt_fd_get_valid_fd_period; 140 fd_rx_ops->fd_swfda_handler = tgt_fd_swfda_handler; 141 } 142 #else 143 static void 144 wlan_lmac_if_fd_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 145 { 146 } 147 #endif 148 149 #ifdef WLAN_SA_API_ENABLE 150 /** 151 * wlan_lmac_if_sa_api_rx_ops_register() - Function to register SA_API RX ops. 152 */ 153 static void 154 wlan_lmac_if_sa_api_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 155 { 156 struct wlan_lmac_if_sa_api_rx_ops *sa_api_rx_ops = &rx_ops->sa_api_rx_ops; 157 158 /* SA API rx ops */ 159 sa_api_rx_ops->sa_api_get_sa_supported = tgt_sa_api_get_sa_supported; 160 sa_api_rx_ops->sa_api_get_validate_sw = tgt_sa_api_get_validate_sw; 161 sa_api_rx_ops->sa_api_enable_sa = tgt_sa_api_enable_sa; 162 sa_api_rx_ops->sa_api_get_sa_enable = tgt_sa_api_get_sa_enable; 163 164 sa_api_rx_ops->sa_api_peer_assoc_hanldler = tgt_sa_api_peer_assoc_hanldler; 165 sa_api_rx_ops->sa_api_update_tx_feedback = tgt_sa_api_update_tx_feedback; 166 sa_api_rx_ops->sa_api_update_rx_feedback = tgt_sa_api_update_rx_feedback; 167 168 sa_api_rx_ops->sa_api_ucfg_set_param = tgt_sa_api_ucfg_set_param; 169 sa_api_rx_ops->sa_api_ucfg_get_param = tgt_sa_api_ucfg_get_param; 170 171 sa_api_rx_ops->sa_api_is_tx_feedback_enabled = tgt_sa_api_is_tx_feedback_enabled; 172 sa_api_rx_ops->sa_api_is_rx_feedback_enabled = tgt_sa_api_is_rx_feedback_enabled; 173 174 sa_api_rx_ops->sa_api_convert_rate_2g = tgt_sa_api_convert_rate_2g; 175 sa_api_rx_ops->sa_api_convert_rate_5g = tgt_sa_api_convert_rate_5g; 176 sa_api_rx_ops->sa_api_get_sa_mode = tgt_sa_api_get_sa_mode; 177 178 sa_api_rx_ops->sa_api_get_beacon_txantenna = tgt_sa_api_get_beacon_txantenna; 179 sa_api_rx_ops->sa_api_cwm_action = tgt_sa_api_cwm_action; 180 } 181 #else 182 static void 183 wlan_lmac_if_sa_api_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 184 { 185 } 186 #endif 187 188 189 #ifdef WLAN_CONV_CRYPTO_SUPPORTED 190 static void 191 wlan_lmac_if_crypto_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 192 { 193 wlan_crypto_register_crypto_rx_ops(&rx_ops->crypto_rx_ops); 194 } 195 #else 196 static void 197 wlan_lmac_if_crypto_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 198 { 199 } 200 #endif 201 202 #ifdef WIFI_POS_CONVERGED 203 static void wlan_lmac_if_umac_rx_ops_register_wifi_pos( 204 struct wlan_lmac_if_rx_ops *rx_ops) 205 { 206 target_if_wifi_pos_register_rx_ops(rx_ops); 207 } 208 #else 209 static void wlan_lmac_if_umac_rx_ops_register_wifi_pos( 210 struct wlan_lmac_if_rx_ops *rx_ops) 211 { 212 } 213 #endif /* WIFI_POS_CONVERGED */ 214 215 #ifdef WLAN_FEATURE_NAN_CONVERGENCE 216 static void wlan_lmac_if_register_nan_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops) 217 { 218 target_if_nan_register_rx_ops(rx_ops); 219 } 220 #else 221 static void wlan_lmac_if_register_nan_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops) 222 { 223 } 224 #endif /* WLAN_FEATURE_NAN_CONVERGENCE */ 225 226 static void wlan_lmac_if_umac_reg_rx_ops_register( 227 struct wlan_lmac_if_rx_ops *rx_ops) 228 { 229 rx_ops->reg_rx_ops.master_list_handler = 230 tgt_reg_process_master_chan_list; 231 232 rx_ops->reg_rx_ops.reg_11d_new_cc_handler = 233 tgt_reg_process_11d_new_country; 234 235 rx_ops->reg_rx_ops.reg_set_regdb_offloaded = 236 tgt_reg_set_regdb_offloaded; 237 238 rx_ops->reg_rx_ops.reg_set_11d_offloaded = 239 tgt_reg_set_11d_offloaded; 240 241 rx_ops->reg_rx_ops.get_dfs_region = 242 wlan_reg_get_dfs_region; 243 244 rx_ops->reg_rx_ops.reg_ch_avoid_event_handler = 245 tgt_reg_process_ch_avoid_event; 246 247 rx_ops->reg_rx_ops.reg_freq_to_chan = 248 wlan_reg_freq_to_chan; 249 250 rx_ops->reg_rx_ops.reg_set_chan_144 = 251 ucfg_reg_modify_chan_144; 252 253 rx_ops->reg_rx_ops.reg_get_chan_144 = 254 ucfg_reg_get_en_chan_144; 255 256 rx_ops->reg_rx_ops.reg_program_default_cc = 257 ucfg_reg_program_default_cc; 258 259 rx_ops->reg_rx_ops.reg_get_current_regdomain = 260 wlan_reg_get_curr_regdomain; 261 } 262 263 #ifdef CONVERGED_P2P_ENABLE 264 static void wlan_lmac_if_umac_rx_ops_register_p2p( 265 struct wlan_lmac_if_rx_ops *rx_ops) 266 { 267 rx_ops->p2p.lo_ev_handler = tgt_p2p_lo_event_cb; 268 rx_ops->p2p.noa_ev_handler = tgt_p2p_noa_event_cb; 269 } 270 #else 271 static void wlan_lmac_if_umac_rx_ops_register_p2p( 272 struct wlan_lmac_if_rx_ops *rx_ops) 273 { 274 } 275 #endif 276 277 #ifdef DFS_COMPONENT_ENABLE 278 static QDF_STATUS 279 wlan_lmac_if_umac_dfs_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 280 { 281 struct wlan_lmac_if_dfs_rx_ops *dfs_rx_ops; 282 283 dfs_rx_ops = &rx_ops->dfs_rx_ops; 284 285 dfs_rx_ops->dfs_get_radars = tgt_dfs_get_radars; 286 dfs_rx_ops->dfs_process_phyerr = tgt_dfs_process_phyerr; 287 dfs_rx_ops->dfs_destroy_object = tgt_dfs_destroy_object; 288 dfs_rx_ops->dfs_radar_enable = tgt_dfs_radar_enable; 289 dfs_rx_ops->dfs_control = tgt_dfs_control; 290 dfs_rx_ops->dfs_is_precac_timer_running = 291 tgt_dfs_is_precac_timer_running; 292 dfs_rx_ops->dfs_find_vht80_chan_for_precac = 293 tgt_dfs_find_vht80_chan_for_precac; 294 dfs_rx_ops->dfs_cancel_precac_timer = utils_dfs_cancel_precac_timer; 295 dfs_rx_ops->dfs_override_precac_timeout = 296 ucfg_dfs_override_precac_timeout; 297 dfs_rx_ops->dfs_set_precac_enable = ucfg_dfs_set_precac_enable; 298 dfs_rx_ops->dfs_get_precac_enable = ucfg_dfs_get_precac_enable; 299 dfs_rx_ops->dfs_get_override_precac_timeout = 300 ucfg_dfs_get_override_precac_timeout; 301 dfs_rx_ops->dfs_set_current_channel = tgt_dfs_set_current_channel; 302 dfs_rx_ops->dfs_process_radar_ind = tgt_dfs_process_radar_ind; 303 dfs_rx_ops->dfs_dfs_cac_complete_ind = tgt_dfs_cac_complete; 304 dfs_rx_ops->dfs_stop = tgt_dfs_stop; 305 dfs_rx_ops->dfs_process_phyerr_filter_offload = 306 tgt_dfs_process_phyerr_filter_offload; 307 dfs_rx_ops->dfs_is_phyerr_filter_offload = 308 tgt_dfs_is_phyerr_filter_offload; 309 310 return QDF_STATUS_SUCCESS; 311 } 312 #else 313 static QDF_STATUS 314 wlan_lmac_if_umac_dfs_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 315 { 316 return QDF_STATUS_SUCCESS; 317 } 318 #endif 319 320 #ifdef CONVERGED_TDLS_ENABLE 321 static QDF_STATUS 322 wlan_lmac_if_umac_tdls_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 323 { 324 rx_ops->tdls_rx_ops.tdls_ev_handler = tgt_tdls_event_handler; 325 326 return QDF_STATUS_SUCCESS; 327 } 328 #else 329 static QDF_STATUS 330 wlan_lmac_if_umac_tdls_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 331 { 332 return QDF_STATUS_SUCCESS; 333 } 334 #endif 335 336 #ifdef WLAN_SUPPORT_GREEN_AP 337 static QDF_STATUS 338 wlan_lmac_if_umac_green_ap_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 339 { 340 rx_ops->green_ap_rx_ops.is_ps_enabled = wlan_green_ap_is_ps_enabled; 341 rx_ops->green_ap_rx_ops.is_dbg_print_enabled = 342 ucfg_green_ap_get_debug_prints; 343 rx_ops->green_ap_rx_ops.ps_set = ucfg_green_ap_set_ps_config; 344 rx_ops->green_ap_rx_ops.ps_get = ucfg_green_ap_get_ps_config; 345 rx_ops->green_ap_rx_ops.suspend_handle = wlan_green_ap_suspend_handle; 346 347 return QDF_STATUS_SUCCESS; 348 } 349 #else 350 static QDF_STATUS 351 wlan_lmac_if_umac_green_ap_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 352 { 353 return QDF_STATUS_SUCCESS; 354 } 355 #endif 356 357 static QDF_STATUS 358 wlan_lmac_if_umac_ftm_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 359 { 360 struct wlan_lmac_if_ftm_rx_ops *ftm_rx_ops; 361 362 ftm_rx_ops = &rx_ops->ftm_rx_ops; 363 364 ftm_rx_ops->ftm_ev_handler = wlan_ftm_process_utf_event; 365 366 return QDF_STATUS_SUCCESS; 367 } 368 369 /** 370 * wlan_lmac_if_umac_rx_ops_register() - UMAC rx handler register 371 * @rx_ops: Pointer to rx_ops structure to be populated 372 * 373 * Register umac RX callabacks which will be called by DA/OL/WMA/WMI 374 * 375 * Return: QDF_STATUS_SUCCESS - in case of success 376 */ 377 QDF_STATUS 378 wlan_lmac_if_umac_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 379 { 380 /* Component specific public api's to be called to register 381 * respective callbacks 382 * Ex: rx_ops->fp = function; 383 */ 384 struct wlan_lmac_if_mgmt_txrx_rx_ops *mgmt_txrx_rx_ops; 385 386 if (!rx_ops) { 387 qdf_print("%s: lmac if rx ops pointer is NULL", __func__); 388 return QDF_STATUS_E_INVAL; 389 } 390 391 /* mgmt txrx rx ops */ 392 mgmt_txrx_rx_ops = &rx_ops->mgmt_txrx_rx_ops; 393 394 mgmt_txrx_rx_ops->mgmt_tx_completion_handler = 395 tgt_mgmt_txrx_tx_completion_handler; 396 mgmt_txrx_rx_ops->mgmt_rx_frame_handler = 397 tgt_mgmt_txrx_rx_frame_handler; 398 mgmt_txrx_rx_ops->mgmt_txrx_get_nbuf_from_desc_id = 399 tgt_mgmt_txrx_get_nbuf_from_desc_id; 400 mgmt_txrx_rx_ops->mgmt_txrx_get_peer_from_desc_id = 401 tgt_mgmt_txrx_get_peer_from_desc_id; 402 mgmt_txrx_rx_ops->mgmt_txrx_get_vdev_id_from_desc_id = 403 tgt_mgmt_txrx_get_vdev_id_from_desc_id; 404 mgmt_txrx_rx_ops->mgmt_txrx_get_free_desc_pool_count = 405 tgt_mgmt_txrx_get_free_desc_pool_count; 406 407 /* scan rx ops */ 408 rx_ops->scan.scan_ev_handler = tgt_scan_event_handler; 409 rx_ops->scan.scan_set_max_active_scans = tgt_scan_set_max_active_scans; 410 411 wlan_lmac_if_atf_rx_ops_register(rx_ops); 412 413 wlan_lmac_if_sa_api_rx_ops_register(rx_ops); 414 415 wlan_lmac_if_crypto_rx_ops_register(rx_ops); 416 /* wifi_pos rx ops */ 417 wlan_lmac_if_umac_rx_ops_register_wifi_pos(rx_ops); 418 419 /* tdls rx ops */ 420 wlan_lmac_if_umac_tdls_rx_ops_register(rx_ops); 421 422 wlan_lmac_if_register_nan_rx_ops(rx_ops); 423 424 wlan_lmac_if_umac_reg_rx_ops_register(rx_ops); 425 426 /* p2p rx ops */ 427 wlan_lmac_if_umac_rx_ops_register_p2p(rx_ops); 428 429 /* DFS rx_ops */ 430 wlan_lmac_if_umac_dfs_rx_ops_register(rx_ops); 431 432 wlan_lmac_if_umac_green_ap_rx_ops_register(rx_ops); 433 434 /* FTM rx_ops */ 435 wlan_lmac_if_umac_ftm_rx_ops_register(rx_ops); 436 437 /* FILS Discovery */ 438 wlan_lmac_if_fd_rx_ops_register(rx_ops); 439 440 return QDF_STATUS_SUCCESS; 441 } 442 443 /** 444 * wlan_lmac_if_set_umac_txops_registration_cb() - tx registration 445 * callback assignment 446 * @dev_type: Dev type can be either Direct attach or Offload 447 * @handler: handler to be called for LMAC tx ops registration 448 * 449 * API to assign appropriate tx registration callback handler based on the 450 * device type(Offload or Direct attach) 451 * 452 * Return: QDF_STATUS_SUCCESS - in case of success 453 */ 454 QDF_STATUS wlan_lmac_if_set_umac_txops_registration_cb(QDF_STATUS (*handler) 455 (struct wlan_lmac_if_tx_ops *)) 456 { 457 wlan_lmac_if_umac_tx_ops_register = handler; 458 return QDF_STATUS_SUCCESS; 459 } 460 EXPORT_SYMBOL(wlan_lmac_if_set_umac_txops_registration_cb); 461 462