Skip to content

Commit dcc4d54

Browse files
LorenzoBianconigregkh
authored andcommitted
net: airoha: Fix VIP configuration for AN7583 SoC
[ Upstream commit 1acdfbd ] EN7581 and AN7583 SoCs have different VIP definitions. Introduce get_vip_port callback in airoha_eth_soc_data struct in order to take into account EN7581 and AN7583 VIP register layout and definition differences. Introduce nbq parameter in airoha_gdm_port struct. At the moment nbq is set statically to value previously used in airhoha_set_gdm2_loopback routine and it will be read from device tree in subsequent patches. Fixes: e4e5ce8 ("net: airoha: Add AN7583 SoC support") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://patch.msgid.link/20260412-airoha-7583-vip-fix-v1-1-c35e02b054bb@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ea690b3 commit dcc4d54

2 files changed

Lines changed: 51 additions & 17 deletions

File tree

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,7 @@ static int airoha_set_vip_for_gdm_port(struct airoha_gdm_port *port,
107107
struct airoha_eth *eth = port->qdma->eth;
108108
u32 vip_port;
109109

110-
switch (port->id) {
111-
case AIROHA_GDM3_IDX:
112-
/* FIXME: handle XSI_PCIE1_PORT */
113-
vip_port = XSI_PCIE0_VIP_PORT_MASK;
114-
break;
115-
case AIROHA_GDM4_IDX:
116-
/* FIXME: handle XSI_USB_PORT */
117-
vip_port = XSI_ETH_VIP_PORT_MASK;
118-
break;
119-
default:
120-
return 0;
121-
}
122-
110+
vip_port = eth->soc->ops.get_vip_port(port, port->nbq);
123111
if (enable) {
124112
airoha_fe_set(eth, REG_FE_VIP_PORT_EN, vip_port);
125113
airoha_fe_set(eth, REG_FE_IFC_PORT_EN, vip_port);
@@ -1710,7 +1698,7 @@ static int airoha_dev_set_macaddr(struct net_device *dev, void *p)
17101698
static int airhoha_set_gdm2_loopback(struct airoha_gdm_port *port)
17111699
{
17121700
struct airoha_eth *eth = port->qdma->eth;
1713-
u32 val, pse_port, chan, nbq;
1701+
u32 val, pse_port, chan;
17141702
int src_port;
17151703

17161704
/* Forward the traffic to the proper GDM port */
@@ -1740,9 +1728,7 @@ static int airhoha_set_gdm2_loopback(struct airoha_gdm_port *port)
17401728
airoha_fe_clear(eth, REG_FE_VIP_PORT_EN, BIT(AIROHA_GDM2_IDX));
17411729
airoha_fe_clear(eth, REG_FE_IFC_PORT_EN, BIT(AIROHA_GDM2_IDX));
17421730

1743-
/* XXX: handle XSI_USB_PORT and XSI_PCE1_PORT */
1744-
nbq = port->id == AIROHA_GDM3_IDX && airoha_is_7581(eth) ? 4 : 0;
1745-
src_port = eth->soc->ops.get_src_port_id(port, nbq);
1731+
src_port = eth->soc->ops.get_src_port_id(port, port->nbq);
17461732
if (src_port < 0)
17471733
return src_port;
17481734

@@ -2951,6 +2937,8 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth,
29512937
port->qdma = qdma;
29522938
port->dev = dev;
29532939
port->id = id;
2940+
/* XXX: Read nbq from DTS */
2941+
port->nbq = id == AIROHA_GDM3_IDX && airoha_is_7581(eth) ? 4 : 0;
29542942
eth->ports[p] = port;
29552943

29562944
return airoha_metadata_dst_alloc(port);
@@ -3152,6 +3140,28 @@ static int airoha_en7581_get_src_port_id(struct airoha_gdm_port *port, int nbq)
31523140
return -EINVAL;
31533141
}
31543142

3143+
static u32 airoha_en7581_get_vip_port(struct airoha_gdm_port *port, int nbq)
3144+
{
3145+
switch (port->id) {
3146+
case AIROHA_GDM3_IDX:
3147+
if (nbq == 4)
3148+
return XSI_PCIE0_VIP_PORT_MASK;
3149+
if (nbq == 5)
3150+
return XSI_PCIE1_VIP_PORT_MASK;
3151+
break;
3152+
case AIROHA_GDM4_IDX:
3153+
if (!nbq)
3154+
return XSI_ETH_VIP_PORT_MASK;
3155+
if (nbq == 1)
3156+
return XSI_USB_VIP_PORT_MASK;
3157+
break;
3158+
default:
3159+
break;
3160+
}
3161+
3162+
return 0;
3163+
}
3164+
31553165
static const char * const an7583_xsi_rsts_names[] = {
31563166
"xsi-mac",
31573167
"hsi0-mac",
@@ -3181,13 +3191,34 @@ static int airoha_an7583_get_src_port_id(struct airoha_gdm_port *port, int nbq)
31813191
return -EINVAL;
31823192
}
31833193

3194+
static u32 airoha_an7583_get_vip_port(struct airoha_gdm_port *port, int nbq)
3195+
{
3196+
switch (port->id) {
3197+
case AIROHA_GDM3_IDX:
3198+
if (!nbq)
3199+
return XSI_ETH_VIP_PORT_MASK;
3200+
break;
3201+
case AIROHA_GDM4_IDX:
3202+
if (!nbq)
3203+
return XSI_PCIE0_VIP_PORT_MASK;
3204+
if (nbq == 1)
3205+
return XSI_USB_VIP_PORT_MASK;
3206+
break;
3207+
default:
3208+
break;
3209+
}
3210+
3211+
return 0;
3212+
}
3213+
31843214
static const struct airoha_eth_soc_data en7581_soc_data = {
31853215
.version = 0x7581,
31863216
.xsi_rsts_names = en7581_xsi_rsts_names,
31873217
.num_xsi_rsts = ARRAY_SIZE(en7581_xsi_rsts_names),
31883218
.num_ppe = 2,
31893219
.ops = {
31903220
.get_src_port_id = airoha_en7581_get_src_port_id,
3221+
.get_vip_port = airoha_en7581_get_vip_port,
31913222
},
31923223
};
31933224

@@ -3198,6 +3229,7 @@ static const struct airoha_eth_soc_data an7583_soc_data = {
31983229
.num_ppe = 1,
31993230
.ops = {
32003231
.get_src_port_id = airoha_an7583_get_src_port_id,
3232+
.get_vip_port = airoha_an7583_get_vip_port,
32013233
},
32023234
};
32033235

drivers/net/ethernet/airoha/airoha_eth.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ struct airoha_gdm_port {
536536
struct airoha_qdma *qdma;
537537
struct net_device *dev;
538538
int id;
539+
int nbq;
539540

540541
struct airoha_hw_stats stats;
541542

@@ -576,6 +577,7 @@ struct airoha_eth_soc_data {
576577
int num_ppe;
577578
struct {
578579
int (*get_src_port_id)(struct airoha_gdm_port *port, int nbq);
580+
u32 (*get_vip_port)(struct airoha_gdm_port *port, int nbq);
579581
} ops;
580582
};
581583

0 commit comments

Comments
 (0)