diff mbox series

wpa_supplicant: Add an option to disable SNR capping

Message ID 20240319204008.792040-1-Chaitanya.Tata@nordicsemi.no
State Changes Requested
Headers show
Series wpa_supplicant: Add an option to disable SNR capping | expand

Commit Message

Krishna Chaitanya March 19, 2024, 8:40 p.m. UTC
When selecting a network the default behaviour of WPA supplicant is to
prefer higher throughput, it does this by capping the SNR.

But in certain environments, reliability is important over throughput
and choosing a lower SNR (thought it is greater than "Great SNR") might
be sub-optimal.

Introduce a configuration option to choose the two options (throughput
or reliability).

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
---
 wpa_supplicant/Makefile  |  4 ++++
 wpa_supplicant/defconfig | 11 +++++++++++
 wpa_supplicant/scan.h    | 10 ++++++++++
 3 files changed, 25 insertions(+)

Comments

Ben Greear March 19, 2024, 8:46 p.m. UTC | #1
On 3/19/24 13:40, Chaitanya Tata wrote:
> When selecting a network the default behaviour of WPA supplicant is to
> prefer higher throughput, it does this by capping the SNR.
> 
> But in certain environments, reliability is important over throughput
> and choosing a lower SNR (thought it is greater than "Great SNR") might
> be sub-optimal.
> 
> Introduce a configuration option to choose the two options (throughput
> or reliability).

Could you make this a run-time configurable instead of compile time option?

That seems a lot more flexible to me...

Thanks,
Ben

> 
> Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
> ---
>   wpa_supplicant/Makefile  |  4 ++++
>   wpa_supplicant/defconfig | 11 +++++++++++
>   wpa_supplicant/scan.h    | 10 ++++++++++
>   3 files changed, 25 insertions(+)
> 
> diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
> index ce1c8b2e3..dc3dbf0ca 100644
> --- a/wpa_supplicant/Makefile
> +++ b/wpa_supplicant/Makefile
> @@ -1877,6 +1877,10 @@ ifdef CONFIG_NO_TKIP
>   CFLAGS += -DCONFIG_NO_TKIP
>   endif
>   
> +ifdef CONFIG_NW_SEL_RELIABILITY
> +CFLAGS += -DCONFIG_NW_SEL_RELIABILITY
> +endif
Krishna Chaitanya March 19, 2024, 9:18 p.m. UTC | #2
On Wed, Mar 20, 2024 at 2:19 AM Ben Greear <greearb@candelatech.com> wrote:
>
> On 3/19/24 13:40, Chaitanya Tata wrote:
> > When selecting a network the default behaviour of WPA supplicant is to
> > prefer higher throughput, it does this by capping the SNR.
> >
> > But in certain environments, reliability is important over throughput
> > and choosing a lower SNR (thought it is greater than "Great SNR") might
> > be sub-optimal.
> >
> > Introduce a configuration option to choose the two options (throughput
> > or reliability).
>
> Could you make this a run-time configurable instead of compile time option?
>
> That seems a lot more flexible to me...

Runtime is a bit trickier as the WPA supplicant maintains an
aggregated scan list (maintained
using ageing), so, if we change the criterion in between, we might
have to flush the existing
scan results and start afresh, hence went with compile time.

But I will think more about this (this was a fresh bug) while I await
any other feedback.
Jouni Malinen March 23, 2024, 7:49 p.m. UTC | #3
On Wed, Mar 20, 2024 at 02:48:39AM +0530, Krishna Chaitanya wrote:
> Runtime is a bit trickier as the WPA supplicant maintains an
> aggregated scan list (maintained
> using ageing), so, if we change the criterion in between, we might
> have to flush the existing
> scan results and start afresh, hence went with compile time.
> 
> But I will think more about this (this was a fresh bug) while I await
> any other feedback.

