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_create_cq_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 };
50
51
53 In order to poll an extended CQ efficiently, a user could use the fol‐
54 lowing functions.
55
56
57 Completion iterator functions
58
59 int ibv_start_poll(struct ibv_cq_ex *cq, struct ibv_poll_cq_attr
60 *attr)
61 Start polling a batch of work completions. attr is given in
62 order to make this function easily extensible in the future.
63 This function either returns 0 on success or an error code oth‐
64 erwise. When no completions are available on the CQ, ENOENT is
65 returned, but the CQ remains in a valid state. On success,
66 querying the completion's attribute could be done using the
67 query functions described below. If an error code is given,
68 end_poll shouldn't be called.
69
70 int ibv_next_poll(struct ibv_cq_ex *cq)
71 This function is called in order to get the next work comple‐
72 tion. It has to be called after start_poll and before end_poll
73 are called. This function either returns 0 on success or an
74 error code otherwise. When no completions are available on the
75 CQ, ENOENT is returned, but the CQ remains in a valid state. On
76 success, querying the completion's attribute could be done using
77 the query functions described below. If an error code is given,
78 end_poll should still be called, indicating this is the end of
79 the polled batch.
80
81 void ibv_end_poll(struct ibv_cq_ex *cq)
82 This function indicates the end of polling batch of work comple‐
83 tions. After calling this function, the user should start a new
84 batch by calling start_poll.
85
86
87 Polling fields in the completion
88 Below members and functions are used in order to poll the cur‐
89 rent completion. The current completion is the completion which
90 the iterator points to (start_poll and next_poll advances this
91 iterator). Only fields that the user requested via wc_flags in
92 ibv_create_cq_ex could be queried. In addition, some fields are
93 only valid in certain opcodes and status codes.
94
95 uint64_t wr_id - Can be accessed directly from struct ibv_cq_ex.
96
97 enum ibv_wc_status - Can be accessed directly from struct
98 ibv_cq_ex.
99
100 enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex *cq); Get
101 the opcode from the current completion.
102
103 uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex *cq); Get the
104 vendor error from the current completion.
105
106 uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex *cq); Get the
107 vendor error from the current completion.
108
109 __be32 ibv_wc_read_imm_data(struct ibv_cq_ex *cq); Get the imme‐
110 diate data field from the current completion.
111
112 uint32_t ibv_wc_read_invalidated_rkey(struct ibv_cq_ex *cq); Get
113 the rkey invalided by the SEND_INVAL from the current comple‐
114 tion.
115
116 uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex *cq); Get the QP
117 number field from the current completion.
118
119 uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex *cq); Get the
120 source QP number field from the current completion.
121
122 int ibv_wc_read_wc_flags(struct ibv_cq_ex *cq); Get the QP flags
123 field from the current completion.
124
125 uint16_t ibv_wc_read_pkey_index(struct ibv_cq_ex *cq); Get the
126 pkey index field from the current completion.
127
128 uint32_t ibv_wc_read_slid(struct ibv_cq_ex *cq); Get the slid
129 field from the current completion.
130
131 uint8_t ibv_wc_read_sl(struct ibv_cq_ex *cq); Get the sl field
132 from the current completion.
133
134 uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex *cq); Get
135 the dlid_path_bits field from the current completion.
136
137 uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex *cq); Get
138 the completion timestamp from the current completion in HCA
139 clock units.
140
141 uint64_t ibv_wc_read_completion_wallclock_ns(struct ibv_cq_ex
142 *cq); Get the completion timestamp from the current completion
143 and convert it from HCA clock units to wall clock nanoseconds.
144
145 uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex *cq); Get the CVLAN
146 field from the current completion.
147
148 uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex *cq); Get flow
149 tag from the current completion.
150
151 void ibv_wc_read_tm_info(struct ibv_cq_ex *cq, struct
152 ibv_wc_tm_info *tm_info); Get tag matching info from the cur‐
153 rent completion.
154 struct ibv_wc_tm_info {
155 uint64_t tag; /* tag from TMH */
156 uint32_t priv; /* opaque user data from TMH */
157 };
158
159
161 ibv_create_cq_ex() returns a pointer to the CQ, or NULL if the request
162 fails.
163
165 ibv_create_cq_ex() may create a CQ with size greater than or equal to
166 the requested size. Check the cqe attribute in the returned CQ for the
167 actual size.
168
169 CQ should be destroyed with ibv_destroy_cq.
170
172 ibv_create_cq(3), ibv_destroy_cq(3), ibv_resize_cq(3),
173 ibv_req_notify_cq(3), ibv_ack_cq_events(3), ibv_create_qp(3)
174
176 Matan Barak <matanb@mellanox.com>
177
178
179
180libibverbs 2016-05-08 IBV_CREATE_CQ_EX(3)