From mboxrd@z Thu Jan 1 00:00:00 1970 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 smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62D5ECCFA09 for ; Tue, 4 Nov 2025 01:07:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3B1038141F; Tue, 4 Nov 2025 01:07:28 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id MH661T19zlKv; Tue, 4 Nov 2025 01:07:27 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8DEF881458 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1762218447; bh=orOXHZwhMfvIeulkmYb4LvM9CF9rPBwsXiU455cuHVE=; h=From:Date:References:In-Reply-To:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=nipFe2qcwVtxBH9/aEzUzY/ItUKEACjzJ3n8ZoE0DjbwgbpnjN9ShbqoqJ6TUtBXH aVIEuezbAkD3OpufXngBBEiKRusXhpr9ynbE2Ad7iP1Qc1dYac5Fhx6F4REAyZubD5 nyHIpvdXIAQ5wHcGxQYkdJFSlAR5tJeY9V7FtNbMkAKcqmpTfYs4suN3v+LyzgJaLv rzEkqQbYTdXkRGrxGJwbxdlohZmTD821753Q+GVB8/7Bvf808dqYYO3+u6PUWElp54 10m2eADpZyDVkF4SzGek8t0J1oV3EukZZYP4lsqHQvNV6BNxmGCZ5NlomfFOgV4LpT L3VCMsrY+AmoA== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 8DEF881458; Tue, 4 Nov 2025 01:07:27 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id 19E46222 for ; Tue, 4 Nov 2025 01:07:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 38DB98144D for ; Tue, 4 Nov 2025 01:07:22 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Q7RcpEfoYyWD for ; Tue, 4 Nov 2025 01:07:21 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=198.175.65.19; helo=mgamail.intel.com; envelope-from=jacob.e.keller@intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 7884F81447 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7884F81447 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7884F81447 for ; Tue, 4 Nov 2025 01:07:21 +0000 (UTC) X-CSE-ConnectionGUID: VTkw2g5yQDyYxZWUKUAUVQ== X-CSE-MsgGUID: NtPOj+LrSB+rcTSMv1+aFw== X-IronPort-AV: E=McAfee;i="6800,10657,11602"; a="64190640" X-IronPort-AV: E=Sophos;i="6.19,277,1754982000"; d="scan'208";a="64190640" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2025 17:07:19 -0800 X-CSE-ConnectionGUID: rPSFeoxLRSmbVz86gZoHuw== X-CSE-MsgGUID: czLgITI+TfGQLpaEwNZTsw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,277,1754982000"; d="scan'208";a="217828768" Received: from orcnseosdtjek.jf.intel.com (HELO [10.166.28.90]) ([10.166.28.90]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2025 17:07:16 -0800 From: Jacob Keller Date: Mon, 03 Nov 2025 17:06:51 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251103-jk-refactor-queue-stats-v1-6-164d2ed859b6@intel.com> References: <20251103-jk-refactor-queue-stats-v1-0-164d2ed859b6@intel.com> In-Reply-To: <20251103-jk-refactor-queue-stats-v1-0-164d2ed859b6@intel.com> To: Aleksandr Loktionov , Alexander Lobakin , Tony Nguyen , Przemek Kitszel Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, Jacob Keller X-Mailer: b4 0.15-dev-f4b34 X-Developer-Signature: v=1; a=openpgp-sha256; l=5182; i=jacob.e.keller@intel.com; h=from:subject:message-id; bh=ADMo9Qqo1+mGJUs7OYACRtvA0GchXlHUsWj5/HrWtnQ=; b=owGbwMvMwCWWNS3WLp9f4wXjabUkhkzOwIOPpHhYOyOOK/yxyXJly/wltvvhtstrt0zbdG3mp L+xEQ5yHaUsDGJcDLJiiiwKDiErrxtPCNN64ywHM4eVCWQIAxenAExk/VZGhmnVsbqSV1qu3BZe nmn567/p5YaZbzynT5qecI39Wl/yLT2Gf3Yn3j+NP9P07+iuO/qzS7pVSzuvBZg9m8pg/6XH9IX AekYA X-Developer-Key: i=jacob.e.keller@intel.com; a=openpgp; fpr=204054A9D73390562AEC431E6A965D3E6F0F28E8 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1762218441; x=1793754441; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=ADMo9Qqo1+mGJUs7OYACRtvA0GchXlHUsWj5/HrWtnQ=; b=O7X0M0lyrgvWG/RHHcN6BjqnW5kDcJ03bDV09XII6lxn3YSN/RJeCb8h mLi1rI2aSVvucFsum0J3UdC7U/vYYW7r+lMJmQHiVDz7zv23zxMWf7SQk 1RQVlHqyQ2rf/diRs9o4rivXfTCBNlS1wQ9bP2RodLu0gd2loupVNaJo7 awj+Y0iEDcpiieTbdqeCswyQ7isLKE4edGveRJZmVOcELvFhtizlaWV1d wbjhvn7hKuPnRNVNCSEUHm8M6XyxqWM16iY6nyXfKztQF23gVieASqY1v 1DlW8e0U7GNloAew9a1OTUq4SCzak/31n9KNwbhDixOKHTBZ/W85orhaI A==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=O7X0M0ly Subject: [Intel-wired-lan] [PATCH iwl-next 6/9] ice: remove ice_q_stats struct and use struct_group X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" The ice_qp_reset_stats function resets the stats for all rings on a VSI. It currently behaves differently for Tx and Rx rings. For Rx rings, it only clears the rx_stats which do not include the pkt and byte counts. For Tx rings and XDP rings, it clears only the pkt and byte counts. We could add extra memset calls to cover both the stats and relevant tx/rx stats fields. Instead, lets convert stats into a struct_group which contains both the pkts and bytes fields as well as the Tx or Rx stats, and remove the ice_q_stats structure entirely. The only remaining user of ice_q_stats is the ice_q_stats_len function in ice_ethtool.c, which just counts the number of fields. Replace this with a simple multiplication by 2. I find this to be simpler to reason about than relying on knowing the layout of the ice_q_stats structure. Now that the stats field of the ice_ring_stats covers all of the statistic values, the ice_qp_reset_stats function will properly zero out all of the fields. Signed-off-by: Jacob Keller --- drivers/net/ethernet/intel/ice/ice_txrx.h | 18 ++++++++---------- drivers/net/ethernet/intel/ice/ice_base.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_ethtool.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_lib.c | 7 ++++--- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.h b/drivers/net/ethernet/intel/ice/ice_txrx.h index f1fe1775baed..8586d5bebac7 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx.h +++ b/drivers/net/ethernet/intel/ice/ice_txrx.h @@ -129,11 +129,6 @@ struct ice_tx_offload_params { u8 header_len; }; -struct ice_q_stats { - u64 pkts; - u64 bytes; -}; - struct ice_txq_stats { u64 restart_q; u64 tx_busy; @@ -148,12 +143,15 @@ struct ice_rxq_stats { struct ice_ring_stats { struct rcu_head rcu; /* to avoid race on free */ - struct ice_q_stats stats; struct u64_stats_sync syncp; - union { - struct ice_txq_stats tx_stats; - struct ice_rxq_stats rx_stats; - }; + struct_group(stats, + u64 pkts; + u64 bytes; + union { + struct ice_txq_stats tx_stats; + struct ice_rxq_stats rx_stats; + }; + ); }; enum ice_ring_state_t { diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c index eadb1e3d12b3..afbff8aa9ceb 100644 --- a/drivers/net/ethernet/intel/ice/ice_base.c +++ b/drivers/net/ethernet/intel/ice/ice_base.c @@ -1414,8 +1414,8 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx) if (!vsi_stat) return; - memset(&vsi_stat->rx_ring_stats[q_idx]->rx_stats, 0, - sizeof(vsi_stat->rx_ring_stats[q_idx]->rx_stats)); + memset(&vsi_stat->rx_ring_stats[q_idx]->stats, 0, + sizeof(vsi_stat->rx_ring_stats[q_idx]->stats)); memset(&vsi_stat->tx_ring_stats[q_idx]->stats, 0, sizeof(vsi_stat->tx_ring_stats[q_idx]->stats)); if (vsi->xdp_rings) diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index a1d9abee97e5..0bc6f31a2b06 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -33,8 +33,8 @@ static int ice_q_stats_len(struct net_device *netdev) { struct ice_netdev_priv *np = netdev_priv(netdev); - return ((np->vsi->alloc_txq + np->vsi->alloc_rxq) * - (sizeof(struct ice_q_stats) / sizeof(u64))); + /* One packets and one bytes count per queue */ + return ((np->vsi->alloc_txq + np->vsi->alloc_rxq) * 2); } #define ICE_PF_STATS_LEN ARRAY_SIZE(ice_gstrings_pf_stats) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index e7265e877703..c6dd297582c1 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -3437,7 +3437,8 @@ int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc) * * This function assumes that caller has acquired a u64_stats_sync lock. */ -static void ice_update_ring_stats(struct ice_q_stats *stats, u64 pkts, u64 bytes) +static void ice_update_ring_stats(struct ice_ring_stats *stats, + u64 pkts, u64 bytes) { stats->bytes += bytes; stats->pkts += pkts; @@ -3452,7 +3453,7 @@ static void ice_update_ring_stats(struct ice_q_stats *stats, u64 pkts, u64 bytes void ice_update_tx_ring_stats(struct ice_tx_ring *tx_ring, u64 pkts, u64 bytes) { u64_stats_update_begin(&tx_ring->ring_stats->syncp); - ice_update_ring_stats(&tx_ring->ring_stats->stats, pkts, bytes); + ice_update_ring_stats(tx_ring->ring_stats, pkts, bytes); u64_stats_update_end(&tx_ring->ring_stats->syncp); } @@ -3465,7 +3466,7 @@ void ice_update_tx_ring_stats(struct ice_tx_ring *tx_ring, u64 pkts, u64 bytes) void ice_update_rx_ring_stats(struct ice_rx_ring *rx_ring, u64 pkts, u64 bytes) { u64_stats_update_begin(&rx_ring->ring_stats->syncp); - ice_update_ring_stats(&rx_ring->ring_stats->stats, pkts, bytes); + ice_update_ring_stats(rx_ring->ring_stats, pkts, bytes); u64_stats_update_end(&rx_ring->ring_stats->syncp); } -- 2.51.0.rc1.197.g6d975e95c9d7