[dpdk-dev,22/28] fm10k: do not assume VF always has 1 queue

Message ID 1441859917-26475-23-git-send-email-xiao.w.wang@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Xiao Wang Sept. 10, 2015, 4:38 a.m. UTC
  It is possible that the PF has not yet assigned resources to the VF.
Although rare, this could result in the VF attempting to read queues it
does not own and result in FUM or THI faults in the PF. To prevent this,
check queue 0 before we continue in init_hw_vf.

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

Patch

diff --git a/drivers/net/fm10k/base/fm10k_vf.c b/drivers/net/fm10k/base/fm10k_vf.c
index ba7c7c1..3fba007 100644
--- a/drivers/net/fm10k/base/fm10k_vf.c
+++ b/drivers/net/fm10k/base/fm10k_vf.c
@@ -126,7 +126,12 @@  STATIC s32 fm10k_init_hw_vf(struct fm10k_hw *hw)
 
 	DEBUGFUNC("fm10k_init_hw_vf");
 
-	/* assume we always have at least 1 queue */
+	/* verify we have at least 1 queue */
+	if (!~FM10K_READ_REG(hw, FM10K_TXQCTL(0)) ||
+	    !~FM10K_READ_REG(hw, FM10K_RXQCTL(0)))
+		return FM10K_ERR_NO_RESOURCES;
+
+	/* determine how many queues we have */
 	for (i = 1; tqdloc0 && (i < FM10K_MAX_QUEUES_POOL); i++) {
 		/* verify the Descriptor cache offsets are increasing */
 		tqdloc = ~FM10K_READ_REG(hw, FM10K_TQDLOC(i));