* [Qemu-devel] [PATCH 05/34] misc: remove duplicated includes [not found] <20170922154014.29350-1-f4bug@amsat.org> @ 2017-09-22 15:39 ` Philippe Mathieu-Daudé 2017-09-22 16:39 ` [Qemu-arm] " Peter Maydell ` (2 more replies) 2017-09-22 16:01 ` [Qemu-arm] [PATCH 27/34] hw/pci: declare pci_nic_init_nofail() in "hw/net/pci.h" Philippe Mathieu-Daudé 2017-09-22 16:01 ` [Qemu-devel] [PATCH 31/34] hw/net/rtl8139: use TYPE_PCI_RTL8139 Philippe Mathieu-Daudé 2 siblings, 3 replies; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2017-09-22 15:39 UTC (permalink / raw) To: Peter Maydell, Thomas Huth, Paolo Bonzini, Peter Crosthwaite, Richard Henderson, Stefano Stabellini, Anthony Perard, Eduardo Habkost, Marcel Apfelbaum, Cornelia Huck, Christian Borntraeger, Alexander Graf, Stafford Horne, Marc-André Lureau, Daniel P. Berrange, Gerd Hoffmann Cc: qemu-trivial, qemu-arm, Philippe Mathieu-Daudé, qemu-devel exec: housekeeping (funny since 02d0e095031) applied using ./scripts/clean-includes Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- accel/tcg/translate-all.c | 1 - exec.c | 3 --- hw/arm/spitz.c | 1 - hw/char/xen_console.c | 1 - hw/core/machine.c | 1 - hw/s390x/css.c | 1 - target/openrisc/exception_helper.c | 1 - tests/vhost-user-test.c | 1 - util/qemu-sockets.c | 1 - vl.c | 1 - 10 files changed, 12 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 2d1ed06065..fb2ad21092 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -31,7 +31,6 @@ #include "tcg.h" #if defined(CONFIG_USER_ONLY) #include "qemu.h" -#include "exec/exec-all.h" #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include <sys/param.h> #if __FreeBSD_version >= 700104 diff --git a/exec.c b/exec.c index a25a4c6018..a1fe82189c 100644 --- a/exec.c +++ b/exec.c @@ -18,8 +18,6 @@ */ #include "qemu/osdep.h" #include "qapi/error.h" -#ifndef _WIN32 -#endif #include "qemu/cutils.h" #include "cpu.h" @@ -51,7 +49,6 @@ #include "trace-root.h" #ifdef CONFIG_FALLOCATE_PUNCH_HOLE -#include <fcntl.h> #include <linux/falloc.h> #endif diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c index feccdb00d3..ac1e15cbbc 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -29,7 +29,6 @@ #include "sysemu/block-backend.h" #include "hw/sysbus.h" #include "exec/address-spaces.h" -#include "sysemu/sysemu.h" #include "cpu.h" #undef REG_FMT diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index 3643dfe067..5e68326c19 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -27,7 +27,6 @@ #include "hw/hw.h" #include "chardev/char-fe.h" #include "hw/xen/xen_backend.h" -#include "qapi/error.h" #include <xen/io/console.h> diff --git a/hw/core/machine.c b/hw/core/machine.c index 80647edc2a..4ad0e9a082 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -20,7 +20,6 @@ #include "sysemu/numa.h" #include "qemu/error-report.h" #include "qemu/cutils.h" -#include "sysemu/numa.h" #include "sysemu/qtest.h" static char *machine_get_accel(Object *obj, Error **errp) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 75d4f301fb..3938fa5909 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -13,7 +13,6 @@ #include "qapi/error.h" #include "qapi/visitor.h" #include "hw/qdev.h" -#include "qemu/error-report.h" #include "qemu/bitops.h" #include "qemu/error-report.h" #include "exec/address-spaces.h" diff --git a/target/openrisc/exception_helper.c b/target/openrisc/exception_helper.c index a8a5f69b05..6073a5b21c 100644 --- a/target/openrisc/exception_helper.c +++ b/target/openrisc/exception_helper.c @@ -21,7 +21,6 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" #include "exception.h" void HELPER(exception)(CPUOpenRISCState *env, uint32_t excp) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 4b98018478..e2c89ed376 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -21,7 +21,6 @@ #include "libqos/libqos.h" #include "libqos/pci-pc.h" #include "libqos/virtio-pci.h" -#include "qapi/error.h" #include "libqos/malloc-pc.h" #include "hw/virtio/virtio-net.h" diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index d149383bb9..d700caef45 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -26,7 +26,6 @@ #include "qapi/error.h" #include "qemu/sockets.h" #include "qemu/main-loop.h" -#include "qapi/clone-visitor.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" #include "qapi-visit.h" diff --git a/vl.c b/vl.c index 88ae727486..d6cb6751e6 100644 --- a/vl.c +++ b/vl.c @@ -95,7 +95,6 @@ int main(int argc, char **argv) #include "sysemu/kvm.h" #include "sysemu/hax.h" #include "qapi/qobject-input-visitor.h" -#include "qapi/qobject-input-visitor.h" #include "qapi-visit.h" #include "qapi/qmp/qjson.h" #include "qemu/option.h" -- 2.14.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-arm] [PATCH 05/34] misc: remove duplicated includes 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 ` [Qemu-devel] " Anthony PERARD 2 siblings, 0 replies; 11+ messages in thread From: Peter Maydell @ 2017-09-22 16:39 UTC (permalink / raw) To: Philippe Mathieu-Daudé Cc: Thomas Huth, Stefano Stabellini, Daniel P. Berrange, Eduardo Habkost, QEMU Trivial, Cornelia Huck, Alexander Graf, QEMU Developers, Marcel Apfelbaum, qemu-arm, Gerd Hoffmann, Marc-André Lureau, Anthony Perard, Paolo Bonzini, Stafford Horne, Christian Borntraeger, Richard Henderson On 22 September 2017 at 16:39, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote: > exec: housekeeping (funny since 02d0e095031) > > applied using ./scripts/clean-includes > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > accel/tcg/translate-all.c | 1 - > exec.c | 3 --- > hw/arm/spitz.c | 1 - > hw/char/xen_console.c | 1 - > hw/core/machine.c | 1 - > hw/s390x/css.c | 1 - > target/openrisc/exception_helper.c | 1 - > tests/vhost-user-test.c | 1 - > util/qemu-sockets.c | 1 - > vl.c | 1 - > 10 files changed, 12 deletions(-) Reviewed-by: Peter Maydell <peter.maydell@linaro.org> thanks -- PMM ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-arm] [PATCH 05/34] misc: remove duplicated includes 2017-09-22 15:39 ` [Qemu-devel] [PATCH 05/34] misc: remove duplicated includes Philippe Mathieu-Daudé 2017-09-22 16:39 ` [Qemu-arm] " Peter Maydell @ 2017-09-25 8:12 ` Cornelia Huck 2017-10-10 15:37 ` [Qemu-devel] " Anthony PERARD 2 siblings, 0 replies; 11+ messages in thread From: Cornelia Huck @ 2017-09-25 8:12 UTC (permalink / raw) To: Philippe Mathieu-Daudé Cc: Peter Maydell, Thomas Huth, Stefano Stabellini, Daniel P. Berrange, Eduardo Habkost, qemu-trivial, Alexander Graf, qemu-devel, Marcel Apfelbaum, qemu-arm, Gerd Hoffmann, Marc-André Lureau, Anthony Perard, Paolo Bonzini, Stafford Horne, Christian Borntraeger, Richard Henderson On Fri, 22 Sep 2017 12:39:45 -0300 Philippe Mathieu-Daudé <f4bug@amsat.org> wrote: > exec: housekeeping (funny since 02d0e095031) > > applied using ./scripts/clean-includes > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > accel/tcg/translate-all.c | 1 - > exec.c | 3 --- > hw/arm/spitz.c | 1 - > hw/char/xen_console.c | 1 - > hw/core/machine.c | 1 - > hw/s390x/css.c | 1 - > target/openrisc/exception_helper.c | 1 - > tests/vhost-user-test.c | 1 - > util/qemu-sockets.c | 1 - > vl.c | 1 - > 10 files changed, 12 deletions(-) > diff --git a/hw/s390x/css.c b/hw/s390x/css.c > index 75d4f301fb..3938fa5909 100644 > --- a/hw/s390x/css.c > +++ b/hw/s390x/css.c > @@ -13,7 +13,6 @@ > #include "qapi/error.h" > #include "qapi/visitor.h" > #include "hw/qdev.h" > -#include "qemu/error-report.h" > #include "qemu/bitops.h" > #include "qemu/error-report.h" > #include "exec/address-spaces.h" Acked-by: Cornelia Huck <cohuck@redhat.com> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 05/34] misc: remove duplicated includes 2017-09-22 15:39 ` [Qemu-devel] [PATCH 05/34] misc: remove duplicated includes Philippe Mathieu-Daudé 2017-09-22 16:39 ` [Qemu-arm] " Peter Maydell 2017-09-25 8:12 ` Cornelia Huck @ 2017-10-10 15:37 ` Anthony PERARD 2 siblings, 0 replies; 11+ messages in thread From: Anthony PERARD @ 2017-10-10 15:37 UTC (permalink / raw) To: Philippe Mathieu-Daudé Cc: Peter Maydell, Thomas Huth, Stefano Stabellini, Eduardo Habkost, Peter Crosthwaite, qemu-trivial, Cornelia Huck, Alexander Graf, qemu-devel, Christian Borntraeger, qemu-arm, Gerd Hoffmann, Marc-André Lureau, Marcel Apfelbaum, Paolo Bonzini, Stafford Horne, Richard Henderson On Fri, Sep 22, 2017 at 12:39:45PM -0300, Philippe Mathieu-Daudé wrote: > exec: housekeeping (funny since 02d0e095031) > > applied using ./scripts/clean-includes > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > accel/tcg/translate-all.c | 1 - > exec.c | 3 --- > hw/arm/spitz.c | 1 - > hw/char/xen_console.c | 1 - > hw/core/machine.c | 1 - > hw/s390x/css.c | 1 - > target/openrisc/exception_helper.c | 1 - > tests/vhost-user-test.c | 1 - > util/qemu-sockets.c | 1 - > vl.c | 1 - > 10 files changed, 12 deletions(-) > Reviewed-by: Anthony PERARD <anthony.perard@citrix.com> -- Anthony PERARD ^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-arm] [PATCH 27/34] hw/pci: declare pci_nic_init_nofail() in "hw/net/pci.h" [not found] <20170922154014.29350-1-f4bug@amsat.org> 2017-09-22 15:39 ` [Qemu-devel] [PATCH 05/34] misc: remove duplicated includes Philippe Mathieu-Daudé @ 2017-09-22 16:01 ` Philippe Mathieu-Daudé 2017-09-23 5:12 ` David Gibson 2017-09-25 14:30 ` Marcel Apfelbaum 2017-09-22 16:01 ` [Qemu-devel] [PATCH 31/34] hw/net/rtl8139: use TYPE_PCI_RTL8139 Philippe Mathieu-Daudé 2 siblings, 2 replies; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2017-09-22 16:01 UTC (permalink / raw) To: Peter Maydell, Thomas Huth, Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum, Aurelien Jarno, Yongbok Kim, Alexander Graf, David Gibson, Jason Wang Cc: qemu-trivial, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé, qemu-devel Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- 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 -- 2.14.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-arm] [PATCH 27/34] hw/pci: declare pci_nic_init_nofail() in "hw/net/pci.h" 2017-09-22 16:01 ` [Qemu-arm] [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 2017-09-25 14:30 ` Marcel Apfelbaum 1 sibling, 0 replies; 11+ messages in thread From: David Gibson @ 2017-09-23 5:12 UTC (permalink / raw) To: Philippe Mathieu-Daudé Cc: Peter Maydell, Thomas Huth, Michael S. Tsirkin, qemu-trivial, Jason Wang, Alexander Graf, qemu-devel, Yongbok Kim, qemu-arm, qemu-ppc, Marcel Apfelbaum, Paolo Bonzini, Aurelien Jarno [-- 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 --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-arm] [PATCH 27/34] hw/pci: declare pci_nic_init_nofail() in "hw/net/pci.h" 2017-09-22 16:01 ` [Qemu-arm] [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 @ 2017-09-25 14:30 ` Marcel Apfelbaum 2017-10-02 18:38 ` Philippe Mathieu-Daudé 1 sibling, 1 reply; 11+ messages in thread From: Marcel Apfelbaum @ 2017-09-25 14:30 UTC (permalink / raw) To: Philippe Mathieu-Daudé, Peter Maydell, Thomas Huth, Paolo Bonzini, Michael S. Tsirkin, Aurelien Jarno, Yongbok Kim, Alexander Graf, David Gibson, Jason Wang Cc: qemu-trivial, qemu-arm, qemu-ppc, qemu-devel Hi Philippe, It seems the patch is doing much more than what is mentioned in the subject. On 22/09/2017 19:01, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > 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 Why don't add the function directly to hw/pci/pci_nic.c ? We have only one calling site anyway. I have nothing against adding an internal H file, but then we would need to add there *all* the functions used only by the pci sub-system. And that may be out of the scope of your series. > 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); > + Can you add a short explanation on how the split helps removing i386/pc dependency from non-PC world? - it is not straight forward, at least for me. Thanks, Marcel > +#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 > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-arm] [PATCH 27/34] hw/pci: declare pci_nic_init_nofail() in "hw/net/pci.h" 2017-09-25 14:30 ` Marcel Apfelbaum @ 2017-10-02 18:38 ` Philippe Mathieu-Daudé 2017-10-17 0:24 ` [Qemu-devel] " Philippe Mathieu-Daudé 0 siblings, 1 reply; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2017-10-02 18:38 UTC (permalink / raw) To: Marcel Apfelbaum Cc: Peter Maydell, Thomas Huth, Michael S. Tsirkin, qemu-trivial, Jason Wang, Alexander Graf, qemu-devel, qemu-arm, qemu-ppc, Yongbok Kim, Paolo Bonzini, Aurelien Jarno, David Gibson Hi Marcel, On 09/25/2017 11:30 AM, Marcel Apfelbaum wrote: > Hi Philippe, > > It seems the patch is doing much more than > what is mentioned in the subject. > > On 22/09/2017 19:01, Philippe Mathieu-Daudé wrote: >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >> --- >> 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 > > Why don't add the function directly to hw/pci/pci_nic.c ? > We have only one calling site anyway. You right! > > I have nothing against adding an internal H file, but then > we would need to add there *all* the functions used > only by the pci sub-system. And that may be out of the scope > of your series. > > > > >> 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); >> + > > Can you add a short explanation on how the split > helps removing i386/pc dependency from non-PC world? > - it is not straight forward, at least for me. I thought there was an old dependency on "hw/pci/pci.h" to something from i386/pc, so every machine using a PCI NIC would have this dependency. Extracting the NIC part as "hw/net/pci.h" would solve this issue. I didn't check attentively but it seems I was wrong, so I'll either drop this patch or reword it. Regards, Phil. > > > Thanks, > Marcel > >> +#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 >> > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 27/34] hw/pci: declare pci_nic_init_nofail() in "hw/net/pci.h" 2017-10-02 18:38 ` Philippe Mathieu-Daudé @ 2017-10-17 0:24 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2017-10-17 0:24 UTC (permalink / raw) To: Marcel Apfelbaum, Jason Wang, Michael Tokarev Cc: Peter Maydell, Thomas Huth, Michael S. Tsirkin, qemu-trivial, Alexander Graf, qemu-devel, qemu-arm, qemu-ppc, Yongbok Kim, Paolo Bonzini, Aurelien Jarno, David Gibson Hi Marcel, >> It seems the patch is doing much more than >> what is mentioned in the subject. >> [...] >> Can you add a short explanation on how the split >> helps removing i386/pc dependency from non-PC world? >> - it is not straight forward, at least for me. > > I thought there was an old dependency on "hw/pci/pci.h" to something > from i386/pc, so every machine using a PCI NIC would have this > dependency. Extracting the NIC part as "hw/net/pci.h" would solve this > issue. I didn't check attentively but it seems I was wrong, so I'll > either drop this patch or reword it. I finally opted to drop it for this series and include it reworded in part 2 which include more PCI-related patches. Regards, Phil. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 31/34] hw/net/rtl8139: use TYPE_PCI_RTL8139 [not found] <20170922154014.29350-1-f4bug@amsat.org> 2017-09-22 15:39 ` [Qemu-devel] [PATCH 05/34] misc: remove duplicated includes Philippe Mathieu-Daudé 2017-09-22 16:01 ` [Qemu-arm] [PATCH 27/34] hw/pci: declare pci_nic_init_nofail() in "hw/net/pci.h" Philippe Mathieu-Daudé @ 2017-09-22 16:01 ` Philippe Mathieu-Daudé 2017-09-25 5:36 ` [Qemu-arm] " Thomas Huth 2 siblings, 1 reply; 11+ messages in thread From: Philippe Mathieu-Daudé @ 2017-09-22 16:01 UTC (permalink / raw) To: Peter Maydell, Thomas Huth, Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum, Aurelien Jarno, Yongbok Kim, Magnus Damm, Jason Wang Cc: qemu-trivial, qemu-arm, Philippe Mathieu-Daudé, qemu-devel Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- include/hw/net/pci.h | 1 + hw/arm/realview.c | 3 ++- hw/arm/versatilepb.c | 3 ++- hw/mips/mips_fulong2e.c | 3 ++- hw/net/rtl8139.c | 7 +++---- hw/sh4/r2d.c | 5 +++-- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/hw/net/pci.h b/include/hw/net/pci.h index 5ad5487a91..43ed3b0145 100644 --- a/include/hw/net/pci.h +++ b/include/hw/net/pci.h @@ -16,6 +16,7 @@ #define TYPE_PCI_E1000 "e1000" #define TYPE_PCI_E1000E "e1000e" #define TYPE_PCI_PCNET "pcnet" +#define TYPE_PCI_RTL8139 "rtl8139" PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus, const char *default_model, diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 87cd1e583c..35f0da28e4 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -20,6 +20,7 @@ #include "sysemu/sysemu.h" #include "hw/boards.h" #include "hw/i2c/i2c.h" +#include "hw/net/pci.h" #include "sysemu/block-backend.h" #include "exec/address-spaces.h" #include "qemu/error-report.h" @@ -269,7 +270,7 @@ static void realview_init(MachineState *machine, done_nic = 1; } else { if (pci_bus) { - pci_nic_init_nofail(nd, pci_bus, "rtl8139", NULL); + pci_nic_init_nofail(nd, pci_bus, TYPE_PCI_RTL8139, NULL); } } } diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index 418792cd02..297aad78e1 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -18,6 +18,7 @@ #include "sysemu/sysemu.h" #include "hw/pci/pci.h" #include "hw/i2c/i2c.h" +#include "hw/net/pci.h" #include "hw/boards.h" #include "sysemu/block-backend.h" #include "exec/address-spaces.h" @@ -271,7 +272,7 @@ static void versatile_init(MachineState *machine, int board_id) smc91c111_init(nd, 0x10010000, sic[25]); done_smc = 1; } else { - pci_nic_init_nofail(nd, pci_bus, "rtl8139", NULL); + pci_nic_init_nofail(nd, pci_bus, TYPE_PCI_RTL8139, NULL); } } if (machine_usb(machine)) { diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 7ebbffa8f2..fe618953c9 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -44,6 +44,7 @@ #include "hw/timer/mc146818rtc.h" #include "hw/timer/i8254.h" #include "hw/input/i8042.h" +#include "hw/net/pci.h" #include "sysemu/blockdev.h" #include "exec/address-spaces.h" #include "sysemu/qtest.h" @@ -253,7 +254,7 @@ static void network_init (PCIBus *pci_bus) default_devaddr = "07"; } - pci_nic_init_nofail(nd, pci_bus, "rtl8139", default_devaddr); + pci_nic_init_nofail(nd, pci_bus, TYPE_PCI_RTL8139, default_devaddr); } } diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 3be24bbee7..0f952eceba 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -59,6 +59,7 @@ #include "net/net.h" #include "net/eth.h" #include "hw/loader.h" +#include "hw/net/pci.h" #include "sysemu/sysemu.h" #include "qemu/iov.h" @@ -90,10 +91,8 @@ static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...) } #endif -#define TYPE_RTL8139 "rtl8139" - #define RTL8139(obj) \ - OBJECT_CHECK(RTL8139State, (obj), TYPE_RTL8139) + OBJECT_CHECK(RTL8139State, (obj), TYPE_PCI_RTL8139) /* Symbolic offsets to registers. */ enum RTL8139_registers { @@ -3437,7 +3436,7 @@ static void rtl8139_class_init(ObjectClass *klass, void *data) } static const TypeInfo rtl8139_info = { - .name = TYPE_RTL8139, + .name = TYPE_PCI_RTL8139, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(RTL8139State), .class_init = rtl8139_class_init, diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c index 16b9ed2db2..dde60b2bc2 100644 --- a/hw/sh4/r2d.c +++ b/hw/sh4/r2d.c @@ -39,6 +39,7 @@ #include "hw/ide.h" #include "hw/loader.h" #include "hw/usb.h" +#include "hw/net/pci.h" #include "hw/block/flash.h" #include "sysemu/block-backend.h" #include "exec/address-spaces.h" @@ -303,8 +304,8 @@ static void r2d_init(MachineState *machine) /* NIC: rtl8139 on-board, and 2 slots. */ for (i = 0; i < nb_nics; i++) - pci_nic_init_nofail(&nd_table[i], pci_bus, - "rtl8139", i==0 ? "2" : NULL); + pci_nic_init_nofail(&nd_table[i], pci_bus, TYPE_PCI_RTL8139, + i == 0 ? "2" : NULL); /* USB keyboard */ usb_create_simple(usb_bus_find(-1), "usb-kbd"); -- 2.14.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-arm] [PATCH 31/34] hw/net/rtl8139: use TYPE_PCI_RTL8139 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 0 siblings, 0 replies; 11+ messages in thread From: Thomas Huth @ 2017-09-25 5:36 UTC (permalink / raw) To: Philippe Mathieu-Daudé, Peter Maydell, Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum, Aurelien Jarno, Yongbok Kim, Magnus Damm, Jason Wang Cc: qemu-trivial, qemu-arm, qemu-devel On 22.09.2017 18:01, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > include/hw/net/pci.h | 1 + > hw/arm/realview.c | 3 ++- > hw/arm/versatilepb.c | 3 ++- > hw/mips/mips_fulong2e.c | 3 ++- > hw/net/rtl8139.c | 7 +++---- > hw/sh4/r2d.c | 5 +++-- > 6 files changed, 13 insertions(+), 9 deletions(-) Reviewed-by: Thomas Huth <thuth@redhat.com> ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-10-17 0:44 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20170922154014.29350-1-f4bug@amsat.org>
2017-09-22 15:39 ` [Qemu-devel] [PATCH 05/34] misc: remove duplicated includes Philippe Mathieu-Daudé
2017-09-22 16:39 ` [Qemu-arm] " Peter Maydell
2017-09-25 8:12 ` Cornelia Huck
2017-10-10 15:37 ` [Qemu-devel] " Anthony PERARD
2017-09-22 16:01 ` [Qemu-arm] [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
2017-09-25 14:30 ` Marcel Apfelbaum
2017-10-02 18:38 ` Philippe Mathieu-Daudé
2017-10-17 0:24 ` [Qemu-devel] " Philippe Mathieu-Daudé
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 ` [Qemu-arm] " Thomas Huth
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).