Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c150a502 authored by Shannon Nelson's avatar Shannon Nelson Committed by Jeff Kirsher
Browse files

i40e: better error messages for NVM update issues



Add more detail to the NVM update error messages so folks
have a better chance at diagnosing issues without having to
resort to heroic measures to reproduce an issue.

Change-ID: I270d1a9c903baceaef0bebcc55d29108ac08b0bd
Signed-off-by: default avatarShannon Nelson <shannon.nelson@intel.com>
Tested-by: default avatarJim Young <jamesx.m.young@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 4443ec94
Loading
Loading
Loading
Loading
+33 −19
Original line number Original line Diff line number Diff line
@@ -822,7 +822,7 @@ static int i40e_get_eeprom(struct net_device *netdev,
	struct i40e_netdev_priv *np = netdev_priv(netdev);
	struct i40e_netdev_priv *np = netdev_priv(netdev);
	struct i40e_hw *hw = &np->vsi->back->hw;
	struct i40e_hw *hw = &np->vsi->back->hw;
	struct i40e_pf *pf = np->vsi->back;
	struct i40e_pf *pf = np->vsi->back;
	int ret_val = 0, len;
	int ret_val = 0, len, offset;
	u8 *eeprom_buff;
	u8 *eeprom_buff;
	u16 i, sectors;
	u16 i, sectors;
	bool last;
	bool last;
@@ -835,19 +835,21 @@ static int i40e_get_eeprom(struct net_device *netdev,
	/* check for NVMUpdate access method */
	/* check for NVMUpdate access method */
	magic = hw->vendor_id | (hw->device_id << 16);
	magic = hw->vendor_id | (hw->device_id << 16);
	if (eeprom->magic && eeprom->magic != magic) {
	if (eeprom->magic && eeprom->magic != magic) {
		struct i40e_nvm_access *cmd;
		int errno;
		int errno;


		/* make sure it is the right magic for NVMUpdate */
		/* make sure it is the right magic for NVMUpdate */
		if ((eeprom->magic >> 16) != hw->device_id)
		if ((eeprom->magic >> 16) != hw->device_id)
			return -EINVAL;
			return -EINVAL;


		ret_val = i40e_nvmupd_command(hw,
		cmd = (struct i40e_nvm_access *)eeprom;
					      (struct i40e_nvm_access *)eeprom,
		ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
					      bytes, &errno);
		if (ret_val)
		if (ret_val)
			dev_info(&pf->pdev->dev,
			dev_info(&pf->pdev->dev,
				 "NVMUpdate read failed err=%d status=0x%x\n",
				 "NVMUpdate read failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
				 ret_val, hw->aq.asq_last_status);
				 ret_val, hw->aq.asq_last_status, errno,
				 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
				 cmd->offset, cmd->data_size);


		return errno;
		return errno;
	}
	}
@@ -876,20 +878,29 @@ static int i40e_get_eeprom(struct net_device *netdev,
			len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i);
			len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i);
			last = true;
			last = true;
		}
		}
		ret_val = i40e_aq_read_nvm(hw, 0x0,
		offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i),
				eeprom->offset + (I40E_NVM_SECTOR_SIZE * i),
		ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len,
				len,
				(u8 *)eeprom_buff + (I40E_NVM_SECTOR_SIZE * i),
				(u8 *)eeprom_buff + (I40E_NVM_SECTOR_SIZE * i),
				last, NULL);
				last, NULL);
		if (ret_val) {
		if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) {
			dev_info(&pf->pdev->dev,
			dev_info(&pf->pdev->dev,
				 "read NVM failed err=%d status=0x%x\n",
				 "read NVM failed, invalid offset 0x%x\n",
				 ret_val, hw->aq.asq_last_status);
				 offset);
			goto release_nvm;
			break;
		} else if (ret_val &&
			   hw->aq.asq_last_status == I40E_AQ_RC_EACCES) {
			dev_info(&pf->pdev->dev,
				 "read NVM failed, access, offset 0x%x\n",
				 offset);
			break;
		} else if (ret_val) {
			dev_info(&pf->pdev->dev,
				 "read NVM failed offset %d err=%d status=0x%x\n",
				 offset, ret_val, hw->aq.asq_last_status);
			break;
		}
		}
	}
	}


release_nvm:
	i40e_release_nvm(hw);
	i40e_release_nvm(hw);
	memcpy(bytes, (u8 *)eeprom_buff, eeprom->len);
	memcpy(bytes, (u8 *)eeprom_buff, eeprom->len);
free_buff:
free_buff:
@@ -917,6 +928,7 @@ static int i40e_set_eeprom(struct net_device *netdev,
	struct i40e_netdev_priv *np = netdev_priv(netdev);
	struct i40e_netdev_priv *np = netdev_priv(netdev);
	struct i40e_hw *hw = &np->vsi->back->hw;
	struct i40e_hw *hw = &np->vsi->back->hw;
	struct i40e_pf *pf = np->vsi->back;
	struct i40e_pf *pf = np->vsi->back;
	struct i40e_nvm_access *cmd;
	int ret_val = 0;
	int ret_val = 0;
	int errno;
	int errno;
	u32 magic;
	u32 magic;
@@ -934,12 +946,14 @@ static int i40e_set_eeprom(struct net_device *netdev,
	    test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
	    test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
		return -EBUSY;
		return -EBUSY;


	ret_val = i40e_nvmupd_command(hw, (struct i40e_nvm_access *)eeprom,
	cmd = (struct i40e_nvm_access *)eeprom;
				      bytes, &errno);
	ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
	if (ret_val)
	if (ret_val && hw->aq.asq_last_status != I40E_AQ_RC_EBUSY)
		dev_info(&pf->pdev->dev,
		dev_info(&pf->pdev->dev,
			 "NVMUpdate write failed err=%d status=0x%x\n",
			 "NVMUpdate write failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
			 ret_val, hw->aq.asq_last_status);
			 ret_val, hw->aq.asq_last_status, errno,
			 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
			 cmd->offset, cmd->data_size);


	return errno;
	return errno;
}
}