diff options
-rw-r--r-- | include/osmocom/bsc/Makefile.am | 1 | ||||
-rw-r--r-- | include/osmocom/bsc/acc_ramp.h | 149 | ||||
-rw-r--r-- | include/osmocom/bsc/gsm_data.h | 5 | ||||
-rw-r--r-- | src/libbsc/Makefile.am | 1 | ||||
-rw-r--r-- | src/libbsc/acc_ramp.c | 235 | ||||
-rw-r--r-- | src/libbsc/bsc_init.c | 15 | ||||
-rw-r--r-- | src/libbsc/bsc_vty.c | 113 | ||||
-rw-r--r-- | src/libbsc/chan_alloc.c | 5 | ||||
-rw-r--r-- | src/libbsc/gsm_data.c | 1 | ||||
-rw-r--r-- | src/libbsc/system_information.c | 11 |
10 files changed, 533 insertions, 3 deletions
diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am index a5d7d18f0..17e8bd313 100644 --- a/include/osmocom/bsc/Makefile.am +++ b/include/osmocom/bsc/Makefile.am @@ -3,6 +3,7 @@ noinst_HEADERS = \ abis_nm.h \ abis_om2000.h \ abis_rsl.h \ + acc_ramp.h \ arfcn_range_encode.h \ bsc_msc.h \ bsc_msg_filter.h \ diff --git a/include/osmocom/bsc/acc_ramp.h b/include/osmocom/bsc/acc_ramp.h new file mode 100644 index 000000000..cb063bf53 --- /dev/null +++ b/include/osmocom/bsc/acc_ramp.h @@ -0,0 +1,149 @@ +/* (C) 2018 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> + * + * Author: Stefan Sperling <ssperling@sysmocom.de> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include <stdbool.h> +#include <stdint.h> + +#include <osmocom/core/timer.h> +#include <osmocom/gsm/protocol/gsm_04_08.h> + +/*! + * Access control class (ACC) ramping is used to slowly make the cell available to + * an increasing number of MS. This avoids overload at startup time in cases where + * a lot of MS would discover the new cell and try to connect to it all at once. + */ + +#define ACC_RAMP_STEP_SIZE_MIN 1 /* allow at most 1 new ACC per ramp step */ +#define ACC_RAMP_STEP_SIZE_DEFAULT ACC_RAMP_STEP_SIZE_MIN +#define ACC_RAMP_STEP_SIZE_MAX 10 /* allow all ACC in one step (effectively disables ramping) */ + +#define ACC_RAMP_STEP_INTERVAL_MIN 30 /* 30 seconds */ +#define ACC_RAMP_STEP_INTERVAL_MAX 600 /* 10 minutes */ + +/*! + * Data structure used to manage ACC ramping. Please avoid setting or reading fields + * in this structure directly. Use the accessor functions below instead. + */ +struct acc_ramp { + struct gsm_bts *bts; /*!< backpointer to BTS using this ACC ramp */ + + bool acc_ramping_enabled; /*!< whether ACC ramping is enabled */ + + /*! + * Bitmask which keeps track of access control classes that are currently denied + * access. The function acc_ramp_apply() uses this mask to modulate bits from + * octets 2 and 3 in RACH Control Parameters (see 3GPP 44.018 10.5.2.29). + * Ramping is only concerned with ACCs 0-9. While any of the bits 0-9 is set, + * the corresponding ACC is barred. + * ACCs 11-15 should always be allowed, and ACC 10 denies emergency calls for + * all ACCs from 0-9 inclusive; these ACCs are ignored in this implementation. + */ + uint16_t barred_accs; + + /*! + * This controls the maximum number of ACCs to allow per ramping step (1 - 10). + * The compile-time default value is ACC_RAMP_STEP_SIZE_DEFAULT. + * This value can be changed by VTY configuration. + * A value of ACC_RAMP_STEP_SIZE_MAX effectively disables ramping. + */ + unsigned int step_size; + + /*! + * Ramping step interval in seconds. + * This value depends on the current BTS channel load average, unless + * it has been overriden by VTY configuration. + */ + unsigned int step_interval_sec; + bool step_interval_is_fixed; + struct osmo_timer_list step_timer; +}; + +/*! + * Return true if ACC ramping is currently enabled, else false. + * \param[in] acc_ramp Pointer to acc_ramp structure. + */ +static inline bool acc_ramp_is_enabled(struct acc_ramp *acc_ramp) +{ + return acc_ramp->acc_ramping_enabled; +} + +/*! + * Return the current ACC ramp step size. + * \param[in] acc_ramp Pointer to acc_ramp structure. + */ +static inline unsigned int acc_ramp_get_step_size(struct acc_ramp *acc_ramp) +{ + return acc_ramp->step_size; +} + +/*! + * Return the current ACC ramp step interval (in seconds) + * \param[in] acc_ramp Pointer to acc_ramp structure. + */ +static inline unsigned int acc_ramp_get_step_interval(struct acc_ramp *acc_ramp) +{ + return acc_ramp->step_interval_sec; +} + +/*! + * If the step interval is dynamic, return true, else return false. + * \param[in] acc_ramp Pointer to acc_ramp structure. + */ +static inline bool acc_ramp_step_interval_is_dynamic(struct acc_ramp *acc_ramp) +{ + return !(acc_ramp->step_interval_is_fixed); +} + +/*! + * Return bitmasks which correspond to access control classes that are currently + * denied access. Ramping is only concerned with those bits which control access + * for ACCs 0-9, and any of the other bits will always be set to zero in these masks, i.e. + * it is safe to OR these bitmasks with the corresponding fields in struct gsm48_rach_control. + * \param[in] acc_ramp Pointer to acc_ramp structure. + */ +static inline uint8_t acc_ramp_get_barred_t2(struct acc_ramp *acc_ramp) +{ + return ((acc_ramp->barred_accs >> 8) & 0x03); +}; +static inline uint8_t acc_ramp_get_barred_t3(struct acc_ramp *acc_ramp) +{ + return (acc_ramp->barred_accs & 0xff); +} + +/*! + * Potentially mark certain Access Control Classes (ACCs) as barred in accordance to ACC ramping. + * \param[in] rach_control RACH control parameters in which barred ACCs will be configured. + * \param[in] acc_ramp Pointer to acc_ramp structure. + */ +static inline void acc_ramp_apply(struct gsm48_rach_control *rach_control, struct acc_ramp *acc_ramp) +{ + rach_control->t2 |= acc_ramp_get_barred_t2(acc_ramp); + rach_control->t3 |= acc_ramp_get_barred_t3(acc_ramp); +} + +void acc_ramp_init(struct acc_ramp *acc_ramp, bool enable, struct gsm_bts *bts); +int acc_ramp_set_step_size(struct acc_ramp *acc_ramp, unsigned int step_size); +int acc_ramp_set_step_interval(struct acc_ramp *acc_ramp, unsigned int step_interval); +void acc_ramp_set_step_interval_dynamic(struct acc_ramp *acc_ramp); +void acc_ramp_start(struct acc_ramp *acc_ramp); +void acc_ramp_abort(struct acc_ramp *acc_ramp); diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 07e54782a..3c65c9c3f 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -26,6 +26,7 @@ #include <osmocom/abis/e1_input.h> #include <osmocom/bsc/meas_rep.h> #include <osmocom/bsc/bsc_msg_filter.h> +#include <osmocom/bsc/acc_ramp.h> struct mgcp_client_conf; struct mgcp_client; @@ -948,6 +949,9 @@ struct gsm_bts { /* do we use static (user-defined) system information messages? (bitmask) */ uint32_t si_mode_static; + /* access control class ramping */ + struct acc_ramp acc_ramp; + /* exclude the BTS from the global RF Lock handling */ int excl_from_rf_lock; @@ -976,6 +980,7 @@ struct gsm_bts { /* Periodic channel load measurements are used to maintain T3122. */ struct load_counter chan_load_samples[7]; int chan_load_samples_idx; + uint8_t chan_load_avg; /* current channel load average in percent (0 - 100). */ }; diff --git a/src/libbsc/Makefile.am b/src/libbsc/Makefile.am index bb1422762..805a7ee1f 100644 --- a/src/libbsc/Makefile.am +++ b/src/libbsc/Makefile.am @@ -26,6 +26,7 @@ libbsc_a_SOURCES = \ abis_om2000_vty.c \ abis_rsl.c \ a_reset.c \ + acc_ramp.c \ bsc_rll.c \ bsc_subscriber.c \ paging.c \ diff --git a/src/libbsc/acc_ramp.c b/src/libbsc/acc_ramp.c new file mode 100644 index 000000000..7cace4bf9 --- /dev/null +++ b/src/libbsc/acc_ramp.c @@ -0,0 +1,235 @@ +/* (C) 2018 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> + * + * Author: Stefan Sperling <ssperling@sysmocom.de> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <strings.h> +#include <errno.h> +#include <stdbool.h> + +#include <osmocom/bsc/debug.h> +#include <osmocom/bsc/acc_ramp.h> +#include <osmocom/bsc/gsm_data.h> + +/* + * Check if an ACC has been permanently barred for a BTS, + * e.g. with the 'rach access-control-class' VTY command. + */ +static bool acc_is_enabled(struct gsm_bts *bts, unsigned int acc) +{ + OSMO_ASSERT(acc >= 0 && acc <= 9); + if (acc == 8 || acc == 9) + return (bts->si_common.rach_control.t2 & (1 << (acc - 8))) == 0; + return (bts->si_common.rach_control.t3 & (1 << (acc))) == 0; +} + +static void allow_one_acc(struct acc_ramp *acc_ramp, unsigned int acc) +{ + OSMO_ASSERT(acc >= 0 && acc <= 9); + LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: allowing Access Control Class %u\n", acc_ramp->bts->nr, acc); + acc_ramp->barred_accs &= ~(1 << acc); +} + +static void barr_one_acc(struct acc_ramp *acc_ramp, unsigned int acc) +{ + OSMO_ASSERT(acc >= 0 && acc <= 9); + LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: barring Access Control Class %u\n", acc_ramp->bts->nr, acc); + acc_ramp->barred_accs |= (1 << acc); +} + +static void barr_all_enabled_accs(struct acc_ramp *acc_ramp) +{ + unsigned int acc; + for (acc = 0; acc < 10; acc++) { + if (acc_is_enabled(acc_ramp->bts, acc)) + barr_one_acc(acc_ramp, acc); + } +} + +static void allow_all_enabled_accs(struct acc_ramp *acc_ramp) +{ + unsigned int acc; + for (acc = 0; acc < 10; acc++) { + if (acc_is_enabled(acc_ramp->bts, acc)) + allow_one_acc(acc_ramp, acc); + } +} + +static unsigned int get_next_step_interval(struct acc_ramp *acc_ramp) +{ + struct gsm_bts *bts = acc_ramp->bts; + uint64_t load; + + if (acc_ramp->step_interval_is_fixed) + return acc_ramp->step_interval_sec; + + /* Scale the step interval to current channel load average. */ + load = (bts->chan_load_avg << 8); /* convert to fixed-point */ + acc_ramp->step_interval_sec = ((load * ACC_RAMP_STEP_INTERVAL_MAX) / 100) >> 8; + if (acc_ramp->step_interval_sec < ACC_RAMP_STEP_SIZE_MIN) + acc_ramp->step_interval_sec = ACC_RAMP_STEP_INTERVAL_MIN; + else if (acc_ramp->step_interval_sec > ACC_RAMP_STEP_INTERVAL_MAX) + acc_ramp->step_interval_sec = ACC_RAMP_STEP_INTERVAL_MAX; + + LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: step interval set to %u seconds based on %u%% channel load average\n", + bts->nr, acc_ramp->step_interval_sec, bts->chan_load_avg); + return acc_ramp->step_interval_sec; +} + +static void do_acc_ramping_step(void *data) +{ + struct acc_ramp *acc_ramp = data; + int i; + + /* Shortcut in case we only do one ramping step. */ + if (acc_ramp->step_size == ACC_RAMP_STEP_SIZE_MAX) { + allow_all_enabled_accs(acc_ramp); + gsm_bts_set_system_infos(acc_ramp->bts); + return; + } + + /* Allow 'step_size' ACCs, starting from ACC0. ACC9 will be allowed last. */ + for (i = 0; i < acc_ramp->step_size; i++) { + int idx = ffs(acc_ramp_get_barred_t3(acc_ramp)); + if (idx > 0) { + /* One of ACC0-ACC7 is still bared. */ + unsigned int acc = idx - 1; + if (acc_is_enabled(acc_ramp->bts, acc)) + allow_one_acc(acc_ramp, acc); + } else { + idx = ffs(acc_ramp_get_barred_t2(acc_ramp)); + if (idx == 1 || idx == 2) { + /* ACC8 or ACC9 is still barred. */ + unsigned int acc = idx - 1 + 8; + if (acc_is_enabled(acc_ramp->bts, acc)) + allow_one_acc(acc_ramp, acc); + } else { + /* All ACCs are now allowed. */ + break; + } + } + } + + gsm_bts_set_system_infos(acc_ramp->bts); + + /* If we have not allowed all ACCs yet, schedule another ramping step. */ + if (acc_ramp_get_barred_t2(acc_ramp) != 0x00 || + acc_ramp_get_barred_t3(acc_ramp) != 0x00) + osmo_timer_schedule(&acc_ramp->step_timer, get_next_step_interval(acc_ramp), 0); +} + +/*! + * Initialize an acc_ramp data structure. + * Storage for this structure must be provided by the caller. + * + * If ACC ramping is enabled, all ACCs are denied by default. + * A subsequent call to acc_ramp_start() will begin the ramping process. + * If ACC ramping is disabled, all ACCs will be allowed by default, + * and there is no need to do anything else. + * + * \param[in] acc_ramp Pointer to acc_ramp structure to be initialized. + * \param[in] enable Indicates whether ACC ramping should be enabled or disabled. + * \param[in] bts BTS which uses this ACC ramp data structure. + */ +void acc_ramp_init(struct acc_ramp *acc_ramp, bool enable, struct gsm_bts *bts) +{ + acc_ramp->bts = bts; + acc_ramp->acc_ramping_enabled = enable; + acc_ramp->step_size = ACC_RAMP_STEP_SIZE_DEFAULT; + acc_ramp->step_interval_sec = ACC_RAMP_STEP_INTERVAL_MIN; + acc_ramp->step_interval_is_fixed = false; + osmo_timer_setup(&acc_ramp->step_timer, do_acc_ramping_step, acc_ramp); + + if (acc_ramp->acc_ramping_enabled) + barr_all_enabled_accs(acc_ramp); + else + allow_all_enabled_accs(acc_ramp); +} + +/*! + * Change the ramping step size which controls how many ACCs will be allowed per ramping step. + * Returns negative on error (step_size out of range), else zero. + * \param[in] acc_ramp Pointer to acc_ramp structure. + * \param[in] step_size The new step size value. + */ +int acc_ramp_set_step_size(struct acc_ramp *acc_ramp, unsigned int step_size) +{ + if (step_size < ACC_RAMP_STEP_SIZE_MIN || step_size > ACC_RAMP_STEP_SIZE_MAX) + return -ERANGE; + + acc_ramp->step_size = step_size; + LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: ramping step size set to %u\n", acc_ramp->bts->nr, step_size); + return 0; +} + +/*! + * Change the ramping step interval to a fixed value. Unless this function is called, + * the interval is automatically scaled to the BTS channel load average. + * \param[in] acc_ramp Pointer to acc_ramp structure. + * \param[in] step_interval The new fixed step interval in seconds. + */ +int acc_ramp_set_step_interval(struct acc_ramp *acc_ramp, unsigned int step_interval) +{ + if (step_interval < ACC_RAMP_STEP_INTERVAL_MIN || step_interval > ACC_RAMP_STEP_INTERVAL_MAX) + return -ERANGE; + + acc_ramp->step_interval_sec = step_interval; + acc_ramp->step_interval_is_fixed = true; + LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: ramping step interval set to %u seconds\n", + acc_ramp->bts->nr, step_interval); + return 0; +} + +/*! + * Clear a previously set fixed ramping step interval, so that the interval + * is again automatically scaled to the BTS channel load average. + * \param[in] acc_ramp Pointer to acc_ramp structure. + */ +void acc_ramp_set_step_interval_dynamic(struct acc_ramp *acc_ramp) +{ + acc_ramp->step_interval_is_fixed = false; + LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: ramping step interval set to 'dynamic'\n", + acc_ramp->bts->nr); +} + +/*! + * Begin the ramping process. Perform at least one ramping step to allow 'step_size' ACCs. + * If 'step_size' is ACC_RAMP_STEP_SIZE_MAX, all ACCs will be allowed immediately. + * \param[in] acc_ramp Pointer to acc_ramp structure. + */ +void acc_ramp_start(struct acc_ramp *acc_ramp) +{ + /* Abort any previously running ramping process. */ + acc_ramp_abort(acc_ramp); + + /* Set all availble ACCs to barred and start ramping up. */ + barr_all_enabled_accs(acc_ramp); + do_acc_ramping_step(acc_ramp); +} + +/*! + * Abort the ramping process. If ramping is disabled or has already finished, + * then this function has no effect. + * \param[in] acc_ramp Pointer to acc_ramp structure. + */ +void acc_ramp_abort(struct acc_ramp *acc_ramp) +{ + if (osmo_timer_pending(&acc_ramp->step_timer)) + osmo_timer_del(&acc_ramp->step_timer); +} diff --git a/src/libbsc/bsc_init.c b/src/libbsc/bsc_init.c index 2b1d53bbb..2fddc80e1 100644 --- a/src/libbsc/bsc_init.c +++ b/src/libbsc/bsc_init.c @@ -331,6 +331,12 @@ static void bootstrap_rsl(struct gsm_bts_trx *trx) bsc_gsmnet->network_code, trx->bts->location_area_code, trx->bts->cell_identity, trx->bts->bsic); + /* + * Re-initialize ACC ramping to ensure ACCs are barred/allowed + * according to our current VTY configuration. + */ + acc_ramp_init(&trx->bts->acc_ramp, acc_ramp_is_enabled(&trx->bts->acc_ramp), trx->bts); + if (trx->bts->type == GSM_BTS_TYPE_NOKIA_SITE) { rsl_nokia_si_begin(trx); } @@ -345,6 +351,9 @@ static void bootstrap_rsl(struct gsm_bts_trx *trx) for (i = 0; i < ARRAY_SIZE(trx->ts); i++) generate_ma_for_ts(&trx->ts[i]); + + if (acc_ramp_is_enabled(&trx->bts->acc_ramp)) + acc_ramp_start(&trx->bts->acc_ramp); } /* Callback function to be called every time we receive a signal from INPUT */ @@ -400,8 +409,10 @@ static int inp_sig_cb(unsigned int subsys, unsigned int signal, if (isd->link_type == E1INP_SIGN_OML) rate_ctr_inc(&trx->bts->bts_ctrs->ctr[BTS_CTR_BTS_OML_FAIL]); - else if (isd->link_type == E1INP_SIGN_RSL) + else if (isd->link_type == E1INP_SIGN_RSL) { rate_ctr_inc(&trx->bts->bts_ctrs->ctr[BTS_CTR_BTS_RSL_FAIL]); + acc_ramp_abort(&trx->bts->acc_ramp); + } /* * free all allocated channels. change the nm_state so the @@ -525,6 +536,8 @@ static int bootstrap_bts(struct gsm_bts *bts) bts->chan_load_samples_idx = 0; + acc_ramp_init(&bts->acc_ramp, false, bts); + /* Initialize the BTS state */ gsm_bts_mo_reset(bts); diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c index 36c849d5e..5ff9cb258 100644 --- a/src/libbsc/bsc_vty.c +++ b/src/libbsc/bsc_vty.c @@ -60,6 +60,7 @@ #include <osmocom/bsc/handover_cfg.h> #include <osmocom/bsc/handover_vty.h> #include <osmocom/bsc/gsm_04_08_utils.h> +#include <osmocom/bsc/acc_ramp.h> #include <inttypes.h> @@ -343,6 +344,18 @@ static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts) VTY_NEWLINE); vty_out(vty, " Cell Reselection Hysteresis: %u dBm%s", bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE); + vty_out(vty, " Access Control Class ramping: %senabled%s", + acc_ramp_is_enabled(&bts->acc_ramp) ? "" : "not ", VTY_NEWLINE); + if (acc_ramp_is_enabled(&bts->acc_ramp)) { + if (!acc_ramp_step_interval_is_dynamic(&bts->acc_ramp)) + vty_out(vty, " Access Control Class ramping step interval: %u seconds%s", + acc_ramp_get_step_interval(&bts->acc_ramp), VTY_NEWLINE); + else + vty_out(vty, " Access Control Class ramping step interval: dynamic%s", VTY_NEWLINE); + vty_out(vty, " enabling %u Access Control Class%s per ramping step%s", + acc_ramp_get_step_size(&bts->acc_ramp), + acc_ramp_get_step_size(&bts->acc_ramp) > 1 ? "es" : "", VTY_NEWLINE); + } vty_out(vty, " RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer, VTY_NEWLINE); vty_out(vty, " RACH Max transmissions: %u%s", @@ -767,6 +780,15 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) for (i = 0; i < 8; i++) if ((i != 2) && (bts->si_common.rach_control.t2 & (0x1 << i))) vty_out(vty, " rach access-control-class %d barred%s", i+8, VTY_NEWLINE); + vty_out(vty, " %saccess-control-class-ramping%s", acc_ramp_is_enabled(&bts->acc_ramp) ? "" : "no ", VTY_NEWLINE); + if (!acc_ramp_step_interval_is_dynamic(&bts->acc_ramp)) { + vty_out(vty, " access-control-class-ramping-step-interval %u%s", + acc_ramp_get_step_interval(&bts->acc_ramp), VTY_NEWLINE); + } else { + vty_out(vty, " access-control-class-ramping-step-interval dynamic%s", VTY_NEWLINE); + } + vty_out(vty, " access-control-class-ramping-step-size %u%s", acc_ramp_get_step_size(&bts->acc_ramp), + VTY_NEWLINE); for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) { if (bts->si_mode_static & (1 << i)) { vty_out(vty, " system-information %s mode static%s", @@ -1858,6 +1880,11 @@ DEFUN(cfg_bts, /* allocate a new one */ bts = gsm_bts_alloc_register(gsmnet, GSM_BTS_TYPE_UNKNOWN, HARDCODED_BSIC); + /* + * Initalize bts->acc_ramp here. Else we could segfault while + * processing a configuration file with ACC ramping settings. + */ + acc_ramp_init(&bts->acc_ramp, false, bts); } else bts = gsm_bts_num(gsmnet, bts_nr); @@ -3210,6 +3237,88 @@ DEFUN(cfg_bts_pcu_sock, cfg_bts_pcu_sock_cmd, return CMD_SUCCESS; } +DEFUN(cfg_bts_acc_ramping, + cfg_bts_acc_ramping_cmd, + "access-control-class-ramping", + "Enable Access Control Class ramping\n") +{ + struct gsm_bts *bts = vty->index; + + acc_ramp_init(&bts->acc_ramp, true, bts); + + /* ACC ramping takes effect when the BTS reconnects. */ + return CMD_SUCCESS; +} + +DEFUN(cfg_bts_no_acc_ramping, cfg_bts_no_acc_ramping_cmd, + "no access-control-class-ramping", + NO_STR + "Disable Access Control Class ramping\n") +{ + struct gsm_bts *bts = vty->index; + + if (acc_ramp_is_enabled(&bts->acc_ramp)) { + acc_ramp_abort(&bts->acc_ramp); + acc_ramp_init(&bts->acc_ramp, false, bts); + gsm_bts_set_system_infos(bts); + } + + return CMD_SUCCESS; +} + +DEFUN(cfg_bts_acc_ramping_step_interval, + cfg_bts_acc_ramping_step_interval_cmd, + "access-control-class-ramping-step-interval (<" + OSMO_STRINGIFY_VAL(ACC_RAMP_STEP_INTERVAL_MIN) "-" + OSMO_STRINGIFY_VAL(ACC_RAMP_STEP_INTERVAL_MAX) ">|dynamic)", + "Configure Access Control Class ramping step interval\n" + "Set a fixed step interval (in seconds)\n" + "Use dynamic step interval based on BTS channel load\n") +{ + struct gsm_bts *bts = vty->index; + bool dynamic = (strcmp(argv[0], "dynamic") == 0); + int error; + + if (dynamic) { + acc_ramp_set_step_interval_dynamic(&bts->acc_ramp); + return CMD_SUCCESS; + } + + error = acc_ramp_set_step_interval(&bts->acc_ramp, atoi(argv[0])); + if (error != 0) { + if (error == -ERANGE) + vty_out(vty, "Unable to set ACC ramp step interval: value out of range%s", VTY_NEWLINE); + else + vty_out(vty, "Unable to set ACC ramp step interval: unknown error%s", VTY_NEWLINE); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + +DEFUN(cfg_bts_acc_ramping_step_size, + cfg_bts_acc_ramping_step_size_cmd, + "access-control-class-ramping-step-size (<" + OSMO_STRINGIFY_VAL(ACC_RAMP_STEP_SIZE_MIN) "-" + OSMO_STRINGIFY_VAL(ACC_RAMP_STEP_SIZE_MAX) ">)", + "Configure Access Control Class ramping step size\n" + "Set the number of Access Control Classes to enable per ramping step\n") +{ + struct gsm_bts *bts = vty->index; + int error; + + error = acc_ramp_set_step_size(&bts->acc_ramp, atoi(argv[0])); + if (error != 0) { + if (error == -ERANGE) + vty_out(vty, "Unable to set ACC ramp step size: value out of range%s", VTY_NEWLINE); + else + vty_out(vty, "Unable to set ACC ramp step size: unknown error%s", VTY_NEWLINE); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + #define EXCL_RFLOCK_STR "Exclude this BTS from the global RF Lock\n" DEFUN(cfg_bts_excl_rf_lock, @@ -4723,6 +4832,10 @@ int bsc_vty_init(struct gsm_network *network) install_element(BTS_NODE, &cfg_bts_amr_hr_hyst3_cmd); install_element(BTS_NODE, &cfg_bts_amr_hr_start_mode_cmd); install_element(BTS_NODE, &cfg_bts_pcu_sock_cmd); + install_element(BTS_NODE, &cfg_bts_acc_ramping_cmd); + install_element(BTS_NODE, &cfg_bts_no_acc_ramping_cmd); + install_element(BTS_NODE, &cfg_bts_acc_ramping_step_interval_cmd); + install_element(BTS_NODE, &cfg_bts_acc_ramping_step_size_cmd); /* See also handover commands added on bts level from handover_vty.c */ install_element(BTS_NODE, &cfg_trx_cmd); diff --git a/src/libbsc/chan_alloc.c b/src/libbsc/chan_alloc.c index 21d509040..284cb216b 100644 --- a/src/libbsc/chan_alloc.c +++ b/src/libbsc/chan_alloc.c @@ -662,8 +662,9 @@ bts_update_t3122_chan_load(struct gsm_bts *bts) load = ((used / total) * 100); LOGP(DRLL, LOGL_DEBUG, "(bts=%d) channel load average is %lu.%.2lu%%\n", bts->nr, (load & 0xffffff00) >> 8, (load & 0xff) / 10); - osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_LOAD_AVERAGE], - (load & 0xffffff00) >> 8); + bts->chan_load_avg = ((load & 0xffffff00) >> 8); + OSMO_ASSERT(bts->chan_load_avg <= 100); + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_LOAD_AVERAGE], bts->chan_load_avg); /* Calculate new T3122 wait indicator. */ wait_ind = ((used / total) * max_wait_ind); diff --git a/src/libbsc/gsm_data.c b/src/libbsc/gsm_data.c index a50425238..e1d422edc 100644 --- a/src/libbsc/gsm_data.c +++ b/src/libbsc/gsm_data.c @@ -771,6 +771,7 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, uint8_t bts_num) /* si handling */ bts->bcch_change_mark = 1; + bts->chan_load_avg = 0; bts->ho = ho_cfg_init(bts, net->ho); diff --git a/src/libbsc/system_information.c b/src/libbsc/system_information.c index a04959d87..750bba427 100644 --- a/src/libbsc/system_information.c +++ b/src/libbsc/system_information.c @@ -39,6 +39,7 @@ #include <osmocom/bsc/rest_octets.h> #include <osmocom/bsc/arfcn_range_encode.h> #include <osmocom/bsc/gsm_04_08_utils.h> +#include <osmocom/bsc/acc_ramp.h> /* * DCS1800 and PCS1900 have overlapping ARFCNs. We would need to set the @@ -675,6 +676,8 @@ static int generate_si1(enum osmo_sysinfo_type t, struct gsm_bts *bts) list_arfcn(si1->cell_channel_description, 0xce, "Serving cell:"); si1->rach_control = bts->si_common.rach_control; + if (acc_ramp_is_enabled(&bts->acc_ramp)) + acc_ramp_apply(&si1->rach_control, &bts->acc_ramp); /* * SI1 Rest Octets (10.5.2.32), contains NCH position and band @@ -705,6 +708,8 @@ static int generate_si2(enum osmo_sysinfo_type t, struct gsm_bts *bts) si2->ncc_permitted = bts->si_common.ncc_permitted; si2->rach_control = bts->si_common.rach_control; + if (acc_ramp_is_enabled(&bts->acc_ramp)) + acc_ramp_apply(&si2->rach_control, &bts->acc_ramp); return sizeof(*si2); } @@ -738,6 +743,8 @@ static int generate_si2bis(enum osmo_sysinfo_type t, struct gsm_bts *bts) bts->si_valid &= ~(1 << SYSINFO_TYPE_2bis); si2b->rach_control = bts->si_common.rach_control; + if (acc_ramp_is_enabled(&bts->acc_ramp)) + acc_ramp_apply(&si2b->rach_control, &bts->acc_ramp); /* SI2bis Rest Octets as per 3GPP TS 44.018 ยง10.5.2.33 */ rc = rest_octets_si2bis(si2b->rest_octets); @@ -860,6 +867,8 @@ static int generate_si3(enum osmo_sysinfo_type t, struct gsm_bts *bts) si3->cell_options = bts->si_common.cell_options; si3->cell_sel_par = bts->si_common.cell_sel_par; si3->rach_control = bts->si_common.rach_control; + if (acc_ramp_is_enabled(&bts->acc_ramp)) + acc_ramp_apply(&si3->rach_control, &bts->acc_ramp); /* allow/disallow DTXu */ gsm48_set_dtx(&si3->cell_options, bts->dtxu, bts->dtxu, true); @@ -910,6 +919,8 @@ static int generate_si4(enum osmo_sysinfo_type t, struct gsm_bts *bts) bts->location_area_code); si4->cell_sel_par = bts->si_common.cell_sel_par; si4->rach_control = bts->si_common.rach_control; + if (acc_ramp_is_enabled(&bts->acc_ramp)) + acc_ramp_apply(&si4->rach_control, &bts->acc_ramp); /* Optional: CBCH Channel Description + CBCH Mobile Allocation */ cbch_lchan = gsm_bts_get_cbch(bts); |