Skip to content

Commit af8bbf7

Browse files
Lama KayalSaeed Mahameed
authored andcommitted
net/mlx5e: Convert mlx5e_flow_steering member of mlx5e_priv to pointer
Make mlx5e_flow_steering member of mlx5e_priv a pointer. Add dynamic allocation respectively. Allocate fs for all profiles when initializing profile, symmetrically deallocate at profile cleanup. Signed-off-by: Lama Kayal <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 454533a commit af8bbf7

File tree

14 files changed

+298
-264
lines changed

14 files changed

+298
-264
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ struct mlx5e_priv {
921921
struct mlx5e_rx_res *rx_res;
922922
u32 *tx_rates;
923923

924-
struct mlx5e_flow_steering fs;
924+
struct mlx5e_flow_steering *fs;
925925

926926
struct workqueue_struct *wq;
927927
struct work_struct update_carrier_work;

drivers/net/ethernet/mellanox/mlx5/core/en/fs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) { return -EOPNOTSU
137137
struct mlx5e_accel_fs_tcp;
138138
#endif
139139

140+
struct mlx5e_profile;
140141
struct mlx5e_fs_udp;
141142
struct mlx5e_fs_any;
142143
struct mlx5e_ptp_fs;
@@ -177,8 +178,8 @@ void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
177178
int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
178179
void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
179180

180-
int mlx5e_fs_init(struct mlx5e_priv *priv);
181-
void mlx5e_fs_cleanup(struct mlx5e_priv *priv);
181+
struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile);
182+
void mlx5e_fs_cleanup(struct mlx5e_flow_steering *fs);
182183

183184
int mlx5e_add_vlan_trap(struct mlx5e_priv *priv, int trap_id, int tir_num);
184185
void mlx5e_remove_vlan_trap(struct mlx5e_priv *priv);

drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ mlx5e_fs_tt_redirect_udp_add_rule(struct mlx5e_priv *priv,
9494
if (!spec)
9595
return ERR_PTR(-ENOMEM);
9696

97-
fs_udp = priv->fs.udp;
97+
fs_udp = priv->fs->udp;
9898
ft = fs_udp->tables[type].t;
9999

100100
fs_udp_set_dport_flow(spec, type, d_port);
@@ -121,10 +121,10 @@ static int fs_udp_add_default_rule(struct mlx5e_priv *priv, enum fs_udp_type typ
121121
struct mlx5e_fs_udp *fs_udp;
122122
int err;
123123

124-
fs_udp = priv->fs.udp;
124+
fs_udp = priv->fs->udp;
125125
fs_udp_t = &fs_udp->tables[type];
126126

127-
dest = mlx5_ttc_get_default_dest(priv->fs.ttc, fs_udp2tt(type));
127+
dest = mlx5_ttc_get_default_dest(priv->fs->ttc, fs_udp2tt(type));
128128
rule = mlx5_add_flow_rules(fs_udp_t->t, NULL, &flow_act, &dest, 1);
129129
if (IS_ERR(rule)) {
130130
err = PTR_ERR(rule);
@@ -208,7 +208,7 @@ static int fs_udp_create_groups(struct mlx5e_flow_table *ft, enum fs_udp_type ty
208208

209209
static int fs_udp_create_table(struct mlx5e_priv *priv, enum fs_udp_type type)
210210
{
211-
struct mlx5e_flow_table *ft = &priv->fs.udp->tables[type];
211+
struct mlx5e_flow_table *ft = &priv->fs->udp->tables[type];
212212
struct mlx5_flow_table_attr ft_attr = {};
213213
int err;
214214

@@ -218,7 +218,7 @@ static int fs_udp_create_table(struct mlx5e_priv *priv, enum fs_udp_type type)
218218
ft_attr.level = MLX5E_FS_TT_UDP_FT_LEVEL;
219219
ft_attr.prio = MLX5E_NIC_PRIO;
220220

221-
ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
221+
ft->t = mlx5_create_flow_table(priv->fs->ns, &ft_attr);
222222
if (IS_ERR(ft->t)) {
223223
err = PTR_ERR(ft->t);
224224
ft->t = NULL;
@@ -259,7 +259,7 @@ static int fs_udp_disable(struct mlx5e_priv *priv)
259259

260260
for (i = 0; i < FS_UDP_NUM_TYPES; i++) {
261261
/* Modify ttc rules destination to point back to the indir TIRs */
262-
err = mlx5_ttc_fwd_default_dest(priv->fs.ttc, fs_udp2tt(i));
262+
err = mlx5_ttc_fwd_default_dest(priv->fs->ttc, fs_udp2tt(i));
263263
if (err) {
264264
netdev_err(priv->netdev,
265265
"%s: modify ttc[%d] default destination failed, err(%d)\n",
@@ -278,10 +278,10 @@ static int fs_udp_enable(struct mlx5e_priv *priv)
278278

279279
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
280280
for (i = 0; i < FS_UDP_NUM_TYPES; i++) {
281-
dest.ft = priv->fs.udp->tables[i].t;
281+
dest.ft = priv->fs->udp->tables[i].t;
282282

283283
/* Modify ttc rules destination to point on the accel_fs FTs */
284-
err = mlx5_ttc_fwd_dest(priv->fs.ttc, fs_udp2tt(i), &dest);
284+
err = mlx5_ttc_fwd_dest(priv->fs->ttc, fs_udp2tt(i), &dest);
285285
if (err) {
286286
netdev_err(priv->netdev,
287287
"%s: modify ttc[%d] destination to accel failed, err(%d)\n",
@@ -294,7 +294,7 @@ static int fs_udp_enable(struct mlx5e_priv *priv)
294294

295295
void mlx5e_fs_tt_redirect_udp_destroy(struct mlx5e_priv *priv)
296296
{
297-
struct mlx5e_fs_udp *fs_udp = priv->fs.udp;
297+
struct mlx5e_fs_udp *fs_udp = priv->fs->udp;
298298
int i;
299299

300300
if (!fs_udp)
@@ -309,20 +309,20 @@ void mlx5e_fs_tt_redirect_udp_destroy(struct mlx5e_priv *priv)
309309
fs_udp_destroy_table(fs_udp, i);
310310

311311
kfree(fs_udp);
312-
priv->fs.udp = NULL;
312+
priv->fs->udp = NULL;
313313
}
314314

315315
int mlx5e_fs_tt_redirect_udp_create(struct mlx5e_priv *priv)
316316
{
317317
int i, err;
318318

319-
if (priv->fs.udp) {
320-
priv->fs.udp->ref_cnt++;
319+
if (priv->fs->udp) {
320+
priv->fs->udp->ref_cnt++;
321321
return 0;
322322
}
323323

324-
priv->fs.udp = kzalloc(sizeof(*priv->fs.udp), GFP_KERNEL);
325-
if (!priv->fs.udp)
324+
priv->fs->udp = kzalloc(sizeof(*priv->fs->udp), GFP_KERNEL);
325+
if (!priv->fs->udp)
326326
return -ENOMEM;
327327

328328
for (i = 0; i < FS_UDP_NUM_TYPES; i++) {
@@ -335,16 +335,16 @@ int mlx5e_fs_tt_redirect_udp_create(struct mlx5e_priv *priv)
335335
if (err)
336336
goto err_destroy_tables;
337337

338-
priv->fs.udp->ref_cnt = 1;
338+
priv->fs->udp->ref_cnt = 1;
339339

340340
return 0;
341341

342342
err_destroy_tables:
343343
while (--i >= 0)
344-
fs_udp_destroy_table(priv->fs.udp, i);
344+
fs_udp_destroy_table(priv->fs->udp, i);
345345

346-
kfree(priv->fs.udp);
347-
priv->fs.udp = NULL;
346+
kfree(priv->fs->udp);
347+
priv->fs->udp = NULL;
348348
return err;
349349
}
350350

@@ -371,7 +371,7 @@ mlx5e_fs_tt_redirect_any_add_rule(struct mlx5e_priv *priv,
371371
if (!spec)
372372
return ERR_PTR(-ENOMEM);
373373

374-
fs_any = priv->fs.any;
374+
fs_any = priv->fs->any;
375375
ft = fs_any->table.t;
376376

377377
fs_any_set_ethertype_flow(spec, ether_type);
@@ -398,10 +398,10 @@ static int fs_any_add_default_rule(struct mlx5e_priv *priv)
398398
struct mlx5e_fs_any *fs_any;
399399
int err;
400400

401-
fs_any = priv->fs.any;
401+
fs_any = priv->fs->any;
402402
fs_any_t = &fs_any->table;
403403

404-
dest = mlx5_ttc_get_default_dest(priv->fs.ttc, MLX5_TT_ANY);
404+
dest = mlx5_ttc_get_default_dest(priv->fs->ttc, MLX5_TT_ANY);
405405
rule = mlx5_add_flow_rules(fs_any_t->t, NULL, &flow_act, &dest, 1);
406406
if (IS_ERR(rule)) {
407407
err = PTR_ERR(rule);
@@ -474,7 +474,7 @@ static int fs_any_create_groups(struct mlx5e_flow_table *ft)
474474

475475
static int fs_any_create_table(struct mlx5e_priv *priv)
476476
{
477-
struct mlx5e_flow_table *ft = &priv->fs.any->table;
477+
struct mlx5e_flow_table *ft = &priv->fs->any->table;
478478
struct mlx5_flow_table_attr ft_attr = {};
479479
int err;
480480

@@ -484,7 +484,7 @@ static int fs_any_create_table(struct mlx5e_priv *priv)
484484
ft_attr.level = MLX5E_FS_TT_ANY_FT_LEVEL;
485485
ft_attr.prio = MLX5E_NIC_PRIO;
486486

487-
ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
487+
ft->t = mlx5_create_flow_table(priv->fs->ns, &ft_attr);
488488
if (IS_ERR(ft->t)) {
489489
err = PTR_ERR(ft->t);
490490
ft->t = NULL;
@@ -514,7 +514,7 @@ static int fs_any_disable(struct mlx5e_priv *priv)
514514
int err;
515515

516516
/* Modify ttc rules destination to point back to the indir TIRs */
517-
err = mlx5_ttc_fwd_default_dest(priv->fs.ttc, MLX5_TT_ANY);
517+
err = mlx5_ttc_fwd_default_dest(priv->fs->ttc, MLX5_TT_ANY);
518518
if (err) {
519519
netdev_err(priv->netdev,
520520
"%s: modify ttc[%d] default destination failed, err(%d)\n",
@@ -530,10 +530,10 @@ static int fs_any_enable(struct mlx5e_priv *priv)
530530
int err;
531531

532532
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
533-
dest.ft = priv->fs.any->table.t;
533+
dest.ft = priv->fs->any->table.t;
534534

535535
/* Modify ttc rules destination to point on the accel_fs FTs */
536-
err = mlx5_ttc_fwd_dest(priv->fs.ttc, MLX5_TT_ANY, &dest);
536+
err = mlx5_ttc_fwd_dest(priv->fs->ttc, MLX5_TT_ANY, &dest);
537537
if (err) {
538538
netdev_err(priv->netdev,
539539
"%s: modify ttc[%d] destination to accel failed, err(%d)\n",
@@ -555,7 +555,7 @@ static void fs_any_destroy_table(struct mlx5e_fs_any *fs_any)
555555

556556
void mlx5e_fs_tt_redirect_any_destroy(struct mlx5e_priv *priv)
557557
{
558-
struct mlx5e_fs_any *fs_any = priv->fs.any;
558+
struct mlx5e_fs_any *fs_any = priv->fs->any;
559559

560560
if (!fs_any)
561561
return;
@@ -568,20 +568,20 @@ void mlx5e_fs_tt_redirect_any_destroy(struct mlx5e_priv *priv)
568568
fs_any_destroy_table(fs_any);
569569

570570
kfree(fs_any);
571-
priv->fs.any = NULL;
571+
priv->fs->any = NULL;
572572
}
573573

574574
int mlx5e_fs_tt_redirect_any_create(struct mlx5e_priv *priv)
575575
{
576576
int err;
577577

578-
if (priv->fs.any) {
579-
priv->fs.any->ref_cnt++;
578+
if (priv->fs->any) {
579+
priv->fs->any->ref_cnt++;
580580
return 0;
581581
}
582582

583-
priv->fs.any = kzalloc(sizeof(*priv->fs.any), GFP_KERNEL);
584-
if (!priv->fs.any)
583+
priv->fs->any = kzalloc(sizeof(*priv->fs->any), GFP_KERNEL);
584+
if (!priv->fs->any)
585585
return -ENOMEM;
586586

587587
err = fs_any_create_table(priv);
@@ -592,14 +592,14 @@ int mlx5e_fs_tt_redirect_any_create(struct mlx5e_priv *priv)
592592
if (err)
593593
goto err_destroy_table;
594594

595-
priv->fs.any->ref_cnt = 1;
595+
priv->fs->any->ref_cnt = 1;
596596

597597
return 0;
598598

599599
err_destroy_table:
600-
fs_any_destroy_table(priv->fs.any);
600+
fs_any_destroy_table(priv->fs->any);
601601

602-
kfree(priv->fs.any);
603-
priv->fs.any = NULL;
602+
kfree(priv->fs->any);
603+
priv->fs->any = NULL;
604604
return err;
605605
}

drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static int mlx5e_ptp_set_state(struct mlx5e_ptp *c, struct mlx5e_params *params)
624624

625625
static void mlx5e_ptp_rx_unset_fs(struct mlx5e_priv *priv)
626626
{
627-
struct mlx5e_ptp_fs *ptp_fs = priv->fs.ptp_fs;
627+
struct mlx5e_ptp_fs *ptp_fs = priv->fs->ptp_fs;
628628

629629
if (!ptp_fs->valid)
630630
return;
@@ -641,7 +641,7 @@ static void mlx5e_ptp_rx_unset_fs(struct mlx5e_priv *priv)
641641
static int mlx5e_ptp_rx_set_fs(struct mlx5e_priv *priv)
642642
{
643643
u32 tirn = mlx5e_rx_res_get_tirn_ptp(priv->rx_res);
644-
struct mlx5e_ptp_fs *ptp_fs = priv->fs.ptp_fs;
644+
struct mlx5e_ptp_fs *ptp_fs = priv->fs->ptp_fs;
645645
struct mlx5_flow_handle *rule;
646646
int err;
647647

@@ -808,13 +808,13 @@ int mlx5e_ptp_alloc_rx_fs(struct mlx5e_priv *priv)
808808
if (!ptp_fs)
809809
return -ENOMEM;
810810

811-
priv->fs.ptp_fs = ptp_fs;
811+
priv->fs->ptp_fs = ptp_fs;
812812
return 0;
813813
}
814814

815815
void mlx5e_ptp_free_rx_fs(struct mlx5e_priv *priv)
816816
{
817-
struct mlx5e_ptp_fs *ptp_fs = priv->fs.ptp_fs;
817+
struct mlx5e_ptp_fs *ptp_fs = priv->fs->ptp_fs;
818818

819819
if (!mlx5e_profile_feature_cap(priv->profile, PTP_RX))
820820
return;

drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ validate_goto_chain(struct mlx5e_priv *priv,
2121
u32 max_chain;
2222

2323
esw = priv->mdev->priv.eswitch;
24-
chains = is_esw ? esw_chains(esw) : mlx5e_nic_chains(priv->fs.tc);
24+
chains = is_esw ? esw_chains(esw) : mlx5e_nic_chains(priv->fs->tc);
2525
max_chain = mlx5_chains_get_chain_range(chains);
2626
reformat_and_fwd = is_esw ?
2727
MLX5_CAP_ESW_FLOWTABLE_FDB(priv->mdev, reformat_and_fwd_to_table) :

0 commit comments

Comments
 (0)