get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 52220,
    "url": "http://patches.dpdk.org/api/patches/52220/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190403171601.9788-5-marcinx.hajkowski@intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<20190403171601.9788-5-marcinx.hajkowski@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190403171601.9788-5-marcinx.hajkowski@intel.com",
    "date": "2019-04-03T17:16:00",
    "name": "[4/4] power: add cmd to query CPU freq.",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "b3531087c77c5f59e0a31a690d47a48b01672cc3",
    "submitter": {
        "id": 1246,
        "url": "http://patches.dpdk.org/api/people/1246/?format=api",
        "name": "Marcin Hajkowski",
        "email": "marcinx.hajkowski@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190403171601.9788-5-marcinx.hajkowski@intel.com/mbox/",
    "series": [
        {
            "id": 4096,
            "url": "http://patches.dpdk.org/api/series/4096/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4096",
            "date": "2019-04-03T17:15:56",
            "name": "Frequency list query",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/4096/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/52220/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/52220/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id BE21D1B567;\n\tWed,  3 Apr 2019 19:16:48 +0200 (CEST)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id B0FF31B513\n\tfor <dev@dpdk.org>; Wed,  3 Apr 2019 19:16:24 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t03 Apr 2019 10:16:24 -0700",
            "from mhajkowx-mobl.ger.corp.intel.com ([10.104.116.180])\n\tby fmsmga001.fm.intel.com with ESMTP; 03 Apr 2019 10:16:23 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.60,305,1549958400\"; d=\"scan'208\";a=\"161086745\"",
        "From": "Hajkowski <marcinx.hajkowski@intel.com>",
        "To": "david.hunt@intel.com",
        "Cc": "dev@dpdk.org,\n\tMarcin Hajkowski <marcinx.hajkowski@intel.com>",
        "Date": "Wed,  3 Apr 2019 19:16:00 +0200",
        "Message-Id": "<20190403171601.9788-5-marcinx.hajkowski@intel.com>",
        "X-Mailer": "git-send-email 2.20.1.windows.1",
        "In-Reply-To": "<20190403171601.9788-1-marcinx.hajkowski@intel.com>",
        "References": "<20190403171601.9788-1-marcinx.hajkowski@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH 4/4] power: add cmd to query CPU freq.",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Marcin Hajkowski <marcinx.hajkowski@intel.com>\n\nAdd command and related logic to query CPU frequencies\neither for specified CPU or all cores.\n\nSigned-off-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>\n---\n .../guest_cli/vm_power_cli_guest.c            | 150 ++++++++++++++++--\n 1 file changed, 138 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c\nindex af49dfef8..d1b4ac2aa 100644\n--- a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c\n+++ b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c\n@@ -99,9 +99,9 @@ set_policy_defaults(struct channel_packet *pkt)\n \tstrcpy(pkt->vm_name, \"ubuntu2\");\n }\n \n-static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,\n-\t\t\t\t__attribute__((unused)) struct cmdline *cl,\n-\t\t\t    __attribute__((unused)) void *data)\n+static void cmd_quit_parsed(__rte_unused void *parsed_result,\n+\t\t__rte_unused struct cmdline *cl,\n+\t\t__rte_unused void *data)\n {\n \tunsigned lcore_id;\n \n@@ -126,10 +126,126 @@ cmdline_parse_inst_t cmd_quit = {\n \n /* *** VM operations *** */\n \n-struct cmd_set_cpu_freq_result {\n-\tcmdline_fixed_string_t set_cpu_freq;\n-\tuint8_t lcore_id;\n-\tcmdline_fixed_string_t cmd;\n+struct cmd_freq_list_result {\n+\tcmdline_fixed_string_t query_freq;\n+\tcmdline_fixed_string_t cpu_num;\n+};\n+\n+static int\n+query_freq_list(struct channel_packet *pkt, unsigned int lcore_id)\n+{\n+\tint ret;\n+\tret = rte_power_guest_channel_send_msg(pkt, lcore_id);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, GUEST_CLI, \"Error sending message.\\n\");\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+receive_freq_list(struct channel_packet_freq_list *pkt_freq_list,\n+\t\tunsigned int lcore_id)\n+{\n+\tint ret;\n+\n+\tret = rte_power_guest_channel_receive_msg(pkt_freq_list,\n+\t\t\tsizeof(struct channel_packet_freq_list),\n+\t\t\tlcore_id);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, GUEST_CLI, \"Error receiving message.\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (pkt_freq_list->command != CPU_POWER_FREQ_LIST) {\n+\t\tRTE_LOG(ERR, GUEST_CLI, \"Unexpected message received.\\n\");\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+static void\n+cmd_query_freq_list_parsed(void *parsed_result,\n+\t\t__rte_unused struct cmdline *cl,\n+\t\t__rte_unused void *data)\n+{\n+\tstruct cmd_freq_list_result *res = parsed_result;\n+\tunsigned int lcore_id;\n+\tstruct channel_packet_freq_list pkt_freq_list;\n+\tstruct channel_packet pkt;\n+\tbool query_list = false;\n+\tint ret;\n+\tchar *ep;\n+\n+\tmemset(&pkt, 0, sizeof(struct channel_packet));\n+\tmemset(&pkt_freq_list, 0, sizeof(struct channel_packet_freq_list));\n+\n+\tif (!strcmp(res->cpu_num, \"all\")) {\n+\n+\t\t/* Get first enabled lcore. */\n+\t\tlcore_id = rte_get_next_lcore(-1,\n+\t\t\t\t0,\n+\t\t\t\t0);\n+\t\tif (lcore_id == RTE_MAX_LCORE) {\n+\t\t\tcmdline_printf(cl, \"Enabled core not found.\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tpkt.command = CPU_POWER_QUERY_FREQ_LIST;\n+\t\tstrcpy(pkt.vm_name, policy.vm_name);\n+\t\tquery_list = true;\n+\t} else {\n+\t\terrno = 0;\n+\t\tlcore_id = (unsigned int)strtol(res->cpu_num, &ep, 10);\n+\t\tif (errno != 0 || lcore_id >= MAX_VCPU_PER_VM ||\n+\t\t\tep == res->cpu_num) {\n+\t\t\tcmdline_printf(cl, \"Invalid parameter provided.\\n\");\n+\t\t\treturn;\n+\t\t}\n+\t\tpkt.command = CPU_POWER_QUERY_FREQ;\n+\t\tstrcpy(pkt.vm_name, policy.vm_name);\n+\t\tpkt.resource_id = lcore_id;\n+\t}\n+\n+\tret = query_freq_list(&pkt, lcore_id);\n+\tif (ret < 0) {\n+\t\tcmdline_printf(cl, \"Error during sending frequency list query.\\n\");\n+\t\treturn;\n+\t}\n+\n+\tret = receive_freq_list(&pkt_freq_list, lcore_id);\n+\tif (ret < 0) {\n+\t\tcmdline_printf(cl, \"Error during frequency list reception.\\n\");\n+\t\treturn;\n+\t}\n+\tif (query_list) {\n+\t\tunsigned int i;\n+\t\tfor (i = 0; i < pkt_freq_list.num_vcpu; ++i)\n+\t\t\tcmdline_printf(cl, \"Frequency of [%d] vcore is %d.\\n\",\n+\t\t\t\t\ti,\n+\t\t\t\t\tpkt_freq_list.freq_list[i]);\n+\t} else {\n+\t\tcmdline_printf(cl, \"Frequency of [%d] vcore is %d.\\n\",\n+\t\t\t\tlcore_id,\n+\t\t\t\tpkt_freq_list.freq_list[lcore_id]);\n+\t}\n+}\n+\n+cmdline_parse_token_string_t cmd_query_freq_token =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_freq_list_result, query_freq, \"query_cpu_freq\");\n+cmdline_parse_token_string_t cmd_query_freq_cpu_num_token =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_freq_list_result, cpu_num, NULL);\n+\n+cmdline_parse_inst_t cmd_query_freq_list = {\n+\t.f = cmd_query_freq_list_parsed,  /* function to call */\n+\t.data = NULL,      /* 2nd arg of func */\n+\t.help_str = \"query_cpu_freq <core_num>|all, request\"\n+\t\t\t\t\" information regarding virtual core frequencies.\"\n+\t\t\t\t\" The keyword 'all' will query list of all vcores for the VM\",\n+\t.tokens = {        /* token list, NULL terminated */\n+\t\t(void *)&cmd_query_freq_token,\n+\t\t(void *)&cmd_query_freq_cpu_num_token,\n+\t\tNULL,\n+\t},\n };\n \n static int\n@@ -138,7 +254,10 @@ check_response_cmd(unsigned int lcore_id, int *result)\n \tstruct channel_packet pkt;\n \tint ret;\n \n-\tret = rte_power_guest_channel_receive_msg(&pkt, lcore_id);\n+\tret = rte_power_guest_channel_receive_msg(&pkt,\n+\t\t\tsizeof(pkt),\n+\t\t\tlcore_id);\n+\n \tif (ret < 0)\n \t\treturn -1;\n \n@@ -150,16 +269,22 @@ check_response_cmd(unsigned int lcore_id, int *result)\n \t\t*result = 0;\n \t\tbreak;\n \tdefault:\n-\t\tRTE_LOG(DEBUG, GUEST_CLI, \"Not expected command has been received.\\n\");\n+\t\tRTE_LOG(ERR, GUEST_CLI, \"Not expected command has been received.\\n\");\n \t\treturn -1;\n \t}\n \n \treturn 0;\n }\n \n+struct cmd_set_cpu_freq_result {\n+\tcmdline_fixed_string_t set_cpu_freq;\n+\tuint8_t lcore_id;\n+\tcmdline_fixed_string_t cmd;\n+};\n+\n static void\n cmd_set_cpu_freq_parsed(void *parsed_result, struct cmdline *cl,\n-\t\t       __attribute__((unused)) void *data)\n+\t\t__rte_unused void *data)\n {\n \tint ret = -1;\n \tstruct cmd_set_cpu_freq_result *res = parsed_result;\n@@ -245,7 +370,7 @@ send_policy(struct channel_packet *pkt, struct cmdline *cl)\n \n static void\n cmd_send_policy_parsed(void *parsed_result, struct cmdline *cl,\n-\t\t       __attribute__((unused)) void *data)\n+\t\t__rte_unused void *data)\n {\n \tint ret = -1;\n \tstruct cmd_send_policy_result *res = parsed_result;\n@@ -281,11 +406,12 @@ cmdline_parse_ctx_t main_ctx[] = {\n \t\t(cmdline_parse_inst_t *)&cmd_quit,\n \t\t(cmdline_parse_inst_t *)&cmd_send_policy_set,\n \t\t(cmdline_parse_inst_t *)&cmd_set_cpu_freq_set,\n+\t\t(cmdline_parse_inst_t *)&cmd_query_freq_list,\n \t\tNULL,\n };\n \n void\n-run_cli(__attribute__((unused)) void *arg)\n+run_cli(__rte_unused void *arg)\n {\n \tstruct cmdline *cl;\n \n",
    "prefixes": [
        "4/4"
    ]
}