From patchwork Wed Apr 5 15:19:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 9664477 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 B9DE560353 for ; Wed, 5 Apr 2017 15:26:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA97922638 for ; Wed, 5 Apr 2017 15:26:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F8AA2852E; Wed, 5 Apr 2017 15:26:31 +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 885A228500 for ; Wed, 5 Apr 2017 15:26:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755689AbdDEP0V (ORCPT ); Wed, 5 Apr 2017 11:26:21 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:52588 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754853AbdDEPYs (ORCPT ); Wed, 5 Apr 2017 11:24:48 -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 v35FJrvo006102; 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 v35FJrn0019821; 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 v35FJr7o019820; 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 2/5] ibverbs: Add inner flow specification support Date: Wed, 5 Apr 2017 18:19:21 +0300 Message-Id: <1491405564-19735-3-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 When one of the L2/L3/L4 flow specification types is or-combined with IBV_FLOW_SPEC_INNER, then the filter is applied on the inner packet header. The flow specifications can contain inner and outer parts for the inner and outer protocol header respectively. Signed-off-by: Moses Reuben Signed-off-by: Artemy Kovalyov Reviewed-by: Maor Gottlieb Reviewed-by: Yishai Hadas --- libibverbs/cmd.c | 11 +++++++++-- libibverbs/man/ibv_create_flow.3 | 1 + libibverbs/verbs.h | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 8814142..6bdd1c4 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -1747,8 +1747,9 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, kern_spec->hdr.type = ib_spec->hdr.type; - switch (ib_spec->hdr.type) { + switch (kern_spec->hdr.type) { case IBV_FLOW_SPEC_ETH: + case IBV_FLOW_SPEC_ETH | IBV_FLOW_SPEC_INNER: kern_spec->eth.size = sizeof(struct ibv_kern_spec_eth); memcpy(&kern_spec->eth.val, &ib_spec->eth.val, sizeof(struct ibv_flow_eth_filter)); @@ -1756,6 +1757,7 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, sizeof(struct ibv_flow_eth_filter)); break; case IBV_FLOW_SPEC_IPV4: + case IBV_FLOW_SPEC_IPV4 | IBV_FLOW_SPEC_INNER: kern_spec->ipv4.size = sizeof(struct ibv_kern_spec_ipv4); memcpy(&kern_spec->ipv4.val, &ib_spec->ipv4.val, sizeof(struct ibv_flow_ipv4_filter)); @@ -1763,13 +1765,15 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, sizeof(struct ibv_flow_ipv4_filter)); break; case IBV_FLOW_SPEC_IPV4_EXT: + case IBV_FLOW_SPEC_IPV4_EXT | IBV_FLOW_SPEC_INNER: ret = get_filters_size(ib_spec, kern_spec, &ib_filter_size, &kern_filter_size, IBV_FLOW_SPEC_IPV4_EXT); if (ret) return ret; - kern_spec->hdr.type = IBV_FLOW_SPEC_IPV4; + kern_spec->hdr.type = IBV_FLOW_SPEC_IPV4 | + (IBV_FLOW_SPEC_INNER & ib_spec->hdr.type); kern_spec->ipv4_ext.size = sizeof(struct ibv_kern_spec_ipv4_ext); memcpy(&kern_spec->ipv4_ext.val, &ib_spec->ipv4_ext.val, @@ -1778,6 +1782,7 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, + ib_filter_size, kern_filter_size); break; case IBV_FLOW_SPEC_IPV6: + case IBV_FLOW_SPEC_IPV6 | IBV_FLOW_SPEC_INNER: ret = get_filters_size(ib_spec, kern_spec, &ib_filter_size, &kern_filter_size, IBV_FLOW_SPEC_IPV6); @@ -1792,6 +1797,8 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, break; case IBV_FLOW_SPEC_TCP: case IBV_FLOW_SPEC_UDP: + case IBV_FLOW_SPEC_TCP | IBV_FLOW_SPEC_INNER: + case IBV_FLOW_SPEC_UDP | IBV_FLOW_SPEC_INNER: kern_spec->tcp_udp.size = sizeof(struct ibv_kern_spec_tcp_udp); memcpy(&kern_spec->tcp_udp.val, &ib_spec->tcp_udp.val, sizeof(struct ibv_flow_ipv4_filter)); diff --git a/libibverbs/man/ibv_create_flow.3 b/libibverbs/man/ibv_create_flow.3 index 3056972..32a7572 100644 --- a/libibverbs/man/ibv_create_flow.3 +++ b/libibverbs/man/ibv_create_flow.3 @@ -67,6 +67,7 @@ IBV_FLOW_SPEC_IPV4_EXT = 0x32, /* Extended flow specification 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 */ +IBV_FLOW_SPEC_INNER = 0x100, /* Flag making L2/L3/L4 specifications to be applied on the inner header */ .in -8 }; .br diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index b41a116..225ab81 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -1223,7 +1223,8 @@ enum ibv_flow_spec_type { IBV_FLOW_SPEC_IPV4_EXT = 0x32, IBV_FLOW_SPEC_TCP = 0x40, IBV_FLOW_SPEC_UDP = 0x41, - IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50 + IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, + IBV_FLOW_SPEC_INNER = 0x100 }; struct ibv_flow_eth_filter {