diff mbox series

[iproute2-next,4/4] rdma: Add support to get MR in raw format

Message ID 20200520102539.458983-5-leon@kernel.org
State RFC
Delegated to: David Ahern
Headers show
Series RAW format dumps through RDMAtool | expand

Commit Message

Leon Romanovsky May 20, 2020, 10:25 a.m. UTC
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(-)

--
2.26.2
diff mbox series

Patch

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: