From patchwork Thu Oct 11 20:31:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10637397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98A0E112B for ; Thu, 11 Oct 2018 20:36:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 868952C126 for ; Thu, 11 Oct 2018 20:36:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 798B52C12E; Thu, 11 Oct 2018 20:36:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF3FD2C12B for ; Thu, 11 Oct 2018 20:36:30 +0000 (UTC) Received: from localhost ([::1]:37004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAhh8-0001aE-3z for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Oct 2018 16:36:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAhcn-0006gx-C8 for qemu-devel@nongnu.org; Thu, 11 Oct 2018 16:32:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAhci-0006c1-13 for qemu-devel@nongnu.org; Thu, 11 Oct 2018 16:32:01 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:65506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAhch-0006bQ-OV for qemu-devel@nongnu.org; Thu, 11 Oct 2018 16:31:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1539289915; x=1570825915; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Vw4Fsqzk+YkUm4jzsF0x6Vpt5HInTFzQJwWXqmVmc6o=; b=FzHOWE8kUe0CSBstd45hnq7r8jfykaknc5oNv/OtCb5fbslZkmdKOQPx /JbwJX8gcEfJjur8/y7qWNEka+bjnzRPx6KOKTie5nyVXe3QRMAEHn9wk TLfNBG9HfEcir6qa6s4I6miTUh3ssOa92JW8xRJC2qnEV/DgRkDtI45OK pv5LRHOkkGbNMMcngwdBoT4LhalJLjD5Ag822tOiGki+lsHe6G5Y0NBDd dFVlGBVJDy+1Ffb8WINOh+5gPnCMuOVl2TP4NaQKiq1XFH/chOLUSD00u UCPeyy0nQti3vkONSlqGuRQAzsJZbUF8O7rKY7ZmCd+73dBGmL2szLV57 g==; X-IronPort-AV: E=Sophos;i="5.54,369,1534780800"; d="scan'208";a="92863297" Received: from mail-sn1nam01lp0111.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.111]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2018 04:31:54 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DCRBadwsCIv6rwi1pCyX+MITT5R9E2bGo9Te2FwIqxI=; b=MwEEYtXeSBTwnwpsvRzc4a5MAIBY/uhHR/di3NcdKrZQPA1JC1dBz5r22FnUbDU+DwqTdYBVEbFuVVtlNQyD2OatmtL+PoojPRfKy8MysHPIpqyegNOPZcJMJ1nEkVokZ8+jJtIJ18Iq6N1Me7jt2uXdYHEWUn1/Za32F4TPYtY= Received: from CY4PR04MB0392.namprd04.prod.outlook.com (10.173.188.145) by CY4PR04MB0454.namprd04.prod.outlook.com (10.173.189.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.23; Thu, 11 Oct 2018 20:31:52 +0000 Received: from CY4PR04MB0392.namprd04.prod.outlook.com ([fe80::ddab:bdc2:6bc7:6d22]) by CY4PR04MB0392.namprd04.prod.outlook.com ([fe80::ddab:bdc2:6bc7:6d22%6]) with mapi id 15.20.1228.020; Thu, 11 Oct 2018 20:31:52 +0000 From: Alistair Francis To: "peter.maydell@linaro.org" Thread-Topic: [PULL 05/10] hw/riscv/virt: Connect a VirtIO net PCIe device Thread-Index: AQHUYaFxTykQjGoez0ymPFpyGWZ5gg== Date: Thu, 11 Oct 2018 20:31:52 +0000 Message-ID: <20181011203115.18666-6-alistair.francis@wdc.com> References: <20181011203115.18666-1-alistair.francis@wdc.com> In-Reply-To: <20181011203115.18666-1-alistair.francis@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: SG2PR01CA0126.apcprd01.prod.exchangelabs.com (2603:1096:4:40::30) To CY4PR04MB0392.namprd04.prod.outlook.com (2603:10b6:903:b1::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY4PR04MB0454; 6:iLtKHSK81nR/xK2AQVjb4BbPCnRWA2Pb2LkD+1q3jENOusTHSfds6Ex9p+FfUcY0oFKie+1fvl6VP96gzbBCvIsb3N3e7Y13fumlwsfKB+5O+eBXQWLinvXqbkTvGrRS+Cz3RfrvCtfaf5wjfKlEpcRdBHqo3kablsbsmid6bI+jRN+KQkQVOOBczBlkEPpQwSmzEc/v0SYKypLtl+TL5XU3y3WO/blf2wj3XBqk9zQDR/ELMnNM9Px5zuGx1T3V/zbYqjCVawJwHv041lgd60JELFgNz1P7ass5MCJiwTnHt8EZYL+b0AXoZA/f4zs7pIYoUAygRiBMd9LBwuerlusQwFt5V55X3zc5mD7udgn6MxzgqDPRyPCjLU0dpH6NxVi15q/RfrKc/yyGxKjMr1FXIz7SdzxVr3lxUKh5BeeohUp4zELqqhyxNc7SGFkqrTGdcak7xLEGqfvY41cNFQ==; 5:QkMrZlgHd28Pp1GVxk9E4OnZtP1djYTeLtFoOePPwKKc+NPO6mVfngrRLNr7GGarM4XYoKV4j+7OtVGy2ImgpKTftJH5QlUgd0YPPtO6mIGA5DPjGA53YklzRKGT8QsWOZKDkgW/vLbhpPge92gwJZlCGTM5AO7Q/MHOFuut4lc=; 7:jTfKM6A5dBe3nL9D5RS7kBGZJkR6sfmOLS4vnpNm/C5pF1jWLzY6+0tFpMT02mLZBh0htRDoGcxj8SE7mSipqKQmULvCg/JcdxQZh7rmPDNN7I8BGU9gPPYeM7f45CMEJJCHmPrdns77dS4TZXGdN+X3QJnlyXtQBAgMo1tGymtDPhTRcX7dgJnwkmtmdK5Mwr5TQfuAioIb9RK7dLWB74/+mj2dTBKT3jElR7ssjx1ixl6bEAo+gbU0Pigl3Wjv x-ms-office365-filtering-correlation-id: 42416d7d-c03c-4577-7277-08d62fb893a9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:CY4PR04MB0454; x-ms-traffictypediagnostic: CY4PR04MB0454: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(21532816269658); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:CY4PR04MB0454; BCL:0; PCL:0; RULEID:; SRVR:CY4PR04MB0454; x-forefront-prvs: 08220FA8D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(346002)(39860400002)(376002)(366004)(396003)(199004)(189003)(71190400001)(71200400001)(2906002)(26005)(76176011)(2900100001)(316002)(478600001)(6436002)(54906003)(14454004)(36756003)(53936002)(6512007)(5640700003)(6486002)(66066001)(81156014)(2351001)(8936002)(476003)(7736002)(72206003)(8676002)(50226002)(105586002)(446003)(86362001)(106356001)(11346002)(99286004)(2616005)(186003)(1076002)(3846002)(6116002)(5250100002)(2501003)(52116002)(6916009)(256004)(97736004)(25786009)(4326008)(68736007)(386003)(486006)(44832011)(5660300001)(102836004)(305945005)(81166006)(6506007); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR04MB0454; H:CY4PR04MB0392.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: FP+k8Bx3jZdDn3M1ePGMPk44przGrIZ6mGIThj8NNRTiDh8ViNNh/fXmzw5ZhXmQLyZ/DbiNaVv5VW1NMoqlC9yph0spcZVwUNxuGOlnTppP6vRoA+V6DS3OkiOXzjsvVejU/lien1iyVDT/Ja0whLNt7DdtwUj6tYRIyADqlZl8ON/XclFIuoXQcsDH8Yb6Vzf7kNhJySvAtTBzNe8OQJi4/Da5YXycqU8VjVVAGq24+sCx9AFRYCxBxcrkqAAqQTlkcrUStsAVjrc9aVP0G/2VehEMt14QambQS17yTfHT0BqNu9jbDq+SfM7vu1ov2hXNr19oSJKhLCbhjvyFifxFw2sMLGUOsXcLdvYVfwE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42416d7d-c03c-4577-7277-08d62fb893a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2018 20:31:52.2661 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR04MB0454 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PULL 05/10] hw/riscv/virt: Connect a VirtIO net PCIe device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Francis , "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis --- default-configs/riscv32-softmmu.mak | 1 + default-configs/riscv64-softmmu.mak | 1 + hw/riscv/virt.c | 20 +++++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/default-configs/riscv32-softmmu.mak b/default-configs/riscv32-softmmu.mak index 05fae82f1b..bb3dd34606 100644 --- a/default-configs/riscv32-softmmu.mak +++ b/default-configs/riscv32-softmmu.mak @@ -9,6 +9,7 @@ CONFIG_CADENCE=y CONFIG_PCI_GENERIC=y CONFIG_PCI_XILINX=y +CONFIG_VIRTIO_PCI=y CONFIG_VGA=y CONFIG_VGA_PCI=y diff --git a/default-configs/riscv64-softmmu.mak b/default-configs/riscv64-softmmu.mak index 05fae82f1b..bb3dd34606 100644 --- a/default-configs/riscv64-softmmu.mak +++ b/default-configs/riscv64-softmmu.mak @@ -9,6 +9,7 @@ CONFIG_CADENCE=y CONFIG_PCI_GENERIC=y CONFIG_PCI_XILINX=y +CONFIG_VIRTIO_PCI=y CONFIG_VGA=y CONFIG_VGA_PCI=y diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 62a953aa2b..6d91810bcf 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -36,6 +36,7 @@ #include "hw/riscv/sifive_test.h" #include "hw/riscv/virt.h" #include "chardev/char.h" +#include "net/net.h" #include "sysemu/arch_init.h" #include "sysemu/device_tree.h" #include "exec/address-spaces.h" @@ -322,6 +323,8 @@ static void riscv_virt_board_init(MachineState *machine) MemoryRegion *system_memory = get_system_memory(); MemoryRegion *main_mem = g_new(MemoryRegion, 1); MemoryRegion *mask_rom = g_new(MemoryRegion, 1); + DeviceState *dev; + PCIBus *pci_bus; char *plic_hart_config; size_t plic_hart_config_len; int i; @@ -436,9 +439,20 @@ static void riscv_virt_board_init(MachineState *machine) qdev_get_gpio_in(DEVICE(s->plic), VIRTIO_IRQ + i)); } - gpex_pcie_init(system_memory, 0, memmap[VIRT_PCIE].base, - memmap[VIRT_PCIE].size, 0x40000000, 0x20000000, - qdev_get_gpio_in(DEVICE(s->plic), PCIE_IRQ), true); + dev = gpex_pcie_init(system_memory, 0, memmap[VIRT_PCIE].base, + memmap[VIRT_PCIE].size, 0x40000000, 0x20000000, + qdev_get_gpio_in(DEVICE(s->plic), PCIE_IRQ), true); + pci_bus = PCI_HOST_BRIDGE(dev)->bus; + + for (i = 0; i < nb_nics; i++) { + NICInfo *nd = &nd_table[i]; + + if (!nd->model) { + nd->model = g_strdup("virtio"); + } + + pci_nic_init_nofail(nd, pci_bus, nd->model, NULL); + } serial_mm_init(system_memory, memmap[VIRT_UART0].base, 0, qdev_get_gpio_in(DEVICE(s->plic), UART0_IRQ), 399193,