[v6,12/12] net/mlx5: support the native port id actions for mirroring
Checks
Commit Message
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 <jiaweiw@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
@@ -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];