get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 47369,
    "url": "http://patches.dpdk.org/api/patches/47369/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181024160311.85457-8-kevin.laatz@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": "<20181024160311.85457-8-kevin.laatz@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181024160311.85457-8-kevin.laatz@intel.com",
    "date": "2018-10-24T16:03:05",
    "name": "[v8,07/13] telemetry: update metrics before sending stats",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "b38ed1420f0818607817ec1aab0f1005cc9f20cc",
    "submitter": {
        "id": 921,
        "url": "http://patches.dpdk.org/api/people/921/?format=api",
        "name": "Kevin Laatz",
        "email": "kevin.laatz@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/20181024160311.85457-8-kevin.laatz@intel.com/mbox/",
    "series": [
        {
            "id": 2075,
            "url": "http://patches.dpdk.org/api/series/2075/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=2075",
            "date": "2018-10-24T16:02:58",
            "name": "introduce telemetry library",
            "version": 8,
            "mbox": "http://patches.dpdk.org/series/2075/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/47369/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/47369/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 9CAE01B13A;\n\tWed, 24 Oct 2018 18:03:38 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id 3BEA01B150\n\tfor <dev@dpdk.org>; Wed, 24 Oct 2018 18:03:27 +0200 (CEST)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t24 Oct 2018 09:03:26 -0700",
            "from silpixa00397517.ir.intel.com (HELO\n\tsilpixa00397517.ger.corp.intel.com) ([10.237.222.54])\n\tby orsmga004.jf.intel.com with ESMTP; 24 Oct 2018 09:03:16 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.54,420,1534834800\"; d=\"scan'208\";a=\"244010345\"",
        "From": "Kevin Laatz <kevin.laatz@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "harry.van.haaren@intel.com, stephen@networkplumber.org,\n\tgaetan.rivet@6wind.com, shreyansh.jain@nxp.com, thomas@monjalon.net, \n\tmattias.ronnblom@ericsson.com, bruce.richardson@intel.com,\n\tCiara Power <ciara.power@intel.com>,\n\tBrian Archbold <brian.archbold@intel.com>,\n\tKevin Laatz <kevin.laatz@intel.com>",
        "Date": "Wed, 24 Oct 2018 17:03:05 +0100",
        "Message-Id": "<20181024160311.85457-8-kevin.laatz@intel.com>",
        "X-Mailer": "git-send-email 2.9.5",
        "In-Reply-To": "<20181024160311.85457-1-kevin.laatz@intel.com>",
        "References": "<20181024132725.5142-1-kevin.laatz@intel.com>\n\t<20181024160311.85457-1-kevin.laatz@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v8 07/13] telemetry: update metrics before\n\tsending stats",
        "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: Ciara Power <ciara.power@intel.com>\n\nThis patch adds functionality to update the statistics in\nthe metrics library with values from the ethdev stats.\n\nValues need to be updated before they are encoded into a JSON\nmessage and sent to the client that requested them. The JSON encoding\nwill be added in a subsequent patch.\n\nSigned-off-by: Ciara Power <ciara.power@intel.com>\nSigned-off-by: Brian Archbold <brian.archbold@intel.com>\nSigned-off-by: Kevin Laatz <kevin.laatz@intel.com>\nAcked-by: Harry van Haaren <harry.van.haaren@intel.com>\n---\n lib/librte_telemetry/rte_telemetry.c          | 134 ++++++++++++++++++++++++++\n lib/librte_telemetry/rte_telemetry_internal.h |   4 +\n lib/librte_telemetry/rte_telemetry_parser.c   |  17 ++++\n 3 files changed, 155 insertions(+)",
    "diff": "diff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c\nindex cac7884..7616e7c 100644\n--- a/lib/librte_telemetry/rte_telemetry.c\n+++ b/lib/librte_telemetry/rte_telemetry.c\n@@ -46,6 +46,78 @@ rte_telemetry_is_port_active(int port_id)\n \treturn 0;\n }\n \n+static int32_t\n+rte_telemetry_update_metrics_ethdev(struct telemetry_impl *telemetry,\n+\tuint16_t port_id, int reg_start_index)\n+{\n+\tint ret, num_xstats, i;\n+\tstruct rte_eth_xstat *eth_xstats;\n+\n+\tif (!rte_eth_dev_is_valid_port(port_id)) {\n+\t\tTELEMETRY_LOG_ERR(\"port_id: %d is invalid\", port_id);\n+\t\tret = rte_telemetry_send_error_response(telemetry, -EINVAL);\n+\t\tif (ret < 0)\n+\t\t\tTELEMETRY_LOG_ERR(\"Could not send error\");\n+\t\treturn -1;\n+\t}\n+\n+\tret = rte_telemetry_is_port_active(port_id);\n+\tif (ret < 1) {\n+\t\tret = rte_telemetry_send_error_response(telemetry, -EINVAL);\n+\t\tif (ret < 0)\n+\t\t\tTELEMETRY_LOG_ERR(\"Could not send error\");\n+\t\treturn -1;\n+\t}\n+\n+\tnum_xstats = rte_eth_xstats_get(port_id, NULL, 0);\n+\tif (num_xstats < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"rte_eth_xstats_get(%u) failed: %d\", port_id,\n+\t\t\t\tnum_xstats);\n+\t\tret = rte_telemetry_send_error_response(telemetry, -EPERM);\n+\t\tif (ret < 0)\n+\t\t\tTELEMETRY_LOG_ERR(\"Could not send error\");\n+\t\treturn -1;\n+\t}\n+\n+\teth_xstats = malloc(sizeof(struct rte_eth_xstat) * num_xstats);\n+\tif (eth_xstats == NULL) {\n+\t\tTELEMETRY_LOG_ERR(\"Failed to malloc memory for xstats\");\n+\t\tret = rte_telemetry_send_error_response(telemetry, -ENOMEM);\n+\t\tif (ret < 0)\n+\t\t\tTELEMETRY_LOG_ERR(\"Could not send error\");\n+\t\treturn -1;\n+\t}\n+\n+\tret = rte_eth_xstats_get(port_id, eth_xstats, num_xstats);\n+\tif (ret < 0 || ret > num_xstats) {\n+\t\tfree(eth_xstats);\n+\t\tTELEMETRY_LOG_ERR(\"rte_eth_xstats_get(%u) len%i failed: %d\",\n+\t\t\t\tport_id, num_xstats, ret);\n+\t\tret = rte_telemetry_send_error_response(telemetry, -EPERM);\n+\t\tif (ret < 0)\n+\t\t\tTELEMETRY_LOG_ERR(\"Could not send error\");\n+\t\treturn -1;\n+\t}\n+\n+\tuint64_t xstats_values[num_xstats];\n+\tfor (i = 0; i < num_xstats; i++)\n+\t\txstats_values[i] = eth_xstats[i].value;\n+\n+\tret = rte_metrics_update_values(port_id, reg_start_index, xstats_values,\n+\t\t\tnum_xstats);\n+\tif (ret < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"Could not update metrics values\");\n+\t\tret = rte_telemetry_send_error_response(telemetry, -EPERM);\n+\t\tif (ret < 0)\n+\t\t\tTELEMETRY_LOG_ERR(\"Could not send error\");\n+\t\tfree(eth_xstats);\n+\t\treturn -1;\n+\t}\n+\n+\tfree(eth_xstats);\n+\treturn 0;\n+}\n+\n int32_t\n rte_telemetry_write_to_socket(struct telemetry_impl *telemetry,\n \tconst char *json_string)\n@@ -130,6 +202,68 @@ rte_telemetry_send_error_response(struct telemetry_impl *telemetry,\n \treturn 0;\n }\n \n+int32_t\n+rte_telemetry_send_ports_stats_values(uint32_t *metric_ids, int num_metric_ids,\n+\tuint32_t *port_ids, int num_port_ids, struct telemetry_impl *telemetry)\n+{\n+\tint ret, i;\n+\tchar *json_buffer = NULL;\n+\n+\tif (telemetry == NULL) {\n+\t\tTELEMETRY_LOG_ERR(\"Invalid telemetry argument\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (metric_ids == NULL) {\n+\t\tTELEMETRY_LOG_ERR(\"Invalid metric_ids array\");\n+\t\tgoto einval_fail;\n+\t}\n+\n+\tif (num_metric_ids < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"Invalid num_metric_ids, must be positive\");\n+\t\tgoto einval_fail;\n+\t}\n+\n+\tif (port_ids == NULL) {\n+\t\tTELEMETRY_LOG_ERR(\"Invalid port_ids array\");\n+\t\tgoto einval_fail;\n+\t}\n+\n+\tif (num_port_ids < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"Invalid num_port_ids, must be positive\");\n+\t\tgoto einval_fail;\n+\t}\n+\n+\tfor (i = 0; i < num_port_ids; i++) {\n+\t\tif (!rte_eth_dev_is_valid_port(port_ids[i])) {\n+\t\t\tTELEMETRY_LOG_ERR(\"Port: %d invalid\", port_ids[i]);\n+\t\t\tgoto einval_fail;\n+\t\t}\n+\n+\t\tret = rte_telemetry_update_metrics_ethdev(telemetry,\n+\t\t\tport_ids[i], telemetry->reg_index);\n+\t\tif (ret < 0) {\n+\t\t\tTELEMETRY_LOG_ERR(\"Failed to update ethdev metrics\");\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tret = rte_telemetry_write_to_socket(telemetry, json_buffer);\n+\tif (ret < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"Could not write to socket\");\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+\n+einval_fail:\n+\tret = rte_telemetry_send_error_response(telemetry, -EINVAL);\n+\tif (ret < 0)\n+\t\tTELEMETRY_LOG_ERR(\"Could not send error\");\n+\treturn -1;\n+}\n+\n+\n static int32_t\n rte_telemetry_reg_ethdev_to_metrics(uint16_t port_id)\n {\ndiff --git a/lib/librte_telemetry/rte_telemetry_internal.h b/lib/librte_telemetry/rte_telemetry_internal.h\nindex 86a5ba1..0082cb2 100644\n--- a/lib/librte_telemetry/rte_telemetry_internal.h\n+++ b/lib/librte_telemetry/rte_telemetry_internal.h\n@@ -71,4 +71,8 @@ rte_telemetry_unregister_client(struct telemetry_impl *telemetry,\n int32_t\n rte_telemetry_is_port_active(int port_id);\n \n+int32_t\n+rte_telemetry_send_ports_stats_values(uint32_t *metric_ids, int num_metric_ids,\n+\tuint32_t *port_ids, int num_port_ids, struct telemetry_impl *telemetry);\n+\n #endif\ndiff --git a/lib/librte_telemetry/rte_telemetry_parser.c b/lib/librte_telemetry/rte_telemetry_parser.c\nindex 6bc4c6d..084c160 100644\n--- a/lib/librte_telemetry/rte_telemetry_parser.c\n+++ b/lib/librte_telemetry/rte_telemetry_parser.c\n@@ -258,6 +258,7 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry,\n \tint ret, num_metrics, i, p;\n \tstruct rte_metric_name *names;\n \tuint64_t num_port_ids = 0;\n+\tuint32_t port_ids[RTE_MAX_ETHPORTS];\n \n \tif (telemetry == NULL) {\n \t\tTELEMETRY_LOG_ERR(\"Invalid telemetry argument\");\n@@ -313,6 +314,7 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry,\n \tuint32_t stat_ids[num_metrics];\n \n \tRTE_ETH_FOREACH_DEV(p) {\n+\t\tport_ids[num_port_ids] = p;\n \t\tnum_port_ids++;\n \t}\n \n@@ -337,6 +339,13 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry,\n \t\tgoto fail;\n \t}\n \n+\tret = rte_telemetry_send_ports_stats_values(stat_ids, num_metrics,\n+\t\tport_ids, num_port_ids, telemetry);\n+\tif (ret < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"Sending ports stats values failed\");\n+\t\tgoto fail;\n+\t}\n+\n \treturn 0;\n \n fail:\n@@ -428,6 +437,14 @@ rte_telemetry_command_ports_stats_values_by_name(struct telemetry_impl\n \t\tTELEMETRY_LOG_ERR(\"Could not convert stat names to IDs\");\n \t\treturn -1;\n \t}\n+\n+\tret = rte_telemetry_send_ports_stats_values(stat_ids, num_stat_names,\n+\t\tport_ids, num_port_ids, telemetry);\n+\tif (ret < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"Sending ports stats values failed\");\n+\t\treturn -1;\n+\t}\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "v8",
        "07/13"
    ]
}