get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 49120,
    "url": "https://patches.dpdk.org/api/patches/49120/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20181219134934.24693-2-barbette@kth.se/",
    "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": "<20181219134934.24693-2-barbette@kth.se>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181219134934.24693-2-barbette@kth.se",
    "date": "2018-12-19T13:49:32",
    "name": "[1/3] rte_ethdev: Add API function to read dev clock",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "845bafc1449ae32421ef5eac268e7db58d9d08f3",
    "submitter": {
        "id": 1155,
        "url": "https://patches.dpdk.org/api/people/1155/?format=api",
        "name": "Tom Barbette",
        "email": "barbette@kth.se"
    },
    "delegate": {
        "id": 319,
        "url": "https://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20181219134934.24693-2-barbette@kth.se/mbox/",
    "series": [
        {
            "id": 2870,
            "url": "https://patches.dpdk.org/api/series/2870/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=2870",
            "date": "2018-12-19T13:49:31",
            "name": "Add rte_eth_read_clock API",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/2870/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/49120/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/49120/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 EE1B71B951;\n\tWed, 19 Dec 2018 14:50:06 +0100 (CET)",
            "from smtp-3.sys.kth.se (smtp-3.sys.kth.se [130.237.48.192])\n\tby dpdk.org (Postfix) with ESMTP id 6DFED1B93A\n\tfor <dev@dpdk.org>; Wed, 19 Dec 2018 14:50:04 +0100 (CET)",
            "from smtp-3.sys.kth.se (localhost.localdomain [127.0.0.1])\n\tby smtp-3.sys.kth.se (Postfix) with ESMTP id 2CF2758C1;\n\tWed, 19 Dec 2018 14:50:04 +0100 (CET)",
            "from smtp-3.sys.kth.se ([127.0.0.1])\n\tby smtp-3.sys.kth.se (smtp-3.sys.kth.se [127.0.0.1]) (amavisd-new,\n\tport 10024)\n\twith LMTP id AY7fq_HMKz1E; Wed, 19 Dec 2018 14:50:03 +0100 (CET)",
            "from nslrack08.ssvl.kth.se (nslrack08.ssvl.kth.se [192.16.125.168])\n\tby smtp-3.sys.kth.se (Postfix) with ESMTPSA id 711F65807;\n\tWed, 19 Dec 2018 14:50:01 +0100 (CET)"
        ],
        "X-Virus-Scanned": "by amavisd-new at kth.se",
        "X-KTH-Auth": "barbette [192.16.125.168]",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=kth.se; s=default;\n\tt=1545227403; bh=6xJxUOJCnbRj+KlLitFqxP5bcjKDlUKvhA2xodgZ54w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References;\n\tb=ob7iTiLGOOCAH96VcOSWtSsBhAbKVObcPufSylKc7niVPl/MA38ZHopO7e6tJWXXN\n\tTd/+C9E/FZ2Gjyz6mfTazAh+0aLV33H3ExUj88V2C48KmWOL2SfRiozC3i6j6j8XN9\n\tnLj6BwTgl8L9HJokW4X5pn0uVo/1hxu3NDo4O+3k=",
        "X-KTH-mail-from": "barbette@kth.se",
        "From": "Tom Barbette <barbette@kth.se>",
        "To": "dev@dpdk.org",
        "Cc": "bruce.richardson@intel.com, john.mcnamara@intel.com,\n\tThomas Monjalon <thomas@monjalon.net>,\n\tFerruh Yigit <ferruh.yigit@intel.com>,\n\tAndrew Rybchenko <arybchenko@solarflare.com>,\n\tShahaf Shuler <shahafs@mellanox.com>, Yongseok Koh <yskoh@mellanox.com>, \n\tTom Barbette <barbette@kth.se>",
        "Date": "Wed, 19 Dec 2018 14:49:32 +0100",
        "Message-Id": "<20181219134934.24693-2-barbette@kth.se>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20181219134934.24693-1-barbette@kth.se>",
        "References": "<20181219134934.24693-1-barbette@kth.se>",
        "Subject": "[dpdk-dev] [PATCH 1/3] rte_ethdev: Add API function to read dev\n\tclock",
        "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": "Add rte_eth_read_clock to read the raw clock of a devide.\n\nThe main use is to get the device clock conversion co-efficients to be\nable to translate the raw clock of the timestamp field of the pkt mbuf\nto a local synced time value.\n\nThis function was missing to allow users to convert the RX timestamp field\nto real time without the complexity of the rte_timesync* facility. One can\nderivate the clock frequency by calling twice read_clock and then keep a\ncommon time base.\n\nSigned-off-by: Tom Barbette <barbette@kth.se>\n---\n doc/guides/nics/features.rst             |  1 +\n lib/librte_ethdev/rte_ethdev.c           | 13 +++++++\n lib/librte_ethdev/rte_ethdev.h           | 44 ++++++++++++++++++++++++\n lib/librte_ethdev/rte_ethdev_core.h      |  6 ++++\n lib/librte_ethdev/rte_ethdev_version.map |  1 +\n lib/librte_mbuf/rte_mbuf.h               |  2 ++\n 6 files changed, 67 insertions(+)",
    "diff": "diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst\nindex d3f904839..45484a30f 100644\n--- a/doc/guides/nics/features.rst\n+++ b/doc/guides/nics/features.rst\n@@ -602,6 +602,7 @@ Supports Timestamp.\n * **[provides] mbuf**: ``mbuf.ol_flags:PKT_RX_TIMESTAMP``.\n * **[provides] mbuf**: ``mbuf.timestamp``.\n * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa: DEV_RX_OFFLOAD_TIMESTAMP``.\n+* **[implements] eth_dev_ops**: ``read_clock``.\n \n .. _nic_features_macsec_offload:\n \ndiff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c\nindex 9d5107dce..97f92d11a 100644\n--- a/lib/librte_ethdev/rte_ethdev.c\n+++ b/lib/librte_ethdev/rte_ethdev.c\n@@ -4124,6 +4124,19 @@ rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *timestamp)\n \t\t\t\t\t\t\t\ttimestamp));\n }\n \n+int\n+rte_eth_read_clock(uint16_t port_id, uint64_t *timestamp)\n+{\n+\tstruct rte_eth_dev *dev;\n+\n+\tRTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);\n+\tdev = &rte_eth_devices[port_id];\n+\n+\tRTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->read_clock, -ENOTSUP);\n+\treturn eth_err(port_id, (*dev->dev_ops->read_clock)(dev,\n+\t\t\t\t\t\t\t\ttimestamp));\n+}\n+\n int\n rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info)\n {\ndiff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h\nindex 1960f3a2d..5a831db29 100644\n--- a/lib/librte_ethdev/rte_ethdev.h\n+++ b/lib/librte_ethdev/rte_ethdev.h\n@@ -3642,6 +3642,50 @@ int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);\n  */\n int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Read the current clock counter of an Ethernet device\n+ *\n+ * This returns the current raw clock value of an Ethernet device.\n+ * The value returned here is from the same clock than the one\n+ * filling timestamp field of RX packets. Therefore it can be used\n+ * to compute a precise conversion of the device clock to the real time.\n+ *\n+ * E.g, a simple heuristic to derivate the frequency would be:\n+ * uint64_t start, end;\n+ * rte_eth_read_clock(port, start);\n+ * rte_delay_ms(100);\n+ * rte_eth_read_clock(port, end);\n+ * double freq = (end - start) * 10;\n+ *\n+ * Compute a common reference with:\n+ * uint64_t base_time_sec = current_time();\n+ * uint64_t base_clock;\n+ * rte_eth_read_clock(port, base_clock);\n+ *\n+ * Then, convert the raw mbuf timestamp with:\n+ * base_time_sec + (double)(mbuf->timestamp - base_clock) / freq;\n+ *\n+ * This simple example will not provide a very good accuracy. One must\n+ * at least measure multiple times the frequency and do a regression.\n+ * To avoid deviation from the system time, the common reference can\n+ * be repeated from time to time. The integer division can also be\n+ * converted by a multiplication and a shift for better performance.\n+ *\n+ * @param port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param time\n+ *   Pointer to the uint64_t that holds the raw clock value.\n+ *\n+ * @return\n+ *   - 0: Success.\n+ *   - -ENODEV: The port ID is invalid.\n+ *   - -ENOTSUP: The function is not supported by the Ethernet driver.\n+ */\n+int __rte_experimental rte_eth_read_clock(uint16_t port_id, uint64_t *time);\n+\n /**\n  * Config l2 tunnel ether type of an Ethernet device for filtering specific\n  * tunnel packets by ether type.\ndiff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h\nindex 8f03f83f6..86806b3eb 100644\n--- a/lib/librte_ethdev/rte_ethdev_core.h\n+++ b/lib/librte_ethdev/rte_ethdev_core.h\n@@ -322,6 +322,10 @@ typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,\n \t\t\t\t       const struct timespec *timestamp);\n /**< @internal Function used to get time from the device clock */\n \n+typedef int (*eth_read_clock)(struct rte_eth_dev *dev,\n+\t\t\t\t      uint64_t *timestamp);\n+/**< @internal Function used to get the current value of the device clock. */\n+\n typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,\n \t\t\t\tstruct rte_dev_reg_info *info);\n /**< @internal Retrieve registers  */\n@@ -496,6 +500,8 @@ struct eth_dev_ops {\n \teth_timesync_read_time     timesync_read_time; /** Get the device clock time. */\n \teth_timesync_write_time    timesync_write_time; /** Set the device clock time. */\n \n+\teth_read_clock             read_clock;\n+\n \teth_xstats_get_by_id_t     xstats_get_by_id;\n \t/**< Get extended device statistic values by ID. */\n \teth_xstats_get_names_by_id_t xstats_get_names_by_id;\ndiff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map\nindex 92ac3de25..12d6c3c1d 100644\n--- a/lib/librte_ethdev/rte_ethdev_version.map\n+++ b/lib/librte_ethdev/rte_ethdev_version.map\n@@ -249,6 +249,7 @@ EXPERIMENTAL {\n \trte_eth_switch_domain_free;\n \trte_flow_conv;\n \trte_flow_expand_rss;\n+\trte_eth_read_clock;\n \trte_mtr_capabilities_get;\n \trte_mtr_create;\n \trte_mtr_destroy;\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 3dbc6695e..4ceefa913 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -605,6 +605,8 @@ struct rte_mbuf {\n \n \t/** Valid if PKT_RX_TIMESTAMP is set. The unit and time reference\n \t * are not normalized but are always the same for a given port.\n+\t * Some devices allow to query rte_eth_read_clock that will return the\n+\t * current device timestamp.\n \t */\n \tuint64_t timestamp;\n \n",
    "prefixes": [
        "1/3"
    ]
}