diff mbox

[RFC,v2,1/6] hw/arm/virt: add a xgmac device

Message ID 1397057589-11779-2-git-send-email-eric.auger@linaro.org
State New
Headers show

Commit Message

Auger Eric April 9, 2014, 3:33 p.m. UTC
From: Kim Phillips <kim.phillips@linaro.org>

This is a hack and only serves as an example of what needs to be
done to make the next RFC - add vfio-platform support - work
for development purposes on a Calxeda Midway system.  We don't want
mach-virt to always create this ethernet device - DO NOT APPLY, etc.

Initial attempts to convince QEMU to create a memory mapped device
on the command line (e.g., -device vfio-platform,name=fff51000.ethernet)
would fail with "Parameter 'driver' expects pluggable device type".
Any guidance as to how to overcome this apparent design limitation
is welcome.

RAM is reduced from 30 to 1GiB such as to not overlap the xgmac device's
physical address.  Not sure if the 30GiB RAM (or whatever the user sets
it to with -m) could be set up above 0x1_0000_0000, but there is probably
extra work needed to resolve this type of conflict.

note: vfio-platform interrupt support development may want interrupt
property data filled; here it's omitted for the time being.

Not-signed-off-by: Kim Phillips <kim.phillips@linaro.org>
---
 hw/arm/virt.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

Comments

Peter Crosthwaite April 10, 2014, 1:26 p.m. UTC | #1
On Thu, Apr 10, 2014 at 1:33 AM, Eric Auger <eric.auger@linaro.org> wrote:
> From: Kim Phillips <kim.phillips@linaro.org>
>
> This is a hack and only serves as an example of what needs to be
> done to make the next RFC - add vfio-platform support - work
> for development purposes on a Calxeda Midway system.  We don't want
> mach-virt to always create this ethernet device - DO NOT APPLY, etc.
>
> Initial attempts to convince QEMU to create a memory mapped device
> on the command line (e.g., -device vfio-platform,name=fff51000.ethernet)
> would fail with "Parameter 'driver' expects pluggable device type".

Alistair is working on this. cc.

Regards,
Peter

