Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3031508rdh; Wed, 27 Sep 2023 23:43:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFK4NTryLj96ozyrPNDVUAf9IFXR9sbDpK/6WjYMnzf844fUHK/kY0L2P83svW4VYMcuWCd X-Received: by 2002:a05:6a20:1046:b0:161:8c5:37f with SMTP id gt6-20020a056a20104600b0016108c5037fmr301242pzc.61.1695883438724; Wed, 27 Sep 2023 23:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695883438; cv=none; d=google.com; s=arc-20160816; b=ow6HUfKjKZExCTUJOIV0I80Oh47t1SphYzrZz6Zej51K5JDfvOrt0enFP5VKpPXlJT psdezsIB//wqv0PwNegPa3bknVVf8migdZrtQUa4gdWdg/1FISPxwUSQA/btdVKbAxi5 2yA5y8T9CERHooUnYjfuVy3XNXUmezl37kZ1LNG7Tas04+SJmpaCEgD8+KHA2PX5kRuf lPqB/iBspedS0jWDnls/74GQugPM439g3jmwAhtvhR+NDO4/4D+tQTAV7rjIoxnFhlqa bPBxnYEctFuklqlk15LWBnj7hws3Yhkh6G8R+TaN/us83Mqpx4NawP3SEuPtXJV2yDJ9 lMwg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zW3/s3yR6S+wd9NeKrS90pvXq0UzEy1WHYyFXwJvSlg=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=V0kTqjd3FoQB88ivcoRyYkFnYykF8XjSkVmhdc7vJBDiBhh+DSpgOpueulWkJdkob3 Kw7pM0EsgmnznHnKlnCehFOkupBhMzI+BCLwB+9Iqgr5NOq/1oiokIGm/HQU80rzGybc /4W+r6UU479xF1ZOb0x4utHGKnOLkiMdiciIfD0eyCcBLe5yICh12zAgsCEjDHtnsT1n UdvuaKIeS7DMVLB80wVzizgqTz5rnM/hJXlSb9+LOsFNhKJKyRxcampoUb3IVx45XR5S ononY6GlT6NW0OLukAGAmQZA+WYTHXQbJbY+oR5kSNXvZlWUZWPP8KIs1Nu5GwQa2igy w3Ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id om6-20020a17090b3a8600b002745c4e215fsi5229515pjb.175.2023.09.27.23.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 23:43:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 7DCEA8070667; Wed, 27 Sep 2023 23:36:14 -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 S230479AbjI1GfT (ORCPT + 99 others); Thu, 28 Sep 2023 02:35:19 -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 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]); Wed, 27 Sep 2023 23:36:14 -0700 (PDT) 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; } -- 2.30.0