77 if (signum == SIGINT || signum == SIGTERM) {
78 DOCA_LOG_INFO(
"Signal %d received, preparing to exit", signum);
114 const uint64_t nb_tasks = 2;
115 struct doca_urom_worker *worker;
119 char *env[] = {
"UCX_LOG_LEVEL=debug"};
186 if (lb_res.
data !=
id) {
187 DOCA_LOG_ERR(
"Loopback data is wrong, should be [%lu] and received [%lu]",
id, lb_res.
data);
195 pthread_ret = pthread_mutex_lock(&
mutex);
196 if (pthread_ret != 0) {
197 DOCA_LOG_ERR(
"Failed to lock resource, error=%d", errno);
201 pthread_ret = pthread_mutex_unlock(&
mutex);
202 if (pthread_ret != 0) {
203 DOCA_LOG_ERR(
"Failed to unlock resource, error=%d", errno);
248 pthread_ret = pthread_mutex_lock(&
mutex);
249 if (pthread_ret != 0) {
250 DOCA_LOG_ERR(
"Failed to lock resource, error=%d", errno);
254 pthread_ret = pthread_mutex_unlock(&
mutex);
255 if (pthread_ret != 0)
256 DOCA_LOG_ERR(
"Failed to unlock resource, error=%d", errno);
276 size_t worker_counts;
279 uint64_t *is_failure = task_user_data.
ptr;
295 for (i = 0; i < worker_counts; i++) {
297 if (ids[0] % 2 != 1) {
298 DOCA_LOG_ERR(
"Wrong worker id exists in workers ids list, should be odd number");
322 size_t worker_counts;
325 uint64_t *is_failure = task_user_data.
ptr;
341 for (i = 0; i < worker_counts; i++) {
343 if (ids[0] % 2 != 0) {
344 DOCA_LOG_ERR(
"Wrong worker id exists in workers ids list, should be even number");
349 DOCA_LOG_INFO(
"Worker even ids query finished successfully");
364 struct doca_dev *dev;
367 uint64_t is_failure = 0;
368 const int nb_workers = 4;
369 pthread_t ids[nb_workers];
370 int ret, idx, actual_workers = 0;
372 size_t i, plugins_count = 0;
373 char *plugin_name =
"worker_graph";
375 struct doca_urom_service *service;
377 struct doca_urom_service_get_workers_by_gid_task *odd_gid_task, *even_gid_task;
379 data.
ptr = &is_failure;
382 if (pthread_mutex_init(&
mutex,
NULL) != 0) {
383 DOCA_LOG_ERR(
"Failed to initiate UROM worker lock, error=%d", errno);
403 for (i = 0; i < plugins_count; i++) {
404 if (strcmp(plugin_name, plugins[i].plugin_name) == 0) {
405 graph_info = &plugins[i];
410 if (graph_info ==
NULL) {
421 for (idx = 0; idx < 8; idx++) {
431 ctx = malloc(
sizeof(*
ctx));
439 ctx->service = service;
440 ctx->worker_id = idx;
443 ctx->plugins = graph_info->
id;
444 ctx->exit_status = &status_arr[idx];
462 DOCA_LOG_INFO(
"Start service workers query task with gid 1 for odd ids");
480 DOCA_LOG_ERR(
"Worker odd ids query finished with errors");
485 DOCA_LOG_INFO(
"Start service workers query task with gid 0 for even ids");
503 DOCA_LOG_ERR(
"Worker even ids query finished with errors");
514 for (idx = 0; idx < actual_workers; idx++) {
515 pthread_join(ids[idx],
NULL);
546 if (pthread_mutex_destroy(&
mutex) != 0)
547 DOCA_LOG_ERR(
"Failed to destroy UROM worker lock, error=%d", errno);
doca_error_t open_doca_device_with_ibdev_name(const uint8_t *value, size_t val_size, tasks_check func, struct doca_dev **retval)
static struct doca_pe * pe
DOCA_STABLE doca_error_t doca_ctx_get_state(const struct doca_ctx *ctx, enum doca_ctx_states *state)
Get context state.
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
doca_ctx_states
This enum defines the states of a context.
@ DOCA_CTX_STATE_STARTING
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
#define DOCA_ERROR_PROPAGATE(r, t)
Save the first encountered doca_error_t.
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_INVALID_VALUE
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
#define DOCA_LOG_DBG(format,...)
Generates a DEBUG application log message.
DOCA_STABLE doca_error_t doca_pe_destroy(struct doca_pe *pe)
Destroy doca progress engine.
DOCA_STABLE doca_error_t doca_task_get_status(const struct doca_task *task)
Get task status.
DOCA_STABLE doca_error_t doca_task_submit(struct doca_task *task)
Submit a task to a progress engine.
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
DOCA_STABLE void doca_task_set_user_data(struct doca_task *task, union doca_data user_data)
Set user data to a task.
DOCA_STABLE doca_error_t doca_pe_create(struct doca_pe **pe)
Creates DOCA progress engine.
ucs_cpu_set_t doca_cpu_set_t
DOCA CPU set structure.
DOCA_EXPERIMENTAL doca_error_t doca_urom_service_get_plugins_list(struct doca_urom_service *service_ctx, const struct doca_urom_service_plugin_info **plugins, size_t *plugins_count)
This method gets the list of supported plugins on service's DPU side.
DOCA_EXPERIMENTAL doca_error_t doca_urom_service_get_cpuset(struct doca_urom_service *service_ctx, doca_cpu_set_t *cpuset)
Get the allowed CPU set for the service.
DOCA_EXPERIMENTAL struct doca_ctx * doca_urom_service_as_ctx(struct doca_urom_service *service_ctx)
Convert service_ctx instance into a generalized context for use with DOCA core objects.
DOCA_EXPERIMENTAL doca_error_t doca_urom_service_destroy(struct doca_urom_service *service_ctx)
This method destroys a UROM Service context.
#define doca_cpu_is_set(_cpu, _cpusetp)
Check if specific bit in DOCA CPU is set.
DOCA_EXPERIMENTAL doca_error_t doca_urom_worker_destroy(struct doca_urom_worker *worker_ctx)
This method destroys a UROM Worker context.
DOCA_EXPERIMENTAL doca_error_t doca_urom_worker_get_id(struct doca_urom_worker *worker_ctx, uint64_t *worker_id)
This method gets the Worker context ID to be used to identify the Worker. Worker IDs enable an applic...
DOCA_EXPERIMENTAL struct doca_ctx * doca_urom_worker_as_ctx(struct doca_urom_worker *worker_ctx)
DOCA_EXPERIMENTAL struct doca_task * doca_urom_service_get_workers_by_gid_task_as_task(struct doca_urom_service_get_workers_by_gid_task *task)
This method converts a service get workers task to doca_task.
DOCA_EXPERIMENTAL doca_error_t doca_urom_service_get_workers_by_gid_task_allocate_init(struct doca_urom_service *service_ctx, uint32_t gid, doca_urom_service_get_workers_by_gid_task_completion_cb_t cb, struct doca_urom_service_get_workers_by_gid_task **task)
Allocate Service get workers by gid task and set task attributes.
DOCA_EXPERIMENTAL doca_error_t doca_urom_service_get_workers_by_gid_task_release(struct doca_urom_service_get_workers_by_gid_task *task)
Release Service get workers by gid task.
DOCA_EXPERIMENTAL const uint64_t * doca_urom_service_get_workers_by_gid_task_get_worker_ids(struct doca_urom_service_get_workers_by_gid_task *task)
Get Service get workers task ids array.
DOCA_EXPERIMENTAL size_t doca_urom_service_get_workers_by_gid_task_get_workers_count(struct doca_urom_service_get_workers_by_gid_task *task)
Get the number of workers returned for the requested gid.
struct doca_urom_service * service
doca_error_t * exit_status
Convenience type for representing opaque data.
struct upf_accel_ctx * ctx
doca_error_t start_urom_service(struct doca_pe *pe, struct doca_dev *dev, uint64_t nb_workers, struct doca_urom_service **service)
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)
static void even_gid_task_cb(struct doca_urom_service_get_workers_by_gid_task *task, union doca_data task_user_data, union doca_data ctx_user_data)
static bool worker_force_quit
static pthread_mutex_t mutex
DOCA_LOG_REGISTER(UROM_MULTI_WORKERS_BOOTS::SAMPLE)
static int nb_running_workers
static void worker_graph_loopback_finished_cb(doca_error_t result, union doca_data cookie, uint64_t data)
static void * worker_main(void *context)
static int nb_exit_workers
doca_error_t multi_workers_bootstrap(char *device_name)
static void odd_gid_task_cb(struct doca_urom_service_get_workers_by_gid_task *task, union doca_data task_user_data, union doca_data ctx_user_data)
static void signal_handler(int signum)
doca_error_t urom_graph_init(uint64_t plugin_id, uint64_t version)
doca_error_t urom_graph_task_loopback(struct doca_urom_worker *worker_ctx, union doca_data cookie, uint64_t data, urom_graph_loopback_finished cb)