00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef RDMA_FACTORIES_H
00022 #define RDMA_FACTORIES_H
00023
00024 #include "rdma_exception.h"
00025
00026 #include <rdma/rdma_cma.h>
00027
00028 #include <boost/shared_ptr.hpp>
00029
00030 namespace Rdma {
00031
00032 void acker(::rdma_cm_event* e) throw ();
00033 void destroyEChannel(::rdma_event_channel* c) throw ();
00034 void destroyId(::rdma_cm_id* i) throw ();
00035 void deallocPd(::ibv_pd* p) throw ();
00036 void destroyCChannel(::ibv_comp_channel* c) throw ();
00037 void destroyCq(::ibv_cq* cq) throw ();
00038 void destroyQp(::ibv_qp* qp) throw ();
00039
00040 inline boost::shared_ptr< ::rdma_event_channel > mkEChannel() {
00041 return
00042 boost::shared_ptr< ::rdma_event_channel >(::rdma_create_event_channel(), destroyEChannel);
00043 }
00044
00045 inline boost::shared_ptr< ::rdma_cm_id >
00046 mkId(::rdma_event_channel* ec, void* context, ::rdma_port_space ps) {
00047 ::rdma_cm_id* i;
00048 CHECK(::rdma_create_id(ec, &i, context, ps));
00049 return boost::shared_ptr< ::rdma_cm_id >(i, destroyId);
00050 }
00051
00052 inline boost::shared_ptr< ::ibv_pd > allocPd(::ibv_context* c) {
00053 ::ibv_pd* pd = CHECK_NULL(ibv_alloc_pd(c));
00054 return boost::shared_ptr< ::ibv_pd >(pd, deallocPd);
00055 }
00056
00057 inline boost::shared_ptr< ::ibv_comp_channel > mkCChannel(::ibv_context* c) {
00058 ::ibv_comp_channel* cc = CHECK_NULL(::ibv_create_comp_channel(c));
00059 return boost::shared_ptr< ::ibv_comp_channel >(cc, destroyCChannel);
00060 }
00061
00062 inline boost::shared_ptr< ::ibv_cq >
00063 mkCq(::ibv_context* c, int cqe, void* context, ::ibv_comp_channel* cc) {
00064 ::ibv_cq* cq = CHECK_NULL(ibv_create_cq(c, cqe, context, cc, 0));
00065 return boost::shared_ptr< ::ibv_cq >(cq, destroyCq);
00066 }
00067 }
00068
00069 #endif // RDMA_FACTORIES_H