[dpdk-dev] bus/fslmc: add support for scanned device count

Message ID 20180102130838.3630-1-shreyansh.jain@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Shreyansh Jain Jan. 2, 2018, 1:08 p.m. UTC
  FSLMC bus detects a multiple type of logical objects representing
components of the datapath.

Using the type of device, a newly introduced API
rte_fslmc_get_device_count can return the count of devices
scanned of that device type.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
:: This patch is based on *net-next* tree.

 drivers/bus/fslmc/fslmc_bus.c               | 12 ++++++++++++
 drivers/bus/fslmc/rte_bus_fslmc_version.map |  1 +
 drivers/bus/fslmc/rte_fslmc.h               | 18 +++++++++++++++---
 3 files changed, 28 insertions(+), 3 deletions(-)
  

Comments

Hemant Agrawal Jan. 11, 2018, 8:56 a.m. UTC | #1
On 1/2/2018 6:38 PM, Shreyansh Jain wrote:
> FSLMC bus detects a multiple type of logical objects representing
> components of the datapath.
>
> Using the type of device, a newly introduced API
> rte_fslmc_get_device_count can return the count of devices
> scanned of that device type.
>
> Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
> ---
> :: This patch is based on *net-next* tree.

<snip>..
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
  
Thomas Monjalon Jan. 12, 2018, 11:45 a.m. UTC | #2
02/01/2018 14:08, Shreyansh Jain:
> FSLMC bus detects a multiple type of logical objects representing
> components of the datapath.
> 
> Using the type of device, a newly introduced API
> rte_fslmc_get_device_count can return the count of devices
> scanned of that device type.
> 
> Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
> ---
> :: This patch is based on *net-next* tree.

Why is it based on next-net tree?
  
Shreyansh Jain Jan. 12, 2018, 12:59 p.m. UTC | #3
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Friday, January 12, 2018 5:15 PM
> To: Shreyansh Jain <shreyansh.jain@nxp.com>
> Cc: dev@dpdk.org; ferruh.yigit@intel.com
> Subject: Re: [dpdk-dev] [PATCH] bus/fslmc: add support for scanned device
> count
> 
> 02/01/2018 14:08, Shreyansh Jain:
> > FSLMC bus detects a multiple type of logical objects representing
> > components of the datapath.
> >
> > Using the type of device, a newly introduced API
> > rte_fslmc_get_device_count can return the count of devices
> > scanned of that device type.
> >
> > Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
> > ---
> > :: This patch is based on *net-next* tree.
> 
> Why is it based on next-net tree?

Because there is a dependency of a lot of patches for DPAA2 which were only on net-next when I sent this patch out. (dependency for lines, not for logic). Else, those would have conflicted when you would have merged net-next into master.

If those have been merged into master, this should be applicable on master as well.
  
Thomas Monjalon Jan. 12, 2018, 2:09 p.m. UTC | #4
12/01/2018 13:59, Shreyansh Jain:
> > -----Original Message-----
> > From: Thomas Monjalon [mailto:thomas@monjalon.net]
> > Sent: Friday, January 12, 2018 5:15 PM
> > To: Shreyansh Jain <shreyansh.jain@nxp.com>
> > Cc: dev@dpdk.org; ferruh.yigit@intel.com
> > Subject: Re: [dpdk-dev] [PATCH] bus/fslmc: add support for scanned device
> > count
> > 
> > 02/01/2018 14:08, Shreyansh Jain:
> > > FSLMC bus detects a multiple type of logical objects representing
> > > components of the datapath.
> > >
> > > Using the type of device, a newly introduced API
> > > rte_fslmc_get_device_count can return the count of devices
> > > scanned of that device type.
> > >
> > > Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
> > > ---
> > > :: This patch is based on *net-next* tree.
> > 
> > Why is it based on next-net tree?
> 
> Because there is a dependency of a lot of patches for DPAA2 which were only on net-next when I sent this patch out. (dependency for lines, not for logic). Else, those would have conflicted when you would have merged net-next into master.
> 
> If those have been merged into master, this should be applicable on master as well.

I have delegated the patch to Ferruh.
Thanks
  
