Add a network device e1000e to the boston-aia board model.
There is no pch_gbe emulation, so we add e1000e in slot 0 func 1,
instead. We need to pass func to call pci_parse_devaddr to find
out slot and func.

Signed-off-by: Chao-ying Fu <c...@mips.com>
Signed-off-by: Djordje Todorovic <djordje.todoro...@htecgroup.com>
---
 hw/pci/pci.c          | 23 ++++++++++++-----------
 hw/riscv/boston-aia.c |  5 +++++
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 2844ec5556..9748acda09 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -980,16 +980,15 @@ static int pci_parse_devaddr(const char *addr, int *domp, 
int *busp,
 
     slot = val;
 
-    if (funcp != NULL) {
-        if (*e != '.')
-            return -1;
-
-        p = e + 1;
-        val = strtoul(p, &e, 16);
-        if (e == p)
-            return -1;
+    if (funcp != NULL && *e != 0) {
+      if (*e != '.')
+        return -1;
+      p = e + 1;
+      val = strtoul(p, &e, 16);
+      if (e == p)
+        return -1;
 
-        func = val;
+      func = val;
     }
 
     /* if funcp == NULL func is 0 */
@@ -2039,13 +2038,15 @@ bool pci_init_nic_in_slot(PCIBus *rootbus, const char 
*model,
     int dom, busnr, devfn;
     PCIDevice *pci_dev;
     unsigned slot;
+
     PCIBus *bus;
 
     if (!nd) {
         return false;
     }
 
-    if (!devaddr || pci_parse_devaddr(devaddr, &dom, &busnr, &slot, NULL) < 0) 
{
+    unsigned func;
+    if (!devaddr || pci_parse_devaddr(devaddr, &dom, &busnr, &slot, &func) < 
0) {
         error_report("Invalid PCI device address %s for device %s",
                      devaddr, model);
         exit(1);
@@ -2056,7 +2057,7 @@ bool pci_init_nic_in_slot(PCIBus *rootbus, const char 
*model,
         exit(1);
     }
 
-    devfn = PCI_DEVFN(slot, 0);
+    devfn = PCI_DEVFN(slot, func);
 
     bus = pci_find_bus_nr(rootbus, busnr);
     if (!bus) {
diff --git a/hw/riscv/boston-aia.c b/hw/riscv/boston-aia.c
index e075dca33a..2615b41a48 100644
--- a/hw/riscv/boston-aia.c
+++ b/hw/riscv/boston-aia.c
@@ -432,6 +432,11 @@ static void boston_mach_init(MachineState *machine)
     ide_drive_get(hd, ich9->ahci.ports);
     ahci_ide_create_devs(&ich9->ahci, hd);
 
+    /* Create e1000e using slot 0 func 1 */
+    pci_init_nic_in_slot(&PCI_BRIDGE(&pcie2->root)->sec_bus, "e1000e", NULL,
+                         "00.1");
+    pci_init_nic_devices(&PCI_BRIDGE(&pcie2->root)->sec_bus, "e1000e");
+
     if (machine->firmware) {
         fw_size = load_image_targphys(machine->firmware,
                                       0x1fc00000, 4 * MiB);
-- 
2.34.1

Reply via email to