dev: add read functions pci config and config ext 77/43977/1
authorMohsin Kazmi <[email protected]>
Mon, 27 Oct 2025 10:17:30 +0000 (10:17 +0000)
committerMohsin Kazmi <[email protected]>
Mon, 27 Oct 2025 10:30:34 +0000 (10:30 +0000)
Type: improvement

Signed-off-by: Mohsin Kazmi <[email protected]>
Change-Id: If21552811239c9f3432c35f2dd1d19091bf39672

src/vnet/dev/bus/pci.c
src/vnet/dev/bus/pci.h

index 10bbfa3..4c086a0 100644 (file)
@@ -180,6 +180,42 @@ vnet_dev_pci_read_config_header (vlib_main_t *vm, vnet_dev_t *dev,
   return VNET_DEV_OK;
 }
 
+vnet_dev_rv_t
+vnet_dev_pci_read_config (vlib_main_t *vm, vnet_dev_t *dev,
+                         vlib_pci_config_t *config)
+{
+  vlib_pci_dev_handle_t h = vnet_dev_get_pci_handle (dev);
+  clib_error_t *err;
+
+  err =
+    vlib_pci_read_write_config (vm, h, VLIB_READ, 0, config, sizeof (*config));
+  if (err)
+    {
+      log_err (dev, "pci_read_config: %U", format_clib_error, err);
+      clib_error_free (err);
+      return VNET_DEV_ERR_BUS;
+    }
+  return VNET_DEV_OK;
+}
+
+vnet_dev_rv_t
+vnet_dev_pci_read_config_ext (vlib_main_t *vm, vnet_dev_t *dev,
+                             vlib_pci_config_ext_t *config_ext)
+{
+  vlib_pci_dev_handle_t h = vnet_dev_get_pci_handle (dev);
+  clib_error_t *err;
+
+  err = vlib_pci_read_write_config (vm, h, VLIB_READ, 0, config_ext,
+                                   sizeof (*config_ext));
+  if (err)
+    {
+      log_err (dev, "pci_read_config_ext: %U", format_clib_error, err);
+      clib_error_free (err);
+      return VNET_DEV_ERR_BUS;
+    }
+  return VNET_DEV_OK;
+}
+
 vnet_dev_rv_t
 vnet_dev_pci_map_region (vlib_main_t *vm, vnet_dev_t *dev, u8 region,
                         void **pp)
index ce9a53a..e8d4685 100644 (file)
@@ -57,7 +57,10 @@ vnet_dev_get_pci_n_msix_interrupts (vnet_dev_t *dev)
 
 vnet_dev_rv_t vnet_dev_pci_read_config_header (vlib_main_t *, vnet_dev_t *,
                                               vlib_pci_config_hdr_t *);
-
+vnet_dev_rv_t vnet_dev_pci_read_config (vlib_main_t *, vnet_dev_t *,
+                                       vlib_pci_config_t *);
+vnet_dev_rv_t vnet_dev_pci_read_config_ext (vlib_main_t *, vnet_dev_t *,
+                                           vlib_pci_config_ext_t *);
 vnet_dev_rv_t vnet_dev_pci_map_region (vlib_main_t *, vnet_dev_t *, u8,
                                       void **);
 vnet_dev_rv_t vnet_dev_pci_function_level_reset (vlib_main_t *, vnet_dev_t *);