* [PATCH net 0/2] net: airoha: Fix IPv6 hw acceleration
@ 2025-05-29 15:52 Lorenzo Bianconi
2025-05-29 15:52 ` [PATCH net 1/2] net: airoha: Initialize PPE UPDMEM source-mac table Lorenzo Bianconi
2025-05-29 15:52 ` [PATCH net 2/2] net: airoha: Fix IPv6 hw acceleration in bridge mode Lorenzo Bianconi
0 siblings, 2 replies; 7+ messages in thread
From: Lorenzo Bianconi @ 2025-05-29 15:52 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michal Kubiak, Lorenzo Bianconi
Cc: linux-arm-kernel, linux-mediatek, netdev
Fix IPv6 hw acceleration in bridge mode resolving ib2 and
airoha_foe_mac_info_common overwrite in
airoha_ppe_foe_commit_subflow_entry routine.
Introduce UPDMEM source-mac table used to set source mac address for
L3 IPv6 hw accelerated traffic.
---
Lorenzo Bianconi (2):
net: airoha: Initialize PPE UPDMEM source-mac table
net: airoha: Fix IPv6 hw acceleration in bridge mode
drivers/net/ethernet/airoha/airoha_eth.c | 2 ++
drivers/net/ethernet/airoha/airoha_eth.h | 1 +
drivers/net/ethernet/airoha/airoha_ppe.c | 52 ++++++++++++++++++++++++-------
drivers/net/ethernet/airoha/airoha_regs.h | 10 ++++++
4 files changed, 53 insertions(+), 12 deletions(-)
---
base-commit: 27eab4c644236a9324084a70fe79e511cbd07393
change-id: 20250529-airoha-flowtable-ipv6-fix-976a1ce80e7d
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net 1/2] net: airoha: Initialize PPE UPDMEM source-mac table
2025-05-29 15:52 [PATCH net 0/2] net: airoha: Fix IPv6 hw acceleration Lorenzo Bianconi
@ 2025-05-29 15:52 ` Lorenzo Bianconi
2025-05-30 18:05 ` Simon Horman
2025-05-29 15:52 ` [PATCH net 2/2] net: airoha: Fix IPv6 hw acceleration in bridge mode Lorenzo Bianconi
1 sibling, 1 reply; 7+ messages in thread
From: Lorenzo Bianconi @ 2025-05-29 15:52 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michal Kubiak, Lorenzo Bianconi
Cc: linux-arm-kernel, linux-mediatek, netdev
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.
Fixes: 00a7678310fe ("net: airoha: Introduce flowtable offload support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
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(-)
diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
index d1d3b854361e443d414876f79f59b3c64cbcbe16..a7ec609d64dee9c8e901c7eb650bb3fe144ee00a 100644
--- 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 airoha_gdm_port *port, const u8 *addr)
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,
diff --git a/drivers/net/ethernet/airoha/airoha_eth.h b/drivers/net/ethernet/airoha/airoha_eth.h
index b815697302bfdf2a6d115a9bbbbadc05462dbadb..a970b789cf232c316e5ea27b0146493bf91c3767 100644
--- 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_ppe *ppe, struct sk_buff *skb,
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,
diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c
index 12d32c92717a6b4ba74728ec02bb2e166d4d9407..a783f16980e6b7fdb69cec7ff09883a9c83d42d5 100644
--- 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(struct airoha_eth *eth,
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(struct airoha_eth *eth,
*/
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(struct airoha_eth *eth,
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_ppe *ppe, struct sk_buff *skb,
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;
diff --git a/drivers/net/ethernet/airoha/airoha_regs.h b/drivers/net/ethernet/airoha/airoha_regs.h
index d931530fc96fb00ada36a6ad37fa295865a6f0a8..04187eb40ec674ec5a4ccfc968bb4bd579a53095 100644
--- 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)
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 2/2] net: airoha: Fix IPv6 hw acceleration in bridge mode
2025-05-29 15:52 [PATCH net 0/2] net: airoha: Fix IPv6 hw acceleration Lorenzo Bianconi
2025-05-29 15:52 ` [PATCH net 1/2] net: airoha: Initialize PPE UPDMEM source-mac table Lorenzo Bianconi
@ 2025-05-29 15:52 ` Lorenzo Bianconi
2025-05-30 18:06 ` Simon Horman
1 sibling, 1 reply; 7+ messages in thread
From: Lorenzo Bianconi @ 2025-05-29 15:52 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michal Kubiak, Lorenzo Bianconi
Cc: linux-arm-kernel, linux-mediatek, netdev
ib2 and airoha_foe_mac_info_common have not the same offsets in
airoha_foe_bridge and airoha_foe_ipv6 structures. Fix IPv6 hw
acceleration in bridge mode resolving ib2 and airoha_foe_mac_info_common
overwrite in airoha_ppe_foe_commit_subflow_entry routine. Moreover, set
AIROHA_FOE_MAC_SMAC_ID to 0xf in airoha_ppe_foe_commit_subflow_entry()
to configure the PPE module to keep original source mac address of the
bridged packets.
Fixes: cd53f622611f ("net: airoha: Add L2 hw acceleration support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/ethernet/airoha/airoha_ppe.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c
index a783f16980e6b7fdb69cec7ff09883a9c83d42d5..d5dbcb556f2b10b23ebbdd32a66a3c4f32cfb460 100644
--- 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(struct airoha_ppe *ppe,
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,23 @@ airoha_ppe_foe_commit_subflow_entry(struct airoha_ppe *ppe,
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;
+ 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;
+ /* keep origianl 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));
+ 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.data = e->data.bridge.data;
airoha_ppe_foe_commit_entry(ppe, &hwe, hash);
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] net: airoha: Initialize PPE UPDMEM source-mac table
2025-05-29 15:52 ` [PATCH net 1/2] net: airoha: Initialize PPE UPDMEM source-mac table Lorenzo Bianconi
@ 2025-05-30 18:05 ` Simon Horman
2025-06-02 17:51 ` Lorenzo Bianconi
0 siblings, 1 reply; 7+ messages in thread
From: Simon Horman @ 2025-05-30 18:05 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michal Kubiak, linux-arm-kernel, linux-mediatek,
netdev
On Thu, May 29, 2025 at 05:52:37PM +0200, Lorenzo Bianconi wrote:
> 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.
Hi Lorenzo,
I think it would be nice to also mention a bit more clearly what (broken)
behaviour this fixes. Likewise for patch 2/2.
>
> Fixes: 00a7678310fe ("net: airoha: Introduce flowtable offload support")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 2/2] net: airoha: Fix IPv6 hw acceleration in bridge mode
2025-05-29 15:52 ` [PATCH net 2/2] net: airoha: Fix IPv6 hw acceleration in bridge mode Lorenzo Bianconi
@ 2025-05-30 18:06 ` Simon Horman
2025-06-02 17:51 ` Lorenzo Bianconi
0 siblings, 1 reply; 7+ messages in thread
From: Simon Horman @ 2025-05-30 18:06 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michal Kubiak, linux-arm-kernel, linux-mediatek,
netdev
On Thu, May 29, 2025 at 05:52:38PM +0200, Lorenzo Bianconi wrote:
> ib2 and airoha_foe_mac_info_common have not the same offsets in
> airoha_foe_bridge and airoha_foe_ipv6 structures. Fix IPv6 hw
> acceleration in bridge mode resolving ib2 and airoha_foe_mac_info_common
> overwrite in airoha_ppe_foe_commit_subflow_entry routine.
I'd lean towards splitting this into two patches. One to address the issue
described above, and one to address the issue described below.
> Moreover, set
> AIROHA_FOE_MAC_SMAC_ID to 0xf in airoha_ppe_foe_commit_subflow_entry()
> to configure the PPE module to keep original source mac address of the
> bridged packets.
>
> Fixes: cd53f622611f ("net: airoha: Add L2 hw acceleration support")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] net: airoha: Initialize PPE UPDMEM source-mac table
2025-05-30 18:05 ` Simon Horman
@ 2025-06-02 17:51 ` Lorenzo Bianconi
0 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Bianconi @ 2025-06-02 17:51 UTC (permalink / raw)
To: Simon Horman
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michal Kubiak, linux-arm-kernel, linux-mediatek,
netdev
[-- Attachment #1: Type: text/plain, Size: 787 bytes --]
> On Thu, May 29, 2025 at 05:52:37PM +0200, Lorenzo Bianconi wrote:
> > 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.
>
> Hi Lorenzo,
>
> I think it would be nice to also mention a bit more clearly what (broken)
> behaviour this fixes. Likewise for patch 2/2.
Hi Simon,
sure, I will do it in v2.
Regards,
Lorenzo
>
> >
> > Fixes: 00a7678310fe ("net: airoha: Introduce flowtable offload support")
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>
> ...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 2/2] net: airoha: Fix IPv6 hw acceleration in bridge mode
2025-05-30 18:06 ` Simon Horman
@ 2025-06-02 17:51 ` Lorenzo Bianconi
0 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Bianconi @ 2025-06-02 17:51 UTC (permalink / raw)
To: Simon Horman
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michal Kubiak, linux-arm-kernel, linux-mediatek,
netdev
[-- Attachment #1: Type: text/plain, Size: 887 bytes --]
> On Thu, May 29, 2025 at 05:52:38PM +0200, Lorenzo Bianconi wrote:
> > ib2 and airoha_foe_mac_info_common have not the same offsets in
> > airoha_foe_bridge and airoha_foe_ipv6 structures. Fix IPv6 hw
> > acceleration in bridge mode resolving ib2 and airoha_foe_mac_info_common
> > overwrite in airoha_ppe_foe_commit_subflow_entry routine.
>
> I'd lean towards splitting this into two patches. One to address the issue
> described above, and one to address the issue described below.
ack, I will do in v2.
Regards,
Lorenzo
>
> > Moreover, set
> > AIROHA_FOE_MAC_SMAC_ID to 0xf in airoha_ppe_foe_commit_subflow_entry()
> > to configure the PPE module to keep original source mac address of the
> > bridged packets.
> >
> > Fixes: cd53f622611f ("net: airoha: Add L2 hw acceleration support")
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>
> ...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-06-02 18:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-29 15:52 [PATCH net 0/2] net: airoha: Fix IPv6 hw acceleration Lorenzo Bianconi
2025-05-29 15:52 ` [PATCH net 1/2] net: airoha: Initialize PPE UPDMEM source-mac table Lorenzo Bianconi
2025-05-30 18:05 ` Simon Horman
2025-06-02 17:51 ` Lorenzo Bianconi
2025-05-29 15:52 ` [PATCH net 2/2] net: airoha: Fix IPv6 hw acceleration in bridge mode Lorenzo Bianconi
2025-05-30 18:06 ` Simon Horman
2025-06-02 17:51 ` Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).