Skip to content

Commit

Permalink
Merge pull request ofiwg#5698 from shefty/master
Browse files Browse the repository at this point in the history
prov/ip-based: Add reporting of network and interface names to getinfo
  • Loading branch information
shefty authored Mar 6, 2020
2 parents 0fae23d + 10558ff commit 1307914
Show file tree
Hide file tree
Showing 15 changed files with 352 additions and 1,315 deletions.
18 changes: 12 additions & 6 deletions include/ofi_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ int ofi_discard_socket(SOCKET sock, size_t len);
#define AF_IB 27
#endif

#define OFI_ADDRSTRLEN (INET6_ADDRSTRLEN + 50)

union ofi_sock_ip {
struct sockaddr sa;
struct sockaddr_in sin;
Expand All @@ -133,16 +135,21 @@ union ofi_sock_ip {
};

struct ofi_addr_list_entry {
char ipstr[INET6_ADDRSTRLEN];
union ofi_sock_ip ipaddr;
size_t speed;
struct slist_entry entry;
struct slist_entry entry;
char ipstr[INET6_ADDRSTRLEN];
union ofi_sock_ip ipaddr;
size_t speed;
char net_name[OFI_ADDRSTRLEN];
char ifa_name[OFI_ADDRSTRLEN];
};

int ofi_addr_cmp(const struct fi_provider *prov, const struct sockaddr *sa1,
const struct sockaddr *sa2);
int ofi_getifaddrs(struct ifaddrs **ifap);
void ofi_get_list_of_addr(struct fi_provider *prov, const char *env_name,

void ofi_set_netmask_str(char *netstr, size_t len, struct ifaddrs *ifa);

void ofi_get_list_of_addr(const struct fi_provider *prov, const char *env_name,
struct slist *addr_list);
void ofi_free_list_of_addr(struct slist *addr_list);

Expand All @@ -153,7 +160,6 @@ void ofi_free_list_of_addr(struct slist *addr_list);
#define ofi_sin6_addr(addr) (((struct sockaddr_in6 *)(addr))->sin6_addr)
#define ofi_sin6_port(addr) (((struct sockaddr_in6 *)(addr))->sin6_port)

#define OFI_ADDRSTRLEN (INET6_ADDRSTRLEN + 50)

static inline size_t ofi_sizeofaddr(const struct sockaddr *addr)
{
Expand Down
3 changes: 3 additions & 0 deletions include/ofi_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,9 @@ struct fi_info *ofi_allocinfo_internal(void);
int util_getinfo(const struct util_prov *util_prov, uint32_t version,
const char *node, const char *service, uint64_t flags,
const struct fi_info *hints, struct fi_info **info);
int ofi_ip_getinfo(const struct util_prov *prov, uint32_t version,
const char *node, const char *service, uint64_t flags,
const struct fi_info *hints, struct fi_info **info);


struct fid_list_entry {
Expand Down
21 changes: 3 additions & 18 deletions prov/sockets/include/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,10 @@ enum {

#define SOCK_WIRE_PROTO_VERSION (2)

extern struct fi_info sock_msg_info;
extern struct fi_info sock_rdm_info;
extern struct fi_info sock_dgram_info;
extern struct util_prov sock_msg_util_prov;
extern struct util_prov sock_rdm_util_prov;
extern struct util_prov sock_dgram_util_prov;
extern struct fi_info sock_msg_info;

extern struct util_prov sock_util_prov;
extern struct fi_domain_attr sock_domain_attr;
extern struct fi_fabric_attr sock_fabric_attr;
extern struct fi_tx_attr sock_msg_tx_attr;
Expand Down Expand Up @@ -989,20 +987,7 @@ union sock_tx_op {
};
#define SOCK_EP_TX_ENTRY_SZ (sizeof(union sock_tx_op))

int sock_verify_info(uint32_t version, const struct fi_info *hints);
int sock_verify_fabric_attr(const struct fi_fabric_attr *attr);
int sock_verify_domain_attr(uint32_t version, const struct fi_info *info);

size_t sock_get_tx_size(size_t size);
int sock_rdm_verify_ep_attr(const struct fi_ep_attr *ep_attr,
const struct fi_tx_attr *tx_attr,
const struct fi_rx_attr *rx_attr);
int sock_dgram_verify_ep_attr(const struct fi_ep_attr *ep_attr,
const struct fi_tx_attr *tx_attr,
const struct fi_rx_attr *rx_attr);
int sock_msg_verify_ep_attr(const struct fi_ep_attr *ep_attr,
const struct fi_tx_attr *tx_attr,
const struct fi_rx_attr *rx_attr);
int sock_get_src_addr(union ofi_sock_ip *dest_addr,
union ofi_sock_ip *src_addr);
int sock_get_src_addr_from_hostname(union ofi_sock_ip *src_addr,
Expand Down
2 changes: 2 additions & 0 deletions prov/sockets/src/sock_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ struct fi_info sock_msg_info = {
};

struct fi_info sock_rdm_info = {
.next = &sock_msg_info,
.caps = SOCK_RDM_TX_CAPS | SOCK_RDM_RX_CAPS | SOCK_DOMAIN_CAPS,
.addr_format = FI_SOCKADDR,
.tx_attr = &sock_rdm_tx_attr,
Expand All @@ -240,6 +241,7 @@ struct fi_info sock_rdm_info = {
};

struct fi_info sock_dgram_info = {
.next = &sock_rdm_info,
.caps = SOCK_DGRAM_TX_CAPS | SOCK_DGRAM_RX_CAPS | SOCK_DOMAIN_CAPS,
.addr_format = FI_SOCKADDR,
.tx_attr = &sock_dgram_tx_attr,
Expand Down
125 changes: 5 additions & 120 deletions prov/sockets/src/sock_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,109 +46,6 @@

extern struct fi_ops_mr sock_dom_mr_ops;

int sock_verify_domain_attr(uint32_t version, const struct fi_info *info)
{
const struct fi_domain_attr *attr = info->domain_attr;

if (!attr)
return 0;

switch (attr->threading) {
case FI_THREAD_UNSPEC:
case FI_THREAD_SAFE:
case FI_THREAD_FID:
case FI_THREAD_DOMAIN:
case FI_THREAD_COMPLETION:
case FI_THREAD_ENDPOINT:
break;
default:
SOCK_LOG_DBG("Invalid threading model!\n");
return -FI_ENODATA;
}

switch (attr->control_progress) {
case FI_PROGRESS_UNSPEC:
case FI_PROGRESS_AUTO:
case FI_PROGRESS_MANUAL:
break;

default:
SOCK_LOG_DBG("Control progress mode not supported!\n");
return -FI_ENODATA;
}

switch (attr->data_progress) {
case FI_PROGRESS_UNSPEC:
case FI_PROGRESS_AUTO:
case FI_PROGRESS_MANUAL:
break;

default:
SOCK_LOG_DBG("Data progress mode not supported!\n");
return -FI_ENODATA;
}

switch (attr->resource_mgmt) {
case FI_RM_UNSPEC:
case FI_RM_DISABLED:
case FI_RM_ENABLED:
break;

default:
SOCK_LOG_DBG("Resource mgmt not supported!\n");
return -FI_ENODATA;
}

switch (attr->av_type) {
case FI_AV_UNSPEC:
case FI_AV_MAP:
case FI_AV_TABLE:
break;

default:
SOCK_LOG_DBG("AV type not supported!\n");
return -FI_ENODATA;
}

if (ofi_check_mr_mode(&sock_prov, version,
sock_domain_attr.mr_mode, info)) {
FI_INFO(&sock_prov, FI_LOG_CORE,
"Invalid memory registration mode\n");
return -FI_ENODATA;
}

if (attr->mr_key_size > sock_domain_attr.mr_key_size)
return -FI_ENODATA;

if (attr->cq_data_size > sock_domain_attr.cq_data_size)
return -FI_ENODATA;

if (attr->cq_cnt > sock_domain_attr.cq_cnt)
return -FI_ENODATA;

if (attr->ep_cnt > sock_domain_attr.ep_cnt)
return -FI_ENODATA;

if (attr->max_ep_tx_ctx > sock_domain_attr.max_ep_tx_ctx)
return -FI_ENODATA;

if (attr->max_ep_rx_ctx > sock_domain_attr.max_ep_rx_ctx)
return -FI_ENODATA;

if (attr->cntr_cnt > sock_domain_attr.cntr_cnt)
return -FI_ENODATA;

if (attr->mr_iov_limit > sock_domain_attr.mr_iov_limit)
return -FI_ENODATA;

if (attr->max_err_data > sock_domain_attr.max_err_data)
return -FI_ENODATA;

if (attr->mr_cnt > sock_domain_attr.mr_cnt)
return -FI_ENODATA;

return 0;
}

static int sock_dom_close(struct fid *fid)
{
Expand Down Expand Up @@ -258,12 +155,8 @@ int sock_domain(struct fid_fabric *fabric, struct fi_info *info,
struct sock_fabric *fab;
int ret;

assert(info && info->domain_attr);
fab = container_of(fabric, struct sock_fabric, fab_fid);
if (info && info->domain_attr) {
ret = sock_verify_domain_attr(fabric->api_version, info);
if (ret)
return -FI_EINVAL;
}

sock_domain = calloc(1, sizeof(*sock_domain));
if (!sock_domain)
Expand All @@ -272,21 +165,16 @@ int sock_domain(struct fid_fabric *fabric, struct fi_info *info,
fastlock_init(&sock_domain->lock);
ofi_atomic_initialize32(&sock_domain->ref, 0);

if (info) {
sock_domain->info = *info;
} else {
SOCK_LOG_ERROR("invalid fi_info\n");
goto err1;
}
sock_domain->info = *info;
sock_domain->info.domain_attr = NULL;

sock_domain->dom_fid.fid.fclass = FI_CLASS_DOMAIN;
sock_domain->dom_fid.fid.context = context;
sock_domain->dom_fid.fid.ops = &sock_dom_fi_ops;
sock_domain->dom_fid.ops = &sock_dom_ops;
sock_domain->dom_fid.mr = &sock_dom_mr_ops;

if (!info->domain_attr ||
info->domain_attr->data_progress == FI_PROGRESS_UNSPEC)
if (info->domain_attr->data_progress == FI_PROGRESS_UNSPEC)
sock_domain->progress_mode = FI_PROGRESS_AUTO;
else
sock_domain->progress_mode = info->domain_attr->data_progress;
Expand All @@ -300,10 +188,7 @@ int sock_domain(struct fid_fabric *fabric, struct fi_info *info,
sock_domain->fab = fab;
*dom = &sock_domain->dom_fid;

if (info->domain_attr)
sock_domain->attr = *(info->domain_attr);
else
sock_domain->attr = sock_domain_attr;
sock_domain->attr = *(info->domain_attr);

ret = ofi_mr_map_init(&sock_prov, sock_domain->attr.mr_mode,
&sock_domain->mr_map);
Expand Down
84 changes: 38 additions & 46 deletions prov/sockets/src/sock_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,16 +1598,10 @@ int sock_alloc_endpoint(struct fid_domain *domain, struct fi_info *info,
struct sock_rx_ctx *rx_ctx;
struct sock_domain *sock_dom;

assert(info);
sock_dom = container_of(domain, struct sock_domain, dom_fid);
if (info) {
ret = sock_verify_info(sock_dom->fab->fab_fid.api_version, info);
if (ret) {
SOCK_LOG_DBG("Cannot support requested options!\n");
return -FI_EINVAL;
}
}

sock_ep = (struct sock_ep *) calloc(1, sizeof(*sock_ep));
sock_ep = calloc(1, sizeof(*sock_ep));
if (!sock_ep)
return -FI_ENOMEM;

Expand Down Expand Up @@ -1647,52 +1641,50 @@ int sock_alloc_endpoint(struct fid_domain *domain, struct fi_info *info,
sock_ep->attr->fclass = fclass;
*ep = sock_ep;

if (info) {
sock_ep->attr->info.caps = info->caps;
sock_ep->attr->info.addr_format = FI_SOCKADDR_IN;
sock_ep->attr->info.caps = info->caps;
sock_ep->attr->info.addr_format = info->addr_format;

if (info->ep_attr) {
sock_ep->attr->ep_type = info->ep_attr->type;
sock_ep->attr->ep_attr.tx_ctx_cnt = info->ep_attr->tx_ctx_cnt;
sock_ep->attr->ep_attr.rx_ctx_cnt = info->ep_attr->rx_ctx_cnt;
}

if (info->src_addr) {
sock_ep->attr->src_addr = calloc(1, sizeof(*sock_ep->
attr->src_addr));
if (!sock_ep->attr->src_addr) {
ret = -FI_ENOMEM;
goto err2;
}
memcpy(sock_ep->attr->src_addr, info->src_addr,
info->src_addrlen);
}
if (info->ep_attr) {
sock_ep->attr->ep_type = info->ep_attr->type;
sock_ep->attr->ep_attr.tx_ctx_cnt = info->ep_attr->tx_ctx_cnt;
sock_ep->attr->ep_attr.rx_ctx_cnt = info->ep_attr->rx_ctx_cnt;
}

if (info->dest_addr) {
sock_ep->attr->dest_addr = calloc(1, sizeof(*sock_ep->
attr->dest_addr));
if (!sock_ep->attr->dest_addr) {
ret = -FI_ENOMEM;
goto err2;
}
memcpy(sock_ep->attr->dest_addr, info->dest_addr,
info->dest_addrlen);
if (info->src_addr) {
sock_ep->attr->src_addr = calloc(1, sizeof(*sock_ep->
attr->src_addr));
if (!sock_ep->attr->src_addr) {
ret = -FI_ENOMEM;
goto err2;
}
memcpy(sock_ep->attr->src_addr, info->src_addr,
info->src_addrlen);
}

if (info->tx_attr) {
sock_ep->tx_attr = *info->tx_attr;
if (!(sock_ep->tx_attr.op_flags & (FI_INJECT_COMPLETE |
FI_TRANSMIT_COMPLETE | FI_DELIVERY_COMPLETE)))
sock_ep->tx_attr.op_flags |= FI_TRANSMIT_COMPLETE;
sock_ep->tx_attr.size = sock_ep->tx_attr.size ?
sock_ep->tx_attr.size : SOCK_EP_TX_SZ;
if (info->dest_addr) {
sock_ep->attr->dest_addr = calloc(1, sizeof(*sock_ep->
attr->dest_addr));
if (!sock_ep->attr->dest_addr) {
ret = -FI_ENOMEM;
goto err2;
}
memcpy(sock_ep->attr->dest_addr, info->dest_addr,
info->dest_addrlen);
}

if (info->rx_attr)
sock_ep->rx_attr = *info->rx_attr;
sock_ep->attr->info.handle = info->handle;
if (info->tx_attr) {
sock_ep->tx_attr = *info->tx_attr;
if (!(sock_ep->tx_attr.op_flags & (FI_INJECT_COMPLETE |
FI_TRANSMIT_COMPLETE | FI_DELIVERY_COMPLETE)))
sock_ep->tx_attr.op_flags |= FI_TRANSMIT_COMPLETE;
sock_ep->tx_attr.size = sock_ep->tx_attr.size ?
sock_ep->tx_attr.size : SOCK_EP_TX_SZ;
}

if (info->rx_attr)
sock_ep->rx_attr = *info->rx_attr;
sock_ep->attr->info.handle = info->handle;

if (!sock_ep->attr->src_addr && sock_ep_assign_src_addr(sock_ep, info)) {
SOCK_LOG_ERROR("failed to get src_address\n");
ret = -FI_EINVAL;
Expand Down
Loading

0 comments on commit 1307914

Please sign in to comment.