Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp130145rdb; Mon, 18 Sep 2023 10:03:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyY2koQvEjHngnFUcxG/jVJg4cxLkQmP+pPbkQPjDzDh+YDL+M5iiikfzlxs1WfkFcJYN0 X-Received: by 2002:a17:90a:69a4:b0:274:ea5b:460d with SMTP id s33-20020a17090a69a400b00274ea5b460dmr3233497pjj.41.1695056626222; Mon, 18 Sep 2023 10:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695056626; cv=none; d=google.com; s=arc-20160816; b=rlJio0nJ4vZE/ri7Ff1cMqWQ4ZGCKkTLe+5Wf4216KE+YJw8CcfGzSK+CWtauQYuHn +gx3DtX0Xjhe95/VGedzJKUVs35wM7iBIlaCpEqSbTpj8uptuBFlNiFjrTJhqZ2t0zka FOFQ56r/QxUuHbPcZ6mhIy4fU8rI5e6uPFWd1Dk5ecnIocUzaTDW6b20QoCvZiRZPPbQ eZ5rw2vF17S09LoURsHD/uRWM3n2/2jrxENZWzx1M2eS7oyYIi6rXgITDyZFLVEpF5za fAkH4dTz++V38CrFjM/PjKVH0OKtYdP0HVGv3cUpE7wpeCwEVcwopLShCK1KpElAoYCq gOVA== 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=0uraEnRcYBszbvbEEzgumPxPMJOwp0+93r1NRAM2fVY=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=JrMkoSf1cSqZEQ7IQlgpCx/ripBCJ1bah9/0/ixxo/sNuZxecA43wE1YQMGUGP/q+k JgH3rIJ48fS81YW9616QUuMSfW/I8J0Zhrpk9nU3yktz7wsGoKiQ87MuflJnVb1+0DUb fkL8HIxz4h3GZ3gDiMUaMSrrqgfNnOEWd94sSxcP18wVu1I0ET1UKjHO1IOQtoVzgaot 5rc2Y2bSAXxP7pxYCDoeEiNGWeTexQNvMAhlxvCUAE7cIw+ROxIbOj1lyD8KaTX3jWV8 tumG5Th3VRj9jDyDAOHt2Ig86ecXRSZfB2IQxIlT7FDL/haDAWWwwjmfugA2n8AESLgV Q9nA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id rm9-20020a17090b3ec900b00267b910cb37si8685681pjb.52.2023.09.18.10.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 10:03:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id CA35C809924E; Mon, 18 Sep 2023 09:57:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbjIRQ4s (ORCPT + 99 others); Mon, 18 Sep 2023 12:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbjIRQ4q (ORCPT ); Mon, 18 Sep 2023 12:56:46 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD343AC; Mon, 18 Sep 2023 09:56:39 -0700 (PDT) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Rq4sq3Nk8zMl6t; Mon, 18 Sep 2023 21:10:39 +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:12 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH RFC for-next 2/3] RDMA/core: Add support to dump SRQ resource in RAW format Date: Mon, 18 Sep 2023 21:11:09 +0800 Message-ID: <20230918131110.3987498-3-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230918131110.3987498-1-huangjunxian6@hisilicon.com> References: <20230918131110.3987498-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: dggems704-chm.china.huawei.com (10.3.19.181) 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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:57:04 -0700 (PDT) From: wenglianfa Add support to dump SRQ resource in raw format. It enable drivers to return the entire device specific SRQ context without setting each field separately. 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 --- drivers/infiniband/core/device.c | 1 + drivers/infiniband/core/nldev.c | 17 +++++++++++++++++ include/rdma/ib_verbs.h | 1 + include/uapi/rdma/rdma_netlink.h | 2 ++ 4 files changed, 21 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 05b37050e842..0cb5459d2c6c 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2652,6 +2652,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) SET_DEVICE_OP(dev_ops, fill_res_qp_entry); SET_DEVICE_OP(dev_ops, fill_res_qp_entry_raw); SET_DEVICE_OP(dev_ops, fill_res_srq_entry); + SET_DEVICE_OP(dev_ops, fill_res_srq_entry_raw); SET_DEVICE_OP(dev_ops, fill_stat_mr_entry); SET_DEVICE_OP(dev_ops, get_dev_fw_str); SET_DEVICE_OP(dev_ops, get_dma_mr); diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c index bebe6adeb533..456545007c14 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -850,6 +850,17 @@ static int fill_res_srq_entry(struct sk_buff *msg, bool has_cap_net_admin, return -EMSGSIZE; } +static int fill_res_srq_raw_entry(struct sk_buff *msg, bool has_cap_net_admin, + struct rdma_restrack_entry *res, uint32_t port) +{ + struct ib_srq *srq = container_of(res, struct ib_srq, res); + struct ib_device *dev = srq->device; + + if (!dev->ops.fill_res_srq_entry_raw) + return -EINVAL; + return dev->ops.fill_res_srq_entry_raw(msg, srq); +} + static int fill_stat_counter_mode(struct sk_buff *msg, struct rdma_counter *counter) { @@ -1659,6 +1670,7 @@ RES_GET_FUNCS(mr_raw, RDMA_RESTRACK_MR); RES_GET_FUNCS(counter, RDMA_RESTRACK_COUNTER); RES_GET_FUNCS(ctx, RDMA_RESTRACK_CTX); RES_GET_FUNCS(srq, RDMA_RESTRACK_SRQ); +RES_GET_FUNCS(srq_raw, RDMA_RESTRACK_SRQ); static LIST_HEAD(link_ops); static DECLARE_RWSEM(link_ops_rwsem); @@ -2564,6 +2576,11 @@ static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = { .dump = nldev_res_get_mr_raw_dumpit, .flags = RDMA_NL_ADMIN_PERM, }, + [RDMA_NLDEV_CMD_RES_SRQ_GET_RAW] = { + .doit = nldev_res_get_srq_raw_doit, + .dump = nldev_res_get_srq_raw_dumpit, + .flags = RDMA_NL_ADMIN_PERM, + }, [RDMA_NLDEV_CMD_STAT_GET_STATUS] = { .doit = nldev_stat_get_counter_status_doit, }, diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 3cbb6141a9ce..e36c0d9aad27 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2609,6 +2609,7 @@ struct ib_device_ops { int (*fill_res_qp_entry_raw)(struct sk_buff *msg, struct ib_qp *ibqp); int (*fill_res_cm_id_entry)(struct sk_buff *msg, struct rdma_cm_id *id); int (*fill_res_srq_entry)(struct sk_buff *msg, struct ib_srq *ib_srq); + int (*fill_res_srq_entry_raw)(struct sk_buff *msg, struct ib_srq *ib_srq); /* Device lifecycle callbacks */ /* diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h index e50c357367db..2830695c3556 100644 --- a/include/uapi/rdma/rdma_netlink.h +++ b/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 }; -- 2.30.0