Skip to content

Commit

Permalink
Merge pull request facebook#61 from adamcalabrigo/meru800bia_services
Browse files Browse the repository at this point in the history
Meru800bia: initial sensor_service and data_corral_service support
  • Loading branch information
adamcalabrigo committed Aug 17, 2023
2 parents fdbbafd + 20e9e95 commit a88a749
Show file tree
Hide file tree
Showing 13 changed files with 513 additions and 30 deletions.
7 changes: 6 additions & 1 deletion arista/rpm/arista-fboss-platform-meru800bia.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Source: %{expand:%%(pwd)}
%define _fboss_meru800bia_dir fboss.git/arista/platform/meru800bia
%define _fboss_build_repo_dir tmp_build_dir/repos/github.com-facebook-fboss.git
%define _fboss_bcm_hw_config_dir %{_fboss_build_repo_dir}/fboss/oss/hw_test_configs
%define _fboss_config_dir %{_fboss_build_repo_dir}/fboss/platform/configs
%define _sai_sdk_src_dir Aqua_SAI/sdk-src

%define _fboss_target_share %{buildroot}/opt/fboss/share
Expand All @@ -19,13 +20,14 @@ Source: %{expand:%%(pwd)}

%description
This package provides platform-specific utilities to run Meta FBOSS OSS on Arista
Meru800bia (Fairywren) switches.
Meru800bia (Viper) switches.

%prep
set -x
find . -mindepth 1 -delete
cp -af %{SOURCEURL0}/%{_fboss_meru800bia_dir}/* .
find %{SOURCEURL0}/%{_sai_sdk_src_dir} -wholename "*/tools/sand/db" -exec cp -r {} . \;
cp -af %{SOURCEURL0}/%{_fboss_config_dir}/meru800bia/sensor_service.json platform_sensors.conf

%install
mkdir -p %{_fboss_target_share}
Expand All @@ -34,8 +36,11 @@ mkdir -p %{_fboss_target_var}
install config/fruid/fruid.json %{_fboss_target_var}
mkdir -p %{_fboss_target_udev}
install config/udev/99-meru800bia.rules %{_fboss_target_udev}
mkdir -p %{_fboss_target_share}/sensor_service/
install platform_sensors.conf %{_fboss_target_share}/sensor_service/

%files
/var/facebook/fboss/fruid.json
/opt/fboss/share/db
/etc/udev/rules.d/99-meru800bia.rules
/opt/fboss/share/sensor_service/platform_sensors.conf
3 changes: 3 additions & 0 deletions cmake/PlatformDataCorralService.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ add_library(data_corral_service_lib
fboss/platform/data_corral_service/darwin/DarwinChassisManager.cpp
fboss/platform/data_corral_service/darwin/DarwinPlatformConfig.cpp
fboss/platform/data_corral_service/darwin/DarwinFruModule.cpp
fboss/platform/data_corral_service/meru800bia/Meru800biaChassisManager.cpp
fboss/platform/data_corral_service/meru800bia/Meru800biaPlatformConfig.cpp
fboss/platform/data_corral_service/meru800bia/Meru800biaFruModule.cpp
)

