diff mbox series

nl80211: Add per peer statistics to compute FCS error rate

Message ID 1538060517-32208-1-git-send-email-jouni@codeaurora.org (mailing list archive)
State Accepted
Delegated to: Johannes Berg
Headers show
Series nl80211: Add per peer statistics to compute FCS error rate | expand

Commit Message

Jouni Malinen Sept. 27, 2018, 3:01 p.m. UTC
From: Ankita Bajaj <bankita@codeaurora.org>

Add support for drivers to report the total number of MPDUs received
and the number of MPDUs received with an FCS error from a specific
peer. These counters will be incremented only when the TA of the
frame matches the MAC address of the peer irrespective of FCS
error.

It should be noted that the TA field in the frame might be corrupted
when there is an FCS error and TA matching logic would fail in such
cases. Hence, FCS error counter might not be fully accurate, but it can
provide help in detecting bad RX links in significant number of cases.
This FCS error counter without full accuracy can be used, e.g., to
trigger a kick-out of a connected client with a bad link in AP mode to
force such a client to roam to another AP.

Signed-off-by: Ankita Bajaj <bankita@codeaurora.org>
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
---
 include/net/cfg80211.h       | 7 +++++++
 include/uapi/linux/nl80211.h | 8 ++++++++
 net/wireless/nl80211.c       | 2 ++
 3 files changed, 17 insertions(+)

Comments

Johannes Berg Oct. 1, 2018, 10:19 a.m. UTC | #1
On Thu, 2018-09-27 at 18:01 +0300, Jouni Malinen wrote:
> From: Ankita Bajaj <bankita@codeaurora.org>
> 
> Add support for drivers to report the total number of MPDUs received
> and the number of MPDUs received with an FCS error from a specific
> peer. These counters will be incremented only when the TA of the
> frame matches the MAC address of the peer irrespective of FCS
> error.

Hmm. The error one seems mostly reasonable, I guess, but do we really
not having anything that's the total number of MPDUs already?

And then, I guess, what exactly would you want there? We might not
always even be able to provide that?

I'm also left wondering what the application here is - perhaps another
thing we could just implement in BPF with the hooks I previously posted
(but admittedly never finished)?

johannes
bankita@codeaurora.org Oct. 4, 2018, 5:32 p.m. UTC | #2
On 2018-10-01 15:49, Johannes Berg wrote:
> On Thu, 2018-09-27 at 18:01 +0300, Jouni Malinen wrote:
>> From: Ankita Bajaj <bankita@codeaurora.org>
>> 
>> Add support for drivers to report the total number of MPDUs received
>> and the number of MPDUs received with an FCS error from a specific
>> peer. These counters will be incremented only when the TA of the
>> frame matches the MAC address of the peer irrespective of FCS
>> error.

We do have rx_packets field but it is for MMPDUs and MSDUs which might 
not reflect the number of MPDUs in all cases. Hence we introduced new 
field for MPDU count.

> Hmm. The error one seems mostly reasonable, I guess, but do we really
> not having anything that's the total number of MPDUs already?
> 
> And then, I guess, what exactly would you want there? We might not
> always even be able to provide that?

> I'm also left wondering what the application here is -

These two fields together will help to find bad rx link with a specific 
peer. This information can be used for example to steer the client to a 
different BSS.

Ankita
diff mbox series

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9f3ed79..1fbb2d9 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1292,6 +1292,10 @@  struct cfg80211_tid_stats {
  * @ack_signal: signal strength (in dBm) of the last ACK frame.
  * @avg_ack_signal: average rssi value of ack packet for the no of msdu's has
  *	been sent.
+ * @rx_mpdu_count: number of MPDUs received from this station
+ * @fcs_err_count: number of packets (MPDUs) received from this station with
+ *	an FCS error. This counter should be incremented only when TA of the
+ *	received packet with an FCS error matches the peer MAC address.
  */
 struct station_info {
 	u64 filled;
@@ -1338,6 +1342,9 @@  struct station_info {
 	struct cfg80211_tid_stats *pertid;
 	s8 ack_signal;
 	s8 avg_ack_signal;
+
+	u32 rx_mpdu_count;
+	u32 fcs_err_count;
 };
 
 #if IS_ENABLED(CONFIG_CFG80211)
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index cfc9417..172f312 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -3051,6 +3051,12 @@  enum nl80211_sta_bss_param {
  * @NL80211_STA_INFO_PAD: attribute used for padding for 64-bit alignment
  * @NL80211_STA_INFO_ACK_SIGNAL: signal strength of the last ACK frame(u8, dBm)
  * @NL80211_STA_INFO_ACK_SIGNAL_AVG: avg signal strength of ACK frames (s8, dBm)
+ * @NL80211_STA_INFO_RX_MPDUS: total number of received packets (MPDUs)
+ *	(u32, from this station)
+ * @NL80211_STA_INFO_FCS_ERROR_COUNT: total number of packets (MPDUs) received
+ *	with an FCS error (u32, from this station). This count may not include
+ *	some packets with an FCS error due to TA corruption. Hence this counter
+ *	might not be fully accurate.
  * @__NL80211_STA_INFO_AFTER_LAST: internal
  * @NL80211_STA_INFO_MAX: highest possible station info attribute
  */
@@ -3091,6 +3097,8 @@  enum nl80211_sta_info {
 	NL80211_STA_INFO_PAD,
 	NL80211_STA_INFO_ACK_SIGNAL,
 	NL80211_STA_INFO_ACK_SIGNAL_AVG,
+	NL80211_STA_INFO_RX_MPDUS,
+	NL80211_STA_INFO_FCS_ERROR_COUNT,
 
 	/* keep last */
 	__NL80211_STA_INFO_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0827cbd..3151171 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4719,6 +4719,8 @@  static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
 	PUT_SINFO_U64(RX_DROP_MISC, rx_dropped_misc);
 	PUT_SINFO_U64(BEACON_RX, rx_beacon);
 	PUT_SINFO(BEACON_SIGNAL_AVG, rx_beacon_signal_avg, u8);
+	PUT_SINFO(RX_MPDUS, rx_mpdu_count, u32);
+	PUT_SINFO(FCS_ERROR_COUNT, fcs_err_count, u32);
 	if (wiphy_ext_feature_isset(&rdev->wiphy,
 				    NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT)) {
 		PUT_SINFO(ACK_SIGNAL, ack_signal, u8);