Commit c8f05283 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Jim Harris
Browse files

bdev_virtio: added virtio_driver struct



Added new struct virtio_driver together
with it's global instance. The struct should
keep all bdev_virtio related information.

Change-Id: If78967c68c4131c89cd86cb4b46f5f0194bca323
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/379863


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent d68001ab
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@
#include "virtio_logs.h"
#include "virtio_queue.h"

struct vtpci_internal virtio_hw_internal[128];
struct virtio_driver g_virtio_driver;

/*
 * Following macros are derived from linux/pci_regs.h, however,
@@ -706,7 +706,7 @@ vtpci_init(struct spdk_pci_device *dev, struct virtio_dev *vdev)
	 */
	if (virtio_read_caps(dev, hw) == 0) {
		PMD_INIT_LOG(INFO, "modern virtio pci detected.");
		virtio_hw_internal[vdev->port_id].vtpci_ops = &modern_ops;
		VTPCI_OPS(vdev) = &modern_ops;
		vdev->modern = 1;
		return 0;
	}
@@ -726,7 +726,7 @@ vtpci_init(struct spdk_pci_device *dev, struct virtio_dev *vdev)
	}
#endif

	virtio_hw_internal[vdev->port_id].vtpci_ops = &legacy_ops;
	VTPCI_OPS(vdev) = &legacy_ops;
	vdev->modern   = 0;

	return 0;
+7 −3
Original line number Diff line number Diff line
@@ -233,10 +233,14 @@ struct vtpci_internal {
	struct rte_pci_ioport io;
};

#define VTPCI_OPS(dev)	(virtio_hw_internal[(dev)->port_id].vtpci_ops)
#define VTPCI_IO(dev)	(&virtio_hw_internal[(dev)->port_id].io)
#define VTPCI_OPS(dev)	(g_virtio_driver.internal[(dev)->port_id].vtpci_ops)
#define VTPCI_IO(dev)	(&g_virtio_driver.internal[(dev)->port_id].io)

extern struct vtpci_internal virtio_hw_internal[128];
struct virtio_driver {
	struct vtpci_internal internal[128];
};

extern struct virtio_driver g_virtio_driver;

/*
 * How many bits to shift physical queue address written to QUEUE_PFN.
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ virtio_user_dev_init(char *path, int queues, int queue_size)
	vdev = &dev->vdev;
	vdev->is_hw = 0;

	virtio_hw_internal[0].vtpci_ops = &virtio_user_ops;
	VTPCI_OPS(vdev) = &virtio_user_ops;

	snprintf(dev->path, PATH_MAX, "%s", path);
	/* Account for control and event queue. */