From patchwork Tue Mar 23 18:01:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 87720 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2NI1B5Y005012 for ; Tue, 23 Mar 2010 18:01:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754003Ab0CWSBL (ORCPT ); Tue, 23 Mar 2010 14:01:11 -0400 Received: from mga09.intel.com ([134.134.136.24]:23234 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753910Ab0CWSBK (ORCPT ); Tue, 23 Mar 2010 14:01:10 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 23 Mar 2010 10:58:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.51,296,1267430400"; d="scan'208";a="502950415" Received: from unknown (HELO msheftyMOBL2) ([10.254.89.25]) by orsmga002.jf.intel.com with ESMTP; 23 Mar 2010 11:00:16 -0700 From: "Sean Hefty" To: "Hefty, Sean" , "linux-rdma" References: <2F3826558E79459EAD2A457A604221C1@amr.corp.intel.com> Subject: [RFC] [PATCH 6/22] [for 2.6.36] rdma/cm: Allow user to specify AF_IB when binding Date: Tue, 23 Mar 2010 11:01:09 -0700 Message-ID: MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcrKsQISoZCN8VP+SeqPIDQtSiqGcAAAZMKw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 In-Reply-To: <2F3826558E79459EAD2A457A604221C1@amr.corp.intel.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 23 Mar 2010 18:01:12 +0000 (UTC) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 1546236..0a3bbf9 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -324,6 +324,13 @@ static int cma_set_qkey(struct rdma_id_private *id_priv) return ret; } +static void cma_translate_ib(struct sockaddr_ib *addr, struct rdma_dev_addr *dev_addr) +{ + dev_addr->dev_type = ARPHRD_INFINIBAND; + rdma_addr_set_sgid(dev_addr, (union ib_gid *) &addr->sib_addr); + ib_addr_set_pkey(dev_addr, ntohs(addr->sib_pkey)); +} + static int cma_acquire_dev(struct rdma_id_private *id_priv) { struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; @@ -2148,7 +2155,8 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) struct rdma_id_private *id_priv; int ret; - if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6) + if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6 && + addr->sa_family != AF_IB) return -EAFNOSUPPORT; id_priv = container_of(id, struct rdma_id_private, id); @@ -2160,9 +2168,14 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) goto err1; if (!cma_any_addr(addr)) { - ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); - if (ret) - goto err1; + if (addr->sa_family == AF_IB) { + cma_translate_ib((struct sockaddr_ib *) addr, + &id->route.addr.dev_addr); + } else { + ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); + if (ret) + goto err1; + } mutex_lock(&lock); ret = cma_acquire_dev(id_priv);