[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_de
From: |
David Woodhouse |
Subject: |
[PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices() |
Date: |
Mon, 8 Jan 2024 20:26:34 +0000 |
From: David Woodhouse <dwmw@amazon.co.uk>
Eliminate direct access to nd_table[] and nb_nics by processing the the
Xen and ISA NICs first and then calling pci_init_nic_devices() for the
rest.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
---
hw/i386/pc.c | 26 ++++++++++++++++----------
include/hw/net/ne2000-isa.h | 2 --
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 496498df3a..d80c536d88 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -658,8 +658,11 @@ static void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd)
{
static int nb_ne2k = 0;
- if (nb_ne2k == NE2000_NB_MAX)
+ if (nb_ne2k == NE2000_NB_MAX) {
+ error_setg(&error_fatal,
+ "maximum number of ISA NE2000 devices exceeded");
return;
+ }
isa_ne2000_init(bus, ne2000_io[nb_ne2k],
ne2000_irq[nb_ne2k], nd);
nb_ne2k++;
@@ -1297,23 +1300,26 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus,
PCIBus *pci_bus,
BusState *xen_bus)
{
MachineClass *mc = MACHINE_CLASS(pcmc);
- int i;
+ bool default_is_ne2k = g_str_equal(mc->default_nic, TYPE_ISA_NE2000);
+ NICInfo *nd;
rom_set_order_override(FW_CFG_ORDER_OVERRIDE_NIC);
- for (i = 0; i < nb_nics; i++) {
- NICInfo *nd = &nd_table[i];
- const char *model = nd->model ? nd->model : mc->default_nic;
- if (xen_bus && (!nd->model || g_str_equal(model, "xen-net-device"))) {
+ if (xen_bus) {
+ while (nc = qemu_find_nic_info("xen-net-device", true, NULL)) {
DeviceState *dev = qdev_new("xen-net-device");
qdev_set_nic_properties(dev, nd);
qdev_realize_and_unref(dev, xen_bus, &error_fatal);
- } else if (g_str_equal(model, "ne2k_isa")) {
- pc_init_ne2k_isa(isa_bus, nd);
- } else {
- pci_nic_init_nofail(nd, pci_bus, model, NULL);
}
}
+
+ while ((nd = qemu_find_nic_info(TYPE_ISA_NE2000, default_is_ne2k, NULL))) {
+ pc_init_ne2k_isa(isa_bus, nd);
+ }
+
+ /* Anything remaining should be a PCI NIC */
+ pci_init_nic_devices(pci_bus, mc->default_nic);
+
rom_reset_order_override();
}
diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h
index af59ee0b02..73bae10ad1 100644
--- a/include/hw/net/ne2000-isa.h
+++ b/include/hw/net/ne2000-isa.h
@@ -22,8 +22,6 @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int
base, int irq,
{
ISADevice *d;
- qemu_check_nic_model(nd, "ne2k_isa");
-
d = isa_try_new(TYPE_ISA_NE2000);
if (d) {
DeviceState *dev = DEVICE(d);
--
2.41.0
- [PATCH v3 45/46] net: remove qemu_show_nic_models(), qemu_find_nic_model(), (continued)
- [PATCH v3 45/46] net: remove qemu_show_nic_models(), qemu_find_nic_model(), David Woodhouse, 2024/01/08
- [PATCH v3 09/46] hw/arm/virt: use pci_init_nic_devices(), David Woodhouse, 2024/01/08
- [PATCH v3 43/46] net: remove qemu_check_nic_model(), David Woodhouse, 2024/01/08
- [PATCH v3 40/46] hw/s390x/s390-virtio-ccw: use qemu_create_nic_device(), David Woodhouse, 2024/01/08
- [PATCH v3 37/46] hw/net/lasi_i82596: use qemu_configure_nic_device(), David Woodhouse, 2024/01/08
- [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(),
David Woodhouse <=
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), Thomas Huth, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), Thomas Huth, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), Thomas Huth, 2024/01/26
- Re: [PATCH v3 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2024/01/26
[PATCH v3 33/46] hw/m68k/q800: use qemu_find_nic_info(), David Woodhouse, 2024/01/08
[PATCH v3 46/46] net: make nb_nics and nd_table[] static in net/net.c, David Woodhouse, 2024/01/08
[PATCH v3 44/46] hw/pci: remove pci_nic_init_nofail(), David Woodhouse, 2024/01/08