| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_FRU_SCANNER_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_FRU_SCANNER_H_ |
| #include <cstdint> |
| #include <memory> |
| #include <string> |
| #include <vector> |
| |
| #include "absl/status/status.h" |
| #include "absl/status/statusor.h" |
| #include "absl/time/time.h" |
| #include "status.pb.h" |
| |
| namespace milotic_tlbmc { |
| |
| // FRU data read from I2C. |
| struct I2cFruInfo { |
| // I2C bus number. |
| uint32_t bus; |
| // FRU address. |
| uint32_t address; |
| // Raw FRU data. |
| std::vector<uint8_t> data; |
| |
| // The following fields will be used for deterministic FRU scanning. |
| // True if any FRU is present and the eeprom is processed successfully on the |
| // specified bus and address. Note that the FRU may be present but not valid |
| // (unexpected part). |
| bool present = false; |
| // Expected barepath of the FRU. |
| std::string expected_barepath; |
| // Expected part number of the FRU. |
| std::string expected_part_number; |
| // Expected serial number of the FRU. |
| std::string expected_serial_number; |
| // True if hardware was detected (via sysfs file or direct I2C ACK) but |
| // content parsing failed. |
| bool parsing_error = false; |
| }; |
| |
| // Fan Assembly FRU info for deterministic scanning. |
| struct I2cSensorAssemblyFruInfo { |
| std::string expected_barepath; |
| uint32_t bus; |
| uint32_t address; |
| bool present = false; |
| }; |
| |
| // ADC FRU info for deterministic scanning. |
| struct AdcFruInfo { |
| std::string expected_barepath; |
| PresenceStatus presence_status; |
| }; |
| |
| // Cable FRU info for deterministic scanning. |
| struct CableFruInfo { |
| std::string expected_barepath; |
| bool present = false; |
| }; |
| |
| // GPIO FRU info for deterministic scanning. |
| struct GpioFruInfo { |
| std::string expected_barepath; |
| PresenceStatus presence_status; |
| }; |
| |
| // USB FRU info for deterministic scanning. |
| struct UsbFruInfo { |
| std::string expected_barepath; |
| PresenceStatus presence_status; |
| }; |
| |
| // Interface for reading FRU data. |
| class FruScanner { |
| public: |
| virtual ~FruScanner() = default; |
| // Reads all FRU data from I2C. |
| virtual absl::StatusOr<std::vector<std::unique_ptr<I2cFruInfo>>> |
| ScanAllI2cFrus() const { |
| return absl::UnimplementedError("ScanAllI2cFrus is not implemented."); |
| } |
| virtual absl::StatusOr<std::unique_ptr<I2cFruInfo>> GetI2cFruInfoFromBus( |
| [[maybe_unused]] int bus, [[maybe_unused]] int address, |
| [[maybe_unused]] absl::Duration delay_between_reads) const { |
| return absl::UnimplementedError("GetI2cFruInfoFromBus is not implemented."); |
| } |
| virtual absl::StatusOr<std::vector<std::unique_ptr<I2cSensorAssemblyFruInfo>>> |
| ScanAllI2cSensorAssemblyFru() const { |
| return absl::UnimplementedError( |
| "ScanAllI2cSensorAssemblyFru is not implemented."); |
| } |
| virtual absl::StatusOr<std::vector<std::unique_ptr<AdcFruInfo>>> |
| ScanAllAdcFrus() const { |
| return absl::UnimplementedError("ScanAllAdcFrus is not implemented."); |
| } |
| virtual absl::StatusOr<std::vector<std::unique_ptr<CableFruInfo>>> |
| ScanAllCableFrus() const { |
| return absl::UnimplementedError("ScanAllCableFrus is not implemented."); |
| } |
| virtual absl::StatusOr<std::vector<std::unique_ptr<GpioFruInfo>>> |
| ScanAllGpioFrus() const { |
| return absl::UnimplementedError("ScanAllGpioFrus is not implemented."); |
| } |
| virtual absl::StatusOr<std::vector<std::unique_ptr<UsbFruInfo>>> |
| ScanAllUsbFrus() const { |
| return absl::UnimplementedError("ScanAllUsbFrus is not implemented."); |
| } |
| }; |
| |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_FRU_SCANNER_H_ |