From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6z9y-0007oP-Ek for qemu-devel@nongnu.org; Wed, 16 Nov 2016 07:17:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6z9v-0000b4-8B for qemu-devel@nongnu.org; Wed, 16 Nov 2016 07:17:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52160) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c6z9v-0000aa-0k for qemu-devel@nongnu.org; Wed, 16 Nov 2016 07:17:47 -0500 References: <1477012975-12181-1-git-send-email-songwenjun@huawei.com> From: Auger Eric Message-ID: Date: Wed, 16 Nov 2016 13:17:24 +0100 MIME-Version: 1.0 In-Reply-To: <1477012975-12181-1-git-send-email-songwenjun@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC, v1, 1/2] hw/vfio/platform: add hisilicon hnsvf device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Rick Song , qemu-devel@nongnu.org, alex.williamson@redhat.com Hi Rick, On 21/10/2016 03:22, Rick Song wrote: > The platform device class has become abstract. This > patch introduces a hisilicon hnsvf device that derives > from it. in https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg03401.html we discussed the relevance to get the platform device non abstract. No change was submitted though. I can submit something next week except if you want to submit a patch yourself. The idea is we would instantiate the vfio platform device using such an option: -device vfio-platform-device,compat="hisilicon,hnsvf-v2" Once such change is accepted, only your second patch will be requested. Thanks Eric > > Signed-off-by: Rick Song > --- > hw/vfio/Makefile.objs | 1 + > hw/vfio/hisi-hnsvf.c | 56 +++++++++++++++++++++++++++++++++++++++ > include/hw/vfio/vfio-hisi-hnsvf.h | 51 +++++++++++++++++++++++++++++++++++ > 3 files changed, 108 insertions(+) > create mode 100644 hw/vfio/hisi-hnsvf.c > create mode 100644 include/hw/vfio/vfio-hisi-hnsvf.h > > diff --git a/hw/vfio/Makefile.objs b/hw/vfio/Makefile.objs > index c25e32b..d19dffc 100644 > --- a/hw/vfio/Makefile.objs > +++ b/hw/vfio/Makefile.objs > @@ -4,5 +4,6 @@ obj-$(CONFIG_PCI) += pci.o pci-quirks.o > obj-$(CONFIG_SOFTMMU) += platform.o > obj-$(CONFIG_SOFTMMU) += calxeda-xgmac.o > obj-$(CONFIG_SOFTMMU) += amd-xgbe.o > +obj-$(CONFIG_SOFTMMU) += hisi-hnsvf.o > obj-$(CONFIG_SOFTMMU) += spapr.o > endif > diff --git a/hw/vfio/hisi-hnsvf.c b/hw/vfio/hisi-hnsvf.c > new file mode 100644 > index 0000000..5b48e27 > --- /dev/null > +++ b/hw/vfio/hisi-hnsvf.c > @@ -0,0 +1,56 @@ > +/* > + * Hisilicon HNS Virtual Function VFIO device > + * > + * Copyright Huawei Limited, 2016 > + * > + * Authors: > + * Rick Song > + * > + * This work is licensed under the terms of the GNU GPL, version 2. See > + * the COPYING file in the top-level directory. > + * > + */ > + > +#include "qemu/osdep.h" > +#include "hw/vfio/vfio-hisi-hnsvf.h" > + > +static void hisi_hnsvf_realize(DeviceState *dev, Error **errp) > +{ > + VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev); > + VFIOHisiHnsvfDeviceClass *k = VFIO_HISI_HNSVF_DEVICE_GET_CLASS(dev); > + > + vdev->compat = g_strdup("hisilicon,hnsvf-v2"); > + > + k->parent_realize(dev, errp); > +} > + > +static const VMStateDescription vfio_platform_hisi_hnsvf_vmstate = { > + .name = TYPE_VFIO_HISI_HNSVF, > + .unmigratable = 1, > +}; > + > +static void vfio_hisi_hnsvf_class_init(ObjectClass *klass, void *data) > +{ > + DeviceClass *dc = DEVICE_CLASS(klass); > + VFIOHisiHnsvfDeviceClass *vcxc = > + VFIO_HISI_HNSVF_DEVICE_CLASS(klass); > + vcxc->parent_realize = dc->realize; > + dc->realize = hisi_hnsvf_realize; > + dc->desc = "VFIO HISI HNSVF"; > + dc->vmsd = &vfio_platform_hisi_hnsvf_vmstate; > +} > + > +static const TypeInfo vfio_hisi_hnsvf_dev_info = { > + .name = TYPE_VFIO_HISI_HNSVF, > + .parent = TYPE_VFIO_PLATFORM, > + .instance_size = sizeof(VFIOHisiHnsvfDevice), > + .class_init = vfio_hisi_hnsvf_class_init, > + .class_size = sizeof(VFIOHisiHnsvfDeviceClass), > +}; > + > +static void register_hisi_hnsvf_dev_type(void) > +{ > + type_register_static(&vfio_hisi_hnsvf_dev_info); > +} > + > +type_init(register_hisi_hnsvf_dev_type) > diff --git a/include/hw/vfio/vfio-hisi-hnsvf.h b/include/hw/vfio/vfio-hisi-hnsvf.h > new file mode 100644 > index 0000000..9208656 > --- /dev/null > +++ b/include/hw/vfio/vfio-hisi-hnsvf.h > @@ -0,0 +1,51 @@ > +/* > + * VFIO Hisilicon HNS Virtual Function device > + * > + * Copyright Hisilicon Limited, 2016 > + * > + * Authors: > + * Rick Song > + * > + * This work is licensed under the terms of the GNU GPL, version 2. See > + * the COPYING file in the top-level directory. > + * > + */ > + > +#ifndef HW_VFIO_VFIO_HISI_HNSVF_H > +#define HW_VFIO_VFIO_HISI_HNSVF_H > + > +#include "hw/vfio/vfio-platform.h" > + > +#define TYPE_VFIO_HISI_HNSVF "vfio-hisi-hnsvf" > + > +/** > + * This device exposes: > + * - 5 MMIO regions: MAC, PCS, SerDes Rx/Tx regs, > + SerDes Integration Registers 1/2 & 2/2 > + * - 2 level sensitive IRQs and optional DMA channel IRQs > + */ > +struct VFIOHisiHnsvfDevice { > + VFIOPlatformDevice vdev; > +}; > + > +typedef struct VFIOHisiHnsvfDevice VFIOHisiHnsvfDevice; > + > +struct VFIOHisiHnsvfDeviceClass { > + /*< private >*/ > + VFIOPlatformDeviceClass parent_class; > + /*< public >*/ > + DeviceRealize parent_realize; > +}; > + > +typedef struct VFIOHisiHnsvfDeviceClass VFIOHisiHnsvfDeviceClass; > + > +#define VFIO_HISI_HNSVF_DEVICE(obj) \ > + OBJECT_CHECK(VFIOHisiHnsvfDevice, (obj), TYPE_VFIO_HISI_HNSVF) > +#define VFIO_HISI_HNSVF_DEVICE_CLASS(klass) \ > + OBJECT_CLASS_CHECK(VFIOHisiHnsvfDeviceClass, (klass), \ > + TYPE_VFIO_HISI_HNSVF) > +#define VFIO_HISI_HNSVF_DEVICE_GET_CLASS(obj) \ > + OBJECT_GET_CLASS(VFIOHisiHnsvfDeviceClass, (obj), \ > + TYPE_VFIO_HISI_HNSVF) > + > +#endif >