From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id A1E944C9F for ; Wed, 13 Mar 2019 16:55:13 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E66813158794; Wed, 13 Mar 2019 15:55:12 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-54.ams2.redhat.com [10.36.112.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D7805C22E; Wed, 13 Mar 2019 15:55:10 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, changpeng.liu@intel.com, tiwei.bie@intel.com, i.maximets@samsung.com, dariusz.stojaczyk@intel.com Cc: Maxime Coquelin Date: Wed, 13 Mar 2019 16:55:03 +0100 Message-Id: <20190313155504.15087-2-maxime.coquelin@redhat.com> In-Reply-To: <20190313155504.15087-1-maxime.coquelin@redhat.com> References: <20190313155504.15087-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 13 Mar 2019 15:55:13 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2 1/2] vhost: add API to set protocol features flags X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 15:55:14 -0000 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 Tested-by: Darek Stojaczyk Reviewed-by: Tiwei Bie --- 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