linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] nl80211: support MSDU statistics
@ 2014-12-18 16:11 Johannes Berg
  2014-12-18 16:11 ` [PATCH 2/2] mac80211: provide per-TID RX/TX MSDU counters Johannes Berg
  2014-12-19 11:05 ` [PATCH 1/2] nl80211: support MSDU statistics Johannes Berg
  0 siblings, 2 replies; 3+ messages in thread
From: Johannes Berg @ 2014-12-18 16:11 UTC (permalink / raw)
  To: linux-wireless; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

The base for the current statistics is pretty mixed up, support
exporting RX/TX statistics for MSDUs per TID.

This makes sense because it's symmetric - we could export per-AC
statistics for all frames (which AC we used for transmission can
be determined also for management frames) but per TID is better
and usually data frames are really the ones we care about. Also,
on RX we can't determine the AC - but we do know the TID for any
QoS MSDU we received.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 include/net/cfg80211.h       | 10 +++++++++-
 include/uapi/linux/nl80211.h | 12 ++++++++++++
 net/wireless/nl80211.c       | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 729f9e0bcf38..d1d0894ff302 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -965,6 +965,10 @@ struct sta_bss_parameters {
  * @txrate: current unicast bitrate from this station
  * @rxrate: current unicast bitrate to this station
  * @rx_packets: packets (MSDUs & MMPDUs) received from this station
+ * @rx_qos_msdu: QoS-MSDUs received from this station (per TID)
+ * @rx_nonqos_msdu: non-QoS-MSDUs received from this station
+ * @tx_qos_msdu: QoS-MSDUs sent to this station (per TID)
+ * @tx_nonqos_msdu: non-QoS-MSDUs sent to this station
  * @tx_packets: packets (MSDUs & MMPDUs) transmitted to this station
  * @tx_retries: cumulative retry counts (MPDUs)
  * @tx_failed: number of failed transmissions (MPDUs) (retries exceeded, no ACK)
@@ -992,7 +996,7 @@ struct sta_bss_parameters {
  *	from this peer
  */
 struct station_info {
-	u32 filled;
+	u64 filled;
 	u32 connected_time;
 	u32 inactive_time;
 	u64 rx_bytes;
@@ -1014,6 +1018,10 @@ struct station_info {
 	u32 tx_retries;
 	u32 tx_failed;
 	u32 rx_dropped_misc;
+	u64 rx_qos_msdu[IEEE80211_NUM_TIDS];
+	u64 rx_nonqos_msdu;
+	u64 tx_qos_msdu[IEEE80211_NUM_TIDS];
+	u64 tx_nonqos_msdu;
 	struct sta_bss_parameters bss_param;
 	struct nl80211_sta_flag_update sta_flags;
 
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 9e5797d00096..6cd33c02113a 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2365,6 +2365,14 @@ enum nl80211_sta_bss_param {
  * @NL80211_STA_INFO_BEACON_RX: number of beacons received from this peer (u64)
  * @NL80211_STA_INFO_BEACON_SIGNAL_AVG: signal strength average
  *	for beacons only (u8, dBm)
+ * @NL80211_STA_INFO_RX_QOS_MSDU: number of QoS-MSDUs received from this
+ *	station, per TID (array of 16 u64 values)
+ * @NL80211_STA_INFO_RX_NONQOS_MSDU: number of non-QoS-MSDUs received from this
+ *	station (u64)
+ * @NL80211_STA_INFO_TX_QOS_MSDU: number of QoS-MSDUs sent to this station,
+ *	per TID (array of 16 u64 values)
+ * @NL80211_STA_INFO_TX_NONQOS_MSDU: number of non-QoS-MSDUs sent to this
+ *	station (u64)
  * @__NL80211_STA_INFO_AFTER_LAST: internal
  * @NL80211_STA_INFO_MAX: highest possible station info attribute
  */
@@ -2400,6 +2408,10 @@ enum nl80211_sta_info {
 	NL80211_STA_INFO_RX_DROP_MISC,
 	NL80211_STA_INFO_BEACON_RX,
 	NL80211_STA_INFO_BEACON_SIGNAL_AVG,
+	NL80211_STA_INFO_RX_QOS_MSDU,
+	NL80211_STA_INFO_RX_NONQOS_MSDU,
+	NL80211_STA_INFO_TX_QOS_MSDU,
+	NL80211_STA_INFO_TX_NONQOS_MSDU,
 
 	/* keep last */
 	__NL80211_STA_INFO_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d7e21a27aef3..f565d8073758 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3668,12 +3668,20 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
 		goto nla_put_failure;
 
 #define PUT_SINFO(attr, memb, type) do {				\
-	if (sinfo->filled & BIT(NL80211_STA_INFO_ ## attr) &&		\
+	if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_ ## attr) &&	\
 	    nla_put_ ## type(msg, NL80211_STA_INFO_ ## attr,		\
 			     sinfo->memb))				\
 		goto nla_put_failure;					\
 	} while (0)
 
+#define PUT_SINFO_TIDS(attr, memb) do {					\
+	BUILD_BUG_ON(sizeof(sinfo->memb) != sizeof(u64) * IEEE80211_NUM_TIDS);\
+	if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_ ## attr) &&	\
+	    nla_put(msg, NL80211_STA_INFO_ ## attr,			\
+		    sizeof(sinfo->memb), sinfo->memb))			\
+		goto nla_put_failure;					\
+	} while (0)
+
 	PUT_SINFO(CONNECTED_TIME, connected_time, u32);
 	PUT_SINFO(INACTIVE_TIME, inactive_time, u32);
 
@@ -3765,6 +3773,10 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
 	PUT_SINFO(RX_DROP_MISC, rx_dropped_misc, u64);
 	PUT_SINFO(BEACON_RX, rx_beacon, u64);
 	PUT_SINFO(BEACON_SIGNAL_AVG, rx_beacon_signal_avg, u8);
+	PUT_SINFO_TIDS(RX_QOS_MSDU, rx_qos_msdu);
+	PUT_SINFO(RX_NONQOS_MSDU, rx_nonqos_msdu, u64);
+	PUT_SINFO_TIDS(TX_QOS_MSDU, tx_qos_msdu);
+	PUT_SINFO(TX_NONQOS_MSDU, tx_nonqos_msdu, u64);
 
 #undef PUT_SINFO
 	nla_nest_end(msg, sinfoattr);
-- 
2.1.1


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

* [PATCH 2/2] mac80211: provide per-TID RX/TX MSDU counters
  2014-12-18 16:11 [PATCH 1/2] nl80211: support MSDU statistics Johannes Berg
@ 2014-12-18 16:11 ` Johannes Berg
  2014-12-19 11:05 ` [PATCH 1/2] nl80211: support MSDU statistics Johannes Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2014-12-18 16:11 UTC (permalink / raw)
  To: linux-wireless; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

Implement the new counters cfg80211 can now advertise to userspace.
The TX code is in the sequence number handler, which is a bit odd,
but that place already knows the TID and frame type, so it was
easiest and least impact there.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/rx.c       |  9 +++++++++
 net/mac80211/sta_info.c | 22 ++++++++++++++++++++++
 net/mac80211/sta_info.h |  7 +++++++
 net/mac80211/tx.c       |  3 +++
 4 files changed, 41 insertions(+)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 444ebff955c1..52c5932adbd9 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2313,6 +2313,15 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
 	if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))
 		return RX_DROP_MONITOR;
 
+	if (rx->sta) {
+		/* The security index has the same property as needed
+		 * for the rx_msdu field, i.e. it is IEEE80211_NUM_TIDS
+		 * for non-QoS-data frames. Here we know it's a data
+		 * frame, so count MSDUs.
+		 */
+		rx->sta->rx_msdu[rx->security_idx]++;
+	}
+
 	/*
 	 * Send unexpected-4addr-frame event to hostapd. For older versions,
 	 * also drop the frame to cooked monitor interfaces.
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 64b53b943d98..b20854bfd02b 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1843,6 +1843,28 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
 		sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE);
 	}
 
+	if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_QOS_MSDU))) {
+		for (i = 0; i < IEEE80211_NUM_TIDS; i++)
+			sinfo->rx_qos_msdu[i] = sta->rx_msdu[i];
+		sinfo->filled |= BIT(NL80211_STA_INFO_RX_QOS_MSDU);
+	}
+
+	if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_NONQOS_MSDU))) {
+		sinfo->rx_nonqos_msdu = sta->rx_msdu[IEEE80211_NUM_TIDS];
+		sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_NONQOS_MSDU);
+	}
+
+	if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_QOS_MSDU))) {
+		for (i = 0; i < 8; i++)
+			sinfo->tx_qos_msdu[i] = sta->tx_msdu_qos[i];
+		sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_QOS_MSDU);
+	}
+
+	if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_NONQOS_MSDU))) {
+		sinfo->tx_nonqos_msdu = sta->tx_msdu_nonqos;
+		sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_NONQOS_MSDU);
+	}
+
 	if (ieee80211_vif_is_mesh(&sdata->vif)) {
 #ifdef CONFIG_MAC80211_MESH
 		sinfo->filled |= BIT(NL80211_STA_INFO_LLID) |
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 4f052bb2a5ad..d34392b44293 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -346,6 +346,10 @@ struct ieee80211_tx_latency_stat {
  * @cipher_scheme: optional cipher scheme for this station
  * @last_tdls_pkt_time: holds the time in jiffies of last TDLS pkt ACKed
  * @reserved_tid: reserved TID (if any, otherwise IEEE80211_TID_UNRESERVED)
+ * @tx_msdu_qos: QoS MSDUs transmitted to this station
+ * @tx_msdu_nonqos: non-QoS MSDUs transmitted to this station
+ * @rx_msdu: MSDUs received from this station, using IEEE80211_NUM_TID
+ *	entry for non-QoS frames
  */
 struct sta_info {
 	/* General information, mostly static */
@@ -416,6 +420,9 @@ struct sta_info {
 	u32 last_rx_rate_vht_flag;
 	u8 last_rx_rate_vht_nss;
 	u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
+	u64 tx_msdu_qos[IEEE80211_NUM_TIDS];
+	u64 tx_msdu_nonqos;
+	u64 rx_msdu[IEEE80211_NUM_TIDS + 1];
 
 	/*
 	 * Aggregation information, locked with lock.
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 058686a721a1..5f3e29c06f64 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -815,6 +815,8 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
 		/* for pure STA mode without beacons, we can do it */
 		hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number);
 		tx->sdata->sequence_number += 0x10;
+		if (tx->sta)
+			tx->sta->tx_msdu_nonqos++;
 		return TX_CONTINUE;
 	}
 
@@ -831,6 +833,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
 	qc = ieee80211_get_qos_ctl(hdr);
 	tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
 	seq = &tx->sta->tid_seq[tid];
+	tx->sta->tx_msdu_qos[tid]++;
 
 	hdr->seq_ctrl = cpu_to_le16(*seq);
 
-- 
2.1.1


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

* Re: [PATCH 1/2] nl80211: support MSDU statistics
  2014-12-18 16:11 [PATCH 1/2] nl80211: support MSDU statistics Johannes Berg
  2014-12-18 16:11 ` [PATCH 2/2] mac80211: provide per-TID RX/TX MSDU counters Johannes Berg
@ 2014-12-19 11:05 ` Johannes Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2014-12-19 11:05 UTC (permalink / raw)
  To: linux-wireless


> + * @rx_qos_msdu: QoS-MSDUs received from this station (per TID)
> + * @rx_nonqos_msdu: non-QoS-MSDUs received from this station
> + * @tx_qos_msdu: QoS-MSDUs sent to this station (per TID)
> + * @tx_nonqos_msdu: non-QoS-MSDUs sent to this station

Well, come to think of it, it looks like we'll probably want more
per-TID data in the future, I'll need at least retries and lost MSDUs.

As a consequence, I'm going to make this the other way around and have a
per-TID nesting (using idx 16 for non-QoS) and in there have the
different values. This will also affect the cfg80211 API.

johannes


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

end of thread, other threads:[~2014-12-19 11:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-18 16:11 [PATCH 1/2] nl80211: support MSDU statistics Johannes Berg
2014-12-18 16:11 ` [PATCH 2/2] mac80211: provide per-TID RX/TX MSDU counters Johannes Berg
2014-12-19 11:05 ` [PATCH 1/2] nl80211: support MSDU statistics Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).