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 4A3E54369D; Thu, 7 Dec 2023 17:19:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F8A342F0D; Thu, 7 Dec 2023 17:18:49 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 9293242F73 for ; Thu, 7 Dec 2023 17:18:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701965927; x=1733501927; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PpOYE0dStoI251F0PbA1DOxL8iUA7tRPyFD/F9z/4CE=; b=XA8VjcgaDJw9igP7IoTolKNahgpnD0btmwPMGPDVcyqx7I2/9TZK/qqV CsxoJiyJ9Uh4V9MJAfTveAklddBlFeCDdaqOGKdFeHS0N+PQhp6m8DCfu C/eHNWtvjTT06FeaX7ehj2cpcl/KFPGyLzYGi5uBa1k+aysGMEU9a/iyh zo+JsOV78Y1+G1jJ0WpoH3v2NJdAgMO4Q4bUOoOwZAVI84DlYTC5plM1t yptNOZKSNrNaeKXi1XjpK5Tk3qYeAu4Efn85wBEXhJl5Zel0i7vpJgsCv N/hmqXTeWoPckcVx5XUNtFL4tCS5t6XNYKBsAzpQVogoQvPPhu5deM7G+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="397048631" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="397048631" 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:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="765153990" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="765153990" Received: from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151]) by orsmga007.jf.intel.com with ESMTP; 07 Dec 2023 08:18:45 -0800 From: Euan Bourke To: dev@dpdk.org Cc: Euan Bourke , Anatoly Burakov , David Hunt , Sivaprasad Tummala Subject: [PATCH v3 8/8] examples/l3fwd-power: update to call arg parser API Date: Thu, 7 Dec 2023 16:18:18 +0000 Message-Id: <20231207161818.2590661-9-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 l3fwd-power example application to call the arg parser library for its 'combined core string parser' instead of implementing its own corelist parser. The default_type passed into the function call is a corelist. Signed-off-by: Euan Bourke --- examples/l3fwd-power/perf_core.c | 51 +++++--------------------------- 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/examples/l3fwd-power/perf_core.c b/examples/l3fwd-power/perf_core.c index 41ef6d0c9a..f8511e30b3 100644 --- a/examples/l3fwd-power/perf_core.c +++ b/examples/l3fwd-power/perf_core.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "perf_core.h" #include "main.h" @@ -177,56 +178,20 @@ parse_perf_config(const char *q_arg) int parse_perf_core_list(const char *corelist) { - int i, idx = 0; - unsigned int count = 0; - char *end = NULL; - int min, max; + int count; + uint16_t cores[RTE_MAX_LCORE]; if (corelist == NULL) { printf("invalid core list\n"); return -1; } + count = rte_arg_parse_core_string(corelist, cores, RTE_DIM(cores), 1); - /* Remove all blank characters ahead and after */ - while (isblank(*corelist)) - corelist++; - i = strlen(corelist); - while ((i > 0) && isblank(corelist[i - 1])) - i--; + for (int i = 0; i < count; i++) + hp_lcores[i] = cores[i]; - /* Get list of cores */ - min = RTE_MAX_LCORE; - do { - while (isblank(*corelist)) - corelist++; - if (*corelist == '\0') - return -1; - errno = 0; - idx = strtoul(corelist, &end, 10); - if (errno || end == NULL) - return -1; - while (isblank(*end)) - end++; - if (*end == '-') { - min = idx; - } else if ((*end == ',') || (*end == '\0')) { - max = idx; - if (min == RTE_MAX_LCORE) - min = idx; - for (idx = min; idx <= max; idx++) { - hp_lcores[count] = idx; - count++; - } - min = RTE_MAX_LCORE; - } else { - printf("invalid core list\n"); - return -1; - } - corelist = end + 1; - } while (*end != '\0'); - - if (count == 0) { + if (count == 0 || count == -1) { printf("invalid core list\n"); return -1; } @@ -234,7 +199,7 @@ parse_perf_core_list(const char *corelist) nb_hp_lcores = count; printf("Configured %d high performance cores\n", nb_hp_lcores); - for (i = 0; i < nb_hp_lcores; i++) + for (uint16_t i = 0; i < nb_hp_lcores; i++) printf("\tHigh performance core %d %d\n", i, hp_lcores[i]); -- 2.34.1