get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/134537/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 134537,
    "url": "http://patchwork.dpdk.org/api/patches/134537/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20231122164550.3873633-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": "<20231122164550.3873633-3-euan.bourke@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231122164550.3873633-3-euan.bourke@intel.com",
    "date": "2023-11-22T16:45:48",
    "name": "[24.03,2/4] arg_parser: add new coremask parsing API",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f05c20a41d06d023ef0baff3fb4c913435a07f88",
    "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/20231122164550.3873633-3-euan.bourke@intel.com/mbox/",
    "series": [
        {
            "id": 30362,
            "url": "http://patchwork.dpdk.org/api/series/30362/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=30362",
            "date": "2023-11-22T16:45:46",
            "name": "add new command line argument parsing library",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/30362/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/134537/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/134537/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 928A943382;\n\tWed, 22 Nov 2023 17:48:11 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 98D84427E2;\n\tWed, 22 Nov 2023 17:47:58 +0100 (CET)",
            "from mgamail.intel.com (mgamail.intel.com [134.134.136.31])\n by mails.dpdk.org (Postfix) with ESMTP id 05A1C41143\n for <dev@dpdk.org>; Wed, 22 Nov 2023 17:46:01 +0100 (CET)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 22 Nov 2023 08:46:00 -0800",
            "from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151])\n by fmsmga002.fm.intel.com with ESMTP; 22 Nov 2023 08:46:00 -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=1700671561; x=1732207561;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=7VchvCaL/vuCasWWSrsz/bp5C11rhK6oToYynqbdJqU=;\n b=VRFT5SaJ5N6+sBbGEkfhOmgpDLfeUnHvkvQxQZlpcF4NRc5fzGVoPcEs\n 2/pwv0seTA0oay3rrU2kkgbNFlA4o2UanVAvA4Bu5oHSC7GN1TbVAS9Gr\n Oq0lQ85KdGjulqi3oNcMIYXCX8E/5FwhhEJn1TgZjk5todsknHDPQESLW\n WZkp7109mLNHcd+ImriUxXsflkkSOj1OO2bC86qSQyF25XADloI6TLZOQ\n kgN5lyQToRTAfIrN2r7f51wZDwYtyEzBkl6an915lHLXqT8QY8lieWZvO\n UMUQLNfzJ2T/uT5EwK60csfdc4UaI9tjdeCZwWvX2dNK0AqHGwyp7N24j g==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6600,9927,10902\"; a=\"456416009\"",
            "E=Sophos;i=\"6.04,219,1695711600\"; d=\"scan'208\";a=\"456416009\"",
            "E=McAfee;i=\"6600,9927,10902\"; a=\"884685111\"",
            "E=Sophos;i=\"6.04,219,1695711600\"; d=\"scan'208\";a=\"884685111\""
        ],
        "X-ExtLoop1": "1",
        "From": "Euan Bourke <euan.bourke@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Euan Bourke <euan.bourke@intel.com>",
        "Subject": "[PATCH 24.03 2/4] arg_parser: add new coremask parsing API",
        "Date": "Wed, 22 Nov 2023 16:45:48 +0000",
        "Message-Id": "<20231122164550.3873633-3-euan.bourke@intel.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20231122164550.3873633-1-euan.bourke@intel.com>",
        "References": "<20231122164550.3873633-1-euan.bourke@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Mailman-Approved-At": "Wed, 22 Nov 2023 17:47:54 +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 parsing\nAPI, parsing the coremask string, filling its values into the cores array.\n\nThe API also returns a 'count' which corresponds to the total number of cores\nin the coremask string.\n\nSigned-off-by: Euan Bourke <euan.bourke@intel.com>\n---\n lib/arg_parser/arg_parser.c     | 58 +++++++++++++++++++++++++++++++++\n lib/arg_parser/rte_arg_parser.h | 33 +++++++++++++++++++\n lib/arg_parser/version.map      |  1 +\n 3 files changed, 92 insertions(+)",
    "diff": "diff --git a/lib/arg_parser/arg_parser.c b/lib/arg_parser/arg_parser.c\nindex 45acaf5631..58be94b67d 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 \t}\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,49 @@ 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+\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')\n+\t\t\t|| (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+\tuint8_t j;\n+\tint val;\n+\n+\tfor (i = i - 1; i >= 0; i--) {\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 (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+\tcorebits_to_array(mask, cores, cores_len);\n+\tuint32_t total_count = mask->total_bits_set;\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 1b12bf451f..b149b37755 100644\n--- a/lib/arg_parser/rte_arg_parser.h\n+++ b/lib/arg_parser/rte_arg_parser.h\n@@ -58,6 +58,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 f11699a306..f334f1aaed 100644\n--- a/lib/arg_parser/version.map\n+++ b/lib/arg_parser/version.map\n@@ -7,4 +7,5 @@ EXPERIMENTAL {\n \n     # added in 24.03\n     rte_parse_corelist;\n+    rte_parse_coremask;\n };\n",
    "prefixes": [
        "24.03",
        "2/4"
    ]
}