linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: David Ahern <dsahern@gmail.com>
Cc: Maor Gottlieb <maorg@mellanox.com>,
	netdev <netdev@vger.kernel.org>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2-next 3/4] rdma: Add support to get CQ in raw format
Date: Wed, 20 May 2020 13:25:38 +0300	[thread overview]
Message-ID: <20200520102539.458983-4-leon@kernel.org> (raw)
In-Reply-To: <20200520102539.458983-1-leon@kernel.org>

From: Maor Gottlieb <maorg@mellanox.com>

Add the required support to print CQ data in raw format.
Example:

$rdma res show cq dev mlx5_2 cqn 1 -r -j
[{"ifindex":8,"ifname":"mlx5_2","cqn":1,"cqe":1023,"users":4,
"poll-ctx":"UNBOUND_WORKQUEUE","adaptive-moderation":"on",
"comm":"ib_core", "data":[0,4,255,254,0,0,0,0,0,0,0,0,16,28,...]}]

Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 rdma/res-cq.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/rdma/res-cq.c b/rdma/res-cq.c
index e1efe3ba..d34b5245 100644
--- a/rdma/res-cq.c
+++ b/rdma/res-cq.c
@@ -39,9 +39,21 @@ static void print_cq_dim_setting(struct rd *rd, struct nlattr *attr)
 	print_on_off(rd, "adaptive-moderation", dim_setting);
 }

+static bool resp_is_valid(struct nlattr **nla_line, bool raw)
+{
+	if (raw)
+		return nla_line[RDMA_NLDEV_ATTR_RES_RAW] ? true : false;
+
+	if (!nla_line[RDMA_NLDEV_ATTR_RES_CQE] ||
+	    !nla_line[RDMA_NLDEV_ATTR_RES_USECNT])
+		return false;
+	return true;
+}
+
 static int res_cq_line(struct rd *rd, const char *name, int idx,
 		       struct nlattr **nla_line)
 {
+	bool raw = rd->show_raw;
 	char *comm = NULL;
 	uint32_t pid = 0;
 	uint8_t poll_ctx = 0;
@@ -50,8 +62,7 @@ static int res_cq_line(struct rd *rd, const char *name, int idx,
 	uint64_t users;
 	uint32_t cqe;

-	if (!nla_line[RDMA_NLDEV_ATTR_RES_CQE] ||
-	    !nla_line[RDMA_NLDEV_ATTR_RES_USECNT])
+	if (!resp_is_valid(nla_line, raw))
 		return MNL_CB_ERROR;

 	cqe = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_CQE]);
@@ -107,6 +118,7 @@ static int res_cq_line(struct rd *rd, const char *name, int idx,
 	print_comm(rd, comm, nla_line);

 	print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
+	print_raw_data(rd, nla_line);
 	newline(rd);

 out:	if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
--
2.26.2


  parent reply	other threads:[~2020-05-21 17:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 10:25 [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool Leon Romanovsky
2020-05-20 10:25 ` [PATCH iproute2-next 1/4] rdma: Refactor res_qp_line Leon Romanovsky
2020-05-20 10:25 ` [PATCH iproute2-next 2/4] rdma: Add support to get QP in raw format Leon Romanovsky
2020-05-20 10:25 ` Leon Romanovsky [this message]
2020-05-20 10:25 ` [PATCH iproute2-next 4/4] rdma: Add support to get MR " Leon Romanovsky
2020-05-27  0:00 ` [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool David Ahern
2020-05-27  2:59   ` Leon Romanovsky
2020-05-27  3:07     ` David Ahern
2020-05-27  4:54       ` 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=20200520102539.458983-4-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maorg@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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).