From patchwork Thu Sep 28 06:32:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 13402052 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F565CE7B00 for ; Thu, 28 Sep 2023 06:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbjI1GfN (ORCPT ); Thu, 28 Sep 2023 02:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230284AbjI1GfM (ORCPT ); Thu, 28 Sep 2023 02:35:12 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87EBA99; Wed, 27 Sep 2023 23:35:10 -0700 (PDT) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Rx3ZC4ZRyzrT7c; Thu, 28 Sep 2023 14:32:51 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 28 Sep 2023 14:35:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH 1/2] rdma: Update uapi headers Date: Thu, 28 Sep 2023 14:32:01 +0800 Message-ID: <20230928063202.1435527-2-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230928063202.1435527-1-huangjunxian6@hisilicon.com> References: <20230928063202.1435527-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Update rdma_netlink.h file upto kernel commit aebf8145e11a ("RDMA/core: Add support to dump SRQ resource in RAW format") Signed-off-by: wenglianfa Signed-off-by: Junxian Huang --- rdma/include/uapi/rdma/rdma_netlink.h | 2 ++ 1 file changed, 2 insertions(+) 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 }; From patchwork Thu Sep 28 06:32:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 13402053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBEC5CE7B01 for ; Thu, 28 Sep 2023 06:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbjI1GfO (ORCPT ); Thu, 28 Sep 2023 02:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230347AbjI1GfN (ORCPT ); Thu, 28 Sep 2023 02:35:13 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7E8AA3; Wed, 27 Sep 2023 23:35:10 -0700 (PDT) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rx3XQ66kCzNnts; Thu, 28 Sep 2023 14:31:18 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 28 Sep 2023 14:35:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH 2/2] rdma: Add support to dump SRQ resource in raw format Date: Thu, 28 Sep 2023 14:32:02 +0800 Message-ID: <20230928063202.1435527-3-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230928063202.1435527-1-huangjunxian6@hisilicon.com> References: <20230928063202.1435527-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: wenglianfa 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 --- 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_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; }