From patchwork Tue Nov 19 14:24:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13879996 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B79831CCB23 for ; Tue, 19 Nov 2024 14:24:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026280; cv=none; b=ct2N4UiOXH74keLQLroADYJ0rOe6bUpQykd1/XKqS9P2eDZoj1gy4IY/pjGGeDrMnHxvEVhOJ13xdoxscI9SBUWcugSzVchSVGtiM0Phot0yD7QV9DopzSArG8dMIwNYQrfQZfwYRu9n7aQTR74oRXitcdg1HxfKBXYvkTRRUa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026280; c=relaxed/simple; bh=DPsUR7Ke79ERngHeudwrMNddstg6r92/IGyrMQLvQKw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ANcZabPsdFgjKGQmGRheQLWc8P6gRnwPdrkIlZCOV7A8fNNhKJy56HVKD8iSJxnN6erJA0ecY5NVva/mBVZ903lSnlPD6NJ0qb59sIqY2BMfTeobl6daSoXCLtSE6OInqOF0spYkdZNqTmj7pBWOMVJP7VCjsYvKQHOBKY57g+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ets5bz+y; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ets5bz+y" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20e576dbc42so46749555ad.0 for ; Tue, 19 Nov 2024 06:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732026278; x=1732631078; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=02MzuxPnd0BClg5tYNWXewgemsxNIJtMddWTyP/ekhM=; b=Ets5bz+yq2LPPYwmCabruYsmxRQdVBFZEN9nGiZwYPnT9bspL8/+PRhPbuTwv0IuLG igo3cYxpVZ77ezQNLW4IYNAvSNGnjrqnh/ifnGDbhy52iHqtWYuBy67djarmXp6xJjWU hyEjzW5xMupHd700652jA/2rco+UVbTm/vhex3M3LtNwp2YkdzpVDw+gTthbm2dzG4MU wMkuSToSaBitJGdxjAGdm2DXy0v4L959XIyDxTS8LH+K/8HQE7M/+xLeozyZAcw7qHnT wHv/7nr/9QtxYs0oPbhM1K+yBD9dKvHl5NhItBVr11dmaSnD+DDZNpAk3NoexZzW+t/G rHnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732026278; x=1732631078; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=02MzuxPnd0BClg5tYNWXewgemsxNIJtMddWTyP/ekhM=; b=FzF5dmgRlBytrD5L/PgSay8H9ptLza/PfArNQ9g8kX74hS8R2zMjt4VmYoMVO1ntDP i1/fagqf5LOnpXtNhqLGYBB6CfPP6JqHfuKRgpeNypCjYDCZnoKpGd0VCFucoaPwq/CO tX7aTH0lqpgj7Byzse24rpoAizvX3dS0wcX0WW1MaOqGC14Rz5PB/C7zHNxcQeS6k3oW GsO89Tgc3pDvmGWGmoHq0SMbwYWlAs1Q7bd3DSInJbLs4QgI0IiTRw+LfTVc/aPdPP35 +ZHa9oDxbsiicvqPPtNPC2MQYPml11fBrdnMnyXFBGcut541A8/kFaejuBZ12H4UFLer wW4w== X-Gm-Message-State: AOJu0YxWECm3UImI8XlGU4e60UmNhh5qavktyl7rTUHRdPfpobMNahsh 5Q8jWLTzxpLmCgAnXRMslV9nNs1nM5jquhIhkOgqNjyDBFtOX5mIEW+2Ug== X-Google-Smtp-Source: AGHT+IEkKcGmwzieRXR5WlwCOhxShF1Xd3ojINgxrU6J/9POyJZ/cwkioPGo6rdlEnuWa8td7/sknQ== X-Received: by 2002:a17:903:244b:b0:20c:e169:eb75 with SMTP id d9443c01a7336-211d0d5ec0amr216538865ad.2.1732026277532; Tue, 19 Nov 2024 06:24:37 -0800 (PST) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212389529b6sm29219115ad.236.2024.11.19.06.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 06:24:37 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/8] util: add util_linear_map Date: Tue, 19 Nov 2024 06:24:23 -0800 Message-Id: <20241119142430.323074-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This has been needed elsewhere but generally shortcuts could be taken mapping with ranges starting/ending with zero. This is a more general linear mapping utility to map values between any two ranges. --- src/util.c | 30 ++++++++++++++++++++++++++++++ src/util.h | 11 +++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/util.c b/src/util.c index a4a78fb6..a6ab9d85 100644 --- a/src/util.c +++ b/src/util.c @@ -312,6 +312,36 @@ bool util_ip_prefix_tohl(const char *ip, uint8_t *prefix_out, return true; } +/* + * Linearly maps @value (expected to be within range @a_start and @a_end) to + * a new value between @b_start and @b_end. + * + * Returns: false if + * @value is not between @a_start and @a_end + * @a_start/@a_end or @b_start/@b_end are equal. + */ +bool util_linear_map(double value, double a_start, double a_end, + double b_start, double b_end, double *mapped_value) +{ + /* Check value is within a's range */ + if (a_start < a_end) { + if (value < a_start || value > a_end) + return false; + } else if (a_start > a_end) { + if (value > a_start || value < a_end) + return false; + } else + return false; + + if (b_start == b_end) + return false; + + *mapped_value = b_start + (((b_end - b_start) / (a_end - a_start)) * + (value - a_start)); + + return true; +} + struct scan_freq_set { uint16_t channels_2ghz; struct l_uintset *channels_5ghz; diff --git a/src/util.h b/src/util.h index dafa446d..9f3f0a57 100644 --- a/src/util.h +++ b/src/util.h @@ -106,6 +106,17 @@ static inline bool util_ip_subnet_match(uint8_t prefix_len, ~((1u << (8 - (prefix_len % 8))) - 1)); } +/* + * Linearly maps (interpolates) 'value' from range 'a' to range 'b' + * + * Fails if: + * - value is not between a and b + * - a_start == a_end + * - b_start == b_end + */ +bool util_linear_map(double value, double a_start, double a_end, + double b_start, double b_end, double *mapped_value); + typedef void (*scan_freq_set_func_t)(uint32_t freq, void *userdata); struct scan_freq_set *scan_freq_set_new(void); From patchwork Tue Nov 19 14:24:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13879997 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26DBB14658D for ; Tue, 19 Nov 2024 14:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026281; cv=none; b=VNS6koX9lXWmxZtV24XUujm7cvADXcST6zRmP0R2dwkaK2DlxMYnfj4sOijVh6skySVUiAJdw/TY9Luqnejul/C+qc/pHRfxiU+FTdtohJGYAFgdCh8J4FhViifOpV1TZiInK9M3w6R9VF/+OG/A8RZfDSVIMmZ8K2HAUGbAloA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026281; c=relaxed/simple; bh=4IeCTmAPtfld/FmYqeFjoJbp+QeeUZikFMRHKNou+zQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PvkwCWkFkLdD1ld/ZCOQzz/9PBfdvPqwJgI+Ij0xAOFAeQQgnZm+yGSeSRvx4ZQ25Ckcqw38187Qvso7F0U3XDoCKGL8fbdyUlPPianmN11FAIBDbFCtluBPr8L0HF8C7hvmZ8GTQ+uc+LJ+jx5xiVO7adj8m5m83Mt64WsRuz8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ca2eBGSD; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ca2eBGSD" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-21263dbbbc4so2236065ad.1 for ; Tue, 19 Nov 2024 06:24:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732026279; x=1732631079; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CtU52x7s4D31fi37GKm2PrginWk4pa8cpE35hMqaCRQ=; b=Ca2eBGSDLiRuPf7F7TwwCORFjER2WdTW02udwz0wDe/8JgW8hBCpb+W7q2p5EOMtmB L9WrwqzyFE/k4CZZ+/21unlbHBSqOLPZVj97kkgBMoaOkMpQ2vz2b0z/zTnP4/ByxQnk ZZHOrFrmgpw7F0BdP7ZEhBjZrpjVDAFlKHnmK3trDw8OktJl2/tCuPRfx7OtQLTxt3Ab wSkg3yu7oI1yILYMRnNoUg4ARwQ52H10DXO2jCOmqYLQh0x9V/xMMVW0Z+pOB495vRF+ QkKHLJeuxJUflw/MpoLu9d4nCUZHH+egcMzIX20ufOBhPopAvq06BEZE2uYVkE8CfZ5D fQGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732026279; x=1732631079; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CtU52x7s4D31fi37GKm2PrginWk4pa8cpE35hMqaCRQ=; b=pBzVFEE1+XfG1a2SnHewCW2EX2f2wqB2ZmuFp7Mty6yizvPTyG10WU7ricBm40Kic7 SyGIlCQxU68+JNFGzuUtIuxZ/2A5PceN+dOC0knVqaN9Uf//sT88xc7z+b0pG1cHHYeQ +qOZQPrqaSWOcCKOlawhyzy9Z5GQQ6Gvn+x1+1ZF5gjw7rBHJVu+Sgvk5Sksf0iVUqY6 Z+s3uvQHow7yAzTkUlwdcXgdHaFXgmKdy7jlpqy7tlyUAfEEazqEnj2EB41Q3BFsDryK kHfj3XbzecHIU/5xd9krRht/EnN+ARk2oizt2q8o6AgNleegIqh2KtHLPbsLHDw7AMTB CGXQ== X-Gm-Message-State: AOJu0YzufWKVGq+CqqVwSkOmMbctj1m8vqcpnb//lnKBeFYHw/0vjcxi ouCJOmblm8NnfObUJvAPJJA0gMDGczu2XSTNktpjVcdH6ombkndTfVm+Dw== X-Google-Smtp-Source: AGHT+IF8fAV0jXjFQUq4nI2gJr/XexbF58QbBd68H+LJwe7GZat8Kelnbi8vWv1TQKECOzhF6FxWXg== X-Received: by 2002:a17:902:fc46:b0:211:f13e:a56d with SMTP id d9443c01a7336-211f13ea929mr182717665ad.24.1732026279159; Tue, 19 Nov 2024 06:24:39 -0800 (PST) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212389529b6sm29219115ad.236.2024.11.19.06.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 06:24:38 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/8] unit: add linear mapping test Date: Tue, 19 Nov 2024 06:24:24 -0800 Message-Id: <20241119142430.323074-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119142430.323074-1-prestwoj@gmail.com> References: <20241119142430.323074-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- unit/test-util.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/unit/test-util.c b/unit/test-util.c index 0bfd1587..214d4819 100644 --- a/unit/test-util.c +++ b/unit/test-util.c @@ -184,6 +184,75 @@ static void ip_prefix_test(const void *data) } } +struct linear_map_case { + double value; + double a_start; + double a_end; + double b_start; + double b_end; + double expected; + + bool fails : 1; +}; + +struct linear_map_case cases[] = { + /* Value out of range */ + { + .value = 100, + .a_start = 1, + .a_end = 3, + .b_start = 10, + .b_end = 12, + .fails = true, + }, + /* Ascending start range */ + { + .value = 1, + .a_start = 0, + .a_end = 2, + .b_start = 10, + .b_end = 12, + .expected = 11, + }, + /* Descending start range */ + { + .value = 1, + .a_start = 2, + .a_end = 0, + .b_start = 10, + .b_end = 12, + .expected = 11, + }, + /* Negatives */ + { + .value = -1, + .a_start = -2, + .a_end = 0, + .b_start = 0, + .b_end = 2, + .expected = 1, + }, +}; + +static void test_linear_map(const void *data) +{ + double mapped; + unsigned int i; + + for (i = 0; i < L_ARRAY_SIZE(cases); i++) { + struct linear_map_case *c = &cases[i]; + bool ret = util_linear_map(c->value, c->a_start, c->a_end, + c->b_start, c->b_end, &mapped); + if (c->fails) { + assert(ret == false); + continue; + } + + assert(ret); + assert(mapped == c->expected); + } +} + int main(int argc, char *argv[]) { l_test_init(&argc, &argv); @@ -192,6 +261,7 @@ int main(int argc, char *argv[]) l_test_add("/util/get_domain/", get_domain_test, NULL); l_test_add("/util/get_username/", get_username_test, NULL); l_test_add("/util/ip_prefix/", ip_prefix_test, NULL); + l_test_add("/util/test_linear_map", test_linear_map, NULL); return l_test_run(); } From patchwork Tue Nov 19 14:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13879998 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD40D1CCEC2 for ; Tue, 19 Nov 2024 14:24:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026283; cv=none; b=F7lfwRcHAr0SbmYjrlT+SuHB40Rcd4o8WYoujrdnqahgOGQcd7tHUTISZZeiT+tdCV/P/beJ2c/HiYWoyVTIcPccPQf9brNjXQZPkIyovXLzwTF5P2/MuzfnEVch2NpOEIZImyFA1W0U8wGRuUbbt806Q2fj9XpJfFJOgSAW/1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026283; c=relaxed/simple; bh=RHCrU+j35IIEqBwc2UJ5N/nOvOWt5C1lVyx0FiXaEWE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K1BZ+cBMGj2n6cB/5Q9FvBfKYpI3vk3nqNSH/rTfAtUUje8sf+cJhFxvWfQPO1lLxETO8AbZ6tkY+US7xqoLW6ofBPn3ZXlNn+3Qnui6QsATejqAoKrA/3MyI1ws/7nF89ZPOwGBQ8W3WpWk8kWyt+NTFR0VI2GJ5UJ1mjE6gWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kdMr4dEJ; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kdMr4dEJ" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-20c803787abso43165365ad.0 for ; Tue, 19 Nov 2024 06:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732026281; x=1732631081; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jHeBryzmHcHlGtI1q7sLAolrWPuwQMEO1uQI6pYkW8I=; b=kdMr4dEJ43Qd+uLzIZwESBIn1NkDshAOXR3yQ6DmaIJKaQBZhPp8kR++SkcFx0aj73 YNQK/ZMtiLvIzRnf7zATG//M0eFktXL1eOifi9aS+9q9tVaR/i4dOaYPBM1jYJ4HmfJY n4n6gogviRTvhkHEOB25+YI3ErqZrjGWOwjtgUsBoFxo//rOu0YsIQ0uz/ZHvu1meTah TH24caI9/CLXOTrNkfKeFvZp3r5XRgnGEVbRRAqk0DmEhQYHwH+ZEZl/OowdIkapm0vG jyp2JhV73hhCWOm82+e4FXe/PnFpsQB5iFiAbBBeDCXONOsd/+h2mxcriWWAD8HOln3z ihmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732026281; x=1732631081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jHeBryzmHcHlGtI1q7sLAolrWPuwQMEO1uQI6pYkW8I=; b=ctfh4CgWqD6ks7yHEz6sLSYlrY0TUZtK4ob2/zP2Hzlq+aj23hcVmPAVYvLlu0B6Tm m8ql4s5zFkEXK5HL2ssx1wI3tTK+RXGhJWfngqGRjKlFFw9/7+ljaHDNykxdImvi7Irw Tyqi2iFBVzylaoI/mhKXkIomkzAPh1Q++rjnR5VnVjorRNh74vljFtN4YllkMN23YyOL /VDxlonczmfbWlSBjnFk8vNtbxuVm896f8IPMHTHmommrLCYMsySEp4689wHqgC2pPMf Phl/xLgQCbBUy3GXpplzdTmLOVjJjZjG74HL7zQQ2h6XM23953g2gMmuZym267FVE904 8IlQ== X-Gm-Message-State: AOJu0YzyooyBLIYest6Adetj9mFntL2XsKO6mREk7bcwV5KlV4ZfpVZU wfQWWl88J1NkN+nhxIAy1teTXRN14PgY++IEPfPu8P58Na6hznUcW2vBGg== X-Google-Smtp-Source: AGHT+IFQYMbw8W+4rUDqqVAcreN7nW05U5smZ+OsN9JEUuoNv/ymxR7c3E4EP2cFJIUCtspWByYPSA== X-Received: by 2002:a17:902:f684:b0:20c:5ffe:3ef1 with SMTP id d9443c01a7336-2124d027ef7mr50566835ad.17.1732026280751; Tue, 19 Nov 2024 06:24:40 -0800 (PST) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212389529b6sm29219115ad.236.2024.11.19.06.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 06:24:40 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/8] util: add util_exponential_decay Date: Tue, 19 Nov 2024 06:24:25 -0800 Message-Id: <20241119142430.323074-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119142430.323074-1-prestwoj@gmail.com> References: <20241119142430.323074-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is copied from network.c that uses a static table to lookup exponential decay values by index (generated from 1/pow(n, 0.3)). network.c uses this for network ranking but it can be useful for BSS ranking as well if you need to apply some exponential backoff to a value. --- src/util.c | 28 ++++++++++++++++++++++++++++ src/util.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/util.c b/src/util.c index a6ab9d85..b673b002 100644 --- a/src/util.c +++ b/src/util.c @@ -636,3 +636,31 @@ struct scan_freq_set *scan_freq_set_clone(const struct scan_freq_set *set, return new; } + +/* First 64 entries calculated by 1 / pow(n, 0.3) for n >= 1 */ +static const double rankmod_table[] = { + 1.0000000000, 0.8122523964, 0.7192230933, 0.6597539554, + 0.6170338627, 0.5841906811, 0.5577898253, 0.5358867313, + 0.5172818580, 0.5011872336, 0.4870596972, 0.4745102806, + 0.4632516708, 0.4530661223, 0.4437850034, 0.4352752816, + 0.4274303178, 0.4201634287, 0.4134032816, 0.4070905315, + 0.4011753236, 0.3956154062, 0.3903746872, 0.3854221125, + 0.3807307877, 0.3762772797, 0.3720410580, 0.3680040435, + 0.3641502401, 0.3604654325, 0.3569369365, 0.3535533906, + 0.3503045821, 0.3471812999, 0.3441752105, 0.3412787518, + 0.3384850430, 0.3357878061, 0.3331812996, 0.3306602598, + 0.3282198502, 0.3258556179, 0.3235634544, 0.3213395618, + 0.3191804229, 0.3170827751, 0.3150435863, 0.3130600345, + 0.3111294892, 0.3092494947, 0.3074177553, 0.3056321221, + 0.3038905808, 0.3021912409, 0.3005323264, 0.2989121662, + 0.2973291870, 0.2957819051, 0.2942689208, 0.2927889114, + 0.2913406263, 0.2899228820, 0.2885345572, 0.2871745887, +}; + +double util_exponential_decay(unsigned int n) +{ + if (n > L_ARRAY_SIZE(rankmod_table)) + return rankmod_table[L_ARRAY_SIZE(rankmod_table) - 1]; + + return rankmod_table[n]; +} diff --git a/src/util.h b/src/util.h index 9f3f0a57..8aef2985 100644 --- a/src/util.h +++ b/src/util.h @@ -141,4 +141,6 @@ struct scan_freq_set *scan_freq_set_clone(const struct scan_freq_set *set, DEFINE_CLEANUP_FUNC(scan_freq_set_free); +double util_exponential_decay(unsigned int n); + #endif /* __UTIL_H */ From patchwork Tue Nov 19 14:24:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13879999 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D01214658D for ; Tue, 19 Nov 2024 14:24:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026284; cv=none; b=YjKu2+VKa00SZoEg/QOCpBqV/6qegKBEnt/8UNg4WyIjblN+vRn4zsh7ioOUL/1WDSoUq3JUkeQ/D2bHF5znzkGZGLwgSoAgIlHRYHsv7a+x46SpOEpiMnLbpNSJrvTCO5WfC3L48sdJOvRhNHt7bz4jMK7CRowuvWxecsgEb94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026284; c=relaxed/simple; bh=e5WhAp3OZKnYz512TSi9RyyBFogrh5qzLsHWOL/kCkU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dKsqGmmwZHB2IuADfOc5G+DAeecrdeKRr2MINO6VUzWkJvLfRJmoGaOIWlbkErffHYumBrIAgJi1Sqly65XUxgkLQw2rmvkRhSxFDdM4T18eYpFf7gFJXaLEwg84cOQhsUy31nuN5NB2wW8Jg4593HmwVj4kXeBUkYkT4iwSmO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=e78O489X; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e78O489X" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-21116b187c4so23248765ad.3 for ; Tue, 19 Nov 2024 06:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732026282; x=1732631082; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=naKvJExB+FpupQscRR3Z9VDlualxusR9hLF+5prY9zQ=; b=e78O489XOSE6/1rq/WrSDNeGtoEtUP7E/7G+svRZW6ozwlmDxGhT6Lx6vQpTR0EJSO 61rBjwSbDYrZH073cPkot68bMn3mWgzYgLDEnxbEs/OVt/ECLW5CzzqiXKLwBRQtH0Ew djKE5myLs+CfgNSaqzNG+qJBY2YoZ3wD8Q6B3hxNgyRlxboWULP8FolIkc/pW6CMz2+N /J+FlHpqZ/OLTcZHDxHD5KutWOXixUZWyHEZxXluWvn0HEaN1tul1FDLXWtB3+8zSrm4 eed+NCjNbeX+yv1ey3nDUUt+amlhL/rUR9dkUHdtuzwSz2rb2Z7oSUngwNXFERTM/kiS JYrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732026282; x=1732631082; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=naKvJExB+FpupQscRR3Z9VDlualxusR9hLF+5prY9zQ=; b=FPTtpk/2uW7426tYfd8sq1/hWU2DKXeSU+BONRtcq1iIAhnPMEGH7j440dfJTx+PG5 Q4J6t8MyNjW+Msgs5oCYCZ5GDjepBs4fsx7o5tK19iIctf8unDtrL9cCkyVH+mZZuR12 c/XE5phrOboGgxQwpBoZ/c9hcMeQmdUmo4CXlpMsC3WwPGVbZ7JZG/eB2kEqjscbqWtw SQBbzCzUzIqg0PxYFJs/mRmARYhs8Vk6K3YMSkRKtM1Ub8RNnAUKwON/tojMhO3LzLFo I27RMXwN3RNI5cJuL+xEv8uHAaQfDTzIE+o8lFoxWxk+/w2bT/sbxRXMil7FeLWbn8eP mkXw== X-Gm-Message-State: AOJu0YzvHCrowuvs4eH6MQHFRo3xMNvAU5M4jdj7xCY8TSfortzGVB1n T7+DUHX8NPBYJ224k6cc2R81pLdGtdq6wa5zEjCNHCJG5ukG70fvf/Tnig== X-Google-Smtp-Source: AGHT+IHl/2+iGOdg9KCXlYHO4JY0NMULJYHqxHFItfSNxwrWsvXQ6Uy5noI8O80R13lTA74l6ebuIQ== X-Received: by 2002:a17:902:e54c:b0:20f:aee9:d8b8 with SMTP id d9443c01a7336-211d0d72ac0mr187971495ad.20.1732026282280; Tue, 19 Nov 2024 06:24:42 -0800 (PST) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212389529b6sm29219115ad.236.2024.11.19.06.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 06:24:41 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 4/8] network: use util_exponential_decay Date: Tue, 19 Nov 2024 06:24:26 -0800 Message-Id: <20241119142430.323074-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119142430.323074-1-prestwoj@gmail.com> References: <20241119142430.323074-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/network.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/src/network.c b/src/network.c index cd8b0ee9..0a40a6c5 100644 --- a/src/network.c +++ b/src/network.c @@ -56,6 +56,7 @@ #include "src/erp.h" #include "src/handshake.h" #include "src/band.h" +#include "src/util.h" #define SAE_PT_SETTING "SAE-PT-Group%u" @@ -212,31 +213,10 @@ void network_disconnected(struct network *network) station_hide_network(network->station, network); } -/* First 64 entries calculated by 1 / pow(n, 0.3) for n >= 1 */ -static const double rankmod_table[] = { - 1.0000000000, 0.8122523964, 0.7192230933, 0.6597539554, - 0.6170338627, 0.5841906811, 0.5577898253, 0.5358867313, - 0.5172818580, 0.5011872336, 0.4870596972, 0.4745102806, - 0.4632516708, 0.4530661223, 0.4437850034, 0.4352752816, - 0.4274303178, 0.4201634287, 0.4134032816, 0.4070905315, - 0.4011753236, 0.3956154062, 0.3903746872, 0.3854221125, - 0.3807307877, 0.3762772797, 0.3720410580, 0.3680040435, - 0.3641502401, 0.3604654325, 0.3569369365, 0.3535533906, - 0.3503045821, 0.3471812999, 0.3441752105, 0.3412787518, - 0.3384850430, 0.3357878061, 0.3331812996, 0.3306602598, - 0.3282198502, 0.3258556179, 0.3235634544, 0.3213395618, - 0.3191804229, 0.3170827751, 0.3150435863, 0.3130600345, - 0.3111294892, 0.3092494947, 0.3074177553, 0.3056321221, - 0.3038905808, 0.3021912409, 0.3005323264, 0.2989121662, - 0.2973291870, 0.2957819051, 0.2942689208, 0.2927889114, - 0.2913406263, 0.2899228820, 0.2885345572, 0.2871745887, -}; - bool network_rankmod(const struct network *network, double *rankmod) { struct network_info *info = network->info; int n; - int nmax; /* * Current policy is that only networks successfully connected @@ -250,12 +230,7 @@ bool network_rankmod(const struct network *network, double *rankmod) if (n < 0) return false; - nmax = L_ARRAY_SIZE(rankmod_table); - - if (n >= nmax) - n = nmax - 1; - - *rankmod = rankmod_table[n]; + *rankmod = util_exponential_decay(n); return true; } @@ -2018,10 +1993,8 @@ void network_rank_update(struct network *network, bool connected) L_WARN_ON(n < 0); - if (n >= (int) L_ARRAY_SIZE(rankmod_table)) - n = L_ARRAY_SIZE(rankmod_table) - 1; - - network->rank = rankmod_table[n] * best_bss->rank + USHRT_MAX; + network->rank = + util_exponential_decay(n) * best_bss->rank + USHRT_MAX; } else network->rank = best_bss->rank; From patchwork Tue Nov 19 14:24:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13880000 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4F881CEAAD for ; Tue, 19 Nov 2024 14:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026286; cv=none; b=St9XktzWOT0kkJMuOhCDLEbYMVQBOD/DZXjFPSDYsdL0HqRoILpS5k/CGDg8VM9yZWGbeMfsEIu9TAVC6m9i/2jBtiLjWuPiUdxfyFxnzFTNa7SERaIcjjzvvk/hMpY9OEvP7651HsKzQByfmkvCVXI+AiE0RnvNm3Su3rNbI0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026286; c=relaxed/simple; bh=LwEVLfS2Zgtl3T0c0/6s6OUulpDSBn/Ul29Tao/WAYo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kjnMyT3ES+XBNHjTCO8i0PKwxobv/YPgR79gLgr6gKFK01qJmNRr0rqSgJdnXdJtGLAvp5k9ZJb6XUiLO1NVpwq9vinaoR200bLkRsHSUl17jGYhhLkoo/FNPE2NIwSMkrs2NUeyU2ESiPlkD/pua76UYlOecx9mpMwfAXAsdKk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fD1nM2zI; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fD1nM2zI" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-21210fe8775so17845885ad.1 for ; Tue, 19 Nov 2024 06:24:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732026284; x=1732631084; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QnHGTCf84UiDJjUmmi/RmJj8DCbIN3s3GUZzCblpgyU=; b=fD1nM2zIkCwY/KNl+s3g1VIapjTcn/aDWH/RcvAPhmjTjgwJdWyGeZ4h4Nit9Oznai CCJY4p8ForTzABj7DcKKYDycSP9RBm+WlG7tys/oc4/DZhnLvzh9xiTDPdEkx8QPjDEZ P5kQ4RzGefFjsEyNCNIyG3eYjhJUpXTk6nK6aSEiz22HAMrxjhflT/m/6SpxeYoTnco0 baxfLzbRNiiZVTZ76fN67Yu4ZVU1y6sHXuG/KWqegGrdzJ0LG7PgVvP4UQYI6rPY9YFY meR2uRJch5LzWtmwf2ccZXj56Xnv1swGwFOPDN4+Q8Ellf0VflpnG4+Id0mDX5OZbuLQ dkZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732026284; x=1732631084; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QnHGTCf84UiDJjUmmi/RmJj8DCbIN3s3GUZzCblpgyU=; b=fuweWWXgQGQ/o4aFA2TkwXJpOVWEpSYgJdAAltZbuQCQu7aB5vFyvWBoh8lWAleUPC JnaiI2DD8BjBHjL4mF4TD967IykZrHecCQZiFsLnsr9XSK+52zilttC0c08lIxJnemxA nBDrVirKiGN0OrdpyJpO9tP7CiwO6yVfl9DCKBni/+REBd268PTZglyU8ugH9zzJQN9p xHVwS3pMWRzYHu8+bvUZgghWfkDvC7xJ9HMES+/ULyx7QiG4SPFYiodk9jwbpdgVwC2G UDaTJgeRz1u9BrwuBPg44GCrIB0VRBgoVyl3syehN61fAs+dqCPKtiDDJ+ZPrpsfmodh 6rNQ== X-Gm-Message-State: AOJu0YxyWWkuFIJRqvV2S9vQ88WcfxsVQlYZB5YcWbcv0egvtVo3t5vk YLZwEaZtWUcwGUlkKxNFM1BT0ma2pmukkOypc5Z9ue4JL3qefPgXBAeRyg== X-Google-Smtp-Source: AGHT+IEjy1TWN8RrY8IFLr7gWu2H8uSQWxO4l9iw+nKYuPfDR4nbuU/svEv5JS4eQ+8yT0WNJs/2cg== X-Received: by 2002:a17:902:e948:b0:212:10ea:a4a1 with SMTP id d9443c01a7336-2124d465ac2mr49236515ad.15.1732026283767; Tue, 19 Nov 2024 06:24:43 -0800 (PST) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212389529b6sm29219115ad.236.2024.11.19.06.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 06:24:43 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 5/8] scan: parse station count from BSS load IE Date: Tue, 19 Nov 2024 06:24:27 -0800 Message-Id: <20241119142430.323074-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119142430.323074-1-prestwoj@gmail.com> References: <20241119142430.323074-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This will be used in BSS ranking --- src/scan.c | 4 ++-- src/scan.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scan.c b/src/scan.c index 2ffbef6d..64de57d2 100644 --- a/src/scan.c +++ b/src/scan.c @@ -1343,8 +1343,8 @@ static bool scan_parse_bss_information_elements(struct scan_bss *bss, iter.len + 2); break; case IE_TYPE_BSS_LOAD: - if (ie_parse_bss_load(&iter, NULL, &bss->utilization, - NULL) < 0) + if (ie_parse_bss_load(&iter, &bss->sta_count, + &bss->utilization, NULL) < 0) l_warn("Unable to parse BSS Load IE for " MAC, MAC_STR(bss->addr)); else diff --git a/src/scan.h b/src/scan.h index 50adca7c..4c1ebc21 100644 --- a/src/scan.h +++ b/src/scan.h @@ -67,6 +67,7 @@ struct scan_bss { uint8_t ssid[SSID_MAX_SIZE]; uint8_t ssid_len; uint8_t utilization; + uint16_t sta_count; uint8_t cc[3]; uint16_t rank; uint64_t time_stamp; From patchwork Tue Nov 19 14:24:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13880001 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D5F81CEACF for ; Tue, 19 Nov 2024 14:24:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026287; cv=none; b=PCmGjCd8aI4ORqt0AxTMTSpJAxiPZnbV466XDPflKcoUZFuZsZAehdbkefjKi52RM1AO8kaWN3/Atod5v6MsMplA4usX+2KxV26IYSFR9XsY6Luw92EDofz0zZs1VuKF+tQwxhKNuN+9hZrR1iQ6/8pn3g+ljUPUDq5G56YpEV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026287; c=relaxed/simple; bh=s5P9THym1xrPKeUoiPfpKUV/fT6odiPKVLjmoxx5iPU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TIx3ryQ6J8xjYAG+Ma0PzvSYoFpeC/raAq+17XgtAe9nA5gjwc80R3wY3/kSgOOcHVhxJPTyYweJXSxuO8J+/UsBYdfvK2Ig7q61hxpfV+wG9WwJ2FQaLGwxy3p303IRKc+RrscweOxW0GPRXUR6ckSvMTyvdZGenG/zHQSN7YM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TlaFCqgV; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TlaFCqgV" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-21210fe8775so17846235ad.1 for ; Tue, 19 Nov 2024 06:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732026285; x=1732631085; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kAmOltD/CiKXU3qRu9vi+6hwzYl2onLaVBZnDAEwbh8=; b=TlaFCqgVLASioxiK6VAzcB/R3J7MIo0SNBJEkFt2e8rIcqh9JcPkiIZNBUVWvpuzmz nMafCD0PAyqxUbmmirp96QgyOAvM3RLQ9Nr01Qclk6gGEAqvw5MIVDwufHRXyI2XPjQq g0uP4uIT1ZQb64K6/mM9HF7v1NZbvdF2FlgRoh5CUAD6lw8CkpY1DOfmrZP22gW3kODO buaRMBgYL2vL9pRgo7kZdS9QqXBGYep1Uy+BtPkfafpMuqWJWe95r1/kMnZLe44yWWSu i23vR0ThsUrOG9muPhBS3BLgz+40SYqt8oODi2rfC8e/aGi7xABpABAL0r6NsUMtLgph Uf9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732026285; x=1732631085; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kAmOltD/CiKXU3qRu9vi+6hwzYl2onLaVBZnDAEwbh8=; b=MrDel2NP54U5hJHFRjAFExQ/zVr97sG4JSCF3uF33P2NzRbFUoMSHpZ+Vpb8g6zeHD TxYUm3yNmXrOEka85olkWsv6Jl/TiUKaqOQPsv1kssoaot3byQA8AA3Z9Mbq1iEZalEC ijqFWlwzOjFoCME1a/5Nbd/YjUwxuAG2AL3jfOaTthVRXwOMpGavueoWzlK/nWY3nr3i rxq1+Iw7+UbDS3rVWMPslIj13LuW17IRyL6RVK975NLAKT7zh81Bc8gByQg/9S7O75/J 9/kCl136zn9e8kv4C7DsTkhXolx27bpJ2Es7mLagPKTddun5j3p0jL5Q83cB52uCIZk4 LkoQ== X-Gm-Message-State: AOJu0YygVaqV2bHvLeNVizQu4rpfPJW1sIfwwYHH/S1VJ066TB4RkHe9 gNJ3q67LTWRGo3FCEemZYJcTbc2qQ6SpB+V/jSlZMve1eUOElI8shT4rUg== X-Google-Smtp-Source: AGHT+IHn6cL3B7sFqHRlLuyFAJ/0f1rlMafkfTqByDZqcsWv6/tswWQpuEuvUcVrIK5C/J9SrcgP0g== X-Received: by 2002:a17:902:f792:b0:20c:b6cf:f465 with SMTP id d9443c01a7336-2124cf595c2mr50110225ad.6.1732026285301; Tue, 19 Nov 2024 06:24:45 -0800 (PST) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212389529b6sm29219115ad.236.2024.11.19.06.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 06:24:45 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 6/8] scan: add ranking modifiers for utilization/station count Date: Tue, 19 Nov 2024 06:24:28 -0800 Message-Id: <20241119142430.323074-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119142430.323074-1-prestwoj@gmail.com> References: <20241119142430.323074-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The utilization rank factor already existed but was very rigid and only checked a few values. This adds the (optional) ability to start applying an exponentially decaying factor to both utilization and station count after some threshold is reached. This area needs to be re-worked in order to support very highly loaded networks. If a network either doesn't support client balancing or does it poorly its left up to the clients to choose the best BSS possible given all the information available. In these cases connecting to a highly loaded BSS may fail, or result in a disconnect soon after connecting. In these cases its likely better for IWD to choose a slightly lower RSSI/datarate BSS over the conventionally 'best' BSS in order to aid in distributing the network load. The thresholds are currently optional and not enabled by default but if set they behave as follows: If the value is above the threshold it is mapped to an integer between 0 and 30. (using a starting range of - 255). This integer is then used to index in the exponential decay table to get a factor between 1 and 0. This factor is then applied to the rank. Note that as the value increases above the threshold the rank will be increasingly effected, as is expected for an exponential function. These option should be used with care as it may have unintended consequences, especially with very high load networks. i.e. you may see IWD roaming to BSS's with much lower signal if there are high load BSS's nearby. To maintain the existing behavior if there is no utilization factor set in main.conf the legacy thresholds/factors will be used. --- src/scan.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 7 deletions(-) diff --git a/src/scan.c b/src/scan.c index 64de57d2..aeab6516 100644 --- a/src/scan.c +++ b/src/scan.c @@ -56,6 +56,8 @@ static double RANK_2G_FACTOR; static double RANK_5G_FACTOR; static double RANK_6G_FACTOR; +static uint32_t RANK_HIGH_UTILIZATION; +static uint32_t RANK_HIGH_STATION_COUNT; static uint32_t SCAN_MAX_INTERVAL; static uint32_t SCAN_INIT_INTERVAL; @@ -1681,10 +1683,77 @@ static struct scan_bss *scan_parse_result(struct l_genl_msg *msg, return bss; } -static void scan_bss_compute_rank(struct scan_bss *bss) +static double scan_legacy_utilization_factor(uint8_t utilization) { static const double RANK_HIGH_UTILIZATION_FACTOR = 0.8; static const double RANK_LOW_UTILIZATION_FACTOR = 1.2; + + if (utilization >= 192) + return RANK_HIGH_UTILIZATION_FACTOR; + else if (utilization <= 63) + return RANK_LOW_UTILIZATION_FACTOR; + + return 1.0; +} + +static double scan_get_load_factors(uint8_t utilization, uint16_t sta_count) +{ + double n; + double factor = 1.0; + /* + * The exponential decay table has 64 entries (0 <= n <= 63) which range + * from 1.0 to 0.28. For the utilization and station count factors we + * likely don't want to adjust the rank so drastically (potentially a + * 78% reduction in the worse case) so cap the index at 30 which equates + * to ~64% at the worst case. + */ + static const uint8_t LOAD_DECAY_OFFSET = 30; + + if (!RANK_HIGH_UTILIZATION) { + /* + * To maintain existing behavior, if the utilization factor is + * unset (default) fall back to the static thresholds and + * factor weights. + */ + factor = scan_legacy_utilization_factor(utilization); + goto sta_count; + } else if (utilization < RANK_HIGH_UTILIZATION) + goto sta_count; + + /* Map the utilization threshold -> 255 to rankmod_table indexes */ + if (L_WARN_ON(!util_linear_map(utilization, RANK_HIGH_UTILIZATION, + 255, 0, LOAD_DECAY_OFFSET, &n))) + goto sta_count; + + factor = util_exponential_decay(n); + +sta_count: + if (!RANK_HIGH_STATION_COUNT || sta_count < RANK_HIGH_STATION_COUNT) + return factor; + + /* + * The station count is a uint16 so in theory it could be excessively + * large. In practice APs generally can't handle anywhere near this so + * put a cap at 255. If at some time in the future APs begin to handle + * this level of capacity we could increase this. + * + * TODO: A warning is used here to make this visible. If we see cases + * where this is happening we may need to give this another look. + */ + if (L_WARN_ON(sta_count > 255)) + sta_count = 255; + + if (L_WARN_ON(!util_linear_map(sta_count, RANK_HIGH_STATION_COUNT, + 255, 0, LOAD_DECAY_OFFSET, &n))) + return factor; + + factor *= util_exponential_decay(n); + + return factor; +} + +static void scan_bss_compute_rank(struct scan_bss *bss) +{ static const double RANK_HIGH_SNR_FACTOR = 1.2; static const double RANK_LOW_SNR_FACTOR = 0.8; double rank; @@ -1708,12 +1777,8 @@ static void scan_bss_compute_rank(struct scan_bss *bss) rank *= RANK_6G_FACTOR; /* Rank loaded APs lower and lightly loaded APs higher */ - if (bss->have_utilization) { - if (bss->utilization >= 192) - rank *= RANK_HIGH_UTILIZATION_FACTOR; - else if (bss->utilization <= 63) - rank *= RANK_LOW_UTILIZATION_FACTOR; - } + if (bss->have_utilization) + rank *= scan_get_load_factors(bss->utilization, bss->sta_count); if (bss->have_snr) { if (bss->snr <= 15) @@ -2599,6 +2664,20 @@ static int scan_init(void) if (SCAN_MAX_INTERVAL > UINT16_MAX) SCAN_MAX_INTERVAL = UINT16_MAX; + if (!l_settings_get_uint(config, "Rank", "HighUtilizationThreshold", + &RANK_HIGH_UTILIZATION)) + RANK_HIGH_UTILIZATION = 0; + + if (L_WARN_ON(RANK_HIGH_UTILIZATION > 255)) + RANK_HIGH_UTILIZATION = 255; + + if (!l_settings_get_uint(config, "Rank", "HighStationCountThreshold", + &RANK_HIGH_STATION_COUNT)) + RANK_HIGH_STATION_COUNT = 0; + + if (L_WARN_ON(RANK_HIGH_STATION_COUNT > 255)) + RANK_HIGH_STATION_COUNT = 255; + return 0; } From patchwork Tue Nov 19 14:24:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13880002 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAE2E2AE74 for ; Tue, 19 Nov 2024 14:24:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026289; cv=none; b=q4tMJSH1l3n7Awuk888stzbgYC/bJM96w1HeYw3gK2Fw97cimBvVOoXI3LGjyhlrmHdUgv+nil0x14EqoGGPg+qJ5k+PLtWQgMUSXphyhbYnnTIQXxKkGxAzSiE3/wmDGRqJERKsUEuTur1pif6pdQKOY8bP59MZkHKe3etItQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026289; c=relaxed/simple; bh=NirQB3cyt7O5tSx9qFIew+TfmRHe5J4KzY72aCuLJXE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gVoualBALaEg2Gl668hqVGC4iD4+fEXIMDVdz+LSdLPaG8PumOmcA7cyP7Sc6Ov4Cz99jjZ/4k80hs8Ye/Zln4agSwRRreL7fyqu6/ru20bfipoXkFoJrpwxuKj57/zxZJBWj+xei9uXQD629iUpcQ8/J31NuKMdZc0OLazKQ3g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fCt7g/3H; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fCt7g/3H" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71e52582cf8so2333594b3a.2 for ; Tue, 19 Nov 2024 06:24:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732026287; x=1732631087; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SNRIJ6fma0uq12NiUlwXj9EiGE28Tr3hgf8O7lL/fDw=; b=fCt7g/3HRxsy7y8jEtBhaTnSF4dtTl6AGGWihwKqk2rNC0UTRMMEwVt7Euff9iwoWq p7X7nmsil5uKOsDJn4RQ2JO5ei/gnzhL8RREjTzM2RC8oXV2csWNgJ1MG/jokMKaQ6SY yX83KM6cOuuur4iPPtqKD8y5/uOYAJvVk4A/LEuSweZhpSaw5I2vG9ys8bBZJ9YWtqv1 FPPT+8Hn7Bibcp/sMdEV2b3veAqbiuWIYQKCPNc6UcIsQf0iRlLXalSkXmAmLtRtgHo7 TtyMYLtJmRVy7tsXt77jdNbAvPF1U3Z32Wc9vtDq3y6jNEHMTQQHwXI/ssHi3/FzBhs3 7rtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732026287; x=1732631087; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SNRIJ6fma0uq12NiUlwXj9EiGE28Tr3hgf8O7lL/fDw=; b=QZlvKI0av9FdQYCpGH4EzmL+0vr7YKLSuXDx5/0tFpnUlxAYMdU8kUKUb8JEsDGSQ3 DqIMBgfqh7USLYK5+F1CQyo5GY6hs0Vim1hyJvyQELhcBB/KNk+aMRljgjhdlV+O6RX0 /4i+lztDn4bS9Jg57XDSCF6kRMMYCaOS3WMwkUV3RCwa4x4FUm7rD8sCONanlM83MrhC WsDEMYmpxiFgsu2SudJhTiDmG7/DGWnMxTdvTjhhkt6+ogsdZgArocHtmLU6NCDFviHL e9KftNwo0NFJcJAyFgRwMr7KuGWiVuLSX9MZxCFozBDpr8IRxQ9MJx3CExAdvoleVFpw Sivw== X-Gm-Message-State: AOJu0YwX9NVO3IZQ48JK7Nikx5vp1PI39WHHE7WTvT87+t438yNS8ehy S9M7CIzQPboohgdeyA+HVS40rKCXhAqVfUKsdKQq9hGXtpJwDp27Npnblw== X-Google-Smtp-Source: AGHT+IFYDHVsZU1ajUBW7ZityAmy4HwCkPfqXKUdmK7htlynLpU/R1cDxykRnXscxk7i7VloDnroYA== X-Received: by 2002:a17:902:e889:b0:212:6011:594a with SMTP id d9443c01a7336-21260209ce9mr11936855ad.3.1732026286792; Tue, 19 Nov 2024 06:24:46 -0800 (PST) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212389529b6sm29219115ad.236.2024.11.19.06.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 06:24:46 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 7/8] doc: document [Rank].HighUtilization/StationCount thresholds Date: Tue, 19 Nov 2024 06:24:29 -0800 Message-Id: <20241119142430.323074-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119142430.323074-1-prestwoj@gmail.com> References: <20241119142430.323074-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/iwd.config.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/iwd.config.rst b/src/iwd.config.rst index 9dc0fe0c..1cb4b05d 100644 --- a/src/iwd.config.rst +++ b/src/iwd.config.rst @@ -341,6 +341,28 @@ autoconnect purposes. A value of 0.0 will disable the 6GHz band and prevent scanning or connecting on those frequencies. + * - HighUtilizationThreshold + - Values: unsigned integer value 0 - 255 (default: **0**, disabled) + + **Warning: This is an experimental feature** + + The BSS utilization threshold at which a negative rank factor begins to + be applied to the BSS. As the load increases for a BSS the ranking factor + decays exponentially, meaning the ranking factor will decrease + exponentially. Setting this can have very drastic effects on the BSS rank + if its utilization is high, use with care. + + * - HighStationCountThreshold + - Values: unsigned integer value 0 - 255 (default: **0**, disabled) + + **Warning: This is an experimental feature** + + The BSS station count threshold at which a negative rank factor begins to + be applied to the BSS. As the station count increases for a BSS the + ranking factor decays exponentially, meaning the ranking factor will + decrease exponentially. Setting this can have very drastic effects on the + BSS rank if its station count is high, use with care. + Scan ---- From patchwork Tue Nov 19 14:24:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13880003 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 596A01CCB49 for ; Tue, 19 Nov 2024 14:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026290; cv=none; b=BcyHPDQW8ewYAcrnDxu4Di1iCV5fP96O1z0BndIf7H1dvqUY/72YuqM0mG1+T8GhD6UOboiMrhyF3W0XinbqU0hsllKocGzsaUo7UYiP/g73y5yUnLqFIh4WXsOHbpJ0siThau6Ja/8PuNctFGAd542IJn70Bi01bHIsx/1ipDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732026290; c=relaxed/simple; bh=BiTPn8V7GCMEkkiqLNJDXuX66xFv9ryNc59hfIyX5Ew=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CL2GlsBkrBKsZhBsvMOuP/ErhhVGbDGcWdC0g7vbtYF62LoUuDcbcyOIQo+5t9YD6KmDA4O+vW4UBgHSdlJp/Vv0oBdT/Zp+brNmXI+N1dbfx6RLE+76Pawp5OXWLCMEzMru0xlmiAwBOst73hzQDAKGDpvM7vEcPfdUtlNpuuw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TE7SwxTU; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TE7SwxTU" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-21210eaa803so25826835ad.2 for ; Tue, 19 Nov 2024 06:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732026288; x=1732631088; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JDyQWJb3P+nou5ag+H+i6p2nhJWw2sD4+N0iPLIwRCo=; b=TE7SwxTUVjLm4nWtf3X+GAHyyvD71x54kx0naxgTiCxA909Nnp7Ko05tTJ9RtXPD8r w3qyLTuVXWiUpV4M/QBh2dXZLcXMS+uYMlaGACrBdldGDiSt/XM17+Zc3Ngto0Q4tEbB 2vuUwlAUX8UUHk00vQpWBfGLEGFOA7rcYjakddUPx31ZPbJvk/JHg8UGQ9UYjjHhcg+1 wXMVfj6kdhEomuX33sXqYKBF0x6QbWBNXVX8myXoTzpTFhMxYp2A16n+oiZ+N+z7jr3O QRrH1EqH/7fuMWJQSF0Hw/BIyyIgxFNA9LUFfMtrkcrT4pB42OBmja7x68JZtd6fu3Nn U6Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732026288; x=1732631088; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JDyQWJb3P+nou5ag+H+i6p2nhJWw2sD4+N0iPLIwRCo=; b=GBZ+D3Bl4vHf6gnaMkhd3S7Stu4cJAPYzpLHnfeRRohABRNRXf7fFjmnJvdMeCrh11 VuIJCc00ZNwTV0IVcfY3dTPqqSzWeZ/Ak/rWJFJNLKRn5qMsgi58hUhaMpejL1ra4KWo OqSAJKTXPFE8AGRfEKtSTRMlEyqOuJjbQ3RI/HUwRDpRlwHJTZRmIeNb5i1CJNHe5A4g D+KUihEQ6kyJvkDuiEkDSdLelw7Co0LjKiTr77lMHL0kIIH0cwwg1kyG05GfAOkjsbDn Ttpj1sf0lvHQSib+5cOXWIXjg1C6kKb8zLFRnPlvFzZoOQxEB6vIv9beKqHvUaKoeVJq GGcw== X-Gm-Message-State: AOJu0Yyt6p6mMecfhRpL4oQtGy+VZxfttDFbimkiJ2o3vpaep/BkIS0g DJ1cnnl4A8wFCHkpft8AJ70Y0/T9cZu7os74ej1B0nZuXMRx6HYt2sU8Hw== X-Google-Smtp-Source: AGHT+IHrddJW+HUJ8DTrUFy5GJDbq4qvT8aagyl4Zd+1VQHizsbl3K6x+EKoVW6pGDy/lNCzdD0Z5Q== X-Received: by 2002:a17:903:22c1:b0:212:26e:712c with SMTP id d9443c01a7336-212026e857fmr144221565ad.26.1732026288332; Tue, 19 Nov 2024 06:24:48 -0800 (PST) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212389529b6sm29219115ad.236.2024.11.19.06.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 06:24:48 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 8/8] station: print client count in scan results Date: Tue, 19 Nov 2024 06:24:30 -0800 Message-Id: <20241119142430.323074-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119142430.323074-1-prestwoj@gmail.com> References: <20241119142430.323074-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/station.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/station.c b/src/station.c index 71dc4c21..1238734f 100644 --- a/src/station.c +++ b/src/station.c @@ -425,7 +425,8 @@ static void station_print_scan_bss(const struct scan_bss *bss) ptr += sprintf(ptr, ", snr: %d", bss->snr); if (bss->have_utilization) - ptr += sprintf(ptr, ", load: %u/255", bss->utilization); + ptr += sprintf(ptr, ", load: %u/255, clients: %u", + bss->utilization, bss->sta_count); l_debug("Processing BSS '%s' with SSID: %s, freq: %u, rank: %u, " "strength: %i, data_rate: %u.%u%s",