Provide driver flag which gives an option to map the cdx device
resource before probing the device driver. External driver can
use rte_cdx_map_device() and rte_cdx_unmap_device() APIs to map/
unmap device resource separately.

Signed-off-by: Abhijit Gangurde <abhijit.gangu...@amd.com>
---
 v4:
 - rte_cdx_map_device() and rte_cdx_unmap_device() APIs are kept
   as internal APIs.

 v3:
 - Changed APIs to __rte_experimental.

 v2:
 - Corrected _RTE_BUS_CDX_H_ to RTE_BUS_CDX_H
 - Improved code comments.

 drivers/bus/cdx/bus_cdx_driver.h |  3 +++
 drivers/bus/cdx/cdx.c            | 10 ++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/cdx/bus_cdx_driver.h b/drivers/bus/cdx/bus_cdx_driver.h
index fcacdb5896..1c9a64c87a 100644
--- a/drivers/bus/cdx/bus_cdx_driver.h
+++ b/drivers/bus/cdx/bus_cdx_driver.h
@@ -37,6 +37,9 @@ struct rte_cdx_bus;
 static const char DRV_EXP_TAG(name, cdx_tbl_export)[] __rte_used = \
 RTE_STR(table)
 
+/** Device needs resource mapping */
+#define RTE_CDX_DRV_NEED_MAPPING 0x0001
+
 /**
  * A structure describing an ID for a CDX driver. Each driver provides a
  * table of these IDs for each device that it supports.
diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c
index f9526e08cc..541aae76c3 100644
--- a/drivers/bus/cdx/cdx.c
+++ b/drivers/bus/cdx/cdx.c
@@ -383,10 +383,12 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,
        CDX_BUS_DEBUG("  probe device %s using driver: %s", dev_name,
                dr->driver.name);
 
-       ret = cdx_vfio_map_resource(dev);
-       if (ret != 0) {
-               CDX_BUS_ERR("CDX map device failed: %d", ret);
-               goto error_map_device;
+       if (dr->drv_flags & RTE_CDX_DRV_NEED_MAPPING) {
+               ret = cdx_vfio_map_resource(dev);
+               if (ret != 0) {
+                       CDX_BUS_ERR("CDX map device failed: %d", ret);
+                       goto error_map_device;
+               }
        }
 
        /* call the driver probe() function */
-- 
2.34.1

Reply via email to