From patchwork Wed May 16 13:31:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10403941 X-Patchwork-Delegate: leon@leon.nu 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 4156B60155 for ; Wed, 16 May 2018 13:32:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2955C28B80 for ; Wed, 16 May 2018 13:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB30328B7B; Wed, 16 May 2018 13:32:55 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 5FD2228A29 for ; Wed, 16 May 2018 13:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752274AbeEPNbc (ORCPT ); Wed, 16 May 2018 09:31:32 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:57691 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751389AbeEPNba (ORCPT ); Wed, 16 May 2018 09:31:30 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 16 May 2018 16:33:18 +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 w4GDVSHU007158; Wed, 16 May 2018 16:31:28 +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 w4GDVSIx010160; Wed, 16 May 2018 16:31:28 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w4GDVSPU010159; Wed, 16 May 2018 16:31:28 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, lariel@mellanox.com Subject: [PATCH rdma-core 2/4] verbs: Add GRE flow specification filter Date: Wed, 16 May 2018 16:31:08 +0300 Message-Id: <1526477470-10080-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1526477470-10080-1-git-send-email-yishaih@mellanox.com> References: <1526477470-10080-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: Ariel Levkovich Allow verbs applications packet steering of GRE tunneled traffic. Adding GRE flow specification based on RFC 2890. GRE consists of flags, protocol and key fields. IPv4 protocol 47 (IPPROTO_GRE) can be used when GRE packets are encapsulated in IPv4. Signed-off-by: Ariel Levkovich Signed-off-by: Yishai Hadas --- libibverbs/cmd.c | 7 +++++++ libibverbs/kern-abi.h | 1 + libibverbs/man/ibv_create_flow.3 | 1 + libibverbs/verbs.h | 24 ++++++++++++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 0f102b4..8d4865d 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -1766,6 +1766,13 @@ 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_GRE: + kern_spec->gre.size = sizeof(struct ib_uverbs_flow_spec_gre); + memcpy(&kern_spec->gre.val, &ib_spec->gre.val, + sizeof(struct ibv_flow_gre_filter)); + memcpy(&kern_spec->gre.mask, &ib_spec->gre.mask, + sizeof(struct ibv_flow_gre_filter)); + break; case IBV_FLOW_SPEC_VXLAN_TUNNEL: ret = get_filters_size(ib_spec, kern_spec, &ib_filter_size, &kern_filter_size, diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h index 23dd104..d8e5987 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -267,6 +267,7 @@ struct ibv_kern_spec { struct ib_uverbs_flow_spec_esp esp; struct ib_uverbs_flow_spec_tcp_udp tcp_udp; struct ib_uverbs_flow_spec_ipv6 ipv6; + struct ib_uverbs_flow_spec_gre gre; struct ib_uverbs_flow_spec_tunnel tunnel; struct ib_uverbs_flow_spec_action_tag flow_tag; struct ib_uverbs_flow_spec_action_drop drop; diff --git a/libibverbs/man/ibv_create_flow.3 b/libibverbs/man/ibv_create_flow.3 index 65de08b..f1737ca 100644 --- a/libibverbs/man/ibv_create_flow.3 +++ b/libibverbs/man/ibv_create_flow.3 @@ -69,6 +69,7 @@ IBV_FLOW_SPEC_ESP = 0x34, /* Flow specification of ESP ( 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_GRE = 0x51, /* Flow specification of GRE header */ IBV_FLOW_SPEC_INNER = 0x100, /* Flag making L2/L3/L4 specifications to be applied on the inner header */ IBV_FLOW_SPEC_ACTION_TAG = 0x1000, /* Action tagging matched packet */ IBV_FLOW_SPEC_ACTION_DROP = 0x1001, /* Action dropping matched packet */ diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index eb57824..d4d621f 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -1400,6 +1400,7 @@ enum ibv_flow_spec_type { IBV_FLOW_SPEC_TCP = 0x40, IBV_FLOW_SPEC_UDP = 0x41, IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, + IBV_FLOW_SPEC_GRE = 0x51, IBV_FLOW_SPEC_INNER = 0x100, IBV_FLOW_SPEC_ACTION_TAG = 0x1000, IBV_FLOW_SPEC_ACTION_DROP = 0x1001, @@ -1491,6 +1492,28 @@ struct ibv_flow_spec_tcp_udp { struct ibv_flow_tcp_udp_filter mask; }; +struct ibv_flow_gre_filter { + /* c_ks_res0_ver field is bits 0-15 in offset 0 of a standard GRE header: + * bit 0 - checksum present bit. + * bit 1 - reserved. set to 0. + * bit 2 - key present bit. + * bit 3 - sequence number present bit. + * bits 4:12 - reserved. set to 0. + * bits 13:15 - GRE version. + */ + uint16_t c_ks_res0_ver; + uint16_t protocol; + uint32_t key; +}; + +struct ibv_flow_spec_gre { + enum ibv_flow_spec_type type; + uint16_t size; + struct ibv_flow_gre_filter val; + struct ibv_flow_gre_filter mask; +}; + + struct ibv_flow_tunnel_filter { uint32_t tunnel_id; }; @@ -1532,6 +1555,7 @@ struct ibv_flow_spec { struct ibv_flow_spec_ipv6 ipv6; struct ibv_flow_spec_esp esp; struct ibv_flow_spec_tunnel tunnel; + struct ibv_flow_spec_gre gre; struct ibv_flow_spec_action_tag flow_tag; struct ibv_flow_spec_action_drop drop; struct ibv_flow_spec_action_handle handle;