Commit 95201f36 authored by Michael Sit Wei Hong's avatar Michael Sit Wei Hong Committed by David S. Miller

net: stmmac: update MAC capabilities when tx queues are updated

Upon boot up, the driver will configure the MAC capabilities based on
the maximum number of tx and rx queues. When the user changes the
tx queues to single queue, the MAC should be capable of supporting Half
Duplex, but the driver does not update the MAC capabilities when it is
configured so.

Using the stmmac_reinit_queues() to check the number of tx queues
and set the MAC capabilities accordingly.

Fixes: 0366f7e0 ("net: stmmac: add ethtool support for get/set channels")
Cc: <stable@vger.kernel.org> # 5.17+
Signed-off-by: default avatarMichael Sit Wei Hong <michael.wei.hong.sit@intel.com>
Signed-off-by: default avatarGan, Yi Fang <yi.fang.gan@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d2ca43f3
...@@ -1197,6 +1197,17 @@ static int stmmac_init_phy(struct net_device *dev) ...@@ -1197,6 +1197,17 @@ static int stmmac_init_phy(struct net_device *dev)
return ret; return ret;
} }
static void stmmac_set_half_duplex(struct stmmac_priv *priv)
{
/* Half-Duplex can only work with single tx queue */
if (priv->plat->tx_queues_to_use > 1)
priv->phylink_config.mac_capabilities &=
~(MAC_10HD | MAC_100HD | MAC_1000HD);
else
priv->phylink_config.mac_capabilities |=
(MAC_10HD | MAC_100HD | MAC_1000HD);
}
static int stmmac_phy_setup(struct stmmac_priv *priv) static int stmmac_phy_setup(struct stmmac_priv *priv)
{ {
struct stmmac_mdio_bus_data *mdio_bus_data; struct stmmac_mdio_bus_data *mdio_bus_data;
...@@ -1228,10 +1239,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) ...@@ -1228,10 +1239,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
MAC_10FD | MAC_100FD | MAC_10FD | MAC_100FD |
MAC_1000FD; MAC_1000FD;
/* Half-Duplex can only work with single queue */ stmmac_set_half_duplex(priv);
if (priv->plat->tx_queues_to_use <= 1)
priv->phylink_config.mac_capabilities |= MAC_10HD | MAC_100HD |
MAC_1000HD;
/* Get the MAC specific capabilities */ /* Get the MAC specific capabilities */
stmmac_mac_phylink_get_caps(priv); stmmac_mac_phylink_get_caps(priv);
...@@ -7172,6 +7180,7 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt) ...@@ -7172,6 +7180,7 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)
priv->rss.table[i] = ethtool_rxfh_indir_default(i, priv->rss.table[i] = ethtool_rxfh_indir_default(i,
rx_cnt); rx_cnt);
stmmac_set_half_duplex(priv);
stmmac_napi_add(dev); stmmac_napi_add(dev);
if (netif_running(dev)) if (netif_running(dev))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment