From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0079.outbound.protection.outlook.com [104.47.2.79]) by dpdk.org (Postfix) with ESMTP id D1DCD378E for ; Tue, 2 Oct 2018 08:30:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gIx5UX1WJ6PrCsRZ/MRt8/Hy8mEe4Z0n88T9708R7mU=; b=Ou2rejAmlg2Xh/OAP1x2V63mg6FFDmof5XVfnvpXVis9mIzQMiNh+Br0Iy50npWRu2DOCz2ToqY7hKvH2lWyoStqauDe/FGrdI2y3bNhdXzSWyRrgqq5G9Vsk5QUqQnvMb3SxekSdfn157bOTFjPi8bPuwns1iDVpELDCDGm5cY= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3443.eurprd05.prod.outlook.com (10.171.187.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.25; Tue, 2 Oct 2018 06:30:33 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::81a1:b719:2345:50e5]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::81a1:b719:2345:50e5%5]) with mapi id 15.20.1185.024; Tue, 2 Oct 2018 06:30:33 +0000 From: Slava Ovsiienko To: "dev@dpdk.org" CC: Shahaf Shuler , Slava Ovsiienko Thread-Topic: [PATCH 1/5] net/mlx5: add VXLAN encap/decap support for e-switch Thread-Index: AQHUWhlsShSsBduI20W6hYhALR2KFg== Date: Tue, 2 Oct 2018 06:30:33 +0000 Message-ID: <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 (2603:10a6:208:3e::32) To AM4PR05MB3265.eurprd05.prod.outlook.com (2603:10a6:205:4::22) authentication-results: spf=none (sender IP is ) smtp.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; AM4PR05MB3443; 6:7J3LWhkxNdlelpr1mFALYdJvtvysoC5y7bviw6WDLQxUMuOcZ5ja9eSOufEsnQjKxTphWFvC7TAik3U6hA4oIpwzkBRM/V73ROS1q2xBzL19G/N3eLpxnko6imVBWL2DtbchBFlpH4Ua3ozYWLgkkBCZgVPqp1chRyMuGxg4g0jDKJjHhzT8Y0JHC+zF4HDe3vYVFleIElaGhzyWK6cJZ75kF6b4AYF8tNMMCBm8Z0T8Z7aqb7ZCkTWYMwA3/RJiY9C0kdFYH3+FGTPKTtGOWD5ZvSzB2F8H4bl0+GGcqXX1FMO2B1Z9iImAqXdvaOY7+v/z6hDQssMpGCvVGSy/kJp7CcSfcnDwH5/77yzpFnwMX/g3RmCkA+K6Rfyird2lya+UwYNQ+zTEhpD9I4NaiJYkONgwmbXkFYq6xZANyNeb1QLhKS3aVeHnpmQwE0ct00U4ocU99pn0Mis9BNvvxw==; 5:zU++hMTySngT1zf4tYj+67Ranu48/KkHKx3EGPTQQk6Q2DagRxoK6FkqV7WD8PQ47OtrRuSRSBRf8LEUzAtyMrEN4NszwFQx6KQsipekUJtlsDflzs4yusZGm063cXyNKFfNWhcu9tdbngIN6cu3A10XIi2//z0Qezo9LdZD22c=; 7:odCT0lkykcwvsRL0YQxHNf1W3V2rEFAl0eTgM9KDiCsYX+uB5e645CuSuAStOHPDmzXBR5uJdqKWk5Fmav8Njrs/RHz8xKhFrve08LueVFplQTkn8bIoRv6Ll+csRqX0T2lGzG7gkCfsaXLVFm99ObU2pVUKYJQlqANMaSCuKQJrD2X7GfOQYf7GfpY+d9oE3LrC5F5q32TmOhjSpyXW2hOemJj8GAWbQNEjAtSCR6CReHyGBgDN6IIpLqx3/oxD x-ms-office365-filtering-correlation-id: 69ad12ae-9b4a-4439-e20c-08d628308e6f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3443; x-ms-traffictypediagnostic: AM4PR05MB3443: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:AM4PR05MB3443; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3443; x-forefront-prvs: 0813C68E65 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(189003)(199004)(5640700003)(256004)(25786009)(14444005)(26005)(106356001)(561944003)(54906003)(186003)(316002)(102836004)(68736007)(105586002)(6116002)(3846002)(97736004)(14454004)(81156014)(1730700003)(86362001)(2351001)(2900100001)(8676002)(7736002)(2616005)(8936002)(476003)(305945005)(81166006)(6486002)(52116002)(386003)(6436002)(6506007)(53936002)(2906002)(4326008)(71200400001)(36756003)(478600001)(486006)(99286004)(5250100002)(66066001)(5660300001)(6512007)(2501003)(6916009)(4744004)(71190400001)(107886003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3443; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: v4WTSqCJEuAOsEbtKcGn3kjoNhWuAeR7vvsYzZWngxSQ0ndITJROisjMijt8w1bu7IeU+m5KDG2Sg8LZhCANh5ZYTygTg+WbGPM9A/SYbjTOAZMnl20jGFOiqC8q5kKjJp0bVLDv8sE2Jzy/CcsqkCMGex3l3qEqtQ6lE34O0FtST8So+8ZxSEJofCKRhe/BqNrnEhk0EpQPKHsvtMhIjS/GiWfJk+srTKnVZfzaU/GR9pF1c+rew9blkTJaM4X1PfkWSWPF2YEkestGRP9iWTKnCnVSy7byDx/jDUuz4+S7nraO8IMhnKIWXF5EMcJJ2CK8hkjZqeAs8hMMDO5kDXhm/PjW29GYjmSlZAteSfQ= 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: 69ad12ae-9b4a-4439-e20c-08d628308e6f X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Oct 2018 06:30:33.6264 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3443 Subject: [dpdk-dev] [PATCH 1/5] net/mlx5: add VXLAN encap/decap support for e-switch X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Oct 2018 06:30:36 -0000 This patchset adds support for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP and RTE_FLOW_ACTION_TYPE_VXLAN_DECAP to mlx5 PMD. This patch is refactored version of proposal 20180831092038.23051-2-adrien.mazarguil@6wind.com. A typical use case is port representors in switchdev mode, with VXLAN traffic encapsulation performed on traffic coming *from* a representor and decapsulation on traffic going *to* that representor, in order to transparently assign a given VXLAN to VF traffic. Since these actions are supported at the switch level, the "transfer" attribute must be set on such flow rules. They must also be combined with a port redirection action to make sense. Since only ingress is supported, encapsulation flow rules are normally applied on a physical port and emit traffic to a port representor. The opposite order is used for decapsulation. Like other mlx5 switch flow rule actions, these are implemented through Linux's TC flower API. Since the Linux interface for VXLAN encap/decap involves virtual network devices (i.e. ip link add type vxlan [...]), the PMD automatically spawns them on a needed basis through Netlink calls. VXLAN interfaces are dynamically created for each local UDP port of outer networks and then used as targets for TC "flower" filters in order to perform encapsulation. These VXLAN interfaces are system-wide, the only one device with given UDP port can exist in the system (the attempt of creating another device with the same UDP local port returns EEXIST), so PMD should support the shared device instances database for PMD instances. These VXLAN implicitly created devices are called VTEPs (Virtual Tunnel End Points). The first part of patchset introduces the new datastructures and definitions needed to implement VXLAN support in mlx5 PMD. The history of the patch: v1 Refactored code of initial experimental proposal 20180831092038.23051-2-adrien.mazarguil@6wind.com, the unattached VTEP used in order to resolve the problem of VTEP UDP port sharing between several PMD ports. Suggested-by: Adrien Mazarguil Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/config.c | 3 + drivers/net/mlx5/Makefile | 75 ++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 11 +++ drivers/net/mlx5/mlx5_flow_tcf.c | 167 +++++++++++++++++++++++++++++++++++= ++++ drivers/net/mlx5/mlx5_nl.c | 12 ++- 5 files changed, 264 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 794aa52..b088c9f 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1172,6 +1172,9 @@ enum item_spec_type { sizeof(struct rte_flow_action_of_pop_mpls)), MK_FLOW_ACTION(OF_PUSH_MPLS, sizeof(struct rte_flow_action_of_push_mpls)), + MK_FLOW_ACTION(VXLAN_ENCAP, + sizeof(struct rte_flow_action_vxlan_encap)), + MK_FLOW_ACTION(VXLAN_DECAP, 0), }; =20 /** Compute storage space needed by action configuration and copy it. */ diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index ca1de9f..63c7191 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -347,6 +347,81 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config= -h.sh enum TCA_VLAN_PUSH_VLAN_PRIORITY \ $(AUTOCONF_OUTPUT) $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_KEY_ID \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_KEY_ID \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_IPV4_SRC \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_IPV4_SRC \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_IPV4_DST \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_IPV4_DST \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_IPV4_DST_MASK \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_IPV4_DST_MASK \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_IPV6_SRC \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_IPV6_SRC \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_IPV6_DST \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_IPV6_DST \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_IPV6_DST_MASK \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_IPV6_DST_MASK \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_UDP_SRC_PORT \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_UDP_SRC_PORT \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_UDP_DST_PORT \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_UDP_DST_PORT \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TC_ACT_TUNNEL_KEY \ + linux/tc_act/tc_tunnel_key.h \ + define TCA_ACT_TUNNEL_KEY \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_TUNNEL_KEY_ENC_DST_PORT \ + linux/tc_act/tc_tunnel_key.h \ + enum TCA_TUNNEL_KEY_ENC_DST_PORT \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ HAVE_SUPPORTED_40000baseKR4_Full \ /usr/include/linux/ethtool.h \ define SUPPORTED_40000baseKR4_Full \ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 10d700a..2d56ced 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -87,6 +87,8 @@ #define MLX5_ACTION_OF_PUSH_VLAN (1u << 8) #define MLX5_ACTION_OF_SET_VLAN_VID (1u << 9) #define MLX5_ACTION_OF_SET_VLAN_PCP (1u << 10) +#define MLX5_ACTION_VXLAN_ENCAP (1u << 11) +#define MLX5_ACTION_VXLAN_DECAP (1u << 12) =20 /* possible L3 layers protocols filtering. */ #define MLX5_IP_PROTOCOL_TCP 6 @@ -178,8 +180,17 @@ struct mlx5_flow_dv { =20 /** Linux TC flower driver for E-Switch flow. */ struct mlx5_flow_tcf { + uint32_t nlsize; /**< Size of NL message buffer. */ + uint32_t applied:1; /**< Whether rule is currently applied. */ + uint64_t item_flags; /**< Item flags. */ + uint64_t action_flags; /**< Action flags. */ struct nlmsghdr *nlh; struct tcmsg *tcm; + union { /**< Tunnel encap/decap descriptor. */ + struct mlx5_flow_tcf_tunnel_hdr *tunnel; + struct mlx5_flow_tcf_vxlan_decap *vxlan_decap; + struct mlx5_flow_tcf_vxlan_encap *vxlan_encap; + }; }; =20 /* Verbs specification header. */ diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_= tcf.c index 1437618..5c93412 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -6,6 +6,29 @@ #include #include #include +/* + * Older versions of linux/if.h do not have the required safeties to coexi= st + * with net/if.h. This causes a compilation failure due to symbol + * redefinitions even when including the latter first. + * + * One workaround is to prevent net/if.h from defining conflicting symbols + * by removing __USE_MISC, and maintaining it undefined while including + * linux/if.h. + * + * Alphabetical order cannot be preserved since net/if.h must always be + * included before linux/if.h regardless. + */ +#ifdef __USE_MISC +#undef __USE_MISC +#define RESTORE_USE_MISC +#endif +#include +#include +#ifdef RESTORE_USE_MISC +#undef RESTORE_USE_MISC +#define __USE_MISC 1 +#endif +#include #include #include #include @@ -53,6 +76,34 @@ struct tc_vlan { =20 #endif /* HAVE_TC_ACT_VLAN */ =20 +#ifdef HAVE_TC_ACT_TUNNEL_KEY + +#include + +#ifndef HAVE_TCA_TUNNEL_KEY_ENC_DST_PORT +#define TCA_TUNNEL_KEY_ENC_DST_PORT 9 +#endif + +#else /* HAVE_TC_ACT_TUNNEL_KEY */ + +#define TCA_ACT_TUNNEL_KEY 17 +#define TCA_TUNNEL_KEY_ACT_SET 1 +#define TCA_TUNNEL_KEY_ACT_RELEASE 2 +#define TCA_TUNNEL_KEY_PARMS 2 +#define TCA_TUNNEL_KEY_ENC_IPV4_SRC 3 +#define TCA_TUNNEL_KEY_ENC_IPV4_DST 4 +#define TCA_TUNNEL_KEY_ENC_IPV6_SRC 5 +#define TCA_TUNNEL_KEY_ENC_IPV6_DST 6 +#define TCA_TUNNEL_KEY_ENC_KEY_ID 7 +#define TCA_TUNNEL_KEY_ENC_DST_PORT 9 + +struct tc_tunnel_key { + tc_gen; + int t_action; +}; + +#endif /* HAVE_TC_ACT_TUNNEL_KEY */ + /* Normally found in linux/netlink.h. */ #ifndef NETLINK_CAP_ACK #define NETLINK_CAP_ACK 10 @@ -148,11 +199,118 @@ struct tc_vlan { #ifndef HAVE_TCA_FLOWER_KEY_VLAN_ETH_TYPE #define TCA_FLOWER_KEY_VLAN_ETH_TYPE 25 #endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_KEY_ID +#define TCA_FLOWER_KEY_ENC_KEY_ID 26 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_IPV4_SRC +#define TCA_FLOWER_KEY_ENC_IPV4_SRC 27 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK +#define TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK 28 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_IPV4_DST +#define TCA_FLOWER_KEY_ENC_IPV4_DST 29 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_IPV4_DST_MASK +#define TCA_FLOWER_KEY_ENC_IPV4_DST_MASK 30 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_IPV6_SRC +#define TCA_FLOWER_KEY_ENC_IPV6_SRC 31 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK +#define TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK 32 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_IPV6_DST +#define TCA_FLOWER_KEY_ENC_IPV6_DST 33 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_IPV6_DST_MASK +#define TCA_FLOWER_KEY_ENC_IPV6_DST_MASK 34 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_UDP_SRC_PORT +#define TCA_FLOWER_KEY_ENC_UDP_SRC_PORT 43 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK +#define TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK 44 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_UDP_DST_PORT +#define TCA_FLOWER_KEY_ENC_UDP_DST_PORT 45 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK +#define TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK 46 +#endif =20 #ifndef IPV6_ADDR_LEN #define IPV6_ADDR_LEN 16 #endif =20 +#define MLX5_VXLAN_DEFAULT_PORT 4789 +#define MLX5_VXLAN_DEVICE_PFX "vmlx_" + +/** Tunnel action type, used for @p type in header structure. */ +enum mlx5_flow_tcf_tunact_type { + MLX5_FLOW_TCF_TUNACT_VXLAN_ENCAP, + MLX5_FLOW_TCF_TUNACT_VXLAN_DECAP, +}; + +/** Flags used for @p mask in tunnel action encap descriptors. */ +#define MLX5_FLOW_TCF_ENCAP_ETH_SRC (1u << 0) +#define MLX5_FLOW_TCF_ENCAP_ETH_DST (1u << 1) +#define MLX5_FLOW_TCF_ENCAP_IPV4_SRC (1u << 2) +#define MLX5_FLOW_TCF_ENCAP_IPV4_DST (1u << 3) +#define MLX5_FLOW_TCF_ENCAP_IPV6_SRC (1u << 4) +#define MLX5_FLOW_TCF_ENCAP_IPV6_DST (1u << 5) +#define MLX5_FLOW_TCF_ENCAP_UDP_SRC (1u << 6) +#define MLX5_FLOW_TCF_ENCAP_UDP_DST (1u << 7) +#define MLX5_FLOW_TCF_ENCAP_VXLAN_VNI (1u << 8) + +/** VXLAN virtual netdev. */ +struct mlx5_flow_tcf_vtep { + LIST_ENTRY(mlx5_flow_tcf_vtep) next; + uint32_t refcnt; + unsigned int ifindex; + uint16_t port; + uint8_t notcreated; +}; + +/** Tunnel descriptor header, common for all tunnel types. */ +struct mlx5_flow_tcf_tunnel_hdr { + uint32_t type; /**< Tunnel action type. */ + unsigned int ifindex_tun; /**< Tunnel endpoint interface. */ + unsigned int ifindex_org; /**< Original dst/src interface */ + unsigned int *ifindex_ptr; /**< Interface ptr in message. */ +}; + +struct mlx5_flow_tcf_vxlan_decap { + struct mlx5_flow_tcf_tunnel_hdr hdr; + uint16_t udp_port; +}; + +struct mlx5_flow_tcf_vxlan_encap { + struct mlx5_flow_tcf_tunnel_hdr hdr; + uint32_t mask; + struct { + struct ether_addr dst; + struct ether_addr src; + } eth; + union { + struct { + rte_be32_t dst; + rte_be32_t src; + } ipv4; + struct { + uint8_t dst[16]; + uint8_t src[16]; + } ipv6; + }; + struct { + rte_be16_t src; + rte_be16_t dst; + } udp; + struct { + uint8_t vni[3]; + } vxlan; +}; + /** Empty masks for known item types. */ static const union { struct rte_flow_item_port_id port_id; @@ -162,6 +320,7 @@ struct tc_vlan { struct rte_flow_item_ipv6 ipv6; struct rte_flow_item_tcp tcp; struct rte_flow_item_udp udp; + struct rte_flow_item_vxlan vxlan; } flow_tcf_mask_empty; =20 /** Supported masks for known item types. */ @@ -173,6 +332,7 @@ struct tc_vlan { struct rte_flow_item_ipv6 ipv6; struct rte_flow_item_tcp tcp; struct rte_flow_item_udp udp; + struct rte_flow_item_vxlan vxlan; } flow_tcf_mask_supported =3D { .port_id =3D { .id =3D 0xffffffff, @@ -209,6 +369,9 @@ struct tc_vlan { .src_port =3D RTE_BE16(0xffff), .dst_port =3D RTE_BE16(0xffff), }, + .vxlan =3D { + .vni =3D "\xff\xff\xff", + }, }; =20 #define SZ_NLATTR_HDR MNL_ALIGN(sizeof(struct nlattr)) @@ -216,6 +379,10 @@ struct tc_vlan { #define SZ_NLATTR_DATA_OF(len) MNL_ALIGN(SZ_NLATTR_HDR + (len)) #define SZ_NLATTR_TYPE_OF(typ) SZ_NLATTR_DATA_OF(sizeof(typ)) #define SZ_NLATTR_STRZ_OF(str) SZ_NLATTR_DATA_OF(strlen(str) + 1) +#define SZ_NLATTR_TYPE_OF_UINT8 SZ_NLATTR_TYPE_OF(uint8_t) +#define SZ_NLATTR_TYPE_OF_UINT16 SZ_NLATTR_TYPE_OF(uint16_t) +#define SZ_NLATTR_TYPE_OF_UINT32 SZ_NLATTR_TYPE_OF(uint32_t) +#define SZ_NLATTR_TYPE_OF_STRUCT(typ) SZ_NLATTR_TYPE_OF(struct typ) =20 #define PTOI_TABLE_SZ_MAX(dev) (mlx5_dev_to_port_id((dev)->device, NULL, 0= ) + 2) =20 diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c index d61826a..88e8e15 100644 --- a/drivers/net/mlx5/mlx5_nl.c +++ b/drivers/net/mlx5/mlx5_nl.c @@ -385,8 +385,10 @@ struct mlx5_nl_ifindex_data { int ret; uint32_t sn =3D priv->nl_sn++; =20 - if (priv->nl_socket_route =3D=3D -1) - return 0; + if (priv->nl_socket_route < 0) { + rte_errno =3D ENOENT; + goto error; + } fd =3D priv->nl_socket_route; ret =3D mlx5_nl_request(fd, &req.hdr, sn, &req.ifm, sizeof(struct ifinfomsg)); @@ -449,8 +451,10 @@ struct mlx5_nl_ifindex_data { int ret; uint32_t sn =3D priv->nl_sn++; =20 - if (priv->nl_socket_route =3D=3D -1) - return 0; + if (priv->nl_socket_route < 0) { + rte_errno =3D ENOENT; + goto error; + } fd =3D priv->nl_socket_route; memcpy(RTA_DATA(&req.rta), mac, ETHER_ADDR_LEN); req.hdr.nlmsg_len =3D NLMSG_ALIGN(req.hdr.nlmsg_len) + --=20 1.8.3.1