qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Marcel Apfelbaum <marcel@redhat.com>,
	Aurelien Jarno <aurelien@aurel32.net>,
	Yongbok Kim <yongbok.kim@imgtec.com>,
	Alexander Graf <agraf@suse.de>, Jason Wang <jasowang@redhat.com>,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 27/34] hw/pci: declare pci_nic_init_nofail() in "hw/net/pci.h"
Date: Sat, 23 Sep 2017 15:12:27 +1000	[thread overview]
Message-ID: <20170923051227.GB4998@umbus.fritz.box> (raw)
In-Reply-To: <20170922160111.31885-5-f4bug@amsat.org>

[-- Attachment #1: Type: text/plain, Size: 9869 bytes --]

On Fri, Sep 22, 2017 at 01:01:04PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

ppc portions

Acked-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  hw/pci/pci_internal.h | 16 +++++++++++
>  include/hw/net/pci.h  | 20 +++++++++++++
>  include/hw/pci/pci.h  |  4 ---
>  hw/arm/virt.c         |  1 +
>  hw/mips/mips_malta.c  |  1 +
>  hw/pci/pci.c          | 67 ++------------------------------------------
>  hw/pci/pci_nic.c      | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/ppc/e500.c         |  1 +
>  hw/ppc/spapr.c        |  1 +
>  hw/pci/Makefile.objs  |  1 +
>  10 files changed, 120 insertions(+), 69 deletions(-)
>  create mode 100644 hw/pci/pci_internal.h
>  create mode 100644 include/hw/net/pci.h
>  create mode 100644 hw/pci/pci_nic.c
> 
> diff --git a/hw/pci/pci_internal.h b/hw/pci/pci_internal.h
> new file mode 100644
> index 0000000000..d967468767
> --- /dev/null
> +++ b/hw/pci/pci_internal.h
> @@ -0,0 +1,16 @@
> +/*
> + * QEMU PCI internal
> + *
> + * Copyright (c) 2005 Fabrice Bellard
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +#ifndef QEMU_HW_PCI_INTERNAL_H
> +#define QEMU_HW_PCI_INTERNAL_H
> +
> +#include "hw/pci/pci_bus.h"
> +
> +PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root, const char *devaddr);
> +
> +#endif
> diff --git a/include/hw/net/pci.h b/include/hw/net/pci.h
> new file mode 100644
> index 0000000000..529591b7f3
> --- /dev/null
> +++ b/include/hw/net/pci.h
> @@ -0,0 +1,20 @@
> +/*
> + * QEMU network devices
> + *
> + * Copyright (c) 2005 Fabrice Bellard
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +#ifndef QEMU_HW_NET_PCI_H
> +#define QEMU_HW_NET_PCI_H
> +
> +#include "net/net.h"
> +#include "hw/pci/pci.h"
> +#include "hw/pci/pci_bus.h"
> +
> +PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
> +                               const char *default_model,
> +                               const char *default_devaddr);
> +
> +#endif
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index aa7ef9cf69..6a0f7b5472 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -422,10 +422,6 @@ void pci_device_set_intx_routing_notifier(PCIDevice *dev,
>                                            PCIINTxRoutingNotifier notifier);
>  void pci_device_reset(PCIDevice *dev);
>  
> -PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
> -                               const char *default_model,
> -                               const char *default_devaddr);
> -
>  PCIDevice *pci_vga_init(PCIBus *bus);
>  
>  int pci_bus_num(PCIBus *s);
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 9e18b410d7..39fab3acb9 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -35,6 +35,7 @@
>  #include "hw/arm/primecell.h"
>  #include "hw/arm/virt.h"
>  #include "hw/devices.h"
> +#include "hw/net/pci.h"
>  #include "net/net.h"
>  #include "sysemu/block-backend.h"
>  #include "sysemu/device_tree.h"
> diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
> index 6945fa47c3..fb6a2f9363 100644
> --- a/hw/mips/mips_malta.c
> +++ b/hw/mips/mips_malta.c
> @@ -48,6 +48,7 @@
>  #include "hw/timer/mc146818rtc.h"
>  #include "hw/input/i8042.h"
>  #include "hw/timer/i8254.h"
> +#include "hw/net/pci.h"
>  #include "sysemu/blockdev.h"
>  #include "exec/address-spaces.h"
>  #include "hw/sysbus.h"             /* SysBusDevice */
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 1e6fb88eba..9b678c8fd0 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -28,7 +28,6 @@
>  #include "hw/pci/pci_bus.h"
>  #include "hw/pci/pci_host.h"
>  #include "monitor/monitor.h"
> -#include "net/net.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/loader.h"
>  #include "qemu/error-report.h"
> @@ -41,6 +40,7 @@
>  #include "hw/hotplug.h"
>  #include "hw/boards.h"
>  #include "qemu/cutils.h"
> +#include "pci_internal.h"
>  
>  //#define DEBUG_PCI
>  #ifdef DEBUG_PCI
> @@ -671,8 +671,7 @@ static int pci_parse_devaddr(const char *addr, int *domp, int *busp,
>      return 0;
>  }
>  
> -static PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root,
> -                                 const char *devaddr)
> +PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root, const char *devaddr)
>  {
>      int dom, bus;
>      unsigned slot;
> @@ -1812,68 +1811,6 @@ PciInfoList *qmp_query_pci(Error **errp)
>      return head;
>  }
>  
> -static const char * const pci_nic_models[] = {
> -    "ne2k_pci",
> -    "i82551",
> -    "i82557b",
> -    "i82559er",
> -    "rtl8139",
> -    "e1000",
> -    "pcnet",
> -    "virtio",
> -    "sungem",
> -    NULL
> -};
> -
> -static const char * const pci_nic_names[] = {
> -    "ne2k_pci",
> -    "i82551",
> -    "i82557b",
> -    "i82559er",
> -    "rtl8139",
> -    "e1000",
> -    "pcnet",
> -    "virtio-net-pci",
> -    "sungem",
> -    NULL
> -};
> -
> -/* Initialize a PCI NIC.  */
> -PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
> -                               const char *default_model,
> -                               const char *default_devaddr)
> -{
> -    const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr;
> -    PCIBus *bus;
> -    PCIDevice *pci_dev;
> -    DeviceState *dev;
> -    int devfn;
> -    int i;
> -
> -    if (qemu_show_nic_models(nd->model, pci_nic_models)) {
> -        exit(0);
> -    }
> -
> -    i = qemu_find_nic_model(nd, pci_nic_models, default_model);
> -    if (i < 0) {
> -        exit(1);
> -    }
> -
> -    bus = pci_get_bus_devfn(&devfn, rootbus, devaddr);
> -    if (!bus) {
> -        error_report("Invalid PCI device address %s for device %s",
> -                     devaddr, pci_nic_names[i]);
> -        exit(1);
> -    }
> -
> -    pci_dev = pci_create(bus, devfn, pci_nic_names[i]);
> -    dev = &pci_dev->qdev;
> -    qdev_set_nic_properties(dev, nd);
> -    qdev_init_nofail(dev);
> -
> -    return pci_dev;
> -}
> -
>  PCIDevice *pci_vga_init(PCIBus *bus)
>  {
>      switch (vga_interface_type) {
> diff --git a/hw/pci/pci_nic.c b/hw/pci/pci_nic.c
> new file mode 100644
> index 0000000000..fb1a10ff12
> --- /dev/null
> +++ b/hw/pci/pci_nic.c
> @@ -0,0 +1,77 @@
> +/*
> + * QEMU PCI network interface
> + *
> + * Copyright (c) 2004 Fabrice Bellard
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +#include "qemu/osdep.h"
> +#include "qemu/error-report.h"
> +#include "hw/pci/pci.h"
> +#include "hw/pci/pci_bus.h"
> +#include "hw/net/pci.h"
> +#include "net/net.h"
> +#include "pci_internal.h"
> +
> +static const char *const pci_nic_models[] = {
> +    "ne2k_pci",
> +    "i82551",
> +    "i82557b",
> +    "i82559er",
> +    "rtl8139",
> +    "e1000",
> +    "pcnet",
> +    "virtio",
> +    "sungem",
> +    NULL
> +};
> +
> +static const char *const pci_nic_names[] = {
> +    "ne2k_pci",
> +    "i82551",
> +    "i82557b",
> +    "i82559er",
> +    "rtl8139",
> +    "e1000",
> +    "pcnet",
> +    "virtio-net-pci",
> +    "sungem",
> +    NULL
> +};
> +
> +/* Initialize a PCI NIC.  */
> +PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
> +                               const char *default_model,
> +                               const char *default_devaddr)
> +{
> +    const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr;
> +    PCIBus *bus;
> +    PCIDevice *pci_dev;
> +    DeviceState *dev;
> +    int devfn;
> +    int i;
> +
> +    if (qemu_show_nic_models(nd->model, pci_nic_models)) {
> +        exit(0);
> +    }
> +
> +    i = qemu_find_nic_model(nd, pci_nic_models, default_model);
> +    if (i < 0) {
> +        exit(1);
> +    }
> +
> +    bus = pci_get_bus_devfn(&devfn, rootbus, devaddr);
> +    if (!bus) {
> +        error_report("Invalid PCI device address %s for device %s",
> +                     devaddr, pci_nic_names[i]);
> +        exit(1);
> +    }
> +
> +    pci_dev = pci_create(bus, devfn, pci_nic_names[i]);
> +    dev = &pci_dev->qdev;
> +    qdev_set_nic_properties(dev, nd);
> +    qdev_init_nofail(dev);
> +
> +    return pci_dev;
> +}
> diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
> index db0e49ab8f..482757ca7b 100644
> --- a/hw/ppc/e500.c
> +++ b/hw/ppc/e500.c
> @@ -24,6 +24,7 @@
>  #include "hw/hw.h"
>  #include "hw/char/serial.h"
>  #include "hw/pci/pci.h"
> +#include "hw/net/pci.h"
>  #include "hw/boards.h"
>  #include "sysemu/sysemu.h"
>  #include "sysemu/kvm.h"
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 17ea77618c..96007051e2 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -56,6 +56,7 @@
>  #include "hw/pci-host/spapr.h"
>  #include "hw/ppc/xics.h"
>  #include "hw/pci/msi.h"
> +#include "hw/net/pci.h"
>  
>  #include "hw/pci/pci.h"
>  #include "hw/scsi/scsi.h"
> diff --git a/hw/pci/Makefile.objs b/hw/pci/Makefile.objs
> index 9f905e6344..125428fd54 100644
> --- a/hw/pci/Makefile.objs
> +++ b/hw/pci/Makefile.objs
> @@ -1,4 +1,5 @@
>  common-obj-$(CONFIG_PCI) += pci.o pci_bridge.o
> +common-obj-$(CONFIG_PCI) += pci_nic.o
>  common-obj-$(CONFIG_PCI) += msix.o msi.o
>  common-obj-$(CONFIG_PCI) += shpc.o
>  common-obj-$(CONFIG_PCI) += slotid_cap.o

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-09-23  5:29 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22 15:39 [Qemu-devel] [PATCH 00/34] remove i386/pc dependency from non-PC world (part 1) Philippe Mathieu-Daudé
2017-09-22 15:39 ` [Qemu-devel] [PATCH 01/34] hw: use "qemu/osdep.h" as first #include in source files Philippe Mathieu-Daudé
2017-09-22 16:06   ` Peter Maydell
2017-09-23  5:08   ` David Gibson
2017-09-25  8:10   ` Cornelia Huck
2017-09-22 15:39 ` [Qemu-devel] [PATCH 02/34] hw: remove "qemu/osdep.h" from header files Philippe Mathieu-Daudé
2017-09-22 16:07   ` Peter Maydell
2017-09-22 16:54     ` Corey Minyard
2017-09-22 17:58     ` Philippe Mathieu-Daudé
2017-09-22 15:39 ` [Qemu-devel] [PATCH 03/34] block: remove "qemu/osdep.h" from header file Philippe Mathieu-Daudé
2017-09-22 16:32   ` Peter Maydell
2017-09-22 15:39 ` [Qemu-devel] [PATCH 04/34] misc: remove headers implicitly included Philippe Mathieu-Daudé
2017-09-22 16:31   ` Peter Maydell
2017-09-25  9:01   ` Stefan Hajnoczi
2017-09-22 15:39 ` [Qemu-devel] [PATCH 05/34] misc: remove duplicated includes Philippe Mathieu-Daudé
2017-09-22 16:39   ` Peter Maydell
2017-09-25  8:12   ` Cornelia Huck
2017-10-10 15:37   ` Anthony PERARD
2017-09-22 15:39 ` [Qemu-devel] [PATCH 06/34] ppc: " Philippe Mathieu-Daudé
2017-09-22 16:39   ` Peter Maydell
2017-09-23  5:31   ` David Gibson
2017-09-22 15:39 ` [Qemu-devel] [PATCH 07/34] i386/hax: " Philippe Mathieu-Daudé
2017-09-22 16:42   ` Peter Maydell
2017-09-22 15:39 ` [Qemu-devel] [PATCH 08/34] nios2: " Philippe Mathieu-Daudé
2017-09-22 16:44   ` Peter Maydell
2017-09-22 15:39 ` [Qemu-devel] [PATCH 09/34] misc: avoid "include/" in include path Philippe Mathieu-Daudé
2017-09-22 16:46   ` Peter Maydell
2017-09-22 15:39 ` [Qemu-devel] [PATCH 10/34] amd_iommu: avoid needless includes in header file Philippe Mathieu-Daudé
2017-09-25  5:13   ` Thomas Huth
2017-09-22 15:39 ` [Qemu-devel] [PATCH 11/34] i386/pc: use TYPE_PORT92 Philippe Mathieu-Daudé
2017-09-25  5:16   ` Thomas Huth
2017-09-22 15:39 ` [Qemu-devel] [PATCH 12/34] misc: remove old i386 dependency Philippe Mathieu-Daudé
2017-09-25  5:15   ` Thomas Huth
2017-10-10 15:37   ` Anthony PERARD
2017-09-22 15:39 ` [Qemu-devel] [PATCH 13/34] hw/ide: " Philippe Mathieu-Daudé
2017-09-22 18:03   ` John Snow
2017-09-22 15:39 ` [Qemu-devel] [PATCH 14/34] hw/ipmi: " Philippe Mathieu-Daudé
2017-09-22 16:58   ` Corey Minyard
2017-09-22 15:39 ` [Qemu-devel] [PATCH 15/34] hw/i2c: " Philippe Mathieu-Daudé
2017-09-25  5:17   ` Thomas Huth
2017-09-22 15:39 ` [Qemu-devel] [PATCH 16/34] hw/tpm: " Philippe Mathieu-Daudé
2017-09-22 16:05   ` Stefan Berger
2017-09-22 15:39 ` [Qemu-devel] [PATCH 17/34] hw/virtio-balloon: " Philippe Mathieu-Daudé
2017-09-25  5:23   ` Thomas Huth
2017-09-22 15:39 ` [Qemu-devel] [PATCH 18/34] hw/unicore32: restrict hw addr defines to source file Philippe Mathieu-Daudé
2017-09-25  5:19   ` Thomas Huth
2017-09-22 15:39 ` [Qemu-devel] [PATCH 19/34] hw/acpi: ACPI_PM_* defines are not restricted to i386 arch Philippe Mathieu-Daudé
2017-09-22 15:40 ` [Qemu-devel] [PATCH 20/34] hw/timer/i8254: rename pit_init() -> i8254_pit_init() Philippe Mathieu-Daudé
2017-09-22 20:09   ` Hervé Poussineau
2017-09-22 15:40 ` [Qemu-devel] [PATCH 22/34] hw/input/i8042: extract API from hw/i386/pc.h Philippe Mathieu-Daudé
2017-09-22 20:10   ` Hervé Poussineau
2017-09-23  5:09   ` David Gibson
2017-09-22 16:01 ` [Qemu-devel] [PATCH 23/34] hw/dma/i8257: rename DMA_init() to i8257_dma_init() Philippe Mathieu-Daudé
2017-09-22 17:43   ` Hervé Poussineau
2017-09-22 18:08     ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
2017-10-06 12:09       ` Eduardo Otubo"
2017-09-22 16:01 ` [Qemu-devel] [PATCH 24/34] hw/timer/mc146818: rename rtc_init() -> mc146818_init() Philippe Mathieu-Daudé
2017-09-22 20:11   ` Hervé Poussineau
2017-09-23  5:10   ` David Gibson
2017-09-22 16:01 ` [Qemu-devel] [PATCH 25/34] hw/timer/m48t59: use TYPE_M48T59_ISA, add entries to MAINTAINERS Philippe Mathieu-Daudé
2017-09-22 20:12   ` Hervé Poussineau
2017-09-23  5:11   ` David Gibson
2017-09-22 16:01 ` [Qemu-devel] [PATCH 26/34] hw/net/ne2000: extract ne2k-isa code from i386/pc to ne2000-isa.c Philippe Mathieu-Daudé
2017-09-22 20:13   ` Hervé Poussineau
2017-09-23  5:11   ` David Gibson
2017-09-22 16:01 ` [Qemu-devel] [PATCH 27/34] hw/pci: declare pci_nic_init_nofail() in "hw/net/pci.h" Philippe Mathieu-Daudé
2017-09-23  5:12   ` David Gibson [this message]
2017-09-25 14:30   ` Marcel Apfelbaum
2017-10-02 18:38     ` Philippe Mathieu-Daudé
2017-10-17  0:24       ` Philippe Mathieu-Daudé
2017-09-22 16:01 ` [Qemu-devel] [PATCH 28/34] hw/net/e1000: use TYPE_PCI_E1000 Philippe Mathieu-Daudé
2017-09-23  5:13   ` David Gibson
2017-09-22 16:01 ` [Qemu-devel] [PATCH 29/34] hw/net/e1000e: use TYPE_PCI_E1000E Philippe Mathieu-Daudé
2017-09-25  5:34   ` Thomas Huth
2017-09-22 16:01 ` [Qemu-devel] [PATCH 30/34] hw/net/pcnet: use TYPE_PCI_PCNET Philippe Mathieu-Daudé
2017-09-22 20:13   ` Hervé Poussineau
2017-09-23  5:14   ` David Gibson
2017-09-22 16:01 ` [Qemu-devel] [PATCH 31/34] hw/net/rtl8139: use TYPE_PCI_RTL8139 Philippe Mathieu-Daudé
2017-09-25  5:36   ` Thomas Huth
2017-09-22 16:01 ` [Qemu-devel] [PATCH 32/34] hw/net/ne2000: use TYPE_PCI_NE2000 Philippe Mathieu-Daudé
2017-09-22 20:14   ` Hervé Poussineau
2017-09-23  5:14   ` David Gibson
2017-09-22 16:01 ` [Qemu-devel] [PATCH 33/34] hw/alpha: remove old i386 dependency Philippe Mathieu-Daudé
2017-09-25  5:38   ` Thomas Huth
2017-10-02 18:52     ` Philippe Mathieu-Daudé
2017-10-02 19:03   ` Richard Henderson
2017-10-06 12:27     ` Philippe Mathieu-Daudé
2017-09-22 16:01 ` [Qemu-devel] [PATCH 34/34] misc: drop " Philippe Mathieu-Daudé
2017-09-25  5:40   ` Thomas Huth
     [not found] ` <20170922154014.29350-22-f4bug@amsat.org>
2017-09-22 20:10   ` [Qemu-devel] [PATCH 21/34] hw/display/vga: remove the old i386/pc dependency Hervé Poussineau
2017-10-16 19:44 ` [Qemu-devel] [PATCH 00/34] remove i386/pc dependency from non-PC world (part 1) Michael Tokarev
2017-10-16 22:49   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170923051227.GB4998@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=aurelien@aurel32.net \
    --cc=f4bug@amsat.org \
    --cc=jasowang@redhat.com \
    --cc=marcel@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=yongbok.kim@imgtec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).