Skip to contentSkip to conversation

dmadev: hide devices array

PATCH In review David Marchand 6 participants 19 messages Oct 20, 2021 – Oct 26, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dmadev: hide devices array

No need to expose rte_dma_devices out of the dmadev library. Existing helpers should be enough, and inlines make use of rte_dma_fp_objs.

---
 app/test/test_dmadev.c      | 5 +++--
 lib/dmadev/rte_dmadev.c     | 2 +-
 lib/dmadev/rte_dmadev_pmd.h | 2 --
 lib/dmadev/version.map      | 1 -
 4 files changed, 4 insertions(+), 6 deletions(-)
app/test/test_dmadev.c +3 -2
index 1e327bd45f..8b58256afc 100644
@@ -747,10 +747,11 @@ test_dmadev_instance(int16_t dev_id)
 	};
 	const int vchan = 0;
 
+	rte_dma_info_get(dev_id, &info);
+
 	printf("\n### Test dmadev instance %u [%s]\n",
-			dev_id, rte_dma_devices[dev_id].data->dev_name);
+			dev_id, info.dev_name);
 
-	rte_dma_info_get(dev_id, &info);
 	if (info.max_vchans < 1)
 		ERR_RETURN("Error, no channels available on device id %u\n", dev_id);
 
lib/dmadev/rte_dmadev.c +1 -1
index 182d32aedb..d4b32b2971 100644
@@ -18,7 +18,7 @@
 static int16_t dma_devices_max;
 
 struct rte_dma_fp_object *rte_dma_fp_objs;
-struct rte_dma_dev *rte_dma_devices;
+static struct rte_dma_dev *rte_dma_devices;
 static struct {
 	/* Hold the dev_max information of the primary process. This field is
 	 * set by the primary process and is read by the secondary process.
lib/dmadev/rte_dmadev_pmd.h +0 -2
index b97b5bf10b..5316ad5b5f 100644
@@ -131,8 +131,6 @@ struct rte_dma_dev {
 	uint64_t reserved[2]; /**< Reserved for future fields. */
 } __rte_cache_aligned;
 
