vhost: fix offload flags in Rx path
authorDavid Marchand <david.marchand@redhat.com>
Mon, 3 May 2021 16:43:44 +0000 (18:43 +0200)
committerMaxime Coquelin <maxime.coquelin@redhat.com>
Tue, 4 May 2021 08:22:17 +0000 (10:22 +0200)
commitca7036b4af3a82d258cca914e71171434b3d0320
tree227aed3d52b71addf4c40768186a1234c26eb3b9
parent85a4fa2f5a15a8c9c018e311ee5f6468bc5a99aa
vhost: fix offload flags in Rx path

The vhost library currently configures Tx offloading (PKT_TX_*) on any
packet received from a guest virtio device which asks for some offloading.

This is problematic, as Tx offloading is something that the application
must ask for: the application needs to configure devices
to support every used offloads (ip, tcp checksumming, tso..), and the
various l2/l3/l4 lengths must be set following any processing that
happened in the application itself.

On the other hand, the received packets are not marked wrt current
packet l3/l4 checksumming info.

Copy virtio rx processing to fix those offload flags with some
differences:
- accept VIRTIO_NET_HDR_GSO_ECN and VIRTIO_NET_HDR_GSO_UDP,
- ignore anything but the VIRTIO_NET_HDR_F_NEEDS_CSUM flag (to comply with
  the virtio spec),

Some applications might rely on the current behavior, so it is left
untouched by default.
A new RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS flag is added to enable the
new behavior.

The vhost example has been updated for the new behavior: TSO is applied to
any packet marked LRO.

Fixes: 859b480d5afd ("vhost: add guest offload setting")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
doc/guides/prog_guide/vhost_lib.rst
doc/guides/rel_notes/release_21_05.rst
drivers/net/vhost/rte_eth_vhost.c
examples/vhost/main.c
lib/vhost/rte_vhost.h
lib/vhost/socket.c
lib/vhost/vhost.c
lib/vhost/vhost.h
lib/vhost/virtio_net.c