1IBV_CREATE_CQ_EX(3) Libibverbs Programmer's Manual IBV_CREATE_CQ_EX(3)
2
3
4
6 ibv_create_cq_ex - create a completion queue (CQ)
7
9 #include <infiniband/verbs.h>
10
11 struct ibv_cq_ex *ibv_create_cq_ex(struct ibv_context *context,
12 struct ibv_cq_init_attr_ex *cq_attr);
13
15 ibv_create_cq_ex() creates a completion queue (CQ) for RDMA device con‐
16 text context. The argument cq_attr is a pointer to struct
17 ibv_cq_init_attr_ex as defined in <infiniband/verbs.h>.
18
19 struct ibv_cq_init_attr_ex {
20 int cqe; /* Minimum number of entries required for CQ */
21 void *cq_context; /* Consumer-supplied context returned for completion events */
22 struct ibv_comp_channel *channel; /* Completion channel where completion events will be queued. May be NULL if completion events will not be used. */
23 int comp_vector; /* Completion vector used to signal completion events. Must be >= 0 and < context->num_comp_vectors. */
24 uint64_t wc_flags; /* The wc_flags that should be returned in ibv_poll_cq_ex. Or'ed bit of enum ibv_wc_flags_ex. */
25 uint32_t comp_mask; /* compatibility mask (extended verb). */
26 uint32_t flags /* One or more flags from enum ibv_create_cq_attr_flags */
27 };
28
29 enum ibv_wc_flags_ex {
30 IBV_WC_EX_WITH_BYTE_LEN = 1 << 0, /* Require byte len in WC */
31 IBV_WC_EX_WITH_IMM = 1 << 1, /* Require immediate in WC */
32 IBV_WC_EX_WITH_QP_NUM = 1 << 2, /* Require QP number in WC */
33 IBV_WC_EX_WITH_SRC_QP = 1 << 3, /* Require source QP in WC */
34 IBV_WC_EX_WITH_SLID = 1 << 4, /* Require slid in WC */
35 IBV_WC_EX_WITH_SL = 1 << 5, /* Require sl in WC */
36 IBV_WC_EX_WITH_DLID_PATH_BITS = 1 << 6, /* Require dlid path bits in WC */
37 IBV_WC_EX_WITH_COMPLETION_TIMESTAMP = 1 << 7, /* Require completion device timestamp in WC /*
38 IBV_WC_EX_WITH_CVLAN = 1 << 8, /* Require VLAN info in WC */
39 IBV_WC_EX_WITH_FLOW_TAG = 1 << 9, /* Require flow tag in WC */
40 IBV_WC_EX_WITH_COMPLETION_TIMESTAMP_WALLCLOCK = 1 << 11, /* Require completion wallclock timestamp in WC */
41 };
42
43 enum ibv_cq_init_attr_mask {
44 IBV_CQ_INIT_ATTR_MASK_FLAGS = 1 << 0,
45 };
46
47 enum ibv_create_cq_attr_flags {
48 IBV_CREATE_CQ_ATTR_SINGLE_THREADED = 1 << 0, /* This CQ is used from a single threaded, thus no locking is required */
49 IBV_CREATE_CQ_ATTR_IGNORE_OVERRUN = 1 << 1, /* This CQ will not pass to error state if overrun, CQE always will be written to next entry.
50 * An application must be designed to avoid ever overflowing the CQ, otherwise CQEs might be lost.
51 */
52 };
53
54
56 In order to poll an extended CQ efficiently, a user could use the fol‐
57 lowing functions.
58
59
60 Completion iterator functions
61
62 int ibv_start_poll(struct ibv_cq_ex *cq, struct ibv_poll_cq_attr
63 *attr)
64 Start polling a batch of work completions. attr is given in
65 order to make this function easily extensible in the future.
66 This function either returns 0 on success or an error code oth‐
67 erwise. When no completions are available on the CQ, ENOENT is
68 returned, but the CQ remains in a valid state. On success,
69 querying the completion's attribute could be done using the
70 query functions described below. If an error code is given,
71 end_poll shouldn't be called.
72
73 int ibv_next_poll(struct ibv_cq_ex *cq)
74 This function is called in order to get the next work comple‐
75 tion. It has to be called after start_poll and before end_poll
76 are called. This function either returns 0 on success or an
77 error code otherwise. When no completions are available on the
78 CQ, ENOENT is returned, but the CQ remains in a valid state. On
79 success, querying the completion's attribute could be done using
80 the query functions described below. If an error code is given,
81 end_poll should still be called, indicating this is the end of
82 the polled batch.
83
84 void ibv_end_poll(struct ibv_cq_ex *cq)
85 This function indicates the end of polling batch of work comple‐
86 tions. After calling this function, the user should start a new
87 batch by calling start_poll.
88
89
90 Polling fields in the completion
91 Below members and functions are used in order to poll the cur‐
92 rent completion. The current completion is the completion which
93 the iterator points to (start_poll and next_poll advances this
94 iterator). Only fields that the user requested via wc_flags in
95 ibv_create_cq_ex could be queried. In addition, some fields are
96 only valid in certain opcodes and status codes.
97
98 uint64_t wr_id - Can be accessed directly from struct ibv_cq_ex.
99
100 enum ibv_wc_status - Can be accessed directly from struct
101 ibv_cq_ex.
102
103 enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex *cq); Get
104 the opcode from the current completion.
105
106 uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex *cq); Get the
107 vendor error from the current completion.
108
109 uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex *cq); Get the
110 vendor error from the current completion.
111
112 __be32 ibv_wc_read_imm_data(struct ibv_cq_ex *cq); Get the imme‐
113 diate data field from the current completion.
114
115 uint32_t ibv_wc_read_invalidated_rkey(struct ibv_cq_ex *cq); Get
116 the rkey invalided by the SEND_INVAL from the current comple‐
117 tion.
118
119 uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex *cq); Get the QP
120 number field from the current completion.
121
122 uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex *cq); Get the
123 source QP number field from the current completion.
124
125 int ibv_wc_read_wc_flags(struct ibv_cq_ex *cq); Get the QP flags
126 field from the current completion.
127
128 uint16_t ibv_wc_read_pkey_index(struct ibv_cq_ex *cq); Get the
129 pkey index field from the current completion.
130
131 uint32_t ibv_wc_read_slid(struct ibv_cq_ex *cq); Get the slid
132 field from the current completion.
133
134 uint8_t ibv_wc_read_sl(struct ibv_cq_ex *cq); Get the sl field
135 from the current completion.
136
137 uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex *cq); Get
138 the dlid_path_bits field from the current completion.
139
140 uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex *cq); Get
141 the completion timestamp from the current completion in HCA
142 clock units.
143
144 uint64_t ibv_wc_read_completion_wallclock_ns(struct ibv_cq_ex
145 *cq); Get the completion timestamp from the current completion
146 and convert it from HCA clock units to wall clock nanoseconds.
147
148 uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex *cq); Get the CVLAN
149 field from the current completion.
150
151 uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex *cq); Get flow
152 tag from the current completion.
153
154 void ibv_wc_read_tm_info(struct ibv_cq_ex *cq, struct
155 ibv_wc_tm_info *tm_info); Get tag matching info from the cur‐
156 rent completion.
157 struct ibv_wc_tm_info {
158 uint64_t tag; /* tag from TMH */
159 uint32_t priv; /* opaque user data from TMH */
160 };
161
162
164 ibv_create_cq_ex() returns a pointer to the CQ, or NULL if the request
165 fails.
166
168 ibv_create_cq_ex() may create a CQ with size greater than or equal to
169 the requested size. Check the cqe attribute in the returned CQ for the
170 actual size.
171
172 CQ should be destroyed with ibv_destroy_cq.
173
175 ibv_create_cq(3), ibv_destroy_cq(3), ibv_resize_cq(3),
176 ibv_req_notify_cq(3), ibv_ack_cq_events(3), ibv_create_qp(3)
177
179 Matan Barak <matanb@mellanox.com>
180
181
182
183libibverbs 2016-05-08 IBV_CREATE_CQ_EX(3)