get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 139203,
    "url": "http://patches.dpdk.org/api/patches/139203/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240409034237.433270-5-stephen@networkplumber.org/",
    "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": "<20240409034237.433270-5-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240409034237.433270-5-stephen@networkplumber.org",
    "date": "2024-04-09T03:40:33",
    "name": "[v8,4/8] net/tap: do not build flow support if header is out of date",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "919af474ce7679f373aac2a58ea0072f22e8d3c3",
    "submitter": {
        "id": 27,
        "url": "http://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240409034237.433270-5-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 31709,
            "url": "http://patches.dpdk.org/api/series/31709/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31709",
            "date": "2024-04-09T03:40:29",
            "name": "net/tap: cleanups and fix BPF support",
            "version": 8,
            "mbox": "http://patches.dpdk.org/series/31709/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/139203/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/139203/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 1452643DD9;\n\tTue,  9 Apr 2024 05:43:12 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E23EE40693;\n\tTue,  9 Apr 2024 05:42:48 +0200 (CEST)",
            "from mail-oo1-f49.google.com (mail-oo1-f49.google.com\n [209.85.161.49]) by mails.dpdk.org (Postfix) with ESMTP id 318AE402CF\n for <dev@dpdk.org>; Tue,  9 Apr 2024 05:42:43 +0200 (CEST)",
            "by mail-oo1-f49.google.com with SMTP id\n 006d021491bc7-5aa20adda1dso1871692eaf.1\n for <dev@dpdk.org>; Mon, 08 Apr 2024 20:42:43 -0700 (PDT)",
            "from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226])\n by smtp.gmail.com with ESMTPSA id\n gm24-20020a17090b101800b0029de90f4d44sm9238197pjb.9.2024.04.08.20.42.41\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 08 Apr 2024 20:42:41 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1712634162;\n x=1713238962; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=a2vMsT7lQuve1AwjvIanirgc6GLuVum0XUWRlqul+mc=;\n b=A8BVxVyygEZRxB9ZiROh7foWK3m2vdmHWwqhQuAGi0DJgENR/LlHcaBYVf20QX1OkD\n 9SBmYEcWnowuLS9q6O5yqFA7xwj+eLVzO8a044p/ieiOVHNEu92GN2TUzfTCbVtgbVBV\n MCleEvBWybdd9IyFe5G5Bg36Gcs6VuOR5Ky4oYd/nC9Xu8m4NB6BjTMkHRl/YEF0UUdq\n w6YBu6m09sjttnTddIhqhagebKWaLa3dHY1HWyeZ1zR27zKDkSAO8czQzdgil+Khb0DR\n jktT6PbYsFRmP5q0aRP4MfqdbD+y7/RubzA1mZh5nI+14yKqd1TEQ3+kIxt2WX7Iv8WH\n KoOw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1712634162; x=1713238962;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=a2vMsT7lQuve1AwjvIanirgc6GLuVum0XUWRlqul+mc=;\n b=dg+qOXvUFV/oxRB0wlByEKJpijBmDRqvtFYljQgp3ZW+k0YQWremEbDwaB3I3xloHh\n A5KIdtG19Cctxnz0tdDbUG0sUdWvJ+rIywXueeVARwfJeHXDEoXZy2Q5xdez9THNwy27\n c+vXSDZ3y4f0uwOJQJzVAPdOabHZI13L9ndaaAns21RSebKu0UTh4N4yLCxWfus0pjqT\n vmlFSeG1Z5CSk82izsz3LdTW2qa9IeV7u6eaVehQ/R7c0J2NMUmEy+SaNSMIr6pT9fK8\n gggrwl7gPfLLCHTkd0u3wqoYAVmptL3ReAEp9RSEJ9BH9FYUv+QF+wiNcQXi65tFkMb1\n x6PQ==",
        "X-Gm-Message-State": "AOJu0YyG7D+h7nDgBKunYGVhD579RQuhYGkK5UIjJP3SC87TIV8zTF9F\n YkhkFvUNyaS/QcHE7rVW/F6JS24UoSG4ldx/B41I/pL7KkgnQlGZa3uZdiHr9tdSXKfpeSAHn9R\n j7o0=",
        "X-Google-Smtp-Source": "\n AGHT+IGexst5eM3BUzPCw8S+z1HXPzFMQZliWc3dICpP+O/mw951SlPfL5ZuFnSmT8xGLz5TuOALRA==",
        "X-Received": "by 2002:a05:6358:2295:b0:17e:bbdb:acbe with SMTP id\n t21-20020a056358229500b0017ebbdbacbemr12633599rwb.14.1712634162263;\n Mon, 08 Apr 2024 20:42:42 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Subject": "[PATCH v8 4/8] net/tap: do not build flow support if header is out of\n date",
        "Date": "Mon,  8 Apr 2024 20:40:33 -0700",
        "Message-ID": "<20240409034237.433270-5-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240409034237.433270-1-stephen@networkplumber.org>",
        "References": "<20240130034925.44869-1-stephen@networkplumber.org>\n <20240409034237.433270-1-stephen@networkplumber.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "The proper place for finding bpf structures and functions is\nin linux/bpf.h. The original version was trying to workaround the\ncase where the build environment was running on old pre BPF\nversion of Glibc, but the target environment had BPF.\n\nHaving own private (and divergent) version headers leads to future\nproblems when BPF definitions evolve.\n\nIf the build infrastructure is so old that TC flower is not\nsupported, then the TAP device will build without any flow support.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n drivers/net/tap/bpf/bpf_extract.py |   1 -\n drivers/net/tap/meson.build        |  17 ++--\n drivers/net/tap/rte_eth_tap.c      |  38 +++++++--\n drivers/net/tap/rte_eth_tap.h      |   7 +-\n drivers/net/tap/tap_bpf.h          | 121 -----------------------------\n drivers/net/tap/tap_bpf_api.c      |  20 +++--\n drivers/net/tap/tap_bpf_insns.h    |   2 -\n drivers/net/tap/tap_flow.c         |  90 ---------------------\n 8 files changed, 60 insertions(+), 236 deletions(-)\n delete mode 100644 drivers/net/tap/tap_bpf.h",
    "diff": "diff --git a/drivers/net/tap/bpf/bpf_extract.py b/drivers/net/tap/bpf/bpf_extract.py\nindex b630c42b80..73c4dafe4e 100644\n--- a/drivers/net/tap/bpf/bpf_extract.py\n+++ b/drivers/net/tap/bpf/bpf_extract.py\n@@ -65,7 +65,6 @@ def write_header(out, source):\n         print(f' * Auto-generated from {source}', file=out)\n     print(\" * This not the original source file. Do NOT edit it.\", file=out)\n     print(\" */\\n\", file=out)\n-    print(\"#include <tap_bpf.h>\", file=out)\n \n \n def main():\ndiff --git a/drivers/net/tap/meson.build b/drivers/net/tap/meson.build\nindex 9cd124d53e..1fd20cfe93 100644\n--- a/drivers/net/tap/meson.build\n+++ b/drivers/net/tap/meson.build\n@@ -7,13 +7,19 @@ if not is_linux\n endif\n sources = files(\n         'rte_eth_tap.c',\n-        'tap_bpf_api.c',\n-        'tap_flow.c',\n         'tap_intr.c',\n         'tap_netlink.c',\n-        'tap_tcmsgs.c',\n )\n \n+if cc.has_header_symbol('linux/pkt_cls.h', 'TCA_FLOWER_ACT')\n+    cflags += '-DHAVE_TCA_FLOWER'\n+    sources += files(\n+        'tap_bpf_api.c',\n+        'tap_flow.c',\n+        'tap_tcmsgs.c',\n+    )\n+endif\n+\n deps = ['bus_vdev', 'gso', 'hash']\n \n cflags += '-DTAP_MAX_QUEUES=8'\n@@ -23,12 +29,7 @@ cflags += '-DTAP_MAX_QUEUES=8'\n #   \"enum/define\", \"symbol to search\" ]\n #\n args = [\n-        [ 'HAVE_TC_FLOWER', 'linux/pkt_cls.h', 'TCA_FLOWER_UNSPEC' ],\n-        [ 'HAVE_TC_VLAN_ID', 'linux/pkt_cls.h', 'TCA_FLOWER_KEY_VLAN_PRIO' ],\n-        [ 'HAVE_TC_BPF', 'linux/pkt_cls.h', 'TCA_BPF_UNSPEC' ],\n-        [ 'HAVE_TC_BPF_FD', 'linux/pkt_cls.h', 'TCA_BPF_FD' ],\n         [ 'HAVE_TC_ACT_BPF', 'linux/tc_act/tc_bpf.h', 'TCA_ACT_BPF_UNSPEC' ],\n-        [ 'HAVE_TC_ACT_BPF_FD', 'linux/tc_act/tc_bpf.h', 'TCA_ACT_BPF_FD' ],\n ]\n config = configuration_data()\n foreach arg:args\ndiff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c\nindex 38a1b2d825..3f4fe95a09 100644\n--- a/drivers/net/tap/rte_eth_tap.c\n+++ b/drivers/net/tap/rte_eth_tap.c\n@@ -1124,12 +1124,15 @@ tap_dev_close(struct rte_eth_dev *dev)\n \n \tif (!internals->persist)\n \t\ttap_link_set_down(dev);\n+\n+#ifdef HAVE_TCA_FLOWER\n \tif (internals->nlsk_fd != -1) {\n \t\ttap_flow_flush(dev, NULL);\n \t\ttap_flow_implicit_flush(internals, NULL);\n \t\ttap_nl_final(internals->nlsk_fd);\n \t\tinternals->nlsk_fd = -1;\n \t}\n+#endif\n \n \tfor (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {\n \t\tstruct rx_queue *rxq = &internals->rxq[i];\n@@ -1265,6 +1268,7 @@ tap_promisc_enable(struct rte_eth_dev *dev)\n \tif (ret != 0)\n \t\treturn ret;\n \n+#ifdef HAVE_TCA_FLOWER\n \tif (pmd->remote_if_index && !pmd->flow_isolate) {\n \t\tdev->data->promiscuous = 1;\n \t\tret = tap_flow_implicit_create(pmd, TAP_REMOTE_PROMISC);\n@@ -1278,7 +1282,7 @@ tap_promisc_enable(struct rte_eth_dev *dev)\n \t\t\treturn ret;\n \t\t}\n \t}\n-\n+#endif\n \treturn 0;\n }\n \n@@ -1293,6 +1297,7 @@ tap_promisc_disable(struct rte_eth_dev *dev)\n \tif (ret != 0)\n \t\treturn ret;\n \n+#ifdef HAVE_TCA_FLOWER\n \tif (pmd->remote_if_index && !pmd->flow_isolate) {\n \t\tdev->data->promiscuous = 0;\n \t\tret = tap_flow_implicit_destroy(pmd, TAP_REMOTE_PROMISC);\n@@ -1306,6 +1311,7 @@ tap_promisc_disable(struct rte_eth_dev *dev)\n \t\t\treturn ret;\n \t\t}\n \t}\n+#endif\n \n \treturn 0;\n }\n@@ -1321,6 +1327,7 @@ tap_allmulti_enable(struct rte_eth_dev *dev)\n \tif (ret != 0)\n \t\treturn ret;\n \n+#ifdef HAVE_TCA_FLOWER\n \tif (pmd->remote_if_index && !pmd->flow_isolate) {\n \t\tdev->data->all_multicast = 1;\n \t\tret = tap_flow_implicit_create(pmd, TAP_REMOTE_ALLMULTI);\n@@ -1334,6 +1341,7 @@ tap_allmulti_enable(struct rte_eth_dev *dev)\n \t\t\treturn ret;\n \t\t}\n \t}\n+#endif\n \n \treturn 0;\n }\n@@ -1349,6 +1357,7 @@ tap_allmulti_disable(struct rte_eth_dev *dev)\n \tif (ret != 0)\n \t\treturn ret;\n \n+#ifdef HAVE_TCA_FLOWER\n \tif (pmd->remote_if_index && !pmd->flow_isolate) {\n \t\tdev->data->all_multicast = 0;\n \t\tret = tap_flow_implicit_destroy(pmd, TAP_REMOTE_ALLMULTI);\n@@ -1362,6 +1371,7 @@ tap_allmulti_disable(struct rte_eth_dev *dev)\n \t\t\treturn ret;\n \t\t}\n \t}\n+#endif\n \n \treturn 0;\n }\n@@ -1407,6 +1417,8 @@ tap_mac_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)\n \tif (ret < 0)\n \t\treturn ret;\n \trte_memcpy(&pmd->eth_addr, mac_addr, RTE_ETHER_ADDR_LEN);\n+\n+#ifdef HAVE_TCA_FLOWER\n \tif (pmd->remote_if_index && !pmd->flow_isolate) {\n \t\t/* Replace MAC redirection rule after a MAC change */\n \t\tret = tap_flow_implicit_destroy(pmd, TAP_REMOTE_LOCAL_MAC);\n@@ -1424,6 +1436,7 @@ tap_mac_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)\n \t\t\treturn ret;\n \t\t}\n \t}\n+#endif\n \n \treturn 0;\n }\n@@ -1901,7 +1914,9 @@ static const struct eth_dev_ops ops = {\n \t.stats_reset            = tap_stats_reset,\n \t.dev_supported_ptypes_get = tap_dev_supported_ptypes_get,\n \t.rss_hash_update        = tap_rss_hash_update,\n+#ifdef HAVE_TCA_FLOWER\n \t.flow_ops_get           = tap_dev_flow_ops_get,\n+#endif\n };\n \n static int\n@@ -1941,7 +1956,9 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,\n \tstrlcpy(pmd->name, tap_name, sizeof(pmd->name));\n \tpmd->type = type;\n \tpmd->ka_fd = -1;\n+#ifdef HAVE_TCA_FLOWER\n \tpmd->nlsk_fd = -1;\n+#endif\n \tpmd->gso_ctx_mp = NULL;\n \n \tpmd->ioctl_sock = socket(AF_INET, SOCK_DGRAM, 0);\n@@ -2021,6 +2038,14 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,\n \t/* Make network device persist after application exit */\n \tpmd->persist = persist;\n \n+\tpmd->if_index = if_nametoindex(pmd->name);\n+\tif (!pmd->if_index) {\n+\t\tTAP_LOG(ERR, \"%s: failed to get if_index.\", pmd->name);\n+\t\tgoto disable_rte_flow;\n+\t}\n+\n+\n+#ifdef HAVE_TCA_FLOWER\n \t/*\n \t * Set up everything related to rte_flow:\n \t * - netlink socket\n@@ -2035,11 +2060,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,\n \t\t\tpmd->name);\n \t\tgoto disable_rte_flow;\n \t}\n-\tpmd->if_index = if_nametoindex(pmd->name);\n-\tif (!pmd->if_index) {\n-\t\tTAP_LOG(ERR, \"%s: failed to get if_index.\", pmd->name);\n-\t\tgoto disable_rte_flow;\n-\t}\n \tif (qdisc_create_multiq(pmd->nlsk_fd, pmd->if_index) < 0) {\n \t\tTAP_LOG(ERR, \"%s: failed to create multiq qdisc.\",\n \t\t\tpmd->name);\n@@ -2050,6 +2070,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,\n \t\t\tpmd->name);\n \t\tgoto disable_rte_flow;\n \t}\n+\n \tLIST_INIT(&pmd->flows);\n \n \tif (strlen(remote_iface)) {\n@@ -2102,6 +2123,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,\n \t\t\tgoto error_remote;\n \t\t}\n \t}\n+#endif\n \n \trte_eth_dev_probing_finish(dev);\n \treturn 0;\n@@ -2116,14 +2138,18 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,\n \trte_eth_dev_probing_finish(dev);\n \treturn 0;\n \n+#ifdef HAVE_TCA_FLOWER\n error_remote:\n \tTAP_LOG(ERR, \" Can't set up remote feature: %s(%d)\",\n \t\tstrerror(errno), errno);\n \ttap_flow_implicit_flush(pmd, NULL);\n+#endif\n \n error_exit:\n+#ifdef HAVE_TCA_FLOWER\n \tif (pmd->nlsk_fd != -1)\n \t\tclose(pmd->nlsk_fd);\n+#endif\n \tif (pmd->ka_fd != -1)\n \t\tclose(pmd->ka_fd);\n \tif (pmd->ioctl_sock != -1)\ndiff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h\nindex 1bcf92ce80..af18b29090 100644\n--- a/drivers/net/tap/rte_eth_tap.h\n+++ b/drivers/net/tap/rte_eth_tap.h\n@@ -16,6 +16,7 @@\n #include <ethdev_driver.h>\n #include <rte_ether.h>\n #include <rte_gso.h>\n+\n #include \"tap_log.h\"\n \n #ifdef IFF_MULTI_QUEUE\n@@ -70,15 +71,17 @@ struct pmd_internals {\n \tchar remote_iface[RTE_ETH_NAME_MAX_LEN]; /* Remote netdevice name */\n \tchar name[RTE_ETH_NAME_MAX_LEN];  /* Internal Tap device name */\n \tint type;                         /* Type field - TUN|TAP */\n+\tint persist;\t\t\t  /* 1 if keep link up, else 0 */\n \tstruct rte_ether_addr eth_addr;   /* Mac address of the device port */\n \tstruct ifreq remote_initial_flags;/* Remote netdevice flags on init */\n \tint remote_if_index;              /* remote netdevice IF_INDEX */\n \tint if_index;                     /* IF_INDEX for the port */\n \tint ioctl_sock;                   /* socket for ioctl calls */\n+\n+#ifdef HAVE_TCA_FLOWER\n \tint nlsk_fd;                      /* Netlink socket fd */\n \tint flow_isolate;                 /* 1 if flow isolation is enabled */\n \tint rss_enabled;                  /* 1 if RSS is enabled, else 0 */\n-\tint persist;\t\t\t  /* 1 if keep link up, else 0 */\n \t/* implicit rules set when RSS is enabled */\n \tint map_fd;                       /* BPF RSS map fd */\n \tint bpf_fd[RTE_PMD_TAP_MAX_QUEUES];/* List of bpf fds per queue */\n@@ -86,6 +89,8 @@ struct pmd_internals {\n \tLIST_HEAD(tap_flows, rte_flow) flows;        /* rte_flow rules */\n \t/* implicit rte_flow rules set when a remote device is active */\n \tLIST_HEAD(tap_implicit_flows, rte_flow) implicit_flows;\n+#endif\n+\n \tstruct rx_queue rxq[RTE_PMD_TAP_MAX_QUEUES]; /* List of RX queues */\n \tstruct tx_queue txq[RTE_PMD_TAP_MAX_QUEUES]; /* List of TX queues */\n \tstruct rte_intr_handle *intr_handle;         /* LSC interrupt handle. */\ndiff --git a/drivers/net/tap/tap_bpf.h b/drivers/net/tap/tap_bpf.h\ndeleted file mode 100644\nindex 0d38bc111f..0000000000\n--- a/drivers/net/tap/tap_bpf.h\n+++ /dev/null\n@@ -1,121 +0,0 @@\n-/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0\n- * Copyright 2017 Mellanox Technologies, Ltd\n- */\n-\n-#ifndef __TAP_BPF_H__\n-#define __TAP_BPF_H__\n-\n-#include <tap_autoconf.h>\n-\n-/* Do not #include <linux/bpf.h> since eBPF must compile on different\n- * distros which may include partial definitions for eBPF (while the\n- * kernel itself may support eBPF). Instead define here all that is needed\n- */\n-\n-/* BPF_MAP_UPDATE_ELEM command flags */\n-#define\tBPF_ANY\t0 /* create a new element or update an existing */\n-\n-/* BPF architecture instruction struct */\n-struct bpf_insn {\n-\t__u8\tcode;\n-\t__u8\tdst_reg:4;\n-\t__u8\tsrc_reg:4;\n-\t__s16\toff;\n-\t__s32\timm; /* immediate value */\n-};\n-\n-/* BPF program types */\n-enum bpf_prog_type {\n-\tBPF_PROG_TYPE_UNSPEC,\n-\tBPF_PROG_TYPE_SOCKET_FILTER,\n-\tBPF_PROG_TYPE_KPROBE,\n-\tBPF_PROG_TYPE_SCHED_CLS,\n-\tBPF_PROG_TYPE_SCHED_ACT,\n-};\n-\n-/* BPF commands types */\n-enum bpf_cmd {\n-\tBPF_MAP_CREATE,\n-\tBPF_MAP_LOOKUP_ELEM,\n-\tBPF_MAP_UPDATE_ELEM,\n-\tBPF_MAP_DELETE_ELEM,\n-\tBPF_MAP_GET_NEXT_KEY,\n-\tBPF_PROG_LOAD,\n-};\n-\n-/* BPF maps types */\n-enum bpf_map_type {\n-\tBPF_MAP_TYPE_UNSPEC,\n-\tBPF_MAP_TYPE_HASH,\n-};\n-\n-/* union of anonymous structs used with TAP BPF commands */\n-union bpf_attr {\n-\t/* BPF_MAP_CREATE command */\n-\tstruct {\n-\t\t__u32\tmap_type;\n-\t\t__u32\tkey_size;\n-\t\t__u32\tvalue_size;\n-\t\t__u32\tmax_entries;\n-\t\t__u32\tmap_flags;\n-\t\t__u32\tinner_map_fd;\n-\t};\n-\n-\t/* BPF_MAP_UPDATE_ELEM, BPF_MAP_DELETE_ELEM commands */\n-\tstruct {\n-\t\t__u32\t\tmap_fd;\n-\t\t__aligned_u64\tkey;\n-\t\tunion {\n-\t\t\t__aligned_u64 value;\n-\t\t\t__aligned_u64 next_key;\n-\t\t};\n-\t\t__u64\t\tflags;\n-\t};\n-\n-\t/* BPF_PROG_LOAD command */\n-\tstruct {\n-\t\t__u32\t\tprog_type;\n-\t\t__u32\t\tinsn_cnt;\n-\t\t__aligned_u64\tinsns;\n-\t\t__aligned_u64\tlicense;\n-\t\t__u32\t\tlog_level;\n-\t\t__u32\t\tlog_size;\n-\t\t__aligned_u64\tlog_buf;\n-\t\t__u32\t\tkern_version;\n-\t\t__u32\t\tprog_flags;\n-\t};\n-} __rte_aligned(8);\n-\n-#ifndef __NR_bpf\n-# if defined(__i386__)\n-#  define __NR_bpf 357\n-# elif defined(__x86_64__)\n-#  define __NR_bpf 321\n-# elif defined(__arm__)\n-#  define __NR_bpf 386\n-# elif defined(__aarch64__)\n-#  define __NR_bpf 280\n-# elif defined(__sparc__)\n-#  define __NR_bpf 349\n-# elif defined(__s390__)\n-#  define __NR_bpf 351\n-# elif defined(__powerpc__)\n-#  define __NR_bpf 361\n-# elif defined(__riscv)\n-#  define __NR_bpf 280\n-# elif defined(__loongarch__)\n-#  define __NR_bpf 280\n-# else\n-#  error __NR_bpf not defined\n-# endif\n-#endif\n-\n-enum {\n-\tBPF_MAP_ID_KEY,\n-\tBPF_MAP_ID_SIMPLE,\n-};\n-\n-static int bpf_load(enum bpf_prog_type type, const struct bpf_insn *insns,\n-\t\tsize_t insns_cnt, const char *license);\n-\n-#endif /* __TAP_BPF_H__ */\ndiff --git a/drivers/net/tap/tap_bpf_api.c b/drivers/net/tap/tap_bpf_api.c\nindex 15283f8917..9e05e2ddf1 100644\n--- a/drivers/net/tap/tap_bpf_api.c\n+++ b/drivers/net/tap/tap_bpf_api.c\n@@ -2,19 +2,19 @@\n  * Copyright 2017 Mellanox Technologies, Ltd\n  */\n \n-#include <errno.h>\n-#include <string.h>\n #include <unistd.h>\n-#include <sys/queue.h>\n+#include <syscall.h>\n+#include <linux/bpf.h>\n \n-#include <rte_malloc.h>\n-#include <rte_eth_tap.h>\n #include <tap_flow.h>\n #include <tap_autoconf.h>\n-#include <tap_tcmsgs.h>\n-#include <tap_bpf.h>\n+\n #include <tap_bpf_insns.h>\n \n+\n+static int bpf_load(enum bpf_prog_type type, const struct bpf_insn *insns,\n+\t\tsize_t insns_cnt, const char *license);\n+\n /**\n  * Load BPF program (section cls_q) into the kernel and return a bpf fd\n  *\n@@ -89,7 +89,13 @@ static inline __u64 ptr_to_u64(const void *ptr)\n static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,\n \t\t\tunsigned int size)\n {\n+#ifdef __NR_bpf\n \treturn syscall(__NR_bpf, cmd, attr, size);\n+#else\n+\tTAP_LOG(ERR, \"No bpf syscall, kernel headers too old?\\n\");\n+\terrno = ENOSYS;\n+\treturn -1;\n+#endif\n }\n \n /**\ndiff --git a/drivers/net/tap/tap_bpf_insns.h b/drivers/net/tap/tap_bpf_insns.h\nindex 53fa76c4e6..cdf2febf05 100644\n--- a/drivers/net/tap/tap_bpf_insns.h\n+++ b/drivers/net/tap/tap_bpf_insns.h\n@@ -3,8 +3,6 @@\n  * This not the original source file. Do NOT edit it.\n  */\n \n-#include <tap_bpf.h>\n-\n static struct bpf_insn cls_q_insns[] = {\n \t{0x61,    2,    1,       52, 0x00000000},\n \t{0x18,    3,    0,        0, 0xdeadbeef},\ndiff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c\nindex 8cf64364a7..5a5a4ea048 100644\n--- a/drivers/net/tap/tap_flow.c\n+++ b/drivers/net/tap/tap_flow.c\n@@ -21,96 +21,6 @@\n #include <tap_tcmsgs.h>\n #include <tap_rss.h>\n \n-#ifndef HAVE_TC_FLOWER\n-/*\n- * For kernels < 4.2, this enum is not defined. Runtime checks will be made to\n- * avoid sending TC messages the kernel cannot understand.\n- */\n-enum {\n-\tTCA_FLOWER_UNSPEC,\n-\tTCA_FLOWER_CLASSID,\n-\tTCA_FLOWER_INDEV,\n-\tTCA_FLOWER_ACT,\n-\tTCA_FLOWER_KEY_ETH_DST,         /* ETH_ALEN */\n-\tTCA_FLOWER_KEY_ETH_DST_MASK,    /* ETH_ALEN */\n-\tTCA_FLOWER_KEY_ETH_SRC,         /* ETH_ALEN */\n-\tTCA_FLOWER_KEY_ETH_SRC_MASK,    /* ETH_ALEN */\n-\tTCA_FLOWER_KEY_ETH_TYPE,        /* be16 */\n-\tTCA_FLOWER_KEY_IP_PROTO,        /* u8 */\n-\tTCA_FLOWER_KEY_IPV4_SRC,        /* be32 */\n-\tTCA_FLOWER_KEY_IPV4_SRC_MASK,   /* be32 */\n-\tTCA_FLOWER_KEY_IPV4_DST,        /* be32 */\n-\tTCA_FLOWER_KEY_IPV4_DST_MASK,   /* be32 */\n-\tTCA_FLOWER_KEY_IPV6_SRC,        /* struct in6_addr */\n-\tTCA_FLOWER_KEY_IPV6_SRC_MASK,   /* struct in6_addr */\n-\tTCA_FLOWER_KEY_IPV6_DST,        /* struct in6_addr */\n-\tTCA_FLOWER_KEY_IPV6_DST_MASK,   /* struct in6_addr */\n-\tTCA_FLOWER_KEY_TCP_SRC,         /* be16 */\n-\tTCA_FLOWER_KEY_TCP_DST,         /* be16 */\n-\tTCA_FLOWER_KEY_UDP_SRC,         /* be16 */\n-\tTCA_FLOWER_KEY_UDP_DST,         /* be16 */\n-};\n-#endif\n-#ifndef HAVE_TC_VLAN_ID\n-enum {\n-\t/* TCA_FLOWER_FLAGS, */\n-\tTCA_FLOWER_KEY_VLAN_ID = TCA_FLOWER_KEY_UDP_DST + 2, /* be16 */\n-\tTCA_FLOWER_KEY_VLAN_PRIO,       /* u8   */\n-\tTCA_FLOWER_KEY_VLAN_ETH_TYPE,   /* be16 */\n-};\n-#endif\n-/*\n- * For kernels < 4.2 BPF related enums may not be defined.\n- * Runtime checks will be carried out to gracefully report on TC messages that\n- * are rejected by the kernel. Rejection reasons may be due to:\n- * 1. enum is not defined\n- * 2. enum is defined but kernel is not configured to support BPF system calls,\n- *    BPF classifications or BPF actions.\n- */\n-#ifndef HAVE_TC_BPF\n-enum {\n-\tTCA_BPF_UNSPEC,\n-\tTCA_BPF_ACT,\n-\tTCA_BPF_POLICE,\n-\tTCA_BPF_CLASSID,\n-\tTCA_BPF_OPS_LEN,\n-\tTCA_BPF_OPS,\n-};\n-#endif\n-#ifndef HAVE_TC_BPF_FD\n-enum {\n-\tTCA_BPF_FD = TCA_BPF_OPS + 1,\n-\tTCA_BPF_NAME,\n-};\n-#endif\n-#ifndef HAVE_TC_ACT_BPF\n-#define tc_gen \\\n-\t__u32                 index; \\\n-\t__u32                 capab; \\\n-\tint                   action; \\\n-\tint                   refcnt; \\\n-\tint                   bindcnt\n-\n-struct tc_act_bpf {\n-\ttc_gen;\n-};\n-\n-enum {\n-\tTCA_ACT_BPF_UNSPEC,\n-\tTCA_ACT_BPF_TM,\n-\tTCA_ACT_BPF_PARMS,\n-\tTCA_ACT_BPF_OPS_LEN,\n-\tTCA_ACT_BPF_OPS,\n-};\n-\n-#endif\n-#ifndef HAVE_TC_ACT_BPF_FD\n-enum {\n-\tTCA_ACT_BPF_FD = TCA_ACT_BPF_OPS + 1,\n-\tTCA_ACT_BPF_NAME,\n-};\n-#endif\n-\n /* RSS key management */\n enum bpf_rss_key_e {\n \tKEY_CMD_GET = 1,\n",
    "prefixes": [
        "v8",
        "4/8"
    ]
}