Skip to content

Commit d4e8744

Browse files
jacob-kellerJeff Kirsher
authored andcommitted
ice: store NVM version info in extracted format
The NVM version and Option ROM version information is stored within the struct ice_nvm_ver_info structure. The data for the NVM is stored as a 2byte value with the major and minor versions each using one byte from the field. The Option ROM is stored as a 4byte value that contains a major, build, and patch number. Modify the code to immediately extract the version values and store them in a new struct ice_orom_info. Remove the now unnecessary ice_get_nvm_version function. Update ice_ethtool.c to use the new fields directly from the structured data. This reduces complexity of the code that prints these versions in ice_ethtool.c Update the macro definitions and variable names to use the term "orom" instead of "oem" for the Option ROM version. This helps increase the clarity of the Option ROM version code. Signed-off-by: Jacob Keller <[email protected]> Reviewed-by: Jesse Brandeburg <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent e945099 commit d4e8744

File tree

5 files changed

+88
-75
lines changed

5 files changed

+88
-75
lines changed

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -614,29 +614,6 @@ static void ice_get_itr_intrl_gran(struct ice_hw *hw)
614614
}
615615
}
616616

617-
/**
618-
* ice_get_nvm_version - get cached NVM version data
619-
* @hw: pointer to the hardware structure
620-
* @oem_ver: 8 bit NVM version
621-
* @oem_build: 16 bit NVM build number
622-
* @oem_patch: 8 NVM patch number
623-
* @ver_hi: high 8 bits of the NVM version
624-
* @ver_lo: low 8 bits of the NVM version
625-
*/
626-
void
627-
ice_get_nvm_version(struct ice_hw *hw, u8 *oem_ver, u16 *oem_build,
628-
u8 *oem_patch, u8 *ver_hi, u8 *ver_lo)
629-
{
630-
struct ice_nvm_info *nvm = &hw->nvm;
631-
632-
*oem_ver = (u8)((nvm->oem_ver & ICE_OEM_VER_MASK) >> ICE_OEM_VER_SHIFT);
633-
*oem_patch = (u8)(nvm->oem_ver & ICE_OEM_VER_PATCH_MASK);
634-
*oem_build = (u16)((nvm->oem_ver & ICE_OEM_VER_BUILD_MASK) >>
635-
ICE_OEM_VER_BUILD_SHIFT);
636-
*ver_hi = (nvm->ver & ICE_NVM_VER_HI_MASK) >> ICE_NVM_VER_HI_SHIFT;
637-
*ver_lo = (nvm->ver & ICE_NVM_VER_LO_MASK) >> ICE_NVM_VER_LO_SHIFT;
638-
}
639-
640617
/**
641618
* ice_init_hw - main hardware initialization routine
642619
* @hw: pointer to the hardware structure

drivers/net/ethernet/intel/ice/ice_common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ ice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
153153
void
154154
ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
155155
u64 *prev_stat, u64 *cur_stat);
156-
void
157-
ice_get_nvm_version(struct ice_hw *hw, u8 *oem_ver, u16 *oem_build,
158-
u8 *oem_patch, u8 *ver_hi, u8 *ver_lo);
159156
enum ice_status
160157
ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
161158
struct ice_aqc_get_elem *buf);

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,23 +167,24 @@ static void
167167
ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
168168
{
169169
struct ice_netdev_priv *np = netdev_priv(netdev);
170-
u8 oem_ver, oem_patch, nvm_ver_hi, nvm_ver_lo;
171170
struct ice_vsi *vsi = np->vsi;
172171
struct ice_pf *pf = vsi->back;
173172
struct ice_hw *hw = &pf->hw;
174-
u16 oem_build;
173+
struct ice_orom_info *orom;
174+
struct ice_nvm_info *nvm;
175+
176+
nvm = &hw->nvm;
177+
orom = &nvm->orom;
175178

176179
strscpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
177180
strscpy(drvinfo->version, ice_drv_ver, sizeof(drvinfo->version));
178181

179182
/* Display NVM version (from which the firmware version can be
180183
* determined) which contains more pertinent information.
181184
*/
182-
ice_get_nvm_version(hw, &oem_ver, &oem_build, &oem_patch,
183-
&nvm_ver_hi, &nvm_ver_lo);
184185
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
185-
"%x.%02x 0x%x %d.%d.%d", nvm_ver_hi, nvm_ver_lo,
186-
hw->nvm.eetrack, oem_ver, oem_build, oem_patch);
186+
"%x.%02x 0x%x %d.%d.%d", nvm->major_ver, nvm->minor_ver,
187+
nvm->eetrack, orom->major, orom->build, orom->patch);
187188

188189
strscpy(drvinfo->bus_info, pci_name(pf->pdev),
189190
sizeof(drvinfo->bus_info));

drivers/net/ethernet/intel/ice/ice_nvm.c

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,62 @@ enum ice_status ice_read_sr_word(struct ice_hw *hw, u16 offset, u16 *data)
307307
return status;
308308
}
309309

310+
/**
311+
* ice_get_orom_ver_info - Read Option ROM version information
312+
* @hw: pointer to the HW struct
313+
*
314+
* Read the Combo Image version data from the Boot Configuration TLV and fill
315+
* in the option ROM version data.
316+
*/
317+
static enum ice_status ice_get_orom_ver_info(struct ice_hw *hw)
318+
{
319+
u16 combo_hi, combo_lo, boot_cfg_tlv, boot_cfg_tlv_len;
320+
struct ice_orom_info *orom = &hw->nvm.orom;
321+
enum ice_status status;
322+
u32 combo_ver;
323+
324+
status = ice_get_pfa_module_tlv(hw, &boot_cfg_tlv, &boot_cfg_tlv_len,
325+
ICE_SR_BOOT_CFG_PTR);
326+
if (status) {
327+
ice_debug(hw, ICE_DBG_INIT,
328+
"Failed to read Boot Configuration Block TLV.\n");
329+
return status;
330+
}
331+
332+
/* Boot Configuration Block must have length at least 2 words
333+
* (Combo Image Version High and Combo Image Version Low)
334+
*/
335+
if (boot_cfg_tlv_len < 2) {
336+
ice_debug(hw, ICE_DBG_INIT,
337+
"Invalid Boot Configuration Block TLV size.\n");
338+
return ICE_ERR_INVAL_SIZE;
339+
}
340+
341+
status = ice_read_sr_word(hw, (boot_cfg_tlv + ICE_NVM_OROM_VER_OFF),
342+
&combo_hi);
343+
if (status) {
344+
ice_debug(hw, ICE_DBG_INIT, "Failed to read OROM_VER hi.\n");
345+
return status;
346+
}
347+
348+
status = ice_read_sr_word(hw, (boot_cfg_tlv + ICE_NVM_OROM_VER_OFF + 1),
349+
&combo_lo);
350+
if (status) {
351+
ice_debug(hw, ICE_DBG_INIT, "Failed to read OROM_VER lo.\n");
352+
return status;
353+
}
354+
355+
combo_ver = ((u32)combo_hi << 16) | combo_lo;
356+
357+
orom->major = (u8)((combo_ver & ICE_OROM_VER_MASK) >>
358+
ICE_OROM_VER_SHIFT);
359+
orom->patch = (u8)(combo_ver & ICE_OROM_VER_PATCH_MASK);
360+
orom->build = (u16)((combo_ver & ICE_OROM_VER_BUILD_MASK) >>
361+
ICE_OROM_VER_BUILD_SHIFT);
362+
363+
return 0;
364+
}
365+
310366
/**
311367
* ice_init_nvm - initializes NVM setting
312368
* @hw: pointer to the HW struct
@@ -316,9 +372,8 @@ enum ice_status ice_read_sr_word(struct ice_hw *hw, u16 offset, u16 *data)
316372
*/
317373
enum ice_status ice_init_nvm(struct ice_hw *hw)
318374
{
319-
u16 oem_hi, oem_lo, boot_cfg_tlv, boot_cfg_tlv_len;
320375
struct ice_nvm_info *nvm = &hw->nvm;
321-
u16 eetrack_lo, eetrack_hi;
376+
u16 eetrack_lo, eetrack_hi, ver;
322377
enum ice_status status;
323378
u32 fla, gens_stat;
324379
u8 sr_size;
@@ -344,12 +399,14 @@ enum ice_status ice_init_nvm(struct ice_hw *hw)
344399
return ICE_ERR_NVM_BLANK_MODE;
345400
}
346401

347-
status = ice_read_sr_word(hw, ICE_SR_NVM_DEV_STARTER_VER, &nvm->ver);
402+
status = ice_read_sr_word(hw, ICE_SR_NVM_DEV_STARTER_VER, &ver);
348403
if (status) {
349404
ice_debug(hw, ICE_DBG_INIT,
350405
"Failed to read DEV starter version.\n");
351406
return status;
352407
}
408+
nvm->major_ver = (ver & ICE_NVM_VER_HI_MASK) >> ICE_NVM_VER_HI_SHIFT;
409+
nvm->minor_ver = (ver & ICE_NVM_VER_LO_MASK) >> ICE_NVM_VER_LO_SHIFT;
353410

354411
status = ice_read_sr_word(hw, ICE_SR_NVM_EETRACK_LO, &eetrack_lo);
355412
if (status) {
@@ -390,39 +447,12 @@ enum ice_status ice_init_nvm(struct ice_hw *hw)
390447
break;
391448
}
392449

393-
status = ice_get_pfa_module_tlv(hw, &boot_cfg_tlv, &boot_cfg_tlv_len,
394-
ICE_SR_BOOT_CFG_PTR);
450+
status = ice_get_orom_ver_info(hw);
395451
if (status) {
396-
ice_debug(hw, ICE_DBG_INIT,
397-
"Failed to read Boot Configuration Block TLV.\n");
452+
ice_debug(hw, ICE_DBG_INIT, "Failed to read Option ROM info.\n");
398453
return status;
399454
}
400455

