# AMI - API Description The following is a brief overview of the AMI API. ## Public API Return Codes | Code | Description | | --------------------- | -------------------- | | AMI\_STATUS\_OK | Success | | AMI\_STATUS\_ERROR | Failure | ## AMI Device Functions The ami\_device struct is defined as an opaque declaration (not exposed via API) and is used to represent a single PCI device instance. It is used in various API’s to identify which device the operation should be performed with. /* Opaque declaration of `struct ami_device`. */ typedef struct ami_device ami_device; /** * struct amc_version - structure to hold AMC version information * @major: Major software version * @minor: Minor software version * @patch: Patch number (if applicable) * @local_changes: 0 for no changes, 1 for changes * @dev_commits: Number of development commits since the version was released */ struct amc_version { uint8_t major; uint8_t minor; uint8_t patch; uint8_t local_changes; uint16_t dev_commits; }; /** * enum ami_amc_debug_level - AMC debug verbosity levels * @AMI_AMC_DEBUG_LEVEL_LOG: used for printing to the log (dmesg) * @AMI_AMC_DEBUG_LEVEL_INFO: used when printing is part of the behaviour * @AMI_AMC_DEBUG_LEVEL_ERROR: used for errors * @AMI_AMC_DEBUG_LEVEL_WARNING: used for warnings * @AMI_AMC_DEBUG_LEVEL_DEBUG: used for debug prints * * Note that these log levels only apply to what AMC puts into dmesg. * Debug levels are "up to and including". The default log level is * `AMI_AMC_DEBUG_LEVEL_LOG`. */ enum ami_amc_debug_level { AMI_AMC_DEBUG_LEVEL_LOG = 0, AMI_AMC_DEBUG_LEVEL_INFO, AMI_AMC_DEBUG_LEVEL_ERROR, AMI_AMC_DEBUG_LEVEL_WARNING, AMI_AMC_DEBUG_LEVEL_DEBUG, };
| Function | Description |
|---|---|
int ami_dev_find_next(ami_device **dev, int b, int d, int f, ami_device *prev); |
Find the next device that matches the specified criteria |
int ami_dev_find(const char *bdf, ami_device **dev); |
Wrapper around `ami_dev_find_next` |
int ami_dev_bringup(const char *bdf, ami_device **dev); |
Find a device and perform additional setup logic on it |
void ami_dev_delete(ami_device **dev); |
Free the memory held by a device struct |
int ami_dev_request_access(ami_device *dev); |
Request elevated device permissions |
int ami_dev_pci_reload(ami_device **dev, const char *bdf); |
Remove a device from the PCI tree and rescan the bus |
int ami_dev_hot_reset(ami_device **dev); |
Trigger a software-based device reboot for this device |
int ami_dev_set_amc_debug_level(ami_device *dev, enum ami_amc_debug_level level); |
Set the AMC debug level. |
int ami_dev_read_uuid(ami_device *dev, char buf[AMI_LOGIC_UUID_SIZE]); |
Read the logic uuid sysfs node |
int ami_dev_get_num_devices(uint16_t *num); |
Get the number of devices attached to the driver |
int ami_dev_get_pci_link_speed(ami_device *dev, uint8_t *current, uint8_t *max); |
Get the PCI link speed. |
int ami_dev_get_pci_link_width(ami_device *dev, uint8_t *current, uint8_t *max); |
Get the PCI link width |
int ami_dev_get_pci_vendor(ami_device *dev, uint16_t *vendor); |
Get the PCI vendor ID |
int ami_dev_get_pci_device(ami_device *dev, uint16_t *device); |
Get the PCI device ID |
int ami_dev_get_pci_numa_node(ami_device *dev, uint8_t *node); |
Get the PCI device NUMA node. |
int ami_dev_get_pci_cpulist(ami_device *dev, char buf[AMI_PCI_CPULIST_SIZE]); |
Get the PCI CPU affinity |
int ami_dev_get_state(ami_device *dev, char buf[AMI_DEV_STATE_SIZE]); |
Get the device state |
int ami_dev_get_name(ami_device *dev, char buf[AMI_DEV_NAME_SIZE]); |
Get the device name |
int ami_dev_get_amc_version(ami_device *dev, struct amc_version *amc_version); |
Get AMC version info if available |
int ami_dev_get_pci_port(ami_device *dev, char buf[AMI_DEV_PCI_PORT_SIZE]); |
Get the BDF of the PCI port for the given device |
int ami_dev_get_pci_bdf(ami_device *dev, uint16_t *bdf); |
Get PCI BDF for this device |
int ami_dev_get_cdev_num(ami_device *dev, int *num); |
Get the character device number for this device |
int ami_dev_get_hwmon_num(ami_device *dev, int *num); |
Get the HWMON number for this device |
| Function Prototype |
Description |
|---|---|
typedef void (*ami_event_handler)(enum ami_event_status status, uint64_t ctr, void *data) |
Receive a single driver event - will run in a separate thread |