| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_NIC_VEEPROM_INTERFACE_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_NIC_VEEPROM_INTERFACE_H_ |
| |
| #include <memory> |
| #include <string> |
| |
| #include "absl/status/statusor.h" |
| #include "absl/strings/string_view.h" |
| #include "veeprom.pb.h" |
| #include "sensor.pb.h" |
| |
| namespace milotic_tlbmc::nic_veeprom { |
| |
| // Accessor is the interface for reading and writing virtual EEPROM data from a |
| // Google NIC. |
| class Accessor { |
| public: |
| virtual ~Accessor() = default; |
| |
| // Do a refresh immediately and update internal data buffer and timestamps |
| // The implementation should do a batch read for all telemetry supported by |
| // the specified version to increase efficiency. |
| // The implementation must be blocking and must be thread-safe. |
| virtual void DoRefresh() = 0; |
| |
| // Given a telemetry name, returns the most recent SensorValue. |
| // The implementation must be blocking and must be thread-safe. |
| virtual absl::StatusOr<std::shared_ptr<const SensorValue>> GetSensorValue( |
| NicTelemetryName name) const = 0; |
| |
| // Creates an accessor for the given veeprom version, bus and address. |
| // Optional registry keys can be provided for I2C and EEPROM implementations. |
| // Legacy factory for backward compatibility. Hardcodes defaults in |
| // implementation. |
| static std::unique_ptr<Accessor> Create(NicTelemetryVersion version, int bus, |
| int address); |
| |
| // New factory with parameterizable drivers, no defaults. |
| // `i2c_impl` specifies the I2cBus registry key (e.g., "I2cBusI2c"). |
| // `eeprom_impl` specifies the Eeprom registry key (e.g., "At24Eeprom"). |
| static std::unique_ptr<Accessor> CreateWithDrivers( |
| NicTelemetryVersion version, int bus, int address, |
| absl::string_view i2c_impl, absl::string_view eeprom_impl); |
| |
| virtual SensorUnit GetSensorUnit(NicTelemetryName sensor) const = 0; |
| }; |
| |
| } // namespace milotic_tlbmc::nic_veeprom |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_NIC_VEEPROM_INTERFACE_H_ |