From patchwork Thu Oct 15 15:48:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 298922 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 C4D31C433DF for ; Thu, 15 Oct 2020 15:51:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 643F72225A for ; Thu, 15 Oct 2020 15:51:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UyPy0Wtx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389816AbgJOPvc (ORCPT ); Thu, 15 Oct 2020 11:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389693AbgJOPvc (ORCPT ); Thu, 15 Oct 2020 11:51:32 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6625C061755 for ; Thu, 15 Oct 2020 08:51:31 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id t25so4275306ejd.13 for ; Thu, 15 Oct 2020 08:51:31 -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=7Rs/cu2LluMi3CRwOAS1cipacPqrAybd2I0RmR8hvyI=; b=UyPy0WtxAysQeeBvIG8TJsPi/s/50j7Jq+J29WVSo87WbUuf2hpQFFDOOk74bMwoFj 7UEAnupVCwJ+f/daUDujgEOtgMcwCmJFo90vahwXVmxv+WnfcCKTOSU3UKFEXElBtjm0 DGDDyV/BH3PpaSPVV4B7ns4tl3PfhZhH7AQxx2qbme90VJ0ZGtee0N7Ec4QJDOI/TqLi CcBMc/08zQwKkwAR50Hi1oJlRhV+1D/8d3T3ft3+4XlkqiZ3Lfrzkb8eeC++JoRxBpIp 3XwTiJFRUuGJC+XackRsDN6Cfkwkyk3rs7CTlZswr6bupZS/lKXq20GdOJJ8A30/4YMV L38A== 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=7Rs/cu2LluMi3CRwOAS1cipacPqrAybd2I0RmR8hvyI=; b=IaaSdcgnm+5lMvjNV2Ys4wISRsER5riPMn0JMltUGGl3G3swTvTWrhbEPbEyFh+yak 8866m5t0KGvW1E/xM+IOk66L8Avql4zqyguiiehSrRfBR592OpdjYiKqMRIdEi89pkee /K77KTpcIywbq7NzrRyxBsD4dRdWPVmu9+WuQFnObReT3VMbuLXbYCbRa0tHfAgEHP19 I3VF5o2Iet7TS6/EjfuQhl69X+ROksCvehODep+tMI6xDtH+8o3y5/q2U/LfTpUTmbXF RsOPpdmdj0W/sw+14D1SDm0rrYghnuzeBffkWIz6ZFydLoweMAgnRPSbd8iBlWzSb990 pnQA== X-Gm-Message-State: AOAM532GmBe/PKW+9W2gpCapIOgMJEYbk4qFD6FxivZSJsiKsxiCsyw5 Bg2uRhoXzNvpQALWDOH06fn8pKfUbrg= X-Google-Smtp-Source: ABdhPJySrqTxwShcBEKpSsEVEoc6etfTnMPSV2xUAbYCdJhE2sMTFV5hiz/PUy8R3lcKjHINp5CmYQ== X-Received: by 2002:a17:906:c095:: with SMTP id f21mr5377527ejz.108.1602777090307; Thu, 15 Oct 2020 08:51:30 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:2800:c92:1571:ee2d:f2ef? (p200300ea8f2328000c921571ee2df2ef.dip0.t-ipconnect.de. [2003:ea:8f23:2800:c92:1571:ee2d:f2ef]) by smtp.googlemail.com with ESMTPSA id ce14sm1835670edb.25.2020.10.15.08.51.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Oct 2020 08:51:29 -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: Message-ID: Date: Thu, 15 Oct 2020 17:48:37 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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 15 15:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 288438 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 4A611C43467 for ; Thu, 15 Oct 2020 15:51:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E353122255 for ; Thu, 15 Oct 2020 15:51:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uF9g4Ud3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389888AbgJOPvf (ORCPT ); Thu, 15 Oct 2020 11:51:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389852AbgJOPve (ORCPT ); Thu, 15 Oct 2020 11:51:34 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6481C061755 for ; Thu, 15 Oct 2020 08:51:32 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id md26so4307442ejb.10 for ; Thu, 15 Oct 2020 08:51:32 -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=vAR035LoWI6oVGxH2cka+EBnHGrsQFbXd6TPtqudK28=; b=uF9g4Ud3NUWZbXqZq0g6hZ8ZmODxs9kjULYfFouB1a90R7LUxfa1cAAlRI5COKzxg5 sFBk3bvsgk9htCwzTsoNNXav5MGQOO+S0+jq3gD71mjCk80b4nX3ySiBkcooDqCQ9Rh0 cUNPaxuKu2NhboDA6Pa5YzuBfq6sE2p0OJUNjqfsaeeg7Nvf6pkDCXRSQPEjMhxtnyED Y9rVWPc51hYOPZbILwNeVhpC90KlYgi2hp8ZkhlTc1D/xps0l14gyUFph0sTGZuI0rHc 7fYPHcsn7QdB+cuhe6hxCxom9kVFPzb5PTkIEYqvzzRS/zokk9cMTmRRDkCphBQU+3rz Larg== 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=vAR035LoWI6oVGxH2cka+EBnHGrsQFbXd6TPtqudK28=; b=cXJ37nN/cXc8cDoWg02atpuKYoyZotjkUMFCT70+GpwHmCzufWZzE6IbX2C3JpKuSI oUjBmkBEwpzA7OTuTJsZFrnvh9YFrK2VOX9BS8lnAhM7seLENSj9M59PhlBV3l+LeYhx a/yqQsSFiFb/fXQDB2mQKnAKKHjQL7jsSfQqh0G6tQdeuC4hlUcIk8tLjhSDUhhvz2kC 9q9QoLoIrwvozCSrQvfg+NeLb1jWvE0hnt8qDAcqTCKSiFnJlFwPl3kcIk27qIW5GZhF 9Az+FruU0oh4o9tJdBjDq4TbIF5D5V+l2wS+5h+l03jZpdK66M8AlQKGhdnS/sqMybfv YQBQ== X-Gm-Message-State: AOAM531JUThi+HU4nZPRhdaXVzQJuP3bT/NXTaBctxFSPYhRinWRPXrz 7x4xiWKvE8cRTE0QEtCixEQVz/rJVAM= X-Google-Smtp-Source: ABdhPJxpooECDK7H9bFbJAWDHZZxkQ6TypGji3r99STHSyot6+uyOtEThOlRxAw+WUvpXU+oDBjkSQ== X-Received: by 2002:a17:906:6805:: with SMTP id k5mr5348403ejr.79.1602777091362; Thu, 15 Oct 2020 08:51:31 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:2800:c92:1571:ee2d:f2ef? (p200300ea8f2328000c921571ee2df2ef.dip0.t-ipconnect.de. [2003:ea:8f23:2800:c92:1571:ee2d:f2ef]) by smtp.googlemail.com with ESMTPSA id d7sm1850465edu.46.2020.10.15.08.51.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Oct 2020 08:51:30 -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: Message-ID: <1c618e2d-049c-7dfa-0f82-5f32fa4e9322@gmail.com> Date: Thu, 15 Oct 2020 17:49:20 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 | 15 +++++++++++++++ net/devres.c | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 568fab708..f5f41c160 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2596,6 +2596,21 @@ 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) +void devm_free_pcpu_stats(void *data); + +#define devm_netdev_alloc_pcpu_stats(dev, type) \ +({ \ + typeof(type) __percpu *pcpu_stats = netdev_alloc_pcpu_stats(type); \ + if (pcpu_stats) { \ + int rc = devm_add_action_or_reset(dev, \ + devm_free_pcpu_stats, \ + (__force void *)pcpu_stats); \ + if (rc) \ + pcpu_stats = NULL; \ + } \ + pcpu_stats; \ +}) + enum netdev_lag_tx_type { NETDEV_LAG_TX_TYPE_UNKNOWN, NETDEV_LAG_TX_TYPE_RANDOM, diff --git a/net/devres.c b/net/devres.c index 1f9be2133..0d6545946 100644 --- a/net/devres.c +++ b/net/devres.c @@ -93,3 +93,9 @@ int devm_register_netdev(struct device *dev, struct net_device *ndev) return 0; } EXPORT_SYMBOL(devm_register_netdev); + +void devm_free_pcpu_stats(void *data) +{ + free_percpu((__force void __percpu *)data); +} +EXPORT_SYMBOL_GPL(devm_free_pcpu_stats); From patchwork Thu Oct 15 15:50:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 298921 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 3A8FFC433DF for ; Thu, 15 Oct 2020 15:51:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFD912225A for ; Thu, 15 Oct 2020 15:51:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eIVCa9sv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389896AbgJOPvf (ORCPT ); Thu, 15 Oct 2020 11:51:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389693AbgJOPve (ORCPT ); Thu, 15 Oct 2020 11:51:34 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E545EC0613D2 for ; Thu, 15 Oct 2020 08:51:33 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id cq12so3609874edb.2 for ; Thu, 15 Oct 2020 08:51:33 -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=o1HGVmUT/OhvqKkWrLamJKiOCE0cdQtudBTyS1tZm8I=; b=eIVCa9svoHxUjRC70zo4OwYhp32AE6RKwMIOps7ykTJTC59EFjxgj7M/zYDwO1smDe hfaGGR0iMaTIA2UaCCGAdFYm8EOsETPB3x3vTIvwM8y3EnZu/uJuQ59NviKaCCm1xcZy LYin9MEe080ve5nmUZ3mR5MFVUCJ+s7XxGSMC7ZXvIr2n2GzshclyMxTtFCCnikpmqJh uTB6Zq/rx4PHm4Sz4qiih0+WzGyTlnc7mtuFDrukIA+atSHYOmt7aMKNxe7f8nIY/QGC wjX1ie8CkSzsTlvHJwOb9EezEAFQ/qPOk2uJsSecIB1kUNtuxQLWIbE1mjdKqfGSs3vX 1h7w== 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=o1HGVmUT/OhvqKkWrLamJKiOCE0cdQtudBTyS1tZm8I=; b=ncwx4CahZk7nt1Tr6s4R7akTDcvrseuMn/HSE0T/+EYZZ7RN5/VpextlAyYJpgWhts TjZvVQ2iL/grASg+NUfedxHNH3EhQc85gJQ0811exhgJFqf+n8DX4QjuFFLP65eLrzBF 0vijqBHaaWgFulSsMzIcF0Rp0jmmgzzLhX7eAZouwxpD6ml/8xKw2XD1ChZkLMvl+OuK uAdxMA6TmebnFLsQUIHspFCqMrdaK0JxjR+YzyOeYZ/sy7Zf9i9ukHA+11XNxiyZmDMb mj6hqh9OjDqfLmcD+FysHQrNw12xHwtUw41jal/hKB2H2hWfEFVGleF2aGraUgsJ0jGm 7Phw== X-Gm-Message-State: AOAM5331NZ+PeTS/JaXG7rmjRv1aKeR4ychiv4wXjJjqv9JBq7pBtrZn LhcIpB1i/vf+RjhItI7R4devwshEynA= X-Google-Smtp-Source: ABdhPJx3b2+j3m1NdTUNo5JM1dS04Uly6y9CIIdasSgDFCh/FtAWiY2wQ5yfS09nCp/+6TEMB/2L7Q== X-Received: by 2002:a05:6402:2070:: with SMTP id bd16mr5038499edb.358.1602777092396; Thu, 15 Oct 2020 08:51:32 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:2800:c92:1571:ee2d:f2ef? (p200300ea8f2328000c921571ee2df2ef.dip0.t-ipconnect.de. [2003:ea:8f23:2800:c92:1571:ee2d:f2ef]) by smtp.googlemail.com with ESMTPSA id r4sm1827936edv.16.2020.10.15.08.51.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Oct 2020 08:51:32 -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: Message-ID: <8d0804a1-16e5-2f76-9e7e-213cd093b520@gmail.com> Date: Thu, 15 Oct 2020 17:50:12 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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 7d366b036..840543bc8 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 15 15:51:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 288439 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 628ADC433E7 for ; Thu, 15 Oct 2020 15:51:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F23D12225D for ; Thu, 15 Oct 2020 15:51:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gUDWyJFB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389902AbgJOPvg (ORCPT ); Thu, 15 Oct 2020 11:51:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389852AbgJOPvf (ORCPT ); Thu, 15 Oct 2020 11:51:35 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E43B1C061755 for ; Thu, 15 Oct 2020 08:51:34 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id l24so3571664edj.8 for ; Thu, 15 Oct 2020 08:51:34 -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=Lieqmg2kpO/cVhmlQ17TOZxbIgp5fwMdOy7myfEO1BI=; b=gUDWyJFBmLrKVkMM3xOvMOa8DJzYCgQc34/x0vg5MVm98NdVLNqr2XZ+bv9+RhMKyd f6EHHUp/Y5LQe5wAOvFCV1yF91ae4CcX5KNJrHq8sb6fTn2ZMtVwI8BgbqA28SMv2Lo+ wQ4OnhvdQSYS9CoJNkv0oyQPwt4X+6YLxbNSknKbl+89zjv/ZiE9zHQrXXGBiZdDmrT2 bfryTkjCna7/268k+qmS22dYWGH0PTmYyOPvIcbV1aJAHMiBk4MEY8IgPrfvisgddIXf MeTYDzjCoRQo3WBMOp01hny+/tSPZtpzwEfxRgwQKKRf+qiqL51/EeajJlaBwzwIYj1N s2Pw== 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=Lieqmg2kpO/cVhmlQ17TOZxbIgp5fwMdOy7myfEO1BI=; b=uF9O8PwVSYAcpA8VUx3VLTERtiUUmvMu3wZn25RmQ6xgcKJqxXRrKOHd1IohjGh3KL xz1z2pOusDI+QlBK/30zpwq1jDBS/fd2I5KxCJ8gufPveY6asYY2aH6xhMmTbfhusCCf DY5S72wUcFsi1V4WQwRapRWOQ0hON+1k7gYrvmo7zwcO671Frg/X7o01S4NqMCQWzDWB KyI9OlD5BCF1TEDPKO+w0UnjCVv9kTgbij0mDzlQM90k8yYN1k62vvmhxzJfSkU6fGs+ Danrr7dv4nCwMiD5oD+Q+oXCA21tqiXV9r8vl5Xf7uNeqSsCuKuRZZ0cXi+0Ipq3i4V1 P8cw== X-Gm-Message-State: AOAM532AJm5XbfsBkIUQcigDZPYnYCaZxUvEIJf5MrY87WvPCdE43aKd MTnguH7r5onM8DG1x77kybQwwzH1XJQ= X-Google-Smtp-Source: ABdhPJxO4QNda/Gvy+uTfydeGCzRoAt7FrGKSQgRcRUVl5VbLn7FZdQMm1uzzoxND4UYHMF7AUDAZw== X-Received: by 2002:a50:d5d8:: with SMTP id g24mr4956948edj.119.1602777093380; Thu, 15 Oct 2020 08:51:33 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:2800:c92:1571:ee2d:f2ef? (p200300ea8f2328000c921571ee2df2ef.dip0.t-ipconnect.de. [2003:ea:8f23:2800:c92:1571:ee2d:f2ef]) by smtp.googlemail.com with ESMTPSA id m6sm2106982ejl.94.2020.10.15.08.51.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Oct 2020 08:51:32 -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: Message-ID: <001f7596-d30a-c2a6-dffb-3ead88ae769e@gmail.com> Date: Thu, 15 Oct 2020 17:51:20 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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 840543bc8..345cd5f00 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);