i40e/base: fix error handling of NVM state update
authorHelin Zhang <helin.zhang@intel.com>
Thu, 30 Apr 2015 15:03:18 +0000 (23:03 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 15 May 2015 14:33:15 +0000 (16:33 +0200)
The state transitions after an error were not managed well, so
these changes get us back to the INIT state or don't transit
out of the INIT state after most errors.

Test report: http://www.dpdk.org/ml/archives/dev/2015-May/017384.html

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
Acked-by: Jijiang Liu <jijiang.liu@intel.com>
Tested-by: Min Cao <min.cao@intel.com>
lib/librte_pmd_i40e/i40e/i40e_nvm.c

index 39f821e..2f3c6a6 100644 (file)
@@ -793,7 +793,10 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct i40e_hw *hw,
                                                     hw->aq.asq_last_status);
                } else {
                        status = i40e_nvmupd_nvm_read(hw, cmd, bytes, perrno);
-                       hw->nvmupd_state = I40E_NVMUPD_STATE_READING;
+                       if (status)
+                               i40e_release_nvm(hw);
+                       else
+                               hw->nvmupd_state = I40E_NVMUPD_STATE_READING;
                }
                break;
 
@@ -832,7 +835,10 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct i40e_hw *hw,
                                                     hw->aq.asq_last_status);
                } else {
                        status = i40e_nvmupd_nvm_write(hw, cmd, bytes, perrno);
-                       hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING;
+                       if (status)
+                               i40e_release_nvm(hw);
+                       else
+                               hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING;
                }
                break;
 
@@ -856,6 +862,9 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct i40e_hw *hw,
                break;
 
        default:
+               i40e_debug(hw, I40E_DEBUG_NVM,
+                          "NVMUPD: bad cmd %s in init state\n",
+                          i40e_nvm_update_state_str[upd_cmd]);
                status = I40E_ERR_NVM;
                *perrno = -ESRCH;
                break;
@@ -937,35 +946,38 @@ retry:
 
        case I40E_NVMUPD_WRITE_LCB:
                status = i40e_nvmupd_nvm_write(hw, cmd, bytes, perrno);
-               if (!status) {
+               if (!status)
                        hw->aq.nvm_release_on_done = true;
-                       hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
-               }
+               hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
                break;
 
        case I40E_NVMUPD_CSUM_CON:
                status = i40e_update_nvm_checksum(hw);
-               if (status)
+               if (status) {
                        *perrno = hw->aq.asq_last_status ?
                                   i40e_aq_rc_to_posix(status,
                                                       hw->aq.asq_last_status) :
                                   -EIO;
+                       hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
+               }
                break;
 
        case I40E_NVMUPD_CSUM_LCB:
                status = i40e_update_nvm_checksum(hw);
-               if (status) {
+               if (status)
                        *perrno = hw->aq.asq_last_status ?
                                   i40e_aq_rc_to_posix(status,
                                                       hw->aq.asq_last_status) :
                                   -EIO;
-               } else {
+               else
                        hw->aq.nvm_release_on_done = true;
-                       hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
-               }
+               hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
                break;
 
        default:
+               i40e_debug(hw, I40E_DEBUG_NVM,
+                          "NVMUPD: bad cmd %s in writing state.\n",
+                          i40e_nvm_update_state_str[upd_cmd]);
                status = I40E_NOT_SUPPORTED;
                *perrno = -ESRCH;
                break;