ATH10K Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Per chain RSSI reporting
@ 2017-05-26 22:49 Norik Dzhandzhapanyan
  2017-05-27  1:12 ` Adrian Chadd
  2017-05-31 12:52 ` Kalle Valo
  0 siblings, 2 replies; 18+ messages in thread
From: Norik Dzhandzhapanyan @ 2017-05-26 22:49 UTC (permalink / raw)
  To: ath10k@lists.infradead.org; +Cc: linux-wireless@vger.kernel.org

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] = {{ 0 }};
+
+static int ath_cb_moving_average(struct ma_buffer *mb, int8_t samp)
+{
+             if (mb->count < MA_SAMPLES) {
+                            mb->count++;
+                            mb->sum += samp;
+                            mb->tail = 0;
+             } else {
+                            int oldest = mb->samps[mb->tail];
+                            mb->tail = (mb->head == MA_SAMPLES - 1) ? 0 : mb->head + 1;
+                            mb->sum = mb->sum - oldest + samp;
+             }
+
+             mb->samps[mb->head] = samp;
+             mb->head = (mb->head == MA_SAMPLES - 1) ? 0 : mb->head + 1;
+
+             return (mb->sum / mb->count);
+}
+
static void ath10k_htt_rx_h_signal(struct ath10k *ar,
                                                              struct ieee80211_rx_status *status,
                                                              struct htt_rx_desc *rxd)
{
-              /* FIXME: Get real NF */
-              status->signal = ATH10K_DEFAULT_NOISE_FLOOR +
-                                            rxd->ppdu_start.rssi_comb;
-              status->flag &= ~RX_FLAG_NO_SIGNAL_VAL;
+    int i;
+
+    for(i=0;i<IEEE80211_MAX_CHAINS;i++)
+    {
+        status->chains &= ~BIT(i);
+
+        if (rxd->ppdu_start.rssi_chains[i].pri20_mhz != 0x80)
+        {
+            int8_t rssi = ATH10K_DEFAULT_NOISE_FLOOR +
+                rxd->ppdu_start.rssi_chains[i].pri20_mhz;
+
+            status->chains |= BIT(i);
+
+            /* Compute the moving average of rssi */
+                                status->chain_signal[i] = ath_cb_moving_average(&ma_buffers[i], rssi);
+        }
+    }
+
+    /* FIXME: Get real NF */
+    status->signal = ATH10K_DEFAULT_NOISE_FLOOR +
+        rxd->ppdu_start.rssi_comb;
+    status->flag &= ~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 may contain proprietary or legally privileged information which may not be disclosed, copied or distributed without the express written consent of Ethertronics Inc. The information is intended to be for the use of the individual or entity named on this transmission. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this transmission in error, please notify us by telephone immediately so that we can arrange for the retrieval of the original documents at no cost to you. Alternatively, notify the sender by replying to this transmission and delete the message without disclosing it. Thank you

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

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

Thread overview: 18+ 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-27  1:12 ` Adrian Chadd
2017-05-27  2:09   ` Norik Dzhandzhapanyan
2017-05-27  8:30     ` Norik Dzhandzhapanyan
2017-05-27 16:07     ` Ben Greear
2017-05-27 16:39       ` Adrian Chadd
2017-05-27 17:56         ` Michael Ney
2017-05-27 19:30           ` Norik Dzhandzhapanyan
2017-05-27 22:10             ` Michael Ney
2017-05-28  1:22               ` Norik Dzhandzhapanyan
2017-05-27 19:31           ` Norik Dzhandzhapanyan
2017-05-27 19:25         ` Norik Dzhandzhapanyan
2017-05-27 21:38           ` Ben Greear
     [not found]             ` <SN1PR08MB13736CC61B1D00ED2968CF5CB0FD0@SN1PR08MB1373.namprd08.prod.outlook.com>
2017-05-27 21:49               ` Ben Greear
2017-05-30 13:23                 ` Matthias May
2017-05-31 13:05     ` Kalle Valo
2017-05-31 12:53   ` Kalle Valo
2017-05-31 12:52 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox