get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 94573,
    "url": "https://patches.dpdk.org/api/patches/94573/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1624241862-19085-1-git-send-email-humin29@huawei.com/",
    "project": {
        "id": 1,
        "url": "https://patches.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": "<1624241862-19085-1-git-send-email-humin29@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1624241862-19085-1-git-send-email-humin29@huawei.com",
    "date": "2021-06-21T02:17:42",
    "name": "[v2] app/procinfo: add device registers dump",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "118f0b87561ca391aadb4d2b779f3a37e13b5df3",
    "submitter": {
        "id": 1944,
        "url": "https://patches.dpdk.org/api/people/1944/?format=api",
        "name": "humin (Q)",
        "email": "humin29@huawei.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1624241862-19085-1-git-send-email-humin29@huawei.com/mbox/",
    "series": [
        {
            "id": 17413,
            "url": "https://patches.dpdk.org/api/series/17413/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17413",
            "date": "2021-06-21T02:17:42",
            "name": "[v2] app/procinfo: add device registers dump",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/17413/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/94573/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/94573/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 53FB4A0547;\n\tMon, 21 Jun 2021 04:18:17 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id C06BC40040;\n\tMon, 21 Jun 2021 04:18:16 +0200 (CEST)",
            "from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189])\n by mails.dpdk.org (Postfix) with ESMTP id 9CA144003F\n for <dev@dpdk.org>; Mon, 21 Jun 2021 04:18:14 +0200 (CEST)",
            "from dggeme756-chm.china.huawei.com (unknown [172.30.72.55])\n by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4G7Y4G5tBfz70kD\n for <dev@dpdk.org>; Mon, 21 Jun 2021 10:14:06 +0800 (CST)",
            "from localhost.localdomain (10.69.192.56) by\n dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id\n 15.1.2176.2; Mon, 21 Jun 2021 10:18:10 +0800"
        ],
        "From": "\"Min Hu (Connor)\" <humin29@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<ferruh.yigit@intel.com>, <reshma.pattan@intel.com>",
        "Date": "Mon, 21 Jun 2021 10:17:42 +0800",
        "Message-ID": "<1624241862-19085-1-git-send-email-humin29@huawei.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1619355742-15429-1-git-send-email-humin29@huawei.com>",
        "References": "<1619355742-15429-1-git-send-email-humin29@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.69.192.56]",
        "X-ClientProxiedBy": "dggems704-chm.china.huawei.com (10.3.19.181) To\n dggeme756-chm.china.huawei.com (10.3.19.102)",
        "X-CFilter-Loop": "Reflected",
        "Subject": "[dpdk-dev] [PATCH v2] app/procinfo: add device registers dump",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Chengchang Tang <tangchengchang@huawei.com>\n\nThis patch add support for dump the device registers from a running\napplication. It can help developers locate the problem.\n\nSigned-off-by: Chengchang Tang <tangchengchang@huawei.com>\nSigned-off-by: Min Hu (Connor) <humin29@huawei.com>\n---\nv2:\n* some logs are adjusted and error string are printed after\nfile operation fails.\n---\n app/proc-info/main.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 93 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/app/proc-info/main.c b/app/proc-info/main.c\nindex b9587f7..553d686 100644\n--- a/app/proc-info/main.c\n+++ b/app/proc-info/main.c\n@@ -94,6 +94,9 @@ static char *mempool_name;\n /**< Enable iter mempool. */\n static uint32_t enable_iter_mempool;\n static char *mempool_iter_name;\n+/**< Enable dump regs. */\n+static uint32_t enable_dump_regs;\n+static char *dump_regs_file_prefix;\n \n /**< display usage */\n static void\n@@ -119,7 +122,8 @@ proc_info_usage(const char *prgname)\n \t\t\"  --show-crypto: to display crypto information\\n\"\n \t\t\"  --show-ring[=name]: to display ring information\\n\"\n \t\t\"  --show-mempool[=name]: to display mempool information\\n\"\n-\t\t\"  --iter-mempool=name: iterate mempool elements to display content\\n\",\n+\t\t\"  --iter-mempool=name: iterate mempool elements to display content\\n\"\n+\t\t\"  --dump-regs=file-prefix: dump reg to file with the file-prefix\\n\",\n \t\tprgname);\n }\n \n@@ -226,6 +230,7 @@ proc_info_parse_args(int argc, char **argv)\n \t\t{\"show-ring\", optional_argument, NULL, 0},\n \t\t{\"show-mempool\", optional_argument, NULL, 0},\n \t\t{\"iter-mempool\", required_argument, NULL, 0},\n+\t\t{\"dump-regs\", required_argument, NULL, 0},\n \t\t{NULL, 0, 0, 0}\n \t};\n \n@@ -288,6 +293,10 @@ proc_info_parse_args(int argc, char **argv)\n \t\t\t\t\t\"iter-mempool\", MAX_LONG_OPT_SZ)) {\n \t\t\t\tenable_iter_mempool = 1;\n \t\t\t\tmempool_iter_name = optarg;\n+\t\t\t} else if (!strncmp(long_option[option_index].name,\n+\t\t\t\t\t\"dump-regs\", MAX_LONG_OPT_SZ)) {\n+\t\t\t\tenable_dump_regs = 1;\n+\t\t\t\tdump_regs_file_prefix = optarg;\n \t\t\t}\n \t\t\tbreak;\n \t\tcase 1:\n@@ -1349,6 +1358,87 @@ iter_mempool(char *name)\n \t}\n }\n \n+static void\n+dump_regs(char *file_prefix)\n+{\n+#define MAX_FILE_NAME_SZ (MAX_LONG_OPT_SZ + 10)\n+\tchar file_name[MAX_FILE_NAME_SZ];\n+\tstruct rte_dev_reg_info reg_info;\n+\tstruct rte_eth_dev_info dev_info;\n+\tunsigned char *buf_data;\n+\tsize_t buf_size;\n+\tFILE *fp_regs;\n+\tuint16_t i;\n+\tint ret;\n+\n+\tsnprintf(bdr_str, MAX_STRING_LEN, \" dump - Port REG\");\n+\tSTATS_BDR_STR(10, bdr_str);\n+\n+\tRTE_ETH_FOREACH_DEV(i) {\n+\t\t/* Skip if port is not in mask */\n+\t\tif ((enabled_port_mask & (1ul << i)) == 0)\n+\t\t\tcontinue;\n+\n+\t\tsnprintf(bdr_str, MAX_STRING_LEN, \" Port (%u)\", i);\n+\t\tSTATS_BDR_STR(5, bdr_str);\n+\n+\t\tmemset(&reg_info, 0, sizeof(reg_info));\n+\t\tmemset(&dev_info, 0, sizeof(dev_info));\n+\n+\t\tret = rte_eth_dev_info_get(i, &dev_info);\n+\t\tif (ret) {\n+\t\t\tprintf(\"Error getting device info: %d\\n\", ret);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tret = rte_eth_dev_get_reg_info(i, &reg_info);\n+\t\tif (ret) {\n+\t\t\tprintf(\"Error getting device reg info: %d\\n\", ret);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tbuf_size = reg_info.length * reg_info.width;\n+\t\tbuf_data = malloc(buf_size);\n+\t\tif (buf_data == NULL) {\n+\t\t\tprintf(\"Error allocating %zu bytes buffer\\n\", buf_size);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\treg_info.data = buf_data;\n+\t\treg_info.length = 0;\n+\t\tret = rte_eth_dev_get_reg_info(i, &reg_info);\n+\t\tif (ret) {\n+\t\t\tprintf(\"Error getting regs from device: %d\\n\", ret);\n+\t\t\tfree(buf_data);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tsnprintf(file_name, MAX_FILE_NAME_SZ, \"%s-port%u\",\n+\t\t\t\tfile_prefix, i);\n+\t\tfp_regs = fopen(file_name, \"wb\");\n+\t\tif (fp_regs == NULL) {\n+\t\t\tprintf(\"Error during opening '%s' for writing: %s\\n\",\n+\t\t\t\t\tfile_name, strerror(errno));\n+\t\t} else {\n+\t\t\tsize_t nr_written;\n+\n+\t\t\tnr_written = fwrite(buf_data, 1, buf_size, fp_regs);\n+\t\t\tif (nr_written != buf_size)\n+\t\t\t\tprintf(\"Error during writing %s: %s\\n\",\n+\t\t\t\t\t\tfile_prefix, strerror(errno));\n+\t\t\telse\n+\t\t\t\tprintf(\"Device (%s) regs dumped successfully, \"\n+\t\t\t\t\t\"driver:%s version:0X%08X\\n\",\n+\t\t\t\t\tdev_info.device->name,\n+\t\t\t\t\tdev_info.driver_name, reg_info.version);\n+\n+\t\t\tfclose(fp_regs);\n+\t\t}\n+\n+\t\tfree(buf_data);\n+\t}\n+}\n+\n int\n main(int argc, char **argv)\n {\n@@ -1454,6 +1544,8 @@ main(int argc, char **argv)\n \t\tshow_mempool(mempool_name);\n \tif (enable_iter_mempool)\n \t\titer_mempool(mempool_iter_name);\n+\tif (enable_dump_regs)\n+\t\tdump_regs(dump_regs_file_prefix);\n \n \tRTE_ETH_FOREACH_DEV(i)\n \t\trte_eth_dev_close(i);\n",
    "prefixes": [
        "v2"
    ]
}