From patchwork Mon Sep 2 14:54:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13787400 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 27694CD13CF for ; Mon, 2 Sep 2024 14:57:59 +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:In-Reply-To:References :Message-ID:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kpDeJd2WCvCmxJPZ5kQKxtUYXduzBMzKqezG5cz74hQ=; b=tWSbAnl+1P/eVggoUSlNnhXCT1 xCjhHOe3z6+Hmk/ms8CFUaQ35B1CnsB3YE69TOzBJjK77WXDaBKWbgunIvOTz566WhQjaN3B8594B 14zInHwVC4DJ+usX3Kf7S7Gb9KLoBaD6n/uOcAzKuL6n2pstlI3TSxN2wC0nki2FTz8kLHn362wOx HZvwO5RnV3tevFLFvJMxAkgqja/Qoz6srecNyWQ5Z3ZasUUXXZy751CpDSGzj9ICszzcGTkYyYwHc Lu8N2/Kla4GCgf7irrQ1VKBSxesS8c4pY5pfKYoscLCl0COOU+/nZFC4N6Fyj5Ts6aUuDKbtauTWv xduYeJog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8V1-0000000EkxS-2zIk; Mon, 02 Sep 2024 14:57:47 +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 1sl8SL-0000000Ek5i-0rdK for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 14:55:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1725288901; x=1756824901; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=RFq5AxOzVdqoMzd9LJQyduTyNy1tEpM8ZAnkxMUGgs8=; b=re0yAwxLLYDJUFCM+4VlejEO+3Csso6pVZtCgWUo6IprF4ehTzcXOxMb K9la829b3L3sZrIWRPvrYZkI1MHNlOVHOELAsAMkc1MADaRgnXxcGYuea KYwCfXcA0G+t5C8elzgKRDCDYuY7H2r96zXzl2TiHx2s3CDodsU7vDPbn 4OL4Qci7BIst3/Da3lVmdO/+eUYX55uVoscYu4S7eE6AcSVdA1qLJAxES f9z9GRjLLMiWjfp6hsCXH+mm1l1/f2rT6LX1dxBIrJYxiLs3fkibuqs6m ehS03hb4e8ttIMSgFchbYN/nfMFU3cqeaw3DcbghP62vmLgLZhE6BTKfZ Q==; X-CSE-ConnectionGUID: WWovGYJSTraVm+sPH856TA== X-CSE-MsgGUID: Sz3lNb5bSGy63k78rnTx+Q== X-IronPort-AV: E=Sophos;i="6.10,195,1719903600"; d="scan'208";a="262150743" 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; 02 Sep 2024 07:54:57 -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.35; Mon, 2 Sep 2024 07:54:49 -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:47 -0700 From: Daniel Machon Date: Mon, 2 Sep 2024 16:54:10 +0200 Subject: [PATCH net-next 05/12] net: sparx5: use FDMA library for adding DCB's in the rx path MIME-Version: 1.0 Message-ID: <20240902-fdma-sparx5-v1-5-1e7d5e5a9f34@microchip.com> References: <20240902-fdma-sparx5-v1-0-1e7d5e5a9f34@microchip.com> In-Reply-To: <20240902-fdma-sparx5-v1-0-1e7d5e5a9f34@microchip.com> 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_075501_496117_60151A5D X-CRM114-Status: GOOD ( 16.55 ) 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 Use the fdma_dcb_add() function to add DCB's in the rx path. This gets rid of the open-coding of nextptr and dataptr handling and leaves it to the library. Signed-off-by: Daniel Machon Reviewed-by: Steen Hegelund Reviewed-by: Jens Emil Schulz Østergaard Reviewed-by: Horatiu Vultur --- .../net/ethernet/microchip/sparx5/sparx5_fdma.c | 49 ++-------------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c index 675f8d5faa74..122876136f75 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c @@ -50,26 +50,6 @@ static int sparx5_fdma_rx_dataptr_cb(struct fdma *fdma, int dcb, int db, return 0; } -static void sparx5_fdma_rx_add_dcb(struct sparx5_rx *rx, - struct fdma_dcb *dcb, - u64 nextptr) -{ - struct fdma *fdma = &rx->fdma; - int idx = 0; - - /* Reset the status of the DB */ - for (idx = 0; idx < fdma->n_dbs; ++idx) { - struct fdma_db *db = &dcb->db[idx]; - - db->status = FDMA_DCB_STATUS_INTR; - } - dcb->nextptr = FDMA_DCB_INVALID_DATA; - dcb->info = FDMA_DCB_INFO_DATAL(FDMA_XTR_BUFFER_SIZE); - - fdma->last_dcb->nextptr = nextptr; - fdma->last_dcb = dcb; -} - static void sparx5_fdma_tx_add_dcb(struct sparx5_tx *tx, struct sparx5_tx_dcb_hw *dcb, u64 nextptr) @@ -179,36 +159,20 @@ static void sparx5_fdma_tx_reload(struct sparx5 *sparx5, struct sparx5_tx *tx) spx5_wr(BIT(tx->fdma.channel_id), sparx5, FDMA_CH_RELOAD); } -static struct sk_buff *sparx5_fdma_rx_alloc_skb(struct sparx5_rx *rx) -{ - return __netdev_alloc_skb(rx->ndev, FDMA_XTR_BUFFER_SIZE, - GFP_ATOMIC); -} - static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx) { struct fdma *fdma = &rx->fdma; unsigned int packet_size; struct sparx5_port *port; - struct sk_buff *new_skb; struct fdma_db *db_hw; struct frame_info fi; struct sk_buff *skb; - dma_addr_t dma_addr; /* Check if the DCB is done */ db_hw = &fdma->dcbs[fdma->dcb_index].db[fdma->db_index]; if (unlikely(!(db_hw->status & FDMA_DCB_STATUS_DONE))) return false; skb = rx->skb[fdma->dcb_index][fdma->db_index]; - /* Replace the DB entry with a new SKB */ - new_skb = sparx5_fdma_rx_alloc_skb(rx); - if (unlikely(!new_skb)) - return false; - /* Map the new skb data and set the new skb */ - dma_addr = virt_to_phys(new_skb->data); - rx->skb[fdma->dcb_index][fdma->db_index] = new_skb; - db_hw->dataptr = dma_addr; packet_size = FDMA_DCB_STATUS_BLOCKL(db_hw->status); skb_put(skb, packet_size); /* Now do the normal processing of the skb */ @@ -247,24 +211,17 @@ static int sparx5_fdma_napi_callback(struct napi_struct *napi, int weight) int counter = 0; while (counter < weight && sparx5_fdma_rx_get_frame(sparx5, rx)) { - struct fdma_dcb *old_dcb; - fdma->db_index++; counter++; /* Check if the DCB can be reused */ if (fdma->db_index != fdma->n_dbs) continue; - /* As the DCB can be reused, just advance the dcb_index - * pointer and set the nextptr in the DCB - */ + fdma_dcb_add(fdma, fdma->dcb_index, + FDMA_DCB_INFO_DATAL(fdma->db_size), + FDMA_DCB_STATUS_INTR); fdma->db_index = 0; - old_dcb = &fdma->dcbs[fdma->dcb_index]; fdma->dcb_index++; fdma->dcb_index &= fdma->n_dcbs - 1; - sparx5_fdma_rx_add_dcb(rx, old_dcb, - fdma->dma + - ((unsigned long)old_dcb - - (unsigned long)fdma->dcbs)); } if (counter < weight) { napi_complete_done(&rx->napi, counter);