[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [Qemu-devel] [PATCH 07/19] aspeed: add support for multip
From: |
Cédric Le Goater |
Subject: |
Re: [Qemu-arm] [Qemu-devel] [PATCH 07/19] aspeed: add support for multiple NICs |
Date: |
Sun, 26 May 2019 19:10:33 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 26/05/2019 03:01, Keno Fischer wrote:
> Drive by comment, since I spotted this in my inbox.
> When I tried to make this change (two years ago though),
> I additionally needed the following. Unfortunately, I don't quite remember
> exactly what the issue was, but I think qemu would crash trying to create more
> than one nic.
Yes.
The fix was :
http://patchwork.ozlabs.org/patch/1102295/
Thanks,
C.
> ---
> hw/net/ftgmac100.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index 8127d0532dc..1318de85a4e 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -977,7 +977,8 @@ static void ftgmac100_realize(DeviceState *dev,
> Error **errp)
> sysbus_init_irq(sbd, &s->irq);
> qemu_macaddr_default_if_unset(&s->conf.macaddr);
>
> - s->conf.peers.ncs[0] = nd_table[0].netdev;
> + char *netdev_id = object_property_get_str(OBJECT(dev), "netdev", NULL);
> + s->conf.peers.ncs[0] = qemu_find_netdev(netdev_id);
>
> s->nic = qemu_new_nic(&net_ftgmac100_info, &s->conf,
> object_get_typename(OBJECT(dev)), DEVICE(dev)->id,
>
>
>
> On Sat, May 25, 2019 at 11:22 AM Cédric Le Goater <address@hidden> wrote:
>>
>> The Aspeed SoCs have two MACs. Extend the Aspeed model to support a
>> second NIC.
>>
>> Signed-off-by: Cédric Le Goater <address@hidden>
>> ---
>> include/hw/arm/aspeed_soc.h | 3 ++-
>> hw/arm/aspeed_soc.c | 33 +++++++++++++++++++--------------
>> 2 files changed, 21 insertions(+), 15 deletions(-)
>>
>> diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
>> index 7247f6da2505..e8556abf4737 100644
>> --- a/include/hw/arm/aspeed_soc.h
>> +++ b/include/hw/arm/aspeed_soc.h
>> @@ -25,6 +25,7 @@
>> #define ASPEED_SPIS_NUM 2
>> #define ASPEED_WDTS_NUM 3
>> #define ASPEED_CPUS_NUM 2
>> +#define ASPEED_MACS_NUM 2
>>
>> typedef struct AspeedSoCState {
>> /*< private >*/
>> @@ -42,7 +43,7 @@ typedef struct AspeedSoCState {
>> AspeedSMCState spi[ASPEED_SPIS_NUM];
>> AspeedSDMCState sdmc;
>> AspeedWDTState wdt[ASPEED_WDTS_NUM];
>> - FTGMAC100State ftgmac100;
>> + FTGMAC100State ftgmac100[ASPEED_MACS_NUM];
>> } AspeedSoCState;
>>
>> #define TYPE_ASPEED_SOC "aspeed-soc"
>> diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
>> index b983d5efc5d1..8cfe9e9515ed 100644
>> --- a/hw/arm/aspeed_soc.c
>> +++ b/hw/arm/aspeed_soc.c
>> @@ -229,8 +229,10 @@ static void aspeed_soc_init(Object *obj)
>> sc->info->silicon_rev);
>> }
>>
>> - sysbus_init_child_obj(obj, "ftgmac100", OBJECT(&s->ftgmac100),
>> - sizeof(s->ftgmac100), TYPE_FTGMAC100);
>> + for (i = 0; i < ASPEED_MACS_NUM; i++) {
>> + sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]),
>> + sizeof(s->ftgmac100[i]), TYPE_FTGMAC100);
>> + }
>> }
>>
>> static void aspeed_soc_realize(DeviceState *dev, Error **errp)
>> @@ -371,19 +373,22 @@ static void aspeed_soc_realize(DeviceState *dev, Error
>> **errp)
>> }
>>
>> /* Net */
>> - qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]);
>> - object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err);
>> - object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized",
>> - &local_err);
>> - error_propagate(&err, local_err);
>> - if (err) {
>> - error_propagate(errp, err);
>> - return;
>> + for (i = 0; i < nb_nics; i++) {
>> + qdev_set_nic_properties(DEVICE(&s->ftgmac100[i]), &nd_table[i]);
>> + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed",
>> + &err);
>> + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "realized",
>> + &local_err);
>> + error_propagate(&err, local_err);
>> + if (err) {
>> + error_propagate(errp, err);
>> + return;
>> + }
>> + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
>> + sc->info->memmap[ASPEED_ETH1 + i]);
>> + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
>> + aspeed_soc_get_irq(s, ASPEED_ETH1 + i));
>> }
>> - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0,
>> - sc->info->memmap[ASPEED_ETH1]);
>> - sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0,
>> - aspeed_soc_get_irq(s, ASPEED_ETH1));
>> }
>>
>> static void aspeed_soc_class_init(ObjectClass *oc, void *data)
>> --
>> 2.20.1
>>
>>
- [Qemu-arm] [PATCH 00/19] aspeed: machine extensions and fixes, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 01/19] hw/arm/aspeed: Use object_initialize_child for correct ref. counting, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 02/19] aspeed: add a per SoC mapping for the interrupt space, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 03/19] aspeed: add a per SoC mapping for the memory space, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 05/19] hw/arm/aspeed: Add RTC to SoC, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 04/19] hw: timer: Add ASPEED RTC device, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 06/19] aspeed: introduce a configurable number of CPU per machine, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 07/19] aspeed: add support for multiple NICs, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 08/19] aspeed/timer: Fix behaviour running Linux, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 09/19] aspeed/timer: Status register contains reload for stopped timer, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 10/19] aspeed/timer: Fix match calculations, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 11/19] aspeed/timer: Provide back-pressure information for short periods, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 19/19] aspeed/smc: Calculate checksum on normal DMA, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 18/19] aspeed/smc: inject errors in DMA checksum, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 17/19] aspeed/smc: add DMA calibration settings, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 15/19] aspeed: add a RAM memory region container, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 16/19] aspeed/smc: add support for DMAs, Cédric Le Goater, 2019/05/25
- [Qemu-arm] [PATCH 14/19] aspeed: remove the "ram" link, Cédric Le Goater, 2019/05/25