airoha: remove upstreamed patches for 6.18
Remove all patches that have already been upstreamed for kernel 6.18. Signed-off-by: Kenneth Kasilag <kenneth@kasilag.me> Link: https://github.com/openwrt/openwrt/pull/21019 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
This commit is contained in:
parent
40f6298d06
commit
2f8c360a67
@ -1,33 +0,0 @@
|
||||
From 2518b119639162251b6cc7195aec394930c1d867 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 9 Oct 2024 00:21:47 +0200
|
||||
Subject: [PATCH] net: airoha: Fix EGRESS_RATE_METER_EN_MASK definition
|
||||
|
||||
Fix typo in EGRESS_RATE_METER_EN_MASK mask definition. This bus in not
|
||||
introducing any user visible problem since, even if we are setting
|
||||
EGRESS_RATE_METER_EN_MASK bit in REG_EGRESS_RATE_METER_CFG register,
|
||||
egress QoS metering is not supported yet since we are missing some other
|
||||
hw configurations (e.g token bucket rate, token bucket size).
|
||||
|
||||
Introduced by commit 23020f049327 ("net: airoha: Introduce ethernet support
|
||||
for EN7581 SoC")
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20241009-airoha-fixes-v2-1-18af63ec19bf@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -554,7 +554,7 @@
|
||||
#define FWD_DSCP_LOW_THR_MASK GENMASK(17, 0)
|
||||
|
||||
#define REG_EGRESS_RATE_METER_CFG 0x100c
|
||||
-#define EGRESS_RATE_METER_EN_MASK BIT(29)
|
||||
+#define EGRESS_RATE_METER_EN_MASK BIT(31)
|
||||
#define EGRESS_RATE_METER_EQ_RATE_EN_MASK BIT(17)
|
||||
#define EGRESS_RATE_METER_WINDOW_SZ_MASK GENMASK(16, 12)
|
||||
#define EGRESS_RATE_METER_TIMESLICE_MASK GENMASK(10, 0)
|
||||
@ -1,306 +0,0 @@
|
||||
From 5c5db81bff81a0fcd9ad998543d4241cbfe4742f Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Thu, 17 Oct 2024 14:44:38 +0200
|
||||
Subject: [PATCH 2/2] hwrng: airoha - add support for Airoha EN7581 TRNG
|
||||
|
||||
Add support for Airoha TRNG. The Airoha SoC provide a True RNG module
|
||||
that can output 4 bytes of raw data at times.
|
||||
|
||||
The module makes use of various noise source to provide True Random
|
||||
Number Generation.
|
||||
|
||||
On probe the module is reset to operate Health Test and verify correct
|
||||
execution of it.
|
||||
|
||||
The module can also provide DRBG function but the execution mode is
|
||||
mutually exclusive, running as TRNG doesn't permit to also run it as
|
||||
DRBG.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Reviewed-by: Martin Kaiser <martin@kaiser.cx>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
---
|
||||
drivers/char/hw_random/Kconfig | 13 ++
|
||||
drivers/char/hw_random/Makefile | 1 +
|
||||
drivers/char/hw_random/airoha-trng.c | 243 +++++++++++++++++++++++++++
|
||||
3 files changed, 257 insertions(+)
|
||||
create mode 100644 drivers/char/hw_random/airoha-trng.c
|
||||
|
||||
--- a/drivers/char/hw_random/Kconfig
|
||||
+++ b/drivers/char/hw_random/Kconfig
|
||||
@@ -62,6 +62,19 @@ config HW_RANDOM_AMD
|
||||
|
||||
If unsure, say Y.
|
||||
|
||||
+config HW_RANDOM_AIROHA
|
||||
+ tristate "Airoha True HW Random Number Generator support"
|
||||
+ depends on ARCH_AIROHA || COMPILE_TEST
|
||||
+ default HW_RANDOM
|
||||
+ help
|
||||
+ This driver provides kernel-side support for the True Random Number
|
||||
+ Generator hardware found on Airoha SoC.
|
||||
+
|
||||
+ To compile this driver as a module, choose M here: the
|
||||
+ module will be called airoha-rng.
|
||||
+
|
||||
+ If unsure, say Y.
|
||||
+
|
||||
config HW_RANDOM_ATMEL
|
||||
tristate "Atmel Random Number Generator support"
|
||||
depends on (ARCH_AT91 || COMPILE_TEST)
|
||||
--- a/drivers/char/hw_random/Makefile
|
||||
+++ b/drivers/char/hw_random/Makefile
|
||||
@@ -8,6 +8,7 @@ rng-core-y := core.o
|
||||
obj-$(CONFIG_HW_RANDOM_TIMERIOMEM) += timeriomem-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o
|
||||
+obj-$(CONFIG_HW_RANDOM_AIROHA) += airoha-trng.o
|
||||
obj-$(CONFIG_HW_RANDOM_ATMEL) += atmel-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_BA431) += ba431-rng.o
|
||||
obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/char/hw_random/airoha-trng.c
|
||||
@@ -0,0 +1,243 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/* Copyright (C) 2024 Christian Marangi */
|
||||
+
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/mod_devicetable.h>
|
||||
+#include <linux/bitfield.h>
|
||||
+#include <linux/delay.h>
|
||||
+#include <linux/hw_random.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/io.h>
|
||||
+#include <linux/iopoll.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+
|
||||
+#define TRNG_IP_RDY 0x800
|
||||
+#define CNT_TRANS GENMASK(15, 8)
|
||||
+#define SAMPLE_RDY BIT(0)
|
||||
+#define TRNG_NS_SEK_AND_DAT_EN 0x804
|
||||
+#define RNG_EN BIT(31) /* referenced as ring_en */
|
||||
+#define RAW_DATA_EN BIT(16)
|
||||
+#define TRNG_HEALTH_TEST_SW_RST 0x808
|
||||
+#define SW_RST BIT(0) /* Active High */
|
||||
+#define TRNG_INTR_EN 0x818
|
||||
+#define INTR_MASK BIT(16)
|
||||
+#define CONTINUOUS_HEALTH_INITR_EN BIT(2)
|
||||
+#define SW_STARTUP_INITR_EN BIT(1)
|
||||
+#define RST_STARTUP_INITR_EN BIT(0)
|
||||
+/* Notice that Health Test are done only out of Reset and with RNG_EN */
|
||||
+#define TRNG_HEALTH_TEST_STATUS 0x824
|
||||
+#define CONTINUOUS_HEALTH_AP_TEST_FAIL BIT(23)
|
||||
+#define CONTINUOUS_HEALTH_RC_TEST_FAIL BIT(22)
|
||||
+#define SW_STARTUP_TEST_DONE BIT(21)
|
||||
+#define SW_STARTUP_AP_TEST_FAIL BIT(20)
|
||||
+#define SW_STARTUP_RC_TEST_FAIL BIT(19)
|
||||
+#define RST_STARTUP_TEST_DONE BIT(18)
|
||||
+#define RST_STARTUP_AP_TEST_FAIL BIT(17)
|
||||
+#define RST_STARTUP_RC_TEST_FAIL BIT(16)
|
||||
+#define RAW_DATA_VALID BIT(7)
|
||||
+
|
||||
+#define TRNG_RAW_DATA_OUT 0x828
|
||||
+
|
||||
+#define TRNG_CNT_TRANS_VALID 0x80
|
||||
+#define BUSY_LOOP_SLEEP 10
|
||||
+#define BUSY_LOOP_TIMEOUT (BUSY_LOOP_SLEEP * 10000)
|
||||
+
|
||||
+struct airoha_trng {
|
||||
+ void __iomem *base;
|
||||
+ struct hwrng rng;
|
||||
+ struct device *dev;
|
||||
+
|
||||
+ struct completion rng_op_done;
|
||||
+};
|
||||
+
|
||||
+static int airoha_trng_irq_mask(struct airoha_trng *trng)
|
||||
+{
|
||||
+ u32 val;
|
||||
+
|
||||
+ val = readl(trng->base + TRNG_INTR_EN);
|
||||
+ val |= INTR_MASK;
|
||||
+ writel(val, trng->base + TRNG_INTR_EN);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_trng_irq_unmask(struct airoha_trng *trng)
|
||||
+{
|
||||
+ u32 val;
|
||||
+
|
||||
+ val = readl(trng->base + TRNG_INTR_EN);
|
||||
+ val &= ~INTR_MASK;
|
||||
+ writel(val, trng->base + TRNG_INTR_EN);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_trng_init(struct hwrng *rng)
|
||||
+{
|
||||
+ struct airoha_trng *trng = container_of(rng, struct airoha_trng, rng);
|
||||
+ int ret;
|
||||
+ u32 val;
|
||||
+
|
||||
+ val = readl(trng->base + TRNG_NS_SEK_AND_DAT_EN);
|
||||
+ val |= RNG_EN;
|
||||
+ writel(val, trng->base + TRNG_NS_SEK_AND_DAT_EN);
|
||||
+
|
||||
+ /* Set out of SW Reset */
|
||||
+ airoha_trng_irq_unmask(trng);
|
||||
+ writel(0, trng->base + TRNG_HEALTH_TEST_SW_RST);
|
||||
+
|
||||
+ ret = wait_for_completion_timeout(&trng->rng_op_done, BUSY_LOOP_TIMEOUT);
|
||||
+ if (ret <= 0) {
|
||||
+ dev_err(trng->dev, "Timeout waiting for Health Check\n");
|
||||
+ airoha_trng_irq_mask(trng);
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ /* Check if Health Test Failed */
|
||||
+ val = readl(trng->base + TRNG_HEALTH_TEST_STATUS);
|
||||
+ if (val & (RST_STARTUP_AP_TEST_FAIL | RST_STARTUP_RC_TEST_FAIL)) {
|
||||
+ dev_err(trng->dev, "Health Check fail: %s test fail\n",
|
||||
+ val & RST_STARTUP_AP_TEST_FAIL ? "AP" : "RC");
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ /* Check if IP is ready */
|
||||
+ ret = readl_poll_timeout(trng->base + TRNG_IP_RDY, val,
|
||||
+ val & SAMPLE_RDY, 10, 1000);
|
||||
+ if (ret < 0) {
|
||||
+ dev_err(trng->dev, "Timeout waiting for IP ready");
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ /* CNT_TRANS must be 0x80 for IP to be considered ready */
|
||||
+ ret = readl_poll_timeout(trng->base + TRNG_IP_RDY, val,
|
||||
+ FIELD_GET(CNT_TRANS, val) == TRNG_CNT_TRANS_VALID,
|
||||
+ 10, 1000);
|
||||
+ if (ret < 0) {
|
||||
+ dev_err(trng->dev, "Timeout waiting for IP ready");
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void airoha_trng_cleanup(struct hwrng *rng)
|
||||
+{
|
||||
+ struct airoha_trng *trng = container_of(rng, struct airoha_trng, rng);
|
||||
+ u32 val;
|
||||
+
|
||||
+ val = readl(trng->base + TRNG_NS_SEK_AND_DAT_EN);
|
||||
+ val &= ~RNG_EN;
|
||||
+ writel(val, trng->base + TRNG_NS_SEK_AND_DAT_EN);
|
||||
+
|
||||
+ /* Put it in SW Reset */
|
||||
+ writel(SW_RST, trng->base + TRNG_HEALTH_TEST_SW_RST);
|
||||
+}
|
||||
+
|
||||
+static int airoha_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
|
||||
+{
|
||||
+ struct airoha_trng *trng = container_of(rng, struct airoha_trng, rng);
|
||||
+ u32 *data = buf;
|
||||
+ u32 status;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = readl_poll_timeout(trng->base + TRNG_HEALTH_TEST_STATUS, status,
|
||||
+ status & RAW_DATA_VALID, 10, 1000);
|
||||
+ if (ret < 0) {
|
||||
+ dev_err(trng->dev, "Timeout waiting for TRNG RAW Data valid\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ *data = readl(trng->base + TRNG_RAW_DATA_OUT);
|
||||
+
|
||||
+ return 4;
|
||||
+}
|
||||
+
|
||||
+static irqreturn_t airoha_trng_irq(int irq, void *priv)
|
||||
+{
|
||||
+ struct airoha_trng *trng = (struct airoha_trng *)priv;
|
||||
+
|
||||
+ airoha_trng_irq_mask(trng);
|
||||
+ /* Just complete the task, we will read the value later */
|
||||
+ complete(&trng->rng_op_done);
|
||||
+
|
||||
+ return IRQ_HANDLED;
|
||||
+}
|
||||
+
|
||||
+static int airoha_trng_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct airoha_trng *trng;
|
||||
+ int irq, ret;
|
||||
+ u32 val;
|
||||
+
|
||||
+ trng = devm_kzalloc(dev, sizeof(*trng), GFP_KERNEL);
|
||||
+ if (!trng)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ trng->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(trng->base))
|
||||
+ return PTR_ERR(trng->base);
|
||||
+
|
||||
+ irq = platform_get_irq(pdev, 0);
|
||||
+ if (irq < 0)
|
||||
+ return irq;
|
||||
+
|
||||
+ airoha_trng_irq_mask(trng);
|
||||
+ ret = devm_request_irq(&pdev->dev, irq, airoha_trng_irq, 0,
|
||||
+ pdev->name, (void *)trng);
|
||||
+ if (ret) {
|
||||
+ dev_err(dev, "Can't get interrupt working.\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ init_completion(&trng->rng_op_done);
|
||||
+
|
||||
+ /* Enable interrupt for SW reset Health Check */
|
||||
+ val = readl(trng->base + TRNG_INTR_EN);
|
||||
+ val |= RST_STARTUP_INITR_EN;
|
||||
+ writel(val, trng->base + TRNG_INTR_EN);
|
||||
+
|
||||
+ /* Set output to raw data */
|
||||
+ val = readl(trng->base + TRNG_NS_SEK_AND_DAT_EN);
|
||||
+ val |= RAW_DATA_EN;
|
||||
+ writel(val, trng->base + TRNG_NS_SEK_AND_DAT_EN);
|
||||
+
|
||||
+ /* Put it in SW Reset */
|
||||
+ writel(SW_RST, trng->base + TRNG_HEALTH_TEST_SW_RST);
|
||||
+
|
||||
+ trng->dev = dev;
|
||||
+ trng->rng.name = pdev->name;
|
||||
+ trng->rng.init = airoha_trng_init;
|
||||
+ trng->rng.cleanup = airoha_trng_cleanup;
|
||||
+ trng->rng.read = airoha_trng_read;
|
||||
+
|
||||
+ ret = devm_hwrng_register(dev, &trng->rng);
|
||||
+ if (ret) {
|
||||
+ dev_err(dev, "failed to register rng device: %d\n", ret);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id airoha_trng_of_match[] = {
|
||||
+ { .compatible = "airoha,en7581-trng", },
|
||||
+ {},
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, airoha_trng_of_match);
|
||||
+
|
||||
+static struct platform_driver airoha_trng_driver = {
|
||||
+ .driver = {
|
||||
+ .name = "airoha-trng",
|
||||
+ .of_match_table = airoha_trng_of_match,
|
||||
+ },
|
||||
+ .probe = airoha_trng_probe,
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(airoha_trng_driver);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
|
||||
+MODULE_DESCRIPTION("Airoha True Random Number Generator driver");
|
||||
@ -1,130 +0,0 @@
|
||||
From 0c729f53b8c33b9e5eadc2d5e673759e3510501e Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 29 Oct 2024 13:17:10 +0100
|
||||
Subject: [PATCH 2/2] net: airoha: Simplify Tx napi logic
|
||||
|
||||
Simplify Tx napi logic relying just on the packet index provided by
|
||||
completion queue indicating the completed packet that can be removed
|
||||
from the Tx DMA ring.
|
||||
This is a preliminary patch to add Qdisc offload for airoha_eth driver.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20241029-airoha-en7581-tx-napi-work-v1-2-96ad1686b946@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 73 ++++++++++++----------
|
||||
1 file changed, 41 insertions(+), 32 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -1690,8 +1690,12 @@ static int airoha_qdma_tx_napi_poll(stru
|
||||
irq_queued = FIELD_GET(IRQ_ENTRY_LEN_MASK, status);
|
||||
|
||||
while (irq_queued > 0 && done < budget) {
|
||||
- u32 qid, last, val = irq_q->q[head];
|
||||
+ u32 qid, val = irq_q->q[head];
|
||||
+ struct airoha_qdma_desc *desc;
|
||||
+ struct airoha_queue_entry *e;
|
||||
struct airoha_queue *q;
|
||||
+ u32 index, desc_ctrl;
|
||||
+ struct sk_buff *skb;
|
||||
|
||||
if (val == 0xff)
|
||||
break;
|
||||
@@ -1701,9 +1705,7 @@ static int airoha_qdma_tx_napi_poll(stru
|
||||
irq_queued--;
|
||||
done++;
|
||||
|
||||
- last = FIELD_GET(IRQ_DESC_IDX_MASK, val);
|
||||
qid = FIELD_GET(IRQ_RING_IDX_MASK, val);
|
||||
-
|
||||
if (qid >= ARRAY_SIZE(qdma->q_tx))
|
||||
continue;
|
||||
|
||||
@@ -1711,46 +1713,53 @@ static int airoha_qdma_tx_napi_poll(stru
|
||||
if (!q->ndesc)
|
||||
continue;
|
||||
|
||||
+ index = FIELD_GET(IRQ_DESC_IDX_MASK, val);
|
||||
+ if (index >= q->ndesc)
|
||||
+ continue;
|
||||
+
|
||||
spin_lock_bh(&q->lock);
|
||||
|
||||
- while (q->queued > 0) {
|
||||
- struct airoha_qdma_desc *desc = &q->desc[q->tail];
|
||||
- struct airoha_queue_entry *e = &q->entry[q->tail];
|
||||
- u32 desc_ctrl = le32_to_cpu(desc->ctrl);
|
||||
- struct sk_buff *skb = e->skb;
|
||||
- u16 index = q->tail;
|
||||
-
|
||||
- if (!(desc_ctrl & QDMA_DESC_DONE_MASK) &&
|
||||
- !(desc_ctrl & QDMA_DESC_DROP_MASK))
|
||||
- break;
|
||||
+ if (!q->queued)
|
||||
+ goto unlock;
|
||||
|
||||
- q->tail = (q->tail + 1) % q->ndesc;
|
||||
- q->queued--;
|
||||
+ desc = &q->desc[index];
|
||||
+ desc_ctrl = le32_to_cpu(desc->ctrl);
|
||||
|
||||
- dma_unmap_single(eth->dev, e->dma_addr, e->dma_len,
|
||||
- DMA_TO_DEVICE);
|
||||
-
|
||||
- WRITE_ONCE(desc->msg0, 0);
|
||||
- WRITE_ONCE(desc->msg1, 0);
|
||||
+ if (!(desc_ctrl & QDMA_DESC_DONE_MASK) &&
|
||||
+ !(desc_ctrl & QDMA_DESC_DROP_MASK))
|
||||
+ goto unlock;
|
||||
+
|
||||
+ e = &q->entry[index];
|
||||
+ skb = e->skb;
|
||||
+
|
||||
+ dma_unmap_single(eth->dev, e->dma_addr, e->dma_len,
|
||||
+ DMA_TO_DEVICE);
|
||||
+ memset(e, 0, sizeof(*e));
|
||||
+ WRITE_ONCE(desc->msg0, 0);
|
||||
+ WRITE_ONCE(desc->msg1, 0);
|
||||
+ q->queued--;
|
||||
+
|
||||
+ /* completion ring can report out-of-order indexes if hw QoS
|
||||
+ * is enabled and packets with different priority are queued
|
||||
+ * to same DMA ring. Take into account possible out-of-order
|
||||
+ * reports incrementing DMA ring tail pointer
|
||||
+ */
|
||||
+ while (q->tail != q->head && !q->entry[q->tail].dma_addr)
|
||||
+ q->tail = (q->tail + 1) % q->ndesc;
|
||||
|
||||
- if (skb) {
|
||||
- u16 queue = skb_get_queue_mapping(skb);
|
||||
- struct netdev_queue *txq;
|
||||
-
|
||||
- txq = netdev_get_tx_queue(skb->dev, queue);
|
||||
- netdev_tx_completed_queue(txq, 1, skb->len);
|
||||
- if (netif_tx_queue_stopped(txq) &&
|
||||
- q->ndesc - q->queued >= q->free_thr)
|
||||
- netif_tx_wake_queue(txq);
|
||||
-
|
||||
- dev_kfree_skb_any(skb);
|
||||
- e->skb = NULL;
|
||||
- }
|
||||
+ if (skb) {
|
||||
+ u16 queue = skb_get_queue_mapping(skb);
|
||||
+ struct netdev_queue *txq;
|
||||
+
|
||||
+ txq = netdev_get_tx_queue(skb->dev, queue);
|
||||
+ netdev_tx_completed_queue(txq, 1, skb->len);
|
||||
+ if (netif_tx_queue_stopped(txq) &&
|
||||
+ q->ndesc - q->queued >= q->free_thr)
|
||||
+ netif_tx_wake_queue(txq);
|
||||
|
||||
- if (index == last)
|
||||
- break;
|
||||
+ dev_kfree_skb_any(skb);
|
||||
}
|
||||
-
|
||||
+unlock:
|
||||
spin_unlock_bh(&q->lock);
|
||||
}
|
||||
|
||||
@ -1,267 +0,0 @@
|
||||
From 3cf67f3769b8227ca75ca7102180a2e270ee01aa Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Fri, 11 Oct 2024 12:43:53 +0200
|
||||
Subject: [PATCH] watchdog: Add support for Airoha EN7851 watchdog
|
||||
|
||||
Add support for Airoha EN7851 watchdog. This is a very basic watchdog
|
||||
with no pretimeout support, max timeout is 28 seconds and it ticks based
|
||||
on half the SoC BUS clock.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
|
||||
Link: https://lore.kernel.org/r/20241011104411.28659-2-ansuelsmth@gmail.com
|
||||
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
|
||||
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
|
||||
---
|
||||
drivers/watchdog/Kconfig | 8 ++
|
||||
drivers/watchdog/Makefile | 1 +
|
||||
drivers/watchdog/airoha_wdt.c | 216 ++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 225 insertions(+)
|
||||
create mode 100644 drivers/watchdog/airoha_wdt.c
|
||||
|
||||
--- a/drivers/watchdog/Kconfig
|
||||
+++ b/drivers/watchdog/Kconfig
|
||||
@@ -408,6 +408,14 @@ config SL28CPLD_WATCHDOG
|
||||
|
||||
# ARM Architecture
|
||||
|
||||
+config AIROHA_WATCHDOG
|
||||
+ tristate "Airoha EN7581 Watchdog"
|
||||
+ depends on ARCH_AIROHA || COMPILE_TEST
|
||||
+ select WATCHDOG_CORE
|
||||
+ help
|
||||
+ Watchdog timer embedded into Airoha SoC. This will reboot your
|
||||
+ system when the timeout is reached.
|
||||
+
|
||||
config ARM_SP805_WATCHDOG
|
||||
tristate "ARM SP805 Watchdog"
|
||||
depends on (ARM || ARM64 || COMPILE_TEST) && ARM_AMBA
|
||||
--- a/drivers/watchdog/Makefile
|
||||
+++ b/drivers/watchdog/Makefile
|
||||
@@ -40,6 +40,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.
|
||||
obj-$(CONFIG_ARM_SP805_WATCHDOG) += sp805_wdt.o
|
||||
obj-$(CONFIG_ARM_SBSA_WATCHDOG) += sbsa_gwdt.o
|
||||
obj-$(CONFIG_ARMADA_37XX_WATCHDOG) += armada_37xx_wdt.o
|
||||
+obj-$(CONFIG_AIROHA_WATCHDOG) += airoha_wdt.o
|
||||
obj-$(CONFIG_ASM9260_WATCHDOG) += asm9260_wdt.o
|
||||
obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o
|
||||
obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/watchdog/airoha_wdt.c
|
||||
@@ -0,0 +1,216 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Airoha Watchdog Driver
|
||||
+ *
|
||||
+ * Copyright (c) 2024, AIROHA All rights reserved.
|
||||
+ *
|
||||
+ * Mayur Kumar <mayur.kumar@airoha.com>
|
||||
+ * Christian Marangi <ansuelsmth@gmail.com>
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/moduleparam.h>
|
||||
+#include <linux/types.h>
|
||||
+#include <linux/bitfield.h>
|
||||
+#include <linux/clk.h>
|
||||
+#include <linux/io.h>
|
||||
+#include <linux/math.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/watchdog.h>
|
||||
+
|
||||
+/* Base address of timer and watchdog registers */
|
||||
+#define TIMER_CTRL 0x0
|
||||
+#define WDT_ENABLE BIT(25)
|
||||
+#define WDT_TIMER_INTERRUPT BIT(21)
|
||||
+/* Timer3 is used as Watchdog Timer */
|
||||
+#define WDT_TIMER_ENABLE BIT(5)
|
||||
+#define WDT_TIMER_LOAD_VALUE 0x2c
|
||||
+#define WDT_TIMER_CUR_VALUE 0x30
|
||||
+#define WDT_TIMER_VAL GENMASK(31, 0)
|
||||
+#define WDT_RELOAD 0x38
|
||||
+#define WDT_RLD BIT(0)
|
||||
+
|
||||
+/* Airoha watchdog structure description */
|
||||
+struct airoha_wdt_desc {
|
||||
+ struct watchdog_device wdog_dev;
|
||||
+ unsigned int wdt_freq;
|
||||
+ void __iomem *base;
|
||||
+};
|
||||
+
|
||||
+#define WDT_HEARTBEAT 24
|
||||
+static int heartbeat = WDT_HEARTBEAT;
|
||||
+module_param(heartbeat, int, 0);
|
||||
+MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. (default="
|
||||
+ __MODULE_STRING(WDT_HEARTBEAT) ")");
|
||||
+
|
||||
+static bool nowayout = WATCHDOG_NOWAYOUT;
|
||||
+module_param(nowayout, bool, 0);
|
||||
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
|
||||
+ __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
||||
+
|
||||
+static int airoha_wdt_start(struct watchdog_device *wdog_dev)
|
||||
+{
|
||||
+ struct airoha_wdt_desc *airoha_wdt = watchdog_get_drvdata(wdog_dev);
|
||||
+ u32 val;
|
||||
+
|
||||
+ val = readl(airoha_wdt->base + TIMER_CTRL);
|
||||
+ val |= (WDT_TIMER_ENABLE | WDT_ENABLE | WDT_TIMER_INTERRUPT);
|
||||
+ writel(val, airoha_wdt->base + TIMER_CTRL);
|
||||
+ val = wdog_dev->timeout * airoha_wdt->wdt_freq;
|
||||
+ writel(val, airoha_wdt->base + WDT_TIMER_LOAD_VALUE);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_wdt_stop(struct watchdog_device *wdog_dev)
|
||||
+{
|
||||
+ struct airoha_wdt_desc *airoha_wdt = watchdog_get_drvdata(wdog_dev);
|
||||
+ u32 val;
|
||||
+
|
||||
+ val = readl(airoha_wdt->base + TIMER_CTRL);
|
||||
+ val &= (~WDT_ENABLE & ~WDT_TIMER_ENABLE);
|
||||
+ writel(val, airoha_wdt->base + TIMER_CTRL);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_wdt_ping(struct watchdog_device *wdog_dev)
|
||||
+{
|
||||
+ struct airoha_wdt_desc *airoha_wdt = watchdog_get_drvdata(wdog_dev);
|
||||
+ u32 val;
|
||||
+
|
||||
+ val = readl(airoha_wdt->base + WDT_RELOAD);
|
||||
+ val |= WDT_RLD;
|
||||
+ writel(val, airoha_wdt->base + WDT_RELOAD);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_wdt_set_timeout(struct watchdog_device *wdog_dev, unsigned int timeout)
|
||||
+{
|
||||
+ wdog_dev->timeout = timeout;
|
||||
+
|
||||
+ if (watchdog_active(wdog_dev)) {
|
||||
+ airoha_wdt_stop(wdog_dev);
|
||||
+ return airoha_wdt_start(wdog_dev);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static unsigned int airoha_wdt_get_timeleft(struct watchdog_device *wdog_dev)
|
||||
+{
|
||||
+ struct airoha_wdt_desc *airoha_wdt = watchdog_get_drvdata(wdog_dev);
|
||||
+ u32 val;
|
||||
+
|
||||
+ val = readl(airoha_wdt->base + WDT_TIMER_CUR_VALUE);
|
||||
+ return DIV_ROUND_UP(val, airoha_wdt->wdt_freq);
|
||||
+}
|
||||
+
|
||||
+static const struct watchdog_info airoha_wdt_info = {
|
||||
+ .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
|
||||
+ .identity = "Airoha Watchdog",
|
||||
+};
|
||||
+
|
||||
+static const struct watchdog_ops airoha_wdt_ops = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .start = airoha_wdt_start,
|
||||
+ .stop = airoha_wdt_stop,
|
||||
+ .ping = airoha_wdt_ping,
|
||||
+ .set_timeout = airoha_wdt_set_timeout,
|
||||
+ .get_timeleft = airoha_wdt_get_timeleft,
|
||||
+};
|
||||
+
|
||||
+static int airoha_wdt_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct airoha_wdt_desc *airoha_wdt;
|
||||
+ struct watchdog_device *wdog_dev;
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct clk *bus_clk;
|
||||
+ int ret;
|
||||
+
|
||||
+ airoha_wdt = devm_kzalloc(dev, sizeof(*airoha_wdt), GFP_KERNEL);
|
||||
+ if (!airoha_wdt)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ airoha_wdt->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(airoha_wdt->base))
|
||||
+ return PTR_ERR(airoha_wdt->base);
|
||||
+
|
||||
+ bus_clk = devm_clk_get_enabled(dev, "bus");
|
||||
+ if (IS_ERR(bus_clk))
|
||||
+ return dev_err_probe(dev, PTR_ERR(bus_clk),
|
||||
+ "failed to enable bus clock\n");
|
||||
+
|
||||
+ /* Watchdog ticks at half the bus rate */
|
||||
+ airoha_wdt->wdt_freq = clk_get_rate(bus_clk) / 2;
|
||||
+
|
||||
+ /* Initialize struct watchdog device */
|
||||
+ wdog_dev = &airoha_wdt->wdog_dev;
|
||||
+ wdog_dev->timeout = heartbeat;
|
||||
+ wdog_dev->info = &airoha_wdt_info;
|
||||
+ wdog_dev->ops = &airoha_wdt_ops;
|
||||
+ /* Bus 300MHz, watchdog 150MHz, 28 seconds */
|
||||
+ wdog_dev->max_timeout = FIELD_MAX(WDT_TIMER_VAL) / airoha_wdt->wdt_freq;
|
||||
+ wdog_dev->parent = dev;
|
||||
+
|
||||
+ watchdog_set_drvdata(wdog_dev, airoha_wdt);
|
||||
+ watchdog_set_nowayout(wdog_dev, nowayout);
|
||||
+ watchdog_stop_on_unregister(wdog_dev);
|
||||
+
|
||||
+ ret = devm_watchdog_register_device(dev, wdog_dev);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ platform_set_drvdata(pdev, airoha_wdt);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_wdt_suspend(struct device *dev)
|
||||
+{
|
||||
+ struct airoha_wdt_desc *airoha_wdt = dev_get_drvdata(dev);
|
||||
+
|
||||
+ if (watchdog_active(&airoha_wdt->wdog_dev))
|
||||
+ airoha_wdt_stop(&airoha_wdt->wdog_dev);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_wdt_resume(struct device *dev)
|
||||
+{
|
||||
+ struct airoha_wdt_desc *airoha_wdt = dev_get_drvdata(dev);
|
||||
+
|
||||
+ if (watchdog_active(&airoha_wdt->wdog_dev)) {
|
||||
+ airoha_wdt_start(&airoha_wdt->wdog_dev);
|
||||
+ airoha_wdt_ping(&airoha_wdt->wdog_dev);
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id airoha_wdt_of_match[] = {
|
||||
+ { .compatible = "airoha,en7581-wdt", },
|
||||
+ { },
|
||||
+};
|
||||
+
|
||||
+MODULE_DEVICE_TABLE(of, airoha_wdt_of_match);
|
||||
+
|
||||
+static DEFINE_SIMPLE_DEV_PM_OPS(airoha_wdt_pm_ops, airoha_wdt_suspend, airoha_wdt_resume);
|
||||
+
|
||||
+static struct platform_driver airoha_wdt_driver = {
|
||||
+ .probe = airoha_wdt_probe,
|
||||
+ .driver = {
|
||||
+ .name = "airoha-wdt",
|
||||
+ .pm = pm_sleep_ptr(&airoha_wdt_pm_ops),
|
||||
+ .of_match_table = airoha_wdt_of_match,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(airoha_wdt_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Mayur Kumar <mayur.kumar@airoha.com>");
|
||||
+MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
|
||||
+MODULE_DESCRIPTION("Airoha EN7581 Watchdog Driver");
|
||||
+MODULE_LICENSE("GPL");
|
||||
@ -1,174 +0,0 @@
|
||||
From 82e6bf912d5846646892becea659b39d178d79e3 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 12 Nov 2024 01:08:53 +0100
|
||||
Subject: [PATCH 5/6] clk: en7523: move en7581_reset_register() in
|
||||
en7581_clk_hw_init()
|
||||
|
||||
Move en7581_reset_register routine in en7581_clk_hw_init() since reset
|
||||
feature is supported just by EN7581 SoC.
|
||||
Get rid of reset struct in en_clk_soc_data data struct.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://lore.kernel.org/r/20241112-clk-en7581-syscon-v2-6-8ada5e394ae4@kernel.org
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/clk-en7523.c | 93 ++++++++++++++--------------------------
|
||||
1 file changed, 33 insertions(+), 60 deletions(-)
|
||||
|
||||
--- a/drivers/clk/clk-en7523.c
|
||||
+++ b/drivers/clk/clk-en7523.c
|
||||
@@ -76,11 +76,6 @@ struct en_rst_data {
|
||||
|
||||
struct en_clk_soc_data {
|
||||
const struct clk_ops pcie_ops;
|
||||
- struct {
|
||||
- const u16 *bank_ofs;
|
||||
- const u16 *idx_map;
|
||||
- u16 idx_map_nr;
|
||||
- } reset;
|
||||
int (*hw_init)(struct platform_device *pdev,
|
||||
struct clk_hw_onecell_data *clk_data);
|
||||
};
|
||||
@@ -596,32 +591,6 @@ static void en7581_register_clocks(struc
|
||||
clk_data->num = EN7523_NUM_CLOCKS;
|
||||
}
|
||||
|
||||
-static int en7581_clk_hw_init(struct platform_device *pdev,
|
||||
- struct clk_hw_onecell_data *clk_data)
|
||||
-{
|
||||
- void __iomem *np_base;
|
||||
- struct regmap *map;
|
||||
- u32 val;
|
||||
-
|
||||
- map = syscon_regmap_lookup_by_compatible("airoha,en7581-chip-scu");
|
||||
- if (IS_ERR(map))
|
||||
- return PTR_ERR(map);
|
||||
-
|
||||
- np_base = devm_platform_ioremap_resource(pdev, 0);
|
||||
- if (IS_ERR(np_base))
|
||||
- return PTR_ERR(np_base);
|
||||
-
|
||||
- en7581_register_clocks(&pdev->dev, clk_data, map, np_base);
|
||||
-
|
||||
- val = readl(np_base + REG_NP_SCU_SSTR);
|
||||
- val &= ~(REG_PCIE_XSI0_SEL_MASK | REG_PCIE_XSI1_SEL_MASK);
|
||||
- writel(val, np_base + REG_NP_SCU_SSTR);
|
||||
- val = readl(np_base + REG_NP_SCU_PCIC);
|
||||
- writel(val | 3, np_base + REG_NP_SCU_PCIC);
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
static int en7523_reset_update(struct reset_controller_dev *rcdev,
|
||||
unsigned long id, bool assert)
|
||||
{
|
||||
@@ -671,23 +640,18 @@ static int en7523_reset_xlate(struct res
|
||||
return rst_data->idx_map[reset_spec->args[0]];
|
||||
}
|
||||
|
||||
-static const struct reset_control_ops en7523_reset_ops = {
|
||||
+static const struct reset_control_ops en7581_reset_ops = {
|
||||
.assert = en7523_reset_assert,
|
||||
.deassert = en7523_reset_deassert,
|
||||
.status = en7523_reset_status,
|
||||
};
|
||||
|
||||
-static int en7523_reset_register(struct platform_device *pdev,
|
||||
- const struct en_clk_soc_data *soc_data)
|
||||
+static int en7581_reset_register(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct en_rst_data *rst_data;
|
||||
void __iomem *base;
|
||||
|
||||
- /* no reset lines available */
|
||||
- if (!soc_data->reset.idx_map_nr)
|
||||
- return 0;
|
||||
-
|
||||
base = devm_platform_ioremap_resource(pdev, 1);
|
||||
if (IS_ERR(base))
|
||||
return PTR_ERR(base);
|
||||
@@ -696,13 +660,13 @@ static int en7523_reset_register(struct
|
||||
if (!rst_data)
|
||||
return -ENOMEM;
|
||||
|
||||
- rst_data->bank_ofs = soc_data->reset.bank_ofs;
|
||||
- rst_data->idx_map = soc_data->reset.idx_map;
|
||||
+ rst_data->bank_ofs = en7581_rst_ofs;
|
||||
+ rst_data->idx_map = en7581_rst_map;
|
||||
rst_data->base = base;
|
||||
|
||||
- rst_data->rcdev.nr_resets = soc_data->reset.idx_map_nr;
|
||||
+ rst_data->rcdev.nr_resets = ARRAY_SIZE(en7581_rst_map);
|
||||
rst_data->rcdev.of_xlate = en7523_reset_xlate;
|
||||
- rst_data->rcdev.ops = &en7523_reset_ops;
|
||||
+ rst_data->rcdev.ops = &en7581_reset_ops;
|
||||
rst_data->rcdev.of_node = dev->of_node;
|
||||
rst_data->rcdev.of_reset_n_cells = 1;
|
||||
rst_data->rcdev.owner = THIS_MODULE;
|
||||
@@ -711,6 +675,32 @@ static int en7523_reset_register(struct
|
||||
return devm_reset_controller_register(dev, &rst_data->rcdev);
|
||||
}
|
||||
|
||||
+static int en7581_clk_hw_init(struct platform_device *pdev,
|
||||
+ struct clk_hw_onecell_data *clk_data)
|
||||
+{
|
||||
+ void __iomem *np_base;
|
||||
+ struct regmap *map;
|
||||
+ u32 val;
|
||||
+
|
||||
+ map = syscon_regmap_lookup_by_compatible("airoha,en7581-chip-scu");
|
||||
+ if (IS_ERR(map))
|
||||
+ return PTR_ERR(map);
|
||||
+
|
||||
+ np_base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(np_base))
|
||||
+ return PTR_ERR(np_base);
|
||||
+
|
||||
+ en7581_register_clocks(&pdev->dev, clk_data, map, np_base);
|
||||
+
|
||||
+ val = readl(np_base + REG_NP_SCU_SSTR);
|
||||
+ val &= ~(REG_PCIE_XSI0_SEL_MASK | REG_PCIE_XSI1_SEL_MASK);
|
||||
+ writel(val, np_base + REG_NP_SCU_SSTR);
|
||||
+ val = readl(np_base + REG_NP_SCU_PCIC);
|
||||
+ writel(val | 3, np_base + REG_NP_SCU_PCIC);
|
||||
+
|
||||
+ return en7581_reset_register(pdev);
|
||||
+}
|
||||
+
|
||||
static int en7523_clk_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
@@ -729,19 +719,7 @@ static int en7523_clk_probe(struct platf
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r)
|
||||
- return dev_err_probe(&pdev->dev, r, "Could not register clock provider: %s\n",
|
||||
- pdev->name);
|
||||
-
|
||||
- r = en7523_reset_register(pdev, soc_data);
|
||||
- if (r) {
|
||||
- of_clk_del_provider(node);
|
||||
- return dev_err_probe(&pdev->dev, r, "Could not register reset controller: %s\n",
|
||||
- pdev->name);
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
+ return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
}
|
||||
|
||||
static const struct en_clk_soc_data en7523_data = {
|
||||
@@ -759,11 +737,6 @@ static const struct en_clk_soc_data en75
|
||||
.enable = en7581_pci_enable,
|
||||
.disable = en7581_pci_disable,
|
||||
},
|
||||
- .reset = {
|
||||
- .bank_ofs = en7581_rst_ofs,
|
||||
- .idx_map = en7581_rst_map,
|
||||
- .idx_map_nr = ARRAY_SIZE(en7581_rst_map),
|
||||
- },
|
||||
.hw_init = en7581_clk_hw_init,
|
||||
};
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
From a9eaf305017a5ebe73ab34e85bd5414055a88f29 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 12 Nov 2024 01:08:54 +0100
|
||||
Subject: [PATCH 6/6] clk: en7523: map io region in a single block
|
||||
|
||||
Map all clock-controller memory region in a single block.
|
||||
This patch does not introduce any backward incompatibility since the dts
|
||||
for EN7581 SoC is not upstream yet.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://lore.kernel.org/r/20241112-clk-en7581-syscon-v2-7-8ada5e394ae4@kernel.org
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/clk-en7523.c | 32 +++++++++++++-------------------
|
||||
1 file changed, 13 insertions(+), 19 deletions(-)
|
||||
|
||||
--- a/drivers/clk/clk-en7523.c
|
||||
+++ b/drivers/clk/clk-en7523.c
|
||||
@@ -39,8 +39,8 @@
|
||||
#define REG_PCIE_XSI1_SEL_MASK GENMASK(12, 11)
|
||||
#define REG_CRYPTO_CLKSRC2 0x20c
|
||||
|
||||
-#define REG_RST_CTRL2 0x00
|
||||
-#define REG_RST_CTRL1 0x04
|
||||
+#define REG_RST_CTRL2 0x830
|
||||
+#define REG_RST_CTRL1 0x834
|
||||
|
||||
struct en_clk_desc {
|
||||
int id;
|
||||
@@ -646,15 +646,9 @@ static const struct reset_control_ops en
|
||||
.status = en7523_reset_status,
|
||||
};
|
||||
|
||||
-static int en7581_reset_register(struct platform_device *pdev)
|
||||
+static int en7581_reset_register(struct device *dev, void __iomem *base)
|
||||
{
|
||||
- struct device *dev = &pdev->dev;
|
||||
struct en_rst_data *rst_data;
|
||||
- void __iomem *base;
|
||||
-
|
||||
- base = devm_platform_ioremap_resource(pdev, 1);
|
||||
- if (IS_ERR(base))
|
||||
- return PTR_ERR(base);
|
||||
|
||||
rst_data = devm_kzalloc(dev, sizeof(*rst_data), GFP_KERNEL);
|
||||
if (!rst_data)
|
||||
@@ -678,27 +672,27 @@ static int en7581_reset_register(struct
|
||||
static int en7581_clk_hw_init(struct platform_device *pdev,
|
||||
struct clk_hw_onecell_data *clk_data)
|
||||
{
|
||||
- void __iomem *np_base;
|
||||
struct regmap *map;
|
||||
+ void __iomem *base;
|
||||
u32 val;
|
||||
|
||||
map = syscon_regmap_lookup_by_compatible("airoha,en7581-chip-scu");
|
||||
if (IS_ERR(map))
|
||||
return PTR_ERR(map);
|
||||
|
||||
- np_base = devm_platform_ioremap_resource(pdev, 0);
|
||||
- if (IS_ERR(np_base))
|
||||
- return PTR_ERR(np_base);
|
||||
+ base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(base))
|
||||
+ return PTR_ERR(base);
|
||||
|
||||
- en7581_register_clocks(&pdev->dev, clk_data, map, np_base);
|
||||
+ en7581_register_clocks(&pdev->dev, clk_data, map, base);
|
||||
|
||||
- val = readl(np_base + REG_NP_SCU_SSTR);
|
||||
+ val = readl(base + REG_NP_SCU_SSTR);
|
||||
val &= ~(REG_PCIE_XSI0_SEL_MASK | REG_PCIE_XSI1_SEL_MASK);
|
||||
- writel(val, np_base + REG_NP_SCU_SSTR);
|
||||
- val = readl(np_base + REG_NP_SCU_PCIC);
|
||||
- writel(val | 3, np_base + REG_NP_SCU_PCIC);
|
||||
+ writel(val, base + REG_NP_SCU_SSTR);
|
||||
+ val = readl(base + REG_NP_SCU_PCIC);
|
||||
+ writel(val | 3, base + REG_NP_SCU_PCIC);
|
||||
|
||||
- return en7581_reset_register(pdev);
|
||||
+ return en7581_reset_register(&pdev->dev, base);
|
||||
}
|
||||
|
||||
static int en7523_clk_probe(struct platform_device *pdev)
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,61 +0,0 @@
|
||||
From ac6f0825e582f2216a582c9edf0cee7bfe347ba6 Mon Sep 17 00:00:00 2001
|
||||
From: Kees Cook <kees@kernel.org>
|
||||
Date: Sun, 17 Nov 2024 03:45:38 -0800
|
||||
Subject: [PATCH] pinctrl: airoha: Use unsigned long for bit search
|
||||
|
||||
Instead of risking alignment problems and causing (false positive) array
|
||||
bound warnings when casting a u32 to (64-bit) unsigned long, just use a
|
||||
native unsigned long for doing bit searches. Avoids warning with GCC 15's
|
||||
-Warray-bounds -fdiagnostics-details:
|
||||
|
||||
In file included from ../include/linux/bitmap.h:11,
|
||||
from ../include/linux/cpumask.h:12,
|
||||
from ../arch/x86/include/asm/paravirt.h:21,
|
||||
from ../arch/x86/include/asm/irqflags.h:80,
|
||||
from ../include/linux/irqflags.h:18,
|
||||
from ../include/linux/spinlock.h:59,
|
||||
from ../include/linux/irq.h:14,
|
||||
from ../include/linux/irqchip/chained_irq.h:10,
|
||||
from ../include/linux/gpio/driver.h:8,
|
||||
from ../drivers/pinctrl/mediatek/pinctrl-airoha.c:11:
|
||||
In function 'find_next_bit',
|
||||
inlined from 'airoha_irq_handler' at ../drivers/pinctrl/mediatek/pinctrl-airoha.c:2394:3:
|
||||
../include/linux/find.h:65:23: error: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u32[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds=]
|
||||
65 | val = *addr & GENMASK(size - 1, offset);
|
||||
| ^~~~~
|
||||
../drivers/pinctrl/mediatek/pinctrl-airoha.c: In function 'airoha_irq_handler':
|
||||
../drivers/pinctrl/mediatek/pinctrl-airoha.c:2387:21: note: object 'status' of size 4
|
||||
2387 | u32 status;
|
||||
| ^~~~~~
|
||||
|
||||
Signed-off-by: Kees Cook <kees@kernel.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/20241117114534.work.292-kees@kernel.org
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-airoha.c | 9 +++++----
|
||||
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
@@ -2384,15 +2384,16 @@ static irqreturn_t airoha_irq_handler(in
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(irq_status_regs); i++) {
|
||||
struct gpio_irq_chip *girq = &pinctrl->gpiochip.chip.irq;
|
||||
- u32 status;
|
||||
+ u32 regmap;
|
||||
+ unsigned long status;
|
||||
int irq;
|
||||
|
||||
if (regmap_read(pinctrl->regmap, pinctrl->gpiochip.status[i],
|
||||
- &status))
|
||||
+ ®map))
|
||||
continue;
|
||||
|
||||
- for_each_set_bit(irq, (unsigned long *)&status,
|
||||
- AIROHA_PIN_BANK_SIZE) {
|
||||
+ status = regmap;
|
||||
+ for_each_set_bit(irq, &status, AIROHA_PIN_BANK_SIZE) {
|
||||
u32 offset = irq + i * AIROHA_PIN_BANK_SIZE;
|
||||
|
||||
generic_handle_irq(irq_find_mapping(girq->domain,
|
||||
@ -1,35 +0,0 @@
|
||||
From 30d9d8f6a2d7e44a9f91737dd409dbc87ac6f6b7 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 15 Oct 2024 09:58:09 +0200
|
||||
Subject: [PATCH] net: airoha: Fix typo in REG_CDM2_FWD_CFG configuration
|
||||
|
||||
Fix typo in airoha_fe_init routine configuring CDM2_OAM_QSEL_MASK field
|
||||
of REG_CDM2_FWD_CFG register.
|
||||
This bug is not introducing any user visible problem since Frame Engine
|
||||
CDM2 port is used just by the second QDMA block and we currently enable
|
||||
just QDMA1 block connected to the MT7530 dsa switch via CDM1 port.
|
||||
|
||||
Introduced by commit 23020f049327 ("net: airoha: Introduce ethernet
|
||||
support for EN7581 SoC")
|
||||
|
||||
Reported-by: ChihWei Cheng <chihwei.cheng@airoha.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Message-ID: <20241015-airoha-eth-cdm2-fixes-v1-1-9dc6993286c3@kernel.org>
|
||||
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -1369,7 +1369,8 @@ static int airoha_fe_init(struct airoha_
|
||||
airoha_fe_set(eth, REG_GDM_MISC_CFG,
|
||||
GDM2_RDM_ACK_WAIT_PREF_MASK |
|
||||
GDM2_CHN_VLD_MODE_MASK);
|
||||
- airoha_fe_rmw(eth, REG_CDM2_FWD_CFG, CDM2_OAM_QSEL_MASK, 15);
|
||||
+ airoha_fe_rmw(eth, REG_CDM2_FWD_CFG, CDM2_OAM_QSEL_MASK,
|
||||
+ FIELD_PREP(CDM2_OAM_QSEL_MASK, 15));
|
||||
|
||||
/* init fragment and assemble Force Port */
|
||||
/* NPU Core-3, NPU Bridge Channel-3 */
|
||||
@ -1,27 +0,0 @@
|
||||
From 5f795590380476f1c9b7ed0ac945c9b0269dc23a Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 3 Jan 2025 13:17:02 +0100
|
||||
Subject: [PATCH 1/4] net: airoha: Enable Tx drop capability for each Tx DMA
|
||||
ring
|
||||
|
||||
This is a preliminary patch in order to enable hw Qdisc offloading.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -1810,6 +1810,10 @@ static int airoha_qdma_init_tx_queue(str
|
||||
WRITE_ONCE(q->desc[i].ctrl, cpu_to_le32(val));
|
||||
}
|
||||
|
||||
+ /* xmit ring drop default setting */
|
||||
+ airoha_qdma_set(qdma, REG_TX_RING_BLOCKING(qid),
|
||||
+ TX_RING_IRQ_BLOCKING_TX_DROP_EN_MASK);
|
||||
+
|
||||
airoha_qdma_wr(qdma, REG_TX_RING_BASE(qid), dma_addr);
|
||||
airoha_qdma_rmw(qdma, REG_TX_CPU_IDX(qid), TX_RING_CPU_IDX_MASK,
|
||||
FIELD_PREP(TX_RING_CPU_IDX_MASK, q->head));
|
||||
@ -1,86 +0,0 @@
|
||||
From 2b288b81560b94958cd68bbe54673e55a1730c95 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 3 Jan 2025 13:17:03 +0100
|
||||
Subject: [PATCH 2/4] net: airoha: Introduce ndo_select_queue callback
|
||||
|
||||
Airoha EN7581 SoC supports 32 Tx DMA rings used to feed packets to QoS
|
||||
channels. Each channels supports 8 QoS queues where the user can apply
|
||||
QoS scheduling policies. In a similar way, the user can configure hw
|
||||
rate shaping for each QoS channel.
|
||||
Introduce ndo_select_queue callback in order to select the tx queue
|
||||
based on QoS channel and QoS queue. In particular, for dsa device select
|
||||
QoS channel according to the dsa user port index, rely on port id
|
||||
otherwise. Select QoS queue based on the skb priority.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 30 ++++++++++++++++++++--
|
||||
1 file changed, 28 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -23,6 +23,8 @@
|
||||
#define AIROHA_MAX_NUM_XSI_RSTS 5
|
||||
#define AIROHA_MAX_MTU 2000
|
||||
#define AIROHA_MAX_PACKET_SIZE 2048
|
||||
+#define AIROHA_NUM_QOS_CHANNELS 4
|
||||
+#define AIROHA_NUM_QOS_QUEUES 8
|
||||
#define AIROHA_NUM_TX_RING 32
|
||||
#define AIROHA_NUM_RX_RING 32
|
||||
#define AIROHA_FE_MC_MAX_VLAN_TABLE 64
|
||||
@@ -2442,21 +2444,44 @@ static void airoha_dev_get_stats64(struc
|
||||
} while (u64_stats_fetch_retry(&port->stats.syncp, start));
|
||||
}
|
||||
|
||||
+static u16 airoha_dev_select_queue(struct net_device *dev, struct sk_buff *skb,
|
||||
+ struct net_device *sb_dev)
|
||||
+{
|
||||
+ struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
+ int queue, channel;
|
||||
+
|
||||
+ /* For dsa device select QoS channel according to the dsa user port
|
||||
+ * index, rely on port id otherwise. Select QoS queue based on the
|
||||
+ * skb priority.
|
||||
+ */
|
||||
+ channel = netdev_uses_dsa(dev) ? skb_get_queue_mapping(skb) : port->id;
|
||||
+ channel = channel % AIROHA_NUM_QOS_CHANNELS;
|
||||
+ queue = (skb->priority - 1) % AIROHA_NUM_QOS_QUEUES; /* QoS queue */
|
||||
+ queue = channel * AIROHA_NUM_QOS_QUEUES + queue;
|
||||
+
|
||||
+ return queue < dev->num_tx_queues ? queue : 0;
|
||||
+}
|
||||
+
|
||||
static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
struct skb_shared_info *sinfo = skb_shinfo(skb);
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
- u32 msg0 = 0, msg1, len = skb_headlen(skb);
|
||||
- int i, qid = skb_get_queue_mapping(skb);
|
||||
+ u32 msg0, msg1, len = skb_headlen(skb);
|
||||
struct airoha_qdma *qdma = port->qdma;
|
||||
u32 nr_frags = 1 + sinfo->nr_frags;
|
||||
struct netdev_queue *txq;
|
||||
struct airoha_queue *q;
|
||||
void *data = skb->data;
|
||||
+ int i, qid;
|
||||
u16 index;
|
||||
u8 fport;
|
||||
|
||||
+ qid = skb_get_queue_mapping(skb) % ARRAY_SIZE(qdma->q_tx);
|
||||
+ msg0 = FIELD_PREP(QDMA_ETH_TXMSG_CHAN_MASK,
|
||||
+ qid / AIROHA_NUM_QOS_QUEUES) |
|
||||
+ FIELD_PREP(QDMA_ETH_TXMSG_QUEUE_MASK,
|
||||
+ qid % AIROHA_NUM_QOS_QUEUES);
|
||||
if (skb->ip_summed == CHECKSUM_PARTIAL)
|
||||
msg0 |= FIELD_PREP(QDMA_ETH_TXMSG_TCO_MASK, 1) |
|
||||
FIELD_PREP(QDMA_ETH_TXMSG_UCO_MASK, 1) |
|
||||
@@ -2630,6 +2655,7 @@ static const struct net_device_ops airoh
|
||||
.ndo_init = airoha_dev_init,
|
||||
.ndo_open = airoha_dev_open,
|
||||
.ndo_stop = airoha_dev_stop,
|
||||
+ .ndo_select_queue = airoha_dev_select_queue,
|
||||
.ndo_start_xmit = airoha_dev_xmit,
|
||||
.ndo_get_stats64 = airoha_dev_get_stats64,
|
||||
.ndo_set_mac_address = airoha_dev_set_macaddr,
|
||||
@ -1,292 +0,0 @@
|
||||
From 20bf7d07c956e5c7a22d3076c599cbb7a6054917 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 3 Jan 2025 13:17:04 +0100
|
||||
Subject: [PATCH 3/4] net: airoha: Add sched ETS offload support
|
||||
|
||||
Introduce support for ETS Qdisc offload available on the Airoha EN7581
|
||||
ethernet controller. In order to be effective, ETS Qdisc must configured
|
||||
as leaf of a HTB Qdisc (HTB Qdisc offload will be added in the following
|
||||
patch). ETS Qdisc available on EN7581 ethernet controller supports at
|
||||
most 8 concurrent bands (QoS queues). We can enable an ETS Qdisc for
|
||||
each available QoS channel.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 196 ++++++++++++++++++++-
|
||||
1 file changed, 195 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <linux/u64_stats_sync.h>
|
||||
#include <net/dsa.h>
|
||||
#include <net/page_pool/helpers.h>
|
||||
+#include <net/pkt_cls.h>
|
||||
#include <uapi/linux/ppp_defs.h>
|
||||
|
||||
#define AIROHA_MAX_NUM_GDM_PORTS 1
|
||||
@@ -543,9 +544,24 @@
|
||||
#define INGRESS_SLOW_TICK_RATIO_MASK GENMASK(29, 16)
|
||||
#define INGRESS_FAST_TICK_MASK GENMASK(15, 0)
|
||||
|
||||
+#define REG_QUEUE_CLOSE_CFG(_n) (0x00a0 + ((_n) & 0xfc))
|
||||
+#define TXQ_DISABLE_CHAN_QUEUE_MASK(_n, _m) BIT((_m) + (((_n) & 0x3) << 3))
|
||||
+
|
||||
#define REG_TXQ_DIS_CFG_BASE(_n) ((_n) ? 0x20a0 : 0x00a0)
|
||||
#define REG_TXQ_DIS_CFG(_n, _m) (REG_TXQ_DIS_CFG_BASE((_n)) + (_m) << 2)
|
||||
|
||||
+#define REG_CNTR_CFG(_n) (0x0400 + ((_n) << 3))
|
||||
+#define CNTR_EN_MASK BIT(31)
|
||||
+#define CNTR_ALL_CHAN_EN_MASK BIT(30)
|
||||
+#define CNTR_ALL_QUEUE_EN_MASK BIT(29)
|
||||
+#define CNTR_ALL_DSCP_RING_EN_MASK BIT(28)
|
||||
+#define CNTR_SRC_MASK GENMASK(27, 24)
|
||||
+#define CNTR_DSCP_RING_MASK GENMASK(20, 16)
|
||||
+#define CNTR_CHAN_MASK GENMASK(7, 3)
|
||||
+#define CNTR_QUEUE_MASK GENMASK(2, 0)
|
||||
+
|
||||
+#define REG_CNTR_VAL(_n) (0x0404 + ((_n) << 3))
|
||||
+
|
||||
#define REG_LMGR_INIT_CFG 0x1000
|
||||
#define LMGR_INIT_START BIT(31)
|
||||
#define LMGR_SRAM_MODE_MASK BIT(30)
|
||||
@@ -571,9 +587,19 @@
|
||||
#define TWRR_WEIGHT_SCALE_MASK BIT(31)
|
||||
#define TWRR_WEIGHT_BASE_MASK BIT(3)
|
||||
|
||||
+#define REG_TXWRR_WEIGHT_CFG 0x1024
|
||||
+#define TWRR_RW_CMD_MASK BIT(31)
|
||||
+#define TWRR_RW_CMD_DONE BIT(30)
|
||||
+#define TWRR_CHAN_IDX_MASK GENMASK(23, 19)
|
||||
+#define TWRR_QUEUE_IDX_MASK GENMASK(18, 16)
|
||||
+#define TWRR_VALUE_MASK GENMASK(15, 0)
|
||||
+
|
||||
#define REG_PSE_BUF_USAGE_CFG 0x1028
|
||||
#define PSE_BUF_ESTIMATE_EN_MASK BIT(29)
|
||||
|
||||
+#define REG_CHAN_QOS_MODE(_n) (0x1040 + ((_n) << 2))
|
||||
+#define CHAN_QOS_MODE_MASK(_n) GENMASK(2 + ((_n) << 2), (_n) << 2)
|
||||
+
|
||||
#define REG_GLB_TRTCM_CFG 0x1080
|
||||
#define GLB_TRTCM_EN_MASK BIT(31)
|
||||
#define GLB_TRTCM_MODE_MASK BIT(30)
|
||||
@@ -722,6 +748,17 @@ enum {
|
||||
FE_PSE_PORT_DROP = 0xf,
|
||||
};
|
||||
|
||||
+enum tx_sched_mode {
|
||||
+ TC_SCH_WRR8,
|
||||
+ TC_SCH_SP,
|
||||
+ TC_SCH_WRR7,
|
||||
+ TC_SCH_WRR6,
|
||||
+ TC_SCH_WRR5,
|
||||
+ TC_SCH_WRR4,
|
||||
+ TC_SCH_WRR3,
|
||||
+ TC_SCH_WRR2,
|
||||
+};
|
||||
+
|
||||
struct airoha_queue_entry {
|
||||
union {
|
||||
void *buf;
|
||||
@@ -812,6 +849,10 @@ struct airoha_gdm_port {
|
||||
int id;
|
||||
|
||||
struct airoha_hw_stats stats;
|
||||
+
|
||||
+ /* qos stats counters */
|
||||
+ u64 cpu_tx_packets;
|
||||
+ u64 fwd_tx_packets;
|
||||
};
|
||||
|
||||
struct airoha_eth {
|
||||
@@ -1982,6 +2023,27 @@ static void airoha_qdma_init_qos(struct
|
||||
FIELD_PREP(SLA_SLOW_TICK_RATIO_MASK, 40));
|
||||
}
|
||||
|
||||
+static void airoha_qdma_init_qos_stats(struct airoha_qdma *qdma)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < AIROHA_NUM_QOS_CHANNELS; i++) {
|
||||
+ /* Tx-cpu transferred count */
|
||||
+ airoha_qdma_wr(qdma, REG_CNTR_VAL(i << 1), 0);
|
||||
+ airoha_qdma_wr(qdma, REG_CNTR_CFG(i << 1),
|
||||
+ CNTR_EN_MASK | CNTR_ALL_QUEUE_EN_MASK |
|
||||
+ CNTR_ALL_DSCP_RING_EN_MASK |
|
||||
+ FIELD_PREP(CNTR_CHAN_MASK, i));
|
||||
+ /* Tx-fwd transferred count */
|
||||
+ airoha_qdma_wr(qdma, REG_CNTR_VAL((i << 1) + 1), 0);
|
||||
+ airoha_qdma_wr(qdma, REG_CNTR_CFG(i << 1),
|
||||
+ CNTR_EN_MASK | CNTR_ALL_QUEUE_EN_MASK |
|
||||
+ CNTR_ALL_DSCP_RING_EN_MASK |
|
||||
+ FIELD_PREP(CNTR_SRC_MASK, 1) |
|
||||
+ FIELD_PREP(CNTR_CHAN_MASK, i));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int airoha_qdma_hw_init(struct airoha_qdma *qdma)
|
||||
{
|
||||
int i;
|
||||
@@ -2032,6 +2094,7 @@ static int airoha_qdma_hw_init(struct ai
|
||||
|
||||
airoha_qdma_set(qdma, REG_TXQ_CNGST_CFG,
|
||||
TXQ_CNGST_DROP_EN | TXQ_CNGST_DEI_DROP_EN);
|
||||
+ airoha_qdma_init_qos_stats(qdma);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2651,6 +2714,135 @@ airoha_ethtool_get_rmon_stats(struct net
|
||||
} while (u64_stats_fetch_retry(&port->stats.syncp, start));
|
||||
}
|
||||
|
||||
+static int airoha_qdma_set_chan_tx_sched(struct airoha_gdm_port *port,
|
||||
+ int channel, enum tx_sched_mode mode,
|
||||
+ const u16 *weights, u8 n_weights)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < AIROHA_NUM_TX_RING; i++)
|
||||
+ airoha_qdma_clear(port->qdma, REG_QUEUE_CLOSE_CFG(channel),
|
||||
+ TXQ_DISABLE_CHAN_QUEUE_MASK(channel, i));
|
||||
+
|
||||
+ for (i = 0; i < n_weights; i++) {
|
||||
+ u32 status;
|
||||
+ int err;
|
||||
+
|
||||
+ airoha_qdma_wr(port->qdma, REG_TXWRR_WEIGHT_CFG,
|
||||
+ TWRR_RW_CMD_MASK |
|
||||
+ FIELD_PREP(TWRR_CHAN_IDX_MASK, channel) |
|
||||
+ FIELD_PREP(TWRR_QUEUE_IDX_MASK, i) |
|
||||
+ FIELD_PREP(TWRR_VALUE_MASK, weights[i]));
|
||||
+ err = read_poll_timeout(airoha_qdma_rr, status,
|
||||
+ status & TWRR_RW_CMD_DONE,
|
||||
+ USEC_PER_MSEC, 10 * USEC_PER_MSEC,
|
||||
+ true, port->qdma,
|
||||
+ REG_TXWRR_WEIGHT_CFG);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ airoha_qdma_rmw(port->qdma, REG_CHAN_QOS_MODE(channel >> 3),
|
||||
+ CHAN_QOS_MODE_MASK(channel),
|
||||
+ mode << __ffs(CHAN_QOS_MODE_MASK(channel)));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_set_tx_prio_sched(struct airoha_gdm_port *port,
|
||||
+ int channel)
|
||||
+{
|
||||
+ static const u16 w[AIROHA_NUM_QOS_QUEUES] = {};
|
||||
+
|
||||
+ return airoha_qdma_set_chan_tx_sched(port, channel, TC_SCH_SP, w,
|
||||
+ ARRAY_SIZE(w));
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_set_tx_ets_sched(struct airoha_gdm_port *port,
|
||||
+ int channel,
|
||||
+ struct tc_ets_qopt_offload *opt)
|
||||
+{
|
||||
+ struct tc_ets_qopt_offload_replace_params *p = &opt->replace_params;
|
||||
+ enum tx_sched_mode mode = TC_SCH_SP;
|
||||
+ u16 w[AIROHA_NUM_QOS_QUEUES] = {};
|
||||
+ int i, nstrict = 0;
|
||||
+
|
||||
+ if (p->bands > AIROHA_NUM_QOS_QUEUES)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ for (i = 0; i < p->bands; i++) {
|
||||
+ if (!p->quanta[i])
|
||||
+ nstrict++;
|
||||
+ }
|
||||
+
|
||||
+ /* this configuration is not supported by the hw */
|
||||
+ if (nstrict == AIROHA_NUM_QOS_QUEUES - 1)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ for (i = 0; i < p->bands - nstrict; i++)
|
||||
+ w[i] = p->weights[nstrict + i];
|
||||
+
|
||||
+ if (!nstrict)
|
||||
+ mode = TC_SCH_WRR8;
|
||||
+ else if (nstrict < AIROHA_NUM_QOS_QUEUES - 1)
|
||||
+ mode = nstrict + 1;
|
||||
+
|
||||
+ return airoha_qdma_set_chan_tx_sched(port, channel, mode, w,
|
||||
+ ARRAY_SIZE(w));
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_get_tx_ets_stats(struct airoha_gdm_port *port,
|
||||
+ int channel,
|
||||
+ struct tc_ets_qopt_offload *opt)
|
||||
+{
|
||||
+ u64 cpu_tx_packets = airoha_qdma_rr(port->qdma,
|
||||
+ REG_CNTR_VAL(channel << 1));
|
||||
+ u64 fwd_tx_packets = airoha_qdma_rr(port->qdma,
|
||||
+ REG_CNTR_VAL((channel << 1) + 1));
|
||||
+ u64 tx_packets = (cpu_tx_packets - port->cpu_tx_packets) +
|
||||
+ (fwd_tx_packets - port->fwd_tx_packets);
|
||||
+ _bstats_update(opt->stats.bstats, 0, tx_packets);
|
||||
+
|
||||
+ port->cpu_tx_packets = cpu_tx_packets;
|
||||
+ port->fwd_tx_packets = fwd_tx_packets;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_tc_setup_qdisc_ets(struct airoha_gdm_port *port,
|
||||
+ struct tc_ets_qopt_offload *opt)
|
||||
+{
|
||||
+ int channel = TC_H_MAJ(opt->handle) >> 16;
|
||||
+
|
||||
+ if (opt->parent == TC_H_ROOT)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ switch (opt->command) {
|
||||
+ case TC_ETS_REPLACE:
|
||||
+ return airoha_qdma_set_tx_ets_sched(port, channel, opt);
|
||||
+ case TC_ETS_DESTROY:
|
||||
+ /* PRIO is default qdisc scheduler */
|
||||
+ return airoha_qdma_set_tx_prio_sched(port, channel);
|
||||
+ case TC_ETS_STATS:
|
||||
+ return airoha_qdma_get_tx_ets_stats(port, channel, opt);
|
||||
+ default:
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int airoha_dev_tc_setup(struct net_device *dev, enum tc_setup_type type,
|
||||
+ void *type_data)
|
||||
+{
|
||||
+ struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
+
|
||||
+ switch (type) {
|
||||
+ case TC_SETUP_QDISC_ETS:
|
||||
+ return airoha_tc_setup_qdisc_ets(port, type_data);
|
||||
+ default:
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static const struct net_device_ops airoha_netdev_ops = {
|
||||
.ndo_init = airoha_dev_init,
|
||||
.ndo_open = airoha_dev_open,
|
||||
@@ -2659,6 +2851,7 @@ static const struct net_device_ops airoh
|
||||
.ndo_start_xmit = airoha_dev_xmit,
|
||||
.ndo_get_stats64 = airoha_dev_get_stats64,
|
||||
.ndo_set_mac_address = airoha_dev_set_macaddr,
|
||||
+ .ndo_setup_tc = airoha_dev_tc_setup,
|
||||
};
|
||||
|
||||
static const struct ethtool_ops airoha_ethtool_ops = {
|
||||
@@ -2708,7 +2901,8 @@ static int airoha_alloc_gdm_port(struct
|
||||
dev->watchdog_timeo = 5 * HZ;
|
||||
dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
|
||||
NETIF_F_TSO6 | NETIF_F_IPV6_CSUM |
|
||||
- NETIF_F_SG | NETIF_F_TSO;
|
||||
+ NETIF_F_SG | NETIF_F_TSO |
|
||||
+ NETIF_F_HW_TC;
|
||||
dev->features |= dev->hw_features;
|
||||
dev->dev.of_node = np;
|
||||
dev->irq = qdma->irq;
|
||||
@ -1,371 +0,0 @@
|
||||
From ef1ca9271313b4ea7b03de69576aacef1e78f381 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 3 Jan 2025 13:17:05 +0100
|
||||
Subject: [PATCH 4/4] net: airoha: Add sched HTB offload support
|
||||
|
||||
Introduce support for HTB Qdisc offload available in the Airoha EN7581
|
||||
ethernet controller. EN7581 can offload only one level of HTB leafs.
|
||||
Each HTB leaf represents a QoS channel supported by EN7581 SoC.
|
||||
The typical use-case is creating a HTB leaf for QoS channel to rate
|
||||
limit the egress traffic and attach an ETS Qdisc to each HTB leaf in
|
||||
order to enforce traffic prioritization.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 288 ++++++++++++++++++++-
|
||||
1 file changed, 287 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -28,6 +28,8 @@
|
||||
#define AIROHA_NUM_QOS_QUEUES 8
|
||||
#define AIROHA_NUM_TX_RING 32
|
||||
#define AIROHA_NUM_RX_RING 32
|
||||
+#define AIROHA_NUM_NETDEV_TX_RINGS (AIROHA_NUM_TX_RING + \
|
||||
+ AIROHA_NUM_QOS_CHANNELS)
|
||||
#define AIROHA_FE_MC_MAX_VLAN_TABLE 64
|
||||
#define AIROHA_FE_MC_MAX_VLAN_PORT 16
|
||||
#define AIROHA_NUM_TX_IRQ 2
|
||||
@@ -43,6 +45,9 @@
|
||||
#define PSE_RSV_PAGES 128
|
||||
#define PSE_QUEUE_RSV_PAGES 64
|
||||
|
||||
+#define QDMA_METER_IDX(_n) ((_n) & 0xff)
|
||||
+#define QDMA_METER_GROUP(_n) (((_n) >> 8) & 0x3)
|
||||
+
|
||||
/* FE */
|
||||
#define PSE_BASE 0x0100
|
||||
#define CSR_IFC_BASE 0x0200
|
||||
@@ -583,6 +588,17 @@
|
||||
#define EGRESS_SLOW_TICK_RATIO_MASK GENMASK(29, 16)
|
||||
#define EGRESS_FAST_TICK_MASK GENMASK(15, 0)
|
||||
|
||||
+#define TRTCM_PARAM_RW_MASK BIT(31)
|
||||
+#define TRTCM_PARAM_RW_DONE_MASK BIT(30)
|
||||
+#define TRTCM_PARAM_TYPE_MASK GENMASK(29, 28)
|
||||
+#define TRTCM_METER_GROUP_MASK GENMASK(27, 26)
|
||||
+#define TRTCM_PARAM_INDEX_MASK GENMASK(23, 17)
|
||||
+#define TRTCM_PARAM_RATE_TYPE_MASK BIT(16)
|
||||
+
|
||||
+#define REG_TRTCM_CFG_PARAM(_n) ((_n) + 0x4)
|
||||
+#define REG_TRTCM_DATA_LOW(_n) ((_n) + 0x8)
|
||||
+#define REG_TRTCM_DATA_HIGH(_n) ((_n) + 0xc)
|
||||
+
|
||||
#define REG_TXWRR_MODE_CFG 0x1020
|
||||
#define TWRR_WEIGHT_SCALE_MASK BIT(31)
|
||||
#define TWRR_WEIGHT_BASE_MASK BIT(3)
|
||||
@@ -759,6 +775,29 @@ enum tx_sched_mode {
|
||||
TC_SCH_WRR2,
|
||||
};
|
||||
|
||||
+enum trtcm_param_type {
|
||||
+ TRTCM_MISC_MODE, /* meter_en, pps_mode, tick_sel */
|
||||
+ TRTCM_TOKEN_RATE_MODE,
|
||||
+ TRTCM_BUCKETSIZE_SHIFT_MODE,
|
||||
+ TRTCM_BUCKET_COUNTER_MODE,
|
||||
+};
|
||||
+
|
||||
+enum trtcm_mode_type {
|
||||
+ TRTCM_COMMIT_MODE,
|
||||
+ TRTCM_PEAK_MODE,
|
||||
+};
|
||||
+
|
||||
+enum trtcm_param {
|
||||
+ TRTCM_TICK_SEL = BIT(0),
|
||||
+ TRTCM_PKT_MODE = BIT(1),
|
||||
+ TRTCM_METER_MODE = BIT(2),
|
||||
+};
|
||||
+
|
||||
+#define MIN_TOKEN_SIZE 4096
|
||||
+#define MAX_TOKEN_SIZE_OFFSET 17
|
||||
+#define TRTCM_TOKEN_RATE_MASK GENMASK(23, 6)
|
||||
+#define TRTCM_TOKEN_RATE_FRACTION_MASK GENMASK(5, 0)
|
||||
+
|
||||
struct airoha_queue_entry {
|
||||
union {
|
||||
void *buf;
|
||||
@@ -850,6 +889,8 @@ struct airoha_gdm_port {
|
||||
|
||||
struct airoha_hw_stats stats;
|
||||
|
||||
+ DECLARE_BITMAP(qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS);
|
||||
+
|
||||
/* qos stats counters */
|
||||
u64 cpu_tx_packets;
|
||||
u64 fwd_tx_packets;
|
||||
@@ -2830,6 +2871,243 @@ static int airoha_tc_setup_qdisc_ets(str
|
||||
}
|
||||
}
|
||||
|
||||
+static int airoha_qdma_get_trtcm_param(struct airoha_qdma *qdma, int channel,
|
||||
+ u32 addr, enum trtcm_param_type param,
|
||||
+ enum trtcm_mode_type mode,
|
||||
+ u32 *val_low, u32 *val_high)
|
||||
+{
|
||||
+ u32 idx = QDMA_METER_IDX(channel), group = QDMA_METER_GROUP(channel);
|
||||
+ u32 val, config = FIELD_PREP(TRTCM_PARAM_TYPE_MASK, param) |
|
||||
+ FIELD_PREP(TRTCM_METER_GROUP_MASK, group) |
|
||||
+ FIELD_PREP(TRTCM_PARAM_INDEX_MASK, idx) |
|
||||
+ FIELD_PREP(TRTCM_PARAM_RATE_TYPE_MASK, mode);
|
||||
+
|
||||
+ airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config);
|
||||
+ if (read_poll_timeout(airoha_qdma_rr, val,
|
||||
+ val & TRTCM_PARAM_RW_DONE_MASK,
|
||||
+ USEC_PER_MSEC, 10 * USEC_PER_MSEC, true,
|
||||
+ qdma, REG_TRTCM_CFG_PARAM(addr)))
|
||||
+ return -ETIMEDOUT;
|
||||
+
|
||||
+ *val_low = airoha_qdma_rr(qdma, REG_TRTCM_DATA_LOW(addr));
|
||||
+ if (val_high)
|
||||
+ *val_high = airoha_qdma_rr(qdma, REG_TRTCM_DATA_HIGH(addr));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_set_trtcm_param(struct airoha_qdma *qdma, int channel,
|
||||
+ u32 addr, enum trtcm_param_type param,
|
||||
+ enum trtcm_mode_type mode, u32 val)
|
||||
+{
|
||||
+ u32 idx = QDMA_METER_IDX(channel), group = QDMA_METER_GROUP(channel);
|
||||
+ u32 config = TRTCM_PARAM_RW_MASK |
|
||||
+ FIELD_PREP(TRTCM_PARAM_TYPE_MASK, param) |
|
||||
+ FIELD_PREP(TRTCM_METER_GROUP_MASK, group) |
|
||||
+ FIELD_PREP(TRTCM_PARAM_INDEX_MASK, idx) |
|
||||
+ FIELD_PREP(TRTCM_PARAM_RATE_TYPE_MASK, mode);
|
||||
+
|
||||
+ airoha_qdma_wr(qdma, REG_TRTCM_DATA_LOW(addr), val);
|
||||
+ airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config);
|
||||
+
|
||||
+ return read_poll_timeout(airoha_qdma_rr, val,
|
||||
+ val & TRTCM_PARAM_RW_DONE_MASK,
|
||||
+ USEC_PER_MSEC, 10 * USEC_PER_MSEC, true,
|
||||
+ qdma, REG_TRTCM_CFG_PARAM(addr));
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_set_trtcm_config(struct airoha_qdma *qdma, int channel,
|
||||
+ u32 addr, enum trtcm_mode_type mode,
|
||||
+ bool enable, u32 enable_mask)
|
||||
+{
|
||||
+ u32 val;
|
||||
+
|
||||
+ if (airoha_qdma_get_trtcm_param(qdma, channel, addr, TRTCM_MISC_MODE,
|
||||
+ mode, &val, NULL))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ val = enable ? val | enable_mask : val & ~enable_mask;
|
||||
+
|
||||
+ return airoha_qdma_set_trtcm_param(qdma, channel, addr, TRTCM_MISC_MODE,
|
||||
+ mode, val);
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_set_trtcm_token_bucket(struct airoha_qdma *qdma,
|
||||
+ int channel, u32 addr,
|
||||
+ enum trtcm_mode_type mode,
|
||||
+ u32 rate_val, u32 bucket_size)
|
||||
+{
|
||||
+ u32 val, config, tick, unit, rate, rate_frac;
|
||||
+ int err;
|
||||
+
|
||||
+ if (airoha_qdma_get_trtcm_param(qdma, channel, addr, TRTCM_MISC_MODE,
|
||||
+ mode, &config, NULL))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ val = airoha_qdma_rr(qdma, addr);
|
||||
+ tick = FIELD_GET(INGRESS_FAST_TICK_MASK, val);
|
||||
+ if (config & TRTCM_TICK_SEL)
|
||||
+ tick *= FIELD_GET(INGRESS_SLOW_TICK_RATIO_MASK, val);
|
||||
+ if (!tick)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ unit = (config & TRTCM_PKT_MODE) ? 1000000 / tick : 8000 / tick;
|
||||
+ if (!unit)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ rate = rate_val / unit;
|
||||
+ rate_frac = rate_val % unit;
|
||||
+ rate_frac = FIELD_PREP(TRTCM_TOKEN_RATE_MASK, rate_frac) / unit;
|
||||
+ rate = FIELD_PREP(TRTCM_TOKEN_RATE_MASK, rate) |
|
||||
+ FIELD_PREP(TRTCM_TOKEN_RATE_FRACTION_MASK, rate_frac);
|
||||
+
|
||||
+ err = airoha_qdma_set_trtcm_param(qdma, channel, addr,
|
||||
+ TRTCM_TOKEN_RATE_MODE, mode, rate);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ val = max_t(u32, bucket_size, MIN_TOKEN_SIZE);
|
||||
+ val = min_t(u32, __fls(val), MAX_TOKEN_SIZE_OFFSET);
|
||||
+
|
||||
+ return airoha_qdma_set_trtcm_param(qdma, channel, addr,
|
||||
+ TRTCM_BUCKETSIZE_SHIFT_MODE,
|
||||
+ mode, val);
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_set_tx_rate_limit(struct airoha_gdm_port *port,
|
||||
+ int channel, u32 rate,
|
||||
+ u32 bucket_size)
|
||||
+{
|
||||
+ int i, err;
|
||||
+
|
||||
+ for (i = 0; i <= TRTCM_PEAK_MODE; i++) {
|
||||
+ err = airoha_qdma_set_trtcm_config(port->qdma, channel,
|
||||
+ REG_EGRESS_TRTCM_CFG, i,
|
||||
+ !!rate, TRTCM_METER_MODE);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = airoha_qdma_set_trtcm_token_bucket(port->qdma, channel,
|
||||
+ REG_EGRESS_TRTCM_CFG,
|
||||
+ i, rate, bucket_size);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_tc_htb_alloc_leaf_queue(struct airoha_gdm_port *port,
|
||||
+ struct tc_htb_qopt_offload *opt)
|
||||
+{
|
||||
+ u32 channel = TC_H_MIN(opt->classid) % AIROHA_NUM_QOS_CHANNELS;
|
||||
+ u32 rate = div_u64(opt->rate, 1000) << 3; /* kbps */
|
||||
+ struct net_device *dev = port->dev;
|
||||
+ int num_tx_queues = dev->real_num_tx_queues;
|
||||
+ int err;
|
||||
+
|
||||
+ if (opt->parent_classid != TC_HTB_CLASSID_ROOT) {
|
||||
+ NL_SET_ERR_MSG_MOD(opt->extack, "invalid parent classid");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ err = airoha_qdma_set_tx_rate_limit(port, channel, rate, opt->quantum);
|
||||
+ if (err) {
|
||||
+ NL_SET_ERR_MSG_MOD(opt->extack,
|
||||
+ "failed configuring htb offload");
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ if (opt->command == TC_HTB_NODE_MODIFY)
|
||||
+ return 0;
|
||||
+
|
||||
+ err = netif_set_real_num_tx_queues(dev, num_tx_queues + 1);
|
||||
+ if (err) {
|
||||
+ airoha_qdma_set_tx_rate_limit(port, channel, 0, opt->quantum);
|
||||
+ NL_SET_ERR_MSG_MOD(opt->extack,
|
||||
+ "failed setting real_num_tx_queues");
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ set_bit(channel, port->qos_sq_bmap);
|
||||
+ opt->qid = AIROHA_NUM_TX_RING + channel;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void airoha_tc_remove_htb_queue(struct airoha_gdm_port *port, int queue)
|
||||
+{
|
||||
+ struct net_device *dev = port->dev;
|
||||
+
|
||||
+ netif_set_real_num_tx_queues(dev, dev->real_num_tx_queues - 1);
|
||||
+ airoha_qdma_set_tx_rate_limit(port, queue + 1, 0, 0);
|
||||
+ clear_bit(queue, port->qos_sq_bmap);
|
||||
+}
|
||||
+
|
||||
+static int airoha_tc_htb_delete_leaf_queue(struct airoha_gdm_port *port,
|
||||
+ struct tc_htb_qopt_offload *opt)
|
||||
+{
|
||||
+ u32 channel = TC_H_MIN(opt->classid) % AIROHA_NUM_QOS_CHANNELS;
|
||||
+
|
||||
+ if (!test_bit(channel, port->qos_sq_bmap)) {
|
||||
+ NL_SET_ERR_MSG_MOD(opt->extack, "invalid queue id");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ airoha_tc_remove_htb_queue(port, channel);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_tc_htb_destroy(struct airoha_gdm_port *port)
|
||||
+{
|
||||
+ int q;
|
||||
+
|
||||
+ for_each_set_bit(q, port->qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS)
|
||||
+ airoha_tc_remove_htb_queue(port, q);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_tc_get_htb_get_leaf_queue(struct airoha_gdm_port *port,
|
||||
+ struct tc_htb_qopt_offload *opt)
|
||||
+{
|
||||
+ u32 channel = TC_H_MIN(opt->classid) % AIROHA_NUM_QOS_CHANNELS;
|
||||
+
|
||||
+ if (!test_bit(channel, port->qos_sq_bmap)) {
|
||||
+ NL_SET_ERR_MSG_MOD(opt->extack, "invalid queue id");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ opt->qid = channel;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_tc_setup_qdisc_htb(struct airoha_gdm_port *port,
|
||||
+ struct tc_htb_qopt_offload *opt)
|
||||
+{
|
||||
+ switch (opt->command) {
|
||||
+ case TC_HTB_CREATE:
|
||||
+ break;
|
||||
+ case TC_HTB_DESTROY:
|
||||
+ return airoha_tc_htb_destroy(port);
|
||||
+ case TC_HTB_NODE_MODIFY:
|
||||
+ case TC_HTB_LEAF_ALLOC_QUEUE:
|
||||
+ return airoha_tc_htb_alloc_leaf_queue(port, opt);
|
||||
+ case TC_HTB_LEAF_DEL:
|
||||
+ case TC_HTB_LEAF_DEL_LAST:
|
||||
+ case TC_HTB_LEAF_DEL_LAST_FORCE:
|
||||
+ return airoha_tc_htb_delete_leaf_queue(port, opt);
|
||||
+ case TC_HTB_LEAF_QUERY_QUEUE:
|
||||
+ return airoha_tc_get_htb_get_leaf_queue(port, opt);
|
||||
+ default:
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int airoha_dev_tc_setup(struct net_device *dev, enum tc_setup_type type,
|
||||
void *type_data)
|
||||
{
|
||||
@@ -2838,6 +3116,8 @@ static int airoha_dev_tc_setup(struct ne
|
||||
switch (type) {
|
||||
case TC_SETUP_QDISC_ETS:
|
||||
return airoha_tc_setup_qdisc_ets(port, type_data);
|
||||
+ case TC_SETUP_QDISC_HTB:
|
||||
+ return airoha_tc_setup_qdisc_htb(port, type_data);
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@@ -2888,7 +3168,8 @@ static int airoha_alloc_gdm_port(struct
|
||||
}
|
||||
|
||||
dev = devm_alloc_etherdev_mqs(eth->dev, sizeof(*port),
|
||||
- AIROHA_NUM_TX_RING, AIROHA_NUM_RX_RING);
|
||||
+ AIROHA_NUM_NETDEV_TX_RINGS,
|
||||
+ AIROHA_NUM_RX_RING);
|
||||
if (!dev) {
|
||||
dev_err(eth->dev, "alloc_etherdev failed\n");
|
||||
return -ENOMEM;
|
||||
@@ -2908,6 +3189,11 @@ static int airoha_alloc_gdm_port(struct
|
||||
dev->irq = qdma->irq;
|
||||
SET_NETDEV_DEV(dev, eth->dev);
|
||||
|
||||
+ /* reserve hw queues for HTB offloading */
|
||||
+ err = netif_set_real_num_tx_queues(dev, AIROHA_NUM_TX_RING);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
err = of_get_ethdev_address(np, dev);
|
||||
if (err) {
|
||||
if (err == -EPROBE_DEFER)
|
||||
@ -1,232 +0,0 @@
|
||||
From 84cf9e541cccb8cb698518a9897942e8c78f1d83 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Thu, 9 Jan 2025 14:12:58 +0100
|
||||
Subject: [PATCH] cpufreq: airoha: Add EN7581 CPUFreq SMCCC driver
|
||||
|
||||
Add simple CPU Freq driver for Airoha EN7581 SoC that control CPU
|
||||
frequency scaling with SMC APIs and register a generic "cpufreq-dt"
|
||||
device.
|
||||
|
||||
All CPU share the same frequency and can't be controlled independently.
|
||||
CPU frequency is controlled by the attached PM domain.
|
||||
|
||||
Add SoC compatible to cpufreq-dt-plat block list as a dedicated cpufreq
|
||||
driver is needed with OPP v2 nodes declared in DTS.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
|
||||
---
|
||||
drivers/cpufreq/Kconfig.arm | 8 ++
|
||||
drivers/cpufreq/Makefile | 1 +
|
||||
drivers/cpufreq/airoha-cpufreq.c | 152 +++++++++++++++++++++++++++
|
||||
drivers/cpufreq/cpufreq-dt-platdev.c | 2 +
|
||||
4 files changed, 163 insertions(+)
|
||||
create mode 100644 drivers/cpufreq/airoha-cpufreq.c
|
||||
|
||||
--- a/drivers/cpufreq/Kconfig.arm
|
||||
+++ b/drivers/cpufreq/Kconfig.arm
|
||||
@@ -15,6 +15,14 @@ config ARM_ALLWINNER_SUN50I_CPUFREQ_NVME
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called sun50i-cpufreq-nvmem.
|
||||
|
||||
+config ARM_AIROHA_SOC_CPUFREQ
|
||||
+ tristate "Airoha EN7581 SoC CPUFreq support"
|
||||
+ depends on ARCH_AIROHA || COMPILE_TEST
|
||||
+ select PM_OPP
|
||||
+ default ARCH_AIROHA
|
||||
+ help
|
||||
+ This adds the CPUFreq driver for Airoha EN7581 SoCs.
|
||||
+
|
||||
config ARM_APPLE_SOC_CPUFREQ
|
||||
tristate "Apple Silicon SoC CPUFreq support"
|
||||
depends on ARCH_APPLE || (COMPILE_TEST && 64BIT)
|
||||
--- a/drivers/cpufreq/Makefile
|
||||
+++ b/drivers/cpufreq/Makefile
|
||||
@@ -52,6 +52,7 @@ obj-$(CONFIG_X86_AMD_FREQ_SENSITIVITY) +
|
||||
|
||||
##################################################################################
|
||||
# ARM SoC drivers
|
||||
+obj-$(CONFIG_ARM_AIROHA_SOC_CPUFREQ) += airoha-cpufreq.o
|
||||
obj-$(CONFIG_ARM_APPLE_SOC_CPUFREQ) += apple-soc-cpufreq.o
|
||||
obj-$(CONFIG_ARM_ARMADA_37XX_CPUFREQ) += armada-37xx-cpufreq.o
|
||||
obj-$(CONFIG_ARM_ARMADA_8K_CPUFREQ) += armada-8k-cpufreq.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/cpufreq/airoha-cpufreq.c
|
||||
@@ -0,0 +1,166 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+
|
||||
+#include <linux/bitfield.h>
|
||||
+#include <linux/cpufreq.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/pm_runtime.h>
|
||||
+#include <linux/slab.h>
|
||||
+
|
||||
+#include "cpufreq-dt.h"
|
||||
+
|
||||
+struct airoha_cpufreq_priv {
|
||||
+ int opp_token;
|
||||
+ struct device **virt_devs;
|
||||
+ struct platform_device *cpufreq_dt;
|
||||
+};
|
||||
+
|
||||
+static struct platform_device *cpufreq_pdev;
|
||||
+
|
||||
+/* NOP function to disable OPP from setting clock */
|
||||
+static int airoha_cpufreq_config_clks_nop(struct device *dev,
|
||||
+ struct opp_table *opp_table,
|
||||
+ struct dev_pm_opp *old_opp,
|
||||
+ struct dev_pm_opp *opp,
|
||||
+ void *data, bool scaling_down)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const char * const airoha_cpufreq_clk_names[] = { "cpu", NULL };
|
||||
+static const char * const airoha_cpufreq_pd_names[] = { "perf", NULL };
|
||||
+
|
||||
+static int airoha_cpufreq_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct dev_pm_opp_config config = {
|
||||
+ .clk_names = airoha_cpufreq_clk_names,
|
||||
+ .config_clks = airoha_cpufreq_config_clks_nop,
|
||||
+ .genpd_names = airoha_cpufreq_pd_names,
|
||||
+ };
|
||||
+ struct platform_device *cpufreq_dt;
|
||||
+ struct airoha_cpufreq_priv *priv;
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct device **virt_devs = NULL;
|
||||
+ struct device *cpu_dev;
|
||||
+ int ret;
|
||||
+
|
||||
+ /* CPUs refer to the same OPP table */
|
||||
+ cpu_dev = get_cpu_device(0);
|
||||
+ if (!cpu_dev)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
+ if (!priv)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ /* Set OPP table conf with NOP config_clks */
|
||||
+ priv->opp_token = dev_pm_opp_set_config(cpu_dev, &config);
|
||||
+ if (priv->opp_token < 0)
|
||||
+ return dev_err_probe(dev, priv->opp_token, "Failed to set OPP config\n");
|
||||
+
|
||||
+ /* Set Attached PM for OPP ACTIVE */
|
||||
+ if (virt_devs) {
|
||||
+ const char * const *name = airoha_cpufreq_pd_names;
|
||||
+ int i, j;
|
||||
+
|
||||
+ for (i = 0; *name; i++, name++) {
|
||||
+ ret = pm_runtime_resume_and_get(virt_devs[i]);
|
||||
+ if (ret) {
|
||||
+ dev_err(cpu_dev, "failed to resume %s: %d\n",
|
||||
+ *name, ret);
|
||||
+
|
||||
+ /* Rollback previous PM runtime calls */
|
||||
+ name = config.genpd_names;
|
||||
+ for (j = 0; *name && j < i; j++, name++)
|
||||
+ pm_runtime_put(virt_devs[j]);
|
||||
+
|
||||
+ goto err_register_cpufreq;
|
||||
+ }
|
||||
+ }
|
||||
+ priv->virt_devs = virt_devs;
|
||||
+ }
|
||||
+
|
||||
+ cpufreq_dt = platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
|
||||
+ ret = PTR_ERR_OR_ZERO(cpufreq_dt);
|
||||
+ if (ret) {
|
||||
+ dev_err(dev, "failed to create cpufreq-dt device: %d\n", ret);
|
||||
+ goto err_register_cpufreq;
|
||||
+ }
|
||||
+
|
||||
+ priv->cpufreq_dt = cpufreq_dt;
|
||||
+ platform_set_drvdata(pdev, priv);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_register_cpufreq:
|
||||
+ dev_pm_opp_clear_config(priv->opp_token);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void airoha_cpufreq_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct airoha_cpufreq_priv *priv = platform_get_drvdata(pdev);
|
||||
+ const char * const *name = airoha_cpufreq_pd_names;
|
||||
+ int i;
|
||||
+
|
||||
+ platform_device_unregister(priv->cpufreq_dt);
|
||||
+
|
||||
+ dev_pm_opp_clear_config(priv->opp_token);
|
||||
+
|
||||
+ for (i = 0; *name; i++, name++)
|
||||
+ pm_runtime_put(priv->virt_devs[i]);
|
||||
+}
|
||||
+
|
||||
+static struct platform_driver airoha_cpufreq_driver = {
|
||||
+ .probe = airoha_cpufreq_probe,
|
||||
+ .remove_new = airoha_cpufreq_remove,
|
||||
+ .driver = {
|
||||
+ .name = "airoha-cpufreq",
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static const struct of_device_id airoha_cpufreq_match_list[] __initconst = {
|
||||
+ { .compatible = "airoha,en7581" },
|
||||
+ {},
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, airoha_cpufreq_match_list);
|
||||
+
|
||||
+static int __init airoha_cpufreq_init(void)
|
||||
+{
|
||||
+ struct device_node *np = of_find_node_by_path("/");
|
||||
+ const struct of_device_id *match;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (!np)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ match = of_match_node(airoha_cpufreq_match_list, np);
|
||||
+ of_node_put(np);
|
||||
+ if (!match)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ ret = platform_driver_register(&airoha_cpufreq_driver);
|
||||
+ if (unlikely(ret < 0))
|
||||
+ return ret;
|
||||
+
|
||||
+ cpufreq_pdev = platform_device_register_data(NULL, "airoha-cpufreq",
|
||||
+ -1, match, sizeof(*match));
|
||||
+ ret = PTR_ERR_OR_ZERO(cpufreq_pdev);
|
||||
+ if (ret)
|
||||
+ platform_driver_unregister(&airoha_cpufreq_driver);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+module_init(airoha_cpufreq_init);
|
||||
+
|
||||
+static void __exit airoha_cpufreq_exit(void)
|
||||
+{
|
||||
+ platform_device_unregister(cpufreq_pdev);
|
||||
+ platform_driver_unregister(&airoha_cpufreq_driver);
|
||||
+}
|
||||
+module_exit(airoha_cpufreq_exit);
|
||||
+
|
||||
+MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
|
||||
+MODULE_DESCRIPTION("CPUfreq driver for Airoha SoCs");
|
||||
+MODULE_LICENSE("GPL");
|
||||
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
|
||||
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
|
||||
@@ -104,6 +104,8 @@ static const struct of_device_id allowli
|
||||
* platforms using "operating-points-v2" property.
|
||||
*/
|
||||
static const struct of_device_id blocklist[] __initconst = {
|
||||
+ { .compatible = "airoha,en7581", },
|
||||
+
|
||||
{ .compatible = "allwinner,sun50i-h6", },
|
||||
{ .compatible = "allwinner,sun50i-h616", },
|
||||
{ .compatible = "allwinner,sun50i-h618", },
|
||||
@ -1,53 +0,0 @@
|
||||
From b56e4d660a9688ff83f5cbdc6e3ea063352d0d79 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Sun, 12 Jan 2025 19:32:45 +0100
|
||||
Subject: [PATCH] net: airoha: Enforce ETS Qdisc priomap
|
||||
|
||||
EN7581 SoC supports fixed QoS band priority where WRR queues have lowest
|
||||
priorities with respect to SP ones.
|
||||
E.g: WRR0, WRR1, .., WRRm, SP0, SP1, .., SPn
|
||||
|
||||
Enforce ETS Qdisc priomap according to the hw capabilities.
|
||||
|
||||
Suggested-by: Davide Caratti <dcaratti@redhat.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Davide Caratti <dcaratti@redhat.com>
|
||||
Link: https://patch.msgid.link/20250112-airoha_ets_priomap-v1-1-fb616de159ba@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 17 +++++++++++++++--
|
||||
1 file changed, 15 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -2806,7 +2806,7 @@ static int airoha_qdma_set_tx_ets_sched(
|
||||
struct tc_ets_qopt_offload_replace_params *p = &opt->replace_params;
|
||||
enum tx_sched_mode mode = TC_SCH_SP;
|
||||
u16 w[AIROHA_NUM_QOS_QUEUES] = {};
|
||||
- int i, nstrict = 0;
|
||||
+ int i, nstrict = 0, nwrr, qidx;
|
||||
|
||||
if (p->bands > AIROHA_NUM_QOS_QUEUES)
|
||||
return -EINVAL;
|
||||
@@ -2820,7 +2820,20 @@ static int airoha_qdma_set_tx_ets_sched(
|
||||
if (nstrict == AIROHA_NUM_QOS_QUEUES - 1)
|
||||
return -EINVAL;
|
||||
|
||||
- for (i = 0; i < p->bands - nstrict; i++)
|
||||
+ /* EN7581 SoC supports fixed QoS band priority where WRR queues have
|
||||
+ * lowest priorities with respect to SP ones.
|
||||
+ * e.g: WRR0, WRR1, .., WRRm, SP0, SP1, .., SPn
|
||||
+ */
|
||||
+ nwrr = p->bands - nstrict;
|
||||
+ qidx = nstrict && nwrr ? nstrict : 0;
|
||||
+ for (i = 1; i <= p->bands; i++) {
|
||||
+ if (p->priomap[i % AIROHA_NUM_QOS_QUEUES] != qidx)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ qidx = i == nwrr ? 0 : qidx + 1;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < nwrr; i++)
|
||||
w[i] = p->weights[nstrict + i];
|
||||
|
||||
if (!nstrict)
|
||||
@ -1,196 +0,0 @@
|
||||
From 82e703dd438b71432cc0ccbb90925d1e32dd014a Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Thu, 9 Jan 2025 14:12:57 +0100
|
||||
Subject: [PATCH] pmdomain: airoha: Add Airoha CPU PM Domain support
|
||||
|
||||
Add Airoha CPU PM Domain support to control frequency and power of CPU
|
||||
present on Airoha EN7581 SoC.
|
||||
|
||||
Frequency and power can be controlled with the use of the SMC command by
|
||||
passing the performance state. The driver also expose a read-only clock
|
||||
that expose the current CPU frequency with SMC command.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20250109131313.32317-1-ansuelsmth@gmail.com
|
||||
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
||||
---
|
||||
drivers/pmdomain/mediatek/Kconfig | 12 ++
|
||||
drivers/pmdomain/mediatek/Makefile | 1 +
|
||||
.../pmdomain/mediatek/airoha-cpu-pmdomain.c | 144 ++++++++++++++++++
|
||||
3 files changed, 157 insertions(+)
|
||||
create mode 100644 drivers/pmdomain/mediatek/airoha-cpu-pmdomain.c
|
||||
|
||||
--- a/drivers/soc/mediatek/Kconfig
|
||||
+++ b/drivers/soc/mediatek/Kconfig
|
||||
@@ -2,6 +2,17 @@
|
||||
#
|
||||
# MediaTek SoC drivers
|
||||
#
|
||||
+config AIROHA_CPU_PM_DOMAIN
|
||||
+ tristate "Airoha CPU power domain"
|
||||
+ default ARCH_AIROHA
|
||||
+ depends on PM
|
||||
+ select PM_GENERIC_DOMAINS
|
||||
+ help
|
||||
+ Say y here to enable CPU power domain support for Airoha SoC.
|
||||
+
|
||||
+ CPU frequency and power is controlled by ATF with SMC command to
|
||||
+ set performance states.
|
||||
+
|
||||
menu "MediaTek SoC drivers"
|
||||
depends on ARCH_MEDIATEK || COMPILE_TEST
|
||||
|
||||
--- a/drivers/pmdomain/mediatek/Makefile
|
||||
+++ b/drivers/pmdomain/mediatek/Makefile
|
||||
@@ -1,3 +1,4 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
|
||||
obj-$(CONFIG_MTK_SCPSYS_PM_DOMAINS) += mtk-pm-domains.o
|
||||
+obj-$(CONFIG_AIROHA_CPU_PM_DOMAIN) += airoha-cpu-pmdomain.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/pmdomain/mediatek/airoha-cpu-pmdomain.c
|
||||
@@ -0,0 +1,144 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+
|
||||
+#include <linux/arm-smccc.h>
|
||||
+#include <linux/bitfield.h>
|
||||
+#include <linux/clk-provider.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/pm_domain.h>
|
||||
+#include <linux/slab.h>
|
||||
+
|
||||
+#define AIROHA_SIP_AVS_HANDLE 0x82000301
|
||||
+#define AIROHA_AVS_OP_BASE 0xddddddd0
|
||||
+#define AIROHA_AVS_OP_MASK GENMASK(1, 0)
|
||||
+#define AIROHA_AVS_OP_FREQ_DYN_ADJ (AIROHA_AVS_OP_BASE | \
|
||||
+ FIELD_PREP(AIROHA_AVS_OP_MASK, 0x1))
|
||||
+#define AIROHA_AVS_OP_GET_FREQ (AIROHA_AVS_OP_BASE | \
|
||||
+ FIELD_PREP(AIROHA_AVS_OP_MASK, 0x2))
|
||||
+
|
||||
+struct airoha_cpu_pmdomain_priv {
|
||||
+ struct clk_hw hw;
|
||||
+ struct generic_pm_domain pd;
|
||||
+};
|
||||
+
|
||||
+static long airoha_cpu_pmdomain_clk_round(struct clk_hw *hw, unsigned long rate,
|
||||
+ unsigned long *parent_rate)
|
||||
+{
|
||||
+ return rate;
|
||||
+}
|
||||
+
|
||||
+static unsigned long airoha_cpu_pmdomain_clk_get(struct clk_hw *hw,
|
||||
+ unsigned long parent_rate)
|
||||
+{
|
||||
+ struct arm_smccc_res res;
|
||||
+
|
||||
+ arm_smccc_1_1_invoke(AIROHA_SIP_AVS_HANDLE, AIROHA_AVS_OP_GET_FREQ,
|
||||
+ 0, 0, 0, 0, 0, 0, &res);
|
||||
+
|
||||
+ /* SMCCC returns freq in MHz */
|
||||
+ return (int)(res.a0 * 1000 * 1000);
|
||||
+}
|
||||
+
|
||||
+/* Airoha CPU clk SMCC is always enabled */
|
||||
+static int airoha_cpu_pmdomain_clk_is_enabled(struct clk_hw *hw)
|
||||
+{
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static const struct clk_ops airoha_cpu_pmdomain_clk_ops = {
|
||||
+ .recalc_rate = airoha_cpu_pmdomain_clk_get,
|
||||
+ .is_enabled = airoha_cpu_pmdomain_clk_is_enabled,
|
||||
+ .round_rate = airoha_cpu_pmdomain_clk_round,
|
||||
+};
|
||||
+
|
||||
+static int airoha_cpu_pmdomain_set_performance_state(struct generic_pm_domain *domain,
|
||||
+ unsigned int state)
|
||||
+{
|
||||
+ struct arm_smccc_res res;
|
||||
+
|
||||
+ arm_smccc_1_1_invoke(AIROHA_SIP_AVS_HANDLE, AIROHA_AVS_OP_FREQ_DYN_ADJ,
|
||||
+ 0, state, 0, 0, 0, 0, &res);
|
||||
+
|
||||
+ /* SMC signal correct apply by unsetting BIT 0 */
|
||||
+ return res.a0 & BIT(0) ? -EINVAL : 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_cpu_pmdomain_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct airoha_cpu_pmdomain_priv *priv;
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ const struct clk_init_data init = {
|
||||
+ .name = "cpu",
|
||||
+ .ops = &airoha_cpu_pmdomain_clk_ops,
|
||||
+ /* Clock with no set_rate, can't cache */
|
||||
+ .flags = CLK_GET_RATE_NOCACHE,
|
||||
+ };
|
||||
+ struct generic_pm_domain *pd;
|
||||
+ int ret;
|
||||
+
|
||||
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
+ if (!priv)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ /* Init and register a get-only clk for Cpufreq */
|
||||
+ priv->hw.init = &init;
|
||||
+ ret = devm_clk_hw_register(dev, &priv->hw);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
|
||||
+ &priv->hw);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* Init and register a PD for CPU */
|
||||
+ pd = &priv->pd;
|
||||
+ pd->name = "cpu_pd";
|
||||
+ pd->flags = GENPD_FLAG_ALWAYS_ON;
|
||||
+ pd->set_performance_state = airoha_cpu_pmdomain_set_performance_state;
|
||||
+
|
||||
+ ret = pm_genpd_init(pd, NULL, false);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = of_genpd_add_provider_simple(dev->of_node, pd);
|
||||
+ if (ret)
|
||||
+ goto err_add_provider;
|
||||
+
|
||||
+ platform_set_drvdata(pdev, priv);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_add_provider:
|
||||
+ pm_genpd_remove(pd);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void airoha_cpu_pmdomain_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct airoha_cpu_pmdomain_priv *priv = platform_get_drvdata(pdev);
|
||||
+
|
||||
+ of_genpd_del_provider(pdev->dev.of_node);
|
||||
+ pm_genpd_remove(&priv->pd);
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id airoha_cpu_pmdomain_of_match[] = {
|
||||
+ { .compatible = "airoha,en7581-cpufreq" },
|
||||
+ { },
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, airoha_cpu_pmdomain_of_match);
|
||||
+
|
||||
+static struct platform_driver airoha_cpu_pmdomain_driver = {
|
||||
+ .probe = airoha_cpu_pmdomain_probe,
|
||||
+ .remove_new = airoha_cpu_pmdomain_remove,
|
||||
+ .driver = {
|
||||
+ .name = "airoha-cpu-pmdomain",
|
||||
+ .of_match_table = airoha_cpu_pmdomain_of_match,
|
||||
+ },
|
||||
+};
|
||||
+module_platform_driver(airoha_cpu_pmdomain_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
|
||||
+MODULE_DESCRIPTION("CPU PM domain driver for Airoha SoCs");
|
||||
+MODULE_LICENSE("GPL");
|
||||
@ -1,83 +0,0 @@
|
||||
From e4a9748e7103c47e575459db2b6a77d14f34da2b Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Tue, 14 Jan 2025 00:10:02 +0100
|
||||
Subject: [PATCH 1/4] clk: en7523: Rework clock handling for different clock
|
||||
numbers
|
||||
|
||||
Airoha EN7581 SoC have additional clock compared to EN7523 but current
|
||||
driver permits to only support up to EN7523 clock numbers.
|
||||
|
||||
To handle this, rework the clock handling and permit to declare the
|
||||
clocks number in match_data and alloca clk_data based on the compatible
|
||||
match_data.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20250113231030.6735-2-ansuelsmth@gmail.com
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/clk-en7523.c | 14 ++++++++------
|
||||
1 file changed, 8 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/clk/clk-en7523.c
|
||||
+++ b/drivers/clk/clk-en7523.c
|
||||
@@ -75,6 +75,7 @@ struct en_rst_data {
|
||||
};
|
||||
|
||||
struct en_clk_soc_data {
|
||||
+ u32 num_clocks;
|
||||
const struct clk_ops pcie_ops;
|
||||
int (*hw_init)(struct platform_device *pdev,
|
||||
struct clk_hw_onecell_data *clk_data);
|
||||
@@ -504,8 +505,6 @@ static void en7523_register_clocks(struc
|
||||
u32 rate;
|
||||
int i;
|
||||
|
||||
- clk_data->num = EN7523_NUM_CLOCKS;
|
||||
-
|
||||
for (i = 0; i < ARRAY_SIZE(en7523_base_clks); i++) {
|
||||
const struct en_clk_desc *desc = &en7523_base_clks[i];
|
||||
u32 reg = desc->div_reg ? desc->div_reg : desc->base_reg;
|
||||
@@ -587,8 +586,6 @@ static void en7581_register_clocks(struc
|
||||
|
||||
hw = en7523_register_pcie_clk(dev, base);
|
||||
clk_data->hws[EN7523_CLK_PCIE] = hw;
|
||||
-
|
||||
- clk_data->num = EN7523_NUM_CLOCKS;
|
||||
}
|
||||
|
||||
static int en7523_reset_update(struct reset_controller_dev *rcdev,
|
||||
@@ -702,13 +699,15 @@ static int en7523_clk_probe(struct platf
|
||||
struct clk_hw_onecell_data *clk_data;
|
||||
int r;
|
||||
|
||||
+ soc_data = device_get_match_data(&pdev->dev);
|
||||
+
|
||||
clk_data = devm_kzalloc(&pdev->dev,
|
||||
- struct_size(clk_data, hws, EN7523_NUM_CLOCKS),
|
||||
+ struct_size(clk_data, hws, soc_data->num_clocks),
|
||||
GFP_KERNEL);
|
||||
if (!clk_data)
|
||||
return -ENOMEM;
|
||||
|
||||
- soc_data = device_get_match_data(&pdev->dev);
|
||||
+ clk_data->num = soc_data->num_clocks;
|
||||
r = soc_data->hw_init(pdev, clk_data);
|
||||
if (r)
|
||||
return r;
|
||||
@@ -717,6 +716,7 @@ static int en7523_clk_probe(struct platf
|
||||
}
|
||||
|
||||
static const struct en_clk_soc_data en7523_data = {
|
||||
+ .num_clocks = ARRAY_SIZE(en7523_base_clks) + 1,
|
||||
.pcie_ops = {
|
||||
.is_enabled = en7523_pci_is_enabled,
|
||||
.prepare = en7523_pci_prepare,
|
||||
@@ -726,6 +726,8 @@ static const struct en_clk_soc_data en75
|
||||
};
|
||||
|
||||
static const struct en_clk_soc_data en7581_data = {
|
||||
+ /* We increment num_clocks by 1 to account for additional PCIe clock */
|
||||
+ .num_clocks = ARRAY_SIZE(en7581_base_clks) + 1,
|
||||
.pcie_ops = {
|
||||
.is_enabled = en7581_pci_is_enabled,
|
||||
.enable = en7581_pci_enable,
|
||||
@ -1,26 +0,0 @@
|
||||
From 02d3b7557ce28c373ea1e925ae16ab5988284313 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Tue, 14 Jan 2025 00:10:03 +0100
|
||||
Subject: [PATCH 2/4] dt-bindings: clock: drop NUM_CLOCKS define for EN7581
|
||||
|
||||
Drop NUM_CLOCKS define for EN7581 include. This is not a binding and
|
||||
should not be placed here. Value is derived internally in the user
|
||||
driver.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20250113231030.6735-3-ansuelsmth@gmail.com
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
include/dt-bindings/clock/en7523-clk.h | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
--- a/include/dt-bindings/clock/en7523-clk.h
|
||||
+++ b/include/dt-bindings/clock/en7523-clk.h
|
||||
@@ -12,6 +12,4 @@
|
||||
#define EN7523_CLK_CRYPTO 6
|
||||
#define EN7523_CLK_PCIE 7
|
||||
|
||||
-#define EN7523_NUM_CLOCKS 8
|
||||
-
|
||||
#endif /* _DT_BINDINGS_CLOCK_AIROHA_EN7523_H_ */
|
||||
@ -1,25 +0,0 @@
|
||||
From 82108ad3285f58f314ad41398f44017c7dbe44de Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Tue, 14 Jan 2025 00:10:04 +0100
|
||||
Subject: [PATCH 3/4] dt-bindings: clock: add ID for eMMC for EN7581
|
||||
|
||||
Add ID for eMMC for EN7581. This is to control clock selection of eMMC
|
||||
between 200MHz and 150MHz.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Acked-by: Conor Dooley <conor.dooley@microchip.com>
|
||||
Link: https://lore.kernel.org/r/20250113231030.6735-4-ansuelsmth@gmail.com
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
include/dt-bindings/clock/en7523-clk.h | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
--- a/include/dt-bindings/clock/en7523-clk.h
|
||||
+++ b/include/dt-bindings/clock/en7523-clk.h
|
||||
@@ -12,4 +12,6 @@
|
||||
#define EN7523_CLK_CRYPTO 6
|
||||
#define EN7523_CLK_PCIE 7
|
||||
|
||||
+#define EN7581_CLK_EMMC 8
|
||||
+
|
||||
#endif /* _DT_BINDINGS_CLOCK_AIROHA_EN7523_H_ */
|
||||
@ -1,41 +0,0 @@
|
||||
From bfe257f9780d8f77045a7da6ec959ee0659d2f98 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Tue, 14 Jan 2025 00:10:05 +0100
|
||||
Subject: [PATCH 4/4] clk: en7523: Add clock for eMMC for EN7581
|
||||
|
||||
Add clock for eMMC for EN7581. This is used to give info of the current
|
||||
eMMC source clock and to switch it from 200MHz or 150MHz.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20250113231030.6735-5-ansuelsmth@gmail.com
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/clk-en7523.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
--- a/drivers/clk/clk-en7523.c
|
||||
+++ b/drivers/clk/clk-en7523.c
|
||||
@@ -91,6 +91,7 @@ static const u32 emi7581_base[] = { 5400
|
||||
static const u32 bus7581_base[] = { 600000000, 540000000 };
|
||||
static const u32 npu7581_base[] = { 800000000, 750000000, 720000000, 600000000 };
|
||||
static const u32 crypto_base[] = { 540000000, 480000000 };
|
||||
+static const u32 emmc7581_base[] = { 200000000, 150000000 };
|
||||
|
||||
static const struct en_clk_desc en7523_base_clks[] = {
|
||||
{
|
||||
@@ -281,6 +282,15 @@ static const struct en_clk_desc en7581_b
|
||||
.base_shift = 0,
|
||||
.base_values = crypto_base,
|
||||
.n_base_values = ARRAY_SIZE(crypto_base),
|
||||
+ }, {
|
||||
+ .id = EN7581_CLK_EMMC,
|
||||
+ .name = "emmc",
|
||||
+
|
||||
+ .base_reg = REG_CRYPTO_CLKSRC2,
|
||||
+ .base_bits = 1,
|
||||
+ .base_shift = 12,
|
||||
+ .base_values = emmc7581_base,
|
||||
+ .n_base_values = ARRAY_SIZE(emmc7581_base),
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
From 0e7a622da17da0042294860cdb7a2fac091d25b1 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:40 +0100
|
||||
Subject: [PATCH 1/6] PCI: mediatek-gen3: Rely on clk_bulk_prepare_enable() in
|
||||
mtk_pcie_en7581_power_up()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Replace clk_bulk_prepare() and clk_bulk_enable() with
|
||||
clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up() routine.
|
||||
|
||||
Link: https://lore.kernel.org/r/20250108-pcie-en7581-fixes-v6-1-21ac939a3b9b@kernel.org
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 14 +++-----------
|
||||
1 file changed, 3 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -900,12 +900,6 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
pm_runtime_enable(dev);
|
||||
pm_runtime_get_sync(dev);
|
||||
|
||||
- err = clk_bulk_prepare(pcie->num_clks, pcie->clks);
|
||||
- if (err) {
|
||||
- dev_err(dev, "failed to prepare clock\n");
|
||||
- goto err_clk_prepare;
|
||||
- }
|
||||
-
|
||||
val = FIELD_PREP(PCIE_VAL_LN0_DOWNSTREAM, 0x47) |
|
||||
FIELD_PREP(PCIE_VAL_LN1_DOWNSTREAM, 0x47) |
|
||||
FIELD_PREP(PCIE_VAL_LN0_UPSTREAM, 0x41) |
|
||||
@@ -918,17 +912,15 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
FIELD_PREP(PCIE_K_FINETUNE_MAX, 0xf);
|
||||
writel_relaxed(val, pcie->base + PCIE_PIPE4_PIE8_REG);
|
||||
|
||||
- err = clk_bulk_enable(pcie->num_clks, pcie->clks);
|
||||
+ err = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks);
|
||||
if (err) {
|
||||
dev_err(dev, "failed to prepare clock\n");
|
||||
- goto err_clk_enable;
|
||||
+ goto err_clk_prepare_enable;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
-err_clk_enable:
|
||||
- clk_bulk_unprepare(pcie->num_clks, pcie->clks);
|
||||
-err_clk_prepare:
|
||||
+err_clk_prepare_enable:
|
||||
pm_runtime_put_sync(dev);
|
||||
pm_runtime_disable(dev);
|
||||
reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
|
||||
@ -1,86 +0,0 @@
|
||||
From e4c7dfd953f7618f0ccb70d87c1629634f306fab Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:41 +0100
|
||||
Subject: [PATCH 2/6] PCI: mediatek-gen3: Move reset/assert callbacks in
|
||||
.power_up()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
In order to make the code more readable, the reset_control_bulk_assert()
|
||||
function for PHY reset lines is moved to make it pair with
|
||||
reset_control_bulk_deassert() in mtk_pcie_power_up() and
|
||||
mtk_pcie_en7581_power_up(). The same change is done for
|
||||
reset_control_assert() used to assert MAC reset line.
|
||||
|
||||
Introduce PCIE_MTK_RESET_TIME_US macro for the time needed to
|
||||
complete PCIe reset on MediaTek controller.
|
||||
|
||||
Link: https://lore.kernel.org/r/20250108-pcie-en7581-fixes-v6-2-21ac939a3b9b@kernel.org
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 28 +++++++++++++--------
|
||||
1 file changed, 18 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -120,6 +120,8 @@
|
||||
|
||||
#define MAX_NUM_PHY_RESETS 3
|
||||
|
||||
+#define PCIE_MTK_RESET_TIME_US 10
|
||||
+
|
||||
/* Time in ms needed to complete PCIe reset on EN7581 SoC */
|
||||
#define PCIE_EN7581_RESET_TIME_MS 100
|
||||
|
||||
@@ -868,9 +870,14 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
u32 val;
|
||||
|
||||
/*
|
||||
- * Wait for the time needed to complete the bulk assert in
|
||||
- * mtk_pcie_setup for EN7581 SoC.
|
||||
+ * The controller may have been left out of reset by the bootloader
|
||||
+ * so make sure that we get a clean start by asserting resets here.
|
||||
*/
|
||||
+ reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
|
||||
+ pcie->phy_resets);
|
||||
+ reset_control_assert(pcie->mac_reset);
|
||||
+
|
||||
+ /* Wait for the time needed to complete the reset lines assert. */
|
||||
mdelay(PCIE_EN7581_RESET_TIME_MS);
|
||||
|
||||
err = phy_init(pcie->phy);
|
||||
@@ -937,6 +944,15 @@ static int mtk_pcie_power_up(struct mtk_
|
||||
struct device *dev = pcie->dev;
|
||||
int err;
|
||||
|
||||
+ /*
|
||||
+ * The controller may have been left out of reset by the bootloader
|
||||
+ * so make sure that we get a clean start by asserting resets here.
|
||||
+ */
|
||||
+ reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
|
||||
+ pcie->phy_resets);
|
||||
+ reset_control_assert(pcie->mac_reset);
|
||||
+ usleep_range(PCIE_MTK_RESET_TIME_US, 2 * PCIE_MTK_RESET_TIME_US);
|
||||
+
|
||||
/* PHY power on and enable pipe clock */
|
||||
err = reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
|
||||
if (err) {
|
||||
@@ -1009,14 +1025,6 @@ static int mtk_pcie_setup(struct mtk_gen
|
||||
* counter since the bulk is shared.
|
||||
*/
|
||||
reset_control_bulk_deassert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
|
||||
- /*
|
||||
- * The controller may have been left out of reset by the bootloader
|
||||
- * so make sure that we get a clean start by asserting resets here.
|
||||
- */
|
||||
- reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets);
|
||||
-
|
||||
- reset_control_assert(pcie->mac_reset);
|
||||
- usleep_range(10, 20);
|
||||
|
||||
/* Don't touch the hardware registers before power up */
|
||||
err = pcie->soc->power_up(pcie);
|
||||
@ -1,35 +0,0 @@
|
||||
From 0c9d2d2ef0d916b490a9222ed20ff4616fca876d Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:42 +0100
|
||||
Subject: [PATCH 3/6] PCI: mediatek-gen3: Add comment about initialization
|
||||
order in mtk_pcie_en7581_power_up()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Add a comment in mtk_pcie_en7581_power_up() to clarify, unlike the other
|
||||
MediaTek Gen3 controllers, the Airoha EN7581 requires PHY initialization
|
||||
and power-on before PHY reset deassert.
|
||||
|
||||
Link: https://lore.kernel.org/r/20250108-pcie-en7581-fixes-v6-3-21ac939a3b9b@kernel.org
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -880,6 +880,10 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
/* Wait for the time needed to complete the reset lines assert. */
|
||||
mdelay(PCIE_EN7581_RESET_TIME_MS);
|
||||
|
||||
+ /*
|
||||
+ * Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
|
||||
+ * requires PHY initialization and power-on before PHY reset deassert.
|
||||
+ */
|
||||
err = phy_init(pcie->phy);
|
||||
if (err) {
|
||||
dev_err(dev, "failed to initialize PHY\n");
|
||||
@ -1,59 +0,0 @@
|
||||
From 90d4e466c9ea2010f33880a36317a8486ccbe082 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:43 +0100
|
||||
Subject: [PATCH 4/6] PCI: mediatek-gen3: Move reset delay in
|
||||
mtk_pcie_en7581_power_up()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
|
||||
causing occasional PCIe link down issues. In order to overcome the
|
||||
problem, PCIe block is reset using REG_PCI_CONTROL (0x88) and
|
||||
REG_RESET_CONTROL (0x834) registers available in the clock module
|
||||
running clk_bulk_prepare_enable() in mtk_pcie_en7581_power_up().
|
||||
|
||||
In order to make the code more readable, move the wait for the time
|
||||
needed to complete the PCIe reset from en7581_pci_enable() to
|
||||
mtk_pcie_en7581_power_up().
|
||||
|
||||
Reduce reset timeout from 250ms to the standard PCIE_T_PVPERL_MS value
|
||||
(100ms) since it has no impact on the driver behavior.
|
||||
|
||||
Link: https://lore.kernel.org/r/20250108-pcie-en7581-fixes-v6-4-21ac939a3b9b@kernel.org
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
Acked-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/clk-en7523.c | 1 -
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 7 +++++++
|
||||
2 files changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/clk/clk-en7523.c
|
||||
+++ b/drivers/clk/clk-en7523.c
|
||||
@@ -489,7 +489,6 @@ static int en7581_pci_enable(struct clk_
|
||||
REG_PCI_CONTROL_PERSTOUT;
|
||||
val = readl(np_base + REG_PCI_CONTROL);
|
||||
writel(val | mask, np_base + REG_PCI_CONTROL);
|
||||
- msleep(250);
|
||||
|
||||
return 0;
|
||||
}
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -929,6 +929,13 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
goto err_clk_prepare_enable;
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * Airoha EN7581 performs PCIe reset via clk callbacks since it has a
|
||||
+ * hw issue with PCIE_PE_RSTB signal. Add wait for the time needed to
|
||||
+ * complete the PCIe reset.
|
||||
+ */
|
||||
+ msleep(PCIE_T_PVPERL_MS);
|
||||
+
|
||||
return 0;
|
||||
|
||||
err_clk_prepare_enable:
|
||||
@ -1,41 +0,0 @@
|
||||
From c98bee18d0a094e37100c85effe5e161418f8644 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:44 +0100
|
||||
Subject: [PATCH 5/6] PCI: mediatek-gen3: Rely on msleep() in
|
||||
mtk_pcie_en7581_power_up()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Since mtk_pcie_en7581_power_up() runs in non-atomic context, rely on
|
||||
msleep() routine instead of mdelay().
|
||||
|
||||
Link: https://lore.kernel.org/r/20250108-pcie-en7581-fixes-v6-5-21ac939a3b9b@kernel.org
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -878,7 +878,7 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
reset_control_assert(pcie->mac_reset);
|
||||
|
||||
/* Wait for the time needed to complete the reset lines assert. */
|
||||
- mdelay(PCIE_EN7581_RESET_TIME_MS);
|
||||
+ msleep(PCIE_EN7581_RESET_TIME_MS);
|
||||
|
||||
/*
|
||||
* Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
|
||||
@@ -906,7 +906,7 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
* Wait for the time needed to complete the bulk de-assert above.
|
||||
* This time is specific for EN7581 SoC.
|
||||
*/
|
||||
- mdelay(PCIE_EN7581_RESET_TIME_MS);
|
||||
+ msleep(PCIE_EN7581_RESET_TIME_MS);
|
||||
|
||||
pm_runtime_enable(dev);
|
||||
pm_runtime_get_sync(dev);
|
||||
@ -1,128 +0,0 @@
|
||||
From 491cb9c5084790aafa02e843349492c284373231 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 9 Jan 2025 00:30:45 +0100
|
||||
Subject: [PATCH 6/6] PCI: mediatek-gen3: Avoid PCIe resetting via PERST# for
|
||||
Airoha EN7581 SoC
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Airoha EN7581 has a hw bug asserting/releasing PERST# signal causing
|
||||
occasional PCIe link down issues. In order to overcome the problem,
|
||||
PERST# signal is not asserted/released during device probe or
|
||||
suspend/resume phase and the PCIe block is reset using
|
||||
en7523_reset_assert() and en7581_pci_enable().
|
||||
|
||||
Introduce flags field in the mtk_gen3_pcie_pdata struct in order to
|
||||
specify per-SoC capabilities.
|
||||
|
||||
Link: https://lore.kernel.org/r/20250109-pcie-en7581-rst-fix-v4-1-4a45c89fb143@kernel.org
|
||||
Tested-by: Hui Ma <hui.ma@airoha.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 59 ++++++++++++++-------
|
||||
1 file changed, 41 insertions(+), 18 deletions(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -127,10 +127,18 @@
|
||||
|
||||
struct mtk_gen3_pcie;
|
||||
|
||||
+enum mtk_gen3_pcie_flags {
|
||||
+ SKIP_PCIE_RSTB = BIT(0), /* Skip PERST# assertion during device
|
||||
+ * probing or suspend/resume phase to
|
||||
+ * avoid hw bugs/issues.
|
||||
+ */
|
||||
+};
|
||||
+
|
||||
/**
|
||||
* struct mtk_gen3_pcie_pdata - differentiate between host generations
|
||||
* @power_up: pcie power_up callback
|
||||
* @phy_resets: phy reset lines SoC data.
|
||||
+ * @flags: pcie device flags.
|
||||
*/
|
||||
struct mtk_gen3_pcie_pdata {
|
||||
int (*power_up)(struct mtk_gen3_pcie *pcie);
|
||||
@@ -138,6 +146,7 @@ struct mtk_gen3_pcie_pdata {
|
||||
const char *id[MAX_NUM_PHY_RESETS];
|
||||
int num_resets;
|
||||
} phy_resets;
|
||||
+ u32 flags;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -404,22 +413,33 @@ static int mtk_pcie_startup_port(struct
|
||||
val |= PCIE_DISABLE_DVFSRC_VLT_REQ;
|
||||
writel_relaxed(val, pcie->base + PCIE_MISC_CTRL_REG);
|
||||
|
||||
- /* Assert all reset signals */
|
||||
- val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
|
||||
- val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB;
|
||||
- writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
|
||||
-
|
||||
/*
|
||||
- * Described in PCIe CEM specification sections 2.2 (PERST# Signal)
|
||||
- * and 2.2.1 (Initial Power-Up (G3 to S0)).
|
||||
- * The deassertion of PERST# should be delayed 100ms (TPVPERL)
|
||||
- * for the power and clock to become stable.
|
||||
+ * Airoha EN7581 has a hw bug asserting/releasing PCIE_PE_RSTB signal
|
||||
+ * causing occasional PCIe link down. In order to overcome the issue,
|
||||
+ * PCIE_RSTB signals are not asserted/released at this stage and the
|
||||
+ * PCIe block is reset using en7523_reset_assert() and
|
||||
+ * en7581_pci_enable().
|
||||
*/
|
||||
- msleep(100);
|
||||
-
|
||||
- /* De-assert reset signals */
|
||||
- val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB);
|
||||
- writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
|
||||
+ if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
|
||||
+ /* Assert all reset signals */
|
||||
+ val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
|
||||
+ val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
|
||||
+ PCIE_PE_RSTB;
|
||||
+ writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
|
||||
+
|
||||
+ /*
|
||||
+ * Described in PCIe CEM specification revision 6.0.
|
||||
+ *
|
||||
+ * The deassertion of PERST# should be delayed 100ms (TPVPERL)
|
||||
+ * for the power and clock to become stable.
|
||||
+ */
|
||||
+ msleep(PCIE_T_PVPERL_MS);
|
||||
+
|
||||
+ /* De-assert reset signals */
|
||||
+ val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
|
||||
+ PCIE_PE_RSTB);
|
||||
+ writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
|
||||
+ }
|
||||
|
||||
/* Check if the link is up or not */
|
||||
err = readl_poll_timeout(pcie->base + PCIE_LINK_STATUS_REG, val,
|
||||
@@ -1171,10 +1191,12 @@ static int mtk_pcie_suspend_noirq(struct
|
||||
return err;
|
||||
}
|
||||
|
||||
- /* Pull down the PERST# pin */
|
||||
- val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
|
||||
- val |= PCIE_PE_RSTB;
|
||||
- writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
|
||||
+ if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
|
||||
+ /* Assert the PERST# pin */
|
||||
+ val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG);
|
||||
+ val |= PCIE_PE_RSTB;
|
||||
+ writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
|
||||
+ }
|
||||
|
||||
dev_dbg(pcie->dev, "entered L2 states successfully");
|
||||
|
||||
@@ -1225,6 +1247,7 @@ static const struct mtk_gen3_pcie_pdata
|
||||
.id[2] = "phy-lane2",
|
||||
.num_resets = 3,
|
||||
},
|
||||
+ .flags = SKIP_PCIE_RSTB,
|
||||
};
|
||||
|
||||
static const struct of_device_id mtk_pcie_of_match[] = {
|
||||
@ -1,34 +0,0 @@
|
||||
From b6d7bb0d3bd74b491e2e6fd59c4d5110d06fd63b Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Sat, 1 Feb 2025 12:00:18 +0100
|
||||
Subject: [PATCH] PCI: mediatek-gen3: Remove leftover mac_reset assert for
|
||||
Airoha EN7581 SoC
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Remove a leftover assert for mac_reset line in mtk_pcie_en7581_power_up().
|
||||
|
||||
This is not harmful since EN7581 does not requires mac_reset and
|
||||
mac_reset is not defined in EN7581 device tree.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
|
||||
Link: https://lore.kernel.org/r/20250201-pcie-en7581-remove-mac_reset-v2-1-a06786cdc683@kernel.org
|
||||
[kwilczynski: commit log]
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -895,7 +895,6 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
*/
|
||||
reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
|
||||
pcie->phy_resets);
|
||||
- reset_control_assert(pcie->mac_reset);
|
||||
|
||||
/* Wait for the time needed to complete the reset lines assert. */
|
||||
msleep(PCIE_EN7581_RESET_TIME_MS);
|
||||
@ -1,81 +0,0 @@
|
||||
From 249b78298078448a699c39356d27d8183af4b281 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 25 Feb 2025 09:04:07 +0100
|
||||
Subject: [PATCH] PCI: mediatek-gen3: Configure PBUS_CSR registers for EN7581
|
||||
SoC
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Configure PBus base address and address mask to allow the hw
|
||||
to detect if a given address is accessible on PCIe controller.
|
||||
|
||||
Fixes: f6ab898356dd ("PCI: mediatek-gen3: Add Airoha EN7581 support")
|
||||
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://lore.kernel.org/r/20250225-en7581-pcie-pbus-csr-v4-2-24324382424a@kernel.org
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 28 ++++++++++++++++++++-
|
||||
1 file changed, 27 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <linux/irqchip/chained_irq.h>
|
||||
#include <linux/irqdomain.h>
|
||||
#include <linux/kernel.h>
|
||||
+#include <linux/mfd/syscon.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/msi.h>
|
||||
#include <linux/of_device.h>
|
||||
@@ -24,6 +25,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/pm_domain.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
+#include <linux/regmap.h>
|
||||
#include <linux/reset.h>
|
||||
|
||||
#include "../pci.h"
|
||||
@@ -885,9 +887,13 @@ static int mtk_pcie_parse_port(struct mt
|
||||
|
||||
static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
|
||||
{
|
||||
+ struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
|
||||
struct device *dev = pcie->dev;
|
||||
+ struct resource_entry *entry;
|
||||
+ struct regmap *pbus_regmap;
|
||||
+ u32 val, args[2], size;
|
||||
+ resource_size_t addr;
|
||||
int err;
|
||||
- u32 val;
|
||||
|
||||
/*
|
||||
* The controller may have been left out of reset by the bootloader
|
||||
@@ -900,6 +906,26 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
msleep(PCIE_EN7581_RESET_TIME_MS);
|
||||
|
||||
/*
|
||||
+ * Configure PBus base address and base address mask to allow the
|
||||
+ * hw to detect if a given address is accessible on PCIe controller.
|
||||
+ */
|
||||
+ pbus_regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node,
|
||||
+ "mediatek,pbus-csr",
|
||||
+ ARRAY_SIZE(args),
|
||||
+ args);
|
||||
+ if (IS_ERR(pbus_regmap))
|
||||
+ return PTR_ERR(pbus_regmap);
|
||||
+
|
||||
+ entry = resource_list_first_type(&host->windows, IORESOURCE_MEM);
|
||||
+ if (!entry)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ addr = entry->res->start - entry->offset;
|
||||
+ regmap_write(pbus_regmap, args[0], lower_32_bits(addr));
|
||||
+ size = lower_32_bits(resource_size(entry->res));
|
||||
+ regmap_write(pbus_regmap, args[1], GENMASK(31, __fls(size)));
|
||||
+
|
||||
+ /*
|
||||
* Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
|
||||
* requires PHY initialization and power-on before PHY reset deassert.
|
||||
*/
|
||||
@ -1,60 +0,0 @@
|
||||
From c6287e1a858e336cc202b484c6138a0fe252c6b3 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 13 Feb 2025 16:34:20 +0100
|
||||
Subject: [PATCH] net: airoha: Fix TSO support for header cloned skbs
|
||||
|
||||
For GSO packets, skb_cow_head() will reallocate the skb for TSO header
|
||||
cloned skbs in airoha_dev_xmit(). For this reason, sinfo pointer can be
|
||||
no more valid. Fix the issue relying on skb_shinfo() macro directly in
|
||||
airoha_dev_xmit().
|
||||
|
||||
The problem exists since
|
||||
commit 23020f049327 ("net: airoha: Introduce ethernet support for EN7581 SoC")
|
||||
but it is not a user visible, since we can't currently enable TSO
|
||||
for DSA user ports since we are missing to initialize net_device
|
||||
vlan_features field.
|
||||
|
||||
Reviewed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250213-airoha-en7581-flowtable-offload-v4-1-b69ca16d74db@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -2569,11 +2569,10 @@ static u16 airoha_dev_select_queue(struc
|
||||
static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
- struct skb_shared_info *sinfo = skb_shinfo(skb);
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
+ u32 nr_frags = 1 + skb_shinfo(skb)->nr_frags;
|
||||
u32 msg0, msg1, len = skb_headlen(skb);
|
||||
struct airoha_qdma *qdma = port->qdma;
|
||||
- u32 nr_frags = 1 + sinfo->nr_frags;
|
||||
struct netdev_queue *txq;
|
||||
struct airoha_queue *q;
|
||||
void *data = skb->data;
|
||||
@@ -2596,8 +2595,9 @@ static netdev_tx_t airoha_dev_xmit(struc
|
||||
if (skb_cow_head(skb, 0))
|
||||
goto error;
|
||||
|
||||
- if (sinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) {
|
||||
- __be16 csum = cpu_to_be16(sinfo->gso_size);
|
||||
+ if (skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 |
|
||||
+ SKB_GSO_TCPV6)) {
|
||||
+ __be16 csum = cpu_to_be16(skb_shinfo(skb)->gso_size);
|
||||
|
||||
tcp_hdr(skb)->check = (__force __sum16)csum;
|
||||
msg0 |= FIELD_PREP(QDMA_ETH_TXMSG_TSO_MASK, 1);
|
||||
@@ -2626,7 +2626,7 @@ static netdev_tx_t airoha_dev_xmit(struc
|
||||
for (i = 0; i < nr_frags; i++) {
|
||||
struct airoha_qdma_desc *desc = &q->desc[index];
|
||||
struct airoha_queue_entry *e = &q->entry[index];
|
||||
- skb_frag_t *frag = &sinfo->frags[i];
|
||||
+ skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
|
||||
dma_addr_t addr;
|
||||
u32 val;
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
From c9f947769b77c8e8f318bfc8a0777e5d20c44d8d Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 17 Oct 2024 16:01:41 +0200
|
||||
Subject: [PATCH] net: airoha: Reset BQL stopping the netdevice
|
||||
|
||||
Run airoha_qdma_cleanup_tx_queue() in ndo_stop callback in order to
|
||||
unmap pending skbs. Moreover, reset BQL txq state stopping the netdevice,
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Hariprasad Kelam <hkelam@marvell.com>
|
||||
Message-ID: <20241017-airoha-en7581-reset-bql-v1-1-08c0c9888de5@kernel.org>
|
||||
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/airoha_eth.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
|
||||
@@ -2489,7 +2489,7 @@ static int airoha_dev_stop(struct net_de
|
||||
{
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
struct airoha_qdma *qdma = port->qdma;
|
||||
- int err;
|
||||
+ int i, err;
|
||||
|
||||
netif_tx_disable(dev);
|
||||
err = airoha_set_gdm_ports(qdma->eth, false);
|
||||
@@ -2500,6 +2500,14 @@ static int airoha_dev_stop(struct net_de
|
||||
GLOBAL_CFG_TX_DMA_EN_MASK |
|
||||
GLOBAL_CFG_RX_DMA_EN_MASK);
|
||||
|
||||
+ for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
|
||||
+ if (!qdma->q_tx[i].ndesc)
|
||||
+ continue;
|
||||
+
|
||||
+ airoha_qdma_cleanup_tx_queue(&qdma->q_tx[i]);
|
||||
+ netdev_tx_reset_subqueue(dev, i);
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,538 +0,0 @@
|
||||
From b38f4ff0ceacd6ce8d333a8dc90f405a040968d3 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:10 +0100
|
||||
Subject: [PATCH 02/15] net: airoha: Move definitions in airoha_eth.h
|
||||
|
||||
Move common airoha_eth definitions in airoha_eth.h in order to reuse
|
||||
them for Packet Processor Engine (PPE) codebase.
|
||||
PPE module is used to enable support for flowtable hw offloading in
|
||||
airoha_eth driver.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 240 +---------------------
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 251 +++++++++++++++++++++++
|
||||
2 files changed, 252 insertions(+), 239 deletions(-)
|
||||
create mode 100644 drivers/net/ethernet/airoha/airoha_eth.h
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -3,14 +3,9 @@
|
||||
* Copyright (c) 2024 AIROHA Inc
|
||||
* Author: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
*/
|
||||
-#include <linux/etherdevice.h>
|
||||
-#include <linux/iopoll.h>
|
||||
-#include <linux/kernel.h>
|
||||
-#include <linux/netdevice.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_net.h>
|
||||
#include <linux/platform_device.h>
|
||||
-#include <linux/reset.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/u64_stats_sync.h>
|
||||
#include <net/dsa.h>
|
||||
@@ -18,35 +13,7 @@
|
||||
#include <net/pkt_cls.h>
|
||||
#include <uapi/linux/ppp_defs.h>
|
||||
|
||||
-#define AIROHA_MAX_NUM_GDM_PORTS 1
|
||||
-#define AIROHA_MAX_NUM_QDMA 2
|
||||
-#define AIROHA_MAX_NUM_RSTS 3
|
||||
-#define AIROHA_MAX_NUM_XSI_RSTS 5
|
||||
-#define AIROHA_MAX_MTU 2000
|
||||
-#define AIROHA_MAX_PACKET_SIZE 2048
|
||||
-#define AIROHA_NUM_QOS_CHANNELS 4
|
||||
-#define AIROHA_NUM_QOS_QUEUES 8
|
||||
-#define AIROHA_NUM_TX_RING 32
|
||||
-#define AIROHA_NUM_RX_RING 32
|
||||
-#define AIROHA_NUM_NETDEV_TX_RINGS (AIROHA_NUM_TX_RING + \
|
||||
- AIROHA_NUM_QOS_CHANNELS)
|
||||
-#define AIROHA_FE_MC_MAX_VLAN_TABLE 64
|
||||
-#define AIROHA_FE_MC_MAX_VLAN_PORT 16
|
||||
-#define AIROHA_NUM_TX_IRQ 2
|
||||
-#define HW_DSCP_NUM 2048
|
||||
-#define IRQ_QUEUE_LEN(_n) ((_n) ? 1024 : 2048)
|
||||
-#define TX_DSCP_NUM 1024
|
||||
-#define RX_DSCP_NUM(_n) \
|
||||
- ((_n) == 2 ? 128 : \
|
||||
- (_n) == 11 ? 128 : \
|
||||
- (_n) == 15 ? 128 : \
|
||||
- (_n) == 0 ? 1024 : 16)
|
||||
-
|
||||
-#define PSE_RSV_PAGES 128
|
||||
-#define PSE_QUEUE_RSV_PAGES 64
|
||||
-
|
||||
-#define QDMA_METER_IDX(_n) ((_n) & 0xff)
|
||||
-#define QDMA_METER_GROUP(_n) (((_n) >> 8) & 0x3)
|
||||
+#include "airoha_eth.h"
|
||||
|
||||
/* FE */
|
||||
#define PSE_BASE 0x0100
|
||||
@@ -706,211 +673,6 @@ struct airoha_qdma_fwd_desc {
|
||||
__le32 rsv1;
|
||||
};
|
||||
|
||||
-enum {
|
||||
- QDMA_INT_REG_IDX0,
|
||||
- QDMA_INT_REG_IDX1,
|
||||
- QDMA_INT_REG_IDX2,
|
||||
- QDMA_INT_REG_IDX3,
|
||||
- QDMA_INT_REG_IDX4,
|
||||
- QDMA_INT_REG_MAX
|
||||
-};
|
||||
-
|
||||
-enum {
|
||||
- XSI_PCIE0_PORT,
|
||||
- XSI_PCIE1_PORT,
|
||||
- XSI_USB_PORT,
|
||||
- XSI_AE_PORT,
|
||||
- XSI_ETH_PORT,
|
||||
-};
|
||||
-
|
||||
-enum {
|
||||
- XSI_PCIE0_VIP_PORT_MASK = BIT(22),
|
||||
- XSI_PCIE1_VIP_PORT_MASK = BIT(23),
|
||||
- XSI_USB_VIP_PORT_MASK = BIT(25),
|
||||
- XSI_ETH_VIP_PORT_MASK = BIT(24),
|
||||
-};
|
||||
-
|
||||
-enum {
|
||||
- DEV_STATE_INITIALIZED,
|
||||
-};
|
||||
-
|
||||
-enum {
|
||||
- CDM_CRSN_QSEL_Q1 = 1,
|
||||
- CDM_CRSN_QSEL_Q5 = 5,
|
||||
- CDM_CRSN_QSEL_Q6 = 6,
|
||||
- CDM_CRSN_QSEL_Q15 = 15,
|
||||
-};
|
||||
-
|
||||
-enum {
|
||||
- CRSN_08 = 0x8,
|
||||
- CRSN_21 = 0x15, /* KA */
|
||||
- CRSN_22 = 0x16, /* hit bind and force route to CPU */
|
||||
- CRSN_24 = 0x18,
|
||||
- CRSN_25 = 0x19,
|
||||
-};
|
||||
-
|
||||
-enum {
|
||||
- FE_PSE_PORT_CDM1,
|
||||
- FE_PSE_PORT_GDM1,
|
||||
- FE_PSE_PORT_GDM2,
|
||||
- FE_PSE_PORT_GDM3,
|
||||
- FE_PSE_PORT_PPE1,
|
||||
- FE_PSE_PORT_CDM2,
|
||||
- FE_PSE_PORT_CDM3,
|
||||
- FE_PSE_PORT_CDM4,
|
||||
- FE_PSE_PORT_PPE2,
|
||||
- FE_PSE_PORT_GDM4,
|
||||
- FE_PSE_PORT_CDM5,
|
||||
- FE_PSE_PORT_DROP = 0xf,
|
||||
-};
|
||||
-
|
||||
-enum tx_sched_mode {
|
||||
- TC_SCH_WRR8,
|
||||
- TC_SCH_SP,
|
||||
- TC_SCH_WRR7,
|
||||
- TC_SCH_WRR6,
|
||||
- TC_SCH_WRR5,
|
||||
- TC_SCH_WRR4,
|
||||
- TC_SCH_WRR3,
|
||||
- TC_SCH_WRR2,
|
||||
-};
|
||||
-
|
||||
-enum trtcm_param_type {
|
||||
- TRTCM_MISC_MODE, /* meter_en, pps_mode, tick_sel */
|
||||
- TRTCM_TOKEN_RATE_MODE,
|
||||
- TRTCM_BUCKETSIZE_SHIFT_MODE,
|
||||
- TRTCM_BUCKET_COUNTER_MODE,
|
||||
-};
|
||||
-
|
||||
-enum trtcm_mode_type {
|
||||
- TRTCM_COMMIT_MODE,
|
||||
- TRTCM_PEAK_MODE,
|
||||
-};
|
||||
-
|
||||
-enum trtcm_param {
|
||||
- TRTCM_TICK_SEL = BIT(0),
|
||||
- TRTCM_PKT_MODE = BIT(1),
|
||||
- TRTCM_METER_MODE = BIT(2),
|
||||
-};
|
||||
-
|
||||
-#define MIN_TOKEN_SIZE 4096
|
||||
-#define MAX_TOKEN_SIZE_OFFSET 17
|
||||
-#define TRTCM_TOKEN_RATE_MASK GENMASK(23, 6)
|
||||
-#define TRTCM_TOKEN_RATE_FRACTION_MASK GENMASK(5, 0)
|
||||
-
|
||||
-struct airoha_queue_entry {
|
||||
- union {
|
||||
- void *buf;
|
||||
- struct sk_buff *skb;
|
||||
- };
|
||||
- dma_addr_t dma_addr;
|
||||
- u16 dma_len;
|
||||
-};
|
||||
-
|
||||
-struct airoha_queue {
|
||||
- struct airoha_qdma *qdma;
|
||||
-
|
||||
- /* protect concurrent queue accesses */
|
||||
- spinlock_t lock;
|
||||
- struct airoha_queue_entry *entry;
|
||||
- struct airoha_qdma_desc *desc;
|
||||
- u16 head;
|
||||
- u16 tail;
|
||||
-
|
||||
- int queued;
|
||||
- int ndesc;
|
||||
- int free_thr;
|
||||
- int buf_size;
|
||||
-
|
||||
- struct napi_struct napi;
|
||||
- struct page_pool *page_pool;
|
||||
-};
|
||||
-
|
||||
-struct airoha_tx_irq_queue {
|
||||
- struct airoha_qdma *qdma;
|
||||
-
|
||||
- struct napi_struct napi;
|
||||
-
|
||||
- int size;
|
||||
- u32 *q;
|
||||
-};
|
||||
-
|
||||
-struct airoha_hw_stats {
|
||||
- /* protect concurrent hw_stats accesses */
|
||||
- spinlock_t lock;
|
||||
- struct u64_stats_sync syncp;
|
||||
-
|
||||
- /* get_stats64 */
|
||||
- u64 rx_ok_pkts;
|
||||
- u64 tx_ok_pkts;
|
||||
- u64 rx_ok_bytes;
|
||||
- u64 tx_ok_bytes;
|
||||
- u64 rx_multicast;
|
||||
- u64 rx_errors;
|
||||
- u64 rx_drops;
|
||||
- u64 tx_drops;
|
||||
- u64 rx_crc_error;
|
||||
- u64 rx_over_errors;
|
||||
- /* ethtool stats */
|
||||
- u64 tx_broadcast;
|
||||
- u64 tx_multicast;
|
||||
- u64 tx_len[7];
|
||||
- u64 rx_broadcast;
|
||||
- u64 rx_fragment;
|
||||
- u64 rx_jabber;
|
||||
- u64 rx_len[7];
|
||||
-};
|
||||
-
|
||||
-struct airoha_qdma {
|
||||
- struct airoha_eth *eth;
|
||||
- void __iomem *regs;
|
||||
-
|
||||
- /* protect concurrent irqmask accesses */
|
||||
- spinlock_t irq_lock;
|
||||
- u32 irqmask[QDMA_INT_REG_MAX];
|
||||
- int irq;
|
||||
-
|
||||
- struct airoha_tx_irq_queue q_tx_irq[AIROHA_NUM_TX_IRQ];
|
||||
-
|
||||
- struct airoha_queue q_tx[AIROHA_NUM_TX_RING];
|
||||
- struct airoha_queue q_rx[AIROHA_NUM_RX_RING];
|
||||
-
|
||||
- /* descriptor and packet buffers for qdma hw forward */
|
||||
- struct {
|
||||
- void *desc;
|
||||
- void *q;
|
||||
- } hfwd;
|
||||
-};
|
||||
-
|
||||
-struct airoha_gdm_port {
|
||||
- struct airoha_qdma *qdma;
|
||||
- struct net_device *dev;
|
||||
- int id;
|
||||
-
|
||||
- struct airoha_hw_stats stats;
|
||||
-
|
||||
- DECLARE_BITMAP(qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS);
|
||||
-
|
||||
- /* qos stats counters */
|
||||
- u64 cpu_tx_packets;
|
||||
- u64 fwd_tx_packets;
|
||||
-};
|
||||
-
|
||||
-struct airoha_eth {
|
||||
- struct device *dev;
|
||||
-
|
||||
- unsigned long state;
|
||||
- void __iomem *fe_regs;
|
||||
-
|
||||
- struct reset_control_bulk_data rsts[AIROHA_MAX_NUM_RSTS];
|
||||
- struct reset_control_bulk_data xsi_rsts[AIROHA_MAX_NUM_XSI_RSTS];
|
||||
-
|
||||
- struct net_device *napi_dev;
|
||||
-
|
||||
- struct airoha_qdma qdma[AIROHA_MAX_NUM_QDMA];
|
||||
- struct airoha_gdm_port *ports[AIROHA_MAX_NUM_GDM_PORTS];
|
||||
-};
|
||||
-
|
||||
static u32 airoha_rr(void __iomem *base, u32 offset)
|
||||
{
|
||||
return readl(base + offset);
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -0,0 +1,251 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
+/*
|
||||
+ * Copyright (c) 2024 AIROHA Inc
|
||||
+ * Author: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
+ */
|
||||
+
|
||||
+#ifndef AIROHA_ETH_H
|
||||
+#define AIROHA_ETH_H
|
||||
+
|
||||
+#include <linux/etherdevice.h>
|
||||
+#include <linux/iopoll.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/netdevice.h>
|
||||
+#include <linux/reset.h>
|
||||
+
|
||||
+#define AIROHA_MAX_NUM_GDM_PORTS 1
|
||||
+#define AIROHA_MAX_NUM_QDMA 2
|
||||
+#define AIROHA_MAX_NUM_RSTS 3
|
||||
+#define AIROHA_MAX_NUM_XSI_RSTS 5
|
||||
+#define AIROHA_MAX_MTU 2000
|
||||
+#define AIROHA_MAX_PACKET_SIZE 2048
|
||||
+#define AIROHA_NUM_QOS_CHANNELS 4
|
||||
+#define AIROHA_NUM_QOS_QUEUES 8
|
||||
+#define AIROHA_NUM_TX_RING 32
|
||||
+#define AIROHA_NUM_RX_RING 32
|
||||
+#define AIROHA_NUM_NETDEV_TX_RINGS (AIROHA_NUM_TX_RING + \
|
||||
+ AIROHA_NUM_QOS_CHANNELS)
|
||||
+#define AIROHA_FE_MC_MAX_VLAN_TABLE 64
|
||||
+#define AIROHA_FE_MC_MAX_VLAN_PORT 16
|
||||
+#define AIROHA_NUM_TX_IRQ 2
|
||||
+#define HW_DSCP_NUM 2048
|
||||
+#define IRQ_QUEUE_LEN(_n) ((_n) ? 1024 : 2048)
|
||||
+#define TX_DSCP_NUM 1024
|
||||
+#define RX_DSCP_NUM(_n) \
|
||||
+ ((_n) == 2 ? 128 : \
|
||||
+ (_n) == 11 ? 128 : \
|
||||
+ (_n) == 15 ? 128 : \
|
||||
+ (_n) == 0 ? 1024 : 16)
|
||||
+
|
||||
+#define PSE_RSV_PAGES 128
|
||||
+#define PSE_QUEUE_RSV_PAGES 64
|
||||
+
|
||||
+#define QDMA_METER_IDX(_n) ((_n) & 0xff)
|
||||
+#define QDMA_METER_GROUP(_n) (((_n) >> 8) & 0x3)
|
||||
+
|
||||
+enum {
|
||||
+ QDMA_INT_REG_IDX0,
|
||||
+ QDMA_INT_REG_IDX1,
|
||||
+ QDMA_INT_REG_IDX2,
|
||||
+ QDMA_INT_REG_IDX3,
|
||||
+ QDMA_INT_REG_IDX4,
|
||||
+ QDMA_INT_REG_MAX
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ XSI_PCIE0_PORT,
|
||||
+ XSI_PCIE1_PORT,
|
||||
+ XSI_USB_PORT,
|
||||
+ XSI_AE_PORT,
|
||||
+ XSI_ETH_PORT,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ XSI_PCIE0_VIP_PORT_MASK = BIT(22),
|
||||
+ XSI_PCIE1_VIP_PORT_MASK = BIT(23),
|
||||
+ XSI_USB_VIP_PORT_MASK = BIT(25),
|
||||
+ XSI_ETH_VIP_PORT_MASK = BIT(24),
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ DEV_STATE_INITIALIZED,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ CDM_CRSN_QSEL_Q1 = 1,
|
||||
+ CDM_CRSN_QSEL_Q5 = 5,
|
||||
+ CDM_CRSN_QSEL_Q6 = 6,
|
||||
+ CDM_CRSN_QSEL_Q15 = 15,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ CRSN_08 = 0x8,
|
||||
+ CRSN_21 = 0x15, /* KA */
|
||||
+ CRSN_22 = 0x16, /* hit bind and force route to CPU */
|
||||
+ CRSN_24 = 0x18,
|
||||
+ CRSN_25 = 0x19,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ FE_PSE_PORT_CDM1,
|
||||
+ FE_PSE_PORT_GDM1,
|
||||
+ FE_PSE_PORT_GDM2,
|
||||
+ FE_PSE_PORT_GDM3,
|
||||
+ FE_PSE_PORT_PPE1,
|
||||
+ FE_PSE_PORT_CDM2,
|
||||
+ FE_PSE_PORT_CDM3,
|
||||
+ FE_PSE_PORT_CDM4,
|
||||
+ FE_PSE_PORT_PPE2,
|
||||
+ FE_PSE_PORT_GDM4,
|
||||
+ FE_PSE_PORT_CDM5,
|
||||
+ FE_PSE_PORT_DROP = 0xf,
|
||||
+};
|
||||
+
|
||||
+enum tx_sched_mode {
|
||||
+ TC_SCH_WRR8,
|
||||
+ TC_SCH_SP,
|
||||
+ TC_SCH_WRR7,
|
||||
+ TC_SCH_WRR6,
|
||||
+ TC_SCH_WRR5,
|
||||
+ TC_SCH_WRR4,
|
||||
+ TC_SCH_WRR3,
|
||||
+ TC_SCH_WRR2,
|
||||
+};
|
||||
+
|
||||
+enum trtcm_param_type {
|
||||
+ TRTCM_MISC_MODE, /* meter_en, pps_mode, tick_sel */
|
||||
+ TRTCM_TOKEN_RATE_MODE,
|
||||
+ TRTCM_BUCKETSIZE_SHIFT_MODE,
|
||||
+ TRTCM_BUCKET_COUNTER_MODE,
|
||||
+};
|
||||
+
|
||||
+enum trtcm_mode_type {
|
||||
+ TRTCM_COMMIT_MODE,
|
||||
+ TRTCM_PEAK_MODE,
|
||||
+};
|
||||
+
|
||||
+enum trtcm_param {
|
||||
+ TRTCM_TICK_SEL = BIT(0),
|
||||
+ TRTCM_PKT_MODE = BIT(1),
|
||||
+ TRTCM_METER_MODE = BIT(2),
|
||||
+};
|
||||
+
|
||||
+#define MIN_TOKEN_SIZE 4096
|
||||
+#define MAX_TOKEN_SIZE_OFFSET 17
|
||||
+#define TRTCM_TOKEN_RATE_MASK GENMASK(23, 6)
|
||||
+#define TRTCM_TOKEN_RATE_FRACTION_MASK GENMASK(5, 0)
|
||||
+
|
||||
+struct airoha_queue_entry {
|
||||
+ union {
|
||||
+ void *buf;
|
||||
+ struct sk_buff *skb;
|
||||
+ };
|
||||
+ dma_addr_t dma_addr;
|
||||
+ u16 dma_len;
|
||||
+};
|
||||
+
|
||||
+struct airoha_queue {
|
||||
+ struct airoha_qdma *qdma;
|
||||
+
|
||||
+ /* protect concurrent queue accesses */
|
||||
+ spinlock_t lock;
|
||||
+ struct airoha_queue_entry *entry;
|
||||
+ struct airoha_qdma_desc *desc;
|
||||
+ u16 head;
|
||||
+ u16 tail;
|
||||
+
|
||||
+ int queued;
|
||||
+ int ndesc;
|
||||
+ int free_thr;
|
||||
+ int buf_size;
|
||||
+
|
||||
+ struct napi_struct napi;
|
||||
+ struct page_pool *page_pool;
|
||||
+};
|
||||
+
|
||||
+struct airoha_tx_irq_queue {
|
||||
+ struct airoha_qdma *qdma;
|
||||
+
|
||||
+ struct napi_struct napi;
|
||||
+
|
||||
+ int size;
|
||||
+ u32 *q;
|
||||
+};
|
||||
+
|
||||
+struct airoha_hw_stats {
|
||||
+ /* protect concurrent hw_stats accesses */
|
||||
+ spinlock_t lock;
|
||||
+ struct u64_stats_sync syncp;
|
||||
+
|
||||
+ /* get_stats64 */
|
||||
+ u64 rx_ok_pkts;
|
||||
+ u64 tx_ok_pkts;
|
||||
+ u64 rx_ok_bytes;
|
||||
+ u64 tx_ok_bytes;
|
||||
+ u64 rx_multicast;
|
||||
+ u64 rx_errors;
|
||||
+ u64 rx_drops;
|
||||
+ u64 tx_drops;
|
||||
+ u64 rx_crc_error;
|
||||
+ u64 rx_over_errors;
|
||||
+ /* ethtool stats */
|
||||
+ u64 tx_broadcast;
|
||||
+ u64 tx_multicast;
|
||||
+ u64 tx_len[7];
|
||||
+ u64 rx_broadcast;
|
||||
+ u64 rx_fragment;
|
||||
+ u64 rx_jabber;
|
||||
+ u64 rx_len[7];
|
||||
+};
|
||||
+
|
||||
+struct airoha_qdma {
|
||||
+ struct airoha_eth *eth;
|
||||
+ void __iomem *regs;
|
||||
+
|
||||
+ /* protect concurrent irqmask accesses */
|
||||
+ spinlock_t irq_lock;
|
||||
+ u32 irqmask[QDMA_INT_REG_MAX];
|
||||
+ int irq;
|
||||
+
|
||||
+ struct airoha_tx_irq_queue q_tx_irq[AIROHA_NUM_TX_IRQ];
|
||||
+
|
||||
+ struct airoha_queue q_tx[AIROHA_NUM_TX_RING];
|
||||
+ struct airoha_queue q_rx[AIROHA_NUM_RX_RING];
|
||||
+
|
||||
+ /* descriptor and packet buffers for qdma hw forward */
|
||||
+ struct {
|
||||
+ void *desc;
|
||||
+ void *q;
|
||||
+ } hfwd;
|
||||
+};
|
||||
+
|
||||
+struct airoha_gdm_port {
|
||||
+ struct airoha_qdma *qdma;
|
||||
+ struct net_device *dev;
|
||||
+ int id;
|
||||
+
|
||||
+ struct airoha_hw_stats stats;
|
||||
+
|
||||
+ DECLARE_BITMAP(qos_sq_bmap, AIROHA_NUM_QOS_CHANNELS);
|
||||
+
|
||||
+ /* qos stats counters */
|
||||
+ u64 cpu_tx_packets;
|
||||
+ u64 fwd_tx_packets;
|
||||
+};
|
||||
+
|
||||
+struct airoha_eth {
|
||||
+ struct device *dev;
|
||||
+
|
||||
+ unsigned long state;
|
||||
+ void __iomem *fe_regs;
|
||||
+
|
||||
+ struct reset_control_bulk_data rsts[AIROHA_MAX_NUM_RSTS];
|
||||
+ struct reset_control_bulk_data xsi_rsts[AIROHA_MAX_NUM_XSI_RSTS];
|
||||
+
|
||||
+ struct net_device *napi_dev;
|
||||
+
|
||||
+ struct airoha_qdma qdma[AIROHA_MAX_NUM_QDMA];
|
||||
+ struct airoha_gdm_port *ports[AIROHA_MAX_NUM_GDM_PORTS];
|
||||
+};
|
||||
+
|
||||
+#endif /* AIROHA_ETH_H */
|
||||
@ -1,101 +0,0 @@
|
||||
From e0758a8694fbaffdc72940774db295585e951119 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:11 +0100
|
||||
Subject: [PATCH 03/15] net: airoha: Move reg/write utility routines in
|
||||
airoha_eth.h
|
||||
|
||||
This is a preliminary patch to introduce flowtable hw offloading
|
||||
support for airoha_eth driver.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 28 +++---------------------
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 26 ++++++++++++++++++++++
|
||||
2 files changed, 29 insertions(+), 25 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -673,17 +673,17 @@ struct airoha_qdma_fwd_desc {
|
||||
__le32 rsv1;
|
||||
};
|
||||
|
||||
-static u32 airoha_rr(void __iomem *base, u32 offset)
|
||||
+u32 airoha_rr(void __iomem *base, u32 offset)
|
||||
{
|
||||
return readl(base + offset);
|
||||
}
|
||||
|
||||
-static void airoha_wr(void __iomem *base, u32 offset, u32 val)
|
||||
+void airoha_wr(void __iomem *base, u32 offset, u32 val)
|
||||
{
|
||||
writel(val, base + offset);
|
||||
}
|
||||
|
||||
-static u32 airoha_rmw(void __iomem *base, u32 offset, u32 mask, u32 val)
|
||||
+u32 airoha_rmw(void __iomem *base, u32 offset, u32 mask, u32 val)
|
||||
{
|
||||
val |= (airoha_rr(base, offset) & ~mask);
|
||||
airoha_wr(base, offset, val);
|
||||
@@ -691,28 +691,6 @@ static u32 airoha_rmw(void __iomem *base
|
||||
return val;
|
||||
}
|
||||
|
||||
-#define airoha_fe_rr(eth, offset) \
|
||||
- airoha_rr((eth)->fe_regs, (offset))
|
||||
-#define airoha_fe_wr(eth, offset, val) \
|
||||
- airoha_wr((eth)->fe_regs, (offset), (val))
|
||||
-#define airoha_fe_rmw(eth, offset, mask, val) \
|
||||
- airoha_rmw((eth)->fe_regs, (offset), (mask), (val))
|
||||
-#define airoha_fe_set(eth, offset, val) \
|
||||
- airoha_rmw((eth)->fe_regs, (offset), 0, (val))
|
||||
-#define airoha_fe_clear(eth, offset, val) \
|
||||
- airoha_rmw((eth)->fe_regs, (offset), (val), 0)
|
||||
-
|
||||
-#define airoha_qdma_rr(qdma, offset) \
|
||||
- airoha_rr((qdma)->regs, (offset))
|
||||
-#define airoha_qdma_wr(qdma, offset, val) \
|
||||
- airoha_wr((qdma)->regs, (offset), (val))
|
||||
-#define airoha_qdma_rmw(qdma, offset, mask, val) \
|
||||
- airoha_rmw((qdma)->regs, (offset), (mask), (val))
|
||||
-#define airoha_qdma_set(qdma, offset, val) \
|
||||
- airoha_rmw((qdma)->regs, (offset), 0, (val))
|
||||
-#define airoha_qdma_clear(qdma, offset, val) \
|
||||
- airoha_rmw((qdma)->regs, (offset), (val), 0)
|
||||
-
|
||||
static void airoha_qdma_set_irqmask(struct airoha_qdma *qdma, int index,
|
||||
u32 clear, u32 set)
|
||||
{
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -248,4 +248,30 @@ struct airoha_eth {
|
||||
struct airoha_gdm_port *ports[AIROHA_MAX_NUM_GDM_PORTS];
|
||||
};
|
||||
|
||||
+u32 airoha_rr(void __iomem *base, u32 offset);
|
||||
+void airoha_wr(void __iomem *base, u32 offset, u32 val);
|
||||
+u32 airoha_rmw(void __iomem *base, u32 offset, u32 mask, u32 val);
|
||||
+
|
||||
+#define airoha_fe_rr(eth, offset) \
|
||||
+ airoha_rr((eth)->fe_regs, (offset))
|
||||
+#define airoha_fe_wr(eth, offset, val) \
|
||||
+ airoha_wr((eth)->fe_regs, (offset), (val))
|
||||
+#define airoha_fe_rmw(eth, offset, mask, val) \
|
||||
+ airoha_rmw((eth)->fe_regs, (offset), (mask), (val))
|
||||
+#define airoha_fe_set(eth, offset, val) \
|
||||
+ airoha_rmw((eth)->fe_regs, (offset), 0, (val))
|
||||
+#define airoha_fe_clear(eth, offset, val) \
|
||||
+ airoha_rmw((eth)->fe_regs, (offset), (val), 0)
|
||||
+
|
||||
+#define airoha_qdma_rr(qdma, offset) \
|
||||
+ airoha_rr((qdma)->regs, (offset))
|
||||
+#define airoha_qdma_wr(qdma, offset, val) \
|
||||
+ airoha_wr((qdma)->regs, (offset), (val))
|
||||
+#define airoha_qdma_rmw(qdma, offset, mask, val) \
|
||||
+ airoha_rmw((qdma)->regs, (offset), (mask), (val))
|
||||
+#define airoha_qdma_set(qdma, offset, val) \
|
||||
+ airoha_rmw((qdma)->regs, (offset), 0, (val))
|
||||
+#define airoha_qdma_clear(qdma, offset, val) \
|
||||
+ airoha_rmw((qdma)->regs, (offset), (val), 0)
|
||||
+
|
||||
#endif /* AIROHA_ETH_H */
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,287 +0,0 @@
|
||||
From af3cf757d5c99011b9b94ea8d78aeaccc0153fdc Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:13 +0100
|
||||
Subject: [PATCH 05/15] net: airoha: Move DSA tag in DMA descriptor
|
||||
|
||||
Packet Processor Engine (PPE) module reads DSA tags from the DMA descriptor
|
||||
and requires untagged DSA packets to properly parse them. Move DSA tag
|
||||
in the DMA descriptor on TX side and read DSA tag from DMA descriptor
|
||||
on RX side. In order to avoid skb reallocation, store tag in skb_dst on
|
||||
RX side.
|
||||
This is a preliminary patch to enable netfilter flowtable hw offloading
|
||||
on EN7581 SoC.
|
||||
|
||||
Tested-by: Sayantan Nandy <sayantan.nandy@airoha.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 125 ++++++++++++++++++++--
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 7 ++
|
||||
drivers/net/ethernet/airoha/airoha_regs.h | 2 +
|
||||
3 files changed, 128 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/u64_stats_sync.h>
|
||||
#include <net/dsa.h>
|
||||
+#include <net/dst_metadata.h>
|
||||
#include <net/page_pool/helpers.h>
|
||||
#include <net/pkt_cls.h>
|
||||
#include <uapi/linux/ppp_defs.h>
|
||||
@@ -656,6 +657,7 @@ static int airoha_qdma_rx_process(struct
|
||||
struct airoha_qdma_desc *desc = &q->desc[q->tail];
|
||||
dma_addr_t dma_addr = le32_to_cpu(desc->addr);
|
||||
u32 desc_ctrl = le32_to_cpu(desc->ctrl);
|
||||
+ struct airoha_gdm_port *port;
|
||||
struct sk_buff *skb;
|
||||
int len, p;
|
||||
|
||||
@@ -683,6 +685,7 @@ static int airoha_qdma_rx_process(struct
|
||||
continue;
|
||||
}
|
||||
|
||||
+ port = eth->ports[p];
|
||||
skb = napi_build_skb(e->buf, q->buf_size);
|
||||
if (!skb) {
|
||||
page_pool_put_full_page(q->page_pool,
|
||||
@@ -694,10 +697,26 @@ static int airoha_qdma_rx_process(struct
|
||||
skb_reserve(skb, 2);
|
||||
__skb_put(skb, len);
|
||||
skb_mark_for_recycle(skb);
|
||||
- skb->dev = eth->ports[p]->dev;
|
||||
+ skb->dev = port->dev;
|
||||
skb->protocol = eth_type_trans(skb, skb->dev);
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
skb_record_rx_queue(skb, qid);
|
||||
+
|
||||
+ if (netdev_uses_dsa(port->dev)) {
|
||||
+ /* PPE module requires untagged packets to work
|
||||
+ * properly and it provides DSA port index via the
|
||||
+ * DMA descriptor. Report DSA tag to the DSA stack
|
||||
+ * via skb dst info.
|
||||
+ */
|
||||
+ u32 sptag = FIELD_GET(QDMA_ETH_RXMSG_SPTAG,
|
||||
+ le32_to_cpu(desc->msg0));
|
||||
+
|
||||
+ if (sptag < ARRAY_SIZE(port->dsa_meta) &&
|
||||
+ port->dsa_meta[sptag])
|
||||
+ skb_dst_set_noref(skb,
|
||||
+ &port->dsa_meta[sptag]->dst);
|
||||
+ }
|
||||
+
|
||||
napi_gro_receive(&q->napi, skb);
|
||||
|
||||
done++;
|
||||
@@ -1657,25 +1676,76 @@ static u16 airoha_dev_select_queue(struc
|
||||
return queue < dev->num_tx_queues ? queue : 0;
|
||||
}
|
||||
|
||||
+static u32 airoha_get_dsa_tag(struct sk_buff *skb, struct net_device *dev)
|
||||
+{
|
||||
+#if IS_ENABLED(CONFIG_NET_DSA)
|
||||
+ struct ethhdr *ehdr;
|
||||
+ struct dsa_port *dp;
|
||||
+ u8 xmit_tpid;
|
||||
+ u16 tag;
|
||||
+
|
||||
+ if (!netdev_uses_dsa(dev))
|
||||
+ return 0;
|
||||
+
|
||||
+ dp = dev->dsa_ptr;
|
||||
+ if (IS_ERR(dp))
|
||||
+ return 0;
|
||||
+
|
||||
+ if (dp->tag_ops->proto != DSA_TAG_PROTO_MTK)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (skb_cow_head(skb, 0))
|
||||
+ return 0;
|
||||
+
|
||||
+ ehdr = (struct ethhdr *)skb->data;
|
||||
+ tag = be16_to_cpu(ehdr->h_proto);
|
||||
+ xmit_tpid = tag >> 8;
|
||||
+
|
||||
+ switch (xmit_tpid) {
|
||||
+ case MTK_HDR_XMIT_TAGGED_TPID_8100:
|
||||
+ ehdr->h_proto = cpu_to_be16(ETH_P_8021Q);
|
||||
+ tag &= ~(MTK_HDR_XMIT_TAGGED_TPID_8100 << 8);
|
||||
+ break;
|
||||
+ case MTK_HDR_XMIT_TAGGED_TPID_88A8:
|
||||
+ ehdr->h_proto = cpu_to_be16(ETH_P_8021AD);
|
||||
+ tag &= ~(MTK_HDR_XMIT_TAGGED_TPID_88A8 << 8);
|
||||
+ break;
|
||||
+ default:
|
||||
+ /* PPE module requires untagged DSA packets to work properly,
|
||||
+ * so move DSA tag to DMA descriptor.
|
||||
+ */
|
||||
+ memmove(skb->data + MTK_HDR_LEN, skb->data, 2 * ETH_ALEN);
|
||||
+ __skb_pull(skb, MTK_HDR_LEN);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return tag;
|
||||
+#else
|
||||
+ return 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
- u32 nr_frags = 1 + skb_shinfo(skb)->nr_frags;
|
||||
- u32 msg0, msg1, len = skb_headlen(skb);
|
||||
struct airoha_qdma *qdma = port->qdma;
|
||||
+ u32 nr_frags, tag, msg0, msg1, len;
|
||||
struct netdev_queue *txq;
|
||||
struct airoha_queue *q;
|
||||
- void *data = skb->data;
|
||||
+ void *data;
|
||||
int i, qid;
|
||||
u16 index;
|
||||
u8 fport;
|
||||
|
||||
qid = skb_get_queue_mapping(skb) % ARRAY_SIZE(qdma->q_tx);
|
||||
+ tag = airoha_get_dsa_tag(skb, dev);
|
||||
+
|
||||
msg0 = FIELD_PREP(QDMA_ETH_TXMSG_CHAN_MASK,
|
||||
qid / AIROHA_NUM_QOS_QUEUES) |
|
||||
FIELD_PREP(QDMA_ETH_TXMSG_QUEUE_MASK,
|
||||
- qid % AIROHA_NUM_QOS_QUEUES);
|
||||
+ qid % AIROHA_NUM_QOS_QUEUES) |
|
||||
+ FIELD_PREP(QDMA_ETH_TXMSG_SP_TAG_MASK, tag);
|
||||
if (skb->ip_summed == CHECKSUM_PARTIAL)
|
||||
msg0 |= FIELD_PREP(QDMA_ETH_TXMSG_TCO_MASK, 1) |
|
||||
FIELD_PREP(QDMA_ETH_TXMSG_UCO_MASK, 1) |
|
||||
@@ -1706,6 +1776,8 @@ static netdev_tx_t airoha_dev_xmit(struc
|
||||
spin_lock_bh(&q->lock);
|
||||
|
||||
txq = netdev_get_tx_queue(dev, qid);
|
||||
+ nr_frags = 1 + skb_shinfo(skb)->nr_frags;
|
||||
+
|
||||
if (q->queued + nr_frags > q->ndesc) {
|
||||
/* not enough space in the queue */
|
||||
netif_tx_stop_queue(txq);
|
||||
@@ -1713,7 +1785,10 @@ static netdev_tx_t airoha_dev_xmit(struc
|
||||
return NETDEV_TX_BUSY;
|
||||
}
|
||||
|
||||
+ len = skb_headlen(skb);
|
||||
+ data = skb->data;
|
||||
index = q->head;
|
||||
+
|
||||
for (i = 0; i < nr_frags; i++) {
|
||||
struct airoha_qdma_desc *desc = &q->desc[index];
|
||||
struct airoha_queue_entry *e = &q->entry[index];
|
||||
@@ -2244,6 +2319,37 @@ static const struct ethtool_ops airoha_e
|
||||
.get_rmon_stats = airoha_ethtool_get_rmon_stats,
|
||||
};
|
||||
|
||||
+static int airoha_metadata_dst_alloc(struct airoha_gdm_port *port)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(port->dsa_meta); i++) {
|
||||
+ struct metadata_dst *md_dst;
|
||||
+
|
||||
+ md_dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX,
|
||||
+ GFP_KERNEL);
|
||||
+ if (!md_dst)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ md_dst->u.port_info.port_id = i;
|
||||
+ port->dsa_meta[i] = md_dst;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void airoha_metadata_dst_free(struct airoha_gdm_port *port)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(port->dsa_meta); i++) {
|
||||
+ if (!port->dsa_meta[i])
|
||||
+ continue;
|
||||
+
|
||||
+ metadata_dst_free(port->dsa_meta[i]);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
|
||||
{
|
||||
const __be32 *id_ptr = of_get_property(np, "reg", NULL);
|
||||
@@ -2316,6 +2422,10 @@ static int airoha_alloc_gdm_port(struct
|
||||
port->id = id;
|
||||
eth->ports[index] = port;
|
||||
|
||||
+ err = airoha_metadata_dst_alloc(port);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
return register_netdev(dev);
|
||||
}
|
||||
|
||||
@@ -2408,8 +2518,10 @@ error_hw_cleanup:
|
||||
for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
|
||||
struct airoha_gdm_port *port = eth->ports[i];
|
||||
|
||||
- if (port && port->dev->reg_state == NETREG_REGISTERED)
|
||||
+ if (port && port->dev->reg_state == NETREG_REGISTERED) {
|
||||
unregister_netdev(port->dev);
|
||||
+ airoha_metadata_dst_free(port);
|
||||
+ }
|
||||
}
|
||||
free_netdev(eth->napi_dev);
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
@@ -2434,6 +2546,7 @@ static void airoha_remove(struct platfor
|
||||
continue;
|
||||
|
||||
unregister_netdev(port->dev);
|
||||
+ airoha_metadata_dst_free(port);
|
||||
}
|
||||
free_netdev(eth->napi_dev);
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#define AIROHA_MAX_NUM_GDM_PORTS 1
|
||||
#define AIROHA_MAX_NUM_QDMA 2
|
||||
+#define AIROHA_MAX_DSA_PORTS 7
|
||||
#define AIROHA_MAX_NUM_RSTS 3
|
||||
#define AIROHA_MAX_NUM_XSI_RSTS 5
|
||||
#define AIROHA_MAX_MTU 2000
|
||||
@@ -43,6 +44,10 @@
|
||||
#define QDMA_METER_IDX(_n) ((_n) & 0xff)
|
||||
#define QDMA_METER_GROUP(_n) (((_n) >> 8) & 0x3)
|
||||
|
||||
+#define MTK_HDR_LEN 4
|
||||
+#define MTK_HDR_XMIT_TAGGED_TPID_8100 1
|
||||
+#define MTK_HDR_XMIT_TAGGED_TPID_88A8 2
|
||||
+
|
||||
enum {
|
||||
QDMA_INT_REG_IDX0,
|
||||
QDMA_INT_REG_IDX1,
|
||||
@@ -231,6 +236,8 @@ struct airoha_gdm_port {
|
||||
/* qos stats counters */
|
||||
u64 cpu_tx_packets;
|
||||
u64 fwd_tx_packets;
|
||||
+
|
||||
+ struct metadata_dst *dsa_meta[AIROHA_MAX_DSA_PORTS];
|
||||
};
|
||||
|
||||
struct airoha_eth {
|
||||
--- a/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
@@ -624,6 +624,8 @@
|
||||
#define QDMA_ETH_TXMSG_ACNT_G1_MASK GENMASK(10, 6) /* 0x1f do not count */
|
||||
#define QDMA_ETH_TXMSG_ACNT_G0_MASK GENMASK(5, 0) /* 0x3f do not count */
|
||||
|
||||
+/* RX MSG0 */
|
||||
+#define QDMA_ETH_RXMSG_SPTAG GENMASK(21, 14)
|
||||
/* RX MSG1 */
|
||||
#define QDMA_ETH_RXMSG_DEI_MASK BIT(31)
|
||||
#define QDMA_ETH_RXMSG_IP6_MASK BIT(30)
|
||||
@ -1,46 +0,0 @@
|
||||
From ab667db1e6014634c6607ebdddc16c1b8394a935 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:14 +0100
|
||||
Subject: [PATCH 06/15] net: dsa: mt7530: Enable Rx sptag for EN7581 SoC
|
||||
|
||||
Packet Processor Engine (PPE) module used for hw acceleration on EN7581
|
||||
mac block, in order to properly parse packets, requires DSA untagged
|
||||
packets on TX side and read DSA tag from DMA descriptor on RX side.
|
||||
For this reason, enable RX Special Tag (SPTAG) for EN7581 SoC.
|
||||
This is a preliminary patch to enable netfilter flowtable hw offloading
|
||||
on EN7581 SoC.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 5 +++++
|
||||
drivers/net/dsa/mt7530.h | 4 ++++
|
||||
2 files changed, 9 insertions(+)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2599,6 +2599,11 @@ mt7531_setup_common(struct dsa_switch *d
|
||||
/* Allow mirroring frames received on the local port (monitor port). */
|
||||
mt7530_set(priv, MT753X_AGC, LOCAL_EN);
|
||||
|
||||
+ /* Enable Special Tag for rx frames */
|
||||
+ if (priv->id == ID_EN7581)
|
||||
+ mt7530_write(priv, MT753X_CPORT_SPTAG_CFG,
|
||||
+ CPORT_SW2FE_STAG_EN | CPORT_FE2SW_STAG_EN);
|
||||
+
|
||||
/* Flush the FDB table */
|
||||
ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
|
||||
if (ret < 0)
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -615,6 +615,10 @@ enum mt7531_xtal_fsel {
|
||||
#define MT7531_GPIO12_RG_RXD3_MASK GENMASK(19, 16)
|
||||
#define MT7531_EXT_P_MDIO_12 (2 << 16)
|
||||
|
||||
+#define MT753X_CPORT_SPTAG_CFG 0x7c10
|
||||
+#define CPORT_SW2FE_STAG_EN BIT(1)
|
||||
+#define CPORT_FE2SW_STAG_EN BIT(0)
|
||||
+
|
||||
/* Registers for LED GPIO control (MT7530 only)
|
||||
* All registers follow this pattern:
|
||||
* [ 2: 0] port 0
|
||||
@ -1,144 +0,0 @@
|
||||
From 80369686737fe07c233a1152da0b84372dabdcd6 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:15 +0100
|
||||
Subject: [PATCH 07/15] net: airoha: Enable support for multiple net_devices
|
||||
|
||||
In the current codebase airoha_eth driver supports just a single
|
||||
net_device connected to the Packet Switch Engine (PSE) lan port (GDM1).
|
||||
As shown in commit 23020f049327 ("net: airoha: Introduce ethernet
|
||||
support for EN7581 SoC"), PSE can switch packets between four GDM ports.
|
||||
Enable the capability to create a net_device for each GDM port of the
|
||||
PSE module. Moreover, since the QDMA blocks can be shared between
|
||||
net_devices, do not stop TX/RX DMA in airoha_dev_stop() if there are
|
||||
active net_devices for this QDMA block.
|
||||
This is a preliminary patch to enable flowtable hw offloading for EN7581
|
||||
SoC.
|
||||
|
||||
Co-developed-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 35 ++++++++++++++----------
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 4 ++-
|
||||
2 files changed, 24 insertions(+), 15 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -1583,6 +1583,7 @@ static int airoha_dev_open(struct net_de
|
||||
airoha_qdma_set(qdma, REG_QDMA_GLOBAL_CFG,
|
||||
GLOBAL_CFG_TX_DMA_EN_MASK |
|
||||
GLOBAL_CFG_RX_DMA_EN_MASK);
|
||||
+ atomic_inc(&qdma->users);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1598,16 +1599,20 @@ static int airoha_dev_stop(struct net_de
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- airoha_qdma_clear(qdma, REG_QDMA_GLOBAL_CFG,
|
||||
- GLOBAL_CFG_TX_DMA_EN_MASK |
|
||||
- GLOBAL_CFG_RX_DMA_EN_MASK);
|
||||
+ for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++)
|
||||
+ netdev_tx_reset_subqueue(dev, i);
|
||||
|
||||
- for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
|
||||
- if (!qdma->q_tx[i].ndesc)
|
||||
- continue;
|
||||
+ if (atomic_dec_and_test(&qdma->users)) {
|
||||
+ airoha_qdma_clear(qdma, REG_QDMA_GLOBAL_CFG,
|
||||
+ GLOBAL_CFG_TX_DMA_EN_MASK |
|
||||
+ GLOBAL_CFG_RX_DMA_EN_MASK);
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
|
||||
+ if (!qdma->q_tx[i].ndesc)
|
||||
+ continue;
|
||||
|
||||
- airoha_qdma_cleanup_tx_queue(&qdma->q_tx[i]);
|
||||
- netdev_tx_reset_subqueue(dev, i);
|
||||
+ airoha_qdma_cleanup_tx_queue(&qdma->q_tx[i]);
|
||||
+ }
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -2350,13 +2355,14 @@ static void airoha_metadata_dst_free(str
|
||||
}
|
||||
}
|
||||
|
||||
-static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
|
||||
+static int airoha_alloc_gdm_port(struct airoha_eth *eth,
|
||||
+ struct device_node *np, int index)
|
||||
{
|
||||
const __be32 *id_ptr = of_get_property(np, "reg", NULL);
|
||||
struct airoha_gdm_port *port;
|
||||
struct airoha_qdma *qdma;
|
||||
struct net_device *dev;
|
||||
- int err, index;
|
||||
+ int err, p;
|
||||
u32 id;
|
||||
|
||||
if (!id_ptr) {
|
||||
@@ -2365,14 +2371,14 @@ static int airoha_alloc_gdm_port(struct
|
||||
}
|
||||
|
||||
id = be32_to_cpup(id_ptr);
|
||||
- index = id - 1;
|
||||
+ p = id - 1;
|
||||
|
||||
if (!id || id > ARRAY_SIZE(eth->ports)) {
|
||||
dev_err(eth->dev, "invalid gdm port id: %d\n", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- if (eth->ports[index]) {
|
||||
+ if (eth->ports[p]) {
|
||||
dev_err(eth->dev, "duplicate gdm port id: %d\n", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -2420,7 +2426,7 @@ static int airoha_alloc_gdm_port(struct
|
||||
port->qdma = qdma;
|
||||
port->dev = dev;
|
||||
port->id = id;
|
||||
- eth->ports[index] = port;
|
||||
+ eth->ports[p] = port;
|
||||
|
||||
err = airoha_metadata_dst_alloc(port);
|
||||
if (err)
|
||||
@@ -2492,6 +2498,7 @@ static int airoha_probe(struct platform_
|
||||
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
|
||||
airoha_qdma_start_napi(ð->qdma[i]);
|
||||
|
||||
+ i = 0;
|
||||
for_each_child_of_node(pdev->dev.of_node, np) {
|
||||
if (!of_device_is_compatible(np, "airoha,eth-mac"))
|
||||
continue;
|
||||
@@ -2499,7 +2506,7 @@ static int airoha_probe(struct platform_
|
||||
if (!of_device_is_available(np))
|
||||
continue;
|
||||
|
||||
- err = airoha_alloc_gdm_port(eth, np);
|
||||
+ err = airoha_alloc_gdm_port(eth, np, i++);
|
||||
if (err) {
|
||||
of_node_put(np);
|
||||
goto error_napi_stop;
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/reset.h>
|
||||
|
||||
-#define AIROHA_MAX_NUM_GDM_PORTS 1
|
||||
+#define AIROHA_MAX_NUM_GDM_PORTS 4
|
||||
#define AIROHA_MAX_NUM_QDMA 2
|
||||
#define AIROHA_MAX_DSA_PORTS 7
|
||||
#define AIROHA_MAX_NUM_RSTS 3
|
||||
@@ -212,6 +212,8 @@ struct airoha_qdma {
|
||||
u32 irqmask[QDMA_INT_REG_MAX];
|
||||
int irq;
|
||||
|
||||
+ atomic_t users;
|
||||
+
|
||||
struct airoha_tx_irq_queue q_tx_irq[AIROHA_NUM_TX_IRQ];
|
||||
|
||||
struct airoha_queue q_tx[AIROHA_NUM_TX_RING];
|
||||
@ -1,77 +0,0 @@
|
||||
From 67fde5d58cd43d129a979e918ec9cd5d2e2fbcfb Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:16 +0100
|
||||
Subject: [PATCH 08/15] net: airoha: Move REG_GDM_FWD_CFG() initialization in
|
||||
airoha_dev_init()
|
||||
|
||||
Move REG_GDM_FWD_CFG() register initialization in airoha_dev_init
|
||||
routine. Moreover, always send traffic PPE module in order to be
|
||||
processed by hw accelerator.
|
||||
This is a preliminary patch to enable netfilter flowtable hw offloading
|
||||
on EN7581 SoC.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 14 ++++----------
|
||||
1 file changed, 4 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -107,25 +107,20 @@ static void airoha_set_gdm_port_fwd_cfg(
|
||||
|
||||
static int airoha_set_gdm_port(struct airoha_eth *eth, int port, bool enable)
|
||||
{
|
||||
- u32 val = enable ? FE_PSE_PORT_PPE1 : FE_PSE_PORT_DROP;
|
||||
- u32 vip_port, cfg_addr;
|
||||
+ u32 vip_port;
|
||||
|
||||
switch (port) {
|
||||
case XSI_PCIE0_PORT:
|
||||
vip_port = XSI_PCIE0_VIP_PORT_MASK;
|
||||
- cfg_addr = REG_GDM_FWD_CFG(3);
|
||||
break;
|
||||
case XSI_PCIE1_PORT:
|
||||
vip_port = XSI_PCIE1_VIP_PORT_MASK;
|
||||
- cfg_addr = REG_GDM_FWD_CFG(3);
|
||||
break;
|
||||
case XSI_USB_PORT:
|
||||
vip_port = XSI_USB_VIP_PORT_MASK;
|
||||
- cfg_addr = REG_GDM_FWD_CFG(4);
|
||||
break;
|
||||
case XSI_ETH_PORT:
|
||||
vip_port = XSI_ETH_VIP_PORT_MASK;
|
||||
- cfg_addr = REG_GDM_FWD_CFG(4);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
@@ -139,8 +134,6 @@ static int airoha_set_gdm_port(struct ai
|
||||
airoha_fe_clear(eth, REG_FE_IFC_PORT_EN, vip_port);
|
||||
}
|
||||
|
||||
- airoha_set_gdm_port_fwd_cfg(eth, cfg_addr, val);
|
||||
-
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -177,8 +170,6 @@ static void airoha_fe_maccr_init(struct
|
||||
airoha_fe_set(eth, REG_GDM_FWD_CFG(p),
|
||||
GDM_TCP_CKSUM | GDM_UDP_CKSUM | GDM_IP4_CKSUM |
|
||||
GDM_DROP_CRC_ERR);
|
||||
- airoha_set_gdm_port_fwd_cfg(eth, REG_GDM_FWD_CFG(p),
|
||||
- FE_PSE_PORT_CDM1);
|
||||
airoha_fe_rmw(eth, REG_GDM_LEN_CFG(p),
|
||||
GDM_SHORT_LEN_MASK | GDM_LONG_LEN_MASK,
|
||||
FIELD_PREP(GDM_SHORT_LEN_MASK, 60) |
|
||||
@@ -1635,8 +1626,11 @@ static int airoha_dev_set_macaddr(struct
|
||||
static int airoha_dev_init(struct net_device *dev)
|
||||
{
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
+ struct airoha_eth *eth = port->qdma->eth;
|
||||
|
||||
airoha_set_macaddr(port, dev->dev_addr);
|
||||
+ airoha_set_gdm_port_fwd_cfg(eth, REG_GDM_FWD_CFG(port->id),
|
||||
+ FE_PSE_PORT_PPE1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,120 +0,0 @@
|
||||
From c28b8375f6d02ef3b5e8c51234cc3f6d47d9fb7f Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:17 +0100
|
||||
Subject: [PATCH 09/15] net: airoha: Rename airoha_set_gdm_port_fwd_cfg() in
|
||||
airoha_set_vip_for_gdm_port()
|
||||
|
||||
Rename airoha_set_gdm_port() in airoha_set_vip_for_gdm_port().
|
||||
Get rid of airoha_set_gdm_ports routine.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 49 ++++++------------------
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 8 ----
|
||||
2 files changed, 11 insertions(+), 46 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -105,25 +105,23 @@ static void airoha_set_gdm_port_fwd_cfg(
|
||||
FIELD_PREP(GDM_UCFQ_MASK, val));
|
||||
}
|
||||
|
||||
-static int airoha_set_gdm_port(struct airoha_eth *eth, int port, bool enable)
|
||||
+static int airoha_set_vip_for_gdm_port(struct airoha_gdm_port *port,
|
||||
+ bool enable)
|
||||
{
|
||||
+ struct airoha_eth *eth = port->qdma->eth;
|
||||
u32 vip_port;
|
||||
|
||||
- switch (port) {
|
||||
- case XSI_PCIE0_PORT:
|
||||
+ switch (port->id) {
|
||||
+ case 3:
|
||||
+ /* FIXME: handle XSI_PCIE1_PORT */
|
||||
vip_port = XSI_PCIE0_VIP_PORT_MASK;
|
||||
break;
|
||||
- case XSI_PCIE1_PORT:
|
||||
- vip_port = XSI_PCIE1_VIP_PORT_MASK;
|
||||
- break;
|
||||
- case XSI_USB_PORT:
|
||||
- vip_port = XSI_USB_VIP_PORT_MASK;
|
||||
- break;
|
||||
- case XSI_ETH_PORT:
|
||||
+ case 4:
|
||||
+ /* FIXME: handle XSI_USB_PORT */
|
||||
vip_port = XSI_ETH_VIP_PORT_MASK;
|
||||
break;
|
||||
default:
|
||||
- return -EINVAL;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
if (enable) {
|
||||
@@ -137,31 +135,6 @@ static int airoha_set_gdm_port(struct ai
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int airoha_set_gdm_ports(struct airoha_eth *eth, bool enable)
|
||||
-{
|
||||
- const int port_list[] = {
|
||||
- XSI_PCIE0_PORT,
|
||||
- XSI_PCIE1_PORT,
|
||||
- XSI_USB_PORT,
|
||||
- XSI_ETH_PORT
|
||||
- };
|
||||
- int i, err;
|
||||
-
|
||||
- for (i = 0; i < ARRAY_SIZE(port_list); i++) {
|
||||
- err = airoha_set_gdm_port(eth, port_list[i], enable);
|
||||
- if (err)
|
||||
- goto error;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-
|
||||
-error:
|
||||
- for (i--; i >= 0; i--)
|
||||
- airoha_set_gdm_port(eth, port_list[i], false);
|
||||
-
|
||||
- return err;
|
||||
-}
|
||||
-
|
||||
static void airoha_fe_maccr_init(struct airoha_eth *eth)
|
||||
{
|
||||
int p;
|
||||
@@ -1560,7 +1533,7 @@ static int airoha_dev_open(struct net_de
|
||||
int err;
|
||||
|
||||
netif_tx_start_all_queues(dev);
|
||||
- err = airoha_set_gdm_ports(qdma->eth, true);
|
||||
+ err = airoha_set_vip_for_gdm_port(port, true);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -1586,7 +1559,7 @@ static int airoha_dev_stop(struct net_de
|
||||
int i, err;
|
||||
|
||||
netif_tx_disable(dev);
|
||||
- err = airoha_set_gdm_ports(qdma->eth, false);
|
||||
+ err = airoha_set_vip_for_gdm_port(port, false);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -58,14 +58,6 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
- XSI_PCIE0_PORT,
|
||||
- XSI_PCIE1_PORT,
|
||||
- XSI_USB_PORT,
|
||||
- XSI_AE_PORT,
|
||||
- XSI_ETH_PORT,
|
||||
-};
|
||||
-
|
||||
-enum {
|
||||
XSI_PCIE0_VIP_PORT_MASK = BIT(22),
|
||||
XSI_PCIE1_VIP_PORT_MASK = BIT(23),
|
||||
XSI_USB_VIP_PORT_MASK = BIT(25),
|
||||
@ -1,627 +0,0 @@
|
||||
From 23290c7bc190def4e1ca61610992d9b7c32e33f3 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:20 +0100
|
||||
Subject: [PATCH 12/15] net: airoha: Introduce Airoha NPU support
|
||||
|
||||
Packet Processor Engine (PPE) module available on EN7581 SoC populates
|
||||
the PPE table with 5-tuples flower rules learned from traffic forwarded
|
||||
between the GDM ports connected to the Packet Switch Engine (PSE) module.
|
||||
The airoha_eth driver can enable hw acceleration of learned 5-tuples
|
||||
rules if the user configure them in netfilter flowtable (netfilter
|
||||
flowtable support will be added with subsequent patches).
|
||||
airoha_eth driver configures and collects data from the PPE module via a
|
||||
Network Processor Unit (NPU) RISC-V module available on the EN7581 SoC.
|
||||
Introduce basic support for Airoha NPU module.
|
||||
|
||||
Tested-by: Sayantan Nandy <sayantan.nandy@airoha.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/Kconfig | 9 +
|
||||
drivers/net/ethernet/airoha/Makefile | 1 +
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 2 +
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 520 +++++++++++++++++++++++
|
||||
drivers/net/ethernet/airoha/airoha_npu.h | 34 ++
|
||||
5 files changed, 566 insertions(+)
|
||||
create mode 100644 drivers/net/ethernet/airoha/airoha_npu.c
|
||||
create mode 100644 drivers/net/ethernet/airoha/airoha_npu.h
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/Kconfig
|
||||
+++ b/drivers/net/ethernet/airoha/Kconfig
|
||||
@@ -7,9 +7,18 @@ config NET_VENDOR_AIROHA
|
||||
|
||||
if NET_VENDOR_AIROHA
|
||||
|
||||
+config NET_AIROHA_NPU
|
||||
+ tristate "Airoha NPU support"
|
||||
+ select WANT_DEV_COREDUMP
|
||||
+ select REGMAP_MMIO
|
||||
+ help
|
||||
+ This driver supports Airoha Network Processor (NPU) available
|
||||
+ on the Airoha Soc family.
|
||||
+
|
||||
config NET_AIROHA
|
||||
tristate "Airoha SoC Gigabit Ethernet support"
|
||||
depends on NET_DSA || !NET_DSA
|
||||
+ select NET_AIROHA_NPU
|
||||
select PAGE_POOL
|
||||
help
|
||||
This driver supports the gigabit ethernet MACs in the
|
||||
--- a/drivers/net/ethernet/airoha/Makefile
|
||||
+++ b/drivers/net/ethernet/airoha/Makefile
|
||||
@@ -4,3 +4,4 @@
|
||||
#
|
||||
|
||||
obj-$(CONFIG_NET_AIROHA) += airoha_eth.o
|
||||
+obj-$(CONFIG_NET_AIROHA_NPU) += airoha_npu.o
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -240,6 +240,8 @@ struct airoha_eth {
|
||||
unsigned long state;
|
||||
void __iomem *fe_regs;
|
||||
|
||||
+ struct airoha_npu __rcu *npu;
|
||||
+
|
||||
struct reset_control_bulk_data rsts[AIROHA_MAX_NUM_RSTS];
|
||||
struct reset_control_bulk_data xsi_rsts[AIROHA_MAX_NUM_XSI_RSTS];
|
||||
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -0,0 +1,520 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-only
|
||||
+/*
|
||||
+ * Copyright (c) 2025 AIROHA Inc
|
||||
+ * Author: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/devcoredump.h>
|
||||
+#include <linux/firmware.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/of_net.h>
|
||||
+#include <linux/of_platform.h>
|
||||
+#include <linux/of_reserved_mem.h>
|
||||
+#include <linux/regmap.h>
|
||||
+
|
||||
+#include "airoha_npu.h"
|
||||
+
|
||||
+#define NPU_EN7581_FIRMWARE_DATA "airoha/en7581_npu_data.bin"
|
||||
+#define NPU_EN7581_FIRMWARE_RV32 "airoha/en7581_npu_rv32.bin"
|
||||
+#define NPU_EN7581_FIRMWARE_RV32_MAX_SIZE 0x200000
|
||||
+#define NPU_EN7581_FIRMWARE_DATA_MAX_SIZE 0x10000
|
||||
+#define NPU_DUMP_SIZE 512
|
||||
+
|
||||
+#define REG_NPU_LOCAL_SRAM 0x0
|
||||
+
|
||||
+#define NPU_PC_BASE_ADDR 0x305000
|
||||
+#define REG_PC_DBG(_n) (0x305000 + ((_n) * 0x100))
|
||||
+
|
||||
+#define NPU_CLUSTER_BASE_ADDR 0x306000
|
||||
+
|
||||
+#define REG_CR_BOOT_TRIGGER (NPU_CLUSTER_BASE_ADDR + 0x000)
|
||||
+#define REG_CR_BOOT_CONFIG (NPU_CLUSTER_BASE_ADDR + 0x004)
|
||||
+#define REG_CR_BOOT_BASE(_n) (NPU_CLUSTER_BASE_ADDR + 0x020 + ((_n) << 2))
|
||||
+
|
||||
+#define NPU_MBOX_BASE_ADDR 0x30c000
|
||||
+
|
||||
+#define REG_CR_MBOX_INT_STATUS (NPU_MBOX_BASE_ADDR + 0x000)
|
||||
+#define MBOX_INT_STATUS_MASK BIT(8)
|
||||
+
|
||||
+#define REG_CR_MBOX_INT_MASK(_n) (NPU_MBOX_BASE_ADDR + 0x004 + ((_n) << 2))
|
||||
+#define REG_CR_MBQ0_CTRL(_n) (NPU_MBOX_BASE_ADDR + 0x030 + ((_n) << 2))
|
||||
+#define REG_CR_MBQ8_CTRL(_n) (NPU_MBOX_BASE_ADDR + 0x0b0 + ((_n) << 2))
|
||||
+#define REG_CR_NPU_MIB(_n) (NPU_MBOX_BASE_ADDR + 0x140 + ((_n) << 2))
|
||||
+
|
||||
+#define NPU_TIMER_BASE_ADDR 0x310100
|
||||
+#define REG_WDT_TIMER_CTRL(_n) (NPU_TIMER_BASE_ADDR + ((_n) * 0x100))
|
||||
+#define WDT_EN_MASK BIT(25)
|
||||
+#define WDT_INTR_MASK BIT(21)
|
||||
+
|
||||
+enum {
|
||||
+ NPU_OP_SET = 1,
|
||||
+ NPU_OP_SET_NO_WAIT,
|
||||
+ NPU_OP_GET,
|
||||
+ NPU_OP_GET_NO_WAIT,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ NPU_FUNC_WIFI,
|
||||
+ NPU_FUNC_TUNNEL,
|
||||
+ NPU_FUNC_NOTIFY,
|
||||
+ NPU_FUNC_DBA,
|
||||
+ NPU_FUNC_TR471,
|
||||
+ NPU_FUNC_PPE,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ NPU_MBOX_ERROR,
|
||||
+ NPU_MBOX_SUCCESS,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ PPE_FUNC_SET_WAIT,
|
||||
+ PPE_FUNC_SET_WAIT_HWNAT_INIT,
|
||||
+ PPE_FUNC_SET_WAIT_HWNAT_DEINIT,
|
||||
+ PPE_FUNC_SET_WAIT_API,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ PPE2_SRAM_SET_ENTRY,
|
||||
+ PPE_SRAM_SET_ENTRY,
|
||||
+ PPE_SRAM_SET_VAL,
|
||||
+ PPE_SRAM_RESET_VAL,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ QDMA_WAN_ETHER = 1,
|
||||
+ QDMA_WAN_PON_XDSL,
|
||||
+};
|
||||
+
|
||||
+#define MBOX_MSG_FUNC_ID GENMASK(14, 11)
|
||||
+#define MBOX_MSG_STATIC_BUF BIT(5)
|
||||
+#define MBOX_MSG_STATUS GENMASK(4, 2)
|
||||
+#define MBOX_MSG_DONE BIT(1)
|
||||
+#define MBOX_MSG_WAIT_RSP BIT(0)
|
||||
+
|
||||
+#define PPE_TYPE_L2B_IPV4 2
|
||||
+#define PPE_TYPE_L2B_IPV4_IPV6 3
|
||||
+
|
||||
+struct ppe_mbox_data {
|
||||
+ u32 func_type;
|
||||
+ u32 func_id;
|
||||
+ union {
|
||||
+ struct {
|
||||
+ u8 cds;
|
||||
+ u8 xpon_hal_api;
|
||||
+ u8 wan_xsi;
|
||||
+ u8 ct_joyme4;
|
||||
+ int ppe_type;
|
||||
+ int wan_mode;
|
||||
+ int wan_sel;
|
||||
+ } init_info;
|
||||
+ struct {
|
||||
+ int func_id;
|
||||
+ u32 size;
|
||||
+ u32 data;
|
||||
+ } set_info;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+static int airoha_npu_send_msg(struct airoha_npu *npu, int func_id,
|
||||
+ void *p, int size)
|
||||
+{
|
||||
+ u16 core = 0; /* FIXME */
|
||||
+ u32 val, offset = core << 4;
|
||||
+ dma_addr_t dma_addr;
|
||||
+ void *addr;
|
||||
+ int ret;
|
||||
+
|
||||
+ addr = kmemdup(p, size, GFP_ATOMIC);
|
||||
+ if (!addr)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ dma_addr = dma_map_single(npu->dev, addr, size, DMA_TO_DEVICE);
|
||||
+ ret = dma_mapping_error(npu->dev, dma_addr);
|
||||
+ if (ret)
|
||||
+ goto out;
|
||||
+
|
||||
+ spin_lock_bh(&npu->cores[core].lock);
|
||||
+
|
||||
+ regmap_write(npu->regmap, REG_CR_MBQ0_CTRL(0) + offset, dma_addr);
|
||||
+ regmap_write(npu->regmap, REG_CR_MBQ0_CTRL(1) + offset, size);
|
||||
+ regmap_read(npu->regmap, REG_CR_MBQ0_CTRL(2) + offset, &val);
|
||||
+ regmap_write(npu->regmap, REG_CR_MBQ0_CTRL(2) + offset, val + 1);
|
||||
+ val = FIELD_PREP(MBOX_MSG_FUNC_ID, func_id) | MBOX_MSG_WAIT_RSP;
|
||||
+ regmap_write(npu->regmap, REG_CR_MBQ0_CTRL(3) + offset, val);
|
||||
+
|
||||
+ ret = regmap_read_poll_timeout_atomic(npu->regmap,
|
||||
+ REG_CR_MBQ0_CTRL(3) + offset,
|
||||
+ val, (val & MBOX_MSG_DONE),
|
||||
+ 100, 100 * MSEC_PER_SEC);
|
||||
+ if (!ret && FIELD_GET(MBOX_MSG_STATUS, val) != NPU_MBOX_SUCCESS)
|
||||
+ ret = -EINVAL;
|
||||
+
|
||||
+ spin_unlock_bh(&npu->cores[core].lock);
|
||||
+
|
||||
+ dma_unmap_single(npu->dev, dma_addr, size, DMA_TO_DEVICE);
|
||||
+out:
|
||||
+ kfree(addr);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int airoha_npu_run_firmware(struct device *dev, void __iomem *base,
|
||||
+ struct reserved_mem *rmem)
|
||||
+{
|
||||
+ const struct firmware *fw;
|
||||
+ void __iomem *addr;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = request_firmware(&fw, NPU_EN7581_FIRMWARE_RV32, dev);
|
||||
+ if (ret)
|
||||
+ return ret == -ENOENT ? -EPROBE_DEFER : ret;
|
||||
+
|
||||
+ if (fw->size > NPU_EN7581_FIRMWARE_RV32_MAX_SIZE) {
|
||||
+ dev_err(dev, "%s: fw size too overlimit (%zu)\n",
|
||||
+ NPU_EN7581_FIRMWARE_RV32, fw->size);
|
||||
+ ret = -E2BIG;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ addr = devm_ioremap(dev, rmem->base, rmem->size);
|
||||
+ if (!addr) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ memcpy_toio(addr, fw->data, fw->size);
|
||||
+ release_firmware(fw);
|
||||
+
|
||||
+ ret = request_firmware(&fw, NPU_EN7581_FIRMWARE_DATA, dev);
|
||||
+ if (ret)
|
||||
+ return ret == -ENOENT ? -EPROBE_DEFER : ret;
|
||||
+
|
||||
+ if (fw->size > NPU_EN7581_FIRMWARE_DATA_MAX_SIZE) {
|
||||
+ dev_err(dev, "%s: fw size too overlimit (%zu)\n",
|
||||
+ NPU_EN7581_FIRMWARE_DATA, fw->size);
|
||||
+ ret = -E2BIG;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ memcpy_toio(base + REG_NPU_LOCAL_SRAM, fw->data, fw->size);
|
||||
+out:
|
||||
+ release_firmware(fw);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static irqreturn_t airoha_npu_mbox_handler(int irq, void *npu_instance)
|
||||
+{
|
||||
+ struct airoha_npu *npu = npu_instance;
|
||||
+
|
||||
+ /* clear mbox interrupt status */
|
||||
+ regmap_write(npu->regmap, REG_CR_MBOX_INT_STATUS,
|
||||
+ MBOX_INT_STATUS_MASK);
|
||||
+
|
||||
+ /* acknowledge npu */
|
||||
+ regmap_update_bits(npu->regmap, REG_CR_MBQ8_CTRL(3),
|
||||
+ MBOX_MSG_STATUS | MBOX_MSG_DONE, MBOX_MSG_DONE);
|
||||
+
|
||||
+ return IRQ_HANDLED;
|
||||
+}
|
||||
+
|
||||
+static void airoha_npu_wdt_work(struct work_struct *work)
|
||||
+{
|
||||
+ struct airoha_npu_core *core;
|
||||
+ struct airoha_npu *npu;
|
||||
+ void *dump;
|
||||
+ u32 val[3];
|
||||
+ int c;
|
||||
+
|
||||
+ core = container_of(work, struct airoha_npu_core, wdt_work);
|
||||
+ npu = core->npu;
|
||||
+
|
||||
+ dump = vzalloc(NPU_DUMP_SIZE);
|
||||
+ if (!dump)
|
||||
+ return;
|
||||
+
|
||||
+ c = core - &npu->cores[0];
|
||||
+ regmap_bulk_read(npu->regmap, REG_PC_DBG(c), val, ARRAY_SIZE(val));
|
||||
+ snprintf(dump, NPU_DUMP_SIZE, "PC: %08x SP: %08x LR: %08x\n",
|
||||
+ val[0], val[1], val[2]);
|
||||
+
|
||||
+ dev_coredumpv(npu->dev, dump, NPU_DUMP_SIZE, GFP_KERNEL);
|
||||
+}
|
||||
+
|
||||
+static irqreturn_t airoha_npu_wdt_handler(int irq, void *core_instance)
|
||||
+{
|
||||
+ struct airoha_npu_core *core = core_instance;
|
||||
+ struct airoha_npu *npu = core->npu;
|
||||
+ int c = core - &npu->cores[0];
|
||||
+ u32 val;
|
||||
+
|
||||
+ regmap_set_bits(npu->regmap, REG_WDT_TIMER_CTRL(c), WDT_INTR_MASK);
|
||||
+ if (!regmap_read(npu->regmap, REG_WDT_TIMER_CTRL(c), &val) &&
|
||||
+ FIELD_GET(WDT_EN_MASK, val))
|
||||
+ schedule_work(&core->wdt_work);
|
||||
+
|
||||
+ return IRQ_HANDLED;
|
||||
+}
|
||||
+
|
||||
+static int airoha_npu_ppe_init(struct airoha_npu *npu)
|
||||
+{
|
||||
+ struct ppe_mbox_data ppe_data = {
|
||||
+ .func_type = NPU_OP_SET,
|
||||
+ .func_id = PPE_FUNC_SET_WAIT_HWNAT_INIT,
|
||||
+ .init_info = {
|
||||
+ .ppe_type = PPE_TYPE_L2B_IPV4_IPV6,
|
||||
+ .wan_mode = QDMA_WAN_ETHER,
|
||||
+ },
|
||||
+ };
|
||||
+
|
||||
+ return airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
+ sizeof(struct ppe_mbox_data));
|
||||
+}
|
||||
+
|
||||
+static int airoha_npu_ppe_deinit(struct airoha_npu *npu)
|
||||
+{
|
||||
+ struct ppe_mbox_data ppe_data = {
|
||||
+ .func_type = NPU_OP_SET,
|
||||
+ .func_id = PPE_FUNC_SET_WAIT_HWNAT_DEINIT,
|
||||
+ };
|
||||
+
|
||||
+ return airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
+ sizeof(struct ppe_mbox_data));
|
||||
+}
|
||||
+
|
||||
+static int airoha_npu_ppe_flush_sram_entries(struct airoha_npu *npu,
|
||||
+ dma_addr_t foe_addr,
|
||||
+ int sram_num_entries)
|
||||
+{
|
||||
+ struct ppe_mbox_data ppe_data = {
|
||||
+ .func_type = NPU_OP_SET,
|
||||
+ .func_id = PPE_FUNC_SET_WAIT_API,
|
||||
+ .set_info = {
|
||||
+ .func_id = PPE_SRAM_RESET_VAL,
|
||||
+ .data = foe_addr,
|
||||
+ .size = sram_num_entries,
|
||||
+ },
|
||||
+ };
|
||||
+
|
||||
+ return airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
+ sizeof(struct ppe_mbox_data));
|
||||
+}
|
||||
+
|
||||
+static int airoha_npu_foe_commit_entry(struct airoha_npu *npu,
|
||||
+ dma_addr_t foe_addr,
|
||||
+ u32 entry_size, u32 hash, bool ppe2)
|
||||
+{
|
||||
+ struct ppe_mbox_data ppe_data = {
|
||||
+ .func_type = NPU_OP_SET,
|
||||
+ .func_id = PPE_FUNC_SET_WAIT_API,
|
||||
+ .set_info = {
|
||||
+ .data = foe_addr,
|
||||
+ .size = entry_size,
|
||||
+ },
|
||||
+ };
|
||||
+ int err;
|
||||
+
|
||||
+ ppe_data.set_info.func_id = ppe2 ? PPE2_SRAM_SET_ENTRY
|
||||
+ : PPE_SRAM_SET_ENTRY;
|
||||
+
|
||||
+ err = airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
+ sizeof(struct ppe_mbox_data));
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ ppe_data.set_info.func_id = PPE_SRAM_SET_VAL;
|
||||
+ ppe_data.set_info.data = hash;
|
||||
+ ppe_data.set_info.size = sizeof(u32);
|
||||
+
|
||||
+ return airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
+ sizeof(struct ppe_mbox_data));
|
||||
+}
|
||||
+
|
||||
+struct airoha_npu *airoha_npu_get(struct device *dev)
|
||||
+{
|
||||
+ struct platform_device *pdev;
|
||||
+ struct device_node *np;
|
||||
+ struct airoha_npu *npu;
|
||||
+
|
||||
+ np = of_parse_phandle(dev->of_node, "airoha,npu", 0);
|
||||
+ if (!np)
|
||||
+ return ERR_PTR(-ENODEV);
|
||||
+
|
||||
+ pdev = of_find_device_by_node(np);
|
||||
+ of_node_put(np);
|
||||
+
|
||||
+ if (!pdev) {
|
||||
+ dev_err(dev, "cannot find device node %s\n", np->name);
|
||||
+ return ERR_PTR(-ENODEV);
|
||||
+ }
|
||||
+
|
||||
+ if (!try_module_get(THIS_MODULE)) {
|
||||
+ dev_err(dev, "failed to get the device driver module\n");
|
||||
+ npu = ERR_PTR(-ENODEV);
|
||||
+ goto error_pdev_put;
|
||||
+ }
|
||||
+
|
||||
+ npu = platform_get_drvdata(pdev);
|
||||
+ if (!npu) {
|
||||
+ npu = ERR_PTR(-ENODEV);
|
||||
+ goto error_module_put;
|
||||
+ }
|
||||
+
|
||||
+ if (!device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER)) {
|
||||
+ dev_err(&pdev->dev,
|
||||
+ "failed to create device link to consumer %s\n",
|
||||
+ dev_name(dev));
|
||||
+ npu = ERR_PTR(-EINVAL);
|
||||
+ goto error_module_put;
|
||||
+ }
|
||||
+
|
||||
+ return npu;
|
||||
+
|
||||
+error_module_put:
|
||||
+ module_put(THIS_MODULE);
|
||||
+error_pdev_put:
|
||||
+ platform_device_put(pdev);
|
||||
+
|
||||
+ return npu;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(airoha_npu_get);
|
||||
+
|
||||
+void airoha_npu_put(struct airoha_npu *npu)
|
||||
+{
|
||||
+ module_put(THIS_MODULE);
|
||||
+ put_device(npu->dev);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(airoha_npu_put);
|
||||
+
|
||||
+static const struct of_device_id of_airoha_npu_match[] = {
|
||||
+ { .compatible = "airoha,en7581-npu" },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, of_airoha_npu_match);
|
||||
+
|
||||
+static const struct regmap_config regmap_config = {
|
||||
+ .name = "npu",
|
||||
+ .reg_bits = 32,
|
||||
+ .val_bits = 32,
|
||||
+ .reg_stride = 4,
|
||||
+ .disable_locking = true,
|
||||
+};
|
||||
+
|
||||
+static int airoha_npu_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct reserved_mem *rmem;
|
||||
+ struct airoha_npu *npu;
|
||||
+ struct device_node *np;
|
||||
+ void __iomem *base;
|
||||
+ int i, irq, err;
|
||||
+
|
||||
+ base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(base))
|
||||
+ return PTR_ERR(base);
|
||||
+
|
||||
+ npu = devm_kzalloc(dev, sizeof(*npu), GFP_KERNEL);
|
||||
+ if (!npu)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ npu->dev = dev;
|
||||
+ npu->ops.ppe_init = airoha_npu_ppe_init;
|
||||
+ npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
|
||||
+ npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
|
||||
+ npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
|
||||
+
|
||||
+ npu->regmap = devm_regmap_init_mmio(dev, base, ®map_config);
|
||||
+ if (IS_ERR(npu->regmap))
|
||||
+ return PTR_ERR(npu->regmap);
|
||||
+
|
||||
+ np = of_parse_phandle(dev->of_node, "memory-region", 0);
|
||||
+ if (!np)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ rmem = of_reserved_mem_lookup(np);
|
||||
+ of_node_put(np);
|
||||
+
|
||||
+ if (!rmem)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ irq = platform_get_irq(pdev, 0);
|
||||
+ if (irq < 0)
|
||||
+ return irq;
|
||||
+
|
||||
+ err = devm_request_irq(dev, irq, airoha_npu_mbox_handler,
|
||||
+ IRQF_SHARED, "airoha-npu-mbox", npu);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(npu->cores); i++) {
|
||||
+ struct airoha_npu_core *core = &npu->cores[i];
|
||||
+
|
||||
+ spin_lock_init(&core->lock);
|
||||
+ core->npu = npu;
|
||||
+
|
||||
+ irq = platform_get_irq(pdev, i + 1);
|
||||
+ if (irq < 0)
|
||||
+ return irq;
|
||||
+
|
||||
+ err = devm_request_irq(dev, irq, airoha_npu_wdt_handler,
|
||||
+ IRQF_SHARED, "airoha-npu-wdt", core);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ INIT_WORK(&core->wdt_work, airoha_npu_wdt_work);
|
||||
+ }
|
||||
+
|
||||
+ err = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = airoha_npu_run_firmware(dev, base, rmem);
|
||||
+ if (err)
|
||||
+ return dev_err_probe(dev, err, "failed to run npu firmware\n");
|
||||
+
|
||||
+ regmap_write(npu->regmap, REG_CR_NPU_MIB(10),
|
||||
+ rmem->base + NPU_EN7581_FIRMWARE_RV32_MAX_SIZE);
|
||||
+ regmap_write(npu->regmap, REG_CR_NPU_MIB(11), 0x40000); /* SRAM 256K */
|
||||
+ regmap_write(npu->regmap, REG_CR_NPU_MIB(12), 0);
|
||||
+ regmap_write(npu->regmap, REG_CR_NPU_MIB(21), 1);
|
||||
+ msleep(100);
|
||||
+
|
||||
+ /* setting booting address */
|
||||
+ for (i = 0; i < NPU_NUM_CORES; i++)
|
||||
+ regmap_write(npu->regmap, REG_CR_BOOT_BASE(i), rmem->base);
|
||||
+ usleep_range(1000, 2000);
|
||||
+
|
||||
+ /* enable NPU cores */
|
||||
+ /* do not start core3 since it is used for WiFi offloading */
|
||||
+ regmap_write(npu->regmap, REG_CR_BOOT_CONFIG, 0xf7);
|
||||
+ regmap_write(npu->regmap, REG_CR_BOOT_TRIGGER, 0x1);
|
||||
+ msleep(100);
|
||||
+
|
||||
+ platform_set_drvdata(pdev, npu);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void airoha_npu_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct airoha_npu *npu = platform_get_drvdata(pdev);
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(npu->cores); i++)
|
||||
+ cancel_work_sync(&npu->cores[i].wdt_work);
|
||||
+}
|
||||
+
|
||||
+static struct platform_driver airoha_npu_driver = {
|
||||
+ .probe = airoha_npu_probe,
|
||||
+ .remove_new = airoha_npu_remove,
|
||||
+ .driver = {
|
||||
+ .name = "airoha-npu",
|
||||
+ .of_match_table = of_airoha_npu_match,
|
||||
+ },
|
||||
+};
|
||||
+module_platform_driver(airoha_npu_driver);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
|
||||
+MODULE_DESCRIPTION("Airoha Network Processor Unit driver");
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
@@ -0,0 +1,34 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
+/*
|
||||
+ * Copyright (c) 2025 AIROHA Inc
|
||||
+ * Author: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
+ */
|
||||
+
|
||||
+#define NPU_NUM_CORES 8
|
||||
+
|
||||
+struct airoha_npu {
|
||||
+ struct device *dev;
|
||||
+ struct regmap *regmap;
|
||||
+
|
||||
+ struct airoha_npu_core {
|
||||
+ struct airoha_npu *npu;
|
||||
+ /* protect concurrent npu memory accesses */
|
||||
+ spinlock_t lock;
|
||||
+ struct work_struct wdt_work;
|
||||
+ } cores[NPU_NUM_CORES];
|
||||
+
|
||||
+ struct {
|
||||
+ int (*ppe_init)(struct airoha_npu *npu);
|
||||
+ int (*ppe_deinit)(struct airoha_npu *npu);
|
||||
+ int (*ppe_flush_sram_entries)(struct airoha_npu *npu,
|
||||
+ dma_addr_t foe_addr,
|
||||
+ int sram_num_entries);
|
||||
+ int (*ppe_foe_commit_entry)(struct airoha_npu *npu,
|
||||
+ dma_addr_t foe_addr,
|
||||
+ u32 entry_size, u32 hash,
|
||||
+ bool ppe2);
|
||||
+ } ops;
|
||||
+};
|
||||
+
|
||||
+struct airoha_npu *airoha_npu_get(struct device *dev);
|
||||
+void airoha_npu_put(struct airoha_npu *npu);
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,210 +0,0 @@
|
||||
From 9cd451d414f6e29f507a216fb3b19fa68c011f8c Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:22 +0100
|
||||
Subject: [PATCH 14/15] net: airoha: Add loopback support for GDM2
|
||||
|
||||
Enable hw redirection for traffic received on GDM2 port to GDM{3,4}.
|
||||
This is required to apply Qdisc offloading (HTB or ETS) for traffic to
|
||||
and from GDM{3,4} port.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 71 ++++++++++++++++++++++-
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 7 +++
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 12 ++--
|
||||
drivers/net/ethernet/airoha/airoha_regs.h | 29 +++++++++
|
||||
4 files changed, 111 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -1609,14 +1609,81 @@ static int airoha_dev_set_macaddr(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void airhoha_set_gdm2_loopback(struct airoha_gdm_port *port)
|
||||
+{
|
||||
+ u32 pse_port = port->id == 3 ? FE_PSE_PORT_GDM3 : FE_PSE_PORT_GDM4;
|
||||
+ struct airoha_eth *eth = port->qdma->eth;
|
||||
+ u32 chan = port->id == 3 ? 4 : 0;
|
||||
+
|
||||
+ /* Forward the traffic to the proper GDM port */
|
||||
+ airoha_set_gdm_port_fwd_cfg(eth, REG_GDM_FWD_CFG(2), pse_port);
|
||||
+ airoha_fe_clear(eth, REG_GDM_FWD_CFG(2), GDM_STRIP_CRC);
|
||||
+
|
||||
+ /* Enable GDM2 loopback */
|
||||
+ airoha_fe_wr(eth, REG_GDM_TXCHN_EN(2), 0xffffffff);
|
||||
+ airoha_fe_wr(eth, REG_GDM_RXCHN_EN(2), 0xffff);
|
||||
+ airoha_fe_rmw(eth, REG_GDM_LPBK_CFG(2),
|
||||
+ LPBK_CHAN_MASK | LPBK_MODE_MASK | LPBK_EN_MASK,
|
||||
+ FIELD_PREP(LPBK_CHAN_MASK, chan) | LPBK_EN_MASK);
|
||||
+ airoha_fe_rmw(eth, REG_GDM_LEN_CFG(2),
|
||||
+ GDM_SHORT_LEN_MASK | GDM_LONG_LEN_MASK,
|
||||
+ FIELD_PREP(GDM_SHORT_LEN_MASK, 60) |
|
||||
+ FIELD_PREP(GDM_LONG_LEN_MASK, AIROHA_MAX_MTU));
|
||||
+
|
||||
+ /* Disable VIP and IFC for GDM2 */
|
||||
+ airoha_fe_clear(eth, REG_FE_VIP_PORT_EN, BIT(2));
|
||||
+ airoha_fe_clear(eth, REG_FE_IFC_PORT_EN, BIT(2));
|
||||
+
|
||||
+ if (port->id == 3) {
|
||||
+ /* FIXME: handle XSI_PCE1_PORT */
|
||||
+ airoha_fe_wr(eth, REG_PPE_DFT_CPORT0(0), 0x5500);
|
||||
+ airoha_fe_rmw(eth, REG_FE_WAN_PORT,
|
||||
+ WAN1_EN_MASK | WAN1_MASK | WAN0_MASK,
|
||||
+ FIELD_PREP(WAN0_MASK, HSGMII_LAN_PCIE0_SRCPORT));
|
||||
+ airoha_fe_rmw(eth,
|
||||
+ REG_SP_DFT_CPORT(HSGMII_LAN_PCIE0_SRCPORT >> 3),
|
||||
+ SP_CPORT_PCIE0_MASK,
|
||||
+ FIELD_PREP(SP_CPORT_PCIE0_MASK,
|
||||
+ FE_PSE_PORT_CDM2));
|
||||
+ } else {
|
||||
+ /* FIXME: handle XSI_USB_PORT */
|
||||
+ airoha_fe_rmw(eth, REG_SRC_PORT_FC_MAP6,
|
||||
+ FC_ID_OF_SRC_PORT24_MASK,
|
||||
+ FIELD_PREP(FC_ID_OF_SRC_PORT24_MASK, 2));
|
||||
+ airoha_fe_rmw(eth, REG_FE_WAN_PORT,
|
||||
+ WAN1_EN_MASK | WAN1_MASK | WAN0_MASK,
|
||||
+ FIELD_PREP(WAN0_MASK, HSGMII_LAN_ETH_SRCPORT));
|
||||
+ airoha_fe_rmw(eth,
|
||||
+ REG_SP_DFT_CPORT(HSGMII_LAN_ETH_SRCPORT >> 3),
|
||||
+ SP_CPORT_ETH_MASK,
|
||||
+ FIELD_PREP(SP_CPORT_ETH_MASK, FE_PSE_PORT_CDM2));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int airoha_dev_init(struct net_device *dev)
|
||||
{
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
struct airoha_eth *eth = port->qdma->eth;
|
||||
+ u32 pse_port;
|
||||
|
||||
airoha_set_macaddr(port, dev->dev_addr);
|
||||
- airoha_set_gdm_port_fwd_cfg(eth, REG_GDM_FWD_CFG(port->id),
|
||||
- FE_PSE_PORT_PPE1);
|
||||
+
|
||||
+ switch (port->id) {
|
||||
+ case 3:
|
||||
+ case 4:
|
||||
+ /* If GDM2 is active we can't enable loopback */
|
||||
+ if (!eth->ports[1])
|
||||
+ airhoha_set_gdm2_loopback(port);
|
||||
+ fallthrough;
|
||||
+ case 2:
|
||||
+ pse_port = FE_PSE_PORT_PPE2;
|
||||
+ break;
|
||||
+ default:
|
||||
+ pse_port = FE_PSE_PORT_PPE1;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ airoha_set_gdm_port_fwd_cfg(eth, REG_GDM_FWD_CFG(port->id), pse_port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -68,6 +68,13 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
+ HSGMII_LAN_PCIE0_SRCPORT = 0x16,
|
||||
+ HSGMII_LAN_PCIE1_SRCPORT,
|
||||
+ HSGMII_LAN_ETH_SRCPORT,
|
||||
+ HSGMII_LAN_USB_SRCPORT,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
XSI_PCIE0_VIP_PORT_MASK = BIT(22),
|
||||
XSI_PCIE1_VIP_PORT_MASK = BIT(23),
|
||||
XSI_USB_VIP_PORT_MASK = BIT(25),
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -216,7 +216,8 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
AIROHA_FOE_IB1_BIND_TTL;
|
||||
hwe->ib1 = val;
|
||||
|
||||
- val = FIELD_PREP(AIROHA_FOE_IB2_PORT_AG, 0x1f);
|
||||
+ val = FIELD_PREP(AIROHA_FOE_IB2_PORT_AG, 0x1f) |
|
||||
+ AIROHA_FOE_IB2_PSE_QOS;
|
||||
if (dsa_port >= 0)
|
||||
val |= FIELD_PREP(AIROHA_FOE_IB2_NBQ, dsa_port);
|
||||
|
||||
@@ -224,14 +225,13 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
u8 pse_port;
|
||||
|
||||
- pse_port = port->id == 4 ? FE_PSE_PORT_GDM4 : port->id;
|
||||
+ if (dsa_port >= 0)
|
||||
+ pse_port = port->id == 4 ? FE_PSE_PORT_GDM4 : port->id;
|
||||
+ else
|
||||
+ pse_port = 2; /* uplink relies on GDM2 loopback */
|
||||
val |= FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT, pse_port);
|
||||
}
|
||||
|
||||
- /* FIXME: implement QoS support setting pse_port to 2 (loopback)
|
||||
- * for uplink and setting qos bit in ib2
|
||||
- */
|
||||
-
|
||||
if (is_multicast_ether_addr(data->eth.h_dest))
|
||||
val |= AIROHA_FOE_IB2_MULTICAST;
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
@@ -38,6 +38,12 @@
|
||||
#define FE_RST_CORE_MASK BIT(0)
|
||||
|
||||
#define REG_FE_FOE_TS 0x0010
|
||||
+
|
||||
+#define REG_FE_WAN_PORT 0x0024
|
||||
+#define WAN1_EN_MASK BIT(16)
|
||||
+#define WAN1_MASK GENMASK(12, 8)
|
||||
+#define WAN0_MASK GENMASK(4, 0)
|
||||
+
|
||||
#define REG_FE_WAN_MAC_H 0x0030
|
||||
#define REG_FE_LAN_MAC_H 0x0040
|
||||
|
||||
@@ -126,6 +132,7 @@
|
||||
#define GDM_IP4_CKSUM BIT(22)
|
||||
#define GDM_TCP_CKSUM BIT(21)
|
||||
#define GDM_UDP_CKSUM BIT(20)
|
||||
+#define GDM_STRIP_CRC BIT(16)
|
||||
#define GDM_UCFQ_MASK GENMASK(15, 12)
|
||||
#define GDM_BCFQ_MASK GENMASK(11, 8)
|
||||
#define GDM_MCFQ_MASK GENMASK(7, 4)
|
||||
@@ -139,6 +146,16 @@
|
||||
#define GDM_SHORT_LEN_MASK GENMASK(13, 0)
|
||||
#define GDM_LONG_LEN_MASK GENMASK(29, 16)
|
||||
|
||||
+#define REG_GDM_LPBK_CFG(_n) (GDM_BASE(_n) + 0x1c)
|
||||
+#define LPBK_GAP_MASK GENMASK(31, 24)
|
||||
+#define LPBK_LEN_MASK GENMASK(23, 10)
|
||||
+#define LPBK_CHAN_MASK GENMASK(8, 4)
|
||||
+#define LPBK_MODE_MASK GENMASK(3, 1)
|
||||
+#define LPBK_EN_MASK BIT(0)
|
||||
+
|
||||
+#define REG_GDM_TXCHN_EN(_n) (GDM_BASE(_n) + 0x24)
|
||||
+#define REG_GDM_RXCHN_EN(_n) (GDM_BASE(_n) + 0x28)
|
||||
+
|
||||
#define REG_FE_CPORT_CFG (GDM1_BASE + 0x40)
|
||||
#define FE_CPORT_PAD BIT(26)
|
||||
#define FE_CPORT_PORT_XFC_MASK BIT(25)
|
||||
@@ -351,6 +368,18 @@
|
||||
|
||||
#define REG_MC_VLAN_DATA 0x2108
|
||||
|
||||
+#define REG_SP_DFT_CPORT(_n) (0x20e0 + ((_n) << 2))
|
||||
+#define SP_CPORT_PCIE1_MASK GENMASK(31, 28)
|
||||
+#define SP_CPORT_PCIE0_MASK GENMASK(27, 24)
|
||||
+#define SP_CPORT_USB_MASK GENMASK(7, 4)
|
||||
+#define SP_CPORT_ETH_MASK GENMASK(7, 4)
|
||||
+
|
||||
+#define REG_SRC_PORT_FC_MAP6 0x2298
|
||||
+#define FC_ID_OF_SRC_PORT27_MASK GENMASK(28, 24)
|
||||
+#define FC_ID_OF_SRC_PORT26_MASK GENMASK(20, 16)
|
||||
+#define FC_ID_OF_SRC_PORT25_MASK GENMASK(12, 8)
|
||||
+#define FC_ID_OF_SRC_PORT24_MASK GENMASK(4, 0)
|
||||
+
|
||||
#define REG_CDM5_RX_OQ1_DROP_CNT 0x29d4
|
||||
|
||||
/* QDMA */
|
||||
@ -1,291 +0,0 @@
|
||||
From 3fe15c640f3808c3faf235553c67c867d1389e5c Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 28 Feb 2025 11:54:23 +0100
|
||||
Subject: [PATCH 15/15] net: airoha: Introduce PPE debugfs support
|
||||
|
||||
Similar to PPE support for Mediatek devices, introduce PPE debugfs
|
||||
in order to dump binded and unbinded flows.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/Makefile | 1 +
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 14 ++
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 17 +-
|
||||
.../net/ethernet/airoha/airoha_ppe_debugfs.c | 181 ++++++++++++++++++
|
||||
4 files changed, 209 insertions(+), 4 deletions(-)
|
||||
create mode 100644 drivers/net/ethernet/airoha/airoha_ppe_debugfs.c
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/Makefile
|
||||
+++ b/drivers/net/ethernet/airoha/Makefile
|
||||
@@ -5,4 +5,5 @@
|
||||
|
||||
obj-$(CONFIG_NET_AIROHA) += airoha-eth.o
|
||||
airoha-eth-y := airoha_eth.o airoha_ppe.o
|
||||
+airoha-eth-$(CONFIG_DEBUG_FS) += airoha_ppe_debugfs.o
|
||||
obj-$(CONFIG_NET_AIROHA_NPU) += airoha_npu.o
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -7,6 +7,7 @@
|
||||
#ifndef AIROHA_ETH_H
|
||||
#define AIROHA_ETH_H
|
||||
|
||||
+#include <linux/debugfs.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -480,6 +481,8 @@ struct airoha_ppe {
|
||||
|
||||
struct hlist_head *foe_flow;
|
||||
u16 foe_check_time[PPE_NUM_ENTRIES];
|
||||
+
|
||||
+ struct dentry *debugfs_dir;
|
||||
};
|
||||
|
||||
struct airoha_eth {
|
||||
@@ -533,5 +536,16 @@ int airoha_ppe_setup_tc_block_cb(enum tc
|
||||
void *cb_priv);
|
||||
int airoha_ppe_init(struct airoha_eth *eth);
|
||||
void airoha_ppe_deinit(struct airoha_eth *eth);
|
||||
+struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
|
||||
+ u32 hash);
|
||||
+
|
||||
+#if CONFIG_DEBUG_FS
|
||||
+int airoha_ppe_debugfs_init(struct airoha_ppe *ppe);
|
||||
+#else
|
||||
+static inline int airoha_ppe_debugfs_init(struct airoha_ppe *ppe)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
|
||||
#endif /* AIROHA_ETH_H */
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -390,8 +390,8 @@ static u32 airoha_ppe_foe_get_entry_hash
|
||||
return hash;
|
||||
}
|
||||
|
||||
-static struct airoha_foe_entry *
|
||||
-airoha_ppe_foe_get_entry(struct airoha_ppe *ppe, u32 hash)
|
||||
+struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
|
||||
+ u32 hash)
|
||||
{
|
||||
if (hash < PPE_SRAM_NUM_ENTRIES) {
|
||||
u32 *hwe = ppe->foe + hash * sizeof(struct airoha_foe_entry);
|
||||
@@ -861,7 +861,7 @@ void airoha_ppe_check_skb(struct airoha_
|
||||
int airoha_ppe_init(struct airoha_eth *eth)
|
||||
{
|
||||
struct airoha_ppe *ppe;
|
||||
- int foe_size;
|
||||
+ int foe_size, err;
|
||||
|
||||
ppe = devm_kzalloc(eth->dev, sizeof(*ppe), GFP_KERNEL);
|
||||
if (!ppe)
|
||||
@@ -882,7 +882,15 @@ int airoha_ppe_init(struct airoha_eth *e
|
||||
if (!ppe->foe_flow)
|
||||
return -ENOMEM;
|
||||
|
||||
- return rhashtable_init(ð->flow_table, &airoha_flow_table_params);
|
||||
+ err = rhashtable_init(ð->flow_table, &airoha_flow_table_params);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = airoha_ppe_debugfs_init(ppe);
|
||||
+ if (err)
|
||||
+ rhashtable_destroy(ð->flow_table);
|
||||
+
|
||||
+ return err;
|
||||
}
|
||||
|
||||
void airoha_ppe_deinit(struct airoha_eth *eth)
|
||||
@@ -898,4 +906,5 @@ void airoha_ppe_deinit(struct airoha_eth
|
||||
rcu_read_unlock();
|
||||
|
||||
rhashtable_destroy(ð->flow_table);
|
||||
+ debugfs_remove(eth->ppe->debugfs_dir);
|
||||
}
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe_debugfs.c
|
||||
@@ -0,0 +1,181 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-only
|
||||
+/*
|
||||
+ * Copyright (c) 2025 AIROHA Inc
|
||||
+ * Author: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
+ */
|
||||
+
|
||||
+#include "airoha_eth.h"
|
||||
+
|
||||
+static void airoha_debugfs_ppe_print_tuple(struct seq_file *m,
|
||||
+ void *src_addr, void *dest_addr,
|
||||
+ u16 *src_port, u16 *dest_port,
|
||||
+ bool ipv6)
|
||||
+{
|
||||
+ __be32 n_addr[IPV6_ADDR_WORDS];
|
||||
+
|
||||
+ if (ipv6) {
|
||||
+ ipv6_addr_cpu_to_be32(n_addr, src_addr);
|
||||
+ seq_printf(m, "%pI6", n_addr);
|
||||
+ } else {
|
||||
+ seq_printf(m, "%pI4h", src_addr);
|
||||
+ }
|
||||
+ if (src_port)
|
||||
+ seq_printf(m, ":%d", *src_port);
|
||||
+
|
||||
+ seq_puts(m, "->");
|
||||
+
|
||||
+ if (ipv6) {
|
||||
+ ipv6_addr_cpu_to_be32(n_addr, dest_addr);
|
||||
+ seq_printf(m, "%pI6", n_addr);
|
||||
+ } else {
|
||||
+ seq_printf(m, "%pI4h", dest_addr);
|
||||
+ }
|
||||
+ if (dest_port)
|
||||
+ seq_printf(m, ":%d", *dest_port);
|
||||
+}
|
||||
+
|
||||
+static int airoha_ppe_debugfs_foe_show(struct seq_file *m, void *private,
|
||||
+ bool bind)
|
||||
+{
|
||||
+ static const char *const ppe_type_str[] = {
|
||||
+ [PPE_PKT_TYPE_IPV4_HNAPT] = "IPv4 5T",
|
||||
+ [PPE_PKT_TYPE_IPV4_ROUTE] = "IPv4 3T",
|
||||
+ [PPE_PKT_TYPE_BRIDGE] = "L2B",
|
||||
+ [PPE_PKT_TYPE_IPV4_DSLITE] = "DS-LITE",
|
||||
+ [PPE_PKT_TYPE_IPV6_ROUTE_3T] = "IPv6 3T",
|
||||
+ [PPE_PKT_TYPE_IPV6_ROUTE_5T] = "IPv6 5T",
|
||||
+ [PPE_PKT_TYPE_IPV6_6RD] = "6RD",
|
||||
+ };
|
||||
+ static const char *const ppe_state_str[] = {
|
||||
+ [AIROHA_FOE_STATE_INVALID] = "INV",
|
||||
+ [AIROHA_FOE_STATE_UNBIND] = "UNB",
|
||||
+ [AIROHA_FOE_STATE_BIND] = "BND",
|
||||
+ [AIROHA_FOE_STATE_FIN] = "FIN",
|
||||
+ };
|
||||
+ struct airoha_ppe *ppe = m->private;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < PPE_NUM_ENTRIES; i++) {
|
||||
+ const char *state_str, *type_str = "UNKNOWN";
|
||||
+ void *src_addr = NULL, *dest_addr = NULL;
|
||||
+ u16 *src_port = NULL, *dest_port = NULL;
|
||||
+ struct airoha_foe_mac_info_common *l2;
|
||||
+ unsigned char h_source[ETH_ALEN] = {};
|
||||
+ unsigned char h_dest[ETH_ALEN];
|
||||
+ struct airoha_foe_entry *hwe;
|
||||
+ u32 type, state, ib2, data;
|
||||
+ bool ipv6 = false;
|
||||
+
|
||||
+ hwe = airoha_ppe_foe_get_entry(ppe, i);
|
||||
+ if (!hwe)
|
||||
+ continue;
|
||||
+
|
||||
+ state = FIELD_GET(AIROHA_FOE_IB1_BIND_STATE, hwe->ib1);
|
||||
+ if (!state)
|
||||
+ continue;
|
||||
+
|
||||
+ if (bind && state != AIROHA_FOE_STATE_BIND)
|
||||
+ continue;
|
||||
+
|
||||
+ state_str = ppe_state_str[state % ARRAY_SIZE(ppe_state_str)];
|
||||
+ type = FIELD_GET(AIROHA_FOE_IB1_BIND_PACKET_TYPE, hwe->ib1);
|
||||
+ if (type < ARRAY_SIZE(ppe_type_str) && ppe_type_str[type])
|
||||
+ type_str = ppe_type_str[type];
|
||||
+
|
||||
+ seq_printf(m, "%05x %s %7s", i, state_str, type_str);
|
||||
+
|
||||
+ switch (type) {
|
||||
+ case PPE_PKT_TYPE_IPV4_HNAPT:
|
||||
+ case PPE_PKT_TYPE_IPV4_DSLITE:
|
||||
+ src_port = &hwe->ipv4.orig_tuple.src_port;
|
||||
+ dest_port = &hwe->ipv4.orig_tuple.dest_port;
|
||||
+ fallthrough;
|
||||
+ case PPE_PKT_TYPE_IPV4_ROUTE:
|
||||
+ src_addr = &hwe->ipv4.orig_tuple.src_ip;
|
||||
+ dest_addr = &hwe->ipv4.orig_tuple.dest_ip;
|
||||
+ break;
|
||||
+ case PPE_PKT_TYPE_IPV6_ROUTE_5T:
|
||||
+ src_port = &hwe->ipv6.src_port;
|
||||
+ dest_port = &hwe->ipv6.dest_port;
|
||||
+ fallthrough;
|
||||
+ case PPE_PKT_TYPE_IPV6_ROUTE_3T:
|
||||
+ case PPE_PKT_TYPE_IPV6_6RD:
|
||||
+ src_addr = &hwe->ipv6.src_ip;
|
||||
+ dest_addr = &hwe->ipv6.dest_ip;
|
||||
+ ipv6 = true;
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (src_addr && dest_addr) {
|
||||
+ seq_puts(m, " orig=");
|
||||
+ airoha_debugfs_ppe_print_tuple(m, src_addr, dest_addr,
|
||||
+ src_port, dest_port, ipv6);
|
||||
+ }
|
||||
+
|
||||
+ switch (type) {
|
||||
+ case PPE_PKT_TYPE_IPV4_HNAPT:
|
||||
+ case PPE_PKT_TYPE_IPV4_DSLITE:
|
||||
+ src_port = &hwe->ipv4.new_tuple.src_port;
|
||||
+ dest_port = &hwe->ipv4.new_tuple.dest_port;
|
||||
+ fallthrough;
|
||||
+ case PPE_PKT_TYPE_IPV4_ROUTE:
|
||||
+ src_addr = &hwe->ipv4.new_tuple.src_ip;
|
||||
+ dest_addr = &hwe->ipv4.new_tuple.dest_ip;
|
||||
+ seq_puts(m, " new=");
|
||||
+ airoha_debugfs_ppe_print_tuple(m, src_addr, dest_addr,
|
||||
+ src_port, dest_port,
|
||||
+ ipv6);
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T) {
|
||||
+ data = hwe->ipv6.data;
|
||||
+ ib2 = hwe->ipv6.ib2;
|
||||
+ l2 = &hwe->ipv6.l2;
|
||||
+ } else {
|
||||
+ data = hwe->ipv4.data;
|
||||
+ ib2 = hwe->ipv4.ib2;
|
||||
+ l2 = &hwe->ipv4.l2.common;
|
||||
+ *((__be16 *)&h_source[4]) =
|
||||
+ cpu_to_be16(hwe->ipv4.l2.src_mac_lo);
|
||||
+ }
|
||||
+
|
||||
+ *((__be32 *)h_dest) = cpu_to_be32(l2->dest_mac_hi);
|
||||
+ *((__be16 *)&h_dest[4]) = cpu_to_be16(l2->dest_mac_lo);
|
||||
+ *((__be32 *)h_source) = cpu_to_be32(l2->src_mac_hi);
|
||||
+
|
||||
+ seq_printf(m, " eth=%pM->%pM etype=%04x data=%08x"
|
||||
+ " vlan=%d,%d ib1=%08x ib2=%08x\n",
|
||||
+ h_source, h_dest, l2->etype, data,
|
||||
+ l2->vlan1, l2->vlan2, hwe->ib1, ib2);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_ppe_debugfs_foe_all_show(struct seq_file *m, void *private)
|
||||
+{
|
||||
+ return airoha_ppe_debugfs_foe_show(m, private, false);
|
||||
+}
|
||||
+DEFINE_SHOW_ATTRIBUTE(airoha_ppe_debugfs_foe_all);
|
||||
+
|
||||
+static int airoha_ppe_debugfs_foe_bind_show(struct seq_file *m, void *private)
|
||||
+{
|
||||
+ return airoha_ppe_debugfs_foe_show(m, private, true);
|
||||
+}
|
||||
+DEFINE_SHOW_ATTRIBUTE(airoha_ppe_debugfs_foe_bind);
|
||||
+
|
||||
+int airoha_ppe_debugfs_init(struct airoha_ppe *ppe)
|
||||
+{
|
||||
+ ppe->debugfs_dir = debugfs_create_dir("ppe", NULL);
|
||||
+ debugfs_create_file("entries", 0444, ppe->debugfs_dir, ppe,
|
||||
+ &airoha_ppe_debugfs_foe_all_fops);
|
||||
+ debugfs_create_file("bind", 0444, ppe->debugfs_dir, ppe,
|
||||
+ &airoha_ppe_debugfs_foe_bind_fops);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
@ -1,550 +0,0 @@
|
||||
From 42de37f40e1bc818df216dfa0918c114cfb5941d Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Sun, 11 May 2025 20:49:55 +0200
|
||||
Subject: [PATCH] thermal/drivers: Add support for Airoha EN7581 thermal sensor
|
||||
|
||||
Add support for Airoha EN7581 thermal sensor. This provide support for
|
||||
reading the CPU or SoC Package sensor and to setup trip points for hot
|
||||
and critical condition. An interrupt is fired to react on this and
|
||||
doesn't require passive poll to read the temperature.
|
||||
|
||||
The thermal regs provide a way to read the ADC value from an external
|
||||
register placed in the Chip SCU regs. Monitor will read this value and
|
||||
fire an interrupt if the trip condition configured is reached.
|
||||
|
||||
The Thermal Trip and Interrupt logic is conceptually similar to Mediatek
|
||||
LVTS Thermal but differ in register mapping and actual function/bug
|
||||
workaround. The implementation only share some register names but from
|
||||
functionality observation it's very different and used only for the
|
||||
basic function of periodically poll the temp and trip the interrupt.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20250511185003.3754495-2-ansuelsmth@gmail.com
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
---
|
||||
drivers/thermal/Kconfig | 9 +
|
||||
drivers/thermal/Makefile | 1 +
|
||||
drivers/thermal/airoha_thermal.c | 489 +++++++++++++++++++++++++++++++
|
||||
3 files changed, 499 insertions(+)
|
||||
create mode 100644 drivers/thermal/airoha_thermal.c
|
||||
|
||||
--- a/drivers/thermal/Kconfig
|
||||
+++ b/drivers/thermal/Kconfig
|
||||
@@ -318,6 +318,15 @@ config QORIQ_THERMAL
|
||||
cpufreq is used as the cooling device to throttle CPUs when the
|
||||
passive trip is crossed.
|
||||
|
||||
+config AIROHA_THERMAL
|
||||
+ tristate "Airoha thermal sensor driver"
|
||||
+ depends on ARCH_AIROHA || COMPILE_TEST
|
||||
+ depends on MFD_SYSCON
|
||||
+ depends on OF
|
||||
+ help
|
||||
+ Enable this to plug the Airoha thermal sensor driver into the Linux
|
||||
+ thermal framework.
|
||||
+
|
||||
config SPEAR_THERMAL
|
||||
tristate "SPEAr thermal sensor driver"
|
||||
depends on PLAT_SPEAR || COMPILE_TEST
|
||||
--- a/drivers/thermal/Makefile
|
||||
+++ b/drivers/thermal/Makefile
|
||||
@@ -35,6 +35,7 @@ obj-$(CONFIG_K3_THERMAL) += k3_bandgap.o
|
||||
# platform thermal drivers
|
||||
obj-y += broadcom/
|
||||
obj-$(CONFIG_THERMAL_MMIO) += thermal_mmio.o
|
||||
+obj-$(CONFIG_AIROHA_THERMAL) += airoha_thermal.o
|
||||
obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o
|
||||
obj-$(CONFIG_SUN8I_THERMAL) += sun8i_thermal.o
|
||||
obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/thermal/airoha_thermal.c
|
||||
@@ -0,0 +1,489 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/bitfield.h>
|
||||
+#include <linux/delay.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/mfd/syscon.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_address.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/regmap.h>
|
||||
+#include <linux/thermal.h>
|
||||
+
|
||||
+/* SCU regs */
|
||||
+#define EN7581_PLLRG_PROTECT 0x268
|
||||
+#define EN7581_PWD_TADC 0x2ec
|
||||
+#define EN7581_MUX_TADC GENMASK(3, 1)
|
||||
+#define EN7581_DOUT_TADC 0x2f8
|
||||
+#define EN7581_DOUT_TADC_MASK GENMASK(15, 0)
|
||||
+
|
||||
+/* PTP_THERMAL regs */
|
||||
+#define EN7581_TEMPMONCTL0 0x800
|
||||
+#define EN7581_SENSE3_EN BIT(3)
|
||||
+#define EN7581_SENSE2_EN BIT(2)
|
||||
+#define EN7581_SENSE1_EN BIT(1)
|
||||
+#define EN7581_SENSE0_EN BIT(0)
|
||||
+#define EN7581_TEMPMONCTL1 0x804
|
||||
+/* period unit calculated in BUS clock * 256 scaling-up */
|
||||
+#define EN7581_PERIOD_UNIT GENMASK(9, 0)
|
||||
+#define EN7581_TEMPMONCTL2 0x808
|
||||
+#define EN7581_FILT_INTERVAL GENMASK(25, 16)
|
||||
+#define EN7581_SEN_INTERVAL GENMASK(9, 0)
|
||||
+#define EN7581_TEMPMONINT 0x80C
|
||||
+#define EN7581_STAGE3_INT_EN BIT(31)
|
||||
+#define EN7581_STAGE2_INT_EN BIT(30)
|
||||
+#define EN7581_STAGE1_INT_EN BIT(29)
|
||||
+#define EN7581_FILTER_INT_EN_3 BIT(28)
|
||||
+#define EN7581_IMMD_INT_EN3 BIT(27)
|
||||
+#define EN7581_NOHOTINTEN3 BIT(26)
|
||||
+#define EN7581_HOFSINTEN3 BIT(25)
|
||||
+#define EN7581_LOFSINTEN3 BIT(24)
|
||||
+#define EN7581_HINTEN3 BIT(23)
|
||||
+#define EN7581_CINTEN3 BIT(22)
|
||||
+#define EN7581_FILTER_INT_EN_2 BIT(21)
|
||||
+#define EN7581_FILTER_INT_EN_1 BIT(20)
|
||||
+#define EN7581_FILTER_INT_EN_0 BIT(19)
|
||||
+#define EN7581_IMMD_INT_EN2 BIT(18)
|
||||
+#define EN7581_IMMD_INT_EN1 BIT(17)
|
||||
+#define EN7581_IMMD_INT_EN0 BIT(16)
|
||||
+#define EN7581_TIME_OUT_INT_EN BIT(15)
|
||||
+#define EN7581_NOHOTINTEN2 BIT(14)
|
||||
+#define EN7581_HOFSINTEN2 BIT(13)
|
||||
+#define EN7581_LOFSINTEN2 BIT(12)
|
||||
+#define EN7581_HINTEN2 BIT(11)
|
||||
+#define EN7581_CINTEN2 BIT(10)
|
||||
+#define EN7581_NOHOTINTEN1 BIT(9)
|
||||
+#define EN7581_HOFSINTEN1 BIT(8)
|
||||
+#define EN7581_LOFSINTEN1 BIT(7)
|
||||
+#define EN7581_HINTEN1 BIT(6)
|
||||
+#define EN7581_CINTEN1 BIT(5)
|
||||
+#define EN7581_NOHOTINTEN0 BIT(4)
|
||||
+/* Similar to COLD and HOT also these seems to be swapped in documentation */
|
||||
+#define EN7581_LOFSINTEN0 BIT(3) /* In documentation: BIT(2) */
|
||||
+#define EN7581_HOFSINTEN0 BIT(2) /* In documentation: BIT(3) */
|
||||
+/* It seems documentation have these swapped as the HW
|
||||
+ * - Fire BIT(1) when lower than EN7581_COLD_THRE
|
||||
+ * - Fire BIT(0) and BIT(5) when higher than EN7581_HOT2NORMAL_THRE or
|
||||
+ * EN7581_HOT_THRE
|
||||
+ */
|
||||
+#define EN7581_CINTEN0 BIT(1) /* In documentation: BIT(0) */
|
||||
+#define EN7581_HINTEN0 BIT(0) /* In documentation: BIT(1) */
|
||||
+#define EN7581_TEMPMONINTSTS 0x810
|
||||
+#define EN7581_STAGE3_INT_STAT BIT(31)
|
||||
+#define EN7581_STAGE2_INT_STAT BIT(30)
|
||||
+#define EN7581_STAGE1_INT_STAT BIT(29)
|
||||
+#define EN7581_FILTER_INT_STAT_3 BIT(28)
|
||||
+#define EN7581_IMMD_INT_STS3 BIT(27)
|
||||
+#define EN7581_NOHOTINTSTS3 BIT(26)
|
||||
+#define EN7581_HOFSINTSTS3 BIT(25)
|
||||
+#define EN7581_LOFSINTSTS3 BIT(24)
|
||||
+#define EN7581_HINTSTS3 BIT(23)
|
||||
+#define EN7581_CINTSTS3 BIT(22)
|
||||
+#define EN7581_FILTER_INT_STAT_2 BIT(21)
|
||||
+#define EN7581_FILTER_INT_STAT_1 BIT(20)
|
||||
+#define EN7581_FILTER_INT_STAT_0 BIT(19)
|
||||
+#define EN7581_IMMD_INT_STS2 BIT(18)
|
||||
+#define EN7581_IMMD_INT_STS1 BIT(17)
|
||||
+#define EN7581_IMMD_INT_STS0 BIT(16)
|
||||
+#define EN7581_TIME_OUT_INT_STAT BIT(15)
|
||||
+#define EN7581_NOHOTINTSTS2 BIT(14)
|
||||
+#define EN7581_HOFSINTSTS2 BIT(13)
|
||||
+#define EN7581_LOFSINTSTS2 BIT(12)
|
||||
+#define EN7581_HINTSTS2 BIT(11)
|
||||
+#define EN7581_CINTSTS2 BIT(10)
|
||||
+#define EN7581_NOHOTINTSTS1 BIT(9)
|
||||
+#define EN7581_HOFSINTSTS1 BIT(8)
|
||||
+#define EN7581_LOFSINTSTS1 BIT(7)
|
||||
+#define EN7581_HINTSTS1 BIT(6)
|
||||
+#define EN7581_CINTSTS1 BIT(5)
|
||||
+#define EN7581_NOHOTINTSTS0 BIT(4)
|
||||
+/* Similar to COLD and HOT also these seems to be swapped in documentation */
|
||||
+#define EN7581_LOFSINTSTS0 BIT(3) /* In documentation: BIT(2) */
|
||||
+#define EN7581_HOFSINTSTS0 BIT(2) /* In documentation: BIT(3) */
|
||||
+/* It seems documentation have these swapped as the HW
|
||||
+ * - Fire BIT(1) when lower than EN7581_COLD_THRE
|
||||
+ * - Fire BIT(0) and BIT(5) when higher than EN7581_HOT2NORMAL_THRE or
|
||||
+ * EN7581_HOT_THRE
|
||||
+ *
|
||||
+ * To clear things, we swap the define but we keep them documented here.
|
||||
+ */
|
||||
+#define EN7581_CINTSTS0 BIT(1) /* In documentation: BIT(0) */
|
||||
+#define EN7581_HINTSTS0 BIT(0) /* In documentation: BIT(1)*/
|
||||
+/* Monitor will take the bigger threshold between HOT2NORMAL and HOT
|
||||
+ * and will fire both HOT2NORMAL and HOT interrupt when higher than the 2
|
||||
+ *
|
||||
+ * It has also been observed that not setting HOT2NORMAL makes the monitor
|
||||
+ * treat COLD threshold as HOT2NORMAL.
|
||||
+ */
|
||||
+#define EN7581_TEMPH2NTHRE 0x824
|
||||
+/* It seems HOT2NORMAL is actually NORMAL2HOT */
|
||||
+#define EN7581_HOT2NORMAL_THRE GENMASK(11, 0)
|
||||
+#define EN7581_TEMPHTHRE 0x828
|
||||
+#define EN7581_HOT_THRE GENMASK(11, 0)
|
||||
+/* Monitor will use this as HOT2NORMAL (fire interrupt when lower than...)*/
|
||||
+#define EN7581_TEMPCTHRE 0x82c
|
||||
+#define EN7581_COLD_THRE GENMASK(11, 0)
|
||||
+/* Also LOW and HIGH offset register are swapped */
|
||||
+#define EN7581_TEMPOFFSETL 0x830 /* In documentation: 0x834 */
|
||||
+#define EN7581_LOW_OFFSET GENMASK(11, 0)
|
||||
+#define EN7581_TEMPOFFSETH 0x834 /* In documentation: 0x830 */
|
||||
+#define EN7581_HIGH_OFFSET GENMASK(11, 0)
|
||||
+#define EN7581_TEMPMSRCTL0 0x838
|
||||
+#define EN7581_MSRCTL3 GENMASK(11, 9)
|
||||
+#define EN7581_MSRCTL2 GENMASK(8, 6)
|
||||
+#define EN7581_MSRCTL1 GENMASK(5, 3)
|
||||
+#define EN7581_MSRCTL0 GENMASK(2, 0)
|
||||
+#define EN7581_TEMPADCVALIDADDR 0x878
|
||||
+#define EN7581_ADC_VALID_ADDR GENMASK(31, 0)
|
||||
+#define EN7581_TEMPADCVOLTADDR 0x87c
|
||||
+#define EN7581_ADC_VOLT_ADDR GENMASK(31, 0)
|
||||
+#define EN7581_TEMPRDCTRL 0x880
|
||||
+/*
|
||||
+ * NOTICE: AHB have this set to 0 by default. Means that
|
||||
+ * the same addr is used for ADC volt and valid reading.
|
||||
+ * In such case, VALID ADDR is used and volt addr is ignored.
|
||||
+ */
|
||||
+#define EN7581_RD_CTRL_DIFF BIT(0)
|
||||
+#define EN7581_TEMPADCVALIDMASK 0x884
|
||||
+#define EN7581_ADV_RD_VALID_POLARITY BIT(5)
|
||||
+#define EN7581_ADV_RD_VALID_POS GENMASK(4, 0)
|
||||
+#define EN7581_TEMPADCVOLTAGESHIFT 0x888
|
||||
+#define EN7581_ADC_VOLTAGE_SHIFT GENMASK(4, 0)
|
||||
+/*
|
||||
+ * Same values for each CTL.
|
||||
+ * Can operate in:
|
||||
+ * - 1 sample
|
||||
+ * - 2 sample and make average of them
|
||||
+ * - 4,6,10,16 sample, drop max and min and make avgerage of them
|
||||
+ */
|
||||
+#define EN7581_MSRCTL_1SAMPLE 0x0
|
||||
+#define EN7581_MSRCTL_AVG2SAMPLE 0x1
|
||||
+#define EN7581_MSRCTL_4SAMPLE_MAX_MIX_AVG2 0x2
|
||||
+#define EN7581_MSRCTL_6SAMPLE_MAX_MIX_AVG4 0x3
|
||||
+#define EN7581_MSRCTL_10SAMPLE_MAX_MIX_AVG8 0x4
|
||||
+#define EN7581_MSRCTL_18SAMPLE_MAX_MIX_AVG16 0x5
|
||||
+#define EN7581_TEMPAHBPOLL 0x840
|
||||
+#define EN7581_ADC_POLL_INTVL GENMASK(31, 0)
|
||||
+/* PTPSPARE0,2 reg are used to store efuse info for calibrated temp offset */
|
||||
+#define EN7581_EFUSE_TEMP_OFFSET_REG 0xf20 /* PTPSPARE0 */
|
||||
+#define EN7581_EFUSE_TEMP_OFFSET GENMASK(31, 16)
|
||||
+#define EN7581_PTPSPARE1 0xf24 /* PTPSPARE1 */
|
||||
+#define EN7581_EFUSE_TEMP_CPU_SENSOR_REG 0xf28 /* PTPSPARE2 */
|
||||
+
|
||||
+#define EN7581_SLOPE_X100_DIO_DEFAULT 5645
|
||||
+#define EN7581_SLOPE_X100_DIO_AVS 5645
|
||||
+
|
||||
+#define EN7581_INIT_TEMP_CPK_X10 300
|
||||
+#define EN7581_INIT_TEMP_FTK_X10 620
|
||||
+#define EN7581_INIT_TEMP_NONK_X10 550
|
||||
+
|
||||
+#define EN7581_SCU_THERMAL_PROTECT_KEY 0x12
|
||||
+#define EN7581_SCU_THERMAL_MUX_DIODE1 0x7
|
||||
+
|
||||
+/* Convert temp to raw value as read from ADC ((((temp / 100) - init) * slope) / 1000) + offset */
|
||||
+#define TEMP_TO_RAW(priv, temp) ((((((temp) / 100) - (priv)->init_temp) * \
|
||||
+ (priv)->default_slope) / 1000) + \
|
||||
+ (priv)->default_offset)
|
||||
+
|
||||
+/* Convert raw to temp ((((temp - offset) * 1000) / slope + init) * 100) */
|
||||
+#define RAW_TO_TEMP(priv, raw) (((((raw) - (priv)->default_offset) * 1000) / \
|
||||
+ (priv)->default_slope + \
|
||||
+ (priv)->init_temp) * 100)
|
||||
+
|
||||
+#define AIROHA_MAX_SAMPLES 6
|
||||
+
|
||||
+struct airoha_thermal_priv {
|
||||
+ void __iomem *base;
|
||||
+ struct regmap *chip_scu;
|
||||
+ struct resource scu_adc_res;
|
||||
+
|
||||
+ struct thermal_zone_device *tz;
|
||||
+ int init_temp;
|
||||
+ int default_slope;
|
||||
+ int default_offset;
|
||||
+};
|
||||
+
|
||||
+static int airoha_get_thermal_ADC(struct airoha_thermal_priv *priv)
|
||||
+{
|
||||
+ u32 val;
|
||||
+
|
||||
+ regmap_read(priv->chip_scu, EN7581_DOUT_TADC, &val);
|
||||
+ return FIELD_GET(EN7581_DOUT_TADC_MASK, val);
|
||||
+}
|
||||
+
|
||||
+static void airoha_init_thermal_ADC_mode(struct airoha_thermal_priv *priv)
|
||||
+{
|
||||
+ u32 adc_mux, pllrg;
|
||||
+
|
||||
+ /* Save PLLRG current value */
|
||||
+ regmap_read(priv->chip_scu, EN7581_PLLRG_PROTECT, &pllrg);
|
||||
+
|
||||
+ /* Give access to thermal regs */
|
||||
+ regmap_write(priv->chip_scu, EN7581_PLLRG_PROTECT, EN7581_SCU_THERMAL_PROTECT_KEY);
|
||||
+ adc_mux = FIELD_PREP(EN7581_MUX_TADC, EN7581_SCU_THERMAL_MUX_DIODE1);
|
||||
+ regmap_write(priv->chip_scu, EN7581_PWD_TADC, adc_mux);
|
||||
+
|
||||
+ /* Restore PLLRG value on exit */
|
||||
+ regmap_write(priv->chip_scu, EN7581_PLLRG_PROTECT, pllrg);
|
||||
+}
|
||||
+
|
||||
+static int airoha_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||
+{
|
||||
+ struct airoha_thermal_priv *priv = thermal_zone_device_priv(tz);
|
||||
+ int min_value, max_value, avg_value, value;
|
||||
+ int i;
|
||||
+
|
||||
+ avg_value = 0;
|
||||
+ min_value = INT_MAX;
|
||||
+ max_value = INT_MIN;
|
||||
+
|
||||
+ for (i = 0; i < AIROHA_MAX_SAMPLES; i++) {
|
||||
+ value = airoha_get_thermal_ADC(priv);
|
||||
+ min_value = min(value, min_value);
|
||||
+ max_value = max(value, max_value);
|
||||
+ avg_value += value;
|
||||
+ }
|
||||
+
|
||||
+ /* Drop min and max and average for the remaining sample */
|
||||
+ avg_value -= (min_value + max_value);
|
||||
+ avg_value /= AIROHA_MAX_SAMPLES - 2;
|
||||
+
|
||||
+ *temp = RAW_TO_TEMP(priv, avg_value);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_thermal_set_trips(struct thermal_zone_device *tz, int low,
|
||||
+ int high)
|
||||
+{
|
||||
+ struct airoha_thermal_priv *priv = thermal_zone_device_priv(tz);
|
||||
+ bool enable_monitor = false;
|
||||
+
|
||||
+ if (high != INT_MAX) {
|
||||
+ /* Validate high and clamp it a supported value */
|
||||
+ high = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
|
||||
+ RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
|
||||
+
|
||||
+ /* We offset the high temp of 1°C to trigger correct event */
|
||||
+ writel(TEMP_TO_RAW(priv, high) >> 4,
|
||||
+ priv->base + EN7581_TEMPOFFSETH);
|
||||
+
|
||||
+ enable_monitor = true;
|
||||
+ }
|
||||
+
|
||||
+ if (low != -INT_MAX) {
|
||||
+ /* Validate low and clamp it to a supported value */
|
||||
+ low = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
|
||||
+ RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
|
||||
+
|
||||
+ /* We offset the low temp of 1°C to trigger correct event */
|
||||
+ writel(TEMP_TO_RAW(priv, low) >> 4,
|
||||
+ priv->base + EN7581_TEMPOFFSETL);
|
||||
+
|
||||
+ enable_monitor = true;
|
||||
+ }
|
||||
+
|
||||
+ /* Enable sensor 0 monitor after trip are set */
|
||||
+ if (enable_monitor)
|
||||
+ writel(EN7581_SENSE0_EN, priv->base + EN7581_TEMPMONCTL0);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct thermal_zone_device_ops thdev_ops = {
|
||||
+ .get_temp = airoha_thermal_get_temp,
|
||||
+ .set_trips = airoha_thermal_set_trips,
|
||||
+};
|
||||
+
|
||||
+static irqreturn_t airoha_thermal_irq(int irq, void *data)
|
||||
+{
|
||||
+ struct airoha_thermal_priv *priv = data;
|
||||
+ enum thermal_notify_event event;
|
||||
+ bool update = false;
|
||||
+ u32 status;
|
||||
+
|
||||
+ status = readl(priv->base + EN7581_TEMPMONINTSTS);
|
||||
+ switch (status & (EN7581_HOFSINTSTS0 | EN7581_LOFSINTSTS0)) {
|
||||
+ case EN7581_HOFSINTSTS0:
|
||||
+ event = THERMAL_TRIP_VIOLATED;
|
||||
+ update = true;
|
||||
+ break;
|
||||
+ case EN7581_LOFSINTSTS0:
|
||||
+ event = THERMAL_EVENT_UNSPECIFIED;
|
||||
+ update = true;
|
||||
+ break;
|
||||
+ default:
|
||||
+ /* Should be impossible as we enable only these Interrupt */
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ /* Reset Interrupt */
|
||||
+ writel(status, priv->base + EN7581_TEMPMONINTSTS);
|
||||
+
|
||||
+ if (update)
|
||||
+ thermal_zone_device_update(priv->tz, event);
|
||||
+
|
||||
+ return IRQ_HANDLED;
|
||||
+}
|
||||
+
|
||||
+static void airoha_thermal_setup_adc_val(struct device *dev,
|
||||
+ struct airoha_thermal_priv *priv)
|
||||
+{
|
||||
+ u32 efuse_calib_info, cpu_sensor;
|
||||
+
|
||||
+ /* Setup thermal sensor to ADC mode and setup the mux to DIODE1 */
|
||||
+ airoha_init_thermal_ADC_mode(priv);
|
||||
+ /* sleep 10 ms for ADC to enable */
|
||||
+ usleep_range(10 * USEC_PER_MSEC, 11 * USEC_PER_MSEC);
|
||||
+
|
||||
+ efuse_calib_info = readl(priv->base + EN7581_EFUSE_TEMP_OFFSET_REG);
|
||||
+ if (efuse_calib_info) {
|
||||
+ priv->default_offset = FIELD_GET(EN7581_EFUSE_TEMP_OFFSET, efuse_calib_info);
|
||||
+ /* Different slope are applied if the sensor is used for CPU or for package */
|
||||
+ cpu_sensor = readl(priv->base + EN7581_EFUSE_TEMP_CPU_SENSOR_REG);
|
||||
+ if (cpu_sensor) {
|
||||
+ priv->default_slope = EN7581_SLOPE_X100_DIO_DEFAULT;
|
||||
+ priv->init_temp = EN7581_INIT_TEMP_FTK_X10;
|
||||
+ } else {
|
||||
+ priv->default_slope = EN7581_SLOPE_X100_DIO_AVS;
|
||||
+ priv->init_temp = EN7581_INIT_TEMP_CPK_X10;
|
||||
+ }
|
||||
+ } else {
|
||||
+ priv->default_offset = airoha_get_thermal_ADC(priv);
|
||||
+ priv->default_slope = EN7581_SLOPE_X100_DIO_DEFAULT;
|
||||
+ priv->init_temp = EN7581_INIT_TEMP_NONK_X10;
|
||||
+ dev_info(dev, "missing thermal calibrarion EFUSE, using non calibrated value\n");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void airoha_thermal_setup_monitor(struct airoha_thermal_priv *priv)
|
||||
+{
|
||||
+ /* Set measure mode */
|
||||
+ writel(FIELD_PREP(EN7581_MSRCTL0, EN7581_MSRCTL_6SAMPLE_MAX_MIX_AVG4),
|
||||
+ priv->base + EN7581_TEMPMSRCTL0);
|
||||
+
|
||||
+ /*
|
||||
+ * Configure ADC valid reading addr
|
||||
+ * The AHB temp monitor system doesn't have direct access to the
|
||||
+ * thermal sensor. It does instead work by providing all kind of
|
||||
+ * address to configure how to access and setup an ADC for the
|
||||
+ * sensor. EN7581 supports only one sensor hence the
|
||||
+ * implementation is greatly simplified but the AHB supports
|
||||
+ * up to 4 different sensor from the same ADC that can be
|
||||
+ * switched by tuning the ADC mux or wiriting address.
|
||||
+ *
|
||||
+ * We set valid instead of volt as we don't enable valid/volt
|
||||
+ * split reading and AHB read valid addr in such case.
|
||||
+ */
|
||||
+ writel(priv->scu_adc_res.start + EN7581_DOUT_TADC,
|
||||
+ priv->base + EN7581_TEMPADCVALIDADDR);
|
||||
+
|
||||
+ /*
|
||||
+ * Configure valid bit on a fake value of bit 16. The ADC outputs
|
||||
+ * max of 2 bytes for voltage.
|
||||
+ */
|
||||
+ writel(FIELD_PREP(EN7581_ADV_RD_VALID_POS, 16),
|
||||
+ priv->base + EN7581_TEMPADCVALIDMASK);
|
||||
+
|
||||
+ /*
|
||||
+ * AHB supports max 12 bytes for ADC voltage. Shift the read
|
||||
+ * value 4 bit to the right. Precision lost by this is minimal
|
||||
+ * in the order of half a °C and is acceptable in the context
|
||||
+ * of triggering interrupt in critical condition.
|
||||
+ */
|
||||
+ writel(FIELD_PREP(EN7581_ADC_VOLTAGE_SHIFT, 4),
|
||||
+ priv->base + EN7581_TEMPADCVOLTAGESHIFT);
|
||||
+
|
||||
+ /* BUS clock is 300MHz counting unit is 3 * 68.64 * 256 = 52.715us */
|
||||
+ writel(FIELD_PREP(EN7581_PERIOD_UNIT, 3),
|
||||
+ priv->base + EN7581_TEMPMONCTL1);
|
||||
+
|
||||
+ /*
|
||||
+ * filt interval is 1 * 52.715us = 52.715us,
|
||||
+ * sen interval is 379 * 52.715us = 19.97ms
|
||||
+ */
|
||||
+ writel(FIELD_PREP(EN7581_FILT_INTERVAL, 1) |
|
||||
+ FIELD_PREP(EN7581_FILT_INTERVAL, 379),
|
||||
+ priv->base + EN7581_TEMPMONCTL2);
|
||||
+
|
||||
+ /* AHB poll is set to 146 * 68.64 = 10.02us */
|
||||
+ writel(FIELD_PREP(EN7581_ADC_POLL_INTVL, 146),
|
||||
+ priv->base + EN7581_TEMPAHBPOLL);
|
||||
+}
|
||||
+
|
||||
+static int airoha_thermal_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct airoha_thermal_priv *priv;
|
||||
+ struct device_node *chip_scu_np;
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ int irq, ret;
|
||||
+
|
||||
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
+ if (!priv)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(priv->base))
|
||||
+ return PTR_ERR(priv->base);
|
||||
+
|
||||
+ chip_scu_np = of_parse_phandle(dev->of_node, "airoha,chip-scu", 0);
|
||||
+ if (!chip_scu_np)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ priv->chip_scu = syscon_node_to_regmap(chip_scu_np);
|
||||
+ if (IS_ERR(priv->chip_scu))
|
||||
+ return PTR_ERR(priv->chip_scu);
|
||||
+
|
||||
+ of_address_to_resource(chip_scu_np, 0, &priv->scu_adc_res);
|
||||
+ of_node_put(chip_scu_np);
|
||||
+
|
||||
+ irq = platform_get_irq(pdev, 0);
|
||||
+ if (irq < 0)
|
||||
+ return irq;
|
||||
+
|
||||
+ ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
|
||||
+ airoha_thermal_irq, IRQF_ONESHOT,
|
||||
+ pdev->name, priv);
|
||||
+ if (ret) {
|
||||
+ dev_err(dev, "Can't get interrupt working.\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ airoha_thermal_setup_monitor(priv);
|
||||
+ airoha_thermal_setup_adc_val(dev, priv);
|
||||
+
|
||||
+ /* register of thermal sensor and get info from DT */
|
||||
+ priv->tz = devm_thermal_of_zone_register(dev, 0, priv, &thdev_ops);
|
||||
+ if (IS_ERR(priv->tz)) {
|
||||
+ dev_err(dev, "register thermal zone sensor failed\n");
|
||||
+ return PTR_ERR(priv->tz);
|
||||
+ }
|
||||
+
|
||||
+ platform_set_drvdata(pdev, priv);
|
||||
+
|
||||
+ /* Enable LOW and HIGH interrupt */
|
||||
+ writel(EN7581_HOFSINTEN0 | EN7581_LOFSINTEN0,
|
||||
+ priv->base + EN7581_TEMPMONINT);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id airoha_thermal_match[] = {
|
||||
+ { .compatible = "airoha,en7581-thermal" },
|
||||
+ {},
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, airoha_thermal_match);
|
||||
+
|
||||
+static struct platform_driver airoha_thermal_driver = {
|
||||
+ .driver = {
|
||||
+ .name = "airoha-thermal",
|
||||
+ .of_match_table = airoha_thermal_match,
|
||||
+ },
|
||||
+ .probe = airoha_thermal_probe,
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(airoha_thermal_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
|
||||
+MODULE_DESCRIPTION("Airoha thermal driver");
|
||||
+MODULE_LICENSE("GPL");
|
||||
@ -1,44 +0,0 @@
|
||||
From e23cba0ab49a9cf95e9bc3a86cfbf336b0e285f6 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Wed, 14 May 2025 23:39:12 +0200
|
||||
Subject: [PATCH] thermal/drivers/airoha: Fix spelling mistake
|
||||
|
||||
Fix various spelling mistake in airoha_thermal_setup_monitor() and
|
||||
define.
|
||||
|
||||
Reported-by: Alok Tiwari <alok.a.tiwari@oracle.com>
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20250514213919.2321490-1-ansuelsmth@gmail.com
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
---
|
||||
drivers/thermal/airoha_thermal.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/airoha_thermal.c
|
||||
+++ b/drivers/thermal/airoha_thermal.c
|
||||
@@ -155,7 +155,7 @@
|
||||
* Can operate in:
|
||||
* - 1 sample
|
||||
* - 2 sample and make average of them
|
||||
- * - 4,6,10,16 sample, drop max and min and make avgerage of them
|
||||
+ * - 4,6,10,16 sample, drop max and min and make average of them
|
||||
*/
|
||||
#define EN7581_MSRCTL_1SAMPLE 0x0
|
||||
#define EN7581_MSRCTL_AVG2SAMPLE 0x1
|
||||
@@ -365,12 +365,12 @@ static void airoha_thermal_setup_monitor
|
||||
/*
|
||||
* Configure ADC valid reading addr
|
||||
* The AHB temp monitor system doesn't have direct access to the
|
||||
- * thermal sensor. It does instead work by providing all kind of
|
||||
- * address to configure how to access and setup an ADC for the
|
||||
+ * thermal sensor. It does instead work by providing various
|
||||
+ * addresses to configure how to access and setup an ADC for the
|
||||
* sensor. EN7581 supports only one sensor hence the
|
||||
* implementation is greatly simplified but the AHB supports
|
||||
- * up to 4 different sensor from the same ADC that can be
|
||||
- * switched by tuning the ADC mux or wiriting address.
|
||||
+ * up to 4 different sensors from the same ADC that can be
|
||||
+ * switched by tuning the ADC mux or writing address.
|
||||
*
|
||||
* We set valid instead of volt as we don't enable valid/volt
|
||||
* split reading and AHB read valid addr in such case.
|
||||
@ -1,435 +0,0 @@
|
||||
From 457d9772e8a5cdae64f66b5f7d5b0247365191ec Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Tue, 1 Apr 2025 15:50:21 +0200
|
||||
Subject: [PATCH] pinctrl: airoha: fix wrong PHY LED mapping and PHY2 LED
|
||||
defines
|
||||
|
||||
The current PHY2 LED define are wrong and actually set BITs outside the
|
||||
related mask. Fix it and set the correct value. While at it, also use
|
||||
FIELD_PREP_CONST macro to make it simple to understand what values are
|
||||
actually applied for the mask.
|
||||
|
||||
Also fix wrong PHY LED mapping. The SoC Switch supports up to 4 port but
|
||||
the register define mapping for 5 PHY port, starting from 0. The mapping
|
||||
was wrongly defined starting from PHY1. Reorder the function group to
|
||||
start from PHY0. PHY4 is actually never supported as we don't have a
|
||||
GPIO pin to assign.
|
||||
|
||||
Cc: stable@vger.kernel.org
|
||||
Fixes: 1c8ace2d0725 ("pinctrl: airoha: Add support for EN7581 SoC")
|
||||
Reviewed-by: Benjamin Larsson <benjamin.larsson@genexis.eu>
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://lore.kernel.org/20250401135026.18018-1-ansuelsmth@gmail.com
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-airoha.c | 159 ++++++++++------------
|
||||
1 file changed, 70 insertions(+), 89 deletions(-)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <dt-bindings/pinctrl/mt65xx.h>
|
||||
+#include <linux/bitfield.h>
|
||||
#include <linux/bits.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/gpio/driver.h>
|
||||
@@ -112,39 +113,19 @@
|
||||
#define REG_LAN_LED1_MAPPING 0x0280
|
||||
|
||||
#define LAN4_LED_MAPPING_MASK GENMASK(18, 16)
|
||||
-#define LAN4_PHY4_LED_MAP BIT(18)
|
||||
-#define LAN4_PHY2_LED_MAP BIT(17)
|
||||
-#define LAN4_PHY1_LED_MAP BIT(16)
|
||||
-#define LAN4_PHY0_LED_MAP 0
|
||||
-#define LAN4_PHY3_LED_MAP GENMASK(17, 16)
|
||||
+#define LAN4_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN4_LED_MAPPING_MASK, (_n))
|
||||
|
||||
#define LAN3_LED_MAPPING_MASK GENMASK(14, 12)
|
||||
-#define LAN3_PHY4_LED_MAP BIT(14)
|
||||
-#define LAN3_PHY2_LED_MAP BIT(13)
|
||||
-#define LAN3_PHY1_LED_MAP BIT(12)
|
||||
-#define LAN3_PHY0_LED_MAP 0
|
||||
-#define LAN3_PHY3_LED_MAP GENMASK(13, 12)
|
||||
+#define LAN3_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN3_LED_MAPPING_MASK, (_n))
|
||||
|
||||
#define LAN2_LED_MAPPING_MASK GENMASK(10, 8)
|
||||
-#define LAN2_PHY4_LED_MAP BIT(12)
|
||||
-#define LAN2_PHY2_LED_MAP BIT(11)
|
||||
-#define LAN2_PHY1_LED_MAP BIT(10)
|
||||
-#define LAN2_PHY0_LED_MAP 0
|
||||
-#define LAN2_PHY3_LED_MAP GENMASK(11, 10)
|
||||
+#define LAN2_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN2_LED_MAPPING_MASK, (_n))
|
||||
|
||||
#define LAN1_LED_MAPPING_MASK GENMASK(6, 4)
|
||||
-#define LAN1_PHY4_LED_MAP BIT(6)
|
||||
-#define LAN1_PHY2_LED_MAP BIT(5)
|
||||
-#define LAN1_PHY1_LED_MAP BIT(4)
|
||||
-#define LAN1_PHY0_LED_MAP 0
|
||||
-#define LAN1_PHY3_LED_MAP GENMASK(5, 4)
|
||||
+#define LAN1_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN1_LED_MAPPING_MASK, (_n))
|
||||
|
||||
#define LAN0_LED_MAPPING_MASK GENMASK(2, 0)
|
||||
-#define LAN0_PHY4_LED_MAP BIT(3)
|
||||
-#define LAN0_PHY2_LED_MAP BIT(2)
|
||||
-#define LAN0_PHY1_LED_MAP BIT(1)
|
||||
-#define LAN0_PHY0_LED_MAP 0
|
||||
-#define LAN0_PHY3_LED_MAP GENMASK(2, 1)
|
||||
+#define LAN0_PHY_LED_MAP(_n) FIELD_PREP_CONST(LAN0_LED_MAPPING_MASK, (_n))
|
||||
|
||||
/* CONF */
|
||||
#define REG_I2C_SDA_E2 0x001c
|
||||
@@ -1476,8 +1457,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN1_LED_MAPPING_MASK,
|
||||
- LAN1_PHY1_LED_MAP
|
||||
+ LAN0_LED_MAPPING_MASK,
|
||||
+ LAN0_PHY_LED_MAP(0)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1491,8 +1472,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN2_LED_MAPPING_MASK,
|
||||
- LAN2_PHY1_LED_MAP
|
||||
+ LAN1_LED_MAPPING_MASK,
|
||||
+ LAN1_PHY_LED_MAP(0)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1506,8 +1487,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN3_LED_MAPPING_MASK,
|
||||
- LAN3_PHY1_LED_MAP
|
||||
+ LAN2_LED_MAPPING_MASK,
|
||||
+ LAN2_PHY_LED_MAP(0)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1521,8 +1502,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN4_LED_MAPPING_MASK,
|
||||
- LAN4_PHY1_LED_MAP
|
||||
+ LAN3_LED_MAPPING_MASK,
|
||||
+ LAN3_PHY_LED_MAP(0)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
},
|
||||
@@ -1540,8 +1521,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN1_LED_MAPPING_MASK,
|
||||
- LAN1_PHY2_LED_MAP
|
||||
+ LAN0_LED_MAPPING_MASK,
|
||||
+ LAN0_PHY_LED_MAP(1)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1555,8 +1536,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN2_LED_MAPPING_MASK,
|
||||
- LAN2_PHY2_LED_MAP
|
||||
+ LAN1_LED_MAPPING_MASK,
|
||||
+ LAN1_PHY_LED_MAP(1)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1570,8 +1551,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN3_LED_MAPPING_MASK,
|
||||
- LAN3_PHY2_LED_MAP
|
||||
+ LAN2_LED_MAPPING_MASK,
|
||||
+ LAN2_PHY_LED_MAP(1)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1585,8 +1566,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN4_LED_MAPPING_MASK,
|
||||
- LAN4_PHY2_LED_MAP
|
||||
+ LAN3_LED_MAPPING_MASK,
|
||||
+ LAN3_PHY_LED_MAP(1)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
},
|
||||
@@ -1604,8 +1585,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN1_LED_MAPPING_MASK,
|
||||
- LAN1_PHY3_LED_MAP
|
||||
+ LAN0_LED_MAPPING_MASK,
|
||||
+ LAN0_PHY_LED_MAP(2)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1619,8 +1600,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN2_LED_MAPPING_MASK,
|
||||
- LAN2_PHY3_LED_MAP
|
||||
+ LAN1_LED_MAPPING_MASK,
|
||||
+ LAN1_PHY_LED_MAP(2)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1634,8 +1615,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN3_LED_MAPPING_MASK,
|
||||
- LAN3_PHY3_LED_MAP
|
||||
+ LAN2_LED_MAPPING_MASK,
|
||||
+ LAN2_PHY_LED_MAP(2)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1649,8 +1630,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN4_LED_MAPPING_MASK,
|
||||
- LAN4_PHY3_LED_MAP
|
||||
+ LAN3_LED_MAPPING_MASK,
|
||||
+ LAN3_PHY_LED_MAP(2)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
},
|
||||
@@ -1668,8 +1649,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN1_LED_MAPPING_MASK,
|
||||
- LAN1_PHY4_LED_MAP
|
||||
+ LAN0_LED_MAPPING_MASK,
|
||||
+ LAN0_PHY_LED_MAP(3)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1683,8 +1664,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN2_LED_MAPPING_MASK,
|
||||
- LAN2_PHY4_LED_MAP
|
||||
+ LAN1_LED_MAPPING_MASK,
|
||||
+ LAN1_PHY_LED_MAP(3)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1698,8 +1679,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN3_LED_MAPPING_MASK,
|
||||
- LAN3_PHY4_LED_MAP
|
||||
+ LAN2_LED_MAPPING_MASK,
|
||||
+ LAN2_PHY_LED_MAP(3)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1713,8 +1694,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED0_MAPPING,
|
||||
- LAN4_LED_MAPPING_MASK,
|
||||
- LAN4_PHY4_LED_MAP
|
||||
+ LAN3_LED_MAPPING_MASK,
|
||||
+ LAN3_PHY_LED_MAP(3)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
},
|
||||
@@ -1732,8 +1713,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN1_LED_MAPPING_MASK,
|
||||
- LAN1_PHY1_LED_MAP
|
||||
+ LAN0_LED_MAPPING_MASK,
|
||||
+ LAN0_PHY_LED_MAP(0)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1747,8 +1728,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN2_LED_MAPPING_MASK,
|
||||
- LAN2_PHY1_LED_MAP
|
||||
+ LAN1_LED_MAPPING_MASK,
|
||||
+ LAN1_PHY_LED_MAP(0)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1762,8 +1743,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN3_LED_MAPPING_MASK,
|
||||
- LAN3_PHY1_LED_MAP
|
||||
+ LAN2_LED_MAPPING_MASK,
|
||||
+ LAN2_PHY_LED_MAP(0)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1777,8 +1758,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN4_LED_MAPPING_MASK,
|
||||
- LAN4_PHY1_LED_MAP
|
||||
+ LAN3_LED_MAPPING_MASK,
|
||||
+ LAN3_PHY_LED_MAP(0)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
},
|
||||
@@ -1796,8 +1777,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN1_LED_MAPPING_MASK,
|
||||
- LAN1_PHY2_LED_MAP
|
||||
+ LAN0_LED_MAPPING_MASK,
|
||||
+ LAN0_PHY_LED_MAP(1)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1811,8 +1792,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN2_LED_MAPPING_MASK,
|
||||
- LAN2_PHY2_LED_MAP
|
||||
+ LAN1_LED_MAPPING_MASK,
|
||||
+ LAN1_PHY_LED_MAP(1)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1826,8 +1807,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN3_LED_MAPPING_MASK,
|
||||
- LAN3_PHY2_LED_MAP
|
||||
+ LAN2_LED_MAPPING_MASK,
|
||||
+ LAN2_PHY_LED_MAP(1)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1841,8 +1822,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN4_LED_MAPPING_MASK,
|
||||
- LAN4_PHY2_LED_MAP
|
||||
+ LAN3_LED_MAPPING_MASK,
|
||||
+ LAN3_PHY_LED_MAP(1)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
},
|
||||
@@ -1860,8 +1841,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN1_LED_MAPPING_MASK,
|
||||
- LAN1_PHY3_LED_MAP
|
||||
+ LAN0_LED_MAPPING_MASK,
|
||||
+ LAN0_PHY_LED_MAP(2)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1875,8 +1856,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN2_LED_MAPPING_MASK,
|
||||
- LAN2_PHY3_LED_MAP
|
||||
+ LAN1_LED_MAPPING_MASK,
|
||||
+ LAN1_PHY_LED_MAP(2)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1890,8 +1871,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN3_LED_MAPPING_MASK,
|
||||
- LAN3_PHY3_LED_MAP
|
||||
+ LAN2_LED_MAPPING_MASK,
|
||||
+ LAN2_PHY_LED_MAP(2)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1905,8 +1886,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN4_LED_MAPPING_MASK,
|
||||
- LAN4_PHY3_LED_MAP
|
||||
+ LAN3_LED_MAPPING_MASK,
|
||||
+ LAN3_PHY_LED_MAP(2)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
},
|
||||
@@ -1924,8 +1905,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN1_LED_MAPPING_MASK,
|
||||
- LAN1_PHY4_LED_MAP
|
||||
+ LAN0_LED_MAPPING_MASK,
|
||||
+ LAN0_PHY_LED_MAP(3)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1939,8 +1920,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN2_LED_MAPPING_MASK,
|
||||
- LAN2_PHY4_LED_MAP
|
||||
+ LAN1_LED_MAPPING_MASK,
|
||||
+ LAN1_PHY_LED_MAP(3)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1954,8 +1935,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN3_LED_MAPPING_MASK,
|
||||
- LAN3_PHY4_LED_MAP
|
||||
+ LAN2_LED_MAPPING_MASK,
|
||||
+ LAN2_PHY_LED_MAP(3)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
}, {
|
||||
@@ -1969,8 +1950,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_LAN_LED1_MAPPING,
|
||||
- LAN4_LED_MAPPING_MASK,
|
||||
- LAN4_PHY4_LED_MAP
|
||||
+ LAN3_LED_MAPPING_MASK,
|
||||
+ LAN3_PHY_LED_MAP(3)
|
||||
},
|
||||
.regmap_size = 2,
|
||||
},
|
||||
@ -1,59 +0,0 @@
|
||||
From 54d989d58d2ac87c8504c2306ba8b4957c60e8dc Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 4 Mar 2025 15:21:08 +0100
|
||||
Subject: [PATCH 1/6] net: airoha: Move min/max packet len configuration in
|
||||
airoha_dev_open()
|
||||
|
||||
In order to align max allowed packet size to the configured mtu, move
|
||||
REG_GDM_LEN_CFG configuration in airoha_dev_open routine.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250304-airoha-eth-rx-sg-v1-1-283ebc61120e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 14 +++++++-------
|
||||
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -138,15 +138,10 @@ static void airoha_fe_maccr_init(struct
|
||||
{
|
||||
int p;
|
||||
|
||||
- for (p = 1; p <= ARRAY_SIZE(eth->ports); p++) {
|
||||
+ for (p = 1; p <= ARRAY_SIZE(eth->ports); p++)
|
||||
airoha_fe_set(eth, REG_GDM_FWD_CFG(p),
|
||||
GDM_TCP_CKSUM | GDM_UDP_CKSUM | GDM_IP4_CKSUM |
|
||||
GDM_DROP_CRC_ERR);
|
||||
- airoha_fe_rmw(eth, REG_GDM_LEN_CFG(p),
|
||||
- GDM_SHORT_LEN_MASK | GDM_LONG_LEN_MASK,
|
||||
- FIELD_PREP(GDM_SHORT_LEN_MASK, 60) |
|
||||
- FIELD_PREP(GDM_LONG_LEN_MASK, 4004));
|
||||
- }
|
||||
|
||||
airoha_fe_rmw(eth, REG_CDM1_VLAN_CTRL, CDM1_VLAN_MASK,
|
||||
FIELD_PREP(CDM1_VLAN_MASK, 0x8100));
|
||||
@@ -1541,9 +1536,9 @@ static void airoha_update_hw_stats(struc
|
||||
|
||||
static int airoha_dev_open(struct net_device *dev)
|
||||
{
|
||||
+ int err, len = ETH_HLEN + dev->mtu + ETH_FCS_LEN;
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
struct airoha_qdma *qdma = port->qdma;
|
||||
- int err;
|
||||
|
||||
netif_tx_start_all_queues(dev);
|
||||
err = airoha_set_vip_for_gdm_port(port, true);
|
||||
@@ -1557,6 +1552,11 @@ static int airoha_dev_open(struct net_de
|
||||
airoha_fe_clear(qdma->eth, REG_GDM_INGRESS_CFG(port->id),
|
||||
GDM_STAG_EN_MASK);
|
||||
|
||||
+ airoha_fe_rmw(qdma->eth, REG_GDM_LEN_CFG(port->id),
|
||||
+ GDM_SHORT_LEN_MASK | GDM_LONG_LEN_MASK,
|
||||
+ FIELD_PREP(GDM_SHORT_LEN_MASK, 60) |
|
||||
+ FIELD_PREP(GDM_LONG_LEN_MASK, len));
|
||||
+
|
||||
airoha_qdma_set(qdma, REG_QDMA_GLOBAL_CFG,
|
||||
GLOBAL_CFG_TX_DMA_EN_MASK |
|
||||
GLOBAL_CFG_RX_DMA_EN_MASK);
|
||||
@ -1,170 +0,0 @@
|
||||
From e12182ddb6e712951d21a50e2c8ccd700e41a40c Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 4 Mar 2025 15:21:09 +0100
|
||||
Subject: [PATCH 2/6] net: airoha: Enable Rx Scatter-Gather
|
||||
|
||||
EN7581 SoC can receive 9k frames. Enable the reception of Scatter-Gather
|
||||
(SG) frames.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250304-airoha-eth-rx-sg-v1-2-283ebc61120e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 68 ++++++++++++++---------
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 1 +
|
||||
drivers/net/ethernet/airoha/airoha_regs.h | 5 ++
|
||||
3 files changed, 48 insertions(+), 26 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -615,10 +615,10 @@ static int airoha_qdma_rx_process(struct
|
||||
struct airoha_qdma_desc *desc = &q->desc[q->tail];
|
||||
u32 hash, reason, msg1 = le32_to_cpu(desc->msg1);
|
||||
dma_addr_t dma_addr = le32_to_cpu(desc->addr);
|
||||
+ struct page *page = virt_to_head_page(e->buf);
|
||||
u32 desc_ctrl = le32_to_cpu(desc->ctrl);
|
||||
struct airoha_gdm_port *port;
|
||||
- struct sk_buff *skb;
|
||||
- int len, p;
|
||||
+ int data_len, len, p;
|
||||
|
||||
if (!(desc_ctrl & QDMA_DESC_DONE_MASK))
|
||||
break;
|
||||
@@ -636,30 +636,41 @@ static int airoha_qdma_rx_process(struct
|
||||
dma_sync_single_for_cpu(eth->dev, dma_addr,
|
||||
SKB_WITH_OVERHEAD(q->buf_size), dir);
|
||||
|
||||
+ data_len = q->skb ? q->buf_size
|
||||
+ : SKB_WITH_OVERHEAD(q->buf_size);
|
||||
+ if (data_len < len)
|
||||
+ goto free_frag;
|
||||
+
|
||||
p = airoha_qdma_get_gdm_port(eth, desc);
|
||||
- if (p < 0 || !eth->ports[p]) {
|
||||
- page_pool_put_full_page(q->page_pool,
|
||||
- virt_to_head_page(e->buf),
|
||||
- true);
|
||||
- continue;
|
||||
- }
|
||||
+ if (p < 0 || !eth->ports[p])
|
||||
+ goto free_frag;
|
||||
|
||||
port = eth->ports[p];
|
||||
- skb = napi_build_skb(e->buf, q->buf_size);
|
||||
- if (!skb) {
|
||||
- page_pool_put_full_page(q->page_pool,
|
||||
- virt_to_head_page(e->buf),
|
||||
- true);
|
||||
- break;
|
||||
+ if (!q->skb) { /* first buffer */
|
||||
+ q->skb = napi_build_skb(e->buf, q->buf_size);
|
||||
+ if (!q->skb)
|
||||
+ goto free_frag;
|
||||
+
|
||||
+ __skb_put(q->skb, len);
|
||||
+ skb_mark_for_recycle(q->skb);
|
||||
+ q->skb->dev = port->dev;
|
||||
+ q->skb->protocol = eth_type_trans(q->skb, port->dev);
|
||||
+ q->skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
+ skb_record_rx_queue(q->skb, qid);
|
||||
+ } else { /* scattered frame */
|
||||
+ struct skb_shared_info *shinfo = skb_shinfo(q->skb);
|
||||
+ int nr_frags = shinfo->nr_frags;
|
||||
+
|
||||
+ if (nr_frags >= ARRAY_SIZE(shinfo->frags))
|
||||
+ goto free_frag;
|
||||
+
|
||||
+ skb_add_rx_frag(q->skb, nr_frags, page,
|
||||
+ e->buf - page_address(page), len,
|
||||
+ q->buf_size);
|
||||
}
|
||||
|
||||
- skb_reserve(skb, 2);
|
||||
- __skb_put(skb, len);
|
||||
- skb_mark_for_recycle(skb);
|
||||
- skb->dev = port->dev;
|
||||
- skb->protocol = eth_type_trans(skb, skb->dev);
|
||||
- skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
- skb_record_rx_queue(skb, qid);
|
||||
+ if (FIELD_GET(QDMA_DESC_MORE_MASK, desc_ctrl))
|
||||
+ continue;
|
||||
|
||||
if (netdev_uses_dsa(port->dev)) {
|
||||
/* PPE module requires untagged packets to work
|
||||
@@ -672,22 +683,27 @@ static int airoha_qdma_rx_process(struct
|
||||
|
||||
if (sptag < ARRAY_SIZE(port->dsa_meta) &&
|
||||
port->dsa_meta[sptag])
|
||||
- skb_dst_set_noref(skb,
|
||||
+ skb_dst_set_noref(q->skb,
|
||||
&port->dsa_meta[sptag]->dst);
|
||||
}
|
||||
|
||||
hash = FIELD_GET(AIROHA_RXD4_FOE_ENTRY, msg1);
|
||||
if (hash != AIROHA_RXD4_FOE_ENTRY)
|
||||
- skb_set_hash(skb, jhash_1word(hash, 0),
|
||||
+ skb_set_hash(q->skb, jhash_1word(hash, 0),
|
||||
PKT_HASH_TYPE_L4);
|
||||
|
||||
reason = FIELD_GET(AIROHA_RXD4_PPE_CPU_REASON, msg1);
|
||||
if (reason == PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
|
||||
airoha_ppe_check_skb(eth->ppe, hash);
|
||||
|
||||
- napi_gro_receive(&q->napi, skb);
|
||||
-
|
||||
done++;
|
||||
+ napi_gro_receive(&q->napi, q->skb);
|
||||
+ q->skb = NULL;
|
||||
+ continue;
|
||||
+free_frag:
|
||||
+ page_pool_put_full_page(q->page_pool, page, true);
|
||||
+ dev_kfree_skb(q->skb);
|
||||
+ q->skb = NULL;
|
||||
}
|
||||
airoha_qdma_fill_rx_queue(q);
|
||||
|
||||
@@ -762,6 +778,7 @@ static int airoha_qdma_init_rx_queue(str
|
||||
FIELD_PREP(RX_RING_THR_MASK, thr));
|
||||
airoha_qdma_rmw(qdma, REG_RX_DMA_IDX(qid), RX_RING_DMA_IDX_MASK,
|
||||
FIELD_PREP(RX_RING_DMA_IDX_MASK, q->head));
|
||||
+ airoha_qdma_set(qdma, REG_RX_SCATTER_CFG(qid), RX_RING_SG_EN_MASK);
|
||||
|
||||
airoha_qdma_fill_rx_queue(q);
|
||||
|
||||
@@ -1182,7 +1199,6 @@ static int airoha_qdma_hw_init(struct ai
|
||||
}
|
||||
|
||||
airoha_qdma_wr(qdma, REG_QDMA_GLOBAL_CFG,
|
||||
- GLOBAL_CFG_RX_2B_OFFSET_MASK |
|
||||
FIELD_PREP(GLOBAL_CFG_DMA_PREFERENCE_MASK, 3) |
|
||||
GLOBAL_CFG_CPU_TXR_RR_MASK |
|
||||
GLOBAL_CFG_PAYLOAD_BYTE_SWAP_MASK |
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -176,6 +176,7 @@ struct airoha_queue {
|
||||
|
||||
struct napi_struct napi;
|
||||
struct page_pool *page_pool;
|
||||
+ struct sk_buff *skb;
|
||||
};
|
||||
|
||||
struct airoha_tx_irq_queue {
|
||||
--- a/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
@@ -626,10 +626,15 @@
|
||||
#define REG_RX_DELAY_INT_IDX(_n) \
|
||||
(((_n) < 16) ? 0x0210 + ((_n) << 5) : 0x0e10 + (((_n) - 16) << 5))
|
||||
|
||||
+#define REG_RX_SCATTER_CFG(_n) \
|
||||
+ (((_n) < 16) ? 0x0214 + ((_n) << 5) : 0x0e14 + (((_n) - 16) << 5))
|
||||
+
|
||||
#define RX_DELAY_INT_MASK GENMASK(15, 0)
|
||||
|
||||
#define RX_RING_DMA_IDX_MASK GENMASK(15, 0)
|
||||
|
||||
+#define RX_RING_SG_EN_MASK BIT(0)
|
||||
+
|
||||
#define REG_INGRESS_TRTCM_CFG 0x0070
|
||||
#define INGRESS_TRTCM_EN_MASK BIT(31)
|
||||
#define INGRESS_TRTCM_MODE_MASK BIT(30)
|
||||
@ -1,47 +0,0 @@
|
||||
From 03b1b69f0662c46f258a45e4a7d7837351c11692 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 4 Mar 2025 15:21:10 +0100
|
||||
Subject: [PATCH 3/6] net: airoha: Introduce airoha_dev_change_mtu callback
|
||||
|
||||
Add airoha_dev_change_mtu callback to update the MTU of a running
|
||||
device.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250304-airoha-eth-rx-sg-v1-3-283ebc61120e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 15 +++++++++++++++
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -1726,6 +1726,20 @@ static void airoha_dev_get_stats64(struc
|
||||
} while (u64_stats_fetch_retry(&port->stats.syncp, start));
|
||||
}
|
||||
|
||||
+static int airoha_dev_change_mtu(struct net_device *dev, int mtu)
|
||||
+{
|
||||
+ struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
+ struct airoha_eth *eth = port->qdma->eth;
|
||||
+ u32 len = ETH_HLEN + mtu + ETH_FCS_LEN;
|
||||
+
|
||||
+ airoha_fe_rmw(eth, REG_GDM_LEN_CFG(port->id),
|
||||
+ GDM_LONG_LEN_MASK,
|
||||
+ FIELD_PREP(GDM_LONG_LEN_MASK, len));
|
||||
+ WRITE_ONCE(dev->mtu, mtu);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static u16 airoha_dev_select_queue(struct net_device *dev, struct sk_buff *skb,
|
||||
struct net_device *sb_dev)
|
||||
{
|
||||
@@ -2418,6 +2432,7 @@ static const struct net_device_ops airoh
|
||||
.ndo_init = airoha_dev_init,
|
||||
.ndo_open = airoha_dev_open,
|
||||
.ndo_stop = airoha_dev_stop,
|
||||
+ .ndo_change_mtu = airoha_dev_change_mtu,
|
||||
.ndo_select_queue = airoha_dev_select_queue,
|
||||
.ndo_start_xmit = airoha_dev_xmit,
|
||||
.ndo_get_stats64 = airoha_dev_get_stats64,
|
||||
@ -1,26 +0,0 @@
|
||||
From 168ef0c1dee83c401896a0bca680e9f97b1ebd64 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 4 Mar 2025 15:21:11 +0100
|
||||
Subject: [PATCH 4/6] net: airoha: Increase max mtu to 9k
|
||||
|
||||
EN7581 SoC supports 9k maximum MTU.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250304-airoha-eth-rx-sg-v1-4-283ebc61120e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -20,7 +20,7 @@
|
||||
#define AIROHA_MAX_DSA_PORTS 7
|
||||
#define AIROHA_MAX_NUM_RSTS 3
|
||||
#define AIROHA_MAX_NUM_XSI_RSTS 5
|
||||
-#define AIROHA_MAX_MTU 2000
|
||||
+#define AIROHA_MAX_MTU 9216
|
||||
#define AIROHA_MAX_PACKET_SIZE 2048
|
||||
#define AIROHA_NUM_QOS_CHANNELS 4
|
||||
#define AIROHA_NUM_QOS_QUEUES 8
|
||||
@ -1,29 +0,0 @@
|
||||
From 35ea4f06fd33fc32f556a0c26d1d8340497fa7f8 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 4 Mar 2025 15:38:05 +0100
|
||||
Subject: [PATCH 5/6] net: airoha: Fix lan4 support in
|
||||
airoha_qdma_get_gdm_port()
|
||||
|
||||
EN7581 SoC supports lan{1,4} ports on MT7530 DSA switch. Fix lan4
|
||||
reported value in airoha_qdma_get_gdm_port routine.
|
||||
|
||||
Fixes: 23020f0493270 ("net: airoha: Introduce ethernet support for EN7581 SoC")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250304-airoha-eth-fix-lan4-v1-1-832417da4bb5@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -589,7 +589,7 @@ static int airoha_qdma_get_gdm_port(stru
|
||||
|
||||
sport = FIELD_GET(QDMA_ETH_RXMSG_SPORT_MASK, msg1);
|
||||
switch (sport) {
|
||||
- case 0x10 ... 0x13:
|
||||
+ case 0x10 ... 0x14:
|
||||
port = 0;
|
||||
break;
|
||||
case 0x2 ... 0x4:
|
||||
@ -1,27 +0,0 @@
|
||||
From a202dfe31cae2f2120297a7142385d80a5577d42 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 4 Mar 2025 16:46:40 +0100
|
||||
Subject: [PATCH 6/6] net: airoha: Enable TSO/Scatter Gather for LAN port
|
||||
|
||||
Set net_device vlan_features in order to enable TSO and Scatter Gather
|
||||
for DSA user ports.
|
||||
|
||||
Reviewed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250304-lan-enable-tso-v1-1-b398eb9976ba@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -2523,6 +2523,7 @@ static int airoha_alloc_gdm_port(struct
|
||||
NETIF_F_SG | NETIF_F_TSO |
|
||||
NETIF_F_HW_TC;
|
||||
dev->features |= dev->hw_features;
|
||||
+ dev->vlan_features = dev->hw_features;
|
||||
dev->dev.of_node = np;
|
||||
dev->irq = qdma->irq;
|
||||
SET_NETDEV_DEV(dev, eth->dev);
|
||||
@ -1,47 +0,0 @@
|
||||
From e368d2a1e8b6f0926e4e76a56b484249905192f5 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 6 Mar 2025 11:52:20 +0100
|
||||
Subject: [PATCH] net: airoha: Fix dev->dsa_ptr check in airoha_get_dsa_tag()
|
||||
|
||||
Fix the following warning reported by Smatch static checker in
|
||||
airoha_get_dsa_tag routine:
|
||||
|
||||
drivers/net/ethernet/airoha/airoha_eth.c:1722 airoha_get_dsa_tag()
|
||||
warn: 'dp' isn't an ERR_PTR
|
||||
|
||||
dev->dsa_ptr can't be set to an error pointer, it can just be NULL.
|
||||
Remove this check since it is already performed in netdev_uses_dsa().
|
||||
|
||||
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
|
||||
Closes: https://lore.kernel.org/netdev/Z8l3E0lGOcrel07C@lore-desk/T/#m54adc113fcdd8c5e6c5f65ffd60d8e8b1d483d90
|
||||
Fixes: af3cf757d5c9 ("net: airoha: Move DSA tag in DMA descriptor")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250306-airoha-flowtable-fixes-v1-1-68d3c1296cdd@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 7 +------
|
||||
1 file changed, 1 insertion(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -1762,18 +1762,13 @@ static u32 airoha_get_dsa_tag(struct sk_
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_NET_DSA)
|
||||
struct ethhdr *ehdr;
|
||||
- struct dsa_port *dp;
|
||||
u8 xmit_tpid;
|
||||
u16 tag;
|
||||
|
||||
if (!netdev_uses_dsa(dev))
|
||||
return 0;
|
||||
|
||||
- dp = dev->dsa_ptr;
|
||||
- if (IS_ERR(dp))
|
||||
- return 0;
|
||||
-
|
||||
- if (dp->tag_ops->proto != DSA_TAG_PROTO_MTK)
|
||||
+ if (dev->dsa_ptr->tag_ops->proto != DSA_TAG_PROTO_MTK)
|
||||
return 0;
|
||||
|
||||
if (skb_cow_head(skb, 0))
|
||||
@ -1,35 +0,0 @@
|
||||
From 08d0185e36ad8bb5902a73711bf114765d282161 Mon Sep 17 00:00:00 2001
|
||||
From: Arnd Bergmann <arnd@arndb.de>
|
||||
Date: Fri, 14 Mar 2025 16:49:59 +0100
|
||||
Subject: [PATCH] net: airoha: fix CONFIG_DEBUG_FS check
|
||||
|
||||
The #if check causes a build failure when CONFIG_DEBUG_FS is turned
|
||||
off:
|
||||
|
||||
In file included from drivers/net/ethernet/airoha/airoha_eth.c:17:
|
||||
drivers/net/ethernet/airoha/airoha_eth.h:543:5: error: "CONFIG_DEBUG_FS" is not defined, evaluates to 0 [-Werror=undef]
|
||||
543 | #if CONFIG_DEBUG_FS
|
||||
| ^~~~~~~~~~~~~~~
|
||||
|
||||
Replace it with the correct #ifdef.
|
||||
|
||||
Fixes: 3fe15c640f38 ("net: airoha: Introduce PPE debugfs support")
|
||||
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
|
||||
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250314155009.4114308-1-arnd@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -540,7 +540,7 @@ void airoha_ppe_deinit(struct airoha_eth
|
||||
struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
|
||||
u32 hash);
|
||||
|
||||
-#if CONFIG_DEBUG_FS
|
||||
+#ifdef CONFIG_DEBUG_FS
|
||||
int airoha_ppe_debugfs_init(struct airoha_ppe *ppe);
|
||||
#else
|
||||
static inline int airoha_ppe_debugfs_init(struct airoha_ppe *ppe)
|
||||
@ -1,77 +0,0 @@
|
||||
From 57b290d97c6150774bf929117ca737a26d8fc33d Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 31 Mar 2025 08:52:53 +0200
|
||||
Subject: [PATCH 1/2] net: airoha: Fix qid report in
|
||||
airoha_tc_get_htb_get_leaf_queue()
|
||||
|
||||
Fix the following kernel warning deleting HTB offloaded leafs and/or root
|
||||
HTB qdisc in airoha_eth driver properly reporting qid in
|
||||
airoha_tc_get_htb_get_leaf_queue routine.
|
||||
|
||||
$tc qdisc replace dev eth1 root handle 10: htb offload
|
||||
$tc class add dev eth1 arent 10: classid 10:4 htb rate 100mbit ceil 100mbit
|
||||
$tc qdisc replace dev eth1 parent 10:4 handle 4: ets bands 8 \
|
||||
quanta 1514 3028 4542 6056 7570 9084 10598 12112
|
||||
$tc qdisc del dev eth1 root
|
||||
|
||||
[ 55.827864] ------------[ cut here ]------------
|
||||
[ 55.832493] WARNING: CPU: 3 PID: 2678 at 0xffffffc0798695a4
|
||||
[ 55.956510] CPU: 3 PID: 2678 Comm: tc Tainted: G O 6.6.71 #0
|
||||
[ 55.963557] Hardware name: Airoha AN7581 Evaluation Board (DT)
|
||||
[ 55.969383] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
|
||||
[ 55.976344] pc : 0xffffffc0798695a4
|
||||
[ 55.979851] lr : 0xffffffc079869a20
|
||||
[ 55.983358] sp : ffffffc0850536a0
|
||||
[ 55.986665] x29: ffffffc0850536a0 x28: 0000000000000024 x27: 0000000000000001
|
||||
[ 55.993800] x26: 0000000000000000 x25: ffffff8008b19000 x24: ffffff800222e800
|
||||
[ 56.000935] x23: 0000000000000001 x22: 0000000000000000 x21: ffffff8008b19000
|
||||
[ 56.008071] x20: ffffff8002225800 x19: ffffff800379d000 x18: 0000000000000000
|
||||
[ 56.015206] x17: ffffffbf9ea59000 x16: ffffffc080018000 x15: 0000000000000000
|
||||
[ 56.022342] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000001
|
||||
[ 56.029478] x11: ffffffc081471008 x10: ffffffc081575a98 x9 : 0000000000000000
|
||||
[ 56.036614] x8 : ffffffc08167fd40 x7 : ffffffc08069e104 x6 : ffffff8007f86000
|
||||
[ 56.043748] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000001
|
||||
[ 56.050884] x2 : 0000000000000000 x1 : 0000000000000250 x0 : ffffff800222c000
|
||||
[ 56.058020] Call trace:
|
||||
[ 56.060459] 0xffffffc0798695a4
|
||||
[ 56.063618] 0xffffffc079869a20
|
||||
[ 56.066777] __qdisc_destroy+0x40/0xa0
|
||||
[ 56.070528] qdisc_put+0x54/0x6c
|
||||
[ 56.073748] qdisc_graft+0x41c/0x648
|
||||
[ 56.077324] tc_get_qdisc+0x168/0x2f8
|
||||
[ 56.080978] rtnetlink_rcv_msg+0x230/0x330
|
||||
[ 56.085076] netlink_rcv_skb+0x5c/0x128
|
||||
[ 56.088913] rtnetlink_rcv+0x14/0x1c
|
||||
[ 56.092490] netlink_unicast+0x1e0/0x2c8
|
||||
[ 56.096413] netlink_sendmsg+0x198/0x3c8
|
||||
[ 56.100337] ____sys_sendmsg+0x1c4/0x274
|
||||
[ 56.104261] ___sys_sendmsg+0x7c/0xc0
|
||||
[ 56.107924] __sys_sendmsg+0x44/0x98
|
||||
[ 56.111492] __arm64_sys_sendmsg+0x20/0x28
|
||||
[ 56.115580] invoke_syscall.constprop.0+0x58/0xfc
|
||||
[ 56.120285] do_el0_svc+0x3c/0xbc
|
||||
[ 56.123592] el0_svc+0x18/0x4c
|
||||
[ 56.126647] el0t_64_sync_handler+0x118/0x124
|
||||
[ 56.131005] el0t_64_sync+0x150/0x154
|
||||
[ 56.134660] ---[ end trace 0000000000000000 ]---
|
||||
|
||||
Fixes: ef1ca9271313b ("net: airoha: Add sched HTB offload support")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Acked-by: Paolo Abeni <pabeni@redhat.com>
|
||||
Link: https://patch.msgid.link/20250331-airoha-htb-qdisc-offload-del-fix-v1-1-4ea429c2c968@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -2376,7 +2376,7 @@ static int airoha_tc_get_htb_get_leaf_qu
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- opt->qid = channel;
|
||||
+ opt->qid = AIROHA_NUM_TX_RING + channel;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
From 367579274f60cb23c570ae5348966ab51e1509a4 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 31 Mar 2025 18:17:31 +0200
|
||||
Subject: [PATCH 2/2] net: airoha: Fix ETS priomap validation
|
||||
|
||||
ETS Qdisc schedules SP bands in a priority order assigning band-0 the
|
||||
highest priority (band-0 > band-1 > .. > band-n) while EN7581 arranges
|
||||
SP bands in a priority order assigning band-7 the highest priority
|
||||
(band-7 > band-6, .. > band-n).
|
||||
Fix priomap check in airoha_qdma_set_tx_ets_sched routine in order to
|
||||
align ETS Qdisc and airoha_eth driver SP priority ordering.
|
||||
|
||||
Fixes: b56e4d660a96 ("net: airoha: Enforce ETS Qdisc priomap")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Reviewed-by: Davide Caratti <dcaratti@redhat.com>
|
||||
Link: https://patch.msgid.link/20250331-airoha-ets-validate-priomap-v1-1-60a524488672@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 16 ++++++++--------
|
||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -2049,7 +2049,7 @@ static int airoha_qdma_set_tx_ets_sched(
|
||||
struct tc_ets_qopt_offload_replace_params *p = &opt->replace_params;
|
||||
enum tx_sched_mode mode = TC_SCH_SP;
|
||||
u16 w[AIROHA_NUM_QOS_QUEUES] = {};
|
||||
- int i, nstrict = 0, nwrr, qidx;
|
||||
+ int i, nstrict = 0;
|
||||
|
||||
if (p->bands > AIROHA_NUM_QOS_QUEUES)
|
||||
return -EINVAL;
|
||||
@@ -2067,17 +2067,17 @@ static int airoha_qdma_set_tx_ets_sched(
|
||||
* lowest priorities with respect to SP ones.
|
||||
* e.g: WRR0, WRR1, .., WRRm, SP0, SP1, .., SPn
|
||||
*/
|
||||
- nwrr = p->bands - nstrict;
|
||||
- qidx = nstrict && nwrr ? nstrict : 0;
|
||||
- for (i = 1; i <= p->bands; i++) {
|
||||
- if (p->priomap[i % AIROHA_NUM_QOS_QUEUES] != qidx)
|
||||
+ for (i = 0; i < nstrict; i++) {
|
||||
+ if (p->priomap[p->bands - i - 1] != i)
|
||||
return -EINVAL;
|
||||
-
|
||||
- qidx = i == nwrr ? 0 : qidx + 1;
|
||||
}
|
||||
|
||||
- for (i = 0; i < nwrr; i++)
|
||||
+ for (i = 0; i < p->bands - nstrict; i++) {
|
||||
+ if (p->priomap[i] != nstrict + i)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
w[i] = p->weights[nstrict + i];
|
||||
+ }
|
||||
|
||||
if (!nstrict)
|
||||
mode = TC_SCH_WRR8;
|
||||
@ -1,100 +0,0 @@
|
||||
From 09bccf56db36501ccb1935d921dc24451e9f57dd Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 1 Apr 2025 11:42:30 +0200
|
||||
Subject: [PATCH] net: airoha: Validate egress gdm port in
|
||||
airoha_ppe_foe_entry_prepare()
|
||||
|
||||
Dev pointer in airoha_ppe_foe_entry_prepare routine is not strictly
|
||||
a device allocated by airoha_eth driver since it is an egress device
|
||||
and the flowtable can contain even wlan, pppoe or vlan devices. E.g:
|
||||
|
||||
flowtable ft {
|
||||
hook ingress priority filter
|
||||
devices = { eth1, lan1, lan2, lan3, lan4, wlan0 }
|
||||
flags offload ^
|
||||
|
|
||||
"not allocated by airoha_eth" --
|
||||
}
|
||||
|
||||
In this case airoha_get_dsa_port() will just return the original device
|
||||
pointer and we can't assume netdev priv pointer points to an
|
||||
airoha_gdm_port struct.
|
||||
Fix the issue validating egress gdm port in airoha_ppe_foe_entry_prepare
|
||||
routine before accessing net_device priv pointer.
|
||||
|
||||
Fixes: 00a7678310fe ("net: airoha: Introduce flowtable offload support")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250401-airoha-validate-egress-gdm-port-v4-1-c7315d33ce10@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 13 +++++++++++++
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 3 +++
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 8 ++++++--
|
||||
3 files changed, 22 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -2472,6 +2472,19 @@ static void airoha_metadata_dst_free(str
|
||||
}
|
||||
}
|
||||
|
||||
+bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
|
||||
+ struct airoha_gdm_port *port)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
|
||||
+ if (eth->ports[i] == port)
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
static int airoha_alloc_gdm_port(struct airoha_eth *eth,
|
||||
struct device_node *np, int index)
|
||||
{
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -532,6 +532,9 @@ u32 airoha_rmw(void __iomem *base, u32 o
|
||||
#define airoha_qdma_clear(qdma, offset, val) \
|
||||
airoha_rmw((qdma)->regs, (offset), (val), 0)
|
||||
|
||||
+bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
|
||||
+ struct airoha_gdm_port *port);
|
||||
+
|
||||
void airoha_ppe_check_skb(struct airoha_ppe *ppe, u16 hash);
|
||||
int airoha_ppe_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
||||
void *cb_priv);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -197,7 +197,8 @@ static int airoha_get_dsa_port(struct ne
|
||||
#endif
|
||||
}
|
||||
|
||||
-static int airoha_ppe_foe_entry_prepare(struct airoha_foe_entry *hwe,
|
||||
+static int airoha_ppe_foe_entry_prepare(struct airoha_eth *eth,
|
||||
+ struct airoha_foe_entry *hwe,
|
||||
struct net_device *dev, int type,
|
||||
struct airoha_flow_data *data,
|
||||
int l4proto)
|
||||
@@ -225,6 +226,9 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
u8 pse_port;
|
||||
|
||||
+ if (!airoha_is_valid_gdm_port(eth, port))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
if (dsa_port >= 0)
|
||||
pse_port = port->id == 4 ? FE_PSE_PORT_GDM4 : port->id;
|
||||
else
|
||||
@@ -633,7 +637,7 @@ static int airoha_ppe_flow_offload_repla
|
||||
!is_valid_ether_addr(data.eth.h_dest))
|
||||
return -EINVAL;
|
||||
|
||||
- err = airoha_ppe_foe_entry_prepare(&hwe, odev, offload_type,
|
||||
+ err = airoha_ppe_foe_entry_prepare(eth, &hwe, odev, offload_type,
|
||||
&data, l4proto);
|
||||
if (err)
|
||||
return err;
|
||||
@ -1,207 +0,0 @@
|
||||
From b4916f67902e2ae1dc8e37dfa45e8894ad2f8921 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 9 Apr 2025 11:47:14 +0200
|
||||
Subject: [PATCH 1/2] net: airoha: Add l2_flows rhashtable
|
||||
|
||||
Introduce l2_flows rhashtable in airoha_ppe struct in order to
|
||||
store L2 flows committed by upper layers of the kernel. This is a
|
||||
preliminary patch in order to offload L2 traffic rules.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
|
||||
Link: https://patch.msgid.link/20250409-airoha-flowtable-l2b-v2-1-4a1e3935ea92@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 15 +++-
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 103 ++++++++++++++++++-----
|
||||
2 files changed, 98 insertions(+), 20 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -422,12 +422,23 @@ struct airoha_flow_data {
|
||||
} pppoe;
|
||||
};
|
||||
|
||||
+enum airoha_flow_entry_type {
|
||||
+ FLOW_TYPE_L4,
|
||||
+ FLOW_TYPE_L2,
|
||||
+ FLOW_TYPE_L2_SUBFLOW,
|
||||
+};
|
||||
+
|
||||
struct airoha_flow_table_entry {
|
||||
- struct hlist_node list;
|
||||
+ union {
|
||||
+ struct hlist_node list; /* PPE L3 flow entry */
|
||||
+ struct rhash_head l2_node; /* L2 flow entry */
|
||||
+ };
|
||||
|
||||
struct airoha_foe_entry data;
|
||||
u32 hash;
|
||||
|
||||
+ enum airoha_flow_entry_type type;
|
||||
+
|
||||
struct rhash_head node;
|
||||
unsigned long cookie;
|
||||
};
|
||||
@@ -480,6 +491,8 @@ struct airoha_ppe {
|
||||
void *foe;
|
||||
dma_addr_t foe_dma;
|
||||
|
||||
+ struct rhashtable l2_flows;
|
||||
+
|
||||
struct hlist_head *foe_flow;
|
||||
u16 foe_check_time[PPE_NUM_ENTRIES];
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -24,6 +24,13 @@ static const struct rhashtable_params ai
|
||||
.automatic_shrinking = true,
|
||||
};
|
||||
|
||||
+static const struct rhashtable_params airoha_l2_flow_table_params = {
|
||||
+ .head_offset = offsetof(struct airoha_flow_table_entry, l2_node),
|
||||
+ .key_offset = offsetof(struct airoha_flow_table_entry, data.bridge),
|
||||
+ .key_len = 2 * ETH_ALEN,
|
||||
+ .automatic_shrinking = true,
|
||||
+};
|
||||
+
|
||||
static bool airoha_ppe2_is_enabled(struct airoha_eth *eth)
|
||||
{
|
||||
return airoha_fe_rr(eth, REG_PPE_GLO_CFG(1)) & PPE_GLO_CFG_EN_MASK;
|
||||
@@ -476,6 +483,43 @@ static int airoha_ppe_foe_commit_entry(s
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void airoha_ppe_foe_remove_flow(struct airoha_ppe *ppe,
|
||||
+ struct airoha_flow_table_entry *e)
|
||||
+{
|
||||
+ lockdep_assert_held(&ppe_lock);
|
||||
+
|
||||
+ hlist_del_init(&e->list);
|
||||
+ if (e->hash != 0xffff) {
|
||||
+ e->data.ib1 &= ~AIROHA_FOE_IB1_BIND_STATE;
|
||||
+ e->data.ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE,
|
||||
+ AIROHA_FOE_STATE_INVALID);
|
||||
+ airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash);
|
||||
+ e->hash = 0xffff;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void airoha_ppe_foe_remove_l2_flow(struct airoha_ppe *ppe,
|
||||
+ struct airoha_flow_table_entry *e)
|
||||
+{
|
||||
+ lockdep_assert_held(&ppe_lock);
|
||||
+
|
||||
+ rhashtable_remove_fast(&ppe->l2_flows, &e->l2_node,
|
||||
+ airoha_l2_flow_table_params);
|
||||
+}
|
||||
+
|
||||
+static void airoha_ppe_foe_flow_remove_entry(struct airoha_ppe *ppe,
|
||||
+ struct airoha_flow_table_entry *e)
|
||||
+{
|
||||
+ spin_lock_bh(&ppe_lock);
|
||||
+
|
||||
+ if (e->type == FLOW_TYPE_L2)
|
||||
+ airoha_ppe_foe_remove_l2_flow(ppe, e);
|
||||
+ else
|
||||
+ airoha_ppe_foe_remove_flow(ppe, e);
|
||||
+
|
||||
+ spin_unlock_bh(&ppe_lock);
|
||||
+}
|
||||
+
|
||||
static void airoha_ppe_foe_insert_entry(struct airoha_ppe *ppe, u32 hash)
|
||||
{
|
||||
struct airoha_flow_table_entry *e;
|
||||
@@ -505,11 +549,37 @@ unlock:
|
||||
spin_unlock_bh(&ppe_lock);
|
||||
}
|
||||
|
||||
+static int
|
||||
+airoha_ppe_foe_l2_flow_commit_entry(struct airoha_ppe *ppe,
|
||||
+ struct airoha_flow_table_entry *e)
|
||||
+{
|
||||
+ struct airoha_flow_table_entry *prev;
|
||||
+
|
||||
+ e->type = FLOW_TYPE_L2;
|
||||
+ prev = rhashtable_lookup_get_insert_fast(&ppe->l2_flows, &e->l2_node,
|
||||
+ airoha_l2_flow_table_params);
|
||||
+ if (!prev)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (IS_ERR(prev))
|
||||
+ return PTR_ERR(prev);
|
||||
+
|
||||
+ return rhashtable_replace_fast(&ppe->l2_flows, &prev->l2_node,
|
||||
+ &e->l2_node,
|
||||
+ airoha_l2_flow_table_params);
|
||||
+}
|
||||
+
|
||||
static int airoha_ppe_foe_flow_commit_entry(struct airoha_ppe *ppe,
|
||||
struct airoha_flow_table_entry *e)
|
||||
{
|
||||
- u32 hash = airoha_ppe_foe_get_entry_hash(&e->data);
|
||||
+ int type = FIELD_GET(AIROHA_FOE_IB1_BIND_PACKET_TYPE, e->data.ib1);
|
||||
+ u32 hash;
|
||||
|
||||
+ if (type == PPE_PKT_TYPE_BRIDGE)
|
||||
+ return airoha_ppe_foe_l2_flow_commit_entry(ppe, e);
|
||||
+
|
||||
+ hash = airoha_ppe_foe_get_entry_hash(&e->data);
|
||||
+ e->type = FLOW_TYPE_L4;
|
||||
e->hash = 0xffff;
|
||||
|
||||
spin_lock_bh(&ppe_lock);
|
||||
@@ -519,23 +589,6 @@ static int airoha_ppe_foe_flow_commit_en
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static void airoha_ppe_foe_flow_remove_entry(struct airoha_ppe *ppe,
|
||||
- struct airoha_flow_table_entry *e)
|
||||
-{
|
||||
- spin_lock_bh(&ppe_lock);
|
||||
-
|
||||
- hlist_del_init(&e->list);
|
||||
- if (e->hash != 0xffff) {
|
||||
- e->data.ib1 &= ~AIROHA_FOE_IB1_BIND_STATE;
|
||||
- e->data.ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE,
|
||||
- AIROHA_FOE_STATE_INVALID);
|
||||
- airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash);
|
||||
- e->hash = 0xffff;
|
||||
- }
|
||||
-
|
||||
- spin_unlock_bh(&ppe_lock);
|
||||
-}
|
||||
-
|
||||
static int airoha_ppe_flow_offload_replace(struct airoha_gdm_port *port,
|
||||
struct flow_cls_offload *f)
|
||||
{
|
||||
@@ -890,9 +943,20 @@ int airoha_ppe_init(struct airoha_eth *e
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
+ err = rhashtable_init(&ppe->l2_flows, &airoha_l2_flow_table_params);
|
||||
+ if (err)
|
||||
+ goto error_flow_table_destroy;
|
||||
+
|
||||
err = airoha_ppe_debugfs_init(ppe);
|
||||
if (err)
|
||||
- rhashtable_destroy(ð->flow_table);
|
||||
+ goto error_l2_flow_table_destroy;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+error_l2_flow_table_destroy:
|
||||
+ rhashtable_destroy(&ppe->l2_flows);
|
||||
+error_flow_table_destroy:
|
||||
+ rhashtable_destroy(ð->flow_table);
|
||||
|
||||
return err;
|
||||
}
|
||||
@@ -909,6 +973,7 @@ void airoha_ppe_deinit(struct airoha_eth
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
+ rhashtable_destroy(ð->ppe->l2_flows);
|
||||
rhashtable_destroy(ð->flow_table);
|
||||
debugfs_remove(eth->ppe->debugfs_dir);
|
||||
}
|
||||
@ -1,253 +0,0 @@
|
||||
From cd53f622611f9a6dd83b858c85448dd3568b67ec Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 9 Apr 2025 11:47:15 +0200
|
||||
Subject: [PATCH 2/2] net: airoha: Add L2 hw acceleration support
|
||||
|
||||
Similar to mtk driver, introduce the capability to offload L2 traffic
|
||||
defining flower rules in the PSE/PPE engine available on EN7581 SoC.
|
||||
Since the hw always reports L2/L3/L4 flower rules, link all L2 rules
|
||||
sharing the same L2 info (with different L3/L4 info) in the L2 subflows
|
||||
list of a given L2 PPE entry.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
|
||||
Link: https://patch.msgid.link/20250409-airoha-flowtable-l2b-v2-2-4a1e3935ea92@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 2 +-
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 9 +-
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 121 ++++++++++++++++++++---
|
||||
3 files changed, 115 insertions(+), 17 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -694,7 +694,7 @@ static int airoha_qdma_rx_process(struct
|
||||
|
||||
reason = FIELD_GET(AIROHA_RXD4_PPE_CPU_REASON, msg1);
|
||||
if (reason == PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
|
||||
- airoha_ppe_check_skb(eth->ppe, hash);
|
||||
+ airoha_ppe_check_skb(eth->ppe, q->skb, hash);
|
||||
|
||||
done++;
|
||||
napi_gro_receive(&q->napi, q->skb);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -431,10 +431,14 @@ enum airoha_flow_entry_type {
|
||||
struct airoha_flow_table_entry {
|
||||
union {
|
||||
struct hlist_node list; /* PPE L3 flow entry */
|
||||
- struct rhash_head l2_node; /* L2 flow entry */
|
||||
+ struct {
|
||||
+ struct rhash_head l2_node; /* L2 flow entry */
|
||||
+ struct hlist_head l2_flows; /* PPE L2 subflows list */
|
||||
+ };
|
||||
};
|
||||
|
||||
struct airoha_foe_entry data;
|
||||
+ struct hlist_node l2_subflow_node; /* PPE L2 subflow entry */
|
||||
u32 hash;
|
||||
|
||||
enum airoha_flow_entry_type type;
|
||||
@@ -548,7 +552,8 @@ u32 airoha_rmw(void __iomem *base, u32 o
|
||||
bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
|
||||
struct airoha_gdm_port *port);
|
||||
|
||||
-void airoha_ppe_check_skb(struct airoha_ppe *ppe, u16 hash);
|
||||
+void airoha_ppe_check_skb(struct airoha_ppe *ppe, struct sk_buff *skb,
|
||||
+ u16 hash);
|
||||
int airoha_ppe_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
||||
void *cb_priv);
|
||||
int airoha_ppe_init(struct airoha_eth *eth);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -204,6 +204,15 @@ static int airoha_get_dsa_port(struct ne
|
||||
#endif
|
||||
}
|
||||
|
||||
+static void airoha_ppe_foe_set_bridge_addrs(struct airoha_foe_bridge *br,
|
||||
+ struct ethhdr *eh)
|
||||
+{
|
||||
+ br->dest_mac_hi = get_unaligned_be32(eh->h_dest);
|
||||
+ br->dest_mac_lo = get_unaligned_be16(eh->h_dest + 4);
|
||||
+ br->src_mac_hi = get_unaligned_be16(eh->h_source);
|
||||
+ br->src_mac_lo = get_unaligned_be32(eh->h_source + 2);
|
||||
+}
|
||||
+
|
||||
static int airoha_ppe_foe_entry_prepare(struct airoha_eth *eth,
|
||||
struct airoha_foe_entry *hwe,
|
||||
struct net_device *dev, int type,
|
||||
@@ -254,13 +263,7 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
|
||||
qdata = FIELD_PREP(AIROHA_FOE_SHAPER_ID, 0x7f);
|
||||
if (type == PPE_PKT_TYPE_BRIDGE) {
|
||||
- hwe->bridge.dest_mac_hi = get_unaligned_be32(data->eth.h_dest);
|
||||
- hwe->bridge.dest_mac_lo =
|
||||
- get_unaligned_be16(data->eth.h_dest + 4);
|
||||
- hwe->bridge.src_mac_hi =
|
||||
- get_unaligned_be16(data->eth.h_source);
|
||||
- hwe->bridge.src_mac_lo =
|
||||
- get_unaligned_be32(data->eth.h_source + 2);
|
||||
+ airoha_ppe_foe_set_bridge_addrs(&hwe->bridge, &data->eth);
|
||||
hwe->bridge.data = qdata;
|
||||
hwe->bridge.ib2 = val;
|
||||
l2 = &hwe->bridge.l2.common;
|
||||
@@ -385,6 +388,19 @@ static u32 airoha_ppe_foe_get_entry_hash
|
||||
hv3 = hwe->ipv6.src_ip[1] ^ hwe->ipv6.dest_ip[1];
|
||||
hv3 ^= hwe->ipv6.src_ip[0];
|
||||
break;
|
||||
+ case PPE_PKT_TYPE_BRIDGE: {
|
||||
+ struct airoha_foe_mac_info *l2 = &hwe->bridge.l2;
|
||||
+
|
||||
+ hv1 = l2->common.src_mac_hi & 0xffff;
|
||||
+ hv1 = hv1 << 16 | l2->src_mac_lo;
|
||||
+
|
||||
+ hv2 = l2->common.dest_mac_lo;
|
||||
+ hv2 = hv2 << 16;
|
||||
+ hv2 = hv2 | ((l2->common.src_mac_hi & 0xffff0000) >> 16);
|
||||
+
|
||||
+ hv3 = l2->common.dest_mac_hi;
|
||||
+ break;
|
||||
+ }
|
||||
case PPE_PKT_TYPE_IPV4_DSLITE:
|
||||
case PPE_PKT_TYPE_IPV6_6RD:
|
||||
default:
|
||||
@@ -496,15 +512,24 @@ static void airoha_ppe_foe_remove_flow(s
|
||||
airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash);
|
||||
e->hash = 0xffff;
|
||||
}
|
||||
+ if (e->type == FLOW_TYPE_L2_SUBFLOW) {
|
||||
+ hlist_del_init(&e->l2_subflow_node);
|
||||
+ kfree(e);
|
||||
+ }
|
||||
}
|
||||
|
||||
static void airoha_ppe_foe_remove_l2_flow(struct airoha_ppe *ppe,
|
||||
struct airoha_flow_table_entry *e)
|
||||
{
|
||||
+ struct hlist_head *head = &e->l2_flows;
|
||||
+ struct hlist_node *n;
|
||||
+
|
||||
lockdep_assert_held(&ppe_lock);
|
||||
|
||||
rhashtable_remove_fast(&ppe->l2_flows, &e->l2_node,
|
||||
airoha_l2_flow_table_params);
|
||||
+ hlist_for_each_entry_safe(e, n, head, l2_subflow_node)
|
||||
+ airoha_ppe_foe_remove_flow(ppe, e);
|
||||
}
|
||||
|
||||
static void airoha_ppe_foe_flow_remove_entry(struct airoha_ppe *ppe,
|
||||
@@ -520,10 +545,56 @@ static void airoha_ppe_foe_flow_remove_e
|
||||
spin_unlock_bh(&ppe_lock);
|
||||
}
|
||||
|
||||
-static void airoha_ppe_foe_insert_entry(struct airoha_ppe *ppe, u32 hash)
|
||||
+static int
|
||||
+airoha_ppe_foe_commit_subflow_entry(struct airoha_ppe *ppe,
|
||||
+ struct airoha_flow_table_entry *e,
|
||||
+ u32 hash)
|
||||
+{
|
||||
+ u32 mask = AIROHA_FOE_IB1_BIND_PACKET_TYPE | AIROHA_FOE_IB1_BIND_UDP;
|
||||
+ struct airoha_foe_entry *hwe_p, hwe;
|
||||
+ struct airoha_flow_table_entry *f;
|
||||
+ struct airoha_foe_mac_info *l2;
|
||||
+ int type;
|
||||
+
|
||||
+ hwe_p = airoha_ppe_foe_get_entry(ppe, hash);
|
||||
+ if (!hwe_p)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ f = kzalloc(sizeof(*f), GFP_ATOMIC);
|
||||
+ if (!f)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ hlist_add_head(&f->l2_subflow_node, &e->l2_flows);
|
||||
+ f->type = FLOW_TYPE_L2_SUBFLOW;
|
||||
+ f->hash = hash;
|
||||
+
|
||||
+ memcpy(&hwe, hwe_p, sizeof(*hwe_p));
|
||||
+ hwe.ib1 = (hwe.ib1 & mask) | (e->data.ib1 & ~mask);
|
||||
+ l2 = &hwe.bridge.l2;
|
||||
+ memcpy(l2, &e->data.bridge.l2, sizeof(*l2));
|
||||
+
|
||||
+ type = FIELD_GET(AIROHA_FOE_IB1_BIND_PACKET_TYPE, hwe.ib1);
|
||||
+ if (type == PPE_PKT_TYPE_IPV4_HNAPT)
|
||||
+ memcpy(&hwe.ipv4.new_tuple, &hwe.ipv4.orig_tuple,
|
||||
+ sizeof(hwe.ipv4.new_tuple));
|
||||
+ else if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T &&
|
||||
+ l2->common.etype == ETH_P_IP)
|
||||
+ l2->common.etype = ETH_P_IPV6;
|
||||
+
|
||||
+ hwe.bridge.ib2 = e->data.bridge.ib2;
|
||||
+ airoha_ppe_foe_commit_entry(ppe, &hwe, hash);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void airoha_ppe_foe_insert_entry(struct airoha_ppe *ppe,
|
||||
+ struct sk_buff *skb,
|
||||
+ u32 hash)
|
||||
{
|
||||
struct airoha_flow_table_entry *e;
|
||||
+ struct airoha_foe_bridge br = {};
|
||||
struct airoha_foe_entry *hwe;
|
||||
+ bool commit_done = false;
|
||||
struct hlist_node *n;
|
||||
u32 index, state;
|
||||
|
||||
@@ -539,12 +610,33 @@ static void airoha_ppe_foe_insert_entry(
|
||||
|
||||
index = airoha_ppe_foe_get_entry_hash(hwe);
|
||||
hlist_for_each_entry_safe(e, n, &ppe->foe_flow[index], list) {
|
||||
- if (airoha_ppe_foe_compare_entry(e, hwe)) {
|
||||
- airoha_ppe_foe_commit_entry(ppe, &e->data, hash);
|
||||
- e->hash = hash;
|
||||
- break;
|
||||
+ if (e->type == FLOW_TYPE_L2_SUBFLOW) {
|
||||
+ state = FIELD_GET(AIROHA_FOE_IB1_BIND_STATE, hwe->ib1);
|
||||
+ if (state != AIROHA_FOE_STATE_BIND) {
|
||||
+ e->hash = 0xffff;
|
||||
+ airoha_ppe_foe_remove_flow(ppe, e);
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (commit_done || !airoha_ppe_foe_compare_entry(e, hwe)) {
|
||||
+ e->hash = 0xffff;
|
||||
+ continue;
|
||||
}
|
||||
+
|
||||
+ airoha_ppe_foe_commit_entry(ppe, &e->data, hash);
|
||||
+ commit_done = true;
|
||||
+ e->hash = hash;
|
||||
}
|
||||
+
|
||||
+ if (commit_done)
|
||||
+ goto unlock;
|
||||
+
|
||||
+ airoha_ppe_foe_set_bridge_addrs(&br, eth_hdr(skb));
|
||||
+ e = rhashtable_lookup_fast(&ppe->l2_flows, &br,
|
||||
+ airoha_l2_flow_table_params);
|
||||
+ if (e)
|
||||
+ airoha_ppe_foe_commit_subflow_entry(ppe, e, hash);
|
||||
unlock:
|
||||
spin_unlock_bh(&ppe_lock);
|
||||
}
|
||||
@@ -899,7 +991,8 @@ int airoha_ppe_setup_tc_block_cb(enum tc
|
||||
return err;
|
||||
}
|
||||
|
||||
-void airoha_ppe_check_skb(struct airoha_ppe *ppe, u16 hash)
|
||||
+void airoha_ppe_check_skb(struct airoha_ppe *ppe, struct sk_buff *skb,
|
||||
+ u16 hash)
|
||||
{
|
||||
u16 now, diff;
|
||||
|
||||
@@ -912,7 +1005,7 @@ void airoha_ppe_check_skb(struct airoha_
|
||||
return;
|
||||
|
||||
ppe->foe_check_time[hash] = now;
|
||||
- airoha_ppe_foe_insert_entry(ppe, hash);
|
||||
+ airoha_ppe_foe_insert_entry(ppe, skb, hash);
|
||||
}
|
||||
|
||||
int airoha_ppe_init(struct airoha_eth *eth)
|
||||
@ -1,405 +0,0 @@
|
||||
From df8398fb7bb7a0e509200af56b79343aa133b7d6 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 15 Apr 2025 09:14:34 +0200
|
||||
Subject: [PATCH] net: airoha: Add matchall filter offload support
|
||||
|
||||
Introduce tc matchall filter offload support in airoha_eth driver.
|
||||
Matchall hw filter is used to implement hw rate policing via tc action
|
||||
police:
|
||||
|
||||
$tc qdisc add dev eth0 handle ffff: ingress
|
||||
$tc filter add dev eth0 parent ffff: matchall action police \
|
||||
rate 100mbit burst 1000k drop
|
||||
|
||||
The current implementation supports just drop/accept as exceed/notexceed
|
||||
actions. Moreover, rate and burst are the only supported configuration
|
||||
parameters.
|
||||
|
||||
Reviewed-by: Davide Caratti <dcaratti@redhat.com>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250415-airoha-hw-rx-ratelimit-v4-1-03458784fbc3@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 273 +++++++++++++++++++++-
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 8 +-
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 9 +-
|
||||
drivers/net/ethernet/airoha/airoha_regs.h | 7 +
|
||||
4 files changed, 286 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -527,6 +527,25 @@ static int airoha_fe_init(struct airoha_
|
||||
/* disable IFC by default */
|
||||
airoha_fe_clear(eth, REG_FE_CSR_IFC_CFG, FE_IFC_EN_MASK);
|
||||
|
||||
+ airoha_fe_wr(eth, REG_PPE_DFT_CPORT0(0),
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(7), FE_PSE_PORT_CDM1) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(6), FE_PSE_PORT_CDM1) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(5), FE_PSE_PORT_CDM1) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(4), FE_PSE_PORT_CDM1) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(3), FE_PSE_PORT_CDM1) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(2), FE_PSE_PORT_CDM1) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(1), FE_PSE_PORT_CDM1) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(0), FE_PSE_PORT_CDM1));
|
||||
+ airoha_fe_wr(eth, REG_PPE_DFT_CPORT0(1),
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(7), FE_PSE_PORT_CDM2) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(6), FE_PSE_PORT_CDM2) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(5), FE_PSE_PORT_CDM2) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(4), FE_PSE_PORT_CDM2) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(3), FE_PSE_PORT_CDM2) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(2), FE_PSE_PORT_CDM2) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(1), FE_PSE_PORT_CDM2) |
|
||||
+ FIELD_PREP(DFT_CPORT_MASK(0), FE_PSE_PORT_CDM2));
|
||||
+
|
||||
/* enable 1:N vlan action, init vlan table */
|
||||
airoha_fe_set(eth, REG_MC_VLAN_EN, MC_VLAN_EN_MASK);
|
||||
|
||||
@@ -1652,7 +1671,6 @@ static void airhoha_set_gdm2_loopback(st
|
||||
|
||||
if (port->id == 3) {
|
||||
/* FIXME: handle XSI_PCE1_PORT */
|
||||
- airoha_fe_wr(eth, REG_PPE_DFT_CPORT0(0), 0x5500);
|
||||
airoha_fe_rmw(eth, REG_FE_WAN_PORT,
|
||||
WAN1_EN_MASK | WAN1_MASK | WAN0_MASK,
|
||||
FIELD_PREP(WAN0_MASK, HSGMII_LAN_PCIE0_SRCPORT));
|
||||
@@ -2127,6 +2145,125 @@ static int airoha_tc_setup_qdisc_ets(str
|
||||
}
|
||||
}
|
||||
|
||||
+static int airoha_qdma_get_rl_param(struct airoha_qdma *qdma, int queue_id,
|
||||
+ u32 addr, enum trtcm_param_type param,
|
||||
+ u32 *val_low, u32 *val_high)
|
||||
+{
|
||||
+ u32 idx = QDMA_METER_IDX(queue_id), group = QDMA_METER_GROUP(queue_id);
|
||||
+ u32 val, config = FIELD_PREP(RATE_LIMIT_PARAM_TYPE_MASK, param) |
|
||||
+ FIELD_PREP(RATE_LIMIT_METER_GROUP_MASK, group) |
|
||||
+ FIELD_PREP(RATE_LIMIT_PARAM_INDEX_MASK, idx);
|
||||
+
|
||||
+ airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config);
|
||||
+ if (read_poll_timeout(airoha_qdma_rr, val,
|
||||
+ val & RATE_LIMIT_PARAM_RW_DONE_MASK,
|
||||
+ USEC_PER_MSEC, 10 * USEC_PER_MSEC, true, qdma,
|
||||
+ REG_TRTCM_CFG_PARAM(addr)))
|
||||
+ return -ETIMEDOUT;
|
||||
+
|
||||
+ *val_low = airoha_qdma_rr(qdma, REG_TRTCM_DATA_LOW(addr));
|
||||
+ if (val_high)
|
||||
+ *val_high = airoha_qdma_rr(qdma, REG_TRTCM_DATA_HIGH(addr));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_set_rl_param(struct airoha_qdma *qdma, int queue_id,
|
||||
+ u32 addr, enum trtcm_param_type param,
|
||||
+ u32 val)
|
||||
+{
|
||||
+ u32 idx = QDMA_METER_IDX(queue_id), group = QDMA_METER_GROUP(queue_id);
|
||||
+ u32 config = RATE_LIMIT_PARAM_RW_MASK |
|
||||
+ FIELD_PREP(RATE_LIMIT_PARAM_TYPE_MASK, param) |
|
||||
+ FIELD_PREP(RATE_LIMIT_METER_GROUP_MASK, group) |
|
||||
+ FIELD_PREP(RATE_LIMIT_PARAM_INDEX_MASK, idx);
|
||||
+
|
||||
+ airoha_qdma_wr(qdma, REG_TRTCM_DATA_LOW(addr), val);
|
||||
+ airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config);
|
||||
+
|
||||
+ return read_poll_timeout(airoha_qdma_rr, val,
|
||||
+ val & RATE_LIMIT_PARAM_RW_DONE_MASK,
|
||||
+ USEC_PER_MSEC, 10 * USEC_PER_MSEC, true,
|
||||
+ qdma, REG_TRTCM_CFG_PARAM(addr));
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_set_rl_config(struct airoha_qdma *qdma, int queue_id,
|
||||
+ u32 addr, bool enable, u32 enable_mask)
|
||||
+{
|
||||
+ u32 val;
|
||||
+ int err;
|
||||
+
|
||||
+ err = airoha_qdma_get_rl_param(qdma, queue_id, addr, TRTCM_MISC_MODE,
|
||||
+ &val, NULL);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ val = enable ? val | enable_mask : val & ~enable_mask;
|
||||
+
|
||||
+ return airoha_qdma_set_rl_param(qdma, queue_id, addr, TRTCM_MISC_MODE,
|
||||
+ val);
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_set_rl_token_bucket(struct airoha_qdma *qdma,
|
||||
+ int queue_id, u32 rate_val,
|
||||
+ u32 bucket_size)
|
||||
+{
|
||||
+ u32 val, config, tick, unit, rate, rate_frac;
|
||||
+ int err;
|
||||
+
|
||||
+ err = airoha_qdma_get_rl_param(qdma, queue_id, REG_INGRESS_TRTCM_CFG,
|
||||
+ TRTCM_MISC_MODE, &config, NULL);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ val = airoha_qdma_rr(qdma, REG_INGRESS_TRTCM_CFG);
|
||||
+ tick = FIELD_GET(INGRESS_FAST_TICK_MASK, val);
|
||||
+ if (config & TRTCM_TICK_SEL)
|
||||
+ tick *= FIELD_GET(INGRESS_SLOW_TICK_RATIO_MASK, val);
|
||||
+ if (!tick)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ unit = (config & TRTCM_PKT_MODE) ? 1000000 / tick : 8000 / tick;
|
||||
+ if (!unit)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ rate = rate_val / unit;
|
||||
+ rate_frac = rate_val % unit;
|
||||
+ rate_frac = FIELD_PREP(TRTCM_TOKEN_RATE_MASK, rate_frac) / unit;
|
||||
+ rate = FIELD_PREP(TRTCM_TOKEN_RATE_MASK, rate) |
|
||||
+ FIELD_PREP(TRTCM_TOKEN_RATE_FRACTION_MASK, rate_frac);
|
||||
+
|
||||
+ err = airoha_qdma_set_rl_param(qdma, queue_id, REG_INGRESS_TRTCM_CFG,
|
||||
+ TRTCM_TOKEN_RATE_MODE, rate);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ val = bucket_size;
|
||||
+ if (!(config & TRTCM_PKT_MODE))
|
||||
+ val = max_t(u32, val, MIN_TOKEN_SIZE);
|
||||
+ val = min_t(u32, __fls(val), MAX_TOKEN_SIZE_OFFSET);
|
||||
+
|
||||
+ return airoha_qdma_set_rl_param(qdma, queue_id, REG_INGRESS_TRTCM_CFG,
|
||||
+ TRTCM_BUCKETSIZE_SHIFT_MODE, val);
|
||||
+}
|
||||
+
|
||||
+static int airoha_qdma_init_rl_config(struct airoha_qdma *qdma, int queue_id,
|
||||
+ bool enable, enum trtcm_unit_type unit)
|
||||
+{
|
||||
+ bool tick_sel = queue_id == 0 || queue_id == 2 || queue_id == 8;
|
||||
+ enum trtcm_param mode = TRTCM_METER_MODE;
|
||||
+ int err;
|
||||
+
|
||||
+ mode |= unit == TRTCM_PACKET_UNIT ? TRTCM_PKT_MODE : 0;
|
||||
+ err = airoha_qdma_set_rl_config(qdma, queue_id, REG_INGRESS_TRTCM_CFG,
|
||||
+ enable, mode);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return airoha_qdma_set_rl_config(qdma, queue_id, REG_INGRESS_TRTCM_CFG,
|
||||
+ tick_sel, TRTCM_TICK_SEL);
|
||||
+}
|
||||
+
|
||||
static int airoha_qdma_get_trtcm_param(struct airoha_qdma *qdma, int channel,
|
||||
u32 addr, enum trtcm_param_type param,
|
||||
enum trtcm_mode_type mode,
|
||||
@@ -2291,10 +2428,142 @@ static int airoha_tc_htb_alloc_leaf_queu
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int airoha_qdma_set_rx_meter(struct airoha_gdm_port *port,
|
||||
+ u32 rate, u32 bucket_size,
|
||||
+ enum trtcm_unit_type unit_type)
|
||||
+{
|
||||
+ struct airoha_qdma *qdma = port->qdma;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
|
||||
+ int err;
|
||||
+
|
||||
+ if (!qdma->q_rx[i].ndesc)
|
||||
+ continue;
|
||||
+
|
||||
+ err = airoha_qdma_init_rl_config(qdma, i, !!rate, unit_type);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = airoha_qdma_set_rl_token_bucket(qdma, i, rate,
|
||||
+ bucket_size);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_tc_matchall_act_validate(struct tc_cls_matchall_offload *f)
|
||||
+{
|
||||
+ const struct flow_action *actions = &f->rule->action;
|
||||
+ const struct flow_action_entry *act;
|
||||
+
|
||||
+ if (!flow_action_has_entries(actions)) {
|
||||
+ NL_SET_ERR_MSG_MOD(f->common.extack,
|
||||
+ "filter run with no actions");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ if (!flow_offload_has_one_action(actions)) {
|
||||
+ NL_SET_ERR_MSG_MOD(f->common.extack,
|
||||
+ "only once action per filter is supported");
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ act = &actions->entries[0];
|
||||
+ if (act->id != FLOW_ACTION_POLICE) {
|
||||
+ NL_SET_ERR_MSG_MOD(f->common.extack, "unsupported action");
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ if (act->police.exceed.act_id != FLOW_ACTION_DROP) {
|
||||
+ NL_SET_ERR_MSG_MOD(f->common.extack,
|
||||
+ "invalid exceed action id");
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ if (act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) {
|
||||
+ NL_SET_ERR_MSG_MOD(f->common.extack,
|
||||
+ "invalid notexceed action id");
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ if (act->police.notexceed.act_id == FLOW_ACTION_ACCEPT &&
|
||||
+ !flow_action_is_last_entry(actions, act)) {
|
||||
+ NL_SET_ERR_MSG_MOD(f->common.extack,
|
||||
+ "action accept must be last");
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ if (act->police.peakrate_bytes_ps || act->police.avrate ||
|
||||
+ act->police.overhead || act->police.mtu) {
|
||||
+ NL_SET_ERR_MSG_MOD(f->common.extack,
|
||||
+ "peakrate/avrate/overhead/mtu unsupported");
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int airoha_dev_tc_matchall(struct net_device *dev,
|
||||
+ struct tc_cls_matchall_offload *f)
|
||||
+{
|
||||
+ enum trtcm_unit_type unit_type = TRTCM_BYTE_UNIT;
|
||||
+ struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
+ u32 rate = 0, bucket_size = 0;
|
||||
+
|
||||
+ switch (f->command) {
|
||||
+ case TC_CLSMATCHALL_REPLACE: {
|
||||
+ const struct flow_action_entry *act;
|
||||
+ int err;
|
||||
+
|
||||
+ err = airoha_tc_matchall_act_validate(f);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ act = &f->rule->action.entries[0];
|
||||
+ if (act->police.rate_pkt_ps) {
|
||||
+ rate = act->police.rate_pkt_ps;
|
||||
+ bucket_size = act->police.burst_pkt;
|
||||
+ unit_type = TRTCM_PACKET_UNIT;
|
||||
+ } else {
|
||||
+ rate = div_u64(act->police.rate_bytes_ps, 1000);
|
||||
+ rate = rate << 3; /* Kbps */
|
||||
+ bucket_size = act->police.burst;
|
||||
+ }
|
||||
+ fallthrough;
|
||||
+ }
|
||||
+ case TC_CLSMATCHALL_DESTROY:
|
||||
+ return airoha_qdma_set_rx_meter(port, rate, bucket_size,
|
||||
+ unit_type);
|
||||
+ default:
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int airoha_dev_setup_tc_block_cb(enum tc_setup_type type,
|
||||
+ void *type_data, void *cb_priv)
|
||||
+{
|
||||
+ struct net_device *dev = cb_priv;
|
||||
+
|
||||
+ if (!tc_can_offload(dev))
|
||||
+ return -EOPNOTSUPP;
|
||||
+
|
||||
+ switch (type) {
|
||||
+ case TC_SETUP_CLSFLOWER:
|
||||
+ return airoha_ppe_setup_tc_block_cb(dev, type_data);
|
||||
+ case TC_SETUP_CLSMATCHALL:
|
||||
+ return airoha_dev_tc_matchall(dev, type_data);
|
||||
+ default:
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int airoha_dev_setup_tc_block(struct airoha_gdm_port *port,
|
||||
struct flow_block_offload *f)
|
||||
{
|
||||
- flow_setup_cb_t *cb = airoha_ppe_setup_tc_block_cb;
|
||||
+ flow_setup_cb_t *cb = airoha_dev_setup_tc_block_cb;
|
||||
static LIST_HEAD(block_cb_list);
|
||||
struct flow_block_cb *block_cb;
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -127,6 +127,11 @@ enum tx_sched_mode {
|
||||
TC_SCH_WRR2,
|
||||
};
|
||||
|
||||
+enum trtcm_unit_type {
|
||||
+ TRTCM_BYTE_UNIT,
|
||||
+ TRTCM_PACKET_UNIT,
|
||||
+};
|
||||
+
|
||||
enum trtcm_param_type {
|
||||
TRTCM_MISC_MODE, /* meter_en, pps_mode, tick_sel */
|
||||
TRTCM_TOKEN_RATE_MODE,
|
||||
@@ -554,8 +559,7 @@ bool airoha_is_valid_gdm_port(struct air
|
||||
|
||||
void airoha_ppe_check_skb(struct airoha_ppe *ppe, struct sk_buff *skb,
|
||||
u16 hash);
|
||||
-int airoha_ppe_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
||||
- void *cb_priv);
|
||||
+int airoha_ppe_setup_tc_block_cb(struct net_device *dev, void *type_data);
|
||||
int airoha_ppe_init(struct airoha_eth *eth);
|
||||
void airoha_ppe_deinit(struct airoha_eth *eth);
|
||||
struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -967,18 +967,13 @@ error_npu_put:
|
||||
return err;
|
||||
}
|
||||
|
||||
-int airoha_ppe_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
||||
- void *cb_priv)
|
||||
+int airoha_ppe_setup_tc_block_cb(struct net_device *dev, void *type_data)
|
||||
{
|
||||
- struct flow_cls_offload *cls = type_data;
|
||||
- struct net_device *dev = cb_priv;
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
+ struct flow_cls_offload *cls = type_data;
|
||||
struct airoha_eth *eth = port->qdma->eth;
|
||||
int err = 0;
|
||||
|
||||
- if (!tc_can_offload(dev) || type != TC_SETUP_CLSFLOWER)
|
||||
- return -EOPNOTSUPP;
|
||||
-
|
||||
mutex_lock(&flow_offload_mutex);
|
||||
|
||||
if (!eth->npu)
|
||||
--- a/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
@@ -283,6 +283,7 @@
|
||||
#define PPE_HASH_SEED 0x12345678
|
||||
|
||||
#define REG_PPE_DFT_CPORT0(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x248)
|
||||
+#define DFT_CPORT_MASK(_n) GENMASK(3 + ((_n) << 2), ((_n) << 2))
|
||||
|
||||
#define REG_PPE_DFT_CPORT1(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x24c)
|
||||
|
||||
@@ -691,6 +692,12 @@
|
||||
#define REG_TRTCM_DATA_LOW(_n) ((_n) + 0x8)
|
||||
#define REG_TRTCM_DATA_HIGH(_n) ((_n) + 0xc)
|
||||
|
||||
+#define RATE_LIMIT_PARAM_RW_MASK BIT(31)
|
||||
+#define RATE_LIMIT_PARAM_RW_DONE_MASK BIT(30)
|
||||
+#define RATE_LIMIT_PARAM_TYPE_MASK GENMASK(29, 28)
|
||||
+#define RATE_LIMIT_METER_GROUP_MASK GENMASK(27, 26)
|
||||
+#define RATE_LIMIT_PARAM_INDEX_MASK GENMASK(23, 16)
|
||||
+
|
||||
#define REG_TXWRR_MODE_CFG 0x1020
|
||||
#define TWRR_WEIGHT_SCALE_MASK BIT(31)
|
||||
#define TWRR_WEIGHT_BASE_MASK BIT(3)
|
||||
@ -1,292 +0,0 @@
|
||||
From 9439db26d3ee4a897e5cd108864172531f31ce07 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 18 Apr 2025 12:40:49 +0200
|
||||
Subject: [PATCH 1/2] net: airoha: Introduce airoha_irq_bank struct
|
||||
|
||||
EN7581 ethernet SoC supports 4 programmable IRQ lines each one composed
|
||||
by 4 IRQ configuration registers. Add airoha_irq_bank struct as a
|
||||
container for independent IRQ lines info (e.g. IRQ number, enabled source
|
||||
interrupts, ecc). This is a preliminary patch to support multiple IRQ lines
|
||||
in airoha_eth driver.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250418-airoha-eth-multi-irq-v1-1-1ab0083ca3c1@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 106 ++++++++++++++--------
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 13 ++-
|
||||
drivers/net/ethernet/airoha/airoha_regs.h | 11 ++-
|
||||
3 files changed, 86 insertions(+), 44 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -34,37 +34,40 @@ u32 airoha_rmw(void __iomem *base, u32 o
|
||||
return val;
|
||||
}
|
||||
|
||||
-static void airoha_qdma_set_irqmask(struct airoha_qdma *qdma, int index,
|
||||
- u32 clear, u32 set)
|
||||
+static void airoha_qdma_set_irqmask(struct airoha_irq_bank *irq_bank,
|
||||
+ int index, u32 clear, u32 set)
|
||||
{
|
||||
+ struct airoha_qdma *qdma = irq_bank->qdma;
|
||||
+ int bank = irq_bank - &qdma->irq_banks[0];
|
||||
unsigned long flags;
|
||||
|
||||
- if (WARN_ON_ONCE(index >= ARRAY_SIZE(qdma->irqmask)))
|
||||
+ if (WARN_ON_ONCE(index >= ARRAY_SIZE(irq_bank->irqmask)))
|
||||
return;
|
||||
|
||||
- spin_lock_irqsave(&qdma->irq_lock, flags);
|
||||
+ spin_lock_irqsave(&irq_bank->irq_lock, flags);
|
||||
|
||||
- qdma->irqmask[index] &= ~clear;
|
||||
- qdma->irqmask[index] |= set;
|
||||
- airoha_qdma_wr(qdma, REG_INT_ENABLE(index), qdma->irqmask[index]);
|
||||
+ irq_bank->irqmask[index] &= ~clear;
|
||||
+ irq_bank->irqmask[index] |= set;
|
||||
+ airoha_qdma_wr(qdma, REG_INT_ENABLE(bank, index),
|
||||
+ irq_bank->irqmask[index]);
|
||||
/* Read irq_enable register in order to guarantee the update above
|
||||
* completes in the spinlock critical section.
|
||||
*/
|
||||
- airoha_qdma_rr(qdma, REG_INT_ENABLE(index));
|
||||
+ airoha_qdma_rr(qdma, REG_INT_ENABLE(bank, index));
|
||||
|
||||
- spin_unlock_irqrestore(&qdma->irq_lock, flags);
|
||||
+ spin_unlock_irqrestore(&irq_bank->irq_lock, flags);
|
||||
}
|
||||
|
||||
-static void airoha_qdma_irq_enable(struct airoha_qdma *qdma, int index,
|
||||
- u32 mask)
|
||||
+static void airoha_qdma_irq_enable(struct airoha_irq_bank *irq_bank,
|
||||
+ int index, u32 mask)
|
||||
{
|
||||
- airoha_qdma_set_irqmask(qdma, index, 0, mask);
|
||||
+ airoha_qdma_set_irqmask(irq_bank, index, 0, mask);
|
||||
}
|
||||
|
||||
-static void airoha_qdma_irq_disable(struct airoha_qdma *qdma, int index,
|
||||
- u32 mask)
|
||||
+static void airoha_qdma_irq_disable(struct airoha_irq_bank *irq_bank,
|
||||
+ int index, u32 mask)
|
||||
{
|
||||
- airoha_qdma_set_irqmask(qdma, index, mask, 0);
|
||||
+ airoha_qdma_set_irqmask(irq_bank, index, mask, 0);
|
||||
}
|
||||
|
||||
static bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
|
||||
@@ -732,6 +735,7 @@ free_frag:
|
||||
static int airoha_qdma_rx_napi_poll(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct airoha_queue *q = container_of(napi, struct airoha_queue, napi);
|
||||
+ struct airoha_irq_bank *irq_bank = &q->qdma->irq_banks[0];
|
||||
int cur, done = 0;
|
||||
|
||||
do {
|
||||
@@ -740,7 +744,7 @@ static int airoha_qdma_rx_napi_poll(stru
|
||||
} while (cur && done < budget);
|
||||
|
||||
if (done < budget && napi_complete(napi))
|
||||
- airoha_qdma_irq_enable(q->qdma, QDMA_INT_REG_IDX1,
|
||||
+ airoha_qdma_irq_enable(irq_bank, QDMA_INT_REG_IDX1,
|
||||
RX_DONE_INT_MASK);
|
||||
|
||||
return done;
|
||||
@@ -965,7 +969,7 @@ unlock:
|
||||
}
|
||||
|
||||
if (done < budget && napi_complete(napi))
|
||||
- airoha_qdma_irq_enable(qdma, QDMA_INT_REG_IDX0,
|
||||
+ airoha_qdma_irq_enable(&qdma->irq_banks[0], QDMA_INT_REG_IDX0,
|
||||
TX_DONE_INT_MASK(id));
|
||||
|
||||
return done;
|
||||
@@ -1196,13 +1200,16 @@ static int airoha_qdma_hw_init(struct ai
|
||||
int i;
|
||||
|
||||
/* clear pending irqs */
|
||||
- for (i = 0; i < ARRAY_SIZE(qdma->irqmask); i++)
|
||||
+ for (i = 0; i < ARRAY_SIZE(qdma->irq_banks[0].irqmask); i++)
|
||||
airoha_qdma_wr(qdma, REG_INT_STATUS(i), 0xffffffff);
|
||||
|
||||
/* setup irqs */
|
||||
- airoha_qdma_irq_enable(qdma, QDMA_INT_REG_IDX0, INT_IDX0_MASK);
|
||||
- airoha_qdma_irq_enable(qdma, QDMA_INT_REG_IDX1, INT_IDX1_MASK);
|
||||
- airoha_qdma_irq_enable(qdma, QDMA_INT_REG_IDX4, INT_IDX4_MASK);
|
||||
+ airoha_qdma_irq_enable(&qdma->irq_banks[0], QDMA_INT_REG_IDX0,
|
||||
+ INT_IDX0_MASK);
|
||||
+ airoha_qdma_irq_enable(&qdma->irq_banks[0], QDMA_INT_REG_IDX1,
|
||||
+ INT_IDX1_MASK);
|
||||
+ airoha_qdma_irq_enable(&qdma->irq_banks[0], QDMA_INT_REG_IDX4,
|
||||
+ INT_IDX4_MASK);
|
||||
|
||||
/* setup irq binding */
|
||||
for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
|
||||
@@ -1247,13 +1254,14 @@ static int airoha_qdma_hw_init(struct ai
|
||||
|
||||
static irqreturn_t airoha_irq_handler(int irq, void *dev_instance)
|
||||
{
|
||||
- struct airoha_qdma *qdma = dev_instance;
|
||||
- u32 intr[ARRAY_SIZE(qdma->irqmask)];
|
||||
+ struct airoha_irq_bank *irq_bank = dev_instance;
|
||||
+ struct airoha_qdma *qdma = irq_bank->qdma;
|
||||
+ u32 intr[ARRAY_SIZE(irq_bank->irqmask)];
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < ARRAY_SIZE(qdma->irqmask); i++) {
|
||||
+ for (i = 0; i < ARRAY_SIZE(intr); i++) {
|
||||
intr[i] = airoha_qdma_rr(qdma, REG_INT_STATUS(i));
|
||||
- intr[i] &= qdma->irqmask[i];
|
||||
+ intr[i] &= irq_bank->irqmask[i];
|
||||
airoha_qdma_wr(qdma, REG_INT_STATUS(i), intr[i]);
|
||||
}
|
||||
|
||||
@@ -1261,7 +1269,7 @@ static irqreturn_t airoha_irq_handler(in
|
||||
return IRQ_NONE;
|
||||
|
||||
if (intr[1] & RX_DONE_INT_MASK) {
|
||||
- airoha_qdma_irq_disable(qdma, QDMA_INT_REG_IDX1,
|
||||
+ airoha_qdma_irq_disable(irq_bank, QDMA_INT_REG_IDX1,
|
||||
RX_DONE_INT_MASK);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
|
||||
@@ -1278,7 +1286,7 @@ static irqreturn_t airoha_irq_handler(in
|
||||
if (!(intr[0] & TX_DONE_INT_MASK(i)))
|
||||
continue;
|
||||
|
||||
- airoha_qdma_irq_disable(qdma, QDMA_INT_REG_IDX0,
|
||||
+ airoha_qdma_irq_disable(irq_bank, QDMA_INT_REG_IDX0,
|
||||
TX_DONE_INT_MASK(i));
|
||||
napi_schedule(&qdma->q_tx_irq[i].napi);
|
||||
}
|
||||
@@ -1287,6 +1295,39 @@ static irqreturn_t airoha_irq_handler(in
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
+static int airoha_qdma_init_irq_banks(struct platform_device *pdev,
|
||||
+ struct airoha_qdma *qdma)
|
||||
+{
|
||||
+ struct airoha_eth *eth = qdma->eth;
|
||||
+ int i, id = qdma - ð->qdma[0];
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(qdma->irq_banks); i++) {
|
||||
+ struct airoha_irq_bank *irq_bank = &qdma->irq_banks[i];
|
||||
+ int err, irq_index = 4 * id + i;
|
||||
+ const char *name;
|
||||
+
|
||||
+ spin_lock_init(&irq_bank->irq_lock);
|
||||
+ irq_bank->qdma = qdma;
|
||||
+
|
||||
+ irq_bank->irq = platform_get_irq(pdev, irq_index);
|
||||
+ if (irq_bank->irq < 0)
|
||||
+ return irq_bank->irq;
|
||||
+
|
||||
+ name = devm_kasprintf(eth->dev, GFP_KERNEL,
|
||||
+ KBUILD_MODNAME ".%d", irq_index);
|
||||
+ if (!name)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ err = devm_request_irq(eth->dev, irq_bank->irq,
|
||||
+ airoha_irq_handler, IRQF_SHARED, name,
|
||||
+ irq_bank);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int airoha_qdma_init(struct platform_device *pdev,
|
||||
struct airoha_eth *eth,
|
||||
struct airoha_qdma *qdma)
|
||||
@@ -1294,9 +1335,7 @@ static int airoha_qdma_init(struct platf
|
||||
int err, id = qdma - ð->qdma[0];
|
||||
const char *res;
|
||||
|
||||
- spin_lock_init(&qdma->irq_lock);
|
||||
qdma->eth = eth;
|
||||
-
|
||||
res = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d", id);
|
||||
if (!res)
|
||||
return -ENOMEM;
|
||||
@@ -1306,12 +1345,7 @@ static int airoha_qdma_init(struct platf
|
||||
return dev_err_probe(eth->dev, PTR_ERR(qdma->regs),
|
||||
"failed to iomap qdma%d regs\n", id);
|
||||
|
||||
- qdma->irq = platform_get_irq(pdev, 4 * id);
|
||||
- if (qdma->irq < 0)
|
||||
- return qdma->irq;
|
||||
-
|
||||
- err = devm_request_irq(eth->dev, qdma->irq, airoha_irq_handler,
|
||||
- IRQF_SHARED, KBUILD_MODNAME, qdma);
|
||||
+ err = airoha_qdma_init_irq_banks(pdev, qdma);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -2802,7 +2836,7 @@ static int airoha_alloc_gdm_port(struct
|
||||
dev->features |= dev->hw_features;
|
||||
dev->vlan_features = dev->hw_features;
|
||||
dev->dev.of_node = np;
|
||||
- dev->irq = qdma->irq;
|
||||
+ dev->irq = qdma->irq_banks[0].irq;
|
||||
SET_NETDEV_DEV(dev, eth->dev);
|
||||
|
||||
/* reserve hw queues for HTB offloading */
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#define AIROHA_MAX_NUM_GDM_PORTS 4
|
||||
#define AIROHA_MAX_NUM_QDMA 2
|
||||
+#define AIROHA_MAX_NUM_IRQ_BANKS 1
|
||||
#define AIROHA_MAX_DSA_PORTS 7
|
||||
#define AIROHA_MAX_NUM_RSTS 3
|
||||
#define AIROHA_MAX_NUM_XSI_RSTS 5
|
||||
@@ -452,17 +453,23 @@ struct airoha_flow_table_entry {
|
||||
unsigned long cookie;
|
||||
};
|
||||
|
||||
-struct airoha_qdma {
|
||||
- struct airoha_eth *eth;
|
||||
- void __iomem *regs;
|
||||
+struct airoha_irq_bank {
|
||||
+ struct airoha_qdma *qdma;
|
||||
|
||||
/* protect concurrent irqmask accesses */
|
||||
spinlock_t irq_lock;
|
||||
u32 irqmask[QDMA_INT_REG_MAX];
|
||||
int irq;
|
||||
+};
|
||||
+
|
||||
+struct airoha_qdma {
|
||||
+ struct airoha_eth *eth;
|
||||
+ void __iomem *regs;
|
||||
|
||||
atomic_t users;
|
||||
|
||||
+ struct airoha_irq_bank irq_banks[AIROHA_MAX_NUM_IRQ_BANKS];
|
||||
+
|
||||
struct airoha_tx_irq_queue q_tx_irq[AIROHA_NUM_TX_IRQ];
|
||||
|
||||
struct airoha_queue q_tx[AIROHA_NUM_TX_RING];
|
||||
--- a/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
@@ -423,11 +423,12 @@
|
||||
((_n) == 2) ? 0x0720 : \
|
||||
((_n) == 1) ? 0x0024 : 0x0020)
|
||||
|
||||
-#define REG_INT_ENABLE(_n) \
|
||||
- (((_n) == 4) ? 0x0750 : \
|
||||
- ((_n) == 3) ? 0x0744 : \
|
||||
- ((_n) == 2) ? 0x0740 : \
|
||||
- ((_n) == 1) ? 0x002c : 0x0028)
|
||||
+#define REG_INT_ENABLE(_b, _n) \
|
||||
+ (((_n) == 4) ? 0x0750 + ((_b) << 5) : \
|
||||
+ ((_n) == 3) ? 0x0744 + ((_b) << 5) : \
|
||||
+ ((_n) == 2) ? 0x0740 + ((_b) << 5) : \
|
||||
+ ((_n) == 1) ? 0x002c + ((_b) << 3) : \
|
||||
+ 0x0028 + ((_b) << 3))
|
||||
|
||||
/* QDMA_CSR_INT_ENABLE1 */
|
||||
#define RX15_COHERENT_INT_MASK BIT(31)
|
||||
@ -1,379 +0,0 @@
|
||||
From f252493e1835366fc25ce631c3056f900977dd11 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 18 Apr 2025 12:40:50 +0200
|
||||
Subject: [PATCH 2/2] net: airoha: Enable multiple IRQ lines support in
|
||||
airoha_eth driver.
|
||||
|
||||
EN7581 ethernet SoC supports 4 programmable IRQ lines for Tx and Rx
|
||||
interrupts. Enable multiple IRQ lines support. Map Rx/Tx queues to the
|
||||
available IRQ lines using the default scheme used in the vendor SDK:
|
||||
|
||||
- IRQ0: rx queues [0-4],[7-9],15
|
||||
- IRQ1: rx queues [21-30]
|
||||
- IRQ2: rx queues 5
|
||||
- IRQ3: rx queues 6
|
||||
|
||||
Tx queues interrupts are managed by IRQ0.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250418-airoha-eth-multi-irq-v1-2-1ab0083ca3c1@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 67 +++++---
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 13 +-
|
||||
drivers/net/ethernet/airoha/airoha_regs.h | 185 +++++++++++++++++-----
|
||||
3 files changed, 206 insertions(+), 59 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -735,7 +735,6 @@ free_frag:
|
||||
static int airoha_qdma_rx_napi_poll(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct airoha_queue *q = container_of(napi, struct airoha_queue, napi);
|
||||
- struct airoha_irq_bank *irq_bank = &q->qdma->irq_banks[0];
|
||||
int cur, done = 0;
|
||||
|
||||
do {
|
||||
@@ -743,9 +742,20 @@ static int airoha_qdma_rx_napi_poll(stru
|
||||
done += cur;
|
||||
} while (cur && done < budget);
|
||||
|
||||
- if (done < budget && napi_complete(napi))
|
||||
- airoha_qdma_irq_enable(irq_bank, QDMA_INT_REG_IDX1,
|
||||
- RX_DONE_INT_MASK);
|
||||
+ if (done < budget && napi_complete(napi)) {
|
||||
+ struct airoha_qdma *qdma = q->qdma;
|
||||
+ int i, qid = q - &qdma->q_rx[0];
|
||||
+ int intr_reg = qid < RX_DONE_HIGH_OFFSET ? QDMA_INT_REG_IDX1
|
||||
+ : QDMA_INT_REG_IDX2;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(qdma->irq_banks); i++) {
|
||||
+ if (!(BIT(qid) & RX_IRQ_BANK_PIN_MASK(i)))
|
||||
+ continue;
|
||||
+
|
||||
+ airoha_qdma_irq_enable(&qdma->irq_banks[i], intr_reg,
|
||||
+ BIT(qid % RX_DONE_HIGH_OFFSET));
|
||||
+ }
|
||||
+ }
|
||||
|
||||
return done;
|
||||
}
|
||||
@@ -1199,17 +1209,24 @@ static int airoha_qdma_hw_init(struct ai
|
||||
{
|
||||
int i;
|
||||
|
||||
- /* clear pending irqs */
|
||||
- for (i = 0; i < ARRAY_SIZE(qdma->irq_banks[0].irqmask); i++)
|
||||
+ for (i = 0; i < ARRAY_SIZE(qdma->irq_banks); i++) {
|
||||
+ /* clear pending irqs */
|
||||
airoha_qdma_wr(qdma, REG_INT_STATUS(i), 0xffffffff);
|
||||
-
|
||||
- /* setup irqs */
|
||||
+ /* setup rx irqs */
|
||||
+ airoha_qdma_irq_enable(&qdma->irq_banks[i], QDMA_INT_REG_IDX0,
|
||||
+ INT_RX0_MASK(RX_IRQ_BANK_PIN_MASK(i)));
|
||||
+ airoha_qdma_irq_enable(&qdma->irq_banks[i], QDMA_INT_REG_IDX1,
|
||||
+ INT_RX1_MASK(RX_IRQ_BANK_PIN_MASK(i)));
|
||||
+ airoha_qdma_irq_enable(&qdma->irq_banks[i], QDMA_INT_REG_IDX2,
|
||||
+ INT_RX2_MASK(RX_IRQ_BANK_PIN_MASK(i)));
|
||||
+ airoha_qdma_irq_enable(&qdma->irq_banks[i], QDMA_INT_REG_IDX3,
|
||||
+ INT_RX3_MASK(RX_IRQ_BANK_PIN_MASK(i)));
|
||||
+ }
|
||||
+ /* setup tx irqs */
|
||||
airoha_qdma_irq_enable(&qdma->irq_banks[0], QDMA_INT_REG_IDX0,
|
||||
- INT_IDX0_MASK);
|
||||
- airoha_qdma_irq_enable(&qdma->irq_banks[0], QDMA_INT_REG_IDX1,
|
||||
- INT_IDX1_MASK);
|
||||
+ TX_COHERENT_LOW_INT_MASK | INT_TX_MASK);
|
||||
airoha_qdma_irq_enable(&qdma->irq_banks[0], QDMA_INT_REG_IDX4,
|
||||
- INT_IDX4_MASK);
|
||||
+ TX_COHERENT_HIGH_INT_MASK);
|
||||
|
||||
/* setup irq binding */
|
||||
for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
|
||||
@@ -1256,6 +1273,7 @@ static irqreturn_t airoha_irq_handler(in
|
||||
{
|
||||
struct airoha_irq_bank *irq_bank = dev_instance;
|
||||
struct airoha_qdma *qdma = irq_bank->qdma;
|
||||
+ u32 rx_intr_mask = 0, rx_intr1, rx_intr2;
|
||||
u32 intr[ARRAY_SIZE(irq_bank->irqmask)];
|
||||
int i;
|
||||
|
||||
@@ -1268,17 +1286,24 @@ static irqreturn_t airoha_irq_handler(in
|
||||
if (!test_bit(DEV_STATE_INITIALIZED, &qdma->eth->state))
|
||||
return IRQ_NONE;
|
||||
|
||||
- if (intr[1] & RX_DONE_INT_MASK) {
|
||||
- airoha_qdma_irq_disable(irq_bank, QDMA_INT_REG_IDX1,
|
||||
- RX_DONE_INT_MASK);
|
||||
+ rx_intr1 = intr[1] & RX_DONE_LOW_INT_MASK;
|
||||
+ if (rx_intr1) {
|
||||
+ airoha_qdma_irq_disable(irq_bank, QDMA_INT_REG_IDX1, rx_intr1);
|
||||
+ rx_intr_mask |= rx_intr1;
|
||||
+ }
|
||||
|
||||
- for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
|
||||
- if (!qdma->q_rx[i].ndesc)
|
||||
- continue;
|
||||
+ rx_intr2 = intr[2] & RX_DONE_HIGH_INT_MASK;
|
||||
+ if (rx_intr2) {
|
||||
+ airoha_qdma_irq_disable(irq_bank, QDMA_INT_REG_IDX2, rx_intr2);
|
||||
+ rx_intr_mask |= (rx_intr2 << 16);
|
||||
+ }
|
||||
|
||||
- if (intr[1] & BIT(i))
|
||||
- napi_schedule(&qdma->q_rx[i].napi);
|
||||
- }
|
||||
+ for (i = 0; rx_intr_mask && i < ARRAY_SIZE(qdma->q_rx); i++) {
|
||||
+ if (!qdma->q_rx[i].ndesc)
|
||||
+ continue;
|
||||
+
|
||||
+ if (rx_intr_mask & BIT(i))
|
||||
+ napi_schedule(&qdma->q_rx[i].napi);
|
||||
}
|
||||
|
||||
if (intr[0] & INT_TX_MASK) {
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#define AIROHA_MAX_NUM_GDM_PORTS 4
|
||||
#define AIROHA_MAX_NUM_QDMA 2
|
||||
-#define AIROHA_MAX_NUM_IRQ_BANKS 1
|
||||
+#define AIROHA_MAX_NUM_IRQ_BANKS 4
|
||||
#define AIROHA_MAX_DSA_PORTS 7
|
||||
#define AIROHA_MAX_NUM_RSTS 3
|
||||
#define AIROHA_MAX_NUM_XSI_RSTS 5
|
||||
@@ -453,6 +453,17 @@ struct airoha_flow_table_entry {
|
||||
unsigned long cookie;
|
||||
};
|
||||
|
||||
+/* RX queue to IRQ mapping: BIT(q) in IRQ(n) */
|
||||
+#define RX_IRQ0_BANK_PIN_MASK 0x839f
|
||||
+#define RX_IRQ1_BANK_PIN_MASK 0x7fe00000
|
||||
+#define RX_IRQ2_BANK_PIN_MASK 0x20
|
||||
+#define RX_IRQ3_BANK_PIN_MASK 0x40
|
||||
+#define RX_IRQ_BANK_PIN_MASK(_n) \
|
||||
+ (((_n) == 3) ? RX_IRQ3_BANK_PIN_MASK : \
|
||||
+ ((_n) == 2) ? RX_IRQ2_BANK_PIN_MASK : \
|
||||
+ ((_n) == 1) ? RX_IRQ1_BANK_PIN_MASK : \
|
||||
+ RX_IRQ0_BANK_PIN_MASK)
|
||||
+
|
||||
struct airoha_irq_bank {
|
||||
struct airoha_qdma *qdma;
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
@@ -463,6 +463,26 @@
|
||||
#define IRQ0_FULL_INT_MASK BIT(1)
|
||||
#define IRQ0_INT_MASK BIT(0)
|
||||
|
||||
+#define RX_COHERENT_LOW_INT_MASK \
|
||||
+ (RX15_COHERENT_INT_MASK | RX14_COHERENT_INT_MASK | \
|
||||
+ RX13_COHERENT_INT_MASK | RX12_COHERENT_INT_MASK | \
|
||||
+ RX11_COHERENT_INT_MASK | RX10_COHERENT_INT_MASK | \
|
||||
+ RX9_COHERENT_INT_MASK | RX8_COHERENT_INT_MASK | \
|
||||
+ RX7_COHERENT_INT_MASK | RX6_COHERENT_INT_MASK | \
|
||||
+ RX5_COHERENT_INT_MASK | RX4_COHERENT_INT_MASK | \
|
||||
+ RX3_COHERENT_INT_MASK | RX2_COHERENT_INT_MASK | \
|
||||
+ RX1_COHERENT_INT_MASK | RX0_COHERENT_INT_MASK)
|
||||
+
|
||||
+#define RX_COHERENT_LOW_OFFSET __ffs(RX_COHERENT_LOW_INT_MASK)
|
||||
+#define INT_RX0_MASK(_n) \
|
||||
+ (((_n) << RX_COHERENT_LOW_OFFSET) & RX_COHERENT_LOW_INT_MASK)
|
||||
+
|
||||
+#define TX_COHERENT_LOW_INT_MASK \
|
||||
+ (TX7_COHERENT_INT_MASK | TX6_COHERENT_INT_MASK | \
|
||||
+ TX5_COHERENT_INT_MASK | TX4_COHERENT_INT_MASK | \
|
||||
+ TX3_COHERENT_INT_MASK | TX2_COHERENT_INT_MASK | \
|
||||
+ TX1_COHERENT_INT_MASK | TX0_COHERENT_INT_MASK)
|
||||
+
|
||||
#define TX_DONE_INT_MASK(_n) \
|
||||
((_n) ? IRQ1_INT_MASK | IRQ1_FULL_INT_MASK \
|
||||
: IRQ0_INT_MASK | IRQ0_FULL_INT_MASK)
|
||||
@@ -471,17 +491,6 @@
|
||||
(IRQ1_INT_MASK | IRQ1_FULL_INT_MASK | \
|
||||
IRQ0_INT_MASK | IRQ0_FULL_INT_MASK)
|
||||
|
||||
-#define INT_IDX0_MASK \
|
||||
- (TX0_COHERENT_INT_MASK | TX1_COHERENT_INT_MASK | \
|
||||
- TX2_COHERENT_INT_MASK | TX3_COHERENT_INT_MASK | \
|
||||
- TX4_COHERENT_INT_MASK | TX5_COHERENT_INT_MASK | \
|
||||
- TX6_COHERENT_INT_MASK | TX7_COHERENT_INT_MASK | \
|
||||
- RX0_COHERENT_INT_MASK | RX1_COHERENT_INT_MASK | \
|
||||
- RX2_COHERENT_INT_MASK | RX3_COHERENT_INT_MASK | \
|
||||
- RX4_COHERENT_INT_MASK | RX7_COHERENT_INT_MASK | \
|
||||
- RX8_COHERENT_INT_MASK | RX9_COHERENT_INT_MASK | \
|
||||
- RX15_COHERENT_INT_MASK | INT_TX_MASK)
|
||||
-
|
||||
/* QDMA_CSR_INT_ENABLE2 */
|
||||
#define RX15_NO_CPU_DSCP_INT_MASK BIT(31)
|
||||
#define RX14_NO_CPU_DSCP_INT_MASK BIT(30)
|
||||
@@ -516,19 +525,121 @@
|
||||
#define RX1_DONE_INT_MASK BIT(1)
|
||||
#define RX0_DONE_INT_MASK BIT(0)
|
||||
|
||||
-#define RX_DONE_INT_MASK \
|
||||
- (RX0_DONE_INT_MASK | RX1_DONE_INT_MASK | \
|
||||
- RX2_DONE_INT_MASK | RX3_DONE_INT_MASK | \
|
||||
- RX4_DONE_INT_MASK | RX7_DONE_INT_MASK | \
|
||||
- RX8_DONE_INT_MASK | RX9_DONE_INT_MASK | \
|
||||
- RX15_DONE_INT_MASK)
|
||||
-#define INT_IDX1_MASK \
|
||||
- (RX_DONE_INT_MASK | \
|
||||
- RX0_NO_CPU_DSCP_INT_MASK | RX1_NO_CPU_DSCP_INT_MASK | \
|
||||
- RX2_NO_CPU_DSCP_INT_MASK | RX3_NO_CPU_DSCP_INT_MASK | \
|
||||
- RX4_NO_CPU_DSCP_INT_MASK | RX7_NO_CPU_DSCP_INT_MASK | \
|
||||
- RX8_NO_CPU_DSCP_INT_MASK | RX9_NO_CPU_DSCP_INT_MASK | \
|
||||
- RX15_NO_CPU_DSCP_INT_MASK)
|
||||
+#define RX_NO_CPU_DSCP_LOW_INT_MASK \
|
||||
+ (RX15_NO_CPU_DSCP_INT_MASK | RX14_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX13_NO_CPU_DSCP_INT_MASK | RX12_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX11_NO_CPU_DSCP_INT_MASK | RX10_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX9_NO_CPU_DSCP_INT_MASK | RX8_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX7_NO_CPU_DSCP_INT_MASK | RX6_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX5_NO_CPU_DSCP_INT_MASK | RX4_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX3_NO_CPU_DSCP_INT_MASK | RX2_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX1_NO_CPU_DSCP_INT_MASK | RX0_NO_CPU_DSCP_INT_MASK)
|
||||
+
|
||||
+#define RX_DONE_LOW_INT_MASK \
|
||||
+ (RX15_DONE_INT_MASK | RX14_DONE_INT_MASK | \
|
||||
+ RX13_DONE_INT_MASK | RX12_DONE_INT_MASK | \
|
||||
+ RX11_DONE_INT_MASK | RX10_DONE_INT_MASK | \
|
||||
+ RX9_DONE_INT_MASK | RX8_DONE_INT_MASK | \
|
||||
+ RX7_DONE_INT_MASK | RX6_DONE_INT_MASK | \
|
||||
+ RX5_DONE_INT_MASK | RX4_DONE_INT_MASK | \
|
||||
+ RX3_DONE_INT_MASK | RX2_DONE_INT_MASK | \
|
||||
+ RX1_DONE_INT_MASK | RX0_DONE_INT_MASK)
|
||||
+
|
||||
+#define RX_NO_CPU_DSCP_LOW_OFFSET __ffs(RX_NO_CPU_DSCP_LOW_INT_MASK)
|
||||
+#define INT_RX1_MASK(_n) \
|
||||
+ ((((_n) << RX_NO_CPU_DSCP_LOW_OFFSET) & RX_NO_CPU_DSCP_LOW_INT_MASK) | \
|
||||
+ (RX_DONE_LOW_INT_MASK & (_n)))
|
||||
+
|
||||
+/* QDMA_CSR_INT_ENABLE3 */
|
||||
+#define RX31_NO_CPU_DSCP_INT_MASK BIT(31)
|
||||
+#define RX30_NO_CPU_DSCP_INT_MASK BIT(30)
|
||||
+#define RX29_NO_CPU_DSCP_INT_MASK BIT(29)
|
||||
+#define RX28_NO_CPU_DSCP_INT_MASK BIT(28)
|
||||
+#define RX27_NO_CPU_DSCP_INT_MASK BIT(27)
|
||||
+#define RX26_NO_CPU_DSCP_INT_MASK BIT(26)
|
||||
+#define RX25_NO_CPU_DSCP_INT_MASK BIT(25)
|
||||
+#define RX24_NO_CPU_DSCP_INT_MASK BIT(24)
|
||||
+#define RX23_NO_CPU_DSCP_INT_MASK BIT(23)
|
||||
+#define RX22_NO_CPU_DSCP_INT_MASK BIT(22)
|
||||
+#define RX21_NO_CPU_DSCP_INT_MASK BIT(21)
|
||||
+#define RX20_NO_CPU_DSCP_INT_MASK BIT(20)
|
||||
+#define RX19_NO_CPU_DSCP_INT_MASK BIT(19)
|
||||
+#define RX18_NO_CPU_DSCP_INT_MASK BIT(18)
|
||||
+#define RX17_NO_CPU_DSCP_INT_MASK BIT(17)
|
||||
+#define RX16_NO_CPU_DSCP_INT_MASK BIT(16)
|
||||
+#define RX31_DONE_INT_MASK BIT(15)
|
||||
+#define RX30_DONE_INT_MASK BIT(14)
|
||||
+#define RX29_DONE_INT_MASK BIT(13)
|
||||
+#define RX28_DONE_INT_MASK BIT(12)
|
||||
+#define RX27_DONE_INT_MASK BIT(11)
|
||||
+#define RX26_DONE_INT_MASK BIT(10)
|
||||
+#define RX25_DONE_INT_MASK BIT(9)
|
||||
+#define RX24_DONE_INT_MASK BIT(8)
|
||||
+#define RX23_DONE_INT_MASK BIT(7)
|
||||
+#define RX22_DONE_INT_MASK BIT(6)
|
||||
+#define RX21_DONE_INT_MASK BIT(5)
|
||||
+#define RX20_DONE_INT_MASK BIT(4)
|
||||
+#define RX19_DONE_INT_MASK BIT(3)
|
||||
+#define RX18_DONE_INT_MASK BIT(2)
|
||||
+#define RX17_DONE_INT_MASK BIT(1)
|
||||
+#define RX16_DONE_INT_MASK BIT(0)
|
||||
+
|
||||
+#define RX_NO_CPU_DSCP_HIGH_INT_MASK \
|
||||
+ (RX31_NO_CPU_DSCP_INT_MASK | RX30_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX29_NO_CPU_DSCP_INT_MASK | RX28_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX27_NO_CPU_DSCP_INT_MASK | RX26_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX25_NO_CPU_DSCP_INT_MASK | RX24_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX23_NO_CPU_DSCP_INT_MASK | RX22_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX21_NO_CPU_DSCP_INT_MASK | RX20_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX19_NO_CPU_DSCP_INT_MASK | RX18_NO_CPU_DSCP_INT_MASK | \
|
||||
+ RX17_NO_CPU_DSCP_INT_MASK | RX16_NO_CPU_DSCP_INT_MASK)
|
||||
+
|
||||
+#define RX_DONE_HIGH_INT_MASK \
|
||||
+ (RX31_DONE_INT_MASK | RX30_DONE_INT_MASK | \
|
||||
+ RX29_DONE_INT_MASK | RX28_DONE_INT_MASK | \
|
||||
+ RX27_DONE_INT_MASK | RX26_DONE_INT_MASK | \
|
||||
+ RX25_DONE_INT_MASK | RX24_DONE_INT_MASK | \
|
||||
+ RX23_DONE_INT_MASK | RX22_DONE_INT_MASK | \
|
||||
+ RX21_DONE_INT_MASK | RX20_DONE_INT_MASK | \
|
||||
+ RX19_DONE_INT_MASK | RX18_DONE_INT_MASK | \
|
||||
+ RX17_DONE_INT_MASK | RX16_DONE_INT_MASK)
|
||||
+
|
||||
+#define RX_DONE_INT_MASK (RX_DONE_HIGH_INT_MASK | RX_DONE_LOW_INT_MASK)
|
||||
+#define RX_DONE_HIGH_OFFSET fls(RX_DONE_HIGH_INT_MASK)
|
||||
+
|
||||
+#define INT_RX2_MASK(_n) \
|
||||
+ ((RX_NO_CPU_DSCP_HIGH_INT_MASK & (_n)) | \
|
||||
+ (((_n) >> RX_DONE_HIGH_OFFSET) & RX_DONE_HIGH_INT_MASK))
|
||||
+
|
||||
+/* QDMA_CSR_INT_ENABLE4 */
|
||||
+#define RX31_COHERENT_INT_MASK BIT(31)
|
||||
+#define RX30_COHERENT_INT_MASK BIT(30)
|
||||
+#define RX29_COHERENT_INT_MASK BIT(29)
|
||||
+#define RX28_COHERENT_INT_MASK BIT(28)
|
||||
+#define RX27_COHERENT_INT_MASK BIT(27)
|
||||
+#define RX26_COHERENT_INT_MASK BIT(26)
|
||||
+#define RX25_COHERENT_INT_MASK BIT(25)
|
||||
+#define RX24_COHERENT_INT_MASK BIT(24)
|
||||
+#define RX23_COHERENT_INT_MASK BIT(23)
|
||||
+#define RX22_COHERENT_INT_MASK BIT(22)
|
||||
+#define RX21_COHERENT_INT_MASK BIT(21)
|
||||
+#define RX20_COHERENT_INT_MASK BIT(20)
|
||||
+#define RX19_COHERENT_INT_MASK BIT(19)
|
||||
+#define RX18_COHERENT_INT_MASK BIT(18)
|
||||
+#define RX17_COHERENT_INT_MASK BIT(17)
|
||||
+#define RX16_COHERENT_INT_MASK BIT(16)
|
||||
+
|
||||
+#define RX_COHERENT_HIGH_INT_MASK \
|
||||
+ (RX31_COHERENT_INT_MASK | RX30_COHERENT_INT_MASK | \
|
||||
+ RX29_COHERENT_INT_MASK | RX28_COHERENT_INT_MASK | \
|
||||
+ RX27_COHERENT_INT_MASK | RX26_COHERENT_INT_MASK | \
|
||||
+ RX25_COHERENT_INT_MASK | RX24_COHERENT_INT_MASK | \
|
||||
+ RX23_COHERENT_INT_MASK | RX22_COHERENT_INT_MASK | \
|
||||
+ RX21_COHERENT_INT_MASK | RX20_COHERENT_INT_MASK | \
|
||||
+ RX19_COHERENT_INT_MASK | RX18_COHERENT_INT_MASK | \
|
||||
+ RX17_COHERENT_INT_MASK | RX16_COHERENT_INT_MASK)
|
||||
+
|
||||
+#define INT_RX3_MASK(_n) (RX_COHERENT_HIGH_INT_MASK & (_n))
|
||||
|
||||
/* QDMA_CSR_INT_ENABLE5 */
|
||||
#define TX31_COHERENT_INT_MASK BIT(31)
|
||||
@@ -556,19 +667,19 @@
|
||||
#define TX9_COHERENT_INT_MASK BIT(9)
|
||||
#define TX8_COHERENT_INT_MASK BIT(8)
|
||||
|
||||
-#define INT_IDX4_MASK \
|
||||
- (TX8_COHERENT_INT_MASK | TX9_COHERENT_INT_MASK | \
|
||||
- TX10_COHERENT_INT_MASK | TX11_COHERENT_INT_MASK | \
|
||||
- TX12_COHERENT_INT_MASK | TX13_COHERENT_INT_MASK | \
|
||||
- TX14_COHERENT_INT_MASK | TX15_COHERENT_INT_MASK | \
|
||||
- TX16_COHERENT_INT_MASK | TX17_COHERENT_INT_MASK | \
|
||||
- TX18_COHERENT_INT_MASK | TX19_COHERENT_INT_MASK | \
|
||||
- TX20_COHERENT_INT_MASK | TX21_COHERENT_INT_MASK | \
|
||||
- TX22_COHERENT_INT_MASK | TX23_COHERENT_INT_MASK | \
|
||||
- TX24_COHERENT_INT_MASK | TX25_COHERENT_INT_MASK | \
|
||||
- TX26_COHERENT_INT_MASK | TX27_COHERENT_INT_MASK | \
|
||||
- TX28_COHERENT_INT_MASK | TX29_COHERENT_INT_MASK | \
|
||||
- TX30_COHERENT_INT_MASK | TX31_COHERENT_INT_MASK)
|
||||
+#define TX_COHERENT_HIGH_INT_MASK \
|
||||
+ (TX31_COHERENT_INT_MASK | TX30_COHERENT_INT_MASK | \
|
||||
+ TX29_COHERENT_INT_MASK | TX28_COHERENT_INT_MASK | \
|
||||
+ TX27_COHERENT_INT_MASK | TX26_COHERENT_INT_MASK | \
|
||||
+ TX25_COHERENT_INT_MASK | TX24_COHERENT_INT_MASK | \
|
||||
+ TX23_COHERENT_INT_MASK | TX22_COHERENT_INT_MASK | \
|
||||
+ TX21_COHERENT_INT_MASK | TX20_COHERENT_INT_MASK | \
|
||||
+ TX19_COHERENT_INT_MASK | TX18_COHERENT_INT_MASK | \
|
||||
+ TX17_COHERENT_INT_MASK | TX16_COHERENT_INT_MASK | \
|
||||
+ TX15_COHERENT_INT_MASK | TX14_COHERENT_INT_MASK | \
|
||||
+ TX13_COHERENT_INT_MASK | TX12_COHERENT_INT_MASK | \
|
||||
+ TX11_COHERENT_INT_MASK | TX10_COHERENT_INT_MASK | \
|
||||
+ TX9_COHERENT_INT_MASK | TX8_COHERENT_INT_MASK)
|
||||
|
||||
#define REG_TX_IRQ_BASE(_n) ((_n) ? 0x0048 : 0x0050)
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
From 4a7843cc8a41b9612becccc07715ed017770eb89 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 6 May 2025 18:56:47 +0200
|
||||
Subject: [PATCH] net: airoha: Add missing field to ppe_mbox_data struct
|
||||
|
||||
The official Airoha EN7581 firmware requires adding max_packet field in
|
||||
ppe_mbox_data struct while the unofficial one used to develop the Airoha
|
||||
EN7581 flowtable support does not require this field.
|
||||
This patch does not introduce any real backwards compatible issue since
|
||||
EN7581 fw is not publicly available in linux-firmware or other
|
||||
repositories (e.g. OpenWrt) yet and the official fw version will use this
|
||||
new layout. For this reason this change needs to be backported.
|
||||
Moreover, make explicit the padding added by the compiler introducing
|
||||
the rsv array in init_info struct.
|
||||
At the same time use u32 instead of int for init_info and set_info
|
||||
struct definitions in ppe_mbox_data struct.
|
||||
|
||||
Fixes: 23290c7bc190d ("net: airoha: Introduce Airoha NPU support")
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250506-airoha-en7581-fix-ppe_mbox_data-v5-1-29cabed6864d@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -104,12 +104,14 @@ struct ppe_mbox_data {
|
||||
u8 xpon_hal_api;
|
||||
u8 wan_xsi;
|
||||
u8 ct_joyme4;
|
||||
- int ppe_type;
|
||||
- int wan_mode;
|
||||
- int wan_sel;
|
||||
+ u8 max_packet;
|
||||
+ u8 rsv[3];
|
||||
+ u32 ppe_type;
|
||||
+ u32 wan_mode;
|
||||
+ u32 wan_sel;
|
||||
} init_info;
|
||||
struct {
|
||||
- int func_id;
|
||||
+ u32 func_id;
|
||||
u32 size;
|
||||
u32 data;
|
||||
} set_info;
|
||||
@ -1,72 +0,0 @@
|
||||
From d6d2b0e1538d5c381ec0ca95afaf772c096ea5dc Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 15 May 2025 08:33:06 +0200
|
||||
Subject: [PATCH] net: airoha: Fix page recycling in airoha_qdma_rx_process()
|
||||
|
||||
Do not recycle the page twice in airoha_qdma_rx_process routine in case
|
||||
of error. Just run dev_kfree_skb() if the skb has been allocated and marked
|
||||
for recycling. Run page_pool_put_full_page() directly if the skb has not
|
||||
been allocated yet.
|
||||
Moreover, rely on DMA address from queue entry element instead of reading
|
||||
it from the DMA descriptor for DMA syncing in airoha_qdma_rx_process().
|
||||
|
||||
Fixes: e12182ddb6e71 ("net: airoha: Enable Rx Scatter-Gather")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250515-airoha-fix-rx-process-error-condition-v2-1-657e92c894b9@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 22 +++++++++-------------
|
||||
1 file changed, 9 insertions(+), 13 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -636,7 +636,6 @@ static int airoha_qdma_rx_process(struct
|
||||
struct airoha_queue_entry *e = &q->entry[q->tail];
|
||||
struct airoha_qdma_desc *desc = &q->desc[q->tail];
|
||||
u32 hash, reason, msg1 = le32_to_cpu(desc->msg1);
|
||||
- dma_addr_t dma_addr = le32_to_cpu(desc->addr);
|
||||
struct page *page = virt_to_head_page(e->buf);
|
||||
u32 desc_ctrl = le32_to_cpu(desc->ctrl);
|
||||
struct airoha_gdm_port *port;
|
||||
@@ -645,22 +644,16 @@ static int airoha_qdma_rx_process(struct
|
||||
if (!(desc_ctrl & QDMA_DESC_DONE_MASK))
|
||||
break;
|
||||
|
||||
- if (!dma_addr)
|
||||
- break;
|
||||
-
|
||||
- len = FIELD_GET(QDMA_DESC_LEN_MASK, desc_ctrl);
|
||||
- if (!len)
|
||||
- break;
|
||||
-
|
||||
q->tail = (q->tail + 1) % q->ndesc;
|
||||
q->queued--;
|
||||
|
||||
- dma_sync_single_for_cpu(eth->dev, dma_addr,
|
||||
+ dma_sync_single_for_cpu(eth->dev, e->dma_addr,
|
||||
SKB_WITH_OVERHEAD(q->buf_size), dir);
|
||||
|
||||
+ len = FIELD_GET(QDMA_DESC_LEN_MASK, desc_ctrl);
|
||||
data_len = q->skb ? q->buf_size
|
||||
: SKB_WITH_OVERHEAD(q->buf_size);
|
||||
- if (data_len < len)
|
||||
+ if (!len || data_len < len)
|
||||
goto free_frag;
|
||||
|
||||
p = airoha_qdma_get_gdm_port(eth, desc);
|
||||
@@ -723,9 +716,12 @@ static int airoha_qdma_rx_process(struct
|
||||
q->skb = NULL;
|
||||
continue;
|
||||
free_frag:
|
||||
- page_pool_put_full_page(q->page_pool, page, true);
|
||||
- dev_kfree_skb(q->skb);
|
||||
- q->skb = NULL;
|
||||
+ if (q->skb) {
|
||||
+ dev_kfree_skb(q->skb);
|
||||
+ q->skb = NULL;
|
||||
+ } else {
|
||||
+ page_pool_put_full_page(q->page_pool, page, true);
|
||||
+ }
|
||||
}
|
||||
airoha_qdma_fill_rx_queue(q);
|
||||
|
||||
@ -1,196 +0,0 @@
|
||||
From c52918744ee1e49cea86622a2633b9782446428f Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 16 May 2025 09:59:59 +0200
|
||||
Subject: [PATCH 1/3] net: airoha: npu: Move memory allocation in
|
||||
airoha_npu_send_msg() caller
|
||||
|
||||
Move ppe_mbox_data struct memory allocation from airoha_npu_send_msg
|
||||
routine to the caller one. This is a preliminary patch to enable wlan NPU
|
||||
offloading and flow counter stats support.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250516-airoha-en7581-flowstats-v2-1-06d5fbf28984@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 126 +++++++++++++----------
|
||||
1 file changed, 72 insertions(+), 54 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -124,17 +124,12 @@ static int airoha_npu_send_msg(struct ai
|
||||
u16 core = 0; /* FIXME */
|
||||
u32 val, offset = core << 4;
|
||||
dma_addr_t dma_addr;
|
||||
- void *addr;
|
||||
int ret;
|
||||
|
||||
- addr = kmemdup(p, size, GFP_ATOMIC);
|
||||
- if (!addr)
|
||||
- return -ENOMEM;
|
||||
-
|
||||
- dma_addr = dma_map_single(npu->dev, addr, size, DMA_TO_DEVICE);
|
||||
+ dma_addr = dma_map_single(npu->dev, p, size, DMA_TO_DEVICE);
|
||||
ret = dma_mapping_error(npu->dev, dma_addr);
|
||||
if (ret)
|
||||
- goto out;
|
||||
+ return ret;
|
||||
|
||||
spin_lock_bh(&npu->cores[core].lock);
|
||||
|
||||
@@ -155,8 +150,6 @@ static int airoha_npu_send_msg(struct ai
|
||||
spin_unlock_bh(&npu->cores[core].lock);
|
||||
|
||||
dma_unmap_single(npu->dev, dma_addr, size, DMA_TO_DEVICE);
|
||||
-out:
|
||||
- kfree(addr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -261,76 +254,101 @@ static irqreturn_t airoha_npu_wdt_handle
|
||||
|
||||
static int airoha_npu_ppe_init(struct airoha_npu *npu)
|
||||
{
|
||||
- struct ppe_mbox_data ppe_data = {
|
||||
- .func_type = NPU_OP_SET,
|
||||
- .func_id = PPE_FUNC_SET_WAIT_HWNAT_INIT,
|
||||
- .init_info = {
|
||||
- .ppe_type = PPE_TYPE_L2B_IPV4_IPV6,
|
||||
- .wan_mode = QDMA_WAN_ETHER,
|
||||
- },
|
||||
- };
|
||||
+ struct ppe_mbox_data *ppe_data;
|
||||
+ int err;
|
||||
|
||||
- return airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
- sizeof(struct ppe_mbox_data));
|
||||
+ ppe_data = kzalloc(sizeof(*ppe_data), GFP_KERNEL);
|
||||
+ if (!ppe_data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ ppe_data->func_type = NPU_OP_SET;
|
||||
+ ppe_data->func_id = PPE_FUNC_SET_WAIT_HWNAT_INIT;
|
||||
+ ppe_data->init_info.ppe_type = PPE_TYPE_L2B_IPV4_IPV6;
|
||||
+ ppe_data->init_info.wan_mode = QDMA_WAN_ETHER;
|
||||
+
|
||||
+ err = airoha_npu_send_msg(npu, NPU_FUNC_PPE, ppe_data,
|
||||
+ sizeof(*ppe_data));
|
||||
+ kfree(ppe_data);
|
||||
+
|
||||
+ return err;
|
||||
}
|
||||
|
||||
static int airoha_npu_ppe_deinit(struct airoha_npu *npu)
|
||||
{
|
||||
- struct ppe_mbox_data ppe_data = {
|
||||
- .func_type = NPU_OP_SET,
|
||||
- .func_id = PPE_FUNC_SET_WAIT_HWNAT_DEINIT,
|
||||
- };
|
||||
+ struct ppe_mbox_data *ppe_data;
|
||||
+ int err;
|
||||
+
|
||||
+ ppe_data = kzalloc(sizeof(*ppe_data), GFP_KERNEL);
|
||||
+ if (!ppe_data)
|
||||
+ return -ENOMEM;
|
||||
|
||||
- return airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
- sizeof(struct ppe_mbox_data));
|
||||
+ ppe_data->func_type = NPU_OP_SET;
|
||||
+ ppe_data->func_id = PPE_FUNC_SET_WAIT_HWNAT_DEINIT;
|
||||
+
|
||||
+ err = airoha_npu_send_msg(npu, NPU_FUNC_PPE, ppe_data,
|
||||
+ sizeof(*ppe_data));
|
||||
+ kfree(ppe_data);
|
||||
+
|
||||
+ return err;
|
||||
}
|
||||
|
||||
static int airoha_npu_ppe_flush_sram_entries(struct airoha_npu *npu,
|
||||
dma_addr_t foe_addr,
|
||||
int sram_num_entries)
|
||||
{
|
||||
- struct ppe_mbox_data ppe_data = {
|
||||
- .func_type = NPU_OP_SET,
|
||||
- .func_id = PPE_FUNC_SET_WAIT_API,
|
||||
- .set_info = {
|
||||
- .func_id = PPE_SRAM_RESET_VAL,
|
||||
- .data = foe_addr,
|
||||
- .size = sram_num_entries,
|
||||
- },
|
||||
- };
|
||||
+ struct ppe_mbox_data *ppe_data;
|
||||
+ int err;
|
||||
+
|
||||
+ ppe_data = kzalloc(sizeof(*ppe_data), GFP_KERNEL);
|
||||
+ if (!ppe_data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ ppe_data->func_type = NPU_OP_SET;
|
||||
+ ppe_data->func_id = PPE_FUNC_SET_WAIT_API;
|
||||
+ ppe_data->set_info.func_id = PPE_SRAM_RESET_VAL;
|
||||
+ ppe_data->set_info.data = foe_addr;
|
||||
+ ppe_data->set_info.size = sram_num_entries;
|
||||
+
|
||||
+ err = airoha_npu_send_msg(npu, NPU_FUNC_PPE, ppe_data,
|
||||
+ sizeof(*ppe_data));
|
||||
+ kfree(ppe_data);
|
||||
|
||||
- return airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
- sizeof(struct ppe_mbox_data));
|
||||
+ return err;
|
||||
}
|
||||
|
||||
static int airoha_npu_foe_commit_entry(struct airoha_npu *npu,
|
||||
dma_addr_t foe_addr,
|
||||
u32 entry_size, u32 hash, bool ppe2)
|
||||
{
|
||||
- struct ppe_mbox_data ppe_data = {
|
||||
- .func_type = NPU_OP_SET,
|
||||
- .func_id = PPE_FUNC_SET_WAIT_API,
|
||||
- .set_info = {
|
||||
- .data = foe_addr,
|
||||
- .size = entry_size,
|
||||
- },
|
||||
- };
|
||||
+ struct ppe_mbox_data *ppe_data;
|
||||
int err;
|
||||
|
||||
- ppe_data.set_info.func_id = ppe2 ? PPE2_SRAM_SET_ENTRY
|
||||
- : PPE_SRAM_SET_ENTRY;
|
||||
+ ppe_data = kzalloc(sizeof(*ppe_data), GFP_ATOMIC);
|
||||
+ if (!ppe_data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ ppe_data->func_type = NPU_OP_SET;
|
||||
+ ppe_data->func_id = PPE_FUNC_SET_WAIT_API;
|
||||
+ ppe_data->set_info.data = foe_addr;
|
||||
+ ppe_data->set_info.size = entry_size;
|
||||
+ ppe_data->set_info.func_id = ppe2 ? PPE2_SRAM_SET_ENTRY
|
||||
+ : PPE_SRAM_SET_ENTRY;
|
||||
|
||||
- err = airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
- sizeof(struct ppe_mbox_data));
|
||||
+ err = airoha_npu_send_msg(npu, NPU_FUNC_PPE, ppe_data,
|
||||
+ sizeof(*ppe_data));
|
||||
if (err)
|
||||
- return err;
|
||||
+ goto out;
|
||||
|
||||
- ppe_data.set_info.func_id = PPE_SRAM_SET_VAL;
|
||||
- ppe_data.set_info.data = hash;
|
||||
- ppe_data.set_info.size = sizeof(u32);
|
||||
+ ppe_data->set_info.func_id = PPE_SRAM_SET_VAL;
|
||||
+ ppe_data->set_info.data = hash;
|
||||
+ ppe_data->set_info.size = sizeof(u32);
|
||||
+
|
||||
+ err = airoha_npu_send_msg(npu, NPU_FUNC_PPE, ppe_data,
|
||||
+ sizeof(*ppe_data));
|
||||
+out:
|
||||
+ kfree(ppe_data);
|
||||
|
||||
- return airoha_npu_send_msg(npu, NPU_FUNC_PPE, &ppe_data,
|
||||
- sizeof(struct ppe_mbox_data));
|
||||
+ return err;
|
||||
}
|
||||
|
||||
struct airoha_npu *airoha_npu_get(struct device *dev)
|
||||
@ -1,633 +0,0 @@
|
||||
From b81e0f2b58be37628b2e12f8dffdd63c84573e75 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 16 May 2025 10:00:00 +0200
|
||||
Subject: [PATCH 2/3] net: airoha: Add FLOW_CLS_STATS callback support
|
||||
|
||||
Introduce per-flow stats accounting to the flowtable hw offload in
|
||||
the airoha_eth driver. Flow stats are split in the PPE and NPU modules:
|
||||
- PPE: accounts for high 32bit of per-flow stats
|
||||
- NPU: accounts for low 32bit of per-flow stats
|
||||
|
||||
FLOW_CLS_STATS can be enabled or disabled at compile time.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250516-airoha-en7581-flowstats-v2-2-06d5fbf28984@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/Kconfig | 7 +
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 33 +++
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 52 +++-
|
||||
drivers/net/ethernet/airoha/airoha_npu.h | 4 +-
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 269 ++++++++++++++++--
|
||||
.../net/ethernet/airoha/airoha_ppe_debugfs.c | 9 +-
|
||||
6 files changed, 354 insertions(+), 20 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/Kconfig
|
||||
+++ b/drivers/net/ethernet/airoha/Kconfig
|
||||
@@ -24,4 +24,11 @@ config NET_AIROHA
|
||||
This driver supports the gigabit ethernet MACs in the
|
||||
Airoha SoC family.
|
||||
|
||||
+config NET_AIROHA_FLOW_STATS
|
||||
+ default y
|
||||
+ bool "Airoha flow stats"
|
||||
+ depends on NET_AIROHA && NET_AIROHA_NPU
|
||||
+ help
|
||||
+ Enable Aiorha flowtable statistic counters.
|
||||
+
|
||||
endif #NET_VENDOR_AIROHA
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -50,6 +50,14 @@
|
||||
#define PPE_NUM 2
|
||||
#define PPE1_SRAM_NUM_ENTRIES (8 * 1024)
|
||||
#define PPE_SRAM_NUM_ENTRIES (2 * PPE1_SRAM_NUM_ENTRIES)
|
||||
+#ifdef CONFIG_NET_AIROHA_FLOW_STATS
|
||||
+#define PPE1_STATS_NUM_ENTRIES (4 * 1024)
|
||||
+#else
|
||||
+#define PPE1_STATS_NUM_ENTRIES 0
|
||||
+#endif /* CONFIG_NET_AIROHA_FLOW_STATS */
|
||||
+#define PPE_STATS_NUM_ENTRIES (2 * PPE1_STATS_NUM_ENTRIES)
|
||||
+#define PPE1_SRAM_NUM_DATA_ENTRIES (PPE1_SRAM_NUM_ENTRIES - PPE1_STATS_NUM_ENTRIES)
|
||||
+#define PPE_SRAM_NUM_DATA_ENTRIES (2 * PPE1_SRAM_NUM_DATA_ENTRIES)
|
||||
#define PPE_DRAM_NUM_ENTRIES (16 * 1024)
|
||||
#define PPE_NUM_ENTRIES (PPE_SRAM_NUM_ENTRIES + PPE_DRAM_NUM_ENTRIES)
|
||||
#define PPE_HASH_MASK (PPE_NUM_ENTRIES - 1)
|
||||
@@ -261,6 +269,8 @@ struct airoha_foe_mac_info {
|
||||
|
||||
u16 pppoe_id;
|
||||
u16 src_mac_lo;
|
||||
+
|
||||
+ u32 meter;
|
||||
};
|
||||
|
||||
#define AIROHA_FOE_IB1_UNBIND_PREBIND BIT(24)
|
||||
@@ -296,6 +306,11 @@ struct airoha_foe_mac_info {
|
||||
#define AIROHA_FOE_TUNNEL BIT(6)
|
||||
#define AIROHA_FOE_TUNNEL_ID GENMASK(5, 0)
|
||||
|
||||
+#define AIROHA_FOE_TUNNEL_MTU GENMASK(31, 16)
|
||||
+#define AIROHA_FOE_ACNT_GRP3 GENMASK(15, 9)
|
||||
+#define AIROHA_FOE_METER_GRP3 GENMASK(8, 5)
|
||||
+#define AIROHA_FOE_METER_GRP2 GENMASK(4, 0)
|
||||
+
|
||||
struct airoha_foe_bridge {
|
||||
u32 dest_mac_hi;
|
||||
|
||||
@@ -379,6 +394,8 @@ struct airoha_foe_ipv6 {
|
||||
u32 ib2;
|
||||
|
||||
struct airoha_foe_mac_info_common l2;
|
||||
+
|
||||
+ u32 meter;
|
||||
};
|
||||
|
||||
struct airoha_foe_entry {
|
||||
@@ -397,6 +414,16 @@ struct airoha_foe_entry {
|
||||
};
|
||||
};
|
||||
|
||||
+struct airoha_foe_stats {
|
||||
+ u32 bytes;
|
||||
+ u32 packets;
|
||||
+};
|
||||
+
|
||||
+struct airoha_foe_stats64 {
|
||||
+ u64 bytes;
|
||||
+ u64 packets;
|
||||
+};
|
||||
+
|
||||
struct airoha_flow_data {
|
||||
struct ethhdr eth;
|
||||
|
||||
@@ -447,6 +474,7 @@ struct airoha_flow_table_entry {
|
||||
struct hlist_node l2_subflow_node; /* PPE L2 subflow entry */
|
||||
u32 hash;
|
||||
|
||||
+ struct airoha_foe_stats64 stats;
|
||||
enum airoha_flow_entry_type type;
|
||||
|
||||
struct rhash_head node;
|
||||
@@ -523,6 +551,9 @@ struct airoha_ppe {
|
||||
struct hlist_head *foe_flow;
|
||||
u16 foe_check_time[PPE_NUM_ENTRIES];
|
||||
|
||||
+ struct airoha_foe_stats *foe_stats;
|
||||
+ dma_addr_t foe_stats_dma;
|
||||
+
|
||||
struct dentry *debugfs_dir;
|
||||
};
|
||||
|
||||
@@ -582,6 +613,8 @@ int airoha_ppe_init(struct airoha_eth *e
|
||||
void airoha_ppe_deinit(struct airoha_eth *eth);
|
||||
struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
|
||||
u32 hash);
|
||||
+void airoha_ppe_foe_entry_get_stats(struct airoha_ppe *ppe, u32 hash,
|
||||
+ struct airoha_foe_stats64 *stats);
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
int airoha_ppe_debugfs_init(struct airoha_ppe *ppe);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <linux/of_reserved_mem.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
+#include "airoha_eth.h"
|
||||
#include "airoha_npu.h"
|
||||
|
||||
#define NPU_EN7581_FIRMWARE_DATA "airoha/en7581_npu_data.bin"
|
||||
@@ -72,6 +73,7 @@ enum {
|
||||
PPE_FUNC_SET_WAIT_HWNAT_INIT,
|
||||
PPE_FUNC_SET_WAIT_HWNAT_DEINIT,
|
||||
PPE_FUNC_SET_WAIT_API,
|
||||
+ PPE_FUNC_SET_WAIT_FLOW_STATS_SETUP,
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -115,6 +117,10 @@ struct ppe_mbox_data {
|
||||
u32 size;
|
||||
u32 data;
|
||||
} set_info;
|
||||
+ struct {
|
||||
+ u32 npu_stats_addr;
|
||||
+ u32 foe_stats_addr;
|
||||
+ } stats_info;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -351,7 +357,40 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
-struct airoha_npu *airoha_npu_get(struct device *dev)
|
||||
+static int airoha_npu_stats_setup(struct airoha_npu *npu,
|
||||
+ dma_addr_t foe_stats_addr)
|
||||
+{
|
||||
+ int err, size = PPE_STATS_NUM_ENTRIES * sizeof(*npu->stats);
|
||||
+ struct ppe_mbox_data *ppe_data;
|
||||
+
|
||||
+ if (!size) /* flow stats are disabled */
|
||||
+ return 0;
|
||||
+
|
||||
+ ppe_data = kzalloc(sizeof(*ppe_data), GFP_ATOMIC);
|
||||
+ if (!ppe_data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ ppe_data->func_type = NPU_OP_SET;
|
||||
+ ppe_data->func_id = PPE_FUNC_SET_WAIT_FLOW_STATS_SETUP;
|
||||
+ ppe_data->stats_info.foe_stats_addr = foe_stats_addr;
|
||||
+
|
||||
+ err = airoha_npu_send_msg(npu, NPU_FUNC_PPE, ppe_data,
|
||||
+ sizeof(*ppe_data));
|
||||
+ if (err)
|
||||
+ goto out;
|
||||
+
|
||||
+ npu->stats = devm_ioremap(npu->dev,
|
||||
+ ppe_data->stats_info.npu_stats_addr,
|
||||
+ size);
|
||||
+ if (!npu->stats)
|
||||
+ err = -ENOMEM;
|
||||
+out:
|
||||
+ kfree(ppe_data);
|
||||
+
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
|
||||
{
|
||||
struct platform_device *pdev;
|
||||
struct device_node *np;
|
||||
@@ -389,6 +428,17 @@ struct airoha_npu *airoha_npu_get(struct
|
||||
goto error_module_put;
|
||||
}
|
||||
|
||||
+ if (stats_addr) {
|
||||
+ int err;
|
||||
+
|
||||
+ err = airoha_npu_stats_setup(npu, *stats_addr);
|
||||
+ if (err) {
|
||||
+ dev_err(dev, "failed to allocate npu stats buffer\n");
|
||||
+ npu = ERR_PTR(err);
|
||||
+ goto error_module_put;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
return npu;
|
||||
|
||||
error_module_put:
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
@@ -17,6 +17,8 @@ struct airoha_npu {
|
||||
struct work_struct wdt_work;
|
||||
} cores[NPU_NUM_CORES];
|
||||
|
||||
+ struct airoha_foe_stats __iomem *stats;
|
||||
+
|
||||
struct {
|
||||
int (*ppe_init)(struct airoha_npu *npu);
|
||||
int (*ppe_deinit)(struct airoha_npu *npu);
|
||||
@@ -30,5 +32,5 @@ struct airoha_npu {
|
||||
} ops;
|
||||
};
|
||||
|
||||
-struct airoha_npu *airoha_npu_get(struct device *dev);
|
||||
+struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr);
|
||||
void airoha_npu_put(struct airoha_npu *npu);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -102,7 +102,7 @@ static void airoha_ppe_hw_init(struct ai
|
||||
|
||||
if (airoha_ppe2_is_enabled(eth)) {
|
||||
sram_num_entries =
|
||||
- PPE_RAM_NUM_ENTRIES_SHIFT(PPE1_SRAM_NUM_ENTRIES);
|
||||
+ PPE_RAM_NUM_ENTRIES_SHIFT(PPE1_SRAM_NUM_DATA_ENTRIES);
|
||||
airoha_fe_rmw(eth, REG_PPE_TB_CFG(0),
|
||||
PPE_SRAM_TB_NUM_ENTRY_MASK |
|
||||
PPE_DRAM_TB_NUM_ENTRY_MASK,
|
||||
@@ -119,7 +119,7 @@ static void airoha_ppe_hw_init(struct ai
|
||||
dram_num_entries));
|
||||
} else {
|
||||
sram_num_entries =
|
||||
- PPE_RAM_NUM_ENTRIES_SHIFT(PPE_SRAM_NUM_ENTRIES);
|
||||
+ PPE_RAM_NUM_ENTRIES_SHIFT(PPE_SRAM_NUM_DATA_ENTRIES);
|
||||
airoha_fe_rmw(eth, REG_PPE_TB_CFG(0),
|
||||
PPE_SRAM_TB_NUM_ENTRY_MASK |
|
||||
PPE_DRAM_TB_NUM_ENTRY_MASK,
|
||||
@@ -417,6 +417,77 @@ static u32 airoha_ppe_foe_get_entry_hash
|
||||
return hash;
|
||||
}
|
||||
|
||||
+static u32 airoha_ppe_foe_get_flow_stats_index(struct airoha_ppe *ppe, u32 hash)
|
||||
+{
|
||||
+ if (!airoha_ppe2_is_enabled(ppe->eth))
|
||||
+ return hash;
|
||||
+
|
||||
+ return hash >= PPE_STATS_NUM_ENTRIES ? hash - PPE1_STATS_NUM_ENTRIES
|
||||
+ : hash;
|
||||
+}
|
||||
+
|
||||
+static void airoha_ppe_foe_flow_stat_entry_reset(struct airoha_ppe *ppe,
|
||||
+ struct airoha_npu *npu,
|
||||
+ int index)
|
||||
+{
|
||||
+ memset_io(&npu->stats[index], 0, sizeof(*npu->stats));
|
||||
+ memset(&ppe->foe_stats[index], 0, sizeof(*ppe->foe_stats));
|
||||
+}
|
||||
+
|
||||
+static void airoha_ppe_foe_flow_stats_reset(struct airoha_ppe *ppe,
|
||||
+ struct airoha_npu *npu)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < PPE_STATS_NUM_ENTRIES; i++)
|
||||
+ airoha_ppe_foe_flow_stat_entry_reset(ppe, npu, i);
|
||||
+}
|
||||
+
|
||||
+static void airoha_ppe_foe_flow_stats_update(struct airoha_ppe *ppe,
|
||||
+ struct airoha_npu *npu,
|
||||
+ struct airoha_foe_entry *hwe,
|
||||
+ u32 hash)
|
||||
+{
|
||||
+ int type = FIELD_GET(AIROHA_FOE_IB1_BIND_PACKET_TYPE, hwe->ib1);
|
||||
+ u32 index, pse_port, val, *data, *ib2, *meter;
|
||||
+ u8 nbq;
|
||||
+
|
||||
+ index = airoha_ppe_foe_get_flow_stats_index(ppe, hash);
|
||||
+ if (index >= PPE_STATS_NUM_ENTRIES)
|
||||
+ return;
|
||||
+
|
||||
+ if (type == PPE_PKT_TYPE_BRIDGE) {
|
||||
+ data = &hwe->bridge.data;
|
||||
+ ib2 = &hwe->bridge.ib2;
|
||||
+ meter = &hwe->bridge.l2.meter;
|
||||
+ } else if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T) {
|
||||
+ data = &hwe->ipv6.data;
|
||||
+ ib2 = &hwe->ipv6.ib2;
|
||||
+ meter = &hwe->ipv6.meter;
|
||||
+ } else {
|
||||
+ data = &hwe->ipv4.data;
|
||||
+ ib2 = &hwe->ipv4.ib2;
|
||||
+ meter = &hwe->ipv4.l2.meter;
|
||||
+ }
|
||||
+
|
||||
+ airoha_ppe_foe_flow_stat_entry_reset(ppe, npu, index);
|
||||
+
|
||||
+ val = FIELD_GET(AIROHA_FOE_CHANNEL | AIROHA_FOE_QID, *data);
|
||||
+ *data = (*data & ~AIROHA_FOE_ACTDP) |
|
||||
+ FIELD_PREP(AIROHA_FOE_ACTDP, val);
|
||||
+
|
||||
+ val = *ib2 & (AIROHA_FOE_IB2_NBQ | AIROHA_FOE_IB2_PSE_PORT |
|
||||
+ AIROHA_FOE_IB2_PSE_QOS | AIROHA_FOE_IB2_FAST_PATH);
|
||||
+ *meter |= FIELD_PREP(AIROHA_FOE_TUNNEL_MTU, val);
|
||||
+
|
||||
+ pse_port = FIELD_GET(AIROHA_FOE_IB2_PSE_PORT, *ib2);
|
||||
+ nbq = pse_port == 1 ? 6 : 5;
|
||||
+ *ib2 &= ~(AIROHA_FOE_IB2_NBQ | AIROHA_FOE_IB2_PSE_PORT |
|
||||
+ AIROHA_FOE_IB2_PSE_QOS);
|
||||
+ *ib2 |= FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT, 6) |
|
||||
+ FIELD_PREP(AIROHA_FOE_IB2_NBQ, nbq);
|
||||
+}
|
||||
+
|
||||
struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
|
||||
u32 hash)
|
||||
{
|
||||
@@ -470,6 +541,8 @@ static int airoha_ppe_foe_commit_entry(s
|
||||
struct airoha_foe_entry *hwe = ppe->foe + hash * sizeof(*hwe);
|
||||
u32 ts = airoha_ppe_get_timestamp(ppe);
|
||||
struct airoha_eth *eth = ppe->eth;
|
||||
+ struct airoha_npu *npu;
|
||||
+ int err = 0;
|
||||
|
||||
memcpy(&hwe->d, &e->d, sizeof(*hwe) - sizeof(hwe->ib1));
|
||||
wmb();
|
||||
@@ -478,25 +551,28 @@ static int airoha_ppe_foe_commit_entry(s
|
||||
e->ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_TIMESTAMP, ts);
|
||||
hwe->ib1 = e->ib1;
|
||||
|
||||
+ rcu_read_lock();
|
||||
+
|
||||
+ npu = rcu_dereference(eth->npu);
|
||||
+ if (!npu) {
|
||||
+ err = -ENODEV;
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+
|
||||
+ airoha_ppe_foe_flow_stats_update(ppe, npu, hwe, hash);
|
||||
+
|
||||
if (hash < PPE_SRAM_NUM_ENTRIES) {
|
||||
dma_addr_t addr = ppe->foe_dma + hash * sizeof(*hwe);
|
||||
bool ppe2 = airoha_ppe2_is_enabled(eth) &&
|
||||
hash >= PPE1_SRAM_NUM_ENTRIES;
|
||||
- struct airoha_npu *npu;
|
||||
- int err = -ENODEV;
|
||||
-
|
||||
- rcu_read_lock();
|
||||
- npu = rcu_dereference(eth->npu);
|
||||
- if (npu)
|
||||
- err = npu->ops.ppe_foe_commit_entry(npu, addr,
|
||||
- sizeof(*hwe), hash,
|
||||
- ppe2);
|
||||
- rcu_read_unlock();
|
||||
|
||||
- return err;
|
||||
+ err = npu->ops.ppe_foe_commit_entry(npu, addr, sizeof(*hwe),
|
||||
+ hash, ppe2);
|
||||
}
|
||||
+unlock:
|
||||
+ rcu_read_unlock();
|
||||
|
||||
- return 0;
|
||||
+ return err;
|
||||
}
|
||||
|
||||
static void airoha_ppe_foe_remove_flow(struct airoha_ppe *ppe,
|
||||
@@ -582,6 +658,7 @@ airoha_ppe_foe_commit_subflow_entry(stru
|
||||
l2->common.etype = ETH_P_IPV6;
|
||||
|
||||
hwe.bridge.ib2 = e->data.bridge.ib2;
|
||||
+ hwe.bridge.data = e->data.bridge.data;
|
||||
airoha_ppe_foe_commit_entry(ppe, &hwe, hash);
|
||||
|
||||
return 0;
|
||||
@@ -681,6 +758,98 @@ static int airoha_ppe_foe_flow_commit_en
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int airoha_ppe_get_entry_idle_time(struct airoha_ppe *ppe, u32 ib1)
|
||||
+{
|
||||
+ u32 state = FIELD_GET(AIROHA_FOE_IB1_BIND_STATE, ib1);
|
||||
+ u32 ts, ts_mask, now = airoha_ppe_get_timestamp(ppe);
|
||||
+ int idle;
|
||||
+
|
||||
+ if (state == AIROHA_FOE_STATE_BIND) {
|
||||
+ ts = FIELD_GET(AIROHA_FOE_IB1_BIND_TIMESTAMP, ib1);
|
||||
+ ts_mask = AIROHA_FOE_IB1_BIND_TIMESTAMP;
|
||||
+ } else {
|
||||
+ ts = FIELD_GET(AIROHA_FOE_IB1_UNBIND_TIMESTAMP, ib1);
|
||||
+ now = FIELD_GET(AIROHA_FOE_IB1_UNBIND_TIMESTAMP, now);
|
||||
+ ts_mask = AIROHA_FOE_IB1_UNBIND_TIMESTAMP;
|
||||
+ }
|
||||
+ idle = now - ts;
|
||||
+
|
||||
+ return idle < 0 ? idle + ts_mask + 1 : idle;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+airoha_ppe_foe_flow_l2_entry_update(struct airoha_ppe *ppe,
|
||||
+ struct airoha_flow_table_entry *e)
|
||||
+{
|
||||
+ int min_idle = airoha_ppe_get_entry_idle_time(ppe, e->data.ib1);
|
||||
+ struct airoha_flow_table_entry *iter;
|
||||
+ struct hlist_node *n;
|
||||
+
|
||||
+ lockdep_assert_held(&ppe_lock);
|
||||
+
|
||||
+ hlist_for_each_entry_safe(iter, n, &e->l2_flows, l2_subflow_node) {
|
||||
+ struct airoha_foe_entry *hwe;
|
||||
+ u32 ib1, state;
|
||||
+ int idle;
|
||||
+
|
||||
+ hwe = airoha_ppe_foe_get_entry(ppe, iter->hash);
|
||||
+ ib1 = READ_ONCE(hwe->ib1);
|
||||
+
|
||||
+ state = FIELD_GET(AIROHA_FOE_IB1_BIND_STATE, ib1);
|
||||
+ if (state != AIROHA_FOE_STATE_BIND) {
|
||||
+ iter->hash = 0xffff;
|
||||
+ airoha_ppe_foe_remove_flow(ppe, iter);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ idle = airoha_ppe_get_entry_idle_time(ppe, ib1);
|
||||
+ if (idle >= min_idle)
|
||||
+ continue;
|
||||
+
|
||||
+ min_idle = idle;
|
||||
+ e->data.ib1 &= ~AIROHA_FOE_IB1_BIND_TIMESTAMP;
|
||||
+ e->data.ib1 |= ib1 & AIROHA_FOE_IB1_BIND_TIMESTAMP;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void airoha_ppe_foe_flow_entry_update(struct airoha_ppe *ppe,
|
||||
+ struct airoha_flow_table_entry *e)
|
||||
+{
|
||||
+ struct airoha_foe_entry *hwe_p, hwe = {};
|
||||
+
|
||||
+ spin_lock_bh(&ppe_lock);
|
||||
+
|
||||
+ if (e->type == FLOW_TYPE_L2) {
|
||||
+ airoha_ppe_foe_flow_l2_entry_update(ppe, e);
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+
|
||||
+ if (e->hash == 0xffff)
|
||||
+ goto unlock;
|
||||
+
|
||||
+ hwe_p = airoha_ppe_foe_get_entry(ppe, e->hash);
|
||||
+ if (!hwe_p)
|
||||
+ goto unlock;
|
||||
+
|
||||
+ memcpy(&hwe, hwe_p, sizeof(*hwe_p));
|
||||
+ if (!airoha_ppe_foe_compare_entry(e, &hwe)) {
|
||||
+ e->hash = 0xffff;
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+
|
||||
+ e->data.ib1 = hwe.ib1;
|
||||
+unlock:
|
||||
+ spin_unlock_bh(&ppe_lock);
|
||||
+}
|
||||
+
|
||||
+static int airoha_ppe_entry_idle_time(struct airoha_ppe *ppe,
|
||||
+ struct airoha_flow_table_entry *e)
|
||||
+{
|
||||
+ airoha_ppe_foe_flow_entry_update(ppe, e);
|
||||
+
|
||||
+ return airoha_ppe_get_entry_idle_time(ppe, e->data.ib1);
|
||||
+}
|
||||
+
|
||||
static int airoha_ppe_flow_offload_replace(struct airoha_gdm_port *port,
|
||||
struct flow_cls_offload *f)
|
||||
{
|
||||
@@ -896,6 +1065,60 @@ static int airoha_ppe_flow_offload_destr
|
||||
return 0;
|
||||
}
|
||||
|
||||
+void airoha_ppe_foe_entry_get_stats(struct airoha_ppe *ppe, u32 hash,
|
||||
+ struct airoha_foe_stats64 *stats)
|
||||
+{
|
||||
+ u32 index = airoha_ppe_foe_get_flow_stats_index(ppe, hash);
|
||||
+ struct airoha_eth *eth = ppe->eth;
|
||||
+ struct airoha_npu *npu;
|
||||
+
|
||||
+ if (index >= PPE_STATS_NUM_ENTRIES)
|
||||
+ return;
|
||||
+
|
||||
+ rcu_read_lock();
|
||||
+
|
||||
+ npu = rcu_dereference(eth->npu);
|
||||
+ if (npu) {
|
||||
+ u64 packets = ppe->foe_stats[index].packets;
|
||||
+ u64 bytes = ppe->foe_stats[index].bytes;
|
||||
+ struct airoha_foe_stats npu_stats;
|
||||
+
|
||||
+ memcpy_fromio(&npu_stats, &npu->stats[index],
|
||||
+ sizeof(*npu->stats));
|
||||
+ stats->packets = packets << 32 | npu_stats.packets;
|
||||
+ stats->bytes = bytes << 32 | npu_stats.bytes;
|
||||
+ }
|
||||
+
|
||||
+ rcu_read_unlock();
|
||||
+}
|
||||
+
|
||||
+static int airoha_ppe_flow_offload_stats(struct airoha_gdm_port *port,
|
||||
+ struct flow_cls_offload *f)
|
||||
+{
|
||||
+ struct airoha_eth *eth = port->qdma->eth;
|
||||
+ struct airoha_flow_table_entry *e;
|
||||
+ u32 idle;
|
||||
+
|
||||
+ e = rhashtable_lookup(ð->flow_table, &f->cookie,
|
||||
+ airoha_flow_table_params);
|
||||
+ if (!e)
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ idle = airoha_ppe_entry_idle_time(eth->ppe, e);
|
||||
+ f->stats.lastused = jiffies - idle * HZ;
|
||||
+
|
||||
+ if (e->hash != 0xffff) {
|
||||
+ struct airoha_foe_stats64 stats = {};
|
||||
+
|
||||
+ airoha_ppe_foe_entry_get_stats(eth->ppe, e->hash, &stats);
|
||||
+ f->stats.pkts += (stats.packets - e->stats.packets);
|
||||
+ f->stats.bytes += (stats.bytes - e->stats.bytes);
|
||||
+ e->stats = stats;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int airoha_ppe_flow_offload_cmd(struct airoha_gdm_port *port,
|
||||
struct flow_cls_offload *f)
|
||||
{
|
||||
@@ -904,6 +1127,8 @@ static int airoha_ppe_flow_offload_cmd(s
|
||||
return airoha_ppe_flow_offload_replace(port, f);
|
||||
case FLOW_CLS_DESTROY:
|
||||
return airoha_ppe_flow_offload_destroy(port, f);
|
||||
+ case FLOW_CLS_STATS:
|
||||
+ return airoha_ppe_flow_offload_stats(port, f);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -929,11 +1154,12 @@ static int airoha_ppe_flush_sram_entries
|
||||
|
||||
static struct airoha_npu *airoha_ppe_npu_get(struct airoha_eth *eth)
|
||||
{
|
||||
- struct airoha_npu *npu = airoha_npu_get(eth->dev);
|
||||
+ struct airoha_npu *npu = airoha_npu_get(eth->dev,
|
||||
+ ð->ppe->foe_stats_dma);
|
||||
|
||||
if (IS_ERR(npu)) {
|
||||
request_module("airoha-npu");
|
||||
- npu = airoha_npu_get(eth->dev);
|
||||
+ npu = airoha_npu_get(eth->dev, ð->ppe->foe_stats_dma);
|
||||
}
|
||||
|
||||
return npu;
|
||||
@@ -956,6 +1182,8 @@ static int airoha_ppe_offload_setup(stru
|
||||
if (err)
|
||||
goto error_npu_put;
|
||||
|
||||
+ airoha_ppe_foe_flow_stats_reset(eth->ppe, npu);
|
||||
+
|
||||
rcu_assign_pointer(eth->npu, npu);
|
||||
synchronize_rcu();
|
||||
|
||||
@@ -1027,6 +1255,15 @@ int airoha_ppe_init(struct airoha_eth *e
|
||||
if (!ppe->foe_flow)
|
||||
return -ENOMEM;
|
||||
|
||||
+ foe_size = PPE_STATS_NUM_ENTRIES * sizeof(*ppe->foe_stats);
|
||||
+ if (foe_size) {
|
||||
+ ppe->foe_stats = dmam_alloc_coherent(eth->dev, foe_size,
|
||||
+ &ppe->foe_stats_dma,
|
||||
+ GFP_KERNEL);
|
||||
+ if (!ppe->foe_stats)
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
err = rhashtable_init(ð->flow_table, &airoha_flow_table_params);
|
||||
if (err)
|
||||
return err;
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe_debugfs.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe_debugfs.c
|
||||
@@ -61,6 +61,7 @@ static int airoha_ppe_debugfs_foe_show(s
|
||||
u16 *src_port = NULL, *dest_port = NULL;
|
||||
struct airoha_foe_mac_info_common *l2;
|
||||
unsigned char h_source[ETH_ALEN] = {};
|
||||
+ struct airoha_foe_stats64 stats = {};
|
||||
unsigned char h_dest[ETH_ALEN];
|
||||
struct airoha_foe_entry *hwe;
|
||||
u32 type, state, ib2, data;
|
||||
@@ -144,14 +145,18 @@ static int airoha_ppe_debugfs_foe_show(s
|
||||
cpu_to_be16(hwe->ipv4.l2.src_mac_lo);
|
||||
}
|
||||
|
||||
+ airoha_ppe_foe_entry_get_stats(ppe, i, &stats);
|
||||
+
|
||||
*((__be32 *)h_dest) = cpu_to_be32(l2->dest_mac_hi);
|
||||
*((__be16 *)&h_dest[4]) = cpu_to_be16(l2->dest_mac_lo);
|
||||
*((__be32 *)h_source) = cpu_to_be32(l2->src_mac_hi);
|
||||
|
||||
seq_printf(m, " eth=%pM->%pM etype=%04x data=%08x"
|
||||
- " vlan=%d,%d ib1=%08x ib2=%08x\n",
|
||||
+ " vlan=%d,%d ib1=%08x ib2=%08x"
|
||||
+ " packets=%llu bytes=%llu\n",
|
||||
h_source, h_dest, l2->etype, data,
|
||||
- l2->vlan1, l2->vlan2, hwe->ib1, ib2);
|
||||
+ l2->vlan1, l2->vlan2, hwe->ib1, ib2,
|
||||
+ stats.packets, stats.bytes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1,28 +0,0 @@
|
||||
From a98326c151ea3d92e9496858cc2dacccd0870941 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 16 May 2025 10:00:01 +0200
|
||||
Subject: [PATCH 3/3] net: airoha: ppe: Disable packet keepalive
|
||||
|
||||
Since netfilter flowtable entries are now refreshed by flow-stats
|
||||
polling, we can disable hw packet keepalive used to periodically send
|
||||
packets belonging to offloaded flows to the kernel in order to refresh
|
||||
flowtable entries.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250516-airoha-en7581-flowstats-v2-3-06d5fbf28984@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -84,6 +84,7 @@ static void airoha_ppe_hw_init(struct ai
|
||||
|
||||
airoha_fe_rmw(eth, REG_PPE_TB_CFG(i),
|
||||
PPE_TB_CFG_SEARCH_MISS_MASK |
|
||||
+ PPE_TB_CFG_KEEPALIVE_MASK |
|
||||
PPE_TB_ENTRY_SIZE_MASK,
|
||||
FIELD_PREP(PPE_TB_CFG_SEARCH_MISS_MASK, 3) |
|
||||
FIELD_PREP(PPE_TB_ENTRY_SIZE_MASK, 0));
|
||||
@ -1,57 +0,0 @@
|
||||
From 09aa788f98da3e2f41ce158cc691d6d52e808bc9 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 21 May 2025 09:16:37 +0200
|
||||
Subject: [PATCH 1/3] net: airoha: Do not store hfwd references in airoha_qdma
|
||||
struct
|
||||
|
||||
Since hfwd descriptor and buffer queues are allocated via
|
||||
dmam_alloc_coherent() we do not need to store their references
|
||||
in airoha_qdma struct. This patch does not introduce any logical changes,
|
||||
just code clean-up.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250521-airopha-desc-sram-v3-2-a6e9b085b4f0@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 8 ++------
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 6 ------
|
||||
2 files changed, 2 insertions(+), 12 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -1098,17 +1098,13 @@ static int airoha_qdma_init_hfwd_queues(
|
||||
int size;
|
||||
|
||||
size = HW_DSCP_NUM * sizeof(struct airoha_qdma_fwd_desc);
|
||||
- qdma->hfwd.desc = dmam_alloc_coherent(eth->dev, size, &dma_addr,
|
||||
- GFP_KERNEL);
|
||||
- if (!qdma->hfwd.desc)
|
||||
+ if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL))
|
||||
return -ENOMEM;
|
||||
|
||||
airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr);
|
||||
|
||||
size = AIROHA_MAX_PACKET_SIZE * HW_DSCP_NUM;
|
||||
- qdma->hfwd.q = dmam_alloc_coherent(eth->dev, size, &dma_addr,
|
||||
- GFP_KERNEL);
|
||||
- if (!qdma->hfwd.q)
|
||||
+ if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL))
|
||||
return -ENOMEM;
|
||||
|
||||
airoha_qdma_wr(qdma, REG_FWD_BUF_BASE, dma_addr);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -513,12 +513,6 @@ struct airoha_qdma {
|
||||
|
||||
struct airoha_queue q_tx[AIROHA_NUM_TX_RING];
|
||||
struct airoha_queue q_rx[AIROHA_NUM_RX_RING];
|
||||
-
|
||||
- /* descriptor and packet buffers for qdma hw forward */
|
||||
- struct {
|
||||
- void *desc;
|
||||
- void *q;
|
||||
- } hfwd;
|
||||
};
|
||||
|
||||
struct airoha_gdm_port {
|
||||
@ -1,79 +0,0 @@
|
||||
From 3a1ce9e3d01bbf3912c3e3f81cb554d558eb715b Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 21 May 2025 09:16:38 +0200
|
||||
Subject: [PATCH 2/3] net: airoha: Add the capability to allocate hwfd buffers
|
||||
via reserved-memory
|
||||
|
||||
In some configurations QDMA blocks require a contiguous block of
|
||||
system memory for hwfd buffers queue. Introduce the capability to allocate
|
||||
hw buffers forwarding queue via the reserved-memory DTS property instead of
|
||||
running dmam_alloc_coherent().
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250521-airopha-desc-sram-v3-3-a6e9b085b4f0@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 33 +++++++++++++++++++++---
|
||||
1 file changed, 30 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_net.h>
|
||||
+#include <linux/of_reserved_mem.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/u64_stats_sync.h>
|
||||
@@ -1093,9 +1094,11 @@ static void airoha_qdma_cleanup_tx_queue
|
||||
static int airoha_qdma_init_hfwd_queues(struct airoha_qdma *qdma)
|
||||
{
|
||||
struct airoha_eth *eth = qdma->eth;
|
||||
+ int id = qdma - ð->qdma[0];
|
||||
dma_addr_t dma_addr;
|
||||
+ const char *name;
|
||||
+ int size, index;
|
||||
u32 status;
|
||||
- int size;
|
||||
|
||||
size = HW_DSCP_NUM * sizeof(struct airoha_qdma_fwd_desc);
|
||||
if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL))
|
||||
@@ -1103,10 +1106,34 @@ static int airoha_qdma_init_hfwd_queues(
|
||||
|
||||
airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr);
|
||||
|
||||
- size = AIROHA_MAX_PACKET_SIZE * HW_DSCP_NUM;
|
||||
- if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL))
|
||||
+ name = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d-buf", id);
|
||||
+ if (!name)
|
||||
return -ENOMEM;
|
||||
|
||||
+ index = of_property_match_string(eth->dev->of_node,
|
||||
+ "memory-region-names", name);
|
||||
+ if (index >= 0) {
|
||||
+ struct reserved_mem *rmem;
|
||||
+ struct device_node *np;
|
||||
+
|
||||
+ /* Consume reserved memory for hw forwarding buffers queue if
|
||||
+ * available in the DTS
|
||||
+ */
|
||||
+ np = of_parse_phandle(eth->dev->of_node, "memory-region",
|
||||
+ index);
|
||||
+ if (!np)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ rmem = of_reserved_mem_lookup(np);
|
||||
+ of_node_put(np);
|
||||
+ dma_addr = rmem->base;
|
||||
+ } else {
|
||||
+ size = AIROHA_MAX_PACKET_SIZE * HW_DSCP_NUM;
|
||||
+ if (!dmam_alloc_coherent(eth->dev, size, &dma_addr,
|
||||
+ GFP_KERNEL))
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
airoha_qdma_wr(qdma, REG_FWD_BUF_BASE, dma_addr);
|
||||
|
||||
airoha_qdma_rmw(qdma, REG_HW_FWD_DSCP_CFG,
|
||||
@ -1,82 +0,0 @@
|
||||
From c683e378c0907e66cee939145edf936c254ff1e3 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 21 May 2025 09:16:39 +0200
|
||||
Subject: [PATCH 3/3] net: airoha: Add the capability to allocate hfwd
|
||||
descriptors in SRAM
|
||||
|
||||
In order to improve packet processing and packet forwarding
|
||||
performances, EN7581 SoC supports consuming SRAM instead of DRAM for
|
||||
hw forwarding descriptors queue.
|
||||
For downlink hw accelerated traffic request to consume SRAM memory
|
||||
for hw forwarding descriptors queue.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250521-airopha-desc-sram-v3-4-a6e9b085b4f0@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 11 +----------
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 9 +++++++++
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 6 ++++++
|
||||
3 files changed, 16 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -71,15 +71,6 @@ static void airoha_qdma_irq_disable(stru
|
||||
airoha_qdma_set_irqmask(irq_bank, index, mask, 0);
|
||||
}
|
||||
|
||||
-static bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
|
||||
-{
|
||||
- /* GDM1 port on EN7581 SoC is connected to the lan dsa switch.
|
||||
- * GDM{2,3,4} can be used as wan port connected to an external
|
||||
- * phy module.
|
||||
- */
|
||||
- return port->id == 1;
|
||||
-}
|
||||
-
|
||||
static void airoha_set_macaddr(struct airoha_gdm_port *port, const u8 *addr)
|
||||
{
|
||||
struct airoha_eth *eth = port->qdma->eth;
|
||||
@@ -1145,7 +1136,7 @@ static int airoha_qdma_init_hfwd_queues(
|
||||
LMGR_INIT_START | LMGR_SRAM_MODE_MASK |
|
||||
HW_FWD_DESC_NUM_MASK,
|
||||
FIELD_PREP(HW_FWD_DESC_NUM_MASK, HW_DSCP_NUM) |
|
||||
- LMGR_INIT_START);
|
||||
+ LMGR_INIT_START | LMGR_SRAM_MODE_MASK);
|
||||
|
||||
return read_poll_timeout(airoha_qdma_rr, status,
|
||||
!(status & LMGR_INIT_START), USEC_PER_MSEC,
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -597,6 +597,15 @@ u32 airoha_rmw(void __iomem *base, u32 o
|
||||
#define airoha_qdma_clear(qdma, offset, val) \
|
||||
airoha_rmw((qdma)->regs, (offset), (val), 0)
|
||||
|
||||
+static inline bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
|
||||
+{
|
||||
+ /* GDM1 port on EN7581 SoC is connected to the lan dsa switch.
|
||||
+ * GDM{2,3,4} can be used as wan port connected to an external
|
||||
+ * phy module.
|
||||
+ */
|
||||
+ return port->id == 1;
|
||||
+}
|
||||
+
|
||||
bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
|
||||
struct airoha_gdm_port *port);
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -251,6 +251,12 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
else
|
||||
pse_port = 2; /* uplink relies on GDM2 loopback */
|
||||
val |= FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT, pse_port);
|
||||
+
|
||||
+ /* For downlink traffic consume SRAM memory for hw forwarding
|
||||
+ * descriptors queue.
|
||||
+ */
|
||||
+ if (airhoa_is_lan_gdm_port(port))
|
||||
+ val |= AIROHA_FOE_IB2_FAST_PATH;
|
||||
}
|
||||
|
||||
if (is_multicast_ether_addr(data->eth.h_dest))
|
||||
@ -1,42 +0,0 @@
|
||||
From c59783780c8ad66f6076a9a7c74df3e006e29519 Mon Sep 17 00:00:00 2001
|
||||
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
|
||||
Date: Sat, 24 May 2025 09:29:11 +0200
|
||||
Subject: [PATCH] net: airoha: Fix an error handling path in
|
||||
airoha_alloc_gdm_port()
|
||||
|
||||
If register_netdev() fails, the error handling path of the probe will not
|
||||
free the memory allocated by the previous airoha_metadata_dst_alloc() call
|
||||
because port->dev->reg_state will not be NETREG_REGISTERED.
|
||||
|
||||
So, an explicit airoha_metadata_dst_free() call is needed in this case to
|
||||
avoid a memory leak.
|
||||
|
||||
Fixes: af3cf757d5c9 ("net: airoha: Move DSA tag in DMA descriptor")
|
||||
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
|
||||
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/1b94b91345017429ed653e2f05d25620dc2823f9.1746715755.git.christophe.jaillet@wanadoo.fr
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -2901,7 +2901,15 @@ static int airoha_alloc_gdm_port(struct
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- return register_netdev(dev);
|
||||
+ err = register_netdev(dev);
|
||||
+ if (err)
|
||||
+ goto free_metadata_dst;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+free_metadata_dst:
|
||||
+ airoha_metadata_dst_free(port);
|
||||
+ return err;
|
||||
}
|
||||
|
||||
static int airoha_probe(struct platform_device *pdev)
|
||||
@ -1,122 +0,0 @@
|
||||
From a869d3a5eb011a9cf9bd864f31f5cf27362de8c7 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 2 Jun 2025 12:55:37 +0200
|
||||
Subject: [PATCH 1/3] net: airoha: Initialize PPE UPDMEM source-mac table
|
||||
|
||||
UPDMEM source-mac table is a key-value map used to store devices mac
|
||||
addresses according to the port identifier. UPDMEM source mac table is
|
||||
used during IPv6 traffic hw acceleration since PPE entries, for space
|
||||
constraints, do not contain the full source mac address but just the
|
||||
identifier in the UPDMEM source-mac table.
|
||||
Configure UPDMEM source-mac table with device mac addresses and set
|
||||
the source-mac ID field for PPE IPv6 entries in order to select the
|
||||
proper device mac address as source mac for L3 IPv6 hw accelerated traffic.
|
||||
|
||||
Fixes: 00a7678310fe ("net: airoha: Introduce flowtable offload support")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250602-airoha-flowtable-ipv6-fix-v2-1-3287f8b55214@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 2 ++
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 1 +
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 26 ++++++++++++++++++++++-
|
||||
drivers/net/ethernet/airoha/airoha_regs.h | 10 +++++++++
|
||||
4 files changed, 38 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -84,6 +84,8 @@ static void airoha_set_macaddr(struct ai
|
||||
val = (addr[3] << 16) | (addr[4] << 8) | addr[5];
|
||||
airoha_fe_wr(eth, REG_FE_MAC_LMIN(reg), val);
|
||||
airoha_fe_wr(eth, REG_FE_MAC_LMAX(reg), val);
|
||||
+
|
||||
+ airoha_ppe_init_upd_mem(port);
|
||||
}
|
||||
|
||||
static void airoha_set_gdm_port_fwd_cfg(struct airoha_eth *eth, u32 addr,
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -614,6 +614,7 @@ void airoha_ppe_check_skb(struct airoha_
|
||||
int airoha_ppe_setup_tc_block_cb(struct net_device *dev, void *type_data);
|
||||
int airoha_ppe_init(struct airoha_eth *eth);
|
||||
void airoha_ppe_deinit(struct airoha_eth *eth);
|
||||
+void airoha_ppe_init_upd_mem(struct airoha_gdm_port *port);
|
||||
struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
|
||||
u32 hash);
|
||||
void airoha_ppe_foe_entry_get_stats(struct airoha_ppe *ppe, u32 hash,
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -223,6 +223,7 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
int dsa_port = airoha_get_dsa_port(&dev);
|
||||
struct airoha_foe_mac_info_common *l2;
|
||||
u32 qdata, ports_pad, val;
|
||||
+ u8 smac_id = 0xf;
|
||||
|
||||
memset(hwe, 0, sizeof(*hwe));
|
||||
|
||||
@@ -257,6 +258,8 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
*/
|
||||
if (airhoa_is_lan_gdm_port(port))
|
||||
val |= AIROHA_FOE_IB2_FAST_PATH;
|
||||
+
|
||||
+ smac_id = port->id;
|
||||
}
|
||||
|
||||
if (is_multicast_ether_addr(data->eth.h_dest))
|
||||
@@ -291,7 +294,7 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
hwe->ipv4.l2.src_mac_lo =
|
||||
get_unaligned_be16(data->eth.h_source + 4);
|
||||
} else {
|
||||
- l2->src_mac_hi = FIELD_PREP(AIROHA_FOE_MAC_SMAC_ID, 0xf);
|
||||
+ l2->src_mac_hi = FIELD_PREP(AIROHA_FOE_MAC_SMAC_ID, smac_id);
|
||||
}
|
||||
|
||||
if (data->vlan.num) {
|
||||
@@ -1238,6 +1241,27 @@ void airoha_ppe_check_skb(struct airoha_
|
||||
airoha_ppe_foe_insert_entry(ppe, skb, hash);
|
||||
}
|
||||
|
||||
+void airoha_ppe_init_upd_mem(struct airoha_gdm_port *port)
|
||||
+{
|
||||
+ struct airoha_eth *eth = port->qdma->eth;
|
||||
+ struct net_device *dev = port->dev;
|
||||
+ const u8 *addr = dev->dev_addr;
|
||||
+ u32 val;
|
||||
+
|
||||
+ val = (addr[2] << 24) | (addr[3] << 16) | (addr[4] << 8) | addr[5];
|
||||
+ airoha_fe_wr(eth, REG_UPDMEM_DATA(0), val);
|
||||
+ airoha_fe_wr(eth, REG_UPDMEM_CTRL(0),
|
||||
+ FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
|
||||
+ PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
|
||||
+
|
||||
+ val = (addr[0] << 8) | addr[1];
|
||||
+ airoha_fe_wr(eth, REG_UPDMEM_DATA(0), val);
|
||||
+ airoha_fe_wr(eth, REG_UPDMEM_CTRL(0),
|
||||
+ FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
|
||||
+ FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
|
||||
+ PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
|
||||
+}
|
||||
+
|
||||
int airoha_ppe_init(struct airoha_eth *eth)
|
||||
{
|
||||
struct airoha_ppe *ppe;
|
||||
--- a/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
@@ -313,6 +313,16 @@
|
||||
#define REG_PPE_RAM_BASE(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x320)
|
||||
#define REG_PPE_RAM_ENTRY(_m, _n) (REG_PPE_RAM_BASE(_m) + ((_n) << 2))
|
||||
|
||||
+#define REG_UPDMEM_CTRL(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x370)
|
||||
+#define PPE_UPDMEM_ACK_MASK BIT(31)
|
||||
+#define PPE_UPDMEM_ADDR_MASK GENMASK(11, 8)
|
||||
+#define PPE_UPDMEM_OFFSET_MASK GENMASK(7, 4)
|
||||
+#define PPE_UPDMEM_SEL_MASK GENMASK(3, 2)
|
||||
+#define PPE_UPDMEM_WR_MASK BIT(1)
|
||||
+#define PPE_UPDMEM_REQ_MASK BIT(0)
|
||||
+
|
||||
+#define REG_UPDMEM_DATA(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x374)
|
||||
+
|
||||
#define REG_FE_GDM_TX_OK_PKT_CNT_H(_n) (GDM_BASE(_n) + 0x280)
|
||||
#define REG_FE_GDM_TX_OK_BYTE_CNT_H(_n) (GDM_BASE(_n) + 0x284)
|
||||
#define REG_FE_GDM_TX_ETH_PKT_CNT_H(_n) (GDM_BASE(_n) + 0x288)
|
||||
@ -1,64 +0,0 @@
|
||||
From 504a577c9b000f9e0e99e1b28616fb4eb369e1ef Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 2 Jun 2025 12:55:38 +0200
|
||||
Subject: [PATCH 2/3] net: airoha: Fix IPv6 hw acceleration in bridge mode
|
||||
|
||||
ib2 and airoha_foe_mac_info_common have not the same offsets in
|
||||
airoha_foe_bridge and airoha_foe_ipv6 structures. Current codebase does
|
||||
not accelerate IPv6 traffic in bridge mode since ib2 and l2 info are not
|
||||
set properly copying airoha_foe_bridge struct into airoha_foe_ipv6 one
|
||||
in airoha_ppe_foe_commit_subflow_entry routine.
|
||||
Fix IPv6 hw acceleration in bridge mode resolving ib2 and
|
||||
airoha_foe_mac_info_common overwrite in
|
||||
airoha_ppe_foe_commit_subflow_entry() and configuring them with proper
|
||||
values.
|
||||
|
||||
Fixes: cd53f622611f ("net: airoha: Add L2 hw acceleration support")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250602-airoha-flowtable-ipv6-fix-v2-2-3287f8b55214@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 23 ++++++++++++-----------
|
||||
1 file changed, 12 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -639,7 +639,6 @@ airoha_ppe_foe_commit_subflow_entry(stru
|
||||
u32 mask = AIROHA_FOE_IB1_BIND_PACKET_TYPE | AIROHA_FOE_IB1_BIND_UDP;
|
||||
struct airoha_foe_entry *hwe_p, hwe;
|
||||
struct airoha_flow_table_entry *f;
|
||||
- struct airoha_foe_mac_info *l2;
|
||||
int type;
|
||||
|
||||
hwe_p = airoha_ppe_foe_get_entry(ppe, hash);
|
||||
@@ -656,18 +655,20 @@ airoha_ppe_foe_commit_subflow_entry(stru
|
||||
|
||||
memcpy(&hwe, hwe_p, sizeof(*hwe_p));
|
||||
hwe.ib1 = (hwe.ib1 & mask) | (e->data.ib1 & ~mask);
|
||||
- l2 = &hwe.bridge.l2;
|
||||
- memcpy(l2, &e->data.bridge.l2, sizeof(*l2));
|
||||
|
||||
type = FIELD_GET(AIROHA_FOE_IB1_BIND_PACKET_TYPE, hwe.ib1);
|
||||
- if (type == PPE_PKT_TYPE_IPV4_HNAPT)
|
||||
- memcpy(&hwe.ipv4.new_tuple, &hwe.ipv4.orig_tuple,
|
||||
- sizeof(hwe.ipv4.new_tuple));
|
||||
- else if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T &&
|
||||
- l2->common.etype == ETH_P_IP)
|
||||
- l2->common.etype = ETH_P_IPV6;
|
||||
+ if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T) {
|
||||
+ memcpy(&hwe.ipv6.l2, &e->data.bridge.l2, sizeof(hwe.ipv6.l2));
|
||||
+ hwe.ipv6.ib2 = e->data.bridge.ib2;
|
||||
+ } else {
|
||||
+ memcpy(&hwe.bridge.l2, &e->data.bridge.l2,
|
||||
+ sizeof(hwe.bridge.l2));
|
||||
+ hwe.bridge.ib2 = e->data.bridge.ib2;
|
||||
+ if (type == PPE_PKT_TYPE_IPV4_HNAPT)
|
||||
+ memcpy(&hwe.ipv4.new_tuple, &hwe.ipv4.orig_tuple,
|
||||
+ sizeof(hwe.ipv4.new_tuple));
|
||||
+ }
|
||||
|
||||
- hwe.bridge.ib2 = e->data.bridge.ib2;
|
||||
hwe.bridge.data = e->data.bridge.data;
|
||||
airoha_ppe_foe_commit_entry(ppe, &hwe, hash);
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
From c86fac5365d3a068422beeb508f2741f1a2d734d Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 2 Jun 2025 12:55:39 +0200
|
||||
Subject: [PATCH 3/3] net: airoha: Fix smac_id configuration in bridge mode
|
||||
|
||||
Set PPE entry smac_id field to 0xf in airoha_ppe_foe_commit_subflow_entry
|
||||
routine for IPv6 traffic in order to instruct the hw to keep original
|
||||
source mac address for IPv6 hw accelerated traffic in bridge mode.
|
||||
|
||||
Fixes: cd53f622611f ("net: airoha: Add L2 hw acceleration support")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250602-airoha-flowtable-ipv6-fix-v2-3-3287f8b55214@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -660,6 +660,11 @@ airoha_ppe_foe_commit_subflow_entry(stru
|
||||
if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T) {
|
||||
memcpy(&hwe.ipv6.l2, &e->data.bridge.l2, sizeof(hwe.ipv6.l2));
|
||||
hwe.ipv6.ib2 = e->data.bridge.ib2;
|
||||
+ /* setting smac_id to 0xf instruct the hw to keep original
|
||||
+ * source mac address
|
||||
+ */
|
||||
+ hwe.ipv6.l2.src_mac_hi = FIELD_PREP(AIROHA_FOE_MAC_SMAC_ID,
|
||||
+ 0xf);
|
||||
} else {
|
||||
memcpy(&hwe.bridge.l2, &e->data.bridge.l2,
|
||||
sizeof(hwe.bridge.l2));
|
||||
@ -1,87 +0,0 @@
|
||||
From 0097c4195b1d0ca57d15979626c769c74747b5a0 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 9 Jun 2025 22:28:40 +0200
|
||||
Subject: [PATCH] net: airoha: Add PPPoE offload support
|
||||
|
||||
Introduce flowtable hw acceleration for PPPoE traffic.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250609-b4-airoha-flowtable-pppoe-v1-1-1520fa7711b4@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 31 ++++++++++++++++++------
|
||||
1 file changed, 23 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -232,6 +232,7 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
FIELD_PREP(AIROHA_FOE_IB1_BIND_UDP, l4proto == IPPROTO_UDP) |
|
||||
FIELD_PREP(AIROHA_FOE_IB1_BIND_VLAN_LAYER, data->vlan.num) |
|
||||
FIELD_PREP(AIROHA_FOE_IB1_BIND_VPM, data->vlan.num) |
|
||||
+ FIELD_PREP(AIROHA_FOE_IB1_BIND_PPPOE, data->pppoe.num) |
|
||||
AIROHA_FOE_IB1_BIND_TTL;
|
||||
hwe->ib1 = val;
|
||||
|
||||
@@ -281,33 +282,42 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
hwe->ipv6.data = qdata;
|
||||
hwe->ipv6.ib2 = val;
|
||||
l2 = &hwe->ipv6.l2;
|
||||
+ l2->etype = ETH_P_IPV6;
|
||||
} else {
|
||||
hwe->ipv4.data = qdata;
|
||||
hwe->ipv4.ib2 = val;
|
||||
l2 = &hwe->ipv4.l2.common;
|
||||
+ l2->etype = ETH_P_IP;
|
||||
}
|
||||
|
||||
l2->dest_mac_hi = get_unaligned_be32(data->eth.h_dest);
|
||||
l2->dest_mac_lo = get_unaligned_be16(data->eth.h_dest + 4);
|
||||
if (type <= PPE_PKT_TYPE_IPV4_DSLITE) {
|
||||
+ struct airoha_foe_mac_info *mac_info;
|
||||
+
|
||||
l2->src_mac_hi = get_unaligned_be32(data->eth.h_source);
|
||||
hwe->ipv4.l2.src_mac_lo =
|
||||
get_unaligned_be16(data->eth.h_source + 4);
|
||||
+
|
||||
+ mac_info = (struct airoha_foe_mac_info *)l2;
|
||||
+ mac_info->pppoe_id = data->pppoe.sid;
|
||||
} else {
|
||||
- l2->src_mac_hi = FIELD_PREP(AIROHA_FOE_MAC_SMAC_ID, smac_id);
|
||||
+ l2->src_mac_hi = FIELD_PREP(AIROHA_FOE_MAC_SMAC_ID, smac_id) |
|
||||
+ FIELD_PREP(AIROHA_FOE_MAC_PPPOE_ID,
|
||||
+ data->pppoe.sid);
|
||||
}
|
||||
|
||||
if (data->vlan.num) {
|
||||
- l2->etype = dsa_port >= 0 ? BIT(dsa_port) : 0;
|
||||
l2->vlan1 = data->vlan.hdr[0].id;
|
||||
if (data->vlan.num == 2)
|
||||
l2->vlan2 = data->vlan.hdr[1].id;
|
||||
- } else if (dsa_port >= 0) {
|
||||
- l2->etype = BIT(15) | BIT(dsa_port);
|
||||
- } else if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T) {
|
||||
- l2->etype = ETH_P_IPV6;
|
||||
- } else {
|
||||
- l2->etype = ETH_P_IP;
|
||||
+ }
|
||||
+
|
||||
+ if (dsa_port >= 0) {
|
||||
+ l2->etype = BIT(dsa_port);
|
||||
+ l2->etype |= !data->vlan.num ? BIT(15) : 0;
|
||||
+ } else if (data->pppoe.num) {
|
||||
+ l2->etype = ETH_P_PPP_SES;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -957,6 +967,11 @@ static int airoha_ppe_flow_offload_repla
|
||||
case FLOW_ACTION_VLAN_POP:
|
||||
break;
|
||||
case FLOW_ACTION_PPPOE_PUSH:
|
||||
+ if (data.pppoe.num == 1 || data.vlan.num == 2)
|
||||
+ return -EOPNOTSUPP;
|
||||
+
|
||||
+ data.pppoe.sid = act->pppoe.sid;
|
||||
+ data.pppoe.num++;
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
@ -1,28 +0,0 @@
|
||||
From f478d68b653323b691280b40fbd3b8ca1ac75aa2 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 9 Jun 2025 22:40:35 +0200
|
||||
Subject: [PATCH] net: airoha: Enable RX queues 16-31
|
||||
|
||||
Fix RX_DONE_INT_MASK definition in order to enable RX queues 16-31.
|
||||
|
||||
Fixes: f252493e18353 ("net: airoha: Enable multiple IRQ lines support in airoha_eth driver.")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250609-aioha-fix-rx-queue-mask-v1-1-f33706a06fa2@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_regs.h | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
@@ -614,8 +614,9 @@
|
||||
RX19_DONE_INT_MASK | RX18_DONE_INT_MASK | \
|
||||
RX17_DONE_INT_MASK | RX16_DONE_INT_MASK)
|
||||
|
||||
-#define RX_DONE_INT_MASK (RX_DONE_HIGH_INT_MASK | RX_DONE_LOW_INT_MASK)
|
||||
#define RX_DONE_HIGH_OFFSET fls(RX_DONE_HIGH_INT_MASK)
|
||||
+#define RX_DONE_INT_MASK \
|
||||
+ ((RX_DONE_HIGH_INT_MASK << RX_DONE_HIGH_OFFSET) | RX_DONE_LOW_INT_MASK)
|
||||
|
||||
#define INT_RX2_MASK(_n) \
|
||||
((RX_NO_CPU_DSCP_HIGH_INT_MASK & (_n)) | \
|
||||
@ -1,32 +0,0 @@
|
||||
From 78bd03ee1f20a267d2c218884b66041b3508ac9c Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 18 Jun 2025 09:37:40 +0200
|
||||
Subject: [PATCH] net: airoha: Always check return value from
|
||||
airoha_ppe_foe_get_entry()
|
||||
|
||||
airoha_ppe_foe_get_entry routine can return NULL, so check the returned
|
||||
pointer is not NULL in airoha_ppe_foe_flow_l2_entry_update()
|
||||
|
||||
Fixes: b81e0f2b58be3 ("net: airoha: Add FLOW_CLS_STATS callback support")
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250618-check-ret-from-airoha_ppe_foe_get_entry-v2-1-068dcea3cc66@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -819,8 +819,10 @@ airoha_ppe_foe_flow_l2_entry_update(stru
|
||||
int idle;
|
||||
|
||||
hwe = airoha_ppe_foe_get_entry(ppe, iter->hash);
|
||||
- ib1 = READ_ONCE(hwe->ib1);
|
||||
+ if (!hwe)
|
||||
+ continue;
|
||||
|
||||
+ ib1 = READ_ONCE(hwe->ib1);
|
||||
state = FIELD_GET(AIROHA_FOE_IB1_BIND_STATE, ib1);
|
||||
if (state != AIROHA_FOE_STATE_BIND) {
|
||||
iter->hash = 0xffff;
|
||||
@ -1,77 +0,0 @@
|
||||
From edf8afeecfbb0b8c1a2edb8c8892d2f759d35321 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 19 Jun 2025 09:07:24 +0200
|
||||
Subject: [PATCH 1/2] net: airoha: Compute number of descriptors according to
|
||||
reserved memory size
|
||||
|
||||
In order to not exceed the reserved memory size for hwfd buffers,
|
||||
compute the number of hwfd buffers/descriptors according to the
|
||||
reserved memory size and the size of each hwfd buffer (2KB).
|
||||
|
||||
Fixes: 3a1ce9e3d01b ("net: airoha: Add the capability to allocate hwfd buffers via reserved-memory")
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250619-airoha-hw-num-desc-v4-1-49600a9b319a@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 21 ++++++++++++---------
|
||||
1 file changed, 12 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -1086,19 +1086,13 @@ static void airoha_qdma_cleanup_tx_queue
|
||||
|
||||
static int airoha_qdma_init_hfwd_queues(struct airoha_qdma *qdma)
|
||||
{
|
||||
+ int size, index, num_desc = HW_DSCP_NUM;
|
||||
struct airoha_eth *eth = qdma->eth;
|
||||
int id = qdma - ð->qdma[0];
|
||||
dma_addr_t dma_addr;
|
||||
const char *name;
|
||||
- int size, index;
|
||||
u32 status;
|
||||
|
||||
- size = HW_DSCP_NUM * sizeof(struct airoha_qdma_fwd_desc);
|
||||
- if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL))
|
||||
- return -ENOMEM;
|
||||
-
|
||||
- airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr);
|
||||
-
|
||||
name = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d-buf", id);
|
||||
if (!name)
|
||||
return -ENOMEM;
|
||||
@@ -1120,8 +1114,12 @@ static int airoha_qdma_init_hfwd_queues(
|
||||
rmem = of_reserved_mem_lookup(np);
|
||||
of_node_put(np);
|
||||
dma_addr = rmem->base;
|
||||
+ /* Compute the number of hw descriptors according to the
|
||||
+ * reserved memory size and the payload buffer size
|
||||
+ */
|
||||
+ num_desc = rmem->size / AIROHA_MAX_PACKET_SIZE;
|
||||
} else {
|
||||
- size = AIROHA_MAX_PACKET_SIZE * HW_DSCP_NUM;
|
||||
+ size = AIROHA_MAX_PACKET_SIZE * num_desc;
|
||||
if (!dmam_alloc_coherent(eth->dev, size, &dma_addr,
|
||||
GFP_KERNEL))
|
||||
return -ENOMEM;
|
||||
@@ -1129,6 +1127,11 @@ static int airoha_qdma_init_hfwd_queues(
|
||||
|
||||
airoha_qdma_wr(qdma, REG_FWD_BUF_BASE, dma_addr);
|
||||
|
||||
+ size = num_desc * sizeof(struct airoha_qdma_fwd_desc);
|
||||
+ if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL))
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr);
|
||||
airoha_qdma_rmw(qdma, REG_HW_FWD_DSCP_CFG,
|
||||
HW_FWD_DSCP_PAYLOAD_SIZE_MASK,
|
||||
FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, 0));
|
||||
@@ -1137,7 +1140,7 @@ static int airoha_qdma_init_hfwd_queues(
|
||||
airoha_qdma_rmw(qdma, REG_LMGR_INIT_CFG,
|
||||
LMGR_INIT_START | LMGR_SRAM_MODE_MASK |
|
||||
HW_FWD_DESC_NUM_MASK,
|
||||
- FIELD_PREP(HW_FWD_DESC_NUM_MASK, HW_DSCP_NUM) |
|
||||
+ FIELD_PREP(HW_FWD_DESC_NUM_MASK, num_desc) |
|
||||
LMGR_INIT_START | LMGR_SRAM_MODE_MASK);
|
||||
|
||||
return read_poll_timeout(airoha_qdma_rr, status,
|
||||
@ -1,64 +0,0 @@
|
||||
From 7b46bdaec00a675f6fac9d0b01a2105b5746ebe9 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 19 Jun 2025 09:07:25 +0200
|
||||
Subject: [PATCH 2/2] net: airoha: Differentiate hwfd buffer size for QDMA0 and
|
||||
QDMA1
|
||||
|
||||
EN7581 SoC allows configuring the size and the number of buffers in
|
||||
hwfd payload queue for both QDMA0 and QDMA1.
|
||||
In order to reduce the required DRAM used for hwfd buffers queues and
|
||||
decrease the memory footprint, differentiate hwfd buffer size for QDMA0
|
||||
and QDMA1 and reduce hwfd buffer size to 1KB for QDMA1 (WAN) while
|
||||
maintaining 2KB for QDMA0 (LAN).
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250619-airoha-hw-num-desc-v4-2-49600a9b319a@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -1089,14 +1089,15 @@ static int airoha_qdma_init_hfwd_queues(
|
||||
int size, index, num_desc = HW_DSCP_NUM;
|
||||
struct airoha_eth *eth = qdma->eth;
|
||||
int id = qdma - ð->qdma[0];
|
||||
+ u32 status, buf_size;
|
||||
dma_addr_t dma_addr;
|
||||
const char *name;
|
||||
- u32 status;
|
||||
|
||||
name = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d-buf", id);
|
||||
if (!name)
|
||||
return -ENOMEM;
|
||||
|
||||
+ buf_size = id ? AIROHA_MAX_PACKET_SIZE / 2 : AIROHA_MAX_PACKET_SIZE;
|
||||
index = of_property_match_string(eth->dev->of_node,
|
||||
"memory-region-names", name);
|
||||
if (index >= 0) {
|
||||
@@ -1117,9 +1118,9 @@ static int airoha_qdma_init_hfwd_queues(
|
||||
/* Compute the number of hw descriptors according to the
|
||||
* reserved memory size and the payload buffer size
|
||||
*/
|
||||
- num_desc = rmem->size / AIROHA_MAX_PACKET_SIZE;
|
||||
+ num_desc = div_u64(rmem->size, buf_size);
|
||||
} else {
|
||||
- size = AIROHA_MAX_PACKET_SIZE * num_desc;
|
||||
+ size = buf_size * num_desc;
|
||||
if (!dmam_alloc_coherent(eth->dev, size, &dma_addr,
|
||||
GFP_KERNEL))
|
||||
return -ENOMEM;
|
||||
@@ -1132,9 +1133,10 @@ static int airoha_qdma_init_hfwd_queues(
|
||||
return -ENOMEM;
|
||||
|
||||
airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr);
|
||||
+ /* QDMA0: 2KB. QDMA1: 1KB */
|
||||
airoha_qdma_rmw(qdma, REG_HW_FWD_DSCP_CFG,
|
||||
HW_FWD_DSCP_PAYLOAD_SIZE_MASK,
|
||||
- FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, 0));
|
||||
+ FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, !!id));
|
||||
airoha_qdma_rmw(qdma, REG_FWD_DSCP_LOW_THR, FWD_DSCP_LOW_THR_MASK,
|
||||
FIELD_PREP(FWD_DSCP_LOW_THR_MASK, 128));
|
||||
airoha_qdma_rmw(qdma, REG_LMGR_INIT_CFG,
|
||||
@ -1,92 +0,0 @@
|
||||
From 38358fa3cc8e16c6862a3e5c5c233f9f652e3a6d Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 31 Jul 2025 12:29:08 +0200
|
||||
Subject: [PATCH] net: airoha: Fix PPE table access in
|
||||
airoha_ppe_debugfs_foe_show()
|
||||
|
||||
In order to avoid any possible race we need to hold the ppe_lock
|
||||
spinlock accessing the hw PPE table. airoha_ppe_foe_get_entry routine is
|
||||
always executed holding ppe_lock except in airoha_ppe_debugfs_foe_show
|
||||
routine. Fix the problem introducing airoha_ppe_foe_get_entry_locked
|
||||
routine.
|
||||
|
||||
Fixes: 3fe15c640f380 ("net: airoha: Introduce PPE debugfs support")
|
||||
Reviewed-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250731-airoha_ppe_foe_get_entry_locked-v2-1-50efbd8c0fd6@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 26 ++++++++++++++++++------
|
||||
1 file changed, 20 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -508,9 +508,11 @@ static void airoha_ppe_foe_flow_stats_up
|
||||
FIELD_PREP(AIROHA_FOE_IB2_NBQ, nbq);
|
||||
}
|
||||
|
||||
-struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
|
||||
- u32 hash)
|
||||
+static struct airoha_foe_entry *
|
||||
+airoha_ppe_foe_get_entry_locked(struct airoha_ppe *ppe, u32 hash)
|
||||
{
|
||||
+ lockdep_assert_held(&ppe_lock);
|
||||
+
|
||||
if (hash < PPE_SRAM_NUM_ENTRIES) {
|
||||
u32 *hwe = ppe->foe + hash * sizeof(struct airoha_foe_entry);
|
||||
struct airoha_eth *eth = ppe->eth;
|
||||
@@ -537,6 +539,18 @@ struct airoha_foe_entry *airoha_ppe_foe_
|
||||
return ppe->foe + hash * sizeof(struct airoha_foe_entry);
|
||||
}
|
||||
|
||||
+struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
|
||||
+ u32 hash)
|
||||
+{
|
||||
+ struct airoha_foe_entry *hwe;
|
||||
+
|
||||
+ spin_lock_bh(&ppe_lock);
|
||||
+ hwe = airoha_ppe_foe_get_entry_locked(ppe, hash);
|
||||
+ spin_unlock_bh(&ppe_lock);
|
||||
+
|
||||
+ return hwe;
|
||||
+}
|
||||
+
|
||||
static bool airoha_ppe_foe_compare_entry(struct airoha_flow_table_entry *e,
|
||||
struct airoha_foe_entry *hwe)
|
||||
{
|
||||
@@ -651,7 +665,7 @@ airoha_ppe_foe_commit_subflow_entry(stru
|
||||
struct airoha_flow_table_entry *f;
|
||||
int type;
|
||||
|
||||
- hwe_p = airoha_ppe_foe_get_entry(ppe, hash);
|
||||
+ hwe_p = airoha_ppe_foe_get_entry_locked(ppe, hash);
|
||||
if (!hwe_p)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -703,7 +717,7 @@ static void airoha_ppe_foe_insert_entry(
|
||||
|
||||
spin_lock_bh(&ppe_lock);
|
||||
|
||||
- hwe = airoha_ppe_foe_get_entry(ppe, hash);
|
||||
+ hwe = airoha_ppe_foe_get_entry_locked(ppe, hash);
|
||||
if (!hwe)
|
||||
goto unlock;
|
||||
|
||||
@@ -818,7 +832,7 @@ airoha_ppe_foe_flow_l2_entry_update(stru
|
||||
u32 ib1, state;
|
||||
int idle;
|
||||
|
||||
- hwe = airoha_ppe_foe_get_entry(ppe, iter->hash);
|
||||
+ hwe = airoha_ppe_foe_get_entry_locked(ppe, iter->hash);
|
||||
if (!hwe)
|
||||
continue;
|
||||
|
||||
@@ -855,7 +869,7 @@ static void airoha_ppe_foe_flow_entry_up
|
||||
if (e->hash == 0xffff)
|
||||
goto unlock;
|
||||
|
||||
- hwe_p = airoha_ppe_foe_get_entry(ppe, e->hash);
|
||||
+ hwe_p = airoha_ppe_foe_get_entry_locked(ppe, e->hash);
|
||||
if (!hwe_p)
|
||||
goto unlock;
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
From 9f6b606b6b37e61427412708411e8e04b1a858e8 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 18 Aug 2025 11:58:25 +0200
|
||||
Subject: [PATCH] net: airoha: ppe: Do not invalid PPE entries in case of SW
|
||||
hash collision
|
||||
|
||||
SW hash computed by airoha_ppe_foe_get_entry_hash routine (used for
|
||||
foe_flow hlist) can theoretically produce collisions between two
|
||||
different HW PPE entries.
|
||||
In airoha_ppe_foe_insert_entry() if the collision occurs we will mark
|
||||
the second PPE entry in the list as stale (setting the hw hash to 0xffff).
|
||||
Stale entries are no more updated in airoha_ppe_foe_flow_entry_update
|
||||
routine and so they are removed by Netfilter.
|
||||
Fix the problem not marking the second entry as stale in
|
||||
airoha_ppe_foe_insert_entry routine if we have already inserted the
|
||||
brand new entry in the PPE table and let Netfilter remove real stale
|
||||
entries according to their timestamp.
|
||||
Please note this is just a theoretical issue spotted reviewing the code
|
||||
and not faced running the system.
|
||||
|
||||
Fixes: cd53f622611f9 ("net: airoha: Add L2 hw acceleration support")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250818-airoha-en7581-hash-collision-fix-v1-1-d190c4b53d1c@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -736,10 +736,8 @@ static void airoha_ppe_foe_insert_entry(
|
||||
continue;
|
||||
}
|
||||
|
||||
- if (commit_done || !airoha_ppe_foe_compare_entry(e, hwe)) {
|
||||
- e->hash = 0xffff;
|
||||
+ if (!airoha_ppe_foe_compare_entry(e, hwe))
|
||||
continue;
|
||||
- }
|
||||
|
||||
airoha_ppe_foe_commit_entry(ppe, &e->data, hash);
|
||||
commit_done = true;
|
||||
@ -1,179 +0,0 @@
|
||||
From 564923b02c1d2fe02ee789f9849ff79979b63b9f Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 11 Aug 2025 17:31:37 +0200
|
||||
Subject: [PATCH 1/6] net: airoha: npu: Add NPU wlan memory initialization
|
||||
commands
|
||||
|
||||
Introduce wlan_init_reserved_memory callback used by MT76 driver during
|
||||
NPU wlan offloading setup.
|
||||
This is a preliminary patch to enable wlan flowtable offload for EN7581
|
||||
SoC with MT76 driver.
|
||||
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250811-airoha-en7581-wlan-offlaod-v7-2-58823603bb4e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 82 ++++++++++++++++++++++++
|
||||
drivers/net/ethernet/airoha/airoha_npu.h | 38 +++++++++++
|
||||
2 files changed, 120 insertions(+)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -124,6 +124,13 @@ struct ppe_mbox_data {
|
||||
};
|
||||
};
|
||||
|
||||
+struct wlan_mbox_data {
|
||||
+ u32 ifindex:4;
|
||||
+ u32 func_type:4;
|
||||
+ u32 func_id;
|
||||
+ DECLARE_FLEX_ARRAY(u8, d);
|
||||
+};
|
||||
+
|
||||
static int airoha_npu_send_msg(struct airoha_npu *npu, int func_id,
|
||||
void *p, int size)
|
||||
{
|
||||
@@ -390,6 +397,80 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
+static int airoha_npu_wlan_msg_send(struct airoha_npu *npu, int ifindex,
|
||||
+ enum airoha_npu_wlan_set_cmd func_id,
|
||||
+ void *data, int data_len, gfp_t gfp)
|
||||
+{
|
||||
+ struct wlan_mbox_data *wlan_data;
|
||||
+ int err, len;
|
||||
+
|
||||
+ len = sizeof(*wlan_data) + data_len;
|
||||
+ wlan_data = kzalloc(len, gfp);
|
||||
+ if (!wlan_data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ wlan_data->ifindex = ifindex;
|
||||
+ wlan_data->func_type = NPU_OP_SET;
|
||||
+ wlan_data->func_id = func_id;
|
||||
+ memcpy(wlan_data->d, data, data_len);
|
||||
+
|
||||
+ err = airoha_npu_send_msg(npu, NPU_FUNC_WIFI, wlan_data, len);
|
||||
+ kfree(wlan_data);
|
||||
+
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+airoha_npu_wlan_set_reserved_memory(struct airoha_npu *npu,
|
||||
+ int ifindex, const char *name,
|
||||
+ enum airoha_npu_wlan_set_cmd func_id)
|
||||
+{
|
||||
+ struct device *dev = npu->dev;
|
||||
+ struct resource res;
|
||||
+ int err;
|
||||
+ u32 val;
|
||||
+
|
||||
+ err = of_reserved_mem_region_to_resource_byname(dev->of_node, name,
|
||||
+ &res);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ val = res.start;
|
||||
+ return airoha_npu_wlan_msg_send(npu, ifindex, func_id, &val,
|
||||
+ sizeof(val), GFP_KERNEL);
|
||||
+}
|
||||
+
|
||||
+static int airoha_npu_wlan_init_memory(struct airoha_npu *npu)
|
||||
+{
|
||||
+ enum airoha_npu_wlan_set_cmd cmd = WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU;
|
||||
+ u32 val = 0;
|
||||
+ int err;
|
||||
+
|
||||
+ err = airoha_npu_wlan_msg_send(npu, 1, cmd, &val, sizeof(val),
|
||||
+ GFP_KERNEL);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ cmd = WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR;
|
||||
+ err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-bufid", cmd);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ cmd = WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR;
|
||||
+ err = airoha_npu_wlan_set_reserved_memory(npu, 0, "pkt", cmd);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ cmd = WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR;
|
||||
+ err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-pkt", cmd);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ cmd = WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU;
|
||||
+ return airoha_npu_wlan_msg_send(npu, 0, cmd, &val, sizeof(val),
|
||||
+ GFP_KERNEL);
|
||||
+}
|
||||
+
|
||||
struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
|
||||
{
|
||||
struct platform_device *pdev;
|
||||
@@ -493,6 +574,7 @@ static int airoha_npu_probe(struct platf
|
||||
npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
|
||||
npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
|
||||
npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
|
||||
+ npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
|
||||
|
||||
npu->regmap = devm_regmap_init_mmio(dev, base, ®map_config);
|
||||
if (IS_ERR(npu->regmap))
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
@@ -6,6 +6,43 @@
|
||||
|
||||
#define NPU_NUM_CORES 8
|
||||
|
||||
+enum airoha_npu_wlan_set_cmd {
|
||||
+ WLAN_FUNC_SET_WAIT_PCIE_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_DESC,
|
||||
+ WLAN_FUNC_SET_WAIT_NPU_INIT_DONE,
|
||||
+ WLAN_FUNC_SET_WAIT_TRAN_TO_CPU,
|
||||
+ WLAN_FUNC_SET_WAIT_BA_WIN_SIZE,
|
||||
+ WLAN_FUNC_SET_WAIT_DRIVER_MODEL,
|
||||
+ WLAN_FUNC_SET_WAIT_DEL_STA,
|
||||
+ WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_IS_TEST_NOBA,
|
||||
+ WLAN_FUNC_SET_WAIT_FLUSHONE_TIMEOUT,
|
||||
+ WLAN_FUNC_SET_WAIT_FLUSHALL_TIMEOUT,
|
||||
+ WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU,
|
||||
+ WLAN_FUNC_SET_WAIT_PCIE_STATE,
|
||||
+ WLAN_FUNC_SET_WAIT_PCIE_PORT_TYPE,
|
||||
+ WLAN_FUNC_SET_WAIT_ERROR_RETRY_TIMES,
|
||||
+ WLAN_FUNC_SET_WAIT_BAR_INFO,
|
||||
+ WLAN_FUNC_SET_WAIT_FAST_FLAG,
|
||||
+ WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_RING_PCIE_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_DESC_HW_BASE,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_BUF_SPACE_HW_BASE,
|
||||
+ WLAN_FUNC_SET_WAIT_RX_RING_FOR_TXDONE_HW_BASE,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_TXRX_REG_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_DEBUG_FLAG,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_HW_CFG_INFO,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_STOP_ACTION,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_PCIE_SWAP,
|
||||
+ WLAN_FUNC_SET_WAIT_RATELIMIT_CTRL,
|
||||
+ WLAN_FUNC_SET_WAIT_HWNAT_INIT,
|
||||
+ WLAN_FUNC_SET_WAIT_ARHT_CHIP_INFO,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_TOKEN_ID_SIZE,
|
||||
+};
|
||||
+
|
||||
struct airoha_npu {
|
||||
struct device *dev;
|
||||
struct regmap *regmap;
|
||||
@@ -29,6 +66,7 @@ struct airoha_npu {
|
||||
dma_addr_t foe_addr,
|
||||
u32 entry_size, u32 hash,
|
||||
bool ppe2);
|
||||
+ int (*wlan_init_reserved_memory)(struct airoha_npu *npu);
|
||||
} ops;
|
||||
};
|
||||
|
||||
@ -1,139 +0,0 @@
|
||||
From f97fc66185b2004ad5f393f78b3e645009ddd1d0 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 11 Aug 2025 17:31:38 +0200
|
||||
Subject: [PATCH 2/6] net: airoha: npu: Add wlan_{send,get}_msg NPU callbacks
|
||||
|
||||
Introduce wlan_send_msg() and wlan_get_msg() NPU wlan callbacks used
|
||||
by the wlan driver (MT76) to initialize NPU module registers in order to
|
||||
offload wireless-wired traffic.
|
||||
This is a preliminary patch to enable wlan flowtable offload for EN7581
|
||||
SoC with MT76 driver.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250811-airoha-en7581-wlan-offlaod-v7-3-58823603bb4e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 52 ++++++++++++++++++++++++
|
||||
drivers/net/ethernet/airoha/airoha_npu.h | 22 ++++++++++
|
||||
2 files changed, 74 insertions(+)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -42,6 +42,22 @@
|
||||
#define REG_CR_MBQ8_CTRL(_n) (NPU_MBOX_BASE_ADDR + 0x0b0 + ((_n) << 2))
|
||||
#define REG_CR_NPU_MIB(_n) (NPU_MBOX_BASE_ADDR + 0x140 + ((_n) << 2))
|
||||
|
||||
+#define NPU_WLAN_BASE_ADDR 0x30d000
|
||||
+
|
||||
+#define REG_IRQ_STATUS (NPU_WLAN_BASE_ADDR + 0x030)
|
||||
+#define REG_IRQ_RXDONE(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 2) + 0x034)
|
||||
+#define NPU_IRQ_RX_MASK(_n) ((_n) == 1 ? BIT(17) : BIT(16))
|
||||
+
|
||||
+#define REG_TX_BASE(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x080)
|
||||
+#define REG_TX_DSCP_NUM(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x084)
|
||||
+#define REG_TX_CPU_IDX(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x088)
|
||||
+#define REG_TX_DMA_IDX(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x08c)
|
||||
+
|
||||
+#define REG_RX_BASE(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x180)
|
||||
+#define REG_RX_DSCP_NUM(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x184)
|
||||
+#define REG_RX_CPU_IDX(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x188)
|
||||
+#define REG_RX_DMA_IDX(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x18c)
|
||||
+
|
||||
#define NPU_TIMER_BASE_ADDR 0x310100
|
||||
#define REG_WDT_TIMER_CTRL(_n) (NPU_TIMER_BASE_ADDR + ((_n) * 0x100))
|
||||
#define WDT_EN_MASK BIT(25)
|
||||
@@ -420,6 +436,30 @@ static int airoha_npu_wlan_msg_send(stru
|
||||
return err;
|
||||
}
|
||||
|
||||
+static int airoha_npu_wlan_msg_get(struct airoha_npu *npu, int ifindex,
|
||||
+ enum airoha_npu_wlan_get_cmd func_id,
|
||||
+ void *data, int data_len, gfp_t gfp)
|
||||
+{
|
||||
+ struct wlan_mbox_data *wlan_data;
|
||||
+ int err, len;
|
||||
+
|
||||
+ len = sizeof(*wlan_data) + data_len;
|
||||
+ wlan_data = kzalloc(len, gfp);
|
||||
+ if (!wlan_data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ wlan_data->ifindex = ifindex;
|
||||
+ wlan_data->func_type = NPU_OP_GET;
|
||||
+ wlan_data->func_id = func_id;
|
||||
+
|
||||
+ err = airoha_npu_send_msg(npu, NPU_FUNC_WIFI, wlan_data, len);
|
||||
+ if (!err)
|
||||
+ memcpy(data, wlan_data->d, data_len);
|
||||
+ kfree(wlan_data);
|
||||
+
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
airoha_npu_wlan_set_reserved_memory(struct airoha_npu *npu,
|
||||
int ifindex, const char *name,
|
||||
@@ -471,6 +511,15 @@ static int airoha_npu_wlan_init_memory(s
|
||||
GFP_KERNEL);
|
||||
}
|
||||
|
||||
+static u32 airoha_npu_wlan_queue_addr_get(struct airoha_npu *npu, int qid,
|
||||
+ bool xmit)
|
||||
+{
|
||||
+ if (xmit)
|
||||
+ return REG_TX_BASE(qid + 2);
|
||||
+
|
||||
+ return REG_RX_BASE(qid);
|
||||
+}
|
||||
+
|
||||
struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
|
||||
{
|
||||
struct platform_device *pdev;
|
||||
@@ -575,6 +624,9 @@ static int airoha_npu_probe(struct platf
|
||||
npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
|
||||
npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
|
||||
npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
|
||||
+ npu->ops.wlan_send_msg = airoha_npu_wlan_msg_send;
|
||||
+ npu->ops.wlan_get_msg = airoha_npu_wlan_msg_get;
|
||||
+ npu->ops.wlan_get_queue_addr = airoha_npu_wlan_queue_addr_get;
|
||||
|
||||
npu->regmap = devm_regmap_init_mmio(dev, base, ®map_config);
|
||||
if (IS_ERR(npu->regmap))
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
@@ -43,6 +43,20 @@ enum airoha_npu_wlan_set_cmd {
|
||||
WLAN_FUNC_SET_WAIT_TOKEN_ID_SIZE,
|
||||
};
|
||||
|
||||
+enum airoha_npu_wlan_get_cmd {
|
||||
+ WLAN_FUNC_GET_WAIT_NPU_INFO,
|
||||
+ WLAN_FUNC_GET_WAIT_LAST_RATE,
|
||||
+ WLAN_FUNC_GET_WAIT_COUNTER,
|
||||
+ WLAN_FUNC_GET_WAIT_DBG_COUNTER,
|
||||
+ WLAN_FUNC_GET_WAIT_RXDESC_BASE,
|
||||
+ WLAN_FUNC_GET_WAIT_WCID_DBG_COUNTER,
|
||||
+ WLAN_FUNC_GET_WAIT_DMA_ADDR,
|
||||
+ WLAN_FUNC_GET_WAIT_RING_SIZE,
|
||||
+ WLAN_FUNC_GET_WAIT_NPU_SUPPORT_MAP,
|
||||
+ WLAN_FUNC_GET_WAIT_MDC_LOCK_ADDRESS,
|
||||
+ WLAN_FUNC_GET_WAIT_NPU_VERSION,
|
||||
+};
|
||||
+
|
||||
struct airoha_npu {
|
||||
struct device *dev;
|
||||
struct regmap *regmap;
|
||||
@@ -67,6 +81,14 @@ struct airoha_npu {
|
||||
u32 entry_size, u32 hash,
|
||||
bool ppe2);
|
||||
int (*wlan_init_reserved_memory)(struct airoha_npu *npu);
|
||||
+ int (*wlan_send_msg)(struct airoha_npu *npu, int ifindex,
|
||||
+ enum airoha_npu_wlan_set_cmd func_id,
|
||||
+ void *data, int data_len, gfp_t gfp);
|
||||
+ int (*wlan_get_msg)(struct airoha_npu *npu, int ifindex,
|
||||
+ enum airoha_npu_wlan_get_cmd func_id,
|
||||
+ void *data, int data_len, gfp_t gfp);
|
||||
+ u32 (*wlan_get_queue_addr)(struct airoha_npu *npu, int qid,
|
||||
+ bool xmit);
|
||||
} ops;
|
||||
};
|
||||
|
||||
@ -1,74 +0,0 @@
|
||||
From 03b7ca3ee5e1b700c462aed5b6cb88f616d6ba7f Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 11 Aug 2025 17:31:39 +0200
|
||||
Subject: [PATCH 3/6] net: airoha: npu: Add wlan irq management callbacks
|
||||
|
||||
Introduce callbacks used by the MT76 driver to configure NPU SoC
|
||||
interrupts. This is a preliminary patch to enable wlan flowtable
|
||||
offload for EN7581 SoC with MT76 driver.
|
||||
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250811-airoha-en7581-wlan-offlaod-v7-4-58823603bb4e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 27 ++++++++++++++++++++++++
|
||||
drivers/net/ethernet/airoha/airoha_npu.h | 4 ++++
|
||||
2 files changed, 31 insertions(+)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -520,6 +520,29 @@ static u32 airoha_npu_wlan_queue_addr_ge
|
||||
return REG_RX_BASE(qid);
|
||||
}
|
||||
|
||||
+static void airoha_npu_wlan_irq_status_set(struct airoha_npu *npu, u32 val)
|
||||
+{
|
||||
+ regmap_write(npu->regmap, REG_IRQ_STATUS, val);
|
||||
+}
|
||||
+
|
||||
+static u32 airoha_npu_wlan_irq_status_get(struct airoha_npu *npu, int q)
|
||||
+{
|
||||
+ u32 val;
|
||||
+
|
||||
+ regmap_read(npu->regmap, REG_IRQ_STATUS, &val);
|
||||
+ return val;
|
||||
+}
|
||||
+
|
||||
+static void airoha_npu_wlan_irq_enable(struct airoha_npu *npu, int q)
|
||||
+{
|
||||
+ regmap_set_bits(npu->regmap, REG_IRQ_RXDONE(q), NPU_IRQ_RX_MASK(q));
|
||||
+}
|
||||
+
|
||||
+static void airoha_npu_wlan_irq_disable(struct airoha_npu *npu, int q)
|
||||
+{
|
||||
+ regmap_clear_bits(npu->regmap, REG_IRQ_RXDONE(q), NPU_IRQ_RX_MASK(q));
|
||||
+}
|
||||
+
|
||||
struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
|
||||
{
|
||||
struct platform_device *pdev;
|
||||
@@ -627,6 +650,10 @@ static int airoha_npu_probe(struct platf
|
||||
npu->ops.wlan_send_msg = airoha_npu_wlan_msg_send;
|
||||
npu->ops.wlan_get_msg = airoha_npu_wlan_msg_get;
|
||||
npu->ops.wlan_get_queue_addr = airoha_npu_wlan_queue_addr_get;
|
||||
+ npu->ops.wlan_set_irq_status = airoha_npu_wlan_irq_status_set;
|
||||
+ npu->ops.wlan_get_irq_status = airoha_npu_wlan_irq_status_get;
|
||||
+ npu->ops.wlan_enable_irq = airoha_npu_wlan_irq_enable;
|
||||
+ npu->ops.wlan_disable_irq = airoha_npu_wlan_irq_disable;
|
||||
|
||||
npu->regmap = devm_regmap_init_mmio(dev, base, ®map_config);
|
||||
if (IS_ERR(npu->regmap))
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
@@ -89,6 +89,10 @@ struct airoha_npu {
|
||||
void *data, int data_len, gfp_t gfp);
|
||||
u32 (*wlan_get_queue_addr)(struct airoha_npu *npu, int qid,
|
||||
bool xmit);
|
||||
+ void (*wlan_set_irq_status)(struct airoha_npu *npu, u32 val);
|
||||
+ u32 (*wlan_get_irq_status)(struct airoha_npu *npu, int q);
|
||||
+ void (*wlan_enable_irq)(struct airoha_npu *npu, int q);
|
||||
+ void (*wlan_disable_irq)(struct airoha_npu *npu, int q);
|
||||
} ops;
|
||||
};
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
From a1740b16c83729d908c760eaa821f27b51e58a13 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 11 Aug 2025 17:31:40 +0200
|
||||
Subject: [PATCH 4/6] net: airoha: npu: Read NPU wlan interrupt lines from the
|
||||
DTS
|
||||
|
||||
Read all NPU wlan IRQ lines from the NPU device-tree node.
|
||||
NPU module fires wlan irq lines when the traffic to/from the WiFi NIC is
|
||||
not hw accelerated (these interrupts will be consumed by the MT76 driver
|
||||
in subsequent patches).
|
||||
This is a preliminary patch to enable wlan flowtable offload for EN7581
|
||||
SoC.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250811-airoha-en7581-wlan-offlaod-v7-5-58823603bb4e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 9 +++++++++
|
||||
drivers/net/ethernet/airoha/airoha_npu.h | 3 +++
|
||||
2 files changed, 12 insertions(+)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -696,6 +696,15 @@ static int airoha_npu_probe(struct platf
|
||||
INIT_WORK(&core->wdt_work, airoha_npu_wdt_work);
|
||||
}
|
||||
|
||||
+ /* wlan IRQ lines */
|
||||
+ for (i = 0; i < ARRAY_SIZE(npu->irqs); i++) {
|
||||
+ irq = platform_get_irq(pdev, i + ARRAY_SIZE(npu->cores) + 1);
|
||||
+ if (irq < 0)
|
||||
+ return irq;
|
||||
+
|
||||
+ npu->irqs[i] = irq;
|
||||
+ }
|
||||
+
|
||||
err = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
|
||||
if (err)
|
||||
return err;
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#define NPU_NUM_CORES 8
|
||||
+#define NPU_NUM_IRQ 6
|
||||
|
||||
enum airoha_npu_wlan_set_cmd {
|
||||
WLAN_FUNC_SET_WAIT_PCIE_ADDR,
|
||||
@@ -68,6 +69,8 @@ struct airoha_npu {
|
||||
struct work_struct wdt_work;
|
||||
} cores[NPU_NUM_CORES];
|
||||
|
||||
+ int irqs[NPU_NUM_IRQ];
|
||||
+
|
||||
struct airoha_foe_stats __iomem *stats;
|
||||
|
||||
struct {
|
||||
@ -1,28 +0,0 @@
|
||||
From 29c4a3ce508961a02d185ead2d52699b16d82c6d Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 11 Aug 2025 17:31:41 +0200
|
||||
Subject: [PATCH 5/6] net: airoha: npu: Enable core 3 for WiFi offloading
|
||||
|
||||
NPU core 3 is responsible for WiFi offloading so enable it during NPU
|
||||
probe.
|
||||
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250811-airoha-en7581-wlan-offlaod-v7-6-58823603bb4e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -726,8 +726,7 @@ static int airoha_npu_probe(struct platf
|
||||
usleep_range(1000, 2000);
|
||||
|
||||
/* enable NPU cores */
|
||||
- /* do not start core3 since it is used for WiFi offloading */
|
||||
- regmap_write(npu->regmap, REG_CR_BOOT_CONFIG, 0xf7);
|
||||
+ regmap_write(npu->regmap, REG_CR_BOOT_CONFIG, 0xff);
|
||||
regmap_write(npu->regmap, REG_CR_BOOT_TRIGGER, 0x1);
|
||||
msleep(100);
|
||||
|
||||
@ -1,416 +0,0 @@
|
||||
From b3ef7bdec66fb1813e865fd39d179a93cefd2015 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Mon, 11 Aug 2025 17:31:42 +0200
|
||||
Subject: [PATCH 6/6] net: airoha: Add airoha_offload.h header
|
||||
|
||||
Move NPU definitions to airoha_offload.h in include/linux/soc/airoha/ in
|
||||
order to allow the MT76 driver to access the callback definitions.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250811-airoha-en7581-wlan-offlaod-v7-7-58823603bb4e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 2 +-
|
||||
drivers/net/ethernet/airoha/airoha_npu.h | 103 ---------
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 2 +-
|
||||
include/linux/soc/airoha/airoha_offload.h | 260 ++++++++++++++++++++++
|
||||
4 files changed, 262 insertions(+), 105 deletions(-)
|
||||
delete mode 100644 drivers/net/ethernet/airoha/airoha_npu.h
|
||||
create mode 100644 include/linux/soc/airoha/airoha_offload.h
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -11,9 +11,9 @@
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_reserved_mem.h>
|
||||
#include <linux/regmap.h>
|
||||
+#include <linux/soc/airoha/airoha_offload.h>
|
||||
|
||||
#include "airoha_eth.h"
|
||||
-#include "airoha_npu.h"
|
||||
|
||||
#define NPU_EN7581_FIRMWARE_DATA "airoha/en7581_npu_data.bin"
|
||||
#define NPU_EN7581_FIRMWARE_RV32 "airoha/en7581_npu_rv32.bin"
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.h
|
||||
+++ /dev/null
|
||||
@@ -1,103 +0,0 @@
|
||||
-/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
-/*
|
||||
- * Copyright (c) 2025 AIROHA Inc
|
||||
- * Author: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
- */
|
||||
-
|
||||
-#define NPU_NUM_CORES 8
|
||||
-#define NPU_NUM_IRQ 6
|
||||
-
|
||||
-enum airoha_npu_wlan_set_cmd {
|
||||
- WLAN_FUNC_SET_WAIT_PCIE_ADDR,
|
||||
- WLAN_FUNC_SET_WAIT_DESC,
|
||||
- WLAN_FUNC_SET_WAIT_NPU_INIT_DONE,
|
||||
- WLAN_FUNC_SET_WAIT_TRAN_TO_CPU,
|
||||
- WLAN_FUNC_SET_WAIT_BA_WIN_SIZE,
|
||||
- WLAN_FUNC_SET_WAIT_DRIVER_MODEL,
|
||||
- WLAN_FUNC_SET_WAIT_DEL_STA,
|
||||
- WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR,
|
||||
- WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR,
|
||||
- WLAN_FUNC_SET_WAIT_IS_TEST_NOBA,
|
||||
- WLAN_FUNC_SET_WAIT_FLUSHONE_TIMEOUT,
|
||||
- WLAN_FUNC_SET_WAIT_FLUSHALL_TIMEOUT,
|
||||
- WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU,
|
||||
- WLAN_FUNC_SET_WAIT_PCIE_STATE,
|
||||
- WLAN_FUNC_SET_WAIT_PCIE_PORT_TYPE,
|
||||
- WLAN_FUNC_SET_WAIT_ERROR_RETRY_TIMES,
|
||||
- WLAN_FUNC_SET_WAIT_BAR_INFO,
|
||||
- WLAN_FUNC_SET_WAIT_FAST_FLAG,
|
||||
- WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU,
|
||||
- WLAN_FUNC_SET_WAIT_TX_RING_PCIE_ADDR,
|
||||
- WLAN_FUNC_SET_WAIT_TX_DESC_HW_BASE,
|
||||
- WLAN_FUNC_SET_WAIT_TX_BUF_SPACE_HW_BASE,
|
||||
- WLAN_FUNC_SET_WAIT_RX_RING_FOR_TXDONE_HW_BASE,
|
||||
- WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR,
|
||||
- WLAN_FUNC_SET_WAIT_INODE_TXRX_REG_ADDR,
|
||||
- WLAN_FUNC_SET_WAIT_INODE_DEBUG_FLAG,
|
||||
- WLAN_FUNC_SET_WAIT_INODE_HW_CFG_INFO,
|
||||
- WLAN_FUNC_SET_WAIT_INODE_STOP_ACTION,
|
||||
- WLAN_FUNC_SET_WAIT_INODE_PCIE_SWAP,
|
||||
- WLAN_FUNC_SET_WAIT_RATELIMIT_CTRL,
|
||||
- WLAN_FUNC_SET_WAIT_HWNAT_INIT,
|
||||
- WLAN_FUNC_SET_WAIT_ARHT_CHIP_INFO,
|
||||
- WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR,
|
||||
- WLAN_FUNC_SET_WAIT_TOKEN_ID_SIZE,
|
||||
-};
|
||||
-
|
||||
-enum airoha_npu_wlan_get_cmd {
|
||||
- WLAN_FUNC_GET_WAIT_NPU_INFO,
|
||||
- WLAN_FUNC_GET_WAIT_LAST_RATE,
|
||||
- WLAN_FUNC_GET_WAIT_COUNTER,
|
||||
- WLAN_FUNC_GET_WAIT_DBG_COUNTER,
|
||||
- WLAN_FUNC_GET_WAIT_RXDESC_BASE,
|
||||
- WLAN_FUNC_GET_WAIT_WCID_DBG_COUNTER,
|
||||
- WLAN_FUNC_GET_WAIT_DMA_ADDR,
|
||||
- WLAN_FUNC_GET_WAIT_RING_SIZE,
|
||||
- WLAN_FUNC_GET_WAIT_NPU_SUPPORT_MAP,
|
||||
- WLAN_FUNC_GET_WAIT_MDC_LOCK_ADDRESS,
|
||||
- WLAN_FUNC_GET_WAIT_NPU_VERSION,
|
||||
-};
|
||||
-
|
||||
-struct airoha_npu {
|
||||
- struct device *dev;
|
||||
- struct regmap *regmap;
|
||||
-
|
||||
- struct airoha_npu_core {
|
||||
- struct airoha_npu *npu;
|
||||
- /* protect concurrent npu memory accesses */
|
||||
- spinlock_t lock;
|
||||
- struct work_struct wdt_work;
|
||||
- } cores[NPU_NUM_CORES];
|
||||
-
|
||||
- int irqs[NPU_NUM_IRQ];
|
||||
-
|
||||
- struct airoha_foe_stats __iomem *stats;
|
||||
-
|
||||
- struct {
|
||||
- int (*ppe_init)(struct airoha_npu *npu);
|
||||
- int (*ppe_deinit)(struct airoha_npu *npu);
|
||||
- int (*ppe_flush_sram_entries)(struct airoha_npu *npu,
|
||||
- dma_addr_t foe_addr,
|
||||
- int sram_num_entries);
|
||||
- int (*ppe_foe_commit_entry)(struct airoha_npu *npu,
|
||||
- dma_addr_t foe_addr,
|
||||
- u32 entry_size, u32 hash,
|
||||
- bool ppe2);
|
||||
- int (*wlan_init_reserved_memory)(struct airoha_npu *npu);
|
||||
- int (*wlan_send_msg)(struct airoha_npu *npu, int ifindex,
|
||||
- enum airoha_npu_wlan_set_cmd func_id,
|
||||
- void *data, int data_len, gfp_t gfp);
|
||||
- int (*wlan_get_msg)(struct airoha_npu *npu, int ifindex,
|
||||
- enum airoha_npu_wlan_get_cmd func_id,
|
||||
- void *data, int data_len, gfp_t gfp);
|
||||
- u32 (*wlan_get_queue_addr)(struct airoha_npu *npu, int qid,
|
||||
- bool xmit);
|
||||
- void (*wlan_set_irq_status)(struct airoha_npu *npu, u32 val);
|
||||
- u32 (*wlan_get_irq_status)(struct airoha_npu *npu, int q);
|
||||
- void (*wlan_enable_irq)(struct airoha_npu *npu, int q);
|
||||
- void (*wlan_disable_irq)(struct airoha_npu *npu, int q);
|
||||
- } ops;
|
||||
-};
|
||||
-
|
||||
-struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr);
|
||||
-void airoha_npu_put(struct airoha_npu *npu);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -7,10 +7,10 @@
|
||||
#include <linux/ip.h>
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/rhashtable.h>
|
||||
+#include <linux/soc/airoha/airoha_offload.h>
|
||||
#include <net/ipv6.h>
|
||||
#include <net/pkt_cls.h>
|
||||
|
||||
-#include "airoha_npu.h"
|
||||
#include "airoha_regs.h"
|
||||
#include "airoha_eth.h"
|
||||
|
||||
--- /dev/null
|
||||
+++ b/include/linux/soc/airoha/airoha_offload.h
|
||||
@@ -0,0 +1,260 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
+/*
|
||||
+ * Copyright (c) 2025 AIROHA Inc
|
||||
+ * Author: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
+ */
|
||||
+#ifndef AIROHA_OFFLOAD_H
|
||||
+#define AIROHA_OFFLOAD_H
|
||||
+
|
||||
+#include <linux/spinlock.h>
|
||||
+#include <linux/workqueue.h>
|
||||
+
|
||||
+#define NPU_NUM_CORES 8
|
||||
+#define NPU_NUM_IRQ 6
|
||||
+#define NPU_RX0_DESC_NUM 512
|
||||
+#define NPU_RX1_DESC_NUM 512
|
||||
+
|
||||
+/* CTRL */
|
||||
+#define NPU_RX_DMA_DESC_LAST_MASK BIT(29)
|
||||
+#define NPU_RX_DMA_DESC_LEN_MASK GENMASK(28, 15)
|
||||
+#define NPU_RX_DMA_DESC_CUR_LEN_MASK GENMASK(14, 1)
|
||||
+#define NPU_RX_DMA_DESC_DONE_MASK BIT(0)
|
||||
+/* INFO */
|
||||
+#define NPU_RX_DMA_PKT_COUNT_MASK GENMASK(31, 28)
|
||||
+#define NPU_RX_DMA_PKT_ID_MASK GENMASK(28, 26)
|
||||
+#define NPU_RX_DMA_SRC_PORT_MASK GENMASK(25, 21)
|
||||
+#define NPU_RX_DMA_CRSN_MASK GENMASK(20, 16)
|
||||
+#define NPU_RX_DMA_FOE_ID_MASK GENMASK(15, 0)
|
||||
+/* DATA */
|
||||
+#define NPU_RX_DMA_SID_MASK GENMASK(31, 16)
|
||||
+#define NPU_RX_DMA_FRAG_TYPE_MASK GENMASK(15, 14)
|
||||
+#define NPU_RX_DMA_PRIORITY_MASK GENMASK(13, 10)
|
||||
+#define NPU_RX_DMA_RADIO_ID_MASK GENMASK(9, 6)
|
||||
+#define NPU_RX_DMA_VAP_ID_MASK GENMASK(5, 2)
|
||||
+#define NPU_RX_DMA_FRAME_TYPE_MASK GENMASK(1, 0)
|
||||
+
|
||||
+struct airoha_npu_rx_dma_desc {
|
||||
+ u32 ctrl;
|
||||
+ u32 info;
|
||||
+ u32 data;
|
||||
+ u32 addr;
|
||||
+ u64 rsv;
|
||||
+} __packed;
|
||||
+
|
||||
+/* CTRL */
|
||||
+#define NPU_TX_DMA_DESC_SCHED_MASK BIT(31)
|
||||
+#define NPU_TX_DMA_DESC_LEN_MASK GENMASK(30, 18)
|
||||
+#define NPU_TX_DMA_DESC_VEND_LEN_MASK GENMASK(17, 1)
|
||||
+#define NPU_TX_DMA_DESC_DONE_MASK BIT(0)
|
||||
+
|
||||
+#define NPU_TXWI_LEN 192
|
||||
+
|
||||
+struct airoha_npu_tx_dma_desc {
|
||||
+ u32 ctrl;
|
||||
+ u32 addr;
|
||||
+ u64 rsv;
|
||||
+ u8 txwi[NPU_TXWI_LEN];
|
||||
+} __packed;
|
||||
+
|
||||
+enum airoha_npu_wlan_set_cmd {
|
||||
+ WLAN_FUNC_SET_WAIT_PCIE_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_DESC,
|
||||
+ WLAN_FUNC_SET_WAIT_NPU_INIT_DONE,
|
||||
+ WLAN_FUNC_SET_WAIT_TRAN_TO_CPU,
|
||||
+ WLAN_FUNC_SET_WAIT_BA_WIN_SIZE,
|
||||
+ WLAN_FUNC_SET_WAIT_DRIVER_MODEL,
|
||||
+ WLAN_FUNC_SET_WAIT_DEL_STA,
|
||||
+ WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_IS_TEST_NOBA,
|
||||
+ WLAN_FUNC_SET_WAIT_FLUSHONE_TIMEOUT,
|
||||
+ WLAN_FUNC_SET_WAIT_FLUSHALL_TIMEOUT,
|
||||
+ WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU,
|
||||
+ WLAN_FUNC_SET_WAIT_PCIE_STATE,
|
||||
+ WLAN_FUNC_SET_WAIT_PCIE_PORT_TYPE,
|
||||
+ WLAN_FUNC_SET_WAIT_ERROR_RETRY_TIMES,
|
||||
+ WLAN_FUNC_SET_WAIT_BAR_INFO,
|
||||
+ WLAN_FUNC_SET_WAIT_FAST_FLAG,
|
||||
+ WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_RING_PCIE_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_DESC_HW_BASE,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_BUF_SPACE_HW_BASE,
|
||||
+ WLAN_FUNC_SET_WAIT_RX_RING_FOR_TXDONE_HW_BASE,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_TXRX_REG_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_DEBUG_FLAG,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_HW_CFG_INFO,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_STOP_ACTION,
|
||||
+ WLAN_FUNC_SET_WAIT_INODE_PCIE_SWAP,
|
||||
+ WLAN_FUNC_SET_WAIT_RATELIMIT_CTRL,
|
||||
+ WLAN_FUNC_SET_WAIT_HWNAT_INIT,
|
||||
+ WLAN_FUNC_SET_WAIT_ARHT_CHIP_INFO,
|
||||
+ WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR,
|
||||
+ WLAN_FUNC_SET_WAIT_TOKEN_ID_SIZE,
|
||||
+};
|
||||
+
|
||||
+enum airoha_npu_wlan_get_cmd {
|
||||
+ WLAN_FUNC_GET_WAIT_NPU_INFO,
|
||||
+ WLAN_FUNC_GET_WAIT_LAST_RATE,
|
||||
+ WLAN_FUNC_GET_WAIT_COUNTER,
|
||||
+ WLAN_FUNC_GET_WAIT_DBG_COUNTER,
|
||||
+ WLAN_FUNC_GET_WAIT_RXDESC_BASE,
|
||||
+ WLAN_FUNC_GET_WAIT_WCID_DBG_COUNTER,
|
||||
+ WLAN_FUNC_GET_WAIT_DMA_ADDR,
|
||||
+ WLAN_FUNC_GET_WAIT_RING_SIZE,
|
||||
+ WLAN_FUNC_GET_WAIT_NPU_SUPPORT_MAP,
|
||||
+ WLAN_FUNC_GET_WAIT_MDC_LOCK_ADDRESS,
|
||||
+ WLAN_FUNC_GET_WAIT_NPU_VERSION,
|
||||
+};
|
||||
+
|
||||
+struct airoha_npu {
|
||||
+#if (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU))
|
||||
+ struct device *dev;
|
||||
+ struct regmap *regmap;
|
||||
+
|
||||
+ struct airoha_npu_core {
|
||||
+ struct airoha_npu *npu;
|
||||
+ /* protect concurrent npu memory accesses */
|
||||
+ spinlock_t lock;
|
||||
+ struct work_struct wdt_work;
|
||||
+ } cores[NPU_NUM_CORES];
|
||||
+
|
||||
+ int irqs[NPU_NUM_IRQ];
|
||||
+
|
||||
+ struct airoha_foe_stats __iomem *stats;
|
||||
+
|
||||
+ struct {
|
||||
+ int (*ppe_init)(struct airoha_npu *npu);
|
||||
+ int (*ppe_deinit)(struct airoha_npu *npu);
|
||||
+ int (*ppe_flush_sram_entries)(struct airoha_npu *npu,
|
||||
+ dma_addr_t foe_addr,
|
||||
+ int sram_num_entries);
|
||||
+ int (*ppe_foe_commit_entry)(struct airoha_npu *npu,
|
||||
+ dma_addr_t foe_addr,
|
||||
+ u32 entry_size, u32 hash,
|
||||
+ bool ppe2);
|
||||
+ int (*wlan_init_reserved_memory)(struct airoha_npu *npu);
|
||||
+ int (*wlan_send_msg)(struct airoha_npu *npu, int ifindex,
|
||||
+ enum airoha_npu_wlan_set_cmd func_id,
|
||||
+ void *data, int data_len, gfp_t gfp);
|
||||
+ int (*wlan_get_msg)(struct airoha_npu *npu, int ifindex,
|
||||
+ enum airoha_npu_wlan_get_cmd func_id,
|
||||
+ void *data, int data_len, gfp_t gfp);
|
||||
+ u32 (*wlan_get_queue_addr)(struct airoha_npu *npu, int qid,
|
||||
+ bool xmit);
|
||||
+ void (*wlan_set_irq_status)(struct airoha_npu *npu, u32 val);
|
||||
+ u32 (*wlan_get_irq_status)(struct airoha_npu *npu, int q);
|
||||
+ void (*wlan_enable_irq)(struct airoha_npu *npu, int q);
|
||||
+ void (*wlan_disable_irq)(struct airoha_npu *npu, int q);
|
||||
+ } ops;
|
||||
+#endif
|
||||
+};
|
||||
+
|
||||
+#if (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU))
|
||||
+struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr);
|
||||
+void airoha_npu_put(struct airoha_npu *npu);
|
||||
+
|
||||
+static inline int airoha_npu_wlan_init_reserved_memory(struct airoha_npu *npu)
|
||||
+{
|
||||
+ return npu->ops.wlan_init_reserved_memory(npu);
|
||||
+}
|
||||
+
|
||||
+static inline int airoha_npu_wlan_send_msg(struct airoha_npu *npu,
|
||||
+ int ifindex,
|
||||
+ enum airoha_npu_wlan_set_cmd cmd,
|
||||
+ void *data, int data_len, gfp_t gfp)
|
||||
+{
|
||||
+ return npu->ops.wlan_send_msg(npu, ifindex, cmd, data, data_len, gfp);
|
||||
+}
|
||||
+
|
||||
+static inline int airoha_npu_wlan_get_msg(struct airoha_npu *npu, int ifindex,
|
||||
+ enum airoha_npu_wlan_get_cmd cmd,
|
||||
+ void *data, int data_len, gfp_t gfp)
|
||||
+{
|
||||
+ return npu->ops.wlan_get_msg(npu, ifindex, cmd, data, data_len, gfp);
|
||||
+}
|
||||
+
|
||||
+static inline u32 airoha_npu_wlan_get_queue_addr(struct airoha_npu *npu,
|
||||
+ int qid, bool xmit)
|
||||
+{
|
||||
+ return npu->ops.wlan_get_queue_addr(npu, qid, xmit);
|
||||
+}
|
||||
+
|
||||
+static inline void airoha_npu_wlan_set_irq_status(struct airoha_npu *npu,
|
||||
+ u32 val)
|
||||
+{
|
||||
+ npu->ops.wlan_set_irq_status(npu, val);
|
||||
+}
|
||||
+
|
||||
+static inline u32 airoha_npu_wlan_get_irq_status(struct airoha_npu *npu, int q)
|
||||
+{
|
||||
+ return npu->ops.wlan_get_irq_status(npu, q);
|
||||
+}
|
||||
+
|
||||
+static inline void airoha_npu_wlan_enable_irq(struct airoha_npu *npu, int q)
|
||||
+{
|
||||
+ npu->ops.wlan_enable_irq(npu, q);
|
||||
+}
|
||||
+
|
||||
+static inline void airoha_npu_wlan_disable_irq(struct airoha_npu *npu, int q)
|
||||
+{
|
||||
+ npu->ops.wlan_disable_irq(npu, q);
|
||||
+}
|
||||
+#else
|
||||
+static inline struct airoha_npu *airoha_npu_get(struct device *dev,
|
||||
+ dma_addr_t *foe_stats_addr)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static inline void airoha_npu_put(struct airoha_npu *npu)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static inline int airoha_npu_wlan_init_reserved_memory(struct airoha_npu *npu)
|
||||
+{
|
||||
+ return -EOPNOTSUPP;
|
||||
+}
|
||||
+
|
||||
+static inline int airoha_npu_wlan_send_msg(struct airoha_npu *npu,
|
||||
+ int ifindex,
|
||||
+ enum airoha_npu_wlan_set_cmd cmd,
|
||||
+ void *data, int data_len, gfp_t gfp)
|
||||
+{
|
||||
+ return -EOPNOTSUPP;
|
||||
+}
|
||||
+
|
||||
+static inline int airoha_npu_wlan_get_msg(struct airoha_npu *npu, int ifindex,
|
||||
+ enum airoha_npu_wlan_get_cmd cmd,
|
||||
+ void *data, int data_len, gfp_t gfp)
|
||||
+{
|
||||
+ return -EOPNOTSUPP;
|
||||
+}
|
||||
+
|
||||
+static inline u32 airoha_npu_wlan_get_queue_addr(struct airoha_npu *npu,
|
||||
+ int qid, bool xmit)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline void airoha_npu_wlan_set_irq_status(struct airoha_npu *npu,
|
||||
+ u32 val)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static inline u32 airoha_npu_wlan_get_irq_status(struct airoha_npu *npu,
|
||||
+ int q)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline void airoha_npu_wlan_enable_irq(struct airoha_npu *npu, int q)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static inline void airoha_npu_wlan_disable_irq(struct airoha_npu *npu, int q)
|
||||
+{
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#endif /* AIROHA_OFFLOAD_H */
|
||||
@ -1,198 +0,0 @@
|
||||
From a8bdd935d1ddb7186358fb60ffe84253e85340c8 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 14 Aug 2025 09:51:16 +0200
|
||||
Subject: [PATCH] net: airoha: Add wlan flowtable TX offload
|
||||
|
||||
Introduce support to offload the traffic received on the ethernet NIC
|
||||
and forwarded to the wireless one using HW Packet Processor Engine (PPE)
|
||||
capabilities.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250814-airoha-en7581-wlan-tx-offload-v1-1-72e0a312003e@kernel.org
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 11 +++
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 103 ++++++++++++++++-------
|
||||
2 files changed, 85 insertions(+), 29 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -252,6 +252,10 @@ enum {
|
||||
#define AIROHA_FOE_MAC_SMAC_ID GENMASK(20, 16)
|
||||
#define AIROHA_FOE_MAC_PPPOE_ID GENMASK(15, 0)
|
||||
|
||||
+#define AIROHA_FOE_MAC_WDMA_QOS GENMASK(15, 12)
|
||||
+#define AIROHA_FOE_MAC_WDMA_BAND BIT(11)
|
||||
+#define AIROHA_FOE_MAC_WDMA_WCID GENMASK(10, 0)
|
||||
+
|
||||
struct airoha_foe_mac_info_common {
|
||||
u16 vlan1;
|
||||
u16 etype;
|
||||
@@ -481,6 +485,13 @@ struct airoha_flow_table_entry {
|
||||
unsigned long cookie;
|
||||
};
|
||||
|
||||
+struct airoha_wdma_info {
|
||||
+ u8 idx;
|
||||
+ u8 queue;
|
||||
+ u16 wcid;
|
||||
+ u8 bss;
|
||||
+};
|
||||
+
|
||||
/* RX queue to IRQ mapping: BIT(q) in IRQ(n) */
|
||||
#define RX_IRQ0_BANK_PIN_MASK 0x839f
|
||||
#define RX_IRQ1_BANK_PIN_MASK 0x7fe00000
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -190,6 +190,31 @@ static int airoha_ppe_flow_mangle_ipv4(c
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int airoha_ppe_get_wdma_info(struct net_device *dev, const u8 *addr,
|
||||
+ struct airoha_wdma_info *info)
|
||||
+{
|
||||
+ struct net_device_path_stack stack;
|
||||
+ struct net_device_path *path;
|
||||
+ int err;
|
||||
+
|
||||
+ if (!dev)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ err = dev_fill_forward_path(dev, addr, &stack);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ path = &stack.path[stack.num_paths - 1];
|
||||
+ if (path->type != DEV_PATH_MTK_WDMA)
|
||||
+ return -1;
|
||||
+
|
||||
+ info->idx = path->mtk_wdma.wdma_idx;
|
||||
+ info->bss = path->mtk_wdma.bss;
|
||||
+ info->wcid = path->mtk_wdma.wcid;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int airoha_get_dsa_port(struct net_device **dev)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_NET_DSA)
|
||||
@@ -220,9 +245,9 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
struct airoha_flow_data *data,
|
||||
int l4proto)
|
||||
{
|
||||
- int dsa_port = airoha_get_dsa_port(&dev);
|
||||
+ u32 qdata = FIELD_PREP(AIROHA_FOE_SHAPER_ID, 0x7f), ports_pad, val;
|
||||
+ int wlan_etype = -EINVAL, dsa_port = airoha_get_dsa_port(&dev);
|
||||
struct airoha_foe_mac_info_common *l2;
|
||||
- u32 qdata, ports_pad, val;
|
||||
u8 smac_id = 0xf;
|
||||
|
||||
memset(hwe, 0, sizeof(*hwe));
|
||||
@@ -236,31 +261,47 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
AIROHA_FOE_IB1_BIND_TTL;
|
||||
hwe->ib1 = val;
|
||||
|
||||
- val = FIELD_PREP(AIROHA_FOE_IB2_PORT_AG, 0x1f) |
|
||||
- AIROHA_FOE_IB2_PSE_QOS;
|
||||
- if (dsa_port >= 0)
|
||||
- val |= FIELD_PREP(AIROHA_FOE_IB2_NBQ, dsa_port);
|
||||
-
|
||||
+ val = FIELD_PREP(AIROHA_FOE_IB2_PORT_AG, 0x1f);
|
||||
if (dev) {
|
||||
- struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
- u8 pse_port;
|
||||
-
|
||||
- if (!airoha_is_valid_gdm_port(eth, port))
|
||||
- return -EINVAL;
|
||||
+ struct airoha_wdma_info info = {};
|
||||
|
||||
- if (dsa_port >= 0)
|
||||
- pse_port = port->id == 4 ? FE_PSE_PORT_GDM4 : port->id;
|
||||
- else
|
||||
- pse_port = 2; /* uplink relies on GDM2 loopback */
|
||||
- val |= FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT, pse_port);
|
||||
-
|
||||
- /* For downlink traffic consume SRAM memory for hw forwarding
|
||||
- * descriptors queue.
|
||||
- */
|
||||
- if (airhoa_is_lan_gdm_port(port))
|
||||
- val |= AIROHA_FOE_IB2_FAST_PATH;
|
||||
+ if (!airoha_ppe_get_wdma_info(dev, data->eth.h_dest, &info)) {
|
||||
+ val |= FIELD_PREP(AIROHA_FOE_IB2_NBQ, info.idx) |
|
||||
+ FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT,
|
||||
+ FE_PSE_PORT_CDM4);
|
||||
+ qdata |= FIELD_PREP(AIROHA_FOE_ACTDP, info.bss);
|
||||
+ wlan_etype = FIELD_PREP(AIROHA_FOE_MAC_WDMA_BAND,
|
||||
+ info.idx) |
|
||||
+ FIELD_PREP(AIROHA_FOE_MAC_WDMA_WCID,
|
||||
+ info.wcid);
|
||||
+ } else {
|
||||
+ struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
+ u8 pse_port;
|
||||
+
|
||||
+ if (!airoha_is_valid_gdm_port(eth, port))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (dsa_port >= 0)
|
||||
+ pse_port = port->id == 4 ? FE_PSE_PORT_GDM4
|
||||
+ : port->id;
|
||||
+ else
|
||||
+ pse_port = 2; /* uplink relies on GDM2
|
||||
+ * loopback
|
||||
+ */
|
||||
+
|
||||
+ val |= FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT, pse_port) |
|
||||
+ AIROHA_FOE_IB2_PSE_QOS;
|
||||
+ /* For downlink traffic consume SRAM memory for hw
|
||||
+ * forwarding descriptors queue.
|
||||
+ */
|
||||
+ if (airhoa_is_lan_gdm_port(port))
|
||||
+ val |= AIROHA_FOE_IB2_FAST_PATH;
|
||||
+ if (dsa_port >= 0)
|
||||
+ val |= FIELD_PREP(AIROHA_FOE_IB2_NBQ,
|
||||
+ dsa_port);
|
||||
|
||||
- smac_id = port->id;
|
||||
+ smac_id = port->id;
|
||||
+ }
|
||||
}
|
||||
|
||||
if (is_multicast_ether_addr(data->eth.h_dest))
|
||||
@@ -272,7 +313,6 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
if (type == PPE_PKT_TYPE_IPV6_ROUTE_3T)
|
||||
hwe->ipv6.ports = ports_pad;
|
||||
|
||||
- qdata = FIELD_PREP(AIROHA_FOE_SHAPER_ID, 0x7f);
|
||||
if (type == PPE_PKT_TYPE_BRIDGE) {
|
||||
airoha_ppe_foe_set_bridge_addrs(&hwe->bridge, &data->eth);
|
||||
hwe->bridge.data = qdata;
|
||||
@@ -313,7 +353,9 @@ static int airoha_ppe_foe_entry_prepare(
|
||||
l2->vlan2 = data->vlan.hdr[1].id;
|
||||
}
|
||||
|
||||
- if (dsa_port >= 0) {
|
||||
+ if (wlan_etype >= 0) {
|
||||
+ l2->etype = wlan_etype;
|
||||
+ } else if (dsa_port >= 0) {
|
||||
l2->etype = BIT(dsa_port);
|
||||
l2->etype |= !data->vlan.num ? BIT(15) : 0;
|
||||
} else if (data->pppoe.num) {
|
||||
@@ -490,6 +532,10 @@ static void airoha_ppe_foe_flow_stats_up
|
||||
meter = &hwe->ipv4.l2.meter;
|
||||
}
|
||||
|
||||
+ pse_port = FIELD_GET(AIROHA_FOE_IB2_PSE_PORT, *ib2);
|
||||
+ if (pse_port == FE_PSE_PORT_CDM4)
|
||||
+ return;
|
||||
+
|
||||
airoha_ppe_foe_flow_stat_entry_reset(ppe, npu, index);
|
||||
|
||||
val = FIELD_GET(AIROHA_FOE_CHANNEL | AIROHA_FOE_QID, *data);
|
||||
@@ -500,7 +546,6 @@ static void airoha_ppe_foe_flow_stats_up
|
||||
AIROHA_FOE_IB2_PSE_QOS | AIROHA_FOE_IB2_FAST_PATH);
|
||||
*meter |= FIELD_PREP(AIROHA_FOE_TUNNEL_MTU, val);
|
||||
|
||||
- pse_port = FIELD_GET(AIROHA_FOE_IB2_PSE_PORT, *ib2);
|
||||
nbq = pse_port == 1 ? 6 : 5;
|
||||
*ib2 &= ~(AIROHA_FOE_IB2_NBQ | AIROHA_FOE_IB2_PSE_PORT |
|
||||
AIROHA_FOE_IB2_PSE_QOS);
|
||||
@ -1,95 +0,0 @@
|
||||
From 524a43c3a0c17fa0a1223eea36751dcba55e5530 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Sat, 23 Aug 2025 09:56:02 +0200
|
||||
Subject: [PATCH 1/3] net: airoha: Rely on airoha_eth struct in
|
||||
airoha_ppe_flow_offload_cmd signature
|
||||
|
||||
Rely on airoha_eth struct in airoha_ppe_flow_offload_cmd routine
|
||||
signature and in all the called subroutines.
|
||||
This is a preliminary patch to introduce flowtable offload for traffic
|
||||
received by the wlan NIC and forwarded to the ethernet one.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250823-airoha-en7581-wlan-rx-offload-v3-1-f78600ec3ed8@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 20 ++++++++------------
|
||||
1 file changed, 8 insertions(+), 12 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -935,11 +935,10 @@ static int airoha_ppe_entry_idle_time(st
|
||||
return airoha_ppe_get_entry_idle_time(ppe, e->data.ib1);
|
||||
}
|
||||
|
||||
-static int airoha_ppe_flow_offload_replace(struct airoha_gdm_port *port,
|
||||
+static int airoha_ppe_flow_offload_replace(struct airoha_eth *eth,
|
||||
struct flow_cls_offload *f)
|
||||
{
|
||||
struct flow_rule *rule = flow_cls_offload_flow_rule(f);
|
||||
- struct airoha_eth *eth = port->qdma->eth;
|
||||
struct airoha_flow_table_entry *e;
|
||||
struct airoha_flow_data data = {};
|
||||
struct net_device *odev = NULL;
|
||||
@@ -1136,10 +1135,9 @@ free_entry:
|
||||
return err;
|
||||
}
|
||||
|
||||
-static int airoha_ppe_flow_offload_destroy(struct airoha_gdm_port *port,
|
||||
+static int airoha_ppe_flow_offload_destroy(struct airoha_eth *eth,
|
||||
struct flow_cls_offload *f)
|
||||
{
|
||||
- struct airoha_eth *eth = port->qdma->eth;
|
||||
struct airoha_flow_table_entry *e;
|
||||
|
||||
e = rhashtable_lookup(ð->flow_table, &f->cookie,
|
||||
@@ -1182,10 +1180,9 @@ void airoha_ppe_foe_entry_get_stats(stru
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
-static int airoha_ppe_flow_offload_stats(struct airoha_gdm_port *port,
|
||||
+static int airoha_ppe_flow_offload_stats(struct airoha_eth *eth,
|
||||
struct flow_cls_offload *f)
|
||||
{
|
||||
- struct airoha_eth *eth = port->qdma->eth;
|
||||
struct airoha_flow_table_entry *e;
|
||||
u32 idle;
|
||||
|
||||
@@ -1209,16 +1206,16 @@ static int airoha_ppe_flow_offload_stats
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int airoha_ppe_flow_offload_cmd(struct airoha_gdm_port *port,
|
||||
+static int airoha_ppe_flow_offload_cmd(struct airoha_eth *eth,
|
||||
struct flow_cls_offload *f)
|
||||
{
|
||||
switch (f->command) {
|
||||
case FLOW_CLS_REPLACE:
|
||||
- return airoha_ppe_flow_offload_replace(port, f);
|
||||
+ return airoha_ppe_flow_offload_replace(eth, f);
|
||||
case FLOW_CLS_DESTROY:
|
||||
- return airoha_ppe_flow_offload_destroy(port, f);
|
||||
+ return airoha_ppe_flow_offload_destroy(eth, f);
|
||||
case FLOW_CLS_STATS:
|
||||
- return airoha_ppe_flow_offload_stats(port, f);
|
||||
+ return airoha_ppe_flow_offload_stats(eth, f);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1288,7 +1285,6 @@ error_npu_put:
|
||||
int airoha_ppe_setup_tc_block_cb(struct net_device *dev, void *type_data)
|
||||
{
|
||||
struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
- struct flow_cls_offload *cls = type_data;
|
||||
struct airoha_eth *eth = port->qdma->eth;
|
||||
int err = 0;
|
||||
|
||||
@@ -1297,7 +1293,7 @@ int airoha_ppe_setup_tc_block_cb(struct
|
||||
if (!eth->npu)
|
||||
err = airoha_ppe_offload_setup(eth);
|
||||
if (!err)
|
||||
- err = airoha_ppe_flow_offload_cmd(port, cls);
|
||||
+ err = airoha_ppe_flow_offload_cmd(eth, type_data);
|
||||
|
||||
mutex_unlock(&flow_offload_mutex);
|
||||
|
||||
@ -1,223 +0,0 @@
|
||||
From f45fc18b6de04483643e8aa2ab97737abfe03d59 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Sat, 23 Aug 2025 09:56:03 +0200
|
||||
Subject: [PATCH 2/3] net: airoha: Add airoha_ppe_dev struct definition
|
||||
|
||||
Introduce airoha_ppe_dev struct as container for PPE offload callbacks
|
||||
consumed by the MT76 driver during flowtable offload for traffic
|
||||
received by the wlan NIC and forwarded to the wired one.
|
||||
Add airoha_ppe_setup_tc_block_cb routine to PPE offload ops for MT76
|
||||
driver.
|
||||
Rely on airoha_ppe_dev pointer in airoha_ppe_setup_tc_block_cb
|
||||
signature.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250823-airoha-en7581-wlan-rx-offload-v3-2-f78600ec3ed8@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 4 +-
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 4 +-
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 1 -
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 67 +++++++++++++++++++++--
|
||||
include/linux/soc/airoha/airoha_offload.h | 35 ++++++++++++
|
||||
5 files changed, 104 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -2622,13 +2622,15 @@ static int airoha_dev_setup_tc_block_cb(
|
||||
void *type_data, void *cb_priv)
|
||||
{
|
||||
struct net_device *dev = cb_priv;
|
||||
+ struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
+ struct airoha_eth *eth = port->qdma->eth;
|
||||
|
||||
if (!tc_can_offload(dev))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
switch (type) {
|
||||
case TC_SETUP_CLSFLOWER:
|
||||
- return airoha_ppe_setup_tc_block_cb(dev, type_data);
|
||||
+ return airoha_ppe_setup_tc_block_cb(ð->ppe->dev, type_data);
|
||||
case TC_SETUP_CLSMATCHALL:
|
||||
return airoha_dev_tc_matchall(dev, type_data);
|
||||
default:
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/reset.h>
|
||||
+#include <linux/soc/airoha/airoha_offload.h>
|
||||
#include <net/dsa.h>
|
||||
|
||||
#define AIROHA_MAX_NUM_GDM_PORTS 4
|
||||
@@ -546,6 +547,7 @@ struct airoha_gdm_port {
|
||||
#define AIROHA_RXD4_FOE_ENTRY GENMASK(15, 0)
|
||||
|
||||
struct airoha_ppe {
|
||||
+ struct airoha_ppe_dev dev;
|
||||
struct airoha_eth *eth;
|
||||
|
||||
void *foe;
|
||||
@@ -622,7 +624,7 @@ bool airoha_is_valid_gdm_port(struct air
|
||||
|
||||
void airoha_ppe_check_skb(struct airoha_ppe *ppe, struct sk_buff *skb,
|
||||
u16 hash);
|
||||
-int airoha_ppe_setup_tc_block_cb(struct net_device *dev, void *type_data);
|
||||
+int airoha_ppe_setup_tc_block_cb(struct airoha_ppe_dev *dev, void *type_data);
|
||||
int airoha_ppe_init(struct airoha_eth *eth);
|
||||
void airoha_ppe_deinit(struct airoha_eth *eth);
|
||||
void airoha_ppe_init_upd_mem(struct airoha_gdm_port *port);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_reserved_mem.h>
|
||||
#include <linux/regmap.h>
|
||||
-#include <linux/soc/airoha/airoha_offload.h>
|
||||
|
||||
#include "airoha_eth.h"
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
#include <linux/ip.h>
|
||||
#include <linux/ipv6.h>
|
||||
+#include <linux/of_platform.h>
|
||||
+#include <linux/platform_device.h>
|
||||
#include <linux/rhashtable.h>
|
||||
-#include <linux/soc/airoha/airoha_offload.h>
|
||||
#include <net/ipv6.h>
|
||||
#include <net/pkt_cls.h>
|
||||
|
||||
@@ -1282,10 +1283,10 @@ error_npu_put:
|
||||
return err;
|
||||
}
|
||||
|
||||
-int airoha_ppe_setup_tc_block_cb(struct net_device *dev, void *type_data)
|
||||
+int airoha_ppe_setup_tc_block_cb(struct airoha_ppe_dev *dev, void *type_data)
|
||||
{
|
||||
- struct airoha_gdm_port *port = netdev_priv(dev);
|
||||
- struct airoha_eth *eth = port->qdma->eth;
|
||||
+ struct airoha_ppe *ppe = dev->priv;
|
||||
+ struct airoha_eth *eth = ppe->eth;
|
||||
int err = 0;
|
||||
|
||||
mutex_lock(&flow_offload_mutex);
|
||||
@@ -1338,6 +1339,61 @@ void airoha_ppe_init_upd_mem(struct airo
|
||||
PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
|
||||
}
|
||||
|
||||
+struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
|
||||
+{
|
||||
+ struct platform_device *pdev;
|
||||
+ struct device_node *np;
|
||||
+ struct airoha_eth *eth;
|
||||
+
|
||||
+ np = of_parse_phandle(dev->of_node, "airoha,eth", 0);
|
||||
+ if (!np)
|
||||
+ return ERR_PTR(-ENODEV);
|
||||
+
|
||||
+ pdev = of_find_device_by_node(np);
|
||||
+ if (!pdev) {
|
||||
+ dev_err(dev, "cannot find device node %s\n", np->name);
|
||||
+ of_node_put(np);
|
||||
+ return ERR_PTR(-ENODEV);
|
||||
+ }
|
||||
+ of_node_put(np);
|
||||
+
|
||||
+ if (!try_module_get(THIS_MODULE)) {
|
||||
+ dev_err(dev, "failed to get the device driver module\n");
|
||||
+ goto error_pdev_put;
|
||||
+ }
|
||||
+
|
||||
+ eth = platform_get_drvdata(pdev);
|
||||
+ if (!eth)
|
||||
+ goto error_module_put;
|
||||
+
|
||||
+ if (!device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER)) {
|
||||
+ dev_err(&pdev->dev,
|
||||
+ "failed to create device link to consumer %s\n",
|
||||
+ dev_name(dev));
|
||||
+ goto error_module_put;
|
||||
+ }
|
||||
+
|
||||
+ return ð->ppe->dev;
|
||||
+
|
||||
+error_module_put:
|
||||
+ module_put(THIS_MODULE);
|
||||
+error_pdev_put:
|
||||
+ platform_device_put(pdev);
|
||||
+
|
||||
+ return ERR_PTR(-ENODEV);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(airoha_ppe_get_dev);
|
||||
+
|
||||
+void airoha_ppe_put_dev(struct airoha_ppe_dev *dev)
|
||||
+{
|
||||
+ struct airoha_ppe *ppe = dev->priv;
|
||||
+ struct airoha_eth *eth = ppe->eth;
|
||||
+
|
||||
+ module_put(THIS_MODULE);
|
||||
+ put_device(eth->dev);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(airoha_ppe_put_dev);
|
||||
+
|
||||
int airoha_ppe_init(struct airoha_eth *eth)
|
||||
{
|
||||
struct airoha_ppe *ppe;
|
||||
@@ -1347,6 +1403,9 @@ int airoha_ppe_init(struct airoha_eth *e
|
||||
if (!ppe)
|
||||
return -ENOMEM;
|
||||
|
||||
+ ppe->dev.ops.setup_tc_block_cb = airoha_ppe_setup_tc_block_cb;
|
||||
+ ppe->dev.priv = ppe;
|
||||
+
|
||||
foe_size = PPE_NUM_ENTRIES * sizeof(struct airoha_foe_entry);
|
||||
ppe->foe = dmam_alloc_coherent(eth->dev, foe_size, &ppe->foe_dma,
|
||||
GFP_KERNEL);
|
||||
--- a/include/linux/soc/airoha/airoha_offload.h
|
||||
+++ b/include/linux/soc/airoha/airoha_offload.h
|
||||
@@ -9,6 +9,41 @@
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
+struct airoha_ppe_dev {
|
||||
+ struct {
|
||||
+ int (*setup_tc_block_cb)(struct airoha_ppe_dev *dev,
|
||||
+ void *type_data);
|
||||
+ } ops;
|
||||
+
|
||||
+ void *priv;
|
||||
+};
|
||||
+
|
||||
+#if (IS_BUILTIN(CONFIG_NET_AIROHA) || IS_MODULE(CONFIG_NET_AIROHA))
|
||||
+struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev);
|
||||
+void airoha_ppe_put_dev(struct airoha_ppe_dev *dev);
|
||||
+
|
||||
+static inline int airoha_ppe_dev_setup_tc_block_cb(struct airoha_ppe_dev *dev,
|
||||
+ void *type_data)
|
||||
+{
|
||||
+ return dev->ops.setup_tc_block_cb(dev, type_data);
|
||||
+}
|
||||
+#else
|
||||
+static inline struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static inline void airoha_ppe_put_dev(struct airoha_ppe_dev *dev)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static inline int airoha_ppe_setup_tc_block_cb(struct airoha_ppe_dev *dev,
|
||||
+ void *type_data)
|
||||
+{
|
||||
+ return -EOPNOTSUPP;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
#define NPU_NUM_CORES 8
|
||||
#define NPU_NUM_IRQ 6
|
||||
#define NPU_RX0_DESC_NUM 512
|
||||
@ -1,207 +0,0 @@
|
||||
From a7cc1aa151e3a9c0314b995f06102f7763d3bd71 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Sat, 23 Aug 2025 09:56:04 +0200
|
||||
Subject: [PATCH 3/3] net: airoha: Introduce check_skb callback in ppe_dev ops
|
||||
|
||||
Export airoha_ppe_check_skb routine in ppe_dev ops. check_skb callback
|
||||
will be used by the MT76 driver in order to offload the traffic received
|
||||
by the wlan NIC and forwarded to the ethernet one.
|
||||
Add rx_wlan parameter to airoha_ppe_check_skb routine signature.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://patch.msgid.link/20250823-airoha-en7581-wlan-rx-offload-v3-3-f78600ec3ed8@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 3 ++-
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 8 ++------
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 25 +++++++++++++----------
|
||||
include/linux/soc/airoha/airoha_offload.h | 20 ++++++++++++++++++
|
||||
4 files changed, 38 insertions(+), 18 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -703,7 +703,8 @@ static int airoha_qdma_rx_process(struct
|
||||
|
||||
reason = FIELD_GET(AIROHA_RXD4_PPE_CPU_REASON, msg1);
|
||||
if (reason == PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
|
||||
- airoha_ppe_check_skb(eth->ppe, q->skb, hash);
|
||||
+ airoha_ppe_check_skb(ð->ppe->dev, q->skb, hash,
|
||||
+ false);
|
||||
|
||||
done++;
|
||||
napi_gro_receive(&q->napi, q->skb);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -230,10 +230,6 @@ struct airoha_hw_stats {
|
||||
};
|
||||
|
||||
enum {
|
||||
- PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED = 0x0f,
|
||||
-};
|
||||
-
|
||||
-enum {
|
||||
AIROHA_FOE_STATE_INVALID,
|
||||
AIROHA_FOE_STATE_UNBIND,
|
||||
AIROHA_FOE_STATE_BIND,
|
||||
@@ -622,8 +618,8 @@ static inline bool airhoa_is_lan_gdm_por
|
||||
bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
|
||||
struct airoha_gdm_port *port);
|
||||
|
||||
-void airoha_ppe_check_skb(struct airoha_ppe *ppe, struct sk_buff *skb,
|
||||
- u16 hash);
|
||||
+void airoha_ppe_check_skb(struct airoha_ppe_dev *dev, struct sk_buff *skb,
|
||||
+ u16 hash, bool rx_wlan);
|
||||
int airoha_ppe_setup_tc_block_cb(struct airoha_ppe_dev *dev, void *type_data);
|
||||
int airoha_ppe_init(struct airoha_eth *eth);
|
||||
void airoha_ppe_deinit(struct airoha_eth *eth);
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -616,7 +616,7 @@ static bool airoha_ppe_foe_compare_entry
|
||||
|
||||
static int airoha_ppe_foe_commit_entry(struct airoha_ppe *ppe,
|
||||
struct airoha_foe_entry *e,
|
||||
- u32 hash)
|
||||
+ u32 hash, bool rx_wlan)
|
||||
{
|
||||
struct airoha_foe_entry *hwe = ppe->foe + hash * sizeof(*hwe);
|
||||
u32 ts = airoha_ppe_get_timestamp(ppe);
|
||||
@@ -639,7 +639,8 @@ static int airoha_ppe_foe_commit_entry(s
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
- airoha_ppe_foe_flow_stats_update(ppe, npu, hwe, hash);
|
||||
+ if (!rx_wlan)
|
||||
+ airoha_ppe_foe_flow_stats_update(ppe, npu, hwe, hash);
|
||||
|
||||
if (hash < PPE_SRAM_NUM_ENTRIES) {
|
||||
dma_addr_t addr = ppe->foe_dma + hash * sizeof(*hwe);
|
||||
@@ -665,7 +666,7 @@ static void airoha_ppe_foe_remove_flow(s
|
||||
e->data.ib1 &= ~AIROHA_FOE_IB1_BIND_STATE;
|
||||
e->data.ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE,
|
||||
AIROHA_FOE_STATE_INVALID);
|
||||
- airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash);
|
||||
+ airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash, false);
|
||||
e->hash = 0xffff;
|
||||
}
|
||||
if (e->type == FLOW_TYPE_L2_SUBFLOW) {
|
||||
@@ -704,7 +705,7 @@ static void airoha_ppe_foe_flow_remove_e
|
||||
static int
|
||||
airoha_ppe_foe_commit_subflow_entry(struct airoha_ppe *ppe,
|
||||
struct airoha_flow_table_entry *e,
|
||||
- u32 hash)
|
||||
+ u32 hash, bool rx_wlan)
|
||||
{
|
||||
u32 mask = AIROHA_FOE_IB1_BIND_PACKET_TYPE | AIROHA_FOE_IB1_BIND_UDP;
|
||||
struct airoha_foe_entry *hwe_p, hwe;
|
||||
@@ -745,14 +746,14 @@ airoha_ppe_foe_commit_subflow_entry(stru
|
||||
}
|
||||
|
||||
hwe.bridge.data = e->data.bridge.data;
|
||||
- airoha_ppe_foe_commit_entry(ppe, &hwe, hash);
|
||||
+ airoha_ppe_foe_commit_entry(ppe, &hwe, hash, rx_wlan);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void airoha_ppe_foe_insert_entry(struct airoha_ppe *ppe,
|
||||
struct sk_buff *skb,
|
||||
- u32 hash)
|
||||
+ u32 hash, bool rx_wlan)
|
||||
{
|
||||
struct airoha_flow_table_entry *e;
|
||||
struct airoha_foe_bridge br = {};
|
||||
@@ -785,7 +786,7 @@ static void airoha_ppe_foe_insert_entry(
|
||||
if (!airoha_ppe_foe_compare_entry(e, hwe))
|
||||
continue;
|
||||
|
||||
- airoha_ppe_foe_commit_entry(ppe, &e->data, hash);
|
||||
+ airoha_ppe_foe_commit_entry(ppe, &e->data, hash, rx_wlan);
|
||||
commit_done = true;
|
||||
e->hash = hash;
|
||||
}
|
||||
@@ -797,7 +798,7 @@ static void airoha_ppe_foe_insert_entry(
|
||||
e = rhashtable_lookup_fast(&ppe->l2_flows, &br,
|
||||
airoha_l2_flow_table_params);
|
||||
if (e)
|
||||
- airoha_ppe_foe_commit_subflow_entry(ppe, e, hash);
|
||||
+ airoha_ppe_foe_commit_subflow_entry(ppe, e, hash, rx_wlan);
|
||||
unlock:
|
||||
spin_unlock_bh(&ppe_lock);
|
||||
}
|
||||
@@ -1301,9 +1302,10 @@ int airoha_ppe_setup_tc_block_cb(struct
|
||||
return err;
|
||||
}
|
||||
|
||||
-void airoha_ppe_check_skb(struct airoha_ppe *ppe, struct sk_buff *skb,
|
||||
- u16 hash)
|
||||
+void airoha_ppe_check_skb(struct airoha_ppe_dev *dev, struct sk_buff *skb,
|
||||
+ u16 hash, bool rx_wlan)
|
||||
{
|
||||
+ struct airoha_ppe *ppe = dev->priv;
|
||||
u16 now, diff;
|
||||
|
||||
if (hash > PPE_HASH_MASK)
|
||||
@@ -1315,7 +1317,7 @@ void airoha_ppe_check_skb(struct airoha_
|
||||
return;
|
||||
|
||||
ppe->foe_check_time[hash] = now;
|
||||
- airoha_ppe_foe_insert_entry(ppe, skb, hash);
|
||||
+ airoha_ppe_foe_insert_entry(ppe, skb, hash, rx_wlan);
|
||||
}
|
||||
|
||||
void airoha_ppe_init_upd_mem(struct airoha_gdm_port *port)
|
||||
@@ -1404,6 +1406,7 @@ int airoha_ppe_init(struct airoha_eth *e
|
||||
return -ENOMEM;
|
||||
|
||||
ppe->dev.ops.setup_tc_block_cb = airoha_ppe_setup_tc_block_cb;
|
||||
+ ppe->dev.ops.check_skb = airoha_ppe_check_skb;
|
||||
ppe->dev.priv = ppe;
|
||||
|
||||
foe_size = PPE_NUM_ENTRIES * sizeof(struct airoha_foe_entry);
|
||||
--- a/include/linux/soc/airoha/airoha_offload.h
|
||||
+++ b/include/linux/soc/airoha/airoha_offload.h
|
||||
@@ -9,10 +9,17 @@
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
+enum {
|
||||
+ PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED = 0x0f,
|
||||
+};
|
||||
+
|
||||
struct airoha_ppe_dev {
|
||||
struct {
|
||||
int (*setup_tc_block_cb)(struct airoha_ppe_dev *dev,
|
||||
void *type_data);
|
||||
+ void (*check_skb)(struct airoha_ppe_dev *dev,
|
||||
+ struct sk_buff *skb, u16 hash,
|
||||
+ bool rx_wlan);
|
||||
} ops;
|
||||
|
||||
void *priv;
|
||||
@@ -27,6 +34,13 @@ static inline int airoha_ppe_dev_setup_t
|
||||
{
|
||||
return dev->ops.setup_tc_block_cb(dev, type_data);
|
||||
}
|
||||
+
|
||||
+static inline void airoha_ppe_dev_check_skb(struct airoha_ppe_dev *dev,
|
||||
+ struct sk_buff *skb,
|
||||
+ u16 hash, bool rx_wlan)
|
||||
+{
|
||||
+ dev->ops.check_skb(dev, skb, hash, rx_wlan);
|
||||
+}
|
||||
#else
|
||||
static inline struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
|
||||
{
|
||||
@@ -42,6 +56,12 @@ static inline int airoha_ppe_setup_tc_bl
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
+
|
||||
+static inline void airoha_ppe_dev_check_skb(struct airoha_ppe_dev *dev,
|
||||
+ struct sk_buff *skb, u16 hash,
|
||||
+ bool rx_wlan)
|
||||
+{
|
||||
+}
|
||||
#endif
|
||||
|
||||
#define NPU_NUM_CORES 8
|
||||
@ -1,50 +0,0 @@
|
||||
From 563fcd6475931c5c8c652a4dd548256314cc87ed Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Fri, 22 Aug 2025 14:14:18 +0200
|
||||
Subject: [PATCH] pinctrl: airoha: Fix return value in pinconf callbacks
|
||||
|
||||
Pinctrl stack requires ENOTSUPP error code if the parameter is not
|
||||
supported by the pinctrl driver. Fix the returned error code in pinconf
|
||||
callbacks if the operation is not supported.
|
||||
|
||||
Fixes: 1c8ace2d0725 ("pinctrl: airoha: Add support for EN7581 SoC")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://lore.kernel.org/20250822-airoha-pinconf-err-val-fix-v1-1-87b4f264ced2@kernel.org
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-airoha.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
@@ -2697,7 +2697,7 @@ static int airoha_pinconf_get(struct pin
|
||||
arg = 1;
|
||||
break;
|
||||
default:
|
||||
- return -EOPNOTSUPP;
|
||||
+ return -ENOTSUPP;
|
||||
}
|
||||
|
||||
*config = pinconf_to_config_packed(param, arg);
|
||||
@@ -2791,7 +2791,7 @@ static int airoha_pinconf_set(struct pin
|
||||
break;
|
||||
}
|
||||
default:
|
||||
- return -EOPNOTSUPP;
|
||||
+ return -ENOTSUPP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2808,10 +2808,10 @@ static int airoha_pinconf_group_get(stru
|
||||
if (airoha_pinconf_get(pctrl_dev,
|
||||
airoha_pinctrl_groups[group].pins[i],
|
||||
config))
|
||||
- return -EOPNOTSUPP;
|
||||
+ return -ENOTSUPP;
|
||||
|
||||
if (i && cur_config != *config)
|
||||
- return -EOPNOTSUPP;
|
||||
+ return -ENOTSUPP;
|
||||
|
||||
cur_config = *config;
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
From 17d4f2a9e6cb224012d85fed52e9794a84fa501d Mon Sep 17 00:00:00 2001
|
||||
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
|
||||
Date: Tue, 2 Sep 2025 13:59:13 +0200
|
||||
Subject: [PATCH 1/1] pinctrl: airoha: replace struct function_desc with struct
|
||||
pinfunction
|
||||
|
||||
struct function_desc is a wrapper around struct pinfunction with an
|
||||
additional void *data pointer. This driver doesn't use the data pointer.
|
||||
We're also working towards reducing the usage of struct function_desc in
|
||||
pinctrl drivers - they should only be created by pinmux core and
|
||||
accessed by drivers using pinmux_generic_get_function(). Replace the
|
||||
struct function_desc objects in this driver with smaller struct
|
||||
pinfunction instances.
|
||||
|
||||
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
|
||||
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-airoha.c | 15 +++++----------
|
||||
1 file changed, 5 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
@@ -35,13 +35,8 @@
|
||||
|
||||
#define PINCTRL_FUNC_DESC(id) \
|
||||
{ \
|
||||
- .desc = { \
|
||||
- .func = { \
|
||||
- .name = #id, \
|
||||
- .groups = id##_groups, \
|
||||
- .ngroups = ARRAY_SIZE(id##_groups), \
|
||||
- } \
|
||||
- }, \
|
||||
+ .desc = PINCTRL_PINFUNCTION(#id, id##_groups, \
|
||||
+ ARRAY_SIZE(id##_groups)), \
|
||||
.groups = id##_func_group, \
|
||||
.group_size = ARRAY_SIZE(id##_func_group), \
|
||||
}
|
||||
@@ -334,7 +329,7 @@ struct airoha_pinctrl_func_group {
|
||||
};
|
||||
|
||||
struct airoha_pinctrl_func {
|
||||
- const struct function_desc desc;
|
||||
+ const struct pinfunction desc;
|
||||
const struct airoha_pinctrl_func_group *groups;
|
||||
u8 group_size;
|
||||
};
|
||||
@@ -2911,13 +2906,13 @@ static int airoha_pinctrl_probe(struct p
|
||||
|
||||
func = &airoha_pinctrl_funcs[i];
|
||||
err = pinmux_generic_add_function(pinctrl->ctrl,
|
||||
- func->desc.func.name,
|
||||
- func->desc.func.groups,
|
||||
- func->desc.func.ngroups,
|
||||
+ func->desc.name,
|
||||
+ func->desc.groups,
|
||||
+ func->desc.ngroups,
|
||||
(void *)func);
|
||||
if (err < 0) {
|
||||
dev_err(dev, "Failed to register function %s\n",
|
||||
- func->desc.func.name);
|
||||
+ func->desc.name);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
From 7d0da8f862340c5f42f0062b8560b8d0971a6ac4 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 7 Jan 2025 23:26:28 +0100
|
||||
Subject: [PATCH] net: airoha: Fix channel configuration for ETS Qdisc
|
||||
|
||||
Limit ETS QoS channel to AIROHA_NUM_QOS_CHANNELS in
|
||||
airoha_tc_setup_qdisc_ets() in order to align the configured channel to
|
||||
the value set in airoha_dev_select_queue().
|
||||
|
||||
Fixes: 20bf7d07c956 ("net: airoha: Add sched ETS offload support")
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
|
||||
Link: https://patch.msgid.link/20250107-airoha-ets-fix-chan-v1-1-97f66ed3a068@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
|
||||
@@ -2204,11 +2204,14 @@ static int airoha_qdma_get_tx_ets_stats(
|
||||
static int airoha_tc_setup_qdisc_ets(struct airoha_gdm_port *port,
|
||||
struct tc_ets_qopt_offload *opt)
|
||||
{
|
||||
- int channel = TC_H_MAJ(opt->handle) >> 16;
|
||||
+ int channel;
|
||||
|
||||
if (opt->parent == TC_H_ROOT)
|
||||
return -EINVAL;
|
||||
|
||||
+ channel = TC_H_MAJ(opt->handle) >> 16;
|
||||
+ channel = channel % AIROHA_NUM_QOS_CHANNELS;
|
||||
+
|
||||
switch (opt->command) {
|
||||
case TC_ETS_REPLACE:
|
||||
return airoha_qdma_set_tx_ets_sched(port, channel, opt);
|
||||
@ -1,342 +0,0 @@
|
||||
From 67e3ba978361cb262f8f8981ab88ccb97f1e2bda Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Tue, 17 Jun 2025 11:16:53 +0200
|
||||
Subject: [PATCH] net: mdio: Add MDIO bus controller for Airoha AN7583
|
||||
|
||||
Airoha AN7583 SoC have 2 dedicated MDIO bus controller in the SCU
|
||||
register map. To driver register an MDIO controller based on the DT
|
||||
reg property and access the register by accessing the parent syscon.
|
||||
|
||||
The MDIO bus logic is similar to the MT7530 internal MDIO bus but
|
||||
deviates of some setting and some HW bug.
|
||||
|
||||
On Airoha AN7583 the MDIO clock is set to 25MHz by default and needs to
|
||||
be correctly setup to 2.5MHz to correctly work (by setting the divisor
|
||||
to 10x).
|
||||
|
||||
There seems to be Hardware bug where AN7583_MII_RWDATA
|
||||
is not wiped in the context of unconnected PHY and the
|
||||
previous read value is returned.
|
||||
|
||||
Example: (only one PHY on the BUS at 0x1f)
|
||||
- read at 0x1f report at 0x2 0x7500
|
||||
- read at 0x0 report 0x7500 on every address
|
||||
|
||||
To workaround this, we reset the Mdio BUS at every read
|
||||
to have consistent values on read operation.
|
||||
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/mdio/Kconfig | 7 +
|
||||
drivers/net/mdio/Makefile | 1 +
|
||||
drivers/net/mdio/mdio-airoha.c | 276 +++++++++++++++++++++++++++++++++
|
||||
3 files changed, 284 insertions(+)
|
||||
create mode 100644 drivers/net/mdio/mdio-airoha.c
|
||||
|
||||
--- a/drivers/net/mdio/Kconfig
|
||||
+++ b/drivers/net/mdio/Kconfig
|
||||
@@ -46,6 +46,13 @@ if MDIO_BUS
|
||||
config MDIO_DEVRES
|
||||
tristate
|
||||
|
||||
+config MDIO_AIROHA
|
||||
+ tristate "Airoha AN7583 MDIO bus controller"
|
||||
+ depends on ARCH_AIROHA || COMPILE_TEST
|
||||
+ help
|
||||
+ This module provides a driver for the MDIO busses found in the
|
||||
+ Airoha AN7583 SoC's.
|
||||
+
|
||||
config MDIO_SUN4I
|
||||
tristate "Allwinner sun4i MDIO interface support"
|
||||
depends on ARCH_SUNXI || COMPILE_TEST
|
||||
--- a/drivers/net/mdio/Makefile
|
||||
+++ b/drivers/net/mdio/Makefile
|
||||
@@ -5,6 +5,7 @@ obj-$(CONFIG_ACPI_MDIO) += acpi_mdio.o
|
||||
obj-$(CONFIG_FWNODE_MDIO) += fwnode_mdio.o
|
||||
obj-$(CONFIG_OF_MDIO) += of_mdio.o
|
||||
|
||||
+obj-$(CONFIG_MDIO_AIROHA) += mdio-airoha.o
|
||||
obj-$(CONFIG_MDIO_ASPEED) += mdio-aspeed.o
|
||||
obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o
|
||||
obj-$(CONFIG_MDIO_BCM_UNIMAC) += mdio-bcm-unimac.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/mdio/mdio-airoha.c
|
||||
@@ -0,0 +1,276 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/* Airoha AN7583 MDIO interface driver
|
||||
+ *
|
||||
+ * Copyright (C) 2025 Christian Marangi <ansuelsmth@gmail.com>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/clk.h>
|
||||
+#include <linux/delay.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/mfd/syscon.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/of_mdio.h>
|
||||
+#include <linux/of_address.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/regmap.h>
|
||||
+#include <linux/reset.h>
|
||||
+
|
||||
+/* MII address register definitions */
|
||||
+#define AN7583_MII_BUSY BIT(31)
|
||||
+#define AN7583_MII_RDY BIT(30) /* RO signal BUS is ready */
|
||||
+#define AN7583_MII_CL22_REG_ADDR GENMASK(29, 25)
|
||||
+#define AN7583_MII_CL45_DEV_ADDR AN7583_MII_CL22_REG_ADDR
|
||||
+#define AN7583_MII_PHY_ADDR GENMASK(24, 20)
|
||||
+#define AN7583_MII_CMD GENMASK(19, 18)
|
||||
+#define AN7583_MII_CMD_CL22_WRITE FIELD_PREP_CONST(AN7583_MII_CMD, 0x1)
|
||||
+#define AN7583_MII_CMD_CL22_READ FIELD_PREP_CONST(AN7583_MII_CMD, 0x2)
|
||||
+#define AN7583_MII_CMD_CL45_ADDR FIELD_PREP_CONST(AN7583_MII_CMD, 0x0)
|
||||
+#define AN7583_MII_CMD_CL45_WRITE FIELD_PREP_CONST(AN7583_MII_CMD, 0x1)
|
||||
+#define AN7583_MII_CMD_CL45_POSTREAD_INCADDR FIELD_PREP_CONST(AN7583_MII_CMD, 0x2)
|
||||
+#define AN7583_MII_CMD_CL45_READ FIELD_PREP_CONST(AN7583_MII_CMD, 0x3)
|
||||
+#define AN7583_MII_ST GENMASK(17, 16)
|
||||
+#define AN7583_MII_ST_CL45 FIELD_PREP_CONST(AN7583_MII_ST, 0x0)
|
||||
+#define AN7583_MII_ST_CL22 FIELD_PREP_CONST(AN7583_MII_ST, 0x1)
|
||||
+#define AN7583_MII_RWDATA GENMASK(15, 0)
|
||||
+#define AN7583_MII_CL45_REG_ADDR AN7583_MII_RWDATA
|
||||
+
|
||||
+#define AN7583_MII_MDIO_DELAY_USEC 100
|
||||
+#define AN7583_MII_MDIO_RETRY_MSEC 100
|
||||
+
|
||||
+struct airoha_mdio_data {
|
||||
+ u32 base_addr;
|
||||
+ struct regmap *regmap;
|
||||
+ struct clk *clk;
|
||||
+ struct reset_control *reset;
|
||||
+};
|
||||
+
|
||||
+static int airoha_mdio_wait_busy(struct airoha_mdio_data *priv)
|
||||
+{
|
||||
+ u32 busy;
|
||||
+
|
||||
+ return regmap_read_poll_timeout(priv->regmap, priv->base_addr, busy,
|
||||
+ !(busy & AN7583_MII_BUSY),
|
||||
+ AN7583_MII_MDIO_DELAY_USEC,
|
||||
+ AN7583_MII_MDIO_RETRY_MSEC * USEC_PER_MSEC);
|
||||
+}
|
||||
+
|
||||
+static void airoha_mdio_reset(struct airoha_mdio_data *priv)
|
||||
+{
|
||||
+ /* There seems to be Hardware bug where AN7583_MII_RWDATA
|
||||
+ * is not wiped in the context of unconnected PHY and the
|
||||
+ * previous read value is returned.
|
||||
+ *
|
||||
+ * Example: (only one PHY on the BUS at 0x1f)
|
||||
+ * - read at 0x1f report at 0x2 0x7500
|
||||
+ * - read at 0x0 report 0x7500 on every address
|
||||
+ *
|
||||
+ * To workaround this, we reset the Mdio BUS at every read
|
||||
+ * to have consistent values on read operation.
|
||||
+ */
|
||||
+ reset_control_assert(priv->reset);
|
||||
+ reset_control_deassert(priv->reset);
|
||||
+}
|
||||
+
|
||||
+static int airoha_mdio_read(struct mii_bus *bus, int addr, int regnum)
|
||||
+{
|
||||
+ struct airoha_mdio_data *priv = bus->priv;
|
||||
+ u32 val;
|
||||
+ int ret;
|
||||
+
|
||||
+ airoha_mdio_reset(priv);
|
||||
+
|
||||
+ val = AN7583_MII_BUSY | AN7583_MII_ST_CL22 |
|
||||
+ AN7583_MII_CMD_CL22_READ;
|
||||
+ val |= FIELD_PREP(AN7583_MII_PHY_ADDR, addr);
|
||||
+ val |= FIELD_PREP(AN7583_MII_CL22_REG_ADDR, regnum);
|
||||
+
|
||||
+ ret = regmap_write(priv->regmap, priv->base_addr, val);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = airoha_mdio_wait_busy(priv);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = regmap_read(priv->regmap, priv->base_addr, &val);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ return FIELD_GET(AN7583_MII_RWDATA, val);
|
||||
+}
|
||||
+
|
||||
+static int airoha_mdio_write(struct mii_bus *bus, int addr, int regnum,
|
||||
+ u16 value)
|
||||
+{
|
||||
+ struct airoha_mdio_data *priv = bus->priv;
|
||||
+ u32 val;
|
||||
+ int ret;
|
||||
+
|
||||
+ val = AN7583_MII_BUSY | AN7583_MII_ST_CL22 |
|
||||
+ AN7583_MII_CMD_CL22_WRITE;
|
||||
+ val |= FIELD_PREP(AN7583_MII_PHY_ADDR, addr);
|
||||
+ val |= FIELD_PREP(AN7583_MII_CL22_REG_ADDR, regnum);
|
||||
+ val |= FIELD_PREP(AN7583_MII_RWDATA, value);
|
||||
+
|
||||
+ ret = regmap_write(priv->regmap, priv->base_addr, val);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = airoha_mdio_wait_busy(priv);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int airoha_mdio_cl45_read(struct mii_bus *bus, int addr, int devnum,
|
||||
+ int regnum)
|
||||
+{
|
||||
+ struct airoha_mdio_data *priv = bus->priv;
|
||||
+ u32 val;
|
||||
+ int ret;
|
||||
+
|
||||
+ airoha_mdio_reset(priv);
|
||||
+
|
||||
+ val = AN7583_MII_BUSY | AN7583_MII_ST_CL45 |
|
||||
+ AN7583_MII_CMD_CL45_ADDR;
|
||||
+ val |= FIELD_PREP(AN7583_MII_PHY_ADDR, addr);
|
||||
+ val |= FIELD_PREP(AN7583_MII_CL45_DEV_ADDR, devnum);
|
||||
+ val |= FIELD_PREP(AN7583_MII_CL45_REG_ADDR, regnum);
|
||||
+
|
||||
+ ret = regmap_write(priv->regmap, priv->base_addr, val);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = airoha_mdio_wait_busy(priv);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ val = AN7583_MII_BUSY | AN7583_MII_ST_CL45 |
|
||||
+ AN7583_MII_CMD_CL45_READ;
|
||||
+ val |= FIELD_PREP(AN7583_MII_PHY_ADDR, addr);
|
||||
+ val |= FIELD_PREP(AN7583_MII_CL45_DEV_ADDR, devnum);
|
||||
+
|
||||
+ ret = regmap_write(priv->regmap, priv->base_addr, val);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = airoha_mdio_wait_busy(priv);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = regmap_read(priv->regmap, priv->base_addr, &val);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ return FIELD_GET(AN7583_MII_RWDATA, val);
|
||||
+}
|
||||
+
|
||||
+static int airoha_mdio_cl45_write(struct mii_bus *bus, int addr, int devnum,
|
||||
+ int regnum, u16 value)
|
||||
+{
|
||||
+ struct airoha_mdio_data *priv = bus->priv;
|
||||
+ u32 val;
|
||||
+ int ret;
|
||||
+
|
||||
+ val = AN7583_MII_BUSY | AN7583_MII_ST_CL45 |
|
||||
+ AN7583_MII_CMD_CL45_ADDR;
|
||||
+ val |= FIELD_PREP(AN7583_MII_PHY_ADDR, addr);
|
||||
+ val |= FIELD_PREP(AN7583_MII_CL45_DEV_ADDR, devnum);
|
||||
+ val |= FIELD_PREP(AN7583_MII_CL45_REG_ADDR, regnum);
|
||||
+
|
||||
+ ret = regmap_write(priv->regmap, priv->base_addr, val);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = airoha_mdio_wait_busy(priv);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ val = AN7583_MII_BUSY | AN7583_MII_ST_CL45 |
|
||||
+ AN7583_MII_CMD_CL45_WRITE;
|
||||
+ val |= FIELD_PREP(AN7583_MII_PHY_ADDR, addr);
|
||||
+ val |= FIELD_PREP(AN7583_MII_CL45_DEV_ADDR, devnum);
|
||||
+ val |= FIELD_PREP(AN7583_MII_RWDATA, value);
|
||||
+
|
||||
+ ret = regmap_write(priv->regmap, priv->base_addr, val);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = airoha_mdio_wait_busy(priv);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int airoha_mdio_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct airoha_mdio_data *priv;
|
||||
+ struct mii_bus *bus;
|
||||
+ u32 addr, freq;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = of_property_read_u32(dev->of_node, "reg", &addr);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ bus = devm_mdiobus_alloc_size(dev, sizeof(*priv));
|
||||
+ if (!bus)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ priv = bus->priv;
|
||||
+ priv->base_addr = addr;
|
||||
+ priv->regmap = device_node_to_regmap(dev->parent->of_node);
|
||||
+
|
||||
+ priv->clk = devm_clk_get_enabled(dev, NULL);
|
||||
+ if (IS_ERR(priv->clk))
|
||||
+ return PTR_ERR(priv->clk);
|
||||
+
|
||||
+ priv->reset = devm_reset_control_get_exclusive(dev, NULL);
|
||||
+ if (IS_ERR(priv->reset))
|
||||
+ return PTR_ERR(priv->reset);
|
||||
+
|
||||
+ reset_control_deassert(priv->reset);
|
||||
+
|
||||
+ bus->name = "airoha_mdio_bus";
|
||||
+ snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(dev));
|
||||
+ bus->parent = dev;
|
||||
+ bus->read = airoha_mdio_read;
|
||||
+ bus->write = airoha_mdio_write;
|
||||
+ bus->read_c45 = airoha_mdio_cl45_read;
|
||||
+ bus->write_c45 = airoha_mdio_cl45_write;
|
||||
+
|
||||
+ /* Check if a custom frequency is defined in DT or default to 2.5 MHz */
|
||||
+ if (of_property_read_u32(dev->of_node, "clock-frequency", &freq))
|
||||
+ freq = 2500000;
|
||||
+
|
||||
+ ret = clk_set_rate(priv->clk, freq);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = devm_of_mdiobus_register(dev, bus, dev->of_node);
|
||||
+ if (ret) {
|
||||
+ reset_control_assert(priv->reset);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id airoha_mdio_dt_ids[] = {
|
||||
+ { .compatible = "airoha,an7583-mdio" },
|
||||
+ { }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, airoha_mdio_dt_ids);
|
||||
+
|
||||
+static struct platform_driver airoha_mdio_driver = {
|
||||
+ .probe = airoha_mdio_probe,
|
||||
+ .driver = {
|
||||
+ .name = "airoha-mdio",
|
||||
+ .of_match_table = airoha_mdio_dt_ids,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(airoha_mdio_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("Airoha AN7583 MDIO interface driver");
|
||||
+MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
|
||||
+MODULE_LICENSE("GPL");
|
||||
@ -1,68 +0,0 @@
|
||||
From af87d38c442c75a40c7d0a7d8c31557e2e6ccf98 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Sun, 25 May 2025 20:22:40 +0200
|
||||
Subject: [PATCH 1/2] pinctrl: airoha: fix wrong PHY LED mux value for LED1
|
||||
GPIO46
|
||||
|
||||
In all the MUX value for LED1 GPIO46 there is a Copy-Paste error where
|
||||
the MUX value is set to LED0_MODE_MASK instead of LED1_MODE_MASK.
|
||||
|
||||
This wasn't notice as there were no board that made use of the
|
||||
secondary PHY LED but looking at the internal Documentation the actual
|
||||
value should be LED1_MODE_MASK similar to the other GPIO entry.
|
||||
|
||||
Fix the wrong value to apply the correct MUX configuration.
|
||||
|
||||
Cc: stable@vger.kernel.org
|
||||
Fixes: 1c8ace2d0725 ("pinctrl: airoha: Add support for EN7581 SoC")
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-airoha.c | 16 ++++++++--------
|
||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
@@ -1747,8 +1747,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[0] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_GPIO_2ND_I2C_MODE,
|
||||
- GPIO_LAN3_LED0_MODE_MASK,
|
||||
- GPIO_LAN3_LED0_MODE_MASK
|
||||
+ GPIO_LAN3_LED1_MODE_MASK,
|
||||
+ GPIO_LAN3_LED1_MODE_MASK
|
||||
},
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
@@ -1811,8 +1811,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[0] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_GPIO_2ND_I2C_MODE,
|
||||
- GPIO_LAN3_LED0_MODE_MASK,
|
||||
- GPIO_LAN3_LED0_MODE_MASK
|
||||
+ GPIO_LAN3_LED1_MODE_MASK,
|
||||
+ GPIO_LAN3_LED1_MODE_MASK
|
||||
},
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
@@ -1875,8 +1875,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[0] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_GPIO_2ND_I2C_MODE,
|
||||
- GPIO_LAN3_LED0_MODE_MASK,
|
||||
- GPIO_LAN3_LED0_MODE_MASK
|
||||
+ GPIO_LAN3_LED1_MODE_MASK,
|
||||
+ GPIO_LAN3_LED1_MODE_MASK
|
||||
},
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
@@ -1939,8 +1939,8 @@ static const struct airoha_pinctrl_func_
|
||||
.regmap[0] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
REG_GPIO_2ND_I2C_MODE,
|
||||
- GPIO_LAN3_LED0_MODE_MASK,
|
||||
- GPIO_LAN3_LED0_MODE_MASK
|
||||
+ GPIO_LAN3_LED1_MODE_MASK,
|
||||
+ GPIO_LAN3_LED1_MODE_MASK
|
||||
},
|
||||
.regmap[1] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
@ -1,58 +0,0 @@
|
||||
From 110930eb12699b92f767fc599c7ab467dd42358a Mon Sep 17 00:00:00 2001
|
||||
From: Christian Marangi <ansuelsmth@gmail.com>
|
||||
Date: Tue, 8 Jul 2025 14:49:56 +0200
|
||||
Subject: [PATCH 2/2] pinctrl: airoha: fix wrong MDIO function bitmaks
|
||||
|
||||
With further testing with an attached Aeonsemi it was discovered that
|
||||
the pinctrl MDIO function applied the wrong bitmask. The error was
|
||||
probably caused by the confusing documentation related to these bits.
|
||||
|
||||
Inspecting what the bootloader actually configure, the SGMII_MDIO_MODE
|
||||
is never actually set but instead it's set force enable to the 2 GPIO
|
||||
(gpio 1-2) for MDC and MDIO pin.
|
||||
|
||||
Applying this configuration permits correct functionality of any
|
||||
externally attached PHY.
|
||||
|
||||
Cc: stable@vger.kernel.org
|
||||
Fixes: 1c8ace2d0725 ("pinctrl: airoha: Add support for EN7581 SoC")
|
||||
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-airoha.c | 15 +++++++++------
|
||||
1 file changed, 9 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
|
||||
@@ -103,6 +103,9 @@
|
||||
#define JTAG_UDI_EN_MASK BIT(4)
|
||||
#define JTAG_DFD_EN_MASK BIT(3)
|
||||
|
||||
+#define REG_FORCE_GPIO_EN 0x0228
|
||||
+#define FORCE_GPIO_EN(n) BIT(n)
|
||||
+
|
||||
/* LED MAP */
|
||||
#define REG_LAN_LED0_MAPPING 0x027c
|
||||
#define REG_LAN_LED1_MAPPING 0x0280
|
||||
@@ -714,16 +717,16 @@ static const struct airoha_pinctrl_func_
|
||||
.name = "mdio",
|
||||
.regmap[0] = {
|
||||
AIROHA_FUNC_MUX,
|
||||
- REG_GPIO_PON_MODE,
|
||||
- GPIO_SGMII_MDIO_MODE_MASK,
|
||||
- GPIO_SGMII_MDIO_MODE_MASK
|
||||
- },
|
||||
- .regmap[1] = {
|
||||
- AIROHA_FUNC_MUX,
|
||||
REG_GPIO_2ND_I2C_MODE,
|
||||
GPIO_MDC_IO_MASTER_MODE_MODE,
|
||||
GPIO_MDC_IO_MASTER_MODE_MODE
|
||||
},
|
||||
+ .regmap[1] = {
|
||||
+ AIROHA_FUNC_MUX,
|
||||
+ REG_FORCE_GPIO_EN,
|
||||
+ FORCE_GPIO_EN(1) | FORCE_GPIO_EN(2),
|
||||
+ FORCE_GPIO_EN(1) | FORCE_GPIO_EN(2)
|
||||
+ },
|
||||
.regmap_size = 2,
|
||||
},
|
||||
};
|
||||
@ -1,45 +0,0 @@
|
||||
From 09630ab91d840416b0178f3660afa4eebce24286 Mon Sep 17 00:00:00 2001
|
||||
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
|
||||
Date: Mon, 22 Sep 2025 16:08:21 +0200
|
||||
Subject: [PATCH] net: airoha: Avoid -Wflex-array-member-not-at-end warning
|
||||
|
||||
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
|
||||
getting ready to enable it, globally.
|
||||
|
||||
Move the conflicting declaration to the end of the corresponding
|
||||
structure. Notice that `struct airoha_foe_entry` is a flexible
|
||||
structure, this is a structure that contains a flexible-array
|
||||
member.
|
||||
|
||||
Fix the following warning:
|
||||
|
||||
drivers/net/ethernet/airoha/airoha_eth.h:474:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
|
||||
|
||||
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/aNFYVYLXQDqm4yxb@kspp
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_eth.h | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
|
||||
@@ -471,7 +471,6 @@ struct airoha_flow_table_entry {
|
||||
};
|
||||
};
|
||||
|
||||
- struct airoha_foe_entry data;
|
||||
struct hlist_node l2_subflow_node; /* PPE L2 subflow entry */
|
||||
u32 hash;
|
||||
|
||||
@@ -480,6 +479,9 @@ struct airoha_flow_table_entry {
|
||||
|
||||
struct rhash_head node;
|
||||
unsigned long cookie;
|
||||
+
|
||||
+ /* Must be last --ends in a flexible-array member. */
|
||||
+ struct airoha_foe_entry data;
|
||||
};
|
||||
|
||||
struct airoha_wdma_info {
|
||||
@ -1,29 +0,0 @@
|
||||
From e156dd6b856fa462430d875b0d4cd281ecd66c23 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 18 Sep 2025 08:59:41 +0200
|
||||
Subject: [PATCH] net: airoha: Fix PPE_IP_PROTO_CHK register definitions
|
||||
|
||||
Fix typo in PPE_IP_PROTO_CHK_IPV4_MASK and PPE_IP_PROTO_CHK_IPV6_MASK
|
||||
register mask definitions. This is not a real problem since this
|
||||
register is not actually used in the current codebase.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_regs.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
|
||||
@@ -237,8 +237,8 @@
|
||||
#define PPE_FLOW_CFG_IP4_TCP_FRAG_MASK BIT(6)
|
||||
|
||||
#define REG_PPE_IP_PROTO_CHK(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x208)
|
||||
-#define PPE_IP_PROTO_CHK_IPV4_MASK GENMASK(15, 0)
|
||||
-#define PPE_IP_PROTO_CHK_IPV6_MASK GENMASK(31, 16)
|
||||
+#define PPE_IP_PROTO_CHK_IPV4_MASK GENMASK(31, 16)
|
||||
+#define PPE_IP_PROTO_CHK_IPV6_MASK GENMASK(15, 0)
|
||||
|
||||
#define REG_PPE_TB_CFG(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x21c)
|
||||
#define PPE_SRAM_TB_NUM_ENTRY_MASK GENMASK(26, 24)
|
||||
@ -1,159 +0,0 @@
|
||||
From 105ce7ad57e492b75ab40f2dc591db645fadbaa2 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 24 Sep 2025 23:14:53 +0200
|
||||
Subject: [PATCH] net: airoha: npu: Add a NPU callback to initialize flow stats
|
||||
|
||||
Introduce a NPU callback to initialize flow stats and remove NPU stats
|
||||
initialization from airoha_npu_get routine. Add num_stats_entries to
|
||||
airoha_npu_ppe_stats_setup routine.
|
||||
This patch makes the code more readable since NPU statistic are now
|
||||
initialized on demand by the NPU consumer (at the moment NPU statistic
|
||||
are configured just by the airoha_eth driver).
|
||||
Moreover this patch allows the NPU consumer (PPE module) to explicitly
|
||||
enable/disable NPU flow stats.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20250924-airoha-npu-init-stats-callback-v1-1-88bdf3c941b2@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/airoha/airoha_npu.c | 24 ++++++-----------------
|
||||
drivers/net/ethernet/airoha/airoha_ppe.c | 19 ++++++++++++------
|
||||
include/linux/soc/airoha/airoha_offload.h | 7 ++++---
|
||||
3 files changed, 23 insertions(+), 27 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
|
||||
@@ -379,15 +379,13 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
-static int airoha_npu_stats_setup(struct airoha_npu *npu,
|
||||
- dma_addr_t foe_stats_addr)
|
||||
+static int airoha_npu_ppe_stats_setup(struct airoha_npu *npu,
|
||||
+ dma_addr_t foe_stats_addr,
|
||||
+ u32 num_stats_entries)
|
||||
{
|
||||
- int err, size = PPE_STATS_NUM_ENTRIES * sizeof(*npu->stats);
|
||||
+ int err, size = num_stats_entries * sizeof(*npu->stats);
|
||||
struct ppe_mbox_data *ppe_data;
|
||||
|
||||
- if (!size) /* flow stats are disabled */
|
||||
- return 0;
|
||||
-
|
||||
ppe_data = kzalloc(sizeof(*ppe_data), GFP_ATOMIC);
|
||||
if (!ppe_data)
|
||||
return -ENOMEM;
|
||||
@@ -542,7 +540,7 @@ static void airoha_npu_wlan_irq_disable(
|
||||
regmap_clear_bits(npu->regmap, REG_IRQ_RXDONE(q), NPU_IRQ_RX_MASK(q));
|
||||
}
|
||||
|
||||
-struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
|
||||
+struct airoha_npu *airoha_npu_get(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev;
|
||||
struct device_node *np;
|
||||
@@ -580,17 +578,6 @@ struct airoha_npu *airoha_npu_get(struct
|
||||
goto error_module_put;
|
||||
}
|
||||
|
||||
- if (stats_addr) {
|
||||
- int err;
|
||||
-
|
||||
- err = airoha_npu_stats_setup(npu, *stats_addr);
|
||||
- if (err) {
|
||||
- dev_err(dev, "failed to allocate npu stats buffer\n");
|
||||
- npu = ERR_PTR(err);
|
||||
- goto error_module_put;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
return npu;
|
||||
|
||||
error_module_put:
|
||||
@@ -643,6 +630,7 @@ static int airoha_npu_probe(struct platf
|
||||
npu->dev = dev;
|
||||
npu->ops.ppe_init = airoha_npu_ppe_init;
|
||||
npu->ops.ppe_deinit = airoha_npu_ppe_deinit;
|
||||
+ npu->ops.ppe_init_stats = airoha_npu_ppe_stats_setup;
|
||||
npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries;
|
||||
npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry;
|
||||
npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory;
|
||||
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
|
||||
@@ -1243,12 +1243,11 @@ static int airoha_ppe_flush_sram_entries
|
||||
|
||||
static struct airoha_npu *airoha_ppe_npu_get(struct airoha_eth *eth)
|
||||
{
|
||||
- struct airoha_npu *npu = airoha_npu_get(eth->dev,
|
||||
- ð->ppe->foe_stats_dma);
|
||||
+ struct airoha_npu *npu = airoha_npu_get(eth->dev);
|
||||
|
||||
if (IS_ERR(npu)) {
|
||||
request_module("airoha-npu");
|
||||
- npu = airoha_npu_get(eth->dev, ð->ppe->foe_stats_dma);
|
||||
+ npu = airoha_npu_get(eth->dev);
|
||||
}
|
||||
|
||||
return npu;
|
||||
@@ -1257,6 +1256,7 @@ static struct airoha_npu *airoha_ppe_npu
|
||||
static int airoha_ppe_offload_setup(struct airoha_eth *eth)
|
||||
{
|
||||
struct airoha_npu *npu = airoha_ppe_npu_get(eth);
|
||||
+ struct airoha_ppe *ppe = eth->ppe;
|
||||
int err;
|
||||
|
||||
if (IS_ERR(npu))
|
||||
@@ -1266,12 +1266,19 @@ static int airoha_ppe_offload_setup(stru
|
||||
if (err)
|
||||
goto error_npu_put;
|
||||
|
||||
- airoha_ppe_hw_init(eth->ppe);
|
||||
- err = airoha_ppe_flush_sram_entries(eth->ppe, npu);
|
||||
+ if (PPE_STATS_NUM_ENTRIES) {
|
||||
+ err = npu->ops.ppe_init_stats(npu, ppe->foe_stats_dma,
|
||||
+ PPE_STATS_NUM_ENTRIES);
|
||||
+ if (err)
|
||||
+ goto error_npu_put;
|
||||
+ }
|
||||
+
|
||||
+ airoha_ppe_hw_init(ppe);
|
||||
+ err = airoha_ppe_flush_sram_entries(ppe, npu);
|
||||
if (err)
|
||||
goto error_npu_put;
|
||||
|
||||
- airoha_ppe_foe_flow_stats_reset(eth->ppe, npu);
|
||||
+ airoha_ppe_foe_flow_stats_reset(ppe, npu);
|
||||
|
||||
rcu_assign_pointer(eth->npu, npu);
|
||||
synchronize_rcu();
|
||||
--- a/include/linux/soc/airoha/airoha_offload.h
|
||||
+++ b/include/linux/soc/airoha/airoha_offload.h
|
||||
@@ -181,6 +181,8 @@ struct airoha_npu {
|
||||
struct {
|
||||
int (*ppe_init)(struct airoha_npu *npu);
|
||||
int (*ppe_deinit)(struct airoha_npu *npu);
|
||||
+ int (*ppe_init_stats)(struct airoha_npu *npu,
|
||||
+ dma_addr_t addr, u32 num_stats_entries);
|
||||
int (*ppe_flush_sram_entries)(struct airoha_npu *npu,
|
||||
dma_addr_t foe_addr,
|
||||
int sram_num_entries);
|
||||
@@ -206,7 +208,7 @@ struct airoha_npu {
|
||||
};
|
||||
|
||||
#if (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU))
|
||||
-struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr);
|
||||
+struct airoha_npu *airoha_npu_get(struct device *dev);
|
||||
void airoha_npu_put(struct airoha_npu *npu);
|
||||
|
||||
static inline int airoha_npu_wlan_init_reserved_memory(struct airoha_npu *npu)
|
||||
@@ -256,8 +258,7 @@ static inline void airoha_npu_wlan_disab
|
||||
npu->ops.wlan_disable_irq(npu, q);
|
||||
}
|
||||
#else
|
||||
-static inline struct airoha_npu *airoha_npu_get(struct device *dev,
|
||||
- dma_addr_t *foe_stats_addr)
|
||||
+static inline struct airoha_npu *airoha_npu_get(struct device *dev)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user