get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 53214,
    "url": "http://patches.dpdk.org/api/patches/53214/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190502121135.18775-2-barbette@kth.se/",
    "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": "<20190502121135.18775-2-barbette@kth.se>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190502121135.18775-2-barbette@kth.se",
    "date": "2019-05-02T12:11:33",
    "name": "[v4,1/3] rte_ethdev: Add API function to read dev clock",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "9f0dadbc6670d2e5a727ac176094b624b47627fe",
    "submitter": {
        "id": 1155,
        "url": "http://patches.dpdk.org/api/people/1155/?format=api",
        "name": "Tom Barbette",
        "email": "barbette@kth.se"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190502121135.18775-2-barbette@kth.se/mbox/",
    "series": [
        {
            "id": 4541,
            "url": "http://patches.dpdk.org/api/series/4541/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4541",
            "date": "2019-05-02T12:11:32",
            "name": "Add rte_eth_read_clock API",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/4541/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/53214/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/53214/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 133245589;\n\tThu,  2 May 2019 14:11:46 +0200 (CEST)",
            "from smtp-4.sys.kth.se (smtp-4.sys.kth.se [130.237.48.193])\n\tby dpdk.org (Postfix) with ESMTP id BB7044C95\n\tfor <dev@dpdk.org>; Thu,  2 May 2019 14:11:42 +0200 (CEST)",
            "from smtp-4.sys.kth.se (localhost.localdomain [127.0.0.1])\n\tby smtp-4.sys.kth.se (Postfix) with ESMTP id 805BB67ED;\n\tThu,  2 May 2019 14:11:42 +0200 (CEST)",
            "from smtp-4.sys.kth.se ([127.0.0.1])\n\tby smtp-4.sys.kth.se (smtp-4.sys.kth.se [127.0.0.1]) (amavisd-new,\n\tport 10024)\n\twith LMTP id 2NbeyNu5TKfv; Thu,  2 May 2019 14:11:41 +0200 (CEST)",
            "from nslrack11.ssvl.kth.se (nslrack11.ssvl.kth.se [192.16.125.171])\n\tby smtp-4.sys.kth.se (Postfix) with ESMTPSA id 5E2EB67D2;\n\tThu,  2 May 2019 14:11:41 +0200 (CEST)"
        ],
        "X-Virus-Scanned": "by amavisd-new at kth.se",
        "X-KTH-Auth": "barbette [192.16.125.171]",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=kth.se; s=default;\n\tt=1556799101; bh=yK8XYrfWL2jThYtdEePTV8LxhmKfvhIEA2VQEyMJ9bg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References;\n\tb=SB0rgp3P/Jqieuc4xTjpqb1mfnyo/ED+M2jkdQXBlt5T2Z8i9r43D86Y2aR2U6dd1\n\tXpB4UAE1uRfACKUYHt5DtuVc2JoZEeBNYzbj6xBdaM03OSrBiVcug3zu2rZ6ZUP6T5\n\tlwkceCubBcA/qPC9CHUx2UtTko5keAsg7Jhucg+I=",
        "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\tolivier.matz@6wind.com, Tom Barbette <barbette@kth.se>",
        "Date": "Thu,  2 May 2019 14:11:33 +0200",
        "Message-Id": "<20190502121135.18775-2-barbette@kth.se>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20190502121135.18775-1-barbette@kth.se>",
        "References": "<20190502121135.18775-1-barbette@kth.se>",
        "Subject": "[dpdk-dev] [PATCH v4 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 device.\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           | 12 ++++++\n lib/librte_ethdev/rte_ethdev.h           | 47 ++++++++++++++++++++++++\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, 69 insertions(+)",
    "diff": "diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst\nindex c5bf32222..025b7f812 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+* **[related] 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 d7cfa3d53..9507a985f 100644\n--- a/lib/librte_ethdev/rte_ethdev.c\n+++ b/lib/librte_ethdev/rte_ethdev.c\n@@ -4170,6 +4170,18 @@ 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 *clock)\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, clock));\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 b8d19c69f..7dd1f8ae7 100644\n--- a/lib/librte_ethdev/rte_ethdev.h\n+++ b/lib/librte_ethdev/rte_ethdev.h\n@@ -3793,6 +3793,53 @@ 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. It is\n+ * a raw amount of ticks, with no given time reference.\n+ * The value returned here is from the same clock than the one\n+ * filling timestamp field of Rx packets when using hardware timestamp\n+ * offload. Therefore it can be used to compute a precise conversion of\n+ * 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\n+rte_eth_read_clock(uint16_t port_id, uint64_t *clock);\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 afcd25599..df9141825 100644\n--- a/lib/librte_ethdev/rte_ethdev_version.map\n+++ b/lib/librte_ethdev/rte_ethdev_version.map\n@@ -253,6 +253,7 @@ EXPERIMENTAL {\n \trte_eth_dev_rx_intr_ctl_q_get_fd;\n \trte_eth_find_next_of;\n \trte_eth_find_next_sibling;\n+\trte_eth_read_clock;\n \trte_eth_switch_domain_alloc;\n \trte_eth_switch_domain_free;\n \trte_flow_conv;\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 68415af02..e530a96c5 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -668,6 +668,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": [
        "v4",
        "1/3"
    ]
}