diff options
| author | Paolo Abeni <pabeni@redhat.com> | 2024-04-16 15:24:57 +0200 | 
|---|---|---|
| committer | Paolo Abeni <pabeni@redhat.com> | 2024-04-16 15:24:58 +0200 | 
| commit | e226eade8f50cda14a353f13777709797c21abf8 (patch) | |
| tree | d07a7bf0c554341794838fc0bdafc0af280375f9 | |
| parent | 24f4c99e00354fd79bc1f6cbca9961adbd2dc81e (diff) | |
| parent | 9cb54af214a7cdc91577ec083e5569f2ce2c86d8 (diff) | |
Merge branch 'net-stmmac-fix-mac-capabilities-procedure'
Serge Semin says:
====================
net: stmmac: Fix MAC-capabilities procedure
The series got born as a result of the discussions around the recent
Yanteng' series adding the Loongson LS7A1000, LS2K1000, LS7A2000, LS2K2000
MACs support:
Link: https://lore.kernel.org/netdev/fu3f6uoakylnb6eijllakeu5i4okcyqq7sfafhp5efaocbsrwe@w74xe7gb6x7p
In particular the Yanteng' patchset needed to implement the Loongson
MAC-specific constraints applied to the link speed and link duplex mode.
As a result of the discussion with Russel the next preliminary patch was
born:
Link: https://lore.kernel.org/netdev/df31e8bcf74b3b4ddb7ddf5a1c371390f16a2ad5.1712917541.git.siyanteng@loongson.cn
The patch above was a temporal solution utilized by Yanteng for further
developments and to move on with the on-going review. This patchset is a
refactored version of that single patch with formatting required for the
fixes patches.
In particular the series starts with fixing the half-duplex-less
constraint currently applied for all IP-cores. In fact it's specific for
the DW QoS Eth only (DW GMAC v4.x/v5.x).
The next patch fixes the MAC-capabilities setting up during the active
Tx/Rx queues re-initialization procedure. Particularly the procedure
missed the max-speed limit thus possibly activating speeds prohibited on
the respective platforms.
Third patch fixes the incorrect MAC-capabilities initialization for DW
MAC100, DW XGMAC and DW XLGMAC devices by moving the correct
initialization to the IP-core specific setup() methods.
That's it for now. Thanks for review and testing in advance.
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-sunxi@lists.linux.dev
Cc: linux-kernel@vger.kernel.org
====================
Link: https://lore.kernel.org/r/20240412180340.7965-1-fancer.lancer@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
7 files changed, 32 insertions, 29 deletions
| diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index a6fefe675ef1..3b7d4ac1e7be 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -553,6 +553,7 @@ extern const struct stmmac_hwtimestamp stmmac_ptp;  extern const struct stmmac_mode_ops dwmac4_ring_mode_ops;  struct mac_link { +	u32 caps;  	u32 speed_mask;  	u32 speed10;  	u32 speed100; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c index b21d99faa2d0..e1b761dcfa1d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c @@ -1096,6 +1096,8 @@ static struct mac_device_info *sun8i_dwmac_setup(void *ppriv)  	priv->dev->priv_flags |= IFF_UNICAST_FLT; +	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | +			 MAC_10 | MAC_100 | MAC_1000;  	/* The loopback bit seems to be re-set when link change  	 * Simply mask it each time  	 * Speed 10/100/1000 are set in BIT(2)/BIT(3) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 3927609abc44..8555299443f4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -539,6 +539,8 @@ int dwmac1000_setup(struct stmmac_priv *priv)  	if (mac->multicast_filter_bins)  		mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins); +	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | +			 MAC_10 | MAC_100 | MAC_1000;  	mac->link.duplex = GMAC_CONTROL_DM;  	mac->link.speed10 = GMAC_CONTROL_PS;  	mac->link.speed100 = GMAC_CONTROL_PS | GMAC_CONTROL_FES; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c index a6e8d7bd9588..7667d103cd0e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c @@ -175,6 +175,8 @@ int dwmac100_setup(struct stmmac_priv *priv)  	dev_info(priv->device, "\tDWMAC100\n");  	mac->pcsr = priv->ioaddr; +	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | +			 MAC_10 | MAC_100;  	mac->link.duplex = MAC_CONTROL_F;  	mac->link.speed10 = 0;  	mac->link.speed100 = 0; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index cef25efbdff9..a38226d7cc6a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -70,7 +70,10 @@ static void dwmac4_core_init(struct mac_device_info *hw,  static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)  { -	priv->phylink_config.mac_capabilities |= MAC_2500FD; +	if (priv->plat->tx_queues_to_use > 1) +		priv->hw->link.caps &= ~(MAC_10HD | MAC_100HD | MAC_1000HD); +	else +		priv->hw->link.caps |= (MAC_10HD | MAC_100HD | MAC_1000HD);  }  static void dwmac4_rx_queue_enable(struct mac_device_info *hw, @@ -1378,6 +1381,8 @@ int dwmac4_setup(struct stmmac_priv *priv)  	if (mac->multicast_filter_bins)  		mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins); +	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | +			 MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD;  	mac->link.duplex = GMAC_CONFIG_DM;  	mac->link.speed10 = GMAC_CONFIG_PS;  	mac->link.speed100 = GMAC_CONFIG_FES | GMAC_CONFIG_PS; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index e841e312077e..f8e7775bb633 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -47,14 +47,6 @@ static void dwxgmac2_core_init(struct mac_device_info *hw,  	writel(XGMAC_INT_DEFAULT_EN, ioaddr + XGMAC_INT_EN);  } -static void xgmac_phylink_get_caps(struct stmmac_priv *priv) -{ -	priv->phylink_config.mac_capabilities |= MAC_2500FD | MAC_5000FD | -						 MAC_10000FD | MAC_25000FD | -						 MAC_40000FD | MAC_50000FD | -						 MAC_100000FD; -} -  static void dwxgmac2_set_mac(void __iomem *ioaddr, bool enable)  {  	u32 tx = readl(ioaddr + XGMAC_TX_CONFIG); @@ -1540,7 +1532,6 @@ static void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *  const struct stmmac_ops dwxgmac210_ops = {  	.core_init = dwxgmac2_core_init, -	.phylink_get_caps = xgmac_phylink_get_caps,  	.set_mac = dwxgmac2_set_mac,  	.rx_ipc = dwxgmac2_rx_ipc,  	.rx_queue_enable = dwxgmac2_rx_queue_enable, @@ -1601,7 +1592,6 @@ static void dwxlgmac2_rx_queue_enable(struct mac_device_info *hw, u8 mode,  const struct stmmac_ops dwxlgmac2_ops = {  	.core_init = dwxgmac2_core_init, -	.phylink_get_caps = xgmac_phylink_get_caps,  	.set_mac = dwxgmac2_set_mac,  	.rx_ipc = dwxgmac2_rx_ipc,  	.rx_queue_enable = dwxlgmac2_rx_queue_enable, @@ -1661,6 +1651,9 @@ int dwxgmac2_setup(struct stmmac_priv *priv)  	if (mac->multicast_filter_bins)  		mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins); +	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | +			 MAC_1000FD | MAC_2500FD | MAC_5000FD | +			 MAC_10000FD;  	mac->link.duplex = 0;  	mac->link.speed10 = XGMAC_CONFIG_SS_10_MII;  	mac->link.speed100 = XGMAC_CONFIG_SS_100_MII; @@ -1698,6 +1691,11 @@ int dwxlgmac2_setup(struct stmmac_priv *priv)  	if (mac->multicast_filter_bins)  		mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins); +	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | +			 MAC_1000FD | MAC_2500FD | MAC_5000FD | +			 MAC_10000FD | MAC_25000FD | +			 MAC_40000FD | MAC_50000FD | +			 MAC_100000FD;  	mac->link.duplex = 0;  	mac->link.speed1000 = XLGMAC_CONFIG_SS_1000;  	mac->link.speed2500 = XLGMAC_CONFIG_SS_2500; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 24cd80490d19..7c6fb14b5555 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1198,17 +1198,6 @@ static int stmmac_init_phy(struct net_device *dev)  	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)  {  	struct stmmac_mdio_bus_data *mdio_bus_data; @@ -1236,15 +1225,11 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)  		xpcs_get_interfaces(priv->hw->xpcs,  				    priv->phylink_config.supported_interfaces); -	priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | -						MAC_10FD | MAC_100FD | -						MAC_1000FD; - -	stmmac_set_half_duplex(priv); -  	/* Get the MAC specific capabilities */  	stmmac_mac_phylink_get_caps(priv); +	priv->phylink_config.mac_capabilities = priv->hw->link.caps; +  	max_speed = priv->plat->max_speed;  	if (max_speed)  		phylink_limit_mac_speed(&priv->phylink_config, max_speed); @@ -7342,6 +7327,7 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)  {  	struct stmmac_priv *priv = netdev_priv(dev);  	int ret = 0, i; +	int max_speed;  	if (netif_running(dev))  		stmmac_release(dev); @@ -7355,7 +7341,14 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)  			priv->rss.table[i] = ethtool_rxfh_indir_default(i,  									rx_cnt); -	stmmac_set_half_duplex(priv); +	stmmac_mac_phylink_get_caps(priv); + +	priv->phylink_config.mac_capabilities = priv->hw->link.caps; + +	max_speed = priv->plat->max_speed; +	if (max_speed) +		phylink_limit_mac_speed(&priv->phylink_config, max_speed); +  	stmmac_napi_add(dev);  	if (netif_running(dev)) | 
