From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4084C43218 for ; Tue, 11 Jun 2019 08:58:25 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 46C4520657 for ; Tue, 11 Jun 2019 08:58:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="UVUyq/XJ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="udc6jkxw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46C4520657 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=marvell.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 56B761C2F3; Tue, 11 Jun 2019 10:58:23 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id D45C61C2F1 for ; Tue, 11 Jun 2019 10:58:21 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5B8tpEl020924; Tue, 11 Jun 2019 01:58:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=/YCk+LTpFaqg6nUcMhWhCHHPn1i860OZDuwamelz7fc=; b=UVUyq/XJ+4Dg8s82KQqeJ1jfgRwalSMul+Got7NvdLhyBZ002QMsJfezdqoU9gnPObQd dzVIm8qLvoZ5Vl1YnYadwEg9vMTXnzAL/s5RQ1pX1cL1+PrQ/QQvk1fsM9i3UjacCdV+ vBOhSHFBedWQYDzBuVyyHpHAIrtwUcLaB0d1mzecMIop8KOgyG8+R068/S2gDXadCXHY Xg4VqI2FiJgsLsdJQOF/SHLCeWIjcAX7NTmqY9SJVnLiK+WUmjdbv3FNZMvUffKIqNwR eGA9YNUMSTRsgW4iVwwDPAdTkMByfUefrslhVsak/nfjY+kQMDmzUPEkP13ja38wDDqe dA== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2t20h321cn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 11 Jun 2019 01:58:20 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 11 Jun 2019 01:58:19 -0700 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (104.47.46.53) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Tue, 11 Jun 2019 01:58:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/YCk+LTpFaqg6nUcMhWhCHHPn1i860OZDuwamelz7fc=; b=udc6jkxw35qtqKFx5O1vxW5SnoR52oJDBs0gcBW1unOuVS8LbSA9G3edVyuW6pXoa+apLSGXKooObTouvZkj8JLqy//xMVh0kqETW0A1yt+rnecMrY8f4xc6d44o/5B7mnujLBZHYrPigAstIlHUSEPPDwpfPhWZlSnZ+zXSbgk= Received: from BN8PR18MB2691.namprd18.prod.outlook.com (20.179.72.94) by BN8PR18MB2835.namprd18.prod.outlook.com (20.179.74.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1965.17; Tue, 11 Jun 2019 08:58:13 +0000 Received: from BN8PR18MB2691.namprd18.prod.outlook.com ([fe80::b86e:d3b3:34b4:377e]) by BN8PR18MB2691.namprd18.prod.outlook.com ([fe80::b86e:d3b3:34b4:377e%5]) with mapi id 15.20.1965.017; Tue, 11 Jun 2019 08:58:13 +0000 From: Sunil Kumar Kori To: Anoob Joseph , Jerin Jacob Kollanukkaran , Nikhil Rao , "Erik Gabriel Carrillo" , Abhinandan Gujjar , Bruce Richardson , Pablo de Lara CC: Anoob Joseph , Narayana Prasad Raju Athreya , "dev@dpdk.org" , Lukas Bartosik , Pavan Nikhilesh Bhagavatula , Hemant Agrawal , "Nipun Gupta" , Harry van Haaren , =?iso-8859-1?Q?Mattias_R=F6nnblom?= , Liang Ma Thread-Topic: [EXT] [dpdk-dev] [PATCH 16/39] eventdev: add eventmode CL options framework Thread-Index: AQHVGjLkVuTwAEUyEEyP2A2uFSGWuKaWJcdw Date: Tue, 11 Jun 2019 08:58:13 +0000 Message-ID: References: <1559583160-13944-1-git-send-email-anoobj@marvell.com> <1559583160-13944-17-git-send-email-anoobj@marvell.com> In-Reply-To: <1559583160-13944-17-git-send-email-anoobj@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [14.140.231.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a3c313a9-74ee-4d7a-efd5-08d6ee4aefb9 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:BN8PR18MB2835; x-ms-traffictypediagnostic: BN8PR18MB2835: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 006546F32A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(376002)(39860400002)(346002)(189003)(199004)(13464003)(446003)(186003)(52536014)(74316002)(476003)(99286004)(53936002)(26005)(7736002)(11346002)(25786009)(6506007)(7696005)(76116006)(305945005)(6116002)(4326008)(64756008)(81156014)(76176011)(3846002)(71200400001)(102836004)(66946007)(81166006)(71190400001)(66446008)(6246003)(66556008)(66476007)(256004)(73956011)(9686003)(55236004)(478600001)(2906002)(5660300002)(86362001)(486006)(8936002)(68736007)(33656002)(110136005)(14454004)(54906003)(7416002)(229853002)(55016002)(66066001)(6436002)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN8PR18MB2835; H:BN8PR18MB2691.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: NdbwhQuGYIgpP0VYM8CcTTfGnq90CUcBSEk1usaqvMxOHXQdrssWVApZpJ2+IAuvvvCIZ3HCcNikvY9jyP45tIEstJC5jOEeTtUiTSz9yWPCT9I1zuQrRzAMthyAv1mk20M2TmQUtY9Rb4+epeseYe6qOuyDB1Gh/FTR+DEartaW+PncdYVp9T7CqTtvvhuLeMeDHI4nep7N7aMXqOFrbcxjjvIPUXRTqAmMpaN55z7YUiTpaWvhz4q8suiVFla5DcygUOpjtiZH5AVdBed7g5+uwk/jnd9/OLEaGTLdkU6VKd7z3jE/8aHf5wAMU6+iRdZLUYn7kfHXtqHc6UwczrXeP+0m9q/8tc8x3MdKVETh/TW3pUXqbpdNlA7VVgS1vG9OkHaqrOyTJCzgk0+V64RBp+/jM7q7B8T72sp+q6Q= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: a3c313a9-74ee-4d7a-efd5-08d6ee4aefb9 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jun 2019 08:58:13.5565 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: skori@marvell.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR18MB2835 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-11_04:, , signatures=0 Subject: Re: [dpdk-dev] [EXT] [PATCH 16/39] eventdev: add eventmode CL options framework 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" Regards Sunil Kumar Kori >-----Original Message----- >From: dev On Behalf Of Anoob Joseph >Sent: Monday, June 3, 2019 11:02 PM >To: Jerin Jacob Kollanukkaran ; Nikhil Rao >; Erik Gabriel Carrillo ; >Abhinandan Gujjar ; Bruce Richardson >; Pablo de Lara > >Cc: Anoob Joseph ; Narayana Prasad Raju Athreya >; dev@dpdk.org; Lukas Bartosik >; Pavan Nikhilesh Bhagavatula >; Hemant Agrawal >; Nipun Gupta ; Harry >van Haaren ; Mattias R=F6nnblom >; Liang Ma >Subject: [EXT] [dpdk-dev] [PATCH 16/39] eventdev: add eventmode CL options >framework > >External Email > >---------------------------------------------------------------------- >Adding usage prints and CL parsing routines for eventmode. Option to selec= t >packet transfer mode is also added. > >Signed-off-by: Anoob Joseph >Signed-off-by: Lukasz Bartosik >--- > lib/librte_eventdev/rte_eventdev_version.map | 2 + > lib/librte_eventdev/rte_eventmode_helper.c | 128 >+++++++++++++++++++++++++++ > lib/librte_eventdev/rte_eventmode_helper.h | 51 +++++++++++ > 3 files changed, 181 insertions(+) > >diff --git a/lib/librte_eventdev/rte_eventdev_version.map >b/lib/librte_eventdev/rte_eventdev_version.map >index 95fd089..1199064 100644 >--- a/lib/librte_eventdev/rte_eventdev_version.map >+++ b/lib/librte_eventdev/rte_eventdev_version.map >@@ -128,4 +128,6 @@ EXPERIMENTAL { > > rte_event_eth_rx_adapter_cb_register; > rte_event_eth_rx_adapter_stats_get; >+ rte_eventmode_helper_print_options_list; >+ rte_eventmode_helper_print_options_description; > }; >diff --git a/lib/librte_eventdev/rte_eventmode_helper.c >b/lib/librte_eventdev/rte_eventmode_helper.c >index f47970e..8119306 100644 >--- a/lib/librte_eventdev/rte_eventmode_helper.c >+++ b/lib/librte_eventdev/rte_eventmode_helper.c >@@ -1,7 +1,135 @@ > /* SPDX-License-Identifier: BSD-3-Clause > * Copyright (C) 2019 Marvell International Ltd. > */ >+#include > > #include >+#include > > #include "rte_eventmode_helper_internal.h" >+ >+#define CMD_LINE_OPT_TRANSFER_MODE "transfer-mode" >+ >+static const char short_options[] =3D >+ "" >+ ; >+ >+enum { >+ /* long options mapped to a short option */ >+ >+ /* first long only option value must be >=3D 256, so that we won't >+ * conflict with short options >+ */ >+ CMD_LINE_OPT_MIN_NUM =3D 256, >+ CMD_LINE_OPT_TRANSFER_MODE_NUM, >+}; >+ >+static const struct option lgopts[] =3D { >+ {CMD_LINE_OPT_TRANSFER_MODE, 1, 0, >CMD_LINE_OPT_TRANSFER_MODE_NUM}, >+ {NULL, 0, 0, 0} >+}; >+ >+/* Internal functions */ >+ >+static int32_t >+internal_parse_decimal(const char *str) { >+ char *end =3D NULL; >+ unsigned long num; >+ >+ num =3D strtoul(str, &end, 10); >+ if ((str[0] =3D=3D '\0') || (end =3D=3D NULL) || (*end !=3D '\0')) >+ return -1; >+ >+ return num; >+} >+ >+/* Global functions */ >+ >+void __rte_experimental >+rte_eventmode_helper_print_options_list(void) >+{ >+ fprintf(stderr, " --" >+ " [--transfer-mode MODE]" >+ ); >+} >+ >+void __rte_experimental >+rte_eventmode_helper_print_options_description(void) >+{ >+ fprintf(stderr, >+ " --transfer-mode MODE\n" >+ " 0: Packet transfer via polling (default)\n" >+ " 1: Packet transfer via eventdev\n" >+ "\n"); >+} >+ Instead of exposing rte_eventmode_helper_print_options_* , we can maintain = a page where all event_helper options are mentioned. Also application usage= function can be updated like fprintf(stderr, "%s [EAL options] --" " -p PORTMASK" " [-q NQ]", " -- [event helper options]" prgname); Advantages: Both functions will be removed from set of APIs and usage func= tion will not be changed much. Suggesting the same methodology as used for = EAL options. >+static int >+em_parse_transfer_mode(struct rte_eventmode_helper_conf *conf, >+ const char *optarg) >+{ >+ int32_t parsed_dec; >+ >+ parsed_dec =3D internal_parse_decimal(optarg); >+ if (parsed_dec !=3D >RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_POLL && >+ parsed_dec !=3D >RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_EVENT) { >+ RTE_EM_HLPR_LOG_ERR("Unsupported packet transfer >mode"); >+ return -1; >+ } >+ conf->mode =3D parsed_dec; >+ return 0; >+} >+ >+static void >+em_initialize_helper_conf(struct rte_eventmode_helper_conf *conf) { >+ /* Set default conf */ >+ >+ /* Packet transfer mode: poll */ >+ conf->mode =3D >RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_POLL; >+} >+ >+struct rte_eventmode_helper_conf * >+rte_eventmode_helper_parse_args(int argc, char **argv) { >+ int32_t opt, ret; >+ struct rte_eventmode_helper_conf *conf =3D NULL; >+ >+ /* Allocate memory for conf */ >+ conf =3D rte_zmalloc("eventmode-helper-conf", >+ sizeof(struct rte_eventmode_helper_conf), >+ RTE_CACHE_LINE_SIZE); >+ if (conf =3D=3D NULL) { >+ RTE_EM_HLPR_LOG_ERR( >+ "Failed allocating memory for eventmode helper >conf"); >+ goto err; >+ } >+ Memory allocation for conf and conf->mode_params can be done in single allo= c operation as given below: size =3D sizeof(struct rte_eventmode_helper_conf) + sizeof(struct eventmod= e_conf); conf =3D malloc(size); conf->mode_params =3D conf + 1; =09 Advantages: one NULL check will be avoided. To release the memory, need to = free one pointer only. line of source code will be reduced. >+ /* Initialize conf with default values */ >+ em_initialize_helper_conf(conf); >+ >+ while ((opt =3D getopt_long(argc, argv, short_options, >+ lgopts, NULL)) !=3D EOF) { >+ switch (opt) { >+ >+ /* Packet transfer mode */ >+ case CMD_LINE_OPT_TRANSFER_MODE_NUM: >+ ret =3D em_parse_transfer_mode(conf, optarg); >+ if (ret < 0) { >+ RTE_EM_HLPR_LOG_ERR( >+ "Invalid packet transfer mode"); >+ goto err; >+ } >+ break; >+ default: >+ goto err; >+ } >+ } >+ return conf; >+ >+err: >+ if (conf !=3D NULL) >+ rte_free(conf); >+ >+ return NULL; >+} >diff --git a/lib/librte_eventdev/rte_eventmode_helper.h >b/lib/librte_eventdev/rte_eventmode_helper.h >index d32cd00..2a0cb30 100644 >--- a/lib/librte_eventdev/rte_eventmode_helper.h >+++ b/lib/librte_eventdev/rte_eventmode_helper.h >@@ -8,6 +8,57 @@ > extern "C" { > #endif > >+#include >+ >+/* Packet transfer mode of the application */ enum >+rte_eventmode_helper_pkt_transfer_mode { >+ RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_POLL =3D 0, >+ RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_EVENT, >+}; >+ >+struct rte_eventmode_helper_conf { >+ enum rte_eventmode_helper_pkt_transfer_mode mode; >+ /**< Packet transfer mode of the application */ >+ void *mode_params; >+ /**< Mode specific parameters */ >+}; >+ >+/* Common helper functions for command line parsing */ >+ >+/** >+ * Print event mode options list >+ * >+ */ >+void __rte_experimental >+rte_eventmode_helper_print_options_list(void); >+ >+/** >+ * Print event mode options description >+ * >+ */ >+void __rte_experimental >+rte_eventmode_helper_print_options_description(void); >+ >+/** >+ * Parse event mode arguments >+ * >+ * The application can call this function in it's argument parsing >+routine to >+ * parse the event mode specific args and create the conf accordingly. >+This >+ * function is to be executed on the MASTER lcore only. >+ * >+ * @param argc >+ * A non-negative value. If it is greater than 0, the array members >+ * for argv[0] through argv[argc] (non-inclusive) shall contain pointer= s >+ * to strings. >+ * @param argv >+ * An array of strings. The contents of the array, as well as the strin= gs >+ * which are pointed to by the array, may be modified by this function. >+ * @return >+ * Configuration generated by parsing the event mode args. >+ */ >+struct rte_eventmode_helper_conf * >+rte_eventmode_helper_parse_args(int argc, char **argv); >+ > #ifdef __cplusplus > } > #endif >-- >2.7.4