All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] net: stmmac: Fix MAC-capabilities procedure
@ 2024-04-17 14:00 ` Serge Semin
  0 siblings, 0 replies; 14+ messages in thread
From: Serge Semin @ 2024-04-17 14:00 UTC (permalink / raw)
  To: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois
  Cc: Serge Semin, Maxime Coquelin, Simon Horman, Huacai Chen,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, netdev,
	linux-stm32, linux-arm-kernel, linux-sunxi, linux-kernel

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/20240412180340.7965-1-fancer.lancer@gmail.com/
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).

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

Serge Semin (2):
  net: stmmac: Rename phylink_get_caps() callback to update_caps()
  net: stmmac: Move MAC caps init to phylink MAC caps getter

 .../net/ethernet/stmicro/stmmac/dwmac4_core.c |  8 ++---
 drivers/net/ethernet/stmicro/stmmac/hwif.h    |  8 ++---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 36 +++++++++----------
 3 files changed, 25 insertions(+), 27 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH net-next v2 0/2] net: stmmac: Fix MAC-capabilities procedure
@ 2024-04-17 14:00 ` Serge Semin
  0 siblings, 0 replies; 14+ messages in thread
From: Serge Semin @ 2024-04-17 14:00 UTC (permalink / raw)
  To: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois
  Cc: Serge Semin, Maxime Coquelin, Simon Horman, Huacai Chen,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, netdev,
	linux-stm32, linux-arm-kernel, linux-sunxi, linux-kernel

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/20240412180340.7965-1-fancer.lancer@gmail.com/
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).

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

Serge Semin (2):
  net: stmmac: Rename phylink_get_caps() callback to update_caps()
  net: stmmac: Move MAC caps init to phylink MAC caps getter

 .../net/ethernet/stmicro/stmmac/dwmac4_core.c |  8 ++---
 drivers/net/ethernet/stmicro/stmmac/hwif.h    |  8 ++---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 36 +++++++++----------
 3 files changed, 25 insertions(+), 27 deletions(-)

-- 
2.43.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH net-next v2 1/2] net: stmmac: Rename phylink_get_caps() callback to update_caps()
  2024-04-17 14:00 ` Serge Semin
@ 2024-04-17 14:00   ` Serge Semin
  -1 siblings, 0 replies; 14+ messages in thread
From: Serge Semin @ 2024-04-17 14:00 UTC (permalink / raw)
  To: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois, Maxime Coquelin
  Cc: Serge Semin, Simon Horman, Huacai Chen, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, netdev, linux-stm32,
	linux-arm-kernel, linux-sunxi, linux-kernel

Since recent commits the stmmac_ops::phylink_get_caps() callback has no
longer been responsible for the phylink MAC capabilities getting, but
merely updates the MAC capabilities in the mac_device_info::link::caps
field. Rename the callback to comply with the what the method does now.

Signed-off-by: Serge Semin <fancer.lancer@gmail.com>

---

Link: https://lore.kernel.org/netdev/20240412180340.7965-5-fancer.lancer@gmail.com/
Changelog v2:
- This is a new patch created based on the discussion around patch #4 in
  the series above.
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 ++++----
 drivers/net/ethernet/stmicro/stmmac/hwif.h        | 8 ++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index a38226d7cc6a..b25774d69195 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -68,7 +68,7 @@ static void dwmac4_core_init(struct mac_device_info *hw,
 		init_waitqueue_head(&priv->tstamp_busy_wait);
 }
 
-static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
+static void dwmac4_update_caps(struct stmmac_priv *priv)
 {
 	if (priv->plat->tx_queues_to_use > 1)
 		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)
 
 const struct stmmac_ops dwmac4_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
