From patchwork Mon Mar 7 21:08:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 8523181 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A678AC0553 for ; Mon, 7 Mar 2016 21:09:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C119C20270 for ; Mon, 7 Mar 2016 21:09:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D438A20220 for ; Mon, 7 Mar 2016 21:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753411AbcCGVJs (ORCPT ); Mon, 7 Mar 2016 16:09:48 -0500 Received: from [193.47.165.129] ([193.47.165.129]:43372 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753402AbcCGVJr (ORCPT ); Mon, 7 Mar 2016 16:09:47 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 Mar 2016 23:09:09 +0200 Received: from sw-mtx-012.mtx.labs.mlnx (sw-mtx-012.mtx.labs.mlnx [10.12.150.39]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id u27L980h015224; Mon, 7 Mar 2016 23:09:09 +0200 Received: from sw-mtx-012.mtx.labs.mlnx (localhost [127.0.0.1]) by sw-mtx-012.mtx.labs.mlnx (8.14.7/8.14.7) with ESMTP id u27L98EQ012000; Mon, 7 Mar 2016 23:09:08 +0200 Received: (from eli@localhost) by sw-mtx-012.mtx.labs.mlnx (8.14.7/8.14.7/Submit) id u27L98g1011999; Mon, 7 Mar 2016 23:09:08 +0200 From: Eli Cohen To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, liranl@mellanox.com, Eli Cohen Subject: [PATCH rdma-next V1 04/10] IB/core: Support accessing SA in virtualized environment Date: Mon, 7 Mar 2016 23:08:54 +0200 Message-Id: <1457384940-11951-5-git-send-email-eli@mellanox.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1457384940-11951-1-git-send-email-eli@mellanox.com> References: <1457384940-11951-1-git-send-email-eli@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Per the ongoing standardisation process, when virtual HCAs are present in a network, traffic is routed based on a destination GID. In order to access the SA we use the well known SA GID. We also add a GRH required boolean field to the port attributes which is used to report to the verbs consumer whether this port is connected to a virtual network. We use this field to realize whether we need to create an address vector with GRH to access the subnet administrator. We clear the port attributes struct before calling the hardware driver to make sure the default remains that GRH is not required. Signed-off-by: Eli Cohen --- Changes from V0: Use queried subnet prefix when creating AH to access the SM drivers/infiniband/core/device.c | 1 + drivers/infiniband/core/sa_query.c | 5 +++++ include/rdma/ib_verbs.h | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 00da80e02154..24926acd4bcd 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -652,6 +652,7 @@ int ib_query_port(struct ib_device *device, if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device)) return -EINVAL; + memset(port_attr, 0, sizeof(*port_attr)); return device->query_port(device, port_num, port_attr); } EXPORT_SYMBOL(ib_query_port); diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index f334090bb612..4fb97df2caa5 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -886,6 +886,11 @@ static void update_sm_ah(struct work_struct *work) ah_attr.dlid = port_attr.sm_lid; ah_attr.sl = port_attr.sm_sl; ah_attr.port_num = port->port_num; + if (port_attr.grh_required) { + ah_attr.ah_flags = IB_AH_GRH; + ah_attr.grh.dgid.global.subnet_prefix = cpu_to_be64(port_attr.subnet_prefix); + ah_attr.grh.dgid.global.interface_id = cpu_to_be64(IB_SA_WELL_KNOWN_GUID); + } new_ah->ah = ib_create_ah(port->agent->qp->pd, &ah_attr); if (IS_ERR(new_ah->ah)) { diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index b3646e30e25d..8add3db9a244 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -97,6 +97,10 @@ enum rdma_node_type { RDMA_NODE_USNIC_UDP, }; +enum { + IB_SA_WELL_KNOWN_GUID = 2, +}; + enum rdma_transport_type { RDMA_TRANSPORT_IB, RDMA_TRANSPORT_IWARP, @@ -510,6 +514,7 @@ struct ib_port_attr { u8 active_speed; u8 phys_state; u64 subnet_prefix; + bool grh_required; }; enum ib_device_modify_flags {