aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c')
-rw-r--r--src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c154
1 files changed, 81 insertions, 73 deletions
diff --git a/src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c b/src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c
index 042fc875..9d2dfecf 100644
--- a/src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c
+++ b/src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c
@@ -22,19 +22,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
+#include <inttypes.h>
#include "misc/lc15bts_mgr.h"
#include "misc/lc15bts_misc.h"
#include "misc/lc15bts_temp.h"
#include "misc/lc15bts_power.h"
+#include "misc/lc15bts_led.h"
+#include "limits.h"
#include <osmo-bts/logging.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/utils.h>
+#include <osmocom/core/linuxlist.h>
-static struct lc15bts_mgr_instance *s_mgr;
-static struct osmo_timer_list temp_ctrl_timer;
+struct lc15bts_mgr_instance *s_mgr;
+static struct osmo_timer_list sensor_ctrl_timer;
static const struct value_string state_names[] = {
{ STATE_NORMAL, "NORMAL" },
@@ -44,12 +47,12 @@ static const struct value_string state_names[] = {
{ 0, NULL }
};
-const char *lc15bts_mgr_temp_get_state(enum lc15bts_temp_state state)
+const char *lc15bts_mgr_sensor_get_state(enum lc15bts_sensor_state state)
{
return get_value_string(state_names, state);
}
-static int next_state(enum lc15bts_temp_state current_state, int critical, int warning)
+static int next_state(enum lc15bts_sensor_state current_state, int critical, int warning)
{
int next_state = -1;
switch (current_state) {
@@ -85,7 +88,7 @@ static int next_state(enum lc15bts_temp_state current_state, int critical, int w
static void handle_normal_actions(int actions)
{
/* switch on the PA */
- if (actions & TEMP_ACT_NORM_PA0_ON) {
+ if (actions & SENSOR_ACT_NORM_PA0_ON) {
if (lc15bts_power_set(LC15BTS_POWER_PA0, 1) != 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to switch on the PA #0\n");
@@ -95,7 +98,7 @@ static void handle_normal_actions(int actions)
}
}
- if (actions & TEMP_ACT_NORM_PA1_ON) {
+ if (actions & SENSOR_ACT_NORM_PA1_ON) {
if (lc15bts_power_set(LC15BTS_POWER_PA1, 1) != 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to switch on the PA #1\n");
@@ -105,7 +108,7 @@ static void handle_normal_actions(int actions)
}
}
- if (actions & TEMP_ACT_NORM_BTS_SRV_ON) {
+ if (actions & SENSOR_ACT_NORM_BTS_SRV_ON) {
LOGP(DTEMP, LOGL_NOTICE,
"Going to switch on the BTS service\n");
/*
@@ -120,7 +123,7 @@ static void handle_normal_actions(int actions)
static void handle_actions(int actions)
{
/* switch off the PA */
- if (actions & TEMP_ACT_PA1_OFF) {
+ if (actions & SENSOR_ACT_PA1_OFF) {
if (lc15bts_power_set(LC15BTS_POWER_PA1, 0) != 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to switch off the PA #1. Stop BTS?\n");
@@ -130,7 +133,7 @@ static void handle_actions(int actions)
}
}
- if (actions & TEMP_ACT_PA0_OFF) {
+ if (actions & SENSOR_ACT_PA0_OFF) {
if (lc15bts_power_set(LC15BTS_POWER_PA0, 0) != 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to switch off the PA #0. Stop BTS?\n");
@@ -140,7 +143,7 @@ static void handle_actions(int actions)
}
}
- if (actions & TEMP_ACT_BTS_SRV_OFF) {
+ if (actions & SENSOR_ACT_BTS_SRV_OFF) {
LOGP(DTEMP, LOGL_NOTICE,
"Going to switch off the BTS service\n");
/*
@@ -161,36 +164,36 @@ static void handle_actions(int actions)
*/
static void execute_normal_act(struct lc15bts_mgr_instance *manager)
{
- LOGP(DTEMP, LOGL_NOTICE, "System is back to normal temperature.\n");
- handle_normal_actions(manager->temp.action_norm);
+ LOGP(DTEMP, LOGL_NOTICE, "System is back to normal state.\n");
+ handle_normal_actions(manager->state.action_norm);
}
static void execute_warning_act(struct lc15bts_mgr_instance *manager)
{
- LOGP(DTEMP, LOGL_NOTICE, "System has reached temperature warning.\n");
- handle_actions(manager->temp.action_warn);
+ LOGP(DTEMP, LOGL_NOTICE, "System has reached warning state.\n");
+ handle_actions(manager->state.action_warn);
}
static void execute_critical_act(struct lc15bts_mgr_instance *manager)
{
LOGP(DTEMP, LOGL_NOTICE, "System has reached critical warning.\n");
- handle_actions(manager->temp.action_crit);
+ handle_actions(manager->state.action_crit);
}
-static void lc15bts_mgr_temp_handle(struct lc15bts_mgr_instance *manager,
+static void lc15bts_mgr_sensor_handle(struct lc15bts_mgr_instance *manager,
int critical, int warning)
{
- int new_state = next_state(manager->temp.state, critical, warning);
+ int new_state = next_state(manager->state.state, critical, warning);
/* Nothing changed */
if (new_state < 0)
return;
LOGP(DTEMP, LOGL_NOTICE, "Moving from state %s to %s.\n",
- get_value_string(state_names, manager->temp.state),
+ get_value_string(state_names, manager->state.state),
get_value_string(state_names, new_state));
- manager->temp.state = new_state;
- switch (manager->temp.state) {
+ manager->state.state = new_state;
+ switch (manager->state.state) {
case STATE_NORMAL:
execute_normal_act(manager);
break;
@@ -206,163 +209,168 @@ static void lc15bts_mgr_temp_handle(struct lc15bts_mgr_instance *manager,
};
}
-static void temp_ctrl_check()
+static void sensor_ctrl_check(struct lc15bts_mgr_instance *mgr)
{
int rc;
+ int temp = 0;
int warn_thresh_passed = 0;
int crit_thresh_passed = 0;
LOGP(DTEMP, LOGL_DEBUG, "Going to check the temperature.\n");
/* Read the current supply temperature */
- rc = lc15bts_temp_get(LC15BTS_TEMP_SUPPLY);
+ rc = lc15bts_temp_get(LC15BTS_TEMP_SUPPLY, &temp);
if (rc < 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to read the supply temperature. rc=%d\n", rc);
warn_thresh_passed = crit_thresh_passed = 1;
} else {
- int temp = rc / 1000;
- if (temp > s_mgr->temp.supply_limit.thresh_warn)
+ temp = temp / 1000;
+ if (temp > mgr->temp.supply_temp_limit.thresh_warn_max)
warn_thresh_passed = 1;
- if (temp > s_mgr->temp.supply_limit.thresh_crit)
+ if (temp > mgr->temp.supply_temp_limit.thresh_crit_max)
crit_thresh_passed = 1;
LOGP(DTEMP, LOGL_DEBUG, "Supply temperature is: %d\n", temp);
}
/* Read the current SoC temperature */
- rc = lc15bts_temp_get(LC15BTS_TEMP_SOC);
+ rc = lc15bts_temp_get(LC15BTS_TEMP_SOC, &temp);
if (rc < 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to read the SoC temperature. rc=%d\n", rc);
warn_thresh_passed = crit_thresh_passed = 1;
} else {
- int temp = rc / 1000;
- if (temp > s_mgr->temp.soc_limit.thresh_warn)
+ temp = temp / 1000;
+ if (temp > mgr->temp.soc_temp_limit.thresh_warn_max)
warn_thresh_passed = 1;
- if (temp > s_mgr->temp.soc_limit.thresh_crit)
+ if (temp > mgr->temp.soc_temp_limit.thresh_crit_max)
crit_thresh_passed = 1;
LOGP(DTEMP, LOGL_DEBUG, "SoC temperature is: %d\n", temp);
}
/* Read the current fpga temperature */
- rc = lc15bts_temp_get(LC15BTS_TEMP_FPGA);
+ rc = lc15bts_temp_get(LC15BTS_TEMP_FPGA, &temp);
if (rc < 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to read the fpga temperature. rc=%d\n", rc);
warn_thresh_passed = crit_thresh_passed = 1;
} else {
- int temp = rc / 1000;
- if (temp > s_mgr->temp.fpga_limit.thresh_warn)
+ temp = temp / 1000;
+ if (temp > mgr->temp.fpga_temp_limit.thresh_warn_max)
warn_thresh_passed = 1;
- if (temp > s_mgr->temp.fpga_limit.thresh_crit)
+ if (temp > mgr->temp.fpga_temp_limit.thresh_crit_max)
crit_thresh_passed = 1;
LOGP(DTEMP, LOGL_DEBUG, "FPGA temperature is: %d\n", temp);
}
- /* Read the current RF log detector temperature */
- rc = lc15bts_temp_get(LC15BTS_TEMP_LOGRF);
+ /* Read the current RMS detector temperature */
+ rc = lc15bts_temp_get(LC15BTS_TEMP_RMSDET, &temp);
if (rc < 0) {
LOGP(DTEMP, LOGL_ERROR,
- "Failed to read the RF log detector temperature. rc=%d\n", rc);
+ "Failed to read the RMS detector temperature. rc=%d\n", rc);
warn_thresh_passed = crit_thresh_passed = 1;
} else {
- int temp = rc / 1000;
- if (temp > s_mgr->temp.logrf_limit.thresh_warn)
+ temp = temp / 1000;
+ if (temp > mgr->temp.rmsdet_temp_limit.thresh_warn_max)
warn_thresh_passed = 1;
- if (temp > s_mgr->temp.logrf_limit.thresh_crit)
+ if (temp > mgr->temp.rmsdet_temp_limit.thresh_crit_max)
crit_thresh_passed = 1;
- LOGP(DTEMP, LOGL_DEBUG, "RF log detector temperature is: %d\n", temp);
+ LOGP(DTEMP, LOGL_DEBUG, "RMS detector temperature is: %d\n", temp);
}
/* Read the current OCXO temperature */
- rc = lc15bts_temp_get(LC15BTS_TEMP_OCXO);
+ rc = lc15bts_temp_get(LC15BTS_TEMP_OCXO, &temp);
if (rc < 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to read the OCXO temperature. rc=%d\n", rc);
warn_thresh_passed = crit_thresh_passed = 1;
} else {
- int temp = rc / 1000;
- if (temp > s_mgr->temp.ocxo_limit.thresh_warn)
+ temp = temp / 1000;
+ if (temp > mgr->temp.ocxo_temp_limit.thresh_warn_max)
warn_thresh_passed = 1;
- if (temp > s_mgr->temp.ocxo_limit.thresh_crit)
+ if (temp > mgr->temp.ocxo_temp_limit.thresh_crit_max)
crit_thresh_passed = 1;
LOGP(DTEMP, LOGL_DEBUG, "OCXO temperature is: %d\n", temp);
}
- /* Read the current TX #1 temperature */
- rc = lc15bts_temp_get(LC15BTS_TEMP_TX0);
+ /* Read the current TX #0 temperature */
+ rc = lc15bts_temp_get(LC15BTS_TEMP_TX0, &temp);
if (rc < 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to read the TX #0 temperature. rc=%d\n", rc);
warn_thresh_passed = crit_thresh_passed = 1;
} else {
- int temp = rc / 1000;
- if (temp > s_mgr->temp.tx0_limit.thresh_warn)
+ temp = temp / 1000;
+ if (temp > mgr->temp.tx0_temp_limit.thresh_warn_max)
warn_thresh_passed = 1;
- if (temp > s_mgr->temp.tx0_limit.thresh_crit)
+ if (temp > mgr->temp.tx0_temp_limit.thresh_crit_max)
crit_thresh_passed = 1;
LOGP(DTEMP, LOGL_DEBUG, "TX #0 temperature is: %d\n", temp);
}
- /* Read the current TX #2 temperature */
- rc = lc15bts_temp_get(LC15BTS_TEMP_TX1);
+ /* Read the current TX #1 temperature */
+ rc = lc15bts_temp_get(LC15BTS_TEMP_TX1, &temp);
if (rc < 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to read the TX #1 temperature. rc=%d\n", rc);
warn_thresh_passed = crit_thresh_passed = 1;
} else {
- int temp = rc / 1000;
- if (temp > s_mgr->temp.tx1_limit.thresh_warn)
+ temp = temp / 1000;
+ if (temp > mgr->temp.tx1_temp_limit.thresh_warn_max)
warn_thresh_passed = 1;
- if (temp > s_mgr->temp.tx1_limit.thresh_crit)
+ if (temp > mgr->temp.tx1_temp_limit.thresh_crit_max)
crit_thresh_passed = 1;
LOGP(DTEMP, LOGL_DEBUG, "TX #1 temperature is: %d\n", temp);
}
- /* Read the current PA #1 temperature */
- rc = lc15bts_temp_get(LC15BTS_TEMP_PA0);
+ /* Read the current PA #0 temperature */
+ rc = lc15bts_temp_get(LC15BTS_TEMP_PA0, &temp);
if (rc < 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to read the PA #0 temperature. rc=%d\n", rc);
warn_thresh_passed = crit_thresh_passed = 1;
} else {
- int temp = rc / 1000;
- if (temp > s_mgr->temp.pa0_limit.thresh_warn)
+ temp = temp / 1000;
+ if (temp > mgr->temp.pa0_temp_limit.thresh_warn_max)
warn_thresh_passed = 1;
- if (temp > s_mgr->temp.pa0_limit.thresh_crit)
+ if (temp > mgr->temp.pa0_temp_limit.thresh_crit_max)
crit_thresh_passed = 1;
LOGP(DTEMP, LOGL_DEBUG, "PA #0 temperature is: %d\n", temp);
}
- /* Read the current PA #2 temperature */
- rc = lc15bts_temp_get(LC15BTS_TEMP_PA1);
+ /* Read the current PA #1 temperature */
+ rc = lc15bts_temp_get(LC15BTS_TEMP_PA1, &temp);
if (rc < 0) {
LOGP(DTEMP, LOGL_ERROR,
"Failed to read the PA #1 temperature. rc=%d\n", rc);
warn_thresh_passed = crit_thresh_passed = 1;
} else {
- int temp = rc / 1000;
- if (temp > s_mgr->temp.pa1_limit.thresh_warn)
+ temp = temp / 1000;
+ if (temp > mgr->temp.pa1_temp_limit.thresh_warn_max)
warn_thresh_passed = 1;
- if (temp > s_mgr->temp.pa1_limit.thresh_crit)
+ if (temp > mgr->temp.pa1_temp_limit.thresh_crit_max)
crit_thresh_passed = 1;
LOGP(DTEMP, LOGL_DEBUG, "PA #1 temperature is: %d\n", temp);
}
- lc15bts_mgr_temp_handle(s_mgr, crit_thresh_passed, warn_thresh_passed);
+ lc15bts_mgr_sensor_handle(mgr, crit_thresh_passed, warn_thresh_passed);
}
-static void temp_ctrl_check_cb(void *unused)
+static void sensor_ctrl_check_cb(void *_data)
{
- temp_ctrl_check();
- /* Check every two minutes? XXX make it configurable! */
- osmo_timer_schedule(&temp_ctrl_timer, 2 * 60, 0);
+ struct lc15bts_mgr_instance *mgr = _data;
+ sensor_ctrl_check(mgr);
+ /* Check every minute? XXX make it configurable! */
+ osmo_timer_schedule(&sensor_ctrl_timer, LC15BTS_SENSOR_TIMER_DURATION, 0);
+ LOGP(DTEMP, LOGL_DEBUG,"Check sensors timer expired\n");
+ /* TODO: do we want to notify if some sensors could not be read? */
}
-int lc15bts_mgr_temp_init(struct lc15bts_mgr_instance *mgr)
+int lc15bts_mgr_sensor_init(struct lc15bts_mgr_instance *mgr)
{
s_mgr = mgr;
- temp_ctrl_timer.cb = temp_ctrl_check_cb;
- temp_ctrl_check_cb(NULL);
+ sensor_ctrl_timer.cb = sensor_ctrl_check_cb;
+ sensor_ctrl_timer.data = s_mgr;
+ sensor_ctrl_check_cb(s_mgr);
return 0;
}