[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/5] pci: Introduce parse_pci_sbdf{_seg}()


  • To: Teddy Astie <teddy.astie@xxxxxxxxxx>
  • From: dmukhin@xxxxxxxx
  • Date: Tue, 19 May 2026 19:39:25 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 205.220.161.53) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=ford.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ford.com; dkim=pass (signature was verified) header.d=saarlouis.ford.com; dkim=pass (signature was verified) header.d=ford.com; arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sS8YO9iyUSJc9im7EGYhEGbzfW3F9UgOtrWpPPBKMO4=; b=w5d6PbD/xOgDvMNjeiUs6WyA/Vh+vTLjSqI6nHM2jMVWlnXI3C0Ql/4im65+W/JgthnezIF1BsFAULMumE2ZgjaGr3fkVd4bsj18GYh5E+xQs2g1Q2qOYCN4nkwt2YIk41WcyLFVNMq2eh+KN6hz3TV+R+6ULKZ7qq+S1dNcPBN6yulPNsKY/OjppQ06NozPm+KNC7HTku/fLdvAXvpNAgIPEwI++Muu+twWfhtkRM6fgfSf/2Zl+uJX2ln6HOWL6HYaVEtZz+4CyOP0KoZ/bys3IeNVLsF+FxmxnRCitlmfopJMkWqtqd9VzUFCZdu758n0wBqGwiIc4IwjEz/KOw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FiFC+j54HFn6juJkdFtIE0vIHbZ6TrRm+H+s502bb0Dvaerz5LOeeMOY5+wjZxrYQBMM/uySfmCeOJ+y0Tn6u2O3BIWwn41tRanmtjKwgPIkJwOxce+wB6FofRi5zkWWrBzSLC3XrGmFnhLmu1qDg2RlaUDQM2fPOEFOPP2mVTh41pmeuZ8+RlDOFyRjS19D5zuO9v6oZni3MjGofUyVaW7WWupVZQyqRxwZRF3opyGzHv+zjM9ES8Uo8yXv8lXV7eJ0MG4FPuz0TDCbTqO1KZyItdYky/3KVKeYgmCioMwVKz5jewxvXKx9aOuh5k9aqwNwLlS2QOuARUxapwIszw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=ppford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=selector2-azureford-onmicrosoft-com header.d=azureford.onmicrosoft.com header.i="@azureford.onmicrosoft.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=ppserprodsaar header.d=saarlouis.ford.com header.i="@saarlouis.ford.com" header.h="Cc:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=ppfserpocford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 20 May 2026 02:39:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Pser-m365-app: SER-APP

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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.