diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 9a731a88cf..8f627d1e52 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -5179,6 +5179,15 @@ int hdd_dynamic_mac_address_set(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, struct qdf_mac_addr mac_addr); +/** + * hdd_is_dynamic_set_mac_addr_allowed() - API to check dynamic MAC address + * update is allowed or not + * @adapter: Pointer to the adapter structure + * + * Return: true or false + */ +bool hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter); + #if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC) /** * hdd_update_vdev_mac_address() - Update VDEV MAC address dynamically @@ -5215,6 +5224,13 @@ static inline int hdd_dynamic_mac_address_set(struct hdd_context *hdd_ctx, { return 0; } + +static inline bool +hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter) +{ + return false; +} + #endif /* WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE */ #ifdef FEATURE_WLAN_FULL_POWER_DOWN_SUPPORT diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 0682c3b1b3..6924988cb1 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -772,6 +772,9 @@ static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr) dev->name); if (adapter->vdev) { + if (!hdd_is_dynamic_set_mac_addr_allowed(adapter)) + return -ENOTSUPP; + ret = hdd_dynamic_mac_address_set(hdd_ctx, adapter, mac_addr); if (ret) return ret; diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index c0806dd4d2..03589f537f 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -5276,35 +5276,6 @@ static void hdd_update_set_mac_addr_req_ctx(struct hdd_adapter *adapter, } #endif -/** - * hdd_is_dynamic_set_mac_addr_allowed() - API to check dynamic MAC address - * update is allowed or not - * @adapter: Pointer to the adapter structure - * - * Return: true or false - */ -static bool hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter) -{ - if (!adapter->vdev) { - hdd_err("VDEV is NULL"); - return false; - } - - switch (adapter->device_mode) { - case QDF_STA_MODE: - if (!cm_is_vdev_disconnected(adapter->vdev)) { - hdd_err("VDEV is not in disconnected state, set mac address isn't supported"); - return false; - } - case QDF_P2P_DEVICE_MODE: - return true; - default: - hdd_err("Dynamic set mac address isn't supported for opmode:%d", - adapter->device_mode); - return false; - } -} - /** * hdd_is_dynamic_set_mac_addr_supported() - API to check dynamic MAC address * update is supported or not @@ -5318,6 +5289,40 @@ hdd_is_dynamic_set_mac_addr_supported(struct hdd_context *hdd_ctx) return hdd_ctx->is_vdev_macaddr_dynamic_update_supported; } +bool hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter) +{ + if (!adapter->vdev) { + hdd_err("VDEV is NULL"); + return false; + } + + if (!hdd_is_dynamic_set_mac_addr_supported(adapter->hdd_ctx)) { + hdd_info_rl("On iface up, set mac address change isn't supported"); + return false; + } + + switch (adapter->device_mode) { + case QDF_STA_MODE: + if (!cm_is_vdev_disconnected(adapter->vdev)) { + hdd_info_rl("VDEV is not in disconnected state, set mac address isn't supported"); + return false; + } + case QDF_P2P_DEVICE_MODE: + return true; + case QDF_SAP_MODE: + if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { + hdd_info_rl("SAP is in up state, set mac address isn't supported"); + return false; + } else { + return true; + } + default: + hdd_info_rl("Dynamic set mac address isn't supported for opmode:%d", + adapter->device_mode); + return false; + } +} + int hdd_dynamic_mac_address_set(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, struct qdf_mac_addr mac_addr) @@ -5423,12 +5428,6 @@ static void hdd_set_mac_addr_event_cb(uint8_t vdev_id, uint8_t status) osif_request_put(req); } #else -static inline bool -hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter) -{ - return false; -} - static inline bool hdd_is_dynamic_set_mac_addr_supported(struct hdd_context *hdd_ctx) { @@ -5465,13 +5464,8 @@ static int __hdd_set_mac_address(struct net_device *dev, void *addr) return ret; if (net_if_running) { - if (hdd_is_dynamic_set_mac_addr_supported(hdd_ctx)) { - if (!hdd_is_dynamic_set_mac_addr_allowed(adapter)) - return -ENOTSUPP; - } else { - hdd_err("On iface up, set mac address change isn't supported"); + if (!hdd_is_dynamic_set_mac_addr_allowed(adapter)) return -ENOTSUPP; - } } qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr));