Skip to content

Commit 1198d78

Browse files
nxf58150fabiobaltieri
authored andcommitted
hostap: Update 11k roaming mechanism
With this changes, device will check if AP support Neighbor Report or not before trigger roaming. No need to issue 11k command to enable 11k, if AP supports Neighbor Report, device will trigger 11k roaming with priority. Signed-off-by: Hui Bai <[email protected]>
1 parent 56e2b01 commit 1198d78

File tree

5 files changed

+47
-8
lines changed

5 files changed

+47
-8
lines changed

include/zephyr/net/wifi_mgmt.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,14 @@ struct wifi_mgmt_ops {
15941594
* @return 0 if ok, < 0 if error
15951595
*/
15961596
int (*btm_query)(const struct device *dev, uint8_t reason);
1597+
1598+
/** Check if ap support Neighbor Report or not.
1599+
* @param dev Pointer to the device structure for the driver instance.
1600+
*
1601+
* @return true if support, false if not support
1602+
*/
1603+
bool (*bss_support_neighbor_rep)(const struct device *dev);
1604+
15971605
/** Judge ap whether support the capability
15981606
*
15991607
* @param dev Pointer to the device structure for the driver instance.

modules/hostap/src/supp_api.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,35 @@ int supplicant_get_rts_threshold(const struct device *dev, unsigned int *rts_thr
17931793
return wifi_mgmt_api->get_rts_threshold(dev, rts_threshold);
17941794
}
17951795

1796+
bool supplicant_bss_support_neighbor_rep(const struct device *dev)
1797+
{
1798+
struct wpa_supplicant *wpa_s;
1799+
bool is_support = false;
1800+
const u8 *rrm_ie = NULL;
1801+
1802+
wpa_s = get_wpa_s_handle(dev);
1803+
if (!wpa_s) {
1804+
wpa_printf(MSG_ERROR, "Interface %s not found", dev->name);
1805+
return false;
1806+
}
1807+
1808+
k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER);
1809+
if (!wpa_s->rrm.rrm_used) {
1810+
goto out;
1811+
}
1812+
1813+
rrm_ie = wpa_bss_get_ie(wpa_s->current_bss,
1814+
WLAN_EID_RRM_ENABLED_CAPABILITIES);
1815+
if (!rrm_ie || !(wpa_s->current_bss->caps & IEEE80211_CAP_RRM) ||
1816+
!(rrm_ie[2] & WLAN_RRM_CAPS_NEIGHBOR_REPORT)) {
1817+
goto out;
1818+
}
1819+
is_support = true;
1820+
out:
1821+
k_mutex_unlock(&wpa_supplicant_mutex);
1822+
return is_support;
1823+
}
1824+
17961825
int supplicant_bss_ext_capab(const struct device *dev, int capab)
17971826
{
17981827
struct wpa_supplicant *wpa_s;

modules/hostap/src/supp_api.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,14 @@ int supplicant_btm_query(const struct device *dev, uint8_t reason);
277277
*/
278278
int supplicant_legacy_roam(const struct device *dev);
279279

280+
/** Check if ap supports Neighbor report or not.
281+
*
282+
* @param dev Pointer to the device structure for the driver instance.
283+
*
284+
* @return true if support, false if not support
285+
*/
286+
bool supplicant_bss_support_neighbor_rep(const struct device *dev);
287+
280288
/** Judge ap whether support the capability
281289
*
282290
* @param dev Pointer to the device structure for the driver instance.

modules/hostap/src/supp_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static const struct wifi_mgmt_ops mgmt_ops = {
7676
.channel = supplicant_channel,
7777
.set_rts_threshold = supplicant_set_rts_threshold,
7878
.get_rts_threshold = supplicant_get_rts_threshold,
79+
.bss_support_neighbor_rep = supplicant_bss_support_neighbor_rep,
7980
.bss_ext_capab = supplicant_bss_ext_capab,
8081
.legacy_roam = supplicant_legacy_roam,
8182
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_WNM

subsys/net/l2/wifi/wifi_mgmt.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ struct wifi_rrm_neighbor_report_t {
4141

4242
struct wifi_roaming_params {
4343
bool is_11r_used;
44-
bool is_11k_enabled;
4544
struct wifi_rrm_neighbor_report_t neighbor_rep;
4645
};
4746

@@ -565,7 +564,7 @@ static int wifi_start_roaming(uint64_t mgmt_request, struct net_if *iface,
565564
}
566565

567566
return wifi_mgmt_api->start_11r_roaming(dev);
568-
} else if (roaming_params.is_11k_enabled) {
567+
} else if (wifi_mgmt_api->bss_support_neighbor_rep(dev)) {
569568
memset(&roaming_params.neighbor_rep, 0x0, sizeof(roaming_params.neighbor_rep));
570569
if (wifi_mgmt_api->send_11k_neighbor_request == NULL) {
571570
return -ENOTSUP;
@@ -890,12 +889,6 @@ static int wifi_11k_cfg(uint64_t mgmt_request, struct net_if *iface,
890889
return -ENETDOWN;
891890
}
892891

893-
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_ROAMING
894-
if (params->oper == WIFI_MGMT_SET) {
895-
roaming_params.is_11k_enabled = params->enable_11k;
896-
}
897-
#endif
898-
899892
return wifi_mgmt_api->cfg_11k(dev, params);
900893
}
901894

0 commit comments

Comments
 (0)