| #include "tlbmc/hal/nic_veeprom/interface.h" |
| |
| #include <memory> |
| #include <string> |
| |
| #include "absl/log/log.h" |
| #include "absl/strings/str_format.h" |
| #include "tlbmc/hal/nic_veeprom/accessor_v1.h" |
| #include "tlbmc/hal/nic_veeprom/accessor_v2.h" |
| #include "veeprom.pb.h" |
| |
| namespace milotic_tlbmc::nic_veeprom { |
| |
| std::unique_ptr<Accessor> Accessor::Create(NicTelemetryVersion version, |
| int bus, int address) { |
| const std::string eeprom_path = |
| absl::StrFormat("/sys/bus/i2c/devices/%d-%04x/eeprom", bus, address); |
| switch (version) { |
| case NicTelemetryVersion::NIC_TELEMETRY_VERSION_V1: |
| return CreateAccessorV1(eeprom_path); |
| case NicTelemetryVersion::NIC_TELEMETRY_VERSION_V2: |
| return CreateAccessorV2(eeprom_path); |
| default: |
| LOG(ERROR) << "Unsupported VEEPROM version: " << version; |
| return nullptr; |
| } |
| } |
| |
| } // namespace milotic_tlbmc::nic_veeprom |