From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8EBC8A0524; Mon, 7 Dec 2020 11:51:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3A670C8CC; Mon, 7 Dec 2020 11:51:35 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id EBB64CF3 for ; Mon, 7 Dec 2020 11:51:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607338290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fTuPfuQL2zbx7+7S9OqVEpzlg25tVEcMU/8aY970nHk=; b=cNW7xlvxtlioo0lrsbQK8h2bmJTItTlEFeP0i8eBWHiEQzux2UF0CcInMmzvEMTadUJ8jY QxZ/0dihxl4IftPxzVvpdDDcf7wrfA57+JhQjSSma0nBBTMjbEcH5EJ2oCEwE4zeVvkL2K 6z/BXoPBMENnF+8lJ9pDa3toHWy+U/M= Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-564--GxZv3PYPMCHudibD0XJxg-1; Mon, 07 Dec 2020 05:51:26 -0500 X-MC-Unique: -GxZv3PYPMCHudibD0XJxg-1 Received: by mail-vk1-f199.google.com with SMTP id v190so5996036vkb.16 for ; Mon, 07 Dec 2020 02:51:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=fTuPfuQL2zbx7+7S9OqVEpzlg25tVEcMU/8aY970nHk=; b=JcjySVp85cDK9LJSVvEXTp18m47V3WAVrx/pTBbIw6ZvwDsgYDKJz9N5sTyBo6iawE IOHX9Wzq2oQ59dvz0TOK0ww+7zuA2JTG6y3H9i1RsHu994eeUk1Ur2qKF3TtnRGQiCT4 uqZ12dL6PX1LZ/w2rFieDgk8qfQNUemuCRgcq0IIBwgPRkSF2+/1ShaNUp6Lnlzmf9vk Pmch0L2Xln0hjyG8jPJP5UoKztoRj9ACVDiQalZhHL8Co3fbOGtR8nJwCzL4Liq0VKwa lUgpGazR4HMbEzL2IAxrxd/Mb+qnFvsvCKtATnczlDhUWtHnN/Y18f6+AHANGbeuZo2g C9nQ== X-Gm-Message-State: AOAM530UXAbkCN9aqUXBwBfbf3Dw16tZDC8E9Aa8Ryt+W2+cHeMyWElf gHR8t1WrkxTwby9F4eFMAc8uwVDPPzSkHqyu+aOlR/KUvBWYIZ4zb0vujj1feaTqX+JS5RjcrTJ QEWlA9PSgS3+34ZoZ/eY= X-Received: by 2002:ab0:4972:: with SMTP id a47mr11063148uad.53.1607338286325; Mon, 07 Dec 2020 02:51:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjMO565PbgXrVatWZ8hHXUQtnyCttso+/x/gFrIb+K5impPYqjMw9Pl9BbGuQhc3Dyi2Uml4HqiPk22ubkqK4= X-Received: by 2002:ab0:4972:: with SMTP id a47mr11063143uad.53.1607338286054; Mon, 07 Dec 2020 02:51:26 -0800 (PST) MIME-Version: 1.0 References: <20201124123249.14451-1-ibtisam.tariq@emumba.com> <20201124123249.14451-6-ibtisam.tariq@emumba.com> In-Reply-To: <20201124123249.14451-6-ibtisam.tariq@emumba.com> From: David Marchand Date: Mon, 7 Dec 2020 11:51:14 +0100 Message-ID: To: Ibtisam Tariq , Maxime Coquelin Cc: "Xia, Chenbo" , Cristian Dumitrescu , "Singh, Jasvinder" , "Mcnamara, John" , "Pattan, Reshma" , "Ananyev, Konstantin" , "Kovacevic, Marko" , dev , Jiayu Hu , huawei.xie@intel.com Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH 6/7] examples/vhost: enhance getopt_long usage X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Nov 24, 2020 at 1:35 PM Ibtisam Tariq wr= ote: > diff --git a/examples/vhost/main.c b/examples/vhost/main.c > index 8d8c3038b..ce8b64035 100644 > --- a/examples/vhost/main.c > +++ b/examples/vhost/main.c > @@ -466,6 +466,33 @@ us_vhost_usage(const char *prgname) > prgname); > } > > +enum { > +#define OPT_VM2VM "vm2vm" > + OPT_VM2VM_NUM =3D 256, > +#define OPT_RX_RETRY "rx-retry" > + OPT_RX_RETRY_NUM, > +#define OPT_RX_RETRY_DELAY "rx-retry-delay" > + OPT_RX_RETRY_DELAY_NUM, > +#define OPT_RX_RETRY_NUMB "rx-retry-num" > + OPT_RX_RETRY_NUMB_NUM, > +#define OPT_MERGEABLE "mergeable" > + OPT_MERGEABLE_NUM, > +#define OPT_STATS "stats" > + OPT_STATS_NUM, > +#define OPT_SOCKET_FILE "socket-file" > + OPT_SOCKET_FILE_NUM, > +#define OPT_TX_CSUM "tx-csum" > + OPT_TX_CSUM_NUM, > +#define OPT_TSO "tso" > + OPT_TSO_NUM, > +#define OPT_CLIENT "client" > +#define OPT_BUILTIN_NET_DRIVER "builtin-net-driver" > +#define OPT_DMA_TYPE "dma-type" > + OPT_DMA_TYPE_NUM, > +#define OPT_DMAS "dmas" > + OPT_DMAS_NUM, Nit: could you align those last two strings? > +}; > + > /* > * Parse the arguments given in the command line of the application. > */ > @@ -477,19 +504,31 @@ us_vhost_parse_args(int argc, char **argv) > unsigned i; > const char *prgname =3D argv[0]; > static struct option long_option[] =3D { > - {"vm2vm", required_argument, NULL, 0}, > - {"rx-retry", required_argument, NULL, 0}, > - {"rx-retry-delay", required_argument, NULL, 0}, > - {"rx-retry-num", required_argument, NULL, 0}, > - {"mergeable", required_argument, NULL, 0}, > - {"stats", required_argument, NULL, 0}, > - {"socket-file", required_argument, NULL, 0}, > - {"tx-csum", required_argument, NULL, 0}, > - {"tso", required_argument, NULL, 0}, > - {"client", no_argument, &client_mode, 1}, > - {"builtin-net-driver", no_argument, &builtin_net_driver, = 1}, > - {"dma-type", required_argument, NULL, 0}, > - {"dmas", required_argument, NULL, 0}, > + {OPT_VM2VM, required_argument, > + NULL, OPT_VM2VM_NUM}, > + {OPT_RX_RETRY, required_argument, > + NULL, OPT_RX_RETRY_NUM}, > + {OPT_RX_RETRY_DELAY, required_argument, > + NULL, OPT_RX_RETRY_DELAY_NUM}, > + {OPT_RX_RETRY_NUMB, required_argument, > + NULL, OPT_RX_RETRY_NUMB_NUM}, > + {OPT_MERGEABLE, required_argument, > + NULL, OPT_MERGEABLE_NUM}, > + {OPT_STATS, required_argument, > + NULL, OPT_STATS_NUM}, > + {OPT_SOCKET_FILE, required_argument, > + NULL, OPT_SOCKET_FILE_NUM}, > + {OPT_TX_CSUM, required_argument, > + NULL, OPT_TX_CSUM_NUM}, > + {OPT_TSO, required_argument, > + NULL, OPT_TSO_NUM}, > + {OPT_CLIENT, no_argument, &client_mode, 1}, > + {OPT_BUILTIN_NET_DRIVER, no_argument, > + &builtin_net_driver, 1}, We will have an issue here. Quoting the manual: """ flag specifies how results are returned for a long option. If flag is NULL, then getopt_long() returns val. (For example, the calling program may set val to the equivalent short option charac=E2=80=90 ter.) Otherwise, getopt_long() returns 0, and flag points to a variable which is set to val if the option is found, but left unchanged if the option is not found. """ $ build/examples/dpdk-vhost --no-huge -m 1024 -l 0,1 -a 0:0.0 -- --builtin-net-driver --socket-file /tmp/sock0 -p 0x1 EAL: Detected 8 lcore(s) EAL: Detected 1 NUMA nodes EAL: Multi-process socket /run/user/114840/dpdk/rte/mp_socket EAL: Selected IOVA mode 'VA' EAL: Probing VFIO support... VHOST_CONFIG: build/examples/dpdk-vhost [EAL options] -- -p PORTMASK --vm2vm [0|1|2] --rx_retry [0|1] --mergeable [0|1] --stats [0-N] --socket-file --nb-devices ND -p PORTMASK: Set mask for ports to be used by application --vm2vm [0|1|2]: disable/software(default)/hardware vm2vm comms --rx-retry [0|1]: disable/enable(default) retries on rx. Enable retry if destintation queue is full --rx-retry-delay [0-N]: timeout(in usecond) between retries on RX. This makes effect only if retries on rx enabled --rx-retry-num [0-N]: the number of retries on rx. This makes effect only if retries on rx enabled --mergeable [0|1]: disable(default)/enable RX mergeable buffers --stats [0-N]: 0: Disable stats, N: Time in seconds to print stats --socket-file: The path of the socket file. --tx-csum [0|1] disable/enable TX checksum offload. --tso [0|1] disable/enable TCP segment offload. --client register a vhost-user socket as client mode. --dma-type register dma type for your vhost async driver. For example "ioat" for now. --dmas register dma channel for specific vhost device. EAL: Error - exiting with code: 1 Cause: Invalid argument This is because getopt_long returned 0. We have two solutions: - we keep this &builtin_net_driver flag use, but we must accept a 0 return value from getopt_long. - we convert this option to the same scheme as the other and add a OPT_BUILTIN_NET_DRIVER_NUM like other options in this example, Maxime, opinion? --=20 David Marchand