[v2] bus/vmbus: add device_order field to rte_vmbus_dev

Message ID 20240624111521.3253-1-vratnikov@netgate.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series [v2] bus/vmbus: add device_order field to rte_vmbus_dev |

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-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Vladimir Ratnikov June 24, 2024, 11:15 a.m. UTC
Field can be used to have static interface naming
in DPDK based applications instead of uuid.
RTE_FOREACH_DEV won't return the correct order of
such devices due to vmbus_ignore_device in case of
blocklisting/allowlisting. So device_order field
will be helpful in that case.

Signed-off-by: Vladimir Ratnikov <vratnikov@netgate.com>
---
 drivers/bus/vmbus/bus_vmbus_driver.h | 1 +
 drivers/bus/vmbus/vmbus_common.c     | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger June 24, 2024, 3:15 p.m. UTC | #1
On Mon, 24 Jun 2024 11:15:21 +0000
Vladimir Ratnikov <vratnikov@netgate.com> wrote:

> Field can be used to have static interface naming
> in DPDK based applications instead of uuid.
> RTE_FOREACH_DEV won't return the correct order of
> such devices due to vmbus_ignore_device in case of
> blocklisting/allowlisting. So device_order field
> will be helpful in that case.
> 
> Signed-off-by: Vladimir Ratnikov <vratnikov@netgate.com>

The patch only has the device_order field, but it is set
but not used anywhere in the DPDK. If you want to use it for naming
then please add that patch as well.
  
Stephen Hemminger June 25, 2024, 12:02 a.m. UTC | #2
On Mon, 24 Jun 2024 11:15:21 +0000
Vladimir Ratnikov <vratnikov@netgate.com> wrote:

> Field can be used to have static interface naming
> in DPDK based applications instead of uuid.
> RTE_FOREACH_DEV won't return the correct order of
> such devices due to vmbus_ignore_device in case of
> blocklisting/allowlisting. So device_order field
> will be helpful in that case.
> 
> Signed-off-by: Vladimir Ratnikov <vratnikov@netgate.com>
> ---

Not sure the order of device discovery is predictable.
The order of devices on vmbus is when they were reported by the host OS.
That is why Linux driver use other ways to have persistent naming.
  
Vladimir Ratnikov June 25, 2024, 11:49 a.m. UTC | #3
Thanks for review!

Regarding to

> The patch only has the device_order field, but it is set but not used
> anywhere in the DPDK.

Unfortunately, It's not for DPDK usage, it's for DPDK based applications.
After some time of testing, if nothing's changed in the host OS(no new
devices, no removed devices) - the device list is always the same with the
same order.

On Tue, Jun 25, 2024 at 2:02 AM Stephen Hemminger <
stephen@networkplumber.org> wrote:

> On Mon, 24 Jun 2024 11:15:21 +0000
> Vladimir Ratnikov <vratnikov@netgate.com> wrote:
>
> > Field can be used to have static interface naming
> > in DPDK based applications instead of uuid.
> > RTE_FOREACH_DEV won't return the correct order of
> > such devices due to vmbus_ignore_device in case of
> > blocklisting/allowlisting. So device_order field
> > will be helpful in that case.
> >
> > Signed-off-by: Vladimir Ratnikov <vratnikov@netgate.com>
> > ---
>
> Not sure the order of device discovery is predictable.
> The order of devices on vmbus is when they were reported by the host OS.
> That is why Linux driver use other ways to have persistent naming.
>
  
Long Li July 6, 2024, 12:21 a.m. UTC | #4
Hi Vladimir,

Is there another way that you can determine the device probe order from your application? (like going through the /sys/class/uio devices)

Long

From: Vladimir Ratnikov <vratnikov@netgate.com>
Sent: Tuesday, June 25, 2024 4:50 AM
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Long Li <longli@microsoft.com>; dev@dpdk.org
Subject: Re: [PATCH v2] bus/vmbus: add device_order field to rte_vmbus_dev

You don't often get email from vratnikov@netgate.com<mailto:vratnikov@netgate.com>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
Thanks for review!

Regarding to
The patch only has the device_order field, but it is set but not used anywhere in the DPDK.
Unfortunately, It's not for DPDK usage, it's for DPDK based applications.
After some time of testing, if nothing's changed in the host OS(no new devices, no removed devices) - the device list is always the same with the same order.

On Tue, Jun 25, 2024 at 2:02 AM Stephen Hemminger <stephen@networkplumber.org<mailto:stephen@networkplumber.org>> wrote:
On Mon, 24 Jun 2024 11:15:21 +0000
Vladimir Ratnikov <vratnikov@netgate.com<mailto:vratnikov@netgate.com>> wrote:

> Field can be used to have static interface naming
> in DPDK based applications instead of uuid.
> RTE_FOREACH_DEV won't return the correct order of
> such devices due to vmbus_ignore_device in case of
> blocklisting/allowlisting. So device_order field
> will be helpful in that case.
>
> Signed-off-by: Vladimir Ratnikov <vratnikov@netgate.com<mailto:vratnikov@netgate.com>>
> ---

Not sure the order of device discovery is predictable.
The order of devices on vmbus is when they were reported by the host OS.
That is why Linux driver use other ways to have persistent naming.
  

Patch

diff --git a/drivers/bus/vmbus/bus_vmbus_driver.h b/drivers/bus/vmbus/bus_vmbus_driver.h
index e2475a642d..6b010cbe41 100644
--- a/drivers/bus/vmbus/bus_vmbus_driver.h
+++ b/drivers/bus/vmbus/bus_vmbus_driver.h
@@ -37,6 +37,7 @@  struct rte_vmbus_device {
 	rte_uuid_t device_id;		       /**< VMBUS device id */
 	rte_uuid_t class_id;		       /**< VMBUS device type */
 	uint32_t relid;			       /**< id for primary */
+	uint16_t device_order;		       /**< Device order after probing */
 	uint8_t monitor_id;		       /**< monitor page */
 	int uio_num;			       /**< UIO device number */
 	uint32_t *int_page;		       /**< VMBUS interrupt page */
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index b9139c6e6c..1a64ab2712 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -199,7 +199,7 @@  rte_vmbus_probe(void)
 	char ubuf[RTE_UUID_STRLEN];
 
 	FOREACH_DEVICE_ON_VMBUS(dev) {
-		probed++;
+		dev->device_order = probed++;
 
 		rte_uuid_unparse(dev->device_id, ubuf, sizeof(ubuf));