Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/134693/?format=api
http://patchwork.dpdk.org/api/patches/134693/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20231128140745.595481-3-euan.bourke@intel.com/", "project": { "id": 1, "url": "http://patchwork.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20231128140745.595481-3-euan.bourke@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20231128140745.595481-3-euan.bourke@intel.com", "date": "2023-11-28T14:07:42", "name": "[24.03,v2,2/5] arg_parser: add new coremask parsing API", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "3669000acefc4ea9f7c9f7ce34f1ebca29ff4373", "submitter": { "id": 3231, "url": "http://patchwork.dpdk.org/api/people/3231/?format=api", "name": "Euan Bourke", "email": "euan.bourke@intel.com" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20231128140745.595481-3-euan.bourke@intel.com/mbox/", "series": [ { "id": 30412, "url": "http://patchwork.dpdk.org/api/series/30412/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=30412", "date": "2023-11-28T14:07:40", "name": "add new command line argument parsing library", "version": 2, "mbox": "http://patchwork.dpdk.org/series/30412/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/134693/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/134693/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 65D7743402;\n\tWed, 29 Nov 2023 17:06:52 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 591F742E39;\n\tWed, 29 Nov 2023 17:06:40 +0100 (CET)", "from mgamail.intel.com (mgamail.intel.com [134.134.136.24])\n by mails.dpdk.org (Postfix) with ESMTP id 95F5142D89\n for <dev@dpdk.org>; Tue, 28 Nov 2023 15:08:14 +0100 (CET)", "from fmsmga001.fm.intel.com ([10.253.24.23])\n by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 28 Nov 2023 06:07:55 -0800", "from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151])\n by fmsmga001.fm.intel.com with ESMTP; 28 Nov 2023 06:07:53 -0800" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1701180494; x=1732716494;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=sy21M+sZNlcTNbmXQNMMufY64nY7Jrx1AB4WXYlIidg=;\n b=aElU752+OxKHZMggqNEzECW6XDE4mx5DjQuhZVczm2fE5RA1mbxwSuRG\n 4C7iP3Rte6KSse5xWBcmUn11fA6fyrqseKr+1GlmZ22Z+tEynE4KpdfrJ\n KWBXK4l4OGurN6tk11jktEt6zQyfY98OjxSW4euZMfcytaHhKnY1HzwSU\n 1CEvAjqi10cIu6VAUDz22zmKSl+RD2zrocpNUNBjmQKxa5PRm92mOYCsk\n TSiMk39y3X9KbWl099QxOrL4IhtEMbAdQxWhbjbemp0V0cfHKsDS25FDi\n VI7bCETW+Z+9Xrbhzbh8Arz35Nrpn306jDv0d7DueNoJnh21u2P1PfpiB A==;", "X-IronPort-AV": [ "E=McAfee;i=\"6600,9927,10907\"; a=\"395747384\"", "E=Sophos;i=\"6.04,234,1695711600\"; d=\"scan'208\";a=\"395747384\"", "E=McAfee;i=\"6600,9927,10907\"; a=\"912450877\"", "E=Sophos;i=\"6.04,234,1695711600\"; d=\"scan'208\";a=\"912450877\"" ], "X-ExtLoop1": "1", "From": "Euan Bourke <euan.bourke@intel.com>", "To": "dev@dpdk.org", "Cc": "Euan Bourke <euan.bourke@intel.com>,\n Bruce Richardson <bruce.richardson@intel.com>", "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>\n <20231128140745.595481-1-euan.bourke@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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 <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "Add new coremask parsing API. This API behaves similarly to the corelist\nparsing API, parsing the coremask string, filling its values into the\ncores array.\n\nThe API also returns a 'count' which corresponds to the total number of\ncores in the coremask string.\n\nSigned-off-by: Euan Bourke <euan.bourke@intel.com>\n---\n lib/arg_parser/arg_parser.c | 57 +++++++++++++++++++++++++++++++++\n lib/arg_parser/rte_arg_parser.h | 33 +++++++++++++++++++\n lib/arg_parser/version.map | 1 +\n 3 files changed, 91 insertions(+)", "diff": "diff --git a/lib/arg_parser/arg_parser.c b/lib/arg_parser/arg_parser.c\nindex 4aa876b4ed..6405eebd03 100644\n--- a/lib/arg_parser/arg_parser.c\n+++ b/lib/arg_parser/arg_parser.c\n@@ -11,6 +11,9 @@\n #include <rte_arg_parser.h>\n #include <rte_common.h>\n \n+#define BITS_PER_HEX 4\n+#define MAX_COREMASK_SIZE ((UINT16_MAX + 1) / BITS_PER_HEX)\n+\n \n struct core_bits {\n \tuint8_t bits[(UINT16_MAX + 1)/CHAR_BIT];\n@@ -57,6 +60,15 @@ corebits_to_array(struct core_bits *mask, uint16_t *cores, size_t max_cores)\n \treturn mask->total_bits_set;\n }\n \n+static int xdigit2val(unsigned char c)\n+{\n+\tif (isdigit(c))\n+\t\treturn c - '0';\n+\telse if (isupper(c))\n+\t\treturn c - 'A' + 10;\n+\telse\n+\t\treturn c - 'a' + 10;\n+}\n \n int\n rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len)\n@@ -111,3 +123,48 @@ rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len)\n \n \treturn total_count;\n }\n+\n+int\n+rte_parse_coremask(const char *coremask, uint16_t *cores, uint32_t cores_len)\n+{\n+\tstruct core_bits *mask = malloc(sizeof(struct core_bits));\n+\tif (mask == NULL)\n+\t\treturn -1;\n+\tmemset(mask, 0, sizeof(struct core_bits));\n+\n+\t/* Remove all blank characters ahead and after .\n+\t * Remove 0x/0X if exists.\n+\t */\n+\twhile (isblank(*coremask))\n+\t\tcoremask++;\n+\tif (coremask[0] == '0' && ((coremask[1] == 'x') || (coremask[1] == 'X')))\n+\t\tcoremask += 2;\n+\n+\tint32_t i = strlen(coremask);\n+\twhile ((i > 0) && isblank(coremask[i - 1]))\n+\t\ti--;\n+\tif (i == 0 || i > MAX_COREMASK_SIZE)\n+\t\treturn -1;\n+\n+\tuint32_t idx = 0;\n+\n+\tfor (i = i - 1; i >= 0; i--) {\n+\t\tint val;\n+\t\tchar c = coremask[i];\n+\n+\t\tif (isxdigit(c) == 0)\n+\t\t\treturn -1;\n+\n+\t\tval = xdigit2val(c);\n+\n+\t\tfor (uint8_t j = 0; j < BITS_PER_HEX; j++, idx++) {\n+\t\t\tif ((1 << j) & val)\n+\t\t\t\tset_core_bit(mask, idx);\n+\t\t}\n+\t}\n+\n+\tuint32_t total_count = corebits_to_array(mask, cores, cores_len);\n+\tfree(mask);\n+\n+\treturn total_count;\n+}\ndiff --git a/lib/arg_parser/rte_arg_parser.h b/lib/arg_parser/rte_arg_parser.h\nindex cf9291d13a..956239d085 100644\n--- a/lib/arg_parser/rte_arg_parser.h\n+++ b/lib/arg_parser/rte_arg_parser.h\n@@ -57,6 +57,39 @@ __rte_experimental\n int\n rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len);\n \n+/**\n+ * Convert a string describing a bitmask of core ids into an array of core ids.\n+ *\n+ * On success, the passed array is filled with the core ids present in the\n+ * bitmask up to the \"cores_len\", and the number of elements added into the array is returned.\n+ * For example, passing a 0xA \"coremask\" results in an array of [1, 3]\n+ * and would return 2.\n+ *\n+ * Like the snprintf function for strings, if the length of the input array is\n+ * insufficient to hold the number of cores in the \"coresmask\", the input array is\n+ * filled to capacity and the return value is the number of elements which would\n+ * be returned if the array had been big enough.\n+ * Function can also be called with a NULL array and 0 \"cores_len\" to find out\n+ * the \"cores_len\" required.\n+ *\n+ * @param coremask\n+ * A string containing a bitmask of core ids.\n+ * @param cores\n+ * An array where to store the core ids.\n+ * Array can be NULL if \"cores_len\" is 0.\n+ * @param cores_len\n+ * The length of the \"cores\" array.\n+ * If the size is smaller than that needed to hold all cores from \"coremask\",\n+ * only \"cores_len\" elements will be written to the array.\n+ * @return\n+ * n: the number of unique cores present in \"coremask\".\n+ * -1 if the string was invalid.\n+ * NOTE: if n > \"cores_len\", then only \"cores_len\" elements in the \"cores\" array are valid.\n+ */\n+__rte_experimental\n+int\n+rte_parse_coremask(const char *coremask, uint16_t *cores, uint32_t cores_len);\n+\n \n #ifdef __cplusplus\n }\ndiff --git a/lib/arg_parser/version.map b/lib/arg_parser/version.map\nindex 588e14c7ad..ac070db785 100644\n--- a/lib/arg_parser/version.map\n+++ b/lib/arg_parser/version.map\n@@ -7,4 +7,5 @@ EXPERIMENTAL {\n \n \t# added in 24.03\n \trte_parse_corelist;\n+\trte_parse_coremask;\n };\n", "prefixes": [ "24.03", "v2", "2/5" ] }{ "id": 134693, "url": "