> Any guidance as to how to overcome this apparent design limitation
> is welcome.
>
> RAM is reduced from 30 to 1GiB such as to not overlap the xgmac device's
> physical address.  Not sure if the 30GiB RAM (or whatever the user sets
> it to with -m) could be set up above 0x1_0000_0000, but there is probably
> extra work needed to resolve this type of conflict.
>
> note: vfio-platform interrupt support development may want interrupt
> property data filled; here it's omitted for the time being.
>
> Not-signed-off-by: Kim Phillips <kim.phillips@linaro.org>
> ---
>  hw/arm/virt.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 2bbc931..5d43cf0 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -65,6 +65,7 @@ enum {
>      VIRT_GIC_CPU,
>      VIRT_UART,
>      VIRT_MMIO,
> +    VIRT_ETHERNET,
>  };
>
>  typedef struct MemMapEntry {
> @@ -106,7 +107,8 @@ static const MemMapEntry a15memmap[] = {
>      [VIRT_MMIO] = { 0xa000000, 0x200 },
>      /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
>      /* 0x10000000 .. 0x40000000 reserved for PCI */
> -    [VIRT_MEM] = { 0x40000000, 30ULL * 1024 * 1024 * 1024 },
> +    [VIRT_MEM] = { 0x40000000, 1ULL * 1024 * 1024 * 1024 },
> +    [VIRT_ETHERNET] = { 0xfff51000, 0x1000 },
>  };
>
>  static const int a15irqmap[] = {
> @@ -291,6 +293,25 @@ static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic)
>      g_free(nodename);
>  }
>
> +static void create_ethernet(const VirtBoardInfo *vbi, qemu_irq *pic)
> +{
> +    char *nodename;
> +    hwaddr base = vbi->memmap[VIRT_ETHERNET].base;
> +    hwaddr size = vbi->memmap[VIRT_ETHERNET].size;
> +    const char compat[] = "calxeda,hb-xgmac";
> +
> +    sysbus_create_simple("vfio-platform", base, NULL);
> +
> +    nodename = g_strdup_printf("/ethernet@%" PRIx64, base);
> +    qemu_fdt_add_subnode(vbi->fdt, nodename);
> +
> +    /* Note that we can't use setprop_string because of the embedded NUL */
> +    qemu_fdt_setprop(vbi->fdt, nodename, "compatible", compat, sizeof(compat));
> +    qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", 2, base, 2, size);
> +
> +    g_free(nodename);
> +}
> +
>  static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic)
>  {
>      int i;
> @@ -425,6 +446,7 @@ static void machvirt_init(QEMUMachineInitArgs *args)
>      }
>
>      create_uart(vbi, pic);
> +    create_ethernet(vbi, pic);
>
>      /* Create mmio transports, so the user can create virtio backends
>       * (which will be automatically plugged in to the transports). If
> --
> 1.8.3.2
>
>
Alexander Graf April 10, 2014, 1:48 p.m. UTC | #2
On 10.04.14 15:26, Peter Crosthwaite wrote:
> On Thu, Apr 10, 2014 at 1:33 AM, Eric Auger <eric.auger@linaro.org> wrote:
>> From: Kim Phillips <kim.phillips@linaro.org>
>>
>> This is a hack and only serves as an example of what needs to be
>> done to make the next RFC - add vfio-platform support - work
>> for development purposes on a Calxeda Midway system.  We don't want
>> mach-virt to always create this ethernet device - DO NOT APPLY, etc.
>>
>> Initial attempts to convince QEMU to create a memory mapped device
>> on the command line (e.g., -device vfio-platform,name=fff51000.ethernet)
>> would fail with "Parameter 'driver' expects pluggable device type".
> Alistair is working on this. cc.

Alaistair, I've had patches tackle this on the mailing list a few months 
ago and received good comments from Anthony on what to change. How far 
in are you already? I'd like to make sure we're on the same page here 
(and don't duplicate work).


Alex
Alistair Francis April 11, 2014, 5:41 a.m. UTC | #3
On Thu, Apr 10, 2014 at 11:48 PM, Alexander Graf <agraf@suse.de> wrote:
>
> On 10.04.14 15:26, Peter Crosthwaite wrote:
>>
>> On Thu, Apr 10, 2014 at 1:33 AM, Eric Auger <eric.auger@linaro.org> wrote:
>>>
>>> From: Kim Phillips <kim.phillips@linaro.org>
>>>
>>> This is a hack and only serves as an example of what needs to be
>>> done to make the next RFC - add vfio-platform support - work
>>> for development purposes on a Calxeda Midway system.  We don't want
>>> mach-virt to always create this ethernet device - DO NOT APPLY, etc.
>>>
>>> Initial attempts to convince QEMU to create a memory mapped device
>>> on the command line (e.g., -device vfio-platform,name=fff51000.ethernet)
>>> would fail with "Parameter 'driver' expects pluggable device type".
>>
>> Alistair is working on this. cc.
>
>
> Alaistair, I've had patches tackle this on the mailing list a few months ago
> and received good comments from Anthony on what to change. How far in are
> you already? I'd like to make sure we're on the same page here (and don't
> duplicate work).
>
>
> Alex
>
>

Hey Alex,

I have a patch I'm about to send to the mailing list. It allows an
entire machine to be added by the -device argument on the command
line. It is a similar implementation to my first version (vl.c: Allow
sysbus devices to be attached via commandline), but much more generic.

Could you point me to your patches so I can compare? At the moment I
don't have much feedback to my implementation

Thanks,

Alistair
Alexander Graf April 11, 2014, 9:21 a.m. UTC | #4
On 11.04.14 07:41, Alistair Francis wrote:
> On Thu, Apr 10, 2014 at 11:48 PM, Alexander Graf <agraf@suse.de> wrote:
>> On 10.04.14 15:26, Peter Crosthwaite wrote:
>>> On Thu, Apr 10, 2014 at 1:33 AM, Eric Auger <eric.auger@linaro.org> wrote:
>>>> From: Kim Phillips <kim.phillips@linaro.org>
>>>>
>>>> This is a hack and only serves as an example of what needs to be
>>>> done to make the next RFC - add vfio-platform support - work
>>>> for development purposes on a Calxeda Midway system.  We don't want
>>>> mach-virt to always create this ethernet device - DO NOT APPLY, etc.
>>>>
>>>> Initial attempts to convince QEMU to create a memory mapped device
>>>> on the command line (e.g., -device vfio-platform,name=fff51000.ethernet)
>>>> would fail with "Parameter 'driver' expects pluggable device type".
>>> Alistair is working on this. cc.
>>
>> Alaistair, I've had patches tackle this on the mailing list a few months ago
>> and received good comments from Anthony on what to change. How far in are
>> you already? I'd like to make sure we're on the same page here (and don't
>> duplicate work).
>>
>>
>> Alex
>>
>>
> Hey Alex,
>
> I have a patch I'm about to send to the mailing list. It allows an
> entire machine to be added by the -device argument on the command
> line. It is a similar implementation to my first version (vl.c: Allow
> sysbus devices to be attached via commandline), but much more generic.
>
> Could you point me to your patches so I can compare? At the moment I
> don't have much feedback to my implementation

Sure. It's right here:

https://lists.gnu.org/archive/html/qemu-devel/2013-07/msg03614.html

But as you can see there was quite a bit of discussion on that thread on 
how to do it right.


Alex
Andreas Färber April 17, 2014, 11:33 a.m. UTC | #5
Am 11.04.2014 07:41, schrieb Alistair Francis:
> On Thu, Apr 10, 2014 at 11:48 PM, Alexander Graf <agraf@suse.de> wrote:
>> On 10.04.14 15:26, Peter Crosthwaite wrote:
>>> On Thu, Apr 10, 2014 at 1:33 AM, Eric Auger <eric.auger@linaro.org> wrote:
>>>>
>>>> Initial attempts to convince QEMU to create a memory mapped device
>>>> on the command line (e.g., -device vfio-platform,name=fff51000.ethernet)
>>>> would fail with "Parameter 'driver' expects pluggable device type".
>>>
>>> Alistair is working on this. cc.
>>
>> Alaistair, I've had patches tackle this on the mailing list a few months ago
>> and received good comments from Anthony on what to change. How far in are
>> you already? I'd like to make sure we're on the same page here (and don't
>> duplicate work).
> 
> Hey Alex,
> 
> I have a patch I'm about to send to the mailing list. It allows an
> entire machine to be added by the -device argument on the command
> line. It is a similar implementation to my first version (vl.c: Allow
> sysbus devices to be attached via commandline), but much more generic.
[...]
> At the moment I
> don't have much feedback to my implementation

Your implementation came at a time where many of us were still busy
contributing fixes to and testing the 2.0 release.

Regards,
Andreas
diff mbox

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 2bbc931..5d43cf0 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -65,6 +65,7 @@  enum {
     VIRT_GIC_CPU,
     VIRT_UART,
     VIRT_MMIO,
+    VIRT_ETHERNET,
 };
 
 typedef struct MemMapEntry {
@@ -106,7 +107,8 @@  static const MemMapEntry a15memmap[] = {
     [VIRT_MMIO] = { 0xa000000, 0x200 },
     /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
     /* 0x10000000 .. 0x40000000 reserved for PCI */
