Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8E01C433ED for ; Tue, 18 May 2021 02:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D7A9613BA for ; Tue, 18 May 2021 02:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239555AbhERCCB convert rfc822-to-8bit (ORCPT ); Mon, 17 May 2021 22:02:01 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:2959 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235741AbhERCCB (ORCPT ); Mon, 17 May 2021 22:02:01 -0400 Received: from dggems704-chm.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FkfKK37rQzCtJH; Tue, 18 May 2021 09:57:57 +0800 (CST) Received: from dggpeml100023.china.huawei.com (7.185.36.151) by dggems704-chm.china.huawei.com (10.3.19.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 18 May 2021 10:00:42 +0800 Received: from dggema753-chm.china.huawei.com (10.1.198.195) by dggpeml100023.china.huawei.com (7.185.36.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Tue, 18 May 2021 10:00:42 +0800 Received: from dggema753-chm.china.huawei.com ([10.9.48.84]) by dggema753-chm.china.huawei.com ([10.9.48.84]) with mapi id 15.01.2176.012; Tue, 18 May 2021 10:00:42 +0800 From: liweihang To: Leon Romanovsky CC: "dledford@redhat.com" , "jgg@nvidia.com" , "linux-rdma@vger.kernel.org" , Linuxarm , "wangxi (M)" Subject: Re: [PATCH for-next 1/7] RDMA/hns: Introduce DCA for RC QP Thread-Topic: [PATCH for-next 1/7] RDMA/hns: Introduce DCA for RC QP Thread-Index: AQHXRZr4v1t5v7kOE0qVw3PCypfZYA== Date: Tue, 18 May 2021 02:00:42 +0000 Message-ID: <8b8bec1cb505477aa22cc36d317a8433@huawei.com> References: <1620650889-61650-1-git-send-email-liweihang@huawei.com> <1620650889-61650-2-git-send-email-liweihang@huawei.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.100.165] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On 2021/5/17 15:28, Leon Romanovsky wrote: > On Mon, May 10, 2021 at 08:48:03PM +0800, Weihang Li wrote: >> From: Xi Wang >> >> The hip09 introduces the DCA(Dynamic context attachment) feature which >> supports many RC QPs to share the WQE buffer in a memory pool, this will >> reduce the memory consumption when there are too many QPs are inactive. >> >> If a QP enables DCA feature, the WQE's buffer will not be allocated when >> creating. But when the users start to post WRs, the hns driver will >> allocate a buffer from the memory pool and then fill WQEs which tagged with >> this QP's number. >> >> The hns ROCEE will stop accessing the WQE buffer when the user polled all >> of the CQEs for a DCA QP, then the driver will recycle this WQE's buffer >> to the memory pool. >> >> This patch adds a group of methods to support the user space register >> buffers to a memory pool which belongs to the user context. The hns kernel >> driver will update the pages state in this pool when the user calling the >> post/poll methods and the user driver can get the QP's WQE buffer address >> by the key and offset which queried from kernel. >> >> Signed-off-by: Xi Wang >> Signed-off-by: Weihang Li >> --- >> drivers/infiniband/hw/hns/Makefile | 2 +- >> drivers/infiniband/hw/hns/hns_roce_dca.c | 381 ++++++++++++++++++++++++++++ >> drivers/infiniband/hw/hns/hns_roce_dca.h | 22 ++ >> drivers/infiniband/hw/hns/hns_roce_device.h | 9 + >> drivers/infiniband/hw/hns/hns_roce_main.c | 27 +- >> include/uapi/rdma/hns-abi.h | 27 ++ >> 6 files changed, 465 insertions(+), 3 deletions(-) >> create mode 100644 drivers/infiniband/hw/hns/hns_roce_dca.c >> create mode 100644 drivers/infiniband/hw/hns/hns_roce_dca.h >> >> diff --git a/drivers/infiniband/hw/hns/Makefile b/drivers/infiniband/hw/hns/Makefile >> index e105945..9962b23 100644 >> --- a/drivers/infiniband/hw/hns/Makefile >> +++ b/drivers/infiniband/hw/hns/Makefile >> @@ -6,7 +6,7 @@ >> ccflags-y := -I $(srctree)/drivers/net/ethernet/hisilicon/hns3 >> >> hns-roce-objs := hns_roce_main.o hns_roce_cmd.o hns_roce_pd.o \ >> - hns_roce_ah.o hns_roce_hem.o hns_roce_mr.o hns_roce_qp.o \ >> + hns_roce_ah.o hns_roce_hem.o hns_roce_mr.o hns_roce_qp.o hns_roce_dca.o \ >> hns_roce_cq.o hns_roce_alloc.o hns_roce_db.o hns_roce_srq.o hns_roce_restrack.o >> >> ifdef CONFIG_INFINIBAND_HNS_HIP06 >> diff --git a/drivers/infiniband/hw/hns/hns_roce_dca.c b/drivers/infiniband/hw/hns/hns_roce_dca.c >> new file mode 100644 >> index 0000000..2a03cf3 >> --- /dev/null >> +++ b/drivers/infiniband/hw/hns/hns_roce_dca.c >> @@ -0,0 +1,381 @@ >> +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB >> +/* >> + * Copyright (c) 2021 Hisilicon Limited. All rights reserved. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include "hns_roce_device.h" >> +#include "hns_roce_dca.h" >> + >> +#define UVERBS_MODULE_NAME hns_ib >> +#include >> + >> +/* DCA memory */ >> +struct dca_mem { >> +#define DCA_MEM_FLAGS_ALLOCED BIT(0) >> +#define DCA_MEM_FLAGS_REGISTERED BIT(1) >> + u32 flags; >> + struct list_head list; /* link to mem list in dca context */ >> + spinlock_t lock; /* protect the @flags and @list */ >> + int page_count; /* page count in this mem obj */ >> + u64 key; /* register by caller */ >> + u32 size; /* bytes in this mem object */ >> + struct hns_dca_page_state *states; /* record each page's state */ >> + void *pages; /* memory handle for getting dma address */ >> +}; >> + >> +struct dca_mem_attr { >> + u64 key; >> + u64 addr; >> + u32 size; >> +}; >> + >> +static inline bool dca_mem_is_free(struct dca_mem *mem) >> +{ >> + return mem->flags == 0; >> +} >> + >> +static inline void set_dca_mem_free(struct dca_mem *mem) >> +{ >> + mem->flags = 0; >> +} >> + >> +static inline void set_dca_mem_alloced(struct dca_mem *mem) >> +{ >> + mem->flags |= DCA_MEM_FLAGS_ALLOCED; >> +} >> + >> +static inline void set_dca_mem_registered(struct dca_mem *mem) >> +{ >> + mem->flags |= DCA_MEM_FLAGS_REGISTERED; >> +} >> + >> +static inline void clr_dca_mem_registered(struct dca_mem *mem) >> +{ >> + mem->flags &= ~DCA_MEM_FLAGS_REGISTERED; >> +} >> + >> +static void free_dca_pages(void *pages) >> +{ >> + ib_umem_release(pages); >> +} > > All this oneline madness should go. > > Thanks > Sure, thanks. Weihang