From patchwork Wed Mar 21 18:09:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10299993 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 30C60600F6 for ; Wed, 21 Mar 2018 18:10:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DAAB298E2 for ; Wed, 21 Mar 2018 18:10:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C399298E6; Wed, 21 Mar 2018 18:10:38 +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 9B13B298E9 for ; Wed, 21 Mar 2018 18:10:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752527AbeCUSKe (ORCPT ); Wed, 21 Mar 2018 14:10:34 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:57469 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752517AbeCUSK0 (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:07 +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 w2LIAKof014347; 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 w2LIAK4c007777; 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 w2LIAKAc007776; 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, Boris Pismenny Subject: [PATCH rdma-core 06/11] mlx5: Add mlx5dv_create_flow_action_esp() DV API Date: Wed, 21 Mar 2018 20:09:55 +0200 Message-Id: <1521655800-7287-7-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 Certain mlx5 based hardware require special data parsing when working with packets which went through ESP action. We would like to avoid unaware applications from mistakenly mishandling the data, skipping the required parsing. In order to do that, we add a new direct verb. This direct verb is identical to the ibv_create_flow_action_esp, but sets a vendor specific flag that means "I expect the data to come with special metadata". In turn, the kernel would verify that the data would indeed be returned as expected and would fail this command otherwise. Signed-off-by: Matan Barak Signed-off-by: Boris Pismenny Signed-off-by: Yishai Hadas --- debian/ibverbs-providers.symbols | 1 + debian/libibverbs-dev.install | 2 + kernel-headers/CMakeLists.txt | 2 + kernel-headers/rdma/mlx5_user_ioctl_cmds.h | 44 +++++++++++++++++++ kernel-headers/rdma/mlx5_user_ioctl_verbs.h | 43 ++++++++++++++++++ providers/mlx5/CMakeLists.txt | 3 +- providers/mlx5/libmlx5.map | 5 +++ providers/mlx5/man/CMakeLists.txt | 1 + providers/mlx5/man/mlx5dv_flow_action_esp.3.md | 60 ++++++++++++++++++++++++++ providers/mlx5/mlx5_api.h | 41 ++++++++++++++++++ providers/mlx5/mlx5dv.h | 15 +++++++ providers/mlx5/verbs.c | 29 +++++++++++++ 12 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 kernel-headers/rdma/mlx5_user_ioctl_cmds.h create mode 100644 kernel-headers/rdma/mlx5_user_ioctl_verbs.h create mode 100644 providers/mlx5/man/mlx5dv_flow_action_esp.3.md create mode 100644 providers/mlx5/mlx5_api.h diff --git a/debian/ibverbs-providers.symbols b/debian/ibverbs-providers.symbols index dc87c07..33e83cd 100644 --- a/debian/ibverbs-providers.symbols +++ b/debian/ibverbs-providers.symbols @@ -18,3 +18,4 @@ libmlx5.so.1 ibverbs-providers #MINVER# mlx5dv_create_qp@MLX5_1.3 16 mlx5dv_create_wq@MLX5_1.3 16 mlx5dv_get_clock_info@MLX5_1.4 17 + mlx5dv_create_flow_action_esp@MLX5_1.5 18 diff --git a/debian/libibverbs-dev.install b/debian/libibverbs-dev.install index 2fd279c..cabadf8 100644 --- a/debian/libibverbs-dev.install +++ b/debian/libibverbs-dev.install @@ -1,5 +1,7 @@ usr/include/infiniband/arch.h usr/include/infiniband/ib_user_ioctl_verbs.h +usr/include/infiniband/mlx5_api.h +usr/include/infiniband/mlx5_user_ioctl_verbs.h usr/include/infiniband/mlx4dv.h usr/include/infiniband/mlx5dv.h usr/include/infiniband/opcode.h diff --git a/kernel-headers/CMakeLists.txt b/kernel-headers/CMakeLists.txt index 011c66b..1ea9da2 100644 --- a/kernel-headers/CMakeLists.txt +++ b/kernel-headers/CMakeLists.txt @@ -11,6 +11,7 @@ publish_internal_headers(rdma rdma/ib_user_verbs.h rdma/mlx4-abi.h rdma/mlx5-abi.h + rdma/mlx5_user_ioctl_cmds.h rdma/mthca-abi.h rdma/nes-abi.h rdma/ocrdma-abi.h @@ -59,5 +60,6 @@ rdma_kernel_provider_abi( publish_headers(infiniband rdma/ib_user_ioctl_verbs.h + rdma/mlx5_user_ioctl_verbs.h ) diff --git a/kernel-headers/rdma/mlx5_user_ioctl_cmds.h b/kernel-headers/rdma/mlx5_user_ioctl_cmds.h new file mode 100644 index 0000000..69d1200 --- /dev/null +++ b/kernel-headers/rdma/mlx5_user_ioctl_cmds.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_USER_IOCTL_CMDS_H +#define MLX5_USER_IOCTL_CMDS_H + +#include + +enum mlx5_ib_create_flow_action_attrs { + /* This attribute belong to the driver namespace */ + MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS = (1U << UVERBS_ID_NS_SHIFT), +}; + +#endif + diff --git a/kernel-headers/rdma/mlx5_user_ioctl_verbs.h b/kernel-headers/rdma/mlx5_user_ioctl_verbs.h new file mode 100644 index 0000000..fbb8bad --- /dev/null +++ b/kernel-headers/rdma/mlx5_user_ioctl_verbs.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_USER_IOCTL_VERBS_H +#define MLX5_USER_IOCTL_VERBS_H + +#include + +enum mlx5_ib_uapi_flow_action_flags { + MLX5_IB_UAPI_FLOW_ACTION_FLAGS_REQUIRE_METADATA = 1 << 0, +}; + +#endif + diff --git a/providers/mlx5/CMakeLists.txt b/providers/mlx5/CMakeLists.txt index a8db43d..17ccd08 100644 --- a/providers/mlx5/CMakeLists.txt +++ b/providers/mlx5/CMakeLists.txt @@ -11,7 +11,7 @@ if (MLX5_MW_DEBUG) endif() rdma_shared_provider(mlx5 libmlx5.map - 1 1.4.${PACKAGE_VERSION} + 1 1.5.${PACKAGE_VERSION} buf.c cq.c dbrec.c @@ -23,4 +23,5 @@ rdma_shared_provider(mlx5 libmlx5.map publish_headers(infiniband mlx5dv.h + mlx5_api.h ) diff --git a/providers/mlx5/libmlx5.map b/providers/mlx5/libmlx5.map index 01fb983..410cc0e 100644 --- a/providers/mlx5/libmlx5.map +++ b/providers/mlx5/libmlx5.map @@ -28,3 +28,8 @@ MLX5_1.4 { global: mlx5dv_get_clock_info; } MLX5_1.3; + +MLX5_1.5 { + global: + mlx5dv_create_flow_action_esp; +} MLX5_1.4; diff --git a/providers/mlx5/man/CMakeLists.txt b/providers/mlx5/man/CMakeLists.txt index 876b6fc..cdc7115 100644 --- a/providers/mlx5/man/CMakeLists.txt +++ b/providers/mlx5/man/CMakeLists.txt @@ -1,4 +1,5 @@ rdma_man_pages( + mlx5dv_flow_action_esp.3.md mlx5dv_get_clock_info.3 mlx5dv_init_obj.3 mlx5dv_query_device.3 diff --git a/providers/mlx5/man/mlx5dv_flow_action_esp.3.md b/providers/mlx5/man/mlx5dv_flow_action_esp.3.md new file mode 100644 index 0000000..e2e223b --- /dev/null +++ b/providers/mlx5/man/mlx5dv_flow_action_esp.3.md @@ -0,0 +1,60 @@ +--- +layout: page +title: mlx5dv_flow_action_esp(3) +section: 3 +tagline: Verbs +--- + +# NAME + +mlx5dv_flow_action_esp(3) -- Flow action esp for mlx5 provider(3) + +# SYNOPSIS + +```c +#include + +struct ibv_flow_action * +mlx5dv_create_flow_action_esp(struct ibv_context *ctx, + struct ibv_flow_action_esp_attr *esp, + struct mlx5dv_flow_action_esp *mlx5_attr); +``` + +# DESCRIPTION + +Create an IPSEC ESP flow steering action. +This verb is identical to *ibv_create_flow_action_esp* verb, but allows mlx5 specific flags. + +# ARGUMENTS + +Please see *ibv_flow_action_esp(3)* man page for *ctx* and *esp*. + +## *mlx5_attr* argument + +```c +struct mlx5dv_flow_action_esp { + uint64_t comp_mask; /* Use enum mlx5dv_flow_action_esp_mask */ + uint32_t action_flags; /* Use enum mlx5dv_flow_action_flags */ +}; +``` + +*comp_mask* +: Bitmask specifying what fields in the structure are valid (*enum mlx5dv_flow_action_esp_mask*). + +*action_flags* +: A bitwise OR of the various values described below. + + *MLX5DV_FLOW_ACTION_FLAGS_REQUIRE_METADATA*: + Each received and transmitted packet using offload is expected to carry metadata in the form of a L2 header + with ethernet type 0x8CE4, followed by 6 bytes of data and the original packet ethertype. + +# NOTE + +The ESN is expected to be placed in the IV field for egress packets. +The 64 bit sequence number is written in big-endian over the 64 bit IV field. +There is no need to call modify to update the ESN window on egress when this DV is used. + +# SEE ALSO + +*ibv_flow_action_esp(3)*, *RFC 4106* + diff --git a/providers/mlx5/mlx5_api.h b/providers/mlx5/mlx5_api.h new file mode 100644 index 0000000..b87f897 --- /dev/null +++ b/providers/mlx5/mlx5_api.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_API_H +#define MLX5_API_H + +#include + +#define mlx5dv_flow_action_flags mlx5_ib_uapi_flow_action_flags +#define MLX5DV_FLOW_ACTION_FLAGS_REQUIRE_METADATA MLX5_IB_UAPI_FLOW_ACTION_FLAGS_REQUIRE_METADATA + +#endif diff --git a/providers/mlx5/mlx5dv.h b/providers/mlx5/mlx5dv.h index 6a7e1d1..37aee18 100644 --- a/providers/mlx5/mlx5dv.h +++ b/providers/mlx5/mlx5dv.h @@ -45,6 +45,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -171,6 +172,20 @@ struct mlx5dv_qp_init_attr { struct ibv_qp *mlx5dv_create_qp(struct ibv_context *context, struct ibv_qp_init_attr_ex *qp_attr, struct mlx5dv_qp_init_attr *mlx5_qp_attr); + +enum mlx5dv_flow_action_esp_mask { + MLX5DV_FLOW_ACTION_ESP_MASK_FLAGS = 1 << 0, +}; + +struct mlx5dv_flow_action_esp { + uint64_t comp_mask; /* Use enum mlx5dv_flow_action_esp_mask */ + uint32_t action_flags; /* Use enum mlx5dv_flow_action_flags */ +}; + +struct ibv_flow_action *mlx5dv_create_flow_action_esp(struct ibv_context *ctx, + struct ibv_flow_action_esp_attr *esp, + struct mlx5dv_flow_action_esp *mlx5_attr); + /* * Most device capabilities are exported by ibv_query_device(...), * but there is HW device-specific information which is important diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index 06f6408..99b30e8 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -46,6 +46,8 @@ #include #include +#include +#include #include "mlx5.h" #include "mlx5-abi.h" @@ -2998,6 +3000,33 @@ struct ibv_flow_action *mlx5_create_flow_action_esp(struct ibv_context *ctx, return _mlx5_create_flow_action_esp(ctx, attr, NULL); } +struct ibv_flow_action *mlx5dv_create_flow_action_esp(struct ibv_context *ctx, + struct ibv_flow_action_esp_attr *esp, + struct mlx5dv_flow_action_esp *mlx5_attr) +{ + DECLARE_COMMAND_BUFFER_LINK(driver_attr, UVERBS_OBJECT_FLOW_ACTION, + UVERBS_METHOD_FLOW_ACTION_ESP_CREATE, 1, + NULL); + + if (!check_comp_mask(mlx5_attr->comp_mask, + MLX5DV_FLOW_ACTION_ESP_MASK_FLAGS)) { + errno = EOPNOTSUPP; + return NULL; + } + + if (mlx5_attr->comp_mask & MLX5DV_FLOW_ACTION_ESP_MASK_FLAGS) { + if (!check_comp_mask(mlx5_attr->action_flags, + MLX5_IB_UAPI_FLOW_ACTION_FLAGS_REQUIRE_METADATA)) { + errno = EOPNOTSUPP; + return NULL; + } + fill_attr_in_uint64(driver_attr, MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS, + mlx5_attr->action_flags); + } + + return _mlx5_create_flow_action_esp(ctx, esp, driver_attr); +} + int mlx5_modify_flow_action_esp(struct ibv_flow_action *action, struct ibv_flow_action_esp_attr *attr) {