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. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D12352
This commit is contained in:
parent
642ec226bb
commit
eb2fe04416
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323728
@ -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;
|
||||
|
@ -188,6 +188,24 @@ hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t *link_status)
|
||||
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)
|
||||
|
@ -41,6 +41,7 @@ int hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr);
|
||||
/* 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,
|
||||
|
@ -2003,6 +2003,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);
|
||||
@ -2159,6 +2160,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) {
|
||||
/*
|
||||
@ -2343,6 +2350,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);
|
||||
@ -3587,6 +3598,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:
|
||||
@ -3650,11 +3662,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
|
||||
|
Loading…
Reference in New Issue
Block a user