target_link_libraries(data_corral_service_lib
Expand Down
170 changes: 170 additions & 0 deletions fboss/platform/configs/meru800bia/sensor_service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"source" : "sysfs",
"sensorMapList" : {
"SCM" : {
"CPU_PACKAGE_TEMP" :{
"path" : "/run/devmap/sensors/CPU_CORE_TEMP/temp1_input",
"thresholds" : {
"upperCriticalVal" : 105
},
"type" : 3
},
"CPU_CORE0_TEMP" :{
"path" : "/run/devmap/sensors/CPU_CORE_TEMP/temp2_input",
"thresholds" : {
"upperCriticalVal" : 105
},
"type" : 3
},
"CPU_CORE1_TEMP" :{
"path" : "/run/devmap/sensors/CPU_CORE_TEMP/temp3_input",
"thresholds" : {
"upperCriticalVal" : 105
},
"type" : 3
},
"CPU_CORE2_TEMP" :{
"path" : "/run/devmap/sensors/CPU_CORE_TEMP/temp4_input",
"thresholds" : {
"upperCriticalVal" : 105
},
"type" : 3
},
"CPU_CORE3_TEMP" :{
"path" : "/run/devmap/sensors/CPU_CORE_TEMP/temp5_input",
"thresholds" : {
"upperCriticalVal" : 105
},
"type" : 3
},
"CPU_CORE4_TEMP" :{
"path" : "/run/devmap/sensors/CPU_CORE_TEMP/temp6_input",
"thresholds" : {
"upperCriticalVal" : 105
},
"type" : 3
},
"CPU_CORE5_TEMP" :{
"path" : "/run/devmap/sensors/CPU_CORE_TEMP/temp7_input",
"thresholds" : {
"upperCriticalVal" : 105
},
"type" : 3
},
"CPU_CORE6_TEMP" :{
"path" : "/run/devmap/sensors/CPU_CORE_TEMP/temp8_input",
"thresholds" : {
"upperCriticalVal" : 105
},
"type" : 3
},
"CPU_CORE7_TEMP" :{
"path" : "/run/devmap/sensors/CPU_CORE_TEMP/temp9_input",
"thresholds" : {
"upperCriticalVal" : 105
},
"type" : 3
},
"CPU_ECB_VIN" : {
"path" : "/run/devmap/sensors/CPU_MPS_PMBUS/in1_input",
"type" : 1
},
"CPU_ECB_VOUT" : {
"path" : "/run/devmap/sensors/CPU_MPS_PMBUS/in2_input",
"type" : 1
},
"CPU_ECB_TEMP" : {
"path" : "/run/devmap/sensors/CPU_MPS_PMBUS/temp1_input",
"type" : 3
},
"CPU_ECB_IOUT" : {
"path" : "/run/devmap/sensors/CPU_MPS_PMBUS/curr1_input",
"type" : 2
},
"CPU_VRM1_VIN1" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_1/in1_input",
"type" : 1
},
"CPU_VRM1_VIN2" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_1/in2_input",
"type" : 1
},
"CPU_VRM1_VOUT_VCCIN" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_1/in3_input",
"type" : 1
},
"CPU_VRM1_VOUT_1V8_CPU" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_1/in4_input",
"type" : 1
},
"CPU_VRM1_TEMP1" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_1/temp1_input",
"type" : 3
},
"CPU_VRM1_TEMP2" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_1/temp2_input",
"type" : 3
},
"CPU_VRM2_VIN1" : {
"path" : "/run/devmap/sensors/CPU_PXE1211/in1_input",
"type" : 1
},
"CPU_VRM2_VIN2" : {
"path" : "/run/devmap/sensors/CPU_PXE1211/in2_input",
"type" : 1
},
"CPU_VRM2_VIN3" : {
"path" : "/run/devmap/sensors/CPU_PXE1211/in3_input",
"type" : 1
},
"CPU_VRM2_VOUT_1V2_VDDQ" : {
"path" : "/run/devmap/sensors/CPU_PXE1211/in4_input",
"type" : 1
},
"CPU_VRM2_VOUT_VNN_NAC" : {
"path" : "/run/devmap/sensors/CPU_PXE1211/in5_input",
"type" : 1
},
"CPU_VRM2_VOUT_1V0_CPU" : {
"path" : "/run/devmap/sensors/CPU_PXE1211/in6_input",
"type" : 1
},
"CPU_VRM2_TEMP1" : {
"path" : "/run/devmap/sensors/CPU_PXE1211/temp1_input",
"type" : 3
},
"CPU_VRM2_TEMP2" : {
"path" : "/run/devmap/sensors/CPU_PXE1211/temp2_input",
"type" : 3
},
"CPU_VRM2_TEMP3" : {
"path" : "/run/devmap/sensors/CPU_PXE1211/temp3_input",
"type" : 3
},
"CPU_VRM3_VIN1" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_2/in1_input",
"type" : 1
},
"CPU_VRM3_VIN2" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_2/in2_input",
"type" : 1
},
"CPU_VRM3_VOUT_1V05_CPU" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_2/in3_input",
"type" : 1
},
"CPU_VRM3_VOUT_VNN_PCH" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_2/in4_input",
"type" : 1
},
"CPU_VRM3_TEMP1" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_2/temp1_input",
"type" : 3
},
"CPU_VRM3_TEMP2" : {
"path" : "/run/devmap/sensors/CPU_PXM1310_2/temp2_input",
"type" : 3
}
}
}
}
8 changes: 8 additions & 0 deletions fboss/platform/data_corral_service/ChassisManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,12 @@ class ChassisManager {
std::unique_ptr<ChassisMonitor> monitor_;
};

