From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 1/2] rdma/cm: Allow user to select specific RDMA loopback device
Date: Fri, 3 May 2013 15:19:51 -0700 [thread overview]
Message-ID: <1367619592-2363-1-git-send-email-sean.hefty@intel.com> (raw)
From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
RDMA connections to a loopback address must map to a physical
RDMA device/port. By default, a connection to a loopback address
automatically binds the corresponding cm_id to the first active
RDMA device/port. The result is that all loopback connections
are forced to use the same device, even if multiple devices
are present.
In order to map loopback connections across multiple RDMA devices,
we expose the mapping directly to the user. For IPv4, we make use
of the multiple loopback addresses which are available, with
each loopback address matched with a specific RDMA device/port.
For IPv6, we use the scope ID as an index into the RDMA CM
device/port list.
For compatibility, if the IPv4 loopback address is the common
localhost (127.0.0.1) address or if no scope ID is given, we follow
the current algorithm of selecting the first active device/port.
Otherwise, the address/scope ID is used as an index into the
device/port list.
Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
drivers/infiniband/core/cma.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 71c2c71..7203a0f 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1913,13 +1913,27 @@ err:
}
EXPORT_SYMBOL(rdma_resolve_route);
+static int cma_loopback_index(struct rdma_id_private *id_priv)
+{
+ struct sockaddr *addr = (struct sockaddr *) &id_priv->id.route.addr.dst_addr;
+
+ if (addr->sa_family == AF_INET)
+ return ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr) -
+ INADDR_LOOPBACK;
+#if IS_ENABLED(CONFIG_IPV6)
+ if (addr->sa_family == AF_INET6)
+ return ((struct sockaddr_in6 *) addr)->sin6_scope_id;
+#endif
+ return 0;
+}
+
static int cma_bind_loopback(struct rdma_id_private *id_priv)
{
struct cma_device *cma_dev;
struct ib_port_attr port_attr;
union ib_gid gid;
u16 pkey;
- int ret;
+ int ret, index;
u8 p;
mutex_lock(&lock);
@@ -1927,6 +1941,17 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
ret = -ENODEV;
goto out;
}
+
+ index = cma_loopback_index(id_priv);
+ if (index) {
+ list_for_each_entry(cma_dev, &dev_list, list) {
+ if (index <= cma_dev->device->phys_port_cnt) {
+ p = index;
+ goto port_found;
+ }
+ index -= cma_dev->device->phys_port_cnt;
+ }
+ }
list_for_each_entry(cma_dev, &dev_list, list)
for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p)
if (!ib_query_port(cma_dev->device, p, &port_attr) &&
--
1.7.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2013-05-03 22:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-03 22:19 sean.hefty-ral2JQCrhuEAvxtiuMwx3w [this message]
[not found] ` <1367619592-2363-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-05-03 22:19 ` [PATCH 2/2] rdma/cm: Allow enabling reuseaddr in any state sean.hefty-ral2JQCrhuEAvxtiuMwx3w
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367619592-2363-1-git-send-email-sean.hefty@intel.com \
--to=sean.hefty-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox