From patchwork Sun Nov 27 14:51:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 9448811 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 1905E6071A for ; Sun, 27 Nov 2016 14:52:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14CF726785 for ; Sun, 27 Nov 2016 14:52:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0980E27BFF; Sun, 27 Nov 2016 14:52:04 +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 8B19526785 for ; Sun, 27 Nov 2016 14:52:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752128AbcK0OwC (ORCPT ); Sun, 27 Nov 2016 09:52:02 -0500 Received: from mail.kernel.org ([198.145.29.136]:47358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126AbcK0OwC (ORCPT ); Sun, 27 Nov 2016 09:52:02 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D838202AE; Sun, 27 Nov 2016 14:52:00 +0000 (UTC) Received: from localhost (unknown [193.47.165.251]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D7AA2202FE; Sun, 27 Nov 2016 14:51:58 +0000 (UTC) From: Leon Romanovsky To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Steve Wise , Mike Marciniszyn , Dennis Dalessandro , Lijun Ou , "Wei Hu(Xavier)" , Faisal Latif , Yishai Hadas , Selvin Xavier , Devesh Sharma , Mitesh Ahuja , Christian Benvenuti , Dave Goodell , Moni Shoua , Or Gerlitz Subject: [PATCH rdma-next 06/10] IB/core: Enable to query QP types supported by IB device on a port Date: Sun, 27 Nov 2016 16:51:32 +0200 Message-Id: <1480258296-27032-7-git-send-email-leon@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480258296-27032-1-git-send-email-leon@kernel.org> References: <1480258296-27032-1-git-send-email-leon@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP 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 From: Or Gerlitz Add qp_type_cap port attribute which is a bit field representation of the ib_qp_type enum. This will allow applications to query what QP types are supported by an IB device instance on a specific port. The qp_type_cap port attribute is set by the core according to the protocol supported for the device port. This holds for all the providers with the exception of two RoCE drivers that don't implement UD and UC. To handle that, they (hns and qedr) are patched to remove these QPs from what's the core has set for them as supported. Signed-off-by: Or Gerlitz Reviewed-by: Matan Barak Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/device.c | 28 ++++++++++++++++++++++++++++ drivers/infiniband/hw/hns/hns_roce_main.c | 3 +++ drivers/infiniband/hw/qedr/verbs.c | 2 ++ include/rdma/ib_verbs.h | 1 + 4 files changed, 34 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 760ef60..f7abde2 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -646,6 +646,31 @@ void ib_dispatch_event(struct ib_event *event) } EXPORT_SYMBOL(ib_dispatch_event); +static void get_port_qp_types(const struct ib_device *device, u8 port_num, + struct ib_port_attr *port_attr) +{ + if (rdma_cap_ib_smi(device, port_num)) + port_attr->qp_type_cap |= BIT(IB_QPT_SMI); + + if (rdma_cap_ib_cm(device, port_num)) + port_attr->qp_type_cap |= BIT(IB_QPT_GSI); + + if (rdma_ib_or_roce(device, port_num)) { + port_attr->qp_type_cap |= (BIT(IB_QPT_RC) | BIT(IB_QPT_UD) | BIT(IB_QPT_UC)); + if (device->attrs.device_cap_flags & IB_DEVICE_XRC) + port_attr->qp_type_cap |= (BIT(IB_QPT_XRC_INI) | BIT(IB_QPT_XRC_TGT)); + } + + if (rdma_protocol_iwarp(device, port_num)) + port_attr->qp_type_cap |= BIT(IB_QPT_RC); + + if (rdma_protocol_raw_packet(device, port_num)) + port_attr->qp_type_cap |= BIT(IB_QPT_RAW_PACKET); + + if (rdma_protocol_usnic(device, port_num)) + port_attr->qp_type_cap |= BIT(IB_QPT_UD); +} + /** * ib_query_port - Query IB port attributes * @device:Device to query @@ -666,6 +691,9 @@ int ib_query_port(struct ib_device *device, return -EINVAL; memset(port_attr, 0, sizeof(*port_attr)); + + get_port_qp_types(device, port_num, port_attr); + err = device->query_port(device, port_num, port_attr); if (err || port_attr->subnet_prefix) return err; diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index c6b5779..22de534 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -430,6 +430,9 @@ static int hns_roce_query_port(struct ib_device *ib_dev, u8 port_num, IB_PORT_ACTIVE : IB_PORT_DOWN; props->phys_state = (props->state == IB_PORT_ACTIVE) ? 5 : 3; + /* mark that UD and UC aren't supported */ + props->qp_type_cap &= ~(BIT(IB_QPT_UD) | BIT(IB_QPT_UC)); + spin_unlock_irqrestore(&hr_dev->iboe.lock, flags); return 0; diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c index 53207ff..33d0219 100644 --- a/drivers/infiniband/hw/qedr/verbs.c +++ b/drivers/infiniband/hw/qedr/verbs.c @@ -263,6 +263,8 @@ int qedr_query_port(struct ib_device *ibdev, u8 port, struct ib_port_attr *attr) attr->max_msg_sz = rdma_port->max_msg_size; attr->max_vl_num = 4; + /* mark that UD and UC aren't supported */ + attr->qp_type_cap &= ~(BIT(IB_QPT_UD) | BIT(IB_QPT_UC)); return 0; } diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 485b725..0b839e4 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -536,6 +536,7 @@ struct ib_port_attr { u8 active_speed; u8 phys_state; bool grh_required; + u16 qp_type_cap; }; enum ib_device_modify_flags {