From 298c539a35d19eae919e81866e59cfb8bb13e4a9 Mon Sep 17 00:00:00 2001 From: Filip Matusiak <filip.matusiak@iopsys.eu> Date: Tue, 13 May 2025 17:22:10 +0200 Subject: [PATCH] Get beacon metrics caps from STA info --- src/agent.c | 23 +++++++++++++++++++++-- src/agent.h | 1 + src/wifi.h | 7 +++++++ src/wifi_ubus.c | 10 ++++++++-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/agent.c b/src/agent.c index 1ca65a857..091d1eb1f 100644 --- a/src/agent.c +++ b/src/agent.c @@ -1287,8 +1287,24 @@ static int update_sta_entry(struct agent *a, struct netif_ap *ap, struct wifi_st s->rx_fail_pkts = e->stats.rx_fail_pkts; s->rtx_pkts = e->stats.tx_retry_pkts; - memcpy(s->bssid, e->bssid, 6); + + if (!!(e->caps.valid & WIFI_CAP_RM_VALID)) { + if (wifi_cap_isset(e->cbitmap, WIFI_CAP_RM_BCN_ACTIVE)) { + s->rrm_mode |= NBR_PARAM_BCN_ACTIVE; + s->supports_bcnreport = true; + } + + if (wifi_cap_isset(e->cbitmap, WIFI_CAP_RM_BCN_PASSIVE)) { + s->rrm_mode |= NBR_PARAM_BCN_PASSIVE; + s->supports_bcnreport = true; + } + + if (wifi_cap_isset(e->cbitmap, WIFI_CAP_RM_BCN_TABLE)) { + s->rrm_mode |= NBR_PARAM_BCN_TABLE; + s->supports_bcnreport = true; + } + } #ifdef UBUS_STA_INFO wifiagent_log_stainfo(ap->agent, s); #endif @@ -1301,7 +1317,8 @@ static int update_sta_entry(struct agent *a, struct netif_ap *ap, struct wifi_st static int agent_req_beacon_metrics(struct agent *a, struct netif_ap *ap, uint8_t *sta_addr, uint8_t opclass, - uint8_t channel, uint8_t *bssid, uint8_t reporting_detail, + uint8_t channel, uint8_t *bssid, + uint8_t rrm_mode, uint8_t reporting_detail, uint8_t ssid_len, char *ssid, uint8_t num_report, uint8_t *report, uint8_t num_element, uint8_t *element) { @@ -1322,6 +1339,7 @@ static int agent_req_beacon_metrics(struct agent *a, param.report = report; param.num_element = num_element; param.element = element; + param.rrm_mode = rrm_mode; return wifi_req_neighbor(ap->ifname, sta_addr, ¶m); } @@ -1346,6 +1364,7 @@ static void wifi_sta_bcn_req(atimer_t *t) agent_req_beacon_metrics(a, breq->ap, s->macaddr, breq->opclass, breq->channel, breq->bssid, + s->rrm_mode, breq->reporting_detail, breq->ssid_len, breq->ssid, 0, NULL, breq->num_element, breq->element); diff --git a/src/agent.h b/src/agent.h index 48f944f47..b88141146 100644 --- a/src/agent.h +++ b/src/agent.h @@ -494,6 +494,7 @@ struct sta { int inform_leaving; /** flag indicating leaving BSS */ bool wait_for_cntlr_nbr; /** awaiting pref nbr from cntlr */ bool supports_bcnreport; /** supports 11K beacon reporting */ + uint8_t rrm_mode; /** bitmap for ACTIVE/PASSIVE/TABLE */ atimer_t sta_timer; /** periodic run */ atimer_t sta_bcn_req_timer; /** enqueue bcn requests */ struct list_head sta_nbrlist; /** neighbor BSSs as seen by this STA */ diff --git a/src/wifi.h b/src/wifi.h index 66575bf94..ed926e4fa 100644 --- a/src/wifi.h +++ b/src/wifi.h @@ -49,10 +49,17 @@ struct wifi_radio_status { uint32_t bandwidth; }; +enum nbr_param_bcn_mode { + NBR_PARAM_BCN_ACTIVE = 1 << 0, + NBR_PARAM_BCN_PASSIVE = 1 << 1, + NBR_PARAM_BCN_TABLE = 1 << 2, +}; + struct wifi_request_neighbor_param { uint8_t opclass; uint8_t channel; uint8_t *bssid; + uint8_t rrm_mode; uint8_t reporting_detail; uint8_t ssid_len; char *ssid; diff --git a/src/wifi_ubus.c b/src/wifi_ubus.c index 890b356c2..47f6e6fd7 100644 --- a/src/wifi_ubus.c +++ b/src/wifi_ubus.c @@ -1718,10 +1718,16 @@ int wifi_ubus_req_neighbor(struct ubus_context *ubus_ctx, const char *ifname, blobmsg_add_string(&bb, "bssid", bssid_macstr); } - /* TODO: revisit */ - /* Set mode to PASSIVE/100ms explicitly */ + /* Start with passive mode by default */ blobmsg_add_string(&bb, "mode", "passive"); blobmsg_add_u32(&bb, "duration", 100); + if (!(param->rrm_mode & NBR_PARAM_BCN_PASSIVE)) { + /* passive not supported, check for active but keep passive otherwise */ + if (param->rrm_mode & NBR_PARAM_BCN_ACTIVE) { + blobmsg_add_string(&bb, "mode", "active"); + blobmsg_add_u32(&bb, "duration", 20); + } + } if (param->reporting_detail) blobmsg_add_u32(&bb, "reporting_detail", param->reporting_detail); -- GitLab