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