Skip to content

Commit b3ba514

Browse files
Erez Shitritdavem330
authored andcommitted
net/mlx5: Refactor create flow table method to accept underlay QP
IB flow tables need the underlay qp to perform flow steering. Here we change the API of the flow tables creation to accept the underlay QP number as a parameter in order to support IB (IPoIB) flow steering. Signed-off-by: Erez Shitrit <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 500a3d0 commit b3ba514

File tree

8 files changed

+113
-50
lines changed

8 files changed

+113
-50
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,16 @@ static int arfs_create_table(struct mlx5e_priv *priv,
321321
{
322322
struct mlx5e_arfs_tables *arfs = &priv->fs.arfs;
323323
struct mlx5e_flow_table *ft = &arfs->arfs_tables[type].ft;
324+
struct mlx5_flow_table_attr ft_attr = {};
324325
int err;
325326

326-
ft->t = mlx5_create_flow_table(priv->fs.ns, MLX5E_NIC_PRIO,
327-
MLX5E_ARFS_TABLE_SIZE, MLX5E_ARFS_FT_LEVEL, 0);
327+
ft->num_groups = 0;
328+
329+
ft_attr.max_fte = MLX5E_ARFS_TABLE_SIZE;
330+
ft_attr.level = MLX5E_ARFS_FT_LEVEL;
331+
ft_attr.prio = MLX5E_NIC_PRIO;
332+
333+
ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
328334
if (IS_ERR(ft->t)) {
329335
err = PTR_ERR(ft->t);
330336
ft->t = NULL;

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,11 +803,15 @@ static void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv)
803803
static int mlx5e_create_ttc_table(struct mlx5e_priv *priv)
804804
{
805805
struct mlx5e_ttc_table *ttc = &priv->fs.ttc;
806+
struct mlx5_flow_table_attr ft_attr = {};
806807
struct mlx5e_flow_table *ft = &ttc->ft;
807808
int err;
808809

809-
ft->t = mlx5_create_flow_table(priv->fs.ns, MLX5E_NIC_PRIO,
810-
MLX5E_TTC_TABLE_SIZE, MLX5E_TTC_FT_LEVEL, 0);
810+
ft_attr.max_fte = MLX5E_TTC_TABLE_SIZE;
811+
ft_attr.level = MLX5E_TTC_FT_LEVEL;
812+
ft_attr.prio = MLX5E_NIC_PRIO;
813+
814+
ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
811815
if (IS_ERR(ft->t)) {
812816
err = PTR_ERR(ft->t);
813817
ft->t = NULL;
@@ -973,12 +977,16 @@ static int mlx5e_create_l2_table(struct mlx5e_priv *priv)
973977
{
974978
struct mlx5e_l2_table *l2_table = &priv->fs.l2;
975979
struct mlx5e_flow_table *ft = &l2_table->ft;
980+
struct mlx5_flow_table_attr ft_attr = {};
976981
int err;
977982

978983
ft->num_groups = 0;
979-
ft->t = mlx5_create_flow_table(priv->fs.ns, MLX5E_NIC_PRIO,
980-
MLX5E_L2_TABLE_SIZE, MLX5E_L2_FT_LEVEL, 0);
981984

985+
ft_attr.max_fte = MLX5E_L2_TABLE_SIZE;
986+
ft_attr.level = MLX5E_L2_FT_LEVEL;
987+
ft_attr.prio = MLX5E_NIC_PRIO;
988+
989+
ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
982990
if (IS_ERR(ft->t)) {
983991
err = PTR_ERR(ft->t);
984992
ft->t = NULL;
@@ -1076,11 +1084,16 @@ static int mlx5e_create_vlan_table_groups(struct mlx5e_flow_table *ft)
10761084
static int mlx5e_create_vlan_table(struct mlx5e_priv *priv)
10771085
{
10781086
struct mlx5e_flow_table *ft = &priv->fs.vlan.ft;
1087+
struct mlx5_flow_table_attr ft_attr = {};
10791088
int err;
10801089

10811090
ft->num_groups = 0;
1082-
ft->t = mlx5_create_flow_table(priv->fs.ns, MLX5E_NIC_PRIO,
1083-
MLX5E_VLAN_TABLE_SIZE, MLX5E_VLAN_FT_LEVEL, 0);
1091+
1092+
ft_attr.max_fte = MLX5E_VLAN_TABLE_SIZE;
1093+
ft_attr.level = MLX5E_VLAN_FT_LEVEL;
1094+
ft_attr.prio = MLX5E_NIC_PRIO;
1095+
1096+
ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
10841097

10851098
if (IS_ERR(ft->t)) {
10861099
err = PTR_ERR(ft->t);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ esw_fdb_set_vport_promisc_rule(struct mlx5_eswitch *esw, u32 vport)
337337
static int esw_create_legacy_fdb_table(struct mlx5_eswitch *esw, int nvports)
338338
{
339339
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
340+
struct mlx5_flow_table_attr ft_attr = {};
340341
struct mlx5_core_dev *dev = esw->dev;
341342
struct mlx5_flow_namespace *root_ns;
342343
struct mlx5_flow_table *fdb;
@@ -362,7 +363,9 @@ static int esw_create_legacy_fdb_table(struct mlx5_eswitch *esw, int nvports)
362363
memset(flow_group_in, 0, inlen);
363364

364365
table_size = BIT(MLX5_CAP_ESW_FLOWTABLE_FDB(dev, log_max_ft_size));
365-
fdb = mlx5_create_flow_table(root_ns, 0, table_size, 0, 0);
366+
367+
ft_attr.max_fte = table_size;
368+
fdb = mlx5_create_flow_table(root_ns, &ft_attr);
366369
if (IS_ERR(fdb)) {
367370
err = PTR_ERR(fdb);
368371
esw_warn(dev, "Failed to create FDB Table err %d\n", err);

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ static int esw_add_fdb_miss_rule(struct mlx5_eswitch *esw)
432432
static int esw_create_offloads_fdb_table(struct mlx5_eswitch *esw, int nvports)
433433
{
434434
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
435+
struct mlx5_flow_table_attr ft_attr = {};
435436
int table_size, ix, esw_size, err = 0;
436437
struct mlx5_core_dev *dev = esw->dev;
437438
struct mlx5_flow_namespace *root_ns;
@@ -475,7 +476,11 @@ static int esw_create_offloads_fdb_table(struct mlx5_eswitch *esw, int nvports)
475476
esw->fdb_table.fdb = fdb;
476477

477478
table_size = nvports + MAX_PF_SQ + 1;
478-
fdb = mlx5_create_flow_table(root_ns, FDB_SLOW_PATH, table_size, 0, 0);
479+
480+
ft_attr.max_fte = table_size;
481+
ft_attr.prio = FDB_SLOW_PATH;
482+
483+
fdb = mlx5_create_flow_table(root_ns, &ft_attr);
479484
if (IS_ERR(fdb)) {
480485
err = PTR_ERR(fdb);
481486
esw_warn(dev, "Failed to create slow path FDB Table err %d\n", err);
@@ -556,9 +561,10 @@ static void esw_destroy_offloads_fdb_table(struct mlx5_eswitch *esw)
556561

557562
static int esw_create_offloads_table(struct mlx5_eswitch *esw)
558563
{
559-
struct mlx5_flow_namespace *ns;
560-
struct mlx5_flow_table *ft_offloads;
564+
struct mlx5_flow_table_attr ft_attr = {};
561565
struct mlx5_core_dev *dev = esw->dev;
566+
struct mlx5_flow_table *ft_offloads;
567+
struct mlx5_flow_namespace *ns;
562568
int err = 0;
563569

564570
ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_OFFLOADS);
@@ -567,7 +573,9 @@ static int esw_create_offloads_table(struct mlx5_eswitch *esw)
567573
return -EOPNOTSUPP;
568574
}
569575

570-
ft_offloads = mlx5_create_flow_table(ns, 0, dev->priv.sriov.num_vfs + 2, 0, 0);
576+
ft_attr.max_fte = dev->priv.sriov.num_vfs + 2;
577+
578+
ft_offloads = mlx5_create_flow_table(ns, &ft_attr);
571579
if (IS_ERR(ft_offloads)) {
572580
err = PTR_ERR(ft_offloads);
573581
esw_warn(esw->dev, "Failed to create offloads table, err %d\n", err);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
4545
u32 in[MLX5_ST_SZ_DW(set_flow_table_root_in)] = {0};
4646
u32 out[MLX5_ST_SZ_DW(set_flow_table_root_out)] = {0};
4747

48+
if ((MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) &&
49+
ft->underlay_qpn == 0)
50+
return 0;
51+
4852
MLX5_SET(set_flow_table_root_in, in, opcode,
4953
MLX5_CMD_OP_SET_FLOW_TABLE_ROOT);
5054
MLX5_SET(set_flow_table_root_in, in, table_type, ft->type);
@@ -54,6 +58,10 @@ int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
5458
MLX5_SET(set_flow_table_root_in, in, other_vport, 1);
5559
}
5660

61+
if ((MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) &&
62+
ft->underlay_qpn != 0)
63+
MLX5_SET(set_flow_table_root_in, in, underlay_qpn, ft->underlay_qpn);
64+
5765
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
5866
}
5967

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

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -778,48 +778,48 @@ static void list_add_flow_table(struct mlx5_flow_table *ft,
778778
}
779779

780780
static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespace *ns,
781+
struct mlx5_flow_table_attr *ft_attr,
781782
enum fs_flow_table_op_mod op_mod,
782-
u16 vport, int prio,
783-
int max_fte, u32 level,
784-
u32 flags)
783+
u16 vport)
785784
{
785+
struct mlx5_flow_root_namespace *root = find_root(&ns->node);
786786
struct mlx5_flow_table *next_ft = NULL;
787+
struct fs_prio *fs_prio = NULL;
787788
struct mlx5_flow_table *ft;
788-
int err;
789789
int log_table_sz;
790-
struct mlx5_flow_root_namespace *root =
791-
find_root(&ns->node);
792-
struct fs_prio *fs_prio = NULL;
790+
int err;
793791

794792
if (!root) {
795793
pr_err("mlx5: flow steering failed to find root of namespace\n");
796794
return ERR_PTR(-ENODEV);
797795
}
798796

799797
mutex_lock(&root->chain_lock);
800-
fs_prio = find_prio(ns, prio);
798+
fs_prio = find_prio(ns, ft_attr->prio);
801799
if (!fs_prio) {
802800
err = -EINVAL;
803801
goto unlock_root;
804802
}
805-
if (level >= fs_prio->num_levels) {
803+
if (ft_attr->level >= fs_prio->num_levels) {
806804
err = -ENOSPC;
807805
goto unlock_root;
808806
}
809807
/* The level is related to the
810808
* priority level range.
811809
*/
812-
level += fs_prio->start_level;
813-
ft = alloc_flow_table(level,
810+
ft_attr->level += fs_prio->start_level;
811+
ft = alloc_flow_table(ft_attr->level,
814812
vport,
815-
max_fte ? roundup_pow_of_two(max_fte) : 0,
813+
ft_attr->max_fte ? roundup_pow_of_two(ft_attr->max_fte) : 0,
816814
root->table_type,
817-
op_mod, flags);
815+
op_mod, ft_attr->flags);
818816
if (!ft) {
819817
err = -ENOMEM;
820818
goto unlock_root;
821819
}
822820

821+
ft->underlay_qpn = ft_attr->underlay_qpn;
822+
823823
tree_init_node(&ft->node, 1, del_flow_table);
824824
log_table_sz = ft->max_fte ? ilog2(ft->max_fte) : 0;
825825
next_ft = find_next_chained_ft(fs_prio);
@@ -849,44 +849,56 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
849849
}
850850

851851
struct mlx5_flow_table *mlx5_create_flow_table(struct mlx5_flow_namespace *ns,
852-
int prio, int max_fte,
853-
u32 level,
854-
u32 flags)
852+
struct mlx5_flow_table_attr *ft_attr)
855853
{
856-
return __mlx5_create_flow_table(ns, FS_FT_OP_MOD_NORMAL, 0, prio,
857-
max_fte, level, flags);
854+
return __mlx5_create_flow_table(ns, ft_attr, FS_FT_OP_MOD_NORMAL, 0);
858855
}
859856

860857
struct mlx5_flow_table *mlx5_create_vport_flow_table(struct mlx5_flow_namespace *ns,
861858
int prio, int max_fte,
862859
u32 level, u16 vport)
863860
{
864-
return __mlx5_create_flow_table(ns, FS_FT_OP_MOD_NORMAL, vport, prio,
865-
max_fte, level, 0);
861+
struct mlx5_flow_table_attr ft_attr = {};
862+
863+
ft_attr.max_fte = max_fte;
864+
ft_attr.level = level;
865+
ft_attr.prio = prio;
866+
867+
return __mlx5_create_flow_table(ns, &ft_attr, FS_FT_OP_MOD_NORMAL, 0);
866868
}
867869

868-
struct mlx5_flow_table *mlx5_create_lag_demux_flow_table(
869-
struct mlx5_flow_namespace *ns,
870-
int prio, u32 level)
870+
struct mlx5_flow_table*
871+
mlx5_create_lag_demux_flow_table(struct mlx5_flow_namespace *ns,
872+
int prio, u32 level)
871873
{
872-
return __mlx5_create_flow_table(ns, FS_FT_OP_MOD_LAG_DEMUX, 0, prio, 0,
873-
level, 0);
874+
struct mlx5_flow_table_attr ft_attr = {};
875+
876+
ft_attr.level = level;
877+
ft_attr.prio = prio;
878+
return __mlx5_create_flow_table(ns, &ft_attr, FS_FT_OP_MOD_LAG_DEMUX, 0);
874879
}
875880
EXPORT_SYMBOL(mlx5_create_lag_demux_flow_table);
876881

877-
struct mlx5_flow_table *mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
878-
int prio,
879-
int num_flow_table_entries,
880-
int max_num_groups,
881-
u32 level,
882-
u32 flags)
882+
struct mlx5_flow_table*
883+
mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
884+
int prio,
885+
int num_flow_table_entries,
886+
int max_num_groups,
887+
u32 level,
888+
u32 flags)
883889
{
890+
struct mlx5_flow_table_attr ft_attr = {};
884891
struct mlx5_flow_table *ft;
885892

886893
if (max_num_groups > num_flow_table_entries)
887894
return ERR_PTR(-EINVAL);
888895

889-
ft = mlx5_create_flow_table(ns, prio, num_flow_table_entries, level, flags);
896+
ft_attr.max_fte = num_flow_table_entries;
897+
ft_attr.prio = prio;
898+
ft_attr.level = level;
899+
ft_attr.flags = flags;
900+
901+
ft = mlx5_create_flow_table(ns, &ft_attr);
890902
if (IS_ERR(ft))
891903
return ft;
892904

@@ -1828,12 +1840,18 @@ static void set_prio_attrs(struct mlx5_flow_root_namespace *root_ns)
18281840
static int create_anchor_flow_table(struct mlx5_flow_steering *steering)
18291841
{
18301842
struct mlx5_flow_namespace *ns = NULL;
1843+
struct mlx5_flow_table_attr ft_attr = {};
18311844
struct mlx5_flow_table *ft;
18321845

18331846
ns = mlx5_get_flow_namespace(steering->dev, MLX5_FLOW_NAMESPACE_ANCHOR);
18341847
if (WARN_ON(!ns))
18351848
return -EINVAL;
1836-
ft = mlx5_create_flow_table(ns, ANCHOR_PRIO, ANCHOR_SIZE, ANCHOR_LEVEL, 0);
1849+
1850+
ft_attr.max_fte = ANCHOR_SIZE;
1851+
ft_attr.level = ANCHOR_LEVEL;
1852+
ft_attr.prio = ANCHOR_PRIO;
1853+
1854+
ft = mlx5_create_flow_table(ns, &ft_attr);
18371855
if (IS_ERR(ft)) {
18381856
mlx5_core_err(steering->dev, "Failed to create last anchor flow table");
18391857
return PTR_ERR(ft);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct mlx5_flow_table {
118118
/* FWD rules that point on this flow table */
119119
struct list_head fwd_rules;
120120
u32 flags;
121+
u32 underlay_qpn;
121122
};
122123

123124
struct mlx5_fc_cache {

include/linux/mlx5/fs.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,18 @@ mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
104104
u32 level,
105105
u32 flags);
106106

107+
struct mlx5_flow_table_attr {
108+
int prio;
109+
int max_fte;
110+
u32 level;
111+
u32 flags;
112+
u32 underlay_qpn;
113+
};
114+
107115
struct mlx5_flow_table *
108116
mlx5_create_flow_table(struct mlx5_flow_namespace *ns,
109-
int prio,
110-
int num_flow_table_entries,
111-
u32 level,
112-
u32 flags);
117+
struct mlx5_flow_table_attr *ft_attr);
118+
113119
struct mlx5_flow_table *
114120
mlx5_create_vport_flow_table(struct mlx5_flow_namespace *ns,
115121
int prio,

0 commit comments

Comments
 (0)