diff mbox series

[v3,15/46] hw/ppc/prep: use pci_init_nic_devices()

Message ID 20240108204909.564514-16-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>

Previously, the first PCI NIC would be placed in PCI slot 3 and the rest
would be dynamically assigned. Even if the user overrode the default NIC
type and made it something other than PCNet.

Now, the first PCNet NIC (that is, anything not explicitly specified
to be anything different) will go to slot 3 even if it isn't the first
NIC specified on the commnd line. And anything else will be dynamically
assigned.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 hw/ppc/prep.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Thomas Huth Jan. 26, 2024, 2:06 p.m. UTC | #1
On 08/01/2024 21.26, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> Previously, the first PCI NIC would be placed in PCI slot 3 and the rest
> would be dynamically assigned. Even if the user overrode the default NIC
> type and made it something other than PCNet.
> 
> Now, the first PCNet NIC (that is, anything not explicitly specified
> to be anything different) will go to slot 3 even if it isn't the first
> NIC specified on the commnd line. And anything else will be dynamically
> assigned.
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>   hw/ppc/prep.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 137276bcb9..1a6cd05c61 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -241,7 +241,6 @@ static void ibm_40p_init(MachineState *machine)
>       ISADevice *isa_dev;
>       ISABus *isa_bus;
>       void *fw_cfg;
> -    int i;
>       uint32_t kernel_base = 0, initrd_base = 0;
>       long kernel_size = 0, initrd_size = 0;
>       char boot_device;
> @@ -336,10 +335,9 @@ static void ibm_40p_init(MachineState *machine)
>           /* XXX: s3-trio at PCI_DEVFN(2, 0) */
>           pci_vga_init(pci_bus);
>   
> -        for (i = 0; i < nb_nics; i++) {
> -            pci_nic_init_nofail(&nd_table[i], pci_bus, mc->default_nic,
> -                                i == 0 ? "3" : NULL);
> -        }
> +        /* First PCNET device at PCI_DEVFN(3, 0) */
> +        pci_init_nic_in_slot(pci_bus, mc->default_nic, NULL, "3");
> +        pci_init_nic_devices(pci_bus, mc->default_nic);
>       }
>   
>       /* Prepare firmware configuration for OpenBIOS */

Fine for me ... Hervé, could you maybe comment from a 40p point of view, too?

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

Patch

diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 137276bcb9..1a6cd05c61 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -241,7 +241,6 @@  static void ibm_40p_init(MachineState *machine)
     ISADevice *isa_dev;
     ISABus *isa_bus;
     void *fw_cfg;
-    int i;
     uint32_t kernel_base = 0, initrd_base = 0;
     long kernel_size = 0, initrd_size = 0;
     char boot_device;
@@ -336,10 +335,9 @@  static void ibm_40p_init(MachineState *machine)
         /* XXX: s3-trio at PCI_DEVFN(2, 0) */
         pci_vga_init(pci_bus);
 
-        for (i = 0; i < nb_nics; i++) {
-            pci_nic_init_nofail(&nd_table[i], pci_bus, mc->default_nic,
-                                i == 0 ? "3" : NULL);
-        }
+        /* First PCNET device at PCI_DEVFN(3, 0) */
+        pci_init_nic_in_slot(pci_bus, mc->default_nic, NULL, "3");
+        pci_init_nic_devices(pci_bus, mc->default_nic);
     }
 
     /* Prepare firmware configuration for OpenBIOS */