Skip to content

Commit b055ecf

Browse files
mark-blochSaeed Mahameed
authored andcommitted
net/mlx5: E-Switch, Refactor setting source port
Setting the source port requires only the E-Switch and vport number. Refactor the function to get those parameters instead of passing the full attribute. Signed-off-by: Mark Bloch <[email protected]> Reviewed-by: Saeed Mahameed <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 4d469ec commit b055ecf

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ mlx5_eswitch_set_rule_flow_source(struct mlx5_eswitch *esw,
257257
static void
258258
mlx5_eswitch_set_rule_source_port(struct mlx5_eswitch *esw,
259259
struct mlx5_flow_spec *spec,
260-
struct mlx5_esw_flow_attr *attr)
260+
struct mlx5_eswitch *src_esw,
261+
u16 vport)
261262
{
262263
void *misc2;
263264
void *misc;
@@ -268,8 +269,8 @@ mlx5_eswitch_set_rule_source_port(struct mlx5_eswitch *esw,
268269
if (mlx5_eswitch_vport_match_metadata_enabled(esw)) {
269270
misc2 = MLX5_ADDR_OF(fte_match_param, spec->match_value, misc_parameters_2);
270271
MLX5_SET(fte_match_set_misc2, misc2, metadata_reg_c_0,
271-
mlx5_eswitch_get_vport_metadata_for_match(attr->in_mdev->priv.eswitch,
272-
attr->in_rep->vport));
272+
mlx5_eswitch_get_vport_metadata_for_match(src_esw,
273+
vport));
273274

274275
misc2 = MLX5_ADDR_OF(fte_match_param, spec->match_criteria, misc_parameters_2);
275276
MLX5_SET(fte_match_set_misc2, misc2, metadata_reg_c_0,
@@ -278,12 +279,12 @@ mlx5_eswitch_set_rule_source_port(struct mlx5_eswitch *esw,
278279
spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS_2;
279280
} else {
280281
misc = MLX5_ADDR_OF(fte_match_param, spec->match_value, misc_parameters);
281-
MLX5_SET(fte_match_set_misc, misc, source_port, attr->in_rep->vport);
282+
MLX5_SET(fte_match_set_misc, misc, source_port, vport);
282283

283284
if (MLX5_CAP_ESW(esw->dev, merged_eswitch))
284285
MLX5_SET(fte_match_set_misc, misc,
285286
source_eswitch_owner_vhca_id,
286-
MLX5_CAP_GEN(attr->in_mdev, vhca_id));
287+
MLX5_CAP_GEN(src_esw->dev, vhca_id));
287288

288289
misc = MLX5_ADDR_OF(fte_match_param, spec->match_criteria, misc_parameters);
289290
MLX5_SET_TO_ONES(fte_match_set_misc, misc, source_port);
@@ -407,7 +408,9 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
407408
fdb = attr->ft;
408409

409410
if (!(attr->flags & MLX5_ESW_ATTR_FLAG_NO_IN_PORT))
410-
mlx5_eswitch_set_rule_source_port(esw, spec, esw_attr);
411+
mlx5_eswitch_set_rule_source_port(esw, spec,
412+
esw_attr->in_mdev->priv.eswitch,
413+
esw_attr->in_rep->vport);
411414
}
412415
if (IS_ERR(fdb)) {
413416
rule = ERR_CAST(fdb);
@@ -487,7 +490,9 @@ mlx5_eswitch_add_fwd_rule(struct mlx5_eswitch *esw,
487490
dest[i].ft = fwd_fdb;
488491
i++;
489492

490-
mlx5_eswitch_set_rule_source_port(esw, spec, esw_attr);
493+
mlx5_eswitch_set_rule_source_port(esw, spec,
494+
esw_attr->in_mdev->priv.eswitch,
495+
esw_attr->in_rep->vport);
491496

492497
if (attr->outer_match_level != MLX5_MATCH_NONE)
493498
spec->match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS;

0 commit comments

Comments
 (0)