get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 49122,
    "url": "https://patches.dpdk.org/api/patches/49122/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20181219134934.24693-4-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-4-barbette@kth.se>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181219134934.24693-4-barbette@kth.se",
    "date": "2018-12-19T13:49:34",
    "name": "[3/3] rxtx_callbacks: Add support for HW timestamp",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "58e6af61c3dd09d1641287898d79aff6b9be47a4",
    "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-4-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/49122/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/49122/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 CE5101B9A6;\n\tWed, 19 Dec 2018 14:50:09 +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 0AD6B1B950\n\tfor <dev@dpdk.org>; Wed, 19 Dec 2018 14:50:06 +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 D512B3699;\n\tWed, 19 Dec 2018 14:50:05 +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 kSUfxjjbttZt; Wed, 19 Dec 2018 14:50:04 +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 2A94B5830;\n\tWed, 19 Dec 2018 14:50:04 +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=1545227404; bh=NE67H4HFRTgsuYC2vyd8Gx0N/bAC3Zyt2MIDRHyvU0Y=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References;\n\tb=mzJYuQa20fNwJgFuZ22+Sh7CEADvhzDzESHJGWFUZH4fFJug2+paK0VZmc67uxexl\n\tJGSdPE9HgH+EkQnJmMj78QqUPnP3e0EZKVYG7qa0goWw3V3Do2vysfRqyRV86/ixSr\n\tz5bFz02MCmFpGZq0CUDgw3lXZJPZChRW1AymVMVo=",
        "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:34 +0100",
        "Message-Id": "<20181219134934.24693-4-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 3/3] rxtx_callbacks: Add support for HW timestamp",
        "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            |  2 +\n examples/rxtx_callbacks/main.c              | 86 ++++++++++++++++++++-\n examples/rxtx_callbacks/meson.build         |  1 +\n 4 files changed, 93 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 85d96d8a2..895f02296 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 ``linuxapp`` 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 e9d30d56f..e70c081f2 100644\n--- a/examples/rxtx_callbacks/Makefile\n+++ b/examples/rxtx_callbacks/Makefile\n@@ -50,6 +50,8 @@ include $(RTE_SDK)/mk/rte.vars.mk\n \n CFLAGS += $(WERROR_FLAGS)\n \n+\n+CFLAGS += -DALLOW_EXPERIMENTAL_API\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..7000464e1 100644\n--- a/examples/rxtx_callbacks/main.c\n+++ b/examples/rxtx_callbacks/main.c\n@@ -10,6 +10,8 @@\n #include <rte_lcore.h>\n #include <rte_mbuf.h>\n \n+#include <getopt.h>\n+\n #define RX_RING_SIZE 1024\n #define TX_RING_SIZE 1024\n \n@@ -17,6 +19,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 +30,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+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 +53,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 +107,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 +126,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 +157,25 @@ 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\trte_eth_read_clock(port, &ticks_base);\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 +238,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 +252,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..2b0a25036 100644\n--- a/examples/rxtx_callbacks/meson.build\n+++ b/examples/rxtx_callbacks/meson.build\n@@ -6,6 +6,7 @@\n # To build this example as a standalone application with an already-installed\n # DPDK instance, use 'make'\n \n+allow_experimental_apis = true\n sources = files(\n \t'main.c'\n )\n",
    "prefixes": [
        "3/3"
    ]
}