DPDK patches and discussions
 help / color / mirror / Atom feed
From: Srujana Challa <schalla@marvell.com>
To: <dev@dpdk.org>, <maxime.coquelin@redhat.com>, <chenbox@nvidia.com>
Cc: <jerinj@marvell.com>, <vattunuru@marvell.com>
Subject: [PATCH v2 2/2] net/virtio-user: add VIRTIO_NET_F_RSS to supported features
Date: Tue, 23 Jan 2024 16:25:23 +0530	[thread overview]
Message-ID: <20240123105523.751151-2-schalla@marvell.com> (raw)
In-Reply-To: <20240123105523.751151-1-schalla@marvell.com>

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 15b75dd802..d395fc1676 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)
 {
@@ -682,7 +700,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,
@@ -894,6 +913,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) {
@@ -955,6 +979,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 671ba50c03..66400b3b62 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -85,6 +85,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 aae4c53f32..bf9de36d8f 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


  reply	other threads:[~2024-01-23 10:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  5:31 [PATCH 1/2] net/virtio-user: improve kick performance with notification area mapping Srujana Challa
2023-12-08  5:31 ` [PATCH 2/2] net/virtio-user: add VIRTIO_NET_F_RSS to supported features Srujana Challa
2024-01-03  7:13   ` [EXT] " Srujana Challa
2024-01-11 14:17   ` Maxime Coquelin
2024-01-22 12:55     ` [EXT] " Srujana Challa
2024-01-11 14:14 ` [PATCH 1/2] net/virtio-user: improve kick performance with notification area mapping Maxime Coquelin
2024-01-22 12:51   ` [EXT] " Srujana Challa
2024-01-23 10:55 ` [PATCH v2 " Srujana Challa
2024-01-23 10:55   ` Srujana Challa [this message]
2024-02-05 10:32     ` [PATCH v2 2/2] net/virtio-user: add VIRTIO_NET_F_RSS to supported features Maxime Coquelin
2024-02-06 14:57     ` Maxime Coquelin
2024-02-05 10:30   ` [PATCH v2 1/2] net/virtio-user: improve kick performance with notification area mapping Maxime Coquelin
2024-02-06 14:57   ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240123105523.751151-2-schalla@marvell.com \
    --to=schalla@marvell.com \
    --cc=chenbox@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=vattunuru@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).