From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by dpdk.org (Postfix) with ESMTP id 573BE68F6 for ; Mon, 9 May 2016 12:54:05 +0200 (CEST) Received: from zmail26.collab.prod.int.phx2.redhat.com (zmail26.collab.prod.int.phx2.redhat.com [10.5.83.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u49As4t0014956; Mon, 9 May 2016 06:54:04 -0400 Date: Mon, 9 May 2016 06:54:04 -0400 (EDT) From: Victor Kaplansky To: Yuanhan Liu Cc: dev@dpdk.org, huawei xie , Tetsuya Mukawa Message-ID: <953716968.28028422.1462791244148.JavaMail.zimbra@redhat.com> In-Reply-To: <1462603224-29510-7-git-send-email-yuanhan.liu@linux.intel.com> References: <1462603224-29510-1-git-send-email-yuanhan.liu@linux.intel.com> <1462603224-29510-7-git-send-email-yuanhan.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.35.203.67] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - GC43 (Linux)/8.0.6_GA_5922) Thread-Topic: vhost: add pmd client and reconnect option Thread-Index: MKAawRBld135D+RTIsTzQEOQLornJA== Subject: Re: [dpdk-dev] [PATCH 6/6] vhost: add pmd client and reconnect option X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2016 10:54:05 -0000 Looks OK to me. I didn't quite get why open_int() is called so. What does it open? -- Victor ----- Original Message ----- > From: "Yuanhan Liu" > To: dev@dpdk.org > Cc: "huawei xie" , "Yuanhan Liu" , "Tetsuya Mukawa" > > Sent: Saturday, May 7, 2016 9:40:24 AM > Subject: [dpdk-dev] [PATCH 6/6] vhost: add pmd client and reconnect option > > Add client and reconnect option to vhost pmd. reconnect only works when > client is given as well. > > Cc: Tetsuya Mukawa > Signed-off-by: Yuanhan Liu > --- > 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 36697cf..7636ef8 100644 > --- a/drivers/net/vhost/rte_eth_vhost.c > +++ b/drivers/net/vhost/rte_eth_vhost.c > @@ -47,12 +47,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 > }; > > @@ -87,6 +91,7 @@ struct pmd_internal { > char *dev_name; > char *iface_name; > uint16_t max_queues; > + uint64_t flags; > > volatile uint16_t once; > }; > @@ -456,7 +461,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; > } > @@ -661,7 +667,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; > @@ -718,6 +724,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); > @@ -782,18 +789,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; > @@ -806,6 +810,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); > > @@ -825,14 +832,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 > >