Skip to content

Commit a869d3a

Browse files
LorenzoBianconiPaolo Abeni
authored andcommitted
net: airoha: Initialize PPE UPDMEM source-mac table
UPDMEM source-mac table is a key-value map used to store devices mac addresses according to the port identifier. UPDMEM source mac table is used during IPv6 traffic hw acceleration since PPE entries, for space constraints, do not contain the full source mac address but just the identifier in the UPDMEM source-mac table. Configure UPDMEM source-mac table with device mac addresses and set the source-mac ID field for PPE IPv6 entries in order to select the proper device mac address as source mac for L3 IPv6 hw accelerated traffic. Fixes: 00a7678 ("net: airoha: Introduce flowtable offload support") Signed-off-by: Lorenzo Bianconi <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent d3f2a95 commit a869d3a

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ static void airoha_set_macaddr(struct airoha_gdm_port *port, const u8 *addr)
8484
val = (addr[3] << 16) | (addr[4] << 8) | addr[5];
8585
airoha_fe_wr(eth, REG_FE_MAC_LMIN(reg), val);
8686
airoha_fe_wr(eth, REG_FE_MAC_LMAX(reg), val);
87+
88+
airoha_ppe_init_upd_mem(port);
8789
}
8890

8991
static void airoha_set_gdm_port_fwd_cfg(struct airoha_eth *eth, u32 addr,

drivers/net/ethernet/airoha/airoha_eth.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ void airoha_ppe_check_skb(struct airoha_ppe *ppe, struct sk_buff *skb,
614614
int airoha_ppe_setup_tc_block_cb(struct net_device *dev, void *type_data);
615615
int airoha_ppe_init(struct airoha_eth *eth);
616616
void airoha_ppe_deinit(struct airoha_eth *eth);
617+
void airoha_ppe_init_upd_mem(struct airoha_gdm_port *port);
617618
struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
618619
u32 hash);
619620
void airoha_ppe_foe_entry_get_stats(struct airoha_ppe *ppe, u32 hash,

drivers/net/ethernet/airoha/airoha_ppe.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ static int airoha_ppe_foe_entry_prepare(struct airoha_eth *eth,
223223
int dsa_port = airoha_get_dsa_port(&dev);
224224
struct airoha_foe_mac_info_common *l2;
225225
u32 qdata, ports_pad, val;
226+
u8 smac_id = 0xf;
226227

227228
memset(hwe, 0, sizeof(*hwe));
228229

@@ -257,6 +258,8 @@ static int airoha_ppe_foe_entry_prepare(struct airoha_eth *eth,
257258
*/
258259
if (airhoa_is_lan_gdm_port(port))
259260
val |= AIROHA_FOE_IB2_FAST_PATH;
261+
262+
smac_id = port->id;
260263
}
261264

262265
if (is_multicast_ether_addr(data->eth.h_dest))
@@ -291,7 +294,7 @@ static int airoha_ppe_foe_entry_prepare(struct airoha_eth *eth,
291294
hwe->ipv4.l2.src_mac_lo =
292295
get_unaligned_be16(data->eth.h_source + 4);
293296
} else {
294-
l2->src_mac_hi = FIELD_PREP(AIROHA_FOE_MAC_SMAC_ID, 0xf);
297+
l2->src_mac_hi = FIELD_PREP(AIROHA_FOE_MAC_SMAC_ID, smac_id);
295298
}
296299

297300
if (data->vlan.num) {
@@ -1238,6 +1241,27 @@ void airoha_ppe_check_skb(struct airoha_ppe *ppe, struct sk_buff *skb,
12381241
airoha_ppe_foe_insert_entry(ppe, skb, hash);
12391242
}
12401243

1244+
void airoha_ppe_init_upd_mem(struct airoha_gdm_port *port)
1245+
{
1246+
struct airoha_eth *eth = port->qdma->eth;
1247+
struct net_device *dev = port->dev;
1248+
const u8 *addr = dev->dev_addr;
1249+
u32 val;
1250+
1251+
val = (addr[2] << 24) | (addr[3] << 16) | (addr[4] << 8) | addr[5];
1252+
airoha_fe_wr(eth, REG_UPDMEM_DATA(0), val);
1253+
airoha_fe_wr(eth, REG_UPDMEM_CTRL(0),
1254+
FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
1255+
PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
1256+
1257+
val = (addr[0] << 8) | addr[1];
1258+
airoha_fe_wr(eth, REG_UPDMEM_DATA(0), val);
1259+
airoha_fe_wr(eth, REG_UPDMEM_CTRL(0),
1260+
FIELD_PREP(PPE_UPDMEM_ADDR_MASK, port->id) |
1261+
FIELD_PREP(PPE_UPDMEM_OFFSET_MASK, 1) |
1262+
PPE_UPDMEM_WR_MASK | PPE_UPDMEM_REQ_MASK);
1263+
}
1264+
12411265
int airoha_ppe_init(struct airoha_eth *eth)
12421266
{
12431267
struct airoha_ppe *ppe;

drivers/net/ethernet/airoha/airoha_regs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@
313313
#define REG_PPE_RAM_BASE(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x320)
314314
#define REG_PPE_RAM_ENTRY(_m, _n) (REG_PPE_RAM_BASE(_m) + ((_n) << 2))
315315

316+
#define REG_UPDMEM_CTRL(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x370)
317+
#define PPE_UPDMEM_ACK_MASK BIT(31)
318+
#define PPE_UPDMEM_ADDR_MASK GENMASK(11, 8)
319+
#define PPE_UPDMEM_OFFSET_MASK GENMASK(7, 4)
320+
#define PPE_UPDMEM_SEL_MASK GENMASK(3, 2)
321+
#define PPE_UPDMEM_WR_MASK BIT(1)
322+
#define PPE_UPDMEM_REQ_MASK BIT(0)
323+
324+
#define REG_UPDMEM_DATA(_n) (((_n) ? PPE2_BASE : PPE1_BASE) + 0x374)
325+
316326
#define REG_FE_GDM_TX_OK_PKT_CNT_H(_n) (GDM_BASE(_n) + 0x280)
317327
#define REG_FE_GDM_TX_OK_BYTE_CNT_H(_n) (GDM_BASE(_n) + 0x284)
318328
#define REG_FE_GDM_TX_ETH_PKT_CNT_H(_n) (GDM_BASE(_n) + 0x288)

0 commit comments

Comments
 (0)