History

net/mlx5: Refactor mlx5_create_auto_grouped_flow_table

Refactor mlx5_create_auto_grouped_flow_table() to use ft_attr param which already carries the max_fte, prio and flags memebers, and is used the same in similar mlx5_create_flow_table() function.

Paul Blakey committed 7 years ago

Commit 61dc7b01 parent 827a8cb8 files · +52 −48Browse files

Unified · Split

8 files
  1. drivers/infiniband/hw/mlx5/main.c +6 −4
  2. drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c +6 −3
  3. drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +8 −5
  4. drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +5 −2
  5. drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +7 −6
  6. drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c +6 −5
  7. drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +6 −15
  8. include/linux/mlx5/fs.h +8 −8
drivers/infiniband/hw/mlx5/main.c+6−4
@@ -3239,12 +3239,14 @@ static struct mlx5_ib_flow_prio *_get_prio(struct mlx5_flow_namespace *ns, · 3238 unmodified lines
32393239 int num_entries, int num_groups,
32403240 u32 flags)
32413241 {
3242+ struct mlx5_flow_table_attr ft_attr = {};
32423243 struct mlx5_flow_table *ft;
32433244
3244− ft = mlx5_create_auto_grouped_flow_table(ns, priority,
3245− num_entries,
3246− num_groups,
3247− 0, flags);
3245+ ft_attr.prio = priority;
3246+ ft_attr.max_fte = num_entries;
3247+ ft_attr.flags = flags;
3248+ ft_attr.autogroup.max_num_groups = num_groups;
3249+ ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
32483250 if (IS_ERR(ft))
32493251 return ERR_CAST(ft);
32503252
drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c+6−3
@@ -58,6 +58,7 @@ static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv, · 57 unmodified lines
5858 struct ethtool_rx_flow_spec *fs,
5959 int num_tuples)
6060 {
61+ struct mlx5_flow_table_attr ft_attr = {};
6162 struct mlx5e_ethtool_table *eth_ft;
6263 struct mlx5_flow_namespace *ns;
6364 struct mlx5_flow_table *ft;
@@ -102,9 +103,11 @@ static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv, · 38 unmodified lines
102103 table_size = min_t(u32, BIT(MLX5_CAP_FLOWTABLE(priv->mdev,
103104 flow_table_properties_nic_receive.log_max_ft_size)),
104105 MLX5E_ETHTOOL_NUM_ENTRIES);
105− ft = mlx5_create_auto_grouped_flow_table(ns, prio,
106− table_size,
107− MLX5E_ETHTOOL_NUM_GROUPS, 0, 0);
106+
107+ ft_attr.prio = prio;
108+ ft_attr.max_fte = table_size;
109+ ft_attr.autogroup.max_num_groups = MLX5E_ETHTOOL_NUM_GROUPS;
110+ ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
108111 if (IS_ERR(ft))
109112 return (void *)ft;
110113
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c+8−5
@@ -960,7 +960,8 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, · 959 unmodified lines
960960
961961 mutex_lock(&priv->fs.tc.t_lock);
962962 if (IS_ERR_OR_NULL(priv->fs.tc.t)) {
963− int tc_grp_size, tc_tbl_size;
963+ struct mlx5_flow_table_attr ft_attr = {};
964+ int tc_grp_size, tc_tbl_size, tc_num_grps;
964965 u32 max_flow_counter;
965966
966967 max_flow_counter = (MLX5_CAP_GEN(dev, max_flow_counter_31_16) << 16) |
@@ -970,13 +971,15 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, · 3 unmodified lines
970971
971972 tc_tbl_size = min_t(int, tc_grp_size * MLX5E_TC_TABLE_NUM_GROUPS,
972973 BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev, log_max_ft_size)));
974+ tc_num_grps = MLX5E_TC_TABLE_NUM_GROUPS;
973975
976+ ft_attr.prio = MLX5E_TC_PRIO;
977+ ft_attr.max_fte = tc_tbl_size;
978+ ft_attr.level = MLX5E_TC_FT_LEVEL;
979+ ft_attr.autogroup.max_num_groups = tc_num_grps;
974980 priv->fs.tc.t =
975981 mlx5_create_auto_grouped_flow_table(priv->fs.ns,
976− MLX5E_TC_PRIO,
977− tc_tbl_size,
978− MLX5E_TC_TABLE_NUM_GROUPS,
979− MLX5E_TC_FT_LEVEL, 0);
982+ &ft_attr);
980983 if (IS_ERR(priv->fs.tc.t)) {
981984 mutex_unlock(&priv->fs.tc.t_lock);
982985 NL_SET_ERR_MSG_MOD(extack,
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c+5−2
@@ -277,6 +277,7 @@ enum { · 276 unmodified lines
277277
278278 static int esw_create_legacy_vepa_table(struct mlx5_eswitch *esw)
279279 {
280+ struct mlx5_flow_table_attr ft_attr = {};
280281 struct mlx5_core_dev *dev = esw->dev;
281282 struct mlx5_flow_namespace *root_ns;
282283 struct mlx5_flow_table *fdb;
@@ -289,8 +290,10 @@ static int esw_create_legacy_vepa_table(struct mlx5_eswitch *esw) · 6 unmodified lines
289290 }
290291
291292 /* num FTE 2, num FG 2 */
292− fdb = mlx5_create_auto_grouped_flow_table(root_ns, LEGACY_VEPA_PRIO,
293− 2, 2, 0, 0);
293+ ft_attr.prio = LEGACY_VEPA_PRIO;
294+ ft_attr.max_fte = 2;
295+ ft_attr.autogroup.max_num_groups = 2;
296+ fdb = mlx5_create_auto_grouped_flow_table(root_ns, &ft_attr);
294297 if (IS_ERR(fdb)) {
295298 err = PTR_ERR(fdb);
296299 esw_warn(dev, "Failed to create VEPA FDB err %d\n", err);
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c+7−6
@@ -904,6 +904,7 @@ create_next_size_table(struct mlx5_eswitch *esw, · 903 unmodified lines
904904 int level,
905905 u32 flags)
906906 {
907+ struct mlx5_flow_table_attr ft_attr = {};
907908 struct mlx5_flow_table *fdb;
908909 int sz;
909910
@@ -911,12 +912,12 @@ create_next_size_table(struct mlx5_eswitch *esw, · 1 unmodified line
911912 if (!sz)
912913 return ERR_PTR(-ENOSPC);
913914
914− fdb = mlx5_create_auto_grouped_flow_table(ns,
915− table_prio,
916− sz,
917− ESW_OFFLOADS_NUM_GROUPS,
918− level,
919− flags);
915+ ft_attr.max_fte = sz;
916+ ft_attr.prio = table_prio;
917+ ft_attr.level = level;
918+ ft_attr.flags = flags;
919+ ft_attr.autogroup.max_num_groups = ESW_OFFLOADS_NUM_GROUPS;
920+ fdb = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
920921 if (IS_ERR(fdb)) {
921922 esw_warn(esw->dev, "Failed to create FDB Table err %d (table prio: %d, level: %d, size: %d)\n",
922923 (int)PTR_ERR(fdb), table_prio, level, sz);
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c+6−5
@@ -50,8 +50,8 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev, · 49 unmodified lines
5050 struct mlx5_flow_act *flow_act)
5151 {
5252 static const struct mlx5_flow_spec spec = {};
53+ struct mlx5_flow_table_attr ft_attr = {};
5354 struct mlx5_flow_namespace *root_ns;
54− int prio, flags;
5555 int err;
5656
5757 root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_FDB);
@@ -63,10 +63,11 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev, · 5 unmodified lines
6363 /* As this is the terminating action then the termination table is the
6464 * same prio as the slow path
6565 */
66− prio = FDB_SLOW_PATH;
67− flags = MLX5_FLOW_TABLE_TERMINATION;
68− tt->termtbl = mlx5_create_auto_grouped_flow_table(root_ns, prio, 1, 1,
69− 0, flags);
66+ ft_attr.flags = MLX5_FLOW_TABLE_TERMINATION;
67+ ft_attr.prio = FDB_SLOW_PATH;
68+ ft_attr.max_fte = 1;
69+ ft_attr.autogroup.max_num_groups = 1;
70+ tt->termtbl = mlx5_create_auto_grouped_flow_table(root_ns, &ft_attr);
7071 if (IS_ERR(tt->termtbl)) {
7172 esw_warn(dev, "Failed to create termination table\n");
7273 return -EOPNOTSUPP;
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c+6−15
@@ -1111,31 +1111,22 @@ EXPORT_SYMBOL(mlx5_create_lag_demux_flow_table); · 1110 unmodified lines
11111111
11121112 struct mlx5_flow_table*
11131113 mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
1114− int prio,
1115− int num_flow_table_entries,
1116− int max_num_groups,
1117− u32 level,
1118− u32 flags)
1114+ struct mlx5_flow_table_attr *ft_attr)
11191115 {
1120− struct mlx5_flow_table_attr ft_attr = {};
11211116 struct mlx5_flow_table *ft;
11221117
1123− if (max_num_groups > num_flow_table_entries)
1118+ if (ft_attr->autogroup.max_num_groups > ft_attr->max_fte)
11241119 return ERR_PTR(-EINVAL);
11251120
1126− ft_attr.max_fte = num_flow_table_entries;
1127− ft_attr.prio = prio;
1128− ft_attr.level = level;
1129− ft_attr.flags = flags;
1130−
1131− ft = mlx5_create_flow_table(ns, &ft_attr);
1121+ ft = mlx5_create_flow_table(ns, ft_attr);
11321122 if (IS_ERR(ft))
11331123 return ft;
11341124
11351125 ft->autogroup.active = true;
1136− ft->autogroup.required_groups = max_num_groups;
1126+ ft->autogroup.required_groups = ft_attr->autogroup.max_num_groups;
11371127 /* We save place for flow groups in addition to max types */
1138− ft->autogroup.group_size = ft->max_fte / (max_num_groups + 1);
1128+ ft->autogroup.group_size = ft->max_fte /
1129+ (ft->autogroup.required_groups + 1);
11391130
11401131 return ft;
11411132 }
include/linux/mlx5/fs.h+8−8
@@ -145,25 +145,25 @@ mlx5_get_flow_vport_acl_namespace(struct mlx5_core_dev *dev, · 144 unmodified lines
145145 enum mlx5_flow_namespace_type type,
146146 int vport);
147147
148−struct mlx5_flow_table *
149−mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
150− int prio,
151− int num_flow_table_entries,
152− int max_num_groups,
153− u32 level,
154− u32 flags);
155−
156148 struct mlx5_flow_table_attr {
157149 int prio;
158150 int max_fte;
159151 u32 level;
160152 u32 flags;
153+
154+ struct {
155+ int max_num_groups;
156+ } autogroup;
161157 };
162158
163159 struct mlx5_flow_table *
164160 mlx5_create_flow_table(struct mlx5_flow_namespace *ns,
165161 struct mlx5_flow_table_attr *ft_attr);
166162
163+struct mlx5_flow_table *
164+mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
165+ struct mlx5_flow_table_attr *ft_attr);
166+
167167 struct mlx5_flow_table *
168168 mlx5_create_vport_flow_table(struct mlx5_flow_namespace *ns,
169169 int prio,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t