Skip to content

Commit 23bcea0

Browse files
committed
airoha: rework and backport for multi-serdes prep
Backport additional upstream patch in preparation for multi-serdes and proper PCS support. Automatically refresh all affected patch. (cherry picked from commit 25de258) Link: openwrt/openwrt#22820 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1 parent c685890 commit 23bcea0

7 files changed

Lines changed: 345 additions & 18 deletions
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
From df8e1e4a2eb5f8ecdef36c502601e8afbc6ad891 Mon Sep 17 00:00:00 2001
2+
From: Lorenzo Bianconi <lorenzo@kernel.org>
3+
Date: Wed, 24 Dec 2025 17:29:33 +0100
4+
Subject: [PATCH] net: airoha: Reset PPE default cput port in
5+
airoha_ppe_hw_init()
6+
7+
Before this patch the default PPE cpu port used for a specific GDM
8+
device was set running ndo_init() callback during device initialization.
9+
The selected PPE cpu port configured for the specific GDM device depends
10+
on the QDMA block assigned to the GDM device. The selected QDMA block
11+
depends on LAN/WAN configuration as specified in commmit XXXX.
12+
However, the user selected PPE cpu port can be different with respect to
13+
the one hardcoded in the NPU firmware binary. The hardcoded PPE cput port
14+
value is loaded initializing the PPE engine running npu ops ppe_init()
15+
callback in airoha_ppe_offload_setup routine.
16+
Reset the default value for PPE cpu ports in airoha_ppe_hw_init routine
17+
in order to apply the user requested configuration according to the device
18+
DTS setup.
19+
Please note this patch is fixing an issue not visible to the user (so we
20+
do not need to backport it) since airoha_eth driver currently supports just
21+
the internal phy available via the MT7530 DSA switch and there are no WAN
22+
interfaces officially supporte since PCS/external phy is not merged mainline
23+
yet (it will be posted with following patches).
24+
25+
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
26+
---
27+
drivers/net/ethernet/airoha/airoha_eth.c | 28 +++++------------------
28+
drivers/net/ethernet/airoha/airoha_eth.h | 2 ++
29+
drivers/net/ethernet/airoha/airoha_ppe.c | 23 ++++++++++++++++++-
30+
drivers/net/ethernet/airoha/airoha_regs.h | 7 +++---
31+
4 files changed, 33 insertions(+), 27 deletions(-)
32+
33+
--- a/drivers/net/ethernet/airoha/airoha_eth.c
34+
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
35+
@@ -1755,8 +1755,7 @@ static int airoha_dev_init(struct net_de
36+
{
37+
struct airoha_gdm_port *port = netdev_priv(dev);
38+
struct airoha_eth *eth = port->eth;
39+
- u32 fe_cpu_port;
40+
- u8 ppe_id;
41+
+ int i;
42+
43+
/* QDMA0 is used for lan ports while QDMA1 is used for WAN ports */
44+
port->qdma = &eth->qdma[!airoha_is_lan_gdm_port(port)];
45+
@@ -1774,28 +1773,13 @@ static int airoha_dev_init(struct net_de
46+
if (err)
47+
return err;
48+
}
49+
- fallthrough;
50+
- case AIROHA_GDM2_IDX:
51+
- if (airoha_ppe_is_enabled(eth, 1)) {
52+
- /* For PPE2 always use secondary cpu port. */
53+
- fe_cpu_port = FE_PSE_PORT_CDM2;
54+
- ppe_id = 1;
55+
- break;
56+
- }
57+
- fallthrough;
58+
- default: {
59+
- u8 qdma_id = port->qdma - &eth->qdma[0];
60+
-
61+
- /* For PPE1 select cpu port according to the running QDMA. */
62+
- fe_cpu_port = qdma_id ? FE_PSE_PORT_CDM2 : FE_PSE_PORT_CDM1;
63+
- ppe_id = 0;
64+
break;
65+
- }
66+
+ default:
67+
+ break;
68+
}
69+
70+
- airoha_fe_rmw(eth, REG_PPE_DFT_CPORT0(ppe_id),
71+
- DFT_CPORT_MASK(port->id),
72+
- __field_prep(DFT_CPORT_MASK(port->id), fe_cpu_port));
73+
+ for (i = 0; i < eth->soc->num_ppe; i++)
74+
+ airoha_ppe_set_cpu_port(port, i);
75+
76+
return 0;
77+
}
78+
@@ -1898,7 +1882,7 @@ static u32 airoha_get_dsa_tag(struct sk_
79+
#endif
80+
}
81+
82+
-static int airoha_get_fe_port(struct airoha_gdm_port *port)
83+
+int airoha_get_fe_port(struct airoha_gdm_port *port)
84+
{
85+
struct airoha_qdma *qdma = port->qdma;
86+
struct airoha_eth *eth = qdma->eth;
87+
--- a/drivers/net/ethernet/airoha/airoha_eth.h
88+
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
89+
@@ -646,9 +646,11 @@ static inline bool airoha_is_7583(struct
90+
return eth->soc->version == 0x7583;
91+
}
92+
93+
+int airoha_get_fe_port(struct airoha_gdm_port *port);
94+
bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
95+
struct airoha_gdm_port *port);
96+
97+
+void airoha_ppe_set_cpu_port(struct airoha_gdm_port *port, u8 ppe_id);
98+
bool airoha_ppe_is_enabled(struct airoha_eth *eth, int index);
99+
void airoha_ppe_check_skb(struct airoha_ppe_dev *dev, struct sk_buff *skb,
100+
u16 hash, bool rx_wlan);
101+
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
102+
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
103+
@@ -85,6 +85,20 @@ static u32 airoha_ppe_get_timestamp(stru
104+
return FIELD_GET(AIROHA_FOE_IB1_BIND_TIMESTAMP, timestamp);
105+
}
106+
107+
+void airoha_ppe_set_cpu_port(struct airoha_gdm_port *port, u8 ppe_id)
108+
+{
109+
+ struct airoha_qdma *qdma = port->qdma;
110+
+ u8 fport = airoha_get_fe_port(port);
111+
+ struct airoha_eth *eth = qdma->eth;
112+
+ u8 qdma_id = qdma - &eth->qdma[0];
113+
+ u32 fe_cpu_port;
114+
+
115+
+ fe_cpu_port = qdma_id ? FE_PSE_PORT_CDM2 : FE_PSE_PORT_CDM1;
116+
+ airoha_fe_rmw(eth, REG_PPE_DFT_CPORT(ppe_id, fport),
117+
+ DFT_CPORT_MASK(fport),
118+
+ __field_prep(DFT_CPORT_MASK(fport), fe_cpu_port));
119+
+}
120+
+
121+
static void airoha_ppe_hw_init(struct airoha_ppe *ppe)
122+
{
123+
u32 sram_ppe_num_data_entries = PPE_SRAM_NUM_ENTRIES, sram_num_entries;
124+
@@ -147,7 +161,9 @@ static void airoha_ppe_hw_init(struct ai
125+
126+
airoha_fe_wr(eth, REG_PPE_HASH_SEED(i), PPE_HASH_SEED);
127+
128+
- for (p = 0; p < ARRAY_SIZE(eth->ports); p++)
129+
+ for (p = 0; p < ARRAY_SIZE(eth->ports); p++) {
130+
+ struct airoha_gdm_port *port = eth->ports[p];
131+
+
132+
airoha_fe_rmw(eth, REG_PPE_MTU(i, p),
133+
FP0_EGRESS_MTU_MASK |
134+
FP1_EGRESS_MTU_MASK,
135+
@@ -155,6 +171,11 @@ static void airoha_ppe_hw_init(struct ai
136+
AIROHA_MAX_MTU) |
137+
FIELD_PREP(FP1_EGRESS_MTU_MASK,
138+
AIROHA_MAX_MTU));
139+
+ if (!port)
140+
+ continue;
141+
+
142+
+ airoha_ppe_set_cpu_port(port, i);
143+
+ }
144+
}
145+
}
146+
147+
--- a/drivers/net/ethernet/airoha/airoha_regs.h
148+
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
149+
@@ -312,10 +312,9 @@
150+
#define REG_PPE_HASH_SEED(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x244)
151+
#define PPE_HASH_SEED 0x12345678
152+
153+
-#define REG_PPE_DFT_CPORT0(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x248)
154+
-#define DFT_CPORT_MASK(_n) GENMASK(3 + ((_n) << 2), ((_n) << 2))
155+
-
156+
-#define REG_PPE_DFT_CPORT1(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x24c)
157+
+#define REG_PPE_DFT_CPORT_BASE(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x248)
158+
+#define REG_PPE_DFT_CPORT(_m, _n) (REG_PPE_DFT_CPORT_BASE(_m) + (((_n) / 8) << 2))
159+
+#define DFT_CPORT_MASK(_n) GENMASK(3 + (((_n) % 8) << 2), (((_n) % 8) << 2))
160+
161+
#define REG_PPE_TB_HASH_CFG(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x250)
162+
#define PPE_DRAM_HASH1_MODE_MASK GENMASK(31, 28)
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
From b1c803d5c8167026791abfaed96fd3e6a1fcd750 Mon Sep 17 00:00:00 2001
2+
From: Lorenzo Bianconi <lorenzo@kernel.org>
3+
Date: Sat, 21 Mar 2026 15:41:44 +0100
4+
Subject: [PATCH] net: airoha: Rework the code flow in airoha_remove() and in
5+
airoha_probe() error path
6+
7+
As suggested by Simon in [0], rework the code flow in airoha_remove()
8+
and in the airoha_probe() error path in order to rely on a more common
9+
approach un-registering configured net-devices first and destroying the
10+
hw resources at the end of the code.
11+
Introduce airoha_qdma_cleanup routine to release QDMA resources.
12+
13+
[0] https://lore.kernel.org/netdev/20251214-airoha-fix-dev-registration-v1-1-860e027ad4c6@kernel.org/
14+
15+
Suggested-by: Simon Horman <horms@kernel.org>
16+
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
17+
Reviewed-by: Simon Horman <horms@kernel.org>
18+
Link: https://patch.msgid.link/20260321-airoha-remove-rework-v2-1-16c7bade5fe5@kernel.org
19+
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
20+
---
21+
drivers/net/ethernet/airoha/airoha_eth.c | 76 ++++++++++++++----------
22+
1 file changed, 44 insertions(+), 32 deletions(-)
23+
24+
--- a/drivers/net/ethernet/airoha/airoha_eth.c
25+
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
26+
@@ -1368,6 +1368,33 @@ static int airoha_qdma_init(struct platf
27+
return airoha_qdma_hw_init(qdma);
28+
}
29+
30+
+static void airoha_qdma_cleanup(struct airoha_qdma *qdma)
31+
+{
32+
+ int i;
33+
+
34+
+ for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
35+
+ if (!qdma->q_rx[i].ndesc)
36+
+ continue;
37+
+
38+
+ netif_napi_del(&qdma->q_rx[i].napi);
39+
+ airoha_qdma_cleanup_rx_queue(&qdma->q_rx[i]);
40+
+ if (qdma->q_rx[i].page_pool) {
41+
+ page_pool_destroy(qdma->q_rx[i].page_pool);
42+
+ qdma->q_rx[i].page_pool = NULL;
43+
+ }
44+
+ }
45+
+
46+
+ for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
47+
+ netif_napi_del(&qdma->q_tx_irq[i].napi);
48+
+
49+
+ for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
50+
+ if (!qdma->q_tx[i].ndesc)
51+
+ continue;
52+
+
53+
+ airoha_qdma_cleanup_tx_queue(&qdma->q_tx[i]);
54+
+ }
55+
+}
56+
+
57+
static int airoha_hw_init(struct platform_device *pdev,
58+
struct airoha_eth *eth)
59+
{
60+
@@ -1395,41 +1422,30 @@ static int airoha_hw_init(struct platfor
61+
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) {
62+
err = airoha_qdma_init(pdev, eth, &eth->qdma[i]);
63+
if (err)
64+
- return err;
65+
+ goto error;
66+
}
67+
68+
err = airoha_ppe_init(eth);
69+
if (err)
70+
- return err;
71+
+ goto error;
72+
73+
set_bit(DEV_STATE_INITIALIZED, &eth->state);
74+
75+
return 0;
76+
+error:
77+
+ for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
78+
+ airoha_qdma_cleanup(&eth->qdma[i]);
79+
+
80+
+ return err;
81+
}
82+
83+
-static void airoha_hw_cleanup(struct airoha_qdma *qdma)
84+
+static void airoha_hw_cleanup(struct airoha_eth *eth)
85+
{
86+
int i;
87+
88+
- for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
89+
- if (!qdma->q_rx[i].ndesc)
90+
- continue;
91+
-
92+
- netif_napi_del(&qdma->q_rx[i].napi);
93+
- airoha_qdma_cleanup_rx_queue(&qdma->q_rx[i]);
94+
- if (qdma->q_rx[i].page_pool)
95+
- page_pool_destroy(qdma->q_rx[i].page_pool);
96+
- }
97+
-
98+
- for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
99+
- netif_napi_del(&qdma->q_tx_irq[i].napi);
100+
-
101+
- for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
102+
- if (!qdma->q_tx[i].ndesc)
103+
- continue;
104+
-
105+
- airoha_qdma_cleanup_tx_queue(&qdma->q_tx[i]);
106+
- }
107+
+ for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
108+
+ airoha_qdma_cleanup(&eth->qdma[i]);
109+
+ airoha_ppe_deinit(eth);
110+
}
111+
112+
static void airoha_qdma_start_napi(struct airoha_qdma *qdma)
113+
@@ -3012,7 +3028,7 @@ static int airoha_probe(struct platform_
114+
115+
err = airoha_hw_init(pdev, eth);
116+
if (err)
117+
- goto error_hw_cleanup;
118+
+ goto error_netdev_free;
119+
120+
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
121+
airoha_qdma_start_napi(&eth->qdma[i]);
122+
@@ -3040,10 +3056,6 @@ static int airoha_probe(struct platform_
123+
error_napi_stop:
124+
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
125+
airoha_qdma_stop_napi(&eth->qdma[i]);
126+
- airoha_ppe_deinit(eth);
127+
-error_hw_cleanup:
128+
- for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
129+
- airoha_hw_cleanup(&eth->qdma[i]);
130+
131+
for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
132+
struct airoha_gdm_port *port = eth->ports[i];
133+
@@ -3055,6 +3067,8 @@ error_hw_cleanup:
134+
unregister_netdev(port->dev);
135+
airoha_metadata_dst_free(port);
136+
}
137+
+ airoha_hw_cleanup(eth);
138+
+error_netdev_free:
139+
free_netdev(eth->napi_dev);
140+
platform_set_drvdata(pdev, NULL);
141+
142+
@@ -3066,10 +3080,8 @@ static void airoha_remove(struct platfor
143+
struct airoha_eth *eth = platform_get_drvdata(pdev);
144+
int i;
145+
146+
- for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) {
147+
+ for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
148+
airoha_qdma_stop_napi(&eth->qdma[i]);
149+
- airoha_hw_cleanup(&eth->qdma[i]);
150+
- }
151+
152+
for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
153+
struct airoha_gdm_port *port = eth->ports[i];
154+
@@ -3080,9 +3092,9 @@ static void airoha_remove(struct platfor
155+
unregister_netdev(port->dev);
156+
airoha_metadata_dst_free(port);
157+
}
158+
- free_netdev(eth->napi_dev);
159+
+ airoha_hw_cleanup(eth);
160+
161+
- airoha_ppe_deinit(eth);
162+
+ free_netdev(eth->napi_dev);
163+
platform_set_drvdata(pdev, NULL);
164+
}
165+

target/linux/airoha/patches-6.12/310-02-net-airoha-deassert-XSI-line-on-hw-init.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1313

1414
--- a/drivers/net/ethernet/airoha/airoha_eth.c
1515
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
16-
@@ -1382,6 +1382,10 @@ static int airoha_hw_init(struct platfor
16+
@@ -1409,6 +1409,10 @@ static int airoha_hw_init(struct platfor
1717
if (err)
1818
return err;
1919

target/linux/airoha/patches-6.12/310-06-net-airoha-add-initial-fixup-for-GDM3-4-port-support.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2828

2929
airoha_fe_crsn_qsel_init(eth);
3030

31-
@@ -1625,7 +1627,8 @@ static int airoha_dev_open(struct net_de
31+
@@ -1641,7 +1643,8 @@ static int airoha_dev_open(struct net_de
3232
if (err)
3333
return err;
3434

target/linux/airoha/patches-6.12/310-07-airoha-ethernet-drop-xsi-mac-reset.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1515

1616
--- a/drivers/net/ethernet/airoha/airoha_eth.c
1717
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
18-
@@ -3113,7 +3113,6 @@ static void airoha_remove(struct platfor
18+
@@ -3109,7 +3109,6 @@ static void airoha_remove(struct platfor
1919
}
2020

2121
static const char * const en7581_xsi_rsts_names[] = {
2222
- "xsi-mac",
2323
"hsi0-mac",
2424
"hsi1-mac",
2525
"hsi-mac",
26-
@@ -3145,7 +3144,6 @@ static int airoha_en7581_get_src_port_id
26+
@@ -3141,7 +3140,6 @@ static int airoha_en7581_get_src_port_id
2727
}
2828

2929
static const char * const an7583_xsi_rsts_names[] = {

0 commit comments

Comments
 (0)