All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Per chain RSSI reporting
@ 2017-05-26 22:49 ` Norik Dzhandzhapanyan
  0 siblings, 0 replies; 36+ messages in thread
From: Norik Dzhandzhapanyan @ 2017-05-26 22:49 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless

Add support for per chain RSSI reporting w/smoothing.

Signed-off-by: Norik Dzhandzhapanyan norikd@ethertronics.com


--- htt_rx.c.orig  2017-05-26 15:26:37.918504255 -0700
+++ htt_rx.c        2017-05-26 12:10:33.139809025 -0700
@@ -825,14 +825,71 @@ static bool ath10k_htt_rx_h_channel(stru
              return true;
}

+/*
+ * Signal data is somewhat glitchy. We smooth it out here with
+ * a 16 point moving average by storing samples in a buffer.
+ * As new samples come in, remove the oldest and add the newest
+ * to the running sum.  Avoids changes/impact to other generic averaging.
+ */
+
+/* Moving average buffer */
+#define MA_SAMPLES (16)
+
+struct ma_buffer
+{
+             int count;
+             int head;
+             int tail;
+             int sum;
+             int samps[MA_SAMPLES];
+};
+
+struct ma_buffer ma_buffers[IEEE80211_MAX_CHAINS] =3D {{ 0 }};
+
+static int ath_cb_moving_average(struct ma_buffer *mb, int8_t samp)
+{
+             if (mb->count < MA_SAMPLES) {
+                            mb->count++;
+                            mb->sum +=3D samp;
+                            mb->tail =3D 0;
+             } else {
+                            int oldest =3D mb->samps[mb->tail];
+                            mb->tail =3D (mb->head =3D=3D MA_SAMPLES - 1) =
? 0 : mb->head + 1;
+                            mb->sum =3D mb->sum - oldest + samp;
+             }
+
+             mb->samps[mb->head] =3D samp;
+             mb->head =3D (mb->head =3D=3D MA_SAMPLES - 1) ? 0 : mb->head =
+ 1;
+
+             return (mb->sum / mb->count);
+}
+
static void ath10k_htt_rx_h_signal(struct ath10k *ar,
                                                              struct ieee80=
211_rx_status *status,
                                                              struct htt_rx=
_desc *rxd)
{
-              /* FIXME: Get real NF */
-              status->signal =3D ATH10K_DEFAULT_NOISE_FLOOR +
-                                            rxd->ppdu_start.rssi_comb;
-              status->flag &=3D ~RX_FLAG_NO_SIGNAL_VAL;
+    int i;
+
+    for(i=3D0;i<IEEE80211_MAX_CHAINS;i++)
+    {
+        status->chains &=3D ~BIT(i);
+
+        if (rxd->ppdu_start.rssi_chains[i].pri20_mhz !=3D 0x80)
+        {
+            int8_t rssi =3D ATH10K_DEFAULT_NOISE_FLOOR +
+                rxd->ppdu_start.rssi_chains[i].pri20_mhz;
+
+            status->chains |=3D BIT(i);
+
+            /* Compute the moving average of rssi */
+                                status->chain_signal[i] =3D ath_cb_moving_=
average(&ma_buffers[i], rssi);
+        }
+    }
+
+    /* FIXME: Get real NF */
+    status->signal =3D ATH10K_DEFAULT_NOISE_FLOOR +
+        rxd->ppdu_start.rssi_comb;
+    status->flag &=3D ~RX_FLAG_NO_SIGNAL_VAL;
}

 static void ath10k_htt_rx_h_mactime(struct ath10k *ar,
The contents of this transmission are Ethertronics Inc. Confidential and ma=
y contain proprietary or legally privileged information which may not be di=
sclosed, copied or distributed without the express written consent of Ether=
tronics Inc. The information is intended to be for the use of the individua=
l or entity named on this transmission. If you are not the intended recipie=
nt, be aware that any disclosure, copying, distribution or use of the conte=
nts of this information is prohibited. If you have received this transmissi=
on in error, please notify us by telephone immediately so that we can arran=
ge for the retrieval of the original documents at no cost to you. Alternati=
vely, notify the sender by replying to this transmission and delete the mes=
sage without disclosing it. Thank you

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2017-05-31 13:06 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 22:49 [PATCH] Per chain RSSI reporting Norik Dzhandzhapanyan
2017-05-26 22:49 ` Norik Dzhandzhapanyan
2017-05-27  1:12 ` Adrian Chadd
2017-05-27  1:12   ` Adrian Chadd
2017-05-27  2:09   ` Norik Dzhandzhapanyan
2017-05-27  2:09     ` Norik Dzhandzhapanyan
2017-05-27  8:30     ` Norik Dzhandzhapanyan
2017-05-27  8:30       ` Norik Dzhandzhapanyan
2017-05-27 16:07     ` Ben Greear
2017-05-27 16:07       ` Ben Greear
2017-05-27 16:39       ` Adrian Chadd
2017-05-27 16:39         ` Adrian Chadd
2017-05-27 17:56         ` Michael Ney
2017-05-27 17:56           ` Michael Ney
2017-05-27 19:30           ` Norik Dzhandzhapanyan
2017-05-27 19:30             ` Norik Dzhandzhapanyan
2017-05-27 22:10             ` Michael Ney
2017-05-27 22:10               ` Michael Ney
2017-05-28  1:22               ` Norik Dzhandzhapanyan
2017-05-28  1:22                 ` Norik Dzhandzhapanyan
2017-05-27 19:31           ` Norik Dzhandzhapanyan
2017-05-27 19:31             ` Norik Dzhandzhapanyan
2017-05-27 19:25         ` Norik Dzhandzhapanyan
2017-05-27 19:25           ` Norik Dzhandzhapanyan
2017-05-27 21:38           ` Ben Greear
2017-05-27 21:38             ` Ben Greear
     [not found]             ` <SN1PR08MB13736CC61B1D00ED2968CF5CB0FD0@SN1PR08MB1373.namprd08.prod.outlook.com>
2017-05-27 21:49               ` Ben Greear
2017-05-27 21:49                 ` Ben Greear
2017-05-30 13:23                 ` Matthias May
2017-05-30 13:23                   ` Matthias May
2017-05-31 13:05     ` Kalle Valo
2017-05-31 13:05       ` Kalle Valo
2017-05-31 12:53   ` Kalle Valo
2017-05-31 12:53     ` Kalle Valo
2017-05-31 12:52 ` Kalle Valo
2017-05-31 12:52   ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.