Commit a9d63c26 authored by Adam Wujek's avatar Adam Wujek 💬

userspace: move reading of temperature tresholds from hal to snmp

Move reading of temperature sensors' tresholds from hal to snmp. Thresholds
were and still are read from dot-config.

update:
--hal
--hal_shmem header
--snmpd
--wr_mon
--wrs_dump_shmem
--uplift ppsi (update hal_shmem header)
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 41061669
......@@ -107,15 +107,11 @@ struct hal_temp_sensors {
int pll; /* IC18 */
int psl; /* IC20 Power Supply Left (PSL) */
int psr; /* IC17 Power Supply Right (PSR) */
int fpga_thold; /* Threshold value for FPGA temperature */
int pll_thold; /* Threshold value for PLL temperature */
int psl_thold; /* Threshold value for PSL temperature */
int psr_thold; /* Threshold value for PSR temperature */
};
/* This is the overall structure stored in shared memory */
#define HAL_SHMEM_VERSION 6 /* Version 6 because of new structure
* hal_temp_sensors in hal_shmem_header */
#define HAL_SHMEM_VERSION 7 /* Version 7 because of moving of reading
* temperature treshold values to snmpd */
struct hal_shmem_header {
int nports;
struct hal_port_state *ports;
......
ppsi @ 34c57cba
Subproject commit 782773077690f2b2d53af0395e3b94e8fcc89a9d
Subproject commit 34c57cba5b27cec87848ad00c312137f3e69ff17
#include "wrsSnmp.h"
#include "snmp_shmem.h"
#include "wrsTemperatureGroup.h"
#include <libwr/config.h>
static struct pickinfo wrsTemperature_pickinfo[] = {
FIELD(wrsTemperature_s, ASN_INTEGER, temp_fpga),
......@@ -15,12 +16,31 @@ static struct pickinfo wrsTemperature_pickinfo[] = {
struct wrsTemperature_s wrsTemperature_s;
static void get_thresholds(void)
{
char *config_item;
/* check wether config fields exist, atoi has to have valid string */
config_item = libwr_cfg_get("SNMP_TEMP_THOLD_FPGA");
if (config_item)
wrsTemperature_s.temp_fpga_thold = atoi(config_item);
config_item = libwr_cfg_get("SNMP_TEMP_THOLD_PLL");
if (config_item)
wrsTemperature_s.temp_pll_thold = atoi(config_item);
config_item = libwr_cfg_get("SNMP_TEMP_THOLD_PSL");
if (config_item)
wrsTemperature_s.temp_psl_thold = atoi(config_item);
config_item = libwr_cfg_get("SNMP_TEMP_THOLD_PSR");
if (config_item)
wrsTemperature_s.temp_psr_thold = atoi(config_item);
}
time_t wrsTemperature_data_fill(void)
{
unsigned ii;
unsigned retries = 0;
static time_t time_update;
time_t time_cur;
static int first_run = 1;
time_cur = time(NULL);
if (time_update
......@@ -30,7 +50,12 @@ time_t wrsTemperature_data_fill(void)
}
time_update = time_cur;
memset(&wrsTemperature_s, 0, sizeof(wrsTemperature_s));
if (first_run) {
/* load thresholds only once */
get_thresholds();
first_run = 0;
}
while (1) {
ii = wrs_shm_seqbegin(hal_head);
......@@ -38,10 +63,6 @@ time_t wrsTemperature_data_fill(void)
wrsTemperature_s.temp_pll = hal_shmem->temp.pll >> 8;
wrsTemperature_s.temp_psl = hal_shmem->temp.psl >> 8;
wrsTemperature_s.temp_psr = hal_shmem->temp.psr >> 8;
wrsTemperature_s.temp_fpga_thold = hal_shmem->temp.fpga_thold;
wrsTemperature_s.temp_pll_thold = hal_shmem->temp.pll_thold;
wrsTemperature_s.temp_psl_thold = hal_shmem->temp.psl_thold;
wrsTemperature_s.temp_psr_thold = hal_shmem->temp.psr_thold;
retries++;
if (retries > 100) {
......
......@@ -412,21 +412,6 @@ void show_temperatures(void)
term_cprintf(C_GREY, "PSR: ");
term_cprintf(C_WHITE, "%2.2f\n",
temp_sensors_local.psr/256.0);
term_cprintf(C_BLUE, "Temperature thresholds:\n");
term_cprintf(C_GREY, "FPGA: ");
term_cprintf(C_WHITE, "%5d ",
temp_sensors_local.fpga_thold);
term_cprintf(C_GREY, "PLL: ");
term_cprintf(C_WHITE, "%5d ",
temp_sensors_local.pll_thold);
term_cprintf(C_GREY, "PSL: ");
term_cprintf(C_WHITE, "%5d ",
temp_sensors_local.psl_thold);
term_cprintf(C_GREY, "PSR: ");
term_cprintf(C_WHITE, "%5d\n",
temp_sensors_local.psr_thold);
}
}
......
......@@ -240,10 +240,6 @@ struct dump_info hal_shmem_info [] = {
DUMP_FIELD(sensor_temp, temp.pll),
DUMP_FIELD(sensor_temp, temp.psl),
DUMP_FIELD(sensor_temp, temp.psr),
DUMP_FIELD(int, temp.fpga_thold),
DUMP_FIELD(int, temp.pll_thold),
DUMP_FIELD(int, temp.psl_thold),
DUMP_FIELD(int, temp.psr_thold),
};
/* map for fields of hal_port_state (hal_shmem.h) */
......
......@@ -185,7 +185,6 @@ int hal_port_init_all()
{
int index;
struct wrs_shm_head *hal_shmem_hdr;
char *config_item;
pr_info("Initializing switch ports...\n");
......@@ -231,19 +230,6 @@ int hal_port_init_all()
/* We are done, mark things as valid */
hal_shmem->nports = hal_port_nports;
hal_shmem_hdr->version = HAL_SHMEM_VERSION;
/* check wether config fields exist, atoi has to have valid string */
config_item = libwr_cfg_get("SNMP_TEMP_THOLD_FPGA");
if (config_item)
hal_shmem->temp.fpga_thold = atoi(config_item);
config_item = libwr_cfg_get("SNMP_TEMP_THOLD_PLL");
if (config_item)
hal_shmem->temp.pll_thold = atoi(config_item);
config_item = libwr_cfg_get("SNMP_TEMP_THOLD_PSL");
if (config_item)
hal_shmem->temp.psl_thold = atoi(config_item);
config_item = libwr_cfg_get("SNMP_TEMP_THOLD_PSR");
if (config_item)
hal_shmem->temp.psr_thold = atoi(config_item);
/* Release processes waiting for HAL's to fill shm with correct data
When shm is opened successfully data in shm is still not populated!
Read data with wrs_shm_seqbegin and wrs_shm_seqend!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment