From 4d79eae6116998da066091a8eab918237b843b2c Mon Sep 17 00:00:00 2001 From: Nick Sarkauskas Date: Mon, 17 Jun 2024 14:34:45 -0700 Subject: [PATCH] CL/DOCA_UROM: Clean up --- .../doca_urom_ucc_plugin/dpu/worker_ucc_p2p.c | 37 +- src/components/cl/doca_urom/Makefile.am | 6 +- src/components/cl/doca_urom/cl_doca_urom.h | 15 +- .../cl/doca_urom/cl_doca_urom_coll.c | 74 +-- .../cl/doca_urom/cl_doca_urom_coll.h | 9 +- ...mmon_doca_urom.c => cl_doca_urom_common.c} | 157 +++--- ...mmon_doca_urom.h => cl_doca_urom_common.h} | 70 +-- .../cl/doca_urom/cl_doca_urom_common_doca.c | 498 ------------------ .../cl/doca_urom/cl_doca_urom_common_doca.h | 145 ----- .../cl/doca_urom/cl_doca_urom_context.c | 55 +- .../cl/doca_urom/cl_doca_urom_lib.c | 17 +- .../cl/doca_urom/cl_doca_urom_team.c | 11 +- .../cl/doca_urom/cl_doca_urom_worker_ucc.c | 325 ++++++------ .../cl/doca_urom/cl_doca_urom_worker_ucc.h | 183 +++---- 14 files changed, 453 insertions(+), 1149 deletions(-) rename src/components/cl/doca_urom/{cl_doca_urom_common_doca_urom.c => cl_doca_urom_common.c} (67%) rename src/components/cl/doca_urom/{cl_doca_urom_common_doca_urom.h => cl_doca_urom_common.h} (58%) delete mode 100644 src/components/cl/doca_urom/cl_doca_urom_common_doca.c delete mode 100644 src/components/cl/doca_urom/cl_doca_urom_common_doca.h diff --git a/contrib/doca_urom_ucc_plugin/dpu/worker_ucc_p2p.c b/contrib/doca_urom_ucc_plugin/dpu/worker_ucc_p2p.c index 69953f5961..c4cb38d35c 100644 --- a/contrib/doca_urom_ucc_plugin/dpu/worker_ucc_p2p.c +++ b/contrib/doca_urom_ucc_plugin/dpu/worker_ucc_p2p.c @@ -17,7 +17,7 @@ #include "worker_ucc.h" #include "../common/urom_ucc.h" -DOCA_LOG_REGISTER(UROM::WORKER::UCC::P2P); +DOCA_LOG_REGISTER(UCC::DOCA_CL : WORKER_UCC_P2P); void urom_ep_err_cb(void *arg, ucp_ep_h ep, ucs_status_t ucs_status) { @@ -439,24 +439,18 @@ doca_error_t ucc_rma_get_host(void *buffer, ucs_status_t ucs_status; ucs_status_ptr_t ucp_status; uint64_t rva = (uint64_t)target; - //static ucp_rkey_h prev_rkey = NULL; - //static void *prev_packed_key = NULL; ucp_request_param_t req_param = {0}; if (packed_key == NULL) return DOCA_ERROR_INVALID_VALUE; ep = ucc_worker->ucc_data[ctx_id].host; - //if (prev_packed_key != packed_key) { - ucs_status = ucp_ep_rkey_unpack(ep, packed_key, &rkey); - if (ucs_status != UCS_OK) { - DOCA_LOG_ERR("Failed to unpack rkey"); - return DOCA_ERROR_NOT_FOUND; - } - //prev_rkey = rkey; - //prev_packed_key = packed_key; - //} else - //rkey = prev_rkey; + + ucs_status = ucp_ep_rkey_unpack(ep, packed_key, &rkey); + if (ucs_status != UCS_OK) { + DOCA_LOG_ERR("Failed to unpack rkey"); + return DOCA_ERROR_NOT_FOUND; + } ucp_status = ucp_get_nbx(ep, buffer, msglen, rva, rkey, &req_param); if (UCS_OK != ucp_status) { @@ -494,24 +488,17 @@ doca_error_t ucc_rma_put_host(void *buffer, ucs_status_ptr_t ucp_status; uint64_t rva = (uint64_t)target; ucp_request_param_t req_param = {0}; - //static void *prev_packed_dst_key = NULL; - //static ucp_rkey_h prev_dst_rkey = NULL; if (packed_key == NULL) return DOCA_ERROR_INVALID_VALUE; ep = ucc_worker->ucc_data[ctx_id].host; - //if (prev_packed_dst_key != packed_key) { - ucs_status = ucp_ep_rkey_unpack(ep, packed_key, &rkey); - if (ucs_status != UCS_OK) { - DOCA_LOG_ERR("Failed to unpack rkey"); - return DOCA_ERROR_NOT_FOUND; - } - //prev_dst_rkey = rkey; - //prev_packed_dst_key = packed_key; - //} else - //rkey = prev_dst_rkey; + ucs_status = ucp_ep_rkey_unpack(ep, packed_key, &rkey); + if (ucs_status != UCS_OK) { + DOCA_LOG_ERR("Failed to unpack rkey"); + return DOCA_ERROR_NOT_FOUND; + } ucp_status = ucp_put_nbx(ep, buffer, msglen, rva, rkey, &req_param); if (UCS_OK != ucp_status) { diff --git a/src/components/cl/doca_urom/Makefile.am b/src/components/cl/doca_urom/Makefile.am index b769696ea7..a7f5589ba1 100644 --- a/src/components/cl/doca_urom/Makefile.am +++ b/src/components/cl/doca_urom/Makefile.am @@ -8,10 +8,8 @@ sources = \ cl_doca_urom_lib.c \ cl_doca_urom_context.c \ cl_doca_urom_team.c \ - cl_doca_urom_common_doca.c \ - cl_doca_urom_common_doca.h \ - cl_doca_urom_common_doca_urom.c \ - cl_doca_urom_common_doca_urom.h \ + cl_doca_urom_common.c \ + cl_doca_urom_common.h \ cl_doca_urom_worker_ucc.c \ cl_doca_urom_worker_ucc.h \ cl_doca_urom_coll.c diff --git a/src/components/cl/doca_urom/cl_doca_urom.h b/src/components/cl/doca_urom/cl_doca_urom.h index 62921b86e5..77b0f9d80c 100644 --- a/src/components/cl/doca_urom/cl_doca_urom.h +++ b/src/components/cl/doca_urom/cl_doca_urom.h @@ -19,8 +19,7 @@ #include #include -#include "cl_doca_urom_common_doca.h" -#include "cl_doca_urom_common_doca_urom.h" +#include "cl_doca_urom_common.h" #include "cl_doca_urom_worker_ucc.h" #include @@ -85,12 +84,12 @@ UCC_CLASS_DECLARE(ucc_cl_doca_urom_context_t, const ucc_base_context_params_t *, const ucc_base_config_t *); typedef struct ucc_cl_doca_urom_team { - ucc_cl_team_t super; - ucc_team_h **teams; - unsigned n_teams; - ucc_coll_score_t *score; - ucc_score_map_t *score_map; - struct ucc_result res; // used for the cookie + ucc_cl_team_t super; + ucc_team_h **teams; + unsigned n_teams; + ucc_coll_score_t *score; + ucc_score_map_t *score_map; + struct ucc_cl_doca_urom_result res; // used for the cookie } ucc_cl_doca_urom_team_t; UCC_CLASS_DECLARE(ucc_cl_doca_urom_team_t, ucc_base_context_t *, const ucc_base_team_params_t *); diff --git a/src/components/cl/doca_urom/cl_doca_urom_coll.c b/src/components/cl/doca_urom/cl_doca_urom_coll.c index 65bcc1a6da..68d22375ee 100644 --- a/src/components/cl/doca_urom/cl_doca_urom_coll.c +++ b/src/components/cl/doca_urom/cl_doca_urom_coll.c @@ -18,8 +18,6 @@ static ucc_status_t ucc_cl_doca_urom_triggered_post_setup(ucc_coll_task_t *task) static ucc_status_t ucc_cl_doca_urom_coll_full_start(ucc_coll_task_t *task) { - doca_error_t result; - ucc_worker_key_buf keys; ucc_cl_doca_urom_team_t *cl_team = ucc_derived_of(task->team, ucc_cl_doca_urom_team_t); ucc_cl_doca_urom_context_t *ctx = UCC_CL_DOCA_UROM_TEAM_CTX(cl_team); @@ -38,6 +36,8 @@ static ucc_status_t ucc_cl_doca_urom_coll_full_start(ucc_coll_task_t *task) ucc_cl_doca_urom_schedule_t); struct export_buf *src_ebuf = &schedule->src_ebuf; struct export_buf *dst_ebuf = &schedule->dst_ebuf; + doca_error_t result; + ucc_worker_key_buf keys; src_ebuf->memh = NULL; dst_ebuf->memh = NULL; @@ -49,56 +49,71 @@ static ucc_status_t ucc_cl_doca_urom_coll_full_start(ucc_coll_task_t *task) in_place = 1; } + if (!in_place) { + ucc_cl_doca_urom_buffer_export_ucc( + tl_ctx->worker.ucp_context, + coll_args->src.info.buffer, + coll_args->src.info.count * + ucc_dt_size(coll_args->src.info.datatype), + src_ebuf); + } + + ucc_cl_doca_urom_buffer_export_ucc( + tl_ctx->worker.ucp_context, + coll_args->dst.info.buffer, + coll_args->dst.info.count * + ucc_dt_size(coll_args->dst.info.datatype), + dst_ebuf); + switch (coll_args->coll_type) { case UCC_COLL_TYPE_ALLTOALL: { if (!in_place) { - ucc_cl_doca_urom_buffer_export_ucc(tl_ctx->worker.ucp_context, coll_args->src.info.buffer, coll_args->src.info.count * ucc_cl_doca_urom_dt_size(coll_args->src.info.datatype), src_ebuf); keys.src_len = src_ebuf->packed_key_len; memcpy(keys.rkeys, src_ebuf->packed_key, keys.src_len); } else { keys.src_len = 0; } - ucc_cl_doca_urom_buffer_export_ucc(tl_ctx->worker.ucp_context, coll_args->dst.info.buffer, coll_args->dst.info.count * ucc_cl_doca_urom_dt_size(coll_args->dst.info.datatype), dst_ebuf); keys.dst_len = dst_ebuf->packed_key_len; - memcpy(keys.rkeys + keys.src_len, dst_ebuf->packed_key, keys.dst_len); + memcpy(keys.rkeys + keys.src_len, + dst_ebuf->packed_key, keys.dst_len); use_xgvmi = 0; } break; case UCC_COLL_TYPE_ALLREDUCE: { if (!in_place) { - ucc_cl_doca_urom_buffer_export_ucc(tl_ctx->worker.ucp_context, coll_args->src.info.buffer, coll_args->src.info.count * ucc_cl_doca_urom_dt_size(coll_args->src.info.datatype), src_ebuf); keys.src_len = src_ebuf->packed_memh_len; memcpy(keys.rkeys, src_ebuf->packed_memh, keys.src_len); } else { keys.src_len = 0; } - ucc_cl_doca_urom_buffer_export_ucc(tl_ctx->worker.ucp_context, coll_args->dst.info.buffer, coll_args->dst.info.count * ucc_cl_doca_urom_dt_size(coll_args->dst.info.datatype), dst_ebuf); keys.dst_len = dst_ebuf->packed_memh_len; - memcpy(keys.rkeys + keys.src_len, dst_ebuf->packed_memh, keys.dst_len); + memcpy(keys.rkeys + keys.src_len, + dst_ebuf->packed_memh, keys.dst_len); use_xgvmi = 1; } break; case UCC_COLL_TYPE_ALLGATHER: { if (!in_place) { - ucc_cl_doca_urom_buffer_export_ucc(tl_ctx->worker.ucp_context, coll_args->src.info.buffer, coll_args->src.info.count * ucc_cl_doca_urom_dt_size(coll_args->src.info.datatype), src_ebuf); keys.src_len = src_ebuf->packed_memh_len; memcpy(keys.rkeys, src_ebuf->packed_memh, keys.src_len); } else { keys.src_len = 0; } - ucc_cl_doca_urom_buffer_export_ucc(tl_ctx->worker.ucp_context, coll_args->dst.info.buffer, coll_args->dst.info.count * ucc_cl_doca_urom_dt_size(coll_args->dst.info.datatype), dst_ebuf); keys.dst_len = dst_ebuf->packed_memh_len; - memcpy(keys.rkeys + keys.src_len, dst_ebuf->packed_memh, keys.dst_len); + memcpy(keys.rkeys + keys.src_len, + dst_ebuf->packed_memh, + keys.dst_len); use_xgvmi = 1; } break; default: - cl_error(&cl_lib->super, "coll_type %s is not supported", ucc_coll_type_str(coll_args->coll_type)); + cl_error(&cl_lib->super, "coll_type %s is not supported", + ucc_coll_type_str(coll_args->coll_type)); } coll_args->mask |= UCC_COLL_ARGS_FIELD_GLOBAL_WORK_BUFFER; - result = doca_urom_ucc_task_collective(cl_lib->urom_ctx.urom_worker, + result = ucc_cl_doca_urom_task_collective(cl_lib->urom_ctx.urom_worker, cookie, rank, coll_args, @@ -107,7 +122,7 @@ static ucc_status_t ucc_cl_doca_urom_coll_full_start(ucc_coll_task_t *task) &keys, sizeof(ucc_worker_key_buf), 0, - urom_ucc_collective_finished); + ucc_cl_doca_urom_collective_finished); if (result != DOCA_SUCCESS) { cl_error(&cl_lib->super, "Failed to create UCC collective task"); } @@ -120,7 +135,6 @@ static ucc_status_t ucc_cl_doca_urom_coll_full_start(ucc_coll_task_t *task) static ucc_status_t ucc_cl_doca_urom_coll_full_finalize(ucc_coll_task_t *task) { - ucc_status_t status; ucc_cl_doca_urom_schedule_t *schedule = ucc_derived_of(task, ucc_cl_doca_urom_schedule_t); ucc_cl_doca_urom_team_t *cl_team = ucc_derived_of(task->team, @@ -134,6 +148,7 @@ static ucc_status_t ucc_cl_doca_urom_coll_full_finalize(ucc_coll_task_t *task) ucc_tl_ucp_context_t); struct export_buf *src_ebuf = &schedule->src_ebuf; struct export_buf *dst_ebuf = &schedule->dst_ebuf; + ucc_status_t status; if (src_ebuf->memh) { ucp_mem_unmap(tl_ctx->worker.ucp_context, src_ebuf->memh); @@ -148,20 +163,20 @@ static ucc_status_t ucc_cl_doca_urom_coll_full_finalize(ucc_coll_task_t *task) static void ucc_cl_doca_urom_coll_full_progress(ucc_coll_task_t *ctask) { - int ret; - ucc_cl_doca_urom_team_t *cl_team = ucc_derived_of(ctask->team, + ucc_cl_doca_urom_team_t *cl_team = ucc_derived_of(ctask->team, ucc_cl_doca_urom_team_t); - ucc_cl_doca_urom_context_t *ctx = UCC_CL_DOCA_UROM_TEAM_CTX(cl_team); - ucc_cl_doca_urom_lib_t *cl_lib = ucc_derived_of( + ucc_cl_doca_urom_context_t *ctx = UCC_CL_DOCA_UROM_TEAM_CTX(cl_team); + ucc_cl_doca_urom_lib_t *cl_lib = ucc_derived_of( ctx->super.super.lib, ucc_cl_doca_urom_lib_t); - ucc_cl_doca_urom_schedule_t *schedule = ucc_derived_of(ctask, + ucc_cl_doca_urom_schedule_t *schedule = ucc_derived_of(ctask, ucc_cl_doca_urom_schedule_t); - int ucp_index = cl_lib->tl_ucp_index; - ucc_tl_ucp_context_t *tl_ctx = ucc_derived_of( - ctx->super.tl_ctxs[ucp_index], - ucc_tl_ucp_context_t); - struct ucc_result *res = &schedule->res; + int ucp_index = cl_lib->tl_ucp_index; + ucc_tl_ucp_context_t *tl_ctx = ucc_derived_of( + ctx->super.tl_ctxs[ucp_index], + ucc_tl_ucp_context_t); + struct ucc_cl_doca_urom_result *res = &schedule->res; + int ret; if (res == NULL) { cl_error(cl_lib, "Error in UROM"); @@ -189,15 +204,15 @@ ucc_status_t ucc_cl_doca_urom_coll_full_init( ucc_base_coll_args_t *coll_args, ucc_base_team_t *team, ucc_coll_task_t **task) { - ucc_status_t status; - ucc_cl_doca_urom_schedule_t *cl_schedule; - ucc_base_coll_args_t args; - ucc_schedule_t *schedule; ucc_cl_doca_urom_team_t *cl_team = ucc_derived_of(team, ucc_cl_doca_urom_team_t); ucc_cl_doca_urom_context_t *ctx = UCC_CL_DOCA_UROM_TEAM_CTX(cl_team); ucc_cl_doca_urom_lib_t *cl_lib = ucc_derived_of(ctx->super.super.lib, ucc_cl_doca_urom_lib_t); + ucc_status_t status; + ucc_cl_doca_urom_schedule_t *cl_schedule; + ucc_base_coll_args_t args; + ucc_schedule_t *schedule; cl_schedule = ucc_cl_doca_urom_get_schedule(cl_team); if (ucc_unlikely(!cl_schedule)) { @@ -245,4 +260,3 @@ ucc_status_t ucc_cl_doca_urom_coll_init(ucc_base_coll_args_t *coll_args, return UCC_OK; } - diff --git a/src/components/cl/doca_urom/cl_doca_urom_coll.h b/src/components/cl/doca_urom/cl_doca_urom_coll.h index f85a9554ff..344c6684da 100644 --- a/src/components/cl/doca_urom/cl_doca_urom_coll.h +++ b/src/components/cl/doca_urom/cl_doca_urom_coll.h @@ -18,10 +18,10 @@ extern const char *ucc_cl_doca_urom_default_alg_select_str[UCC_CL_DOCA_UROM_N_DEFAULT_ALG_SELECT_STR]; typedef struct ucc_cl_doca_urom_schedule_t { - ucc_schedule_pipelined_t super; - struct ucc_result res; - struct export_buf src_ebuf; - struct export_buf dst_ebuf; + ucc_schedule_pipelined_t super; + struct ucc_cl_doca_urom_result res; + struct export_buf src_ebuf; + struct export_buf dst_ebuf; } ucc_cl_doca_urom_schedule_t; static inline ucc_cl_doca_urom_schedule_t * @@ -39,4 +39,3 @@ static inline void ucc_cl_doca_urom_put_schedule(ucc_schedule_t *schedule) } #endif - diff --git a/src/components/cl/doca_urom/cl_doca_urom_common_doca_urom.c b/src/components/cl/doca_urom/cl_doca_urom_common.c similarity index 67% rename from src/components/cl/doca_urom/cl_doca_urom_common_doca_urom.c rename to src/components/cl/doca_urom/cl_doca_urom_common.c index 3cda7f4c9e..97f1c929d6 100644 --- a/src/components/cl/doca_urom/cl_doca_urom_common_doca_urom.c +++ b/src/components/cl/doca_urom/cl_doca_urom_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED. + * Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED. * * This software product is a proprietary product of NVIDIA CORPORATION & * AFFILIATES (the "Company") and all right, title, and interest in and to the @@ -26,68 +26,17 @@ #include #include -#include "cl_doca_urom_common_doca_urom.h" +#include "cl_doca_urom_common.h" -DOCA_LOG_REGISTER(UROM::SAMPLES : COMMON); +DOCA_LOG_REGISTER(UCC::DOCA_CL : UROM_COMMON); -/* - * ARGP Callback - Handle IB device name parameter - * - * @param [in]: Input parameter - * @config [in/out]: Program configuration context - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -static doca_error_t device_address_callback(void *param, void *config) -{ - struct urom_common_cfg *urom_cfg = (struct urom_common_cfg *)config; - char *device_name = (char *)param; - int len; - - len = strnlen(device_name, DOCA_DEVINFO_IBDEV_NAME_SIZE); - if (len == DOCA_DEVINFO_IBDEV_NAME_SIZE) { - DOCA_LOG_ERR("Entered IB device name exceeding the maximum size of %d", - DOCA_DEVINFO_IBDEV_NAME_SIZE - 1); - return DOCA_ERROR_INVALID_VALUE; - } - strncpy(urom_cfg->device_name, device_name, len + 1); - - return DOCA_SUCCESS; -} - -doca_error_t register_urom_common_params(void) +doca_error_t ucc_cl_doca_urom_start_urom_service( + struct doca_pe *pe, struct doca_dev *dev, uint64_t nb_workers, + struct doca_urom_service **service) { - doca_error_t result; - struct doca_argp_param *device_param; - - /* Create and register device param */ - result = doca_argp_param_create(&device_param); - if (result != DOCA_SUCCESS) { - DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_error_get_descr(result)); - return result; - } - doca_argp_param_set_short_name(device_param, "d"); - doca_argp_param_set_long_name(device_param, "device"); - doca_argp_param_set_arguments(device_param, ""); - doca_argp_param_set_description(device_param, "IB device name."); - doca_argp_param_set_callback(device_param, device_address_callback); - doca_argp_param_set_type(device_param, DOCA_ARGP_TYPE_STRING); - result = doca_argp_register_param(device_param); - if (result != DOCA_SUCCESS) { - DOCA_LOG_ERR("Failed to register program param: %s", doca_error_get_descr(result)); - return result; - } - - return result; -} - -doca_error_t start_urom_service(struct doca_pe *pe, - struct doca_dev *dev, - uint64_t nb_workers, - struct doca_urom_service **service) -{ - enum doca_ctx_states state; + enum doca_ctx_states state; struct doca_urom_service *inst; - doca_error_t result, tmp_result; + doca_error_t result, tmp_result; /* Create service context */ result = doca_urom_service_create(&inst); @@ -133,20 +82,15 @@ doca_error_t start_urom_service(struct doca_pe *pe, return result; } -doca_error_t start_urom_worker(struct doca_pe *pe, - struct doca_urom_service *service, - uint64_t worker_id, - uint32_t *gid, - uint64_t nb_tasks, - doca_cpu_set_t *cpuset, - char **env, - size_t env_count, - uint64_t plugins, - struct doca_urom_worker **worker) +doca_error_t ucc_cl_doca_urom_start_urom_worker( + struct doca_pe *pe, struct doca_urom_service *service, + uint64_t worker_id, uint32_t *gid, uint64_t nb_tasks, + doca_cpu_set_t *cpuset, char **env, size_t env_count, uint64_t plugins, + struct doca_urom_worker **worker) { - enum doca_ctx_states state; + enum doca_ctx_states state; struct doca_urom_worker *inst; - doca_error_t result, tmp_result; + doca_error_t result, tmp_result; result = doca_urom_worker_create(&inst); if (result != DOCA_SUCCESS) @@ -228,19 +172,16 @@ doca_error_t start_urom_worker(struct doca_pe *pe, return result; } -doca_error_t start_urom_domain(struct doca_pe *pe, - struct doca_urom_domain_oob_coll *oob, - uint64_t *worker_ids, - struct doca_urom_worker **workers, - size_t nb_workers, - struct urom_domain_buffer_attrs *buffers, - size_t nb_buffers, - struct doca_urom_domain **domain) +doca_error_t ucc_cl_doca_urom_start_urom_domain( + struct doca_pe *pe, struct doca_urom_domain_oob_coll *oob, + uint64_t *worker_ids, struct doca_urom_worker **workers, + size_t nb_workers, struct ucc_cl_doca_urom_domain_buffer_attrs *buffers, + size_t nb_buffers, struct doca_urom_domain **domain) { - size_t i; - doca_error_t result, tmp_result; - enum doca_ctx_states state; struct doca_urom_domain *inst; + enum doca_ctx_states state; + doca_error_t result, tmp_result; + size_t i; result = doca_urom_domain_create(&inst); if (result != DOCA_SUCCESS) { @@ -309,3 +250,55 @@ doca_error_t start_urom_domain(struct doca_pe *pe, } return result; } + + +doca_error_t ucc_cl_doca_urom_open_doca_device_with_ibdev_name( + const uint8_t *value, size_t val_size, + ucc_cl_doca_urom_tasks_check func, struct doca_dev **retval) +{ + char buf[DOCA_DEVINFO_IBDEV_NAME_SIZE] = {}; + char val_copy[DOCA_DEVINFO_IBDEV_NAME_SIZE] = {}; + struct doca_devinfo **dev_list; + uint32_t nb_devs; + int res; + size_t i; + + /* Set default return value */ + *retval = NULL; + + /* Setup */ + if (val_size > DOCA_DEVINFO_IBDEV_NAME_SIZE) { + DOCA_LOG_ERR("Value size too large. Failed to locate device"); + return DOCA_ERROR_INVALID_VALUE; + } + memcpy(val_copy, value, val_size); + + res = doca_devinfo_create_list(&dev_list, &nb_devs); + if (res != DOCA_SUCCESS) { + DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(res)); + return res; + } + + /* Search */ + for (i = 0; i < nb_devs; i++) { + res = doca_devinfo_get_ibdev_name(dev_list[i], buf, DOCA_DEVINFO_IBDEV_NAME_SIZE); + if (res == DOCA_SUCCESS && strncmp(buf, val_copy, val_size) == 0) { + /* If any special capabilities are needed */ + if (func != NULL && func(dev_list[i]) != DOCA_SUCCESS) + continue; + + /* if device can be opened */ + res = doca_dev_open(dev_list[i], retval); + if (res == DOCA_SUCCESS) { + doca_devinfo_destroy_list(dev_list); + return res; + } + } + } + + DOCA_LOG_WARN("Matching device not found"); + res = DOCA_ERROR_NOT_FOUND; + + doca_devinfo_destroy_list(dev_list); + return res; +} diff --git a/src/components/cl/doca_urom/cl_doca_urom_common_doca_urom.h b/src/components/cl/doca_urom/cl_doca_urom_common.h similarity index 58% rename from src/components/cl/doca_urom/cl_doca_urom_common_doca_urom.h rename to src/components/cl/doca_urom/cl_doca_urom_common.h index b7d84642e3..20335cf7d3 100644 --- a/src/components/cl/doca_urom/cl_doca_urom_common_doca_urom.h +++ b/src/components/cl/doca_urom/cl_doca_urom_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED. + * Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED. * * This software product is a proprietary product of NVIDIA CORPORATION & * AFFILIATES (the "Company") and all right, title, and interest in and to the @@ -15,24 +15,21 @@ #define _GNU_SOURCE #endif -#ifndef UROM_COMMON_H_ -#define UROM_COMMON_H_ +#ifndef UCC_CL_DOCA_UROM_COMMON_H_ +#define UCC_CL_DOCA_UROM_COMMON_H_ #include #include #include +#include -/* - * Struct contains all the common configurations that needed for DOCA UROM samples. - */ -struct urom_common_cfg { - char device_name[DOCA_DEVINFO_IBDEV_NAME_SIZE]; /* DOCA device name */ -}; +/* Function to check if a given device is capable of executing some task */ +typedef doca_error_t (*ucc_cl_doca_urom_tasks_check)(struct doca_devinfo *); /* * Struct contains domain shared buffer details */ -struct urom_domain_buffer_attrs { +struct ucc_cl_doca_urom_domain_buffer_attrs { void *buffer; /* Buffer address */ size_t buf_len; /* Buffer length */ void *memh; /* Buffer packed memory handle */ @@ -42,11 +39,19 @@ struct urom_domain_buffer_attrs { }; /* - * Register the common command line parameter for the sample. + * Open a DOCA device according to a given IB device name * + * @value [in]: IB device name + * @val_size [in]: input length, in bytes + * @func [in]: pointer to a function that checks if the device have some task capabilities (Ignored if set to NULL) + * @retval [out]: pointer to doca_dev struct, NULL if not found * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t register_urom_common_params(void); +doca_error_t ucc_cl_doca_urom_open_doca_device_with_ibdev_name( + const uint8_t *value, + size_t val_size, + ucc_cl_doca_urom_tasks_check func, + struct doca_dev **retval); /* * Start UROM service context @@ -57,7 +62,7 @@ doca_error_t register_urom_common_params(void); * @service [out]: service context * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t start_urom_service(struct doca_pe *pe, +doca_error_t ucc_cl_doca_urom_start_urom_service(struct doca_pe *pe, struct doca_dev *dev, uint64_t nb_workers, struct doca_urom_service **service); @@ -77,16 +82,16 @@ doca_error_t start_urom_service(struct doca_pe *pe, * @worker [out]: set worker context * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t start_urom_worker(struct doca_pe *pe, - struct doca_urom_service *service, - uint64_t worker_id, - uint32_t *gid, - uint64_t nb_tasks, - doca_cpu_set_t *cpuset, - char **env, - size_t env_count, - uint64_t plugins, - struct doca_urom_worker **worker); +doca_error_t ucc_cl_doca_urom_start_urom_worker(struct doca_pe *pe, + struct doca_urom_service *service, + uint64_t worker_id, + uint32_t *gid, + uint64_t nb_tasks, + doca_cpu_set_t *cpuset, + char **env, + size_t env_count, + uint64_t plugins, + struct doca_urom_worker **worker); /* * Start UROM domain context @@ -101,12 +106,13 @@ doca_error_t start_urom_worker(struct doca_pe *pe, * @domain [out]: domain context * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t start_urom_domain(struct doca_pe *pe, - struct doca_urom_domain_oob_coll *oob, - uint64_t *worker_ids, - struct doca_urom_worker **workers, - size_t nb_workers, - struct urom_domain_buffer_attrs *buffers, - size_t nb_buffers, - struct doca_urom_domain **domain); -#endif /* UROM_COMMON_H_ */ +doca_error_t ucc_cl_doca_urom_start_urom_domain(struct doca_pe *pe, + struct doca_urom_domain_oob_coll *oob, + uint64_t *worker_ids, + struct doca_urom_worker **workers, + size_t nb_workers, + struct ucc_cl_doca_urom_domain_buffer_attrs *buffers, + size_t nb_buffers, + struct doca_urom_domain **domain); + +#endif /* UCC_CL_DOCA_UROM_COMMON_H_ */ diff --git a/src/components/cl/doca_urom/cl_doca_urom_common_doca.c b/src/components/cl/doca_urom/cl_doca_urom_common_doca.c deleted file mode 100644 index df8a825639..0000000000 --- a/src/components/cl/doca_urom/cl_doca_urom_common_doca.c +++ /dev/null @@ -1,498 +0,0 @@ -/* - * Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED. - * - * This software product is a proprietary product of NVIDIA CORPORATION & - * AFFILIATES (the "Company") and all right, title, and interest in and to the - * software product, including all associated intellectual property rights, are - * and shall remain exclusively with the Company. - * - * This software product is governed by the End User License Agreement - * provided with the software product. - * - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cl_doca_urom_common_doca.h" - -DOCA_LOG_REGISTER(COMMON); - -doca_error_t open_doca_device_with_pci(const char *pci_addr, tasks_check func, struct doca_dev **retval) -{ - struct doca_devinfo **dev_list; - uint32_t nb_devs; - uint8_t is_addr_equal = 0; - int res; - size_t i; - - /* Set default return value */ - *retval = NULL; - - res = doca_devinfo_create_list(&dev_list, &nb_devs); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(res)); - return res; - } - - /* Search */ - for (i = 0; i < nb_devs; i++) { - res = doca_devinfo_is_equal_pci_addr(dev_list[i], pci_addr, &is_addr_equal); - if (res == DOCA_SUCCESS && is_addr_equal) { - /* If any special capabilities are needed */ - if (func != NULL && func(dev_list[i]) != DOCA_SUCCESS) - continue; - - /* if device can be opened */ - res = doca_dev_open(dev_list[i], retval); - if (res == DOCA_SUCCESS) { - doca_devinfo_destroy_list(dev_list); - return res; - } - } - } - - DOCA_LOG_WARN("Matching device not found"); - res = DOCA_ERROR_NOT_FOUND; - - doca_devinfo_destroy_list(dev_list); - return res; -} - -doca_error_t open_doca_device_with_ibdev_name(const uint8_t *value, - size_t val_size, - tasks_check func, - struct doca_dev **retval) -{ - struct doca_devinfo **dev_list; - uint32_t nb_devs; - char buf[DOCA_DEVINFO_IBDEV_NAME_SIZE] = {}; - char val_copy[DOCA_DEVINFO_IBDEV_NAME_SIZE] = {}; - int res; - size_t i; - - /* Set default return value */ - *retval = NULL; - - /* Setup */ - if (val_size > DOCA_DEVINFO_IBDEV_NAME_SIZE) { - DOCA_LOG_ERR("Value size too large. Failed to locate device"); - return DOCA_ERROR_INVALID_VALUE; - } - memcpy(val_copy, value, val_size); - - res = doca_devinfo_create_list(&dev_list, &nb_devs); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(res)); - return res; - } - - /* Search */ - for (i = 0; i < nb_devs; i++) { - res = doca_devinfo_get_ibdev_name(dev_list[i], buf, DOCA_DEVINFO_IBDEV_NAME_SIZE); - if (res == DOCA_SUCCESS && strncmp(buf, val_copy, val_size) == 0) { - /* If any special capabilities are needed */ - if (func != NULL && func(dev_list[i]) != DOCA_SUCCESS) - continue; - - /* if device can be opened */ - res = doca_dev_open(dev_list[i], retval); - if (res == DOCA_SUCCESS) { - doca_devinfo_destroy_list(dev_list); - return res; - } - } - } - - DOCA_LOG_WARN("Matching device not found"); - res = DOCA_ERROR_NOT_FOUND; - - doca_devinfo_destroy_list(dev_list); - return res; -} - -doca_error_t open_doca_device_with_iface_name(const uint8_t *value, - size_t val_size, - tasks_check func, - struct doca_dev **retval) -{ - struct doca_devinfo **dev_list; - uint32_t nb_devs; - char buf[DOCA_DEVINFO_IFACE_NAME_SIZE] = {}; - char val_copy[DOCA_DEVINFO_IFACE_NAME_SIZE] = {}; - int res; - size_t i; - - /* Set default return value */ - *retval = NULL; - - /* Setup */ - if (val_size > DOCA_DEVINFO_IFACE_NAME_SIZE) { - DOCA_LOG_ERR("Value size too large. Failed to locate device"); - return DOCA_ERROR_INVALID_VALUE; - } - memcpy(val_copy, value, val_size); - - res = doca_devinfo_create_list(&dev_list, &nb_devs); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(res)); - return res; - } - - /* Search */ - for (i = 0; i < nb_devs; i++) { - res = doca_devinfo_get_iface_name(dev_list[i], buf, DOCA_DEVINFO_IFACE_NAME_SIZE); - if (res == DOCA_SUCCESS && strncmp(buf, val_copy, val_size) == 0) { - /* If any special capabilities are needed */ - if (func != NULL && func(dev_list[i]) != DOCA_SUCCESS) - continue; - - /* if device can be opened */ - res = doca_dev_open(dev_list[i], retval); - if (res == DOCA_SUCCESS) { - doca_devinfo_destroy_list(dev_list); - return res; - } - } - } - - DOCA_LOG_WARN("Matching device not found"); - res = DOCA_ERROR_NOT_FOUND; - - doca_devinfo_destroy_list(dev_list); - return res; -} - -doca_error_t open_doca_device_with_capabilities(tasks_check func, struct doca_dev **retval) -{ - struct doca_devinfo **dev_list; - uint32_t nb_devs; - doca_error_t result; - size_t i; - - /* Set default return value */ - *retval = NULL; - - result = doca_devinfo_create_list(&dev_list, &nb_devs); - if (result != DOCA_SUCCESS) { - DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(result)); - return result; - } - - /* Search */ - for (i = 0; i < nb_devs; i++) { - /* If any special capabilities are needed */ - if (func(dev_list[i]) != DOCA_SUCCESS) - continue; - - /* If device can be opened */ - if (doca_dev_open(dev_list[i], retval) == DOCA_SUCCESS) { - doca_devinfo_destroy_list(dev_list); - return DOCA_SUCCESS; - } - } - - DOCA_LOG_WARN("Matching device not found"); - doca_devinfo_destroy_list(dev_list); - return DOCA_ERROR_NOT_FOUND; -} - -doca_error_t open_doca_device_rep_with_vuid(struct doca_dev *local, - enum doca_devinfo_rep_filter filter, - const uint8_t *value, - size_t val_size, - struct doca_dev_rep **retval) -{ - uint32_t nb_rdevs = 0; - struct doca_devinfo_rep **rep_dev_list = NULL; - char val_copy[DOCA_DEVINFO_REP_VUID_SIZE] = {}; - char buf[DOCA_DEVINFO_REP_VUID_SIZE] = {}; - doca_error_t result; - size_t i; - - /* Set default return value */ - *retval = NULL; - - /* Setup */ - if (val_size > DOCA_DEVINFO_REP_VUID_SIZE) { - DOCA_LOG_ERR("Value size too large. Ignored"); - return DOCA_ERROR_INVALID_VALUE; - } - memcpy(val_copy, value, val_size); - - /* Search */ - result = doca_devinfo_rep_create_list(local, filter, &rep_dev_list, &nb_rdevs); - if (result != DOCA_SUCCESS) { - DOCA_LOG_ERR( - "Failed to create devinfo representor list. Representor devices are available only on DPU, do not run on Host"); - return DOCA_ERROR_INVALID_VALUE; - } - - for (i = 0; i < nb_rdevs; i++) { - result = doca_devinfo_rep_get_vuid(rep_dev_list[i], buf, DOCA_DEVINFO_REP_VUID_SIZE); - if (result == DOCA_SUCCESS && strncmp(buf, val_copy, DOCA_DEVINFO_REP_VUID_SIZE) == 0 && - doca_dev_rep_open(rep_dev_list[i], retval) == DOCA_SUCCESS) { - doca_devinfo_rep_destroy_list(rep_dev_list); - return DOCA_SUCCESS; - } - } - - DOCA_LOG_WARN("Matching device not found"); - doca_devinfo_rep_destroy_list(rep_dev_list); - return DOCA_ERROR_NOT_FOUND; -} - -doca_error_t open_doca_device_rep_with_pci(struct doca_dev *local, - enum doca_devinfo_rep_filter filter, - const char *pci_addr, - struct doca_dev_rep **retval) -{ - uint32_t nb_rdevs = 0; - struct doca_devinfo_rep **rep_dev_list = NULL; - uint8_t is_addr_equal = 0; - doca_error_t result; - size_t i; - - *retval = NULL; - - /* Search */ - result = doca_devinfo_rep_create_list(local, filter, &rep_dev_list, &nb_rdevs); - if (result != DOCA_SUCCESS) { - DOCA_LOG_ERR( - "Failed to create devinfo representors list. Representor devices are available only on DPU, do not run on Host"); - return DOCA_ERROR_INVALID_VALUE; - } - - for (i = 0; i < nb_rdevs; i++) { - result = doca_devinfo_rep_is_equal_pci_addr(rep_dev_list[i], pci_addr, &is_addr_equal); - if (result == DOCA_SUCCESS && is_addr_equal && - doca_dev_rep_open(rep_dev_list[i], retval) == DOCA_SUCCESS) { - doca_devinfo_rep_destroy_list(rep_dev_list); - return DOCA_SUCCESS; - } - } - - DOCA_LOG_WARN("Matching device not found"); - doca_devinfo_rep_destroy_list(rep_dev_list); - return DOCA_ERROR_NOT_FOUND; -} - -doca_error_t create_core_objects(struct program_core_objects *state, uint32_t max_bufs) -{ - doca_error_t res; - - res = doca_mmap_create(&state->src_mmap); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Unable to create source mmap: %s", doca_error_get_descr(res)); - return res; - } - res = doca_mmap_add_dev(state->src_mmap, state->dev); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Unable to add device to source mmap: %s", doca_error_get_descr(res)); - goto destroy_src_mmap; - } - - res = doca_mmap_create(&state->dst_mmap); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Unable to create destination mmap: %s", doca_error_get_descr(res)); - goto destroy_src_mmap; - } - res = doca_mmap_add_dev(state->dst_mmap, state->dev); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Unable to add device to destination mmap: %s", doca_error_get_descr(res)); - goto destroy_dst_mmap; - } - - if (max_bufs != 0) { - res = doca_buf_inventory_create(max_bufs, &state->buf_inv); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Unable to create buffer inventory: %s", doca_error_get_descr(res)); - goto destroy_dst_mmap; - } - - res = doca_buf_inventory_start(state->buf_inv); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Unable to start buffer inventory: %s", doca_error_get_descr(res)); - goto destroy_buf_inv; - } - } - - res = doca_pe_create(&state->pe); - if (res != DOCA_SUCCESS) { - DOCA_LOG_ERR("Unable to create progress engine: %s", doca_error_get_descr(res)); - goto destroy_buf_inv; - } - - return DOCA_SUCCESS; - -destroy_buf_inv: - if (state->buf_inv != NULL) { - doca_buf_inventory_destroy(state->buf_inv); - state->buf_inv = NULL; - } - -destroy_dst_mmap: - doca_mmap_destroy(state->dst_mmap); - state->dst_mmap = NULL; - -destroy_src_mmap: - doca_mmap_destroy(state->src_mmap); - state->src_mmap = NULL; - - return res; -} - -doca_error_t request_stop_ctx(struct doca_pe *pe, struct doca_ctx *ctx) -{ - doca_error_t tmp_result, result = DOCA_SUCCESS; - - tmp_result = doca_ctx_stop(ctx); - if (tmp_result == DOCA_ERROR_IN_PROGRESS) { - enum doca_ctx_states ctx_state; - - do { - (void)doca_pe_progress(pe); - tmp_result = doca_ctx_get_state(ctx, &ctx_state); - if (tmp_result != DOCA_SUCCESS) { - DOCA_ERROR_PROPAGATE(result, tmp_result); - DOCA_LOG_ERR("Failed to get state from ctx: %s", doca_error_get_descr(tmp_result)); - break; - } - } while (ctx_state != DOCA_CTX_STATE_IDLE); - } else if (tmp_result != DOCA_SUCCESS) { - DOCA_ERROR_PROPAGATE(result, tmp_result); - DOCA_LOG_ERR("Failed to stop ctx: %s", doca_error_get_descr(tmp_result)); - } - - return result; -} - -doca_error_t destroy_core_objects(struct program_core_objects *state) -{ - doca_error_t tmp_result, result = DOCA_SUCCESS; - - if (state->pe != NULL) { - tmp_result = doca_pe_destroy(state->pe); - if (tmp_result != DOCA_SUCCESS) { - DOCA_ERROR_PROPAGATE(result, tmp_result); - DOCA_LOG_ERR("Failed to destroy pe: %s", doca_error_get_descr(tmp_result)); - } - state->pe = NULL; - } - - if (state->buf_inv != NULL) { - tmp_result = doca_buf_inventory_destroy(state->buf_inv); - if (tmp_result != DOCA_SUCCESS) { - DOCA_ERROR_PROPAGATE(result, tmp_result); - DOCA_LOG_ERR("Failed to destroy buf inventory: %s", doca_error_get_descr(tmp_result)); - } - state->buf_inv = NULL; - } - - if (state->dst_mmap != NULL) { - tmp_result = doca_mmap_destroy(state->dst_mmap); - if (tmp_result != DOCA_SUCCESS) { - DOCA_ERROR_PROPAGATE(result, tmp_result); - DOCA_LOG_ERR("Failed to destroy destination mmap: %s", doca_error_get_descr(tmp_result)); - } - state->dst_mmap = NULL; - } - - if (state->src_mmap != NULL) { - tmp_result = doca_mmap_destroy(state->src_mmap); - if (tmp_result != DOCA_SUCCESS) { - DOCA_ERROR_PROPAGATE(result, tmp_result); - DOCA_LOG_ERR("Failed to destroy source mmap: %s", doca_error_get_descr(tmp_result)); - } - state->src_mmap = NULL; - } - - if (state->dev != NULL) { - tmp_result = doca_dev_close(state->dev); - if (tmp_result != DOCA_SUCCESS) { - DOCA_ERROR_PROPAGATE(result, tmp_result); - DOCA_LOG_ERR("Failed to close device: %s", doca_error_get_descr(tmp_result)); - } - state->dev = NULL; - } - - return result; -} - -char *hex_dump(const void *data, size_t size) -{ - /* - * : - * 00000000: 31 32 33 34 35 36 37 38 39 30 61 62 63 64 65 66 1234567890abcdef - * 8 2 8 * 3 1 8 * 3 1 16 1 - */ - const size_t line_size = 8 + 2 + 8 * 3 + 1 + 8 * 3 + 1 + 16 + 1; - size_t i, j, r, read_index; - size_t num_lines, buffer_size; - char *buffer, *write_head; - unsigned char cur_char, printable; - char ascii_line[17]; - const unsigned char *input_buffer; - - /* Allocate a dynamic buffer to hold the full result */ - num_lines = (size + 16 - 1) / 16; - buffer_size = num_lines * line_size + 1; - buffer = (char *)malloc(buffer_size); - if (buffer == NULL) - return NULL; - write_head = buffer; - input_buffer = data; - read_index = 0; - - for (i = 0; i < num_lines; i++) { - /* Offset */ - snprintf(write_head, buffer_size, "%08lX: ", i * 16); - write_head += 8 + 2; - buffer_size -= 8 + 2; - /* Hex print - 2 chunks of 8 bytes */ - for (r = 0; r < 2; r++) { - for (j = 0; j < 8; j++) { - /* If there is content to print */ - if (read_index < size) { - cur_char = input_buffer[read_index++]; - snprintf(write_head, buffer_size, "%02X ", cur_char); - /* Printable chars go "as-is" */ - if (' ' <= cur_char && cur_char <= '~') - printable = cur_char; - /* Otherwise, use a '.' */ - else - printable = '.'; - /* Else, just use spaces */ - } else { - snprintf(write_head, buffer_size, " "); - printable = ' '; - } - ascii_line[r * 8 + j] = printable; - write_head += 3; - buffer_size -= 3; - } - /* Spacer between the 2 hex groups */ - snprintf(write_head, buffer_size, " "); - write_head += 1; - buffer_size -= 1; - } - /* Ascii print */ - ascii_line[16] = '\0'; - snprintf(write_head, buffer_size, "%s\n", ascii_line); - write_head += 16 + 1; - buffer_size -= 16 + 1; - } - /* No need for the last '\n' */ - write_head[-1] = '\0'; - return buffer; -} diff --git a/src/components/cl/doca_urom/cl_doca_urom_common_doca.h b/src/components/cl/doca_urom/cl_doca_urom_common_doca.h deleted file mode 100644 index 1c5d38f426..0000000000 --- a/src/components/cl/doca_urom/cl_doca_urom_common_doca.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED. - * - * This software product is a proprietary product of NVIDIA CORPORATION & - * AFFILIATES (the "Company") and all right, title, and interest in and to the - * software product, including all associated intellectual property rights, are - * and shall remain exclusively with the Company. - * - * This software product is governed by the End User License Agreement - * provided with the software product. - * - */ - -#ifndef COMMON_H_ -#define COMMON_H_ - -#include -#include - -/* Function to check if a given device is capable of executing some task */ -typedef doca_error_t (*tasks_check)(struct doca_devinfo *); - -/* DOCA core objects used by the samples / applications */ -struct program_core_objects { - struct doca_dev *dev; /* doca device */ - struct doca_mmap *src_mmap; /* doca mmap for source buffer */ - struct doca_mmap *dst_mmap; /* doca mmap for destination buffer */ - struct doca_buf_inventory *buf_inv; /* doca buffer inventory */ - struct doca_ctx *ctx; /* doca context */ - struct doca_pe *pe; /* doca progress engine */ -}; - -/* - * Open a DOCA device according to a given PCI address - * - * @pci_addr [in]: PCI address - * @func [in]: pointer to a function that checks if the device have some task capabilities (Ignored if set to NULL) - * @retval [out]: pointer to doca_dev struct, NULL if not found - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -doca_error_t open_doca_device_with_pci(const char *pci_addr, tasks_check func, struct doca_dev **retval); - -/* - * Open a DOCA device according to a given IB device name - * - * @value [in]: IB device name - * @val_size [in]: input length, in bytes - * @func [in]: pointer to a function that checks if the device have some task capabilities (Ignored if set to NULL) - * @retval [out]: pointer to doca_dev struct, NULL if not found - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -doca_error_t open_doca_device_with_ibdev_name(const uint8_t *value, - size_t val_size, - tasks_check func, - struct doca_dev **retval); - -/* - * Open a DOCA device according to a given interface name - * - * @value [in]: interface name - * @val_size [in]: input length, in bytes - * @func [in]: pointer to a function that checks if the device have some task capabilities (Ignored if set to NULL) - * @retval [out]: pointer to doca_dev struct, NULL if not found - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -doca_error_t open_doca_device_with_iface_name(const uint8_t *value, - size_t val_size, - tasks_check func, - struct doca_dev **retval); - -/* - * Open a DOCA device with a custom set of capabilities - * - * @func [in]: pointer to a function that checks if the device have some task capabilities - * @retval [out]: pointer to doca_dev struct, NULL if not found - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -doca_error_t open_doca_device_with_capabilities(tasks_check func, struct doca_dev **retval); - -/* - * Open a DOCA device representor according to a given VUID string - * - * @local [in]: queries represtors of the given local doca device - * @filter [in]: bitflags filter to narrow the represetors in the search - * @value [in]: IB device name - * @val_size [in]: input length, in bytes - * @retval [out]: pointer to doca_dev_rep struct, NULL if not found - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -doca_error_t open_doca_device_rep_with_vuid(struct doca_dev *local, - enum doca_devinfo_rep_filter filter, - const uint8_t *value, - size_t val_size, - struct doca_dev_rep **retval); - -/* - * Open a DOCA device according to a given PCI address - * - * @local [in]: queries representors of the given local doca device - * @filter [in]: bitflags filter to narrow the representors in the search - * @pci_addr [in]: PCI address - * @retval [out]: pointer to doca_dev_rep struct, NULL if not found - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -doca_error_t open_doca_device_rep_with_pci(struct doca_dev *local, - enum doca_devinfo_rep_filter filter, - const char *pci_addr, - struct doca_dev_rep **retval); - -/* - * Initialize a series of DOCA Core objects needed for the program's execution - * - * @state [in]: struct containing the set of initialized DOCA Core objects - * @max_bufs [in]: maximum number of buffers for DOCA Inventory - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -doca_error_t create_core_objects(struct program_core_objects *state, uint32_t max_bufs); - -/* - * Request to stop context - * - * @pe [in]: DOCA progress engine - * @ctx [in]: DOCA context added to the progress engine - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -doca_error_t request_stop_ctx(struct doca_pe *pe, struct doca_ctx *ctx); - -/* - * Cleanup the series of DOCA Core objects created by create_core_objects - * - * @state [in]: struct containing the set of initialized DOCA Core objects - * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise - */ -doca_error_t destroy_core_objects(struct program_core_objects *state); - -/* - * Create a string Hex dump representation of the given input buffer - * - * @data [in]: Pointer to the input buffer - * @size [in]: Number of bytes to be analyzed - * @return: pointer to the string representation, or NULL if an error was encountered - */ -char *hex_dump(const void *data, size_t size); - -#endif diff --git a/src/components/cl/doca_urom/cl_doca_urom_context.c b/src/components/cl/doca_urom/cl_doca_urom_context.c index 6606d8bf85..0048af04bc 100644 --- a/src/components/cl/doca_urom/cl_doca_urom_context.c +++ b/src/components/cl/doca_urom/cl_doca_urom_context.c @@ -37,21 +37,11 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_context_t, const ucc_base_context_params_t *params, const ucc_base_config_t *config) { - ucc_tl_ucp_context_t *tl_ctx; - enum doca_ctx_states state; - struct export_buf ebuf; - ucc_status_t status; - ucs_status_t ucs_status; - ucc_rank_t rank; - uint64_t rank_u64; - void *buffer; - int i; - int ret; - struct urom_domain_buffer_attrs buf_attrs = {0}; + struct ucc_cl_doca_urom_domain_buffer_attrs buf_attrs = {0}; struct doca_urom_domain_oob_coll oob_coll = {0}; doca_error_t tmp_result = DOCA_SUCCESS; union doca_data cookie = {0}; - struct ucc_result res = {0}; + struct ucc_cl_doca_urom_result res = {0}; doca_error_t result = DOCA_SUCCESS; size_t length = 4096; int ucp_index = -1; @@ -67,6 +57,16 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_context_t, .mask = UCC_LIB_PARAM_FIELD_THREAD_MODE, .thread_mode = UCC_THREAD_SINGLE, }; + ucc_tl_ucp_context_t *tl_ctx; + enum doca_ctx_states state; + struct export_buf ebuf; + ucc_status_t status; + ucs_status_t ucs_status; + ucc_rank_t rank; + uint64_t rank_u64; + void *buffer; + int i; + int ret; UCC_CLASS_CALL_SUPER_INIT(ucc_cl_context_t, &cl_config->super, params->context); @@ -119,7 +119,7 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_context_t, } /* Create and start worker context */ - result = start_urom_worker(doca_urom_lib->urom_ctx.urom_pe, + result = ucc_cl_doca_urom_start_urom_worker(doca_urom_lib->urom_ctx.urom_pe, doca_urom_lib->urom_ctx.urom_service, rank, NULL, 16, NULL, envs, num_envs, doca_urom_lib->urom_ctx.ucc_info->id, @@ -181,7 +181,7 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_context_t, /* Create domain context */ rank_u64 = (uint64_t)rank; - result = start_urom_domain(doca_urom_lib->urom_ctx.urom_pe, &oob_coll, + result = ucc_cl_doca_urom_start_urom_domain(doca_urom_lib->urom_ctx.urom_pe, &oob_coll, &rank_u64, &doca_urom_lib->urom_ctx.urom_worker, 1, &buf_attrs, 1, &doca_urom_lib->urom_ctx.urom_domain); @@ -207,9 +207,9 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_context_t, /* Create lib */ cookie.ptr = &res; - result = doca_urom_ucc_task_lib_create(doca_urom_lib->urom_ctx.urom_worker, + result = ucc_cl_doca_urom_task_lib_create(doca_urom_lib->urom_ctx.urom_worker, cookie, rank, &lib_params, - urom_ucc_lib_create_finished); + ucc_cl_doca_urom_lib_create_finished); if (result != DOCA_SUCCESS) { cl_error(cl_config->super.cl_lib, "Failed to create lib creation task"); goto domain_stop; @@ -226,12 +226,12 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_context_t, cl_debug(cl_config->super.cl_lib, "UCC lib create is done"); cl_debug(cl_config->super.cl_lib, "Creating pd channel"); - result = doca_urom_ucc_task_pd_channel(doca_urom_lib->urom_ctx.urom_worker, + result = ucc_cl_doca_urom_task_pd_channel(doca_urom_lib->urom_ctx.urom_worker, cookie, rank, tl_ctx->worker.worker_address, tl_ctx->worker.ucp_addrlen, - urom_ucc_pss_dc_finished); + ucc_cl_doca_urom_pss_dc_finished); if (result != DOCA_SUCCESS) { cl_error(cl_config->super.cl_lib, "Failed to create data channel task"); goto lib_destroy; @@ -249,11 +249,11 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_context_t, cl_debug(cl_config->super.cl_lib, "Passive data channel is done"); cl_debug(cl_config->super.cl_lib, "Creating task ctx"); - result = doca_urom_ucc_task_ctx_create(doca_urom_lib->urom_ctx.urom_worker, + result = ucc_cl_doca_urom_task_ctx_create(doca_urom_lib->urom_ctx.urom_worker, cookie, rank, 0, NULL, 1, params->params.oob.n_oob_eps, 0x0, length, - urom_ucc_ctx_create_finished); + ucc_cl_doca_urom_ctx_create_finished); if (result != DOCA_SUCCESS) { cl_error(cl_config->super.cl_lib, "Failed to create UCC context task"); goto lib_destroy; @@ -288,8 +288,8 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_context_t, return UCC_OK; lib_destroy: - result = doca_urom_ucc_task_lib_destroy(doca_urom_lib->urom_ctx.urom_worker, - cookie, rank, lib_destroy_finished); + result = ucc_cl_doca_urom_task_lib_destroy(doca_urom_lib->urom_ctx.urom_worker, + cookie, rank, ucc_cl_doca_urom_lib_destroy_finished); if (result != DOCA_SUCCESS) { cl_error(self->super.super.lib, "Failed to create UCC lib destroy task"); @@ -334,21 +334,21 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_context_t, UCC_CLASS_CLEANUP_FUNC(ucc_cl_doca_urom_context_t) { - int i, ret; - ucc_rank_t rank; ucc_cl_doca_urom_lib_t *doca_urom_lib = ucc_derived_of(self->super.super.lib, ucc_cl_doca_urom_lib_t); - struct ucc_result res = {0}; + struct ucc_cl_doca_urom_result res = {0}; union doca_data cookie = {0}; doca_error_t result = DOCA_SUCCESS; + int i, ret; + ucc_rank_t rank; rank = doca_urom_lib->urom_ctx.ctx_rank; cookie.ptr = &res; // nick TODO why isnt this func called? - result = doca_urom_ucc_task_lib_destroy(doca_urom_lib->urom_ctx.urom_worker, - cookie, rank, lib_destroy_finished); + result = ucc_cl_doca_urom_task_lib_destroy(doca_urom_lib->urom_ctx.urom_worker, + cookie, rank, ucc_cl_doca_urom_lib_destroy_finished); if (result != DOCA_SUCCESS) { cl_error(self->super.super.lib, "Failed to create UCC lib destroy task"); @@ -393,4 +393,3 @@ ucc_cl_doca_urom_get_context_attr(const ucc_base_context_t *context, return UCC_OK; } - diff --git a/src/components/cl/doca_urom/cl_doca_urom_lib.c b/src/components/cl/doca_urom/cl_doca_urom_lib.c index 1f8ee6c8be..89aa63b0f9 100644 --- a/src/components/cl/doca_urom/cl_doca_urom_lib.c +++ b/src/components/cl/doca_urom/cl_doca_urom_lib.c @@ -16,16 +16,16 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_lib_t, const ucc_base_lib_params_t *params, const ucc_base_config_t *config) { - const struct doca_urom_service_plugin_info *plugins; - char *plugin_name; - char *device; - size_t i; struct doca_log_backend *sdk_log = NULL; doca_error_t tmp_result = DOCA_SUCCESS; doca_error_t result = DOCA_SUCCESS; size_t plugins_count = 0; const ucc_cl_doca_urom_lib_config_t *cl_config = ucc_derived_of(config, ucc_cl_doca_urom_lib_config_t); + const struct doca_urom_service_plugin_info *plugins; + char *plugin_name; + char *device; + size_t i; UCC_CLASS_CALL_SUPER_INIT(ucc_cl_lib_t, &ucc_cl_doca_urom.super, &cl_config->super); @@ -48,7 +48,7 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_lib_t, const ucc_base_lib_params_t *params, return UCC_ERR_NO_RESOURCE; } - result = open_doca_device_with_ibdev_name((uint8_t *)device, strlen(device), + result = ucc_cl_doca_urom_open_doca_device_with_ibdev_name((uint8_t *)device, strlen(device), NULL, &self->dev); if (result != DOCA_SUCCESS) { cl_error(&self->super, "failed to open device %s\n", device); @@ -61,7 +61,7 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_lib_t, const ucc_base_lib_params_t *params, goto dev_close; } - result = start_urom_service(self->urom_ctx.urom_pe, self->dev, 2, + result = ucc_cl_doca_urom_start_urom_service(self->urom_ctx.urom_pe, self->dev, 2, &self->urom_ctx.urom_service); if (result != DOCA_SUCCESS) { cl_error(&self->super, "Failed to create UROM service context"); @@ -90,7 +90,7 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_lib_t, const ucc_base_lib_params_t *params, goto service_stop; } - result = urom_ucc_init(self->urom_ctx.ucc_info->id, + result = ucc_cl_doca_urom_save_plugin_id(self->urom_ctx.ucc_info->id, self->urom_ctx.ucc_info->version); if (result != DOCA_SUCCESS) { cl_error(&self->super, "Failed to init UCC worker plugin"); @@ -105,8 +105,6 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_lib_t, const ucc_base_lib_params_t *params, return UCC_ERR_NO_MEMORY; } - //self->tl_ucp_index = -1; // nick: why was this here? - return UCC_OK; service_stop: @@ -242,4 +240,3 @@ ucc_status_t ucc_cl_doca_urom_get_lib_properties(ucc_base_lib_properties_t *prop return UCC_OK; } - diff --git a/src/components/cl/doca_urom/cl_doca_urom_team.c b/src/components/cl/doca_urom/cl_doca_urom_team.c index e870bfd917..e5af4461c9 100644 --- a/src/components/cl/doca_urom/cl_doca_urom_team.c +++ b/src/components/cl/doca_urom/cl_doca_urom_team.c @@ -11,13 +11,13 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_team_t, ucc_base_context_t *cl_context, const ucc_base_team_params_t *params) { - ucc_status_t status; union doca_data cookie = {0}; doca_error_t result = DOCA_SUCCESS; ucc_cl_doca_urom_context_t *ctx = ucc_derived_of(cl_context, ucc_cl_doca_urom_context_t); ucc_cl_doca_urom_lib_t *doca_urom_lib = ucc_derived_of(ctx->super.super.lib, ucc_cl_doca_urom_lib_t); + ucc_status_t status; UCC_CLASS_CALL_SUPER_INIT(ucc_cl_team_t, &ctx->super, params); @@ -37,14 +37,14 @@ UCC_CLASS_INIT_FUNC(ucc_cl_doca_urom_team_t, ucc_base_context_t *cl_context, cookie.ptr = &self->res; - result = doca_urom_ucc_task_team_create(doca_urom_lib->urom_ctx.urom_worker, + result = ucc_cl_doca_urom_task_team_create(doca_urom_lib->urom_ctx.urom_worker, cookie, doca_urom_lib->urom_ctx.ctx_rank, 0 /* start */, 1 /* stride */, params->params.oob.n_oob_eps /* size */, doca_urom_lib->urom_ctx.urom_ucc_context, - urom_ucc_team_create_finished); + ucc_cl_doca_urom_team_create_finished); if (result != DOCA_SUCCESS) { cl_error(cl_context->lib, "Failed to create UCC team task"); @@ -82,8 +82,8 @@ ucc_status_t ucc_cl_doca_urom_team_create_test(ucc_base_team_t *cl_team) ucc_derived_of(ctx->super.super.lib, ucc_cl_doca_urom_lib_t); ucc_memory_type_t mem_types[2] = {UCC_MEMORY_TYPE_HOST, UCC_MEMORY_TYPE_CUDA}; - struct team_create_result *team_create = &team->res.team_create; - struct ucc_result res = {0}; + struct ucc_cl_doca_urom_team_create_result *team_create = &team->res.team_create; + struct ucc_cl_doca_urom_result res = {0}; ucc_coll_score_t *score = NULL; int mt_n = 2; @@ -165,4 +165,3 @@ ucc_status_t ucc_cl_doca_urom_team_get_scores(ucc_base_team_t *cl_team, *score = NULL; return status; } - diff --git a/src/components/cl/doca_urom/cl_doca_urom_worker_ucc.c b/src/components/cl/doca_urom/cl_doca_urom_worker_ucc.c index 7e32829dda..654de4845b 100644 --- a/src/components/cl/doca_urom/cl_doca_urom_worker_ucc.c +++ b/src/components/cl/doca_urom/cl_doca_urom_worker_ucc.c @@ -19,7 +19,7 @@ #include "cl_doca_urom_worker_ucc.h" -DOCA_LOG_REGISTER(UROM::WORKER::UCC); +DOCA_LOG_REGISTER(UCC::DOCA_CL : WORKER_UCC); static uint64_t ucc_id; /* UCC plugin id, id is generated by UROM lib and * will be updated in init function @@ -27,16 +27,16 @@ static uint64_t ucc_id; /* UCC plugin id, id is generated by UROM lib and static uint64_t ucc_version = 0x01; /* UCC plugin host version */ /* UCC task metadata */ -struct doca_ucc_task_data { +struct ucc_cl_doca_urom_task_data { union doca_data cookie; /* User cookie */ union { - doca_urom_ucc_lib_create_finished lib_create; /* User lib create task callback */ - doca_urom_ucc_lib_destroy_finished lib_destroy; /* User lib destroy task callback */ - doca_urom_ucc_ctx_create_finished ctx_create; /* User context create task callback */ - doca_urom_ucc_ctx_destroy_finished ctx_destroy; /* User context destroy task callback */ - doca_urom_ucc_team_create_finished team_create; /* User UCC team create task callback */ - doca_urom_ucc_collective_finished collective; /* User UCC collective task callback */ - doca_urom_ucc_pd_channel_finished pd_channel; /* User passive data channel task callback */ + ucc_cl_doca_urom_lib_create_finished_cb lib_create; /* User lib create task callback */ + ucc_cl_doca_urom_lib_destroy_finished_cb lib_destroy; /* User lib destroy task callback */ + ucc_cl_doca_urom_ctx_create_finished_cb ctx_create; /* User context create task callback */ + ucc_cl_doca_urom_ctx_destroy_finished_cb ctx_destroy; /* User context destroy task callback */ + ucc_cl_doca_urom_team_create_finished_cb team_create; /* User UCC team create task callback */ + ucc_cl_doca_urom_collective_finished_cb collective; /* User UCC collective task callback */ + ucc_cl_doca_urom_pd_channel_finished_cb pd_channel; /* User passive data channel task callback */ }; }; @@ -47,7 +47,7 @@ struct doca_ucc_task_data { * @ucc_notif [out]: set unpacked UCC notification * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -static doca_error_t urom_worker_ucc_notif_unpack(void *packed_notif, struct urom_worker_notify_ucc **ucc_notif) +static doca_error_t notif_unpack(void *packed_notif, struct urom_worker_notify_ucc **ucc_notif) { *ucc_notif = packed_notif; return DOCA_SUCCESS; @@ -59,18 +59,18 @@ static doca_error_t urom_worker_ucc_notif_unpack(void *packed_notif, struct urom * @task [in]: UROM worker task * @type [in]: UCC task type */ -static void urom_ucc_completion(struct doca_urom_worker_cmd_task *task, enum urom_worker_ucc_notify_type type) +static void completion(struct doca_urom_worker_cmd_task *task, enum urom_worker_ucc_notify_type type) { - size_t data_len; - doca_error_t result; - struct doca_buf *response; - struct urom_worker_notify_ucc notify_error = {0}; - struct urom_worker_notify_ucc *ucc_notify = ¬ify_error; - struct doca_ucc_task_data *task_data; + struct urom_worker_notify_ucc notify_error = {0}; + struct urom_worker_notify_ucc *ucc_notify = ¬ify_error; + struct ucc_cl_doca_urom_task_data *task_data; + struct doca_buf *response; + doca_error_t result; + size_t data_len; notify_error.notify_type = type; - task_data = (struct doca_ucc_task_data *)doca_urom_worker_cmd_task_get_user_data(task); + task_data = (struct ucc_cl_doca_urom_task_data *)doca_urom_worker_cmd_task_get_user_data(task); if (task_data == NULL) { DOCA_LOG_ERR("Failed to get task data buffer"); goto task_release; @@ -87,7 +87,7 @@ static void urom_ucc_completion(struct doca_urom_worker_cmd_task *task, enum uro if (result != DOCA_SUCCESS) goto error_exit; - result = urom_worker_ucc_notif_unpack((void *)ucc_notify, &ucc_notify); + result = notif_unpack((void *)ucc_notify, &ucc_notify); if (result != DOCA_SUCCESS) goto error_exit; @@ -161,18 +161,18 @@ static void urom_ucc_completion(struct doca_urom_worker_cmd_task *task, enum uro * @packed_cmd [out]: packed command buffer * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -static doca_error_t urom_worker_ucc_cmd_pack(struct urom_worker_ucc_cmd *ucc_cmd, +static doca_error_t cmd_pack(struct urom_worker_ucc_cmd *ucc_cmd, size_t *packed_cmd_len, void *packed_cmd) { - void *pack_head; - size_t pack_len; - size_t team_size; - size_t disp_pack_size; - size_t count_pack_size; + void *pack_tail = packed_cmd; + void *pack_head; + size_t pack_len; + size_t team_size; + size_t disp_pack_size; + size_t count_pack_size; ucc_coll_args_t *coll_args; int is_count_64, is_disp_64; - void *pack_tail = packed_cmd; pack_len = sizeof(struct urom_worker_ucc_cmd); if (pack_len > *packed_cmd_len) @@ -256,27 +256,27 @@ static doca_error_t urom_worker_ucc_cmd_pack(struct urom_worker_ucc_cmd *ucc_cmd * @task_user_data [in]: task user data * @ctx_user_data [in]: worker context user data */ -static void doca_urom_ucc_lib_create_completed(struct doca_urom_worker_cmd_task *task, +static void lib_create_completed(struct doca_urom_worker_cmd_task *task, union doca_data task_user_data, union doca_data ctx_user_data) { (void)task_user_data; (void)ctx_user_data; - urom_ucc_completion(task, UROM_WORKER_NOTIFY_UCC_LIB_CREATE_COMPLETE); + completion(task, UROM_WORKER_NOTIFY_UCC_LIB_CREATE_COMPLETE); } -doca_error_t doca_urom_ucc_task_lib_create(struct doca_urom_worker *worker_ctx, +doca_error_t ucc_cl_doca_urom_task_lib_create(struct doca_urom_worker *worker_ctx, union doca_data cookie, uint64_t dpu_worker_id, void *params, - doca_urom_ucc_lib_create_finished cb) + ucc_cl_doca_urom_lib_create_finished_cb cb) { - doca_error_t result; - size_t pack_len = 0; - struct doca_buf *payload; - struct doca_urom_worker_cmd_task *task; - struct doca_ucc_task_data *task_data; - struct urom_worker_ucc_cmd *ucc_cmd; + size_t pack_len = 0; + struct doca_buf *payload; + struct doca_urom_worker_cmd_task *task; + struct ucc_cl_doca_urom_task_data *task_data; + struct urom_worker_ucc_cmd *ucc_cmd; + doca_error_t result; /* Allocate task */ result = doca_urom_worker_cmd_task_allocate_init(worker_ctx, ucc_id, &task); @@ -297,7 +297,7 @@ doca_error_t doca_urom_ucc_task_lib_create(struct doca_urom_worker *worker_ctx, ucc_cmd->dpu_worker_id = dpu_worker_id; ucc_cmd->lib_create_cmd.params = params; - result = urom_worker_ucc_cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); + result = cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); if (result != DOCA_SUCCESS) goto task_destroy; @@ -305,11 +305,11 @@ doca_error_t doca_urom_ucc_task_lib_create(struct doca_urom_worker *worker_ctx, if (result != DOCA_SUCCESS) goto task_destroy; - task_data = (struct doca_ucc_task_data *)doca_urom_worker_cmd_task_get_user_data(task); + task_data = (struct ucc_cl_doca_urom_task_data *)doca_urom_worker_cmd_task_get_user_data(task); task_data->lib_create = cb; task_data->cookie = cookie; - doca_urom_worker_cmd_task_set_cb(task, doca_urom_ucc_lib_create_completed); + doca_urom_worker_cmd_task_set_cb(task, lib_create_completed); result = doca_task_submit(doca_urom_worker_cmd_task_as_task(task)); if (result != DOCA_SUCCESS) @@ -329,26 +329,26 @@ doca_error_t doca_urom_ucc_task_lib_create(struct doca_urom_worker *worker_ctx, * @task_user_data [in]: task user data * @ctx_user_data [in]: worker context user data */ -static void doca_urom_ucc_lib_destroy_completed(struct doca_urom_worker_cmd_task *task, +static void lib_destroy_completed(struct doca_urom_worker_cmd_task *task, union doca_data task_user_data, union doca_data ctx_user_data) { (void)task_user_data; (void)ctx_user_data; - urom_ucc_completion(task, UROM_WORKER_NOTIFY_UCC_LIB_DESTROY_COMPLETE); + completion(task, UROM_WORKER_NOTIFY_UCC_LIB_DESTROY_COMPLETE); } doca_error_t doca_urom_ucc_task_lib_destroy(struct doca_urom_worker *worker_ctx, union doca_data cookie, uint64_t dpu_worker_id, - doca_urom_ucc_lib_destroy_finished cb) + ucc_cl_doca_urom_lib_destroy_finished_cb cb) { - doca_error_t result; - size_t pack_len = 0; - struct doca_buf *payload; - struct doca_urom_worker_cmd_task *task; - struct doca_ucc_task_data *task_data; - struct urom_worker_ucc_cmd *ucc_cmd; + size_t pack_len = 0; + struct doca_buf *payload; + struct doca_urom_worker_cmd_task *task; + struct ucc_cl_doca_urom_task_data *task_data; + struct urom_worker_ucc_cmd *ucc_cmd; + doca_error_t result; /* Allocate task */ result = doca_urom_worker_cmd_task_allocate_init(worker_ctx, ucc_id, &task); @@ -368,7 +368,7 @@ doca_error_t doca_urom_ucc_task_lib_destroy(struct doca_urom_worker *worker_ctx, ucc_cmd->cmd_type = UROM_WORKER_CMD_UCC_LIB_DESTROY; ucc_cmd->dpu_worker_id = dpu_worker_id; - result = urom_worker_ucc_cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); + result = cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); if (result != DOCA_SUCCESS) goto task_destroy; @@ -376,11 +376,11 @@ doca_error_t doca_urom_ucc_task_lib_destroy(struct doca_urom_worker *worker_ctx, if (result != DOCA_SUCCESS) goto task_destroy; - task_data = (struct doca_ucc_task_data *)doca_urom_worker_cmd_task_get_user_data(task); + task_data = (struct ucc_cl_doca_urom_task_data *)doca_urom_worker_cmd_task_get_user_data(task); task_data->lib_destroy = cb; task_data->cookie = cookie; - doca_urom_worker_cmd_task_set_cb(task, doca_urom_ucc_lib_destroy_completed); + doca_urom_worker_cmd_task_set_cb(task, lib_destroy_completed); result = doca_task_submit(doca_urom_worker_cmd_task_as_task(task)); if (result != DOCA_SUCCESS) @@ -400,16 +400,16 @@ doca_error_t doca_urom_ucc_task_lib_destroy(struct doca_urom_worker *worker_ctx, * @task_user_data [in]: task user data * @ctx_user_data [in]: worker context user data */ -static void doca_urom_ucc_ctx_create_completed(struct doca_urom_worker_cmd_task *task, +static void ctx_create_completed(struct doca_urom_worker_cmd_task *task, union doca_data task_user_data, union doca_data ctx_user_data) { (void)task_user_data; (void)ctx_user_data; - urom_ucc_completion(task, UROM_WORKER_NOTIFY_UCC_CONTEXT_CREATE_COMPLETE); + completion(task, UROM_WORKER_NOTIFY_UCC_CONTEXT_CREATE_COMPLETE); } -doca_error_t doca_urom_ucc_task_ctx_create(struct doca_urom_worker *worker_ctx, +doca_error_t ucc_cl_doca_urom_task_ctx_create(struct doca_urom_worker *worker_ctx, union doca_data cookie, uint64_t dpu_worker_id, int64_t start, @@ -418,14 +418,14 @@ doca_error_t doca_urom_ucc_task_ctx_create(struct doca_urom_worker *worker_ctx, int64_t size, void *base_va, uint64_t len, - doca_urom_ucc_ctx_create_finished cb) + ucc_cl_doca_urom_ctx_create_finished_cb cb) { - doca_error_t result; - size_t pack_len = 0; - struct doca_buf *payload; - struct doca_urom_worker_cmd_task *task; - struct doca_ucc_task_data *task_data; - struct urom_worker_ucc_cmd *ucc_cmd; + size_t pack_len = 0; + struct ucc_cl_doca_urom_task_data *task_data; + struct doca_urom_worker_cmd_task *task; + struct urom_worker_ucc_cmd *ucc_cmd; + struct doca_buf *payload; + doca_error_t result; /* Allocate task */ result = doca_urom_worker_cmd_task_allocate_init(worker_ctx, ucc_id, &task); @@ -454,7 +454,7 @@ doca_error_t doca_urom_ucc_task_ctx_create(struct doca_urom_worker *worker_ctx, ucc_cmd->context_create_cmd.base_va = base_va; ucc_cmd->context_create_cmd.len = len; - result = urom_worker_ucc_cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); + result = cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); if (result != DOCA_SUCCESS) goto task_destroy; @@ -462,11 +462,11 @@ doca_error_t doca_urom_ucc_task_ctx_create(struct doca_urom_worker *worker_ctx, if (result != DOCA_SUCCESS) goto task_destroy; - task_data = (struct doca_ucc_task_data *)doca_urom_worker_cmd_task_get_user_data(task); + task_data = (struct ucc_cl_doca_urom_task_data *)doca_urom_worker_cmd_task_get_user_data(task); task_data->ctx_create = cb; task_data->cookie = cookie; - doca_urom_worker_cmd_task_set_cb(task, doca_urom_ucc_ctx_create_completed); + doca_urom_worker_cmd_task_set_cb(task, ctx_create_completed); result = doca_task_submit(doca_urom_worker_cmd_task_as_task(task)); if (result != DOCA_SUCCESS) @@ -486,27 +486,27 @@ doca_error_t doca_urom_ucc_task_ctx_create(struct doca_urom_worker *worker_ctx, * @task_user_data [in]: task user data * @ctx_user_data [in]: worker context user data */ -static void doca_urom_ucc_ctx_destroy_completed(struct doca_urom_worker_cmd_task *task, +static void ctx_destroy_completed(struct doca_urom_worker_cmd_task *task, union doca_data task_user_data, union doca_data ctx_user_data) { (void)task_user_data; (void)ctx_user_data; - urom_ucc_completion(task, UROM_WORKER_NOTIFY_UCC_CONTEXT_DESTROY_COMPLETE); + completion(task, UROM_WORKER_NOTIFY_UCC_CONTEXT_DESTROY_COMPLETE); } -doca_error_t doca_urom_ucc_task_ctx_destroy(struct doca_urom_worker *worker_ctx, +doca_error_t ucc_cl_doca_urom_task_ctx_destroy(struct doca_urom_worker *worker_ctx, union doca_data cookie, uint64_t dpu_worker_id, void *context, - doca_urom_ucc_ctx_destroy_finished cb) + ucc_cl_doca_urom_ctx_destroy_finished_cb cb) { - doca_error_t result; - size_t pack_len = 0; - struct doca_buf *payload; - struct doca_urom_worker_cmd_task *task; - struct doca_ucc_task_data *task_data; - struct urom_worker_ucc_cmd *ucc_cmd; + size_t pack_len = 0; + struct ucc_cl_doca_urom_task_data *task_data; + struct doca_urom_worker_cmd_task *task; + struct urom_worker_ucc_cmd *ucc_cmd; + struct doca_buf *payload; + doca_error_t result; /* Allocate task */ result = doca_urom_worker_cmd_task_allocate_init(worker_ctx, ucc_id, &task); @@ -527,7 +527,7 @@ doca_error_t doca_urom_ucc_task_ctx_destroy(struct doca_urom_worker *worker_ctx, ucc_cmd->dpu_worker_id = dpu_worker_id; ucc_cmd->context_destroy_cmd.context_h = context; - result = urom_worker_ucc_cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); + result = cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); if (result != DOCA_SUCCESS) goto task_destroy; @@ -535,11 +535,11 @@ doca_error_t doca_urom_ucc_task_ctx_destroy(struct doca_urom_worker *worker_ctx, if (result != DOCA_SUCCESS) goto task_destroy; - task_data = (struct doca_ucc_task_data *)doca_urom_worker_cmd_task_get_user_data(task); + task_data = (struct ucc_cl_doca_urom_task_data *)doca_urom_worker_cmd_task_get_user_data(task); task_data->ctx_destroy = cb; task_data->cookie = cookie; - doca_urom_worker_cmd_task_set_cb(task, doca_urom_ucc_ctx_destroy_completed); + doca_urom_worker_cmd_task_set_cb(task, ctx_destroy_completed); result = doca_task_submit(doca_urom_worker_cmd_task_as_task(task)); if (result != DOCA_SUCCESS) @@ -559,30 +559,30 @@ doca_error_t doca_urom_ucc_task_ctx_destroy(struct doca_urom_worker *worker_ctx, * @task_user_data [in]: task user data * @ctx_user_data [in]: worker context user data */ -static void doca_urom_ucc_team_create_completed(struct doca_urom_worker_cmd_task *task, +static void team_create_completed(struct doca_urom_worker_cmd_task *task, union doca_data task_user_data, union doca_data ctx_user_data) { (void)task_user_data; (void)ctx_user_data; - urom_ucc_completion(task, UROM_WORKER_NOTIFY_UCC_TEAM_CREATE_COMPLETE); + completion(task, UROM_WORKER_NOTIFY_UCC_TEAM_CREATE_COMPLETE); } -doca_error_t doca_urom_ucc_task_team_create(struct doca_urom_worker *worker_ctx, +doca_error_t ucc_cl_doca_urom_task_team_create(struct doca_urom_worker *worker_ctx, union doca_data cookie, uint64_t dpu_worker_id, int64_t start, int64_t stride, int64_t size, void *context, - doca_urom_ucc_team_create_finished cb) + ucc_cl_doca_urom_team_create_finished_cb cb) { - doca_error_t result; - size_t pack_len = 0; - struct doca_buf *payload; - struct doca_urom_worker_cmd_task *task; - struct doca_ucc_task_data *task_data; - struct urom_worker_ucc_cmd *ucc_cmd; + size_t pack_len = 0; + struct ucc_cl_doca_urom_task_data *task_data; + struct doca_urom_worker_cmd_task *task; + struct urom_worker_ucc_cmd *ucc_cmd; + struct doca_buf *payload; + doca_error_t result; /* Allocate task */ result = doca_urom_worker_cmd_task_allocate_init(worker_ctx, ucc_id, &task); @@ -606,7 +606,7 @@ doca_error_t doca_urom_ucc_task_team_create(struct doca_urom_worker *worker_ctx, ucc_cmd->team_create_cmd.size = size; ucc_cmd->team_create_cmd.context_h = context; - result = urom_worker_ucc_cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); + result = cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); if (result != DOCA_SUCCESS) goto task_destroy; @@ -614,11 +614,11 @@ doca_error_t doca_urom_ucc_task_team_create(struct doca_urom_worker *worker_ctx, if (result != DOCA_SUCCESS) goto task_destroy; - task_data = (struct doca_ucc_task_data *)doca_urom_worker_cmd_task_get_user_data(task); + task_data = (struct ucc_cl_doca_urom_task_data *)doca_urom_worker_cmd_task_get_user_data(task); task_data->team_create = cb; task_data->cookie = cookie; - doca_urom_worker_cmd_task_set_cb(task, doca_urom_ucc_team_create_completed); + doca_urom_worker_cmd_task_set_cb(task, team_create_completed); result = doca_task_submit(doca_urom_worker_cmd_task_as_task(task)); if (result != DOCA_SUCCESS) @@ -638,16 +638,16 @@ doca_error_t doca_urom_ucc_task_team_create(struct doca_urom_worker *worker_ctx, * @task_user_data [in]: task user data * @ctx_user_data [in]: worker context user data */ -static void doca_urom_ucc_collective_completed(struct doca_urom_worker_cmd_task *task, +static void collective_completed(struct doca_urom_worker_cmd_task *task, union doca_data task_user_data, union doca_data ctx_user_data) { (void)task_user_data; (void)ctx_user_data; - urom_ucc_completion(task, UROM_WORKER_NOTIFY_UCC_COLLECTIVE_COMPLETE); + completion(task, UROM_WORKER_NOTIFY_UCC_COLLECTIVE_COMPLETE); } -doca_error_t doca_urom_ucc_task_collective(struct doca_urom_worker *worker_ctx, +doca_error_t ucc_cl_doca_urom_task_collective(struct doca_urom_worker *worker_ctx, union doca_data cookie, uint64_t dpu_worker_id, void *coll_args, @@ -656,14 +656,14 @@ doca_error_t doca_urom_ucc_task_collective(struct doca_urom_worker *worker_ctx, void *work_buffer, size_t work_buffer_size, size_t team_size, - doca_urom_ucc_collective_finished cb) + ucc_cl_doca_urom_collective_finished_cb cb) { - doca_error_t result; - size_t pack_len = 0; - struct doca_buf *payload; - struct doca_urom_worker_cmd_task *task; - struct doca_ucc_task_data *task_data; - struct urom_worker_ucc_cmd *ucc_cmd; + size_t pack_len = 0; + struct ucc_cl_doca_urom_task_data *task_data; + struct doca_urom_worker_cmd_task *task; + struct urom_worker_ucc_cmd *ucc_cmd; + struct doca_buf *payload; + doca_error_t result; /* Allocate task */ result = doca_urom_worker_cmd_task_allocate_init(worker_ctx, ucc_id, &task); @@ -689,7 +689,7 @@ doca_error_t doca_urom_ucc_task_collective(struct doca_urom_worker *worker_ctx, ucc_cmd->coll_cmd.work_buffer_size = work_buffer_size; ucc_cmd->coll_cmd.team_size = team_size; - result = urom_worker_ucc_cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); + result = cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); if (result != DOCA_SUCCESS) goto task_destroy; @@ -697,11 +697,11 @@ doca_error_t doca_urom_ucc_task_collective(struct doca_urom_worker *worker_ctx, if (result != DOCA_SUCCESS) goto task_destroy; - task_data = (struct doca_ucc_task_data *)doca_urom_worker_cmd_task_get_user_data(task); + task_data = (struct ucc_cl_doca_urom_task_data *)doca_urom_worker_cmd_task_get_user_data(task); task_data->collective = cb; task_data->cookie = cookie; - doca_urom_worker_cmd_task_set_cb(task, doca_urom_ucc_collective_completed); + doca_urom_worker_cmd_task_set_cb(task, collective_completed); result = doca_task_submit(doca_urom_worker_cmd_task_as_task(task)); if (result != DOCA_SUCCESS) @@ -721,28 +721,28 @@ doca_error_t doca_urom_ucc_task_collective(struct doca_urom_worker *worker_ctx, * @task_user_data [in]: task user data * @ctx_user_data [in]: worker context user data */ -static void doca_urom_pd_channel_completed(struct doca_urom_worker_cmd_task *task, +static void pd_channel_completed(struct doca_urom_worker_cmd_task *task, union doca_data task_user_data, union doca_data ctx_user_data) { (void)task_user_data; (void)ctx_user_data; - urom_ucc_completion(task, UROM_WORKER_NOTIFY_UCC_PASSIVE_DATA_CHANNEL_COMPLETE); + completion(task, UROM_WORKER_NOTIFY_UCC_PASSIVE_DATA_CHANNEL_COMPLETE); } -doca_error_t doca_urom_ucc_task_pd_channel(struct doca_urom_worker *worker_ctx, +doca_error_t ucc_cl_doca_urom_task_pd_channel(struct doca_urom_worker *worker_ctx, union doca_data cookie, uint64_t dpu_worker_id, void *ucp_addr, size_t addr_len, - doca_urom_ucc_pd_channel_finished cb) + ucc_cl_doca_urom_pd_channel_finished_cb cb) { - doca_error_t result; - size_t pack_len = 0; - struct doca_buf *payload; - struct doca_urom_worker_cmd_task *task; - struct doca_ucc_task_data *task_data; - struct urom_worker_ucc_cmd *ucc_cmd; + size_t pack_len = 0; + struct ucc_cl_doca_urom_task_data *task_data; + struct doca_urom_worker_cmd_task *task; + struct urom_worker_ucc_cmd *ucc_cmd; + struct doca_buf *payload; + doca_error_t result; /* Allocate task */ result = doca_urom_worker_cmd_task_allocate_init(worker_ctx, ucc_id, &task); @@ -764,7 +764,7 @@ doca_error_t doca_urom_ucc_task_pd_channel(struct doca_urom_worker *worker_ctx, ucc_cmd->pass_dc_create_cmd.ucp_addr = ucp_addr; ucc_cmd->pass_dc_create_cmd.addr_len = addr_len; - result = urom_worker_ucc_cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); + result = cmd_pack(ucc_cmd, &pack_len, (void *)ucc_cmd); if (result != DOCA_SUCCESS) goto task_destroy; @@ -772,11 +772,12 @@ doca_error_t doca_urom_ucc_task_pd_channel(struct doca_urom_worker *worker_ctx, if (result != DOCA_SUCCESS) goto task_destroy; - task_data = (struct doca_ucc_task_data *)doca_urom_worker_cmd_task_get_user_data(task); + task_data = (struct ucc_cl_doca_urom_task_data *) + doca_urom_worker_cmd_task_get_user_data(task); task_data->pd_channel = cb; task_data->cookie = cookie; - doca_urom_worker_cmd_task_set_cb(task, doca_urom_pd_channel_completed); + doca_urom_worker_cmd_task_set_cb(task, pd_channel_completed); result = doca_task_submit(doca_urom_worker_cmd_task_as_task(task)); if (result != DOCA_SUCCESS) @@ -789,7 +790,8 @@ doca_error_t doca_urom_ucc_task_pd_channel(struct doca_urom_worker *worker_ctx, return result; } -doca_error_t urom_ucc_init(uint64_t plugin_id, uint64_t version) +doca_error_t ucc_cl_doca_urom_save_plugin_id(uint64_t plugin_id, + uint64_t version) { if (version != ucc_version) return DOCA_ERROR_UNSUPPORTED_VERSION; @@ -805,9 +807,11 @@ doca_error_t urom_ucc_init(uint64_t plugin_id, uint64_t version) * @cookie [in]: program cookie * @dpu_worker_id [in]: UROM DPU worker id */ -void urom_ucc_lib_create_finished(doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id) +void ucc_cl_doca_urom_lib_create_finished( + doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id) { - struct ucc_result *res = (struct ucc_result *)cookie.ptr; + struct ucc_cl_doca_urom_result *res = + (struct ucc_cl_doca_urom_result *)cookie.ptr; if (res == NULL) return; @@ -823,12 +827,12 @@ void urom_ucc_lib_create_finished(doca_error_t result, union doca_data cookie, u * @dpu_worker_id [in]: UROM DPU worker id * @status [in]: channel creation status */ -void urom_ucc_pss_dc_finished(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - ucc_status_t status) +void ucc_cl_doca_urom_pss_dc_finished( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, ucc_status_t status) { - struct ucc_result *res = (struct ucc_result *)cookie.ptr; + struct ucc_cl_doca_urom_result *res = + (struct ucc_cl_doca_urom_result *)cookie.ptr; if (res == NULL) return; @@ -844,9 +848,12 @@ void urom_ucc_pss_dc_finished(doca_error_t result, * @cookie [in]: program cookie * @dpu_worker_id [in]: UROM DPU worker id */ -void lib_destroy_finished(doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id) +void ucc_cl_doca_urom_lib_destroy_finished( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id) { - struct ucc_result *res = (struct ucc_result *)cookie.ptr; + struct ucc_cl_doca_urom_result *res = + (struct ucc_cl_doca_urom_result *)cookie.ptr; if (res == NULL) return; @@ -862,12 +869,12 @@ void lib_destroy_finished(doca_error_t result, union doca_data cookie, uint64_t * @dpu_worker_id [in]: UROM DPU worker id * @context [in]: pointer to UCC context */ -void urom_ucc_ctx_create_finished(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - void *context) +void ucc_cl_doca_urom_ctx_create_finished( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, void *context) { - struct ucc_result *res = (struct ucc_result *)cookie.ptr; + struct ucc_cl_doca_urom_result *res = + (struct ucc_cl_doca_urom_result *)cookie.ptr; if (res == NULL) return; @@ -884,12 +891,12 @@ void urom_ucc_ctx_create_finished(doca_error_t result, * @dpu_worker_id [in]: UROM DPU worker id * @status [in]: collective status */ -void urom_ucc_collective_finished(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - ucc_status_t status) +void ucc_cl_doca_urom_collective_finished( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, ucc_status_t status) { - struct ucc_result *res = (struct ucc_result *)cookie.ptr; + struct ucc_cl_doca_urom_result *res = + (struct ucc_cl_doca_urom_result *)cookie.ptr; if (res == NULL) return; @@ -906,12 +913,12 @@ void urom_ucc_collective_finished(doca_error_t result, * @dpu_worker_id [in]: UROM DPU worker id * @team [in]: pointer to UCC team */ -void urom_ucc_team_create_finished(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - void *team) +void ucc_cl_doca_urom_team_create_finished( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, void *team) { - struct ucc_result *res = (struct ucc_result *)cookie.ptr; + struct ucc_cl_doca_urom_result *res = + (struct ucc_cl_doca_urom_result *)cookie.ptr; if (res == NULL) return; @@ -921,8 +928,9 @@ void urom_ucc_team_create_finished(doca_error_t result, res->team_create.status = 2; // set done } -ucc_status_t ucc_cl_doca_urom_buffer_export_ucc(ucp_context_h ucp_context, void *buf, size_t len, - struct export_buf *ebuf) +ucc_status_t ucc_cl_doca_urom_buffer_export_ucc( + ucp_context_h ucp_context, void *buf, + size_t len, struct export_buf *ebuf) { ucs_status_t ucs_status; ucp_mem_map_params_t params; @@ -960,34 +968,3 @@ ucc_status_t ucc_cl_doca_urom_buffer_export_ucc(ucp_context_h ucp_context, void return UCC_OK; } - -size_t ucc_cl_doca_urom_dt_size(ucc_datatype_t ucc_dt) -{ - size_t size_mod = 8; - - switch(ucc_dt) { - case UCC_DT_INT8: - case UCC_DT_UINT8: - size_mod = sizeof(char); - break; - case UCC_DT_INT32: - case UCC_DT_UINT32: - case UCC_DT_FLOAT32: - size_mod = sizeof(int); - break; - case UCC_DT_INT64: - case UCC_DT_UINT64: - case UCC_DT_FLOAT64: - size_mod = sizeof(uint64_t); - break; - case UCC_DT_INT128: - case UCC_DT_UINT128: - case UCC_DT_FLOAT128: - size_mod = sizeof(__int128_t); - break; - default: - break; - } - - return size_mod; -} diff --git a/src/components/cl/doca_urom/cl_doca_urom_worker_ucc.h b/src/components/cl/doca_urom/cl_doca_urom_worker_ucc.h index 7f9ccfafea..dbcdeaa225 100644 --- a/src/components/cl/doca_urom/cl_doca_urom_worker_ucc.h +++ b/src/components/cl/doca_urom/cl_doca_urom_worker_ucc.h @@ -11,8 +11,8 @@ * */ -#ifndef WORKER_UCC_H_ -#define WORKER_UCC_H_ +#ifndef UCC_CL_DOCA_UROM_WORKER_UCC_H_ +#define UCC_CL_DOCA_UROM_WORKER_UCC_H_ #include @@ -34,47 +34,45 @@ struct export_buf { }; /* UCC context create result */ -struct context_create_result { +struct ucc_cl_doca_urom_context_create_result { void *context; /* Pointer to UCC context */ }; /* UCC team create result */ -struct team_create_result { +struct ucc_cl_doca_urom_team_create_result { void *team; /* Pointer to UCC team */ int status; /* nick: 0=nothing, 1=team create in progress, 2=team create done */ }; /* UCC collective result */ -struct collective_result { +struct ucc_cl_doca_urom_collective_result { ucc_status_t status; /* UCC collective status */ }; /* UCC passive data channel result */ -struct pass_dc_result { +struct ucc_cl_doca_urom_pass_dc_result { ucc_status_t status; /* UCC data channel status */ }; /* UCC task result structure */ -struct ucc_result { +struct ucc_cl_doca_urom_result { doca_error_t result; /* Task result */ uint64_t dpu_worker_id; /* DPU worker id */ union { - struct context_create_result context_create; /* Context create result */ - struct team_create_result team_create; /* Team create result */ - struct collective_result collective; /* Collective result */ - struct pass_dc_result pass_dc; /* Passive data channel result */ + struct ucc_cl_doca_urom_context_create_result context_create; /* Context create result */ + struct ucc_cl_doca_urom_team_create_result team_create; /* Team create result */ + struct ucc_cl_doca_urom_collective_result collective; /* Collective result */ + struct ucc_cl_doca_urom_pass_dc_result pass_dc; /* Passive data channel result */ }; }; -void urom_ucc_collective_finished(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - ucc_status_t status); +void ucc_cl_doca_urom_collective_finished( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, ucc_status_t status); -ucc_status_t ucc_cl_doca_urom_buffer_export_ucc(ucp_context_h ucp_context, void *buf, size_t len, - struct export_buf *ebuf); - -size_t ucc_cl_doca_urom_dt_size(ucc_datatype_t ucc_dt); +ucc_status_t ucc_cl_doca_urom_buffer_export_ucc( + ucp_context_h ucp_context, void *buf, + size_t len, struct export_buf *ebuf); /* * UCC team create callback @@ -84,10 +82,9 @@ size_t ucc_cl_doca_urom_dt_size(ucc_datatype_t ucc_dt); * @dpu_worker_id [in]: UROM DPU worker id * @team [in]: pointer to UCC team */ -void urom_ucc_team_create_finished(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - void *team); +void ucc_cl_doca_urom_team_create_finished( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, void *team); /* * UCC lib create callback @@ -96,7 +93,8 @@ void urom_ucc_team_create_finished(doca_error_t result, * @cookie [in]: program cookie * @dpu_worker_id [in]: UROM DPU worker id */ -void urom_ucc_lib_create_finished(doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); +void ucc_cl_doca_urom_lib_create_finished( + doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); /* * UCC passive data channel callback @@ -106,10 +104,9 @@ void urom_ucc_lib_create_finished(doca_error_t result, union doca_data cookie, u * @dpu_worker_id [in]: UROM DPU worker id * @status [in]: channel creation status */ -void urom_ucc_pss_dc_finished(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - ucc_status_t status); +void ucc_cl_doca_urom_pss_dc_finished( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, ucc_status_t status); /* * UCC lib destroy callback @@ -118,7 +115,8 @@ void urom_ucc_pss_dc_finished(doca_error_t result, * @cookie [in]: program cookie * @dpu_worker_id [in]: UROM DPU worker id */ -void lib_destroy_finished(doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); +void ucc_cl_doca_urom_lib_destroy_finished( + doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); /* * UCC context create callback @@ -128,10 +126,9 @@ void lib_destroy_finished(doca_error_t result, union doca_data cookie, uint64_t * @dpu_worker_id [in]: UROM DPU worker id * @context [in]: pointer to UCC context */ -void urom_ucc_ctx_create_finished(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - void *context); +void ucc_cl_doca_urom_ctx_create_finished( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, void *context); /* * UCC lib create task callback function, will be called once the task is finished @@ -140,7 +137,8 @@ void urom_ucc_ctx_create_finished(doca_error_t result, * @cookie [in]: user cookie * @dpu_worker_id [in]: UCC DPU worker id */ -typedef void (*doca_urom_ucc_lib_create_finished)(doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); +typedef void (*ucc_cl_doca_urom_lib_create_finished_cb)( + doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); /* * UCC lib destroy task callback function, will be called once the task is finished @@ -149,7 +147,8 @@ typedef void (*doca_urom_ucc_lib_create_finished)(doca_error_t result, union doc * @cookie [in]: user cookie * @dpu_worker_id [in]: UCC DPU worker id */ -typedef void (*doca_urom_ucc_lib_destroy_finished)(doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); +typedef void (*ucc_cl_doca_urom_lib_destroy_finished_cb)( + doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); /* * UCC context create task callback function, will be called once the task is finished @@ -159,10 +158,9 @@ typedef void (*doca_urom_ucc_lib_destroy_finished)(doca_error_t result, union do * @dpu_worker_id [in]: UCC DPU worker id * @context [in]: pointer to UCC context */ -typedef void (*doca_urom_ucc_ctx_create_finished)(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - void *context); +typedef void (*ucc_cl_doca_urom_ctx_create_finished_cb)( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, void *context); /* * UCC context destroy task callback function, will be called once the task is finished @@ -171,7 +169,8 @@ typedef void (*doca_urom_ucc_ctx_create_finished)(doca_error_t result, * @cookie [in]: user cookie * @dpu_worker_id [in]: UCC DPU worker id */ -typedef void (*doca_urom_ucc_ctx_destroy_finished)(doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); +typedef void (*ucc_cl_doca_urom_ctx_destroy_finished_cb)( + doca_error_t result, union doca_data cookie, uint64_t dpu_worker_id); /* * UCC team create task callback function, will be called once the task is finished @@ -181,10 +180,9 @@ typedef void (*doca_urom_ucc_ctx_destroy_finished)(doca_error_t result, union do * @dpu_worker_id [in]: UCC DPU worker id * @team [in]: pointer to UCC team */ -typedef void (*doca_urom_ucc_team_create_finished)(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - void *team); +typedef void (*ucc_cl_doca_urom_team_create_finished_cb)( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, void *team); /* * UCC collective task callback function, will be called once the task is finished @@ -194,10 +192,9 @@ typedef void (*doca_urom_ucc_team_create_finished)(doca_error_t result, * @dpu_worker_id [in]: UCC DPU worker id * @status [in]: UCC status */ -typedef void (*doca_urom_ucc_collective_finished)(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - ucc_status_t status); +typedef void (*ucc_cl_doca_urom_collective_finished_cb)( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, ucc_status_t status); /* * UCC passive data channel task callback function, will be called once the task is finished @@ -207,10 +204,9 @@ typedef void (*doca_urom_ucc_collective_finished)(doca_error_t result, * @dpu_worker_id [in]: UCC DPU worker id * @status [in]: UCC status */ -typedef void (*doca_urom_ucc_pd_channel_finished)(doca_error_t result, - union doca_data cookie, - uint64_t dpu_worker_id, - ucc_status_t status); +typedef void (*ucc_cl_doca_urom_pd_channel_finished_cb)( + doca_error_t result, union doca_data cookie, + uint64_t dpu_worker_id, ucc_status_t status); /* * Create UCC library task @@ -222,11 +218,10 @@ typedef void (*doca_urom_ucc_pd_channel_finished)(doca_error_t result, * @cb [in]: program callback to call once the task is finished * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t doca_urom_ucc_task_lib_create(struct doca_urom_worker *worker_ctx, - union doca_data cookie, - uint64_t dpu_worker_id, - void *params, - doca_urom_ucc_lib_create_finished cb); +doca_error_t ucc_cl_doca_urom_task_lib_create( + struct doca_urom_worker *worker_ctx, union doca_data cookie, + uint64_t dpu_worker_id, void *params, + ucc_cl_doca_urom_lib_create_finished_cb cb); /* * Create UCC library destroy task @@ -237,10 +232,10 @@ doca_error_t doca_urom_ucc_task_lib_create(struct doca_urom_worker *worker_ctx, * @cb [in]: program callback to call once the task is finished * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t doca_urom_ucc_task_lib_destroy(struct doca_urom_worker *worker_ctx, - union doca_data cookie, - uint64_t dpu_worker_id, - doca_urom_ucc_lib_destroy_finished cb); +doca_error_t ucc_cl_doca_urom_task_lib_destroy( + struct doca_urom_worker *worker_ctx, union doca_data cookie, + uint64_t dpu_worker_id, + ucc_cl_doca_urom_lib_destroy_finished_cb cb); /* * Create UCC context task @@ -257,16 +252,11 @@ doca_error_t doca_urom_ucc_task_lib_destroy(struct doca_urom_worker *worker_ctx, * @cb [in]: program callback to call once the task is finished * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t doca_urom_ucc_task_ctx_create(struct doca_urom_worker *worker_ctx, - union doca_data cookie, - uint64_t dpu_worker_id, - int64_t start, - int64_t *array, - int64_t stride, - int64_t size, - void *base_va, - uint64_t len, - doca_urom_ucc_ctx_create_finished cb); +doca_error_t ucc_cl_doca_urom_task_ctx_create( + struct doca_urom_worker *worker_ctx, union doca_data cookie, + uint64_t dpu_worker_id, int64_t start, int64_t *array, + int64_t stride, int64_t size, void *base_va, uint64_t len, + ucc_cl_doca_urom_ctx_create_finished_cb cb); /* * Create UCC context destroy task @@ -278,11 +268,10 @@ doca_error_t doca_urom_ucc_task_ctx_create(struct doca_urom_worker *worker_ctx, * @cb [in]: program callback to call once the task is finished * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t doca_urom_ucc_task_ctx_destroy(struct doca_urom_worker *worker_ctx, - union doca_data cookie, - uint64_t dpu_worker_id, - void *context, - doca_urom_ucc_ctx_destroy_finished cb); +doca_error_t ucc_cl_doca_urom_task_ctx_destroy( + struct doca_urom_worker *worker_ctx, union doca_data cookie, + uint64_t dpu_worker_id, void *context, + ucc_cl_doca_urom_ctx_destroy_finished_cb cb); /* * Create UCC team task @@ -297,14 +286,10 @@ doca_error_t doca_urom_ucc_task_ctx_destroy(struct doca_urom_worker *worker_ctx, * @cb [in]: program callback to call once the task is finished * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t doca_urom_ucc_task_team_create(struct doca_urom_worker *worker_ctx, - union doca_data cookie, - uint64_t dpu_worker_id, - int64_t start, - int64_t stride, - int64_t size, - void *context, - doca_urom_ucc_team_create_finished cb); +doca_error_t ucc_cl_doca_urom_task_team_create( + struct doca_urom_worker *worker_ctx, union doca_data cookie, + uint64_t dpu_worker_id, int64_t start, int64_t stride, int64_t size, + void *context, ucc_cl_doca_urom_team_create_finished_cb cb); /* * Create UCC collective task @@ -321,16 +306,11 @@ doca_error_t doca_urom_ucc_task_team_create(struct doca_urom_worker *worker_ctx, * @cb [in]: program callback to call once the task is finished * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t doca_urom_ucc_task_collective(struct doca_urom_worker *worker_ctx, - union doca_data cookie, - uint64_t dpu_worker_id, - void *coll_args, - void *team, - int use_xgvmi, - void *work_buffer, - size_t work_buffer_size, - size_t team_size, - doca_urom_ucc_collective_finished cb); +doca_error_t ucc_cl_doca_urom_task_collective( + struct doca_urom_worker *worker_ctx, union doca_data cookie, + uint64_t dpu_worker_id, void *coll_args, void *team, int use_xgvmi, + void *work_buffer, size_t work_buffer_size, size_t team_size, + ucc_cl_doca_urom_collective_finished_cb cb); /* * Create UCC passive data channel task @@ -343,12 +323,10 @@ doca_error_t doca_urom_ucc_task_collective(struct doca_urom_worker *worker_ctx, * @cb [in]: program callback to call once the task is finished * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t doca_urom_ucc_task_pd_channel(struct doca_urom_worker *worker_ctx, - union doca_data cookie, - uint64_t dpu_worker_id, - void *ucp_addr, - size_t addr_len, - doca_urom_ucc_pd_channel_finished cb); +doca_error_t ucc_cl_doca_urom_task_pd_channel( + struct doca_urom_worker *worker_ctx, union doca_data cookie, + uint64_t dpu_worker_id, void *ucp_addr, size_t addr_len, + ucc_cl_doca_urom_pd_channel_finished_cb cb); /* * This method inits UCC plugin. @@ -357,6 +335,7 @@ doca_error_t doca_urom_ucc_task_pd_channel(struct doca_urom_worker *worker_ctx, * @version [in]: plugin version on DPU side * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise */ -doca_error_t urom_ucc_init(uint64_t plugin_id, uint64_t version); +doca_error_t ucc_cl_doca_urom_save_plugin_id( + uint64_t plugin_id, uint64_t version); -#endif /* WORKER_UCC_H_ */ +#endif /* UCC_CL_DOCA_UROM_WORKER_UCC_H_ */