From patchwork Thu Mar 25 19:05:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 88308 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 o2PJ5ZFv028188 for ; Thu, 25 Mar 2010 19:05:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754300Ab0CYTFe (ORCPT ); Thu, 25 Mar 2010 15:05:34 -0400 Received: from mga14.intel.com ([143.182.124.37]:45809 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754258Ab0CYTFe (ORCPT ); Thu, 25 Mar 2010 15:05:34 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 25 Mar 2010 12:05:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.51,309,1267430400"; d="scan'208";a="258716896" Received: from mshefty-mobl2.amr.corp.intel.com (HELO msheftyMOBL2) ([10.24.137.126]) by azsmga001.ch.intel.com with ESMTP; 25 Mar 2010 12:05:33 -0700 From: "Sean Hefty" To: "Hefty, Sean" , "linux-rdma" References: <2F3826558E79459EAD2A457A604221C1@amr.corp.intel.com> <012F7D9E5E97445E9100EF170212AEE7@amr.corp.intel.com> Subject: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB Date: Thu, 25 Mar 2010 12:05:33 -0700 Message-ID: <7451BD1514874F3E987E55040776EECC@amr.corp.intel.com> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcrKsQISoZCN8VP+SeqPIDQtSiqGcAAAUeigAGbM3JA= In-Reply-To: <012F7D9E5E97445E9100EF170212AEE7@amr.corp.intel.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 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]); Thu, 25 Mar 2010 19:05:36 +0000 (UTC) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index ac57155..57f1521 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -657,18 +657,28 @@ static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst) case AF_INET: return ((struct sockaddr_in *) src)->sin_addr.s_addr != ((struct sockaddr_in *) dst)->sin_addr.s_addr; - default: + case AF_INET6: return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr, &((struct sockaddr_in6 *) dst)->sin6_addr); + default: + return ib_addr_cmp(&((struct sockaddr_ib *) src)->sib_addr, + &((struct sockaddr_ib *) dst)->sib_addr); } } -static inline __be16 cma_port(struct sockaddr *addr) +/* AF_IB must be using the RDMA CM IP Annex */ +static __be16 cma_port(struct sockaddr *addr) { - if (addr->sa_family == AF_INET) + switch (addr->sa_family) { + case AF_INET: return ((struct sockaddr_in *) addr)->sin_port; - else + case AF_INET6: return ((struct sockaddr_in6 *) addr)->sin6_port; + case AF_IB: + return htons((u16) be64_to_cpu(((struct sockaddr_ib *) addr)->sib_sid)); + default: + return 0; + } } static inline int cma_any_port(struct sockaddr *addr) @@ -1945,10 +1955,24 @@ EXPORT_SYMBOL(rdma_resolve_addr); static void cma_bind_port(struct rdma_bind_list *bind_list, struct rdma_id_private *id_priv) { - struct sockaddr_in *sin; + struct sockaddr *addr; + __be16 port; - sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr; - sin->sin_port = htons(bind_list->port); + addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr; + port = htons(bind_list->port); + + switch (addr->sa_family) { + case AF_INET: + ((struct sockaddr_in *) addr)->sin_port = port; + break; + case AF_INET6: + ((struct sockaddr_in6 *) addr)->sin6_port = port; + break; + case AF_IB: + ((struct sockaddr_ib *) addr)->sib_sid = + cpu_to_be64(((u64) id_priv->id.ps << 16) + ntohs(port)); + break; + } id_priv->bind_list = bind_list; hlist_add_head(&id_priv->node, &bind_list->owners); }