From patchwork Fri Jun 11 12:47:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chien Tung X-Patchwork-Id: 105570 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 o5BCloDa016052 for ; Fri, 11 Jun 2010 12:47:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755978Ab0FKMrt (ORCPT ); Fri, 11 Jun 2010 08:47:49 -0400 Received: from mga01.intel.com ([192.55.52.88]:59861 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755877Ab0FKMrt (ORCPT ); Fri, 11 Jun 2010 08:47:49 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 11 Jun 2010 05:43:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.53,403,1272870000"; d="scan'208";a="807000246" Received: from unknown (HELO ctung-MOBL.intel.com) ([10.254.112.117]) by fmsmga001.fm.intel.com with SMTP; 11 Jun 2010 05:47:25 -0700 Received: by ctung-MOBL.intel.com (sSMTP sendmail emulation); Fri, 11 Jun 2010 07:47:46 -0500 Date: Fri, 11 Jun 2010 07:47:46 -0500 From: Chien Tung To: Roland Dreier Cc: linux-rdma@vger.kernel.org Subject: [PATCH v2] RDMA/CMA: fix iWARP adapter TCP port space usage Message-ID: <20100611124746.GA2292@CTUNG-MOBL1> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.2.2i 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]); Fri, 11 Jun 2010 12:47:50 +0000 (UTC) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index b930b81..d5855f9 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -56,6 +56,11 @@ MODULE_AUTHOR("Sean Hefty"); MODULE_DESCRIPTION("Generic RDMA CM Agent"); MODULE_LICENSE("Dual BSD/GPL"); +int unify_tcp_port_space = 1; +module_param(unify_tcp_port_space, int, 0644); +MODULE_PARM_DESC(unify_tcp_port_space, "Unify the host TCP and RDMA port " + "space allocation (default=1)"); + #define CMA_CM_RESPONSE_TIMEOUT 20 #define CMA_MAX_CM_RETRIES 15 #define CMA_CM_MRA_SETTING (IB_CM_MRA_FLAG_DELAY | 24) @@ -118,6 +123,7 @@ struct rdma_id_private { struct rdma_cm_id id; struct rdma_bind_list *bind_list; + struct socket *sock; struct hlist_node node; struct list_head list; /* listen_any_list or cma_device.list */ struct list_head listen_list; /* per device listens */ @@ -806,6 +812,8 @@ static void cma_release_port(struct rdma_id_private *id_priv) kfree(bind_list); } mutex_unlock(&lock); + if (id_priv->sock) + sock_release(id_priv->sock); } static void cma_leave_mc_groups(struct rdma_id_private *id_priv) @@ -2035,6 +2043,37 @@ static int cma_use_port(struct idr *ps, struct rdma_id_private *id_priv) return 0; } +static int cma_get_tcp_port(struct rdma_id_private *id_priv) +{ + int ret; + int size; + struct socket *sock; + + ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); + if (ret) + return ret; + + size = ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr); + + ret = sock->ops->bind(sock, + (struct sockaddr *) &id_priv->id.route.addr.src_addr, + size); + if (ret) + goto err; + + ret = sock->ops->getname(sock, + (struct sockaddr *) &id_priv->id.route.addr.src_addr, + &size, 0); + if (ret) + goto err; + + id_priv->sock = sock; + return 0; +err: + sock_release(sock); + return ret; +} + static int cma_get_port(struct rdma_id_private *id_priv) { struct idr *ps; @@ -2046,6 +2085,11 @@ static int cma_get_port(struct rdma_id_private *id_priv) break; case RDMA_PS_TCP: ps = &tcp_ps; + if (unify_tcp_port_space) { + ret = cma_get_tcp_port(id_priv); + if (ret) + goto out; + } break; case RDMA_PS_UDP: ps = &udp_ps; @@ -2063,7 +2107,7 @@ static int cma_get_port(struct rdma_id_private *id_priv) else ret = cma_use_port(ps, id_priv); mutex_unlock(&lock); - +out: return ret; }