linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] hyperv: Add processing of MTU reduced by the host
@ 2014-11-11 23:27 Haiyang Zhang
  2014-11-12 19:46 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Haiyang Zhang @ 2014-11-11 23:27 UTC (permalink / raw)
  To: davem, netdev
  Cc: haiyangz, kys, olaf, jasowang, linux-kernel, driverdev-devel

If the host uses packet encapsulation feature, the MTU may be reduced by the
host due to headroom reservation for encapsulation. This patch handles this
new MTU value.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/net/hyperv/netvsc.c       |    3 ++-
 drivers/net/hyperv/netvsc_drv.c   |    4 ++--
 drivers/net/hyperv/rndis_filter.c |    9 +++++++++
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 7d76c95..6b46311 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -440,7 +440,8 @@ static int negotiate_nvsp_ver(struct hv_device *device,
 	/* NVSPv2 only: Send NDIS config */
 	memset(init_packet, 0, sizeof(struct nvsp_message));
 	init_packet->hdr.msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG;
-	init_packet->msg.v2_msg.send_ndis_config.mtu = net_device->ndev->mtu;
+	init_packet->msg.v2_msg.send_ndis_config.mtu = net_device->ndev->mtu +
+						       ETH_HLEN;
 	init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q = 1;
 
 	ret = vmbus_sendpacket(device->channel, init_packet,
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 3295e4e..b689f96 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -699,9 +699,9 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 		return -ENODEV;
 
 	if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)
-		limit = NETVSC_MTU;
+		limit = NETVSC_MTU - ETH_HLEN;
 
-	if (mtu < 68 || mtu > limit)
+	if (mtu < ETH_DATA_LEN || mtu > limit)
 		return -EINVAL;
 
 	nvdev->start_remove = true;
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index ccce6f2..7b2c5d1 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -998,6 +998,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 	int t;
 	struct ndis_recv_scale_cap rsscap;
 	u32 rsscap_size = sizeof(struct ndis_recv_scale_cap);
+	u32 mtu, size;
 
 	rndis_device = get_rndis_device();
 	if (!rndis_device)
@@ -1029,6 +1030,14 @@ int rndis_filter_device_add(struct hv_device *dev,
 		return ret;
 	}
 
+	/* Get the MTU from the host */
+	size = sizeof(u32);
+	ret = rndis_filter_query_device(rndis_device,
+					RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE,
+					&mtu, &size);
+	if (ret == 0 && size == sizeof(u32))
+		net_device->ndev->mtu = mtu;
+
 	/* Get the mac address */
 	ret = rndis_filter_query_device_mac(rndis_device);
 	if (ret != 0) {
-- 
1.7.1


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

* Re: [PATCH net-next] hyperv: Add processing of MTU reduced by the host
  2014-11-11 23:27 [PATCH net-next] hyperv: Add processing of MTU reduced by the host Haiyang Zhang
@ 2014-11-12 19:46 ` David Miller
  2014-11-12 20:02   ` Haiyang Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2014-11-12 19:46 UTC (permalink / raw)
  To: haiyangz; +Cc: netdev, kys, olaf, jasowang, linux-kernel, driverdev-devel

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Tue, 11 Nov 2014 15:27:52 -0800

> -	if (mtu < 68 || mtu > limit)
> +	if (mtu < ETH_DATA_LEN || mtu > limit)
>  		return -EINVAL;

This is not correct.

The test is against the minimally supported MTU, which should
be 68 not ETH_DATA_LEN which is 1500.

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

* RE: [PATCH net-next] hyperv: Add processing of MTU reduced by the host
  2014-11-12 19:46 ` David Miller
@ 2014-11-12 20:02   ` Haiyang Zhang
  2014-11-12 20:04     ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Haiyang Zhang @ 2014-11-12 20:02 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, KY Srinivasan, olaf, jasowang, linux-kernel, driverdev-devel



> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Wednesday, November 12, 2014 2:47 PM
> To: Haiyang Zhang
> Cc: netdev@vger.kernel.org; KY Srinivasan; olaf@aepfle.de;
> jasowang@redhat.com; linux-kernel@vger.kernel.org; driverdev-
> devel@linuxdriverproject.org
> Subject: Re: [PATCH net-next] hyperv: Add processing of MTU reduced by
> the host
> 
> From: Haiyang Zhang <haiyangz@microsoft.com>
> Date: Tue, 11 Nov 2014 15:27:52 -0800
> 
> > -	if (mtu < 68 || mtu > limit)
> > +	if (mtu < ETH_DATA_LEN || mtu > limit)
> >  		return -EINVAL;
> 
> This is not correct.
> 
> The test is against the minimally supported MTU, which should
> be 68 not ETH_DATA_LEN which is 1500.

The Hyper-V host doesn't support MTU below 1500. If we try setting MTU to a 
value < 1500, the host will use 1500 automatically and return 1500 in the 
RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE query and guest will also use it. That's 
why I set the lower limit to ETH_DATA_LEN.

Are you suggesting that we keep the 68 as the lower limit, and let the host 
auto-reset it to 1500 when we trying to set an MTU < 1500?

Thanks,
- Haiyang


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

* Re: [PATCH net-next] hyperv: Add processing of MTU reduced by the host
  2014-11-12 20:02   ` Haiyang Zhang
@ 2014-11-12 20:04     ` David Miller
  2014-11-12 20:31       ` Haiyang Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2014-11-12 20:04 UTC (permalink / raw)
  To: haiyangz; +Cc: netdev, kys, olaf, jasowang, linux-kernel, driverdev-devel

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Wed, 12 Nov 2014 20:02:11 +0000

> The Hyper-V host doesn't support MTU below 1500. If we try setting MTU to a 
> value < 1500, the host will use 1500 automatically and return 1500 in the 
> RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE query and guest will also use it. That's 
> why I set the lower limit to ETH_DATA_LEN.
> 
> Are you suggesting that we keep the 68 as the lower limit, and let the host 
> auto-reset it to 1500 when we trying to set an MTU < 1500?

Then you need to add a comment, because without any information or
context that change looks wrong.

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

* RE: [PATCH net-next] hyperv: Add processing of MTU reduced by the host
  2014-11-12 20:04     ` David Miller
@ 2014-11-12 20:31       ` Haiyang Zhang
  0 siblings, 0 replies; 5+ messages in thread
From: Haiyang Zhang @ 2014-11-12 20:31 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, KY Srinivasan, olaf, jasowang, linux-kernel, driverdev-devel



> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Wednesday, November 12, 2014 3:04 PM
> To: Haiyang Zhang
> Cc: netdev@vger.kernel.org; KY Srinivasan; olaf@aepfle.de;
> jasowang@redhat.com; linux-kernel@vger.kernel.org; driverdev-
> devel@linuxdriverproject.org
> Subject: Re: [PATCH net-next] hyperv: Add processing of MTU reduced by
> the host
> 
> From: Haiyang Zhang <haiyangz@microsoft.com>
> Date: Wed, 12 Nov 2014 20:02:11 +0000
> 
> > The Hyper-V host doesn't support MTU below 1500. If we try setting MTU
> to a
> > value < 1500, the host will use 1500 automatically and return 1500 in
> the
> > RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE query and guest will also use it.
> That's
> > why I set the lower limit to ETH_DATA_LEN.
> >
> > Are you suggesting that we keep the 68 as the lower limit, and let the
> host
> > auto-reset it to 1500 when we trying to set an MTU < 1500?
> 
> Then you need to add a comment, because without any information or
> context that change looks wrong.

I will add a comment.
Thanks,
- Haiyang

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

end of thread, other threads:[~2014-11-12 20:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-11 23:27 [PATCH net-next] hyperv: Add processing of MTU reduced by the host Haiyang Zhang
2014-11-12 19:46 ` David Miller
2014-11-12 20:02   ` Haiyang Zhang
2014-11-12 20:04     ` David Miller
2014-11-12 20:31       ` Haiyang Zhang

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).