From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C969BA09FF; Mon, 28 Dec 2020 13:42:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8B7E0CBCD; Mon, 28 Dec 2020 13:34:18 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 8F73CCA60 for ; Mon, 28 Dec 2020 13:33:37 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@nvidia.com) with SMTP; 28 Dec 2020 14:33:35 +0200 Received: from nvidia.com (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0BSCXWng001295; Mon, 28 Dec 2020 14:33:34 +0200 From: Tal Shnaiderman To: dev@dpdk.org Cc: thomas@monjalon.net, matan@nvidia.com, rasland@nvidia.com, ophirmu@nvidia.com Date: Mon, 28 Dec 2020 14:32:54 +0200 Message-Id: <20201228123302.3608-28-talshn@nvidia.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20201228123302.3608-1-talshn@nvidia.com> References: <20201217173037.11396-2-talshn@nvidia.com> <20201228123302.3608-1-talshn@nvidia.com> Subject: [dpdk-dev] [PATCH v2 27/35] net/mlx5/windows: create flow rule X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ophir Munk This commit implements mlx5_flow_os_create_flow() API. It is equivalent to Linux rdma-core implementation. The API receives the matcher mask, matcher value and an array of actions. They are copied into a PRM-like struct devx_fs_rule_add_in. Then glue API devx_fs_rule_add() is called. Signed-off-by: Ophir Munk Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_prm.h | 6 +++++ drivers/net/mlx5/windows/mlx5_flow_os.c | 46 ++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index ac42238d30..8c9b53ce10 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -825,6 +825,12 @@ struct mlx5_ifc_fte_match_param_bits { #endif }; +struct mlx5_ifc_dest_format_struct_bits { + u8 destination_type[0x8]; + u8 destination_id[0x18]; + u8 reserved_0[0x20]; +}; + enum { MLX5_MATCH_CRITERIA_ENABLE_OUTER_BIT, MLX5_MATCH_CRITERIA_ENABLE_MISC_BIT, diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c index 0c0fba3720..daf4e15ddb 100644 --- a/drivers/net/mlx5/windows/mlx5_flow_os.c +++ b/drivers/net/mlx5/windows/mlx5_flow_os.c @@ -187,13 +187,41 @@ mlx5_flow_os_create_flow(void *matcher, void *match_value, size_t num_actions, void *actions[], void **flow) { - RTE_SET_USED(matcher); - RTE_SET_USED(match_value); - RTE_SET_USED(num_actions); - RTE_SET_USED(actions); - *flow = NULL; - rte_errno = ENOTSUP; - return -rte_errno; + struct mlx5_action *action; + int i; + struct mlx5_matcher *mlx5_matcher = matcher; + struct mlx5_flow_dv_match_params *mlx5_match_value = match_value; + uint32_t in[MLX5_ST_SZ_DW(devx_fs_rule_add_in)] = {0}; + void *matcher_c = MLX5_ADDR_OF(devx_fs_rule_add_in, in, + match_criteria); + void *matcher_v = MLX5_ADDR_OF(devx_fs_rule_add_in, in, + match_value); + + MLX5_ASSERT(mlx5_matcher->ctx); + memcpy(matcher_c, mlx5_matcher->match_buf, + mlx5_match_value->size); + /* Use mlx5_match_value->size for match criteria */ + memcpy(matcher_v, mlx5_match_value->buf, + mlx5_match_value->size); + for (i = 0; i < num_actions; i++) { + action = actions[i]; + switch (action->type) { + case MLX5_FLOW_CONTEXT_DEST_TYPE_TIR: + MLX5_SET(devx_fs_rule_add_in, in, + dest.destination_type, + MLX5_FLOW_CONTEXT_DEST_TYPE_TIR); + MLX5_SET(devx_fs_rule_add_in, in, + dest.destination_id, + action->dest_tir.id); + break; + default: + break; + } + MLX5_SET(devx_fs_rule_add_in, in, match_criteria_enable, + MLX5_MATCH_OUTER_HEADERS); + } + *flow = mlx5_glue->devx_fs_rule_add(mlx5_matcher->ctx, in, sizeof(in)); + return (*flow) ? 0 : -1; } /** @@ -208,7 +236,5 @@ mlx5_flow_os_create_flow(void *matcher, void *match_value, int mlx5_flow_os_destroy_flow(void *drv_flow_ptr) { - RTE_SET_USED(dev_flow_ptr); - rte_errno = ENOTSUP; - return -rte_errno; + return mlx5_glue->devx_fs_rule_del(drv_flow_ptr); } -- 2.16.1.windows.4