Thread View: linux.kernel.netdev
10 messages
10 total messages
Started by ιθζ
Mon, 12 Oct 2026 07:10
[PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: ιθζ
Date: Mon, 12 Oct 2026 07:10
Date: Mon, 12 Oct 2026 07:10
75 lines
11631 bytes
11631 bytes
PPE routed IPv6 FOE entries do not carry the egress source MAC inline;
they store an SMAC id and the hardware resolves the address through the
UPDMEM table, which airoha_ppe_init_upd_mem() only programs with the GDM
port own dev_addr at probe time.
The netdev the flow actually egresses can legally carry a different
address: on PON setups the authentication MAC belongs to the pon device
while each service VLAN routes with its own address, so offloaded IPv6
frames left the port with a stale source MAC and were silently dropped
upstream. IPv4 was unaffected since HNAPT entries embed the MAC inline,
which made the failure hard to diagnose: TCP handshake and TLS completed
over the slow path and the transfer stalled exactly when the flow got
offloaded.
Before writing smac_id for routed IPv6 entries, program the UPDMEM slot
with the source address of this flow.
airoha_set_macaddr() writes the same slot from the ndo_open and
ndo_set_mac_address paths: take flow_offload_mutex there too so the two
UPDMEM writers cannot interleave their two-step DATA/CTRL sequence and
leave a stale address behind.
Tested on a Nokia XG-040G-MD (AN7581, GPON WAN, PPPoE over a service
VLAN carrying its own MAC address): IPv6 HTTPS transfers went from
stalling at the 15 s curl cap with partial bytes to completing at line
rate with hardware offloading enabled, matching IPv4 throughput.
Fixes: 00a7678310fe3 ("net: airoha: Introduce flowtable offload support")
Signed-off-by: Yaoming Chen <cc201008@gmail.com>
---
drivers/net/ethernet/airoha/airoha_eth.c | 8 ++++++++
drivers/net/ethernet/airoha/airoha_ppe.c | 13 +++++++++++++
2 files changed, 21 insertions(+)
--- a/drivers/net/ethernet/airoha/airoha_eth.c
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
@@ -138,7 +138,15 @@ airoha_set_macaddr(struct airoha_gdm_dev *dev,
airoha_fe_wr(eth, REG_FE_MAC_LMIN(reg), lmin);
airoha_fe_wr(eth, REG_FE_MAC_LMAX(reg), lmax);
+ /*
+ * Serialize with the flowtable offload path: both writers program the
+ * same UPDMEM slot with a two-step DATA/CTRL sequence and concurrent
+ * updates would interleave, leaving a stale source MAC under already
+ * bound IPv6 entries.
+ */
+ mutex_lock(&flow_offload_mutex);
airoha_ppe_init_upd_mem(dev, addr);
+ mutex_unlock(&flow_offload_mutex);
return 0;
}
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
@@ -414,6 +414,19 @@ airoha_ppe_foe_entry_prepare(struct airoha_eth *eth,
dsa_port);
smac_id = port->id;
+ /*
+ * Routed IPv6 entries resolve the egress source MAC
+ * through the UPDMEM table indexed by smac_id. The
+ * egress netdev can legally carry a different address
+ * than the GDM port itself: on PON setups the
+ * authentication MAC lives on the pon device while
+ * each service VLAN routes with its own address. Keep
+ * the table entry in sync with the source address this
+ * flow is actually going to use.
+ */
+ if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T)
+ airoha_ppe_init_upd_mem(dev,
+ data->eth.h_source);
}
}
Re: [PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: Lorenzo Bianconi
Date: Mon, 12 Oct 2026 15:56
Date: Mon, 12 Oct 2026 15:56
103 lines
9376 bytes
9376 bytes
--7loBx0NG4ClbL5mp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
> PPE routed IPv6 FOE entries do not carry the egress source MAC inline;
> they store an SMAC id and the hardware resolves the address through the
> UPDMEM table, which airoha_ppe_init_upd_mem() only programs with the GDM
> port own dev_addr at probe time.
>=20
> The netdev the flow actually egresses can legally carry a different
> address: on PON setups the authentication MAC belongs to the pon device
> while each service VLAN routes with its own address, so offloaded IPv6
> frames left the port with a stale source MAC and were silently dropped
> upstream. IPv4 was unaffected since HNAPT entries embed the MAC inline,
> which made the failure hard to diagnose: TCP handshake and TLS completed
> over the slow path and the transfer stalled exactly when the flow got
> offloaded.
>=20
> Before writing smac_id for routed IPv6 entries, program the UPDMEM slot
> with the source address of this flow.
>=20
> airoha_set_macaddr() writes the same slot from the ndo_open and
> ndo_set_mac_address paths: take flow_offload_mutex there too so the two
> UPDMEM writers cannot interleave their two-step DATA/CTRL sequence and
> leave a stale address behind.
>=20
> Tested on a Nokia XG-040G-MD (AN7581, GPON WAN, PPPoE over a service
> VLAN carrying its own MAC address): IPv6 HTTPS transfers went from
> stalling at the 15 s curl cap with partial bytes to completing at line
> rate with hardware offloading enabled, matching IPv4 throughput.
>=20
> Fixes: 00a7678310fe3 ("net: airoha: Introduce flowtable offload support")
> Signed-off-by: Yaoming Chen <cc201008@gmail.com>
> ---
> drivers/net/ethernet/airoha/airoha_eth.c | 8 ++++++++
> drivers/net/ethernet/airoha/airoha_ppe.c | 13 +++++++++++++
> 2 files changed, 21 insertions(+)
>=20
> --- a/drivers/net/ethernet/airoha/airoha_eth.c
> +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> @@ -138,7 +138,15 @@ airoha_set_macaddr(struct airoha_gdm_dev *dev,
> airoha_fe_wr(eth, REG_FE_MAC_LMIN(reg), lmin);
> airoha_fe_wr(eth, REG_FE_MAC_LMAX(reg), lmax);
>=20
> + /*
> + * Serialize with the flowtable offload path: both writers program the
> + * same UPDMEM slot with a two-step DATA/CTRL sequence and concurrent
> + * updates would interleave, leaving a stale source MAC under already
> + * bound IPv6 entries.
> + */
> + mutex_lock(&flow_offload_mutex);
> airoha_ppe_init_upd_mem(dev, addr);
> + mutex_unlock(&flow_offload_mutex);
This seems a deadlock to me since airoha_set_macaddr() is running holding
flow_offload_mutex mutex in airoha_enable_qos_for_gdm34().
>=20
> return 0;
> }
>=20
> --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> @@ -414,6 +414,19 @@ airoha_ppe_foe_entry_prepare(struct airoha_eth *eth,
> dsa_port);
>=20
> smac_id =3D port->id;
> + /*
> + * Routed IPv6 entries resolve the egress source MAC
> + * through the UPDMEM table indexed by smac_id. The
> + * egress netdev can legally carry a different address
> + * than the GDM port itself: on PON setups the
> + * authentication MAC lives on the pon device while
> + * each service VLAN routes with its own address. Keep
> + * the table entry in sync with the source address this
> + * flow is actually going to use.
> + */
> + if (type >=3D PPE_PKT_TYPE_IPV6_ROUTE_3T)
> + airoha_ppe_init_upd_mem(dev,
> + data->eth.h_source);
I do not think you used checkpatch here.
Regards,
Lorenzo
> }
> }
--7loBx0NG4ClbL5mp
Content-Type: application/pgp-signature; name=signature.asc
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCas0DOwAKCRA6cBh0uS2t
rK9aAP9PNyueczLuKOh6HqOy9UG4JJo/Y70ApaV7gfwe/UqkKQEAg1vnuG8yRZy7
CSfsA8crmPEQSI4RS1bv4G6GvRjz7QE=
=I85x
-----END PGP SIGNATURE-----
--7loBx0NG4ClbL5mp--
Re: [PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: ιθζ
Date: Mon, 12 Oct 2026 17:09
Date: Mon, 12 Oct 2026 17:09
56 lines
10673 bytes
10673 bytes
Ooo, the new patch should be a dedicated leaf lock inside
airoha_ppe_init_upd_mem().
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
@@ -416,6 +416,19 @@
dsa_port);
smac_id = port->id;
+ /*
+ * Routed IPv6 entries resolve the egress source MAC
+ * through the UPDMEM table indexed by smac_id. The
+ * egress netdev can legally carry a different address
+ * than the GDM port itself: on PON setups the
+ * authentication MAC lives on the pon device while
+ * each service VLAN routes with its own address. Keep
+ * the table entry in sync with the source address this
+ * flow is actually going to use.
+ */
+ if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T)
+ airoha_ppe_init_upd_mem(dev,
+ data->eth.h_source);
}
}
@@ -1529,10 +1542,21 @@
void airoha_ppe_init_upd_mem(struct airoha_gdm_dev *dev, const u8 *addr)
{
+ static DEFINE_MUTEX(updmem_lock);
+
struct airoha_gdm_port *port = dev->port;
struct airoha_eth *eth = dev->eth;
u32 val;
+ /*
+ * Routed IPv6 entries resolve the egress source MAC through the
+ * UPDMEM table indexed by smac_id; the ndo_open/ndo_set_mac_address
+ * writers hold flow_offload_mutex (QoS paths re-lock via
+ * airoha_set_macaddr()), so this lock also serializes the leaf
+ * against them.
+ */
+ mutex_lock(&updmem_lock);
+
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),
@@ -1545,6 +1569,8 @@
FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
+
+ mutex_unlock(&updmem_lock);
}
struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
Re: [PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: Lorenzo Bianconi
Date: Tue, 13 Oct 2026 07:36
Date: Tue, 13 Oct 2026 07:36
90 lines
8417 bytes
8417 bytes
--TsY4h+RbU0p15xnQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
> Ooo, the new patch should be a dedicated leaf lock inside
> airoha_ppe_init_upd_mem().
> --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> @@ -416,6 +416,19 @@
> dsa_port);
>=20
> smac_id =3D port->id;
> + /*
> + * Routed IPv6 entries resolve the egress source MAC
> + * through the UPDMEM table indexed by smac_id. The
> + * egress netdev can legally carry a different address
> + * than the GDM port itself: on PON setups the
> + * authentication MAC lives on the pon device while
> + * each service VLAN routes with its own address. Keep
> + * the table entry in sync with the source address this
> + * flow is actually going to use.
Is the issue occurring just with PON or are you able to trigger the issue e=
ven
in the upstream codebase? I guess you should not post a fix for some code t=
hat
is not upstream yet. Moreover, in the PON setup, I guess the approach is st=
ill
broken if the user change the device mac address.
> + */
> + if (type >=3D PPE_PKT_TYPE_IPV6_ROUTE_3T)
> + airoha_ppe_init_upd_mem(dev,
> + data->eth.h_source);
> }
> }
>=20
> @@ -1529,10 +1542,21 @@
>=20
> void airoha_ppe_init_upd_mem(struct airoha_gdm_dev *dev, const u8 *addr)
> {
> + static DEFINE_MUTEX(updmem_lock);
> +
> struct airoha_gdm_port *port =3D dev->port;
> struct airoha_eth *eth =3D dev->eth;
> u32 val;
>=20
> + /*
> + * Routed IPv6 entries resolve the egress source MAC through the
> + * UPDMEM table indexed by smac_id; the ndo_open/ndo_set_mac_address
> + * writers hold flow_offload_mutex (QoS paths re-lock via
> + * airoha_set_macaddr()), so this lock also serializes the leaf
> + * against them.
> + */
> + mutex_lock(&updmem_lock);
This is only required adding the above configuration since in the current
codebase airoha_ppe_init_upd_mem() is always running holding RTNL.
Regards,
Lorenzo
> +
> val =3D (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),
> @@ -1545,6 +1569,8 @@
> FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
> FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
> PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
> +
> + mutex_unlock(&updmem_lock);
> }
>=20
> struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
--TsY4h+RbU0p15xnQ
Content-Type: application/pgp-signature; name=signature.asc
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCas3faAAKCRA6cBh0uS2t
rBzUAQCL/fb8smdTz5MWaZqzvmSS5tTGd94zzSEJp/E/0DMNXQD/ecISkztvJeO7
lNdqhT63wJKz2zXCWEru2qKfnsV6EQA=
=YGK5
-----END PGP SIGNATURE-----
--TsY4h+RbU0p15xnQ--
Re: [PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: Lorenzo Bianconi
Date: Tue, 13 Oct 2026 15:54
Date: Tue, 13 Oct 2026 15:54
153 lines
11553 bytes
11553 bytes
--Fip1EEA1bp5qMo/a
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
> The issue is reproducible in the upstream codebase, without any of the
> out-of-tree PON code -- the PON setup is just where I first hit it.
>=20
> Reproduction with mainline code only (airoha eth + the mt7530 MMIO DSA
> driver; the "airoha,en7581-switch" binding and driver are mainline,
> the DT node just needs to be added to a board file):
>=20
> - AN7581 board, switch node with its CPU port on GDM1. Use a DSA user
> port as a routed WAN interface with its own MAC address.
>=20
> airoha_get_dsa_port() replaces the egress netdev with the conduit, so
> routed IPv6 FOE entries carry smac_id =3D conduit port id, and the PPE
> resolves the egress source MAC through UPDMEM[conduit]. That slot is
> only programmed by airoha_set_macaddr(), which never runs when a DSA
> slave address changes, so offloaded IPv6 frames leave the port with
> the conduit's MAC instead of the user port's. IPv4 is unaffected,
> since HNAPT entries store the MACs inline. The same shape appears on a
> GDM port with two "airoha,eth-port" children carrying different MAC
> LSBs, which the recent multi-SerDES series allows by design
> (REG_FE_MAC_LMIN/LMAX); for that variant the exposure starts with the
> series introducing multiple net_devices per GDM port.
>=20
> The posted patch only reprograms the shared per-port slot at offload
> time, so a later address change on any netdev of that port re-breaks
> offloaded IPv6 flows. It is a temporary patch for this setup; the
> final solution is up to the maintainers.
I do not think the case you described is fixed with your patch. Let's consi=
der
the following case:
- time t0: you offload a flow rule for traffic egressing dsa port0
- time t1: you offload a flow rule for traffic egressing dsa port1
Since the index written in REG_UPDMEM_CTRL() subfield is still the conduit =
port
ID, you are egressing traffic from port0 with L2 address of port1. Am I rig=
ht,
or am I missing something?
Moreover, is it a bug if we use the conduit port L2 address as source mac
address for IPv6 traffic?
Regards,
Lorenzo
>=20
> A proper fix would probably give each netdev its own UPDMEM entry: the
> table is indexed by a 4-bit address (16 entries) while the FOE
> smac_id field is 5-bit with 0xf reserved for "keep original MAC", so
> there is room beyond the port ids. Slots could be programmed from
> airoha_set_macaddr() (always under RTNL, as you noted) plus a
> netdevice notifier for DSA slaves, and foe_entry_prepare() would only
> reference the slot -- removing both the race and the extra locking the
> current approach needs.
>=20
> Lorenzo Bianconi <lorenzo@kernel.org> =E4=BA=8E2026=E5=B9=B410=E6=9C=8813=
=E6=97=A5=E5=91=A8=E4=BA=8C 15:36=E5=86=99=E9=81=93=EF=BC=9A
> >
> > > Ooo, the new patch should be a dedicated leaf lock inside
> > > airoha_ppe_init_upd_mem().
> > > --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> > > +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> > > @@ -416,6 +416,19 @@
> > > dsa_port);
> > >
> > > smac_id =3D port->id;
> > > + /*
> > > + * Routed IPv6 entries resolve the egress source MAC
> > > + * through the UPDMEM table indexed by smac_id. The
> > > + * egress netdev can legally carry a different address
> > > + * than the GDM port itself: on PON setups the
> > > + * authentication MAC lives on the pon device while
> > > + * each service VLAN routes with its own address. Keep
> > > + * the table entry in sync with the source address this
> > > + * flow is actually going to use.
> >
> > Is the issue occurring just with PON or are you able to trigger the iss=
ue
> even
> > in the upstream codebase? I guess you should not post a fix for some co=
de
> that
> > is not upstream yet. Moreover, in the PON setup, I guess the approach is
> still
> > broken if the user change the device mac address.
> >
> > > + */
> > > + if (type >=3D PPE_PKT_TYPE_IPV6_ROUTE_3T)
> > > + airoha_ppe_init_upd_mem(dev,
> > > + data->eth.h_source);
> > > }
> > > }
> > >
> > > @@ -1529,10 +1542,21 @@
> > >
> > > void airoha_ppe_init_upd_mem(struct airoha_gdm_dev *dev, const u8
> *addr)
> > > {
> > > + static DEFINE_MUTEX(updmem_lock);
> > > +
> > > struct airoha_gdm_port *port =3D dev->port;
> > > struct airoha_eth *eth =3D dev->eth;
> > > u32 val;
> > >
> > > + /*
> > > + * Routed IPv6 entries resolve the egress source MAC through the
> > > + * UPDMEM table indexed by smac_id; the ndo_open/ndo_set_mac_address
> > > + * writers hold flow_offload_mutex (QoS paths re-lock via
> > > + * airoha_set_macaddr()), so this lock also serializes the leaf
> > > + * against them.
> > > + */
> > > + mutex_lock(&updmem_lock);
> >
> > This is only required adding the above configuration since in the curre=
nt
> > codebase airoha_ppe_init_upd_mem() is always running holding RTNL.
> >
> > Regards,
> > Lorenzo
> >
> > > +
> > > val =3D (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),
> > > @@ -1545,6 +1569,8 @@
> > > FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
> > > FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
> > > PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
> > > +
> > > + mutex_unlock(&updmem_lock);
> > > }
> > >
> > > struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
--Fip1EEA1bp5qMo/a
Content-Type: application/pgp-signature; name=signature.asc
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCas5UUQAKCRA6cBh0uS2t
rAYFAQDficBv9jdbtC8Mk7r3GKyBesME3qEugohD1wSnjlTI1gEA5NcCKczi6hN8
qgNmVTJhPzicY32zfoQMQcLSHOOkXgc=
=FdXQ
-----END PGP SIGNATURE-----
--Fip1EEA1bp5qMo/a--
Re: [PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: ιθζ
Date: Tue, 13 Oct 2026 17:21
Date: Tue, 13 Oct 2026 17:21
155 lines
15839 bytes
15839 bytes
Yes, your analysis is correct: with the patch, the flow offloaded at t1
reprograms the shared UPDMEM entry, so the flow egressing port0 starts
using port1's L2 address. Our setup happens to carry a single IPv6
identity per GDM port (the other services are IPv4), which is why the
patch holds there -- it is a stopgap for that topology, as noted.
On the second question: in the default DSA configuration user ports
inherit the conduit address, so the conduit MAC as source is
indistinguishable from the user port's own. It diverges once user ports
carry their own addresses (nvmem-assigned or user-configured): the
egress frame then differs from what the software path would emit, and
upstream bridges learn the conduit MAC behind a user port. Whether that
is a bug or a corner case is your call; per-netdev slots would cover
either way.
Lorenzo Bianconi <lorenzo@kernel.org> δΊ2026εΉ΄10ζ13ζ₯ε¨δΊ 23:54ειοΌ
>
> > The issue is reproducible in the upstream codebase, without any of the
> > out-of-tree PON code -- the PON setup is just where I first hit it.
> >
> > Reproduction with mainline code only (airoha eth + the mt7530 MMIO DSA
> > driver; the "airoha,en7581-switch" binding and driver are mainline,
> > the DT node just needs to be added to a board file):
> >
> > - AN7581 board, switch node with its CPU port on GDM1. Use a DSA user
> > port as a routed WAN interface with its own MAC address.
> >
> > airoha_get_dsa_port() replaces the egress netdev with the conduit, so
> > routed IPv6 FOE entries carry smac_id = conduit port id, and the PPE
> > resolves the egress source MAC through UPDMEM[conduit]. That slot is
> > only programmed by airoha_set_macaddr(), which never runs when a DSA
> > slave address changes, so offloaded IPv6 frames leave the port with
> > the conduit's MAC instead of the user port's. IPv4 is unaffected,
> > since HNAPT entries store the MACs inline. The same shape appears on a
> > GDM port with two "airoha,eth-port" children carrying different MAC
> > LSBs, which the recent multi-SerDES series allows by design
> > (REG_FE_MAC_LMIN/LMAX); for that variant the exposure starts with the
> > series introducing multiple net_devices per GDM port.
> >
> > The posted patch only reprograms the shared per-port slot at offload
> > time, so a later address change on any netdev of that port re-breaks
> > offloaded IPv6 flows. It is a temporary patch for this setup; the
> > final solution is up to the maintainers.
>
> I do not think the case you described is fixed with your patch. Let's consider
> the following case:
>
> - time t0: you offload a flow rule for traffic egressing dsa port0
> - time t1: you offload a flow rule for traffic egressing dsa port1
>
> Since the index written in REG_UPDMEM_CTRL() subfield is still the conduit port
> ID, you are egressing traffic from port0 with L2 address of port1. Am I right,
> or am I missing something?
> Moreover, is it a bug if we use the conduit port L2 address as source mac
> address for IPv6 traffic?
>
> Regards,
> Lorenzo
>
> >
> > A proper fix would probably give each netdev its own UPDMEM entry: the
> > table is indexed by a 4-bit address (16 entries) while the FOE
> > smac_id field is 5-bit with 0xf reserved for "keep original MAC", so
> > there is room beyond the port ids. Slots could be programmed from
> > airoha_set_macaddr() (always under RTNL, as you noted) plus a
> > netdevice notifier for DSA slaves, and foe_entry_prepare() would only
> > reference the slot -- removing both the race and the extra locking the
> > current approach needs.
> >
> > Lorenzo Bianconi <lorenzo@kernel.org> δΊ2026εΉ΄10ζ13ζ₯ε¨δΊ 15:36ειοΌ
> > >
> > > > Ooo, the new patch should be a dedicated leaf lock inside
> > > > airoha_ppe_init_upd_mem().
> > > > --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > @@ -416,6 +416,19 @@
> > > > dsa_port);
> > > >
> > > > smac_id = port->id;
> > > > + /*
> > > > + * Routed IPv6 entries resolve the egress source MAC
> > > > + * through the UPDMEM table indexed by smac_id. The
> > > > + * egress netdev can legally carry a different address
> > > > + * than the GDM port itself: on PON setups the
> > > > + * authentication MAC lives on the pon device while
> > > > + * each service VLAN routes with its own address. Keep
> > > > + * the table entry in sync with the source address this
> > > > + * flow is actually going to use.
> > >
> > > Is the issue occurring just with PON or are you able to trigger the issue
> > even
> > > in the upstream codebase? I guess you should not post a fix for some code
> > that
> > > is not upstream yet. Moreover, in the PON setup, I guess the approach is
> > still
> > > broken if the user change the device mac address.
> > >
> > > > + */
> > > > + if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T)
> > > > + airoha_ppe_init_upd_mem(dev,
> > > > + data->eth.h_source);
> > > > }
> > > > }
> > > >
> > > > @@ -1529,10 +1542,21 @@
> > > >
> > > > void airoha_ppe_init_upd_mem(struct airoha_gdm_dev *dev, const u8
> > *addr)
> > > > {
> > > > + static DEFINE_MUTEX(updmem_lock);
> > > > +
> > > > struct airoha_gdm_port *port = dev->port;
> > > > struct airoha_eth *eth = dev->eth;
> > > > u32 val;
> > > >
> > > > + /*
> > > > + * Routed IPv6 entries resolve the egress source MAC through the
> > > > + * UPDMEM table indexed by smac_id; the ndo_open/ndo_set_mac_address
> > > > + * writers hold flow_offload_mutex (QoS paths re-lock via
> > > > + * airoha_set_macaddr()), so this lock also serializes the leaf
> > > > + * against them.
> > > > + */
> > > > + mutex_lock(&updmem_lock);
> > >
> > > This is only required adding the above configuration since in the current
> > > codebase airoha_ppe_init_upd_mem() is always running holding RTNL.
> > >
> > > Regards,
> > > Lorenzo
> > >
> > > > +
> > > > 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),
> > > > @@ -1545,6 +1569,8 @@
> > > > FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
> > > > FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
> > > > PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
> > > > +
> > > > + mutex_unlock(&updmem_lock);
> > > > }
> > > >
> > > > struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
Re: [PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: Lorenzo Bianconi
Date: Tue, 13 Oct 2026 20:41
Date: Tue, 13 Oct 2026 20:41
185 lines
13493 bytes
13493 bytes
--2yphx2aGqXHqbPHX
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Oct 14, =E9=99=88=E8=80=80=E6=98=8E wrote:
> Yes, your analysis is correct: with the patch, the flow offloaded at t1
> reprograms the shared UPDMEM entry, so the flow egressing port0 starts
> using port1's L2 address. Our setup happens to carry a single IPv6
> identity per GDM port (the other services are IPv4), which is why the
> patch holds there -- it is a stopgap for that topology, as noted.
>=20
> On the second question: in the default DSA configuration user ports
> inherit the conduit address, so the conduit MAC as source is
> indistinguishable from the user port's own. It diverges once user ports
> carry their own addresses (nvmem-assigned or user-configured): the
> egress frame then differs from what the software path would emit, and
> upstream bridges learn the conduit MAC behind a user port. Whether that
> is a bug or a corner case is your call; per-netdev slots would cover
> either way.
I have not tested it yet, but can you please check if the patch available at
[0] fixes the reported issue? Thanks.
Regards,
Lorenzo
[0] https://github.com/LorenzoBianconi/net-next/commit/486a5f13c62985d4333a=
231cc9aaec714e81fcd2
>=20
> Lorenzo Bianconi <lorenzo@kernel.org> =E4=BA=8E2026=E5=B9=B410=E6=9C=8813=
=E6=97=A5=E5=91=A8=E4=BA=8C 23:54=E5=86=99=E9=81=93=EF=BC=9A
> >
> > > The issue is reproducible in the upstream codebase, without any of the
> > > out-of-tree PON code -- the PON setup is just where I first hit it.
> > >
> > > Reproduction with mainline code only (airoha eth + the mt7530 MMIO DSA
> > > driver; the "airoha,en7581-switch" binding and driver are mainline,
> > > the DT node just needs to be added to a board file):
> > >
> > > - AN7581 board, switch node with its CPU port on GDM1. Use a DSA user
> > > port as a routed WAN interface with its own MAC address.
> > >
> > > airoha_get_dsa_port() replaces the egress netdev with the conduit, so
> > > routed IPv6 FOE entries carry smac_id =3D conduit port id, and the PPE
> > > resolves the egress source MAC through UPDMEM[conduit]. That slot is
> > > only programmed by airoha_set_macaddr(), which never runs when a DSA
> > > slave address changes, so offloaded IPv6 frames leave the port with
> > > the conduit's MAC instead of the user port's. IPv4 is unaffected,
> > > since HNAPT entries store the MACs inline. The same shape appears on a
> > > GDM port with two "airoha,eth-port" children carrying different MAC
> > > LSBs, which the recent multi-SerDES series allows by design
> > > (REG_FE_MAC_LMIN/LMAX); for that variant the exposure starts with the
> > > series introducing multiple net_devices per GDM port.
> > >
> > > The posted patch only reprograms the shared per-port slot at offload
> > > time, so a later address change on any netdev of that port re-breaks
> > > offloaded IPv6 flows. It is a temporary patch for this setup; the
> > > final solution is up to the maintainers.
> >
> > I do not think the case you described is fixed with your patch. Let's c=
onsider
> > the following case:
> >
> > - time t0: you offload a flow rule for traffic egressing dsa port0
> > - time t1: you offload a flow rule for traffic egressing dsa port1
> >
> > Since the index written in REG_UPDMEM_CTRL() subfield is still the cond=
uit port
> > ID, you are egressing traffic from port0 with L2 address of port1. Am I=
right,
> > or am I missing something?
> > Moreover, is it a bug if we use the conduit port L2 address as source m=
ac
> > address for IPv6 traffic?
> >
> > Regards,
> > Lorenzo
> >
> > >
> > > A proper fix would probably give each netdev its own UPDMEM entry: the
> > > table is indexed by a 4-bit address (16 entries) while the FOE
> > > smac_id field is 5-bit with 0xf reserved for "keep original MAC", so
> > > there is room beyond the port ids. Slots could be programmed from
> > > airoha_set_macaddr() (always under RTNL, as you noted) plus a
> > > netdevice notifier for DSA slaves, and foe_entry_prepare() would only
> > > reference the slot -- removing both the race and the extra locking the
> > > current approach needs.
> > >
> > > Lorenzo Bianconi <lorenzo@kernel.org> =E4=BA=8E2026=E5=B9=B410=E6=9C=
=8813=E6=97=A5=E5=91=A8=E4=BA=8C 15:36=E5=86=99=E9=81=93=EF=BC=9A
> > > >
> > > > > Ooo, the new patch should be a dedicated leaf lock inside
> > > > > airoha_ppe_init_upd_mem().
> > > > > --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > > +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > > @@ -416,6 +416,19 @@
> > > > > dsa_port);
> > > > >
> > > > > smac_id =3D port->id;
> > > > > + /*
> > > > > + * Routed IPv6 entries resolve the egress source MAC
> > > > > + * through the UPDMEM table indexed by smac_id. The
> > > > > + * egress netdev can legally carry a different address
> > > > > + * than the GDM port itself: on PON setups the
> > > > > + * authentication MAC lives on the pon device while
> > > > > + * each service VLAN routes with its own address. Keep
> > > > > + * the table entry in sync with the source address this
> > > > > + * flow is actually going to use.
> > > >
> > > > Is the issue occurring just with PON or are you able to trigger the=
issue
> > > even
> > > > in the upstream codebase? I guess you should not post a fix for som=
e code
> > > that
> > > > is not upstream yet. Moreover, in the PON setup, I guess the approa=
ch is
> > > still
> > > > broken if the user change the device mac address.
> > > >
> > > > > + */
> > > > > + if (type >=3D PPE_PKT_TYPE_IPV6_ROUTE_3T)
> > > > > + airoha_ppe_init_upd_mem(dev,
> > > > > + data->eth.h_source);
> > > > > }
> > > > > }
> > > > >
> > > > > @@ -1529,10 +1542,21 @@
> > > > >
> > > > > void airoha_ppe_init_upd_mem(struct airoha_gdm_dev *dev, const u8
> > > *addr)
> > > > > {
> > > > > + static DEFINE_MUTEX(updmem_lock);
> > > > > +
> > > > > struct airoha_gdm_port *port =3D dev->port;
> > > > > struct airoha_eth *eth =3D dev->eth;
> > > > > u32 val;
> > > > >
> > > > > + /*
> > > > > + * Routed IPv6 entries resolve the egress source MAC through the
> > > > > + * UPDMEM table indexed by smac_id; the ndo_open/ndo_set_mac_add=
ress
> > > > > + * writers hold flow_offload_mutex (QoS paths re-lock via
> > > > > + * airoha_set_macaddr()), so this lock also serializes the leaf
> > > > > + * against them.
> > > > > + */
> > > > > + mutex_lock(&updmem_lock);
> > > >
> > > > This is only required adding the above configuration since in the c=
urrent
> > > > codebase airoha_ppe_init_upd_mem() is always running holding RTNL.
> > > >
> > > > Regards,
> > > > Lorenzo
> > > >
> > > > > +
> > > > > val =3D (addr[2] << 24) | (addr[3] << 16) | (addr[4] << 8) | ad=
dr[5];
> > > > > airoha_fe_wr(eth, REG_UPDMEM_DATA(0), val);
> > > > > airoha_fe_wr(eth, REG_UPDMEM_CTRL(0),
> > > > > @@ -1545,6 +1569,8 @@
> > > > > FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
> > > > > FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
> > > > > PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
> > > > > +
> > > > > + mutex_unlock(&updmem_lock);
> > > > > }
> > > > >
> > > > > struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
--2yphx2aGqXHqbPHX
Content-Type: application/pgp-signature; name=signature.asc
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCas6XhwAKCRA6cBh0uS2t
rHdOAQD1N3DK3YaUpREWtj66KFuq6jmX/TCpDSfI90hr7a6dsAEAr8pQEaJCbMCm
r43E0FvDZZIk9lCLSFwo+SoiGPd9eAo=
=lSOH
-----END PGP SIGNATURE-----
--2yphx2aGqXHqbPHX--
Re: [PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: ιθζ
Date: Wed, 14 Oct 2026 03:28
Date: Wed, 14 Oct 2026 03:28
210 lines
18030 bytes
18030 bytes
Went through the patch:
Per-port UPDMEM slots referenced from the FOE and programmed
through the notifier look correct; the slot range fits the 4-bit UPDMEM
address and the 5-bit smac_id field, stays clear of the GDM port ids,
and would only reach 0xf (the "keep original source MAC" marker) for
an 8-port switch, which this SoC does not have.
For the non-DSA variants, in our setup several service VLANs
(voip/iptv/tr069/internet) are stacked on a single GDM port, each with
its own MAC address. VLAN devices are visible neither to the notifier
nor to airoha_set_macaddr(), and foe_entry_prepare() still collapses
them to smac_id = port->id, so all of them would egress with the port
base MAC. The two-airoha,eth-port multi-SerDES variant shares the same
gap.
What the VLAN case needs is the same identity-scoped treatment for
these devices: a slot allocated per egress identity, programmed on
their address events and referenced per flow instead of per port.
Lorenzo Bianconi <lorenzo@kernel.org> δΊ2026εΉ΄10ζ14ζ₯ε¨δΈ 04:41ειοΌ
>
> On Oct 14, ιθζ wrote:
> > Yes, your analysis is correct: with the patch, the flow offloaded at t1
> > reprograms the shared UPDMEM entry, so the flow egressing port0 starts
> > using port1's L2 address. Our setup happens to carry a single IPv6
> > identity per GDM port (the other services are IPv4), which is why the
> > patch holds there -- it is a stopgap for that topology, as noted.
> >
> > On the second question: in the default DSA configuration user ports
> > inherit the conduit address, so the conduit MAC as source is
> > indistinguishable from the user port's own. It diverges once user ports
> > carry their own addresses (nvmem-assigned or user-configured): the
> > egress frame then differs from what the software path would emit, and
> > upstream bridges learn the conduit MAC behind a user port. Whether that
> > is a bug or a corner case is your call; per-netdev slots would cover
> > either way.
>
> I have not tested it yet, but can you please check if the patch available at
> [0] fixes the reported issue? Thanks.
>
> Regards,
> Lorenzo
>
> [0] https://github.com/LorenzoBianconi/net-next/commit/486a5f13c62985d4333a231cc9aaec714e81fcd2
>
> >
> > Lorenzo Bianconi <lorenzo@kernel.org> δΊ2026εΉ΄10ζ13ζ₯ε¨δΊ 23:54ειοΌ
> > >
> > > > The issue is reproducible in the upstream codebase, without any of the
> > > > out-of-tree PON code -- the PON setup is just where I first hit it.
> > > >
> > > > Reproduction with mainline code only (airoha eth + the mt7530 MMIO DSA
> > > > driver; the "airoha,en7581-switch" binding and driver are mainline,
> > > > the DT node just needs to be added to a board file):
> > > >
> > > > - AN7581 board, switch node with its CPU port on GDM1. Use a DSA user
> > > > port as a routed WAN interface with its own MAC address.
> > > >
> > > > airoha_get_dsa_port() replaces the egress netdev with the conduit, so
> > > > routed IPv6 FOE entries carry smac_id = conduit port id, and the PPE
> > > > resolves the egress source MAC through UPDMEM[conduit]. That slot is
> > > > only programmed by airoha_set_macaddr(), which never runs when a DSA
> > > > slave address changes, so offloaded IPv6 frames leave the port with
> > > > the conduit's MAC instead of the user port's. IPv4 is unaffected,
> > > > since HNAPT entries store the MACs inline. The same shape appears on a
> > > > GDM port with two "airoha,eth-port" children carrying different MAC
> > > > LSBs, which the recent multi-SerDES series allows by design
> > > > (REG_FE_MAC_LMIN/LMAX); for that variant the exposure starts with the
> > > > series introducing multiple net_devices per GDM port.
> > > >
> > > > The posted patch only reprograms the shared per-port slot at offload
> > > > time, so a later address change on any netdev of that port re-breaks
> > > > offloaded IPv6 flows. It is a temporary patch for this setup; the
> > > > final solution is up to the maintainers.
> > >
> > > I do not think the case you described is fixed with your patch. Let's consider
> > > the following case:
> > >
> > > - time t0: you offload a flow rule for traffic egressing dsa port0
> > > - time t1: you offload a flow rule for traffic egressing dsa port1
> > >
> > > Since the index written in REG_UPDMEM_CTRL() subfield is still the conduit port
> > > ID, you are egressing traffic from port0 with L2 address of port1. Am I right,
> > > or am I missing something?
> > > Moreover, is it a bug if we use the conduit port L2 address as source mac
> > > address for IPv6 traffic?
> > >
> > > Regards,
> > > Lorenzo
> > >
> > > >
> > > > A proper fix would probably give each netdev its own UPDMEM entry: the
> > > > table is indexed by a 4-bit address (16 entries) while the FOE
> > > > smac_id field is 5-bit with 0xf reserved for "keep original MAC", so
> > > > there is room beyond the port ids. Slots could be programmed from
> > > > airoha_set_macaddr() (always under RTNL, as you noted) plus a
> > > > netdevice notifier for DSA slaves, and foe_entry_prepare() would only
> > > > reference the slot -- removing both the race and the extra locking the
> > > > current approach needs.
> > > >
> > > > Lorenzo Bianconi <lorenzo@kernel.org> δΊ2026εΉ΄10ζ13ζ₯ε¨δΊ 15:36ειοΌ
> > > > >
> > > > > > Ooo, the new patch should be a dedicated leaf lock inside
> > > > > > airoha_ppe_init_upd_mem().
> > > > > > --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > > > +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > > > @@ -416,6 +416,19 @@
> > > > > > dsa_port);
> > > > > >
> > > > > > smac_id = port->id;
> > > > > > + /*
> > > > > > + * Routed IPv6 entries resolve the egress source MAC
> > > > > > + * through the UPDMEM table indexed by smac_id. The
> > > > > > + * egress netdev can legally carry a different address
> > > > > > + * than the GDM port itself: on PON setups the
> > > > > > + * authentication MAC lives on the pon device while
> > > > > > + * each service VLAN routes with its own address. Keep
> > > > > > + * the table entry in sync with the source address this
> > > > > > + * flow is actually going to use.
> > > > >
> > > > > Is the issue occurring just with PON or are you able to trigger the issue
> > > > even
> > > > > in the upstream codebase? I guess you should not post a fix for some code
> > > > that
> > > > > is not upstream yet. Moreover, in the PON setup, I guess the approach is
> > > > still
> > > > > broken if the user change the device mac address.
> > > > >
> > > > > > + */
> > > > > > + if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T)
> > > > > > + airoha_ppe_init_upd_mem(dev,
> > > > > > + data->eth.h_source);
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > @@ -1529,10 +1542,21 @@
> > > > > >
> > > > > > void airoha_ppe_init_upd_mem(struct airoha_gdm_dev *dev, const u8
> > > > *addr)
> > > > > > {
> > > > > > + static DEFINE_MUTEX(updmem_lock);
> > > > > > +
> > > > > > struct airoha_gdm_port *port = dev->port;
> > > > > > struct airoha_eth *eth = dev->eth;
> > > > > > u32 val;
> > > > > >
> > > > > > + /*
> > > > > > + * Routed IPv6 entries resolve the egress source MAC through the
> > > > > > + * UPDMEM table indexed by smac_id; the ndo_open/ndo_set_mac_address
> > > > > > + * writers hold flow_offload_mutex (QoS paths re-lock via
> > > > > > + * airoha_set_macaddr()), so this lock also serializes the leaf
> > > > > > + * against them.
> > > > > > + */
> > > > > > + mutex_lock(&updmem_lock);
> > > > >
> > > > > This is only required adding the above configuration since in the current
> > > > > codebase airoha_ppe_init_upd_mem() is always running holding RTNL.
> > > > >
> > > > > Regards,
> > > > > Lorenzo
> > > > >
> > > > > > +
> > > > > > 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),
> > > > > > @@ -1545,6 +1569,8 @@
> > > > > > FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
> > > > > > FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
> > > > > > PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
> > > > > > +
> > > > > > + mutex_unlock(&updmem_lock);
> > > > > > }
> > > > > >
> > > > > > struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
Re: [PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: Lorenzo Bianconi
Date: Wed, 14 Oct 2026 07:50
Date: Wed, 14 Oct 2026 07:50
247 lines
15702 bytes
15702 bytes
--bFnl5cuHayO5eqE4
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
> Went through the patch:
>=20
> Per-port UPDMEM slots referenced from the FOE and programmed
> through the notifier look correct; the slot range fits the 4-bit UPDMEM
> address and the 5-bit smac_id field, stays clear of the GDM port ids,
> and would only reach 0xf (the "keep original source MAC" marker) for
> an 8-port switch, which this SoC does not have.
do you have any chance to test it with offloading? I can't do it at the mom=
ent.
>=20
> For the non-DSA variants, in our setup several service VLANs
> (voip/iptv/tr069/internet) are stacked on a single GDM port, each with
> its own MAC address. VLAN devices are visible neither to the notifier
> nor to airoha_set_macaddr(), and foe_entry_prepare() still collapses
> them to smac_id =3D port->id, so all of them would egress with the port
> base MAC. The two-airoha,eth-port multi-SerDES variant shares the same
> gap.
I guess you can modify the airoha_eth_even() logic in order to look at vlan=
too
but you need to implement the proper logic for the smac_id hw space.
Regards,
Lorenzo
>=20
> What the VLAN case needs is the same identity-scoped treatment for
> these devices: a slot allocated per egress identity, programmed on
> their address events and referenced per flow instead of per port.
>=20
> Lorenzo Bianconi <lorenzo@kernel.org> =E4=BA=8E2026=E5=B9=B410=E6=9C=8814=
=E6=97=A5=E5=91=A8=E4=B8=89 04:41=E5=86=99=E9=81=93=EF=BC=9A
> >
> > On Oct 14, =E9=99=88=E8=80=80=E6=98=8E wrote:
> > > Yes, your analysis is correct: with the patch, the flow offloaded at =
t1
> > > reprograms the shared UPDMEM entry, so the flow egressing port0 starts
> > > using port1's L2 address. Our setup happens to carry a single IPv6
> > > identity per GDM port (the other services are IPv4), which is why the
> > > patch holds there -- it is a stopgap for that topology, as noted.
> > >
> > > On the second question: in the default DSA configuration user ports
> > > inherit the conduit address, so the conduit MAC as source is
> > > indistinguishable from the user port's own. It diverges once user por=
ts
> > > carry their own addresses (nvmem-assigned or user-configured): the
> > > egress frame then differs from what the software path would emit, and
> > > upstream bridges learn the conduit MAC behind a user port. Whether th=
at
> > > is a bug or a corner case is your call; per-netdev slots would cover
> > > either way.
> >
> > I have not tested it yet, but can you please check if the patch availab=
le at
> > [0] fixes the reported issue? Thanks.
> >
> > Regards,
> > Lorenzo
> >
> > [0] https://github.com/LorenzoBianconi/net-next/commit/486a5f13c62985d4=
333a231cc9aaec714e81fcd2
> >
> > >
> > > Lorenzo Bianconi <lorenzo@kernel.org> =E4=BA=8E2026=E5=B9=B410=E6=9C=
=8813=E6=97=A5=E5=91=A8=E4=BA=8C 23:54=E5=86=99=E9=81=93=EF=BC=9A
> > > >
> > > > > The issue is reproducible in the upstream codebase, without any o=
f the
> > > > > out-of-tree PON code -- the PON setup is just where I first hit i=
t.
> > > > >
> > > > > Reproduction with mainline code only (airoha eth + the mt7530 MMI=
O DSA
> > > > > driver; the "airoha,en7581-switch" binding and driver are mainlin=
e,
> > > > > the DT node just needs to be added to a board file):
> > > > >
> > > > > - AN7581 board, switch node with its CPU port on GDM1. Use a DSA =
user
> > > > > port as a routed WAN interface with its own MAC address.
> > > > >
> > > > > airoha_get_dsa_port() replaces the egress netdev with the conduit=
, so
> > > > > routed IPv6 FOE entries carry smac_id =3D conduit port id, and th=
e PPE
> > > > > resolves the egress source MAC through UPDMEM[conduit]. That slot=
is
> > > > > only programmed by airoha_set_macaddr(), which never runs when a =
DSA
> > > > > slave address changes, so offloaded IPv6 frames leave the port wi=
th
> > > > > the conduit's MAC instead of the user port's. IPv4 is unaffected,
> > > > > since HNAPT entries store the MACs inline. The same shape appears=
on a
> > > > > GDM port with two "airoha,eth-port" children carrying different M=
AC
> > > > > LSBs, which the recent multi-SerDES series allows by design
> > > > > (REG_FE_MAC_LMIN/LMAX); for that variant the exposure starts with=
the
> > > > > series introducing multiple net_devices per GDM port.
> > > > >
> > > > > The posted patch only reprograms the shared per-port slot at offl=
oad
> > > > > time, so a later address change on any netdev of that port re-bre=
aks
> > > > > offloaded IPv6 flows. It is a temporary patch for this setup; the
> > > > > final solution is up to the maintainers.
> > > >
> > > > I do not think the case you described is fixed with your patch. Let=
's consider
> > > > the following case:
> > > >
> > > > - time t0: you offload a flow rule for traffic egressing dsa port0
> > > > - time t1: you offload a flow rule for traffic egressing dsa port1
> > > >
> > > > Since the index written in REG_UPDMEM_CTRL() subfield is still the =
conduit port
> > > > ID, you are egressing traffic from port0 with L2 address of port1. =
Am I right,
> > > > or am I missing something?
> > > > Moreover, is it a bug if we use the conduit port L2 address as sour=
ce mac
> > > > address for IPv6 traffic?
> > > >
> > > > Regards,
> > > > Lorenzo
> > > >
> > > > >
> > > > > A proper fix would probably give each netdev its own UPDMEM entry=
: the
> > > > > table is indexed by a 4-bit address (16 entries) while the FOE
> > > > > smac_id field is 5-bit with 0xf reserved for "keep original MAC",=
so
> > > > > there is room beyond the port ids. Slots could be programmed from
> > > > > airoha_set_macaddr() (always under RTNL, as you noted) plus a
> > > > > netdevice notifier for DSA slaves, and foe_entry_prepare() would =
only
> > > > > reference the slot -- removing both the race and the extra lockin=
g the
> > > > > current approach needs.
> > > > >
> > > > > Lorenzo Bianconi <lorenzo@kernel.org> =E4=BA=8E2026=E5=B9=B410=E6=
=9C=8813=E6=97=A5=E5=91=A8=E4=BA=8C 15:36=E5=86=99=E9=81=93=EF=BC=9A
> > > > > >
> > > > > > > Ooo, the new patch should be a dedicated leaf lock inside
> > > > > > > airoha_ppe_init_upd_mem().
> > > > > > > --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > > > > +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > > > > @@ -416,6 +416,19 @@
> > > > > > > dsa_port);
> > > > > > >
> > > > > > > smac_id =3D port->id;
> > > > > > > + /*
> > > > > > > + * Routed IPv6 entries resolve the egress source MAC
> > > > > > > + * through the UPDMEM table indexed by smac_id. The
> > > > > > > + * egress netdev can legally carry a different address
> > > > > > > + * than the GDM port itself: on PON setups the
> > > > > > > + * authentication MAC lives on the pon device while
> > > > > > > + * each service VLAN routes with its own address. Keep
> > > > > > > + * the table entry in sync with the source address this
> > > > > > > + * flow is actually going to use.
> > > > > >
> > > > > > Is the issue occurring just with PON or are you able to trigger=
the issue
> > > > > even
> > > > > > in the upstream codebase? I guess you should not post a fix for=
some code
> > > > > that
> > > > > > is not upstream yet. Moreover, in the PON setup, I guess the ap=
proach is
> > > > > still
> > > > > > broken if the user change the device mac address.
> > > > > >
> > > > > > > + */
> > > > > > > + if (type >=3D PPE_PKT_TYPE_IPV6_ROUTE_3T)
> > > > > > > + airoha_ppe_init_upd_mem(dev,
> > > > > > > + data->eth.h_source);
> > > > > > > }
> > > > > > > }
> > > > > > >
> > > > > > > @@ -1529,10 +1542,21 @@
> > > > > > >
> > > > > > > void airoha_ppe_init_upd_mem(struct airoha_gdm_dev *dev, con=
st u8
> > > > > *addr)
> > > > > > > {
> > > > > > > + static DEFINE_MUTEX(updmem_lock);
> > > > > > > +
> > > > > > > struct airoha_gdm_port *port =3D dev->port;
> > > > > > > struct airoha_eth *eth =3D dev->eth;
> > > > > > > u32 val;
> > > > > > >
> > > > > > > + /*
> > > > > > > + * Routed IPv6 entries resolve the egress source MAC through=
the
> > > > > > > + * UPDMEM table indexed by smac_id; the ndo_open/ndo_set_mac=
_address
> > > > > > > + * writers hold flow_offload_mutex (QoS paths re-lock via
> > > > > > > + * airoha_set_macaddr()), so this lock also serializes the l=
eaf
> > > > > > > + * against them.
> > > > > > > + */
> > > > > > > + mutex_lock(&updmem_lock);
> > > > > >
> > > > > > This is only required adding the above configuration since in t=
he current
> > > > > > codebase airoha_ppe_init_upd_mem() is always running holding RT=
NL.
> > > > > >
> > > > > > Regards,
> > > > > > Lorenzo
> > > > > >
> > > > > > > +
> > > > > > > val =3D (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),
> > > > > > > @@ -1545,6 +1569,8 @@
> > > > > > > FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
> > > > > > > FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
> > > > > > > PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
> > > > > > > +
> > > > > > > + mutex_unlock(&updmem_lock);
> > > > > > > }
> > > > > > >
> > > > > > > struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
--bFnl5cuHayO5eqE4
Content-Type: application/pgp-signature; name=signature.asc
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCas80MgAKCRA6cBh0uS2t
rGlnAP9+nPBdDTIOUWeHUeWNlU1pieseWUc303gM+J+KV3R1yAD+KyqoSYSE1qzY
J9oYwpYAk9poYL9s+FKtkw29DWX/ZAg=
=eOxL
-----END PGP SIGNATURE-----
--bFnl5cuHayO5eqE4--
Re: [PATCH net] net: airoha: Keep UPDMEM egress MAC in sync for offloaded IPv6 flows
Author: ιθζ
Date: Wed, 14 Oct 2026 09:05
Date: Wed, 14 Oct 2026 09:05
254 lines
19857 bytes
19857 bytes
No, I don't have a setup to exercise the DSA offload path, so I can't
provide a Tested-by for this one.
Agreed on the VLAN case: extending the notifier to VLAN devices is the
easy half; the smac_id hw space allocation is the actual design work.
That is beyond our scope for now.
It is worth noting that the free smac_id space is tight once the GDM
ports and the DSA range are carved out (single digits on this SoC), so
the allocation likely needs to be dynamic with reclaim, covering only
identities that actually route IPv6.
Lorenzo Bianconi <lorenzo@kernel.org> δΊ2026εΉ΄10ζ14ζ₯ε¨δΈ 15:50ειοΌ
>
> > Went through the patch:
> >
> > Per-port UPDMEM slots referenced from the FOE and programmed
> > through the notifier look correct; the slot range fits the 4-bit UPDMEM
> > address and the 5-bit smac_id field, stays clear of the GDM port ids,
> > and would only reach 0xf (the "keep original source MAC" marker) for
> > an 8-port switch, which this SoC does not have.
>
> do you have any chance to test it with offloading? I can't do it at the moment.
>
> >
> > For the non-DSA variants, in our setup several service VLANs
> > (voip/iptv/tr069/internet) are stacked on a single GDM port, each with
> > its own MAC address. VLAN devices are visible neither to the notifier
> > nor to airoha_set_macaddr(), and foe_entry_prepare() still collapses
> > them to smac_id = port->id, so all of them would egress with the port
> > base MAC. The two-airoha,eth-port multi-SerDES variant shares the same
> > gap.
>
> I guess you can modify the airoha_eth_even() logic in order to look at vlan too
> but you need to implement the proper logic for the smac_id hw space.
>
> Regards,
> Lorenzo
>
> >
> > What the VLAN case needs is the same identity-scoped treatment for
> > these devices: a slot allocated per egress identity, programmed on
> > their address events and referenced per flow instead of per port.
> >
> > Lorenzo Bianconi <lorenzo@kernel.org> δΊ2026εΉ΄10ζ14ζ₯ε¨δΈ 04:41ειοΌ
> > >
> > > On Oct 14, ιθζ wrote:
> > > > Yes, your analysis is correct: with the patch, the flow offloaded at t1
> > > > reprograms the shared UPDMEM entry, so the flow egressing port0 starts
> > > > using port1's L2 address. Our setup happens to carry a single IPv6
> > > > identity per GDM port (the other services are IPv4), which is why the
> > > > patch holds there -- it is a stopgap for that topology, as noted.
> > > >
> > > > On the second question: in the default DSA configuration user ports
> > > > inherit the conduit address, so the conduit MAC as source is
> > > > indistinguishable from the user port's own. It diverges once user ports
> > > > carry their own addresses (nvmem-assigned or user-configured): the
> > > > egress frame then differs from what the software path would emit, and
> > > > upstream bridges learn the conduit MAC behind a user port. Whether that
> > > > is a bug or a corner case is your call; per-netdev slots would cover
> > > > either way.
> > >
> > > I have not tested it yet, but can you please check if the patch available at
> > > [0] fixes the reported issue? Thanks.
> > >
> > > Regards,
> > > Lorenzo
> > >
> > > [0] https://github.com/LorenzoBianconi/net-next/commit/486a5f13c62985d4333a231cc9aaec714e81fcd2
> > >
> > > >
> > > > Lorenzo Bianconi <lorenzo@kernel.org> δΊ2026εΉ΄10ζ13ζ₯ε¨δΊ 23:54ειοΌ
> > > > >
> > > > > > The issue is reproducible in the upstream codebase, without any of the
> > > > > > out-of-tree PON code -- the PON setup is just where I first hit it.
> > > > > >
> > > > > > Reproduction with mainline code only (airoha eth + the mt7530 MMIO DSA
> > > > > > driver; the "airoha,en7581-switch" binding and driver are mainline,
> > > > > > the DT node just needs to be added to a board file):
> > > > > >
> > > > > > - AN7581 board, switch node with its CPU port on GDM1. Use a DSA user
> > > > > > port as a routed WAN interface with its own MAC address.
> > > > > >
> > > > > > airoha_get_dsa_port() replaces the egress netdev with the conduit, so
> > > > > > routed IPv6 FOE entries carry smac_id = conduit port id, and the PPE
> > > > > > resolves the egress source MAC through UPDMEM[conduit]. That slot is
> > > > > > only programmed by airoha_set_macaddr(), which never runs when a DSA
> > > > > > slave address changes, so offloaded IPv6 frames leave the port with
> > > > > > the conduit's MAC instead of the user port's. IPv4 is unaffected,
> > > > > > since HNAPT entries store the MACs inline. The same shape appears on a
> > > > > > GDM port with two "airoha,eth-port" children carrying different MAC
> > > > > > LSBs, which the recent multi-SerDES series allows by design
> > > > > > (REG_FE_MAC_LMIN/LMAX); for that variant the exposure starts with the
> > > > > > series introducing multiple net_devices per GDM port.
> > > > > >
> > > > > > The posted patch only reprograms the shared per-port slot at offload
> > > > > > time, so a later address change on any netdev of that port re-breaks
> > > > > > offloaded IPv6 flows. It is a temporary patch for this setup; the
> > > > > > final solution is up to the maintainers.
> > > > >
> > > > > I do not think the case you described is fixed with your patch. Let's consider
> > > > > the following case:
> > > > >
> > > > > - time t0: you offload a flow rule for traffic egressing dsa port0
> > > > > - time t1: you offload a flow rule for traffic egressing dsa port1
> > > > >
> > > > > Since the index written in REG_UPDMEM_CTRL() subfield is still the conduit port
> > > > > ID, you are egressing traffic from port0 with L2 address of port1. Am I right,
> > > > > or am I missing something?
> > > > > Moreover, is it a bug if we use the conduit port L2 address as source mac
> > > > > address for IPv6 traffic?
> > > > >
> > > > > Regards,
> > > > > Lorenzo
> > > > >
> > > > > >
> > > > > > A proper fix would probably give each netdev its own UPDMEM entry: the
> > > > > > table is indexed by a 4-bit address (16 entries) while the FOE
> > > > > > smac_id field is 5-bit with 0xf reserved for "keep original MAC", so
> > > > > > there is room beyond the port ids. Slots could be programmed from
> > > > > > airoha_set_macaddr() (always under RTNL, as you noted) plus a
> > > > > > netdevice notifier for DSA slaves, and foe_entry_prepare() would only
> > > > > > reference the slot -- removing both the race and the extra locking the
> > > > > > current approach needs.
> > > > > >
> > > > > > Lorenzo Bianconi <lorenzo@kernel.org> δΊ2026εΉ΄10ζ13ζ₯ε¨δΊ 15:36ειοΌ
> > > > > > >
> > > > > > > > Ooo, the new patch should be a dedicated leaf lock inside
> > > > > > > > airoha_ppe_init_upd_mem().
> > > > > > > > --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > > > > > +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> > > > > > > > @@ -416,6 +416,19 @@
> > > > > > > > dsa_port);
> > > > > > > >
> > > > > > > > smac_id = port->id;
> > > > > > > > + /*
> > > > > > > > + * Routed IPv6 entries resolve the egress source MAC
> > > > > > > > + * through the UPDMEM table indexed by smac_id. The
> > > > > > > > + * egress netdev can legally carry a different address
> > > > > > > > + * than the GDM port itself: on PON setups the
> > > > > > > > + * authentication MAC lives on the pon device while
> > > > > > > > + * each service VLAN routes with its own address. Keep
> > > > > > > > + * the table entry in sync with the source address this
> > > > > > > > + * flow is actually going to use.
> > > > > > >
> > > > > > > Is the issue occurring just with PON or are you able to trigger the issue
> > > > > > even
> > > > > > > in the upstream codebase? I guess you should not post a fix for some code
> > > > > > that
> > > > > > > is not upstream yet. Moreover, in the PON setup, I guess the approach is
> > > > > > still
> > > > > > > broken if the user change the device mac address.
> > > > > > >
> > > > > > > > + */
> > > > > > > > + if (type >= PPE_PKT_TYPE_IPV6_ROUTE_3T)
> > > > > > > > + airoha_ppe_init_upd_mem(dev,
> > > > > > > > + data->eth.h_source);
> > > > > > > > }
> > > > > > > > }
> > > > > > > >
> > > > > > > > @@ -1529,10 +1542,21 @@
> > > > > > > >
> > > > > > > > void airoha_ppe_init_upd_mem(struct airoha_gdm_dev *dev, const u8
> > > > > > *addr)
> > > > > > > > {
> > > > > > > > + static DEFINE_MUTEX(updmem_lock);
> > > > > > > > +
> > > > > > > > struct airoha_gdm_port *port = dev->port;
> > > > > > > > struct airoha_eth *eth = dev->eth;
> > > > > > > > u32 val;
> > > > > > > >
> > > > > > > > + /*
> > > > > > > > + * Routed IPv6 entries resolve the egress source MAC through the
> > > > > > > > + * UPDMEM table indexed by smac_id; the ndo_open/ndo_set_mac_address
> > > > > > > > + * writers hold flow_offload_mutex (QoS paths re-lock via
> > > > > > > > + * airoha_set_macaddr()), so this lock also serializes the leaf
> > > > > > > > + * against them.
> > > > > > > > + */
> > > > > > > > + mutex_lock(&updmem_lock);
> > > > > > >
> > > > > > > This is only required adding the above configuration since in the current
> > > > > > > codebase airoha_ppe_init_upd_mem() is always running holding RTNL.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Lorenzo
> > > > > > >
> > > > > > > > +
> > > > > > > > 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),
> > > > > > > > @@ -1545,6 +1569,8 @@
> > > > > > > > FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
> > > > > > > > FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
> > > > > > > > PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
> > > > > > > > +
> > > > > > > > + mutex_unlock(&updmem_lock);
> > > > > > > > }
> > > > > > > >
> > > > > > > > struct airoha_ppe_dev *airoha_ppe_get_dev(struct device *dev)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads