[dpdk-dev,v3] net/i40e: fix PF notify issue when VF not up

Message ID 1501256891-38849-1-git-send-email-xiaoyun.li@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Li, Xiaoyun July 28, 2017, 3:48 p.m. UTC
  This patch stops PF from sending messages to inactive VF
and modifies VF state to active when VF reset is completed.

Fixes: 4861cde46116 ("i40e: new poll mode driver")
Cc: stable@dpdk.org

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
---
 drivers/net/i40e/i40e_pf.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)
  

Comments

Jingjing Wu July 31, 2017, 2:50 a.m. UTC | #1
> -----Original Message-----
> From: Li, Xiaoyun
> Sent: Friday, July 28, 2017 11:48 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Li, Xiaoyun <xiaoyun.li@intel.com>; stable@dpdk.org
> Subject: [PATCH v3] net/i40e: fix PF notify issue when VF not up
> 
> This patch stops PF from sending messages to inactive VF
> and modifies VF state to active when VF reset is completed.
> 
> Fixes: 4861cde46116 ("i40e: new poll mode driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>

Thanks
Jingjing
  
Ferruh Yigit July 31, 2017, 2:41 p.m. UTC | #2
On 7/31/2017 3:50 AM, Wu, Jingjing wrote:
> 
> 
>> -----Original Message-----
>> From: Li, Xiaoyun
>> Sent: Friday, July 28, 2017 11:48 PM
>> To: Wu, Jingjing <jingjing.wu@intel.com>
>> Cc: dev@dpdk.org; Li, Xiaoyun <xiaoyun.li@intel.com>; stable@dpdk.org
>> Subject: [PATCH v3] net/i40e: fix PF notify issue when VF not up
>>
>> This patch stops PF from sending messages to inactive VF
>> and modifies VF state to active when VF reset is completed.
>>
>> Fixes: 4861cde46116 ("i40e: new poll mode driver")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
> Acked-by: Jingjing Wu <jingjing.wu@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index b4cf57f..e64f849 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -152,22 +152,22 @@  i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool do_hw_reset)
 		val |= I40E_VPGEN_VFRTRIG_VFSWR_MASK;
 		I40E_WRITE_REG(hw, I40E_VPGEN_VFRTRIG(vf_id), val);
 		I40E_WRITE_FLUSH(hw);
-	}
 
 #define VFRESET_MAX_WAIT_CNT 100
-	/* Wait until VF reset is done */
-	for (i = 0; i < VFRESET_MAX_WAIT_CNT; i++) {
-		rte_delay_us(10);
-		val = I40E_READ_REG(hw, I40E_VPGEN_VFRSTAT(vf_id));
-		if (val & I40E_VPGEN_VFRSTAT_VFRD_MASK)
-			break;
-	}
+		/* Wait until VF reset is done */
+		for (i = 0; i < VFRESET_MAX_WAIT_CNT; i++) {
+			rte_delay_us(10);
+			val = I40E_READ_REG(hw, I40E_VPGEN_VFRSTAT(vf_id));
+			if (val & I40E_VPGEN_VFRSTAT_VFRD_MASK)
+				break;
+		}
 
-	if (i >= VFRESET_MAX_WAIT_CNT) {
-		PMD_DRV_LOG(ERR, "VF reset timeout");
-		return -ETIMEDOUT;
+		if (i >= VFRESET_MAX_WAIT_CNT) {
+			PMD_DRV_LOG(ERR, "VF reset timeout");
+			return -ETIMEDOUT;
+		}
+		vf->state = I40E_VF_ACTIVE;
 	}
-
 	/* This is not first time to do reset, do cleanup job first */
 	if (vf->vsi) {
 		/* Disable queues */
@@ -262,7 +262,10 @@  i40e_pf_host_send_msg_to_vf(struct i40e_pf_vf *vf,
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
 	uint16_t abs_vf_id = hw->func_caps.vf_base_id + vf->vf_idx;
-	int ret;
+	int ret = I40E_ERR_ADMIN_QUEUE_ERROR;
+
+	if (vf->state == I40E_VF_INACTIVE)
+		return ret;
 
 	ret = i40e_aq_send_msg_to_vf(hw, abs_vf_id, opcode, retval,
 						msg, msglen, NULL);