@@ -221,6 +221,19 @@ SRST
Show PCI information.
ERST
+ {
+ .name = "msix",
+ .args_type = "dev:s",
+ .params = "dev",
+ .help = "dump MSI-X information",
+ .cmd = hmp_info_msix,
+ },
+
+SRST
+ ``info msix`` *dev*
+ Dump MSI-X information for device *dev*.
+ERST
+
#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K)
{
@@ -22,6 +22,7 @@
#include "sysemu/xen.h"
#include "migration/qemu-file-types.h"
#include "migration/vmstate.h"
+#include "monitor/monitor.h"
#include "qemu/range.h"
#include "qapi/error.h"
#include "trace.h"
@@ -669,3 +670,65 @@ const VMStateDescription vmstate_msix = {
VMSTATE_END_OF_LIST()
}
};
+
+static void msix_dump_table(Monitor *mon, PCIDevice *dev)
+{
+ int vector;
+ uint32_t val;
+ uint8_t *table_entry;
+
+ monitor_printf(mon, "Msg L.Addr ");
+ monitor_printf(mon, "Msg U.Addr ");
+ monitor_printf(mon, "Msg Data ");
+ monitor_printf(mon, "Vect Ctrl\n");
+
+ for (vector = 0; vector < dev->msix_entries_nr; vector++) {
+ table_entry = dev->msix_table + vector * PCI_MSIX_ENTRY_SIZE;
+
+ val = pci_get_long(table_entry + PCI_MSIX_ENTRY_LOWER_ADDR);
+ monitor_printf(mon, "0x%08x ", val);
+
+ val = pci_get_long(table_entry + PCI_MSIX_ENTRY_UPPER_ADDR);
+ monitor_printf(mon, "0x%08x ", val);
+
+ val = pci_get_long(table_entry + PCI_MSIX_ENTRY_DATA);
+ monitor_printf(mon, "0x%08x ", val);
+
+ val = pci_get_long(table_entry + PCI_MSIX_ENTRY_VECTOR_CTRL);
+ monitor_printf(mon, "0x%08x\n", val);
+ }
+
+ monitor_printf(mon, "\n");
+}
+
+static void msix_dump_pba(Monitor *mon, PCIDevice *dev)
+{
+ int vector;
+
+ monitor_printf(mon, "MSI-X PBA\n");
+
+ for (vector = 0; vector < dev->msix_entries_nr; vector++) {
+ monitor_printf(mon, "%d ", !!msix_is_pending(dev, vector));
+
+ if (vector % 16 == 15) {
+ monitor_printf(mon, "\n");
+ }
+ }
+
+ if (vector % 16 != 15) {
+ monitor_printf(mon, "\n");
+ }
+
+ monitor_printf(mon, "\n");
+}
+
+void msix_dump_info(Monitor *mon, PCIDevice *dev, Error **errp)
+{
+ if (!msix_present(dev)) {
+ error_setg(errp, "MSI-X not available");
+ return;
+ }
+
+ msix_dump_table(mon, dev);
+ msix_dump_pba(mon, dev);
+}
@@ -47,6 +47,8 @@ int msix_set_vector_notifiers(PCIDevice *dev,
MSIVectorPollNotifier poll_notifier);
void msix_unset_vector_notifiers(PCIDevice *dev);
+void msix_dump_info(Monitor *mon, PCIDevice *dev, Error **errp);
+
extern const VMStateDescription vmstate_msix;
#define VMSTATE_MSIX_TEST(_field, _state, _test) { \
@@ -36,6 +36,7 @@ void hmp_info_irq(Monitor *mon, const QDict *qdict);
void hmp_info_pic(Monitor *mon, const QDict *qdict);
void hmp_info_rdma(Monitor *mon, const QDict *qdict);
void hmp_info_pci(Monitor *mon, const QDict *qdict);
+void hmp_info_msix(Monitor *mon, const QDict *qdict);
void hmp_info_tpm(Monitor *mon, const QDict *qdict);
void hmp_info_iothreads(Monitor *mon, const QDict *qdict);
void hmp_quit(Monitor *mon, const QDict *qdict);
@@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "hw/sysbus.h"
+#include "hw/pci/msix.h"
#include "monitor/hmp.h"
#include "monitor/monitor.h"
#include "monitor/qdev.h"
@@ -1005,3 +1006,27 @@ bool qmp_command_available(const QmpCommand *cmd, Error **errp)
}
return true;
}
+
+void hmp_info_msix(Monitor *mon, const QDict *qdict)
+{
+ const char *name = qdict_get_str(qdict, "dev");
+ DeviceState *dev = find_device_state(name, NULL);
+ PCIDevice *pci_dev;
+ Error *err = NULL;
+
+ if (!dev) {
+ error_setg(&err, "Device %s not found", name);
+ goto exit;
+ }
+
+ if (!object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+ error_setg(&err, "Not a PCI device");
+ goto exit;
+ }
+
+ pci_dev = PCI_DEVICE(dev);
+ msix_dump_info(mon, pci_dev, &err);
+
+exit:
+ hmp_handle_error(mon, err);
+}