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 49066A04B5; Wed, 28 Oct 2020 00:40:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2A7EEC836; Wed, 28 Oct 2020 00:25:28 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 0202A4C89 for ; Wed, 28 Oct 2020 00:24:02 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 28 Oct 2020 01:23:59 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09RNNrsJ026642; Wed, 28 Oct 2020 01:23:58 +0200 From: Ophir Munk To: dev@dpdk.org, Raslan Darawsheh Cc: Ophir Munk , Matan Azrad , Tal Shnaiderman , Thomas Monjalon Date: Tue, 27 Oct 2020 23:23:30 +0000 Message-Id: <20201027232335.31427-68-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20201027232335.31427-1-ophirmu@nvidia.com> References: <20201027232335.31427-1-ophirmu@nvidia.com> Subject: [dpdk-dev] [PATCH v1 67/72] 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" 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 --- 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 1dfd6bd..bbd15bf 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -809,6 +809,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 05010f4..bc5fd39 100644 --- a/drivers/net/mlx5/windows/mlx5_flow_os.c +++ b/drivers/net/mlx5/windows/mlx5_flow_os.c @@ -184,13 +184,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; } /** @@ -205,7 +233,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.8.4