Skip to content

Commit

Permalink
prov/cxi: Support domain tx cmdq allocation
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Ziemba <[email protected]>
  • Loading branch information
iziemba committed Jan 24, 2024
1 parent c13d2f5 commit 55d2712
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions prov/cxi/include/cxip.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ struct cxip_domain {
struct dlist_entry cmdq_list;
unsigned int cmdq_cnt;
struct ofi_genlock cmdq_lock;
size_t tx_size;
};

static inline bool cxip_domain_mr_cache_enabled(struct cxip_domain *dom)
Expand Down
74 changes: 74 additions & 0 deletions prov/cxi/src/cxip_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,66 @@

extern struct fi_ops_mr cxip_dom_mr_ops;

static void cxip_domain_cmdq_free(struct cxip_domain *dom)
{
struct cxip_domain_cmdq *cmdq;

while ((cmdq = dlist_first_entry_or_null(&dom->cmdq_list,
struct cxip_domain_cmdq,
entry))) {

cxip_cmdq_free(cmdq->cmdq);
dlist_remove(&cmdq->entry);
dom->cmdq_cnt--;
free(cmdq);
}
}

static int cxip_domain_cmdq_alloc(struct cxip_domain *dom,
uint16_t vni,
enum cxi_traffic_class tc,
struct cxip_domain_cmdq **dom_cmdq)
{
struct cxip_domain_cmdq *cmdq;
struct cxi_cq_alloc_opts cq_opts = {
.flags = CXI_CQ_IS_TX,
};
int ret;

cmdq = calloc(1, sizeof(*cmdq));
if (!cmdq) {
CXIP_WARN("Failed to allocate cmdq memory\n");
return -FI_ENOMEM;
}

/* Domain managed transmit command queues require being updated on
* empty to be able to safely change communication profile VNI.
*/
cq_opts.policy = CXI_CQ_UPDATE_HIGH_FREQ_EMPTY;

/* An IDC command can use up to 4x 64 byte slots. */
cq_opts.count = 4 * dom->tx_size;

ret = cxip_cmdq_alloc(dom->lni, NULL, &cq_opts, vni, tc,
CXI_TC_TYPE_DEFAULT, &cmdq->cmdq);
if (ret) {
CXIP_WARN("Failed to allocate cmdq: %d\n", ret);
goto err_free_mem;
}

dlist_insert_head(&cmdq->entry, &dom->cmdq_list);
dom->cmdq_cnt++;

*dom_cmdq = cmdq;

return FI_SUCCESS;

err_free_mem:
free(cmdq);

return ret;
}

/*
* cxip_domain_req_alloc() - Allocate a domain control buffer ID
*/
Expand Down Expand Up @@ -262,6 +322,7 @@ static int cxip_dom_close(struct fid *fid)
cxip_telemetry_free(dom->telemetry);
}

cxip_domain_cmdq_free(dom);
cxip_domain_disable(dom);

assert(dlist_empty(&dom->cmdq_list));
Expand Down Expand Up @@ -1493,6 +1554,19 @@ int cxip_domain(struct fid_fabric *fabric, struct fi_info *info,
dlist_init(&cxi_domain->cmdq_list);
cxi_domain->cmdq_cnt = 0;

/* Align domain TX command size based on EP TX size attribute. In
* addition, support ENV vars to override size.
*/
cxi_domain->tx_size = 0;
if (info->tx_attr)
cxi_domain->tx_size = info->tx_attr->size;

if (!info->tx_attr) {
cxi_domain->tx_size = cxip_env.default_tx_size;
cxi_domain->tx_size =
MAX(cxip_env.default_cq_size, cxi_domain->tx_size);
}

if (cxi_domain->util_domain.threading == FI_THREAD_DOMAIN)
ofi_genlock_init(&cxi_domain->cmdq_lock, OFI_LOCK_NONE);
else
Expand Down

0 comments on commit 55d2712

Please sign in to comment.