1. 21 Mar, 2020 6 commits
    • Jacob Keller's avatar
      ice: enable initial devlink support · 1adf7ead
      Jacob Keller authored
      Begin implementing support for the devlink interface with the ice
      driver.
      
      The pf structure is currently memory managed through devres, via
      a devm_alloc. To mimic this behavior, after allocating the devlink
      pointer, use devm_add_action to add a teardown action for releasing the
      devlink memory on exit.
      
      The ice hardware is a multi-function PCIe device. Thus, each physical
      function will get its own devlink instance. This means that each
      function will be treated independently, with its own parameters and
      configuration. This is done because the ice driver loads a separate
      instance for each function.
      
      Due to this, the implementation does not enable devlink to manage
      device-wide resources or configuration, as each physical function will
      be treated independently. This is done for simplicity, as managing
      a devlink instance across multiple driver instances would significantly
      increase the complexity for minimal gain.
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      1adf7ead
    • Jesse Brandeburg's avatar
      ice: implement full NVM read from ETHTOOL_GEEPROM · 84a24798
      Jesse Brandeburg authored
      The current implementation of .get_eeprom only enables reading from the
      Shadow RAM portion of the NVM contents. Implement support for reading
      the entire flash contents instead of only the initial portion contained
      in the Shadow RAM.
      
      A complete dump can take several seconds, but the ETHTOOL_GEEPROM ioctl
      is capable of reading only a limited portion at a time by specifying the
      offset and length to read.
      
      In order to perform the reads directly, several functions are made non
      static. Additionally, the unused ice_read_sr_buf_aq and ice_read_sr_buf
      functions are removed.
      Signed-off-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      84a24798
    • Jacob Keller's avatar
      ice: discover and store size of available flash · 81f07491
      Jacob Keller authored
      When reading from the NVM using a flat address, it is useful to know the
      upper bound on the size of the flash contents. This value is not stored
      within the NVM.
      
      We can determine the size by performing a bisection between upper and
      lower bounds. It is known that the size cannot exceed 16 MB (offset of
      0xFFFFFF).
      
      Use a while loop to bisect the upper and lower bounds by reading one
      byte at a time. On a failed read, lower the maximum bound. On
      a successful read, increase the lower bound.
      
      Save this as the flash_size in the ice_nvm_info structure that contains
      data related to the NVM.
      
      The size will be used in a future patch for implementing full NVM read
      via ethtool's GEEPROM command.
      
      The maximum possible size for the flash is bounded by the size limit for
      the NVM AdminQ commands. Add a new macro, ICE_AQC_NVM_MAX_OFFSET, which
      can be used to represent this upper bound.
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      81f07491
    • Jacob Keller's avatar
      ice: store NVM version info in extracted format · d4e87444
      Jacob Keller authored
      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: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      d4e87444
    • Jacob Keller's avatar
      ice: create function to read a section of the NVM and Shadow RAM · e9450990
      Jacob Keller authored
      The NVM contents are read via firmware by using the ice_aq_read_nvm
      function. This function has a couple of limits:
      
      1) The AdminQ commands can only take buffers sized up to 4Kb. Thus, any
         larger read must be split into multiple reads.
      2) when reading from the Shadow RAM, reads must not cross sector
         boundaries. The sectors are also 4Kb in size.
      
      Implement the ice_read_flat_nvm function to read portions of the NVM by
      flat offset. That is, to read using offsets from the start of the NVM
      rather than from a specific module.
      
      This function will be able to read both from the NVM and from the Shadow
      RAM. For simplicity NVM reads will always be broken up to not cross 4Kb
      page boundaries, even though this is not required unless reading from
      the Shadow RAM.
      
      Use this new function as the implementation of ice_read_sr_word_aq.
      
      The ice_read_sr_buf_aq function is not modified here. This is because
      a following change will remove the only caller of that function in favor
      of directly using ice_read_flat_nvm. Thus, there is little benefit to
      changing it now only to remove it momentarily. At the same time, the
      ice_read_sr_aq function will also be removed.
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      e9450990
    • Jacob Keller's avatar
      ice: use __le16 types for explicitly Little Endian values · 2efefb56
      Jacob Keller authored
      The ice_read_sr_aq function returns words in the Little Endian format.
      Remove the need for __force and typecasting by using a local variable in
      the ice_read_sr_word_aq function.
      
      Additionally clarify explicitly that the ice_read_sr_aq function takes
      storage for __le16 values instead of using u16.
      
      Being explicit about the endianness of this data helps when using tools
      like sparse to catch endian-related issues.
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      2efefb56
  2. 20 Mar, 2020 34 commits