Skip to content

Commit

Permalink
prov/tcp: implement FI_NO_CONNECT for AV inserts
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Oost <stephen.oost@intel.com>
  • Loading branch information
ooststep committed Jan 24, 2025
1 parent d0101e9 commit 903879e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
3 changes: 2 additions & 1 deletion include/ofi_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,8 @@ struct util_peer_addr {
union ofi_sock_ip addr;
};

struct util_peer_addr *util_get_peer(struct rxm_av *av, const void *addr);
int util_get_peer(struct rxm_av *av, const void *addr, struct util_peer_addr **peer,
uint64_t flags);
void util_put_peer(struct util_peer_addr *peer);

/* All peer addresses, whether they've been inserted into the AV
Expand Down
6 changes: 3 additions & 3 deletions prov/rxm/src/rxm_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,9 @@ rxm_process_connreq(struct rxm_ep *ep, struct rxm_eq_cm_entry *cm_entry)
ofi_addr_set_port(&peer_addr.sa, cm_entry->data.connect.port);

av = container_of(ep->util_ep.av, struct rxm_av, util_av);
peer = util_get_peer(av, &peer_addr);
if (!peer) {
RXM_WARN_ERR(FI_LOG_EP_CTRL, "util_get_peer", -FI_ENOMEM);
ret = util_get_peer(av, &peer_addr, &peer, 0);
if (ret) {
RXM_WARN_ERR(FI_LOG_EP_CTRL, "util_get_peer", ret);
goto reject;
}

Expand Down
6 changes: 3 additions & 3 deletions prov/tcp/src/xnet_rdm_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ static void xnet_process_connreq(struct fi_eq_cm_entry *cm_entry)
ofi_addr_set_port(&peer_addr.sa, ntohs(msg->port));

av = container_of(rdm->util_ep.av, struct rxm_av, util_av);
peer = util_get_peer(av, &peer_addr);
if (!peer) {
XNET_WARN_ERR(FI_LOG_EP_CTRL, "util_get_peer", -FI_ENOMEM);
ret = util_get_peer(av, &peer_addr, &peer, 0);
if (ret) {
XNET_WARN_ERR(FI_LOG_EP_CTRL, "util_get_peer", ret);
goto reject;
}

Expand Down
39 changes: 24 additions & 15 deletions prov/util/src/rxm_av.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,32 @@ static void rxm_free_peer(struct util_peer_addr *peer)
ofi_ibuf_free(peer);
}

struct util_peer_addr *
util_get_peer(struct rxm_av *av, const void *addr)

int util_get_peer(struct rxm_av *av, const void *addr, struct util_peer_addr **peer,
uint64_t flags)
{
struct util_peer_addr *peer;
struct ofi_rbnode *node;
int ret;

ofi_mutex_lock(&av->util_av.lock);
node = ofi_rbmap_find(&av->addr_map, (void *) addr);
if (node) {
peer = node->data;
peer->refcnt++;
*peer = node->data;
(*peer)->refcnt++;
} else {
peer = rxm_alloc_peer(av, addr);
}
if (flags && FI_NO_CONNECT) {
*peer = NULL;
ret = -FI_EHOSTUNREACH;
goto unlock;
}

*peer = rxm_alloc_peer(av, addr);
if (!*peer)
ret = -FI_ENOMEM;
}
unlock:
ofi_mutex_unlock(&av->util_av.lock);
return peer;
return peer ? FI_SUCCESS : ret;
}

static void util_deref_peer(struct util_peer_addr *peer)
Expand Down Expand Up @@ -165,17 +174,17 @@ rxm_put_peer_addr(struct rxm_av *av, fi_addr_t fi_addr)

static int
rxm_av_add_peers(struct rxm_av *av, const void *addr, size_t count,
fi_addr_t *fi_addr, fi_addr_t *user_ids)
fi_addr_t *fi_addr, fi_addr_t *user_ids, uint64_t flags)
{
struct util_peer_addr *peer;
const void *cur_addr;
fi_addr_t cur_fi_addr;
size_t i;
size_t i, ret;

for (i = 0; i < count; i++) {
cur_addr = ((char *) addr + i * av->util_av.addrlen);
peer = util_get_peer(av, cur_addr);
if (!peer)
ret = util_get_peer(av, cur_addr, &peer, flags);
if (ret)
goto err;

if (user_ids) {
Expand Down Expand Up @@ -206,7 +215,7 @@ rxm_av_add_peers(struct rxm_av *av, const void *addr, size_t count,
ofi_mutex_unlock(&av->util_av.lock);
}
}
return -FI_ENOMEM;
return ret;
}

static int rxm_av_remove(struct fid_av *av_fid, fi_addr_t *fi_addr,
Expand Down Expand Up @@ -299,7 +308,7 @@ static int rxm_av_insert(struct fid_av *av_fid, const void *addr, size_t count,

count = ret;

ret = rxm_av_add_peers(av, addr, count, fi_addr, user_ids);
ret = rxm_av_add_peers(av, addr, count, fi_addr, user_ids, flags);
if (ret) {
rxm_av_remove(av_fid, fi_addr, count, flags);
goto out;
Expand Down Expand Up @@ -345,7 +354,7 @@ static int rxm_av_insertsym(struct fid_av *av_fid, const char *node,
if (ret > 0 && ret < count)
count = ret;

ret = rxm_av_add_peers(av, addr, count, fi_addr, NULL);
ret = rxm_av_add_peers(av, addr, count, fi_addr, NULL, flags);
if (ret) {
rxm_av_remove(av_fid, fi_addr, count, flags);
return ret;
Expand Down

0 comments on commit 903879e

Please sign in to comment.