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: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/379863
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-09-25 19:57:57 +02:00 committed by Jim Harris
parent d68001abd8
commit c8f052836d
3 changed files with 11 additions and 7 deletions

View File

@ -43,7 +43,7 @@
#include "virtio_logs.h" #include "virtio_logs.h"
#include "virtio_queue.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, * 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) { if (virtio_read_caps(dev, hw) == 0) {
PMD_INIT_LOG(INFO, "modern virtio pci detected."); 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; vdev->modern = 1;
return 0; return 0;
} }
@ -726,7 +726,7 @@ vtpci_init(struct spdk_pci_device *dev, struct virtio_dev *vdev)
} }
#endif #endif
virtio_hw_internal[vdev->port_id].vtpci_ops = &legacy_ops; VTPCI_OPS(vdev) = &legacy_ops;
vdev->modern = 0; vdev->modern = 0;
return 0; return 0;

View File

@ -233,10 +233,14 @@ struct vtpci_internal {
struct rte_pci_ioport io; struct rte_pci_ioport io;
}; };
#define VTPCI_OPS(dev) (virtio_hw_internal[(dev)->port_id].vtpci_ops) #define VTPCI_OPS(dev) (g_virtio_driver.internal[(dev)->port_id].vtpci_ops)
#define VTPCI_IO(dev) (&virtio_hw_internal[(dev)->port_id].io) #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. * How many bits to shift physical queue address written to QUEUE_PFN.

View File

@ -239,7 +239,7 @@ virtio_user_dev_init(char *path, int queues, int queue_size)
vdev = &dev->vdev; vdev = &dev->vdev;
vdev->is_hw = 0; 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); snprintf(dev->path, PATH_MAX, "%s", path);
/* Account for control and event queue. */ /* Account for control and event queue. */