The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=55c07af60172b211116be47010fc0831aafc99e8
commit 55c07af60172b211116be47010fc0831aafc99e8 Author: Bjoern A. Zeeb <[email protected]> AuthorDate: 2026-08-16 21:32:31 +0000 Commit: Bjoern A. Zeeb <[email protected]> CommitDate: 2026-09-14 19:05:59 +0000 LinuxKPI: pci: add pci_select_bars() and pci_msix_vec_count() For pci_select_bars() we use the LinuxKPI internal information, while for pci_select_bars() we fall back to the native PCI stack. Needed by a wifi driver. MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D58878 --- sys/compat/linuxkpi/common/include/linux/pci.h | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 12ca790f8811..7e416c3e9234 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -437,6 +437,24 @@ pci_resource_flags(struct pci_dev *pdev, int bar) return (1 << type); } +static inline int +pci_select_bars(struct pci_dev *pdev, unsigned long flags) +{ + int bars, bar; + + bars = 0; + /* We only support BARs here; Linux may support more types. */ + for (bar = PCIR_MAX_BAR_0; bar >= 0; bar--) { + int bar_flags; + + bar_flags = pci_resource_flags(pdev, bar); + if ((bar_flags & flags) != 0) + bars |= (1 << bar); + } + + return (bars); +} + static inline const char * pci_name(struct pci_dev *d) { @@ -1574,6 +1592,17 @@ pci_irq_vector(struct pci_dev *pdev, unsigned int vector) return (-ENXIO); } +static inline int +pci_msix_vec_count(struct pci_dev *pdev) +{ + int avail; + + avail = pci_msix_count(pdev->dev.bsddev); + if (avail == 0) + return (-EINVAL); + return (avail); +} + static inline int pci_wake_from_d3(struct pci_dev *pdev, bool enable) {
