svn commit: r324477 - stable/11/sys/dev/hyperv/netvsc
Sepherosa Ziehau
sephe at FreeBSD.org
Tue Oct 10 05:52:30 UTC 2017
Author: sephe
Date: Tue Oct 10 05:52:28 2017
New Revision: 324477
URL: https://svnweb.freebsd.org/changeset/base/324477
Log:
MFC 323728,323729
323728
hyperv/hn: Fix MTU setting
- Add size of an ethernet header to the value configured to NVS. This
does not seem to have any effects if MTU is 1500, but fix hypervisor
side's setting if MTU > 1500.
- Override the MTU setting according to the view from the hypervisor
side.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D12352
323729
hyperv/hn: Incease max supported MTU
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D12365
Modified:
stable/11/sys/dev/hyperv/netvsc/hn_nvs.c
stable/11/sys/dev/hyperv/netvsc/hn_rndis.c
stable/11/sys/dev/hyperv/netvsc/hn_rndis.h
stable/11/sys/dev/hyperv/netvsc/if_hn.c
stable/11/sys/dev/hyperv/netvsc/if_hnvar.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/dev/hyperv/netvsc/hn_nvs.c
==============================================================================
--- stable/11/sys/dev/hyperv/netvsc/hn_nvs.c Tue Oct 10 05:47:10 2017 (r324476)
+++ stable/11/sys/dev/hyperv/netvsc/hn_nvs.c Tue Oct 10 05:52:28 2017 (r324477)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/taskqueue.h>
+#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_media.h>
@@ -503,7 +504,7 @@ hn_nvs_conf_ndis(struct hn_softc *sc, int mtu)
memset(&conf, 0, sizeof(conf));
conf.nvs_type = HN_NVS_TYPE_NDIS_CONF;
- conf.nvs_mtu = mtu;
+ conf.nvs_mtu = mtu + ETHER_HDR_LEN;
conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN;
if (sc->hn_nvs_ver >= HN_NVS_VERSION_5)
conf.nvs_caps |= HN_NVS_NDIS_CONF_SRIOV;
Modified: stable/11/sys/dev/hyperv/netvsc/hn_rndis.c
==============================================================================
--- stable/11/sys/dev/hyperv/netvsc/hn_rndis.c Tue Oct 10 05:47:10 2017 (r324476)
+++ stable/11/sys/dev/hyperv/netvsc/hn_rndis.c Tue Oct 10 05:52:28 2017 (r324477)
@@ -188,6 +188,24 @@ hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t
return (0);
}
+int
+hn_rndis_get_mtu(struct hn_softc *sc, uint32_t *mtu)
+{
+ size_t size;
+ int error;
+
+ size = sizeof(*mtu);
+ error = hn_rndis_query(sc, OID_GEN_MAXIMUM_FRAME_SIZE, NULL, 0,
+ mtu, &size);
+ if (error)
+ return (error);
+ if (size != sizeof(uint32_t)) {
+ if_printf(sc->hn_ifp, "invalid mtu len %zu\n", size);
+ return (EINVAL);
+ }
+ return (0);
+}
+
static const void *
hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t reqlen,
struct hn_nvs_sendctx *sndc, size_t *comp_len)
Modified: stable/11/sys/dev/hyperv/netvsc/hn_rndis.h
==============================================================================
--- stable/11/sys/dev/hyperv/netvsc/hn_rndis.h Tue Oct 10 05:47:10 2017 (r324476)
+++ stable/11/sys/dev/hyperv/netvsc/hn_rndis.h Tue Oct 10 05:52:28 2017 (r324477)
@@ -41,6 +41,7 @@ int hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *
/* link_status: NDIS_MEDIA_STATE_ */
int hn_rndis_get_linkstatus(struct hn_softc *sc,
uint32_t *link_status);
+int hn_rndis_get_mtu(struct hn_softc *sc, uint32_t *mtu);
/* filter: NDIS_PACKET_TYPE_. */
int hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter);
void hn_rndis_rx_ctrl(struct hn_softc *sc, const void *data,
Modified: stable/11/sys/dev/hyperv/netvsc/if_hn.c
==============================================================================
--- stable/11/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 05:47:10 2017 (r324476)
+++ stable/11/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 05:52:28 2017 (r324477)
@@ -1999,6 +1999,7 @@ hn_attach(device_t dev)
uint8_t eaddr[ETHER_ADDR_LEN];
struct ifnet *ifp = NULL;
int error, ring_cnt, tx_ring_cnt;
+ uint32_t mtu;
sc->hn_dev = dev;
sc->hn_prichan = vmbus_get_channel(dev);
@@ -2155,6 +2156,12 @@ hn_attach(device_t dev)
if (error)
goto failed;
+ error = hn_rndis_get_mtu(sc, &mtu);
+ if (error)
+ mtu = ETHERMTU;
+ else if (bootverbose)
+ device_printf(dev, "RNDIS mtu %u\n", mtu);
+
#if __FreeBSD_version >= 1100099
if (sc->hn_rx_ring_inuse > 1) {
/*
@@ -2339,6 +2346,10 @@ hn_attach(device_t dev)
if_printf(ifp, "TSO segcnt %u segsz %u\n",
ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize);
}
+ if (mtu < ETHERMTU) {
+ if_printf(ifp, "fixup mtu %u -> %u\n", ifp->if_mtu, mtu);
+ ifp->if_mtu = mtu;
+ }
/* Inform the upper layer about the long frame support. */
ifp->if_hdrlen = sizeof(struct ether_vlan_header);
@@ -3583,6 +3594,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
int mask, error = 0;
struct ifrsskey *ifrk;
struct ifrsshash *ifrh;
+ uint32_t mtu;
switch (cmd) {
case SIOCSIFMTU:
@@ -3646,11 +3658,23 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
}
+ error = hn_rndis_get_mtu(sc, &mtu);
+ if (error)
+ mtu = ifr->ifr_mtu;
+ else if (bootverbose)
+ if_printf(ifp, "RNDIS mtu %u\n", mtu);
+
/*
* Commit the requested MTU, after the synthetic parts
* have been successfully attached.
*/
- ifp->if_mtu = ifr->ifr_mtu;
+ if (mtu >= ifr->ifr_mtu) {
+ mtu = ifr->ifr_mtu;
+ } else {
+ if_printf(ifp, "fixup mtu %d -> %u\n",
+ ifr->ifr_mtu, mtu);
+ }
+ ifp->if_mtu = mtu;
/*
* Synthetic parts' reattach may change the chimney
Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h
==============================================================================
--- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 05:47:10 2017 (r324476)
+++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 05:52:28 2017 (r324477)
@@ -36,8 +36,7 @@
#define HN_RXBUF_SIZE (16 * 1024 * 1024)
#define HN_RXBUF_SIZE_COMPAT (15 * 1024 * 1024)
-/* Claimed to be 12232B */
-#define HN_MTU_MAX (9 * 1024)
+#define HN_MTU_MAX (65535 - ETHER_ADDR_LEN)
#define HN_TXBR_SIZE (128 * PAGE_SIZE)
#define HN_RXBR_SIZE (128 * PAGE_SIZE)
More information about the svn-src-stable-11
mailing list