]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
librdmacm: add support to bind using AF_IB
authorSean Hefty <sean.hefty@intel.com>
Thu, 6 May 2010 22:44:25 +0000 (15:44 -0700)
committerSean Hefty <sean.hefty@intel.com>
Thu, 6 May 2010 22:44:25 +0000 (15:44 -0700)
Allow rdma_bind_addr to accept AF_IB addresses.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
include/rdma/rdma_cma_abi.h
src/cma.c

index b4d6a15924d62effbd308a93f94f21489e7d7f21..8c75c9d2e14e2dfc0e49b2f44a67f84483004bdc 100644 (file)
@@ -66,7 +66,8 @@ enum {
        UCMA_CMD_JOIN_IP_MCAST,
        UCMA_CMD_LEAVE_MCAST,
        UCMA_CMD_MIGRATE_ID,
-       UCMA_CMD_QUERY
+       UCMA_CMD_QUERY,
+       UCMA_CMD_BIND
 };
 
 struct ucma_abi_cmd_hdr {
@@ -102,6 +103,13 @@ struct ucma_abi_bind_ip {
        __u32 id;
 };
 
+struct ucma_abi_bind {
+       __u32 id;
+       __u16 addr_size;
+       __u16 reserved;
+       struct sockaddr_storage addr;
+};
+
 struct ucma_abi_resolve_ip {
        struct sockaddr_in6 src_addr;
        struct sockaddr_in6 dst_addr;
index 10bcd98b86fa2c974761d56d79332d766105fe96..5d6d9f73146c9c702a78550f25aec3c5ea5421a7 100644 (file)
--- a/src/cma.c
+++ b/src/cma.c
@@ -673,6 +673,28 @@ static int ucma_query_route(struct rdma_cm_id *id)
        return 0;
 }
 
+static int rdma_bind_addr2(struct rdma_cm_id *id, struct sockaddr *addr,
+                          socklen_t addrlen)
+{
+       struct ucma_abi_bind *cmd;
+       struct cma_id_private *id_priv;
+       void *msg;
+       int ret, size;
+       
+       CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_BIND, size);
+       id_priv = container_of(id, struct cma_id_private, id);
+       cmd->id = id_priv->handle;
+       cmd->addr_size = addrlen;
+       cmd->reserved = 0;
+       memcpy(&cmd->addr, addr, addrlen);
+
+       ret = write(id->channel->fd, msg, size);
+       if (ret != size)
+               return (ret >= 0) ? ERR(ENODATA) : -1;
+
+       return ucma_query_addr(id);
+}
+
 int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
 {
        struct ucma_abi_bind_ip *cmd;
@@ -684,6 +706,9 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
        if (!addrlen)
                return ERR(EINVAL);
 
+       if (af_ib_support)
+               return rdma_bind_addr2(id, addr, addrlen);
+
        CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_BIND_IP, size);
        id_priv = container_of(id, struct cma_id_private, id);
        cmd->id = id_priv->handle;