+	.update_caps = dwmac4_update_caps,
 	.set_mac = stmmac_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1235,7 +1235,7 @@ const struct stmmac_ops dwmac4_ops = {
 
 const struct stmmac_ops dwmac410_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
+	.update_caps = dwmac4_update_caps,
 	.set_mac = stmmac_dwmac4_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1284,7 +1284,7 @@ const struct stmmac_ops dwmac410_ops = {
 
 const struct stmmac_ops dwmac510_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
+	.update_caps = dwmac4_update_caps,
 	.set_mac = stmmac_dwmac4_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 7be04b54738b..90384db228b5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -308,8 +308,8 @@ struct stmmac_est;
 struct stmmac_ops {
 	/* MAC core initialization */
 	void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
-	/* Get phylink capabilities */
-	void (*phylink_get_caps)(struct stmmac_priv *priv);
+	/* Update MAC capabilities */
+	void (*update_caps)(struct stmmac_priv *priv);
 	/* Enable the MAC RX/TX */
 	void (*set_mac)(void __iomem *ioaddr, bool enable);
 	/* Enable and verify that the IPC module is supported */
@@ -430,8 +430,8 @@ struct stmmac_ops {
 
 #define stmmac_core_init(__priv, __args...) \
 	stmmac_do_void_callback(__priv, mac, core_init, __args)
-#define stmmac_mac_phylink_get_caps(__priv) \
-	stmmac_do_void_callback(__priv, mac, phylink_get_caps, __priv)
+#define stmmac_mac_update_caps(__priv) \
+	stmmac_do_void_callback(__priv, mac, update_caps, __priv)
 #define stmmac_mac_set(__priv, __args...) \
 	stmmac_do_void_callback(__priv, mac, set_mac, __args)
 #define stmmac_rx_ipc(__priv, __args...) \
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7c6fb14b5555..b810f6b69bf5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1225,8 +1225,8 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 		xpcs_get_interfaces(priv->hw->xpcs,
 				    priv->phylink_config.supported_interfaces);
 
-	/* Get the MAC specific capabilities */
-	stmmac_mac_phylink_get_caps(priv);
+	/* Refresh the MAC-specific capabilities */
+	stmmac_mac_update_caps(priv);
 
 	priv->phylink_config.mac_capabilities = priv->hw->link.caps;
 
@@ -7341,7 +7341,7 @@ 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_mac_phylink_get_caps(priv);
+	stmmac_mac_update_caps(priv);
 
 	priv->phylink_config.mac_capabilities = priv->hw->link.caps;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next v2 1/2] net: stmmac: Rename phylink_get_caps() callback to update_caps()
@ 2024-04-17 14:00   ` Serge Semin
  0 siblings, 0 replies; 14+ messages in thread
From: Serge Semin @ 2024-04-17 14:00 UTC (permalink / raw)
  To: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois, Maxime Coquelin
  Cc: Serge Semin, Simon Horman, Huacai Chen, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, netdev, linux-stm32,
	linux-arm-kernel, linux-sunxi, linux-kernel

Since recent commits the stmmac_ops::phylink_get_caps() callback has no
longer been responsible for the phylink MAC capabilities getting, but
merely updates the MAC capabilities in the mac_device_info::link::caps
field. Rename the callback to comply with the what the method does now.

Signed-off-by: Serge Semin <fancer.lancer@gmail.com>

---

Link: https://lore.kernel.org/netdev/20240412180340.7965-5-fancer.lancer@gmail.com/
Changelog v2:
- This is a new patch created based on the discussion around patch #4 in
  the series above.
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 ++++----
 drivers/net/ethernet/stmicro/stmmac/hwif.h        | 8 ++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index a38226d7cc6a..b25774d69195 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -68,7 +68,7 @@ static void dwmac4_core_init(struct mac_device_info *hw,
 		init_waitqueue_head(&priv->tstamp_busy_wait);
 }
 
-static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
+static void dwmac4_update_caps(struct stmmac_priv *priv)
 {
 	if (priv->plat->tx_queues_to_use > 1)
 		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)
 
 const struct stmmac_ops dwmac4_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
+	.update_caps = dwmac4_update_caps,
 	.set_mac = stmmac_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1235,7 +1235,7 @@ const struct stmmac_ops dwmac4_ops = {
 
 const struct stmmac_ops dwmac410_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
+	.update_caps = dwmac4_update_caps,
 	.set_mac = stmmac_dwmac4_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1284,7 +1284,7 @@ const struct stmmac_ops dwmac410_ops = {
 
 const struct stmmac_ops dwmac510_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
+	.update_caps = dwmac4_update_caps,
 	.set_mac = stmmac_dwmac4_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 7be04b54738b..90384db228b5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -308,8 +308,8 @@ struct stmmac_est;
 struct stmmac_ops {
 	/* MAC core initialization */
 	void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
-	/* Get phylink capabilities */
-	void (*phylink_get_caps)(struct stmmac_priv *priv);
+	/* Update MAC capabilities */
+	void (*update_caps)(struct stmmac_priv *priv);
 	/* Enable the MAC RX/TX */
 	void (*set_mac)(void __iomem *ioaddr, bool enable);
 	/* Enable and verify that the IPC module is supported */
@@ -430,8 +430,8 @@ struct stmmac_ops {
 
 #define stmmac_core_init(__priv, __args...) \
 	stmmac_do_void_callback(__priv, mac, core_init, __args)
-#define stmmac_mac_phylink_get_caps(__priv) \
-	stmmac_do_void_callback(__priv, mac, phylink_get_caps, __priv)
+#define stmmac_mac_update_caps(__priv) \
+	stmmac_do_void_callback(__priv, mac, update_caps, __priv)
 #define stmmac_mac_set(__priv, __args...) \
 	stmmac_do_void_callback(__priv, mac, set_mac, __args)
 #define stmmac_rx_ipc(__priv, __args...) \
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7c6fb14b5555..b810f6b69bf5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1225,8 +1225,8 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 		xpcs_get_interfaces(priv->hw->xpcs,
 				    priv->phylink_config.supported_interfaces);
 
-	/* Get the MAC specific capabilities */
-	stmmac_mac_phylink_get_caps(priv);
+	/* Refresh the MAC-specific capabilities */
+	stmmac_mac_update_caps(priv);
 
 	priv->phylink_config.mac_capabilities = priv->hw->link.caps;
 
@@ -7341,7 +7341,7 @@ 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_mac_phylink_get_caps(priv);
+	stmmac_mac_update_caps(priv);
 
 	priv->phylink_config.mac_capabilities = priv->hw->link.caps;
 
-- 
2.43.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next v2 2/2] net: stmmac: Move MAC caps init to phylink MAC caps getter
  2024-04-17 14:00 ` Serge Semin
@ 2024-04-17 14:00   ` Serge Semin
  -1 siblings, 0 replies; 14+ messages in thread
From: Serge Semin @ 2024-04-17 14:00 UTC (permalink / raw)
  To: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois, Maxime Coquelin
  Cc: Serge Semin, Simon Horman, Huacai Chen, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, netdev, linux-stm32,
	linux-arm-kernel, linux-sunxi, linux-kernel

After a set of recent fixes the stmmac_phy_setup() and
stmmac_reinit_queues() methods have turned to having some duplicated code.
Let's get rid from the duplication by moving the MAC-capabilities
initialization to the PHYLINK MAC-capabilities getter. The getter is
called during each network device interface open/close cycle. So the
MAC-capabilities will be initialized in generic device open procedure and
in case of the Tx/Rx queues re-initialization as the original code
semantics implies.

Signed-off-by: Serge Semin <fancer.lancer@gmail.com>

---

Link: https://lore.kernel.org/netdev/20240412180340.7965-5-fancer.lancer@gmail.com/
Changelog v2:
- Resubmit the patch to net-next separately from the main patchset (Paolo)
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 36 +++++++++----------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b810f6b69bf5..0d6cd1704e6a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
 			priv->pause, tx_cnt);
 }
 
+static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
+					 phy_interface_t interface)
+{
+	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
+
+	/* Refresh the MAC-specific capabilities */
+	stmmac_mac_update_caps(priv);
+
+	config->mac_capabilities = priv->hw->link.caps;
+
+	if (priv->plat->max_speed)
+		phylink_limit_mac_speed(config, priv->plat->max_speed);
+
+	return config->mac_capabilities;
+}
+
 static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
 						 phy_interface_t interface)
 {
@@ -1105,6 +1121,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
 }
 
 static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
+	.mac_get_caps = stmmac_mac_get_caps,
 	.mac_select_pcs = stmmac_mac_select_pcs,
 	.mac_config = stmmac_mac_config,
 	.mac_link_down = stmmac_mac_link_down,
@@ -1204,7 +1221,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 	int mode = priv->plat->phy_interface;
 	struct fwnode_handle *fwnode;
 	struct phylink *phylink;
-	int max_speed;
 
 	priv->phylink_config.dev = &priv->dev->dev;
 	priv->phylink_config.type = PHYLINK_NETDEV;
@@ -1225,15 +1241,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 		xpcs_get_interfaces(priv->hw->xpcs,
 				    priv->phylink_config.supported_interfaces);
 
-	/* Refresh the MAC-specific capabilities */
-	stmmac_mac_update_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);
-
 	fwnode = priv->plat->port_node;
 	if (!fwnode)
 		fwnode = dev_fwnode(priv->device);
@@ -7327,7 +7334,6 @@ 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);
@@ -7341,14 +7347,6 @@ 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_mac_update_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))
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next v2 2/2] net: stmmac: Move MAC caps init to phylink MAC caps getter
@ 2024-04-17 14:00   ` Serge Semin
  0 siblings, 0 replies; 14+ messages in thread
From: Serge Semin @ 2024-04-17 14:00 UTC (permalink / raw)
  To: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois, Maxime Coquelin
  Cc: Serge Semin, Simon Horman, Huacai Chen, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, netdev, linux-stm32,
	linux-arm-kernel, linux-sunxi, linux-kernel

After a set of recent fixes the stmmac_phy_setup() and
stmmac_reinit_queues() methods have turned to having some duplicated code.
Let's get rid from the duplication by moving the MAC-capabilities
initialization to the PHYLINK MAC-capabilities getter. The getter is
called during each network device interface open/close cycle. So the
MAC-capabilities will be initialized in generic device open procedure and
in case of the Tx/Rx queues re-initialization as the original code
semantics implies.

Signed-off-by: Serge Semin <fancer.lancer@gmail.com>

---

Link: https://lore.kernel.org/netdev/20240412180340.7965-5-fancer.lancer@gmail.com/
Changelog v2:
- Resubmit the patch to net-next separately from the main patchset (Paolo)
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 36 +++++++++----------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b810f6b69bf5..0d6cd1704e6a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
 			priv->pause, tx_cnt);
 }
 
+static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
+					 phy_interface_t interface)
+{
+	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
+
+	/* Refresh the MAC-specific capabilities */
+	stmmac_mac_update_caps(priv);
+
+	config->mac_capabilities = priv->hw->link.caps;
+
+	if (priv->plat->max_speed)
+		phylink_limit_mac_speed(config, priv->plat->max_speed);
+
+	return config->mac_capabilities;
+}
+
 static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
 						 phy_interface_t interface)
 {
@@ -1105,6 +1121,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
 }
 
 static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
