aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmo-bts/bts.h1
-rw-r--r--include/osmo-bts/bts_model.h1
-rw-r--r--src/common/bts.c53
-rw-r--r--src/common/main.c18
-rw-r--r--src/common/vty.c20
-rw-r--r--src/osmo-bts-litecell15/main.c12
-rw-r--r--src/osmo-bts-oc2g/main.c12
-rw-r--r--src/osmo-bts-octphy/l1_if.c5
-rw-r--r--src/osmo-bts-omldummy/bts_model.c5
-rw-r--r--src/osmo-bts-sysmo/main.c5
-rw-r--r--src/osmo-bts-trx/main.c5
-rw-r--r--src/osmo-bts-virtual/main.c5
-rw-r--r--tests/handover/handover_test.c13
-rw-r--r--tests/meas/meas_test.c17
-rw-r--r--tests/stubs.c2
-rw-r--r--tests/sysmobts/sysmobts_test.c2
16 files changed, 117 insertions, 59 deletions
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index 34ba9568..d7c4bbf3 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -27,6 +27,7 @@ enum {
extern void *tall_bts_ctx;
int bts_init(struct gsm_bts *bts);
+int bts_trx_init(struct gsm_bts_trx *trx);
void bts_shutdown(struct gsm_bts *bts, const char *reason);
struct gsm_bts *create_bts(uint8_t num_trx, char *id);
diff --git a/include/osmo-bts/bts_model.h b/include/osmo-bts/bts_model.h
index 7a87d786..f1f68307 100644
--- a/include/osmo-bts/bts_model.h
+++ b/include/osmo-bts/bts_model.h
@@ -14,6 +14,7 @@ struct phy_instance;
/* BTS model specific functions needed by the common code */
int bts_model_init(struct gsm_bts *bts);
+int bts_model_trx_init(struct gsm_bts_trx *trx);
int bts_model_check_oml(struct gsm_bts *bts, uint8_t msg_type,
struct tlv_parsed *old_attr, struct tlv_parsed *new_attr,
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;
}
diff --git a/src/osmo-bts-litecell15/main.c b/src/osmo-bts-litecell15/main.c
index de175e34..e4f9a567 100644
--- a/src/osmo-bts-litecell15/main.c
+++ b/src/osmo-bts-litecell15/main.c
@@ -79,11 +79,6 @@ int bts_model_init(struct gsm_bts *bts)
exit(1);
}
- llist_for_each_entry(trx, &bts->trx_list, list) {
- trx->nominal_power = 40;
- trx->power_params.trx_p_max_out_mdBm = to_mdB(bts->c0->nominal_power);
- }
-
if (stat(LC15BTS_RF_LOCK_PATH, &st) == 0) {
LOGP(DL1C, LOGL_NOTICE, "Not starting BTS due to RF_LOCK file present\n");
exit(23);
@@ -104,6 +99,13 @@ int bts_model_init(struct gsm_bts *bts)
return 0;
}
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{
+ trx->nominal_power = 40;
+ trx->power_params.trx_p_max_out_mdBm = to_mdB(trx->bts->c0->nominal_power);
+ return 0;
+}
+
void bts_model_phy_link_set_defaults(struct phy_link *plink)
{
}
diff --git a/src/osmo-bts-oc2g/main.c b/src/osmo-bts-oc2g/main.c
index 9777c092..574bc723 100644
--- a/src/osmo-bts-oc2g/main.c
+++ b/src/osmo-bts-oc2g/main.c
@@ -105,11 +105,6 @@ int bts_model_init(struct gsm_bts *bts)
exit(1);
}
- llist_for_each_entry(trx, &bts->trx_list, list) {
- trx->nominal_power = 40;
- trx->power_params.trx_p_max_out_mdBm = to_mdB(bts->c0->nominal_power);
- }
-
if (stat(OC2GBTS_RF_LOCK_PATH, &st) == 0) {
LOGP(DL1C, LOGL_NOTICE, "Not starting BTS due to RF_LOCK file present\n");
exit(23);
@@ -130,6 +125,13 @@ int bts_model_init(struct gsm_bts *bts)
return 0;
}
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{
+ trx->nominal_power = 40;
+ trx->power_params.trx_p_max_out_mdBm = to_mdB(trx->bts->c0->nominal_power);
+ return 0;
+}
+
void bts_model_phy_link_set_defaults(struct phy_link *plink)
{
}
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 40d5300d..f149c048 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -792,6 +792,11 @@ int bts_model_init(struct gsm_bts *bts)
return 0;
}
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{
+ return 0;
+}
+
/***********************************************************************
* handling of messages coming up from PHY
***********************************************************************/
diff --git a/src/osmo-bts-omldummy/bts_model.c b/src/osmo-bts-omldummy/bts_model.c
index 9ade2c6c..fa1aaf4c 100644
--- a/src/osmo-bts-omldummy/bts_model.c
+++ b/src/osmo-bts-omldummy/bts_model.c
@@ -179,6 +179,11 @@ int bts_model_init(struct gsm_bts *bts)
return 0;
}
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{
+ return 0;
+}
+
void bts_model_print_help()
{
}
diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c
index b63d07ef..221e8e8a 100644
--- a/src/osmo-bts-sysmo/main.c
+++ b/src/osmo-bts-sysmo/main.c
@@ -91,6 +91,11 @@ int bts_model_init(struct gsm_bts *bts)
return 0;
}
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{
+ return 0;
+}
+
int bts_model_oml_estab(struct gsm_bts *bts)
{
return 0;
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index 61610f73..98f460eb 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -118,6 +118,11 @@ int bts_model_init(struct gsm_bts *bts)
return 0;
}
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{
+ return 0;
+}
+
void bts_model_phy_link_set_defaults(struct phy_link *plink)
{
plink->u.osmotrx.local_ip = talloc_strdup(plink, "127.0.0.1");
diff --git a/src/osmo-bts-virtual/main.c b/src/osmo-bts-virtual/main.c
index b66a3ff9..88041fd3 100644
--- a/src/osmo-bts-virtual/main.c
+++ b/src/osmo-bts-virtual/main.c
@@ -72,6 +72,11 @@ int bts_model_init(struct gsm_bts *bts)
return 0;
}
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{
+ return 0;
+}
+
void bts_model_print_help()
{
LOGP(DSUM, LOGL_NOTICE, "Unimplemented %s\n", __func__);
diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c
index c7bd8f8d..407ed95d 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -75,14 +75,18 @@ int main(int argc, char **argv)
fprintf(stderr, "Failed to create BTS structure\n");
exit(1);
}
+ if (bts_init(bts) < 0) {
+ fprintf(stderr, "unable to init BTS\n");
+ exit(1);
+ }
+
trx = gsm_bts_trx_alloc(bts);
if (!trx) {
- fprintf(stderr, "Failed to TRX structure\n");
+ fprintf(stderr, "Failed to alloc TRX structure\n");
exit(1);
}
-
- if (bts_init(bts) < 0) {
- fprintf(stderr, "unable to to open bts\n");
+ if (bts_trx_init(trx) < 0) {
+ fprintf(stderr, "unable to init TRX\n");
exit(1);
}
@@ -268,6 +272,7 @@ int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg, struct tlv_parsed
int bts_model_opstart(struct gsm_bts *bts, struct gsm_abis_mo *mo, void *obj) { return 0; }
int bts_model_chg_adm_state(struct gsm_bts *bts, struct gsm_abis_mo *mo, void *obj, uint8_t adm_state) { return 0; }
int bts_model_init(struct gsm_bts *bts) { return 0; }
+int bts_model_trx_init(struct gsm_bts_trx *trx) { return 0; }
int bts_model_trx_deact_rf(struct gsm_bts_trx *trx) { return 0; }
int bts_model_trx_close(struct gsm_bts_trx *trx) { return 0; }
void trx_get_hlayer1(void) {}
diff --git a/tests/meas/meas_test.c b/tests/meas/meas_test.c
index d4f3fe68..f5803743 100644
--- a/tests/meas/meas_test.c
+++ b/tests/meas/meas_test.c
@@ -519,14 +519,18 @@ int main(int argc, char **argv)
fprintf(stderr, "Failed to create BTS structure\n");
exit(1);
}
+ if (bts_init(bts) < 0) {
+ fprintf(stderr, "unable to init BTS\n");
+ exit(1);
+ }
+
trx = gsm_bts_trx_alloc(bts);
if (!trx) {
- fprintf(stderr, "Failed to TRX structure\n");
+ fprintf(stderr, "Failed to alloc TRX structure\n");
exit(1);
}
-
- if (bts_init(bts) < 0) {
- fprintf(stderr, "unable to to open bts\n");
+ if (bts_trx_init(trx) < 0) {
+ fprintf(stderr, "unable to init TRX\n");
exit(1);
}
@@ -626,6 +630,11 @@ int bts_model_init(struct gsm_bts *bts)
return 0;
}
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{
+ return 0;
+}
+
int bts_model_trx_deact_rf(struct gsm_bts_trx *trx)
{
return 0;
diff --git a/tests/stubs.c b/tests/stubs.c
index f969cb3c..d6f4d3d8 100644
--- a/tests/stubs.c
+++ b/tests/stubs.c
@@ -13,6 +13,8 @@ int bts_model_chg_adm_state(struct gsm_bts *bts, struct gsm_abis_mo *mo,
{ return 0; }
int bts_model_init(struct gsm_bts *bts)
{ return 0; }
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{ return 0; }
int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg,
struct tlv_parsed *new_attr, int kind, void *obj)
{ return 0; }
diff --git a/tests/sysmobts/sysmobts_test.c b/tests/sysmobts/sysmobts_test.c
index 02490bef..4b01ed7a 100644
--- a/tests/sysmobts/sysmobts_test.c
+++ b/tests/sysmobts/sysmobts_test.c
@@ -198,6 +198,8 @@ void bts_update_status(enum bts_global_status which, int on)
int bts_model_init(struct gsm_bts *bts)
{ return 0; }
+int bts_model_trx_init(struct gsm_bts_trx *trx)
+{ return 0; }
int bts_model_oml_estab(struct gsm_bts *bts)
{ return 0; }
void bts_model_abis_close(struct gsm_bts *bts)