From patchwork Fri Apr 18 16:38:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 14057501 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 55C89C369AB for ; Fri, 18 Apr 2025 16:59:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nVv/TY3Il5DScahsJh76vQZ+rQ+Fbt8axpnBJApzBb4=; b=IJwT7+oaiw5V6ofePbFObMNI+h Q1CRMYNK+uvwkmH+ULvuJgy0m+6pPRtRNe2Wq0Qj6qcTx92r0ygteplRCVrU5GySAM5ciwvKIaKVu jn89Rw+5QpspZQi3gdtgCb3u+oeL4jeUPggx85TdBoTSQgZRQDuUvZYt/wwCYVRNE4LTqb6DPa4GX Lvxsx4yIrVsgh5GvXoViiDYBU1cUMHtj2a1dEMMANF2/AOCMf/ClE5ba5d7LxEu+NCwUjIR+/6+31 K4nxpDPa+/S++Ft5vsCorrc3mFlh328fE3sL5HdTyzKcKWRfnMfjlJBtyqKjJl6GgGYjMAg1yNAKf P4yoNcCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u5p3B-0000000H7JQ-3ZKU; Fri, 18 Apr 2025 16:58:49 +0000 Received: from mgamail.intel.com ([192.198.163.12]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1u5ojg-0000000Gygf-1TjD for linux-arm-kernel@lists.infradead.org; Fri, 18 Apr 2025 16:38:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744994320; x=1776530320; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y+sPxnK4agLH0GHm8BwfzRpkrP/ygcap9LC/O3MI0PA=; b=lIDjX2/vApEo6B1y7hwr10trI5UVpwjrKow9kVxGSLaDPhpsOdm4Fd6B CHPX0kSf1AqpkZ1RxI3dnAhX+jin901jHnAnzLBhGjSlKAksn6sV/rhn6 xkENHxDrIbqHXcZeh7X2DXy/6CP5ZmuVySBbvFXbFlxW4tQ2WbtLnEP8F U15a811bbWBFw/Ujt+X3OneTRY/f2dHc1mneeigy2FfjTQksY8NfUjo+D uy54zWWBtRIvqGhSZ69SU6It/WojkAar9yGkUTeg9GUc7lrSMfU2rhp1Q pB2UKJnaEduP9Y8KZWwADG4ZtIsi3nBqrWxN34qcWIbT/IFJYfKUpDdDs w==; X-CSE-ConnectionGUID: Kydvzjy6TnW9AaQ0tyIgRg== X-CSE-MsgGUID: HrREXxLvRcCZnq5l8X7UaQ== X-IronPort-AV: E=McAfee;i="6700,10204,11407"; a="50454432" X-IronPort-AV: E=Sophos;i="6.15,222,1739865600"; d="scan'208";a="50454432" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2025 09:38:36 -0700 X-CSE-ConnectionGUID: 96tB1Qk/SJi1/Yk4zAg7ZA== X-CSE-MsgGUID: +SmQEmMKQgCrp+hp4oK3Eg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,222,1739865600"; d="scan'208";a="130892281" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orviesa009.jf.intel.com with ESMTP; 18 Apr 2025 09:38:36 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, andrew+netdev@lunn.ch, netdev@vger.kernel.org Cc: Faizal Rahim , anthony.l.nguyen@intel.com, vinicius.gomes@intel.com, vitaly.lifshits@intel.com, dima.ruinskiy@intel.com, przemyslaw.kitszel@intel.com, chwee.lin.choong@intel.com, yong.liang.choong@linux.intel.com, vladimir.oltean@nxp.com, horms@kernel.org, linux@armlinux.org.uk, xiaolei.wang@windriver.com, hayashi.kunihiko@socionext.com, ast@kernel.org, jesper.nilsson@axis.com, mcoquelin.stm32@gmail.com, rmk+kernel@armlinux.org.uk, fancer.lancer@gmail.com, kory.maincent@bootlin.com, linux-stm32@st-md-mailman.stormreply.com, hkelam@marvell.com, alexandre.torgue@foss.st.com, daniel@iogearbox.net, linux-arm-kernel@lists.infradead.org, hawk@kernel.org, quic_jsuraj@quicinc.com, gal@nvidia.com, john.fastabend@gmail.com, 0x1207@gmail.com, bpf@vger.kernel.org, Mor Bar-Gabay Subject: [PATCH net-next 09/14] igc: set the RX packet buffer size for TSN mode Date: Fri, 18 Apr 2025 09:38:15 -0700 Message-ID: <20250418163822.3519810-10-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250418163822.3519810-1-anthony.l.nguyen@intel.com> References: <20250418163822.3519810-1-anthony.l.nguyen@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250418_093840_416566_33F3E210 X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Faizal Rahim In preparation for supporting frame preemption, when entering TSN mode, set the receive packet buffer to 15KB for the Express MAC, 15KB for the Preemptible MAC and 2KB for the BMC. References: I225/I226 SW User Manual, Section 4.7.9, Section 7.1.3.2, Section 8.3.1 The newly introduced macros follow the naming from the i226 SW User Manual for easy reference. Co-developed-by: Vinicius Costa Gomes Signed-off-by: Vinicius Costa Gomes Signed-off-by: Faizal Rahim Tested-by: Mor Bar-Gabay Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/igc/igc_defines.h | 5 ++++ drivers/net/ethernet/intel/igc/igc_tsn.c | 27 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h b/drivers/net/ethernet/intel/igc/igc_defines.h index 12a16a7acb03..86abd3bafb37 100644 --- a/drivers/net/ethernet/intel/igc/igc_defines.h +++ b/drivers/net/ethernet/intel/igc/igc_defines.h @@ -399,17 +399,22 @@ /* Mask for RX packet buffer size */ #define IGC_RXPBSIZE_EXP_MASK GENMASK(5, 0) #define IGC_BMC2OSPBSIZE_MASK GENMASK(11, 6) +#define IGC_RXPBSIZE_BE_MASK GENMASK(17, 12) /* Mask for timestamp in RX buffer */ #define IGC_RXPBS_CFG_TS_EN_MASK GENMASK(31, 31) /* High-priority RX packet buffer size (KB). Used for Express traffic when preemption is enabled */ #define IGC_RXPBSIZE_EXP(x) FIELD_PREP(IGC_RXPBSIZE_EXP_MASK, (x)) /* BMC to OS packet buffer size in KB */ #define IGC_BMC2OSPBSIZE(x) FIELD_PREP(IGC_BMC2OSPBSIZE_MASK, (x)) +/* Low-priority RX packet buffer size (KB). Used for BE traffic when preemption is enabled */ +#define IGC_RXPBSIZE_BE(x) FIELD_PREP(IGC_RXPBSIZE_BE_MASK, (x)) /* Enable RX packet buffer for timestamp descriptor, saving 16 bytes per packet if set */ #define IGC_RXPBS_CFG_TS_EN FIELD_PREP(IGC_RXPBS_CFG_TS_EN_MASK, 1) /* Default value following I225/I226 SW User Manual Section 8.3.1 */ #define IGC_RXPBSIZE_EXP_BMC_DEFAULT ( \ IGC_RXPBSIZE_EXP(34) | IGC_BMC2OSPBSIZE(2)) +#define IGC_RXPBSIZE_EXP_BMC_BE_TSN ( \ + IGC_RXPBSIZE_EXP(15) | IGC_BMC2OSPBSIZE(2) | IGC_RXPBSIZE_BE(15)) /* Mask for TX packet buffer size */ #define IGC_TXPB0SIZE_MASK GENMASK(5, 0) diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c b/drivers/net/ethernet/intel/igc/igc_tsn.c index 498741d83ca6..2254f255cc3b 100644 --- a/drivers/net/ethernet/intel/igc/igc_tsn.c +++ b/drivers/net/ethernet/intel/igc/igc_tsn.c @@ -125,6 +125,29 @@ static void igc_tsn_tx_arb(struct igc_adapter *adapter, u16 *queue_per_tc) wr32(IGC_TXARB, txarb); } +/** + * igc_tsn_set_rxpbsize - Set the receive packet buffer size + * @adapter: Pointer to the igc_adapter structure + * @rxpbs_exp_bmc_be: Value to set the receive packet buffer size, including + * express buffer, BMC buffer, and Best Effort buffer + * + * The IGC_RXPBS register value may include allocations for the Express buffer, + * BMC buffer, Best Effort buffer, and the timestamp descriptor buffer + * (IGC_RXPBS_CFG_TS_EN). + */ +static void igc_tsn_set_rxpbsize(struct igc_adapter *adapter, + u32 rxpbs_exp_bmc_be) +{ + struct igc_hw *hw = &adapter->hw; + u32 rxpbs = rd32(IGC_RXPBS); + + rxpbs &= ~(IGC_RXPBSIZE_EXP_MASK | IGC_BMC2OSPBSIZE_MASK | + IGC_RXPBSIZE_BE_MASK); + rxpbs |= rxpbs_exp_bmc_be; + + wr32(IGC_RXPBS, rxpbs); +} + /* Returns the TSN specific registers to their default values after * the adapter is reset. */ @@ -139,6 +162,8 @@ static int igc_tsn_disable_offload(struct igc_adapter *adapter) wr32(IGC_TXPBS, IGC_TXPBSIZE_DEFAULT); wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_DEFAULT); + igc_tsn_set_rxpbsize(adapter, IGC_RXPBSIZE_EXP_BMC_DEFAULT); + if (igc_is_device_id_i226(hw)) igc_tsn_restore_retx_default(adapter); @@ -202,6 +227,8 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter) wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_TSN); wr32(IGC_TXPBS, IGC_TXPBSIZE_TSN); + igc_tsn_set_rxpbsize(adapter, IGC_RXPBSIZE_EXP_BMC_BE_TSN); + if (igc_is_device_id_i226(hw)) igc_tsn_set_retx_qbvfullthreshold(adapter);