From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by dpdk.org (Postfix) with ESMTP id 6C43A5320 for ; Mon, 9 May 2016 12:47:38 +0200 (CEST) Received: from zmail26.collab.prod.int.phx2.redhat.com (zmail26.collab.prod.int.phx2.redhat.com [10.5.83.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u49Alb9w016973; Mon, 9 May 2016 06:47:37 -0400 Date: Mon, 9 May 2016 06:47:37 -0400 (EDT) From: Victor Kaplansky To: Yuanhan Liu Cc: dev@dpdk.org, huawei xie , "Michael S. Tsirkin" Message-ID: <1170087184.28025431.1462790857641.JavaMail.zimbra@redhat.com> In-Reply-To: <1462603224-29510-6-git-send-email-yuanhan.liu@linux.intel.com> References: <1462603224-29510-1-git-send-email-yuanhan.liu@linux.intel.com> <1462603224-29510-6-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: examples/vhost: add client and reconnect option Thread-Index: xxNOvsinT6//5Gw8Z9uHKVSJJGccug== Subject: Re: [dpdk-dev] [PATCH 5/6] examples/vhost: add 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:47:38 -0000 Again, it may be useful to add mixed --client-server option, when backend tries to connect as client and if failed, comes up as a server... Just a suggestion from user point of view... ----- Original Message ----- > From: "Yuanhan Liu" > To: dev@dpdk.org > Cc: "huawei xie" , "Yuanhan Liu" > Sent: Saturday, May 7, 2016 9:40:23 AM > Subject: [dpdk-dev] [PATCH 5/6] examples/vhost: add client and reconnect option > > Add --client and --reconnect option to enable the client mode and > reconnect mode, respectively. --rconnect works only when --client > is given as well. > > Signed-off-by: Yuanhan Liu > --- > examples/vhost/main.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > > diff --git a/examples/vhost/main.c b/examples/vhost/main.c > index 6899189..26c4d5f 100644 > --- a/examples/vhost/main.c > +++ b/examples/vhost/main.c > @@ -132,6 +132,9 @@ static uint32_t enable_tx_csum; > /* Disable TSO offload */ > static uint32_t enable_tso; > > +static int client_mode; > +static int reconnect; > + > /* Specify timeout (in useconds) between retries on RX. */ > static uint32_t burst_rx_delay_time = BURST_RX_WAIT_US; > /* Specify the number of retries on RX. */ > @@ -459,7 +462,9 @@ us_vhost_usage(const char *prgname) > " --stats [0-N]: 0: Disable stats, N: Time in seconds to print stats\n" > " --dev-basename: The basename to be used for the character device.\n" > " --tx-csum [0|1] disable/enable TX checksum offload.\n" > - " --tso [0|1] disable/enable TCP segment offload.\n", > + " --tso [0|1] disable/enable TCP segment offload.\n" > + " --client register a vhost-user socket as client mode.\n" > + " --reconnect reconnect to vhost-user server when disconnects.\n", > prgname); > } > > @@ -484,6 +489,8 @@ us_vhost_parse_args(int argc, char **argv) > {"dev-basename", required_argument, NULL, 0}, > {"tx-csum", required_argument, NULL, 0}, > {"tso", required_argument, NULL, 0}, > + {"client", no_argument, &client_mode, 1}, > + {"reconnect", no_argument, &reconnect, 1}, > {NULL, 0, 0, 0}, > }; > > @@ -647,6 +654,12 @@ us_vhost_parse_args(int argc, char **argv) > } > } > > + if (reconnect && !client_mode) { > + RTE_LOG(INFO, VHOST_CONFIG, > + "--reconnect works only when --client is specified\n"); > + return -1; > + } > + > for (i = 0; i < RTE_MAX_ETHPORTS; i++) { > if (enabled_port_mask & (1 << i)) > ports[num_ports++] = (uint8_t)i; > @@ -1406,6 +1419,7 @@ main(int argc, char *argv[]) > uint8_t portid; > static pthread_t tid; > char thread_name[RTE_MAX_THREAD_NAME_LEN]; > + uint64_t flags = 0; > > signal(SIGINT, sigint_handler); > > @@ -1498,8 +1512,13 @@ main(int argc, char *argv[]) > if (mergeable == 0) > rte_vhost_feature_disable(1ULL << VIRTIO_NET_F_MRG_RXBUF); > > + if (client_mode) > + flags |= RTE_VHOST_USER_CLIENT; > + if (reconnect) > + flags |= RTE_VHOST_USER_RECONNECT; > + > /* Register vhost(cuse or user) driver to handle vhost messages. */ > - ret = rte_vhost_driver_register(dev_basename, 0); > + ret = rte_vhost_driver_register(dev_basename, flags); > if (ret != 0) > rte_exit(EXIT_FAILURE, "vhost driver register failure.\n"); > > -- > 1.9.0 > >