From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2018443700; Fri, 15 Dec 2023 18:27:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E64C3433B5; Fri, 15 Dec 2023 18:27:05 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by mails.dpdk.org (Postfix) with ESMTP id 0E71D433BF for ; Fri, 15 Dec 2023 18:27:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702661224; x=1734197224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5l5sU4EugsPauK8Vfoc5qJj20SctflAYnknNS1cEcZ0=; b=SZdtb8EYiKDCIh/GR9AP6K99NdTeL4TnnaUbBYxX6NOWzig92qbsXMHb KqKLExqk1F764SBk/BI6hl5wQKvwtJTLtDkU3E6OKyMRJNCzjOx7TUwoo JA4/093PapUxjDqJGj9lZyOrnaTjygtgTzmfBY3T6VYjJRZljZDzjAm5y poLejAh9+4Xw0UDhulwNzoFsCY6nvZ0F3UKKrP7XNyiXk3C692FsfQHjM qYNXPqhPZA6IyMfyMJIy/zOhUqHZ5kqixPbH1pwsXokCWOCdfvyxCdKfK /RInA6DjbO0tQ9Qs47niXWi52R48LreX3ad5G3L+iFpvy67jYsFNzxg96 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10925"; a="2474259" X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="2474259" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2023 09:27:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="22914289" Received: from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151]) by orviesa001.jf.intel.com with ESMTP; 15 Dec 2023 09:27:03 -0800 From: Euan Bourke To: dev@dpdk.org Cc: Euan Bourke , Harry van Haaren Subject: [PATCH v4 7/8] examples/eventdev_pipeline: update to call arg parser API Date: Fri, 15 Dec 2023 17:26:31 +0000 Message-Id: <20231215172632.3102502-8-euan.bourke@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231215172632.3102502-1-euan.bourke@intel.com> References: <20231215172632.3102502-1-euan.bourke@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Update to the eventdev_pipeline example application to call the arg parser library for its 'combined core string parser' instead of implementing its own coremask parser. The default_type passed into the function call is a coremask. Signed-off-by: Euan Bourke --- examples/eventdev_pipeline/main.c | 66 +++----------------- examples/eventdev_pipeline/pipeline_common.h | 1 + 2 files changed, 11 insertions(+), 56 deletions(-) diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c index 0c995d1a70..edd0e2c843 100644 --- a/examples/eventdev_pipeline/main.c +++ b/examples/eventdev_pipeline/main.c @@ -56,69 +56,23 @@ core_in_use(unsigned int lcore_id) { fdata->tx_core[lcore_id] || fdata->worker_core[lcore_id]); } -/* - * Parse the coremask given as argument (hexadecimal string) and fill - * the global configuration (core role and core count) with the parsed - * value. - */ -static int xdigit2val(unsigned char c) -{ - int val; - - if (isdigit(c)) - val = c - '0'; - else if (isupper(c)) - val = c - 'A' + 10; - else - val = c - 'a' + 10; - return val; -} - static uint64_t parse_coremask(const char *coremask) { - int i, j, idx = 0; - unsigned int count = 0; - char c; - int val; + int count; + uint16_t i; uint64_t mask = 0; - const int32_t BITS_HEX = 4; + uint16_t cores[RTE_MAX_LCORE]; - if (coremask == NULL) - return -1; - /* Remove all blank characters ahead and after . - * Remove 0x/0X if exists. - */ - while (isblank(*coremask)) - coremask++; - if (coremask[0] == '0' && ((coremask[1] == 'x') - || (coremask[1] == 'X'))) - coremask += 2; - i = strlen(coremask); - while ((i > 0) && isblank(coremask[i - 1])) - i--; - if (i == 0) - return -1; + count = rte_arg_parse_core_string(coremask, cores, RTE_DIM(cores), + RTE_ARG_PARSE_TYPE_COREMASK); - for (i = i - 1; i >= 0 && idx < MAX_NUM_CORE; i--) { - c = coremask[i]; - if (isxdigit(c) == 0) { - /* invalid characters */ - return -1; - } - val = xdigit2val(c); - for (j = 0; j < BITS_HEX && idx < MAX_NUM_CORE; j++, idx++) { - if ((1 << j) & val) { - mask |= (1ULL << idx); - count++; - } - } - } - for (; i >= 0; i--) - if (coremask[i] != '0') - return -1; - if (count == 0) + if (count == 0 || count == -1) return -1; + + for (i = 0; i < count; i++) + mask |= 1ULL << cores[i]; + return mask; } diff --git a/examples/eventdev_pipeline/pipeline_common.h b/examples/eventdev_pipeline/pipeline_common.h index 28b6ab85ff..2b97a29bfc 100644 --- a/examples/eventdev_pipeline/pipeline_common.h +++ b/examples/eventdev_pipeline/pipeline_common.h @@ -6,6 +6,7 @@ #include +#include #include #include #include -- 2.34.1