net: move UFO support detection to tap-linux.c

Only supported on Linux

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Mark McLoughlin 2009-10-22 17:49:16 +01:00 committed by Anthony Liguori
parent 1faac1f7d4
commit 9c282718aa
6 changed files with 29 additions and 6 deletions

View file

@ -41,6 +41,11 @@ int tap_probe_vnet_hdr(int fd)
return 0; return 0;
} }
int tap_probe_has_ufo(int fd)
{
return 0;
}
void tap_fd_set_offload(int fd, int csum, int tso4, void tap_fd_set_offload(int fd, int csum, int tso4,
int tso6, int ecn, int ufo) int tso6, int ecn, int ufo)
{ {

View file

@ -71,6 +71,11 @@ int tap_probe_vnet_hdr(int fd)
return 0; return 0;
} }
int tap_probe_has_ufo(int fd)
{
return 0;
}
void tap_fd_set_offload(int fd, int csum, int tso4, void tap_fd_set_offload(int fd, int csum, int tso4,
int tso6, int ecn, int ufo) int tso6, int ecn, int ufo)
{ {

View file

@ -112,6 +112,18 @@ int tap_probe_vnet_hdr(int fd)
return ifr.ifr_flags & IFF_VNET_HDR; return ifr.ifr_flags & IFF_VNET_HDR;
} }
int tap_probe_has_ufo(int fd)
{
unsigned offload;
offload = TUN_F_CSUM | TUN_F_UFO;
if (ioctl(fd, TUNSETOFFLOAD, offload) < 0)
return 0;
return 1;
}
void tap_fd_set_offload(int fd, int csum, int tso4, void tap_fd_set_offload(int fd, int csum, int tso4,
int tso6, int ecn, int ufo) int tso6, int ecn, int ufo)
{ {

View file

@ -194,6 +194,11 @@ int tap_probe_vnet_hdr(int fd)
return 0; return 0;
} }
int tap_probe_has_ufo(int fd)
{
return 0;
}
void tap_fd_set_offload(int fd, int csum, int tso4, void tap_fd_set_offload(int fd, int csum, int tso4,
int tso6, int ecn, int ufo) int tso6, int ecn, int ufo)
{ {

View file

@ -271,7 +271,6 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
int vnet_hdr) int vnet_hdr)
{ {
TAPState *s; TAPState *s;
unsigned int offload;
s = qemu_mallocz(sizeof(TAPState)); s = qemu_mallocz(sizeof(TAPState));
s->fd = fd; s->fd = fd;
@ -281,11 +280,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
vlan, NULL, model, name, NULL, vlan, NULL, model, name, NULL,
tap_receive, tap_receive_raw, tap_receive, tap_receive_raw,
tap_receive_iov, tap_cleanup, s); tap_receive_iov, tap_cleanup, s);
s->has_ufo = 0; s->has_ufo = tap_probe_has_ufo(s->fd);
/* 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_set_offload(s->vc, 0, 0, 0, 0, 0);
tap_read_poll(s, 1); tap_read_poll(s, 1);
return s; return s;

View file

@ -45,6 +45,7 @@ void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn,
int tap_set_sndbuf(int fd, QemuOpts *opts); int tap_set_sndbuf(int fd, QemuOpts *opts);
int tap_probe_vnet_hdr(int fd); int tap_probe_vnet_hdr(int fd);
int tap_probe_has_ufo(int fd);
void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo); void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo);
#endif /* QEMU_NET_TAP_H */ #endif /* QEMU_NET_TAP_H */