{"id":2220891,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2220891/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/0815f1eb4b60faa653ea703e420395b724d05216.1775648513.git.pabeni@redhat.com/","project":{"id":46,"url":"http://patchwork.ozlabs.org/api/1.1/projects/46/?format=json","name":"Intel Wired Ethernet development","link_name":"intel-wired-lan","list_id":"intel-wired-lan.osuosl.org","list_email":"intel-wired-lan@osuosl.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<0815f1eb4b60faa653ea703e420395b724d05216.1775648513.git.pabeni@redhat.com>","date":"2026-04-08T11:43:45","name":"[iwl-next,1/2] i40e: implement basic per-queue stats","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"41756c828a038a97af0767cb011abb487a48a444","submitter":{"id":67312,"url":"http://patchwork.ozlabs.org/api/1.1/people/67312/?format=json","name":"Paolo Abeni","email":"pabeni@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/0815f1eb4b60faa653ea703e420395b724d05216.1775648513.git.pabeni@redhat.com/mbox/","series":[{"id":499122,"url":"http://patchwork.ozlabs.org/api/1.1/series/499122/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=499122","date":"2026-04-08T11:43:44","name":"i40e: implement per-queue stats","version":1,"mbox":"http://patchwork.ozlabs.org/series/499122/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2220891/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2220891/checks/","tags":{},"headers":{"Return-Path":"<intel-wired-lan-bounces@osuosl.org>","X-Original-To":["incoming@patchwork.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256\n header.s=default header.b=J9J5Ve/Q;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frLnm6ScDz1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 08 Apr 2026 21:44:28 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id 2288340EF7;\n\tWed,  8 Apr 2026 11:44:27 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id ZIbYyovEU44s; Wed,  8 Apr 2026 11:44:26 +0000 (UTC)","from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id 60BAC40E9E;\n\tWed,  8 Apr 2026 11:44:26 +0000 (UTC)","from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n by lists1.osuosl.org (Postfix) with ESMTP id 181B1237\n for <intel-wired-lan@lists.osuosl.org>; Wed,  8 Apr 2026 11:44:25 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n by smtp4.osuosl.org (Postfix) with ESMTP id 0A74340E9E\n for <intel-wired-lan@lists.osuosl.org>; Wed,  8 Apr 2026 11:44:25 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id ZBDP9i1p-v63 for <intel-wired-lan@lists.osuosl.org>;\n Wed,  8 Apr 2026 11:44:24 +0000 (UTC)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by smtp4.osuosl.org (Postfix) with ESMTPS id E4B7540E4B\n for <intel-wired-lan@lists.osuosl.org>; Wed,  8 Apr 2026 11:44:23 +0000 (UTC)","from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-UudbUPSyM8yz-NV0sAcXTA-1; Wed,\n 08 Apr 2026 07:44:18 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id A2F3A1800610; Wed,  8 Apr 2026 11:44:15 +0000 (UTC)","from gerbillo.redhat.com (unknown [10.44.32.173])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 4A7FA1800361; Wed,  8 Apr 2026 11:44:11 +0000 (UTC)"],"X-Virus-Scanned":["amavis at osuosl.org","amavis at osuosl.org"],"X-Comment":"SPF check N/A for local connections - client-ip=140.211.166.142;\n helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=<UNKNOWN> ","DKIM-Filter":["OpenDKIM Filter v2.11.0 smtp4.osuosl.org 60BAC40E9E","OpenDKIM Filter v2.11.0 smtp4.osuosl.org E4B7540E4B"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org;\n\ts=default; t=1775648666;\n\tbh=NvUt9aU1Ztdwrr0UI5JNClG/hHu+7WShFgS8wrqKml0=;\n\th=From:To:Cc:Date:In-Reply-To:References:Subject:List-Id:\n\t List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:\n\t From;\n\tb=J9J5Ve/QdslmumeRyiXS9+syUdKtQfK4R0qmg15NPaidpMkdtpr3qb2vNoOQXt2vC\n\t oCe5YnwbuNQ3PQoKO33bej0zMSoGNdOMMi8OrkMncACh33p6hVKErMWyzW4N7btWZB\n\t eYGm77w5Evrn5hHYyqycveD4Qhg4ehWBrhBCr1YMypvBcqHrTi+peD1I1CAQNS4+Gv\n\t k/vkrB2iGzy2+Zp87BlTlenlLJBt4lOVNAcX1bq7/b+a9v8f9LGPGyi9Cqt6KvxQgS\n\t GZreqHbZA5nkJjfkLl4/sfQjMakHOM9aTWkFXA1c3MgGQ3nYV3tgMIv9OuAM2TtbQ6\n\t PDFsGhqq12beg==","Received-SPF":"Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124;\n helo=us-smtp-delivery-124.mimecast.com; envelope-from=pabeni@redhat.com;\n receiver=<UNKNOWN>","DMARC-Filter":"OpenDMARC Filter v1.4.2 smtp4.osuosl.org E4B7540E4B","X-MC-Unique":"UudbUPSyM8yz-NV0sAcXTA-1","X-Mimecast-MFC-AGG-ID":"UudbUPSyM8yz-NV0sAcXTA_1775648656","From":"Paolo Abeni <pabeni@redhat.com>","To":"intel-wired-lan@lists.osuosl.org","Cc":"Tony Nguyen <anthony.l.nguyen@intel.com>,\n Przemek Kitszel <przemyslaw.kitszel@intel.com>,\n Andrew Lunn <andrew+netdev@lunn.ch>,\n \"David S. Miller\" <davem@davemloft.net>,\n Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>,\n Alexei Starovoitov <ast@kernel.org>,\n Daniel Borkmann <daniel@iogearbox.net>,\n Jesper Dangaard Brouer <hawk@kernel.org>,\n John Fastabend <john.fastabend@gmail.com>,\n Stanislav Fomichev <sdf@fomichev.me>, netdev@vger.kernel.org","Date":"Wed,  8 Apr 2026 13:43:45 +0200","Message-ID":"\n <0815f1eb4b60faa653ea703e420395b724d05216.1775648513.git.pabeni@redhat.com>","In-Reply-To":"<cover.1775648513.git.pabeni@redhat.com>","References":"<cover.1775648513.git.pabeni@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","X-Mimecast-MFC-PROC-ID":"7v-xwW7LgP6TkADT83RPuFVhwUlN3HkUj3uponTtggg_1775648656","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-Mailman-Original-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com;\n s=mimecast20190719; t=1775648662;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=NvUt9aU1Ztdwrr0UI5JNClG/hHu+7WShFgS8wrqKml0=;\n b=B/iXBZS/dEZMC0vIygiL2sThZboDgt8uPe31QP7hpgfgjkBIyJV646ffifaZVyz9dkrj4n\n lcPrJbn5ZWzPe91LAnwSaGcLc2bnCAJLoV54dwZVfl59Z8+YNYI/HXF+C6TRUes0LYymoR\n kqExTQ0K1ZTNY7hz6VWbYUIvMyhKEtA=","X-Mailman-Original-Authentication-Results":["smtp4.osuosl.org;\n dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","smtp4.osuosl.org;\n dkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=B/iXBZS/"],"Subject":"[Intel-wired-lan] [PATCH iwl-next 1/2] i40e: implement basic\n per-queue stats","X-BeenThere":"intel-wired-lan@osuosl.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Intel Wired Ethernet Linux Kernel Driver Development\n <intel-wired-lan.osuosl.org>","List-Unsubscribe":"<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>","List-Archive":"<http://lists.osuosl.org/pipermail/intel-wired-lan/>","List-Post":"<mailto:intel-wired-lan@osuosl.org>","List-Help":"<mailto:intel-wired-lan-request@osuosl.org?subject=help>","List-Subscribe":"<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>","Errors-To":"intel-wired-lan-bounces@osuosl.org","Sender":"\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"},"content":"Only expose the counters currently available (bytes, packets); add\naccount for base stats to deal with ring clear.\n\nSigned-off-by: Paolo Abeni <pabeni@redhat.com>\n---\n drivers/net/ethernet/intel/i40e/i40e.h      |   7 ++\n drivers/net/ethernet/intel/i40e/i40e_main.c | 133 ++++++++++++++++++++\n 2 files changed, 140 insertions(+)","diff":"diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex dcb50c2e1aa2..fe642c464e9c 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -836,16 +836,23 @@ struct i40e_vsi {\n \tstruct i40e_eth_stats eth_stats;\n \tstruct i40e_eth_stats eth_stats_offsets;\n \tu64 tx_restart;\n+\tu64 tx_restart_base;\n \tu64 tx_busy;\n+\tu64 tx_busy_base;\n \tu64 tx_linearize;\n \tu64 tx_force_wb;\n \tu64 tx_stopped;\n+\tu64 tx_stopped_base;\n+\tu64 tx_bytes;\n+\tu64 tx_packets;\n \tu64 rx_buf_failed;\n \tu64 rx_page_failed;\n \tu64 rx_page_reuse;\n \tu64 rx_page_alloc;\n \tu64 rx_page_waive;\n \tu64 rx_page_busy;\n+\tu64 rx_bytes;\n+\tu64 rx_packets;\n \n \t/* These are containers of ring pointers, allocated at run-time */\n \tstruct i40e_ring **rx_rings;\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c\nindex 926d001b2150..0d0b3619ec56 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_main.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c\n@@ -7,6 +7,7 @@\n #include <linux/if_bridge.h>\n #include <linux/if_macvlan.h>\n #include <linux/module.h>\n+#include <net/netdev_queues.h>\n #include <net/pkt_cls.h>\n #include <net/xdp_sock_drv.h>\n \n@@ -11686,6 +11687,26 @@ static int i40e_vsi_clear(struct i40e_vsi *vsi)\n \treturn 0;\n }\n \n+static void i40e_vsi_aggregate_tx_counters(struct i40e_vsi *vsi,\n+\t\t\t\t\t   struct i40e_ring *tx_ring)\n+{\n+\tif (!tx_ring)\n+\t\treturn;\n+\n+\tvsi->tx_bytes += tx_ring->stats.bytes;\n+\tvsi->tx_packets += tx_ring->stats.packets;\n+}\n+\n+static void i40e_vsi_aggregate_rx_counters(struct i40e_vsi *vsi,\n+\t\t\t\t\t   struct i40e_ring *rx_ring)\n+{\n+\tif (!rx_ring)\n+\t\treturn;\n+\n+\tvsi->rx_bytes += rx_ring->stats.bytes;\n+\tvsi->rx_packets += rx_ring->stats.packets;\n+}\n+\n /**\n  * i40e_vsi_clear_rings - Deallocates the Rx and Tx rings for the provided VSI\n  * @vsi: the VSI being cleaned\n@@ -11696,6 +11717,13 @@ static void i40e_vsi_clear_rings(struct i40e_vsi *vsi)\n \n \tif (vsi->tx_rings && vsi->tx_rings[0]) {\n \t\tfor (i = 0; i < vsi->alloc_queue_pairs; i++) {\n+\t\t\tstruct i40e_ring *xdp_ring = vsi->xdp_rings ?\n+\t\t\t\t\t\t     vsi->xdp_rings[i] : NULL;\n+\n+\t\t\ti40e_vsi_aggregate_tx_counters(vsi, vsi->tx_rings[i]);\n+\t\t\ti40e_vsi_aggregate_tx_counters(vsi, xdp_ring);\n+\t\t\ti40e_vsi_aggregate_rx_counters(vsi, vsi->rx_rings[i]);\n+\n \t\t\tkfree_rcu(vsi->tx_rings[i], rcu);\n \t\t\tWRITE_ONCE(vsi->tx_rings[i], NULL);\n \t\t\tWRITE_ONCE(vsi->rx_rings[i], NULL);\n@@ -13625,6 +13653,110 @@ static const struct net_device_ops i40e_netdev_ops = {\n \t.ndo_hwtstamp_set\t= i40e_ptp_hwtstamp_set,\n };\n \n+static void i40e_get_queue_stats_rx(struct net_device *dev, int idx,\n+\t\t\t\t    struct netdev_queue_stats_rx *rx)\n+{\n+\tstruct i40e_netdev_priv *np = netdev_priv(dev);\n+\tstruct i40e_vsi *vsi = np->vsi;\n+\tstruct i40e_ring *rx_ring;\n+\tunsigned int start;\n+\tu64 bytes, packets;\n+\n+\trcu_read_lock();\n+\trx_ring = READ_ONCE(vsi->rx_rings[idx]);\n+\tif (!rx_ring)\n+\t\tgoto unlock;\n+\n+\tdo {\n+\t\tstart = u64_stats_fetch_begin(&rx_ring->syncp);\n+\t\tbytes = rx_ring->stats.bytes;\n+\t\tpackets = rx_ring->stats.packets;\n+\t} while (u64_stats_fetch_retry(&rx_ring->syncp, start));\n+\n+\trx->bytes = bytes;\n+\trx->packets = packets;\n+\n+unlock:\n+\trcu_read_unlock();\n+}\n+\n+static void i40e_zero_tx_ring_stats(struct netdev_queue_stats_tx *tx)\n+{\n+\ttx->bytes = 0;\n+\ttx->packets = 0;\n+\ttx->stop = 0;\n+\ttx->wake = 0;\n+\ttx->hw_drops = 0;\n+}\n+\n+static void i40e_add_tx_ring_stats(struct i40e_ring *tx_ring,\n+\t\t\t\t   struct netdev_queue_stats_tx *tx)\n+{\n+\tu64 bytes, packets;\n+\tunsigned int start;\n+\n+\tdo {\n+\t\tstart = u64_stats_fetch_begin(&tx_ring->syncp);\n+\t\tbytes = tx_ring->stats.bytes;\n+\t\tpackets = tx_ring->stats.packets;\n+\t} while (u64_stats_fetch_retry(&tx_ring->syncp, start));\n+\n+\ttx->bytes += bytes;\n+\ttx->packets += packets;\n+\n+\ttx->stop += tx_ring->tx_stats.tx_stopped;\n+\ttx->wake += tx_ring->tx_stats.restart_queue;\n+\ttx->hw_drops += tx_ring->tx_stats.tx_busy;\n+}\n+\n+static void i40e_get_queue_stats_tx(struct net_device *dev, int idx,\n+\t\t\t\t    struct netdev_queue_stats_tx *tx)\n+{\n+\tstruct i40e_netdev_priv *np = netdev_priv(dev);\n+\tstruct i40e_vsi *vsi = np->vsi;\n+\tstruct i40e_ring *tx_ring;\n+\n+\trcu_read_lock();\n+\ttx_ring = READ_ONCE(vsi->tx_rings[idx]);\n+\tif (!tx_ring)\n+\t\tgoto out;\n+\n+\ti40e_zero_tx_ring_stats(tx);\n+\ti40e_add_tx_ring_stats(tx_ring, tx);\n+\n+\tif (i40e_enabled_xdp_vsi(vsi)) {\n+\t\ttx_ring = READ_ONCE(vsi->xdp_rings[idx]);\n+\t\tif (tx_ring)\n+\t\t\ti40e_add_tx_ring_stats(tx_ring, tx);\n+\t}\n+\n+out:\n+\trcu_read_unlock();\n+}\n+\n+static void i40e_get_base_stats(struct net_device *dev,\n+\t\t\t\tstruct netdev_queue_stats_rx *rx,\n+\t\t\t\tstruct netdev_queue_stats_tx *tx)\n+{\n+\tstruct i40e_netdev_priv *np = netdev_priv(dev);\n+\tstruct i40e_vsi *vsi = np->vsi;\n+\n+\ttx->bytes = vsi->tx_bytes;\n+\ttx->packets = vsi->tx_packets;\n+\ttx->wake = vsi->tx_restart_base;\n+\ttx->stop = vsi->tx_stopped_base;\n+\ttx->hw_drops = vsi->tx_busy_base;\n+\n+\trx->bytes = vsi->rx_bytes;\n+\trx->packets = vsi->rx_packets;\n+}\n+\n+static const struct netdev_stat_ops i40e_stat_ops = {\n+\t.get_queue_stats_rx\t= i40e_get_queue_stats_rx,\n+\t.get_queue_stats_tx\t= i40e_get_queue_stats_tx,\n+\t.get_base_stats\t\t= i40e_get_base_stats,\n+};\n+\n /**\n  * i40e_config_netdev - Setup the netdev flags\n  * @vsi: the VSI being configured\n@@ -13787,6 +13919,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)\n \t/* Setup netdev TC information */\n \ti40e_vsi_config_netdev_tc(vsi, vsi->tc_config.enabled_tc);\n \n+\tnetdev->stat_ops = &i40e_stat_ops;\n \tnetdev->netdev_ops = &i40e_netdev_ops;\n \tnetdev->watchdog_timeo = 5 * HZ;\n \ti40e_set_ethtool_ops(netdev);\n","prefixes":["iwl-next","1/2"]}