[PATCH v1 3/6] vpci: rename and export vpci_bar_add_rangeset

Mykyta Poturai posted 6 patches 3 months, 1 week ago
[PATCH v1 3/6] vpci: rename and export vpci_bar_add_rangeset
Posted by Mykyta Poturai 3 months, 1 week ago
Export functions required for SR-IOV support.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
 xen/drivers/vpci/header.c | 8 ++++----
 xen/include/xen/vpci.h    | 2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index f33fb27bde..f947f652cd 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -733,8 +733,8 @@ static void cf_check rom_write(
     }
 }
 
-static int bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
-                            unsigned int i)
+int vpci_bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
+                          unsigned int i)
 {
     char str[32];
 
@@ -950,7 +950,7 @@ static int cf_check init_header(struct pci_dev *pdev)
         else
             bars[i].type = VPCI_BAR_MEM32;
 
-        rc = bar_add_rangeset(pdev, &bars[i], i);
+        rc = vpci_bar_add_rangeset(pdev, &bars[i], i);
         if ( rc )
             goto fail;
 
@@ -1009,7 +1009,7 @@ static int cf_check init_header(struct pci_dev *pdev)
             rom->type = VPCI_BAR_EMPTY;
         else
         {
-            rc = bar_add_rangeset(pdev, rom, num_bars);
+            rc = vpci_bar_add_rangeset(pdev, rom, num_bars);
             if ( rc )
                 goto fail;
         }
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index 0f0f321023..06f7039f20 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -294,6 +294,8 @@ bool vpci_ecam_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,
 
 /* Map/unmap the BARs of a vPCI device. */
 int vpci_modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only);
+int vpci_bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
+                            unsigned int i);
 
 #endif /* __XEN__ */
 
-- 
2.34.1
Re: [PATCH v1 3/6] vpci: rename and export vpci_bar_add_rangeset
Posted by Roger Pau Monné 3 months ago
On Fri, Jul 25, 2025 at 02:24:32PM +0000, Mykyta Poturai wrote:
> Export functions required for SR-IOV support.
> 
> Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
> ---
>  xen/drivers/vpci/header.c | 8 ++++----
>  xen/include/xen/vpci.h    | 2 ++
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
> index f33fb27bde..f947f652cd 100644
> --- a/xen/drivers/vpci/header.c
> +++ b/xen/drivers/vpci/header.c
> @@ -733,8 +733,8 @@ static void cf_check rom_write(
>      }
>  }
>  
> -static int bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
> -                            unsigned int i)
> +int vpci_bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
> +                          unsigned int i)

Inline from my reply on the BAR register write series, it might be
less wasteful to allocate the ranges per-vCPU rather than per-device.
The only purpose of those rangesets is for BAR mapping, and such
mapping is performed exclusively for each device on a single vCPU.

With that there's probably no need to export this function, as it will
no longer exist.

Thanks, Roger.
Re: [PATCH v1 3/6] vpci: rename and export vpci_bar_add_rangeset
Posted by Teddy Astie 3 months, 1 week ago
Le 25/07/2025 à 16:26, Mykyta Poturai a écrit :
> Export functions required for SR-IOV support.
> 
> Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
> ---
>   xen/drivers/vpci/header.c | 8 ++++----
>   xen/include/xen/vpci.h    | 2 ++
>   2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
> index f33fb27bde..f947f652cd 100644
> --- a/xen/drivers/vpci/header.c
> +++ b/xen/drivers/vpci/header.c
> @@ -733,8 +733,8 @@ static void cf_check rom_write(
>       }
>   }
>   
> -static int bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
> -                            unsigned int i)
> +int vpci_bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
> +                          unsigned int i)
>   {
>       char str[32];
>   
> @@ -950,7 +950,7 @@ static int cf_check init_header(struct pci_dev *pdev)
>           else
>               bars[i].type = VPCI_BAR_MEM32;
>   
> -        rc = bar_add_rangeset(pdev, &bars[i], i);
> +        rc = vpci_bar_add_rangeset(pdev, &bars[i], i);
>           if ( rc )
>               goto fail;
>   
> @@ -1009,7 +1009,7 @@ static int cf_check init_header(struct pci_dev *pdev)
>               rom->type = VPCI_BAR_EMPTY;
>           else
>           {
> -            rc = bar_add_rangeset(pdev, rom, num_bars);
> +            rc = vpci_bar_add_rangeset(pdev, rom, num_bars);
>               if ( rc )
>                   goto fail;
>           }
> diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
> index 0f0f321023..06f7039f20 100644
> --- a/xen/include/xen/vpci.h
> +++ b/xen/include/xen/vpci.h
> @@ -294,6 +294,8 @@ bool vpci_ecam_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,
>   
>   /* Map/unmap the BARs of a vPCI device. */
>   int vpci_modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only);
> +int vpci_bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
> +                            unsigned int i);
                              ^
nit, alignment is a bit off

With that fixed

Reviewed-by: Teddy Astie <teddy.astie@vates.tech>

>   
>   #endif /* __XEN__ */
>   



Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech