[v4,1/1] bus/cdx: provide driver flag for optional resource mapping

Message ID 20231016091634.2770946-1-abhijit.gangurde@amd.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v4,1/1] bus/cdx: provide driver flag for optional resource mapping |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing warning Testing issues
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Abhijit Gangurde Oct. 16, 2023, 9:16 a.m. UTC
  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.gangurde@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(-)
  

Comments

Thomas Monjalon Oct. 16, 2023, 3:21 p.m. UTC | #1
16/10/2023 11:16, Abhijit Gangurde:
> 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.gangurde@amd.com>

Applied, thanks.
  

Patch

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 */