From patchwork Wed May 10 23:23:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dasaratharaman Chandramouli X-Patchwork-Id: 9720749 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 72D5E60364 for ; Wed, 10 May 2017 23:23:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 828DC2860E for ; Wed, 10 May 2017 23:23:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 776E428635; Wed, 10 May 2017 23:23:23 +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 154FE2860E for ; Wed, 10 May 2017 23:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751096AbdEJXXV (ORCPT ); Wed, 10 May 2017 19:23:21 -0400 Received: from mga05.intel.com ([192.55.52.43]:47450 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754400AbdEJXXU (ORCPT ); Wed, 10 May 2017 19:23:20 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP; 10 May 2017 16:23:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,321,1491289200"; d="scan'208";a="1128792872" Received: from phwtpriv01.ph.intel.com ([10.228.208.76]) by orsmga001.jf.intel.com with ESMTP; 10 May 2017 16:23:19 -0700 From: Dasaratharaman Chandramouli To: Doug Ledford , linux-rdma Subject: [PATCH rdma-next 2/4] IB/CM: Create appropriate path records when handling CM request Date: Wed, 10 May 2017 19:23:16 -0400 Message-Id: <1494458598-6911-3-git-send-email-dasaratharaman.chandramouli@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1494458598-6911-1-git-send-email-dasaratharaman.chandramouli@intel.com> References: <1494458598-6911-1-git-send-email-dasaratharaman.chandramouli@intel.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 When handling an incoming conection request, ib_cm creates either an IB or an OPA path record based on the gid field in the request. Reviewed-by: Don Hiatt Reviewed-by: Ira Weiny Signed-off-by: Dasaratharaman Chandramouli --- drivers/infiniband/core/cm.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 9a7f4be..01cfa24 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -1421,6 +1421,12 @@ static inline int cm_is_active_peer(__be64 local_ca_guid, __be64 remote_ca_guid, (be32_to_cpu(local_qpn) > be32_to_cpu(remote_qpn)))); } +static bool cm_req_has_alt_path(struct cm_req_msg *req_msg) +{ + return ((req_msg->alt_local_lid) || + (ib_is_opa_gid(&req_msg->alt_local_gid))); +} + static void cm_format_paths_from_req(struct cm_req_msg *req_msg, struct sa_path_rec *primary_path, struct sa_path_rec *alt_path) @@ -1800,9 +1806,18 @@ static int cm_req_handler(struct cm_work *work) dev_net(gid_attr.ndev)); dev_put(gid_attr.ndev); } else { - work->path[0].rec_type = SA_PATH_REC_TYPE_IB; + /* + * If the gid in the request is an OPA GID, + * create an OPA PR + */ + if (ib_is_opa_gid(&req_msg->primary_local_gid) && + rdma_cap_opa_ah(work->port->cm_dev->ib_device, + work->port->port_num)) + work->path[0].rec_type = SA_PATH_REC_TYPE_OPA; + else + work->path[0].rec_type = SA_PATH_REC_TYPE_IB; } - if (req_msg->alt_local_lid) + if (cm_req_has_alt_path(req_msg)) work->path[1].rec_type = work->path[0].rec_type; cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]); @@ -1827,16 +1842,21 @@ static int cm_req_handler(struct cm_work *work) dev_net(gid_attr.ndev)); dev_put(gid_attr.ndev); } else { - work->path[0].rec_type = SA_PATH_REC_TYPE_IB; + if (ib_is_opa_gid(&req_msg->primary_local_gid) && + rdma_cap_opa_ah(work->port->cm_dev->ib_device, + work->port->port_num)) + work->path[0].rec_type = SA_PATH_REC_TYPE_OPA; + else + work->path[0].rec_type = SA_PATH_REC_TYPE_IB; } - if (req_msg->alt_local_lid) + if (cm_req_has_alt_path(req_msg)) work->path[1].rec_type = work->path[0].rec_type; ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID, &work->path[0].sgid, sizeof work->path[0].sgid, NULL, 0); goto rejected; } - if (req_msg->alt_local_lid) { + if (cm_req_has_alt_path(req_msg)) { ret = cm_init_av_by_path(&work->path[1], &cm_id_priv->alt_av, cm_id_priv); if (ret) { @@ -2953,8 +2973,6 @@ static void cm_format_path_from_lap(struct cm_id_private *cm_id_priv, struct sa_path_rec *path, struct cm_lap_msg *lap_msg) { - memset(path, 0, sizeof *path); - path->rec_type = SA_PATH_REC_TYPE_IB; path->dgid = lap_msg->alt_local_gid; path->sgid = lap_msg->alt_remote_gid; sa_path_set_dlid(path, htonl(ntohs(lap_msg->alt_local_lid))); @@ -2990,6 +3008,13 @@ static int cm_lap_handler(struct cm_work *work) return -EINVAL; param = &work->cm_event.param.lap_rcvd; + memset(&work->path[0], 0, sizeof(work->path[0])); + if (ib_is_opa_gid(&lap_msg->alt_local_gid) && + rdma_cap_opa_ah(work->port->cm_dev->ib_device, + work->port->port_num)) + work->path[0].rec_type = SA_PATH_REC_TYPE_OPA; + else + work->path[0].rec_type = SA_PATH_REC_TYPE_IB; param->alternate_path = &work->path[0]; cm_format_path_from_lap(cm_id_priv, param->alternate_path, lap_msg); work->cm_event.private_data = &lap_msg->private_data;