get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 78724,
    "url": "https://patches.dpdk.org/api/patches/78724/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1600949555-28043-51-git-send-email-arybchenko@solarflare.com/",
    "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": "<1600949555-28043-51-git-send-email-arybchenko@solarflare.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1600949555-28043-51-git-send-email-arybchenko@solarflare.com",
    "date": "2020-09-24T12:12:25",
    "name": "[v3,50/60] common/sfc_efx/base: support UDP tunnel operations for EF100",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "2125ba10b5280682524527e6073423d5c99ddc45",
    "submitter": {
        "id": 607,
        "url": "https://patches.dpdk.org/api/people/607/?format=api",
        "name": "Andrew Rybchenko",
        "email": "arybchenko@solarflare.com"
    },
    "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/1600949555-28043-51-git-send-email-arybchenko@solarflare.com/mbox/",
    "series": [
        {
            "id": 12473,
            "url": "https://patches.dpdk.org/api/series/12473/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=12473",
            "date": "2020-09-24T12:11:40",
            "name": "common/sfc_efx: support Riverhead NIC family",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/12473/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/78724/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/78724/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 28058A04B1;\n\tThu, 24 Sep 2020 14:21:20 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 83FC21E49D;\n\tThu, 24 Sep 2020 14:14:08 +0200 (CEST)",
            "from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com\n [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 55A261DE2F\n for <dev@dpdk.org>; Thu, 24 Sep 2020 14:13:04 +0200 (CEST)",
            "from mx1-us1.ppe-hosted.com (unknown [10.7.65.62])\n by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id\n 1F1B1600CF for <dev@dpdk.org>; Thu, 24 Sep 2020 12:13:04 +0000 (UTC)",
            "from us4-mdac16-12.ut7.mdlocal (unknown [10.7.65.236])\n by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 1CFA98009E\n for <dev@dpdk.org>; Thu, 24 Sep 2020 12:13:04 +0000 (UTC)",
            "from mx1-us1.ppe-hosted.com (unknown [10.7.65.174])\n by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id\n 763A4280050\n for <dev@dpdk.org>; Thu, 24 Sep 2020 12:13:03 +0000 (UTC)",
            "from webmail.solarflare.com (uk.solarflare.com [193.34.186.16])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))\n (No client certificate requested)\n by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id\n 2BEDA1C0069\n for <dev@dpdk.org>; Thu, 24 Sep 2020 12:13:03 +0000 (UTC)",
            "from ukex01.SolarFlarecom.com (10.17.10.4) by\n ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id\n 15.0.1497.2; Thu, 24 Sep 2020 13:12:48 +0100",
            "from opal.uk.solarflarecom.com (10.17.10.1) by\n ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id\n 15.0.1497.2 via Frontend Transport; Thu, 24 Sep 2020 13:12:48 +0100",
            "from ukv-loginhost.uk.solarflarecom.com\n (ukv-loginhost.uk.solarflarecom.com [10.17.10.39])\n by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 08OCCmUk026089;\n Thu, 24 Sep 2020 13:12:48 +0100",
            "from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1])\n by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 4FC2F1613AB;\n Thu, 24 Sep 2020 13:12:48 +0100 (BST)"
        ],
        "X-Virus-Scanned": "Proofpoint Essentials engine",
        "From": "Andrew Rybchenko <arybchenko@solarflare.com>",
        "To": "<dev@dpdk.org>",
        "CC": "Igor Romanov <igor.romanov@oktetlabs.ru>",
        "Date": "Thu, 24 Sep 2020 13:12:25 +0100",
        "Message-ID": "<1600949555-28043-51-git-send-email-arybchenko@solarflare.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1600949555-28043-1-git-send-email-arybchenko@solarflare.com>",
        "References": "<1600764594-14752-1-git-send-email-arybchenko@solarflare.com>\n <1600949555-28043-1-git-send-email-arybchenko@solarflare.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-TM-AS-Product-Ver": "SMEX-12.5.0.1300-8.6.1012-25674.003",
        "X-TM-AS-Result": "No-7.880200-8.000000-10",
        "X-TMASE-MatchedRID": "fvfYm8EmthcoS/tMLUVY9bBZAi3nrnzbMVx/3ZYby7903EU8crzuS+Z5\n Gn23AeDZuA9fFHhyLzywgcHDNo5AtPI1YbpS1+avPwKTD1v8YV5MkOX0UoduuTbpMgyAfh26u2H\n gmoVy+kry2EKN1EBlF5yUY93IDmCeO3EUo7ts5V6qNnzrkU+2mgoXSOLC5a443nbDJg0gir/vWC\n W/gP4RcCNbkVYpiM4Y57jS/hsxRY9lHEcK8cX2YMzSKGx9g8xhjs/yyyVHGh4Z9P2vDaImpqip1\n 8v0DWYVJkprB3tCGSlLBme6SEq2PUobO+54PiwGlIlVPzMCz/SwqLgRdvwAipGhAvBSa2i/1GWb\n KN8y66+EbplTnExxytQfNGn/5BppeFTBDh9n8Ezi447y/nAm6KR07tNu9vNjH1bhq4z+yfSdW2C\n /Ex2sg0fivM8BUT0x0wo2BidtLYkoNJV93bkz0GFdfLBMkul8XGjQf7uckKtZ+YxyNxdzR5dtyT\n UmkMozF3zGB4TkDtw3WFHyJFVzsIy3ARqB9bsb+ACG5oWJ7tLLRD51bz5RZJGJXR6jRFu4c4iQI\n JxbfRoLwJuN5zSpTrUrIc4nkZtOGAdnzrnkM48URSScn+QSXt0H8LFZNFG7bkV4e2xSge7I/7GZ\n nYPuf4n5sqzLqwrUBGheuLZvRK8S8HrICCVHtGA7bUFBqh2V",
        "X-TM-AS-User-Approved-Sender": "Yes",
        "X-TM-AS-User-Blocked-Sender": "No",
        "X-TMASE-Result": "10--7.880200-8.000000",
        "X-TMASE-Version": "SMEX-12.5.0.1300-8.6.1012-25674.003",
        "X-MDID": "1600949584-R09iNU8QqOwh",
        "Subject": "[dpdk-dev] [PATCH v3 50/60] common/sfc_efx/base: support UDP tunnel\n\toperations for EF100",
        "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 <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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Igor Romanov <igor.romanov@oktetlabs.ru>\n\nEF100 uses VNIC encapsulation rule MCDI for configuring UDP\ntunnels in HW individually. Use busy added and removed states\nof UDP tunnel table entries for the implementation.\n\nSigned-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>\nSigned-off-by: Andrew Rybchenko <arybchenko@solarflare.com>\nReviewed-by: Andy Moreton <amoreton@xilinx.com>\n---\n drivers/common/sfc_efx/base/ef10_filter.c  |  10 +-\n drivers/common/sfc_efx/base/efx_impl.h     |   7 +\n drivers/common/sfc_efx/base/efx_mcdi.h     |  11 +\n drivers/common/sfc_efx/base/efx_tunnel.c   |  25 +-\n drivers/common/sfc_efx/base/meson.build    |   1 +\n drivers/common/sfc_efx/base/rhead_impl.h   |  14 +\n drivers/common/sfc_efx/base/rhead_nic.c    |  17 +\n drivers/common/sfc_efx/base/rhead_tunnel.c | 343 +++++++++++++++++++++\n 8 files changed, 418 insertions(+), 10 deletions(-)\n create mode 100644 drivers/common/sfc_efx/base/rhead_tunnel.c",
    "diff": "diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c\nindex 51e6f1a210..0e5f04fe3b 100644\n--- a/drivers/common/sfc_efx/base/ef10_filter.c\n+++ b/drivers/common/sfc_efx/base/ef10_filter.c\n@@ -1328,9 +1328,15 @@ ef10_filter_supported_filters(\n \t\trc = efx_mcdi_get_parser_disp_info(enp, &buffer[next_buf_idx],\n \t\t    next_buf_length, B_TRUE, &mcdi_encap_list_length);\n \t\tif (rc != 0) {\n-\t\t\tif (rc == ENOSPC)\n+\t\t\tif (rc == ENOSPC) {\n \t\t\t\tno_space = B_TRUE;\n-\t\t\telse\n+\t\t\t} else if (rc == EINVAL) {\n+\t\t\t\t/*\n+\t\t\t\t * Do not fail if the MCDI do not recognize the\n+\t\t\t\t * query for encapsulated packet filters.\n+\t\t\t\t */\n+\t\t\t\tmcdi_encap_list_length = 0;\n+\t\t\t} else\n \t\t\t\tgoto fail2;\n \t\t} else {\n \t\t\tfor (i = next_buf_idx;\ndiff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h\nindex 1ae4eeaf88..be3f3f6bf5 100644\n--- a/drivers/common/sfc_efx/base/efx_impl.h\n+++ b/drivers/common/sfc_efx/base/efx_impl.h\n@@ -496,11 +496,18 @@ typedef enum efx_tunnel_udp_entry_state_e {\n \tEFX_TUNNEL_UDP_ENTRY_APPLIED, /* Tunnel is applied by HW */\n } efx_tunnel_udp_entry_state_t;\n \n+#if EFSYS_OPT_RIVERHEAD\n+typedef uint32_t\tefx_vnic_encap_rule_handle_t;\n+#endif /* EFSYS_OPT_RIVERHEAD */\n+\n typedef struct efx_tunnel_udp_entry_s {\n \tuint16_t\t\t\tetue_port; /* host/cpu-endian */\n \tuint16_t\t\t\tetue_protocol;\n \tboolean_t\t\t\tetue_busy;\n \tefx_tunnel_udp_entry_state_t\tetue_state;\n+#if EFSYS_OPT_RIVERHEAD\n+\tefx_vnic_encap_rule_handle_t\tetue_handle;\n+#endif /* EFSYS_OPT_RIVERHEAD */\n } efx_tunnel_udp_entry_t;\n \n typedef struct efx_tunnel_cfg_s {\ndiff --git a/drivers/common/sfc_efx/base/efx_mcdi.h b/drivers/common/sfc_efx/base/efx_mcdi.h\nindex 97ac8bf496..77a3d636e2 100644\n--- a/drivers/common/sfc_efx/base/efx_mcdi.h\n+++ b/drivers/common/sfc_efx/base/efx_mcdi.h\n@@ -384,6 +384,17 @@ efx_mcdi_phy_module_get_info(\n \t\tMC_CMD_ ## _field9, _value9,\t\t\t\t\\\n \t\tMC_CMD_ ## _field10, _value10)\n \n+/*\n+ * Native setters (MCDI_IN_SET_*_NATIVE) are used when MCDI field is in\n+ * network order to avoid conversion to little-endian that is done in\n+ * other setters.\n+ */\n+#define\tMCDI_IN_SET_WORD_NATIVE(_emr, _ofst, _value)\t\t\t\\\n+\tMCDI_IN2((_emr), efx_word_t, _ofst)->ew_u16[0] = (_value)\n+\n+#define\tMCDI_IN_SET_DWORD_NATIVE(_emr, _ofst, _value)\t\t\t\\\n+\tMCDI_IN2((_emr), efx_dword_t, _ofst)->ed_u32[0] = (_value)\n+\n #define\tMCDI_OUT(_emr, _type, _ofst)\t\t\t\t\t\\\n \t((_type *)((_emr).emr_out_buf + (_ofst)))\n \ndiff --git a/drivers/common/sfc_efx/base/efx_tunnel.c b/drivers/common/sfc_efx/base/efx_tunnel.c\nindex 204871e00d..02b83d97ed 100644\n--- a/drivers/common/sfc_efx/base/efx_tunnel.c\n+++ b/drivers/common/sfc_efx/base/efx_tunnel.c\n@@ -47,13 +47,6 @@\n \n #if EFSYS_OPT_TUNNEL\n \n-#if EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_RIVERHEAD\n-static const efx_tunnel_ops_t\t__efx_tunnel_dummy_ops = {\n-\tNULL,\t/* eto_reconfigure */\n-\tNULL,\t/* eto_fini */\n-};\n-#endif /* EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_RIVERHEAD */\n-\n #if EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2\n static\t__checkReturn\tboolean_t\n ef10_udp_encap_supported(\n@@ -66,13 +59,29 @@ ef10_tunnel_reconfigure(\n static\t\t\tvoid\n ef10_tunnel_fini(\n \t__in\t\tefx_nic_t *enp);\n+#endif /* EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */\n \n+#if EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON\n+static const efx_tunnel_ops_t\t__efx_tunnel_dummy_ops = {\n+\tNULL,\t/* eto_reconfigure */\n+\tNULL,\t/* eto_fini */\n+};\n+#endif /* EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON */\n+\n+#if EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2\n static const efx_tunnel_ops_t\t__efx_tunnel_ef10_ops = {\n \tef10_tunnel_reconfigure,\t/* eto_reconfigure */\n \tef10_tunnel_fini,\t\t/* eto_fini */\n };\n #endif /* EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */\n \n+#if EFSYS_OPT_RIVERHEAD\n+static const efx_tunnel_ops_t\t__efx_tunnel_rhead_ops = {\n+\trhead_tunnel_reconfigure,\t/* eto_reconfigure */\n+\trhead_tunnel_fini,\t\t/* eto_fini */\n+};\n+#endif /* EFSYS_OPT_RIVERHEAD */\n+\n /* Indicates that an entry is to be set */\n static\t__checkReturn\t\tboolean_t\n ef10_entry_staged(\n@@ -241,7 +250,7 @@ efx_tunnel_init(\n \n #if EFSYS_OPT_RIVERHEAD\n \tcase EFX_FAMILY_RIVERHEAD:\n-\t\tetop = &__efx_tunnel_dummy_ops;\n+\t\tetop = &__efx_tunnel_rhead_ops;\n \t\tbreak;\n #endif /* EFSYS_OPT_RIVERHEAD */\n \ndiff --git a/drivers/common/sfc_efx/base/meson.build b/drivers/common/sfc_efx/base/meson.build\nindex 21feb36c73..e0acbda993 100644\n--- a/drivers/common/sfc_efx/base/meson.build\n+++ b/drivers/common/sfc_efx/base/meson.build\n@@ -58,6 +58,7 @@ sources = [\n \t'rhead_nic.c',\n \t'rhead_pci.c',\n \t'rhead_rx.c',\n+\t'rhead_tunnel.c',\n \t'rhead_tx.c',\n ]\n \ndiff --git a/drivers/common/sfc_efx/base/rhead_impl.h b/drivers/common/sfc_efx/base/rhead_impl.h\nindex 91347c335a..4d5307d18b 100644\n--- a/drivers/common/sfc_efx/base/rhead_impl.h\n+++ b/drivers/common/sfc_efx/base/rhead_impl.h\n@@ -437,6 +437,20 @@ rhead_tx_qstats_update(\n \n #endif /* EFSYS_OPT_QSTATS */\n \n+#if EFSYS_OPT_TUNNEL\n+\n+LIBEFX_INTERNAL\n+extern\t__checkReturn\tefx_rc_t\n+rhead_tunnel_reconfigure(\n+\t__in\t\tefx_nic_t *enp);\n+\n+LIBEFX_INTERNAL\n+extern\t\t\tvoid\n+rhead_tunnel_fini(\n+\t__in\t\tefx_nic_t *enp);\n+\n+#endif /* EFSYS_OPT_TUNNEL */\n+\n #if EFSYS_OPT_PCI\n \n /*\ndiff --git a/drivers/common/sfc_efx/base/rhead_nic.c b/drivers/common/sfc_efx/base/rhead_nic.c\nindex 787afb37a3..f965c1735e 100644\n--- a/drivers/common/sfc_efx/base/rhead_nic.c\n+++ b/drivers/common/sfc_efx/base/rhead_nic.c\n@@ -22,6 +22,23 @@ rhead_board_cfg(\n \tif ((rc = efx_mcdi_nic_board_cfg(enp)) != 0)\n \t\tgoto fail1;\n \n+\t/*\n+\t * The tunnel encapsulation initialization happens unconditionally\n+\t * for now.\n+\t */\n+\tencp->enc_tunnel_encapsulations_supported =\n+\t    (1u << EFX_TUNNEL_PROTOCOL_VXLAN) |\n+\t    (1u << EFX_TUNNEL_PROTOCOL_GENEVE) |\n+\t    (1u << EFX_TUNNEL_PROTOCOL_NVGRE);\n+\n+\t/*\n+\t * Software limitation inherited from EF10. This limit is not\n+\t * increased since the hardware does not report this limit, it is\n+\t * handled internally resulting in a tunnel add error when there is no\n+\t * space for more UDP tunnels.\n+\t */\n+\tencp->enc_tunnel_config_udp_entries_max = EFX_TUNNEL_MAXNENTRIES;\n+\n \tencp->enc_clk_mult = 1; /* not used for Riverhead */\n \n \t/*\ndiff --git a/drivers/common/sfc_efx/base/rhead_tunnel.c b/drivers/common/sfc_efx/base/rhead_tunnel.c\nnew file mode 100644\nindex 0000000000..34ba074eac\n--- /dev/null\n+++ b/drivers/common/sfc_efx/base/rhead_tunnel.c\n@@ -0,0 +1,343 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ *\n+ * Copyright(c) 2020 Xilinx, Inc.\n+ */\n+\n+#include \"efx.h\"\n+#include \"efx_impl.h\"\n+\n+#if EFSYS_OPT_RIVERHEAD && EFSYS_OPT_TUNNEL\n+\n+/* Match by Ether-type */\n+#define\tEFX_VNIC_ENCAP_RULE_MATCH_ETHER_TYPE \\\n+\t(1u << MC_CMD_VNIC_ENCAP_RULE_ADD_IN_MATCH_ETHER_TYPE_LBN)\n+/* Match by outer VLAN ID */\n+#define\tEFX_VNIC_ENCAP_RULE_MATCH_OUTER_VID \\\n+\t(1u << MC_CMD_VNIC_ENCAP_RULE_ADD_IN_MATCH_OUTER_VLAN_LBN)\n+/* Match by local IP host address */\n+#define\tEFX_VNIC_ENCAP_RULE_MATCH_LOC_HOST \\\n+\t(1u << MC_CMD_VNIC_ENCAP_RULE_ADD_IN_MATCH_DST_IP_LBN)\n+/* Match by IP transport protocol */\n+#define\tEFX_VNIC_ENCAP_RULE_MATCH_IP_PROTO \\\n+\t(1u << MC_CMD_VNIC_ENCAP_RULE_ADD_IN_MATCH_IP_PROTO_LBN)\n+/* Match by local TCP/UDP port */\n+#define\tEFX_VNIC_ENCAP_RULE_MATCH_LOC_PORT \\\n+\t(1u << MC_CMD_VNIC_ENCAP_RULE_ADD_IN_MATCH_DST_PORT_LBN)\n+\n+/*\n+ * Helper structure to pass parameters to MCDI function to add a VNIC\n+ * encapsulation rule.\n+ */\n+typedef struct efx_vnic_encap_rule_spec_s {\n+\tuint32_t\t\tevers_mport_selector; /* Host-endian */\n+\tuint32_t\t\tevers_match_flags; /* Host-endian */\n+\tuint16_t\t\tevers_ether_type; /* Host-endian */\n+\tuint16_t\t\tevers_outer_vid; /* Host-endian */\n+\tefx_oword_t\t\tevers_loc_host; /* Big-endian */\n+\tuint8_t\t\t\tevers_ip_proto;\n+\tuint16_t\t\tevers_loc_port; /* Host-endian */\n+\tefx_tunnel_protocol_t\tevers_encap_type;\n+} efx_vnic_encap_rule_spec_t;\n+\n+static\t\t\t\tuint32_t\n+efx_tunnel_protocol2mae_encap_type(\n+\t__in\t\tefx_tunnel_protocol_t proto,\n+\t__out\t\tuint32_t *typep)\n+{\n+\tefx_rc_t rc;\n+\n+\tswitch (proto) {\n+\tcase EFX_TUNNEL_PROTOCOL_NONE:\n+\t\t*typep = MAE_MCDI_ENCAP_TYPE_NONE;\n+\t\tbreak;\n+\tcase EFX_TUNNEL_PROTOCOL_VXLAN:\n+\t\t*typep = MAE_MCDI_ENCAP_TYPE_VXLAN;\n+\t\tbreak;\n+\tcase EFX_TUNNEL_PROTOCOL_GENEVE:\n+\t\t*typep = MAE_MCDI_ENCAP_TYPE_GENEVE;\n+\t\tbreak;\n+\tcase EFX_TUNNEL_PROTOCOL_NVGRE:\n+\t\t*typep = MAE_MCDI_ENCAP_TYPE_NVGRE;\n+\t\tbreak;\n+\tdefault:\n+\t\trc = EINVAL;\n+\t\tgoto fail1;\n+\t}\n+\n+\treturn (0);\n+\n+fail1:\n+\tEFSYS_PROBE1(fail1, efx_rc_t, rc);\n+\n+\treturn (rc);\n+}\n+\n+static\t__checkReturn\t\tefx_rc_t\n+efx_mcdi_vnic_encap_rule_add(\n+\t__in\t\t\tefx_nic_t *enp,\n+\t__in\t\t\tconst efx_vnic_encap_rule_spec_t *spec,\n+\t__out\t\t\tefx_vnic_encap_rule_handle_t *handle)\n+\n+{\n+\tefx_mcdi_req_t req;\n+\tEFX_MCDI_DECLARE_BUF(payload,\n+\t\tMC_CMD_VNIC_ENCAP_RULE_ADD_IN_LEN,\n+\t\tMC_CMD_VNIC_ENCAP_RULE_ADD_OUT_LEN);\n+\tuint32_t encap_type;\n+\tefx_rc_t rc;\n+\n+\treq.emr_cmd = MC_CMD_VNIC_ENCAP_RULE_ADD;\n+\treq.emr_in_buf = payload;\n+\treq.emr_in_length = MC_CMD_VNIC_ENCAP_RULE_ADD_IN_LEN;\n+\treq.emr_out_buf = payload;\n+\treq.emr_out_length = MC_CMD_VNIC_ENCAP_RULE_ADD_OUT_LEN;\n+\n+\tMCDI_IN_SET_DWORD(req, VNIC_ENCAP_RULE_ADD_IN_MPORT_SELECTOR,\n+\t    spec->evers_mport_selector);\n+\tMCDI_IN_SET_DWORD(req, VNIC_ENCAP_RULE_ADD_IN_MATCH_FLAGS,\n+\t    spec->evers_match_flags);\n+\n+\tMCDI_IN_SET_WORD_NATIVE(req, VNIC_ENCAP_RULE_ADD_IN_ETHER_TYPE,\n+\t    __CPU_TO_BE_16(spec->evers_ether_type));\n+\tMCDI_IN_SET_WORD_NATIVE(req, VNIC_ENCAP_RULE_ADD_IN_OUTER_VLAN_WORD,\n+\t    __CPU_TO_BE_16(spec->evers_outer_vid));\n+\n+\t/*\n+\t * Address is already in network order as well as the MCDI field,\n+\t * so plain copy is used.\n+\t */\n+\tEFX_STATIC_ASSERT(sizeof (spec->evers_loc_host) ==\n+\t    MC_CMD_VNIC_ENCAP_RULE_ADD_IN_DST_IP_LEN);\n+\tmemcpy(MCDI_IN2(req, uint8_t, VNIC_ENCAP_RULE_ADD_IN_DST_IP),\n+\t    &spec->evers_loc_host.eo_byte[0],\n+\t    MC_CMD_VNIC_ENCAP_RULE_ADD_IN_DST_IP_LEN);\n+\n+\tMCDI_IN_SET_BYTE(req, VNIC_ENCAP_RULE_ADD_IN_IP_PROTO,\n+\t    spec->evers_ip_proto);\n+\tMCDI_IN_SET_WORD_NATIVE(req, VNIC_ENCAP_RULE_ADD_IN_DST_PORT,\n+\t    __CPU_TO_BE_16(spec->evers_loc_port));\n+\n+\trc = efx_tunnel_protocol2mae_encap_type(spec->evers_encap_type,\n+\t    &encap_type);\n+\tif (rc != 0)\n+\t\tgoto fail1;\n+\n+\tMCDI_IN_SET_DWORD(req, VNIC_ENCAP_RULE_ADD_IN_ENCAP_TYPE, encap_type);\n+\n+\tefx_mcdi_execute(enp, &req);\n+\n+\tif (req.emr_rc != 0) {\n+\t\trc = req.emr_rc;\n+\t\tgoto fail2;\n+\t}\n+\n+\tif (req.emr_out_length_used != MC_CMD_VNIC_ENCAP_RULE_ADD_OUT_LEN) {\n+\t\trc = EMSGSIZE;\n+\t\tgoto fail3;\n+\t}\n+\n+\tif (handle != NULL)\n+\t\t*handle = MCDI_OUT_DWORD(req, VNIC_ENCAP_RULE_ADD_OUT_HANDLE);\n+\n+\treturn (0);\n+\n+fail3:\n+\tEFSYS_PROBE(fail3);\n+\n+fail2:\n+\tEFSYS_PROBE(fail2);\n+\n+fail1:\n+\tEFSYS_PROBE1(fail1, efx_rc_t, rc);\n+\n+\treturn (rc);\n+}\n+\n+static\t__checkReturn\t\tefx_rc_t\n+efx_mcdi_vnic_encap_rule_remove(\n+\t__in\t\t\tefx_nic_t *enp,\n+\t__in\t\t\tefx_vnic_encap_rule_handle_t handle)\n+\n+{\n+\tefx_mcdi_req_t req;\n+\tEFX_MCDI_DECLARE_BUF(payload,\n+\t    MC_CMD_VNIC_ENCAP_RULE_REMOVE_IN_LEN,\n+\t    MC_CMD_VNIC_ENCAP_RULE_REMOVE_OUT_LEN);\n+\tefx_rc_t rc;\n+\n+\treq.emr_cmd = MC_CMD_VNIC_ENCAP_RULE_REMOVE;\n+\treq.emr_in_buf = payload;\n+\treq.emr_in_length = MC_CMD_VNIC_ENCAP_RULE_REMOVE_IN_LEN;\n+\treq.emr_out_buf = payload;\n+\treq.emr_out_length = MC_CMD_VNIC_ENCAP_RULE_REMOVE_OUT_LEN;\n+\n+\tMCDI_IN_SET_DWORD(req, VNIC_ENCAP_RULE_REMOVE_IN_HANDLE, handle);\n+\n+\tefx_mcdi_execute(enp, &req);\n+\n+\tif (req.emr_rc != 0) {\n+\t\trc = req.emr_rc;\n+\t\tgoto fail1;\n+\t}\n+\n+\tif (req.emr_out_length_used != MC_CMD_VNIC_ENCAP_RULE_REMOVE_OUT_LEN) {\n+\t\trc = EMSGSIZE;\n+\t\tgoto fail2;\n+\t}\n+\n+\treturn (0);\n+\n+fail2:\n+\tEFSYS_PROBE(fail2);\n+\n+fail1:\n+\tEFSYS_PROBE1(fail1, efx_rc_t, rc);\n+\n+\treturn (rc);\n+}\n+\n+static\t\t\tvoid\n+rhead_vnic_encap_rule_spec_init(\n+\t__in\t\tconst efx_tunnel_udp_entry_t *etuep,\n+\t__out\t\tefx_vnic_encap_rule_spec_t *spec)\n+{\n+\tmemset(spec, 0, sizeof (*spec));\n+\n+\tspec->evers_mport_selector = MAE_MPORT_SELECTOR_ASSIGNED;\n+\tspec->evers_match_flags = EFX_VNIC_ENCAP_RULE_MATCH_IP_PROTO |\n+\t    EFX_VNIC_ENCAP_RULE_MATCH_LOC_PORT;\n+\tspec->evers_ip_proto = EFX_IPPROTO_UDP;\n+\tspec->evers_loc_port = etuep->etue_port;\n+\tspec->evers_encap_type = etuep->etue_protocol;\n+}\n+\n+static\t__checkReturn\tefx_rc_t\n+rhead_udp_port_tunnel_add(\n+\t__in\t\tefx_nic_t *enp,\n+\t__inout\t\tefx_tunnel_udp_entry_t *etuep)\n+{\n+\tefx_vnic_encap_rule_spec_t spec;\n+\n+\trhead_vnic_encap_rule_spec_init(etuep, &spec);\n+\treturn (efx_mcdi_vnic_encap_rule_add(enp, &spec, &etuep->etue_handle));\n+}\n+\n+static\t__checkReturn\tefx_rc_t\n+rhead_udp_port_tunnel_remove(\n+\t__in\t\tefx_nic_t *enp,\n+\t__in\t\tefx_tunnel_udp_entry_t *etuep)\n+{\n+\treturn (efx_mcdi_vnic_encap_rule_remove(enp, etuep->etue_handle));\n+}\n+\n+\t__checkReturn\tefx_rc_t\n+rhead_tunnel_reconfigure(\n+\t__in\t\tefx_nic_t *enp)\n+{\n+\tefx_tunnel_cfg_t *etcp = &enp->en_tunnel_cfg;\n+\tefx_rc_t rc;\n+\tefsys_lock_state_t state;\n+\tefx_tunnel_cfg_t etc;\n+\tefx_tunnel_cfg_t added;\n+\tunsigned int i;\n+\tunsigned int j;\n+\n+\tmemset(&added, 0, sizeof(added));\n+\n+\t/*\n+\t * Make a local copy of UDP tunnel table to release the lock\n+\t * when executing MCDIs.\n+\t */\n+\tEFSYS_LOCK(enp->en_eslp, state);\n+\tmemcpy(&etc, etcp, sizeof (etc));\n+\tEFSYS_UNLOCK(enp->en_eslp, state);\n+\n+\tfor (i = 0; i < etc.etc_udp_entries_num; i++) {\n+\t\tefx_tunnel_udp_entry_t *etc_entry = &etc.etc_udp_entries[i];\n+\n+\t\tif (etc_entry->etue_busy == B_FALSE)\n+\t\t\tcontinue;\n+\n+\t\tswitch (etc_entry->etue_state) {\n+\t\tcase EFX_TUNNEL_UDP_ENTRY_APPLIED:\n+\t\t\tbreak;\n+\t\tcase EFX_TUNNEL_UDP_ENTRY_ADDED:\n+\t\t\trc = rhead_udp_port_tunnel_add(enp, etc_entry);\n+\t\t\tif (rc != 0)\n+\t\t\t\tgoto fail1;\n+\t\t\tadded.etc_udp_entries[added.etc_udp_entries_num] =\n+\t\t\t    *etc_entry;\n+\t\t\tadded.etc_udp_entries_num++;\n+\t\t\tbreak;\n+\t\tcase EFX_TUNNEL_UDP_ENTRY_REMOVED:\n+\t\t\trc = rhead_udp_port_tunnel_remove(enp, etc_entry);\n+\t\t\tif (rc != 0)\n+\t\t\t\tgoto fail2;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tEFSYS_ASSERT(0);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tEFSYS_LOCK(enp->en_eslp, state);\n+\n+\t/*\n+\t * Adding or removing non-busy entries does not change the\n+\t * order of busy entries. Therefore one linear search iteration\n+\t * suffices.\n+\t */\n+\tfor (i = 0, j = 0; i < etcp->etc_udp_entries_num; i++) {\n+\t\tefx_tunnel_udp_entry_t *cur_entry = &etcp->etc_udp_entries[i];\n+\t\tefx_tunnel_udp_entry_t *added_entry = &added.etc_udp_entries[j];\n+\n+\t\tif (cur_entry->etue_state == EFX_TUNNEL_UDP_ENTRY_ADDED &&\n+\t\t    cur_entry->etue_port == added_entry->etue_port) {\n+\t\t\tcur_entry->etue_handle = added_entry->etue_handle;\n+\t\t\tj++;\n+\t\t}\n+\t}\n+\n+\tEFSYS_UNLOCK(enp->en_eslp, state);\n+\n+\treturn (0);\n+\n+fail2:\n+\tEFSYS_PROBE(fail2);\n+\n+fail1:\n+\tEFSYS_PROBE1(fail1, efx_rc_t, rc);\n+\n+\twhile (i-- > 0) {\n+\t\tif (etc.etc_udp_entries[i].etue_busy == B_FALSE)\n+\t\t\tcontinue;\n+\n+\t\tswitch (etc.etc_udp_entries[i].etue_state) {\n+\t\tcase EFX_TUNNEL_UDP_ENTRY_APPLIED:\n+\t\t\tbreak;\n+\t\tcase EFX_TUNNEL_UDP_ENTRY_ADDED:\n+\t\t\t(void) rhead_udp_port_tunnel_remove(enp,\n+\t\t\t\t\t&etc.etc_udp_entries[i]);\n+\t\t\tbreak;\n+\t\tcase EFX_TUNNEL_UDP_ENTRY_REMOVED:\n+\t\t\t(void) rhead_udp_port_tunnel_add(enp,\n+\t\t\t\t\t&etc.etc_udp_entries[i]);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tEFSYS_ASSERT(0);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\treturn (rc);\n+}\n+\n+\t\t\tvoid\n+rhead_tunnel_fini(\n+\t__in\t\tefx_nic_t *enp)\n+{\n+\t(void) efx_tunnel_config_clear(enp);\n+\t(void) efx_tunnel_reconfigure(enp);\n+}\n+\n+#endif\t/* EFSYS_OPT_RIVERHEAD && EFSYS_OPT_TUNNEL */\n",
    "prefixes": [
        "v3",
        "50/60"
    ]
}