Skip to content

Commit

Permalink
prov/sockets: Fix fabric and domain name settings
Browse files Browse the repository at this point in the history
Convert sockets to use the new IP provider getinfo code.  This
ensures that the fabric and domain names are set correctly based
on the addresses used.

Because the common code verifies and formats the fi_info output,
we can remove a bunch of code in the socket provider that performs
similar checks done by the common code.

Signed-off-by: Sean Hefty <[email protected]>
  • Loading branch information
shefty committed Mar 4, 2020
1 parent 0b61879 commit 10558ff
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 1,100 deletions.
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 10558ff

Please sign in to comment.