get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 45804,
    "url": "http://patchwork.dpdk.org/api/patches/45804/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1538461807-37507-5-git-send-email-viacheslavo@mellanox.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<1538461807-37507-5-git-send-email-viacheslavo@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1538461807-37507-5-git-send-email-viacheslavo@mellanox.com",
    "date": "2018-10-02T06:30:42",
    "name": "[5/5] net/mlx5: e-switch VXLAN tunnel devices management",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "6b88e0c6c3e3903eab9cc6bfcf32d7d9624f7aaf",
    "submitter": {
        "id": 1102,
        "url": "http://patchwork.dpdk.org/api/people/1102/?format=api",
        "name": "Slava Ovsiienko",
        "email": "viacheslavo@mellanox.com"
    },
    "delegate": {
        "id": 6624,
        "url": "http://patchwork.dpdk.org/api/users/6624/?format=api",
        "username": "shahafs",
        "first_name": "Shahaf",
        "last_name": "Shuler",
        "email": "shahafs@mellanox.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1538461807-37507-5-git-send-email-viacheslavo@mellanox.com/mbox/",
    "series": [
        {
            "id": 1626,
            "url": "http://patchwork.dpdk.org/api/series/1626/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=1626",
            "date": "2018-10-02T06:30:36",
            "name": null,
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/1626/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/45804/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/45804/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 64B2E4CB3;\n\tTue,  2 Oct 2018 08:30:46 +0200 (CEST)",
            "from EUR02-AM5-obe.outbound.protection.outlook.com\n\t(mail-eopbgr00073.outbound.protection.outlook.com [40.107.0.73])\n\tby dpdk.org (Postfix) with ESMTP id AD66A4D3A\n\tfor <dev@dpdk.org>; Tue,  2 Oct 2018 08:30:43 +0200 (CEST)",
            "from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by\n\tAM4PR05MB3284.eurprd05.prod.outlook.com (10.171.186.157) with\n\tMicrosoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\t15.20.1185.22; Tue, 2 Oct 2018 06:30:42 +0000",
            "from AM4PR05MB3265.eurprd05.prod.outlook.com\n\t([fe80::81a1:b719:2345:50e5]) by\n\tAM4PR05MB3265.eurprd05.prod.outlook.com\n\t([fe80::81a1:b719:2345:50e5%5]) with mapi id 15.20.1185.024;\n\tTue, 2 Oct 2018 06:30:42 +0000"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com;\n\ts=selector1;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=qdlpXxt+XYi6k2UZ/mmLdPvjnX1dQJqx9OiOVckhrsQ=;\n\tb=eC7la7d5lA/ypUaH9XgVNhBZTKphVayMUvPeSGLBO2Hsa9MxDSO4zgNrT3nxmZwArikpi9i4OjoMticdThqek2nO81p+HL0Uv06M7Om6PtCXMipHTSAjlRBuWUymtf9jsdaFtcv2pdu++xvJYPjIX9gXKIwUpE1uDJIY73sSF+U=",
        "From": "Slava Ovsiienko <viacheslavo@mellanox.com>",
        "To": "\"dev@dpdk.org\" <dev@dpdk.org>",
        "CC": "Shahaf Shuler <shahafs@mellanox.com>, Slava Ovsiienko\n\t<viacheslavo@mellanox.com>",
        "Thread-Topic": "[PATCH 5/5] net/mlx5: e-switch VXLAN tunnel devices management",
        "Thread-Index": "AQHUWhlxq79e/tSVaEucP+fG+hh4Dg==",
        "Date": "Tue, 2 Oct 2018 06:30:42 +0000",
        "Message-ID": "<1538461807-37507-5-git-send-email-viacheslavo@mellanox.com>",
        "References": "<1538461807-37507-1-git-send-email-viacheslavo@mellanox.com>",
        "In-Reply-To": "<1538461807-37507-1-git-send-email-viacheslavo@mellanox.com>",
        "Accept-Language": "en-US",
        "Content-Language": "en-US",
        "X-MS-Has-Attach": "",
        "X-MS-TNEF-Correlator": "",
        "x-clientproxiedby": "AM0PR02CA0019.eurprd02.prod.outlook.com\n\t(2603:10a6:208:3e::32) To AM4PR05MB3265.eurprd05.prod.outlook.com\n\t(2603:10a6:205:4::22)",
        "authentication-results": "spf=none (sender IP is )\n\tsmtp.mailfrom=viacheslavo@mellanox.com; ",
        "x-ms-exchange-messagesentrepresentingtype": "1",
        "x-originating-ip": "[37.142.13.130]",
        "x-ms-publictraffictype": "Email",
        "x-microsoft-exchange-diagnostics": "1; AM4PR05MB3284;\n\t6:V+KhsqPh7IJsMFZKCq6C3Bg5ssPxUfR3vzJEYOaJwYRlHzuFStT6tU1trtfFbVCBBVLpCwGFvGv2DXCakTY3/k7F07vD62Bec1GMZdP4yGmHr4LQuxG8k708MiWZOvRKQejMAMmVu5fW71JkSiNxt7QUUOV18cmOlOuKxHNkb1yndqpS/gmZ0V8PjWEY+ELb1ttafhmK2957FDFpEUEdTwS7x9MH97tvWYAt/qSknwZWyVn4g658DKJhYOne8PoqhgPJAtxbT1knv49QzAAHtHbsGmsWcfDM+DevveZHvuf4YkNkVOzTxcSisTezF94wzH43rZPHMC2YuHsvpUYWl7XQnURoT9rxXI95ez4Yx+8bnfx6lPkKefF9dKJtAiyN/9RU3pW9tIn4OUW18NKkIDXHv33xB0og7AHWIr9sJLG2snZau+Fuw+62dpfxRSSsUuhNYKjSUmHB8rVS5Qa/VQ==;\n\t5:upWyKs6PgrQ6TuyQJnFFS55zhQ19Jem5lzrckR4kj2AV1Jc0cJ52ZIZf3h4M80jI9gDeMHpbxoKoXGHENs8Bj0bwVUYPAn5T69u8PZu2tp8nCp3/IhwwwTvq32ssHewXgOl6Hqr7WTYqoHZkqVelAZX8gQewe86cop14eG7HZlc=;\n\t7:M7SdFbpCjL7hiYa1KM5bV3D2Ox3Fp3fru5AZ0r94iZOt7u1vAvpaUWOljorffZULTqF3jeJEoxAXDKrJql1mFKBWViHHoc3VHEk8W9evOZ/EbHThJCL3MgqRAyTgplCbgGVcKWSwkeu1WJRuw8PBCpeee1Tc+eVSIpG2lwy9B5ziPiNNb/mJMb0Q7g/iWbV6PNpbtoINmeXJydGLg4fbVfMUZZb+mjjN3EyJXP448xj4FV2pA8e9Hd1/4JKqt9Ga",
        "x-ms-office365-filtering-correlation-id": "3bd80dd8-f4d9-48eb-6bd0-08d628309377",
        "x-ms-office365-filtering-ht": "Tenant",
        "x-microsoft-antispam": "BCL:0; PCL:0;\n\tRULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);\n\tSRVR:AM4PR05MB3284; ",
        "x-ms-traffictypediagnostic": "AM4PR05MB3284:",
        "x-microsoft-antispam-prvs": "<AM4PR05MB3284FABFE3F5F720D49583B3D2E80@AM4PR05MB3284.eurprd05.prod.outlook.com>",
        "x-exchange-antispam-report-test": "UriScan:(211171220733660)(788757137089);",
        "x-ms-exchange-senderadcheck": "1",
        "x-exchange-antispam-report-cfa-test": "BCL:0; PCL:0;\n\tRULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051);\n\tSRVR:AM4PR05MB3284; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3284; ",
        "x-forefront-prvs": "0813C68E65",
        "x-forefront-antispam-report": "SFV:NSPM;\n\tSFS:(10009020)(346002)(376002)(366004)(396003)(136003)(39860400002)(189003)(199004)(386003)(97736004)(186003)(26005)(52116002)(6512007)(36756003)(6506007)(2351001)(99286004)(6916009)(68736007)(446003)(3846002)(305945005)(6116002)(7736002)(102836004)(76176011)(11346002)(5640700003)(486006)(86362001)(5660300001)(2616005)(476003)(2900100001)(106356001)(316002)(1730700003)(25786009)(478600001)(81166006)(81156014)(5250100002)(2501003)(54906003)(6436002)(8936002)(14444005)(71200400001)(71190400001)(2906002)(107886003)(8676002)(256004)(66066001)(4326008)(14454004)(6486002)(105586002)(53936002)(4744004);\n\tDIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3284;\n\tH:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en;\n\tPTR:InfoNoRecords; MX:1; A:1; ",
        "received-spf": "None (protection.outlook.com: mellanox.com does not designate\n\tpermitted sender hosts)",
        "x-microsoft-antispam-message-info": "mwAzW31/BOvqbYp1gz7YskUtkMWwndqyxdQPRh874B/NelC4faQQ7Ts4iK+6M9OqoTxE2QSxkBjl8mH6ru2JJRLXOUlD14WQSsl1aUrAdNHX9xjFnBUEwFs7ypJbafjS5sWcXzAB6ItEfYIoIqngaKXRviNhxUeEv58zPaPEkfPjUHBRV9jzu6A3TIKaqKJhZAsArCuoFWqZUgWJMIpl24ESn9rqSWQbIV4uvdVN+a+LbZTMApIbpfem6w05f8qyIkpc8vnIBYQU70B2xmHHXiJGEl11dFlV7Oy5cZnjAjDAlHujVs8Z4VjKp2zkP0nDHdUV/uVddH57RlBHvbfF+Csr7rsn+iUI3GXSQ+MRWjc=",
        "spamdiagnosticoutput": "1:99",
        "spamdiagnosticmetadata": "NSPM",
        "Content-Type": "text/plain; charset=\"iso-8859-1\"",
        "Content-Transfer-Encoding": "quoted-printable",
        "MIME-Version": "1.0",
        "X-OriginatorOrg": "Mellanox.com",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "3bd80dd8-f4d9-48eb-6bd0-08d628309377",
        "X-MS-Exchange-CrossTenant-originalarrivaltime": "02 Oct 2018 06:30:42.0264\n\t(UTC)",
        "X-MS-Exchange-CrossTenant-fromentityheader": "Hosted",
        "X-MS-Exchange-CrossTenant-id": "a652971c-7d2e-4d9b-a6a4-d149256f461b",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "AM4PR05MB3284",
        "Subject": "[dpdk-dev] [PATCH 5/5] net/mlx5: e-switch VXLAN tunnel devices\n\tmanagement",
        "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": "VXLAN interfaces are dynamically created for each local UDP port\nof outer networks and then used as targets for TC \"flower\" filters\nin order to perform encapsulation. These VXLAN interfaces are\nsystem-wide, the only one device with given UDP port can exist\nin the system (the attempt of creating another device with the\nsame UDP local port returns EEXIST), so PMD should support the\nshared device instances database for PMD instances. These VXLAN\nimplicitly created devices are called VTEPs (Virtual Tunnel\nEnd Points).\n\nCreation of the VTEP occurs at the moment of rule applying. The\nlink is set up, root ingress qdisc is also initialized. One VTEP\nis shared for all encapsulation rules in the DPDK application\ninstance. For decapsulaton one VTEP is created per every unique\nUDP local port to accept tunnel traffic. The name of created\nVTEP consists of prefix \"vmlx_\" and the number of UDP port in\ndecimal digits without leading zeros (vmlx_4789). The VTEP\ncan be preliminary created in the system before the launching\napplication, it allows to share UDP ports between primary and\nsecondary processes.\n\nSuggested-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>\nSigned-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>\n---\n drivers/net/mlx5/mlx5_flow_tcf.c | 344 ++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 343 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c\nindex dfffc50..0e62fe9 100644\n--- a/drivers/net/mlx5/mlx5_flow_tcf.c\n+++ b/drivers/net/mlx5/mlx5_flow_tcf.c\n@@ -1482,7 +1482,7 @@ struct flow_tcf_ptoi {\n \t\tdefault:\n \t\t\treturn rte_flow_error_set(error, ENOTSUP,\n \t\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ITEM,\n-\t\t\t\t\t\t  NULL, \"item not supported\");\n+\t\t\t\t\t\t  items, \"item not supported\");\n \t\t}\n \t}\n \tfor (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {\n@@ -2886,6 +2886,291 @@ struct flow_tcf_ptoi {\n \treturn 0;\n }\n \n+/* VTEP device list is shared between PMD port instances. */\n+static LIST_HEAD(, mlx5_flow_tcf_vtep)\n+\t\t\tvtep_list_vxlan = LIST_HEAD_INITIALIZER();\n+static pthread_mutex_t vtep_list_mutex = PTHREAD_MUTEX_INITIALIZER;\n+static struct mlx5_flow_tcf_vtep *vtep_encap;\n+\n+/**\n+ * Deletes VTEP network device.\n+ *\n+ * @param[in] tcf\n+ *   Context object initialized by mlx5_flow_tcf_socket_open().\n+ * @param[in] vtep\n+ *   Flow tcf object with tunnel device structure to delete.\n+ */\n+static void\n+flow_tcf_delete_iface(struct mlx5_tcf_socket *tcf,\n+\t\t      struct mlx5_flow_tcf_vtep *vtep)\n+{\n+\tstruct nlmsghdr *nlh;\n+\tstruct ifinfomsg *ifm;\n+\talignas(struct nlmsghdr)\n+\tuint8_t buf[mnl_nlmsg_size(MNL_ALIGN(sizeof(*ifm))) + 8];\n+\tint ret;\n+\n+\tDRV_LOG(NOTICE, \"VTEP delete (%d)\", vtep->port);\n+\tnlh = mnl_nlmsg_put_header(buf);\n+\tnlh->nlmsg_type = RTM_DELLINK;\n+\tnlh->nlmsg_flags = NLM_F_REQUEST;\n+\tifm = mnl_nlmsg_put_extra_header(nlh, sizeof(*ifm));\n+\tifm->ifi_family = AF_UNSPEC;\n+\tifm->ifi_index = vtep->ifindex;\n+\tret = flow_tcf_nl_ack(tcf, nlh);\n+\tif (ret)\n+\t\tDRV_LOG(DEBUG, \"error deleting VXLAN encap/decap ifindex %u\",\n+\t\t\tifm->ifi_index);\n+}\n+\n+/**\n+ * Creates VTEP network device.\n+ *\n+ * @param[in] tcf\n+ *   Context object initialized by mlx5_flow_tcf_socket_open().\n+ * @param[in] port\n+ *   UDP port of created VTEP device.\n+ * @param[out] error\n+ *   Perform verbose error reporting if not NULL.\n+ *\n+ * @return\n+ * Pointer to created device structure on success, NULL otherwise\n+ * and rte_errno is set.\n+ */\n+static struct mlx5_flow_tcf_vtep*\n+flow_tcf_create_iface(struct mlx5_tcf_socket *tcf, uint16_t port,\n+\t\t      struct rte_flow_error *error)\n+{\n+\tstruct mlx5_flow_tcf_vtep *vtep;\n+\tstruct nlmsghdr *nlh;\n+\tstruct ifinfomsg *ifm;\n+\talignas(struct nlmsghdr)\n+\tchar name[sizeof(MLX5_VXLAN_DEVICE_PFX) + 24];\n+\tuint8_t buf[mnl_nlmsg_size(sizeof(*ifm)) +\n+\t\t       SZ_NLATTR_DATA_OF(sizeof(name)) +\n+\t\t       SZ_NLATTR_NEST * 2 +\n+\t\t       SZ_NLATTR_STRZ_OF(\"vxlan\") +\n+\t\t       SZ_NLATTR_TYPE_OF_UINT32 +\n+\t\t       SZ_NLATTR_TYPE_OF_UINT16 +\n+\t\t       SZ_NLATTR_TYPE_OF_UINT8 + 128];\n+\tstruct nlattr *na_info;\n+\tstruct nlattr *na_vxlan;\n+\trte_be16_t vxlan_port = RTE_BE16(port);\n+\tint ret;\n+\n+\tvtep = rte_zmalloc(__func__, sizeof(*vtep),\n+\t\t\talignof(struct mlx5_flow_tcf_vtep));\n+\tif (!vtep) {\n+\t\trte_flow_error_set\n+\t\t\t(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t NULL, \"unadble to allocate memory for VTEP desc\");\n+\t\treturn NULL;\n+\t}\n+\t*vtep = (struct mlx5_flow_tcf_vtep){\n+\t\t\t.refcnt = 0,\n+\t\t\t.port = port,\n+\t\t\t.notcreated = 0,\n+\t};\n+\tmemset(buf, 0, sizeof(buf));\n+\tnlh = mnl_nlmsg_put_header(buf);\n+\tnlh->nlmsg_type = RTM_NEWLINK;\n+\tnlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE  | NLM_F_EXCL;\n+\tifm = mnl_nlmsg_put_extra_header(nlh, sizeof(*ifm));\n+\tifm->ifi_family = AF_UNSPEC;\n+\tifm->ifi_type = 0;\n+\tifm->ifi_index = 0;\n+\tifm->ifi_flags = IFF_UP;\n+\tifm->ifi_change = 0xffffffff;\n+\tsnprintf(name, sizeof(name), \"%s%u\", MLX5_VXLAN_DEVICE_PFX, port);\n+\tmnl_attr_put_strz(nlh, IFLA_IFNAME, name);\n+\tna_info = mnl_attr_nest_start(nlh, IFLA_LINKINFO);\n+\tassert(na_info);\n+\tmnl_attr_put_strz(nlh, IFLA_INFO_KIND, \"vxlan\");\n+\tna_vxlan = mnl_attr_nest_start(nlh, IFLA_INFO_DATA);\n+\tassert(na_vxlan);\n+\tmnl_attr_put_u8(nlh, IFLA_VXLAN_COLLECT_METADATA, 1);\n+\tmnl_attr_put_u8(nlh, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, 1);\n+\tmnl_attr_put_u8(nlh, IFLA_VXLAN_LEARNING, 0);\n+\tmnl_attr_put_u16(nlh, IFLA_VXLAN_PORT, vxlan_port);\n+\tmnl_attr_nest_end(nlh, na_vxlan);\n+\tmnl_attr_nest_end(nlh, na_info);\n+\tassert(sizeof(buf) >= nlh->nlmsg_len);\n+\tret = flow_tcf_nl_ack(tcf, nlh);\n+\tif (ret) {\n+\t\tDRV_LOG(WARNING,\n+\t\t\t\"VTEP %s create failure (%d)\",\n+\t\t\tname, rte_errno);\n+\t\tvtep->notcreated = 1; /* Assume the device exists. */\n+\t}\n+\tret = if_nametoindex(name);\n+\tif (ret) {\n+\t\tvtep->ifindex = ret;\n+\t\tmemset(buf, 0, sizeof(buf));\n+\t\tnlh = mnl_nlmsg_put_header(buf);\n+\t\tnlh->nlmsg_type = RTM_NEWLINK;\n+\t\tnlh->nlmsg_flags = NLM_F_REQUEST;\n+\t\tifm = mnl_nlmsg_put_extra_header(nlh, sizeof(*ifm));\n+\t\tifm->ifi_family = AF_UNSPEC;\n+\t\tifm->ifi_type = 0;\n+\t\tifm->ifi_index = vtep->ifindex;\n+\t\tifm->ifi_flags = IFF_UP;\n+\t\tifm->ifi_change = IFF_UP;\n+\t\tret = flow_tcf_nl_ack(tcf, nlh);\n+\t\tif (ret) {\n+\t\t\tDRV_LOG(WARNING,\n+\t\t\t\"VTEP %s set link up failure (%d)\", name, rte_errno);\n+\t\t\trte_free(vtep);\n+\t\t\trte_flow_error_set\n+\t\t\t\t(error, -errno,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t \"netlink: failed to set VTEP link up\");\n+\t\t\tvtep = NULL;\n+\t\t} else {\n+\t\t\tret = mlx5_flow_tcf_ifindex_init(tcf,\n+\t\t\t\t\t\t\t vtep->ifindex, error);\n+\t\t\tif (ret)\n+\t\t\t\tDRV_LOG(WARNING,\n+\t\t\t\t\"VTEP %s init failure (%d)\", name, rte_errno);\n+\t\t}\n+\t} else {\n+\t\tDRV_LOG(WARNING,\n+\t\t\t\"VTEP %s failed to get index (%d)\", name, errno);\n+\t\trte_flow_error_set\n+\t\t\t(error, -errno,\n+\t\t\t RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t vtep->notcreated ? \"netlink: failed to create VTEP\" :\n+\t\t\t \"netlink: failed to retrieve VTEP ifindex\");\n+\t\t\t ret = 1;\n+\t}\n+\tif (ret) {\n+\t\tif (!vtep->notcreated && vtep->ifindex)\n+\t\t\tflow_tcf_delete_iface(tcf, vtep);\n+\t\trte_free(vtep);\n+\t\tvtep = NULL;\n+\t}\n+\tDRV_LOG(NOTICE, \"VTEP create (%d, %s)\", vtep->port, vtep ? \"OK\" : \"error\");\n+\treturn vtep;\n+}\n+\n+/**\n+ * Creates target interface index for tunneling.\n+ *\n+ * @param tcf\n+ *   Context object initialized by mlx5_flow_tcf_socket_open().\n+ * @param[in] dev_flow\n+ *   Flow tcf object with tunnel structure pointer set.\n+ * @param[out] error\n+ *   Perform verbose error reporting if not NULL.\n+ *\n+ * @return\n+ *   Interface index on success, zero otherwise and rte_errno is set.\n+ */\n+static unsigned int\n+flow_tcf_tunnel_vtep_create(struct mlx5_tcf_socket *tcf,\n+\t\t\t    struct mlx5_flow *dev_flow,\n+\t\t\t    struct rte_flow_error *error)\n+{\n+\tunsigned int ret;\n+\n+\tassert(dev_flow->tcf.tunnel);\n+\tpthread_mutex_lock(&vtep_list_mutex);\n+\tswitch (dev_flow->tcf.tunnel->type) {\n+\tcase MLX5_FLOW_TCF_TUNACT_VXLAN_ENCAP:\n+\t\tif (!vtep_encap) {\n+\t\t\tvtep_encap = flow_tcf_create_iface(tcf,\n+\t\t\t\tMLX5_VXLAN_DEFAULT_PORT, error);\n+\t\t\tif (!vtep_encap) {\n+\t\t\t\tret = 0;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tLIST_INSERT_HEAD(&vtep_list_vxlan, vtep_encap, next);\n+\t\t}\n+\t\tvtep_encap->refcnt++;\n+\t\tret = vtep_encap->ifindex;\n+\t\tassert(ret);\n+\t\tbreak;\n+\tcase MLX5_FLOW_TCF_TUNACT_VXLAN_DECAP: {\n+\t\tstruct mlx5_flow_tcf_vtep *vtep;\n+\t\tuint16_t port = dev_flow->tcf.vxlan_decap->udp_port;\n+\n+\t\tLIST_FOREACH(vtep, &vtep_list_vxlan, next) {\n+\t\t\tif (vtep->port == port)\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tif (!vtep) {\n+\t\t\tvtep = flow_tcf_create_iface(tcf, port, error);\n+\t\t\tif (!vtep) {\n+\t\t\t\tret = 0;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tLIST_INSERT_HEAD(&vtep_list_vxlan, vtep, next);\n+\t\t}\n+\t\tvtep->refcnt++;\n+\t\tret = vtep->ifindex;\n+\t\tassert(ret);\n+\t\tbreak;\n+\t}\n+\tdefault:\n+\t\trte_flow_error_set(error, ENOTSUP,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t\"unsupported tunnel type\");\n+\t\tret = 0;\n+\t\tbreak;\n+\t}\n+\tpthread_mutex_unlock(&vtep_list_mutex);\n+\treturn ret;\n+}\n+\n+/**\n+ * Deletes tunneling interface by UDP port.\n+ *\n+ * @param tx\n+ *   Context object initialized by mlx5_flow_tcf_socket_open().\n+ * @param[in] dev_flow\n+ *   Flow tcf object with tunnel structure pointer set.\n+ */\n+static void\n+flow_tcf_tunnel_vtep_delete(struct mlx5_tcf_socket *tcf,\n+\t\t\t    struct mlx5_flow *dev_flow)\n+{\n+\tstruct mlx5_flow_tcf_vtep *vtep;\n+\tuint16_t port = MLX5_VXLAN_DEFAULT_PORT;\n+\n+\tassert(dev_flow->tcf.tunnel);\n+\tpthread_mutex_lock(&vtep_list_mutex);\n+\tswitch (dev_flow->tcf.tunnel->type) {\n+\tcase MLX5_FLOW_TCF_TUNACT_VXLAN_DECAP:\n+\t\tport = dev_flow->tcf.vxlan_decap->udp_port;\n+\t\t/* There is no break operator intentionally. */\n+\tcase MLX5_FLOW_TCF_TUNACT_VXLAN_ENCAP:\n+\t\tLIST_FOREACH(vtep, &vtep_list_vxlan, next) {\n+\t\t\tif (vtep->port == port)\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tif (!vtep) {\n+\t\t\tDRV_LOG(WARNING,\n+\t\t\t\t\"No VTEP device found in the list\");\n+\t\t\tbreak;\n+\t\t}\n+\t\tassert(dev_flow->tcf.tunnel->ifindex_tun == vtep->ifindex);\n+\t\tassert(vtep->refcnt);\n+\t\tif (vtep->refcnt && --vtep->refcnt)\n+\t\t\tbreak;\n+\t\tif (!vtep->notcreated)\n+\t\t\tflow_tcf_delete_iface(tcf, vtep);\n+\t\tLIST_REMOVE(vtep, next);\n+\t\tif (vtep_encap == vtep)\n+\t\t\tvtep_encap = NULL;\n+\t\trte_free(vtep);\n+\t\tbreak;\n+\tdefault:\n+\t\tassert(false);\n+\t\tDRV_LOG(WARNING, \"Unsupported tunnel type\");\n+\t\tbreak;\n+\t}\n+\tpthread_mutex_unlock(&vtep_list_mutex);\n+}\n+\n /**\n  * Apply flow to E-Switch by sending Netlink message.\n  *\n@@ -2917,12 +3202,45 @@ struct flow_tcf_ptoi {\n \tnlh = dev_flow->tcf.nlh;\n \tnlh->nlmsg_type = RTM_NEWTFILTER;\n \tnlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL;\n+\tif (dev_flow->tcf.tunnel) {\n+\t\t/*\n+\t\t * Replace the interface index, target for\n+\t\t * encapsulation, source for decapsulation\n+\t\t */\n+\t\tassert(!dev_flow->tcf.tunnel->ifindex_tun);\n+\t\tassert(dev_flow->tcf.tunnel->ifindex_ptr);\n+\t\t/* Create actual VTEP device when rule is being applied. */\n+\t\tdev_flow->tcf.tunnel->ifindex_tun\n+\t\t\t= flow_tcf_tunnel_vtep_create(&priv->tcf_socket,\n+\t\t\t\t\t\t      dev_flow, error);\n+\t\t\tDRV_LOG(INFO, \"Replace ifindex: %d->%d\",\n+\t\t\t\tdev_flow->tcf.tunnel->ifindex_tun,\n+\t\t\t\t*dev_flow->tcf.tunnel->ifindex_ptr);\n+\t\tif (!dev_flow->tcf.tunnel->ifindex_tun)\n+\t\t\treturn -rte_errno;\n+\t\tdev_flow->tcf.tunnel->ifindex_org\n+\t\t\t= *dev_flow->tcf.tunnel->ifindex_ptr;\n+\t\t*dev_flow->tcf.tunnel->ifindex_ptr\n+\t\t\t= dev_flow->tcf.tunnel->ifindex_tun;\n+\t}\n \tret = flow_tcf_nl_ack(tcf, nlh);\n+\tif (dev_flow->tcf.tunnel) {\n+\t\tDRV_LOG(INFO, \"Restore ifindex: %d->%d\",\n+\t\t\t\tdev_flow->tcf.tunnel->ifindex_org,\n+\t\t\t\t*dev_flow->tcf.tunnel->ifindex_ptr);\n+\t\t*dev_flow->tcf.tunnel->ifindex_ptr\n+\t\t\t= dev_flow->tcf.tunnel->ifindex_org;\n+\t\tdev_flow->tcf.tunnel->ifindex_org = 0;\n+\t}\n \tif (!ret) {\n \t\tdev_flow->tcf.applied = 1;\n \t\treturn 0;\n \t}\n \tDRV_LOG(WARNING, \"Failed to create TC rule (%d)\", rte_errno);\n+\tif (dev_flow->tcf.tunnel->ifindex_tun) {\n+\t\tflow_tcf_tunnel_vtep_delete(&priv->tcf_socket, dev_flow);\n+\t\tdev_flow->tcf.tunnel->ifindex_tun = 0;\n+\t}\n \treturn rte_flow_error_set(error, rte_errno,\n \t\t\t\t  RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n \t\t\t\t  \"netlink: failed to create TC flow rule\");\n@@ -2951,10 +3269,34 @@ struct flow_tcf_ptoi {\n \t\treturn;\n \t/* E-Switch flow can't be expanded. */\n \tassert(!LIST_NEXT(dev_flow, next));\n+\tif (!dev_flow->tcf.applied)\n+\t\treturn;\n+\tif (dev_flow->tcf.tunnel) {\n+\t\t/*\n+\t\t * Replace the interface index, target for\n+\t\t * encapsulation, source for decapsulation\n+\t\t */\n+\t\tassert(dev_flow->tcf.tunnel->ifindex_tun);\n+\t\tassert(dev_flow->tcf.tunnel->ifindex_ptr);\n+\t\tdev_flow->tcf.tunnel->ifindex_org\n+\t\t\t= *dev_flow->tcf.tunnel->ifindex_ptr;\n+\t\t*dev_flow->tcf.tunnel->ifindex_ptr\n+\t\t\t= dev_flow->tcf.tunnel->ifindex_tun;\n+\t}\n \tnlh = dev_flow->tcf.nlh;\n \tnlh->nlmsg_type = RTM_DELTFILTER;\n \tnlh->nlmsg_flags = NLM_F_REQUEST;\n \tflow_tcf_nl_ack(tcf, nlh);\n+\tif (dev_flow->tcf.tunnel) {\n+\t\t*dev_flow->tcf.tunnel->ifindex_ptr\n+\t\t\t= dev_flow->tcf.tunnel->ifindex_org;\n+\t\tdev_flow->tcf.tunnel->ifindex_org = 0;\n+\t\tif (dev_flow->tcf.tunnel->ifindex_tun) {\n+\t\t\tflow_tcf_tunnel_vtep_delete(&priv->tcf_socket,\n+\t\t\t\t\t\t    dev_flow);\n+\t\t\tdev_flow->tcf.tunnel->ifindex_tun = 0;\n+\t\t}\n+\t}\n \tdev_flow->tcf.applied = 0;\n }\n \n",
    "prefixes": [
        "5/5"
    ]
}