neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/28204 )
Change subject: code cleanup for all_allocated timers, no functional change ......................................................................
code cleanup for all_allocated timers, no functional change
Reduce some code dup in all_allocated accounting and cosmetically prepare for upcoming performance fix.
Have a struct all_allocated, allow easy re-use of function all_allocated_update().
Rename function to all_allocated_update_bsc(). Upcoming patch will also add all_allocated_update_bts().
Related: SYS#5976 Change-Id: Id7a82c65d56a87818fc35bbeedf67e2af2f89f11 --- M include/osmocom/bsc/bsc_stats.h M include/osmocom/bsc/bts.h M include/osmocom/bsc/gsm_data.h M src/osmo-bsc/bsc_init.c M src/osmo-bsc/bsc_stats.c M src/osmo-bsc/bts.c M src/osmo-bsc/lchan_fsm.c 7 files changed, 50 insertions(+), 70 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/04/28204/1
diff --git a/include/osmocom/bsc/bsc_stats.h b/include/osmocom/bsc/bsc_stats.h index 801a2c1..edd36b6 100644 --- a/include/osmocom/bsc/bsc_stats.h +++ b/include/osmocom/bsc/bsc_stats.h @@ -110,4 +110,5 @@ 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 5a67791..fc3ebce 100644 --- a/include/osmocom/bsc/bts.h +++ b/include/osmocom/bsc/bts.h @@ -637,10 +637,7 @@ /* 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 6abe943..88c6474 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -1203,6 +1203,13 @@ 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 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 650a76b..c381c0f 100644 --- a/src/osmo-bsc/bsc_init.c +++ b/src/osmo-bsc/bsc_init.c @@ -132,7 +132,7 @@ 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 @@ .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 @@ .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 @@ .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 b48c90a..2632ac8 100644 --- a/src/osmo-bsc/bsc_stats.c +++ b/src/osmo-bsc/bsc_stats.c @@ -195,67 +195,45 @@ 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 ad46f54..d0adb2a 100644 --- a/src/osmo-bsc/bts.c +++ b/src/osmo-bsc/bts.c @@ -216,7 +216,7 @@ } 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 @@ .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 @@ .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 @@ .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 1c85ff3..e3ae4a6 100644 --- a/src/osmo-bsc/lchan_fsm.c +++ b/src/osmo-bsc/lchan_fsm.c @@ -525,7 +525,7 @@ 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 @@ return; }
- bsc_update_time_cc_all_allocated(bts->network); + all_allocated_update_bsc();
lchan->conn = info->for_conn;