• Jacob Keller's avatar
    ice: introduce function for reading from flash modules · 0ce50c70
    Jacob Keller authored
    When reading from the flash memory of the device, the ice driver has two
    interfaces available to it. First, it can use a mediated interface via
    firmware that allows specifying a module ID. This allows reading from
    specific modules of the active flash bank.
    
    The second interface available is to perform flat reads. This allows
    complete access to the entire flash. However, using it requires the
    software to handle calculating module location and interpret pointer
    addresses.
    
    While most data required is accessible through the convenient first
    interface, certain flash contents are not. This includes the CSS header
    information associated with the Option ROM and NVM banks, as well as any
    access to the "inactive" banks used as scratch space for performing
    flash updates.
    
    In order to access all of the relevant flash contents, software must use
    the flat reads. Rather than forcing all flows to perform flat read
    calculations, introduce a new abstraction for reading from the flash:
    ice_read_flash_module. This function provides an abstraction for reading
    from either the active or inactive flash bank at the requested module.
    This interface is very similar to the abstraction provided via firmware,
    but allows access to additional modules, as well as providing
    a mechanism to request access to both flash banks.
    
    At first glance, it might make sense for this abstraction to allow
    specifying precisely which bank (1st or 2nd) the caller wishes to read.
    This is simpler to implement but more difficult to use. In practice,
    most callers only know whether they want the active bank, or the
    inactive bank. Rather than force callers to determine for themselves
    which bank to read from, implement ice_read_flash_module in terms of
    "active" vs "inactive". This significantly simplifies the implementation
    at the caller level and is a more useful abstraction over the flash
    contents.
    
    Make use of this new interface to refactor reading of the main NVM
    version information. Instead of using the firmware's mediated ShadowRAM
    function, use the ice_read_flash_module abstraction.
    
    To do this, notice that most reads of the NVM are going to be in 2-byte
    word chunks. To simplify using ice_read_flash_module for this case,
    ice_read_nvm_module is introduced. This is a simple wrapper around
    ice_read_flash_module which takes the correct pointer address for the
    NVM bank, and forces the 2-byte word format onto the caller.
    
    When reading the NVM versions, some fields are read from the Shadow RAM.
    The Shadow RAM is the first 64KB of flash memory, and is populated
    during device load. Most fields are copied from a section within the
    active NVM bank. In order to read this data from both the active and
    inactive NVM banks, we need to read not from the first 64KB of flash,
    but instead from the correct offset into the NVM bank. Introduce
    ice_read_nvm_sr_copy for this purpose. This function wraps around
    ice_read_nvm_module and has the same interface as the ice_read_sr_word,
    with the exception of allowing the caller to specify whether to read the
    active or inactive flash bank.
    
    With this change, it is now trivial to refactor ice_get_nvm_ver_info to
    read using the software mediated ice_read_flash_module interface instead
    of relying on the firmware mediated interface. This will be used in the
    following change to implement support for stored versions in the devlink
    info report.
    
    Additionally, the overall ice_read_flash_module interface will be used
    and extended to support all three major flash banks, and additionally to
    support reading the flash image security revision information.
    Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
    Tested-by: default avatarTony Brelinski <tonyx.brelinski@intel.com>
    Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
    0ce50c70
ice_nvm.c 31.8 KB