From: Or Gerlitz <ogerlitz@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Amir Vadai <amirv@mellanox.com>,
Tal Alon <talal@mellanox.com>,
Hadar Har-Zion <hadarh@mellanox.com>,
Eran Ben Elisha <eranbe@mellanox.com>,
Or Gerlitz <ogerlitz@mellanox.com>
Subject: [PATCH net-next V1 05/13] net/mlx4_core: Adjust counter grant policy in the resource tracker
Date: Mon, 15 Jun 2015 17:59:00 +0300 [thread overview]
Message-ID: <1434380348-19005-6-git-send-email-ogerlitz@mellanox.com> (raw)
In-Reply-To: <1434380348-19005-1-git-send-email-ogerlitz@mellanox.com>
From: Eran Ben Elisha <eranbe@mellanox.com>
Each physical function has a guarantee of two counters per port, one
for a default counter and one for the IB driver.
Each virtual function has a guarantee of one counter per port.
All other counters are free and can be obtained on demand.
This is a preparation step for supporting a get_vf_stats ndo call,
so we can promise a counter for every VF in order to collect their
statistics from the PF context.
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
---
.../net/ethernet/mellanox/mlx4/resource_tracker.c | 35 +++++++++++++++++--
1 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index ab48386..802eb2a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -48,6 +48,8 @@
#include "fw.h"
#define MLX4_MAC_VALID (1ull << 63)
+#define MLX4_PF_COUNTERS_PER_PORT 2
+#define MLX4_VF_COUNTERS_PER_PORT 1
struct mac_res {
struct list_head list;
@@ -459,11 +461,21 @@ void mlx4_init_quotas(struct mlx4_dev *dev)
dev->quotas.mpt =
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)
{
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 =
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->
num_vfs + 1) *
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 ||
!res_alloc->allocated)
@@ -577,9 +592,17 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
break;
case RES_COUNTER:
res_alloc->quota[t] = dev->caps.max_counters;
- res_alloc->guaranteed[t] = 0;
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;
default:
break;
@@ -952,7 +975,7 @@ static struct res_common *alloc_srq_tr(int id)
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;
@@ -962,6 +985,7 @@ static struct res_common *alloc_counter_tr(int id)
ret->com.res_id = id;
ret->com.state = RES_COUNTER_ALLOCATED;
+ ret->port = port;
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");
return NULL;
case RES_COUNTER:
- ret = alloc_counter_tr(id);
+ ret = alloc_counter_tr(id, extra);
break;
case RES_XRCD:
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;
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);
if (err)
return err;
--
1.7.1
next prev parent reply other threads:[~2015-06-15 14:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-15 14:58 [PATCH net-next V1 00/13] mlx4 driver update (+ new VF ndo) Or Gerlitz
2015-06-15 14:58 ` [PATCH net-next V1 01/13] net/mlx4_core: Check before cleaning counters bitmap Or Gerlitz
2015-06-15 14:58 ` [PATCH net-next V1 02/13] net/mlx4_core: Reset counters data when freed Or Gerlitz
2015-06-15 14:58 ` [PATCH net-next V1 03/13] net/mlx4_core: Add sink counter Or Gerlitz
2015-06-15 14:58 ` [PATCH net-next V1 04/13] net/mlx4_core: Remove counters table allocation from VF flow Or Gerlitz
2015-06-15 14:59 ` Or Gerlitz [this message]
2015-06-15 14:59 ` [PATCH net-next V1 06/13] net/mlx4_core: Add port attribute when tracking counters Or Gerlitz
2015-06-15 14:59 ` [PATCH net-next V1 07/13] net/mlx4_core: Allocate default counter per port Or Gerlitz
2015-06-15 14:59 ` [PATCH net-next V1 08/13] IB/mlx4: Add RoCE/IB dedicated counters Or Gerlitz
2015-06-15 14:59 ` [PATCH net-next V1 09/13] IB/mlx4: Set VF to read from QP counters Or Gerlitz
2015-06-15 14:59 ` [PATCH net-next V1 10/13] net/mlx4_core: Add helper to query counters Or Gerlitz
2015-06-15 14:59 ` [PATCH net-next V1 11/13] net/mlx4_en: Show PF own statistics via ethtool Or Gerlitz
2015-06-15 14:59 ` [PATCH net-next V1 12/13] net/core: Add reading VF statistics through the PF netdevice Or Gerlitz
2015-06-15 14:59 ` [PATCH net-next V1 13/13] net/mlx4_en: Support ndo_get_vf_stats Or Gerlitz
2015-06-16 0:23 ` [PATCH net-next V1 00/13] mlx4 driver update (+ new VF ndo) David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434380348-19005-6-git-send-email-ogerlitz@mellanox.com \
--to=ogerlitz@mellanox.com \
--cc=amirv@mellanox.com \
--cc=davem@davemloft.net \
--cc=eranbe@mellanox.com \
--cc=hadarh@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=talal@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).