DABC (Data Acquisition Backbone Core)  2.9.9
QueuePair.h
Go to the documentation of this file.
1 /************************************************************
2  * The Data Acquisition Backbone Core (DABC) *
3  ************************************************************
4  * Copyright (C) 2009 - *
5  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
6  * Planckstr. 1, 64291 Darmstadt, Germany *
7  * Contact: http://dabc.gsi.de *
8  ************************************************************
9  * This software can be used under the GPL license *
10  * agreements as stated in LICENSE.txt file *
11  * which is part of the distribution. *
12  ************************************************************/
13 
14 #ifndef VERBS_QueuePair
15 #define VERBS_QueuePair
16 
17 #define VERBS_MAX_INLINE 256
18 #define VERBS_DEFAULT_QKEY 0x01234567
19 #define VERBS_MCAST_QPN 0xffffff
20 #define VERBS_UD_MEMADDON 40
21 
22 #define VERBSQP_RC 0
23 #define VERBSQP_UC 1
24 #define VERBSQP_UD 2
25 
26 #ifndef VERBS_Context
27 #include "verbs/Context.h"
28 #endif
29 
30 namespace verbs {
31 
32  class Device;
33  class ComplQueue;
34 
37  class QueuePair {
38  public:
39  QueuePair(ContextRef ctx, ibv_qp_type qp_type,
40  ComplQueue* send_cq, int send_depth, int max_send_sge,
41  ComplQueue* recv_cq, int recv_depth, int max_recv_sge);
42  virtual ~QueuePair();
43 
44  struct ibv_qp *qp() const { return f_qp; }
45 
46  ibv_qp_type qp_type() const { return fType; }
47  bool is_ud() const { return qp_type()==IBV_QPT_UD; }
48  uint32_t qp_num() const { return f_qp ? f_qp->qp_num : 0; }
49  uint32_t local_psn() const { return f_local_psn; }
50 
51  unsigned NumSendSegs() const { return fNumSendSegs; }
52 
61  bool Connect(uint16_t lid, uint32_t qpn, uint32_t psn, uint8_t src_path_bits = 0);
62 
64  bool InitUD();
65 
66  uint16_t remote_lid() const { return f_remote_lid; }
67  uint32_t remote_qpn() const { return f_remote_qpn; }
68  uint32_t remote_psn() const { return f_remote_psn; }
69 
70  bool Post_Send(struct ibv_send_wr* swr);
71  bool Post_Recv(struct ibv_recv_wr* rwr);
72 
73  bool AttachMcast(ibv_gid* mgid, uint16_t mlid);
74  bool DetachMcast(ibv_gid* mgid, uint16_t mlid);
75 
76  protected:
77  static uint32_t fQPCounter;
78 
80 
81  ibv_qp_type fType;
82 
83  struct ibv_qp *f_qp;
84 
85  uint32_t f_local_psn;
86 
87  uint16_t f_remote_lid;
88  uint32_t f_remote_qpn;
89  uint32_t f_remote_psn;
90 
91  unsigned fNumSendSegs;
92  };
93 }
94 
95 #endif
Wrapper for IB VERBS completion queue
Definition: ComplQueue.h:35
Reference to verbs::Context
Definition: Context.h:74
Represent VERBS queue pair functionality.
Definition: QueuePair.h:37
bool is_ud() const
Definition: QueuePair.h:47
ContextRef fContext
Definition: QueuePair.h:79
QueuePair(ContextRef ctx, ibv_qp_type qp_type, ComplQueue *send_cq, int send_depth, int max_send_sge, ComplQueue *recv_cq, int recv_depth, int max_recv_sge)
Definition: QueuePair.cxx:29
static uint32_t fQPCounter
Definition: QueuePair.h:77
ibv_qp_type fType
Definition: QueuePair.h:81
bool InitUD()
Initialize QP for unreliable datagram protocol.
Definition: QueuePair.cxx:113
uint16_t f_remote_lid
Definition: QueuePair.h:87
unsigned NumSendSegs() const
Definition: QueuePair.h:51
bool Post_Send(struct ibv_send_wr *swr)
Definition: QueuePair.cxx:261
bool Post_Recv(struct ibv_recv_wr *rwr)
Definition: QueuePair.cxx:273
struct ibv_qp * qp() const
Definition: QueuePair.h:44
ibv_qp_type qp_type() const
Definition: QueuePair.h:46
bool DetachMcast(ibv_gid *mgid, uint16_t mlid)
Definition: QueuePair.cxx:290
uint32_t qp_num() const
Definition: QueuePair.h:48
bool AttachMcast(ibv_gid *mgid, uint16_t mlid)
Definition: QueuePair.cxx:285
virtual ~QueuePair()
Definition: QueuePair.cxx:104
uint32_t remote_qpn() const
Definition: QueuePair.h:67
unsigned fNumSendSegs
Definition: QueuePair.h:91
uint32_t local_psn() const
Definition: QueuePair.h:49
uint32_t f_remote_qpn
Definition: QueuePair.h:88
uint16_t remote_lid() const
Definition: QueuePair.h:66
uint32_t f_remote_psn
Definition: QueuePair.h:89
uint32_t f_local_psn
number used in connection
Definition: QueuePair.h:85
uint32_t remote_psn() const
Definition: QueuePair.h:68
struct ibv_qp * f_qp
Definition: QueuePair.h:83
bool Connect(uint16_t lid, uint32_t qpn, uint32_t psn, uint8_t src_path_bits=0)
Connect QP to specified remote queue pair.
Definition: QueuePair.cxx:141
Support of InfiniBand verbs.
Definition: Device.cxx:54