[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 28/47] hw/arm/npcm7xx: use qemu_configure_nic_device, allow em
From: |
David Woodhouse |
Subject: |
[PATCH v4 28/47] hw/arm/npcm7xx: use qemu_configure_nic_device, allow emc0/emc1 as aliases |
Date: |
Fri, 26 Jan 2024 17:25:05 +0000 |
From: David Woodhouse <dwmw@amazon.co.uk>
Also update the test to specify which device to attach the test socket
to, and remove the comment lamenting the fact that we can't do so.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/arm/npcm7xx.c | 16 +++++++++-------
tests/qtest/npcm7xx_emc-test.c | 18 ++++--------------
2 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
index 15ff21d047..ee395864e4 100644
--- a/hw/arm/npcm7xx.c
+++ b/hw/arm/npcm7xx.c
@@ -655,8 +655,9 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
/*
* EMC Modules. Cannot fail.
- * The mapping of the device to its netdev backend works as follows:
- * emc[i] = nd_table[i]
+ * Use the available NIC configurations in order, allowing 'emc0' and
+ * 'emc1' to by used as aliases for the model= parameter to override.
+ *
* This works around the inability to specify the netdev property for the
* emc device: it's not pluggable and thus the -device option can't be
* used.
@@ -664,12 +665,13 @@ static void npcm7xx_realize(DeviceState *dev, Error
**errp)
QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_emc_addr) != ARRAY_SIZE(s->emc));
QEMU_BUILD_BUG_ON(ARRAY_SIZE(s->emc) != 2);
for (i = 0; i < ARRAY_SIZE(s->emc); i++) {
- s->emc[i].emc_num = i;
SysBusDevice *sbd = SYS_BUS_DEVICE(&s->emc[i]);
- if (nd_table[i].used) {
- qemu_check_nic_model(&nd_table[i], TYPE_NPCM7XX_EMC);
- qdev_set_nic_properties(DEVICE(sbd), &nd_table[i]);
- }
+ char alias[6];
+
+ s->emc[i].emc_num = i;
+ snprintf(alias, sizeof(alias), "emc%u", i);
+ qemu_configure_nic_device(DEVICE(sbd), true, alias);
+
/*
* The device exists regardless of whether it's connected to a QEMU
* netdev backend. So always instantiate it even if there is no
diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c
index b046f1d76a..f7646fae2c 100644
--- a/tests/qtest/npcm7xx_emc-test.c
+++ b/tests/qtest/npcm7xx_emc-test.c
@@ -225,21 +225,11 @@ static int *packet_test_init(int module_num, GString
*cmd_line)
g_assert_cmpint(ret, != , -1);
/*
- * KISS and use -nic. We specify two nics (both emc{0,1}) because there's
- * currently no way to specify only emc1: The driver implicitly relies on
- * emc[i] == nd_table[i].
+ * KISS and use -nic. The driver accepts 'emc0' and 'emc1' as aliases
+ * in the 'model' field to specify the device to match.
*/
- if (module_num == 0) {
- g_string_append_printf(cmd_line,
- " -nic socket,fd=%d,model=" TYPE_NPCM7XX_EMC " "
- " -nic user,model=" TYPE_NPCM7XX_EMC " ",
- test_sockets[1]);
- } else {
- g_string_append_printf(cmd_line,
- " -nic user,model=" TYPE_NPCM7XX_EMC " "
- " -nic socket,fd=%d,model=" TYPE_NPCM7XX_EMC "
",
- test_sockets[1]);
- }
+ g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d ",
+ test_sockets[1], module_num);
g_test_queue_destroy(packet_test_clear, test_sockets);
return test_sockets;
--
2.43.0
- [PATCH v4 45/47] hw/pci: remove pci_nic_init_nofail(), (continued)
- [PATCH v4 45/47] hw/pci: remove pci_nic_init_nofail(), David Woodhouse, 2024/01/26
- [PATCH v4 08/47] hw/arm/sbsa-ref: use pci_init_nic_devices(), David Woodhouse, 2024/01/26
- [PATCH v4 15/47] hw/ppc/prep: use pci_init_nic_devices(), David Woodhouse, 2024/01/26
- [PATCH v4 43/47] hw/xtensa/xtfpga: use qemu_create_nic_device(), David Woodhouse, 2024/01/26
- [PATCH v4 42/47] hw/sparc/sun4m: use qemu_find_nic_info(), David Woodhouse, 2024/01/26
- [PATCH v4 09/47] hw/arm/virt: use pci_init_nic_devices(), David Woodhouse, 2024/01/26
- [PATCH v4 01/47] net: add qemu_{configure, create}_nic_device(), qemu_find_nic_info(), David Woodhouse, 2024/01/26
- [PATCH v4 23/47] hw/arm/exynos4: use qemu_create_nic_device(), David Woodhouse, 2024/01/26
- [PATCH v4 06/47] hw/xen: use qemu_create_nic_bus_devices() to instantiate Xen NICs, David Woodhouse, 2024/01/26
- [PATCH v4 32/47] hw/m68k/mcf5208: use qemu_create_nic_device(), David Woodhouse, 2024/01/26
- [PATCH v4 28/47] hw/arm/npcm7xx: use qemu_configure_nic_device, allow emc0/emc1 as aliases,
David Woodhouse <=
- [PATCH v4 27/47] hw/arm/highbank: use qemu_create_nic_device(), David Woodhouse, 2024/01/26
- [PATCH v4 11/47] hw/loongarch: use pci_init_nic_devices(), David Woodhouse, 2024/01/26
- [PATCH v4 03/47] net: add qemu_create_nic_bus_devices(), David Woodhouse, 2024/01/26
- [PATCH v4 34/47] hw/microblaze: use qemu_configure_nic_device(), David Woodhouse, 2024/01/26
- [PATCH v4 19/47] hw/sparc64/sun4u: use pci_init_nic_devices(), David Woodhouse, 2024/01/26
- [PATCH v4 18/47] hw/sh4/r2d: use pci_init_nic_devices(), David Woodhouse, 2024/01/26
- [PATCH v4 05/47] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2024/01/26
- [PATCH v4 21/47] hw/arm/allwinner: use qemu_configure_nic_device(), David Woodhouse, 2024/01/26
- [PATCH v4 04/47] hw/pci: add pci_init_nic_devices(), pci_init_nic_in_slot(), David Woodhouse, 2024/01/26
- [PATCH v4 25/47] hw/net/smc91c111: use qemu_configure_nic_device(), David Woodhouse, 2024/01/26