local-node: periodically send link-measurement requests
authorDavid Bauer <mail@david-bauer.net>
Sat, 26 Mar 2022 21:58:15 +0000 (22:58 +0100)
committerDavid Bauer <mail@david-bauer.net>
Mon, 4 Apr 2022 15:08:07 +0000 (17:08 +0200)
Send link-measurement requests to every supporting local-sta in order to
acquire information to assess the link-quality bi-directional.

The link-measurement request is sent each configurable interval. It can
be disabled by configuring the interval to 0.

Signed-off-by: David Bauer <mail@david-bauer.net>
local_node.c
main.c
node.h
openwrt/usteer/files/etc/config/usteer
openwrt/usteer/files/etc/init.d/usteer
ubus.c
usteer.h

index bf6ade99e84a4fba781dc0096a34128289551791..8fb2485a84b0b0157e0f8cf755eb0aec0ea9392a 100644 (file)
@@ -659,6 +659,33 @@ usteer_local_node_state_next(struct uloop_timeout *timeout)
        ubus_complete_request_async(ubus_ctx, &ln->req);
 }
 
+static void
+usteer_local_node_request_link_measurement(struct usteer_local_node *ln)
+{
+       unsigned int min_count = DIV_ROUND_UP(config.link_measurement_interval, config.local_sta_update);
+       struct usteer_node *node;
+       struct sta_info *si;
+
+       node = &ln->node;
+
+       if (ln->link_measurement_tries < min_count) {
+               ln->link_measurement_tries++;
+               return;
+       }
+       
+       ln->link_measurement_tries = 0;
+
+       if (!config.link_measurement_interval)
+               return;
+
+       list_for_each_entry(si, &node->sta_info, node_list) {
+               if (si->connected != STA_CONNECTED)
+                       continue;
+
+               usteer_ubus_trigger_link_measurement(si);
+       }
+}
+
 static void
 usteer_local_node_update(struct uloop_timeout *timeout)
 {
@@ -680,6 +707,8 @@ usteer_local_node_update(struct uloop_timeout *timeout)
        uloop_timeout_set(&ln->req_timer, 1);
        usteer_local_node_kick(ln);
        usteer_band_steering_perform_steer(ln);
+       usteer_local_node_request_link_measurement(ln);
+
        uloop_timeout_set(timeout, config.local_sta_update);
 }
 
diff --git a/main.c b/main.c
index 6c8033a86fd206d97e5d5ba1d65aab6c8ba941ed..bb4e9e34fc2d05a2989203c8348ac019bb659bd1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -102,6 +102,8 @@ void usteer_init_defaults(void)
        config.band_steering_interval = 120000;
        config.band_steering_min_snr = -60;
 
+       config.link_measurement_interval = 30000;
+
        config.roam_kick_delay = 10000;
        config.roam_process_timeout = 5 * 1000;
        config.roam_scan_tries = 3;
diff --git a/node.h b/node.h
index 914746ddb6c3991b204c924e9019c5facd43f8c9..77a512f08eab1e19e591090333621afeb85f9f21 100644 (file)
--- a/node.h
+++ b/node.h
@@ -70,6 +70,8 @@ struct usteer_local_node {
                bool req_pending;
                bool status_complete;
        } netifd;
+
+       unsigned int link_measurement_tries;
 };
 
 struct interface;
index 53fcbbfa96737191302398286eb2644f5bfb0bc2..ece7efcf8c8626cf7646956b0d0a4e610e9d1e94 100644 (file)
@@ -125,6 +125,10 @@ config usteer
        # steered to a higher frequency band
        #option band_steering_min_snr -60
 
+       # Interval (ms) the device is sent a link-measurement request to help assess
+       # the bi-directional link quality. Setting the interval to 0 disables link-measurements.
+       #option link_measurement_interval 30000
+
        # Script to run after bringing up a node
        #option node_up_script ''
 
index 2d014b066fca252b5d7984556072d373dea23ecf..07fd99efb667da4e09fc1d8acc0c055d2624c80b 100755 (executable)
@@ -85,7 +85,7 @@ uci_usteer() {
                roam_kick_delay roam_scan_tries roam_scan_timeout \
                roam_scan_snr roam_scan_interval \
                roam_trigger_snr roam_trigger_interval \
-               band_steering_interval band_steering_min_snr \
+               band_steering_interval band_steering_min_snr link_measurement_interval \
                load_kick_threshold load_kick_delay load_kick_min_clients \
                load_kick_reason_code
        do
diff --git a/ubus.c b/ubus.c
index 0fa7e36455ca6a92f9dc4b80e773765b4ef898fa..19ab4b3efc7a0685d697dcef0348df65e0141cee 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -183,6 +183,7 @@ struct cfg_item {
        _cfg(U32, load_kick_reason_code), \
        _cfg(U32, band_steering_interval), \
        _cfg(I32, band_steering_min_snr), \
+       _cfg(U32, link_measurement_interval), \
        _cfg(ARRAY_CB, interfaces), \
        _cfg(STRING_CB, node_up_script), \
        _cfg(ARRAY_CB, event_log_types), \
@@ -695,6 +696,20 @@ int usteer_ubus_notify_client_disassoc(struct sta_info *si)
        return ubus_invoke(ubus_ctx, ln->obj_id, "wnm_disassoc_imminent", b.head, NULL, 0, 100);
 }
 
+int usteer_ubus_trigger_link_measurement(struct sta_info *si)
+{
+       struct usteer_local_node *ln = container_of(si->node, struct usteer_local_node, node);
+
+       if (!usteer_sta_supports_link_measurement(si))
+               return 0;
+
+       blob_buf_init(&b, 0);
+       blobmsg_printf(&b, "addr", MAC_ADDR_FMT, MAC_ADDR_DATA(si->sta->addr));
+       blobmsg_add_u32(&b, "tx-power-used", 5);
+       blobmsg_add_u32(&b, "tx-power-max", 10);
+       return ubus_invoke(ubus_ctx, ln->obj_id, "link_measurement_req", b.head, NULL, 0, 100);
+}
+
 int usteer_ubus_trigger_client_scan(struct sta_info *si)
 {
        struct usteer_local_node *ln = container_of(si->node, struct usteer_local_node, node);
index 34c958bd28869ccdcbbaf1882eb0c3895b8bdaaa..ec4e2191182f56d5e78b9da96c85e2ffb71361fc 100644 (file)
--- a/usteer.h
+++ b/usteer.h
@@ -191,6 +191,8 @@ struct usteer_config {
        uint32_t band_steering_interval;
        int32_t band_steering_min_snr; 
 
+       uint32_t link_measurement_interval;
+
        uint32_t initial_connect_delay;
 
        bool load_kick_enabled;
@@ -388,4 +390,6 @@ void usteer_measurement_report_del(struct usteer_measurement_report *mr);
 struct usteer_measurement_report *
 usteer_measurement_report_add(struct sta *sta, struct usteer_node *node, uint8_t rcpi, uint8_t rsni, uint64_t timestamp);
 
+
+int usteer_ubus_trigger_link_measurement(struct sta_info *si);
 #endif