+	.mac_get_caps = stmmac_mac_get_caps,
 	.mac_select_pcs = stmmac_mac_select_pcs,
 	.mac_config = stmmac_mac_config,
 	.mac_link_down = stmmac_mac_link_down,
@@ -1204,7 +1221,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 	int mode = priv->plat->phy_interface;
 	struct fwnode_handle *fwnode;
 	struct phylink *phylink;
-	int max_speed;
 
 	priv->phylink_config.dev = &priv->dev->dev;
 	priv->phylink_config.type = PHYLINK_NETDEV;
@@ -1225,15 +1241,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 		xpcs_get_interfaces(priv->hw->xpcs,
 				    priv->phylink_config.supported_interfaces);
 
-	/* Refresh the MAC-specific capabilities */
-	stmmac_mac_update_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);
-
 	fwnode = priv->plat->port_node;
 	if (!fwnode)
 		fwnode = dev_fwnode(priv->device);
@@ -7327,7 +7334,6 @@ 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);
@@ -7341,14 +7347,6 @@ 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_mac_update_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))
-- 
2.43.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next v2 1/2] net: stmmac: Rename phylink_get_caps() callback to update_caps()
  2024-04-17 14:00   ` Serge Semin
@ 2024-04-18 11:29     ` Romain Gantois
  -1 siblings, 0 replies; 14+ messages in thread
