Skip to content

Commit

Permalink
prov/efa: Move efa_rdm_cq_wc_is_unsolicited to efa_cq
Browse files Browse the repository at this point in the history
Move efa_use_unsolicited_write_recv to efa.h
so they can be used outside rdm.

Signed-off-by: Jessie Yang <jiaxiyan@amazon.com>
  • Loading branch information
jiaxiyan authored and shijin-aws committed Jan 7, 2025
1 parent b9b0c32 commit 52a023f
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 36 deletions.
6 changes: 6 additions & 0 deletions prov/efa/src/efa.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,10 @@ static inline void efa_perfset_end(struct efa_rdm_ep *ep, size_t index)
#define efa_perfset_end(ep, index) do {} while (0)
#endif

static inline
bool efa_use_unsolicited_write_recv()
{
return efa_env.use_unsolicited_write_recv && efa_device_support_unsolicited_write_recv();
}

#endif /* EFA_H */
2 changes: 1 addition & 1 deletion prov/efa/src/efa_base_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int efa_qp_create(struct efa_qp **qp, struct ibv_qp_init_attr_ex *init_attr_ex,
init_attr_ex->send_ops_flags |= IBV_QP_EX_WITH_RDMA_WRITE_WITH_IMM;
}
#if HAVE_CAPS_UNSOLICITED_WRITE_RECV
if (efa_rdm_use_unsolicited_write_recv())
if (efa_use_unsolicited_write_recv())
efa_attr.flags |= EFADV_QP_FLAGS_UNSOLICITED_WRITE_RECV;
#endif
efa_attr.driver_qp_type = EFADV_QP_DRIVER_TYPE_SRD;
Expand Down
26 changes: 25 additions & 1 deletion prov/efa/src/efa_cq.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static inline int efa_cq_ibv_cq_ex_open(struct fi_cq_attr *attr,
};

#if HAVE_CAPS_UNSOLICITED_WRITE_RECV
if (efa_rdm_use_unsolicited_write_recv())
if (efa_use_unsolicited_write_recv())
efadv_cq_init_attr.wc_flags |= EFADV_WC_EX_WITH_IS_UNSOLICITED;
#endif

Expand Down Expand Up @@ -176,3 +176,27 @@ static inline int efa_cq_ibv_cq_ex_open(struct fi_cq_attr *attr,
&init_attr_ex, ibv_ctx, ibv_cq_ex, ibv_cq_ex_type);
}
#endif

#if HAVE_CAPS_UNSOLICITED_WRITE_RECV
/**
* @brief Check whether a completion consumes recv buffer
*
* @param ibv_cq_ex extended ibv cq
* @return true the wc consumes a recv buffer
* @return false the wc doesn't consume a recv buffer
*/
static inline
bool efa_cq_wc_is_unsolicited(struct ibv_cq_ex *ibv_cq_ex)
{
return efa_use_unsolicited_write_recv() && efadv_wc_is_unsolicited(efadv_cq_from_ibv_cq_ex(ibv_cq_ex));
}

#else

static inline
bool efa_cq_wc_is_unsolicited(struct ibv_cq_ex *ibv_cq_ex)
{
return false;
}

#endif
27 changes: 2 additions & 25 deletions prov/efa/src/rdm/efa_rdm_cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,6 @@ static struct fi_ops efa_rdm_cq_fi_ops = {
};


#if HAVE_CAPS_UNSOLICITED_WRITE_RECV
/**
* @brief Check whether a completion consumes recv buffer
*
* @param ibv_cq_ex extended ibv cq
* @return true the wc consumes a recv buffer
* @return false the wc doesn't consume a recv buffer
*/
static inline
bool efa_rdm_cq_wc_is_unsolicited(struct ibv_cq_ex *ibv_cq_ex)
{
return efa_rdm_use_unsolicited_write_recv() && efadv_wc_is_unsolicited(efadv_cq_from_ibv_cq_ex(ibv_cq_ex));
}

#else

static inline
bool efa_rdm_cq_wc_is_unsolicited(struct ibv_cq_ex *ibv_cq_ex)
{
return false;
}