I do not really like adding build time configuration parameters for
something like this, so I would be much more likely to apply a version
that allows configuration to be done from the runtime configuration
file. I don't see this really being toggled that frequently, but it
makes no sense for distros to be forced to distribute two different
binaries if they want to support both options.
Krishna Chaitanya March 24, 2024, 4:02 p.m. UTC | #4
On Sun, Mar 24, 2024 at 1:19 AM Jouni Malinen <j@w1.fi> wrote:
>
> On Wed, Mar 20, 2024 at 02:48:39AM +0530, Krishna Chaitanya wrote:
> > Runtime is a bit trickier as the WPA supplicant maintains an
> > aggregated scan list (maintained
> > using ageing), so, if we change the criterion in between, we might
> > have to flush the existing
> > scan results and start afresh, hence went with compile time.
> >
> > But I will think more about this (this was a fresh bug) while I await
> > any other feedback.
>
> I do not really like adding build time configuration parameters for
> something like this, so I would be much more likely to apply a version
> that allows configuration to be done from the runtime configuration
> file. I don't see this really being toggled that frequently, but it
> makes no sense for distros to be forced to distribute two different
> binaries if they want to support both options.
I have chosen compile time as this option is seldom changed, but
I understand your point about maintaining separate binaries.

I will add a runtime configuration option for the scan, thanks.
diff mbox series

Patch

diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
index ce1c8b2e3..dc3dbf0ca 100644
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
@@ -1877,6 +1877,10 @@  ifdef CONFIG_NO_TKIP
 CFLAGS += -DCONFIG_NO_TKIP
 endif
 
+ifdef CONFIG_NW_SEL_RELIABILITY
+CFLAGS += -DCONFIG_NW_SEL_RELIABILITY
+endif
+
 dynamic_eap_methods: $(EAPDYN)
 
 _OBJS_VAR := OBJS_priv
diff --git a/wpa_supplicant/defconfig b/wpa_supplicant/defconfig
index 708a82385..0b87fb5df 100644
--- a/wpa_supplicant/defconfig
+++ b/wpa_supplicant/defconfig
@@ -628,3 +628,14 @@  CONFIG_DPP=y
 # design is still subject to change. As such, this should not yet be enabled in
 # production use.
 #CONFIG_PASN=y
+
+# When selecting a network, prefer networks with a better signal strength
+# without any cap a.k.a "Great SNR".
+#
+# If this is enabled then higher SNR is preferred without any cap over higher band
+# (higher throughput) to achieve better reliability.
+#
+# If this is disabled then for networks with capped SNR, the preference is given
+# to the network with higher band (5GHz or 6GHz) and then to the network with
+# higher SNR.
+#CONFIG_NW_SEL_RELIABILITY=y
diff --git a/wpa_supplicant/scan.h b/wpa_supplicant/scan.h
index d1780eb09..175dc37ef 100644
--- a/wpa_supplicant/scan.h
+++ b/wpa_supplicant/scan.h
@@ -18,6 +18,15 @@ 
 #define DEFAULT_NOISE_FLOOR_5GHZ (-92)
 #define DEFAULT_NOISE_FLOOR_6GHZ (-92)
 
+#ifdef CONFIG_NW_SEL_RELIABILITY
+/*
+ * This basically disables capping the SNR when choosing the best BSS. This
+ * means that the BSS with the highest SNR will be chosen, independent of the
+ * band. This is useful for scenarios where reliability is more important than
+ * throughput.
+ */
+#define GREAT_SNR 999
+#else
 /*
  * Channels with a great SNR can operate at full rate. What is a great SNR?
  * This doc https://supportforums.cisco.com/docs/DOC-12954 says, "the general
@@ -29,6 +38,7 @@ 
  * somewhat conservative value here.
  */
 #define GREAT_SNR 25
+#endif /* CONFIG_NW_SEL_RELIABILITY */
 
 #define IS_2P4GHZ(n) (n >= 2412 && n <= 2484)
 #define IS_5GHZ(n) (n > 4000 && n < 5895)