Introducing RSS to virtio-net
v3 cover Introducing RSS to virtio-net
From: Sameeh Jubran <[email protected]>
Please ignore the feature number value (60) in the patch, it is not final for now.
Difference from v2:
* Dropped RSS_HASH_FUNCTION_NONE flag from RSS as it seems to be useless.
* Added more comments to the code.
* Beautifications.
* Fixed some sentences to make them clearer.
Sameeh Jubran (2):
content: net: Add VIRTIO_NET_F_CTRL_STEERING_MODE feature
content: net: steering mode: Add RSS
content.tex | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+)
Signature · 6 lines
2.13.6 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
PATCH v3 1/2 content: net: Add VIRTIO_NET_F_CTRL_STEERING_MODE feature
From: Sameeh Jubran <[email protected]>
This commit introduces steering mode into network device. Steering mode is a general infrastructure for various steering modes that can be implemented on top of it such as Automatic and RSS.
--- content.tex | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
content.tex +61 -0
@@ -3115,6 +3115,9 @@ features. \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control channel. + +\item[VIRTIO_NET_F_CTRL_STEERING_MODE(60)] Device supports configurable steering + mode. \end{description} \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device / Feature bits / Feature bit requirements}
@@ -3317,6 +3320,8 @@ struct virtio_net_hdr { le16 csum_start; le16 csum_offset; le16 num_buffers; +// Only if VIRTIO_NET_F_CTRL_STEERING_MODE has been negotiated + le64 hash; }; \end{lstlisting}
@@ -4013,6 +4018,62 @@ MUST format \field{virtqueue_pairs} according to the native endian of the guest rather than (necessarily when not using the legacy interface) little-endian. +\paragraph{Steering mode}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode} + +\begin{lstlisting} +// steering mode flags +#define STEERING_MODE_AUTO 0x1 + +// Used by the devide for returning to the driver the supported steering modes +struct virtio_net_steering_modes { +le32 steering_modes; +}; + +struct virtio_net_steering_mode { +le32 steering_mode; +le32 command; + +// A union which can be used for passing structures to one of the sub modes + union { + } +}; + +#define VIRTIO_NET_F_CTRL_STEERING_MODE 27 + +#define VIRTIO_NET_CTRL_STEERING_MODE 7 +#define VIRTIO_NET_CTRL_SM_GET_SUPPORTED_MODES 0 +#define VIRTIO_NET_CTRL_SM_CONTROL 1 +\end{lstlisting} + +If the VIRTIO_NET_F_CTRL_STEERING_MODE is negotiated the driver can send control commands for the +configuring the steering mode. There are multiple steering modes and they can be configured using +the VIRTIO_NET_CTRL_SM_CONTROL command. Each mode has it's own set of commands. + +The auto steering mode is the default mode if nothing else has been configured by the driver +and the VIRTIO_NET_F_CTRL_STEERING_MODE feature is acked by the driver. + +The class VIRTIO_NET_CTRL_STEERING_MODE has two commands: + +\begin{enumerate} + +\item VIRTIO_NET_CTRL_SM_GET_SUPPORTED_MODES is used for getting the supported steering modes by the device. + The command should be executed by the driver before attempting to configure the steering mode. Once the device + receives this command it should fill the virtio_net_steering_modes structure with the supported steering mode + flags. + +\item The command VIRTIO_NET_CTRL_SM_CONTROL is used for controlling the different steering modes. Each steering mode + has its own set of commands. When executing this command the structure virtio_net_steering_mode should be used as follows: + the \field{steering_mode} should be filled with one of the steering mode flags along with an appropriate command from the chosen + steering mode. The union of virtio_net_steering_mode should be used and filled as the mode's command suggests. +\end{enumerate} + +If this feature has been negotiated, the virtio header has an additional +\field{hash} field attached to it. + +\subparagraph{Automatic Receive Steering}{Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode / Automatic Receive Steering} + +This is the default steering mode, please refer to the "Automatic receive steering in multiqueue" section. + \paragraph{Offloads State Configuration}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Offloads State Configuration} If the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature is negotiated, the driver can
Signature · 6 lines
2.13.6 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v3 1/2] content: net: Add VIRTIO_NET_F_CTRL_STEERING_MODE feature
Hi Sameeh,
See inline..
Quoted 74 lines · Sameeh Jubran
From: Sameeh Jubran <[email protected]>
This commit introduces steering mode into network device. Steering mode is a general infrastructure for various steering modes that can be implemented on top of it such as Automatic and RSS.
Signed-off-by Sameeh Jubran <[email protected]>--- content.tex | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)content.tex +41
-0@@ -3115,6 +3115,9 @@ features. \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control channel. + +\item[VIRTIO_NET_F_CTRL_STEERING_MODE(60)] Device supports configurable steering + mode. \end{description} \subsubsection{Feature bit requirements}\label{sec:Device Types / Network Device / Feature bits / Feature bit requirements}@@ -3317,6 +3320,8 @@ struct virtio_net_hdr { le16 csum_start; le16 csum_offset; le16 num_buffers; +// Only if VIRTIO_NET_F_CTRL_STEERING_MODE has been negotiated + le64 hash; }; \end{lstlisting}@@ -4013,6 +4018,62 @@ MUST format \field{virtqueue_pairs} according to the native endian of the guest rather than (necessarily when not using the legacy interface) little-endian. +\paragraph{Steering mode}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode} + +\begin{lstlisting} +// steering mode flags +#define STEERING_MODE_AUTO 0x1 + +// Used by the devide for returning to the driver the supported steering modes +struct virtio_net_steering_modes { +le32 steering_modes; +}; + +struct virtio_net_steering_mode { +le32 steering_mode; +le32 command; + +// A union which can be used for passing structures to one of the sub modes + union { + } +}; + +#define VIRTIO_NET_F_CTRL_STEERING_MODE 27 + +#define VIRTIO_NET_CTRL_STEERING_MODE 7 +#define VIRTIO_NET_CTRL_SM_GET_SUPPORTED_MODES 0 +#define VIRTIO_NET_CTRL_SM_CONTROL 1 +\end{lstlisting} + +If the VIRTIO_NET_F_CTRL_STEERING_MODE is negotiated the driver can send control commands for the +configuring the steering mode. There are multiple steering modes and they can be configured using +the VIRTIO_NET_CTRL_SM_CONTROL command. Each mode has it's own set of commands. + +The auto steering mode is the default mode if nothing else has been configured by the driver +and the VIRTIO_NET_F_CTRL_STEERING_MODE feature is acked by the driver. + +The class VIRTIO_NET_CTRL_STEERING_MODE has two commands: +
content.tex MUST format \field{virtqueue_pairs} · line 4066
Quoted 10 lines
content.tex +10
-0+\begin{enumerate} + +\item VIRTIO_NET_CTRL_SM_GET_SUPPORTED_MODES is used for getting the supported steering modes by the device. + The command should be executed by the driver before attempting to configure the steering mode. Once the device + receives this command it should fill the virtio_net_steering_modes structure with the supported steering mode + flags. + +\item The command VIRTIO_NET_CTRL_SM_CONTROL is used for controlling the different steering modes. Each steering mode + has its own set of commands. When executing this command the structure virtio_net_steering_mode should be used as follows: + the \field{steering_mode} should be filled with one of the steering mode flags along with an appropriate command from the chosen
should we say? should be filled with one of the supported steering mode
content.tex MUST format \field{virtqueue_pairs} · line 4070
Quoted 4 lines
content.tex +4
-0+ steering mode. The union of virtio_net_steering_mode should be used and filled as the mode's command suggests. +\end{enumerate} + +If this feature has been negotiated, the virtio header has an additional
should say:
virtio net header has an additional
content.tex MUST format \field{virtqueue_pairs} · line 4075
Quoted 5 lines
content.tex +5
-0+\field{hash} field attached to it. + +\subparagraph{Automatic Receive Steering}{Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode / Automatic Receive Steering} + +This is the default steering mode, please refer to the "Automatic receive steering in multiqueue" section.
I see referred section named in the spec as "Automatic receive steering in multiqueue mode".
content.tex MUST format \field{virtqueue_pairs} · line 4079
Quoted 4 lines
content.tex +1
-0+ \paragraph{Offloads State Configuration}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Offloads State Configuration} If the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature is negotiated, the driver can
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v3 1/2] content: net: Add VIRTIO_NET_F_CTRL_STEERING_MODE feature
Quoted 96 lines · Vijayabhaskar Balakrishna
Hi Sameeh,
See inline..
Quoted 90 lines · Sameeh Jubran
From: Sameeh Jubran <[email protected]>
This commit introduces steering mode into network device. Steering mode is a general infrastructure for various steering modes that can be implemented on top of it such as Automatic and RSS.
Signed-off-by Sameeh Jubran <[email protected]>--- content.tex | 61 ++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)content.tex +2
-0@@ -3115,6 +3115,9 @@ features. \item[VIRTIO_NET_F_CTRL_MAC_ADDR(23)] Set MAC address through control channel. + +\item[VIRTIO_NET_F_CTRL_STEERING_MODE(60)] Device supports configurablesteering
+ mode.
\end{description}
\subsubsection{Feature bit requirements}\label{sec:Device Types /
Network Device / Feature bits / Feature bit requirements}content.tex +2
-0@@ -3317,6 +3320,8 @@ struct virtio_net_hdr { le16 csum_start; le16 csum_offset; le16 num_buffers; +// Only if VIRTIO_NET_F_CTRL_STEERING_MODE has been negotiated + le64 hash; }; \end{lstlisting} @@ -4013,6 +4018,62 @@ MUST format \field{virtqueue_pairs}according to the native endian of the guest rather than (necessarily when not using the legacy interface) little-endian. +\paragraph{Steering mode}\label{sec:Device Types / Network Device /
Device Operation / Control Virtqueue / Steering mode}content.tex +6
-0+ +\begin{lstlisting} +// steering mode flags +#define STEERING_MODE_AUTO 0x1 + +// Used by the devide for returning to the driver the supported steeringmodes
content.tex +9
-0+struct virtio_net_steering_modes { +le32 steering_modes; +}; + +struct virtio_net_steering_mode { +le32 steering_mode; +le32 command; + +// A union which can be used for passing structures to one of the submodes
content.tex +12
-0+ union { + } +}; + +#define VIRTIO_NET_F_CTRL_STEERING_MODE 27 + +#define VIRTIO_NET_CTRL_STEERING_MODE 7 +#define VIRTIO_NET_CTRL_SM_GET_SUPPORTED_MODES 0 +#define VIRTIO_NET_CTRL_SM_CONTROL 1 +\end{lstlisting} + +If the VIRTIO_NET_F_CTRL_STEERING_MODE is negotiated the driver cansend control commands for the
+configuring the steering mode. There are multiple steering modes and they can be configured using
+theVIRTIO_NET_CTRL_SM_CONTROLcommand. Each mode has it's own set of commands.content.tex +2
-0+ +The auto steering mode is the default mode if nothing else has beenconfigured by the driver
content.tex +7
-0+and the VIRTIO_NET_F_CTRL_STEERING_MODE feature is acked by the driver. + +The class VIRTIO_NET_CTRL_STEERING_MODE has two commands: + +\begin{enumerate} + +\item VIRTIO_NET_CTRL_SM_GET_SUPPORTED_MODES is used for getting thesupported steering modes by the device.
+ The command should be executed by the driver before attempting to
configure the steering mode. Once the device
+ receives this command it should fill thevirtio_net_steering_modesstructure with the supported steering modecontent.tex +2
-0+ flags. +
Quoted 8 lines
Quoted 7 lines
+\item The command
VIRTIO_NET_CTRL_SM_CONTROLis used for controlling the different steering modes. Each steering mode
+ has its own set of commands. When executing this command the
structurevirtio_net_steering_modeshould be used as follows:
+ the \field{steering_mode} should be filled with one of the
steering mode flags along with an appropriate command from the chosenshould we say? should be filled with one of the supported steering mode
since it is more accurate, we can do that
Quoted 8 lines
+ steering mode. The union of
virtio_net_steering_modeshould becontent.tex
Quoted 5 lines
used and filled as the mode's command suggests.
+\end{enumerate}content.tex +2
-0+ +If this feature has been negotiated, the virtio header has an additionalshould say:
virtio net header has an additional
True, I'll change that
Quoted 12 lines
+\field{hash} field attached to it.
Quoted 8 lines
+
+\subparagraph{Automatic Receive Steering}{Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode / Automatic Receive Steering}content.tex +2
-0+ +This is the default steering mode, please refer to the "Automaticreceive steering in multiqueue" section.
I see referred section named in the spec as "Automatic receive steering in multiqueue mode".
I'll add "mode" to this, thanks for catching that
Quoted 9 lines
+
Quoted 6 lines
\paragraph{Offloads State Configuration}\label{sec:Device Types /
Network Device / Device Operation / Control Virtqueue / Offloads State Configuration}
If theVIRTIO_NET_F_CTRL_GUEST_OFFLOADSfeature is negotiated, the
driver can
Signature · 4 lines
Respectfully, *Sameeh Jubran* *Linkedin <https://il.linkedin.com/pub/sameeh-jubran/87/747/a8a>* *Software Engineer @ Daynix <http://www.daynix.com>.*
PATCH v3 2/2 content: net: steering mode: Add RSS
In reply to Sameeh JubranFrom: Sameeh Jubran <[email protected]>
This commit introduces the RSS feature into virtio-net. It is introduced as a sub mode for a general command which configures the steering mode.
Most modern high end network devices today support configurable hash functions, this commit introduces RSS - Receive Side Scaling - [1] to virtio net device.
The RSS is a technology from Microsoft that boosts network device performance by efficiently distributing the traffic among the CPUs in a multiprocessor system.
This feature is supported in most of the modern network cards as well as most modern OSes including Linux and Windows. It is worth mentioning that both DPDK and Hyper-v support RSS too.
[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/network/ndis-receive-side-scaling2
--- content.tex | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+)
content.tex +109 -0
@@ -4023,6 +4023,7 @@ according to the native endian of the guest rather than \begin{lstlisting} // steering mode flags #define STEERING_MODE_AUTO 0x1 +#define STEERING_MODE_RSS 0x2 // Used by the devide for returning to the driver the supported steering modes struct virtio_net_steering_modes {
@@ -4035,6 +4036,7 @@ le32 command; // A union which can be used for passing structures to one of the sub modes union { + struct virtio_net_rss rss_conf; } };
@@ -4074,6 +4076,113 @@ If this feature has been negotiated, the virtio header has an additional This is the default steering mode, please refer to the "Automatic receive steering in multiqueue" section. +\subparagraph{Receive Side Scaling}{Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode / Receive Side Scaling} + +\begin{lstlisting} +#define RSS_HASH_FUNCTION_TOEPLITZ 0x1 +#define RSS_HASH_FUNCTION_SYMMETRIC 0x2 + +// Hash function fields +#define RSS_HASH_FIELDS_IPV4 0x00000100 +#define RSS_HASH_FIELDS_TCP_IPV4 0x00000200 +#define RSS_HASH_FIELDS_IPV6 0x00000400 +#define RSS_HASH_FIELDS_IPV6_EX 0x00000800 +#define RSS_HASH_FIELDS_TCP_IPV6 0x00001000 +#define RSS_HASH_FIELDS_TCP_IPV6_EX 0x00002000 + +struct virtio_net_rss_supported_hash{ +le32 hash_function; +} + +struct virtio_net_rss { +le32 hash_function; +le32 hash_function_flags; +le32 hash_key_length; +le32 indirection_table_length; + struct { + le32 hash_key[hash_key_length]; + le32 indirection_table[indirection_table_length]; + } +}; + +#define VIRTIO_NET_SM_CTRL_RSS_GET_SUPPORTED_FUNCTIONS 0 +#define VIRTIO_NET_SM_CTRL_RSS_SET 1 +\end{lstlisting} + +If the VIRTIO_NET_F_CTRL_STEERING_MODE is negotiated the driver can send control +commands using the VIRTIO_NET_CTRL_SM_CONTROL command along with the STEERING_MODE_RSS +flag for configuring RSS the virtio_net_steering_mode should be filled. The +\field{steering_mode} field should be filled with the STEERING_MODE_RSS flag along +with one of the VIRTIO_NET_SM_CTRL_RSS commands in the \field{command} field. The +\field{rss_conf} field should be used. + +The class VIRTIO_NET_CTRL_RSS has two commands: + +\begin{enumerate} +\item VIRTIO_NET_SM_CTRL_RSS_GET_SUPPORTED_FUNCTIONS returns the hash functions + supported by the device to the driver. +\item VIRTIO_NET_SM_CTRL_RSS_SET applies the new RSS configuration. The command is + used by the driver for setting RSS hash function, hash key and + indirection table in the device. +\end{enumerate} + +\devicenormative{\subparagraph}{Receive Side Scaling}{Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode / Receive Side Scaling} + +The device MUST fill the virtio_net_rss_supported_hash structure with the hash +functions it supports and return the structure to the driver. One or more +flags of the RSS_HASH_FUNCTION flags MUST be used to fill the \field{hash_function} +field. + +The device MUST drop all previous RSS configuration upon receiving +VIRTIO_NET_SM_CTRL_RSS_SET command. + +The device MUST set the RSS configuration according to the settings provided as +follows, once the configuration process is completed the device SHOULD apply +the hash function to each of the incoming packets with regards to the flags in +the \field{hash_function_flags} fields and distribute the packets through the +virqueues using the calculated hash and the indirection table that were earlier +provided by the driver. + +Setting RSS configuration +\begin{enumerate} +\item The driver fills all of the fields and passes them through the control + queue to the device. + +\item The device sets the RSS configuration as provided by the driver. + +\item If the device successfully applied the configuration, on each packet + received the device MUST calculate the hash for the packet using + the fields specified in \field{hash_function_flags} and store it in the + virtio-net header in the \field{hash} field and the hash fields + used in the calculation. +\end{enumerate} + +\drivernormative{\subparagraph}{Receive Side Scaling}{Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode / Receive Side Scaling} + +If the driver wants to set RSS hash it should fill the RSS structure fields +as follows: + +\begin{itemize} +\item The driver SHOULD choose the hash function that SHOULD be used and fill + it in the \field{hash_function} field along with the appropriate flags + in the \field{hash_function_flags} field. These flags indicate to the + device which packet fields MUST be used in the calculation process of + the hash. +\item Once the hash function has been chosen a hash key should also be set by + the driver in the \field{hash_key} field, the length of the key should + be stored in the \field{hash_key_length} field. +\item Lastly the driver should fill the indirection table array in the + \field{indirection_table} field while setting the array length in + \field{indirection_table_length}. This structure is used by the device + for determining in which RX virt queue the packet should be placed. +\end{itemize} +Once the configuration phase is over successfully, the packets SHOULD have the +\field{hash} field with the hash value that was calculated by the device. + +Whenever the driver wants to stop performing RSS, it can switch back to +Automatic Steering Mode using the VIRTIO_NET_CTRL_SM_CONTROL command along with +the STEERING_MODE_AUTO flag. + \paragraph{Offloads State Configuration}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Offloads State Configuration} If the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature is negotiated, the driver can
Signature · 6 lines
2.13.6 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v3 2/2] content: net: steering mode: Add RSS
Hi Sameeh,
See inline..
Thanks,
Vijay
Quoted 76 lines · Sameeh Jubran
From: Sameeh Jubran <[email protected]>
This commit introduces the RSS feature into virtio-net. It is introduced as a sub mode for a general command which configures the steering mode.
Most modern high end network devices today support configurable hash functions, this commit introduces RSS - Receive Side Scaling - [1] to virtio net device.
The RSS is a technology from Microsoft that boosts network device performance by efficiently distributing the traffic among the CPUs in a multiprocessor system.
This feature is supported in most of the modern network cards as well as most modern OSes including Linux and Windows. It is worth mentioning that both DPDK and Hyper-v support RSS too.
[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/network/ndis-receive-side-scaling2
Signed-off-by Sameeh Jubran <[email protected]>--- content.tex | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+)content.tex +31
-0@@ -4023,6 +4023,7 @@ according to the native endian of the guest rather than \begin{lstlisting} // steering mode flags #define STEERING_MODE_AUTO 0x1 +#define STEERING_MODE_RSS 0x2 // Used by the devide for returning to the driver the supported steering modes struct virtio_net_steering_modes {@@ -4035,6 +4036,7 @@ le32 command; // A union which can be used for passing structures to one of the sub modes union { + struct virtio_net_rss rss_conf; } };@@ -4074,6 +4076,113 @@ If this feature has been negotiated, the virtio header has an additional This is the default steering mode, please refer to the "Automatic receive steering in multiqueue" section. +\subparagraph{Receive Side Scaling}{Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode / Receive Side Scaling} + +\begin{lstlisting} +#define RSS_HASH_FUNCTION_TOEPLITZ 0x1 +#define RSS_HASH_FUNCTION_SYMMETRIC 0x2 + +// Hash function fields +#define RSS_HASH_FIELDS_IPV4 0x00000100 +#define RSS_HASH_FIELDS_TCP_IPV4 0x00000200 +#define RSS_HASH_FIELDS_IPV6 0x00000400 +#define RSS_HASH_FIELDS_IPV6_EX 0x00000800 +#define RSS_HASH_FIELDS_TCP_IPV6 0x00001000 +#define RSS_HASH_FIELDS_TCP_IPV6_EX 0x00002000 + +struct virtio_net_rss_supported_hash{ +le32 hash_function; +} + +struct virtio_net_rss { +le32 hash_function; +le32 hash_function_flags; +le32 hash_key_length; +le32 indirection_table_length; + struct { + le32 hash_key[hash_key_length]; + le32 indirection_table[indirection_table_length]; + } +}; +
content.tex If this feature has been negotiated, the virtio header has an additional · line 4117
Quoted 10 lines
content.tex +10
-0+#define VIRTIO_NET_SM_CTRL_RSS_GET_SUPPORTED_FUNCTIONS 0 +#define VIRTIO_NET_SM_CTRL_RSS_SET 1 +\end{lstlisting} + +If the VIRTIO_NET_F_CTRL_STEERING_MODE is negotiated the driver can send control +commands using the VIRTIO_NET_CTRL_SM_CONTROL command along with the STEERING_MODE_RSS +flag for configuring RSS the virtio_net_steering_mode should be filled. The +\field{steering_mode} field should be filled with the STEERING_MODE_RSS flag along +with one of the VIRTIO_NET_SM_CTRL_RSS commands in the \field{command} field. The +\field{rss_conf} field should be used.
May be reworded for clarify along the lines: If theVIRTIO_NET_F_CTRL_STEERING_MODE feature bit is negotiated, the driver can send steering mode control command, VIRTIO_NET_CTRL_SM_CONTROL, with the STEERING_MODE_RSSflag for configuring RSS provided it is one of the supported modes. The supported steering modes returned by device in response to VIRTIO_NET_CTRL_SM_GET_SUPPORTED_MODES command issued by the driver. For configuring particulars of RSS steering mode, the various fields of virtio_net_steering_mode should be filled by the driver. This includes \field{steering_mode} with STEERING_MODE_RSS flag along
with one of the VIRTIO_NET_SM_CTRL_RSS commands in the \field{command} field in addition to union \field{rss_conf} field members.
Quoted 55 lines
content.tex +55
-0+ +The class VIRTIO_NET_CTRL_RSS has two commands: + +\begin{enumerate} +\item VIRTIO_NET_SM_CTRL_RSS_GET_SUPPORTED_FUNCTIONS returns the hash functions + supported by the device to the driver. +\item VIRTIO_NET_SM_CTRL_RSS_SET applies the new RSS configuration. The command is + used by the driver for setting RSS hash function, hash key and + indirection table in the device. +\end{enumerate} + +\devicenormative{\subparagraph}{Receive Side Scaling}{Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode / Receive Side Scaling} + +The device MUST fill the virtio_net_rss_supported_hash structure with the hash +functions it supports and return the structure to the driver. One or more +flags of the RSS_HASH_FUNCTION flags MUST be used to fill the \field{hash_function} +field. + +The device MUST drop all previous RSS configuration upon receiving +VIRTIO_NET_SM_CTRL_RSS_SET command. + +The device MUST set the RSS configuration according to the settings provided as +follows, once the configuration process is completed the device SHOULD apply +the hash function to each of the incoming packets with regards to the flags in +the \field{hash_function_flags} fields and distribute the packets through the +virqueues using the calculated hash and the indirection table that were earlier +provided by the driver. + +Setting RSS configuration +\begin{enumerate} +\item The driver fills all of the fields and passes them through the control + queue to the device. + +\item The device sets the RSS configuration as provided by the driver. + +\item If the device successfully applied the configuration, on each packet + received the device MUST calculate the hash for the packet using + the fields specified in \field{hash_function_flags} and store it in the + virtio-net header in the \field{hash} field and the hash fields + used in the calculation. +\end{enumerate} + +\drivernormative{\subparagraph}{Receive Side Scaling}{Device Types / Network Device / Device Operation / Control Virtqueue / Steering mode / Receive Side Scaling} + +If the driver wants to set RSS hash it should fill the RSS structure fields +as follows: + +\begin{itemize} +\item The driver SHOULD choose the hash function that SHOULD be used and fill + it in the \field{hash_function} field along with the appropriate flags + in the \field{hash_function_flags} field. These flags indicate to the + device which packet fields MUST be used in the calculation process of + the hash. +\item Once the hash function has been chosen a hash key should also be set by + the driver in the \field{hash_key} field, the length of the key should
content.tex If this feature has been negotiated, the virtio header has an additional · line 4182
Quoted 10 lines
content.tex +10
-0+ be stored in the \field{hash_key_length} field. +\item Lastly the driver should fill the indirection table array in the + \field{indirection_table} field while setting the array length in + \field{indirection_table_length}. This structure is used by the device + for determining in which RX virt queue the packet should be placed. +\end{itemize} +Once the configuration phase is over successfully, the packets SHOULD have the +\field{hash} field with the hash value that was calculated by the device. + +Whenever the driver wants to stop performing RSS, it can switch back to
Should we say: ..stop performing RSS or any earlier configured steering mode,
content.tex If this feature has been negotiated, the virtio header has an additional · line 4188
Quoted 6 lines
content.tex +3
-0+Automatic Steering Mode using the VIRTIO_NET_CTRL_SM_CONTROL command along with +the STEERING_MODE_AUTO flag. + \paragraph{Offloads State Configuration}\label{sec:Device Types / Network Device / Device Operation / Control Virtqueue / Offloads State Configuration} If the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature is negotiated, the driver can
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [virtio-dev] [PATCH v3 2/2] content: net: steering mode: Add RSS
Quoted 116 lines · Vijayabhaskar Balakrishna
Hi Sameeh,
See inline..
Thanks,
VijayQuoted 91 lines · Sameeh Jubran
From: Sameeh Jubran <[email protected]>
This commit introduces the RSS feature into virtio-net. It is introduced as a sub mode for a general command which configures the steering mode.
Most modern high end network devices today support configurable hash functions,
this commit introduces RSS - Receive Side Scaling - [1] to virtio net device.The RSS is a technology from Microsoft that boosts network device performance
by efficiently distributing the traffic among the CPUs in a multiprocessor system.This feature is supported in most of the modern network cards as well as most
modern OSes including Linux and Windows. It is worth mentioning that both DPDK
and Hyper-v support RSS too.[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/ne
twork/ndis-receive-side-scaling2Signed-off-by Sameeh Jubran <[email protected]>--- content.tex | 109 ++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+)content.tex +0
-0@@ -4023,6 +4023,7 @@ according to the native endian of the guest ratherthan
\begin{lstlisting}
// steering mode flags
#defineSTEERING_MODE_AUTO0x1
+#defineSTEERING_MODE_RSS0x2// Used by the devide for returning to the driver the supportedsteering modes
structvirtio_net_steering_modes{content.tex +0
-0@@ -4035,6 +4036,7 @@ le32 command; // A union which can be used for passing structures to one of the submodes
union { + struct virtio_net_rss rss_conf; }};
@@ -4074,6 +4076,113 @@ If this feature has been negotiated, the virtio
header has an additional
This is the default steering mode, please refer to the "Automatic
receive steering in multiqueue" section.
+\subparagraph{Receive Side Scaling}{Device Types / Network Device /
Device Operation / Control Virtqueue / Steering mode / Receive Side Scaling}content.tex +33
-0+ +\begin{lstlisting} +#define RSS_HASH_FUNCTION_TOEPLITZ 0x1 +#define RSS_HASH_FUNCTION_SYMMETRIC 0x2 + +// Hash function fields +#define RSS_HASH_FIELDS_IPV4 0x00000100 +#define RSS_HASH_FIELDS_TCP_IPV4 0x00000200 +#define RSS_HASH_FIELDS_IPV6 0x00000400 +#define RSS_HASH_FIELDS_IPV6_EX 0x00000800 +#define RSS_HASH_FIELDS_TCP_IPV6 0x00001000 +#define RSS_HASH_FIELDS_TCP_IPV6_EX 0x00002000 + +struct virtio_net_rss_supported_hash{ +le32 hash_function; +} + +struct virtio_net_rss { +le32 hash_function; +le32 hash_function_flags; +le32 hash_key_length; +le32 indirection_table_length; + struct { + le32 hash_key[hash_key_length]; + le32 indirection_table[indirection_table_length]; + } +}; + +#define VIRTIO_NET_SM_CTRL_RSS_GET_SUPPORTED_FUNCTIONS 0 +#define VIRTIO_NET_SM_CTRL_RSS_SET 1 +\end{lstlisting} + +If the VIRTIO_NET_F_CTRL_STEERING_MODE is negotiated the driver cansend control
+commands using theVIRTIO_NET_CTRL_SM_CONTROLcommand along with theQuoted 9 lines
STEERING_MODE_RSS
+flag for configuring RSS thevirtio_net_steering_modeshould be filled. The
+\field{steering_mode} field should be filled with theSTEERING_MODE_RSSflag along
+with one of theVIRTIO_NET_SM_CTRL_RSScommands in the \field{command} field. The
+\field{rss_conf} field should be used.May be reworded for clarify along the lines: If
theVIRTIO_NET_F_CTRL_STEERING_MODE
feature bit is negotiated, the driver can send steering mode control command,VIRTIO_NET_CTRL_SM_CONTROL, with theSTEERING_MODE_RSSflagfor configuring RSS provided
it is one of the supported modes. The supported steering modes returned
Quoted 8 lines
by device in
response toVIRTIO_NET_CTRL_SM_GET_SUPPORTED_MODEScommand issued by the driver.
For configuring particulars of RSS steering mode, the various fields ofvirtio_net_steering_modeshould be filled by the driver. This includes \field{steering_mode} withSTEERING_MODE_RSSflag along with one of theVIRTIO_NET_SM_CTRL_RSScommands in the \field{command} field in addition to union \field{rss_conf} field members.
Thanks for the suggestions, I'll rephrase the paragraph based on the above.
Quoted 87 lines
+
Quoted 85 lines
content.tex +4
-0+The class VIRTIO_NET_CTRL_RSS has two commands: + +\begin{enumerate} +\item VIRTIO_NET_SM_CTRL_RSS_GET_SUPPORTED_FUNCTIONS returns the hashfunctions
+ supported by the device to the driver.
+\itemVIRTIO_NET_SM_CTRL_RSS_SETapplies the new RSS configuration. The command iscontent.tex +5
-0+ used by the driver for setting RSS hash function, hash key and + indirection table in the device. +\end{enumerate} + +\devicenormative{\subparagraph}{Receive Side Scaling}{Device Types /Network Device / Device Operation / Control Virtqueue / Steering mode / Receive Side Scaling}
content.tex +2
-0+ +The device MUST fill the virtio_net_rss_supported_hash structure withthe hash
content.tex +2
-0+functions it supports and return the structure to the driver. One or more +flags of the RSS_HASH_FUNCTION flags MUST be used to fill the\field{hash_function}
content.tex +6
-0+field. + +The device MUST drop all previous RSS configuration upon receiving +VIRTIO_NET_SM_CTRL_RSS_SET command. + +The device MUST set the RSS configuration according to the settingsprovided as
+follows, once the configuration process is completed the device SHOULD apply
+the hash function to each of the incoming packets with regards to the flags in
+the \field{hash_function_flags} fields and distribute the packets through the
+virqueues using the calculated hash and the indirection table that were earliercontent.tex +5
-0+provided by the driver. + +Setting RSS configuration +\begin{enumerate} +\item The driver fills all of the fields and passes them through thecontrol
content.tex +5
-0+ queue to the device. + +\item The device sets the RSS configuration as provided by the driver. + +\item If the device successfully applied the configuration, on eachpacket
content.tex +2
-0+ received the device MUST calculate the hash for the packet using + the fields specified in \field{hash_function_flags} and store itin the
content.tex +5
-0+ virtio-net header in the \field{hash} field and the hash fields + used in the calculation. +\end{enumerate} + +\drivernormative{\subparagraph}{Receive Side Scaling}{Device Types /Network Device / Device Operation / Control Virtqueue / Steering mode / Receive Side Scaling}
content.tex +2
-0+ +If the driver wants to set RSS hash it should fill the RSS structurefields
content.tex +4
-0+as follows: + +\begin{itemize} +\item The driver SHOULD choose the hash function that SHOULD be used andfill
+ it in the \field{hash_function} field along with the appropriate
flags
+ in the \field{hash_function_flags} field. These flags indicate to
the
+ device which packet fields MUST be used in the calculation
process of
+ the hash.
+\item Once the hash function has been chosen a hash key should also be set by
+ the driver in the \field{hash_key} field, the length of the key
shouldcontent.tex +4
-0+ be stored in the \field{hash_key_length} field. +\item Lastly the driver should fill the indirection table array in the + \field{indirection_table} field while setting the array length in + \field{indirection_table_length}. This structure is used by thedevice
+ for determining in which RX virt queue the packet should be
placed.
+\end{itemize}
Quoted 8 lines
content.tex
Quoted 6 lines
+Once the configuration phase is over successfully, the packets SHOULD have the
+\field{hash} field with the hash value that was calculated by the device.content.tex +2
-0+ +Whenever the driver wants to stop performing RSS, it can switch back toShould we say: ..stop performing RSS or any earlier configured steering mode,
Since this section is devoted to RSS I think we should keep this RSS specific.
Quoted 13 lines
+Automatic Steering Mode using the
VIRTIO_NET_CTRL_SM_CONTROLcommandQuoted 9 lines
along with
content.tex +2
-0+the STEERING_MODE_AUTO flag. + \paragraph{Offloads State Configuration}\label{sec:Device Types /Network Device / Device Operation / Control Virtqueue / Offloads State Configuration}
If theVIRTIO_NET_F_CTRL_GUEST_OFFLOADSfeature is negotiated, the
driver can
Signature · 4 lines
Respectfully, *Sameeh Jubran* *Linkedin <https://il.linkedin.com/pub/sameeh-jubran/87/747/a8a>* *Software Engineer @ Daynix <http://www.daynix.com>.*
ping
Quoted 26 lines · Sameeh Jubran
From: Sameeh Jubran <[email protected]>
Please ignore the feature number value (60) in the patch, it is not final for now.
Difference from v2:
* Dropped
RSS_HASH_FUNCTION_NONEflag from RSS as it seems to be useless.
* Added more comments to the code.
* Beautifications.
* Fixed some sentences to make them clearer.Sameeh Jubran (2):
content: net: AddVIRTIO_NET_F_CTRL_STEERING_MODEfeature
content: net: steering mode: Add RSScontent.tex | 170 ++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+)--
2.13.6
Signature · 4 lines
Respectfully, *Sameeh Jubran* *Linkedin <https://il.linkedin.com/pub/sameeh-jubran/87/747/a8a>* *Software Engineer @ Daynix <http://www.daynix.com>.*