From patchwork Thu Dec 18 16:11:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 5514841 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4D38B9F1CD for ; Thu, 18 Dec 2014 16:11:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30B47209DE for ; Thu, 18 Dec 2014 16:11:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF2EE209DC for ; Thu, 18 Dec 2014 16:11:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751178AbaLRQLd (ORCPT ); Thu, 18 Dec 2014 11:11:33 -0500 Received: from s3.sipsolutions.net ([5.9.151.49]:42071 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbaLRQLc (ORCPT ); Thu, 18 Dec 2014 11:11:32 -0500 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84) (envelope-from ) id 1Y1dfn-0006b5-0D; Thu, 18 Dec 2014 17:11:31 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH 2/2] mac80211: provide per-TID RX/TX MSDU counters Date: Thu, 18 Dec 2014 17:11:23 +0100 Message-Id: <1418919083-28297-2-git-send-email-johannes@sipsolutions.net> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1418919083-28297-1-git-send-email-johannes@sipsolutions.net> References: <1418919083-28297-1-git-send-email-johannes@sipsolutions.net> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Berg 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 --- 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);