From patchwork Wed May 16 13:31:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10403945 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 3E95660155 for ; Wed, 16 May 2018 13:33:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 129C22897B for ; Wed, 16 May 2018 13:33:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AD0128964; Wed, 16 May 2018 13:32:59 +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 1986B28964 for ; Wed, 16 May 2018 13:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbeEPNbc (ORCPT ); Wed, 16 May 2018 09:31:32 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:57688 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752186AbeEPNba (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 w4GDVSDM007174; 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 w4GDVSMW010164; 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 w4GDVSN3010163; 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 3/4] verbs: Add MPLS flow specification filter Date: Wed, 16 May 2018 16:31:09 +0300 Message-Id: <1526477470-10080-4-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 Add MPLS flow specification based on RFC 3032. MPLS spec defined with label field which includes the label value and additional parameters such as: BoS, TC and TTL. MPLS allows stacking multiple labels in sequence. In addition, the MPLS header can be encapsulated on top of different layers, e.g.: ETH, IP (rfc4023), UDP (rfc7510), GRE (rfc4023). Therefore, when using the flow creation verb, the application should organize the spec filters list in the command in an ordered manner, such that reflects the actual protocol stack of the packet, to determine the exact position of the MPLS headers in the protocol stack. 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 | 19 ++++++++++++++++++- libibverbs/verbs.h | 18 ++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 8d4865d..738ae39 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -1773,6 +1773,13 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, memcpy(&kern_spec->gre.mask, &ib_spec->gre.mask, sizeof(struct ibv_flow_gre_filter)); break; + case IBV_FLOW_SPEC_MPLS: + kern_spec->mpls.size = sizeof(struct ib_uverbs_flow_spec_mpls); + memcpy(&kern_spec->mpls.val, &ib_spec->mpls.val, + sizeof(struct ibv_flow_mpls_filter)); + memcpy(&kern_spec->mpls.mask, &ib_spec->mpls.mask, + sizeof(struct ibv_flow_mpls_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 d8e5987..33642fe 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -269,6 +269,7 @@ struct ibv_kern_spec { 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_mpls mpls; struct ib_uverbs_flow_spec_action_tag flow_tag; struct ib_uverbs_flow_spec_action_drop drop; struct ib_uverbs_flow_spec_action_handle handle; diff --git a/libibverbs/man/ibv_create_flow.3 b/libibverbs/man/ibv_create_flow.3 index f1737ca..9f0d179 100644 --- a/libibverbs/man/ibv_create_flow.3 +++ b/libibverbs/man/ibv_create_flow.3 @@ -70,6 +70,7 @@ IBV_FLOW_SPEC_TCP = 0x40, /* Flow specification of TCP h 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_MPLS = 0x60, /* Flow specification of MPLS 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 */ @@ -111,7 +112,23 @@ In addition to the domain, there is priority within each of the domains. A lower priority numeric value (higher priority) takes precedence over matching rules with higher numeric priority value (lower priority). It is important to note that the priority value of a flow spec is used not only to establish the precedence of conflicting flow matches but also as a way to abstract the order on which flow specs are tested for matches. Flows with higher priorities will be tested before flows with lower priorities. -.PP + +.SS Rules definition ordering +An application can provide the ibv_flow_spec_xxx rules in an un-ordered scheme. In this case, each spec should be well +defined and match a specific network header layer. +In some cases, when certain flow spec types are present in the spec list, it is required to provide the list in an +ordered manner so that the position of that flow spec type in the protocol stack is strictly defined. +This is essential to represent many of the encapsulation tunnel protocols. +.br + +The flow spec types which require this sort of ordering are: +.br +.B 1. IBV_FLOW_SPEC_MPLS - +.br +Since MPLS header can appear at several locations in the protocol stack and can also be +encapsulated on top of different layers, it is required to place this spec according to its exact location in the +protocol stack. +.br .SS ibv_destroy_flow() destroys the flow .I flow_id\fR. diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index d4d621f..ab5758d 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -1401,6 +1401,7 @@ enum ibv_flow_spec_type { IBV_FLOW_SPEC_UDP = 0x41, IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, IBV_FLOW_SPEC_GRE = 0x51, + IBV_FLOW_SPEC_MPLS = 0x60, IBV_FLOW_SPEC_INNER = 0x100, IBV_FLOW_SPEC_ACTION_TAG = 0x1000, IBV_FLOW_SPEC_ACTION_DROP = 0x1001, @@ -1513,6 +1514,22 @@ struct ibv_flow_spec_gre { struct ibv_flow_gre_filter mask; }; +struct ibv_flow_mpls_filter { + /* The field includes the entire MPLS label: + * bits 0:19 - label value field. + * bits 20:22 - traffic class field. + * bits 23 - bottom of stack bit. + * bits 24:31 - ttl field. + */ + uint32_t label; +}; + +struct ibv_flow_spec_mpls { + enum ibv_flow_spec_type type; + uint16_t size; + struct ibv_flow_mpls_filter val; + struct ibv_flow_mpls_filter mask; +}; struct ibv_flow_tunnel_filter { uint32_t tunnel_id; @@ -1556,6 +1573,7 @@ struct ibv_flow_spec { struct ibv_flow_spec_esp esp; struct ibv_flow_spec_tunnel tunnel; struct ibv_flow_spec_gre gre; + struct ibv_flow_spec_mpls mpls; struct ibv_flow_spec_action_tag flow_tag; struct ibv_flow_spec_action_drop drop; struct ibv_flow_spec_action_handle handle;