diff mbox series

[ovs-dev,dpdk-latest] netdev-dpdk: Report device bus specific information.

Message ID 20220926090710.2853123-1-david.marchand@redhat.com
State Superseded
Headers show
Series [ovs-dev,dpdk-latest] netdev-dpdk: Report device bus specific information. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation fail test: fail

Commit Message

David Marchand Sept. 26, 2022, 9:07 a.m. UTC
22.11 dropped direct access to bus specific structures.
Instead, a new API reports bus specific information.

Report bus name and device bus specific information.

The difference looks like:
-driver_name=mlx5_pci, if_descr="DPDK 21.11.0 mlx5_pci"
+driver_name=mlx5_pci, if_descr="DPDK 22.11.0-rc0 mlx5_pci"

-pci-device_id="0x1019"
-pci-vendor_id="0x15b3"
+bus_info="bus_name=pci, vendor_id=15b3, device_id=1019"

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/netdev-dpdk.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

Comments

Pai G, Sunil Sept. 26, 2022, 2:23 p.m. UTC | #1
> -----Original Message-----
> From: dev <ovs-dev-bounces@openvswitch.org> On Behalf Of David Marchand
> Sent: Monday, September 26, 2022 2:37 PM
> To: dev@openvswitch.org
> Cc: maxime.coquelin@redhat.com
> Subject: [ovs-dev] [PATCH dpdk-latest] netdev-dpdk: Report device bus
> specific information.
> 
> 22.11 dropped direct access to bus specific structures.
> Instead, a new API reports bus specific information.
> 
> Report bus name and device bus specific information.
> 
> The difference looks like:
> -driver_name=mlx5_pci, if_descr="DPDK 21.11.0 mlx5_pci"
> +driver_name=mlx5_pci, if_descr="DPDK 22.11.0-rc0 mlx5_pci"
> 
> -pci-device_id="0x1019"
> -pci-vendor_id="0x15b3"
> +bus_info="bus_name=pci, vendor_id=15b3, device_id=1019"
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  lib/netdev-dpdk.c | 23 ++++++++---------------
>  1 file changed, 8 insertions(+), 15 deletions(-)
> 

Thanks for the patch David.

Everything LGTM,
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 0dd655507b..fb4b3282dc 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -26,9 +26,10 @@ 
 #include <sys/socket.h>
 #include <linux/if.h>
 
-#include <rte_bus_pci.h>
+#include <rte_bus.h>
 #include <rte_config.h>
 #include <rte_cycles.h>
+#include <rte_dev.h>
 #include <rte_errno.h>
 #include <rte_ethdev.h>
 #include <rte_flow.h>
@@ -3639,6 +3640,7 @@  netdev_dpdk_get_status(const struct netdev *netdev, struct smap *args)
 {
     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
     struct rte_eth_dev_info dev_info;
+    const char *bus_info;
     uint32_t link_speed;
     uint32_t dev_flags;
 
@@ -3651,19 +3653,8 @@  netdev_dpdk_get_status(const struct netdev *netdev, struct smap *args)
     rte_eth_dev_info_get(dev->port_id, &dev_info);
     link_speed = dev->link.link_speed;
     dev_flags = *dev_info.dev_flags;
+    bus_info = rte_dev_bus_info(dev_info.device);
     ovs_mutex_unlock(&dev->mutex);
-    const struct rte_bus *bus;
-    const struct rte_pci_device *pci_dev;
-    uint16_t vendor_id = RTE_PCI_ANY_ID;
-    uint16_t device_id = RTE_PCI_ANY_ID;
-    bus = rte_bus_find_by_device(dev_info.device);
-    if (bus && !strcmp(bus->name, "pci")) {
-        pci_dev = RTE_DEV_TO_PCI(dev_info.device);
-        if (pci_dev) {
-            vendor_id = pci_dev->id.vendor_id;
-            device_id = pci_dev->id.device_id;
-        }
-    }
     ovs_mutex_unlock(&dpdk_mutex);
 
     smap_add_format(args, "port_no", DPDK_PORT_ID_FMT, dev->port_id);
@@ -3687,8 +3678,10 @@  netdev_dpdk_get_status(const struct netdev *netdev, struct smap *args)
     smap_add_format(args, "if_type", "%"PRIu32, IF_TYPE_ETHERNETCSMACD);
     smap_add_format(args, "if_descr", "%s %s", rte_version(),
                                                dev_info.driver_name);
-    smap_add_format(args, "pci-vendor_id", "0x%x", vendor_id);
-    smap_add_format(args, "pci-device_id", "0x%x", device_id);
+    smap_add_format(args, "bus_info", "bus_name=%s%s%s",
+                    rte_bus_name(rte_dev_bus(dev_info.device)),
+                    bus_info != NULL ? ", " : "",
+                    bus_info != NULL ? bus_info : "");
 
     /* Not all link speeds are defined in the OpenFlow specs e.g. 25 Gbps.
      * In that case the speed will not be reported as part of the usual