[dpdk-dev] [PATCH 3/7] virtio: fix build with mempool debug enabled

2015-03-04 Thread Ouyang, Changchun


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Tuesday, March 3, 2015 11:24 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH 3/7] virtio: fix build with mempool debug
> enabled
> 
> The mempool header forces error on -Wcast-qual:
>   error: cast discards ?const? qualifier from pointer target type
> 
> Let's fix it by removing const qualifier of pci driver from commit
>   5e9f6d1340ff ("pci: reference driver structure for each device") It's
> needed because the driver flags are changed depending on using uio or not.
> Actually these driver flags should be directly attached to each device.
> 
> Fixes: da978dfdc43b ("virtio: use port IO to get PCI resource")
> 
> Signed-off-by: Thomas Monjalon 

Acked-by: Changchun Ouyang


[dpdk-dev] [PATCH 3/7] virtio: fix build with mempool debug enabled

2015-03-03 Thread Thomas Monjalon
The mempool header forces error on -Wcast-qual:
error: cast discards ?const? qualifier from pointer target type

Let's fix it by removing const qualifier of pci driver from commit
5e9f6d1340ff ("pci: reference driver structure for each device")
It's needed because the driver flags are changed depending on using uio or not.
Actually these driver flags should be directly attached to each device.

Fixes: da978dfdc43b ("virtio: use port IO to get PCI resource")

Signed-off-by: Thomas Monjalon 
---
 lib/librte_eal/common/include/rte_pci.h | 2 +-
 lib/librte_pmd_virtio/Makefile  | 2 --
 lib/librte_pmd_virtio/virtio_ethdev.c   | 8 ++--
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index b9cdf8b..995f814 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -158,7 +158,7 @@ struct rte_pci_device {
struct rte_pci_id id;   /**< PCI ID. */
struct rte_pci_resource mem_resource[PCI_MAX_RESOURCE];   /**< PCI 
Memory Resource */
struct rte_intr_handle intr_handle; /**< Interrupt handle */
-   const struct rte_pci_driver *driver;/**< Associated driver */
+   struct rte_pci_driver *driver;  /**< Associated driver */
uint16_t max_vfs;   /**< sriov enable if not zero */
int numa_node;  /**< NUMA node connection */
struct rte_devargs *devargs;/**< Device user arguments */
diff --git a/lib/librte_pmd_virtio/Makefile b/lib/librte_pmd_virtio/Makefile
index 0baaf46..793067f 100644
--- a/lib/librte_pmd_virtio/Makefile
+++ b/lib/librte_pmd_virtio/Makefile
@@ -57,6 +57,4 @@ DEPDIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += lib/librte_eal 
lib/librte_ether
 DEPDIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += lib/librte_mempool lib/librte_mbuf
 DEPDIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += lib/librte_net lib/librte_malloc

-CFLAGS_virtio_ethdev.o += -Wno-cast-qual
-
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index 88ecd57..4bad1e4 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -938,8 +938,6 @@ static int virtio_resource_init_by_uio(struct 
rte_pci_device *pci_dev)
char filename[PATH_MAX];
unsigned long start, size;
unsigned int uio_num;
-   struct rte_pci_driver *pci_drv =
-   (struct rte_pci_driver *)pci_dev->driver;

if (get_uio_dev(&pci_dev->addr, dirname, sizeof(dirname), &uio_num) < 0)
return -1;
@@ -978,7 +976,7 @@ static int virtio_resource_init_by_uio(struct 
rte_pci_device *pci_dev)
}

pci_dev->intr_handle.type = RTE_INTR_HANDLE_UIO;
-   pci_drv->drv_flags |= RTE_PCI_DRV_INTR_LSC;
+   pci_dev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC;

return 0;
 }
@@ -993,8 +991,6 @@ static int virtio_resource_init_by_ioports(struct 
rte_pci_device *pci_dev)
char pci_id[16];
int found = 0;
size_t linesz;
-   struct rte_pci_driver *pci_drv =
-   (struct rte_pci_driver *)pci_dev->driver;

snprintf(pci_id, sizeof(pci_id), PCI_PRI_FMT,
 pci_dev->addr.domain,
@@ -1046,7 +1042,7 @@ static int virtio_resource_init_by_ioports(struct 
rte_pci_device *pci_dev)
start, size);

/* can't support lsc interrupt without uio */
-   pci_drv->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;
+   pci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;

return 0;
 }
-- 
2.2.2