Skip to content

Commit

Permalink
prov/efa: Improve various iov_count assertions
Browse files Browse the repository at this point in the history
Signed-off-by: Darryl Abbate <drl@amazon.com>
  • Loading branch information
darrylabbate authored and shijin-aws committed Apr 18, 2024
1 parent ee31a23 commit 415279c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion prov/efa/src/efa_mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static int efa_mr_cache_regattr(struct fid *fid, const struct fi_mr_attr *attr,
domain = container_of(fid, struct efa_domain,
util_domain.domain_fid.fid);

assert(attr->iov_count == 1);
assert(attr->iov_count > 0 && attr->iov_count <= domain->info->domain_attr->mr_iov_limit);
ofi_mr_info_get_iov_from_mr_attr(&info, attr, flags);
info.iface = attr->iface;
info.device = attr->device.reserved;
Expand Down
3 changes: 3 additions & 0 deletions prov/efa/src/rdm/efa_rdm_ep_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ int efa_rdm_ep_post_user_recv_buf(struct efa_rdm_ep *ep, struct efa_rdm_ope *rxe
struct efa_mr *mr;
int err;

/*
* TODO remove/change assert expression when function logic is fixed
*/
assert(rxe->iov_count == 1);
assert(rxe->iov[0].iov_len >= ep->msg_prefix_size);
pkt_entry = (struct efa_rdm_pke *)rxe->iov[0].iov_base;
Expand Down
14 changes: 8 additions & 6 deletions prov/efa/src/rdm/efa_rdm_ope.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ ssize_t efa_rdm_txe_prepare_local_read_pkt_entry(struct efa_rdm_ope *txe)
struct efa_rdm_pke *pkt_entry_copy;

assert(txe->type == EFA_RDM_TXE);
assert(txe->rma_iov_count == 1);
assert(txe->rma_iov_count > 0 && txe->rma_iov_count <= efa_rdm_ep_domain(txe->ep)->info->tx_attr->rma_iov_limit);

pkt_entry = txe->local_read_pkt_entry;
if (pkt_entry->mr && !(txe->ep->sendrecv_in_order_aligned_128_bytes))
Expand Down Expand Up @@ -1286,11 +1286,11 @@ int efa_rdm_ope_post_read(struct efa_rdm_ope *ope)
struct efa_rdm_ep *ep;
struct efa_rdm_pke *pkt_entry;

assert(ope->iov_count > 0);
assert(ope->rma_iov_count > 0);

ep = ope->ep;

assert(ope->iov_count > 0 && ope->iov_count <= efa_rdm_ep_domain(ep)->info->tx_attr->iov_limit);
assert(ope->rma_iov_count > 0 && ope->rma_iov_count <= efa_rdm_ep_domain(ep)->info->tx_attr->rma_iov_limit);

if (ope->bytes_read_total_len == 0) {

/* According to libfabric document
Expand Down Expand Up @@ -1431,9 +1431,11 @@ int efa_rdm_ope_post_remote_write(struct efa_rdm_ope *ope)
struct efa_rdm_ep *ep;
struct efa_rdm_pke *pkt_entry;

assert(ope->iov_count > 0);
assert(ope->rma_iov_count > 0);
ep = ope->ep;

assert(ope->iov_count > 0 && ope->iov_count <= efa_rdm_ep_domain(ep)->info->tx_attr->iov_limit);
assert(ope->rma_iov_count > 0 && ope->rma_iov_count <= efa_rdm_ep_domain(ep)->info->tx_attr->rma_iov_limit);

if (ope->bytes_write_total_len == 0) {
/* According to libfabric document
* https://ofiwg.github.io/libfabric/main/man/fi_rma.3.html
Expand Down

0 comments on commit 415279c

Please sign in to comment.