From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0079.outbound.protection.outlook.com [104.47.42.79]) by dpdk.org (Postfix) with ESMTP id 7B8A51BB0E for ; Fri, 8 Jun 2018 19:25:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xOSHeKyS7XdVLRlN8b5wKhbklwIbuvxXXO2Vvfc44Zc=; b=UbSlGODZ+MnrUKt+jhilxGede0FfP+FAfyMbm4Pbxu0X0eqT8DpFBY5epUYunoL6nmw2kGQeJqV+WPCTNUO1KxrsrtaRk7sYSeoN5gri0CvNWh9NE6BMmxI0a0MUjIIC3xdiaokDAJ5A+fr+jlvWBZORx4uABoFBUUTK3npnnTU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; Received: from ajoseph83.caveonetworks.com.caveonetworks.com (115.113.156.2) by DM6PR07MB4906.namprd07.prod.outlook.com (2603:10b6:5:a3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.841.17; Fri, 8 Jun 2018 17:25:07 +0000 From: Anoob Joseph To: Bruce Richardson , Jerin Jacob , Pablo de Lara Cc: Anoob Joseph , Hemant Agrawal , Narayana Prasad , Nikhil Rao , Pavan Nikhilesh , Sunil Kumar Kori , dev@dpdk.org Date: Fri, 8 Jun 2018 22:54:02 +0530 Message-Id: <1528478659-15859-4-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528478659-15859-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1528478659-15859-1-git-send-email-anoob.joseph@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: BM1PR0101CA0050.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::12) To DM6PR07MB4906.namprd07.prod.outlook.com (2603:10b6:5:a3::11) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM6PR07MB4906; X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4906; 3:lsed3pLz0RJPwzz6Lf5AINScoQRayGwLSZOksbMwjiAtP+Y/eRnVQlXKN6Ntc7UJJly2yFMkPnzPZiThV1RmwGhO0V88OUS9pqtK1dyEVYw40igBJX4LWCHnT/rXrD9NoVCISSEShnwqsNtndVHsyPqaqb2uqJF9psaQogj8CGquklXQqkQ5Q0M0njQ/NLGgsN2aRBBJ6CgkJtfTt4vPm7+gc4I3a+DmTSXOdxazgBkB2BK3yqZrGhYurOL2/l6S; 25:UQLY/gyw6E5f1fxWWGWcFhztnlTVmre20Cri119cprxWRMo25b/j6CtC3hFjH6+pTCQDYBkCehq/7bFWFx5z8Y6aN+G/mLnHMSvzBuxwmKoEMTJn2IUVUCLm7UeRD9i4AQeYrn/dbx5U7qYrUcmV5mmDgZzYNRX7RDNU/yVRl1cfW2IFwphxdln2XXHw7NBKdk4rc12xAXPODuucoSxhMzxsqWAHv+EiJhrj2qlt57jJEnoWUTbZA/6GXWN+3fiCusH30D5N9PCJZrsI0ZSzjhbf/0IwZO8gIwuekDb8uVl7LnTHKbQf6LKTg3SwBzY+nET+Baio9T66Hs/9S8Mm9A==; 31:5vYkc156KHUnrxpJFlLvkVH2pAKSImYLh3Q5lsBJkLDoOtfLPWAvqbXzNv5taZhck53H/oKyA1W0XhqloZORjhj2w942tfddwJAt9r3yTPpsHmpXujpSzoSIm4dKj3tFqAmCj5N2XYezFK7JgzKzUAmPTskumVZmFZjyYuBzekzNCmXBaen5QcO7lVvXCnX1TCYfmpGDFI2BdTjoTdrn5Obi03I1kwcvtBVF9Wk0ZEY= X-MS-TrafficTypeDiagnostic: DM6PR07MB4906: X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4906; 20:muTxdZ/2LFecLU1Xt3ZJOLRYUFHKMaZBt464ijM2vun1fh4jLa8KGAA+QsB/eBm0hk+XC6ufSQBgjSE7+gOv0ur/QXBmKNT3P0lv+E6S7AKdVnvyicyCyh8Jh1GOVSc6w6kfrU2CfsNTTjHiE0NwgG3LKyoCh1pXQX3jhbwdMzLLdqa9xv7NkDD9BWAYY5PlnFWFKi3KIyauOfXmrUqoHpV5FV25IWIKEKoNHIv4BbG6CzG6+1tls+XlAck1CRiu21qTNfIeZZOzJy/wEsBoXsUwFg5qLsFjG0b0KFU7zgZD/AheLG8ZTCcVSe8SWWftrNiRnBSxWW6y3TowVMnR3K5irUixq+xN458kcPnJ43WZt9nZse6aGoAy88+hpAYq8dDdhD6tIDlPTXkGjWmamBUDQWydy7K3qVT7vtVmmjrh0AHEZRfGf8GKhuwIL3gilEhwvjCbh880voF1Oio4GHSKxkd0/7JHtlWc5cRpyEPIlsISoXuwn77POdpHIvE0FhjBtZ9hY9AOjAnRrnmoABL7LmhHxWLmvtW5YnSj40Eue50xVsXrePaRy3B9Q0T3VQk6w39PDegri4/PSq178Rd5mpri52a5xN0bBwqO+OI=; 4:Fd0iCkji2Yd+UzdlBwHMXdbz3ZomUgT5rQ+4GhqDgSetp1Lvjg8OojgaNl0VEQs0s5g4USfD2ThIMFMwghmLAMX+KalJ9OV2SNV59aN/U+KB1bNbAxGcTp/hjnjTlCtYU+7+riA8X6Ws+QLp6eSUyNzKBMYpxqFY0LfMiDkco/U4OPZlJksxoviwgNqA0+vMogpIrknA9kg6l8uzweFqcmXxDz5BiXCG01nk+UD6wC9yu8pzPBn4GzR02mhUfUT7ih6xjVLvlgk4qIchDRF/eQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(3231254)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:DM6PR07MB4906; BCL:0; PCL:0; RULEID:; SRVR:DM6PR07MB4906; X-Forefront-PRVS: 06973FFAD3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(366004)(376002)(396003)(39380400002)(189003)(199004)(186003)(16526019)(5660300001)(26005)(42882007)(55236004)(66066001)(47776003)(68736007)(6666003)(305945005)(2906002)(8676002)(7736002)(8936002)(36756003)(52116002)(2616005)(956004)(476003)(446003)(50226002)(81166006)(11346002)(44832011)(6506007)(386003)(486006)(76176011)(51416003)(48376002)(50466002)(97736004)(316002)(6512007)(25786009)(53936002)(6486002)(81156014)(4326008)(3846002)(6116002)(16586007)(54906003)(110136005)(105586002)(106356001)(72206003)(478600001)(8656006); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR07MB4906; H:ajoseph83.caveonetworks.com.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR07MB4906; 23:4xgg/b1wGq7kFv+Bb60RaonK+GAiMxLfbK+5D5COS?= =?us-ascii?Q?BQtq21g/ObZWFKLKsVfsJfNUFoMjOb8YVkVR0K4uvUlzLh0k/n/uzsCyPDn/?= =?us-ascii?Q?Uip7q1dk3R26VQG5bYYdvWMey/XjWb1PYe4IGfXldXMdXT/gGsZwGOzxwcIB?= =?us-ascii?Q?WTiQA7VFeivwDa4tGgrC87NS6VHJo3wzeHKG61QY49kLHpf9NDOgAg1HcLo2?= =?us-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1ajXvlNAEjZtJH8Ey/KD0E7apqzrVm086ksErM09nYgJn5BQMRmFX1xLZMSFP6yMXtDz50=; 24:92jaFLXiPF52wr5mccXBVi77MYRgM0r+ER869tkA43XV7b8nrukkdXUZwyGSM2FEvLPjJz+K/Ge0txSRb3WAFawB+CcMrJQsEiHie3m8hdE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4906; 7:vCUhmijPDTm9EcD7J9zjOCz876/1jW3TnvaT9rhtIC9K5/fnkTLPmzUHO/sdPj8YrNGtMDAOP4djh/2OeayuOAk5WCZldpBbkaGIQKR/umzJWxB6TVxZofk2bFfPsdH6pgYpsbq1m9McW1fu/ZdEE418haXujSeRlzw6uOlDOQ+/ZLxGef0ubydELSH+mkO33nCX/vy+cl02afAKopyyzAoFQlRF/4eNyFYPPdzKzNpWd9ew2OgXmFJmNDkp7QkB X-MS-Office365-Filtering-Correlation-Id: 7e562e18-4062-431e-32d5-08d5cd64c970 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2018 17:25:07.4821 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e562e18-4062-431e-32d5-08d5cd64c970 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR07MB4906 Subject: [dpdk-dev] [PATCH 03/20] 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: , X-List-Received-Date: Fri, 08 Jun 2018 17:25:12 -0000 Adding usage prints and CL parsing routines for eventmode. Option to select packet transfer mode is also added. Signed-off-by: Anoob Joseph --- lib/librte_eventdev/rte_eventmode_helper.c | 128 +++++++++++++++++++++++++++++ lib/librte_eventdev/rte_eventmode_helper.h | 50 +++++++++++ 2 files changed, 178 insertions(+) diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c index b7ff056..14ea493 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) 2018 Cavium, Inc */ +#include #include +#include #include "rte_eventmode_helper_internal.h" + +#define CMD_LINE_OPT_TRANSFER_MODE "transfer-mode" + +static const char short_options[] = + "" + ; + +enum { + /* long options mapped to a short option */ + + /* first long only option value must be >= 256, so that we won't + * conflict with short options + */ + CMD_LINE_OPT_MIN_NUM = 256, + CMD_LINE_OPT_TRANSFER_MODE_NUM, +}; + +static const struct option lgopts[] = { + {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 = NULL; + unsigned long num; + + num = strtoul(str, &end, 10); + if ((str[0] == '\0') || (end == NULL) || (*end != '\0')) + return -1; + + return num; +} + +/* Global functions */ + +void +rte_eventmode_helper_print_options_list(void) +{ + fprintf(stderr, " --" + " [--transfer-mode MODE]" + ); +} + +void +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"); +} + +static int +em_parse_transfer_mode(struct rte_eventmode_helper_conf *conf, + const char *optarg) +{ + int32_t parsed_dec; + + parsed_dec = internal_parse_decimal(optarg); + if (parsed_dec != RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_POLL && + parsed_dec != RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_EVENT) { + RTE_EM_HLPR_LOG_ERR("Unsupported packet transfer mode"); + return -1; + } + conf->mode = 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 = 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 = NULL; + + /* Allocate memory for conf */ + conf = rte_zmalloc("eventmode-helper-conf", + sizeof(struct rte_eventmode_helper_conf), + RTE_CACHE_LINE_SIZE); + if (conf == NULL) { + RTE_EM_HLPR_LOG_ERR( + "Failed allocating memory for eventmode helper conf"); + goto err; + } + + /* Initialize conf with default values */ + em_initialize_helper_conf(conf); + + while ((opt = getopt_long(argc, argv, short_options, + lgopts, NULL)) != EOF) { + switch (opt) { + + /* Packet transfer mode */ + case CMD_LINE_OPT_TRANSFER_MODE_NUM: + ret = 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 != 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 5d39bd3..bfe4fa9 100644 --- a/lib/librte_eventdev/rte_eventmode_helper.h +++ b/lib/librte_eventdev/rte_eventmode_helper.h @@ -3,4 +3,54 @@ */ #ifndef _RTE_EVENTMODE_HELPER_H_ #define _RTE_EVENTMODE_HELPER_H_ + +/* Packet transfer mode of the application */ +enum rte_eventmode_helper_pkt_transfer_mode { + RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_POLL = 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_eventmode_helper_print_options_list(void); + +/** + * Print event mode options description + * + */ +void +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 pointers + * to strings. + * @param argv + * An array of strings. The contents of the array, as well as the strings + * 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); + #endif /* _RTE_EVENTMODE_HELPER_H_ */ -- 2.7.4