From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47499 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Op1IN-0002K4-QK for qemu-devel@nongnu.org; Fri, 27 Aug 2010 11:56:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Op1Ai-0000G3-DN for qemu-devel@nongnu.org; Fri, 27 Aug 2010 11:51:20 -0400 Received: from mail-vw0-f45.google.com ([209.85.212.45]:48080) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Op1Ai-0000FJ-Ak for qemu-devel@nongnu.org; Fri, 27 Aug 2010 11:48:52 -0400 Received: by vws19 with SMTP id 19so3089124vws.4 for ; Fri, 27 Aug 2010 08:48:50 -0700 (PDT) MIME-Version: 1.0 Sender: camm@ualberta.ca In-Reply-To: <20100825223950.7e664cb4@shadowfax.no-ip.com> References: <20100825223950.7e664cb4@shadowfax.no-ip.com> Date: Fri, 27 Aug 2010 09:48:48 -0600 Message-ID: Subject: Re: [Qemu-devel] Template for developing a Qemu device with PCIe and MSI-X From: Cam Macdonell Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: adnan@khaleel.us Cc: Isaku Yamahata , qemu-devel@nongnu.org On Wed, Aug 25, 2010 at 4:39 PM, Adnan Khaleel wrote: > Hi Isaku, > > I've made some progress in coding the device template but its no where ne= ar > complete. > > I've created some files and am attaching it to this note. Based on what I > could gather from the pcie source files I've made a stab at creating a > simple model. I've also attached a file for a simple pci device that work= s > under regular Qemu. I would like to duplicate its functionality in your p= cie > environment for starters. > > Could you please take a look at the files I've created and tell me if I'v= e > understood your pcie model correctly. Any help will be truly appreciated. > > Adnan Hi Adnan, There is a fairly simple device I've created called "ivshmem" that is in the qemu git tree. It is a regular PCI device that exports a shared memory object via a BAR and supports a few registers and optional MSI-X interrupts (I had to pick through the virtio code to get MSI-X working, so looking at ivshmem might save you some effort). My device is somewhat similar to a graphics card actually which I recall is your goal. The purpose of ivshmem is to support sharing memory between multiple guests running on the same host. It follows the qdev model which you will need to do. Cam > > The five files I've modified from your git repository are as follows > > hw/pci_ids.h=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 // = Added vendor id defines > hw/pc_q35.c=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 // D= evice instantiation > hw/pcie_msix_template.h=A0 // Device header file > hw/pcie_msix_template.c=A0 // Device file > Makefile.objs=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 // Ad= ded pcie_msix_template.o to list of > objects being built > > Everything should compile without any warnings or errors. > > The last file: > sc_link_pci.c > Is the original PCI device that I'm trying to convert into being PCIe and > MSI-X and is included merely for reference to help you understand what I'= d > like to achieve in your environment. > > > ________________________________ > From: Isaku Yamahata [mailto:yamahata@valinux.co.jp] > To: Adnan Khaleel [mailto:adnan@khaleel.us] > Cc: qemu-devel@nongnu.org > Sent: Wed, 18 Aug 2010 22:19:04 -0500 > Subject: Re: [Qemu-devel] Template for developing a Qemu device with PCIe > and MSI-X > > On Wed, Aug 18, 2010 at 02:10:10PM -0500, Adnan Khaleel wrote: >> Hello Qemu developers, >> >> I'm interested in developing a device model that plugs into Qemu that is >> based >> on a PCIe interface and uses MSI-X. My goal is to ultimately attach a GP= U >> simulator to this PCIe interface and use the entire platfom (Qemu + GPU >> simulator) for studying cpu, gpu interactions. >> >> I'm not terribly familiar with the Qemu device model and I'm looking for >> some >> assistance, perhaps a starting template for pcie and msi-x that would >> offer the >> basic functionality that I could then build upon. >> >> I have looked at the various devices that already modelled that are >> included >> with Qemu (v0.12.5 at least) and I've noticed several a few pci devices, >> eg; >> ne2k and cirrus-pci etc, however only one device truly seems to utilize >> both >> the technologies that I'm interested in and that is the virtio-pci.c >> >> I'm not sure what virtio-pci does so I'm not sure if that is a suitable >> starting point for me. >> >> Any help, suggestions etc would be extremely helpful and much appreciate= d. > > Qemu doesn't support pcie at the moment. > Only partial patches have been merged, still more patches have to > be merged for pcie to fully work. The following repo is available. > > git clone http://people.valinux.co.jp/~yamahata/qemu/q35/qemu > git clone http://people.valinux.co.jp/~yamahata/qemu/q35/seabios > git clone http://people.valinux.co.jp/~yamahata/qemu/q35/vgabios > > Note: patched seabios and vgabios are needed, you have to pass ACPI DSDT > for q35. > example: > qemu-system-x86_64 -M pc_q35 -acpitable > load_header,data=3Droms/seabios/src/q35-acpi-dsdt.aml > > This repo is for those who want to try/develop pcie support, > not for upstream merge. So they include patches unsuitable for upstream. > The repo includes pcie port switch emulator which utilize pcie and > MSI(not MSI-X). > > The difference between PCI device and PCIe device is configuration > space size. > By setting PCIDeviceInfo::is_express =3D 1, you'll get 4K configuration > space. Helper functions for pcie are found in qemu/hw/pcie.c > For msi-x, see qemu/hw/msix.c. > > Thanks, > -- > yamahata >