i40e: Move NVM event wait check to NVM code
authorShannon Nelson <shannon.nelson@intel.com>
Fri, 1 Apr 2016 10:56:11 +0000 (03:56 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 7 Apr 2016 02:00:42 +0000 (19:00 -0700)
The logic that checks AQ events for NVM done events is better kept
in nvm.c with the rest of the nvmupdate handling code.

Change-ID: I2ea58980df8ecaa3726b28a37bff3dfcb8df03dc
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_adminq.c
drivers/net/ethernet/intel/i40e/i40e_nvm.c
drivers/net/ethernet/intel/i40e/i40e_prototype.h

index e8278e1d61302c484db0991469db8f399dc90954..43bb4139d8963d0e8499652fcee420d5d6033644 100644 (file)
 
 static void i40e_resume_aq(struct i40e_hw *hw);
 
-/**
- * i40e_is_nvm_update_op - return true if this is an NVM update operation
- * @desc: API request descriptor
- **/
-static inline bool i40e_is_nvm_update_op(struct i40e_aq_desc *desc)
-{
-       return (desc->opcode == cpu_to_le16(i40e_aqc_opc_nvm_erase)) ||
-               (desc->opcode == cpu_to_le16(i40e_aqc_opc_nvm_update));
-}
-
 /**
  *  i40e_adminq_init_regs - Initialize AdminQ registers
  *  @hw: pointer to the hardware structure
@@ -1023,26 +1013,7 @@ i40e_status i40e_clean_arq_element(struct i40e_hw *hw,
        hw->aq.arq.next_to_clean = ntc;
        hw->aq.arq.next_to_use = ntu;
 
-       if (i40e_is_nvm_update_op(&e->desc)) {
-               if (hw->nvm_release_on_done) {
-                       i40e_release_nvm(hw);
-                       hw->nvm_release_on_done = false;
-               }
-
-               switch (hw->nvmupd_state) {
-               case I40E_NVMUPD_STATE_INIT_WAIT:
-                       hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
-                       break;
-
-               case I40E_NVMUPD_STATE_WRITE_WAIT:
-                       hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING;
-                       break;
-
-               default:
-                       break;
-               }
-       }
-
+       i40e_nvmupd_check_wait_event(hw, le16_to_cpu(e->desc.opcode));
 clean_arq_element_out:
        /* Set pending if needed, unlock and return */
        if (pending)
index 1ae29ac8c310ececa45316ae53853cc399042ea2..f2cea3d25de31bf06899bc5a11a02d0d6f8ed192 100644 (file)
@@ -1029,6 +1029,37 @@ retry:
        return status;
 }
 
+/**
+ * i40e_nvmupd_check_wait_event - handle NVM update operation events
+ * @hw: pointer to the hardware structure
+ * @opcode: the event that just happened
+ **/
+void i40e_nvmupd_check_wait_event(struct i40e_hw *hw, u16 opcode)
+{
+       if (opcode == i40e_aqc_opc_nvm_erase ||
+           opcode == i40e_aqc_opc_nvm_update) {
+               i40e_debug(hw, I40E_DEBUG_NVM,
+                          "NVMUPD: clearing wait on opcode 0x%04x\n", opcode);
+               if (hw->nvm_release_on_done) {
+                       i40e_release_nvm(hw);
+                       hw->nvm_release_on_done = false;
+               }
+
+               switch (hw->nvmupd_state) {
+               case I40E_NVMUPD_STATE_INIT_WAIT:
+                       hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
+                       break;
+
+               case I40E_NVMUPD_STATE_WRITE_WAIT:
+                       hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING;
+                       break;
+
+               default:
+                       break;
+               }
+       }
+}
+
 /**
  * i40e_nvmupd_validate_command - Validate given command
  * @hw: pointer to hardware structure
index d51eee5bf79acd19d851a7abe3d6b320a5ce14bb..134035f53f2c2a9dc414cc3ba27a49c966205636 100644 (file)
@@ -308,6 +308,7 @@ i40e_status i40e_validate_nvm_checksum(struct i40e_hw *hw,
 i40e_status i40e_nvmupd_command(struct i40e_hw *hw,
                                struct i40e_nvm_access *cmd,
                                u8 *bytes, int *);
+void i40e_nvmupd_check_wait_event(struct i40e_hw *hw, u16 opcode);
 void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status);
 
 extern struct i40e_rx_ptype_decoded i40e_ptype_lookup[];