[dpdk-dev] vhost: support UDP Fragmentation Offload

Message ID 1511247412-130965-1-git-send-email-jiayu.hu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Yuanhan Liu
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Hu, Jiayu Nov. 21, 2017, 6:56 a.m. UTC
  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>
---
 lib/librte_mbuf/rte_mbuf.h    |  7 +++++++
 lib/librte_vhost/vhost.h      |  2 ++
 lib/librte_vhost/virtio_net.c | 10 ++++++++++
 3 files changed, 19 insertions(+)
  

Comments

Stephen Hemminger Nov. 21, 2017, 7:12 a.m. UTC | #1
On Tue, 21 Nov 2017 14:56:52 +0800
Jiayu Hu <jiayu.hu@intel.com> wrote:

> 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>

This may no longer be a desirable feature to implement.
UFO was just deprecated and removed from Linux.
It had no useful benefit.
  
Hu, Jiayu Nov. 21, 2017, 7:41 a.m. UTC | #2
Hi Stephen,

> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Tuesday, November 21, 2017 3:13 PM
> To: Hu, Jiayu <jiayu.hu@intel.com>
> Cc: dev@dpdk.org; yliu@fridaylinux.org; Tan, Jianfeng
> <jianfeng.tan@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] vhost: support UDP Fragmentation Offload
> 
> On Tue, 21 Nov 2017 14:56:52 +0800
> Jiayu Hu <jiayu.hu@intel.com> wrote:
> 
> > 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>
> 
> This may no longer be a desirable feature to implement.
> UFO was just deprecated and removed from Linux.
> It had no useful benefit.

The main reason of supporting UFO is to make the backend live migration from
vhost-net to vhost-user possible. Host and guest UFO are default features for virtio-net,
and vhost-net supports both. But vhosy-user doesn't support them. If we want to
migrate from vhost-net to vhost-user, this features gap would cause live migration fail.

Thanks,
Jiayu
  
Neil Horman Nov. 21, 2017, 2:33 p.m. UTC | #3
On Tue, Nov 21, 2017 at 07:41:00AM +0000, Hu, Jiayu wrote:
> Hi Stephen,
> 
> > -----Original Message-----
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Tuesday, November 21, 2017 3:13 PM
> > To: Hu, Jiayu <jiayu.hu@intel.com>
> > Cc: dev@dpdk.org; yliu@fridaylinux.org; Tan, Jianfeng
> > <jianfeng.tan@intel.com>
> > Subject: Re: [dpdk-dev] [PATCH] vhost: support UDP Fragmentation Offload
> > 
> > On Tue, 21 Nov 2017 14:56:52 +0800
> > Jiayu Hu <jiayu.hu@intel.com> wrote:
> > 
> > > 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>
> > 
> > This may no longer be a desirable feature to implement.
> > UFO was just deprecated and removed from Linux.
> > It had no useful benefit.
> 
> The main reason of supporting UFO is to make the backend live migration from
> vhost-net to vhost-user possible. Host and guest UFO are default features for virtio-net,
> and vhost-net supports both. But vhosy-user doesn't support them. If we want to
> migrate from vhost-net to vhost-user, this features gap would cause live migration fail.
> 
> Thanks,
> Jiayu
> 

Its not a widely used feature, but if it helps migrage people, its not a hard
feature to support

Acked-by: Neil Horman <nhorman@tuxdriver.com>
  
