get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 110219,
    "url": "https://patches.dpdk.org/api/patches/110219/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20220425053446.921528-2-robinx.zhang@intel.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": "<20220425053446.921528-2-robinx.zhang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220425053446.921528-2-robinx.zhang@intel.com",
    "date": "2022-04-25T05:34:42",
    "name": "[v4,1/5] ethdev: add telemetry command for module EEPROM",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5f6e27004066690db1864aa330b0daf4f5e3c755",
    "submitter": {
        "id": 2004,
        "url": "https://patches.dpdk.org/api/people/2004/?format=api",
        "name": "Robin Zhang",
        "email": "robinx.zhang@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20220425053446.921528-2-robinx.zhang@intel.com/mbox/",
    "series": [
        {
            "id": 22654,
            "url": "https://patches.dpdk.org/api/series/22654/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=22654",
            "date": "2022-04-25T05:34:41",
            "name": "add telemetry command for show module EEPROM",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/22654/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/110219/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/110219/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 4118EA00BE;\n\tMon, 25 Apr 2022 07:39:55 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id B4F514280D;\n\tMon, 25 Apr 2022 07:39:34 +0200 (CEST)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n by mails.dpdk.org (Postfix) with ESMTP id DDF1C427FB\n for <dev@dpdk.org>; Mon, 25 Apr 2022 07:39:31 +0200 (CEST)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 24 Apr 2022 22:39:31 -0700",
            "from intel-cd-odc-robin.cd.intel.com ([10.240.178.191])\n by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 24 Apr 2022 22:39:28 -0700"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1650865172; x=1682401172;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=iWxKxOCUFPq5QpJDXLi/ASRM9REeWSh3wAZtT4BtOqY=;\n b=mjVpsj/4im0DCVG/x69XexZ+jyvldxx8PihCtq4vElYRGsibPi0aLB+m\n EdiCvg9kdSgKxASUlH8f7w143/vry5amgOctp0PIpKe5FoEvm/Nj2yx7s\n h0mpJmYpvNjJP5I/Hu6VGUOHOeNjYyFq+HqsCtMAV7Fk6J+snTuhrKTBN\n Wy4qBftU9TwPjFXWQM3tnz+YVgRSAwGWLZry65P5WnhlKQeGVbYMYLb8y\n GwlevuMliWmb5Gst1PtKmhj+NW7CkO5/0V2OXxdbZiR8eu9Tmaiex9pTo\n 6vhnHvWQW/Cgy8Wye95hy0om9QRJ3fjgIOyH0A2Frjjojqwb5O/KbH364 g==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6400,9594,10327\"; a=\"247070499\"",
            "E=Sophos;i=\"5.90,287,1643702400\"; d=\"scan'208\";a=\"247070499\"",
            "E=Sophos;i=\"5.90,287,1643702400\"; d=\"scan'208\";a=\"579087224\""
        ],
        "From": "Robin Zhang <robinx.zhang@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "qiming.yang@intel.com, qi.z.zhang@intel.com, stevex.yang@intel.com,\n thomas@monjalon.net, andrew.rybchenko@oktetlabs.ru,\n bruce.richardson@intel.com, david.marchand@redhat.com,\n Robin Zhang <robinx.zhang@intel.com>",
        "Subject": "[PATCH v4 1/5] ethdev: add telemetry command for module EEPROM",
        "Date": "Mon, 25 Apr 2022 05:34:42 +0000",
        "Message-Id": "<20220425053446.921528-2-robinx.zhang@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220425053446.921528-1-robinx.zhang@intel.com>",
        "References": "<20220215101853.919735-1-robinx.zhang@intel.com>\n <20220425053446.921528-1-robinx.zhang@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": "Add a new telemetry command /ethdev/module_eeprom to dump the module\nEEPROM of each port. The format of module EEPROM information follows\nthe SFF(Small Form Factor) Committee specifications.\n\nCurrent the format support SFP(Small Formfactor Pluggable)/SFP+/\nQSFP+(Quad Small Formfactor Pluggable)/QSFP28 with specs SFF-8079/\nSFF-8472/SFF-8024/SFF-8636.\n\nSigned-off-by: Robin Zhang <robinx.zhang@intel.com>\n---\n lib/ethdev/ethdev_sff_telemetry.c | 129 ++++++++++++++++++++++++++++++\n lib/ethdev/ethdev_sff_telemetry.h |  39 +++++++++\n lib/ethdev/meson.build            |   1 +\n lib/ethdev/rte_ethdev.c           |   3 +\n 4 files changed, 172 insertions(+)\n create mode 100644 lib/ethdev/ethdev_sff_telemetry.c\n create mode 100644 lib/ethdev/ethdev_sff_telemetry.h",
    "diff": "diff --git a/lib/ethdev/ethdev_sff_telemetry.c b/lib/ethdev/ethdev_sff_telemetry.c\nnew file mode 100644\nindex 0000000000..507571d995\n--- /dev/null\n+++ b/lib/ethdev/ethdev_sff_telemetry.c\n@@ -0,0 +1,129 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 Intel Corporation\n+ */\n+\n+#include <errno.h>\n+\n+#include <rte_ethdev.h>\n+#include <rte_common.h>\n+#include \"ethdev_sff_telemetry.h\"\n+\n+static void\n+sff_port_module_eeprom_display(uint16_t port_id, struct sff_item *items)\n+{\n+\tstruct rte_eth_dev_module_info minfo;\n+\tstruct rte_dev_eeprom_info einfo;\n+\tint ret;\n+\n+\tret = rte_eth_dev_get_module_info(port_id, &minfo);\n+\tif (ret != 0) {\n+\t\tswitch (ret) {\n+\t\tcase -ENODEV:\n+\t\t\tRTE_ETHDEV_LOG(ERR, \"port index %d invalid\\n\", port_id);\n+\t\t\tbreak;\n+\t\tcase -ENOTSUP:\n+\t\t\tRTE_ETHDEV_LOG(ERR, \"operation not supported by device\\n\");\n+\t\t\tbreak;\n+\t\tcase -EIO:\n+\t\t\tRTE_ETHDEV_LOG(ERR, \"device is removed\\n\");\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tRTE_ETHDEV_LOG(ERR, \"Unable to get port %d EEPROM module info\\n\", ret);\n+\t\t\tbreak;\n+\t\t}\n+\t\treturn;\n+\t\t}\n+\n+\teinfo.offset = 0;\n+\teinfo.length = minfo.eeprom_len;\n+\teinfo.data = calloc(1, minfo.eeprom_len);\n+\tif (einfo.data == NULL) {\n+\t\tRTE_ETHDEV_LOG(ERR, \"Allocation of port %u eeprom data failed\\n\", port_id);\n+\t\treturn;\n+\t}\n+\n+\tret = rte_eth_dev_get_module_eeprom(port_id, &einfo);\n+\tif (ret != 0) {\n+\t\tswitch (ret) {\n+\t\tcase -ENODEV:\n+\t\t\tRTE_ETHDEV_LOG(ERR, \"port index %d invalid\\n\", port_id);\n+\t\t\tbreak;\n+\t\tcase -ENOTSUP:\n+\t\t\tRTE_ETHDEV_LOG(ERR, \"operation not supported by device\\n\");\n+\t\t\tbreak;\n+\t\tcase -EIO:\n+\t\t\tRTE_ETHDEV_LOG(ERR, \"device is removed\\n\");\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tRTE_ETHDEV_LOG(ERR, \"Unable to get port %d module EEPROM\\n\", ret);\n+\t\t\tbreak;\n+\t\t}\n+\t\tfree(einfo.data);\n+\t\treturn;\n+\t}\n+\n+\tswitch (minfo.type) {\n+\t/* parsing module EEPROM data base on different module type */\n+\tdefault:\n+\t\tRTE_ETHDEV_LOG(NOTICE, \"Unsupported module type: %u\\n\", minfo.type);\n+\t\tbreak;\n+\t}\n+\n+\tfree(einfo.data);\n+}\n+\n+void\n+add_item_string(struct sff_item *items, const char *name_str, const char *value_str)\n+{\n+\t/* append different values for same keys */\n+\tif (sff_item_count > 0 &&\n+\t    (strcmp(items[sff_item_count - 1].name, name_str) == 0)) {\n+\t\tstrlcat(items[sff_item_count - 1].value, \"; \", SFF_ITEM_VALUE_SIZE);\n+\t\tstrlcat(items[sff_item_count - 1].value, value_str, SFF_ITEM_VALUE_SIZE);\n+\t\treturn;\n+\t}\n+\n+\tsnprintf(items[sff_item_count].name, SFF_ITEM_NAME_SIZE, \"%s\", name_str);\n+\tsnprintf(items[sff_item_count].value, SFF_ITEM_VALUE_SIZE, \"%s\", value_str);\n+\tsff_item_count++;\n+}\n+\n+int\n+eth_dev_handle_port_module_eeprom(const char *cmd __rte_unused, const char *params,\n+\t\t\t\t  struct rte_tel_data *d)\n+{\n+\tchar *end_param;\n+\tint port_id, i;\n+\tstruct sff_item *items;\n+\tsff_item_count = 0;\n+\n+\tif (params == NULL || strlen(params) == 0 || !isdigit(*params))\n+\t\treturn -1;\n+\n+\terrno = 0;\n+\tport_id = strtoul(params, &end_param, 0);\n+\n+\tif (errno != 0) {\n+\t\tRTE_ETHDEV_LOG(ERR, \"Invalid argument\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (*end_param != '\\0')\n+\t\tRTE_ETHDEV_LOG(NOTICE,\n+\t\t\t\"Extra parameters passed to ethdev telemetry command, ignoring\");\n+\n+\titems = calloc(1, sizeof(struct sff_item) * SFF_ITEM_MAX_COUNT);\n+\tif (items == NULL) {\n+\t\tRTE_ETHDEV_LOG(ERR, \"Error allocating memory of items\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tsff_port_module_eeprom_display(port_id, items);\n+\n+\trte_tel_data_start_dict(d);\n+\tfor (i = 0; i < sff_item_count; i++)\n+\t\trte_tel_data_add_dict_string(d, items[i].name, items[i].value);\n+\n+\tfree(items);\n+\treturn 0;\n+}\ndiff --git a/lib/ethdev/ethdev_sff_telemetry.h b/lib/ethdev/ethdev_sff_telemetry.h\nnew file mode 100644\nindex 0000000000..0134fe2b5f\n--- /dev/null\n+++ b/lib/ethdev/ethdev_sff_telemetry.h\n@@ -0,0 +1,39 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 Intel Corporation\n+ */\n+\n+#ifndef _ETHDEV_SFF_TELEMETRY_H_\n+#define _ETHDEV_SFF_TELEMETRY_H_\n+\n+#include <rte_telemetry.h>\n+\n+#define ARRAY_SIZE(arr) RTE_DIM(arr)\n+\n+#define SFF_ITEM_NAME_SIZE 64\n+#define SFF_ITEM_VALUE_SIZE 256\n+#define SFF_ITEM_MAX_COUNT 256\n+#define SFF_ITEM_VAL_COMPOSE_SIZE 64\n+\n+struct sff_item {\n+\tchar name[SFF_ITEM_NAME_SIZE];    /* The item name. */\n+\tchar value[SFF_ITEM_VALUE_SIZE];  /* The item value. */\n+};\n+\n+uint16_t sff_item_count;\n+\n+/* SFF-8079 Optics diagnostics */\n+void sff_8079_show_all(const uint8_t *data, struct sff_item *items);\n+\n+/* SFF-8472 Optics diagnostics */\n+void sff_8472_show_all(const uint8_t *data, struct sff_item *items);\n+\n+/* SFF-8636 Optics diagnostics */\n+void sff_8636_show_all(const uint8_t *data, uint32_t eeprom_len, struct sff_item *items);\n+\n+int eth_dev_handle_port_module_eeprom(const char *cmd __rte_unused,\n+\t\t\t\t      const char *params,\n+\t\t\t\t      struct rte_tel_data *d);\n+\n+void add_item_string(struct sff_item *items, const char *name_str, const char *value_str);\n+\n+#endif /* _ETHDEV_SFF_TELEMETRY_H_ */\ndiff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build\nindex a094585bf7..49c77acb3f 100644\n--- a/lib/ethdev/meson.build\n+++ b/lib/ethdev/meson.build\n@@ -11,6 +11,7 @@ sources = files(\n         'rte_flow.c',\n         'rte_mtr.c',\n         'rte_tm.c',\n+        'ethdev_sff_telemetry.c',\n )\n \n headers = files(\ndiff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c\nindex 29a3d80466..2b87df1b32 100644\n--- a/lib/ethdev/rte_ethdev.c\n+++ b/lib/ethdev/rte_ethdev.c\n@@ -39,6 +39,7 @@\n #include \"ethdev_driver.h\"\n #include \"ethdev_profile.h\"\n #include \"ethdev_private.h\"\n+#include \"ethdev_sff_telemetry.h\"\n \n struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];\n \n@@ -5876,4 +5877,6 @@ RTE_INIT(ethdev_init_telemetry)\n \t\t\t\"Returns the link status for a port. Parameters: int port_id\");\n \trte_telemetry_register_cmd(\"/ethdev/info\", eth_dev_handle_port_info,\n \t\t\t\"Returns the device info for a port. Parameters: int port_id\");\n+\trte_telemetry_register_cmd(\"/ethdev/module_eeprom\", eth_dev_handle_port_module_eeprom,\n+\t\t\t\"Returns module EEPROM info with SFF specs. Parameters: int port_id\");\n }\n",
    "prefixes": [
        "v4",
        "1/5"
    ]
}