From patchwork Wed Oct 21 16:37:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lan Tianyu X-Patchwork-Id: 534197 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8E99D141320 for ; Thu, 22 Oct 2015 15:29:52 +1100 (AEDT) Received: from localhost ([::1]:55697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zp7Ve-0005PT-AF for incoming@patchwork.ozlabs.org; Thu, 22 Oct 2015 00:29:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zowa4-0000VT-Qg for qemu-devel@nongnu.org; Wed, 21 Oct 2015 12:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zowa0-0002ZH-Nt for qemu-devel@nongnu.org; Wed, 21 Oct 2015 12:49:40 -0400 Received: from mga09.intel.com ([134.134.136.24]:43256) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zowa0-0002Z9-EF for qemu-devel@nongnu.org; Wed, 21 Oct 2015 12:49:36 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 21 Oct 2015 09:49:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,712,1437462000"; d="scan'208";a="832281205" Received: from lantianyu-ws.sh.intel.com (HELO localhost) ([10.239.159.159]) by fmsmga002.fm.intel.com with ESMTP; 21 Oct 2015 09:49:27 -0700 From: Lan Tianyu To: bhelgaas@google.com, carolyn.wyborny@intel.com, donald.c.skidmore@intel.com, eddie.dong@intel.com, nrupal.jani@intel.com, yang.z.zhang@intel.com, agraf@suse.de, kvm@vger.kernel.org, pbonzini@redhat.com, qemu-devel@nongnu.org, emil.s.tantilov@intel.com, intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com, jesse.brandeburg@intel.com, john.ronciak@intel.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, matthew.vick@intel.com, mitch.a.williams@intel.com, netdev@vger.kernel.org, shannon.nelson@intel.com Date: Thu, 22 Oct 2015 00:37:38 +0800 Message-Id: <1445445464-5056-7-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1445445464-5056-1-git-send-email-tianyu.lan@intel.com> References: <1445445464-5056-1-git-send-email-tianyu.lan@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Cc: Lan Tianyu Subject: [Qemu-devel] [RFC Patch 06/12] IXGBEVF: Add self emulation layer 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 In order to restore VF function after migration, add self emulation layer to record regs' values during accessing regs. Signed-off-by: Lan Tianyu --- drivers/net/ethernet/intel/ixgbevf/Makefile | 3 ++- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 2 +- .../net/ethernet/intel/ixgbevf/self-emulation.c | 26 ++++++++++++++++++++++ drivers/net/ethernet/intel/ixgbevf/vf.h | 5 ++++- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/intel/ixgbevf/self-emulation.c diff --git a/drivers/net/ethernet/intel/ixgbevf/Makefile b/drivers/net/ethernet/intel/ixgbevf/Makefile index 4ce4c97..841c884 100644 --- a/drivers/net/ethernet/intel/ixgbevf/Makefile +++ b/drivers/net/ethernet/intel/ixgbevf/Makefile @@ -31,7 +31,8 @@ obj-$(CONFIG_IXGBEVF) += ixgbevf.o -ixgbevf-objs := vf.o \ +ixgbevf-objs := self-emulation.o \ + vf.o \ mbx.o \ ethtool.o \ ixgbevf_main.o diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index a16d267..4446916 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -156,7 +156,7 @@ u32 ixgbevf_read_reg(struct ixgbe_hw *hw, u32 reg) if (IXGBE_REMOVED(reg_addr)) return IXGBE_FAILED_READ_REG; - value = readl(reg_addr + reg); + value = ixgbe_self_emul_readl(reg_addr, reg); if (unlikely(value == IXGBE_FAILED_READ_REG)) ixgbevf_check_remove(hw, reg); return value; diff --git a/drivers/net/ethernet/intel/ixgbevf/self-emulation.c b/drivers/net/ethernet/intel/ixgbevf/self-emulation.c new file mode 100644 index 0000000..d74b2da --- /dev/null +++ b/drivers/net/ethernet/intel/ixgbevf/self-emulation.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include + +#include "vf.h" +#include "ixgbevf.h" + +static u32 hw_regs[0x4000]; + +u32 ixgbe_self_emul_readl(volatile void __iomem *base, u32 addr) +{ + u32 tmp; + + tmp = readl(base + addr); + hw_regs[(unsigned long)addr] = tmp; + + return tmp; +} + +void ixgbe_self_emul_writel(u32 val, volatile void __iomem *base, u32 addr) +{ + hw_regs[(unsigned long)addr] = val; + writel(val, (volatile void __iomem *)(base + addr)); +} diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.h b/drivers/net/ethernet/intel/ixgbevf/vf.h index d40f036..6a3f4eb 100644 --- a/drivers/net/ethernet/intel/ixgbevf/vf.h +++ b/drivers/net/ethernet/intel/ixgbevf/vf.h @@ -39,6 +39,9 @@ struct ixgbe_hw; +u32 ixgbe_self_emul_readl(volatile void __iomem *base, u32 addr); +void ixgbe_self_emul_writel(u32 val, volatile void __iomem *base, u32 addr); + /* iterator type for walking multicast address lists */ typedef u8* (*ixgbe_mc_addr_itr) (struct ixgbe_hw *hw, u8 **mc_addr_ptr, u32 *vmdq); @@ -182,7 +185,7 @@ static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value) if (IXGBE_REMOVED(reg_addr)) return; - writel(value, reg_addr + reg); + ixgbe_self_emul_writel(value, reg_addr, reg); } #define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)