From 5932cd76b357acbfcd9bfa56f4e7f5b3225815e9 Mon Sep 17 00:00:00 2001
From: sunshihao520 <sunshihao@huawei.com>
Date: Thu, 4 Feb 2021 14:52:43 +0800
Subject: [PATCH 01/15] lib:env_dpdk fix the enum rte_kernel_driver definition
 deference between dpdk 19.11 and 20.11

In dpdk 19.11, rte_kernel_driver is the old version, add version check before use the members.
Signed-off-by: sunshihao <sunshihao@huawei.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6252 (master)

(cherry picked from commit b1687cd45680d1573be9f66e748014fd9c5e9e4e)
Change-Id: Ic1db37cc0760c7d03692fd2cdcbb6ff1e41f872d
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6321
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: sunshihao <sunshihao@huawei.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
---
 lib/env_dpdk/memory.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/env_dpdk/memory.c b/lib/env_dpdk/memory.c
index f49dcf4..c923483 100644
--- a/lib/env_dpdk/memory.c
+++ b/lib/env_dpdk/memory.c
@@ -1238,7 +1238,11 @@ vtophys_iommu_device_event(const char *device_name,
 		RTE_DEV_FOREACH(dev, "bus=pci", &dev_iter) {
 			if (strcmp(dev->name, device_name) == 0) {
 				struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev);
+#if RTE_VERSION < RTE_VERSION_NUM(20, 11, 0, 0)
+				if (pci_dev->kdrv == RTE_KDRV_VFIO) {
+#else
 				if (pci_dev->kdrv == RTE_PCI_KDRV_VFIO) {
+#endif
 					/* This is a new PCI device using vfio */
 					g_vfio.device_ref++;
 				}
@@ -1267,7 +1271,11 @@ vtophys_iommu_device_event(const char *device_name,
 		RTE_DEV_FOREACH(dev, "bus=pci", &dev_iter) {
 			if (strcmp(dev->name, device_name) == 0) {
 				struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev);
+#if RTE_VERSION < RTE_VERSION_NUM(20, 11, 0, 0)
+				if (pci_dev->kdrv == RTE_KDRV_VFIO) {
+#else
 				if (pci_dev->kdrv == RTE_PCI_KDRV_VFIO) {
+#endif
 					/* This is a PCI device using vfio */
 					g_vfio.device_ref--;
 				}
@@ -1362,7 +1370,11 @@ vtophys_iommu_init(void)
 	RTE_DEV_FOREACH(dev, "bus=pci", &dev_iter) {
 		struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev);
 
+#if RTE_VERSION < RTE_VERSION_NUM(20, 11, 0, 0)
+		if (pci_dev->kdrv == RTE_KDRV_VFIO) {
+#else
 		if (pci_dev->kdrv == RTE_PCI_KDRV_VFIO) {
+#endif
 			/* This is a PCI device using vfio */
 			g_vfio.device_ref++;
 		}
-- 
1.8.3.1

