diff options
author | Haiyang Zhang <haiyangz@microsoft.com> | 2014-11-12 17:07:44 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-12 16:21:36 -0500 |
commit | 4d3c9d37f77566b04216dfc9a6513082002d7a1f (patch) | |
tree | c23efd4874c81912f2ad9a176ba57d74c9ec637a /drivers/net/hyperv | |
parent | 5226cfc500022104d92813ee218608e80f56ead6 (diff) |
hyperv: Add processing of MTU reduced by the host
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/hyperv')
-rw-r--r-- | drivers/net/hyperv/netvsc.c | 3 | ||||
-rw-r--r-- | drivers/net/hyperv/netvsc_drv.c | 5 | ||||
-rw-r--r-- | drivers/net/hyperv/rndis_filter.c | 9 |
3 files changed, 14 insertions, 3 deletions
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 7d76c9523395..6b463117dcac 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, | |||
440 | /* NVSPv2 only: Send NDIS config */ | 440 | /* NVSPv2 only: Send NDIS config */ |
441 | memset(init_packet, 0, sizeof(struct nvsp_message)); | 441 | memset(init_packet, 0, sizeof(struct nvsp_message)); |
442 | init_packet->hdr.msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG; | 442 | init_packet->hdr.msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG; |
443 | init_packet->msg.v2_msg.send_ndis_config.mtu = net_device->ndev->mtu; | 443 | init_packet->msg.v2_msg.send_ndis_config.mtu = net_device->ndev->mtu + |
444 | ETH_HLEN; | ||
444 | init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q = 1; | 445 | init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q = 1; |
445 | 446 | ||
446 | ret = vmbus_sendpacket(device->channel, init_packet, | 447 | ret = vmbus_sendpacket(device->channel, init_packet, |
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 3295e4ee9dbb..15d82eda0baf 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c | |||
@@ -699,9 +699,10 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) | |||
699 | return -ENODEV; | 699 | return -ENODEV; |
700 | 700 | ||
701 | if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) | 701 | if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) |
702 | limit = NETVSC_MTU; | 702 | limit = NETVSC_MTU - ETH_HLEN; |
703 | 703 | ||
704 | if (mtu < 68 || mtu > limit) | 704 | /* Hyper-V hosts don't support MTU < ETH_DATA_LEN (1500) */ |
705 | if (mtu < ETH_DATA_LEN || mtu > limit) | ||
705 | return -EINVAL; | 706 | return -EINVAL; |
706 | 707 | ||
707 | nvdev->start_remove = true; | 708 | nvdev->start_remove = true; |
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index ccce6f24b009..7b2c5d1e9bad 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, | |||
998 | int t; | 998 | int t; |
999 | struct ndis_recv_scale_cap rsscap; | 999 | struct ndis_recv_scale_cap rsscap; |
1000 | u32 rsscap_size = sizeof(struct ndis_recv_scale_cap); | 1000 | u32 rsscap_size = sizeof(struct ndis_recv_scale_cap); |
1001 | u32 mtu, size; | ||
1001 | 1002 | ||
1002 | rndis_device = get_rndis_device(); | 1003 | rndis_device = get_rndis_device(); |
1003 | if (!rndis_device) | 1004 | if (!rndis_device) |
@@ -1029,6 +1030,14 @@ int rndis_filter_device_add(struct hv_device *dev, | |||
1029 | return ret; | 1030 | return ret; |
1030 | } | 1031 | } |
1031 | 1032 | ||
1033 | /* Get the MTU from the host */ | ||
1034 | size = sizeof(u32); | ||
1035 | ret = rndis_filter_query_device(rndis_device, | ||
1036 | RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE, | ||
1037 | &mtu, &size); | ||
1038 | if (ret == 0 && size == sizeof(u32)) | ||
1039 | net_device->ndev->mtu = mtu; | ||
1040 | |||
1032 | /* Get the mac address */ | 1041 | /* Get the mac address */ |
1033 | ret = rndis_filter_query_device_mac(rndis_device); | 1042 | ret = rndis_filter_query_device_mac(rndis_device); |
1034 | if (ret != 0) { | 1043 | if (ret != 0) { |