提交 ef560861 编写于 作者: S Sean Hefty 提交者: Roland Dreier

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: NSean Hefty <sean.hefty@intel.com>
Signed-off-by: NRoland Dreier <roland@purestorage.com>
上级 2e2d190c
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <net/addrconf.h> #include <net/addrconf.h>
#include <net/ip6_route.h> #include <net/ip6_route.h>
#include <rdma/ib_addr.h> #include <rdma/ib_addr.h>
#include <rdma/ib.h>
MODULE_AUTHOR("Sean Hefty"); MODULE_AUTHOR("Sean Hefty");
MODULE_DESCRIPTION("IB Address Translation"); MODULE_DESCRIPTION("IB Address Translation");
...@@ -70,6 +71,21 @@ static LIST_HEAD(req_list); ...@@ -70,6 +71,21 @@ static LIST_HEAD(req_list);
static DECLARE_DELAYED_WORK(work, process_req); static DECLARE_DELAYED_WORK(work, process_req);
static struct workqueue_struct *addr_wq; static struct workqueue_struct *addr_wq;
int rdma_addr_size(struct sockaddr *addr)
{
switch (addr->sa_family) {
case AF_INET:
return sizeof(struct sockaddr_in);
case AF_INET6:
return sizeof(struct sockaddr_in6);
case AF_IB:
return sizeof(struct sockaddr_ib);
default:
return 0;
}
}
EXPORT_SYMBOL(rdma_addr_size);
void rdma_addr_register_client(struct rdma_addr_client *client) void rdma_addr_register_client(struct rdma_addr_client *client)
{ {
atomic_set(&client->refcount, 1); atomic_set(&client->refcount, 1);
...@@ -369,12 +385,12 @@ int rdma_resolve_ip(struct rdma_addr_client *client, ...@@ -369,12 +385,12 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
goto err; goto err;
} }
memcpy(src_in, src_addr, ip_addr_size(src_addr)); memcpy(src_in, src_addr, rdma_addr_size(src_addr));
} else { } else {
src_in->sa_family = dst_addr->sa_family; src_in->sa_family = dst_addr->sa_family;
} }
memcpy(dst_in, dst_addr, ip_addr_size(dst_addr)); memcpy(dst_in, dst_addr, rdma_addr_size(dst_addr));
req->addr = addr; req->addr = addr;
req->callback = callback; req->callback = callback;
req->context = context; req->context = context;
......
...@@ -1584,7 +1584,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv, ...@@ -1584,7 +1584,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
dev_id_priv->state = RDMA_CM_ADDR_BOUND; dev_id_priv->state = RDMA_CM_ADDR_BOUND;
memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr, memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr,
ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr)); rdma_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr));
cma_attach_to_dev(dev_id_priv, cma_dev); cma_attach_to_dev(dev_id_priv, cma_dev);
list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list); 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,7 +1989,7 @@ static void addr_handler(int status, struct sockaddr *src_addr,
event.status = status; event.status = status;
} else { } else {
memcpy(&id_priv->id.route.addr.src_addr, src_addr, memcpy(&id_priv->id.route.addr.src_addr, src_addr,
ip_addr_size(src_addr)); rdma_addr_size(src_addr));
event.event = RDMA_CM_EVENT_ADDR_RESOLVED; event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
} }
...@@ -2079,7 +2079,7 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, ...@@ -2079,7 +2079,7 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
return -EINVAL; return -EINVAL;
atomic_inc(&id_priv->refcount); atomic_inc(&id_priv->refcount);
memcpy(&id->route.addr.dst_addr, dst_addr, ip_addr_size(dst_addr)); memcpy(&id->route.addr.dst_addr, dst_addr, rdma_addr_size(dst_addr));
if (cma_any_addr(dst_addr)) if (cma_any_addr(dst_addr))
ret = cma_resolve_loopback(id_priv); ret = cma_resolve_loopback(id_priv);
else else
...@@ -2399,7 +2399,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) ...@@ -2399,7 +2399,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
goto err1; goto err1;
} }
memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr)); memcpy(&id->route.addr.src_addr, addr, rdma_addr_size(addr));
if (!(id_priv->options & (1 << CMA_OPTION_AFONLY))) { if (!(id_priv->options & (1 << CMA_OPTION_AFONLY))) {
if (addr->sa_family == AF_INET) if (addr->sa_family == AF_INET)
id_priv->afonly = 1; id_priv->afonly = 1;
...@@ -3178,7 +3178,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, ...@@ -3178,7 +3178,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
if (!mc) if (!mc)
return -ENOMEM; return -ENOMEM;
memcpy(&mc->addr, addr, ip_addr_size(addr)); memcpy(&mc->addr, addr, rdma_addr_size(addr));
mc->context = context; mc->context = context;
mc->id_priv = id_priv; mc->id_priv = id_priv;
...@@ -3223,7 +3223,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) ...@@ -3223,7 +3223,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
id_priv = container_of(id, struct rdma_id_private, id); id_priv = container_of(id, struct rdma_id_private, id);
spin_lock_irq(&id_priv->lock); spin_lock_irq(&id_priv->lock);
list_for_each_entry(mc, &id_priv->mc_list, list) { list_for_each_entry(mc, &id_priv->mc_list, list) {
if (!memcmp(&mc->addr, addr, ip_addr_size(addr))) { if (!memcmp(&mc->addr, addr, rdma_addr_size(addr))) {
list_del(&mc->list); list_del(&mc->list);
spin_unlock_irq(&id_priv->lock); spin_unlock_irq(&id_priv->lock);
......
...@@ -102,11 +102,7 @@ void rdma_addr_cancel(struct rdma_dev_addr *addr); ...@@ -102,11 +102,7 @@ void rdma_addr_cancel(struct rdma_dev_addr *addr);
int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev, int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
const unsigned char *dst_dev_addr); const unsigned char *dst_dev_addr);
static inline int ip_addr_size(struct sockaddr *addr) int rdma_addr_size(struct sockaddr *addr);
{
return addr->sa_family == AF_INET6 ?
sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in);
}
static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr) static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册