virtio-net: dynamic network offloads configuration
v4 cover virtio-net: dynamic network offloads configuration
From: Dmitry Fleytman <[email protected]>
This patch implements recently accepted by virtio-spec dynamic offloads configuration feature.
See commit message for details.
V4 changes:
1. Feature definitions re-used for command bitmask
2. Command data made uint64
3. Commit messsages fixed
V3 changes:
1. Compat macro added
2. Feature name beautification
V2 changes:
1. _GUEST_ added to command and feature names
2. Live migration logic fixed
One of recently introduced Windows features (RSC) requires network driver to be able to enable and disable HW LRO offload on the fly without device reinitialization.
Current Virtio specification doesn't support this requirement. The solution proposed by following spec patch is to add a new control command for this purpose.
The same solution may be used in Linux driver for ethtool interface implementation.
Signature · 1 line
1.8.1.4
PATCH v4 1/1 virtio-net: dynamic network offloads configuration
From: Dmitry Fleytman <[email protected]>
Virtio-net driver currently negotiates network offloads on startup via features mechanism and have no ability to disable and re-enable offloads later.
This patch introduced a new control command that allows to configure device network offloads state dynamically. The patch also introduces a new feature flag VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
--- hw/pc.h | 4 +++ hw/virtio-net.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++--------- hw/virtio-net.h | 13 ++++++++ 3 files changed, 99 insertions(+), 15 deletions(-)
hw/pc.h +4 -0
@@ -221,6 +221,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); .property = "vectors",\ /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\ .value = stringify(0xFFFFFFFF),\ + },{ \ + .driver = "virtio-net-pci", \ + .property = "ctrl_guest_offloads", \ + .value = "off", \ },{\ .driver = "e1000",\ .property = "romfile",\
hw/virtio-net.c +82 -15
139 lines not on this page · raw message
hw/virtio-net.h +13 -0
@@ -27,6 +27,8 @@/* The feature bitmap for virtio net */ #define VIRTIO_NET_F_CSUM 0/* Host handles pkts w/ partial csum */ #define VIRTIO_NET_F_GUEST_CSUM 1/* Guest handles pkts w/ partial csum */ +#define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2/* Control channel offload +* configuration support */ #define VIRTIO_NET_F_MAC 5/* Host has given MAC address. */ #define VIRTIO_NET_F_GSO 6/* Host handles pkts w/ any GSO type */ #define VIRTIO_NET_F_GUEST_TSO4 7/* Guest can handle TSOv4 in. */
@@ -182,6 +184,7 @@ typedef struct VirtIONet {uint16_t max_queues;uint16_t curr_queues;size_t config_size; +uint64_t curr_guest_offloads; } VirtIONet;#define VIRTIO_NET_CTRL_MAC 1
@@ -221,6 +224,15 @@ struct virtio_net_ctrl_mq {#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 +/* +* Control network offloads +* +* Dynamic offloads are available with the +* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit. +*/ +#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 +#define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 +#define DEFINE_VIRTIO_NET_FEATURES (_state, _field) \ DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \ DEFINE_PROP_BIT("csum", _state, _field, VIRTIO_NET_F_CSUM, true), \
@@ -241,6 +253,7 @@ struct virtio_net_ctrl_mq {DEFINE_PROP_BIT ("ctrl_vlan" , _state, _field,VIRTIO_NET_F_CTRL_VLAN , true), \DEFINE_PROP_BIT ("ctrl_rx_extra" , _state, _field,VIRTIO_NET_F_CTRL_RX_EXTRA , true), \DEFINE_PROP_BIT ("ctrl_mac_addr" , _state, _field,VIRTIO_NET_F_CTRL_MAC_ADDR , true), \ +DEFINE_PROP_BIT ("ctrl_guest_offloads" , _state, _field,VIRTIO_NET_F_CTRL_GUEST_OFFLOADS , true), \ DEFINE_PROP_BIT("mq", _state, _field, VIRTIO_NET_F_MQ, false)#endif
Signature · 1 line
1.8.1.4