2022-09-15 00:44:04

by Bryan O'Donoghue

[permalink] [raw]
Subject: [PATCH v3 1/1] wcn36xx: Add RX frame SNR as a source of system entropy

The signal-to-noise-ratio SNR is returned by the wcn36xx firmware for each
received frame. SNR represents all of the unwanted interference signal
after filtering out the fundamental frequency and harmonics of the
frequency.

Noise can come from various electromagnetic sources, from temperature
affecting the performance hardware components or quantization effects
converting from analog to digital domains.

The SNR value returned by the WiFi firmware then is a good source of
entropy.

Other WiFi drivers offer up the noise component of the FFT as an entropy
source for the random pool e.g.

commit 2aa56cca3571 ("ath9k: Mix the received FFT bins to the random pool")

I attended Jason's talk on sources of randomness at Plumbers and it
occurred to me that SNR is a reasonable candidate to add.

Cc: Jason A. Donenfeld <[email protected]>
Signed-off-by: Bryan O'Donoghue <[email protected]>
---
drivers/net/wireless/ath/wcn36xx/txrx.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c
index 8da3955995b6e..0802ed7288249 100644
--- a/drivers/net/wireless/ath/wcn36xx/txrx.c
+++ b/drivers/net/wireless/ath/wcn36xx/txrx.c
@@ -16,6 +16,7 @@

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

+#include <linux/random.h>
#include "txrx.h"

static inline int get_rssi0(struct wcn36xx_rx_bd *bd)
@@ -278,6 +279,7 @@ static void wcn36xx_update_survey(struct wcn36xx *wcn, int rssi, int snr,
struct ieee80211_supported_band *sband;
int idx;
int i;
+ u8 snr_sample = snr & 0xff;

idx = 0;
if (band == NL80211_BAND_5GHZ)
@@ -297,6 +299,8 @@ static void wcn36xx_update_survey(struct wcn36xx *wcn, int rssi, int snr,
wcn->chan_survey[idx].rssi = rssi;
wcn->chan_survey[idx].snr = snr;
spin_unlock(&wcn->survey_lock);
+
+ add_device_randomness(&snr_sample, sizeof(snr_sample));
}

int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb)
--
2.37.3


2022-09-16 16:48:11

by Loic Poulain

[permalink] [raw]
Subject: Re: [PATCH v3 1/1] wcn36xx: Add RX frame SNR as a source of system entropy

On Thu, 15 Sept 2022 at 02:41, Bryan O'Donoghue <[email protected]>
wrote:
>
> The signal-to-noise-ratio SNR is returned by the wcn36xx firmware for each
> received frame. SNR represents all of the unwanted interference signal
> after filtering out the fundamental frequency and harmonics of the
> frequency.
>
> Noise can come from various electromagnetic sources, from temperature
> affecting the performance hardware components or quantization effects
> converting from analog to digital domains.
>
> The SNR value returned by the WiFi firmware then is a good source of
> entropy.
>
> Other WiFi drivers offer up the noise component of the FFT as an entropy
> source for the random pool e.g.
>
> commit 2aa56cca3571 ("ath9k: Mix the received FFT bins to the random
pool")
>
> I attended Jason's talk on sources of randomness at Plumbers and it
> occurred to me that SNR is a reasonable candidate to add.
>
> Cc: Jason A. Donenfeld <[email protected]>
> Signed-off-by: Bryan O'Donoghue <[email protected]>

Acked-by: Loic Poulain <[email protected]>

2022-09-19 12:43:41

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v3 1/1] wcn36xx: Add RX frame SNR as a source of system entropy

Bryan O'Donoghue <[email protected]> wrote:

> The signal-to-noise-ratio SNR is returned by the wcn36xx firmware for each
> received frame. SNR represents all of the unwanted interference signal
> after filtering out the fundamental frequency and harmonics of the
> frequency.
>
> Noise can come from various electromagnetic sources, from temperature
> affecting the performance hardware components or quantization effects
> converting from analog to digital domains.
>
> The SNR value returned by the WiFi firmware then is a good source of
> entropy.
>
> Other WiFi drivers offer up the noise component of the FFT as an entropy
> source for the random pool e.g.
>
> commit 2aa56cca3571 ("ath9k: Mix the received FFT bins to the random pool")
>
> I attended Jason's talk on sources of randomness at Plumbers and it
> occurred to me that SNR is a reasonable candidate to add.
>
> Cc: Jason A. Donenfeld <[email protected]>
> Signed-off-by: Bryan O'Donoghue <[email protected]>
> Signed-off-by: Kalle Valo <[email protected]>

Patch applied to ath-next branch of ath.git, thanks.

e1a6b5d3a971 wifi: wcn36xx: Add RX frame SNR as a source of system entropy

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches