43 #define SLEEP_IN_MICROS (10)
44 #define SLEEP_IN_NANOS (SLEEP_IN_MICROS * 1000)
45 #define TIMEOUT_IN_MICROS (5 * 1000 * 1000)
47 #define VFS_DEVICE_QUEUE_SIZE 64
48 #define VFS_DEVICE_NUM_QUEUES 16
55 struct doca_dev_rep *
rep;
70 if (signum == SIGINT || signum == SIGTERM) {
71 DOCA_LOG_INFO(
"Signal %d received, preparing to exit", signum);
132 uint8_t is_equal = 0;
136 return is_equal == 1;
149 struct doca_devinfo **dev_list;
164 for (i = 0; i < nb_devs; i++) {
194 DOCA_LOG_INFO(
"Emulated device's hotplug state has changed");
202 switch (hotplug_state) {
204 DOCA_LOG_INFO(
"Hotplug state changed to DOCA_DEVEMU_PCI_HP_STATE_POWER_OFF");
207 DOCA_LOG_INFO(
"Hotplug state changed to DOCA_DEVEMU_PCI_HP_STATE_UNPLUG_IN_PROGRESS");
210 DOCA_LOG_INFO(
"Hotplug state changed to DOCA_DEVEMU_PCI_HP_STATE_PLUG_IN_PROGRESS");
213 DOCA_LOG_INFO(
"Hotplug state changed to DOCA_DEVEMU_PCI_HP_STATE_POWER_ON");
238 DOCA_LOG_ERR(
"Unable to allocate emulated PCI device hotplug state change event: %s",
255 uint8_t is_supported = 0;
256 size_t elapsed_time_in_micros;
257 struct timespec ts = {
296 if (is_supported == 0) {
298 "Found device with matching address, but does not have hotplug support. Make sure a physical function was provided, and running with root permission");
347 DOCA_LOG_INFO(
"Hotplug initiated waiting for host to notice new device");
366 DOCA_LOG_INFO(
"Hotunplug initiated waiting for host to release device");
369 elapsed_time_in_micros = 0;
static const char tag[DOCA_VFS_TAG_SIZE+1]
static void state_cleanup(struct program_state *state)
static doca_error_t register_to_hotplug_state_change_events(struct doca_devemu_pci_dev *pci_dev, void *cookie)
static bool device_has_pci_addr(const struct doca_devinfo *devinfo, const char *pci_address)
static void hotplug_event_handler_cb(struct doca_devemu_pci_dev *pci_dev, union doca_data user_data)
static bool unplug_requested
#define VFS_DEVICE_QUEUE_SIZE
#define TIMEOUT_IN_MICROS
doca_error_t devemu_vfs_device_create(const char *pci_address)
#define VFS_DEVICE_NUM_QUEUES
static doca_error_t find_doca_device(const char *pci_address, struct doca_dev **dev)
DOCA_LOG_REGISTER(DPU_DEVEMU_VFS_DEVICE_CREATE)
static void signal_handler(int signum)
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_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_create_rep(const struct doca_devemu_pci_type *pci_type, struct doca_dev_rep **dev_rep)
Create a new representor device for a given DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_destroy_rep(struct doca_dev_rep *rep_dev)
Destroy a representor device created by doca_devemu_pci_dev_create_rep().
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_hotplug(struct doca_devemu_pci_dev *pci_dev)
Issue hotplug procedure of the DOCA devemu PCI device.
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_devemu_pci_hotplug_state
DOCA devemu pci hotplug state.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_event_hotplug_state_change_register(struct doca_devemu_pci_dev *pci_dev, doca_devemu_pci_dev_event_hotplug_state_change_handler_cb_t handler, union doca_data user_data)
Register to hotplug state changes.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_hotunplug(struct doca_devemu_pci_dev *pci_dev)
Issue hot unplug procedure of the DOCA devemu PCI device.
@ DOCA_DEVEMU_PCI_HP_STATE_POWER_OFF
@ DOCA_DEVEMU_PCI_HP_STATE_UNPLUG_IN_PROGRESS
@ DOCA_DEVEMU_PCI_HP_STATE_PLUG_IN_PROGRESS
@ DOCA_DEVEMU_PCI_HP_STATE_POWER_ON
DOCA_EXPERIMENTAL struct doca_devemu_pci_type * doca_devemu_vfs_type_as_pci_type(struct doca_devemu_vfs_type *vfs_type)
Convert DOCA Virtio FS type instance into DOCA PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_vfs_find_default_vfs_type_by_dev(struct doca_dev *dev, struct doca_devemu_vfs_type **vfs_type)
Find the default DOCA Virtio FS type associated with the device.
#define DOCA_VFS_TAG_SIZE
Size, in bytes, of the virtio FS tag in DOCA. According to the specification this is the name associa...
DOCA_EXPERIMENTAL struct doca_devemu_pci_dev * doca_devemu_vfs_dev_as_pci_dev(struct doca_devemu_vfs_dev *vfs_dev)
Convert DOCA Virtio FS device instance into DOCA devemu PCI device.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_vfs_dev_set_num_request_queues(struct doca_devemu_vfs_dev *vfs_dev, uint32_t num_request_queues)
Set the value of the VIRTIO FS Device num_request_queues register.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_vfs_dev_set_tag(struct doca_devemu_vfs_dev *vfs_dev, const char tag[DOCA_VFS_TAG_SIZE])
Set the value of the Virtio FS device tag. According to the specification the tag is encoded in UTF-8...
DOCA_EXPERIMENTAL doca_error_t doca_devemu_vfs_dev_destroy(struct doca_devemu_vfs_dev *vfs_dev)
Free a DOCA Virtio FS device object.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_vfs_dev_create(struct doca_devemu_vfs_type *vfs_type, struct doca_dev_rep *dev_rep, struct doca_pe *progress_engine, struct doca_devemu_vfs_dev **vfs_dev)
Allocate DOCA Virtio FS device.
DOCA_EXPERIMENTAL struct doca_devemu_virtio_dev * doca_devemu_vfs_dev_as_virtio_dev(struct doca_devemu_vfs_dev *vfs_dev)
Convert DOCA Virtio FS device instance into DOCA Virtio device.
DOCA_EXPERIMENTAL struct doca_ctx * doca_devemu_vfs_dev_as_ctx(struct doca_devemu_vfs_dev *vfs_dev)
Convert DOCA Virtio FS device instance into DOCA context.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_virtio_dev_set_queue_size(struct doca_devemu_virtio_dev *virtio_dev, uint16_t queue_size)
Set the Virtio max queue size for all Virtio queues.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_virtio_dev_set_num_queues(struct doca_devemu_virtio_dev *virtio_dev, uint16_t num_queues)
Set the Virtio device num_queues register in common configuration structure according to Virtio speci...
DOCA_STABLE doca_error_t doca_devinfo_is_equal_pci_addr(const struct doca_devinfo *devinfo, const char *pci_addr_str, uint8_t *is_equal)
Check if a PCI address belongs to a DOCA devinfo.
DOCA_STABLE doca_error_t doca_devinfo_create_list(struct doca_devinfo ***dev_list, uint32_t *nb_devs)
Creates list of all available local devices.
DOCA_STABLE doca_error_t doca_devinfo_destroy_list(struct doca_devinfo **dev_list)
Destroy list of local device info structures.
DOCA_STABLE doca_error_t doca_dev_open(struct doca_devinfo *devinfo, struct doca_dev **dev)
Initialize local device for use.
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_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
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.
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_WARN(format,...)
Generates a WARNING application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
DOCA_STABLE doca_error_t doca_pe_destroy(struct doca_pe *pe)
Destroy doca progress engine.
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.
struct doca_devemu_vfs_dev * vfs_dev
struct doca_dev_rep * rep
struct doca_devemu_vfs_type * vfs_type
Convenience type for representing opaque data.