From patchwork Tue Nov 28 14:07:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Euan Bourke X-Patchwork-Id: 134692 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8F00843402; Wed, 29 Nov 2023 17:06:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2F30F42E34; Wed, 29 Nov 2023 17:06:39 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id AAD1342D89 for ; Tue, 28 Nov 2023 15:08:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701180493; x=1732716493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QbYdaPGNXoLY6Fr+VjU9HEuWmyg9z/vp6syFAK9Ubz0=; b=jWgtjKzZHqcqii4zd3HWoQU2HYRPlQHllLLG+coqnCbxkfzaqqcmXGAm v8YBEKTI6DoqJD1ntxQrmOcI4BJNQc9jE48nw+L69Khswrc8wI+MVeV5y kJ13aEonxOZcU/bOAxFpO2wyW2IHP18eq4cbbKia33gWDVNVm/MeOlFlm gLRgeXppdVHdpi3dBWwmpODMtxSOCy0RKTqMR3bwac2VTOhmm/C0neeD5 mdxYSk2pHXBl2o9RqMGqTjLfHtvwE7GzOv6rfUuwC7O6+KgCEYcLXnd9j 55bRRT0hrkGbXbkkHu7qrF2imtmIm1AWfgTnv+iOnbXV1aG2lQNnxTHqP w==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="395747342" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="395747342" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 06:07:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="912450871" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="912450871" Received: from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151]) by fmsmga001.fm.intel.com with ESMTP; 28 Nov 2023 06:07:50 -0800 From: Euan Bourke To: dev@dpdk.org Cc: Euan Bourke , Thomas Monjalon , Bruce Richardson Subject: [PATCH 24.03 v2 1/5] arg_parser: new library for command line parsing Date: Tue, 28 Nov 2023 14:07:41 +0000 Message-Id: <20231128140745.595481-2-euan.bourke@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128140745.595481-1-euan.bourke@intel.com> References: <20231122164550.3873633-1-euan.bourke@intel.com> <20231128140745.595481-1-euan.bourke@intel.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 29 Nov 2023 17:06:37 +0100 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 Add a new library to make it easier for eal and other libraries to parse command line arguments. The first function in this library is one to parse a corelist string into an array of individual core ids. The function will then return the total number of cores described in the corelist. Signed-off-by: Euan Bourke --- .mailmap | 1 + MAINTAINERS | 4 ++ doc/api/doxy-api-index.md | 3 +- doc/api/doxy-api.conf.in | 1 + lib/arg_parser/arg_parser.c | 113 ++++++++++++++++++++++++++++++++ lib/arg_parser/meson.build | 7 ++ lib/arg_parser/rte_arg_parser.h | 65 ++++++++++++++++++ lib/arg_parser/version.map | 10 +++ lib/meson.build | 2 + 9 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 lib/arg_parser/arg_parser.c create mode 100644 lib/arg_parser/meson.build create mode 100644 lib/arg_parser/rte_arg_parser.h create mode 100644 lib/arg_parser/version.map diff --git a/.mailmap b/.mailmap index ab0742a382..528bc68a30 100644 --- a/.mailmap +++ b/.mailmap @@ -379,6 +379,7 @@ Eric Zhang Erik Gabriel Carrillo Erik Ziegenbalg Erlu Chen +Euan Bourke Eugenio PĂ©rez Eugeny Parshutin Evan Swanson diff --git a/MAINTAINERS b/MAINTAINERS index 0d1c8126e3..68ef5ba14b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1756,6 +1756,10 @@ M: Nithin Dabilpuram M: Pavan Nikhilesh F: lib/node/ +Argument parsing +M: Bruce Richardson +F: lib/arg_parser/ + Test Applications ----------------- diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index a6a768bd7c..f711010140 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -221,7 +221,8 @@ The public API headers are grouped by topics: [config file](@ref rte_cfgfile.h), [key/value args](@ref rte_kvargs.h), [string](@ref rte_string_fns.h), - [thread](@ref rte_thread.h) + [thread](@ref rte_thread.h), + [argument parsing](@ref rte_arg_parser.h) - **debug**: [jobstats](@ref rte_jobstats.h), diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in index e94c9e4e46..05718ba6ed 100644 --- a/doc/api/doxy-api.conf.in +++ b/doc/api/doxy-api.conf.in @@ -28,6 +28,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/lib/eal/include \ @TOPDIR@/lib/eal/include/generic \ @TOPDIR@/lib/acl \ + @TOPDIR@/lib/arg_parser \ @TOPDIR@/lib/bbdev \ @TOPDIR@/lib/bitratestats \ @TOPDIR@/lib/bpf \ diff --git a/lib/arg_parser/arg_parser.c b/lib/arg_parser/arg_parser.c new file mode 100644 index 0000000000..4aa876b4ed --- /dev/null +++ b/lib/arg_parser/arg_parser.c @@ -0,0 +1,113 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Intel Corporation + */ + +#include "errno.h" +#include "stdlib.h" +#include "ctype.h" +#include "string.h" +#include "stdbool.h" + +#include +#include + + +struct core_bits { + uint8_t bits[(UINT16_MAX + 1)/CHAR_BIT]; + uint16_t max_bit_set; + uint16_t min_bit_set; + uint32_t total_bits_set; +}; + +static inline bool +get_core_bit(struct core_bits *mask, uint16_t idx) +{ + return !!(mask->bits[idx / 8] & (1 << (idx % 8))); +} + +static inline void +set_core_bit(struct core_bits *mask, uint16_t idx) +{ + if (get_core_bit(mask, idx)) + return; + + mask->bits[idx/8] |= 1 << (idx % 8); + /* Update min and max bit if its first time setting a bit */ + if (++(mask->total_bits_set) == 1) { + mask->min_bit_set = idx; + mask->max_bit_set = idx; + return; + } + + if (idx > mask->max_bit_set) + mask->max_bit_set = idx; + + if (idx < mask->min_bit_set) + mask->min_bit_set = idx; +} + +static inline uint32_t +corebits_to_array(struct core_bits *mask, uint16_t *cores, size_t max_cores) +{ + uint32_t count = 0; + for (uint32_t i = mask->min_bit_set; i <= mask->max_bit_set && count < max_cores; i++) { + if (get_core_bit(mask, i)) + cores[count++] = i; + } + return mask->total_bits_set; +} + + +int +rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len) +{ + int32_t min = -1; + char *end = NULL; + + struct core_bits *mask = malloc(sizeof(struct core_bits)); + if (mask == NULL) + return -1; + memset(mask, 0, sizeof(struct core_bits)); + + min = -1; + do { + uint32_t idx; + int32_t max; + + while (isblank(*corelist)) + corelist++; + if (!isdigit(*corelist)) + return -1; + + errno = 0; + idx = strtol(corelist, &end, 10); + if (errno || end == NULL || idx > UINT16_MAX) + return -1; + while (isblank(*end)) + end++; + if (*end == '-') + min = idx; + + else if (*end == ',' || *end == '\0') { + max = idx; + if (min == -1) + min = idx; + + /* Swap min and max if min is larger than max */ + if (min > max) + RTE_SWAP(min, max); + + for (; min <= max; min++) + set_core_bit(mask, min); + + min = -1; + } else + return -1; + corelist = end + 1; + } while (*end != '\0'); + + uint32_t total_count = corebits_to_array(mask, cores, cores_len); + free(mask); + + return total_count; +} diff --git a/lib/arg_parser/meson.build b/lib/arg_parser/meson.build new file mode 100644 index 0000000000..6ee228bd69 --- /dev/null +++ b/lib/arg_parser/meson.build @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2023 Intel Corporation + +sources = files('arg_parser.c') +headers = files('rte_arg_parser.h') + +includes += global_inc diff --git a/lib/arg_parser/rte_arg_parser.h b/lib/arg_parser/rte_arg_parser.h new file mode 100644 index 0000000000..cf9291d13a --- /dev/null +++ b/lib/arg_parser/rte_arg_parser.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Intel Corporation + */ + +#ifndef _RTE_ARG_PARSER_H_ +#define _RTE_ARG_PARSER_H_ + +/** + * @file + * + * RTE Argument Parsing API + * + * The argument parsing API is a collection of functions to help parse + * command line arguments. The API takes a string input and will return + * it to the user in a more usable format. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + + +/** + * Convert a string describing a list of core ids into an array of core ids. + * + * On success, the passed array is filled with the core ids present in the + * list up to the "cores_len", and the length of the array is returned. + * For example, passing a 1-3,6 "corelist" results in an array of [1, 2, 3, 6] + * and would return 4. + * + * Like the snprintf function for strings, if the length of the input array is + * insufficient to hold the number of cores in the "corelist", the input array is + * filled to capacity and the return value is the number of elements which would + * be returned if the array had been big enough. + * Function can also be called with a NULL array and 0 "cores_len" to find out + * the "cores_len" required. + * + * @param corelist + * Input string describing a list of core ids. + * @param cores + * An array where to store the core ids. + * Array can be NULL if "cores_len" is 0. + * @param cores_len + * The length of the "cores" array. + * If the size is smaller than that needed to hold all cores from "corelist", + * only "cores_len" elements will be written to the array. + * @return + * n: the number of unique cores present in "corelist". + * -1 if the string was invalid. + * NOTE: if n > "cores_len", then only "cores_len" elements in the "cores" array are valid. + */ +__rte_experimental +int +rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len); + + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_ARG_PARSER_H_ */ diff --git a/lib/arg_parser/version.map b/lib/arg_parser/version.map new file mode 100644 index 0000000000..588e14c7ad --- /dev/null +++ b/lib/arg_parser/version.map @@ -0,0 +1,10 @@ +DPDK_24 { + local: *; +}; + +EXPERIMENTAL { + global: + + # added in 24.03 + rte_parse_corelist; +}; diff --git a/lib/meson.build b/lib/meson.build index 6c143ce5a6..db9e769033 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -11,6 +11,7 @@ libraries = [ 'log', 'kvargs', # eal depends on kvargs + 'arg_parser', 'telemetry', # basic info querying 'eal', # everything depends on eal 'ring', @@ -72,6 +73,7 @@ if is_ms_compiler 'log', 'kvargs', 'telemetry', + 'arg_parser', ] endif From patchwork Tue Nov 28 14:07:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Euan Bourke X-Patchwork-Id: 134693 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 65D7743402; Wed, 29 Nov 2023 17:06:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 591F742E39; Wed, 29 Nov 2023 17:06:40 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 95F5142D89 for ; Tue, 28 Nov 2023 15:08:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701180494; x=1732716494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sy21M+sZNlcTNbmXQNMMufY64nY7Jrx1AB4WXYlIidg=; b=aElU752+OxKHZMggqNEzECW6XDE4mx5DjQuhZVczm2fE5RA1mbxwSuRG 4C7iP3Rte6KSse5xWBcmUn11fA6fyrqseKr+1GlmZ22Z+tEynE4KpdfrJ KWBXK4l4OGurN6tk11jktEt6zQyfY98OjxSW4euZMfcytaHhKnY1HzwSU 1CEvAjqi10cIu6VAUDz22zmKSl+RD2zrocpNUNBjmQKxa5PRm92mOYCsk TSiMk39y3X9KbWl099QxOrL4IhtEMbAdQxWhbjbemp0V0cfHKsDS25FDi VI7bCETW+Z+9Xrbhzbh8Arz35Nrpn306jDv0d7DueNoJnh21u2P1PfpiB A==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="395747384" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="395747384" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 06:07:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="912450877" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="912450877" Received: from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151]) by fmsmga001.fm.intel.com with ESMTP; 28 Nov 2023 06:07:53 -0800 From: Euan Bourke To: dev@dpdk.org Cc: Euan Bourke , Bruce Richardson Subject: [PATCH 24.03 v2 2/5] arg_parser: add new coremask parsing API Date: Tue, 28 Nov 2023 14:07:42 +0000 Message-Id: <20231128140745.595481-3-euan.bourke@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128140745.595481-1-euan.bourke@intel.com> References: <20231122164550.3873633-1-euan.bourke@intel.com> <20231128140745.595481-1-euan.bourke@intel.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 29 Nov 2023 17:06:37 +0100 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 Add new coremask parsing API. This API behaves similarly to the corelist parsing API, parsing the coremask string, filling its values into the cores array. The API also returns a 'count' which corresponds to the total number of cores in the coremask string. Signed-off-by: Euan Bourke --- lib/arg_parser/arg_parser.c | 57 +++++++++++++++++++++++++++++++++ lib/arg_parser/rte_arg_parser.h | 33 +++++++++++++++++++ lib/arg_parser/version.map | 1 + 3 files changed, 91 insertions(+) diff --git a/lib/arg_parser/arg_parser.c b/lib/arg_parser/arg_parser.c index 4aa876b4ed..6405eebd03 100644 --- a/lib/arg_parser/arg_parser.c +++ b/lib/arg_parser/arg_parser.c @@ -11,6 +11,9 @@ #include #include +#define BITS_PER_HEX 4 +#define MAX_COREMASK_SIZE ((UINT16_MAX + 1) / BITS_PER_HEX) + struct core_bits { uint8_t bits[(UINT16_MAX + 1)/CHAR_BIT]; @@ -57,6 +60,15 @@ corebits_to_array(struct core_bits *mask, uint16_t *cores, size_t max_cores) return mask->total_bits_set; } +static int xdigit2val(unsigned char c) +{ + if (isdigit(c)) + return c - '0'; + else if (isupper(c)) + return c - 'A' + 10; + else + return c - 'a' + 10; +} int rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len) @@ -111,3 +123,48 @@ rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len) return total_count; } + +int +rte_parse_coremask(const char *coremask, uint16_t *cores, uint32_t cores_len) +{ + struct core_bits *mask = malloc(sizeof(struct core_bits)); + if (mask == NULL) + return -1; + memset(mask, 0, sizeof(struct core_bits)); + + /* 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; + + int32_t i = strlen(coremask); + while ((i > 0) && isblank(coremask[i - 1])) + i--; + if (i == 0 || i > MAX_COREMASK_SIZE) + return -1; + + uint32_t idx = 0; + + for (i = i - 1; i >= 0; i--) { + int val; + char c = coremask[i]; + + if (isxdigit(c) == 0) + return -1; + + val = xdigit2val(c); + + for (uint8_t j = 0; j < BITS_PER_HEX; j++, idx++) { + if ((1 << j) & val) + set_core_bit(mask, idx); + } + } + + uint32_t total_count = corebits_to_array(mask, cores, cores_len); + free(mask); + + return total_count; +} diff --git a/lib/arg_parser/rte_arg_parser.h b/lib/arg_parser/rte_arg_parser.h index cf9291d13a..956239d085 100644 --- a/lib/arg_parser/rte_arg_parser.h +++ b/lib/arg_parser/rte_arg_parser.h @@ -57,6 +57,39 @@ __rte_experimental int rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len); +/** + * Convert a string describing a bitmask of core ids into an array of core ids. + * + * On success, the passed array is filled with the core ids present in the + * bitmask up to the "cores_len", and the number of elements added into the array is returned. + * For example, passing a 0xA "coremask" results in an array of [1, 3] + * and would return 2. + * + * Like the snprintf function for strings, if the length of the input array is + * insufficient to hold the number of cores in the "coresmask", the input array is + * filled to capacity and the return value is the number of elements which would + * be returned if the array had been big enough. + * Function can also be called with a NULL array and 0 "cores_len" to find out + * the "cores_len" required. + * + * @param coremask + * A string containing a bitmask of core ids. + * @param cores + * An array where to store the core ids. + * Array can be NULL if "cores_len" is 0. + * @param cores_len + * The length of the "cores" array. + * If the size is smaller than that needed to hold all cores from "coremask", + * only "cores_len" elements will be written to the array. + * @return + * n: the number of unique cores present in "coremask". + * -1 if the string was invalid. + * NOTE: if n > "cores_len", then only "cores_len" elements in the "cores" array are valid. + */ +__rte_experimental +int +rte_parse_coremask(const char *coremask, uint16_t *cores, uint32_t cores_len); + #ifdef __cplusplus } diff --git a/lib/arg_parser/version.map b/lib/arg_parser/version.map index 588e14c7ad..ac070db785 100644 --- a/lib/arg_parser/version.map +++ b/lib/arg_parser/version.map @@ -7,4 +7,5 @@ EXPERIMENTAL { # added in 24.03 rte_parse_corelist; + rte_parse_coremask; }; From patchwork Tue Nov 28 14:07:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Euan Bourke X-Patchwork-Id: 134694 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2FEE443402; Wed, 29 Nov 2023 17:07:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 772C342E40; Wed, 29 Nov 2023 17:06:41 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 4D49C42D89 for ; Tue, 28 Nov 2023 15:08:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701180500; x=1732716500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VDhf5FB/kqu5Y1PkkCq5w5mK693GLL3rHOwzrWlAFBE=; b=NT6ShdFj0VMeOkh9AQI54MV76dGnADZyu9K+cJaI9515SVlv2ccktMeE cSjCs3wx3t7n+lMv3XkfO1CJheJ7zXnSFqLCw6PhT4S0UiuDrANfnrowE zuxxzhxE9p5F47RB/PQiP5v4atOEmrkNVFBVD6UM6VIpsoESyq3ZXsIxu qeLNIFXNVuaKklsYJYGymTu6xC6759RmuBw+6FG8Wdkgg28bTT93AqNKW wJE54awI8huIyFRUdob8r4HdwTFBmge0zeYOGbjHx2A8yS5jZ3HrzOV1f UvOCbKflIWv+2zrHLEAnx5YVdfnUHFW1DAd2Uw9sEvUENxfiP0Ur0DAND Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="395747466" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="395747466" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 06:08:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="912450889" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="912450889" Received: from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151]) by fmsmga001.fm.intel.com with ESMTP; 28 Nov 2023 06:08:03 -0800 From: Euan Bourke To: dev@dpdk.org Cc: Euan Bourke Subject: [PATCH 24.03 v2 3/5] eal: add support for new arg parsing library Date: Tue, 28 Nov 2023 14:07:43 +0000 Message-Id: <20231128140745.595481-4-euan.bourke@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128140745.595481-1-euan.bourke@intel.com> References: <20231122164550.3873633-1-euan.bourke@intel.com> <20231128140745.595481-1-euan.bourke@intel.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 29 Nov 2023 17:06:37 +0100 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 EAL functions relating to corelist and coremask parsing to support the new arg parsing library. Functions now call the API instead of implementing their own version. Signed-off-by: Euan Bourke --- lib/eal/common/eal_common_options.c | 114 ++++------------------------ lib/eal/meson.build | 2 +- 2 files changed, 14 insertions(+), 102 deletions(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index a6d21f1cba..7c89a1e18b 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #ifndef RTE_EXEC_ENV_WINDOWS #include @@ -706,7 +707,7 @@ update_lcore_config(int *cores) } static int -check_core_list(int *lcores, unsigned int count) +check_core_list(uint16_t *lcores, unsigned int count) { char lcorestr[RTE_MAX_LCORE * 10]; bool overflow = false; @@ -746,60 +747,18 @@ check_core_list(int *lcores, unsigned int count) int rte_eal_parse_coremask(const char *coremask, int *cores) { - const char *coremask_orig = coremask; - int lcores[RTE_MAX_LCORE]; - unsigned int count = 0; - int i, j, idx; - int val; - char c; + int count; + uint16_t lcores[RTE_MAX_LCORE]; + int idx; for (idx = 0; idx < RTE_MAX_LCORE; idx++) cores[idx] = -1; - idx = 0; - /* 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) { - RTE_LOG(ERR, EAL, "No lcores in coremask: [%s]\n", - coremask_orig); - return -1; - } + /* Call public coremask parsing API */ + count = rte_parse_coremask(coremask, lcores, RTE_MAX_LCORE); - for (i = i - 1; i >= 0; i--) { - c = coremask[i]; - if (isxdigit(c) == 0) { - /* invalid characters */ - RTE_LOG(ERR, EAL, "invalid characters in coremask: [%s]\n", - coremask_orig); - return -1; - } - val = xdigit2val(c); - for (j = 0; j < BITS_PER_HEX; j++, idx++) - { - if ((1 << j) & val) { - if (count >= RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "Too many lcores provided. Cannot exceed RTE_MAX_LCORE (%d)\n", - RTE_MAX_LCORE); - return -1; - } - lcores[count++] = idx; - } - } - } - if (count == 0) { - RTE_LOG(ERR, EAL, "No lcores in coremask: [%s]\n", - coremask_orig); + if (count <= 0 || count > RTE_MAX_LCORE) return -1; - } if (check_core_list(lcores, count)) return -1; @@ -898,64 +857,17 @@ eal_parse_service_corelist(const char *corelist) static int eal_parse_corelist(const char *corelist, int *cores) { - unsigned int count = 0, i; - int lcores[RTE_MAX_LCORE]; - char *end = NULL; - int min, max; + int count; + uint16_t lcores[RTE_MAX_LCORE]; int idx; for (idx = 0; idx < RTE_MAX_LCORE; idx++) cores[idx] = -1; - /* Remove all blank characters ahead */ - while (isblank(*corelist)) - corelist++; + /* Call public corelist parsing API */ + count = rte_parse_corelist(corelist, lcores, RTE_MAX_LCORE); - /* Get list of cores */ - min = -1; - do { - while (isblank(*corelist)) - corelist++; - if (*corelist == '\0') - return -1; - errno = 0; - idx = strtol(corelist, &end, 10); - if (errno || end == NULL) - return -1; - if (idx < 0) - return -1; - while (isblank(*end)) - end++; - if (*end == '-') { - min = idx; - } else if ((*end == ',') || (*end == '\0')) { - max = idx; - if (min == -1) - min = idx; - for (idx = min; idx <= max; idx++) { - bool dup = false; - - /* Check if this idx is already present */ - for (i = 0; i < count; i++) { - if (lcores[i] == idx) - dup = true; - } - if (dup) - continue; - if (count >= RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "Too many lcores provided. Cannot exceed RTE_MAX_LCORE (%d)\n", - RTE_MAX_LCORE); - return -1; - } - lcores[count++] = idx; - } - min = -1; - } else - return -1; - corelist = end + 1; - } while (*end != '\0'); - - if (count == 0) + if (count <= 0 || count > RTE_MAX_LCORE) return -1; if (check_core_list(lcores, count)) diff --git a/lib/eal/meson.build b/lib/eal/meson.build index e1d6c4cf17..52a22e2e66 100644 --- a/lib/eal/meson.build +++ b/lib/eal/meson.build @@ -14,7 +14,7 @@ subdir(exec_env) subdir(arch_subdir) -deps += ['log', 'kvargs'] +deps += ['log', 'kvargs', 'arg_parser'] if not is_windows deps += ['telemetry'] endif From patchwork Tue Nov 28 14:07:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Euan Bourke X-Patchwork-Id: 134695 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 884DD43402; Wed, 29 Nov 2023 17:07:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 893A842E4B; Wed, 29 Nov 2023 17:06:42 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 13D0D42D89 for ; Tue, 28 Nov 2023 15:08:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701180501; x=1732716501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tRpOZFtjLKYGr1rIFCT8IXRe2jnLTQQzM3S0E1dnOZY=; b=Cwn8dtvJlA4+hj3h0IQLUxxdcARdoQfhbUAdPLCO9/Dqflp0ObSCKPu5 RSI0LYRQlyiDbbiBpqSAPf9TH4WTt0Cq3ikPE1ucf/cMK6b4NKr0izj+S jJEdDSxKXa3hyFPn9fIosA1IIq0oZLM1jkwR7gojbzek9Xlq/2vggF3Gd vcjqB4afuBJR6MjwAwU+Eah6aixsdaQmC8p6cYkHyo7sg7cK64ncYYQBD twyeNLvZbSforwuC6UFlg00xFLgXRQogcICGkLwayz8KSgdAT408NrFgO 4IYaALzm6aP96m1qTyu1XCmrZhvP2ZuIRjPYFvs23C74M5yy1Uhf2/Uy8 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="395747492" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="395747492" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 06:08:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="912450894" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="912450894" Received: from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151]) by fmsmga001.fm.intel.com with ESMTP; 28 Nov 2023 06:08:06 -0800 From: Euan Bourke To: dev@dpdk.org Cc: Euan Bourke Subject: [PATCH 24.03 v2 4/5] eal: update to service core related parsers Date: Tue, 28 Nov 2023 14:07:44 +0000 Message-Id: <20231128140745.595481-5-euan.bourke@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128140745.595481-1-euan.bourke@intel.com> References: <20231122164550.3873633-1-euan.bourke@intel.com> <20231128140745.595481-1-euan.bourke@intel.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 29 Nov 2023 17:06:37 +0100 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 Updates to the parse service cores functions in EAL to call the arg parser API instead of implementing its own versions. Signed-off-by: Euan Bourke --- lib/eal/common/eal_common_options.c | 177 ++++++++-------------------- 1 file changed, 47 insertions(+), 130 deletions(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 7c89a1e18b..bf70d22975 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -573,97 +573,52 @@ eal_plugins_init(void) * 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 int eal_parse_service_coremask(const char *coremask) { struct rte_config *cfg = rte_eal_get_configuration(); - int i, j, idx = 0; - unsigned int count = 0; - char c; - int val; + uint16_t cores[RTE_MAX_LCORE]; + int64_t count; uint32_t taken_lcore_count = 0; - 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; - - for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) { - c = coremask[i]; - if (isxdigit(c) == 0) { - /* invalid characters */ - return -1; - } - val = xdigit2val(c); - for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; - j++, idx++) { - if ((1 << j) & val) { - /* handle main lcore already parsed */ - uint32_t lcore = idx; - if (main_lcore_parsed && - cfg->main_lcore == lcore) { - RTE_LOG(ERR, EAL, - "lcore %u is main lcore, cannot use as service core\n", - idx); - return -1; - } + for (uint16_t idx = 0; idx < RTE_DIM(cores); idx++) + cores[idx] = -1; - if (eal_cpu_detected(idx) == 0) { - RTE_LOG(ERR, EAL, - "lcore %u unavailable\n", idx); - return -1; - } + count = rte_parse_coremask(coremask, cores, RTE_DIM(cores)); - if (cfg->lcore_role[idx] == ROLE_RTE) - taken_lcore_count++; + if (count == 0 || count == -1) + return -1; - lcore_config[idx].core_role = ROLE_SERVICE; - count++; - } + for (int i = 0; i < count; i++) { + uint32_t lcore = cores[i]; + if (main_lcore_parsed && + cfg->main_lcore == lcore) { + RTE_LOG(ERR, EAL, + "lcore %u is main lcore, cannot use as service core\n", + cores[i]); + return -1; } - } - for (; i >= 0; i--) - if (coremask[i] != '0') + if (eal_cpu_detected(cores[i]) == 0) { + RTE_LOG(ERR, EAL, + "lcore %u unavailable\n", cores[i]); return -1; + } - for (; idx < RTE_MAX_LCORE; idx++) - lcore_config[idx].core_index = -1; - - if (count == 0) - return -1; + if (cfg->lcore_role[cores[i]] == ROLE_RTE) + taken_lcore_count++; + lcore_config[cores[i]].core_role = ROLE_SERVICE; + } if (core_parsed && taken_lcore_count != count) { RTE_LOG(WARNING, EAL, - "Not all service cores are in the coremask. " + "Not all service cores were in the coremask. " "Please ensure -c or -l includes service cores\n"); } + for (uint16_t j = count*4; j < RTE_MAX_LCORE; j++) + lcore_config[j].core_index = -1; + cfg->service_lcore_count = count; return 0; } @@ -780,70 +735,32 @@ static int eal_parse_service_corelist(const char *corelist) { struct rte_config *cfg = rte_eal_get_configuration(); - int i; - unsigned count = 0; - char *end = NULL; - uint32_t min, max, idx; + int64_t i, count; + uint16_t cores[RTE_MAX_LCORE]; uint32_t taken_lcore_count = 0; - if (corelist == NULL) - return -1; + for (uint16_t idx = 0; idx < RTE_DIM(cores); idx++) + cores[idx] = -1; - /* Remove all blank characters ahead and after */ - while (isblank(*corelist)) - corelist++; - i = strlen(corelist); - while ((i > 0) && isblank(corelist[i - 1])) - i--; + count = rte_parse_corelist(corelist, cores, RTE_DIM(cores)); - /* 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; - if (idx >= RTE_MAX_LCORE) - 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++) { - if (cfg->lcore_role[idx] != ROLE_SERVICE) { - /* handle main lcore already parsed */ - uint32_t lcore = idx; - if (cfg->main_lcore == lcore && - main_lcore_parsed) { - RTE_LOG(ERR, EAL, - "Error: lcore %u is main lcore, cannot use as service core\n", - idx); - return -1; - } - if (cfg->lcore_role[idx] == ROLE_RTE) - taken_lcore_count++; - - lcore_config[idx].core_role = - ROLE_SERVICE; - count++; - } - } - min = RTE_MAX_LCORE; - } else + if (count == 0 || count == -1) + return -1; + + for (i = 0; i < count; i++) { + uint32_t lcore = cores[i]; + if (cfg->main_lcore == lcore && + main_lcore_parsed) { + RTE_LOG(ERR, EAL, + "Error: lcore %u is main lcore, cannot use as service core\n", + cores[i]); return -1; - corelist = end + 1; - } while (*end != '\0'); + } + if (cfg->lcore_role[cores[i]] == ROLE_RTE) + taken_lcore_count++; - if (count == 0) - return -1; + lcore_config[cores[i]].core_role = ROLE_SERVICE; + } if (core_parsed && taken_lcore_count != count) { RTE_LOG(WARNING, EAL, From patchwork Tue Nov 28 14:07:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Euan Bourke X-Patchwork-Id: 134696 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 29DC743402; Wed, 29 Nov 2023 17:07:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C92F542E53; Wed, 29 Nov 2023 17:06:43 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id DA84E42D89 for ; Tue, 28 Nov 2023 15:08:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701180510; x=1732716510; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qjhJtH9CwxTSMbthNQXVfVsM/Tp0Btb35w3IlMhUzhU=; b=VLZOGAYR5bZwAOQZt8EbL1E2tv8YUNEJrRWArIheSCiX4mQS5dVcLTfA DBErgVijJq5XG4i3VaB98Hgy5+GXj+P8jrf+fdHZVyJ5xXQkTlVjpxAIh oYrO+TFWQKyBh3vB238ECS8DYcuH8K+Mt/VgOJOqwmrf81dqUOVvMV+5v H1C5QUXoe4F2ku7BCnUzi/v49H3FSXcVmeHmd4Ib/FDhv4c85+tg6CuYt q0eDIRNg2GZSzQx3Srlum4Fjbqp0tkAj5OPvAAuXYUZGW+G17BUzE8HVo RjFQlxwKC4jW4n4ulhGIqRU4ZvmkqxtggByhzafotv7QCsPghrKSYDTk2 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="395747526" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="395747526" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 06:08:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="912450904" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="912450904" Received: from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151]) by fmsmga001.fm.intel.com with ESMTP; 28 Nov 2023 06:08:10 -0800 From: Euan Bourke To: dev@dpdk.org Cc: Euan Bourke , Abdullah Sevincer Subject: [PATCH 24.03 v2 5/5] event/dlb2: add new arg parsing library API support Date: Tue, 28 Nov 2023 14:07:45 +0000 Message-Id: <20231128140745.595481-6-euan.bourke@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128140745.595481-1-euan.bourke@intel.com> References: <20231122164550.3873633-1-euan.bourke@intel.com> <20231128140745.595481-1-euan.bourke@intel.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 29 Nov 2023 17:06:37 +0100 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 Switched the dlb2 driver to call the new arg parsing library instead of eal for coremask parsing, and updated the resource probe function to support the changed formatting of the API. Signed-off-by: Euan Bourke --- drivers/event/dlb2/dlb2_priv.h | 4 +- drivers/event/dlb2/pf/base/dlb2_resource.c | 51 +++++++++------------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/drivers/event/dlb2/dlb2_priv.h b/drivers/event/dlb2/dlb2_priv.h index 31a3beeb6c..c14d83da5b 100644 --- a/drivers/event/dlb2/dlb2_priv.h +++ b/drivers/event/dlb2/dlb2_priv.h @@ -10,6 +10,7 @@ #include #include +#include #include "dlb2_user.h" #include "dlb2_log.h" #include "rte_pmd_dlb2.h" @@ -729,9 +730,6 @@ void dlb2_event_build_hcws(struct dlb2_port *qm_port, uint8_t *sched_type, uint8_t *queue_id); -/* Extern functions */ -extern int rte_eal_parse_coremask(const char *coremask, int *cores); - /* Extern globals */ extern struct process_local_port_data dlb2_port[][DLB2_NUM_PORT_TYPES]; diff --git a/drivers/event/dlb2/pf/base/dlb2_resource.c b/drivers/event/dlb2/pf/base/dlb2_resource.c index 7ce3e3531c..fda094c3f7 100644 --- a/drivers/event/dlb2/pf/base/dlb2_resource.c +++ b/drivers/event/dlb2/pf/base/dlb2_resource.c @@ -922,49 +922,38 @@ dlb2_resource_probe(struct dlb2_hw *hw, const void *probe_args) { const struct dlb2_devargs *args = (const struct dlb2_devargs *)probe_args; const char *mask = args ? args->producer_coremask : NULL; - int cpu = 0, cnt = 0, cores[RTE_MAX_LCORE], i; + int cpu = 0, i; + uint16_t cores[RTE_MAX_LCORE]; if (args) { mask = (const char *)args->producer_coremask; } - if (mask && rte_eal_parse_coremask(mask, cores)) { + int ret = rte_parse_coremask(mask, cores, RTE_DIM(cores)); + + if (mask && ret == -1) { DLB2_LOG_ERR(": Invalid producer coremask=%s", mask); return -1; } - hw->num_prod_cores = 0; - for (i = 0; i < RTE_MAX_LCORE; i++) { - bool is_pcore = (mask && cores[i] != -1); - - if (rte_lcore_is_enabled(i)) { - if (is_pcore) { - /* - * Populate the producer cores from parsed - * coremask - */ - hw->prod_core_list[cores[i]] = i; - hw->num_prod_cores++; - - } else if ((++cnt == DLB2_EAL_PROBE_CORE || - rte_lcore_count() < DLB2_EAL_PROBE_CORE)) { - /* - * If no producer coremask is provided, use the - * second EAL core to probe - */ - cpu = i; - break; - } - } else if (is_pcore) { + hw->num_prod_cores = ret; + /* Check for no producer cores and then get the second EAL core */ + if (hw->num_prod_cores > 0) + cpu = cores[0]; + else if (rte_lcore_count() < DLB2_EAL_PROBE_CORE) + cpu = rte_get_main_lcore(); + else + cpu = rte_get_next_lcore(-1, 1, 0); + + /* check our producer list is valid and error out if not */ + for (i = 0; i < hw->num_prod_cores; i++) { + if (!rte_lcore_is_enabled(cores[i])) { DLB2_LOG_ERR("Producer coremask(%s) must be a subset of EAL coremask", - mask); + mask); return -1; - } - } - /* Use the first core in producer coremask to probe */ - if (hw->num_prod_cores) - cpu = hw->prod_core_list[0]; + hw->prod_core_list[i] = cores[i]; +} dlb2_get_pp_allocation(hw, cpu, DLB2_LDB_PORT); dlb2_get_pp_allocation(hw, cpu, DLB2_DIR_PORT);