RDMA/cma: Allow user to specify AF_IB when binding
Modify rdma_bind_addr to allow the user to specify AF_IB when binding to a device. AF_IB indicates that the user is not mapping an IP address to the native IB addressing. (The mapping may have already been done, or is not needed) Signed-off-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
This commit is contained in:
parent
58afdcb738
commit
680f920a2e
@ -359,6 +359,27 @@ static int find_gid_port(struct ib_device *device, union ib_gid *gid, u8 port_nu
|
|||||||
return -EADDRNOTAVAIL;
|
return -EADDRNOTAVAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cma_translate_ib(struct sockaddr_ib *sib, struct rdma_dev_addr *dev_addr)
|
||||||
|
{
|
||||||
|
dev_addr->dev_type = ARPHRD_INFINIBAND;
|
||||||
|
rdma_addr_set_sgid(dev_addr, (union ib_gid *) &sib->sib_addr);
|
||||||
|
ib_addr_set_pkey(dev_addr, ntohs(sib->sib_pkey));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cma_translate_addr(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (addr->sa_family != AF_IB) {
|
||||||
|
ret = rdma_translate_ip(addr, dev_addr);
|
||||||
|
} else {
|
||||||
|
cma_translate_ib((struct sockaddr_ib *) addr, dev_addr);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int cma_acquire_dev(struct rdma_id_private *id_priv)
|
static int cma_acquire_dev(struct rdma_id_private *id_priv)
|
||||||
{
|
{
|
||||||
struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
|
struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
|
||||||
@ -1136,8 +1157,8 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
|
|||||||
rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
|
rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
|
||||||
ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey));
|
ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey));
|
||||||
} else {
|
} else {
|
||||||
ret = rdma_translate_ip((struct sockaddr *) &rt->addr.src_addr,
|
ret = cma_translate_addr((struct sockaddr *) &rt->addr.src_addr,
|
||||||
&rt->addr.dev_addr);
|
&rt->addr.dev_addr);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@ -1176,8 +1197,8 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id,
|
|||||||
ip_ver, port, src, dst);
|
ip_ver, port, src, dst);
|
||||||
|
|
||||||
if (!cma_any_addr((struct sockaddr *) &id->route.addr.src_addr)) {
|
if (!cma_any_addr((struct sockaddr *) &id->route.addr.src_addr)) {
|
||||||
ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr,
|
ret = cma_translate_addr((struct sockaddr *) &id->route.addr.src_addr,
|
||||||
&id->route.addr.dev_addr);
|
&id->route.addr.dev_addr);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@ -2443,7 +2464,8 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
|
|||||||
struct rdma_id_private *id_priv;
|
struct rdma_id_private *id_priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6)
|
if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6 &&
|
||||||
|
addr->sa_family != AF_IB)
|
||||||
return -EAFNOSUPPORT;
|
return -EAFNOSUPPORT;
|
||||||
|
|
||||||
id_priv = container_of(id, struct rdma_id_private, id);
|
id_priv = container_of(id, struct rdma_id_private, id);
|
||||||
@ -2455,7 +2477,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
|
|||||||
goto err1;
|
goto err1;
|
||||||
|
|
||||||
if (!cma_any_addr(addr)) {
|
if (!cma_any_addr(addr)) {
|
||||||
ret = rdma_translate_ip(addr, &id->route.addr.dev_addr);
|
ret = cma_translate_addr(addr, &id->route.addr.dev_addr);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err1;
|
goto err1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user