[2/2] net/virtio-user: add VIRTIO_NET_F_RSS to supported features

Message ID 20231208053121.152929-2-schalla@marvell.com (mailing list archive)
State Changes Requested
Delegated to: Maxime Coquelin
Headers
Series [1/2] net/virtio-user: improve kick performance with notification area mapping |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/intel-Testing fail Testing issues

Commit Message

Srujana Challa Dec. 8, 2023, 5:31 a.m. UTC
  This patch introduces new function to get rss device config
and adds code to forward the RSS control command to backend
through hw control queue if RSS feature is negotiated.
This patch will help to negotiate VIRTIO_NET_F_RSS feature
if vhost-vdpa backend supports RSS in HW.

Signed-off-by: Srujana Challa <schalla@marvell.com>
---
 .../net/virtio/virtio_user/virtio_user_dev.c  | 31 ++++++++++++++++++-
 .../net/virtio/virtio_user/virtio_user_dev.h  |  2 ++
 drivers/net/virtio/virtio_user_ethdev.c       |  3 ++
 3 files changed, 35 insertions(+), 1 deletion(-)
  

Comments

Srujana Challa Jan. 3, 2024, 7:13 a.m. UTC | #1
Ping

> ----------------------------------------------------------------------
> This patch introduces new function to get rss device config and adds code to
> forward the RSS control command to backend through hw control queue if
> RSS feature is negotiated.
> This patch will help to negotiate VIRTIO_NET_F_RSS feature if vhost-vdpa
> backend supports RSS in HW.
> 
> Signed-off-by: Srujana Challa <schalla@marvell.com>
> ---
>  .../net/virtio/virtio_user/virtio_user_dev.c  | 31 ++++++++++++++++++-
> .../net/virtio/virtio_user/virtio_user_dev.h  |  2 ++
>  drivers/net/virtio/virtio_user_ethdev.c       |  3 ++
>  3 files changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 578877d089..b0937c9df9 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -304,6 +304,24 @@ virtio_user_dev_init_max_queue_pairs(struct
> virtio_user_dev *dev, uint32_t user_
>  	return 0;
>  }
> 
> +int
> +virtio_user_dev_get_rss_config(struct virtio_user_dev *dev, void *dst,
> +size_t offset, int length) {
> +	int ret = 0;
> +
> +	if (!(dev->device_features & (1ULL << VIRTIO_NET_F_RSS)))
> +		return -ENOTSUP;
> +
> +	if (!dev->ops->get_config)
> +		return -ENOTSUP;
> +
> +	ret = dev->ops->get_config(dev, dst, offset, length);
> +	if (ret)
> +		PMD_DRV_LOG(ERR, "(%s) Failed to get rss config in device",
> +dev->path);
> +
> +	return ret;
> +}
> +
>  int
>  virtio_user_dev_set_mac(struct virtio_user_dev *dev)  { @@ -687,7 +705,8
> @@ virtio_user_free_vrings(struct virtio_user_dev *dev)
>  	 1ULL << VIRTIO_F_IN_ORDER		|	\
>  	 1ULL << VIRTIO_F_VERSION_1		|	\
>  	 1ULL << VIRTIO_F_RING_PACKED		|	\
> -	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
> +	 1ULL << VIRTIO_F_NOTIFICATION_DATA	|	\
> +	 1ULL << VIRTIO_NET_F_RSS)
> 
>  int
>  virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t
> queues, @@ -903,6 +922,11 @@ virtio_user_handle_ctrl_msg_split(struct
> virtio_user_dev *dev, struct vring *vri
> 
>  		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
>  		status = virtio_user_handle_mq(dev, queues);
> +	} else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd ==
> VIRTIO_NET_CTRL_MQ_RSS_CONFIG) {
> +		struct virtio_net_ctrl_rss *rss;
> +
> +		rss = (struct virtio_net_ctrl_rss *)(uintptr_t)vring-
> >desc[idx_data].addr;
> +		status = virtio_user_handle_mq(dev, rss->max_tx_vq);
>  	} else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
>  		   hdr->class == VIRTIO_NET_CTRL_MAC ||
>  		   hdr->class == VIRTIO_NET_CTRL_VLAN) { @@ -964,6
> +988,11 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev
> *dev,
>  		queues = *(uint16_t *)(uintptr_t)
>  				vring->desc[idx_data].addr;
>  		status = virtio_user_handle_mq(dev, queues);
> +	} else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd ==
> VIRTIO_NET_CTRL_MQ_RSS_CONFIG) {
> +		struct virtio_net_ctrl_rss *rss;
> +
> +		rss = (struct virtio_net_ctrl_rss *)(uintptr_t)vring-
> >desc[idx_data].addr;
> +		status = virtio_user_handle_mq(dev, rss->max_tx_vq);
>  	} else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
>  		   hdr->class == VIRTIO_NET_CTRL_MAC ||
>  		   hdr->class == VIRTIO_NET_CTRL_VLAN) { diff --git
> a/drivers/net/virtio/virtio_user/virtio_user_dev.h
> b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> index 29ec386da5..39b3eec0f2 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> @@ -86,6 +86,8 @@ int virtio_user_dev_update_status(struct
> virtio_user_dev *dev);  int virtio_user_dev_update_link_state(struct
> virtio_user_dev *dev);  int virtio_user_dev_set_mac(struct virtio_user_dev
> *dev);  int virtio_user_dev_get_mac(struct virtio_user_dev *dev);
> +int virtio_user_dev_get_rss_config(struct virtio_user_dev *dev, void *dst,
> size_t offset,
> +				   int length);
>  void virtio_user_dev_delayed_disconnect_handler(void *param);  int
> virtio_user_dev_server_reconnect(struct virtio_user_dev *dev);  extern const
> char * const virtio_user_backend_strings[]; diff --git
> a/drivers/net/virtio/virtio_user_ethdev.c
> b/drivers/net/virtio/virtio_user_ethdev.c
> index 241465ecdd..6c10e8f6c0 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -52,6 +52,9 @@ virtio_user_read_dev_config(struct virtio_hw *hw,
> size_t offset,
> 
>  	if (offset == offsetof(struct virtio_net_config, max_virtqueue_pairs))
>  		*(uint16_t *)dst = dev->max_queue_pairs;
> +
> +	if (offset >= offsetof(struct virtio_net_config, rss_max_key_size))
> +		virtio_user_dev_get_rss_config(dev, dst, offset, length);
>  }
> 
>  static void
> --
> 2.25.1
  
Maxime Coquelin Jan. 11, 2024, 2:17 p.m. UTC | #2
Hi,

On 12/8/23 06:31, Srujana Challa wrote:
> This patch introduces new function to get rss device config
> and adds code to forward the RSS control command to backend
> through hw control queue if RSS feature is negotiated.
> This patch will help to negotiate VIRTIO_NET_F_RSS feature
> if vhost-vdpa backend supports RSS in HW.
> 
> Signed-off-by: Srujana Challa <schalla@marvell.com>
> ---
>   .../net/virtio/virtio_user/virtio_user_dev.c  | 31 ++++++++++++++++++-
>   .../net/virtio/virtio_user/virtio_user_dev.h  |  2 ++
>   drivers/net/virtio/virtio_user_ethdev.c       |  3 ++
>   3 files changed, 35 insertions(+), 1 deletion(-)
> 

Nice! Same question as on patch 1, I would be interested in knowing
which hardware supports this feature.

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Srujana Challa Jan. 22, 2024, 12:55 p.m. UTC | #3
> Hi,
> 
> On 12/8/23 06:31, Srujana Challa wrote:
> > This patch introduces new function to get rss device config and adds
> > code to forward the RSS control command to backend through hw control
> > queue if RSS feature is negotiated.
> > This patch will help to negotiate VIRTIO_NET_F_RSS feature if
> > vhost-vdpa backend supports RSS in HW.
> >
> > Signed-off-by: Srujana Challa <schalla@marvell.com>
> > ---
> >   .../net/virtio/virtio_user/virtio_user_dev.c  | 31 ++++++++++++++++++-
> >   .../net/virtio/virtio_user/virtio_user_dev.h  |  2 ++
> >   drivers/net/virtio/virtio_user_ethdev.c       |  3 ++
> >   3 files changed, 35 insertions(+), 1 deletion(-)
> >
> 
> Nice! Same question as on patch 1, I would be interested in knowing which
> hardware supports this feature.

Marvell's Octeon DPU supports this feature.
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Thanks,
> Maxime
  

Patch

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 578877d089..b0937c9df9 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -304,6 +304,24 @@  virtio_user_dev_init_max_queue_pairs(struct virtio_user_dev *dev, uint32_t user_
 	return 0;
 }
 
+int
+virtio_user_dev_get_rss_config(struct virtio_user_dev *dev, void *dst, size_t offset, int length)
+{
+	int ret = 0;
+
+	if (!(dev->device_features & (1ULL << VIRTIO_NET_F_RSS)))
+		return -ENOTSUP;
+
+	if (!dev->ops->get_config)
+		return -ENOTSUP;
+
+	ret = dev->ops->get_config(dev, dst, offset, length);
+	if (ret)
+		PMD_DRV_LOG(ERR, "(%s) Failed to get rss config in device", dev->path);
+
+	return ret;
+}
+
 int
 virtio_user_dev_set_mac(struct virtio_user_dev *dev)
 {
@@ -687,7 +705,8 @@  virtio_user_free_vrings(struct virtio_user_dev *dev)
 	 1ULL << VIRTIO_F_IN_ORDER		|	\
 	 1ULL << VIRTIO_F_VERSION_1		|	\
 	 1ULL << VIRTIO_F_RING_PACKED		|	\
-	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
+	 1ULL << VIRTIO_F_NOTIFICATION_DATA	|	\
+	 1ULL << VIRTIO_NET_F_RSS)
 
 int
 virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
@@ -903,6 +922,11 @@  virtio_user_handle_ctrl_msg_split(struct virtio_user_dev *dev, struct vring *vri
 
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_RSS_CONFIG) {
+		struct virtio_net_ctrl_rss *rss;
+
+		rss = (struct virtio_net_ctrl_rss *)(uintptr_t)vring->desc[idx_data].addr;
+		status = virtio_user_handle_mq(dev, rss->max_tx_vq);
 	} else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
 		   hdr->class == VIRTIO_NET_CTRL_MAC ||
 		   hdr->class == VIRTIO_NET_CTRL_VLAN) {
@@ -964,6 +988,11 @@  virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 		queues = *(uint16_t *)(uintptr_t)
 				vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd == VIRTIO_NET_CTRL_MQ_RSS_CONFIG) {
+		struct virtio_net_ctrl_rss *rss;
+
+		rss = (struct virtio_net_ctrl_rss *)(uintptr_t)vring->desc[idx_data].addr;
+		status = virtio_user_handle_mq(dev, rss->max_tx_vq);
 	} else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
 		   hdr->class == VIRTIO_NET_CTRL_MAC ||
 		   hdr->class == VIRTIO_NET_CTRL_VLAN) {
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index 29ec386da5..39b3eec0f2 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -86,6 +86,8 @@  int virtio_user_dev_update_status(struct virtio_user_dev *dev);
 int virtio_user_dev_update_link_state(struct virtio_user_dev *dev);
 int virtio_user_dev_set_mac(struct virtio_user_dev *dev);
 int virtio_user_dev_get_mac(struct virtio_user_dev *dev);
+int virtio_user_dev_get_rss_config(struct virtio_user_dev *dev, void *dst, size_t offset,
+				   int length);
 void virtio_user_dev_delayed_disconnect_handler(void *param);
 int virtio_user_dev_server_reconnect(struct virtio_user_dev *dev);
 extern const char * const virtio_user_backend_strings[];
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 241465ecdd..6c10e8f6c0 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -52,6 +52,9 @@  virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,
 
 	if (offset == offsetof(struct virtio_net_config, max_virtqueue_pairs))
 		*(uint16_t *)dst = dev->max_queue_pairs;
+
+	if (offset >= offsetof(struct virtio_net_config, rss_max_key_size))
+		virtio_user_dev_get_rss_config(dev, dst, offset, length);
 }
 
 static void