get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1528340,
    "url": "http://patchwork.ozlabs.org/api/patches/1528340/",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20210915124319.1683219-4-cmi@nvidia.com/",
    "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": "<20210915124319.1683219-4-cmi@nvidia.com>",
    "list_archive_url": null,
    "date": "2021-09-15T12:43:15",
    "name": "[ovs-dev,v15,3/7] dpif-offload-provider: Introduce dpif-offload-provider layer",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "37f4566b006ff16353c48ba9588f27931ce1e0aa",
    "submitter": {
        "id": 80086,
        "url": "http://patchwork.ozlabs.org/api/people/80086/",
        "name": "Chris Mi",
        "email": "cmi@nvidia.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20210915124319.1683219-4-cmi@nvidia.com/mbox/",
    "series": [
        {
            "id": 262447,
            "url": "http://patchwork.ozlabs.org/api/series/262447/",
            "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=262447",
            "date": "2021-09-15T12:43:12",
            "name": "Add offload support for sFlow",
            "version": 15,
            "mbox": "http://patchwork.ozlabs.org/series/262447/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1528340/comments/",
    "check": "success",
    "checks": "http://patchwork.ozlabs.org/api/patches/1528340/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@ozlabs.org",
            "ovs-dev@lists.linuxfoundation.org"
        ],
        "Authentication-Results": "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)",
        "Received": [
            "from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138])\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 4H8fz10qRjz9ssD\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Sep 2021 22:43:40 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby smtp1.osuosl.org (Postfix) with ESMTP id 7801D82A2D;\n\tWed, 15 Sep 2021 12:43:34 +0000 (UTC)",
            "from smtp1.osuosl.org ([127.0.0.1])\n\tby localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id vEoiRe0mxGxw; Wed, 15 Sep 2021 12:43:33 +0000 (UTC)",
            "from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])\n\tby smtp1.osuosl.org (Postfix) with ESMTPS id 74C18829B1;\n\tWed, 15 Sep 2021 12:43:32 +0000 (UTC)",
            "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 7E5F3C0023;\n\tWed, 15 Sep 2021 12:43:31 +0000 (UTC)",
            "from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 22704C0011\n for <dev@openvswitch.org>; Wed, 15 Sep 2021 12:43:30 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by smtp2.osuosl.org (Postfix) with ESMTP id 1D6D3401C8\n for <dev@openvswitch.org>; Wed, 15 Sep 2021 12:43:30 +0000 (UTC)",
            "from smtp2.osuosl.org ([127.0.0.1])\n by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id WlsSVYY8ruu0 for <dev@openvswitch.org>;\n Wed, 15 Sep 2021 12:43:28 +0000 (UTC)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by smtp2.osuosl.org (Postfix) with ESMTP id 312E040101\n for <dev@openvswitch.org>; Wed, 15 Sep 2021 12:43:27 +0000 (UTC)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from cmi@nvidia.com)\n with SMTP; 15 Sep 2021 15:43:21 +0300",
            "from c-141-46-1-010.mtl.labs.mlnx (c-141-46-1-010.mtl.labs.mlnx\n [10.141.46.10])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 18FChLbX010242;\n Wed, 15 Sep 2021 15:43:21 +0300"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.8.0",
        "To": "dev@openvswitch.org",
        "Date": "Wed, 15 Sep 2021 15:43:15 +0300",
        "Message-Id": "<20210915124319.1683219-4-cmi@nvidia.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20210915124319.1683219-1-cmi@nvidia.com>",
        "References": "<20210915124319.1683219-1-cmi@nvidia.com>",
        "MIME-Version": "1.0",
        "Cc": "elibr@nvidia.com, simon.horman@netronome.com, roniba@nvidia.com,\n i.maximets@ovn.org",
        "Subject": "[ovs-dev] [PATCH v15 3/7] dpif-offload-provider: Introduce\n\tdpif-offload-provider layer",
        "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>",
        "From": "Chris Mi via dev <ovs-dev@openvswitch.org>",
        "Reply-To": "Chris Mi <cmi@nvidia.com>",
        "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": "Some offload actions require functionality that is not netdev\nbased, but dpif. For example, sFlow action requires to create\na psample netlink socket to receive the sampled packets from\nTC or kernel driver.\n\nCreate dpif-offload-provider layer to support such actions.\n\nSigned-off-by: Chris Mi <cmi@nvidia.com>\nReviewed-by: Eli Britstein <elibr@nvidia.com>\n---\n lib/automake.mk             |  2 ++\n lib/dpif-netdev.c           |  1 +\n lib/dpif-netlink.c          |  2 ++\n lib/dpif-offload-provider.h | 47 +++++++++++++++++++++++++++++++++++++\n lib/dpif-offload.c          | 43 +++++++++++++++++++++++++++++++++\n lib/dpif-provider.h         |  8 ++++++-\n lib/dpif.c                  | 10 ++++++++\n 7 files changed, 112 insertions(+), 1 deletion(-)\n create mode 100644 lib/dpif-offload-provider.h\n create mode 100644 lib/dpif-offload.c",
    "diff": "diff --git a/lib/automake.mk b/lib/automake.mk\nindex 46f869a33..9259f57de 100644\n--- a/lib/automake.mk\n+++ b/lib/automake.mk\n@@ -127,6 +127,8 @@ lib_libopenvswitch_la_SOURCES = \\\n \tlib/dpif-netdev-private.h \\\n \tlib/dpif-netdev-perf.c \\\n \tlib/dpif-netdev-perf.h \\\n+\tlib/dpif-offload.c \\\n+\tlib/dpif-offload-provider.h \\\n \tlib/dpif-provider.h \\\n \tlib/dpif.c \\\n \tlib/dpif.h \\\ndiff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c\nindex 4cd0e9ebd..1645b44b0 100644\n--- a/lib/dpif-netdev.c\n+++ b/lib/dpif-netdev.c\n@@ -8801,6 +8801,7 @@ const struct dpif_class dpif_netdev_class = {\n     dpif_netdev_bond_add,\n     dpif_netdev_bond_del,\n     dpif_netdev_bond_stats_get,\n+    NULL,                       /* dpif_offload_api */\n };\n \n static void\ndiff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c\nindex 34fc04237..f546b48e5 100644\n--- a/lib/dpif-netlink.c\n+++ b/lib/dpif-netlink.c\n@@ -34,6 +34,7 @@\n \n #include \"bitmap.h\"\n #include \"dpif-netlink-rtnl.h\"\n+#include \"dpif-offload-provider.h\"\n #include \"dpif-provider.h\"\n #include \"fat-rwlock.h\"\n #include \"flow.h\"\n@@ -4340,6 +4341,7 @@ const struct dpif_class dpif_netlink_class = {\n     NULL,                       /* bond_add */\n     NULL,                       /* bond_del */\n     NULL,                       /* bond_stats_get */\n+    NULL,                       /* dpif_offload_api */\n };\n \n static int\ndiff --git a/lib/dpif-offload-provider.h b/lib/dpif-offload-provider.h\nnew file mode 100644\nindex 000000000..75238c4cb\n--- /dev/null\n+++ b/lib/dpif-offload-provider.h\n@@ -0,0 +1,47 @@\n+/*\n+ * Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at:\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+#ifndef DPIF_OFFLOAD_PROVIDER_H\n+#define DPIF_OFFLOAD_PROVIDER_H\n+\n+struct dpif;\n+struct dpif_offload_sflow;\n+\n+/* Datapath interface offload structure, to be defined by each implementation\n+ * of a datapath interface.\n+ */\n+struct dpif_offload_api {\n+    /* Called when the dpif provider is registered and right after dpif\n+     * provider init function. */\n+    void (*init)(void);\n+\n+    /* Free all dpif offload resources. */\n+    void (*destroy)(void);\n+\n+    /* Arranges for the poll loop for an upcall handler to wake up when psample\n+     * has a message queued to be received. */\n+    void (*sflow_recv_wait)(void);\n+\n+    /* Polls for an upcall from psample for an upcall handler.\n+     * Return 0 for success. */\n+    int (*sflow_recv)(struct dpif_offload_sflow *sflow);\n+};\n+\n+void dpif_offload_sflow_recv_wait(const struct dpif *dpif);\n+int dpif_offload_sflow_recv(const struct dpif *dpif,\n+                            struct dpif_offload_sflow *sflow);\n+\n+#endif /* DPIF_OFFLOAD_PROVIDER_H */\ndiff --git a/lib/dpif-offload.c b/lib/dpif-offload.c\nnew file mode 100644\nindex 000000000..842e05798\n--- /dev/null\n+++ b/lib/dpif-offload.c\n@@ -0,0 +1,43 @@\n+/*\n+ * Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at:\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+#include <config.h>\n+#include <errno.h>\n+\n+#include \"dpif-provider.h\"\n+\n+void\n+dpif_offload_sflow_recv_wait(const struct dpif *dpif)\n+{\n+    const struct dpif_offload_api *offload_api = dpif->dpif_class->offload_api;\n+\n+    if (offload_api && offload_api->sflow_recv_wait) {\n+        offload_api->sflow_recv_wait();\n+    }\n+}\n+\n+int\n+dpif_offload_sflow_recv(const struct dpif *dpif,\n+                        struct dpif_offload_sflow *sflow)\n+{\n+    const struct dpif_offload_api *offload_api = dpif->dpif_class->offload_api;\n+\n+    if (offload_api && offload_api->sflow_recv) {\n+        return offload_api->sflow_recv(sflow);\n+    }\n+\n+    return EOPNOTSUPP;\n+}\ndiff --git a/lib/dpif-provider.h b/lib/dpif-provider.h\nindex 7e11b9697..ce20cdeb1 100644\n--- a/lib/dpif-provider.h\n+++ b/lib/dpif-provider.h\n@@ -22,8 +22,9 @@\n  * exposed over OpenFlow as a single switch.  Datapaths and the collections of\n  * ports that they contain may be fixed or dynamic. */\n \n-#include \"openflow/openflow.h\"\n #include \"dpif.h\"\n+#include \"dpif-offload-provider.h\"\n+#include \"openflow/openflow.h\"\n #include \"util.h\"\n \n #ifdef  __cplusplus\n@@ -635,6 +636,11 @@ struct dpif_class {\n      * sufficient to store BOND_BUCKETS number of elements. */\n     int (*bond_stats_get)(struct dpif *dpif, uint32_t bond_id,\n                           uint64_t *n_bytes);\n+\n+    /* Some offload actions require functionality that is not netdev based,\n+     * but dpif. Add dpif-offload-provider layer API to support such\n+     * offload actions. */\n+    const struct dpif_offload_api *offload_api;\n };\n \n extern const struct dpif_class dpif_netlink_class;\ndiff --git a/lib/dpif.c b/lib/dpif.c\nindex 8c4aed47b..13a3cd0d4 100644\n--- a/lib/dpif.c\n+++ b/lib/dpif.c\n@@ -153,6 +153,10 @@ dp_register_provider__(const struct dpif_class *new_class)\n         return error;\n     }\n \n+    if (new_class->offload_api && new_class->offload_api->init) {\n+        new_class->offload_api->init();\n+    }\n+\n     registered_class = xmalloc(sizeof *registered_class);\n     registered_class->dpif_class = new_class;\n     registered_class->refcount = 0;\n@@ -183,6 +187,7 @@ static int\n dp_unregister_provider__(const char *type)\n {\n     struct shash_node *node;\n+    const struct dpif_class *dpif_class;\n     struct registered_dpif_class *registered_class;\n \n     node = shash_find(&dpif_classes, type);\n@@ -196,6 +201,11 @@ dp_unregister_provider__(const char *type)\n         return EBUSY;\n     }\n \n+    dpif_class = registered_class->dpif_class;\n+    if (dpif_class->offload_api && dpif_class->offload_api->destroy) {\n+        dpif_class->offload_api->destroy();\n+    }\n+\n     shash_delete(&dpif_classes, node);\n     free(registered_class);\n \n",
    "prefixes": [
        "ovs-dev",
        "v15",
        "3/7"
    ]
}