net/i40e/base: fix retrying logic
authorXiaolong Ye <xiaolong.ye@intel.com>
Mon, 13 Jan 2020 02:39:37 +0000 (10:39 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 17 Jan 2020 18:46:02 +0000 (19:46 +0100)
Fixed a bug where driver was breaking out of the loop and
reporting an error without retrying first.

Fixes: 466eec7d6b1a ("net/i40e/base: retry AQC to overcome IRCRead hangs")

Signed-off-by: Marcin Formela <marcin.formela@intel.com>
Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Beilei Xing <beilei.xing@intel.com>
drivers/net/i40e/base/i40e_common.c

index 4f87ec9..a37e705 100644 (file)
@@ -1714,19 +1714,22 @@ enum i40e_status_code i40e_aq_get_phy_capabilities(struct i40e_hw *hw,
                status = i40e_asq_send_command(hw, &desc, abilities,
                                               abilities_size, cmd_details);
 
-               if (status != I40E_SUCCESS)
-                       break;
-
-               if (hw->aq.asq_last_status == I40E_AQ_RC_EIO) {
+               switch (hw->aq.asq_last_status) {
+               case I40E_AQ_RC_EIO:
                        status = I40E_ERR_UNKNOWN_PHY;
                        break;
-               } else if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN) {
+               case I40E_AQ_RC_EAGAIN:
                        i40e_msec_delay(1);
                        total_delay++;
                        status = I40E_ERR_TIMEOUT;
+                       break;
+               /* also covers I40E_AQ_RC_OK */
+               default:
+                       break;
                }
-       } while ((hw->aq.asq_last_status != I40E_AQ_RC_OK) &&
-                (total_delay < max_delay));
+
+       } while ((hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN) &&
+               (total_delay < max_delay));
 
        if (status != I40E_SUCCESS)
                return status;