devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: netdev@vger.kernel.org
Cc: lorenzo.bianconi@redhat.com, nbd@nbd.name, john@phrozen.org,
	sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, daniel@makrotopia.org,
	linux-mediatek@lists.infradead.org, sujuan.chen@mediatek.com,
	horms@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, devicetree@vger.kernel.org
Subject: [PATCH v2 net-next 12/17] net: ethernet: mtk_wed: refactor mtk_wed_check_wfdma_rx_fill routine
Date: Mon, 18 Sep 2023 12:29:14 +0200	[thread overview]
Message-ID: <67af87aaf109fc167b34d97ce1fbe98ac10fb5c9.1695032291.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1695032290.git.lorenzo@kernel.org>

Refactor mtk_wed_check_wfdma_rx_fill() in order to be reused adding HW
receive offload support for MT7988 SoC.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/mediatek/mtk_wed.c | 44 +++++++++++++++----------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c
index b6ca12686beb..18cbf028f6ed 100644
--- a/drivers/net/ethernet/mediatek/mtk_wed.c
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c
@@ -586,22 +586,15 @@ mtk_wed_set_512_support(struct mtk_wed_device *dev, bool enable)
 	}
 }
 
-#define MTK_WFMDA_RX_DMA_EN	BIT(2)
-static void
-mtk_wed_check_wfdma_rx_fill(struct mtk_wed_device *dev, int idx)
+static int
+mtk_wed_check_wfdma_rx_fill(struct mtk_wed_device *dev,
+			    struct mtk_wed_ring *ring)
 {
-	u32 val;
 	int i;
 
-	if (!(dev->rx_ring[idx].flags & MTK_WED_RING_CONFIGURED))
-		return; /* queue is not configured by mt76 */
-
 	for (i = 0; i < 3; i++) {
-		u32 cur_idx;
+		u32 cur_idx = readl(ring->wpdma + MTK_WED_RING_OFS_CPU_IDX);
 
-		cur_idx = wed_r32(dev,
-				  MTK_WED_WPDMA_RING_RX_DATA(idx) +
-				  MTK_WED_RING_OFS_CPU_IDX);
 		if (cur_idx == MTK_WED_RX_RING_SIZE - 1)
 			break;
 
@@ -610,12 +603,10 @@ mtk_wed_check_wfdma_rx_fill(struct mtk_wed_device *dev, int idx)
 
 	if (i == 3) {
 		dev_err(dev->hw->dev, "rx dma enable failed\n");
-		return;
+		return -ETIMEDOUT;
 	}
 
-	val = wifi_r32(dev, dev->wlan.wpdma_rx_glo - dev->wlan.phy_base) |
-	      MTK_WFMDA_RX_DMA_EN;
-	wifi_w32(dev, dev->wlan.wpdma_rx_glo - dev->wlan.phy_base, val);
+	return 0;
 }
 
 static void
@@ -1546,6 +1537,7 @@ mtk_wed_configure_irq(struct mtk_wed_device *dev, u32 irq_mask)
 	wed_w32(dev, MTK_WED_INT_MASK, irq_mask);
 }
 
+#define MTK_WFMDA_RX_DMA_EN	BIT(2)
 static void
 mtk_wed_dma_enable(struct mtk_wed_device *dev)
 {
@@ -1633,8 +1625,26 @@ mtk_wed_dma_enable(struct mtk_wed_device *dev)
 		wdma_set(dev, MTK_WDMA_WRBK_TX_CFG, MTK_WDMA_WRBK_TX_CFG_WRBK_EN);
 	}
 
-	for (i = 0; i < MTK_WED_RX_QUEUES; i++)
-		mtk_wed_check_wfdma_rx_fill(dev, i);
+	for (i = 0; i < MTK_WED_RX_QUEUES; i++) {
+		struct mtk_wed_ring *ring = &dev->rx_ring[i];
+		u32 val;
+
+		if (!(ring->flags & MTK_WED_RING_CONFIGURED))
+			continue; /* queue is not configured by mt76 */
+
+		if (mtk_wed_check_wfdma_rx_fill(dev, ring)) {
+			dev_err(dev->hw->dev,
+				"rx_ring(%d) dma enable failed\n", i);
+			continue;
+		}
+
+		val = wifi_r32(dev,
+			       dev->wlan.wpdma_rx_glo -
+			       dev->wlan.phy_base) | MTK_WFMDA_RX_DMA_EN;
+		wifi_w32(dev,
+			 dev->wlan.wpdma_rx_glo - dev->wlan.phy_base,
+			 val);
+	}
 }
 
 static void
-- 
2.41.0


  parent reply	other threads:[~2023-09-18 10:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 10:29 [PATCH v2 net-next 00/17] Add WED support for MT7988 chipset Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 01/17] dt-bindings: soc: mediatek: mt7986-wo-ccif: add binding for MT7988 SoC Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 02/17] dt-bindings: arm: mediatek: mt7622-wed: add WED " Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 03/17] net: ethernet: mtk_wed: introduce versioning utility routines Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 04/17] net: ethernet: mtk_wed: do not configure rx offload if not supported Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 05/17] net: ethernet: mtk_wed: rename mtk_rxbm_desc in mtk_wed_bm_desc Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 06/17] net: ethernet: mtk_wed: introduce mtk_wed_buf structure Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 07/17] net: ethernet: mtk_wed: move mem_region array out of mtk_wed_mcu_load_firmware Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 08/17] net: ethernet: mtk_wed: make memory region optional Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 09/17] net: ethernet: mtk_wed: fix EXT_INT_STATUS_RX_FBUF definitions for MT7986 SoC Lorenzo Bianconi
2023-09-18 11:35   ` Daniel Golle
2023-09-18 12:17     ` Lorenzo Bianconi
2023-09-19 14:07     ` Paolo Abeni
2023-09-18 10:29 ` [PATCH v2 net-next 10/17] net: ethernet: mtk_wed: add mtk_wed_soc_data structure Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 11/17] net: ethernet: mtk_wed: introduce WED support for MT7988 Lorenzo Bianconi
2023-09-18 10:29 ` Lorenzo Bianconi [this message]
2023-09-18 10:29 ` [PATCH v2 net-next 13/17] net: ethernet: mtk_wed: introduce partial AMSDU offload " Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 14/17] net: ethernet: mtk_wed: introduce hw_rro " Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 15/17] net: ethernet: mtk_wed: debugfs: move wed_v2 specific regs out of regs array Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 16/17] net: ethernet: mtk_wed: debugfs: add WED 3.0 debugfs entries Lorenzo Bianconi
2023-09-18 10:29 ` [PATCH v2 net-next 17/17] net: ethernet: mtk_wed: add wed 3.0 reset support Lorenzo Bianconi
2023-09-19 17:20 ` [PATCH v2 net-next 00/17] Add WED support for MT7988 chipset patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=67af87aaf109fc167b34d97ce1fbe98ac10fb5c9.1695032291.git.lorenzo@kernel.org \
    --to=lorenzo@kernel.org \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=john@phrozen.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@kernel.org \
    --cc=sean.wang@mediatek.com \
    --cc=sujuan.chen@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).