Maxime Coquelin Dec. 5, 2017, 2:57 p.m. UTC | #4
On 11/21/2017 07:56 AM, Jiayu Hu wrote:
> 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>
> ---
>   lib/librte_mbuf/rte_mbuf.h    |  7 +++++++
>   lib/librte_vhost/vhost.h      |  2 ++
>   lib/librte_vhost/virtio_net.c | 10 ++++++++++
>   3 files changed, 19 insertions(+)

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Maxime Coquelin Dec. 6, 2017, 8:36 a.m. UTC | #5
On 11/21/2017 07:56 AM, Jiayu Hu wrote:
> 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>
> ---
>   lib/librte_mbuf/rte_mbuf.h    |  7 +++++++
>   lib/librte_vhost/vhost.h      |  2 ++
>   lib/librte_vhost/virtio_net.c | 10 ++++++++++
>   3 files changed, 19 insertions(+)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index ce8a05d..3d8cfc9 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -209,6 +209,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.
>    */
>   #define PKT_TX_SEC_OFFLOAD 		(1ULL << 43)
> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
> index 1cc81c1..fc109ef 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -206,10 +206,12 @@ struct vhost_msg {
>   				(1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
>   				(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) | \

I actually have the same question as for GSO.
Dos it impact performance as it seems enabled by default in QEMU?
How do you test it?

Thanks,
Maxime

>   				(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \
>   				(1ULL << VIRTIO_NET_F_MTU) | \
>   				(1ULL << VIRTIO_F_IOMMU_PLATFORM))
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 6fee16e..3a3a0ad 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -188,6 +188,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);
> @@ -834,6 +839,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);
>
  
Hu, Jiayu Dec. 7, 2017, 1:14 p.m. UTC | #6
Hi Maxime,

> -----Original Message-----

> From: Maxime Coquelin [mailto:maxime.coquelin@redhat.com]

> Sent: Wednesday, December 6, 2017 4:37 PM

> To: Hu, Jiayu <jiayu.hu@intel.com>; dev@dpdk.org

> Cc: yliu@fridaylinux.org; Tan, Jianfeng <jianfeng.tan@intel.com>

> Subject: Re: [dpdk-dev] [PATCH] vhost: support UDP Fragmentation Offload

> 

> 

> 

> On 11/21/2017 07:56 AM, Jiayu Hu wrote:

> > 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>

> > ---

> >   lib/librte_mbuf/rte_mbuf.h    |  7 +++++++

> >   lib/librte_vhost/vhost.h      |  2 ++

> >   lib/librte_vhost/virtio_net.c | 10 ++++++++++

> >   3 files changed, 19 insertions(+)

> >

> > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h

> > index ce8a05d..3d8cfc9 100644

> > --- a/lib/librte_mbuf/rte_mbuf.h

> > +++ b/lib/librte_mbuf/rte_mbuf.h

> > @@ -209,6 +209,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.

> >    */

> >   #define PKT_TX_SEC_OFFLOAD 		(1ULL << 43)

> > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h

> > index 1cc81c1..fc109ef 100644

> > --- a/lib/librte_vhost/vhost.h

> > +++ b/lib/librte_vhost/vhost.h

> > @@ -206,10 +206,12 @@ struct vhost_msg {

> >   				(1ULL <<

> VHOST_USER_F_PROTOCOL_FEATURES) | \

> >   				(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) | \

> 

> I actually have the same question as for GSO.

> Dos it impact performance as it seems enabled by default in QEMU?


When enable host/guest UFO, the frontend and the backend can communicate
via large UDP packets, thus reducing the number of packets to be processed.
It's similar with TSO for virtio. Therefore, I think host/guest UFO can bring
performance gains.

> How do you test it?


We launch testpmd with two vhost-user ports, which connect to two VMs in one
server. When launch qemu, we enable host and guest UFO with command "host_ufo=on,
guest_ufo=on,csum=on". Then we run iperf in the two VMs to send large UDP packets.
If you use "show port xstats all" in testpmd, you can see the vhost-user port can receive
large UDP packets, which means host_ufo works. Additionally, if the forwarded large UDP
packets can be received by the VM, it means guest_ufo also works.

Thanks,
Jiayu
> 

> Thanks,

> Maxime

> 

> >   				(1ULL << VIRTIO_RING_F_INDIRECT_DESC)

> | \

> >   				(1ULL << VIRTIO_NET_F_MTU) | \

> >   				(1ULL << VIRTIO_F_IOMMU_PLATFORM))

> > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c

> > index 6fee16e..3a3a0ad 100644

> > --- a/lib/librte_vhost/virtio_net.c

> > +++ b/lib/librte_vhost/virtio_net.c

> > @@ -188,6 +188,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);

> > @@ -834,6 +839,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);

> >
  
