From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 3265632937A; Thu, 24 Sep 2026 19:57:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279837; cv=none; b=l01jcqep6bsDoWF8NaLz50JZvOP21SA6RnhUQVTaSjyzXKgiO0waLP6MCTq98bnMtChDxcbjCEvO4nHRYrrzMh4BXqX/UQHaX9FwVfx6SJQEEi+PN09xVW6u6r8VbTTG/6zWanDZip/tfT9UOlNanZW+Ba9EXFEBwLCsAUd0oIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279837; c=relaxed/simple; bh=Gn2TaEmSIG+/lBYc0ldYI+V/SltKbL/jrsFeLOUFEck=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=uorSGrpyKCPZRtths/HmGS9odCodccCaJE5Fp3vBC9UznrIXaGp3DqqWZY5BZkXQp/AGZWEzbpvpbSVkheLB+1aUZzR3Qr4BX86KmJ9Sv7MbZdwJ/IIZI9QBg2784J4FCNxN8xykOq5+v82vfCN8j+Bcgd5UdaELQ8MkGYH4H3o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=Vej73FJo; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="Vej73FJo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279832; x=1821815832; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Gn2TaEmSIG+/lBYc0ldYI+V/SltKbL/jrsFeLOUFEck=; b=Vej73FJosCuxJmFLKpA2ZjDUG/UGxWSxTS1L5uPbg1MEBr9SWLjqlHrG 9bJyQh0bE546DqlzazKHu63qj7x23VKkrcIlT/Q1X8UQdn3edHX9g1yD+ y9+pBFE8BHfPa4eLvyLSnSvI6Dpmzp3tSZanK6NLNzCXFFKY7wxl/W6++ 3a15ckpewExd072RgkJMj44PCELRM4TV+6BV0/8rfCeLzsv3BJdJ1xvKo igVzClmf/l2jOsBFwEXiKc6Z9ewshyBh4EYM+WVz5rB7ICGENY1m1CSv1 8wGiWD2OCkh/Km1XBRGLAZpiNPHt7W/JFrI1bx/iq3J5bDamhsP05Xz91 g==; X-CSE-ConnectionGUID: dt19c12VQ8e4I6MEbc3qBA== X-CSE-MsgGUID: GAV2M1Q1SI6YQ7IauS2mwg== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="64420627" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:57:06 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:57:05 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:01 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:49 +0200 Subject: [PATCH net-next v8 01/15] MAINTAINERS: add FDMA library to Sparx5 SoC entry Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-1-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 The FDMA library under drivers/net/ethernet/microchip/fdma/ is shared by the lan966x, sparx5 and lan969x drivers, but is not covered by an entry in the MAINTAINERS file. A subsequent patch will add new files to the FDMA library, so let's make sure it's covered. Add drivers/net/ethernet/microchip/fdma/ to the Sparx5 SoC entry, since I am already listed there. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index e3ce77c839b0..e5da9d0378b6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3214,6 +3214,7 @@ M: UNGLinuxDriver@microchip.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Supported F: arch/arm64/boot/dts/microchip/sparx* +F: drivers/net/ethernet/microchip/fdma/ F: drivers/net/ethernet/microchip/vcap/ F: drivers/pinctrl/pinctrl-microchip-sgpio.c N: sparx5 --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 99BF74B270F; Thu, 24 Sep 2026 19:57:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279840; cv=none; b=K7fbC9p/WQMGfJ05fbqQEffzbol0yEzEzI5MH3tSk8XU/k1bvKLSG+p4cTmK7FV/X9nX0CBuKgO+MPH1sdQnr+q33TGPBpVX2iUu3Ao/UQthx/gqvMPV2PIuZnD8QoIrXFvd2NtnpfI7aXZ2Gj21ncx2mjP2SJEkrXUk2ivCtt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279840; c=relaxed/simple; bh=d+JKpOCaVjCO+56ImP8WkKP2l/kS85jXgylLfub1kPQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=JGG8om/FkcfvfmeYx1fBBBDTogPI6Hgl7d1VYKHYBX5Vh/sqNK25kLimmocb3FR4rxBJdrhFm1XEoIzkGmPqolbaUcVj2T/79bNAEYPGJ6fpp2RGW2VEum8ny7EgHIe3v1m91sFUt1w5g0E952XC787NHbFOtnzm2DXMbx4sB+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=piKm5/Mi; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="piKm5/Mi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279834; x=1821815834; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=d+JKpOCaVjCO+56ImP8WkKP2l/kS85jXgylLfub1kPQ=; b=piKm5/Mi4mHJL96LlXTwPToAl+7fOuQ9kYQYE5wWU7BOo71q19lcLf/l RAb57wg6Q7LnSD+551O+WQm53KymFsChZB5KYWmIyIEqUqdgcqQUKsHKQ EWJEolS8C/rmU0Jxwp5Mo5Ipf14qCvZpoya9XsXas5DZKv4f7gN6aWlyC +549x2iTirgqBO7CNuan7OOemyzgZ7UxEUMJHdxXeFt8djTXWekmpwCNK 5KLD5m0s0+dxrvNLZ5Y7jxtkhCEKImV+o0YmncwK5UgizNXJ1L8DKAWT6 FlCINwwuKtZSdSd5MtGVscGCgSFxC8R3jFoiuep2UwqHgeP0F0+FyuTXz A==; X-CSE-ConnectionGUID: mv94WYDzQsyIfuwttj5qaw== X-CSE-MsgGUID: 4vw4Z76URg6UfLFBnblEAQ== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="63176278" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 12:57:10 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex2.mchp-main.com (10.10.87.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.49; Thu, 24 Sep 2026 12:57:10 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:05 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:50 +0200 Subject: [PATCH net-next v8 02/15] net: microchip: fdma: rename contiguous dataptr helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-2-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 When the FDMA library was introduced [1], two helpers to get the DMA and virtual address of a data buffer, in contiguous memory, were added. These helpers have had no callers until this series. I found the naming I initially used confusing and inconsistent. Rename fdma_dataptr_get_contiguous() and fdma_dataptr_virt_get_contiguous() to fdma_dataptr_dma_addr_contiguous() and fdma_dataptr_virt_addr_contiguous(). This makes the pair symmetric and clarifies what type of address each returns. [1]: commit 30e48a75df9c ("net: microchip: add FDMA library") Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- drivers/net/ethernet/microchip/fdma/fdma_api.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/microchip/fdma/fdma_api.h b/drivers/net/e= thernet/microchip/fdma/fdma_api.h index d91affe8bd98..dea8e3cc155a 100644 --- a/drivers/net/ethernet/microchip/fdma/fdma_api.h +++ b/drivers/net/ethernet/microchip/fdma/fdma_api.h @@ -197,8 +197,8 @@ static inline int fdma_nextptr_cb(struct fdma *fdma, in= t dcb_idx, u64 *nextptr) * if the dataptr addresses and DCB's are in contiguous memory and the dri= ver * supports XDP. */ -static inline u64 fdma_dataptr_get_contiguous(struct fdma *fdma, int dcb_i= dx, - int db_idx) +static inline u64 fdma_dataptr_dma_addr_contiguous(struct fdma *fdma, + int dcb_idx, int db_idx) { return fdma->dma + (sizeof(struct fdma_dcb) * fdma->n_dcbs) + (dcb_idx * fdma->n_dbs + db_idx) * fdma->db_size + @@ -209,8 +209,8 @@ static inline u64 fdma_dataptr_get_contiguous(struct fd= ma *fdma, int dcb_idx, * applicable if the dataptr addresses and DCB's are in contiguous memory = and * the driver supports XDP. */ -static inline void *fdma_dataptr_virt_get_contiguous(struct fdma *fdma, - int dcb_idx, int db_idx) +static inline void *fdma_dataptr_virt_addr_contiguous(struct fdma *fdma, + int dcb_idx, int db_idx) { return (u8 *)fdma->dcbs + (sizeof(struct fdma_dcb) * fdma->n_dcbs) + (dcb_idx * fdma->n_dbs + db_idx) * fdma->db_size + --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 B508C42E42F; Thu, 24 Sep 2026 19:57:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279844; cv=none; b=IY8uJ57dv+fM/tzulJKeXBQyYHkUVuFVbwa+EIOSU7Gco3OhhijmTWqKqNi47edf2wHp4GKqQg+itapjJHltFujgFDh2RYHavz23qX7Qve8NmSu7+souMZtjM25M+IqwcNp+RL8kNpRocK9eTJP+XVUFTPhKVKjoNbZuvB7s7+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279844; c=relaxed/simple; bh=eWXDxvjo1b40Oaa4SLtuLOQS21zoSGBx8A9HWDSwW9M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=kUXg5o2Rb1T89VPT1pWNM3nsasQ8yMaK1yNiLX0Lqwox6u+dWrFe0AVEzvhpGqcS+xZK2N7iYbjfr84jEquRAiqydvNIi8wWZk06pI8ZBQND8dnGdwpfIKKDuDbbvKpc9sUAE4+E9zCua3R82xLTU4jJ6ug6KwsPa+6P67knqvo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=rAt8Xa05; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="rAt8Xa05" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279839; x=1821815839; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=eWXDxvjo1b40Oaa4SLtuLOQS21zoSGBx8A9HWDSwW9M=; b=rAt8Xa05LjikKNc+tfpgroR4MnmNXGp+QKAPlh3sdqXJsDSPwf5S6//p GDEieA3oBGupHjCkQLSI9X3uNUATA//hp0Ahbs1rK7ZI1pZSaavAFBKDb 6dLya5P4ZyZfueVTYsinK7/tHQbyJlchpGzAQZ5BOnXbrKXInUBT2nFgF a+a039btKRR+n79Wf1cIda/bWHJ0JIwA28O4v3ylpecRfTIbq0F09HDVH 2bVkiC2YglwA17RNs8Gt4ih0cebxS5G9/9+brSgjx+d0DJ+7WO6s/PQrU 6Ia9lZZ2CJ84/ySIUFBVNkqqnY2XY3w8pHxWqruy1i7UPoZSRghin6JGE w==; X-CSE-ConnectionGUID: BO+XYviMQOmTA54m9chmgA== X-CSE-MsgGUID: USQ1WD8gRUWeXaLTbfQ9Nw== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="231239474" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:57:14 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:57:14 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:10 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:51 +0200 Subject: [PATCH net-next v8 03/15] net: microchip: fdma: add PCIe ATU support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-3-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 When lan966x or lan969x operates as a PCIe endpoint, the internal FDMA engine cannot directly access host memory. Instead, DMA addresses must be translated through the PCIe Address Translation Unit (ATU). The ATU provides outbound windows that map internal addresses to PCIe bus addresses. The ATU outbound address space (0x10000000-0x1fffffff) is divided into six equally-sized regions (~42MB each). When FDMA buffers are allocated, a free ATU region is claimed and programmed with the DMA target address. The FDMA engine then uses the region's base address in its descriptors, and the ATU translates these to the actual DMA addresses on the PCIe bus. Add the required functions and helpers that combine the DMA allocation with the ATU region mapping. These are used by the lan966x PCIe FDMA path. The ATU cannot express a limit finer than its 64KB region granularity, so pad the mapped allocation to that boundary; otherwise the outbound window would extend past the memory the host allocated for DMA. This implementation will also be used by the lan969x, when PCIe FDMA is added for that platform in the future. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- drivers/net/ethernet/microchip/fdma/Makefile | 4 + drivers/net/ethernet/microchip/fdma/fdma_api.c | 44 ++++++ drivers/net/ethernet/microchip/fdma/fdma_api.h | 14 ++ drivers/net/ethernet/microchip/fdma/fdma_pci.c | 208 +++++++++++++++++++++= ++++ drivers/net/ethernet/microchip/fdma/fdma_pci.h | 57 +++++++ 5 files changed, 327 insertions(+) diff --git a/drivers/net/ethernet/microchip/fdma/Makefile b/drivers/net/eth= ernet/microchip/fdma/Makefile index cc9a736be357..910a10b33fb9 100644 --- a/drivers/net/ethernet/microchip/fdma/Makefile +++ b/drivers/net/ethernet/microchip/fdma/Makefile @@ -5,3 +5,7 @@ =20 obj-$(CONFIG_FDMA) +=3D fdma.o fdma-y +=3D fdma_api.o + +ifneq ($(CONFIG_MCHP_LAN966X_PCI),) +fdma-y +=3D fdma_pci.o +endif diff --git a/drivers/net/ethernet/microchip/fdma/fdma_api.c b/drivers/net/e= thernet/microchip/fdma/fdma_api.c index e78c3590da9e..a3c9e3097c5c 100644 --- a/drivers/net/ethernet/microchip/fdma/fdma_api.c +++ b/drivers/net/ethernet/microchip/fdma/fdma_api.c @@ -127,6 +127,50 @@ void fdma_free_phys(struct fdma *fdma) } EXPORT_SYMBOL_GPL(fdma_free_phys); =20 +#if IS_ENABLED(CONFIG_MCHP_LAN966X_PCI) +/* Allocate coherent DMA memory and map it in the ATU. */ +int fdma_alloc_coherent_and_map(struct device *dev, struct fdma *fdma, + struct fdma_pci_atu *atu) +{ + struct fdma_pci_atu_region *region; + int err; + + if (WARN_ON(fdma->atu_region)) + return -EBUSY; + + /* The ATU cannot express a limit finer than the region granularity, so + * the hardware widens the programmed limit to that boundary. Pad the + * allocation to match, or the outbound window would extend past the + * memory we own. + */ + fdma->size =3D ALIGN(fdma->size, FDMA_PCI_ATU_REGION_ALIGN); + + err =3D fdma_alloc_coherent(dev, fdma); + if (err) + return err; + + region =3D fdma_pci_atu_region_map(atu, fdma->dma, fdma->size); + if (IS_ERR(region)) { + fdma_free_coherent(dev, fdma); + return PTR_ERR(region); + } + + fdma->atu_region =3D region; + + return 0; +} +EXPORT_SYMBOL_GPL(fdma_alloc_coherent_and_map); + +/* Free coherent DMA memory and unmap the memory in the ATU. */ +void fdma_free_coherent_and_unmap(struct device *dev, struct fdma *fdma) +{ + fdma_pci_atu_region_unmap(fdma->atu_region); + fdma->atu_region =3D NULL; + fdma_free_coherent(dev, fdma); +} +EXPORT_SYMBOL_GPL(fdma_free_coherent_and_unmap); +#endif + /* Get the size of the FDMA memory */ u32 fdma_get_size(struct fdma *fdma) { diff --git a/drivers/net/ethernet/microchip/fdma/fdma_api.h b/drivers/net/e= thernet/microchip/fdma/fdma_api.h index dea8e3cc155a..ccc30d506e89 100644 --- a/drivers/net/ethernet/microchip/fdma/fdma_api.h +++ b/drivers/net/ethernet/microchip/fdma/fdma_api.h @@ -7,6 +7,8 @@ #include #include =20 +#include "fdma_pci.h" + /* This provides a common set of functions and data structures for interac= ting * with the Frame DMA engine on multiple Microchip switchcores. * @@ -109,6 +111,11 @@ struct fdma { u32 channel_id; =20 struct fdma_ops ops; + +#if IS_ENABLED(CONFIG_MCHP_LAN966X_PCI) + /* PCI ATU region for this FDMA instance. */ + struct fdma_pci_atu_region *atu_region; +#endif }; =20 /* Advance the DCB index and wrap if required. */ @@ -233,9 +240,16 @@ int __fdma_dcb_add(struct fdma *fdma, int dcb_idx, u64= info, u64 status, =20 int fdma_alloc_coherent(struct device *dev, struct fdma *fdma); int fdma_alloc_phys(struct fdma *fdma); +#if IS_ENABLED(CONFIG_MCHP_LAN966X_PCI) +int fdma_alloc_coherent_and_map(struct device *dev, struct fdma *fdma, + struct fdma_pci_atu *atu); +#endif =20 void fdma_free_coherent(struct device *dev, struct fdma *fdma); void fdma_free_phys(struct fdma *fdma); +#if IS_ENABLED(CONFIG_MCHP_LAN966X_PCI) +void fdma_free_coherent_and_unmap(struct device *dev, struct fdma *fdma); +#endif =20 u32 fdma_get_size(struct fdma *fdma); u32 fdma_get_size_contiguous(struct fdma *fdma); diff --git a/drivers/net/ethernet/microchip/fdma/fdma_pci.c b/drivers/net/e= thernet/microchip/fdma/fdma_pci.c new file mode 100644 index 000000000000..dd1dc46cbc9d --- /dev/null +++ b/drivers/net/ethernet/microchip/fdma/fdma_pci.c @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include +#include +#include + +#include "fdma_pci.h" + +/* When the switch operates as a PCIe endpoint, the FDMA engine needs to + * DMA to/from host memory. The FDMA writes to addresses within the endpoi= nt's + * internal Outbound (OB) address space, and the PCIe ATU translates these= to + * DMA addresses on the PCIe bus, targeting host memory. + * + * The ATU supports up to six outbound regions. This implementation divides + * the OB address space into six equally sized chunks. + * + * +-------------+------------+------------+-----+------------+ + * | Index | Region 0 | Region 1 | ... | Region 5 | + * +-------------+------------+------------+-----+------------+ + * | Base addr | 0x10000000 | 0x12aa0000 | ... | 0x1d520000 | + * | Limit addr | 0x12a9ffff | 0x1553ffff | ... | 0x1ffbffff | + * | Target addr | host dma | host dma | ... | host dma | + * +-------------+------------+------------+-----+------------+ + * + * Base addr is the start address of the region within the OB address spac= e. + * Limit addr is each region's own upper bound. The value actually + * programmed is set per-mapping as base_addr + mapped size - 1, and is + * usually smaller than this. + * Target addr is the host DMA address that the base addr translates to. + */ + +#define FDMA_PCI_ATU_OB_START 0x10000000 +#define FDMA_PCI_ATU_OB_END 0x1fffffff + +#define FDMA_PCI_ATU_ADDR 0x300000 +#define FDMA_PCI_ATU_IDX_SIZE 0x200 +#define FDMA_PCI_ATU_ENA_REG 0x4 +#define FDMA_PCI_ATU_ENA_BIT BIT(31) +#define FDMA_PCI_ATU_LWR_BASE_ADDR 0x8 +#define FDMA_PCI_ATU_UPP_BASE_ADDR 0xc +#define FDMA_PCI_ATU_LIMIT_ADDR 0x10 +#define FDMA_PCI_ATU_LWR_TARGET_ADDR 0x14 +#define FDMA_PCI_ATU_UPP_TARGET_ADDR 0x18 + +static u32 fdma_pci_atu_region_size(void) +{ + return round_down((FDMA_PCI_ATU_OB_END - FDMA_PCI_ATU_OB_START) / + FDMA_PCI_ATU_REGION_MAX, FDMA_PCI_ATU_REGION_ALIGN); +} + +static void __iomem *fdma_pci_atu_addr_get(void __iomem *addr, int offset, + int idx) +{ + return addr + FDMA_PCI_ATU_ADDR + FDMA_PCI_ATU_IDX_SIZE * idx + offset; +} + +static void fdma_pci_atu_region_enable(struct fdma_pci_atu_region *region) +{ + writel(FDMA_PCI_ATU_ENA_BIT, + fdma_pci_atu_addr_get(region->atu->addr, FDMA_PCI_ATU_ENA_REG, + region->idx)); +} + +static void fdma_pci_atu_region_disable(struct fdma_pci_atu_region *region) +{ + writel(0, fdma_pci_atu_addr_get(region->atu->addr, FDMA_PCI_ATU_ENA_REG, + region->idx)); +} + +/* Configure the address translation in the ATU. */ +static void +fdma_pci_atu_configure_translation(struct fdma_pci_atu_region *region) +{ + struct fdma_pci_atu *atu =3D region->atu; + int idx =3D region->idx; + + writel(lower_32_bits(region->base_addr), + fdma_pci_atu_addr_get(atu->addr, + FDMA_PCI_ATU_LWR_BASE_ADDR, idx)); + + writel(upper_32_bits(region->base_addr), + fdma_pci_atu_addr_get(atu->addr, + FDMA_PCI_ATU_UPP_BASE_ADDR, idx)); + + /* The OB address space lies entirely below 4GB, so the limit always + * fits the lower limit register and the upper one is left alone. + */ + writel(region->limit_addr, + fdma_pci_atu_addr_get(atu->addr, FDMA_PCI_ATU_LIMIT_ADDR, idx)); + + writel(lower_32_bits(region->target_addr), + fdma_pci_atu_addr_get(atu->addr, + FDMA_PCI_ATU_LWR_TARGET_ADDR, idx)); + + writel(upper_32_bits(region->target_addr), + fdma_pci_atu_addr_get(atu->addr, + FDMA_PCI_ATU_UPP_TARGET_ADDR, idx)); +} + +/* Find an unused ATU region. */ +static struct fdma_pci_atu_region * +fdma_pci_atu_region_get_free(struct fdma_pci_atu *atu) +{ + struct fdma_pci_atu_region *regions =3D atu->regions; + + for (int i =3D 0; i < FDMA_PCI_ATU_REGION_MAX; i++) { + if (regions[i].in_use) + continue; + + return ®ions[i]; + } + + return ERR_PTR(-ENOSPC); +} + +/* Unmap an ATU region, clearing its translation and disabling it. */ +void fdma_pci_atu_region_unmap(struct fdma_pci_atu_region *region) +{ + if (IS_ERR_OR_NULL(region)) + return; + + mutex_lock(®ion->atu->lock); + + region->target_addr =3D 0; + region->in_use =3D false; + + fdma_pci_atu_region_disable(region); + fdma_pci_atu_configure_translation(region); + + mutex_unlock(®ion->atu->lock); +} +EXPORT_SYMBOL_GPL(fdma_pci_atu_region_unmap); + +/* Map a host DMA address into a free outbound region. */ +struct fdma_pci_atu_region * +fdma_pci_atu_region_map(struct fdma_pci_atu *atu, u64 target_addr, int siz= e) +{ + struct fdma_pci_atu_region *region; + + if (!atu) + return ERR_PTR(-EINVAL); + + if (size <=3D 0) + return ERR_PTR(-EINVAL); + + if (size > fdma_pci_atu_region_size()) + return ERR_PTR(-ERANGE); + + /* The ATU region base is only ever aligned to FDMA_PCI_ATU_REGION_ALIGN; + * require the same alignment of the host target address, since the ATU + * translates addr - target_addr + base_addr and any misalignment here + * would shift every translated address by the same amount. + */ + if (!IS_ALIGNED(target_addr, FDMA_PCI_ATU_REGION_ALIGN)) + return ERR_PTR(-EINVAL); + + mutex_lock(&atu->lock); + + region =3D fdma_pci_atu_region_get_free(atu); + if (IS_ERR(region)) { + mutex_unlock(&atu->lock); + return region; + } + + region->target_addr =3D target_addr; + region->limit_addr =3D region->base_addr + size - 1; + region->in_use =3D true; + + fdma_pci_atu_configure_translation(region); + fdma_pci_atu_region_enable(region); + + mutex_unlock(&atu->lock); + + return region; +} +EXPORT_SYMBOL_GPL(fdma_pci_atu_region_map); + +/* Translate a host DMA address to the corresponding OB address. */ +u64 fdma_pci_atu_translate_addr(struct fdma_pci_atu_region *region, u64 ad= dr) +{ + return region->base_addr + (addr - region->target_addr); +} +EXPORT_SYMBOL_GPL(fdma_pci_atu_translate_addr); + +/* Initialize ATU, dividing the OB space into equally sized regions. */ +void fdma_pci_atu_init(struct fdma_pci_atu *atu, void __iomem *addr) +{ + struct fdma_pci_atu_region *regions =3D atu->regions; + u32 region_size =3D fdma_pci_atu_region_size(); + + atu->addr =3D addr; + mutex_init(&atu->lock); + + for (int i =3D 0; i < FDMA_PCI_ATU_REGION_MAX; i++) { + regions[i].base_addr =3D + FDMA_PCI_ATU_OB_START + (i * region_size); + regions[i].limit_addr =3D 0; + regions[i].target_addr =3D 0; + regions[i].idx =3D i; + regions[i].atu =3D atu; + regions[i].in_use =3D false; + + fdma_pci_atu_region_disable(®ions[i]); + } +} +EXPORT_SYMBOL_GPL(fdma_pci_atu_init); diff --git a/drivers/net/ethernet/microchip/fdma/fdma_pci.h b/drivers/net/e= thernet/microchip/fdma/fdma_pci.h new file mode 100644 index 000000000000..010bdb4d50b0 --- /dev/null +++ b/drivers/net/ethernet/microchip/fdma/fdma_pci.h @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _FDMA_PCI_H_ +#define _FDMA_PCI_H_ + +#include +#include +#include +#include + +#define FDMA_PCI_ATU_REGION_MAX 6 + +/* Outbound regions are 64KB granular (datasheet section 3.24.7.4.1), so b= oth + * the region base and the mapped size must be aligned to this. + */ +#define FDMA_PCI_ATU_REGION_ALIGN BIT(16) + +#define FDMA_PCI_DB_ALIGN 128 +#define FDMA_PCI_DB_SIZE(mtu) ALIGN(mtu, FDMA_PCI_DB_ALIGN) + +struct fdma_pci_atu; + +struct fdma_pci_atu_region { + struct fdma_pci_atu *atu; + u64 base_addr; /* Base addr of the OB window */ + u64 limit_addr; /* End addr of the active mapping (base_addr + size - 1) = */ + u64 target_addr; /* Host DMA address this region maps to */ + int idx; + bool in_use; +}; + +struct fdma_pci_atu { + void __iomem *addr; + struct mutex lock; /* Protects region alloc/free and ATU register access = */ + struct fdma_pci_atu_region regions[FDMA_PCI_ATU_REGION_MAX]; +}; + +/* Initialize ATU, dividing OB space into regions. */ +void fdma_pci_atu_init(struct fdma_pci_atu *atu, void __iomem *addr); + +/* Unmap an ATU region, clearing its translation and disabling it. */ +void fdma_pci_atu_region_unmap(struct fdma_pci_atu_region *region); + +/* Map a host DMA address into a free ATU region. target_addr and size mus= t be + * FDMA_PCI_ATU_REGION_ALIGN aligned; a misaligned target_addr returns -EI= NVAL. + */ +struct fdma_pci_atu_region *fdma_pci_atu_region_map(struct fdma_pci_atu *a= tu, + u64 target_addr, + int size); + +/* Translate a host DMA address to the OB address space. Reads the region + * unlocked, so the caller must quiesce DMA and the descriptor paths before + * unmapping the region. + */ +u64 fdma_pci_atu_translate_addr(struct fdma_pci_atu_region *region, u64 ad= dr); + +#endif --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 81F09463B74; Thu, 24 Sep 2026 19:57:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279848; cv=none; b=liya1fxX4AyPq17W/5BrSH/ZUhglaKvrXm2plX/wmNviDUd7OjvfX09DzWGNrmNt6R4+vSuBiuxKlm9FSDwLPe7w4o1oQv2B50y2yVjkgoo5i3dVoZf3oCUKi9iNf2UAT86Xkvk5mVotHGfDMlcwi+5xli4s6/T9WRHkvywgC2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279848; c=relaxed/simple; bh=FF6QRWvolzsP0sTH1U6d+Yj1wY9euWyqxEoL/O8e+/o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=HykDEemMpj9RDnJCJUrbCBfQF9H4Ld4B11pyg/Y/St82NaJ2+ECVkNXuyi7OlxfJKLm3dB8JRB3qyHN7p6IuUVOm4C7wbjRC8sqJLmGMw9+JthG3NJORmjkS3+uMCT4FOHcLrP/dTxqa8zet0UDeWS/pmozhY9azhtrRy9YhJZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=ovA/LMK4; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="ovA/LMK4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279848; x=1821815848; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=FF6QRWvolzsP0sTH1U6d+Yj1wY9euWyqxEoL/O8e+/o=; b=ovA/LMK4bUA/cRAuInmLRyUKIRBLf08B9XGvqNrVNtxVVNumjAAKt8zq c/WUMVN9g5of1tHJ0JPlN+ORKfeqYFxbTz+KU6QViPUifgrTnxfCGxLYt TdqdeJP0FImW+f1X9Iv/Bhjrb60chziu3c/Gp9AI+6LPDGng3ld1bp0LF 8aZURjmxJr5cfLI02IEzqxxtH2/a80eMaod3KXMlvTc/DpCfE3qwJi+Uj FFSpGhS3dnMsikGO/yxYh13x0l0Ap+mFuNVnZ8DmL8oEQMeHUHCf6UJRy 0str30E2k2pK4aWsIPoRCwacJ232ZrhdTuwFILVdyJmnu0FBKbTy7AT9J A==; X-CSE-ConnectionGUID: Eq/m5JzJQHSqE+mU6Q3qsw== X-CSE-MsgGUID: YAAkedm5Tpy/Q2GINru/Jw== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="74257250" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 12:57:24 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex2.mchp-main.com (10.10.87.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.49; Thu, 24 Sep 2026 12:57:18 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:14 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:52 +0200 Subject: [PATCH net-next v8 04/15] net: microchip: fdma: use little-endian types for descriptor fields Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-4-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 The FDMA engine reads and writes the DCB and DB descriptors in little-endian byte order. So far the descriptors have only been produced by the little-endian SoC itself, so plain u64 fields were fine. With the PCIe FDMA path, the descriptors live in host memory and are written by the host CPU, which may be big-endian. Change the descriptor fields to __le64 and convert at the library boundary: in __fdma_db_add() and __fdma_dcb_add() on write, and in the fdma_db_*() accessors on read. The dataptr and nextptr callbacks keep their u64 signatures, so their implementations are unchanged. Add fdma_db_dataptr_get(), and convert the lan966x sites that read the descriptor fields directly to use the accessors. No functional change on little-endian hosts. Signed-off-by: Daniel Machon --- drivers/net/ethernet/microchip/fdma/fdma_api.c | 21 ++++++++++++++++-= ---- drivers/net/ethernet/microchip/fdma/fdma_api.h | 20 +++++++++++++----= --- .../net/ethernet/microchip/lan966x/lan966x_fdma.c | 9 +++++---- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/microchip/fdma/fdma_api.c b/drivers/net/e= thernet/microchip/fdma/fdma_api.c index a3c9e3097c5c..f7a42348e932 100644 --- a/drivers/net/ethernet/microchip/fdma/fdma_api.c +++ b/drivers/net/ethernet/microchip/fdma/fdma_api.c @@ -12,10 +12,18 @@ static int __fdma_db_add(struct fdma *fdma, int dcb_idx= , int db_idx, u64 status, int db_idx, u64 *dataptr)) { struct fdma_db *db =3D fdma_db_get(fdma, dcb_idx, db_idx); + u64 dataptr; + int err; + + db->status =3D cpu_to_le64(status); =20 - db->status =3D status; + err =3D cb(fdma, dcb_idx, db_idx, &dataptr); + if (unlikely(err)) + return err; =20 - return cb(fdma, dcb_idx, db_idx, &db->dataptr); + db->dataptr =3D cpu_to_le64(dataptr); + + return 0; } =20 /* Add a DB to a DCB, using the callback set in the fdma_ops struct. */ @@ -35,6 +43,7 @@ int __fdma_dcb_add(struct fdma *fdma, int dcb_idx, u64 in= fo, u64 status, u64 *dataptr)) { struct fdma_dcb *dcb =3D fdma_dcb_get(fdma, dcb_idx); + u64 nextptr; int i, err; =20 for (i =3D 0; i < fdma->n_dbs; i++) { @@ -43,14 +52,16 @@ int __fdma_dcb_add(struct fdma *fdma, int dcb_idx, u64 = info, u64 status, return err; } =20 - err =3D dcb_cb(fdma, dcb_idx, &fdma->last_dcb->nextptr); + err =3D dcb_cb(fdma, dcb_idx, &nextptr); if (unlikely(err)) return err; =20 + fdma->last_dcb->nextptr =3D cpu_to_le64(nextptr); + fdma->last_dcb =3D dcb; =20 - dcb->nextptr =3D FDMA_DCB_INVALID_DATA; - dcb->info =3D info; + dcb->nextptr =3D cpu_to_le64(FDMA_DCB_INVALID_DATA); + dcb->info =3D cpu_to_le64(info); =20 return 0; } diff --git a/drivers/net/ethernet/microchip/fdma/fdma_api.h b/drivers/net/e= thernet/microchip/fdma/fdma_api.h index ccc30d506e89..4e4f009b77cb 100644 --- a/drivers/net/ethernet/microchip/fdma/fdma_api.h +++ b/drivers/net/ethernet/microchip/fdma/fdma_api.h @@ -66,13 +66,13 @@ struct fdma; =20 struct fdma_db { - u64 dataptr; - u64 status; + __le64 dataptr; + __le64 status; }; =20 struct fdma_dcb { - u64 nextptr; - u64 info; + __le64 nextptr; + __le64 info; struct fdma_db db[FDMA_DB_MAX]; }; =20 @@ -147,19 +147,25 @@ static inline bool fdma_dcb_is_reusable(struct fdma *= fdma) /* Check if the FDMA has marked this DB as done. */ static inline bool fdma_db_is_done(struct fdma_db *db) { - return db->status & FDMA_DCB_STATUS_DONE; + return le64_to_cpu(db->status) & FDMA_DCB_STATUS_DONE; } =20 /* Get the length of a DB. */ static inline int fdma_db_len_get(struct fdma_db *db) { - return FDMA_DCB_STATUS_BLOCKL(db->status); + return FDMA_DCB_STATUS_BLOCKL(le64_to_cpu(db->status)); +} + +/* Get the dataptr of a DB. */ +static inline u64 fdma_db_dataptr_get(struct fdma_db *db) +{ + return le64_to_cpu(db->dataptr); } =20 /* Set the length of a DB. */ static inline void fdma_dcb_len_set(struct fdma_dcb *dcb, u32 len) { - dcb->info =3D FDMA_DCB_INFO_DATAL(len); + dcb->info =3D cpu_to_le64(FDMA_DCB_INFO_DATAL(len)); } =20 /* Get a DB by index. */ diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_fdma.c index 41d4ec7f2f57..68fd454ebc98 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -406,8 +406,9 @@ static int lan966x_fdma_rx_check_frame(struct lan966x_r= x *rx, u64 *src_port) return FDMA_ERROR; =20 dma_sync_single_for_cpu(lan966x->dev, - (dma_addr_t)db->dataptr + XDP_PACKET_HEADROOM, - FDMA_DCB_STATUS_BLOCKL(db->status), + (dma_addr_t)fdma_db_dataptr_get(db) + + XDP_PACKET_HEADROOM, + fdma_db_len_get(db), DMA_FROM_DEVICE); =20 lan966x_ifh_get_src_port(page_address(page) + XDP_PACKET_HEADROOM, @@ -419,7 +420,7 @@ static int lan966x_fdma_rx_check_frame(struct lan966x_r= x *rx, u64 *src_port) if (!lan966x_xdp_port_present(port)) return FDMA_PASS; =20 - return lan966x_xdp_run(port, page, FDMA_DCB_STATUS_BLOCKL(db->status)); + return lan966x_xdp_run(port, page, fdma_db_len_get(db)); } =20 static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx, @@ -443,7 +444,7 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct= lan966x_rx *rx, skb_mark_for_recycle(skb); =20 skb_reserve(skb, XDP_PACKET_HEADROOM); - skb_put(skb, FDMA_DCB_STATUS_BLOCKL(db->status)); + skb_put(skb, fdma_db_len_get(db)); =20 lan966x_ifh_get_timestamp(skb->data, ×tamp); =20 --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 9BAB94CB8AC; Thu, 24 Sep 2026 19:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279853; cv=none; b=nOF5TNFEy6wlyLd0DZ+NWfzTwCKvAlnfA1ZOtLMkiWZ4blbLe9PvXLxC+scUBQ48AtYkP9i2bKssE9LPmRs5W6ScT9nCNBpz8KtY/SqWEd1kc8wo5P/hvxjKaGVCiQXK6GyMhDrepIRCkO84V1T/bJ/+sVg33dBs7lUpIPz6qHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279853; c=relaxed/simple; bh=bTmIpqNrNvU3IHtPezg+HL5Y1+Y1opzwgINLmoX0OYI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=ZlXfRULGGS9FgUadO3t5rJAE8r6X8zHi16ky37+ig3/LT/l1WdTedppW0UW6TDGSk6IhflG6Xfu3SiX6khngUDrWZqiFe+8Z9gciKvpPKet62PiUcYdCpUrRAxE8IOKl5ajcPKkS87NgSIQllpplLYkZt0KdseHo0/J0HntKSE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=0UacfMOH; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="0UacfMOH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279850; x=1821815850; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=bTmIpqNrNvU3IHtPezg+HL5Y1+Y1opzwgINLmoX0OYI=; b=0UacfMOH4q0Rbv6cl/+H1l3MkUdoNL3fjc5He6ISu/qELtFtumaD+Gnr L1FS63y4oIpTKopntd1nAV26LrND1G74NFvrp86wzF8LdcQWFCg27ccNz X/w/pVUfTpOUpMc33r2GU2Nv+GG1aoCYqgg/7X6W1c9mN24frIWjEkgMU CKIIUnByXFyRe8jUS5i9hIxuydVRL0YcGRd/BUsOrV847gFcWoDwt7Fy0 kO2tRt7tav6xdED2LTFclgOgnzfUE1orWNkrwx5qf0ddRH/hVSwKEOHO3 7khnbDXe0jT36VnIPKPzzqM13orcd1S8Y8wm90M8nmY7W+l3mhc/61Wsw w==; X-CSE-ConnectionGUID: 4e95//WWTUedOtgVIwaRxw== X-CSE-MsgGUID: tyP16sZBRs28XDKQe879rA== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="64420630" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:57:24 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:57:23 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:19 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:53 +0200 Subject: [PATCH net-next v8 05/15] net: lan966x: add FDMA LLP register write helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-5-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 The FDMA Link List Pointer (LLP) register points to the first DCB in the chain and must be written before the channel is activated. This tells the FDMA engine where to begin DMA transfers. Move the LLP register writes from the channel start/activate functions into the allocation functions and introduce a shared lan966x_fdma_llp_configure() helper. This is needed because the upcoming PCIe FDMA path writes ATU-translated addresses to the LLP registers instead of DMA addresses. Keeping the writes in the shared start/activate path would overwrite these translated addresses. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- .../net/ethernet/microchip/lan966x/lan966x_fdma.c | 30 ++++++++++--------= ---- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_fdma.c index 68fd454ebc98..1c5484a506ff 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -109,6 +109,13 @@ static int lan966x_fdma_rx_alloc_page_pool(struct lan9= 66x_rx *rx) return 0; } =20 +static void lan966x_fdma_llp_configure(struct lan966x *lan966x, u64 addr, + u8 channel_id) +{ + lan_wr(lower_32_bits(addr), lan966x, FDMA_DCB_LLP(channel_id)); + lan_wr(upper_32_bits(addr), lan966x, FDMA_DCB_LLP1(channel_id)); +} + static int lan966x_fdma_rx_alloc(struct lan966x_rx *rx) { struct lan966x *lan966x =3D rx->lan966x; @@ -128,6 +135,8 @@ static int lan966x_fdma_rx_alloc(struct lan966x_rx *rx) fdma_dcbs_init(fdma, FDMA_DCB_INFO_DATAL(fdma->db_size), FDMA_DCB_STATUS_INTR); =20 + lan966x_fdma_llp_configure(lan966x, fdma->dma, fdma->channel_id); + return 0; } =20 @@ -137,14 +146,6 @@ static void lan966x_fdma_rx_start(struct lan966x_rx *r= x) struct fdma *fdma =3D &rx->fdma; u32 mask; =20 - /* When activating a channel, first is required to write the first DCB - * address and then to activate it - */ - lan_wr(lower_32_bits((u64)fdma->dma), lan966x, - FDMA_DCB_LLP(fdma->channel_id)); - lan_wr(upper_32_bits((u64)fdma->dma), lan966x, - FDMA_DCB_LLP1(fdma->channel_id)); - lan_wr(FDMA_CH_CFG_CH_DCB_DB_CNT_SET(fdma->n_dbs) | FDMA_CH_CFG_CH_INTR_DB_EOF_ONLY_SET(1) | FDMA_CH_CFG_CH_INJ_PORT_SET(0) | @@ -215,6 +216,8 @@ static int lan966x_fdma_tx_alloc(struct lan966x_tx *tx) =20 fdma_dcbs_init(fdma, 0, 0); =20 + lan966x_fdma_llp_configure(lan966x, fdma->dma, fdma->channel_id); + return 0; =20 out: @@ -236,14 +239,6 @@ static void lan966x_fdma_tx_activate(struct lan966x_tx= *tx) struct fdma *fdma =3D &tx->fdma; u32 mask; =20 - /* When activating a channel, first is required to write the first DCB - * address and then to activate it - */ - lan_wr(lower_32_bits((u64)fdma->dma), lan966x, - FDMA_DCB_LLP(fdma->channel_id)); - lan_wr(upper_32_bits((u64)fdma->dma), lan966x, - FDMA_DCB_LLP1(fdma->channel_id)); - lan_wr(FDMA_CH_CFG_CH_DCB_DB_CNT_SET(fdma->n_dbs) | FDMA_CH_CFG_CH_INTR_DB_EOF_ONLY_SET(1) | FDMA_CH_CFG_CH_INJ_PORT_SET(0) | @@ -877,6 +872,9 @@ static int lan966x_fdma_reload(struct lan966x *lan966x,= int new_mtu) MEM_TYPE_PAGE_POOL, page_pool); } =20 + lan966x_fdma_llp_configure(lan966x, lan966x->rx.fdma.dma, + lan966x->rx.fdma.channel_id); + lan966x_fdma_rx_start(&lan966x->rx); =20 lan966x_fdma_wakeup_netdev(lan966x); --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 C84B44CC269; Thu, 24 Sep 2026 19:57:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279854; cv=none; b=MSNwhR2oXRNeEorOjl5qUN6tFuZnmnzp3sEPnRvJ5PEP8YPCq2RrOPdC/IHcDMK30fzqCj1h+LRO2SC7lI2LVzOOjSatQTDhDacV9zsrOqlRsdcpSWkO8ovrJVFAfuamkHn99v2R9loDeYaC0W4lXj5WHKlFW2rgQRo+MF4uDMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279854; c=relaxed/simple; bh=uAjuVs+ar/be9P7MezDvO8gsGdNh69Bo2d+uWmDN2zk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=nuhPg3Ex/+D6C5wjfKQtJaPXl6jFpCUpnt+poOBr7UfD/FxzRMnb8j07ZlfRJ07I4ni2bZf4pN1SM3kTWzsg/qeJhkeHDOfoJm/L5vf8IsPpxJWiKphvTfh6OMcd8bNQjX/mnGm2ZBctq4S+0CM4A78dhnsy+AZPgGwHT6dKWHk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=0q7inS2N; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="0q7inS2N" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279855; x=1821815855; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=uAjuVs+ar/be9P7MezDvO8gsGdNh69Bo2d+uWmDN2zk=; b=0q7inS2N0sr6YgtfIzey7qknnMGczQT7VESChP30FS6cTLch+qCF0Hx7 w7ewg2FWOfFoV+NOt+AZM42Axmbz0LJcpshy0Fcscq2Fj2WqsD/0za9bV Tn8LcC+TbAGCTrTMdjGwqnI+iE3buwHNDh3fmDA0HMbzbXjNjkT2MCCqT HRlsMsYCc5eStLbSbp04EdMAvHAFFmGcSlEvZJdDvNUDigAft4X+3JMg7 GuH9UlGNkavOOdz7+SGtB8m5FzTRehsOCqO9hXqZkn0oCeMe4/+IpjjWF Js0zLAFC9g1nZh5kjY6Y0UtxTbgQveYTzz/ekaFLiwGJbT1/4tg8Tfa/V Q==; X-CSE-ConnectionGUID: Vvk/wXE2QwK9SdxXPJeKLw== X-CSE-MsgGUID: TiBLsBqQQX2c6fBEDD+eJw== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="74257255" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:57:33 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:57:27 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:23 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:54 +0200 Subject: [PATCH net-next v8 06/15] net: lan966x: export FDMA helpers for reuse Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-6-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 Make shared FDMA helpers non-static, so they can be reused by the PCIe FDMA implementation. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- .../net/ethernet/microchip/lan966x/lan966x_fdma.c | 22 +++++++++++-------= ---- .../net/ethernet/microchip/lan966x/lan966x_main.h | 11 +++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_fdma.c index 1c5484a506ff..651ea03eede7 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -109,8 +109,8 @@ static int lan966x_fdma_rx_alloc_page_pool(struct lan96= 6x_rx *rx) return 0; } =20 -static void lan966x_fdma_llp_configure(struct lan966x *lan966x, u64 addr, - u8 channel_id) +void lan966x_fdma_llp_configure(struct lan966x *lan966x, u64 addr, + u8 channel_id) { lan_wr(lower_32_bits(addr), lan966x, FDMA_DCB_LLP(channel_id)); lan_wr(upper_32_bits(addr), lan966x, FDMA_DCB_LLP1(channel_id)); @@ -140,7 +140,7 @@ static int lan966x_fdma_rx_alloc(struct lan966x_rx *rx) return 0; } =20 -static void lan966x_fdma_rx_start(struct lan966x_rx *rx) +void lan966x_fdma_rx_start(struct lan966x_rx *rx) { struct lan966x *lan966x =3D rx->lan966x; struct fdma *fdma =3D &rx->fdma; @@ -171,7 +171,7 @@ static void lan966x_fdma_rx_start(struct lan966x_rx *rx) lan966x, FDMA_CH_ACTIVATE); } =20 -static void lan966x_fdma_rx_disable(struct lan966x_rx *rx) +void lan966x_fdma_rx_disable(struct lan966x_rx *rx) { struct lan966x *lan966x =3D rx->lan966x; struct fdma *fdma =3D &rx->fdma; @@ -191,7 +191,7 @@ static void lan966x_fdma_rx_disable(struct lan966x_rx *= rx) lan966x, FDMA_CH_DB_DISCARD); } =20 -static void lan966x_fdma_rx_reload(struct lan966x_rx *rx) +void lan966x_fdma_rx_reload(struct lan966x_rx *rx) { struct lan966x *lan966x =3D rx->lan966x; =20 @@ -264,7 +264,7 @@ static void lan966x_fdma_tx_activate(struct lan966x_tx = *tx) lan966x, FDMA_CH_ACTIVATE); } =20 -static void lan966x_fdma_tx_disable(struct lan966x_tx *tx) +void lan966x_fdma_tx_disable(struct lan966x_tx *tx) { struct lan966x *lan966x =3D tx->lan966x; struct fdma *fdma =3D &tx->fdma; @@ -296,7 +296,7 @@ static void lan966x_fdma_tx_reload(struct lan966x_tx *t= x) lan966x, FDMA_CH_RELOAD); } =20 -static void lan966x_fdma_wakeup_netdev(struct lan966x *lan966x) +void lan966x_fdma_wakeup_netdev(struct lan966x *lan966x) { struct lan966x_port *port; int i; @@ -471,7 +471,7 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct= lan966x_rx *rx, return NULL; } =20 -static int lan966x_fdma_napi_poll(struct napi_struct *napi, int weight) +int lan966x_fdma_napi_poll(struct napi_struct *napi, int weight) { struct lan966x *lan966x =3D container_of(napi, struct lan966x, napi); struct lan966x_rx *rx =3D &lan966x->rx; @@ -584,7 +584,7 @@ static int lan966x_fdma_get_next_dcb(struct lan966x_tx = *tx) return -1; } =20 -static void lan966x_fdma_tx_start(struct lan966x_tx *tx) +void lan966x_fdma_tx_start(struct lan966x_tx *tx) { struct lan966x *lan966x =3D tx->lan966x; =20 @@ -802,7 +802,7 @@ static int lan966x_fdma_get_max_mtu(struct lan966x *lan= 966x) return max_mtu; } =20 -static int lan966x_qsys_sw_status(struct lan966x *lan966x) +int lan966x_qsys_sw_status(struct lan966x *lan966x) { return lan_rd(lan966x, QSYS_SW_STATUS(CPU_PORT)); } @@ -884,7 +884,7 @@ static int lan966x_fdma_reload(struct lan966x *lan966x,= int new_mtu) return err; } =20 -static int lan966x_fdma_get_max_frame(struct lan966x *lan966x) +int lan966x_fdma_get_max_frame(struct lan966x *lan966x) { return lan966x_fdma_get_max_mtu(lan966x) + IFH_LEN_BYTES + diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.h index eea286c29474..83c361abb789 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -561,6 +561,17 @@ int lan966x_fdma_init(struct lan966x *lan966x); void lan966x_fdma_deinit(struct lan966x *lan966x); irqreturn_t lan966x_fdma_irq_handler(int irq, void *args); int lan966x_fdma_reload_page_pool(struct lan966x *lan966x); +int lan966x_fdma_napi_poll(struct napi_struct *napi, int weight); +void lan966x_fdma_llp_configure(struct lan966x *lan966x, u64 addr, + u8 channel_id); +void lan966x_fdma_rx_start(struct lan966x_rx *rx); +void lan966x_fdma_rx_disable(struct lan966x_rx *rx); +void lan966x_fdma_rx_reload(struct lan966x_rx *rx); +void lan966x_fdma_tx_start(struct lan966x_tx *tx); +void lan966x_fdma_tx_disable(struct lan966x_tx *tx); +void lan966x_fdma_wakeup_netdev(struct lan966x *lan966x); +int lan966x_fdma_get_max_frame(struct lan966x *lan966x); +int lan966x_qsys_sw_status(struct lan966x *lan966x); =20 int lan966x_lag_port_join(struct lan966x_port *port, struct net_device *brport_dev, --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 8216E429036; Thu, 24 Sep 2026 19:57:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279859; cv=none; b=ZTitkuwQziLBuvVlRGGgqjd+ESOJRkA7e7Y4QVZkGjP22c8C0clClGARDfzYXfO2VPs6Qw2d/hlkgehUZN5OSPHUG4lV0R0MR2cj1HYp8FnQcNeuDjoaWH53FXtAcYOPsIrAUaqLWXbS0JBhhk8RMafH17cK0RIXQL+jSVz7zkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279859; c=relaxed/simple; bh=7SJDHiTNZUVrA2+aUWyf6Kg0AVhJfh5JdWvOY32Bbt0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=EvXS7nYIaRj6XfcLXaLQJyJzEMDDxJcCwQBWaKlB+gOn01VMJcxPr/nhn3Mcyn4WPTxx7GZCThuoYRr/hTVtlHzIP3yQn0eyscYN8raGLPKLmYhjSrSUanq3MhGcIVzGRDhNA+TDWd3X8Z6Xqfi9a54QriGZN4lBUkss53k9ihM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=zTWd0o+r; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="zTWd0o+r" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279855; x=1821815855; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=7SJDHiTNZUVrA2+aUWyf6Kg0AVhJfh5JdWvOY32Bbt0=; b=zTWd0o+rs9d+6pLjXi0e5VrOUykp1LZwSE2Kr/oCck491Vol1hI7HYZ9 uYg9/6AhZXAX7qUaeW75q5SlPjhBxOdHHVPmQHdrQ0ZxXDZ4mwWwmU6fo +dA9VhQpWly6C5zDirRvG6Bqq8gY+Mswd3b3O5N2BbUpBeXlQUHTUoIIG rcRHpCoT2jvK/nqepjP8sMwAzsQzG4m52hZb5Cama75UZZUlt2V4ipTo2 rBd9AgCSuNdjR4sO7N/0iDSRiB5QoJYLL5Locct2gfxR4ZhSRSWgS9/fo MpZ+DmFKR5DNrDciR7ZhEB+WwL10nS50k4HgdEjOpmqWgdqdlmK2xVunO Q==; X-CSE-ConnectionGUID: /PA5yiZ3SiimKIT/ka/hMg== X-CSE-MsgGUID: Dj9Q2I9MR1emHWK57xauyw== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="64420633" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 12:57:33 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex2.mchp-main.com (10.10.87.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.49; Thu, 24 Sep 2026 12:57:32 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:28 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:55 +0200 Subject: [PATCH net-next v8 07/15] net: lan966x: use a dedicated device for DMA operations Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-7-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 In preparation for the PCIe FDMA implementation, add lan966x->dma_dev, resolved once at probe time, and use it for every DMA operation the FDMA path performs: coherent allocations, streaming mappings and the RX page pool. Natively, dma_dev is lan966x->dev, so there is no functional change. Since dma_dev differs from dev only on the PCIe path, add lan966x_is_pci() on top of it, for the later PCIe patches to key off. Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- .../net/ethernet/microchip/lan966x/lan966x_fdma.c | 30 +++++++++++-------= ---- .../net/ethernet/microchip/lan966x/lan966x_main.c | 16 ++++++++++++ .../net/ethernet/microchip/lan966x/lan966x_main.h | 10 ++++++++ 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_fdma.c index 651ea03eede7..ae6e5aec5e13 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -80,7 +80,7 @@ static int lan966x_fdma_rx_alloc_page_pool(struct lan966x= _rx *rx) .flags =3D PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV, .pool_size =3D rx->fdma.n_dcbs, .nid =3D NUMA_NO_NODE, - .dev =3D lan966x->dev, + .dev =3D lan966x->dma_dev, .dma_dir =3D DMA_FROM_DEVICE, .offset =3D XDP_PACKET_HEADROOM, .max_len =3D rx->max_mtu - @@ -126,7 +126,7 @@ static int lan966x_fdma_rx_alloc(struct lan966x_rx *rx) if (err) return err; =20 - err =3D fdma_alloc_coherent(lan966x->dev, fdma); + err =3D fdma_alloc_coherent(lan966x->dma_dev, fdma); if (err) { page_pool_destroy(rx->page_pool); return err; @@ -210,7 +210,7 @@ static int lan966x_fdma_tx_alloc(struct lan966x_tx *tx) if (!tx->dcbs_buf) return -ENOMEM; =20 - err =3D fdma_alloc_coherent(lan966x->dev, fdma); + err =3D fdma_alloc_coherent(lan966x->dma_dev, fdma); if (err) goto out; =20 @@ -230,7 +230,7 @@ static void lan966x_fdma_tx_free(struct lan966x_tx *tx) struct lan966x *lan966x =3D tx->lan966x; =20 kfree(tx->dcbs_buf); - fdma_free_coherent(lan966x->dev, &tx->fdma); + fdma_free_coherent(lan966x->dma_dev, &tx->fdma); } =20 static void lan966x_fdma_tx_activate(struct lan966x_tx *tx) @@ -355,7 +355,7 @@ static void lan966x_fdma_tx_clear_buf(struct lan966x *l= an966x, int weight) =20 dcb_buf->used =3D false; if (dcb_buf->use_skb) { - dma_unmap_single(lan966x->dev, + dma_unmap_single(lan966x->dma_dev, dcb_buf->dma_addr, dcb_buf->len, DMA_TO_DEVICE); @@ -364,7 +364,7 @@ static void lan966x_fdma_tx_clear_buf(struct lan966x *l= an966x, int weight) napi_consume_skb(dcb_buf->data.skb, weight); } else { if (dcb_buf->xdp_ndo) - dma_unmap_single(lan966x->dev, + dma_unmap_single(lan966x->dma_dev, dcb_buf->dma_addr, dcb_buf->len, DMA_TO_DEVICE); @@ -400,7 +400,7 @@ static int lan966x_fdma_rx_check_frame(struct lan966x_r= x *rx, u64 *src_port) if (unlikely(!page)) return FDMA_ERROR; =20 - dma_sync_single_for_cpu(lan966x->dev, + dma_sync_single_for_cpu(lan966x->dma_dev, (dma_addr_t)fdma_db_dataptr_get(db) + XDP_PACKET_HEADROOM, fdma_db_len_get(db), @@ -636,11 +636,11 @@ int lan966x_fdma_xmit_xdpf(struct lan966x_port *port,= void *ptr, u32 len) lan966x_ifh_set_bypass(ifh, 1); lan966x_ifh_set_port(ifh, BIT_ULL(port->chip_port)); =20 - dma_addr =3D dma_map_single(lan966x->dev, + dma_addr =3D dma_map_single(lan966x->dma_dev, xdpf->data - IFH_LEN_BYTES, xdpf->len + IFH_LEN_BYTES, DMA_TO_DEVICE); - if (dma_mapping_error(lan966x->dev, dma_addr)) { + if (dma_mapping_error(lan966x->dma_dev, dma_addr)) { ret =3D NETDEV_TX_OK; goto out; } @@ -656,7 +656,7 @@ int lan966x_fdma_xmit_xdpf(struct lan966x_port *port, v= oid *ptr, u32 len) lan966x_ifh_set_port(ifh, BIT_ULL(port->chip_port)); =20 dma_addr =3D page_pool_get_dma_addr(page); - dma_sync_single_for_device(lan966x->dev, + dma_sync_single_for_device(lan966x->dma_dev, dma_addr + XDP_PACKET_HEADROOM, len + IFH_LEN_BYTES, DMA_TO_DEVICE); @@ -735,9 +735,9 @@ int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh,= struct net_device *dev) memcpy(skb->data, ifh, IFH_LEN_BYTES); skb_put(skb, 4); =20 - dma_addr =3D dma_map_single(lan966x->dev, skb->data, skb->len, + dma_addr =3D dma_map_single(lan966x->dma_dev, skb->data, skb->len, DMA_TO_DEVICE); - if (dma_mapping_error(lan966x->dev, dma_addr)) { + if (dma_mapping_error(lan966x->dma_dev, dma_addr)) { dev->stats.tx_dropped++; err =3D NETDEV_TX_OK; goto release; @@ -843,7 +843,7 @@ static int lan966x_fdma_reload(struct lan966x *lan966x,= int new_mtu) page_pool_put_full_page(page_pool, old_pages[i][j], false); =20 - fdma_free_coherent(lan966x->dev, &fdma_rx_old); + fdma_free_coherent(lan966x->dma_dev, &fdma_rx_old); =20 page_pool_destroy(page_pool); =20 @@ -993,7 +993,7 @@ int lan966x_fdma_init(struct lan966x *lan966x) =20 err =3D lan966x_fdma_tx_alloc(&lan966x->tx); if (err) { - fdma_free_coherent(lan966x->dev, &lan966x->rx.fdma); + fdma_free_coherent(lan966x->dma_dev, &lan966x->rx.fdma); page_pool_destroy(lan966x->rx.page_pool); return err; } @@ -1015,7 +1015,7 @@ void lan966x_fdma_deinit(struct lan966x *lan966x) napi_disable(&lan966x->napi); =20 lan966x_fdma_rx_free_pages(&lan966x->rx); - fdma_free_coherent(lan966x->dev, &lan966x->rx.fdma); + fdma_free_coherent(lan966x->dma_dev, &lan966x->rx.fdma); page_pool_destroy(lan966x->rx.page_pool); lan966x_fdma_tx_free(&lan966x->tx); } diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.c index 1179a6e127c5..2741f7c9fa4c 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -1081,6 +1082,20 @@ static int lan966x_reset_switch(struct lan966x *lan9= 66x) return 0; } =20 +/* When enumerated over PCIe, dev is a platform device with no + * iommus/dma-ranges of its own, so DMA must target the PCIe endpoint inst= ead. + * The result differs from dev only in that case; lan966x_is_pci() relies = on it. + */ +static struct device *lan966x_get_dma_dev(struct device *dev) +{ + for (struct device *p =3D dev->parent; p; p =3D p->parent) { + if (dev_is_pci(p)) + return p; + } + + return dev; +} + static int lan966x_probe(struct platform_device *pdev) { struct fwnode_handle *ports, *portnp; @@ -1094,6 +1109,7 @@ static int lan966x_probe(struct platform_device *pdev) =20 platform_set_drvdata(pdev, lan966x); lan966x->dev =3D &pdev->dev; + lan966x->dma_dev =3D lan966x_get_dma_dev(lan966x->dev); =20 if (!device_get_mac_address(&pdev->dev, mac_addr)) { ether_addr_copy(lan966x->base_mac, mac_addr); diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.h index 83c361abb789..3f09f8ddf620 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -270,6 +270,9 @@ struct lan966x_skb_cb { struct lan966x { struct device *dev; =20 + /* Device used for DMA; the PCIe endpoint when enumerated over PCIe. */ + struct device *dma_dev; + u8 num_phys_ports; struct lan966x_port **ports; =20 @@ -573,6 +576,13 @@ void lan966x_fdma_wakeup_netdev(struct lan966x *lan966= x); int lan966x_fdma_get_max_frame(struct lan966x *lan966x); int lan966x_qsys_sw_status(struct lan966x *lan966x); =20 +/* dma_dev differs from dev only on the PCIe path. */ +static inline bool lan966x_is_pci(struct lan966x *lan966x) +{ + return IS_ENABLED(CONFIG_MCHP_LAN966X_PCI) && + lan966x->dma_dev !=3D lan966x->dev; +} + int lan966x_lag_port_join(struct lan966x_port *port, struct net_device *brport_dev, struct net_device *bond, --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 EE7454A6CF5; Thu, 24 Sep 2026 19:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279867; cv=none; b=RVXXG1uC8EEKzt0svh7NIfLuIqjGphLrqIh/KePyuXHVfaiVXoRi1Y4C1REkp0Fo+Ahv1LHriQs7FBMUsdGuHnFm6Q7xyFltfHzuFUbKqVAL0OZo+hA+R1jysweQTa9H8njKyRz841oKwk1w0k91p3m1Dt+ridoPZQk+1pKPaMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279867; c=relaxed/simple; bh=p2Q25QixnWjEL0MXvUBXiM484P+nmYzwCzZV7OoKTJE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=eT4AyBGwTVTteqmr71V275ef7I5YjWtcdOVPAfR2z0TXoKTJR71hSLN3HLrAkHcZlnePGpLG08/5m+Vyc3KO6yFS9GIIjJJfKJXdUk8shhIRa2MG0oLhMdc8o1qhVAmyFYGK79hs4VU05I1zYmZ8Jbiu5Zbk4jtK7budJomk0Ng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=JKHTWCXC; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="JKHTWCXC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279862; x=1821815862; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=p2Q25QixnWjEL0MXvUBXiM484P+nmYzwCzZV7OoKTJE=; b=JKHTWCXCo8UvaritGngpPCO5G1cGRbVZqehhO6vrpnjYW3vHB8VOFCg4 pQtx9ff/NRJ0la2sENrqPrFRVf/las1LOxRtGwngrC979h7TIPRoTUd6w yLyRqqh+ss8RzLtF+4MiABLz9JRUOrZ4kUouNUmMGzLattR97ofurPFiP g/AyGAUbsSfqI2P1s9Y/bO42UwvwljWQuDMQ2tUF0sjsAVweGPrNKZcQm +CeKxxF9LtaHCyJWgNWhVPLAXtRXYiO+Ps+pvuHCZKUynG2W49yQU5re2 IULJbT0r/SEhv4ZPXKzrdAX0V03128n3JHnb5bgGVQAnP7pKIvTGhKJSU Q==; X-CSE-ConnectionGUID: YlbJLw4xSB6HhUP/TLzRYQ== X-CSE-MsgGUID: vNkeohRQSpaFCdMdiBUmlA== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="231239482" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:57:37 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:57:36 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:32 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:56 +0200 Subject: [PATCH net-next v8 08/15] net: lan966x: add FDMA ops dispatch for PCIe support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-8-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 Introduce lan966x_fdma_ops to support different FDMA implementations for platform and PCIe. Plumb fdma_init, fdma_deinit, fdma_xmit, fdma_poll and fdma_resize through the ops table, and select the implementation at probe time. Only the platform implementation exists at this point; the PCIe implementation is added in a later patch. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- .../net/ethernet/microchip/lan966x/lan966x_fdma.c | 2 +- .../net/ethernet/microchip/lan966x/lan966x_main.c | 20 +++++++++++++++-= ---- .../net/ethernet/microchip/lan966x/lan966x_main.h | 13 +++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_fdma.c index ae6e5aec5e13..5f46166cbfe4 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -948,7 +948,7 @@ void lan966x_fdma_netdev_init(struct lan966x *lan966x, = struct net_device *dev) return; =20 lan966x->fdma_ndev =3D dev; - netif_napi_add(dev, &lan966x->napi, lan966x_fdma_napi_poll); + netif_napi_add(dev, &lan966x->napi, lan966x->ops->fdma_poll); napi_enable(&lan966x->napi); } =20 diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.c index 2741f7c9fa4c..6e6c08bb8eea 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -27,6 +27,14 @@ =20 #define IO_RANGES 2 =20 +static const struct lan966x_fdma_ops lan966x_fdma_ops =3D { + .fdma_init =3D &lan966x_fdma_init, + .fdma_deinit =3D &lan966x_fdma_deinit, + .fdma_xmit =3D &lan966x_fdma_xmit, + .fdma_poll =3D &lan966x_fdma_napi_poll, + .fdma_resize =3D &lan966x_fdma_change_mtu, +}; + static const struct of_device_id lan966x_match[] =3D { { .compatible =3D "microchip,lan966x-switch" }, { } @@ -392,7 +400,7 @@ static netdev_tx_t lan966x_port_xmit(struct sk_buff *sk= b, =20 spin_lock(&lan966x->tx_lock); if (port->lan966x->fdma) - err =3D lan966x_fdma_xmit(skb, ifh, dev); + err =3D lan966x->ops->fdma_xmit(skb, ifh, dev); else err =3D lan966x_port_ifh_xmit(skb, ifh, dev); spin_unlock(&lan966x->tx_lock); @@ -414,7 +422,7 @@ static int lan966x_port_change_mtu(struct net_device *d= ev, int new_mtu) if (!lan966x->fdma) return 0; =20 - err =3D lan966x_fdma_change_mtu(lan966x); + err =3D lan966x->ops->fdma_resize(lan966x); if (err) { lan_wr(DEV_MAC_MAXLEN_CFG_MAX_LEN_SET(LAN966X_HW_MTU(old_mtu)), lan966x, DEV_MAC_MAXLEN_CFG(port->chip_port)); @@ -1111,6 +1119,8 @@ static int lan966x_probe(struct platform_device *pdev) lan966x->dev =3D &pdev->dev; lan966x->dma_dev =3D lan966x_get_dma_dev(lan966x->dev); =20 + lan966x->ops =3D &lan966x_fdma_ops; + if (!device_get_mac_address(&pdev->dev, mac_addr)) { ether_addr_copy(lan966x->base_mac, mac_addr); } else { @@ -1250,7 +1260,7 @@ static int lan966x_probe(struct platform_device *pdev) if (err) goto cleanup_fdb; =20 - err =3D lan966x_fdma_init(lan966x); + err =3D lan966x->ops->fdma_init(lan966x); if (err) goto cleanup_ptp; =20 @@ -1263,7 +1273,7 @@ static int lan966x_probe(struct platform_device *pdev) return 0; =20 cleanup_fdma: - lan966x_fdma_deinit(lan966x); + lan966x->ops->fdma_deinit(lan966x); =20 cleanup_ptp: lan966x_ptp_deinit(lan966x); @@ -1291,7 +1301,7 @@ static void lan966x_remove(struct platform_device *pd= ev) =20 lan966x_taprio_deinit(lan966x); lan966x_vcap_deinit(lan966x); - lan966x_fdma_deinit(lan966x); + lan966x->ops->fdma_deinit(lan966x); lan966x_cleanup_ports(lan966x); =20 cancel_delayed_work_sync(&lan966x->stats_work); diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.h index 3f09f8ddf620..aab5e53ed059 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -193,6 +193,17 @@ enum vcap_is1_port_sel_rt { VCAP_IS1_PS_RT_FOLLOW_OTHER =3D 7, }; =20 +struct lan966x; + +struct lan966x_fdma_ops { + int (*fdma_init)(struct lan966x *lan966x); + void (*fdma_deinit)(struct lan966x *lan966x); + int (*fdma_xmit)(struct sk_buff *skb, __be32 *ifh, + struct net_device *dev); + int (*fdma_poll)(struct napi_struct *napi, int weight); + int (*fdma_resize)(struct lan966x *lan966x); +}; + struct lan966x_port; =20 struct lan966x_rx { @@ -273,6 +284,8 @@ struct lan966x { /* Device used for DMA; the PCIe endpoint when enumerated over PCIe. */ struct device *dma_dev; =20 + const struct lan966x_fdma_ops *ops; + u8 num_phys_ports; struct lan966x_port **ports; =20 --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 EDB9042E42F; Thu, 24 Sep 2026 19:57:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279870; cv=none; b=rqA2vpFdBMFZ5eOjbHUH4aJ7bfJurIy8SaaO9LmCl4hyl1xS2vVNdSb6BabZY6KQiYR+gaOdv4YBaeT8ExovrSEDCEuUUvueU1zVmxUFSHQpgZxUavOo5nSAfIezp6kJpkM6C6UwanKHbf+g/Cuoy1353q9JecaE42XFRLbnMK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279870; c=relaxed/simple; bh=y0vF6b41qbK3wylCJn2vV8VV9O4lTAJzwOWZxknr6bc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=kbEEppd+1VXsfudPesZkwUcHQTIhQMOx+mbx/45on+OBii1idGhdTCsSSUjbVJpc4UfSCT/PSTUKunjAJ8SRNYxlPLFgKIbv/bevxRWyZtSk4e5jDtx5bqh/uVaAzJkY4P73C5+gPIHdYfoznZcY9B7dwgmB/qt4DVkgkf7iwBk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=vHrJo+1S; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="vHrJo+1S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279867; x=1821815867; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=y0vF6b41qbK3wylCJn2vV8VV9O4lTAJzwOWZxknr6bc=; b=vHrJo+1S0+Q+zseNgiJnrs2VZ3T/2EFkDzarslQFZMv9p8tGcJlRP85m TR+nc57O9rAMdr/phQwB06Y7mjvsBmjn9wYGyFbh4mw8cxmTDgE9+yc8x eKojMLdgqhaqionmYH9mQaGS1yWre1ZlXM+mvnJ0g4DN2RBCObGUz0aBq 2nzJPyiKVq199YzjYYCCVRGCg/3dpkMMIBb3JYnovbx8rn1T55yjWMXpP rseLAq1pGtI/viY8wRYvpN0EqA/naNYPSAIKLRqn5tVdG7+ccoGwshUfA JcKXtF1qthVxUx5FbUD/5T+cTH6uhaeczp61R9CclC6hQGMOrNqdTAicV Q==; X-CSE-ConnectionGUID: VbuQ8EQsTNe24HDwSI+PYw== X-CSE-MsgGUID: BtH5oc4PRL2Y6rxMBv2GYw== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="295533222" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 12:57:42 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex2.mchp-main.com (10.10.87.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.49; Thu, 24 Sep 2026 12:57:41 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:37 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:57 +0200 Subject: [PATCH net-next v8 09/15] net: lan966x: clear FDMA interrupt stickies after switch reset Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-9-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 When in PCI mode, the GCB soft reset issued by the reset controller can latch spurious bits in the FDMA error stickies. The latched bits sit in FDMA_INTR_ERR until the FDMA IRQ is requested later in probe, at which point the handler fires immediately and WARNs. Clear FDMA_ERRORS, FDMA_INTR_ERR and FDMA_INTR_DB right after the switch reset so the FDMA comes out clean and the IRQ handler does not see ghost errors on probe. The clear runs on both the PCI and platform paths. On the platform path it has no effect =E2=80=94 there are no spurious stickies to clear =E2= =80=94 but keeping it unconditional avoids a PCI-specific code path here. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.c index 6e6c08bb8eea..259d81e75907 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -1067,6 +1067,15 @@ static int lan966x_reset_switch(struct lan966x *lan9= 66x) =20 reset_control_reset(switch_reset); =20 + /* When in PCI mode, the GCB soft reset issued by the reset + * controller can latch spurious bits in the FDMA error and + * data-block stickies. Clear them before request_irq hooks up the + * FDMA IRQ line, otherwise the handler fires immediately on probe. + */ + lan_wr(lan_rd(lan966x, FDMA_ERRORS), lan966x, FDMA_ERRORS); + lan_wr(lan_rd(lan966x, FDMA_INTR_ERR), lan966x, FDMA_INTR_ERR); + lan_wr(lan_rd(lan966x, FDMA_INTR_DB), lan966x, FDMA_INTR_DB); + /* Don't reinitialize the switch core, if it is already initialized. In * case it is initialized twice, some pointers inside the queue system * in HW will get corrupted and then after a while the queue system gets --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 668DE4BD780; Thu, 24 Sep 2026 19:57:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279879; cv=none; b=BD8RzeoALHrC69L4fKpLNtqbhAX+O+aTosyBx0od40yr238q+V10DHRevXTgHu47/MlGjdSjR65sfULo1eWzgLMMkJODJMbnaux2al+BUlcinDl3sGkS9TQAdPzIfVV/Gv4mKYOIFj1sVHLUEnT9gaDS4sI0t8nynasyqSjzVGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279879; c=relaxed/simple; bh=pGR7i7vKpqRNc9vGubTZLDoyFujs97jb/TlsjbSuprY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=tMWKpunWZlOVHttdRtVAj4I0rWYPiYWf31rxE0k+jFg8p6DAeA5JW4hzCgeWAG0FiB/UHtj+rjMNAMczzGUoMcTZVTSbQdjUaWLRwkXHPISHx5iffztJW/HyqR1C9idsKZ4SQrrlJRPZYPMVwlBuJciQntj+Qk0mrMfK8J5Izvw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=Wv3CwVUr; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="Wv3CwVUr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279880; x=1821815880; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=pGR7i7vKpqRNc9vGubTZLDoyFujs97jb/TlsjbSuprY=; b=Wv3CwVUrV845WbqVzFPuV5sISOKj4YxTwiiaPLiNKWsU89jm5eq3rFV9 H/vJH/6hOQq6afdJ9LqYGGKMWdeqKgRSM9Afxtf/do2oie3F4AV8bch9A gWs7ZyurNR1fo7iEAOIvuL9fGYqR13A1li6jbi2kHpYkPPGd6SraBSk+W XDyqVTqfmwGPa+hSe2dUkQGZKaiXc4DVLYDb1AflDyjINR/iNyp1yVVSK 33C+tzVsdjyIetlUAUKXaT9jiXYy3ZLFwh9Ir/YwI5voiYqIhkUaXFLIV NFjSje+VKdld2Y7Vzke4r8TkZOj5icj3uXjQFISUAFMrq0BC50Kr3p5gz g==; X-CSE-ConnectionGUID: Bz0N20pjT4mk9+9mP/I8Fw== X-CSE-MsgGUID: 4E5hoKkoQGiJqzDRYAUIlQ== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="74257269" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:57:51 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:57:45 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:42 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:58 +0200 Subject: [PATCH net-next v8 10/15] net: lan966x: add shutdown callback to stop the FDMA on reboot Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-10-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 As a PCIe endpoint, lan966x is not reset by a host reboot: its FDMA channels and interrupt sources stay armed, and the OIC ORs every source into the shared PCIe INTx, asserted before the driver has re-probed. A still-active channel also keeps write access to host memory the next kernel will reuse. Add a shutdown callback that: - frees the ana, xtr and FDMA irqs, masking and unmapping them at the OIC (disable_irq() would leave both set - the OIC has no irq_disable()) - masks the analyzer source, armed unconditionally by lan966x_init() and re-armed by the MAC table's age timer - stops and detaches the netdevs, draining in-flight xmit and clearing netif_device_present() so ndo_open/ndo_change_mtu cannot re-enter the FDMA against a disabled NAPI - disables both FDMA channels and masks their interrupts - unmaps the outbound ATU windows, leaving none armed (the windows are mapped by the PCIe FDMA backend added later in this series) NAPI is skipped when fdma_ndev is unset (a probed switch with no usable port never adds one), and XDP attach cannot re-enter the FDMA either: on PCIe, lan966x_xdp_setup() returns before the page pool reload, which is the only point where it touches the FDMA. Only the PCIe instantiation needs this - the SoC one resets with the chip - so the callback returns early on a platform device; the check is at runtime since .shutdown belongs to the driver, and a PCIe-enabled kernel binds both. FDMA_INTR_ENA persists across a warm reboot, so also restore the full enable in lan966x_fdma_rx_start(), run after both rings are allocated. The PCIe FDMA backend added later in this series starts RX through the same function, so both backends are re-armed from one site. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- .../net/ethernet/microchip/lan966x/lan966x_fdma.c | 4 ++ .../net/ethernet/microchip/lan966x/lan966x_main.c | 56 ++++++++++++++++++= ++++ .../net/ethernet/microchip/lan966x/lan966x_regs.h | 15 ++++++ 3 files changed, 75 insertions(+) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_fdma.c index 5f46166cbfe4..2e8f786d6fee 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -146,6 +146,10 @@ void lan966x_fdma_rx_start(struct lan966x_rx *rx) struct fdma *fdma =3D &rx->fdma; u32 mask; =20 + lan_wr(FDMA_INTR_ENA_INTR_PORT_ENA_SET(GENMASK(1, 0)) | + FDMA_INTR_ENA_INTR_CH_ENA_SET(GENMASK(7, 0)), + lan966x, FDMA_INTR_ENA); + lan_wr(FDMA_CH_CFG_CH_DCB_DB_CNT_SET(fdma->n_dbs) | FDMA_CH_CFG_CH_INTR_DB_EOF_ONLY_SET(1) | FDMA_CH_CFG_CH_INJ_PORT_SET(0) | diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.c index 259d81e75907..024ce9f9916c 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -1324,9 +1324,65 @@ static void lan966x_remove(struct platform_device *p= dev) debugfs_remove_recursive(lan966x->debugfs_root); } =20 +static void lan966x_shutdown(struct platform_device *pdev) +{ + struct lan966x *lan966x =3D platform_get_drvdata(pdev); + + /* As a PCIe endpoint the switch is not reset by the host reboot, so it + * has to be quiesced here: + * + * Free the irqs and mask the sources: no source can assert INTx. + * Disable NAPI: the teardown must not race a poll. + * Stop and detach the netdevs: drains xmit, closes ndo_open and MTU. + * Stop the FDMA channels: waits for the engine to go idle. + * Unmap the ATU windows: revokes the engine's access to host memory. + */ + if (!lan966x_is_pci(lan966x)) + return; + + if (lan966x->xtr_irq > 0) + devm_free_irq(lan966x->dev, lan966x->xtr_irq, lan966x); + if (lan966x->ana_irq > 0) + devm_free_irq(lan966x->dev, lan966x->ana_irq, lan966x); + if (lan966x->fdma_irq > 0) + devm_free_irq(lan966x->dev, lan966x->fdma_irq, lan966x); + + lan_wr(0, lan966x, ANA_ANAINTR); + + if (!lan966x->fdma) + return; + + rtnl_lock(); + + if (lan966x->fdma_ndev) + napi_disable(&lan966x->napi); + + for (int p =3D 0; p < lan966x->num_phys_ports; p++) { + if (!lan966x->ports[p] || !lan966x->ports[p]->dev) + continue; + + netif_tx_disable(lan966x->ports[p]->dev); + netif_device_detach(lan966x->ports[p]->dev); + } + + lan966x_fdma_rx_disable(&lan966x->rx); + lan966x_fdma_tx_disable(&lan966x->tx); + + lan_wr(0, lan966x, FDMA_INTR_ENA); + lan_wr(0, lan966x, FDMA_INTR_DB_ENA); + +#if IS_ENABLED(CONFIG_MCHP_LAN966X_PCI) + fdma_pci_atu_region_unmap(lan966x->rx.fdma.atu_region); + fdma_pci_atu_region_unmap(lan966x->tx.fdma.atu_region); +#endif + + rtnl_unlock(); +} + static struct platform_driver lan966x_driver =3D { .probe =3D lan966x_probe, .remove =3D lan966x_remove, + .shutdown =3D lan966x_shutdown, .driver =3D { .name =3D "lan966x-switch", .of_match_table =3D lan966x_match, diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h b/driver= s/net/ethernet/microchip/lan966x/lan966x_regs.h index 4b553927d2e0..aba0d36ae6b5 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h @@ -1039,6 +1039,21 @@ enum lan966x_target { /* FDMA:FDMA:FDMA_INTR_ERR */ #define FDMA_INTR_ERR __REG(TARGET_FDMA, 0, 1, 8, 0, 1, 428, 4= 00, 0, 1, 4) =20 +/* FDMA:FDMA:FDMA_INTR_ENA */ +#define FDMA_INTR_ENA __REG(TARGET_FDMA, 0, 1, 8, 0, 1, 428, 4= 04, 0, 1, 4) + +#define FDMA_INTR_ENA_INTR_PORT_ENA GENMASK(9, 8) +#define FDMA_INTR_ENA_INTR_PORT_ENA_SET(x)\ + FIELD_PREP(FDMA_INTR_ENA_INTR_PORT_ENA, x) +#define FDMA_INTR_ENA_INTR_PORT_ENA_GET(x)\ + FIELD_GET(FDMA_INTR_ENA_INTR_PORT_ENA, x) + +#define FDMA_INTR_ENA_INTR_CH_ENA GENMASK(7, 0) +#define FDMA_INTR_ENA_INTR_CH_ENA_SET(x)\ + FIELD_PREP(FDMA_INTR_ENA_INTR_CH_ENA, x) +#define FDMA_INTR_ENA_INTR_CH_ENA_GET(x)\ + FIELD_GET(FDMA_INTR_ENA_INTR_CH_ENA, x) + /* FDMA:FDMA:FDMA_ERRORS */ #define FDMA_ERRORS __REG(TARGET_FDMA, 0, 1, 8, 0, 1, 428, 4= 12, 0, 1, 4) =20 --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 5B5CF4CB8C2; Thu, 24 Sep 2026 19:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279883; cv=none; b=NyXDSfxCnW3hiyPCK8PxNjl/8YSFWOgzD8WSBRJAxFdnLWhkQNv5+FUmGTr9oS1xAgr1eWobc04d+9H+YHRuc55iILV5eJQamhZc4gVkRDDDh7QHoXR5tEGUPl46QDuLph/ZvyUOUBBhq2dIb51VWrFt4Wq7BPmmY7ipRO7na/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279883; c=relaxed/simple; bh=ok4w000mb/QLspwAwhNlv80NTSgWtXGvdfSXh1AK2kg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=tMOr0FQpyb0RPzEuwq5MNy80LdSJYhpklF0qXx8eK8sZfNzZ1VYfzSTQZmto9Hl66/yg3OaZGJlLxzXin/0P6seM3thsxaQ+xuiu93TDHudnnHaKKf6/rMoq7DZpUTfkMEMI6/IeP87VAkEfm7xa0mIdL0RRNz4Kf7ekCl7yK/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=WPoCze1A; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="WPoCze1A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279877; x=1821815877; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=ok4w000mb/QLspwAwhNlv80NTSgWtXGvdfSXh1AK2kg=; b=WPoCze1Atb58uNE5puAs8ncWrePgWukEp5XXvFLQpQTMhOXhsJd3zU0R 9Cs4iZnB10SvbmbJz80Ny+jALCfdHt2zX7D1KqGCeUCnBuzq6Us7JZXw8 H2EW93uRzm+3ZPq70ZN5vhdd+hFf6vCquIS1uEwQ/5PlubO7gj6KgefSB q9BTFDyS8Flltr64wd1/4/KdCzlD+D6tUEeMPzA81DWrCh6XvpJzMKVpF luCeudjcslxhsIdIxv3QqCUQPThVMC4hmJXfxjfQuL4Ra6ZcYK7gVNIJF NRpxP6Lf1Drx93209uCu3z5PgPFuCQtN0b9TrtZaAkWn1PcXcJgMnkkYB A==; X-CSE-ConnectionGUID: Mj2inXOiQ+iRpj7pPIWAPw== X-CSE-MsgGUID: 4zpzypQAR1ijbYkRlXD8Aw== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="63176288" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:57:50 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:57:50 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:46 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:56:59 +0200 Subject: [PATCH net-next v8 11/15] net: lan966x: add PCIe FDMA support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-11-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 Add PCIe FDMA support for lan966x. The PCIe FDMA path uses contiguous DMA buffers mapped through the endpoint's ATU, with memcpy-based frame transfer instead of per-page DMA mappings. With PCIe FDMA, throughput increases from ~33 Mbps (register-based I/O) to ~620 Mbps on an Intel x86 host with a lan966x PCIe card. XDP is not supported on this path yet, so do not advertise xdp_features and reject program attach for PCIe instances. Tested-by: Herve Codina Signed-off-by: Daniel Machon --- drivers/net/ethernet/microchip/lan966x/Makefile | 4 + .../ethernet/microchip/lan966x/lan966x_fdma_pci.c | 421 +++++++++++++++++= ++++ .../net/ethernet/microchip/lan966x/lan966x_main.c | 11 +- .../net/ethernet/microchip/lan966x/lan966x_main.h | 7 + .../net/ethernet/microchip/lan966x/lan966x_regs.h | 10 + .../net/ethernet/microchip/lan966x/lan966x_xdp.c | 6 + 6 files changed, 456 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/Makefile b/drivers/net/= ethernet/microchip/lan966x/Makefile index 4cdbe263502c..02db4d4d9826 100644 --- a/drivers/net/ethernet/microchip/lan966x/Makefile +++ b/drivers/net/ethernet/microchip/lan966x/Makefile @@ -18,6 +18,10 @@ lan966x-switch-objs :=3D lan966x_main.o lan966x_phylink= .o lan966x_port.o \ lan966x-switch-$(CONFIG_LAN966X_DCB) +=3D lan966x_dcb.o lan966x-switch-$(CONFIG_DEBUG_FS) +=3D lan966x_vcap_debugfs.o =20 +ifneq ($(CONFIG_MCHP_LAN966X_PCI),) +lan966x-switch-y +=3D lan966x_fdma_pci.o +endif + # Provide include files ccflags-y +=3D -I$(srctree)/drivers/net/ethernet/microchip/vcap ccflags-y +=3D -I$(srctree)/drivers/net/ethernet/microchip/fdma diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c b/dr= ivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c new file mode 100644 index 000000000000..bccd1b8590d7 --- /dev/null +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c @@ -0,0 +1,421 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include "fdma_api.h" +#include "lan966x_main.h" + +static int lan966x_fdma_pci_dataptr_cb(struct fdma *fdma, int dcb, int db, + u64 *dataptr) +{ + u64 addr; + + addr =3D fdma_dataptr_dma_addr_contiguous(fdma, dcb, db); + + *dataptr =3D fdma_pci_atu_translate_addr(fdma->atu_region, addr); + + return 0; +} + +static int lan966x_fdma_pci_nextptr_cb(struct fdma *fdma, int dcb, u64 *ne= xtptr) +{ + u64 addr; + + fdma_nextptr_cb(fdma, dcb, &addr); + + *nextptr =3D fdma_pci_atu_translate_addr(fdma->atu_region, addr); + + return 0; +} + +/* Stop the TX queues on every port, so nothing feeds the injection channel + * while it is torn down or resized. + */ +static void lan966x_fdma_tx_disable_netdev(struct lan966x *lan966x) +{ + struct lan966x_port *port; + int i; + + for (i =3D 0; i < lan966x->num_phys_ports; ++i) { + port =3D lan966x->ports[i]; + if (!port) + continue; + + netif_tx_disable(port->dev); + } +} + +static int lan966x_fdma_pci_rx_alloc(struct lan966x_rx *rx) +{ + struct lan966x *lan966x =3D rx->lan966x; + struct fdma *fdma =3D &rx->fdma; + int err; + + err =3D fdma_alloc_coherent_and_map(lan966x->dma_dev, fdma, + &lan966x->atu); + if (err) + return err; + + err =3D fdma_dcbs_init(fdma, + FDMA_DCB_INFO_DATAL(fdma->db_size - XDP_PACKET_HEADROOM), + FDMA_DCB_STATUS_INTR); + if (err) { + fdma_free_coherent_and_unmap(lan966x->dma_dev, fdma); + return err; + } + + lan966x_fdma_llp_configure(lan966x, + fdma->atu_region->base_addr, + fdma->channel_id); + + return 0; +} + +static int lan966x_fdma_pci_tx_alloc(struct lan966x_tx *tx) +{ + struct lan966x *lan966x =3D tx->lan966x; + struct fdma *fdma =3D &tx->fdma; + int err; + + err =3D fdma_alloc_coherent_and_map(lan966x->dma_dev, fdma, + &lan966x->atu); + if (err) + return err; + + err =3D fdma_dcbs_init(fdma, + FDMA_DCB_INFO_DATAL(fdma->db_size), + FDMA_DCB_STATUS_DONE); + if (err) { + fdma_free_coherent_and_unmap(lan966x->dma_dev, fdma); + return err; + } + + lan966x_fdma_llp_configure(lan966x, + fdma->atu_region->base_addr, + fdma->channel_id); + + return 0; +} + +static int lan966x_fdma_pci_get_next_dcb(struct fdma *fdma) +{ + struct fdma_db *db; + + for (int i =3D 0; i < fdma->n_dcbs; i++) { + db =3D fdma_db_get(fdma, i, 0); + + if (!fdma_db_is_done(db)) + continue; + if (fdma_is_last(fdma, &fdma->dcbs[i])) + continue; + + return i; + } + + return -ENOSPC; +} + +/* TX slot layout (sizes in bytes): + * + * +---------------------+-----+---------+-----+ + * | XDP_PACKET_HEADROOM | IFH | payload | FCS | + * | 256 | 28 | len | 4 | + * +---------------------+-----+---------+-----+ + * |<---------------- db_size ----------------->| + * + * Return true if the frame plus required overhead fits. + */ +static bool lan966x_fdma_pci_tx_size_fits(struct fdma *fdma, u32 len) +{ + return XDP_PACKET_HEADROOM + IFH_LEN_BYTES + len + ETH_FCS_LEN <=3D + fdma->db_size; +} + +/* Return true if blockl is a valid RX frame size. */ +static bool lan966x_fdma_pci_rx_size_fits(struct fdma *fdma, u32 blockl) +{ + return blockl >=3D IFH_LEN_BYTES + ETH_HLEN + ETH_FCS_LEN && + blockl <=3D fdma->db_size - XDP_PACKET_HEADROOM; +} + +static int lan966x_fdma_pci_rx_check_frame(struct lan966x_rx *rx, u64 *src= _port) +{ + struct lan966x *lan966x =3D rx->lan966x; + struct fdma *fdma =3D &rx->fdma; + struct lan966x_port *port; + struct fdma_db *db; + void *virt_addr; + u32 blockl; + + /* virt_addr points to the IFH. */ + virt_addr =3D fdma_dataptr_virt_addr_contiguous(fdma, + fdma->dcb_index, + fdma->db_index); + + lan966x_ifh_get_src_port(virt_addr, src_port); + + if (*src_port >=3D lan966x->num_phys_ports) + return FDMA_ERROR; + + port =3D lan966x->ports[*src_port]; + if (!port) + return FDMA_ERROR; + + db =3D fdma_db_next_get(fdma); + + /* BLOCKL is a 16-bit HW-populated field; reject obviously-bad + * values before they feed memcpy/XDP sizes. + */ + blockl =3D fdma_db_len_get(db); + if (!lan966x_fdma_pci_rx_size_fits(fdma, blockl)) + return FDMA_ERROR; + + return FDMA_PASS; +} + +static struct sk_buff *lan966x_fdma_pci_rx_get_frame(struct lan966x_rx *rx, + u64 src_port) +{ + struct lan966x *lan966x =3D rx->lan966x; + struct fdma *fdma =3D &rx->fdma; + struct sk_buff *skb; + struct fdma_db *db; + u32 data_len; + + /* Get the received frame and create an SKB for it. */ + db =3D fdma_db_next_get(fdma); + data_len =3D fdma_db_len_get(db); + + skb =3D napi_alloc_skb(&lan966x->napi, data_len); + if (unlikely(!skb)) + return NULL; + + memcpy(skb->data, + fdma_dataptr_virt_addr_contiguous(fdma, + fdma->dcb_index, + fdma->db_index), + data_len); + + skb_put(skb, data_len); + + skb->dev =3D lan966x->ports[src_port]->dev; + skb_pull(skb, IFH_LEN_BYTES); + + skb_trim(skb, skb->len - ETH_FCS_LEN); + + skb->protocol =3D eth_type_trans(skb, skb->dev); + + if (lan966x->bridge_mask & BIT(src_port)) { + skb->offload_fwd_mark =3D 1; + + skb_reset_network_header(skb); + if (!lan966x_hw_offload(lan966x, src_port, skb)) + skb->offload_fwd_mark =3D 0; + } + + skb->dev->stats.rx_bytes +=3D skb->len; + skb->dev->stats.rx_packets++; + + return skb; +} + +static int lan966x_fdma_pci_xmit(struct sk_buff *skb, __be32 *ifh, + struct net_device *dev) +{ + struct lan966x_port *port =3D netdev_priv(dev); + struct lan966x *lan966x =3D port->lan966x; + struct lan966x_tx *tx =3D &lan966x->tx; + struct fdma *fdma =3D &tx->fdma; + int next_to_use; + void *virt_addr; + + next_to_use =3D lan966x_fdma_pci_get_next_dcb(fdma); + + if (next_to_use < 0) { + netif_stop_queue(dev); + return NETDEV_TX_BUSY; + } + + if (skb_put_padto(skb, ETH_ZLEN)) { + dev->stats.tx_dropped++; + return NETDEV_TX_OK; + } + + if (!lan966x_fdma_pci_tx_size_fits(fdma, skb->len)) { + dev_kfree_skb_any(skb); + dev->stats.tx_dropped++; + return NETDEV_TX_OK; + } + + skb_tx_timestamp(skb); + + /* virt_addr points to the IFH. */ + virt_addr =3D fdma_dataptr_virt_addr_contiguous(fdma, next_to_use, 0); + memcpy(virt_addr, ifh, IFH_LEN_BYTES); + memcpy(virt_addr + IFH_LEN_BYTES, skb->data, skb->len); + + /* Order frame write before DCB status write below. */ + dma_wmb(); + + fdma_dcb_add(fdma, + next_to_use, + 0, + FDMA_DCB_STATUS_INTR | + FDMA_DCB_STATUS_SOF | + FDMA_DCB_STATUS_EOF | + FDMA_DCB_STATUS_BLOCKO(0) | + FDMA_DCB_STATUS_BLOCKL(IFH_LEN_BYTES + skb->len + ETH_FCS_LEN)); + + /* Start the transmission. */ + lan966x_fdma_tx_start(tx); + + dev->stats.tx_bytes +=3D skb->len; + dev->stats.tx_packets++; + + /* Safe to free: PTP is not supported on the PCIe path yet, + * so lan966x->ptp is always 0 here. + */ + dev_consume_skb_any(skb); + + return NETDEV_TX_OK; +} + +static int lan966x_fdma_pci_napi_poll(struct napi_struct *napi, int weight) +{ + struct lan966x *lan966x =3D container_of(napi, struct lan966x, napi); + struct lan966x_rx *rx =3D &lan966x->rx; + struct fdma *fdma =3D &rx->fdma; + int dcb_reload, old_dcb; + struct sk_buff *skb; + int counter =3D 0; + u64 src_port; + + /* Wake any stopped TX queues if a TX DCB is available. */ + spin_lock(&lan966x->tx_lock); + if (lan966x_fdma_pci_get_next_dcb(&lan966x->tx.fdma) >=3D 0) + lan966x_fdma_wakeup_netdev(lan966x); + spin_unlock(&lan966x->tx_lock); + + dcb_reload =3D fdma->dcb_index; + + /* Get all received skbs. */ + while (counter < weight) { + if (!fdma_has_frames(fdma)) + break; + /* Order DONE read before DCB/frame reads below. */ + dma_rmb(); + counter++; + switch (lan966x_fdma_pci_rx_check_frame(rx, &src_port)) { + case FDMA_PASS: + break; + case FDMA_ERROR: + /* No rx_dropped increment here because src_port is + * invalid. + */ + fdma_dcb_advance(fdma); + continue; + } + skb =3D lan966x_fdma_pci_rx_get_frame(rx, src_port); + fdma_dcb_advance(fdma); + if (!skb) { + lan966x->ports[src_port]->dev->stats.rx_dropped++; + continue; + } + + napi_gro_receive(&lan966x->napi, skb); + } + while (dcb_reload !=3D fdma->dcb_index) { + old_dcb =3D dcb_reload; + dcb_reload++; + dcb_reload &=3D fdma->n_dcbs - 1; + + fdma_dcb_add(fdma, + old_dcb, + FDMA_DCB_INFO_DATAL(fdma->db_size - XDP_PACKET_HEADROOM), + FDMA_DCB_STATUS_INTR); + + lan966x_fdma_rx_reload(rx); + } + + if (counter < weight && napi_complete_done(napi, counter)) + lan_wr(0xff, lan966x, FDMA_INTR_DB_ENA); + + return counter; +} + +static int lan966x_fdma_pci_init(struct lan966x *lan966x) +{ + struct fdma *rx_fdma =3D &lan966x->rx.fdma; + struct fdma *tx_fdma =3D &lan966x->tx.fdma; + int err; + + if (!lan966x->fdma) + return 0; + + lan_wr(FDMA_CTRL_NRESET_SET(0), lan966x, FDMA_CTRL); + lan_wr(FDMA_CTRL_NRESET_SET(1), lan966x, FDMA_CTRL); + + fdma_pci_atu_init(&lan966x->atu, lan966x->regs[TARGET_PCIE_DBI]); + + lan966x->rx.lan966x =3D lan966x; + lan966x->rx.max_mtu =3D lan966x_fdma_get_max_frame(lan966x); + rx_fdma->channel_id =3D FDMA_XTR_CHANNEL; + rx_fdma->n_dcbs =3D FDMA_DCB_MAX; + rx_fdma->n_dbs =3D FDMA_RX_DCB_MAX_DBS; + rx_fdma->priv =3D lan966x; + rx_fdma->db_size =3D FDMA_PCI_DB_SIZE(lan966x->rx.max_mtu); + rx_fdma->size =3D fdma_get_size_contiguous(rx_fdma); + rx_fdma->ops.nextptr_cb =3D &lan966x_fdma_pci_nextptr_cb; + rx_fdma->ops.dataptr_cb =3D &lan966x_fdma_pci_dataptr_cb; + + lan966x->tx.lan966x =3D lan966x; + tx_fdma->channel_id =3D FDMA_INJ_CHANNEL; + tx_fdma->n_dcbs =3D FDMA_DCB_MAX; + tx_fdma->n_dbs =3D FDMA_TX_DCB_MAX_DBS; + tx_fdma->priv =3D lan966x; + tx_fdma->db_size =3D FDMA_PCI_DB_SIZE(lan966x->rx.max_mtu); + tx_fdma->size =3D fdma_get_size_contiguous(tx_fdma); + tx_fdma->ops.nextptr_cb =3D &lan966x_fdma_pci_nextptr_cb; + tx_fdma->ops.dataptr_cb =3D &lan966x_fdma_pci_dataptr_cb; + + err =3D lan966x_fdma_pci_rx_alloc(&lan966x->rx); + if (err) + return err; + + err =3D lan966x_fdma_pci_tx_alloc(&lan966x->tx); + if (err) { + fdma_free_coherent_and_unmap(lan966x->dma_dev, rx_fdma); + return err; + } + + lan966x_fdma_rx_start(&lan966x->rx); + + return 0; +} + +static int lan966x_fdma_pci_resize(struct lan966x *lan966x) +{ + return -EOPNOTSUPP; +} + +static void lan966x_fdma_pci_deinit(struct lan966x *lan966x) +{ + if (!lan966x->fdma) + return; + + if (lan966x->fdma_ndev) + napi_disable(&lan966x->napi); + + lan966x_fdma_tx_disable_netdev(lan966x); + lan966x_fdma_rx_disable(&lan966x->rx); + lan966x_fdma_tx_disable(&lan966x->tx); + + fdma_free_coherent_and_unmap(lan966x->dma_dev, &lan966x->rx.fdma); + fdma_free_coherent_and_unmap(lan966x->dma_dev, &lan966x->tx.fdma); +} + +const struct lan966x_fdma_ops lan966x_fdma_pci_ops =3D { + .fdma_init =3D &lan966x_fdma_pci_init, + .fdma_deinit =3D &lan966x_fdma_pci_deinit, + .fdma_xmit =3D &lan966x_fdma_pci_xmit, + .fdma_poll =3D &lan966x_fdma_pci_napi_poll, + .fdma_resize =3D &lan966x_fdma_pci_resize, +}; diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.c index 024ce9f9916c..de2202786826 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -50,6 +50,7 @@ struct lan966x_main_io_resource { static const struct lan966x_main_io_resource lan966x_main_iomap[] =3D { { TARGET_CPU, 0xc0000, 0 }, /* 0xe00c0000 */ { TARGET_FDMA, 0xc0400, 0 }, /* 0xe00c0400 */ + { TARGET_PCIE_DBI, 0x400000, 0 }, /* 0xe0400000 */ { TARGET_ORG, 0, 1 }, /* 0xe2000000 */ { TARGET_GCB, 0x4000, 1 }, /* 0xe2004000 */ { TARGET_QS, 0x8000, 1 }, /* 0xe2008000 */ @@ -873,7 +874,8 @@ static int lan966x_probe_port(struct lan966x *lan966x, = u32 p, =20 port->phylink =3D phylink; =20 - if (lan966x->fdma) + /* XDP is not supported on the PCIe FDMA path. */ + if (lan966x->fdma && !lan966x_is_pci(lan966x)) dev->xdp_features =3D NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | NETDEV_XDP_ACT_NDO_XMIT; @@ -1128,7 +1130,8 @@ static int lan966x_probe(struct platform_device *pdev) lan966x->dev =3D &pdev->dev; lan966x->dma_dev =3D lan966x_get_dma_dev(lan966x->dev); =20 - lan966x->ops =3D &lan966x_fdma_ops; + lan966x->ops =3D lan966x_is_pci(lan966x) ? &lan966x_fdma_pci_ops : + &lan966x_fdma_ops; =20 if (!device_get_mac_address(&pdev->dev, mac_addr)) { ether_addr_copy(lan966x->base_mac, mac_addr); @@ -1187,7 +1190,9 @@ static int lan966x_probe(struct platform_device *pdev) if (err) return dev_err_probe(&pdev->dev, err, "Unable to use ptp irq"); =20 - lan966x->ptp =3D 1; + /* PTP is not supported on the PCIe path yet. */ + if (!lan966x_is_pci(lan966x)) + lan966x->ptp =3D 1; } =20 lan966x->fdma_irq =3D platform_get_irq_byname(pdev, "fdma"); diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.h index aab5e53ed059..16bc28c8f11f 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -17,6 +17,7 @@ #include =20 #include +#include #include #include =20 @@ -291,6 +292,10 @@ struct lan966x { =20 void __iomem *regs[NUM_TARGETS]; =20 +#if IS_ENABLED(CONFIG_MCHP_LAN966X_PCI) + struct fdma_pci_atu atu; +#endif + int shared_queue_sz; =20 u8 base_mac[ETH_ALEN]; @@ -589,6 +594,8 @@ void lan966x_fdma_wakeup_netdev(struct lan966x *lan966x= ); int lan966x_fdma_get_max_frame(struct lan966x *lan966x); int lan966x_qsys_sw_status(struct lan966x *lan966x); =20 +extern const struct lan966x_fdma_ops lan966x_fdma_pci_ops; + /* dma_dev differs from dev only on the PCIe path. */ static inline bool lan966x_is_pci(struct lan966x *lan966x) { diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h b/driver= s/net/ethernet/microchip/lan966x/lan966x_regs.h index aba0d36ae6b5..4778ea217673 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_regs.h @@ -20,6 +20,7 @@ enum lan966x_target { TARGET_FDMA =3D 21, TARGET_GCB =3D 27, TARGET_ORG =3D 36, + TARGET_PCIE_DBI =3D 40, TARGET_PTP =3D 41, TARGET_QS =3D 42, TARGET_QSYS =3D 46, @@ -1009,6 +1010,15 @@ enum lan966x_target { #define FDMA_CH_CFG_CH_MEM_GET(x)\ FIELD_GET(FDMA_CH_CFG_CH_MEM, x) =20 +/* FDMA:FDMA:FDMA_CTRL */ +#define FDMA_CTRL __REG(TARGET_FDMA, 0, 1, 8, 0, 1, 428, 4= 24, 0, 1, 4) + +#define FDMA_CTRL_NRESET BIT(0) +#define FDMA_CTRL_NRESET_SET(x)\ + FIELD_PREP(FDMA_CTRL_NRESET, x) +#define FDMA_CTRL_NRESET_GET(x)\ + FIELD_GET(FDMA_CTRL_NRESET, x) + /* FDMA:FDMA:FDMA_PORT_CTRL */ #define FDMA_PORT_CTRL(r) __REG(TARGET_FDMA, 0, 1, 8, 0, 1, 428, 3= 76, r, 2, 4) =20 diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c b/drivers= /net/ethernet/microchip/lan966x/lan966x_xdp.c index 9ee61db8690b..e63634887f64 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c @@ -20,6 +20,12 @@ static int lan966x_xdp_setup(struct net_device *dev, str= uct netdev_bpf *xdp) return -EOPNOTSUPP; } =20 + if (lan966x_is_pci(lan966x)) { + NL_SET_ERR_MSG_MOD(xdp->extack, + "XDP is not supported on the PCIe FDMA path"); + return -EOPNOTSUPP; + } + old_xdp =3D lan966x_xdp_present(lan966x); old_prog =3D xchg(&port->xdp_prog, xdp->prog); new_xdp =3D lan966x_xdp_present(lan966x); --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 5E4B34E3EDA; Thu, 24 Sep 2026 19:57:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279887; cv=none; b=Dz198Tvy9rot/TDj1sPOkoWlovuAfM5GfSlSOY15ezKLbqIwSNZLwDbjgcN1s5IxAMDu3Nr4enL4R8PvaKbf3vZRwdfBUtK0rpSdZhjT8ffYRXho9pR+2Rje57YQOT6pgLYAiUCEyKhJsDDuNMcHklKSLC5Ju/TJs2lz721gUsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279887; c=relaxed/simple; bh=yHAHGaIw7xWHbLsBatGbI8K42D/OICCxEX464FUuDgA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=PtDhbbmp/zP2DqCMwR5dsIBgcMgb0whtqstv7FTFYgw71EPTUAjg898T2MkQVwfg9P5/t5vc/t0zTO429se+72Tp3HMjf8KalmyV7VoxD3TY4k5pZqvg1rIdpNAm8t0eu1w/Gu2uewbPpwTvlCS6+94NleaO1uFQUcnxZLAylT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=Z8Apogkw; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="Z8Apogkw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279882; x=1821815882; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=yHAHGaIw7xWHbLsBatGbI8K42D/OICCxEX464FUuDgA=; b=Z8Apogkw7VFMalbmq8KLVXAPtf93ERRDQPMKK+tUMZPsR8YUupneu1Ri hTmLt3wbSt2UdcKg1Lk+9V4Rv/7on1F5TJmnxL9RcBQTjL0NpbQ2d4lWC EK7+MdOhsooUt2iRb4Q+TbHl/vRiIt+Ga1f9WkDp+mtwVvdfMTQjW0nD3 MvU9Q6ar9SyI2ItouuimUCg5/IG95sqN8Z+e1xfV/eduLjl9nMR5sJWd+ aAaodKmB8Aylmv+unHB7UvyJYOwwAaA+7PAGp7jyCjN0BFtUWjKlHXfZ1 eDMVbF/sIIXJFa52RoQmO+oFO5JsRmjdTCTCEYR72J+d3m9SRpoqxzzyp Q==; X-CSE-ConnectionGUID: upnDy4IjTCS1vuGFhbKIug== X-CSE-MsgGUID: x+QhZdkbQGem6zDsufeN5g== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="295533230" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:57:56 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:57:54 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:50 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:57:00 +0200 Subject: [PATCH net-next v8 12/15] net: lan966x: add PCIe FDMA MTU change support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-12-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 Add MTU change support for the PCIe FDMA path: on an MTU change, the contiguous ATU-mapped RX and TX buffers are reallocated at the new size, falling back to the existing buffers on failure. Cap the PCIe DCB ring at 256 (FDMA_PCI_DCB_MAX): 512 DCBs would overflow MAX_PAGE_ORDER at jumbo MTU. The ring must fit one MAX_PAGE_ORDER block after ATU padding, and db_size is handed to the FDMA in the 16-bit DCB DATAL field. Advertise the resulting limit in dev->max_mtu (FDMA_PCI_MAX_MTU) when the FDMA is in use - a switch with no "fdma" interrupt named uses the unconstrained register-based path instead, so the cap is gated on lan966x->fdma, not lan966x_is_pci() alone. On a 4KB-page, MAX_PAGE_ORDER=3D10 build this is MTU 15498; the overhead is shared with lan966x_fdma_get_max_frame() via FDMA_OVERHEAD. Skip the resize until lan966x_fdma_pci_init() has built the rings; it runs after the netdevs register and sizes them from DEV_MAC_MAXLEN_CFG, already programmed by the caller. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- .../net/ethernet/microchip/lan966x/lan966x_fdma.c | 6 +- .../ethernet/microchip/lan966x/lan966x_fdma_pci.c | 153 +++++++++++++++++= +++- .../net/ethernet/microchip/lan966x/lan966x_main.c | 3 +- .../net/ethernet/microchip/lan966x/lan966x_main.h | 28 ++++ 4 files changed, 181 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_fdma.c index 2e8f786d6fee..a7940eca5df3 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -890,11 +890,7 @@ static int lan966x_fdma_reload(struct lan966x *lan966x= , int new_mtu) =20 int lan966x_fdma_get_max_frame(struct lan966x *lan966x) { - return lan966x_fdma_get_max_mtu(lan966x) + - IFH_LEN_BYTES + - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + - VLAN_HLEN * 2 + - XDP_PACKET_HEADROOM; + return lan966x_fdma_get_max_mtu(lan966x) + FDMA_OVERHEAD; } =20 static int __lan966x_fdma_reload(struct lan966x *lan966x, int max_mtu) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c b/dr= ivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c index bccd1b8590d7..7185e65dda43 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c @@ -358,7 +358,7 @@ static int lan966x_fdma_pci_init(struct lan966x *lan966= x) lan966x->rx.lan966x =3D lan966x; lan966x->rx.max_mtu =3D lan966x_fdma_get_max_frame(lan966x); rx_fdma->channel_id =3D FDMA_XTR_CHANNEL; - rx_fdma->n_dcbs =3D FDMA_DCB_MAX; + rx_fdma->n_dcbs =3D FDMA_PCI_DCB_MAX; rx_fdma->n_dbs =3D FDMA_RX_DCB_MAX_DBS; rx_fdma->priv =3D lan966x; rx_fdma->db_size =3D FDMA_PCI_DB_SIZE(lan966x->rx.max_mtu); @@ -368,7 +368,7 @@ static int lan966x_fdma_pci_init(struct lan966x *lan966= x) =20 lan966x->tx.lan966x =3D lan966x; tx_fdma->channel_id =3D FDMA_INJ_CHANNEL; - tx_fdma->n_dcbs =3D FDMA_DCB_MAX; + tx_fdma->n_dcbs =3D FDMA_PCI_DCB_MAX; tx_fdma->n_dbs =3D FDMA_TX_DCB_MAX_DBS; tx_fdma->priv =3D lan966x; tx_fdma->db_size =3D FDMA_PCI_DB_SIZE(lan966x->rx.max_mtu); @@ -391,9 +391,156 @@ static int lan966x_fdma_pci_init(struct lan966x *lan9= 66x) return 0; } =20 +/* Reset existing rx and tx buffers. */ +static void lan966x_fdma_pci_reset_mem(struct lan966x *lan966x) +{ + struct lan966x_rx *rx =3D &lan966x->rx; + struct lan966x_tx *tx =3D &lan966x->tx; + + memset(rx->fdma.dcbs, 0, rx->fdma.size); + memset(tx->fdma.dcbs, 0, tx->fdma.size); + + fdma_dcbs_init(&rx->fdma, + FDMA_DCB_INFO_DATAL(rx->fdma.db_size - XDP_PACKET_HEADROOM), + FDMA_DCB_STATUS_INTR); + + fdma_dcbs_init(&tx->fdma, + FDMA_DCB_INFO_DATAL(tx->fdma.db_size), + FDMA_DCB_STATUS_DONE); + + lan966x_fdma_llp_configure(lan966x, + tx->fdma.atu_region->base_addr, + tx->fdma.channel_id); + lan966x_fdma_llp_configure(lan966x, + rx->fdma.atu_region->base_addr, + rx->fdma.channel_id); +} + +/* Wake all TX queues on every port (undoes lan966x_fdma_tx_disable_netdev= ). */ +static void lan966x_fdma_pci_wakeup_netdev(struct lan966x *lan966x) +{ + for (int i =3D 0; i < lan966x->num_phys_ports; ++i) { + struct lan966x_port *port =3D lan966x->ports[i]; + + if (port) + netif_tx_wake_all_queues(port->dev); + } +} + +static int lan966x_fdma_pci_reload(struct lan966x *lan966x, int new_mtu) +{ + struct fdma tx_fdma_old =3D lan966x->tx.fdma; + struct fdma rx_fdma_old =3D lan966x->rx.fdma; + u32 old_mtu =3D lan966x->rx.max_mtu; + int err; + + napi_disable(&lan966x->napi); + lan966x_fdma_tx_disable_netdev(lan966x); + lan966x_fdma_rx_disable(&lan966x->rx); + lan966x_fdma_tx_disable(&lan966x->tx); + + lan966x->rx.max_mtu =3D new_mtu; + + /* Must be NULL'ed in order to realloc them. */ + lan966x->rx.fdma.atu_region =3D NULL; + lan966x->tx.fdma.atu_region =3D NULL; + + lan966x->tx.fdma.db_size =3D FDMA_PCI_DB_SIZE(lan966x->rx.max_mtu); + lan966x->tx.fdma.size =3D fdma_get_size_contiguous(&lan966x->tx.fdma); + lan966x->rx.fdma.db_size =3D FDMA_PCI_DB_SIZE(lan966x->rx.max_mtu); + lan966x->rx.fdma.size =3D fdma_get_size_contiguous(&lan966x->rx.fdma); + + err =3D lan966x_fdma_pci_rx_alloc(&lan966x->rx); + if (err) + goto restore; + + err =3D lan966x_fdma_pci_tx_alloc(&lan966x->tx); + if (err) { + fdma_free_coherent_and_unmap(lan966x->dma_dev, + &lan966x->rx.fdma); + goto restore; + } + + /* Free and unmap old memory. */ + fdma_free_coherent_and_unmap(lan966x->dma_dev, &rx_fdma_old); + fdma_free_coherent_and_unmap(lan966x->dma_dev, &tx_fdma_old); + + /* Order matters: napi_enable() must precede the wakes, or a TX that + * completes first clears FDMA_INTR_DB_ENA with nothing scheduled to + * restore it, leaving RX dead until the next reload. + */ + napi_enable(&lan966x->napi); + lan966x_fdma_rx_start(&lan966x->rx); + lan966x_fdma_pci_wakeup_netdev(lan966x); + + return err; +restore: + + /* No new buffers are allocated at this point. Use the old buffers, + * but reset them before starting the FDMA again. + */ + + memcpy(&lan966x->tx.fdma, &tx_fdma_old, sizeof(struct fdma)); + memcpy(&lan966x->rx.fdma, &rx_fdma_old, sizeof(struct fdma)); + + lan966x->rx.max_mtu =3D old_mtu; + + lan966x_fdma_pci_reset_mem(lan966x); + + napi_enable(&lan966x->napi); + lan966x_fdma_rx_start(&lan966x->rx); + lan966x_fdma_pci_wakeup_netdev(lan966x); + + return err; +} + +static int __lan966x_fdma_pci_reload(struct lan966x *lan966x, int max_mtu) +{ + int err; + u32 val; + + /* Disable the CPU port. */ + lan_rmw(QSYS_SW_PORT_MODE_PORT_ENA_SET(0), + QSYS_SW_PORT_MODE_PORT_ENA, + lan966x, QSYS_SW_PORT_MODE(CPU_PORT)); + + /* Flush the CPU queues. */ + readx_poll_timeout(lan966x_qsys_sw_status, + lan966x, + val, + !(QSYS_SW_STATUS_EQ_AVAIL_GET(val)), + READL_SLEEP_US, READL_TIMEOUT_US); + + /* Add a sleep in case there are frames between the queues and the CPU + * port + */ + usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); + + err =3D lan966x_fdma_pci_reload(lan966x, max_mtu); + + /* Enable back the CPU port. */ + lan_rmw(QSYS_SW_PORT_MODE_PORT_ENA_SET(1), + QSYS_SW_PORT_MODE_PORT_ENA, + lan966x, QSYS_SW_PORT_MODE(CPU_PORT)); + + return err; +} + static int lan966x_fdma_pci_resize(struct lan966x *lan966x) { - return -EOPNOTSUPP; + int max_mtu; + + /* Nothing to resize until fdma_pci_init() has built the rings; it + * sizes them from DEV_MAC_MAXLEN_CFG, which the caller already set. + */ + if (!lan966x->rx.lan966x) + return 0; + + max_mtu =3D lan966x_fdma_get_max_frame(lan966x); + if (max_mtu =3D=3D lan966x->rx.max_mtu) + return 0; + + return __lan966x_fdma_pci_reload(lan966x, max_mtu); } =20 static void lan966x_fdma_pci_deinit(struct lan966x *lan966x) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.c index de2202786826..c3afc4cc597f 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -823,7 +823,8 @@ static int lan966x_probe_port(struct lan966x *lan966x, = u32 p, port->chip_port =3D p; lan966x->ports[p] =3D port; =20 - dev->max_mtu =3D ETH_MAX_MTU; + dev->max_mtu =3D lan966x_is_pci(lan966x) && lan966x->fdma ? + FDMA_PCI_MAX_MTU : ETH_MAX_MTU; =20 dev->netdev_ops =3D &lan966x_port_netdev_ops; dev->ethtool_ops =3D &lan966x_ethtool_ops; diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.h index 16bc28c8f11f..1877f1916d71 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,33 @@ #define FDMA_INJ_CHANNEL 0 #define FDMA_DCB_MAX 512 =20 +/* Ring must fit in one MAX_PAGE_ORDER DMA block; 512 DCBs overflows + * at jumbo MTU. + */ +#define FDMA_PCI_DCB_MAX 256 + +#define FDMA_OVERHEAD \ + (IFH_LEN_BYTES + \ + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + \ + VLAN_HLEN * 2 + \ + XDP_PACKET_HEADROOM) + +/* Largest db_size keeping the ATU-padded ring inside one MAX_PAGE_ORDER + * block and within the 16-bit DCB DATAL field. Inverts ALIGN(x, R) <=3D L + * into x <=3D ALIGN_DOWN(L, R) to bound x directly. + */ +#define FDMA_PCI_DB_SIZE_MAX \ + MIN_T(u32, \ + (ALIGN_DOWN(PAGE_SIZE << MAX_PAGE_ORDER, \ + FDMA_PCI_ATU_REGION_ALIGN) - \ + FDMA_PCI_DCB_MAX * sizeof(struct fdma_dcb)) / \ + (FDMA_PCI_DCB_MAX * FDMA_RX_DCB_MAX_DBS), \ + ALIGN_DOWN(GENMASK(15, 0), FDMA_PCI_DB_ALIGN)) + +#define FDMA_PCI_MAX_MTU \ + (FDMA_PCI_DB_SIZE_MAX - FDMA_OVERHEAD - \ + (ETH_HLEN + ETH_FCS_LEN)) + #define SE_IDX_QUEUE 0 /* 0-79 : Queue scheduler elements */ #define SE_IDX_PORT 80 /* 80-89 : Port schedular elements */ =20 --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 5B4C54DD3BB; Thu, 24 Sep 2026 19:58:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279888; cv=none; b=TOqrRx9E+QaMc7oWgWk4c+q38hDDA3iIFI4BMG0AKp7HRAM47CXusNXBMGeziHA08cLFyCwi01JuJbcbIojuszQZcG0ujCiFd2JQHn61/mphKEdjbgNqB+rs9Tm86Bj4WWjsOx+D1aAzl9ly8jv5EEmQdh8qbqa9HZ1hr2jbmPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279888; c=relaxed/simple; bh=1Q/sy5mN3c8A6LwSAkxjFG7jG122dNcJEFpCc+9sr/g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Yh/pL38mhUi+u4prJfWTquPVRKmMTiUV6Abyg2FIPy/9lkFCRWCoD51LepYbUq4Et+ZrKkJjH0D7Rdh0DOlOINcY3QolhkcsfSHV03/BCZ6gDwt9UMO8ceh5vkkJtHsWZ4cGZ2hQcRbO0tkXsKCn6NVxhsMgSHvx1vgZz8QQyBE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=ss48lKK2; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="ss48lKK2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279884; x=1821815884; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=1Q/sy5mN3c8A6LwSAkxjFG7jG122dNcJEFpCc+9sr/g=; b=ss48lKK22QEVElktZMhwK6jZoYAwaP4ZjF6dnyoBxgM0D+AJtCdWU+9S ttEQfVmp5IQpbuIt4McIBMbmXASaVCGpKcD44q40AXgOv+WbnhHJ0KEjs 2rg0DtZQRnSn7VjJ7MZWO/cKw7sypxEwvmNjvVGr1ghWK+ktYmWD1ovd1 /sRHbIE9/iQw7XHgruNL5BZcBFE5qmzdqdP6Igol1IPpYV7Z0bBSjVYdi 1F5QZttToTjyMuYwNktV7NP3f4qrTKIAGBlUdmT02+tq/EPU0pajkroL9 88vMdDYkfnK2tDgUrWkW+6pbPV27MATjZhZinJRb93pJFfKslutl/CTvt A==; X-CSE-ConnectionGUID: 2L7VMx2VRuC59tovHVZIHg== X-CSE-MsgGUID: pHBkZWUKQmWAqcSA8oG7ew== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="63176294" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2026 12:58:00 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex4.mchp-main.com (10.10.87.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.49; Thu, 24 Sep 2026 12:57:59 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:57:55 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:57:01 +0200 Subject: [PATCH net-next v8 13/15] net: lan966x: add PCIe FDMA XDP support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-13-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 Add XDP support for the PCIe FDMA path. The implementation operates on contiguous ATU-mapped buffers with memcpy-based XDP_TX, unlike the platform path which uses page_pool. XDP sees the frame with IFH and FCS stripped. These are removed in lan966x_fdma_pci_rx_check_frame() before the BPF program runs, because after the program returns the driver cannot tell whether the tail region was modified. The skb_pull/skb_trim previously done in lan966x_fdma_pci_rx_get_frame() are removed for the same reason; the frame pointer and length are pre-computed by rx_check_frame() and passed through rx_get_frame() and lan966x_xdp_pci_run() to the caller. lan966x_fdma_pci_xmit_xdpf() handles XDP_TX: it rebuilds a fresh IFH in the TX slot, copies the post-XDP frame after it, and lets HW insert a new FCS. lan966x_xdp_setup() is extended so the PCIe path skips the page_pool reload that the platform path needs. Only XDP_ACT_BASIC is supported. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- .../ethernet/microchip/lan966x/lan966x_fdma_pci.c | 167 +++++++++++++++++= +--- .../net/ethernet/microchip/lan966x/lan966x_main.c | 12 +- .../net/ethernet/microchip/lan966x/lan966x_xdp.c | 12 +- 3 files changed, 160 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c b/dr= ivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c index 7185e65dda43..216e9cbcd158 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma_pci.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ =20 +#include + #include "fdma_api.h" #include "lan966x_main.h" =20 @@ -136,7 +138,123 @@ static bool lan966x_fdma_pci_rx_size_fits(struct fdma= *fdma, u32 blockl) blockl <=3D fdma->db_size - XDP_PACKET_HEADROOM; } =20 -static int lan966x_fdma_pci_rx_check_frame(struct lan966x_rx *rx, u64 *src= _port) +static int lan966x_fdma_pci_xmit_xdpf(struct lan966x_port *port, + void *ptr, u32 len) +{ + struct lan966x *lan966x =3D port->lan966x; + struct lan966x_tx *tx =3D &lan966x->tx; + struct fdma *fdma =3D &tx->fdma; + int next_to_use, ret =3D 0; + void *virt_addr; + + spin_lock(&lan966x->tx_lock); + + next_to_use =3D lan966x_fdma_pci_get_next_dcb(fdma); + + if (next_to_use < 0) { + netif_stop_queue(port->dev); + port->dev->stats.tx_dropped++; + ret =3D NETDEV_TX_BUSY; + goto out; + } + + /* Only the upper bound is enforced: XDP owns the frame contents and + * length, so a program that shrinks below ETH_ZLEN gets what it asked + * for. + */ + if (!lan966x_fdma_pci_tx_size_fits(fdma, len)) { + port->dev->stats.tx_dropped++; + ret =3D -EINVAL; + goto out; + } + + /* virt_addr points to the IFH. */ + virt_addr =3D fdma_dataptr_virt_addr_contiguous(fdma, next_to_use, 0); + + /* Construct a fresh IFH. */ + memset(virt_addr, 0, IFH_LEN_BYTES); + lan966x_ifh_set_bypass(virt_addr, 1); + lan966x_ifh_set_port(virt_addr, BIT_ULL(port->chip_port)); + + /* Copy the (post-XDP) frame after the IFH. */ + memcpy(virt_addr + IFH_LEN_BYTES, ptr, len); + + /* Order frame write before DCB status write below. */ + dma_wmb(); + + /* Reserve ETH_FCS_LEN for the HW-inserted FCS (len is FCS-stripped). */ + fdma_dcb_add(fdma, + next_to_use, + 0, + FDMA_DCB_STATUS_INTR | + FDMA_DCB_STATUS_SOF | + FDMA_DCB_STATUS_EOF | + FDMA_DCB_STATUS_BLOCKO(0) | + FDMA_DCB_STATUS_BLOCKL(IFH_LEN_BYTES + len + ETH_FCS_LEN)); + + /* Start the transmission. */ + lan966x_fdma_tx_start(tx); + + port->dev->stats.tx_bytes +=3D len; + port->dev->stats.tx_packets++; + +out: + spin_unlock(&lan966x->tx_lock); + + return ret; +} + +static int lan966x_xdp_pci_run(struct lan966x_port *port, void *data, + u32 data_len, void **xdp_data, u32 *xdp_len) +{ + /* Read once so the NULL check and bpf_prog_run_xdp() see the same + * pointer. + */ + struct bpf_prog *xdp_prog =3D READ_ONCE(port->xdp_prog); + struct lan966x *lan966x =3D port->lan966x; + struct fdma *fdma =3D &lan966x->rx.fdma; + struct xdp_buff xdp; + u32 act; + + if (!xdp_prog) + return FDMA_PASS; + + xdp_init_buff(&xdp, fdma->db_size, &port->xdp_rxq); + + /* hard_start is set to slot start (virt_addr is XDP_PACKET_HEADROOM + * into the slot). Headroom includes the IFH; BPF may grow into it + * via adjust_head. IFH is rebuilt on XDP_TX and unread on XDP_PASS. + */ + xdp_prepare_buff(&xdp, + data - XDP_PACKET_HEADROOM, + XDP_PACKET_HEADROOM + IFH_LEN_BYTES, + data_len, + false); + + act =3D bpf_prog_run_xdp(xdp_prog, &xdp); + + *xdp_data =3D xdp.data; + *xdp_len =3D xdp.data_end - xdp.data; + + switch (act) { + case XDP_PASS: + return FDMA_PASS; + case XDP_TX: + return lan966x_fdma_pci_xmit_xdpf(port, *xdp_data, *xdp_len) ? + FDMA_DROP : FDMA_TX; + default: + bpf_warn_invalid_xdp_action(port->dev, xdp_prog, act); + fallthrough; + case XDP_ABORTED: + trace_xdp_exception(port->dev, xdp_prog, act); + fallthrough; + case XDP_DROP: + return FDMA_DROP; + } +} + +static int lan966x_fdma_pci_rx_check_frame(struct lan966x_rx *rx, u64 *src= _port, + void **data, u32 *data_len) { struct lan966x *lan966x =3D rx->lan966x; struct fdma *fdma =3D &rx->fdma; @@ -168,38 +286,33 @@ static int lan966x_fdma_pci_rx_check_frame(struct lan= 966x_rx *rx, u64 *src_port) if (!lan966x_fdma_pci_rx_size_fits(fdma, blockl)) return FDMA_ERROR; =20 - return FDMA_PASS; + /* Present the Ethernet frame (no IFH, no FCS). HW re-inserts the + * FCS on TX; see lan966x_fdma_pci_xmit_xdpf(). May be overridden + * by XDP. The FCS strip is unconditional because NETIF_F_RXFCS + * is not advertised in hw_features. + */ + *data =3D virt_addr + IFH_LEN_BYTES; + *data_len =3D blockl - IFH_LEN_BYTES - ETH_FCS_LEN; + + return lan966x_xdp_pci_run(port, virt_addr, *data_len, data, data_len); } =20 static struct sk_buff *lan966x_fdma_pci_rx_get_frame(struct lan966x_rx *rx, - u64 src_port) + u64 src_port, void *data, + u32 data_len) { struct lan966x *lan966x =3D rx->lan966x; - struct fdma *fdma =3D &rx->fdma; struct sk_buff *skb; - struct fdma_db *db; - u32 data_len; - - /* Get the received frame and create an SKB for it. */ - db =3D fdma_db_next_get(fdma); - data_len =3D fdma_db_len_get(db); =20 skb =3D napi_alloc_skb(&lan966x->napi, data_len); if (unlikely(!skb)) return NULL; =20 - memcpy(skb->data, - fdma_dataptr_virt_addr_contiguous(fdma, - fdma->dcb_index, - fdma->db_index), - data_len); + memcpy(skb->data, data, data_len); =20 skb_put(skb, data_len); =20 skb->dev =3D lan966x->ports[src_port]->dev; - skb_pull(skb, IFH_LEN_BYTES); - - skb_trim(skb, skb->len - ETH_FCS_LEN); =20 skb->protocol =3D eth_type_trans(skb, skb->dev); =20 @@ -287,6 +400,8 @@ static int lan966x_fdma_pci_napi_poll(struct napi_struc= t *napi, int weight) struct sk_buff *skb; int counter =3D 0; u64 src_port; + u32 data_len; + void *data; =20 /* Wake any stopped TX queues if a TX DCB is available. */ spin_lock(&lan966x->tx_lock); @@ -303,7 +418,10 @@ static int lan966x_fdma_pci_napi_poll(struct napi_stru= ct *napi, int weight) /* Order DONE read before DCB/frame reads below. */ dma_rmb(); counter++; - switch (lan966x_fdma_pci_rx_check_frame(rx, &src_port)) { + switch (lan966x_fdma_pci_rx_check_frame(rx, + &src_port, + &data, + &data_len)) { case FDMA_PASS: break; case FDMA_ERROR: @@ -312,8 +430,17 @@ static int lan966x_fdma_pci_napi_poll(struct napi_stru= ct *napi, int weight) */ fdma_dcb_advance(fdma); continue; + case FDMA_TX: + fdma_dcb_advance(fdma); + continue; + case FDMA_DROP: + fdma_dcb_advance(fdma); + continue; } - skb =3D lan966x_fdma_pci_rx_get_frame(rx, src_port); + skb =3D lan966x_fdma_pci_rx_get_frame(rx, + src_port, + data, + data_len); fdma_dcb_advance(fdma); if (!skb) { lan966x->ports[src_port]->dev->stats.rx_dropped++; diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/driver= s/net/ethernet/microchip/lan966x/lan966x_main.c index c3afc4cc597f..e4c9c5812cca 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -875,11 +875,13 @@ static int lan966x_probe_port(struct lan966x *lan966x= , u32 p, =20 port->phylink =3D phylink; =20 - /* XDP is not supported on the PCIe FDMA path. */ - if (lan966x->fdma && !lan966x_is_pci(lan966x)) - dev->xdp_features =3D NETDEV_XDP_ACT_BASIC | - NETDEV_XDP_ACT_REDIRECT | - NETDEV_XDP_ACT_NDO_XMIT; + if (lan966x->fdma) { + dev->xdp_features =3D NETDEV_XDP_ACT_BASIC; + + if (!lan966x_is_pci(lan966x)) + dev->xdp_features |=3D NETDEV_XDP_ACT_REDIRECT | + NETDEV_XDP_ACT_NDO_XMIT; + } =20 err =3D register_netdev(dev); if (err) { diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c b/drivers= /net/ethernet/microchip/lan966x/lan966x_xdp.c index e63634887f64..b98426afc785 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_xdp.c @@ -20,16 +20,16 @@ static int lan966x_xdp_setup(struct net_device *dev, st= ruct netdev_bpf *xdp) return -EOPNOTSUPP; } =20 - if (lan966x_is_pci(lan966x)) { - NL_SET_ERR_MSG_MOD(xdp->extack, - "XDP is not supported on the PCIe FDMA path"); - return -EOPNOTSUPP; - } - old_xdp =3D lan966x_xdp_present(lan966x); old_prog =3D xchg(&port->xdp_prog, xdp->prog); new_xdp =3D lan966x_xdp_present(lan966x); =20 + /* PCIe FDMA uses contiguous buffers, so no page_pool reload + * is needed. + */ + if (lan966x_is_pci(lan966x)) + goto out; + if (old_xdp =3D=3D new_xdp) goto out; =20 --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 2B8474E8E11; Thu, 24 Sep 2026 19:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279892; cv=none; b=EomBmbF6n4aOv9Gjgg2xBw4u8H8Pq3qk1vuQiAjuDPR3q9V+JsKsYntXSbNtfAA/tYyKDf/B0SETw1j6EzoDA6xIOyOjSeT55/tSDaL30eYokFRvkuNdkCkDYp0IMLhO62jBcyZ86eF4y6MuhbrT4e4x2PCcy+S1EpLiCGEm7FM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279892; c=relaxed/simple; bh=c5Izg07tkdc5eWh/EbdJlKt5hNZ4OwsKWgWyQGIZoTY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=VgFNoaGwO3XCGrpsA0+fY4DSH1ELp+h1BaCTCnWxQU6mwCugLrgEBq4deP2XiKEoNkRoamaHusba62wIhJ+njdtKhFosOt9pE72cKbvfvJQErq4xV3NmvzPS+ry/mIS5hMTJeRPkWvpH+T7scuicCzkUaSdRoB3zPJ6TrRIXrYQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=UwkbL2xV; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="UwkbL2xV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279894; x=1821815894; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=c5Izg07tkdc5eWh/EbdJlKt5hNZ4OwsKWgWyQGIZoTY=; b=UwkbL2xV9inRhhJD812gOgc/z6Tif2Eu+ayY6gC8x+6l+iM4Bnl2/2Wb Ia+BI4Z2k5++utOxT4qw9wUd1LNyWVq6H9iKg3SsAZTTChzd0ntInh3mK CMKzuG3ODSEPJcVog0I5+cZmS7YVJ0nlJ+Bpz7iIVSrjdUHHiwQGiye5M YdoHtYvXjqyIp5XUkFQSI5v99HvbEiKOaFcymV7K/o+qnb8OSN3KrBujQ JC5yxYDmQ/F05ldP6CBxxZ4JzYDy6OXzTjcZIHx3ordBz/FMxkGaJKUHf PYMs7lPnn4efnNdrm5jIYIGbuWxKCpmaG8hAw6f1486DaI2jpbLu4hHax A==; X-CSE-ConnectionGUID: gukwD5jJQt2CF3VfsLI/aw== X-CSE-MsgGUID: mclnWOHIQvG9DxmhCqkINA== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="74257273" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:58:09 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:58:04 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:58:00 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:57:02 +0200 Subject: [PATCH net-next v8 14/15] misc: lan966x-pci: dts: extend cpu reg to cover PCIE DBI space Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-14-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 The ATU outbound windows used by the FDMA engine are programmed through registers at offset 0x400000+, which falls outside the current cpu reg mapping. Extend the cpu reg size from 0x100000 (1MB) to 0x800000 (8MB) to cover the full PCIE DBI and iATU register space. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- drivers/misc/lan966x_pci.dtso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/lan966x_pci.dtso b/drivers/misc/lan966x_pci.dtso index 7b196b0a0eb6..7bb726550caf 100644 --- a/drivers/misc/lan966x_pci.dtso +++ b/drivers/misc/lan966x_pci.dtso @@ -135,7 +135,7 @@ lan966x_phy1: ethernet-lan966x_phy@2 { =20 switch: switch@e0000000 { compatible =3D "microchip,lan966x-switch"; - reg =3D <0xe0000000 0x0100000>, + reg =3D <0xe0000000 0x0800000>, <0xe2000000 0x0800000>; reg-names =3D "cpu", "gcb"; =20 --=20 2.34.1 From nobody Fri Sep 25 00:41:22 2026 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 D4CC14CC281; Thu, 24 Sep 2026 19:58:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279895; cv=none; b=Ukhd1wYLBnrXFmlUC0WuakB6J6Mi1MvHeIi7Qps4QsvXLwS9Ku5e9D0jId9QCQzVpFPnu9EPCo5jADSMk9P+n4sA9TEuE9DDXYHi9Z0oVcbVgXR6EMKrnSRfauCAKUFsPzflNUgCZhJCHPpxL5qEh1NbQxcnytDH6k90sKE+oCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790279895; c=relaxed/simple; bh=f1Jl7ARCrnbvOaZkK/LjDTX3tw1/5r96ssNQoJplEUQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=maq0lo6mtrnDrFAaNM0vsGlsCofBU3VQGxqoqN+7jQXO1g9hgc+IRvKzuQuIVNviZDnn8rn9x26DVmm/umkbQD4wajvNkrpJZmJTBvkXH/ydKAQUMwKeG1pxFtyJ+boOZ2nGSPwNbpf/sMpjvggb/49/4DQB8FzsEZyCNRebLwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=bRpQk9u6; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="bRpQk9u6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1790279893; x=1821815893; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=f1Jl7ARCrnbvOaZkK/LjDTX3tw1/5r96ssNQoJplEUQ=; b=bRpQk9u6ZoOfv8jDX4Wz8QHkMWkpfUFyh42u+a5yYyLgwyx6gJyk69G/ 4Yk5Ru8jgcijGubk5dizcIrhSOA5JMYB8/UQA8EDXGfebkD0TJ8cSkdnC FNAiMi3ub7P625LQN2ZKM5sfwaZ4KhV4Nb2Wv13MaNdKjgRmspjinon2y mZMdzwUBJsGoZAhAk8gHyLDp2EdM69T/6PlOW6zpebbNRcP8eNmwTLKzr lQdJk4bhJSP4EqDqm86TRbZWp4sGqbuC40F5Qa3aDwfYfIfc1lPNpgD0H R1AboEtWVCKMm4vtFlvyuHWUtW9NKbsMvOKPy4xvp6RU9ctAjNTdda39Q Q==; X-CSE-ConnectionGUID: t3UEfPi8TTO8/B3fdvd7jA== X-CSE-MsgGUID: j6ks3an0QcOcMOgW2tdqPw== X-IronPort-AV: E=Sophos;i="6.27,121,1787036400"; d="scan'208";a="295533236" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Sep 2026 12:58:09 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 24 Sep 2026 12:58:08 -0700 Received: from DEN-DL-M70577.microsemi.net (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Thu, 24 Sep 2026 12:58:04 -0700 From: Daniel Machon Date: Thu, 24 Sep 2026 21:57:03 +0200 Subject: [PATCH net-next v8 15/15] misc: lan966x-pci: dts: add fdma interrupt to overlay Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260924-lan966x-pci-fdma-v8-15-201c7b707d8b@microchip.com> References: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> In-Reply-To: <20260924-lan966x-pci-fdma-v8-0-201c7b707d8b@microchip.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Steen Hegelund , , "Alexei Starovoitov" , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , Stanislav Fomichev , Herve Codina , Arnd Bergmann , Greg Kroah-Hartman , Mohsin Bashir , "Simon Horman" CC: Richard Cochran , , , , X-Mailer: b4 0.14.3 Add the fdma interrupt (OIC interrupt 14) to the lan966x PCI device tree overlay, enabling FDMA-based frame injection/extraction when the switch is connected over PCIe. Tested-by: Herve Codina Signed-off-by: Daniel Machon Reviewed-by: Simon Horman --- drivers/misc/lan966x_pci.dtso | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/misc/lan966x_pci.dtso b/drivers/misc/lan966x_pci.dtso index 7bb726550caf..5bb12dbc0843 100644 --- a/drivers/misc/lan966x_pci.dtso +++ b/drivers/misc/lan966x_pci.dtso @@ -141,8 +141,9 @@ switch: switch@e0000000 { =20 interrupt-parent =3D <&oic>; interrupts =3D <12 IRQ_TYPE_LEVEL_HIGH>, + <14 IRQ_TYPE_LEVEL_HIGH>, <9 IRQ_TYPE_LEVEL_HIGH>; - interrupt-names =3D "xtr", "ana"; + interrupt-names =3D "xtr", "fdma", "ana"; =20 resets =3D <&reset 0>; reset-names =3D "switch"; --=20 2.34.1