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 97FCEA04B1; Wed, 9 Sep 2020 08:50:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5B2FF1C197; Wed, 9 Sep 2020 08:48:51 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id A6ACC1C0CE for ; Wed, 9 Sep 2020 08:48:36 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from jiaweiw@nvidia.com) with SMTP; 9 Sep 2020 09:48:34 +0300 Received: from nvidia.com (gen-l-vrt-280.mtl.labs.mlnx [10.237.45.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0896mYG7029471; Wed, 9 Sep 2020 09:48:34 +0300 From: Jiawei Wang To: orika@nvidia.com, viacheslavo@nvidia.com, matan@nvidia.com, thomas@monjalon.net, ferruh.yigit@intel.com, marko.kovacevic@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, rasland@nvidia.com, ian.stokes@intel.com, fbl@redhat.com, asafp@nvidia.com Date: Wed, 9 Sep 2020 09:48:34 +0300 Message-Id: <1599634114-148013-13-git-send-email-jiaweiw@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599634114-148013-1-git-send-email-jiaweiw@nvidia.com> References: <1598540492-406340-1-git-send-email-jiaweiw@nvidia.com> <1599634114-148013-1-git-send-email-jiaweiw@nvidia.com> Subject: [dpdk-dev] [PATCH v6 12/12] net/mlx5: support the native port id actions for mirroring 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 patch to support the mirroring with native port id action even without the sample action in the flow. The flow would be like: flow create 0 ingress transfer pattern eth / end actions port_id id 1 / port_id id 2 / end Ingress packet match from uplink, send to VF1 but also mirror to VF2. While PMD parse a e-switch rule and found the multiple port actions, then will create a new multiple destination DR action and add it into the flow instead of two port id action. Signed-off-by: Jiawei Wang --- drivers/net/mlx5/mlx5_flow_dv.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index cf85780..8c195d4 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -3738,7 +3738,8 @@ struct field_modify_info modify_tcp[] = { "port id action parameters must be" " specified"); if (action_flags & (MLX5_FLOW_FATE_ACTIONS | - MLX5_FLOW_FATE_ESWITCH_ACTIONS)) + (MLX5_FLOW_FATE_ESWITCH_ACTIONS & + ~MLX5_FLOW_ACTION_PORT_ID))) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "can have only one fate actions in" @@ -9007,6 +9008,7 @@ struct field_modify_info modify_tcp[] = { struct mlx5_flow_dv_sample_resource sample_res; void *sample_actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS] = {0}; struct mlx5_flow_sub_actions_list *sample_act; + struct mlx5_flow_sub_actions_list *mirror_act; uint32_t sample_act_pos = UINT32_MAX; uint32_t num_of_dest = 0; int tmp_actions_n = 0; @@ -9056,7 +9058,21 @@ struct field_modify_info modify_tcp[] = { &port_id, error)) return -rte_errno; port_id_resource.port_id = port_id; - MLX5_ASSERT(!handle->rix_port_id_action); + if (handle->rix_port_id_action) { + // update for native mirror port id action + struct mlx5_flow_sub_actions_idx *mirror_idx = + &sample_res.sample_idx; + mirror_act = &sample_res.sample_act; + mirror_act->dr_port_id_action = + dev_flow->dv.port_id_action->action; + mirror_idx->rix_port_id_action = + dev_flow->handle->rix_port_id_action; + sample_actions[mirror_act->actions_num++] = + mirror_act->dr_port_id_action; + mirror_act->action_flags |= + MLX5_FLOW_ACTION_PORT_ID; + action_flags |= MLX5_FLOW_ACTION_SAMPLE; + } if (flow_dv_port_id_action_resource_register (dev, &port_id_resource, dev_flow, error)) return -rte_errno; @@ -9523,6 +9539,8 @@ struct field_modify_info modify_tcp[] = { RTE_FLOW_ERROR_TYPE_ACTION, NULL, "cannot create sample action"); + if (sample_act_pos == UINT32_MAX) + sample_act_pos = actions_n++; if (num_of_dest > 1) { dev_flow->dv.actions[sample_act_pos] = dev_flow->dv.multi_dest_res->action; @@ -9555,6 +9573,9 @@ struct field_modify_info modify_tcp[] = { dev_flow->dv.actions[i]) || (sample_act->dr_port_id_action && sample_act->dr_port_id_action == + dev_flow->dv.actions[i]) || + (mirror_act->dr_port_id_action && + mirror_act->dr_port_id_action == dev_flow->dv.actions[i])) continue; temp_actions[tmp_actions_n++] = dev_flow->dv.actions[i]; -- 1.8.3.1