#define VIRTIO_MSI_QUEUE_VECTOR 22 /* vector for selected VQ notifications
(16, RW) */
-/* The bit of the ISR which indicates a device has an interrupt. */
-#define VIRTIO_PCI_ISR_INTR 0x1
-/* The bit of the ISR which indicates a device configuration change. */
-#define VIRTIO_PCI_ISR_CONFIG 0x2
-/* Vector value used to disable MSI for queue. */
-#define VIRTIO_MSI_NO_VECTOR 0xFFFF
-
-/* VirtIO device IDs. */
-#define VIRTIO_ID_NETWORK 0x01
-#define VIRTIO_ID_BLOCK 0x02
-#define VIRTIO_ID_CONSOLE 0x03
-#define VIRTIO_ID_ENTROPY 0x04
-#define VIRTIO_ID_BALLOON 0x05
-#define VIRTIO_ID_IOMEMORY 0x06
-#define VIRTIO_ID_9P 0x09
-
-/* Status byte for guest to report progress. */
-#define VIRTIO_CONFIG_STATUS_RESET 0x00
-#define VIRTIO_CONFIG_STATUS_ACK 0x01
-#define VIRTIO_CONFIG_STATUS_DRIVER 0x02
-#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04
-#define VIRTIO_CONFIG_STATUS_FEATURES_OK 0x08
-#define VIRTIO_CONFIG_STATUS_DEV_NEED_RESET 0x40
-#define VIRTIO_CONFIG_STATUS_FAILED 0x80
-
-
/* Common configuration */
#define VIRTIO_PCI_CAP_COMMON_CFG 1
/* Notifications */
uint32_t queue_used_hi; /* read-write */
};
+enum virtio_msix_status {
+ VIRTIO_MSIX_NONE = 0,
+ VIRTIO_MSIX_DISABLED = 1,
+ VIRTIO_MSIX_ENABLED = 2
+};
+
struct virtio_pci_dev {
struct virtio_hw hw;
- struct rte_pci_device *pci_dev;
struct virtio_pci_common_cfg *common_cfg;
struct virtio_net_config *dev_cfg;
+ enum virtio_msix_status msix_status;
uint8_t *isr;
uint16_t *notify_base;
uint32_t notify_off_multiplier;
#define virtio_pci_get_dev(hwp) container_of(hwp, struct virtio_pci_dev, hw)
-/*
- * This structure is just a reference to read
- * net device specific config space; it just a chodu structure
- *
- */
-struct virtio_net_config {
- /* The config defining mac address (if VIRTIO_NET_F_MAC) */
- uint8_t mac[RTE_ETHER_ADDR_LEN];
- /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
- uint16_t status;
- uint16_t max_virtqueue_pairs;
- uint16_t mtu;
- /*
- * speed, in units of 1Mb. All values 0 to INT_MAX are legal.
- * Any other value stands for unknown.
- */
- uint32_t speed;
- /*
- * 0x00 - half duplex
- * 0x01 - full duplex
- * Any other value stands for unknown.
- */
- uint8_t duplex;
-
-} __rte_packed;
+struct virtio_pci_internal {
+ struct rte_pci_ioport io;
+ struct rte_pci_device *dev;
+};
+
+extern struct virtio_pci_internal virtio_pci_internal[RTE_MAX_ETHPORTS];
+
+#define VTPCI_IO(hw) (&virtio_pci_internal[(hw)->port_id].io)
+#define VTPCI_DEV(hw) (virtio_pci_internal[(hw)->port_id].dev)
+
/*
* How many bits to shift physical queue address written to QUEUE_PFN.
*/
#define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12
-/* The alignment to use between consumer and producer parts of vring. */
-#define VIRTIO_PCI_VRING_ALIGN 4096
-
-enum virtio_msix_status {
- VIRTIO_MSIX_NONE = 0,
- VIRTIO_MSIX_DISABLED = 1,
- VIRTIO_MSIX_ENABLED = 2
-};
-
-
/*
* Function declaration from virtio_pci.c
*/
int vtpci_init(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev);
-void vtpci_reset(struct virtio_hw *);
-
-void vtpci_reinit_complete(struct virtio_hw *);
-
-uint8_t vtpci_get_status(struct virtio_hw *);
-void vtpci_set_status(struct virtio_hw *, uint8_t);
-
-void vtpci_write_dev_config(struct virtio_hw *, size_t, const void *, int);
-
-void vtpci_read_dev_config(struct virtio_hw *, size_t, void *, int);
-
-uint8_t vtpci_isr(struct virtio_hw *);
-
void vtpci_legacy_ioport_unmap(struct virtio_hw *hw);
int vtpci_legacy_ioport_map(struct virtio_hw *hw);