From patchwork Tue Nov 23 16:39: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: 12634733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75D4EC433FE for ; Tue, 23 Nov 2021 16:41:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234534AbhKWQos (ORCPT ); Tue, 23 Nov 2021 11:44:48 -0500 Received: from mga12.intel.com ([192.55.52.136]:26573 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234942AbhKWQoj (ORCPT ); Tue, 23 Nov 2021 11:44:39 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10177"; a="215086302" X-IronPort-AV: E=Sophos;i="5.87,258,1631602800"; d="scan'208";a="215086302" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2021 08:41:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,258,1631602800"; d="scan'208";a="456747076" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga003.jf.intel.com with ESMTP; 23 Nov 2021 08:41:17 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 1ANGf4Wg016784; Tue, 23 Nov 2021 16:41:14 GMT From: Alexander Lobakin To: "David S. Miller" , Jakub Kicinski Cc: Alexander Lobakin , Jesse Brandeburg , Michal Swiatkowski , Maciej Fijalkowski , Jonathan Corbet , Shay Agroskin , Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , Ioana Ciornei , Claudiu Manoil , Tony Nguyen , Thomas Petazzoni , Marcin Wojtas , Russell King , Saeed Mahameed , Leon Romanovsky , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , =?utf-8?q?Toke_H=C3=B8iland-J?= =?utf-8?q?=C3=B8rgensen?= , John Fastabend , Edward Cree , Martin Habets , "Michael S. Tsirkin" , Jason Wang , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Lorenzo Bianconi , Yajun Deng , Sergey Ryazanov , David Ahern , Andrei Vagin , Johannes Berg , Vladimir Oltean , Cong Wang , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v2 net-next 04/26] dpaa2: implement generic XDP stats callbacks Date: Tue, 23 Nov 2021 17:39:33 +0100 Message-Id: <20211123163955.154512-5-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211123163955.154512-1-alexandr.lobakin@intel.com> References: <20211123163955.154512-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Add an ability to dpaa2 to query its 5 per-channel XDP counters using generic XDP stats infra. Signed-off-by: Alexander Lobakin Reviewed-by: Jesse Brandeburg --- .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) -- 2.33.1 diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 6451c8383639..7715aecedacc 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -1973,6 +1973,49 @@ static void dpaa2_eth_get_stats(struct net_device *net_dev, } } +static int dpaa2_eth_get_xdp_stats_nch(const struct net_device *net_dev, + u32 attr_id) +{ + const struct dpaa2_eth_priv *priv = netdev_priv(net_dev); + + switch (attr_id) { + case IFLA_XDP_XSTATS_TYPE_XDP: + return priv->num_channels; + default: + return -EOPNOTSUPP; + } +} + +static int dpaa2_eth_get_xdp_stats(const struct net_device *net_dev, + u32 attr_id, void *attr_data) +{ + const struct dpaa2_eth_priv *priv = netdev_priv(net_dev); + struct ifla_xdp_stats *xdp_stats = attr_data; + u32 i; + + switch (attr_id) { + case IFLA_XDP_XSTATS_TYPE_XDP: + break; + default: + return -EOPNOTSUPP; + } + + for (i = 0; i < priv->num_channels; i++) { + const struct dpaa2_eth_ch_stats *ch_stats; + + ch_stats = &priv->channel[i]->stats; + + xdp_stats->drop = ch_stats->xdp_drop; + xdp_stats->redirect = ch_stats->xdp_redirect; + xdp_stats->tx = ch_stats->xdp_tx; + xdp_stats->tx_errors = ch_stats->xdp_tx_err; + + xdp_stats++; + } + + return 0; +} + /* Copy mac unicast addresses from @net_dev to @priv. * Its sole purpose is to make dpaa2_eth_set_rx_mode() more readable. */ @@ -2601,6 +2644,8 @@ static const struct net_device_ops dpaa2_eth_ops = { .ndo_stop = dpaa2_eth_stop, .ndo_set_mac_address = dpaa2_eth_set_addr, .ndo_get_stats64 = dpaa2_eth_get_stats, + .ndo_get_xdp_stats_nch = dpaa2_eth_get_xdp_stats_nch, + .ndo_get_xdp_stats = dpaa2_eth_get_xdp_stats, .ndo_set_rx_mode = dpaa2_eth_set_rx_mode, .ndo_set_features = dpaa2_eth_set_features, .ndo_eth_ioctl = dpaa2_eth_ioctl,