Yao, Lei A Dec. 25, 2017, 1:48 a.m. UTC | #7
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jiayu Hu
> Sent: Tuesday, November 21, 2017 2:57 PM
> To: dev@dpdk.org
> Cc: yliu@fridaylinux.org; Tan, Jianfeng <jianfeng.tan@intel.com>; Hu, Jiayu
> <jiayu.hu@intel.com>
> Subject: [dpdk-dev] [PATCH] vhost: support UDP Fragmentation Offload
> 
> 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>
Tested-by: Lei Yao<lei.a.yao@intel.com>
This patch has been tested on my server,  with guest_ufo=on,host_ufo=on are
added to the qemu cmdlind, using vhost-user as backend, vm can send and receive  
big UDP packets.
> ---
>  lib/librte_mbuf/rte_mbuf.h    |  7 +++++++
>  lib/librte_vhost/vhost.h      |  2 ++
>  lib/librte_vhost/virtio_net.c | 10 ++++++++++
>  3 files changed, 19 insertions(+)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index ce8a05d..3d8cfc9 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -209,6 +209,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.
>   */
>  #define PKT_TX_SEC_OFFLOAD 		(1ULL << 43)
> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
> index 1cc81c1..fc109ef 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -206,10 +206,12 @@ struct vhost_msg {
>  				(1ULL <<
> VHOST_USER_F_PROTOCOL_FEATURES) | \
>  				(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))
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 6fee16e..3a3a0ad 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -188,6 +188,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);
> @@ -834,6 +839,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);
> --
> 2.7.4
  
Yuanhan Liu Dec. 27, 2017, 2:34 p.m. UTC | #8
On Tue, Nov 21, 2017 at 02:56:52PM +0800, Jiayu Hu wrote:
> 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>
> ---
>  lib/librte_mbuf/rte_mbuf.h    |  7 +++++++
>  lib/librte_vhost/vhost.h      |  2 ++
>  lib/librte_vhost/virtio_net.c | 10 ++++++++++
>  3 files changed, 19 insertions(+)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index ce8a05d..3d8cfc9 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -209,6 +209,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)

This patch added a new mbuf flag, Olivier, do you have objections?

	--yliu
  
Yuanhan Liu Jan. 8, 2018, 2:27 p.m. UTC | #9
On Tue, Nov 21, 2017 at 02:56:52PM +0800, Jiayu Hu wrote:
> 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>

Applied to dpdk-next-virtio.

Thanks.

	--yliu
  
Thomas Monjalon Jan. 16, 2018, 11:20 a.m. UTC | #10
08/01/2018 15:27, Yuanhan Liu:
> On Tue, Nov 21, 2017 at 02:56:52PM +0800, Jiayu Hu wrote:
> > 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>
> 
> Applied to dpdk-next-virtio.

Olivier Matz, mbuf maintainer, was not Cc'ed in this patch.
Olivier, can you confirm this new mbuf flag is OK?
  
Olivier Matz Jan. 16, 2018, 12:21 p.m. UTC | #11
On Tue, Jan 16, 2018 at 12:20:48PM +0100, Thomas Monjalon wrote:
> 08/01/2018 15:27, Yuanhan Liu:
> > On Tue, Nov 21, 2017 at 02:56:52PM +0800, Jiayu Hu wrote:
> > > 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>
> > 
> > Applied to dpdk-next-virtio.
> 
> Olivier Matz, mbuf maintainer, was not Cc'ed in this patch.
> Olivier, can you confirm this new mbuf flag is OK?

Yuanhan CC'ed me, but I was quite busy at that time.

Even if it's to late:
Acked-by: Olivier Matz <olivier.matz@6wind.com>
  

Patch

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ce8a05d..3d8cfc9 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -209,6 +209,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.
  */
 #define PKT_TX_SEC_OFFLOAD 		(1ULL << 43)
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 1cc81c1..fc109ef 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -206,10 +206,12 @@  struct vhost_msg {
 				(1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
 				(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))
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 6fee16e..3a3a0ad 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -188,6 +188,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);
@@ -834,6 +839,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);