All of lore.kernel.org
 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 4/4] rdma: Add support to get MR in raw format
Date: Wed, 20 May 2020 13:25:39 +0300	[thread overview]
Message-ID: <20200520102539.458983-5-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 MR data in raw format.
Example:

$rdma res show mr dev mlx5_1 mrn 2 -r -j
[{"ifindex":7,"ifname":"mlx5_1","mrn":2,"mrlen":4096,"pdn":5, pid":24336,
"comm":"ibv_rc_pingpong","data":[0,4,255,254,0,0,0,0,0,0,0,0,16,28,0,216,...]}]

Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 rdma/res-mr.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/rdma/res-mr.c b/rdma/res-mr.c
index c1366035..b6e0a6a9 100644
--- a/rdma/res-mr.c
+++ b/rdma/res-mr.c
@@ -7,17 +7,27 @@
 #include "res.h"
 #include <inttypes.h>

+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_MRLEN])
+		return MNL_CB_ERROR;
+	return true;
+}
+
 static int res_mr_line(struct rd *rd, const char *name, int idx,
 		       struct nlattr **nla_line)
 {
 	uint32_t rkey = 0, lkey = 0;
 	uint64_t iova = 0, mrlen;
+	bool raw = rd->show_raw;
 	char *comm = NULL;
 	uint32_t pdn = 0;
 	uint32_t mrn = 0;
 	uint32_t pid = 0;

-	if (!nla_line[RDMA_NLDEV_ATTR_RES_MRLEN])
+	if (!resp_is_valid(nla_line, raw))
 		return MNL_CB_ERROR;

 	if (nla_line[RDMA_NLDEV_ATTR_RES_RKEY])
@@ -69,6 +79,7 @@ static int res_mr_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:
--
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 ` [PATCH iproute2-next 3/4] rdma: Add support to get CQ " Leon Romanovsky
2020-05-20 10:25 ` Leon Romanovsky [this message]
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-5-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.