From patchwork Tue Aug 3 16:36:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12416785 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 76B8CC432BE for ; Tue, 3 Aug 2021 16:38:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58A8C61104 for ; Tue, 3 Aug 2021 16:38:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234920AbhHCQim (ORCPT ); Tue, 3 Aug 2021 12:38:42 -0400 Received: from mga03.intel.com ([134.134.136.65]:60864 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234338AbhHCQiE (ORCPT ); Tue, 3 Aug 2021 12:38:04 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10065"; a="213766160" X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="213766160" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 09:37:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="500883687" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga001.jf.intel.com with ESMTP; 03 Aug 2021 09:37:41 -0700 Received: from alobakin-mobl.ger.corp.intel.com (eflejszm-mobl2.ger.corp.intel.com [10.213.26.164]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 173GahF3029968; Tue, 3 Aug 2021 17:37:36 +0100 From: Alexander Lobakin To: "David S. Miller" , Jakub Kicinski Cc: Alexander Lobakin , Jesse Brandeburg , Lukasz Czapnik , Marcin Kubiak , Michal Kubiak , Michal Swiatkowski , Jonathan Corbet , Netanel Belgazal , Arthur Kiyanovski , Guy Tzalik , Saeed Bishara , Ioana Ciornei , Claudiu Manoil , Thomas Petazzoni , Marcin Wojtas , Russell King , Edward Cree , Martin Habets , "Michael S. Tsirkin" , Jason Wang , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Shay Agroskin , Sameeh Jubran , Alexander Duyck , Danielle Ratson , Ido Schimmel , Andrew Lunn , Vladyslav Tarasiuk , Arnd Bergmann , Andrew Morton , Jian Shen , Petr Vorel , Dan Murphy , Yangbo Lu , Michal Kubecek , Zheng Yongjun , Heiner Kallweit , YueHaibing , Johannes Berg , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, bpf@vger.kernel.org Subject: [PATCH net-next 13/21] ethernet, sfc: convert to standard XDP stats Date: Tue, 3 Aug 2021 18:36:33 +0200 Message-Id: <20210803163641.3743-14-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210803163641.3743-1-alexandr.lobakin@intel.com> References: <20210803163641.3743-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Just like DPAA2 driver, EF{100,X} store XDP stats per-channel, but present them as the sums across all channels. Switch to the standard per-channel XDP stats. n_rx_xdp_bad_drops goes as "general XDP errors", because driver uses just one counter for all kinds of errors. Signed-off-by: Alexander Lobakin Reviewed-by: Jesse Brandeburg Acked-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_ethtool.c | 2 ++ drivers/net/ethernet/sfc/ethtool.c | 2 ++ drivers/net/ethernet/sfc/ethtool_common.c | 35 ++++++++++++++++++++--- drivers/net/ethernet/sfc/ethtool_common.h | 3 ++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef100_ethtool.c b/drivers/net/ethernet/sfc/ef100_ethtool.c index 835c838b7dfa..c4797fefef2e 100644 --- a/drivers/net/ethernet/sfc/ef100_ethtool.c +++ b/drivers/net/ethernet/sfc/ef100_ethtool.c @@ -49,6 +49,8 @@ const struct ethtool_ops ef100_ethtool_ops = { .get_fecparam = efx_ethtool_get_fecparam, .set_fecparam = efx_ethtool_set_fecparam, .get_ethtool_stats = efx_ethtool_get_stats, + .get_std_stats_channels = efx_ethtool_get_std_stats_channels, + .get_xdp_stats = efx_ethtool_get_xdp_stats, .get_rxnfc = efx_ethtool_get_rxnfc, .set_rxnfc = efx_ethtool_set_rxnfc, .reset = efx_ethtool_reset, diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 058d9fe41d99..307724275a3e 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -269,4 +269,6 @@ const struct ethtool_ops efx_ethtool_ops = { .get_fec_stats = efx_ethtool_get_fec_stats, .get_fecparam = efx_ethtool_get_fecparam, .set_fecparam = efx_ethtool_set_fecparam, + .get_std_stats_channels = efx_ethtool_get_std_stats_channels, + .get_xdp_stats = efx_ethtool_get_xdp_stats, }; diff --git a/drivers/net/ethernet/sfc/ethtool_common.c b/drivers/net/ethernet/sfc/ethtool_common.c index bf1443539a1a..4aa6792d5795 100644 --- a/drivers/net/ethernet/sfc/ethtool_common.c +++ b/drivers/net/ethernet/sfc/ethtool_common.c @@ -87,10 +87,6 @@ static const struct efx_sw_stat_desc efx_sw_stat_desc[] = { EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc), EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_events), EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_packets), - EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_drops), - EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_bad_drops), - EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_tx), - EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_redirect), #ifdef CONFIG_RFS_ACCEL EFX_ETHTOOL_UINT_CHANNEL_STAT_NO_N(rfs_filter_count), EFX_ETHTOOL_UINT_CHANNEL_STAT(rfs_succeeded), @@ -557,6 +553,37 @@ void efx_ethtool_get_stats(struct net_device *net_dev, efx_ptp_update_stats(efx, data); } +int efx_ethtool_get_std_stats_channels(struct net_device *net_dev, u32 sset) +{ + const struct efx_nic *efx = netdev_priv(net_dev); + + switch (sset) { + case ETH_SS_STATS_XDP: + return efx->n_channels; + default: + return -EOPNOTSUPP; + } +} + +void efx_ethtool_get_xdp_stats(struct net_device *net_dev, + struct ethtool_xdp_stats *xdp_stats) +{ + struct efx_nic *efx = netdev_priv(net_dev); + const struct efx_channel *channel; + + spin_lock_bh(&efx->stats_lock); + + efx_for_each_channel(channel, efx) { + xdp_stats->drop = channel->n_rx_xdp_drops; + xdp_stats->errors = channel->n_rx_xdp_bad_drops; + xdp_stats->redirect = channel->n_rx_xdp_redirect; + xdp_stats->tx = channel->n_rx_xdp_tx; + xdp_stats++; + } + + spin_unlock_bh(&efx->stats_lock); +} + /* This must be called with rtnl_lock held. */ int efx_ethtool_get_link_ksettings(struct net_device *net_dev, struct ethtool_link_ksettings *cmd) diff --git a/drivers/net/ethernet/sfc/ethtool_common.h b/drivers/net/ethernet/sfc/ethtool_common.h index 659491932101..bb2a43873ba1 100644 --- a/drivers/net/ethernet/sfc/ethtool_common.h +++ b/drivers/net/ethernet/sfc/ethtool_common.h @@ -30,6 +30,9 @@ void efx_ethtool_get_strings(struct net_device *net_dev, u32 string_set, void efx_ethtool_get_stats(struct net_device *net_dev, struct ethtool_stats *stats __attribute__ ((unused)), u64 *data); +int efx_ethtool_get_std_stats_channels(struct net_device *net_dev, u32 sset); +void efx_ethtool_get_xdp_stats(struct net_device *net_dev, + struct ethtool_xdp_stats *xdp_stats); int efx_ethtool_get_link_ksettings(struct net_device *net_dev, struct ethtool_link_ksettings *out); int efx_ethtool_set_link_ksettings(struct net_device *net_dev,