linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] rdma: Add support to dump SRQ resource in raw format
@ 2023-09-18 13:11 Junxian Huang
  2023-09-19  5:34 ` Mark Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Junxian Huang @ 2023-09-18 13:11 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel, huangjunxian6

From: wenglianfa <wenglianfa@huawei.com>

Add support to dump SRQ resource in raw format.

This patch relies on the corresponding kernel patch:
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/include/uapi/rdma/rdma_netlink.h |  2 ++
 rdma/res-srq.c                        | 17 ++++++++++++++++-
 rdma/res.h                            |  2 ++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/rdma/include/uapi/rdma/rdma_netlink.h b/rdma/include/uapi/rdma/rdma_netlink.h
index 92c528a0..84f775be 100644
--- a/rdma/include/uapi/rdma/rdma_netlink.h
+++ b/rdma/include/uapi/rdma/rdma_netlink.h
@@ -299,6 +299,8 @@ enum rdma_nldev_command {
 
 	RDMA_NLDEV_CMD_STAT_GET_STATUS,
 
+	RDMA_NLDEV_CMD_RES_SRQ_GET_RAW,
+
 	RDMA_NLDEV_NUM_OPS
 };
 
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;
 	}
-- 
2.30.0


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

* Re: [PATCH RFC] rdma: Add support to dump SRQ resource in raw format
  2023-09-18 13:11 [PATCH RFC] rdma: Add support to dump SRQ resource in raw format Junxian Huang
@ 2023-09-19  5:34 ` Mark Zhang
  2023-09-19 10:53   ` Junxian Huang
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Zhang @ 2023-09-19  5:34 UTC (permalink / raw)
  To: Junxian Huang, jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel

On 9/18/2023 9:11 PM, Junxian Huang wrote:
> External email: Use caution opening links or attachments
> 
> 
> From: wenglianfa <wenglianfa@huawei.com>
> 
> Add support to dump SRQ resource in raw format.
> 
> This patch relies on the corresponding kernel patch:
> 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/include/uapi/rdma/rdma_netlink.h |  2 ++
>   rdma/res-srq.c                        | 17 ++++++++++++++++-
>   rdma/res.h                            |  2 ++
>   3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/rdma/include/uapi/rdma/rdma_netlink.h b/rdma/include/uapi/rdma/rdma_netlink.h
> index 92c528a0..84f775be 100644
> --- a/rdma/include/uapi/rdma/rdma_netlink.h
> +++ b/rdma/include/uapi/rdma/rdma_netlink.h
> @@ -299,6 +299,8 @@ enum rdma_nldev_command {
> 
>          RDMA_NLDEV_CMD_STAT_GET_STATUS,
> 
> +       RDMA_NLDEV_CMD_RES_SRQ_GET_RAW,
> +
>          RDMA_NLDEV_NUM_OPS
>   };
> 

Usually this file is submitted as a separate patch.


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

* Re: [PATCH RFC] rdma: Add support to dump SRQ resource in raw format
  2023-09-19  5:34 ` Mark Zhang
@ 2023-09-19 10:53   ` Junxian Huang
  0 siblings, 0 replies; 3+ messages in thread
From: Junxian Huang @ 2023-09-19 10:53 UTC (permalink / raw)
  To: Mark Zhang, jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel



On 2023/9/19 13:34, Mark Zhang wrote:
> On 9/18/2023 9:11 PM, Junxian Huang wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> From: wenglianfa <wenglianfa@huawei.com>
>>
>> Add support to dump SRQ resource in raw format.
>>
>> This patch relies on the corresponding kernel patch:
>> 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/include/uapi/rdma/rdma_netlink.h |  2 ++
>>   rdma/res-srq.c                        | 17 ++++++++++++++++-
>>   rdma/res.h                            |  2 ++
>>   3 files changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/rdma/include/uapi/rdma/rdma_netlink.h b/rdma/include/uapi/rdma/rdma_netlink.h
>> index 92c528a0..84f775be 100644
>> --- a/rdma/include/uapi/rdma/rdma_netlink.h
>> +++ b/rdma/include/uapi/rdma/rdma_netlink.h
>> @@ -299,6 +299,8 @@ enum rdma_nldev_command {
>>
>>          RDMA_NLDEV_CMD_STAT_GET_STATUS,
>>
>> +       RDMA_NLDEV_CMD_RES_SRQ_GET_RAW,
>> +
>>          RDMA_NLDEV_NUM_OPS
>>   };
>>
> 
> Usually this file is submitted as a separate patch.
> 
Thanks. Will fix it in the formal patch.

Junxian

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

end of thread, other threads:[~2023-09-19 10:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-18 13:11 [PATCH RFC] rdma: Add support to dump SRQ resource in raw format Junxian Huang
2023-09-19  5:34 ` Mark Zhang
2023-09-19 10:53   ` Junxian Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).