Skip to content

Commit bcd6740

Browse files
Chris MiSaeed Mahameed
authored andcommitted
net/mlx5e: Move sample attribute to flow attribute
Currently it is in eswitch attribute. Move it to flow attribute to reflect the change in previous patch. Signed-off-by: Chris Mi <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 0027d70 commit bcd6740

File tree

5 files changed

+29
-28
lines changed

5 files changed

+29
-28
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
391391
sample_flow = kzalloc(sizeof(*sample_flow), GFP_KERNEL);
392392
if (!sample_flow)
393393
return ERR_PTR(-ENOMEM);
394-
esw_attr->sample->sample_flow = sample_flow;
394+
sample_attr = attr->sample_attr;
395+
sample_attr->sample_flow = sample_flow;
395396

396397
/* Allocate default table per vport, chain and prio. Otherwise, there is
397398
* only one default table for the same sampler object. Rules with different
@@ -411,7 +412,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
411412
/* Perform the original matches on the default table.
412413
* Offload all actions except the sample action.
413414
*/
414-
esw_attr->sample->sample_default_tbl = default_tbl;
415+
sample_attr->sample_default_tbl = default_tbl;
415416
/* When offloading sample and encap action, if there is no valid
416417
* neigh data struct, a slow path rule is offloaded first. Source
417418
* port metadata match is set at that time. A per vport table is
@@ -426,21 +427,21 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
426427
}
427428

428429
/* Create sampler object. */
429-
sample_flow->sampler = sampler_get(tc_psample, esw_attr->sample->rate, default_tbl->id);
430+
sample_flow->sampler = sampler_get(tc_psample, sample_attr->rate, default_tbl->id);
430431
if (IS_ERR(sample_flow->sampler)) {
431432
err = PTR_ERR(sample_flow->sampler);
432433
goto err_sampler;
433434
}
434435

435436
/* Create an id mapping reg_c0 value to sample object. */
436437
restore_obj.type = MLX5_MAPPED_OBJ_SAMPLE;
437-
restore_obj.sample.group_id = esw_attr->sample->group_num;
438-
restore_obj.sample.rate = esw_attr->sample->rate;
439-
restore_obj.sample.trunc_size = esw_attr->sample->trunc_size;
438+
restore_obj.sample.group_id = sample_attr->group_num;
439+
restore_obj.sample.rate = sample_attr->rate;
440+
restore_obj.sample.trunc_size = sample_attr->trunc_size;
440441
err = mapping_add(esw->offloads.reg_c0_obj_pool, &restore_obj, &obj_id);
441442
if (err)
442443
goto err_obj_id;
443-
esw_attr->sample->restore_obj_id = obj_id;
444+
sample_attr->restore_obj_id = obj_id;
444445

445446
/* Create sample restore context. */
446447
sample_flow->restore = sample_restore_get(tc_psample, obj_id);
@@ -462,14 +463,14 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
462463
err = -ENOMEM;
463464
goto err_alloc_sample_attr;
464465
}
465-
pre_esw_attr = pre_attr->esw_attr;
466466
pre_attr->action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
467467
pre_attr->modify_hdr = sample_flow->restore->modify_hdr;
468468
pre_attr->flags = MLX5_ESW_ATTR_FLAG_SAMPLE;
469469
pre_attr->chain = attr->chain;
470470
pre_attr->prio = attr->prio;
471-
pre_esw_attr->sample = sample_attr;
472-
pre_esw_attr->sample->sampler_id = sample_flow->sampler->sampler_id;
471+
pre_attr->sample_attr = sample_attr;
472+
sample_attr->sampler_id = sample_flow->sampler->sampler_id;
473+
pre_esw_attr = pre_attr->esw_attr;
473474
pre_esw_attr->in_mdev = esw_attr->in_mdev;
474475
pre_esw_attr->in_rep = esw_attr->in_rep;
475476
sample_flow->pre_rule = mlx5_eswitch_add_offloaded_rule(esw, spec, pre_attr);
@@ -528,22 +529,22 @@ mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *tc_psample,
528529
return;
529530
}
530531

531-
sample_flow = esw_attr->sample->sample_flow;
532+
sample_flow = attr->sample_attr->sample_flow;
532533
pre_attr = sample_flow->pre_attr;
533534
memset(pre_attr, 0, sizeof(*pre_attr));
534535
mlx5_eswitch_del_offloaded_rule(esw, sample_flow->pre_rule, pre_attr);
535536
mlx5_eswitch_del_offloaded_rule(esw, sample_flow->rule, attr);
536537

537538
sample_restore_put(tc_psample, sample_flow->restore);
538-
mapping_remove(esw->offloads.reg_c0_obj_pool, esw_attr->sample->restore_obj_id);
539+
mapping_remove(esw->offloads.reg_c0_obj_pool, attr->sample_attr->restore_obj_id);
539540
sampler_put(tc_psample, sample_flow->sampler);
540541
tbl_attr.chain = attr->chain;
541542
tbl_attr.prio = attr->prio;
542543
tbl_attr.vport = esw_attr->in_rep->vport;
543544
tbl_attr.vport_ns = &mlx5_esw_vport_tbl_sample_ns;
544545
mlx5_esw_vporttbl_put(esw, &tbl_attr);
545546

546-
kfree(pre_attr->esw_attr->sample);
547+
kfree(pre_attr->sample_attr);
547548
kfree(pre_attr);
548549
kfree(sample_flow);
549550
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
15501550
else
15511551
mlx5e_detach_mod_hdr(priv, flow);
15521552
}
1553+
kfree(attr->sample_attr);
15531554
kvfree(attr->parse_attr);
15541555
kvfree(attr->esw_attr->rx_tun_attr);
15551556

