73 if (signum == SIGINT || signum == SIGTERM) {
74 DOCA_LOG_INFO(
"Signal %d received, preparing to exit", signum);
120 DOCA_LOG_ERR(
"Failed to create DB completion context to be used in DPA: %s",
160 DOCA_LOG_ERR(
"RPC to initialize DPA app context has failed");
187 DOCA_LOG_ERR(
"RPC to uninitialize DPA app context has failed");
280 DOCA_LOG_INFO(
"FLR has occurred destroying PCI device and recreating it");
287 DOCA_LOG_ERR(
"Failed to stop PCI device during FLR event");
294 DOCA_LOG_ERR(
"Failed to start PCI device during FLR event");
334 struct doca_ctx *
ctx,
344 switch (next_state) {
358 "Devemu device has entered into stopping state. This happens only when attempting to stop before destroying doorbell");
405 const char *emulated_dev_vuid,
406 uint16_t db_region_idx,
410 struct timespec ts = {
416 bool destroy_rep =
false;
417 uint16_t max_num_db = 0;
457 if (max_num_db == 0) {
462 if (
db_id >= (uint32_t)max_num_db) {
465 "DB ID must not exceed the maximum number of DBs per PCI type: expected DB ID less than %u but received %u",
522 DOCA_LOG_ERR(
"Failed to set PCI emulated device context datapath on DPA: %s",
559 "Expected hotplug state to be DOCA_DEVEMU_PCI_HP_STATE_POWER_ON instead current state is %s",
doca_error_t init_dpa(struct devemu_resources *resources, struct doca_dpa_app *dpa_app)
void devemu_resources_cleanup(struct devemu_resources *resources, bool destroy_rep)
doca_dpa_func_t db_handler
static void flr_event_handler_cb(struct doca_devemu_pci_dev *pci_dev, union doca_data user_data)
struct doca_dpa_app * devemu_pci_sample_app
doca_error_t init_dpa_app_ctx(struct devemu_resources *resources)
doca_error_t destroy_db_object(struct devemu_resources *resources)
doca_error_t devemu_pci_device_db_dpu(const char *pci_address, const char *emulated_dev_vuid, uint16_t db_region_idx, uint32_t db_id)
doca_error_t uninit_dpa_app_ctx(struct devemu_resources *resources)
static void state_change_event_handler_cb(const union doca_data user_data, struct doca_ctx *ctx, enum doca_ctx_states prev_state, enum doca_ctx_states next_state)
static doca_error_t register_to_ctx_state_change_events(struct devemu_resources *resources)
doca_dpa_func_t init_app_ctx_rpc
doca_error_t create_db_object(struct devemu_resources *resources, uint16_t db_region_idx, uint32_t db_id)
doca_error_t create_db_dpa_comp(struct devemu_resources *resources)
DOCA_LOG_REGISTER(DEVEMU_PCI_DEVICE_DB_DPU)
static doca_error_t register_to_flr_events(struct devemu_resources *resources)
doca_error_t init_dpa_db_thread(struct devemu_resources *resources)
static void signal_handler(int signum)
doca_dpa_func_t uninit_app_ctx_rpc
struct rdma_resources resources
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_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_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_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_CTX_STATE_STOPPING
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_cap_type_get_max_num_db(const struct doca_devinfo *devinfo, uint16_t *num_db)
Get the maximal number of doorbells that can be configured for any PCI type that was created using do...
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_create(const char *name, struct doca_devemu_pci_type **pci_type)
Create a stopped DOCA devemu PCI type.
#define DOCA_DEVEMU_PCI_TYPE_NAME_LEN
Maximal length for the NULL terminated string that describe the name of the emulated PCI device type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_cap_type_is_hotplug_supported(const struct doca_devinfo *devinfo, const struct doca_devemu_pci_type *pci_type, uint8_t *supported)
Get the hotplug capability of the device for a given DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_completion_create(struct doca_dpa_thread *th, struct doca_devemu_pci_db_completion **db_comp)
Allocate DOCA devemu PCI device doorbell completion context on DPA. The created completion context wi...
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_event_flr_register(struct doca_devemu_pci_dev *pci_dev, doca_devemu_pci_dev_event_flr_handler_cb_t handler, union doca_data user_data)
Register to PCI FLR (Function Level Reset) event.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_get_dpa_handle(struct doca_devemu_pci_db *db, doca_dpa_dev_devemu_pci_db_t *db_handle)
Get the DPA handle for the DOCA devemu PCI device doorbell.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_get_hotplug_state(struct doca_devemu_pci_dev *pci_dev, enum doca_devemu_pci_hotplug_state *state)
Get the hotplug state of the DOCA devemu PCI device.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_destroy(struct doca_devemu_pci_db *db)
Destroy the DOCA devemu PCI device doorbell.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_create(struct doca_devemu_pci_type *pci_type, struct doca_dev_rep *dev_rep, struct doca_pe *progress_engine, struct doca_devemu_pci_dev **pci_dev)
Allocate DOCA devemu PCI device.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_completion_get_dpa_handle(struct doca_devemu_pci_db_completion *db_comp, doca_dpa_dev_devemu_pci_db_completion_t *db_comp_handle)
Get the DPA handle for the DOCA devemu PCI device doorbell completion context.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_completion_start(struct doca_devemu_pci_db_completion *db_comp)
Start DOCA devemu PCI device doorbell completion context.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_stop(struct doca_devemu_pci_db *db)
Stop DOCA devemu PCI device doorbell. A stopped doorbell will not trigger completions on the associat...
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_create_on_dpa(struct doca_devemu_pci_dev *pci_dev, struct doca_devemu_pci_db_completion *db_comp, uint8_t bar_id, uint64_t bar_start_addr, uint32_t db_id, uint64_t user_data_on_dpa, struct doca_devemu_pci_db **db)
Allocate DOCA devemu PCI device doorbell on DPA. The created doorbell will be associated with a singl...
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_db_start(struct doca_devemu_pci_db *db)
Start DOCA devemu PCI device doorbell. A started doorbell will be able to trigger completions on the ...
DOCA_EXPERIMENTAL struct doca_ctx * doca_devemu_pci_dev_as_ctx(struct doca_devemu_pci_dev *pci_dev)
Convert DOCA devemu PCI device instance into DOCA context.
@ DOCA_DEVEMU_PCI_HP_STATE_POWER_ON
DOCA_STABLE struct doca_devinfo * doca_dev_as_devinfo(const struct doca_dev *dev)
Get local device info from device. This should be useful when wanting to query information about devi...
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_run(struct doca_dpa_thread *dpa_thread)
Run DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_create(struct doca_dpa *dpa, struct doca_dpa_thread **dpa_thread)
Create DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_rpc(struct doca_dpa *dpa, doca_dpa_func_t *func, uint64_t *retval,...)
RPC to run DPA kernel.
void() doca_dpa_func_t(void)
Generic function pointer type.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_set_func_arg(struct doca_dpa_thread *dpa_thread, doca_dpa_func_t *func, uint64_t arg)
Set DPA thread entry point and its argument.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_start(struct doca_dpa_thread *dpa_thread)
Start DPA thread.
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
@ DOCA_ERROR_NOT_SUPPORTED
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
DOCA_STABLE doca_error_t doca_pe_create(struct doca_pe **pe)
Creates DOCA progress engine.
doca_error_t configure_and_start_pci_type(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
const char * hotplug_state_to_string(enum doca_devemu_pci_hotplug_state hotplug_state)
doca_error_t find_emulated_device(struct doca_devemu_pci_type *pci_type, const char *vuid, struct doca_dev_rep **rep)
doca_error_t find_supported_device(const char *dev_name, const struct doca_devemu_pci_type *pci_type, emulation_supported_cb_t has_support, struct doca_dev **dev)
static const struct bar_db_region_config db_configs[PCI_TYPE_NUM_BAR_DB_REGIONS]
struct bar_region_config region
struct doca_devemu_pci_dev * pci_dev
Convenience type for representing opaque data.
struct upf_accel_ctx * ctx