From patchwork Thu Oct 29 17:29:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 11867061 X-Patchwork-Delegate: kuba@kernel.org 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=ham 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 E2ECEC4363A for ; Thu, 29 Oct 2020 17:35:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 649DB2076A for ; Thu, 29 Oct 2020 17:35:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MDPZLmIg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726665AbgJ2RfI (ORCPT ); Thu, 29 Oct 2020 13:35:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbgJ2RfI (ORCPT ); Thu, 29 Oct 2020 13:35:08 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1DD0C0613D5 for ; Thu, 29 Oct 2020 10:35:07 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id c18so614353wme.2 for ; Thu, 29 Oct 2020 10:35:07 -0700 (PDT) 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-language:content-transfer-encoding; bh=iqNQanOjCjBVA0LFMrkVarMbtIyFsISIzsc7ApMy7s4=; b=MDPZLmIgj66v7GaF00Uygj+YwNTwC7nXKJk9ajt3tm8oOYI9CqiIosf52JmeVUD1aF Ef8jak2+hzVhzdes9HzvuyK0yP0o+UgLyBdGfF94yB8FQE1eJ76nobBKeNaKp0YFNzui 1vl421CqquGo0AZsAOYzQe/6Ek58gtlkJxT9hBOJ+aL/aK1QtRQCF2C0bwZEaaen+Nas ogBBoCBN/AcXT1C/S2hwqBPWnA3ihR8nu5yviEBB27Z7M3VsW4Baxw7U1t/HpJmi/dUR mAnx9KzVIc7RNOHsZWUZiHTZfmhpAyE693+nBnrpBoboGYkYs+Qn/bm3inyoK5R45SeH 1kqQ== 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-language :content-transfer-encoding; bh=iqNQanOjCjBVA0LFMrkVarMbtIyFsISIzsc7ApMy7s4=; b=qeA3JgaZk0UVjLMvEwq8MuYQWF/NCJ4cCBa5vKXoExydAJg6pDKCWLOz5jU2R1bmvH 4aJ5u4+1f35mj2CT/Olg1x5hiVnp3zWmzurv3hf6R6JmP2CFKUuWx590TBa3VGsKpK2X Q/l6rakmq/zYxiIP6fXq4WqqfAYEIq9bSm74/DdrjMgI4MWJA+vg0w2FtcGS8bBq5ziI Z/7XPSJGq3+v5QZies7sK/lVGQ6ByoComaV33VR0m4QHYM92dMeqhLuu6tp+KPlR4udR X7FTdWua0fUuuM/2/DzDXEQgvEmn14heZj0PKsN5W/qgqF77HSvvnzeqYsgNrum9vtC9 d+xQ== X-Gm-Message-State: AOAM531aX435reqrbPKJX9bww78HRBxqtvexaxV3YRmOi+98cBl5sFYF SRDCWKaC1BlLVokyAd5vkBawUKttSog= X-Google-Smtp-Source: ABdhPJzj8r9pdsXgSvG7k470ANITzl+sH/qTPbHaHvVnwc7khFgVteKzpmO/sk0DbP3ahzbwe2oMng== X-Received: by 2002:a1c:6102:: with SMTP id v2mr208429wmb.75.1603992906208; Thu, 29 Oct 2020 10:35:06 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:2800:a990:f24b:87e1:a560? (p200300ea8f232800a990f24b87e1a560.dip0.t-ipconnect.de. [2003:ea:8f23:2800:a990:f24b:87e1:a560]) by smtp.googlemail.com with ESMTPSA id 24sm763848wmf.44.2020.10.29.10.35.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Oct 2020 10:35:05 -0700 (PDT) Subject: [PATCH net-next 1/4] net: core: add dev_sw_netstats_tx_add From: Heiner Kallweit To: David Miller , Jakub Kicinski , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: <1fdb8ecd-be0a-755d-1d92-c62ed8399e77@gmail.com> Message-ID: <972dfa4e-d983-9daa-2d34-23844793646a@gmail.com> Date: Thu, 29 Oct 2020 18:29:59 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <1fdb8ecd-be0a-755d-1d92-c62ed8399e77@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add dev_sw_netstats_tx_add(), complementing already existing dev_sw_netstats_rx_add(). Other than dev_sw_netstats_rx_add allow to pass the number of packets as function argument. Signed-off-by: Heiner Kallweit --- include/linux/netdevice.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 964b494b0..568fab708 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2557,6 +2557,18 @@ static inline void dev_sw_netstats_rx_add(struct net_device *dev, unsigned int l u64_stats_update_end(&tstats->syncp); } +static inline void dev_sw_netstats_tx_add(struct net_device *dev, + unsigned int packets, + unsigned int len) +{ + struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); + + u64_stats_update_begin(&tstats->syncp); + tstats->tx_bytes += len; + tstats->tx_packets += packets; + u64_stats_update_end(&tstats->syncp); +} + static inline void dev_lstats_add(struct net_device *dev, unsigned int len) { struct pcpu_lstats *lstats = this_cpu_ptr(dev->lstats); From patchwork Thu Oct 29 17:31:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 11867067 X-Patchwork-Delegate: kuba@kernel.org 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=ham 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 7A503C2D0A3 for ; Thu, 29 Oct 2020 17:35:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 150BD2076D for ; Thu, 29 Oct 2020 17:35:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bbNGMMD8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726973AbgJ2RfK (ORCPT ); Thu, 29 Oct 2020 13:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbgJ2RfJ (ORCPT ); Thu, 29 Oct 2020 13:35:09 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBFACC0613D5 for ; Thu, 29 Oct 2020 10:35:08 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id y12so3689626wrp.6 for ; Thu, 29 Oct 2020 10:35:08 -0700 (PDT) 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-language:content-transfer-encoding; bh=oRmz+4+o7OE+5WNthkg3Flvqqv0uTmDftIeGOPIUHTA=; b=bbNGMMD8IpyjBA1HDwRhmK+2pfDLh9HTObzKHHQBRt9dCnzIkU33nxQ/59bgtZnBt4 y6FPM8vWCvTz+6opgY70QLFL8ZI0WXtLmGQ6iu+yIvkK67AWNVlc4WGmQrgBWuW77dI6 rn0ML/LLg+LKSp69pRntJS6DUkQUgfBnCjMkgz0Z4C/F4vOpEl11paNWLuRXS1qJ5k3/ u0MrUi3C+AT/7GsF5VB/nWIdehOfhhM2xGAdJMxpARL68zOuoyJ+a+toCGrs5LK5vWi6 TqjP71Ip/hbcVketObZ090zpzItadVKc+KpdmRW4bKCvG3Rct8HHE+4hxXGFNVo2KcEk t7OQ== 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-language :content-transfer-encoding; bh=oRmz+4+o7OE+5WNthkg3Flvqqv0uTmDftIeGOPIUHTA=; b=hNlgy1IfzToWl5MlKgFZrIO7D5lTVwFCnt40/qZJ9Kk4miEYagYjBOAUJv9ef1ZrsS rQbzyp65WLgejFNJOdsF9lpWUuRjTRA6AM94STXSBwJwmiMA+9Bfo9WaL7lORAIBLMFy UXMm4HzcA5fuaJu2ERAwKrsiGw3e1ogsRk13U4bEMsy+I1OxM1yvic67EDyPk4YQEate W8XjD+9dVldAfTI2yWCuplss+bf/mp5HYkYQIIFbZAt82Lx2jZrvQadKz/LpE7LMaV7S M5ob+llnKW4NV2mU7t1xkEkcEmWeGaB7FMe3AhpXy/I5fcw6wRTJVzUGdJCi8pXy2Qiw ItPQ== X-Gm-Message-State: AOAM531CYOUfkSasr0ylL6AGOsXWwtdrUQZH+hT5F7k6YQxfYlPdcTdq CG8JCbsaI+SNRk2UNTnZ/c2djDCf59M= X-Google-Smtp-Source: ABdhPJzSYzD05M+cQ/w+z2GvYhAR1lB9uX8WRX+qIyJymL5TKifTPejlXyFLnQ6groUnjHI53XDmHw== X-Received: by 2002:adf:f381:: with SMTP id m1mr7645418wro.347.1603992907302; Thu, 29 Oct 2020 10:35:07 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:2800:a990:f24b:87e1:a560? (p200300ea8f232800a990f24b87e1a560.dip0.t-ipconnect.de. [2003:ea:8f23:2800:a990:f24b:87e1:a560]) by smtp.googlemail.com with ESMTPSA id t19sm964793wmi.26.2020.10.29.10.35.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Oct 2020 10:35:06 -0700 (PDT) Subject: [PATCH net-next 2/4] net: core: add devm_netdev_alloc_pcpu_stats From: Heiner Kallweit To: David Miller , Jakub Kicinski , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: <1fdb8ecd-be0a-755d-1d92-c62ed8399e77@gmail.com> Message-ID: <78eb7e22-902c-0227-3bbf-d324eb232ade@gmail.com> Date: Thu, 29 Oct 2020 18:31:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <1fdb8ecd-be0a-755d-1d92-c62ed8399e77@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We have netdev_alloc_pcpu_stats(), and we have devm_alloc_percpu(). Add a managed version of netdev_alloc_pcpu_stats, e.g. for allocating the per-cpu stats in the probe() callback of a driver. It needs to be a macro for dealing properly with the type argument. Signed-off-by: Heiner Kallweit --- include/linux/netdevice.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 568fab708..6e06fef32 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2596,6 +2596,20 @@ static inline void dev_lstats_add(struct net_device *dev, unsigned int len) #define netdev_alloc_pcpu_stats(type) \ __netdev_alloc_pcpu_stats(type, GFP_KERNEL) +#define devm_netdev_alloc_pcpu_stats(dev, type) \ +({ \ + typeof(type) __percpu *pcpu_stats = devm_alloc_percpu(dev, type);\ + if (pcpu_stats) { \ + int __cpu; \ + for_each_possible_cpu(__cpu) { \ + typeof(type) *stat; \ + stat = per_cpu_ptr(pcpu_stats, __cpu); \ + u64_stats_init(&stat->syncp); \ + } \ + } \ + pcpu_stats; \ +}) + enum netdev_lag_tx_type { NETDEV_LAG_TX_TYPE_UNKNOWN, NETDEV_LAG_TX_TYPE_RANDOM, From patchwork Thu Oct 29 17:33:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 11867065 X-Patchwork-Delegate: kuba@kernel.org 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=ham 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 97F63C55179 for ; Thu, 29 Oct 2020 17:35:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39F6D207DE for ; Thu, 29 Oct 2020 17:35:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g3K+Fy5I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727344AbgJ2RfL (ORCPT ); Thu, 29 Oct 2020 13:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbgJ2RfK (ORCPT ); Thu, 29 Oct 2020 13:35:10 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8210C0613D5 for ; Thu, 29 Oct 2020 10:35:09 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id y12so3689696wrp.6 for ; Thu, 29 Oct 2020 10:35:09 -0700 (PDT) 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-language:content-transfer-encoding; bh=QvmtyFxr6vKdR7cSSnv7I9JoLTrn08Vr5xGDcRwZ4b8=; b=g3K+Fy5IpGTTFu93hn7NkceYYsMQv6FoqrWj/eiLyW+kGu841TlZ3LyE8KsVepLKLX FlbRJFMbN6GAaTqYafrqVMYVF5XEFeTN1X/0ZkbvcT7HEdGjoMG8LXgFJIuWDj2cDa7M IrAgiLvx/no/HshJoARZ7pxzhkDLSrh4CerQeQKAtDZD7CNGj3HbqKzeKjtHkVv+DbYn o0lTVgbKvyV0rPN8J1wPvn6TNi8ehFTJc52eTxTr3ORMAPRuw9VkvxnKsZPNrDJ9t+TH /AWa0qm96Msy6bAEMHcsiQkHiWtGYRl63h88iOnF96XHjlx6BDzG9PFSg1DfMYKJ3Diu bX2w== 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-language :content-transfer-encoding; bh=QvmtyFxr6vKdR7cSSnv7I9JoLTrn08Vr5xGDcRwZ4b8=; b=q4aVhFZBkgu57fF1kJApkfi5XWOlLfwjJEzbp2Xuc48CmKQMjPPmPOcBxa9Z6WuKP3 v//ulwhiNlNhxnvSy9ZAbbe0iWFHeFXJjSefr8Mtk5CBfdcekzes4EIO8akTgnT2w7Wl DZgP/TjlFgEBDCNHN7dN8Ub38JSIv4S+55XDJkvbFWzUkUDQEElnh3LZWGjjRMEI//br scTJq0oBMKBjsea3VY/rEZf9pVXJYCTWDUgdDa8zmMQLeJeJE7ynfLi0uMlcGDygdu6I xVPRLO2TCTDVcg14ZJf3cb0W7kEdaoSDAqbau0eFChxnSNs7oeL7MApxl7DTCp4KdcJd 8jLg== X-Gm-Message-State: AOAM532VPzxIDSovgvtDULPmM6lsBcM4r+sXXH1q/A1Lkxp8mV5Pwp/U R5JA+pOiS3Fl9v0Bt2AUIvjW4r6mS+c= X-Google-Smtp-Source: ABdhPJwbIUbk2WKzLuP0poImKDJap6463N6LVIW2OXjFX5ptsLjHKl7zr5nnC2xX+5rxgb2CbOHdew== X-Received: by 2002:adf:fe84:: with SMTP id l4mr6951022wrr.293.1603992908368; Thu, 29 Oct 2020 10:35:08 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:2800:a990:f24b:87e1:a560? (p200300ea8f232800a990f24b87e1a560.dip0.t-ipconnect.de. [2003:ea:8f23:2800:a990:f24b:87e1:a560]) by smtp.googlemail.com with ESMTPSA id q12sm6394086wrx.13.2020.10.29.10.35.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Oct 2020 10:35:07 -0700 (PDT) Subject: [PATCH net-next 3/4] r8169: use struct pcpu_sw_netstats for rx/tx packet/byte counters From: Heiner Kallweit To: David Miller , Jakub Kicinski , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: <1fdb8ecd-be0a-755d-1d92-c62ed8399e77@gmail.com> Message-ID: <36e182ec-8fe2-2e39-9830-fe86096bc8ef@gmail.com> Date: Thu, 29 Oct 2020 18:33:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <1fdb8ecd-be0a-755d-1d92-c62ed8399e77@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Switch to the net core rx/tx byte/packet counter infrastructure. This simplifies the code, only small drawback is some memory overhead because we use just one queue, but allocate the counters per cpu. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 00f13805c..0ef30ad8a 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4417,6 +4417,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp, if (tp->dirty_tx != dirty_tx) { netdev_completed_queue(dev, pkts_compl, bytes_compl); + dev_sw_netstats_tx_add(dev, pkts_compl, bytes_compl); rtl_inc_priv_stats(&tp->tx_stats, pkts_compl, bytes_compl); tp->dirty_tx = dirty_tx; @@ -4539,6 +4540,7 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget napi_gro_receive(&tp->napi, skb); + dev_sw_netstats_rx_add(dev, pkt_size); rtl_inc_priv_stats(&tp->rx_stats, 1, pkt_size); release_descriptor: rtl8169_mark_to_asic(desc); @@ -4790,9 +4792,7 @@ rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) pm_runtime_get_noresume(&pdev->dev); netdev_stats_to_stats64(stats, &dev->stats); - - rtl_get_priv_stats(&tp->rx_stats, &stats->rx_packets, &stats->rx_bytes); - rtl_get_priv_stats(&tp->tx_stats, &stats->tx_packets, &stats->tx_bytes); + dev_fetch_sw_netstats(stats, dev->tstats); /* * Fetch additional counter values missing in stats collected by driver @@ -5263,6 +5263,11 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->eee_adv = -1; tp->ocp_base = OCP_STD_PHY_BASE; + dev->tstats = devm_netdev_alloc_pcpu_stats(&pdev->dev, + struct pcpu_sw_netstats); + if (!dev->tstats) + return -ENOMEM; + /* Get the *optional* external "ether_clk" used on some boards */ rc = rtl_get_ether_clk(tp); if (rc) From patchwork Thu Oct 29 17:34:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 11867063 X-Patchwork-Delegate: kuba@kernel.org 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=ham 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 17DBAC4363A for ; Thu, 29 Oct 2020 17:35:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE7D620790 for ; Thu, 29 Oct 2020 17:35:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JjmvbWUj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727431AbgJ2RfM (ORCPT ); Thu, 29 Oct 2020 13:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727324AbgJ2RfL (ORCPT ); Thu, 29 Oct 2020 13:35:11 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 216ADC0613D5 for ; Thu, 29 Oct 2020 10:35:11 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id e2so643247wme.1 for ; Thu, 29 Oct 2020 10:35:11 -0700 (PDT) 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-language:content-transfer-encoding; bh=bn6Ffq1R0Fbj3HDTfO/FvuE7XasQ79ljvJbpZcCEY44=; b=JjmvbWUj/fUdpbGtjgwPjPJg1iZBpgQsuDXxssn3p+tCIu4sDWVk4UkChLAr2v81py a/lZpl3ix6XhU0W+J5Nozc6jTSncvxipr7dbbZd6A5Alyl/1Cb0Z4TvJ+1w70GdjqVDO XemQlTSX6EfgHgcZhS8JZqzCCpRNvgqQr4O/SGXU178nvLNuQoJjkidmYehj+Js18c1X lakvTv6HOZEAGT9e+Rmf7xI4nSB90A2QhtIt603i1Lg0EXwmF5iNwWe+QUzHoN0tLr+b BMvGjdZg7aKNhAikY5wkgslUWDbRN4qKLZUtUAIY5CT+EcL6BFch4qxsqqcnxm3LGY+h Wang== 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-language :content-transfer-encoding; bh=bn6Ffq1R0Fbj3HDTfO/FvuE7XasQ79ljvJbpZcCEY44=; b=m1g/jbANQvpuDhbCKflS7K9lI51JJFvxdhVB119Sh++4ghMNbNCQbM/zX3MPgd3Rdv 05K8Y3NKYFjsET4WYYEtIr7o4up3+wxZZZGevdKEx4jOOdF6rTITonkLKHwKefbrIo+K JfYZNhG6Edqud7U66WvmopyZ/RRKcKf7oZ75tWQubREToNHo9PpjDxNoA/ifqOVBWH0a vnXR1e8nA2dUeycgFAQ75fZmnYvho7FSYOHTFckY4XYmrdmYw1j5zNYgY2mfuD2xA/i2 hzRCli+J2Ah+1EbQfL3nAel4kVg+0ce1Zt5M7u55w82KTlTsD3f686Jm2W8g3pTmxZ8d iwGQ== X-Gm-Message-State: AOAM532ZUY8vqZRB90qGk6Oq3iv+7+t3nuhbBovKddRqtr2o5cbf/X0H dLz4pQ6wHJLaJnUKccIUwaho+4JyAww= X-Google-Smtp-Source: ABdhPJx6MeF0rUO3XhuLuSIZz7T19Ir/AtxdT40ulWsTQ3Bwqk1AqGnPbwTuV9UbhJDs6Jo+y3px5w== X-Received: by 2002:a7b:c20d:: with SMTP id x13mr1023939wmi.83.1603992909541; Thu, 29 Oct 2020 10:35:09 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:2800:a990:f24b:87e1:a560? (p200300ea8f232800a990f24b87e1a560.dip0.t-ipconnect.de. [2003:ea:8f23:2800:a990:f24b:87e1:a560]) by smtp.googlemail.com with ESMTPSA id y206sm820851wmd.34.2020.10.29.10.35.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Oct 2020 10:35:09 -0700 (PDT) Subject: [PATCH net-next 4/4] r8169: remove no longer needed private rx/tx packet/byte counters From: Heiner Kallweit To: David Miller , Jakub Kicinski , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: <1fdb8ecd-be0a-755d-1d92-c62ed8399e77@gmail.com> Message-ID: Date: Thu, 29 Oct 2020 18:34:39 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <1fdb8ecd-be0a-755d-1d92-c62ed8399e77@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org After switching to the net core rx/tx byte/packet counters we can remove the now unused private version. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 34 ----------------------- 1 file changed, 34 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 0ef30ad8a..b6c11aaa5 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -584,12 +584,6 @@ enum rtl_flag { RTL_FLAG_MAX }; -struct rtl8169_stats { - u64 packets; - u64 bytes; - struct u64_stats_sync syncp; -}; - struct rtl8169_private { void __iomem *mmio_addr; /* memory map physical address */ struct pci_dev *pci_dev; @@ -600,8 +594,6 @@ struct rtl8169_private { u32 cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */ u32 cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */ u32 dirty_tx; - struct rtl8169_stats rx_stats; - struct rtl8169_stats tx_stats; struct TxDesc *TxDescArray; /* 256-aligned Tx descriptor ring */ struct RxDesc *RxDescArray; /* 256-aligned Rx descriptor ring */ dma_addr_t TxPhyAddr; @@ -700,27 +692,6 @@ static bool rtl_supports_eee(struct rtl8169_private *tp) tp->mac_version != RTL_GIGA_MAC_VER_39; } -static void rtl_get_priv_stats(struct rtl8169_stats *stats, - u64 *pkts, u64 *bytes) -{ - unsigned int start; - - do { - start = u64_stats_fetch_begin_irq(&stats->syncp); - *pkts = stats->packets; - *bytes = stats->bytes; - } while (u64_stats_fetch_retry_irq(&stats->syncp, start)); -} - -static void rtl_inc_priv_stats(struct rtl8169_stats *stats, - u64 pkts, u64 bytes) -{ - u64_stats_update_begin(&stats->syncp); - stats->packets += pkts; - stats->bytes += bytes; - u64_stats_update_end(&stats->syncp); -} - static void rtl_read_mac_from_reg(struct rtl8169_private *tp, u8 *mac, int reg) { int i; @@ -4416,9 +4387,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp, if (tp->dirty_tx != dirty_tx) { netdev_completed_queue(dev, pkts_compl, bytes_compl); - dev_sw_netstats_tx_add(dev, pkts_compl, bytes_compl); - rtl_inc_priv_stats(&tp->tx_stats, pkts_compl, bytes_compl); tp->dirty_tx = dirty_tx; /* Sync with rtl8169_start_xmit: @@ -4541,7 +4510,6 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget napi_gro_receive(&tp->napi, skb); dev_sw_netstats_rx_add(dev, pkt_size); - rtl_inc_priv_stats(&tp->rx_stats, 1, pkt_size); release_descriptor: rtl8169_mark_to_asic(desc); } @@ -5345,8 +5313,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) } INIT_WORK(&tp->wk.work, rtl_task); - u64_stats_init(&tp->rx_stats.syncp); - u64_stats_init(&tp->tx_stats.syncp); rtl_init_mac_address(tp);