From 7c4a22dbc48f51eb199766bf1b29e061bf765cbd Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 17 Mar 2018 11:47:47 +0100 Subject: cosmetic: Move agch_queue to sub-structure of gsm_bts_role_bts Rathert han have 11 direct members of gsm_bts_role_bts, group them into a sub-struct as ew do for other parts like interference, laod, ... Change-Id: Iefecf4b70c1b11c650913f2ae3783718ffb8a36c --- include/osmo-bts/gsm_data.h | 30 ++++++++++++----------- src/common/bts.c | 60 ++++++++++++++++++++++----------------------- src/common/vty.c | 30 +++++++++++------------ tests/agch/agch_test.c | 24 +++++++++--------- 4 files changed, 73 insertions(+), 71 deletions(-) diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h index 16521044..31879b9b 100644 --- a/include/osmo-bts/gsm_data.h +++ b/include/osmo-bts/gsm_data.h @@ -69,20 +69,22 @@ struct gsm_bts_role_bts { uint8_t max_ta; /* AGCH queuing */ - struct llist_head agch_queue; - int agch_queue_length; - int agch_max_queue_length; - - int agch_queue_thresh_level; /* Cleanup threshold in percent of max len */ - int agch_queue_low_level; /* Low water mark in percent of max len */ - int agch_queue_high_level; /* High water mark in percent of max len */ - - /* TODO: Use a rate counter group instead */ - uint64_t agch_queue_dropped_msgs; - uint64_t agch_queue_merged_msgs; - uint64_t agch_queue_rejected_msgs; - uint64_t agch_queue_agch_msgs; - uint64_t agch_queue_pch_msgs; + struct { + struct llist_head queue; + int length; + int max_length; + + int thresh_level; /* Cleanup threshold in percent of max len */ + int low_level; /* Low water mark in percent of max len */ + int high_level; /* High water mark in percent of max len */ + + /* TODO: Use a rate counter group instead */ + uint64_t dropped_msgs; + uint64_t merged_msgs; + uint64_t rejected_msgs; + uint64_t agch_msgs; + uint64_t pch_msgs; + } agch_queue; struct paging_state *paging_state; char *bsc_oml_host; diff --git a/src/common/bts.c b/src/common/bts.c index 32ec5560..3ab6e872 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -122,8 +122,8 @@ int bts_init(struct gsm_bts *bts) bts->role = btsb = talloc_zero(bts, struct gsm_bts_role_bts); btsb->bts = bts; - INIT_LLIST_HEAD(&btsb->agch_queue); - btsb->agch_queue_length = 0; + INIT_LLIST_HEAD(&btsb->agch_queue.queue); + btsb->agch_queue.length = 0; bts->ctrs = rate_ctr_group_alloc(bts, &bts_ctrg_desc, bts->nr); @@ -131,9 +131,9 @@ int bts_init(struct gsm_bts *bts) * raise threshold to GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DISABLE to * disable this feature. */ - btsb->agch_queue_low_level = GSM_BTS_AGCH_QUEUE_LOW_LEVEL_DEFAULT; - btsb->agch_queue_high_level = GSM_BTS_AGCH_QUEUE_HIGH_LEVEL_DEFAULT; - btsb->agch_queue_thresh_level = GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DEFAULT; + btsb->agch_queue.low_level = GSM_BTS_AGCH_QUEUE_LOW_LEVEL_DEFAULT; + btsb->agch_queue.high_level = GSM_BTS_AGCH_QUEUE_HIGH_LEVEL_DEFAULT; + btsb->agch_queue.thresh_level = GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DEFAULT; /* configurable via VTY */ btsb->paging_state = paging_init(btsb, 200, 0); @@ -389,20 +389,20 @@ static void bts_update_agch_max_queue_length(struct gsm_bts *bts) { struct gsm_bts_role_bts *btsb = bts_role_bts(bts); struct gsm48_system_information_type_3 *si3; - int old_max_length = btsb->agch_max_queue_length; + int old_max_length = btsb->agch_queue.max_length; if (!(bts->si_valid & (1<agch_max_queue_length = + btsb->agch_queue.max_length = bts_agch_max_queue_length(si3->rach_control.tx_integer, si3->control_channel_desc.ccch_conf); - if (btsb->agch_max_queue_length != old_max_length) + if (btsb->agch_queue.max_length != old_max_length) LOGP(DRSL, LOGL_INFO, "Updated AGCH max queue length to %d\n", - btsb->agch_max_queue_length); + btsb->agch_queue.max_length); } #define REQ_REFS_PER_IMM_ASS_REJ 4 @@ -538,31 +538,31 @@ int bts_agch_enqueue(struct gsm_bts *bts, struct msgb *msg) int hard_limit = 1000; struct gsm48_imm_ass_rej *imm_ass_cmd = msgb_l3(msg); - if (btsb->agch_queue_length > hard_limit) { + if (btsb->agch_queue.length > hard_limit) { LOGP(DSUM, LOGL_ERROR, "AGCH: too many messages in queue, " "refusing message type 0x%02x, length = %d/%d\n", ((struct gsm48_imm_ass *)msgb_l3(msg))->msg_type, - btsb->agch_queue_length, btsb->agch_max_queue_length); + btsb->agch_queue.length, btsb->agch_queue.max_length); - btsb->agch_queue_rejected_msgs++; + btsb->agch_queue.rejected_msgs++; return -ENOMEM; } - if (btsb->agch_queue_length > 0) { + if (btsb->agch_queue.length > 0) { struct msgb *last_msg = - llist_entry(btsb->agch_queue.prev, struct msgb, list); + llist_entry(btsb->agch_queue.queue.prev, struct msgb, list); struct gsm48_imm_ass_rej *last_imm_ass_rej = msgb_l3(last_msg); if (try_merge_imm_ass_rej(last_imm_ass_rej, imm_ass_cmd)) { - btsb->agch_queue_merged_msgs++; + btsb->agch_queue.merged_msgs++; msgb_free(msg); return 0; } } - msgb_enqueue(&btsb->agch_queue, msg); - btsb->agch_queue_length++; + msgb_enqueue(&btsb->agch_queue.queue, msg); + btsb->agch_queue.length++; return 0; } @@ -570,11 +570,11 @@ int bts_agch_enqueue(struct gsm_bts *bts, struct msgb *msg) struct msgb *bts_agch_dequeue(struct gsm_bts *bts) { struct gsm_bts_role_bts *btsb = bts_role_bts(bts); - struct msgb *msg = msgb_dequeue(&btsb->agch_queue); + struct msgb *msg = msgb_dequeue(&btsb->agch_queue.queue); if (!msg) return NULL; - btsb->agch_queue_length--; + btsb->agch_queue.length--; return msg; } @@ -589,16 +589,16 @@ static void compact_agch_queue(struct gsm_bts *bts) struct gsm_bts_role_bts *btsb = bts_role_bts(bts); struct msgb *msg, *msg2; int max_len, slope, offs; - int level_low = btsb->agch_queue_low_level; - int level_high = btsb->agch_queue_high_level; - int level_thres = btsb->agch_queue_thresh_level; + int level_low = btsb->agch_queue.low_level; + int level_high = btsb->agch_queue.high_level; + int level_thres = btsb->agch_queue.thresh_level; - max_len = btsb->agch_max_queue_length; + max_len = btsb->agch_queue.max_length; if (max_len == 0) max_len = 1; - if (btsb->agch_queue_length < max_len * level_thres / 100) + if (btsb->agch_queue.length < max_len * level_thres / 100) return; /* p^ @@ -615,7 +615,7 @@ static void compact_agch_queue(struct gsm_bts *bts) else slope = 0x10000 * max_len; /* p_drop >= 1 if len > offs */ - llist_for_each_entry_safe(msg, msg2, &btsb->agch_queue, list) { + llist_for_each_entry_safe(msg, msg2, &btsb->agch_queue.queue, list) { struct gsm48_imm_ass *imm_ass_cmd = msgb_l3(msg); int p_drop; @@ -624,16 +624,16 @@ static void compact_agch_queue(struct gsm_bts *bts) /* IMMEDIATE ASSIGN REJECT */ - p_drop = (btsb->agch_queue_length - offs) * slope / max_len; + p_drop = (btsb->agch_queue.length - offs) * slope / max_len; if ((random() & 0xffff) >= p_drop) return; llist_del(&msg->list); - btsb->agch_queue_length--; + btsb->agch_queue.length--; msgb_free(msg); - btsb->agch_queue_dropped_msgs++; + btsb->agch_queue.dropped_msgs++; } return; } @@ -673,9 +673,9 @@ int bts_ccch_copy_msg(struct gsm_bts *bts, uint8_t *out_buf, struct gsm_time *gt msgb_free(msg); if (is_ag_res) - btsb->agch_queue_agch_msgs++; + btsb->agch_queue.agch_msgs++; else - btsb->agch_queue_pch_msgs++; + btsb->agch_queue.pch_msgs++; return rc; } diff --git a/src/common/vty.c b/src/common/vty.c index f3f846b2..ca5ca7c4 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -270,12 +270,12 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) vty_out(vty, " paging lifetime %u%s", paging_get_lifetime(btsb->paging_state), VTY_NEWLINE); vty_out(vty, " uplink-power-target %d%s", btsb->ul_power_target, VTY_NEWLINE); - if (btsb->agch_queue_thresh_level != GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DEFAULT - || btsb->agch_queue_low_level != GSM_BTS_AGCH_QUEUE_LOW_LEVEL_DEFAULT - || btsb->agch_queue_high_level != GSM_BTS_AGCH_QUEUE_HIGH_LEVEL_DEFAULT) + if (btsb->agch_queue.thresh_level != GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DEFAULT + || btsb->agch_queue.low_level != GSM_BTS_AGCH_QUEUE_LOW_LEVEL_DEFAULT + || btsb->agch_queue.high_level != GSM_BTS_AGCH_QUEUE_HIGH_LEVEL_DEFAULT) vty_out(vty, " agch-queue-mgmt threshold %d low %d high %d%s", - btsb->agch_queue_thresh_level, btsb->agch_queue_low_level, - btsb->agch_queue_high_level, VTY_NEWLINE); + btsb->agch_queue.thresh_level, btsb->agch_queue.low_level, + btsb->agch_queue.high_level, VTY_NEWLINE); for (i = 0; i < 32; i++) { if (gsmtap_sapi_mask & (1 << i)) { @@ -534,9 +534,9 @@ DEFUN(cfg_bts_agch_queue_mgmt_params, struct gsm_bts *bts = vty->index; struct gsm_bts_role_bts *btsb = bts_role_bts(bts); - btsb->agch_queue_thresh_level = atoi(argv[0]); - btsb->agch_queue_low_level = atoi(argv[1]); - btsb->agch_queue_high_level = atoi(argv[2]); + btsb->agch_queue.thresh_level = atoi(argv[0]); + btsb->agch_queue.low_level = atoi(argv[1]); + btsb->agch_queue.high_level = atoi(argv[2]); return CMD_SUCCESS; } @@ -550,9 +550,9 @@ DEFUN(cfg_bts_agch_queue_mgmt_default, struct gsm_bts *bts = vty->index; struct gsm_bts_role_bts *btsb = bts_role_bts(bts); - btsb->agch_queue_thresh_level = GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DEFAULT; - btsb->agch_queue_low_level = GSM_BTS_AGCH_QUEUE_LOW_LEVEL_DEFAULT; - btsb->agch_queue_high_level = GSM_BTS_AGCH_QUEUE_HIGH_LEVEL_DEFAULT; + btsb->agch_queue.thresh_level = GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DEFAULT; + btsb->agch_queue.low_level = GSM_BTS_AGCH_QUEUE_LOW_LEVEL_DEFAULT; + btsb->agch_queue.high_level = GSM_BTS_AGCH_QUEUE_HIGH_LEVEL_DEFAULT; return CMD_SUCCESS; } @@ -822,10 +822,10 @@ static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts) vty_out(vty, " AGCH: Queue limit %u, occupied %d, " "dropped %"PRIu64", merged %"PRIu64", rejected %"PRIu64", " "ag-res %"PRIu64", non-res %"PRIu64"%s", - btsb->agch_max_queue_length, btsb->agch_queue_length, - btsb->agch_queue_dropped_msgs, btsb->agch_queue_merged_msgs, - btsb->agch_queue_rejected_msgs, btsb->agch_queue_agch_msgs, - btsb->agch_queue_pch_msgs, + btsb->agch_queue.max_length, btsb->agch_queue.length, + btsb->agch_queue.dropped_msgs, btsb->agch_queue.merged_msgs, + btsb->agch_queue.rejected_msgs, btsb->agch_queue.agch_msgs, + btsb->agch_queue.pch_msgs, VTY_NEWLINE); vty_out(vty, " CBCH backlog queue length: %u%s", llist_length(&btsb->smscb_state.queue), VTY_NEWLINE); diff --git a/tests/agch/agch_test.c b/tests/agch/agch_test.c index b5094afb..89f113ab 100644 --- a/tests/agch/agch_test.c +++ b/tests/agch/agch_test.c @@ -116,11 +116,11 @@ static void test_agch_queue(void) g_time.t3 = 6; printf("Testing AGCH messages queue handling.\n"); - btsb->agch_max_queue_length = 32; + btsb->agch_queue.max_length = 32; - btsb->agch_queue_low_level = 30; - btsb->agch_queue_high_level = 30; - btsb->agch_queue_thresh_level = 60; + btsb->agch_queue.low_level = 30; + btsb->agch_queue.high_level = 30; + btsb->agch_queue.thresh_level = 60; for (round = 1; round <= num_rounds; round++) { for (idx = 0; idx < num_ima_per_round; idx++) { @@ -143,10 +143,10 @@ static void test_agch_queue(void) "dropped %"PRIu64", merged %"PRIu64", rejected %"PRIu64", " "ag-res %"PRIu64", non-res %"PRIu64"\n", count, imm_ass_count, imm_ass_rej_count, imm_ass_rej_ref_count, - btsb->agch_max_queue_length, btsb->agch_queue_length, - btsb->agch_queue_dropped_msgs, btsb->agch_queue_merged_msgs, - btsb->agch_queue_rejected_msgs, btsb->agch_queue_agch_msgs, - btsb->agch_queue_pch_msgs); + btsb->agch_queue.max_length, btsb->agch_queue.length, + btsb->agch_queue.dropped_msgs, btsb->agch_queue.merged_msgs, + btsb->agch_queue.rejected_msgs, btsb->agch_queue.agch_msgs, + btsb->agch_queue.pch_msgs); imm_ass_count = 0; imm_ass_rej_count = 0; @@ -182,10 +182,10 @@ static void test_agch_queue(void) "dropped %"PRIu64", merged %"PRIu64", rejected %"PRIu64", " "ag-res %"PRIu64", non-res %"PRIu64"\n", multiframes, imm_ass_count, imm_ass_rej_count, imm_ass_rej_ref_count, - btsb->agch_max_queue_length, btsb->agch_queue_length, - btsb->agch_queue_dropped_msgs, btsb->agch_queue_merged_msgs, - btsb->agch_queue_rejected_msgs, btsb->agch_queue_agch_msgs, - btsb->agch_queue_pch_msgs); + btsb->agch_queue.max_length, btsb->agch_queue.length, + btsb->agch_queue.dropped_msgs, btsb->agch_queue.merged_msgs, + btsb->agch_queue.rejected_msgs, btsb->agch_queue.agch_msgs, + btsb->agch_queue.pch_msgs); } static void test_agch_queue_length_computation(void) -- cgit v1.2.3