Define VIRTIO_NET_F_HASH_REPORT feature
v4 cover Define VIRTIO_NET_F_HASH_REPORT feature
Changes from v3:
Rebased to latest master branch
Changes feature number to 57 (as 58 is under discussion) Minor changes according to v3 review
Yuri Benditovich (1):
virtio-net: Define per-packet hash reporting feature
content.tex | 347 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 229 insertions(+), 118 deletions(-)
Signature · 18 lines
2.17.1 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/
PATCH v4 1/1 virtio-net: Define per-packet hash reporting feature
Fixes: https://github.com/oasis-tcs/virtio-spec/issues/66
Define respective feature bit for virtio-net. Extend packet layout to populate hash value and type. Move the definition of IP/TCP/UDP header fields to calculate the hash out of RSS section to common network device section.
--- content.tex | 347 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 229 insertions(+), 118 deletions(-)
content.tex +229 -118
@@ -2895,6 +2895,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_HASH_REPORT(57)] Device can report per-packet hash + value and a type of calculated hash. + \item[VIRTIO_NET_F_GUEST_HDRLEN(59)] Driver can provide the exact \field{hdr_len} value. Device benefits from knowing the exact header length.
@@ -2995,35 +2998,17 @@ \subsection{Device configuration layout}\label{sec:Device Types / Network Device le32 supported_hash_types; }; \end{lstlisting} -\label{sec:Device Types / Network Device / Device configuration layout / RSS} -Three following fields, \field{rss_max_key_size}, \field{rss_max_indirection_table_length} -and \field{supported_hash_types} only exist if VIRTIO_NET_F_RSS is set. +The following field, \field{rss_max_key_size} only exist if VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT is set. +It specifies the maximal supported length of RSS key in bytes. -Field \field{rss_max_key_size} specifies the maximal supported length of RSS key in bytes. +The following field, \field{rss_max_indirection_table_length} only exist if VIRTIO_NET_F_RSS is set. +It specifies the maximal number of 16-bit entries in RSS indirection table. -Field \field{rss_max_indirection_table_length} specifies the maximal number of 16-bit entries in RSS indirection table. +The next field, \field{supported_hash_types} exists only if the device supports hash calculation, +i.e. if VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT is set. -Field \field{supported_hash_types} contains the bitmask of supported RSS hash types. - -Hash types applicable for IPv4 packets: -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) -#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) -\end{lstlisting} -Hash types applicable for IPv6 packets without extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) -#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) -\end{lstlisting} -Hash types applicable for IPv6 packets with extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) -#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) -#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) -\end{lstlisting} -For the exact meaning of VIRTIO_NET_RSS_HASH_TYPE_ flags see \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}. +Field \field{supported_hash_types} contains the bitmask of supported hash types. +See \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types} for details of supported hash types. \devicenormative{\subsubsection}{Device configuration layout}{Device Types / Network Device / Device configuration layout}
@@ -3048,7 +3033,7 @@ \subsection{Device configuration layout}\label{sec:Device Types / Network Device negotiated. The device MUST set \field{rss_max_key_size} to at least 40, if it offers -VIRTIO_NET_F_RSS. +VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT. The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers VIRTIO_NET_F_RSS.
@@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O le16 csum_start; le16 csum_offset; le16 num_buffers; + le32 hash_value; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) + le16 hash_type; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) }; \end{lstlisting}
@@ -3517,6 +3504,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network \end{enumerate} +If applicable, the device calculates per-packet hash for incoming packets as +defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}. + +If applicable, the device reports hash information for incoming packets as +defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash reporting for incoming packets}. + \devicenormative{\paragraph}{Processing of Incoming Packets}{Device Types / Network Device / Device Operation / Processing of Incoming Packets} \label{devicenormative:Device Types / Network Device / Device Operation / Processing of Packets}%old label for latexdiff
@@ -3619,6 +3612,181 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network If neither VIRTIO_NET_HDR_F_NEEDS_CSUM nor VIRTIO_NET_HDR_F_DATA_VALID is set, the driver MUST NOT rely on the packet checksum being correct. + +\paragraph{Hash calculation for incoming packets} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets} + +A device attempts to calculate a per-packet hash in the following cases: +\begin{itemize} +\item The feature VIRTIO_NET_F_RSS was negotiated. The device uses the hash to determine the receive virtqueue to place incoming packets. +\item The feature VIRTIO_NET_F_HASH_REPORT was negotiated. The device reports the hash value and the hash type with the packet. +\end{itemize} + +If the feature VIRTIO_NET_F_RSS was negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the virtio_net_rss_config structure as 'Enabled hash types' bitmask. +\item The device uses a key as defined in \field{hash_key_data} and \field{hash_key_length} of the virtio_net_rss_config structure (see +\ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}). +\end{itemize} + +If the feature VIRTIO_NET_F_RSS was not negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the virtio_net_hash_config structure as 'Enabled hash types' bitmask. +\item The device uses a key as defined in \field{hash_key_data} and \field{hash_key_length} of the virtio_net_hash_config structure (see +\ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}). +\end{itemize} + +Note that if the device offers VIRTIO_NET_F_HASH_REPORT, even if it supports only one pair of virtqueues, it MUST support +at least one of commands of VIRTIO_NET_CTRL_MQ class to configure reported hash parameters: +\begin{itemize} +\item If the device offers VIRTIO_NET_F_RSS, it MUST support VIRTIO_NET_CTRL_MQ_RSS_CONFIG command per + \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}. +\item Otherwise the device MUST support VIRTIO_NET_CTRL_MQ_HASH_CONFIG command per + \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}. +\end{itemize} + +\subparagraph{Supported/enabled hash types} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types} +Hash types applicable for IPv4 packets: +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv4 (1 << 0) +#define VIRTIO_NET_HASH_TYPE_TCPv4 (1 << 1) +#define VIRTIO_NET_HASH_TYPE_UDPv4 (1 << 2) +\end{lstlisting} +Hash types applicable for IPv6 packets without extension headers +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv6 (1 << 3) +#define VIRTIO_NET_HASH_TYPE_TCPv6 (1 << 4) +#define VIRTIO_NET_HASH_TYPE_UDPv6 (1 << 5) +\end{lstlisting} +Hash types applicable for IPv6 packets with extension headers +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IP_EX (1 << 6) +#define VIRTIO_NET_HASH_TYPE_TCP_EX (1 << 7) +#define VIRTIO_NET_HASH_TYPE_UDP_EX (1 << 8) +\end{lstlisting} + +\subparagraph{IPv4 packets} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv4 packets} +The device calculates the hash on IPv4 packets according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCPv4 is set and the packet has +a TCP header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv4 is set and the +packet has a UDP header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\item Source UDP port +\item Destination UDP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_IPv4 is set, the hash is +calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\end{itemize} +\item Else the device does not calculate the hash +\end{itemize} + +\subparagraph{IPv6 packets without extension header} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header} +The device calculates the hash on IPv6 packets without extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCPv6 is set and the packet has +a TCPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv6 is set and the +packet has a UDPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\item Source UDP port +\item Destination UDP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_IPv6 is set, the hash is +calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\end{itemize} +\item Else the device does not calculate the hash +\end{itemize} + +\subparagraph{IPv6 packets with extension header} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets with extension header} +The device calculates the hash on IPv6 packets with extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCP_EX is set and the packet +has a TCPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. +\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDP_EX is set and the +packet has a UDPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. +\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. +\item Source UDP port +\item Destination UDP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_IP_EX is set, the hash is +calculated over the following fields: +\begin{itemize} +\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. +\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. +\end{itemize} +\item Else skip IPv6 extension headers and calculate the hash as +defined for an IPv6 packet without extension headers +(see \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header}). +\end{itemize} + +\paragraph{Hash reporting for incoming packets} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash reporting for incoming packets} + +If VIRTIO_NET_F_HASH_REPORT was negotiated and + the device has calculated the hash for the packet, the device fills \field{hash_type} with the type of calculated hash +and \field{hash_value} with the value of calculated hash. + +If VIRTIO_NET_F_HASH_REPORT was negotiated but due to any reason the +hash was not calculated, the device sets \field{hash_type} to VIRTIO_NET_HASH_REPORT_NONE. + +Possible values that the device can report in \field{hash_type} are defined below. +They correspond to supported hash types defined in +\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types} +as follows: + +VIRTIO_NET_HASH_TYPE_XXX = 1 << (VIRTIO_NET_HASH_REPORT_XXX - 1) + +\begin{lstlisting} +#define VIRTIO_NET_HASH_REPORT_NONE 0 +#define VIRTIO_NET_HASH_REPORT_IPv4 1 +#define VIRTIO_NET_HASH_REPORT_TCPv4 2 +#define VIRTIO_NET_HASH_REPORT_UDPv4 3 +#define VIRTIO_NET_HASH_REPORT_IPv6 4 +#define VIRTIO_NET_HASH_REPORT_TCPv6 5 +#define VIRTIO_NET_HASH_REPORT_UDPv6 6 +#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 +#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 +#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 +\end{lstlisting} + \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue} The driver uses the control virtqueue (if VIRTIO_NET_F_CTRL_VQ is
@@ -3896,6 +4064,7 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi #define VIRTIO_NET_CTRL_MQ 4 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 (for automatic receive steering) #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 (for configurable receive steering) + #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 (for configurable hash calculation) \end{lstlisting} If more than one multiqueue mode is negotiated, the resulting device configuration is defined by the last command sent by the driver.
@@ -3961,10 +4130,37 @@ \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. +\subparagraph{Hash calculation}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation} +If VIRTIO_NET_F_HASH_REPORT was negotiated and the device uses automatic receive steering, +the device MUST support a command to configure hash calculation parameters. + +The driver provides parameters for hash calculation as follows: + +\field{class} VIRTIO_NET_CTRL_MQ, \field{command} VIRTIO_NET_CTRL_MQ_HASH_CONFIG. + +The \field{command-specific-data} has following format: +\begin{lstlisting} +struct virtio_net_hash_config { + le32 hash_types; + le16 reserved[4]; + u8 hash_key_length; + u8 hash_key_data[hash_key_length]; +}; +\end{lstlisting} +Field \field{hash_types} contains a bitmask of allowed hash types as +defined in +\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types}. +Initially the device has all hash types disabled and reports only VIRTIO_NET_HASH_REPORT_NONE. + +Field \field{reserved} MUST contain zeroes. It is defined to make the structure to match the layout of virtio_net_rss_config structure, +defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS)}. + +Fields \field{hash_key_length} and \field{hash_key_data} define the key to be used in hash calculation. + \paragraph{Receive-side scaling (RSS)}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS)} A device offers the feature VIRTIO_NET_F_RSS if it supports RSS receive steering with Toeplitz hash calculation and configurable parameters. -A driver queries RSS capabilities of the device by reading device configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout / RSS} +A driver queries RSS capabilities of the device by reading device configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout} \subparagraph{Setting RSS parameters}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}
@@ -3981,7 +4177,8 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi }; \end{lstlisting} Field \field{hash_types} contains a bitmask of allowed hash types as -defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}. +defined in +\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types}. Field \field{indirection_table_mask} is a mask to be applied to the calculated hash to produce an index in the
@@ -3995,93 +4192,7 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi A driver sets \field{max_tx_vq} to inform a device how many transmit virtqueues it may use (transmitq1\ldots transmitq \field{max_tx_vq}). -\subparagraph{RSS hash types}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types} - -The device calculates the hash on IPv4 packets according to the -field \field{hash_types} of the virtio_net_rss_config structure as follows: -\begin{itemize} -\item If VIRTIO_NET_RSS_HASH_TYPE_TCPv4 is set and the packet has -a TCP header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv4 is set and the -packet has a UDP header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\item Source UDP port -\item Destination UDP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_IPv4 is set, the hash is -calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\end{itemize} -\item Else the device does not calculate the hash -\end{itemize} - -\label{itm:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers} -The device calculates the hash on IPv6 packets without extension -headers according to the field \field{hash_types} of the virtio_net_rss_config structure as follows: -\begin{itemize} -\item If VIRTIO_NET_RSS_HASH_TYPE_TCPv6 is set and the packet has -a TCPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv6 is set and the -packet has a UDPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\item Source UDP port -\item Destination UDP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_IPv6 is set, the hash is -calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\end{itemize} -\item Else the device does not calculate the hash -\end{itemize} - -The device calculates the hash on IPv6 packets with extension -headers according to the field \field{hash_types} of the virtio_net_rss_config structure as follows: -\begin{itemize} -\item If VIRTIO_NET_RSS_HASH_TYPE_TCP_EX is set and the packet -has a TCPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. -\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDP_EX is set and the -packet has a UDPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. -\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. -\item Source UDP port -\item Destination UDP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_IP_EX is set, the hash is -calculated over the following fields: -\begin{itemize} -\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. -\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. -\end{itemize} -\item Else skip IPv6 extension headers and calculate the hash as -defined for an IPv6 packet without extension headers (see \ref{itm:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers}). -\end{itemize} +Fields \field{hash_key_length} and \field{hash_key_data} define the key to be used in hash calculation. \drivernormative{\subparagraph}{Setting RSS parameters}{Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) }
@@ -4093,12 +4204,12 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi A driver MUST use \field{indirection_table_mask} values that are less than \field{rss_max_indirection_table_length} reported by a device. -A driver MUST NOT set any VIRTIO_NET_RSS_HASH_TYPE_ flags that are not supported by a device. +A driver MUST NOT set any VIRTIO_NET_HASH_TYPE_ flags that are not supported by a device. \devicenormative{\subparagraph}{RSS processing}{Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS processing} The device MUST determine the destination queue for a network packet as follows: \begin{itemize} -\item Calculate the hash of the packet as defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types} +\item Calculate the hash of the packet as defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}. \item If the device did not calculate the hash for the specific packet, the device directs the packet to the receiveq specified by \field{unclassified_queue} of virtio_net_rss_config structure (value of 0 corresponds to receiveq1). \item Apply \field{indirection_table_mask} to the calculated hash and use the result as the index in the indirection table to get 0-based number of destination receiveq (value of 0 corresponds to receiveq1). \end{itemize}
Signature · 18 lines
2.17.1 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/
[virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
Quoted 80 lines · Yuri Benditovich
Fixes: https://github.com/oasis-tcs/virtio-spec/issues/66
Define respective feature bit for virtio-net. Extend packet layout to populate hash value and type. Move the definition of IP/TCP/UDP header fields to calculate the hash out of RSS section to common network device section.Signed-off-by Yuri Benditovich <[email protected]>--- content.tex | 347 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 229 insertions(+), 118 deletions(-)content.tex +12
-27@@ -2895,6 +2895,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_HASH_REPORT(57)] Device can report per-packet hash + value and a type of calculated hash. + \item[VIRTIO_NET_F_GUEST_HDRLEN(59)] Driver can provide the exact \field{hdr_len} value. Device benefits from knowing the exact header length.@@ -2995,35 +2998,17 @@ \subsection{Device configuration layout}\label{sec:Device Types / Network Device le32 supported_hash_types; }; \end{lstlisting} -\label{sec:Device Types / Network Device / Device configuration layout / RSS} -Three following fields, \field{rss_max_key_size}, \field{rss_max_indirection_table_length} -and \field{supported_hash_types} only exist if VIRTIO_NET_F_RSS is set. +The following field, \field{rss_max_key_size} only exist if VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT is set. +It specifies the maximal supported length of RSS key in bytes. -Field \field{rss_max_key_size} specifies the maximal supported length of RSS key in bytes. +The following field, \field{rss_max_indirection_table_length} only exist if VIRTIO_NET_F_RSS is set. +It specifies the maximal number of 16-bit entries in RSS indirection table. -Field \field{rss_max_indirection_table_length} specifies the maximal number of 16-bit entries in RSS indirection table. +The next field, \field{supported_hash_types} exists only if the device supports hash calculation, +i.e. if VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT is set. -Field \field{supported_hash_types} contains the bitmask of supported RSS hash types. - -Hash types applicable for IPv4 packets: -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) -#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) -\end{lstlisting} -Hash types applicable for IPv6 packets without extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) -#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) -\end{lstlisting} -Hash types applicable for IPv6 packets with extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) -#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) -#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) -\end{lstlisting} -For the exact meaning of VIRTIO_NET_RSS_HASH_TYPE_ flags see \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}. +Field \field{supported_hash_types} contains the bitmask of supported hash types. +See \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types} for details of supported hash types. \devicenormative{\subsubsection}{Device configuration layout}{Device Types / Network Device / Device configuration layout}@@ -3048,7 +3033,7 @@ \subsection{Device configuration layout}\label{sec:Device Types / Network Device negotiated. The device MUST set \field{rss_max_key_size} to at least 40, if it offers -VIRTIO_NET_F_RSS. +VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT. The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers VIRTIO_NET_F_RSS.
content.tex \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O · line 3185
Quoted 6 lines
content.tex +2
-0@@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O le16 csum_start; le16 csum_offset; le16 num_buffers; + le32 hash_value; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) + le16 hash_type; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) };
Just noticed this - it's a bit problematic as it might force compilers to add 2 bytes of padding at the end. Let's add extra 2 bytes of padding explicitly?
Quoted 170 lines
content.tex +157
-0\end{lstlisting}@@ -3517,6 +3504,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network \end{enumerate} +If applicable, the device calculates per-packet hash for incoming packets as +defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}. + +If applicable, the device reports hash information for incoming packets as +defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash reporting for incoming packets}. + \devicenormative{\paragraph}{Processing of Incoming Packets}{Device Types / Network Device / Device Operation / Processing of Incoming Packets} \label{devicenormative:Device Types / Network Device / Device Operation / Processing of Packets}%old label for latexdiff@@ -3619,6 +3612,181 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network If neither VIRTIO_NET_HDR_F_NEEDS_CSUM nor VIRTIO_NET_HDR_F_DATA_VALID is set, the driver MUST NOT rely on the packet checksum being correct. + +\paragraph{Hash calculation for incoming packets} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets} + +A device attempts to calculate a per-packet hash in the following cases: +\begin{itemize} +\item The feature VIRTIO_NET_F_RSS was negotiated. The device uses the hash to determine the receive virtqueue to place incoming packets. +\item The feature VIRTIO_NET_F_HASH_REPORT was negotiated. The device reports the hash value and the hash type with the packet. +\end{itemize} + +If the feature VIRTIO_NET_F_RSS was negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the virtio_net_rss_config structure as 'Enabled hash types' bitmask. +\item The device uses a key as defined in \field{hash_key_data} and \field{hash_key_length} of the virtio_net_rss_config structure (see +\ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}). +\end{itemize} + +If the feature VIRTIO_NET_F_RSS was not negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the virtio_net_hash_config structure as 'Enabled hash types' bitmask. +\item The device uses a key as defined in \field{hash_key_data} and \field{hash_key_length} of the virtio_net_hash_config structure (see +\ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}). +\end{itemize} + +Note that if the device offers VIRTIO_NET_F_HASH_REPORT, even if it supports only one pair of virtqueues, it MUST support +at least one of commands of VIRTIO_NET_CTRL_MQ class to configure reported hash parameters: +\begin{itemize} +\item If the device offers VIRTIO_NET_F_RSS, it MUST support VIRTIO_NET_CTRL_MQ_RSS_CONFIG command per + \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}. +\item Otherwise the device MUST support VIRTIO_NET_CTRL_MQ_HASH_CONFIG command per + \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}. +\end{itemize} + +\subparagraph{Supported/enabled hash types} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types} +Hash types applicable for IPv4 packets: +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv4 (1 << 0) +#define VIRTIO_NET_HASH_TYPE_TCPv4 (1 << 1) +#define VIRTIO_NET_HASH_TYPE_UDPv4 (1 << 2) +\end{lstlisting} +Hash types applicable for IPv6 packets without extension headers +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv6 (1 << 3) +#define VIRTIO_NET_HASH_TYPE_TCPv6 (1 << 4) +#define VIRTIO_NET_HASH_TYPE_UDPv6 (1 << 5) +\end{lstlisting} +Hash types applicable for IPv6 packets with extension headers +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IP_EX (1 << 6) +#define VIRTIO_NET_HASH_TYPE_TCP_EX (1 << 7) +#define VIRTIO_NET_HASH_TYPE_UDP_EX (1 << 8) +\end{lstlisting} + +\subparagraph{IPv4 packets} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv4 packets} +The device calculates the hash on IPv4 packets according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCPv4 is set and the packet has +a TCP header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv4 is set and the +packet has a UDP header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\item Source UDP port +\item Destination UDP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_IPv4 is set, the hash is +calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\end{itemize} +\item Else the device does not calculate the hash +\end{itemize} + +\subparagraph{IPv6 packets without extension header} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header} +The device calculates the hash on IPv6 packets without extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCPv6 is set and the packet has +a TCPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv6 is set and the +packet has a UDPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\item Source UDP port +\item Destination UDP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_IPv6 is set, the hash is +calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\end{itemize} +\item Else the device does not calculate the hash +\end{itemize} + +\subparagraph{IPv6 packets with extension header} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets with extension header} +The device calculates the hash on IPv6 packets with extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCP_EX is set and the packet +has a TCPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. +\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDP_EX is set and the +packet has a UDPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. +\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. +\item Source UDP port +\item Destination UDP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_IP_EX is set, the hash is +calculated over the following fields: +\begin{itemize} +\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. +\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. +\end{itemize} +\item Else skip IPv6 extension headers and calculate the hash as +defined for an IPv6 packet without extension headers +(see \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header}). +\end{itemize} + +\paragraph{Hash reporting for incoming packets} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash reporting for incoming packets} + +If VIRTIO_NET_F_HASH_REPORT was negotiated and + the device has calculated the hash for the packet, the device fills \field{hash_type} with the type of calculated hash +and \field{hash_value} with the value of calculated hash.
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network · line 3775
Quoted 10 lines
content.tex +10
-0+ +If VIRTIO_NET_F_HASH_REPORT was negotiated but due to any reason the +hash was not calculated, the device sets \field{hash_type} to VIRTIO_NET_HASH_REPORT_NONE. + +Possible values that the device can report in \field{hash_type} are defined below. +They correspond to supported hash types defined in +\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types} +as follows: + +VIRTIO_NET_HASH_TYPE_XXX = 1 << (VIRTIO_NET_HASH_REPORT_XXX - 1)
So hash_type is the HASH_REPORT value then? That's quite confusing. Let's rename to hash_report?
Quoted 186 lines
content.tex +48
-91+ +\begin{lstlisting} +#define VIRTIO_NET_HASH_REPORT_NONE 0 +#define VIRTIO_NET_HASH_REPORT_IPv4 1 +#define VIRTIO_NET_HASH_REPORT_TCPv4 2 +#define VIRTIO_NET_HASH_REPORT_UDPv4 3 +#define VIRTIO_NET_HASH_REPORT_IPv6 4 +#define VIRTIO_NET_HASH_REPORT_TCPv6 5 +#define VIRTIO_NET_HASH_REPORT_UDPv6 6 +#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 +#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 +#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 +\end{lstlisting} + \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue} The driver uses the control virtqueue (if VIRTIO_NET_F_CTRL_VQ is@@ -3896,6 +4064,7 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi #define VIRTIO_NET_CTRL_MQ 4 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 (for automatic receive steering) #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 (for configurable receive steering) + #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 (for configurable hash calculation) \end{lstlisting} If more than one multiqueue mode is negotiated, the resulting device configuration is defined by the last command sent by the driver.@@ -3961,10 +4130,37 @@ \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. +\subparagraph{Hash calculation}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation} +If VIRTIO_NET_F_HASH_REPORT was negotiated and the device uses automatic receive steering, +the device MUST support a command to configure hash calculation parameters. + +The driver provides parameters for hash calculation as follows: + +\field{class} VIRTIO_NET_CTRL_MQ, \field{command} VIRTIO_NET_CTRL_MQ_HASH_CONFIG. + +The \field{command-specific-data} has following format: +\begin{lstlisting} +struct virtio_net_hash_config { + le32 hash_types; + le16 reserved[4]; + u8 hash_key_length; + u8 hash_key_data[hash_key_length]; +}; +\end{lstlisting} +Field \field{hash_types} contains a bitmask of allowed hash types as +defined in +\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types}. +Initially the device has all hash types disabled and reports only VIRTIO_NET_HASH_REPORT_NONE. + +Field \field{reserved} MUST contain zeroes. It is defined to make the structure to match the layout of virtio_net_rss_config structure, +defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS)}. + +Fields \field{hash_key_length} and \field{hash_key_data} define the key to be used in hash calculation. + \paragraph{Receive-side scaling (RSS)}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS)} A device offers the feature VIRTIO_NET_F_RSS if it supports RSS receive steering with Toeplitz hash calculation and configurable parameters. -A driver queries RSS capabilities of the device by reading device configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout / RSS} +A driver queries RSS capabilities of the device by reading device configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout} \subparagraph{Setting RSS parameters}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}@@ -3981,7 +4177,8 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi }; \end{lstlisting} Field \field{hash_types} contains a bitmask of allowed hash types as -defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}. +defined in +\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types}. Field \field{indirection_table_mask} is a mask to be applied to the calculated hash to produce an index in the@@ -3995,93 +4192,7 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi A driver sets \field{max_tx_vq} to inform a device how many transmit virtqueues it may use (transmitq1\ldots transmitq \field{max_tx_vq}). -\subparagraph{RSS hash types}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types} - -The device calculates the hash on IPv4 packets according to the -field \field{hash_types} of the virtio_net_rss_config structure as follows: -\begin{itemize} -\item If VIRTIO_NET_RSS_HASH_TYPE_TCPv4 is set and the packet has -a TCP header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv4 is set and the -packet has a UDP header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\item Source UDP port -\item Destination UDP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_IPv4 is set, the hash is -calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\end{itemize} -\item Else the device does not calculate the hash -\end{itemize} - -\label{itm:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers} -The device calculates the hash on IPv6 packets without extension -headers according to the field \field{hash_types} of the virtio_net_rss_config structure as follows: -\begin{itemize} -\item If VIRTIO_NET_RSS_HASH_TYPE_TCPv6 is set and the packet has -a TCPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv6 is set and the -packet has a UDPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\item Source UDP port -\item Destination UDP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_IPv6 is set, the hash is -calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\end{itemize} -\item Else the device does not calculate the hash -\end{itemize} - -The device calculates the hash on IPv6 packets with extension -headers according to the field \field{hash_types} of the virtio_net_rss_config structure as follows: -\begin{itemize} -\item If VIRTIO_NET_RSS_HASH_TYPE_TCP_EX is set and the packet -has a TCPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. -\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDP_EX is set and the -packet has a UDPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. -\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. -\item Source UDP port -\item Destination UDP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_IP_EX is set, the hash is -calculated over the following fields: -\begin{itemize} -\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address. -\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address. -\end{itemize} -\item Else skip IPv6 extension headers and calculate the hash as -defined for an IPv6 packet without extension headers (see \ref{itm:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers}). -\end{itemize} +Fields \field{hash_key_length} and \field{hash_key_data} define the key to be used in hash calculation. \drivernormative{\subparagraph}{Setting RSS parameters}{Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) }@@ -4093,12 +4204,12 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi A driver MUST use \field{indirection_table_mask} values that are less than \field{rss_max_indirection_table_length} reported by a device. -A driver MUST NOT set any VIRTIO_NET_RSS_HASH_TYPE_ flags that are not supported by a device. +A driver MUST NOT set any VIRTIO_NET_HASH_TYPE_ flags that are not supported by a device. \devicenormative{\subparagraph}{RSS processing}{Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS processing} The device MUST determine the destination queue for a network packet as follows: \begin{itemize} -\item Calculate the hash of the packet as defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types} +\item Calculate the hash of the packet as defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}. \item If the device did not calculate the hash for the specific packet, the device directs the packet to the receiveq specified by \field{unclassified_queue} of virtio_net_rss_config structure (value of 0 corresponds to receiveq1). \item Apply \field{indirection_table_mask} to the calculated hash and use the result as the index in the indirection table to get 0-based number of destination receiveq (value of 0 corresponds to receiveq1). \end{itemize}Signature · 1 line
2.17.1
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/
Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
----- Original Message -----
Quoted 104 lines
From: "Michael S. Tsirkin" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: [email protected]
Sent: Wednesday, February 19, 2020 11:12:40 AM
Subject: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureQuoted 96 lines · Yuri Benditovich
Fixes: https://github.com/oasis-tcs/virtio-spec/issues/66
Define respective feature bit for virtio-net. Extend packet layout to populate hash value and type. Move the definition of IP/TCP/UDP header fields to calculate the hash out of RSS section to common network device section.Signed-off-by Yuri Benditovich <[email protected]>---
content.tex | 347 ++++++++++++++++++++++++++++++++++------------------1 file changed, 229 insertions(+), 118 deletions(-)content.tex +0
-0@@ -2895,6 +2895,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_HASH_REPORT(57)] Device can report per-packet hash
+ value and a type of calculated hash.
+
\item[VIRTIO_NET_F_GUEST_HDRLEN(59)] Driver can provide the exact \field{hdr_len}
value. Device benefits from knowing the exact header length.content.tex +0
-0@@ -2995,35 +2998,17 @@ \subsection{Device configurationlayout}\label{sec:Device Types / Network Device
le32supported_hash_types;
};
\end{lstlisting}
-\label{sec:Device Types / Network Device / Device configuration layout / RSS}
-Three following fields, \field{rss_max_key_size}, \field{rss_max_indirection_table_length}content.tex +1
-1-and \field{supported_hash_types} only exist if VIRTIO_NET_F_RSS is set. +The following field, \field{rss_max_key_size} only exist if
VIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORTis set.content.tex +1
-1+It specifies the maximal supported length of RSS key in bytes. -Field \field{rss_max_key_size} specifies the maximal supported length ofRSS key in bytes.
+The following field, \field{rss_max_indirection_table_length} only exist ifVIRTIO_NET_F_RSSis set.
+It specifies the maximal number of 16-bit entries in RSS indirection table.-Field \field{rss_max_indirection_table_length} specifies the maximal number of 16-bit entries in RSS indirection table.
+The next field, \field{supported_hash_types} exists only if the device supports hash calculation,content.tex +1
-1+i.e. if VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT is set. -Field \field{supported_hash_types} contains the bitmask of supported RSShash types.
content.tex +0
-20- -Hash types applicable for IPv4 packets: -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) -#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) -\end{lstlisting} -Hash types applicable for IPv6 packets without extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) -#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) -\end{lstlisting} -Hash types applicable for IPv6 packets with extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) -#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) -#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) -\end{lstlisting} -For the exact meaning of VIRTIO_NET_RSS_HASH_TYPE_ flags see\ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}. +Field \field{supported_hash_types} contains the bitmask of supported hash types.
+See \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types} for details of supported hash types.\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Network Device / Device configuration layout}
content.tex +0
-0@@ -3048,7 +3033,7 @@ \subsection{Device configurationlayout}\label{sec:Device Types / Network Device
negotiated.The device MUST set \field{rss_max_key_size} to at least 40, if it offers
content.tex +1
-1-VIRTIO_NET_F_RSS. +VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT.
Quoted 15 lines
Quoted 11 lines
The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers
VIRTIO_NET_F_RSS.content.tex +0
-0@@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types/ Network Device / Device O
le16csum_start;
le16csum_offset;
le16num_buffers;
+ le32hash_value; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
+ le16hash_type; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated) };Just noticed this - it's a bit problematic as it might force compilers to add 2 bytes of padding at the end. Let's add extra 2 bytes of padding explicitly?
OK, no problem
Quoted 230 lines
Quoted 230 lines
\end{lstlisting}
content.tex +0
-0@@ -3517,6 +3504,12 @@ \subsubsection{Processing of IncomingPackets}\label{sec:Device Types / Network
\end{enumerate}
+If applicable, the device calculates per-packet hash for incoming packets as
+defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}.content.tex +3
-0+ +If applicable, the device reports hash information for incoming packets as +defined in \ref{sec:Device Types / Network Device / Device Operation /Processing of Incoming Packets / Hash reporting for incoming packets}. +
\devicenormative{\paragraph}{Processing of Incoming Packets}{Device Types / Network Device / Device Operation / Processing of Incoming Packets} \label{devicenormative:Device Types / Network Device / Device Operation / Processing of Packets}%old label for latexdiffcontent.tex +0
-0@@ -3619,6 +3612,181 @@ \subsubsection{Processing of IncomingPackets}\label{sec:Device Types / Network
If neitherVIRTIO_NET_HDR_F_NEEDS_CSUMnorVIRTIO_NET_HDR_F_DATA_VALIDis set, the driver MUST NOT
rely on the packet checksum being correct.
+
+\paragraph{Hash calculation for incoming packets} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}content.tex +4
-0+ +A device attempts to calculate a per-packet hash in the following cases: +\begin{itemize} +\item The feature VIRTIO_NET_F_RSS was negotiated. The device uses thehash to determine the receive virtqueue to place incoming packets. +\item The feature
VIRTIO_NET_F_HASH_REPORTwas negotiated. The device reports the hash value and the hash type with the packet. +\end{itemize}content.tex +4
-0+ +If the feature VIRTIO_NET_F_RSS was negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the virtio_net_rss_configstructure as 'Enabled hash types' bitmask.
+\item The device uses a key as defined in \field{hash_key_data} and \field{hash_key_length} of thevirtio_net_rss_configstructure (see +\ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}). +\end{itemize}content.tex +4
-0+ +If the feature VIRTIO_NET_F_RSS was not negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the virtio_net_hash_configstructure as 'Enabled hash types' bitmask.
+\item The device uses a key as defined in \field{hash_key_data} and \field{hash_key_length} of thevirtio_net_hash_configstructure (see +\ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}).
+\end{itemize}content.tex +2
-0+ +Note that if the device offers VIRTIO_NET_F_HASH_REPORT, even if itsupports only one pair of virtqueues, it MUST support
+at least one of commands ofVIRTIO_NET_CTRL_MQclass to configure reported hash parameters:
+\begin{itemize}
+\item If the device offersVIRTIO_NET_F_RSS, it MUST supportVIRTIO_NET_CTRL_MQ_RSS_CONFIGcommand per
+ \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}. +\item Otherwise the device MUST supportVIRTIO_NET_CTRL_MQ_HASH_CONFIGcommand per
+ \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}.
+\end{itemize}
+
+\subparagraph{Supported/enabled hash types}
+\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types}content.tex +21
-0+Hash types applicable for IPv4 packets: +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv4 (1 << 0) +#define VIRTIO_NET_HASH_TYPE_TCPv4 (1 << 1) +#define VIRTIO_NET_HASH_TYPE_UDPv4 (1 << 2) +\end{lstlisting} +Hash types applicable for IPv6 packets without extension headers +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv6 (1 << 3) +#define VIRTIO_NET_HASH_TYPE_TCPv6 (1 << 4) +#define VIRTIO_NET_HASH_TYPE_UDPv6 (1 << 5) +\end{lstlisting} +Hash types applicable for IPv6 packets with extension headers +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IP_EX (1 << 6) +#define VIRTIO_NET_HASH_TYPE_TCP_EX (1 << 7) +#define VIRTIO_NET_HASH_TYPE_UDP_EX (1 << 8) +\end{lstlisting} + +\subparagraph{IPv4 packets} +\label{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets / IPv4 packets}
+The device calculates the hash on IPv4 packets according to 'Enabled hash types' bitmask as follows:
+\begin{itemize}
+\item IfVIRTIO_NET_HASH_TYPE_TCPv4is set and the packet hascontent.tex +26
-0+a TCP header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv4 is set and the +packet has a UDP header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\item Source UDP port +\item Destination UDP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_IPv4 is set, the hash is +calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\end{itemize} +\item Else the device does not calculate the hash +\end{itemize} + +\subparagraph{IPv6 packets without extension header} +\label{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header}
content.tex +13
-0+The device calculates the hash on IPv6 packets without extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCPv6 is set and the packet has +a TCPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv6 is set and the +packet has a UDPv6 header, the hash is calculated over the followingfields:
+\begin{itemize}
+\item Source IPv6 address
+\item Destination IPv6 address
+\item Source UDP port
+\item Destination UDP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_IPv6is set, the hash iscontent.tex +10
-0+calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\end{itemize} +\item Else the device does not calculate the hash +\end{itemize} + +\subparagraph{IPv6 packets with extension header} +\label{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets / IPv6 packets with extension header}
content.tex +7
-0+The device calculates the hash on IPv6 packets with extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCP_EX is set and the packet +has a TCPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Home address from the home address option in the IPv6 destinationoptions header. If the extension header is not present, use the Source IPv6 address.
+\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
+\item Source TCP port
+\item Destination TCP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_UDP_EXis set and the +packet has a UDPv6 header, the hash is calculated over the following fields:
+\begin{itemize}
+\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
+\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
+\item Source UDP port
+\item Destination UDP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_IP_EXis set, the hash is +calculated over the following fields:
+\begin{itemize}
+\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
+\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
+\end{itemize}
+\item Else skip IPv6 extension headers and calculate the hash ascontent.tex +2
-0+defined for an IPv6 packet without extension headers +(see \ref{sec:Device Types / Network Device / Device Operation /Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header}).
+\end{itemize}
+
+\paragraph{Hash reporting for incoming packets} +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash reporting for incoming packets}content.tex +3
-0+ +If VIRTIO_NET_F_HASH_REPORT was negotiated and + the device has calculated the hash for the packet, the device fills\field{hash_type} with the type of calculated hash
content.tex +4
-0+and \field{hash_value} with the value of calculated hash. + +If VIRTIO_NET_F_HASH_REPORT was negotiated but due to any reason the +hash was not calculated, the device sets \field{hash_type} to
VIRTIO_NET_HASH_REPORT_NONE.content.tex +2
-0+ +Possible values that the device can report in \field{hash_type} aredefined below.
+They correspond to supported hash types defined in +\ref{sec:Device Types / Network Device / Device Operation / Processing of
Quoted 8 lines
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network · line 3775
Quoted 5 lines
Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types}
content.tex +3
-0+as follows: + +VIRTIO_NET_HASH_TYPE_XXX = 1 << (VIRTIO_NET_HASH_REPORT_XXX - 1)So
hash_typeis theHASH_REPORTvalue then? That's quite confusing. Let's rename tohash_report?
No problem to rename anything, but I'd like to do it one time. Currently meaningful hash report values are (1..9), 0 for none They correspond to bitmask of 9 bits for enabled/supported. It was possible to use the same definitions for enable/support/report but then reported kind of hash should be 4 bytes.
As you anyway suggests padding at the end of the packet, we can do that, i.e. add (32 bit hash + 32 bit type)
Or if we stay with the values as they are now:
values 0..9 - VIRTIO_NET_WHAT?
bits from 0 to 8 - VIRTIO_NET_WHAT?
Quoted 276 lines
Quoted 252 lines
content.tex +14
-0+ +\begin{lstlisting} +#define VIRTIO_NET_HASH_REPORT_NONE 0 +#define VIRTIO_NET_HASH_REPORT_IPv4 1 +#define VIRTIO_NET_HASH_REPORT_TCPv4 2 +#define VIRTIO_NET_HASH_REPORT_UDPv4 3 +#define VIRTIO_NET_HASH_REPORT_IPv6 4 +#define VIRTIO_NET_HASH_REPORT_TCPv6 5 +#define VIRTIO_NET_HASH_REPORT_UDPv6 6 +#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 +#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 +#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 +\end{lstlisting} +\subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue}
The driver uses the control virtqueue (if
VIRTIO_NET_F_CTRL_VQiscontent.tex +0
-0@@ -3896,6 +4064,7 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
#defineVIRTIO_NET_CTRL_MQ4
#defineVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET0 (for automatic receive steering) #defineVIRTIO_NET_CTRL_MQ_RSS_CONFIG1 (for configurable receive steering)
+ #defineVIRTIO_NET_CTRL_MQ_HASH_CONFIG2 (for configurable hash calculation)
\end{lstlisting}If more than one multiqueue mode is negotiated, the resulting device configuration is defined by the last command sent by the driver.
content.tex +0
-0@@ -3961,10 +4130,37 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
according to the native endian of the guest rather than (necessarily when not using the legacy interface) little-endian.+\subparagraph{Hash calculation}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}
+IfVIRTIO_NET_F_HASH_REPORTwas negotiated and the device uses automatic receive steering,
+the device MUST support a command to configure hash calculation parameters.content.tex +4
-0+ +The driver provides parameters for hash calculation as follows: + +\field{class} VIRTIO_NET_CTRL_MQ, \field{command}
VIRTIO_NET_CTRL_MQ_HASH_CONFIG.content.tex +13
-0+ +The \field{command-specific-data} has following format: +\begin{lstlisting} +struct virtio_net_hash_config { + le32 hash_types; + le16 reserved[4]; + u8 hash_key_length; + u8 hash_key_data[hash_key_length]; +}; +\end{lstlisting} +Field \field{hash_types} contains a bitmask of allowed hash types as +defined in +\ref{sec:Device Types / Network Device / Device Operation / Processing ofIncoming Packets / Hash calculation for incoming packets / Supported/enabled hash types}.
+Initially the device has all hash types disabled and reports onlyVIRTIO_NET_HASH_REPORT_NONE.content.tex +2
-0+ +Field \field{reserved} MUST contain zeroes. It is defined to make thestructure to match the layout of
virtio_net_rss_configstructure, +defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS)}.content.tex +2
-0+ +Fields \field{hash_key_length} and \field{hash_key_data} define the key tobe used in hash calculation.
+
\paragraph{Receive-side scaling (RSS)}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS)}
A device offers the featureVIRTIO_NET_F_RSSif it supports RSS receive steering with Toeplitz hash calculation and configurable parameters.-A driver queries RSS capabilities of the device by reading device configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout / RSS}
+A driver queries RSS capabilities of the device by reading device configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout}\subparagraph{Setting RSS parameters}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}
content.tex +0
-0@@ -3981,7 +4177,8 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
};
\end{lstlisting}
Field \field{hash_types} contains a bitmask of allowed hash types as -defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}. +defined in
+\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types}.Field \field{indirection_table_mask} is a mask to be applied to the calculated hash to produce an index in the
content.tex +0
-0@@ -3995,93 +4192,7 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
A driver sets \field{max_tx_vq} to inform a device how many transmit virtqueues it may use (transmitq1\ldots transmitq \field{max_tx_vq}).
-\subparagraph{RSS hash types}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}
content.tex +0
-3- -The device calculates the hash on IPv4 packets according to the -field \field{hash_types} of the virtio_net_rss_config structure asfollows:
-\begin{itemize}
-\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv4is set and the packet hascontent.tex +0
-25-a TCP header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv4 is set and the -packet has a UDP header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\item Source UDP port -\item Destination UDP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_IPv4 is set, the hash is -calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\end{itemize} -\item Else the device does not calculate the hash -\end{itemize} - -\label{itm:Device Types / Network Device / Device Operation / ControlVirtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers}
content.tex +0
-2-The device calculates the hash on IPv6 packets without extension -headers according to the field \field{hash_types} of the
virtio_net_rss_configstructure as follows:
-\begin{itemize}
-\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv6is set and the packet hascontent.tex +0
-9-a TCPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv6 is set and the -packet has a UDPv6 header, the hash is calculated over the followingfields:
-\begin{itemize}
-\item Source IPv6 address
-\item Destination IPv6 address
-\item Source UDP port
-\item Destination UDP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv6is set, the hash iscontent.tex +0
-10-calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\end{itemize} -\item Else the device does not calculate the hash -\end{itemize} - -The device calculates the hash on IPv6 packets with extension -headers according to the field \field{hash_types} of the
virtio_net_rss_configstructure as follows:
-\begin{itemize}
-\item IfVIRTIO_NET_RSS_HASH_TYPE_TCP_EXis set and the packet -has a TCPv6 header, the hash is calculated over the following fields:
-\begin{itemize}
-\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
-\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
-\item Source TCP port
-\item Destination TCP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDP_EXis set and the -packet has a UDPv6 header, the hash is calculated over the following fields:
-\begin{itemize}
-\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
-\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
-\item Source UDP port
-\item Destination UDP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IP_EXis set, the hash is -calculated over the following fields:
-\begin{itemize}
-\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
-\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
-\end{itemize}
-\item Else skip IPv6 extension headers and calculate the hash as -defined for an IPv6 packet without extension headers (see \ref{itm:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers}).
-\end{itemize}
+Fields \field{hash_key_length} and \field{hash_key_data} define the key to be used in hash calculation.\drivernormative{\subparagraph}{Setting RSS parameters}{Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) }
content.tex +0
-0@@ -4093,12 +4204,12 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
A driver MUST use \field{indirection_table_mask} values that are less than \field{rss_max_indirection_table_length} reported by a device.
-A driver MUST NOT set any
VIRTIO_NET_RSS_HASH_TYPE_flags that are not supported by a device.
+A driver MUST NOT set anyVIRTIO_NET_HASH_TYPE_flags that are not supported by a device.\devicenormative{\subparagraph}{RSS processing}{Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS processing}
The device MUST determine the destination queue for a network packet as follows:
\begin{itemize}
-\item Calculate the hash of the packet as defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}
+\item Calculate the hash of the packet as defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}.
\item If the device did not calculate the hash for the specific packet, the device directs the packet to the receiveq specified byQuoted 8 lines
\field{unclassified_queue} of
virtio_net_rss_configstructure (value of 0 corresponds to receiveq1).
\item Apply \field{indirection_table_mask} to the calculated hash and use the result as the index in the indirection table to get 0-based number of destination receiveq (value of 0 corresponds to receiveq1). \end{itemize}
--
2.17.1This 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/
Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
Quoted 371 lines · Yuri Benditovich
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
From: "Michael S. Tsirkin" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: [email protected]
Sent: Wednesday, February 19, 2020 11:12:40 AM
Subject: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureOn Wed, Feb 19, 2020 at 09:53:37AM +0200, Yuri Benditovich wrote:
> Fixes: https://github.com/oasis-tcs/virtio-spec/issues/66
> Define respective feature bit for virtio-net.
> Extend packet layout to populate hash value and type.
> Move the definition of IP/TCP/UDP header fields to
> calculate the hash out of RSS section to common network
> device section.
>
> Signed-off-by: Yuri Benditovich <[email protected]> > ---
> content.tex | 347 ++++++++++++++++++++++++++++++++++------------------ > 1 file changed, 229 insertions(+), 118 deletions(-)
>
> diff --git a/content.tex b/content.tex
> index b91a132..d7d4e42 100644
> --- a/content.tex
> +++ b/content.tex
> @@ -2895,6 +2895,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_HASH_REPORT(57)] Device can report per-packet hash
> + value and a type of calculated hash.
> +
> \item[VIRTIO_NET_F_GUEST_HDRLEN(59)] Driver can provide the exact \field {hdr_len}
> value. Device benefits from knowing the exact header length.
>
> @@ -2995,35 +2998,17 @@ \subsection{Device configuration layout}\label {sec:Device Types / Network Device
> le32supported_hash_types;
> };
> \end{lstlisting}
> -\label{sec:Device Types / Network Device / Device configuration layout / RSS}
> -Three following fields, \field{rss_max_key_size}, \field {rss_max_indirection_table_length}
> -and \field{supported_hash_types} only exist ifVIRTIO_NET_F_RSSis set. > +The following field, \field{rss_max_key_size} only exist ifVIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORTis set.
> +It specifies the maximal supported length of RSS key in bytes. >
> -Field \field{rss_max_key_size} specifies the maximal supported length of RSS key in bytes.
> +The following field, \field{rss_max_indirection_table_length} only exist ifVIRTIO_NET_F_RSSis set.
> +It specifies the maximal number of 16-bit entries in RSS indirection table.
>
> -Field \field{rss_max_indirection_table_length} specifies the maximal number of 16-bit entries in RSS indirection table.
> +The next field, \field{supported_hash_types} exists only if the device supports hash calculation,
> +i.e. ifVIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORTis set. >
> -Field \field{supported_hash_types} contains the bitmask of supported RSS hash types.
> -
> -Hash types applicable for IPv4 packets:
> -\begin{lstlisting}
> -#defineVIRTIO_NET_RSS_HASH_TYPE_IPv4(1 << 0)
> -#defineVIRTIO_NET_RSS_HASH_TYPE_TCPv4(1 << 1)
> -#defineVIRTIO_NET_RSS_HASH_TYPE_UDPv4(1 << 2)
> -\end{lstlisting}
> -Hash types applicable for IPv6 packets without extension headers > -\begin{lstlisting}
> -#defineVIRTIO_NET_RSS_HASH_TYPE_IPv6(1 << 3)
> -#defineVIRTIO_NET_RSS_HASH_TYPE_TCPv6(1 << 4)
> -#defineVIRTIO_NET_RSS_HASH_TYPE_UDPv6(1 << 5)
> -\end{lstlisting}
> -Hash types applicable for IPv6 packets with extension headers > -\begin{lstlisting}
> -#defineVIRTIO_NET_RSS_HASH_TYPE_IP_EX(1 << 6)
> -#defineVIRTIO_NET_RSS_HASH_TYPE_TCP_EX(1 << 7)
> -#defineVIRTIO_NET_RSS_HASH_TYPE_UDP_EX(1 << 8)
> -\end{lstlisting}
> -For the exact meaning ofVIRTIO_NET_RSS_HASH_TYPE_flags see \ref {sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}.
> +Field \field{supported_hash_types} contains the bitmask of supported hash types.
> +See \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types} for details of supported hash types. >
> \devicenormative{\subsubsection}{Device configuration layout}{Device Types / Network Device / Device configuration layout}
>
> @@ -3048,7 +3033,7 @@ \subsection{Device configuration layout}\label {sec:Device Types / Network Device
> negotiated.
>
> The device MUST set \field{rss_max_key_size} to at least 40, if it offers
> -VIRTIO_NET_F_RSS.
> +VIRTIO_NET_F_RSS orVIRTIO_NET_F_HASH_REPORT.
>
> The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers
>VIRTIO_NET_F_RSS.
> @@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O
> le16csum_start;
> le16csum_offset;
> le16num_buffers;
> + le32hash_value; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
> + le16hash_type; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
> };Just noticed this - it's a bit problematic as it might force compilers to add 2 bytes of padding at the end. Let's add extra 2 bytes of padding explicitly?
OK, no problem
Review \subsubsection{Processing of Incoming Packets}\
Quoted 3 lines
\end{lstlisting}
(quoted diff) +0
-0@@ -3517,6 +3504,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
>
> \end{enumerate}
>
> +If applicable, the device calculates per-packet hash for incoming packets as
> +defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}. > +
> +If applicable, the device reports hash information for incoming packets as
> +defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash reporting for incoming packets}. > +
> \devicenormative{\paragraph}{Processing of Incoming Packets}{Device Types / Network Device / Device Operation / Processing of Incoming Packets} > \label{devicenormative:Device Types / Network Device / Device Operation / Processing of Packets}%old label for latexdiff
>
> @@ -3619,6 +3612,181 @@ \subsubsection{Processing of Incoming Packets}\
label{sec:Device Types / Network
> If neitherVIRTIO_NET_HDR_F_NEEDS_CSUMnor
>VIRTIO_NET_HDR_F_DATA_VALIDis set, the driver MUST NOT
> rely on the packet checksum being correct.
> +
> +\paragraph{Hash calculation for incoming packets}
> +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}
> +
> +A device attempts to calculate a per-packet hash in the following cases:
> +\begin{itemize}
> +\item The featureVIRTIO_NET_F_RSSwas negotiated. The device uses the hash to determine the receive virtqueue to place incoming packets. > +\item The featureVIRTIO_NET_F_HASH_REPORTwas negotiated. The device reports the hash value and the hash type with the packet.
> +\end{itemize}
> +
> +If the featureVIRTIO_NET_F_RSSwas negotiated:
> +\begin{itemize}
> +\item The device uses \field{hash_types} of thevirtio_net_rss_configstructure as 'Enabled hash types' bitmask.
> +\item The device uses a key as defined in \field{hash_key_data} and \
field{hash_key_length} of thevirtio_net_rss_configstructure (see > +\ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}). > +\end{itemize}
> +
> +If the featureVIRTIO_NET_F_RSSwas not negotiated:
> +\begin{itemize}
> +\item The device uses \field{hash_types} of thevirtio_net_hash_configstructure as 'Enabled hash types' bitmask.
> +\item The device uses a key as defined in \field{hash_key_data} and \
field{hash_key_length} of thevirtio_net_hash_configstructure (see > +\ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}).
> +\end{itemize}
> +
> +Note that if the device offersVIRTIO_NET_F_HASH_REPORT, even if it supports only one pair of virtqueues, it MUST support
> +at least one of commands ofVIRTIO_NET_CTRL_MQclass to configure reported hash parameters:
> +\begin{itemize}
> +\item If the device offersVIRTIO_NET_F_RSS, it MUST supportVIRTIO_NET_CTRL_MQ_RSS_CONFIGcommand per
> + \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}. > +\item Otherwise the device MUST supportVIRTIO_NET_CTRL_MQ_HASH_CONFIGcommand per
> + \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}.
> +\end{itemize}
> +
> +\subparagraph{Supported/enabled hash types}
> +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/ enabled hash types}
> +Hash types applicable for IPv4 packets:
> +\begin{lstlisting}
> +#defineVIRTIO_NET_HASH_TYPE_IPv4(1 << 0)
> +#defineVIRTIO_NET_HASH_TYPE_TCPv4(1 << 1)
> +#defineVIRTIO_NET_HASH_TYPE_UDPv4(1 << 2)
> +\end{lstlisting}
> +Hash types applicable for IPv6 packets without extension headers > +\begin{lstlisting}
> +#defineVIRTIO_NET_HASH_TYPE_IPv6(1 << 3)
> +#defineVIRTIO_NET_HASH_TYPE_TCPv6(1 << 4)
> +#defineVIRTIO_NET_HASH_TYPE_UDPv6(1 << 5)
> +\end{lstlisting}
> +Hash types applicable for IPv6 packets with extension headers > +\begin{lstlisting}
> +#defineVIRTIO_NET_HASH_TYPE_IP_EX(1 << 6)
> +#defineVIRTIO_NET_HASH_TYPE_TCP_EX(1 << 7)
> +#defineVIRTIO_NET_HASH_TYPE_UDP_EX(1 << 8)
> +\end{lstlisting}
> +
> +\subparagraph{IPv4 packets}
> +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv4 packets} > +The device calculates the hash on IPv4 packets according to 'Enabled hash types' bitmask as follows:
> +\begin{itemize}
> +\item IfVIRTIO_NET_HASH_TYPE_TCPv4is set and the packet has > +a TCP header, the hash is calculated over the following fields:
> +\begin{itemize}
> +\item Source IP address
> +\item Destination IP address
> +\item Source TCP port
> +\item Destination TCP port
> +\end{itemize}
> +\item Else ifVIRTIO_NET_HASH_TYPE_UDPv4is set and the
> +packet has a UDP header, the hash is calculated over the following fields:
> +\begin{itemize}
> +\item Source IP address
> +\item Destination IP address
> +\item Source UDP port
> +\item Destination UDP port
> +\end{itemize}
> +\item Else ifVIRTIO_NET_HASH_TYPE_IPv4is set, the hash is > +calculated over the following fields:
> +\begin{itemize}
> +\item Source IP address
> +\item Destination IP address
> +\end{itemize}
> +\item Else the device does not calculate the hash
> +\end{itemize}
> +
> +\subparagraph{IPv6 packets without extension header}
> +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header}
> +The device calculates the hash on IPv6 packets without extension > +headers according to 'Enabled hash types' bitmask as follows:
> +\begin{itemize}
> +\item IfVIRTIO_NET_HASH_TYPE_TCPv6is set and the packet has > +a TCPv6 header, the hash is calculated over the following fields:
> +\begin{itemize}
> +\item Source IPv6 address
> +\item Destination IPv6 address
> +\item Source TCP port
> +\item Destination TCP port
> +\end{itemize}
> +\item Else ifVIRTIO_NET_HASH_TYPE_UDPv6is set and the
> +packet has a UDPv6 header, the hash is calculated over the following fields:
> +\begin{itemize}
> +\item Source IPv6 address
> +\item Destination IPv6 address
> +\item Source UDP port
> +\item Destination UDP port
> +\end{itemize}
> +\item Else ifVIRTIO_NET_HASH_TYPE_IPv6is set, the hash is > +calculated over the following fields:
> +\begin{itemize}
> +\item Source IPv6 address
> +\item Destination IPv6 address
> +\end{itemize}
> +\item Else the device does not calculate the hash
> +\end{itemize}
> +
> +\subparagraph{IPv6 packets with extension header}
> +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets with extension header}
> +The device calculates the hash on IPv6 packets with extension > +headers according to 'Enabled hash types' bitmask as follows:
> +\begin{itemize}
> +\item IfVIRTIO_NET_HASH_TYPE_TCP_EXis set and the packet > +has a TCPv6 header, the hash is calculated over the following fields:
> +\begin{itemize}
> +\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
> +\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
> +\item Source TCP port
> +\item Destination TCP port
> +\end{itemize}
> +\item Else ifVIRTIO_NET_HASH_TYPE_UDP_EXis set and the
> +packet has a UDPv6 header, the hash is calculated over the following fields:
> +\begin{itemize}
> +\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
> +\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
> +\item Source UDP port
> +\item Destination UDP port
> +\end{itemize}
> +\item Else ifVIRTIO_NET_HASH_TYPE_IP_EXis set, the hash is > +calculated over the following fields:
> +\begin{itemize}
> +\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
> +\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
> +\end{itemize}
> +\item Else skip IPv6 extension headers and calculate the hash as > +defined for an IPv6 packet without extension headers
> +(see \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header}).
> +\end{itemize}
> +
> +\paragraph{Hash reporting for incoming packets}
> +\label{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash reporting for incoming packets}
> +
> +IfVIRTIO_NET_F_HASH_REPORTwas negotiated and
> + the device has calculated the hash for the packet, the device fills \
field{hash_type} with the type of calculated hash
> +and \field{hash_value} with the value of calculated hash.
> +
> +IfVIRTIO_NET_F_HASH_REPORTwas negotiated but due to any reason the > +hash was not calculated, the device sets \field{hash_type} toVIRTIO_NET_HASH_REPORT_NONE.
> +
> +Possible values that the device can report in \field{hash_type} are defined below.
> +They correspond to supported hash types defined in
> +\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/ enabled hash types}
> +as follows:
> +
> +VIRTIO_NET_HASH_TYPE_XXX = 1 << (VIRTIO_NET_HASH_REPORT_XXX- 1)So
hash_typeis theHASH_REPORTvalue then? That's quite confusing. Let's rename tohash_report?
Quoted 7 lines
No problem to rename anything, but I'd like to do it one time. Currently meaningful hash report values are (1..9), 0 for none They correspond to bitmask of 9 bits for enabled/supported. It was possible to use the same definitions for enable/support/report but then reported kind of hash should be 4 bytes.
As you anyway suggests padding at the end of the packet, we can do that, i.e. add (32 bit hash + 32 bit type)
We can but it seems like a waste, does it not? padding can be used for something later ...
Quoted 2 lines
Or if we stay with the values as they are now:
values 0..9 -VIRTIO_NET_WHAT?
I thought that's VIRTIO_NET_HASH_REPORT_XXX
Quoted 1 line
bits from 0 to 8 -
VIRTIO_NET_WHAT?
and this one VIRTIO_NET_HASH_TYPE_XXX?
Generally what you did here is a bit unusual. Mostly we just define bit numbers
#define VIRTIO_SCSI_F_INOUT 0 #define VIRTIO_SCSI_F_HOTPLUG 1 #define VIRTIO_SCSI_F_CHANGE 2 #define VIRTIO_SCSI_F_T10_PI 3
and just say that bit numbers are from this table, with bit 0 corresponding to the value 0, bit 1 to value 1 etc.
maybe that would have been easier on the eyes - I didn't try, I'm not even sure.
But what you have is correct enough, we can always try to improve the wording later.
Quoted 273 lines
Quoted 7 lines
content.tex +5
-0+ +\begin{lstlisting} +#define VIRTIO_NET_HASH_REPORT_NONE 0 +#define VIRTIO_NET_HASH_REPORT_IPv4 1 +#define VIRTIO_NET_HASH_REPORT_TCPv4 2content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 10 lines
content.tex +9
-0+#define VIRTIO_NET_HASH_REPORT_UDPv4 3 +#define VIRTIO_NET_HASH_REPORT_IPv6 4 +#define VIRTIO_NET_HASH_REPORT_TCPv6 5 +#define VIRTIO_NET_HASH_REPORT_UDPv6 6 +#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 +#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 +#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 +\end{lstlisting} + \subsubsection{Control Virtqueue}\label{sec:Device Types / NetworkDevice / Device Operation / Control Virtqueue}
>
> The driver uses the control virtqueue (ifVIRTIO_NET_F_CTRL_VQis > @@ -3896,6 +4064,7 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
> #defineVIRTIO_NET_CTRL_MQ4
> #defineVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET0 (for automatic receive
steering)
> #defineVIRTIO_NET_CTRL_MQ_RSS_CONFIG1 (for configurable
receive steering)
> + #defineVIRTIO_NET_CTRL_MQ_HASH_CONFIG2 (for configurable hash
calculation)
> \end{lstlisting}
>
> If more than one multiqueue mode is negotiated, the resulting device configuration is defined by the last command sent by the driver. > @@ -3961,10 +4130,37 @@ \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. >
> +\subparagraph{Hash calculation}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}
> +IfVIRTIO_NET_F_HASH_REPORTwas negotiated and the device uses automatic receive steering,
> +the device MUST support a command to configure hash calculation parameters.
> +
> +The driver provides parameters for hash calculation as follows:
> +
> +\field{class}VIRTIO_NET_CTRL_MQ, \field{command}VIRTIO_NET_CTRL_MQ_HASH_CONFIG.
> +
> +The \field{command-specific-data} has following format:
> +\begin{lstlisting}
> +structvirtio_net_hash_config{
> + le32hash_types;
> + le16 reserved[4];
> + u8hash_key_length;
> + u8 hash_key_data[hash_key_length];
> +};
> +\end{lstlisting}
> +Field \field{hash_types} contains a bitmask of allowed hash types as > +defined in
> +\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/ enabled hash types}.
> +Initially the device has all hash types disabled and reports onlyVIRTIO_NET_HASH_REPORT_NONE.
> +
> +Field \field{reserved} MUST contain zeroes. It is defined to make the structure to match the layout ofvirtio_net_rss_configstructure, > +defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS)}.
> +
> +Fields \field{hash_key_length} and \field{hash_key_data} define the key to be used in hash calculation.
> +
> \paragraph{Receive-side scaling (RSS)}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS)} > A device offers the featureVIRTIO_NET_F_RSSif it supports RSS receive steering with Toeplitz hash calculation and configurable parameters. >
> -A driver queries RSS capabilities of the device by reading device configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout / RSS}
> +A driver queries RSS capabilities of the device by reading device configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout}
>
> \subparagraph{Setting RSS parameters}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}
>
> @@ -3981,7 +4177,8 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
> };
> \end{lstlisting}
> Field \field{hash_types} contains a bitmask of allowed hash types as > -defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}. > +defined in
> +\ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets / Supported/ enabled hash types}.
>
> Field \field{indirection_table_mask} is a mask to be applied to > the calculated hash to produce an index in the
> @@ -3995,93 +4192,7 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
>
> A driver sets \field{max_tx_vq} to inform a device how many transmit virtqueues it may use (transmitq1\ldots transmitq \field{max_tx_vq}). >
> -\subparagraph{RSS hash types}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}
> -
> -The device calculates the hash on IPv4 packets according to the > -field \field{hash_types} of thevirtio_net_rss_configstructure as follows:
> -\begin{itemize}
> -\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv4is set and the packet has > -a TCP header, the hash is calculated over the following fields:
> -\begin{itemize}
> -\item Source IP address
> -\item Destination IP address
> -\item Source TCP port
> -\item Destination TCP port
> -\end{itemize}
> -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDPv4is set and the > -packet has a UDP header, the hash is calculated over the following fields:
> -\begin{itemize}
> -\item Source IP address
> -\item Destination IP address
> -\item Source UDP port
> -\item Destination UDP port
> -\end{itemize}
> -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv4is set, the hash is > -calculated over the following fields:
> -\begin{itemize}
> -\item Source IP address
> -\item Destination IP address
> -\end{itemize}
> -\item Else the device does not calculate the hash
> -\end{itemize}
> -
> -\label{itm:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers}
> -The device calculates the hash on IPv6 packets without extension > -headers according to the field \field{hash_types} of thevirtio_net_rss_configstructure as follows:
> -\begin{itemize}
> -\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv6is set and the packet has > -a TCPv6 header, the hash is calculated over the following fields:
> -\begin{itemize}
> -\item Source IPv6 address
> -\item Destination IPv6 address
> -\item Source TCP port
> -\item Destination TCP port
> -\end{itemize}
> -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDPv6is set and the > -packet has a UDPv6 header, the hash is calculated over the following fields:
> -\begin{itemize}
> -\item Source IPv6 address
> -\item Destination IPv6 address
> -\item Source UDP port
> -\item Destination UDP port
> -\end{itemize}
> -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv6is set, the hash is > -calculated over the following fields:
> -\begin{itemize}
> -\item Source IPv6 address
> -\item Destination IPv6 address
> -\end{itemize}
> -\item Else the device does not calculate the hash
> -\end{itemize}
> -
> -The device calculates the hash on IPv6 packets with extension > -headers according to the field \field{hash_types} of thevirtio_net_rss_configstructure as follows:
> -\begin{itemize}
> -\item IfVIRTIO_NET_RSS_HASH_TYPE_TCP_EXis set and the packet > -has a TCPv6 header, the hash is calculated over the following fields:
> -\begin{itemize}
> -\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
> -\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
> -\item Source TCP port
> -\item Destination TCP port
> -\end{itemize}
> -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDP_EXis set and the > -packet has a UDPv6 header, the hash is calculated over the following fields:
> -\begin{itemize}
> -\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
> -\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
> -\item Source UDP port
> -\item Destination UDP port
> -\end{itemize}
> -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IP_EXis set, the hash is > -calculated over the following fields:
> -\begin{itemize}
> -\item Home address from the home address option in the IPv6 destination options header. If the extension header is not present, use the Source IPv6 address.
> -\item IPv6 address that is contained in the Routing-Header-Type-2 from the associated extension header. If the extension header is not present, use the Destination IPv6 address.
> -\end{itemize}
> -\item Else skip IPv6 extension headers and calculate the hash as > -defined for an IPv6 packet without extension headers (see \ref {itm:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers}).
> -\end{itemize}
> +Fields \field{hash_key_length} and \field{hash_key_data} define the key to be used in hash calculation.
>
> \drivernormative{\subparagraph}{Setting RSS parameters}{Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) }
>
> @@ -4093,12 +4204,12 @@ \subsubsection{Control Virtqueue}\label {sec:Device Types / Network Device / Devi
>
> A driver MUST use \field{indirection_table_mask} values that are less than \field{rss_max_indirection_table_length} reported by a device. >
> -A driver MUST NOT set anyVIRTIO_NET_RSS_HASH_TYPE_flags that are not supported by a device.
> +A driver MUST NOT set anyVIRTIO_NET_HASH_TYPE_flags that are not supported by a device.
>
> \devicenormative{\subparagraph}{RSS processing}{Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS processing}
> The device MUST determine the destination queue for a network packet as follows:
> \begin{itemize}
> -\item Calculate the hash of the packet as defined in \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}
> +\item Calculate the hash of the packet as defined in \ref{sec:Device Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}.
> \item If the device did not calculate the hash for the specific packet, the device directs the packet to the receiveq specified by \field {unclassified_queue} ofvirtio_net_rss_configstructure (value of 0 corresponds to receiveq1).
> \item Apply \field{indirection_table_mask} to the calculated hash and use the result as the index in the indirection table to get 0-based number of destination receiveq (value of 0 corresponds to receiveq1). > \end{itemize}
> --
> 2.17.1This 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.
Quoted 12 lines
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/
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/
Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
----- Original Message -----
Quoted 388 lines
From: "Michael S. Tsirkin" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: "Yuri Benditovich" <[email protected]>, [email protected]
Sent: Wednesday, February 19, 2020 4:35:49 PM
Subject: Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureQuoted 371 lines · Yuri Benditovich
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
From: "Michael S. Tsirkin" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: [email protected]
Sent: Wednesday, February 19, 2020 11:12:40 AM
Subject: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featurecontent.tex \subsection{Feature bits}\label{sec:Device Types /
Quoted 17 lines · Yuri Benditovich
Fixes: https://github.com/oasis-tcs/virtio-spec/issues/66
Define respective feature bit for virtio-net. Extend packet layout to populate hash value and type. Move the definition of IP/TCP/UDP header fields to calculate the hash out of RSS section to common network device section.Signed-off-by Yuri Benditovich <[email protected]>---
content.tex | 347 ++++++++++++++++++++++++++++++++++------------------1 file changed, 229 insertions(+), 118 deletions(-)content.tex +0
-0@@ -2895,6 +2895,9 @@ \subsection{Feature bits}\label{sec:Device Types /Network Device / Feature bits
Quoted 7 lines
\item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control channel.
+\item[VIRTIO_NET_F_HASH_REPORT(57)] Device can report per-packet hash
+ value and a type of calculated hash.
+
\item[VIRTIO_NET_F_GUEST_HDRLEN(59)] Driver can provide the exact \field{
hdr_len}content.tex \subsection{Device configuration layout}\label
Quoted 3 lines
value. Device benefits from knowing the exact header length.
content.tex +0
-0@@ -2995,35 +2998,17 @@ \subsection{Device configuration layout}\label{sec:Device Types / Network Device
content.tex \subsection{Device configuration layout}\label{sec:Device Types / Network Device
Quoted 4 lines
content.tex +0
-1le32 supported_hash_types; }; \end{lstlisting} -\label{sec:Device Types / Network Device / Device configuration layout /RSS}
content.tex \subsection{Device configuration layout}\label · line 2999
Quoted 1 line
content.tex +0
-1-Three following fields, \field{rss_max_key_size}, \field{
rss_max_indirection_table_length}content.tex \subsection{Device configuration layout}\label · line 3001
Quoted 2 lines
content.tex +1
-1-and \field{supported_hash_types} only exist if VIRTIO_NET_F_RSS is set. +The following field, \field{rss_max_key_size} only exist if
VIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORTis set.content.tex \subsection{Device configuration layout}\label{sec:Device Types / Network Device
Quoted 3 lines
content.tex +1
-1+It specifies the maximal supported length of RSS key in bytes. -Field \field{rss_max_key_size} specifies the maximal supported length ofRSS key in bytes.
content.tex \subsection{Device configuration layout}\label · line 3004
Quoted 1 line
content.tex +1
-0+The following field, \field{rss_max_indirection_table_length} only existif
VIRTIO_NET_F_RSSis set.content.tex \subsection{Device configuration layout}\label · line 3005
Quoted 1 line
content.tex +1
-0+It specifies the maximal number of 16-bit entries in RSS indirectiontable.
content.tex \subsection{Device configuration layout}\label · line 3003
Quoted 2 lines
content.tex +0
-1-Field \field{rss_max_indirection_table_length} specifies the maximalnumber of 16-bit entries in RSS indirection table.
content.tex \subsection{Device configuration layout}\label · line 3006
Quoted 1 line
content.tex +1
-0+The next field, \field{supported_hash_types} exists only if the devicesupports hash calculation,
content.tex \subsection{Device configuration layout}\label{sec:Device Types / Network Device
Quoted 3 lines
content.tex +1
-1+i.e. if VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT is set. -Field \field{supported_hash_types} contains the bitmask of supported RSShash types.
Quoted 10 lines
content.tex +0
-10- -Hash types applicable for IPv4 packets: -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) -#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) -\end{lstlisting} -Hash types applicable for IPv6 packets without extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3)content.tex \subsection{Device configuration layout}\label{sec:Device Types / Network Device
Quoted 10 lines
content.tex +0
-10-#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) -\end{lstlisting} -Hash types applicable for IPv6 packets with extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) -#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) -#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) -\end{lstlisting} -For the exact meaning of VIRTIO_NET_RSS_HASH_TYPE_ flags see \ref{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}.
content.tex \subsection{Device configuration layout}\label · line 3009
Quoted 1 line
content.tex +1
-0+Field \field{supported_hash_types} contains the bitmask of supportedhash types.
content.tex \subsection{Device configuration layout}\label · line 3010
Quoted 1 line
content.tex +1
-0+See \ref{sec:Device Types / Network Device / Device Operation /Processing of Incoming Packets / Hash calculation for incoming packets / Supported/enabled hash types} for details of supported hash types.
Quoted 2 lines
\devicenormative{\subsubsection}{Device configuration layout}{Device
Types / Network Device / Device configuration layout}
content.tex \subsection{Device configuration layout}\label
Quoted 2 lines
content.tex +0
-0@@ -3048,7 +3033,7 @@ \subsection{Device configuration layout}\label{sec:Device Types / Network Device
Quoted 3 lines
negotiated.
The device MUST set \field{rss_max_key_size} to at least 40, if it
offers
Quoted 4 lines
content.tex +1
-1-VIRTIO_NET_F_RSS. +VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT.The device MUST set \field{rss_max_indirection_table_length} to at least
128, if it offers
content.tex \subsection{Device Operation}\label{sec:Device
Quoted 2 lines
VIRTIO_NET_F_RSS.content.tex +0
-0@@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:DeviceTypes / Network Device / Device O
content.tex \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O · line 3185
Quoted 6 lines
content.tex +2
-0le16 csum_start; le16 csum_offset; le16 num_buffers; + le32 hash_value; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) + le16 hash_type; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) };Just noticed this - it's a bit problematic as it might force compilers to add 2 bytes of padding at the end. Let's add extra 2 bytes of padding explicitly?
OK, no problem
content.tex \subsubsection{Processing of Incoming Packets}\
Quoted 3 lines
content.tex +0
-0\end{lstlisting}@@ -3517,6 +3504,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 4 lines
content.tex +1
-0\end{enumerate} +If applicable, the device calculates per-packet hash for incomingpackets as
content.tex \subsubsection{Processing of Incoming Packets}\ · line 3507
Quoted 1 line
content.tex +1
-0+defined in \ref{sec:Device Types / Network Device / Device Operation /Processing of Incoming Packets / Hash calculation for incoming packets}.
content.tex \subsubsection{Processing of Incoming Packets}\ · line 3509
Quoted 2 lines
content.tex +2
-0+ +If applicable, the device reports hash information for incoming packetsas
content.tex \subsubsection{Processing of Incoming Packets}\ · line 3510
Quoted 1 line
content.tex +1
-0+defined in \ref{sec:Device Types / Network Device / Device Operation /Processing of Incoming Packets / Hash reporting for incoming packets}.
Quoted 2 lines
content.tex +1
-0+\devicenormative{\paragraph}{Processing of Incoming Packets}{Device
Types / Network Device / Device Operation / Processing of Incoming Packets}
Quoted 1 line
\label{devicenormative:Device Types / Network Device / Device Operation
/ Processing of Packets}%old label for latexdiff
content.tex \subsubsection{Processing of Incoming Packets}\
Quoted 2 lines
content.tex +0
-0@@ -3619,6 +3612,181 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 6 lines
If neither
VIRTIO_NET_HDR_F_NEEDS_CSUMnorVIRTIO_NET_HDR_F_DATA_VALIDis set, the driver MUST NOT
rely on the packet checksum being correct.
+
+\paragraph{Hash calculation for incoming packets} +\label{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets}
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 4 lines
content.tex +4
-0+ +A device attempts to calculate a per-packet hash in the following cases: +\begin{itemize} +\item The feature VIRTIO_NET_F_RSS was negotiated. The device uses thehash to determine the receive virtqueue to place incoming packets.
Quoted 1 line
+\item The feature
VIRTIO_NET_F_HASH_REPORTwas negotiated. The devicereports the hash value and the hash type with the packet.
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 5 lines
+\end{itemize}
content.tex +4
-0+ +If the feature VIRTIO_NET_F_RSS was negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the virtio_net_rss_configstructure as 'Enabled hash types' bitmask.
Quoted 1 line
+\item The device uses a key as defined in \field{hash_key_data} and \
field{hash_key_length} of the
virtio_net_rss_configstructure (seeQuoted 1 line
+\ref{sec:Device Types / Network Device / Device Operation / Control
Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}).
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 5 lines
+\end{itemize}
content.tex +4
-0+ +If the feature VIRTIO_NET_F_RSS was not negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the virtio_net_hash_configstructure as 'Enabled hash types' bitmask.
Quoted 1 line
+\item The device uses a key as defined in \field{hash_key_data} and \
field{hash_key_length} of the
virtio_net_hash_configstructure (seeQuoted 1 line
+\ref{sec:Device Types / Network Device / Device Operation / Control
Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}).
content.tex
Quoted 3 lines
+\end{itemize}
content.tex +2
-0+ +Note that if the device offers VIRTIO_NET_F_HASH_REPORT, even if itsupports only one pair of virtqueues, it MUST support
Quoted 1 line
+at least one of commands of
VIRTIO_NET_CTRL_MQclass to configurereported hash parameters:
Quoted 2 lines
+\begin{itemize}
+\item If the device offersVIRTIO_NET_F_RSS, it MUST support
VIRTIO_NET_CTRL_MQ_RSS_CONFIGcommand perQuoted 1 line
+ \ref{sec:Device Types / Network Device / Device Operation / Control
Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}.
Quoted 1 line
+\item Otherwise the device MUST support
VIRTIO_NET_CTRL_MQ_HASH_CONFIGcommand per
Quoted 1 line
+ \ref{sec:Device Types / Network Device / Device Operation / Control
Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}.
Quoted 4 lines
+\end{itemize}
+
+\subparagraph{Supported/enabled hash types} +\label{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets / Supported/ enabled hash types}
Quoted 11 lines
content.tex +11
-0+Hash types applicable for IPv4 packets: +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv4 (1 << 0) +#define VIRTIO_NET_HASH_TYPE_TCPv4 (1 << 1) +#define VIRTIO_NET_HASH_TYPE_UDPv4 (1 << 2) +\end{lstlisting} +Hash types applicable for IPv6 packets without extension headers +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv6 (1 << 3) +#define VIRTIO_NET_HASH_TYPE_TCPv6 (1 << 4) +#define VIRTIO_NET_HASH_TYPE_UDPv6 (1 << 5)content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 10 lines
content.tex +10
-0+\end{lstlisting} +Hash types applicable for IPv6 packets with extension headers +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IP_EX (1 << 6) +#define VIRTIO_NET_HASH_TYPE_TCP_EX (1 << 7) +#define VIRTIO_NET_HASH_TYPE_UDP_EX (1 << 8) +\end{lstlisting} + +\subparagraph{IPv4 packets} +\label{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets / IPv4 packets}
Quoted 1 line
+The device calculates the hash on IPv4 packets according to 'Enabled
hash types' bitmask as follows:
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 11 lines
+\begin{itemize}
+\item IfVIRTIO_NET_HASH_TYPE_TCPv4is set and the packet hascontent.tex +9
-0+a TCP header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv4 is set and the +packet has a UDP header, the hash is calculated over the followingfields:
Quoted 7 lines
+\begin{itemize}
+\item Source IP address
+\item Destination IP address
+\item Source UDP port
+\item Destination UDP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_IPv4is set, the hash iscontent.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 10 lines
content.tex +10
-0+calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\end{itemize} +\item Else the device does not calculate the hash +\end{itemize} + +\subparagraph{IPv6 packets without extension header} +\label{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header}
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 13 lines
content.tex +13
-0+The device calculates the hash on IPv6 packets without extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCPv6 is set and the packet has +a TCPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv6 is set and the +packet has a UDPv6 header, the hash is calculated over the followingfields:
Quoted 7 lines
+\begin{itemize}
+\item Source IPv6 address
+\item Destination IPv6 address
+\item Source UDP port
+\item Destination UDP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_IPv6is set, the hash iscontent.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 10 lines
content.tex +10
-0+calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\end{itemize} +\item Else the device does not calculate the hash +\end{itemize} + +\subparagraph{IPv6 packets with extension header} +\label{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets / IPv6 packets with extension header}
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 7 lines
content.tex +7
-0+The device calculates the hash on IPv6 packets with extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCP_EX is set and the packet +has a TCPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Home address from the home address option in the IPv6 destinationoptions header. If the extension header is not present, use the Source IPv6 address.
Quoted 1 line
+\item IPv6 address that is contained in the Routing-Header-Type-2 from
the associated extension header. If the extension header is not present, use the Destination IPv6 address.
Quoted 5 lines
+\item Source TCP port
+\item Destination TCP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_UDP_EXis set and the +packet has a UDPv6 header, the hash is calculated over the followingfields:
Quoted 2 lines
+\begin{itemize}
+\item Home address from the home address option in the IPv6 destinationoptions header. If the extension header is not present, use the Source IPv6 address.
Quoted 1 line
+\item IPv6 address that is contained in the Routing-Header-Type-2 from
the associated extension header. If the extension header is not present, use the Destination IPv6 address.
Quoted 7 lines
+\item Source UDP port
+\item Destination UDP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_IP_EXis set, the hash is +calculated over the following fields:
+\begin{itemize}
+\item Home address from the home address option in the IPv6 destinationoptions header. If the extension header is not present, use the Source IPv6 address.
Quoted 1 line
+\item IPv6 address that is contained in the Routing-Header-Type-2 from
the associated extension header. If the extension header is not present, use the Destination IPv6 address.
content.tex
Quoted 4 lines
+\end{itemize}
+\item Else skip IPv6 extension headers and calculate the hash ascontent.tex +2
-0+defined for an IPv6 packet without extension headers +(see \ref{sec:Device Types / Network Device / Device Operation /Processing of Incoming Packets / Hash calculation for incoming packets / IPv6 packets without extension header}).
Quoted 4 lines
+\end{itemize}
+
+\paragraph{Hash reporting for incoming packets} +\label{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash reporting for incoming packets}
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 3 lines
content.tex +3
-0+ +If VIRTIO_NET_F_HASH_REPORT was negotiated and + the device has calculated the hash for the packet, the device fills \field{hash_type} with the type of calculated hash
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 4 lines
content.tex +4
-0+and \field{hash_value} with the value of calculated hash. + +If VIRTIO_NET_F_HASH_REPORT was negotiated but due to any reason the +hash was not calculated, the device sets \field{hash_type} to
VIRTIO_NET_HASH_REPORT_NONE.content.tex
Quoted 2 lines
content.tex +2
-0+ +Possible values that the device can report in \field{hash_type} aredefined below.
Quoted 2 lines
+They correspond to supported hash types defined in +\ref{sec:Device Types / Network Device / Device Operation / Processing
of Incoming Packets / Hash calculation for incoming packets / Supported/ enabled hash types}
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network · line 3775
Quoted 3 lines
content.tex +3
-0+as follows: + +VIRTIO_NET_HASH_TYPE_XXX = 1 << (VIRTIO_NET_HASH_REPORT_XXX - 1)So
hash_typeis theHASH_REPORTvalue then? That's quite confusing. Let's rename tohash_report?Quoted 7 lines
No problem to rename anything, but I'd like to do it one time. Currently meaningful hash report values are (1..9), 0 for none They correspond to bitmask of 9 bits for enabled/supported. It was possible to use the same definitions for enable/support/report but then reported kind of hash should be 4 bytes.
As you anyway suggests padding at the end of the packet, we can do that, i.e. add (32 bit hash + 32 bit type)
Quoted 7 lines
We can but it seems like a waste, does it not? padding can be used for something later ...
Quoted 2 lines
Or if we stay with the values as they are now:
values 0..9 -VIRTIO_NET_WHAT?I thought that's
VIRTIO_NET_HASH_REPORT_XXX
OK, this is exactly what is defined
Quoted 3 lines
Quoted 1 line
bits from 0 to 8 -
VIRTIO_NET_WHAT?and this one
VIRTIO_NET_HASH_TYPE_XXX?
OK, this is also exactly what is defined
Quoted 6 lines
Generally what you did here is a bit unusual. Mostly we just define bit numbers
#defineVIRTIO_SCSI_F_INOUT0
#defineVIRTIO_SCSI_F_HOTPLUG1
#defineVIRTIO_SCSI_F_CHANGE2
#defineVIRTIO_SCSI_F_T10_PI3
Value 0 of hash_report is "no hash calculated" and it does not participate in support/enable mask. I did not want to use value other than zero for "no hash".
So you want bit 0 to be reserved (not used) in enable/support mask and then to have all the VIRTIO_NET_HASH_TYPE_XXX to be exactly 1 << VIRTIO_NET_HASH_REPORT_XXX? Just say...
Quoted 294 lines
and just say that bit numbers are from this table, with bit 0 corresponding to the value 0, bit 1 to value 1 etc.
maybe that would have been easier on the eyes - I didn't try, I'm not even sure.
But what you have is correct enough, we can always try to improve the wording later.
Quoted 285 lines
Quoted 16 lines
content.tex +14
-0+ +\begin{lstlisting} +#define VIRTIO_NET_HASH_REPORT_NONE 0 +#define VIRTIO_NET_HASH_REPORT_IPv4 1 +#define VIRTIO_NET_HASH_REPORT_TCPv4 2 +#define VIRTIO_NET_HASH_REPORT_UDPv4 3 +#define VIRTIO_NET_HASH_REPORT_IPv6 4 +#define VIRTIO_NET_HASH_REPORT_TCPv6 5 +#define VIRTIO_NET_HASH_REPORT_UDPv6 6 +#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 +#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 +#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 +\end{lstlisting} +Quoted 1 line
\subsubsection{Control Virtqueue}\label{sec:Device Types / Network
Device / Device Operation / Control Virtqueue}
content.tex \subsubsection{Control Virtqueue}\label{sec:Device
Quoted 3 lines
The driver uses the control virtqueue (if
VIRTIO_NET_F_CTRL_VQiscontent.tex +0
-0@@ -3896,6 +4064,7 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
content.tex \subsubsection{Control Virtqueue}\label{sec:Device · line 4065
Quoted 2 lines
content.tex +0
-0#define VIRTIO_NET_CTRL_MQ 4 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 (for automatic receivesteering)
content.tex \subsubsection{Control Virtqueue}\label{sec:Device · line 4066
Quoted 1 line
content.tex +0
-0#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 (for configurablereceive steering)
content.tex \subsubsection{Control Virtqueue}\label{sec:Device · line 4067
Quoted 1 line
content.tex +1
-0+ #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 (for configurable hashcalculation)
Quoted 3 lines
content.tex +0
-0\end{lstlisting}If more than one multiqueue mode is negotiated, the resulting device
configuration is defined by the last command sent by the driver.
content.tex \subsubsection{Control Virtqueue}\label
Quoted 1 line
content.tex +0
-0@@ -3961,10 +4130,37 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 4 lines
according to the native endian of the guest rather than (necessarily when not using the legacy interface) little-endian.
+\subparagraph{Hash calculation}\label{sec:Device Types / Network Device
/ Device Operation / Control Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}
Quoted 1 line
+If
VIRTIO_NET_F_HASH_REPORTwas negotiated and the device uses automaticreceive steering,
Quoted 1 line
+the device MUST support a command to configure hash calculation
parameters.
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 4 lines
content.tex +4
-0+ +The driver provides parameters for hash calculation as follows: + +\field{class} VIRTIO_NET_CTRL_MQ, \field{command}
VIRTIO_NET_CTRL_MQ_HASH_CONFIG.content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 13 lines
content.tex +13
-0+ +The \field{command-specific-data} has following format: +\begin{lstlisting} +struct virtio_net_hash_config { + le32 hash_types; + le16 reserved[4]; + u8 hash_key_length; + u8 hash_key_data[hash_key_length]; +}; +\end{lstlisting} +Field \field{hash_types} contains a bitmask of allowed hash types as +defined in +\ref{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets / Supported/ enabled hash types}.
Quoted 1 line
+Initially the device has all hash types disabled and reports only
VIRTIO_NET_HASH_REPORT_NONE.content.tex
Quoted 2 lines
content.tex +2
-0+ +Field \field{reserved} MUST contain zeroes. It is defined to make thestructure to match the layout of
virtio_net_rss_configstructure,Quoted 1 line
+defined in \ref{sec:Device Types / Network Device / Device Operation /
Control Virtqueue / Receive-side scaling (RSS)}.
content.tex
Quoted 2 lines
content.tex +2
-0+ +Fields \field{hash_key_length} and \field{hash_key_data} define the keyto be used in hash calculation.
Quoted 2 lines
+
\paragraph{Receive-side scaling (RSS)}\label{sec:Device Types / NetworkDevice / Device Operation / Control Virtqueue / Receive-side scaling (RSS)}
Quoted 1 line
A device offers the feature
VIRTIO_NET_F_RSSif it supports RSS receivesteering with Toeplitz hash calculation and configurable parameters.
Quoted 2 lines
-A driver queries RSS capabilities of the device by reading device
configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout / RSS}
Quoted 1 line
+A driver queries RSS capabilities of the device by reading device
configuration as defined in \ref{sec:Device Types / Network Device / Device configuration layout}
Quoted 2 lines
\subparagraph{Setting RSS parameters}\label{sec:Device Types / Network
Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}
content.tex \subsubsection{Control Virtqueue}\label{sec:Device
Quoted 2 lines
content.tex +0
-0@@ -3981,7 +4177,8 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
Quoted 4 lines
content.tex +0
-0}; \end{lstlisting}Field \field{hash_types} contains a bitmask of allowed hash types as -defined in \ref{sec:Device Types / Network Device / Device Operation /
Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}.
Quoted 2 lines
+defined in
+\ref{sec:Device Types / Network Device / Device Operation / Processingof Incoming Packets / Hash calculation for incoming packets / Supported/ enabled hash types}.
content.tex \subsubsection{Control Virtqueue}\label{sec:Device
Quoted 4 lines
Field \field{indirection_table_mask} is a mask to be applied to the calculated hash to produce an index in the
content.tex +0
-0@@ -3995,93 +4192,7 @@ \subsubsection{Control Virtqueue}\label{sec:DeviceTypes / Network Device / Devi
Quoted 2 lines
A driver sets \field{max_tx_vq} to inform a device how many transmit
virtqueues it may use (transmitq1\ldots transmitq \field{max_tx_vq}).
Quoted 2 lines
-\subparagraph{RSS hash types}\label{sec:Device Types / Network Device /
Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 3 lines
content.tex +0
-3- -The device calculates the hash on IPv4 packets according to the -field \field{hash_types} of the virtio_net_rss_config structure asfollows:
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 11 lines
-\begin{itemize}
-\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv4is set and the packet hascontent.tex +0
-9-a TCP header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv4 is set and the -packet has a UDP header, the hash is calculated over the followingfields:
Quoted 7 lines
-\begin{itemize}
-\item Source IP address
-\item Destination IP address
-\item Source UDP port
-\item Destination UDP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv4is set, the hash iscontent.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 9 lines
content.tex +0
-9-calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\end{itemize} -\item Else the device does not calculate the hash -\end{itemize} - -\label{itm:Device Types / Network Device / Device Operation / ControlVirtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers}
content.tex
Quoted 2 lines
content.tex +0
-2-The device calculates the hash on IPv6 packets without extension -headers according to the field \field{hash_types} of the
virtio_net_rss_configstructure as follows:content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 11 lines
-\begin{itemize}
-\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv6is set and the packet hascontent.tex +0
-9-a TCPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv6 is set and the -packet has a UDPv6 header, the hash is calculated over the followingfields:
Quoted 7 lines
-\begin{itemize}
-\item Source IPv6 address
-\item Destination IPv6 address
-\item Source UDP port
-\item Destination UDP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv6is set, the hash iscontent.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 10 lines
content.tex +0
-10-calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\end{itemize} -\item Else the device does not calculate the hash -\end{itemize} - -The device calculates the hash on IPv6 packets with extension -headers according to the field \field{hash_types} of the
virtio_net_rss_configstructure as follows:Quoted 5 lines
-\begin{itemize}
-\item IfVIRTIO_NET_RSS_HASH_TYPE_TCP_EXis set and the packet -has a TCPv6 header, the hash is calculated over the following fields:
-\begin{itemize}
-\item Home address from the home address option in the IPv6 destinationoptions header. If the extension header is not present, use the Source IPv6 address.
Quoted 1 line
-\item IPv6 address that is contained in the Routing-Header-Type-2 from
the associated extension header. If the extension header is not present, use the Destination IPv6 address.
Quoted 5 lines
-\item Source TCP port
-\item Destination TCP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDP_EXis set and the -packet has a UDPv6 header, the hash is calculated over the followingfields:
Quoted 2 lines
-\begin{itemize}
-\item Home address from the home address option in the IPv6 destinationoptions header. If the extension header is not present, use the Source IPv6 address.
Quoted 1 line
-\item IPv6 address that is contained in the Routing-Header-Type-2 from
the associated extension header. If the extension header is not present, use the Destination IPv6 address.
Quoted 7 lines
-\item Source UDP port
-\item Destination UDP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IP_EXis set, the hash is -calculated over the following fields:
-\begin{itemize}
-\item Home address from the home address option in the IPv6 destinationoptions header. If the extension header is not present, use the Source IPv6 address.
Quoted 1 line
-\item IPv6 address that is contained in the Routing-Header-Type-2 from
the associated extension header. If the extension header is not present, use the Destination IPv6 address.
Quoted 3 lines
-\end{itemize}
-\item Else skip IPv6 extension headers and calculate the hash as -defined for an IPv6 packet without extension headers (see \ref{itm:Device Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers}).
Quoted 2 lines
-\end{itemize}
+Fields \field{hash_key_length} and \field{hash_key_data} define the keyto be used in hash calculation.
Quoted 2 lines
\drivernormative{\subparagraph}{Setting RSS parameters}{Device Types /
Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) }
content.tex \subsubsection{Control Virtqueue}\label
Quoted 2 lines
content.tex +0
-0@@ -4093,12 +4204,12 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 2 lines
A driver MUST use \field{indirection_table_mask} values that are less
than \field{rss_max_indirection_table_length} reported by a device.
Quoted 2 lines
-A driver MUST NOT set any
VIRTIO_NET_RSS_HASH_TYPE_flags that are notsupported by a device.
Quoted 1 line
+A driver MUST NOT set any
VIRTIO_NET_HASH_TYPE_flags that are notsupported by a device.
Quoted 2 lines
\devicenormative{\subparagraph}{RSS processing}{Device Types / Network
Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS processing}
Quoted 1 line
The device MUST determine the destination queue for a network packet as
follows:
Quoted 2 lines
\begin{itemize}
-\item Calculate the hash of the packet as defined in \ref{sec:DeviceTypes / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}
Quoted 1 line
+\item Calculate the hash of the packet as defined in \ref{sec:Device
Types / Network Device / Device Operation / Processing of Incoming Packets / Hash calculation for incoming packets}.
Quoted 1 line
\item If the device did not calculate the hash for the specific packet,
the device directs the packet to the receiveq specified by \field {
unclassified_queue} ofvirtio_net_rss_configstructure (value of 0 corresponds to receiveq1).Quoted 1 line
\item Apply \field{indirection_table_mask} to the calculated hash and
use the result as the index in the indirection table to get 0-based number of destination receiveq (value of 0 corresponds to receiveq1).
Quoted 3 lines
\end{itemize}
--
2.17.1This 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/
Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
Quoted 484 lines · Yuri Benditovich
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
From: "Michael S. Tsirkin" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: "Yuri Benditovich" <[email protected]>, [email protected]
Sent: Wednesday, February 19, 2020 4:35:49 PM
Subject: Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureOn Wed, Feb 19, 2020 at 06:07:13AM -0500, Yuri Benditovich wrote:
>
>
> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ >
> From: "Michael S. Tsirkin" <[email protected]>
> To: "Yuri Benditovich" <[email protected]>
> Cc: [email protected]
> Sent: Wednesday, February 19, 2020 11:12:40 AM
> Subject: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define
per-packet
> hash reporting feature
>
> On Wed, Feb 19, 2020 at 09:53:37AM +0200, Yuri Benditovich wrote:
> > Fixes: https://github.com/oasis-tcs/virtio-spec/issues/66
> > Define respective feature bit for virtio-net.
> > Extend packet layout to populate hash value and type.
> > Move the definition of IP/TCP/UDP header fields to
> > calculate the hash out of RSS section to common network
> > device section.
> >
> > Signed-off-by: Yuri Benditovich <[email protected]>
> > ---
> > content.tex | 347
++++++++++++++++++++++++++++++++++------------------
> > 1 file changed, 229 insertions(+), 118 deletions(-)
> >
> > diff --git a/content.tex b/content.tex
> > index b91a132..d7d4e42 100644
> > --- a/content.tex
> > +++ b/content.tex
> > @@ -2895,6 +2895,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_HASH_REPORT(57)] Device can report per-packet
hash
> > + value and a type of calculated hash.
> > +
> > \item[VIRTIO_NET_F_GUEST_HDRLEN(59)] Driver can provide the exact
\field
> {hdr_len}
> > value. Device benefits from knowing the exact header length.
> >
> > @@ -2995,35 +2998,17 @@ \subsection{Device configuration layout}\
label
> {sec:Device Types / Network Device
> > le32supported_hash_types;
> > };
> > \end{lstlisting}
> > -\label{sec:Device Types / Network Device / Device configuration
layout /
> RSS}
> > -Three following fields, \field{rss_max_key_size}, \field
> {rss_max_indirection_table_length}
> > -and \field{supported_hash_types} only exist ifVIRTIO_NET_F_RSSis
set.
> > +The following field, \field{rss_max_key_size} only exist if
>VIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORTis set.
> > +It specifies the maximal supported length of RSS key in bytes.
> >
> > -Field \field{rss_max_key_size} specifies the maximal supported
length of
> RSS key in bytes.
> > +The following field, \field{rss_max_indirection_table_length} only
exist
> ifVIRTIO_NET_F_RSSis set.
> > +It specifies the maximal number of 16-bit entries in RSS
indirection
> table.
> >
> > -Field \field{rss_max_indirection_table_length} specifies the
maximal
> number of 16-bit entries in RSS indirection table.
> > +The next field, \field{supported_hash_types} exists only if the
device
> supports hash calculation,
> > +i.e. ifVIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORTis set.
> >
> > -Field \field{supported_hash_types} contains the bitmask of
supported RSS
> hash types.
> > -
> > -Hash types applicable for IPv4 packets:
> > -\begin{lstlisting}
> > -#defineVIRTIO_NET_RSS_HASH_TYPE_IPv4(1 << 0)
> > -#defineVIRTIO_NET_RSS_HASH_TYPE_TCPv4(1 << 1)
> > -#defineVIRTIO_NET_RSS_HASH_TYPE_UDPv4(1 << 2)
> > -\end{lstlisting}
> > -Hash types applicable for IPv6 packets without extension headers
> > -\begin{lstlisting}
> > -#defineVIRTIO_NET_RSS_HASH_TYPE_IPv6(1 << 3)
> > -#defineVIRTIO_NET_RSS_HASH_TYPE_TCPv6(1 << 4)
> > -#defineVIRTIO_NET_RSS_HASH_TYPE_UDPv6(1 << 5)
> > -\end{lstlisting}
> > -Hash types applicable for IPv6 packets with extension headers
> > -\begin{lstlisting}
> > -#defineVIRTIO_NET_RSS_HASH_TYPE_IP_EX(1 << 6)
> > -#defineVIRTIO_NET_RSS_HASH_TYPE_TCP_EX(1 << 7)
> > -#defineVIRTIO_NET_RSS_HASH_TYPE_UDP_EX(1 << 8)
> > -\end{lstlisting}
> > -For the exact meaning ofVIRTIO_NET_RSS_HASH_TYPE_flags see \ref
> {sec:Device Types / Network Device / Device Operation / Control
Virtqueue /
> Receive-side scaling (RSS) / RSS hash types}.
> > +Field \field{supported_hash_types} contains the bitmask of
supported
> hash types.
> > +See \ref{sec:Device Types / Network Device / Device Operation /
> Processing of Incoming Packets / Hash calculation for incoming
packets /
> Supported/enabled hash types} for details of supported hash types.
> >
> > \devicenormative{\subsubsection}{Device configuration layout}
{Device
> Types / Network Device / Device configuration layout}
> >
> > @@ -3048,7 +3033,7 @@ \subsection{Device configuration layout}\
label
> {sec:Device Types / Network Device
> > negotiated.
> >
> > The device MUST set \field{rss_max_key_size} to at least 40, if it
> offers
> > -VIRTIO_NET_F_RSS.
> > +VIRTIO_NET_F_RSS orVIRTIO_NET_F_HASH_REPORT.
> >
> > The device MUST set \field{rss_max_indirection_table_length} to at
least
> 128, if it offers
> >VIRTIO_NET_F_RSS.
> > @@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label
{sec:Device
> Types / Network Device / Device O
> > le16csum_start;
> > le16csum_offset;
> > le16num_buffers;
> > + le32hash_value; (Only ifVIRTIO_NET_F_HASH_REPORT
negotiated)
> > + le16hash_type; (Only ifVIRTIO_NET_F_HASH_REPORT
negotiated)
> > };
>
> Just noticed this - it's a bit problematic as it might force
> compilers to add 2 bytes of padding at the end. Let's add extra 2
bytes
> of padding explicitly?
>
> OK, no problem
>
>
>
>
> > \end{lstlisting}
> >
> > @@ -3517,6 +3504,12 @@ \subsubsection{Processing of Incoming
Packets}\
> label{sec:Device Types / Network
> >
> > \end{enumerate}
> >
> > +If applicable, the device calculates per-packet hash for incoming
> packets as
> > +defined in \ref{sec:Device Types / Network Device / Device
Operation /
> Processing of Incoming Packets / Hash calculation for incoming
packets}.
> > +
> > +If applicable, the device reports hash information for incoming
packets
> as
> > +defined in \ref{sec:Device Types / Network Device / Device
Operation /
> Processing of Incoming Packets / Hash reporting for incoming
packets}.
> > +
> > \devicenormative{\paragraph}{Processing of Incoming Packets}
{Device
> Types / Network Device / Device Operation / Processing of Incoming
Packets}
> > \label{devicenormative:Device Types / Network Device / Device
Operation
> / Processing of Packets}%old label for latexdiff
> >
> > @@ -3619,6 +3612,181 @@ \subsubsection{Processing of Incoming
Packets}\
> label{sec:Device Types / Network
> > If neitherVIRTIO_NET_HDR_F_NEEDS_CSUMnor
> >VIRTIO_NET_HDR_F_DATA_VALIDis set, the driver MUST NOT
> > rely on the packet checksum being correct.
> > +
> > +\paragraph{Hash calculation for incoming packets}
> > +\label{sec:Device Types / Network Device / Device Operation /
Processing
> of Incoming Packets / Hash calculation for incoming packets}
> > +
> > +A device attempts to calculate a per-packet hash in the following
cases:
> > +\begin{itemize}
> > +\item The featureVIRTIO_NET_F_RSSwas negotiated. The device uses
the
> hash to determine the receive virtqueue to place incoming packets.
> > +\item The featureVIRTIO_NET_F_HASH_REPORTwas negotiated. The
device
> reports the hash value and the hash type with the packet.
> > +\end{itemize}
> > +
> > +If the featureVIRTIO_NET_F_RSSwas negotiated:
> > +\begin{itemize}
> > +\item The device uses \field{hash_types} of the
virtio_net_rss_config
> structure as 'Enabled hash types' bitmask.
> > +\item The device uses a key as defined in \field{hash_key_data}
and \
> field{hash_key_length} of thevirtio_net_rss_configstructure (see
> > +\ref{sec:Device Types / Network Device / Device Operation /
Control
> Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}).
> > +\end{itemize}
> > +
> > +If the featureVIRTIO_NET_F_RSSwas not negotiated:
> > +\begin{itemize}
> > +\item The device uses \field{hash_types} of the
virtio_net_hash_config
> structure as 'Enabled hash types' bitmask.
> > +\item The device uses a key as defined in \field{hash_key_data}
and \
> field{hash_key_length} of thevirtio_net_hash_configstructure (see
> > +\ref{sec:Device Types / Network Device / Device Operation /
Control
> Virtqueue / Automatic receive steering in multiqueue mode / Hash
> calculation}).
> > +\end{itemize}
> > +
> > +Note that if the device offersVIRTIO_NET_F_HASH_REPORT, even if
it
> supports only one pair of virtqueues, it MUST support
> > +at least one of commands ofVIRTIO_NET_CTRL_MQclass to configure
> reported hash parameters:
> > +\begin{itemize}
> > +\item If the device offersVIRTIO_NET_F_RSS, it MUST support
>VIRTIO_NET_CTRL_MQ_RSS_CONFIGcommand per
> > + \ref{sec:Device Types / Network Device / Device Operation /
Control
> Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}.
> > +\item Otherwise the device MUST support
VIRTIO_NET_CTRL_MQ_HASH_CONFIG
> command per
> > + \ref{sec:Device Types / Network Device / Device Operation /
Control
> Virtqueue / Automatic receive steering in multiqueue mode / Hash
> calculation}.
> > +\end{itemize}
> > +
> > +\subparagraph{Supported/enabled hash types}
> > +\label{sec:Device Types / Network Device / Device Operation /
Processing
> of Incoming Packets / Hash calculation for incoming packets /
Supported/
> enabled hash types}
> > +Hash types applicable for IPv4 packets:
> > +\begin{lstlisting}
> > +#defineVIRTIO_NET_HASH_TYPE_IPv4(1 << 0)
> > +#defineVIRTIO_NET_HASH_TYPE_TCPv4(1 << 1)
> > +#defineVIRTIO_NET_HASH_TYPE_UDPv4(1 << 2)
> > +\end{lstlisting}
> > +Hash types applicable for IPv6 packets without extension headers
> > +\begin{lstlisting}
> > +#defineVIRTIO_NET_HASH_TYPE_IPv6(1 << 3)
> > +#defineVIRTIO_NET_HASH_TYPE_TCPv6(1 << 4)
> > +#defineVIRTIO_NET_HASH_TYPE_UDPv6(1 << 5)
> > +\end{lstlisting}
> > +Hash types applicable for IPv6 packets with extension headers
> > +\begin{lstlisting}
> > +#defineVIRTIO_NET_HASH_TYPE_IP_EX(1 << 6)
> > +#defineVIRTIO_NET_HASH_TYPE_TCP_EX(1 << 7)
> > +#defineVIRTIO_NET_HASH_TYPE_UDP_EX(1 << 8)
> > +\end{lstlisting}
> > +
> > +\subparagraph{IPv4 packets}
> > +\label{sec:Device Types / Network Device / Device Operation /
Processing
> of Incoming Packets / Hash calculation for incoming packets / IPv4
packets}
> > +The device calculates the hash on IPv4 packets according to
'Enabled
> hash types' bitmask as follows:
> > +\begin{itemize}
> > +\item IfVIRTIO_NET_HASH_TYPE_TCPv4is set and the packet has
> > +a TCP header, the hash is calculated over the following fields:
> > +\begin{itemize}
> > +\item Source IP address
> > +\item Destination IP address
> > +\item Source TCP port
> > +\item Destination TCP port
> > +\end{itemize}
> > +\item Else ifVIRTIO_NET_HASH_TYPE_UDPv4is set and the
> > +packet has a UDP header, the hash is calculated over the following
> fields:
> > +\begin{itemize}
> > +\item Source IP address
> > +\item Destination IP address
> > +\item Source UDP port
> > +\item Destination UDP port
> > +\end{itemize}
> > +\item Else ifVIRTIO_NET_HASH_TYPE_IPv4is set, the hash is
> > +calculated over the following fields:
> > +\begin{itemize}
> > +\item Source IP address
> > +\item Destination IP address
> > +\end{itemize}
> > +\item Else the device does not calculate the hash
> > +\end{itemize}
> > +
> > +\subparagraph{IPv6 packets without extension header}
> > +\label{sec:Device Types / Network Device / Device Operation /
Processing
> of Incoming Packets / Hash calculation for incoming packets / IPv6
packets
> without extension header}
> > +The device calculates the hash on IPv6 packets without extension
> > +headers according to 'Enabled hash types' bitmask as follows:
> > +\begin{itemize}
> > +\item IfVIRTIO_NET_HASH_TYPE_TCPv6is set and the packet has
> > +a TCPv6 header, the hash is calculated over the following fields:
> > +\begin{itemize}
> > +\item Source IPv6 address
> > +\item Destination IPv6 address
> > +\item Source TCP port
> > +\item Destination TCP port
> > +\end{itemize}
> > +\item Else ifVIRTIO_NET_HASH_TYPE_UDPv6is set and the
> > +packet has a UDPv6 header, the hash is calculated over the
following
> fields:
> > +\begin{itemize}
> > +\item Source IPv6 address
> > +\item Destination IPv6 address
> > +\item Source UDP port
> > +\item Destination UDP port
> > +\end{itemize}
> > +\item Else ifVIRTIO_NET_HASH_TYPE_IPv6is set, the hash is
> > +calculated over the following fields:
> > +\begin{itemize}
> > +\item Source IPv6 address
> > +\item Destination IPv6 address
> > +\end{itemize}
> > +\item Else the device does not calculate the hash
> > +\end{itemize}
> > +
> > +\subparagraph{IPv6 packets with extension header}
> > +\label{sec:Device Types / Network Device / Device Operation /
Processing
> of Incoming Packets / Hash calculation for incoming packets / IPv6
packets
> with extension header}
> > +The device calculates the hash on IPv6 packets with extension
> > +headers according to 'Enabled hash types' bitmask as follows:
> > +\begin{itemize}
> > +\item IfVIRTIO_NET_HASH_TYPE_TCP_EXis set and the packet
> > +has a TCPv6 header, the hash is calculated over the following
fields:
> > +\begin{itemize}
> > +\item Home address from the home address option in the IPv6
destination
> options header. If the extension header is not present, use the
Source IPv6
> address.
> > +\item IPv6 address that is contained in the Routing-Header-Type-2
from
> the associated extension header. If the extension header is not
present,
> use the Destination IPv6 address.
> > +\item Source TCP port
> > +\item Destination TCP port
> > +\end{itemize}
> > +\item Else ifVIRTIO_NET_HASH_TYPE_UDP_EXis set and the
> > +packet has a UDPv6 header, the hash is calculated over the
following
> fields:
> > +\begin{itemize}
> > +\item Home address from the home address option in the IPv6
destination
> options header. If the extension header is not present, use the
Source IPv6
> address.
> > +\item IPv6 address that is contained in the Routing-Header-Type-2
from
> the associated extension header. If the extension header is not
present,
> use the Destination IPv6 address.
> > +\item Source UDP port
> > +\item Destination UDP port
> > +\end{itemize}
> > +\item Else ifVIRTIO_NET_HASH_TYPE_IP_EXis set, the hash is
> > +calculated over the following fields:
> > +\begin{itemize}
> > +\item Home address from the home address option in the IPv6
destination
> options header. If the extension header is not present, use the
Source IPv6
> address.
> > +\item IPv6 address that is contained in the Routing-Header-Type-2
from
> the associated extension header. If the extension header is not
present,
> use the Destination IPv6 address.
> > +\end{itemize}
> > +\item Else skip IPv6 extension headers and calculate the hash as
> > +defined for an IPv6 packet without extension headers
> > +(see \ref{sec:Device Types / Network Device / Device Operation /
> Processing of Incoming Packets / Hash calculation for incoming
packets /
> IPv6 packets without extension header}).
> > +\end{itemize}
> > +
> > +\paragraph{Hash reporting for incoming packets}
> > +\label{sec:Device Types / Network Device / Device Operation /
Processing
> of Incoming Packets / Hash reporting for incoming packets}
> > +
> > +IfVIRTIO_NET_F_HASH_REPORTwas negotiated and
> > + the device has calculated the hash for the packet, the device
fills \
> field{hash_type} with the type of calculated hash
> > +and \field{hash_value} with the value of calculated hash.
> > +
> > +IfVIRTIO_NET_F_HASH_REPORTwas negotiated but due to any reason
the
> > +hash was not calculated, the device sets \field{hash_type} to
>VIRTIO_NET_HASH_REPORT_NONE.
> > +
> > +Possible values that the device can report in \field{hash_type}
are
> defined below.
> > +They correspond to supported hash types defined in
> > +\ref{sec:Device Types / Network Device / Device Operation /
Processing
> of Incoming Packets / Hash calculation for incoming packets /
Supported/
> enabled hash types}
> > +as follows:
> > +
> > +VIRTIO_NET_HASH_TYPE_XXX = 1 << (VIRTIO_NET_HASH_REPORT_XXX- 1)
>
>
> Sohash_typeis theHASH_REPORTvalue then? That's quite confusing.
> Let's rename tohash_report?
>
> No problem to rename anything, but I'd like to do it one time.
> Currently meaningful hash report values are (1..9), 0 for none
> They correspond to bitmask of 9 bits for enabled/supported.
> It was possible to use the same definitions for enable/support/report > but then reported kind of hash should be 4 bytes.
> As you anyway suggests padding at the end of the packet, we can do that, > i.e. add (32 bit hash + 32 bit type)We can but it seems like a waste, does it not? padding can be used for something later ...
> Or if we stay with the values as they are now:
> values 0..9 -VIRTIO_NET_WHAT?I thought that's
VIRTIO_NET_HASH_REPORT_XXXOK, this is exactly what is defined
Quoted 7 lines
Quoted 1 line
bits from 0 to 8 -
VIRTIO_NET_WHAT?and this one
VIRTIO_NET_HASH_TYPE_XXX?OK, this is also exactly what is defined
Right I'm saying what's defined is fine, just call the fields consistently.
Quoted 10 lines
Generally what you did here is a bit unusual. Mostly we just define
bit numbers
#define VIRTIO_SCSI_F_INOUT 0
#define VIRTIO_SCSI_F_HOTPLUG 1
#define VIRTIO_SCSI_F_CHANGE 2
#define VIRTIO_SCSI_F_T10_PI 3Quoted 3 lines
Value 0 of
hash_reportis "no hash calculated" and it does not participate in support/enable mask. I did not want to use value other than zero for "no hash".
Oh right.
Quoted 4 lines
So you want bit 0 to be reserved (not used) in enable/support mask and then to have all the
VIRTIO_NET_HASH_TYPE_XXXto be exactly 1 <<VIRTIO_NET_HASH_REPORT_XXX? Just say...
We can do that too but it's up to you really.
So fixing the below you would say
bit 0 curresponding to value 1,
bit 1 corresponding to value 2 etc.
No bit corresponds to value 0
?
Quoted 346 lines
and just say that bit numbers are from this table, with bit 0 corresponding to the value 0, bit 1 to value 1 etc.
maybe that would have been easier on the eyes - I didn't try, I'm not even sure.
But what you have is correct enough, we can always try to improve the wording later.
>
>
> > +
> > +\begin{lstlisting}
> > +#defineVIRTIO_NET_HASH_REPORT_NONE0
> > +#defineVIRTIO_NET_HASH_REPORT_IPv41
> > +#defineVIRTIO_NET_HASH_REPORT_TCPv42
> > +#defineVIRTIO_NET_HASH_REPORT_UDPv43
> > +#defineVIRTIO_NET_HASH_REPORT_IPv64
> > +#defineVIRTIO_NET_HASH_REPORT_TCPv65
> > +#defineVIRTIO_NET_HASH_REPORT_UDPv66
> > +#defineVIRTIO_NET_HASH_REPORT_IPv6_EX7
> > +#defineVIRTIO_NET_HASH_REPORT_TCPv6_EX8
> > +#defineVIRTIO_NET_HASH_REPORT_UDPv6_EX9
> > +\end{lstlisting}
> > +
> > \subsubsection{Control Virtqueue}\label{sec:Device Types / Network
> Device / Device Operation / Control Virtqueue}
> >
> > The driver uses the control virtqueue (ifVIRTIO_NET_F_CTRL_VQis
> > @@ -3896,6 +4064,7 @@ \subsubsection{Control Virtqueue}\label
{sec:Device
> Types / Network Device / Devi
> > #defineVIRTIO_NET_CTRL_MQ4
> > #defineVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET0 (for automatic
receive
> steering)
> > #defineVIRTIO_NET_CTRL_MQ_RSS_CONFIG1 (for
configurable
> receive steering)
> > + #defineVIRTIO_NET_CTRL_MQ_HASH_CONFIG2 (for
configurable hash
> calculation)
> > \end{lstlisting}
> >
> > If more than one multiqueue mode is negotiated, the resulting
device
> configuration is defined by the last command sent by the driver.
> > @@ -3961,10 +4130,37 @@ \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.
> >
> > +\subparagraph{Hash calculation}\label{sec:Device Types / Network
Device
> / Device Operation / Control Virtqueue / Automatic receive steering
in
> multiqueue mode / Hash calculation}
> > +IfVIRTIO_NET_F_HASH_REPORTwas negotiated and the device uses
automatic
> receive steering,
> > +the device MUST support a command to configure hash calculation
> parameters.
> > +
> > +The driver provides parameters for hash calculation as follows:
> > +
> > +\field{class}VIRTIO_NET_CTRL_MQ, \field{command}
>VIRTIO_NET_CTRL_MQ_HASH_CONFIG.
> > +
> > +The \field{command-specific-data} has following format:
> > +\begin{lstlisting}
> > +structvirtio_net_hash_config{
> > + le32hash_types;
> > + le16 reserved[4];
> > + u8hash_key_length;
> > + u8 hash_key_data[hash_key_length];
> > +};
> > +\end{lstlisting}
> > +Field \field{hash_types} contains a bitmask of allowed hash types
as
> > +defined in
> > +\ref{sec:Device Types / Network Device / Device Operation /
Processing
> of Incoming Packets / Hash calculation for incoming packets /
Supported/
> enabled hash types}.
> > +Initially the device has all hash types disabled and reports only
>VIRTIO_NET_HASH_REPORT_NONE.
> > +
> > +Field \field{reserved} MUST contain zeroes. It is defined to make
the
> structure to match the layout ofvirtio_net_rss_configstructure,
> > +defined in \ref{sec:Device Types / Network Device / Device
Operation /
> Control Virtqueue / Receive-side scaling (RSS)}.
> > +
> > +Fields \field{hash_key_length} and \field{hash_key_data} define
the key
> to be used in hash calculation.
> > +
> > \paragraph{Receive-side scaling (RSS)}\label{sec:Device Types /
Network
> Device / Device Operation / Control Virtqueue / Receive-side scaling
(RSS)}
> > A device offers the featureVIRTIO_NET_F_RSSif it supports RSS
receive
> steering with Toeplitz hash calculation and configurable parameters.
> >
> > -A driver queries RSS capabilities of the device by reading device
> configuration as defined in \ref{sec:Device Types / Network Device /
Device
> configuration layout / RSS}
> > +A driver queries RSS capabilities of the device by reading device
> configuration as defined in \ref{sec:Device Types / Network Device /
Device
> configuration layout}
> >
> > \subparagraph{Setting RSS parameters}\label{sec:Device Types /
Network
> Device / Device Operation / Control Virtqueue / Receive-side scaling
(RSS)
> / Setting RSS parameters}
> >
> > @@ -3981,7 +4177,8 @@ \subsubsection{Control Virtqueue}\label
{sec:Device
> Types / Network Device / Devi
> > };
> > \end{lstlisting}
> > Field \field{hash_types} contains a bitmask of allowed hash types
as
> > -defined in \ref{sec:Device Types / Network Device / Device
Operation /
> Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}.
> > +defined in
> > +\ref{sec:Device Types / Network Device / Device Operation /
Processing
> of Incoming Packets / Hash calculation for incoming packets /
Supported/
> enabled hash types}.
> >
> > Field \field{indirection_table_mask} is a mask to be applied to
> > the calculated hash to produce an index in the
> > @@ -3995,93 +4192,7 @@ \subsubsection{Control Virtqueue}\label
{sec:Device
> Types / Network Device / Devi
> >
> > A driver sets \field{max_tx_vq} to inform a device how many
transmit
> virtqueues it may use (transmitq1\ldots transmitq \field{max_tx_vq}).
> >
> > -\subparagraph{RSS hash types}\label{sec:Device Types / Network
Device /
> Device Operation / Control Virtqueue / Receive-side scaling (RSS) /
RSS
> hash types}
> > -
> > -The device calculates the hash on IPv4 packets according to the
> > -field \field{hash_types} of thevirtio_net_rss_configstructure as
> follows:
> > -\begin{itemize}
> > -\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv4is set and the packet has
> > -a TCP header, the hash is calculated over the following fields:
> > -\begin{itemize}
> > -\item Source IP address
> > -\item Destination IP address
> > -\item Source TCP port
> > -\item Destination TCP port
> > -\end{itemize}
> > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDPv4is set and the
> > -packet has a UDP header, the hash is calculated over the following
> fields:
> > -\begin{itemize}
> > -\item Source IP address
> > -\item Destination IP address
> > -\item Source UDP port
> > -\item Destination UDP port
> > -\end{itemize}
> > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv4is set, the hash is
> > -calculated over the following fields:
> > -\begin{itemize}
> > -\item Source IP address
> > -\item Destination IP address
> > -\end{itemize}
> > -\item Else the device does not calculate the hash
> > -\end{itemize}
> > -
> > -\label{itm:Device Types / Network Device / Device Operation /
Control
> Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6
> packets without extension headers}
> > -The device calculates the hash on IPv6 packets without extension
> > -headers according to the field \field{hash_types} of the
>virtio_net_rss_configstructure as follows:
> > -\begin{itemize}
> > -\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv6is set and the packet has
> > -a TCPv6 header, the hash is calculated over the following fields:
> > -\begin{itemize}
> > -\item Source IPv6 address
> > -\item Destination IPv6 address
> > -\item Source TCP port
> > -\item Destination TCP port
> > -\end{itemize}
> > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDPv6is set and the
> > -packet has a UDPv6 header, the hash is calculated over the
following
> fields:
> > -\begin{itemize}
> > -\item Source IPv6 address
> > -\item Destination IPv6 address
> > -\item Source UDP port
> > -\item Destination UDP port
> > -\end{itemize}
> > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv6is set, the hash is
> > -calculated over the following fields:
> > -\begin{itemize}
> > -\item Source IPv6 address
> > -\item Destination IPv6 address
> > -\end{itemize}
> > -\item Else the device does not calculate the hash
> > -\end{itemize}
> > -
> > -The device calculates the hash on IPv6 packets with extension
> > -headers according to the field \field{hash_types} of the
>virtio_net_rss_configstructure as follows:
> > -\begin{itemize}
> > -\item IfVIRTIO_NET_RSS_HASH_TYPE_TCP_EXis set and the packet
> > -has a TCPv6 header, the hash is calculated over the following
fields:
> > -\begin{itemize}
> > -\item Home address from the home address option in the IPv6
destination
> options header. If the extension header is not present, use the
Source IPv6
> address.
> > -\item IPv6 address that is contained in the Routing-Header-Type-2
from
> the associated extension header. If the extension header is not
present,
> use the Destination IPv6 address.
> > -\item Source TCP port
> > -\item Destination TCP port
> > -\end{itemize}
> > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDP_EXis set and the
> > -packet has a UDPv6 header, the hash is calculated over the
following
> fields:
> > -\begin{itemize}
> > -\item Home address from the home address option in the IPv6
destination
> options header. If the extension header is not present, use the
Source IPv6
> address.
> > -\item IPv6 address that is contained in the Routing-Header-Type-2
from
> the associated extension header. If the extension header is not
present,
> use the Destination IPv6 address.
> > -\item Source UDP port
> > -\item Destination UDP port
> > -\end{itemize}
> > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IP_EXis set, the hash is
> > -calculated over the following fields:
> > -\begin{itemize}
> > -\item Home address from the home address option in the IPv6
destination
> options header. If the extension header is not present, use the
Source IPv6
> address.
> > -\item IPv6 address that is contained in the Routing-Header-Type-2
from
> the associated extension header. If the extension header is not
present,
> use the Destination IPv6 address.
> > -\end{itemize}
> > -\item Else skip IPv6 extension headers and calculate the hash as
> > -defined for an IPv6 packet without extension headers (see \ref
> {itm:Device Types / Network Device / Device Operation / Control
Virtqueue /
> Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets
without
> extension headers}).
> > -\end{itemize}
> > +Fields \field{hash_key_length} and \field{hash_key_data} define
the key
> to be used in hash calculation.
> >
> > \drivernormative{\subparagraph}{Setting RSS parameters}{Device
Types /
> Network Device / Device Operation / Control Virtqueue / Receive-side
> scaling (RSS) }
> >
> > @@ -4093,12 +4204,12 @@ \subsubsection{Control Virtqueue}\label
> {sec:Device Types / Network Device / Devi
> >
> > A driver MUST use \field{indirection_table_mask} values that are
less
> than \field{rss_max_indirection_table_length} reported by a device.
> >
> > -A driver MUST NOT set anyVIRTIO_NET_RSS_HASH_TYPE_flags that are
not
> supported by a device.
> > +A driver MUST NOT set anyVIRTIO_NET_HASH_TYPE_flags that are not
> supported by a device.
> >
> > \devicenormative{\subparagraph}{RSS processing}{Device Types /
Network
> Device / Device Operation / Control Virtqueue / Receive-side scaling
(RSS)
> / RSS processing}
> > The device MUST determine the destination queue for a network
packet as
> follows:
> > \begin{itemize}
> > -\item Calculate the hash of the packet as defined in \ref
{sec:Device
> Types / Network Device / Device Operation / Control Virtqueue /
> Receive-side scaling (RSS) / RSS hash types}
> > +\item Calculate the hash of the packet as defined in \ref
{sec:Device
> Types / Network Device / Device Operation / Processing of Incoming
Packets
> / Hash calculation for incoming packets}.
> > \item If the device did not calculate the hash for the specific
packet,
> the device directs the packet to the receiveq specified by \field
> {unclassified_queue} ofvirtio_net_rss_configstructure (value of 0
> corresponds to receiveq1).
> > \item Apply \field{indirection_table_mask} to the calculated hash
and
> use the result as the index in the indirection table to get 0-based
number
> of destination receiveq (value of 0 corresponds to receiveq1).
> > \end{itemize}
> > --
> > 2.17.1
>
>
> 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.
>
Quoted 16 lines
> 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/
>
>
>
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/
Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
----- Original Message -----
Quoted 525 lines
From: "Michael S. Tsirkin" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: "Yuri Benditovich" <[email protected]>, [email protected]
Sent: Wednesday, February 19, 2020 4:56:04 PM
Subject: Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureQuoted 484 lines · Yuri Benditovich
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
From: "Michael S. Tsirkin" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: "Yuri Benditovich" <[email protected]>, [email protected]
Sent: Wednesday, February 19, 2020 4:35:49 PM
Subject: Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureQuoted 3 lines · Yuri Benditovich
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Quoted 6 lines
From: "Michael S. Tsirkin" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: [email protected]
Sent: Wednesday, February 19, 2020 11:12:40 AM
Subject: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Defineper-packet
Quoted 13 lines
hash reporting feature
Quoted 10 lines · Yuri Benditovich
Fixes: https://github.com/oasis-tcs/virtio-spec/issues/66
Define respective feature bit for virtio-net. Extend packet layout to populate hash value and type. Move the definition of IP/TCP/UDP header fields to calculate the hash out of RSS section to common network device section.Signed-off-by Yuri Benditovich <[email protected]>---
content.tex | 347++++++++++++++++++++++++++++++++++------------------
Quoted 7 lines
content.tex \subsection{Feature bits}\label{sec:Device
Quoted 7 lines
1 file changed, 229 insertions(+), 118 deletions(-)content.tex +0
-0@@ -2895,6 +2895,9 @@ \subsection{Feature bits}\label{sec:DeviceTypes /
Quoted 2 lines
Network Device / Feature bits
Quoted 1 line
\item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through
control
Quoted 3 lines
Quoted 3 lines
channel.
+\item[VIRTIO_NET_F_HASH_REPORT(57)] Device can report per-packet
hash
Quoted 3 lines
Quoted 3 lines
+ value and a type of calculated hash.
+
\item[VIRTIO_NET_F_GUEST_HDRLEN(59)] Driver can provide the exact\field
Quoted 4 lines
{
hdr_len}content.tex \subsection{Device configuration layout}\
Quoted 3 lines
value. Device benefits from knowing the exact header length.
content.tex +0
-0@@ -2995,35 +2998,17 @@ \subsection{Device configuration layout}\label
Quoted 5 lines
{sec:Device Types / Network Device
Quoted 4 lines
content.tex +0
-1le32 supported_hash_types; }; \end{lstlisting} -\label{sec:Device Types / Network Device / Device configurationlayout /
Quoted 4 lines
RSS}
content.tex \subsection{Device configuration layout}\ · line 2999
Quoted 1 line
content.tex +0
-1-Three following fields, \field{rss_max_key_size}, \field{
rss_max_indirection_table_length}Quoted 1 line
content.tex +0
-1-and \field{supported_hash_types} only exist if VIRTIO_NET_F_RSS isset.
Quoted 5 lines
content.tex \subsection{Device configuration layout}\ · line 3001
Quoted 1 line
content.tex +1
-0+The following field, \field{rss_max_key_size} only exist if
VIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORTis set.content.tex \subsection{Device configuration layout}\label{sec:Device Types / Network Device
Quoted 3 lines
content.tex +1
-1+It specifies the maximal supported length of RSS key in bytes. -Field \field{rss_max_key_size} specifies the maximal supportedlength of
Quoted 2 lines
RSS key in bytes.
Quoted 1 line
content.tex +1
-0+The following field, \field{rss_max_indirection_table_length} onlyexist
Quoted 2 lines
if
VIRTIO_NET_F_RSSis set.Quoted 1 line
content.tex +1
-0+It specifies the maximal number of 16-bit entries in RSSindirection
Quoted 3 lines
table.
Quoted 2 lines
content.tex +0
-1-Field \field{rss_max_indirection_table_length} specifies themaximal
Quoted 2 lines
number of 16-bit entries in RSS indirection table.
Quoted 1 line
content.tex +1
-0+The next field, \field{supported_hash_types} exists only if thedevice
Quoted 4 lines
supports hash calculation,
content.tex \subsection{Device configuration layout}\label{sec:Device Types / Network Device
Quoted 3 lines
content.tex +1
-1+i.e. if VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT is set. -Field \field{supported_hash_types} contains the bitmask ofsupported RSS
Quoted 14 lines
hash types.
Quoted 13 lines
content.tex +0
-13- -Hash types applicable for IPv4 packets: -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) -#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) -\end{lstlisting} -Hash types applicable for IPv6 packets without extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) -#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) -#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) -\end{lstlisting}Quoted 8 lines
content.tex \subsection{Device configuration layout}\label{sec:Device Types / Network Device
Quoted 7 lines
content.tex +0
-7-Hash types applicable for IPv6 packets with extension headers -\begin{lstlisting} -#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) -#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) -#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) -\end{lstlisting} -For the exact meaning of VIRTIO_NET_RSS_HASH_TYPE_ flags see \ref{sec:Device Types / Network Device / Device Operation / Control
Virtqueue /
Quoted 2 lines
Receive-side scaling (RSS) / RSS hash types}.
Quoted 1 line
content.tex +1
-0+Field \field{supported_hash_types} contains the bitmask ofsupported
Quoted 3 lines
hash types.
content.tex \subsection{Device configuration layout}\ · line 3010
Quoted 1 line
content.tex +1
-0+See \ref{sec:Device Types / Network Device / Device Operation /Processing of Incoming Packets / Hash calculation for incoming
packets /
Quoted 3 lines
Supported/enabled hash types} for details of supported hash types.
Quoted 2 lines
content.tex +0
-0\devicenormative{\subsubsection}{Device configuration layout}{Device
Quoted 3 lines
Types / Network Device / Device configuration layout}
content.tex \subsection{Device configuration layout}\
Quoted 2 lines
content.tex +0
-0@@ -3048,7 +3033,7 @@ \subsection{Device configuration layout}\label
Quoted 9 lines
{sec:Device Types / Network Device
Quoted 3 lines
negotiated.
The device MUST set \field{rss_max_key_size} to at least 40, if it
offers
Quoted 4 lines
content.tex +1
-1-VIRTIO_NET_F_RSS. +VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT.The device MUST set \field{rss_max_indirection_table_length} to at
least
Quoted 3 lines
128, if it offers
content.tex \subsection{Device Operation}\label
Quoted 2 lines
VIRTIO_NET_F_RSS.content.tex +0
-0@@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device
Quoted 5 lines
Types / Network Device / Device O
Quoted 4 lines
content.tex +1
-0le16 csum_start; le16 csum_offset; le16 num_buffers; + le32 hash_value; (Only if VIRTIO_NET_F_HASH_REPORTnegotiated)
Quoted 1 line
content.tex \subsection{Device Operation}\label · line 3184
Quoted 1 line
content.tex +1
-0+ le16 hash_type; (Only if VIRTIO_NET_F_HASH_REPORTnegotiated)
Quoted 4 lines
content.tex \subsection{Device Operation}\label · line 3185
Quoted 1 line
content.tex +0
-0};Just noticed this - it's a bit problematic as it might force compilers to add 2 bytes of padding at the end. Let's add extra 2
bytes
Quoted 10 lines
of padding explicitly?
OK, no problem
content.tex \subsubsection{Processing of Incoming
Quoted 3 lines
content.tex +0
-0\end{lstlisting}@@ -3517,6 +3504,12 @@ \subsubsection{Processing of IncomingPackets}\
Quoted 7 lines
label{sec:Device Types / Network
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 4 lines
content.tex +1
-0\end{enumerate} +If applicable, the device calculates per-packet hash for incomingpackets as
Quoted 1 line
content.tex +1
-0+defined in \ref{sec:Device Types / Network Device / DeviceOperation /
Quoted 1 line
Processing of Incoming Packets / Hash calculation for incoming
packets}.
Quoted 2 lines
content.tex \subsubsection{Processing of Incoming · line 3509
Quoted 2 lines
content.tex +2
-0+ +If applicable, the device reports hash information for incomingpackets
Quoted 2 lines
as
Quoted 1 line
content.tex +1
-0+defined in \ref{sec:Device Types / Network Device / DeviceOperation /
Quoted 1 line
Processing of Incoming Packets / Hash reporting for incoming
packets}.
Quoted 2 lines
content.tex \subsubsection{Processing of Incoming · line 3512
Quoted 2 lines
content.tex +1
-0+ \devicenormative{\paragraph}{Processing of Incoming Packets}{Device
Quoted 1 line
Types / Network Device / Device Operation / Processing of Incoming
Packets}
Quoted 1 line
Quoted 1 line
\label{devicenormative:Device Types / Network Device / Device
Operation
Quoted 3 lines
/ Processing of Packets}%old label for latexdiff
content.tex \subsubsection{Processing of Incoming
Quoted 2 lines
content.tex +0
-0@@ -3619,6 +3612,181 @@ \subsubsection{Processing of IncomingPackets}\
Quoted 7 lines
label{sec:Device Types / Network
Quoted 6 lines
If neither
VIRTIO_NET_HDR_F_NEEDS_CSUMnorVIRTIO_NET_HDR_F_DATA_VALIDis set, the driver MUST NOT rely on the packet checksum being correct.
+
+\paragraph{Hash calculation for incoming packets} +\label{sec:Device Types / Network Device / Device Operation /Processing
Quoted 3 lines
of Incoming Packets / Hash calculation for incoming packets}
content.tex
Quoted 2 lines
content.tex +2
-0+ +A device attempts to calculate a per-packet hash in the followingcases:
Quoted 2 lines
Quoted 2 lines
+\begin{itemize}
+\item The featureVIRTIO_NET_F_RSSwas negotiated. The device usesthe
Quoted 2 lines
hash to determine the receive virtqueue to place incoming packets.
Quoted 1 line
+\item The feature
VIRTIO_NET_F_HASH_REPORTwas negotiated. Thedevice
Quoted 6 lines
reports the hash value and the hash type with the packet.
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 5 lines
+\end{itemize}
content.tex +4
-0+ +If the feature VIRTIO_NET_F_RSS was negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the
virtio_net_rss_configQuoted 2 lines
structure as 'Enabled hash types' bitmask.
Quoted 1 line
+\item The device uses a key as defined in \field{hash_key_data}
and \
Quoted 2 lines
field{hash_key_length} of the
virtio_net_rss_configstructure (seeQuoted 1 line
+\ref{sec:Device Types / Network Device / Device Operation /
Control
Quoted 6 lines
Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}).
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 5 lines
+\end{itemize}
content.tex +4
-0+ +If the feature VIRTIO_NET_F_RSS was not negotiated: +\begin{itemize} +\item The device uses \field{hash_types} of the
virtio_net_hash_configQuoted 2 lines
structure as 'Enabled hash types' bitmask.
Quoted 1 line
+\item The device uses a key as defined in \field{hash_key_data}
and \
Quoted 2 lines
field{hash_key_length} of the
virtio_net_hash_configstructure (seeQuoted 1 line
+\ref{sec:Device Types / Network Device / Device Operation /
Control
Quoted 5 lines
Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}).
content.tex
Quoted 3 lines
+\end{itemize}
content.tex +2
-0+ +Note that if the device offers VIRTIO_NET_F_HASH_REPORT, even ifit
Quoted 7 lines
supports only one pair of virtqueues, it MUST support
Quoted 1 line
+at least one of commands of
VIRTIO_NET_CTRL_MQclass to configurereported hash parameters:
Quoted 2 lines
+\begin{itemize}
+\item If the device offersVIRTIO_NET_F_RSS, it MUST support
VIRTIO_NET_CTRL_MQ_RSS_CONFIGcommand perQuoted 1 line
+ \ref{sec:Device Types / Network Device / Device Operation /
Control
Quoted 2 lines
Virtqueue / Receive-side scaling (RSS) / Setting RSS parameters}.
Quoted 1 line
+\item Otherwise the device MUST support
VIRTIO_NET_CTRL_MQ_HASH_CONFIGQuoted 2 lines
command per
Quoted 1 line
+ \ref{sec:Device Types / Network Device / Device Operation /
Control
Quoted 6 lines
Virtqueue / Automatic receive steering in multiqueue mode / Hash calculation}.
Quoted 4 lines
+\end{itemize}
+
+\subparagraph{Supported/enabled hash types} +\label{sec:Device Types / Network Device / Device Operation /Processing
Quoted 1 line
of Incoming Packets / Hash calculation for incoming packets /
Supported/
Quoted 14 lines
enabled hash types}
Quoted 13 lines
content.tex +13
-0+Hash types applicable for IPv4 packets: +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv4 (1 << 0) +#define VIRTIO_NET_HASH_TYPE_TCPv4 (1 << 1) +#define VIRTIO_NET_HASH_TYPE_UDPv4 (1 << 2) +\end{lstlisting} +Hash types applicable for IPv6 packets without extension headers +\begin{lstlisting} +#define VIRTIO_NET_HASH_TYPE_IPv6 (1 << 3) +#define VIRTIO_NET_HASH_TYPE_TCPv6 (1 << 4) +#define VIRTIO_NET_HASH_TYPE_UDPv6 (1 << 5) +\end{lstlisting} +Hash types applicable for IPv6 packets with extension headersQuoted 8 lines
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 8 lines
+\begin{lstlisting}
content.tex +7
-0+#define VIRTIO_NET_HASH_TYPE_IP_EX (1 << 6) +#define VIRTIO_NET_HASH_TYPE_TCP_EX (1 << 7) +#define VIRTIO_NET_HASH_TYPE_UDP_EX (1 << 8) +\end{lstlisting} + +\subparagraph{IPv4 packets} +\label{sec:Device Types / Network Device / Device Operation /Processing
Quoted 1 line
of Incoming Packets / Hash calculation for incoming packets / IPv4
packets}
Quoted 1 line
Quoted 1 line
+The device calculates the hash on IPv4 packets according to
'Enabled
Quoted 22 lines
hash types' bitmask as follows:
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 11 lines
+\begin{itemize}
+\item IfVIRTIO_NET_HASH_TYPE_TCPv4is set and the packet hascontent.tex +9
-0+a TCP header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IP address +\item Destination IP address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv4 is set and the +packet has a UDP header, the hash is calculated over the followingfields:
Quoted 9 lines
+\begin{itemize}
+\item Source IP address
+\item Destination IP address
+\item Source UDP port
+\item Destination UDP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_IPv4is set, the hash is +calculated over the following fields:
+\begin{itemize}Quoted 8 lines
Quoted 8 lines
+\item Source IP address
+\item Destination IP address
+\end{itemize}
+\item Else the device does not calculate the hash +\end{itemize}
+
+\subparagraph{IPv6 packets without extension header} +\label{sec:Device Types / Network Device / Device Operation /Processing
Quoted 1 line
of Incoming Packets / Hash calculation for incoming packets / IPv6
packets
Quoted 14 lines
without extension header}
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 13 lines
content.tex +13
-0+The device calculates the hash on IPv6 packets without extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCPv6 is set and the packet has +a TCPv6 header, the hash is calculated over the following fields: +\begin{itemize} +\item Source IPv6 address +\item Destination IPv6 address +\item Source TCP port +\item Destination TCP port +\end{itemize} +\item Else if VIRTIO_NET_HASH_TYPE_UDPv6 is set and the +packet has a UDPv6 header, the hash is calculated over thefollowing
Quoted 10 lines
fields:
Quoted 9 lines
+\begin{itemize}
+\item Source IPv6 address
+\item Destination IPv6 address
+\item Source UDP port
+\item Destination UDP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_IPv6is set, the hash is +calculated over the following fields:
+\begin{itemize}Quoted 8 lines
Quoted 8 lines
+\item Source IPv6 address
+\item Destination IPv6 address
+\end{itemize}
+\item Else the device does not calculate the hash +\end{itemize}
+
+\subparagraph{IPv6 packets with extension header} +\label{sec:Device Types / Network Device / Device Operation /Processing
Quoted 1 line
of Incoming Packets / Hash calculation for incoming packets / IPv6
packets
Quoted 6 lines
with extension header}
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 5 lines
content.tex +5
-0+The device calculates the hash on IPv6 packets with extension +headers according to 'Enabled hash types' bitmask as follows: +\begin{itemize} +\item If VIRTIO_NET_HASH_TYPE_TCP_EX is set and the packet +has a TCPv6 header, the hash is calculated over the followingfields:
Quoted 2 lines
Quoted 2 lines
+\begin{itemize}
+\item Home address from the home address option in the IPv6destination
Quoted 1 line
options header. If the extension header is not present, use the
Source IPv6
Quoted 2 lines
address.
Quoted 1 line
+\item IPv6 address that is contained in the Routing-Header-Type-2
from
Quoted 1 line
the associated extension header. If the extension header is not
present,
Quoted 6 lines
use the Destination IPv6 address.
Quoted 5 lines
+\item Source TCP port
+\item Destination TCP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_UDP_EXis set and the +packet has a UDPv6 header, the hash is calculated over thefollowing
Quoted 3 lines
fields:
Quoted 2 lines
+\begin{itemize}
+\item Home address from the home address option in the IPv6destination
Quoted 1 line
options header. If the extension header is not present, use the
Source IPv6
Quoted 2 lines
address.
Quoted 1 line
+\item IPv6 address that is contained in the Routing-Header-Type-2
from
Quoted 1 line
the associated extension header. If the extension header is not
present,
Quoted 8 lines
use the Destination IPv6 address.
Quoted 7 lines
+\item Source UDP port
+\item Destination UDP port
+\end{itemize}
+\item Else ifVIRTIO_NET_HASH_TYPE_IP_EXis set, the hash is +calculated over the following fields:
+\begin{itemize}
+\item Home address from the home address option in the IPv6destination
Quoted 1 line
options header. If the extension header is not present, use the
Source IPv6
Quoted 2 lines
address.
Quoted 1 line
+\item IPv6 address that is contained in the Routing-Header-Type-2
from
Quoted 1 line
the associated extension header. If the extension header is not
present,
Quoted 6 lines
use the Destination IPv6 address.
content.tex
Quoted 4 lines
+\end{itemize}
+\item Else skip IPv6 extension headers and calculate the hash ascontent.tex +2
-0+defined for an IPv6 packet without extension headers +(see \ref{sec:Device Types / Network Device / Device Operation /Processing of Incoming Packets / Hash calculation for incoming
packets /
Quoted 5 lines
IPv6 packets without extension header}).
Quoted 4 lines
+\end{itemize}
+
+\paragraph{Hash reporting for incoming packets} +\label{sec:Device Types / Network Device / Device Operation /Processing
Quoted 4 lines
of Incoming Packets / Hash reporting for incoming packets}
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 3 lines
content.tex +3
-0+ +If VIRTIO_NET_F_HASH_REPORT was negotiated and + the device has calculated the hash for the packet, the devicefills \
Quoted 4 lines
field{hash_type} with the type of calculated hash
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
Quoted 3 lines
content.tex +3
-0+and \field{hash_value} with the value of calculated hash. + +If VIRTIO_NET_F_HASH_REPORT was negotiated but due to any reasonthe
Quoted 4 lines
Quoted 1 line
+hash was not calculated, the device sets \field{hash_type} to
VIRTIO_NET_HASH_REPORT_NONE.content.tex
Quoted 2 lines
content.tex +2
-0+ +Possible values that the device can report in \field{hash_type}are
Quoted 3 lines
defined below.
Quoted 2 lines
+They correspond to supported hash types defined in +\ref{sec:Device Types / Network Device / Device Operation /
Processing
Quoted 1 line
of Incoming Packets / Hash calculation for incoming packets /
Supported/
Quoted 9 lines
enabled hash types}
content.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network · line 3775
Quoted 3 lines
content.tex +3
-0+as follows: + +VIRTIO_NET_HASH_TYPE_XXX = 1 << (VIRTIO_NET_HASH_REPORT_XXX - 1)So
hash_typeis theHASH_REPORTvalue then? That's quite confusing. Let's rename tohash_report?Quoted 7 lines
No problem to rename anything, but I'd like to do it one time. Currently meaningful hash report values are (1..9), 0 for none They correspond to bitmask of 9 bits for enabled/supported. It was possible to use the same definitions for enable/support/report but then reported kind of hash should be 4 bytes.
As you anyway suggests padding at the end of the packet, we can do that, i.e. add (32 bit hash + 32 bit type)We can but it seems like a waste, does it not? padding can be used for something later ...
Quoted 2 lines
Or if we stay with the values as they are now:
values 0..9 -VIRTIO_NET_WHAT?I thought that's
VIRTIO_NET_HASH_REPORT_XXXOK, this is exactly what is defined
Quoted 7 lines
Quoted 1 line
bits from 0 to 8 -
VIRTIO_NET_WHAT?and this one
VIRTIO_NET_HASH_TYPE_XXX?OK, this is also exactly what is defined
Right I'm saying what's defined is fine, just call the fields consistently.
Quoted 10 lines
Generally what you did here is a bit unusual. Mostly we just define bit numbers
#defineVIRTIO_SCSI_F_INOUT0
#defineVIRTIO_SCSI_F_HOTPLUG1
#defineVIRTIO_SCSI_F_CHANGE2
#defineVIRTIO_SCSI_F_T10_PI3Quoted 3 lines
Value 0 of
hash_reportis "no hash calculated" and it does not participate in support/enable mask. I did not want to use value other than zero for "no hash".Oh right.
Quoted 4 lines
So you want bit 0 to be reserved (not used) in enable/support mask and then to have all the
VIRTIO_NET_HASH_TYPE_XXXto be exactly 1 <<VIRTIO_NET_HASH_REPORT_XXX? Just say...
Quoted 7 lines
We can do that too but it's up to you really.
So fixing the below you would say
bit 0 curresponding to value 1,
bit 1 corresponding to value 2 etc.
No bit corresponds to value 0
?
Currently defined:
Reports:VIRTIO_NET_HASH_REPORT_NONE 0 VIRTIO_NET_HASH_REPORT_IPv4 1 VIRTIO_NET_HASH_REPORT_UDPv4 3 VIRTIO_NET_HASH_REPORT_UDPv6_EX 9
Bitmask (VIRTIO_NET_HASH_TYPE_XXX = 1 << (VIRTIO_NET_HASH_REPORT_XXX - 1)):VIRTIO_NET_HASH_TYPE_IPv4 = (1 << 0)VIRTIO_NET_HASH_TYPE_UDPv4 = (1 << 2) VIRTIO_NET_HASH_TYPE_UDP_EX = (1 << 8)
How you want it to be changed?
Can you please write here in the same format?
Quoted 378 lines
Quoted 346 lines
and just say that bit numbers are from this table, with bit 0 corresponding to the value 0, bit 1 to value 1 etc.
maybe that would have been easier on the eyes - I didn't try, I'm not even sure.
But what you have is correct enough, we can always try to improve the wording later.
Quoted 19 lines
Quoted 16 lines
content.tex +14
-0+ +\begin{lstlisting} +#define VIRTIO_NET_HASH_REPORT_NONE 0 +#define VIRTIO_NET_HASH_REPORT_IPv4 1 +#define VIRTIO_NET_HASH_REPORT_TCPv4 2 +#define VIRTIO_NET_HASH_REPORT_UDPv4 3 +#define VIRTIO_NET_HASH_REPORT_IPv6 4 +#define VIRTIO_NET_HASH_REPORT_TCPv6 5 +#define VIRTIO_NET_HASH_REPORT_UDPv6 6 +#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 +#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 +#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 +\end{lstlisting} +Quoted 1 line
\subsubsection{Control Virtqueue}\label{sec:Device Types / Network
Device / Device Operation / Control Virtqueue}
Quoted 1 line
Quoted 2 lines
content.tex \subsubsection{Control Virtqueue}\label
Quoted 2 lines
The driver uses the control virtqueue (if
VIRTIO_NET_F_CTRL_VQiscontent.tex +0
-0@@ -3896,6 +4064,7 @@ \subsubsection{Control Virtqueue}\label{sec:Device
Quoted 3 lines
Types / Network Device / Devi
Quoted 2 lines
content.tex +0
-0#define VIRTIO_NET_CTRL_MQ 4 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 (for automaticreceive
Quoted 2 lines
steering)
Quoted 1 line
content.tex +0
-0#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 (forconfigurable
Quoted 2 lines
receive steering)
Quoted 1 line
content.tex +1
-0+ #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 (forconfigurable hash
Quoted 4 lines
calculation)
Quoted 3 lines
content.tex +0
-0\end{lstlisting}If more than one multiqueue mode is negotiated, the resulting
device
Quoted 7 lines
configuration is defined by the last command sent by the driver.
content.tex \subsubsection{Control Virtqueue}\label
Quoted 1 line
content.tex +0
-0@@ -3961,10 +4130,37 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 4 lines
according to the native endian of the guest rather than (necessarily when not using the legacy interface) little-endian.
+\subparagraph{Hash calculation}\label{sec:Device Types / Network
Device
Quoted 1 line
/ Device Operation / Control Virtqueue / Automatic receive steering
in
Quoted 2 lines
multiqueue mode / Hash calculation}
Quoted 1 line
+If
VIRTIO_NET_F_HASH_REPORTwas negotiated and the device usesautomatic
Quoted 8 lines
receive steering,
Quoted 1 line
+the device MUST support a command to configure hash calculation
parameters.
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 4 lines
content.tex +4
-0+ +The driver provides parameters for hash calculation as follows: + +\field{class} VIRTIO_NET_CTRL_MQ, \field{command}
VIRTIO_NET_CTRL_MQ_HASH_CONFIG.Quoted 11 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 11 lines
content.tex +11
-0+ +The \field{command-specific-data} has following format: +\begin{lstlisting} +struct virtio_net_hash_config { + le32 hash_types; + le16 reserved[4]; + u8 hash_key_length; + u8 hash_key_data[hash_key_length]; +}; +\end{lstlisting} +Field \field{hash_types} contains a bitmask of allowed hash typesas
Quoted 2 lines
Quoted 2 lines
+defined in
+\ref{sec:Device Types / Network Device / Device Operation /Processing
Quoted 1 line
of Incoming Packets / Hash calculation for incoming packets /
Supported/
Quoted 5 lines
enabled hash types}.
Quoted 1 line
+Initially the device has all hash types disabled and reports only
VIRTIO_NET_HASH_REPORT_NONE.content.tex
Quoted 2 lines
content.tex +2
-0+ +Field \field{reserved} MUST contain zeroes. It is defined to makethe
Quoted 2 lines
structure to match the layout of
virtio_net_rss_configstructure,Quoted 1 line
+defined in \ref{sec:Device Types / Network Device / Device
Operation /
Quoted 3 lines
Control Virtqueue / Receive-side scaling (RSS)}.
content.tex
Quoted 2 lines
content.tex +2
-0+ +Fields \field{hash_key_length} and \field{hash_key_data} definethe key
Quoted 3 lines
to be used in hash calculation.
Quoted 2 lines
+
\paragraph{Receive-side scaling (RSS)}\label{sec:Device Types /Network
Quoted 1 line
Device / Device Operation / Control Virtqueue / Receive-side scaling
(RSS)}
Quoted 1 line
Quoted 1 line
A device offers the feature
VIRTIO_NET_F_RSSif it supports RSSreceive
Quoted 4 lines
steering with Toeplitz hash calculation and configurable parameters.
Quoted 2 lines
-A driver queries RSS capabilities of the device by reading device
configuration as defined in \ref{sec:Device Types / Network Device /
Device
Quoted 3 lines
configuration layout / RSS}
Quoted 1 line
+A driver queries RSS capabilities of the device by reading device
configuration as defined in \ref{sec:Device Types / Network Device /
Device
Quoted 3 lines
configuration layout}
Quoted 2 lines
\subparagraph{Setting RSS parameters}\label{sec:Device Types /
Network
Quoted 1 line
Device / Device Operation / Control Virtqueue / Receive-side scaling
(RSS)
Quoted 3 lines
/ Setting RSS parameters}
content.tex \subsubsection{Control Virtqueue}\label
Quoted 2 lines
content.tex +0
-0@@ -3981,7 +4177,8 @@ \subsubsection{Control Virtqueue}\label{sec:Device
Quoted 4 lines
Types / Network Device / Devi
Quoted 3 lines
content.tex +0
-0}; \end{lstlisting}Field \field{hash_types} contains a bitmask of allowed hash types
as
Quoted 1 line
Quoted 1 line
-defined in \ref{sec:Device Types / Network Device / Device
Operation /
Quoted 3 lines
Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}.
Quoted 2 lines
+defined in
+\ref{sec:Device Types / Network Device / Device Operation /Processing
Quoted 1 line
of Incoming Packets / Hash calculation for incoming packets /
Supported/
Quoted 5 lines
enabled hash types}.
content.tex \subsubsection{Control Virtqueue}\label
Quoted 4 lines
Field \field{indirection_table_mask} is a mask to be applied to the calculated hash to produce an index in the
content.tex +0
-0@@ -3995,93 +4192,7 @@ \subsubsection{Control Virtqueue}\label{sec:Device
Quoted 3 lines
Types / Network Device / Devi
Quoted 2 lines
A driver sets \field{max_tx_vq} to inform a device how many
transmit
Quoted 3 lines
virtqueues it may use (transmitq1\ldots transmitq \field{max_tx_vq}).
Quoted 2 lines
-\subparagraph{RSS hash types}\label{sec:Device Types / Network
Device /
Quoted 1 line
Device Operation / Control Virtqueue / Receive-side scaling (RSS) /
RSS
Quoted 17 lines
hash types}
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 3 lines
content.tex +0
-3- -The device calculates the hash on IPv4 packets according to the -field \field{hash_types} of the virtio_net_rss_config structure asfollows:
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 11 lines
-\begin{itemize}
-\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv4is set and the packet hascontent.tex +0
-9-a TCP header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv4 is set and the -packet has a UDP header, the hash is calculated over the followingfields:
Quoted 16 lines
Quoted 7 lines
-\begin{itemize}
-\item Source IP address
-\item Destination IP address
-\item Source UDP port
-\item Destination UDP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv4is set, the hash iscontent.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 9 lines
content.tex +0
-9-calculated over the following fields: -\begin{itemize} -\item Source IP address -\item Destination IP address -\end{itemize} -\item Else the device does not calculate the hash -\end{itemize} - -\label{itm:Device Types / Network Device / Device Operation /Control
Quoted 5 lines
Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets without extension headers}
content.tex
Quoted 2 lines
content.tex +0
-2-The device calculates the hash on IPv6 packets without extension -headers according to the field \field{hash_types} of the
virtio_net_rss_configstructure as follows:Quoted 11 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 11 lines
-\begin{itemize}
-\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv6is set and the packet hascontent.tex +0
-9-a TCPv6 header, the hash is calculated over the following fields: -\begin{itemize} -\item Source IPv6 address -\item Destination IPv6 address -\item Source TCP port -\item Destination TCP port -\end{itemize} -\item Else if VIRTIO_NET_RSS_HASH_TYPE_UDPv6 is set and the -packet has a UDPv6 header, the hash is calculated over thefollowing
Quoted 11 lines
fields:
Quoted 10 lines
-\begin{itemize}
-\item Source IPv6 address
-\item Destination IPv6 address
-\item Source UDP port
-\item Destination UDP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv6is set, the hash is -calculated over the following fields:
-\begin{itemize}
-\item Source IPv6 addressQuoted 11 lines
content.tex \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 7 lines
-\item Destination IPv6 address -\end{itemize}
-\item Else the device does not calculate the hash -\end{itemize}content.tex +0
-3- -The device calculates the hash on IPv6 packets with extension -headers according to the field \field{hash_types} of the
virtio_net_rss_configstructure as follows:Quoted 3 lines
-\begin{itemize}
-\item IfVIRTIO_NET_RSS_HASH_TYPE_TCP_EXis set and the packet -has a TCPv6 header, the hash is calculated over the followingfields:
Quoted 2 lines
Quoted 2 lines
-\begin{itemize}
-\item Home address from the home address option in the IPv6destination
Quoted 1 line
options header. If the extension header is not present, use the
Source IPv6
Quoted 2 lines
address.
Quoted 1 line
-\item IPv6 address that is contained in the Routing-Header-Type-2
from
Quoted 1 line
the associated extension header. If the extension header is not
present,
Quoted 6 lines
use the Destination IPv6 address.
Quoted 5 lines
-\item Source TCP port
-\item Destination TCP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDP_EXis set and the -packet has a UDPv6 header, the hash is calculated over thefollowing
Quoted 3 lines
fields:
Quoted 2 lines
-\begin{itemize}
-\item Home address from the home address option in the IPv6destination
Quoted 1 line
options header. If the extension header is not present, use the
Source IPv6
Quoted 2 lines
address.
Quoted 1 line
-\item IPv6 address that is contained in the Routing-Header-Type-2
from
Quoted 1 line
the associated extension header. If the extension header is not
present,
Quoted 8 lines
use the Destination IPv6 address.
Quoted 7 lines
-\item Source UDP port
-\item Destination UDP port
-\end{itemize}
-\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IP_EXis set, the hash is -calculated over the following fields:
-\begin{itemize}
-\item Home address from the home address option in the IPv6destination
Quoted 1 line
options header. If the extension header is not present, use the
Source IPv6
Quoted 2 lines
address.
Quoted 1 line
-\item IPv6 address that is contained in the Routing-Header-Type-2
from
Quoted 1 line
the associated extension header. If the extension header is not
present,
Quoted 5 lines
use the Destination IPv6 address.
Quoted 3 lines
-\end{itemize}
-\item Else skip IPv6 extension headers and calculate the hash as -defined for an IPv6 packet without extension headers (see \ref{itm:Device Types / Network Device / Device Operation / Control
Virtqueue /
Quoted 1 line
Receive-side scaling (RSS) / RSS hash types/hash on IPv6 packets
without
Quoted 3 lines
extension headers}).
Quoted 2 lines
-\end{itemize}
+Fields \field{hash_key_length} and \field{hash_key_data} definethe key
Quoted 3 lines
to be used in hash calculation.
Quoted 2 lines
\drivernormative{\subparagraph}{Setting RSS parameters}{Device
Types /
Quoted 7 lines
Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) }
content.tex \subsubsection{Control Virtqueue}\label
Quoted 2 lines
content.tex +0
-0@@ -4093,12 +4204,12 @@ \subsubsection{Control Virtqueue}\label{sec:Device Types / Network Device / Devi
Quoted 2 lines
A driver MUST use \field{indirection_table_mask} values that are
less
Quoted 3 lines
than \field{rss_max_indirection_table_length} reported by a device.
Quoted 2 lines
-A driver MUST NOT set any
VIRTIO_NET_RSS_HASH_TYPE_flags that arenot
Quoted 5 lines
supported by a device.
Quoted 1 line
+A driver MUST NOT set any
VIRTIO_NET_HASH_TYPE_flags that are notsupported by a device.
Quoted 2 lines
\devicenormative{\subparagraph}{RSS processing}{Device Types /
Network
Quoted 1 line
Device / Device Operation / Control Virtqueue / Receive-side scaling
(RSS)
Quoted 2 lines
/ RSS processing}
Quoted 1 line
The device MUST determine the destination queue for a network
packet as
Quoted 3 lines
follows:
Quoted 2 lines
\begin{itemize}
-\item Calculate the hash of the packet as defined in \ref{sec:Device
Quoted 3 lines
Types / Network Device / Device Operation / Control Virtqueue / Receive-side scaling (RSS) / RSS hash types}
Quoted 1 line
+\item Calculate the hash of the packet as defined in \ref
{sec:Device
Quoted 1 line
Types / Network Device / Device Operation / Processing of Incoming
Packets
Quoted 2 lines
/ Hash calculation for incoming packets}.
Quoted 1 line
\item If the device did not calculate the hash for the specific
packet,
Quoted 4 lines
the device directs the packet to the receiveq specified by \field {
unclassified_queue} ofvirtio_net_rss_configstructure (value of 0 corresponds to receiveq1).Quoted 1 line
\item Apply \field{indirection_table_mask} to the calculated hash
and
Quoted 1 line
use the result as the index in the indirection table to get 0-based
number
Quoted 13 lines
of destination receiveq (value of 0 corresponds to receiveq1).
Quoted 3 lines
\end{itemize}
--
2.17.1This 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.
Quoted 16 lines
Quoted 5 lines
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
Quoted 7 lines
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/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/
Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
Quoted 624 lines · Yuri Benditovich
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
From: "Michael S. Tsirkin" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: "Yuri Benditovich" <[email protected]>, [email protected]
Sent: Wednesday, February 19, 2020 4:56:04 PM
Subject: Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureOn Wed, Feb 19, 2020 at 09:49:37AM -0500, Yuri Benditovich wrote:
>
>
> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ >
> From: "Michael S. Tsirkin" <[email protected]>
> To: "Yuri Benditovich" <[email protected]>
> Cc: "Yuri Benditovich" <[email protected]>,
> [email protected]
> Sent: Wednesday, February 19, 2020 4:35:49 PM
> Subject: Re: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define
> per-packet hash reporting feature
>
> On Wed, Feb 19, 2020 at 06:07:13AM -0500, Yuri Benditovich wrote:
> >
> >
> >
> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
> >
> > From: "Michael S. Tsirkin" <[email protected]>
> > To: "Yuri Benditovich" <[email protected]>
> > Cc: [email protected]
> > Sent: Wednesday, February 19, 2020 11:12:40 AM
> > Subject: [virtio-comment] Re: [PATCH v4 1/1] virtio-net: Define
> per-packet
> > hash reporting feature
> >
> > On Wed, Feb 19, 2020 at 09:53:37AM +0200, Yuri Benditovich
wrote:
> > > Fixes: https://github.com/oasis-tcs/virtio-spec/issues/66
> > > Define respective feature bit for virtio-net.
> > > Extend packet layout to populate hash value and type.
> > > Move the definition of IP/TCP/UDP header fields to
> > > calculate the hash out of RSS section to common network
> > > device section.
> > >
> > > Signed-off-by: Yuri Benditovich <[email protected]>
> > > ---
> > > content.tex | 347
> ++++++++++++++++++++++++++++++++++------------------
> > > 1 file changed, 229 insertions(+), 118 deletions(-)
> > >
> > > diff --git a/content.tex b/content.tex
> > > index b91a132..d7d4e42 100644
> > > --- a/content.tex
> > > +++ b/content.tex
> > > @@ -2895,6 +2895,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_HASH_REPORT(57)] Device can report
per-packet
> hash
> > > + value and a type of calculated hash.
> > > +
> > > \item[VIRTIO_NET_F_GUEST_HDRLEN(59)] Driver can provide the
exact
> \field
> > {hdr_len}
> > > value. Device benefits from knowing the exact header
length.
> > >
> > > @@ -2995,35 +2998,17 @@ \subsection{Device configuration
layout}\
> label
> > {sec:Device Types / Network Device
> > > le32supported_hash_types;
> > > };
> > > \end{lstlisting}
> > > -\label{sec:Device Types / Network Device / Device
configuration
> layout /
> > RSS}
> > > -Three following fields, \field{rss_max_key_size}, \field
> > {rss_max_indirection_table_length}
> > > -and \field{supported_hash_types} only exist if
VIRTIO_NET_F_RSSis
> set.
> > > +The following field, \field{rss_max_key_size} only exist if
> >VIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORTis set.
> > > +It specifies the maximal supported length of RSS key in
bytes.
> > >
> > > -Field \field{rss_max_key_size} specifies the maximal
supported
> length of
> > RSS key in bytes.
> > > +The following field, \field
{rss_max_indirection_table_length} only
> exist
> > ifVIRTIO_NET_F_RSSis set.
> > > +It specifies the maximal number of 16-bit entries in RSS
> indirection
> > table.
> > >
> > > -Field \field{rss_max_indirection_table_length} specifies the
> maximal
> > number of 16-bit entries in RSS indirection table.
> > > +The next field, \field{supported_hash_types} exists only if
the
> device
> > supports hash calculation,
> > > +i.e. ifVIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORTis set.
> > >
> > > -Field \field{supported_hash_types} contains the bitmask of
> supported RSS
> > hash types.
> > > -
> > > -Hash types applicable for IPv4 packets:
> > > -\begin{lstlisting}
> > > -#defineVIRTIO_NET_RSS_HASH_TYPE_IPv4(1 << 0)
> > > -#defineVIRTIO_NET_RSS_HASH_TYPE_TCPv4(1 << 1)
> > > -#defineVIRTIO_NET_RSS_HASH_TYPE_UDPv4(1 << 2)
> > > -\end{lstlisting}
> > > -Hash types applicable for IPv6 packets without extension
headers
> > > -\begin{lstlisting}
> > > -#defineVIRTIO_NET_RSS_HASH_TYPE_IPv6(1 << 3)
> > > -#defineVIRTIO_NET_RSS_HASH_TYPE_TCPv6(1 << 4)
> > > -#defineVIRTIO_NET_RSS_HASH_TYPE_UDPv6(1 << 5)
> > > -\end{lstlisting}
> > > -Hash types applicable for IPv6 packets with extension
headers
> > > -\begin{lstlisting}
> > > -#defineVIRTIO_NET_RSS_HASH_TYPE_IP_EX(1 << 6)
> > > -#defineVIRTIO_NET_RSS_HASH_TYPE_TCP_EX(1 << 7)
> > > -#defineVIRTIO_NET_RSS_HASH_TYPE_UDP_EX(1 << 8)
> > > -\end{lstlisting}
> > > -For the exact meaning ofVIRTIO_NET_RSS_HASH_TYPE_flags see
\ref
> > {sec:Device Types / Network Device / Device Operation / Control
> Virtqueue /
> > Receive-side scaling (RSS) / RSS hash types}.
> > > +Field \field{supported_hash_types} contains the bitmask of
> supported
> > hash types.
> > > +See \ref{sec:Device Types / Network Device / Device
Operation /
> > Processing of Incoming Packets / Hash calculation for incoming
> packets /
> > Supported/enabled hash types} for details of supported hash
types.
> > >
> > > \devicenormative{\subsubsection}{Device configuration
layout}
> {Device
> > Types / Network Device / Device configuration layout}
> > >
> > > @@ -3048,7 +3033,7 @@ \subsection{Device configuration
layout}\
> label
> > {sec:Device Types / Network Device
> > > negotiated.
> > >
> > > The device MUST set \field{rss_max_key_size} to at least 40,
if it
> > offers
> > > -VIRTIO_NET_F_RSS.
> > > +VIRTIO_NET_F_RSS orVIRTIO_NET_F_HASH_REPORT.
> > >
> > > The device MUST set \field{rss_max_indirection_table_length}
to at
> least
> > 128, if it offers
> > >VIRTIO_NET_F_RSS.
> > > @@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label
> {sec:Device
> > Types / Network Device / Device O
> > > le16csum_start;
> > > le16csum_offset;
> > > le16num_buffers;
> > > + le32hash_value; (Only ifVIRTIO_NET_F_HASH_REPORT
> negotiated)
> > > + le16hash_type; (Only ifVIRTIO_NET_F_HASH_REPORT
> negotiated)
> > > };
> >
> > Just noticed this - it's a bit problematic as it might force
> > compilers to add 2 bytes of padding at the end. Let's add extra
2
> bytes
> > of padding explicitly?
> >
> > OK, no problem
> >
> >
> >
> >
> > > \end{lstlisting}
> > >
> > > @@ -3517,6 +3504,12 @@ \subsubsection{Processing of Incoming
> Packets}\
> > label{sec:Device Types / Network
> > >
> > > \end{enumerate}
> > >
> > > +If applicable, the device calculates per-packet hash for
incoming
> > packets as
> > > +defined in \ref{sec:Device Types / Network Device / Device
> Operation /
> > Processing of Incoming Packets / Hash calculation for incoming
> packets}.
> > > +
> > > +If applicable, the device reports hash information for
incoming
> packets
> > as
> > > +defined in \ref{sec:Device Types / Network Device / Device
> Operation /
> > Processing of Incoming Packets / Hash reporting for incoming
> packets}.
> > > +
> > > \devicenormative{\paragraph}{Processing of Incoming Packets}
> {Device
> > Types / Network Device / Device Operation / Processing of
Incoming
> Packets}
> > > \label{devicenormative:Device Types / Network Device /
Device
> Operation
> > / Processing of Packets}%old label for latexdiff
> > >
> > > @@ -3619,6 +3612,181 @@ \subsubsection{Processing of Incoming
> Packets}\
> > label{sec:Device Types / Network
> > > If neitherVIRTIO_NET_HDR_F_NEEDS_CSUMnor
> > >VIRTIO_NET_HDR_F_DATA_VALIDis set, the driver MUST NOT
> > > rely on the packet checksum being correct.
> > > +
> > > +\paragraph{Hash calculation for incoming packets}
> > > +\label{sec:Device Types / Network Device / Device Operation
/
> Processing
> > of Incoming Packets / Hash calculation for incoming packets}
> > > +
> > > +A device attempts to calculate a per-packet hash in the
following
> cases:
> > > +\begin{itemize}
> > > +\item The featureVIRTIO_NET_F_RSSwas negotiated. The
device uses
> the
> > hash to determine the receive virtqueue to place incoming
packets.
> > > +\item The featureVIRTIO_NET_F_HASH_REPORTwas negotiated.
The
> device
> > reports the hash value and the hash type with the packet.
> > > +\end{itemize}
> > > +
> > > +If the featureVIRTIO_NET_F_RSSwas negotiated:
> > > +\begin{itemize}
> > > +\item The device uses \field{hash_types} of the
>virtio_net_rss_config
> > structure as 'Enabled hash types' bitmask.
> > > +\item The device uses a key as defined in \field
{hash_key_data}
> and \
> > field{hash_key_length} of thevirtio_net_rss_configstructure
(see
> > > +\ref{sec:Device Types / Network Device / Device Operation /
> Control
> > Virtqueue / Receive-side scaling (RSS) / Setting RSS
parameters}).
> > > +\end{itemize}
> > > +
> > > +If the featureVIRTIO_NET_F_RSSwas not negotiated:
> > > +\begin{itemize}
> > > +\item The device uses \field{hash_types} of the
>virtio_net_hash_config
> > structure as 'Enabled hash types' bitmask.
> > > +\item The device uses a key as defined in \field
{hash_key_data}
> and \
> > field{hash_key_length} of thevirtio_net_hash_configstructure
(see
> > > +\ref{sec:Device Types / Network Device / Device Operation /
> Control
> > Virtqueue / Automatic receive steering in multiqueue mode /
Hash
> > calculation}).
> > > +\end{itemize}
> > > +
> > > +Note that if the device offersVIRTIO_NET_F_HASH_REPORT,
even if
> it
> > supports only one pair of virtqueues, it MUST support
> > > +at least one of commands ofVIRTIO_NET_CTRL_MQclass to
configure
> > reported hash parameters:
> > > +\begin{itemize}
> > > +\item If the device offersVIRTIO_NET_F_RSS, it MUST support
> >VIRTIO_NET_CTRL_MQ_RSS_CONFIGcommand per
> > > + \ref{sec:Device Types / Network Device / Device Operation /
> Control
> > Virtqueue / Receive-side scaling (RSS) / Setting RSS
parameters}.
> > > +\item Otherwise the device MUST support
>VIRTIO_NET_CTRL_MQ_HASH_CONFIG
> > command per
> > > + \ref{sec:Device Types / Network Device / Device Operation /
> Control
> > Virtqueue / Automatic receive steering in multiqueue mode /
Hash
> > calculation}.
> > > +\end{itemize}
> > > +
> > > +\subparagraph{Supported/enabled hash types}
> > > +\label{sec:Device Types / Network Device / Device Operation
/
> Processing
> > of Incoming Packets / Hash calculation for incoming packets /
> Supported/
> > enabled hash types}
> > > +Hash types applicable for IPv4 packets:
> > > +\begin{lstlisting}
> > > +#defineVIRTIO_NET_HASH_TYPE_IPv4(1 << 0)
> > > +#defineVIRTIO_NET_HASH_TYPE_TCPv4(1 << 1)
> > > +#defineVIRTIO_NET_HASH_TYPE_UDPv4(1 << 2)
> > > +\end{lstlisting}
> > > +Hash types applicable for IPv6 packets without extension
headers
> > > +\begin{lstlisting}
> > > +#defineVIRTIO_NET_HASH_TYPE_IPv6(1 << 3)
> > > +#defineVIRTIO_NET_HASH_TYPE_TCPv6(1 << 4)
> > > +#defineVIRTIO_NET_HASH_TYPE_UDPv6(1 << 5)
> > > +\end{lstlisting}
> > > +Hash types applicable for IPv6 packets with extension
headers
> > > +\begin{lstlisting}
> > > +#defineVIRTIO_NET_HASH_TYPE_IP_EX(1 << 6)
> > > +#defineVIRTIO_NET_HASH_TYPE_TCP_EX(1 << 7)
> > > +#defineVIRTIO_NET_HASH_TYPE_UDP_EX(1 << 8)
> > > +\end{lstlisting}
> > > +
> > > +\subparagraph{IPv4 packets}
> > > +\label{sec:Device Types / Network Device / Device Operation
/
> Processing
> > of Incoming Packets / Hash calculation for incoming packets /
IPv4
> packets}
> > > +The device calculates the hash on IPv4 packets according to
> 'Enabled
> > hash types' bitmask as follows:
> > > +\begin{itemize}
> > > +\item IfVIRTIO_NET_HASH_TYPE_TCPv4is set and the packet
has
> > > +a TCP header, the hash is calculated over the following
fields:
> > > +\begin{itemize}
> > > +\item Source IP address
> > > +\item Destination IP address
> > > +\item Source TCP port
> > > +\item Destination TCP port
> > > +\end{itemize}
> > > +\item Else ifVIRTIO_NET_HASH_TYPE_UDPv4is set and the
> > > +packet has a UDP header, the hash is calculated over the
following
> > fields:
> > > +\begin{itemize}
> > > +\item Source IP address
> > > +\item Destination IP address
> > > +\item Source UDP port
> > > +\item Destination UDP port
> > > +\end{itemize}
> > > +\item Else ifVIRTIO_NET_HASH_TYPE_IPv4is set, the hash is
> > > +calculated over the following fields:
> > > +\begin{itemize}
> > > +\item Source IP address
> > > +\item Destination IP address
> > > +\end{itemize}
> > > +\item Else the device does not calculate the hash
> > > +\end{itemize}
> > > +
> > > +\subparagraph{IPv6 packets without extension header}
> > > +\label{sec:Device Types / Network Device / Device Operation
/
> Processing
> > of Incoming Packets / Hash calculation for incoming packets /
IPv6
> packets
> > without extension header}
> > > +The device calculates the hash on IPv6 packets without
extension
> > > +headers according to 'Enabled hash types' bitmask as
follows:
> > > +\begin{itemize}
> > > +\item IfVIRTIO_NET_HASH_TYPE_TCPv6is set and the packet
has
> > > +a TCPv6 header, the hash is calculated over the following
fields:
> > > +\begin{itemize}
> > > +\item Source IPv6 address
> > > +\item Destination IPv6 address
> > > +\item Source TCP port
> > > +\item Destination TCP port
> > > +\end{itemize}
> > > +\item Else ifVIRTIO_NET_HASH_TYPE_UDPv6is set and the
> > > +packet has a UDPv6 header, the hash is calculated over the
> following
> > fields:
> > > +\begin{itemize}
> > > +\item Source IPv6 address
> > > +\item Destination IPv6 address
> > > +\item Source UDP port
> > > +\item Destination UDP port
> > > +\end{itemize}
> > > +\item Else ifVIRTIO_NET_HASH_TYPE_IPv6is set, the hash is
> > > +calculated over the following fields:
> > > +\begin{itemize}
> > > +\item Source IPv6 address
> > > +\item Destination IPv6 address
> > > +\end{itemize}
> > > +\item Else the device does not calculate the hash
> > > +\end{itemize}
> > > +
> > > +\subparagraph{IPv6 packets with extension header}
> > > +\label{sec:Device Types / Network Device / Device Operation
/
> Processing
> > of Incoming Packets / Hash calculation for incoming packets /
IPv6
> packets
> > with extension header}
> > > +The device calculates the hash on IPv6 packets with
extension
> > > +headers according to 'Enabled hash types' bitmask as
follows:
> > > +\begin{itemize}
> > > +\item IfVIRTIO_NET_HASH_TYPE_TCP_EXis set and the packet
> > > +has a TCPv6 header, the hash is calculated over the
following
> fields:
> > > +\begin{itemize}
> > > +\item Home address from the home address option in the IPv6
> destination
> > options header. If the extension header is not present, use the
> Source IPv6
> > address.
> > > +\item IPv6 address that is contained in the
Routing-Header-Type-2
> from
> > the associated extension header. If the extension header is not
> present,
> > use the Destination IPv6 address.
> > > +\item Source TCP port
> > > +\item Destination TCP port
> > > +\end{itemize}
> > > +\item Else ifVIRTIO_NET_HASH_TYPE_UDP_EXis set and the
> > > +packet has a UDPv6 header, the hash is calculated over the
> following
> > fields:
> > > +\begin{itemize}
> > > +\item Home address from the home address option in the IPv6
> destination
> > options header. If the extension header is not present, use the
> Source IPv6
> > address.
> > > +\item IPv6 address that is contained in the
Routing-Header-Type-2
> from
> > the associated extension header. If the extension header is not
> present,
> > use the Destination IPv6 address.
> > > +\item Source UDP port
> > > +\item Destination UDP port
> > > +\end{itemize}
> > > +\item Else ifVIRTIO_NET_HASH_TYPE_IP_EXis set, the hash is
> > > +calculated over the following fields:
> > > +\begin{itemize}
> > > +\item Home address from the home address option in the IPv6
> destination
> > options header. If the extension header is not present, use the
> Source IPv6
> > address.
> > > +\item IPv6 address that is contained in the
Routing-Header-Type-2
> from
> > the associated extension header. If the extension header is not
> present,
> > use the Destination IPv6 address.
> > > +\end{itemize}
> > > +\item Else skip IPv6 extension headers and calculate the
hash as
> > > +defined for an IPv6 packet without extension headers
> > > +(see \ref{sec:Device Types / Network Device / Device
Operation /
> > Processing of Incoming Packets / Hash calculation for incoming
> packets /
> > IPv6 packets without extension header}).
> > > +\end{itemize}
> > > +
> > > +\paragraph{Hash reporting for incoming packets}
> > > +\label{sec:Device Types / Network Device / Device Operation
/
> Processing
> > of Incoming Packets / Hash reporting for incoming packets}
> > > +
> > > +IfVIRTIO_NET_F_HASH_REPORTwas negotiated and
> > > + the device has calculated the hash for the packet, the
device
> fills \
> > field{hash_type} with the type of calculated hash
> > > +and \field{hash_value} with the value of calculated hash.
> > > +
> > > +IfVIRTIO_NET_F_HASH_REPORTwas negotiated but due to any
reason
> the
> > > +hash was not calculated, the device sets \field{hash_type}
to
> >VIRTIO_NET_HASH_REPORT_NONE.
> > > +
> > > +Possible values that the device can report in \field
{hash_type}
> are
> > defined below.
> > > +They correspond to supported hash types defined in
> > > +\ref{sec:Device Types / Network Device / Device Operation /
> Processing
> > of Incoming Packets / Hash calculation for incoming packets /
> Supported/
> > enabled hash types}
> > > +as follows:
> > > +
> > > +VIRTIO_NET_HASH_TYPE_XXX = 1 << (VIRTIO_NET_HASH_REPORT_XXX
- 1)
> >
> >
> > Sohash_typeis theHASH_REPORTvalue then? That's quite
confusing.
> > Let's rename tohash_report?
> >
> > No problem to rename anything, but I'd like to do it one time.
> > Currently meaningful hash report values are (1..9), 0 for none
> > They correspond to bitmask of 9 bits for enabled/supported.
> > It was possible to use the same definitions for enable/support/
report
> > but then reported kind of hash should be 4 bytes.
> > As you anyway suggests padding at the end of the packet, we can do
that,
> > i.e. add (32 bit hash + 32 bit type)
>
> We can but it seems like a waste, does it not? padding can be used
for
> something later ...
>
> > Or if we stay with the values as they are now:
> > values 0..9 -VIRTIO_NET_WHAT?
>
> I thought that'sVIRTIO_NET_HASH_REPORT_XXX
>
> OK, this is exactly what is defined
>
>
> > bits from 0 to 8 -VIRTIO_NET_WHAT?
>
>
> and this oneVIRTIO_NET_HASH_TYPE_XXX?
>
> OK, this is also exactly what is defined
>Right I'm saying what's defined is fine, just call the fields consistently.
>
>
> Generally what you did here is a bit unusual. Mostly we just define
> bit numbers
> #defineVIRTIO_SCSI_F_INOUT0
> #defineVIRTIO_SCSI_F_HOTPLUG1
> #defineVIRTIO_SCSI_F_CHANGE2
> #defineVIRTIO_SCSI_F_T10_PI3
>
>
> Value 0 ofhash_reportis "no hash calculated" and it does not > participate in support/enable mask. I did not want to > use value other than zero for "no hash".Oh right.
> So you want bit 0 to be reserved (not used) in enable/support mask > and then to have all the
VIRTIO_NET_HASH_TYPE_XXXto be > exactly 1 <<VIRTIO_NET_HASH_REPORT_XXX? Just say...
>We can do that too but it's up to you really.
So fixing the below you would say
bit 0 curresponding to value 1, bit 1 corresponding to value 2 etc. No bit corresponds to value 0
?Currently defined:
Reports:
VIRTIO_NET_HASH_REPORT_NONE 0 VIRTIO_NET_HASH_REPORT_IPv4 1 VIRTIO_NET_HASH_REPORT_UDPv4 3 VIRTIO_NET_HASH_REPORT_UDPv6_EX 9
Quoted 8 lines
Bitmask (
VIRTIO_NET_HASH_TYPE_XXX= 1 << (VIRTIO_NET_HASH_REPORT_XXX- 1)):VIRTIO_NET_HASH_TYPE_IPv4= (1 << 0)VIRTIO_NET_HASH_TYPE_UDPv4= (1 << 2)VIRTIO_NET_HASH_TYPE_UDP_EX= (1 << 8)How you want it to be changed?
Can you please write here in the same format?
IMHO at a minimum, \field{hash_type} should be \field{hash_report}.
That's all.
Quoted 451 lines
Quoted 16 lines
and just say that bit numbers are from this table, with bit 0 corresponding to the value 0, bit 1 to value 1 etc.
maybe that would have been easier on the eyes - I didn't try, I'm not even sure.
But what you have is correct enough, we can always try to improve the wording later.
>
>Quoted 15 lines
> > +
> > +\begin{lstlisting}
> > +#defineVIRTIO_NET_HASH_REPORT_NONE0
> > +#defineVIRTIO_NET_HASH_REPORT_IPv41
> > +#defineVIRTIO_NET_HASH_REPORT_TCPv42
> > +#defineVIRTIO_NET_HASH_REPORT_UDPv43
> > +#defineVIRTIO_NET_HASH_REPORT_IPv64
> > +#defineVIRTIO_NET_HASH_REPORT_TCPv65
> > +#defineVIRTIO_NET_HASH_REPORT_UDPv66
> > +#defineVIRTIO_NET_HASH_REPORT_IPv6_EX7
> > +#defineVIRTIO_NET_HASH_REPORT_TCPv6_EX8
> > +#defineVIRTIO_NET_HASH_REPORT_UDPv6_EX9
> > +\end{lstlisting}
> > +
> > \subsubsection{Control Virtqueue}\label{sec:Device Types /Network
> > Device / Device Operation / Control Virtqueue}
> > >
> > > The driver uses the control virtqueue (if
VIRTIO_NET_F_CTRL_VQis
> > > @@ -3896,6 +4064,7 @@ \subsubsection{Control Virtqueue}\label
> {sec:Device
> > Types / Network Device / Devi
> > > #defineVIRTIO_NET_CTRL_MQ4
> > > #defineVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET0 (for
automatic
> receive
> > steering)
> > > #defineVIRTIO_NET_CTRL_MQ_RSS_CONFIG1 (for
> configurable
> > receive steering)
> > > + #defineVIRTIO_NET_CTRL_MQ_HASH_CONFIG2 (for
> configurable hash
> > calculation)
> > > \end{lstlisting}
> > >
> > > If more than one multiqueue mode is negotiated, the
resulting
> device
> > configuration is defined by the last command sent by the
driver.
> > > @@ -3961,10 +4130,37 @@ \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.
> > >
> > > +\subparagraph{Hash calculation}\label{sec:Device Types /
Network
> Device
> > / Device Operation / Control Virtqueue / Automatic receive
steering
> in
> > multiqueue mode / Hash calculation}
> > > +IfVIRTIO_NET_F_HASH_REPORTwas negotiated and the device
uses
> automatic
> > receive steering,
> > > +the device MUST support a command to configure hash
calculation
> > parameters.
> > > +
> > > +The driver provides parameters for hash calculation as
follows:
> > > +
> > > +\field{class}VIRTIO_NET_CTRL_MQ, \field{command}
> >VIRTIO_NET_CTRL_MQ_HASH_CONFIG.
> > > +
> > > +The \field{command-specific-data} has following format:
> > > +\begin{lstlisting}
> > > +structvirtio_net_hash_config{
> > > + le32hash_types;
> > > + le16 reserved[4];
> > > + u8hash_key_length;
> > > + u8 hash_key_data[hash_key_length];
> > > +};
> > > +\end{lstlisting}
> > > +Field \field{hash_types} contains a bitmask of allowed hash
types
> as
> > > +defined in
> > > +\ref{sec:Device Types / Network Device / Device Operation /
> Processing
> > of Incoming Packets / Hash calculation for incoming packets /
> Supported/
> > enabled hash types}.
> > > +Initially the device has all hash types disabled and reports
only
> >VIRTIO_NET_HASH_REPORT_NONE.
> > > +
> > > +Field \field{reserved} MUST contain zeroes. It is defined to
make
> the
> > structure to match the layout ofvirtio_net_rss_config
structure,
> > > +defined in \ref{sec:Device Types / Network Device / Device
> Operation /
> > Control Virtqueue / Receive-side scaling (RSS)}.
> > > +
> > > +Fields \field{hash_key_length} and \field{hash_key_data}
define
> the key
> > to be used in hash calculation.
> > > +
> > > \paragraph{Receive-side scaling (RSS)}\label{sec:Device
Types /
> Network
> > Device / Device Operation / Control Virtqueue / Receive-side
scaling
> (RSS)}
> > > A device offers the featureVIRTIO_NET_F_RSSif it supports
RSS
> receive
> > steering with Toeplitz hash calculation and configurable
parameters.
> > >
> > > -A driver queries RSS capabilities of the device by reading
device
> > configuration as defined in \ref{sec:Device Types / Network
Device /
> Device
> > configuration layout / RSS}
> > > +A driver queries RSS capabilities of the device by reading
device
> > configuration as defined in \ref{sec:Device Types / Network
Device /
> Device
> > configuration layout}
> > >
> > > \subparagraph{Setting RSS parameters}\label{sec:Device Types
/
> Network
> > Device / Device Operation / Control Virtqueue / Receive-side
scaling
> (RSS)
> > / Setting RSS parameters}
> > >
> > > @@ -3981,7 +4177,8 @@ \subsubsection{Control Virtqueue}\label
> {sec:Device
> > Types / Network Device / Devi
> > > };
> > > \end{lstlisting}
> > > Field \field{hash_types} contains a bitmask of allowed hash
types
> as
> > > -defined in \ref{sec:Device Types / Network Device / Device
> Operation /
> > Control Virtqueue / Receive-side scaling (RSS) / RSS hash
types}.
> > > +defined in
> > > +\ref{sec:Device Types / Network Device / Device Operation /
> Processing
> > of Incoming Packets / Hash calculation for incoming packets /
> Supported/
> > enabled hash types}.
> > >
> > > Field \field{indirection_table_mask} is a mask to be applied
to
> > > the calculated hash to produce an index in the
> > > @@ -3995,93 +4192,7 @@ \subsubsection{Control Virtqueue}\
label
> {sec:Device
> > Types / Network Device / Devi
> > >
> > > A driver sets \field{max_tx_vq} to inform a device how many
> transmit
> > virtqueues it may use (transmitq1\ldots transmitq \field
{max_tx_vq}).
> > >
> > > -\subparagraph{RSS hash types}\label{sec:Device Types /
Network
> Device /
> > Device Operation / Control Virtqueue / Receive-side scaling
(RSS) /
> RSS
> > hash types}
> > > -
> > > -The device calculates the hash on IPv4 packets according to
the
> > > -field \field{hash_types} of thevirtio_net_rss_config
structure as
> > follows:
> > > -\begin{itemize}
> > > -\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv4is set and the
packet has
> > > -a TCP header, the hash is calculated over the following
fields:
> > > -\begin{itemize}
> > > -\item Source IP address
> > > -\item Destination IP address
> > > -\item Source TCP port
> > > -\item Destination TCP port
> > > -\end{itemize}
> > > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDPv4is set and the
> > > -packet has a UDP header, the hash is calculated over the
following
> > fields:
> > > -\begin{itemize}
> > > -\item Source IP address
> > > -\item Destination IP address
> > > -\item Source UDP port
> > > -\item Destination UDP port
> > > -\end{itemize}
> > > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv4is set, the hash
is
> > > -calculated over the following fields:
> > > -\begin{itemize}
> > > -\item Source IP address
> > > -\item Destination IP address
> > > -\end{itemize}
> > > -\item Else the device does not calculate the hash
> > > -\end{itemize}
> > > -
> > > -\label{itm:Device Types / Network Device / Device Operation
/
> Control
> > Virtqueue / Receive-side scaling (RSS) / RSS hash types/hash on
IPv6
> > packets without extension headers}
> > > -The device calculates the hash on IPv6 packets without
extension
> > > -headers according to the field \field{hash_types} of the
> >virtio_net_rss_configstructure as follows:
> > > -\begin{itemize}
> > > -\item IfVIRTIO_NET_RSS_HASH_TYPE_TCPv6is set and the
packet has
> > > -a TCPv6 header, the hash is calculated over the following
fields:
> > > -\begin{itemize}
> > > -\item Source IPv6 address
> > > -\item Destination IPv6 address
> > > -\item Source TCP port
> > > -\item Destination TCP port
> > > -\end{itemize}
> > > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDPv6is set and the
> > > -packet has a UDPv6 header, the hash is calculated over the
> following
> > fields:
> > > -\begin{itemize}
> > > -\item Source IPv6 address
> > > -\item Destination IPv6 address
> > > -\item Source UDP port
> > > -\item Destination UDP port
> > > -\end{itemize}
> > > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IPv6is set, the hash
is
> > > -calculated over the following fields:
> > > -\begin{itemize}
> > > -\item Source IPv6 address
> > > -\item Destination IPv6 address
> > > -\end{itemize}
> > > -\item Else the device does not calculate the hash
> > > -\end{itemize}
> > > -
> > > -The device calculates the hash on IPv6 packets with
extension
> > > -headers according to the field \field{hash_types} of the
> >virtio_net_rss_configstructure as follows:
> > > -\begin{itemize}
> > > -\item IfVIRTIO_NET_RSS_HASH_TYPE_TCP_EXis set and the
packet
> > > -has a TCPv6 header, the hash is calculated over the
following
> fields:
> > > -\begin{itemize}
> > > -\item Home address from the home address option in the IPv6
> destination
> > options header. If the extension header is not present, use the
> Source IPv6
> > address.
> > > -\item IPv6 address that is contained in the
Routing-Header-Type-2
> from
> > the associated extension header. If the extension header is not
> present,
> > use the Destination IPv6 address.
> > > -\item Source TCP port
> > > -\item Destination TCP port
> > > -\end{itemize}
> > > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_UDP_EXis set and the
> > > -packet has a UDPv6 header, the hash is calculated over the
> following
> > fields:
> > > -\begin{itemize}
> > > -\item Home address from the home address option in the IPv6
> destination
> > options header. If the extension header is not present, use the
> Source IPv6
> > address.
> > > -\item IPv6 address that is contained in the
Routing-Header-Type-2
> from
> > the associated extension header. If the extension header is not
> present,
> > use the Destination IPv6 address.
> > > -\item Source UDP port
> > > -\item Destination UDP port
> > > -\end{itemize}
> > > -\item Else ifVIRTIO_NET_RSS_HASH_TYPE_IP_EXis set, the
hash is
> > > -calculated over the following fields:
> > > -\begin{itemize}
> > > -\item Home address from the home address option in the IPv6
> destination
> > options header. If the extension header is not present, use the
> Source IPv6
> > address.
> > > -\item IPv6 address that is contained in the
Routing-Header-Type-2
> from
> > the associated extension header. If the extension header is not
> present,
> > use the Destination IPv6 address.
> > > -\end{itemize}
> > > -\item Else skip IPv6 extension headers and calculate the
hash as
> > > -defined for an IPv6 packet without extension headers (see \
ref
> > {itm:Device Types / Network Device / Device Operation / Control
> Virtqueue /
> > Receive-side scaling (RSS) / RSS hash types/hash on IPv6
packets
> without
> > extension headers}).
> > > -\end{itemize}
> > > +Fields \field{hash_key_length} and \field{hash_key_data}
define
> the key
> > to be used in hash calculation.
> > >
> > > \drivernormative{\subparagraph}{Setting RSS parameters}
{Device
> Types /
> > Network Device / Device Operation / Control Virtqueue /
Receive-side
> > scaling (RSS) }
> > >
> > > @@ -4093,12 +4204,12 @@ \subsubsection{Control Virtqueue}\
label
> > {sec:Device Types / Network Device / Devi
> > >
> > > A driver MUST use \field{indirection_table_mask} values that
are
> less
> > than \field{rss_max_indirection_table_length} reported by a
device.
> > >
> > > -A driver MUST NOT set anyVIRTIO_NET_RSS_HASH_TYPE_flags
that are
> not
> > supported by a device.
> > > +A driver MUST NOT set anyVIRTIO_NET_HASH_TYPE_flags that
are not
> > supported by a device.
> > >
> > > \devicenormative{\subparagraph}{RSS processing}{Device Types
/
> Network
> > Device / Device Operation / Control Virtqueue / Receive-side
scaling
> (RSS)
> > / RSS processing}
> > > The device MUST determine the destination queue for a
network
> packet as
> > follows:
> > > \begin{itemize}
> > > -\item Calculate the hash of the packet as defined in \ref
> {sec:Device
> > Types / Network Device / Device Operation / Control Virtqueue /
> > Receive-side scaling (RSS) / RSS hash types}
> > > +\item Calculate the hash of the packet as defined in \ref
> {sec:Device
> > Types / Network Device / Device Operation / Processing of
Incoming
> Packets
> > / Hash calculation for incoming packets}.
> > > \item If the device did not calculate the hash for the
specific
> packet,
> > the device directs the packet to the receiveq specified by \
field
> > {unclassified_queue} ofvirtio_net_rss_configstructure (value
of 0
> > corresponds to receiveq1).
> > > \item Apply \field{indirection_table_mask} to the calculated
hash
> and
> > use the result as the index in the indirection table to get
0-based
> number
> > of destination receiveq (value of 0 corresponds to receiveq1).
> > > \end{itemize}
> > > --
> > > 2.17.1
> >
> >
> > 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/
> >
> >
> >
>
>
>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.
Quoted 12 lines
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/
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/
Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
In reply to Yuri Benditovichcontent.tex \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O · line 3187
Quoted 11 lines · Yuri Benditovich
The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers
VIRTIO_NET_F_RSS.content.tex +2
-0@@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O le16 csum_start; le16 csum_offset; le16 num_buffers; + le32 hash_value; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) + le16 hash_type; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) }; \end{lstlisting}
A question here:
Consider we introduce VIRTIO_NET_F_FEATURE_INFORMATION in the future:
le32 hash_type; // VIRTIO_NET_F_HASH_REPORT
le32 feature_information; // VIRTIO_NET_F_FEATURE_INFORMATION
What happens if HASH_REPORT is not negotiated, I believe we expect a stable ABI(offset) here for feature_information?
Thanks
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/
Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
Quoted 18 lines · Jason Wang
content.tex \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O · line 3186
Quoted 10 lines · Yuri Benditovich
The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers
VIRTIO_NET_F_RSS.content.tex +2
-0@@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O le16 csum_start; le16 csum_offset; le16 num_buffers; + le32 hash_value; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) + le16 hash_type; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) }; \end{lstlisting}A question here:
Consider we introduce
VIRTIO_NET_F_FEATURE_INFORMATIONin the future:
Quoted 8 lines
le32
hash_type; //VIRTIO_NET_F_HASH_REPORT
le32feature_information; //VIRTIO_NET_F_FEATURE_INFORMATIONWhat happens if
HASH_REPORTis not negotiated, I believe we expect a stable ABI(offset) here forfeature_information?Thanks
We'll have to decide at that point ... any better ideas?
Signature · 18 lines
MST 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/
Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Jason Wang
content.tex \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O · line 3186
Quoted 10 lines · Yuri Benditovich
The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers
VIRTIO_NET_F_RSS.content.tex +2
-0@@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O le16 csum_start; le16 csum_offset; le16 num_buffers; + le32 hash_value; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) + le16 hash_type; (Only if VIRTIO_NET_F_HASH_REPORT negotiated) }; \end{lstlisting}A question here:
Consider we introduce
VIRTIO_NET_F_FEATURE_INFORMATIONin the future:le32
hash_type; //VIRTIO_NET_F_HASH_REPORT
le32feature_information; //VIRTIO_NET_F_FEATURE_INFORMATION
Quoted 6 lines
Quoted 5 lines
What happens if
HASH_REPORTis not negotiated, I believe we expect a stable ABI(offset) here forfeature_information?Thanks
We'll have to decide at that point ... any better ideas?
Not sure but something that is self descriptive? (which could be an overkill for fields that only need few bytes).
Thanks
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/
Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
----- Original Message -----
Quoted 34 lines
From: "Jason Wang" <[email protected]>
To: "Michael S. Tsirkin" <[email protected]>
Cc: "Yuri Benditovich" <[email protected]>, [email protected]
Sent: Thursday, February 20, 2020 8:38:50 AM
Subject: Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureQuoted 25 lines · Michael S. Tsirkin
Quoted 24 lines · Jason Wang
Quoted 4 lines · Yuri Benditovich
The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers
VIRTIO_NET_F_RSS.(quoted diff) +0
-0@@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:DeviceQuoted 8 lines
Types / Network Device / Device O
le16csum_start;
le16csum_offset;
le16num_buffers;
+ le32hash_value; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
+ le16hash_type; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated) };
\end{lstlisting}A question here:
Consider we introduce
VIRTIO_NET_F_FEATURE_INFORMATIONin the future:le32
hash_type; //VIRTIO_NET_F_HASH_REPORT
le32feature_information; //VIRTIO_NET_F_FEATURE_INFORMATIONWhat happens if
HASH_REPORTis not negotiated, I believe we expect a stable
ABI(offset) here forfeature_information?
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Thanks
We'll have to decide at that point ... any better ideas?
Not sure but something that is self descriptive? (which could be an overkill for fields that only need few bytes).
The problem is that the driver typically wants to know the header size from the beginning to configure SG table. So any self-descriptive layout seems good but in practice not so usable, IMO.
Quoted 17 lines
Thanks
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/
Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
Quoted 44 lines · Yuri Benditovich
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
From: "Jason Wang" <[email protected]>
To: "Michael S. Tsirkin" <[email protected]>
Cc: "Yuri Benditovich" <[email protected]>, [email protected]
Sent: Thursday, February 20, 2020 8:38:50 AM
Subject: Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureOn 2020/2/19 下午10:23, Michael S. Tsirkin wrote:
> On Wed, Feb 19, 2020 at 08:27:10PM +0800, Jason Wang wrote:
>> On 2020/2/19 下午3:53, Yuri Benditovich wrote:
>>> The device MUST set \field{rss_max_indirection_table_length} to at
least 128, if it offers
>>>VIRTIO_NET_F_RSS.
>>> @@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O
>>> le16csum_start;
>>> le16csum_offset;
>>> le16num_buffers;
>>> + le32hash_value; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
>>> + le16hash_type; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
>>> };
>>> \end{lstlisting}
>> A question here:
>>
>> Consider we introduceVIRTIO_NET_F_FEATURE_INFORMATIONin the future:
>>
>> le32hash_type; //VIRTIO_NET_F_HASH_REPORT
>> le32feature_information; //VIRTIO_NET_F_FEATURE_INFORMATION>>
>> What happens ifHASH_REPORTis not negotiated, I believe we expect a stable
>> ABI(offset) here forfeature_information?
>>
>> Thanks
>>
> We'll have to decide at that point ... any better ideas?
Quoted 6 lines
Not sure but something that is self descriptive? (which could be an overkill for fields that only need few bytes).
The problem is that the driver typically wants to know the header size from the beginning to configure SG table.
So any self-descriptive layout seems good but in practice not so usable, IMO.
We should also look at packing things more tightly down the road.
Quoted 12 lines
Thanks
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.
Quoted 12 lines
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/
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/
Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
In reply to Yuri BenditovichQuoted 44 lines · Yuri Benditovich
------------------------------------------------------------------------
*From: *"Jason Wang" <[email protected]>
*To: *"Michael S. Tsirkin" <[email protected]>
*Cc: *"Yuri Benditovich" <[email protected]>, [email protected]
*Sent: *Thursday, February 20, 2020 8:38:50 AM *Subject: *Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureOn 2020/2/19 下午10:23, Michael S. Tsirkin wrote:
> On Wed, Feb 19, 2020 at 08:27:10PM +0800, Jason Wang wrote:
>> On 2020/2/19 下午3:53, Yuri Benditovich wrote:
>>> The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers >>> VIRTIO_NET_F_RSS.
>>> @@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O >>> le16csum_start;
>>> le16csum_offset;
>>> le16num_buffers;
>>> + le32hash_value; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
>>> + le16hash_type; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
>>> };
>>> \end{lstlisting}
>> A question here:
>>
>> Consider we introduceVIRTIO_NET_F_FEATURE_INFORMATIONin the future:
>>
>> le32hash_type; //VIRTIO_NET_F_HASH_REPORT
>> le32feature_information; //VIRTIO_NET_F_FEATURE_INFORMATION>>
>> What happens ifHASH_REPORTis not negotiated, I believe we expect a stable
>> ABI(offset) here forfeature_information?
>>
>> Thanks
>>
Quoted 7 lines
> We'll have to decide at that point ... any better ideas?
Not sure but something that is self descriptive? (which could be an overkill for fields that only need few bytes).
The problem is that the driver typically wants to know the header size from the beginning to configure SG table.
Yes, so still the above example. Consider a driver only support VIRTIO_NET_F_FEATURE_INFORMATION, how to determine the size of the vnet header?
Stable offset is simpler but may waste space.
Quoted 1 line
So any self-descriptive layout seems good but in practice not so usable, IMO.
I think then it can calculate the header length based on the feature negotiated.
hdr_len = sizeof(vnet_hdr) + VIRTIO_NET_F_HASH_REPORT ? 4 : 0 + VIRTIO_NET_F_FEAUTER_INFORMATION ? 4 : 0
Thanks
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/
Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
Quoted 56 lines · Jason Wang
Quoted 44 lines · Yuri Benditovich
------------------------------------------------------------------------
*From: *"Jason Wang" <[email protected]>
*To: *"Michael S. Tsirkin" <[email protected]>
*Cc: *"Yuri Benditovich" <[email protected]>, [email protected]
*Sent: *Thursday, February 20, 2020 8:38:50 AM *Subject: *Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureOn 2020/2/19 下午10:23, Michael S. Tsirkin wrote:
> On Wed, Feb 19, 2020 at 08:27:10PM +0800, Jason Wang wrote:
>> On 2020/2/19 下午3:53, Yuri Benditovich wrote:
>>> The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers >>> VIRTIO_NET_F_RSS.
>>> @@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O >>> le16csum_start;
>>> le16csum_offset;
>>> le16num_buffers;
>>> + le32hash_value; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
>>> + le16hash_type; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
>>> };
>>> \end{lstlisting}
>> A question here:
>>
>> Consider we introduceVIRTIO_NET_F_FEATURE_INFORMATIONin the future:
>>
>> le32hash_type; //VIRTIO_NET_F_HASH_REPORT
>> le32feature_information; //VIRTIO_NET_F_FEATURE_INFORMATION>>
>> What happens ifHASH_REPORTis not negotiated, I believe we expect a stable
>> ABI(offset) here forfeature_information?
>>
>> Thanks
>>Quoted 8 lines
> We'll have to decide at that point ... any better ideas?
Not sure but something that is self descriptive? (which could be an overkill for fields that only need few bytes).
The problem is that the driver typically wants to know the header size from the beginning to configure SG table.
Quoted 5 lines
Yes, so still the above example. Consider a driver only support
VIRTIO_NET_F_FEATURE_INFORMATION, how to determine the size of the vnet header?Stable offset is simpler but may waste space.
So we have:
dev->needed_headroom = vi->hdr_len;
simply put we are going to waste space on the max header size anyway. Dynamically sizing the header for each packet is pointless, won't save memory.
Quoted 5 lines
Quoted 3 lines
So any self-descriptive layout seems good but in practice not so usable, IMO.
Quoted 7 lines
I think then it can calculate the header length based on the feature negotiated.
hdr_len=sizeof(vnet_hdr)+VIRTIO_NET_F_HASH_REPORT? 4 : 0 +VIRTIO_NET_F_FEAUTER_INFORMATION? 4 : 0Thanks
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/
Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
In reply to Jason WangQuoted 67 lines · Jason Wang
Quoted 44 lines · Yuri Benditovich
------------------------------------------------------------------------
*From: *"Jason Wang" <[email protected]>
*To: *"Michael S. Tsirkin" <[email protected]>
*Cc: *"Yuri Benditovich" <[email protected]>, [email protected]
*Sent: *Thursday, February 20, 2020 8:38:50 AM *Subject: *Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureOn 2020/2/19 下午10:23, Michael S. Tsirkin wrote:
> On Wed, Feb 19, 2020 at 08:27:10PM +0800, Jason Wang wrote:
>> On 2020/2/19 下午3:53, Yuri Benditovich wrote:
>>> The device MUST set \field{rss_max_indirection_table_length} to at least 128, if it offers >>> VIRTIO_NET_F_RSS.
>>> @@ -3195,6 +3180,8 @@ \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O >>> le16csum_start;
>>> le16csum_offset;
>>> le16num_buffers;
>>> + le32hash_value; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
>>> + le16hash_type; (Only ifVIRTIO_NET_F_HASH_REPORTnegotiated)
>>> };
>>> \end{lstlisting}
>> A question here:
>>
>> Consider we introduceVIRTIO_NET_F_FEATURE_INFORMATIONin the future:
>>
>> le32hash_type; //VIRTIO_NET_F_HASH_REPORT
>> le32feature_information; //VIRTIO_NET_F_FEATURE_INFORMATION>>
>> What happens ifHASH_REPORTis not negotiated, I believe we expect a stable
>> ABI(offset) here forfeature_information?
>>
>> Thanks
>>Quoted 8 lines
> We'll have to decide at that point ... any better ideas?
Not sure but something that is self descriptive? (which could be an overkill for fields that only need few bytes).
The problem is that the driver typically wants to know the header size from the beginning to configure SG table.
Yes, so still the above example. Consider a driver only support
VIRTIO_NET_F_FEATURE_INFORMATION, how to determine the size of the vnet header?Stable offset is simpler but may waste space.
Quoted 2 lines
So any self-descriptive layout seems good but in practice not so usable, IMO.
Quoted 7 lines
I think then it can calculate the header length based on the feature negotiated.
hdr_len=sizeof(vnet_hdr)+VIRTIO_NET_F_HASH_REPORT? 4 : 0 +VIRTIO_NET_F_FEAUTER_INFORMATION? 4 : 0Thanks
For sure that's basically what this proposal amounts to, anyway.
Signature · 18 lines
MST 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/
Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting feature
In reply to Jason Wang----- Original Message -----
Quoted 68 lines
From: "Jason Wang" <[email protected]>
To: "Yuri Benditovich" <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>, "Yuri Benditovich" <[email protected]>, [email protected]
Sent: Thursday, February 20, 2020 10:11:51 AM
Subject: Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureQuoted 44 lines · Yuri Benditovich
------------------------------------------------------------------------
*From: *"Jason Wang" <[email protected]>
*To: *"Michael S. Tsirkin" <[email protected]>
*Cc: *"Yuri Benditovich" <[email protected]>, [email protected]
*Sent: *Thursday, February 20, 2020 8:38:50 AM *Subject: *Re: [virtio-comment] [PATCH v4 1/1] virtio-net: Define per-packet hash reporting featureQuoted 3 lines · Michael S. Tsirkin
Quoted 2 lines · Jason Wang
Quoted 1 line · Yuri Benditovich
The device MUST set
\field{rss_max_indirection_table_length} to at least 128, if it offers
Quoted 2 lines
Quoted 2 lines
Review \subsection{Device
Quoted 2 lines
VIRTIO_NET_F_RSS.(quoted diff) +0
-0@@ -3195,6 +3180,8 @@ \subsection{DeviceOperation}\label{sec:Device Types / Network Device / Device O
Quoted 4 lines
Quoted 4 lines
content.tex \subsection{Device Operation}\label{sec:Device Types / Network Device / Device O
Quoted 4 lines
content.tex +1
-0le16 csum_start; le16 csum_offset; le16 num_buffers; + le32 hash_value; (Only if VIRTIO_NET_F_HASH_REPORTnegotiated)
Quoted 1 line
Quoted 1 line
Review \subsection{Device · line 3184
Quoted 1 line
(quoted diff) +1
-0+ le16 hash_type; (Only if VIRTIO_NET_F_HASH_REPORTnegotiated)
Quoted 5 lines
Quoted 5 lines
Review \subsection{Device · line 3186
Quoted 2 lines
(quoted diff) +0
-0}; \end{lstlisting}A question here:
Consider we introduce
VIRTIO_NET_F_FEATURE_INFORMATIONin thefuture:
Quoted 5 lines
Quoted 5 lines
le32
hash_type; //VIRTIO_NET_F_HASH_REPORT
le32feature_information; //VIRTIO_NET_F_FEATURE_INFORMATIONWhat happens if
HASH_REPORTis not negotiated, I believe weexpect a stable
Quoted 4 lines
Quoted 4 lines
ABI(offset) here for
feature_information?Thanks
Quoted 8 lines
Quoted 1 line
We'll have to decide at that point ... any better ideas?
Not sure but something that is self descriptive? (which could be an overkill for fields that only need few bytes).
The problem is that the driver typically wants to know the header size from the beginning to configure SG table.
Yes, so still the above example. Consider a driver only support
VIRTIO_NET_F_FEATURE_INFORMATION, how to determine the size of the vnet header?Stable offset is simpler but may waste space.
Quoted 8 lines
Quoted 2 lines
So any self-descriptive layout seems good but in practice not so usable, IMO.
I think then it can calculate the header length based on the feature negotiated.
hdr_len=sizeof(vnet_hdr)+VIRTIO_NET_F_HASH_REPORT? 4 : 0 +VIRTIO_NET_F_FEAUTER_INFORMATION? 4 : 0
Also possible.
We'll need to define it as soon as we define in the spec the second feature affecting packet size. There is also another point raised by Michael some time ago: different packet layouts for TX and RX.
Quoted 17 lines
Thanks
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/