diff mbox series

[net-next,3/3] nfp: add support restart of link auto-negotiation

Message ID 20220921121235.169761-4-simon.horman@corigine.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series nfp: support FEC mode reporting and auto-neg | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 4 maintainers not CCed: edumazet@google.com baowen.zheng@corigine.com louis.peens@corigine.com yinjun.zhang@corigine.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 51 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Simon Horman Sept. 21, 2022, 12:12 p.m. UTC
From: Fei Qin <fei.qin@corigine.com>

Add support restart of link auto-negotiation.
This may be initiated using:

  # ethtool -r <intf>

Signed-off-by: Fei Qin <fei.qin@corigine.com>
Reviewed-by: Louis Peens <louis.peens@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
 .../ethernet/netronome/nfp/nfp_net_ethtool.c  | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)

Comments

Jakub Kicinski Sept. 23, 2022, 12:54 a.m. UTC | #1
On Wed, 21 Sep 2022 14:12:35 +0200 Simon Horman wrote:
> +	err = nfp_port_configure(netdev, false);
> +	if (err) {
> +		netdev_info(netdev, "Link down failed: %d\n", err);
> +		return err;
> +	}
> +
> +	err = nfp_port_configure(netdev, true);
> +	if (err) {
> +		netdev_info(netdev, "Link up failed: %d\n", err);
> +		return err;
> +	}
> +
> +	netdev_info(netdev, "Link reset succeeded\n");
> +	return 0;

This will not do anything if the port is forced up by multi host
or NC-SI.
Yinjun Zhang Sept. 23, 2022, 4:40 a.m. UTC | #2
On Thu, 22 Sep 2022 17:54:53 -0700 Jakub Kicinski wrote:
> On Wed, 21 Sep 2022 14:12:35 +0200 Simon Horman wrote:
> > +
> > +	netdev_info(netdev, "Link reset succeeded\n");
> > +	return 0;
> 
> This will not do anything if the port is forced up by multi host
> or NC-SI.

OK, we're going to do the reset thing as long as it's physically
configured up.
Yinjun Zhang Sept. 23, 2022, 4:52 a.m. UTC | #3
> On Thu, 22 Sep 2022 17:54:53 -0700 Jakub Kicinski wrote:
> > On Wed, 21 Sep 2022 14:12:35 +0200 Simon Horman wrote:
> > > +
> > > +	netdev_info(netdev, "Link reset succeeded\n");
> > > +	return 0;
> >
> > This will not do anything if the port is forced up by multi host
> > or NC-SI.
> 
> OK, we're going to do the reset thing as long as it's physically
> configured up.

Sorry, I may misunderstand, will use ` nfp_eth_set_configured` directly.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
index 00aacc48a7a2..ceda4d0b98bf 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
@@ -228,6 +228,37 @@  nfp_net_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
 	nfp_get_drvinfo(nn->app, nn->pdev, vnic_version, drvinfo);
 }
 
+static int
+nfp_net_nway_reset(struct net_device *netdev)
+{
+	struct nfp_eth_table_port *eth_port;
+	struct nfp_port *port;
+	int err;
+
+	port = nfp_port_from_netdev(netdev);
+	eth_port = nfp_port_get_eth_port(port);
+	if (!eth_port)
+		return -EOPNOTSUPP;
+
+	if (!netif_running(netdev))
+		return 0;
+
+	err = nfp_port_configure(netdev, false);
+	if (err) {
+		netdev_info(netdev, "Link down failed: %d\n", err);
+		return err;
+	}
+
+	err = nfp_port_configure(netdev, true);
+	if (err) {
+		netdev_info(netdev, "Link up failed: %d\n", err);
+		return err;
+	}
+
+	netdev_info(netdev, "Link reset succeeded\n");
+	return 0;
+}
+
 static void
 nfp_app_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
 {
@@ -1854,6 +1885,7 @@  static const struct ethtool_ops nfp_net_ethtool_ops = {
 				     ETHTOOL_COALESCE_MAX_FRAMES |
 				     ETHTOOL_COALESCE_USE_ADAPTIVE,
 	.get_drvinfo		= nfp_net_get_drvinfo,
+	.nway_reset             = nfp_net_nway_reset,
 	.get_link		= ethtool_op_get_link,
 	.get_ringparam		= nfp_net_get_ringparam,
 	.set_ringparam		= nfp_net_set_ringparam,
@@ -1891,6 +1923,7 @@  static const struct ethtool_ops nfp_net_ethtool_ops = {
 
 const struct ethtool_ops nfp_port_ethtool_ops = {
 	.get_drvinfo		= nfp_app_get_drvinfo,
+	.nway_reset             = nfp_net_nway_reset,
 	.get_link		= ethtool_op_get_link,
 	.get_strings		= nfp_port_get_strings,
 	.get_ethtool_stats	= nfp_port_get_stats,