Re: [kvm-unit-tests PATCH 10/14] pci: add bdf helpers

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

 



On Fri, Oct 14, 2016 at 08:40:48PM +0800, Peter Xu wrote:
> Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
> ---
>  lib/pci.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/lib/pci.h b/lib/pci.h
> index b8755ff..6a1c3c9 100644
> --- a/lib/pci.h
> +++ b/lib/pci.h
> @@ -18,6 +18,12 @@ 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)
> +#define PCI_SLOT(devfn)                 (((devfn) >> 3) & 0x1f)
> +#define PCI_FUNC(devfn)                 ((devfn) & 0x07)
> +#define PCI_BUILD_BDF(bus, devfn)       ((bus << 8) | (devfn))

As I mention frequently; I know nothing about PCI, but this doesn't
look right to me. DEVFN should be defined as

 #define PCI_DEVFN(slot, func)   ((((slot) & 0x1f) << 3) | ((func) & 0x07))

Care to explain these? Please provide the explanation in the commit
message to along with a motivation for adding them.

Thanks,
drew

> +
>  struct pci_dev {
>  	bool inited;
>  	uint16_t pci_addr;
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux