Skip to content

Commit

Permalink
Merge pull request #2949 from a-ilango/v1.4.x
Browse files Browse the repository at this point in the history
verbs: Cherry picked commits from master to 1.4.x
  • Loading branch information
shefty authored May 2, 2017
2 parents 22f9c10 + c1252f5 commit 6e3d0e9
Show file tree
Hide file tree
Showing 5 changed files with 317 additions and 231 deletions.
22 changes: 22 additions & 0 deletions include/fi.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ int ofi_ep_bind_valid(struct fi_provider *prov, struct fid *bfid, uint64_t flags
uint64_t fi_gettime_ms(void);
uint64_t fi_gettime_us(void);

/*
* Address utility functions
*/

#ifndef AF_IB
#define AF_IB 27
#endif

static inline int ofi_equals_ipaddr(struct sockaddr_in *addr1,
struct sockaddr_in *addr2)
{
Expand All @@ -184,6 +192,20 @@ static inline int ofi_equals_sockaddr(struct sockaddr_in *addr1,
(addr1->sin_port == addr2->sin_port));
}

static inline int ofi_translate_addr_format(int family)
{
switch (family) {
case AF_INET:
return FI_SOCKADDR_IN;
case AF_INET6:
return FI_SOCKADDR_IN6;
case AF_IB:
return FI_SOCKADDR_IB;
default:
return FI_FORMAT_UNSPEC;
}
}

#ifdef __cplusplus
}
#endif
Expand Down
12 changes: 12 additions & 0 deletions include/fi_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,21 @@ static inline void dlist_remove(struct dlist_entry *item)
item->next->prev = item->prev;
}

#define dlist_pop_front_container(head, container, member) \
do { \
container = container_of((head)->next, typeof(*container), \
member); \
dlist_remove((head)->next); \
} while (0)

#define dlist_foreach(head, item) \
for ((item) = (head)->next; (item) != (head); (item) = (item)->next)

#define dlist_foreach_container(head, container, member) \
for (container = container_of((head)->next, typeof(*container), member); \
&(container->member) != (head); \
container = container_of(container->member.next, typeof(*container), member))

typedef int dlist_func_t(struct dlist_entry *item, const void *arg);

static inline struct dlist_entry *
Expand Down
24 changes: 8 additions & 16 deletions prov/verbs/src/fi_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ int fi_ibv_rdm_cm_bind_ep(struct fi_ibv_rdm_cm *cm, struct fi_ibv_rdm_ep *ep)

assert(cm->ec && cm->listener);

memcpy(&ep->my_addr, ep->domain->info->src_addr, sizeof(ep->my_addr));
if (ep->domain->info->src_addr) {
memcpy(&ep->my_addr, ep->domain->info->src_addr, sizeof(ep->my_addr));

inet_ntop(ep->my_addr.sin_family,
&ep->my_addr.sin_addr.s_addr,
my_ipoib_addr_str, INET_ADDRSTRLEN);
inet_ntop(ep->my_addr.sin_family,
&ep->my_addr.sin_addr.s_addr,
my_ipoib_addr_str, INET_ADDRSTRLEN);
} else {
strcpy(my_ipoib_addr_str, "undefined");
}

VERBS_INFO(FI_LOG_EP_CTRL, "My IPoIB: %s\n", my_ipoib_addr_str);

Expand Down Expand Up @@ -171,7 +175,6 @@ int fi_ibv_create_ep(const char *node, const char *service,
struct rdma_addrinfo **rai, struct rdma_cm_id **id)
{
struct rdma_addrinfo *_rai;
struct sockaddr *local_addr;
int ret;

ret = fi_ibv_get_rdma_rai(node, service, flags, hints, &_rai);
Expand All @@ -185,15 +188,6 @@ int fi_ibv_create_ep(const char *node, const char *service,
ret = -errno;
goto err1;
}
if (rai && !_rai->ai_src_addr) {
local_addr = rdma_get_local_addr(*id);
_rai->ai_src_len = fi_ibv_sockaddr_len(local_addr);
if (!(_rai->ai_src_addr = malloc(_rai->ai_src_len))) {
ret = -FI_ENOMEM;
goto err2;
}
memcpy(_rai->ai_src_addr, local_addr, _rai->ai_src_len);
}

if (rai) {
*rai = _rai;
Expand All @@ -202,8 +196,6 @@ int fi_ibv_create_ep(const char *node, const char *service,
}

return ret;
err2:
rdma_destroy_ep(*id);
err1:
rdma_freeaddrinfo(_rai);

Expand Down
10 changes: 10 additions & 0 deletions prov/verbs/src/fi_verbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@

extern struct fi_provider fi_ibv_prov;

struct verbs_addr {
struct dlist_entry entry;
struct rdma_addrinfo *rai;
};

struct verbs_dev_info {
struct dlist_entry entry;
char *name;
struct dlist_entry addrs;
};

struct fi_ibv_fabric {
struct fid_fabric fabric_fid;
Expand Down
Loading

0 comments on commit 6e3d0e9

Please sign in to comment.