diff --git a/include/osmocom/bsc/bsc_stats.h b/include/osmocom/bsc/bsc_stats.h index 801a2c153..edd36b656 100644 --- a/include/osmocom/bsc/bsc_stats.h +++ b/include/osmocom/bsc/bsc_stats.h @@ -110,4 +110,5 @@ enum { extern const struct osmo_stat_item_group_desc bsc_statg_desc; void bsc_update_connection_stats(struct gsm_network *net); -void bsc_update_time_cc_all_allocated(struct gsm_network *net); + +void all_allocated_update_bsc(); diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h index 5a67791f5..fc3ebce12 100644 --- a/include/osmocom/bsc/bts.h +++ b/include/osmocom/bsc/bts.h @@ -637,10 +637,7 @@ struct gsm_bts { /* At what point in the channel allocation sequence to dispatch the Immediate Assignment (Abis optimization) */ enum imm_ass_time imm_ass_time; - struct osmo_time_cc all_allocated_sdcch; - struct osmo_time_cc all_allocated_static_sdcch; - struct osmo_time_cc all_allocated_tch; - struct osmo_time_cc all_allocated_static_tch; + struct all_allocated all_allocated; }; #define GSM_BTS_SI2Q(bts, i) (struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater][i]) diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 6abe94332..88c6474c9 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -1203,6 +1203,13 @@ struct gsm_tz { int dst; /* daylight savings */ }; +struct all_allocated { + struct osmo_time_cc sdcch; + struct osmo_time_cc static_sdcch; + struct osmo_time_cc tch; + struct osmo_time_cc static_tch; +}; + struct gsm_network { struct osmo_plmn_id plmn; @@ -1313,10 +1320,7 @@ struct gsm_network { struct smlc_config *smlc; - struct osmo_time_cc all_allocated_sdcch; - struct osmo_time_cc all_allocated_static_sdcch; - struct osmo_time_cc all_allocated_tch; - struct osmo_time_cc all_allocated_static_tch; + struct all_allocated all_allocated; }; struct gsm_audio_support { diff --git a/src/osmo-bsc/bsc_init.c b/src/osmo-bsc/bsc_init.c index 650a76ba8..c381c0f09 100644 --- a/src/osmo-bsc/bsc_init.c +++ b/src/osmo-bsc/bsc_init.c @@ -132,7 +132,7 @@ static struct gsm_network *bsc_network_init(void *ctx) if (!net->bts_unknown_statg) goto err_free_all; - net->all_allocated_sdcch = (struct osmo_time_cc){ + net->all_allocated.sdcch = (struct osmo_time_cc){ .cfg = { .gran_usec = 1*1000000, .forget_sum_usec = 60*1000000, @@ -143,7 +143,7 @@ static struct gsm_network *bsc_network_init(void *ctx) .T_defs = net->T_defs, }, }; - net->all_allocated_static_sdcch = (struct osmo_time_cc){ + net->all_allocated.static_sdcch = (struct osmo_time_cc){ .cfg = { .gran_usec = 1*1000000, .forget_sum_usec = 60*1000000, @@ -154,7 +154,7 @@ static struct gsm_network *bsc_network_init(void *ctx) .T_defs = net->T_defs, }, }; - net->all_allocated_tch = (struct osmo_time_cc){ + net->all_allocated.tch = (struct osmo_time_cc){ .cfg = { .gran_usec = 1*1000000, .forget_sum_usec = 60*1000000, @@ -165,7 +165,7 @@ static struct gsm_network *bsc_network_init(void *ctx) .T_defs = net->T_defs, }, }; - net->all_allocated_static_tch = (struct osmo_time_cc){ + net->all_allocated.static_tch = (struct osmo_time_cc){ .cfg = { .gran_usec = 1*1000000, .forget_sum_usec = 60*1000000, diff --git a/src/osmo-bsc/bsc_stats.c b/src/osmo-bsc/bsc_stats.c index b48c90a00..e540f299f 100644 --- a/src/osmo-bsc/bsc_stats.c +++ b/src/osmo-bsc/bsc_stats.c @@ -195,67 +195,46 @@ void bsc_update_connection_stats(struct gsm_network *net) osmo_stat_item_set(osmo_stat_item_group_get_item(net->bsc_statg, BSC_STAT_NUM_TRX_TOTAL), num_trx_total); /* Make sure to notice cells that become disconnected */ - bsc_update_time_cc_all_allocated(net); + all_allocated_update_bsc(); } -void bsc_update_time_cc_all_allocated(struct gsm_network *net) +static void all_allocated_update(struct all_allocated *all_allocated, const struct chan_counts *c) { - struct gsm_bts *bts; - struct gsm_bts_trx *trx; + osmo_time_cc_set_flag(&all_allocated->sdcch, + c->val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_SDCCH] + && !c->val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_FREE][GSM_LCHAN_SDCCH]); + osmo_time_cc_set_flag(&all_allocated->static_sdcch, + c->val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_SDCCH] + && !c->val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_FREE][GSM_LCHAN_SDCCH]); + + osmo_time_cc_set_flag(&all_allocated->tch, + (c->val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_F] + + c->val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_H]) + && !(c->val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_F] + + c->val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_H])); + + osmo_time_cc_set_flag(&all_allocated->static_tch, + (c->val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_F] + + c->val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_H]) + && !(c->val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_F] + + c->val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_H])); +} + +void all_allocated_update_bsc() +{ + struct gsm_network *net = bsc_gsmnet; + struct gsm_bts *bts; struct chan_counts bsc_counts; + chan_counts_zero(&bsc_counts); llist_for_each_entry(bts, &net->bts_list, list) { struct chan_counts bts_counts; - chan_counts_zero(&bts_counts); - - llist_for_each_entry(trx, &bts->trx_list, list) { - struct chan_counts trx_counts; - chan_counts_for_trx(&trx_counts, trx); - chan_counts_add(&bts_counts, &trx_counts); - } - - osmo_time_cc_set_flag(&bts->all_allocated_sdcch, - bts_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_SDCCH] - && !bts_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_FREE][GSM_LCHAN_SDCCH]); - - osmo_time_cc_set_flag(&bts->all_allocated_static_sdcch, - bts_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_SDCCH] - && !bts_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_FREE][GSM_LCHAN_SDCCH]); - - osmo_time_cc_set_flag(&bts->all_allocated_tch, - (bts_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_F] - + bts_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_H]) - && !(bts_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_F] - + bts_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_H])); - - osmo_time_cc_set_flag(&bts->all_allocated_static_tch, - (bts_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_F] - + bts_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_H]) - && !(bts_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_F] - + bts_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_H])); - + chan_counts_for_bts(&bts_counts, bts); + all_allocated_update(&bts->all_allocated, &bts_counts); chan_counts_add(&bsc_counts, &bts_counts); } - osmo_time_cc_set_flag(&net->all_allocated_sdcch, - bsc_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_SDCCH] - && !bsc_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_FREE][GSM_LCHAN_SDCCH]); - - osmo_time_cc_set_flag(&net->all_allocated_static_sdcch, - bsc_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_SDCCH] - && !bsc_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_FREE][GSM_LCHAN_SDCCH]); - - osmo_time_cc_set_flag(&net->all_allocated_tch, - (bsc_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_F] - + bsc_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_H]) - && !(bsc_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_F] - + bsc_counts.val[CHAN_COUNTS1_ALL][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_H])); - - osmo_time_cc_set_flag(&net->all_allocated_static_tch, - (bsc_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_F] - + bsc_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_MAX_TOTAL][GSM_LCHAN_TCH_H]) - && !(bsc_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_F] - + bsc_counts.val[CHAN_COUNTS1_STATIC][CHAN_COUNTS2_FREE][GSM_LCHAN_TCH_H])); + all_allocated_update(&net->all_allocated, &bsc_counts); } diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c index ad46f54f9..d0adb2a3f 100644 --- a/src/osmo-bsc/bts.c +++ b/src/osmo-bsc/bts.c @@ -216,7 +216,7 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, struct gsm_bts_sm *bts_sm } bts->bts_statg = osmo_stat_item_group_alloc(bts, &bts_statg_desc, bts->nr); - bts->all_allocated_sdcch = (struct osmo_time_cc){ + bts->all_allocated.sdcch = (struct osmo_time_cc){ .cfg = { .gran_usec = 1*1000000, .forget_sum_usec = 60*1000000, @@ -227,7 +227,7 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, struct gsm_bts_sm *bts_sm .T_defs = net->T_defs, }, }; - bts->all_allocated_static_sdcch = (struct osmo_time_cc){ + bts->all_allocated.static_sdcch = (struct osmo_time_cc){ .cfg = { .gran_usec = 1*1000000, .forget_sum_usec = 60*1000000, @@ -238,7 +238,7 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, struct gsm_bts_sm *bts_sm .T_defs = net->T_defs, }, }; - bts->all_allocated_tch = (struct osmo_time_cc){ + bts->all_allocated.tch = (struct osmo_time_cc){ .cfg = { .gran_usec = 1*1000000, .forget_sum_usec = 60*1000000, @@ -249,7 +249,7 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, struct gsm_bts_sm *bts_sm .T_defs = net->T_defs, }, }; - bts->all_allocated_static_tch = (struct osmo_time_cc){ + bts->all_allocated.static_tch = (struct osmo_time_cc){ .cfg = { .gran_usec = 1*1000000, .forget_sum_usec = 60*1000000, diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c index 1c85ff30e..e3ae4a67f 100644 --- a/src/osmo-bsc/lchan_fsm.c +++ b/src/osmo-bsc/lchan_fsm.c @@ -525,7 +525,7 @@ static void lchan_fsm_unused_onenter(struct osmo_fsm_inst *fi, uint32_t prev_sta lchan_reset(lchan); osmo_fsm_inst_dispatch(lchan->ts->fi, TS_EV_LCHAN_UNUSED, lchan); - bsc_update_time_cc_all_allocated(bts->network); + all_allocated_update_bsc(); /* Poll the channel request queue, so that waiting calls can make use of the lchan that just * has become unused now. */ @@ -707,7 +707,7 @@ static void lchan_fsm_wait_ts_ready_onenter(struct osmo_fsm_inst *fi, uint32_t p return; } - bsc_update_time_cc_all_allocated(bts->network); + all_allocated_update_bsc(); lchan->conn = info->for_conn;