Skip to content

Commit e226ead

Browse files
author
Paolo Abeni
committed
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 <[email protected]> Cc: Maxime Coquelin <[email protected]> Cc: Simon Horman <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Chen-Yu Tsai <[email protected]> Cc: Jernej Skrabec <[email protected]> Cc: Samuel Holland <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 24f4c99 + 9cb54af commit e226ead

File tree

7 files changed

+32
-29
lines changed

7 files changed

+32
-29
lines changed

drivers/net/ethernet/stmicro/stmmac/common.h

+1
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ extern const struct stmmac_hwtimestamp stmmac_ptp;
553553
extern const struct stmmac_mode_ops dwmac4_ring_mode_ops;
554554

555555
struct mac_link {
556+
u32 caps;
556557
u32 speed_mask;
557558
u32 speed10;
558559
u32 speed100;

drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

+2
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,8 @@ static struct mac_device_info *sun8i_dwmac_setup(void *ppriv)
10961096

10971097
priv->dev->priv_flags |= IFF_UNICAST_FLT;
10981098

1099+
mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
1100+
MAC_10 | MAC_100 | MAC_1000;
10991101
/* The loopback bit seems to be re-set when link change
11001102
* Simply mask it each time
11011103
* Speed 10/100/1000 are set in BIT(2)/BIT(3)

drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c

+2
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ int dwmac1000_setup(struct stmmac_priv *priv)
539539
if (mac->multicast_filter_bins)
540540
mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
541541

542+
mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
543+
MAC_10 | MAC_100 | MAC_1000;
542544
mac->link.duplex = GMAC_CONTROL_DM;
543545
mac->link.speed10 = GMAC_CONTROL_PS;
544546
mac->link.speed100 = GMAC_CONTROL_PS | GMAC_CONTROL_FES;

drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c

+2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ int dwmac100_setup(struct stmmac_priv *priv)
175175
dev_info(priv->device, "\tDWMAC100\n");
176176

177177
mac->pcsr = priv->ioaddr;
178+
mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
179+
MAC_10 | MAC_100;
178180
mac->link.duplex = MAC_CONTROL_F;
179181
mac->link.speed10 = 0;
180182
mac->link.speed100 = 0;

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ static void dwmac4_core_init(struct mac_device_info *hw,
7070

7171
static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
7272
{
73-
priv->phylink_config.mac_capabilities |= MAC_2500FD;
73+
if (priv->plat->tx_queues_to_use > 1)
74+
priv->hw->link.caps &= ~(MAC_10HD | MAC_100HD | MAC_1000HD);
75+
else
76+
priv->hw->link.caps |= (MAC_10HD | MAC_100HD | MAC_1000HD);
7477
}
7578

7679
static void dwmac4_rx_queue_enable(struct mac_device_info *hw,
@@ -1378,6 +1381,8 @@ int dwmac4_setup(struct stmmac_priv *priv)
13781381
if (mac->multicast_filter_bins)
13791382
mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
13801383

1384+
mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
1385+
MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD;
13811386
mac->link.duplex = GMAC_CONFIG_DM;
13821387
mac->link.speed10 = GMAC_CONFIG_PS;
13831388
mac->link.speed100 = GMAC_CONFIG_FES | GMAC_CONFIG_PS;

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c

+8-10
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ static void dwxgmac2_core_init(struct mac_device_info *hw,
4747
writel(XGMAC_INT_DEFAULT_EN, ioaddr + XGMAC_INT_EN);
4848
}
4949

50-
static void xgmac_phylink_get_caps(struct stmmac_priv *priv)
51-
{
52-
priv->phylink_config.mac_capabilities |= MAC_2500FD | MAC_5000FD |
53-
MAC_10000FD | MAC_25000FD |
54-
MAC_40000FD | MAC_50000FD |
55-
MAC_100000FD;
56-
}
57-
5850
static void dwxgmac2_set_mac(void __iomem *ioaddr, bool enable)
5951
{
6052
u32 tx = readl(ioaddr + XGMAC_TX_CONFIG);
@@ -1540,7 +1532,6 @@ static void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *
15401532

15411533
const struct stmmac_ops dwxgmac210_ops = {
15421534
.core_init = dwxgmac2_core_init,
1543-
.phylink_get_caps = xgmac_phylink_get_caps,
15441535
.set_mac = dwxgmac2_set_mac,
15451536
.rx_ipc = dwxgmac2_rx_ipc,
15461537
.rx_queue_enable = dwxgmac2_rx_queue_enable,
@@ -1601,7 +1592,6 @@ static void dwxlgmac2_rx_queue_enable(struct mac_device_info *hw, u8 mode,
16011592

16021593
const struct stmmac_ops dwxlgmac2_ops = {
16031594
.core_init = dwxgmac2_core_init,
1604-
.phylink_get_caps = xgmac_phylink_get_caps,
16051595
.set_mac = dwxgmac2_set_mac,
16061596
.rx_ipc = dwxgmac2_rx_ipc,
16071597
.rx_queue_enable = dwxlgmac2_rx_queue_enable,
@@ -1661,6 +1651,9 @@ int dwxgmac2_setup(struct stmmac_priv *priv)
16611651
if (mac->multicast_filter_bins)
16621652
mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
16631653

1654+
mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
1655+
MAC_1000FD | MAC_2500FD | MAC_5000FD |
1656+
MAC_10000FD;
16641657
mac->link.duplex = 0;
16651658
mac->link.speed10 = XGMAC_CONFIG_SS_10_MII;
16661659
mac->link.speed100 = XGMAC_CONFIG_SS_100_MII;
@@ -1698,6 +1691,11 @@ int dwxlgmac2_setup(struct stmmac_priv *priv)
16981691
if (mac->multicast_filter_bins)
16991692
mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
17001693

1694+
mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
1695+
MAC_1000FD | MAC_2500FD | MAC_5000FD |
1696+
MAC_10000FD | MAC_25000FD |
1697+
MAC_40000FD | MAC_50000FD |
1698+
MAC_100000FD;
17011699
mac->link.duplex = 0;
17021700
mac->link.speed1000 = XLGMAC_CONFIG_SS_1000;
17031701
mac->link.speed2500 = XLGMAC_CONFIG_SS_2500;

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

+11-18
Original file line numberDiff line numberDiff line change
@@ -1198,17 +1198,6 @@ static int stmmac_init_phy(struct net_device *dev)
11981198
return ret;
11991199
}
12001200

1201-
static void stmmac_set_half_duplex(struct stmmac_priv *priv)
1202-
{
1203-
/* Half-Duplex can only work with single tx queue */
1204-
if (priv->plat->tx_queues_to_use > 1)
1205-
priv->phylink_config.mac_capabilities &=
1206-
~(MAC_10HD | MAC_100HD | MAC_1000HD);
1207-
else
1208-
priv->phylink_config.mac_capabilities |=
1209-
(MAC_10HD | MAC_100HD | MAC_1000HD);
1210-
}
1211-
12121201
static int stmmac_phy_setup(struct stmmac_priv *priv)
12131202
{
12141203
struct stmmac_mdio_bus_data *mdio_bus_data;
@@ -1236,15 +1225,11 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
12361225
xpcs_get_interfaces(priv->hw->xpcs,
12371226
priv->phylink_config.supported_interfaces);
12381227

1239-
priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
1240-
MAC_10FD | MAC_100FD |
1241-
MAC_1000FD;
1242-
1243-
stmmac_set_half_duplex(priv);
1244-
12451228
/* Get the MAC specific capabilities */
12461229
stmmac_mac_phylink_get_caps(priv);
12471230

1231+
priv->phylink_config.mac_capabilities = priv->hw->link.caps;
1232+
12481233
max_speed = priv->plat->max_speed;
12491234
if (max_speed)
12501235
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)
73427327
{
73437328
struct stmmac_priv *priv = netdev_priv(dev);
73447329
int ret = 0, i;
7330+
int max_speed;
73457331

73467332
if (netif_running(dev))
73477333
stmmac_release(dev);
@@ -7355,7 +7341,14 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)
73557341
priv->rss.table[i] = ethtool_rxfh_indir_default(i,
73567342
rx_cnt);
73577343

7358-
stmmac_set_half_duplex(priv);
7344+
stmmac_mac_phylink_get_caps(priv);
7345+
7346+
priv->phylink_config.mac_capabilities = priv->hw->link.caps;
7347+
7348+
max_speed = priv->plat->max_speed;
7349+
if (max_speed)
7350+
phylink_limit_mac_speed(&priv->phylink_config, max_speed);
7351+
73597352
stmmac_napi_add(dev);
73607353

73617354
if (netif_running(dev))

0 commit comments

Comments
 (0)