From patchwork Mon Jul 9 15:52: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: 10515051 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 44F66600CA for ; Mon, 9 Jul 2018 15:52:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C6028C79 for ; Mon, 9 Jul 2018 15:52:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2858A28D49; Mon, 9 Jul 2018 15:52: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 A15C628C79 for ; Mon, 9 Jul 2018 15:52:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933928AbeGIPwj (ORCPT ); Mon, 9 Jul 2018 11:52:39 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:42487 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933004AbeGIPwg (ORCPT ); Mon, 9 Jul 2018 11:52:36 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 9 Jul 2018 18:55:27 +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 w69FqVAX007092; Mon, 9 Jul 2018 18:52:31 +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 w69FqV34019308; Mon, 9 Jul 2018 18:52:31 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w69FqVhm019307; Mon, 9 Jul 2018 18:52:31 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, majd@mellanox.com, jgg@mellanox.com Subject: [PATCH rdma-core 3/4] mlx5: Introduce flow matcher and its related DV APIs Date: Mon, 9 Jul 2018 18:52:09 +0300 Message-Id: <1531151530-19188-4-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1531151530-19188-1-git-send-email-yishaih@mellanox.com> References: <1531151530-19188-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 Introduce mlx5 flow matcher object and its related DV APIs. The flow matcher object matches to the device specification and enables creating a flow object that supports the device options. Downstream patches from this series use the matcher object as part of flow creation. Signed-off-by: Yishai Hadas --- debian/ibverbs-providers.symbols | 3 ++ providers/mlx5/CMakeLists.txt | 2 +- providers/mlx5/libmlx5.map | 6 ++++ providers/mlx5/mlx5.h | 5 +++ providers/mlx5/mlx5dv.h | 22 +++++++++++++ providers/mlx5/verbs.c | 69 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 106 insertions(+), 1 deletion(-) diff --git a/debian/ibverbs-providers.symbols b/debian/ibverbs-providers.symbols index 3143f6f..f0c54f8 100644 --- a/debian/ibverbs-providers.symbols +++ b/debian/ibverbs-providers.symbols @@ -11,6 +11,7 @@ libmlx5.so.1 ibverbs-providers #MINVER# MLX5_1.3@MLX5_1.3 16 MLX5_1.4@MLX5_1.4 17 MLX5_1.5@MLX5_1.5 18 + MLX5_1.6@MLX5_1.6 20 mlx5dv_init_obj@MLX5_1.0 13 mlx5dv_init_obj@MLX5_1.2 15 mlx5dv_query_device@MLX5_1.0 13 @@ -20,3 +21,5 @@ libmlx5.so.1 ibverbs-providers #MINVER# mlx5dv_create_wq@MLX5_1.3 16 mlx5dv_get_clock_info@MLX5_1.4 17 mlx5dv_create_flow_action_esp@MLX5_1.5 18 + mlx5dv_create_flow_matcher@MLX5_1.6 20 + mlx5dv_destroy_flow_matcher@MLX5_1.6 20 diff --git a/providers/mlx5/CMakeLists.txt b/providers/mlx5/CMakeLists.txt index 5a4b47f..7328c56 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.5.${PACKAGE_VERSION} + 1 1.6.${PACKAGE_VERSION} buf.c cq.c dbrec.c diff --git a/providers/mlx5/libmlx5.map b/providers/mlx5/libmlx5.map index 410cc0e..8538f5e 100644 --- a/providers/mlx5/libmlx5.map +++ b/providers/mlx5/libmlx5.map @@ -33,3 +33,9 @@ MLX5_1.5 { global: mlx5dv_create_flow_action_esp; } MLX5_1.4; + +MLX5_1.6 { + global: + mlx5dv_create_flow_matcher; + mlx5dv_destroy_flow_matcher; +} MLX5_1.5; diff --git a/providers/mlx5/mlx5.h b/providers/mlx5/mlx5.h index 16ce2cc..16404a8 100644 --- a/providers/mlx5/mlx5.h +++ b/providers/mlx5/mlx5.h @@ -557,6 +557,11 @@ struct mlx5_flow { struct mlx5_counters *mcounters; }; +struct mlx5dv_flow_matcher { + struct ibv_context *context; + uint32_t handle; +}; + static inline int mlx5_ilog2(int n) { int t; diff --git a/providers/mlx5/mlx5dv.h b/providers/mlx5/mlx5dv.h index acf0a13..9710133 100644 --- a/providers/mlx5/mlx5dv.h +++ b/providers/mlx5/mlx5dv.h @@ -194,6 +194,28 @@ struct mlx5dv_flow_action_esp { uint32_t action_flags; /* Use enum mlx5dv_flow_action_flags */ }; +struct mlx5dv_flow_match_parameters { + size_t match_sz; + uint64_t match_buf[]; /* Device spec format */ +}; + +struct mlx5dv_flow_matcher_attr { + enum ibv_flow_attr_type type; + uint32_t flags; /* From enum ibv_flow_flags */ + uint16_t priority; + uint8_t match_criteria_enable; /* Device spec format */ + struct mlx5dv_flow_match_parameters *match_mask; + uint64_t comp_mask; +}; + +struct mlx5dv_flow_matcher; + +struct mlx5dv_flow_matcher * +mlx5dv_create_flow_matcher(struct ibv_context *context, + struct mlx5dv_flow_matcher_attr *matcher_attr); + +int mlx5dv_destroy_flow_matcher(struct mlx5dv_flow_matcher *matcher); + 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); diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index e95cdb8..2654c45 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -3542,3 +3542,72 @@ int mlx5_read_counters(struct ibv_counters *counters, NULL); } + +struct mlx5dv_flow_matcher * +mlx5dv_create_flow_matcher(struct ibv_context *context, + struct mlx5dv_flow_matcher_attr *attr) +{ + DECLARE_COMMAND_BUFFER_LINK(cmd, MLX5_IB_OBJECT_FLOW_MATCHER, + MLX5_IB_METHOD_FLOW_MATCHER_CREATE, + 4, + NULL); + struct mlx5dv_flow_matcher *flow_matcher; + struct ib_uverbs_attr *handle; + int ret; + + if (!check_comp_mask(attr->comp_mask, 0)) { + errno = EOPNOTSUPP; + return NULL; + } + + flow_matcher = calloc(1, sizeof(*flow_matcher)); + if (!flow_matcher) { + errno = ENOMEM; + return NULL; + } + + if (attr->type != IBV_FLOW_ATTR_NORMAL) { + errno = EOPNOTSUPP; + goto err; + } + + handle = fill_attr_out_obj(cmd, MLX5_IB_ATTR_FLOW_MATCHER_CREATE_HANDLE); + fill_attr_in(cmd, MLX5_IB_ATTR_FLOW_MATCHER_MATCH_MASK, + attr->match_mask->match_buf, + attr->match_mask->match_sz); + fill_attr_in(cmd, MLX5_IB_ATTR_FLOW_MATCHER_MATCH_CRITERIA, + &attr->match_criteria_enable, sizeof(attr->match_criteria_enable)); + fill_attr_in_enum(cmd, MLX5_IB_ATTR_FLOW_MATCHER_FLOW_TYPE, + IBV_FLOW_ATTR_NORMAL, &attr->priority, + sizeof(attr->priority)); + + ret = execute_ioctl(context, cmd); + if (ret) + goto err; + + flow_matcher->context = context; + flow_matcher->handle = read_attr_obj(MLX5_IB_ATTR_FLOW_MATCHER_CREATE_HANDLE, handle); + + return flow_matcher; + +err: + free(flow_matcher); + return NULL; +} + +int mlx5dv_destroy_flow_matcher(struct mlx5dv_flow_matcher *flow_matcher) +{ + DECLARE_COMMAND_BUFFER(cmd, MLX5_IB_OBJECT_FLOW_MATCHER, + MLX5_IB_METHOD_FLOW_MATCHER_DESTROY, + 1); + int ret; + + fill_attr_in_obj(cmd, MLX5_IB_ATTR_FLOW_MATCHER_DESTROY_HANDLE, flow_matcher->handle); + ret = execute_ioctl(flow_matcher->context, cmd); + + if (ret) + return ret; + + free(flow_matcher); + return 0; +}