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 54DC0A0350; Thu, 25 Jun 2020 18:51:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8E51C1BDFD; Thu, 25 Jun 2020 18:50:48 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id DD6E32B96 for ; Thu, 25 Jun 2020 18:50:38 +0200 (CEST) From: Jiawei Wang To: orika@mellanox.com, viacheslavo@mellanox.com, matan@mellanox.com Cc: dev@dpdk.org, thomas@monjalon.net, rasland@mellanox.com, ian.stokes@intel.com, fbl@redhat.com, jiaweiw@mellanox.com Date: Thu, 25 Jun 2020 19:26:18 +0300 Message-Id: <1593102379-400132-8-git-send-email-jiaweiw@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593102379-400132-1-git-send-email-jiaweiw@mellanox.com> References: <1593102379-400132-1-git-send-email-jiaweiw@mellanox.com> Subject: [dpdk-dev] [PATCH 7/8] net/mlx5: update the metadata register c0 support 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" For Sample flow, it splits into two sub flows and using metadata register as matcher between two flows. Meatadata register C0 filed might be also used for source vport index if kernel uses this field, this changes add the checking while do tag action with reg_c0 to decide using upper or lower 16-bits of metadata register c0 filed. Signed-off-by: Jiawei Wang --- drivers/net/mlx5/mlx5_flow_dv.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 62a4a3b..ed9d2d2e 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -980,13 +980,24 @@ struct field_modify_info modify_tcp[] = { */ static int flow_dv_convert_action_set_reg - (struct mlx5_flow_dv_modify_hdr_resource *resource, + (struct rte_eth_dev *dev, + struct mlx5_flow_dv_modify_hdr_resource *resource, const struct rte_flow_action *action, struct rte_flow_error *error) { const struct mlx5_rte_flow_action_set_tag *conf = action->conf; - struct mlx5_modification_cmd *actions = resource->actions; uint32_t i = resource->actions_num; + struct mlx5_priv *priv = dev->data->dev_private; + rte_be32_t mask = UINT32_MAX; + rte_be32_t data = rte_cpu_to_be_32(conf->data) & mask; + struct rte_flow_item item = { + .spec = &data, + .mask = &mask, + }; + struct field_modify_info reg_c_x[] = { + [1] = {0, 0, 0}, + }; + int reg = conf->id; if (i >= MLX5_MAX_MODIFY_NUM) return rte_flow_error_set(error, EINVAL, @@ -994,15 +1005,16 @@ struct field_modify_info modify_tcp[] = { "too many items to modify"); MLX5_ASSERT(conf->id != REG_NONE); MLX5_ASSERT(conf->id < RTE_DIM(reg_to_field)); - actions[i] = (struct mlx5_modification_cmd) { - .action_type = MLX5_MODIFICATION_TYPE_SET, - .field = reg_to_field[conf->id], - }; - actions[i].data0 = rte_cpu_to_be_32(actions[i].data0); - actions[i].data1 = rte_cpu_to_be_32(conf->data); - ++i; - resource->actions_num = i; - return 0; + if (reg == REG_C_0) { + uint32_t msk_c0 = priv->sh->dv_regc0_mask; + uint32_t shl_c0 = rte_bsf32(msk_c0); + data = rte_cpu_to_be_32(rte_cpu_to_be_32(data) << shl_c0); + mask = rte_cpu_to_be_32(mask) & msk_c0; + mask = rte_cpu_to_be_32(mask << shl_c0); + } + reg_c_x[0] = (struct field_modify_info){4, 0, reg_to_field[reg]}; + return flow_dv_convert_modify_action(&item, reg_c_x, NULL, resource, + MLX5_MODIFICATION_TYPE_SET, error); } /** @@ -8722,7 +8734,7 @@ struct field_modify_info modify_tcp[] = { break; case MLX5_RTE_FLOW_ACTION_TYPE_TAG: if (flow_dv_convert_action_set_reg - (mhdr_res, actions, error)) + (dev, mhdr_res, actions, error)) return -rte_errno; action_flags |= MLX5_FLOW_ACTION_SET_TAG; break; -- 1.8.3.1