From: Romain Gantois @ 2024-04-18 11:29 UTC (permalink / raw)
  To: Serge Semin
  Cc: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois, Maxime Coquelin, Simon Horman, Huacai Chen,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, netdev,
	linux-stm32, linux-arm-kernel, linux-sunxi, linux-kernel

On Wed, 17 Apr 2024, Serge Semin wrote:

> Since recent commits the stmmac_ops::phylink_get_caps() callback has no
> longer been responsible for the phylink MAC capabilities getting, but
> merely updates the MAC capabilities in the mac_device_info::link::caps
> field. Rename the callback to comply with the what the method does now.
> 
> Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
> 
> ---
> 
> Link: https://lore.kernel.org/netdev/20240412180340.7965-5-fancer.lancer@gmail.com/
> Changelog v2:
> - This is a new patch created based on the discussion around patch #4 in
>   the series above.
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 ++++----
>  drivers/net/ethernet/stmicro/stmmac/hwif.h        | 8 ++++----
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> index a38226d7cc6a..b25774d69195 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> @@ -68,7 +68,7 @@ static void dwmac4_core_init(struct mac_device_info *hw,
>  		init_waitqueue_head(&priv->tstamp_busy_wait);
>  }
>  
> -static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
> +static void dwmac4_update_caps(struct stmmac_priv *priv)
>  {
>  	if (priv->plat->tx_queues_to_use > 1)
>  		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)
>  
>  const struct stmmac_ops dwmac4_ops = {
>  	.core_init = dwmac4_core_init,
> -	.phylink_get_caps = dwmac4_phylink_get_caps,
> +	.update_caps = dwmac4_update_caps,
>  	.set_mac = stmmac_set_mac,
>  	.rx_ipc = dwmac4_rx_ipc_enable,
>  	.rx_queue_enable = dwmac4_rx_queue_enable,
> @@ -1235,7 +1235,7 @@ const struct stmmac_ops dwmac4_ops = {
>  
>  const struct stmmac_ops dwmac410_ops = {
>  	.core_init = dwmac4_core_init,
> -	.phylink_get_caps = dwmac4_phylink_get_caps,
> +	.update_caps = dwmac4_update_caps,
>  	.set_mac = stmmac_dwmac4_set_mac,
>  	.rx_ipc = dwmac4_rx_ipc_enable,
>  	.rx_queue_enable = dwmac4_rx_queue_enable,
> @@ -1284,7 +1284,7 @@ const struct stmmac_ops dwmac410_ops = {
>  
>  const struct stmmac_ops dwmac510_ops = {
>  	.core_init = dwmac4_core_init,
> -	.phylink_get_caps = dwmac4_phylink_get_caps,
> +	.update_caps = dwmac4_update_caps,
>  	.set_mac = stmmac_dwmac4_set_mac,
>  	.rx_ipc = dwmac4_rx_ipc_enable,
>  	.rx_queue_enable = dwmac4_rx_queue_enable,
> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> index 7be04b54738b..90384db228b5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> @@ -308,8 +308,8 @@ struct stmmac_est;
>  struct stmmac_ops {
>  	/* MAC core initialization */
>  	void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
> -	/* Get phylink capabilities */
> -	void (*phylink_get_caps)(struct stmmac_priv *priv);
> +	/* Update MAC capabilities */
> +	void (*update_caps)(struct stmmac_priv *priv);
>  	/* Enable the MAC RX/TX */
>  	void (*set_mac)(void __iomem *ioaddr, bool enable);
>  	/* Enable and verify that the IPC module is supported */
> @@ -430,8 +430,8 @@ struct stmmac_ops {
>  
>  #define stmmac_core_init(__priv, __args...) \
>  	stmmac_do_void_callback(__priv, mac, core_init, __args)
> -#define stmmac_mac_phylink_get_caps(__priv) \
> -	stmmac_do_void_callback(__priv, mac, phylink_get_caps, __priv)
> +#define stmmac_mac_update_caps(__priv) \
> +	stmmac_do_void_callback(__priv, mac, update_caps, __priv)
>  #define stmmac_mac_set(__priv, __args...) \
>  	stmmac_do_void_callback(__priv, mac, set_mac, __args)
>  #define stmmac_rx_ipc(__priv, __args...) \
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 7c6fb14b5555..b810f6b69bf5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1225,8 +1225,8 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
>  		xpcs_get_interfaces(priv->hw->xpcs,
>  				    priv->phylink_config.supported_interfaces);
>  
> -	/* Get the MAC specific capabilities */
> -	stmmac_mac_phylink_get_caps(priv);
> +	/* Refresh the MAC-specific capabilities */
> +	stmmac_mac_update_caps(priv);
>  
>  	priv->phylink_config.mac_capabilities = priv->hw->link.caps;
>  
> @@ -7341,7 +7341,7 @@ 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_mac_phylink_get_caps(priv);
> +	stmmac_mac_update_caps(priv);
>  
>  	priv->phylink_config.mac_capabilities = priv->hw->link.caps;
>  
> -- 
> 2.43.0
> 
> 

Reviewed-by: Romain Gantois <romain.gantois@bootlin.com>

Thanks,

-- 
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next v2 1/2] net: stmmac: Rename phylink_get_caps() callback to update_caps()
@ 2024-04-18 11:29     ` Romain Gantois
  0 siblings, 0 replies; 14+ messages in thread
From: Romain Gantois @ 2024-04-18 11:29 UTC (permalink / raw)
  To: Serge Semin
  Cc: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois, Maxime Coquelin, Simon Horman, Huacai Chen,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, netdev,
	linux-stm32, linux-arm-kernel, linux-sunxi, linux-kernel

On Wed, 17 Apr 2024, Serge Semin wrote:

> Since recent commits the stmmac_ops::phylink_get_caps() callback has no
> longer been responsible for the phylink MAC capabilities getting, but
> merely updates the MAC capabilities in the mac_device_info::link::caps
> field. Rename the callback to comply with the what the method does now.
> 
> Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
> 
> ---
> 
> Link: https://lore.kernel.org/netdev/20240412180340.7965-5-fancer.lancer@gmail.com/
> Changelog v2:
> - This is a new patch created based on the discussion around patch #4 in
>   the series above.
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 ++++----
>  drivers/net/ethernet/stmicro/stmmac/hwif.h        | 8 ++++----
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> index a38226d7cc6a..b25774d69195 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> @@ -68,7 +68,7 @@ static void dwmac4_core_init(struct mac_device_info *hw,
>  		init_waitqueue_head(&priv->tstamp_busy_wait);
>  }
>  
> -static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
> +static void dwmac4_update_caps(struct stmmac_priv *priv)
>  {
>  	if (priv->plat->tx_queues_to_use > 1)
>  		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)
>  
>  const struct stmmac_ops dwmac4_ops = {
>  	.core_init = dwmac4_core_init,
> -	.phylink_get_caps = dwmac4_phylink_get_caps,
> +	.update_caps = dwmac4_update_caps,
>  	.set_mac = stmmac_set_mac,
>  	.rx_ipc = dwmac4_rx_ipc_enable,
>  	.rx_queue_enable = dwmac4_rx_queue_enable,
> @@ -1235,7 +1235,7 @@ const struct stmmac_ops dwmac4_ops = {
>  
>  const struct stmmac_ops dwmac410_ops = {
>  	.core_init = dwmac4_core_init,
> -	.phylink_get_caps = dwmac4_phylink_get_caps,
> +	.update_caps = dwmac4_update_caps,
>  	.set_mac = stmmac_dwmac4_set_mac,
>  	.rx_ipc = dwmac4_rx_ipc_enable,
>  	.rx_queue_enable = dwmac4_rx_queue_enable,
> @@ -1284,7 +1284,7 @@ const struct stmmac_ops dwmac410_ops = {
>  
>  const struct stmmac_ops dwmac510_ops = {
>  	.core_init = dwmac4_core_init,
> -	.phylink_get_caps = dwmac4_phylink_get_caps,
> +	.update_caps = dwmac4_update_caps,
>  	.set_mac = stmmac_dwmac4_set_mac,
>  	.rx_ipc = dwmac4_rx_ipc_enable,
>  	.rx_queue_enable = dwmac4_rx_queue_enable,
> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> index 7be04b54738b..90384db228b5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> @@ -308,8 +308,8 @@ struct stmmac_est;
>  struct stmmac_ops {
>  	/* MAC core initialization */
>  	void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
> -	/* Get phylink capabilities */
> -	void (*phylink_get_caps)(struct stmmac_priv *priv);
> +	/* Update MAC capabilities */
> +	void (*update_caps)(struct stmmac_priv *priv);
>  	/* Enable the MAC RX/TX */
>  	void (*set_mac)(void __iomem *ioaddr, bool enable);
>  	/* Enable and verify that the IPC module is supported */
> @@ -430,8 +430,8 @@ struct stmmac_ops {
>  
>  #define stmmac_core_init(__priv, __args...) \
>  	stmmac_do_void_callback(__priv, mac, core_init, __args)
> -#define stmmac_mac_phylink_get_caps(__priv) \
> -	stmmac_do_void_callback(__priv, mac, phylink_get_caps, __priv)
> +#define stmmac_mac_update_caps(__priv) \
> +	stmmac_do_void_callback(__priv, mac, update_caps, __priv)
>  #define stmmac_mac_set(__priv, __args...) \
>  	stmmac_do_void_callback(__priv, mac, set_mac, __args)
>  #define stmmac_rx_ipc(__priv, __args...) \
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 7c6fb14b5555..b810f6b69bf5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1225,8 +1225,8 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
>  		xpcs_get_interfaces(priv->hw->xpcs,
>  				    priv->phylink_config.supported_interfaces);
>  
> -	/* Get the MAC specific capabilities */
> -	stmmac_mac_phylink_get_caps(priv);
> +	/* Refresh the MAC-specific capabilities */
> +	stmmac_mac_update_caps(priv);
>  
>  	priv->phylink_config.mac_capabilities = priv->hw->link.caps;
>  
> @@ -7341,7 +7341,7 @@ 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_mac_phylink_get_caps(priv);
> +	stmmac_mac_update_caps(priv);
>  
>  	priv->phylink_config.mac_capabilities = priv->hw->link.caps;
>  
> -- 
> 2.43.0
> 
> 

Reviewed-by: Romain Gantois <romain.gantois@bootlin.com>

Thanks,

-- 
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next v2 2/2] net: stmmac: Move MAC caps init to phylink MAC caps getter
  2024-04-17 14:00   ` Serge Semin
@ 2024-04-18 11:34     ` Romain Gantois
  -1 siblings, 0 replies; 14+ messages in thread
From: Romain Gantois @ 2024-04-18 11:34 UTC (permalink / raw)
  To: Serge Semin
  Cc: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois, Maxime Coquelin, Simon Horman, Huacai Chen,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, netdev,
	linux-stm32, linux-arm-kernel, linux-sunxi, linux-kernel

On Wed, 17 Apr 2024, Serge Semin wrote:

> After a set of recent fixes the stmmac_phy_setup() and
> stmmac_reinit_queues() methods have turned to having some duplicated code.
> Let's get rid from the duplication by moving the MAC-capabilities
> initialization to the PHYLINK MAC-capabilities getter. The getter is
> called during each network device interface open/close cycle. So the
> MAC-capabilities will be initialized in generic device open procedure and
> in case of the Tx/Rx queues re-initialization as the original code
> semantics implies.
> 
> Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
> 
> ---
> 
> Link: https://lore.kernel.org/netdev/20240412180340.7965-5-fancer.lancer@gmail.com/
> Changelog v2:
> - Resubmit the patch to net-next separately from the main patchset (Paolo)
> ---
>  .../net/ethernet/stmicro/stmmac/stmmac_main.c | 36 +++++++++----------
>  1 file changed, 17 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index b810f6b69bf5..0d6cd1704e6a 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
>  			priv->pause, tx_cnt);
>  }
>  
> +static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
> +					 phy_interface_t interface)
> +{
> +	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
> +
> +	/* Refresh the MAC-specific capabilities */
> +	stmmac_mac_update_caps(priv);
> +
> +	config->mac_capabilities = priv->hw->link.caps;
> +
> +	if (priv->plat->max_speed)
> +		phylink_limit_mac_speed(config, priv->plat->max_speed);
> +
> +	return config->mac_capabilities;
> +}
> +
>  static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
>  						 phy_interface_t interface)
>  {
> @@ -1105,6 +1121,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
>  }
>  
>  static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
> +	.mac_get_caps = stmmac_mac_get_caps,
>  	.mac_select_pcs = stmmac_mac_select_pcs,
>  	.mac_config = stmmac_mac_config,
>  	.mac_link_down = stmmac_mac_link_down,
> @@ -1204,7 +1221,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
>  	int mode = priv->plat->phy_interface;
>  	struct fwnode_handle *fwnode;
>  	struct phylink *phylink;
> -	int max_speed;
>  
>  	priv->phylink_config.dev = &priv->dev->dev;
>  	priv->phylink_config.type = PHYLINK_NETDEV;
> @@ -1225,15 +1241,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
>  		xpcs_get_interfaces(priv->hw->xpcs,
>  				    priv->phylink_config.supported_interfaces);
>  
> -	/* Refresh the MAC-specific capabilities */
> -	stmmac_mac_update_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);
> -
>  	fwnode = priv->plat->port_node;
>  	if (!fwnode)
>  		fwnode = dev_fwnode(priv->device);
> @@ -7327,7 +7334,6 @@ 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);
> @@ -7341,14 +7347,6 @@ 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_mac_update_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))
> -- 
> 2.43.0
> 
> 

Reviewed-by: Romain Gantois <romain.gantois@bootlin.com>

Thanks,

-- 
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next v2 2/2] net: stmmac: Move MAC caps init to phylink MAC caps getter
@ 2024-04-18 11:34     ` Romain Gantois
  0 siblings, 0 replies; 14+ messages in thread
From: Romain Gantois @ 2024-04-18 11:34 UTC (permalink / raw)
  To: Serge Semin
  Cc: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Yanteng Si,
	Romain Gantois, Maxime Coquelin, Simon Horman, Huacai Chen,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, netdev,
	linux-stm32, linux-arm-kernel, linux-sunxi, linux-kernel

On Wed, 17 Apr 2024, Serge Semin wrote:

> After a set of recent fixes the stmmac_phy_setup() and
> stmmac_reinit_queues() methods have turned to having some duplicated code.
> Let's get rid from the duplication by moving the MAC-capabilities
> initialization to the PHYLINK MAC-capabilities getter. The getter is
> called during each network device interface open/close cycle. So the
> MAC-capabilities will be initialized in generic device open procedure and
> in case of the Tx/Rx queues re-initialization as the original code
> semantics implies.
> 
> Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
> 
> ---
> 
> Link: https://lore.kernel.org/netdev/20240412180340.7965-5-fancer.lancer@gmail.com/
> Changelog v2:
> - Resubmit the patch to net-next separately from the main patchset (Paolo)
> ---
>  .../net/ethernet/stmicro/stmmac/stmmac_main.c | 36 +++++++++----------
>  1 file changed, 17 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index b810f6b69bf5..0d6cd1704e6a 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
>  			priv->pause, tx_cnt);
>  }
>  
> +static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
> +					 phy_interface_t interface)
> +{
> +	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
> +
> +	/* Refresh the MAC-specific capabilities */
> +	stmmac_mac_update_caps(priv);
> +
> +	config->mac_capabilities = priv->hw->link.caps;
> +
> +	if (priv->plat->max_speed)
> +		phylink_limit_mac_speed(config, priv->plat->max_speed);
> +
> +	return config->mac_capabilities;
> +}
> +
>  static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
>  						 phy_interface_t interface)
>  {
> @@ -1105,6 +1121,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
>  }
>  
>  static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
> +	.mac_get_caps = stmmac_mac_get_caps,
>  	.mac_select_pcs = stmmac_mac_select_pcs,
>  	.mac_config = stmmac_mac_config,
>  	.mac_link_down = stmmac_mac_link_down,
> @@ -1204,7 +1221,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
>  	int mode = priv->plat->phy_interface;
>  	struct fwnode_handle *fwnode;
>  	struct phylink *phylink;
> -	int max_speed;
>  
>  	priv->phylink_config.dev = &priv->dev->dev;
>  	priv->phylink_config.type = PHYLINK_NETDEV;
> @@ -1225,15 +1241,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
>  		xpcs_get_interfaces(priv->hw->xpcs,
>  				    priv->phylink_config.supported_interfaces);
>  
> -	/* Refresh the MAC-specific capabilities */
> -	stmmac_mac_update_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);
> -
>  	fwnode = priv->plat->port_node;
>  	if (!fwnode)
>  		fwnode = dev_fwnode(priv->device);
> @@ -7327,7 +7334,6 @@ 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);
> @@ -7341,14 +7347,6 @@ 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_mac_update_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))
> -- 
> 2.43.0
> 
> 

Reviewed-by: Romain Gantois <romain.gantois@bootlin.com>

Thanks,

-- 
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next v2 0/2] net: stmmac: Fix MAC-capabilities procedure
  2024-04-17 14:00 ` Serge Semin
@ 2024-04-19  1:53   ` Jakub Kicinski
  -1 siblings, 0 replies; 14+ messages in thread
From: Jakub Kicinski @ 2024-04-19  1:53 UTC (permalink / raw)
  To: Serge Semin
  Cc: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Paolo Abeni, Russell King, Yanteng Si, Romain Gantois,
	Maxime Coquelin, Simon Horman, Huacai Chen, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, netdev, linux-stm32,
	linux-arm-kernel, linux-sunxi, linux-kernel

On Wed, 17 Apr 2024 17:00:06 +0300 Serge Semin wrote:
> 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.

According to the build bot it didn't apply at the time of posting :S
It does apply now but the bot doesn't have a "retry now" button.
Could you repost?
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next v2 0/2] net: stmmac: Fix MAC-capabilities procedure
@ 2024-04-19  1:53   ` Jakub Kicinski
  0 siblings, 0 replies; 14+ messages in thread
From: Jakub Kicinski @ 2024-04-19  1:53 UTC (permalink / raw)
  To: Serge Semin
  Cc: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Paolo Abeni, Russell King, Yanteng Si, Romain Gantois,
	Maxime Coquelin, Simon Horman, Huacai Chen, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, netdev, linux-stm32,
	linux-arm-kernel, linux-sunxi, linux-kernel

On Wed, 17 Apr 2024 17:00:06 +0300 Serge Semin wrote:
> 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.

According to the build bot it didn't apply at the time of posting :S
It does apply now but the bot doesn't have a "retry now" button.
Could you repost?
-- 
pw-bot: cr

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next v2 0/2] net: stmmac: Fix MAC-capabilities procedure
  2024-04-19  1:53   ` Jakub Kicinski
