Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 1 | /* (C) 2018 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> |
| 2 | * |
| 3 | * Author: Stefan Sperling <ssperling@sysmocom.de> |
| 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU Affero General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU Affero General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Affero General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <strings.h> |
| 23 | #include <errno.h> |
| 24 | #include <stdbool.h> |
| 25 | |
| 26 | #include <osmocom/bsc/debug.h> |
| 27 | #include <osmocom/bsc/acc_ramp.h> |
| 28 | #include <osmocom/bsc/gsm_data.h> |
Stefan Sperling | 4d3d243 | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 29 | #include <osmocom/bsc/chan_alloc.h> |
Stefan Sperling | 60ecdef | 2018-04-10 17:55:08 +0200 | [diff] [blame] | 30 | #include <osmocom/bsc/signal.h> |
Stefan Sperling | cda994e | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 31 | #include <osmocom/bsc/abis_nm.h> |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 32 | |
| 33 | /* |
| 34 | * Check if an ACC has been permanently barred for a BTS, |
| 35 | * e.g. with the 'rach access-control-class' VTY command. |
| 36 | */ |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 37 | static bool acc_is_permanently_barred(struct gsm_bts *bts, unsigned int acc) |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 38 | { |
| 39 | OSMO_ASSERT(acc >= 0 && acc <= 9); |
| 40 | if (acc == 8 || acc == 9) |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 41 | return (bts->si_common.rach_control.t2 & (1 << (acc - 8))); |
| 42 | return (bts->si_common.rach_control.t3 & (1 << (acc))); |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | static void allow_one_acc(struct acc_ramp *acc_ramp, unsigned int acc) |
| 46 | { |
| 47 | OSMO_ASSERT(acc >= 0 && acc <= 9); |
Stefan Sperling | 53d40e0 | 2018-04-10 16:25:26 +0200 | [diff] [blame] | 48 | if (acc_ramp->barred_accs & (1 << acc)) |
Pau Espin Pedrol | 67f20bc | 2018-05-28 11:44:54 +0200 | [diff] [blame^] | 49 | LOGP(DRSL, LOGL_NOTICE, "(bts=%d) ACC RAMP: allowing Access Control Class %u\n", acc_ramp->bts->nr, acc); |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 50 | acc_ramp->barred_accs &= ~(1 << acc); |
| 51 | } |
| 52 | |
| 53 | static void barr_one_acc(struct acc_ramp *acc_ramp, unsigned int acc) |
| 54 | { |
| 55 | OSMO_ASSERT(acc >= 0 && acc <= 9); |
Stefan Sperling | 53d40e0 | 2018-04-10 16:25:26 +0200 | [diff] [blame] | 56 | if ((acc_ramp->barred_accs & (1 << acc)) == 0) |
Pau Espin Pedrol | 67f20bc | 2018-05-28 11:44:54 +0200 | [diff] [blame^] | 57 | LOGP(DRSL, LOGL_NOTICE, "(bts=%d) ACC RAMP: barring Access Control Class %u\n", acc_ramp->bts->nr, acc); |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 58 | acc_ramp->barred_accs |= (1 << acc); |
| 59 | } |
| 60 | |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 61 | static void barr_all_accs(struct acc_ramp *acc_ramp) |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 62 | { |
| 63 | unsigned int acc; |
| 64 | for (acc = 0; acc < 10; acc++) { |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 65 | if (!acc_is_permanently_barred(acc_ramp->bts, acc)) |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 66 | barr_one_acc(acc_ramp, acc); |
| 67 | } |
| 68 | } |
| 69 | |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 70 | static void allow_all_accs(struct acc_ramp *acc_ramp) |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 71 | { |
| 72 | unsigned int acc; |
| 73 | for (acc = 0; acc < 10; acc++) { |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 74 | if (!acc_is_permanently_barred(acc_ramp->bts, acc)) |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 75 | allow_one_acc(acc_ramp, acc); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | static unsigned int get_next_step_interval(struct acc_ramp *acc_ramp) |
| 80 | { |
| 81 | struct gsm_bts *bts = acc_ramp->bts; |
| 82 | uint64_t load; |
| 83 | |
| 84 | if (acc_ramp->step_interval_is_fixed) |
| 85 | return acc_ramp->step_interval_sec; |
| 86 | |
| 87 | /* Scale the step interval to current channel load average. */ |
| 88 | load = (bts->chan_load_avg << 8); /* convert to fixed-point */ |
| 89 | acc_ramp->step_interval_sec = ((load * ACC_RAMP_STEP_INTERVAL_MAX) / 100) >> 8; |
| 90 | if (acc_ramp->step_interval_sec < ACC_RAMP_STEP_SIZE_MIN) |
| 91 | acc_ramp->step_interval_sec = ACC_RAMP_STEP_INTERVAL_MIN; |
| 92 | else if (acc_ramp->step_interval_sec > ACC_RAMP_STEP_INTERVAL_MAX) |
| 93 | acc_ramp->step_interval_sec = ACC_RAMP_STEP_INTERVAL_MAX; |
| 94 | |
| 95 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: step interval set to %u seconds based on %u%% channel load average\n", |
| 96 | bts->nr, acc_ramp->step_interval_sec, bts->chan_load_avg); |
| 97 | return acc_ramp->step_interval_sec; |
| 98 | } |
| 99 | |
| 100 | static void do_acc_ramping_step(void *data) |
| 101 | { |
| 102 | struct acc_ramp *acc_ramp = data; |
| 103 | int i; |
| 104 | |
| 105 | /* Shortcut in case we only do one ramping step. */ |
| 106 | if (acc_ramp->step_size == ACC_RAMP_STEP_SIZE_MAX) { |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 107 | allow_all_accs(acc_ramp); |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 108 | gsm_bts_set_system_infos(acc_ramp->bts); |
| 109 | return; |
| 110 | } |
| 111 | |
| 112 | /* Allow 'step_size' ACCs, starting from ACC0. ACC9 will be allowed last. */ |
| 113 | for (i = 0; i < acc_ramp->step_size; i++) { |
| 114 | int idx = ffs(acc_ramp_get_barred_t3(acc_ramp)); |
| 115 | if (idx > 0) { |
| 116 | /* One of ACC0-ACC7 is still bared. */ |
| 117 | unsigned int acc = idx - 1; |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 118 | if (!acc_is_permanently_barred(acc_ramp->bts, acc)) |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 119 | allow_one_acc(acc_ramp, acc); |
| 120 | } else { |
| 121 | idx = ffs(acc_ramp_get_barred_t2(acc_ramp)); |
| 122 | if (idx == 1 || idx == 2) { |
| 123 | /* ACC8 or ACC9 is still barred. */ |
| 124 | unsigned int acc = idx - 1 + 8; |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 125 | if (!acc_is_permanently_barred(acc_ramp->bts, acc)) |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 126 | allow_one_acc(acc_ramp, acc); |
| 127 | } else { |
| 128 | /* All ACCs are now allowed. */ |
| 129 | break; |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | gsm_bts_set_system_infos(acc_ramp->bts); |
| 135 | |
| 136 | /* If we have not allowed all ACCs yet, schedule another ramping step. */ |
| 137 | if (acc_ramp_get_barred_t2(acc_ramp) != 0x00 || |
| 138 | acc_ramp_get_barred_t3(acc_ramp) != 0x00) |
| 139 | osmo_timer_schedule(&acc_ramp->step_timer, get_next_step_interval(acc_ramp), 0); |
| 140 | } |
| 141 | |
Stefan Sperling | 60ecdef | 2018-04-10 17:55:08 +0200 | [diff] [blame] | 142 | /* Implements osmo_signal_cbfn() -- trigger or abort ACC ramping upon changes RF lock state. */ |
| 143 | static int acc_ramp_nm_sig_cb(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data) |
| 144 | { |
| 145 | struct nm_statechg_signal_data *nsd = signal_data; |
| 146 | struct acc_ramp *acc_ramp = handler_data; |
| 147 | struct gsm_bts_trx *trx = NULL; |
Stefan Sperling | cda994e | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 148 | bool trigger_ramping = false, abort_ramping = false; |
Stefan Sperling | 60ecdef | 2018-04-10 17:55:08 +0200 | [diff] [blame] | 149 | |
Stefan Sperling | b06c7a2 | 2018-04-11 20:46:38 +0200 | [diff] [blame] | 150 | /* Handled signals map to an Administrative State Change ACK, or a State Changed Event Report. */ |
| 151 | if (signal != S_NM_STATECHG_ADM && signal != S_NM_STATECHG_OPER) |
Stefan Sperling | 60ecdef | 2018-04-10 17:55:08 +0200 | [diff] [blame] | 152 | return 0; |
| 153 | |
| 154 | if (nsd->obj_class != NM_OC_RADIO_CARRIER) |
| 155 | return 0; |
| 156 | |
| 157 | trx = nsd->obj; |
| 158 | |
Stefan Sperling | cda994e | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 159 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d,trx=%d) ACC RAMP: administrative state %s -> %s\n", |
| 160 | acc_ramp->bts->nr, trx->nr, |
| 161 | get_value_string(abis_nm_adm_state_names, nsd->old_state->administrative), |
| 162 | get_value_string(abis_nm_adm_state_names, nsd->new_state->administrative)); |
| 163 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d,trx=%d) ACC RAMP: operational state %s -> %s\n", |
| 164 | acc_ramp->bts->nr, trx->nr, |
| 165 | abis_nm_opstate_name(nsd->old_state->operational), |
| 166 | abis_nm_opstate_name(nsd->new_state->operational)); |
| 167 | |
Stefan Sperling | 60ecdef | 2018-04-10 17:55:08 +0200 | [diff] [blame] | 168 | /* We only care about state changes of the first TRX. */ |
| 169 | if (trx->nr != 0) |
| 170 | return 0; |
| 171 | |
| 172 | /* RSL must already be up. We cannot send RACH system information to the BTS otherwise. */ |
Stefan Sperling | cda994e | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 173 | if (trx->rsl_link == NULL) { |
| 174 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d,trx=%d) ACC RAMP: ignoring state change because RSL link is down\n", |
| 175 | acc_ramp->bts->nr, trx->nr); |
Stefan Sperling | 60ecdef | 2018-04-10 17:55:08 +0200 | [diff] [blame] | 176 | return 0; |
Stefan Sperling | 60ecdef | 2018-04-10 17:55:08 +0200 | [diff] [blame] | 177 | } |
| 178 | |
Stefan Sperling | cda994e | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 179 | /* Trigger or abort ACC ramping based on the new state of this TRX. */ |
| 180 | if (nsd->old_state->administrative != nsd->new_state->administrative) { |
| 181 | switch (nsd->new_state->administrative) { |
| 182 | case NM_STATE_UNLOCKED: |
| 183 | if (nsd->old_state->operational != nsd->new_state->operational) { |
| 184 | /* |
| 185 | * Administrative and operational state have both changed. |
| 186 | * Trigger ramping only if TRX 0 will be both enabled and unlocked. |
| 187 | */ |
| 188 | if (nsd->new_state->operational == NM_OPSTATE_ENABLED) |
| 189 | trigger_ramping = true; |
| 190 | else |
| 191 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d,trx=%d) ACC RAMP: ignoring state change " |
| 192 | "because TRX is transitioning into operational state '%s'\n", |
| 193 | acc_ramp->bts->nr, trx->nr, |
| 194 | abis_nm_opstate_name(nsd->new_state->operational)); |
| 195 | } else { |
| 196 | /* |
| 197 | * Operational state has not changed. |
| 198 | * Trigger ramping only if TRX 0 is already usable. |
| 199 | */ |
| 200 | if (trx_is_usable(trx)) |
| 201 | trigger_ramping = true; |
| 202 | else |
| 203 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d,trx=%d) ACC RAMP: ignoring state change " |
| 204 | "because TRX is not usable\n", acc_ramp->bts->nr, trx->nr); |
| 205 | } |
| 206 | break; |
| 207 | case NM_STATE_LOCKED: |
| 208 | case NM_STATE_SHUTDOWN: |
| 209 | abort_ramping = true; |
| 210 | break; |
| 211 | case NM_STATE_NULL: |
| 212 | default: |
Pau Espin Pedrol | 67f20bc | 2018-05-28 11:44:54 +0200 | [diff] [blame^] | 213 | LOGP(DRSL, LOGL_ERROR, "(bts=%d) ACC RAMP: unrecognized administrative state '0x%x' " |
Stefan Sperling | cda994e | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 214 | "reported for TRX 0\n", acc_ramp->bts->nr, nsd->new_state->administrative); |
| 215 | break; |
| 216 | } |
| 217 | } |
| 218 | if (nsd->old_state->operational != nsd->new_state->operational) { |
| 219 | switch (nsd->new_state->operational) { |
| 220 | case NM_OPSTATE_ENABLED: |
| 221 | if (nsd->old_state->administrative != nsd->new_state->administrative) { |
| 222 | /* |
| 223 | * Administrative and operational state have both changed. |
| 224 | * Trigger ramping only if TRX 0 will be both enabled and unlocked. |
| 225 | */ |
| 226 | if (nsd->new_state->administrative == NM_STATE_UNLOCKED) |
| 227 | trigger_ramping = true; |
| 228 | else |
| 229 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d,trx=%d) ACC RAMP: ignoring state change " |
| 230 | "because TRX is transitioning into administrative state '%s'\n", |
| 231 | acc_ramp->bts->nr, trx->nr, |
| 232 | get_value_string(abis_nm_adm_state_names, nsd->new_state->administrative)); |
| 233 | } else { |
| 234 | /* |
| 235 | * Administrative state has not changed. |
| 236 | * Trigger ramping only if TRX 0 is already unlocked. |
| 237 | */ |
| 238 | if (trx->mo.nm_state.administrative == NM_STATE_UNLOCKED) |
| 239 | trigger_ramping = true; |
| 240 | else |
| 241 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d,trx=%d) ACC RAMP: ignoring state change " |
| 242 | "because TRX is in administrative state '%s'\n", |
| 243 | acc_ramp->bts->nr, trx->nr, |
| 244 | get_value_string(abis_nm_adm_state_names, trx->mo.nm_state.administrative)); |
| 245 | } |
| 246 | break; |
| 247 | case NM_OPSTATE_DISABLED: |
| 248 | abort_ramping = true; |
| 249 | break; |
| 250 | case NM_OPSTATE_NULL: |
| 251 | default: |
Pau Espin Pedrol | 67f20bc | 2018-05-28 11:44:54 +0200 | [diff] [blame^] | 252 | LOGP(DRSL, LOGL_ERROR, "(bts=%d) ACC RAMP: unrecognized operational state '0x%x' " |
Stefan Sperling | cda994e | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 253 | "reported for TRX 0\n", acc_ramp->bts->nr, nsd->new_state->administrative); |
| 254 | break; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | if (trigger_ramping) |
| 259 | acc_ramp_trigger(acc_ramp); |
| 260 | else if (abort_ramping) |
| 261 | acc_ramp_abort(acc_ramp); |
| 262 | |
Stefan Sperling | 60ecdef | 2018-04-10 17:55:08 +0200 | [diff] [blame] | 263 | return 0; |
| 264 | } |
| 265 | |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 266 | /*! |
| 267 | * Initialize an acc_ramp data structure. |
| 268 | * Storage for this structure must be provided by the caller. |
| 269 | * |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 270 | * By default, ACC ramping is disabled and all ACCs are allowed. |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 271 | * |
| 272 | * \param[in] acc_ramp Pointer to acc_ramp structure to be initialized. |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 273 | * \param[in] bts BTS which uses this ACC ramp data structure. |
| 274 | */ |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 275 | void acc_ramp_init(struct acc_ramp *acc_ramp, struct gsm_bts *bts) |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 276 | { |
| 277 | acc_ramp->bts = bts; |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 278 | acc_ramp_set_enabled(acc_ramp, false); |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 279 | acc_ramp->step_size = ACC_RAMP_STEP_SIZE_DEFAULT; |
| 280 | acc_ramp->step_interval_sec = ACC_RAMP_STEP_INTERVAL_MIN; |
| 281 | acc_ramp->step_interval_is_fixed = false; |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 282 | allow_all_accs(acc_ramp); |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 283 | osmo_timer_setup(&acc_ramp->step_timer, do_acc_ramping_step, acc_ramp); |
Stefan Sperling | 60ecdef | 2018-04-10 17:55:08 +0200 | [diff] [blame] | 284 | osmo_signal_register_handler(SS_NM, acc_ramp_nm_sig_cb, acc_ramp); |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | /*! |
| 288 | * Change the ramping step size which controls how many ACCs will be allowed per ramping step. |
| 289 | * Returns negative on error (step_size out of range), else zero. |
| 290 | * \param[in] acc_ramp Pointer to acc_ramp structure. |
| 291 | * \param[in] step_size The new step size value. |
| 292 | */ |
| 293 | int acc_ramp_set_step_size(struct acc_ramp *acc_ramp, unsigned int step_size) |
| 294 | { |
| 295 | if (step_size < ACC_RAMP_STEP_SIZE_MIN || step_size > ACC_RAMP_STEP_SIZE_MAX) |
| 296 | return -ERANGE; |
| 297 | |
| 298 | acc_ramp->step_size = step_size; |
| 299 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: ramping step size set to %u\n", acc_ramp->bts->nr, step_size); |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | /*! |
| 304 | * Change the ramping step interval to a fixed value. Unless this function is called, |
| 305 | * the interval is automatically scaled to the BTS channel load average. |
| 306 | * \param[in] acc_ramp Pointer to acc_ramp structure. |
| 307 | * \param[in] step_interval The new fixed step interval in seconds. |
| 308 | */ |
| 309 | int acc_ramp_set_step_interval(struct acc_ramp *acc_ramp, unsigned int step_interval) |
| 310 | { |
| 311 | if (step_interval < ACC_RAMP_STEP_INTERVAL_MIN || step_interval > ACC_RAMP_STEP_INTERVAL_MAX) |
| 312 | return -ERANGE; |
| 313 | |
| 314 | acc_ramp->step_interval_sec = step_interval; |
| 315 | acc_ramp->step_interval_is_fixed = true; |
| 316 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: ramping step interval set to %u seconds\n", |
| 317 | acc_ramp->bts->nr, step_interval); |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | /*! |
| 322 | * Clear a previously set fixed ramping step interval, so that the interval |
| 323 | * is again automatically scaled to the BTS channel load average. |
| 324 | * \param[in] acc_ramp Pointer to acc_ramp structure. |
| 325 | */ |
| 326 | void acc_ramp_set_step_interval_dynamic(struct acc_ramp *acc_ramp) |
| 327 | { |
| 328 | acc_ramp->step_interval_is_fixed = false; |
| 329 | LOGP(DRSL, LOGL_DEBUG, "(bts=%d) ACC RAMP: ramping step interval set to 'dynamic'\n", |
| 330 | acc_ramp->bts->nr); |
| 331 | } |
| 332 | |
| 333 | /*! |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 334 | * Determine if ACC ramping should be started according to configuration, and |
Stefan Sperling | 4d3d243 | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 335 | * begin the ramping process if the necessary conditions are present. |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 336 | * Perform at least one ramping step to allow 'step_size' ACCs. |
| 337 | * If 'step_size' is ACC_RAMP_STEP_SIZE_MAX, or if ACC ramping is disabled, |
| 338 | * all ACCs will be allowed immediately. |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 339 | * \param[in] acc_ramp Pointer to acc_ramp structure. |
| 340 | */ |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 341 | void acc_ramp_trigger(struct acc_ramp *acc_ramp) |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 342 | { |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 343 | /* Abort any previously running ramping process and allow all available ACCs. */ |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 344 | acc_ramp_abort(acc_ramp); |
| 345 | |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 346 | if (acc_ramp_is_enabled(acc_ramp)) { |
Stefan Sperling | cda994e | 2018-04-12 09:18:36 +0200 | [diff] [blame] | 347 | /* Set all available ACCs to barred and start ramping up. */ |
| 348 | barr_all_accs(acc_ramp); |
| 349 | do_acc_ramping_step(acc_ramp); |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 350 | } |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | /*! |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 354 | * Abort the ramping process and allow all available ACCs immediately. |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 355 | * \param[in] acc_ramp Pointer to acc_ramp structure. |
| 356 | */ |
| 357 | void acc_ramp_abort(struct acc_ramp *acc_ramp) |
| 358 | { |
| 359 | if (osmo_timer_pending(&acc_ramp->step_timer)) |
| 360 | osmo_timer_del(&acc_ramp->step_timer); |
Stefan Sperling | ea33341 | 2018-04-10 16:36:54 +0200 | [diff] [blame] | 361 | |
Stefan Sperling | 0ad90b3 | 2018-04-11 13:36:52 +0200 | [diff] [blame] | 362 | allow_all_accs(acc_ramp); |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 363 | } |