From: David Bauer Date: Sat, 26 Mar 2022 21:58:15 +0000 (+0100) Subject: local-node: periodically send link-measurement requests X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=f88ac239034e06ae18b398dfa5058d60a574f877;p=project%2Fusteer.git local-node: periodically send link-measurement requests 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 --- diff --git a/local_node.c b/local_node.c index bf6ade9..8fb2485 100644 --- a/local_node.c +++ b/local_node.c @@ -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 6c8033a..bb4e9e3 100644 --- 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 914746d..77a512f 100644 --- 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; diff --git a/openwrt/usteer/files/etc/config/usteer b/openwrt/usteer/files/etc/config/usteer index 53fcbbf..ece7efc 100644 --- a/openwrt/usteer/files/etc/config/usteer +++ b/openwrt/usteer/files/etc/config/usteer @@ -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 '' diff --git a/openwrt/usteer/files/etc/init.d/usteer b/openwrt/usteer/files/etc/init.d/usteer index 2d014b0..07fd99e 100755 --- a/openwrt/usteer/files/etc/init.d/usteer +++ b/openwrt/usteer/files/etc/init.d/usteer @@ -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 0fa7e36..19ab4b3 100644 --- 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); diff --git a/usteer.h b/usteer.h index 34c958b..ec4e219 100644 --- 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