From patchwork Tue Nov 10 19:48:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 323501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C83FC388F7 for ; Tue, 10 Nov 2020 19:51:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7A4220809 for ; Tue, 10 Nov 2020 19:51:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l/9jHpoH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731696AbgKJTv1 (ORCPT ); Tue, 10 Nov 2020 14:51:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731613AbgKJTv0 (ORCPT ); Tue, 10 Nov 2020 14:51:26 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B41BC0613D1; Tue, 10 Nov 2020 11:51:25 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id dk16so19316300ejb.12; Tue, 10 Nov 2020 11:51:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=NhuUAeR80nfEeuMWJO9rn2BTncFH7te01FW54NzBpW0=; b=l/9jHpoHkxGjhxxpoLcIKUhaM62UhbllNGha4Jm9H0CxXCyZ7VxrOaAXcYQBMQVs4Z wee+8QCMDvxlTW8MaZ3vhgJtZ+jIaX5l8r8uyMjoGC36JvWiVLZVrRz39iBl3+xcc0yT e4saa3KkL7D9WjH7PRS0T3i2hA8T9sEk8wSdp/xpkDGkmkVGe8Cn5Eo0cxgbKILFsPWV 77zvKw49H9JN5zE4xPPas8ackvvroVMSyVm1u6ij+WWfVAW4ANxwKI3A3T1uUvJhTGWE bE3R/GL75W4oe/NfCzxHFvI6EulHbtdTrKnTjGngPNoi3awQqt++LDA83+vSuQHqVbdx lePw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=NhuUAeR80nfEeuMWJO9rn2BTncFH7te01FW54NzBpW0=; b=fRSudPqsL0Gmb6X+ieL3Giw2xia+37m3xMcI0j26nkDRIH6TpAOgOOmZQdehFdx/Kw eAoAGg+PsaGrU9Q0HUU8V44upKIWsoctSFeNi5ifpeD0j/4+HUfD2F1EwnCi3+rWPYg3 Y0GgfkNC5vM0dfICYF7zP90NczR4C8hHZk188/J35VAzYn1e/e6zvD78F12EZZRN3W89 GDwONrPyYZXYdIgf4AzwVk67S7za6gwA1kBT87mBxwloaMga6mxpSiV9jHfKMk+sZ/aV djLSEq8WOBvx9If+f48jpHaZJ6wjPmyYBxKKnbB+GrtcZELCFujpuHfVkzmcH7egPeII 96bQ== X-Gm-Message-State: AOAM532g4zmShHBnE4pKWkxFnN97yj+st5tRwwuEtZ4DKsrinU8RtEwx DZ2igBl5wBwiBWhlK4iUpQgRqxMAc/N4Hw== X-Google-Smtp-Source: ABdhPJwA3v9bN4hBcNPA/ZTQbFo4nEiwQ73RwBaMXlDzRloJblYJEK+RYKsMLYx6DUR+0k5Ww8Q9Dg== X-Received: by 2002:a17:906:6949:: with SMTP id c9mr21671485ejs.482.1605037883883; Tue, 10 Nov 2020 11:51:23 -0800 (PST) Received: from ?IPv6:2003:ea:8f23:2800:895e:e59d:3602:de4b? (p200300ea8f232800895ee59d3602de4b.dip0.t-ipconnect.de. [2003:ea:8f23:2800:895e:e59d:3602:de4b]) by smtp.googlemail.com with ESMTPSA id l20sm11104664eja.40.2020.11.10.11.51.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Nov 2020 11:51:23 -0800 (PST) Subject: [PATCH net-next 3/5] qtnfmac: switch to core handling of rx/tx byte/packet counters From: Heiner Kallweit To: Jakub Kicinski , David Miller , Mike Marciniszyn , Dennis Dalessandro , Doug Ledford , Jason Gunthorpe , =?utf-8?q?Bj=C3=B8rn_Mork?= , Igor Mitsyanko , Sergey Matyukevich , Kalle Valo , Oliver Neukum , Peter Korsgaard , Steve Glendinning , Microchip Linux Driver Support , Jussi Kivilinna Cc: "netdev@vger.kernel.org" , linux-rdma@vger.kernel.org, Linux USB Mailing List , linux-wireless References: <5fbe3a1f-6625-eadc-b1c9-f76f78debb94@gmail.com> Message-ID: <4b22c155-6868-793f-ebfe-f797e16b9c40@gmail.com> Date: Tue, 10 Nov 2020 20:48:54 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.1 MIME-Version: 1.0 In-Reply-To: <5fbe3a1f-6625-eadc-b1c9-f76f78debb94@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use netdev->tstats instead of a member of qtnf_vif for storing a pointer to the per-cpu counters. This allows us to use core functionality for statistics handling. The driver sets netdev->needs_free_netdev, therefore freeing the per-cpu counters at the right point in time is a little bit tricky. Best option seems to be to use the ndo_init/ndo_uninit callbacks. Signed-off-by: Heiner Kallweit --- drivers/net/wireless/quantenna/qtnfmac/core.c | 78 ++++--------------- drivers/net/wireless/quantenna/qtnfmac/core.h | 4 - .../quantenna/qtnfmac/pcie/pearl_pcie.c | 4 +- .../quantenna/qtnfmac/pcie/topaz_pcie.c | 4 +- 4 files changed, 20 insertions(+), 70 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c index bf6dbeb61..ad726bd10 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.c +++ b/drivers/net/wireless/quantenna/qtnfmac/core.c @@ -126,28 +126,13 @@ qtnf_netdev_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) if (unlikely(skb->protocol == htons(ETH_P_PAE))) { qtnf_packet_send_hi_pri(skb); - qtnf_update_tx_stats(ndev, skb); + dev_sw_netstats_tx_add(ndev, 1, skb->len); return NETDEV_TX_OK; } return qtnf_bus_data_tx(mac->bus, skb, mac->macid, vif->vifid); } -/* Netdev handler for getting stats. - */ -static void qtnf_netdev_get_stats64(struct net_device *ndev, - struct rtnl_link_stats64 *stats) -{ - struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); - - netdev_stats_to_stats64(stats, &ndev->stats); - - if (!vif->stats64) - return; - - dev_fetch_sw_netstats(stats, vif->stats64); -} - /* Netdev handler for transmission timeout. */ static void qtnf_netdev_tx_timeout(struct net_device *ndev, unsigned int txqueue) @@ -211,13 +196,27 @@ static int qtnf_netdev_port_parent_id(struct net_device *ndev, return 0; } +static int qtnf_netdev_alloc_pcpu_stats(struct net_device *dev) +{ + dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); + + return dev->tstats ? 0 : -ENOMEM; +} + +static void qtnf_netdev_free_pcpu_stats(struct net_device *dev) +{ + free_percpu(dev->tstats); +} + /* Network device ops handlers */ const struct net_device_ops qtnf_netdev_ops = { + .ndo_init = qtnf_netdev_alloc_pcpu_stats, + .ndo_uninit = qtnf_netdev_free_pcpu_stats, .ndo_open = qtnf_netdev_open, .ndo_stop = qtnf_netdev_close, .ndo_start_xmit = qtnf_netdev_hard_start_xmit, .ndo_tx_timeout = qtnf_netdev_tx_timeout, - .ndo_get_stats64 = qtnf_netdev_get_stats64, + .ndo_get_stats64 = dev_get_tstats64, .ndo_set_mac_address = qtnf_netdev_set_mac_address, .ndo_get_port_parent_id = qtnf_netdev_port_parent_id, }; @@ -448,10 +447,6 @@ static struct qtnf_wmac *qtnf_core_mac_alloc(struct qtnf_bus *bus, qtnf_sta_list_init(&vif->sta_list); INIT_WORK(&vif->high_pri_tx_work, qtnf_vif_send_data_high_pri); skb_queue_head_init(&vif->high_pri_tx_queue); - vif->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!vif->stats64) - pr_warn("VIF%u.%u: per cpu stats allocation failed\n", - macid, i); } qtnf_mac_init_primary_intf(mac); @@ -531,7 +526,6 @@ static void qtnf_core_mac_detach(struct qtnf_bus *bus, unsigned int macid) } rtnl_unlock(); qtnf_sta_list_free(&vif->sta_list); - free_percpu(vif->stats64); } if (mac->wiphy_registered) @@ -924,46 +918,6 @@ void qtnf_wake_all_queues(struct net_device *ndev) } EXPORT_SYMBOL_GPL(qtnf_wake_all_queues); -void qtnf_update_rx_stats(struct net_device *ndev, const struct sk_buff *skb) -{ - struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); - struct pcpu_sw_netstats *stats64; - - if (unlikely(!vif || !vif->stats64)) { - ndev->stats.rx_packets++; - ndev->stats.rx_bytes += skb->len; - return; - } - - stats64 = this_cpu_ptr(vif->stats64); - - u64_stats_update_begin(&stats64->syncp); - stats64->rx_packets++; - stats64->rx_bytes += skb->len; - u64_stats_update_end(&stats64->syncp); -} -EXPORT_SYMBOL_GPL(qtnf_update_rx_stats); - -void qtnf_update_tx_stats(struct net_device *ndev, const struct sk_buff *skb) -{ - struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev); - struct pcpu_sw_netstats *stats64; - - if (unlikely(!vif || !vif->stats64)) { - ndev->stats.tx_packets++; - ndev->stats.tx_bytes += skb->len; - return; - } - - stats64 = this_cpu_ptr(vif->stats64); - - u64_stats_update_begin(&stats64->syncp); - stats64->tx_packets++; - stats64->tx_bytes += skb->len; - u64_stats_update_end(&stats64->syncp); -} -EXPORT_SYMBOL_GPL(qtnf_update_tx_stats); - struct dentry *qtnf_get_debugfs_dir(void) { return qtnf_debugfs_dir; diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h index 269ce12cf..b204a2407 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.h +++ b/drivers/net/wireless/quantenna/qtnfmac/core.h @@ -70,8 +70,6 @@ struct qtnf_vif { struct qtnf_sta_list sta_list; unsigned long cons_tx_timeout_cnt; int generation; - - struct pcpu_sw_netstats __percpu *stats64; }; struct qtnf_mac_info { @@ -139,8 +137,6 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed); struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid); struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb); void qtnf_wake_all_queues(struct net_device *ndev); -void qtnf_update_rx_stats(struct net_device *ndev, const struct sk_buff *skb); -void qtnf_update_tx_stats(struct net_device *ndev, const struct sk_buff *skb); void qtnf_virtual_intf_cleanup(struct net_device *ndev); diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c index 9a20c0f29..0003df577 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c +++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c @@ -489,7 +489,7 @@ static void qtnf_pearl_data_tx_reclaim(struct qtnf_pcie_pearl_state *ps) PCI_DMA_TODEVICE); if (skb->dev) { - qtnf_update_tx_stats(skb->dev, skb); + dev_sw_netstats_tx_add(skb->dev, 1, skb->len); if (unlikely(priv->tx_stopped)) { qtnf_wake_all_queues(skb->dev); priv->tx_stopped = 0; @@ -756,7 +756,7 @@ static int qtnf_pcie_pearl_rx_poll(struct napi_struct *napi, int budget) skb_put(skb, psize); ndev = qtnf_classify_skb(bus, skb); if (likely(ndev)) { - qtnf_update_rx_stats(ndev, skb); + dev_sw_netstats_rx_add(ndev, skb->len); skb->protocol = eth_type_trans(skb, ndev); napi_gro_receive(napi, skb); } else { diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c index 4b87d3151..24f1be8dd 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c +++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c @@ -418,7 +418,7 @@ static void qtnf_topaz_data_tx_reclaim(struct qtnf_pcie_topaz_state *ts) PCI_DMA_TODEVICE); if (skb->dev) { - qtnf_update_tx_stats(skb->dev, skb); + dev_sw_netstats_tx_add(skb->dev, 1, skb->len); if (unlikely(priv->tx_stopped)) { qtnf_wake_all_queues(skb->dev); priv->tx_stopped = 0; @@ -662,7 +662,7 @@ static int qtnf_topaz_rx_poll(struct napi_struct *napi, int budget) skb_put(skb, psize); ndev = qtnf_classify_skb(bus, skb); if (likely(ndev)) { - qtnf_update_rx_stats(ndev, skb); + dev_sw_netstats_rx_add(ndev, skb->len); skb->protocol = eth_type_trans(skb, ndev); netif_receive_skb(skb); } else { From patchwork Tue Nov 10 19:50:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 323500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EFB6C61DD8 for ; Tue, 10 Nov 2020 19:51:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40E7720809 for ; Tue, 10 Nov 2020 19:51:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FJBcjArr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731738AbgKJTvb (ORCPT ); Tue, 10 Nov 2020 14:51:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731706AbgKJTv1 (ORCPT ); Tue, 10 Nov 2020 14:51:27 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B292C0613D1; Tue, 10 Nov 2020 11:51:27 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id s25so19360655ejy.6; Tue, 10 Nov 2020 11:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=zHwz+GVnqFj0IOBBK7m9sISogVlrXHBHVpez2vtGxNA=; b=FJBcjArrc68gCYiLrDGvZd6QudecMs1EO6nC5MljgPZbFfe8ROp/r6j3bvRtqCpvq2 pFRmx5QINgTBD8ZQ5/Q/kXtGlpWwhd3ZGEaQJzAHwZn0UTkSqMGNjJ22JLOmeGiUrN0I vg3irUcDoRKsa5HMa5rLlPHUINvuozNxCVSuj8id0I5aU3T9xOhXN1u8L/2XAJJqzwnM l2yR8xWZYze8QGk51mQjeUgsD9sYUZdgygq7gYJLieRSrIqCm5rQH9of/B9h/nR/yhGg gVd4SPgWxifkcfBzEO2f7I3NKvl0nGcgPebK1S59AUD4zATlvibz02AHAdbQMvSYq6ed A0qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=zHwz+GVnqFj0IOBBK7m9sISogVlrXHBHVpez2vtGxNA=; b=DeyUglLblmwhLLRu/sTJ7F0uyBss9Yj/lgdtLl2lQUtf2K07U77Rtn0YP5XBvAB5vT DNxL4HjeINZ4qvny+pbwKPwAM6BM3OGv9cJNBwVLwz6n8i+MEFH2DHyweBpbHDnQ/Xvb lSGXCoWFsWKuZur/glQdIZD9d/nueOg9OwUhd5/FRfhkozaKcu0hR4MrJZ1aLaC26U73 cvP0pds9p1vKmkj75ho28xfM/XZ2jY6n9HsRyLJFSzOWkbyAvUeK90ZaH3XbEiMeGc9G fBvDO+LJFQHCJH8VN4wrIJ9b8ThWSgyzZE6wbiDKZgtz7FYoMwRN46essnf80jmURjHO mNRw== X-Gm-Message-State: AOAM530xEcvgrp5qqKessa8SVsk6yNEfEE1QqSoeOaa7ek3BZc45v/Ym +qzZrnrj39VENvL/X0/ill5ux7x94Kyq4Q== X-Google-Smtp-Source: ABdhPJwv7D0aq69+i+DJRpOmUJFGVxjQUqfSRPPhxT0WwRJkW+VRtKG7hep6IvUCrb+x0GgV876iiA== X-Received: by 2002:a17:906:2cc5:: with SMTP id r5mr21890684ejr.328.1605037885529; Tue, 10 Nov 2020 11:51:25 -0800 (PST) Received: from ?IPv6:2003:ea:8f23:2800:895e:e59d:3602:de4b? (p200300ea8f232800895ee59d3602de4b.dip0.t-ipconnect.de. [2003:ea:8f23:2800:895e:e59d:3602:de4b]) by smtp.googlemail.com with ESMTPSA id r20sm10535899edq.6.2020.11.10.11.51.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Nov 2020 11:51:25 -0800 (PST) Subject: [PATCH net-next 4/5] usbnet: switch to core handling of rx/tx byte/packet counters From: Heiner Kallweit To: Jakub Kicinski , David Miller , Mike Marciniszyn , Dennis Dalessandro , Doug Ledford , Jason Gunthorpe , =?utf-8?q?Bj=C3=B8rn_Mork?= , Igor Mitsyanko , Sergey Matyukevich , Kalle Valo , Oliver Neukum , Peter Korsgaard , Steve Glendinning , Microchip Linux Driver Support , Jussi Kivilinna Cc: "netdev@vger.kernel.org" , linux-rdma@vger.kernel.org, Linux USB Mailing List , linux-wireless References: <5fbe3a1f-6625-eadc-b1c9-f76f78debb94@gmail.com> Message-ID: <8fb63ae9-1179-49e4-f9bb-e0e536f72158@gmail.com> Date: Tue, 10 Nov 2020 20:50:02 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.1 MIME-Version: 1.0 In-Reply-To: <5fbe3a1f-6625-eadc-b1c9-f76f78debb94@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use netdev->tstats instead of a member of usbnet for storing a pointer to the per-cpu counters. This allows us to use core functionality for statistics handling. Signed-off-by: Heiner Kallweit --- drivers/net/usb/usbnet.c | 23 +++++++---------------- include/linux/usb/usbnet.h | 6 ++---- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 6062dc278..1447da1d5 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -304,7 +304,7 @@ static void __usbnet_status_stop_force(struct usbnet *dev) */ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) { - struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); + struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->net->tstats); unsigned long flags; int status; @@ -980,15 +980,6 @@ int usbnet_set_link_ksettings(struct net_device *net, } EXPORT_SYMBOL_GPL(usbnet_set_link_ksettings); -void usbnet_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) -{ - struct usbnet *dev = netdev_priv(net); - - netdev_stats_to_stats64(stats, &net->stats); - dev_fetch_sw_netstats(stats, dev->stats64); -} -EXPORT_SYMBOL_GPL(usbnet_get_stats64); - u32 usbnet_get_link (struct net_device *net) { struct usbnet *dev = netdev_priv(net); @@ -1220,7 +1211,7 @@ static void tx_complete (struct urb *urb) struct usbnet *dev = entry->dev; if (urb->status == 0) { - struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); + struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->net->tstats); unsigned long flags; flags = u64_stats_update_begin_irqsave(&stats64->syncp); @@ -1596,7 +1587,7 @@ void usbnet_disconnect (struct usb_interface *intf) usb_free_urb(dev->interrupt); kfree(dev->padding_pkt); - free_percpu(dev->stats64); + free_percpu(net->tstats); free_netdev(net); } EXPORT_SYMBOL_GPL(usbnet_disconnect); @@ -1608,7 +1599,7 @@ static const struct net_device_ops usbnet_netdev_ops = { .ndo_tx_timeout = usbnet_tx_timeout, .ndo_set_rx_mode = usbnet_set_rx_mode, .ndo_change_mtu = usbnet_change_mtu, - .ndo_get_stats64 = usbnet_get_stats64, + .ndo_get_stats64 = dev_get_tstats64, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, }; @@ -1671,8 +1662,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) dev->driver_info = info; dev->driver_name = name; - dev->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!dev->stats64) + net->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); + if (!net->tstats) goto out0; dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV @@ -1812,7 +1803,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) */ cancel_work_sync(&dev->kevent); del_timer_sync(&dev->delay); - free_percpu(dev->stats64); + free_percpu(net->tstats); out0: free_netdev(net); out: diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index 2e4f7721f..1f6dfa977 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h @@ -65,8 +65,6 @@ struct usbnet { struct usb_anchor deferred; struct tasklet_struct bh; - struct pcpu_sw_netstats __percpu *stats64; - struct work_struct kevent; unsigned long flags; # define EVENT_TX_HALT 0 @@ -285,7 +283,7 @@ extern int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags); extern void usbnet_status_stop(struct usbnet *dev); extern void usbnet_update_max_qlen(struct usbnet *dev); -extern void usbnet_get_stats64(struct net_device *dev, - struct rtnl_link_stats64 *stats); + +#define usbnet_get_stats64 dev_get_tstats64 #endif /* __LINUX_USB_USBNET_H */