Signed-off-by: Jan Viktorin <viktorin at rehivetech.com> --- lib/librte_cryptodev/rte_cryptodev.c | 3 +-- lib/librte_eal/common/include/rte_pci.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index f09f67e..682c1aa 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -424,8 +424,7 @@ rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv, { /* Call crypto device initialization directly if device is virtual */ if (type == PMD_VDEV) - return rte_cryptodev_init((struct rte_pci_driver *)cryptodrv, - NULL); + return rte_cryptodev_init(to_pci_driver(cryptodrv), NULL); /* * Register PCI driver for physical device intialisation during diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 54d0fe2..1321654 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -82,6 +82,7 @@ extern "C" { #include <stdint.h> #include <inttypes.h> +#include <rte_debug.h> #include <rte_interrupts.h> TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */ @@ -215,6 +216,17 @@ struct rte_pci_driver { uint32_t drv_flags; /**< Flags contolling handling of device. */ }; +static inline struct rte_pci_driver * +to_pci_driver(void *p) +{ + unsigned int *magic = (unsigned int *) p; + if (*magic == RTE_PCI_DRV_MAGIC) + return (struct rte_pci_driver *) p; + + rte_panic("%s: bad cast (%p: %08x)\n", __func__, p, *magic); + return NULL; +} + /** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */ #define RTE_PCI_DRV_NEED_MAPPING 0x0001 /** Device driver must be registered several times until failure - deprecated */ -- 2.6.3