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 2920437B4 for ; Fri, 2 Sep 2016 16:44:32 +0200 (CEST) Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 996FF4E4C2; Fri, 2 Sep 2016 14:44:31 +0000 (UTC) Received: from [10.36.6.193] (vpn1-6-193.ams2.redhat.com [10.36.6.193]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u82EiSbc007867 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 2 Sep 2016 10:44:30 -0400 To: Pankaj Chauhan , dev@dpdk.org References: <1472315186-28090-1-git-send-email-pankaj.chauhan@nxp.com> <1472315186-28090-3-git-send-email-pankaj.chauhan@nxp.com> Cc: hemant.agrawal@nxp.com, shreyansh.jain@nxp.com, jianfeng.tan@intel.com, yuanhan.liu@linux.intel.com From: Maxime Coquelin Message-ID: <86a9016e-af22-35d9-cbcd-40d2ccc71490@redhat.com> Date: Fri, 2 Sep 2016 16:44:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1472315186-28090-3-git-send-email-pankaj.chauhan@nxp.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 02 Sep 2016 14:44:31 +0000 (UTC) Subject: Re: [dpdk-dev] [RFC][PATCH 2/3] examples/vhost: Add vswitch command line options 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: Fri, 02 Sep 2016 14:44:32 -0000 On 08/27/2016 06:26 PM, Pankaj Chauhan wrote: > Add command line options for selecting switch implementation > and maximum ports for the vswitch.following are two new command > line options: > > --switch [char string, Selects the switch imlementation] > --max-ports [int, selects maximum number of ports to support] > > For example: > > $ ./vhost-switch -c 3 -n 2 --socket-mem 1024 --huge-dir /hugetlbfs -- -p > 0x1 --dev-basename sock1 --switch "vmdq" --max-ports 3 > > Signed-off-by: Pankaj Chauhan > --- > examples/vhost/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/examples/vhost/main.c b/examples/vhost/main.c > index 92a9823..59cddb8 100644 > --- a/examples/vhost/main.c > +++ b/examples/vhost/main.c > @@ -142,6 +142,10 @@ static uint32_t burst_rx_retry_num = BURST_RX_RETRIES; > /* Character device basename. Can be set by user. */ > static char dev_basename[MAX_BASENAME_SZ] = "vhost-net"; > > +/* vswitch device name and maximum number of ports */ > +static char switch_dev[MAX_BASENAME_SZ] = "vmdq"; > +static uint32_t switch_max_ports = MAX_DEVICES; > + > /* empty vmdq configuration structure. Filled in programatically */ > static struct rte_eth_conf vmdq_conf_default = { > .rxmode = { > @@ -408,6 +412,22 @@ us_vhost_parse_basename(const char *q_arg) > } > > /* > + * Set switch device name. > + */ > +static int > +us_vhost_parse_switch_name(const char *q_arg) > +{ > + /* parse number string */ > + > + if (strnlen(q_arg, MAX_BASENAME_SZ) > MAX_BASENAME_SZ) > + return -1; > + else > + snprintf((char*)&switch_dev, MAX_BASENAME_SZ, "%s", q_arg); why casting? > + > + return 0; > +} > + > +/* > * Parse the portmask provided at run time. > */ > static int > @@ -501,6 +521,8 @@ us_vhost_parse_args(int argc, char **argv) > {"tx-csum", required_argument, NULL, 0}, > {"tso", required_argument, NULL, 0}, > {"client", no_argument, &client_mode, 1}, > + {"switch", required_argument, NULL, 0}, > + {"max-ports", required_argument, NULL, 0}, > {NULL, 0, 0, 0}, > }; > > @@ -655,6 +677,27 @@ us_vhost_parse_args(int argc, char **argv) > } > } > > + /* Set vswitch_driver name */ > + if (!strncmp(long_option[option_index].name, "switch", MAX_LONG_OPT_SZ)) { > + if (us_vhost_parse_switch_name(optarg) == -1) { > + RTE_LOG(INFO, VHOST_CONFIG, "Invalid argument for character switch dev (Max %d characters)\n", MAX_BASENAME_SZ); ERR may be morez appropriate. And the message may be a little too long. > + us_vhost_usage(prgname); > + return -1; > + } > + } > + > + /* Specify Max ports in vswitch. */ > + if (!strncmp(long_option[option_index].name, "max-ports", MAX_LONG_OPT_SZ)) { > + ret = parse_num_opt(optarg, INT32_MAX); > + if (ret == -1) { > + RTE_LOG(INFO, VHOST_CONFIG, "Invalid argument for switch max ports [0-N]\n"); > + us_vhost_usage(prgname); > + return -1; > + } else { > + switch_max_ports = ret; > + } The else is not needed as the 'if' returns. > + } > + > break; > > /* Invalid option - print options. */ >