@ 2024-04-19  8:58     ` Serge Semin
  -1 siblings, 0 replies; 14+ messages in thread
From: Serge Semin @ 2024-04-19  8:58 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Paolo Abeni, Russell King, Yanteng Si, Romain Gantois,
	Maxime Coquelin, Simon Horman, Huacai Chen, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, netdev, linux-stm32,
	linux-arm-kernel, linux-sunxi, linux-kernel

On Thu, Apr 18, 2024 at 06:53:28PM -0700, Jakub Kicinski wrote:
> On Wed, 17 Apr 2024 17:00:06 +0300 Serge Semin wrote:
> > 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.
> 

> According to the build bot it didn't apply at the time of posting :S

Most likely it happened because the first three patches
https://lore.kernel.org/netdev/20240412180340.7965-1-fancer.lancer@gmail.com/
hadn't been merged in yet back then. They are now.

> It does apply now but the bot doesn't have a "retry now" button.
> Could you repost?

Sure. I'll do that in an instant.

-Serge(y)

> -- 
> pw-bot: cr

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next v2 0/2] net: stmmac: Fix MAC-capabilities procedure
@ 2024-04-19  8:58     ` Serge Semin
  0 siblings, 0 replies; 14+ messages in thread
From: Serge Semin @ 2024-04-19  8:58 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Alexandre Torgue, Jose Abreu, David S. Miller, Eric Dumazet,
	Paolo Abeni, Russell King, Yanteng Si, Romain Gantois,
	Maxime Coquelin, Simon Horman, Huacai Chen, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, netdev, linux-stm32,
	linux-arm-kernel, linux-sunxi, linux-kernel

