Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144439844
D23987.id69265.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D23987.id69265.diff
View Options
Index: sys/dev/virtio/network/if_vtnet.c
===================================================================
--- sys/dev/virtio/network/if_vtnet.c
+++ sys/dev/virtio/network/if_vtnet.c
@@ -207,6 +207,7 @@
static void vtnet_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static void vtnet_get_hwaddr(struct vtnet_softc *);
static void vtnet_set_hwaddr(struct vtnet_softc *);
+static void vtnet_get_mtu(struct vtnet_softc *sc);
static void vtnet_vlan_tag_remove(struct mbuf *);
static void vtnet_set_rx_process_limit(struct vtnet_softc *);
static void vtnet_set_tx_intr_threshold(struct vtnet_softc *);
@@ -268,6 +269,7 @@
{ VIRTIO_NET_F_CSUM, "TxChecksum" },
{ VIRTIO_NET_F_GUEST_CSUM, "RxChecksum" },
{ VIRTIO_NET_F_MAC, "MacAddress" },
+ { VIRTIO_NET_F_MTU, "MtuAdvice" },
{ VIRTIO_NET_F_GSO, "TxAllGSO" },
{ VIRTIO_NET_F_GUEST_TSO4, "RxTSOv4" },
{ VIRTIO_NET_F_GUEST_TSO6, "RxTSOv6" },
@@ -635,6 +637,10 @@
if (virtio_with_feature(dev, VIRTIO_RING_F_EVENT_IDX))
sc->vtnet_flags |= VTNET_FLAG_EVENT_IDX;
+ if (virtio_with_feature(dev, VIRTIO_NET_F_MTU)) {
+ sc->vtnet_flags |= VTNET_FLAG_MTU;
+ }
+
if (virtio_with_feature(dev, VIRTIO_NET_F_MAC)) {
/* This feature should always be negotiated. */
sc->vtnet_flags |= VTNET_FLAG_MAC;
@@ -977,6 +983,10 @@
ether_ifattach(ifp, sc->vtnet_hwaddr);
+ /* Set intial MTU */
+ vtnet_get_mtu(sc);
+ ifp->if_mtu = sc->vtnet_mtu;
+
if (virtio_with_feature(dev, VIRTIO_NET_F_STATUS))
ifp->if_capabilities |= IFCAP_LINKSTATE;
@@ -3682,6 +3692,22 @@
sc->vtnet_hwaddr[i] = virtio_read_dev_config_1(dev,
offsetof(struct virtio_net_config, mac) + i);
}
+}
+
+static void
+vtnet_get_mtu(struct vtnet_softc *sc)
+{
+ device_t dev;
+
+ dev = sc->vtnet_dev;
+
+ if ((sc->vtnet_flags & VTNET_FLAG_MTU) == 0) {
+ sc->vtnet_mtu = ETHERMTU;
+ return;
+ }
+
+ sc->vtnet_mtu = virtio_read_dev_config_2(dev,
+ offsetof(struct virtio_net_config, mtu));
}
static void
Index: sys/dev/virtio/network/if_vtnetvar.h
===================================================================
--- sys/dev/virtio/network/if_vtnetvar.h
+++ sys/dev/virtio/network/if_vtnetvar.h
@@ -151,6 +151,7 @@
#define VTNET_FLAG_MULTIQ 0x0200
#define VTNET_FLAG_INDIRECT 0x0400
#define VTNET_FLAG_EVENT_IDX 0x0800
+#define VTNET_FLAG_MTU 0x1000
int vtnet_link_active;
int vtnet_hdr_size;
@@ -180,6 +181,7 @@
struct mtx vtnet_mtx;
char vtnet_mtx_name[16];
char vtnet_hwaddr[ETHER_ADDR_LEN];
+ uint16_t vtnet_mtu;
};
/*
@@ -278,6 +280,7 @@
/* Features desired/implemented by this driver. */
#define VTNET_FEATURES \
(VIRTIO_NET_F_MAC | \
+ VIRTIO_NET_F_MTU | \
VIRTIO_NET_F_STATUS | \
VIRTIO_NET_F_CTRL_VQ | \
VIRTIO_NET_F_CTRL_RX | \
Index: sys/dev/virtio/network/virtio_net.h
===================================================================
--- sys/dev/virtio/network/virtio_net.h
+++ sys/dev/virtio/network/virtio_net.h
@@ -36,6 +36,7 @@
/* The feature bitmap for virtio net */
#define VIRTIO_NET_F_CSUM 0x00001 /* Host handles pkts w/ partial csum */
#define VIRTIO_NET_F_GUEST_CSUM 0x00002 /* Guest handles pkts w/ partial csum*/
+#define VIRTIO_NET_F_MTU 0x00008 /* Host has MTU advice */
#define VIRTIO_NET_F_MAC 0x00020 /* Host has given MAC address. */
#define VIRTIO_NET_F_GSO 0x00040 /* Host handles pkts w/ any GSO type */
#define VIRTIO_NET_F_GUEST_TSO4 0x00080 /* Guest can handle TSOv4 in. */
@@ -68,6 +69,7 @@
* Legal values are between 1 and 0x8000.
*/
uint16_t max_virtqueue_pairs;
+ uint16_t mtu;
} __packed;
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 9, 11:10 AM (17 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28500362
Default Alt Text
D23987.id69265.diff (3 KB)
Attached To
Mode
D23987: [if_vtnet] Add VIRTIO_NET_F_MTU flag support.
Attached
Detach File
Event Timeline
Log In to Comment