Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp136060rdb; Mon, 18 Sep 2023 10:13:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFotSaWwdhvXiD+1BfZzb1tKdiJb0iPNxOhsu59ulBEal7kZ7q/Xp4jeAvYyHpsTLI1MnN/ X-Received: by 2002:a17:902:dac7:b0:1bf:4582:90d with SMTP id q7-20020a170902dac700b001bf4582090dmr13630382plx.46.1695057186649; Mon, 18 Sep 2023 10:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695057186; cv=none; d=google.com; s=arc-20160816; b=uYJpAMV2TzA0VJgldmylcplkwP3Rr340fwlMMhuNrq/gkUCEbOiA71vd8RmbSXEepU nsLxMIw6yAtwsQ5QSY/EU/KJle07vHXlf9zy3RZY4uiNaCJguJFLN1xAY179Lxr9GXQI F7SwYj2otakEPKB7CNuhxyik2pVYn0VG0dhMa4XzKDjiO7lH95mknC+6gUKGECA+ujas dIwmL06MHxDfeAe1XB6MYf9uEmUMYmTWk20RirImeclX3WXuyG/xg/WTbX6GZCUDrFqY DdWzmaU7hyrEgGmD+ghIKS6JR11q8qEywHqC4SMQ9lqoJG4C31UdcgPNX5LLJ7D2C27C c4aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=AkXvgDhezODo9SM1OR/TgkR94MVpIkFhMh3C5QIkZf4=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=W6InfhtoPqIYGLaH+KceXPxPMUphw+UzbX6FLiktZcs4L2vP/IbQVAdh+TWwXALUqk SDJNLUD+CvVk9yqq6SxGASEl+68CPPbQim06lroMe78Pu6hqSKA5RKn55J+nrIrR7vNW K8uCKekVgM918yxZPpvAPn7B5owUJRI0NhIsJRjHeYYuY4IthfJILpOQsy4vzkQ0kS4Y QCCa0yC5jHLvq3d0mjOMaKA+MiuXZj7XYXTNZb4PPqB4VXAl/3AQ+B2qj9N2eKoKy/rU n8Dc9xN8kJpUvqXmCOmBC6iO2u7nbzpn4evPuGXqdQ56PFlDuzCivfNcvSJ8os5dVZS2 LV1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id jy3-20020a17090342c300b001b9eb349549si3039726plb.630.2023.09.18.10.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 10:13:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B6FD08027003; Mon, 18 Sep 2023 09:57:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231176AbjIRQ4v (ORCPT + 99 others); Mon, 18 Sep 2023 12:56:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbjIRQ4p (ORCPT ); Mon, 18 Sep 2023 12:56:45 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DA3F9D; Mon, 18 Sep 2023 09:56:39 -0700 (PDT) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Rq4tN1qJgzMl74; Mon, 18 Sep 2023 21:11:08 +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; Mon, 18 Sep 2023 21:14:40 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH RFC] rdma: Add support to dump SRQ resource in raw format Date: Mon, 18 Sep 2023 21:11:40 +0800 Message-ID: <20230918131140.4037213-1-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:57:03 -0700 (PDT) From: wenglianfa 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 --- 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