diff mbox series

[v3,13/46] hw/mips/malta: use pci_init_nic_devices()

Message ID 20240108204909.564514-14-dwmw2@infradead.org
State New
Headers show
Series Rework matching of network devices to -nic options | expand

Commit Message

David Woodhouse Jan. 8, 2024, 8:26 p.m. UTC
From: David Woodhouse <dwmw@amazon.co.uk>

The Malta board setup code would previously place the first NIC into PCI
slot 11 if was a PCNet card, and the rest (including the first if it was
anything other than a PCNet card) would be dynamically assigned.

Now it will place any PCNet NIC into slot 11, and then anything else will
be dynamically assigned.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 hw/mips/malta.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Comments

Thomas Huth Jan. 26, 2024, 1:57 p.m. UTC | #1
On 08/01/2024 21.26, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> The Malta board setup code would previously place the first NIC into PCI
> slot 11 if was a PCNet card, and the rest (including the first if it was
> anything other than a PCNet card) would be dynamically assigned.
> 
> Now it will place any PCNet NIC into slot 11, and then anything else will
> be dynamically assigned.
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>   hw/mips/malta.c | 15 +++------------
>   1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/mips/malta.c b/hw/mips/malta.c
> index d22bb1edef..af74008c82 100644
> --- a/hw/mips/malta.c
> +++ b/hw/mips/malta.c
> @@ -612,18 +612,9 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,
>   /* Network support */
>   static void network_init(PCIBus *pci_bus)
>   {
> -    int i;
> -
> -    for (i = 0; i < nb_nics; i++) {
> -        NICInfo *nd = &nd_table[i];
> -        const char *default_devaddr = NULL;
> -
> -        if (i == 0 && (!nd->model || strcmp(nd->model, "pcnet") == 0))
> -            /* The malta board has a PCNet card using PCI SLOT 11 */
> -            default_devaddr = "0b";
> -
> -        pci_nic_init_nofail(nd, pci_bus, "pcnet", default_devaddr);
> -    }
> +    /* The malta board has a PCNet card using PCI SLOT 11 */
> +    pci_init_nic_in_slot(pci_bus, "pcnet", NULL, "0b");
> +    pci_init_nic_devices(pci_bus, "pcnet");
>   }

Reviewed-by: Thomas Huth <thuth@redhat.com>

Philippe, could you maybe have a look at this, too?
diff mbox series

Patch

diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index d22bb1edef..af74008c82 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -612,18 +612,9 @@  static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,
 /* Network support */
 static void network_init(PCIBus *pci_bus)
 {
-    int i;
-
-    for (i = 0; i < nb_nics; i++) {
-        NICInfo *nd = &nd_table[i];
-        const char *default_devaddr = NULL;
-
-        if (i == 0 && (!nd->model || strcmp(nd->model, "pcnet") == 0))
-            /* The malta board has a PCNet card using PCI SLOT 11 */
-            default_devaddr = "0b";
-
-        pci_nic_init_nofail(nd, pci_bus, "pcnet", default_devaddr);
-    }
+    /* The malta board has a PCNet card using PCI SLOT 11 */
+    pci_init_nic_in_slot(pci_bus, "pcnet", NULL, "0b");
+    pci_init_nic_devices(pci_bus, "pcnet");
 }
 
 static void bl_setup_gt64120_jump_kernel(void **p, uint64_t run_addr,