]> git.droids-corp.org - dpdk.git/commitdiff
vhost: support UDP Fragmentation Offload
authorJiayu Hu <jiayu.hu@intel.com>
Tue, 21 Nov 2017 06:56:52 +0000 (14:56 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
In virtio, UDP Fragmentation Offload (UFO) includes two parts: host UFO
and guest UFO. Guest UFO means the frontend can receive large UDP
packets, and host UFO means the backend can receive large UDP packets.
This patch supports host UFO and guest UFO for vhost-user.

Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Tested-by: Lei Yao <lei.a.yao@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Yuanhan Liu <yliu@fridaylinux.org>
lib/librte_mbuf/rte_mbuf.h
lib/librte_vhost/vhost.h
lib/librte_vhost/virtio_net.c

index e4e3917f649e0e02f00002c87f7f9cc7beb91201..6cba632b97fa9af80339a1d1388acf3a50b2548c 100644 (file)
@@ -208,6 +208,13 @@ extern "C" {
 
 /* add new TX flags here */
 
+/**
+ * UDP Fragmentation Offload flag. This flag is used for enabling UDP
+ * fragmentation in SW or in HW. When use UFO, mbuf->tso_segsz is used
+ * to store the MSS of UDP fragments.
+ */
+#define PKT_TX_UDP_SEG (1ULL << 42)
+
 /**
  * Request security offload processing on the TX packet.
  */
index 1943d069a1a901963918949c130d39e07f207521..8afb4265dec1b42ea111ef6419dbe61c71b2abe2 100644 (file)
@@ -178,10 +178,12 @@ struct vhost_msg {
                                (1ULL << VIRTIO_NET_F_GSO) | \
                                (1ULL << VIRTIO_NET_F_HOST_TSO4) | \
                                (1ULL << VIRTIO_NET_F_HOST_TSO6) | \
+                               (1ULL << VIRTIO_NET_F_HOST_UFO) | \
                                (1ULL << VIRTIO_NET_F_CSUM)    | \
                                (1ULL << VIRTIO_NET_F_GUEST_CSUM) | \
                                (1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
                                (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
+                               (1ULL << VIRTIO_NET_F_GUEST_UFO) | \
                                (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \
                                (1ULL << VIRTIO_NET_F_MTU) | \
                                (1ULL << VIRTIO_F_IOMMU_PLATFORM))
index 4f7217f89898ad4f01d5a3de727d515c071a7ab9..cd304f61b7ba4573c0d7cd0c109cc28a3f1b2688 100644 (file)
@@ -159,6 +159,11 @@ virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr)
                net_hdr->gso_size = m_buf->tso_segsz;
                net_hdr->hdr_len = m_buf->l2_len + m_buf->l3_len
                                        + m_buf->l4_len;
+       } else if (m_buf->ol_flags & PKT_TX_UDP_SEG) {
+               net_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
+               net_hdr->gso_size = m_buf->tso_segsz;
+               net_hdr->hdr_len = m_buf->l2_len + m_buf->l3_len +
+                       m_buf->l4_len;
        } else {
                ASSIGN_UNLESS_EQUAL(net_hdr->gso_type, 0);
                ASSIGN_UNLESS_EQUAL(net_hdr->gso_size, 0);
@@ -792,6 +797,11 @@ vhost_dequeue_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *m)
                        m->tso_segsz = hdr->gso_size;
                        m->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
                        break;
+               case VIRTIO_NET_HDR_GSO_UDP:
+                       m->ol_flags |= PKT_TX_UDP_SEG;
+                       m->tso_segsz = hdr->gso_size;
+                       m->l4_len = sizeof(struct udp_hdr);
+                       break;
                default:
                        RTE_LOG(WARNING, VHOST_DATA,
                                "unsupported gso type %u.\n", hdr->gso_type);