From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
RDMA mailing list <linux-rdma@vger.kernel.org>,
Boris Pismenny <borisp@mellanox.com>,
Matan Barak <matanb@mellanox.com>,
Raed Salem <raeds@mellanox.com>,
Yishai Hadas <yishaih@mellanox.com>,
Saeed Mahameed <saeedm@mellanox.com>,
linux-netdev <netdev@vger.kernel.org>
Subject: [PATCH rdma-next v1 13/13] IB/mlx5: Add counters read support
Date: Sun, 27 May 2018 13:23:46 +0300 [thread overview]
Message-ID: <20180527102346.15149-14-leon@kernel.org> (raw)
In-Reply-To: <20180527102346.15149-1-leon@kernel.org>
From: Raed Salem <raeds@mellanox.com>
This patch implements the uverbs counters read API, it will use the
specific read counters function to the given type to accomplish its
task.
Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Raed Salem <raeds@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/hw/mlx5/main.c | 44 +++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 2044d9f69a83..ef688a265d47 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -5316,6 +5316,49 @@ static void depopulate_specs_root(struct mlx5_ib_dev *dev)
uverbs_free_spec_tree(dev->ib_dev.specs_root);
}
+static int mlx5_ib_read_counters(struct ib_counters *counters,
+ struct ib_counters_read_attr *read_attr,
+ struct uverbs_attr_bundle *attrs)
+{
+ struct mlx5_ib_mcounters *mcounters = to_mcounters(counters);
+ struct mlx5_read_counters_attr mread_attr = {};
+ u32 *desc;
+ int ret, i;
+
+ mutex_lock(&mcounters->mcntrs_mutex);
+ if (mcounters->cntrs_max_index > read_attr->ncounters) {
+ ret = -EINVAL;
+ goto err_bound;
+ }
+
+ mread_attr.out = kcalloc(mcounters->counters_num, sizeof(u64),
+ GFP_KERNEL);
+ if (!mread_attr.out) {
+ ret = -ENOMEM;
+ goto err_bound;
+ }
+
+ mread_attr.hw_cntrs_hndl = mcounters->hw_cntrs_hndl;
+ mread_attr.flags = read_attr->flags;
+ ret = mcounters->read_counters(counters->device, &mread_attr);
+ if (ret)
+ goto err_read;
+
+ /*
+ * We pass over the counters data array to assign according
+ * to the descriptions and indexing pairs.
+ */
+ desc = mcounters->counters_data;
+ for (i = 0; i < mcounters->ncounters * 2; i += 2)
+ read_attr->counters_buff[desc[i+1]] += mread_attr.out[desc[i]];
+
+err_read:
+ kfree(mread_attr.out);
+err_bound:
+ mutex_unlock(&mcounters->mcntrs_mutex);
+ return ret;
+}
+
static int mlx5_ib_destroy_counters(struct ib_counters *counters)
{
struct mlx5_ib_mcounters *mcounters = to_mcounters(counters);
@@ -5589,6 +5632,7 @@ int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
dev->ib_dev.driver_id = RDMA_DRIVER_MLX5;
dev->ib_dev.create_counters = mlx5_ib_create_counters;
dev->ib_dev.destroy_counters = mlx5_ib_destroy_counters;
+ dev->ib_dev.read_counters = mlx5_ib_read_counters;
err = init_node_data(dev);
if (err)
--
2.14.3
next prev parent reply other threads:[~2018-05-27 10:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-27 10:23 [PATCH rdma-next v1 00/13] Verbs flow counters support Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 01/13] IB/uverbs: Add an ib_uobject getter to ioctl() infrastructure Leon Romanovsky
2018-05-27 10:23 ` [PATCH mlx5-next v1 02/13] net/mlx5: Export flow counter related API Leon Romanovsky
2018-05-28 8:34 ` Or Gerlitz
2018-05-28 9:16 ` Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 03/13] IB/core: Introduce counters object and its create/destroy Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 04/13] IB/uverbs: Add create/destroy counters support Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 05/13] IB/core: Introduce counters read verb Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 06/13] IB/uverbs: Add read counters support Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 07/13] IB/core: Support passing uhw for create_flow Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 08/13] IB/core: Add support for flow counters Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 09/13] IB/uverbs: " Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 10/13] IB/mlx5: Add counters create and destroy support Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 11/13] IB/mlx5: Add flow counters binding support Leon Romanovsky
2018-05-28 17:27 ` Jason Gunthorpe
2018-05-29 7:11 ` Leon Romanovsky
2018-05-27 10:23 ` [PATCH rdma-next v1 12/13] IB/mlx5: Add flow counters read support Leon Romanovsky
2018-05-27 10:23 ` Leon Romanovsky [this message]
2018-05-27 16:22 ` [PATCH rdma-next v1 00/13] Verbs flow counters support Leon Romanovsky
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=20180527102346.15149-14-leon@kernel.org \
--to=leon@kernel.org \
--cc=borisp@mellanox.com \
--cc=dledford@redhat.com \
--cc=jgg@mellanox.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=matanb@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=raeds@mellanox.com \
--cc=saeedm@mellanox.com \
--cc=yishaih@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).