diff mbox series

[v3] net: ftgmac100: Get link speed and duplex for NC-SI

Message ID 20240827030513.481469-1-jacky_chou@aspeedtech.com (mailing list archive)
State Accepted
Commit e24a6c874601efb3de6e535895dd8e4f56fa98f1
Delegated to: Netdev Maintainers
Headers show
Series [v3] net: ftgmac100: Get link speed and duplex for NC-SI | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 76 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jacky Chou Aug. 27, 2024, 3:05 a.m. UTC
The ethtool of this driver uses the phy API of ethtool
to get the link information from PHY driver.
Because the NC-SI is forced on 100Mbps and full duplex,
the driver connect a fixed-link phy driver for NC-SI.
The ethtool will get the link information from the
fixed-link phy driver.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
v3:
  - Add fixed-link phy device unregister in
    ftgmac100_phy_disconnect().
  - Adjust header and variable sorting.
v2:
  - use static for struct fixed_phy_status ncsi_phy_status
  - Stop phy device at net_device stop when using NC-SI.
  - Start phy device at net_device start when using NC-SI.
---
 drivers/net/ethernet/faraday/ftgmac100.c | 28 ++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

Comments

Jacob Keller Aug. 28, 2024, 9:07 p.m. UTC | #1
On 8/26/2024 8:05 PM, Jacky Chou wrote:
> The ethtool of this driver uses the phy API of ethtool
> to get the link information from PHY driver.
> Because the NC-SI is forced on 100Mbps and full duplex,
> the driver connect a fixed-link phy driver for NC-SI.
> The ethtool will get the link information from the
> fixed-link phy driver.
> 
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> ---

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
patchwork-bot+netdevbpf@kernel.org Aug. 29, 2024, 12:20 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 27 Aug 2024 11:05:13 +0800 you wrote:
> The ethtool of this driver uses the phy API of ethtool
> to get the link information from PHY driver.
> Because the NC-SI is forced on 100Mbps and full duplex,
> the driver connect a fixed-link phy driver for NC-SI.
> The ethtool will get the link information from the
> fixed-link phy driver.
> 
> [...]

Here is the summary with links:
  - [v3] net: ftgmac100: Get link speed and duplex for NC-SI
    https://git.kernel.org/netdev/net-next/c/e24a6c874601

You are awesome, thank you!
Matthieu Baerts (NGI0) Aug. 29, 2024, 10:19 a.m. UTC | #3
Hello,

On 27/08/2024 05:05, Jacky Chou wrote:
> The ethtool of this driver uses the phy API of ethtool
> to get the link information from PHY driver.
> Because the NC-SI is forced on 100Mbps and full duplex,
> the driver connect a fixed-link phy driver for NC-SI.
> The ethtool will get the link information from the
> fixed-link phy driver.

FYI, we got a small conflict when merging 'net' in 'net-next' in the
MPTCP tree due to this patch applied in 'net':

  4186c8d9e6af ("net: ftgmac100: Ensure tx descriptor updates are visible")

and this one from 'net-next':

  e24a6c874601 ("net: ftgmac100: Get link speed and duplex for NC-SI")

----- Generic Message -----
The best is to avoid conflicts between 'net' and 'net-next' trees but if
they cannot be avoided when preparing patches, a note about how to fix
them is much appreciated.

The conflict has been resolved on our side[1] and the resolution we
suggest is attached to this email. Please report any issues linked to
this conflict resolution as it might be used by others. If you worked on
the mentioned patches, don't hesitate to ACK this conflict resolution.
---------------------------

Regarding this conflict, it looks like it was due to a
refactoring/clean-up, removing extra whitespaces a bit everywhere in the
same file, and was surprisingly part of the fix patch applied in 'net'.
The two unrelated changes have been taken to resolve this conflict:
removing the extra space, and adding 'phy_stop(netdev->phydev);' after
the 'err_ncsi' label.

Rerere cache is available in [2].

Cheers,
Matt

[1] https://github.com/multipath-tcp/mptcp_net-next/commit/ecf6b3c48b19
[2] https://github.com/multipath-tcp/mptcp-upstream-rr-cache/commit/20cd
diff mbox series

Patch

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index fddfd1dd5070..444671b8bbe2 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -24,6 +24,7 @@ 
 #include <linux/crc32.h>
 #include <linux/if_vlan.h>
 #include <linux/of_net.h>
+#include <linux/phy_fixed.h>
 #include <net/ip.h>
 #include <net/ncsi.h>
 
@@ -50,6 +51,15 @@ 
 #define FTGMAC_100MHZ		100000000
 #define FTGMAC_25MHZ		25000000
 
+/* For NC-SI to register a fixed-link phy device */
+static struct fixed_phy_status ncsi_phy_status = {
+	.link = 1,
+	.speed = SPEED_100,
+	.duplex = DUPLEX_FULL,
+	.pause = 0,
+	.asym_pause = 0
+};
+
 struct ftgmac100 {
 	/* Registers */
 	struct resource *res;
@@ -1531,7 +1541,8 @@  static int ftgmac100_open(struct net_device *netdev)
 	if (netdev->phydev) {
 		/* If we have a PHY, start polling */
 		phy_start(netdev->phydev);
-	} else if (priv->use_ncsi) {
+	}
+	if (priv->use_ncsi) {
 		/* If using NC-SI, set our carrier on and start the stack */
 		netif_carrier_on(netdev);
 
@@ -1544,6 +1555,7 @@  static int ftgmac100_open(struct net_device *netdev)
 	return 0;
 
  err_ncsi:
+	phy_stop(netdev->phydev);
 	napi_disable(&priv->napi);
 	netif_stop_queue(netdev);
  err_alloc:
@@ -1577,7 +1589,7 @@  static int ftgmac100_stop(struct net_device *netdev)
 	netif_napi_del(&priv->napi);
 	if (netdev->phydev)
 		phy_stop(netdev->phydev);
-	else if (priv->use_ncsi)
+	if (priv->use_ncsi)
 		ncsi_stop_dev(priv->ndev);
 
 	ftgmac100_stop_hw(priv);
@@ -1715,6 +1727,9 @@  static void ftgmac100_phy_disconnect(struct net_device *netdev)
 	phy_disconnect(netdev->phydev);
 	if (of_phy_is_fixed_link(priv->dev->of_node))
 		of_phy_deregister_fixed_link(priv->dev->of_node);
+
+	if (priv->use_ncsi)
+		fixed_phy_unregister(netdev->phydev);
 }
 
 static void ftgmac100_destroy_mdio(struct net_device *netdev)
@@ -1792,6 +1807,7 @@  static int ftgmac100_probe(struct platform_device *pdev)
 	struct resource *res;
 	int irq;
 	struct net_device *netdev;
+	struct phy_device *phydev;
 	struct ftgmac100 *priv;
 	struct device_node *np;
 	int err = 0;
@@ -1879,6 +1895,14 @@  static int ftgmac100_probe(struct platform_device *pdev)
 			err = -EINVAL;
 			goto err_phy_connect;
 		}
+
+		phydev = fixed_phy_register(PHY_POLL, &ncsi_phy_status, NULL);
+		err = phy_connect_direct(netdev, phydev, ftgmac100_adjust_link,
+					 PHY_INTERFACE_MODE_MII);
+		if (err) {
+			dev_err(&pdev->dev, "Connecting PHY failed\n");
+			goto err_phy_connect;
+		}
 	} else if (np && of_phy_is_fixed_link(np)) {
 		struct phy_device *phy;