get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 53216,
    "url": "http://patches.dpdk.org/api/patches/53216/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190502121135.18775-4-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-4-barbette@kth.se>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190502121135.18775-4-barbette@kth.se",
    "date": "2019-05-02T12:11:35",
    "name": "[v4,3/3] rxtx_callbacks: Add support for HW timestamp",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "c7e545aaaa26bdf84ac293d5b2fd565d3ec0b047",
    "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-4-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/53216/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/53216/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 C2BBF5B20;\n\tThu,  2 May 2019 14:11:49 +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 4D6594D27\n\tfor <dev@dpdk.org>; Thu,  2 May 2019 14:11:44 +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 131112934;\n\tThu,  2 May 2019 14:11:44 +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 HfIe_kWf9mPD; Thu,  2 May 2019 14:11:42 +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 699176792;\n\tThu,  2 May 2019 14:11:42 +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=1556799102; bh=TKlcexl5Os+9wK6EIlhddgdDC0JHPtDvTN2nRrnZaqI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References;\n\tb=R0HDiiThw5y3VVfZCzOs5CFN2ABwpySdCUM/rK1UKhvpZeULrxetLFs9ot73/7Zc8\n\tuM9wwdsaA6DG0sznB2GVHAD2AG5wJtba91eHzx0/tFQqzgcMhZ+hTEteSDyTCnIN72\n\t43p08nUyTmsn5q1pGrxYmHEQffvDuAMGjbimSFDA=",
        "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:35 +0200",
        "Message-Id": "<20190502121135.18775-4-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 3/3] rxtx_callbacks: Add support for HW\n\ttimestamp",
        "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": "Use rxtx callback to demonstrate a way to use rte_eth_read_clock to\nconvert the hardware timestamps to an amount of cycles.\n\nThis allows to get the amount of time the packet spent since its entry\nin the device. While the regular latency only shows the latency from\nwhen it entered the software stack.\n\nSigned-off-by: Tom Barbette <barbette@kth.se>\n---\n doc/guides/sample_app_ug/rxtx_callbacks.rst |  9 ++-\n examples/rxtx_callbacks/Makefile            |  3 +\n examples/rxtx_callbacks/main.c              | 87 ++++++++++++++++++++-\n examples/rxtx_callbacks/meson.build         |  3 +\n 4 files changed, 97 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/doc/guides/sample_app_ug/rxtx_callbacks.rst b/doc/guides/sample_app_ug/rxtx_callbacks.rst\nindex 81463d28d..6b0c64461 100644\n--- a/doc/guides/sample_app_ug/rxtx_callbacks.rst\n+++ b/doc/guides/sample_app_ug/rxtx_callbacks.rst\n@@ -13,6 +13,10 @@ In the sample application a user defined callback is applied to all received\n packets to add a timestamp. A separate callback is applied to all packets\n prior to transmission to calculate the elapsed time, in CPU cycles.\n \n+If hardware timestamping is supported by the NIC, the sample application will\n+also display the average latency since the packet was timestamped in hardware,\n+on top of the latency since the packet was received and processed by the RX\n+callback.\n \n Compiling the Application\n -------------------------\n@@ -36,7 +40,10 @@ To run the example in a ``linux`` environment:\n \n .. code-block:: console\n \n-    ./build/rxtx_callbacks -l 1 -n 4\n+    ./build/rxtx_callbacks -l 1 -n 4 -- [-t]\n+\n+Use -t to enable hardware timestamping. If not supported by the NIC, an error\n+will be displayed.\n \n Refer to *DPDK Getting Started Guide* for general information on running\n applications and the Environment Abstraction Layer (EAL) options.\ndiff --git a/examples/rxtx_callbacks/Makefile b/examples/rxtx_callbacks/Makefile\nindex b937d599b..0a4660681 100644\n--- a/examples/rxtx_callbacks/Makefile\n+++ b/examples/rxtx_callbacks/Makefile\n@@ -50,6 +50,9 @@ include $(RTE_SDK)/mk/rte.vars.mk\n \n CFLAGS += $(WERROR_FLAGS)\n \n+# rte_eth_read_clock is experimental\n+CFLAGS += -DALLOW_EXPERIMENTAL_API\n+\n # workaround for a gcc bug with noreturn attribute\n # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603\n ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)\ndiff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c\nindex 2058be627..55aa82288 100644\n--- a/examples/rxtx_callbacks/main.c\n+++ b/examples/rxtx_callbacks/main.c\n@@ -4,6 +4,7 @@\n \n #include <stdint.h>\n #include <inttypes.h>\n+#include <getopt.h>\n #include <rte_eal.h>\n #include <rte_ethdev.h>\n #include <rte_cycles.h>\n@@ -17,6 +18,9 @@\n #define MBUF_CACHE_SIZE 250\n #define BURST_SIZE 32\n \n+static const char usage[] =\n+\t\"%s EAL_ARGS -- [-t]\\n\";\n+\n static const struct rte_eth_conf port_conf_default = {\n \t.rxmode = {\n \t\t.max_rx_pkt_len = ETHER_MAX_LEN,\n@@ -25,9 +29,14 @@ static const struct rte_eth_conf port_conf_default = {\n \n static struct {\n \tuint64_t total_cycles;\n+\tuint64_t total_queue_cycles;\n \tuint64_t total_pkts;\n } latency_numbers;\n \n+int hw_timestamping;\n+\n+#define TICKS_PER_CYCLE_SHIFT 16\n+static uint64_t ticks_per_cycle_mult;\n \n static uint16_t\n add_timestamps(uint16_t port __rte_unused, uint16_t qidx __rte_unused,\n@@ -43,22 +52,42 @@ add_timestamps(uint16_t port __rte_unused, uint16_t qidx __rte_unused,\n }\n \n static uint16_t\n-calc_latency(uint16_t port __rte_unused, uint16_t qidx __rte_unused,\n+calc_latency(uint16_t port, uint16_t qidx __rte_unused,\n \t\tstruct rte_mbuf **pkts, uint16_t nb_pkts, void *_ __rte_unused)\n {\n \tuint64_t cycles = 0;\n+\tuint64_t queue_ticks = 0;\n \tuint64_t now = rte_rdtsc();\n+\tuint64_t ticks;\n \tunsigned i;\n \n-\tfor (i = 0; i < nb_pkts; i++)\n+\tif (hw_timestamping)\n+\t\trte_eth_read_clock(port, &ticks);\n+\n+\tfor (i = 0; i < nb_pkts; i++) {\n \t\tcycles += now - pkts[i]->udata64;\n+\t\tif (hw_timestamping)\n+\t\t\tqueue_ticks += ticks - pkts[i]->timestamp;\n+\t}\n+\n \tlatency_numbers.total_cycles += cycles;\n+\tif (hw_timestamping)\n+\t\tlatency_numbers.total_queue_cycles += (queue_ticks\n+\t\t\t* ticks_per_cycle_mult) >> TICKS_PER_CYCLE_SHIFT;\n+\n \tlatency_numbers.total_pkts += nb_pkts;\n \n \tif (latency_numbers.total_pkts > (100 * 1000 * 1000ULL)) {\n \t\tprintf(\"Latency = %\"PRIu64\" cycles\\n\",\n \t\tlatency_numbers.total_cycles / latency_numbers.total_pkts);\n-\t\tlatency_numbers.total_cycles = latency_numbers.total_pkts = 0;\n+\t\tif (hw_timestamping) {\n+\t\t\tprintf(\"Latency from HW = %\"PRIu64\" cycles\\n\",\n+\t\t\t   latency_numbers.total_queue_cycles\n+\t\t\t   / latency_numbers.total_pkts);\n+\t\t}\n+\t\tlatency_numbers.total_cycles = 0;\n+\t\tlatency_numbers.total_queue_cycles = 0;\n+\t\tlatency_numbers.total_pkts = 0;\n \t}\n \treturn nb_pkts;\n }\n@@ -77,6 +106,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)\n \tint retval;\n \tuint16_t q;\n \tstruct rte_eth_dev_info dev_info;\n+\tstruct rte_eth_rxconf rxconf;\n \tstruct rte_eth_txconf txconf;\n \n \tif (!rte_eth_dev_is_valid_port(port))\n@@ -95,9 +125,20 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)\n \tif (retval != 0)\n \t\treturn retval;\n \n+\trxconf = dev_info.default_rxconf;\n+\n+\tif (hw_timestamping) {\n+\t\tif (!(dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TIMESTAMP)) {\n+\t\t\tprintf(\"\\nERROR: Port %u does not support hardware timestamping\\n\"\n+\t\t\t\t\t, port);\n+\t\t\treturn -1;\n+\t\t}\n+\t\trxconf.offloads |= DEV_RX_OFFLOAD_TIMESTAMP;\n+\t}\n+\n \tfor (q = 0; q < rx_rings; q++) {\n \t\tretval = rte_eth_rx_queue_setup(port, q, nb_rxd,\n-\t\t\t\trte_eth_dev_socket_id(port), NULL, mbuf_pool);\n+\t\t\trte_eth_dev_socket_id(port), &rxconf, mbuf_pool);\n \t\tif (retval < 0)\n \t\t\treturn retval;\n \t}\n@@ -115,6 +156,27 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)\n \tif (retval < 0)\n \t\treturn retval;\n \n+\tif (hw_timestamping && ticks_per_cycle_mult  == 0) {\n+\t\tuint64_t cycles_base = rte_rdtsc();\n+\t\tuint64_t ticks_base;\n+\t\tretval = rte_eth_read_clock(port, &ticks_base);\n+\t\tif (retval != 0)\n+\t\t\treturn retval;\n+\t\trte_delay_ms(100);\n+\t\tuint64_t cycles = rte_rdtsc();\n+\t\tuint64_t ticks;\n+\t\trte_eth_read_clock(port, &ticks);\n+\t\tuint64_t c_freq = cycles - cycles_base;\n+\t\tuint64_t t_freq = ticks - ticks_base;\n+\t\tdouble freq_mult = (double)c_freq / t_freq;\n+\t\tprintf(\"TSC Freq ~= %lu\\nHW Freq ~= %lu\\nRatio : %f\\n\",\n+\t\t\t\tc_freq * 10, t_freq * 10, freq_mult);\n+\t\t/* TSC will be faster than internal ticks so freq_mult is > 0\n+\t\t * We convert the multiplication to an integer shift & mult\n+\t\t */\n+\t\tticks_per_cycle_mult = (1 << TICKS_PER_CYCLE_SHIFT) / freq_mult;\n+\t}\n+\n \tstruct ether_addr addr;\n \n \trte_eth_macaddr_get(port, &addr);\n@@ -177,6 +239,11 @@ main(int argc, char *argv[])\n \tstruct rte_mempool *mbuf_pool;\n \tuint16_t nb_ports;\n \tuint16_t portid;\n+\tstruct option lgopts[] = {\n+\t\t{ NULL,  0, 0, 0 }\n+\t};\n+\tint opt, option_index;\n+\n \n \t/* init EAL */\n \tint ret = rte_eal_init(argc, argv);\n@@ -186,6 +253,18 @@ main(int argc, char *argv[])\n \targc -= ret;\n \targv += ret;\n \n+\twhile ((opt = getopt_long(argc, argv, \"t\", lgopts, &option_index))\n+\t\t\t!= EOF)\n+\t\tswitch (opt) {\n+\t\tcase 't':\n+\t\t\thw_timestamping = 1;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tprintf(usage, argv[0]);\n+\t\t\treturn -1;\n+\t\t}\n+\toptind = 1; /* reset getopt lib */\n+\n \tnb_ports = rte_eth_dev_count_avail();\n \tif (nb_ports < 2 || (nb_ports & 1))\n \t\trte_exit(EXIT_FAILURE, \"Error: number of ports must be even\\n\");\ndiff --git a/examples/rxtx_callbacks/meson.build b/examples/rxtx_callbacks/meson.build\nindex c34e11e36..a7bf12dd3 100644\n--- a/examples/rxtx_callbacks/meson.build\n+++ b/examples/rxtx_callbacks/meson.build\n@@ -6,6 +6,9 @@\n # To build this example as a standalone application with an already-installed\n # DPDK instance, use 'make'\n \n+#rte_eth_read_clock is experimental\n+allow_experimental_apis = true\n+\n sources = files(\n \t'main.c'\n )\n",
    "prefixes": [
        "v4",
        "3/3"
    ]
}