diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 094b43eaf84b..883649ba38ae 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -1973,14 +1973,6 @@ int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, enum nl80211_hidden_ssid hidden_ssid, bool check_for_concurrency, bool update_beacon); -#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH -QDF_STATUS hdd_register_for_sap_restart_with_channel_switch(void); -#else -static inline QDF_STATUS hdd_register_for_sap_restart_with_channel_switch(void) -{ - return QDF_STATUS_SUCCESS; -} -#endif #if !defined(REMOVE_PKT_LOG) int hdd_process_pktlog_command(hdd_context_t *hdd_ctx, uint32_t set_value, @@ -2298,6 +2290,7 @@ static inline void hdd_send_peer_status_ind_to_app( * Return: 0 sucess else failure */ int wlan_hdd_send_p2p_quota(hdd_adapter_t *adapter, int sval); + /** * wlan_hdd_send_p2p_quota()- Send MCC latency to FW * @adapter: Adapter data @@ -2308,4 +2301,17 @@ int wlan_hdd_send_p2p_quota(hdd_adapter_t *adapter, int sval); * Return: 0 sucess else failure */ int wlan_hdd_send_mcc_latency(hdd_adapter_t *adapter, int sval); + +/** + * wlan_hdd_get_adapter_from_vdev()- Get adapter from vdev id + * and PSOC object data + * @psoc: Psoc object data + * @vdev_id: vdev id + * + * Get adapter from vdev id and PSOC object data + * + * Return: adapter pointer + */ +hdd_adapter_t *wlan_hdd_get_adapter_from_vdev(struct wlan_objmgr_psoc + *psoc, uint8_t vdev_id); #endif /* end #if !defined(WLAN_HDD_MAIN_H) */ diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 7c59d9f20aff..b8b0175de02c 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -2354,6 +2354,81 @@ void hdd_sap_restart_with_channel_switch(hdd_adapter_t *ap_adapter, return; } } + +void sap_restart_chan_switch_cb (struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, uint32_t channel, + uint32_t channel_bw) +{ + hdd_adapter_t *ap_adapter = wlan_hdd_get_adapter_from_vdev( + psoc, vdev_id); + if (!ap_adapter) { + hdd_err("Adapter is NULL"); + return; + } + hdd_sap_restart_with_channel_switch(ap_adapter, channel, + channel_bw); +} + +QDF_STATUS wlan_hdd_get_channel_for_sap_restart( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, uint8_t *channel, + uint8_t *sec_ch, bool restart_sap) +{ + tHalHandle *hal_handle; + hdd_ap_ctx_t *hdd_ap_ctx; + uint16_t intf_ch = 0; + + hdd_adapter_t *ap_adapter = wlan_hdd_get_adapter_from_vdev( + psoc, vdev_id); + if (!ap_adapter) { + hdd_err("Adapter is NULL"); + return QDF_STATUS_E_FAILURE; + } + + if (NULL == channel || NULL == sec_ch) { + hdd_err("Null parameters"); + } + + if (!test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) + return QDF_STATUS_E_FAILURE; + + hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); + hal_handle = WLAN_HDD_GET_HAL_CTX(ap_adapter); + + if (!hal_handle) + return QDF_STATUS_E_FAILURE; + + intf_ch = wlansap_check_cc_intf(hdd_ap_ctx->sapContext); + hdd_info("intf_ch: %d", intf_ch); + + if (intf_ch == 0) { + hdd_err("interface channel is 0"); + return QDF_STATUS_E_FAILURE; + } + + hdd_info("SAP restart orig chan: %d, new chan: %d", + hdd_ap_ctx->sapConfig.channel, intf_ch); + hdd_ap_ctx->sapConfig.channel = intf_ch; + hdd_ap_ctx->sapConfig.ch_params.ch_width = + hdd_ap_ctx->sapConfig.ch_width_orig; + hdd_ap_ctx->bss_stop_reason = BSS_STOP_DUE_TO_MCC_SCC_SWITCH; + + cds_set_channel_params(hdd_ap_ctx->sapConfig.channel, + hdd_ap_ctx->sapConfig.sec_ch, + &hdd_ap_ctx->sapConfig.ch_params); + *channel = hdd_ap_ctx->sapConfig.channel; + *sec_ch = hdd_ap_ctx->sapConfig.sec_ch; + + if (restart_sap) { + hdd_info("Restart SAP as a part of channel switch"); + sap_restart_chan_switch_cb(psoc, vdev_id, + hdd_ap_ctx->sapConfig.channel, + hdd_ap_ctx->sapConfig.ch_params.ch_width); + + } + + return QDF_STATUS_SUCCESS; +} #endif int diff --git a/core/hdd/src/wlan_hdd_hostapd.h b/core/hdd/src/wlan_hdd_hostapd.h index 50542d497950..ab5c2a7dba38 100644 --- a/core/hdd/src/wlan_hdd_hostapd.h +++ b/core/hdd/src/wlan_hdd_hostapd.h @@ -67,6 +67,39 @@ int hdd_softap_set_channel_change(struct net_device *dev, void hdd_sap_restart_with_channel_switch(hdd_adapter_t *adapter, uint32_t target_channel, uint32_t target_bw); +/** + * sap_restart_chan_switch_cb() - Function to restart SAP with + * a different channel + * @psoc: PSOC object information + * @vdev_id: vdev id + * @channel: channel to switch + * + * This function restarts SAP with a different channel + * + * Return: None + * + */ +void sap_restart_chan_switch_cb (struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, uint32_t channel, + uint32_t channel_bw); +/** + * wlan_hdd_get_channel_for_sap_restart() - Function to get + * suitable channel and restart SAP + * @psoc: PSOC object information + * @vdev_id: vdev id + * @channel: channel to be returned + * @sec_ch: secondary channel to be returned + * @restart_sap: restsart SAP as a part of channel switch + * + * This function gets the channel parameters to restart SAP + * + * Return: None + * + */ +QDF_STATUS wlan_hdd_get_channel_for_sap_restart( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, uint8_t *channel, + uint8_t *sec_ch, bool restart_sap); #endif eCsrEncryptionType diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 38a190f6abcc..e2bb0936f2d5 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -1879,6 +1879,27 @@ hdd_update_cds_ac_specs_params(hdd_context_t *hdd_ctx) } } +#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH +static void hdd_register_policy_manager_callback( + struct wlan_objmgr_psoc *psoc) +{ + struct policy_mgr_hdd_cbacks hdd_cbacks; + hdd_cbacks.sap_restart_chan_switch_cb = + sap_restart_chan_switch_cb; + hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = + wlan_hdd_get_channel_for_sap_restart; + if (QDF_STATUS_SUCCESS != + policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { + hdd_err("HDD callback registration with policy manager failed"); + } +} +#else +static void hdd_register_policy_manager_callback( + struct wlan_objmgr_psoc *psoc) +{ +} +#endif + /** * hdd_wlan_start_modules() - Single driver state machine for starting modules * @hdd_ctx: HDD context @@ -2000,6 +2021,9 @@ int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, goto close; } + hdd_register_policy_manager_callback( + hdd_ctx->hdd_psoc); + hdd_update_hw_sw_info(hdd_ctx); hdd_ctx->driver_status = DRIVER_MODULES_OPENED; @@ -8008,37 +8032,6 @@ int hdd_pktlog_enable_disable(hdd_context_t *hdd_ctx, bool enable, } #endif /* REMOVE_PKT_LOG */ - -#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH -/** - * hdd_register_for_sap_restart_with_channel_switch() - Register for SAP channel - * switch without restart - * - * Registers callback function to change the operating channel of SAP by using - * channel switch announcements instead of restarting SAP. - * - * Return: QDF_STATUS - */ -QDF_STATUS hdd_register_for_sap_restart_with_channel_switch(void) -{ - QDF_STATUS status; - hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); - if (!hdd_ctx) { - hdd_err("hdd ctx is NULL"); - return QDF_STATUS_E_FAILURE; - } - - - status = policy_mgr_register_sap_restart_channel_switch_cb( - hdd_ctx->hdd_psoc, - (void *)hdd_sap_restart_with_channel_switch); - if (!QDF_IS_STATUS_SUCCESS(status)) - hdd_err("restart cb registration failed"); - - return status; -} -#endif - /** * hdd_get_platform_wlan_mac_buff() - API to query platform driver * for MAC address @@ -8688,6 +8681,21 @@ static int hdd_deconfigure_cds(hdd_context_t *hdd_ctx) return ret; } +#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH +static void hdd_deregister_policy_manager_callback( + struct wlan_objmgr_psoc *psoc) +{ + if (QDF_STATUS_SUCCESS != + policy_mgr_deregister_hdd_cb(psoc)) { + hdd_err("HDD callback deregister with policy manager failed"); + } +} +#else +static void hdd_deregister_policy_manager_callback( + struct wlan_objmgr_psoc *psoc) +{ +} +#endif /** * hdd_wlan_stop_modules - Single driver state machine for stoping modules @@ -8709,6 +8717,8 @@ int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx) ENTER(); + hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); + qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); if (!qdf_ctx) { hdd_err("QDF device context NULL"); @@ -9147,15 +9157,6 @@ int hdd_register_cb(hdd_context_t *hdd_ctx) sme_ext_scan_register_callback(hdd_ctx->hHal, wlan_hdd_cfg80211_extscan_callback); - status = policy_mgr_register_sap_restart_channel_switch_cb( - hdd_ctx->hdd_psoc, - (void *)hdd_sap_restart_with_channel_switch); - if (!QDF_IS_STATUS_SUCCESS(status)) { - hdd_err("restart cb registration failed"); - ret = -EINVAL; - return ret; - } - sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, hdd_rssi_threshold_breached); @@ -9200,12 +9201,6 @@ void hdd_deregister_cb(hdd_context_t *hdd_ctx) sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); - status = policy_mgr_deregister_sap_restart_channel_switch_cb( - hdd_ctx->hdd_psoc); - if (!QDF_IS_STATUS_SUCCESS(status)) - hdd_err("De-register restart cb registration failed: %d", - status); - sme_stats_ext_register_callback(hdd_ctx->hHal, wlan_hdd_cfg80211_stats_ext_callback); @@ -11253,6 +11248,25 @@ int wlan_hdd_send_mcc_latency(hdd_adapter_t *adapter, int set_value) return 0; } +hdd_adapter_t *wlan_hdd_get_adapter_from_vdev(struct wlan_objmgr_psoc + *psoc, uint8_t vdev_id) +{ + hdd_adapter_t *adapter = NULL; + hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + + /* + * Currently PSOC is not being used. But this logic will + * change once we have the converged implementation of + * HDD context per PSOC in place. This would break if + * multiple vdev objects reuse the vdev id. + */ + adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); + if (!adapter) + hdd_err("Get adapter by vdev id failed"); + + return adapter; +} + /* Register the module init/exit functions */ module_init(hdd_module_init); module_exit(hdd_module_exit);