diff options
author | Stefan Sperling <ssperling@sysmocom.de> | 2018-02-06 20:30:34 +0100 |
---|---|---|
committer | Stefan Sperling <ssperling@sysmocom.de> | 2018-02-06 20:30:34 +0100 |
commit | 44714b9e2916db4f1cfc3dab1d2976dfcf71a7b3 (patch) | |
tree | d8a77814fd6c7fe7c4f6ddd0883b1c4eeff42273 /src/libbsc/acc_ramp.c | |
parent | 8dc7a3c597cb1769c3a9d6cd86e6f4744c5960d8 (diff) |
do not conflict with the 'rach access-control-class' vty command
Change-Id: If46a01e5a43de38cbaeeeb2d5b91c4879cfc0e15
Diffstat (limited to 'src/libbsc/acc_ramp.c')
-rw-r--r-- | src/libbsc/acc_ramp.c | 77 |
1 files changed, 45 insertions, 32 deletions
diff --git a/src/libbsc/acc_ramp.c b/src/libbsc/acc_ramp.c index 27103bcda..20f7dcf50 100644 --- a/src/libbsc/acc_ramp.c +++ b/src/libbsc/acc_ramp.c @@ -25,28 +25,50 @@ #include <osmocom/bsc/acc_ramp.h> #include <osmocom/bsc/gsm_data.h> -static void deny_all_accs(struct acc_ramp *acc_ramp) +static bool bts_allows_acc(struct gsm_bts *bts, unsigned int acc) { - LOGP(DRLL, LOGL_DEBUG, "(bts=%d) ACC RAMP: denying all Access Control Classes 0-9\n", acc_ramp->bts->nr); - acc_ramp->barred_t2 = 0x03; /* ACC8, ACC9 barred */ - acc_ramp->barred_t3 = 0xff; /* ACC0 - ACC7 barred */ + 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_all_accs(struct acc_ramp *acc_ramp) +static void allow_acc(struct acc_ramp *acc_ramp, unsigned int acc) { - LOGP(DRLL, LOGL_DEBUG, "(bts=%d) ACC RAMP: allowing all Access Control Classes 0-9\n", acc_ramp->bts->nr); - acc_ramp->barred_t2 = 0x00; /* ACC8, ACC9 allowed */ - acc_ramp->barred_t3 = 0x00; /* ACC0 - ACC7 allowed */ + assert(acc >= 0 && acc <= 9); + LOGP(DRLL, LOGL_DEBUG, "(bts=%d) ACC RAMP: allowing Access Control Class %u\n", acc_ramp->bts->nr, acc); + if (acc == 8 || acc == 9) + acc_ramp->barred_t2 &= ~(1 << (acc - 8)); + else + acc_ramp->barred_t3 &= ~(1 << acc); } -static void allow_one_acc(struct acc_ramp *acc_ramp, unsigned int acc) +static void barr_acc(struct acc_ramp *acc_ramp, unsigned int acc) { - LOGP(DRLL, LOGL_DEBUG, "(bts=%d) ACC RAMP: allowing Access Control Class %u\n", acc_ramp->bts->nr, acc); assert(acc >= 0 && acc <= 9); + LOGP(DRLL, LOGL_DEBUG, "(bts=%d) ACC RAMP: barring Access Control Class %u\n", acc_ramp->bts->nr, acc); if (acc == 8 || acc == 9) - acc_ramp->barred_t2 &= ~(1 << (acc - 8)); + acc_ramp->barred_t2 |= (1 << (acc - 8)); else - acc_ramp->barred_t3 &= ~(1 << acc); + acc_ramp->barred_t3 |= (1 << acc); +} + +static void barr_all_allowed_accs(struct acc_ramp *acc_ramp) +{ + unsigned int acc; + for (acc = 0; acc < 10; acc++) { + if (bts_allows_acc(acc_ramp->bts, acc)) + barr_acc(acc_ramp, acc); + } +} + +static void allow_all_allowed_accs(struct acc_ramp *acc_ramp) +{ + unsigned int acc; + for (acc = 0; acc < 10; acc++) { + if (bts_allows_acc(acc_ramp->bts, acc)) + allow_acc(acc_ramp, acc); + } } static unsigned int get_next_step_interval(struct acc_ramp *acc_ramp) @@ -73,16 +95,6 @@ static unsigned int get_next_step_interval(struct acc_ramp *acc_ramp) return acc_ramp->step_interval_sec; } -static void update_bts_rach_control(struct acc_ramp *acc_ramp) -{ - struct gsm_bts *bts = acc_ramp->bts; - - /* Update RACH control parameters of this BTS. */ - bts->si_common.rach_control.t2 &= ~0x03; - bts->si_common.rach_control.t2 |= acc_ramp_get_barred_t2(acc_ramp); - bts->si_common.rach_control.t3 = acc_ramp_get_barred_t3(acc_ramp); -} - static void send_bts_system_info(struct gsm_bts *bts) { struct gsm_bts_trx *trx; @@ -99,7 +111,7 @@ static void do_ramping_step(void *data) /* Shortcut in case we only do one ramping step. */ if (acc_ramp->step_size == ACC_RAMP_STEP_SIZE_MAX) { - allow_all_accs(acc_ramp); + allow_all_allowed_accs(acc_ramp); return; } @@ -107,13 +119,17 @@ static void do_ramping_step(void *data) for (i = 0; i < acc_ramp->step_size; i++) { int idx = ffs(acc_ramp->barred_t3); if (idx > 0) { + unsigned int acc = idx - 1; /* one of ACC0-ACC7 is still bared */ - allow_one_acc(acc_ramp, idx - 1); + if (bts_allows_acc(acc_ramp->bts, acc)) + allow_acc(acc_ramp, acc); } else { idx = ffs(acc_ramp->barred_t2); if (idx == 1 || idx == 2) { + unsigned int acc = idx - 1 + 8; /* ACC8 or ACC9 is still barred */ - allow_one_acc(acc_ramp, idx - 1 + 8); + if (bts_allows_acc(acc_ramp->bts, acc)) + allow_acc(acc_ramp, acc); } else { /* all ACCs are now allowed */ break; @@ -121,8 +137,6 @@ static void do_ramping_step(void *data) } } - - update_bts_rach_control(acc_ramp); send_bts_system_info(acc_ramp->bts); /* If we have not allowed all ACCs yet, schedule another ramping step. */ @@ -140,10 +154,9 @@ void acc_ramp_init(struct acc_ramp *acc_ramp, struct gsm_bts *bts) osmo_timer_setup(&acc_ramp->step_timer, do_ramping_step, acc_ramp); if (bts->acc_ramping_enabled) - deny_all_accs(acc_ramp); + barr_all_allowed_accs(acc_ramp); else - allow_all_accs(acc_ramp); - update_bts_rach_control(acc_ramp); + allow_all_allowed_accs(acc_ramp); } int acc_ramp_set_step_size(struct acc_ramp *acc_ramp, enum acc_ramp_step_size step_size) @@ -175,8 +188,8 @@ void acc_ramp_start(struct acc_ramp *acc_ramp) /* Abort any previously running ramping process. */ acc_ramp_abort(acc_ramp); - /* Set all ACCs to denied and start ramping up. */ - deny_all_accs(acc_ramp); + /* Set all availble ACCs to barred and start ramping up. */ + barr_all_allowed_accs(acc_ramp); do_ramping_step(acc_ramp); } |