diff mbox

[kvm-unit-tests,12/17] pci: add bdf helpers

Message ID 1477468040-21034-13-git-send-email-peterx@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Xu Oct. 26, 2016, 7:47 a.m. UTC
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 lib/pci.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Andrew Jones Nov. 4, 2016, 5:51 p.m. UTC | #1
On Wed, Oct 26, 2016 at 03:47:15PM +0800, Peter Xu wrote:
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  lib/pci.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/pci.h b/lib/pci.h
> index 0336455..7a3bce9 100644
> --- a/lib/pci.h
> +++ b/lib/pci.h
> @@ -18,6 +18,9 @@ enum {
>  #define PCI_BAR_NUM                     (6)
>  #define PCI_DEVFN_MAX                   (256)
>  
> +#define PCI_BDF_GET_DEVFN(x)            ((x) & 0xff)
> +#define PCI_BDF_GET_BUS(x)              (((x) >> 8) & 0xff)

I feel the above four defines (PCI_BAR_NUM, PCI_DEVFN_MAX,
PCI_BDF_GET_DEVFN, PCI_BDF_GET_BUS) are on the crufty side, but I
won't fight too hard to try to convince you to drop them :-)

> +
>  struct pci_dev {
>  	uint16_t pci_bdf;
>  	phys_addr_t pci_bar[PCI_BAR_NUM];
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/pci.h b/lib/pci.h
index 0336455..7a3bce9 100644
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -18,6 +18,9 @@  enum {
 #define PCI_BAR_NUM                     (6)
 #define PCI_DEVFN_MAX                   (256)
 
+#define PCI_BDF_GET_DEVFN(x)            ((x) & 0xff)
+#define PCI_BDF_GET_BUS(x)              (((x) >> 8) & 0xff)
+
 struct pci_dev {
 	uint16_t pci_bdf;
 	phys_addr_t pci_bar[PCI_BAR_NUM];