401-
/* Boot Configuration Block must have length at least 2 words
402-
* (Combo Image Version High and Combo Image Version Low)
403-
*/
404-
if (boot_cfg_tlv_len < 2) {
405-
ice_debug(hw, ICE_DBG_INIT,
406-
"Invalid Boot Configuration Block TLV size.\n");
407-
return ICE_ERR_INVAL_SIZE;
408-
}
409-
410-
status = ice_read_sr_word(hw, (boot_cfg_tlv + ICE_NVM_OEM_VER_OFF),
411-
&oem_hi);
412-
if (status) {
413-
ice_debug(hw, ICE_DBG_INIT, "Failed to read OEM_VER hi.\n");
414-
return status;
415-
}
416-
417-
status = ice_read_sr_word(hw, (boot_cfg_tlv + ICE_NVM_OEM_VER_OFF + 1),
418-
&oem_lo);
419-
if (status) {
420-
ice_debug(hw, ICE_DBG_INIT, "Failed to read OEM_VER lo.\n");
421-
return status;
422-
}
423-
424-
nvm->oem_ver = ((u32)oem_hi << 16) | oem_lo;
425-
426456
return 0;
427457
}
428458

drivers/net/ethernet/intel/ice/ice_type.h

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,20 @@ struct ice_fc_info {
239239
enum ice_fc_mode req_mode; /* FC mode requested by caller */
240240
};
241241

242+
/* Option ROM version information */
243+
struct ice_orom_info {
244+
u8 major; /* Major version of OROM */
245+
u8 patch; /* Patch version of OROM */
246+
u16 build; /* Build version of OROM */
247+
};
248+
242249
/* NVM Information */
243250
struct ice_nvm_info {
244-
u32 eetrack; /* NVM data version */
245-
u32 oem_ver; /* OEM version info */
246-
u16 sr_words; /* Shadow RAM size in words */
247-
u16 ver; /* NVM package version */
251+
struct ice_orom_info orom; /* Option ROM version info */
252+
u32 eetrack; /* NVM data version */
253+
u16 sr_words; /* Shadow RAM size in words */
254+
u8 major_ver; /* major version of NVM package */
255+
u8 minor_ver; /* minor version of dev starter */
248256
u8 blank_nvm_mode; /* is NVM empty (no FW present) */
249257
};
250258

@@ -626,20 +634,20 @@ struct ice_hw_port_stats {
626634

627635
/* Checksum and Shadow RAM pointers */
628636
#define ICE_SR_BOOT_CFG_PTR 0x132
629-
#define ICE_NVM_OEM_VER_OFF 0x02
637+
#define ICE_NVM_OROM_VER_OFF 0x02
630638
#define ICE_SR_NVM_DEV_STARTER_VER 0x18
631639
#define ICE_SR_NVM_EETRACK_LO 0x2D
632640
#define ICE_SR_NVM_EETRACK_HI 0x2E
633641
#define ICE_NVM_VER_LO_SHIFT 0
634642
#define ICE_NVM_VER_LO_MASK (0xff << ICE_NVM_VER_LO_SHIFT)
635643
#define ICE_NVM_VER_HI_SHIFT 12
636644
#define ICE_NVM_VER_HI_MASK (0xf << ICE_NVM_VER_HI_SHIFT)
637-
#define ICE_OEM_VER_PATCH_SHIFT 0
638-
#define ICE_OEM_VER_PATCH_MASK (0xff << ICE_OEM_VER_PATCH_SHIFT)
639-
#define ICE_OEM_VER_BUILD_SHIFT 8
640-
#define ICE_OEM_VER_BUILD_MASK (0xffff << ICE_OEM_VER_BUILD_SHIFT)
641-
#define ICE_OEM_VER_SHIFT 24
642-
#define ICE_OEM_VER_MASK (0xff << ICE_OEM_VER_SHIFT)
645+
#define ICE_OROM_VER_PATCH_SHIFT 0
646+
#define ICE_OROM_VER_PATCH_MASK (0xff << ICE_OROM_VER_PATCH_SHIFT)
647+
#define ICE_OROM_VER_BUILD_SHIFT 8
648+
#define ICE_OROM_VER_BUILD_MASK (0xffff << ICE_OROM_VER_BUILD_SHIFT)
649+
#define ICE_OROM_VER_SHIFT 24
650+
#define ICE_OROM_VER_MASK (0xff << ICE_OROM_VER_SHIFT)
643651
#define ICE_SR_PFA_PTR 0x40
644652
#define ICE_SR_SECTOR_SIZE_IN_WORDS 0x800
645653
#define ICE_SR_WORDS_IN_1KB 512

0 commit comments

Comments
 (0)