From patchwork Tue Dec 28 18:48:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Herbszt X-Patchwork-Id: 76855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 94986B70DF for ; Wed, 29 Dec 2010 05:49:42 +1100 (EST) Received: from localhost ([127.0.0.1]:40028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PXec6-0003p8-88 for incoming@patchwork.ozlabs.org; Tue, 28 Dec 2010 13:49:38 -0500 Received: from [140.186.70.92] (port=37244 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PXebZ-0003ok-IT for qemu-devel@nongnu.org; Tue, 28 Dec 2010 13:49:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PXebX-00083B-9p for qemu-devel@nongnu.org; Tue, 28 Dec 2010 13:49:05 -0500 Received: from mailout-de.gmx.net ([213.165.64.22]:34353 helo=mail.gmx.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PXebW-00082m-VE for qemu-devel@nongnu.org; Tue, 28 Dec 2010 13:49:03 -0500 Received: (qmail invoked by alias); 28 Dec 2010 18:49:01 -0000 Received: from g226049244.adsl.alicedsl.de (HELO FSCPC) [92.226.49.244] by mail.gmx.net (mp052) with SMTP; 28 Dec 2010 19:49:01 +0100 X-Authenticated: #310364 X-Provags-ID: V01U2FsdGVkX1/D/b0IYC3D4dbeKzeX5qZQ3iBKd9Kf04tnezt5rn nEknJ/8TFPbHEG Message-ID: From: "Sebastian Herbszt" To: "Michael S. Tsirkin" References: <1292879881$2997@local> <20101227140136.GA27055@redhat.com> <5C6885C942B1469F90662F3DC1C2D8A1@FSCPC> <20101228171955.GA2850@redhat.com> In-Reply-To: <20101228171955.GA2850@redhat.com> Date: Tue, 28 Dec 2010 19:48:23 +0100 MIME-Version: 1.0 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Windows Mail 6.0.6001.18416 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18483 X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] Re: [PATCH] piix: use pci_config_set_prog_interface() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Michael S. Tsirkin wrote: > On Tue, Dec 28, 2010 at 05:24:06PM +0100, Sebastian Herbszt wrote: >> Michael S. Tsirkin wrote: >> >On Mon, Dec 20, 2010 at 10:18:01PM +0100, Sebastian Herbszt wrote: >> >>Use pci_config_set_prog_interface(). >> >> >> >>Signed-off-by: Sebastian Herbszt >> > >> >Since I was asked explicitly - I don't have a problem >> >with these changes: both class and prog interface. >> >However, they aren't all that useful in themselves. >> > >> >For class, what I would like to see is a system where >> >the device class is put in the qdev info table, >> >and where -device ? >> >(and hopefully the legacy -help, -nic etc as well) >> >use this information. >> >> I am not sure if you mean something like the patch below. > > Not exactly > > - I'd like to keep the pci_config_set_class in the devices, > just make it do an assert. Assert on which condition? > - Nics already have DEFINE_NIC_PROPERTIES - can this be used somehow? > Same for other devices ... We got DEFINE_NIC_PROPERTIES and DEFINE_BLOCK_PROPERTIES. Something like DEFINE_PCI_PROPERTIES could be introduced, but i am not sure which device properties it should hold (vendor_id, device_id, class, etc?). Those will then be user-modifiable with e.g. -device e1000,pci_class=1234. Sebastian diff --git a/hw/e1000.c b/hw/e1000.c index af101bd..e302703 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -1171,6 +1171,7 @@ static PCIDeviceInfo e1000_info = { .romfile = "pxe-e1000.bin", .qdev.props = (Property[]) { DEFINE_NIC_PROPERTIES(E1000State, conf), + DEFINE_PROP_UINT16("pci_class", E1000State, dev.class, PCI_CLASS_NETWORK_ETHERNET), DEFINE_PROP_END_OF_LIST(), } }; diff --git a/hw/pci.c b/hw/pci.c index ef00d20..06bbf04 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1620,6 +1620,9 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) info->is_bridge); if (pci_dev == NULL) return -1; + + pci_config_set_class(pci_dev->config, pci_dev->class); + rc = info->init(pci_dev); if (rc != 0) { do_pci_unregister_device(pci_dev); diff --git a/hw/pci.h b/hw/pci.h index 17744dc..5dc9053 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -189,6 +189,9 @@ struct PCIDevice { char *romfile; ram_addr_t rom_offset; uint32_t rom_bar; + + /* class */ + uint16_t class; }; PCIDevice *pci_register_device(PCIBus *bus, const char *name,