From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0074.outbound.protection.outlook.com [104.47.1.74]) by dpdk.org (Postfix) with ESMTP id A737A1B12B for ; Thu, 1 Nov 2018 13:19:26 +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=GMGMthCk971hnyDjEl1u7Hffn3VQWFeQU6BQ+92G+kE=; b=XWFjGpK36x/1oCIv/ar+6hb8lf+IKpEM3SfW9xtEeET+ttjPUCu3fPLlf4NSKnjojRU4QWfs3ODU0/BIVrXtW+gLNBHKAW4JReMNOCNMnVoKK+b9+3E9F+/JAn07lC6nH9eORHg+8oy7c8nXWpe9WdxILEOT4PAVTtFnzeAUb/4= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3505.eurprd05.prod.outlook.com (10.171.188.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.24; Thu, 1 Nov 2018 12:19:25 +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.1273.030; Thu, 1 Nov 2018 12:19:25 +0000 From: Slava Ovsiienko To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh , Slava Ovsiienko Thread-Topic: [PATCH v3 04/13] net/mlx5: add necessary structures for e-switch VXLAN Thread-Index: AQHUcd0gi3eCw++l70e0foyFOlHL9A== Date: Thu, 1 Nov 2018 12:19:25 +0000 Message-ID: <1541074741-41368-5-git-send-email-viacheslavo@mellanox.com> References: <1539612815-47199-1-git-send-email-viacheslavo@mellanox.com> <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: LO2P265CA0079.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::19) 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; AM4PR05MB3505; 6:7ghKs64KUrXq2+Z7mJpwaaRNih3yD9GgYfCdGNS9h9D3nbqUFWFlh8t2CyAPgZc3TCCVd5xFiEVDMgCsbawZY/4D7veJyvgA+FA96qf2lB3EznR4Q1k9uISEypDNszNnxLXCeAWomfwb0yOaiFDpx6MO/RQZnO+LU60ZzeoPLQYoWrA/etl09pOv4OyyLQYtlu/c1h4hAf+MyT2nk+FzzKwLouDd9MX+uDlLXxmYPRe+3nbeSQeUV4l6jbbavDEMhJs7bXcgyx4G0QLXkGczbbHX6thVIo3RIEnRIFv8YNrL+ZKis6hP/Hh6gwdjdqJXYpaEu977HhBT/c+UMy75mG2DMgOX0ih5ZYVRWv08sGrmpHJ3BO9ryNkkJP3V2o4W/nL1OBXY0Elc2b6ZdgE3oKrl6Izz5UEi6IiNLEClHS3sE/QhtjEr/73bm6K+XQbEvkZHIeA/vugiVnst9ZplNA==; 5:ct0zMYR5p2+qA82tYWD4eVJ0slS71z2RYVba5Yyy5nwRYbPAcTIDZQqRE0awFY7Ua8zem9UA+1g7MlpGZtYaI56JXbgPWsb2i8yjonaINUeOMGe4DigqiPb3FefFWtQzcSkFSqb8zBIV38Xx09HcyaiZ1/QTRzEjeaFVMz2Jsh4=; 7:G1s5HaBoae4FvDWFnh2HfZUqipr78ol9LXMtdB6UWihQc7K5mQaNjioQzlevW9Kn1+51BGap6JSz+LLYd4LiJihb6BJsfXZIMfk+fAbjjAv/Mf66t/9Twm8cf2Z1/Nge53uLtuyxhHjpXIwiGFbpEw== x-ms-office365-filtering-correlation-id: d6c4ad7f-3a7e-4de0-cf8e-08d63ff44349 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:AM4PR05MB3505; x-ms-traffictypediagnostic: AM4PR05MB3505: 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)(3231382)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3505; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3505; x-forefront-prvs: 0843C17679 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(366004)(136003)(39860400002)(199004)(189003)(7736002)(6506007)(386003)(486006)(5024004)(14444005)(52116002)(76176011)(256004)(4326008)(36756003)(25786009)(8676002)(66066001)(81156014)(81166006)(5250100002)(99286004)(14454004)(6436002)(107886003)(6512007)(5660300001)(478600001)(53936002)(68736007)(26005)(86362001)(102836004)(97736004)(305945005)(6636002)(2900100001)(6486002)(8936002)(71190400001)(71200400001)(316002)(2906002)(476003)(3846002)(6116002)(186003)(11346002)(54906003)(105586002)(446003)(2616005)(106356001)(6862004)(37006003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3505; 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: kMPAwJDYpUOeXWoq93pzMTx2Qh/UoW2IJTY+LNGy/XaG50aVuny0sBFCRPLM+5VTWxdjdK0DMV5al9J5HumykLyhGsiGnpQBRPgrtM8rzq4r8p30TGGTKe33UduJAbu68HjNFZzgQNYmqXxNts6kB+9ZAwvUWRfLW/2FOWThJYi/TWwnr/8sHdM8xRWN34HcvRCrnbFx+NH1U1mefuPxfSqc+gpb2WH4Mj+uBz+lzBZhiPw+qCu2xLNXGwsXZjrgotGxXn0EYntCfsvsrs/uCv5pUE7UiFqWLA/LXc3b0+ER0YBy+5U6CpBdSBZBZJ+RWwsdv8HHXFLXkn+FU7Zid+aEzpPS+i3vbY5jS6Ep7ek= 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: d6c4ad7f-3a7e-4de0-cf8e-08d63ff44349 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2018 12:19:25.6890 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3505 Subject: [dpdk-dev] [PATCH v3 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: , X-List-Received-Date: Thu, 01 Nov 2018 12:19:27 -0000 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 --- 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 392c525..3887ee9 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -191,6 +191,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 }; =20 /* 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. */ }; =20 +/** + * 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; =20 /** 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 =3D { .port_id =3D { .id =3D 0xffffffff, @@ -413,6 +509,9 @@ struct flow_tcf_stats_basic { .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)) --=20 1.8.3.1