#endif
/**
* @brief handle rdma-core CQ completion resulted from IBV_WRITE_WITH_IMM
*
Expand Down Expand Up @@ -148,7 +125,7 @@ void efa_rdm_cq_proc_ibv_recv_rdma_with_imm_completion(
* For unsolicited wc, pkt_entry can be NULL, so we can only
* access it for solicited wc.
*/
if (!efa_rdm_cq_wc_is_unsolicited(ibv_cq_ex)) {
if (!efa_cq_wc_is_unsolicited(ibv_cq_ex)) {
/**
* Recv with immediate will consume a pkt_entry, but the pkt is not
* filled, so free the pkt_entry and record we have one less posted
Expand Down Expand Up @@ -494,7 +471,7 @@ void efa_rdm_cq_poll_ibv_cq(ssize_t cqe_to_process, struct efa_ibv_cq *ibv_cq)
break;
case IBV_WC_RECV: /* fall through */
case IBV_WC_RECV_RDMA_WITH_IMM:
if (efa_rdm_cq_wc_is_unsolicited(ibv_cq->ibv_cq_ex)) {
if (efa_cq_wc_is_unsolicited(ibv_cq->ibv_cq_ex)) {
EFA_WARN(FI_LOG_CQ, "Receive error %s (%d) for unsolicited write recv",
efa_strerror(prov_errno), prov_errno);
efa_base_ep_write_eq_error(&ep->base_ep, to_fi_errno(prov_errno), prov_errno);
Expand Down
2 changes: 1 addition & 1 deletion prov/efa/src/rdm/efa_rdm_ep_fiops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ void efa_rdm_ep_set_extra_info(struct efa_rdm_ep *ep)

ep->extra_info[0] |= EFA_RDM_EXTRA_FEATURE_DELIVERY_COMPLETE;

if (efa_rdm_use_unsolicited_write_recv())
if (efa_use_unsolicited_write_recv())
ep->extra_info[0] |= EFA_RDM_EXTRA_FEATURE_UNSOLICITED_WRITE_RECV;

if (ep->use_zcpy_rx) {
Expand Down
2 changes: 1 addition & 1 deletion prov/efa/src/rdm/efa_rdm_rma.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ ssize_t efa_rdm_rma_post_write(struct efa_rdm_ep *ep, struct efa_rdm_ope *txe)
"This is usually caused by inconsistent efa driver, libfabric, or rdma-core versions.\n"
"Please use consistent software versions on both hosts, or disable the unsolicited write "
"recv feature by setting environment variable FI_EFA_USE_UNSOLICITED_WRITE_RECV=0\n",
efa_rdm_use_unsolicited_write_recv(), efa_rdm_peer_support_unsolicited_write_recv(txe->peer),
efa_use_unsolicited_write_recv(), efa_rdm_peer_support_unsolicited_write_recv(txe->peer),
ep->err_msg);
return -FI_EOPNOTSUPP;
}
Expand Down
5 changes: 0 additions & 5 deletions prov/efa/src/rdm/efa_rdm_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,5 @@ static inline void efa_rdm_poison_mem_region(void *ptr, size_t size)
}
#endif

static inline
bool efa_rdm_use_unsolicited_write_recv()
{
return efa_env.use_unsolicited_write_recv && efa_device_support_unsolicited_write_recv();
}

#endif /* _EFA_RDM_UTIL_H */
2 changes: 1 addition & 1 deletion prov/efa/test/efa_unit_test_cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void test_ibv_cq_ex_read_bad_recv_status(struct efa_resource **state)
efa_rdm_cq->ibv_cq.ibv_cq_ex->status = IBV_WC_GENERAL_ERR;

#if HAVE_CAPS_UNSOLICITED_WRITE_RECV
if (efa_rdm_use_unsolicited_write_recv()) {
if (efa_use_unsolicited_write_recv()) {
efadv_cq_from_ibv_cq_ex(efa_rdm_cq->ibv_cq.ibv_cq_ex)->wc_is_unsolicited = &efa_mock_efadv_wc_is_unsolicited;
will_return(efa_mock_efadv_wc_is_unsolicited, false);
}
Expand Down
2 changes: 1 addition & 1 deletion prov/efa/test/efa_unit_test_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,6 @@ void test_efa_rdm_ep_support_unsolicited_write_recv(struct efa_resource **state)

efa_rdm_ep = container_of(resource->ep, struct efa_rdm_ep, base_ep.util_ep.ep_fid);

assert_int_equal(efa_rdm_use_unsolicited_write_recv(),
assert_int_equal(efa_use_unsolicited_write_recv(),
efa_rdm_ep_support_unsolicited_write_recv(efa_rdm_ep));
}

0 comments on commit 52a023f

Please sign in to comment.