Commit f26983fa authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

rte_virtio: move pci_dump_json_config out of #ifdef



pci_dump_json_config() is used for both legacy and modern PCI virtio
devices, so move it out of the #ifdef PCI_LEGACY_SUPPORT so it is
available when building against older DPDK versions.

Change-Id: I986f9e6a81abda64d77f954b15807d06e35d1748
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/383487


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
parent 79745b8c
Loading
Loading
Loading
Loading
+19 −19
Original line number Diff line number Diff line
@@ -88,6 +88,25 @@ free_virtio_hw(struct virtio_dev *dev)
	free(hw);
}

static void
pci_dump_json_config(struct virtio_dev *dev, struct spdk_json_write_ctx *w)
{
	struct virtio_hw *hw = virtio_dev_get_hw(dev);
	struct spdk_pci_addr pci_addr = spdk_pci_device_get_addr((struct spdk_pci_device *)hw->pci_dev);
	char addr[32];

	spdk_json_write_name(w, "type");
	if (dev->modern) {
		spdk_json_write_string(w, "pci-modern");
	} else {
		spdk_json_write_string(w, "pci-legacy");
	}

	spdk_json_write_name(w, "pci_address");
	spdk_pci_addr_fmt(addr, sizeof(addr), &pci_addr);
	spdk_json_write_string(w, addr);
}

#ifdef PCI_LEGACY_SUPPORT

static struct rte_pci_ioport *
@@ -240,25 +259,6 @@ legacy_notify_queue(struct virtio_dev *dev, struct virtqueue *vq)
		VIRTIO_PCI_QUEUE_NOTIFY);
}

static void
pci_dump_json_config(struct virtio_dev *dev, struct spdk_json_write_ctx *w)
{
	struct virtio_hw *hw = virtio_dev_get_hw(dev);
	struct spdk_pci_addr pci_addr = spdk_pci_device_get_addr((struct spdk_pci_device *)hw->pci_dev);
	char addr[32];

	spdk_json_write_name(w, "type");
	if (dev->modern) {
		spdk_json_write_string(w, "pci-modern");
	} else {
		spdk_json_write_string(w, "pci-legacy");
	}

	spdk_json_write_name(w, "pci_address");
	spdk_pci_addr_fmt(addr, sizeof(addr), &pci_addr);
	spdk_json_write_string(w, addr);
}

const struct virtio_pci_ops legacy_ops = {
	.read_dev_cfg	= legacy_read_dev_config,
	.write_dev_cfg	= legacy_write_dev_config,