From patchwork Sun May 3 21:43:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arend van Spriel X-Patchwork-Id: 6322321 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C8825BEEE1 for ; Sun, 3 May 2015 21:43:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5582202A1 for ; Sun, 3 May 2015 21:43:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DCCC20270 for ; Sun, 3 May 2015 21:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751709AbbECVnH (ORCPT ); Sun, 3 May 2015 17:43:07 -0400 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:61525 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751505AbbECVnF (ORCPT ); Sun, 3 May 2015 17:43:05 -0400 X-IronPort-AV: E=Sophos;i="5.13,362,1427785200"; d="scan'208";a="63774242" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw2-out.broadcom.com with ESMTP; 03 May 2015 14:51:15 -0700 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.235.1; Sun, 3 May 2015 14:43:04 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.235.1; Sun, 3 May 2015 14:43:04 -0700 Received: from bld-bun-01.bun.broadcom.com (unknown [10.176.128.83]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 9612340FEA; Sun, 3 May 2015 14:41:27 -0700 (PDT) Received: by bld-bun-01.bun.broadcom.com (Postfix, from userid 25152) id E22E2B0514F; Sun, 3 May 2015 23:43:02 +0200 (CEST) From: Arend van Spriel To: Johannes Berg CC: linux-wireless , Arend van Spriel Subject: [PATCH] mac80211: add pcpu_sw_netstats field in ieee80211_sub_if_data Date: Sun, 3 May 2015 23:43:01 +0200 Message-ID: <1430689381-2339-1-git-send-email-arend@broadcom.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 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=unavailable 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 Add field in struct ieee80211_sub_if_data pointing to per-cpu net statistics. Using this instead of field in struct netdevice makes it easier to backport the functionality. Signed-off-by: Arend van Spriel --- net/mac80211/ieee80211_i.h | 1 + net/mac80211/iface.c | 21 +++++++++++++-------- net/mac80211/rx.c | 11 ++++++----- net/mac80211/tx.c | 9 +++++---- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index e9f36f7..e231932 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -833,6 +833,7 @@ struct ieee80211_sub_if_data { struct delayed_work dec_tailroom_needed_wk; struct net_device *dev; + struct pcpu_sw_netstats *tstats; struct ieee80211_local *local; unsigned int flags; diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index dc2d713..3f62dbb 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1097,6 +1097,7 @@ static u16 ieee80211_netdev_select_queue(struct net_device *dev, static struct rtnl_link_stats64 * ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); int i; for_each_possible_cpu(i) { @@ -1104,7 +1105,7 @@ ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) u64 rx_packets, rx_bytes, tx_packets, tx_bytes; unsigned int start; - tstats = per_cpu_ptr(dev->tstats, i); + tstats = per_cpu_ptr(sdata->tstats, i); do { start = u64_stats_fetch_begin_irq(&tstats->syncp); @@ -1171,7 +1172,10 @@ static const struct net_device_ops ieee80211_monitorif_ops = { static void ieee80211_if_free(struct net_device *dev) { - free_percpu(dev->tstats); + struct ieee80211_sub_if_data *sdata; + + sdata = netdev_priv(dev); + free_percpu(sdata->tstats); free_netdev(dev); } @@ -1721,12 +1725,6 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, return -ENOMEM; dev_net_set(ndev, wiphy_net(local->hw.wiphy)); - ndev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!ndev->tstats) { - free_netdev(ndev); - return -ENOMEM; - } - ndev->needed_headroom = local->tx_headroom + 4*6 /* four MAC addresses */ + 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */ @@ -1752,6 +1750,13 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, /* don't use IEEE80211_DEV_TO_SUB_IF -- it checks too much */ sdata = netdev_priv(ndev); ndev->ieee80211_ptr = &sdata->wdev; + + sdata->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); + if (!sdata->tstats) { + free_netdev(ndev); + return -ENOMEM; + } + memcpy(sdata->vif.addr, ndev->dev_addr, ETH_ALEN); memcpy(sdata->name, ndev->name, IFNAMSIZ); diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index e082535..d1578a2 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -32,9 +32,10 @@ #include "wme.h" #include "rate.h" -static inline void ieee80211_rx_stats(struct net_device *dev, u32 len) +static inline void ieee80211_rx_stats(struct ieee80211_sub_if_data *sdata, + u32 len) { - struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); + struct pcpu_sw_netstats *tstats = this_cpu_ptr(sdata->tstats); u64_stats_update_begin(&tstats->syncp); tstats->rx_packets++; @@ -539,7 +540,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, } prev_dev = sdata->dev; - ieee80211_rx_stats(sdata->dev, skb->len); + ieee80211_rx_stats(sdata, skb->len); } if (prev_dev) { @@ -2048,7 +2049,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) skb = rx->skb; xmit_skb = NULL; - ieee80211_rx_stats(dev, skb->len); + ieee80211_rx_stats(sdata, skb->len); if ((sdata->vif.type == NL80211_IFTYPE_AP || sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && @@ -3061,7 +3062,7 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, } prev_dev = sdata->dev; - ieee80211_rx_stats(sdata->dev, skb->len); + ieee80211_rx_stats(sdata, skb->len); } if (prev_dev) { diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 745fdf5..bca48e4 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -37,9 +37,10 @@ /* misc utils */ -static inline void ieee80211_tx_stats(struct net_device *dev, u32 len) +static inline void ieee80211_tx_stats(struct ieee80211_sub_if_data *sdata, + u32 len) { - struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); + struct pcpu_sw_netstats *tstats = this_cpu_ptr(sdata->tstats); u64_stats_update_begin(&tstats->syncp); tstats->tx_packets++; @@ -2737,7 +2738,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, return true; } - ieee80211_tx_stats(dev, skb->len + extra_head); + ieee80211_tx_stats(sdata, skb->len + extra_head); /* will not be crypto-handled beyond what we do here, so use false * as the may-encrypt argument for the resize to not account for @@ -2918,7 +2919,7 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb, if (IS_ERR(skb)) goto out; - ieee80211_tx_stats(dev, skb->len); + ieee80211_tx_stats(sdata, skb->len); ieee80211_xmit(sdata, sta, skb); }