From patchwork Mon Sep 2 14:54:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13787411 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 B4319CA0ED3 for ; Mon, 2 Sep 2024 15:05:16 +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=y2R/xslLnbn4eVozEuimAE4d306kwCFbsrvHKiw16zM=; b=pNzXOsbAVTuTR6OIzvL5TuV+g0 +onM1T5naZMJ5B8cXbqUewHMRu30UfYJwJItSt/Gf3piBSmUXqyqdCGh35xoOdAMvFsR/uPQ9Ix2h XYpZqFwk5TJVqD6SIwSurev9pI7MaH5HrWJwyBPCsC7gJ5fCdb5x2lI0I37DC43JxjBFbaZ1Ic1ps ReEGj3IKB3E1QJEr7mUXvqngHcGkNBvNjlC02TA5KViBeGlVzwv0pKQqpfFRa8gB9s34ELkcIpeNR ueeF7HdbZN/qNblBUwxv9eDE2OsPJn2aGsRofqF+tz2VJrcm8yBIaiiaT0c1PB8uzq+Az7iNwib/s Nk7d9n1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8c3-0000000EmYR-3sce; Mon, 02 Sep 2024 15:05:03 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8Sq-0000000EkJK-0SLo for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 14:55:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1725288931; x=1756824931; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=aLG08PxBlNupyF1+ErIPnFVlFIj4PCZ139J4QY9jINA=; b=jTrw63SgvkUVG2MCGSOqpEEIuogyq93w5cK89/OxQWDGS6tTMZpQ2EMF 54yjAUEDvBXQNJ1grz7DdQP0lrDysnRi7ODTwgYlEysPUR0R1G/GPQm0T tjmO2kQRoUeIbnMmQURpy5bHbYpeLnyDVqQFQ+a36QzLSQ6g+z3pFjnoV ja2Ujwy4fGPDWyRy07bnwURFklWJ2l3nocDpw0uBaVqXrej38n2Js3MBO KHzN9vnEKCkfh2ybqf5CWvbNlWRPkNeBx7tjU3qqMrMakoMV0OfIY3SNw 12y79SrvAgfSqPp8L5oXluib6uoRoXgGj4nvIh6hRgNsJbBMZfAPPmK9y Q==; X-CSE-ConnectionGUID: 6WD2x+lUSXKxeZe2mffqQA== X-CSE-MsgGUID: K0Bz7V1LTx6WDCI2utsLfg== X-IronPort-AV: E=Sophos;i="6.10,195,1719903600"; d="scan'208";a="31128324" 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; 02 Sep 2024 07:55:30 -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:55:00 -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:58 -0700 From: Daniel Machon Date: Mon, 2 Sep 2024 16:54:14 +0200 Subject: [PATCH net-next 09/12] net: sparx5: use FDMA library for adding DCB's in the tx path MIME-Version: 1.0 Message-ID: <20240902-fdma-sparx5-v1-9-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_075532_242761_6CA74080 X-CRM114-Status: GOOD ( 12.29 ) 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 tx path. This gets rid of the open-coding of nextptr and dataptr handling and leaves it to the library. Also, make sure the fdma indexes are advanced using: fdma_dcb_advance(), so that the correct nextptr and dataptr offsets are retrieved. 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 | 39 +++++----------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c index 8f721f7671ce..4fc52140752a 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c @@ -231,48 +231,27 @@ static int sparx5_fdma_napi_callback(struct napi_struct *napi, int weight) return counter; } -static struct fdma_dcb *sparx5_fdma_next_dcb(struct sparx5_tx *tx, - struct fdma_dcb *dcb) -{ - struct fdma_dcb *next_dcb; - struct fdma *fdma = &tx->fdma; - - next_dcb = dcb; - next_dcb++; - /* Handle wrap-around */ - if ((unsigned long)next_dcb >= - ((unsigned long)fdma->dcbs + fdma->n_dcbs * sizeof(*dcb))) - next_dcb = fdma->dcbs; - return next_dcb; -} - int sparx5_fdma_xmit(struct sparx5 *sparx5, u32 *ifh, struct sk_buff *skb) { struct sparx5_tx *tx = &sparx5->tx; struct fdma *fdma = &tx->fdma; static bool first_time = true; - struct fdma_dcb *next_dcb_hw; - struct fdma_db *db_hw; struct sparx5_db *db; - next_dcb_hw = sparx5_fdma_next_dcb(tx, fdma->last_dcb); - db_hw = &next_dcb_hw->db[0]; - if (!(db_hw->status & FDMA_DCB_STATUS_DONE)) + fdma_dcb_advance(fdma); + if (!fdma_db_is_done(fdma_db_get(fdma, fdma->dcb_index, 0))) return -EINVAL; db = list_first_entry(&tx->db_list, struct sparx5_db, list); - list_move_tail(&db->list, &tx->db_list); - next_dcb_hw->nextptr = FDMA_DCB_INVALID_DATA; - fdma->last_dcb->nextptr = fdma->dma + - ((unsigned long)next_dcb_hw - - (unsigned long)fdma->dcbs); - fdma->last_dcb = next_dcb_hw; memset(db->cpu_addr, 0, FDMA_XTR_BUFFER_SIZE); memcpy(db->cpu_addr, ifh, IFH_LEN * 4); memcpy(db->cpu_addr + IFH_LEN * 4, skb->data, skb->len); - db_hw->status = FDMA_DCB_STATUS_SOF | - FDMA_DCB_STATUS_EOF | - FDMA_DCB_STATUS_BLOCKO(0) | - FDMA_DCB_STATUS_BLOCKL(skb->len + IFH_LEN * 4 + 4); + + fdma_dcb_add(fdma, fdma->dcb_index, 0, + FDMA_DCB_STATUS_SOF | + FDMA_DCB_STATUS_EOF | + FDMA_DCB_STATUS_BLOCKO(0) | + FDMA_DCB_STATUS_BLOCKL(skb->len + IFH_LEN * 4 + 4)); + if (first_time) { sparx5_fdma_tx_activate(sparx5, tx); first_time = false;