From patchwork Wed Jun 8 06:44:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 9163385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 26C9060832 for ; Wed, 8 Jun 2016 06:39:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1851428389 for ; Wed, 8 Jun 2016 06:39:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D49928390; Wed, 8 Jun 2016 06:39:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ECF928389 for ; Wed, 8 Jun 2016 06:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753762AbcFHGjA (ORCPT ); Wed, 8 Jun 2016 02:39:00 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:10764 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754901AbcFHGcw (ORCPT ); Wed, 8 Jun 2016 02:32:52 -0400 Received: from 172.24.1.36 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.36]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DIJ01428; Wed, 08 Jun 2016 14:32:37 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Wed, 8 Jun 2016 14:32:23 +0800 From: Lijun Ou To: , , , , , , CC: , , , , , , , , , , , Subject: [RESEND PATCH v9 11/22] IB/hns: Add IB device registration Date: Wed, 8 Jun 2016 14:44:46 +0800 Message-ID: <1465368297-82118-12-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465368297-82118-1-git-send-email-oulijun@huawei.com> References: <1465368297-82118-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090206.5757BC0B.005C, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 60a202bcbb1d4dd9955ecb8d75b4f9f1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch registered IB device when loaded, and unregistered IB device when removed. Signed-off-by: Wei Hu Signed-off-by: Nenglong Zhao Signed-off-by: Lijun Ou --- drivers/infiniband/hw/hns/hns_roce_main.c | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 7fb0d34..f179a7f 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -62,6 +62,41 @@ #include "hns_roce_device.h" #include "hns_roce_icm.h" +void hns_roce_unregister_device(struct hns_roce_dev *hr_dev) +{ + ib_unregister_device(&hr_dev->ib_dev); +} + +int hns_roce_register_device(struct hns_roce_dev *hr_dev) +{ + int ret; + struct hns_roce_ib_iboe *iboe = NULL; + struct ib_device *ib_dev = NULL; + struct device *dev = &hr_dev->pdev->dev; + + iboe = &hr_dev->iboe; + + ib_dev = &hr_dev->ib_dev; + strlcpy(ib_dev->name, "hisi_%d", IB_DEVICE_NAME_MAX); + + ib_dev->owner = THIS_MODULE; + ib_dev->node_type = RDMA_NODE_IB_CA; + ib_dev->dma_device = dev; + + ib_dev->phys_port_cnt = hr_dev->caps.num_ports; + ib_dev->local_dma_lkey = hr_dev->caps.reserved_lkey; + ib_dev->num_comp_vectors = hr_dev->caps.num_comp_vectors; + ib_dev->uverbs_abi_ver = 1; + + ret = ib_register_device(ib_dev, NULL); + if (ret) { + dev_err(dev, "ib_register_device failed!\n"); + return ret; + } + + return 0; +} + int hns_roce_get_cfg(struct hns_roce_dev *hr_dev) { int i; @@ -363,6 +398,17 @@ static int hns_roce_probe(struct platform_device *pdev) goto error_failed_engine_init; } + ret = hns_roce_register_device(hr_dev); + if (ret) { + dev_err(dev, "register_device failed!\n"); + goto error_failed_register_device; + } + + return 0; + +error_failed_register_device: + hns_roce_engine_exit(hr_dev); + error_failed_engine_init: hns_roce_cleanup_bitmap(hr_dev);