Skip to content

Commit

Permalink
aalc: add sensor level 3 and event log (#2056)
Browse files Browse the repository at this point in the history
Summary:
- modify fan table
- block auto tune command util bic is ready
- disable auto tune will not set duty to 0
- add more error log event
- add sensor COOLING_CAPACITY
- add sensor BPB_RACK_LEVEL_3
- extend COOLING_CAPACITY modbus command to 2 register
- add modbus shell command for test
- modify the threshold of y_filter to be dynamic
- fix threshold struct member last_status to the correct size

Pull Request resolved: #2056

Test Plan: - Build code: PASS

Reviewed By: waffle2k

Differential Revision: D65333687

fbshipit-source-id: 38af4196585393c7ac438fef4fb5cd4130b05115
  • Loading branch information
HungYi-Li authored and facebook-github-bot committed Nov 15, 2024
1 parent 33ebec3 commit ddf9fc9
Show file tree
Hide file tree
Showing 16 changed files with 292 additions and 147 deletions.
1 change: 1 addition & 0 deletions meta-facebook/aalc-rpu/src/platform/plat_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
#define ADC_CALIBRATION 1
#define MORE_THAN_ONE_ADM1272
#define ENABLE_PLAT_DEF_SENSOR
#define BIC_UPDATE_MAX_OFFSET 0x60000

#endif
42 changes: 0 additions & 42 deletions meta-facebook/aalc-rpu/src/platform/plat_fsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,6 @@ static uint8_t fsc_poll_flag = 1;
extern zone_cfg zone_table[];
extern uint32_t zone_table_size;

static int get_flow_rate_setpoint(void)
{
const int worst_case = 200; // TODO: TBD
float flow_rate_val = 0.0;
float tout_val = 0.0;
float tin_val = 0.0;

uint8_t flow_rate_status = get_sensor_reading_to_real_val(
SENSOR_NUM_BPB_RPU_COOLANT_FLOW_RATE_LPM, &flow_rate_val);
uint8_t tout_status =
get_sensor_reading_to_real_val(SENSOR_NUM_BPB_HEX_WATER_INLET_TEMP_C, &tout_val);
uint8_t tin_status =
get_sensor_reading_to_real_val(SENSOR_NUM_BPB_RPU_COOLANT_INLET_TEMP_C, &tin_val);

if (flow_rate_status != SENSOR_READ_4BYTE_ACUR_SUCCESS)
return worst_case;

if (tout_status != SENSOR_READ_4BYTE_ACUR_SUCCESS)
return worst_case;

if (tin_status != SENSOR_READ_4BYTE_ACUR_SUCCESS)
return worst_case;

FSC_PRINTF("flow_rate_val %f, tout_val %f, tin_val %f\n", flow_rate_val, tout_val, tin_val);
FSC_PRINTF("1.00815 * flow_rate_val * (tout_val - tin_val) = %f\n",
1.00815 * flow_rate_val * (tout_val - tin_val));
return (int)(1.00815 * flow_rate_val * (tout_val - tin_val));
}

uint8_t fsc_debug_set(uint8_t enable)
{
enable_debug_print = enable;
Expand Down Expand Up @@ -159,19 +130,6 @@ static uint8_t calculatePID(zone_cfg *zone_p, uint8_t *duty)

int16_t temp = (int16_t)tmp;

tmp = 0.0;
if (p->setpoint_type == SETPOINT_AIR_INTEL_AVG_C) {
if (get_sensor_reading_to_real_val(SENSOR_NUM_SB_HEX_AIR_INLET_AVG_TEMP_C,
&tmp) !=
SENSOR_READ_4BYTE_ACUR_SUCCESS) {
tmp = 40.0; // worst case
}
tmp = CLAMP(tmp, -20, 100);
p->setpoint = (int16_t)tmp + 10;
} else if (p->setpoint_type == SETPOINT_FLOW_RATE_LPM) {
p->setpoint = get_flow_rate_setpoint();
}

FSC_PRINTF("\t\t----- sensor_num %x, temp = %d, p->setpoint %d\n", p->sensor_num,
temp, p->setpoint);

Expand Down
7 changes: 1 addition & 6 deletions meta-facebook/aalc-rpu/src/platform/plat_fsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ enum FSC_TYPE {
FSC_TYPE_DEFAULT,
};

enum SETPOINT_TYPE {
SETPOINT_AIR_INTEL_AVG_C = 0,
SETPOINT_FLOW_RATE_LPM,
};

/* stepwise */
typedef struct {
uint8_t temp;
Expand All @@ -71,7 +66,7 @@ typedef struct {
typedef struct {
uint8_t sensor_num;
int setpoint;
uint8_t setpoint_type;
/*uint8_t setpoint_type;*/
float kp;
float ki;
float kd;
Expand Down
18 changes: 16 additions & 2 deletions meta-facebook/aalc-rpu/src/platform/plat_fsc_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pid_cfg hex_fan_pid_table[] = {
{
.sensor_num = SENSOR_NUM_BPB_RPU_COOLANT_OUTLET_TEMP_C,
.setpoint_type = SETPOINT_AIR_INTEL_AVG_C,
.setpoint = 40,
.kp = -7,
.ki = -0.1,
.kd = -3,
Expand Down Expand Up @@ -63,6 +63,7 @@ stepwise_cfg hex_fan_stepwise_table[] = {
},
};

/*
pid_cfg pump_pid_table[] = {
{
.sensor_num = SENSOR_NUM_BPB_RPU_COOLANT_OUTLET_TEMP_C,
Expand Down Expand Up @@ -120,6 +121,18 @@ stepwise_cfg pump_stepwise_table[] = {
{45, 35},
},
},
};*/

stepwise_cfg pump_stepwise_table[] = {
{
.sensor_num = SENSOR_NUM_COOLING_CAPACITY,
.step = {
{30, 45},
{45, 55},
{60, 65},
{61, 100},
},
},
};

stepwise_cfg rpu_fan_stepwise_table[] = {
Expand Down Expand Up @@ -163,8 +176,9 @@ zone_cfg zone_table[] = {
// zone 2 - pump
.sw_tbl = pump_stepwise_table,
.sw_tbl_num = ARRAY_SIZE(pump_stepwise_table),
/*
.pid_tbl = pump_pid_table,
.pid_tbl_num = ARRAY_SIZE(pump_pid_table),
.pid_tbl_num = ARRAY_SIZE(pump_pid_table),*/
.interval = 1,
.set_duty = pwm_control,
.set_duty_arg = PWM_GROUP_E_PUMP,
Expand Down
11 changes: 10 additions & 1 deletion meta-facebook/aalc-rpu/src/platform/plat_hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ bool pump_setting_set_auto_tune_flag(pump_reset_struct *data, uint8_t bit_val)
{
CHECK_NULL_ARG_WITH_RETURN(data, false);

if (!get_status_flag(STATUS_FLAG_SYSTEM_READY))
return false;

if (bit_val) {
for (uint8_t i = MANUAL_PWM_E_HEX_FAN; i <= MANUAL_PWM_E_RPU_FAN; i++) {
if (get_manual_pwm_flag(i))
Expand Down Expand Up @@ -415,7 +418,13 @@ uint8_t pwm_control(uint8_t group, uint8_t duty)
static int64_t auto_tune_time;
if (!get_status_flag(STATUS_FLAG_AUTO_TUNE)) {
auto_tune_time = k_uptime_get();
set_pwm_group(group, 0);
return 0;
}

// keep 0 duty when first enabling auto tune
static bool is_init = false;
if (!is_init) {
is_init = true;
return 0;
}

Expand Down
24 changes: 24 additions & 0 deletions meta-facebook/aalc-rpu/src/platform/plat_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,30 @@ const err_sensor_mapping sensor_err_codes[] = {
{ HIGH_PRESS_DETECTED, SENSOR_NUM_BPB_RPU_COOLANT_OUTLET_P_KPA },
{ FLOW_RATE_SENSOR_TRIGGERED, SENSOR_NUM_BPB_RPU_COOLANT_FLOW_RATE_LPM },
{ EMERGENCY_BUTTON_TRIGGERED, SENSOR_NUM_EMERGENCY_BUTTON_TRIGGERED },
{ LOG_ERR_HEX_EXTERNAL_Y_FILTER, SENSOR_NUM_HEX_EXTERNAL_Y_FILTER },
{ LOG_ERR_BPB_RPU_COOLANT_INLET_P_KPA, SENSOR_NUM_BPB_RPU_COOLANT_INLET_P_KPA },
{ LOG_ERR_BPB_RACK_PRESSURE_3_P_KPA, SENSOR_NUM_BPB_RACK_PRESSURE_3_P_KPA },
{ LOG_ERR_BPB_RACK_PRESSURE_4_P_KPA, SENSOR_NUM_BPB_RACK_PRESSURE_4_P_KPA },
{ LOG_ERR_SB_HEX_PRESSURE_1_P_KPA, SENSOR_NUM_SB_HEX_PRESSURE_1_P_KPA },
{ LOG_ERR_SB_HEX_PRESSURE_2_P_KPA, SENSOR_NUM_SB_HEX_PRESSURE_2_P_KPA },
{ LOG_ERR_BPB_RPU_COOLANT_INLET_TEMP_C, SENSOR_NUM_BPB_RPU_COOLANT_INLET_TEMP_C },
{ LOG_ERR_BPB_RPU_COOLANT_OUTLET_TEMP_C, SENSOR_NUM_BPB_RPU_COOLANT_OUTLET_TEMP_C },
{ LOG_ERR_BPB_HEX_WATER_INLET_TEMP_C, SENSOR_NUM_BPB_HEX_WATER_INLET_TEMP_C },
{ LOG_ERR_SB_HEX_AIR_INLET_AVG_TEMP_C, SENSOR_NUM_SB_HEX_AIR_INLET_AVG_TEMP_C },
{ LOG_ERR_FB_1_FAN_TACH_RPM, SENSOR_NUM_FB_1_FAN_TACH_RPM },
{ LOG_ERR_FB_2_FAN_TACH_RPM, SENSOR_NUM_FB_2_FAN_TACH_RPM },
{ LOG_ERR_FB_3_FAN_TACH_RPM, SENSOR_NUM_FB_3_FAN_TACH_RPM },
{ LOG_ERR_FB_4_FAN_TACH_RPM, SENSOR_NUM_FB_4_FAN_TACH_RPM },
{ LOG_ERR_FB_5_FAN_TACH_RPM, SENSOR_NUM_FB_5_FAN_TACH_RPM },
{ LOG_ERR_FB_6_FAN_TACH_RPM, SENSOR_NUM_FB_6_FAN_TACH_RPM },
{ LOG_ERR_FB_7_FAN_TACH_RPM, SENSOR_NUM_FB_7_FAN_TACH_RPM },
{ LOG_ERR_FB_8_FAN_TACH_RPM, SENSOR_NUM_FB_8_FAN_TACH_RPM },
{ LOG_ERR_FB_9_FAN_TACH_RPM, SENSOR_NUM_FB_9_FAN_TACH_RPM },
{ LOG_ERR_FB_10_FAN_TACH_RPM, SENSOR_NUM_FB_10_FAN_TACH_RPM },
{ LOG_ERR_FB_11_FAN_TACH_RPM, SENSOR_NUM_FB_11_FAN_TACH_RPM },
{ LOG_ERR_FB_12_FAN_TACH_RPM, SENSOR_NUM_FB_12_FAN_TACH_RPM },
{ LOG_ERR_FB_13_FAN_TACH_RPM, SENSOR_NUM_FB_13_FAN_TACH_RPM },
{ LOG_ERR_FB_14_FAN_TACH_RPM, SENSOR_NUM_FB_14_FAN_TACH_RPM },
};

const err_sensor_mapping sensor_normal_codes[] = {
Expand Down
24 changes: 24 additions & 0 deletions meta-facebook/aalc-rpu/src/platform/plat_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@ enum LOG_ERROR_CODE {
HIGH_PRESS_DETECTED = 0xA0,
FLOW_RATE_SENSOR_TRIGGERED = 0xA1,
EMERGENCY_BUTTON_TRIGGERED = 0xA2,
LOG_ERR_HEX_EXTERNAL_Y_FILTER = 0xA3,
LOG_ERR_BPB_RPU_COOLANT_INLET_P_KPA = 0xA4,
LOG_ERR_BPB_RACK_PRESSURE_3_P_KPA = 0xA5,
LOG_ERR_BPB_RACK_PRESSURE_4_P_KPA = 0xA6,
LOG_ERR_SB_HEX_PRESSURE_1_P_KPA = 0xA7,
LOG_ERR_SB_HEX_PRESSURE_2_P_KPA = 0xA8,
LOG_ERR_BPB_RPU_COOLANT_INLET_TEMP_C = 0xA9,
LOG_ERR_BPB_RPU_COOLANT_OUTLET_TEMP_C = 0xAA,
LOG_ERR_BPB_HEX_WATER_INLET_TEMP_C = 0xAB,
LOG_ERR_SB_HEX_AIR_INLET_AVG_TEMP_C = 0xAC,
LOG_ERR_FB_1_FAN_TACH_RPM = 0xAD,
LOG_ERR_FB_2_FAN_TACH_RPM = 0xAE,
LOG_ERR_FB_3_FAN_TACH_RPM = 0xAF,
LOG_ERR_FB_4_FAN_TACH_RPM = 0xB0,
LOG_ERR_FB_5_FAN_TACH_RPM = 0xB1,
LOG_ERR_FB_6_FAN_TACH_RPM = 0xB2,
LOG_ERR_FB_7_FAN_TACH_RPM = 0xB3,
LOG_ERR_FB_8_FAN_TACH_RPM = 0xB4,
LOG_ERR_FB_9_FAN_TACH_RPM = 0xB5,
LOG_ERR_FB_10_FAN_TACH_RPM = 0xB6,
LOG_ERR_FB_11_FAN_TACH_RPM = 0xB7,
LOG_ERR_FB_12_FAN_TACH_RPM = 0xB8,
LOG_ERR_FB_13_FAN_TACH_RPM = 0xB9,
LOG_ERR_FB_14_FAN_TACH_RPM = 0xBA,
};

typedef struct _err_sensor_mapping {
Expand Down
56 changes: 19 additions & 37 deletions meta-facebook/aalc-rpu/src/platform/plat_modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,18 @@ uint8_t modbus_get_senser_reading(modbus_command_mapping *cmd)

if (status == SENSOR_READ_4BYTE_ACUR_SUCCESS) {
float r = pow_of_10(cmd->arg2);
int16_t byte_val = val / cmd->arg1 / r; // scale
int16_t byte_val = 0;
// capacity scale kW to W
if (cmd->addr == MODBUS_AALC_COOLING_CAPACITY_W_ADDR) {
int32_t scaled_val = (int32_t)(val * 1000 / cmd->arg1 / r);
byte_val = scaled_val & 0xFFFF;
} else if (cmd->addr == MODBUS_AALC_COOLING_CAPACITY_W_EXT_ADDR) {
int32_t scaled_val = (int32_t)(val * 1000 / cmd->arg1 / r);
byte_val = (scaled_val >> 16) & 0xFFFF;
} else {
byte_val = val / cmd->arg1 / r; // scale
}

memcpy(cmd->data, &byte_val, sizeof(uint16_t) * cmd->cmd_size);
return MODBUS_EXC_NONE;
}
Expand Down Expand Up @@ -458,39 +469,6 @@ uint8_t modbus_get_sticky_sensor_status(modbus_command_mapping *cmd)
return MODBUS_EXC_NONE;
}

uint8_t modbus_get_aalc_cooling_capacity(modbus_command_mapping *cmd)
{
CHECK_NULL_ARG_WITH_RETURN(cmd, MODBUS_EXC_ILLEGAL_DATA_VAL);
/*
* AALC_Cooling_Capacity_W = 67.21*Flow rate*(Tout-Tin)
* Flow Rate = Flow sensor reading (LPM)
* Tout = Rack Coolant temperature sensor reading (°C)
* Tin = RPU Coolant outlet temperature sensor reading(°C)
*/

float flow_rate_val, tout_val, tin_val;

uint8_t flow_rate_status = get_sensor_reading_to_real_val(
SENSOR_NUM_BPB_RPU_COOLANT_FLOW_RATE_LPM, &flow_rate_val);
uint8_t tout_status =
get_sensor_reading_to_real_val(SENSOR_NUM_BPB_HEX_WATER_INLET_TEMP_C, &tout_val);
uint8_t tin_status =
get_sensor_reading_to_real_val(SENSOR_NUM_BPB_RPU_COOLANT_INLET_TEMP_C, &tin_val);

if (flow_rate_status != SENSOR_READ_4BYTE_ACUR_SUCCESS)
return MODBUS_EXC_ILLEGAL_DATA_VAL;

if (tout_status != SENSOR_READ_4BYTE_ACUR_SUCCESS)
return MODBUS_EXC_ILLEGAL_DATA_VAL;

if (tin_status != SENSOR_READ_4BYTE_ACUR_SUCCESS)
return MODBUS_EXC_ILLEGAL_DATA_VAL;

cmd->data[0] = (uint16_t)(67.21 * flow_rate_val * (tout_val - tin_val));

return MODBUS_EXC_NONE;
}

uint8_t modbus_get_manual_flag(modbus_command_mapping *cmd)
{
CHECK_NULL_ARG_WITH_RETURN(cmd, MODBUS_EXC_ILLEGAL_DATA_VAL);
Expand Down Expand Up @@ -713,8 +691,10 @@ modbus_command_mapping modbus_command_table[] = {
SENSOR_NUM_MB_FAN1_TACH_RPM, 1, 0, 1 },
{ MODBUS_MB_FAN2_TACH_RPM_ADDR, NULL, modbus_get_senser_reading,
SENSOR_NUM_MB_FAN2_TACH_RPM, 1, 0, 1 },
{ MODBUS_AALC_COOLING_CAPACITY_W_ADDR, NULL, modbus_get_aalc_cooling_capacity, 0, 1, -1,
1 },
{ MODBUS_AALC_COOLING_CAPACITY_W_ADDR, NULL, modbus_get_senser_reading,
SENSOR_NUM_COOLING_CAPACITY, 1, -1, 1 },
{ MODBUS_AALC_COOLING_CAPACITY_W_EXT_ADDR, NULL, modbus_get_senser_reading,
SENSOR_NUM_COOLING_CAPACITY, 1, -1, 1 },
{ MODBUS_RPU_PUMP1_STATUS_ADDR, NULL, modbus_get_aalc_sensor_status, RPU_PUMP1_STATUS, 0, 0,
1 },
{ MODBUS_RPU_PUMP2_STATUS_ADDR, NULL, modbus_get_aalc_sensor_status, RPU_PUMP2_STATUS, 0, 0,
Expand Down Expand Up @@ -803,6 +783,8 @@ modbus_command_mapping modbus_command_table[] = {
SENSOR_NUM_BPB_RACK_LEVEL_1, 1, 0, 1 },
{ MODBUS_BPB_RACK_LEVEL_2_ADDR, NULL, modbus_get_senser_reading,
SENSOR_NUM_BPB_RACK_LEVEL_2, 1, 0, 1 },
{ MODBUS_BPB_RACK_LEVEL_3_ADDR, NULL, modbus_get_senser_reading,
SENSOR_NUM_BPB_RACK_LEVEL_3, 1, 0, 1 },
{ MODBUS_MB_HUM_PCT_RH_ADDR, NULL, modbus_get_senser_reading, SENSOR_NUM_MB_HUM_PCT_RH, 1,
0, 1 },
{ MODBUS_PDB_HUM_PCT_RH_ADDR, NULL, modbus_get_senser_reading, SENSOR_NUM_PDB_HUM_PCT_RH, 1,
Expand Down Expand Up @@ -1242,7 +1224,7 @@ modbus_command_mapping modbus_command_table[] = {
{ MODBUS_HEAT_EXCHANGER_FAN_CONTROL_BOX_FBPN_ADDR, NULL, NULL, 0, 0, 0, 4 },
};

static modbus_command_mapping *ptr_to_modbus_table(uint16_t addr)
modbus_command_mapping *ptr_to_modbus_table(uint16_t addr)
{
for (uint16_t i = 0; i < ARRAY_SIZE(modbus_command_table); i++) {
if ((addr >= modbus_command_table[i].addr) &&
Expand Down
4 changes: 4 additions & 0 deletions meta-facebook/aalc-rpu/src/platform/plat_modbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ enum read_fru_data_type {
#define MODBUS_V_3_3_AUX_ADDR 0xA030
#define MODBUS_V_1_2_AUX_ADDR 0xA031
#define MODBUS_V_5_USB_ADDR 0xA032
#define MODBUS_BPB_RACK_LEVEL_3_ADDR 0xA033
#define MODBUS_AALC_COOLING_CAPACITY_W_EXT_ADDR 0xA034
#define MODBUS_MODBUS_ADDR_PATH_WITH_WEDGE400_ADDR 0xA401
#define MODBUS_MANUAL_CONTROL_RPU_FAN_ON_OFF_ADDR 0xA480
#define MODBUS_ERROR_LOG_COUNT_ADDR 0x1A28
Expand Down Expand Up @@ -388,4 +390,6 @@ enum read_fru_data_type {

#define MODBUS_test_for_write_uptime_ADDR 0x1A0C

modbus_command_mapping *ptr_to_modbus_table(uint16_t addr);

#endif
10 changes: 10 additions & 0 deletions meta-facebook/aalc-rpu/src/platform/plat_sdr_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -10613,6 +10613,16 @@ SDR_Full_sensor plat_sdr_table[] = {
.sensor_num = SENSOR_NUM_SB_HEX_AIR_INLET_AVG_TEMP_C,
.ID_str = "SB_HEX_AIR_INLET_AVG_TEMP_C",
},
// SENSOR_NUM_COOLING_CAPACITY
{
.sensor_num = SENSOR_NUM_COOLING_CAPACITY,
.ID_str = "COOLING_CAPACITY",
},
// SENSOR_NUM_BPB_RACK_LEVEL_3
{
.sensor_num = SENSOR_NUM_BPB_RACK_LEVEL_3,
.ID_str = "BPB_RACK_LEVEL_3",
},
};

const int SDR_TABLE_SIZE = ARRAY_SIZE(plat_sdr_table);
Loading

0 comments on commit ddf9fc9

Please sign in to comment.