Page MenuHomeFreeBSD

bhnd: Unify NVRAM/SPROM parsing, implement compact SPROM layout encoding
ClosedPublic

Authored by landonf on Nov 26 2016, 12:41 AM.

Details

Summary
  • Defined an abstract NVRAM I/O API (bhnd_nvram_io), decoupling NVRAM/SPROM parsing from the actual underlying NVRAM data provider (e.g. CFE firmware devices).
  • Defined an abstract NVRAM data API (bhnd_nvram_data), decoupling higher-level NVRAM operations (indexed lookup, data conversion, etc) from the underlying NVRAM file format parsing/serialization.
  • Implemented a new high-level bhnd_nvram_store API, providing indexed variable lookup, pending write tracking, etc on top of an arbitrary bhnd_nvram_data instance.
  • Migrated all NVRAM device drivers to the common bhnd_nvram_store API.
  • Implemented a common bhnd_nvram_val API for parsing/encoding NVRAM variable values, including applying format-specific behavior when converting to/from the NVRAM string representations.
  • Dropped the now unnecessary bhnd_nvram driver, and moved the broadcom/mips-specific CFE NVRAM driver out into sys/mips/broadcom.
  • Implemented a new nvram_map file format:
    • Variable definitions are now defined separately from the SPROM layout information, allowing us to independently define SPROM layouts that reference the common variable definitions. Later, this should also allow us to define CIS tuple NVRAM mappings with the same common NVRAM variable definitions.
    • Variables can now be defined within arbitrary named groups.
    • Textual descriptions and help information can be defined inline for both variables and variable groups.
  • Implemented a new, compact encoding of SPROM image layout offsets:
    • The encoding is loosely modeled on Apple dyld compressed LINKEDIT symbol binding opcodes; it provides a compact state-machine encoding of the mapping between NVRAM variables and the SPROM image offset, mask, and shift instructions necessary to decode or encode the SPROM variable data.
    • The compact encoding reduces the size of the generated SPROM variable layout data from roughly 60KB to 3KB. The sequential nature SPROM layout opcode tables also simplify iteration of the SPROM variables, as it's no longer neccessary to iterate the full NVRAM variable definition table, but instead simply scan the SPROM revision's layout opcode table.
  • Added source-level (but not build system) support for building the NVRAM file format APIs (bhnd_nvram_io, bhnd_nvram_data, bhnd_nvram_store) as a userspace library.
Test Plan

Tested for bhnd(4)/bwn(4) regressions against:

  • BCM4321
  • BCM43225
  • BCM4331
  • Netgear WGT634U
  • Asus RT-N16
  • Asus RT-N53

Diff Detail

Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 6065
Build 6329: arc lint + arc unit

Event Timeline

landonf retitled this revision from to bhnd: Unify NVRAM/SPROM parsing, implement compact SPROM layout encoding.Nov 26 2016, 12:41 AM
landonf updated this object.
landonf edited the test plan for this revision. (Show Details)
landonf added reviewers: adrian, mizhka_gmail.com.
landonf updated this revision to Diff 22520.
landonf updated this revision to Diff 22521.

Fixed comment spelling errors.

adrian edited edge metadata.Nov 26 2016, 4:29 AM
adrian accepted this revision.

.. wow. :)

This revision is now accepted and ready to land.Nov 26 2016, 4:29 AM
mizhka_gmail.com accepted this revision.
landonf closed this revision.Dec 12 2016, 8:04 PM