From patchwork Mon Sep 2 14:54:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13787401 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 DB366CA0ED3 for ; Mon, 2 Sep 2024 14:58: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: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=DxIVrq0QaXUOq/HntQdZX3VrcKKDNSXwQv8XNzdELog=; b=YmLmlubxfd7j14GHbyBHd+QEZC CX/4cljzabbwOebiy/c/RH5x/Yl/+uTx8b11nGi/LU5y/OLgPc26ua+CWALpS/z859Jqb25Yx/G76 dPOmmddRxn3oPfTzXi5DH/MsuTD47tpA/u9g4kI/r19zmAudlDkMiqpDYiQJfE4Bklr/UMPC+hx6t w1ZsKvo6TVZU3gFJf3blbt5dmxbzeYNeBOu/GdfcpTqlb05elNLBkb2lwvbBR8jALJ1rEuqtY+lSE p606TfXSDvo6qZXPX68U9fYFLsWeU9CCz8yZl1kejC7XlMo59J4BJ5JTu80HUS8rX4o4Wlza+vQgO l9qr9nWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8Vu-0000000ElEI-29mP; Mon, 02 Sep 2024 14:58:42 +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 1sl8SM-0000000Ek7H-3Ze6 for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 14:55:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1725288902; x=1756824902; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Pi32t5UY/P3LWFumotKzK0POQA28FP5B1cv8ISci/Pg=; b=WBvxETBPzcgxiVPgyqD0JCUc0jgLth6NDeCZF/fPOfHdk9OKUsWCzR04 S+cAnjlX1ftdK3StteU3SDkg5yj+GtRfg3raVgJdLcIY5pILuvMcH/Jae fG5bAE48SJQ7vxMI3rJ6tuk4lplRR/BEYXKRJjgCDX84zXiVjQD5z7MwQ WVa5e3jyq35gg5FTWAp3zmON0iUuAZIpvi3k2d1TnwZ9ZDHNvyM6VETgt jpJrJHecw3qmYwDivYwxnQxv35m4vcSgU74WFFGtvOeWa9MCrvKybRsQO EsOWlMH+CyKYzJ5/El6X/xx/0MkwvBrGaDIlvt4J6mHFXQUZYkvS2COFj A==; X-CSE-ConnectionGUID: WWovGYJSTraVm+sPH856TA== X-CSE-MsgGUID: CQIqPPUvSU2IDx2nLMTnUA== X-IronPort-AV: E=Sophos;i="6.10,195,1719903600"; d="scan'208";a="262150745" 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:55 -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:52 -0700 From: Daniel Machon Date: Mon, 2 Sep 2024 16:54:12 +0200 Subject: [PATCH net-next 07/12] net: sparx5: use a few FDMA helpers in the rx path MIME-Version: 1.0 Message-ID: <20240902-fdma-sparx5-v1-7-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_075503_047758_A4784D6F X-CRM114-Status: GOOD ( 12.86 ) 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 The library provides helpers for a number of DCB and DB operations. Use these in the rx path. Signed-off-by: Daniel Machon Reviewed-by: Steen Hegelund Reviewed-by: Jens Emil Schulz Østergaard Reviewed-by: Horatiu Vultur --- drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c index d01516f32d0c..c37718b99d67 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c @@ -162,19 +162,17 @@ static void sparx5_fdma_tx_reload(struct sparx5 *sparx5, struct sparx5_tx *tx) 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 fdma_db *db_hw; struct frame_info fi; struct sk_buff *skb; /* 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))) + db_hw = fdma_db_next_get(fdma); + if (unlikely(!fdma_db_is_done(db_hw))) return false; skb = rx->skb[fdma->dcb_index][fdma->db_index]; - packet_size = FDMA_DCB_STATUS_BLOCKL(db_hw->status); - skb_put(skb, packet_size); + skb_put(skb, fdma_db_len_get(db_hw)); /* Now do the normal processing of the skb */ sparx5_ifh_parse((u32 *)skb->data, &fi); /* Map to port netdev */ @@ -211,17 +209,16 @@ 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)) { - fdma->db_index++; + fdma_db_advance(fdma); counter++; /* Check if the DCB can be reused */ - if (fdma->db_index != fdma->n_dbs) + if (fdma_dcb_is_reusable(fdma)) continue; fdma_dcb_add(fdma, fdma->dcb_index, FDMA_DCB_INFO_DATAL(fdma->db_size), FDMA_DCB_STATUS_INTR); - fdma->db_index = 0; - fdma->dcb_index++; - fdma->dcb_index &= fdma->n_dcbs - 1; + fdma_db_reset(fdma); + fdma_dcb_advance(fdma); } if (counter < weight) { napi_complete_done(&rx->napi, counter);