Skip to content

Commit e5b132b

Browse files
pkwapulianguy11
authored andcommitted
ixgbe: Add support for EEPROM dump in E610 device
Add low level support for EEPROM dump for the specified network device. Co-developed-by: Stefan Wegrzyn <[email protected]> Signed-off-by: Stefan Wegrzyn <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Bharath R <[email protected]> Signed-off-by: Piotr Kwapulinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent d2483eb commit e5b132b

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,38 @@ int ixgbe_enter_lplu_e610(struct ixgbe_hw *hw)
20732073
return ixgbe_aci_set_phy_cfg(hw, &phy_cfg);
20742074
}
20752075

2076+
/**
2077+
* ixgbe_init_eeprom_params_e610 - Initialize EEPROM params
2078+
* @hw: pointer to hardware structure
2079+
*
2080+
* Initialize the EEPROM parameters ixgbe_eeprom_info within the ixgbe_hw
2081+
* struct in order to set up EEPROM access.
2082+
*
2083+
* Return: the operation exit code.
2084+
*/
2085+
int ixgbe_init_eeprom_params_e610(struct ixgbe_hw *hw)
2086+
{
2087+
struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
2088+
u32 gens_stat;
2089+
u8 sr_size;
2090+
2091+
if (eeprom->type != ixgbe_eeprom_uninitialized)
2092+
return 0;
2093+
2094+
eeprom->type = ixgbe_flash;
2095+
2096+
gens_stat = IXGBE_READ_REG(hw, GLNVM_GENS);
2097+
sr_size = FIELD_GET(GLNVM_GENS_SR_SIZE_M, gens_stat);
2098+
2099+
/* Switching to words (sr_size contains power of 2). */
2100+
eeprom->word_size = BIT(sr_size) * IXGBE_SR_WORDS_IN_1KB;
2101+
2102+
hw_dbg(hw, "Eeprom params: type = %d, size = %d\n", eeprom->type,
2103+
eeprom->word_size);
2104+
2105+
return 0;
2106+
}
2107+
20762108
/**
20772109
* ixgbe_aci_get_netlist_node - get a node handle
20782110
* @hw: pointer to the hw struct
@@ -2319,6 +2351,36 @@ int ixgbe_read_flat_nvm(struct ixgbe_hw *hw, u32 offset, u32 *length,
23192351
return err;
23202352
}
23212353

2354+
/**
2355+
* ixgbe_read_sr_buf_aci - Read Shadow RAM buffer via ACI
2356+
* @hw: pointer to the HW structure
2357+
* @offset: offset of the Shadow RAM words to read (0x000000 - 0x001FFF)
2358+
* @words: (in) number of words to read; (out) number of words actually read
2359+
* @data: words read from the Shadow RAM
2360+
*
2361+
* Read 16 bit words (data buf) from the Shadow RAM. Acquire/release the NVM
2362+
* ownership.
2363+
*
2364+
* Return: the operation exit code.
2365+
*/
2366+
int ixgbe_read_sr_buf_aci(struct ixgbe_hw *hw, u16 offset, u16 *words,
2367+
u16 *data)
2368+
{
2369+
u32 bytes = *words * 2;
2370+
int err;
2371+
2372+
err = ixgbe_read_flat_nvm(hw, offset * 2, &bytes, (u8 *)data, true);
2373+
if (err)
2374+
return err;
2375+
2376+
*words = bytes / 2;
2377+
2378+
for (int i = 0; i < *words; i++)
2379+
data[i] = le16_to_cpu(((__le16 *)data)[i]);
2380+
2381+
return 0;
2382+
}
2383+
23222384
/**
23232385
* ixgbe_read_ee_aci_e610 - Read EEPROM word using the admin command.
23242386
* @hw: pointer to hardware structure
@@ -2352,6 +2414,39 @@ int ixgbe_read_ee_aci_e610(struct ixgbe_hw *hw, u16 offset, u16 *data)
23522414
return err;
23532415
}
23542416

2417+
/**
2418+
* ixgbe_read_ee_aci_buffer_e610 - Read EEPROM words via ACI
2419+
* @hw: pointer to hardware structure
2420+
* @offset: offset of words in the EEPROM to read
2421+
* @words: number of words to read
2422+
* @data: words to read from the EEPROM
2423+
*
2424+
* Read 16 bit words from the EEPROM via the ACI. Initialize the EEPROM params
2425+
* prior to the read. Acquire/release the NVM ownership.
2426+
*
2427+
* Return: the operation exit code.
2428+
*/
2429+
int ixgbe_read_ee_aci_buffer_e610(struct ixgbe_hw *hw, u16 offset,
2430+
u16 words, u16 *data)
2431+
{
2432+
int err;
2433+
2434+
if (hw->eeprom.type == ixgbe_eeprom_uninitialized) {
2435+
err = hw->eeprom.ops.init_params(hw);
2436+
if (err)
2437+
return err;
2438+
}
2439+
2440+
err = ixgbe_acquire_nvm(hw, IXGBE_RES_READ);
2441+
if (err)
2442+
return err;
2443+
2444+
err = ixgbe_read_sr_buf_aci(hw, offset, &words, data);
2445+
ixgbe_release_nvm(hw);
2446+
2447+
return err;
2448+
}
2449+
23552450
/**
23562451
* ixgbe_validate_eeprom_checksum_e610 - Validate EEPROM checksum
23572452
* @hw: pointer to hardware structure

drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int ixgbe_identify_module_e610(struct ixgbe_hw *hw);
5656
int ixgbe_setup_phy_link_e610(struct ixgbe_hw *hw);
5757
int ixgbe_set_phy_power_e610(struct ixgbe_hw *hw, bool on);
5858
int ixgbe_enter_lplu_e610(struct ixgbe_hw *hw);
59+
int ixgbe_init_eeprom_params_e610(struct ixgbe_hw *hw);
5960
int ixgbe_aci_get_netlist_node(struct ixgbe_hw *hw,
6061
struct ixgbe_aci_cmd_get_link_topo *cmd,
6162
u8 *node_part_number, u16 *node_handle);
@@ -69,7 +70,11 @@ int ixgbe_nvm_validate_checksum(struct ixgbe_hw *hw);
6970
int ixgbe_read_sr_word_aci(struct ixgbe_hw *hw, u16 offset, u16 *data);
7071
int ixgbe_read_flat_nvm(struct ixgbe_hw *hw, u32 offset, u32 *length,
7172
u8 *data, bool read_shadow_ram);
73+
int ixgbe_read_sr_buf_aci(struct ixgbe_hw *hw, u16 offset, u16 *words,
74+
u16 *data);
7275
int ixgbe_read_ee_aci_e610(struct ixgbe_hw *hw, u16 offset, u16 *data);
76+
int ixgbe_read_ee_aci_buffer_e610(struct ixgbe_hw *hw, u16 offset,
77+
u16 words, u16 *data);
7378
int ixgbe_validate_eeprom_checksum_e610(struct ixgbe_hw *hw, u16 *checksum_val);
7479

7580
#endif /* _IXGBE_E610_H_ */

drivers/net/ethernet/intel/ixgbe/ixgbe_type_e610.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@
1212
/* Checksum and Shadow RAM pointers */
1313
#define E610_SR_SW_CHECKSUM_WORD 0x3F
1414

15+
/* Shadow RAM related */
16+
#define IXGBE_SR_WORDS_IN_1KB 512
17+
1518
/* Firmware Status Register (GL_FWSTS) */
1619
#define GL_FWSTS 0x00083048 /* Reset Source: POR */
1720
#define GL_FWSTS_EP_PF0 BIT(24)
1821
#define GL_FWSTS_EP_PF1 BIT(25)
1922

23+
/* Global NVM General Status Register */
24+
#define GLNVM_GENS 0x000B6100 /* Reset Source: POR */
25+
#define GLNVM_GENS_SR_SIZE_M GENMASK(7, 5)
26+
2027
/* Flash Access Register */
2128
#define IXGBE_GLNVM_FLA 0x000B6108 /* Reset Source: POR */
2229
#define IXGBE_GLNVM_FLA_LOCKED_S 6

0 commit comments

Comments
 (0)