From patchwork Wed Mar 21 18:09:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10299987 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 21142600F6 for ; Wed, 21 Mar 2018 18:10:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1283A298D3 for ; Wed, 21 Mar 2018 18:10:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 110D8298E9; Wed, 21 Mar 2018 18:10:35 +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 7CD34298D3 for ; Wed, 21 Mar 2018 18:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752469AbeCUSKa (ORCPT ); Wed, 21 Mar 2018 14:10:30 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:57470 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752519AbeCUSK0 (ORCPT ); Wed, 21 Mar 2018 14:10:26 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 21 Mar 2018 20:11:08 +0200 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 w2LIAK7o014356; Wed, 21 Mar 2018 20:10:20 +0200 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 w2LIAKOr007793; Wed, 21 Mar 2018 20:10:20 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w2LIAKJn007792; Wed, 21 Mar 2018 20:10:20 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, matanb@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 09/11] verbs: Add flow steering specification for ESP Date: Wed, 21 Mar 2018 20:09:58 +0200 Message-Id: <1521655800-7287-10-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1521655800-7287-1-git-send-email-yishaih@mellanox.com> References: <1521655800-7287-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: Matan Barak Matching ESP packets (ipsec packets) requires a new flow steering specification. We add such a specification containing the SPI and the sequence number. Signed-off-by: Matan Barak Signed-off-by: Yishai Hadas --- kernel-headers/rdma/ib_user_verbs.h | 18 ++++++++++++++++++ libibverbs/cmd.c | 8 ++++++++ libibverbs/kern-abi.h | 1 + libibverbs/man/ibv_create_flow.3 | 1 + libibverbs/verbs.h | 14 ++++++++++++++ 5 files changed, 42 insertions(+) diff --git a/kernel-headers/rdma/ib_user_verbs.h b/kernel-headers/rdma/ib_user_verbs.h index d56fba0..48be0c7 100644 --- a/kernel-headers/rdma/ib_user_verbs.h +++ b/kernel-headers/rdma/ib_user_verbs.h @@ -1001,6 +1001,24 @@ struct ib_uverbs_flow_spec_tunnel { struct ib_uverbs_flow_tunnel_filter mask; }; +struct ib_uverbs_flow_spec_esp_filter { + __u32 spi; + __u32 seq; +}; + +struct ib_uverbs_flow_spec_esp { + union { + struct ib_uverbs_flow_spec_hdr hdr; + struct { + __u32 type; + __u16 size; + __u16 reserved; + }; + }; + struct ib_uverbs_flow_spec_esp_filter val; + struct ib_uverbs_flow_spec_esp_filter mask; +}; + struct ib_uverbs_flow_attr { __u32 type; __u16 size; diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 36d62eb..77c91b9 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -1739,6 +1739,14 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, memcpy(&kern_spec->ipv6.mask, (void *)&ib_spec->ipv6.val + ib_filter_size, kern_filter_size); break; + case IBV_FLOW_SPEC_ESP: + case IBV_FLOW_SPEC_ESP | IBV_FLOW_SPEC_INNER: + kern_spec->esp.size = sizeof(struct ib_uverbs_flow_spec_esp); + memcpy(&kern_spec->esp.val, &ib_spec->esp.val, + sizeof(struct ib_uverbs_flow_spec_esp_filter)); + memcpy(&kern_spec->esp.mask, (void *)&ib_spec->esp.mask, + sizeof(struct ib_uverbs_flow_spec_esp_filter)); + break; case IBV_FLOW_SPEC_TCP: case IBV_FLOW_SPEC_UDP: case IBV_FLOW_SPEC_TCP | IBV_FLOW_SPEC_INNER: diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h index 157f64f..8e8064a 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -256,6 +256,7 @@ struct ibv_kern_spec { struct ib_uverbs_flow_spec_eth eth; struct ibv_kern_spec_ipv4 ipv4; struct ib_uverbs_flow_spec_ipv4 ipv4_ext; + 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_tunnel tunnel; diff --git a/libibverbs/man/ibv_create_flow.3 b/libibverbs/man/ibv_create_flow.3 index 1762503..43c0b9c 100644 --- a/libibverbs/man/ibv_create_flow.3 +++ b/libibverbs/man/ibv_create_flow.3 @@ -65,6 +65,7 @@ IBV_FLOW_SPEC_ETH = 0x20, /* Flow specification of L2 he IBV_FLOW_SPEC_IPV4 = 0x30, /* Flow specification of IPv4 header */ IBV_FLOW_SPEC_IPV6 = 0x31, /* Flow specification of IPv6 header */ IBV_FLOW_SPEC_IPV4_EXT = 0x32, /* Extended flow specification of IPv4 */ +IBV_FLOW_SPEC_ESP = 0x34, /* Flow specification of ESP (IPSec) header */ 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 */ diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 8dbfcf1..a595db8 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -1380,6 +1380,7 @@ enum ibv_flow_spec_type { IBV_FLOW_SPEC_IPV4 = 0x30, IBV_FLOW_SPEC_IPV6 = 0x31, IBV_FLOW_SPEC_IPV4_EXT = 0x32, + IBV_FLOW_SPEC_ESP = 0x34, IBV_FLOW_SPEC_TCP = 0x40, IBV_FLOW_SPEC_UDP = 0x41, IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, @@ -1449,6 +1450,18 @@ struct ibv_flow_spec_ipv6 { struct ibv_flow_ipv6_filter mask; }; +struct ibv_flow_esp_filter { + uint32_t spi; + uint32_t seq; +}; + +struct ibv_flow_spec_esp { + enum ibv_flow_spec_type type; + uint16_t size; + struct ibv_flow_esp_filter val; + struct ibv_flow_esp_filter mask; +}; + struct ibv_flow_tcp_udp_filter { uint16_t dst_port; uint16_t src_port; @@ -1494,6 +1507,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_esp esp; struct ibv_flow_spec_tunnel tunnel; struct ibv_flow_spec_action_tag flow_tag; struct ibv_flow_spec_action_drop drop;