diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-11-12 12:50:23 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-11-18 20:29:40 +0000 |
commit | eebb6a4216f136132400831ca35ed70e7502e92a (patch) | |
tree | 0b987086e93e19d08360cd4d647af4f15d11688f /src/common | |
parent | e5f4654ee34c5a346a0b85805c706115464e96e1 (diff) |
bts: Allocate TRX for BTS dynamically, deprecate -t
No need to pass -t num_trx anymore to specify number of TRX to use. It
is calculated based on dynamic allocation from VTY config.
Using parameter -t is flagged as deprecated and is transformed into a
NOOP por backward compatibility.
As a result, TRX now are allocated after the BTS is allocated and
initial config (pre-VTY) is applied.
A new function bts_trx_init() is added, to set default config on each
TRX during allocation and before setting VTY config on it.
A new per BTS model function bts_model_trx_init() is added, to allow
per model specific default configuration of each TRX.
Change-Id: Iab1a754ab12a626759f9f90aa66f87bdce65ac9c
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/bts.c | 53 | ||||
-rw-r--r-- | src/common/main.c | 18 | ||||
-rw-r--r-- | src/common/vty.c | 20 |
3 files changed, 50 insertions, 41 deletions
diff --git a/src/common/bts.c b/src/common/bts.c index c251fdda..68cb1672 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -105,11 +105,10 @@ static const struct rate_ctr_group_desc bts_ctrg_desc = { bts_ctr_desc }; -/* Initialize the BTS (and TRX) data structures, called before config +/* Initialize the BTS data structures, called before config * file reading */ int bts_init(struct gsm_bts *bts) { - struct gsm_bts_trx *trx; int rc, i; static int initialized = 0; void *tall_rtp_ctx; @@ -167,26 +166,6 @@ int bts_init(struct gsm_bts *bts) oml_mo_state_init(&bts->gprs.nsvc[0].mo, -1, NM_AVSTATE_DEPENDENCY); oml_mo_state_init(&bts->gprs.nsvc[1].mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OFF_LINE); - /* initialize bts data structure */ - llist_for_each_entry(trx, &bts->trx_list, list) { - struct trx_power_params *tpp = &trx->power_params; - int i; - - for (i = 0; i < ARRAY_SIZE(trx->ts); i++) { - struct gsm_bts_trx_ts *ts = &trx->ts[i]; - int k; - - for (k = 0; k < ARRAY_SIZE(ts->lchan); k++) { - struct gsm_lchan *lchan = &ts->lchan[k]; - INIT_LLIST_HEAD(&lchan->dl_tch_queue); - } - } - /* Default values for the power adjustments */ - tpp->ramp.max_initial_pout_mdBm = to_mdB(0); - tpp->ramp.step_size_mdB = to_mdB(2); - tpp->ramp.step_interval_sec = 1; - } - /* allocate a talloc pool for ORTP to ensure it doesn't have to go back * to the libc malloc all the time */ tall_rtp_ctx = talloc_pool(tall_bts_ctx, 262144); @@ -215,6 +194,36 @@ int bts_init(struct gsm_bts *bts) return rc; } +/* Initialize the TRX data structures, called before config + * file reading */ +int bts_trx_init(struct gsm_bts_trx *trx) +{ + /* initialize bts data structure */ + struct trx_power_params *tpp = &trx->power_params; + int rc, i; + + for (i = 0; i < ARRAY_SIZE(trx->ts); i++) { + struct gsm_bts_trx_ts *ts = &trx->ts[i]; + int k; + + for (k = 0; k < ARRAY_SIZE(ts->lchan); k++) { + struct gsm_lchan *lchan = &ts->lchan[k]; + INIT_LLIST_HEAD(&lchan->dl_tch_queue); + } + } + /* Default values for the power adjustments */ + tpp->ramp.max_initial_pout_mdBm = to_mdB(0); + tpp->ramp.step_size_mdB = to_mdB(2); + tpp->ramp.step_interval_sec = 1; + + rc = bts_model_trx_init(trx); + if (rc < 0) { + llist_del(&trx->list); + return rc; + } + return 0; +} + static void shutdown_timer_cb(void *data) { fprintf(stderr, "Shutdown timer expired\n"); diff --git a/src/common/main.c b/src/common/main.c index 9121a2ab..f90a4d4d 100644 --- a/src/common/main.c +++ b/src/common/main.c @@ -59,7 +59,6 @@ int quit = 0; static const char *config_file = "osmo-bts.cfg"; static int daemonize = 0; static int rt_prio = -1; -static int trx_num = 1; static char *gsmtap_ip = 0; extern int g_vty_port_num; @@ -76,8 +75,6 @@ static void print_help() " -e --log-level Set a global log-level\n" " -r --realtime PRIO Use SCHED_RR with the specified priority\n" " -i --gsmtap-ip The destination IP used for GSMTAP.\n" - " -t --trx-num Set number of TRX (default=%d)\n", - trx_num ); bts_model_print_help(); } @@ -152,9 +149,8 @@ static void handle_options(int argc, char **argv) gsmtap_ip = optarg; break; case 't': - trx_num = atoi(optarg); - if (trx_num < 1) - trx_num = 1; + fprintf(stderr, "Parameter -t is deprecated and does nothing, " + "TRX num is calculated from VTY\n"); break; case '?': case 1: @@ -228,7 +224,7 @@ int bts_main(int argc, char **argv) { struct gsm_bts_trx *trx; struct e1inp_line *line; - int rc, i; + int rc; printf("((*))\n |\n / \\ OsmoBTS\n"); @@ -251,13 +247,7 @@ int bts_main(int argc, char **argv) fprintf(stderr, "Failed to create BTS structure\n"); exit(1); } - for (i = 1; i < trx_num; i++) { - trx = gsm_bts_trx_alloc(bts); - if (!trx) { - fprintf(stderr, "Failed to create TRX structure\n"); - exit(1); - } - } + e1inp_vty_init(); bts_vty_init(bts, &bts_log_info); diff --git a/src/common/vty.c b/src/common/vty.c index f918f576..f3054139 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -227,12 +227,22 @@ DEFUN(cfg_bts_trx, cfg_bts_trx_cmd, struct gsm_bts *bts = vty->index; struct gsm_bts_trx *trx; - trx = gsm_bts_trx_num(bts, trx_nr); + + if (trx_nr > bts->num_trx) { + vty_out(vty, "%% The next unused TRX number is %u%s", + bts->num_trx, VTY_NEWLINE); + return CMD_WARNING; + } else if (trx_nr == bts->num_trx) { + /* allocate a new one */ + trx = gsm_bts_trx_alloc(bts); + if (trx) + bts_trx_init(trx); + } else + trx = gsm_bts_trx_num(bts, trx_nr); + if (!trx) { - vty_out(vty, "Unknown TRX %u. Available TRX are: 0..%u%s", - trx_nr, bts->num_trx - 1, VTY_NEWLINE); - vty_out(vty, "Hint: Check if commandline option -t matches the" - "number of available transceivers!%s", VTY_NEWLINE); + vty_out(vty, "%% Unable to allocate TRX %u%s", + trx_nr, VTY_NEWLINE); return CMD_WARNING; } |