diff mbox series

[iproute2-next,2/2] rdma: Add support to dump SRQ resource in raw format

Message ID 20231007035855.2273364-3-huangjunxian6@hisilicon.com (mailing list archive)
State Superseded
Headers show
Series rdma: Support dumping SRQ resource in raw format | expand

Commit Message

Junxian Huang Oct. 7, 2023, 3:58 a.m. UTC
From: wenglianfa <wenglianfa@huawei.com>

Add support to dump SRQ resource in raw format.

This patch relies on the corresponding kernel commit aebf8145e11a
("RDMA/core: Add support to dump SRQ resource in RAW format")

Example:
$ rdma res show srq -r
dev hns3 149000...

$ rdma res show srq -j -r
[{"ifindex":0,"ifname":"hns3","data":[149,0,0,...]}]

Signed-off-by: wenglianfa <wenglianfa@huawei.com>
---
 rdma/res-srq.c | 17 ++++++++++++++++-
 rdma/res.h     |  2 ++
 2 files changed, 18 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky Oct. 9, 2023, 8:44 a.m. UTC | #1
On Sat, Oct 07, 2023 at 11:58:55AM +0800, Junxian Huang wrote:
> From: wenglianfa <wenglianfa@huawei.com>
> 
> Add support to dump SRQ resource in raw format.
> 
> This patch relies on the corresponding kernel commit aebf8145e11a
> ("RDMA/core: Add support to dump SRQ resource in RAW format")
> 
> Example:
> $ rdma res show srq -r
> dev hns3 149000...
> 
> $ rdma res show srq -j -r
> [{"ifindex":0,"ifname":"hns3","data":[149,0,0,...]}]
> 
> Signed-off-by: wenglianfa <wenglianfa@huawei.com>
> ---
>  rdma/res-srq.c | 17 ++++++++++++++++-
>  rdma/res.h     |  2 ++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/rdma/res-srq.c b/rdma/res-srq.c
> index 186ae281..d2581a3f 100644
> --- a/rdma/res-srq.c
> +++ b/rdma/res-srq.c
> @@ -162,6 +162,20 @@ out:
>  	return -EINVAL;
>  }

<...>

>  static int res_srq_line(struct rd *rd, const char *name, int idx,
>  			struct nlattr **nla_line)
>  {
> @@ -276,7 +290,8 @@ int res_srq_parse_cb(const struct nlmsghdr *nlh, void *data)
>  		if (ret != MNL_CB_OK)
>  			break;
>  
> -		ret = res_srq_line(rd, name, idx, nla_line);
> +		ret = (rd->show_raw) ? res_srq_line_raw(rd, name, idx, nla_line) :
> +		       res_srq_line(rd, name, idx, nla_line);

You are missing same change in res_srq_idx_parse_cb(), see commit e2bbf737e61b ("rdma: Add support to get MR in raw format")
as an example.

Thanks

>  		if (ret != MNL_CB_OK)
>  			break;
>  	}
> diff --git a/rdma/res.h b/rdma/res.h
> index 70e51acd..e880c28b 100644
> --- a/rdma/res.h
> +++ b/rdma/res.h
> @@ -39,6 +39,8 @@ static inline uint32_t res_get_command(uint32_t command, struct rd *rd)
>  		return RDMA_NLDEV_CMD_RES_CQ_GET_RAW;
>  	case RDMA_NLDEV_CMD_RES_MR_GET:
>  		return RDMA_NLDEV_CMD_RES_MR_GET_RAW;
> +	case RDMA_NLDEV_CMD_RES_SRQ_GET:
> +		return RDMA_NLDEV_CMD_RES_SRQ_GET_RAW;
>  	default:
>  		return command;
>  	}
> -- 
> 2.30.0
>
diff mbox series

Patch

diff --git a/rdma/res-srq.c b/rdma/res-srq.c
index 186ae281..d2581a3f 100644
--- a/rdma/res-srq.c
+++ b/rdma/res-srq.c
@@ -162,6 +162,20 @@  out:
 	return -EINVAL;
 }
 
+static int res_srq_line_raw(struct rd *rd, const char *name, int idx,
+			    struct nlattr **nla_line)
+{
+	if (!nla_line[RDMA_NLDEV_ATTR_RES_RAW])
+		return MNL_CB_ERROR;
+
+	open_json_object(NULL);
+	print_dev(rd, idx, name);
+	print_raw_data(rd, nla_line);
+	newline(rd);
+
+	return MNL_CB_OK;
+}
+
 static int res_srq_line(struct rd *rd, const char *name, int idx,
 			struct nlattr **nla_line)
 {
@@ -276,7 +290,8 @@  int res_srq_parse_cb(const struct nlmsghdr *nlh, void *data)
 		if (ret != MNL_CB_OK)
 			break;
 
-		ret = res_srq_line(rd, name, idx, nla_line);
+		ret = (rd->show_raw) ? res_srq_line_raw(rd, name, idx, nla_line) :
+		       res_srq_line(rd, name, idx, nla_line);
 		if (ret != MNL_CB_OK)
 			break;
 	}
diff --git a/rdma/res.h b/rdma/res.h
index 70e51acd..e880c28b 100644
--- a/rdma/res.h
+++ b/rdma/res.h
@@ -39,6 +39,8 @@  static inline uint32_t res_get_command(uint32_t command, struct rd *rd)
 		return RDMA_NLDEV_CMD_RES_CQ_GET_RAW;
 	case RDMA_NLDEV_CMD_RES_MR_GET:
 		return RDMA_NLDEV_CMD_RES_MR_GET_RAW;
+	case RDMA_NLDEV_CMD_RES_SRQ_GET:
+		return RDMA_NLDEV_CMD_RES_SRQ_GET_RAW;
 	default:
 		return command;
 	}