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.
Unified · Split
| @@ -3239,12 +3239,14 @@ static struct mlx5_ib_flow_prio *_get_prio(struct mlx5_flow_namespace *ns, · 3238 unmodified lines | ||
| 3239 | 3239 | int num_entries, int num_groups, |
| 3240 | 3240 | u32 flags) |
| 3241 | 3241 | { |
| 3242 | + struct mlx5_flow_table_attr ft_attr = {}; | |
| 3242 | 3243 | struct mlx5_flow_table *ft; |
| 3243 | 3244 | |
| 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); | |
| 3248 | 3250 | if (IS_ERR(ft)) |
| 3249 | 3251 | return ERR_CAST(ft); |
| 3250 | 3252 | |
| @@ -58,6 +58,7 @@ static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv, · 57 unmodified lines | ||
| 58 | 58 | struct ethtool_rx_flow_spec *fs, |
| 59 | 59 | int num_tuples) |
| 60 | 60 | { |
| 61 | + struct mlx5_flow_table_attr ft_attr = {}; | |
| 61 | 62 | struct mlx5e_ethtool_table *eth_ft; |
| 62 | 63 | struct mlx5_flow_namespace *ns; |
| 63 | 64 | struct mlx5_flow_table *ft; |
| @@ -102,9 +103,11 @@ static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv, · 38 unmodified lines | ||
| 102 | 103 | table_size = min_t(u32, BIT(MLX5_CAP_FLOWTABLE(priv->mdev, |
| 103 | 104 | flow_table_properties_nic_receive.log_max_ft_size)), |
| 104 | 105 | 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); | |
| 108 | 111 | if (IS_ERR(ft)) |
| 109 | 112 | return (void *)ft; |
| 110 | 113 | |
| @@ -960,7 +960,8 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, · 959 unmodified lines | ||
| 960 | 960 | |
| 961 | 961 | mutex_lock(&priv->fs.tc.t_lock); |
| 962 | 962 | 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; | |
| 964 | 965 | u32 max_flow_counter; |
| 965 | 966 | |
| 966 | 967 | 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 | ||
| 970 | 971 | |
| 971 | 972 | tc_tbl_size = min_t(int, tc_grp_size * MLX5E_TC_TABLE_NUM_GROUPS, |
| 972 | 973 | BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev, log_max_ft_size))); |
| 974 | + tc_num_grps = MLX5E_TC_TABLE_NUM_GROUPS; | |
| 973 | 975 | |
| 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; | |
| 974 | 980 | priv->fs.tc.t = |
| 975 | 981 | 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); | |
| 980 | 983 | if (IS_ERR(priv->fs.tc.t)) { |
| 981 | 984 | mutex_unlock(&priv->fs.tc.t_lock); |
| 982 | 985 | NL_SET_ERR_MSG_MOD(extack, |
| @@ -277,6 +277,7 @@ enum { · 276 unmodified lines | ||
| 277 | 277 | |
| 278 | 278 | static int esw_create_legacy_vepa_table(struct mlx5_eswitch *esw) |
| 279 | 279 | { |
| 280 | + struct mlx5_flow_table_attr ft_attr = {}; | |
| 280 | 281 | struct mlx5_core_dev *dev = esw->dev; |
| 281 | 282 | struct mlx5_flow_namespace *root_ns; |
| 282 | 283 | struct mlx5_flow_table *fdb; |
| @@ -289,8 +290,10 @@ static int esw_create_legacy_vepa_table(struct mlx5_eswitch *esw) · 6 unmodified lines | ||
| 289 | 290 | } |
| 290 | 291 | |
| 291 | 292 | /* 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); | |
| 294 | 297 | if (IS_ERR(fdb)) { |
| 295 | 298 | err = PTR_ERR(fdb); |
| 296 | 299 | esw_warn(dev, "Failed to create VEPA FDB err %d\n", err); |
| @@ -904,6 +904,7 @@ create_next_size_table(struct mlx5_eswitch *esw, · 903 unmodified lines | ||
| 904 | 904 | int level, |
| 905 | 905 | u32 flags) |
| 906 | 906 | { |
| 907 | + struct mlx5_flow_table_attr ft_attr = {}; | |
| 907 | 908 | struct mlx5_flow_table *fdb; |
| 908 | 909 | int sz; |
| 909 | 910 | |
| @@ -911,12 +912,12 @@ create_next_size_table(struct mlx5_eswitch *esw, · 1 unmodified line | ||
| 911 | 912 | if (!sz) |
| 912 | 913 | return ERR_PTR(-ENOSPC); |
| 913 | 914 | |
| 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); | |
| 920 | 921 | if (IS_ERR(fdb)) { |
| 921 | 922 | esw_warn(esw->dev, "Failed to create FDB Table err %d (table prio: %d, level: %d, size: %d)\n", |
| 922 | 923 | (int)PTR_ERR(fdb), table_prio, level, sz); |
| @@ -50,8 +50,8 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev, · 49 unmodified lines | ||
| 50 | 50 | struct mlx5_flow_act *flow_act) |
| 51 | 51 | { |
| 52 | 52 | static const struct mlx5_flow_spec spec = {}; |
| 53 | + struct mlx5_flow_table_attr ft_attr = {}; | |
| 53 | 54 | struct mlx5_flow_namespace *root_ns; |
| 54 | − int prio, flags; | |
| 55 | 55 | int err; |
| 56 | 56 | |
| 57 | 57 | 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 | ||
| 63 | 63 | /* As this is the terminating action then the termination table is the |
| 64 | 64 | * same prio as the slow path |
| 65 | 65 | */ |
| 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); | |
| 70 | 71 | if (IS_ERR(tt->termtbl)) { |
| 71 | 72 | esw_warn(dev, "Failed to create termination table\n"); |
| 72 | 73 | return -EOPNOTSUPP; |
| @@ -1111,31 +1111,22 @@ EXPORT_SYMBOL(mlx5_create_lag_demux_flow_table); · 1110 unmodified lines | ||
| 1111 | 1111 | |
| 1112 | 1112 | struct mlx5_flow_table* |
| 1113 | 1113 | 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) | |
| 1119 | 1115 | { |
| 1120 | − struct mlx5_flow_table_attr ft_attr = {}; | |
| 1121 | 1116 | struct mlx5_flow_table *ft; |
| 1122 | 1117 | |
| 1123 | − if (max_num_groups > num_flow_table_entries) | |
| 1118 | + if (ft_attr->autogroup.max_num_groups > ft_attr->max_fte) | |
| 1124 | 1119 | return ERR_PTR(-EINVAL); |
| 1125 | 1120 | |
| 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); | |
| 1132 | 1122 | if (IS_ERR(ft)) |
| 1133 | 1123 | return ft; |
| 1134 | 1124 | |
| 1135 | 1125 | ft->autogroup.active = true; |
| 1136 | − ft->autogroup.required_groups = max_num_groups; | |
| 1126 | + ft->autogroup.required_groups = ft_attr->autogroup.max_num_groups; | |
| 1137 | 1127 | /* 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); | |
| 1139 | 1130 | |
| 1140 | 1131 | return ft; |
| 1141 | 1132 | } |
| @@ -145,25 +145,25 @@ mlx5_get_flow_vport_acl_namespace(struct mlx5_core_dev *dev, · 144 unmodified lines | ||
| 145 | 145 | enum mlx5_flow_namespace_type type, |
| 146 | 146 | int vport); |
| 147 | 147 | |
| 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 | − | |
| 156 | 148 | struct mlx5_flow_table_attr { |
| 157 | 149 | int prio; |
| 158 | 150 | int max_fte; |
| 159 | 151 | u32 level; |
| 160 | 152 | u32 flags; |
| 153 | + | |
| 154 | + struct { | |
| 155 | + int max_num_groups; | |
| 156 | + } autogroup; | |
| 161 | 157 | }; |
| 162 | 158 | |
| 163 | 159 | struct mlx5_flow_table * |
| 164 | 160 | mlx5_create_flow_table(struct mlx5_flow_namespace *ns, |
| 165 | 161 | struct mlx5_flow_table_attr *ft_attr); |
| 166 | 162 | |
| 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 | + | |
| 167 | 167 | struct mlx5_flow_table * |
| 168 | 168 | mlx5_create_vport_flow_table(struct mlx5_flow_namespace *ns, |
| 169 | 169 | int prio, |