netdev: store signal threshold in netdev object, not globally

This prepares for the ability to toggle between two signal
thresholds in netdev. Since each netdev may not need/want the
same threshold store it in the netdev object rather than globally.
This commit is contained in:
James Prestwood 2024-08-23 15:23:34 -07:00 committed by Denis Kenzior
parent 54b6330845
commit 7ba5b0f924
1 changed files with 14 additions and 8 deletions

View File

@ -172,6 +172,9 @@ struct netdev {
struct netdev_ext_key_info *ext_key_info;
int low_signal_threshold;
int low_signal_threshold_5ghz;
bool connected : 1;
bool associated : 1;
bool operational : 1;
@ -206,6 +209,9 @@ static struct l_genl_family *nl80211;
static struct l_queue *netdev_list;
static struct watchlist netdev_watches;
static bool mac_per_ssid;
/* Threshold RSSI for roaming to trigger, configurable in main.conf */
static int LOW_SIGNAL_THRESHOLD;
static int LOW_SIGNAL_THRESHOLD_5GHZ;
static unsigned int iov_ie_append(struct iovec *iov,
unsigned int n_iov, unsigned int c,
@ -1058,10 +1064,6 @@ struct netdev *netdev_find(int ifindex)
return l_queue_find(netdev_list, netdev_match, L_UINT_TO_PTR(ifindex));
}
/* Threshold RSSI for roaming to trigger, configurable in main.conf */
static int LOW_SIGNAL_THRESHOLD;
static int LOW_SIGNAL_THRESHOLD_5GHZ;
static void netdev_cqm_event_rssi_threshold(struct netdev *netdev,
uint32_t rssi_event)
{
@ -1089,8 +1091,9 @@ static void netdev_cqm_event_rssi_value(struct netdev *netdev, int rssi_val)
{
bool new_rssi_low;
uint8_t prev_rssi_level_idx = netdev->cur_rssi_level_idx;
int threshold = netdev->frequency > 4000 ? LOW_SIGNAL_THRESHOLD_5GHZ :
LOW_SIGNAL_THRESHOLD;
int threshold = netdev->frequency > 4000 ?
netdev->low_signal_threshold_5ghz :
netdev->low_signal_threshold;
if (!netdev->connected)
return;
@ -3585,8 +3588,9 @@ static struct l_genl_msg *netdev_build_cmd_cqm_rssi_update(
uint32_t hyst = 5;
int thold_count;
int32_t thold_list[levels_num + 2];
int threshold = netdev->frequency > 4000 ? LOW_SIGNAL_THRESHOLD_5GHZ :
LOW_SIGNAL_THRESHOLD;
int threshold = netdev->frequency > 4000 ?
netdev->low_signal_threshold_5ghz :
netdev->low_signal_threshold;
if (levels_num == 0) {
thold_list[0] = threshold;
@ -6163,6 +6167,8 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg,
l_strlcpy(netdev->name, ifname, IFNAMSIZ);
netdev->wiphy = wiphy;
netdev->pae_over_nl80211 = pae_io == NULL;
netdev->low_signal_threshold = LOW_SIGNAL_THRESHOLD;
netdev->low_signal_threshold_5ghz = LOW_SIGNAL_THRESHOLD_5GHZ;
if (set_mac)
memcpy(netdev->set_mac_once, set_mac, 6);