get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 134934,
    "url": "http://patchwork.dpdk.org/api/patches/134934/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20231207161818.2590661-7-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": "<20231207161818.2590661-7-euan.bourke@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231207161818.2590661-7-euan.bourke@intel.com",
    "date": "2023-12-07T16:18:16",
    "name": "[v3,6/8] arg_parser: added common core string and heuristic parsers",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "cc87bc7f98c35998fe5654cf3b0065c561bbd925",
    "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/20231207161818.2590661-7-euan.bourke@intel.com/mbox/",
    "series": [
        {
            "id": 30478,
            "url": "http://patchwork.dpdk.org/api/series/30478/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=30478",
            "date": "2023-12-07T16:18:10",
            "name": "add new command line argument parsing library",
            "version": 3,
            "mbox": "http://patchwork.dpdk.org/series/30478/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/134934/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/134934/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 A0F754369D;\n\tThu,  7 Dec 2023 17:19:25 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 4F0C442F6F;\n\tThu,  7 Dec 2023 17:18:47 +0100 (CET)",
            "from mgamail.intel.com (mgamail.intel.com [134.134.136.24])\n by mails.dpdk.org (Postfix) with ESMTP id 521F442F4F\n for <dev@dpdk.org>; Thu,  7 Dec 2023 17:18:44 +0100 (CET)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 07 Dec 2023 08:18:44 -0800",
            "from unknown (HELO silpixa00400630.ir.intel.com) ([10.237.213.151])\n by orsmga007.jf.intel.com with ESMTP; 07 Dec 2023 08:18:42 -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=1701965924; x=1733501924;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=X+91EEYKdZSCJ5uhR76zNfCqIVvnVsqGw+7rnYFiXhY=;\n b=D1bCawCiyFaXf8EOqmR1XCQ/nQwcd82bMH/Ffd4LWxo1G9o4kOp1kJ/F\n 9vUjrjfIE9zOz8nTXEFcFIH/s4mJLEg0B2huwhrkXTlI4yuHsF+YJ9H64\n Yx6Td5vywvEf7ZONgn/QIWEx836U74PDw56kjHAg/B+tE474CYUozn6eC\n rWZ+XjQmjU019UETC3l7khL6fx0+Ezyr/xTw2vOgeRasWZI8MPRM9+qOa\n sF0L0WzEuQg1artjkJBuKxa8b7BtWxrDvM4BAHTk7wxR/9lzkWbMiI5sS\n E2pkreybf3KaQKoqDD0KV73enVAGFh7x+R900ZLAI6inxYH8J+3rPN6LD A==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6600,9927,10917\"; a=\"397048628\"",
            "E=Sophos;i=\"6.04,256,1695711600\"; d=\"scan'208\";a=\"397048628\"",
            "E=McAfee;i=\"6600,9927,10917\"; a=\"765153984\"",
            "E=Sophos;i=\"6.04,256,1695711600\"; d=\"scan'208\";a=\"765153984\""
        ],
        "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 v3 6/8] arg_parser: added common core string and heuristic\n parsers",
        "Date": "Thu,  7 Dec 2023 16:18:16 +0000",
        "Message-Id": "<20231207161818.2590661-7-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 <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": "Two new functions, the first is a 'heuristic parser' which examines a\nstring describing a set of cores and determines based off heuristics\nwhether its a coremask or a corelist.\n\nSecond is a 'combined parser' which calls the first function and then\nbased off the returned value will call the relevant core string parser.\nThis function also takes a 'default_type' int which corresponds to\nwhich parser should be used in the case of an ambiguous string.\n\nSigned-off-by: Euan Bourke <euan.bourke@intel.com>\n---\n lib/arg_parser/arg_parser.c     | 68 +++++++++++++++++++++++++++++++++\n lib/arg_parser/rte_arg_parser.h | 60 +++++++++++++++++++++++++++++\n lib/arg_parser/version.map      |  2 +\n 3 files changed, 130 insertions(+)",
    "diff": "diff --git a/lib/arg_parser/arg_parser.c b/lib/arg_parser/arg_parser.c\nindex cebab9e2f8..95cbc50c13 100644\n--- a/lib/arg_parser/arg_parser.c\n+++ b/lib/arg_parser/arg_parser.c\n@@ -7,10 +7,15 @@\n #include \"ctype.h\"\n #include \"string.h\"\n #include \"stdbool.h\"\n+#include \"stdio.h\"\n \n #include <rte_arg_parser.h>\n #include <rte_common.h>\n \n+#define RTE_ARG_PARSE_TYPE_COREMASK 0\n+#define RTE_ARG_PARSE_TYPE_CORELIST 1\n+#define RTE_ARG_PARSE_TYPE_UNKNOWN 2\n+\n #define BITS_PER_HEX 4\n #define MAX_COREMASK_SIZE ((UINT16_MAX + 1) / BITS_PER_HEX)\n \n@@ -22,6 +27,7 @@ struct core_bits {\n \tuint32_t total_bits_set;\n };\n \n+\n static inline bool\n get_core_bit(struct core_bits *mask, uint16_t idx)\n {\n@@ -159,3 +165,65 @@ rte_arg_parse_coremask(const char *coremask, uint16_t *cores, uint32_t cores_len\n \n \treturn total_count;\n }\n+\n+int\n+rte_arg_parse_arg_type(const char *core_string)\n+{\n+\t/* Remove leading whitespace */\n+\twhile (isblank(*core_string))\n+\t\tcore_string++;\n+\n+\t/* Check for 0x prefix */\n+\tif (core_string[0] == '0' && tolower(core_string[1]) == 'x') {\n+\t\tif (core_string[2] != '\\0')\n+\t\t\treturn RTE_ARG_PARSE_TYPE_COREMASK;\n+\t\treturn -1;\n+\t}\n+\n+\tint i = 0, idx = 0;\n+\t/* Check for ',' and '-' and check for A-F */\n+\tdo {\n+\t\twhile (isblank(core_string[idx]))\n+\t\t\tidx++;\n+\n+\t\tif (core_string[idx] == ',' || core_string[idx] == '-')\n+\t\t\treturn RTE_ARG_PARSE_TYPE_CORELIST;\n+\n+\t\tif (isalpha(core_string[idx])) {\n+\t\t\tif (isxdigit(core_string[idx]))\n+\t\t\t\treturn RTE_ARG_PARSE_TYPE_COREMASK;\n+\t\t\treturn -1;\n+\t\t}\n+\t\tidx++;\n+\t\ti++;\n+\t} while (core_string[idx] != '\\0');\n+\n+\t/* Check length of core_string if ambiguous as max length of a uint16_t is 5 digits\n+\t * implying its a coremask.\n+\t */\n+\tif (i > 5)\n+\t\treturn RTE_ARG_PARSE_TYPE_COREMASK;\n+\n+\treturn -1;\n+}\n+\n+int\n+rte_arg_parse_core_string(const char *core_string, uint16_t *cores, uint32_t cores_len,\n+\t\tint default_type)\n+{\n+\tif (default_type != RTE_ARG_PARSE_TYPE_COREMASK &&\n+\t\t\tdefault_type != RTE_ARG_PARSE_TYPE_CORELIST) {\n+\t\treturn -1;\n+\t}\n+\tswitch (rte_arg_parse_arg_type(core_string)) {\n+\tcase RTE_ARG_PARSE_TYPE_COREMASK:\n+\t\treturn rte_arg_parse_coremask(core_string, cores, cores_len);\n+\tcase RTE_ARG_PARSE_TYPE_CORELIST:\n+\t\treturn rte_arg_parse_corelist(core_string, cores, cores_len);\n+\tdefault:\n+\t\treturn default_type == RTE_ARG_PARSE_TYPE_COREMASK ?\n+\t\t\trte_arg_parse_coremask(core_string, cores, cores_len) :\n+\t\t\trte_arg_parse_corelist(core_string, cores, cores_len);\n+\t\treturn -1;\n+\t}\n+}\ndiff --git a/lib/arg_parser/rte_arg_parser.h b/lib/arg_parser/rte_arg_parser.h\nindex 359d40e305..125ca9524c 100644\n--- a/lib/arg_parser/rte_arg_parser.h\n+++ b/lib/arg_parser/rte_arg_parser.h\n@@ -92,6 +92,66 @@ __rte_experimental\n int\n rte_arg_parse_coremask(const char *coremask, uint16_t *cores, uint32_t cores_len);\n \n+/**\n+ * Use heuristics to determine if a string contains a coremask or a corelist.\n+ *\n+ * This function will check a series of conditions and return an int representing which\n+ * core type (mask or list) the string represents or UNKNOWN if the string is ambiguous.\n+ *\n+ * @param core_string\n+ *   A string describing the intended cores to be parsed\n+ * @return\n+ *   int representing the core type\n+ *   -1: error.\n+ *   0: coremask.\n+ *   1: corelist.\n+ *   2: unknown (ambiguous).\n+ */\n+__rte_experimental\n+int\n+rte_arg_parse_arg_type(const char *core_string);\n+\n+/**\n+ * Convert a string describing either a corelist or coremask into an array of core ids.\n+ *\n+ * This function will fill the \"cores\" array up to \"cores_len\" with the core ids described\n+ * in the \"core_string\". The string can either describe a corelist or a coremask, and\n+ * will be parsed accordingly. The number of unique core ids in the string is then returned.\n+ * For example:\n+ * \"1-4\" is treated as a corelist and results in an array of [1,2,3,4] with 4 being returned\n+ * \"0xA1\" is treated as a coremask and results in an array of [0,5,7] with 3 being returned\n+ *\n+ * In the case of an ambiguous string, the function will use the default_type parameter to\n+ * decide.\n+ *\n+ * NOTE: if the length of the input array is insufficient to hold the number of core ids\n+ * in \"core_string\" 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 \"core_string\" may be determined by calling the\n+ * function with a NULL array pointer and array length given as 0.\n+ *\n+ * @param core_string\n+ *   A string describing the intended cores to be parsed.\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 \"core_string\"\n+ * @param default_type\n+ *   How to treat ambiguous cases (e.g. '4' could be mask or list).\n+ *   0: mask.\n+ *   1: list.\n+ * @return\n+ *   n: the number of unique cores present in \"core_string\".\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_arg_parse_core_string(const char *core_string, uint16_t *cores, uint32_t cores_len,\n+\t\tint default_type);\n \n #ifdef __cplusplus\n }\ndiff --git a/lib/arg_parser/version.map b/lib/arg_parser/version.map\nindex b44d4b02b7..383b6bd0e9 100644\n--- a/lib/arg_parser/version.map\n+++ b/lib/arg_parser/version.map\n@@ -8,4 +8,6 @@ EXPERIMENTAL {\n \t# added in 24.03\n \trte_arg_parse_corelist;\n \trte_arg_parse_coremask;\n+\trte_arg_parse_arg_type;\n+\trte_arg_parse_core_string;\n };\n",
    "prefixes": [
        "v3",
        "6/8"
    ]
}