Skip to content

Commit

Permalink
Merge tag 'mlx5-updates-2023-04-14' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/saeed/linux

mlx5-updates-2023-04-14

Yevgeny Kliteynik Says:
=======================

SW Steering: Support pattern/args modify_header actions

The following patch series adds support for a new pattern/arguments type
of modify_header actions.

Starting with ConnectX-6 DX, we use a new design of modify_header FW object.
The current modify_header object allows for having only limited number of
these FW objects, which means that we are limited in the number of offloaded
flows that require modify_header action.

The new approach comprises of two types of objects: pattern and argument.
Pattern holds header modification templates, later used with corresponding
argument object to create complete header modification actions.
The pattern indicates which headers are modified, while the arguments
provide the specific values.
Therefore a single pattern can be used with different arguments in different
flows, enabling offloading of large number of modify_header flows.

 - Patch 1, 2: Add ICM pool for modify-header-pattern objects and implement
   patterns cache, allowing patterns reuse for different flows
 - Patch 3: Allow for chunk allocation separately for STEv0 and STEv1
 - Patch 4: Read related device capabilities
 - Patch 5: Add create/destroy functions for the new general object type
 - Patch 6: Add support for writing modify header argument to ICM
 - Patch 7, 8: Some required fixes to support pattern/arg - separate read
   buffer from the write buffer and fix QP continuous allocation
 - Patch 9: Add pool for modify header arg objects
 - Patch 10, 11, 12: Implement MODIFY_HEADER and TNL_L3_TO_L2 actions with
   the new patterns/args design
 - Patch 13: Optimization - set modify header action of size 1 directly on
   the STE instead of separate pattern/args combination
 - Patch 14: Adjust debug dump for patterns/args
 - Patch 15: Enable patterns and arguments for supporting devices

=======================
  • Loading branch information
David S. Miller committed Apr 17, 2023
2 parents e2174b0 + 220ae98 commit 0475135
Show file tree
Hide file tree
Showing 15 changed files with 1,025 additions and 89 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ mlx5_core-$(CONFIG_MLX5_SW_STEERING) += steering/dr_domain.o steering/dr_table.o
steering/dr_cmd.o steering/dr_fw.o \
steering/dr_action.o steering/fs_dr.o \
steering/dr_definer.o steering/dr_ptrn.o \
steering/dr_dbg.o lib/smfs.o
steering/dr_arg.o steering/dr_dbg.o lib/smfs.o
#
# SF device
#
Expand Down
92 changes: 47 additions & 45 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,34 @@ int mlx5dr_actions_build_ste_arr(struct mlx5dr_matcher *matcher,
case DR_ACTION_TYP_TNL_L2_TO_L2:
break;
case DR_ACTION_TYP_TNL_L3_TO_L2:
attr.decap_index = action->rewrite->index;
attr.decap_actions = action->rewrite->num_of_actions;
attr.decap_with_vlan =
attr.decap_actions == WITH_VLAN_NUM_HW_ACTIONS;
if (action->rewrite->ptrn && action->rewrite->arg) {
attr.decap_index = mlx5dr_arg_get_obj_id(action->rewrite->arg);
attr.decap_actions = action->rewrite->ptrn->num_of_actions;
attr.decap_pat_idx = action->rewrite->ptrn->index;
} else {
attr.decap_index = action->rewrite->index;
attr.decap_actions = action->rewrite->num_of_actions;
attr.decap_with_vlan =
attr.decap_actions == WITH_VLAN_NUM_HW_ACTIONS;
attr.decap_pat_idx = MLX5DR_INVALID_PATTERN_INDEX;
}
break;
case DR_ACTION_TYP_MODIFY_HDR:
attr.modify_index = action->rewrite->index;
attr.modify_actions = action->rewrite->num_of_actions;
if (action->rewrite->single_action_opt) {
attr.modify_actions = action->rewrite->num_of_actions;
attr.single_modify_action = action->rewrite->data;
} else {
if (action->rewrite->ptrn && action->rewrite->arg) {
attr.modify_index =
mlx5dr_arg_get_obj_id(action->rewrite->arg);
attr.modify_actions = action->rewrite->ptrn->num_of_actions;
attr.modify_pat_idx = action->rewrite->ptrn->index;
} else {
attr.modify_index = action->rewrite->index;
attr.modify_actions = action->rewrite->num_of_actions;
attr.modify_pat_idx = MLX5DR_INVALID_PATTERN_INDEX;
}
}
if (action->rewrite->modify_ttl)
dr_action_modify_ttl_adjust(dmn, &attr, rx_rule,
&recalc_cs_required);
Expand Down Expand Up @@ -1365,8 +1385,6 @@ dr_action_verify_reformat_params(enum mlx5dr_action_type reformat_type,
return -EINVAL;
}

#define ACTION_CACHE_LINE_SIZE 64

static int
dr_action_create_reformat_action(struct mlx5dr_domain *dmn,
u8 reformat_param_0, u8 reformat_param_1,
Expand Down Expand Up @@ -1403,36 +1421,25 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn,
}
case DR_ACTION_TYP_TNL_L3_TO_L2:
{
u8 hw_actions[ACTION_CACHE_LINE_SIZE] = {};
u8 hw_actions[DR_ACTION_CACHE_LINE_SIZE] = {};
int ret;

ret = mlx5dr_ste_set_action_decap_l3_list(dmn->ste_ctx,
data, data_sz,
hw_actions,
ACTION_CACHE_LINE_SIZE,
DR_ACTION_CACHE_LINE_SIZE,
&action->rewrite->num_of_actions);
if (ret) {
mlx5dr_dbg(dmn, "Failed creating decap l3 action list\n");
return ret;
}

action->rewrite->chunk = mlx5dr_icm_alloc_chunk(dmn->action_icm_pool,
DR_CHUNK_SIZE_8);
if (!action->rewrite->chunk) {
mlx5dr_dbg(dmn, "Failed allocating modify header chunk\n");
return -ENOMEM;
}

action->rewrite->data = (void *)hw_actions;
action->rewrite->index = (mlx5dr_icm_pool_get_chunk_icm_addr
(action->rewrite->chunk) -
dmn->info.caps.hdr_modify_icm_addr) /
ACTION_CACHE_LINE_SIZE;
action->rewrite->data = hw_actions;
action->rewrite->dmn = dmn;

ret = mlx5dr_send_postsend_action(dmn, action);
ret = mlx5dr_ste_alloc_modify_hdr(action);
if (ret) {
mlx5dr_dbg(dmn, "Writing decap l3 actions to ICM failed\n");
mlx5dr_icm_free_chunk(action->rewrite->chunk);
mlx5dr_dbg(dmn, "Failed preparing reformat data\n");
return ret;
}
return 0;
Expand Down Expand Up @@ -1963,7 +1970,6 @@ static int dr_action_create_modify_action(struct mlx5dr_domain *dmn,
__be64 actions[],
struct mlx5dr_action *action)
{
struct mlx5dr_icm_chunk *chunk;
u32 max_hw_actions;
u32 num_hw_actions;
u32 num_sw_actions;
Expand All @@ -1980,15 +1986,9 @@ static int dr_action_create_modify_action(struct mlx5dr_domain *dmn,
return -EINVAL;
}

chunk = mlx5dr_icm_alloc_chunk(dmn->action_icm_pool, DR_CHUNK_SIZE_16);
if (!chunk)
return -ENOMEM;

hw_actions = kcalloc(1, max_hw_actions * DR_MODIFY_ACTION_SIZE, GFP_KERNEL);
if (!hw_actions) {
ret = -ENOMEM;
goto free_chunk;
}
if (!hw_actions)
return -ENOMEM;

ret = dr_actions_convert_modify_header(action,
max_hw_actions,
Expand All @@ -2000,24 +2000,24 @@ static int dr_action_create_modify_action(struct mlx5dr_domain *dmn,
if (ret)
goto free_hw_actions;

action->rewrite->chunk = chunk;
action->rewrite->modify_ttl = modify_ttl;
action->rewrite->data = (u8 *)hw_actions;
action->rewrite->num_of_actions = num_hw_actions;
action->rewrite->index = (mlx5dr_icm_pool_get_chunk_icm_addr(chunk) -
dmn->info.caps.hdr_modify_icm_addr) /
ACTION_CACHE_LINE_SIZE;

ret = mlx5dr_send_postsend_action(dmn, action);
if (ret)
goto free_hw_actions;
if (num_hw_actions == 1 &&
dmn->info.caps.sw_format_ver >= MLX5_STEERING_FORMAT_CONNECTX_6DX) {
action->rewrite->single_action_opt = true;
} else {
action->rewrite->single_action_opt = false;
ret = mlx5dr_ste_alloc_modify_hdr(action);
if (ret)
goto free_hw_actions;
}

return 0;

free_hw_actions:
kfree(hw_actions);
free_chunk:
mlx5dr_icm_free_chunk(chunk);
return ret;
}

Expand Down Expand Up @@ -2162,7 +2162,8 @@ int mlx5dr_action_destroy(struct mlx5dr_action *action)
refcount_dec(&action->reformat->dmn->refcount);
break;
case DR_ACTION_TYP_TNL_L3_TO_L2:
mlx5dr_icm_free_chunk(action->rewrite->chunk);
mlx5dr_ste_free_modify_hdr(action);
kfree(action->rewrite->data);
refcount_dec(&action->rewrite->dmn->refcount);
break;
case DR_ACTION_TYP_L2_TO_TNL_L2:
Expand All @@ -2173,7 +2174,8 @@ int mlx5dr_action_destroy(struct mlx5dr_action *action)
refcount_dec(&action->reformat->dmn->refcount);
break;
case DR_ACTION_TYP_MODIFY_HDR:
mlx5dr_icm_free_chunk(action->rewrite->chunk);
if (!action->rewrite->single_action_opt)
mlx5dr_ste_free_modify_hdr(action);
kfree(action->rewrite->data);
refcount_dec(&action->rewrite->dmn->refcount);
break;
Expand Down
Loading

0 comments on commit 0475135

Please sign in to comment.