@@ -1559,7 +1560,6 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
15591560
if (flow_flag_test(flow, L3_TO_L2_DECAP))
15601561
mlx5e_detach_decap(priv, flow);
15611562

1562-
kfree(flow->attr->esw_attr->sample);
15631563
kfree(flow->attr);
15641564
}
15651565

@@ -3716,13 +3716,13 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
37163716
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
37173717
struct mlx5e_tc_flow_parse_attr *parse_attr;
37183718
struct mlx5e_rep_priv *rpriv = priv->ppriv;
3719+
struct mlx5e_sample_attr sample_attr = {};
37193720
const struct ip_tunnel_info *info = NULL;
37203721
struct mlx5_flow_attr *attr = flow->attr;
37213722
int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS];
37223723
bool ft_flow = mlx5e_is_ft_flow(flow);
37233724
const struct flow_action_entry *act;
37243725
struct mlx5_esw_flow_attr *esw_attr;
3725-
struct mlx5e_sample_attr sample = {};
37263726
bool encap = false, decap = false;
37273727
u32 action = attr->action;
37283728
int err, i, if_count = 0;
@@ -3993,10 +3993,10 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
39933993
NL_SET_ERR_MSG_MOD(extack, "Sample action with connection tracking is not supported");
39943994
return -EOPNOTSUPP;
39953995
}
3996-
sample.rate = act->sample.rate;
3997-
sample.group_num = act->sample.psample_group->group_num;
3996+
sample_attr.rate = act->sample.rate;
3997+
sample_attr.group_num = act->sample.psample_group->group_num;
39983998
if (act->sample.truncate)
3999-
sample.trunc_size = act->sample.trunc_size;
3999+
sample_attr.trunc_size = act->sample.trunc_size;
40004000
flow_flag_set(flow, SAMPLE);
40014001
break;
40024002
default:
@@ -4081,10 +4081,10 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
40814081
* no errors after parsing.
40824082
*/
40834083
if (flow_flag_test(flow, SAMPLE)) {
4084-
esw_attr->sample = kzalloc(sizeof(*esw_attr->sample), GFP_KERNEL);
4085-
if (!esw_attr->sample)
4084+
attr->sample_attr = kzalloc(sizeof(*attr->sample_attr), GFP_KERNEL);
4085+
if (!attr->sample_attr)
40864086
return -ENOMEM;
4087-
*esw_attr->sample = sample;
4087+
*attr->sample_attr = sample_attr;
40884088
}
40894089

40904090
return 0;

drivers/net/ethernet/mellanox/mlx5/core/en_tc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct mlx5_flow_attr {
7070
struct mlx5_fc *counter;
7171
struct mlx5_modify_hdr *modify_hdr;
7272
struct mlx5_ct_attr ct_attr;
73+
struct mlx5e_sample_attr *sample_attr;
7374
struct mlx5e_tc_flow_parse_attr *parse_attr;
7475
u32 chain;
7576
u16 prio;

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ struct mlx5_esw_flow_attr {
469469
} dests[MLX5_MAX_FLOW_FWD_VPORTS];
470470
struct mlx5_rx_tun_attr *rx_tun_attr;
471471
struct mlx5_pkt_reformat *decap_pkt_reformat;
472-
struct mlx5e_sample_attr *sample;
473472
};
474473

475474
int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ esw_cleanup_decap_indir(struct mlx5_eswitch *esw,
187187
static int
188188
esw_setup_sampler_dest(struct mlx5_flow_destination *dest,
189189
struct mlx5_flow_act *flow_act,
190-
struct mlx5_esw_flow_attr *esw_attr,
190+
struct mlx5_flow_attr *attr,
191191
int i)
192192
{
193193
flow_act->flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
194194
dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER;
195-
dest[i].sampler_id = esw_attr->sample->sampler_id;
195+
dest[i].sampler_id = attr->sample_attr->sampler_id;
196196

197197
return 0;
198198
}
@@ -435,7 +435,7 @@ esw_setup_dests(struct mlx5_flow_destination *dest,
435435
attr->flags |= MLX5_ESW_ATTR_FLAG_SRC_REWRITE;
436436

437437
if (attr->flags & MLX5_ESW_ATTR_FLAG_SAMPLE) {
438-
esw_setup_sampler_dest(dest, flow_act, esw_attr, *i);
438+
esw_setup_sampler_dest(dest, flow_act, attr, *i);
439439
(*i)++;
440440
} else if (attr->dest_ft) {
441441
esw_setup_ft_dest(dest, flow_act, esw, attr, spec, *i);
@@ -540,9 +540,9 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
540540
if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
541541
flow_act.modify_hdr = attr->modify_hdr;
542542

543-
/* esw_attr->sample is allocated only when there is a sample action */
544-
if (esw_attr->sample && esw_attr->sample->sample_default_tbl) {
545-
fdb = esw_attr->sample->sample_default_tbl;
543+
/* sample_attr is allocated only when there is a sample action */
544+
if (attr->sample_attr && attr->sample_attr->sample_default_tbl) {
545+
fdb = attr->sample_attr->sample_default_tbl;
546546
} else if (split) {
547547
fwd_attr.chain = attr->chain;
548548
fwd_attr.prio = attr->prio;

0 commit comments

Comments
 (0)