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 DDF2E4369D; Thu, 7 Dec 2023 17:19:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4962042F73; Thu, 7 Dec 2023 17:18:48 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id CBF2342F4F for ; Thu, 7 Dec 2023 17:18:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701965926; x=1733501926; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ntTCL7ZgxcrHmd3eNMTw872VD78V+HYFJAaokwfMgTE=; b=EWBSAqD86LwAxYRJsHXkVZbULV7z+h5qSBhk3A0BXellwFdl5WeZhJ1w FvMjZKIm1I0Xce6rjRxzptF15b+V8DTePypkSfTLsuqM0EHezzvX5GYFn Bngqw5GXrwa9/GiV6GrFe9bWT8y+DxFacwrq8YwEjeYynoOpNvzTDMm8w BE73UxfcfFsLo8oaKMajTfQhuSwXZHSyhNJO4S0IjnPb8ExpzRmhbKosy eNw+4JCuT5rRRaNuxKKcFfHowCtP780d7B0ZDLfwEpTOkmw7W9WIR1UDV UeEVUp8SBILtAeMNObszTR1UzpefU1jP4aYBsd36w7BSev0z9OArC2Dde A==; X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="397048630" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="397048630" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 08:18:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="765153987" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="765153987" Received: from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151]) by orsmga007.jf.intel.com with ESMTP; 07 Dec 2023 08:18:44 -0800 From: Euan Bourke To: dev@dpdk.org Cc: Euan Bourke , Harry van Haaren Subject: [PATCH v3 7/8] examples/eventdev_pipeline: update to call arg parser API Date: Thu, 7 Dec 2023 16:18:17 +0000 Message-Id: <20231207161818.2590661-8-euan.bourke@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207161818.2590661-1-euan.bourke@intel.com> References: <20231207161818.2590661-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 | 65 +++----------------- examples/eventdev_pipeline/pipeline_common.h | 1 + 2 files changed, 10 insertions(+), 56 deletions(-) diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c index 0c995d1a70..c59d01e7a5 100644 --- a/examples/eventdev_pipeline/main.c +++ b/examples/eventdev_pipeline/main.c @@ -56,69 +56,22 @@ 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), 0); - 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