enum ChassisLedColor {
OFF = 0,
RED = 1,
GREEN = 2,
BLUE = 3,
AMBER = 4,
};

} // namespace facebook::fboss::platform::data_corral_service
4 changes: 4 additions & 0 deletions fboss/platform/data_corral_service/DataCorralServiceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "fboss/lib/platforms/PlatformProductInfo.h"
#include "fboss/platform/data_corral_service/DataCorralServiceImpl.h"
#include "fboss/platform/data_corral_service/darwin/DarwinChassisManager.h"
#include "fboss/platform/data_corral_service/meru800bia/Meru800biaChassisManager.h"
#include "fboss/platform/weutil/Weutil.h"

namespace {
Expand All @@ -38,6 +39,9 @@ void DataCorralServiceImpl::init() {
if (type == PlatformType::PLATFORM_DARWIN) {
chassisManager_ =
std::make_unique<DarwinChassisManager>(kRefreshIntervalInMs);
} else if (type == PlatformType::PLATFORM_MERU800BIA) {
chassisManager_ =
std::make_unique<Meru800biaChassisManager>(kRefreshIntervalInMs);
} else {
XLOG(WARN) << "Unable to instantiate ChassisManager for platform "
<< toString(type);
Expand Down
34 changes: 17 additions & 17 deletions fboss/platform/data_corral_service/darwin/DarwinChassisManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ const std::string kSetColorFailure = "set.color.failure";
namespace facebook::fboss::platform::data_corral_service {

void DarwinChassisLed::setColorPath(
DarwinLedColor color,
ChassisLedColor color,
const std::string& path) {
XLOG(DBG2) << "led " << name_ << ", color " << color << ", sysfs path "
<< path;
paths_[color] = path;
}

void DarwinChassisLed::setColor(DarwinLedColor color) {
void DarwinChassisLed::setColor(ChassisLedColor color) {
if (color_ != color) {
if (!facebook::fboss::writeSysfs(paths_[color], "1")) {
XLOG(ERR) << "failed to set color " << color << " for led " << name_;
Expand All @@ -61,7 +61,7 @@ void DarwinChassisLed::setColor(DarwinLedColor color) {
fb303::fbData->setCounter(kSetColorFailure, 0);
}

DarwinLedColor DarwinChassisLed::getColor() {
ChassisLedColor DarwinChassisLed::getColor() {
for (auto const& colorPath : paths_) {
std::string brightness = facebook::fboss::readSysfs(colorPath.second);
try {
Expand All @@ -75,7 +75,7 @@ DarwinLedColor DarwinChassisLed::getColor() {
throw;
}
}
return DarwinLedColor::OFF;
return ChassisLedColor::OFF;
}

void DarwinChassisManager::initModules() {
Expand All @@ -94,43 +94,43 @@ void DarwinChassisManager::initModules() {
pemLed_ = std::make_unique<DarwinChassisLed>(kPemLed);
for (auto attr : *platformConfig.chassisAttributes()) {
if (*attr.name() == kSystemLed + kLedRed) {
sysLed_->setColorPath(DarwinLedColor::RED, *attr.path());
sysLed_->setColorPath(ChassisLedColor::RED, *attr.path());
} else if (*attr.name() == kSystemLed + kLedGreen) {
sysLed_->setColorPath(DarwinLedColor::GREEN, *attr.path());
sysLed_->setColorPath(ChassisLedColor::GREEN, *attr.path());
} else if (*attr.name() == kFanLed + kLedRed) {
fanLed_->setColorPath(DarwinLedColor::RED, *attr.path());
fanLed_->setColorPath(ChassisLedColor::RED, *attr.path());
} else if (*attr.name() == kFanLed + kLedGreen) {
fanLed_->setColorPath(DarwinLedColor::GREEN, *attr.path());
fanLed_->setColorPath(ChassisLedColor::GREEN, *attr.path());
} else if (*attr.name() == kPemLed + kLedRed) {
pemLed_->setColorPath(DarwinLedColor::RED, *attr.path());
pemLed_->setColorPath(ChassisLedColor::RED, *attr.path());
} else if (*attr.name() == kPemLed + kLedGreen) {
pemLed_->setColorPath(DarwinLedColor::GREEN, *attr.path());
pemLed_->setColorPath(ChassisLedColor::GREEN, *attr.path());
}
}
}

void DarwinChassisManager::programChassis() {
DarwinLedColor sysLedColor = DarwinLedColor::GREEN;
DarwinLedColor fanLedColor = DarwinLedColor::GREEN;
DarwinLedColor pemLedColor = DarwinLedColor::GREEN;
ChassisLedColor sysLedColor = ChassisLedColor::GREEN;
ChassisLedColor fanLedColor = ChassisLedColor::GREEN;
ChassisLedColor pemLedColor = ChassisLedColor::GREEN;

for (auto& fru : fruModules_) {
if (!fru.second->isPresent()) {
XLOG(DBG2) << "Fru module " << fru.first << " is absent";
sysLedColor = DarwinLedColor::RED;
sysLedColor = ChassisLedColor::RED;
if (std::strncmp(
fru.first.c_str(), kDarwinFan.c_str(), kDarwinFan.length()) ==
0) {
fanLedColor = DarwinLedColor::RED;
fanLedColor = ChassisLedColor::RED;
} else if (
std::strncmp(
fru.first.c_str(), kDarwinPem.c_str(), kDarwinPem.length()) ==
0) {
pemLedColor = DarwinLedColor::RED;
pemLedColor = ChassisLedColor::RED;
}
}
}
if (sysLedColor == DarwinLedColor::GREEN) {
if (sysLedColor == ChassisLedColor::GREEN) {
XLOG(DBG4) << "All fru modules are present";
}
fb303::fbData->setCounter(fmt::format("{}.color", kSystemLed), sysLedColor);
Expand Down
18 changes: 6 additions & 12 deletions fboss/platform/data_corral_service/darwin/DarwinChassisManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,21 @@

namespace facebook::fboss::platform::data_corral_service {

enum DarwinLedColor {
OFF = 0,
RED = 1,
GREEN = 2,
};

class DarwinChassisLed {
public:
explicit DarwinChassisLed(const std::string& name)
: name_(name), color_(DarwinLedColor::OFF) {}
void setColorPath(DarwinLedColor color, const std::string& path);
: name_(name), color_(ChassisLedColor::OFF) {}
void setColorPath(ChassisLedColor color, const std::string& path);
const std::string& getName() {
return name_;
}
void setColor(DarwinLedColor color);
DarwinLedColor getColor();
void setColor(ChassisLedColor color);
ChassisLedColor getColor();

private:
std::string name_;
DarwinLedColor color_;
std::unordered_map<DarwinLedColor, std::string> paths_;
ChassisLedColor color_;
std::unordered_map<ChassisLedColor, std::string> paths_;
};

class DarwinChassisManager : public ChassisManager {
Expand Down

0 comments on commit a88a749

Please sign in to comment.