From: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>,
Mark Bloch <markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Steve Wise <swise-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>,
alonvi-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org
Subject: [PATCH 2/3] mlx4: Add support for protocol statistics
Date: Tue, 15 Mar 2016 10:54:43 -0500 [thread overview]
Message-ID: <20160315155455.282397466@linux.com> (raw)
In-Reply-To: 20160315155441.222586021@linux.com
[-- Attachment #1: mlx4_protocol_stats --]
[-- Type: text/plain, Size: 5368 bytes --]
Add support for basic Infiniband CQ statistics for the mlx4 driver.
This is based on an old approach posted years ago. Maybe Mellanox
can come up with a better one but this shows how it can be implemented
in the mlx4 driver and it works for our needs.
The old patch did only show how to retrieve the counter
values for the device as a whole not for each port. An improvement
would be to add proper support for port based counters.
Signed-off-by: Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
Index: linux/drivers/infiniband/hw/mlx4/main.c
===================================================================
--- linux.orig/drivers/infiniband/hw/mlx4/main.c
+++ linux/drivers/infiniband/hw/mlx4/main.c
@@ -2210,6 +2210,106 @@ static int mlx4_port_immutable(struct ib
return 0;
}
+enum mlx4_diagnostic_counters {
+ MLX4_RQ_NUM_LLE,
+ MLX4_SQ_NUM_LLE,
+ MLX4_RQ_NUM_LQPOE,
+ MLX4_SQ_NUM_LQPOE,
+ MLX4_RQ_NUM_LPE,
+ MLX4_SQ_NUM_LPE,
+ MLX4_RQ_NUM_WRFE,
+ MLX4_SQ_NUM_WRFE,
+ MLX4_SQ_NUM_MWBE,
+ MLX4_SQ_NUM_BRE,
+ MLX4_RQ_NUM_LAE,
+ MLX4_SQ_NUM_RIRE,
+ MLX4_RQ_NUM_RIRE,
+ MLX4_SQ_NUM_RAE,
+ MLX4_RQ_NUM_RAE,
+ MLX4_SQ_NUM_ROE,
+ MLX4_SQ_NUM_TREE,
+ MLX4_SQ_NUM_RREE,
+ MLX4_RQ_NUM_RNR,
+ MLX4_SQ_NUM_RNR,
+ MLX4_RQ_NUM_OOS,
+ MLX4_SQ_NUM_OOS,
+ MLX4_RQ_NUM_MCE,
+ MLX4_RQ_NUM_UDSDPRD,
+ MLX4_RQ_NUM_UCSDPRD,
+ MLX4_NUM_CQOVF,
+ MLX4_NUM_EQOVF,
+ MLX4_NUM_BADDB,
+ MLX4_COUNTERS_NUM,
+};
+
+
+static char *mlx4_counter_names[] = {
+ "rq_num_lle",
+ "sq_num_lle",
+ "rq_num_lqpoe",
+ "sq_num_lqpoe",
+ "rq_num_lpe",
+ "sq_num_lpe",
+ "rq_num_wrfe",
+ "sq_num_wrfe",
+ "sq_num_mwbe",
+ "sq_num_bre",
+ "rq_num_lae",
+ "sq_num_rire",
+ "rq_num_rire",
+ "sq_num_rae",
+ "rq_num_rae",
+ "sq_num_roe",
+ "sq_num_tree",
+ "sq_num_rree",
+ "rq_num_rnr",
+ "sq_num_rnr",
+ "rq_num_oos",
+ "sq_num_oos",
+ "rq_num_mce",
+ "rq_num_udsdprd",
+ "rq_num_ucsdprd",
+ "num_cqovf",
+ "num_eqovf",
+ "num_baddb",
+ NULL
+};
+
+static int offsets[MLX4_COUNTERS_NUM] = {
+ 0x00, 0x04, 0x08, 0x0C, 0x18, 0x1C, 0x20, 0x24,
+ 0x2C, 0x34, 0x38, 0x44, 0x48, 0x4C, 0x50, 0x54,
+ 0x5C, 0x64, 0x68, 0x6C, 0x100, 0x104, 0x108, 0x118,
+ 0x120, 0x1A0, 0x1A4, 0x1A8 };
+
+static int mlx4_ib_show_stats(struct ib_device *ibdev,
+ struct rdma_protocol_stats *stats, u8 port)
+{
+ struct mlx4_ib_dev *dev;
+ int ret;
+
+ stats->name = mlx4_counter_names;
+ stats->dirname = "ib_stats";
+
+ /*
+ * We should be checking for the port here and obtain
+ * port specific counters if possible
+ *
+ * if (port)
+ * { Do port specific things }
+ *
+ */
+
+ dev = to_mdev(ibdev);
+ ret = mlx4_query_diag_counters(dev->dev, 2, offsets, stats->value,
+ MLX4_COUNTERS_NUM);
+ if (ret) {
+ pr_err("%s: failed to read ib counters\n", __func__);
+ return ret;
+ }
+
+ return 0;
+}
+
static void *mlx4_ib_add(struct mlx4_dev *dev)
{
struct mlx4_ib_dev *ibdev;
@@ -2344,6 +2444,7 @@ static void *mlx4_ib_add(struct mlx4_dev
ibdev->ib_dev.process_mad = mlx4_ib_process_mad;
ibdev->ib_dev.get_port_immutable = mlx4_port_immutable;
ibdev->ib_dev.disassociate_ucontext = mlx4_ib_disassociate_ucontext;
+ ibdev->ib_dev.get_protocol_stats = mlx4_ib_show_stats;
if (!mlx4_is_slave(ibdev->dev)) {
ibdev->ib_dev.alloc_fmr = mlx4_ib_fmr_alloc;
Index: linux/drivers/net/ethernet/mellanox/mlx4/fw.c
===================================================================
--- linux.orig/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ linux/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -2453,6 +2453,41 @@ int mlx4_NOP(struct mlx4_dev *dev)
MLX4_CMD_NATIVE);
}
+int mlx4_query_diag_counters(struct mlx4_dev *dev, u8 op_modifier,
+ int *offsets, u64 *values,
+ size_t array_len)
+{
+ struct mlx4_cmd_mailbox *mailbox;
+ u32 *outbox;
+ int ret;
+ int i;
+
+ mailbox = mlx4_alloc_cmd_mailbox(dev);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ outbox = mailbox->buf;
+
+ ret = mlx4_cmd_box(dev, 0, mailbox->dma, 0, op_modifier,
+ MLX4_CMD_DIAG_RPRT, MLX4_CMD_TIME_CLASS_A,
+ MLX4_CMD_NATIVE);
+ if (ret)
+ goto out;
+
+ for (i = 0; i < array_len; i++) {
+ if (offsets[i] > MLX4_MAILBOX_SIZE) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ MLX4_GET(values[i], outbox, offsets[i]);
+ }
+
+out:
+ mlx4_free_cmd_mailbox(dev, mailbox);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(mlx4_query_diag_counters);
+
int mlx4_get_phys_port_id(struct mlx4_dev *dev)
{
u8 port;
Index: linux/include/linux/mlx4/device.h
===================================================================
--- linux.orig/include/linux/mlx4/device.h
+++ linux/include/linux/mlx4/device.h
@@ -1369,6 +1369,8 @@ void mlx4_fmr_unmap(struct mlx4_dev *dev
u32 *lkey, u32 *rkey);
int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr);
int mlx4_SYNC_TPT(struct mlx4_dev *dev);
+int mlx4_query_diag_counters(struct mlx4_dev *dev, u8 op_modifier,
+ int *offsets, u64 *values, size_t array_len);
int mlx4_test_interrupts(struct mlx4_dev *dev);
u32 mlx4_get_eqs_per_port(struct mlx4_dev *dev, u8 port);
bool mlx4_is_eq_vector_valid(struct mlx4_dev *dev, u8 port, int vector);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-03-15 15:54 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-15 15:54 [PATCH 0/3] Dynamically extendable device counter support Christoph Lameter
2016-03-15 15:54 ` [PATCH 1/3] ib core: Make device counter infrastructure dynamic Christoph Lameter
[not found] ` <20160315155455.173645653-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
2016-03-16 15:47 ` Dennis Dalessandro
[not found] ` <20160316154738.GA26530-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2016-03-16 17:17 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1603161213560.15010-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-03-16 17:45 ` Dennis Dalessandro
2016-03-17 7:23 ` Leon Romanovsky
[not found] ` <20160317072354.GB25216-2ukJVAZIZ/Y@public.gmane.org>
2016-03-17 8:17 ` Leon Romanovsky
[not found] ` <20160317081716.GD25216-2ukJVAZIZ/Y@public.gmane.org>
2016-03-18 1:57 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1603172057030.18714-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-03-18 6:20 ` Leon Romanovsky
[not found] ` <20160318062009.GI25216-2ukJVAZIZ/Y@public.gmane.org>
2016-03-18 14:33 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1603180932310.25235-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-03-18 15:51 ` Leon Romanovsky
2016-03-18 1:56 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1603172054540.18714-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-03-18 6:16 ` Leon Romanovsky
[not found] ` <20160318061659.GH25216-2ukJVAZIZ/Y@public.gmane.org>
2016-03-18 14:34 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1603180933320.25235-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-03-18 15:42 ` Leon Romanovsky
2016-05-13 19:18 ` Doug Ledford
[not found] ` <057c8ac8-1d34-e7b9-c0ad-91d805c81139-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-05-16 13:52 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1605160851370.23895-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-05-16 15:43 ` Doug Ledford
[not found] ` <041c6da0-e022-2bd1-5f00-e569c077e154-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-05-16 17:04 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1605161203010.26453-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-05-16 17:27 ` Doug Ledford
[not found] ` <db1bf3dd-20b1-3f2f-eaa3-25e5e8aff35b-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-05-16 17:49 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1605161238560.10085-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-05-16 18:01 ` Doug Ledford
[not found] ` <102cd100-55f7-fa85-cd75-ba0db5b9fa34-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-05-17 14:19 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1605170918080.9956-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-05-17 16:00 ` Doug Ledford
[not found] ` <3e9a3e19-58cb-c25f-89a1-f0e51df562d8-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-05-17 16:06 ` Steve Wise
2016-05-17 17:00 ` Jason Gunthorpe
[not found] ` <20160517170027.GC19976-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-05-17 17:34 ` Doug Ledford
[not found] ` <bc83cc75-aa2e-6fc6-e1c6-a0190b972013-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-05-18 17:25 ` Jason Gunthorpe
[not found] ` <20160518172542.GA15516-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-05-18 18:11 ` Doug Ledford
[not found] ` <12e991bc-aa9b-a8b0-3cd4-b56d58a44d60-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-05-18 18:17 ` Steve Wise
2016-05-18 19:01 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1605181401030.29313-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-05-18 20:27 ` Steve Wise
2016-05-19 14:34 ` Christoph Lameter
2016-05-19 19:24 ` Doug Ledford
2016-05-18 21:11 ` Jason Gunthorpe
2016-05-16 18:06 ` Jason Gunthorpe
2016-05-16 18:27 ` Steve Wise
2016-03-15 15:54 ` Christoph Lameter [this message]
2016-03-15 15:54 ` [PATCH 3/3] mlx5: Implement new counter infrastructure Christoph Lameter
[not found] ` <20160315155455.397561811-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
2016-05-13 19:18 ` Doug Ledford
[not found] ` <d01d42d9-08a8-968a-97f9-40188301170a-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-05-16 13:52 ` Christoph Lameter
[not found] ` <alpine.DEB.2.20.1605160852260.23895-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2016-05-16 15:44 ` Doug Ledford
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=20160315155455.282397466@linux.com \
--to=cl-vytec60ixjuavxtiumwx3w@public.gmane.org \
--cc=alonvi-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=swise-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org \
/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).