DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal: update all buses default scan mode
@ 2021-03-16 12:45 Xueming Li
  2021-03-22 23:32 ` Dmitry Kozlyuk
  2021-03-28 13:12 ` [dpdk-dev] [PATCH v1] " Xueming Li
  0 siblings, 2 replies; 8+ messages in thread
From: Xueming Li @ 2021-03-16 12:45 UTC (permalink / raw)
  Cc: dev, Dmitry Kozlyuk, Narcisa Ana Maria Vasile, Dmitry Malloy,
	Pallavi Kadam, Ray Kinsella, Neil Horman

When parsing EAL allowed or blocked device arguments, only device bus
being parsed got default scan mode updated. If the devargs was vdev, PCI
bus default scan mode not touched, all PCI bus devices will got probed
even none appear in allowed list.

This patch update all buses default scan mode when parsing first
devargs.

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 lib/librte_eal/common/eal_common_bus.c     | 16 ++++++++++++++++
 lib/librte_eal/common/eal_common_devargs.c | 13 +++++--------
 lib/librte_eal/common/eal_private.h        |  9 +++++++++
 lib/librte_eal/rte_eal_exports.def         |  1 +
 lib/librte_eal/version.map                 |  2 ++
 5 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index baa5b532af..ebbb3995f6 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -277,3 +277,19 @@ rte_bus_sigbus_handler(const void *failure_addr)
 
 	return ret;
 }
+
+static bool mode_set;
+
+void
+rte_bus_scan_mode_update(enum rte_bus_scan_mode mode)
+{
+	struct rte_bus *bus;
+
+	if (mode_set)
+		return;
+	TAILQ_FOREACH(bus, &rte_bus_list, next) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED)
+			bus->conf.scan_mode = mode;
+	}
+	mode_set = true;
+}
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index fcf3d9a3cc..3aedcb5c09 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -301,7 +301,6 @@ int
 rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 {
 	struct rte_devargs *devargs = NULL;
-	struct rte_bus *bus = NULL;
 	const char *dev = devargs_str;
 
 	/* use calloc instead of rte_zmalloc as it's called early at init */
@@ -312,15 +311,13 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	if (rte_devargs_parse(devargs, dev))
 		goto fail;
 	devargs->type = devtype;
-	bus = devargs->bus;
 	if (devargs->type == RTE_DEVTYPE_BLOCKED)
 		devargs->policy = RTE_DEV_BLOCKED;
-	if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
-		if (devargs->policy == RTE_DEV_ALLOWED)
-			bus->conf.scan_mode = RTE_BUS_SCAN_ALLOWLIST;
-		else if (devargs->policy == RTE_DEV_BLOCKED)
-			bus->conf.scan_mode = RTE_BUS_SCAN_BLOCKLIST;
-	}
+
+	if (devargs->policy == RTE_DEV_ALLOWED)
+		rte_bus_scan_mode_update(RTE_BUS_SCAN_ALLOWLIST);
+	else if (devargs->policy == RTE_DEV_BLOCKED)
+		rte_bus_scan_mode_update(RTE_BUS_SCAN_BLOCKLIST);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
 	return 0;
 
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index b8a0d20021..78b07508ec 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -452,6 +452,15 @@ int rte_eal_memory_detach(void);
  */
 struct rte_bus *rte_bus_find_by_device_name(const char *str);
 
