Skip to content

Commit

Permalink
[v1.22.x] prov/efa: Remove dupliated user_info in efa_rdm_ep
Browse files Browse the repository at this point in the history
user_info is just a duplication of fi_info passed
by fi_endpoint(), which is duplicated to base_ep.info
already.

Signed-off-by: Shi Jin <sjina@amazon.com>
(cherry picked from commit 93cd9ff)
  • Loading branch information
shijin-aws committed Sep 19, 2024
1 parent bcc1376 commit b583654
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
7 changes: 3 additions & 4 deletions prov/efa/src/rdm/efa_rdm_ep.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ struct efa_rdm_ep {
*/
bool use_device_rdma;

struct fi_info *user_info; /**< fi_info passed by user when calling fi_endpoint */
bool sendrecv_in_order_aligned_128_bytes; /**< whether to support in order send/recv of each aligned 128 bytes memory region */
bool write_in_order_aligned_128_bytes; /**< whether to support in order write of each aligned 128 bytes memory region */
char err_msg[EFA_RDM_ERROR_MSG_BUFFER_LENGTH]; /* A large enough buffer to store CQ/EQ error data used by e.g. fi_cq_readerr */
Expand Down Expand Up @@ -240,7 +239,7 @@ static inline size_t efa_rdm_ep_get_tx_pool_size(struct efa_rdm_ep *ep)

static inline int efa_rdm_ep_need_sas(struct efa_rdm_ep *ep)
{
return ((ep->user_info->tx_attr->msg_order & FI_ORDER_SAS) || (ep->user_info->rx_attr->msg_order & FI_ORDER_SAS));
return ((ep->base_ep.info->tx_attr->msg_order & FI_ORDER_SAS) || (ep->base_ep.info->rx_attr->msg_order & FI_ORDER_SAS));
}


Expand Down Expand Up @@ -363,7 +362,7 @@ bool efa_rdm_ep_support_rdma_write(struct efa_rdm_ep *ep)
* @return -FI_EOPNOTSUPP if FI_RMA wasn't requested, 0 if it was.
*/
static inline int efa_rdm_ep_cap_check_rma(struct efa_rdm_ep *ep) {
if ((ep->user_info->caps & FI_RMA) == FI_RMA)
if ((ep->base_ep.info->caps & FI_RMA) == FI_RMA)
return 0;
EFA_WARN_ONCE(FI_LOG_EP_DATA, "Operation requires FI_RMA capability, which was not requested.\n");
return -FI_EOPNOTSUPP;
Expand All @@ -374,7 +373,7 @@ static inline int efa_rdm_ep_cap_check_rma(struct efa_rdm_ep *ep) {
* @return -FI_EOPNOTSUPP if FI_ATOMIC wasn't requested, 0 if it was.
*/
static inline int efa_rdm_ep_cap_check_atomic(struct efa_rdm_ep *ep) {
if ((ep->user_info->caps & FI_ATOMIC) == FI_ATOMIC)
if ((ep->base_ep.info->caps & FI_ATOMIC) == FI_ATOMIC)
return 0;
EFA_WARN_ONCE(FI_LOG_EP_DATA, "Operation requires FI_ATOMIC capability, which was not requested.\n");
return -FI_EOPNOTSUPP;
Expand Down
33 changes: 12 additions & 21 deletions prov/efa/src/rdm/efa_rdm_ep_fiops.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ void efa_rdm_ep_set_use_zcpy_rx(struct efa_rdm_ep *ep)
}

/* Max msg size is too large, turn off zcpy recv */
if (ep->max_msg_size > ep->mtu_size - ep->user_info->ep_attr->msg_prefix_size) {
if (ep->max_msg_size > ep->mtu_size - ep->base_ep.info->ep_attr->msg_prefix_size) {
EFA_INFO(FI_LOG_EP_CTRL, "max_msg_size (%zu) is greater than the mtu size limit: %zu. Zero-copy receive protocol will be disabled.\n",
ep->max_msg_size, ep->mtu_size - ep->user_info->ep_attr->msg_prefix_size);
ep->max_msg_size, ep->mtu_size - ep->base_ep.info->ep_attr->msg_prefix_size);
ep->use_zcpy_rx = false;
goto out;
}
Expand Down Expand Up @@ -552,12 +552,6 @@ int efa_rdm_ep_open(struct fid_domain *domain, struct fi_info *info,
efa_rdm_ep->shm_ep = NULL;
}

efa_rdm_ep->user_info = fi_dupinfo(info);
if (!efa_rdm_ep->user_info) {
ret = -FI_ENOMEM;
goto err_free_ep;
}

efa_rdm_ep->host_id = efa_get_host_id(efa_env.host_id_file);
if (efa_rdm_ep->host_id) {
EFA_INFO(FI_LOG_EP_CTRL, "efa_rdm_ep->host_id: i-%017lx\n", efa_rdm_ep->host_id);
Expand Down Expand Up @@ -999,9 +993,6 @@ static int efa_rdm_ep_close(struct fid *fid)
if (efa_rdm_ep->pke_vec)
free(efa_rdm_ep->pke_vec);

if (efa_rdm_ep->user_info)
fi_freeinfo(efa_rdm_ep->user_info);

free(efa_rdm_ep);
return retv;
}
Expand Down Expand Up @@ -1137,7 +1128,7 @@ void efa_rdm_ep_update_shm(struct efa_rdm_ep *ep)

use_shm = true;

assert(ep->user_info);
assert(ep->base_ep.info);

/*
* shm provider must make cuda calls to transfer cuda memory.
Expand All @@ -1147,7 +1138,7 @@ void efa_rdm_ep_update_shm(struct efa_rdm_ep *ep)
* AWS Neuron and Habana Synapse, have no SHM provider
* support anyways, so disabling SHM will not impact them.
*/
if (((ep->user_info->caps & FI_HMEM)
if (((ep->base_ep.info->caps & FI_HMEM)
&& hmem_ops[FI_HMEM_CUDA].initialized
&& !ep->cuda_api_permitted)
|| !ep->shm_permitted) {
Expand Down Expand Up @@ -1468,11 +1459,11 @@ static int efa_rdm_ep_set_shared_memory_permitted(struct efa_rdm_ep *ep, bool sh
*/
static int efa_rdm_ep_set_max_msg_size(struct efa_rdm_ep *ep, size_t max_msg_size)
{
if (max_msg_size > ep->user_info->ep_attr->max_msg_size) {
if (max_msg_size > ep->base_ep.info->ep_attr->max_msg_size) {
EFA_WARN(FI_LOG_EP_CTRL,
"Requested size of %zu for FI_OPT_MAX_MSG_SIZE "
"exceeds the maximum (%zu)\n",
max_msg_size, ep->user_info->ep_attr->max_msg_size);
max_msg_size, ep->base_ep.info->ep_attr->max_msg_size);
return -FI_EINVAL;
}
ep->max_msg_size = max_msg_size;
Expand All @@ -1494,11 +1485,11 @@ static int efa_rdm_ep_set_max_msg_size(struct efa_rdm_ep *ep, size_t max_msg_siz
*/
static int efa_rdm_ep_set_max_rma_size(struct efa_rdm_ep *ep, size_t max_rma_size)
{
if (max_rma_size > ep->user_info->ep_attr->max_msg_size) {
if (max_rma_size > ep->base_ep.info->ep_attr->max_msg_size) {
EFA_WARN(FI_LOG_EP_CTRL,
"Requested size of %zu for FI_OPT_MAX_RMA_SIZE "
"exceeds the maximum (%zu)\n",
max_rma_size, ep->user_info->ep_attr->max_msg_size);
max_rma_size, ep->base_ep.info->ep_attr->max_msg_size);
return -FI_EINVAL;
}
ep->max_rma_size = max_rma_size;
Expand All @@ -1520,11 +1511,11 @@ static int efa_rdm_ep_set_max_rma_size(struct efa_rdm_ep *ep, size_t max_rma_siz
*/
static int efa_rdm_ep_set_inject_msg_size(struct efa_rdm_ep *ep, size_t inject_msg_size)
{
if (inject_msg_size > ep->user_info->tx_attr->inject_size) {
if (inject_msg_size > ep->base_ep.info->tx_attr->inject_size) {
EFA_WARN(FI_LOG_EP_CTRL,
"Requested size of %zu for FI_OPT_INJECT_MSG_SIZE "
"exceeds the maximum (%zu)\n",
inject_msg_size, ep->user_info->tx_attr->inject_size);
inject_msg_size, ep->base_ep.info->tx_attr->inject_size);
return -FI_EINVAL;
}
ep->inject_size = inject_msg_size;
Expand All @@ -1546,11 +1537,11 @@ static int efa_rdm_ep_set_inject_msg_size(struct efa_rdm_ep *ep, size_t inject_m
*/
static int efa_rdm_ep_set_inject_rma_size(struct efa_rdm_ep *ep, size_t inject_rma_size)
{
if (inject_rma_size > ep->user_info->tx_attr->inject_size) {
if (inject_rma_size > ep->base_ep.info->tx_attr->inject_size) {
EFA_WARN(FI_LOG_EP_CTRL,
"Requested size of %zu for FI_OPT_INJECT_RMA_SIZE "
"exceeds the maximum (%zu)\n",
inject_rma_size, ep->user_info->tx_attr->inject_size);
inject_rma_size, ep->base_ep.info->tx_attr->inject_size);
return -FI_EINVAL;
}
ep->inject_size = inject_rma_size;
Expand Down
2 changes: 1 addition & 1 deletion prov/efa/src/rdm/efa_rdm_ope.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void efa_rdm_txe_construct(struct efa_rdm_ope *txe,
txe->cq_entry.len = ofi_total_iov_len(txe->iov, txe->iov_count);
txe->cq_entry.buf = OFI_LIKELY(txe->cq_entry.len > 0) ? txe->iov[0].iov_base : NULL;

if (ep->user_info->mode & FI_MSG_PREFIX) {
if (ep->base_ep.info->mode & FI_MSG_PREFIX) {
ofi_consume_iov_desc(txe->iov, txe->desc, &txe->iov_count, ep->msg_prefix_size);
}
txe->total_len = ofi_total_iov_len(txe->iov, txe->iov_count);
Expand Down
4 changes: 2 additions & 2 deletions prov/efa/test/efa_unit_test_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ void test_efa_rdm_ep_rma_without_caps(struct efa_resource **state)

/* ensure we don't have RMA capability. */
efa_rdm_ep = container_of(resource->ep, struct efa_rdm_ep, base_ep.util_ep.ep_fid);
assert_int_equal( efa_rdm_ep->user_info->caps & FI_RMA, 0);
assert_int_equal( efa_rdm_ep->base_ep.info->caps & FI_RMA, 0);

/* create a fake peer */
err = fi_getname(&resource->ep->fid, &raw_addr, &raw_addr_len);
Expand Down Expand Up @@ -793,7 +793,7 @@ void test_efa_rdm_ep_atomic_without_caps(struct efa_resource **state)

/* ensure we don't have ATOMIC capability. */
efa_rdm_ep = container_of(resource->ep, struct efa_rdm_ep, base_ep.util_ep.ep_fid);
assert_int_equal( efa_rdm_ep->user_info->caps & FI_ATOMIC, 0);
assert_int_equal( efa_rdm_ep->base_ep.info->caps & FI_ATOMIC, 0);

/* create a fake peer */
err = fi_getname(&resource->ep->fid, &raw_addr, &raw_addr_len);
Expand Down

0 comments on commit b583654

Please sign in to comment.