Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool
@ 2020-05-20 10:25 Leon Romanovsky
  2020-05-20 10:25 ` [PATCH iproute2-next 1/4] rdma: Refactor res_qp_line Leon Romanovsky
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Leon Romanovsky @ 2020-05-20 10:25 UTC (permalink / raw)
  To: David Ahern; +Cc: Leon Romanovsky, netdev, RDMA mailing list, Stephen Hemminger

From: Leon Romanovsky <leonro@mellanox.com>

Hi,

The following series adds support to get the RDMA resource data in RAW
format. The main motivation for doing this is to enable vendors to
return the entire QP/CQ/MR data without a need from the vendor to set
each field separately.

User-space part of the kernel series [1].

Thanks

[1] https://lore.kernel.org/linux-rdma/20200513095034.208385-1-leon@kernel.org

Maor Gottlieb (4):
  rdma: Refactor res_qp_line
  rdma: Add support to get QP in raw format
  rdma: Add support to get CQ in raw format
  rdma: Add support to get MR in raw format

 man/man8/rdma-resource.8 |   5 ++
 man/man8/rdma.8          |   4 ++
 rdma/rdma.c              |   8 ++-
 rdma/rdma.h              |   7 +-
 rdma/res-cq.c            |  16 ++++-
 rdma/res-mr.c            |  13 +++-
 rdma/res-qp.c            | 139 ++++++++++++++++++++++++++-------------
 rdma/res.c               |   1 +
 rdma/utils.c             |  20 ++++++
 9 files changed, 163 insertions(+), 50 deletions(-)

--
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH iproute2-next 1/4] rdma: Refactor res_qp_line
  2020-05-20 10:25 [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool Leon Romanovsky
@ 2020-05-20 10:25 ` Leon Romanovsky
  2020-05-20 10:25 ` [PATCH iproute2-next 2/4] rdma: Add support to get QP in raw format Leon Romanovsky
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2020-05-20 10:25 UTC (permalink / raw)
  To: David Ahern; +Cc: Maor Gottlieb, netdev, RDMA mailing list, Stephen Hemminger

From: Maor Gottlieb <maorg@mellanox.com>

Downstream patch adds the support to get the QP data in raw format.
Move the unshared code to function.

Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 rdma/res-qp.c | 114 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 69 insertions(+), 45 deletions(-)

diff --git a/rdma/res-qp.c b/rdma/res-qp.c
index 801cfca9..b36b7289 100644
--- a/rdma/res-qp.c
+++ b/rdma/res-qp.c
@@ -64,54 +64,53 @@ static void print_pathmig(struct rd *rd, uint32_t val, struct nlattr **nla_line)
 			   "path-mig-state %s ", path_mig_to_str(val));
 }

-static int res_qp_line(struct rd *rd, const char *name, int idx,
-		       struct nlattr **nla_line)
+struct res_qp_info {
+	uint32_t lqpn;
+	uint32_t port;
+	uint32_t pid;
+	char *comm;
+};
+
+static bool resp_is_valid(struct nlattr **nla_line)
 {
-	uint32_t lqpn, rqpn = 0, rq_psn = 0, sq_psn;
-	uint8_t type, state, path_mig_state = 0;
-	uint32_t port = 0, pid = 0;
-	uint32_t pdn = 0;
-	char *comm = NULL;
-
 	if (!nla_line[RDMA_NLDEV_ATTR_RES_LQPN] ||
 	    !nla_line[RDMA_NLDEV_ATTR_RES_SQ_PSN] ||
 	    !nla_line[RDMA_NLDEV_ATTR_RES_TYPE] ||
 	    !nla_line[RDMA_NLDEV_ATTR_RES_STATE])
-		return MNL_CB_ERROR;
-
-	if (nla_line[RDMA_NLDEV_ATTR_PORT_INDEX])
-		port = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_PORT_INDEX]);
-
-	if (port != rd->port_idx)
-		goto out;
+		return false;
+	return true;
+}

-	lqpn = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_LQPN]);
-	if (rd_is_filtered_attr(rd, "lqpn", lqpn,
-				nla_line[RDMA_NLDEV_ATTR_RES_LQPN]))
-		goto out;
+static void res_qp_line_query(struct rd *rd, const char *name, int idx,
+			      struct nlattr **nla_line,
+			      struct res_qp_info *info)
+{
+	uint8_t type, state, path_mig_state = 0;
+	uint32_t rqpn = 0, rq_psn = 0, sq_psn;
+	uint32_t pdn = 0;

 	if (nla_line[RDMA_NLDEV_ATTR_RES_PDN])
 		pdn = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
 	if (rd_is_filtered_attr(rd, "pdn", pdn,
 				nla_line[RDMA_NLDEV_ATTR_RES_PDN]))
-		goto out;
+		return;

 	if (nla_line[RDMA_NLDEV_ATTR_RES_RQPN])
 		rqpn = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_RQPN]);
 	if (rd_is_filtered_attr(rd, "rqpn", rqpn,
 				nla_line[RDMA_NLDEV_ATTR_RES_RQPN]))
-		goto out;
+		return;

 	if (nla_line[RDMA_NLDEV_ATTR_RES_RQ_PSN])
 		rq_psn = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_RQ_PSN]);
 	if (rd_is_filtered_attr(rd, "rq-psn", rq_psn,
 				nla_line[RDMA_NLDEV_ATTR_RES_RQ_PSN]))
-		goto out;
+		return;

 	sq_psn = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_SQ_PSN]);
 	if (rd_is_filtered_attr(rd, "sq-psn", sq_psn,
 				nla_line[RDMA_NLDEV_ATTR_RES_SQ_PSN]))
-		goto out;
+		return;

 	if (nla_line[RDMA_NLDEV_ATTR_RES_PATH_MIG_STATE])
 		path_mig_state = mnl_attr_get_u8(
@@ -119,35 +118,22 @@ static int res_qp_line(struct rd *rd, const char *name, int idx,
 	if (rd_is_string_filtered_attr(
 		    rd, "path-mig-state", path_mig_to_str(path_mig_state),
 		    nla_line[RDMA_NLDEV_ATTR_RES_PATH_MIG_STATE]))
-		goto out;
+		return;

 	type = mnl_attr_get_u8(nla_line[RDMA_NLDEV_ATTR_RES_TYPE]);
 	if (rd_is_string_filtered_attr(rd, "type", qp_types_to_str(type),
 				       nla_line[RDMA_NLDEV_ATTR_RES_TYPE]))
-		goto out;
+		return;

 	state = mnl_attr_get_u8(nla_line[RDMA_NLDEV_ATTR_RES_STATE]);
 	if (rd_is_string_filtered_attr(rd, "state", qp_states_to_str(state),
 				       nla_line[RDMA_NLDEV_ATTR_RES_STATE]))
-		goto out;
-
-	if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
-		pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
-		comm = get_task_name(pid);
-	}
-
-	if (rd_is_filtered_attr(rd, "pid", pid,
-				nla_line[RDMA_NLDEV_ATTR_RES_PID]))
-		goto out;
-
-	if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
-		/* discard const from mnl_attr_get_str */
-		comm = (char *)mnl_attr_get_str(
-			nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
+		return;

 	open_json_object(NULL);
-	print_link(rd, idx, name, port, nla_line);
-	res_print_uint(rd, "lqpn", lqpn, nla_line[RDMA_NLDEV_ATTR_RES_LQPN]);
+	print_link(rd, idx, name, info->port, nla_line);
+	res_print_uint(rd, "lqpn", info->lqpn,
+		       nla_line[RDMA_NLDEV_ATTR_RES_LQPN]);
 	print_rqpn(rd, rqpn, nla_line);

 	print_type(rd, type);
@@ -159,14 +145,52 @@ static int res_qp_line(struct rd *rd, const char *name, int idx,

 	print_pathmig(rd, path_mig_state, nla_line);
 	res_print_uint(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
-	res_print_uint(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
-	print_comm(rd, comm, nla_line);
+	res_print_uint(rd, "pid", info->pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+	print_comm(rd, info->comm, nla_line);

 	print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
 	newline(rd);
+}
+
+static int res_qp_line(struct rd *rd, const char *name, int idx,
+		       struct nlattr **nla_line)
+{
+	struct res_qp_info info = {};
+
+	if (!resp_is_valid(nla_line))
+		return MNL_CB_ERROR;
+
+	if (nla_line[RDMA_NLDEV_ATTR_PORT_INDEX])
+		info.port =
+			mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_PORT_INDEX]);
+
+	if (info.port != rd->port_idx)
+		goto out;
+
+	info.lqpn = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_LQPN]);
+	if (rd_is_filtered_attr(rd, "lqpn", info.lqpn,
+				nla_line[RDMA_NLDEV_ATTR_RES_LQPN]))
+		goto out;
+
+	if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
+		info.pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+		info.comm = get_task_name(info.pid);
+	}
+
+	if (rd_is_filtered_attr(rd, "pid", info.pid,
+				nla_line[RDMA_NLDEV_ATTR_RES_PID]))
+		goto out;
+
+	if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
+		struct nlattr *line = nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME];
+		/* discard const from mnl_attr_get_str */
+		info.comm = (char *)mnl_attr_get_str(line);
+	}
+
+	res_qp_line_query(rd, name, idx, nla_line, &info);
 out:
 	if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
-		free(comm);
+		free(info.comm);
 	return MNL_CB_OK;
 }

--
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH iproute2-next 2/4] rdma: Add support to get QP in raw format
  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 ` Leon Romanovsky
  2020-05-20 10:25 ` [PATCH iproute2-next 3/4] rdma: Add support to get CQ " Leon Romanovsky
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2020-05-20 10:25 UTC (permalink / raw)
  To: David Ahern; +Cc: Maor Gottlieb, netdev, RDMA mailing list, Stephen Hemminger

From: Maor Gottlieb <maorg@mellanox.com>

Add 'raw' argument to get the resource in raw format.
When RDMA_NLDEV_ATTR_RES_RAW is set in the netlink message,
then the resource fields are in raw format, print it as byte array.

Example:
$rdma res show qp link rocep0s12f0/1 lqpn 1137 -j -r
[{"ifindex":7,"ifname":"mlx5_1","port":1,"lqpn":265,"pid":24336
"comm":"ibv_rc_pingpong","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...]}]

Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 man/man8/rdma-resource.8 |  5 +++++
 man/man8/rdma.8          |  4 ++++
 rdma/rdma.c              |  8 +++++++-
 rdma/rdma.h              |  7 +++++--
 rdma/res-qp.c            | 37 ++++++++++++++++++++++++++++++++-----
 rdma/res.c               |  1 +
 rdma/utils.c             | 20 ++++++++++++++++++++
 7 files changed, 74 insertions(+), 8 deletions(-)

diff --git a/man/man8/rdma-resource.8 b/man/man8/rdma-resource.8
index 05030d0a..8d0d14c6 100644
--- a/man/man8/rdma-resource.8
+++ b/man/man8/rdma-resource.8
@@ -83,6 +83,11 @@ rdma res show qp link mlx5_4/1 lqpn 0-6
 Limit to specific Local QPNs.
 .RE
 .PP
+rdma res show qp link mlx5_4/1 lqpn 6 -r
+.RS 4
+Driver specific details in raw format.
+.RE
+.PP
 rdma resource show cm_id dst-port 7174
 .RS 4
 Show CM_IDs with destination ip port of 7174.
diff --git a/man/man8/rdma.8 b/man/man8/rdma.8
index 221bf334..c9e5d50d 100644
--- a/man/man8/rdma.8
+++ b/man/man8/rdma.8
@@ -51,6 +51,10 @@ If there were any errors during execution of the commands, the application retur
 .BR "\-d" , " --details"
 Output detailed information.  Adding a second \-d includes driver-specific details.

+.TP
+.BR "\-r" , " --raw"
+Output includes driver-specific details in raw format.
+
 .TP
 .BR "\-p" , " --pretty"
 When combined with -j generate a pretty JSON output.
diff --git a/rdma/rdma.c b/rdma/rdma.c
index 22050555..19fadeb5 100644
--- a/rdma/rdma.c
+++ b/rdma/rdma.c
@@ -112,6 +112,7 @@ int main(int argc, char **argv)
 		{ "json",		no_argument,		NULL, 'j' },
 		{ "pretty",		no_argument,		NULL, 'p' },
 		{ "details",		no_argument,		NULL, 'd' },
+		{ "raw",		no_argument,		NULL, 'r' },
 		{ "force",		no_argument,		NULL, 'f' },
 		{ "batch",		required_argument,	NULL, 'b' },
 		{ NULL, 0, NULL, 0 }
@@ -120,6 +121,7 @@ int main(int argc, char **argv)
 	const char *batch_file = NULL;
 	bool show_details = false;
 	bool json_output = false;
+	bool show_raw = false;
 	bool force = false;
 	struct rd rd = {};
 	char *filename;
@@ -127,7 +129,7 @@ int main(int argc, char **argv)
 	int err;
 	filename = basename(argv[0]);

-	while ((opt = getopt_long(argc, argv, ":Vhdpjfb:",
+	while ((opt = getopt_long(argc, argv, ":Vhdrpjfb:",
 				  long_options, NULL)) >= 0) {
 		switch (opt) {
 		case 'V':
@@ -143,6 +145,9 @@ int main(int argc, char **argv)
 			else
 				show_details = true;
 			break;
+		case 'r':
+			show_raw = true;
+			break;
 		case 'j':
 			json_output = 1;
 			break;
@@ -172,6 +177,7 @@ int main(int argc, char **argv)
 	rd.show_driver_details = show_driver_details;
 	rd.json_output = json_output;
 	rd.pretty_output = pretty;
+	rd.show_raw = show_raw;

 	err = rd_init(&rd, filename);
 	if (err)
diff --git a/rdma/rdma.h b/rdma/rdma.h
index 735b1bf7..a6c6bdea 100644
--- a/rdma/rdma.h
+++ b/rdma/rdma.h
@@ -57,8 +57,9 @@ struct rd {
 	int argc;
 	char **argv;
 	char *filename;
-	bool show_details;
-	bool show_driver_details;
+	uint8_t show_details:1;
+	uint8_t show_driver_details:1;
+	uint8_t show_raw:1;
 	struct list_head dev_map_list;
 	uint32_t dev_idx;
 	uint32_t port_idx;
@@ -134,9 +135,11 @@ int rd_attr_check(const struct nlattr *attr, int *typep);
  * Print helpers
  */
 void print_driver_table(struct rd *rd, struct nlattr *tb);
+void print_raw_data(struct rd *rd, struct nlattr **nla_line);
 void newline(struct rd *rd);
 void newline_indent(struct rd *rd);
 void print_on_off(struct rd *rd, const char *key_str, bool on);
+void print_raw_data(struct rd *rd, struct nlattr **nla_line);
 #define MAX_LINE_LENGTH 80

 #endif /* _RDMA_TOOL_H_ */
diff --git a/rdma/res-qp.c b/rdma/res-qp.c
index b36b7289..f5e36439 100644
--- a/rdma/res-qp.c
+++ b/rdma/res-qp.c
@@ -71,16 +71,38 @@ struct res_qp_info {
 	char *comm;
 };

-static bool resp_is_valid(struct nlattr **nla_line)
+static bool resp_is_valid(struct nlattr **nla_line, bool raw)
 {
-	if (!nla_line[RDMA_NLDEV_ATTR_RES_LQPN] ||
-	    !nla_line[RDMA_NLDEV_ATTR_RES_SQ_PSN] ||
+	if (!nla_line[RDMA_NLDEV_ATTR_RES_LQPN])
+		return false;
+
+	if (raw)
+		return nla_line[RDMA_NLDEV_ATTR_RES_RAW] ? true : false;
+
+	if (!nla_line[RDMA_NLDEV_ATTR_RES_SQ_PSN] ||
 	    !nla_line[RDMA_NLDEV_ATTR_RES_TYPE] ||
 	    !nla_line[RDMA_NLDEV_ATTR_RES_STATE])
 		return false;
+
 	return true;
 }

+static void res_qp_line_raw(struct rd *rd, const char *name, int idx,
+			    struct nlattr **nla_line,
+			    struct res_qp_info *info)
+{
+	open_json_object(NULL);
+	print_link(rd, idx, name, info->port, nla_line);
+	res_print_uint(rd, "lqpn", info->lqpn,
+		       nla_line[RDMA_NLDEV_ATTR_RES_LQPN]);
+
+	res_print_uint(rd, "pid", info->pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+	print_comm(rd, info->comm, nla_line);
+
+	print_raw_data(rd, nla_line);
+	newline(rd);
+}
+
 static void res_qp_line_query(struct rd *rd, const char *name, int idx,
 			      struct nlattr **nla_line,
 			      struct res_qp_info *info)
@@ -156,8 +178,9 @@ static int res_qp_line(struct rd *rd, const char *name, int idx,
 		       struct nlattr **nla_line)
 {
 	struct res_qp_info info = {};
+	bool raw = rd->show_raw;

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

 	if (nla_line[RDMA_NLDEV_ATTR_PORT_INDEX])
@@ -187,7 +210,11 @@ static int res_qp_line(struct rd *rd, const char *name, int idx,
 		info.comm = (char *)mnl_attr_get_str(line);
 	}

-	res_qp_line_query(rd, name, idx, nla_line, &info);
+	if (raw)
+		res_qp_line_raw(rd, name, idx, nla_line, &info);
+	else
+		res_qp_line_query(rd, name, idx, nla_line, &info);
+
 out:
 	if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
 		free(info.comm);
diff --git a/rdma/res.c b/rdma/res.c
index 251f5041..759a1151 100644
--- a/rdma/res.c
+++ b/rdma/res.c
@@ -97,6 +97,7 @@ int _res_send_idx_msg(struct rd *rd, uint32_t command, mnl_cb_t callback,

 	mnl_attr_put_u32(rd->nlh, id, idx);

+	mnl_attr_put_u8(rd->nlh, RDMA_NLDEV_ATTR_RES_RAW, rd->show_raw);
 	if (command == RDMA_NLDEV_CMD_STAT_GET)
 		mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_STAT_RES,
 				 RDMA_NLDEV_ATTR_RES_MR);
diff --git a/rdma/utils.c b/rdma/utils.c
index e25c3adf..4d3de4fa 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -450,6 +450,7 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
 	[RDMA_NLDEV_ATTR_STAT_RES] = MNL_TYPE_U32,
 	[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK] = MNL_TYPE_U32,
 	[RDMA_NLDEV_ATTR_DEV_DIM] = MNL_TYPE_U8,
+	[RDMA_NLDEV_ATTR_RES_RAW] = MNL_TYPE_BINARY,
 };

 int rd_attr_check(const struct nlattr *attr, int *typep)
@@ -890,6 +891,25 @@ static int print_driver_entry(struct rd *rd, struct nlattr *key_attr,
 	return ret;
 }

+void print_raw_data(struct rd *rd, struct nlattr **nla_line)
+{
+	uint8_t *data;
+	uint32_t len;
+	int i = 0;
+
+	if (!rd->show_raw)
+		return;
+
+	len = mnl_attr_get_payload_len(nla_line[RDMA_NLDEV_ATTR_RES_RAW]);
+	data = mnl_attr_get_payload(nla_line[RDMA_NLDEV_ATTR_RES_RAW]);
+	open_json_array(PRINT_JSON, "data");
+	while (i < len) {
+		print_color_uint(PRINT_ANY, COLOR_NONE, NULL, "%d", data[i]);
+		i++;
+	}
+	close_json_array(PRINT_ANY, ">");
+}
+
 void print_driver_table(struct rd *rd, struct nlattr *tb)
 {
 	int print_type = RDMA_NLDEV_PRINT_TYPE_UNSPEC;
--
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH iproute2-next 3/4] rdma: Add support to get CQ in raw format
  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
  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
  4 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2020-05-20 10:25 UTC (permalink / raw)
  To: David Ahern; +Cc: Maor Gottlieb, netdev, RDMA mailing list, Stephen Hemminger

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH iproute2-next 4/4] rdma: Add support to get MR in raw format
  2020-05-20 10:25 [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool Leon Romanovsky
                   ` (2 preceding siblings ...)
  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
  2020-05-27  0:00 ` [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool David Ahern
  4 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2020-05-20 10:25 UTC (permalink / raw)
  To: David Ahern; +Cc: Maor Gottlieb, netdev, RDMA mailing list, Stephen Hemminger

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool
  2020-05-20 10:25 [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool Leon Romanovsky
                   ` (3 preceding siblings ...)
  2020-05-20 10:25 ` [PATCH iproute2-next 4/4] rdma: Add support to get MR " Leon Romanovsky
@ 2020-05-27  0:00 ` David Ahern
  2020-05-27  2:59   ` Leon Romanovsky
  4 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2020-05-27  0:00 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Leon Romanovsky, netdev, RDMA mailing list, Stephen Hemminger

On 5/20/20 4:25 AM, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
> 
> Hi,
> 
> The following series adds support to get the RDMA resource data in RAW
> format. The main motivation for doing this is to enable vendors to
> return the entire QP/CQ/MR data without a need from the vendor to set
> each field separately.
> 
> User-space part of the kernel series [1].
> 
> Thanks
> 
> [1] https://lore.kernel.org/linux-rdma/20200513095034.208385-1-leon@kernel.org
> 
> Maor Gottlieb (4):
>   rdma: Refactor res_qp_line
>   rdma: Add support to get QP in raw format
>   rdma: Add support to get CQ in raw format
>   rdma: Add support to get MR in raw format
> 

The set depends on UAPI files not visible in either Dave or Linus' tree
yet. We moved rdma uapi files under rdma/include/uapi/ and as I recall
the expectation is that you submit updates with your patches once they
are accepted and that the headers are in sync with Linus' tree once the
code arrives there.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Leon Romanovsky @ 2020-05-27  2:59 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, RDMA mailing list, Stephen Hemminger

On Tue, May 26, 2020 at 06:00:17PM -0600, David Ahern wrote:
> On 5/20/20 4:25 AM, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@mellanox.com>
> >
> > Hi,
> >
> > The following series adds support to get the RDMA resource data in RAW
> > format. The main motivation for doing this is to enable vendors to
> > return the entire QP/CQ/MR data without a need from the vendor to set
> > each field separately.
> >
> > User-space part of the kernel series [1].
> >
> > Thanks
> >
> > [1] https://lore.kernel.org/linux-rdma/20200513095034.208385-1-leon@kernel.org
> >
> > Maor Gottlieb (4):
> >   rdma: Refactor res_qp_line
> >   rdma: Add support to get QP in raw format
> >   rdma: Add support to get CQ in raw format
> >   rdma: Add support to get MR in raw format
> >
>
> The set depends on UAPI files not visible in either Dave or Linus' tree
> yet. We moved rdma uapi files under rdma/include/uapi/ and as I recall
> the expectation is that you submit updates with your patches once they
> are accepted and that the headers are in sync with Linus' tree once the
> code arrives there.

Yes, you remember correctly.

What should I write in the series to make it clear that the patches
need to be reviewed but not merged yet due to on-going kernel
submission?

We are not merging any code in RDMA that doesn't have corresponding
parts in iproute2 or rdma-core.

Thanks

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool
  2020-05-27  2:59   ` Leon Romanovsky
