52 if (signum == SIGINT || signum == SIGTERM) {
53 DOCA_LOG_INFO(
"Signal %d received, preparing to exit", signum);
65 struct doca_devemu_pci_dev_event_bar_stateful_region_driver_write *event,
68 struct doca_devemu_pci_dev *pci_dev;
74 DOCA_LOG_INFO(
"Host wrote to stateful region of emulated device");
97 DOCA_LOG_ERR(
"Failed to dump values of stateful region: Memory allocation failure");
101 DOCA_LOG_INFO(
"Printing values of stateful region [bar_id=%u, start_address=%lu, size=%lu]\n%s",
126 uint64_t max_region_size = 0;
130 user_data.
ptr = (
void *)config;
138 DOCA_LOG_ERR(
"Unable to register to emulated PCI device stateful region write event: %s",
143 max_region_size = max_region_size > config->
size ? max_region_size : config->
size;
154 resources->stateful_region_values = calloc(1, max_region_size);
156 DOCA_LOG_ERR(
"Unable to allocate buffer for storing stateful region values: out of memory");
173 struct timespec ts = {
179 bool destroy_rep =
false;
188 "No stateful region was configured for type. Please configure at least 1 stateful region to run this sample");
263 "Expected hotplug state to be DOCA_DEVEMU_PCI_HP_STATE_POWER_ON instead current state is %s",
void devemu_resources_cleanup(struct devemu_resources *resources, bool destroy_rep)
static void stateful_region_write_event_handler_cb(struct doca_devemu_pci_dev_event_bar_stateful_region_driver_write *event, union doca_data user_data)
DOCA_LOG_REGISTER(DEVEMU_PCI_DEVICE_STATEFUL_REGION_DPU)
doca_error_t devemu_pci_device_stateful_region_dpu(const char *pci_address, const char *emulated_dev_vuid)
static doca_error_t register_to_stateful_region_write_events(struct doca_devemu_pci_dev *pci_dev, struct devemu_resources *resources)
static void signal_handler(int signum)
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_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_user_data(const struct doca_ctx *ctx, union doca_data *user_data)
get user data from context
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_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 struct doca_devemu_pci_dev * doca_devemu_pci_dev_event_bar_stateful_region_driver_write_get_pci_dev(struct doca_devemu_pci_dev_event_bar_stateful_region_driver_write *event)
Get DOCA devemu PCI device from BAR stateful region driver write event.
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_dev_query_bar_stateful_region_values(struct doca_devemu_pci_dev *pci_dev, uint8_t id, uint64_t offset, void *out_values, uint64_t size)
Query registers values of the stateful region in a DOCA devemu PCI device.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_event_bar_stateful_region_driver_write_register(struct doca_devemu_pci_dev *pci_dev, doca_devemu_pci_dev_event_bar_stateful_region_driver_write_handler_cb_t handler, uint8_t bar_id, uint64_t bar_region_start_addr, union doca_data user_data)
Register to BAR stateful region driver write event.
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
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.
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.
char * hex_dump(const void *data, size_t size)
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)
#define PCI_TYPE_NUM_BAR_STATEFUL_REGIONS
static const struct bar_region_config stateful_configs[PCI_TYPE_NUM_BAR_STATEFUL_REGIONS]
struct doca_devemu_pci_dev * pci_dev
Convenience type for representing opaque data.