get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 53536,
    "url": "http://patchwork.dpdk.org/api/patches/53536/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20190517160757.28098-1-reshma.pattan@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": "<20190517160757.28098-1-reshma.pattan@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190517160757.28098-1-reshma.pattan@intel.com",
    "date": "2019-05-17T16:07:57",
    "name": "lib/telemetry: add support to fetch global metrics",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "9c18bbbcfbe9ce261bac9f3678522ccdeec8a7a3",
    "submitter": {
        "id": 70,
        "url": "http://patchwork.dpdk.org/api/people/70/?format=api",
        "name": "Pattan, Reshma",
        "email": "reshma.pattan@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/20190517160757.28098-1-reshma.pattan@intel.com/mbox/",
    "series": [
        {
            "id": 4712,
            "url": "http://patchwork.dpdk.org/api/series/4712/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=4712",
            "date": "2019-05-17T16:07:57",
            "name": "lib/telemetry: add support to fetch global metrics",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/4712/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/53536/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/53536/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 8D9205B38;\n\tFri, 17 May 2019 18:08:04 +0200 (CEST)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby dpdk.org (Postfix) with ESMTP id A380B5B16\n\tfor <dev@dpdk.org>; Fri, 17 May 2019 18:08:02 +0200 (CEST)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t17 May 2019 09:08:01 -0700",
            "from silpixa00400214.ir.intel.com (HELO\n\tsilpixa00400214.ger.corp.intel.com) ([10.237.222.119])\n\tby orsmga001.jf.intel.com with ESMTP; 17 May 2019 09:07:59 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Reshma Pattan <reshma.pattan@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "kevin.laatz@intel.com, anatoly.burakov@intel.com,\n\tReshma Pattan <reshma.pattan@intel.com>",
        "Date": "Fri, 17 May 2019 17:07:57 +0100",
        "Message-Id": "<20190517160757.28098-1-reshma.pattan@intel.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH] lib/telemetry: add support to fetch global\n\tmetrics",
        "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": "telemetry has support for fetching port based stats\nfrom metrics library.\n\nMetrics library also has global stats which are\nnot fetched by telemetry, so extend telemetry to\nfetch the global metrics.\n\nSigned-off-by: Reshma Pattan <reshma.pattan@intel.com>\n---\n doc/guides/howto/telemetry.rst                |   9 +-\n doc/guides/rel_notes/release_19_08.rst        |   5 +\n lib/librte_telemetry/rte_telemetry.c          | 119 ++++++++++++----\n lib/librte_telemetry/rte_telemetry_internal.h |  31 ++++-\n lib/librte_telemetry/rte_telemetry_parser.c   | 130 +++++++++++++++---\n usertools/dpdk-telemetry-client.py            |  13 +-\n 6 files changed, 253 insertions(+), 54 deletions(-)",
    "diff": "diff --git a/doc/guides/howto/telemetry.rst b/doc/guides/howto/telemetry.rst\nindex 00f8f7a85..cacc08216 100644\n--- a/doc/guides/howto/telemetry.rst\n+++ b/doc/guides/howto/telemetry.rst\n@@ -11,9 +11,10 @@ Introduction\n ------------\n \n The ``librte_telemetry`` provides the functionality so that users may query\n-metrics from incoming port traffic. The application which initializes packet\n-forwarding will act as the server, sending metrics to the requesting application\n-which acts as the client.\n+metrics from incoming port traffic and global stats(application stats).\n+The application which initializes packet forwarding will act as the server,\n+sending metrics to the requesting application which acts as the client.\n+\n \n In DPDK, applications are used to initialize the ``telemetry``. To view incoming\n traffic on featured ports, the application should be run first (ie. after ports\n@@ -79,7 +80,7 @@ any DPDK application is applicable.\n    the menu.\n \n #. Send traffic to any or all available ports from a traffic generator.\n-   Select a query option(recursive or singular polling).\n+   Select a query option(recursive or singular polling or global stats).\n    The metrics will then be displayed on the client terminal in JSON format.\n \n #. Once finished, unregister the client using the menu command.\ndiff --git a/doc/guides/rel_notes/release_19_08.rst b/doc/guides/rel_notes/release_19_08.rst\nindex b9510f93a..a0bf9923a 100644\n--- a/doc/guides/rel_notes/release_19_08.rst\n+++ b/doc/guides/rel_notes/release_19_08.rst\n@@ -54,6 +54,11 @@ New Features\n      Also, make sure to start the actual text at the margin.\n      =========================================================\n \n+* **Updated telemetry library for global metrics support.**\n+\n+  Updated ``librte_telemetry`` to fetch the global metrics from the\n+  ``librte_metrics`` library.\n+\n \n Removed Items\n -------------\ndiff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c\nindex b852630c5..dabf2c775 100644\n--- a/lib/librte_telemetry/rte_telemetry.c\n+++ b/lib/librte_telemetry/rte_telemetry.c\n@@ -449,17 +449,14 @@ rte_telemetry_json_format_port(struct telemetry_impl *telemetry,\n \n static int32_t\n rte_telemetry_encode_json_format(struct telemetry_impl *telemetry,\n-\tuint32_t *port_ids, uint32_t num_port_ids, uint32_t *metric_ids,\n-\tuint32_t num_metric_ids, char **json_buffer)\n+\tstruct telemetry_encode_param *ep, char **json_buffer)\n {\n \tint ret;\n \tjson_t *root, *ports;\n \tuint32_t i;\n-\n-\tif (num_port_ids <= 0 || num_metric_ids <= 0) {\n-\t\tTELEMETRY_LOG_ERR(\"Please provide port and metric ids to query\");\n-\t\tgoto einval_fail;\n-\t}\n+\tuint32_t port_id;\n+\tuint32_t num_port_ids;\n+\tuint32_t num_metric_ids;\n \n \tports = json_array();\n \tif (ports == NULL) {\n@@ -467,20 +464,47 @@ rte_telemetry_encode_json_format(struct telemetry_impl *telemetry,\n \t\tgoto eperm_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+\tif (ep->type == PORT_STATS) {\n+\t\tnum_port_ids = ep->pp.num_port_ids;\n+\t\tnum_metric_ids = ep->pp.num_metric_ids;\n+\n+\t\tif (num_port_ids <= 0 || num_metric_ids <= 0) {\n+\t\t\tTELEMETRY_LOG_ERR(\"Please provide port and metric ids to query\");\n \t\t\tgoto einval_fail;\n \t\t}\n-\t}\n \n-\tfor (i = 0; i < num_port_ids; i++) {\n-\t\tret = rte_telemetry_json_format_port(telemetry, port_ids[i],\n-\t\t\tports, metric_ids, num_metric_ids);\n+\t\tfor (i = 0; i < num_port_ids; i++) {\n+\t\t\tport_id = ep->pp.port_ids[i];\n+\t\t\tif (!rte_eth_dev_is_valid_port(port_id)) {\n+\t\t\t\tTELEMETRY_LOG_ERR(\"Port: %d invalid\",\n+\t\t\t\t\t\t\tport_id);\n+\t\t\t\tgoto einval_fail;\n+\t\t\t}\n+\t\t}\n+\n+\t\tfor (i = 0; i < num_port_ids; i++) {\n+\t\t\tport_id = ep->pp.port_ids[i];\n+\t\t\tret = rte_telemetry_json_format_port(telemetry,\n+\t\t\t\t\tport_id, ports, &ep->pp.metric_ids[0],\n+\t\t\t\t\tnum_metric_ids);\n+\t\t\tif (ret < 0) {\n+\t\t\t\tTELEMETRY_LOG_ERR(\"Format port in JSON failed\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t}\n+\t} else if (ep->type == GLOBAL_STATS) {\n+\t\t/* Request Global Metrics */\n+\t\tret = rte_telemetry_json_format_port(telemetry,\n+\t\t\t\tRTE_METRICS_GLOBAL,\n+\t\t\t\tports, &ep->gp.metric_ids[0],\n+\t\t\t\tep->gp.num_metric_ids);\n \t\tif (ret < 0) {\n-\t\t\tTELEMETRY_LOG_ERR(\"Format port in JSON failed\");\n+\t\t\tTELEMETRY_LOG_ERR(\" Request Global Metrics Failed\");\n \t\t\treturn -1;\n \t\t}\n+\t} else {\n+\t\tTELEMETRY_LOG_ERR(\" Invalid metrics type in encode params\");\n+\t\tgoto einval_fail;\n \t}\n \n \troot = json_object();\n@@ -520,8 +544,8 @@ rte_telemetry_encode_json_format(struct telemetry_impl *telemetry,\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+rte_telemetry_send_global_stats_values(struct telemetry_encode_param *ep,\n+\tstruct telemetry_impl *telemetry)\n {\n \tint ret, i;\n \tchar *json_buffer = NULL;\n@@ -531,42 +555,77 @@ rte_telemetry_send_ports_stats_values(uint32_t *metric_ids, int num_metric_ids,\n \t\treturn -1;\n \t}\n \n-\tif (metric_ids == NULL) {\n-\t\tTELEMETRY_LOG_ERR(\"Invalid metric_ids array\");\n+\tif (ep->gp.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 (num_metric_ids < 0) {\n-\t\tTELEMETRY_LOG_ERR(\"Invalid num_metric_ids, must be positive\");\n+\tret = rte_telemetry_encode_json_format(telemetry, ep,\n+\t\t&json_buffer);\n+\tif (ret < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"JSON encode function failed\");\n+\t\treturn -1;\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+int32_t\n+rte_telemetry_send_ports_stats_values(struct telemetry_encode_param *ep,\n+\tstruct telemetry_impl *telemetry)\n+{\n+\tint ret, i;\n+\tchar *json_buffer = NULL;\n+\tuint32_t port_id;\n+\n+\tif (telemetry == NULL) {\n+\t\tTELEMETRY_LOG_ERR(\"Invalid telemetry argument\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (ep == NULL) {\n+\t\tTELEMETRY_LOG_ERR(\"Invalid encode param argument\");\n \t\tgoto einval_fail;\n \t}\n \n-\tif (port_ids == NULL) {\n-\t\tTELEMETRY_LOG_ERR(\"Invalid port_ids array\");\n+\tif (ep->pp.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 (num_port_ids < 0) {\n+\tif (ep->pp.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+\tfor (i = 0; i < ep->pp.num_port_ids; i++) {\n+\t\tport_id = ep->pp.port_ids[i];\n+\t\tif (!rte_eth_dev_is_valid_port(port_id)) {\n+\t\t\tTELEMETRY_LOG_ERR(\"Port: %d invalid\", port_id);\n \t\t\tgoto einval_fail;\n \t\t}\n \n \t\tret = rte_telemetry_update_metrics_ethdev(telemetry,\n-\t\t\t\tport_ids[i], telemetry->reg_index[i]);\n+\t\t\t\tport_id, telemetry->reg_index[i]);\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_encode_json_format(telemetry, port_ids,\n-\t\tnum_port_ids, metric_ids, num_metric_ids, &json_buffer);\n+\tret = rte_telemetry_encode_json_format(telemetry, ep, &json_buffer);\n \tif (ret < 0) {\n \t\tTELEMETRY_LOG_ERR(\"JSON encode function failed\");\n \t\treturn -1;\ndiff --git a/lib/librte_telemetry/rte_telemetry_internal.h b/lib/librte_telemetry/rte_telemetry_internal.h\nindex c298c3919..6a91d0c44 100644\n--- a/lib/librte_telemetry/rte_telemetry_internal.h\n+++ b/lib/librte_telemetry/rte_telemetry_internal.h\n@@ -24,6 +24,8 @@ extern int telemetry_log_level;\n #define TELEMETRY_LOG_INFO(fmt, args...) \\\n \tTELEMETRY_LOG(INFO, fmt, ## args)\n \n+#define MAX_METRICS 256\n+\n typedef struct telemetry_client {\n \tchar *file_path;\n \tint fd;\n@@ -48,6 +50,28 @@ enum rte_telemetry_parser_actions {\n \tACTION_DELETE = 2\n };\n \n+enum rte_telemetry_stats_type {\n+\tPORT_STATS = 0,\n+\tGLOBAL_STATS = 1\n+};\n+\n+/* @internal */\n+struct telemetry_encode_param {\n+\tenum rte_telemetry_stats_type type;\n+\tunion {\n+\t\tstruct port_param {\n+\t\t\tuint32_t num_metric_ids;\n+\t\t\tuint32_t metric_ids[MAX_METRICS];\n+\t\t\tuint32_t num_port_ids;\n+\t\t\tuint32_t port_ids[RTE_MAX_ETHPORTS];\n+\t\t} pp;\n+\t\tstruct global_param {\n+\t\t\tuint32_t num_metric_ids;\n+\t\t\tuint32_t metric_ids[MAX_METRICS];\n+\t\t} gp;\n+\t};\n+};\n+\n int32_t\n rte_telemetry_parse_client_message(struct telemetry_impl *telemetry, char *buf);\n \n@@ -72,10 +96,13 @@ 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+rte_telemetry_send_ports_stats_values(struct telemetry_encode_param *ep,\n+\tstruct telemetry_impl *telemetry);\n \n int32_t\n rte_telemetry_socket_messaging_testing(int index, int socket);\n \n+int32_t\n+rte_telemetry_send_global_stats_values(struct telemetry_encode_param *ep,\n+\tstruct telemetry_impl *telemetry);\n #endif\ndiff --git a/lib/librte_telemetry/rte_telemetry_parser.c b/lib/librte_telemetry/rte_telemetry_parser.c\nindex 9bc16eef4..3a2fa0b49 100644\n--- a/lib/librte_telemetry/rte_telemetry_parser.c\n+++ b/lib/librte_telemetry/rte_telemetry_parser.c\n@@ -258,8 +258,9 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry,\n \tint ret, num_metrics, i, p;\n \tstruct rte_metric_value *values;\n \tuint64_t num_port_ids = 0;\n-\tuint32_t port_ids[RTE_MAX_ETHPORTS];\n+\tstruct telemetry_encode_param ep;\n \n+\tmemset(&ep, 0, sizeof(ep));\n \tif (telemetry == NULL) {\n \t\tTELEMETRY_LOG_ERR(\"Invalid telemetry argument\");\n \t\treturn -1;\n@@ -310,10 +311,8 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry,\n \t\treturn -1;\n \t}\n \n-\tuint32_t stat_ids[num_metrics];\n-\n \tRTE_ETH_FOREACH_DEV(p) {\n-\t\tport_ids[num_port_ids] = p;\n+\t\tep.pp.port_ids[num_port_ids] = p;\n \t\tnum_port_ids++;\n \t}\n \n@@ -327,16 +326,22 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry,\n \t\tgoto fail;\n \t}\n \n-\tret = rte_metrics_get_values(port_ids[0], values, num_metrics);\n+\tret = rte_metrics_get_values(ep.pp.port_ids[0], values, num_metrics);\n \tif (ret < 0) {\n \t\tTELEMETRY_LOG_ERR(\"Could not get stat values\");\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\tgoto fail;\n \t}\n \tfor (i = 0; i < num_metrics; i++)\n-\t\tstat_ids[i] = values[i].key;\n+\t\tep.pp.metric_ids[i] = values[i].key;\n+\n+\tep.pp.num_port_ids = num_port_ids;\n+\tep.pp.num_metric_ids = num_metrics;\n+\tep.type = PORT_STATS;\n \n-\tret = rte_telemetry_send_ports_stats_values(stat_ids, num_metrics,\n-\t\tport_ids, num_port_ids, telemetry);\n+\tret = rte_telemetry_send_ports_stats_values(&ep, telemetry);\n \tif (ret < 0) {\n \t\tTELEMETRY_LOG_ERR(\"Sending ports stats values failed\");\n \t\tgoto fail;\n@@ -349,6 +354,93 @@ rte_telemetry_command_ports_all_stat_values(struct telemetry_impl *telemetry,\n \treturn -1;\n }\n \n+int32_t\n+rte_telemetry_command_global_stat_values(struct telemetry_impl *telemetry,\n+\t int action, json_t *data)\n+{\n+\tint ret, num_metrics, i, p;\n+\tstruct rte_metric_value *values;\n+\tstruct telemetry_encode_param ep;\n+\n+\tmemset(&ep, 0, sizeof(ep));\n+\tif (telemetry == NULL) {\n+\t\tTELEMETRY_LOG_ERR(\"Invalid telemetry argument\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (action != ACTION_GET) {\n+\t\tTELEMETRY_LOG_WARN(\"Invalid action for this command\");\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+\tif (json_is_object(data)) {\n+\t\tTELEMETRY_LOG_WARN(\"Invalid data provided for this command\");\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_metrics = rte_metrics_get_values(RTE_METRICS_GLOBAL, NULL, 0);\n+\tif (num_metrics < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"Cannot get metrics count\");\n+\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+\n+\t\treturn -1;\n+\t} else if (num_metrics == 0) {\n+\t\tTELEMETRY_LOG_ERR(\"No metrics to display (none have been registered)\");\n+\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+\n+\t\treturn -1;\n+\t}\n+\n+\tvalues = malloc(sizeof(struct rte_metric_value) * num_metrics);\n+\tif (values == NULL) {\n+\t\tTELEMETRY_LOG_ERR(\"Cannot allocate memory\");\n+\t\tret = rte_telemetry_send_error_response(telemetry,\n+\t\t\t -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_metrics_get_values(RTE_METRICS_GLOBAL, values, num_metrics);\n+\tif (ret < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"Could not get stat values\");\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\tgoto fail;\n+\t}\n+\tfor (i = 0; i < num_metrics; i++)\n+\t\tep.gp.metric_ids[i] = values[i].key;\n+\n+\tep.gp.num_metric_ids = num_metrics;\n+\tep.type = GLOBAL_STATS;\n+\n+\tret = rte_telemetry_send_global_stats_values(&ep, telemetry);\n+\tif (ret < 0) {\n+\t\tTELEMETRY_LOG_ERR(\"Sending global stats values failed\");\n+\t\tgoto fail;\n+\t}\n+\n+\tfree(values);\n+\treturn 0;\n+\n+fail:\n+\tfree(values);\n+\treturn -1;\n+}\n+\n int32_t\n rte_telemetry_command_ports_stats_values_by_name(struct telemetry_impl\n \t*telemetry, int action, json_t *data)\n@@ -356,13 +448,15 @@ rte_telemetry_command_ports_stats_values_by_name(struct telemetry_impl\n \tint ret;\n \tjson_t *port_ids_json = json_object_get(data, \"ports\");\n \tjson_t *stat_names_json = json_object_get(data, \"stats\");\n-\tuint64_t num_port_ids = json_array_size(port_ids_json);\n \tuint64_t num_stat_names = json_array_size(stat_names_json);\n \tconst char *stat_names[num_stat_names];\n-\tuint32_t port_ids[num_port_ids], stat_ids[num_stat_names];\n+\tstruct telemetry_encode_param ep;\n \tsize_t index;\n \tjson_t *value;\n \n+\tep.pp.num_port_ids = json_array_size(port_ids_json);\n+\tep.pp.num_metric_ids = num_stat_names;\n+\tmemset(&ep, 0, sizeof(ep));\n \tif (telemetry == NULL) {\n \t\tTELEMETRY_LOG_ERR(\"Invalid telemetry argument\");\n \t\treturn -1;\n@@ -402,8 +496,8 @@ rte_telemetry_command_ports_stats_values_by_name(struct telemetry_impl\n \t\t\t\tTELEMETRY_LOG_ERR(\"Could not send error\");\n \t\t\treturn -1;\n \t\t}\n-\t\tport_ids[index] = json_integer_value(value);\n-\t\tret = rte_telemetry_is_port_active(port_ids[index]);\n+\t\tep.pp.port_ids[index] = json_integer_value(value);\n+\t\tret = rte_telemetry_is_port_active(ep.pp.port_ids[index]);\n \t\tif (ret < 1) {\n \t\t\tret = rte_telemetry_send_error_response(telemetry,\n \t\t\t\t-EINVAL);\n@@ -427,15 +521,15 @@ rte_telemetry_command_ports_stats_values_by_name(struct telemetry_impl\n \t\tstat_names[index] = json_string_value(value);\n \t}\n \n-\tret = rte_telemetry_stat_names_to_ids(telemetry, stat_names, stat_ids,\n-\t\tnum_stat_names);\n+\tret = rte_telemetry_stat_names_to_ids(telemetry, stat_names,\n+\t\tep.pp.metric_ids, num_stat_names);\n \tif (ret < 0) {\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+\tep.type = PORT_STATS;\n+\tret = rte_telemetry_send_ports_stats_values(&ep, telemetry);\n \tif (ret < 0) {\n \t\tTELEMETRY_LOG_ERR(\"Sending ports stats values failed\");\n \t\treturn -1;\n@@ -480,6 +574,10 @@ rte_telemetry_parse_command(struct telemetry_impl *telemetry, int action,\n \t\t{\n \t\t\t.text = \"ports_all_stat_values\",\n \t\t\t.fn = &rte_telemetry_command_ports_all_stat_values\n+\t\t},\n+\t\t{\n+\t\t\t.text = \"global_stat_values\",\n+\t\t\t.fn = &rte_telemetry_command_global_stat_values\n \t\t}\n \t};\n \ndiff --git a/usertools/dpdk-telemetry-client.py b/usertools/dpdk-telemetry-client.py\nindex ce0c7a905..572ff56bb 100755\n--- a/usertools/dpdk-telemetry-client.py\n+++ b/usertools/dpdk-telemetry-client.py\n@@ -12,6 +12,7 @@\n METRICS_REQ = \"{\\\"action\\\":0,\\\"command\\\":\\\"ports_all_stat_values\\\",\\\"data\\\":null}\"\n API_REG = \"{\\\"action\\\":1,\\\"command\\\":\\\"clients\\\",\\\"data\\\":{\\\"client_path\\\":\\\"\"\n API_UNREG = \"{\\\"action\\\":2,\\\"command\\\":\\\"clients\\\",\\\"data\\\":{\\\"client_path\\\":\\\"\"\n+GLOBAL_METRICS_REQ = \"{\\\"action\\\":0,\\\"command\\\":\\\"global_stat_values\\\",\\\"data\\\":null}\"\n DEFAULT_FP = \"/var/run/dpdk/default_client\"\n \n class Socket:\n@@ -79,12 +80,18 @@ def repeatedlyRequestMetrics(self, sleep_time): # Recursively requests metrics f\n             self.requestMetrics()\n             time.sleep(sleep_time)\n \n+    def requestGlobalMetrics(self): #Requests global metrics for given client\n+        self.socket.client_fd.send(GLOBAL_METRICS_REQ)\n+        data = self.socket.client_fd.recv(BUFFER_SIZE)\n+        print \"\\nResponse: \\n\", str(data)\n+\n     def interactiveMenu(self, sleep_time): # Creates Interactive menu within the script\n-        while self.choice != 3:\n+        while self.choice != 4:\n             print(\"\\nOptions Menu\")\n             print(\"[1] Send for Metrics for all ports\")\n             print(\"[2] Send for Metrics for all ports recursively\")\n-            print(\"[3] Unregister client\")\n+            print(\"[3] Send for global Metrics\")\n+            print(\"[4] Unregister client\")\n \n             try:\n                 self.choice = int(input(\"\\n:\"))\n@@ -95,6 +102,8 @@ def interactiveMenu(self, sleep_time): # Creates Interactive menu within the scr\n                 elif self.choice == 2:\n                     self.repeatedlyRequestMetrics(sleep_time)\n                 elif self.choice == 3:\n+                    self.requestGlobalMetrics()\n+                elif self.choice == 4:\n                     self.unregister()\n                     self.unregistered = 1\n                 else:\n",
    "prefixes": []
}