+/**
+ * Update all buses scan mode if not set, used by EAL parameter parsing.
+ *
+ * @param mode
+ *   Bus scan mode to be set.
+ */
+__rte_internal
+void rte_bus_scan_mode_update(enum rte_bus_scan_mode mode);
+
 /**
  * Create the unix channel for primary/secondary communication.
  *
diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def
index 474cf123fa..2757f31461 100644
--- a/lib/librte_eal/rte_eal_exports.def
+++ b/lib/librte_eal/rte_eal_exports.def
@@ -11,6 +11,7 @@ EXPORTS
 	rte_bus_probe
 	rte_bus_register
 	rte_bus_scan
+	rte_bus_scan_mode_update
 	rte_bus_unregister
 	rte_calloc
 	rte_calloc_socket
diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map
index fce90a112f..171bca478d 100644
--- a/lib/librte_eal/version.map
+++ b/lib/librte_eal/version.map
@@ -417,6 +417,8 @@ EXPERIMENTAL {
 INTERNAL {
 	global:
 
+	rte_bus_scan_mode_update;
+
 	rte_mem_lock;
 	rte_mem_map;
 	rte_mem_page_size;
-- 
2.25.1


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

* Re: [dpdk-dev] [PATCH] eal: update all buses default scan mode
  2021-03-16 12:45 [dpdk-dev] [PATCH] eal: update all buses default scan mode Xueming Li
@ 2021-03-22 23:32 ` Dmitry Kozlyuk
  2021-03-23  9:33   ` Kinsella, Ray
  2021-03-28 13:12 ` [dpdk-dev] [PATCH v1] " Xueming Li
  1 sibling, 1 reply; 8+ messages in thread
From: Dmitry Kozlyuk @ 2021-03-22 23:32 UTC (permalink / raw)
  To: Xueming Li
  Cc: dev, Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam,
	Ray Kinsella, Neil Horman

2021-03-16 20:45 (UTC+0800), Xueming Li:
[...]
> diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
> index baa5b532af..ebbb3995f6 100644
> --- a/lib/librte_eal/common/eal_common_bus.c
> +++ b/lib/librte_eal/common/eal_common_bus.c
> @@ -277,3 +277,19 @@ rte_bus_sigbus_handler(const void *failure_addr)
>  
>  	return ret;
>  }
> +
> +static bool mode_set;

Could be function-local if we really want to save list traversals.

> +
> +void
> +rte_bus_scan_mode_update(enum rte_bus_scan_mode mode)
> +{
> +	struct rte_bus *bus;
> +
> +	if (mode_set)
> +		return;
> +	TAILQ_FOREACH(bus, &rte_bus_list, next) {
> +		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED)
> +			bus->conf.scan_mode = mode;
> +	}
> +	mode_set = true;
> +}

[...]
>  /**
>   * Create the unix channel for primary/secondary communication.
>   *
> diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def
> index 474cf123fa..2757f31461 100644
> --- a/lib/librte_eal/rte_eal_exports.def
> +++ b/lib/librte_eal/rte_eal_exports.def
> @@ -11,6 +11,7 @@ EXPORTS
>  	rte_bus_probe
>  	rte_bus_register
>  	rte_bus_scan
> +	rte_bus_scan_mode_update
>  	rte_bus_unregister
>  	rte_calloc
>  	rte_calloc_socket
> diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map
> index fce90a112f..171bca478d 100644
> --- a/lib/librte_eal/version.map
> +++ b/lib/librte_eal/version.map
> @@ -417,6 +417,8 @@ EXPERIMENTAL {
>  INTERNAL {
>  	global:
>  
> +	rte_bus_scan_mode_update;
> +
>  	rte_mem_lock;
>  	rte_mem_map;
>  	rte_mem_page_size;

New function is private to EAL, so it doesn't need exporting.

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

* Re: [dpdk-dev] [PATCH] eal: update all buses default scan mode
  2021-03-22 23:32 ` Dmitry Kozlyuk
@ 2021-03-23  9:33   ` Kinsella, Ray
  2021-03-23  9:34     ` Kinsella, Ray
  0 siblings, 1 reply; 8+ messages in thread
From: Kinsella, Ray @ 2021-03-23  9:33 UTC (permalink / raw)
  To: Dmitry Kozlyuk, Xueming Li
  Cc: dev, Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam, Neil Horman



On 22/03/2021 23:32, Dmitry Kozlyuk wrote:
> 2021-03-16 20:45 (UTC+0800), Xueming Li:
> [...]
>> diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
>> index baa5b532af..ebbb3995f6 100644
>> --- a/lib/librte_eal/common/eal_common_bus.c
>> +++ b/lib/librte_eal/common/eal_common_bus.c
>> @@ -277,3 +277,19 @@ rte_bus_sigbus_handler(const void *failure_addr)
>>  
>>  	return ret;
>>  }
>> +
>> +static bool mode_set;
> 
> Could be function-local if we really want to save list traversals.
> 
>> +
>> +void
>> +rte_bus_scan_mode_update(enum rte_bus_scan_mode mode)
>> +{
>> +	struct rte_bus *bus;
>> +
>> +	if (mode_set)
>> +		return;
>> +	TAILQ_FOREACH(bus, &rte_bus_list, next) {
>> +		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED)
>> +			bus->conf.scan_mode = mode;
>> +	}
>> +	mode_set = true;
>> +}
> 
> [...]
>>  /**
>>   * Create the unix channel for primary/secondary communication.
>>   *
>> diff --git a/lib/librte_eal/rte_eal_exports.def b/lib/librte_eal/rte_eal_exports.def
>> index 474cf123fa..2757f31461 100644
>> --- a/lib/librte_eal/rte_eal_exports.def
>> +++ b/lib/librte_eal/rte_eal_exports.def
>> @@ -11,6 +11,7 @@ EXPORTS
>>  	rte_bus_probe
>>  	rte_bus_register
>>  	rte_bus_scan
>> +	rte_bus_scan_mode_update
>>  	rte_bus_unregister
>>  	rte_calloc
>>  	rte_calloc_socket
>> diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map
>> index fce90a112f..171bca478d 100644
>> --- a/lib/librte_eal/version.map
>> +++ b/lib/librte_eal/version.map
>> @@ -417,6 +417,8 @@ EXPERIMENTAL {
>>  INTERNAL {
>>  	global:
>>  
>> +	rte_bus_scan_mode_update;
>> +
>>  	rte_mem_lock;
>>  	rte_mem_map;
>>  	rte_mem_page_size;
> 
> New function is private to EAL, so it doesn't need exporting.
> 

Right - it is annotated as INTERNAL.

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

* Re: [dpdk-dev] [PATCH] eal: update all buses default scan mode
  2021-03-23  9:33   ` Kinsella, Ray
@ 2021-03-23  9:34     ` Kinsella, Ray
  2021-03-23  9:57       ` Dmitry Kozlyuk
  0 siblings, 1 reply; 8+ messages in thread
From: Kinsella, Ray @ 2021-03-23  9:34 UTC (permalink / raw)
  To: Dmitry Kozlyuk, Xueming Li
  Cc: dev, Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam, Neil Horman



On 23/03/2021 09:33, Kinsella, Ray wrote:
> 
> 
> On 22/03/2021 23:32, Dmitry Kozlyuk wrote:
>> 2021-03-16 20:45 (UTC+0800), Xueming Li:
>> [...]
[SNIP]
>>>  	rte_mem_page_size;
>>
>> New function is private to EAL, so it doesn't need exporting.
>>
> 
> Right - it is annotated as INTERNAL.
> 

Sorry, let me be clearer - it is being correctly annotated unless I have missed something.

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

* Re: [dpdk-dev] [PATCH] eal: update all buses default scan mode
  2021-03-23  9:34     ` Kinsella, Ray
@ 2021-03-23  9:57       ` Dmitry Kozlyuk
  2021-03-23  9:58         ` Kinsella, Ray
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Kozlyuk @ 2021-03-23  9:57 UTC (permalink / raw)
  To: Kinsella, Ray
  Cc: Xueming Li, dev, Narcisa Ana Maria Vasile, Dmitry Malloy,
	Pallavi Kadam, Neil Horman

2021-03-23 09:34 (UTC+0000), Kinsella, Ray:
> On 23/03/2021 09:33, Kinsella, Ray wrote:
> > 
> > 
> > On 22/03/2021 23:32, Dmitry Kozlyuk wrote:  
> >> 2021-03-16 20:45 (UTC+0800), Xueming Li:
> >> [...]  
> [SNIP]
> >>>  	rte_mem_page_size;  
> >>
> >> New function is private to EAL, so it doesn't need exporting.
> >>  
> > 
> > Right - it is annotated as INTERNAL.
> >   
> 
> Sorry, let me be clearer - it is being correctly annotated unless I have missed something.

This function is purely internal to librte_eal. It doesn't need to be added
to .map or .def. It also doesn't need __rte_internal, like other functions in
eal_private.h don't need it either.

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

* Re: [dpdk-dev] [PATCH] eal: update all buses default scan mode
  2021-03-23  9:57       ` Dmitry Kozlyuk
@ 2021-03-23  9:58         ` Kinsella, Ray
  2021-03-28 13:14           ` Xueming(Steven) Li
  0 siblings, 1 reply; 8+ messages in thread
From: Kinsella, Ray @ 2021-03-23  9:58 UTC (permalink / raw)
  To: Dmitry Kozlyuk
  Cc: Xueming Li, dev, Narcisa Ana Maria Vasile, Dmitry Malloy,
	Pallavi Kadam, Neil Horman



On 23/03/2021 09:57, Dmitry Kozlyuk wrote:
> 2021-03-23 09:34 (UTC+0000), Kinsella, Ray:
>> On 23/03/2021 09:33, Kinsella, Ray wrote:
>>>
>>>
>>> On 22/03/2021 23:32, Dmitry Kozlyuk wrote:  
>>>> 2021-03-16 20:45 (UTC+0800), Xueming Li:
>>>> [...]  
>> [SNIP]
>>>>>  	rte_mem_page_size;  
>>>>
>>>> New function is private to EAL, so it doesn't need exporting.
>>>>  
>>>
>>> Right - it is annotated as INTERNAL.
>>>   
>>
>> Sorry, let me be clearer - it is being correctly annotated unless I have missed something.
> 
> This function is purely internal to librte_eal. It doesn't need to be added
> to .map or .def. It also doesn't need __rte_internal, like other functions in
> eal_private.h don't need it either.
> 

ok - I get you now - agreed.

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

* [dpdk-dev] [PATCH v1] eal: update all buses default scan mode
  2021-03-16 12:45 [dpdk-dev] [PATCH] eal: update all buses default scan mode Xueming Li
  2021-03-22 23:32 ` Dmitry Kozlyuk
@ 2021-03-28 13:12 ` Xueming Li
  1 sibling, 0 replies; 8+ messages in thread
From: Xueming Li @ 2021-03-28 13:12 UTC (permalink / raw)
  Cc: dev, Dmitry Kozlyuk, Kinsella Ray

When parsing EAL allowed or blocked device arguments, only device bus
being parsed got default scan mode updated. If the devargs was vdev, PCI
bus default scan mode not touched, all PCI bus devices will got probed
even none appear in allowed list.

This patch update all buses default scan mode when parsing first
devargs.

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 lib/librte_eal/common/eal_common_bus.c     | 15 +++++++++++++++
 lib/librte_eal/common/eal_common_devargs.c | 13 +++++--------
 lib/librte_eal/common/eal_private.h        |  8 ++++++++
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index baa5b532af..d5818a456e 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -277,3 +277,18 @@ rte_bus_sigbus_handler(const void *failure_addr)
 
 	return ret;
 }
+
+void
+rte_bus_scan_mode_update(enum rte_bus_scan_mode mode)
+{
+	struct rte_bus *bus;
+	static bool mode_set;
+
+	if (mode_set)
+		return;
+	TAILQ_FOREACH(bus, &rte_bus_list, next) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED)
+			bus->conf.scan_mode = mode;
+	}
+	mode_set = true;
+}
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index fcf3d9a3cc..3aedcb5c09 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -301,7 +301,6 @@ int
 rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 {
 	struct rte_devargs *devargs = NULL;
-	struct rte_bus *bus = NULL;
 	const char *dev = devargs_str;
 
 	/* use calloc instead of rte_zmalloc as it's called early at init */