-    [VIRT_MEM] = { 0x40000000, 30ULL * 1024 * 1024 * 1024 },
+    [VIRT_MEM] = { 0x40000000, 1ULL * 1024 * 1024 * 1024 },
+    [VIRT_ETHERNET] = { 0xfff51000, 0x1000 },
 };
 
 static const int a15irqmap[] = {
@@ -291,6 +293,25 @@  static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic)
     g_free(nodename);
 }
 
+static void create_ethernet(const VirtBoardInfo *vbi, qemu_irq *pic)
+{
+    char *nodename;
+    hwaddr base = vbi->memmap[VIRT_ETHERNET].base;
+    hwaddr size = vbi->memmap[VIRT_ETHERNET].size;
+    const char compat[] = "calxeda,hb-xgmac";
+
+    sysbus_create_simple("vfio-platform", base, NULL);
+
+    nodename = g_strdup_printf("/ethernet@%" PRIx64, base);
+    qemu_fdt_add_subnode(vbi->fdt, nodename);
+
+    /* Note that we can't use setprop_string because of the embedded NUL */
+    qemu_fdt_setprop(vbi->fdt, nodename, "compatible", compat, sizeof(compat));
+    qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", 2, base, 2, size);
+
+    g_free(nodename);
+}
+
 static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic)
 {
     int i;
@@ -425,6 +446,7 @@  static void machvirt_init(QEMUMachineInitArgs *args)
     }
 
     create_uart(vbi, pic);
+    create_ethernet(vbi, pic);
 
     /* Create mmio transports, so the user can create virtio backends
      * (which will be automatically plugged in to the transports). If