From: Pankaj Chauhan <pankaj.chauhan@nxp.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>, <dev@dpdk.org>
Cc: <hemant.agrawal@nxp.com>, <shreyansh.jain@nxp.com>,
<jianfeng.tan@intel.com>, <yuanhan.liu@linux.intel.com>
Subject: Re: [dpdk-dev] [RFC][PATCH 2/3] examples/vhost: Add vswitch command line options
Date: Sat, 3 Sep 2016 20:59:41 +0530 [thread overview]
Message-ID: <2389c298-4836-f7be-52cd-8303e8b544a5@nxp.com> (raw)
In-Reply-To: <86a9016e-af22-35d9-cbcd-40d2ccc71490@redhat.com>
On 9/2/2016 8:14 PM, Maxime Coquelin wrote:
>
>
> 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 <switch_name> [char string, Selects the switch imlementation]
>> --max-ports<port_count> [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 <pankaj.chauhan@nxp.com>
>> ---
>> 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?
yes not required, will remove it.
>> +
>> + 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.
I didn't get the comment, can you please help me understand.
> And the message may be a little too long.
I will shorten it, thanks.
>
>> + 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.
Agreed, will fix it.
>> + }
>> +
>> break;
>>
>> /* Invalid option - print options. */
>>
>
next prev parent reply other threads:[~2016-09-03 15:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-27 16:26 [dpdk-dev] [RFC][PATCH 0/3] example/vhost: Introduce Vswitch Framework Pankaj Chauhan
2016-08-26 16:56 ` Maxime Coquelin
2016-08-27 16:26 ` [dpdk-dev] [RFC][PATCH 1/3] examples/vhost: Add vswitch (generic switch) framework Pankaj Chauhan
2016-09-02 14:17 ` Maxime Coquelin
2016-09-03 15:28 ` Pankaj Chauhan
2016-08-27 16:26 ` [dpdk-dev] [RFC][PATCH 2/3] examples/vhost: Add vswitch command line options Pankaj Chauhan
2016-09-02 14:44 ` Maxime Coquelin
2016-09-03 15:29 ` Pankaj Chauhan [this message]
2016-08-27 16:26 ` [dpdk-dev] [RFC][PATCH 3/3] examples/vhost: Add VMDQ vswitch device Pankaj Chauhan
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=2389c298-4836-f7be-52cd-8303e8b544a5@nxp.com \
--to=pankaj.chauhan@nxp.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
--cc=jianfeng.tan@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=shreyansh.jain@nxp.com \
--cc=yuanhan.liu@linux.intel.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).