diff mbox series

[1/3] virtio-net: introduce RSS RX steering feature

Message ID 20200226174809.9675-2-yuri.benditovich@daynix.com (mailing list archive)
State New, archived
Headers show
Series reference implementation of RSS | expand

Commit Message

Yuri Benditovich Feb. 26, 2020, 5:48 p.m. UTC
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
---
 include/standard-headers/linux/virtio_net.h | 37 +++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

Comments

Michael S. Tsirkin March 5, 2020, 1:21 p.m. UTC | #1
On Wed, Feb 26, 2020 at 07:48:07PM +0200, Yuri Benditovich wrote:
> Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
> ---
>  include/standard-headers/linux/virtio_net.h | 37 +++++++++++++++++++--
>  1 file changed, 35 insertions(+), 2 deletions(-)


It will take a bit until next merge window when the linux
headers will be updated.
Until that happens you can just put these defines where
they are used.

> diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h
> index 260c3681d7..3bc100afe3 100644
> --- a/include/standard-headers/linux/virtio_net.h
> +++ b/include/standard-headers/linux/virtio_net.h
> @@ -57,6 +57,7 @@
>  					 * Steering */
>  #define VIRTIO_NET_F_CTRL_MAC_ADDR 23	/* Set MAC address */
>  
> +#define VIRTIO_NET_F_RSS    	  60	/* Supports RSS RX steering */
>  #define VIRTIO_NET_F_STANDBY	  62	/* Act as standby for another device
>  					 * with the same MAC.
>  					 */
> @@ -69,6 +70,16 @@
>  #define VIRTIO_NET_S_LINK_UP	1	/* Link is up */
>  #define VIRTIO_NET_S_ANNOUNCE	2	/* Announcement is needed */
>  
> +#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)
> +#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)
> +#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)
> +
>  struct virtio_net_config {
>  	/* The config defining mac address (if VIRTIO_NET_F_MAC) */
>  	uint8_t mac[ETH_ALEN];
> @@ -92,6 +103,14 @@ struct virtio_net_config {
>  	 * Any other value stands for unknown.
>  	 */
>  	uint8_t duplex;
> +
> +	/* maximal size of RSS key */
> +	uint8_t rss_max_key_size;
> +	/* maximal number of indirection table entries */
> +	uint16_t rss_max_indirection_table_length;
> +	/* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
> +	uint32_t supported_hash_types;
> +
>  } QEMU_PACKED;
>  
>  /*
> @@ -237,15 +256,29 @@ struct virtio_net_ctrl_mac {
>   * Accordingly, driver should not transmit new packets  on virtqueues other than
>   * specified.
>   */
> +#define VIRTIO_NET_CTRL_MQ   4
> + #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
> + #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG          1
> +
> +/* for VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET */
>  struct virtio_net_ctrl_mq {
>  	__virtio16 virtqueue_pairs;
>  };
>  
> -#define VIRTIO_NET_CTRL_MQ   4
> - #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
>   #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN        1
>   #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX        0x8000
>  
> +/* for VIRTIO_NET_CTRL_MQ_RSS_CONFIG */
> +struct virtio_net_rss_config {
> +    uint32_t hash_types;
> +    uint16_t indirection_table_mask;
> +    uint16_t unclassified_queue;
> +    uint16_t indirection_table[1/* + indirection_table_mask*/];
> +    uint16_t max_tx_vq;
> +    uint8_t hash_key_length;
> +    uint8_t hash_key_data[/*hash_key_length*/];
> +};
> +
>  /*
>   * Control network offloads
>   *
> -- 
> 2.17.1
Yuri Benditovich March 6, 2020, 9:29 a.m. UTC | #2
On Thu, Mar 5, 2020 at 3:21 PM Michael S. Tsirkin <mst@redhat.com> wrote:

> On Wed, Feb 26, 2020 at 07:48:07PM +0200, Yuri Benditovich wrote:
> > Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
> > ---
> >  include/standard-headers/linux/virtio_net.h | 37 +++++++++++++++++++--
> >  1 file changed, 35 insertions(+), 2 deletions(-)
>
>
> It will take a bit until next merge window when the linux
> headers will be updated.
> Until that happens you can just put these defines where
> they are used.
>

We also extend the configuration virtio_net_config structure and its
field 'supported_hash_types' uses these defines. Please advise.


>
> > diff --git a/include/standard-headers/linux/virtio_net.h
> b/include/standard-headers/linux/virtio_net.h
> > index 260c3681d7..3bc100afe3 100644
> > --- a/include/standard-headers/linux/virtio_net.h
> > +++ b/include/standard-headers/linux/virtio_net.h
> > @@ -57,6 +57,7 @@
> >                                        * Steering */
> >  #define VIRTIO_NET_F_CTRL_MAC_ADDR 23        /* Set MAC address */
> >
> > +#define VIRTIO_NET_F_RSS       60    /* Supports RSS RX steering */
> >  #define VIRTIO_NET_F_STANDBY   62    /* Act as standby for another
> device
> >                                        * with the same MAC.
> >                                        */
> > @@ -69,6 +70,16 @@
> >  #define VIRTIO_NET_S_LINK_UP 1       /* Link is up */
> >  #define VIRTIO_NET_S_ANNOUNCE        2       /* Announcement is needed
> */
> >
> > +#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)
> > +#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)
> > +#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)
> > +
> >  struct virtio_net_config {
> >       /* The config defining mac address (if VIRTIO_NET_F_MAC) */
> >       uint8_t mac[ETH_ALEN];
> > @@ -92,6 +103,14 @@ struct virtio_net_config {
> >        * Any other value stands for unknown.
> >        */
> >       uint8_t duplex;
> > +
> > +     /* maximal size of RSS key */
> > +     uint8_t rss_max_key_size;
> > +     /* maximal number of indirection table entries */
> > +     uint16_t rss_max_indirection_table_length;
> > +     /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
> > +     uint32_t supported_hash_types;
> > +
> >  } QEMU_PACKED;
> >
> >  /*
> > @@ -237,15 +256,29 @@ struct virtio_net_ctrl_mac {
> >   * Accordingly, driver should not transmit new packets  on virtqueues
> other than
> >   * specified.
> >   */
> > +#define VIRTIO_NET_CTRL_MQ   4
> > + #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
> > + #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG          1
> > +
> > +/* for VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET */
> >  struct virtio_net_ctrl_mq {
> >       __virtio16 virtqueue_pairs;
> >  };
> >
> > -#define VIRTIO_NET_CTRL_MQ   4
> > - #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
> >   #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN        1
> >   #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX        0x8000
> >
> > +/* for VIRTIO_NET_CTRL_MQ_RSS_CONFIG */
> > +struct virtio_net_rss_config {
> > +    uint32_t hash_types;
> > +    uint16_t indirection_table_mask;
> > +    uint16_t unclassified_queue;
> > +    uint16_t indirection_table[1/* + indirection_table_mask*/];
> > +    uint16_t max_tx_vq;
> > +    uint8_t hash_key_length;
> > +    uint8_t hash_key_data[/*hash_key_length*/];
> > +};
> > +
> >  /*
> >   * Control network offloads
> >   *
> > --
> > 2.17.1
>
>
Michael S. Tsirkin March 6, 2020, 10:25 a.m. UTC | #3
On Fri, Mar 06, 2020 at 11:29:50AM +0200, Yuri Benditovich wrote:
> 
> 
> On Thu, Mar 5, 2020 at 3:21 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> 
>     On Wed, Feb 26, 2020 at 07:48:07PM +0200, Yuri Benditovich wrote:
>     > Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
>     > ---
>     >  include/standard-headers/linux/virtio_net.h | 37 +++++++++++++++++++--
>     >  1 file changed, 35 insertions(+), 2 deletions(-)
> 
> 
>     It will take a bit until next merge window when the linux
>     headers will be updated.
>     Until that happens you can just put these defines where
>     they are used.
> 
> 
> We also extend the configuration virtio_net_config structure and its
> field 'supported_hash_types' uses these defines. Please advise.


Make a private copy of it with a different name for now.
Add a comment so we don't forget to remove down the road.

> 
> 
>     > diff --git a/include/standard-headers/linux/virtio_net.h b/include/
>     standard-headers/linux/virtio_net.h
>     > index 260c3681d7..3bc100afe3 100644
>     > --- a/include/standard-headers/linux/virtio_net.h
>     > +++ b/include/standard-headers/linux/virtio_net.h
>     > @@ -57,6 +57,7 @@
>     >                                        * Steering */
>     >  #define VIRTIO_NET_F_CTRL_MAC_ADDR 23        /* Set MAC address */
>     > 
>     > +#define VIRTIO_NET_F_RSS       60    /* Supports RSS RX steering */
>     >  #define VIRTIO_NET_F_STANDBY   62    /* Act as standby for another
>     device
>     >                                        * with the same MAC.
>     >                                        */
>     > @@ -69,6 +70,16 @@
>     >  #define VIRTIO_NET_S_LINK_UP 1       /* Link is up */
>     >  #define VIRTIO_NET_S_ANNOUNCE        2       /* Announcement is needed *
>     /
>     > 
>     > +#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)
>     > +#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)
>     > +#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)
>     > +
>     >  struct virtio_net_config {
>     >       /* The config defining mac address (if VIRTIO_NET_F_MAC) */
>     >       uint8_t mac[ETH_ALEN];
>     > @@ -92,6 +103,14 @@ struct virtio_net_config {
>     >        * Any other value stands for unknown.
>     >        */
>     >       uint8_t duplex;
>     > +
>     > +     /* maximal size of RSS key */
>     > +     uint8_t rss_max_key_size;
>     > +     /* maximal number of indirection table entries */
>     > +     uint16_t rss_max_indirection_table_length;
>     > +     /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
>     > +     uint32_t supported_hash_types;
>     > +
>     >  } QEMU_PACKED;
>     > 
>     >  /*
>     > @@ -237,15 +256,29 @@ struct virtio_net_ctrl_mac {
>     >   * Accordingly, driver should not transmit new packets  on virtqueues
>     other than
>     >   * specified.
>     >   */
>     > +#define VIRTIO_NET_CTRL_MQ   4
>     > + #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
>     > + #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG          1
>     > +
>     > +/* for VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET */
>     >  struct virtio_net_ctrl_mq {
>     >       __virtio16 virtqueue_pairs;
>     >  };
>     > 
>     > -#define VIRTIO_NET_CTRL_MQ   4
>     > - #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
>     >   #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN        1
>     >   #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX        0x8000
>     > 
>     > +/* for VIRTIO_NET_CTRL_MQ_RSS_CONFIG */
>     > +struct virtio_net_rss_config {
>     > +    uint32_t hash_types;
>     > +    uint16_t indirection_table_mask;
>     > +    uint16_t unclassified_queue;
>     > +    uint16_t indirection_table[1/* + indirection_table_mask*/];
>     > +    uint16_t max_tx_vq;
>     > +    uint8_t hash_key_length;
>     > +    uint8_t hash_key_data[/*hash_key_length*/];
>     > +};
>     > +
>     >  /*
>     >   * Control network offloads
>     >   *
>     > --
>     > 2.17.1
> 
>
diff mbox series

Patch

diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h
index 260c3681d7..3bc100afe3 100644
--- a/include/standard-headers/linux/virtio_net.h
+++ b/include/standard-headers/linux/virtio_net.h
@@ -57,6 +57,7 @@ 
 					 * Steering */
 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23	/* Set MAC address */
 
+#define VIRTIO_NET_F_RSS    	  60	/* Supports RSS RX steering */
 #define VIRTIO_NET_F_STANDBY	  62	/* Act as standby for another device
 					 * with the same MAC.
 					 */
@@ -69,6 +70,16 @@ 
 #define VIRTIO_NET_S_LINK_UP	1	/* Link is up */
 #define VIRTIO_NET_S_ANNOUNCE	2	/* Announcement is needed */
 
+#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)
+#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)
+#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)
+
 struct virtio_net_config {
 	/* The config defining mac address (if VIRTIO_NET_F_MAC) */
 	uint8_t mac[ETH_ALEN];
@@ -92,6 +103,14 @@  struct virtio_net_config {
 	 * Any other value stands for unknown.
 	 */
 	uint8_t duplex;
+
+	/* maximal size of RSS key */
+	uint8_t rss_max_key_size;
+	/* maximal number of indirection table entries */
+	uint16_t rss_max_indirection_table_length;
+	/* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
+	uint32_t supported_hash_types;
+
 } QEMU_PACKED;
 
 /*
@@ -237,15 +256,29 @@  struct virtio_net_ctrl_mac {
  * Accordingly, driver should not transmit new packets  on virtqueues other than
  * specified.
  */
+#define VIRTIO_NET_CTRL_MQ   4
+ #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
+ #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG          1
+
+/* for VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET */
 struct virtio_net_ctrl_mq {
 	__virtio16 virtqueue_pairs;
 };
 
-#define VIRTIO_NET_CTRL_MQ   4
- #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET        0
  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN        1
  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX        0x8000
 
+/* for VIRTIO_NET_CTRL_MQ_RSS_CONFIG */
+struct virtio_net_rss_config {
+    uint32_t hash_types;
+    uint16_t indirection_table_mask;
+    uint16_t unclassified_queue;
+    uint16_t indirection_table[1/* + indirection_table_mask*/];
+    uint16_t max_tx_vq;
+    uint8_t hash_key_length;
+    uint8_t hash_key_data[/*hash_key_length*/];
+};
+
 /*
  * Control network offloads
  *