From patchwork Tue Aug 3 16:36:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12416773 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 88514C432BE for ; Tue, 3 Aug 2021 16:37:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BC046109F for ; Tue, 3 Aug 2021 16:37:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234179AbhHCQhp (ORCPT ); Tue, 3 Aug 2021 12:37:45 -0400 Received: from mga03.intel.com ([134.134.136.65]:60794 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234215AbhHCQhl (ORCPT ); Tue, 3 Aug 2021 12:37:41 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10065"; a="213766082" X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="213766082" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 09:37:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="479589080" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga008.fm.intel.com with ESMTP; 03 Aug 2021 09:37:17 -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 173GahEv029968; Tue, 3 Aug 2021 17:37:12 +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 07/21] ethernet, ena: convert to standard XDP stats Date: Tue, 3 Aug 2021 18:36:27 +0200 Message-Id: <20210803163641.3743-8-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 Its 6 XDP per-channel counters align just fine with the standard stats. Drop them from the custom Ethtool statistics and expose to the standard stats infra instead. Signed-off-by: Alexander Lobakin Reviewed-by: Jesse Brandeburg --- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c index 851a198cec82..1b6563641575 100644 --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c @@ -90,12 +90,6 @@ static const struct ena_stats ena_stats_rx_strings[] = { ENA_STAT_RX_ENTRY(bad_req_id), ENA_STAT_RX_ENTRY(empty_rx_ring), ENA_STAT_RX_ENTRY(csum_unchecked), - ENA_STAT_RX_ENTRY(xdp_aborted), - ENA_STAT_RX_ENTRY(xdp_drop), - ENA_STAT_RX_ENTRY(xdp_pass), - ENA_STAT_RX_ENTRY(xdp_tx), - ENA_STAT_RX_ENTRY(xdp_invalid), - ENA_STAT_RX_ENTRY(xdp_redirect), }; static const struct ena_stats ena_stats_ena_com_strings[] = { @@ -324,6 +318,44 @@ static void ena_get_ethtool_strings(struct net_device *netdev, } } +static int ena_get_std_stats_channels(struct net_device *netdev, u32 sset) +{ + const struct ena_adapter *adapter = netdev_priv(netdev); + + switch (sset) { + case ETH_SS_STATS_XDP: + return adapter->num_io_queues; + default: + return -EOPNOTSUPP; + } +} + +static void ena_get_xdp_stats(struct net_device *netdev, + struct ethtool_xdp_stats *xdp_stats) +{ + const struct ena_adapter *adapter = netdev_priv(netdev); + const struct u64_stats_sync *syncp; + const struct ena_stats_rx *stats; + struct ethtool_xdp_stats *iter; + u32 i; + + for (i = 0; i < adapter->num_io_queues; i++) { + stats = &adapter->rx_ring[i].rx_stats; + syncp = &adapter->rx_ring[i].syncp; + iter = xdp_stats + i; + + ena_safe_update_stat(&stats->xdp_drop, &iter->drop, syncp); + ena_safe_update_stat(&stats->xdp_pass, &iter->pass, syncp); + ena_safe_update_stat(&stats->xdp_tx, &iter->tx, syncp); + ena_safe_update_stat(&stats->xdp_redirect, &iter->redirect, + syncp); + ena_safe_update_stat(&stats->xdp_aborted, &iter->aborted, + syncp); + ena_safe_update_stat(&stats->xdp_invalid, &iter->invalid, + syncp); + } +} + static int ena_get_link_ksettings(struct net_device *netdev, struct ethtool_link_ksettings *link_ksettings) { @@ -916,6 +948,8 @@ static const struct ethtool_ops ena_ethtool_ops = { .get_tunable = ena_get_tunable, .set_tunable = ena_set_tunable, .get_ts_info = ethtool_op_get_ts_info, + .get_std_stats_channels = ena_get_std_stats_channels, + .get_xdp_stats = ena_get_xdp_stats, }; void ena_set_ethtool_ops(struct net_device *netdev)