diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index d90fd3bc43a..ca60e51c57d 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -668,6 +668,12 @@ vtnet_setup_features(struct vtnet_softc *sc) sc->vtnet_flags |= VTNET_FLAG_MAC; } + if (virtio_with_feature(dev, VIRTIO_NET_F_MTU)) { + sc->vtnet_max_mtu = virtio_read_dev_config_2(dev, + offsetof(struct virtio_net_config, mtu)); + } else + sc->vtnet_max_mtu = VTNET_MAX_MTU; + if (virtio_with_feature(dev, VIRTIO_NET_F_MRG_RXBUF)) { sc->vtnet_flags |= VTNET_FLAG_MRG_RXBUFS; sc->vtnet_hdr_size = sizeof(struct virtio_net_hdr_mrg_rxbuf); @@ -1094,10 +1100,9 @@ vtnet_rx_cluster_size(struct vtnet_softc *sc, int mtu) return (MCLBYTES); /* - * Try to scale the receive mbuf cluster size from the MTU. Without - * the GUEST_TSO[46] features, the VirtIO specification says the - * driver must only be able to receive ~1500 byte frames. But if - * jumbo frames can be transmitted then try to receive jumbo. + * Try to scale the receive mbuf cluster size from the MTU. We + * could also use the VQ size to influence the selected size, + * but that would only matter for very small queues. */ if (vtnet_modern(sc)) { MPASS(sc->vtnet_hdr_size == sizeof(struct virtio_net_hdr_v1)); @@ -1128,7 +1133,7 @@ vtnet_ioctl_mtu(struct vtnet_softc *sc, int mtu) if (ifp->if_mtu == mtu) return (0); - else if (mtu < ETHERMIN || mtu > VTNET_MAX_MTU) + else if (mtu < ETHERMIN || mtu > sc->vtnet_max_mtu) return (EINVAL); ifp->if_mtu = mtu; diff --git a/sys/dev/virtio/network/if_vtnetvar.h b/sys/dev/virtio/network/if_vtnetvar.h index eaf6eaf8d50..29a0dbbb734 100644 --- a/sys/dev/virtio/network/if_vtnetvar.h +++ b/sys/dev/virtio/network/if_vtnetvar.h @@ -164,6 +164,7 @@ struct vtnet_softc { int vtnet_tx_intr_thresh; int vtnet_tx_nsegs; int vtnet_if_flags; + int vtnet_max_mtu; int vtnet_act_vq_pairs; int vtnet_max_vq_pairs; int vtnet_requested_vq_pairs; @@ -297,6 +298,7 @@ CTASSERT(sizeof(struct vtnet_mac_filter) <= PAGE_SIZE); #define VTNET_COMMON_FEATURES \ (VIRTIO_NET_F_MAC | \ VIRTIO_NET_F_STATUS | \ + VIRTIO_NET_F_MTU | \ VIRTIO_NET_F_CTRL_VQ | \ VIRTIO_NET_F_CTRL_RX | \ VIRTIO_NET_F_CTRL_MAC_ADDR | \