On Thu, Apr 18, 2024 at 06:53:28PM -0700, Jakub Kicinski wrote:
> On Wed, 17 Apr 2024 17:00:06 +0300 Serge Semin wrote:
> > 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.
> 

> According to the build bot it didn't apply at the time of posting :S

Most likely it happened because the first three patches
https://lore.kernel.org/netdev/20240412180340.7965-1-fancer.lancer@gmail.com/
hadn't been merged in yet back then. They are now.

> It does apply now but the bot doesn't have a "retry now" button.
> Could you repost?

Sure. I'll do that in an instant.

-Serge(y)

> -- 
> pw-bot: cr

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-04-19  8:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 14:00 [PATCH net-next v2 0/2] net: stmmac: Fix MAC-capabilities procedure Serge Semin
2024-04-17 14:00 ` Serge Semin
2024-04-17 14:00 ` [PATCH net-next v2 1/2] net: stmmac: Rename phylink_get_caps() callback to update_caps() Serge Semin
2024-04-17 14:00   ` Serge Semin
2024-04-18 11:29   ` Romain Gantois
2024-04-18 11:29     ` Romain Gantois
2024-04-17 14:00 ` [PATCH net-next v2 2/2] net: stmmac: Move MAC caps init to phylink MAC caps getter Serge Semin
2024-04-17 14:00   ` Serge Semin
2024-04-18 11:34   ` Romain Gantois
2024-04-18 11:34     ` Romain Gantois
2024-04-19  1:53 ` [PATCH net-next v2 0/2] net: stmmac: Fix MAC-capabilities procedure Jakub Kicinski
2024-04-19  1:53   ` Jakub Kicinski
2024-04-19  8:58   ` Serge Semin
2024-04-19  8:58     ` Serge Semin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.