[virtio-dev] Re: [PATCH v2] virtio_net: support split header

2022-05-30 Thread Michael S. Tsirkin
On Tue, May 31, 2022 at 10:10:52AM +0800, Xuan Zhuo wrote:
> On Mon, 30 May 2022 14:27:26 -0400, "Michael S. Tsirkin"  
> wrote:
> > On Sat, May 07, 2022 at 03:15:33PM +0800, Xuan Zhuo wrote:
> > > The purpose of this feature is to split the header and the payload of
> > > the packet.
> > >
> > > |receive buffer|
> > > |   0th descriptor | 1th descriptor|
> > > | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->|   payload |
> > >
> > > We can use a buffer plus a separate page when allocating the receive
> > > buffer. In this way, we can ensure that all payloads can be
> > > independently in a page, which is very beneficial for the zerocopy
> > > implemented by the upper layer.
> > >
> > > Signed-off-by: Xuan Zhuo 
> >
> > Okay, but I don't think this covers all possible use-cases.
> > If we are doing this let's try to address alignment requirements too.
> 
> Very happy to do this job.
> 
> I thinks "offset" can contain these requirements.

I am not so sure. The issue is with all of the extension headers where
the payload is is not always predictable, even for a
given type.

> No matter how many descriptors
> are used, we treat multiple buffers as a continuous piece of memory. The 
> device
> places ip, tcp/udp at the specified location according to the specified 
> offset.
> 
> The device does not care whether the data is finally aligned with the buffer
> specified by a descriptor, the device only needs to ensure that each layer of
> the protocol is placed on the specified "offset".
> 
> Many other places need to be modified, and I will publish a new spec.
> 
> Thanks.
> 
> >
> > > ---
> > >  conformance.tex |  2 ++
> > >  content.tex | 72 +
> > >  2 files changed, 74 insertions(+)
> > >
> > > diff --git a/conformance.tex b/conformance.tex
> > > index 663e7c3..6f561fb 100644
> > > --- a/conformance.tex
> > > +++ b/conformance.tex
> > > @@ -149,6 +149,7 @@ \section{Conformance Targets}\label{sec:Conformance / 
> > > Conformance Targets}
> > >  \item \ref{drivernormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Automatic receive steering in multiqueue 
> > > mode}
> > >  \item \ref{drivernormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Offloads State Configuration / Setting 
> > > Offloads State}
> > >  \item \ref{drivernormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Receive-side scaling (RSS) }
> > > +\item \ref{drivernormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Split Header}
> > >  \end{itemize}
> > >
> > >  \conformance{\subsection}{Block Driver 
> > > Conformance}\label{sec:Conformance / Driver Conformance / Block Driver 
> > > Conformance}
> > > @@ -411,6 +412,7 @@ \section{Conformance Targets}\label{sec:Conformance / 
> > > Conformance Targets}
> > >  \item \ref{devicenormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Gratuitous Packet Sending}
> > >  \item \ref{devicenormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Automatic receive steering in multiqueue 
> > > mode}
> > >  \item \ref{devicenormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS 
> > > processing}
> > > +\item \ref{devicenormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Split Header}
> > >  \end{itemize}
> > >
> > >  \conformance{\subsection}{Block Device 
> > > Conformance}\label{sec:Conformance / Device Conformance / Block Device 
> > > Conformance}
> > > diff --git a/content.tex b/content.tex
> > > index 060bdab..3340402 100644
> > > --- a/content.tex
> > > +++ b/content.tex
> > > @@ -3092,6 +3092,9 @@ \subsection{Feature bits}\label{sec:Device Types / 
> > > Network Device / Feature bits
> > >  \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control
> > >  channel.
> > >
> > > +\item[VIRTIO_NET_F_SPLIT_HEADER (55)] Device supports to split the 
> > > header and
> > > +the payload.
> > > +
> > >  \item[VIRTIO_NET_F_HOST_USO (56)] Device can receive USO packets. Unlike 
> > > UFO
> > >   (fragmenting the packet) the USO splits large UDP packet
> > >   to several segments when each of these smaller packets has UDP header.
> > > @@ -3139,6 +3142,7 @@ \subsubsection{Feature bit 
> > > requirements}\label{sec:Device Types / Network Device
> > >  \item[VIRTIO_NET_F_CTRL_MAC_ADDR] Requires VIRTIO_NET_F_CTRL_VQ.
> > >  \item[VIRTIO_NET_F_RSC_EXT] Requires VIRTIO_NET_F_HOST_TSO4 or 
> > > VIRTIO_NET_F_HOST_TSO6.
> > >  \item[VIRTIO_NET_F_RSS] Requires VIRTIO_NET_F_CTRL_VQ.
> > > +\item[VIRTIO_NET_F_SPLIT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ.
> > >  \end{description}
> > >
> > >  \subsubsection{Legacy Interface: Feature 

Re: [virtio-dev] Re: [PATCH v2] virtio_net: support split header

2022-05-30 Thread Michael S. Tsirkin
On Tue, May 31, 2022 at 12:38:14PM +0800, Jason Wang wrote:
> On Tue, May 31, 2022 at 2:23 AM Michael S. Tsirkin  wrote:
> >
> > On Mon, May 30, 2022 at 01:56:06PM +0800, Jason Wang wrote:
> > > On Thu, May 26, 2022 at 2:31 PM Xuan Zhuo  
> > > wrote:
> > > >
> > > > On Mon, 9 May 2022 16:41:11 +0800, Jason Wang  
> > > > wrote:
> > > > >
> > > > > 在 2022/5/7 15:15, Xuan Zhuo 写道:
> > > > > > The purpose of this feature is to split the header and the payload 
> > > > > > of
> > > > > > the packet.
> > > > > >
> > > > > > |receive buffer 
> > > > > >|
> > > > > > |   0th descriptor | 1th descriptor 
> > > > > >|
> > > > > > | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->|   payload  
> > > > > >|
> > > > > >
> > > > > > We can use a buffer plus a separate page when allocating the receive
> > > > > > buffer. In this way, we can ensure that all payloads can be
> > > > > > independently in a page, which is very beneficial for the zerocopy
> > > > > > implemented by the upper layer.
> > > > > >
> > > > > > Signed-off-by: Xuan Zhuo 
> > > > > > ---
> > > > > >   conformance.tex |  2 ++
> > > > > >   content.tex | 72 
> > > > > > +
> > > > > >   2 files changed, 74 insertions(+)
> > > > > >
> > > > > > diff --git a/conformance.tex b/conformance.tex
> > > > > > index 663e7c3..6f561fb 100644
> > > > > > --- a/conformance.tex
> > > > > > +++ b/conformance.tex
> > > > > > @@ -149,6 +149,7 @@ \section{Conformance 
> > > > > > Targets}\label{sec:Conformance / Conformance Targets}
> > > > > >   \item \ref{drivernormative:Device Types / Network Device / Device 
> > > > > > Operation / Control Virtqueue / Automatic receive steering in 
> > > > > > multiqueue mode}
> > > > > >   \item \ref{drivernormative:Device Types / Network Device / Device 
> > > > > > Operation / Control Virtqueue / Offloads State Configuration / 
> > > > > > Setting Offloads State}
> > > > > >   \item \ref{drivernormative:Device Types / Network Device / Device 
> > > > > > Operation / Control Virtqueue / Receive-side scaling (RSS) }
> > > > > > +\item \ref{drivernormative:Device Types / Network Device / Device 
> > > > > > Operation / Control Virtqueue / Split Header}
> > > > > >   \end{itemize}
> > > > > >
> > > > > >   \conformance{\subsection}{Block Driver 
> > > > > > Conformance}\label{sec:Conformance / Driver Conformance / Block 
> > > > > > Driver Conformance}
> > > > > > @@ -411,6 +412,7 @@ \section{Conformance 
> > > > > > Targets}\label{sec:Conformance / Conformance Targets}
> > > > > >   \item \ref{devicenormative:Device Types / Network Device / Device 
> > > > > > Operation / Control Virtqueue / Gratuitous Packet Sending}
> > > > > >   \item \ref{devicenormative:Device Types / Network Device / Device 
> > > > > > Operation / Control Virtqueue / Automatic receive steering in 
> > > > > > multiqueue mode}
> > > > > >   \item \ref{devicenormative:Device Types / Network Device / Device 
> > > > > > Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS 
> > > > > > processing}
> > > > > > +\item \ref{devicenormative:Device Types / Network Device / Device 
> > > > > > Operation / Control Virtqueue / Split Header}
> > > > > >   \end{itemize}
> > > > > >
> > > > > >   \conformance{\subsection}{Block Device 
> > > > > > Conformance}\label{sec:Conformance / Device Conformance / Block 
> > > > > > Device Conformance}
> > > > > > diff --git a/content.tex b/content.tex
> > > > > > index 060bdab..3340402 100644
> > > > > > --- a/content.tex
> > > > > > +++ b/content.tex
> > > > > > @@ -3092,6 +3092,9 @@ \subsection{Feature bits}\label{sec:Device 
> > > > > > Types / Network Device / Feature bits
> > > > > >   \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through 
> > > > > > control
> > > > > >   channel.
> > > > > >
> > > > > > +\item[VIRTIO_NET_F_SPLIT_HEADER (55)] Device supports to split the 
> > > > > > header and
> > > > > > +the payload.
> > > > > > +
> > > > > >   \item[VIRTIO_NET_F_HOST_USO (56)] Device can receive USO packets. 
> > > > > > Unlike UFO
> > > > > >(fragmenting the packet) the USO splits large UDP packet
> > > > > >to several segments when each of these smaller packets has UDP 
> > > > > > header.
> > > > > > @@ -3139,6 +3142,7 @@ \subsubsection{Feature bit 
> > > > > > requirements}\label{sec:Device Types / Network Device
> > > > > >   \item[VIRTIO_NET_F_CTRL_MAC_ADDR] Requires VIRTIO_NET_F_CTRL_VQ.
> > > > > >   \item[VIRTIO_NET_F_RSC_EXT] Requires VIRTIO_NET_F_HOST_TSO4 or 
> > > > > > VIRTIO_NET_F_HOST_TSO6.
> > > > > >   \item[VIRTIO_NET_F_RSS] Requires VIRTIO_NET_F_CTRL_VQ.
> > > > > > +\item[VIRTIO_NET_F_SPLIT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ.
> > > > > >   \end{description}
> > > > > >
> > > > > >   \subsubsection{Legacy Interface: Feature bits}\label{sec:Device 
> > > > > > Types / Network Device / Feature bits / Legacy 

[virtio-dev] Re: [PATCH v2] virtio_net: support split header

2022-05-30 Thread Michael S. Tsirkin
On Tue, May 31, 2022 at 10:10:52AM +0800, Xuan Zhuo wrote:
> On Mon, 30 May 2022 14:27:26 -0400, "Michael S. Tsirkin"  
> wrote:
> > On Sat, May 07, 2022 at 03:15:33PM +0800, Xuan Zhuo wrote:
> > > The purpose of this feature is to split the header and the payload of
> > > the packet.
> > >
> > > |receive buffer|
> > > |   0th descriptor | 1th descriptor|
> > > | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->|   payload |
> > >
> > > We can use a buffer plus a separate page when allocating the receive
> > > buffer. In this way, we can ensure that all payloads can be
> > > independently in a page, which is very beneficial for the zerocopy
> > > implemented by the upper layer.
> > >
> > > Signed-off-by: Xuan Zhuo 
> >
> > Okay, but I don't think this covers all possible use-cases.
> > If we are doing this let's try to address alignment requirements too.
> 
> Very happy to do this job.
> 
> I thinks "offset" can contain these requirements. No matter how many 
> descriptors
> are used, we treat multiple buffers as a continuous piece of memory. The 
> device
> places ip, tcp/udp at the specified location according to the specified 
> offset.
> 
> The device does not care whether the data is finally aligned with the buffer
> specified by a descriptor, the device only needs to ensure that each layer of
> the protocol is placed on the specified "offset".
> 
> Many other places need to be modified, and I will publish a new spec.
> 
> Thanks.
> 
> >
> > > ---
> > >  conformance.tex |  2 ++
> > >  content.tex | 72 +
> > >  2 files changed, 74 insertions(+)
> > >
> > > diff --git a/conformance.tex b/conformance.tex
> > > index 663e7c3..6f561fb 100644
> > > --- a/conformance.tex
> > > +++ b/conformance.tex
> > > @@ -149,6 +149,7 @@ \section{Conformance Targets}\label{sec:Conformance / 
> > > Conformance Targets}
> > >  \item \ref{drivernormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Automatic receive steering in multiqueue 
> > > mode}
> > >  \item \ref{drivernormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Offloads State Configuration / Setting 
> > > Offloads State}
> > >  \item \ref{drivernormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Receive-side scaling (RSS) }
> > > +\item \ref{drivernormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Split Header}
> > >  \end{itemize}
> > >
> > >  \conformance{\subsection}{Block Driver 
> > > Conformance}\label{sec:Conformance / Driver Conformance / Block Driver 
> > > Conformance}
> > > @@ -411,6 +412,7 @@ \section{Conformance Targets}\label{sec:Conformance / 
> > > Conformance Targets}
> > >  \item \ref{devicenormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Gratuitous Packet Sending}
> > >  \item \ref{devicenormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Automatic receive steering in multiqueue 
> > > mode}
> > >  \item \ref{devicenormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS 
> > > processing}
> > > +\item \ref{devicenormative:Device Types / Network Device / Device 
> > > Operation / Control Virtqueue / Split Header}
> > >  \end{itemize}
> > >
> > >  \conformance{\subsection}{Block Device 
> > > Conformance}\label{sec:Conformance / Device Conformance / Block Device 
> > > Conformance}
> > > diff --git a/content.tex b/content.tex
> > > index 060bdab..3340402 100644
> > > --- a/content.tex
> > > +++ b/content.tex
> > > @@ -3092,6 +3092,9 @@ \subsection{Feature bits}\label{sec:Device Types / 
> > > Network Device / Feature bits
> > >  \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control
> > >  channel.
> > >
> > > +\item[VIRTIO_NET_F_SPLIT_HEADER (55)] Device supports to split the 
> > > header and
> > > +the payload.
> > > +
> > >  \item[VIRTIO_NET_F_HOST_USO (56)] Device can receive USO packets. Unlike 
> > > UFO
> > >   (fragmenting the packet) the USO splits large UDP packet
> > >   to several segments when each of these smaller packets has UDP header.
> > > @@ -3139,6 +3142,7 @@ \subsubsection{Feature bit 
> > > requirements}\label{sec:Device Types / Network Device
> > >  \item[VIRTIO_NET_F_CTRL_MAC_ADDR] Requires VIRTIO_NET_F_CTRL_VQ.
> > >  \item[VIRTIO_NET_F_RSC_EXT] Requires VIRTIO_NET_F_HOST_TSO4 or 
> > > VIRTIO_NET_F_HOST_TSO6.
> > >  \item[VIRTIO_NET_F_RSS] Requires VIRTIO_NET_F_CTRL_VQ.
> > > +\item[VIRTIO_NET_F_SPLIT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ.
> > >  \end{description}
> > >
> > >  \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / 
> > > Network Device / Feature bits / Legacy Interface: Feature bits}
> > > @@ -3370,6 +3374,7 @@ \subsection{Device 

Re: [virtio-dev] Re: [PATCH v2] virtio_net: support split header

2022-05-30 Thread Jason Wang
On Tue, May 31, 2022 at 2:23 AM Michael S. Tsirkin  wrote:
>
> On Mon, May 30, 2022 at 01:56:06PM +0800, Jason Wang wrote:
> > On Thu, May 26, 2022 at 2:31 PM Xuan Zhuo  
> > wrote:
> > >
> > > On Mon, 9 May 2022 16:41:11 +0800, Jason Wang  wrote:
> > > >
> > > > 在 2022/5/7 15:15, Xuan Zhuo 写道:
> > > > > The purpose of this feature is to split the header and the payload of
> > > > > the packet.
> > > > >
> > > > > |receive buffer   
> > > > >  |
> > > > > |   0th descriptor | 1th descriptor   
> > > > >  |
> > > > > | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->|   payload
> > > > >  |
> > > > >
> > > > > We can use a buffer plus a separate page when allocating the receive
> > > > > buffer. In this way, we can ensure that all payloads can be
> > > > > independently in a page, which is very beneficial for the zerocopy
> > > > > implemented by the upper layer.
> > > > >
> > > > > Signed-off-by: Xuan Zhuo 
> > > > > ---
> > > > >   conformance.tex |  2 ++
> > > > >   content.tex | 72 
> > > > > +
> > > > >   2 files changed, 74 insertions(+)
> > > > >
> > > > > diff --git a/conformance.tex b/conformance.tex
> > > > > index 663e7c3..6f561fb 100644
> > > > > --- a/conformance.tex
> > > > > +++ b/conformance.tex
> > > > > @@ -149,6 +149,7 @@ \section{Conformance 
> > > > > Targets}\label{sec:Conformance / Conformance Targets}
> > > > >   \item \ref{drivernormative:Device Types / Network Device / Device 
> > > > > Operation / Control Virtqueue / Automatic receive steering in 
> > > > > multiqueue mode}
> > > > >   \item \ref{drivernormative:Device Types / Network Device / Device 
> > > > > Operation / Control Virtqueue / Offloads State Configuration / 
> > > > > Setting Offloads State}
> > > > >   \item \ref{drivernormative:Device Types / Network Device / Device 
> > > > > Operation / Control Virtqueue / Receive-side scaling (RSS) }
> > > > > +\item \ref{drivernormative:Device Types / Network Device / Device 
> > > > > Operation / Control Virtqueue / Split Header}
> > > > >   \end{itemize}
> > > > >
> > > > >   \conformance{\subsection}{Block Driver 
> > > > > Conformance}\label{sec:Conformance / Driver Conformance / Block 
> > > > > Driver Conformance}
> > > > > @@ -411,6 +412,7 @@ \section{Conformance 
> > > > > Targets}\label{sec:Conformance / Conformance Targets}
> > > > >   \item \ref{devicenormative:Device Types / Network Device / Device 
> > > > > Operation / Control Virtqueue / Gratuitous Packet Sending}
> > > > >   \item \ref{devicenormative:Device Types / Network Device / Device 
> > > > > Operation / Control Virtqueue / Automatic receive steering in 
> > > > > multiqueue mode}
> > > > >   \item \ref{devicenormative:Device Types / Network Device / Device 
> > > > > Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS 
> > > > > processing}
> > > > > +\item \ref{devicenormative:Device Types / Network Device / Device 
> > > > > Operation / Control Virtqueue / Split Header}
> > > > >   \end{itemize}
> > > > >
> > > > >   \conformance{\subsection}{Block Device 
> > > > > Conformance}\label{sec:Conformance / Device Conformance / Block 
> > > > > Device Conformance}
> > > > > diff --git a/content.tex b/content.tex
> > > > > index 060bdab..3340402 100644
> > > > > --- a/content.tex
> > > > > +++ b/content.tex
> > > > > @@ -3092,6 +3092,9 @@ \subsection{Feature bits}\label{sec:Device 
> > > > > Types / Network Device / Feature bits
> > > > >   \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through 
> > > > > control
> > > > >   channel.
> > > > >
> > > > > +\item[VIRTIO_NET_F_SPLIT_HEADER (55)] Device supports to split the 
> > > > > header and
> > > > > +the payload.
> > > > > +
> > > > >   \item[VIRTIO_NET_F_HOST_USO (56)] Device can receive USO packets. 
> > > > > Unlike UFO
> > > > >(fragmenting the packet) the USO splits large UDP packet
> > > > >to several segments when each of these smaller packets has UDP 
> > > > > header.
> > > > > @@ -3139,6 +3142,7 @@ \subsubsection{Feature bit 
> > > > > requirements}\label{sec:Device Types / Network Device
> > > > >   \item[VIRTIO_NET_F_CTRL_MAC_ADDR] Requires VIRTIO_NET_F_CTRL_VQ.
> > > > >   \item[VIRTIO_NET_F_RSC_EXT] Requires VIRTIO_NET_F_HOST_TSO4 or 
> > > > > VIRTIO_NET_F_HOST_TSO6.
> > > > >   \item[VIRTIO_NET_F_RSS] Requires VIRTIO_NET_F_CTRL_VQ.
> > > > > +\item[VIRTIO_NET_F_SPLIT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ.
> > > > >   \end{description}
> > > > >
> > > > >   \subsubsection{Legacy Interface: Feature bits}\label{sec:Device 
> > > > > Types / Network Device / Feature bits / Legacy Interface: Feature 
> > > > > bits}
> > > > > @@ -3370,6 +3374,7 @@ \subsection{Device Operation}\label{sec:Device 
> > > > > Types / Network Device / Device O
> > > > >   #define VIRTIO_NET_HDR_F_NEEDS_CSUM1
> > > > >   #define VIRTIO_NET_HDR_F_DATA_VALID2
> > > > >   #define 

[virtio-dev] Re: [PATCH v2] virtio_net: support split header

2022-05-30 Thread Xuan Zhuo
On Mon, 30 May 2022 14:27:26 -0400, "Michael S. Tsirkin"  
wrote:
> On Sat, May 07, 2022 at 03:15:33PM +0800, Xuan Zhuo wrote:
> > The purpose of this feature is to split the header and the payload of
> > the packet.
> >
> > |receive buffer|
> > |   0th descriptor | 1th descriptor|
> > | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->|   payload |
> >
> > We can use a buffer plus a separate page when allocating the receive
> > buffer. In this way, we can ensure that all payloads can be
> > independently in a page, which is very beneficial for the zerocopy
> > implemented by the upper layer.
> >
> > Signed-off-by: Xuan Zhuo 
>
> Okay, but I don't think this covers all possible use-cases.
> If we are doing this let's try to address alignment requirements too.

Very happy to do this job.

I thinks "offset" can contain these requirements. No matter how many descriptors
are used, we treat multiple buffers as a continuous piece of memory. The device
places ip, tcp/udp at the specified location according to the specified offset.

The device does not care whether the data is finally aligned with the buffer
specified by a descriptor, the device only needs to ensure that each layer of
the protocol is placed on the specified "offset".

Many other places need to be modified, and I will publish a new spec.

Thanks.

>
> > ---
> >  conformance.tex |  2 ++
> >  content.tex | 72 +
> >  2 files changed, 74 insertions(+)
> >
> > diff --git a/conformance.tex b/conformance.tex
> > index 663e7c3..6f561fb 100644
> > --- a/conformance.tex
> > +++ b/conformance.tex
> > @@ -149,6 +149,7 @@ \section{Conformance Targets}\label{sec:Conformance / 
> > Conformance Targets}
> >  \item \ref{drivernormative:Device Types / Network Device / Device 
> > Operation / Control Virtqueue / Automatic receive steering in multiqueue 
> > mode}
> >  \item \ref{drivernormative:Device Types / Network Device / Device 
> > Operation / Control Virtqueue / Offloads State Configuration / Setting 
> > Offloads State}
> >  \item \ref{drivernormative:Device Types / Network Device / Device 
> > Operation / Control Virtqueue / Receive-side scaling (RSS) }
> > +\item \ref{drivernormative:Device Types / Network Device / Device 
> > Operation / Control Virtqueue / Split Header}
> >  \end{itemize}
> >
> >  \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance 
> > / Driver Conformance / Block Driver Conformance}
> > @@ -411,6 +412,7 @@ \section{Conformance Targets}\label{sec:Conformance / 
> > Conformance Targets}
> >  \item \ref{devicenormative:Device Types / Network Device / Device 
> > Operation / Control Virtqueue / Gratuitous Packet Sending}
> >  \item \ref{devicenormative:Device Types / Network Device / Device 
> > Operation / Control Virtqueue / Automatic receive steering in multiqueue 
> > mode}
> >  \item \ref{devicenormative:Device Types / Network Device / Device 
> > Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS processing}
> > +\item \ref{devicenormative:Device Types / Network Device / Device 
> > Operation / Control Virtqueue / Split Header}
> >  \end{itemize}
> >
> >  \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance 
> > / Device Conformance / Block Device Conformance}
> > diff --git a/content.tex b/content.tex
> > index 060bdab..3340402 100644
> > --- a/content.tex
> > +++ b/content.tex
> > @@ -3092,6 +3092,9 @@ \subsection{Feature bits}\label{sec:Device Types / 
> > Network Device / Feature bits
> >  \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control
> >  channel.
> >
> > +\item[VIRTIO_NET_F_SPLIT_HEADER (55)] Device supports to split the header 
> > and
> > +the payload.
> > +
> >  \item[VIRTIO_NET_F_HOST_USO (56)] Device can receive USO packets. Unlike 
> > UFO
> >   (fragmenting the packet) the USO splits large UDP packet
> >   to several segments when each of these smaller packets has UDP header.
> > @@ -3139,6 +3142,7 @@ \subsubsection{Feature bit 
> > requirements}\label{sec:Device Types / Network Device
> >  \item[VIRTIO_NET_F_CTRL_MAC_ADDR] Requires VIRTIO_NET_F_CTRL_VQ.
> >  \item[VIRTIO_NET_F_RSC_EXT] Requires VIRTIO_NET_F_HOST_TSO4 or 
> > VIRTIO_NET_F_HOST_TSO6.
> >  \item[VIRTIO_NET_F_RSS] Requires VIRTIO_NET_F_CTRL_VQ.
> > +\item[VIRTIO_NET_F_SPLIT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ.
> >  \end{description}
> >
> >  \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / 
> > Network Device / Feature bits / Legacy Interface: Feature bits}
> > @@ -3370,6 +3374,7 @@ \subsection{Device Operation}\label{sec:Device Types 
> > / Network Device / Device O
> >  #define VIRTIO_NET_HDR_F_NEEDS_CSUM1
> >  #define VIRTIO_NET_HDR_F_DATA_VALID2
> >  #define VIRTIO_NET_HDR_F_RSC_INFO  4
> > +#define VIRTIO_NET_HDR_F_SPLIT_HEADER  8
> >  u8 flags;
> >  #define 

[virtio-dev] Re: [PATCH v2] virtio_net: support split header

2022-05-30 Thread Michael S. Tsirkin
On Sat, May 07, 2022 at 03:15:33PM +0800, Xuan Zhuo wrote:
> The purpose of this feature is to split the header and the payload of
> the packet.
> 
> |receive buffer|
> |   0th descriptor | 1th descriptor|
> | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->|   payload |
> 
> We can use a buffer plus a separate page when allocating the receive
> buffer. In this way, we can ensure that all payloads can be
> independently in a page, which is very beneficial for the zerocopy
> implemented by the upper layer.
> 
> Signed-off-by: Xuan Zhuo 

Okay, but I don't think this covers all possible use-cases.
If we are doing this let's try to address alignment requirements too.

> ---
>  conformance.tex |  2 ++
>  content.tex | 72 +
>  2 files changed, 74 insertions(+)
> 
> diff --git a/conformance.tex b/conformance.tex
> index 663e7c3..6f561fb 100644
> --- a/conformance.tex
> +++ b/conformance.tex
> @@ -149,6 +149,7 @@ \section{Conformance Targets}\label{sec:Conformance / 
> Conformance Targets}
>  \item \ref{drivernormative:Device Types / Network Device / Device Operation 
> / Control Virtqueue / Automatic receive steering in multiqueue mode}
>  \item \ref{drivernormative:Device Types / Network Device / Device Operation 
> / Control Virtqueue / Offloads State Configuration / Setting Offloads State}
>  \item \ref{drivernormative:Device Types / Network Device / Device Operation 
> / Control Virtqueue / Receive-side scaling (RSS) }
> +\item \ref{drivernormative:Device Types / Network Device / Device Operation 
> / Control Virtqueue / Split Header}
>  \end{itemize}
>  
>  \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / 
> Driver Conformance / Block Driver Conformance}
> @@ -411,6 +412,7 @@ \section{Conformance Targets}\label{sec:Conformance / 
> Conformance Targets}
>  \item \ref{devicenormative:Device Types / Network Device / Device Operation 
> / Control Virtqueue / Gratuitous Packet Sending}
>  \item \ref{devicenormative:Device Types / Network Device / Device Operation 
> / Control Virtqueue / Automatic receive steering in multiqueue mode}
>  \item \ref{devicenormative:Device Types / Network Device / Device Operation 
> / Control Virtqueue / Receive-side scaling (RSS) / RSS processing}
> +\item \ref{devicenormative:Device Types / Network Device / Device Operation 
> / Control Virtqueue / Split Header}
>  \end{itemize}
>  
>  \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / 
> Device Conformance / Block Device Conformance}
> diff --git a/content.tex b/content.tex
> index 060bdab..3340402 100644
> --- a/content.tex
> +++ b/content.tex
> @@ -3092,6 +3092,9 @@ \subsection{Feature bits}\label{sec:Device Types / 
> Network Device / Feature bits
>  \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control
>  channel.
>  
> +\item[VIRTIO_NET_F_SPLIT_HEADER (55)] Device supports to split the header and
> +the payload.
> +
>  \item[VIRTIO_NET_F_HOST_USO (56)] Device can receive USO packets. Unlike UFO
>   (fragmenting the packet) the USO splits large UDP packet
>   to several segments when each of these smaller packets has UDP header.
> @@ -3139,6 +3142,7 @@ \subsubsection{Feature bit 
> requirements}\label{sec:Device Types / Network Device
>  \item[VIRTIO_NET_F_CTRL_MAC_ADDR] Requires VIRTIO_NET_F_CTRL_VQ.
>  \item[VIRTIO_NET_F_RSC_EXT] Requires VIRTIO_NET_F_HOST_TSO4 or 
> VIRTIO_NET_F_HOST_TSO6.
>  \item[VIRTIO_NET_F_RSS] Requires VIRTIO_NET_F_CTRL_VQ.
> +\item[VIRTIO_NET_F_SPLIT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ.
>  \end{description}
>  
>  \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / 
> Network Device / Feature bits / Legacy Interface: Feature bits}
> @@ -3370,6 +3374,7 @@ \subsection{Device Operation}\label{sec:Device Types / 
> Network Device / Device O
>  #define VIRTIO_NET_HDR_F_NEEDS_CSUM1
>  #define VIRTIO_NET_HDR_F_DATA_VALID2
>  #define VIRTIO_NET_HDR_F_RSC_INFO  4
> +#define VIRTIO_NET_HDR_F_SPLIT_HEADER  8
>  u8 flags;
>  #define VIRTIO_NET_HDR_GSO_NONE0
>  #define VIRTIO_NET_HDR_GSO_TCPV4   1
> @@ -4471,6 +4476,73 @@ \subsubsection{Control Virtqueue}\label{sec:Device 
> Types / Network Device / Devi
>  according to the native endian of the guest rather than
>  (necessarily when not using the legacy interface) little-endian.
>  
> +\paragraph{Split Header}\label{sec:Device Types / Network Device / Device 
> Operation / Control Virtqueue / Split Header}
> +
> +If the VIRTIO_NET_F_SPLIT_HEADER feature is negotiated,
> +the device supports to split the header and the payload.
> +The header and payload will be separated into different buffers.
> +
> +\subparagraph{Split Header}\label{sec:Device Types / Network Device / Device 
> Operation / Control Virtqueue / Split Header / Setting Split Header}
> +
> +To configure the split 

Re: [virtio-dev] Re: [PATCH v2] virtio_net: support split header

2022-05-30 Thread Michael S. Tsirkin
On Mon, May 30, 2022 at 01:56:06PM +0800, Jason Wang wrote:
> On Thu, May 26, 2022 at 2:31 PM Xuan Zhuo  wrote:
> >
> > On Mon, 9 May 2022 16:41:11 +0800, Jason Wang  wrote:
> > >
> > > 在 2022/5/7 15:15, Xuan Zhuo 写道:
> > > > The purpose of this feature is to split the header and the payload of
> > > > the packet.
> > > >
> > > > |receive buffer|
> > > > |   0th descriptor | 1th descriptor|
> > > > | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->|   payload |
> > > >
> > > > We can use a buffer plus a separate page when allocating the receive
> > > > buffer. In this way, we can ensure that all payloads can be
> > > > independently in a page, which is very beneficial for the zerocopy
> > > > implemented by the upper layer.
> > > >
> > > > Signed-off-by: Xuan Zhuo 
> > > > ---
> > > >   conformance.tex |  2 ++
> > > >   content.tex | 72 +
> > > >   2 files changed, 74 insertions(+)
> > > >
> > > > diff --git a/conformance.tex b/conformance.tex
> > > > index 663e7c3..6f561fb 100644
> > > > --- a/conformance.tex
> > > > +++ b/conformance.tex
> > > > @@ -149,6 +149,7 @@ \section{Conformance Targets}\label{sec:Conformance 
> > > > / Conformance Targets}
> > > >   \item \ref{drivernormative:Device Types / Network Device / Device 
> > > > Operation / Control Virtqueue / Automatic receive steering in 
> > > > multiqueue mode}
> > > >   \item \ref{drivernormative:Device Types / Network Device / Device 
> > > > Operation / Control Virtqueue / Offloads State Configuration / Setting 
> > > > Offloads State}
> > > >   \item \ref{drivernormative:Device Types / Network Device / Device 
> > > > Operation / Control Virtqueue / Receive-side scaling (RSS) }
> > > > +\item \ref{drivernormative:Device Types / Network Device / Device 
> > > > Operation / Control Virtqueue / Split Header}
> > > >   \end{itemize}
> > > >
> > > >   \conformance{\subsection}{Block Driver 
> > > > Conformance}\label{sec:Conformance / Driver Conformance / Block Driver 
> > > > Conformance}
> > > > @@ -411,6 +412,7 @@ \section{Conformance Targets}\label{sec:Conformance 
> > > > / Conformance Targets}
> > > >   \item \ref{devicenormative:Device Types / Network Device / Device 
> > > > Operation / Control Virtqueue / Gratuitous Packet Sending}
> > > >   \item \ref{devicenormative:Device Types / Network Device / Device 
> > > > Operation / Control Virtqueue / Automatic receive steering in 
> > > > multiqueue mode}
> > > >   \item \ref{devicenormative:Device Types / Network Device / Device 
> > > > Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS 
> > > > processing}
> > > > +\item \ref{devicenormative:Device Types / Network Device / Device 
> > > > Operation / Control Virtqueue / Split Header}
> > > >   \end{itemize}
> > > >
> > > >   \conformance{\subsection}{Block Device 
> > > > Conformance}\label{sec:Conformance / Device Conformance / Block Device 
> > > > Conformance}
> > > > diff --git a/content.tex b/content.tex
> > > > index 060bdab..3340402 100644
> > > > --- a/content.tex
> > > > +++ b/content.tex
> > > > @@ -3092,6 +3092,9 @@ \subsection{Feature bits}\label{sec:Device Types 
> > > > / Network Device / Feature bits
> > > >   \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control
> > > >   channel.
> > > >
> > > > +\item[VIRTIO_NET_F_SPLIT_HEADER (55)] Device supports to split the 
> > > > header and
> > > > +the payload.
> > > > +
> > > >   \item[VIRTIO_NET_F_HOST_USO (56)] Device can receive USO packets. 
> > > > Unlike UFO
> > > >(fragmenting the packet) the USO splits large UDP packet
> > > >to several segments when each of these smaller packets has UDP 
> > > > header.
> > > > @@ -3139,6 +3142,7 @@ \subsubsection{Feature bit 
> > > > requirements}\label{sec:Device Types / Network Device
> > > >   \item[VIRTIO_NET_F_CTRL_MAC_ADDR] Requires VIRTIO_NET_F_CTRL_VQ.
> > > >   \item[VIRTIO_NET_F_RSC_EXT] Requires VIRTIO_NET_F_HOST_TSO4 or 
> > > > VIRTIO_NET_F_HOST_TSO6.
> > > >   \item[VIRTIO_NET_F_RSS] Requires VIRTIO_NET_F_CTRL_VQ.
> > > > +\item[VIRTIO_NET_F_SPLIT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ.
> > > >   \end{description}
> > > >
> > > >   \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types 
> > > > / Network Device / Feature bits / Legacy Interface: Feature bits}
> > > > @@ -3370,6 +3374,7 @@ \subsection{Device Operation}\label{sec:Device 
> > > > Types / Network Device / Device O
> > > >   #define VIRTIO_NET_HDR_F_NEEDS_CSUM1
> > > >   #define VIRTIO_NET_HDR_F_DATA_VALID2
> > > >   #define VIRTIO_NET_HDR_F_RSC_INFO  4
> > > > +#define VIRTIO_NET_HDR_F_SPLIT_HEADER  8
> > > >   u8 flags;
> > > >   #define VIRTIO_NET_HDR_GSO_NONE0
> > > >   #define VIRTIO_NET_HDR_GSO_TCPV4   1
> > > > @@ -4471,6 +4476,73 @@ \subsubsection{Control 
> > > > Virtqueue}\label{sec:Device Types / Network Device