From patchwork Thu Apr 1 17:08:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 90192 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 o31H8iDW030454 for ; Thu, 1 Apr 2010 17:08:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757762Ab0DARIw (ORCPT ); Thu, 1 Apr 2010 13:08:52 -0400 Received: from mga11.intel.com ([192.55.52.93]:44648 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757610Ab0DARIv (ORCPT ); Thu, 1 Apr 2010 13:08:51 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 01 Apr 2010 10:08:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.51,349,1267430400"; d="scan'208";a="785809578" Received: from unknown (HELO msheftyMOBL2) ([10.254.108.159]) by fmsmga001.fm.intel.com with ESMTP; 01 Apr 2010 10:08:49 -0700 From: "Sean Hefty" To: "Hefty, Sean" , References: Subject: [PATCH 16/26] rdma/cm: expose private data when using AF_IB Date: Thu, 1 Apr 2010 10:08:41 -0700 Message-ID: <04C434500E4B462A899BC3666334D4E7@amr.corp.intel.com> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcrRtMZV7yVukZHyQqa3gseqBpR7/wABQJfA In-Reply-To: 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, 01 Apr 2010 17:08:55 +0000 (UTC) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 0432eca..b3188fc 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -820,6 +820,7 @@ static inline int cma_user_data_offset(enum rdma_port_space ps) { switch (ps) { case RDMA_PS_SDP: + case RDMA_PS_IB: return 0; default: return sizeof(struct cma_hdr); @@ -2349,19 +2350,19 @@ err1: } EXPORT_SYMBOL(rdma_bind_addr); -static int cma_format_hdr(void *hdr, enum rdma_port_space ps, - struct rdma_route *route) +static int cma_format_hdr(void *hdr, struct rdma_cm_id *id) { struct cma_hdr *cma_hdr; struct sdp_hh *sdp_hdr; - if (route->addr.src_addr.ss_family == AF_INET) { + if (id->route.addr.src_addr.ss_family == AF_INET && + id->route.addr.dst_addr.ss_family == AF_INET) { struct sockaddr_in *src4, *dst4; - src4 = (struct sockaddr_in *) &route->addr.src_addr; - dst4 = (struct sockaddr_in *) &route->addr.dst_addr; + src4 = (struct sockaddr_in *) &id->route.addr.src_addr; + dst4 = (struct sockaddr_in *) &id->route.addr.dst_addr; - switch (ps) { + switch (id->ps) { case RDMA_PS_SDP: sdp_hdr = hdr; if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) @@ -2380,13 +2381,14 @@ static int cma_format_hdr(void *hdr, enum rdma_port_space ps, cma_hdr->port = src4->sin_port; break; } - } else { + } else if (id->route.addr.src_addr.ss_family == AF_INET6 && + id->route.addr.dst_addr.ss_family == AF_INET6) { struct sockaddr_in6 *src6, *dst6; - src6 = (struct sockaddr_in6 *) &route->addr.src_addr; - dst6 = (struct sockaddr_in6 *) &route->addr.dst_addr; + src6 = (struct sockaddr_in6 *) &id->route.addr.src_addr; + dst6 = (struct sockaddr_in6 *) &id->route.addr.dst_addr; - switch (ps) { + switch (id->ps) { case RDMA_PS_SDP: sdp_hdr = hdr; if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) @@ -2478,20 +2480,20 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv, { struct ib_cm_sidr_req_param req; struct rdma_route *route; - int ret; + int offset, ret; - req.private_data_len = sizeof(struct cma_hdr) + - conn_param->private_data_len; + offset = cma_user_data_offset(id_priv->id.ps); + req.private_data_len = offset + conn_param->private_data_len; req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC); if (!req.private_data) return -ENOMEM; if (conn_param->private_data && conn_param->private_data_len) - memcpy((void *) req.private_data + sizeof(struct cma_hdr), + memcpy((void *) req.private_data + offset, conn_param->private_data, conn_param->private_data_len); route = &id_priv->id.route; - ret = cma_format_hdr((void *) req.private_data, id_priv->id.ps, route); + ret = cma_format_hdr((void *) req.private_data, &id_priv->id); if (ret) goto out; @@ -2545,7 +2547,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv, } route = &id_priv->id.route; - ret = cma_format_hdr(private_data, id_priv->id.ps, route); + ret = cma_format_hdr(private_data, &id_priv->id); if (ret) goto out; req.private_data = private_data;