From patchwork Thu Oct 4 20:06:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10626603 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 7893914BD for ; Thu, 4 Oct 2018 20:08:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AC9F296AF for ; Thu, 4 Oct 2018 20:08:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E66C296B2; Thu, 4 Oct 2018 20:08:29 +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 DBF78296AF for ; Thu, 4 Oct 2018 20:08:28 +0000 (UTC) Received: from localhost ([::1]:58804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g89vA-00010d-3r for patchwork-qemu-devel@patchwork.kernel.org; Thu, 04 Oct 2018 16:08:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g89tr-000053-F7 for qemu-devel@nongnu.org; Thu, 04 Oct 2018 16:07:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g89tn-00088z-BQ for qemu-devel@nongnu.org; Thu, 04 Oct 2018 16:07:07 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:51852) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g89tn-00087d-2T for qemu-devel@nongnu.org; Thu, 04 Oct 2018 16:07:03 -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=1538683624; x=1570219624; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Vw4Fsqzk+YkUm4jzsF0x6Vpt5HInTFzQJwWXqmVmc6o=; b=ns5TNxLg5+Lew3980/DsofP8BqLjNfpfcsx0ejgdcgsodunhlWKJwfOy 1/05V+LUJUsCpxCNGbzMeyPu1oclDGRHhd/DsFfkgKGv8xG4QXCiELZFn B+EkRE02v+Xmy6Sxpz+Vh2bgt4qEe2yAstirVKviWyIK6kse5XGG5Hdj4 5QR2myZ1+5B4K6U01kx+2+dVT5BN1xHeZN2FxxZmQ4bnV6bQ2uknbBjH1 yUnjj+QY4nx04w81kobfmcSbysE3nczrgRtrampkfjWf2oFOywCoxNFLt UspQSgUNavPwbiLHIe8e5c90hYG40Z18q+d3o5Ad4Yhov0tDIS1Zr5O2S w==; X-IronPort-AV: E=Sophos;i="5.54,341,1534780800"; d="scan'208";a="91270220" Received: from mail-sn1nam04lp0087.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([216.32.180.87]) by ob1.hgst.iphmx.com with ESMTP; 05 Oct 2018 04:07:02 +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=ac/DSlHUIz5uRH+llWyClIS4R7dE2mrhfkYHUpZZcQaF8Zr0rOKxHTM+tDVoPGymHMKFin3qHuDUiK5bZCJqiDJt0btYs1jKRPU+Ironq68iXCPVWumpwNUUnF9O+5xJ78z0hOTjcpHl7zeEC+si9bRisMH5/gCoLXOiRYOpr5A= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0959.namprd04.prod.outlook.com (10.174.249.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.25; Thu, 4 Oct 2018 20:06:59 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::f94c:102e:8dce:7c02]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::f94c:102e:8dce:7c02%6]) with mapi id 15.20.1185.026; Thu, 4 Oct 2018 20:06:59 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "mjc@sifive.com" Thread-Topic: [PATCH v5 5/5] hw/riscv/virt: Connect a VirtIO net PCIe device Thread-Index: AQHUXB3OVLz7K98LD0qYbqT5LyNzrw== Date: Thu, 4 Oct 2018 20:06:59 +0000 Message-ID: <4ae3539e9e432912819b41aefbfdde237a27057d.1538683492.git.alistair.francis@wdc.com> References: In-Reply-To: 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: BYAPR02CA0072.namprd02.prod.outlook.com (2603:10b6:a03:54::49) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0959; 6:LZmypLUTVn939BbdOSbxZG9AD0eEpl3uqxxG1zONaec6VLR+ZRtTdd/LD8mhP6kfK6aw0SGrX4TUezVNLlvg12kBL9FxPr0CB5VjTGpRRvWuxOfhVdJNBY1qVc1j488apXs6nWdlH6rIDpugHLEDy3RAUbi+UNbSeRqngpdhhz8ijNgPB52HS6n53jK0kCUo4diyQMpoekVimTRpbRh6boNgcP0UmyD86KNjZ8iVjUv2FeYsmv41ReISBRV4L0gvRxXQQ/RIBW9ALLS35DfmAIFJl5ezTjQAXbOS/3kZtBHgwl2UsKWt1Cu94tpmf4GRyVWCd05xFAbDQaxzB8sjktCoKkC1j9mvI7CAQUlm7IW+yjYInD15/XVYOtZi99sznGl3SnpKDi0eBwWEQB0fiacndFwBw1rrcme8uSDydbvctIqYrevzthVH/C2NG118oQgurKsqGei/p6LxDtcDpA==; 5:F5752h//+qjCOo6xYZrv34m0NmCDl0TeN7En6X4/ZktYbPkpO+yCIPAId3RdP7Ah60JNop5aDOa3egaMtQCKlLQcKTwPx9ojYnqau4n23Dan+IsfKMsj3yAKUtJFz+Dr0SrhUqQKi0GsVtle2IDOl/tn1mLP9fee8nORpo4M2UI=; 7:hDrzPzcIKUFlK4yXATfFIgHzpsUwuaYvIFYZ+1sHa+wAjuuWV1XlxRgXuso4yhmYbDQIRV4hkgNcUMGvEz6SVVKec623Ilss1sSgwjEVCvrGcWXgQJErkZZlbUHYIsSNhMovBXGEHUpUjgYQ+B6TTpFgvJcMyRSCzNvu2mzd1am425eLfsuwTyWT9sVjAuTMdakKb6GUiR4mnlbSznRebpvHZUp4VLv92ijq+RXXMC0WfcklkzSiHBDYmqZjV5Qr x-ms-office365-filtering-correlation-id: b878dba8-6200-4959-a7b4-08d62a34f0ee x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0959; x-ms-traffictypediagnostic: MWHPR04MB0959: 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)(3231355)(944501410)(52105095)(3002001)(6055026)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(201708071742011)(7699051); SRVR:MWHPR04MB0959; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0959; x-forefront-prvs: 0815F8251E x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(346002)(376002)(136003)(39860400002)(189003)(199004)(76176011)(106356001)(476003)(14454004)(71200400001)(68736007)(5250100002)(36756003)(478600001)(186003)(2900100001)(52116002)(26005)(7736002)(486006)(71190400001)(50226002)(305945005)(102836004)(105586002)(54906003)(110136005)(446003)(3846002)(6116002)(11346002)(2616005)(6436002)(8676002)(44832011)(118296001)(5660300001)(81156014)(97736004)(2906002)(316002)(6506007)(386003)(81166006)(256004)(39060400002)(8936002)(99286004)(72206003)(25786009)(2501003)(6512007)(6486002)(66066001)(86362001)(4326008)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0959; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: r+TBzQ9s7JTp4Y+IFvvnpNIzMl6i1X4zbuL+7os2lOq0n6ZPFxkjzPUbhwcLNr0ldHiIO+F+0sD9lW+kjoo0TD9p59yETlMcSYUGvO7x/j8G1xzFRtf3Zmzgg8wAsgZI6ErjzKhWpLTJGxBbwyBCrMjPgq327Gu/HVt1LsOZlQeBcHYq1w93qCaQDR9JpzSPX/o4FW+ctYyQYS5tWQULLZvY70i42z9kFD1LT1XqHMv8khu88KuGpQ5MwX0DdRDeeCerFdzpkROKyGRd6u9wAJL6YHsjEdxgklfQAZaf34xxBTlb0tFAZBgzmP8RVkL3cwNIv3eWkyqDy28hWQsAqDVS1+PFebFR1tPDGdELkRw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b878dba8-6200-4959-a7b4-08d62a34f0ee X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Oct 2018 20:06:59.3526 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0959 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v5 5/5] 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: "alistair23@gmail.com" , "palmer@sifive.com" , Alistair Francis , "stephen@eideticom.com" 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,