From patchwork Mon Sep 18 13:11:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 141485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2817973vqi; Mon, 18 Sep 2023 10:13:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG97Sa4WU7HrtHOlnJMAdMiXgxng1AT+qRRg8mNRQhyVFiJhEWqUf0Efi2VZh7nCAsDsssF X-Received: by 2002:a05:6a21:3282:b0:141:69d:8041 with SMTP id yt2-20020a056a21328200b00141069d8041mr13308415pzb.48.1695057220451; Mon, 18 Sep 2023 10:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695057220; cv=none; d=google.com; s=arc-20160816; b=f6d2hU3pne57TmsabVN8zbSfhKGyudlUw33tdc/H9WkiuMwm8d+rn5VAeDGGwwoSZ+ WbJ0q7i/m5UNqCd3AlVZW123XLmQ/LlNnHKSFJxVtr2GtZOF1JcKfWCo/PQCmZCGeT5Q cM7aOlmH0MMejrLu1soDVC9+DVjwfnnFJxLyON01OZXLx7AVTmxuEVZHBN06jskviPgo q5ey92FTjZlpx3hJDhfLT/TxHaNdyWlTG+SF0FJLCLQPEyY8n8NSHikfZ19tmRNGcy6C 4caJ4IdUxyBvnZmBzb+BbcRxhS5UHqgQQhuGdiyAGs8E9DwHf994GTijWoIPmeDs4XLl 4KXQ== 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 Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id z3-20020a633303000000b00573f9d916fbsi8227433pgz.784.2023.09.18.10.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 10:13:40 -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 BE8858028FF9; Mon, 18 Sep 2023 09:57:27 -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 S231194AbjIRQ4v (ORCPT + 25 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 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:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777396319648438763 X-GMAIL-MSGID: 1777396319648438763 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; }