DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] dma/idxd: add allow/block list support
@ 2021-11-30  9:54 Radu Nicolau
  2021-11-30 10:29 ` Bruce Richardson
  2021-12-02 12:50 ` [PATCH v2] " Radu Nicolau
  0 siblings, 2 replies; 5+ messages in thread
From: Radu Nicolau @ 2021-11-30  9:54 UTC (permalink / raw)
  To: Bruce Richardson, Kevin Laatz; +Cc: dev, Radu Nicolau

Add support for allow or block list for devices bound
to the kernel driver.
When used the allow or block list applies as an additional
condition to the name prefix.

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 doc/guides/dmadevs/idxd.rst | 10 ++++++++++
 drivers/dma/idxd/idxd_bus.c | 30 ++++++++++++++++++++++++++----
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/doc/guides/dmadevs/idxd.rst b/doc/guides/dmadevs/idxd.rst
index d4a210b854..6201d4db1d 100644
--- a/doc/guides/dmadevs/idxd.rst
+++ b/doc/guides/dmadevs/idxd.rst
@@ -117,6 +117,16 @@ the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueu
 name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only
 use a subset of configured queues.
 
+Additionally, the -a (allowlist) or -b (blocklist) commandline parameters are
+also available to further restrict the device list that will be used.
+If the -a option is used then any device that passes the ``dpdk_`` or
+``--file-prefix`` prefix condition must also be present in the allow list.
+Similarly, when the block list is used any device that passes the prefix
+condition must not be in the block list.
+For example, to only use ``wq0.3``, assuming the name prefix condition is met::
+
+	$ dpdk-test -a wq0.3
+
 Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``,
 that is a "DMA device type" inside DPDK, and can be accessed using APIs from the
 ``rte_dmadev`` library.
diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c
index 08639e9dce..13cb967f6d 100644
--- a/drivers/dma/idxd/idxd_bus.c
+++ b/drivers/dma/idxd/idxd_bus.c
@@ -9,6 +9,7 @@
 #include <libgen.h>
 
 #include <rte_bus.h>
+#include <rte_devargs.h>
 #include <rte_eal.h>
 #include <rte_log.h>
 #include <rte_dmadev_pmd.h>
@@ -244,8 +245,18 @@ idxd_probe_dsa(struct rte_dsa_device *dev)
 	return 0;
 }
 
+static int search_devargs(const char *name)
+{
+	struct rte_devargs *devargs;
+	RTE_EAL_DEVARGS_FOREACH(dsa_bus.bus.name, devargs) {
+		if (strcmp(devargs->name, name) == 0)
+			return 1;
+	}
+	return 0;
+}
+
 static int
-is_for_this_process_use(const char *name)
+is_for_this_process_use(struct rte_dsa_device *dev, const char *name)
 {
 	char *runtime_dir = strdup(rte_eal_get_runtime_dir());
 	char *prefix = basename(runtime_dir);
@@ -257,6 +268,13 @@ is_for_this_process_use(const char *name)
 	if (strncmp(name, prefix, prefixlen) == 0 && name[prefixlen] == '_')
 		retval = 1;
 
+	if (retval && dsa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_UNDEFINED) {
+		if (dsa_bus.bus.conf.scan_mode == RTE_BUS_SCAN_ALLOWLIST)
+			retval = search_devargs(dev->device.name);
+		else
+			retval = !search_devargs(dev->device.name);
+	}
+
 	free(runtime_dir);
 	return retval;
 }
@@ -273,7 +291,8 @@ dsa_probe(void)
 				read_wq_string(dev, "name", name, sizeof(name)) < 0)
 			continue;
 
-		if (strncmp(type, "user", 4) == 0 && is_for_this_process_use(name)) {
+		if (strncmp(type, "user", 4) == 0 &&
+				is_for_this_process_use(dev, name)) {
 			dev->device.driver = &dsa_bus.driver;
 			idxd_probe_dsa(dev);
 			continue;
@@ -370,8 +389,11 @@ dsa_addr_parse(const char *name, void *addr)
 		return -1;
 	}
 
-	wq->device_id = device_id;
-	wq->wq_id = wq_id;
+	if (wq != NULL) {
+		wq->device_id = device_id;
+		wq->wq_id = wq_id;
+	}
+
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dma/idxd: add allow/block list support
  2021-11-30  9:54 [PATCH] dma/idxd: add allow/block list support Radu Nicolau
@ 2021-11-30 10:29 ` Bruce Richardson
  2021-12-02 12:50 ` [PATCH v2] " Radu Nicolau
  1 sibling, 0 replies; 5+ messages in thread
From: Bruce Richardson @ 2021-11-30 10:29 UTC (permalink / raw)
  To: Radu Nicolau; +Cc: Kevin Laatz, dev

On Tue, Nov 30, 2021 at 09:54:39AM +0000, Radu Nicolau wrote:
> Add support for allow or block list for devices bound
> to the kernel driver.
> When used the allow or block list applies as an additional
> condition to the name prefix.
> 
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Minor comments inline below.
> ---
>  doc/guides/dmadevs/idxd.rst | 10 ++++++++++
>  drivers/dma/idxd/idxd_bus.c | 30 ++++++++++++++++++++++++++----
>  2 files changed, 36 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/guides/dmadevs/idxd.rst b/doc/guides/dmadevs/idxd.rst
> index d4a210b854..6201d4db1d 100644
> --- a/doc/guides/dmadevs/idxd.rst
> +++ b/doc/guides/dmadevs/idxd.rst
> @@ -117,6 +117,16 @@ the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueu
>  name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only
>  use a subset of configured queues.
>  
> +Additionally, the -a (allowlist) or -b (blocklist) commandline parameters are
> +also available to further restrict the device list that will be used.
> +If the -a option is used then any device that passes the ``dpdk_`` or
Should probably have a comma after "used", and then you can split the line
at that point, having the rest of the sentence on one line. I believe
longer lines are allowed for docs so long as we split them at punctuation
points.

> +``--file-prefix`` prefix condition must also be present in the allow list.
> +Similarly, when the block list is used any device that passes the prefix
> +condition must not be in the block list.
Similarly for this sentence, can put comma and break after "used".

> +For example, to only use ``wq0.3``, assuming the name prefix condition is met::
> +
> +	$ dpdk-test -a wq0.3
> +
>  Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``,
>  that is a "DMA device type" inside DPDK, and can be accessed using APIs from the
>  ``rte_dmadev`` library.
<snip>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] dma/idxd: add allow/block list support
  2021-11-30  9:54 [PATCH] dma/idxd: add allow/block list support Radu Nicolau
  2021-11-30 10:29 ` Bruce Richardson
@ 2021-12-02 12:50 ` Radu Nicolau
  2021-12-02 12:56   ` Kevin Laatz
  1 sibling, 1 reply; 5+ messages in thread
From: Radu Nicolau @ 2021-12-02 12:50 UTC (permalink / raw)
  To: Bruce Richardson, Kevin Laatz; +Cc: dev, Radu Nicolau

Add support for allow or block list for devices bound
to the kernel driver.
When used the allow or block list applies as an additional
condition to the name prefix.

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
v2: corrected doc

 doc/guides/dmadevs/idxd.rst |  8 ++++++++
 drivers/dma/idxd/idxd_bus.c | 30 ++++++++++++++++++++++++++----
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/doc/guides/dmadevs/idxd.rst b/doc/guides/dmadevs/idxd.rst
index d4a210b854..a4681b2c5a 100644
--- a/doc/guides/dmadevs/idxd.rst
+++ b/doc/guides/dmadevs/idxd.rst
@@ -117,6 +117,14 @@ the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueu
 name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only
 use a subset of configured queues.
 
+Additionally, the -a (allowlist) or -b (blocklist) commandline parameters are
+also available to further restrict the device list that will be used. If the -a option is used,
+then any device that passes the ``dpdk_`` or ``--file-prefix`` prefix condition must also be present in the allow list.
+Similarly, when the block list is used, any device that passes the prefix condition must not be in the block list.
+For example, to only use ``wq0.3``, assuming the name prefix condition is met::
+
+	$ dpdk-test -a wq0.3
+
 Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``,
 that is a "DMA device type" inside DPDK, and can be accessed using APIs from the
 ``rte_dmadev`` library.
diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c
index 08639e9dce..13cb967f6d 100644
--- a/drivers/dma/idxd/idxd_bus.c
+++ b/drivers/dma/idxd/idxd_bus.c
@@ -9,6 +9,7 @@
 #include <libgen.h>
 
 #include <rte_bus.h>
+#include <rte_devargs.h>
 #include <rte_eal.h>
 #include <rte_log.h>
 #include <rte_dmadev_pmd.h>
@@ -244,8 +245,18 @@ idxd_probe_dsa(struct rte_dsa_device *dev)
 	return 0;
 }
 
+static int search_devargs(const char *name)
+{
+	struct rte_devargs *devargs;
+	RTE_EAL_DEVARGS_FOREACH(dsa_bus.bus.name, devargs) {
+		if (strcmp(devargs->name, name) == 0)
+			return 1;
+	}
+	return 0;
+}
+
 static int
-is_for_this_process_use(const char *name)
+is_for_this_process_use(struct rte_dsa_device *dev, const char *name)
 {
 	char *runtime_dir = strdup(rte_eal_get_runtime_dir());
 	char *prefix = basename(runtime_dir);
@@ -257,6 +268,13 @@ is_for_this_process_use(const char *name)
 	if (strncmp(name, prefix, prefixlen) == 0 && name[prefixlen] == '_')
 		retval = 1;
 
+	if (retval && dsa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_UNDEFINED) {
+		if (dsa_bus.bus.conf.scan_mode == RTE_BUS_SCAN_ALLOWLIST)
+			retval = search_devargs(dev->device.name);
+		else
+			retval = !search_devargs(dev->device.name);
+	}
+
 	free(runtime_dir);
 	return retval;
 }
@@ -273,7 +291,8 @@ dsa_probe(void)
 				read_wq_string(dev, "name", name, sizeof(name)) < 0)
 			continue;
 
-		if (strncmp(type, "user", 4) == 0 && is_for_this_process_use(name)) {
+		if (strncmp(type, "user", 4) == 0 &&
+				is_for_this_process_use(dev, name)) {
 			dev->device.driver = &dsa_bus.driver;
 			idxd_probe_dsa(dev);
 			continue;
@@ -370,8 +389,11 @@ dsa_addr_parse(const char *name, void *addr)
 		return -1;
 	}
 
-	wq->device_id = device_id;
-	wq->wq_id = wq_id;
+	if (wq != NULL) {
+		wq->device_id = device_id;
+		wq->wq_id = wq_id;
+	}
+
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] dma/idxd: add allow/block list support
  2021-12-02 12:50 ` [PATCH v2] " Radu Nicolau
@ 2021-12-02 12:56   ` Kevin Laatz
  2022-02-13 22:24     ` Thomas Monjalon
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Laatz @ 2021-12-02 12:56 UTC (permalink / raw)
  To: Radu Nicolau, Bruce Richardson; +Cc: dev


On 02/12/2021 12:50, Radu Nicolau wrote:
> Add support for allow or block list for devices bound
> to the kernel driver.
> When used the allow or block list applies as an additional
> condition to the name prefix.
>
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> v2: corrected doc
>
>   doc/guides/dmadevs/idxd.rst |  8 ++++++++
>   drivers/dma/idxd/idxd_bus.c | 30 ++++++++++++++++++++++++++----
>   2 files changed, 34 insertions(+), 4 deletions(-)
>

Acked-by: Kevin Laatz <kevin.laatz@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] dma/idxd: add allow/block list support
  2021-12-02 12:56   ` Kevin Laatz
@ 2022-02-13 22:24     ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2022-02-13 22:24 UTC (permalink / raw)
  To: Radu Nicolau; +Cc: Bruce Richardson, dev, Kevin Laatz

02/12/2021 13:56, Kevin Laatz:
> On 02/12/2021 12:50, Radu Nicolau wrote:
> > Add support for allow or block list for devices bound
> > to the kernel driver.
> > When used the allow or block list applies as an additional
> > condition to the name prefix.
> >
> > Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> > Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Acked-by: Kevin Laatz <kevin.laatz@intel.com>

Applied, thanks.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-13 22:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30  9:54 [PATCH] dma/idxd: add allow/block list support Radu Nicolau
2021-11-30 10:29 ` Bruce Richardson
2021-12-02 12:50 ` [PATCH v2] " Radu Nicolau
2021-12-02 12:56   ` Kevin Laatz
2022-02-13 22:24     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).