net/mlx5: Cap the maximum flow group size to 16M entries
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / fs_core.c
index 6e20cbb4656a7e26eeb626140e8e95e01df8e6e8..1b7a1cde097ce686c92635ae86f2daa80c14815c 100644 (file)
@@ -1173,6 +1173,7 @@ mlx5_create_lag_demux_flow_table(struct mlx5_flow_namespace *ns,
 }
 EXPORT_SYMBOL(mlx5_create_lag_demux_flow_table);
 
+#define MAX_FLOW_GROUP_SIZE BIT(24)
 struct mlx5_flow_table*
 mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
                                    struct mlx5_flow_table_attr *ft_attr)
@@ -1192,6 +1193,10 @@ mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
        if (num_reserved_entries > ft->max_fte)
                goto err_validate;
 
+       /* Align the number of groups according to the largest group size */
+       if (autogroups_max_fte / (max_num_groups + 1) > MAX_FLOW_GROUP_SIZE)
+               max_num_groups = (autogroups_max_fte / MAX_FLOW_GROUP_SIZE) - 1;
+
        ft->autogroup.active = true;
        ft->autogroup.required_groups = max_num_groups;
        ft->autogroup.max_fte = autogroups_max_fte;