-extern struct rte_dma_dev *rte_dma_devices;
-
 /**
  * @internal
  * Allocate a new dmadev slot for an DMA device and return the pointer to that
lib/dmadev/version.map +0 -1
index ef561acd46..89f7a5b1d3 100644
@@ -30,7 +30,6 @@ EXPERIMENTAL {
 INTERNAL {
 	global:
 
-	rte_dma_devices;
 	rte_dma_fp_objs;
 	rte_dma_pmd_allocate;
 	rte_dma_pmd_release;
Signature · 1 line
2.23.0
#1 lore raw

PATCH 2/2 dmadev: remove symbol versioning for inline helpers

Inline helpers have no global symbols in shared libraries. There is no reason to ask for versioning (plus this library would not build on Windows).

Fixes 91e581e5c924 ("dmadev: add data plane API")
Fixes ea8cf0f8536d ("dmadev: add burst capacity API")
---
 lib/dmadev/version.map | 7 -------
 1 file changed, 7 deletions(-)
lib/dmadev/version.map +0 -7
index 89f7a5b1d3..7031d6b335 100644
@@ -1,17 +1,11 @@
 EXPERIMENTAL {
 	global:
 
-	rte_dma_burst_capacity;
 	rte_dma_close;
-	rte_dma_completed;
-	rte_dma_completed_status;
 	rte_dma_configure;
-	rte_dma_copy;
-	rte_dma_copy_sg;
 	rte_dma_count_avail;
 	rte_dma_dev_max;
 	rte_dma_dump;
-	rte_dma_fill;
 	rte_dma_get_dev_id_by_name;
 	rte_dma_info_get;
 	rte_dma_is_valid;
@@ -20,7 +14,6 @@ EXPERIMENTAL {
 	rte_dma_stats_get;
 	rte_dma_stats_reset;
 	rte_dma_stop;
-	rte_dma_submit;
 	rte_dma_vchan_setup;
 	rte_dma_vchan_status;
 
Signature · 1 line
2.23.0
Acked-by on v1 2/2
#2 lore raw

Re: [dpdk-dev] [PATCH 2/2] dmadev: remove symbol versioning for inline helpers

Quoted 8 lines · David Marchand

Inline helpers have no global symbols in shared libraries. There is no reason to ask for versioning (plus this library would not build on Windows).

Fixes 91e581e5c924 ("dmadev: add data plane API")
Fixes ea8cf0f8536d ("dmadev: add burst capacity API")
Reviewed-by on v1 1/2
#3 lore raw
In reply to David Marchand
Quoted 17 lines · David Marchand

No need to expose rte_dma_devices out of the dmadev library. Existing helpers should be enough, and inlines make use of rte_dma_fp_objs.

---
 app/test/test_dmadev.c      | 5 +++--
 lib/dmadev/rte_dmadev.c     | 2 +-
 lib/dmadev/rte_dmadev_pmd.h | 2 --
 lib/dmadev/version.map      | 1 -
 4 files changed, 4 insertions(+), 6 deletions(-)
app/test/test_dmadev.c +0 -0
index 1e327bd45f..8b58256afc 100644

app/test/test_dmadev.c test_dmadev_instance(int16_t dev_id) · line 750

Quoted 4 lines
app/test/test_dmadev.c +1 -0
@@ -747,10 +747,11 @@ test_dmadev_instance(int16_t dev_id)
 	};
 	const int vchan = 0;
 
+	rte_dma_info_get(dev_id, &info);

suggest declare info as: struct rte_dma_stats info = { 0 }; so that the following %s will display NULL if rte_dma_info_get call fail.

anyway,

Quoted 11 lines
app/test/test_dmadev.c +2 -2
+
 	printf("\n### Test dmadev instance %u [%s]\n",
-			dev_id, rte_dma_devices[dev_id].data->dev_name);
+			dev_id, info.dev_name);
 
-	rte_dma_info_get(dev_id, &info);
 	if (info.max_vchans < 1)
 		ERR_RETURN("Error, no channels available on device id %u\n", dev_id);
 
lib/dmadev/rte_dmadev.c +0 -0
index 182d32aedb..d4b32b2971 100644

[snip]

#4 lore raw
Quoted 22 lines · fengchengwen
Quoted 20 lines · David Marchand

No need to expose rte_dma_devices out of the dmadev library. Existing helpers should be enough, and inlines make use of rte_dma_fp_objs.

---
 app/test/test_dmadev.c      | 5 +++--
 lib/dmadev/rte_dmadev.c     | 2 +-
 lib/dmadev/rte_dmadev_pmd.h | 2 --
 lib/dmadev/version.map      | 1 -
 4 files changed, 4 insertions(+), 6 deletions(-)
app/test/test_dmadev.c +0 -0
index 1e327bd45f..8b58256afc 100644
@@ -747,10 +747,11 @@ test_dmadev_instance(int16_t dev_id)
      };
      const int vchan = 0;
 
Quoted 4 lines

app/test/test_dmadev.c test_dmadev_instance(int16_t dev_id) · line 750

Quoted 1 line
app/test/test_dmadev.c +1 -0
+     rte_dma_info_get(dev_id, &info);

suggest declare info as: struct rte_dma_stats info = { 0 }; so that the following %s will display NULL if rte_dma_info_get call fail.

The problem is more generic.
Other info fields are used by the test.
If rte_dma_info_get can fail, its return code must be checked.

Worth a followup patch, can you send it?

Thanks.

Signature · 1 line
David Marchand
#6 lore raw

PATCH v2 1/3 dmadev: hide devices array

In reply to David Marchand

From: David Marchand <[email protected]>

No need to expose rte_dma_devices out of the dmadev library. Existing helpers should be enough, and inlines make use of rte_dma_fp_objs.

---
 app/test/test_dmadev.c      | 5 +++--
 lib/dmadev/rte_dmadev.c     | 2 +-
 lib/dmadev/rte_dmadev_pmd.h | 2 --
 lib/dmadev/version.map      | 1 -
 4 files changed, 4 insertions(+), 6 deletions(-)
app/test/test_dmadev.c +3 -2
index 1e327bd45f..8b58256afc 100644
@@ -747,10 +747,11 @@ test_dmadev_instance(int16_t dev_id)
 	};
 	const int vchan = 0;
 
+	rte_dma_info_get(dev_id, &info);
+
 	printf("\n### Test dmadev instance %u [%s]\n",
-			dev_id, rte_dma_devices[dev_id].data->dev_name);
+			dev_id, info.dev_name);
 
-	rte_dma_info_get(dev_id, &info);
 	if (info.max_vchans < 1)
 		ERR_RETURN("Error, no channels available on device id %u\n", dev_id);
 
lib/dmadev/rte_dmadev.c +1 -1
index 182d32aedb..d4b32b2971 100644
@@ -18,7 +18,7 @@
 static int16_t dma_devices_max;
 
 struct rte_dma_fp_object *rte_dma_fp_objs;
-struct rte_dma_dev *rte_dma_devices;
+static struct rte_dma_dev *rte_dma_devices;
 static struct {
 	/* Hold the dev_max information of the primary process. This field is
 	 * set by the primary process and is read by the secondary process.
lib/dmadev/rte_dmadev_pmd.h +0 -2
index b97b5bf10b..5316ad5b5f 100644
@@ -131,8 +131,6 @@ struct rte_dma_dev {
 	uint64_t reserved[2]; /**< Reserved for future fields. */
 } __rte_cache_aligned;
 
