netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: David Miller <davem@davemloft.net>
Cc: cforno12@linux.vnet.ibm.com, netdev@vger.kernel.org,
	mst@redhat.com, jasowang@redhat.com, haiyangz@microsoft.com,
	sthemmin@microsoft.com, sashal@kernel.org,
	tlfalcon@linux.ibm.com
Subject: Re: [PATCH, net-next, v3, 0/2] net/ethtool: Introduce link_ksettings API for virtual network devices
Date: Thu, 19 Dec 2019 19:58:18 -0800	[thread overview]
Message-ID: <20191219195818.62501eea@hermes.lan> (raw)
In-Reply-To: <20191219.141619.1840874136750249908.davem@davemloft.net>

On Thu, 19 Dec 2019 14:16:19 -0800 (PST)
David Miller <davem@davemloft.net> wrote:

> From: Stephen Hemminger <stephen@networkplumber.org>
> Date: Thu, 19 Dec 2019 13:11:56 -0800
> 
> > I don't think this makes sense for netvsc. The speed and duplex have no
> > meaning, why do you want to allow overriding it? If this is to try and make
> > some dashboard look good; then you aren't seeing the real speed which is
> > what only the host knows. Plus it does take into account the accelerated
> > networking path.  
> 
> Maybe that's the point, userspace has extraneous knowledge it might
> use to set it accurately.
> 
> This helps for bonding/team etc. as well.
> 
> I don't think there is any real harm in allowing to set this, and
> we've done this in the past I think.

The most widely used case with netvsc is using VF to get accelerated networking
in that case real speed and duplex value is reported by the VF device.

Maybe something like the following (COMPLETELY UNTESTED):


diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index eff8fef4f775..111847ca7e8c 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1083,11 +1083,14 @@ static int netvsc_get_link_ksettings(struct net_device *dev,
 				     struct ethtool_link_ksettings *cmd)
 {
 	struct net_device_context *ndc = netdev_priv(dev);
+	struct net_device *vf_netdev = rtnl_dereference(ndc->vf_netdev);
+
+	if (vf_netdev)
+		return __ethtool_get_link_ksettings(vf_netdev, cmd);
 
 	cmd->base.speed = ndc->speed;
 	cmd->base.duplex = ndc->duplex;
 	cmd->base.port = PORT_OTHER;
-
 	return 0;
 }
 
@@ -1095,8 +1098,17 @@ static int netvsc_set_link_ksettings(struct net_device *dev,
 				     const struct ethtool_link_ksettings *cmd)
 {
 	struct net_device_context *ndc = netdev_priv(dev);
+	struct net_device *vf_netdev = rtnl_dereference(ndc->vf_netdev);
 	u32 speed;
 
+	if (vf_netdev) {
+		if (!vf_netdev->ethtool_ops->set_link_ksettings)
+			return -EOPNOTSUPP;
+
+		return vf_netdev->ethtool_ops->set_link_ksettings(vf_netdev,
+								  cmd);
+	}
+
 	speed = cmd->base.speed;
 	if (!ethtool_validate_speed(speed) ||
 	    !ethtool_validate_duplex(cmd->base.duplex) ||
-- 
2.20.1


  parent reply	other threads:[~2019-12-20  3:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-19 19:40 [PATCH, net-next, v3, 0/2] net/ethtool: Introduce link_ksettings API for virtual network devices Cris Forno
2019-12-19 19:40 ` [PATCH, net-next, v3, 1/2] Three virtual devices (ibmveth, virtio_net, and netvsc) all have similar code to set/get link settings and validate ethtool command. To eliminate duplication of code, it is factored out into core/ethtool.c Cris Forno
2019-12-19 22:36   ` Michal Kubecek
2019-12-20  1:26     ` Thomas Falcon
2019-12-20  7:04       ` Michal Kubecek
2020-01-07 17:40         ` Cristobal Forno
2019-12-19 19:40 ` [PATCH, net-next, v3, 2/2] With get/set link settings functions in core/ethtool.c, ibmveth, netvsc, and virtio now use the core's helper function Cris Forno
2019-12-19 21:11 ` [PATCH, net-next, v3, 0/2] net/ethtool: Introduce link_ksettings API for virtual network devices Stephen Hemminger
2019-12-19 22:16   ` David Miller
2019-12-20  3:29     ` Stephen Hemminger
2019-12-20 22:53       ` David Miller
2019-12-20  3:58     ` Stephen Hemminger [this message]
2019-12-20 22:30     ` Stephen Hemminger
  -- strict thread matches above, loose matches on Subject: below --
2019-12-19 20:54 Cris Forno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191219195818.62501eea@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=cforno12@linux.vnet.ibm.com \
    --cc=davem@davemloft.net \
    --cc=haiyangz@microsoft.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=sthemmin@microsoft.com \
    --cc=tlfalcon@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).