@ 2020-05-27  3:07     ` David Ahern
  2020-05-27  4:54       ` Leon Romanovsky
  0 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2020-05-27  3:07 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: netdev, RDMA mailing list, Stephen Hemminger

On 5/26/20 8:59 PM, Leon Romanovsky wrote:
> 
> Yes, you remember correctly.
> 
> What should I write in the series to make it clear that the patches
> need to be reviewed but not merged yet due to on-going kernel
> submission?
> 
> We are not merging any code in RDMA that doesn't have corresponding
> parts in iproute2 or rdma-core.
> 
> Thanks
> 


Let's stick with labeling iproute2 patches RFC until they are ready to
be committed.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next 0/4] RAW format dumps through RDMAtool
  2020-05-27  3:07     ` David Ahern
@ 2020-05-27  4:54       ` Leon Romanovsky
  0 siblings, 0 replies; 9+ messages in thread
From: Leon Romanovsky @ 2020-05-27  4:54 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, RDMA mailing list, Stephen Hemminger

On Tue, May 26, 2020 at 09:07:34PM -0600, David Ahern wrote:
> On 5/26/20 8:59 PM, Leon Romanovsky wrote:
> >
> > Yes, you remember correctly.
> >
> > What should I write in the series to make it clear that the patches
> > need to be reviewed but not merged yet due to on-going kernel
> > submission?
> >
> > We are not merging any code in RDMA that doesn't have corresponding
> > parts in iproute2 or rdma-core.
> >
> > Thanks
> >
>
>
> Let's stick with labeling iproute2 patches RFC until they are ready to
> be committed.

Thanks, I'll do.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git