features |= (1 << VIRTIO_NET_F_GUEST_TSO4);
features |= (1 << VIRTIO_NET_F_GUEST_TSO6);
features |= (1 << VIRTIO_NET_F_GUEST_ECN);
+
+ if (tap_has_ufo(n->vc->peer)) {
+ features |= (1 << VIRTIO_NET_F_GUEST_UFO);
+ features |= (1 << VIRTIO_NET_F_HOST_UFO);
+ }
}
return 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_ECN) & 1);
+ (features >> VIRTIO_NET_F_GUEST_ECN) & 1,
+ (features >> VIRTIO_NET_F_GUEST_UFO) & 1);
}
}
(n->vdev.features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
(n->vdev.features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
(n->vdev.features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_ECN) & 1);
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_ECN) & 1,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_UFO) & 1);
}
}
#endif /* CONFIG_SLIRP */
#if defined(_WIN32)
+int tap_has_ufo(VLANClientState *vc)
+{
+ return 0;
+}
int tap_has_vnet_hdr(VLANClientState *vc)
{
return 0;
void tap_using_vnet_hdr(VLANClientState *vc, int using_vnet_hdr)
{
}
-void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn)
+void tap_set_offload(VLANClientState *vc, int csum, int tso4,
+ int tso6, int ecn, int ufo)
{
}
#else /* !defined(_WIN32) */
unsigned int write_poll : 1;
unsigned int has_vnet_hdr : 1;
unsigned int using_vnet_hdr : 1;
+ unsigned int has_ufo: 1;
} TAPState;
static int launch_script(const char *setup_script, const char *ifname, int fd);
return 0;
}
+int tap_has_ufo(VLANClientState *vc)
+{
+ TAPState *s = vc->opaque;
+
+ assert(vc->type == NET_CLIENT_TYPE_TAP);
+
+ return s->has_ufo;
+}
+
int tap_has_vnet_hdr(VLANClientState *vc)
{
TAPState *s = vc->opaque;
return ifr.ifr_flags & IFF_VNET_HDR;
}
-void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn)
+void tap_set_offload(VLANClientState *vc, int csum, int tso4,
+ int tso6, int ecn, int ufo)
{
TAPState *s = vc->opaque;
unsigned int offload = 0;
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));
+ offload &= ~TUN_F_UFO;
+ if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) {
+ fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
+ strerror(errno));
+ }
}
}
int vnet_hdr)
{
TAPState *s;
+ unsigned int offload;
s = qemu_mallocz(sizeof(TAPState));
s->fd = fd;
vlan, NULL, model, name, NULL,
tap_receive, tap_receive_raw,
tap_receive_iov, tap_cleanup, s);
+ s->has_ufo = 0;
+ /* Check if tap supports UFO */
+ offload = TUN_F_CSUM | TUN_F_UFO;
+ if (ioctl(s->fd, TUNSETOFFLOAD, offload) == 0)
+ s->has_ufo = 1;
+ tap_set_offload(s->vc, 0, 0, 0, 0, 0);
tap_read_poll(s, 1);
return s;
}
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
+int tap_has_ufo(VLANClientState *vc);
int tap_has_vnet_hdr(VLANClientState *vc);
void tap_using_vnet_hdr(VLANClientState *vc, int using_vnet_hdr);
-void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn);
+void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn, int ufo);
#endif