virtio-spec/net: dynamic network offloads configuration
v4 cover virtio-spec/net: dynamic network offloads configuration
From: Dmitry Fleytman <[email protected]>
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.
Patch for QEMU mainline that implements this specification change attached as well.
Signature · 1 line
1.8.1.4
PATCH v4 2/2 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
PATCH v4 1/2 virtio-spec: dynamic network offloads configuration
In reply to Dmitry FleytmanFrom: 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.
--- virtio-spec.lyx | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+)
virtio-spec.lyx +143 -0
@@ -60,6 +60,7 @@ \author -1930653948 "Amos Kong" \author -608949062 "Rusty Russell,,," \author -385801441 "Cornelia Huck" [email protected] +\author 460276516 "Dmitry Fleytman" [email protected] \author 1112500848 "Rusty Russell" [email protected] \author 1531152142 "Paolo Bonzini,,," \author 1717892615 "Alexey Zaytsev,,,"
@@ -4261,6 +4262,20 @@ VIRTIO_NET_F_GUEST_CSUM \end_inset (1) Guest handles packets with partial checksum +\change_inserted 460276516 1363712169 + +\end_layout + +\begin_layout Description + +\change_inserted 460276516 1363712334 +VIRTIO_NET_F_CTRL_GUEST_OFFLOADS +\begin_inset space ~ +\end_inset + +(2) Control channel offloads reconfiguration support. +\change_unchanged + \end_layout \begin_layout Description
@@ -5675,6 +5690,134 @@ virtqueue_pairs = 1 \end_layout +\begin_layout Subsection* + +\change_inserted 460276516 1363765850 +Offloads State Configuration +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363765861 +If the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature is negotiated, the driver can + send control commands for dynamic offloads state configuration. +\end_layout + +\begin_layout Subsubsection* + +\change_inserted 460276516 1363765928 +Setting offloads state +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363713225 +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +\change_inserted 460276516 1363765996 + +u64 offloads; +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363765997 + +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766044 + +#define VIRTIO_NET_F_GUEST_CSUM 1 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766051 + +#define VIRTIO_NET_F_GUEST_TSO4 7 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766055 + +#define VIRTIO_NET_F_GUEST_TSO6 8 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766064 + +#define VIRTIO_NET_F_GUEST_ECN 9 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766035 + +#define VIRTIO_NET_F_GUEST_UFO 10 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766031 + +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363765865 + +#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363765867 + + #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363766082 +The class VIRTIO_NET_CTRL_GUEST_OFFLOADS has one command: VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET + applies the new offloads configuration. +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363766435 +u64 value passed as command data is a bitmask, bits set define offloads + to be enabled, bits cleared - offloads to be disabled. +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363766757 +There is a corresponding device feature for each offload. + Upon feature negotiation corresponding offload gets enabled to preserve + backward compartibility. +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363766720 +Corresponding feature must be negotiated at startup in order to allow dynamic + change of specific offload state. +\end_layout + \begin_layout Chapter* Appendix D: Block Device \end_layout
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH 1/2 V4] virtio-spec: dynamic network offloads configuration
Il 04/04/2013 09:55, Dmitry Fleytman ha scritto:
Quoted 34 lines
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 flagVIRTIO_NET_F_CTRL_GUEST_OFFLOADS.Signed-off-by Dmitry Fleytman <[email protected]>--- virtio-spec.lyx | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+)virtio-spec.lyx +4
-0@@ -60,6 +60,7 @@ \author -1930653948 "Amos Kong" \author -608949062 "Rusty Russell,,," \author -385801441 "Cornelia Huck" [email protected] +\author 460276516 "Dmitry Fleytman" [email protected] \author 1112500848 "Rusty Russell" [email protected] \author 1531152142 "Paolo Bonzini,,," \author 1717892615 "Alexey Zaytsev,,,"@@ -4261,6 +4262,20 @@ VIRTIO_NET_F_GUEST_CSUM \end_inset (1) Guest handles packets with partial checksum +\change_inserted 460276516 1363712169 + +\end_layout
virtio-spec.lyx VIRTIO_NET_F_GUEST_CSUM · line 4277
Quoted 10 lines
virtio-spec.lyx +10
-0+ +\begin_layout Description + +\change_inserted 460276516 1363712334 +VIRTIO_NET_F_CTRL_GUEST_OFFLOADS +\begin_inset space ~ +\end_inset + +(2) Control channel offloads reconfiguration support. +\change_unchanged
Rusty,
you might have missed this patch because your address was misspelled.
Is there a story behind skipping virtio-net feature bits 2..4?
Paolo
Quoted 139 lines
virtio-spec.lyx +128
-0\end_layout \begin_layout Description@@ -5675,6 +5690,134 @@ virtqueue_pairs = 1 \end_layout +\begin_layout Subsection* + +\change_inserted 460276516 1363765850 +Offloads State Configuration +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363765861 +If the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature is negotiated, the driver can + send control commands for dynamic offloads state configuration. +\end_layout + +\begin_layout Subsubsection* + +\change_inserted 460276516 1363765928 +Setting offloads state +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363713225 +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +\change_inserted 460276516 1363765996 + +u64 offloads; +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363765997 + +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766044 + +#define VIRTIO_NET_F_GUEST_CSUM 1 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766051 + +#define VIRTIO_NET_F_GUEST_TSO4 7 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766055 + +#define VIRTIO_NET_F_GUEST_TSO6 8 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766064 + +#define VIRTIO_NET_F_GUEST_ECN 9 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766035 + +#define VIRTIO_NET_F_GUEST_UFO 10 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363766031 + +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363765865 + +#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 +\end_layout + +\begin_layout Plain Layout + +\change_inserted 460276516 1363765867 + + #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363766082 +The class VIRTIO_NET_CTRL_GUEST_OFFLOADS has one command: VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET + applies the new offloads configuration. +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363766435 +u64 value passed as command data is a bitmask, bits set define offloads + to be enabled, bits cleared - offloads to be disabled. +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363766757 +There is a corresponding device feature for each offload. + Upon feature negotiation corresponding offload gets enabled to preserve + backward compartibility. +\end_layout + +\begin_layout Standard + +\change_inserted 460276516 1363766720 +Corresponding feature must be negotiated at startup in order to allow dynamic + change of specific offload state. +\end_layout + \begin_layout Chapter* Appendix D: Block Device \end_layout
Michael S. Tsirkin
maintainerRe: [Qemu-devel] [PATCH 1/2 V4] virtio-spec: dynamic network offloads configuration
Quoted 48 lines · Paolo Bonzini
Il 04/04/2013 09:55, Dmitry Fleytman ha scritto:
Quoted 34 lines
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 flagVIRTIO_NET_F_CTRL_GUEST_OFFLOADS.Signed-off-by Dmitry Fleytman <[email protected]>--- virtio-spec.lyx | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+)virtio-spec.lyx +4
-0@@ -60,6 +60,7 @@ \author -1930653948 "Amos Kong" \author -608949062 "Rusty Russell,,," \author -385801441 "Cornelia Huck" [email protected] +\author 460276516 "Dmitry Fleytman" [email protected] \author 1112500848 "Rusty Russell" [email protected] \author 1531152142 "Paolo Bonzini,,," \author 1717892615 "Alexey Zaytsev,,,"@@ -4261,6 +4262,20 @@ VIRTIO_NET_F_GUEST_CSUM \end_inset (1) Guest handles packets with partial checksum +\change_inserted 460276516 1363712169 + +\end_layoutvirtio-spec.lyx VIRTIO_NET_F_GUEST_CSUM · line 4277
Quoted 10 lines
virtio-spec.lyx +10
-0+ +\begin_layout Description + +\change_inserted 460276516 1363712334 +VIRTIO_NET_F_CTRL_GUEST_OFFLOADS +\begin_inset space ~ +\end_inset + +(2) Control channel offloads reconfiguration support. +\change_unchangedRusty,
Quoted 1 line
you might have missed this patch because your address was misspelled.
It's commit 721861222802d0ebc48564d727a3684f7b21cadd in
https://github.com/rustyrussell/virtio-spec
Quoted 3 lines
Is there a story behind skipping virtio-net feature bits 2..4?
Paolo
Bits 3-4 now :)
I'm curious too.
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 1/2 V4] virtio-spec: dynamic network offloads configuration
Quoted 7 lines · Michael S. Tsirkin
Quoted 3 lines · Paolo Bonzini
Is there a story behind skipping virtio-net feature bits 2..4?
Paolo
Bits 3-4 now :)
I'm curious too.
Not a good one :)
The year is 2007. virtio_net was the posterchild of free expression and crazy experimentation. We were all so very young...
The original host TSO bits in virtio_net were like so:
#define VIRTIO_NET_F_TSO4 1 #define VIRTIO_NET_F_UFO 2 #define VIRTIO_NET_F_TSO4_ECN 3 #define VIRTIO_NET_F_TSO6 4
But I decided we might as well offer all or nothing, and if you couldn't handle one, you could just do it in software:
#define VIRTIO_NET_F_GSO 6
Reading the git commits, it seems Linux didn't do UFO in software (at the time, at least), so the bits were split out again, with the explicit _HOST_ in the names:
#define VIRTIO_NET_F_HOST_TSO4 11 /* Host can handle TSOv4 in. */ #define VIRTIO_NET_F_HOST_TSO6 12 /* Host can handle TSOv6 in. */ #define VIRTIO_NET_F_HOST_ECN 13 /* Host can handle TSO[6] w/ ECN in. */ #define VIRTIO_NET_F_HOST_UFO 14 /* Host can handle UFO in. */
This was all before there was a host implementation, so we were playing.
ie. the bits are perfectly fine for reuse.
Cheers,
Rusty.