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);