Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <jacob.e.keller@intel.com>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

authored by

Jacob Keller and committed by
Jeff Kirsher
d4e87444 e9450990

+88 -75
-23
drivers/net/ethernet/intel/ice/ice_common.c
··· 615 615 } 616 616 617 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 - 640 - /** 641 618 * ice_init_hw - main hardware initialization routine 642 619 * @hw: pointer to the hardware structure 643 620 */
-3
drivers/net/ethernet/intel/ice/ice_common.h
··· 153 153 void 154 154 ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded, 155 155 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); 159 156 enum ice_status 160 157 ice_sched_query_elem(struct ice_hw *hw, u32 node_teid, 161 158 struct ice_aqc_get_elem *buf);
+7 -6
drivers/net/ethernet/intel/ice/ice_ethtool.c
··· 167 167 ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) 168 168 { 169 169 struct ice_netdev_priv *np = netdev_priv(netdev); 170 - u8 oem_ver, oem_patch, nvm_ver_hi, nvm_ver_lo; 171 170 struct ice_vsi *vsi = np->vsi; 172 171 struct ice_pf *pf = vsi->back; 173 172 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; 175 178 176 179 strscpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); 177 180 strscpy(drvinfo->version, ice_drv_ver, sizeof(drvinfo->version)); ··· 182 179 /* Display NVM version (from which the firmware version can be 183 180 * determined) which contains more pertinent information. 184 181 */ 185 - ice_get_nvm_version(hw, &oem_ver, &oem_build, &oem_patch, 186 - &nvm_ver_hi, &nvm_ver_lo); 187 182 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), 188 - "%x.%02x 0x%x %d.%d.%d", nvm_ver_hi, nvm_ver_lo, 189 - hw->nvm.eetrack, oem_ver, oem_build, oem_patch); 183 + "%x.%02x 0x%x %d.%d.%d", nvm->major_ver, nvm->minor_ver, 184 + nvm->eetrack, orom->major, orom->build, orom->patch); 190 185 191 186 strscpy(drvinfo->bus_info, pci_name(pf->pdev), 192 187 sizeof(drvinfo->bus_info));
+62 -32
drivers/net/ethernet/intel/ice/ice_nvm.c
··· 308 308 } 309 309 310 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 + 366 + /** 311 367 * ice_init_nvm - initializes NVM setting 312 368 * @hw: pointer to the HW struct 313 369 * ··· 372 316 */ 373 317 enum ice_status ice_init_nvm(struct ice_hw *hw) 374 318 { 375 - u16 oem_hi, oem_lo, boot_cfg_tlv, boot_cfg_tlv_len; 376 319 struct ice_nvm_info *nvm = &hw->nvm; 377 - u16 eetrack_lo, eetrack_hi; 320 + u16 eetrack_lo, eetrack_hi, ver; 378 321 enum ice_status status; 379 322 u32 fla, gens_stat; 380 323 u8 sr_size; ··· 399 344 return ICE_ERR_NVM_BLANK_MODE; 400 345 } 401 346 402 - status = ice_read_sr_word(hw, ICE_SR_NVM_DEV_STARTER_VER, &nvm->ver); 347 + status = ice_read_sr_word(hw, ICE_SR_NVM_DEV_STARTER_VER, &ver); 403 348 if (status) { 404 349 ice_debug(hw, ICE_DBG_INIT, 405 350 "Failed to read DEV starter version.\n"); 406 351 return status; 407 352 } 353 + nvm->major_ver = (ver & ICE_NVM_VER_HI_MASK) >> ICE_NVM_VER_HI_SHIFT; 354 + nvm->minor_ver = (ver & ICE_NVM_VER_LO_MASK) >> ICE_NVM_VER_LO_SHIFT; 408 355 409 356 status = ice_read_sr_word(hw, ICE_SR_NVM_EETRACK_LO, &eetrack_lo); 410 357 if (status) { ··· 447 390 break; 448 391 } 449 392 450 - status = ice_get_pfa_module_tlv(hw, &boot_cfg_tlv, &boot_cfg_tlv_len, 451 - ICE_SR_BOOT_CFG_PTR); 393 + status = ice_get_orom_ver_info(hw); 452 394 if (status) { 453 - ice_debug(hw, ICE_DBG_INIT, 454 - "Failed to read Boot Configuration Block TLV.\n"); 395 + ice_debug(hw, ICE_DBG_INIT, "Failed to read Option ROM info.\n"); 455 396 return status; 456 397 } 457 - 458 - /* Boot Configuration Block must have length at least 2 words 459 - * (Combo Image Version High and Combo Image Version Low) 460 - */ 461 - if (boot_cfg_tlv_len < 2) { 462 - ice_debug(hw, ICE_DBG_INIT, 463 - "Invalid Boot Configuration Block TLV size.\n"); 464 - return ICE_ERR_INVAL_SIZE; 465 - } 466 - 467 - status = ice_read_sr_word(hw, (boot_cfg_tlv + ICE_NVM_OEM_VER_OFF), 468 - &oem_hi); 469 - if (status) { 470 - ice_debug(hw, ICE_DBG_INIT, "Failed to read OEM_VER hi.\n"); 471 - return status; 472 - } 473 - 474 - status = ice_read_sr_word(hw, (boot_cfg_tlv + ICE_NVM_OEM_VER_OFF + 1), 475 - &oem_lo); 476 - if (status) { 477 - ice_debug(hw, ICE_DBG_INIT, "Failed to read OEM_VER lo.\n"); 478 - return status; 479 - } 480 - 481 - nvm->oem_ver = ((u32)oem_hi << 16) | oem_lo; 482 398 483 399 return 0; 484 400 }
+19 -11
drivers/net/ethernet/intel/ice/ice_type.h
··· 239 239 enum ice_fc_mode req_mode; /* FC mode requested by caller */ 240 240 }; 241 241 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 + 242 249 /* NVM Information */ 243 250 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 */ 248 256 u8 blank_nvm_mode; /* is NVM empty (no FW present) */ 249 257 }; 250 258 ··· 634 626 635 627 /* Checksum and Shadow RAM pointers */ 636 628 #define ICE_SR_BOOT_CFG_PTR 0x132 637 - #define ICE_NVM_OEM_VER_OFF 0x02 629 + #define ICE_NVM_OROM_VER_OFF 0x02 638 630 #define ICE_SR_NVM_DEV_STARTER_VER 0x18 639 631 #define ICE_SR_NVM_EETRACK_LO 0x2D 640 632 #define ICE_SR_NVM_EETRACK_HI 0x2E ··· 642 634 #define ICE_NVM_VER_LO_MASK (0xff << ICE_NVM_VER_LO_SHIFT) 643 635 #define ICE_NVM_VER_HI_SHIFT 12 644 636 #define ICE_NVM_VER_HI_MASK (0xf << ICE_NVM_VER_HI_SHIFT) 645 - #define ICE_OEM_VER_PATCH_SHIFT 0 646 - #define ICE_OEM_VER_PATCH_MASK (0xff << ICE_OEM_VER_PATCH_SHIFT) 647 - #define ICE_OEM_VER_BUILD_SHIFT 8 648 - #define ICE_OEM_VER_BUILD_MASK (0xffff << ICE_OEM_VER_BUILD_SHIFT) 649 - #define ICE_OEM_VER_SHIFT 24 650 - #define ICE_OEM_VER_MASK (0xff << ICE_OEM_VER_SHIFT) 637 + #define ICE_OROM_VER_PATCH_SHIFT 0 638 + #define ICE_OROM_VER_PATCH_MASK (0xff << ICE_OROM_VER_PATCH_SHIFT) 639 + #define ICE_OROM_VER_BUILD_SHIFT 8 640 + #define ICE_OROM_VER_BUILD_MASK (0xffff << ICE_OROM_VER_BUILD_SHIFT) 641 + #define ICE_OROM_VER_SHIFT 24 642 + #define ICE_OROM_VER_MASK (0xff << ICE_OROM_VER_SHIFT) 651 643 #define ICE_SR_PFA_PTR 0x40 652 644 #define ICE_SR_SECTOR_SIZE_IN_WORDS 0x800 653 645 #define ICE_SR_WORDS_IN_1KB 512