-extern struct rte_dma_dev *rte_dma_devices;
-
 /**
  * @internal
  * Allocate a new dmadev slot for an DMA device and return the pointer to that
lib/dmadev/version.map +0 -1
index ef561acd46..89f7a5b1d3 100644
@@ -30,7 +30,6 @@ EXPERIMENTAL {
 INTERNAL {
 	global:
 
-	rte_dma_devices;
 	rte_dma_fp_objs;
 	rte_dma_pmd_allocate;
 	rte_dma_pmd_release;
Signature · 1 line
2.33.0
#7 lore raw

PATCH v2 2/3 app/test: add check for DMA info get API

This patch add check for rte_dma_info_get() API.

---
 app/test/test_dmadev.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
app/test/test_dmadev.c +6 -3
index 8b58256afc..d6d5dfc803 100644
@@ -746,8 +746,11 @@ test_dmadev_instance(int16_t dev_id)
 			.nb_desc = TEST_RINGSIZE,
 	};
 	const int vchan = 0;
+	int ret;
 
-	rte_dma_info_get(dev_id, &info);
+	ret = rte_dma_info_get(dev_id, &info);
+	if (ret)
+		ERR_RETURN("Error with rte_dma_info_get()\n");
 
 	printf("\n### Test dmadev instance %u [%s]\n",
 			dev_id, info.dev_name);
@@ -761,8 +764,8 @@ test_dmadev_instance(int16_t dev_id)
 	if (rte_dma_vchan_setup(dev_id, vchan, &qconf) < 0)
 		ERR_RETURN("Error with queue configuration\n");
 
-	rte_dma_info_get(dev_id, &info);
-	if (info.nb_vchans != 1)
+	ret = rte_dma_info_get(dev_id, &info);
+	if (ret || info.nb_vchans != 1)
 		ERR_RETURN("Error, no configured queues reported on device id %u\n", dev_id);
 
 	if (rte_dma_start(dev_id) != 0)
Signature · 1 line
2.33.0
author Reviewed-by on v2 2/3
#8 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] app/test: add check for DMA info get API

Quoted 2 lines · Chengwen Feng

This patch add check for rte_dma_info_get() API.

Fixes 718f7804841f ("test/dma: add basic dmadev instance tests")
Quoted 2 lines

Thanks for following up.

Quoted 9 lines
---
 app/test/test_dmadev.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
app/test/test_dmadev.c +0 -0
index 8b58256afc..d6d5dfc803 100644

app/test/test_dmadev.c test_dmadev_instance(int16_t dev_id) · line 752

Quoted 8 lines
app/test/test_dmadev.c +3 -1
@@ -746,8 +746,11 @@ test_dmadev_instance(int16_t dev_id)
                        .nb_desc = TEST_RINGSIZE,
        };
        const int vchan = 0;
+       int ret;
 
-       rte_dma_info_get(dev_id, &info);
+       ret = rte_dma_info_get(dev_id, &info);
+       if (ret)

Nit: ret != 0

app/test/test_dmadev.c test_dmadev_instance(int16_t dev_id) · line 768

Quoted 12 lines
app/test/test_dmadev.c +3 -2
+               ERR_RETURN("Error with rte_dma_info_get()\n");
 
        printf("\n### Test dmadev instance %u [%s]\n",
                        dev_id, info.dev_name);
@@ -761,8 +764,8 @@ test_dmadev_instance(int16_t dev_id)
        if (rte_dma_vchan_setup(dev_id, vchan, &qconf) < 0)
                ERR_RETURN("Error with queue configuration\n");
 
-       rte_dma_info_get(dev_id, &info);
-       if (info.nb_vchans != 1)
+       ret = rte_dma_info_get(dev_id, &info);
+       if (ret || info.nb_vchans != 1)

Nit: ret != 0

Quoted 6 lines
app/test/test_dmadev.c +0 -1
                ERR_RETURN("Error, no configured queues reported on device id %u\n", dev_id);
 
        if (rte_dma_start(dev_id) != 0)
--

2.33.0

Signature · 1 line
David Marchand
Acked-by
#10 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] app/test: add check for DMA info get API

Quoted 7 lines

From: Laatz, Kevin <[email protected]>
Sent: Thursday 21 October 2021 15:04
To: Chengwen Feng <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Walsh, Conor <[email protected]>; Richardson, Bruce <[email protected]>
Subject: Re: [PATCH v2 2/3] app/test: add check for DMA info get API

Quoted 7 lines
Quoted 6 lines · Chengwen Feng

This patch add check for rte_dma_info_get() API.

---
  app/test/test_dmadev.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
#11 lore raw

PATCH v2 3/3 dmadev: fix compile error in debug mode

In reply to Chengwen Feng

This patch fix compile error when enable RTE_DMADEV_DEBUG.

Fixes ea8cf0f8536d ("dmadev: add burst capacity API")
---
 lib/dmadev/rte_dmadev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dmadev/rte_dmadev.h +1 -1
index f5d23017b1..9942c6ec21 100644
@@ -1126,7 +1126,7 @@ rte_dma_burst_capacity(int16_t dev_id, uint16_t vchan)
 #ifdef RTE_DMADEV_DEBUG
 	if (!rte_dma_is_valid(dev_id))
 		return 0;
-	RTE_FUNC_PTR_OR_ERR_RET(*obbj->burst_capacity, 0);
+	RTE_FUNC_PTR_OR_ERR_RET(*obj->burst_capacity, 0);
 #endif
 	return (*obj->burst_capacity)(obj->dev_private, vchan);
 }
Signature · 1 line
2.33.0
Acked-by
#14 lore raw

Re: [dpdk-dev] [PATCH v2 3/3] dmadev: fix compile error in debug mode

Quoted 7 lines

From: Laatz, Kevin <[email protected]>
Sent: Thursday 21 October 2021 15:04
To: Chengwen Feng <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Walsh, Conor <[email protected]>; Richardson, Bruce <[email protected]>
Subject: Re: [PATCH v2 3/3] dmadev: fix compile error in debug mode

Quoted 7 lines
Quoted 6 lines · Chengwen Feng

This patch fix compile error when enable RTE_DMADEV_DEBUG.

Fixes ea8cf0f8536d ("dmadev: add burst capacity API")

---

Acked-by on v2 1/3
#16 lore raw
In reply to Chengwen Feng
Quoted 9 lines · Chengwen Feng

From: David Marchand <[email protected]>

No need to expose rte_dma_devices out of the dmadev library. Existing helpers should be enough, and inlines make use of rte_dma_fp_objs.

Quoted 7 lines
---
  app/test/test_dmadev.c      | 5 +++--
  lib/dmadev/rte_dmadev.c     | 2 +-
  lib/dmadev/rte_dmadev_pmd.h | 2 --
  lib/dmadev/version.map      | 1 -
  4 files changed, 4 insertions(+), 6 deletions(-)
#17 lore raw
Quoted 7 lines · Kevin Laatz
Quoted 5 lines · Chengwen Feng

From: David Marchand <[email protected]>

No need to expose rte_dma_devices out of the dmadev library. Existing helpers should be enough, and inlines make use of rte_dma_fp_objs.

I asked this earlier and was asked to use rte_dma_devices[] array by Kevin. Now that it has been made static is there a different way to get the fp_obj->private_data from a PMD .remove function ?
I need the private data for DMA queue state cleanup.

Quoted 13 lines
Quoted 11 lines
---
  app/test/test_dmadev.c      | 5 +++--
  lib/dmadev/rte_dmadev.c     | 2 +-
  lib/dmadev/rte_dmadev_pmd.h | 2 --
  lib/dmadev/version.map      | 1 -
  4 files changed, 4 insertions(+), 6 deletions(-)
#18 lore raw
Quoted 5 lines · Radha Mohan
Quoted 4 lines · Kevin Laatz
Quoted 2 lines · Chengwen Feng

From: David Marchand <[email protected]>

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

No need to expose rte_dma_devices out of the dmadev library. Existing helpers should be enough, and inlines make use of rte_dma_fp_objs.

I asked this earlier and was asked to use rte_dma_devices[] array by Kevin. Now that it has been made static is there a different way to get the fp_obj->private_data from a PMD .remove function ?
I need the private data for DMA queue state cleanup.

PMD .remove function just call rte_dma_pmd_release() and it's will invoke PMD .dev_close ops:
rte_dma_pmd_release()

    --> rte_dma_close()
      --> PMD .dev_close ops

PMD could implemente cleanup in dev_close ops.

If the PMD want support multi-process, just make sure only the primary could do really cleanup in the dev_close ops.

Quoted 17 lines
Quoted 13 lines
Quoted 5 lines
Quoted 7 lines
---
  app/test/test_dmadev.c      | 5 +++--
  lib/dmadev/rte_dmadev.c     | 2 +-
  lib/dmadev/rte_dmadev_pmd.h | 2 --
  lib/dmadev/version.map      | 1 -
  4 files changed, 4 insertions(+), 6 deletions(-)
Quoted 1 line

.