提交 dac388ef 编写于 作者: M Maor Gottlieb 提交者: Doug Ledford

IB/mlx5: Check supported flow table size

Check that the required flow table size is supported
by device. Return ENOMEM error if no space left.

In addition change the create flow table routine
to return ENOMEM instead of ENOSPC.

Fixes: 038d2ef8 ('IB/mlx5: Add flow steering support')
Signed-off-by: NMaor Gottlieb <maorg@mellanox.com>
Signed-off-by: NLeon Romanovsky <leon@kernel.org>
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 13776612
...@@ -2049,11 +2049,14 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev, ...@@ -2049,11 +2049,14 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,
struct mlx5_flow_namespace *ns = NULL; struct mlx5_flow_namespace *ns = NULL;
struct mlx5_ib_flow_prio *prio; struct mlx5_ib_flow_prio *prio;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
int max_table_size;
int num_entries; int num_entries;
int num_groups; int num_groups;
int priority; int priority;
int err = 0; int err = 0;
max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
log_max_ft_size));
if (flow_attr->type == IB_FLOW_ATTR_NORMAL) { if (flow_attr->type == IB_FLOW_ATTR_NORMAL) {
if (flow_is_multicast_only(flow_attr) && if (flow_is_multicast_only(flow_attr) &&
!dont_trap) !dont_trap)
...@@ -2092,6 +2095,9 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev, ...@@ -2092,6 +2095,9 @@ static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,
if (!ns) if (!ns)
return ERR_PTR(-ENOTSUPP); return ERR_PTR(-ENOTSUPP);
if (num_entries > max_table_size)
return ERR_PTR(-ENOMEM);
ft = prio->flow_table; ft = prio->flow_table;
if (!ft) { if (!ft) {
ft = mlx5_create_auto_grouped_flow_table(ns, priority, ft = mlx5_create_auto_grouped_flow_table(ns, priority,
...@@ -2316,7 +2322,7 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp, ...@@ -2316,7 +2322,7 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
int err; int err;
if (flow_attr->priority > MLX5_IB_FLOW_LAST_PRIO) if (flow_attr->priority > MLX5_IB_FLOW_LAST_PRIO)
return ERR_PTR(-ENOSPC); return ERR_PTR(-ENOMEM);
if (domain != IB_FLOW_DOMAIN_USER || if (domain != IB_FLOW_DOMAIN_USER ||
flow_attr->port > MLX5_CAP_GEN(dev->mdev, num_ports) || flow_attr->port > MLX5_CAP_GEN(dev->mdev, num_ports) ||
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册