From patchwork Mon Nov 5 11:35:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10667891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35CDE15A6 for ; Mon, 5 Nov 2018 11:36:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23F7628DB6 for ; Mon, 5 Nov 2018 11:36:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17D2129789; Mon, 5 Nov 2018 11:36:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 8CA9428DB6 for ; Mon, 5 Nov 2018 11:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728215AbeKEUzU (ORCPT ); Mon, 5 Nov 2018 15:55:20 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33267 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728245AbeKEUzU (ORCPT ); Mon, 5 Nov 2018 15:55:20 -0500 Received: by mail-wr1-f65.google.com with SMTP id u1-v6so9142571wrn.0 for ; Mon, 05 Nov 2018 03:36:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Nv3Bo7szsUBBJIr4eV579jM+pJpXIMbJzJySYUbVf+c=; b=uBQF2TRoz/GHUHi6gbyN1qxq0k7QKz1VbkWsjNRnvG4PRgg2cSo20gjPvnzIA4DIn9 iG6gtSbD9P/SgHy5HDGnt9sLOsJPHFl3iaVBcryOZI5xiuBfQdzAU4EkeelvtaP7iVdi QhuerjPhMOnx7Oj1uB6DBtbRpi/FcG51qgpmv19J3IT8cRXbeyWJgAwCbHnuQy8l/qLt HTHr6daO76ky11mutN4s8iRFTSU5NXk0nANcCT1/KGTPJyNScm3e8E8+M3tchLtSo5Im Lz6f4o4aCpKOMWd0zNQZ6tcbRSnIDGceiti+Gimf6oDLTWvxKsEgCDn2ggC4aDtNu5+2 Vv4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Nv3Bo7szsUBBJIr4eV579jM+pJpXIMbJzJySYUbVf+c=; b=oVc4/ra6SM0H6MwuPeA3o4UnmFje1q6uXh8X1mL4FMBTKPZd5/Vb06xg/ENVUgYttb iat/HUvKBVxWoWWzbGt00CknfD/JmRH99D7NQ8B3Ey9tHruY13XShBxjYpT1KtDYLPXU FTW6R/H2i5Z/hCRObPkze/Br8MzQX/d/I4H14kkidXkQZGl7mFgaSXKuc31AxXwZ5oej LmsLPecaCxYUYmRjBLVhx0R45jrCCosuRI4w2irP9fLBaTsk/V4nE97F3P5E9FOybvbF qnZHO3k4pI9ReVXgrXi8brJCkn70WsWKIzVvwj1Obu0CVnoYg+k7sRMwO2D5UzKgmE3y En9g== X-Gm-Message-State: AGRZ1gIEpirh2qDnZ5F5avs0GviGQkNJsBDMwgdsaC3gducNWA80pqTC rBVTUoQZXYP5F8c7PGFgE7w= X-Google-Smtp-Source: AJdET5dcu+qJtKX2c2pIfYHOr3sQcI/Qpi5+3Y7OcqpgnjDO/Ns29Ab7bvKW18d2IxE5HP1qZhuH9Q== X-Received: by 2002:adf:a492:: with SMTP id g18-v6mr20331376wrb.167.1541417761101; Mon, 05 Nov 2018 03:36:01 -0800 (PST) Received: from kheib-workstation.redhat.com ([192.116.94.216]) by smtp.gmail.com with ESMTPSA id z18-v6sm10762147wru.83.2018.11.05.03.35.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Nov 2018 03:36:00 -0800 (PST) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, kamalheib1@gmail.com Subject: [PATCH rdma-next v3 13/20] RDMA/qedr: Initialize ib_device_ops struct Date: Mon, 5 Nov 2018 13:35:21 +0200 Message-Id: <20181105113528.8317-14-kamalheib1@gmail.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181105113528.8317-1-kamalheib1@gmail.com> References: <20181105113528.8317-1-kamalheib1@gmail.com> 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 Initialize ib_device_ops with the supported operations using ib_set_device_ops(). Signed-off-by: Kamal Heib --- drivers/infiniband/hw/qedr/main.c | 114 +++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 51 deletions(-) diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c index 8d6ff9df49fe..137b0bedb2db 100644 --- a/drivers/infiniband/hw/qedr/main.c +++ b/drivers/infiniband/hw/qedr/main.c @@ -160,12 +160,16 @@ static const struct attribute_group qedr_attr_group = { .attrs = qedr_attributes, }; +static const struct ib_device_ops qedr_iw_dev_ops = { + .query_gid = qedr_iw_query_gid, + .get_port_immutable = qedr_iw_port_immutable, +}; + static int qedr_iw_register_device(struct qedr_dev *dev) { dev->ibdev.node_type = RDMA_NODE_RNIC; - dev->ibdev.query_gid = qedr_iw_query_gid; - dev->ibdev.get_port_immutable = qedr_iw_port_immutable; + ib_set_device_ops(&dev->ibdev, &qedr_iw_dev_ops); dev->ibdev.iwcm = kzalloc(sizeof(*dev->ibdev.iwcm), GFP_KERNEL); if (!dev->ibdev.iwcm) @@ -186,13 +190,67 @@ static int qedr_iw_register_device(struct qedr_dev *dev) return 0; } +static const struct ib_device_ops qedr_roce_dev_ops = { + .get_port_immutable = qedr_roce_port_immutable, +}; + static void qedr_roce_register_device(struct qedr_dev *dev) { dev->ibdev.node_type = RDMA_NODE_IB_CA; - dev->ibdev.get_port_immutable = qedr_roce_port_immutable; + ib_set_device_ops(&dev->ibdev, &qedr_roce_dev_ops); } +static const struct ib_device_ops qedr_dev_ops = { + /* Device operations */ + .query_device = qedr_query_device, + .get_dev_fw_str = qedr_get_dev_fw_str, + /* Port operations */ + .query_port = qedr_query_port, + .modify_port = qedr_modify_port, + .get_netdev = qedr_get_netdev, + .get_link_layer = qedr_link_layer, + /* Ucontext operations */ + .alloc_ucontext = qedr_alloc_ucontext, + .dealloc_ucontext = qedr_dealloc_ucontext, + .mmap = qedr_mmap, + /* PD operations */ + .alloc_pd = qedr_alloc_pd, + .dealloc_pd = qedr_dealloc_pd, + /* CQ operations */ + .create_cq = qedr_create_cq, + .destroy_cq = qedr_destroy_cq, + .resize_cq = qedr_resize_cq, + .req_notify_cq = qedr_arm_cq, + .poll_cq = qedr_poll_cq, + /* QP operations */ + .create_qp = qedr_create_qp, + .modify_qp = qedr_modify_qp, + .query_qp = qedr_query_qp, + .destroy_qp = qedr_destroy_qp, + .post_send = qedr_post_send, + .post_recv = qedr_post_recv, + /* SRQ operations */ + .create_srq = qedr_create_srq, + .destroy_srq = qedr_destroy_srq, + .modify_srq = qedr_modify_srq, + .query_srq = qedr_query_srq, + .post_srq_recv = qedr_post_srq_recv, + /* PKey operations */ + .query_pkey = qedr_query_pkey, + /* AH operations */ + .create_ah = qedr_create_ah, + .destroy_ah = qedr_destroy_ah, + /* MR operations */ + .get_dma_mr = qedr_get_dma_mr, + .dereg_mr = qedr_dereg_mr, + .reg_user_mr = qedr_reg_user_mr, + .alloc_mr = qedr_alloc_mr, + .map_mr_sg = qedr_map_mr_sg, + /* MAD operations */ + .process_mad = qedr_process_mad, +}; + static int qedr_register_device(struct qedr_dev *dev) { int rc; @@ -237,57 +295,11 @@ static int qedr_register_device(struct qedr_dev *dev) dev->ibdev.phys_port_cnt = 1; dev->ibdev.num_comp_vectors = dev->num_cnq; - - dev->ibdev.query_device = qedr_query_device; - dev->ibdev.query_port = qedr_query_port; - dev->ibdev.modify_port = qedr_modify_port; - - dev->ibdev.alloc_ucontext = qedr_alloc_ucontext; - dev->ibdev.dealloc_ucontext = qedr_dealloc_ucontext; - dev->ibdev.mmap = qedr_mmap; - - dev->ibdev.alloc_pd = qedr_alloc_pd; - dev->ibdev.dealloc_pd = qedr_dealloc_pd; - - dev->ibdev.create_cq = qedr_create_cq; - dev->ibdev.destroy_cq = qedr_destroy_cq; - dev->ibdev.resize_cq = qedr_resize_cq; - dev->ibdev.req_notify_cq = qedr_arm_cq; - - dev->ibdev.create_qp = qedr_create_qp; - dev->ibdev.modify_qp = qedr_modify_qp; - dev->ibdev.query_qp = qedr_query_qp; - dev->ibdev.destroy_qp = qedr_destroy_qp; - - dev->ibdev.create_srq = qedr_create_srq; - dev->ibdev.destroy_srq = qedr_destroy_srq; - dev->ibdev.modify_srq = qedr_modify_srq; - dev->ibdev.query_srq = qedr_query_srq; - dev->ibdev.post_srq_recv = qedr_post_srq_recv; - dev->ibdev.query_pkey = qedr_query_pkey; - - dev->ibdev.create_ah = qedr_create_ah; - dev->ibdev.destroy_ah = qedr_destroy_ah; - - dev->ibdev.get_dma_mr = qedr_get_dma_mr; - dev->ibdev.dereg_mr = qedr_dereg_mr; - dev->ibdev.reg_user_mr = qedr_reg_user_mr; - dev->ibdev.alloc_mr = qedr_alloc_mr; - dev->ibdev.map_mr_sg = qedr_map_mr_sg; - - dev->ibdev.poll_cq = qedr_poll_cq; - dev->ibdev.post_send = qedr_post_send; - dev->ibdev.post_recv = qedr_post_recv; - - dev->ibdev.process_mad = qedr_process_mad; - - dev->ibdev.get_netdev = qedr_get_netdev; - dev->ibdev.dev.parent = &dev->pdev->dev; - dev->ibdev.get_link_layer = qedr_link_layer; - dev->ibdev.get_dev_fw_str = qedr_get_dev_fw_str; rdma_set_device_sysfs_group(&dev->ibdev, &qedr_attr_group); + ib_set_device_ops(&dev->ibdev, &qedr_dev_ops); + dev->ibdev.driver_id = RDMA_DRIVER_QEDR; return ib_register_device(&dev->ibdev, "qedr%d", NULL); }