|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 1/5] pci: Introduce parse_pci_sbdf{_seg}()
On Mon, May 18, 2026 at 05:21:25PM +0200, Teddy Astie wrote:
> In many places, we're parsing a PCI string into individual parts
> (seg, bus, dev, fn) and then transform it into a pci_sbdf_t using PCI_SBDF
> macro. Rather than converting from parts to pci_sbdf_t and vice versa,
> introduce a new function that parses a PCI string into a pci_sbdf_t structure
> directly.
>
> Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
> ---
> xen/drivers/pci/pci.c | 18 ++++++++++++++++++
> xen/include/xen/pci.h | 3 +++
> 2 files changed, 21 insertions(+)
>
> diff --git a/xen/drivers/pci/pci.c b/xen/drivers/pci/pci.c
> index 084be3880c..1d06cb035b 100644
> --- a/xen/drivers/pci/pci.c
> +++ b/xen/drivers/pci/pci.c
> @@ -202,3 +202,21 @@ const char *__init parse_pci_seg(const char *s, unsigned
> int *seg_p,
>
> return s;
> }
> +
> +const char *parse_pci_sbdf(const char *s, pci_sbdf_t *sbdf)
> +{
> + unsigned int seg, bus, dev, func;
> + const char *out = parse_pci(s, &seg, &bus, &dev, &func);
IMO, both parse_pci() and parse_pci_seg() should be merged into
parse_pci_sbdf() and parse_pci_sbdf_seg() at the end of the series,
since there will be no remaining consumers of the old APIs.
What do you think?
> +
> + *sbdf = PCI_SBDF(seg, bus, dev, func);
> + return out;
> +}
> +
> +const char *parse_pci_sbdf_seg(const char *s, pci_sbdf_t *sbdf, bool
> *def_seg)
> +{
> + unsigned int seg, bus, dev, func;
> + const char *out = parse_pci_seg(s, &seg, &bus, &dev, &func, def_seg);
> +
> + *sbdf = PCI_SBDF(seg, bus, dev, func);
> + return out;
> +}
> diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
> index afb6bbf50d..7bfc59cd75 100644
> --- a/xen/include/xen/pci.h
> +++ b/xen/include/xen/pci.h
> @@ -280,6 +280,9 @@ const char *parse_pci_seg(const char *s, unsigned int
> *seg_p,
> unsigned int *bus_p, unsigned int *dev_p,
> unsigned int *func_p, bool *def_seg);
>
> +const char *parse_pci_sbdf(const char *s, pci_sbdf_t *sbdf);
> +const char *parse_pci_sbdf_seg(const char *s, pci_sbdf_t *sbdf, bool
> *def_seg);
> +
> #define PCI_BAR_VF (1u << 0)
> #define PCI_BAR_LAST (1u << 1)
> #define PCI_BAR_ROM (1u << 2)
> --
> 2.52.0
>
>
>
> --
> Teddy Astie | Vates XCP-ng Developer
>
> XCP-ng & Xen Orchestra - Vates solutions
>
> web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |