33 const struct doca_devemu_pci_type *pci_type,
35 struct doca_dev **dev)
37 struct doca_devinfo **dev_list;
54 for (i = 0; i < nb_devs; i++) {
63 res = has_support(dev_list[i], pci_type, &is_supported);
70 if (is_supported == 0) {
72 "Device doesn't support the hot plug capability. Make sure a physical function was provided, and running with root permission");
97 struct doca_devinfo_rep **rep_list;
110 for (dev_idx = 0; dev_idx < nb_devs; ++dev_idx) {
236 region_config->
size);
238 DOCA_LOG_ERR(
"Unable to set MSI-X table region at index %d: %s",
250 region_config->
size);
252 DOCA_LOG_ERR(
"Unable to set MSI-X pending bit array region at index %d: %s",
264 region_config->
size);
311 DOCA_LOG_ERR(
"Failed to configure and start pci device");
322 if (pci_type !=
NULL) {
341 switch (hotplug_state) {
343 return "DOCA_DEVEMU_PCI_HP_STATE_POWER_OFF";
345 return "DOCA_DEVEMU_PCI_HP_STATE_UNPLUG_IN_PROGRESS";
347 return "DOCA_DEVEMU_PCI_HP_STATE_PLUG_IN_PROGRESS";
349 return "DOCA_DEVEMU_PCI_HP_STATE_POWER_ON";
355 #ifdef SPDK_APP_DEBUG
363 const size_t line_size = 8 + 2 + 8 * 3 + 1 + 8 * 3 + 1 + 16 + 1;
364 size_t i, j, r, read_index;
365 size_t num_lines, buffer_size;
366 char *buffer, *write_head;
367 unsigned char cur_char, printable;
369 const unsigned char *input_buffer;
372 num_lines = (
size + 16 - 1) / 16;
373 buffer_size = num_lines * line_size + 1;
374 buffer = (
char *)malloc(buffer_size);
381 for (i = 0; i < num_lines; i++) {
383 snprintf(write_head, buffer_size,
"%08lX: ", i * 16);
385 buffer_size -= 8 + 2;
387 for (r = 0; r < 2; r++) {
388 for (j = 0; j < 8; j++) {
390 if (read_index <
size) {
391 cur_char = input_buffer[read_index++];
392 snprintf(write_head, buffer_size,
"%02X ", cur_char);
394 if (
' ' <= cur_char && cur_char <=
'~')
395 printable = cur_char;
401 snprintf(write_head, buffer_size,
" ");
404 ascii_line[r * 8 + j] = printable;
409 snprintf(write_head, buffer_size,
" ");
414 ascii_line[16] =
'\0';
415 snprintf(write_head, buffer_size,
"%s\n", ascii_line);
416 write_head += 16 + 1;
417 buffer_size -= 16 + 1;
420 write_head[-1] =
'\0';
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_stateful_region_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size)
Set a stateful BAR region configuration for a BAR layout in a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_start(struct doca_devemu_pci_type *pci_type)
Start a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_create_rep_list(struct doca_devemu_pci_type *pci_type, struct doca_devinfo_rep ***dev_list_rep, uint32_t *nb_devs_rep)
Create list of available representor devices for a given DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_memory_bar_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint8_t log_sz, enum doca_devemu_pci_bar_mem_type memory_type, uint8_t prefetchable)
Set a memory BAR layout configuration for DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_stop(struct doca_devemu_pci_type *pci_type)
Stop a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_class_code(struct doca_devemu_pci_type *pci_type, uint32_t class_code)
Set the PCI Class Code of a DOCA devemu PCI type to identify generic operation.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_revision_id(struct doca_devemu_pci_type *pci_type, uint8_t revision_id)
Set the PCI Revision ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_device_id(struct doca_devemu_pci_type *pci_type, uint16_t device_id)
Set the PCI Device ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_db_region_by_offset_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size, uint8_t log_db_size, uint8_t log_stride_size)
Set a doorbell BAR region configuration for a BAR layout in a DOCA devemu PCI type....
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.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_vendor_id(struct doca_devemu_pci_type *pci_type, uint16_t vendor_id)
Set the PCI Vendor ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_db_region_by_data_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size, uint8_t log_db_size, uint16_t db_id_msbyte, uint16_t db_id_lsbyte)
Set a doorbell BAR region configuration for a BAR layout in a DOCA devemu PCI type....
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_num_msix(struct doca_devemu_pci_type *pci_type, uint16_t num_msix)
Set the size of the MSI-X Table from MSI-X Capability Registers (1 based) of a DOCA devemu PCI type....
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_subsystem_id(struct doca_devemu_pci_type *pci_type, uint16_t subsystem_id)
Set the PCI Subsystem ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_destroy(struct doca_devemu_pci_type *pci_type)
Destroy a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_subsystem_vendor_id(struct doca_devemu_pci_type *pci_type, uint16_t subsystem_vid)
Set the PCI Subsystem Vendor ID of a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_msix_pba_region_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size)
Set a MSI-X PBA BAR region configuration for a BAR layout in a DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_dev(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
Set the DOCA device for a specific DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_set_bar_msix_table_region_conf(struct doca_devemu_pci_type *pci_type, uint8_t id, uint64_t start_addr, uint64_t size)
Set a MSI-X table BAR region configuration for a BAR layout in a DOCA devemu PCI 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_devemu_pci_hotplug_state
DOCA devemu pci hotplug state.
@ 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_STABLE doca_error_t doca_dev_rep_open(struct doca_devinfo_rep *devinfo, struct doca_dev_rep **dev_rep)
Initialize representor device for use.
DOCA_STABLE doca_error_t doca_devinfo_rep_destroy_list(struct doca_devinfo_rep **dev_list_rep)
Destroy list of representor device info structures.
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_rep_get_vuid(const struct doca_devinfo_rep *devinfo_rep, char *rep_vuid, uint32_t size)
Get the Vendor Unique ID of a representor DOCA devinfo.
DOCA_STABLE doca_error_t doca_devinfo_get_ibdev_name(const struct doca_devinfo *devinfo, char *ibdev_name, uint32_t size)
Get the name of the IB device represented by a DOCA devinfo.
#define DOCA_DEVINFO_IBDEV_NAME_SIZE
Buffer size to hold Infiniband/RoCE device name. Including a null terminator.
#define DOCA_DEVINFO_REP_VUID_SIZE
Buffer size to hold VUID. Including a null terminator.
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 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.
@ DOCA_ERROR_NOT_SUPPORTED
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_WARN(format,...)
Generates a WARNING application log message.
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)
void cleanup_pci_resources(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
doca_error_t create_find_start_pci_type(char *dev_name, 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)
static doca_error_t set_pci_type_configurations(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
DOCA_LOG_REGISTER(NVME_PCI_COMMON)
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)
doca_error_t(* emulation_supported_cb_t)(const struct doca_devinfo *, const struct doca_devemu_pci_type *pci_type, uint8_t *is_supported)
#define PCI_TYPE_NUM_BAR_MSIX_PBA_REGIONS
#define PCI_TYPE_SUBSYSTEM_VENDOR_ID
#define PCI_TYPE_NUM_BAR_MSIX_TABLE_REGIONS
static const struct bar_memory_layout_config layout_configs[PCI_TYPE_NUM_BAR_MEMORY_LAYOUT]
#define PCI_TYPE_NUM_BAR_MEMORY_LAYOUT
static const struct bar_db_region_config db_configs[PCI_TYPE_NUM_BAR_DB_REGIONS]
#define PCI_TYPE_SUBSYSTEM_ID
#define PCI_TYPE_VENDOR_ID
#define PCI_TYPE_DEVICE_ID
static const struct bar_region_config msix_pba_configs[PCI_TYPE_NUM_BAR_MSIX_PBA_REGIONS]
#define PCI_TYPE_NUM_BAR_DB_REGIONS
#define PCI_TYPE_NUM_BAR_STATEFUL_REGIONS
#define PCI_TYPE_REVISION_ID
static const struct bar_region_config msix_table_configs[PCI_TYPE_NUM_BAR_MSIX_TABLE_REGIONS]
#define PCI_TYPE_CLASS_CODE
static const struct bar_region_config stateful_configs[PCI_TYPE_NUM_BAR_STATEFUL_REGIONS]
#define PCI_TYPE_NUM_MSIX
struct bar_region_config region
uint8_t log_db_stride_size
enum doca_devemu_pci_bar_mem_type memory_type