Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1232175rdh; Fri, 24 Nov 2023 07:53:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbMXWULExnq4Zgf0/Bk0Il0ayZZGH7mWLN/7JVDpScCvyBfoC2xy1GaoHIbSG7DKABsZEW X-Received: by 2002:a05:6a00:1147:b0:6cb:42ac:9b69 with SMTP id b7-20020a056a00114700b006cb42ac9b69mr3696424pfm.25.1700841189664; Fri, 24 Nov 2023 07:53:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700841189; cv=none; d=google.com; s=arc-20160816; b=em3am9qgyUpGEReGT6x10ARONH6IUXEoKivbmoISbPMk0yokd4ycapTlsPhOdgTK+k F+xzxUB58/TrDasTsfHiaDJ8+d3hcjHzp0X9mkF4IInlgicTh8Hjwlge1mpvOefeRoht dGCDMwZg+HWaRRyxvVkLqH/22voRt7ND5b4G2IeQDyIIk9kqfkVvTiRsGBlAQDPw9Ovf i9cD8FKQ9XPT/XejHSiNfgei0tJB3/WTKOCptY+r5hINH13hT0kTixE38pJq43fYzFP6 FXeuV2B246Fh9oSU8GsbKa7hHe9TNzdt4B8IEIhd4HjNlIfsZlEXR9Aa9ZZIUKJwldRa SMmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jT4s30TeYlvn8p6JUX/KCC4gsgzj4m5bZ8ar+Wu2aec=; fh=QtEizEezWMPccSW0U8o1LFLT1SqErEb68UiNokAWV6o=; b=Wcll83ZXCE7RR8UGcXEEcP31/QE+QllerqOWqodSgk9qLl4QLSIBjIJAFcINdBWFKK LWf+eH42kRqxtOxQFSfafk7TByPQ0Dkyrjdrc3o/tp4mTV76kf3C5QAsVWUb1o2Beukw UxOmUcIwILxfpoNx/e2LG6bfk5NF8mcc0kNFbXsDBf+UJSUluf8GriVNziwlvrP+s+E/ y4SzO/kBWU3Q9/F2gKcY9LscRsHSNE1jG5YHaZlNVvpisU2Zsk9LQLV8tU3+B+MWYFXt BkKv6nqlfMGFbY/sVTSg26nkW6XypeMrxOEKYS3jzN/x/p5XAb7EnrTNOql5mIbvboX5 gaCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JZ+jNfEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id y23-20020aa79437000000b006cb90b336dcsi3651668pfo.267.2023.11.24.07.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 07:53:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JZ+jNfEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 74DB280859B7; Fri, 24 Nov 2023 07:52:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233150AbjKXPvS (ORCPT + 99 others); Fri, 24 Nov 2023 10:51:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346014AbjKXPug (ORCPT ); Fri, 24 Nov 2023 10:50:36 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A811D1BEB; Fri, 24 Nov 2023 07:50:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700841041; x=1732377041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vNhuJGk9a3rj9zylCAk6VpbxP2Sl8GFkRFLwLz92Y0w=; b=JZ+jNfEt4tiy/BuuPx3rKtcRBxxC3y843ZOwL/zUzDClN/Tb4Pn86ARy 14CK5WV94+eOrn7ZvpCTVm5uWBdsWJDOM1iwDNc2W4DyaR3+qxdzroLv9 1Oj/hsETwiDq/kytt5oOyXiqxSyPQzYSH3YzxM8UL+25TRCXVwXuJnMF+ aN6wNAmGk7Ri1MMWfLhYIhcBeoX2kuPVd9w9wo4EUJHL/uyPiVea4th4w 3w2HM868QCjjwHZQSgJfFNpuTjNN8uSGk/Y928m70DZsCafseg919NkSB 5+fZAzr+UxtXoXTrshyeDA4ZF7G61WKYqPOFWW74IElWF/+UB0Q7feLXR g==; X-IronPort-AV: E=McAfee;i="6600,9927,10904"; a="389592595" X-IronPort-AV: E=Sophos;i="6.04,224,1695711600"; d="scan'208";a="389592595" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2023 07:50:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,224,1695711600"; d="scan'208";a="15660278" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa001.jf.intel.com with ESMTP; 24 Nov 2023 07:50:38 -0800 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Maciej Fijalkowski , Michal Kubiak , Larysa Zaremba , Alexander Duyck , Yunsheng Lin , David Christensen , Jesper Dangaard Brouer , Ilias Apalodimas , Paul Menzel , netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v5 10/14] iavf: pack iavf_ring more efficiently Date: Fri, 24 Nov 2023 16:47:28 +0100 Message-ID: <20231124154732.1623518-11-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231124154732.1623518-1-aleksander.lobakin@intel.com> References: <20231124154732.1623518-1-aleksander.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 24 Nov 2023 07:52:23 -0800 (PST) Before replacing the Rx buffer management with libie, clean up &iavf_ring a bit. There are several fields not used anywhere in the code -- simply remove them. Move ::tail up to remove a hole. Replace ::arm_wb boolean with 1-bit flag in ::flags to free 1 more byte. Finally, move ::prev_pkt_ctr out of &iavf_tx_queue_stats -- it doesn't belong there (used for Tx stall detection). Place it next to the stats on the ring itself to fill the 4-byte slot. The result: no holes and all the hot fields fit into the first 64-byte cacheline. Signed-off-by: Alexander Lobakin --- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 12 +++++------ drivers/net/ethernet/intel/iavf/iavf_txrx.h | 22 +++------------------ 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c index 665ee1feb877..62f976d322ab 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c @@ -184,7 +184,7 @@ void iavf_detect_recover_hung(struct iavf_vsi *vsi) * pending work. */ packets = tx_ring->stats.packets & INT_MAX; - if (tx_ring->tx_stats.prev_pkt_ctr == packets) { + if (tx_ring->prev_pkt_ctr == packets) { iavf_force_wb(vsi, tx_ring->q_vector); continue; } @@ -193,7 +193,7 @@ void iavf_detect_recover_hung(struct iavf_vsi *vsi) * to iavf_get_tx_pending() */ smp_rmb(); - tx_ring->tx_stats.prev_pkt_ctr = + tx_ring->prev_pkt_ctr = iavf_get_tx_pending(tx_ring, true) ? packets : -1; } } @@ -319,7 +319,7 @@ static bool iavf_clean_tx_irq(struct iavf_vsi *vsi, ((j / WB_STRIDE) == 0) && (j > 0) && !test_bit(__IAVF_VSI_DOWN, vsi->state) && (IAVF_DESC_UNUSED(tx_ring) != tx_ring->count)) - tx_ring->arm_wb = true; + tx_ring->flags |= IAVF_TXR_FLAGS_ARM_WB; } /* notify netdev of completed buffers */ @@ -674,7 +674,7 @@ int iavf_setup_tx_descriptors(struct iavf_ring *tx_ring) tx_ring->next_to_use = 0; tx_ring->next_to_clean = 0; - tx_ring->tx_stats.prev_pkt_ctr = -1; + tx_ring->prev_pkt_ctr = -1; return 0; err: @@ -1494,8 +1494,8 @@ int iavf_napi_poll(struct napi_struct *napi, int budget) clean_complete = false; continue; } - arm_wb |= ring->arm_wb; - ring->arm_wb = false; + arm_wb |= !!(ring->flags & IAVF_TXR_FLAGS_ARM_WB); + ring->flags &= ~IAVF_TXR_FLAGS_ARM_WB; } /* Handle case where we are called by netpoll with a budget of 0 */ diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.h b/drivers/net/ethernet/intel/iavf/iavf_txrx.h index 720bca0e6716..9b8154c5f4fb 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.h +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.h @@ -228,7 +228,6 @@ struct iavf_tx_queue_stats { u64 tx_done_old; u64 tx_linearize; u64 tx_force_wb; - int prev_pkt_ctr; u64 tx_lost_interrupt; }; @@ -238,12 +237,6 @@ struct iavf_rx_queue_stats { u64 alloc_buff_failed; }; -enum iavf_ring_state_t { - __IAVF_TX_FDIR_INIT_DONE, - __IAVF_TX_XPS_INIT_DONE, - __IAVF_RING_STATE_NBITS /* must be last */ -}; - /* some useful defines for virtchannel interface, which * is the only remaining user of header split */ @@ -265,10 +258,8 @@ struct iavf_ring { struct iavf_tx_buffer *tx_bi; struct iavf_rx_buffer *rx_bi; }; - DECLARE_BITMAP(state, __IAVF_RING_STATE_NBITS); - u16 queue_index; /* Queue number of ring */ - u8 dcb_tc; /* Traffic class of ring */ u8 __iomem *tail; + u16 queue_index; /* Queue number of ring */ /* high bit set means dynamic, use accessors routines to read/write. * hardware only supports 2us resolution for the ITR registers. @@ -278,22 +269,14 @@ struct iavf_ring { u16 itr_setting; u16 count; /* Number of descriptors */ - u16 reg_idx; /* HW register index of the ring */ /* used in interrupt processing */ u16 next_to_use; u16 next_to_clean; - u8 atr_sample_rate; - u8 atr_count; - - bool ring_active; /* is ring online or not */ - bool arm_wb; /* do something to arm write back */ - u8 packet_stride; - u16 flags; #define IAVF_TXR_FLAGS_WB_ON_ITR BIT(0) -/* BIT(1) is free, was IAVF_RXR_FLAGS_BUILD_SKB_ENABLED */ +#define IAVF_TXR_FLAGS_ARM_WB BIT(1) /* BIT(2) is free */ #define IAVF_TXRX_FLAGS_VLAN_TAG_LOC_L2TAG1 BIT(3) #define IAVF_TXR_FLAGS_VLAN_TAG_LOC_L2TAG2 BIT(4) @@ -307,6 +290,7 @@ struct iavf_ring { struct iavf_rx_queue_stats rx_stats; }; + int prev_pkt_ctr; /* For Tx stall detection */ unsigned int size; /* length of descriptor ring in bytes */ dma_addr_t dma; /* physical address of ring */ -- 2.42.0