git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net/mlx5: fix mirroring with metering action
[dpdk.git]
/
drivers
/
net
/
virtio
/
virtio_pci.c
diff --git
a/drivers/net/virtio/virtio_pci.c
b/drivers/net/virtio/virtio_pci.c
index
baadc79
..
c14d133
100644
(file)
--- a/
drivers/net/virtio/virtio_pci.c
+++ b/
drivers/net/virtio/virtio_pci.c
@@
-28,15
+28,8
@@
* The remaining space is defined by each driver as the per-driver
* configuration space.
*/
* 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)
-
-
-struct virtio_pci_internal {
- struct rte_pci_ioport io;
-};
-
-#define VTPCI_IO(hw) (&virtio_pci_internal[(hw)->port_id].io)
+#define VIRTIO_PCI_CONFIG(dev) \
+ (((dev)->msix_status == VIRTIO_MSIX_ENABLED) ? 24 : 20)
struct virtio_pci_internal virtio_pci_internal[RTE_MAX_ETHPORTS];
struct virtio_pci_internal virtio_pci_internal[RTE_MAX_ETHPORTS];
@@
-121,6
+114,7
@@
static void
legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
void *dst, int length)
{
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;
#ifdef RTE_ARCH_PPC_64
int size;
@@
-128,17
+122,17
@@
legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
if (length >= 4) {
size = 4;
rte_pci_ioport_read(VTPCI_IO(hw), dst, 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,
*(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,
*(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;
}
dst = (char *)dst + size;
@@
-147,7
+141,7
@@
legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
}
#else
rte_pci_ioport_read(VTPCI_IO(hw), dst, length,
}
#else
rte_pci_ioport_read(VTPCI_IO(hw), dst, length,
- VIRTIO_PCI_CONFIG(
hw
) + offset);
+ VIRTIO_PCI_CONFIG(
dev
) + offset);
#endif
}
#endif
}
@@
-155,6
+149,7
@@
static void
legacy_write_dev_config(struct virtio_hw *hw, size_t offset,
const void *src, int length)
{
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;
#ifdef RTE_ARCH_PPC_64
union {
uint32_t u32;
@@
-167,16
+162,16
@@
legacy_write_dev_config(struct virtio_hw *hw, size_t offset,
size = 4;
tmp.u32 = rte_cpu_to_be_32(*(const uint32_t *)src);
rte_pci_ioport_write(VTPCI_IO(hw), &tmp.u32, size,
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,
} 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,
} 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;
}
src = (const char *)src + size;
@@
-185,7
+180,7
@@
legacy_write_dev_config(struct virtio_hw *hw, size_t offset,
}
#else
rte_pci_ioport_write(VTPCI_IO(hw), src, length,
}
#else
rte_pci_ioport_write(VTPCI_IO(hw), src, length,
- VIRTIO_PCI_CONFIG(
hw
) + offset);
+ VIRTIO_PCI_CONFIG(
dev
) + offset);
#endif
}
#endif
}
@@
-311,15
+306,14
@@
legacy_intr_detect(struct virtio_hw *hw)
{
struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
{
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(VTPCI_DEV(hw));
+ hw->intr_lsc = !!dev->msix_status;
}
static int
legacy_dev_close(struct virtio_hw *hw)
{
}
static int
legacy_dev_close(struct virtio_hw *hw)
{
- struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
-
- rte_pci_unmap_device(dev->pci_dev);
+ rte_pci_unmap_device(VTPCI_DEV(hw));
rte_pci_ioport_unmap(VTPCI_IO(hw));
return 0;
rte_pci_ioport_unmap(VTPCI_IO(hw));
return 0;
@@
-489,7
+483,7
@@
modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)
avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc);
used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
ring[vq->vq_nentries]),
avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc);
used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
ring[vq->vq_nentries]),
- VIRTIO_
PCI_
VRING_ALIGN);
+ VIRTIO_VRING_ALIGN);
rte_write16(vq->vq_queue_index, &dev->common_cfg->queue_select);
rte_write16(vq->vq_queue_index, &dev->common_cfg->queue_select);
@@
-571,15
+565,14
@@
modern_intr_detect(struct virtio_hw *hw)
{
struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
{
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(VTPCI_DEV(hw));
+ hw->intr_lsc = !!dev->msix_status;
}
static int
modern_dev_close(struct virtio_hw *hw)
{
}
static int
modern_dev_close(struct virtio_hw *hw)
{
- struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
-
- rte_pci_unmap_device(dev->pci_dev);
+ rte_pci_unmap_device(VTPCI_DEV(hw));
return 0;
}
return 0;
}
@@
-603,12
+596,6
@@
const struct virtio_ops modern_ops = {
.dev_close = modern_dev_close,
};
.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)
{
static void *
get_cfg_addr(struct rte_pci_device *dev, struct virtio_pci_cap *cap)
{
@@
-691,9
+678,9
@@
virtio_read_caps(struct rte_pci_device *pci_dev, struct virtio_hw *hw)
}
if (flags & PCI_MSIX_ENABLE)
}
if (flags & PCI_MSIX_ENABLE)
-
hw->use_msix
= VIRTIO_MSIX_ENABLED;
+
dev->msix_status
= VIRTIO_MSIX_ENABLED;
else
else
-
hw->use_msix
= VIRTIO_MSIX_DISABLED;
+
dev->msix_status
= VIRTIO_MSIX_DISABLED;
}
if (cap.cap_vndr != PCI_CAP_ID_VNDR) {
}
if (cap.cap_vndr != PCI_CAP_ID_VNDR) {
@@
-774,8
+761,6
@@
vtpci_init(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev)
RTE_BUILD_BUG_ON(offsetof(struct virtio_pci_dev, hw) != 0);
RTE_BUILD_BUG_ON(offsetof(struct virtio_pci_dev, hw) != 0);
- dev->pci_dev = pci_dev;
-
/*
* Try if we can succeed reading virtio pci caps, which exists
* only on modern pci device. If failed, we fallback to legacy
/*
* Try if we can succeed reading virtio pci caps, which exists
* only on modern pci device. If failed, we fallback to legacy
@@
-818,7
+803,5
@@
void vtpci_legacy_ioport_unmap(struct virtio_hw *hw)
int vtpci_legacy_ioport_map(struct virtio_hw *hw)
{
int vtpci_legacy_ioport_map(struct virtio_hw *hw)
{
- struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
-
- return rte_pci_ioport_map(dev->pci_dev, 0, VTPCI_IO(hw));
+ return rte_pci_ioport_map(VTPCI_DEV(hw), 0, VTPCI_IO(hw));
}
}