Skip to content

Commit e654b3a

Browse files
committed
prov/efa: remove duplicated efa_cq_construct_cq_entry
efa_cq_construct_cq_entry can be replaced by the efa_cq_read_data_entry to avoid duplicated code. Signed-off-by: Shi Jin <[email protected]>
1 parent 49ec2fa commit e654b3a

File tree

1 file changed

+27
-47
lines changed

1 file changed

+27
-47
lines changed

prov/efa/src/efa_cq.c

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ static inline uint64_t efa_cq_opcode_to_fi_flags(enum ibv_wc_opcode opcode) {
3333
}
3434
}
3535

36-
static void efa_cq_construct_cq_entry(struct efa_ibv_cq* cq,
37-
struct fi_cq_tagged_entry *entry, int opcode)
36+
static void efa_cq_read_context_entry(struct efa_ibv_cq *ibv_cq, void *buf, int opcode)
37+
{
38+
struct fi_cq_entry *entry = buf;
39+
40+
entry->op_context = (void *)(uintptr_t)ibv_cq->ibv_cq_ex->wr_id;
41+
}
42+
43+
static inline
44+
void efa_cq_read_entry_common(struct efa_ibv_cq *cq, struct fi_cq_msg_entry *entry, int opcode)
3845
{
3946
struct ibv_cq_ex *ibv_cqx = cq->ibv_cq_ex;
4047

@@ -45,12 +52,21 @@ static void efa_cq_construct_cq_entry(struct efa_ibv_cq* cq,
4552
entry->op_context = NULL;
4653
entry->flags = efa_cq_opcode_to_fi_flags(opcode);
4754
}
48-
4955
entry->len = efa_ibv_cq_wc_read_byte_len(cq);
56+
}
57+
58+
static void efa_cq_read_msg_entry(struct efa_ibv_cq *cq, void *buf, int opcode)
59+
{
60+
efa_cq_read_entry_common(cq, (struct fi_cq_msg_entry *)buf, opcode);
61+
}
62+
63+
static void efa_cq_read_data_entry(struct efa_ibv_cq *cq, void *buf, int opcode)
64+
{
65+
struct fi_cq_data_entry *entry = buf;
66+
67+
efa_cq_read_entry_common(cq, (struct fi_cq_msg_entry *)buf, opcode);
5068
entry->buf = NULL;
5169
entry->data = 0;
52-
entry->tag = 0;
53-
5470
if (efa_ibv_cq_wc_read_wc_flags(cq) & IBV_WC_WITH_IMM) {
5571
entry->flags |= FI_REMOTE_CQ_DATA;
5672
entry->data = efa_ibv_cq_wc_read_imm_data(cq);
@@ -86,7 +102,8 @@ static void efa_cq_handle_error(struct efa_base_ep *base_ep,
86102
struct ibv_cq_ex *ibv_cq_ex = cq->ibv_cq_ex;
87103

88104
memset(&err_entry, 0, sizeof(err_entry));
89-
efa_cq_construct_cq_entry(cq, (struct fi_cq_tagged_entry *) &err_entry, efa_ibv_cq_wc_read_opcode(cq));
105+
/* Use the most informative entry that efa-direct support to construct cq entry for general usage */
106+
efa_cq_read_data_entry(cq, &err_entry, efa_ibv_cq_wc_read_opcode(cq));
90107
err_entry.err = err;
91108
err_entry.prov_errno = prov_errno;
92109

@@ -300,7 +317,8 @@ int efa_cq_poll_ibv_cq(ssize_t cqe_to_process, struct efa_ibv_cq *ibv_cq)
300317
break;
301318
}
302319

303-
efa_cq_construct_cq_entry(ibv_cq, &cq_entry, opcode);
320+
/* Use the most informative entry that efa-direct support to construct cq entry for general usage */
321+
efa_cq_read_data_entry(ibv_cq, &cq_entry, opcode);
304322
EFA_DBG(FI_LOG_CQ,
305323
"Write cq entry of context: %lx, flags: %lx\n",
306324
(size_t) cq_entry.op_context, cq_entry.flags);
@@ -569,45 +587,6 @@ int efa_cq_signal(struct fid_cq *cq_fid)
569587
return 0;
570588
}
571589

572-
static void efa_cq_read_context_entry(struct efa_ibv_cq *ibv_cq, void *buf, int opcode)
573-
{
574-
struct fi_cq_entry *entry = buf;
575-
576-
entry->op_context = (void *)(uintptr_t)ibv_cq->ibv_cq_ex->wr_id;
577-
}
578-
579-
static inline
580-
void efa_cq_read_entry_common(struct efa_ibv_cq *cq, struct fi_cq_msg_entry *entry, int opcode)
581-
{
582-
struct ibv_cq_ex *ibv_cqx = cq->ibv_cq_ex;
583-
584-
if (!efa_cq_wc_is_unsolicited(cq) && ibv_cqx->wr_id) {
585-
entry->op_context = (void *)ibv_cqx->wr_id;
586-
entry->flags = (opcode == IBV_WC_RECV_RDMA_WITH_IMM) ? efa_cq_opcode_to_fi_flags(opcode): ((struct efa_context *) ibv_cqx->wr_id)->completion_flags;
587-
} else {
588-
entry->op_context = NULL;
589-
entry->flags = efa_cq_opcode_to_fi_flags(opcode);
590-
}
591-
entry->len = efa_ibv_cq_wc_read_byte_len(cq);
592-
}
593-
594-
static void efa_cq_read_msg_entry(struct efa_ibv_cq *cq, void *buf, int opcode)
595-
{
596-
efa_cq_read_entry_common(cq, (struct fi_cq_msg_entry *)buf, opcode);
597-
}
598-
599-
static void efa_cq_read_data_entry(struct efa_ibv_cq *cq, void *buf, int opcode)
600-
{
601-
struct fi_cq_data_entry *entry = buf;
602-
603-
efa_cq_read_entry_common(cq, (struct fi_cq_msg_entry *)buf, opcode);
604-
entry->data = 0;
605-
if (efa_ibv_cq_wc_read_wc_flags(cq) & IBV_WC_WITH_IMM) {
606-
entry->flags |= FI_REMOTE_CQ_DATA;
607-
entry->data = efa_ibv_cq_wc_read_imm_data(cq);
608-
}
609-
}
610-
611590
static inline fi_addr_t efa_cq_get_src_addr(struct efa_ibv_cq *ibv_cq, int opcode)
612591
{
613592
struct efa_cq *efa_cq;
@@ -661,7 +640,8 @@ static inline void efa_cq_fill_err_entry(struct efa_ibv_cq *ibv_cq, struct fi_cq
661640
int prov_errno = efa_ibv_cq_wc_read_vendor_err(ibv_cq);
662641
fi_addr_t addr;
663642

664-
efa_cq_construct_cq_entry(ibv_cq, (struct fi_cq_tagged_entry *) buf, opcode);
643+
/* Use the most informative entry that efa-direct support to construct cq entry for general usage */
644+
efa_cq_read_data_entry(ibv_cq, buf, opcode);
665645
buf->err = to_fi_errno(prov_errno);
666646
buf->prov_errno = prov_errno;
667647

0 commit comments

Comments
 (0)