Skip to content

Commit

Permalink
Darwin Rackmon ORV3 support (#288)
Browse files Browse the repository at this point in the history
Summary:
Provide additional config and enhancements to Rackmon logic to support ORV3 for Darwin. Darwin is the only platform so far to support Rackmon from FBOSS.

Pull Request resolved: #288

Test Plan:
1. On a Darwin system connected to PSUs and BBUs, used the thriftctl utility to verify rackmon was monitoring the devices:
```
[root@rkdo301 ~]# thriftctl listPorts
5909: neteng.fboss.ctrl.FbossCtrl
5910: neteng.fboss.qsfp.QsfpService
5931: neteng.fboss.hw_ctrl.FbossHwCtrl
5932: neteng.fboss.hw_ctrl.FbossHwCtrl
5970: neteng.fboss.platform.sensor_service.SensorServiceThrift 5972: fan_service.FanService
5973: rackmonsvc.rackmonsvc.RackmonCtrl
[root@rkdo301 ~]# thriftctl listMethods -p 5973
Found 10 available methods under port:5973
        controlRackmond
        getMonitorData
        getMonitorDataEx
        getPowerLossSiren
        listModbusDevices
        presetMultipleRegisters
        readFileRecord
        readHoldingRegisters
        reload
        writeSingleRegister
[root@rkdo301 ~]# thriftctl request listModbusDevices -p 5973 [ModbusDeviceInfo(
    devAddress=64,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=65,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=66,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=67,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=68,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=69,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=96,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=97,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=98,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=99,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=100,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=101,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=3), ModbusDeviceInfo(
    devAddress=200,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=201,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=202,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=203,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=204,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=205,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=232,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=233,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=234,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=235,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=236,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1), ModbusDeviceInfo(
    devAddress=237,
    mode=0,
    baudrate=19200,
    timeouts=0,
    crcErrors=0,
    miscErrors=0,
    deviceType=1)]
[root@rkdo301 ~]# thriftctl request getMonitorData -p 5973 > /tmp/monitordata.txt
```

2. Ran the rackmon_test on a Darwin system:

```
[root@rkd205 ~]# /tmp/rackmon_test --gtest_filter=RackmonConfig.RegisterMap
Running main() from gmock_main.cc
Note: Google Test filter = RackmonConfig.RegisterMap
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from RackmonConfig
[ RUN      ] RackmonConfig.RegisterMap
[       OK ] RackmonConfig.RegisterMap (1 ms)
[----------] 1 test from RackmonConfig (1 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (1 ms total)
[  PASSED  ] 1 test.
```

Monitored data is attached to this PR.
[rackmondata.txt](https://github.com/user-attachments/files/17637889/rackmondata.txt)

Reviewed By: amithash

Differential Revision: D65801239

Pulled By: joancaneus

fbshipit-source-id: d5bda7f9aa54e21d0c18828f338ab6d5feb51b19
  • Loading branch information
geoffhanson authored and facebook-github-bot committed Dec 5, 2024
1 parent b324e1f commit f472021
Show file tree
Hide file tree
Showing 6 changed files with 1,333 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmake/PlatformRackmon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/fboss/platform/rackmon/configs/interface/rackmon.conf fboss/platform/rackmon/configs/interface/rackmon.conf
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/fboss/platform/rackmon/configs/interface/rackmon_pls.conf fboss/platform/rackmon/configs/interface/rackmon_pls.conf
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/fboss/platform/rackmon/configs/register_map/orv2_psu.json fboss/platform/rackmon/configs/register_map/orv2_psu.json
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/fboss/platform/rackmon/configs/register_map/orv3_psu.json fboss/platform/rackmon/configs/register_map/orv3_psu.json
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/fboss/platform/rackmon/configs/register_map/orv3_bbu.json fboss/platform/rackmon/configs/register_map/orv3_bbu.json
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/fboss/platform/rackmon/generate_rackmon_config.sh fboss/platform/rackmon/generate_rackmon_config.sh
COMMAND fboss/platform/rackmon/generate_rackmon_config.sh --install_dir=fboss/platform/rackmon/
DEPENDS fboss/platform/rackmon/configs/interface/rackmon.conf fboss/platform/rackmon/configs/interface/rackmon_pls.conf fboss/platform/rackmon/configs/register_map/orv2_psu.json
DEPENDS fboss/platform/rackmon/configs/interface/rackmon.conf fboss/platform/rackmon/configs/interface/rackmon_pls.conf fboss/platform/rackmon/configs/register_map/orv2_psu.json fboss/platform/rackmon/configs/register_map/orv3_psu.json fboss/platform/rackmon/configs/register_map/orv3_bbu.json
)

add_fbthrift_cpp_library(
Expand Down
6 changes: 6 additions & 0 deletions fboss/platform/rackmon/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ custom_rule(
"configs/interface/rackmon.conf",
"configs/interface/rackmon_pls.conf",
"configs/register_map/orv2_psu.json",
"configs/register_map/orv3_bbu.json",
"configs/register_map/orv3_psu.json",
],
add_install_dir = True,
build_script_dep = ":generate_rackmon_config.sh",
Expand All @@ -61,6 +63,8 @@ buck_filegroup(
"configs/interface/rackmon.conf",
"configs/interface/rackmon_pls.conf",
"configs/register_map/orv2_psu.json",
"configs/register_map/orv3_bbu.json",
"configs/register_map/orv3_psu.json",
],
)

Expand Down Expand Up @@ -120,6 +124,8 @@ cpp_binary(
"configs/interface/rackmon.conf",
"configs/interface/rackmon_pls.conf",
"configs/register_map/orv2_psu.json",
"configs/register_map/orv3_bbu.json",
"configs/register_map/orv3_psu.json",
],
deps = [
":handler",
Expand Down
10 changes: 10 additions & 0 deletions fboss/platform/rackmon/RackmonThriftHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@ ModbusDeviceType typeFromString(const std::string& str) {
if (str == "ORV2_PSU") {
return ModbusDeviceType::ORV2_PSU;
}
if (str == "ORV3_PSU") {
return ModbusDeviceType::ORV3_PSU;
}
if (str == "ORV3_BBU") {
return ModbusDeviceType::ORV3_BBU;
}
throw std::runtime_error("Unknown PSU: " + str);
}

std::string typeToString(ModbusDeviceType type) {
switch (type) {
case ModbusDeviceType::ORV2_PSU:
return "ORV2_PSU";
case ModbusDeviceType::ORV3_PSU:
return "ORV3_PSU";
case ModbusDeviceType::ORV3_BBU:
return "ORV3_BBU";
default:
break;
}
Expand Down
Loading

0 comments on commit f472021

Please sign in to comment.