|
@@ -48,6 +48,8 @@
|
|
|
#include "fw.h"
|
|
#include "fw.h"
|
|
|
|
|
|
|
|
#define MLX4_MAC_VALID (1ull << 63)
|
|
#define MLX4_MAC_VALID (1ull << 63)
|
|
|
|
|
+#define MLX4_PF_COUNTERS_PER_PORT 2
|
|
|
|
|
+#define MLX4_VF_COUNTERS_PER_PORT 1
|
|
|
|
|
|
|
|
struct mac_res {
|
|
struct mac_res {
|
|
|
struct list_head list;
|
|
struct list_head list;
|
|
@@ -459,11 +461,21 @@ void mlx4_init_quotas(struct mlx4_dev *dev)
|
|
|
dev->quotas.mpt =
|
|
dev->quotas.mpt =
|
|
|
priv->mfunc.master.res_tracker.res_alloc[RES_MPT].quota[pf];
|
|
priv->mfunc.master.res_tracker.res_alloc[RES_MPT].quota[pf];
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+static int get_max_gauranteed_vfs_counter(struct mlx4_dev *dev)
|
|
|
|
|
+{
|
|
|
|
|
+ /* reduce the sink counter */
|
|
|
|
|
+ return (dev->caps.max_counters - 1 -
|
|
|
|
|
+ (MLX4_PF_COUNTERS_PER_PORT * MLX4_MAX_PORTS))
|
|
|
|
|
+ / MLX4_MAX_PORTS;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
int mlx4_init_resource_tracker(struct mlx4_dev *dev)
|
|
int mlx4_init_resource_tracker(struct mlx4_dev *dev)
|
|
|
{
|
|
{
|
|
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
|
|
int i, j;
|
|
int i, j;
|
|
|
int t;
|
|
int t;
|
|
|
|
|
+ int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev);
|
|
|
|
|
|
|
|
priv->mfunc.master.res_tracker.slave_list =
|
|
priv->mfunc.master.res_tracker.slave_list =
|
|
|
kzalloc(dev->num_slaves * sizeof(struct slave_list),
|
|
kzalloc(dev->num_slaves * sizeof(struct slave_list),
|
|
@@ -499,6 +511,9 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
|
|
|
res_alloc->allocated = kzalloc((dev->persist->
|
|
res_alloc->allocated = kzalloc((dev->persist->
|
|
|
num_vfs + 1) *
|
|
num_vfs + 1) *
|
|
|
sizeof(int), GFP_KERNEL);
|
|
sizeof(int), GFP_KERNEL);
|
|
|
|
|
+ /* Reduce the sink counter */
|
|
|
|
|
+ if (i == RES_COUNTER)
|
|
|
|
|
+ res_alloc->res_free = dev->caps.max_counters - 1;
|
|
|
|
|
|
|
|
if (!res_alloc->quota || !res_alloc->guaranteed ||
|
|
if (!res_alloc->quota || !res_alloc->guaranteed ||
|
|
|
!res_alloc->allocated)
|
|
!res_alloc->allocated)
|
|
@@ -577,9 +592,17 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
|
|
|
break;
|
|
break;
|
|
|
case RES_COUNTER:
|
|
case RES_COUNTER:
|
|
|
res_alloc->quota[t] = dev->caps.max_counters;
|
|
res_alloc->quota[t] = dev->caps.max_counters;
|
|
|
- res_alloc->guaranteed[t] = 0;
|
|
|
|
|
if (t == mlx4_master_func_num(dev))
|
|
if (t == mlx4_master_func_num(dev))
|
|
|
- res_alloc->res_free = res_alloc->quota[t];
|
|
|
|
|
|
|
+ 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;
|
|
|
|
|
+ res_alloc->res_free -= res_alloc->guaranteed[t];
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
break;
|
|
break;
|
|
@@ -952,7 +975,7 @@ static struct res_common *alloc_srq_tr(int id)
|
|
|
return &ret->com;
|
|
return &ret->com;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static struct res_common *alloc_counter_tr(int id)
|
|
|
|
|
|
|
+static struct res_common *alloc_counter_tr(int id, int port)
|
|
|
{
|
|
{
|
|
|
struct res_counter *ret;
|
|
struct res_counter *ret;
|
|
|
|
|
|
|
@@ -962,6 +985,7 @@ static struct res_common *alloc_counter_tr(int id)
|
|
|
|
|
|
|
|
ret->com.res_id = id;
|
|
ret->com.res_id = id;
|
|
|
ret->com.state = RES_COUNTER_ALLOCATED;
|
|
ret->com.state = RES_COUNTER_ALLOCATED;
|
|
|
|
|
+ ret->port = port;
|
|
|
|
|
|
|
|
return &ret->com;
|
|
return &ret->com;
|
|
|
}
|
|
}
|
|
@@ -1022,7 +1046,7 @@ static struct res_common *alloc_tr(u64 id, enum mlx4_resource type, int slave,
|
|
|
pr_err("implementation missing\n");
|
|
pr_err("implementation missing\n");
|
|
|
return NULL;
|
|
return NULL;
|
|
|
case RES_COUNTER:
|
|
case RES_COUNTER:
|
|
|
- ret = alloc_counter_tr(id);
|
|
|
|
|
|
|
+ ret = alloc_counter_tr(id, extra);
|
|
|
break;
|
|
break;
|
|
|
case RES_XRCD:
|
|
case RES_XRCD:
|
|
|
ret = alloc_xrcdn_tr(id);
|
|
ret = alloc_xrcdn_tr(id);
|
|
@@ -2335,6 +2359,9 @@ static int counter_free_res(struct mlx4_dev *dev, int slave, int op, int cmd,
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
index = get_param_l(&in_param);
|
|
index = get_param_l(&in_param);
|
|
|
|
|
+ if (index == MLX4_SINK_COUNTER_INDEX(dev))
|
|
|
|
|
+ return 0;
|
|
|
|
|
+
|
|
|
err = rem_res_range(dev, slave, index, 1, RES_COUNTER, 0);
|
|
err = rem_res_range(dev, slave, index, 1, RES_COUNTER, 0);
|
|
|
if (err)
|
|
if (err)
|
|
|
return err;
|
|
return err;
|