@@ -312,15 +311,13 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	if (rte_devargs_parse(devargs, dev))
 		goto fail;
 	devargs->type = devtype;
-	bus = devargs->bus;
 	if (devargs->type == RTE_DEVTYPE_BLOCKED)
 		devargs->policy = RTE_DEV_BLOCKED;
-	if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
-		if (devargs->policy == RTE_DEV_ALLOWED)
-			bus->conf.scan_mode = RTE_BUS_SCAN_ALLOWLIST;
-		else if (devargs->policy == RTE_DEV_BLOCKED)
-			bus->conf.scan_mode = RTE_BUS_SCAN_BLOCKLIST;
-	}
+
+	if (devargs->policy == RTE_DEV_ALLOWED)
+		rte_bus_scan_mode_update(RTE_BUS_SCAN_ALLOWLIST);
+	else if (devargs->policy == RTE_DEV_BLOCKED)
+		rte_bus_scan_mode_update(RTE_BUS_SCAN_BLOCKLIST);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
 	return 0;
 
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index b8a0d20021..ddd6769849 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -452,6 +452,14 @@ int rte_eal_memory_detach(void);
  */
 struct rte_bus *rte_bus_find_by_device_name(const char *str);
 
+/**
+ * Update all buses scan mode if not set, used by EAL parameter parsing.
+ *
+ * @param mode
+ *   Bus scan mode to be set.
+ */
+void rte_bus_scan_mode_update(enum rte_bus_scan_mode mode);
+
 /**
  * Create the unix channel for primary/secondary communication.
  *
-- 
2.25.1


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

* Re: [dpdk-dev] [PATCH] eal: update all buses default scan mode
  2021-03-23  9:58         ` Kinsella, Ray
@ 2021-03-28 13:14           ` Xueming(Steven) Li
  0 siblings, 0 replies; 8+ messages in thread
From: Xueming(Steven) Li @ 2021-03-28 13:14 UTC (permalink / raw)
  To: Kinsella, Ray, Dmitry Kozlyuk
  Cc: dev, Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam, Neil Horman

Thanks for comments, new version sent:
http://patchwork.dpdk.org/project/dpdk/patch/20210328131222.16584-1-xuemingl@nvidia.com/

>-----Original Message-----
>From: Kinsella, Ray <mdr@ashroe.eu>
>Sent: Tuesday, March 23, 2021 5:59 PM
>To: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
>Cc: Xueming(Steven) Li <xuemingl@nvidia.com>; dev@dpdk.org; Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>; Dmitry
>Malloy <dmitrym@microsoft.com>; Pallavi Kadam <pallavi.kadam@intel.com>; Neil Horman <nhorman@tuxdriver.com>
>Subject: Re: [PATCH] eal: update all buses default scan mode
>
>
>
>On 23/03/2021 09:57, Dmitry Kozlyuk wrote:
>> 2021-03-23 09:34 (UTC+0000), Kinsella, Ray:
>>> On 23/03/2021 09:33, Kinsella, Ray wrote:
>>>>
>>>>
>>>> On 22/03/2021 23:32, Dmitry Kozlyuk wrote:
>>>>> 2021-03-16 20:45 (UTC+0800), Xueming Li:
>>>>> [...]
>>> [SNIP]
>>>>>>  	rte_mem_page_size;
>>>>>
>>>>> New function is private to EAL, so it doesn't need exporting.
>>>>>
>>>>
>>>> Right - it is annotated as INTERNAL.
>>>>
>>>
>>> Sorry, let me be clearer - it is being correctly annotated unless I have missed something.
>>
>> This function is purely internal to librte_eal. It doesn't need to be
>> added to .map or .def. It also doesn't need __rte_internal, like other
>> functions in eal_private.h don't need it either.
>>
>
>ok - I get you now - agreed.

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

end of thread, other threads:[~2021-03-28 13:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 12:45 [dpdk-dev] [PATCH] eal: update all buses default scan mode Xueming Li
2021-03-22 23:32 ` Dmitry Kozlyuk
2021-03-23  9:33   ` Kinsella, Ray
2021-03-23  9:34     ` Kinsella, Ray
2021-03-23  9:57       ` Dmitry Kozlyuk
2021-03-23  9:58         ` Kinsella, Ray
2021-03-28 13:14           ` Xueming(Steven) Li
2021-03-28 13:12 ` [dpdk-dev] [PATCH v1] " Xueming Li

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git