Skip to content

Commit 57f1591

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. The main part of the series has already been merged in on v1 stage. The leftover is the cleanup patches which rename stmmac_ops::phylink_get_caps() callback to stmmac_ops::update_caps() and move the MAC-capabilities init/re-init to the phylink MAC-capabilities getter. Link: https://lore.kernel.org/netdev/[email protected]/ Changelog v2: - Add a new patch (Romain): [PATCH net-next v2 1/2] net: stmmac: Rename phylink_get_caps() callback to update_caps() - Resubmit the leftover patches to net-next tree (Paolo). Link: https://lore.kernel.org/netdev/[email protected]/ Changelog v3: - Just resubmit (Jakub). Signed-off-by: Serge Semin <[email protected]> ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 30b3fe0 + f951a64 commit 57f1591

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void dwmac4_core_init(struct mac_device_info *hw,
6868
init_waitqueue_head(&priv->tstamp_busy_wait);
6969
}
7070

71-
static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
71+
static void dwmac4_update_caps(struct stmmac_priv *priv)
7272
{
7373
if (priv->plat->tx_queues_to_use > 1)
7474
priv->hw->link.caps &= ~(MAC_10HD | MAC_100HD | MAC_1000HD);
@@ -1190,7 +1190,7 @@ static void dwmac4_set_hw_vlan_mode(struct mac_device_info *hw)
11901190

11911191
const struct stmmac_ops dwmac4_ops = {
11921192
.core_init = dwmac4_core_init,
1193-
.phylink_get_caps = dwmac4_phylink_get_caps,
1193+
.update_caps = dwmac4_update_caps,
11941194
.set_mac = stmmac_set_mac,
11951195
.rx_ipc = dwmac4_rx_ipc_enable,
11961196
.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1235,7 +1235,7 @@ const struct stmmac_ops dwmac4_ops = {
12351235

12361236
const struct stmmac_ops dwmac410_ops = {
12371237
.core_init = dwmac4_core_init,
1238-
.phylink_get_caps = dwmac4_phylink_get_caps,
1238+
.update_caps = dwmac4_update_caps,
12391239
.set_mac = stmmac_dwmac4_set_mac,
12401240
.rx_ipc = dwmac4_rx_ipc_enable,
12411241
.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1284,7 +1284,7 @@ const struct stmmac_ops dwmac410_ops = {
12841284

12851285
const struct stmmac_ops dwmac510_ops = {
12861286
.core_init = dwmac4_core_init,
1287-
.phylink_get_caps = dwmac4_phylink_get_caps,
1287+
.update_caps = dwmac4_update_caps,
12881288
.set_mac = stmmac_dwmac4_set_mac,
12891289
.rx_ipc = dwmac4_rx_ipc_enable,
12901290
.rx_queue_enable = dwmac4_rx_queue_enable,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ struct stmmac_est;
308308
struct stmmac_ops {
309309
/* MAC core initialization */
310310
void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
311-
/* Get phylink capabilities */
312-
void (*phylink_get_caps)(struct stmmac_priv *priv);
311+
/* Update MAC capabilities */
312+
void (*update_caps)(struct stmmac_priv *priv);
313313
/* Enable the MAC RX/TX */
314314
void (*set_mac)(void __iomem *ioaddr, bool enable);
315315
/* Enable and verify that the IPC module is supported */
@@ -430,8 +430,8 @@ struct stmmac_ops {
430430

431431
#define stmmac_core_init(__priv, __args...) \
432432
stmmac_do_void_callback(__priv, mac, core_init, __args)
433-
#define stmmac_mac_phylink_get_caps(__priv) \
434-
stmmac_do_void_callback(__priv, mac, phylink_get_caps, __priv)
433+
#define stmmac_mac_update_caps(__priv) \
434+
stmmac_do_void_callback(__priv, mac, update_caps, __priv)
435435
#define stmmac_mac_set(__priv, __args...) \
436436
stmmac_do_void_callback(__priv, mac, set_mac, __args)
437437
#define stmmac_rx_ipc(__priv, __args...) \

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
936936
priv->pause, tx_cnt);
937937
}
938938

939+
static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
940+
phy_interface_t interface)
941+
{
942+
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
943+
944+
/* Refresh the MAC-specific capabilities */
945+
stmmac_mac_update_caps(priv);
946+
947+
config->mac_capabilities = priv->hw->link.caps;
948+
949+
if (priv->plat->max_speed)
950+
phylink_limit_mac_speed(config, priv->plat->max_speed);
951+
952+
return config->mac_capabilities;
953+
}
954+
939955
static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
940956
phy_interface_t interface)
941957
{
@@ -1102,6 +1118,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
11021118
}
11031119

11041120
static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
1121+
.mac_get_caps = stmmac_mac_get_caps,
11051122
.mac_select_pcs = stmmac_mac_select_pcs,
11061123
.mac_config = stmmac_mac_config,
11071124
.mac_link_down = stmmac_mac_link_down,
@@ -1201,7 +1218,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
12011218
int mode = priv->plat->phy_interface;
12021219
struct fwnode_handle *fwnode;
12031220
struct phylink *phylink;
1204-
int max_speed;
12051221

12061222
priv->phylink_config.dev = &priv->dev->dev;
12071223
priv->phylink_config.type = PHYLINK_NETDEV;
@@ -1225,15 +1241,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
12251241
xpcs_get_interfaces(priv->hw->xpcs,
12261242
priv->phylink_config.supported_interfaces);
12271243

1228-
/* Get the MAC specific capabilities */
1229-
stmmac_mac_phylink_get_caps(priv);
1230-
1231-
priv->phylink_config.mac_capabilities = priv->hw->link.caps;
1232-
1233-
max_speed = priv->plat->max_speed;
1234-
if (max_speed)
1235-
phylink_limit_mac_speed(&priv->phylink_config, max_speed);
1236-
12371244
fwnode = priv->plat->port_node;
12381245
if (!fwnode)
12391246
fwnode = dev_fwnode(priv->device);
@@ -7329,7 +7336,6 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)
73297336
{
73307337
struct stmmac_priv *priv = netdev_priv(dev);
73317338
int ret = 0, i;
7332-
int max_speed;
73337339

73347340
if (netif_running(dev))
73357341
stmmac_release(dev);
@@ -7343,14 +7349,6 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt)
73437349
priv->rss.table[i] = ethtool_rxfh_indir_default(i,
73447350
rx_cnt);
73457351

7346-
stmmac_mac_phylink_get_caps(priv);
7347-
7348-
priv->phylink_config.mac_capabilities = priv->hw->link.caps;
7349-
7350-
max_speed = priv->plat->max_speed;
7351-
if (max_speed)
7352-
phylink_limit_mac_speed(&priv->phylink_config, max_speed);
7353-
73547352
stmmac_napi_add(dev);
73557353

73567354
if (netif_running(dev))

0 commit comments

Comments
 (0)