From patchwork Fri Oct 31 14:05:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 39908 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CD5C5202FE for ; Fri, 31 Oct 2014 14:06:25 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf652910wiw.11 for ; Fri, 31 Oct 2014 07:06:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=ClugEYmkCy7V8QfdspVQTbzsqmoLqPxixccG13fGXkA=; b=IhkF2m6GDi/2YY1/FOoHoVQm2I+zIz3+dzBlZeRv83V44pHDaK76ggxGNukVRt7UdK Qo3lI6KFThZUamlGpVKOUSUP+cvCHb35IHxQzyc1PQnIokXFi3rL8Fzzil5R2KTPe/Pn OeRALsHNZBNy3M+8NHk2pSHBwJFhjJmcBTEusUSofIoS1+25BpEuZzBePgs1xPQ7QloJ mEZ/CSHcGNNCWhnZpYaYs9gKwTLeXdv2ZTmslWLQvWGhAMJqtb3qUON5w32cdoE19W5n ckmrawQvbssQx2WDwN7vVgA2tt9nPTQ8XngY57ukjbt98B1cCa6JGdI0zaPAaLpabGUK Z+yA== X-Gm-Message-State: ALoCoQlSaxRL3NWY1bgQVMa8tv8vlSMlIQW6eJBIJ0qrELVdhZO6iRelWvrdMtkh2yrzJho7KzSz X-Received: by 10.181.27.135 with SMTP id jg7mr679072wid.5.1414764385019; Fri, 31 Oct 2014 07:06:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.40 with SMTP id 8ls311154lar.61.gmail; Fri, 31 Oct 2014 07:06:24 -0700 (PDT) X-Received: by 10.112.12.35 with SMTP id v3mr26464560lbb.80.1414764384811; Fri, 31 Oct 2014 07:06:24 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id ce7si16851036lbc.71.2014.10.31.07.06.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 07:06:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id gd6so5186456lab.34 for ; Fri, 31 Oct 2014 07:06:24 -0700 (PDT) X-Received: by 10.152.87.98 with SMTP id w2mr26190494laz.27.1414764384690; Fri, 31 Oct 2014 07:06:24 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.84.229 with SMTP id c5csp207524lbz; Fri, 31 Oct 2014 07:06:24 -0700 (PDT) X-Received: by 10.194.133.229 with SMTP id pf5mr28680163wjb.73.1414764383771; Fri, 31 Oct 2014 07:06:23 -0700 (PDT) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com. [209.85.212.180]) by mx.google.com with ESMTPS id ek2si26631943wid.102.2014.10.31.07.06.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 07:06:23 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.180 as permitted sender) client-ip=209.85.212.180; Received: by mail-wi0-f180.google.com with SMTP id hi2so1398746wib.7 for ; Fri, 31 Oct 2014 07:06:23 -0700 (PDT) X-Received: by 10.194.186.168 with SMTP id fl8mr23175378wjc.75.1414764383472; Fri, 31 Oct 2014 07:06:23 -0700 (PDT) Received: from midway01-04-00.lavalab ([88.98.47.97]) by mx.google.com with ESMTPSA id v10sm12504563wiy.23.2014.10.31.07.06.22 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 07:06:22 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, agraf@suse.de, pbonzini@redhat.com, kim.phillips@freescale.com, a.rigo@virtualopensystems.com, manish.jaggi@caviumnetworks.com, joel.schopp@amd.com Cc: eric.auger@linaro.org, kvmarm@lists.cs.columbia.edu, patches@linaro.org, alex.williamson@redhat.com, peter.maydell@linaro.org, will.deacon@arm.com, Bharat.Bhushan@freescale.com, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com Subject: [PATCH v7 10/16] hw/vfio: calxeda xgmac device Date: Fri, 31 Oct 2014 14:05:44 +0000 Message-Id: <1414764350-5140-11-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1414764350-5140-1-git-send-email-eric.auger@linaro.org> References: <1414764350-5140-1-git-send-email-eric.auger@linaro.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.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The platform device class has become abstract. The device can be be instantiated on command line using such option. -device vfio-calxeda-xgmac,host="fff51000.ethernet" Signed-off-by: Eric Auger --- 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 | 54 ++++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-calxeda-xgmac.h | 41 +++++++++++++++++++++++++++ 3 files changed, 96 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..913ab14 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..199e076 --- /dev/null +++ b/hw/vfio/calxeda_xgmac.c @@ -0,0 +1,54 @@ +/* + * calxeda xgmac example 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_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"; +} + +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..1529cf5 --- /dev/null +++ b/include/hw/vfio/vfio-calxeda-xgmac.h @@ -0,0 +1,41 @@ +/* + * 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" + +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