net/ice/base: add function to get FW mode
authorQi Zhang <qi.z.zhang@intel.com>
Thu, 29 Aug 2019 02:35:55 +0000 (10:35 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:52 +0000 (15:00 +0200)
Add a helper function to get FW mode. The FW mode can be normal,
debug, recovery or rollback.

This makes ice_is_fw_in_rec_mode redundant, so remove it.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
drivers/net/ice/base/ice_common.c
drivers/net/ice/base/ice_common.h

index 52fd8c8..681740c 100644 (file)
@@ -4102,16 +4102,25 @@ ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
 }
 
 /**
- * ice_is_fw_in_rec_mode
+ * ice_get_fw_mode - returns FW mode
  * @hw: pointer to the HW struct
- *
- * This function returns true if fw is in recovery mode
  */
-bool ice_is_fw_in_rec_mode(struct ice_hw *hw)
+enum ice_fw_modes ice_get_fw_mode(struct ice_hw *hw)
 {
-       u32 reg;
+#define ICE_FW_MODE_DBG_M BIT(0)
+#define ICE_FW_MODE_REC_M BIT(1)
+#define ICE_FW_MODE_ROLLBACK_M BIT(2)
+       u32 fw_mode;
 
        /* check the current FW mode */
-       reg = rd32(hw, GL_MNG_FWSM);
-       return (reg & GL_MNG_FWSM_FW_MODES_M) > ICE_FW_MODE_DBG;
+       fw_mode = rd32(hw, GL_MNG_FWSM) & GL_MNG_FWSM_FW_MODES_M;
+
+       if (fw_mode & ICE_FW_MODE_DBG_M)
+               return ICE_FW_MODE_DBG;
+       else if (fw_mode & ICE_FW_MODE_REC_M)
+               return ICE_FW_MODE_REC;
+       else if (fw_mode & ICE_FW_MODE_ROLLBACK_M)
+               return ICE_FW_MODE_ROLLBACK;
+       else
+               return ICE_FW_MODE_NORMAL;
 }
index 2063295..1d8701d 100644 (file)
@@ -14,7 +14,7 @@ enum ice_fw_modes {
        ICE_FW_MODE_NORMAL,
        ICE_FW_MODE_DBG,
        ICE_FW_MODE_REC,
-       ICE_FW_MODE_DBG_REC
+       ICE_FW_MODE_ROLLBACK
 };
 
 enum ice_status ice_nvm_validate_checksum(struct ice_hw *hw);
@@ -198,8 +198,8 @@ ice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
 void
 ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
                  u64 *prev_stat, u64 *cur_stat);
+enum ice_fw_modes ice_get_fw_mode(struct ice_hw *hw);
 enum ice_status
 ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
                     struct ice_aqc_get_elem *buf);
-bool ice_is_fw_in_rec_mode(struct ice_hw *hw);
 #endif /* _ICE_COMMON_H_ */