NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
doca_ctx.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED.
3  *
4  * This software product is a proprietary product of NVIDIA CORPORATION &
5  * AFFILIATES (the "Company") and all right, title, and interest in and to the
6  * software product, including all associated intellectual property rights, are
7  * and shall remain exclusively with the Company.
8  *
9  * This software product is governed by the End User License Agreement
10  * provided with the software product.
11  *
12  */
13 
26 #ifndef DOCA_CTX_H_
27 #define DOCA_CTX_H_
28 
29 #include <stddef.h>
30 #include <stdint.h>
31 
32 #include <doca_error.h>
33 #include <doca_types.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*********************************************************************************************************************
40  * DOCA Context
41  *********************************************************************************************************************/
42 
43 struct doca_ctx;
44 struct doca_devinfo;
45 
99  /*
100  * doca_ctx_stop called.
101  * Resources are allocated, context can not allocate tasks, submit tasks, allocate events or register events.
102  * Submitted tasks are flushed or drained (during progress call).
103  * ctx will usually move to idle state when number of in-flight tasks reach 0.
104  * Application should call progress_one until the context moves to idle state.
105  */
107 };
108 
123 typedef void (*doca_ctx_state_changed_callback_t)(const union doca_data user_data,
124  struct doca_ctx *ctx,
125  enum doca_ctx_states prev_state,
126  enum doca_ctx_states next_state);
127 
156 doca_error_t doca_ctx_start(struct doca_ctx *ctx);
157 
178 doca_error_t doca_ctx_stop(struct doca_ctx *ctx);
179 
196 doca_error_t doca_ctx_get_num_inflight_tasks(const struct doca_ctx *ctx, size_t *num_inflight_tasks);
197 
198 struct doca_gpu;
199 
217 doca_error_t doca_ctx_set_datapath_on_gpu(struct doca_ctx *ctx, struct doca_gpu *gpu_dev);
218 
236 doca_error_t doca_ctx_set_user_data(struct doca_ctx *ctx, union doca_data user_data);
237 
254 doca_error_t doca_ctx_get_user_data(const struct doca_ctx *ctx, union doca_data *user_data);
255 
273 
290 doca_error_t doca_ctx_get_state(const struct doca_ctx *ctx, enum doca_ctx_states *state);
291 
302 void doca_ctx_flush_tasks(struct doca_ctx *ctx);
303 
304 struct doca_dpa;
305 
323 doca_error_t doca_ctx_set_datapath_on_dpa(struct doca_ctx *ctx, struct doca_dpa *dpa_dev);
324 
346 doca_error_t doca_ctx_set_completion_vector(struct doca_ctx *ctx, uint32_t comp_vector);
347 
362 doca_error_t doca_ctx_cap_get_num_completion_vectors(const struct doca_devinfo *devinfo, uint32_t *num_comp_vectors);
363 
364 #ifdef __cplusplus
365 }
366 #endif
367 
370 #endif /* DOCA_CTX_H_ */
static struct doca_gpu * gpu_dev
#define DOCA_EXPERIMENTAL
To set a Symbol (or specifically a function) as experimental.
Definition: doca_compat.h:103
#define DOCA_STABLE
To set a Symbol (or specifically a function) as stable API, i.e. it won't be changed.
Definition: doca_compat.h:96
void(* doca_ctx_state_changed_callback_t)(const union doca_data user_data, struct doca_ctx *ctx, enum doca_ctx_states prev_state, enum doca_ctx_states next_state)
Function to execute on context state change.
Definition: doca_ctx.h:123
DOCA_EXPERIMENTAL doca_error_t doca_ctx_set_completion_vector(struct doca_ctx *ctx, uint32_t comp_vector)
Set context completion vector.
DOCA_EXPERIMENTAL void doca_ctx_flush_tasks(struct doca_ctx *ctx)
Flushes tasks that were not flushed during submit.
DOCA_EXPERIMENTAL doca_error_t doca_ctx_cap_get_num_completion_vectors(const struct doca_devinfo *devinfo, uint32_t *num_comp_vectors)
Get number of completion vectors.
DOCA_STABLE doca_error_t doca_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_EXPERIMENTAL doca_error_t doca_ctx_set_datapath_on_gpu(struct doca_ctx *ctx, struct doca_gpu *gpu_dev)
This function binds the DOCA context to a gpu device.
DOCA_EXPERIMENTAL doca_error_t doca_ctx_set_datapath_on_dpa(struct doca_ctx *ctx, struct doca_dpa *dpa_dev)
This function binds the DOCA context to a dpa device.
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_set_state_changed_cb(struct doca_ctx *ctx, doca_ctx_state_changed_callback_t cb)
Set state changed callback.
DOCA_STABLE doca_error_t doca_ctx_set_user_data(struct doca_ctx *ctx, union doca_data user_data)
set user data to context
DOCA_STABLE doca_error_t doca_ctx_get_num_inflight_tasks(const struct doca_ctx *ctx, size_t *num_inflight_tasks)
Get number of in flight tasks in a doca context.
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.
Definition: doca_ctx.h:83
DOCA_STABLE doca_error_t doca_ctx_get_user_data(const struct doca_ctx *ctx, union doca_data *user_data)
get user data from context
@ DOCA_CTX_STATE_STARTING
Definition: doca_ctx.h:93
@ DOCA_CTX_STATE_STOPPING
Definition: doca_ctx.h:106
@ DOCA_CTX_STATE_IDLE
Definition: doca_ctx.h:88
@ DOCA_CTX_STATE_RUNNING
Definition: doca_ctx.h:98
enum doca_error doca_error_t
DOCA API return codes.
Convenience type for representing opaque data.
Definition: doca_types.h:56
struct upf_accel_ctx * ctx