Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp132501lqp; Thu, 4 Apr 2024 08:50:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuSO8lMElsae6+utBDYf4sY1SzYGPODDQ64OCkiM3bBfgg7WsZ7ssgedGgVV1ZKTlvDrSKdmXrDN8ebTS0km/n8MVGVzJ/pVbjrIsi9g== X-Google-Smtp-Source: AGHT+IHncPj2ZR1MQT4ITGtu/iafG6JmuGxtf7zgWZrPGvQt6CbgdGy1e2tUhdJJQ+OW6km3kXW0 X-Received: by 2002:a17:907:9729:b0:a46:94c7:49a5 with SMTP id jg41-20020a170907972900b00a4694c749a5mr2415412ejc.40.1712245815223; Thu, 04 Apr 2024 08:50:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712245815; cv=pass; d=google.com; s=arc-20160816; b=VPs+FIpxwIVLltv1QoO7Yrp3u3pVdqqvEhmyQlruWknVmP3m7zAhHTgP52MBM8ejMg tsSx2JXSInMr/F+6CkYlb26Ucsufb88JSi+gcvAReyLZXLrKqSI0D89cztIqDL3b0Ccj jJsUMX/poXN257nk0afzDn6c5I7HfToJwOu0lrpbds/SwlmMSAV93MnZWghTObImnMTu qtHYTCxv7nJu8dj6yAY/tdjs5eLb4FThe6GiX7k56wKgdEWUf2UlUxi2D8dcasT5zVSt pEXhBaEiv84cFqJAywU0nPOR3IsL0qwCsCa0cU2gGEMnEtroVHOS1QBtK3rnrInLWmO8 OI5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TWULREaDYd0GhQ+xj1jSHJEQCjdrCYSQBfrRSSrbhK4=; fh=B5gvjxB31ljWn9/oP8q8GGKyJ7/RnV7iry/PFi28Ayg=; b=crgXVTZxRrZHuUNSB8KNjYmN/rgyJUg74EV7FQGHYFKRCdovfwUT8NNusKY2Jmfabo JzxGlPAQEehKMrzDLCJND7ME0f1QU2Y7JAOJOfeAjXndmUC+ZJ1iLXlMTPB76RrSn3Mz ilJcwp8JZ5WWEx/clbkEIAfas552WMpEv18VlFUKkW8eTkRVIFpws2i/l7Avr7ZyTXt4 cFR5iPsTlmBvXwSHxt8nUvUzRqIlZDy1L7F1dTCIBk1WFwBrPBjFsanD8hg3DF+HIF23 F4zTrXh9EMTk4hNTfKfaIp552GsjXCoIZQHAML4hFUDpn09rvrl/ejiwdnqFcQlTiAMO 3Vnw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Oj3C3Ewi; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-131762-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k9-20020a17090632c900b00a474fe51f14si7932022ejk.696.2024.04.04.08.50.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 08:50:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131762-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Oj3C3Ewi; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-131762-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C68151F21D82 for ; Thu, 4 Apr 2024 15:50:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2856F12E1D3; Thu, 4 Apr 2024 15:46:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Oj3C3Ewi" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97B071353E3; Thu, 4 Apr 2024 15:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712245580; cv=none; b=Bttu5svn+49oTaLDibUdSfPdySwv+5fZv6F3EvB6wVZrJh3bkF4p7PgD0Uf46YDhGZYnEcsxUkJo035ofimKPn4bwEV99R/sbIxun+QuV6lf2obpQnFcgPokkhGBnC9j65eRYv5qbvcntGGHo/rr4jKXpa5CQ1aFJdJhtQuPZEw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712245580; c=relaxed/simple; bh=zVEgMieKOqlQ10EzIrZ/nTBJY74dbSjTG4wpdzvMuBc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X0VHXxrxyj503kvpxLB6xLpxl9t2QaYNNFdvjw7pHsidLr+Qk0cImsS1isqlHmMaPqafdznq5PlHLEcmQ8pRmGOZu3RdvoFyUpA/3xz7GoDRXewl1AbfCPHCx9NKbDB6G25kXf5K4BLzkv+r53jpnYw11OgI8UMh3NGQuT4/95s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Oj3C3Ewi; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712245579; x=1743781579; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zVEgMieKOqlQ10EzIrZ/nTBJY74dbSjTG4wpdzvMuBc=; b=Oj3C3Ewi8fjlcwpgiRNPBMSF7LQNgNK+QSwmSVyBapNSb1iwGN/nac0V QOYogmscx9untcsLvb7w3/jDZtA+aS1XaDtQo0uDZ0ErmHBDVcX5GLosp 7Czu1PcQeq/seUgVa4yKuL4uaoKRyIo8z179nI5HcyVBmbbDw4g2RO6J0 QF4OP4LwbgJ8g+TiOjn5UknOwYi/QMe4nuE296TJaUmtIodhePTUH50jS DEONl0YzYDtMExDi36EYjCGTEyZq1QJxCiUILThaCVEsjhOfwuHzacG7d f7YGOraAN373c1x4NNyDjcBqAs/w2yTg4ozjtha2iSSOztDM9CRn1yqi/ w==; X-CSE-ConnectionGUID: Oz3gAwOrTyaD8oXt/hNE7A== X-CSE-MsgGUID: G5ZF5ciES3u9Am2It0tvaA== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="11312272" X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="11312272" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2024 08:46:18 -0700 X-CSE-ConnectionGUID: GqwZ3y4WS0adSW3xkpnDgQ== X-CSE-MsgGUID: kipuvfN9ShqhUig8GjCFNg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="23288218" Received: from newjersey.igk.intel.com ([10.102.20.203]) by fmviesa005.fm.intel.com with ESMTP; 04 Apr 2024 08:46:14 -0700 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Alexander Duyck , Yunsheng Lin , Jesper Dangaard Brouer , Ilias Apalodimas , Christoph Lameter , Vlastimil Babka , Andrew Morton , nex.sw.ncis.osdt.itp.upstreaming@intel.com, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v9 8/9] iavf: pack iavf_ring more efficiently Date: Thu, 4 Apr 2024 17:44:01 +0200 Message-ID: <20240404154402.3581254-9-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404154402.3581254-1-aleksander.lobakin@intel.com> References: <20240404154402.3581254-1-aleksander.lobakin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.h | 22 +++------------------ drivers/net/ethernet/intel/iavf/iavf_txrx.c | 12 +++++------ 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.h b/drivers/net/ethernet/intel/iavf/iavf_txrx.h index e01777531635..ed559fa6f214 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.h +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.h @@ -227,7 +227,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; }; @@ -237,12 +236,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 */ @@ -264,10 +257,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. @@ -277,22 +268,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) @@ -306,6 +289,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 */ diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c index a14f7f211150..1a27fa613f6d 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c @@ -185,7 +185,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; } @@ -194,7 +194,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; } } @@ -320,7 +320,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 */ @@ -675,7 +675,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: @@ -1491,8 +1491,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 */ -- 2.44.0