{
return VIRTIO_OPS(hw)->get_status(hw);
}
+
+uint8_t
+virtio_get_isr(struct virtio_hw *hw)
+{
+ return VIRTIO_OPS(hw)->get_isr(hw);
+}
#define VIRTIO_CONFIG_STATUS_DEV_NEED_RESET 0x40
#define VIRTIO_CONFIG_STATUS_FAILED 0x80
+/* The bit of the ISR which indicates a device has an interrupt. */
+#define VIRTIO_ISR_INTR 0x1
+/* The bit of the ISR which indicates a device configuration change. */
+#define VIRTIO_ISR_CONFIG 0x2
+/* Vector value used to disable MSI for queue. */
+#define VIRTIO_MSI_NO_VECTOR 0xFFFF
+
/*
* This structure is just a reference to read net device specific
* config space; it is just a shadow structure.
uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
uint32_t speed; /* link speed in MB */
uint8_t duplex;
- uint8_t use_msix;
+ uint8_t intr_lsc;
uint16_t max_mtu;
/*
* App management thread and virtio interrupt handler thread
void virtio_read_dev_config(struct virtio_hw *hw, size_t offset, void *dst, int length);
void virtio_reset(struct virtio_hw *hw);
void virtio_reinit_complete(struct virtio_hw *hw);
-
+uint8_t virtio_get_isr(struct virtio_hw *hw);
#endif /* _VIRTIO_H_ */
uint16_t status;
/* Read interrupt status which clears interrupt */
- isr = vtpci_isr(hw);
+ isr = virtio_get_isr(hw);
PMD_DRV_LOG(INFO, "interrupt status = %#x", isr);
if (virtio_intr_unmask(dev) < 0)
PMD_DRV_LOG(ERR, "interrupt enable failed");
- if (isr & VIRTIO_PCI_ISR_CONFIG) {
+ if (isr & VIRTIO_ISR_CONFIG) {
if (virtio_dev_link_update(dev, 0) == 0)
rte_eth_dev_callback_process(dev,
RTE_ETH_EVENT_INTR_LSC,
hw->weak_barriers = !virtio_with_feature(hw, VIRTIO_F_ORDER_PLATFORM);
/* If host does not support both status and MSI-X then disable LSC */
- if (virtio_with_feature(hw, VIRTIO_NET_F_STATUS) &&
- hw->use_msix != VIRTIO_MSIX_NONE)
+ if (virtio_with_feature(hw, VIRTIO_NET_F_STATUS) && hw->intr_lsc)
eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
else
eth_dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
* The remaining space is defined by each driver as the per-driver
* configuration space.
*/
-#define VIRTIO_PCI_CONFIG(hw) \
- (((hw)->use_msix == VIRTIO_MSIX_ENABLED) ? 24 : 20)
+#define VIRTIO_PCI_CONFIG(dev) \
+ (((dev)->msix_status == VIRTIO_MSIX_ENABLED) ? 24 : 20)
struct virtio_pci_internal {
legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
void *dst, int length)
{
+ struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
#ifdef RTE_ARCH_PPC_64
int size;
if (length >= 4) {
size = 4;
rte_pci_ioport_read(VTPCI_IO(hw), dst, size,
- VIRTIO_PCI_CONFIG(hw) + offset);
+ VIRTIO_PCI_CONFIG(dev) + offset);
*(uint32_t *)dst = rte_be_to_cpu_32(*(uint32_t *)dst);
} else if (length >= 2) {
size = 2;
rte_pci_ioport_read(VTPCI_IO(hw), dst, size,
- VIRTIO_PCI_CONFIG(hw) + offset);
+ VIRTIO_PCI_CONFIG(dev) + offset);
*(uint16_t *)dst = rte_be_to_cpu_16(*(uint16_t *)dst);
} else {
size = 1;
rte_pci_ioport_read(VTPCI_IO(hw), dst, size,
- VIRTIO_PCI_CONFIG(hw) + offset);
+ VIRTIO_PCI_CONFIG(dev) + offset);
}
dst = (char *)dst + size;
}
#else
rte_pci_ioport_read(VTPCI_IO(hw), dst, length,
- VIRTIO_PCI_CONFIG(hw) + offset);
+ VIRTIO_PCI_CONFIG(dev) + offset);
#endif
}
legacy_write_dev_config(struct virtio_hw *hw, size_t offset,
const void *src, int length)
{
+ struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
#ifdef RTE_ARCH_PPC_64
union {
uint32_t u32;
size = 4;
tmp.u32 = rte_cpu_to_be_32(*(const uint32_t *)src);
rte_pci_ioport_write(VTPCI_IO(hw), &tmp.u32, size,
- VIRTIO_PCI_CONFIG(hw) + offset);
+ VIRTIO_PCI_CONFIG(dev) + offset);
} else if (length >= 2) {
size = 2;
tmp.u16 = rte_cpu_to_be_16(*(const uint16_t *)src);
rte_pci_ioport_write(VTPCI_IO(hw), &tmp.u16, size,
- VIRTIO_PCI_CONFIG(hw) + offset);
+ VIRTIO_PCI_CONFIG(dev) + offset);
} else {
size = 1;
rte_pci_ioport_write(VTPCI_IO(hw), src, size,
- VIRTIO_PCI_CONFIG(hw) + offset);
+ VIRTIO_PCI_CONFIG(dev) + offset);
}
src = (const char *)src + size;
}
#else
rte_pci_ioport_write(VTPCI_IO(hw), src, length,
- VIRTIO_PCI_CONFIG(hw) + offset);
+ VIRTIO_PCI_CONFIG(dev) + offset);
#endif
}
{
struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
- hw->use_msix = vtpci_msix_detect(dev->pci_dev);
+ dev->msix_status = vtpci_msix_detect(dev->pci_dev);
+ hw->intr_lsc = !!dev->msix_status;
}
static int
{
struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
- hw->use_msix = vtpci_msix_detect(dev->pci_dev);
+ dev->msix_status = vtpci_msix_detect(dev->pci_dev);
+ hw->intr_lsc = !!dev->msix_status;
}
static int
.dev_close = modern_dev_close,
};
-uint8_t
-vtpci_isr(struct virtio_hw *hw)
-{
- return VIRTIO_OPS(hw)->get_isr(hw);
-}
-
static void *
get_cfg_addr(struct rte_pci_device *dev, struct virtio_pci_cap *cap)
{
}
if (flags & PCI_MSIX_ENABLE)
- hw->use_msix = VIRTIO_MSIX_ENABLED;
+ dev->msix_status = VIRTIO_MSIX_ENABLED;
else
- hw->use_msix = VIRTIO_MSIX_DISABLED;
+ dev->msix_status = VIRTIO_MSIX_DISABLED;
}
if (cap.cap_vndr != PCI_CAP_ID_VNDR) {
#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
-
/* 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;
/* 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);
-
-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);
/* rxq interrupts and config interrupt are separated in virtio-user,
* here we only report config change.
*/
- return VIRTIO_PCI_ISR_CONFIG;
+ return VIRTIO_ISR_CONFIG;
}
static uint16_t
hw->port_id = data->port_id;
dev->port_id = data->port_id;
VIRTIO_OPS(hw) = &virtio_user_ops;
- /*
- * MSIX is required to enable LSC (see virtio_init_device).
- * Here just pretend that we support msix.
- */
- hw->use_msix = 1;
+
+ hw->intr_lsc = 1;
hw->use_vec_rx = 0;
hw->use_vec_tx = 0;
hw->use_inorder_rx = 0;