@@ -71,7 +71,7 @@ static int efa_dgram_ep_close(fid_t fid)
71
71
static int efa_dgram_ep_bind (struct fid * fid , struct fid * bfid , uint64_t flags )
72
72
{
73
73
struct efa_dgram_ep * ep ;
74
- struct efa_dgram_cq * cq ;
74
+ struct efa_cq * cq ;
75
75
struct efa_av * av ;
76
76
struct util_eq * eq ;
77
77
struct util_cntr * cntr ;
@@ -94,24 +94,14 @@ static int efa_dgram_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
94
94
if (!(flags & (FI_RECV | FI_TRANSMIT )))
95
95
return - FI_EBADFLAGS ;
96
96
97
- cq = container_of (bfid , struct efa_dgram_cq , util_cq .cq_fid );
97
+ cq = container_of (bfid , struct efa_cq , util_cq .cq_fid );
98
98
if (ep -> base_ep .domain != cq -> domain )
99
99
return - FI_EINVAL ;
100
100
101
101
ret = ofi_ep_bind_cq (& ep -> base_ep .util_ep , & cq -> util_cq , flags );
102
102
if (ret )
103
103
return ret ;
104
104
105
- if (flags & FI_RECV ) {
106
- if (ep -> rcq )
107
- return - EINVAL ;
108
- ep -> rcq = cq ;
109
- }
110
- if (flags & FI_TRANSMIT ) {
111
- if (ep -> scq )
112
- return - EINVAL ;
113
- ep -> scq = cq ;
114
- }
115
105
break ;
116
106
case FI_CLASS_AV :
117
107
av = container_of (bfid , struct efa_av , util_av .av_fid .fid );
@@ -186,46 +176,47 @@ static int efa_dgram_ep_setflags(struct fid_ep *ep_fid, uint64_t flags)
186
176
static int efa_dgram_ep_enable (struct fid_ep * ep_fid )
187
177
{
188
178
struct ibv_qp_init_attr_ex attr_ex = { 0 };
189
- struct ibv_pd * ibv_pd ;
190
179
struct efa_dgram_ep * ep ;
180
+ struct efa_cq * scq , * rcq ;
191
181
int err ;
192
182
193
183
ep = container_of (ep_fid , struct efa_dgram_ep , base_ep .util_ep .ep_fid );
194
184
195
- if (!ep -> scq && !ep -> rcq ) {
185
+ scq = ep -> base_ep .util_ep .tx_cq ? container_of (ep -> base_ep .util_ep .tx_cq , struct efa_cq , util_cq ) : NULL ;
186
+ rcq = ep -> base_ep .util_ep .rx_cq ? container_of (ep -> base_ep .util_ep .rx_cq , struct efa_cq , util_cq ) : NULL ;
187
+
188
+ if (!scq && !rcq ) {
196
189
EFA_WARN (FI_LOG_EP_CTRL ,
197
190
"Endpoint is not bound to a send or receive completion queue\n" );
198
191
return - FI_ENOCQ ;
199
192
}
200
193
201
- if (!ep -> scq && ofi_send_allowed (ep -> base_ep .info -> caps )) {
194
+ if (!scq && ofi_needs_tx (ep -> base_ep .info -> caps )) {
202
195
EFA_WARN (FI_LOG_EP_CTRL ,
203
196
"Endpoint is not bound to a send completion queue when it has transmit capabilities enabled (FI_SEND).\n" );
204
197
return - FI_ENOCQ ;
205
198
}
206
199
207
- if (!ep -> rcq && ofi_recv_allowed (ep -> base_ep .info -> caps )) {
200
+ if (!rcq && ofi_needs_rx (ep -> base_ep .info -> caps )) {
208
201
EFA_WARN (FI_LOG_EP_CTRL ,
209
202
"Endpoint is not bound to a receive completion queue when it has receive capabilities enabled. (FI_RECV)\n" );
210
203
return - FI_ENOCQ ;
211
204
}
212
205
213
- if (ep -> scq ) {
206
+ if (scq ) {
214
207
attr_ex .cap .max_send_wr = ep -> base_ep .info -> tx_attr -> size ;
215
208
attr_ex .cap .max_send_sge = ep -> base_ep .info -> tx_attr -> iov_limit ;
216
- attr_ex .send_cq = ibv_cq_ex_to_cq (ep -> scq -> ibv_cq_ex );
217
- ibv_pd = ep -> scq -> domain -> ibv_pd ;
209
+ attr_ex .send_cq = ibv_cq_ex_to_cq (scq -> ibv_cq_ex );
218
210
} else {
219
- attr_ex .send_cq = ibv_cq_ex_to_cq (ep -> rcq -> ibv_cq_ex );
220
- ibv_pd = ep -> rcq -> domain -> ibv_pd ;
211
+ attr_ex .send_cq = ibv_cq_ex_to_cq (rcq -> ibv_cq_ex );
221
212
}
222
213
223
- if (ep -> rcq ) {
214
+ if (rcq ) {
224
215
attr_ex .cap .max_recv_wr = ep -> base_ep .info -> rx_attr -> size ;
225
216
attr_ex .cap .max_recv_sge = ep -> base_ep .info -> rx_attr -> iov_limit ;
226
- attr_ex .recv_cq = ibv_cq_ex_to_cq (ep -> rcq -> ibv_cq_ex );
217
+ attr_ex .recv_cq = ibv_cq_ex_to_cq (rcq -> ibv_cq_ex );
227
218
} else {
228
- attr_ex .recv_cq = ibv_cq_ex_to_cq (ep -> scq -> ibv_cq_ex );
219
+ attr_ex .recv_cq = ibv_cq_ex_to_cq (scq -> ibv_cq_ex );
229
220
}
230
221
231
222
attr_ex .cap .max_inline_data =
@@ -234,7 +225,7 @@ static int efa_dgram_ep_enable(struct fid_ep *ep_fid)
234
225
assert (EFA_EP_TYPE_IS_DGRAM (ep -> base_ep .domain -> info ));
235
226
attr_ex .qp_type = IBV_QPT_UD ;
236
227
attr_ex .comp_mask = IBV_QP_INIT_ATTR_PD ;
237
- attr_ex .pd = ibv_pd ;
228
+ attr_ex .pd = container_of ( ep -> base_ep . util_ep . domain , struct efa_domain , util_domain ) -> ibv_pd ;
238
229
239
230
attr_ex .qp_context = ep ;
240
231
attr_ex .sq_sig_all = 1 ;
@@ -277,89 +268,19 @@ static struct fi_ops efa_dgram_ep_ops = {
277
268
.ops_open = fi_no_ops_open ,
278
269
};
279
270
280
- static void efa_dgram_ep_progress_internal (struct efa_dgram_ep * ep , struct efa_dgram_cq * efa_dgram_cq )
271
+ /**
272
+ * @brief progress engine for the EFA dgram endpoint
273
+ *
274
+ * This function now a no-op.
275
+ *
276
+ * @param[in] util_ep The endpoint FID to progress
277
+ */
278
+ static
279
+ void efa_ep_progress_no_op (struct util_ep * util_ep )
281
280
{
282
- struct util_cq * cq ;
283
- struct fi_cq_tagged_entry cq_entry [efa_dgram_cq_PROGRESS_ENTRIES ] = {0 };
284
- struct fi_cq_tagged_entry * temp_cq_entry ;
285
- struct fi_cq_err_entry cq_err_entry = {0 };
286
- fi_addr_t src_addr [efa_dgram_cq_PROGRESS_ENTRIES ];
287
- uint64_t flags ;
288
- int i ;
289
- ssize_t ret , err ;
290
-
291
- cq = & efa_dgram_cq -> util_cq ;
292
- flags = ep -> base_ep .util_ep .caps ;
293
-
294
- VALGRIND_MAKE_MEM_DEFINED (& cq_entry , sizeof (cq_entry ));
295
-
296
- ret = efa_dgram_cq_readfrom (& cq -> cq_fid , cq_entry , efa_dgram_cq_PROGRESS_ENTRIES ,
297
- (flags & FI_SOURCE ) ? src_addr : NULL );
298
- if (ret == - FI_EAGAIN )
299
- return ;
300
-
301
- if (OFI_UNLIKELY (ret < 0 )) {
302
- if (OFI_UNLIKELY (ret != - FI_EAVAIL )) {
303
- EFA_WARN (FI_LOG_CQ , "no error available errno: %ld\n" , ret );
304
- efa_base_ep_write_eq_error (& ep -> base_ep , - ret , FI_EFA_ERR_DGRAM_CQ_READ );
305
- return ;
306
- }
307
-
308
- err = efa_dgram_cq_readerr (& cq -> cq_fid , & cq_err_entry , flags );
309
- if (OFI_UNLIKELY (err < 0 )) {
310
- EFA_WARN (FI_LOG_CQ , "unable to read error entry errno: %ld\n" , err );
311
- efa_base_ep_write_eq_error (& ep -> base_ep , FI_EIO , cq_err_entry .prov_errno );
312
- return ;
313
- }
314
-
315
- ofi_cq_write_error (cq , & cq_err_entry );
316
- return ;
317
- }
318
-
319
- temp_cq_entry = (struct fi_cq_tagged_entry * )cq_entry ;
320
- for (i = 0 ; i < ret ; i ++ ) {
321
- (flags & FI_SOURCE ) ?
322
- ofi_cq_write_src (cq , temp_cq_entry -> op_context ,
323
- temp_cq_entry -> flags ,
324
- temp_cq_entry -> len ,
325
- temp_cq_entry -> buf ,
326
- temp_cq_entry -> data ,
327
- temp_cq_entry -> tag ,
328
- src_addr [i ]) :
329
- ofi_cq_write (cq , temp_cq_entry -> op_context ,
330
- temp_cq_entry -> flags ,
331
- temp_cq_entry -> len ,
332
- temp_cq_entry -> buf ,
333
- temp_cq_entry -> data ,
334
- temp_cq_entry -> tag );
335
-
336
- temp_cq_entry = (struct fi_cq_tagged_entry * )
337
- ((uint8_t * )temp_cq_entry + efa_dgram_cq -> entry_size );
338
- }
339
281
return ;
340
282
}
341
283
342
- void efa_dgram_ep_progress (struct util_ep * ep )
343
- {
344
- struct efa_dgram_ep * efa_dgram_ep ;
345
- struct efa_dgram_cq * rcq ;
346
- struct efa_dgram_cq * scq ;
347
-
348
- efa_dgram_ep = container_of (ep , struct efa_dgram_ep , base_ep .util_ep );
349
- rcq = efa_dgram_ep -> rcq ;
350
- scq = efa_dgram_ep -> scq ;
351
-
352
- ofi_genlock_lock (& ep -> lock );
353
-
354
- if (rcq )
355
- efa_dgram_ep_progress_internal (efa_dgram_ep , rcq );
356
-
357
- if (scq && scq != rcq )
358
- efa_dgram_ep_progress_internal (efa_dgram_ep , scq );
359
-
360
- ofi_genlock_unlock (& ep -> lock );
361
- }
362
-
363
284
static struct fi_ops_atomic efa_dgram_ep_atomic_ops = {
364
285
.size = sizeof (struct fi_ops_atomic ),
365
286
.write = fi_no_atomic_write ,
@@ -433,7 +354,7 @@ int efa_dgram_ep_open(struct fid_domain *domain_fid, struct fi_info *user_info,
433
354
if (!ep )
434
355
return - FI_ENOMEM ;
435
356
436
- ret = efa_base_ep_construct (& ep -> base_ep , domain_fid , user_info , efa_dgram_ep_progress , context );
357
+ ret = efa_base_ep_construct (& ep -> base_ep , domain_fid , user_info , efa_ep_progress_no_op , context );
437
358
if (ret )
438
359
goto err_ep_destroy ;
439
360
0 commit comments