PCI: helper to make a TBDF from a pcidev
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 9 Feb 2015 22:21:45 +0000 (17:21 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Sun, 1 Mar 2015 14:36:00 +0000 (09:36 -0500)
All of the PCI devices need to do this, and it'll be easier on an
spatch.

kern/arch/x86/pci.c
kern/arch/x86/pci.h
kern/drivers/net/ether8139.c
kern/drivers/net/ether8169.c
kern/drivers/net/ether82563.c
kern/drivers/net/etherigbe.c

index 505be0b..a06d8e9 100644 (file)
@@ -576,3 +576,8 @@ int pci_find_cap(struct pci_device *pcidev, uint8_t cap_id, uint32_t *cap_reg)
                *cap_reg = pcidev->caps[cap_id];
        return 0;
 }
+
+unsigned int pci_to_tbdf(struct pci_device *pcidev)
+{
+       return MKBUS(BusPCI, pcidev->bus, pcidev->dev, pcidev->func);
+}
index 9e2179f..1b3d392 100644 (file)
@@ -414,6 +414,7 @@ uint16_t pci_get_subvendor(struct pci_device *pcidev);
 uint16_t pci_get_subdevice(struct pci_device *pcidev);
 void pci_dump_config(struct pci_device *pcidev, size_t len);
 int pci_find_cap(struct pci_device *pcidev, uint8_t cap_id, uint32_t *cap_reg);
+unsigned int pci_to_tbdf(struct pci_device *pcidev);
 static inline void pci_set_drvdata(struct pci_device *pcidev, void *data);
 static inline void *pci_get_drvdata(struct pci_device *pcidev);
 
index 7b8beb8..47cab68 100644 (file)
@@ -750,8 +750,7 @@ static int rtl8139pnp(struct ether *edev)
                edev->ea[4] = i;
                edev->ea[5] = i >> 8;
        }
-       edev->tbdf = MKBUS(BusPCI, ctlr->pcidev->bus, ctlr->pcidev->dev,
-                          ctlr->pcidev->func);
+       edev->tbdf = pci_to_tbdf(ctlr->pcidev);
        edev->attach = rtl8139attach;
        edev->transmit = rtl8139transmit;
        edev->ifstat = rtl8139ifstat;
index dfed1e6..bfc790e 100644 (file)
@@ -1216,8 +1216,7 @@ rtl8169pnp(struct ether* edev)
                edev->ea[5] = r>>8;
        }
 
-       edev->tbdf = MKBUS(BusPCI, ctlr->pci->bus, ctlr->pci->dev,
-                          ctlr->pci->func);
+       edev->tbdf = pci_to_tbdf(ctlr->pci);
        edev->attach = rtl8169attach;
        edev->transmit = rtl8169transmit;
        edev->ifstat = rtl8169ifstat;
index 344c0c6..47283ea 100644 (file)
@@ -1922,8 +1922,7 @@ static int pnp(struct ether *edev, int type)
        edev->ctlr = ctlr;
        edev->port = ctlr->mmio_paddr;
        edev->irq = ctlr->pcidev->irqline;
-       edev->tbdf = MKBUS(BusPCI, ctlr->pcidev->bus, ctlr->pcidev->dev,
-                          ctlr->pcidev->func);
+       edev->tbdf = pci_to_tbdf(ctlr->pcidev);
        edev->netif.mbps = 1000;
        edev->maxmtu = ctlr->rbsz;
        memmove(edev->ea, ctlr->ra, Eaddrlen);
index c56d261..4841321 100644 (file)
@@ -2053,7 +2053,7 @@ igbepnp(struct ether* edev)
        edev->ctlr = ctlr;
        edev->port = ctlr->port;
        edev->irq = ctlr->pci->irqline;
-       edev->tbdf = MKBUS(BusPCI, ctlr->pci->bus, ctlr->pci->dev, ctlr->pci->func);
+       edev->tbdf = pci_to_tbdf(ctlr->pci);
        edev->netif.mbps = 1000;
        memmove(edev->ea, ctlr->ra, Eaddrlen);