From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50088.outbound.protection.outlook.com [40.107.5.88]) by dpdk.org (Postfix) with ESMTP id 0D9125B40 for ; Fri, 2 Nov 2018 18:53:15 +0100 (CET) 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=AwTyHP5NUpHYMhPP97uSH5EmwL6sYVx8JA6NvF3bfs0=; b=lS62ZWULMiowanEKT3oD/DkYp0013cPsOLR6NFj/HDm/FskIRaswD7sX+Bl2sceTkKMk81kp3hXp++GKbNs5ulsB2sCN8b/KvyPSBgjkA4gnylG1ST0BW83fhc15nq4kxUhZMr+5Dz0pETwEmITqBRBJk03FpLTVafAyjP5Rv6U= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3203.eurprd05.prod.outlook.com (10.171.186.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.20; Fri, 2 Nov 2018 17:53:13 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::544b:a68d:e6a5:ba6e]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::544b:a68d:e6a5:ba6e%2]) with mapi id 15.20.1294.024; Fri, 2 Nov 2018 17:53:13 +0000 From: Slava Ovsiienko To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh , Slava Ovsiienko Thread-Topic: [PATCH v4 00/13] net/mlx5: e-switch VXLAN encap/decap hardware offload Thread-Index: AQHUctTtSAfLaBsZHUGBAQbf9g0YPQ== Date: Fri, 2 Nov 2018 17:53:13 +0000 Message-ID: <1541181152-15788-1-git-send-email-viacheslavo@mellanox.com> References: <1541074741-41368-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1541074741-41368-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: LO2P265CA0112.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::28) 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; AM4PR05MB3203; 6:JoVbfckBO45EfaCZAJwuB6t3BtvgUVfxIYrm+36Euk6A+MFHMZWLUUdL1W5bX23Hg28bBCUdsbujGfrbnweOB0LN5Cn8FeSTMYnoECirH91OxuAXLl0xIUrxP7seiaKlSxtTzbjpA/HEguCtC9bRtiJUW1YCkINf0V/E8wcmJJXpvvNV60tpbjRKI4upE9jhkorsJSd4Hq9cMVKoErl6LlNWAUB66fs3J0Su5+p6QkKrlGHUlr4PuSdxejWB+UxzgbRX7HImKlm8AzsFcYgMc4RqwkZNWZRm4M0jed1jJD0cD9UcTHU4L+hqixr9Yw9/LnASFWNjdP1VfULCxHgGjnyMVMhjj/1tdvOFDSEVcj9lyS1EcvHRMzqcMZUgYfxJwgU0eaa2edl4sMZO0T5FfhTQA2ovAdwEkTlCkJD1P0uexsPa2+YzI2sD1nF7hJcXlmrf3J7aDDXqhPKCZJa7ig==; 5:PAb1CO7Jo3TLM+PBaRZK+3kdB50JEnpCz3iClS3O5QMSAFGiw4p5szBOqKrhMIlQ7hDQWfCzXqWHMHLxP6eF0MCgQNhKDeXwYkw2z/mEiYxoqTRiTZzx3Yji+MJgK618omx6XbRSwsp0fSUAduwYi2RphlB3xTlloryOKh8Pc+g=; 7:h9A4x6bgjmVYt7pVIupuG17/lHjHr4s0d5fxnYmN/mtQi1jyZa2g/861jm3hscIe/BdY05XQef6JqOrd2n+dGKPtdd1kYOFgYBorGXZs/fzSmB2hmaklOSeE8YEB5jVCQl0fBvrZ/koc6AARKBk84Q== x-ms-office365-filtering-correlation-id: bcffaeb0-8719-4569-5b7f-08d640ec0f57 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3203; x-ms-traffictypediagnostic: AM4PR05MB3203: 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)(5005006)(8121501046)(3231382)(944501410)(4982022)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3203; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3203; x-forefront-prvs: 08444C7C87 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(346002)(39860400002)(136003)(366004)(396003)(199004)(189003)(6636002)(11346002)(478600001)(446003)(2616005)(476003)(486006)(256004)(14444005)(5024004)(386003)(6506007)(102836004)(26005)(6306002)(99286004)(86362001)(561944003)(3846002)(6116002)(14454004)(6512007)(316002)(25786009)(53936002)(97736004)(71190400001)(37006003)(4326008)(6862004)(71200400001)(186003)(107886003)(6436002)(54906003)(6486002)(5660300001)(2906002)(106356001)(36756003)(66066001)(105586002)(966005)(2900100001)(8936002)(52116002)(76176011)(81166006)(305945005)(81156014)(8676002)(68736007)(7736002)(21314003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3203; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: ZsJn2n1PiwS8cSumja0WSa5B5MTbyFiV0ULgxhGDDgw4ImE/QwfJUB9CSrJ9iar821ZorlMfAqh2HMgidUjW0vd79Tw7Iqk3oxwiJ2mHj0wMpQwvC5wZCz5P1pav86S2UloVP1bnKW4EGTC2YWT+XKAph1JEkqDA+vqasF6OwVSbL3JWV1YKxmcFs/oRuWdn8+E0VMv8FdZokoflDbt7nINrlfssjGSaBJIkS5jL2yr2FwsM+VcW+csIwx7KBWS08ZaM1dbGAayZbn9Xms2vGtjLIjMvKF29kLd+Z/kZ5pfwV5PgcE4g3qxUbpqICUBDeQHKIKc1lyRz2NukYUs+I8IZLr9FEDIeeKDISoVs8GU= 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: bcffaeb0-8719-4569-5b7f-08d640ec0f57 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Nov 2018 17:53:13.5998 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3203 Subject: [dpdk-dev] [PATCH v4 00/13] net/mlx5: e-switch VXLAN encap/decap hardware offload 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: Fri, 02 Nov 2018 17:53:15 -0000 This patchset adds the VXLAN encapsulation/decapsulation hardware offload feature for E-Switch. =20 A typical use case of tunneling infrastructure is port representors=20 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 E-Switch level, the "transfer"=20 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.=20 The opposite order is used for decapsulation. Like other mlx5 E-Switch flow rule actions, these ones 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 dynamically spawns them on a needed basis through Netlink calls. These VXLAN implicitly created devices are called VTEPs (Virtual Tunnel End Points). VXLAN interfaces are dynamically created for each local port of outer networks and then used as targets for TC "flower" filters in order to perform encapsulation. For decapsulation the VXLAN devices are created for each unique UDP-port. These VXLAN interfaces are system-wide, the only one device with given UDP port can exist=20 in the system (the attempt of creating another device with the=20 same UDP local port returns EEXIST), so PMD should support the shared (between PMD instances) device database.=20 Rules samples consideraions: $PF - physical device, outer network $VF - representor for VF, outer/inner network $VXLAN - VTEP netdev name $PF_OUTER_IP - $PF IP (v4 or v6) within outer network $REMOTE_IP - remote peer IP (v4 or v6) within outer network $LOCAL_PORT - local UDP port $REMOTE_PORT - remote UDP port VXLAN VTEP creation with iproute2 (PMD does the same via Netlink): - for encapsulation: ip link add $VXLAN type vxlan dstport $LOCAL_PORT external dev $PF ip link set dev $VXLAN up tc qdisc del dev $VXLAN ingress tc qdisc add dev $VXLAN ingress $LOCAL_PORT for egress encapsulated traffic (note, this is not source UDP port in the VXLAN header, it is just UDP port assigned to VTEP, no practical usage) is selected from available UDP ports automatically in range 30000-60000. - for decapsulation: ip link add $VXLAN type vxlan dstport $LOCAL_PORT external ip link set dev $VXLAN up tc qdisc del dev $VXLAN ingress tc qdisc add dev $VXLAN ingress $LOCAL_PORT is UDP port receiving the VXLAN traffic from outer networks. All ingress UDP traffic with given UDP destination port from ALL existing netdevs is routed by kernel to the $VXLAN net device. While applying the rule the kernel checks the IP parameter withing rule, determines the appropriate underlaying PF and tryes to setup the rule hardware offload. VXLAN encapsulation=20 VXLAN encap rules are applied to the VF ingress traffic and have the=20 VTEP as actual redirection destinations instead of outer PF. The encapsulation rule should provide: - redirection action VF->PF - VF port ID - some inner network parameters (MACs)=20 - the tunnel outer source IP (v4/v6), (IS A MUST) - the tunnel outer destination IP (v4/v6), (IS A MUST). - VNI - Virtual Network Identifier (IS A MUST) VXLAN encapsulation rule sample for tc utility: tc filter add dev $VF protocol all parent ffff: flower skip_sw \ action tunnel_key set dst_port $REMOTE_PORT \ src_ip $PF_OUTER_IP dst_ip $REMOTE_IP id $VNI \ action mirred egress redirect dev $VXLAN VXLAN encapsulation rule sample for testpmd: - Setting up outer properties of VXLAN tunnel: set vxlan ip-version ipv4 vni $VNI \ udp-src $IGNORED udp-dst $REMOTE_PORT \ ip-src $PF_OUTER_IP ip-dst $REMOTE_IP \ eth-src $IGNORED eth-dst $REMOTE_MAC - Creating a flow rule on port ID 4 performing VXLAN encapsulation with the abovementioned properties and directing the resulting traffic to port ID 0: flow create 4 ingress transfer pattern eth src is $INNER_MAC / end actions vxlan_encap / port_id id 0 / end There is no direct way found to provide kernel with all required encapsulatioh header parameters. The encapsulation VTEP is created attached to the outer interface and assumed as default path for egress encapsulated traffic. The outer tunnel IP address are assigned to interface using Netlink, the implicit route is created like this: ip addr add peer dev scope link The peer address option provides implicit route, and scope link attribute reduces the risk of conflicts. At initialization time all local scope link addresses are flushed from the outer network device. The destination MAC address is provided via permenent neigh rule: ip neigh add dev lladdr to nud permanent At initialization time all neigh rules of permanent type are flushed from the outer network device.=20 VXLAN decapsulation=20 VXLAN decap rules are applied to the ingress traffic of VTEP ($VXLAN) device instead of PF. The decapsulation rule should provide: - redirection action PF->VF - VF port ID as redirection destination - $VXLAN device as ingress traffic source - the tunnel outer source IP (v4/v6), (optional) - the tunnel outer destination IP (v4/v6), (IS A MUST) - the tunnel local UDP port (IS A MUST, PMD looks for appropriate VTEP with given local UDP port) - VNI - Virtual Network Identifier (IS A MUST) VXLAN decap rule sample for tc utility:=20 tc filter add dev $VXLAN protocol all parent ffff: flower skip_sw \ enc_src_ip $REMOTE_IP enc_dst_ip $PF_OUTER_IP enc_key_id $VNI \ nc_dst_port $LOCAL_PORT \ action tunnel_key unset action mirred egress redirect dev $VF =09 VXLAN decap rule sample for testpmd:=20 - Creating a flow on port ID 0 performing VXLAN decapsulation and directing the result to port ID 4 with checking inner properties: flow create 0 ingress transfer pattern /=20 ipv4 src is $REMOTE_IP dst $PF_LOCAL_IP / udp src is 9999 dst is $LOCAL_PORT / vxlan vni is $VNI /=20 eth src is 00:11:22:33:44:55 dst is $INNER_MAC / end actions vxlan_decap / port_id id 4 / end The VXLAN encap/decap rules constrains (implied by current kernel support) - VXLAN decapsulation provided for PF->VF direction only - VXLAN encapsulation provided for VF->PF direction only - current implementation will support non-shared database of VTEPs (impossible simultaneous usage of the same UDP port by several instances of DPDK apps) Suggested-by: Adrien Mazarguil Signed-off-by: Viacheslav Ovsiienko --- V4: * indentation cleanup and codestyle issues * patchset minor resplitting * tunnel type initialization moved to prepare routine =20 v3: * http://patches.dpdk.org/patch/47661/ * patchset is resplitted into more dedicated parts * decapsulation rule takes MAC from inner eth item * appropriate RTE_BEx are replaced with runtime rte_cpu_xxx * E-Switch Flow counter deletion is fixed * VTEP management routines are refactored * found typos are corrected v2: * http://patches.dpdk.org/patch/46848/ * removed non-VXLAN related parts * multipart Netlink messages support * local IP and peer IP rules management * neigh IP address to MAC address rules * management rules cleanup at outer device initialization * attached devices cleanup at outer device initialization v1: * http://patches.dpdk.org/patch/45800/ * Refactored code of initial experimental proposal v0: * http://patches.dpdk.org/cover/44080/ * Initial proposal by Adrien Mazarguil Viacheslav Ovsiienko (13): net/mlx5: prepare makefile for adding E-Switch VXLAN net/mlx5: prepare meson.build for adding E-Switch VXLAN net/mlx5: add necessary definitions for E-Switch VXLAN net/mlx5: add necessary structures for E-Switch VXLAN net/mlx5: swap items/actions validations for E-Switch rules net/mlx5: add E-Switch VXLAN support to validation routine net/mlx5: add VXLAN support to flow prepare routine net/mlx5: add VXLAN support to flow translate routine net/mlx5: update E-Switch VXLAN netlink routines net/mlx5: fix E-Switch Flow counter deletion net/mlx5: add E-switch VXLAN tunnel devices management net/mlx5: add E-Switch VXLAN encapsulation rules net/mlx5: add E-switch VXLAN rule cleanup routines drivers/net/mlx5/Makefile | 85 + drivers/net/mlx5/meson.build | 34 + drivers/net/mlx5/mlx5_flow.h | 9 + drivers/net/mlx5/mlx5_flow_tcf.c | 4094 ++++++++++++++++++++++++++++++++--= ---- 4 files changed, 3615 insertions(+), 607 deletions(-) --=20 1.8.3.1