[PATCH net-next 1/2] net: airoha: Initialize PPE UPDMEM source-mac table

Lorenzo Bianconi lorenzo at kernel.org
Tue May 27 07:22:57 PDT 2025


> 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.

This patch has now a conflict with the following commit:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=c683e378c0907e66cee939145edf936c254ff1e3

Since this is actually a fix, I can repost targeting net tree as soon as
it is aligned to net-next.

Regards,
Lorenzo

> 
> Fixes: 00a7678310fe ("net: airoha: Introduce flowtable offload support")
> Signed-off-by: Lorenzo Bianconi <lorenzo at 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  | 25 ++++++++++++++++++++++++-
>  drivers/net/ethernet/airoha/airoha_regs.h | 10 ++++++++++
>  4 files changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> index 0d627e511266d94e079e8a87d2f812fb14b4ad07..e4c67c7bbf215d448640f978cd0d9d50abd73644 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.c
> +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> @@ -92,6 +92,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 531a3c49c1562a986111a1ce1c215c8751c16e09..a951246c0171e14497b510d3029fc0a7f891efe6 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.h
> +++ b/drivers/net/ethernet/airoha/airoha_eth.h
> @@ -611,6 +611,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 2d273937f19cf304ab4b821241fdc3ea93604f0e..1d5a04eb82a6645e2b6a22ff4e694275ef1727d8 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));
>  
> @@ -251,6 +252,7 @@ static int airoha_ppe_foe_entry_prepare(struct airoha_eth *eth,
>  		else
>  			pse_port = 2; /* uplink relies on GDM2 loopback */
>  		val |= FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT, pse_port);
> +		smac_id = port->id;
>  	}
>  
>  	if (is_multicast_ether_addr(data->eth.h_dest))
> @@ -285,7 +287,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) {
> @@ -1232,6 +1234,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
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20250527/6bfd262f/attachment.sig>


More information about the linux-arm-kernel mailing list