From patchwork Thu May 17 13:32:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 159902 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 11604B6FD7 for ; Thu, 17 May 2012 23:33:21 +1000 (EST) Received: from localhost ([::1]:45881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV0pS-000164-Fb for incoming@patchwork.ozlabs.org; Thu, 17 May 2012 09:33:18 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV0p7-0000yM-Qw for qemu-devel@nongnu.org; Thu, 17 May 2012 09:33:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SV0p3-0004XK-4R for qemu-devel@nongnu.org; Thu, 17 May 2012 09:32:57 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:44261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV0p2-0004Wy-RT for qemu-devel@nongnu.org; Thu, 17 May 2012 09:32:53 -0400 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate03.web.de (Postfix) with ESMTP id 5E0431B4D38D0 for ; Thu, 17 May 2012 15:32:51 +0200 (CEST) Received: from localhost.localdomain ([187.105.13.240]) by smtp.web.de (mrweb001) with ESMTPA (Nemesis) id 0LuuC9-1S4eNk2b1V-01083v; Thu, 17 May 2012 15:32:51 +0200 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Thu, 17 May 2012 10:32:29 -0300 Message-Id: X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-Provags-ID: V02:K0:h3Nq49oMlaMwm13DiCD1GP6reCYACtT2cuTqUCGiX0p PiyrKRjscajBHIj54+UpW5zhPkEbMa2VmoWkuN0YF9YeGlCSov lHJgGSM9VeDo9uE/u44l1KlJSfwqGF5n9aGueTHWoXM8kFMkUz 3NpEmjLKHgsfibRUwWCLFCxGsLoOqg6gxhlEku1kphU1Q+/wws WuIcSlTV6EekwYspfYppw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.234 Cc: qemu-devel , kvm@vger.kernel.org, "Michael S. Tsirkin" Subject: [Qemu-devel] [RFC][PATCH v2 01/11] msix: Factor out msix_get_message 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 From: Jan Kiszka This helper will also be used by the upcoming config notifier. Signed-off-by: Jan Kiszka --- hw/msix.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/msix.c b/hw/msix.c index 3835eaa..3197465 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -35,6 +35,15 @@ #define MSIX_PAGE_PENDING (MSIX_PAGE_SIZE / 2) #define MSIX_MAX_ENTRIES 32 +static MSIMessage msix_get_message(PCIDevice *dev, unsigned vector) +{ + uint8_t *table_entry = dev->msix_table_page + vector * PCI_MSIX_ENTRY_SIZE; + MSIMessage msg; + + msg.address = pci_get_quad(table_entry + PCI_MSIX_ENTRY_LOWER_ADDR); + msg.data = pci_get_long(table_entry + PCI_MSIX_ENTRY_DATA); + return msg; +} /* Add MSI-X capability to the config space for the device. */ /* Given a bar and its size, add MSI-X table on top of it @@ -352,9 +361,7 @@ uint32_t msix_bar_size(PCIDevice *dev) /* Send an MSI-X message */ void msix_notify(PCIDevice *dev, unsigned vector) { - uint8_t *table_entry = dev->msix_table_page + vector * PCI_MSIX_ENTRY_SIZE; - uint64_t address; - uint32_t data; + MSIMessage msg; if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) return; @@ -363,9 +370,9 @@ void msix_notify(PCIDevice *dev, unsigned vector) return; } - address = pci_get_quad(table_entry + PCI_MSIX_ENTRY_LOWER_ADDR); - data = pci_get_long(table_entry + PCI_MSIX_ENTRY_DATA); - stl_le_phys(address, data); + msg = msix_get_message(dev, vector); + + stl_le_phys(msg.address, msg.data); } void msix_reset(PCIDevice *dev)