diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-07-03 16:43:51 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-07-05 18:18:16 +0200 |
commit | 9b47b27d4f388c417df10047edb79076c31bea69 (patch) | |
tree | 29e98001a1894563f43c1df5558e7abff8d189e0 /src | |
parent | 23fd316dea2b3f949d03d8578b920a3d4ff2f3a9 (diff) |
Move gsm_bts code gsm-data.* => bts.*
bts.h refers to struct gsm_bts object, but we still had a bunch of stuff
in bulky gsm_data.* from old days. Let's move stuff where it belongs to
start clean up of gsm_data.
Change-Id: I0a4219e3f64f625ee8b364bf408b8d2bcc8085c5
Diffstat (limited to 'src')
-rw-r--r-- | src/common/bts.c | 169 | ||||
-rw-r--r-- | src/common/bts_shutdown_fsm.c | 1 | ||||
-rw-r--r-- | src/common/gsm_data.c | 183 | ||||
-rw-r--r-- | src/common/load_indication.c | 1 | ||||
-rw-r--r-- | src/common/msg_utils.c | 1 | ||||
-rw-r--r-- | src/common/scheduler.c | 1 | ||||
-rw-r--r-- | src/common/sysinfo.c | 1 | ||||
-rw-r--r-- | src/osmo-bts-octphy/l1_if.c | 1 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/sysmobts_vty.c | 1 | ||||
-rw-r--r-- | src/osmo-bts-trx/trx_vty.c | 1 |
10 files changed, 183 insertions, 177 deletions
diff --git a/src/common/bts.c b/src/common/bts.c index dccb0986..2f6a7004 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -32,6 +32,7 @@ #include <osmocom/core/timer.h> #include <osmocom/core/msgb.h> #include <osmocom/core/talloc.h> +#include <osmocom/core/tdef.h> #include <osmocom/core/stats.h> #include <osmocom/core/rate_ctr.h> #include <osmocom/gsm/protocol/gsm_12_21.h> @@ -50,6 +51,7 @@ #include <osmo-bts/signal.h> #include <osmo-bts/dtx_dl_amr_fsm.h> #include <osmo-bts/cbch.h> +#include <osmo-bts/bts_shutdown_fsm.h> #define MIN_QUAL_RACH 50 /* minimum link quality (in centiBels) for Access Bursts */ #define MIN_QUAL_NORM -5 /* minimum link quality (in centiBels) for Normal Bursts */ @@ -122,6 +124,152 @@ static const struct rate_ctr_group_desc cbch_ctrg_desc = { cbch_ctr_desc }; +static struct osmo_tdef bts_T_defs[] = { + /* T-1: FIXME: Ideally should be dynamically calculated per trx at + * shutdown start based on params below, and highest trx value taken: + * + VTY's power-ramp step-interval. + * + Amount of steps needed (taking into account how many dB each step moves). + * + Extra time to get response back for each step. + * For now we simply give 5 mins, which should be enough for any + * acceptable setup, while still ensuring will timeout at some point if + * something fails in the ramp down procedure. + */ + { .T=-1, .default_val=300, .desc="Time after which osmo-bts exits if regular ramp down during shut down process does not finish (s)" }, + { .T=-2, .default_val=3, .desc="Time after which osmo-bts exits if requesting transceivers to stop during shut down process does not finish (s)" }, + {} +}; + +static const uint8_t bts_nse_timer_default[] = { 3, 3, 3, 3, 30, 3, 10 }; +static const uint8_t bts_cell_timer_default[] = + { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 }; +static const struct gprs_rlc_cfg rlc_cfg_default = { + .parameter = { + [RLC_T3142] = 20, + [RLC_T3169] = 5, + [RLC_T3191] = 5, + [RLC_T3193] = 160, /* 10ms */ + [RLC_T3195] = 5, + [RLC_N3101] = 10, + [RLC_N3103] = 4, + [RLC_N3105] = 8, + [CV_COUNTDOWN] = 15, + [T_DL_TBF_EXT] = 250 * 10, /* ms */ + [T_UL_TBF_EXT] = 250 * 10, /* ms */ + }, + .paging = { + .repeat_time = 5 * 50, /* ms */ + .repeat_count = 3, + }, + .cs_mask = 0x1fff, + .initial_cs = 2, + .initial_mcs = 6, +}; + +const struct value_string osmo_bts_variant_names[_NUM_BTS_VARIANT + 1] = { + { BTS_UNKNOWN, "unknown" }, + { BTS_OSMO_LITECELL15, "osmo-bts-lc15" }, + { BTS_OSMO_OC2G, "osmo-bts-oc2g" }, + { BTS_OSMO_OCTPHY, "osmo-bts-octphy" }, + { BTS_OSMO_SYSMO, "osmo-bts-sysmo" }, + { BTS_OSMO_TRX, "osmo-bts-trx" }, + { BTS_OSMO_VIRTUAL, "osmo-bts-virtual" }, + { BTS_OSMO_OMLDUMMY, "osmo-bts-omldummy" }, + { 0, NULL } +}; + +const char *btsvariant2str(enum gsm_bts_type_variant v) +{ + return get_value_string(osmo_bts_variant_names, v); +} + +const struct value_string bts_attribute_names[] = { + OSMO_VALUE_STRING(BTS_TYPE_VARIANT), + OSMO_VALUE_STRING(BTS_SUB_MODEL), + OSMO_VALUE_STRING(TRX_PHY_VERSION), + { 0, NULL } +}; + +const char *btsatttr2str(enum bts_attribute v) +{ + return get_value_string(bts_attribute_names, v); +} + +const struct value_string bts_impl_flag_desc[] = { + { BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP, "DSP/HW based MS Power Control Loop" }, + { BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB, "Measurement and Payload data combined" }, + { 0, NULL } +}; + +struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num) +{ + struct gsm_bts *bts = talloc_zero(ctx, struct gsm_bts); + int i; + + if (!bts) + return NULL; + + bts->nr = bts_num; + bts->num_trx = 0; + INIT_LLIST_HEAD(&bts->trx_list); + bts->ms_max_power = 15; /* dBm */ + + bts->T_defs = bts_T_defs; + osmo_tdefs_reset(bts->T_defs); + bts->shutdown_fi = osmo_fsm_inst_alloc(&bts_shutdown_fsm, bts, bts, + LOGL_INFO, NULL); + osmo_fsm_inst_update_id_f(bts->shutdown_fi, "bts%d", bts->nr); + + gsm_mo_init(&bts->mo, bts, NM_OC_BTS, + bts->nr, 0xff, 0xff); + gsm_mo_init(&bts->site_mgr.mo, bts, NM_OC_SITE_MANAGER, + 0xff, 0xff, 0xff); + + for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) { + bts->gprs.nsvc[i].bts = bts; + bts->gprs.nsvc[i].id = i; + gsm_mo_init(&bts->gprs.nsvc[i].mo, bts, NM_OC_GPRS_NSVC, + bts->nr, i, 0xff); + } + memcpy(&bts->gprs.nse.timer, bts_nse_timer_default, + sizeof(bts->gprs.nse.timer)); + gsm_mo_init(&bts->gprs.nse.mo, bts, NM_OC_GPRS_NSE, + bts->nr, 0xff, 0xff); + memcpy(&bts->gprs.cell.timer, bts_cell_timer_default, + sizeof(bts->gprs.cell.timer)); + gsm_mo_init(&bts->gprs.cell.mo, bts, NM_OC_GPRS_CELL, + bts->nr, 0xff, 0xff); + memcpy(&bts->gprs.cell.rlc_cfg, &rlc_cfg_default, + sizeof(bts->gprs.cell.rlc_cfg)); + + /* create our primary TRX. It will be initialized during bts_init() */ + bts->c0 = gsm_bts_trx_alloc(bts); + if (!bts->c0) { + talloc_free(bts); + return NULL; + } + bts->c0->ts[0].pchan = GSM_PCHAN_CCCH_SDCCH4; + + bts->features = bitvec_alloc(MAX_BTS_FEATURES / 8, bts); + OSMO_ASSERT(bts->features != NULL); + + return bts; +} + +struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num) +{ + struct gsm_bts *bts; + + if (num >= net->num_bts) + return NULL; + + llist_for_each_entry(bts, &net->bts_list, list) { + if (bts->nr == num) + return bts; + } + + return NULL; +} + /* Initialize the BTS data structures, called before config * file reading */ int bts_init(struct gsm_bts *bts) @@ -817,3 +965,24 @@ int bts_supports_cm(struct gsm_bts *bts, enum gsm_phys_chan_config pchan, return 0; } + +/* return the gsm_lchan for the CBCH (if it exists at all) */ +struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts) +{ + struct gsm_lchan *lchan = NULL; + struct gsm_bts_trx *trx = bts->c0; + + if (trx->ts[0].pchan == GSM_PCHAN_CCCH_SDCCH4_CBCH) + lchan = &trx->ts[0].lchan[2]; + else { + int i; + for (i = 0; i < 8; i++) { + if (trx->ts[i].pchan == GSM_PCHAN_SDCCH8_SACCH8C_CBCH) { + lchan = &trx->ts[i].lchan[2]; + break; + } + } + } + + return lchan; +} diff --git a/src/common/bts_shutdown_fsm.c b/src/common/bts_shutdown_fsm.c index d55b1cd4..c81a4ab1 100644 --- a/src/common/bts_shutdown_fsm.c +++ b/src/common/bts_shutdown_fsm.c @@ -28,6 +28,7 @@ #include <osmo-bts/logging.h> #include <osmo-bts/gsm_data.h> #include <osmo-bts/bts_model.h> +#include <osmo-bts/bts.h> #define X(s) (1 << (s)) diff --git a/src/common/gsm_data.c b/src/common/gsm_data.c index 57f33ae0..c63793c6 100644 --- a/src/common/gsm_data.c +++ b/src/common/gsm_data.c @@ -30,74 +30,13 @@ #include <osmocom/core/talloc.h> #include <osmocom/core/statistics.h> #include <osmocom/core/fsm.h> -#include <osmocom/core/tdef.h> #include <osmocom/gsm/gsm_utils.h> #include <osmocom/gsm/abis_nm.h> #include <osmocom/codec/ecu.h> #include <osmo-bts/gsm_data.h> -#include <osmo-bts/bts_shutdown_fsm.h> - -static struct osmo_tdef bts_T_defs[] = { - /* T-1: FIXME: Ideally should be dynamically calculated per trx at - * shutdown start based on params below, and highest trx value taken: - * + VTY's power-ramp step-interval. - * + Amount of steps needed (taking into account how many dB each step moves). - * + Extra time to get response back for each step. - * For now we simply give 5 mins, which should be enough for any - * acceptable setup, while still ensuring will timeout at some point if - * something fails in the ramp down procedure. - */ - { .T=-1, .default_val=300, .desc="Time after which osmo-bts exits if regular ramp down during shut down process does not finish (s)" }, - { .T=-2, .default_val=3, .desc="Time after which osmo-bts exits if requesting transceivers to stop during shut down process does not finish (s)" }, - {} -}; - -const struct value_string bts_attribute_names[] = { - OSMO_VALUE_STRING(BTS_TYPE_VARIANT), - OSMO_VALUE_STRING(BTS_SUB_MODEL), - OSMO_VALUE_STRING(TRX_PHY_VERSION), - { 0, NULL } -}; - -enum bts_attribute str2btsattr(const char *s) -{ - return get_string_value(bts_attribute_names, s); -} - -const char *btsatttr2str(enum bts_attribute v) -{ - return get_value_string(bts_attribute_names, v); -} - -const struct value_string osmo_bts_variant_names[_NUM_BTS_VARIANT + 1] = { - { BTS_UNKNOWN, "unknown" }, - { BTS_OSMO_LITECELL15, "osmo-bts-lc15" }, - { BTS_OSMO_OC2G, "osmo-bts-oc2g" }, - { BTS_OSMO_OCTPHY, "osmo-bts-octphy" }, - { BTS_OSMO_SYSMO, "osmo-bts-sysmo" }, - { BTS_OSMO_TRX, "osmo-bts-trx" }, - { BTS_OSMO_VIRTUAL, "osmo-bts-virtual" }, - { BTS_OSMO_OMLDUMMY, "osmo-bts-omldummy" }, - { 0, NULL } -}; - -enum gsm_bts_type_variant str2btsvariant(const char *arg) -{ - return get_string_value(osmo_bts_variant_names, arg); -} - -const char *btsvariant2str(enum gsm_bts_type_variant v) -{ - return get_value_string(osmo_bts_variant_names, v); -} - -const struct value_string bts_impl_flag_desc[] = { - { BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP, "DSP/HW based MS Power Control Loop" }, - { BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB, "Measurement and Payload data combined" }, - { 0, NULL } -}; +#include <osmo-bts/bts.h> const struct value_string gsm_pchant_names[13] = { { GSM_PCHAN_NONE, "NONE" }, @@ -164,21 +103,6 @@ const char *gsm_lchans_name(enum gsm_lchan_state s) return get_value_string(lchan_s_names, s); } -struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num) -{ - struct gsm_bts *bts; - - if (num >= net->num_bts) - return NULL; - - llist_for_each_entry(bts, &net->bts_list, list) { - if (bts->nr == num) - return bts; - } - - return NULL; -} - struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts) { struct gsm_bts_trx *trx = talloc_zero(bts, struct gsm_bts_trx); @@ -233,88 +157,6 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts) return trx; } - -static const uint8_t bts_nse_timer_default[] = { 3, 3, 3, 3, 30, 3, 10 }; -static const uint8_t bts_cell_timer_default[] = - { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 }; -static const struct gprs_rlc_cfg rlc_cfg_default = { - .parameter = { - [RLC_T3142] = 20, - [RLC_T3169] = 5, - [RLC_T3191] = 5, - [RLC_T3193] = 160, /* 10ms */ - [RLC_T3195] = 5, - [RLC_N3101] = 10, - [RLC_N3103] = 4, - [RLC_N3105] = 8, - [CV_COUNTDOWN] = 15, - [T_DL_TBF_EXT] = 250 * 10, /* ms */ - [T_UL_TBF_EXT] = 250 * 10, /* ms */ - }, - .paging = { - .repeat_time = 5 * 50, /* ms */ - .repeat_count = 3, - }, - .cs_mask = 0x1fff, - .initial_cs = 2, - .initial_mcs = 6, -}; - -struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num) -{ - struct gsm_bts *bts = talloc_zero(ctx, struct gsm_bts); - int i; - - if (!bts) - return NULL; - - bts->nr = bts_num; - bts->num_trx = 0; - INIT_LLIST_HEAD(&bts->trx_list); - bts->ms_max_power = 15; /* dBm */ - - bts->T_defs = bts_T_defs; - osmo_tdefs_reset(bts->T_defs); - bts->shutdown_fi = osmo_fsm_inst_alloc(&bts_shutdown_fsm, bts, bts, - LOGL_INFO, NULL); - osmo_fsm_inst_update_id_f(bts->shutdown_fi, "bts%d", bts->nr); - - gsm_mo_init(&bts->mo, bts, NM_OC_BTS, - bts->nr, 0xff, 0xff); - gsm_mo_init(&bts->site_mgr.mo, bts, NM_OC_SITE_MANAGER, - 0xff, 0xff, 0xff); - - for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) { - bts->gprs.nsvc[i].bts = bts; - bts->gprs.nsvc[i].id = i; - gsm_mo_init(&bts->gprs.nsvc[i].mo, bts, NM_OC_GPRS_NSVC, - bts->nr, i, 0xff); - } - memcpy(&bts->gprs.nse.timer, bts_nse_timer_default, - sizeof(bts->gprs.nse.timer)); - gsm_mo_init(&bts->gprs.nse.mo, bts, NM_OC_GPRS_NSE, - bts->nr, 0xff, 0xff); - memcpy(&bts->gprs.cell.timer, bts_cell_timer_default, - sizeof(bts->gprs.cell.timer)); - gsm_mo_init(&bts->gprs.cell.mo, bts, NM_OC_GPRS_CELL, - bts->nr, 0xff, 0xff); - memcpy(&bts->gprs.cell.rlc_cfg, &rlc_cfg_default, - sizeof(bts->gprs.cell.rlc_cfg)); - - /* create our primary TRX. It will be initialized during bts_init() */ - bts->c0 = gsm_bts_trx_alloc(bts); - if (!bts->c0) { - talloc_free(bts); - return NULL; - } - bts->c0->ts[0].pchan = GSM_PCHAN_CCCH_SDCCH4; - - bts->features = bitvec_alloc(MAX_BTS_FEATURES / 8, bts); - OSMO_ASSERT(bts->features != NULL); - - return bts; -} - struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num) { struct gsm_bts_trx *trx; @@ -499,25 +341,12 @@ uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan, return gsm_pchan2chan_nr(as_pchan, lchan->ts->nr, lchan->nr); } -/* return the gsm_lchan for the CBCH (if it exists at all) */ -struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts) +uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts) { - struct gsm_lchan *lchan = NULL; - struct gsm_bts_trx *trx = bts->c0; - - if (trx->ts[0].pchan == GSM_PCHAN_CCCH_SDCCH4_CBCH) - lchan = &trx->ts[0].lchan[2]; - else { - int i; - for (i = 0; i < 8; i++) { - if (trx->ts[i].pchan == GSM_PCHAN_SDCCH8_SACCH8C_CBCH) { - lchan = &trx->ts[i].lchan[2]; - break; - } - } - } - - return lchan; + if (ts->tsc != -1) + return ts->tsc; + else + return ts->trx->bts->bsic & 7; } /* determine logical channel based on TRX and channel number IE */ diff --git a/src/common/load_indication.c b/src/common/load_indication.c index 8d9b56f8..c9b26458 100644 --- a/src/common/load_indication.c +++ b/src/common/load_indication.c @@ -27,6 +27,7 @@ #include <osmo-bts/gsm_data.h> #include <osmo-bts/rsl.h> #include <osmo-bts/paging.h> +#include <osmo-bts/bts.h> static void reset_load_counters(struct gsm_bts *bts) { diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c index 52b05668..1817849f 100644 --- a/src/common/msg_utils.c +++ b/src/common/msg_utils.c @@ -23,6 +23,7 @@ #include <osmo-bts/oml.h> #include <osmo-bts/amr.h> #include <osmo-bts/rsl.h> +#include <osmo-bts/bts.h> #include <osmocom/gsm/protocol/ipaccess.h> #include <osmocom/gsm/protocol/gsm_12_21.h> diff --git a/src/common/scheduler.c b/src/common/scheduler.c index 30689186..7375a1ae 100644 --- a/src/common/scheduler.c +++ b/src/common/scheduler.c @@ -42,6 +42,7 @@ #include <osmo-bts/l1sap.h> #include <osmo-bts/scheduler.h> #include <osmo-bts/scheduler_backend.h> +#include <osmo-bts/bts.h> extern void *tall_bts_ctx; diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index f5bc3c88..4a86c4e7 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -25,6 +25,7 @@ #include <osmo-bts/logging.h> #include <osmo-bts/gsm_data.h> #include <osmo-bts/pcu_if.h> +#include <osmo-bts/bts.h> /* properly increment SI2q index and return SI2q data for scheduling */ static inline uint8_t *get_si2q_inc_index(struct gsm_bts *bts) diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c index 0adc8fee..c03b4112 100644 --- a/src/osmo-bts-octphy/l1_if.c +++ b/src/osmo-bts-octphy/l1_if.c @@ -43,6 +43,7 @@ #include <osmo-bts/logging.h> #include <osmo-bts/l1sap.h> #include <osmo-bts/handover.h> +#include <osmo-bts/bts.h> #include "l1_if.h" #include "l1_oml.h" diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index 0653f01b..7876612d 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -45,6 +45,7 @@ #include <osmo-bts/bts_model.h> #include <osmo-bts/vty.h> #include <osmo-bts/rsl.h> +#include <osmo-bts/bts.h> #include "femtobts.h" #include "l1_if.h" diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c index 2e529588..fb75a4e5 100644 --- a/src/osmo-bts-trx/trx_vty.c +++ b/src/osmo-bts-trx/trx_vty.c @@ -42,6 +42,7 @@ #include <osmo-bts/logging.h> #include <osmo-bts/vty.h> #include <osmo-bts/scheduler.h> +#include <osmo-bts/bts.h> #include "l1_if.h" #include "trx_if.h" |