Skip to content

Commit 9cb54af

Browse files
fancerPaolo Abeni
authored and
Paolo Abeni
committed
net: stmmac: Fix IP-cores specific MAC capabilities
Here is the list of the MAC capabilities specific to the particular DW MAC IP-cores currently supported by the driver: DW MAC100: MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10 | MAC_100 DW GMAC: MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000 Allwinner sun8i MAC: MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000 DW QoS Eth: MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD if there is more than 1 active Tx/Rx queues: MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10FD | MAC_100FD | MAC_1000FD | MAC_2500FD DW XGMAC: MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_1000FD | MAC_2500FD | MAC_5000FD | MAC_10000FD DW XLGMAC: MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_1000FD | MAC_2500FD | MAC_5000FD | MAC_10000FD | MAC_25000FD | MAC_40000FD | MAC_50000FD | MAC_100000FD As you can see there are only two common capabilities: MAC_ASYM_PAUSE | MAC_SYM_PAUSE. Meanwhile what is currently implemented defines 10/100/1000 link speeds for all IP-cores, which is definitely incorrect for DW MAC100, DW XGMAC and DW XLGMAC devices. Seeing the flow-control is implemented as a callback for each MAC IP-core (see dwmac100_flow_ctrl(), dwmac1000_flow_ctrl(), sun8i_dwmac_flow_ctrl(), etc) and since the MAC-specific setup() method is supposed to be called for each available DW MAC-based device, the capabilities initialization can be freely moved to these setup() functions, thus correctly setting up the MAC-capabilities for each IP-core (including the Allwinner Sun8i). A new stmmac_link::caps field was specifically introduced for that so to have all link-specific info preserved in a single structure. Note the suggested change fixes three earlier commits at a time. The commit 5b0d7d7 ("net: stmmac: Add the missing speeds that XGMAC supports") permitted the 10-100 link speeds and 1G half-duplex mode for DW XGMAC IP-core even though it doesn't support them. The commit df7699c ("net: stmmac: Do not cut down 1G modes") incorrectly added the MAC1000 capability to the DW MAC100 IP-core. Similarly to the DW XGMAC the commit 8a88093 ("net: stmmac: Add XLGMII support") incorrectly permitted the 10-100 link speeds and 1G half-duplex mode for DW XLGMAC IP-core. Fixes: 5b0d7d7 ("net: stmmac: Add the missing speeds that XGMAC supports") Fixes: df7699c ("net: stmmac: Do not cut down 1G modes") Fixes: 8a88093 ("net: stmmac: Add XLGMII support") Suggested-by: Russell King (Oracle) <[email protected]> Signed-off-by: Serge Semin <[email protected]> Reviewed-by: Romain Gantois <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 59c3d6c commit 9cb54af

File tree

7 files changed

+23
-19
lines changed

7 files changed

+23
-19
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

+4-6
Original file line numberDiff line numberDiff line change
@@ -70,14 +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;
74-
7573
if (priv->plat->tx_queues_to_use > 1)
76-
priv->phylink_config.mac_capabilities &=
77-
~(MAC_10HD | MAC_100HD | MAC_1000HD);
74+
priv->hw->link.caps &= ~(MAC_10HD | MAC_100HD | MAC_1000HD);
7875
else
79-
priv->phylink_config.mac_capabilities |=
80-
(MAC_10HD | MAC_100HD | MAC_1000HD);
76+
priv->hw->link.caps |= (MAC_10HD | MAC_100HD | MAC_1000HD);
8177
}
8278

8379
static void dwmac4_rx_queue_enable(struct mac_device_info *hw,
@@ -1385,6 +1381,8 @@ int dwmac4_setup(struct stmmac_priv *priv)
13851381
if (mac->multicast_filter_bins)
13861382
mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
13871383

1384+
mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
1385+
MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD;
13881386
mac->link.duplex = GMAC_CONFIG_DM;
13891387
mac->link.speed10 = GMAC_CONFIG_PS;
13901388
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

+4-3
Original file line numberDiff line numberDiff line change
@@ -1225,12 +1225,11 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
12251225
xpcs_get_interfaces(priv->hw->xpcs,
12261226
priv->phylink_config.supported_interfaces);
12271227

1228-
priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
1229-
MAC_10 | MAC_100 | MAC_1000;
1230-
12311228
/* Get the MAC specific capabilities */
12321229
stmmac_mac_phylink_get_caps(priv);
12331230

1231+
priv->phylink_config.mac_capabilities = priv->hw->link.caps;
1232+
12341233
max_speed = priv->plat->max_speed;
12351234
if (max_speed)
12361235
phylink_limit_mac_speed(&priv->phylink_config, max_speed);
@@ -7344,6 +7343,8 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)
73447343

73457344
stmmac_mac_phylink_get_caps(priv);
73467345

7346+
priv->phylink_config.mac_capabilities = priv->hw->link.caps;
7347+
73477348
max_speed = priv->plat->max_speed;
73487349
if (max_speed)
73497350
phylink_limit_mac_speed(&priv->phylink_config, max_speed);

0 commit comments

Comments
 (0)