qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 07/19] aspeed: add support for multiple NICs


From: Cédric Le Goater
Subject: Re: [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
>>
>>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]