From patchwork Tue Apr 8 12:40:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alvaro Neira X-Patchwork-Id: 337648 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D02851400B8 for ; Tue, 8 Apr 2014 22:42:04 +1000 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WXVLb-0004NK-Tp; Tue, 08 Apr 2014 14:41:52 +0200 Received: from mail.sysmocom.de ([144.76.43.93]) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WXVL5-0004H3-I0 for openbsc@lists.osmocom.org; Tue, 08 Apr 2014 14:41:23 +0200 Received: from localhost.localdomain (221.82.78.188.dynamic.jazztel.es [188.78.82.221]) by mail.sysmocom.de (Postfix) with ESMTPA id 1C4BE50B74 for ; Tue, 8 Apr 2014 12:41:19 +0000 (UTC) From: Alvaro Neira Ayuso To: openbsc@lists.osmocom.org Subject: [osmo-bts PATCH 3/3] main: Added support for changing the max_power_red in sbts2050 Date: Tue, 8 Apr 2014 14:40:35 +0200 Message-Id: <1396960835-14662-1-git-send-email-anayuso@sysmocom.de> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-Spam-Score: 0.1 (/) X-Spam-Report: SpamASsassin versoin 3.3.1 on ganesha.gnumonks.org summary: Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.1 TW_SB BODY: Odd Letter Triples with SB X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org From: Álvaro Neira Ayuso Added functions for changing the max_power_red in case of we receive a Failure Event report from the manager. The sbts2050 change the max_power_red to the value that we have configured in the manager and the sbts2050 restore this value to the initial value if the bts don't receive another Failure Event report in the same time that we check the temperature in the manager. Signed-off-by: Alvaro Neira Ayuso --- src/osmo-bts-sysmo/main.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c index 61a5716..b492327 100644 --- a/src/osmo-bts-sysmo/main.c +++ b/src/osmo-bts-sysmo/main.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -55,11 +56,14 @@ #define IPA_HEADER_SIZE 3 #define IPA_OML_PROTO 0xFF +#define TEMP_TIMER_SECS (6 * 3600) + 1 + #include "utils.h" #include "eeprom.h" #include "l1_if.h" #include "hw_misc.h" #include "btsconfig.h" +#include /* FIXME: read from real hardware */ const uint8_t abis_mac[6] = { 0,1,2,3,4,5 }; @@ -297,6 +301,60 @@ static int write_pid_file(char *procname) return 0; } #ifdef BUILD_SBTS2050 +static int init_max_power_red; +static int new_max_power_red; +static int status_change_power_red = 0; + +enum { + SBTS2050_DISABLE_CHANGE_POWER = 0, + SBTS2050_ENABLE_CHANGE_POWER, +}; + +#define oml_tlv_parse(dec, buf, len) \ + tlv_parse(dec, &abis_nm_att_tlvdef, buf, len, 0, 0) + +/* Size of the struct plus 1 Bytes of tag and 2 Bytes for the length */ +#define tlv_add_info_len() (sizeof(struct sbts2050_config_info) + 3) + +static struct osmo_timer_list power_timer; +static void change_max_power_red_cb(void *data) +{ + struct gsm_bts *bts = data; + + if (status_change_power_red == SBTS2050_ENABLE_CHANGE_POWER) { + if (bts->c0->max_power_red != new_max_power_red) { + init_max_power_red = bts->c0->max_power_red; + bts->c0->max_power_red = new_max_power_red; + } + status_change_power_red = SBTS2050_DISABLE_CHANGE_POWER; + osmo_timer_schedule(&power_timer, TEMP_TIMER_SECS, 0); + } else if (status_change_power_red == SBTS2050_DISABLE_CHANGE_POWER) + bts->c0->max_power_red = init_max_power_red; +} + +static int take_max_power_red(struct msgb *msg) +{ + struct sbts2050_config_info *config_info; + struct tlv_parsed tlv_out; + int rc; + + rc = oml_tlv_parse(&tlv_out, msg->tail - tlv_add_info_len(), + tlv_add_info_len()); + + if (rc < 0) + return -1; + + config_info = + (struct sbts2050_config_info *) TLVP_VAL(&tlv_out, NM_ATT_ADD_INFO); + + new_max_power_red = config_info->max_power_red; + + status_change_power_red = SBTS2050_ENABLE_CHANGE_POWER; + change_max_power_red_cb(bts); + + return 0; +} + static int test_recv_msg(struct msgb *msg) { struct ipaccess_head *hh = (struct ipaccess_head *)msg->data; @@ -355,6 +413,11 @@ static int read_sock(struct osmo_fd *fd, unsigned int what) return -1; } + if (take_max_power_red(msg) < 0) { + LOGP(DL1C, LOGL_NOTICE, "Failed Add_info: Malformed message"); + return -1; + } + mo = &bts->mo; msg->trx = mo->bts->c0; @@ -478,6 +541,10 @@ int main(int argc, char **argv) read_fd.fd = -1; accept_fd.data = &read_fd; + init_max_power_red = bts->c0->max_power_red; + power_timer.cb = change_max_power_red_cb; + power_timer.data = bts; + rc = osmo_sock_unix_init_ofd(&accept_fd, SOCK_SEQPACKET, 0, SOCKET_PATH, OSMO_SOCK_F_BIND | OSMO_SOCK_F_NONBLOCK); if (rc < 0) {