net/mlx4_core: Dynamically set guaranteed amount of counters per VF
Prior to this patch, the amount of counters guaranteed per VF in the
resource tracker was MLX4_VF_COUNTERS_PER_PORT * MLX4_MAX_PORTS. It was
set regardless if the VF was single or dual port.
This caused several VFs to have no guaranteed counters although the
system could satisfy their request.
The fix is to dynamically guarantee counters, based on each VF
specification.
Fixes: 9de92c60be
("net/mlx4_core: Adjust counter grant policy in the resource tracker")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c1b5ddc112
commit
e19868efea
|
@ -471,12 +471,31 @@ void mlx4_init_quotas(struct mlx4_dev *dev)
|
|||
priv->mfunc.master.res_tracker.res_alloc[RES_MPT].quota[pf];
|
||||
}
|
||||
|
||||
static int get_max_gauranteed_vfs_counter(struct mlx4_dev *dev)
|
||||
static int
|
||||
mlx4_calc_res_counter_guaranteed(struct mlx4_dev *dev,
|
||||
struct resource_allocator *res_alloc,
|
||||
int vf)
|
||||
{
|
||||
/* reduce the sink counter */
|
||||
return (dev->caps.max_counters - 1 -
|
||||
(MLX4_PF_COUNTERS_PER_PORT * MLX4_MAX_PORTS))
|
||||
/ MLX4_MAX_PORTS;
|
||||
struct mlx4_active_ports actv_ports;
|
||||
int ports, counters_guaranteed;
|
||||
|
||||
/* For master, only allocate according to the number of phys ports */
|
||||
if (vf == mlx4_master_func_num(dev))
|
||||
return MLX4_PF_COUNTERS_PER_PORT * dev->caps.num_ports;
|
||||
|
||||
/* calculate real number of ports for the VF */
|
||||
actv_ports = mlx4_get_active_ports(dev, vf);
|
||||
ports = bitmap_weight(actv_ports.ports, dev->caps.num_ports);
|
||||
counters_guaranteed = ports * MLX4_VF_COUNTERS_PER_PORT;
|
||||
|
||||
/* If we do not have enough counters for this VF, do not
|
||||
* allocate any for it. '-1' to reduce the sink counter.
|
||||
*/
|
||||
if ((res_alloc->res_reserved + counters_guaranteed) >
|
||||
(dev->caps.max_counters - 1))
|
||||
return 0;
|
||||
|
||||
return counters_guaranteed;
|
||||
}
|
||||
|
||||
int mlx4_init_resource_tracker(struct mlx4_dev *dev)
|
||||
|
@ -484,7 +503,6 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
|
|||
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||
int i, j;
|
||||
int t;
|
||||
int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev);
|
||||
|
||||
priv->mfunc.master.res_tracker.slave_list =
|
||||
kcalloc(dev->num_slaves, sizeof(struct slave_list),
|
||||
|
@ -603,16 +621,8 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
|
|||
break;
|
||||
case RES_COUNTER:
|
||||
res_alloc->quota[t] = dev->caps.max_counters;
|
||||
if (t == mlx4_master_func_num(dev))
|
||||
res_alloc->guaranteed[t] =
|
||||
MLX4_PF_COUNTERS_PER_PORT *
|
||||
MLX4_MAX_PORTS;
|
||||
else if (t <= max_vfs_guarantee_counter)
|
||||
res_alloc->guaranteed[t] =
|
||||
MLX4_VF_COUNTERS_PER_PORT *
|
||||
MLX4_MAX_PORTS;
|
||||
else
|
||||
res_alloc->guaranteed[t] = 0;
|
||||
mlx4_calc_res_counter_guaranteed(dev, res_alloc, t);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue