Skip to content

Commit 4b4255e

Browse files
ikhorndavem330
authored andcommitted
net: ethernet: ti: cpsw: restore shaper configuration while down/up
Need to restore shapers configuration after interface was down/up. This is needed as appropriate configuration is still replicated in kernel settings. This only shapers context restore, so vlan configuration should be restored by user if needed, especially for devices with one port where vlan frames are sent via ALE. Reviewed-by: Ilias Apalodimas <[email protected]> Reviewed-by: Grygorii Strashko <[email protected]> Signed-off-by: Ivan Khoronzhuk <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 57d9014 commit 4b4255e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,51 @@ static int cpsw_set_cbs(struct net_device *ndev,
18081808
return ret;
18091809
}
18101810

1811+
static void cpsw_cbs_resume(struct cpsw_slave *slave, struct cpsw_priv *priv)
1812+
{
1813+
int fifo, bw;
1814+
1815+
for (fifo = CPSW_FIFO_SHAPERS_NUM; fifo > 0; fifo--) {
1816+
bw = priv->fifo_bw[fifo];
1817+
if (!bw)
1818+
continue;
1819+
1820+
cpsw_set_fifo_rlimit(priv, fifo, bw);
1821+
}
1822+
}
1823+
1824+
static void cpsw_mqprio_resume(struct cpsw_slave *slave, struct cpsw_priv *priv)
1825+
{
1826+
struct cpsw_common *cpsw = priv->cpsw;
1827+
u32 tx_prio_map = 0;
1828+
int i, tc, fifo;
1829+
u32 tx_prio_rg;
1830+
1831+
if (!priv->mqprio_hw)
1832+
return;
1833+
1834+
for (i = 0; i < 8; i++) {
1835+
tc = netdev_get_prio_tc_map(priv->ndev, i);
1836+
fifo = CPSW_FIFO_SHAPERS_NUM - tc;
1837+
tx_prio_map |= fifo << (4 * i);
1838+
}
1839+
1840+
tx_prio_rg = cpsw->version == CPSW_VERSION_1 ?
1841+
CPSW1_TX_PRI_MAP : CPSW2_TX_PRI_MAP;
1842+
1843+
slave_write(slave, tx_prio_map, tx_prio_rg);
1844+
}
1845+
1846+
/* restore resources after port reset */
1847+
static void cpsw_restore(struct cpsw_priv *priv)
1848+
{
1849+
/* restore MQPRIO offload */
1850+
for_each_slave(priv, cpsw_mqprio_resume, priv);
1851+
1852+
/* restore CBS offload */
1853+
for_each_slave(priv, cpsw_cbs_resume, priv);
1854+
}
1855+
18111856
static int cpsw_ndo_open(struct net_device *ndev)
18121857
{
18131858
struct cpsw_priv *priv = netdev_priv(ndev);
@@ -1887,6 +1932,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
18871932

18881933
}
18891934

1935+
cpsw_restore(priv);
1936+
18901937
/* Enable Interrupt pacing if configured */
18911938
if (cpsw->coal_intvl != 0) {
18921939
struct ethtool_coalesce coal;

0 commit comments

Comments
 (0)