From patchwork Tue Jun 9 08:00:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 49643 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B453A21419 for ; Tue, 9 Jun 2015 08:00:58 +0000 (UTC) Received: by lagh7 with SMTP id h7sf2606597lag.2 for ; Tue, 09 Jun 2015 01:00:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:content-type:content-transfer-encoding:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=h/pUO4U7llNDerokCuWuSD6XcM2CClIEMQs5KmtQTEs=; b=ZcWDVRouxLoBXB5Pni8R/ELMrnbMRJiIOLc7PQ77ovqFVcQD2Ss8W4PQMTfTnVBEqA K0CirSl89tezINktGeejD3flHWQSOTVYH78t3mguav6YhrNtKyKM/fKnLD7FSYCcW6g0 A3CuOSLiz25j9UpCzsantLjkiOHVHVsIT+I6l3RFzL8UsXHNGe1areJwvG4JuIj7g7YH dR1rsD9b9+A1CzRQ9W/XSHdBHi9lASiGxaayu/09nDP7Bjsi2dTPbNjNr7O0Jphvp4+J /7bWXK05Es9wZ3L5GjEEJFH8Rkfa/D98AaNQuKaY0XuBjg1iPNBnsGso0XEyP/aDq4kR bvxA== X-Gm-Message-State: ALoCoQmy9gLFKKiY0aIatVoN5JpqxzDuN9gd1362WaE61tbtiYWtDaQEdnhR/WjsVgevjiJQhxO/ X-Received: by 10.180.19.72 with SMTP id c8mr16177811wie.2.1433836857733; Tue, 09 Jun 2015 01:00:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.225.167 with SMTP id rl7ls39234lac.74.gmail; Tue, 09 Jun 2015 01:00:57 -0700 (PDT) X-Received: by 10.152.2.38 with SMTP id 6mr21548907lar.80.1433836857453; Tue, 09 Jun 2015 01:00:57 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id z6si5089448lae.16.2015.06.09.01.00.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2015 01:00:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by laew7 with SMTP id w7so6358322lae.1 for ; Tue, 09 Jun 2015 01:00:57 -0700 (PDT) X-Received: by 10.152.225.166 with SMTP id rl6mr21192951lac.36.1433836857361; Tue, 09 Jun 2015 01:00:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2414865lbb; Tue, 9 Jun 2015 01:00:56 -0700 (PDT) X-Received: by 10.140.106.101 with SMTP id d92mr23804433qgf.70.1433836855710; Tue, 09 Jun 2015 01:00:55 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 199si4713199qhe.36.2015.06.09.01.00.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Jun 2015 01:00:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:33522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2ESt-0004hh-1p for patch@linaro.org; Tue, 09 Jun 2015 04:00:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2ESQ-0004QU-Rs for qemu-devel@nongnu.org; Tue, 09 Jun 2015 04:00:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2ESO-0004KO-1d for qemu-devel@nongnu.org; Tue, 09 Jun 2015 04:00:26 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:34404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2ESN-0004J5-Q1 for qemu-devel@nongnu.org; Tue, 09 Jun 2015 04:00:23 -0400 Received: by wibut5 with SMTP id ut5so9055656wib.1 for ; Tue, 09 Jun 2015 01:00:23 -0700 (PDT) X-Received: by 10.194.176.201 with SMTP id ck9mr39599302wjc.108.1433836823135; Tue, 09 Jun 2015 01:00:23 -0700 (PDT) Received: from midway01-04-00.lavalab ([81.128.185.50]) by mx.google.com with ESMTPSA id r9sm8056416wjo.26.2015.06.09.01.00.21 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Jun 2015 01:00:22 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, qemu-devel@nongnu.org, alex.williamson@redhat.com, peter.maydell@linaro.org Date: Tue, 9 Jun 2015 09:00:07 +0100 Message-Id: <1433836807-10435-1-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.174 Subject: [Qemu-devel] [PATCH] hw/vfio/platform: calxeda xgmac device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The platform device class has become abstract. This patch introduces a calxeda xgmac device that derives from it. Signed-off-by: Eric Auger Reviewed-by: Alex Bennée --- v16 -> v17: - properly attach vfio_platform_calxeda_xgmac_vmstate v15 -> v16: - added Vikram's T-b v10 -> v11: - add Alex Reviewed-by - move virt modifications in a separate patch v8 -> v9: - renamed calxeda_xgmac.c into calxeda-xgmac.c v7 -> v8: - add a comment in the header about the MMIO regions and IRQ which are exposed by the device v5 -> v6 - back again following Alex Graf advises - fix a bug related to compat override v4 -> v5: removed since device tree was moved to hw/arm/dyn_sysbus_devtree.c v4: creation for device tree specialization --- hw/vfio/Makefile.objs | 1 + hw/vfio/calxeda-xgmac.c | 55 ++++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-calxeda-xgmac.h | 46 ++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 hw/vfio/calxeda-xgmac.c create mode 100644 include/hw/vfio/vfio-calxeda-xgmac.h diff --git a/hw/vfio/Makefile.objs b/hw/vfio/Makefile.objs index c5c76fe..d540c9d 100644 --- a/hw/vfio/Makefile.objs +++ b/hw/vfio/Makefile.objs @@ -2,4 +2,5 @@ ifeq ($(CONFIG_LINUX), y) obj-$(CONFIG_SOFTMMU) += common.o obj-$(CONFIG_PCI) += pci.o obj-$(CONFIG_SOFTMMU) += platform.o +obj-$(CONFIG_SOFTMMU) += calxeda-xgmac.o endif diff --git a/hw/vfio/calxeda-xgmac.c b/hw/vfio/calxeda-xgmac.c new file mode 100644 index 0000000..eb914f0 --- /dev/null +++ b/hw/vfio/calxeda-xgmac.c @@ -0,0 +1,55 @@ +/* + * calxeda xgmac VFIO device + * + * Copyright Linaro Limited, 2014 + * + * Authors: + * Eric Auger + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include "hw/vfio/vfio-calxeda-xgmac.h" + +static void calxeda_xgmac_realize(DeviceState *dev, Error **errp) +{ + VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev); + VFIOCalxedaXgmacDeviceClass *k = VFIO_CALXEDA_XGMAC_DEVICE_GET_CLASS(dev); + + vdev->compat = g_strdup("calxeda,hb-xgmac"); + + k->parent_realize(dev, errp); +} + +static const VMStateDescription vfio_platform_calxeda_xgmac_vmstate = { + .name = TYPE_VFIO_CALXEDA_XGMAC, + .unmigratable = 1, +}; + +static void vfio_calxeda_xgmac_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VFIOCalxedaXgmacDeviceClass *vcxc = + VFIO_CALXEDA_XGMAC_DEVICE_CLASS(klass); + vcxc->parent_realize = dc->realize; + dc->realize = calxeda_xgmac_realize; + dc->desc = "VFIO Calxeda XGMAC"; + dc->vmsd = &vfio_platform_calxeda_xgmac_vmstate; +} + +static const TypeInfo vfio_calxeda_xgmac_dev_info = { + .name = TYPE_VFIO_CALXEDA_XGMAC, + .parent = TYPE_VFIO_PLATFORM, + .instance_size = sizeof(VFIOCalxedaXgmacDevice), + .class_init = vfio_calxeda_xgmac_class_init, + .class_size = sizeof(VFIOCalxedaXgmacDeviceClass), +}; + +static void register_calxeda_xgmac_dev_type(void) +{ + type_register_static(&vfio_calxeda_xgmac_dev_info); +} + +type_init(register_calxeda_xgmac_dev_type) diff --git a/include/hw/vfio/vfio-calxeda-xgmac.h b/include/hw/vfio/vfio-calxeda-xgmac.h new file mode 100644 index 0000000..f994775 --- /dev/null +++ b/include/hw/vfio/vfio-calxeda-xgmac.h @@ -0,0 +1,46 @@ +/* + * VFIO calxeda xgmac device + * + * Copyright Linaro Limited, 2014 + * + * Authors: + * Eric Auger + * + * 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_CALXEDA_XGMAC_H +#define HW_VFIO_VFIO_CALXEDA_XGMAC_H + +#include "hw/vfio/vfio-platform.h" + +#define TYPE_VFIO_CALXEDA_XGMAC "vfio-calxeda-xgmac" + +/** + * This device exposes: + * - a single MMIO region corresponding to its register space + * - 3 IRQS (main and 2 power related IRQs) + */ +typedef struct VFIOCalxedaXgmacDevice { + VFIOPlatformDevice vdev; +} VFIOCalxedaXgmacDevice; + +typedef struct VFIOCalxedaXgmacDeviceClass { + /*< private >*/ + VFIOPlatformDeviceClass parent_class; + /*< public >*/ + DeviceRealize parent_realize; +} VFIOCalxedaXgmacDeviceClass; + +#define VFIO_CALXEDA_XGMAC_DEVICE(obj) \ + OBJECT_CHECK(VFIOCalxedaXgmacDevice, (obj), TYPE_VFIO_CALXEDA_XGMAC) +#define VFIO_CALXEDA_XGMAC_DEVICE_CLASS(klass) \ + OBJECT_CLASS_CHECK(VFIOCalxedaXgmacDeviceClass, (klass), \ + TYPE_VFIO_CALXEDA_XGMAC) +#define VFIO_CALXEDA_XGMAC_DEVICE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(VFIOCalxedaXgmacDeviceClass, (obj), \ + TYPE_VFIO_CALXEDA_XGMAC) + +#endif