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: 145788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3113959vqu; Wed, 27 Sep 2023 23:42:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8mgwqHNj+Q8it2DL/RVho+GhbSnaFnwvXMVK6bx3ehEsgL6AkqINfmufNj76pJ4Bozs4n X-Received: by 2002:a17:902:eb44:b0:1c3:8679:6ed4 with SMTP id i4-20020a170902eb4400b001c386796ed4mr319911pli.8.1695883364986; Wed, 27 Sep 2023 23:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695883364; cv=none; d=google.com; s=arc-20160816; b=wh0VoW9lj954i6hsvnBzHgR+8j41sIXK9w6jq6AWGWu2RRLy1Z7xwh2efxD4IG5TTi pplkW//eAlFHWQUr33x0CQ6DpWjXnut1P5gZ0/v1b+1mlbgVDwgwaQxE8+QE6XpO9ZHe +lm1C7s5fgJ+ug5BIQQMtW92U78hhRbrlI65Wu1qoviyuJHaCa+TQ4SGHVFPlh2N/tis 91VGs6efEuLTfCk1M1YBu0XrH8D0gZRitTbdVB+9985vMjEVQ4JLg7mp9qb0MokcUaEa sWCTy3S9IMVtPP1Ow0KpAmEmscDMQNGcI2MpcAutPfErswi9MxuLFhSoyhHyQk1JagUa dd1A== 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 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t4-20020a17090340c400b001c58ac5b753si16740467pld.120.2023.09.27.23.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 23:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 59BEE803FF8B; Wed, 27 Sep 2023 23:35:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbjI1GfT (ORCPT + 20 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 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 27 Sep 2023 23:35:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778262595387680570 X-GMAIL-MSGID: 1778262595387680570 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; }