get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 135234,
    "url": "http://patchwork.dpdk.org/api/patches/135234/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20231215172632.3102502-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": "<20231215172632.3102502-3-euan.bourke@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231215172632.3102502-3-euan.bourke@intel.com",
    "date": "2023-12-15T17:26:26",
    "name": "[v4,2/8] arg_parser: add new coremask parsing API",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "e342c4664ed505f12655c78da38520890cfc5f4e",
    "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/20231215172632.3102502-3-euan.bourke@intel.com/mbox/",
    "series": [
        {
            "id": 30582,
            "url": "http://patchwork.dpdk.org/api/series/30582/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=30582",
            "date": "2023-12-15T17:26:24",
            "name": "add new command line argument parsing library",
            "version": 4,
            "mbox": "http://patchwork.dpdk.org/series/30582/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/135234/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/135234/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 1CB3F43700;\n\tFri, 15 Dec 2023 18:26:58 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id D3E2B4338F;\n\tFri, 15 Dec 2023 18:26:51 +0100 (CET)",
            "from mgamail.intel.com (mgamail.intel.com [192.198.163.10])\n by mails.dpdk.org (Postfix) with ESMTP id CB73C43399\n for <dev@dpdk.org>; Fri, 15 Dec 2023 18:26:49 +0100 (CET)",
            "from orviesa001.jf.intel.com ([10.64.159.141])\n by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 15 Dec 2023 09:26:49 -0800",
            "from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151])\n by orviesa001.jf.intel.com with ESMTP; 15 Dec 2023 09:26:48 -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=1702661210; x=1734197210;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=BlKltLXAHkZnuOHB8DzlXHBUilkZroPUNFyag8fVs9w=;\n b=htl2PlpIzBpbry48TTyZy0GMHajiSg/itGWUIMaaDtjymYIjCUtcFSqS\n XTcPCC2MFN3aVi1N4IIRdqtCn4sDv8KV0m2qzLb9CJwr9lc2NNIriyE/h\n 8NFk5IYS7WEW2+zBtt3by4lvx2fIvd2giP0lYee1ymX6+YRf1MV4i0n3L\n kh3qmhIPH+7qrqwktUSRexH8DrGsrI8vatKJLEvFN6nvxvNfuK7nwp9HB\n 57kV9em6IxjKcuTDhW+6gw5OQhvreZZ1WPorXl8O0DUH9HexjudSp51MD\n lBF9mcbf3OWEtvuaPkE8FfPo0X/v8z324PE9XdLbPg2o8ehvo6zAAMINj A==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6600,9927,10925\"; a=\"2474237\"",
            "E=Sophos;i=\"6.04,279,1695711600\";\n   d=\"scan'208\";a=\"2474237\"",
            "E=Sophos;i=\"6.04,279,1695711600\"; d=\"scan'208\";a=\"22914244\""
        ],
        "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 v4 2/8] arg_parser: add new coremask parsing API",
        "Date": "Fri, 15 Dec 2023 17:26:26 +0000",
        "Message-Id": "<20231215172632.3102502-3-euan.bourke@intel.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20231215172632.3102502-1-euan.bourke@intel.com>",
        "References": "\n <https://inbox.dpdk.org/dev/20231207161818.2590661-1-euan.bourke@intel.com/>\n <20231215172632.3102502-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 <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\nto the corelist parsing API, taking a coremask string, a cores\narray and a cores_len int. Parsing the coremask string, filling\nits values into the cores array up to cores_len.\n\nThe API also returns a 'count' which corresponds to the total number\nof cores in the coremask string.\n\nSigned-off-by: Euan Bourke <euan.bourke@intel.com>\n---\n lib/arg_parser/arg_parser.c     | 51 +++++++++++++++++++++++++++++++++\n lib/arg_parser/rte_arg_parser.h | 34 ++++++++++++++++++++++\n lib/arg_parser/version.map      |  1 +\n 3 files changed, 86 insertions(+)",
    "diff": "diff --git a/lib/arg_parser/arg_parser.c b/lib/arg_parser/arg_parser.c\nindex d8324a27b1..8d86a7b618 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_arg_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len)\n@@ -106,3 +118,42 @@ rte_arg_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len\n \n \treturn corebits_to_array(&mask, cores, cores_len);\n }\n+\n+int\n+rte_arg_parse_coremask(const char *coremask, uint16_t *cores, uint32_t cores_len)\n+{\n+\tstruct core_bits mask = {0};\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 -EINVAL;\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 -EINVAL;\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+\treturn corebits_to_array(&mask, cores, cores_len);\n+}\ndiff --git a/lib/arg_parser/rte_arg_parser.h b/lib/arg_parser/rte_arg_parser.h\nindex a1ef428b95..49d7daa204 100644\n--- a/lib/arg_parser/rte_arg_parser.h\n+++ b/lib/arg_parser/rte_arg_parser.h\n@@ -58,6 +58,40 @@ __rte_experimental\n int\n rte_arg_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 unique cores present in the\n+ * \"coremask\" is returned.\n+ * For example, passing a 0xA \"coremask\" results in an array of [1, 3]\n+ * and would return 2.\n+ *\n+ * NOTE: if the length of the input array is insufficient to hold the number of core ids\n+ * in \"coremask\" the input array is filled to capacity but the return value is the\n+ * number of elements which would have been written to the array, had enough space been\n+ * available. [This is similar to the behaviour of the snprintf function]. Because of\n+ * this, the number of core values in the \"coremask\" may be determined by calling the\n+ * function with a NULL array pointer and array length given as 0.\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+ *   -EINVAL 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_arg_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 b0caaac569..b44d4b02b7 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_arg_parse_corelist;\n+\trte_arg_parse_coremask;\n };\n",
    "prefixes": [
        "v4",
        "2/8"
    ]
}