]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/net/ethernet/intel/ice/ice_controlq.c
ice: update fw version check logic
[linux.git] / drivers / net / ethernet / intel / ice / ice_controlq.c
index 62be72fdc8f30c283b2385216f41ff15b87dc628..b25ce4f587f5e7f4de00ed4815ab6f4425a376bb 100644 (file)
@@ -518,22 +518,31 @@ ice_shutdown_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
 
 /**
  * ice_aq_ver_check - Check the reported AQ API version.
- * @fw_branch: The "branch" of FW, typically describes the device type
- * @fw_major: The major version of the FW API
- * @fw_minor: The minor version increment of the FW API
+ * @hw: pointer to the hardware structure
  *
  * Checks if the driver should load on a given AQ API version.
  *
  * Return: 'true' iff the driver should attempt to load. 'false' otherwise.
  */
-static bool ice_aq_ver_check(u8 fw_branch, u8 fw_major, u8 fw_minor)
+static bool ice_aq_ver_check(struct ice_hw *hw)
 {
-       if (fw_branch != EXP_FW_API_VER_BRANCH)
-               return false;
-       if (fw_major != EXP_FW_API_VER_MAJOR)
-               return false;
-       if (fw_minor != EXP_FW_API_VER_MINOR)
+       if (hw->api_maj_ver > EXP_FW_API_VER_MAJOR) {
+               /* Major API version is newer than expected, don't load */
+               dev_warn(ice_hw_to_dev(hw),
+                        "The driver for the device stopped because the NVM image is newer than expected. You must install the most recent version of the network driver.\n");
                return false;
+       } else if (hw->api_maj_ver == EXP_FW_API_VER_MAJOR) {
+               if (hw->api_min_ver > (EXP_FW_API_VER_MINOR + 2))
+                       dev_info(ice_hw_to_dev(hw),
+                                "The driver for the device detected a newer version of the NVM image than expected. Please install the most recent version of the network driver.\n");
+               else if ((hw->api_min_ver + 2) < EXP_FW_API_VER_MINOR)
+                       dev_info(ice_hw_to_dev(hw),
+                                "The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n");
+       } else {
+               /* Major API version is older than expected, log a warning */
+               dev_info(ice_hw_to_dev(hw),
+                        "The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n");
+       }
        return true;
 }
 
@@ -588,8 +597,7 @@ static enum ice_status ice_init_check_adminq(struct ice_hw *hw)
        if (status)
                goto init_ctrlq_free_rq;
 
-       if (!ice_aq_ver_check(hw->api_branch, hw->api_maj_ver,
-                             hw->api_min_ver)) {
+       if (!ice_aq_ver_check(hw)) {
                status = ICE_ERR_FW_API_VER;
                goto init_ctrlq_free_rq;
        }
@@ -597,11 +605,11 @@ static enum ice_status ice_init_check_adminq(struct ice_hw *hw)
        return 0;
 
 init_ctrlq_free_rq:
-       if (cq->rq.head) {
+       if (cq->rq.count) {
                ice_shutdown_rq(hw, cq);
                mutex_destroy(&cq->rq_lock);
        }
-       if (cq->sq.head) {
+       if (cq->sq.count) {
                ice_shutdown_sq(hw, cq);
                mutex_destroy(&cq->sq_lock);
        }
@@ -710,11 +718,11 @@ static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)
                return;
        }
 
-       if (cq->sq.head) {
+       if (cq->sq.count) {
                ice_shutdown_sq(hw, cq);
                mutex_destroy(&cq->sq_lock);
        }
-       if (cq->rq.head) {
+       if (cq->rq.count) {
                ice_shutdown_rq(hw, cq);
                mutex_destroy(&cq->rq_lock);
        }
@@ -806,6 +814,9 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
        u16 retval = 0;
        u32 val = 0;
 
+       /* if reset is in progress return a soft error */
+       if (hw->reset_ongoing)
+               return ICE_ERR_RESET_ONGOING;
        mutex_lock(&cq->sq_lock);
 
        cq->sq_last_status = ICE_AQ_RC_OK;
@@ -847,7 +858,7 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
 
        details = ICE_CTL_Q_DETAILS(cq->sq, cq->sq.next_to_use);
        if (cd)
-               memcpy(details, cd, sizeof(*details));
+               *details = *cd;
        else
                memset(details, 0, sizeof(*details));