* [PATCH qemu-kvm] Enable UFO on virtio-net/tap devices
@ 2009-06-06 0:16 Sridhar Samudrala
2009-06-06 7:33 ` Jan Kiszka
2009-06-07 6:21 ` Avi Kivity
0 siblings, 2 replies; 5+ messages in thread
From: Sridhar Samudrala @ 2009-06-06 0:16 UTC (permalink / raw)
To: kvm, herbert.xu, rusty, davem, netdev
Enable UFO on the host tap device if supported and allow setting UFO
on virtio-net in the guest.
Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 3c77b99..8a53e27 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -134,7 +134,8 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev)
features |= (1 << VIRTIO_NET_F_HOST_TSO6);
features |= (1 << VIRTIO_NET_F_HOST_ECN);
features |= (1 << VIRTIO_NET_F_MRG_RXBUF);
- /* Kernel can't actually handle UFO in software currently. */
+ // features |= (1 << VIRTIO_NET_F_HOST_UFO);
+ features |= (1 << VIRTIO_NET_F_GUEST_UFO);
}
#endif
@@ -173,6 +174,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
(features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
(features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
(features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
+ (features >> VIRTIO_NET_F_GUEST_UFO) & 1,
(features >> VIRTIO_NET_F_GUEST_ECN) & 1);
#endif
}
diff --git a/net.c b/net.c
index 01e31db..e7dbcd0 100644
--- a/net.c
+++ b/net.c
@@ -990,8 +990,13 @@ static int tap_probe_vnet_hdr(int fd)
}
#ifdef TUNSETOFFLOAD
+
+#ifndef TUN_F_UFO
+#define TUN_F_UFO 0x10
+#endif
+
static void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6,
- int ecn)
+ int ecn, int ufo)
{
TAPState *s = vc->opaque;
unsigned int offload = 0;
@@ -1004,11 +1009,18 @@ static void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6,
offload |= TUN_F_TSO6;
if ((tso4 || tso6) && ecn)
offload |= TUN_F_TSO_ECN;
+ if (ufo)
+ offload |= TUN_F_UFO;
}
- if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0)
- fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
- strerror(errno));
+ if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) {
+ /* Try without UFO */
+ offload &= ~TUN_F_UFO;
+ if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) {
+ fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
+ strerror(errno));
+ }
+ }
}
#endif /* TUNSETOFFLOAD */
@@ -1043,7 +1055,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
s->vc->fd_read_raw = tap_receive_raw;
#ifdef TUNSETOFFLOAD
s->vc->set_offload = tap_set_offload;
- tap_set_offload(s->vc, 0, 0, 0, 0);
+ tap_set_offload(s->vc, 0, 0, 0, 0, 0);
#endif
qemu_set_fd_handler2(s->fd, tap_can_send, tap_send, NULL, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd);
diff --git a/net.h b/net.h
index 3d0b6f2..ecfb1f9 100644
--- a/net.h
+++ b/net.h
@@ -11,7 +11,7 @@ typedef struct VLANClientState VLANClientState;
typedef void (NetCleanup) (VLANClientState *);
typedef void (LinkStatusChanged)(VLANClientState *);
-typedef void (SetOffload)(VLANClientState *, int, int, int, int);
+typedef void (SetOffload)(VLANClientState *, int, int, int, int, int);
struct VLANClientState {
IOReadHandler *fd_read;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH qemu-kvm] Enable UFO on virtio-net/tap devices
2009-06-06 0:16 [PATCH qemu-kvm] Enable UFO on virtio-net/tap devices Sridhar Samudrala
@ 2009-06-06 7:33 ` Jan Kiszka
2009-06-08 16:32 ` Sridhar Samudrala
2009-06-07 6:21 ` Avi Kivity
1 sibling, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2009-06-06 7:33 UTC (permalink / raw)
To: Sridhar Samudrala; +Cc: kvm, herbert.xu, rusty, davem, netdev
[-- Attachment #1: Type: text/plain, Size: 3547 bytes --]
Sridhar Samudrala wrote:
> Enable UFO on the host tap device if supported and allow setting UFO
> on virtio-net in the guest.
>
> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
>
>
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 3c77b99..8a53e27 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -134,7 +134,8 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev)
> features |= (1 << VIRTIO_NET_F_HOST_TSO6);
> features |= (1 << VIRTIO_NET_F_HOST_ECN);
> features |= (1 << VIRTIO_NET_F_MRG_RXBUF);
> - /* Kernel can't actually handle UFO in software currently. */
> + // features |= (1 << VIRTIO_NET_F_HOST_UFO);
> + features |= (1 << VIRTIO_NET_F_GUEST_UFO);
Looks like you forgot some development fragments here.
> }
> #endif
>
> @@ -173,6 +174,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
> (features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
> (features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
> (features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
> + (features >> VIRTIO_NET_F_GUEST_UFO) & 1,
> (features >> VIRTIO_NET_F_GUEST_ECN) & 1);
So UFO is the last-but-one parameter to the callback...
> #endif
> }
> diff --git a/net.c b/net.c
> index 01e31db..e7dbcd0 100644
> --- a/net.c
> +++ b/net.c
> @@ -990,8 +990,13 @@ static int tap_probe_vnet_hdr(int fd)
> }
>
> #ifdef TUNSETOFFLOAD
> +
> +#ifndef TUN_F_UFO
> +#define TUN_F_UFO 0x10
> +#endif
> +
> static void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6,
> - int ecn)
> + int ecn, int ufo)
...or is it the last one?
> {
> TAPState *s = vc->opaque;
> unsigned int offload = 0;
> @@ -1004,11 +1009,18 @@ static void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6,
> offload |= TUN_F_TSO6;
> if ((tso4 || tso6) && ecn)
> offload |= TUN_F_TSO_ECN;
> + if (ufo)
> + offload |= TUN_F_UFO;
> }
>
> - if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0)
> - fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
> - strerror(errno));
> + if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) {
> + /* Try without UFO */
> + offload &= ~TUN_F_UFO;
> + if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) {
> + fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
> + strerror(errno));
> + }
> + }
> }
> #endif /* TUNSETOFFLOAD */
>
> @@ -1043,7 +1055,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
> s->vc->fd_read_raw = tap_receive_raw;
> #ifdef TUNSETOFFLOAD
> s->vc->set_offload = tap_set_offload;
> - tap_set_offload(s->vc, 0, 0, 0, 0);
> + tap_set_offload(s->vc, 0, 0, 0, 0, 0);
> #endif
> qemu_set_fd_handler2(s->fd, tap_can_send, tap_send, NULL, s);
> snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd);
> diff --git a/net.h b/net.h
> index 3d0b6f2..ecfb1f9 100644
> --- a/net.h
> +++ b/net.h
> @@ -11,7 +11,7 @@ typedef struct VLANClientState VLANClientState;
>
> typedef void (NetCleanup) (VLANClientState *);
> typedef void (LinkStatusChanged)(VLANClientState *);
> -typedef void (SetOffload)(VLANClientState *, int, int, int, int);
> +typedef void (SetOffload)(VLANClientState *, int, int, int, int, int);
>
> struct VLANClientState {
> IOReadHandler *fd_read;
>
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH qemu-kvm] Enable UFO on virtio-net/tap devices
2009-06-06 0:16 [PATCH qemu-kvm] Enable UFO on virtio-net/tap devices Sridhar Samudrala
2009-06-06 7:33 ` Jan Kiszka
@ 2009-06-07 6:21 ` Avi Kivity
2009-06-08 16:40 ` Sridhar Samudrala
1 sibling, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2009-06-07 6:21 UTC (permalink / raw)
To: Sridhar Samudrala; +Cc: kvm, herbert.xu, rusty, davem, netdev
Sridhar Samudrala wrote:
> Enable UFO on the host tap device if supported and allow setting UFO
> on virtio-net in the guest.
>
> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
>
>
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 3c77b99..8a53e27 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -134,7 +134,8 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev)
> features |= (1 << VIRTIO_NET_F_HOST_TSO6);
> features |= (1 << VIRTIO_NET_F_HOST_ECN);
> features |= (1 << VIRTIO_NET_F_MRG_RXBUF);
> - /* Kernel can't actually handle UFO in software currently. */
> + // features |= (1 << VIRTIO_NET_F_HOST_UFO);
> + features |= (1 << VIRTIO_NET_F_GUEST_UFO);
>
Where are these defined?
> @@ -990,8 +990,13 @@ static int tap_probe_vnet_hdr(int fd)
> }
>
> #ifdef TUNSETOFFLOAD
> +
> +#ifndef TUN_F_UFO
> +#define TUN_F_UFO 0x10
> +#endif
> +
>
Should just use the definition in the kernel header.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH qemu-kvm] Enable UFO on virtio-net/tap devices
2009-06-06 7:33 ` Jan Kiszka
@ 2009-06-08 16:32 ` Sridhar Samudrala
0 siblings, 0 replies; 5+ messages in thread
From: Sridhar Samudrala @ 2009-06-08 16:32 UTC (permalink / raw)
To: Jan Kiszka; +Cc: kvm, herbert.xu, rusty, davem, netdev
On Sat, 2009-06-06 at 09:33 +0200, Jan Kiszka wrote:
> Sridhar Samudrala wrote:
> > Enable UFO on the host tap device if supported and allow setting UFO
> > on virtio-net in the guest.
> >
> > Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
> >
> >
> > diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> > index 3c77b99..8a53e27 100644
> > --- a/hw/virtio-net.c
> > +++ b/hw/virtio-net.c
> > @@ -134,7 +134,8 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev)
> > features |= (1 << VIRTIO_NET_F_HOST_TSO6);
> > features |= (1 << VIRTIO_NET_F_HOST_ECN);
> > features |= (1 << VIRTIO_NET_F_MRG_RXBUF);
> > - /* Kernel can't actually handle UFO in software currently. */
> > + // features |= (1 << VIRTIO_NET_F_HOST_UFO);
> > + features |= (1 << VIRTIO_NET_F_GUEST_UFO);
>
> Looks like you forgot some development fragments here.
Yes. i sent a wrong version of the qemu patch.
Please ignore this one.
Thanks
Sridhar
>
> > }
> > #endif
> >
> > @@ -173,6 +174,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
> > (features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
> > (features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
> > (features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
> > + (features >> VIRTIO_NET_F_GUEST_UFO) & 1,
> > (features >> VIRTIO_NET_F_GUEST_ECN) & 1);
>
> So UFO is the last-but-one parameter to the callback...
>
> > #endif
> > }
> > diff --git a/net.c b/net.c
> > index 01e31db..e7dbcd0 100644
> > --- a/net.c
> > +++ b/net.c
> > @@ -990,8 +990,13 @@ static int tap_probe_vnet_hdr(int fd)
> > }
> >
> > #ifdef TUNSETOFFLOAD
> > +
> > +#ifndef TUN_F_UFO
> > +#define TUN_F_UFO 0x10
> > +#endif
> > +
> > static void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6,
> > - int ecn)
> > + int ecn, int ufo)
>
> ...or is it the last one?
>
> > {
> > TAPState *s = vc->opaque;
> > unsigned int offload = 0;
> > @@ -1004,11 +1009,18 @@ static void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6,
> > offload |= TUN_F_TSO6;
> > if ((tso4 || tso6) && ecn)
> > offload |= TUN_F_TSO_ECN;
> > + if (ufo)
> > + offload |= TUN_F_UFO;
> > }
> >
> > - if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0)
> > - fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
> > - strerror(errno));
> > + if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) {
> > + /* Try without UFO */
> > + offload &= ~TUN_F_UFO;
> > + if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) {
> > + fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
> > + strerror(errno));
> > + }
> > + }
> > }
> > #endif /* TUNSETOFFLOAD */
> >
> > @@ -1043,7 +1055,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
> > s->vc->fd_read_raw = tap_receive_raw;
> > #ifdef TUNSETOFFLOAD
> > s->vc->set_offload = tap_set_offload;
> > - tap_set_offload(s->vc, 0, 0, 0, 0);
> > + tap_set_offload(s->vc, 0, 0, 0, 0, 0);
> > #endif
> > qemu_set_fd_handler2(s->fd, tap_can_send, tap_send, NULL, s);
> > snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd);
> > diff --git a/net.h b/net.h
> > index 3d0b6f2..ecfb1f9 100644
> > --- a/net.h
> > +++ b/net.h
> > @@ -11,7 +11,7 @@ typedef struct VLANClientState VLANClientState;
> >
> > typedef void (NetCleanup) (VLANClientState *);
> > typedef void (LinkStatusChanged)(VLANClientState *);
> > -typedef void (SetOffload)(VLANClientState *, int, int, int, int);
> > +typedef void (SetOffload)(VLANClientState *, int, int, int, int, int);
> >
> > struct VLANClientState {
> > IOReadHandler *fd_read;
> >
>
> Jan
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH qemu-kvm] Enable UFO on virtio-net/tap devices
2009-06-07 6:21 ` Avi Kivity
@ 2009-06-08 16:40 ` Sridhar Samudrala
0 siblings, 0 replies; 5+ messages in thread
From: Sridhar Samudrala @ 2009-06-08 16:40 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, herbert.xu, rusty, davem, netdev
On Sun, 2009-06-07 at 09:21 +0300, Avi Kivity wrote:
> Sridhar Samudrala wrote:
> > Enable UFO on the host tap device if supported and allow setting UFO
> > on virtio-net in the guest.
> >
> > Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
> >
> >
> > diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> > index 3c77b99..8a53e27 100644
> > --- a/hw/virtio-net.c
> > +++ b/hw/virtio-net.c
> > @@ -134,7 +134,8 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev)
> > features |= (1 << VIRTIO_NET_F_HOST_TSO6);
> > features |= (1 << VIRTIO_NET_F_HOST_ECN);
> > features |= (1 << VIRTIO_NET_F_MRG_RXBUF);
> > - /* Kernel can't actually handle UFO in software currently. */
> > + // features |= (1 << VIRTIO_NET_F_HOST_UFO);
> > + features |= (1 << VIRTIO_NET_F_GUEST_UFO);
> >
>
> Where are these defined?
They are in hw/virtio_net.h
>
> > @@ -990,8 +990,13 @@ static int tap_probe_vnet_hdr(int fd)
> > }
> >
> > #ifdef TUNSETOFFLOAD
> > +
> > +#ifndef TUN_F_UFO
> > +#define TUN_F_UFO 0x10
> > +#endif
> > +
> >
>
> Should just use the definition in the kernel header.
>
TUN_F_UFO is not defined in the current version of kernel header linux/if_tun.h.
I have added this in my kernel patches to support UFO.
So until this definition gets into the distro versions of kernel headers, i think
we need to have this defined in qemu.
Thanks
Sridhar
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-06-08 16:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-06 0:16 [PATCH qemu-kvm] Enable UFO on virtio-net/tap devices Sridhar Samudrala
2009-06-06 7:33 ` Jan Kiszka
2009-06-08 16:32 ` Sridhar Samudrala
2009-06-07 6:21 ` Avi Kivity
2009-06-08 16:40 ` Sridhar Samudrala
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.