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: 7458851 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5611FBEEA4 for ; Wed, 21 Oct 2015 16:50:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73DEF20875 for ; Wed, 21 Oct 2015 16:50:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 731B620887 for ; Wed, 21 Oct 2015 16:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756181AbbJUQuF (ORCPT ); Wed, 21 Oct 2015 12:50:05 -0400 Received: from mga01.intel.com ([192.55.52.88]:5395 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755829AbbJUQuD (ORCPT ); Wed, 21 Oct 2015 12:50:03 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 21 Oct 2015 09:49:35 -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 Cc: Lan Tianyu Subject: [RFC Patch 06/12] IXGBEVF: Add self emulation layer 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)