From patchwork Tue Apr 15 18:20:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alvaro Neira X-Patchwork-Id: 339352 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [213.95.27.120]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AA350140089 for ; Wed, 16 Apr 2014 04:21:06 +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 1Wa7ya-0001QD-31; Tue, 15 Apr 2014 20:20:56 +0200 Received: from mail.sysmocom.de ([144.76.43.93]) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1Wa7yE-0001KX-W6 for openbsc@lists.osmocom.org; Tue, 15 Apr 2014 20:20:38 +0200 Received: from localhost.localdomain (tmo-107-36.customers.d1-online.com [80.187.107.36]) by mail.sysmocom.de (Postfix) with ESMTPA id 34F2252E80 for ; Tue, 15 Apr 2014 18:20:34 +0000 (UTC) From: Alvaro Neira Ayuso To: openbsc@lists.osmocom.org Subject: [osmo-bts PATCH 3/3 v5] main: Added support for changing the max_power_red in sbts2050 Date: Tue, 15 Apr 2014 20:20:03 +0200 Message-Id: <1397586003-16077-1-git-send-email-anayuso@sysmocom.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1397395595-14818-1-git-send-email-anayuso@sysmocom.de> References: <1397395595-14818-1-git-send-email-anayuso@sysmocom.de> MIME-Version: 1.0 X-Spam-Score: 0.2 (/) X-Spam-Report: SpamASsassin versoin 3.3.1 on ganesha.gnumonks.org summary: Content analysis details: (0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.1 TW_TR BODY: Odd Letter Triples with TR 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 --- [changed in v5] * Added the function for updating the power transmitter * Changed the transmitter reduce power for using a relative value and not a absolute value. src/osmo-bts-sysmo/main.c | 79 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c index 11e1878..3f2a20d 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 @@ -53,11 +54,14 @@ #define SYSMOBTS_RF_LOCK_PATH "/var/lock/bts_rf_lock" +#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 }; @@ -295,6 +299,73 @@ static int write_pid_file(char *procname) return 0; } +static int reduce_max_power; +static int status_change_power_red; + +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) + +/********************************************************************** + * Function for change the transmitter power + *********************************************************************/ +static void update_transmiter_power(struct gsm_bts_trx *trx, int reduce_power) +{ + struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); + int power_transmitter = trx->nominal_power - trx->max_power_red; + + if (fl1h->hLayer1) + l1if_set_txpower(fl1h, power_transmitter - reduce_power); +} + +static struct osmo_timer_list power_timer; +static void change_transmitter_power_cb(void *data) +{ + struct gsm_bts *bts = data; + struct gsm_bts_trx *trx = bts->c0; + + if (status_change_power_red == SBTS2050_ENABLE_CHANGE_POWER) { + update_transmiter_power(trx, reduce_max_power); + 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) + update_transmiter_power(trx, 0); +} + +/********************************************************************** + * Function for take the power that we have configured for + * reduce the transmitter power + *********************************************************************/ +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); + + reduce_max_power = config_info->reduce_max_power; + + status_change_power_red = SBTS2050_ENABLE_CHANGE_POWER; + change_transmitter_power_cb(bts); + + return 0; +} + /********************************************************************** * Function for checking that the OML msg received is well-formed *********************************************************************/ @@ -405,6 +476,11 @@ static int read_sock(struct osmo_fd *fd, unsigned int what) goto err; } + if (take_max_power_red(msg) < 0) { + LOGP(DL1C, LOGL_ERROR, "Add_info Malformed message\n"); + goto err; + } + mo = &bts->mo; msg->trx = mo->bts->c0; @@ -459,6 +535,9 @@ static int oml_sock_unix_init(struct osmo_fd *accept, struct osmo_fd *read) read->fd = -1; accept->data = read; + power_timer.cb = change_transmitter_power_cb; + power_timer.data = bts; + rc = osmo_sock_unix_init_ofd(accept, SOCK_SEQPACKET, 0, SOCKET_PATH, OSMO_SOCK_F_BIND | OSMO_SOCK_F_NONBLOCK); return rc;