All of lore.kernel.org
 help / color / mirror / Atom feed
From: Norik Dzhandzhapanyan <norikd@ethertronics.com>
To: "ath10k@lists.infradead.org" <ath10k@lists.infradead.org>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: [PATCH] Per chain RSSI reporting
Date: Fri, 26 May 2017 22:49:45 +0000	[thread overview]
Message-ID: <SN1PR08MB1373BF583E9CE2AA6A0F6381B0FC0@SN1PR08MB1373.namprd08.prod.outlook.com> (raw)

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

WARNING: multiple messages have this Message-ID (diff)
From: Norik Dzhandzhapanyan <norikd@ethertronics.com>
To: "ath10k@lists.infradead.org" <ath10k@lists.infradead.org>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: [PATCH] Per chain RSSI reporting
Date: Fri, 26 May 2017 22:49:45 +0000	[thread overview]
Message-ID: <SN1PR08MB1373BF583E9CE2AA6A0F6381B0FC0@SN1PR08MB1373.namprd08.prod.outlook.com> (raw)

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

             reply	other threads:[~2017-05-26 22:49 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 22:49 Norik Dzhandzhapanyan [this message]
2017-05-26 22:49 ` [PATCH] Per chain RSSI reporting 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SN1PR08MB1373BF583E9CE2AA6A0F6381B0FC0@SN1PR08MB1373.namprd08.prod.outlook.com \
    --to=norikd@ethertronics.com \
    --cc=ath10k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.