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 | int num_entries, int num_groups, | 3239 | int num_entries, int num_groups, |
| 3240 | u32 flags) | 3240 | u32 flags) |
| 3241 | { | 3241 | { |
| 3242 | struct mlx5_flow_table_attr ft_attr = {}; | ||
| 3242 | struct mlx5_flow_table *ft; | 3243 | struct mlx5_flow_table *ft; |
| 3243 | 3244 | ||
| 3244 | ft = mlx5_create_auto_grouped_flow_table(ns, priority, | 3245 | ft_attr.prio = priority; |
| 3245 | num_entries, | 3246 | ft_attr.max_fte = num_entries; |
| 3246 | num_groups, | 3247 | ft_attr.flags = flags; |
| 3247 | 0, flags); | 3248 | ft_attr.autogroup.max_num_groups = num_groups; |
| 3249 | ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr); | ||
| 3248 | if (IS_ERR(ft)) | 3250 | if (IS_ERR(ft)) |
| 3249 | return ERR_CAST(ft); | 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 | struct ethtool_rx_flow_spec *fs, | 58 | struct ethtool_rx_flow_spec *fs, |
| 59 | int num_tuples) | 59 | int num_tuples) |
| 60 | { | 60 | { |
| 61 | struct mlx5_flow_table_attr ft_attr = {}; | ||
| 61 | struct mlx5e_ethtool_table *eth_ft; | 62 | struct mlx5e_ethtool_table *eth_ft; |
| 62 | struct mlx5_flow_namespace *ns; | 63 | struct mlx5_flow_namespace *ns; |
| 63 | struct mlx5_flow_table *ft; | 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 | table_size = min_t(u32, BIT(MLX5_CAP_FLOWTABLE(priv->mdev, | 103 | table_size = min_t(u32, BIT(MLX5_CAP_FLOWTABLE(priv->mdev, |
| 103 | flow_table_properties_nic_receive.log_max_ft_size)), | 104 | flow_table_properties_nic_receive.log_max_ft_size)), |
| 104 | MLX5E_ETHTOOL_NUM_ENTRIES); | 105 | MLX5E_ETHTOOL_NUM_ENTRIES); |
| 105 | ft = mlx5_create_auto_grouped_flow_table(ns, prio, | 106 | |
| 106 | table_size, | 107 | ft_attr.prio = prio; |
| 107 | MLX5E_ETHTOOL_NUM_GROUPS, 0, 0); | 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 | if (IS_ERR(ft)) | 111 | if (IS_ERR(ft)) |
| 109 | return (void *)ft; | 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 | mutex_lock(&priv->fs.tc.t_lock); | 961 | mutex_lock(&priv->fs.tc.t_lock); |
| 962 | if (IS_ERR_OR_NULL(priv->fs.tc.t)) { | 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 | u32 max_flow_counter; | 965 | u32 max_flow_counter; |
| 965 | 966 | ||
| 966 | max_flow_counter = (MLX5_CAP_GEN(dev, max_flow_counter_31_16) << 16) | | 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 | tc_tbl_size = min_t(int, tc_grp_size * MLX5E_TC_TABLE_NUM_GROUPS, | 972 | tc_tbl_size = min_t(int, tc_grp_size * MLX5E_TC_TABLE_NUM_GROUPS, |
| 972 | BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev, log_max_ft_size))); | 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 | priv->fs.tc.t = | 980 | priv->fs.tc.t = |
| 975 | mlx5_create_auto_grouped_flow_table(priv->fs.ns, | 981 | mlx5_create_auto_grouped_flow_table(priv->fs.ns, |
| 976 | MLX5E_TC_PRIO, | 982 | &ft_attr); |
| 977 | tc_tbl_size, | ||
| 978 | MLX5E_TC_TABLE_NUM_GROUPS, | ||
| 979 | MLX5E_TC_FT_LEVEL, 0); | ||
| 980 | if (IS_ERR(priv->fs.tc.t)) { | 983 | if (IS_ERR(priv->fs.tc.t)) { |
| 981 | mutex_unlock(&priv->fs.tc.t_lock); | 984 | mutex_unlock(&priv->fs.tc.t_lock); |
| 982 | NL_SET_ERR_MSG_MOD(extack, | 985 | NL_SET_ERR_MSG_MOD(extack, |
| @@ -277,6 +277,7 @@ enum { · 276 unmodified lines | |||
| 277 | 277 | ||
| 278 | static int esw_create_legacy_vepa_table(struct mlx5_eswitch *esw) | 278 | static int esw_create_legacy_vepa_table(struct mlx5_eswitch *esw) |
| 279 | { | 279 | { |
| 280 | struct mlx5_flow_table_attr ft_attr = {}; | ||
| 280 | struct mlx5_core_dev *dev = esw->dev; | 281 | struct mlx5_core_dev *dev = esw->dev; |
| 281 | struct mlx5_flow_namespace *root_ns; | 282 | struct mlx5_flow_namespace *root_ns; |
| 282 | struct mlx5_flow_table *fdb; | 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 | /* num FTE 2, num FG 2 */ | 292 | /* num FTE 2, num FG 2 */ |
| 292 | fdb = mlx5_create_auto_grouped_flow_table(root_ns, LEGACY_VEPA_PRIO, | 293 | ft_attr.prio = LEGACY_VEPA_PRIO; |
| 293 | 2, 2, 0, 0); | 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 | if (IS_ERR(fdb)) { | 297 | if (IS_ERR(fdb)) { |
| 295 | err = PTR_ERR(fdb); | 298 | err = PTR_ERR(fdb); |
| 296 | esw_warn(dev, "Failed to create VEPA FDB err %d\n", err); | 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 | int level, | 904 | int level, |
| 905 | u32 flags) | 905 | u32 flags) |
| 906 | { | 906 | { |
| 907 | struct mlx5_flow_table_attr ft_attr = {}; | ||
| 907 | struct mlx5_flow_table *fdb; | 908 | struct mlx5_flow_table *fdb; |
| 908 | int sz; | 909 | int sz; |
| 909 | 910 | ||
| @@ -911,12 +912,12 @@ create_next_size_table(struct mlx5_eswitch *esw, · 1 unmodified line | |||
| 911 | if (!sz) | 912 | if (!sz) |
| 912 | return ERR_PTR(-ENOSPC); | 913 | return ERR_PTR(-ENOSPC); |
| 913 | 914 | ||
| 914 | fdb = mlx5_create_auto_grouped_flow_table(ns, | 915 | ft_attr.max_fte = sz; |
| 915 | table_prio, | 916 | ft_attr.prio = table_prio; |
| 916 | sz, | 917 | ft_attr.level = level; |
| 917 | ESW_OFFLOADS_NUM_GROUPS, | 918 | ft_attr.flags = flags; |
| 918 | level, | 919 | ft_attr.autogroup.max_num_groups = ESW_OFFLOADS_NUM_GROUPS; |
| 919 | flags); | 920 | fdb = mlx5_create_auto_grouped_flow_table(ns, &ft_attr); |
| 920 | if (IS_ERR(fdb)) { | 921 | if (IS_ERR(fdb)) { |
| 921 | esw_warn(esw->dev, "Failed to create FDB Table err %d (table prio: %d, level: %d, size: %d)\n", | 922 | esw_warn(esw->dev, "Failed to create FDB Table err %d (table prio: %d, level: %d, size: %d)\n", |
| 922 | (int)PTR_ERR(fdb), table_prio, level, sz); | 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 | struct mlx5_flow_act *flow_act) | 50 | struct mlx5_flow_act *flow_act) |
| 51 | { | 51 | { |
| 52 | static const struct mlx5_flow_spec spec = {}; | 52 | static const struct mlx5_flow_spec spec = {}; |
| 53 | struct mlx5_flow_table_attr ft_attr = {}; | ||
| 53 | struct mlx5_flow_namespace *root_ns; | 54 | struct mlx5_flow_namespace *root_ns; |
| 54 | int prio, flags; | ||
| 55 | int err; | 55 | int err; |
| 56 | 56 | ||
| 57 | root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_FDB); | 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 | /* As this is the terminating action then the termination table is the | 63 | /* As this is the terminating action then the termination table is the |
| 64 | * same prio as the slow path | 64 | * same prio as the slow path |
| 65 | */ | 65 | */ |
| 66 | prio = FDB_SLOW_PATH; | 66 | ft_attr.flags = MLX5_FLOW_TABLE_TERMINATION; |
| 67 | flags = MLX5_FLOW_TABLE_TERMINATION; | 67 | ft_attr.prio = FDB_SLOW_PATH; |
| 68 | tt->termtbl = mlx5_create_auto_grouped_flow_table(root_ns, prio, 1, 1, | 68 | ft_attr.max_fte = 1; |
| 69 | 0, flags); | 69 | ft_attr.autogroup.max_num_groups = 1; |
| 70 | tt->termtbl = mlx5_create_auto_grouped_flow_table(root_ns, &ft_attr); | ||
| 70 | if (IS_ERR(tt->termtbl)) { | 71 | if (IS_ERR(tt->termtbl)) { |
| 71 | esw_warn(dev, "Failed to create termination table\n"); | 72 | esw_warn(dev, "Failed to create termination table\n"); |
| 72 | return -EOPNOTSUPP; | 73 | return -EOPNOTSUPP; |
| @@ -1111,31 +1111,22 @@ EXPORT_SYMBOL(mlx5_create_lag_demux_flow_table); · 1110 unmodified lines | |||
| 1111 | 1111 | ||
| 1112 | struct mlx5_flow_table* | 1112 | struct mlx5_flow_table* |
| 1113 | mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns, | 1113 | mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns, |
| 1114 | int prio, | 1114 | struct mlx5_flow_table_attr *ft_attr) |
| 1115 | int num_flow_table_entries, | ||
| 1116 | int max_num_groups, | ||
| 1117 | u32 level, | ||
| 1118 | u32 flags) | ||
| 1119 | { | 1115 | { |
| 1120 | struct mlx5_flow_table_attr ft_attr = {}; | ||
| 1121 | struct mlx5_flow_table *ft; | 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 | return ERR_PTR(-EINVAL); | 1119 | return ERR_PTR(-EINVAL); |
| 1125 | 1120 | ||
| 1126 | ft_attr.max_fte = num_flow_table_entries; | 1121 | ft = mlx5_create_flow_table(ns, ft_attr); |
| 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); | ||
| 1132 | if (IS_ERR(ft)) | 1122 | if (IS_ERR(ft)) |
| 1133 | return ft; | 1123 | return ft; |
| 1134 | 1124 | ||
| 1135 | ft->autogroup.active = true; | 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 | /* We save place for flow groups in addition to max types */ | 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 | return ft; | 1131 | return ft; |
| 1141 | } | 1132 | } |
| @@ -145,25 +145,25 @@ mlx5_get_flow_vport_acl_namespace(struct mlx5_core_dev *dev, · 144 unmodified lines | |||
| 145 | enum mlx5_flow_namespace_type type, | 145 | enum mlx5_flow_namespace_type type, |
| 146 | int vport); | 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 | struct mlx5_flow_table_attr { | 148 | struct mlx5_flow_table_attr { |
| 157 | int prio; | 149 | int prio; |
| 158 | int max_fte; | 150 | int max_fte; |
| 159 | u32 level; | 151 | u32 level; |
| 160 | u32 flags; | 152 | u32 flags; |
| 153 | |||
| 154 | struct { | ||
| 155 | int max_num_groups; | ||
| 156 | } autogroup; | ||
| 161 | }; | 157 | }; |
| 162 | 158 | ||
| 163 | struct mlx5_flow_table * | 159 | struct mlx5_flow_table * |
| 164 | mlx5_create_flow_table(struct mlx5_flow_namespace *ns, | 160 | mlx5_create_flow_table(struct mlx5_flow_namespace *ns, |
| 165 | struct mlx5_flow_table_attr *ft_attr); | 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 | struct mlx5_flow_table * | 167 | struct mlx5_flow_table * |
| 168 | mlx5_create_vport_flow_table(struct mlx5_flow_namespace *ns, | 168 | mlx5_create_vport_flow_table(struct mlx5_flow_namespace *ns, |
| 169 | int prio, | 169 | int prio, |