From patchwork Wed Apr 5 15:19:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 9664481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 943CE60353 for ; Wed, 5 Apr 2017 15:27:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 844872621D for ; Wed, 5 Apr 2017 15:27:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78FF42816B; Wed, 5 Apr 2017 15:27:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D43312621D for ; Wed, 5 Apr 2017 15:27:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754277AbdDEP1F (ORCPT ); Wed, 5 Apr 2017 11:27:05 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:52577 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755495AbdDEPYr (ORCPT ); Wed, 5 Apr 2017 11:24:47 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 5 Apr 2017 18:19:53 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v35FJrRo006099; Wed, 5 Apr 2017 18:19:53 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id v35FJrCo019817; Wed, 5 Apr 2017 18:19:53 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v35FJrud019816; Wed, 5 Apr 2017 18:19:53 +0300 From: Yishai Hadas To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, artemyko@mellanox.com, yishaih@mellanox.com, maorg@mellanox.com, majd@mellanox.com, Moses Reuben Subject: [PATCH rdma-core 1/5] ibverbs: Add tunnel VXLAN flow specification Date: Wed, 5 Apr 2017 18:19:20 +0300 Message-Id: <1491405564-19735-2-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1491405564-19735-1-git-send-email-yishaih@mellanox.com> References: <1491405564-19735-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Artemy Kovalyov Add flow specification for receiving a specific VXLAN packet. The specification defines a filter on the VNI field in the packet. There is an option to mask a range of tunnel IDs to be steered by using the filter mask. VNI: 24-bit value that provides a unique identifier for the individual VXLAN segment. Signed-off-by: Moses Reuben Signed-off-by: Artemy Kovalyov Reviewed-by: Maor Gottlieb Reviewed-by: Yishai Hadas --- libibverbs/cmd.c | 22 ++++++++++++++++++++++ libibverbs/kern-abi.h | 13 +++++++++++++ libibverbs/man/ibv_create_flow.3 | 1 + libibverbs/verbs.h | 25 +++++++++++++++++++------ 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 06ec671..8814142 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -1712,6 +1712,15 @@ static int get_filters_size(struct ibv_flow_spec *ib_spec, ib_spec_filter_mask = (void *)&ib_spec->ipv6.val + *ib_filter_size; break; + case IBV_FLOW_SPEC_VXLAN_TUNNEL: + min_filter_size = + offsetof(struct ibv_kern_tunnel_filter, + tunnel_id) + + sizeof(kern_spec->tunnel.mask.tunnel_id); + curr_kern_filter_size = min_filter_size; + ib_spec_filter_mask = (void *)&ib_spec->tunnel.val + + *ib_filter_size; + break; default: return EINVAL; } @@ -1789,6 +1798,19 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, memcpy(&kern_spec->tcp_udp.mask, &ib_spec->tcp_udp.mask, sizeof(struct ibv_flow_tcp_udp_filter)); break; + case IBV_FLOW_SPEC_VXLAN_TUNNEL: + ret = get_filters_size(ib_spec, kern_spec, + &ib_filter_size, &kern_filter_size, + IBV_FLOW_SPEC_VXLAN_TUNNEL); + if (ret) + return ret; + + kern_spec->tunnel.size = sizeof(struct ibv_kern_spec_tunnel); + memcpy(&kern_spec->tunnel.val, &ib_spec->tunnel.val, + kern_filter_size); + memcpy(&kern_spec->tunnel.mask, (void *)&ib_spec->tunnel.val + + ib_filter_size, kern_filter_size); + break; default: return EINVAL; } diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h index cb229f8..f8bdc9d 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -919,6 +919,18 @@ struct ibv_kern_spec_tcp_udp { }; +struct ibv_kern_tunnel_filter { + __u32 tunnel_id; +}; + +struct ibv_kern_spec_tunnel { + __u32 type; + __u16 size; + __u16 reserved; + struct ibv_kern_tunnel_filter val; + struct ibv_kern_tunnel_filter mask; +}; + struct ibv_kern_spec { union { struct { @@ -931,6 +943,7 @@ struct ibv_kern_spec { struct ibv_kern_spec_ipv4_ext ipv4_ext; struct ibv_kern_spec_tcp_udp tcp_udp; struct ibv_kern_spec_ipv6 ipv6; + struct ibv_kern_spec_tunnel tunnel; }; }; diff --git a/libibverbs/man/ibv_create_flow.3 b/libibverbs/man/ibv_create_flow.3 index 656bbf1..3056972 100644 --- a/libibverbs/man/ibv_create_flow.3 +++ b/libibverbs/man/ibv_create_flow.3 @@ -66,6 +66,7 @@ IBV_FLOW_SPEC_IPV6 = 0x31, /* Flow specification of IPv6 IBV_FLOW_SPEC_IPV4_EXT = 0x32, /* Extended flow specification of IPv4 */ IBV_FLOW_SPEC_TCP = 0x40, /* Flow specification of TCP header */ IBV_FLOW_SPEC_UDP = 0x41, /* Flow specification of UDP header */ +IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, /* Flow specification of VXLAN header */ .in -8 }; .br diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 4dbdb02..b41a116 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -1217,12 +1217,13 @@ enum ibv_flow_attr_type { }; enum ibv_flow_spec_type { - IBV_FLOW_SPEC_ETH = 0x20, - IBV_FLOW_SPEC_IPV4 = 0x30, - IBV_FLOW_SPEC_IPV6 = 0x31, - IBV_FLOW_SPEC_IPV4_EXT = 0x32, - IBV_FLOW_SPEC_TCP = 0x40, - IBV_FLOW_SPEC_UDP = 0x41, + IBV_FLOW_SPEC_ETH = 0x20, + IBV_FLOW_SPEC_IPV4 = 0x30, + IBV_FLOW_SPEC_IPV6 = 0x31, + IBV_FLOW_SPEC_IPV4_EXT = 0x32, + IBV_FLOW_SPEC_TCP = 0x40, + IBV_FLOW_SPEC_UDP = 0x41, + IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50 }; struct ibv_flow_eth_filter { @@ -1298,6 +1299,17 @@ struct ibv_flow_spec_tcp_udp { struct ibv_flow_tcp_udp_filter mask; }; +struct ibv_flow_tunnel_filter { + uint32_t tunnel_id; +}; + +struct ibv_flow_spec_tunnel { + enum ibv_flow_spec_type type; + uint16_t size; + struct ibv_flow_tunnel_filter val; + struct ibv_flow_tunnel_filter mask; +}; + struct ibv_flow_spec { union { struct { @@ -1309,6 +1321,7 @@ struct ibv_flow_spec { struct ibv_flow_spec_tcp_udp tcp_udp; struct ibv_flow_spec_ipv4_ext ipv4_ext; struct ibv_flow_spec_ipv6 ipv6; + struct ibv_flow_spec_tunnel tunnel; }; };