aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Hefty <sean.hefty@intel.com>2013-05-29 13:09:10 -0400
committerRoland Dreier <roland@purestorage.com>2013-06-20 16:08:02 -0400
commitef560861c01c301cde3da154eb9c1c2619924c3a (patch)
tree67c9b7ec2cc29f65a958c4d55afd8130eeeb8f62
parent2e2d190c5eb05d5a2615f4092e5fe821710404f9 (diff)
IB/addr: Add AF_IB support to ip_addr_size
Add support for AF_IB to ip_addr_size, and rename the function to account for the change. Give the compiler more control over whether the call should be inline or not by moving the definition into the .c file, removing the static inline, and exporting it. Signed-off-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r--drivers/infiniband/core/addr.c20
-rw-r--r--drivers/infiniband/core/cma.c12
-rw-r--r--include/rdma/ib_addr.h6
3 files changed, 25 insertions, 13 deletions
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index eaec8d7a3b73..e90f2b2eabd7 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -45,6 +45,7 @@
45#include <net/addrconf.h> 45#include <net/addrconf.h>
46#include <net/ip6_route.h> 46#include <net/ip6_route.h>
47#include <rdma/ib_addr.h> 47#include <rdma/ib_addr.h>
48#include <rdma/ib.h>
48 49
49MODULE_AUTHOR("Sean Hefty"); 50MODULE_AUTHOR("Sean Hefty");
50MODULE_DESCRIPTION("IB Address Translation"); 51MODULE_DESCRIPTION("IB Address Translation");
@@ -70,6 +71,21 @@ static LIST_HEAD(req_list);
70static DECLARE_DELAYED_WORK(work, process_req); 71static DECLARE_DELAYED_WORK(work, process_req);
71static struct workqueue_struct *addr_wq; 72static struct workqueue_struct *addr_wq;
72 73
74int rdma_addr_size(struct sockaddr *addr)
75{
76 switch (addr->sa_family) {
77 case AF_INET:
78 return sizeof(struct sockaddr_in);
79 case AF_INET6:
80 return sizeof(struct sockaddr_in6);
81 case AF_IB:
82 return sizeof(struct sockaddr_ib);
83 default:
84 return 0;
85 }
86}
87EXPORT_SYMBOL(rdma_addr_size);
88
73void rdma_addr_register_client(struct rdma_addr_client *client) 89void rdma_addr_register_client(struct rdma_addr_client *client)
74{ 90{
75 atomic_set(&client->refcount, 1); 91 atomic_set(&client->refcount, 1);
@@ -369,12 +385,12 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
369 goto err; 385 goto err;
370 } 386 }
371 387
372 memcpy(src_in, src_addr, ip_addr_size(src_addr)); 388 memcpy(src_in, src_addr, rdma_addr_size(src_addr));
373 } else { 389 } else {
374 src_in->sa_family = dst_addr->sa_family; 390 src_in->sa_family = dst_addr->sa_family;
375 } 391 }
376 392
377 memcpy(dst_in, dst_addr, ip_addr_size(dst_addr)); 393 memcpy(dst_in, dst_addr, rdma_addr_size(dst_addr));
378 req->addr = addr; 394 req->addr = addr;
379 req->callback = callback; 395 req->callback = callback;
380 req->context = context; 396 req->context = context;
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 22a23a73745e..2b1041c5844c 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1584,7 +1584,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
1584 1584
1585 dev_id_priv->state = RDMA_CM_ADDR_BOUND; 1585 dev_id_priv->state = RDMA_CM_ADDR_BOUND;
1586 memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr, 1586 memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr,
1587 ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr)); 1587 rdma_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr));
1588 1588
1589 cma_attach_to_dev(dev_id_priv, cma_dev); 1589 cma_attach_to_dev(dev_id_priv, cma_dev);
1590 list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list); 1590 list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list);
@@ -1989,7 +1989,7 @@ static void addr_handler(int status, struct sockaddr *src_addr,
1989 event.status = status; 1989 event.status = status;
1990 } else { 1990 } else {
1991 memcpy(&id_priv->id.route.addr.src_addr, src_addr, 1991 memcpy(&id_priv->id.route.addr.src_addr, src_addr,
1992 ip_addr_size(src_addr)); 1992 rdma_addr_size(src_addr));
1993 event.event = RDMA_CM_EVENT_ADDR_RESOLVED; 1993 event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
1994 } 1994 }
1995 1995
@@ -2079,7 +2079,7 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
2079 return -EINVAL; 2079 return -EINVAL;
2080 2080
2081 atomic_inc(&id_priv->refcount); 2081 atomic_inc(&id_priv->refcount);
2082 memcpy(&id->route.addr.dst_addr, dst_addr, ip_addr_size(dst_addr)); 2082 memcpy(&id->route.addr.dst_addr, dst_addr, rdma_addr_size(dst_addr));
2083 if (cma_any_addr(dst_addr)) 2083 if (cma_any_addr(dst_addr))
2084 ret = cma_resolve_loopback(id_priv); 2084 ret = cma_resolve_loopback(id_priv);
2085 else 2085 else
@@ -2399,7 +2399,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
2399 goto err1; 2399 goto err1;
2400 } 2400 }
2401 2401
2402 memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr)); 2402 memcpy(&id->route.addr.src_addr, addr, rdma_addr_size(addr));
2403 if (!(id_priv->options & (1 << CMA_OPTION_AFONLY))) { 2403 if (!(id_priv->options & (1 << CMA_OPTION_AFONLY))) {
2404 if (addr->sa_family == AF_INET) 2404 if (addr->sa_family == AF_INET)
2405 id_priv->afonly = 1; 2405 id_priv->afonly = 1;
@@ -3178,7 +3178,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
3178 if (!mc) 3178 if (!mc)
3179 return -ENOMEM; 3179 return -ENOMEM;
3180 3180
3181 memcpy(&mc->addr, addr, ip_addr_size(addr)); 3181 memcpy(&mc->addr, addr, rdma_addr_size(addr));
3182 mc->context = context; 3182 mc->context = context;
3183 mc->id_priv = id_priv; 3183 mc->id_priv = id_priv;
3184 3184
@@ -3223,7 +3223,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
3223 id_priv = container_of(id, struct rdma_id_private, id); 3223 id_priv = container_of(id, struct rdma_id_private, id);
3224 spin_lock_irq(&id_priv->lock); 3224 spin_lock_irq(&id_priv->lock);
3225 list_for_each_entry(mc, &id_priv->mc_list, list) { 3225 list_for_each_entry(mc, &id_priv->mc_list, list) {
3226 if (!memcmp(&mc->addr, addr, ip_addr_size(addr))) { 3226 if (!memcmp(&mc->addr, addr, rdma_addr_size(addr))) {
3227 list_del(&mc->list); 3227 list_del(&mc->list);
3228 spin_unlock_irq(&id_priv->lock); 3228 spin_unlock_irq(&id_priv->lock);
3229 3229
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index 99965395c5f3..f3ac0f2c4c66 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -102,11 +102,7 @@ void rdma_addr_cancel(struct rdma_dev_addr *addr);
102int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev, 102int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
103 const unsigned char *dst_dev_addr); 103 const unsigned char *dst_dev_addr);
104 104
105static inline int ip_addr_size(struct sockaddr *addr) 105int rdma_addr_size(struct sockaddr *addr);
106{
107 return addr->sa_family == AF_INET6 ?
108 sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in);
109}
110 106
111static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr) 107static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr)
112{ 108{