Skip to content

Commit d8e037b

Browse files
committed
prov/efa: Implement FI_CONTEXT2 in EFA Direct
Store the completion flags and peer address in FI_CONTEXT2 and retrieve later when writing cq. Signed-off-by: Jessie Yang <[email protected]>
1 parent a93beca commit d8e037b

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

prov/efa/src/efa.h

+10
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ struct efa_fabric {
107107
#endif
108108
};
109109

110+
struct efa_context {
111+
uint64_t completion_flags;
112+
fi_addr_t addr;
113+
};
114+
115+
#if defined(static_assert) && defined(__x86_64__)
116+
static_assert(sizeof(struct efa_context) <= sizeof(struct fi_context2),
117+
"efa_context must not be larger than fi_context2");
118+
#endif
119+
110120
static inline
111121
int efa_str_to_ep_addr(const char *node, const char *service, struct efa_ep_addr *addr)
112122
{

prov/efa/src/efa_cq.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ static void efa_cq_construct_cq_entry(struct ibv_cq_ex *ibv_cqx,
3636
struct fi_cq_tagged_entry *entry)
3737
{
3838
entry->op_context = (void *)ibv_cqx->wr_id;
39-
entry->flags = efa_cq_opcode_to_fi_flags(ibv_wc_read_opcode(ibv_cqx));
39+
if (!ibv_cq_ex->wr_id)
40+
entry->flags = efa_cq_opcode_to_fi_flags(ibv_wc_read_opcode(ibv_cqx));
41+
else
42+
entry->flags = ((struct efa_context *) ibv_cqx->wr_id)->completion_flags;
4043
entry->len = ibv_wc_read_byte_len(ibv_cqx);
4144
entry->buf = NULL;
4245
entry->data = 0;
@@ -81,8 +84,7 @@ static void efa_cq_handle_error(struct efa_base_ep *base_ep,
8184
err_entry.prov_errno = prov_errno;
8285

8386
if (is_tx)
84-
// TODO: get correct peer addr for TX operation
85-
addr = FI_ADDR_NOTAVAIL;
87+
addr = ((struct efa_context *)ibv_cqx->wr_id)->addr;
8688
else
8789
addr = efa_av_reverse_lookup(base_ep->av,
8890
ibv_wc_read_slid(ibv_cq_ex),

prov/efa/src/efa_msg.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ static inline ssize_t efa_post_recv(struct efa_base_ep *base_ep, const struct fi
101101
wr = &base_ep->efa_recv_wr_vec[wr_index].wr;
102102
wr->num_sge = msg->iov_count;
103103
wr->sg_list = base_ep->efa_recv_wr_vec[wr_index].sge;
104-
wr->wr_id = (uintptr_t) ((flags & FI_COMPLETION) ? msg->context : NULL);
104+
105+
struct efa_context *efa_context = (struct efa_context *) msg->context;
106+
efa_context->completion_flags = FI_RECV | FI_MSG;
107+
efa_context->addr = msg->addr;
108+
wr->wr_id = (uintptr_t) ((flags & FI_COMPLETION) ? efa_context : NULL);
105109

106110
for (i = 0; i < msg->iov_count; i++) {
107111
addr = (uintptr_t)msg->msg_iov[i].iov_base;
@@ -224,7 +228,10 @@ static inline ssize_t efa_post_send(struct efa_base_ep *base_ep, const struct fi
224228
base_ep->is_wr_started = true;
225229
}
226230

227-
qp->ibv_qp_ex->wr_id = (uintptr_t) ((flags & FI_COMPLETION) ? msg->context : NULL);
231+
struct efa_context *efa_context = (struct efa_context *) msg->context;
232+
efa_context->completion_flags = FI_SEND | FI_MSG;
233+
efa_context->addr = msg->addr;
234+
qp->ibv_qp_ex->wr_id = (uintptr_t) ((flags & FI_COMPLETION) ? efa_context : NULL);
228235

229236
if (flags & FI_REMOTE_CQ_DATA) {
230237
ibv_wr_send_imm(qp->ibv_qp_ex, msg->data);

prov/efa/src/efa_rma.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ static inline ssize_t efa_rma_post_read(struct efa_base_ep *base_ep,
9090
ibv_wr_start(qp->ibv_qp_ex);
9191
base_ep->is_wr_started = true;
9292
}
93-
qp->ibv_qp_ex->wr_id = (uintptr_t) ((flags & FI_COMPLETION) ? msg->context : NULL);
93+
94+
struct efa_context *efa_context = (struct efa_context *) msg->context;
95+
efa_context->completion_flags = FI_RMA | FI_READ;
96+
efa_context->addr = msg->addr;
97+
qp->ibv_qp_ex->wr_id = (uintptr_t) ((flags & FI_COMPLETION) ? efa_context : NULL);
9498

9599
/* ep->domain->info->tx_attr->rma_iov_limit is set to 1 */
96100
ibv_wr_rdma_read(qp->ibv_qp_ex, msg->rma_iov[0].key, msg->rma_iov[0].addr);
@@ -225,7 +229,14 @@ static inline ssize_t efa_rma_post_write(struct efa_base_ep *base_ep,
225229
ibv_wr_start(qp->ibv_qp_ex);
226230
base_ep->is_wr_started = true;
227231
}
228-
qp->ibv_qp_ex->wr_id = (uintptr_t) ((flags & FI_COMPLETION) ? msg->context : NULL);
232+
233+
struct efa_context *efa_context = (struct efa_context *) msg->context;
234+
efa_context->completion_flags =
235+
flags & FI_REMOTE_CQ_DATA ?
236+
FI_REMOTE_CQ_DATA | FI_RMA | FI_REMOTE_WRITE :
237+
FI_RMA | FI_WRITE;
238+
efa_context->addr = msg->addr;
239+
qp->ibv_qp_ex->wr_id = (uintptr_t) ((flags & FI_COMPLETION) ? efa_context : NULL);
229240

230241
if (flags & FI_REMOTE_CQ_DATA) {
231242
ibv_wr_rdma_write_imm(qp->ibv_qp_ex, msg->rma_iov[0].key,

0 commit comments

Comments
 (0)