Ferruh Yigit Jan. 12, 2018, 6:01 p.m. UTC | #5
On 1/2/2018 1:08 PM, Shreyansh Jain wrote:
> FSLMC bus detects a multiple type of logical objects representing
> components of the datapath.
> 
> Using the type of device, a newly introduced API
> rte_fslmc_get_device_count can return the count of devices
> scanned of that device type.
> 
> Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 63c333a59..39478f7f3 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -53,6 +53,14 @@ 
 struct rte_fslmc_bus rte_fslmc_bus;
 uint8_t dpaa2_virt_mode;
 
+uint32_t
+rte_fslmc_get_device_count(enum rte_dpaa2_dev_type device_type)
+{
+	if (device_type > DPAA2_DEVTYPE_MAX)
+		return 0;
+	return rte_fslmc_bus.device_count[device_type];
+}
+
 static void
 cleanup_fslmc_device_list(void)
 {
@@ -164,6 +172,9 @@  scan_one_fslmc_device(char *dev_name)
 	else
 		dev->dev_type = DPAA2_UNKNOWN;
 
+	/* Update the device found into the device_count table */
+	rte_fslmc_bus.device_count[dev->dev_type]++;
+
 	t_ptr = strtok(NULL, ".");
 	if (!t_ptr) {
 		FSLMC_BUS_LOG(ERR, "Incorrect device string observed (%s).",
@@ -408,6 +419,7 @@  struct rte_fslmc_bus rte_fslmc_bus = {
 	},
 	.device_list = TAILQ_HEAD_INITIALIZER(rte_fslmc_bus.device_list),
 	.driver_list = TAILQ_HEAD_INITIALIZER(rte_fslmc_bus.driver_list),
+	.device_count = {0},
 };
 
 RTE_REGISTER_BUS(fslmc, rte_fslmc_bus.bus);
diff --git a/drivers/bus/fslmc/rte_bus_fslmc_version.map b/drivers/bus/fslmc/rte_bus_fslmc_version.map
index f59fc671f..16b759d8b 100644
--- a/drivers/bus/fslmc/rte_bus_fslmc_version.map
+++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map
@@ -97,5 +97,6 @@  DPDK_18.02 {
 	dpaa2_virt_mode;
 	qbman_fq_query_state;
 	qbman_fq_state_frame_count;
+	rte_fslmc_get_device_count;
 
 } DPDK_17.11;
diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h
index fd52e2b84..e6314b5cb 100644
--- a/drivers/bus/fslmc/rte_fslmc.h
+++ b/drivers/bus/fslmc/rte_fslmc.h
@@ -88,7 +88,8 @@  enum rte_dpaa2_dev_type {
 	DPAA2_CI,	/**< DPCI type device */
 	DPAA2_MPORTAL,  /**< DPMCP type device */
 	/* Unknown device placeholder */
-	DPAA2_UNKNOWN
+	DPAA2_UNKNOWN,
+	DPAA2_DEVTYPE_MAX,
 };
 
 TAILQ_HEAD(rte_dpaa2_object_list, rte_dpaa2_object);
@@ -150,8 +151,8 @@  struct rte_fslmc_bus {
 				/**< FSLMC DPAA2 Device list */
 	struct rte_fslmc_driver_list driver_list;
 				/**< FSLMC DPAA2 Driver list */
-	int device_count;
-				/**< Optional: Count of devices on bus */
+	int device_count[DPAA2_DEVTYPE_MAX];
+				/**< Count of all devices scanned */
 };
 
 /**
@@ -191,6 +192,17 @@  RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
  */
 void rte_fslmc_object_register(struct rte_dpaa2_object *object);
 
+/**
+ * Count of a particular type of DPAA2 device scanned on the bus.
+ *
+ * @param dev_type
+ *   Type of device as rte_dpaa2_dev_type enumerator
+ * @return
+ *   >=0 for count; 0 indicates either no device of the said type scanned or
+ *   invalid device type.
+ */
+uint32_t rte_fslmc_get_device_count(enum rte_dpaa2_dev_type device_type);
+
 /** Helper for DPAA2 object registration */
 #define RTE_PMD_REGISTER_DPAA2_OBJECT(nm, dpaa2_obj) \
 RTE_INIT(dpaa2objinitfn_ ##nm); \