From patchwork Wed May 25 14:23:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 816382 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4PEOgQJ000390 for ; Wed, 25 May 2011 14:24:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754940Ab1EYOYh (ORCPT ); Wed, 25 May 2011 10:24:37 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:59024 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754647Ab1EYOYf (ORCPT ); Wed, 25 May 2011 10:24:35 -0400 Received: by mail-ww0-f44.google.com with SMTP id 36so8540053wwa.1 for ; Wed, 25 May 2011 07:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=j7ExzLGHBMwy9wK+EabtEazoUYwWyiWP1cdf96QDOkU=; b=rlRQ0c8wdhoN/xw5EIaeDka/bKLC7jXQ+sTfZJ7bR5ftsh5cL81zJbJ6yIIgtzp3ha QTSZK6aevLY5CU82SJND6/BrnArMv6HnYThrMNMu7oFf01K2V8pwRRqtVOFjigJUdODa VwwIVJU3Qn7rmF5SFOLpqJhHIl0aIckQfVwBU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=pc/bK6jWQ4WLZNGts8U+K3oo5vL9D3a/LLLwzGGmCUUqWnmr+iGvyQQ/fxhuY6l5M2 Z7lHrm8PlJKr7ozGJ7K6RXIdWC4CBsFA6NXLhdiV6GEnH0R7G5lJP3mOqToDwUw8Ax7r +peOHGDKDTv5LW/FK3vrKjng5AXhLw9+8W+Oo= Received: by 10.227.58.16 with SMTP id e16mr4773689wbh.13.1306333475013; Wed, 25 May 2011 07:24:35 -0700 (PDT) Received: from localhost.localdomain (bzq-109-66-201-145.red.bezeqint.net [109.66.201.145]) by mx.google.com with ESMTPS id m21sm404829wbh.25.2011.05.25.07.24.33 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 07:24:34 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: john@jfloren.net, kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, Sasha Levin Subject: [PATCH 8/9] kvm tools: Use dynamic IO port allocation in virtio-net driver Date: Wed, 25 May 2011 17:23:46 +0300 Message-Id: <1306333427-26186-8-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1306333427-26186-1-git-send-email-levinsasha928@gmail.com> References: <1306333427-26186-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 25 May 2011 14:24:42 +0000 (UTC) Signed-off-by: Sasha Levin --- tools/kvm/virtio/net.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c index 649bc0f..765ae56d 100644 --- a/tools/kvm/virtio/net.c +++ b/tools/kvm/virtio/net.c @@ -37,7 +37,6 @@ static struct pci_device_header pci_header = { .class = 0x020000, .subsys_vendor_id = PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET, .subsys_id = VIRTIO_ID_NET, - .bar[0] = IOPORT_VIRTIO_NET | PCI_BASE_ADDRESS_SPACE_IO, }; struct net_device { @@ -51,6 +50,7 @@ struct net_device { u8 status; u8 isr; u16 queue_selector; + u16 base_addr; pthread_t io_rx_thread; pthread_mutex_t io_rx_lock; @@ -166,7 +166,7 @@ static bool virtio_net_pci_io_device_specific_in(void *data, unsigned long offse static bool virtio_net_pci_io_in(struct kvm *kvm, u16 port, void *data, int size, u32 count) { - unsigned long offset = port - IOPORT_VIRTIO_NET; + unsigned long offset = port - ndev.base_addr; bool ret = true; mutex_lock(&ndev.mutex); @@ -230,7 +230,7 @@ static void virtio_net_handle_callback(struct kvm *kvm, u16 queue_index) static bool virtio_net_pci_io_out(struct kvm *kvm, u16 port, void *data, int size, u32 count) { - unsigned long offset = port - IOPORT_VIRTIO_NET; + unsigned long offset = port - ndev.base_addr; bool ret = true; mutex_lock(&ndev.mutex); @@ -387,14 +387,19 @@ void virtio_net__init(const struct virtio_net_parameters *params) { if (virtio_net__tap_init(params)) { u8 dev, line, pin; + u16 net_base_addr; if (irq__register_device(VIRTIO_ID_NET, &dev, &pin, &line) < 0) return; pci_header.irq_pin = pin; pci_header.irq_line = line; + net_base_addr = ioport__find_free_range(); + pci_header.bar[0] = net_base_addr | PCI_BASE_ADDRESS_SPACE_IO; + ndev.base_addr = net_base_addr; + pci__register(&pci_header, dev); - ioport__register(IOPORT_VIRTIO_NET, &virtio_net_io_ops, IOPORT_VIRTIO_NET_SIZE); + ioport__register(net_base_addr, &virtio_net_io_ops, IOPORT_SIZE); virtio_net__io_thread_init(params->kvm); }