Skip to content

Commit 6375722

Browse files
committed
Merge tag 'mlx5-updates-2022-07-28' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-updates-2022-07-28 Misc updates to mlx5 driver: 1) Gal corrects to use skb_tcp_all_headers on encapsulated skbs. 2) Roi Adds the support for offloading standalone police actions. 3) lama, did some refactoring to minimize code coupling with mlx5e_priv "god object" in some of the follows, and converts some of the objects to pointers to preserve on memory when these objects aren't needed. This is part one of two parts series. * tag 'mlx5-updates-2022-07-28' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net/mlx5e: Move mlx5e_init_l2_addr to en_main net/mlx5e: Split en_fs ndo's and move to en_main net/mlx5e: Separate mlx5e_set_rx_mode_work and move caller to en_main net/mlx5e: Add mdev to flow_steering struct net/mlx5e: Report flow steering errors with mdev err report API net/mlx5e: Convert mlx5e_flow_steering member of mlx5e_priv to pointer net/mlx5e: Allocate VLAN and TC for featured profiles only net/mlx5e: Make mlx5e_tc_table private net/mlx5e: Convert mlx5e_tc_table member of mlx5e_flow_steering to pointer net/mlx5e: TC, Support tc action api for police net/mlx5e: TC, Separate get/update/replace meter functions net/mlx5e: Add red and green counters for metering net/mlx5e: TC, Allocate post meter ft per rule net/mlx5: DR, Add support for flow metering ASO net/mlx5e: Fix wrong use of skb_tcp_all_headers() with encapsulation ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 84a8d93 + 069448b commit 6375722

30 files changed

+1265
-511
lines changed

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

+3-2
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;
@@ -987,6 +987,8 @@ enum mlx5e_profile_feature {
987987
MLX5E_PROFILE_FEATURE_PTP_RX,
988988
MLX5E_PROFILE_FEATURE_PTP_TX,
989989
MLX5E_PROFILE_FEATURE_QOS_HTB,
990+
MLX5E_PROFILE_FEATURE_FS_VLAN,
991+
MLX5E_PROFILE_FEATURE_FS_TC,
990992
};
991993

992994
struct mlx5e_profile {
@@ -1022,7 +1024,6 @@ void mlx5e_shampo_dealloc_hd(struct mlx5e_rq *rq, u16 len, u16 start, bool close
10221024
void mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
10231025
void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s);
10241026

1025-
void mlx5e_init_l2_addr(struct mlx5e_priv *priv);
10261027
int mlx5e_self_test_num(struct mlx5e_priv *priv);
10271028
int mlx5e_self_test_fill_strings(struct mlx5e_priv *priv, u8 *data);
10281029
void mlx5e_self_test(struct net_device *ndev, struct ethtool_test *etest,

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

+17-27
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,6 @@ enum {
1515
MLX5E_TC_MISS_LEVEL,
1616
};
1717

18-
struct mlx5e_tc_table {
19-
/* Protects the dynamic assignment of the t parameter
20-
* which is the nic tc root table.
21-
*/
22-
struct mutex t_lock;
23-
struct mlx5_flow_table *t;
24-
struct mlx5_flow_table *miss_t;
25-
struct mlx5_fs_chains *chains;
26-
struct mlx5e_post_act *post_act;
27-
28-
struct rhashtable ht;
29-
30-
struct mod_hdr_tbl mod_hdr;
31-
struct mutex hairpin_tbl_lock; /* protects hairpin_tbl */
32-
DECLARE_HASHTABLE(hairpin_tbl, 8);
33-
34-
struct notifier_block netdevice_nb;
35-
struct netdev_net_notifier netdevice_nn;
36-
37-
struct mlx5_tc_ct_priv *ct;
38-
struct mapping_ctx *mapping;
39-
};
40-
4118
struct mlx5e_flow_table {
4219
int num_groups;
4320
struct mlx5_flow_table *t;
@@ -160,16 +137,20 @@ static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) { return -EOPNOTSU
160137
struct mlx5e_accel_fs_tcp;
161138
#endif
162139

140+
struct mlx5e_profile;
163141
struct mlx5e_fs_udp;
164142
struct mlx5e_fs_any;
165143
struct mlx5e_ptp_fs;
166144

167145
struct mlx5e_flow_steering {
146+
bool state_destroy;
147+
bool vlan_strip_disable;
148+
struct mlx5_core_dev *mdev;
168149
struct mlx5_flow_namespace *ns;
169150
#ifdef CONFIG_MLX5_EN_RXNFC
170151
struct mlx5e_ethtool_steering ethtool;
171152
#endif
172-
struct mlx5e_tc_table tc;
153+
struct mlx5e_tc_table *tc;
173154
struct mlx5e_promisc_table promisc;
174155
struct mlx5e_vlan_table *vlan;
175156
struct mlx5e_l2_table l2;
@@ -200,13 +181,22 @@ void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
200181
int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
201182
void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
202183

203-
int mlx5e_fs_init(struct mlx5e_priv *priv);
204-
void mlx5e_fs_cleanup(struct mlx5e_priv *priv);
184+
struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,
185+
struct mlx5_core_dev *mdev,
186+
bool state_destroy);
187+
void mlx5e_fs_cleanup(struct mlx5e_flow_steering *fs);
205188

206189
int mlx5e_add_vlan_trap(struct mlx5e_priv *priv, int trap_id, int tir_num);
207190
void mlx5e_remove_vlan_trap(struct mlx5e_priv *priv);
208191
int mlx5e_add_mac_trap(struct mlx5e_priv *priv, int trap_id, int tir_num);
209192
void mlx5e_remove_mac_trap(struct mlx5e_priv *priv);
210-
193+
void mlx5e_fs_set_rx_mode_work(struct mlx5e_flow_steering *fs, struct net_device *netdev);
194+
int mlx5e_fs_vlan_rx_add_vid(struct mlx5e_flow_steering *fs,
195+
struct net_device *netdev,
196+
__be16 proto, u16 vid);
197+
int mlx5e_fs_vlan_rx_kill_vid(struct mlx5e_flow_steering *fs,
198+
struct net_device *netdev,
199+
__be16 proto, u16 vid);
200+
void mlx5e_fs_init_l2_addr(struct mlx5e_flow_steering *fs, struct net_device *netdev);
211201
#endif /* __MLX5E_FLOW_STEER_H__ */
212202

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

+36-36
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

+4-4
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;

0 commit comments

Comments
 (0)