From patchwork Mon Sep 2 14:54:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13787403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1165ECD13CF for ; Mon, 2 Sep 2024 15:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:CC:To: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=f4wMGsN3FWWeOV3YqecS0vtjS+/vF2c7igAN1VN2DHA=; b=l3w4K3vCNYAb6s HFYddx3BvcKYbqyFfunUAsEISlK71g8yPj/HE21viw31+QSdJ3GbQW5+vP2/eB/mmG8kzM/WRy0kM AXXjiDvX/WBgDV7oyJ8+TunW++4T/tb0gkRGob34GKV29xzFlbFcyIh/K6/wZbq2IqbNxrzCWHspn pXVkn5Vx1ELDKczPZ99mVG10qKss1MMzRgI9MJYGVGqTMbYM4EyJnukrbJnnlz0Lr1TvC6RQrYWEr BtXlL5ESQI8XMDHI4GThZuljcUw/VTvPHeM/gauMwZCvbEglndz9IQUBkNiifVOUMe4MB2FOZzhb9 LImnJZILsxwZYtOUYWLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8Xi-0000000ElpJ-43Kv; Mon, 02 Sep 2024 15:00:34 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8SR-0000000EkAV-0gD2 for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 14:55:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1725288906; x=1756824906; h=from:subject:date:message-id:mime-version: content-transfer-encoding:to:cc; bh=Ay7cz/cAx5VzT0SFGJs2YTe8CXFBSqYgGWY1vbNoneo=; b=p3M1WOvg9+gtnq+MBhim9pFJMFM4Jlb0UiQcbpe8ejkGWEEp0balxp62 /uw7uas6q06wXNBCOuLZOaHEDeVcA92WpUy/+7WzX033FVUYON76SonFN T7Fpj/TjP7Hpui6djMFnrCUwj/yA650KBycLO+QQSY3tZzHHlzCvwPlwM 5OXdwZ7oaZ1eLqMpckePyturVTqZp1VdQanv2pyt/VxY90HEf17k1LbTy FdJ/Z/sFm/GX7/Ohsb3ZS5bk+I84bDLUPqHuHLyMo8ySoYRXtgweuFcxb RBWCYMwY+LYgNvbFmW8I2N7m7oNOqFbgS/41gugtfDwjltdby+niP6CRB g==; X-CSE-ConnectionGUID: /Vcaqev1TP+OZLTGnI90pA== X-CSE-MsgGUID: dDyp8V77RRGGGtCZGqytLw== X-IronPort-AV: E=Sophos;i="6.10,195,1719903600"; d="scan'208";a="34271102" 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; 02 Sep 2024 07:55:06 -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.35; Mon, 2 Sep 2024 07:54:36 -0700 Received: from [10.205.21.108] (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 2 Sep 2024 07:54:34 -0700 From: Daniel Machon Subject: [PATCH net-next 00/12] net: microchip: add FDMA library and use it for Sparx5 Date: Mon, 2 Sep 2024 16:54:05 +0200 Message-ID: <20240902-fdma-sparx5-v1-0-1e7d5e5a9f34@microchip.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAI3R1WYC/x2MSQrDMAwAvxJ0rsB1E7p8pfSg2HKjQ9QghWAI+ XvdHodhZgdnE3Z4dDsYb+Ly0QbnUwdpIn0zSm4MMcQ+3EPEkmdCX8jqgANdU7j1IcdLgVYsxkX q//YE5RWV6wqvZkZyxtFI0/S7zSQKx/EFMUTuL34AAAA= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , "Steen Hegelund" , Horatiu Vultur , , , CC: , , , =?utf-8?q?Jens_Emil_Schulz_=C3=98st?= =?utf-8?q?ergaard?= X-Mailer: b4 0.14-dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_075507_261832_6937DBD5 X-CRM114-Status: GOOD ( 16.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch series is the first of a 2-part series, that adds a new common FDMA library for Microchip switch chips Sparx5 and lan966x. These chips share the same FDMA engine, and as such will benefit from a common library with a common implementation. This also has the benefit of removing a lot open-coded bookkeeping and duplicate code for the two drivers. Additionally, upstreaming efforts for a third chip, lan969x, will begin in the near future. This chip will use the new library too. In this first series, the FDMA library is introduced and used by the Sparx5 switch driver. ################### # Example of use: # ################### - Initialize the rx and tx fdma structs with values for: number of DCB's, number of DB's, channel ID, DB size (data buffer size), and total size of the requested memory. Also provide two callbacks: nextptr_cb() and dataptr_cb() for getting the nextptr and dataptr. - Allocate memory using fdma_alloc_phys() or fdma_alloc_coherent(). - Initialize the DCB's with fdma_dcb_init(). - Add new DCB's with fdma_dcb_add(). - Free memory with fdma_free_phys() or fdma_free_coherent(). ##################### # Patch breakdown: # ##################### Patch #1: introduces library and selects it for Sparx5. Patch #2: includes the fdma_api.h header and removes old symbols. Patch #3: replaces old rx and tx variables with equivalent ones from the fdma struct. Only the variables that can be changed without breaking traffic is changed in this patch. Patch #4: uses the library for allocation of rx buffers. This requires quite a bit of refactoring in this single patch. Patch #5: uses the library for adding DCB's in the rx path. Patch #6: uses the library for freeing rx buffers. Patch #7: uses the library helpers in the rx path. Patch #8: uses the library for allocation of tx buffers. This requires quite a bit of refactoring in this single patch. Patch #9: uses the library for adding DCB's in the tx path. Patch #10: uses the library helpers in the tx path. Patch #11: ditches the existing linked list for storing buffer addresses, and instead uses offsets into contiguous memory. Patch #12: modifies existing rx and tx functions to be direction independent. To: David S. Miller To: Eric Dumazet To: Jakub Kicinski To: Paolo Abeni To: Lars Povlsen To: Steen Hegelund To: Horatiu Vultur To: UNGLinuxDriver@microchip.com To: rdunlap@infradead.org To: horms@kernel.org Cc: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Daniel Machon --- Daniel Machon (12): net: microchip: add FDMA library net: sparx5: use FDMA library symbols net: sparx5: replace a few variables with new equivalent ones net: sparx5: use the FDMA library for allocation of rx buffers net: sparx5: use FDMA library for adding DCB's in the rx path net: sparx5: use library helper for freeing rx buffers net: sparx5: use a few FDMA helpers in the rx path net: sparx5: use the FDMA library for allocation of tx buffers net: sparx5: use FDMA library for adding DCB's in the tx path net: sparx5: use library helper for freeing tx buffers net: sparx5: use contiguous memory for tx buffers net: sparx5: ditch sparx5_fdma_rx/tx_reload() functions drivers/net/ethernet/microchip/Kconfig | 1 + drivers/net/ethernet/microchip/Makefile | 1 + drivers/net/ethernet/microchip/fdma/Kconfig | 18 + drivers/net/ethernet/microchip/fdma/Makefile | 7 + drivers/net/ethernet/microchip/fdma/fdma_api.c | 146 ++++++++ drivers/net/ethernet/microchip/fdma/fdma_api.h | 243 +++++++++++++ drivers/net/ethernet/microchip/sparx5/Kconfig | 1 + drivers/net/ethernet/microchip/sparx5/Makefile | 1 + .../net/ethernet/microchip/sparx5/sparx5_fdma.c | 382 +++++++-------------- .../net/ethernet/microchip/sparx5/sparx5_main.h | 31 +- 10 files changed, 545 insertions(+), 286 deletions(-) --- base-commit: 221f9cce949ac8042f65b71ed1fde13b99073256 change-id: 20240902-fdma-sparx5-5a7c0840d23f Best regards,