From patchwork Fri Nov 2 17:53:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 47755 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 008317D05; Fri, 2 Nov 2018 18:53:24 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50074.outbound.protection.outlook.com [40.107.5.74]) by dpdk.org (Postfix) with ESMTP id 228F95F1B for ; Fri, 2 Nov 2018 18:53:18 +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=A3fDT7LVMzpOFlQBwu1Jd6d4qbAZjdrhzc7oTGTg90s=; b=Ubr7nSBUbIVtVN3LCUc8FaHb4l14xlSz8THuRRN65pkQB4oPxvoXaHeUNo3DEvvnTMtGi9IAtrChoFV5of7FQW7mYjxfBJyEPC7TzI9lXs6IIP9IdUNP+ms0Shxsqp1UmMWpFxQMpsUQMUyPxublPaQUH/Pjj0MGZX1vaLhT1zQ= 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:17 +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:17 +0000 From: Slava Ovsiienko To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh , Slava Ovsiienko Thread-Topic: [PATCH v4 04/13] net/mlx5: add necessary structures for E-Switch VXLAN Thread-Index: AQHUctTvfTmzfdY50kOrrfOn5eLTSg== Date: Fri, 2 Nov 2018 17:53:17 +0000 Message-ID: <1541181152-15788-5-git-send-email-viacheslavo@mellanox.com> References: <1541074741-41368-1-git-send-email-viacheslavo@mellanox.com> <1541181152-15788-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1541181152-15788-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:gwyjhzcAXoUlGACQb+4S0O+G1qVXoyf+ZXns01r7V5r+uusJA2olPWGV8y+QTb8l9ZAljPN8Hw9cc6P4ei5eSrot5hGLIgvaLOO6RxUqGtEegnbYMEohyJvuNrGPXFUeApW9eSZRfvhDZaGczoqVn36cvczZeTJYsQBmaFYHP4OlJu/zDxNBQVHiEUJbpLrTFLk9TY2UX89SksmFHMDuERWIpr7s+kqdetW8K4rXTnf8d0hMzjuM5Q+OTNTQ6LQ8buT+uxQVaQphZN0EQ+TD5fuNlsAIh9sZab8Z+Xhy7INsFVzgT7R6Lfh/ch16OSj+HYnOhbmVH5bmiBgEIqIWllPkO+rKKv1z8ABwV513+AdJ7cOqqgn9y3ouVD43p+5H1nNSgZQYviuyY2EmNuKs+lNV5O8F2auNxyqdOTziNZ1bD2T+puImFI7jGJqfxLe1HEeFJOW9xP63pe/gszjFgg==; 5:gxvgDjbzB8deujBlXbzYYd57Vy/2WqYJTN6F2ZJ8b/gwiBdNn2awaHjpoNFLnSDdEmMCdrvpLCEeAHqu5Q1COUodFmGsk9nbnNT9ezk0eeVmu/gs9vRG73jNoG5iptZrxt13XA/+iZPheut5xithjEVal2MOcP2GTk6dVwdmpxA=; 7:QoRs1dTaecMT7hxQQnk3SZeUIYY1v7fQcz6NzunTUY8s+YblEwVqQBlnUI8hD4GePCGs2TJOY4fx4NvOEVxZRyzRKTtt1FJtSg3YvAqsTgS9FVlMMQFqXkcWM+QN/zDiKp+c7Jsdm1LpbAuI8UJjVg== x-ms-office365-filtering-correlation-id: 6ed33d52-b782-4df5-e871-08d640ec117c 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)(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)(99286004)(86362001)(3846002)(6116002)(14454004)(6512007)(316002)(25786009)(53936002)(97736004)(71190400001)(37006003)(4326008)(6862004)(71200400001)(186003)(107886003)(6436002)(54906003)(6486002)(5660300001)(2906002)(106356001)(36756003)(66066001)(105586002)(2900100001)(8936002)(52116002)(76176011)(81166006)(305945005)(81156014)(8676002)(68736007)(7736002); 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: i3+XrsfJre/Y9R/rz4Rn4n6SPGr9/WYxVu3CfvWAI/+Hr4zHR6ce3up51y5luENFlall0UWyYrm5ITb896mtVJK1SzCCcFXO6TsAJsrurSOtY5eWEGbCKxPY2PXP1Nzxj3Fio2DTbQ3wm68l9p/DK1ge589uJ7nNbDPzT0ZEbF0wQKJx7M9W6l6cJj6oKMniSutgqyF1cTEiZow881JLrJG224qSvRtwzo3I2nj26cTp6MNn45VTDfGXQ5PIB+j4lyfXqI9Zyk60nJByeQh0CQLpPXxbDAGVNWqK71j34qJgC6S4xmvF8nz/sC+E2++uh+wIUIVShrn0VI9PrNwWmJ3m+i6m2NsSft3wqyUEOJU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ed33d52-b782-4df5-e871-08d640ec117c X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Nov 2018 17:53:17.1833 (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 04/13] net/mlx5: add necessary structures for E-Switch VXLAN 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch introduces the data structures needed to implement VXLAN encapsulation/decapsulation hardware offload support for E-Switch. Suggested-by: Adrien Mazarguil Signed-off-by: Viacheslav Ovsiienko Acked-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow.h | 9 ++++ drivers/net/mlx5/mlx5_flow_tcf.c | 99 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index fadde55..2a3ce44 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -219,6 +219,15 @@ struct mlx5_flow_dv { struct mlx5_flow_tcf { struct nlmsghdr *nlh; struct tcmsg *tcm; + union { /**< Tunnel encap/decap descriptor. */ + struct flow_tcf_tunnel_hdr *tunnel; + struct flow_tcf_vxlan_decap *vxlan_decap; + struct flow_tcf_vxlan_encap *vxlan_encap; + }; + uint32_t applied:1; /**< Whether rule is currently applied. */ +#ifndef NDEBUG + uint32_t nlsize; /**< Size of NL message buffer for debug check. */ +#endif }; /* Verbs specification header. */ diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index 4d54112..55c77e3 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -348,6 +348,100 @@ struct mlx5_flow_tcf_context { uint8_t *buf; /* Message buffer. */ }; +/** + * Neigh rule structure. The neigh rule is applied via Netlink to + * outer tunnel iface in order to provide destination MAC address + * for the VXLAN encapsultion. The neigh rule is implicitly related + * to the Flow itself and can be shared by multiple Flows. + */ +struct tcf_neigh_rule { + LIST_ENTRY(tcf_neigh_rule) next; + uint32_t refcnt; + struct ether_addr eth; + uint16_t mask; + union { + struct { + rte_be32_t dst; + } ipv4; + struct { + uint8_t dst[IPV6_ADDR_LEN]; + } ipv6; + }; +}; + +/** + * Local rule structure. The local rule is applied via Netlink to + * outer tunnel iface in order to provide local and peer IP addresses + * of the VXLAN tunnel for encapsulation. The local rule is implicitly + * related to the Flow itself and can be shared by multiple Flows. + */ +struct tcf_local_rule { + LIST_ENTRY(tcf_local_rule) next; + uint32_t refcnt; + uint16_t mask; + union { + struct { + rte_be32_t dst; + rte_be32_t src; + } ipv4; + struct { + uint8_t dst[IPV6_ADDR_LEN]; + uint8_t src[IPV6_ADDR_LEN]; + } ipv6; + }; +}; + +/** VXLAN virtual netdev. */ +struct tcf_vtep { + LIST_ENTRY(tcf_vtep) next; + LIST_HEAD(, tcf_neigh_rule) neigh; + LIST_HEAD(, tcf_local_rule) local; + uint32_t refcnt; + unsigned int ifindex; /**< Own interface index. */ + unsigned int ifouter; /**< Index of device attached to. */ + uint16_t port; + uint8_t created; +}; + +/** Tunnel descriptor header, common for all tunnel types. */ +struct flow_tcf_tunnel_hdr { + uint32_t type; /**< Tunnel action type. */ + struct tcf_vtep *vtep; /**< Virtual tunnel endpoint device. */ + unsigned int ifindex_org; /**< Original dst/src interface */ + unsigned int *ifindex_ptr; /**< Interface ptr in message. */ +}; + +struct flow_tcf_vxlan_decap { + struct flow_tcf_tunnel_hdr hdr; + uint16_t udp_port; +}; + +struct flow_tcf_vxlan_encap { + struct 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[IPV6_ADDR_LEN]; + uint8_t src[IPV6_ADDR_LEN]; + } ipv6; + }; +struct { + rte_be16_t src; + rte_be16_t dst; + } udp; + struct { + uint8_t vni[3]; + } vxlan; +}; + /** Structure used when extracting the values of a flow counters * from a netlink message. */ @@ -365,6 +459,7 @@ struct flow_tcf_stats_basic { 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; /** Supported masks for known item types. */ @@ -376,6 +471,7 @@ struct flow_tcf_stats_basic { 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 = { .port_id = { .id = 0xffffffff, @@ -413,6 +509,9 @@ struct flow_tcf_stats_basic { .src_port = RTE_BE16(0xffff), .dst_port = RTE_BE16(0xffff), }, + .vxlan = { + .vni = "\xff\xff\xff", + }, }; #define SZ_NLATTR_HDR MNL_ALIGN(sizeof(struct nlattr))