For some arm64-related interrupt controller work I need to be able to
compose a PCIe requester ID. Since this is a generic PCIe concept
that might be useful on other architectures (for example for IOMMU
support), I propose to add a function to the MI PCI code.
ok?
Index: dev/pci/pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/pci.c,v
retrieving revision 1.111
diff -u -p -r1.111 pci.c
--- dev/pci/pci.c 27 Nov 2015 15:28:22 -0000 1.111
+++ dev/pci/pci.c 28 Jul 2018 11:42:51 -0000
@@ -659,6 +659,15 @@ pci_get_ht_capability(pci_chipset_tag_t
return (0);
}
+uint16_t
+pci_requester_id(pci_chipset_tag_t pc, pcitag_t tag)
+{
+ int bus, dev, func;
+
+ pci_decompose_tag(pc, tag, &bus, &dev, &func);
+ return ((bus << 8) | (dev << 3) | func);
+}
+
int
pci_find_device(struct pci_attach_args *pa,
int (*match)(struct pci_attach_args *))
Index: dev/pci/pcivar.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcivar.h,v
retrieving revision 1.69
diff -u -p -r1.69 pcivar.h
--- dev/pci/pcivar.h 8 Aug 2013 17:54:11 -0000 1.69
+++ dev/pci/pcivar.h 28 Jul 2018 11:42:51 -0000
@@ -226,7 +226,6 @@ int pci_mapreg_map(struct pci_attach_arg
bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *,
bus_size_t *, bus_size_t);
-
int pci_io_find(pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
bus_size_t *);
int pci_mem_find(pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
@@ -236,6 +235,8 @@ int pci_get_capability(pci_chipset_tag_t
int *, pcireg_t *);
int pci_get_ht_capability(pci_chipset_tag_t, pcitag_t, int,
int *, pcireg_t *);
+
+uint16_t pci_requester_id(pci_chipset_tag_t, pcitag_t);
struct pci_matchid {
pci_vendor_id_t pm_vid;