1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2011-2012 Los Alamos National Security, LLC. All rights
4  *                         reserved.
5  *               2014      Mellanox Technologies, Inc.
6  *                         All rights reserved.
7  * $COPYRIGHT$
8  *
9  * Additional copyrights may follow
10  *
11  * $HEADER$
12  *
13  */
14 
15 #if !defined(MCA_OOB_UD_QP_H)
16 #define MCA_OOB_UD_QP_H
17 
18 #include "orte_config.h"
19 
20 #ifdef HAVE_SYS_TYPES_H
21 #include <sys/types.h>
22 #endif
23 
24 #include "orte/types.h"
25 
26 #include "opal/mca/base/base.h"
27 #include "opal/class/opal_free_list.h"
28 #include "opal/class/opal_hash_table.h"
29 #include "opal/threads/mutex.h"
30 #include "opal/threads/condition.h"
31 #include "opal/threads/threads.h"
32 #include "opal/mca/timer/base/base.h"
33 
34 #include "orte/mca/oob/oob.h"
35 #include "orte/mca/oob/base/base.h"
36 
37 #include <infiniband/verbs.h>
38 
39 
40 enum mca_oob_ud_qp_type_t {
41     MCA_OOB_UD_QP_DATA,
42     MCA_OOB_UD_QP_LISTEN
43 };
44 
45 struct mca_oob_ud_port_t;
46 
47 struct mca_oob_ud_qp_t {
48     opal_free_list_item_t super;
49     enum mca_oob_ud_qp_type_t type;
50 
51     struct ibv_qp *ib_qp;
52     struct mca_oob_ud_port_t *port;
53 
54     struct ibv_cq *ib_send_cq, *ib_recv_cq;
55 };
56 typedef struct mca_oob_ud_qp_t mca_oob_ud_qp_t;
57 OBJ_CLASS_DECLARATION(mca_oob_ud_qp_t);
58 
59 int mca_oob_ud_qp_init (mca_oob_ud_qp_t *qp, struct mca_oob_ud_port_t *port,
60                         struct ibv_comp_channel *recv_channel,
61                         struct ibv_comp_channel *send_channel, bool onecq);
62 
63 int mca_oob_ud_qp_to_reset (mca_oob_ud_qp_t *qp);
64 int mca_oob_ud_qp_to_rts (mca_oob_ud_qp_t *qp);
65 int mca_oob_ud_qp_purge (mca_oob_ud_qp_t *qp);
66 
67 int mca_oob_ud_qp_post_send (mca_oob_ud_qp_t *qp, struct ibv_send_wr *wr, int num_completions);
68 int mca_oob_ud_qp_post_recv (mca_oob_ud_qp_t *qp, struct ibv_recv_wr *wr);
69 
70 int mca_oob_ud_qp_data_aquire (struct mca_oob_ud_port_t *port, mca_oob_ud_qp_t **qp_ptr);
71 int mca_oob_ud_qp_data_release (mca_oob_ud_qp_t *qp);
72 
73 #endif
74