From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id B90266CB2 for ; Tue, 7 Jun 2016 06:04:21 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 06 Jun 2016 21:04:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,431,1459839600"; d="scan'208";a="996647248" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by fmsmga002.fm.intel.com with ESMTP; 06 Jun 2016 21:04:20 -0700 From: Yuanhan Liu To: dev@dpdk.org Cc: huawei.xie@intel.com, Traynor Kevin , marcandre.lureau@redhat.com, Yuanhan Liu Date: Tue, 7 Jun 2016 12:05:07 +0800 Message-Id: <1465272308-3572-6-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1465272308-3572-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1463120192-24200-1-git-send-email-yuanhan.liu@linux.intel.com> <1465272308-3572-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH v3 5/6] examples/vhost: add client 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: Tue, 07 Jun 2016 04:04:22 -0000 Add --client option to let vhost-switch acts as the client. Signed-off-by: Yuanhan Liu --- v3: remove the --reconnect opt, as it's enabled by default. --- examples/vhost/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 9406d94..bd92ac6 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -132,6 +132,8 @@ static uint32_t enable_tx_csum; /* Disable TSO offload */ static uint32_t enable_tso; +static int client_mode; + /* 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. */ @@ -458,7 +460,8 @@ 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", prgname); } @@ -483,6 +486,7 @@ 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}, {NULL, 0, 0, 0}, }; @@ -1397,6 +1401,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); @@ -1487,8 +1492,11 @@ 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; + /* 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