From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, i.maximets@samsung.com, changpeng.liu@intel.com,
tiwei.bie@intel.com, dariusz.stojaczyk@intel.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [PATCH v3 1/2] vhost: add API to set protocol features flags
Date: Tue, 19 Mar 2019 11:54:16 +0100 [thread overview]
Message-ID: <20190319105417.16890-2-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20190319105417.16890-1-maxime.coquelin@redhat.com>
rte_vhost_driver_set_protocol_features API is to be used
by external backends to advertize vhost-user protocol
features it supports.
It has to be called after rte_vhost_driver_register() and
before rte_vhost_driver_start().
Example of usage to advertize VHOST_USER_PROTOCOL_F_FOOBAR
protocol feature:
const char *path = "/tmp/vhost-user";
uint64_t protocol_features;
rte_vhost_driver_register(path, 0);
rte_vhost_driver_get_protocol_features(path, &protocol_features);
protocol_features |= VHOST_USER_PROTOCOL_F_FOOBAR;
rte_vhost_driver_set_protocol_features(path, protocol_features);
rte_vhost_driver_start(path);
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Tested-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
---
lib/librte_vhost/rte_vhost.h | 14 ++++++++++++++
lib/librte_vhost/rte_vhost_version.map | 1 +
lib/librte_vhost/socket.c | 14 ++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
index 2753670a2..c9c392975 100644
--- a/lib/librte_vhost/rte_vhost.h
+++ b/lib/librte_vhost/rte_vhost.h
@@ -405,6 +405,20 @@ int rte_vhost_driver_disable_features(const char *path, uint64_t features);
*/
int rte_vhost_driver_get_features(const char *path, uint64_t *features);
+/**
+ * Set the protocol feature bits before feature negotiation.
+ *
+ * @param path
+ * The vhost-user socket file path
+ * @param protocol_features
+ * Supported protocol features
+ * @return
+ * 0 on success, -1 on failure
+ */
+int __rte_experimental
+rte_vhost_driver_set_protocol_features(const char *path,
+ uint64_t protocol_features);
+
/**
* Get the protocol feature bits before feature negotiation.
*
diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
index 8a3bc19e0..5f1d4a75c 100644
--- a/lib/librte_vhost/rte_vhost_version.map
+++ b/lib/librte_vhost/rte_vhost_version.map
@@ -86,4 +86,5 @@ EXPERIMENTAL {
rte_vhost_host_notifier_ctrl;
rte_vdpa_relay_vring_used;
rte_vhost_extern_callback_register;
+ rte_vhost_driver_set_protocol_features;
};
diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 9883b0491..3da9de62c 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -707,6 +707,20 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features)
return ret;
}
+int
+rte_vhost_driver_set_protocol_features(const char *path,
+ uint64_t protocol_features)
+{
+ struct vhost_user_socket *vsocket;
+
+ pthread_mutex_lock(&vhost_user.mutex);
+ vsocket = find_vhost_user_socket(path);
+ if (vsocket)
+ vsocket->protocol_features = protocol_features;
+ pthread_mutex_unlock(&vhost_user.mutex);
+ return vsocket ? 0 : -1;
+}
+
int
rte_vhost_driver_get_protocol_features(const char *path,
uint64_t *protocol_features)
--
2.20.1
next prev parent reply other threads:[~2019-03-19 10:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 10:54 [dpdk-dev] [PATCH v3 0/2] vhost: Support external backend only vhost-user requests Maxime Coquelin
2019-03-19 10:54 ` Maxime Coquelin
2019-03-19 10:54 ` Maxime Coquelin [this message]
2019-03-19 10:54 ` [dpdk-dev] [PATCH v3 1/2] vhost: add API to set protocol features flags Maxime Coquelin
2019-03-19 10:54 ` [dpdk-dev] [PATCH v3 2/2] vhost: support requests only handled by external backend Maxime Coquelin
2019-03-19 10:54 ` Maxime Coquelin
2019-03-20 4:54 ` Tiwei Bie
2019-03-20 4:54 ` Tiwei Bie
2019-03-20 7:34 ` [dpdk-dev] [PATCH v3 0/2] vhost: Support external backend only vhost-user requests Maxime Coquelin
2019-03-20 7:34 ` Maxime Coquelin
2019-03-20 14:32 ` Stojaczyk, Dariusz
2019-03-20 14:32 ` Stojaczyk, Dariusz
2019-03-21 9:21 ` Maxime Coquelin
2019-03-21 9:21 ` Maxime Coquelin
2019-03-22 10:29 ` Zhang, Roy Fan
2019-03-22 10:29 ` Zhang, Roy Fan
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=20190319105417.16890-2-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=changpeng.liu@intel.com \
--cc=dariusz.stojaczyk@intel.com \
--cc=dev@dpdk.org \
--cc=i.maximets@samsung.com \
--cc=tiwei.bie@intel.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).