Skip to content

Commit 6efb026

Browse files
danish-tigregkh
authored andcommitted
net: ti: icssg-prueth: Fix HSR and switch offload Enablement during firwmare reload.
[ Upstream commit 01792bc ] To enable HSR / Switch offload, certain configurations are needed. Currently they are done inside icssg_change_mode(). This function only gets called if we move from one mode to another without bringing the links up / down. Once in HSR / Switch mode, if we bring the links down and bring it back up again. The callback sequence is, - emac_ndo_stop() Firmwares are stopped - emac_ndo_open() Firmwares are loaded In this path icssg_change_mode() doesn't get called and as a result the configurations needed for HSR / Switch is not done. To fix this, put all these configurations in a separate function icssg_enable_fw_offload() and call this from both icssg_change_mode() and emac_ndo_open() Fixes: 5637508 ("net: ti: icssg-prueth: Enable HSR Tx duplication, Tx Tag and Rx Tag offload") Signed-off-by: MD Danish Anwar <danishanwar@ti.com> Link: https://patch.msgid.link/20250814105106.1491871-1-danishanwar@ti.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f97f647 commit 6efb026

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed

drivers/net/ethernet/ti/icssg/icssg_prueth.c

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,44 @@ static void prueth_emac_stop(struct prueth *prueth)
240240
}
241241
}
242242

243+
static void icssg_enable_fw_offload(struct prueth *prueth)
244+
{
245+
struct prueth_emac *emac;
246+
int mac;
247+
248+
for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) {
249+
emac = prueth->emac[mac];
250+
if (prueth->is_hsr_offload_mode) {
251+
if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM)
252+
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE);
253+
else
254+
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE);
255+
}
256+
257+
if (prueth->is_switch_mode || prueth->is_hsr_offload_mode) {
258+
if (netif_running(emac->ndev)) {
259+
icssg_fdb_add_del(emac, eth_stp_addr, prueth->default_vlan,
260+
ICSSG_FDB_ENTRY_P0_MEMBERSHIP |
261+
ICSSG_FDB_ENTRY_P1_MEMBERSHIP |
262+
ICSSG_FDB_ENTRY_P2_MEMBERSHIP |
263+
ICSSG_FDB_ENTRY_BLOCK,
264+
true);
265+
icssg_vtbl_modify(emac, emac->port_vlan | DEFAULT_VID,
266+
BIT(emac->port_id) | DEFAULT_PORT_MASK,
267+
BIT(emac->port_id) | DEFAULT_UNTAG_MASK,
268+
true);
269+
if (prueth->is_hsr_offload_mode)
270+
icssg_vtbl_modify(emac, DEFAULT_VID,
271+
DEFAULT_PORT_MASK,
272+
DEFAULT_UNTAG_MASK, true);
273+
icssg_set_pvid(prueth, emac->port_vlan, emac->port_id);
274+
if (prueth->is_switch_mode)
275+
icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE);
276+
}
277+
}
278+
}
279+
}
280+
243281
static int prueth_emac_common_start(struct prueth *prueth)
244282
{
245283
struct prueth_emac *emac;
@@ -790,6 +828,7 @@ static int emac_ndo_open(struct net_device *ndev)
790828
ret = prueth_emac_common_start(prueth);
791829
if (ret)
792830
goto free_rx_irq;
831+
icssg_enable_fw_offload(prueth);
793832
}
794833

795834
flow_cfg = emac->dram.va + ICSSG_CONFIG_OFFSET + PSI_L_REGULAR_FLOW_ID_BASE_OFFSET;
@@ -1397,44 +1436,15 @@ static int prueth_emac_restart(struct prueth *prueth)
13971436

13981437
static void icssg_change_mode(struct prueth *prueth)
13991438
{
1400-
struct prueth_emac *emac;
1401-
int mac, ret;
1439+
int ret;
14021440

14031441
ret = prueth_emac_restart(prueth);
14041442
if (ret) {
14051443
dev_err(prueth->dev, "Failed to restart the firmwares, aborting the process");
14061444
return;
14071445
}
14081446

1409-
for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) {
1410-
emac = prueth->emac[mac];
1411-
if (prueth->is_hsr_offload_mode) {
1412-
if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM)
1413-
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE);
1414-
else
1415-
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE);
1416-
}
1417-
1418-
if (netif_running(emac->ndev)) {
1419-
icssg_fdb_add_del(emac, eth_stp_addr, prueth->default_vlan,
1420-
ICSSG_FDB_ENTRY_P0_MEMBERSHIP |
1421-
ICSSG_FDB_ENTRY_P1_MEMBERSHIP |
1422-
ICSSG_FDB_ENTRY_P2_MEMBERSHIP |
1423-
ICSSG_FDB_ENTRY_BLOCK,
1424-
true);
1425-
icssg_vtbl_modify(emac, emac->port_vlan | DEFAULT_VID,
1426-
BIT(emac->port_id) | DEFAULT_PORT_MASK,
1427-
BIT(emac->port_id) | DEFAULT_UNTAG_MASK,
1428-
true);
1429-
if (prueth->is_hsr_offload_mode)
1430-
icssg_vtbl_modify(emac, DEFAULT_VID,
1431-
DEFAULT_PORT_MASK,
1432-
DEFAULT_UNTAG_MASK, true);
1433-
icssg_set_pvid(prueth, emac->port_vlan, emac->port_id);
1434-
if (prueth->is_switch_mode)
1435-
icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE);
1436-
}
1437-
}
1447+
icssg_enable_fw_offload(prueth);
14381448
}
14391449

14401450
static int prueth_netdevice_port_link(struct net_device *ndev,

0 commit comments

Comments
 (0)