From patchwork Wed Sep 12 16:04:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10597949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17FD1921 for ; Wed, 12 Sep 2018 16:04:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0851E2A664 for ; Wed, 12 Sep 2018 16:04:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0CEE2A67C; Wed, 12 Sep 2018 16:04:40 +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 8D4352A664 for ; Wed, 12 Sep 2018 16:04:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726985AbeILVJt (ORCPT ); Wed, 12 Sep 2018 17:09:49 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:41759 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726821AbeILVJt (ORCPT ); Wed, 12 Sep 2018 17:09:49 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 12 Sep 2018 19:08:48 +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 w8CG4X6j020174; Wed, 12 Sep 2018 19:04:33 +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 w8CG4XXD029559; Wed, 12 Sep 2018 19:04:33 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w8CG4Xut029557; Wed, 12 Sep 2018 19:04:33 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, jgg@mellanox.com, markb@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 1/4] Update kernel headers Date: Wed, 12 Sep 2018 19:04:06 +0300 Message-Id: <1536768249-29432-2-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1536768249-29432-1-git-send-email-yishaih@mellanox.com> References: <1536768249-29432-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 To commit a090d0d859ff ("RDMA/mlx5: Extend packet reformat verbs") Signed-off-by: Yishai Hadas --- kernel-headers/rdma/mlx5_user_ioctl_cmds.h | 18 ++++++++++++++++++ kernel-headers/rdma/mlx5_user_ioctl_verbs.h | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/kernel-headers/rdma/mlx5_user_ioctl_cmds.h b/kernel-headers/rdma/mlx5_user_ioctl_cmds.h index 9c51801..75c7093 100644 --- a/kernel-headers/rdma/mlx5_user_ioctl_cmds.h +++ b/kernel-headers/rdma/mlx5_user_ioctl_cmds.h @@ -166,4 +166,22 @@ enum mlx5_ib_flow_methods { MLX5_IB_METHOD_DESTROY_FLOW, }; +enum mlx5_ib_flow_action_methods { + MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER = (1U << UVERBS_ID_NS_SHIFT), + MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT, +}; + +enum mlx5_ib_create_flow_action_create_modify_header_attrs { + MLX5_IB_ATTR_CREATE_MODIFY_HEADER_HANDLE = (1U << UVERBS_ID_NS_SHIFT), + MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM, + MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE, +}; + +enum mlx5_ib_create_flow_action_create_packet_reformat_attrs { + MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE = (1U << UVERBS_ID_NS_SHIFT), + MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE, + MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_FT_TYPE, + MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_BUF, +}; + #endif diff --git a/kernel-headers/rdma/mlx5_user_ioctl_verbs.h b/kernel-headers/rdma/mlx5_user_ioctl_verbs.h index 8a2fb33..4ef62c0 100644 --- a/kernel-headers/rdma/mlx5_user_ioctl_verbs.h +++ b/kernel-headers/rdma/mlx5_user_ioctl_verbs.h @@ -39,5 +39,17 @@ enum mlx5_ib_uapi_flow_action_flags { MLX5_IB_UAPI_FLOW_ACTION_FLAGS_REQUIRE_METADATA = 1 << 0, }; +enum mlx5_ib_uapi_flow_table_type { + MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX = 0x0, + MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX = 0x1, +}; + +enum mlx5_ib_uapi_flow_action_packet_reformat_type { + MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 = 0x0, + MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL = 0x1, + MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 = 0x2, + MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL = 0x3, +}; + #endif From patchwork Wed Sep 12 16:04:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10597951 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64C9F14BD for ; Wed, 12 Sep 2018 16:04:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 548FE2A5D2 for ; Wed, 12 Sep 2018 16:04:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 486262A674; Wed, 12 Sep 2018 16:04:41 +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 ED7FE2A669 for ; Wed, 12 Sep 2018 16:04:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbeILVJu (ORCPT ); Wed, 12 Sep 2018 17:09:50 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:41761 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726912AbeILVJt (ORCPT ); Wed, 12 Sep 2018 17:09:49 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 12 Sep 2018 19:08:48 +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 w8CG4XIK020180; Wed, 12 Sep 2018 19:04:33 +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 w8CG4Xxf029563; Wed, 12 Sep 2018 19:04:33 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w8CG4XwK029562; Wed, 12 Sep 2018 19:04:33 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, jgg@mellanox.com, markb@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 2/4] verbs: Expose a new accessor to be used with enum values Date: Wed, 12 Sep 2018 19:04:07 +0300 Message-Id: <1536768249-29432-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1536768249-29432-1-git-send-email-yishaih@mellanox.com> References: <1536768249-29432-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: Mark Bloch When the kernel expects to get an enum const value, use fill_attr_const_in(). The enum value is passed as uint64 value. Signed-off-by: Mark Bloch Signed-off-by: Yishai Hadas --- libibverbs/cmd_ioctl.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libibverbs/cmd_ioctl.h b/libibverbs/cmd_ioctl.h index 3a61f59..f856b74 100644 --- a/libibverbs/cmd_ioctl.h +++ b/libibverbs/cmd_ioctl.h @@ -296,6 +296,9 @@ fill_attr_in_uint64(struct ibv_command_buffer *cmd, uint16_t attr_id, return attr; } +#define fill_attr_const_in(cmd, attr_id, _data) \ + fill_attr_in_uint64(cmd, attr_id, _data) + static inline struct ib_uverbs_attr * fill_attr_in_uint32(struct ibv_command_buffer *cmd, uint16_t attr_id, uint32_t data) From patchwork Wed Sep 12 16:04: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: 10597955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9097814BD for ; Wed, 12 Sep 2018 16:04:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D49F2A5D2 for ; Wed, 12 Sep 2018 16:04:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 712FB2A674; Wed, 12 Sep 2018 16:04:42 +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 EF0F12A5D2 for ; Wed, 12 Sep 2018 16:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbeILVJv (ORCPT ); Wed, 12 Sep 2018 17:09:51 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:41762 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726677AbeILVJu (ORCPT ); Wed, 12 Sep 2018 17:09:50 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 12 Sep 2018 19:08:48 +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 w8CG4XWm020183; Wed, 12 Sep 2018 19:04:33 +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 w8CG4X8A029567; Wed, 12 Sep 2018 19:04:33 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w8CG4X0m029566; Wed, 12 Sep 2018 19:04:33 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, jgg@mellanox.com, markb@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 3/4] mlx5: Add modify header flow action Date: Wed, 12 Sep 2018 19:04:08 +0300 Message-Id: <1536768249-29432-4-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1536768249-29432-1-git-send-email-yishaih@mellanox.com> References: <1536768249-29432-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: Mark Bloch Expose a new flow action as DV, modify header. It allows to create a flow action which mutates packet headers. It can be attached to steering rules via ibv_create_flow(). Signed-off-by: Mark Bloch Signed-off-by: Yishai Hadas --- debian/ibverbs-providers.symbols | 2 ++ providers/mlx5/CMakeLists.txt | 2 +- providers/mlx5/libmlx5.map | 5 +++++ providers/mlx5/mlx5_api.h | 3 +++ providers/mlx5/mlx5dv.h | 20 ++++++++++++++++++++ providers/mlx5/verbs.c | 38 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 69 insertions(+), 1 deletion(-) diff --git a/debian/ibverbs-providers.symbols b/debian/ibverbs-providers.symbols index 11ea417..839a744 100644 --- a/debian/ibverbs-providers.symbols +++ b/debian/ibverbs-providers.symbols @@ -12,6 +12,7 @@ libmlx5.so.1 ibverbs-providers #MINVER# MLX5_1.4@MLX5_1.4 17 MLX5_1.5@MLX5_1.5 18 MLX5_1.6@MLX5_1.6 20 + MLX5_1.7@MLX5_1.7 21 mlx5dv_init_obj@MLX5_1.0 13 mlx5dv_init_obj@MLX5_1.2 15 mlx5dv_query_device@MLX5_1.0 13 @@ -24,3 +25,4 @@ libmlx5.so.1 ibverbs-providers #MINVER# mlx5dv_create_flow_matcher@MLX5_1.6 20 mlx5dv_destroy_flow_matcher@MLX5_1.6 20 mlx5dv_create_flow@MLX5_1.6 20 + mlx5dv_create_flow_action_modify_header@MLX5_1.7 21 diff --git a/providers/mlx5/CMakeLists.txt b/providers/mlx5/CMakeLists.txt index 4a0f88b..1d0961c 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.6.${PACKAGE_VERSION} + 1 1.7.${PACKAGE_VERSION} buf.c cq.c dbrec.c diff --git a/providers/mlx5/libmlx5.map b/providers/mlx5/libmlx5.map index 7501fa7..80d5654 100644 --- a/providers/mlx5/libmlx5.map +++ b/providers/mlx5/libmlx5.map @@ -40,3 +40,8 @@ MLX5_1.6 { mlx5dv_destroy_flow_matcher; mlx5dv_create_flow; } MLX5_1.5; + +MLX5_1.7 { + global: + mlx5dv_create_flow_action_modify_header; +} MLX5_1.6; diff --git a/providers/mlx5/mlx5_api.h b/providers/mlx5/mlx5_api.h index b87f897..8373b12 100644 --- a/providers/mlx5/mlx5_api.h +++ b/providers/mlx5/mlx5_api.h @@ -37,5 +37,8 @@ #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 +#define mlx5dv_flow_table_type mlx5_ib_uapi_flow_table_type +#define MLX5DV_FLOW_TABLE_TYPE_NIC_RX MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX +#define MLX5DV_FLOW_TABLE_TYPE_NIC_TX MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX #endif diff --git a/providers/mlx5/mlx5dv.h b/providers/mlx5/mlx5dv.h index b592029..bee29e0 100644 --- a/providers/mlx5/mlx5dv.h +++ b/providers/mlx5/mlx5dv.h @@ -245,6 +245,26 @@ struct ibv_flow_action *mlx5dv_create_flow_action_esp(struct ibv_context *ctx, struct mlx5dv_flow_action_esp *mlx5_attr); /* + * mlx5dv_create_flow_action_modify_header - Create a flow action which mutates + * a packet. The flow action can be attached to steering rules via + * ibv_create_flow(). + * + * @ctx: RDMA device context to create the action on. + * @actions_sz: The size of *actions* buffer in bytes. + * @actions: A buffer which contains modify actions provided in device spec + * format. + * @ft_type: Defines the flow table type to which the modify + * header action will be attached. + * + * Return a valid ibv_flow_action if successful, NULL otherwise. + */ +struct ibv_flow_action * +mlx5dv_create_flow_action_modify_header(struct ibv_context *ctx, + size_t actions_sz, + uint64_t actions[], + enum mlx5dv_flow_table_type ft_type); + +/* * Most device capabilities are exported by ibv_query_device(...), * but there is HW device-specific information which is important * for data-path, but isn't provided. diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index ff40029..1e61f44 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -3317,6 +3317,44 @@ int mlx5_modify_flow_action_esp(struct ibv_flow_action *action, return ibv_cmd_modify_flow_action_esp(vaction, attr, NULL); } +struct ibv_flow_action *mlx5dv_create_flow_action_modify_header(struct ibv_context *ctx, + size_t actions_sz, + uint64_t actions[], + enum mlx5dv_flow_table_type ft_type) +{ + DECLARE_COMMAND_BUFFER(cmd, UVERBS_OBJECT_FLOW_ACTION, + MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER, + 3); + struct ib_uverbs_attr *handle = fill_attr_out_obj(cmd, + MLX5_IB_ATTR_CREATE_MODIFY_HEADER_HANDLE); + struct verbs_flow_action *action; + int ret; + + fill_attr_in(cmd, MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM, + actions, actions_sz); + fill_attr_const_in(cmd, MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE, + ft_type); + + action = calloc(1, sizeof(*action)); + if (!action) { + errno = ENOMEM; + return NULL; + } + + ret = execute_ioctl(ctx, cmd); + if (ret) { + free(action); + return NULL; + } + + action->action.context = ctx; + action->type = IBV_FLOW_ACTION_UNSPECIFIED; + action->handle = read_attr_obj(MLX5_IB_ATTR_CREATE_MODIFY_HEADER_HANDLE, + handle); + + return &action->action; +} + int mlx5_destroy_flow_action(struct ibv_flow_action *action) { struct verbs_flow_action *vaction = From patchwork Wed Sep 12 16:04: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: 10597957 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDD101575 for ; Wed, 12 Sep 2018 16:04:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCED42A664 for ; Wed, 12 Sep 2018 16:04:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B157B2A67C; Wed, 12 Sep 2018 16:04:42 +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 3ADF12A664 for ; Wed, 12 Sep 2018 16:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726854AbeILVJu (ORCPT ); Wed, 12 Sep 2018 17:09:50 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:41760 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726945AbeILVJt (ORCPT ); Wed, 12 Sep 2018 17:09:49 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 12 Sep 2018 19:08:48 +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 w8CG4XpF020186; Wed, 12 Sep 2018 19:04:33 +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 w8CG4XMV029622; Wed, 12 Sep 2018 19:04:33 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w8CG4Xfa029621; Wed, 12 Sep 2018 19:04:33 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, jgg@mellanox.com, markb@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 4/4] mlx5: Add packet reformat flow action Date: Wed, 12 Sep 2018 19:04:09 +0300 Message-Id: <1536768249-29432-5-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1536768249-29432-1-git-send-email-yishaih@mellanox.com> References: <1536768249-29432-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: Mark Bloch A new DV is used to expose the creation of a packet reformat context. It can be used to do decap/encap of packets. It can be attached to steering flow rules via ibv_create_flow(). Signed-off-by: Mark Bloch Signed-off-by: Yishai Hadas --- debian/ibverbs-providers.symbols | 1 + providers/mlx5/libmlx5.map | 1 + providers/mlx5/man/CMakeLists.txt | 1 + .../man/mlx5dv_flow_action_packet_reformat.3.md | 63 ++++++++++++++++++++++ providers/mlx5/mlx5_api.h | 5 ++ providers/mlx5/mlx5dv.h | 10 ++++ providers/mlx5/verbs.c | 50 +++++++++++++++++ 7 files changed, 131 insertions(+) create mode 100644 providers/mlx5/man/mlx5dv_flow_action_packet_reformat.3.md diff --git a/debian/ibverbs-providers.symbols b/debian/ibverbs-providers.symbols index 839a744..98b4e16 100644 --- a/debian/ibverbs-providers.symbols +++ b/debian/ibverbs-providers.symbols @@ -26,3 +26,4 @@ libmlx5.so.1 ibverbs-providers #MINVER# mlx5dv_destroy_flow_matcher@MLX5_1.6 20 mlx5dv_create_flow@MLX5_1.6 20 mlx5dv_create_flow_action_modify_header@MLX5_1.7 21 + mlx5dv_create_flow_action_packet_reformat@MLX5_1.7 21 diff --git a/providers/mlx5/libmlx5.map b/providers/mlx5/libmlx5.map index 80d5654..ca697b4 100644 --- a/providers/mlx5/libmlx5.map +++ b/providers/mlx5/libmlx5.map @@ -44,4 +44,5 @@ MLX5_1.6 { MLX5_1.7 { global: mlx5dv_create_flow_action_modify_header; + mlx5dv_create_flow_action_packet_reformat; } MLX5_1.6; diff --git a/providers/mlx5/man/CMakeLists.txt b/providers/mlx5/man/CMakeLists.txt index cdc7115..420975c 100644 --- a/providers/mlx5/man/CMakeLists.txt +++ b/providers/mlx5/man/CMakeLists.txt @@ -1,5 +1,6 @@ rdma_man_pages( mlx5dv_flow_action_esp.3.md + mlx5dv_flow_action_packet_reformat.3.md mlx5dv_get_clock_info.3 mlx5dv_init_obj.3 mlx5dv_query_device.3 diff --git a/providers/mlx5/man/mlx5dv_flow_action_packet_reformat.3.md b/providers/mlx5/man/mlx5dv_flow_action_packet_reformat.3.md new file mode 100644 index 0000000..099fd89 --- /dev/null +++ b/providers/mlx5/man/mlx5dv_flow_action_packet_reformat.3.md @@ -0,0 +1,63 @@ + +--- +layout: page +title: mlx5dv_flow_action_packet_reformat +section: 3 +tagline: Verbs +--- + +# NAME + +mlx5dv_flow_action_packet_reformat - Flow action reformat packet for mlx5 provider + +# SYNOPSIS + +```c +#include + +struct ibv_flow_action * +mlx5dv_create_flow_action_packet_reformat(struct ibv_context *ctx, + size_t data_sz, + void *data, + enum mlx5dv_flow_action_packet_reformat_type reformat_type, + enum mlx5dv_flow_table_type ft_type) +``` + +# DESCRIPTION + +Create a packet reformat flow steering action. +It allows to add/remove packet headers. + +# ARGUMENTS +*ctx* +: RDMA device context to create the action on. + +*data_sz* +: The size of *data* buffer. + +*data* +: A buffer which contains headers in case the actions requires them. + +*reformat_type* +: The reformat type to be create. Use enum mlx5dv_flow_action_packet_reformat_type. + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2: Decap a generic L2 + tunneled packet upto inner L2. + + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL: Generic encap, *data* + should contain the encapsulating headers. + + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2: Will do decap where + the inner packet starts from L3. *data* should be MAC or MAC + vlan (14 or 18 bytes) to be + appended to the packet after the decap action. + + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL: Will do encap where is + L2 of the original packet will not be included. *data* should be the encapsulating header. + +*ft_type* +: It defines the flow table type to which the packet reformat action + will be attached. + +# SEE ALSO + +*ibv_create_flow(3)* *ibv_create_flow_action(3)* + diff --git a/providers/mlx5/mlx5_api.h b/providers/mlx5/mlx5_api.h index 8373b12..bc5de06 100644 --- a/providers/mlx5/mlx5_api.h +++ b/providers/mlx5/mlx5_api.h @@ -40,5 +40,10 @@ #define mlx5dv_flow_table_type mlx5_ib_uapi_flow_table_type #define MLX5DV_FLOW_TABLE_TYPE_NIC_RX MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_RX #define MLX5DV_FLOW_TABLE_TYPE_NIC_TX MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX +#define mlx5dv_flow_action_packet_reformat_type mlx5_ib_uapi_flow_action_packet_reformat_type +#define MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 +#define MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL +#define MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 +#define MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL MLX5_IB_UAPI_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL #endif diff --git a/providers/mlx5/mlx5dv.h b/providers/mlx5/mlx5dv.h index bee29e0..bb9aaaa 100644 --- a/providers/mlx5/mlx5dv.h +++ b/providers/mlx5/mlx5dv.h @@ -265,6 +265,16 @@ mlx5dv_create_flow_action_modify_header(struct ibv_context *ctx, enum mlx5dv_flow_table_type ft_type); /* + * mlx5dv_create_flow_action_packet_reformat - Create flow action which can + * encap/decap packets. + */ +struct ibv_flow_action * +mlx5dv_create_flow_action_packet_reformat(struct ibv_context *ctx, + size_t data_sz, + void *data, + enum mlx5dv_flow_action_packet_reformat_type reformat_type, + enum mlx5dv_flow_table_type ft_type); +/* * Most device capabilities are exported by ibv_query_device(...), * but there is HW device-specific information which is important * for data-path, but isn't provided. diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index 1e61f44..de731ce 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -3355,6 +3355,56 @@ struct ibv_flow_action *mlx5dv_create_flow_action_modify_header(struct ibv_conte return &action->action; } +struct ibv_flow_action * +mlx5dv_create_flow_action_packet_reformat(struct ibv_context *ctx, + size_t data_sz, + void *data, + enum mlx5dv_flow_action_packet_reformat_type reformat_type, + enum mlx5dv_flow_table_type ft_type) +{ + DECLARE_COMMAND_BUFFER(cmd, UVERBS_OBJECT_FLOW_ACTION, + MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT, 4); + struct ib_uverbs_attr *handle = fill_attr_out_obj(cmd, + MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE); + struct verbs_flow_action *action; + int ret; + + if ((!data && data_sz) || (data && !data_sz)) { + errno = EINVAL; + return NULL; + } + + if (data && data_sz) + fill_attr_in(cmd, + MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_BUF, + data, data_sz); + + fill_attr_const_in(cmd, MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE, + reformat_type); + + fill_attr_const_in(cmd, MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_FT_TYPE, + ft_type); + + action = calloc(1, sizeof(*action)); + if (!action) { + errno = ENOMEM; + return NULL; + } + + ret = execute_ioctl(ctx, cmd); + if (ret) { + free(action); + return NULL; + } + + action->action.context = ctx; + action->type = IBV_FLOW_ACTION_UNSPECIFIED; + action->handle = read_attr_obj(MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE, + handle); + + return &action->action; +} + int mlx5_destroy_flow_action(struct ibv_flow_action *action) { struct verbs_flow_action *vaction =