]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ixgbe: add FW API version check
authorJedrzej Jagielski <jedrzej.jagielski@intel.com>
Thu, 10 Apr 2025 13:00:06 +0000 (15:00 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 15 Apr 2025 14:36:33 +0000 (07:36 -0700)
Add E610 specific function checking whether the FW API version
is compatible with the driver expectations.

The major API version should be less than or equal to the expected
API version. If not the driver won't be fully operational.

Check the minor version, and if it is more than two versions lesser
or greater than the expected version, print a message indicating
that the NVM or driver should be updated respectively.

Reviewed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
Co-developed-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
Signed-off-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Tested-by: Bharath R <bharath.r@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ixgbe/devlink/devlink.c
drivers/net/ethernet/intel/ixgbe/ixgbe.h
drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
drivers/net/ethernet/intel/ixgbe/ixgbe_type_e610.h

index d0197991763c12d17773da6684ecdcc3762000cf..3e79e446a9449e61d36c3501f6b016723faff5a4 100644 (file)
@@ -471,6 +471,8 @@ static int ixgbe_devlink_reload_empr_finish(struct devlink *devlink,
 
        *actions_performed = BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE);
 
+       adapter->flags2 &= ~IXGBE_FLAG2_API_MISMATCH;
+
        return 0;
 }
 
index 83d4d7368cdac24e5967e6bb2906bcaf5e1d2ff3..2246997bc9fb4583043e822c6d365cf6950ace4a 100644 (file)
@@ -671,6 +671,7 @@ struct ixgbe_adapter {
 #define IXGBE_FLAG2_PHY_FW_LOAD_FAILED         BIT(20)
 #define IXGBE_FLAG2_NO_MEDIA                   BIT(21)
 #define IXGBE_FLAG2_MOD_POWER_UNSUPPORTED      BIT(22)
+#define IXGBE_FLAG2_API_MISMATCH               BIT(23)
 
        /* Tx fast path data */
        int num_tx_queues;
index 9dd788aea0c210edc651771e7dcc3823bf32e389..5d42da11547e3f3beb9b31b860247a634392af4f 100644 (file)
@@ -3873,6 +3873,7 @@ static const struct ixgbe_mac_operations mac_ops_e610 = {
        .led_off                        = ixgbe_led_off_generic,
        .init_led_link_act              = ixgbe_init_led_link_act_generic,
        .reset_hw                       = ixgbe_reset_hw_e610,
+       .get_fw_ver                     = ixgbe_aci_get_fw_ver,
        .get_media_type                 = ixgbe_get_media_type_e610,
        .setup_link                     = ixgbe_setup_link_e610,
        .get_link_capabilities          = ixgbe_get_link_capabilities_e610,
index 2cc0af0dfe7ce8ff83ceafe8ce8ff9d30776032b..84ee481a0ce1ae51b78f85a4c5d3c31794f6d17e 100644 (file)
@@ -8365,6 +8365,34 @@ static void ixgbe_reset_subtask(struct ixgbe_adapter *adapter)
        rtnl_unlock();
 }
 
+static int ixgbe_check_fw_api_mismatch(struct ixgbe_adapter *adapter)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+
+       if (hw->mac.type != ixgbe_mac_e610)
+               return 0;
+
+       if (hw->mac.ops.get_fw_ver && hw->mac.ops.get_fw_ver(hw))
+               return 0;
+
+       if (hw->api_maj_ver > IXGBE_FW_API_VER_MAJOR) {
+               e_dev_err("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");
+
+               adapter->flags2 |= IXGBE_FLAG2_API_MISMATCH;
+               return -EOPNOTSUPP;
+       } else if (hw->api_maj_ver == IXGBE_FW_API_VER_MAJOR &&
+                  hw->api_min_ver > IXGBE_FW_API_VER_MINOR + IXGBE_FW_API_VER_DIFF_ALLOWED) {
+               e_dev_info("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");
+               adapter->flags2 |= IXGBE_FLAG2_API_MISMATCH;
+       } else if (hw->api_maj_ver < IXGBE_FW_API_VER_MAJOR ||
+                  hw->api_min_ver < IXGBE_FW_API_VER_MINOR - IXGBE_FW_API_VER_DIFF_ALLOWED) {
+               e_dev_info("The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n");
+               adapter->flags2 |= IXGBE_FLAG2_API_MISMATCH;
+       }
+
+       return 0;
+}
+
 /**
  * ixgbe_check_fw_error - Check firmware for errors
  * @adapter: the adapter private structure
@@ -8375,6 +8403,7 @@ static bool ixgbe_check_fw_error(struct ixgbe_adapter *adapter)
 {
        struct ixgbe_hw *hw = &adapter->hw;
        u32 fwsm;
+       int err;
 
        /* read fwsm.ext_err_ind register and log errors */
        fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM(hw));
@@ -8389,6 +8418,11 @@ static bool ixgbe_check_fw_error(struct ixgbe_adapter *adapter)
                e_dev_err("Firmware recovery mode detected. Limiting functionality. Refer to the Intel(R) Ethernet Adapters and Devices User Guide for details on firmware recovery mode.\n");
                return true;
        }
+       if (!(adapter->flags2 & IXGBE_FLAG2_API_MISMATCH)) {
+               err = ixgbe_check_fw_api_mismatch(adapter);
+               if (err)
+                       return true;
+       }
 
        return false;
 }
index 5f814f023573f977db375fb47490b04d7ed7a77e..6bf6ba7dcdccd9e9e9c76f1b462e6d6d179af114 100644 (file)
@@ -3456,6 +3456,7 @@ struct ixgbe_mac_operations {
        int (*start_hw)(struct ixgbe_hw *);
        int (*clear_hw_cntrs)(struct ixgbe_hw *);
        enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
+       int (*get_fw_ver)(struct ixgbe_hw *hw);
        int (*get_mac_addr)(struct ixgbe_hw *, u8 *);
        int (*get_san_mac_addr)(struct ixgbe_hw *, u8 *);
        int (*get_device_caps)(struct ixgbe_hw *, u16 *);
index c36eaff3a08346a60c14dc0d598b1672533061b8..2e105419eef84f5df14ff66c95e94877f71177b4 100644 (file)
 #define IXGBE_PF_HICR_SV                       BIT(2)
 #define IXGBE_PF_HICR_EV                       BIT(3)
 
+#define IXGBE_FW_API_VER_MAJOR         0x01
+#define IXGBE_FW_API_VER_MINOR         0x07
+#define IXGBE_FW_API_VER_DIFF_ALLOWED  0x02
+
 #define IXGBE_ACI_DESC_SIZE            32
 #define IXGBE_ACI_DESC_SIZE_IN_DWORDS  (IXGBE_ACI_DESC_SIZE / BYTES_PER_DWORD)