From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: dev@dpdk.org
Cc: huawei.xie@intel.com, Traynor Kevin <kevin.traynor@intel.com>,
marcandre.lureau@redhat.com,
Yuanhan Liu <yuanhan.liu@linux.intel.com>
Subject: [dpdk-dev] [PATCH v2 6/6] vhost: add pmd client and reconnect option
Date: Thu, 12 May 2016 23:16:32 -0700 [thread overview]
Message-ID: <1463120192-24200-7-git-send-email-yuanhan.liu@linux.intel.com> (raw)
In-Reply-To: <1463120192-24200-1-git-send-email-yuanhan.liu@linux.intel.com>
Add client and reconnect option to vhost pmd. reconnect only works when
client is given.
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
drivers/net/vhost/rte_eth_vhost.c | 54 ++++++++++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 12 deletions(-)
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 91b5d95..c7e03d0 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -50,12 +50,16 @@
#define ETH_VHOST_IFACE_ARG "iface"
#define ETH_VHOST_QUEUES_ARG "queues"
+#define ETH_VHOST_CLIENT_ARG "client"
+#define ETH_VHOST_RECONNECT_ARG "reconnect"
static const char *drivername = "VHOST PMD";
static const char *valid_arguments[] = {
ETH_VHOST_IFACE_ARG,
ETH_VHOST_QUEUES_ARG,
+ ETH_VHOST_CLIENT_ARG,
+ ETH_VHOST_RECONNECT_ARG,
NULL
};
@@ -89,6 +93,7 @@ struct pmd_internal {
char *dev_name;
char *iface_name;
uint16_t max_queues;
+ uint64_t flags;
volatile uint16_t once;
};
@@ -467,7 +472,8 @@ eth_dev_start(struct rte_eth_dev *dev)
int ret = 0;
if (rte_atomic16_cmpset(&internal->once, 0, 1)) {
- ret = rte_vhost_driver_register(internal->iface_name, 0);
+ ret = rte_vhost_driver_register(internal->iface_name,
+ internal->flags);
if (ret)
return ret;
}
@@ -672,7 +678,7 @@ static const struct eth_dev_ops ops = {
static int
eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
- const unsigned numa_node)
+ const unsigned numa_node, uint64_t flags)
{
struct rte_eth_dev_data *data = NULL;
struct pmd_internal *internal = NULL;
@@ -729,6 +735,7 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
internal->iface_name = strdup(iface_name);
if (internal->iface_name == NULL)
goto error;
+ internal->flags = flags;
list->eth_dev = eth_dev;
pthread_mutex_lock(&internal_list_lock);
@@ -793,18 +800,15 @@ open_iface(const char *key __rte_unused, const char *value, void *extra_args)
}
static inline int
-open_queues(const char *key __rte_unused, const char *value, void *extra_args)
+open_int(const char *key __rte_unused, const char *value, void *extra_args)
{
- uint16_t *q = extra_args;
+ uint16_t *n = extra_args;
if (value == NULL || extra_args == NULL)
return -EINVAL;
- *q = (uint16_t)strtoul(value, NULL, 0);
- if (*q == USHRT_MAX && errno == ERANGE)
- return -1;
-
- if (*q > RTE_MAX_QUEUES_PER_PORT)
+ *n = (uint16_t)strtoul(value, NULL, 0);
+ if (*n == USHRT_MAX && errno == ERANGE)
return -1;
return 0;
@@ -817,6 +821,9 @@ rte_pmd_vhost_devinit(const char *name, const char *params)
int ret = 0;
char *iface_name;
uint16_t queues;
+ uint64_t flags = 0;
+ int client_mode;
+ int reconnect;
RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", name);
@@ -836,14 +843,37 @@ rte_pmd_vhost_devinit(const char *name, const char *params)
if (rte_kvargs_count(kvlist, ETH_VHOST_QUEUES_ARG) == 1) {
ret = rte_kvargs_process(kvlist, ETH_VHOST_QUEUES_ARG,
- &open_queues, &queues);
- if (ret < 0)
+ &open_int, &queues);
+ if (ret < 0 || queues > RTE_MAX_QUEUES_PER_PORT)
goto out_free;
} else
queues = 1;
- eth_dev_vhost_create(name, iface_name, queues, rte_socket_id());
+ if (rte_kvargs_count(kvlist, ETH_VHOST_CLIENT_ARG) == 1) {
+ ret = rte_kvargs_process(kvlist, ETH_VHOST_CLIENT_ARG,
+ &open_int, &client_mode);
+ if (ret < 0)
+ goto out_free;
+ }
+ if (rte_kvargs_count(kvlist, ETH_VHOST_RECONNECT_ARG) == 1) {
+ ret = rte_kvargs_process(kvlist, ETH_VHOST_RECONNECT_ARG,
+ &open_int, &reconnect);
+ if (ret < 0)
+ goto out_free;
+ }
+ if (client_mode)
+ flags |= RTE_VHOST_USER_CLIENT;
+ if (reconnect)
+ flags |= RTE_VHOST_USER_RECONNECT;
+ if (reconnect && !client_mode) {
+ RTE_LOG(ERR, PMD,
+ "reconnect works only when client is specified\n");
+ ret = -1;
+ goto out_free;
+ }
+
+ eth_dev_vhost_create(name, iface_name, queues, rte_socket_id(), flags);
out_free:
rte_kvargs_free(kvlist);
--
1.9.0
next prev parent reply other threads:[~2016-05-13 6:11 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-07 6:40 [dpdk-dev] [PATCH 0/6] vhost: add vhost-user client mode and reconnect ability Yuanhan Liu
2016-05-07 6:40 ` [dpdk-dev] [PATCH 1/6] vhost: rename structs for enabling client mode Yuanhan Liu
2016-05-07 6:40 ` [dpdk-dev] [PATCH 2/6] vhost: add vhost-user " Yuanhan Liu
2016-05-09 10:33 ` Victor Kaplansky
2016-05-09 20:33 ` Yuanhan Liu
2016-05-09 20:30 ` Michael S. Tsirkin
2016-05-07 6:40 ` [dpdk-dev] [PATCH 3/6] vhost: add reconnect ability Yuanhan Liu
2016-05-09 16:47 ` Xie, Huawei
2016-05-09 18:12 ` Yuanhan Liu
2016-05-10 7:24 ` Xie, Huawei
2016-05-10 7:54 ` Michael S. Tsirkin
2016-05-10 8:07 ` Xie, Huawei
2016-05-10 8:42 ` Michael S. Tsirkin
2016-05-10 9:00 ` Xie, Huawei
2016-05-10 9:17 ` Michael S. Tsirkin
2016-05-10 17:17 ` Loftus, Ciara
2016-05-11 21:46 ` Michael S. Tsirkin
2016-05-07 6:40 ` [dpdk-dev] [PATCH 4/6] vhost: workaround stale vring base Yuanhan Liu
2016-05-09 10:45 ` Victor Kaplansky
2016-05-09 13:39 ` Xie, Huawei
2016-05-09 18:23 ` Yuanhan Liu
2016-05-09 12:19 ` Michael S. Tsirkin
2016-05-09 16:25 ` Xie, Huawei
2016-05-09 18:22 ` Yuanhan Liu
2016-06-13 20:47 ` Michael S. Tsirkin
2016-05-10 8:21 ` Xie, Huawei
2016-05-07 6:40 ` [dpdk-dev] [PATCH 5/6] examples/vhost: add client and reconnect option Yuanhan Liu
2016-05-09 10:47 ` Victor Kaplansky
2016-05-07 6:40 ` [dpdk-dev] [PATCH 6/6] vhost: add pmd " Yuanhan Liu
2016-05-09 10:54 ` Victor Kaplansky
2016-05-09 18:26 ` Yuanhan Liu
2016-05-10 3:23 ` [dpdk-dev] [PATCH 0/6] vhost: add vhost-user client mode and reconnect ability Xu, Qian Q
2016-05-10 17:41 ` Yuanhan Liu
2016-05-13 6:16 ` [dpdk-dev] [PATCH v2 " Yuanhan Liu
2016-05-13 6:16 ` [dpdk-dev] [PATCH v2 1/6] vhost: rename structs for enabling client mode Yuanhan Liu
2016-05-13 6:16 ` [dpdk-dev] [PATCH v2 2/6] vhost: add vhost-user " Yuanhan Liu
2016-05-13 6:16 ` [dpdk-dev] [PATCH v2 3/6] vhost: add reconnect ability Yuanhan Liu
2016-05-13 6:16 ` [dpdk-dev] [PATCH v2 4/6] vhost: workaround stale vring base Yuanhan Liu
2016-05-13 6:16 ` [dpdk-dev] [PATCH v2 5/6] examples/vhost: add client and reconnect option Yuanhan Liu
2016-05-13 6:16 ` Yuanhan Liu [this message]
2016-05-25 17:45 ` [dpdk-dev] [PATCH v2 6/6] vhost: add pmd " Rich Lane
2016-05-26 8:01 ` Yuanhan Liu
2016-06-07 4:05 ` [dpdk-dev] [PATCH v3 0/6] vhost: add vhost-user client mode and reconnect ability Yuanhan Liu
2016-06-07 4:05 ` [dpdk-dev] [PATCH v3 1/6] vhost: rename structs for enabling client mode Yuanhan Liu
2016-06-07 4:05 ` [dpdk-dev] [PATCH v3 2/6] vhost: add vhost-user " Yuanhan Liu
2016-06-07 4:05 ` [dpdk-dev] [PATCH v3 3/6] vhost: add reconnect ability Yuanhan Liu
2016-06-07 4:05 ` [dpdk-dev] [PATCH v3 4/6] vhost: workaround stale vring base Yuanhan Liu
2016-06-07 4:05 ` [dpdk-dev] [PATCH v3 5/6] examples/vhost: add client option Yuanhan Liu
2016-06-07 4:05 ` [dpdk-dev] [PATCH v3 6/6] vhost: add pmd " Yuanhan Liu
2016-06-14 12:00 ` [dpdk-dev] [PATCH v3 0/6] vhost: add vhost-user client mode and reconnect ability Yuanhan Liu
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=1463120192-24200-7-git-send-email-yuanhan.liu@linux.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=dev@dpdk.org \
--cc=huawei.xie@intel.com \
--cc=kevin.traynor@intel.com \
--cc=marcandre.lureau@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 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).