Commit cfa747a6 authored by Jacob Keller's avatar Jacob Keller Committed by Jakub Kicinski

ice: fix reads from NVM Shadow RAM on E830 and E825-C devices

The ice driver reads data from the Shadow RAM portion of the NVM during
initialization, including data used to identify the NVM image and device,
such as the ETRACK ID used to populate devlink dev info fw.bundle.

Currently it is using a fixed offset defined by ICE_CSS_HEADER_LENGTH to
compute the appropriate offset. This worked fine for E810 and E822 devices
which both have CSS header length of 330 words.

Other devices, including both E825-C and E830 devices have different sizes
for their CSS header. The use of a hard coded value results in the driver
reading from the wrong block in the NVM when attempting to access the
Shadow RAM copy. This results in the driver reporting the fw.bundle as 0x0
in both the devlink dev info and ethtool -i output.

The first E830 support was introduced by commit ba20ecb1 ("ice: Hook up
4 E830 devices by adding their IDs") and the first E825-C support was
introducted by commit f64e1894 ("ice: introduce new E825C devices
family")

The NVM actually contains the CSS header length embedded in it. Remove the
hard coded value and replace it with logic to read the length from the NVM
directly. This is more resilient against all existing and future hardware,
vs looking up the expected values from a table. It ensures the driver will
read from the appropriate place when determining the ETRACK ID value used
for populating the fw.bundle_id and for reporting in ethtool -i.

The CSS header length for both the active and inactive flash bank is stored
in the ice_bank_info structure to avoid unnecessary duplicate work when
accessing multiple words of the Shadow RAM. Both banks are read in the
unlikely event that the header length is different for the NVM in the
inactive bank, rather than being different only by the overall device
family.

Fixes: ba20ecb1 ("ice: Hook up 4 E830 devices by adding their IDs")
Co-developed-by: default avatarPaul Greenwalt <paul.greenwalt@intel.com>
Signed-off-by: default avatarPaul Greenwalt <paul.greenwalt@intel.com>
Reviewed-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Tested-by: default avatarPucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20240603-net-2024-05-30-intel-net-fixes-v2-2-e3563aa89b0c@intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 03e4a092
...@@ -374,11 +374,25 @@ ice_read_nvm_module(struct ice_hw *hw, enum ice_bank_select bank, u32 offset, u1 ...@@ -374,11 +374,25 @@ ice_read_nvm_module(struct ice_hw *hw, enum ice_bank_select bank, u32 offset, u1
* *
* Read the specified word from the copy of the Shadow RAM found in the * Read the specified word from the copy of the Shadow RAM found in the
* specified NVM module. * specified NVM module.
*
* Note that the Shadow RAM copy is always located after the CSS header, and
* is aligned to 64-byte (32-word) offsets.
*/ */
static int static int
ice_read_nvm_sr_copy(struct ice_hw *hw, enum ice_bank_select bank, u32 offset, u16 *data) ice_read_nvm_sr_copy(struct ice_hw *hw, enum ice_bank_select bank, u32 offset, u16 *data)
{ {
return ice_read_nvm_module(hw, bank, ICE_NVM_SR_COPY_WORD_OFFSET + offset, data); u32 sr_copy;
switch (bank) {
case ICE_ACTIVE_FLASH_BANK:
sr_copy = roundup(hw->flash.banks.active_css_hdr_len, 32);
break;
case ICE_INACTIVE_FLASH_BANK:
sr_copy = roundup(hw->flash.banks.inactive_css_hdr_len, 32);
break;
}
return ice_read_nvm_module(hw, bank, sr_copy + offset, data);
} }
/** /**
...@@ -1023,6 +1037,72 @@ static int ice_determine_active_flash_banks(struct ice_hw *hw) ...@@ -1023,6 +1037,72 @@ static int ice_determine_active_flash_banks(struct ice_hw *hw)
return 0; return 0;
} }
/**
* ice_get_nvm_css_hdr_len - Read the CSS header length from the NVM CSS header
* @hw: pointer to the HW struct
* @bank: whether to read from the active or inactive flash bank
* @hdr_len: storage for header length in words
*
* Read the CSS header length from the NVM CSS header and add the Authentication
* header size, and then convert to words.
*
* Return: zero on success, or a negative error code on failure.
*/
static int
ice_get_nvm_css_hdr_len(struct ice_hw *hw, enum ice_bank_select bank,
u32 *hdr_len)
{
u16 hdr_len_l, hdr_len_h;
u32 hdr_len_dword;
int status;
status = ice_read_nvm_module(hw, bank, ICE_NVM_CSS_HDR_LEN_L,
&hdr_len_l);
if (status)
return status;
status = ice_read_nvm_module(hw, bank, ICE_NVM_CSS_HDR_LEN_H,
&hdr_len_h);
if (status)
return status;
/* CSS header length is in DWORD, so convert to words and add
* authentication header size
*/
hdr_len_dword = hdr_len_h << 16 | hdr_len_l;
*hdr_len = (hdr_len_dword * 2) + ICE_NVM_AUTH_HEADER_LEN;
return 0;
}
/**
* ice_determine_css_hdr_len - Discover CSS header length for the device
* @hw: pointer to the HW struct
*
* Determine the size of the CSS header at the start of the NVM module. This
* is useful for locating the Shadow RAM copy in the NVM, as the Shadow RAM is
* always located just after the CSS header.
*
* Return: zero on success, or a negative error code on failure.
*/
static int ice_determine_css_hdr_len(struct ice_hw *hw)
{
struct ice_bank_info *banks = &hw->flash.banks;
int status;
status = ice_get_nvm_css_hdr_len(hw, ICE_ACTIVE_FLASH_BANK,
&banks->active_css_hdr_len);
if (status)
return status;
status = ice_get_nvm_css_hdr_len(hw, ICE_INACTIVE_FLASH_BANK,
&banks->inactive_css_hdr_len);
if (status)
return status;
return 0;
}
/** /**
* ice_init_nvm - initializes NVM setting * ice_init_nvm - initializes NVM setting
* @hw: pointer to the HW struct * @hw: pointer to the HW struct
...@@ -1069,6 +1149,12 @@ int ice_init_nvm(struct ice_hw *hw) ...@@ -1069,6 +1149,12 @@ int ice_init_nvm(struct ice_hw *hw)
return status; return status;
} }
status = ice_determine_css_hdr_len(hw);
if (status) {
ice_debug(hw, ICE_DBG_NVM, "Failed to determine Shadow RAM copy offsets.\n");
return status;
}
status = ice_get_nvm_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->nvm); status = ice_get_nvm_ver_info(hw, ICE_ACTIVE_FLASH_BANK, &flash->nvm);
if (status) { if (status) {
ice_debug(hw, ICE_DBG_INIT, "Failed to read NVM info.\n"); ice_debug(hw, ICE_DBG_INIT, "Failed to read NVM info.\n");
......
...@@ -482,6 +482,8 @@ struct ice_bank_info { ...@@ -482,6 +482,8 @@ struct ice_bank_info {
u32 orom_size; /* Size of OROM bank */ u32 orom_size; /* Size of OROM bank */
u32 netlist_ptr; /* Pointer to 1st Netlist bank */ u32 netlist_ptr; /* Pointer to 1st Netlist bank */
u32 netlist_size; /* Size of Netlist bank */ u32 netlist_size; /* Size of Netlist bank */
u32 active_css_hdr_len; /* Active CSS header length */
u32 inactive_css_hdr_len; /* Inactive CSS header length */
enum ice_flash_bank nvm_bank; /* Active NVM bank */ enum ice_flash_bank nvm_bank; /* Active NVM bank */
enum ice_flash_bank orom_bank; /* Active OROM bank */ enum ice_flash_bank orom_bank; /* Active OROM bank */
enum ice_flash_bank netlist_bank; /* Active Netlist bank */ enum ice_flash_bank netlist_bank; /* Active Netlist bank */
...@@ -1087,17 +1089,13 @@ struct ice_aq_get_set_rss_lut_params { ...@@ -1087,17 +1089,13 @@ struct ice_aq_get_set_rss_lut_params {
#define ICE_SR_SECTOR_SIZE_IN_WORDS 0x800 #define ICE_SR_SECTOR_SIZE_IN_WORDS 0x800
/* CSS Header words */ /* CSS Header words */
#define ICE_NVM_CSS_HDR_LEN_L 0x02
#define ICE_NVM_CSS_HDR_LEN_H 0x03
#define ICE_NVM_CSS_SREV_L 0x14 #define ICE_NVM_CSS_SREV_L 0x14
#define ICE_NVM_CSS_SREV_H 0x15 #define ICE_NVM_CSS_SREV_H 0x15
/* Length of CSS header section in words */ /* Length of Authentication header section in words */
#define ICE_CSS_HEADER_LENGTH 330 #define ICE_NVM_AUTH_HEADER_LEN 0x08
/* Offset of Shadow RAM copy in the NVM bank area. */
#define ICE_NVM_SR_COPY_WORD_OFFSET roundup(ICE_CSS_HEADER_LENGTH, 32)
/* Size in bytes of Option ROM trailer */
#define ICE_NVM_OROM_TRAILER_LENGTH (2 * ICE_CSS_HEADER_LENGTH)
/* The Link Topology Netlist section is stored as a series of words. It is /* The Link Topology Netlist section is stored as a series of words. It is
* stored in the NVM as a TLV, with the first two words containing the type * stored in the NVM as a TLV, with the first two words containing the type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment