From patchwork Wed Apr 25 05:54:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Voevodin X-Patchwork-Id: 154801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0859CB6FBD for ; Wed, 25 Apr 2012 15:55:03 +1000 (EST) Received: from localhost ([::1]:42282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMvBs-0003Fv-SH for incoming@patchwork.ozlabs.org; Wed, 25 Apr 2012 01:55:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:32776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMvBT-0002q3-Qv for qemu-devel@nongnu.org; Wed, 25 Apr 2012 01:54:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SMvBQ-0006eP-Av for qemu-devel@nongnu.org; Wed, 25 Apr 2012 01:54:35 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:51853) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMvBP-0006Yv-V9 for qemu-devel@nongnu.org; Wed, 25 Apr 2012 01:54:32 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: TEXT/PLAIN Received: from euspt2 ([210.118.77.14]) by mailout4.w1.samsung.com (Sun Java(tm) System Messaging Server 6.3-8.04 (built Jul 29 2009; 32bit)) with ESMTP id <0M3000GYUTR0Z170@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Wed, 25 Apr 2012 06:54:36 +0100 (BST) Received: from evvoevodinPC.rnd.samsung.ru ([106.109.9.191]) by spt2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0M300064STQJKX@spt2.w1.samsung.com> for qemu-devel@nongnu.org; Wed, 25 Apr 2012 06:54:26 +0100 (BST) Date: Wed, 25 Apr 2012 09:54:11 +0400 From: Evgeny Voevodin In-reply-to: <1335333257-5128-1-git-send-email-e.voevodin@samsung.com> To: qemu-devel@nongnu.org Message-id: <1335333257-5128-4-git-send-email-e.voevodin@samsung.com> X-Mailer: git-send-email 1.7.5.4 References: <1335333257-5128-1-git-send-email-e.voevodin@samsung.com> X-detected-operating-system: by eggs.gnu.org: Solaris 9.1 X-Received-From: 210.118.77.14 Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, i.mitsyanko@samsung.com, Evgeny Voevodin , kyungmin.park@samsung.com, d.solodkiy@samsung.com, m.kozlov@samsung.com Subject: [Qemu-devel] [RFC 3/9] Virtio: Add transport bindings. 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Evgeny Voevodin --- Makefile.objs | 1 + hw/virtio-transport.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ hw/virtio-transport.h | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 0 deletions(-) create mode 100644 hw/virtio-transport.c create mode 100644 hw/virtio-transport.h diff --git a/Makefile.objs b/Makefile.objs index 6d6f24d..5a648bc 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -212,6 +212,7 @@ hw-obj-y += vl.o loader.o hw-obj-$(CONFIG_VIRTIO) += virtio-console.o hw-obj-y += usb/libhw.o hw-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o +hw-obj-$(CONFIG_VIRTIO) += virtio-transport.o hw-obj-y += fw_cfg.o hw-obj-$(CONFIG_PCI) += pci.o pci_bridge.o pci_bridge_dev.o hw-obj-$(CONFIG_PCI) += msix.o msi.o diff --git a/hw/virtio-transport.c b/hw/virtio-transport.c new file mode 100644 index 0000000..4225a30 --- /dev/null +++ b/hw/virtio-transport.c @@ -0,0 +1,46 @@ +/* + * Virtio transport bindings + * + * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. + * + * Author: + * Evgeny Voevodin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "virtio-transport.h" + +#define VIRTIO_TRANSPORT_BUS "virtio-transport" + +struct BusInfo virtio_transport_bus_info = { + .name = VIRTIO_TRANSPORT_BUS, + .size = sizeof(VirtIOTransportBusState), +}; + +int virtio_init_transport(DeviceState *dev, VirtIODevice *vdev) +{ + DeviceState *transport_dev = qdev_get_parent_bus(dev)->parent; + BusState *bus; + VirtIOTransportBusState *virtio_transport_bus; + + /* transport device has single child bus */ + bus = QLIST_FIRST(&transport_dev->child_bus); + virtio_transport_bus = DO_UPCAST(VirtIOTransportBusState, bus, bus); + + if (virtio_transport_bus->init_fn) { + return virtio_transport_bus->init_fn(dev, vdev); + } + + return 0; +} diff --git a/hw/virtio-transport.h b/hw/virtio-transport.h new file mode 100644 index 0000000..ff39bf7 --- /dev/null +++ b/hw/virtio-transport.h @@ -0,0 +1,39 @@ +/* + * Virtio transport header + * + * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. + * + * Author: + * Evgeny Voevodin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef VIRTIO_TRANSPORT_H_ +#define VIRTIO_TRANSPORT_H_ + +#include "sysbus.h" +#include "virtio.h" + +extern struct BusInfo virtio_transport_bus_info; + +typedef int (*virtio_init_transport_fn)(DeviceState *dev, VirtIODevice *vdev); + +typedef struct VirtIOTransportBusState { + BusState bus; + virtio_init_transport_fn init_fn; +} VirtIOTransportBusState; + +int virtio_init_transport(DeviceState *dev, VirtIODevice *vdev); + +#endif /* VIRTIO_TRANSPORT_H_ */