[dpdk-dev] [PATCH 05/14] eal/common: introduce function to_pci_device
Jan Viktorin
viktorin at rehivetech.com
Mon Jan 4 21:08:17 CET 2016
Signed-off-by: Jan Viktorin <viktorin at rehivetech.com>
---
lib/librte_eal/common/include/rte_pci.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 1321654..204ee82 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -171,6 +171,17 @@ struct rte_pci_device {
enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */
};
+static inline struct rte_pci_device *
+to_pci_device(void *p)
+{
+ unsigned int *magic = (unsigned int *) p;
+ if (*magic == RTE_PCI_DEVICE_MAGIC)
+ return (struct rte_pci_device *) p;
+
+ rte_panic("%s: bad cast (%p: %08x)\n", __func__, p, *magic);
+ return NULL;
+}
+
/** Any PCI device identifier (vendor, device, ...) */
#define PCI_ANY_ID (0xffff)
--
2.6.3
More information about the dev
mailing list