[dpdk-dev,08/16] fm10k: ensure VF restores itr_scale on stop_hw

Message ID 1437986559-31016-8-git-send-email-xiao.w.wang@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Xiao Wang July 27, 2015, 8:42 a.m. UTC
  In a recent change, the ITR scale was given to the VF via TDLEN
registers at driver initialization. This allows the VF to determine what
the ITR scale for PCIe link speed should be. However, a VF unload
followed by a reload incorrectly left this value as 0. Thus, the driver
reloads and uses 0 as the ITR scale instead of the correct value. If the
VF driver blindly trusted this value it could cause a divide by zero
failure.

Fix this by having stop_hw_vf reset the ITR scale as the device goes
down, similar to the way we handle the MAC address.

Signed-off-by: Wang Xiao W <xiao.w.wang@intel.com>
---
 drivers/net/fm10k/base/fm10k_vf.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/fm10k/base/fm10k_vf.c b/drivers/net/fm10k/base/fm10k_vf.c
index ce42189..7981417 100644
--- a/drivers/net/fm10k/base/fm10k_vf.c
+++ b/drivers/net/fm10k/base/fm10k_vf.c
@@ -41,7 +41,7 @@  POSSIBILITY OF SUCH DAMAGE.
 STATIC s32 fm10k_stop_hw_vf(struct fm10k_hw *hw)
 {
 	u8 *perm_addr = hw->mac.perm_addr;
-	u32 bal = 0, bah = 0;
+	u32 bal = 0, bah = 0, tdlen;
 	s32 err;
 	u16 i;
 
@@ -63,6 +63,9 @@  STATIC s32 fm10k_stop_hw_vf(struct fm10k_hw *hw)
 		       ((u32)perm_addr[2]);
 	}
 
+	/* restore default itr_scale for next VF initialization */
+	tdlen = hw->mac.itr_scale << FM10K_TDLEN_ITR_SCALE_SHIFT;
+
 	/* The queues have already been disabled so we just need to
 	 * update their base address registers
 	 */
@@ -71,6 +74,7 @@  STATIC s32 fm10k_stop_hw_vf(struct fm10k_hw *hw)
 		FM10K_WRITE_REG(hw, FM10K_TDBAH(i), bah);
 		FM10K_WRITE_REG(hw, FM10K_RDBAL(i), bal);
 		FM10K_WRITE_REG(hw, FM10K_RDBAH(i), bah);
+		FM10K_WRITE_REG(hw, FM10K_TDLEN(i), tdlen);
 	}
 
 	return FM10K_SUCCESS;