From: Olivier Matz Date: Thu, 13 Oct 2016 14:16:10 +0000 (+0200) Subject: net/virtio: support LRO X-Git-Tag: spdx-start~5607 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=86d59b21468a3c7be30969c1ac5fd7212484b562;hp=58169a9c815348c11fff64445f90dcfce0688e1d;p=dpdk.git net/virtio: support LRO Signed-off-by: Olivier Matz Reviewed-by: Maxime Coquelin Acked-by: Yuanhan Liu --- diff --git a/doc/guides/rel_notes/release_16_11.rst b/doc/guides/rel_notes/release_16_11.rst index a6ff76d5b8..decf57b834 100644 --- a/doc/guides/rel_notes/release_16_11.rst +++ b/doc/guides/rel_notes/release_16_11.rst @@ -86,6 +86,7 @@ New Features * **Supported offloads with virtio.** * Rx/Tx checksums + * LRO * **Added virtio NEON support for ARM.** diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index adae9a9382..157e44cd75 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1369,6 +1369,10 @@ virtio_dev_configure(struct rte_eth_dev *dev) req_features = VIRTIO_PMD_DEFAULT_GUEST_FEATURES; if (rxmode->hw_ip_checksum) req_features |= (1ULL << VIRTIO_NET_F_GUEST_CSUM); + if (rxmode->enable_lro) + req_features |= + (1ULL << VIRTIO_NET_F_GUEST_TSO4) | + (1ULL << VIRTIO_NET_F_GUEST_TSO6); /* if request features changed, reinit the device */ if (req_features != hw->req_guest_features) { @@ -1384,6 +1388,14 @@ virtio_dev_configure(struct rte_eth_dev *dev) return -ENOTSUP; } + if (rxmode->enable_lro && + (!vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO4) || + !vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO4))) { + PMD_DRV_LOG(NOTICE, + "lro not available on this host"); + return -ENOTSUP; + } + /* Setup and start control queue */ if (vtpci_with_feature(hw, VIRTIO_NET_F_CTRL_VQ)) { ret = virtio_dev_cq_queue_setup(dev, @@ -1599,7 +1611,8 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) }; dev_info->rx_offload_capa = DEV_RX_OFFLOAD_TCP_CKSUM | - DEV_RX_OFFLOAD_UDP_CKSUM; + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_LRO; dev_info->tx_offload_capa = 0; if (hw->guest_features & (1ULL << VIRTIO_NET_F_CSUM)) { diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index 221630549c..cf8ee68730 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -118,13 +118,4 @@ uint16_t virtio_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts, int eth_virtio_dev_init(struct rte_eth_dev *eth_dev); -/* - * The VIRTIO_NET_F_GUEST_TSO[46] features permit the host to send us - * frames larger than 1514 bytes. We do not yet support software LRO - * via tcp_lro_rx(). - */ -#define VTNET_LRO_FEATURES (VIRTIO_NET_F_GUEST_TSO4 | \ - VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_ECN) - - #endif /* _VIRTIO_ETHDEV_H_ */ diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 675dc437da..0fa635a624 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -715,13 +715,36 @@ virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) m->ol_flags |= PKT_RX_L4_CKSUM_GOOD; } + /* GSO request, save required information in mbuf */ + if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) { + /* Check unsupported modes */ + if ((hdr->gso_type & VIRTIO_NET_HDR_GSO_ECN) || + (hdr->gso_size == 0)) { + return -EINVAL; + } + + /* Update mss lengthes in mbuf */ + m->tso_segsz = hdr->gso_size; + switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) { + case VIRTIO_NET_HDR_GSO_TCPV4: + case VIRTIO_NET_HDR_GSO_TCPV6: + m->ol_flags |= PKT_RX_LRO | \ + PKT_RX_L4_CKSUM_NONE; + break; + default: + return -EINVAL; + } + } + return 0; } static inline int rx_offload_enabled(struct virtio_hw *hw) { - return vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_CSUM); + return vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_CSUM) || + vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO4) || + vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO6); } #define VIRTIO_MBUF_BURST_SZ 64