All of lore.kernel.org
 help / color / mirror / Atom feed
From: <skoteshwar@marvell.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
	Chenbo Xia <chenbox@nvidia.com>
Cc: <dev@dpdk.org>, Satha Rao <skoteshwar@marvell.com>
Subject: [PATCH 5/5] net/virtio-user: support vDPA configuration callback
Date: Mon, 7 Oct 2024 20:34:03 +0530	[thread overview]
Message-ID: <20241007150403.1680983-5-skoteshwar@marvell.com> (raw)
In-Reply-To: <20241007150403.1680983-1-skoteshwar@marvell.com>

From: Satha Rao <skoteshwar@marvell.com>

Extended the vhost_vdpa_get_intr_fd API to create an event and
register for configuration callbacks with the vDPA backend. This
enhancement allows the virtio-user driver to handle configuration
changes more effectively.

Signed-off-by: Satha Rao <skoteshwar@marvell.com>
---
 drivers/net/virtio/virtio_user/vhost_vdpa.c   | 18 ++++++++++--
 .../net/virtio/virtio_user/virtio_user_dev.c  | 29 +++++++++++++++++++
 .../net/virtio/virtio_user/virtio_user_dev.h  |  2 ++
 3 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_vdpa.c b/drivers/net/virtio/virtio_user/vhost_vdpa.c
index e8aea54000..c9eaffce16 100644
--- a/drivers/net/virtio/virtio_user/vhost_vdpa.c
+++ b/drivers/net/virtio/virtio_user/vhost_vdpa.c
@@ -9,6 +9,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/eventfd.h>
 
 #include <rte_memory.h>
 
@@ -634,10 +635,21 @@ vhost_vdpa_update_link_state(struct virtio_user_dev *dev)
 }
 
 static int
-vhost_vdpa_get_intr_fd(struct virtio_user_dev *dev __rte_unused)
+vhost_vdpa_get_intr_fd(struct virtio_user_dev *dev)
 {
-	/* No link state interrupt with Vhost-vDPA */
-	return -1;
+	int fd;
+
+	if (dev->cfg_epfd)
+		return dev->cfg_epfd;
+
+	fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+	if (fd < 0) {
+		PMD_DRV_LOG(ERR, "failed to create fd error, %s", strerror(errno));
+		fd = -1;
+	}
+	dev->cfg_epfd = fd;
+
+	return fd;
 }
 
 static int
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 91ad1312f7..ea00eb50f5 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -487,6 +487,21 @@ virtio_user_dev_get_speed_duplex_config(struct virtio_user_dev *dev, void *dst,
 	return ret;
 }
 
+int
+virtio_user_dev_set_config_call(struct virtio_user_dev *dev, int fd)
+{
+	int ret = 0;
+
+	if (!dev->ops->set_config_call)
+		return -ENOTSUP;
+
+	ret = dev->ops->set_config_call(dev, fd);
+	if (ret)
+		PMD_DRV_LOG(ERR, "(%s) Failed to set config call in device", dev->path);
+
+	return ret;
+}
+
 static int
 virtio_user_dev_init_notify(struct virtio_user_dev *dev)
 {
@@ -769,6 +784,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
 	dev->unsupported_features = 0;
 	dev->backend_type = backend_type;
 	dev->ifname = *ifname;
+	dev->cfg_epfd = 0;
 
 	if (virtio_user_dev_setup(dev) < 0) {
 		PMD_INIT_LOG(ERR, "(%s) backend set up fails", dev->path);
@@ -863,6 +879,15 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
 		}
 	}
 
+	/* vhost vdpa register valid fd to handle config callback */
+	if (dev->cfg_epfd) {
+		struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id];
+
+		if (rte_intr_efd_counter_size_set(eth_dev->intr_handle, 8))
+			return -rte_errno;
+		virtio_user_dev_set_config_call(dev, dev->cfg_epfd);
+	}
+
 	*ifname = NULL;
 	return 0;
 
@@ -892,6 +917,10 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
 
 	virtio_user_free_vrings(dev);
 
+	if (dev->cfg_epfd) {
+		close(dev->cfg_epfd);
+		dev->cfg_epfd = 0;
+	}
 	free(dev->ifname);
 
 	if (dev->is_server)
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index 57d75d1c53..1ad93521e3 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -31,6 +31,7 @@ struct virtio_user_dev {
 
 	int		*callfds;
 	int		*kickfds;
+	int		cfg_epfd; /* config callback interrupt */
 	int		mac_specified;
 	uint16_t	max_queue_pairs;
 	uint16_t	queue_pairs;
@@ -89,6 +90,7 @@ int virtio_user_dev_get_rss_config(struct virtio_user_dev *dev, void *dst, size_
 				   int length);
 int virtio_user_dev_get_speed_duplex_config(struct virtio_user_dev *dev, void *dst,
 					    size_t offset, int length);
+int virtio_user_dev_set_config_call(struct virtio_user_dev *dev, int fd);
 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[];
-- 
2.25.1


  parent reply	other threads:[~2024-10-07 15:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-07 15:03 [PATCH 1/5] interrupts: fix number of bytes read for vdev skoteshwar
2024-10-07 15:04 ` [PATCH 2/5] net/virtio-user: get link duplex and speed skoteshwar
2024-10-07 15:04 ` [PATCH 3/5] net/virtio: add set config callback skoteshwar
2024-10-07 15:04 ` [PATCH 4/5] net/virtio: implement update link state API skoteshwar
2024-10-07 15:04 ` skoteshwar [this message]
2024-10-09  4:01 ` [PATCH 1/5] interrupts: fix number of bytes read for vdev Stephen Hemminger

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=20241007150403.1680983-5-skoteshwar@marvell.com \
    --to=skoteshwar@marvell.com \
    --cc=chenbox@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.