Skip to content

Commit 01792bc

Browse files
danish-tiPaolo Abeni
authored andcommitted
net: ti: icssg-prueth: Fix HSR and switch offload Enablement during firwmare reload.
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 0417adf commit 01792bc

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
@@ -203,6 +203,44 @@ static void prueth_emac_stop(struct prueth *prueth)
203203
}
204204
}
205205

206+
static void icssg_enable_fw_offload(struct prueth *prueth)
207+
{
208+
struct prueth_emac *emac;
209+
int mac;
210+
211+
for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) {
212+
emac = prueth->emac[mac];
213+
if (prueth->is_hsr_offload_mode) {
214+
if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM)
215+
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE);
216+
else
217+
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE);
218+
}
219+
220+
if (prueth->is_switch_mode || prueth->is_hsr_offload_mode) {
221+
if (netif_running(emac->ndev)) {
222+
icssg_fdb_add_del(emac, eth_stp_addr, prueth->default_vlan,
223+
ICSSG_FDB_ENTRY_P0_MEMBERSHIP |
224+
ICSSG_FDB_ENTRY_P1_MEMBERSHIP |
225+
ICSSG_FDB_ENTRY_P2_MEMBERSHIP |
226+
ICSSG_FDB_ENTRY_BLOCK,
227+
true);
228+
icssg_vtbl_modify(emac, emac->port_vlan | DEFAULT_VID,
229+
BIT(emac->port_id) | DEFAULT_PORT_MASK,
230+
BIT(emac->port_id) | DEFAULT_UNTAG_MASK,
231+
true);
232+
if (prueth->is_hsr_offload_mode)
233+
icssg_vtbl_modify(emac, DEFAULT_VID,
234+
DEFAULT_PORT_MASK,
235+
DEFAULT_UNTAG_MASK, true);
236+
icssg_set_pvid(prueth, emac->port_vlan, emac->port_id);
237+
if (prueth->is_switch_mode)
238+
icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE);
239+
}
240+
}
241+
}
242+
}
243+
206244
static int prueth_emac_common_start(struct prueth *prueth)
207245
{
208246
struct prueth_emac *emac;
@@ -753,6 +791,7 @@ static int emac_ndo_open(struct net_device *ndev)
753791
ret = prueth_emac_common_start(prueth);
754792
if (ret)
755793
goto free_rx_irq;
794+
icssg_enable_fw_offload(prueth);
756795
}
757796

758797
flow_cfg = emac->dram.va + ICSSG_CONFIG_OFFSET + PSI_L_REGULAR_FLOW_ID_BASE_OFFSET;
@@ -1360,44 +1399,15 @@ static int prueth_emac_restart(struct prueth *prueth)
13601399

13611400
static void icssg_change_mode(struct prueth *prueth)
13621401
{
1363-
struct prueth_emac *emac;
1364-
int mac, ret;
1402+
int ret;
13651403

13661404
ret = prueth_emac_restart(prueth);
13671405
if (ret) {
13681406
dev_err(prueth->dev, "Failed to restart the firmwares, aborting the process");
13691407
return;
13701408
}
13711409

1372-
for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) {
1373-
emac = prueth->emac[mac];
1374-
if (prueth->is_hsr_offload_mode) {
1375-
if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM)
1376-
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE);
1377-
else
1378-
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE);
1379-
}
1380-
1381-
if (netif_running(emac->ndev)) {
1382-
icssg_fdb_add_del(emac, eth_stp_addr, prueth->default_vlan,
1383-
ICSSG_FDB_ENTRY_P0_MEMBERSHIP |
1384-
ICSSG_FDB_ENTRY_P1_MEMBERSHIP |
1385-
ICSSG_FDB_ENTRY_P2_MEMBERSHIP |
1386-
ICSSG_FDB_ENTRY_BLOCK,
1387-
true);
1388-
icssg_vtbl_modify(emac, emac->port_vlan | DEFAULT_VID,
1389-
BIT(emac->port_id) | DEFAULT_PORT_MASK,
1390-
BIT(emac->port_id) | DEFAULT_UNTAG_MASK,
1391-
true);
1392-
if (prueth->is_hsr_offload_mode)
1393-
icssg_vtbl_modify(emac, DEFAULT_VID,
1394-
DEFAULT_PORT_MASK,
1395-
DEFAULT_UNTAG_MASK, true);
1396-
icssg_set_pvid(prueth, emac->port_vlan, emac->port_id);
1397-
if (prueth->is_switch_mode)
1398-
icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE);
1399-
}
1400-
}
1410+
icssg_enable_fw_offload(prueth);
14011411
}
14021412

14031413
static int prueth_netdevice_port_link(struct net_device *ndev,

0 commit comments

Comments
 (0)