get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1525718,
    "url": "http://patchwork.ozlabs.org/api/patches/1525718/",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/28d0e91e601c39268699b71183a036c94cc2096f.1631094144.git.grive@u256.net/",
    "project": {
        "id": 47,
        "url": "http://patchwork.ozlabs.org/api/projects/47/",
        "name": "Open vSwitch",
        "link_name": "openvswitch",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "git@github.com:openvswitch/ovs.git",
        "webscm_url": "https://github.com/openvswitch/ovs",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<28d0e91e601c39268699b71183a036c94cc2096f.1631094144.git.grive@u256.net>",
    "list_archive_url": null,
    "date": "2021-09-08T09:47:34",
    "name": "[ovs-dev,v5,10/27] dpif-netdev: Implement hardware offloads stats query",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "ee265faa98e01f8ad806c724b62847e4ee2556a7",
    "submitter": {
        "id": 78795,
        "url": "http://patchwork.ozlabs.org/api/people/78795/",
        "name": "Gaëtan Rivet",
        "email": "grive@u256.net"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/28d0e91e601c39268699b71183a036c94cc2096f.1631094144.git.grive@u256.net/mbox/",
    "series": [
        {
            "id": 261424,
            "url": "http://patchwork.ozlabs.org/api/series/261424/",
            "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=261424",
            "date": "2021-09-08T09:47:24",
            "name": "dpif-netdev: Parallel offload processing",
            "version": 5,
            "mbox": "http://patchwork.ozlabs.org/series/261424/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1525718/comments/",
    "check": "success",
    "checks": "http://patchwork.ozlabs.org/api/patches/1525718/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "ovs-dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@lists.linuxfoundation.org"
        ],
        "Authentication-Results": [
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=u256.net header.i=@u256.net header.a=rsa-sha256\n header.s=fm2 header.b=zv0QQv5J;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=messagingengine.com header.i=@messagingengine.com\n header.a=rsa-sha256 header.s=fm3 header.b=FBNfEZAj;\n\tdkim-atps=neutral",
            "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=140.211.166.136; helo=smtp3.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)",
            "smtp4.osuosl.org (amavisd-new);\n dkim=pass (2048-bit key) header.d=u256.net header.b=\"zv0QQv5J\";\n dkim=pass (2048-bit key) header.d=messagingengine.com\n header.b=\"FBNfEZAj\""
        ],
        "Received": [
            "from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4H4HQY13Z3z9sW8\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  8 Sep 2021 19:48:53 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby smtp3.osuosl.org (Postfix) with ESMTP id 6F817613A3;\n\tWed,  8 Sep 2021 09:48:51 +0000 (UTC)",
            "from smtp3.osuosl.org ([127.0.0.1])\n\tby localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 5RCsFlZ4CCgE; Wed,  8 Sep 2021 09:48:50 +0000 (UTC)",
            "from lists.linuxfoundation.org (lf-lists.osuosl.org\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby smtp3.osuosl.org (Postfix) with ESMTPS id 7ABB0613BA;\n\tWed,  8 Sep 2021 09:48:49 +0000 (UTC)",
            "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 43003C001D;\n\tWed,  8 Sep 2021 09:48:49 +0000 (UTC)",
            "from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 29101C000D\n for <ovs-dev@openvswitch.org>; Wed,  8 Sep 2021 09:48:48 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by smtp4.osuosl.org (Postfix) with ESMTP id 0353240791\n for <ovs-dev@openvswitch.org>; Wed,  8 Sep 2021 09:48:21 +0000 (UTC)",
            "from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id cJYjyR569O28 for <ovs-dev@openvswitch.org>;\n Wed,  8 Sep 2021 09:48:18 +0000 (UTC)",
            "from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com\n [64.147.123.19])\n by smtp4.osuosl.org (Postfix) with ESMTPS id E912840719\n for <ovs-dev@openvswitch.org>; Wed,  8 Sep 2021 09:48:17 +0000 (UTC)",
            "from compute4.internal (compute4.nyi.internal [10.202.2.44])\n by mailout.west.internal (Postfix) with ESMTP id 62EF132009CD;\n Wed,  8 Sep 2021 05:48:17 -0400 (EDT)",
            "from mailfrontend2 ([10.202.2.163])\n by compute4.internal (MEProxy); Wed, 08 Sep 2021 05:48:17 -0400",
            "by mail.messagingengine.com (Postfix) with ESMTPA; Wed,\n 8 Sep 2021 05:48:16 -0400 (EDT)"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "from auto-whitelisted by SQLgrey-1.8.0",
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=u256.net; h=from\n :to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding; s=fm2; bh=jcwgcMmj4UoJw\n BlVwXyeNE7TsTvk7b7Lpo9YnABpjBM=; b=zv0QQv5JywAotJH+RrUcZr26ITpB6\n S/noZsWllC8grJYBDWpG0HojkEVrJCgAlkek2JXhts2XFOwf/ih48S43+dtlgT3d\n SOJa2gBgR41FoxdpVawNLfEvOc2YsjSCZ5UyMAhPtYzWqEruGPf76mRXECcJ0gDT\n 0FA1f1GvKPstMevJCRevOH5E1SHIiuPsQVukY97Kv5dQiDTas/pVOr33q1gQwVh0\n pMhfylIKPOFi4dZQvVjqko3A9YtHdILz2D5ZtHsRqDPJYDMo+JvQUWvGd3OgSwRH\n AoZtjhf5hTlfLqZUZg5fMUWpa6LW9QiCX0QCK2Ei5iJrV10uVxL2Qhn0A==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n messagingengine.com; h=cc:content-transfer-encoding:date:from\n :in-reply-to:message-id:mime-version:references:subject:to\n :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=\n fm3; bh=jcwgcMmj4UoJwBlVwXyeNE7TsTvk7b7Lpo9YnABpjBM=; b=FBNfEZAj\n WKUqx/yk1z13HwYV/HYJ8zAGvlEyBTedfeTBEBaU3buhP2aswmaZn+xVrI3WMjQy\n VxEaLG8hfNpnQWG/emn0Qn16jDiyIZ2fqzuBfj80t0726pnqLcqfPLNUNoDU8QQA\n DEyfTujsBuA5AahGoswDKcMzomQ0WuDurkw3NB+xnjBY2a3G2J8SfcFsh2U9egP8\n 2YLhm8gNaLwrnlxYtH/WT6lFKueBRTqxLFynqijeCMCdnF3kxtb5zXiEgFI3J+gS\n 0K4hL9pTWPx6g8zr5ajxompZDMnszQGoZ0adYMWf5sU0fdS8JP2YbDIhoLX+20SM\n AJwiXcOt1fdTUQ=="
        ],
        "X-ME-Sender": "<xms:4IY4YTTES92E92OSD2g9uAJajNdDNSwA-JlDxAS4DnIeNVHKB2NBqQ>\n <xme:4IY4YUxeb4tAEoijhuKCQSjBUpVwWDX3DOPC9AuKuCjgNwGe_MLcEJrkMZ5fICKhw\n R80yPY4C5bgml5NZk0>",
        "X-ME-Received": "\n <xmr:4IY4YY3GkzqmERdq06uqk0pdIyL20gaFrVBtNa2H0iG19sD6p_4sE-Bx_1FW-OcyuAz2o9XaJnOAED5GHWnur6Fusw>",
        "X-ME-Proxy-Cause": "\n gggruggvucftvghtrhhoucdtuddrgedvtddrudefjedgudekucetufdoteggodetrfdotf\n fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen\n uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne\n cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefirggvthgr\n nhcutfhivhgvthcuoehgrhhivhgvsehuvdehiedrnhgvtheqnecuggftrfgrthhtvghrnh\n ephefgveffkeetheetfeeifedvheelfeejfeehveduteejhfekuedtkeeiuedvteehnecu\n vehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepghhrihhvvg\n esuhdvheeirdhnvght",
        "X-ME-Proxy": "<xmx:4IY4YTCkLUoBZC6afKvGbADIwn00t16TRsldXSQ5ybwADI1SexCJnw>\n <xmx:4IY4YcjMdc-UiBulHdpBV0Gf-wZDqHS1cR4yfpgmfHhUr3PETGkclg>\n <xmx:4IY4YXp9auS6eQQ17XIGLI3Vn-js6FE4_otAH2wolE0Qdd-YiPfKkg>\n <xmx:4YY4YYYFI4-Nn6KqLvDtEN5cdcmamKSZICKa30Ye6oKUuOewKSzH7Q>",
        "From": "Gaetan Rivet <grive@u256.net>",
        "To": "ovs-dev@openvswitch.org",
        "Date": "Wed,  8 Sep 2021 11:47:34 +0200",
        "Message-Id": "\n <28d0e91e601c39268699b71183a036c94cc2096f.1631094144.git.grive@u256.net>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<cover.1631094144.git.grive@u256.net>",
        "References": "<cover.1631094144.git.grive@u256.net>",
        "MIME-Version": "1.0",
        "Cc": "Eli Britstein <elibr@nvidia.com>,\n Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Subject": "[ovs-dev] [PATCH v5 10/27] dpif-netdev: Implement hardware offloads\n\tstats query",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "ovs-dev-bounces@openvswitch.org",
        "Sender": "\"dev\" <ovs-dev-bounces@openvswitch.org>"
    },
    "content": "In the netdev datapath, keep track of the enqueued offloads between\nthe PMDs and the offload thread.  Additionally, query each netdev\nfor their hardware offload counters.\n\nSigned-off-by: Gaetan Rivet <grive@u256.net>\nReviewed-by: Eli Britstein <elibr@nvidia.com>\nReviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/dpif-netdev.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 89 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c\nindex 36d6a5962..c592f8c1d 100644\n--- a/lib/dpif-netdev.c\n+++ b/lib/dpif-netdev.c\n@@ -53,6 +53,7 @@\n #include \"hmapx.h\"\n #include \"id-pool.h\"\n #include \"ipf.h\"\n+#include \"mov-avg.h\"\n #include \"netdev.h\"\n #include \"netdev-offload.h\"\n #include \"netdev-provider.h\"\n@@ -345,6 +346,7 @@ struct dp_offload_thread_item {\n     struct nlattr *actions;\n     size_t actions_len;\n     odp_port_t orig_in_port; /* Originating in_port for tnl flows. */\n+    long long int timestamp;\n \n     struct ovs_list node;\n };\n@@ -352,12 +354,18 @@ struct dp_offload_thread_item {\n struct dp_offload_thread {\n     struct ovs_mutex mutex;\n     struct ovs_list list;\n+    uint64_t enqueued_item;\n+    struct mov_avg_cma cma;\n+    struct mov_avg_ema ema;\n     pthread_cond_t cond;\n };\n \n static struct dp_offload_thread dp_offload_thread = {\n     .mutex = OVS_MUTEX_INITIALIZER,\n     .list  = OVS_LIST_INITIALIZER(&dp_offload_thread.list),\n+    .enqueued_item = 0,\n+    .cma = MOV_AVG_CMA_INITIALIZER,\n+    .ema = MOV_AVG_EMA_INITIALIZER(100),\n };\n \n static struct ovsthread_once offload_thread_once\n@@ -2551,6 +2559,7 @@ dp_netdev_append_flow_offload(struct dp_offload_thread_item *offload)\n {\n     ovs_mutex_lock(&dp_offload_thread.mutex);\n     ovs_list_push_back(&dp_offload_thread.list, &offload->node);\n+    dp_offload_thread.enqueued_item++;\n     xpthread_cond_signal(&dp_offload_thread.cond);\n     ovs_mutex_unlock(&dp_offload_thread.mutex);\n }\n@@ -2656,6 +2665,7 @@ dp_netdev_flow_offload_main(void *data OVS_UNUSED)\n {\n     struct dp_offload_thread_item *offload;\n     struct ovs_list *list;\n+    long long int latency_us;\n     const char *op;\n     int ret;\n \n@@ -2668,6 +2678,7 @@ dp_netdev_flow_offload_main(void *data OVS_UNUSED)\n             ovsrcu_quiesce_end();\n         }\n         list = ovs_list_pop_front(&dp_offload_thread.list);\n+        dp_offload_thread.enqueued_item--;\n         offload = CONTAINER_OF(list, struct dp_offload_thread_item, node);\n         ovs_mutex_unlock(&dp_offload_thread.mutex);\n \n@@ -2688,6 +2699,10 @@ dp_netdev_flow_offload_main(void *data OVS_UNUSED)\n             OVS_NOT_REACHED();\n         }\n \n+        latency_us = time_usec() - offload->timestamp;\n+        mov_avg_cma_update(&dp_offload_thread.cma, latency_us);\n+        mov_avg_ema_update(&dp_offload_thread.ema, latency_us);\n+\n         VLOG_DBG(\"%s to %s netdev flow \"UUID_FMT,\n                  ret == 0 ? \"succeed\" : \"failed\", op,\n                  UUID_ARGS((struct uuid *) &offload->flow->mega_ufid));\n@@ -2712,6 +2727,7 @@ queue_netdev_flow_del(struct dp_netdev_pmd_thread *pmd,\n \n     offload = dp_netdev_alloc_flow_offload(pmd, flow,\n                                            DP_NETDEV_FLOW_OFFLOAD_OP_DEL);\n+    offload->timestamp = pmd->ctx.now;\n     dp_netdev_append_flow_offload(offload);\n }\n \n@@ -2805,6 +2821,7 @@ queue_netdev_flow_put(struct dp_netdev_pmd_thread *pmd,\n     offload->actions_len = actions_len;\n     offload->orig_in_port = orig_in_port;\n \n+    offload->timestamp = pmd->ctx.now;\n     dp_netdev_append_flow_offload(offload);\n }\n \n@@ -4123,6 +4140,77 @@ dpif_netdev_operate(struct dpif *dpif, struct dpif_op **ops, size_t n_ops,\n     }\n }\n \n+static int\n+dpif_netdev_offload_stats_get(struct dpif *dpif,\n+                              struct netdev_custom_stats *stats)\n+{\n+    enum {\n+        DP_NETDEV_HW_OFFLOADS_STATS_ENQUEUED,\n+        DP_NETDEV_HW_OFFLOADS_STATS_INSERTED,\n+        DP_NETDEV_HW_OFFLOADS_STATS_LAT_CMA_MEAN,\n+        DP_NETDEV_HW_OFFLOADS_STATS_LAT_CMA_STDDEV,\n+        DP_NETDEV_HW_OFFLOADS_STATS_LAT_EMA_MEAN,\n+        DP_NETDEV_HW_OFFLOADS_STATS_LAT_EMA_STDDEV,\n+    };\n+    const char *names[] = {\n+        [DP_NETDEV_HW_OFFLOADS_STATS_ENQUEUED] =\n+            \"                Enqueued offloads\",\n+        [DP_NETDEV_HW_OFFLOADS_STATS_INSERTED] =\n+            \"                Inserted offloads\",\n+        [DP_NETDEV_HW_OFFLOADS_STATS_LAT_CMA_MEAN] =\n+            \"  Cumulative Average latency (us)\",\n+        [DP_NETDEV_HW_OFFLOADS_STATS_LAT_CMA_STDDEV] =\n+            \"   Cumulative Latency stddev (us)\",\n+        [DP_NETDEV_HW_OFFLOADS_STATS_LAT_EMA_MEAN] =\n+            \" Exponential Average latency (us)\",\n+        [DP_NETDEV_HW_OFFLOADS_STATS_LAT_EMA_STDDEV] =\n+            \"  Exponential Latency stddev (us)\",\n+    };\n+    struct dp_netdev *dp = get_dp_netdev(dpif);\n+    struct dp_netdev_port *port;\n+    uint64_t nb_offloads;\n+    size_t i;\n+\n+    if (!netdev_is_flow_api_enabled()) {\n+        return EINVAL;\n+    }\n+\n+    stats->size = ARRAY_SIZE(names);\n+    stats->counters = xcalloc(stats->size, sizeof *stats->counters);\n+\n+    nb_offloads = 0;\n+\n+    ovs_mutex_lock(&dp->port_mutex);\n+    HMAP_FOR_EACH (port, node, &dp->ports) {\n+        uint64_t port_nb_offloads = 0;\n+\n+        /* Do not abort on read error from a port, just report 0. */\n+        if (!netdev_flow_get_n_flows(port->netdev, &port_nb_offloads)) {\n+            nb_offloads += port_nb_offloads;\n+        }\n+    }\n+    ovs_mutex_unlock(&dp->port_mutex);\n+\n+    stats->counters[DP_NETDEV_HW_OFFLOADS_STATS_ENQUEUED].value =\n+        dp_offload_thread.enqueued_item;\n+    stats->counters[DP_NETDEV_HW_OFFLOADS_STATS_INSERTED].value = nb_offloads;\n+    stats->counters[DP_NETDEV_HW_OFFLOADS_STATS_LAT_CMA_MEAN].value =\n+        mov_avg_cma(&dp_offload_thread.cma);\n+    stats->counters[DP_NETDEV_HW_OFFLOADS_STATS_LAT_CMA_STDDEV].value =\n+        mov_avg_cma_std_dev(&dp_offload_thread.cma);\n+    stats->counters[DP_NETDEV_HW_OFFLOADS_STATS_LAT_EMA_MEAN].value =\n+        mov_avg_ema(&dp_offload_thread.ema);\n+    stats->counters[DP_NETDEV_HW_OFFLOADS_STATS_LAT_EMA_STDDEV].value =\n+        mov_avg_ema_std_dev(&dp_offload_thread.ema);\n+\n+    for (i = 0; i < ARRAY_SIZE(names); i++) {\n+        snprintf(stats->counters[i].name, sizeof(stats->counters[i].name),\n+                 \"%s\", names[i]);\n+    }\n+\n+    return 0;\n+}\n+\n /* Enable or Disable PMD auto load balancing. */\n static void\n set_pmd_auto_lb(struct dp_netdev *dp, bool always_log)\n@@ -8741,7 +8829,7 @@ const struct dpif_class dpif_netdev_class = {\n     dpif_netdev_flow_dump_thread_destroy,\n     dpif_netdev_flow_dump_next,\n     dpif_netdev_operate,\n-    NULL,                       /* offload_stats_get */\n+    dpif_netdev_offload_stats_get,\n     NULL,                       /* recv_set */\n     NULL,                       /* handlers_set */\n     NULL,                       /* number_handlers_required */\n",
    "prefixes": [
        "ovs-dev",
        "v5",
        "10/27"
    ]
}