From: Maor Gottlieb <maorg@xxxxxxxxxxxx> 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@xxxxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- 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