]> git.openfabrics.org - ~shefty/libibcm.git/commitdiff
r4019: Add support for userspace RDMA connection management abstraction (CMA).
authorSean Hefty <sean.hefty@intel.com>
Fri, 11 Nov 2005 00:33:09 +0000 (00:33 +0000)
committerSean Hefty <sean.hefty@intel.com>
Fri, 11 Nov 2005 00:33:09 +0000 (00:33 +0000)
- Adds common user/kernel data structures and copy routines in ib_uverbs and
  libibverbs.
- Update ib_ucm and libibcm to use common structures and copy routines.
- Add new kernel module, rdma_ucm, to support userspace CMA.
- Add userspace CMA library, librdmacm.
- Add userspace CMA test program.
- Update kernel CMA to support userspace CMA library.
- Add support for users to transition QP states.
- Add backlog parameter to rdma_listen API.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Makefile.am
README
configure.in
include/infiniband/cm.h
include/infiniband/cm_abi.h
src/cm.c
src/libibcm.map

index e07ee21ae1acf7e2b9c506875f012dc14a700200..b70af15ee086fc882c8c0e6afd0cd8de650e85c3 100644 (file)
@@ -18,10 +18,6 @@ endif
 src_libibcm_la_SOURCES = src/cm.c
 src_libibcm_la_LDFLAGS = -avoid-version $(ucm_version_script)
 
-bin_PROGRAMS = examples/ucmpost
-examples_ucmpost_SOURCES = examples/cmpost.c
-examples_ucmpost_LDADD = $(top_builddir)/src/libibcm.la
-
 libibcmincludedir = $(includedir)/infiniband
 
 libibcminclude_HEADERS = include/infiniband/cm_abi.h \
diff --git a/README b/README
index 7af9d8548d809d1f9441bdde7775a89944f7ec75..98322c6c1cce804671205ad689b2dcc0712f79a7 100644 (file)
--- a/README
+++ b/README
@@ -12,18 +12,17 @@ Libraries are installed by default at /usr/local/lib.
 
 Device files
 
-The userspace CM uses a single device file regardless of the number
-of adapters or ports present.
+The userspace CM uses a device file per adapter present.
 
 To create the appropriate character device file automatically with
 udev, a rule like
 
-    KERNEL="ucm", NAME="infiniband/%k", MODE="0666"
+    KERNEL="ucm*", NAME="infiniband/%k", MODE="0666"
 
 can be used.  This will create the device node named
 
-    /dev/infiniband/ucm
+    /dev/infiniband/ucm0
 
-or you can create it manually
+for the first HCA in the system, or you can create it manually
 
-  mknod /dev/infiniband/ucm c 231 255
+  mknod /dev/infiniband/ucm0 c 231 255
index e22673e14838c7a6b1ae8f5d0f2e920dfc804697..82df98c4eafeca201b85f8f9d25ee47ef6c41119 100644 (file)
@@ -27,8 +27,6 @@ if test "$disable_libcheck" != "yes"
 then
 AC_CHECK_LIB(ibverbs, ibv_get_devices, [],
     AC_MSG_ERROR([ibv_get_devices() not found.  libibcm requires libibverbs.]))
-AC_CHECK_LIB(ibat, ib_at_route_by_ip, [],
-    AC_MSG_ERROR([ib_at_route_by_ip() not found.  libibcm requires libibat.]))
 fi
 
 dnl Checks for header files.
@@ -36,8 +34,8 @@ if test "$disable_libcheck" != "yes"
 then
 AC_CHECK_HEADER(infiniband/verbs.h, [],
     AC_MSG_ERROR([<infiniband/verbs.h> not found.  Is libibverbs installed?]))
-AC_CHECK_HEADER(infiniband/at.h, [],
-    AC_MSG_ERROR([<infiniband/at.h> not found.  Is libibat installed?]))
+AC_CHECK_HEADER(infiniband/marshall.h, [],
+    AC_MSG_ERROR([<infiniband/marshall.h> not found.  Is libibverbs installed?]))
 fi
 AC_HEADER_STDC
 
index f8bcec3609ae202972d309f84e1a94a4f5fac47b..c57e1459cfbcf24288b646310abbc92d683976a4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2004, 2005 Intel Corporation.  All rights reserved.
  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
  * Copyright (c) 2004 Voltaire Corporation.  All rights reserved.
  *
index 69492fc8ecbaf513d80194175410cf426df9cff8..a3c698c46941e32791b29069b006ba0a55095c20 100644 (file)
@@ -37,6 +37,9 @@
 #define CM_ABI_H
 
 #include <linux/types.h>
+#include <infiniband/sa.h>
+#include <infiniband/marshall.h>
+
 /*
  * This file must be kept in sync with the kernel's version of ib_user_cm.h
  */
@@ -114,58 +117,6 @@ struct cm_abi_init_qp_attr {
        __u32 qp_state;
 };
 
-struct cm_abi_ah_attr {
-       __u8    grh_dgid[16];
-       __u32   grh_flow_label;
-       __u16   dlid;
-       __u16   reserved;
-       __u8    grh_sgid_index;
-       __u8    grh_hop_limit;
-       __u8    grh_traffic_class;
-       __u8    sl;
-       __u8    src_path_bits;
-       __u8    static_rate;
-       __u8    is_global;
-       __u8    port_num;
-};
-
-struct cm_abi_init_qp_attr_resp {
-       __u32   qp_attr_mask;
-       __u32   qp_state;
-       __u32   cur_qp_state;
-       __u32   path_mtu;
-       __u32   path_mig_state;
-       __u32   qkey;
-       __u32   rq_psn;
-       __u32   sq_psn;
-       __u32   dest_qp_num;
-       __u32   qp_access_flags;
-
-       struct cm_abi_ah_attr   ah_attr;
-       struct cm_abi_ah_attr   alt_ah_attr;
-
-       /* ibv_qp_cap */
-       __u32   max_send_wr;
-       __u32   max_recv_wr;
-       __u32   max_send_sge;
-       __u32   max_recv_sge;
-       __u32   max_inline_data;
-
-       __u16   pkey_index;
-       __u16   alt_pkey_index;
-       __u8    en_sqd_async_notify;
-       __u8    sq_draining;
-       __u8    max_rd_atomic;
-       __u8    max_dest_rd_atomic;
-       __u8    min_rnr_timer;
-       __u8    port_num;
-       __u8    timeout;
-       __u8    retry_cnt;
-       __u8    rnr_retry;
-       __u8    alt_port_num;
-       __u8    alt_timeout;
-};
-
 struct cm_abi_listen {
        __u64 service_id;
        __u64 service_mask;
@@ -184,28 +135,6 @@ struct cm_abi_private_data {
        __u8  reserved[3];
 };
 
-struct cm_abi_path_rec {
-       __u8  dgid[16];
-       __u8  sgid[16];
-       __u16 dlid;
-       __u16 slid;
-       __u32 raw_traffic;
-       __u32 flow_label;
-       __u32 reversible;
-       __u32 mtu;
-       __u16 pkey;
-       __u8  hop_limit;
-       __u8  traffic_class;
-       __u8  numb_path;
-       __u8  sl;
-       __u8  mtu_selector;
-       __u8  rate_selector;
-       __u8  rate;
-       __u8  packet_life_time_selector;
-       __u8  packet_life_time;
-       __u8  preference;
-};
-
 struct cm_abi_req {
        __u32 id;
        __u32 qpn;
@@ -308,8 +237,8 @@ struct cm_abi_event_get {
 };
 
 struct cm_abi_req_event_resp {
-       struct cm_abi_path_rec primary_path;
-       struct cm_abi_path_rec alternate_path;
+       struct ib_kern_path_rec primary_path;
+       struct ib_kern_path_rec alternate_path;
        __u64                  remote_ca_guid;
        __u32                  remote_qkey;
        __u32                  remote_qpn;
@@ -353,7 +282,7 @@ struct cm_abi_mra_event_resp {
 };
 
 struct cm_abi_lap_event_resp {
-       struct cm_abi_path_rec path;
+       struct ib_kern_path_rec path;
 };
 
 struct cm_abi_apr_event_resp {
index 2e9ac108691db95888f9dbb1ef97cb09e066d257..a9420e3ae15c0e4569b7fc34d9e812fbff482f5b 100644 (file)
--- a/src/cm.c
+++ b/src/cm.c
@@ -52,6 +52,7 @@
 
 #include <infiniband/cm.h>
 #include <infiniband/cm_abi.h>
+#include <infiniband/marshall.h>
 
 #define PFX "libibcm: "
 
@@ -266,33 +267,6 @@ struct ib_cm_device* ib_cm_get_device(struct ibv_context *device_context)
        return NULL;
 }
 
-static void cm_param_path_get(struct cm_abi_path_rec *abi,
-                             struct ib_sa_path_rec *sa)
-{
-       memcpy(abi->dgid, sa->dgid.raw, sizeof(union ibv_gid));
-       memcpy(abi->sgid, sa->sgid.raw, sizeof(union ibv_gid));
-
-       abi->dlid = sa->dlid;
-       abi->slid = sa->slid;
-
-       abi->raw_traffic  = sa->raw_traffic;
-       abi->flow_label   = sa->flow_label;
-       abi->reversible   = sa->reversible;
-       abi->mtu          = sa->mtu;
-       abi->pkey         = sa->pkey;
-
-       abi->hop_limit                 = sa->hop_limit;
-       abi->traffic_class             = sa->traffic_class;
-       abi->numb_path                 = sa->numb_path;
-       abi->sl                        = sa->sl;
-       abi->mtu_selector              = sa->mtu_selector;
-       abi->rate_selector             = sa->rate_selector;
-       abi->rate                      = sa->rate;
-       abi->packet_life_time_selector = sa->packet_life_time_selector;
-       abi->packet_life_time          = sa->packet_life_time;
-       abi->preference                = sa->preference;
-}
-
 static void ib_cm_free_id(struct cm_id_private *cm_id_priv)
 {
        pthread_cond_destroy(&cm_id_priv->cond);
@@ -407,65 +381,11 @@ int ib_cm_attr_id(struct ib_cm_id *cm_id, struct ib_cm_attr_param *param)
        return 0;
 }
 
-static void ib_cm_copy_ah_attr(struct ibv_ah_attr *dest_attr,
-                              struct cm_abi_ah_attr *src_attr)
-{
-       memcpy(dest_attr->grh.dgid.raw, src_attr->grh_dgid,
-              sizeof dest_attr->grh.dgid);
-       dest_attr->grh.flow_label = src_attr->grh_flow_label;
-       dest_attr->grh.sgid_index = src_attr->grh_sgid_index;
-       dest_attr->grh.hop_limit = src_attr->grh_hop_limit;
-       dest_attr->grh.traffic_class = src_attr->grh_traffic_class;
-
-       dest_attr->dlid = src_attr->dlid;
-       dest_attr->sl = src_attr->sl;
-       dest_attr->src_path_bits = src_attr->src_path_bits;
-       dest_attr->static_rate = src_attr->static_rate;
-       dest_attr->is_global = src_attr->is_global;
-       dest_attr->port_num = src_attr->port_num;
-}
-
-static void ib_cm_copy_qp_attr(struct ibv_qp_attr *dest_attr,
-                              struct cm_abi_init_qp_attr_resp *src_attr)
-{
-       dest_attr->cur_qp_state = src_attr->cur_qp_state;
-       dest_attr->path_mtu = src_attr->path_mtu;
-       dest_attr->path_mig_state = src_attr->path_mig_state;
-       dest_attr->qkey = src_attr->qkey;
-       dest_attr->rq_psn = src_attr->rq_psn;
-       dest_attr->sq_psn = src_attr->sq_psn;
-       dest_attr->dest_qp_num = src_attr->dest_qp_num;
-       dest_attr->qp_access_flags = src_attr->qp_access_flags;
-
-       dest_attr->cap.max_send_wr = src_attr->max_send_wr;
-       dest_attr->cap.max_recv_wr = src_attr->max_recv_wr;
-       dest_attr->cap.max_send_sge = src_attr->max_send_sge;
-       dest_attr->cap.max_recv_sge = src_attr->max_recv_sge;
-       dest_attr->cap.max_inline_data = src_attr->max_inline_data;
-
-       ib_cm_copy_ah_attr(&dest_attr->ah_attr, &src_attr->ah_attr);
-       ib_cm_copy_ah_attr(&dest_attr->alt_ah_attr, &src_attr->alt_ah_attr);
-
-       dest_attr->pkey_index = src_attr->pkey_index;
-       dest_attr->alt_pkey_index = src_attr->alt_pkey_index;
-       dest_attr->en_sqd_async_notify = src_attr->en_sqd_async_notify;
-       dest_attr->sq_draining = src_attr->sq_draining;
-       dest_attr->max_rd_atomic = src_attr->max_rd_atomic;
-       dest_attr->max_dest_rd_atomic = src_attr->max_dest_rd_atomic;
-       dest_attr->min_rnr_timer = src_attr->min_rnr_timer;
-       dest_attr->port_num = src_attr->port_num;
-       dest_attr->timeout = src_attr->timeout;
-       dest_attr->retry_cnt = src_attr->retry_cnt;
-       dest_attr->rnr_retry = src_attr->rnr_retry;
-       dest_attr->alt_port_num = src_attr->alt_port_num;
-       dest_attr->alt_timeout = src_attr->alt_timeout;
-}
-
 int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
                       struct ibv_qp_attr *qp_attr,
                       int *qp_attr_mask)
 {
-       struct cm_abi_init_qp_attr_resp *resp;
+       struct ibv_kern_qp_attr *resp;
        struct cm_abi_init_qp_attr *cmd;
        void *msg;
        int result;
@@ -483,7 +403,7 @@ int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
                return (result > 0) ? -ENODATA : result;
 
        *qp_attr_mask = resp->qp_attr_mask;
-       ib_cm_copy_qp_attr(qp_attr, resp);
+       ib_copy_qp_attr_from_kern(qp_attr, resp);
 
        return 0;
 }
@@ -511,8 +431,8 @@ int ib_cm_listen(struct ib_cm_id *cm_id,
 
 int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
 {
-       struct cm_abi_path_rec *p_path;
-       struct cm_abi_path_rec *a_path;
+       struct ib_kern_path_rec *p_path;
+       struct ib_kern_path_rec *a_path;
        struct cm_abi_req *cmd;
        void *msg;
        int result;
@@ -543,7 +463,7 @@ int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
                if (!p_path)
                        return -ENOMEM;
 
-               cm_param_path_get(p_path, param->primary_path);
+               ib_copy_path_rec_to_kern(p_path, param->primary_path);
                cmd->primary_path = (uintptr_t) p_path;
        }
                
@@ -552,7 +472,7 @@ int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
                if (!a_path)
                        return -ENOMEM;
 
-               cm_param_path_get(a_path, param->alternate_path);
+               ib_copy_path_rec_to_kern(a_path, param->alternate_path);
                cmd->alternate_path = (uintptr_t) a_path;
        }
 
@@ -758,7 +678,7 @@ int ib_cm_send_lap(struct ib_cm_id *cm_id,
                   void *private_data,
                   uint8_t private_data_len)
 {
-       struct cm_abi_path_rec *abi_path;
+       struct ib_kern_path_rec *abi_path;
        struct cm_abi_lap *cmd;
        void *msg;
        int result;
@@ -772,7 +692,7 @@ int ib_cm_send_lap(struct ib_cm_id *cm_id,
                if (!abi_path)
                        return -ENOMEM;
 
-               cm_param_path_get(abi_path, alternate_path);
+               ib_copy_path_rec_to_kern(abi_path, alternate_path);
                cmd->path = (uintptr_t) abi_path;
        }
 
@@ -791,7 +711,7 @@ int ib_cm_send_lap(struct ib_cm_id *cm_id,
 int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
                        struct ib_cm_sidr_req_param *param)
 {
-       struct cm_abi_path_rec *abi_path;
+       struct ib_kern_path_rec *abi_path;
        struct cm_abi_sidr_req *cmd;
        void *msg;
        int result;
@@ -812,7 +732,7 @@ int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
                if (!abi_path)
                        return -ENOMEM;
 
-               cm_param_path_get(abi_path, param->path);
+               ib_copy_path_rec_to_kern(abi_path, param->path);
                cmd->path = (uintptr_t) abi_path;
        }
 
@@ -862,39 +782,6 @@ int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id,
        return 0;
 }
 
-/*
- * event processing
- */
-static void cm_event_path_get(struct ib_sa_path_rec  *upath,
-                             struct cm_abi_path_rec *kpath)
-{
-       if (!kpath || !upath)
-               return;
-
-       memcpy(upath->dgid.raw, kpath->dgid, sizeof upath->dgid);
-       memcpy(upath->sgid.raw, kpath->sgid, sizeof upath->sgid);
-       
-       upath->dlid             = kpath->dlid;
-       upath->slid             = kpath->slid;
-       upath->raw_traffic      = kpath->raw_traffic;
-       upath->flow_label       = kpath->flow_label;
-       upath->hop_limit        = kpath->hop_limit;
-       upath->traffic_class    = kpath->traffic_class;
-       upath->reversible       = kpath->reversible;
-       upath->numb_path        = kpath->numb_path;
-       upath->pkey             = kpath->pkey;
-       upath->sl               = kpath->sl;
-       upath->mtu_selector     = kpath->mtu_selector;
-       upath->mtu              = kpath->mtu;
-       upath->rate_selector    = kpath->rate_selector;
-       upath->rate             = kpath->rate;
-       upath->packet_life_time = kpath->packet_life_time;
-       upath->preference       = kpath->preference;
-
-       upath->packet_life_time_selector = 
-               kpath->packet_life_time_selector;
-}
-
 static void cm_event_req_get(struct ib_cm_req_event_param *ureq,
                             struct cm_abi_req_event_resp *kreq)
 {
@@ -913,8 +800,10 @@ static void cm_event_req_get(struct ib_cm_req_event_param *ureq,
        ureq->srq                        = kreq->srq;
        ureq->port                       = kreq->port;
 
-       cm_event_path_get(ureq->primary_path, &kreq->primary_path);
-       cm_event_path_get(ureq->alternate_path, &kreq->alternate_path);
+       ib_copy_path_rec_from_kern(ureq->primary_path, &kreq->primary_path);
+       if (ureq->alternate_path)
+               ib_copy_path_rec_from_kern(ureq->alternate_path,
+                                          &kreq->alternate_path);
 }
 
 static void cm_event_rep_get(struct ib_cm_rep_event_param *urep,
@@ -1058,8 +947,8 @@ int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
        case IB_CM_LAP_RECEIVED:
                evt->param.lap_rcvd.alternate_path = path_b;
                path_b = NULL;
-               cm_event_path_get(evt->param.lap_rcvd.alternate_path,
-                                 &resp->u.lap_resp.path);
+               ib_copy_path_rec_from_kern(evt->param.lap_rcvd.alternate_path,
+                                          &resp->u.lap_resp.path);
                break;
        case IB_CM_APR_RECEIVED:
                evt->param.apr_rcvd.ap_status = resp->u.apr_resp.status;
index 613475caf751774cc30ff5a663f17814f30f57fd..879b506e9c148ca7a48789fe4721172784d21209 100644 (file)
@@ -1,9 +1,9 @@
-IBCM_1.0 {
+IBCM_4.0 {
        global:
 
-               ib_cm_event_get;
-               ib_cm_event_put;
-               ib_cm_get_fd;
+               ib_cm_get_event;
+               ib_cm_ack_event;
+               ib_cm_get_device;
                ib_cm_create_id;
                ib_cm_destroy_id;
                ib_cm_attr_id;
@@ -20,5 +20,6 @@ IBCM_1.0 {
                ib_cm_send_apr;
                ib_cm_send_sidr_req;
                ib_cm_send_sidr_rep;
+               ib_cm_init_qp_attr;
        local: *;
 };