aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openbsc/include/openbsc/Makefile.am1
-rw-r--r--openbsc/include/openbsc/acc_ramp.h149
-rw-r--r--openbsc/include/openbsc/gsm_data_shared.h6
-rw-r--r--openbsc/src/libbsc/Makefile.am1
-rw-r--r--openbsc/src/libbsc/acc_ramp.c236
-rw-r--r--openbsc/src/libbsc/bsc_init.c15
-rw-r--r--openbsc/src/libbsc/bsc_vty.c113
-rw-r--r--openbsc/src/libbsc/chan_alloc.c5
-rw-r--r--openbsc/src/libbsc/system_information.c11
-rw-r--r--openbsc/src/libcommon/gsm_data_shared.c2
10 files changed, 536 insertions, 3 deletions
diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am
index 126b115ed..1fa30d56c 100644
--- a/openbsc/include/openbsc/Makefile.am
+++ b/openbsc/include/openbsc/Makefile.am
@@ -2,6 +2,7 @@ noinst_HEADERS = \
abis_nm.h \
abis_om2000.h \
abis_rsl.h \
+ acc_ramp.h \
arfcn_range_encode.h \
auth.h \
bsc_msc.h \
diff --git a/openbsc/include/openbsc/acc_ramp.h b/openbsc/include/openbsc/acc_ramp.h
new file mode 100644
index 000000000..cb063bf53
--- /dev/null
+++ b/openbsc/include/openbsc/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/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 47c5faef4..ddd59918e 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -24,6 +24,8 @@
#include <osmocom/gsm/lapdm.h>
#endif
+#include <openbsc/acc_ramp.h>
+
/* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1:
4-bit index is used (2#1111 = 10#15) */
#define SI2Q_MAX_NUM 16
@@ -845,6 +847,9 @@ struct gsm_bts {
int force_combined_si;
int bcch_change_mark;
+ /* access control class ramping */
+ struct acc_ramp acc_ramp;
+
#ifdef ROLE_BSC
/* Abis NM queue */
struct llist_head abis_queue;
@@ -915,6 +920,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). */
#endif /* ROLE_BSC */
void *role;
diff --git a/openbsc/src/libbsc/Makefile.am b/openbsc/src/libbsc/Makefile.am
index e78bde624..666e8b3a9 100644
--- a/openbsc/src/libbsc/Makefile.am
+++ b/openbsc/src/libbsc/Makefile.am
@@ -23,6 +23,7 @@ libbsc_a_SOURCES = \
abis_om2000.c \
abis_om2000_vty.c \
abis_rsl.c \
+ acc_ramp.c \
bsc_rll.c \
bsc_subscriber.c \
paging.c \
diff --git a/openbsc/src/libbsc/acc_ramp.c b/openbsc/src/libbsc/acc_ramp.c
new file mode 100644
index 000000000..08810b5b8
--- /dev/null
+++ b/openbsc/src/libbsc/acc_ramp.c
@@ -0,0 +1,236 @@
+/* (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 <openbsc/debug.h>
+#include <openbsc/acc_ramp.h>
+#include <openbsc/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/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c
index 4cfe20a04..0f732d758 100644
--- a/openbsc/src/libbsc/bsc_init.c
+++ b/openbsc/src/libbsc/bsc_init.c
@@ -310,6 +310,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);
}
@@ -324,6 +330,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 */
@@ -379,8 +388,10 @@ static int inp_sig_cb(unsigned int subsys, unsigned int signal,
if (isd->link_type == E1INP_SIGN_OML)
rate_ctr_inc(&trx->bts->network->bsc_ctrs->ctr[BSC_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->network->bsc_ctrs->ctr[BSC_CTR_BTS_RSL_FAIL]);
+ acc_ramp_abort(&trx->bts->acc_ramp);
+ }
/*
* free all allocated channels. change the nm_state so the
@@ -509,6 +520,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/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index fd77fabb0..5340e11dd 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -56,6 +56,7 @@
#include <openbsc/bsc_msc_data.h>
#include <openbsc/osmo_bsc_rf.h>
#include <openbsc/pcu_if.h>
+#include <openbsc/acc_ramp.h>
#include <openbsc/common_cs.h>
@@ -260,6 +261,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",
@@ -663,6 +676,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",
@@ -1629,6 +1651,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);
@@ -3008,6 +3035,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,
@@ -4354,6 +4463,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);
install_element(BTS_NODE, &cfg_trx_cmd);
install_node(&trx_node, dummy_config_write);
diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c
index b27ac8fd2..5fa20af29 100644
--- a/openbsc/src/libbsc/chan_alloc.c
+++ b/openbsc/src/libbsc/chan_alloc.c
@@ -609,8 +609,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/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index 9d40a2454..57921455a 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -37,6 +37,7 @@
#include <openbsc/abis_rsl.h>
#include <openbsc/rest_octets.h>
#include <openbsc/arfcn_range_encode.h>
+#include <openbsc/acc_ramp.h>
/*
* DCS1800 and PCS1900 have overlapping ARFCNs. We would need to set the
@@ -662,6 +663,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
@@ -692,6 +695,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);
}
@@ -725,6 +730,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);
return sizeof(*si2b);
}
@@ -841,6 +848,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);
@@ -891,6 +900,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);
diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index 37baec341..75fe0b0ef 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -381,6 +381,8 @@ struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num)
/* si handling */
bts->bcch_change_mark = 1;
+ bts->chan_load_avg = 0;
+
/* timer overrides */
bts->T3122 = 0; /* not overriden by default */