virtio_net: support for split transport header
PATCH v8 1/1 virtio_net: support for split transport header
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) |
|<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload |
|<------------------------------->|
^
|
max_lenWe can use one page for every 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.
---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.
v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.
v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.
v5:
1. Determine when hdr_len is credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of merge
v4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wang
conformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)
conformance.tex +2 -0
@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}
@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}
content.tex +91 -0
121 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 190 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +84
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet. + \item The packet is an IP fragmentation. + \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available. + \item The total size of the virtio net header and the transport header exceeds \field{max_len}. +\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer. +The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets. The maximum available length of the first buffer +used by the device is specified by \field{max_len}. If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. +
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4579
Quoted 10 lines
content.tex +7
-0+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}
Hi, I submitted split header v8 on the morning of the 16th, do you have any new comments?
Looking forward to your comments.
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 2 lines · Heng Qi
Hi, I submitted split header v8 on the morning of the 16th, do you have any new comments?
Sit tight please, I can't review that quickly. I know some maintainers are much better, sorry!
Signature · 6 lines
MST --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 162 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +56
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4551
Quoted 10 lines
content.tex +10
-0+VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet. + \item The packet is an IP fragmentation. + \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available.
So this means the feature is disabled for the device without merge-able buffer? Note that, even in the case of mergeable buffer, it doesn't mean a buffer that only contains a single descriptor.
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4552
Quoted 1 line
content.tex +1
-0+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.
I don't get the reason why we need max_len. Can't it implied in the length of the first descriptor?
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 13 lines
content.tex +13
-0+\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer. +The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.
Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new max_len).
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4567
Quoted 2 lines
content.tex +1
-0The maximum available length of the first buffer +used by the device is specified by \field{max_len}.
Similarly the max length seems to be implied by length - offset?
Thanks
Quoted 12 lines
content.tex +10
-0If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. + +\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header.
Quoted 2 lines
\paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 165 lines · Jason Wang
Quoted 163 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +63
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet. + \item The packet is an IP fragmentation.
Quoted 10 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4551
Quoted 3 lines
content.tex +3
-0+ \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available.So this means the feature is disabled for the device without merge-able buffer? Note that, even in the case of mergeable buffer, it doesn't mean a buffer that only contains a single descriptor.
Yes, since the purpose of this scheme is to no longer depend on descriptor chains, the buffer submitted to the receiveq can be thought of as containing only one descriptor. So this feature depends on the mergeable buffer.
Quoted 6 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4552
Quoted 1 line
content.tex +1
-0+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?
Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
content.tex +10
-0+\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.
Quoted 9 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 3 lines
content.tex +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.
Quoted 3 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4566
Quoted 3 lines
content.tex +1
-0The maximum available length of the first buffer +used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 15 lines
Thanks
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4578
Quoted 12 lines
content.tex +10
-0If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. + +\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 178 lines · Heng Qi
Quoted 165 lines · Jason Wang
Quoted 163 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +63
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet. + \item The packet is an IP fragmentation.Quoted 10 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4551
Quoted 3 lines
content.tex +3
-0+ \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available.So this means the feature is disabled for the device without merge-able buffer? Note that, even in the case of mergeable buffer, it doesn't mean a buffer that only contains a single descriptor.
Quoted 3 lines
Yes, since the purpose of this scheme is to no longer depend on descriptor chains, the buffer submitted to the receiveq can be thought of as containing only one descriptor. So this feature depends on the mergeable buffer.
To tell the truth, I'm not sure this is a good choice. We never had a feature that depends solely on the mergeable rx buffer before. Especially considering that using a descriptor chain is not hard. And I'm not sure we should care too much on the overhead since the splitting is enabled by the administrator when it needs e.g zerocopy.
Quoted 33 lines
Quoted 7 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4552
Quoted 2 lines
content.tex +1
-0+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
content.tex +10
-0+\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 3 lines
content.tex +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).
Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.
Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 23 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4566
Quoted 3 lines
content.tex +1
-0The maximum available length of the first buffer +used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
content.tex +3
-0If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4578
Quoted 8 lines
content.tex +7
-0+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 184 lines · Jason Wang
Quoted 178 lines · Heng Qi
Quoted 165 lines · Jason Wang
Quoted 163 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +63
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet. + \item The packet is an IP fragmentation.Quoted 10 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4551
Quoted 3 lines
content.tex +3
-0+ \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available.So this means the feature is disabled for the device without merge-able buffer? Note that, even in the case of mergeable buffer, it doesn't mean a buffer that only contains a single descriptor.
Quoted 3 lines
Yes, since the purpose of this scheme is to no longer depend on descriptor chains, the buffer submitted to the receiveq can be thought of as containing only one descriptor. So this feature depends on the mergeable buffer.
Quoted 17 lines
To tell the truth, I'm not sure this is a good choice. We never had a feature that depends solely on the mergeable rx buffer before. Especially considering that using a descriptor chain is not hard. And I'm not sure we should care too much on the overhead since the splitting is enabled by the administrator when it needs e.g zerocopy.
Quoted 11 lines
Quoted 7 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4552
Quoted 2 lines
content.tex +1
-0+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
But this doesn't answer the question, without max_len, if tailroom is needed, we can simply allocate a larger buffer?
Thanks
Quoted 27 lines
Quoted 22 lines
Quoted 12 lines
Quoted 12 lines
content.tex +10
-0+\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 3 lines
content.tex +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.
Quoted 41 lines
Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 36 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4566
Quoted 3 lines
content.tex +1
-0The maximum available length of the first buffer +used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 15 lines
Thanks
Quoted 12 lines
content.tex +10
-0If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. + +\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 183 lines · Jason Wang
Quoted 178 lines · Heng Qi
Quoted 165 lines · Jason Wang
Quoted 163 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +63
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet. + \item The packet is an IP fragmentation.Quoted 10 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4551
Quoted 3 lines
content.tex +3
-0+ \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available.So this means the feature is disabled for the device without merge-able buffer? Note that, even in the case of mergeable buffer, it doesn't mean a buffer that only contains a single descriptor.
Quoted 3 lines
Yes, since the purpose of this scheme is to no longer depend on descriptor chains, the buffer submitted to the receiveq can be thought of as containing only one descriptor. So this feature depends on the mergeable buffer.
Quoted 5 lines
To tell the truth, I'm not sure this is a good choice. We never had a feature that depends solely on the mergeable rx buffer before. Especially considering that using a descriptor chain is not hard. And I'm not sure we should care too much on the overhead since the splitting is enabled by the administrator when it needs e.g zerocopy.
It's overwhelmed us, and we haven't been able to agree on this.
Michael doesn't want to use desc chain, it's not just a performance issue. In an early email, he mentioned that desc chain may be abandoned in the future. So we have been trying not to rely on desc chain.
If we can't make a feature depend only on mergeable, should we use solution B?
2. Scheme B ( refer to your suggestion )
Our rethinking approach is no longer based on descriptor chain.
We refer to your proposed offset-based scheme as scheme B. As you suggested, scheme B gives the device a buffer, using offset to indicate where to place the payload. Like this:
<header>...<padding>... <beginning of page><data>
But how to apply for this buffer?
Since we want the payload to be placed on a separate page, the method we consider is to directly alloc two pages from driver of contiguous memory.
Then the beginning of this contiguous memory is used to store the headroom, and the contiguous memory after the headroom is directly handed over to the device. Similar to the following:
[------------------ receive buffer(2 pages) ------------------------------] [<------------first page -------------------><------ second page -------->]
[<-----><virtnet hdr> <mac,ip,tcp>..<padding>< payload >]
^ ^
| |
| pointer to device
|
|
Driver reserved, the later part is filled
We have already entered v8, but we have not been able to reach an agreement on the basic capabilities. I want to solve this problem first.
@Jason @Michael
Thanks.
Quoted 82 lines
Quoted 34 lines
Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4552
Quoted 3 lines
content.tex +1
-0+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
content.tex +10
-0+\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 3 lines
content.tex +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 23 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4566
Quoted 3 lines
content.tex +1
-0The maximum available length of the first buffer +used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
content.tex +3
-0If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4578
Quoted 8 lines
content.tex +7
-0+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}
Quoted 4 lines
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 185 lines · Xuan Zhuo
Quoted 183 lines · Jason Wang
Quoted 181 lines · Heng Qi
Quoted 165 lines · Jason Wang
Quoted 163 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +63
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet. + \item The packet is an IP fragmentation.Quoted 10 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4551
Quoted 3 lines
content.tex +3
-0+ \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available.So this means the feature is disabled for the device without merge-able buffer? Note that, even in the case of mergeable buffer, it doesn't mean a buffer that only contains a single descriptor.
Yes, since the purpose of this scheme is to no longer depend on descriptor chains, the buffer submitted to the receiveq can be thought of as containing only one descriptor. So this feature depends on the mergeable buffer.
Quoted 8 lines
Quoted 5 lines
To tell the truth, I'm not sure this is a good choice. We never had a feature that depends solely on the mergeable rx buffer before. Especially considering that using a descriptor chain is not hard. And I'm not sure we should care too much on the overhead since the splitting is enabled by the administrator when it needs e.g zerocopy.
It's overwhelmed us, and we haven't been able to agree on this.
Sorry for this but let's make an agreement before posting a new version.
Quoted 4 lines
Michael doesn't want to use desc chain, it's not just a performance issue. In an early email, he mentioned that desc chain may be abandoned in the future. So we have been trying not to rely on desc chain.
This seems to be a very large change which seems a little bit too early to be considered.
Quoted 8 lines
If we can't make a feature depend only on mergeable, should we use solution B?
2. Scheme B ( refer to your suggestion )
Our rethinking approach is no longer based on descriptor chain.
We refer to your proposed offset-based scheme as scheme B.
The offset seems to be the suggestion of Michael.
I think I like the design of v7 for several reasons:
1) easy to reserve head/tailroom without any extension of the spec
2) easy to work with mergeable rx buffer
3) it is the model used by modern NIC like e810 [1]
[1] e810 manual 2.4 Figure 10-4 have a nic diagram to demonstrate how it works which is similar to v7
Thanks
Quoted 23 lines
As you suggested, scheme B gives the device a buffer, using offset to indicate where to place the payload. Like this:
<header>...<padding>... <beginning of page><data>
But how to apply for this buffer?
Since we want the payload to be placed on a separate page, the method we consider is to directly alloc two pages from driver of contiguous memory.Then the beginning of this contiguous memory is used to store the headroom, and the contiguous memory after the headroom is directly handed over to the device. Similar to the following:
[------------------ receive buffer(2 pages) ------------------------------] [<------------first page -------------------><------ second page -------->]
[<-----><virtnet hdr> <mac,ip,tcp>..<padding>< payload >]
^ ^
| |
| pointer to device
|
|
Driver reserved, the later part is filled
Quoted 98 lines
We have already entered v8, but we have not been able to reach an agreement on the basic capabilities. I want to solve this problem first.
@Jason @Michael
Thanks.
Quoted 86 lines
Quoted 34 lines
Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4552
Quoted 3 lines
content.tex +1
-0+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
content.tex +10
-0+\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 3 lines
content.tex +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 23 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4566
Quoted 3 lines
content.tex +1
-0The maximum available length of the first buffer +used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
content.tex +3
-0If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4578
Quoted 8 lines
content.tex +7
-0+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 193 lines · Jason Wang
Quoted 192 lines · Xuan Zhuo
Quoted 188 lines · Jason Wang
Quoted 178 lines · Heng Qi
Quoted 165 lines · Jason Wang
Quoted 163 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +63
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet. + \item The packet is an IP fragmentation.Quoted 10 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4551
Quoted 3 lines
content.tex +3
-0+ \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available.So this means the feature is disabled for the device without merge-able buffer? Note that, even in the case of mergeable buffer, it doesn't mean a buffer that only contains a single descriptor.
Quoted 3 lines
Yes, since the purpose of this scheme is to no longer depend on descriptor chains, the buffer submitted to the receiveq can be thought of as containing only one descriptor. So this feature depends on the mergeable buffer.
To tell the truth, I'm not sure this is a good choice. We never had a feature that depends solely on the mergeable rx buffer before. Especially considering that using a descriptor chain is not hard. And I'm not sure we should care too much on the overhead since the splitting is enabled by the administrator when it needs e.g zerocopy.
Quoted 3 lines
Quoted 1 line
It's overwhelmed us, and we haven't been able to agree on this.
Sorry for this but let's make an agreement before posting a new version.
Right, let's do that.
Jason I think the issue with previous proposals is that they conflict with VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.
Quoted 7 lines
Quoted 4 lines
Michael doesn't want to use desc chain, it's not just a performance issue. In an early email, he mentioned that desc chain may be abandoned in the future. So we have been trying not to rely on desc chain.
This seems to be a very large change which seems a little bit too early to be considered.
I'd like to put it in other terms. Fundamentally devices are not supposed to talk about descriptors at all. Descriptors are
a way to describe buffers, and devices should all work in terms of buffers. I am working on cleaning up the spec from confusion and terminology mixups. We have several major sources all over the spec:
- descriptor/buffer used inconsistently
- feature negotiated/offered used inconsistently
- field exists/valid used inconsistently
My way to address the first issue is to make sure devices all work with buffers. And buffers are described by descriptors (makes sense, right?) and made available to device by driver and used by device.
The advantage of this is layering - we can change the way buffers are passed around without changing devices. And, it matches the virtio API nicely.
Existing devices are all fine with this - they do not pass any information in the descriptor. Yes, this seems like an option to pass some information around, but I am not convinced it is worth the layering violation.
By comparison, ability to write data at an offset seems generally useful, in particular we have a very old issue even without the split header feature where with mergeable buffers
if we attempt to align the data in the 1st buffer at a cache line boundary by adding an offset before ETH header, then when it spills over to the second buffer it will be misaligned there. Wastes an extra cache line for such packets. Offsets can allow fixing this.
I don't see architecturally what is wrong with making feature just depend on mergeable buffers for now. We can always allow a combination down the road. Let's just make it clear that if drivers see SPLIT && !MERGEABLE they should not fail probe, they should instead clear the split header feature.
Quoted 13 lines
Quoted 8 lines
If we can't make a feature depend only on mergeable, should we use solution B?
2. Scheme B ( refer to your suggestion )
Our rethinking approach is no longer based on descriptor chain.
We refer to your proposed offset-based scheme as scheme B.
The offset seems to be the suggestion of Michael.
I think I like the design of v7 for several reasons:
Quoted 130 lines
1) easy to reserve head/tailroom without any extension of the spec
2) easy to work with mergeable rx buffer
3) it is the model used by modern NIC like e810 [1][1] e810 manual 2.4 Figure 10-4 have a nic diagram to demonstrate how it works which is similar to v7
Thanks
Quoted 121 lines
As you suggested, scheme B gives the device a buffer, using offset to indicate where to place the payload. Like this:
<header>...<padding>... <beginning of page><data>
But how to apply for this buffer?
Since we want the payload to be placed on a separate page, the method we consider is to directly alloc two pages from driver of contiguous memory.Then the beginning of this contiguous memory is used to store the headroom, and the contiguous memory after the headroom is directly handed over to the device. Similar to the following:
[------------------ receive buffer(2 pages) ------------------------------] [<------------first page -------------------><------ second page -------->]
[<-----><virtnet hdr> <mac,ip,tcp>..<padding>< payload >]
^ ^
| |
| pointer to device
|
|
Driver reserved, the later part is filledWe have already entered v8, but we have not been able to reach an agreement on the basic capabilities. I want to solve this problem first.
@Jason @Michael
Thanks.
Quoted 86 lines
Quoted 34 lines
Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4552
Quoted 3 lines
content.tex +1
-0+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
content.tex +10
-0+\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 3 lines
content.tex +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 23 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4566
Quoted 3 lines
content.tex +1
-0The maximum available length of the first buffer +used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
content.tex +3
-0If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4578
Quoted 8 lines
content.tex +7
-0+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 222 lines · Michael S. Tsirkin
Quoted 193 lines · Jason Wang
Quoted 192 lines · Xuan Zhuo
Quoted 188 lines · Jason Wang
Quoted 178 lines · Heng Qi
Quoted 165 lines · Jason Wang
Quoted 163 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +63
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet. + \item The packet is an IP fragmentation.Quoted 10 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4550
Quoted 3 lines
content.tex +3
-0+ \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available.So this means the feature is disabled for the device without merge-able buffer? Note that, even in the case of mergeable buffer, it doesn't mean a buffer that only contains a single descriptor.
Quoted 3 lines
Yes, since the purpose of this scheme is to no longer depend on descriptor chains, the buffer submitted to the receiveq can be thought of as containing only one descriptor. So this feature depends on the mergeable buffer.
To tell the truth, I'm not sure this is a good choice. We never had a feature that depends solely on the mergeable rx buffer before. Especially considering that using a descriptor chain is not hard. And I'm not sure we should care too much on the overhead since the splitting is enabled by the administrator when it needs e.g zerocopy.
Quoted 3 lines
Quoted 1 line
It's overwhelmed us, and we haven't been able to agree on this.
Sorry for this but let's make an agreement before posting a new version.
Right, let's do that.
Jason I think the issue with previous proposals is that they conflict withVIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Quoted 7 lines
Quoted 4 lines
Michael doesn't want to use desc chain, it's not just a performance issue. In an early email, he mentioned that desc chain may be abandoned in the future. So we have been trying not to rely on desc chain.
This seems to be a very large change which seems a little bit too early to be considered.
I'd like to put it in other terms. Fundamentally devices are not supposed to talk about descriptors at all. Descriptors are
a way to describe buffers, and devices should all work in terms of buffers. I am working on cleaning up the spec from confusion and terminology mixups. We have several major sources all over the spec:
- descriptor/buffer used inconsistently
- feature negotiated/offered used inconsistently
- field exists/valid used inconsistently
Quoted 3 lines
My way to address the first issue is to make sure devices all work with buffers. And buffers are described by descriptors (makes sense, right?) and made available to device by driver and used by device.
Can we try to keep desc info? I think it's a very important feature for virtio-net, and many NICs are designed based on this.
Our current solutions B and C will waste a lot of memory. If the page occupied by the header can be quickly reclaimed, then we have to do a copy in the driver.
Quoted 10 lines
The advantage of this is layering - we can change the way buffers are passed around without changing devices. And, it matches the virtio API nicely.
Existing devices are all fine with this - they do not pass any information in the descriptor. Yes, this seems like an option to pass some information around, but I am not convinced it is worth the layering violation.
Quoted 8 lines
By comparison, ability to write data at an offset seems generally useful, in particular we have a very old issue even without the split header feature where with mergeable buffers
if we attempt to align the data in the 1st buffer at a cache line boundary by adding an offset before ETH header, then when it spills over to the second buffer it will be misaligned there. Wastes an extra cache line for such packets. Offsets can allow fixing this.
Scheme B In addition to the memory problem, under this scheme, if we want to implement tcp zerocopy, then we must apply for two consecutive pages for a buffer. The second page is used to place the payload. The first is used to place the header.
Quoted 7 lines
I don't see architecturally what is wrong with making feature just depend on mergeable buffers for now. We can always allow a combination down the road. Let's just make it clear that if drivers see SPLIT && !MERGEABLE they should not fail probe, they should instead clear the split header feature.
According to my understanding, for B, it does not depend on mergeable.
If we give up desc info completely, then we prefer B.
Hi Jason, what are your thoughts?
Thanks.
Quoted 148 lines
Quoted 16 lines
Quoted 11 lines
If we can't make a feature depend only on mergeable, should we use solution B?
2. Scheme B ( refer to your suggestion )
Our rethinking approach is no longer based on descriptor chain.
We refer to your proposed offset-based scheme as scheme B.
The offset seems to be the suggestion of Michael.
I think I like the design of v7 for several reasons:
Quoted 130 lines
1) easy to reserve head/tailroom without any extension of the spec
2) easy to work with mergeable rx buffer
3) it is the model used by modern NIC like e810 [1][1] e810 manual 2.4 Figure 10-4 have a nic diagram to demonstrate how it works which is similar to v7
Thanks
Quoted 121 lines
As you suggested, scheme B gives the device a buffer, using offset to indicate where to place the payload. Like this:
<header>...<padding>... <beginning of page><data>
But how to apply for this buffer?
Since we want the payload to be placed on a separate page, the method we consider is to directly alloc two pages from driver of contiguous memory.Then the beginning of this contiguous memory is used to store the headroom, and the contiguous memory after the headroom is directly handed over to the device. Similar to the following:
[------------------ receive buffer(2 pages) ------------------------------] [<------------first page -------------------><------ second page -------->]
[<-----><virtnet hdr> <mac,ip,tcp>..<padding>< payload >]
^ ^
| |
| pointer to device
|
|
Driver reserved, the later part is filledWe have already entered v8, but we have not been able to reach an agreement on the basic capabilities. I want to solve this problem first.
@Jason @Michael
Thanks.
Quoted 86 lines
Quoted 34 lines
Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4551
Quoted 3 lines
content.tex +1
-0+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
content.tex +10
-0+\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4564
Quoted 3 lines
content.tex +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 23 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4566
Quoted 3 lines
content.tex +1
-0The maximum available length of the first buffer +used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
content.tex +3
-0If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4578
Quoted 8 lines
content.tex +7
-0+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 4 lines
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 20 lines · Xuan Zhuo
Quoted 16 lines
Quoted 6 lines
Quoted 3 lines
Michael doesn't want to use desc chain, it's not just a performance issue. In an early email, he mentioned that desc chain may be abandoned in the future. So we have been trying not to rely on desc chain.
This seems to be a very large change which seems a little bit too early to be considered.
I'd like to put it in other terms. Fundamentally devices are not supposed to talk about descriptors at all. Descriptors are
a way to describe buffers, and devices should all work in terms of buffers. I am working on cleaning up the spec from confusion and terminology mixups. We have several major sources all over the spec:
- descriptor/buffer used inconsistently
- feature negotiated/offered used inconsistently
- field exists/valid used inconsistentlyQuoted 3 lines
My way to address the first issue is to make sure devices all work with buffers. And buffers are described by descriptors (makes sense, right?) and made available to device by driver and used by device.
Quoted 5 lines
Can we try to keep desc info? I think it's a very important feature for virtio-net, and many NICs are designed based on this.
Our current solutions B and C will waste a lot of memory. If the page occupied by the header can be quickly reclaimed, then we have to do a copy in the driver.
Not sure I understand. Can you explain?
Quoted 19 lines
Quoted 10 lines
The advantage of this is layering - we can change the way buffers are passed around without changing devices. And, it matches the virtio API nicely.
Existing devices are all fine with this - they do not pass any information in the descriptor. Yes, this seems like an option to pass some information around, but I am not convinced it is worth the layering violation.
Quoted 8 lines
By comparison, ability to write data at an offset seems generally useful, in particular we have a very old issue even without the split header feature where with mergeable buffers
if we attempt to align the data in the 1st buffer at a cache line boundary by adding an offset before ETH header, then when it spills over to the second buffer it will be misaligned there. Wastes an extra cache line for such packets. Offsets can allow fixing this.
Quoted 4 lines
Scheme B In addition to the memory problem, under this scheme, if we want to implement tcp zerocopy, then we must apply for two consecutive pages for a buffer. The second page is used to place the payload. The first is used to place the header.
I just don't understand why there would be a difference. Explanation?
Quoted 9 lines
Quoted 8 lines
I don't see architecturally what is wrong with making feature just depend on mergeable buffers for now. We can always allow a combination down the road. Let's just make it clear that if drivers see SPLIT && !MERGEABLE they should not fail probe, they should instead clear the split header feature.
Quoted 160 lines
According to my understanding, for B, it does not depend on mergeable.
If we give up desc info completely, then we prefer B.
Hi Jason, what are your thoughts?
Thanks.
Quoted 152 lines
Quoted 16 lines
Quoted 11 lines
If we can't make a feature depend only on mergeable, should we use solution B?
2. Scheme B ( refer to your suggestion )
Our rethinking approach is no longer based on descriptor chain.
We refer to your proposed offset-based scheme as scheme B.
The offset seems to be the suggestion of Michael.
I think I like the design of v7 for several reasons:
Quoted 130 lines
1) easy to reserve head/tailroom without any extension of the spec
2) easy to work with mergeable rx buffer
3) it is the model used by modern NIC like e810 [1][1] e810 manual 2.4 Figure 10-4 have a nic diagram to demonstrate how it works which is similar to v7
Thanks
Quoted 121 lines
As you suggested, scheme B gives the device a buffer, using offset to indicate where to place the payload. Like this:
<header>...<padding>... <beginning of page><data>
But how to apply for this buffer?
Since we want the payload to be placed on a separate page, the method we consider is to directly alloc two pages from driver of contiguous memory.Then the beginning of this contiguous memory is used to store the headroom, and the contiguous memory after the headroom is directly handed over to the device. Similar to the following:
[------------------ receive buffer(2 pages) ------------------------------] [<------------first page -------------------><------ second page -------->]
[<-----><virtnet hdr> <mac,ip,tcp>..<padding>< payload >]
^ ^
| |
| pointer to device
|
|
Driver reserved, the later part is filledWe have already entered v8, but we have not been able to reach an agreement on the basic capabilities. I want to solve this problem first.
@Jason @Michael
Thanks.
Quoted 86 lines
Quoted 34 lines
Quoted 8 lines
Quoted 3 lines
+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.
I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
+\end{itemize}
(quoted diff) +9
-0+ +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 23 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
Quoted 3 lines
The maximum available length of the first buffer
+used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
If \field{max_len} is 0 or
+$ \field{offset} + \field{max_len} $ is greater than the length of the buffer,(quoted diff) +2
-0+the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
Review
Quoted 8 lines
+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header}
(quoted diff) +6
-0+ +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 21 lines · Michael S. Tsirkin
Quoted 20 lines · Xuan Zhuo
Quoted 19 lines
Quoted 6 lines
Quoted 3 lines
Michael doesn't want to use desc chain, it's not just a performance issue. In an early email, he mentioned that desc chain may be abandoned in the future. So we have been trying not to rely on desc chain.
This seems to be a very large change which seems a little bit too early to be considered.
I'd like to put it in other terms. Fundamentally devices are not supposed to talk about descriptors at all. Descriptors are
a way to describe buffers, and devices should all work in terms of buffers. I am working on cleaning up the spec from confusion and terminology mixups. We have several major sources all over the spec:
- descriptor/buffer used inconsistently
- feature negotiated/offered used inconsistently
- field exists/valid used inconsistentlyMy way to address the first issue is to make sure devices all work with buffers. And buffers are described by descriptors (makes sense, right?) and made available to device by driver and used by device.
Quoted 7 lines
Quoted 5 lines
Can we try to keep desc info? I think it's a very important feature for virtio-net, and many NICs are designed based on this.
Our current solutions B and C will waste a lot of memory. If the page occupied by the header can be quickly reclaimed, then we have to do a copy in the driver.
Not sure I understand. Can you explain?
For example B, we allocate two consecutive pages, the second page is used for payload. The first page is used to reserve the header. The first page is too wasteful, 4k of space, only the header is saved. In this way, we can copy away the data of the first page, so that the first page can be quickly reclaimed.
Why two consecutive pages? The payload achieves page alignment, and there is still some space in front of the page, so we must allocate two connected pages.
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
The advantage of this is layering - we can change the way buffers are passed around without changing devices. And, it matches the virtio API nicely.
Existing devices are all fine with this - they do not pass any information in the descriptor. Yes, this seems like an option to pass some information around, but I am not convinced it is worth the layering violation.
By comparison, ability to write data at an offset seems generally useful, in particular we have a very old issue even without the split header feature where with mergeable buffers
if we attempt to align the data in the 1st buffer at a cache line boundary by adding an offset before ETH header, then when it spills over to the second buffer it will be misaligned there. Wastes an extra cache line for such packets. Offsets can allow fixing this.
Quoted 7 lines
Quoted 4 lines
Scheme B In addition to the memory problem, under this scheme, if we want to implement tcp zerocopy, then we must apply for two consecutive pages for a buffer. The second page is used to place the payload. The first is used to place the header.
I just don't understand why there would be a difference. Explanation?
I'm concerned that allocating two contiguous pages in large numbers will cause unknowable problems(such perfermance)
Thanks.
Quoted 166 lines
Quoted 166 lines
Quoted 9 lines
I don't see architecturally what is wrong with making feature just depend on mergeable buffers for now. We can always allow a combination down the road. Let's just make it clear that if drivers see SPLIT && !MERGEABLE they should not fail probe, they should instead clear the split header feature.
According to my understanding, for B, it does not depend on mergeable.
If we give up desc info completely, then we prefer B.
Hi Jason, what are your thoughts?
Thanks.
Quoted 148 lines
Quoted 146 lines
Quoted 11 lines
If we can't make a feature depend only on mergeable, should we use solution B?
2. Scheme B ( refer to your suggestion )
Our rethinking approach is no longer based on descriptor chain.
We refer to your proposed offset-based scheme as scheme B.
The offset seems to be the suggestion of Michael.
I think I like the design of v7 for several reasons:
1) easy to reserve head/tailroom without any extension of the spec
2) easy to work with mergeable rx buffer
3) it is the model used by modern NIC like e810 [1][1] e810 manual 2.4 Figure 10-4 have a nic diagram to demonstrate how it works which is similar to v7
Thanks
Quoted 121 lines
As you suggested, scheme B gives the device a buffer, using offset to indicate where to place the payload. Like this:
<header>...<padding>... <beginning of page><data>
But how to apply for this buffer?
Since we want the payload to be placed on a separate page, the method we consider is to directly alloc two pages from driver of contiguous memory.Then the beginning of this contiguous memory is used to store the headroom, and the contiguous memory after the headroom is directly handed over to the device. Similar to the following:
[------------------ receive buffer(2 pages) ------------------------------] [<------------first page -------------------><------ second page -------->]
[<-----><virtnet hdr> <mac,ip,tcp>..<padding>< payload >]
^ ^
| |
| pointer to device
|
|
Driver reserved, the later part is filledWe have already entered v8, but we have not been able to reach an agreement on the basic capabilities. I want to solve this problem first.
@Jason @Michael
Thanks.
Quoted 86 lines
Quoted 34 lines
Quoted 8 lines
Quoted 3 lines
+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.
I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
+\end{itemize}
(quoted diff) +9
-0+ +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 23 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
Quoted 3 lines
The maximum available length of the first buffer
+used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
If \field{max_len} is 0 or
+$ \field{offset} + \field{max_len} $ is greater than the length of the buffer,(quoted diff) +2
-0+the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
Review
Quoted 8 lines
+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header}
(quoted diff) +6
-0+ +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 31 lines · Xuan Zhuo
Quoted 21 lines · Michael S. Tsirkin
Quoted 20 lines · Xuan Zhuo
Quoted 19 lines
Quoted 6 lines
Quoted 3 lines
Michael doesn't want to use desc chain, it's not just a performance issue. In an early email, he mentioned that desc chain may be abandoned in the future. So we have been trying not to rely on desc chain.
This seems to be a very large change which seems a little bit too early to be considered.
I'd like to put it in other terms. Fundamentally devices are not supposed to talk about descriptors at all. Descriptors are
a way to describe buffers, and devices should all work in terms of buffers. I am working on cleaning up the spec from confusion and terminology mixups. We have several major sources all over the spec:
- descriptor/buffer used inconsistently
- feature negotiated/offered used inconsistently
- field exists/valid used inconsistentlyMy way to address the first issue is to make sure devices all work with buffers. And buffers are described by descriptors (makes sense, right?) and made available to device by driver and used by device.
Quoted 7 lines
Quoted 5 lines
Can we try to keep desc info? I think it's a very important feature for virtio-net, and many NICs are designed based on this.
Our current solutions B and C will waste a lot of memory. If the page occupied by the header can be quickly reclaimed, then we have to do a copy in the driver.
Not sure I understand. Can you explain?
Quoted 7 lines
For example B, we allocate two consecutive pages, the second page is used for payload. The first page is used to reserve the header. The first page is too wasteful, 4k of space, only the header is saved. In this way, we can copy away the data of the first page, so that the first page can be quickly reclaimed.
Why two consecutive pages? The payload achieves page alignment, and there is still some space in front of the page, so we must allocate two connected pages.
Are we talking without mergeable here?
Quoted 26 lines
Quoted 26 lines
Quoted 24 lines
Quoted 11 lines
The advantage of this is layering - we can change the way buffers are passed around without changing devices. And, it matches the virtio API nicely.
Existing devices are all fine with this - they do not pass any information in the descriptor. Yes, this seems like an option to pass some information around, but I am not convinced it is worth the layering violation.
Quoted 8 lines
By comparison, ability to write data at an offset seems generally useful, in particular we have a very old issue even without the split header feature where with mergeable buffers
if we attempt to align the data in the 1st buffer at a cache line boundary by adding an offset before ETH header, then when it spills over to the second buffer it will be misaligned there. Wastes an extra cache line for such packets. Offsets can allow fixing this.Scheme B In addition to the memory problem, under this scheme, if we want to implement tcp zerocopy, then we must apply for two consecutive pages for a buffer. The second page is used to place the payload. The first is used to place the header.
Quoted 179 lines
Quoted 1 line
I just don't understand why there would be a difference. Explanation?
I'm concerned that allocating two contiguous pages in large numbers will cause unknowable problems(such perfermance)
Thanks.
Quoted 171 lines
Quoted 170 lines
Quoted 9 lines
I don't see architecturally what is wrong with making feature just depend on mergeable buffers for now. We can always allow a combination down the road. Let's just make it clear that if drivers see SPLIT && !MERGEABLE they should not fail probe, they should instead clear the split header feature.
According to my understanding, for B, it does not depend on mergeable.
If we give up desc info completely, then we prefer B.
Hi Jason, what are your thoughts?
Thanks.
Quoted 152 lines
Quoted 16 lines
Quoted 11 lines
If we can't make a feature depend only on mergeable, should we use solution B?
2. Scheme B ( refer to your suggestion )
Our rethinking approach is no longer based on descriptor chain.
We refer to your proposed offset-based scheme as scheme B.
The offset seems to be the suggestion of Michael.
I think I like the design of v7 for several reasons:
Quoted 130 lines
1) easy to reserve head/tailroom without any extension of the spec
2) easy to work with mergeable rx buffer
3) it is the model used by modern NIC like e810 [1][1] e810 manual 2.4 Figure 10-4 have a nic diagram to demonstrate how it works which is similar to v7
Thanks
Quoted 121 lines
As you suggested, scheme B gives the device a buffer, using offset to indicate where to place the payload. Like this:
<header>...<padding>... <beginning of page><data>
But how to apply for this buffer?
Since we want the payload to be placed on a separate page, the method we consider is to directly alloc two pages from driver of contiguous memory.Then the beginning of this contiguous memory is used to store the headroom, and the contiguous memory after the headroom is directly handed over to the device. Similar to the following:
[------------------ receive buffer(2 pages) ------------------------------] [<------------first page -------------------><------ second page -------->]
[<-----><virtnet hdr> <mac,ip,tcp>..<padding>< payload >]
^ ^
| |
| pointer to device
|
|
Driver reserved, the later part is filledWe have already entered v8, but we have not been able to reach an agreement on the basic capabilities. I want to solve this problem first.
@Jason @Michael
Thanks.
Quoted 86 lines
Quoted 34 lines
Quoted 8 lines
Quoted 3 lines
+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.
I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
+\end{itemize}
(quoted diff) +9
-0+ +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 23 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
Quoted 3 lines
The maximum available length of the first buffer
+used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
If \field{max_len} is 0 or
+$ \field{offset} + \field{max_len} $ is greater than the length of the buffer,(quoted diff) +2
-0+the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
Review
Quoted 8 lines
+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header}
(quoted diff) +6
-0+ +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 37 lines · Michael S. Tsirkin
Quoted 36 lines · Xuan Zhuo
Quoted 21 lines · Michael S. Tsirkin
Quoted 20 lines · Xuan Zhuo
Quoted 19 lines
Quoted 6 lines
Quoted 3 lines
Michael doesn't want to use desc chain, it's not just a performance issue. In an early email, he mentioned that desc chain may be abandoned in the future. So we have been trying not to rely on desc chain.
This seems to be a very large change which seems a little bit too early to be considered.
I'd like to put it in other terms. Fundamentally devices are not supposed to talk about descriptors at all. Descriptors are
a way to describe buffers, and devices should all work in terms of buffers. I am working on cleaning up the spec from confusion and terminology mixups. We have several major sources all over the spec:
- descriptor/buffer used inconsistently
- feature negotiated/offered used inconsistently
- field exists/valid used inconsistentlyMy way to address the first issue is to make sure devices all work with buffers. And buffers are described by descriptors (makes sense, right?) and made available to device by driver and used by device.
Quoted 7 lines
Quoted 5 lines
Can we try to keep desc info? I think it's a very important feature for virtio-net, and many NICs are designed based on this.
Our current solutions B and C will waste a lot of memory. If the page occupied by the header can be quickly reclaimed, then we have to do a copy in the driver.
Not sure I understand. Can you explain?
For example B, we allocate two consecutive pages, the second page is used for payload. The first page is used to reserve the header. The first page is too wasteful, 4k of space, only the header is saved. In this way, we can copy away the data of the first page, so that the first page can be quickly reclaimed.
Quoted 4 lines
Quoted 2 lines
Why two consecutive pages? The payload achieves page alignment, and there is still some space in front of the page, so we must allocate two connected pages.
Are we talking without mergeable here?
I think B(offset) is not dependent on mergeable .
C must depend on mergeable.
Thanks.
Quoted 202 lines
Quoted 202 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
The advantage of this is layering - we can change the way buffers are passed around without changing devices. And, it matches the virtio API nicely.
Existing devices are all fine with this - they do not pass any information in the descriptor. Yes, this seems like an option to pass some information around, but I am not convinced it is worth the layering violation.
By comparison, ability to write data at an offset seems generally useful, in particular we have a very old issue even without the split header feature where with mergeable buffers
if we attempt to align the data in the 1st buffer at a cache line boundary by adding an offset before ETH header, then when it spills over to the second buffer it will be misaligned there. Wastes an extra cache line for such packets. Offsets can allow fixing this.Quoted 7 lines
Quoted 4 lines
Scheme B In addition to the memory problem, under this scheme, if we want to implement tcp zerocopy, then we must apply for two consecutive pages for a buffer. The second page is used to place the payload. The first is used to place the header.
I just don't understand why there would be a difference. Explanation?
I'm concerned that allocating two contiguous pages in large numbers will cause unknowable problems(such perfermance)
Thanks.
Quoted 166 lines
Quoted 166 lines
Quoted 9 lines
I don't see architecturally what is wrong with making feature just depend on mergeable buffers for now. We can always allow a combination down the road. Let's just make it clear that if drivers see SPLIT && !MERGEABLE they should not fail probe, they should instead clear the split header feature.
According to my understanding, for B, it does not depend on mergeable.
If we give up desc info completely, then we prefer B.
Hi Jason, what are your thoughts?
Thanks.
Quoted 148 lines
Quoted 146 lines
Quoted 11 lines
If we can't make a feature depend only on mergeable, should we use solution B?
2. Scheme B ( refer to your suggestion )
Our rethinking approach is no longer based on descriptor chain.
We refer to your proposed offset-based scheme as scheme B.
The offset seems to be the suggestion of Michael.
I think I like the design of v7 for several reasons:
1) easy to reserve head/tailroom without any extension of the spec
2) easy to work with mergeable rx buffer
3) it is the model used by modern NIC like e810 [1][1] e810 manual 2.4 Figure 10-4 have a nic diagram to demonstrate how it works which is similar to v7
Thanks
Quoted 121 lines
As you suggested, scheme B gives the device a buffer, using offset to indicate where to place the payload. Like this:
<header>...<padding>... <beginning of page><data>
But how to apply for this buffer?
Since we want the payload to be placed on a separate page, the method we consider is to directly alloc two pages from driver of contiguous memory.Then the beginning of this contiguous memory is used to store the headroom, and the contiguous memory after the headroom is directly handed over to the device. Similar to the following:
[------------------ receive buffer(2 pages) ------------------------------] [<------------first page -------------------><------ second page -------->]
[<-----><virtnet hdr> <mac,ip,tcp>..<padding>< payload >]
^ ^
| |
| pointer to device
|
|
Driver reserved, the later part is filledWe have already entered v8, but we have not been able to reach an agreement on the basic capabilities. I want to solve this problem first.
@Jason @Michael
Thanks.
Quoted 86 lines
Quoted 34 lines
Quoted 8 lines
Quoted 3 lines
+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.
I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 11 lines
Quoted 11 lines
+\end{itemize}
(quoted diff) +9
-0+ +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. + +\field{offset} and \field{max_len} are valid when device uses the first buffer.Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 23 lines
Quoted 4 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 7 lines
Quoted 3 lines
The maximum available length of the first buffer
+used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
If \field{max_len} is 0 or
+$ \field{offset} + \field{max_len} $ is greater than the length of the buffer,(quoted diff) +2
-0+the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
Review
Quoted 8 lines
+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header}
(quoted diff) +6
-0+ +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 187 lines · Michael S. Tsirkin
Quoted 186 lines · Jason Wang
Quoted 185 lines · Xuan Zhuo
Quoted 183 lines · Jason Wang
Quoted 174 lines · Heng Qi
Quoted 163 lines · Jason Wang
Quoted 162 lines · hengqi
From: Xuan Zhuo <[email protected]>
The purpose of this feature is to split the transport header and the payload of the packet.
| receive buffer1(page) | receive buffer2(page) | |<- offset ->| virtnet hdr | mac | ip | tcp |<- hold ->| payload | |<------------------------------->| ^ | max_lenWe can use one page for every 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 <[email protected]>Signed-off-by Heng Qi <[email protected]>Reviewed-by Kangjie Xu <[email protected]>---
v8:
1. Do not depend on descriptor chain. @Michael S. Tsirkin
2. Add \field{offset} and \field{max_len}.
3. Fix some presentation issues. @Jason Wang
4. Clarify some paragraphs.v7:
1. Fix some presentation issues.
2. Use "split transport header". @Jason Wang
3. Clarify some paragraphs. @Cornelia Huck
4. determine the device what to do if it does not perform header split on a packet.v6:
1. Fix some syntax issues. @Cornelia Huck
2. Clarify some paragraphs. @Cornelia Huck
3. Determine the device what to do if it does not perform header split on a packet.v5:
1. Determine whenhdr_lenis credible in the process of rx
2. Clean up the use of buffers and descriptors
3. Clarify the meaning of used lenght if the first descriptor is skipped in the case of mergev4:
1. fix typo @Cornelia Huck @Jason Wang
2. do not split header for IP fragmentation packet. @Jason Wangconformance.tex | 2 ++ content.tex | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)conformance.tex +2
-0@@ -150,6 +150,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{drivernormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Driver Conformance}\label{sec:Conformance / Driver Conformance / Block Driver Conformance}@@ -415,6 +416,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \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 / Notifications Coalescing} +\item \ref{devicenormative:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} \end{itemize} \conformance{\subsection}{Block Device Conformance}\label{sec:Conformance / Device Conformance / Block Device Conformance}content.tex +62
-0@@ -3084,6 +3084,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_TRANSPORT_HEADER (52)] Device supports splitting + the transport header and the payload. + \item[VIRTIO_NET_F_NOTF_COAL(53)] Device supports notifications coalescing. \item[VIRTIO_NET_F_GUEST_USO4 (54)] Driver can receive USOv4 packets.@@ -3140,6 +3143,7 @@ \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device \item[VIRTIO_NET_F_NOTF_COAL] 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_TRANSPORT_HEADER] Requires VIRTIO_NET_F_CTRL_VQ and VIRTIO_NET_F_MRG_RXBUF. \end{description} \subsubsection{Legacy Interface: Feature bits}\label{sec:Device Types / Network Device / Feature bits / Legacy Interface: Feature bits}@@ -3371,6 +3375,7 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 #define VIRTIO_NET_HDR_F_DATA_VALID 2 #define VIRTIO_NET_HDR_F_RSC_INFO 4 +#define VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER 8 u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 #define VIRTIO_NET_HDR_GSO_TCPV4 1@@ -3823,6 +3828,11 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network been negotiated, the driver MAY use \field{hdr_len} only as a hint about the transport header size. The driver MUST NOT rely on \field{hdr_len} to be correct. + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, +the driver SHOULD treat the \field{hdr_len} as the length of the transport +header inside the first buffer. + \begin{note} This is due to various bugs in implementations. \end{note}@@ -4483,6 +4493,87 @@ \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 Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER feature is negotiated, +the device supports splitting the transport header and the payload. +The transport header and the payload will be separated into different +buffers. + +\subparagraph{Split Transport Header}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header / Setting Split Transport Header} + +To configure the split transport header, the following layout structure +and definitions are used: + +\begin{lstlisting} +struct virtio_net_split_transport_header_config { +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4 (1 << 0) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6 (1 << 1) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4 (1 << 2) +#define VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6 (1 << 3) + le64 type; + le16 offset; + le16 max_len; +}; + +#define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER 6 + #define VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET 0 +\end{lstlisting} + +The class VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER has one command: +VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET applies the new split +header configuration. + +The driver can enable or disable split transport header for different transport +protocols by setting or clearing corresponding bits in \field{type}. + +\begin{itemize} + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4: split after ipv4 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6: split after ipv6 tcp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4: split after ipv4 udp header + \item VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6: split after ipv6 udp header +\end{itemize} + +\devicenormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +A device MUST disable transport header splitting upon reset and initialization. + +If VIRTIO_NET_F_SPLIT_TRANSPORT_HEADER is negotiated, the device MUST support +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_TCP6, +VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP4, VIRTIO_NET_SPLIT_TRANSPORT_HEADER_TYPE_UDP6. + +A device MUST NOT split the transport header if it encounters any of the following cases: +\begin{itemize} + \item The device does not recognize the transport protocol of the packet.Quoted 10 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4550
Quoted 4 lines
content.tex +4
-0+ \item The packet is an IP fragmentation. + \item The splitting of the specific transport protocol is not enabled via + VIRTIO_NET_CTRL_SPLIT_TRANSPORT_HEADER_SET. + \item At most one buffer is available.So this means the feature is disabled for the device without merge-able buffer? Note that, even in the case of mergeable buffer, it doesn't mean a buffer that only contains a single descriptor.
Quoted 3 lines
Yes, since the purpose of this scheme is to no longer depend on descriptor chains, the buffer submitted to the receiveq can be thought of as containing only one descriptor. So this feature depends on the mergeable buffer.
To tell the truth, I'm not sure this is a good choice. We never had a feature that depends solely on the mergeable rx buffer before. Especially considering that using a descriptor chain is not hard. And I'm not sure we should care too much on the overhead since the splitting is enabled by the administrator when it needs e.g zerocopy.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
It's overwhelmed us, and we haven't been able to agree on this.
Sorry for this but let's make an agreement before posting a new version.
Right, let's do that.
Jason I think the issue with previous proposals is that they conflict withVIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.
Yes, but I didn't found how it can conflict the any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Michael doesn't want to use desc chain, it's not just a performance issue. In an early email, he mentioned that desc chain may be abandoned in the future. So we have been trying not to rely on desc chain.
This seems to be a very large change which seems a little bit too early to be considered.
Quoted 8 lines
I'd like to put it in other terms. Fundamentally devices are not supposed to talk about descriptors at all. Descriptors are
a way to describe buffers, and devices should all work in terms of buffers. I am working on cleaning up the spec from confusion and terminology mixups. We have several major sources all over the spec:
- descriptor/buffer used inconsistently
- feature negotiated/offered used inconsistently
- field exists/valid used inconsistently
Ok.
Quoted 8 lines
My way to address the first issue is to make sure devices all work with buffers. And buffers are described by descriptors (makes sense, right?) and made available to device by driver and used by device.
The advantage of this is layering - we can change the way buffers are passed around without changing devices. And, it matches the virtio API nicely.
Yes, but this looks more like a spec tweak instead of a problem existed now: Driver doesn't care about the descriptors since driver talks to virtio core with sg so it has sufficient flexibility to organize the layout to what it wants.
1) sg #1, vnet_headers + l2/l3/l4 header
2) sg #2, l4 payload
For direct/indirect descriptors, core can simply using direct/indirect descriptor chain to describe the sg and place the payload in second buffer (instead of the descriptor).
For mergeable buffer, it might be more challenge since it's not easy to know if a buffer will be used for header or payload in advance. This makes it not easy to align payload buffer at page boundary especially consider packet header may need headrooms. We can't simply allocate pages and feed them to the device, that calls some new facilities:
1) offset to write as suggested by this patch, some memory might be wasted for the buffer that is used for header.
2) or device can assume header/payload buffers so driver can post buffers like:
2.1) header buffer #1
2.2) payload buffer #1
2.3) header buffer #2
2.4) payload buffer #2
...
There could be some transitional overhead (memory/descriptor wasting) when enabling and disabling header splitting but it should be affordable.
Quoted 6 lines
Existing devices are all fine with this - they do not pass any information in the descriptor. Yes, this seems like an option to pass some information around, but I am not convinced it is worth the layering violation.
Quoted 7 lines
By comparison, ability to write data at an offset seems generally useful, in particular we have a very old issue even without the split header feature where with mergeable buffers
if we attempt to align the data in the 1st buffer at a cache line boundary by adding an offset before ETH header, then when it spills over to the second buffer it will be misaligned there. Wastes an extra cache line for such packets. Offsets can allow fixing this.
Probably but as discussed, this seems to be an independent feature and I don't see how it can help for splitting headers. And does this conflict with the any_layout somehow?
Quoted 4 lines
I don't see architecturally what is wrong with making feature just depend on mergeable buffers for now.
Yes, but I don't see anything that prevent us from adding support for non-merge-able case. (Supporting mergeable buffer seems even more complex)
Thanks
Quoted 133 lines
We can always allow a combination
down the road. Let's just make it clear that if drivers see SPLIT && !MERGEABLE they should not fail probe, they should instead clear the split header feature.Quoted 125 lines
Quoted 7 lines
If we can't make a feature depend only on mergeable, should we use solution B?
2. Scheme B ( refer to your suggestion )
Our rethinking approach is no longer based on descriptor chain.
We refer to your proposed offset-based scheme as scheme B.
The offset seems to be the suggestion of Michael.
I think I like the design of v7 for several reasons:
1) easy to reserve head/tailroom without any extension of the spec
2) easy to work with mergeable rx buffer
3) it is the model used by modern NIC like e810 [1][1] e810 manual 2.4 Figure 10-4 have a nic diagram to demonstrate how it works which is similar to v7
Thanks
Quoted 105 lines
As you suggested, scheme B gives the device a buffer, using offset to indicate where to place the payload. Like this:
<header>...<padding>... <beginning of page><data>
But how to apply for this buffer?
Since we want the payload to be placed on a separate page, the method we consider is to directly alloc two pages from driver of contiguous memory.Then the beginning of this contiguous memory is used to store the headroom, and the contiguous memory after the headroom is directly handed over to the device. Similar to the following:
[------------------ receive buffer(2 pages) ------------------------------] [<------------first page -------------------><------ second page -------->]
[<-----><virtnet hdr> <mac,ip,tcp>..<padding>< payload >]
^ ^
| |
| pointer to device
|
|
Driver reserved, the later part is filledWe have already entered v8, but we have not been able to reach an agreement on the basic capabilities. I want to solve this problem first.
@Jason @Michael
Thanks.
Quoted 71 lines
Quoted 27 lines
Quoted 5 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4551
Quoted 1 line
content.tex +1
-0+ \item The total size of the virtio net header and the transport header exceeds \field{max_len}.I don't get the reason why we need
max_len. Can't it implied in the length of the first descriptor?Split transport header is usually used in high-throughput scenarios, such as GSO-enabled cases. Therefore, it is best to reserve tailroom with $ (the length of the buffer) - (\field{offset} + \filed{max_len}) $ in the first buffer to build the non-linear data area of the socket buffer.
Quoted 9 lines
Quoted 9 lines
content.tex +9
-0+\end{itemize} + +If the transport header is split by the device, the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER +bit in \field{flags} MUST be set. The transport header MUST be on the first +buffer, following the virtio net header. The payload MUST start from the +second buffer. The device MUST set \field{hdr_len} of structure +virtio_net_hdr to the length of the transport header. +The used length still reports the number of bytes it has written to memory. +Quoted 9 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4564
Quoted 4 lines
content.tex +4
-0+\field{offset} and \field{max_len} are valid when device uses the first buffer. +The device MUST reserve space in the first buffer using \filed{offset}. +If \field{offset} exceeds the length of the buffer, the device MUST drop +the receive packets.Can the device simply don't split the packet in this case? Anyhow we need synchronize the driver with the device in the case (e.g when driver is try to having a new
max_len).Quoted 4 lines
We think that \field{offset} is actively set by the driver, so the driver will also receive packets according to this offset.
But if the case is considered to be caused by driver error settings, the device can do not split the packet.Note that protocol like ipv6 allows variable length of the header, falling back to not split the header seems better to me.
Thanks
Quoted 18 lines
Quoted 3 lines
(I wonder if the offset deserves a independent feature (but depends on the merge able) in this case).
Okay, we can consider later.
Quoted 5 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4566
Quoted 2 lines
content.tex +1
-0The maximum available length of the first buffer +used by the device is specified by \field{max_len}.Similarly the max length seems to be implied by length - offset?
You can refer to the above answer about \field{max_len} similarly.
Thanks.
Quoted 3 lines
Thanks
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
content.tex +3
-0If \field{max_len} is 0 or +$ \field{offset} + \field{max_len} $ is greater than the length of the buffer, +the device can use the entire buffer starting at \field{offset}. +Quoted 8 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi · line 4578
Quoted 8 lines
content.tex +7
-0+\drivernormative{\subparagraph}{Setting Split Transport Header}{Device Types / Network Device / Device Operation / Control Virtqueue / Split Transport Header} + +If the VIRTIO_NET_HDR_F_SPLIT_TRANSPORT_HEADER bit in \field{flags} is set, the driver +SHOULD treat the contents of \field{hdr_len} as the length of the transport header +inside the first buffer. + +If \field{max_len} is not equal to 0, it MUST be greater than the size of the virtio net header. \paragraph{Notifications Coalescing}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Notifications Coalescing}---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Signature · 6 lines
MST --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).
Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Thanks
Quoted 5 lines
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 21 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Quoted 5 lines
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Thanks
The point of ANY_LAYOUT is to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:
If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also num_buffers is then always >= 2, maybe state this to avoid confusion.
B- without mergeable, there's no flexibility. In particular, there can
not be uninitialized space between header and data. If we had flexibility here, this could be helpful for alignment, security, etc.
Unfortunately, our hands are tied:
\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
so all buffers have to be initialized completely up to the reported used length.
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
Signature · 6 lines
MST --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 32 lines · Michael S. Tsirkin
Quoted 21 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Quoted 5 lines
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.
Quoted 8 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers.
If I understand correctly, this is our v8.
Quoted 4 lines
And in theory device can
choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes.
This is very interesting, I did not think of this point. This is helpful to reduce the waste of memory.
Quoted 12 lines
Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
Quoted 6 lines
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.
Yes, I think this is feasible.
Quoted 15 lines
B- without mergeable, there's no flexibility. In particular, there can
not be uninitialized space between header and data. If we had flexibility here, this could be helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.
Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
I don't think this is very troublesome, the device can memset the hole by 0.
Quoted 30 lines
so all buffers have to be initialized completely up to the reported used length.
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
So lots of spec work, some security risks, and unclear performance.Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
Quoted 3 lines
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 35 lines · Xuan Zhuo
Quoted 34 lines · Michael S. Tsirkin
Quoted 21 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Quoted 5 lines
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.Let's keep it that way.
Quoted 8 lines
Quoted 6 lines
Now, let's formulate what are some of the problems with the current way.
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers.If I understand correctly, this is our v8.
I think it is, or at least close.
Quoted 7 lines
Quoted 4 lines
And in theory device can
choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes.This is very interesting, I did not think of this point. This is helpful to reduce the waste of memory.
Hmm good point. I should add: since we are no longer fully using the first buffer the feature has a memory cost and - in case of a cache pressure - can degrade performance rather than improve it. Thus, allowing flexibility for both devices and drivers at runtime rather than fixing things through features thus sounds like a good idea.
Quoted 12 lines
Quoted 12 lines
Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
Quoted 8 lines
Quoted 6 lines
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Yes, I think this is feasible.
Thinking more about this, a question is what to do about packets without split header. I can see several options
A- add some buffers just for the non split case. without in-order they
can just stay available. with in-order they have to be recycled which might be expensive.
They will also occupy space in the ring. more memory costs. Don't much like it for above reasons.
OTOH then I wanted to work on partial-order anyway. Maybe it's time to prioritize that work.
B- write all of the packet in the payload buffer and just skip header buffer (e.g. make it 0 size?)
payload within packet will be misaligned then. Do we care? maybe not -
this was supposed to be an exception. In this case:
Problem B: where should virtio net header
go then? we can put it in the header buffer still, or we can
store it linear with the packet. or we can leave both options, up to device. what is better might depend on
different factors. any chance of performance testing?
Quoted 15 lines
Quoted 15 lines
B- without mergeable, there's no flexibility. In particular, there can
not be uninitialized space between header and data. If we had flexibility here, this could be helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.
Quoted 7 lines
Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
I don't think this is very troublesome, the device can memset the hole by 0.
Yes it can. But that has a performance cost. How large - depends on the hole size and a bunch of other factors.
Quoted 30 lines
Quoted 30 lines
so all buffers have to be initialized completely up to the reported used length.
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
So lots of spec work, some security risks, and unclear performance.Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
Quoted 3 lines
Quoted 3 lines
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 84 lines · Michael S. Tsirkin
Quoted 35 lines · Xuan Zhuo
Quoted 34 lines · Michael S. Tsirkin
Quoted 21 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Quoted 5 lines
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.Let's keep it that way.
Quoted 8 lines
Quoted 6 lines
Now, let's formulate what are some of the problems with the current way.
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers.If I understand correctly, this is our v8.
I think it is, or at least close.
Quoted 7 lines
Quoted 4 lines
And in theory device can
choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes.This is very interesting, I did not think of this point. This is helpful to reduce the waste of memory.
Hmm good point. I should add: since we are no longer fully using the first buffer the feature has a memory cost and - in case of a cache pressure - can degrade performance rather than improve it. Thus, allowing flexibility for both devices and drivers at runtime rather than fixing things through features thus sounds like a good idea.
Quoted 12 lines
Quoted 12 lines
Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
Quoted 8 lines
Quoted 6 lines
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Yes, I think this is feasible.
Quoted 9 lines
Thinking more about this, a question is what to do about packets without split header. I can see several options
A- add some buffers just for the non split case. without in-order they
can just stay available. with in-order they have to be recycled which might be expensive.
They will also occupy space in the ring. more memory costs. Don't much like it for above reasons.
OTOH then I wanted to work on partial-order anyway. Maybe it's time to prioritize that work.
Yes, I also prefer order processing, although we mess up the order, which is good in some cases.
Quoted 9 lines
B- write all of the packet in the payload buffer and just skip header buffer (e.g. make it 0 size?)
payload within packet will be misaligned then. Do we care? maybe not -
this was supposed to be an exception. In this case:
Problem B: where should virtio net header
go then? we can put it in the header buffer still, or we can
store it linear with the packet. or we can leave both options, up to device. what is better might depend on
different factors. any chance of performance testing?
avail ring:
| small buffer | page | small buffer | page | small buffer | page | small buffer | page |
In this case, I think it is a good idea to set the small buffer to 0 size for non-split headers.
This is an advantage over desc chain. The desc chain can only put the virtio-net header in the small buffer.
Quoted 22 lines
Quoted 22 lines
Quoted 20 lines
B- without mergeable, there's no flexibility. In particular, there can
not be uninitialized space between header and data. If we had flexibility here, this could be helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
Quoted 4 lines
Quoted 1 line
I don't think this is very troublesome, the device can memset the hole by 0.
Yes it can. But that has a performance cost. How large - depends on the hole size and a bunch of other factors.
The actual hole size is not large, general IP + TCP size.
Thanks
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
so all buffers have to be initialized completely up to the reported used length.
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
So lots of spec work, some security risks, and unclear performance.Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.
I'm not sure how this would work without the support from the device. This probably can only work if:
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the header
This is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the header
Quoted 7 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.
How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2
Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layout
Quoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.
Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.
Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
Thanks
Quoted 18 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
Quoted 3 lines
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 146 lines · Jason Wang
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the headerThis is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the headerQuoted 7 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layoutQuoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
Quoted 2 lines
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
I think the core of the problem here is that the uninitialized space within the range of specified in the len.
Thanks.
Quoted 25 lines
Thanks
Quoted 21 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 37 lines · Jason Wang
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
Quoted 7 lines
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the headerThis is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the header
We currently say:
If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
the idea is basically just to lift this requirement for specific packets. Things certainly worked before, this is just an optimization.
Quoted 101 lines
Quoted 8 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layoutQuoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
Quoted 26 lines
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
Thanks
Quoted 21 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 49 lines · Michael S. Tsirkin
Quoted 37 lines · Jason Wang
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
Quoted 7 lines
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the headerThis is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the headerWe currently say:
Quoted 8 lines
If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
the idea is basically just to lift this requirement for specific packets. Things certainly worked before, this is just an optimization.
The problem is, the offset is not fixed and can be determined by the driver. It's variable so it requires the device to parse the packet to know.
Thanks
Quoted 127 lines
Quoted 127 lines
Quoted 11 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layoutQuoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
Thanks
Quoted 18 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 59 lines · Jason Wang
Quoted 49 lines · Michael S. Tsirkin
Quoted 37 lines · Jason Wang
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
Quoted 7 lines
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the headerThis is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the headerWe currently say:
Quoted 8 lines
If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
the idea is basically just to lift this requirement for specific packets. Things certainly worked before, this is just an optimization.
Quoted 5 lines
The problem is, the offset is not fixed and can be determined by the driver. It's variable so it requires the device to parse the packet to know.
Thanks
IIUC device parsing packet and splitting the header is exactly what the feature is supposed to do. It's benefitial if device is a hardware one.
Quoted 127 lines
Quoted 127 lines
Quoted 127 lines
Quoted 11 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layoutQuoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
Thanks
Quoted 18 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 61 lines · Michael S. Tsirkin
Quoted 59 lines · Jason Wang
Quoted 57 lines · Michael S. Tsirkin
Quoted 37 lines · Jason Wang
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
Quoted 7 lines
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the headerThis is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the headerWe currently say:
If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
the idea is basically just to lift this requirement for specific packets. Things certainly worked before, this is just an optimization.
Quoted 8 lines
Quoted 5 lines
The problem is, the offset is not fixed and can be determined by the driver. It's variable so it requires the device to parse the packet to know.
Thanks
IIUC device parsing packet and splitting the header is exactly what the feature is supposed to do. It's benefitial if device is a hardware one.
Right, so in any way (even with a mergeable buffer), if the device parses and splits, we need to tweak the section you quote above from the spec, since there will be some space left in the buffer other than the last one?
Thanks
Quoted 129 lines
Quoted 129 lines
Quoted 129 lines
Quoted 129 lines
Quoted 13 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layoutQuoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
Thanks
Quoted 18 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 71 lines · Jason Wang
Quoted 61 lines · Michael S. Tsirkin
Quoted 59 lines · Jason Wang
Quoted 57 lines · Michael S. Tsirkin
Quoted 37 lines · Jason Wang
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
Quoted 7 lines
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the headerThis is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the headerWe currently say:
If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
the idea is basically just to lift this requirement for specific packets. Things certainly worked before, this is just an optimization.
Quoted 8 lines
Quoted 5 lines
The problem is, the offset is not fixed and can be determined by the driver. It's variable so it requires the device to parse the packet to know.
Thanks
IIUC device parsing packet and splitting the header is exactly what the feature is supposed to do. It's benefitial if device is a hardware one.
Quoted 6 lines
Right, so in any way (even with a mergeable buffer), if the device parses and splits, we need to tweak the section you quote above from the spec, since there will be some space left in the buffer other than the last one?
Thanks
Exactly. My point was, we know relaxing this does not conflict with other parts of the spec since we didn't use to require this.
Quoted 129 lines
Quoted 129 lines
Quoted 129 lines
Quoted 129 lines
Quoted 129 lines
Quoted 13 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layoutQuoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
Thanks
Quoted 18 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
FYI:
A new rx zerocopy idea, which is different from Eric's tcp mmap zerocopy, the buffer comes from user mode and put to device, no longer requires page alignment, but still depends on split header.
https://lore.kernel.org/io-uring/[email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 106 lines · Jason Wang
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the headerThis is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the headerQuoted 7 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet
is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layoutQuoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
Quoted 7 lines
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
We've talked a bit more about split header so far, but there still seem to be some issues, so let's recap.
一、 Method Discussion Review
In order to adapt to the Eric's tcp receive interface to achieve zero copy, header and payload are required to be stored separately, and the payload is stored in a paged alignment way. Therefore, we have discussed several options for split header as follows:
1: method A ( depend on the descriptor chain )
| receive buffer | | 0th descriptor | 1th descriptor | | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |
Method A uses a buffer plus a separate page when allocating the receive buffer. In this way, we can ensure that all payloads can be put independently in a page, which is very beneficial for the zerocopy implemented by the upper layer.
The advantage of method A is that the implementation is clearer, it can support normal header spit and the rollback conditions. It can also easily support xdp. The downside is that devices operating directly on the descriptor chain may cause the layering violation, and also affect the performance.
2. method B ( depend on mergeable buffer)
| receive buffer (page) | receive buffer (page) | | <-- offset(hold) --> | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |
^
|
pointer to device
Method B is based on your previous suggestion, it is implemented based on mergeable buffer, filling a separate page each time.
If the split header is negotiated and the packet can be successfully split by the device, the device needs to find at least two buffers, namely two pages, one for the virtio-net header and transport header, and the other for the payload.
The advantage of method B is that it relies on mergeable buffer instead of the descriptor chain. It overcomes the shortcomings of method A and can achieve the purpose of the device focusing on the buffer instead of the descriptor. Its disadvantage is that it causes memory waste.
3. method C ( depend on mergeable buffer )
| small buffer | data buffer (page) | small buffer | data buffer (page) | small buffer | data buffer (page) |
Method B fills a separate page each time, while method C needs to fill the small buffer and page buffer separately. Method C puts the header in small buffer and the payload in a page.
The advantage of method C is that some buffers are filled for header and data respectively, which reduces the memory waste of method B. However, this method is difficult to weigh the number of filled header buffers and data buffers, and an unreasonable proportion will affect performance. For example, in a scenario with a large number of large packets, too many header buffers will affect performance, or in a scenario with a large number of small packets, too many data buffers can also affect performance. At the same time, if some protocols with a large number of packets do not support split header, the existence of the header buffers will also affect performance.
二、Points of agreement and disagreement
1. What we have now agreed upon is that:
None of the three methods break VIRTIO_F_ANY_LAYOUT, they make virtio net header and packet header stored together.
We have now agreed to relax the following in the split header scenario,
"indicates to both the device and the driver that no assumptions were made about framing."
because when a bigger packet comes, and a data buffer is not enough to store this packet, the device either chooses to skip the next header buffer to break what the spec says above, or chooses not to skip the header buffer and cannot make payload page aligned. Therefore, all three methods need to relax the above requirements.
2. What we haven't now agreed upon is that:
The point where we don't agree now is that we don't have a more precise discussion of which approach to take, but we're still bouncing between approaches.
At present, all three approaches seem to achieve our requirements, but each has advantages and disadvantages. Should we focus on the most important points, such as performance to choose. It seems a little difficult to cover everything?
三、Two forms of implementing receive zerocopy
the Eric's tcp receive interface requires the header and payload are stored in separate buffers, and the payload is stored in a paged alignment way.
Now, io_uring also proposes a new receive zerocopy method, which requires header and payload to be stored in separate buffers, but does not require payload page aligned.
https://lore.kernel.org/io-uring/[email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196
Thanks.
Quoted 33 lines
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
Quoted 26 lines
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
Thanks
Quoted 21 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Hi, all.
Split header is a technique with important applications, such as Eric (https://lwn.net/Articles/754681/)
and Jonathan Lemon (https://lore.kernel.org/io-uring/20221007211713.170714-1- [email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196) realize the zero-copy technology respectively, they all have one thing in common that the header and
the payload need to be in separate buffers, and Eric's method requires the payload to be page-aligned.
We implemented zero-copy on the virtio-net driver according to Eric's method. The commands and
environment are as follows:
# environment VM1<---->vhost-user<->OVS<->vhost-user<---->VM2 cpu Model name: Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz kernel version 6.0 # commands (linux/tools/testing/selftests/net) ./tcp_mmap -s -z -4 -p 1000 & ./tcp_mmap -H 10.0.0.2 -z -4 -p 1000 The performance data is as follows (implemented according to the split header v7 version, https://lists.oasis-open.org/archives/virtio-dev/202209/msg00004.html): # direct copy 17.6604 s 10.08 s # zero copy 1.9 GB/s 3.3 GB/s We discussed a lot before, the core point is the choice of method A and method C, we seem to be unable to reach an agreement on this point, seeing the above summary and previous discussion (https://lists.oasis-open.org/archives/virtio-dev /202210/msg00017.html), how can we resolve this conflict and let this important feature continue? I really need your help. Cc Jason, Michael, Cornelia, Xuan. Thanks. ------------------------------------------------------------------ 发件人:Heng Qi <[email protected]> 发送时间:2022年10月20日(星期四) 16:34 收件人:Jason Wang <[email protected]> 抄 送:Michael S. Tsirkin <[email protected]>; Xuan Zhuo <[email protected]>; Virtio-Dev <[email protected]>; Kangjie Xu <[email protected]> 主 题:Re: [virtio-dev] [PATCH v8] virtio_net: support for split transport header On Sat, Oct 08, 2022 at 12:37:45PM +0800, Jason Wang wrote:
Quoted 106 lines · Michael S. Tsirkin
Quoted 27 lines · Jason Wang
Quoted 25 lines · Michael S. Tsirkin
Quoted 11 lines · Jason Wang
Quoted 8 lines
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the headerThis is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the headerQuoted 7 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layoutQuoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
Quoted 7 lines
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
We've talked a bit more about split header so far, but there still seem to be some issues, so let's recap.
一、 Method Discussion Review
In order to adapt to the Eric's tcp receive interface to achieve zero copy, header and payload are required to be stored separately, and the payload is stored in a paged alignment way. Therefore, we have discussed several options for split header as follows:
1: method A ( depend on the descriptor chain )
| receive buffer | | 0th descriptor | 1th descriptor | | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |
Method A uses a buffer plus a separate page when allocating the receive buffer. In this way, we can ensure that all payloads can be put independently in a page, which is very beneficial for the zerocopy implemented by the upper layer.
The advantage of method A is that the implementation is clearer, it can support normal header spit and the rollback conditions. It can also easily support xdp. The downside is that devices operating directly on the descriptor chain may cause the layering violation, and also affect the performance.
2. method B ( depend on mergeable buffer)
| receive buffer (page) | receive buffer (page) | | <-- offset(hold) --> | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |
^
|
pointer to device
Method B is based on your previous suggestion, it is implemented based
on mergeable buffer, filling a separate page each time.
If the split header is negotiated and the packet can be successfully split by the device,
the device needs to find at least two buffers, namely two pages, one for the virtio-net header and transport header, and the other for the payload.
The advantage of method B is that it relies on mergeable buffer instead of the descriptor chain. It overcomes the shortcomings of method A and can achieve the purpose of the device focusing
on the buffer instead of the descriptor. Its disadvantage is that it causes memory waste.
3. method C ( depend on mergeable buffer )
| small buffer | data buffer (page) | small buffer | data buffer (page) | small buffer | data buffer (page) | Method B fills a separate page each time, while method C needs to fill the small buffer and
page buffer separately. Method C puts the header in small buffer and the payload in a page.
The advantage of method C is that some buffers are filled for header and data respectively, which reduces the memory waste of method B. However, this method is difficult to weigh
the number of filled header buffers and data buffers, and an unreasonable proportion will
affect performance. For example, in a scenario with a large number of large packets,
too many header buffers will affect performance, or in a scenario with a large number of small packets, too many data buffers can also affect performance. At the same time, if some protocols with a large number of packets do not support split header, the existence of the header buffers will also affect performance.
二、Points of agreement and disagreement
1. What we have now agreed upon is that:
None of the three methods break VIRTIO_F_ANY_LAYOUT, they make virtio net header and
packet header stored together.
We have now agreed to relax the following in the split header scenario,
"indicates to both the device and the driver that no assumptions were made about framing."
because when a bigger packet comes, and a data buffer is not enough to store this packet,
the device either chooses to skip the next header buffer to break what the spec says above,
or chooses not to skip the header buffer and cannot make payload page aligned.
Therefore, all three methods need to relax the above requirements.
2. What we haven't now agreed upon is that:
The point where we don't agree now is that we don't have a more precise discussion of which approach to take, but we're still bouncing between approaches.
At present, all three approaches seem to achieve our requirements, but each has advantages
and disadvantages. Should we focus on the most important points, such as performance to choose. It seems a little difficult to cover everything?
三、Two forms of implementing receive zerocopy
the Eric's tcp receive interface requires the header and payload are stored in separate buffers, and the payload is stored in a paged alignment way.
Now, io_uring also proposes a new receive zerocopy method, which requires header and payload
to be stored in separate buffers, but does not require payload page aligned.
https://lore.kernel.org/io-uring/[email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196
Thanks.
Quoted 33 lines
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
Quoted 26 lines
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
Thanks
Quoted 21 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
--
MST
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 7 lines · hengqi
Hi, all.
Split header is a technique with important applications, such as Eric (https://lwn.net/Articles/754681/)
and Jonathan Lemon (https://lore.kernel.org/io-uring/20221007211713.170714-1- [email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196) realize the zero-copy technology respectively, they all have one thing in common that the header and
the payload need to be in separate buffers, and Eric's method requires the payload to be page-aligned.
We implemented zero-copy on the virtio-net driver according to Eric's method. The commands and
environment are as follows:
Quoted 13 lines
# environment VM1<---->vhost-user<->OVS<->vhost-user<---->VM2 cpu Model name: Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz kernel version 6.0 # commands (linux/tools/testing/selftests/net) ./tcp_mmap -s -z -4 -p 1000 & ./tcp_mmap -H 10.0.0.2 -z -4 -p 1000 The performance data is as follows (implemented according to the split header v7 version, https://lists.oasis-open.org/archives/virtio-dev/202209/msg00004.html): # direct copy 17.6604 s 10.08 s # zero copy 1.9 GB/s 3.3 GB/s
Sorry for the formatting error caused by the application. It should be:
#direct copy vs. zero copy
17.6604 s 10.08 s
1.9 GB/s 3.3 GB/s
Thanks.
Quoted 255 lines
We discussed a lot before, the core point is the choice of method A and method C, we seem
to be unable to reach an agreement on this point, seeing the above summary and previous discussion (https://lists.oasis-open.org/archives/virtio-dev /202210/msg00017.html), how can we resolve this conflict and let this important feature continue?
I really need your help. Cc Jason, Michael, Cornelia, Xuan.
Thanks.
------------------------------------------------------------------
发件人:Heng Qi <[email protected]>
发送时间:2022年10月20日(星期四) 16:34
收件人:Jason Wang <[email protected]>
抄 送:Michael S. Tsirkin <[email protected]>; Xuan Zhuo <[email protected]>; Virtio-Dev <[email protected]>; Kangjie Xu <[email protected]> 主 题:Re: [virtio-dev] [PATCH v8]virtio_net: support for split transport headerQuoted 106 lines · Jason Wang
Quoted 27 lines · Michael S. Tsirkin
Quoted 25 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 3 lines
Jason I think the issue with previous proposals is that they conflict with
VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the driver flexibility in arranging the packet in memory is benefitial.Yes, but I didn't found how it can conflict the
any_layout. Device can just to not split the header when the layout doesn't fit for header splitting. (And this seems the case even if we're using buffers).Quoted 8 lines
Well spec says:
indicates to both the device and the driver that no assumptions were made about framing.
if device assumes that descriptor boundaries are where driver wants packet to be stored that is clearly an assumption.
Yes but what I want to say is, the device can choose to not split the packet if the framing doesn't fit. Does it still comply with the above description?
Quoted 5 lines
Quoted 1 line
Thanks
The point of
ANY_LAYOUTis to give drivers maximum flexibility. For example, if driver wants to split the header at some specific offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the headerThis is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the headerQuoted 7 lines
Let's keep it that way.
Now, let's formulate what are some of the problems with the current way.
Quoted 7 lines
A- mergeable buffers is even more flexible, since a single packet is built up of multiple buffers. And in theory device can choose arbitrary set of buffers to store a packet.
So you could supply a small buffer for headers followed by a bigger one for payload, in theory even without any changes. Problem 1: However since this is not how devices currently operate, a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layoutQuoted 20 lines
Problem 2: Also, in the past we found it useful to be able to figure out whether packet fits in a single buffer without looking at the header.
For this reason, we have this text:If a receive packet is spread over multiple buffers, the device MUST use all buffers but the last (i.e. the first \field{num_buffers} - 1 buffers) completely up to the full length of each buffer supplied by the driver.
if we want to keep this optimization and allow using a separate buffer for headers, then I think we could rely on the feature bit from Problem 1 and just make an exception for the first buffer. Also
num_buffersis then always >= 2, maybe state this to avoid confusion.Quoted 2 lines
B- without mergeable, there's no flexibility. In particular, there can not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
Quoted 7 lines
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
We've talked a bit more about split header so far, but there still seem to be some issues, so let's recap.
一、 Method Discussion Review
In order to adapt to the Eric's tcp receive interface to achieve zero copy, header and payload are required to be stored separately, and the payload is stored in a paged alignment way. Therefore, we have discussed several options for split header as follows:
1: method A ( depend on the descriptor chain )| receive buffer | | 0th descriptor | 1th descriptor | | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |Method A uses a buffer plus a separate page when allocating the receive buffer. In this way, we can ensure that all payloads can be put independently in a page, which is very beneficial for the zerocopy implemented by the upper layer.
The advantage of method A is that the implementation is clearer, it can support normal header spit and the rollback conditions. It can also easily support xdp. The downside is that devices operating directly on the descriptor chain may cause the layering violation, and also affect the performance.
2. method B ( depend on mergeable buffer)| receive buffer (page) | receive buffer (page) | | <-- offset(hold) --> | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |^
|
pointer to device
Method B is based on your previous suggestion, it is implemented based
on mergeable buffer, filling a separate page each time.
If the split header is negotiated and the packet can be successfully split by the device,
the device needs to find at least two buffers, namely two pages, one for the virtio-net header and transport header, and the other for the payload.
The advantage of method B is that it relies on mergeable buffer instead of the descriptor chain. It overcomes the shortcomings of method A and can achieve the purpose of the device focusing
on the buffer instead of the descriptor. Its disadvantage is that it causes memory waste.
3. method C ( depend on mergeable buffer )
| small buffer | data buffer (page) | small buffer | data buffer (page) | small buffer | data buffer (page) | Method B fills a separate page each time, while method C needs to fill the small buffer and
page buffer separately. Method C puts the header in small buffer and the payload in a page.
The advantage of method C is that some buffers are filled for header and data respectively, which reduces the memory waste of method B. However, this method is difficult to weigh
the number of filled header buffers and data buffers, and an unreasonable proportion will
affect performance. For example, in a scenario with a large number of large packets,
too many header buffers will affect performance, or in a scenario with a large number of small packets, too many data buffers can also affect performance. At the same time, if some protocols with a large number of packets do not support split header, the existence of the header buffers will also affect performance.
二、Points of agreement and disagreement
1. What we have now agreed upon is that:
None of the three methods breakVIRTIO_F_ANY_LAYOUT, they make virtio net header and
packet header stored together.
We have now agreed to relax the following in the split header scenario,
"indicates to both the device and the driver that no assumptions were made about framing."
because when a bigger packet comes, and a data buffer is not enough to store this packet,
the device either chooses to skip the next header buffer to break what the spec says above,
or chooses not to skip the header buffer and cannot make payload page aligned.
Therefore, all three methods need to relax the above requirements.
2. What we haven't now agreed upon is that:
The point where we don't agree now is that we don't have a more precise discussion of which approach to take, but we're still bouncing between approaches.
At present, all three approaches seem to achieve our requirements, but each has advantages
and disadvantages. Should we focus on the most important points, such as performance to choose. It seems a little difficult to cover everything?
三、Two forms of implementing receive zerocopy
the Eric's tcp receive interface requires the header and payload are stored in separate buffers, and the payload is stored in a paged alignment way.
Now,io_uringalso proposes a new receive zerocopy method, which requires header and payload
to be stored in separate buffers, but does not require payload page aligned.
https://lore.kernel.org/io-uring/[email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196
Thanks.Quoted 33 lines
Quoted 10 lines
If we had flexibility here, this could be
helpful for alignment, security, etc.
Unfortunately, our hands are tied:\field{len} is particularly useful
for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs.Quoted 4 lines
For example, a network driver may hand a received buffer directly to an unprivileged userspace application. If the network device has not overwritten the bytes which were in that buffer, this could leak the contents of freed memory from other processes to the application.
This should be a bug of the driver. For example, if the driver wants to implement zerocopy, it must guarantee that every byte was written by the device before mapping it to the userspace, if it can't it should do the copy instead.
Quoted 5 lines
so all buffers have to be initialized completely up to the reported used length.
Quoted 7 lines
It could be that the guarantee is not relevant in some use-cases. We would have to specify that this is an exception to the rule, explain that drivers must be careful about information leaks. Let's say there's a feature bit that adds uninitialized space somewhere. How much was added? We can find out by parsing the packet but once you start doing that just to assemble the skb you have already lost performance.
Quoted 26 lines
I don't get here, for those uninitialized spaces, it looks just tailroom for the skb.
Thanks
Quoted 21 lines
So lots of spec work, some security risks, and unclear performance.
Is above a fair summary?
If yes I would say let's address A, but make sure we ask drivers to clear the new feature bit if there's no mergeable (as opposed to e.g. failing probe) so we can add support for !mergeable down the road.
--
MST---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Hi Heng Qi,
Sorry for the joining this conversation little late. Your email has very useful summary.
Unfortunately, non-text content (HTML content) doesn’t get achieved.
So, changing the format to text to capture your useful comments.
If you can change your email client settings to be text mode, it will be easier to converse.
We have equal interest in having efficient split hdr support and do together with you. Please find response "response" tag below at the end of email to avoid top posting.
From: [email protected] <[email protected]> On Behalf Of hengqi
Sent: Tuesday, January 31, 2023 4:23 AM
To: virtio-dev <[email protected]>; virtio-comment <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Cornelia Huck <[email protected]>; Kangjie Xu <[email protected]>; Xuan Zhuo <[email protected]>
Subject: [virtio-comment] 回复:[virtio-dev] [PATCH v8] virtio_net: support for split transport header
Hi, all.
Split header is a technique with important applications, such as Eric (https://lwn.net/Articles/754681/)
and Jonathan Lemon (https://lore.kernel.org/io-uring/20221007211713.170714-1- mailto:[email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196) realize the zero-copy technology respectively, they all have one thing in common that the header and
the payload need to be in separate buffers, and Eric's method requires the payload to be page-aligned.
We implemented zero-copy on the virtio-net driver according to Eric's method. The commands and environment are as follows:
# environment
VM1<---->vhost-user<->OVS<->vhost-user<---->VM2
cpu Model name: Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
kernel version 6.0
# commands (linux/tools/testing/selftests/net) ./tcp_mmap -s -z -4 -p 1000 & ./tcp_mmap -H 10.0.0.2 -z -4 -p 1000
The performance data is as follows (implemented according to the split header v7 version,
https://lists.oasis-open.org/archives/virtio-dev/202209/msg00004.html):
# direct copy
17.6604 s 10.08 s
# zero copy 1.9 GB/s 3.3 GB/s
We discussed a lot before, the core point is the choice of method A and method C, we seem
to be unable to reach an agreement on this point, seeing the above summary and previous discussion (https://lists.oasis-open.org/archives/virtio-dev /202210/msg00017.html), how can we resolve this conflict and let this important feature continue?
I really need your help. Cc Jason, Michael, Cornelia, Xuan.
Thanks.
------------------------------------------------------------------
发件人:Heng Qi <mailto:[email protected]>
发送时间:2022年10月20日(星期四) 16:34
收件人:Jason Wang <mailto:[email protected]>
抄 送:Michael S. Tsirkin <mailto:[email protected]>; Xuan Zhuo <mailto:[email protected]>; Virtio-Dev <mailto:[email protected]>; Kangjie Xu <mailto:[email protected]> 主 题:Re: [virtio-dev] [PATCH v8] virtio_net: support for split transport header
Quoted 105 lines · Jason Wang
On Thu, Sep 29, 2022 at 3:04 PM Michael S. Tsirkin <mailto:[email protected]> wrote:
>
> On Thu, Sep 29, 2022 at 09:48:33AM +0800, Jason Wang wrote:
> > On Wed, Sep 28, 2022 at 9:39 PM Michael S. Tsirkin <mailto:[email protected]> wrote:
> > >
> > > On Mon, Sep 26, 2022 at 04:06:17PM +0800, Jason Wang wrote:
> > > > > Jason I think the issue with previous proposals is that they conflict > > > > > with VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the > > > > > driver flexibility in arranging the packet in memory is benefitial. > > > >
> > > >
> > > > Yes, but I didn't found how it can conflict the any_layout. Device can just > > > > to not split the header when the layout doesn't fit for header splitting. > > > > (And this seems the case even if we're using buffers).
> > >
> > > Well spec says:
> > >
> > > indicates to both the device and the driver that no
> > > assumptions were made about framing.
> > >
> > > if device assumes that descriptor boundaries are where
> > > driver wants packet to be stored that is clearly
> > > an assumption.
> >
> > Yes but what I want to say is, the device can choose to not split the > > packet if the framing doesn't fit. Does it still comply with the above > > description?
> >
> > Thanks
>
> The point of ANY_LAYOUT is to give drivers maximum flexibility.
> For example, if driver wants to split the header at some specific
> offset this is already possible without extra functionality.
I'm not sure how this would work without the support from the device. This probably can only work if:
1) the driver know what kind of packet it can receive
2) protocol have fixed length of the header
This is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the header
>
> Let's keep it that way.
>
> Now, let's formulate what are some of the problems with the current way. >
>
>
> A- mergeable buffers is even more flexible, since a single packet
> is built up of multiple buffers. And in theory device can
> choose arbitrary set of buffers to store a packet.
> So you could supply a small buffer for headers followed by a bigger > one for payload, in theory even without any changes.
> Problem 1: However since this is not how devices currently operate, > a feature bit would be helpful.
How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2
Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layout
>
> Problem 2: Also, in the past we found it useful to be able to figure out whether > packet fits in a single buffer without looking at the header.
> For this reason, we have this text:
>
> If a receive packet is spread over multiple buffers, the device > MUST use all buffers but the last (i.e. the first \field{num_buffers} - > 1 buffers) completely up to the full length of each buffer
> supplied by the driver.
>
> if we want to keep this optimization and allow using a separate
> buffer for headers, then I think we could rely on the feature bit
> from Problem 1 and just make an exception for the first buffer.
> Also num_buffers is then always >= 2, maybe state this to avoid
> confusion.
>
>
>
>
>
> B- without mergeable, there's no flexibility. In particular, there can > not be uninitialized space between header and data.
I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
Quoted 8 lines
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
We've talked a bit more about split header so far, but there still seem to be some issues, so let's recap.
一、 Method Discussion Review
In order to adapt to the Eric's tcp receive interface to achieve zero copy, header and payload are required to be stored separately, and the payload is stored in a paged alignment way. Therefore, we have discussed several options for split header as follows:
1: method A ( depend on the descriptor chain )
| receive buffer | | 0th descriptor | 1th descriptor | | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |
Method A uses a buffer plus a separate page when allocating the receive buffer. In this way, we can ensure that all payloads can be put independently in a page, which is very beneficial for the zerocopy implemented by the upper layer.
The advantage of method A is that the implementation is clearer, it can support normal header spit and the rollback conditions. It can also easily support xdp. The downside is that devices operating directly on the descriptor chain may cause the layering violation, and also affect the performance.
2. method B ( depend on mergeable buffer)
| receive buffer (page) | receive buffer (page) | | <-- offset(hold) --> | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |
^
|
pointer to device
Method B is based on your previous suggestion, it is implemented based on mergeable buffer, filling a separate page each time.
If the split header is negotiated and the packet can be successfully split by the device, the device needs to find at least two buffers, namely two pages, one for the virtio-net header and transport header, and the other for the payload.
The advantage of method B is that it relies on mergeable buffer instead of the descriptor chain. It overcomes the shortcomings of method A and can achieve the purpose of the device focusing on the buffer instead of the descriptor. Its disadvantage is that it causes memory waste.
3. method C ( depend on mergeable buffer )
| small buffer | data buffer (page) | small buffer | data buffer (page) | small buffer | data buffer (page) |
Method B fills a separate page each time, while method C needs to fill the small buffer and page buffer separately. Method C puts the header in small buffer and the payload in a page.
The advantage of method C is that some buffers are filled for header and data respectively, which reduces the memory waste of method B. However, this method is difficult to weigh the number of filled header buffers and data buffers, and an unreasonable proportion will affect performance. For example, in a scenario with a large number of large packets, too many header buffers will affect performance, or in a scenario with a large number of small packets, too many data buffers can also affect performance. At the same time, if some protocols with a large number of packets do not support split header, the existence of the header buffers will also affect performance.
二、Points of agreement and disagreement
1. What we have now agreed upon is that:
None of the three methods break VIRTIO_F_ANY_LAYOUT, they make virtio net header and packet header stored together.
We have now agreed to relax the following in the split header scenario, "indicates to both the device and the driver that no assumptions were made about framing." because when a bigger packet comes, and a data buffer is not enough to store this packet, the device either chooses to skip the next header buffer to break what the spec says above, or chooses not to skip the header buffer and cannot make payload page aligned. Therefore, all three methods need to relax the above requirements.
2. What we haven't now agreed upon is that:
The point where we don't agree now is that we don't have a more precise discussion of which approach to take, but we're still bouncing between approaches.
At present, all three approaches seem to achieve our requirements, but each has advantages and disadvantages. Should we focus on the most important points, such as performance to choose. It seems a little difficult to cover everything?
三、Two forms of implementing receive zerocopy
the Eric's tcp receive interface requires the header and payload are stored in separate buffers, and the payload is stored in a paged alignment way.
Now, io_uring also proposes a new receive zerocopy method, which requires header and payload to be stored in separate buffers, but does not require payload page aligned.
https://lore.kernel.org/io-uring/[email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196
Response....
Page alignment requirements should not come from the virtio spec. There are a variety of cases which may use non page aligned data buffers. a. A kernel only consumer can use it who doesn't have mmap requirement. b. A VQ accessible directly in user space may also use it without page alignment. c. A system with 64k page size, page aligned memory has a fair amount of wastage. d. iouring example you pointed, also has non page aligned use.
So let the driver deal with alignment restriction, outside of the virtio spec.
In header data split cases, data buffers utilization is more important than the tiny header buffers utilization. How about if the headers do not interfere with the data buffers?
In other words, say a given RQ has optionally linked to a circular queue of header buffers. All header buffers are of the same size, supplied one time.
This header size and circular q address is configured one time at RQ creation time.
With this the device doesn't need to process header buffer size every single incoming packet. Data buffers can continue as chains or merged mode can be supported.
When the received packet’s header cannot fit, it continues as-is in the data buffer. Virtio net hdr as suggest indicates usage of hdr buffer offset/index.
This method has few benefits on perf and buffer efficiency as below.
1. Data buffers can be directly mapped at best utilization
2. Device doesn't need to match up per packet header sizes and descriptor sizes, efficient for device to implement
3. No need to keep reposting the header buffers, only its tail index to be updated.
Directly gives 50% cycle reduction on buffer traversing on driver side on rx path.
4. Ability to share this header buffer queue among multiple RQs if needed.
5. In the future there may be an extension to place tiny whole packets that can fit in the header buffer also to contain the rest of the data.
6. Device can always fall back to place packet header in data buffer when header buffer is not available or smaller than newer protocol
7. Because the header buffer comes virtually contiguous memory and not intermixed with data buffers, there isn't small per header allocations
8. Also works in both chained and merged mode
9. memory utilization for an RQ of depth 256, with 4K page size for data buffers = 1M, and hdr buffer per packet = 256 * 128bytes = only 3% of the data buffer. So, in worst case when no packet uses the header buffers wastage is only 3%.
When high number of packets larger than 4K uses the header buffer, say 8K packets, header buffer utilization is at 50%. So, wastage is only 1.5%. At 1500 mtu merged buffer data buffer size, it is also < 10% of hdr buffer memory.
All 3 cases are very manageable range of buffer utilization.
Crafting and modifying the feature bits from your v7 version and virtio net header is not difficult to get there if we like this approach.
Quoted 8 lines · Parav Pandit
Hi Heng Qi,
Sorry for the joining this conversation little late. Your email has very useful summary.
Unfortunately, non-text content (HTML content) doesn’t get achieved.
So, changing the format to text to capture your useful comments.
If you can change your email client settings to be text mode, it will be easier to converse.
I'm very sorry, but is it convenient for you to check the format of the current quote reply?
I will reply after your response tag, please see below.
Quoted 263 lines
We have equal interest in having efficient split hdr support and do together with you. Please find response "response" tag below at the end of email to avoid top posting.
From: [email protected] <[email protected]> On Behalf Of hengqi
Sent: Tuesday, January 31, 2023 4:23 AM
To: virtio-dev <[email protected]>; virtio-comment <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Cornelia Huck <[email protected]>; Kangjie Xu <[email protected]>; Xuan Zhuo <[email protected]>
Subject: [virtio-comment] 回复:[virtio-dev] [PATCH v8]virtio_net: support for split transport headerHi, all.
Split header is a technique with important applications, such as Eric (https://lwn.net/Articles/754681/)
and Jonathan Lemon (https://lore.kernel.org/io-uring/20221007211713.170714-1- mailto:[email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196) realize the zero-copy technology respectively, they all have one thing in common that the header and
the payload need to be in separate buffers, and Eric's method requires the payload to be page-aligned.We implemented zero-copy on the virtio-net driver according to Eric's method. The commands and environment are as follows:
# environment
VM1<---->vhost-user<->OVS<->vhost-user<---->VM2
cpu Model name: Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
kernel version 6.0# commands (linux/tools/testing/selftests/net) ./tcp_mmap -s -z -4 -p 1000 & ./tcp_mmap -H 10.0.0.2 -z -4 -p 1000The performance data is as follows (implemented according to the split header v7 version,
https://lists.oasis-open.org/archives/virtio-dev/202209/msg00004.html):
# direct copy
17.6604 s 10.08 s# zero copy 1.9 GB/s 3.3 GB/sWe discussed a lot before, the core point is the choice of method A and method C, we seem
to be unable to reach an agreement on this point, seeing the above summary and previous discussion (https://lists.oasis-open.org/archives/virtio-dev /202210/msg00017.html), how can we resolve this conflict and let this important feature continue?
I really need your help. Cc Jason, Michael, Cornelia, Xuan.Thanks.
------------------------------------------------------------------
发件人:Heng Qi <mailto:[email protected]>
发送时间:2022年10月20日(星期四) 16:34
收件人:Jason Wang <mailto:[email protected]>
抄 送:Michael S. Tsirkin <mailto:[email protected]>; Xuan Zhuo <mailto:[email protected]>; Virtio-Dev <mailto:[email protected]>; Kangjie Xu <mailto:[email protected]> 主 题:Re: [virtio-dev] [PATCH v8]virtio_net: support for split transport headerQuoted 106 lines · Jason Wang
On Thu, Sep 29, 2022 at 3:04 PM Michael S. Tsirkin <mailto:[email protected]> wrote:
>
> On Thu, Sep 29, 2022 at 09:48:33AM +0800, Jason Wang wrote:
> > On Wed, Sep 28, 2022 at 9:39 PM Michael S. Tsirkin <mailto:[email protected]> wrote:
> > >
> > > On Mon, Sep 26, 2022 at 04:06:17PM +0800, Jason Wang wrote:
> > > > > Jason I think the issue with previous proposals is that they conflict > > > > > with VIRTIO_F_ANY_LAYOUT. We have repeatedly found that giving the > > > > > driver flexibility in arranging the packet in memory is benefitial. > > > >
> > > >
> > > > Yes, but I didn't found how it can conflict the any_layout. Device can just > > > > to not split the header when the layout doesn't fit for header splitting. > > > > (And this seems the case even if we're using buffers).
> > >
> > > Well spec says:
> > >
> > > indicates to both the device and the driver that no
> > > assumptions were made about framing.
> > >
> > > if device assumes that descriptor boundaries are where
> > > driver wants packet to be stored that is clearly
> > > an assumption.
> >
> > Yes but what I want to say is, the device can choose to not split the > > packet if the framing doesn't fit. Does it still comply with the above > > description?
> >
> > Thanks
>
> The point of ANY_LAYOUT is to give drivers maximum flexibility.
> For example, if driver wants to split the header at some specific
> offset this is already possible without extra functionality.I'm not sure how this would work without the support from the device. This probably can only work if:
1) the driver know what kind of packet it can receive 2) protocol have fixed length of the header
This is probably not true consider:
1) TCP and UDP have different header length
2) IPv6 has an variable length of the header>
> Let's keep it that way.
>
> Now, let's formulate what are some of the problems with the current way. >
>
>
> A- mergeable buffers is even more flexible, since a single packet > is built up of multiple buffers. And in theory device can > choose arbitrary set of buffers to store a packet.
> So you could supply a small buffer for headers followed by a bigger > one for payload, in theory even without any changes.
> Problem 1: However since this is not how devices currently operate, > a feature bit would be helpful.How do we know the bigger buffer is sufficient for the packet? If we try to allocate 64K (not sufficient for the future even) it breaks the effort of the mergeable buffer:
header buffer #1
payload buffer #1
header buffer #2
payload buffer #2Is the device expected to
1) fill payload in header buffer #2, this breaks the effort that we want to make payload page aligned
2) skip header buffer #2, in this case, the device assumes the framing when it breaks any layout>
> Problem 2: Also, in the past we found it useful to be able to figure out whether > packet fits in a single buffer without looking at the header.
> For this reason, we have this text:
>
> If a receive packet is spread over multiple buffers, the device > MUST use all buffers but the last (i.e. the first \field{num_buffers} - > 1 buffers) completely up to the full length of each buffer
> supplied by the driver.
>
> if we want to keep this optimization and allow using a separate
> buffer for headers, then I think we could rely on the feature bit > from Problem 1 and just make an exception for the first buffer.
> Also num_buffers is then always >= 2, maybe state this to avoid
> confusion.
>
>
>
>
>
> B- without mergeable, there's no flexibility. In particular, there can > not be uninitialized space between header and data.I had two questions
1) why is this not a problem of mergeable? There's no guarantee that the header is just the length of what the driver allocates for header buffer anyhow
Quoted 7 lines
E.g the header length could be smaller than the header buffer, the device still needs to skip part of the space in the header buffer.
2) it should be the responsibility of the driver to handle the uninitialized space, it should do anything that is necessary for security, more below
We've talked a bit more about split header so far, but there still seem to be some issues, so let's recap.
一、 Method Discussion Review
In order to adapt to the Eric's tcp receive interface to achieve zero copy, header and payload are required to be stored separately, and the payload is stored in a paged alignment way. Therefore, we have discussed several options for split header as follows:
1: method A ( depend on the descriptor chain )
| receive buffer | | 0th descriptor | 1th descriptor | | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |Method A uses a buffer plus a separate page when allocating the receive buffer. In this way, we can ensure that all payloads can be put independently in a page, which is very beneficial for the zerocopy implemented by the upper layer.
The advantage of method A is that the implementation is clearer, it can support normal header spit and the rollback conditions. It can also easily support xdp. The downside is that devices operating directly on the descriptor chain may cause the layering violation, and also affect the performance.
2. method B ( depend on mergeable buffer)
| receive buffer (page) | receive buffer (page) | | <-- offset(hold) --> | virtnet hdr | mac | ip hdr | tcp hdr|<-- hold -->| payload |^
|
pointer to deviceMethod B is based on your previous suggestion, it is implemented based on mergeable buffer, filling a separate page each time.
If the split header is negotiated and the packet can be successfully split by the device, the device needs to find at least two buffers, namely two pages, one for the virtio-net header and transport header, and the other for the payload.
The advantage of method B is that it relies on mergeable buffer instead of the descriptor chain. It overcomes the shortcomings of method A and can achieve the purpose of the device focusing on the buffer instead of the descriptor. Its disadvantage is that it causes memory waste.
3. method C ( depend on mergeable buffer )
| small buffer | data buffer (page) | small buffer | data buffer (page) | small buffer | data buffer (page) |Method B fills a separate page each time, while method C needs to fill the small buffer and page buffer separately. Method C puts the header in small buffer and the payload in a page.
The advantage of method C is that some buffers are filled for header and data respectively, which reduces the memory waste of method B. However, this method is difficult to weigh the number of filled header buffers and data buffers, and an unreasonable proportion will affect performance. For example, in a scenario with a large number of large packets, too many header buffers will affect performance, or in a scenario with a large number of small packets, too many data buffers can also affect performance. At the same time, if some protocols with a large number of packets do not support split header, the existence of the header buffers will also affect performance.
二、Points of agreement and disagreement
1. What we have now agreed upon is that:
None of the three methods break VIRTIO_F_ANY_LAYOUT, they make virtio net header and packet header stored together.We have now agreed to relax the following in the split header scenario,
"indicates to both the device and the driver that no assumptions were made about framing."
because when a bigger packet comes, and a data buffer is not enough to store this packet, the device either chooses to skip the next header buffer to break what the spec says above, or chooses not to skip the header buffer and cannot make payload page aligned. Therefore, all three methods need to relax the above requirements.2. What we haven't now agreed upon is that:
The point where we don't agree now is that we don't have a more precise discussion of which approach to take, but we're still bouncing between approaches.
At present, all three approaches seem to achieve our requirements, but each has advantages and disadvantages. Should we focus on the most important points, such as performance to choose. It seems a little difficult to cover everything?三、Two forms of implementing receive zerocopy
the Eric's tcp receive interface requires the header and payload are stored in separate buffers, and the payload is stored in a paged alignment way.
Now, io_uring also proposes a new receive zerocopy method, which requires header and payload to be stored in separate buffers, but does not require payload page aligned.
https://lore.kernel.org/io-uring/[email protected]/T/#m678770d1fa7040fd76ed35026b93dfcbf25f6196Response....
Page alignment requirements should not come from the virtio spec. There are a variety of cases which may use non page aligned data buffers. a. A kernel only consumer can use it who doesn't have mmap requirement. b. A VQ accessible directly in user space may also use it without page alignment. c. A system with 64k page size, page aligned memory has a fair amount of wastage. d. iouring example you pointed, also has non page aligned use.
So let the driver deal with alignment restriction, outside of the virtio spec.
In header data split cases, data buffers utilization is more important than the tiny header buffers utilization. How about if the headers do not interfere with the data buffers?
Quoted 8 lines
In other words, say a given RQ has optionally linked to a circular queue of header buffers. All header buffers are of the same size, supplied one time.
This header size and circular q address is configured one time at RQ creation time.With this the device doesn't need to process header buffer size every single incoming packet. Data buffers can continue as chains or merged mode can be supported.
When the received packet’s header cannot fit, it continues as-is in the data buffer. Virtio net hdr as suggest indicates usage of hdr buffer offset/index.
This is a good direction, thanks a lot for your comments, the new split header method might look like this:
When allocating the receive queue, allocate a circular queue storing the header buffers at the driver layer, which is shared with the device, and set the length of the header buffer. The length of the circular queue is the same as the length of the descriptor table.
1. When a data packet is successfully split, all virtio-net-hdr + transport headers are stored in the header buffer, and VIRTIO_NET_HDR_F_SPLIT_HEADER is set in the flag of virtio-net-hdr; If the header buffer is not enough to store virtio-net-hdr + transport header, then roll back, that is, not split the packet;
2. When a packet is not split by the device for some reason, virtio-net-hdr is placed in the header buffer, and the transport header and payload are placed in the buffer. At this time, xdp is not supported, because xdp requires the transport header to be placed in the first buffer, the header buffer. Then why not start storing packets from the header buffer? If this is the case, imagine a situation: If all small packets are put into the header buffers, and virtio net driver receives packets according to the descriptor table and used_ring, but the data buffers are empty at this time, then can't seem to continue? It seems that the operation of circular queue has become a producer-consumer problem again.
3. The meaning of hdr_len in virtio-net-hdr:
i. When splitting successfully: hdr_len represents the effective length of the header in the header buffer. ii. On unsuccessful split: hdr_len is 0.
What do you think of this plan? Or is there a better one?
Thanks.
Quoted 18 lines
This method has few benefits on perf and buffer efficiency as below.
1. Data buffers can be directly mapped at best utilization
2. Device doesn't need to match up per packet header sizes and descriptor sizes, efficient for device to implement
3. No need to keep reposting the header buffers, only its tail index to be updated.
Directly gives 50% cycle reduction on buffer traversing on driver side on rx path.
4. Ability to share this header buffer queue among multiple RQs if needed.
5. In the future there may be an extension to place tiny whole packets that can fit in the header buffer also to contain the rest of the data.
6. Device can always fall back to place packet header in data buffer when header buffer is not available or smaller than newer protocol
7. Because the header buffer comes virtually contiguous memory and not intermixed with data buffers, there isn't small per header allocations
8. Also works in both chained and merged mode
9. memory utilization for an RQ of depth 256, with 4K page size for data buffers = 1M, and hdr buffer per packet = 256 * 128bytes = only 3% of the data buffer. So, in worst case when no packet uses the header buffers wastage is only 3%.
When high number of packets larger than 4K uses the header buffer, say 8K packets, header buffer utilization is at 50%. So, wastage is only 1.5%. At 1500 mtu merged buffer data buffer size, it is also < 10% of hdr buffer memory.
All 3 cases are very manageable range of buffer utilization.Crafting and modifying the feature bits from your v7 version and virtio net header is not difficult to get there if we like this approach.
Quoted 3 lines
From: Heng Qi <[email protected]>
Sent: Wednesday, February 1, 2023 8:18 AM
[..]
Quoted 37 lines
Quoted 6 lines
Response....
Page alignment requirements should not come from the virtio spec. There are a variety of cases which may use non page aligned data buffers. a. A kernel only consumer can use it who doesn't have mmap requirement. b. A VQ accessible directly in user space may also use it without page
alignment.
Quoted 1 line
c. A system with 64k page size, page aligned memory has a fair amount of
wastage.
Quoted 5 lines
d. iouring example you pointed, also has non page aligned use.
So let the driver deal with alignment restriction, outside of the virtio spec.
In header data split cases, data buffers utilization is more important than the
tiny header buffers utilization.
Quoted 3 lines
How about if the headers do not interfere with the data buffers?
In other words, say a given RQ has optionally linked to a circular queue of
header buffers.
Quoted 2 lines
All header buffers are of the same size, supplied one time.
This header size and circular q address is configured one time at RQ creationtime.
Quoted 2 lines
With this the device doesn't need to process header buffer size every single
incoming packet.
Quoted 2 lines
Data buffers can continue as chains or merged mode can be supported. When the received packet’s header cannot fit, it continues as-is in the data
buffer.
Quoted 1 line
Virtio net hdr as suggest indicates usage of hdr buffer offset/index.
This is a good direction, thanks a lot for your comments, the new split header method might look like this:
When allocating the receive queue, allocate a circular queue storing the header buffers at the driver layer, which is shared with the device, and set the length of the header buffer. The length of the circular queue is the same as the length of the descriptor table.
Quoted 5 lines
1. When a data packet is successfully split, all virtio-net-hdr + transport headers are stored in the header buffer, and
VIRTIO_NET_HDR_F_SPLIT_HEADERis set in the flag of virtio-net-hdr; If the header buffer is not enough to store virtio- net-hdr + transport header, then roll back, that is, not split the packet;
Right.
Quoted 4 lines
2. When a packet is not split by the device for some reason, virtio-net-hdr is placed in the header buffer, and the transport header and payload are placed in the buffer. At this time, xdp is not supported, because xdp requires the transport header to be placed in the first buffer, the header buffer.
I do not understand why the xdp is not supported in this case.
Isn't it the case today, where xdp_prepare_buff() gets the buffer with offset after the net hdr? In the above case you mentioned xdp gets to used the packet buffer where pkt hdr + data is located.
Quoted 5 lines
Then why
not start storing packets from the header buffer? If this is the case, imagine a
situation: If all small packets are put into the header buffers, and virtio net driver receives packets according to the descriptor table andused_ring, but the data buffers are empty at this time, then can't seem to continue?
In future when such mode is extended, vq mechanism will be extended to handle desc table and used ring anyway.
Quoted 4 lines
It seems that
the operation of circular queue has become a producer-consumer problem again.
I didn’t follow.
I tend to imagine that driver consumed meta data (vnet_hdr and used ring) should be placed together in one buffer and Actual packet header and data belongs to other buffer.
This way there is clear layering of ownership. But before we explore this option, lets understand your above point.
Quoted 36 lines
3. The meaning of
hdr_lenin virtio-net-hdr:
i. When splitting successfully:hdr_lenrepresents the effective length of the
header in the header buffer.
ii. On unsuccessful split:hdr_lenis 0.What do you think of this plan? Or is there a better one?
Thanks.
Quoted 5 lines
This method has few benefits on perf and buffer efficiency as below.
1. Data buffers can be directly mapped at best utilization 2. Device doesn't need to match up per packet header sizes and descriptor sizes, efficient for device to implement 3. No need to keep reposting the headerbuffers, only its tail index to be updated.
Quoted 1 line
Directly gives 50% cycle reduction on buffer traversing on driver side on rx
path.
Quoted 2 lines
4. Ability to share this header buffer queue among multiple RQs if needed.
5. In the future there may be an extension to place tiny whole packets thatcan fit in the header buffer also to contain the rest of the data.
Quoted 4 lines
6. Device can always fall back to place packet header in data buffer when header buffer is not available or smaller than newer protocol 7. Because the header buffer comes virtually contiguous memory and not intermixed with data buffers, there isn't small per header allocations 8. Also
works in both chained and merged mode 9. memory utilization for an RQ of depth 256, with 4K page size for data buffers = 1M, and hdr buffer per packet = 256 * 128bytes = only 3% of the data buffer.
Quoted 2 lines
So, in worst case when no packet uses the header buffers wastage is only 3%. When high number of packets larger than 4K uses the header buffer, say 8K
packets, header buffer utilization is at 50%. So, wastage is only 1.5%.
Quoted 1 line
At 1500 mtu merged buffer data buffer size, it is also < 10% of hdr buffer
memory.
Quoted 3 lines
All 3 cases are very manageable range of buffer utilization.
Crafting and modifying the feature bits from your v7 version and virtio net
header is not difficult to get there if we like this approach.
Quoted 46 lines · Parav Pandit
Quoted 2 lines
From: Heng Qi <[email protected]>
Sent: Wednesday, February 1, 2023 8:18 AM[..]
Quoted 35 lines
Quoted 6 lines
Response....
Page alignment requirements should not come from the virtio spec. There are a variety of cases which may use non page aligned data buffers. a. A kernel only consumer can use it who doesn't have mmap requirement. b. A VQ accessible directly in user space may also use it without page
alignment.
Quoted 1 line
c. A system with 64k page size, page aligned memory has a fair amount of
wastage.
Quoted 5 lines
d. iouring example you pointed, also has non page aligned use.
So let the driver deal with alignment restriction, outside of the virtio spec.
In header data split cases, data buffers utilization is more important than the
tiny header buffers utilization.
Quoted 3 lines
How about if the headers do not interfere with the data buffers?
In other words, say a given RQ has optionally linked to a circular queue of
header buffers.
Quoted 2 lines
All header buffers are of the same size, supplied one time.
This header size and circular q address is configured one time at RQ creationtime.
Quoted 1 line
With this the device doesn't need to process header buffer size every single
incoming packet.
Quoted 2 lines
Data buffers can continue as chains or merged mode can be supported. When the received packet’s header cannot fit, it continues as-is in the data
buffer.
Quoted 1 line
Virtio net hdr as suggest indicates usage of hdr buffer offset/index.
This is a good direction, thanks a lot for your comments, the new split header method might look like this:
When allocating the receive queue, allocate a circular queue storing the header buffers at the driver layer, which is shared with the device, and set the length of the header buffer. The length of the circular queue is the same as the length of the descriptor table.Quoted 5 lines
1. When a data packet is successfully split, all virtio-net-hdr + transport headers are stored in the header buffer, and
VIRTIO_NET_HDR_F_SPLIT_HEADERis set in the flag of virtio-net-hdr; If the header buffer is not enough to store virtio- net-hdr + transport header, then roll back, that is, not split the packet;Right.
Quoted 7 lines
Quoted 4 lines
2. When a packet is not split by the device for some reason, virtio-net-hdr is placed in the header buffer, and the transport header and payload are placed in the buffer. At this time, xdp is not supported, because xdp requires the transport header to be placed in the first buffer, the header buffer.
I do not understand why the xdp is not supported in this case.
Isn't it the case today, wherexdp_prepare_buff()gets the buffer with offset after the net hdr? In the above case you mentioned xdp gets to used the packet buffer where pkt hdr + data is located.
The head buffer and data buffer are not continuous, but xdp requires the data memory in the linear area to be continuous. When virtio-net-hdr is stored in the header buffer, and the transport header and payload are in the data buffer, the requirements of xdp are not met at this time. Many xdp kern programs and xdp core layers also require the transport header to be placed in the linear region.
Quoted 6 lines
Quoted 5 lines
Then why
not start storing packets from the header buffer? If this is the case, imagine a
situation: If all small packets are put into the header buffers, and virtio net driver receives packets according to the descriptor table andused_ring, but the data buffers are empty at this time, then can't seem to continue?In future when such mode is extended, vq mechanism will be extended to handle desc table and used ring anyway.
Yes, for example, we can support the descriptor table to allow placing a buffer with a length of 0 as a placeholder to deal with the above problem.
Quoted 8 lines
Quoted 5 lines
It seems that
the operation of circular queue has become a producer-consumer problem again.I didn’t follow.
I tend to imagine that driver consumed meta data (
vnet_hdrand used ring) should be placed together in one buffer and
Sorry, I didn't understand what you said, can you explain more clearly? Do you mean that virtio-ner-hdr and some other metadata are placed in a buffer? How are used ring and virtio-net-hdr placed together in one buffer?
Thanks.
Quoted 38 lines
Actual packet header and data belongs to other buffer.
This way there is clear layering of ownership. But before we explore this option, lets understand your above point.Quoted 35 lines
3. The meaning of
hdr_lenin virtio-net-hdr:
i. When splitting successfully:hdr_lenrepresents the effective length of the
header in the header buffer.
ii. On unsuccessful split:hdr_lenis 0.What do you think of this plan? Or is there a better one?
Thanks.
Quoted 4 lines
This method has few benefits on perf and buffer efficiency as below.
1. Data buffers can be directly mapped at best utilization 2. Device doesn't need to match up per packet header sizes and descriptor sizes, efficient for device to implement 3. No need to keep reposting the headerbuffers, only its tail index to be updated.
Quoted 1 line
Directly gives 50% cycle reduction on buffer traversing on driver side on rx
path.
Quoted 2 lines
4. Ability to share this header buffer queue among multiple RQs if needed.
5. In the future there may be an extension to place tiny whole packets thatcan fit in the header buffer also to contain the rest of the data.
Quoted 4 lines
6. Device can always fall back to place packet header in data buffer when header buffer is not available or smaller than newer protocol 7. Because the header buffer comes virtually contiguous memory and not intermixed with data buffers, there isn't small per header allocations 8. Also
works in both chained and merged mode 9. memory utilization for an RQ of depth 256, with 4K page size for data buffers = 1M, and hdr buffer per packet = 256 * 128bytes = only 3% of the data buffer.
Quoted 2 lines
So, in worst case when no packet uses the header buffers wastage is only 3%. When high number of packets larger than 4K uses the header buffer, say 8K
packets, header buffer utilization is at 50%. So, wastage is only 1.5%.
Quoted 1 line
At 1500 mtu merged buffer data buffer size, it is also < 10% of hdr buffer
memory.
Quoted 3 lines
All 3 cases are very manageable range of buffer utilization.
Crafting and modifying the feature bits from your v7 version and virtio net
header is not difficult to get there if we like this approach.
Quoted 69 lines
From: Heng Qi <[email protected]>
Sent: Wednesday, February 1, 2023 10:45 PMQuoted 46 lines · Parav Pandit
Quoted 2 lines
From: Heng Qi <[email protected]>
Sent: Wednesday, February 1, 2023 8:18 AM[..]
Quoted 42 lines
Quoted 7 lines
Response....
Page alignment requirements should not come from the virtio spec. There are a variety of cases which may use non page aligned data buffers. a. A kernel only consumer can use it who doesn't have mmap requirement. b. A VQ accessible directly in user space may also use it without page
alignment.
Quoted 2 lines
c. A system with 64k page size, page aligned memory has a fair amount of
wastage.
Quoted 6 lines
d. iouring example you pointed, also has non page aligned use.
So let the driver deal with alignment restriction, outside of the virtio spec.
In header data split cases, data buffers utilization is more important than the
tiny header buffers utilization.
Quoted 4 lines
How about if the headers do not interfere with the data buffers?
In other words, say a given RQ has optionally linked to a circular queue of
header buffers.
Quoted 3 lines
All header buffers are of the same size, supplied one time. This header size and circular q address is configured one time at RQ creation
time.
Quoted 2 lines
With this the device doesn't need to process header buffer size every single
incoming packet.
Quoted 3 lines
Data buffers can continue as chains or merged mode can be supported. When the received packet’s header cannot fit, it continues as-is in the data
buffer.
Quoted 1 line
Virtio net hdr as suggest indicates usage of hdr buffer offset/index.
This is a good direction, thanks a lot for your comments, the new split header method might look like this:
When allocating the receive queue, allocate a circular queue storing the header buffers at the driver layer, which is shared with the device, and set the length of the header buffer. The length of the circular queue is the same as the length of the descriptor table.Quoted 12 lines
Quoted 6 lines
1. When a data packet is successfully split, all virtio-net-hdr + transport headers are stored in the header buffer, and
VIRTIO_NET_HDR_F_SPLIT_HEADERis set in the flag of virtio-net-hdr; If the header buffer is not enough to store virtio- net-hdr + transport header, then roll back, that is, not split the packet;Right.
Quoted 4 lines
2. When a packet is not split by the device for some reason, virtio-net-hdr is placed in the header buffer, and the transport header and payload are placed in the buffer. At this time, xdp is not supported, because xdp requires the transport header to be placed in the
first buffer, the header buffer.
Quoted 2 lines
I do not understand why the xdp is not supported in this case. Isn't it the case today, where
xdp_prepare_buff()gets the buffer with offsetafter the net hdr?
Quoted 1 line
In the above case you mentioned xdp gets to used the packet buffer where
Quoted 9 lines
pkt hdr + data is located.
The head buffer and data buffer are not continuous, but xdp requires the data memory in the linear area to be continuous. When virtio-net-hdr is stored in the header buffer, and the transport header and payload are in the data buffer, the requirements of xdp are not met at this time. Many xdp kern programs and xdp core layers also require the transport header to be placed in the linear region.
Lets keep aside a virtio net hdr for a moment.
Pkt HDR (L2 to L4) is in buffer_type_1.
Pkt Data (after L4) is in buffer_type_2.
They are not contiguous.
In this case XDP doesn’t work.
Did I understand you correctly?
If so, there is ongoing work to support multi buffer XDP. We should look forward to have that support it in the future in OS.
Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
Then why
not start storing packets from the header buffer? If this is the case, imagine a
situation: If all small packets are put into the header buffers, and virtio net driver receives packets according to the descriptor table andused_ring, but the data buffers are empty at this time, then can't seemto continue?
Quoted 1 line
In future when such mode is extended, vq mechanism will be extended to
handle desc table and used ring anyway.
Yes, for example, we can support the descriptor table to allow placing a buffer with a length of 0 as a placeholder to deal with the above problem.
Quoted 7 lines
Quoted 5 lines
It seems that
the operation of circular queue has become a producer-consumer problem again.I didn’t follow.
Quoted 8 lines
Quoted 2 lines
I tend to imagine that driver consumed meta data (
vnet_hdrand used ring) should be placed together in one buffer andSorry, I didn't understand what you said, can you explain more clearly? Do you mean that
virtio-ner-hdr and some other metadata are placed in a buffer? How are used ring and virtio-net-hdr placed together in one buffer?
We can extend virtio net used ring which will consist of,
struct virtio_net_used_ring_entry {
struct virtio_net_hdr hdr; /* with padding bytes */
struct used_elem elem[];
};
struct virtio_net_used_ring {
struct virtio_net_used_ring_entry ring[];
};With above layering is nit.
Driver metadata stays in driver level such as something like above struct.
HDR buffer can have constant size head room too, which is cache line aligned without any kind of padding. No need to mix driver internal meta data (vnet_hdr and packet hdr) together.
This may find its use even without HDS, where one received packets, metadata is found adjacent in single cache line.
Quoted 46 lines
Thanks.
Quoted 2 lines
Actual packet header and data belongs to other buffer.
This way there is clear layering of ownership. But before we explore thisoption, lets understand your above point.
Quoted 3 lines
Quoted 3 lines
3. The meaning of
hdr_lenin virtio-net-hdr:
i. When splitting successfully:hdr_lenrepresents the effective length ofthe
Quoted 16 lines
Quoted 16 lines
header in the header buffer.
ii. On unsuccessful split:hdr_lenis 0.What do you think of this plan? Or is there a better one?
Thanks.
Quoted 4 lines
This method has few benefits on perf and buffer efficiency as below.
1. Data buffers can be directly mapped at best utilization 2. Device doesn't need to match up per packet header sizes and descriptor sizes, efficient for device to implement 3. No need to keep reposting the headerbuffers, only its tail index to be updated.
Quoted 1 line
Directly gives 50% cycle reduction on buffer traversing on driver side on rx
path.
Quoted 2 lines
4. Ability to share this header buffer queue among multiple RQs if needed.
5. In the future there may be an extension to place tiny whole packets thatQuoted 7 lines
Quoted 7 lines
can fit in the header buffer also to contain the rest of the data.
Quoted 4 lines
6. Device can always fall back to place packet header in data buffer when header buffer is not available or smaller than newer protocol 7. Because the header buffer comes virtually contiguous memory and not intermixed with data buffers, there isn't small per header allocations 8. Also
works in both chained and merged mode 9. memory utilization for an RQ of depth 256, with 4K page size for data buffers = 1M, and hdr buffer per
packet =
Quoted 2 lines
Quoted 2 lines
256 * 128bytes = only 3% of the data buffer.
Quoted 1 line
So, in worst case when no packet uses the header buffers wastage is only
3%.
Quoted 1 line
Quoted 1 line
Quoted 1 line
When high number of packets larger than 4K uses the header buffer, say
8K
Quoted 7 lines
Quoted 7 lines
packets, header buffer utilization is at 50%. So, wastage is only 1.5%.
Quoted 1 line
At 1500 mtu merged buffer data buffer size, it is also < 10% of hdr buffer
memory.
Quoted 3 lines
All 3 cases are very manageable range of buffer utilization.
Crafting and modifying the feature bits from your v7 version and virtio net
header is not difficult to get there if we like this approach.
Quoted 77 lines · Parav Pandit
Quoted 68 lines
From: Heng Qi <[email protected]>
Sent: Wednesday, February 1, 2023 10:45 PMQuoted 46 lines · Parav Pandit
Quoted 2 lines
From: Heng Qi <[email protected]>
Sent: Wednesday, February 1, 2023 8:18 AM[..]
Quoted 42 lines
Quoted 7 lines
Response....
Page alignment requirements should not come from the virtio spec. There are a variety of cases which may use non page aligned data buffers. a. A kernel only consumer can use it who doesn't have mmap requirement. b. A VQ accessible directly in user space may also use it without page
alignment.
Quoted 2 lines
c. A system with 64k page size, page aligned memory has a fair amount of
wastage.
Quoted 6 lines
d. iouring example you pointed, also has non page aligned use.
So let the driver deal with alignment restriction, outside of the virtio spec.
In header data split cases, data buffers utilization is more important than the
tiny header buffers utilization.
Quoted 4 lines
How about if the headers do not interfere with the data buffers?
In other words, say a given RQ has optionally linked to a circular queue of
header buffers.
Quoted 3 lines
All header buffers are of the same size, supplied one time. This header size and circular q address is configured one time at RQ creation
time.
Quoted 2 lines
With this the device doesn't need to process header buffer size every single
incoming packet.
Quoted 3 lines
Data buffers can continue as chains or merged mode can be supported. When the received packet’s header cannot fit, it continues as-is in the data
buffer.
Quoted 1 line
Virtio net hdr as suggest indicates usage of hdr buffer offset/index.
This is a good direction, thanks a lot for your comments, the new split header method might look like this:
When allocating the receive queue, allocate a circular queue storing the header buffers at the driver layer, which is shared with the device, and set the length of the header buffer. The length of the circular queue is the same as the length of the descriptor table.Quoted 12 lines
Quoted 6 lines
1. When a data packet is successfully split, all virtio-net-hdr + transport headers are stored in the header buffer, and
VIRTIO_NET_HDR_F_SPLIT_HEADERis set in the flag of virtio-net-hdr; If the header buffer is not enough to store virtio- net-hdr + transport header, then roll back, that is, not split the packet;Right.
Quoted 4 lines
2. When a packet is not split by the device for some reason, virtio-net-hdr is placed in the header buffer, and the transport header and payload are placed in the buffer. At this time, xdp is not supported, because xdp requires the transport header to be placed in the
first buffer, the header buffer.
Quoted 2 lines
I do not understand why the xdp is not supported in this case. Isn't it the case today, where
xdp_prepare_buff()gets the buffer with offsetafter the net hdr?
Quoted 1 line
In the above case you mentioned xdp gets to used the packet buffer where
Quoted 9 lines
pkt hdr + data is located.
The head buffer and data buffer are not continuous, but xdp requires the data memory in the linear area to be continuous. When virtio-net-hdr is stored in the header buffer, and the transport header and payload are in the data buffer, the requirements of xdp are not met at this time. Many xdp kern programs and xdp core layers also require the transport header to be placed in the linear region.
Quoted 6 lines
Lets keep aside a virtio net hdr for a moment.
Pkt HDR (L2 to L4) is inbuffer_type_1.
Pkt Data (after L4) is inbuffer_type_2.
They are not contiguous.
In this case XDP doesn’t work.
Did I understand you correctly?
It seems not. The case you mentioned is currently supported in virtio-net:
https://lore.kernel.org/all/[email protected]/ .
I just mean:
Virtio-net-hdr is in buffer_type_1.
Pkt hdr (L2 to L4) + pkt data (after L4) are in buffer_type_2.
They are not contiguous and xdp doesn't work.
Quoted 38 lines
If so, there is ongoing work to support multi buffer XDP. We should look forward to have that support it in the future in OS.
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
Then why
not start storing packets from the header buffer? If this is the case, imagine a
situation: If all small packets are put into the header buffers, and virtio net driver receives packets according to the descriptor table andused_ring, but the data buffers are empty at this time, then can't seemto continue?
Quoted 1 line
In future when such mode is extended, vq mechanism will be extended to
handle desc table and used ring anyway.
Yes, for example, we can support the descriptor table to allow placing a buffer with a length of 0 as a placeholder to deal with the above problem.
Quoted 4 lines
Quoted 4 lines
It seems that
the operation of circular queue has become a producer-consumer problem again.Quoted 9 lines
Quoted 4 lines
I didn’t follow.
I tend to imagine that driver consumed meta data (
vnet_hdrand used ring) should be placed together in one buffer andSorry, I didn't understand what you said, can you explain more clearly? Do you mean that
virtio-ner-hdr and some other metadata are placed in a buffer? How are used ring and virtio-net-hdr placed together in one buffer?We can extend virtio net used ring which will consist of,
struct virtio_net_used_ring_entry { struct virtio_net_hdr hdr; /* with padding bytes */ struct used_elem elem[]; }; struct virtio_net_used_ring { struct virtio_net_used_ring_entry ring[]; };
Quoted 6 lines
With above layering is nit.
Driver metadata stays in driver level such as something like above struct.
HDR buffer can have constant size head room too, which is cache line aligned without any kind of padding. No need to mix driver internal meta data (vnet_hdrand packet hdr) together.This may find its use even without HDS, where one received packets, metadata is found adjacent in single cache line.
Yes, this seems to be a good solution, but we should proceed step by step, such as pushing the split header first, and then try to change the virtio core later.
Thanks.
Quoted 36 lines
Quoted 36 lines
Thanks.
Quoted 2 lines
Actual packet header and data belongs to other buffer.
This way there is clear layering of ownership. But before we explore thisoption, lets understand your above point.
Quoted 2 lines
Quoted 2 lines
3. The meaning of
hdr_lenin virtio-net-hdr:
i. When splitting successfully:hdr_lenrepresents the effective length ofthe
Quoted 16 lines
Quoted 16 lines
header in the header buffer.
ii. On unsuccessful split:hdr_lenis 0.What do you think of this plan? Or is there a better one?
Thanks.
Quoted 4 lines
This method has few benefits on perf and buffer efficiency as below.
1. Data buffers can be directly mapped at best utilization 2. Device doesn't need to match up per packet header sizes and descriptor sizes, efficient for device to implement 3. No need to keep reposting the headerbuffers, only its tail index to be updated.
Quoted 1 line
Directly gives 50% cycle reduction on buffer traversing on driver side on rx
path.
Quoted 2 lines
4. Ability to share this header buffer queue among multiple RQs if needed.
5. In the future there may be an extension to place tiny whole packets thatQuoted 7 lines
Quoted 7 lines
can fit in the header buffer also to contain the rest of the data.
Quoted 4 lines
6. Device can always fall back to place packet header in data buffer when header buffer is not available or smaller than newer protocol 7. Because the header buffer comes virtually contiguous memory and not intermixed with data buffers, there isn't small per header allocations 8. Also
works in both chained and merged mode 9. memory utilization for an RQ of depth 256, with 4K page size for data buffers = 1M, and hdr buffer per
packet =
Quoted 2 lines
Quoted 2 lines
256 * 128bytes = only 3% of the data buffer.
Quoted 1 line
So, in worst case when no packet uses the header buffers wastage is only
3%.
Quoted 1 line
Quoted 1 line
Quoted 1 line
When high number of packets larger than 4K uses the header buffer, say
Quoted 8 lines
Quoted 8 lines
8K
Quoted 7 lines
Quoted 7 lines
packets, header buffer utilization is at 50%. So, wastage is only 1.5%.
Quoted 1 line
At 1500 mtu merged buffer data buffer size, it is also < 10% of hdr buffer
memory.
Quoted 3 lines
All 3 cases are very manageable range of buffer utilization.
Crafting and modifying the feature bits from your v7 version and virtio net
header is not difficult to get there if we like this approach.
This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.
In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.
Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/
Quoted 124 lines · Parav Pandit
Quoted 69 lines
From: Heng Qi <[email protected]>
Sent: Wednesday, February 1, 2023 10:45 PMQuoted 46 lines · Parav Pandit
Quoted 2 lines
From: Heng Qi <[email protected]>
Sent: Wednesday, February 1, 2023 8:18 AM[..]
Quoted 42 lines
Quoted 7 lines
Response....
Page alignment requirements should not come from the virtio spec. There are a variety of cases which may use non page aligned data buffers. a. A kernel only consumer can use it who doesn't have mmap requirement. b. A VQ accessible directly in user space may also use it without page
alignment.
Quoted 2 lines
c. A system with 64k page size, page aligned memory has a fair amount of
wastage.
Quoted 6 lines
d. iouring example you pointed, also has non page aligned use.
So let the driver deal with alignment restriction, outside of the virtio spec.
In header data split cases, data buffers utilization is more important than the
tiny header buffers utilization.
Quoted 4 lines
How about if the headers do not interfere with the data buffers?
In other words, say a given RQ has optionally linked to a circular queue of
header buffers.
Quoted 3 lines
All header buffers are of the same size, supplied one time. This header size and circular q address is configured one time at RQ creation
time.
Quoted 2 lines
With this the device doesn't need to process header buffer size every single
incoming packet.
Quoted 3 lines
Data buffers can continue as chains or merged mode can be supported. When the received packet’s header cannot fit, it continues as-is in the data
buffer.
Quoted 1 line
Virtio net hdr as suggest indicates usage of hdr buffer offset/index.
This is a good direction, thanks a lot for your comments, the new split header method might look like this:
When allocating the receive queue, allocate a circular queue storing the header buffers at the driver layer, which is shared with the device, and set the length of the header buffer. The length of the circular queue is the same as the length of the descriptor table.Quoted 12 lines
Quoted 6 lines
1. When a data packet is successfully split, all virtio-net-hdr + transport headers are stored in the header buffer, and
VIRTIO_NET_HDR_F_SPLIT_HEADERis set in the flag of virtio-net-hdr; If the header buffer is not enough to store virtio- net-hdr + transport header, then roll back, that is, not split the packet;Right.
Quoted 4 lines
2. When a packet is not split by the device for some reason, virtio-net-hdr is placed in the header buffer, and the transport header and payload are placed in the buffer. At this time, xdp is not supported, because xdp requires the transport header to be placed in the
first buffer, the header buffer.
Quoted 2 lines
I do not understand why the xdp is not supported in this case. Isn't it the case today, where
xdp_prepare_buff()gets the buffer with offsetafter the net hdr?
Quoted 1 line
In the above case you mentioned xdp gets to used the packet buffer where
Quoted 9 lines
pkt hdr + data is located.
The head buffer and data buffer are not continuous, but xdp requires the data memory in the linear area to be continuous. When virtio-net-hdr is stored in the header buffer, and the transport header and payload are in the data buffer, the requirements of xdp are not met at this time. Many xdp kern programs and xdp core layers also require the transport header to be placed in the linear region.
Lets keep aside a virtio net hdr for a moment.
Pkt HDR (L2 to L4) is inbuffer_type_1.
Pkt Data (after L4) is inbuffer_type_2.
They are not contiguous.
In this case XDP doesn’t work.
Did I understand you correctly?
If so, there is ongoing work to support multi buffer XDP. We should look forward to have that support it in the future in OS.Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
Then why
not start storing packets from the header buffer? If this is the case, imagine a
situation: If all small packets are put into the header buffers, and virtio net driver receives packets according to the descriptor table andused_ring, but the data buffers are empty at this time, then can't seemto continue?
Quoted 1 line
In future when such mode is extended, vq mechanism will be extended to
handle desc table and used ring anyway.
Yes, for example, we can support the descriptor table to allow placing a buffer with a length of 0 as a placeholder to deal with the above problem.
Quoted 7 lines
Quoted 5 lines
It seems that
the operation of circular queue has become a producer-consumer problem again.I didn’t follow.
Quoted 8 lines
Quoted 2 lines
I tend to imagine that driver consumed meta data (
vnet_hdrand used ring) should be placed together in one buffer andSorry, I didn't understand what you said, can you explain more clearly? Do you mean that
virtio-ner-hdr and some other metadata are placed in a buffer? How are used ring and virtio-net-hdr placed together in one buffer?We can extend virtio net used ring which will consist of,
struct virtio_net_used_ring_entry { struct virtio_net_hdr hdr; /* with padding bytes */ struct used_elem elem[]; }; struct virtio_net_used_ring { struct virtio_net_used_ring_entry ring[]; };
Quoted 6 lines
With above layering is nit.
Driver metadata stays in driver level such as something like above struct.
HDR buffer can have constant size head room too, which is cache line aligned without any kind of padding. No need to mix driver internal meta data (vnet_hdrand packet hdr) together.This may find its use even without HDS, where one received packets, metadata is found adjacent in single cache line.
Most xdp packets just have all of the header set to 0. So maybe we can just skip it completely.
Or worst case a single bit - we can probably find a place to store it without making the ring larger.
Quoted 46 lines
Quoted 46 lines
Thanks.
Quoted 2 lines
Actual packet header and data belongs to other buffer.
This way there is clear layering of ownership. But before we explore thisoption, lets understand your above point.
Quoted 3 lines
Quoted 3 lines
3. The meaning of
hdr_lenin virtio-net-hdr:
i. When splitting successfully:hdr_lenrepresents the effective length ofthe
Quoted 16 lines
Quoted 16 lines
header in the header buffer.
ii. On unsuccessful split:hdr_lenis 0.What do you think of this plan? Or is there a better one?
Thanks.
Quoted 4 lines
This method has few benefits on perf and buffer efficiency as below.
1. Data buffers can be directly mapped at best utilization 2. Device doesn't need to match up per packet header sizes and descriptor sizes, efficient for device to implement 3. No need to keep reposting the headerbuffers, only its tail index to be updated.
Quoted 1 line
Directly gives 50% cycle reduction on buffer traversing on driver side on rx
path.
Quoted 2 lines
4. Ability to share this header buffer queue among multiple RQs if needed.
5. In the future there may be an extension to place tiny whole packets thatQuoted 7 lines
Quoted 7 lines
can fit in the header buffer also to contain the rest of the data.
Quoted 4 lines
6. Device can always fall back to place packet header in data buffer when header buffer is not available or smaller than newer protocol 7. Because the header buffer comes virtually contiguous memory and not intermixed with data buffers, there isn't small per header allocations 8. Also
works in both chained and merged mode 9. memory utilization for an RQ of depth 256, with 4K page size for data buffers = 1M, and hdr buffer per
packet =
Quoted 2 lines
Quoted 2 lines
256 * 128bytes = only 3% of the data buffer.
Quoted 1 line
So, in worst case when no packet uses the header buffers wastage is only
3%.
Quoted 1 line
Quoted 1 line
Quoted 1 line
When high number of packets larger than 4K uses the header buffer, say
8K
Quoted 7 lines
Quoted 7 lines
packets, header buffer utilization is at 50%. So, wastage is only 1.5%.
Quoted 1 line
At 1500 mtu merged buffer data buffer size, it is also < 10% of hdr buffer
memory.
Quoted 3 lines
All 3 cases are very manageable range of buffer utilization.
Crafting and modifying the feature bits from your v7 version and virtio net
header is not difficult to get there if we like this approach.