From ad79b857cd1683a263a8602b14e9c4aaba3178b6 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 14 Jan 2021 13:20:55 +0100 Subject: [PATCH] Move cs_downgrade_threshold field from BTS to PCU Change-Id: I3e1c65eb3cccff565d5d84588bdce93a47909a0f --- src/bts.cpp | 1 - src/bts.h | 4 ---- src/gprs_ms.c | 2 +- src/gprs_pcu.c | 1 + src/gprs_pcu.h | 3 +++ src/pcu_vty.c | 14 ++++---------- tests/ms/MsTest.cpp | 6 +++--- tests/tbf/TbfTest.cpp | 8 ++------ 8 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/bts.cpp b/src/bts.cpp index 3795ca2c..32ec71ea 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -232,7 +232,6 @@ static void bts_init(struct gprs_rlcmac_bts *bts, BTS* bts_obj) bts->mcs_lqual_ranges[7].high = 24; bts->mcs_lqual_ranges[8].low = 23; bts->mcs_lqual_ranges[8].high = 256; - bts->cs_downgrade_threshold = 200; bts->ns_dialect = NS2_DIALECT_IPACCESS; /* TODO: increase them when CRBB decoding is implemented */ diff --git a/src/bts.h b/src/bts.h index ea218f7a..afad02c4 100644 --- a/src/bts.h +++ b/src/bts.h @@ -108,10 +108,6 @@ struct gprs_rlcmac_bts { uint8_t si13[GSM_MACBLOCK_LEN]; bool si13_is_set; - - /* downgrade DL CS when less than specified octets are left in tx queue. Optimization, see paper: - "Theoretical Analysis of GPRS Throughput and Delay" */ - uint16_t cs_downgrade_threshold; /* Link quality range for each UL (M)CS. Below or above, next/prev (M)CS is selected. */ struct {int16_t low; int16_t high; } cs_lqual_ranges[MAX_GPRS_CS]; struct {int16_t low; int16_t high; } mcs_lqual_ranges[MAX_EDGE_MCS]; diff --git a/src/gprs_ms.c b/src/gprs_ms.c index cc64c86f..c0fb55e0 100644 --- a/src/gprs_ms.c +++ b/src/gprs_ms.c @@ -794,7 +794,7 @@ enum CodingScheme ms_current_cs_dl(const struct GprsMs *ms) unencoded_octets += llc_chunk_size(tbf_llc((struct gprs_rlcmac_tbf *)ms->dl_tbf)); /* There are many unencoded octets, don't reduce */ - if (unencoded_octets >= bts_data(ms->bts)->cs_downgrade_threshold) + if (unencoded_octets >= the_pcu->vty.cs_downgrade_threshold) return cs; /* RF conditions are good, don't reduce */ diff --git a/src/gprs_pcu.c b/src/gprs_pcu.c index d7a851b7..ba48c389 100644 --- a/src/gprs_pcu.c +++ b/src/gprs_pcu.c @@ -58,6 +58,7 @@ struct gprs_pcu *gprs_pcu_alloc(void *ctx) pcu->vty.cs_adj_enabled = true; pcu->vty.cs_adj_upper_limit = 33; /* Decrease CS if the error rate is above */ pcu->vty.cs_adj_lower_limit = 10; /* Increase CS if the error rate is below */ + pcu->vty.cs_downgrade_threshold = 200; pcu->T_defs = T_defs_pcu; osmo_tdefs_reset(pcu->T_defs); diff --git a/src/gprs_pcu.h b/src/gprs_pcu.h index 6c9eae10..146b8b80 100644 --- a/src/gprs_pcu.h +++ b/src/gprs_pcu.h @@ -82,6 +82,9 @@ struct gprs_pcu { bool cs_adj_enabled; /* whether cs_adj_{upper,lower}_limit are used to adjust DL CS */ uint8_t cs_adj_upper_limit; /* downgrade DL CS if error rate above its value */ uint8_t cs_adj_lower_limit; /* upgrade DL CS if error rate below its value */ + /* downgrade DL CS when less than specified octets are left in tx queue. Optimization, see paper: + "Theoretical Analysis of GPRS Throughput and Delay" */ + uint16_t cs_downgrade_threshold; } vty; struct gsmtap_inst *gsmtap; diff --git a/src/pcu_vty.c b/src/pcu_vty.c index c830400c..e0edf91c 100644 --- a/src/pcu_vty.c +++ b/src/pcu_vty.c @@ -143,9 +143,9 @@ static int config_write_pcu(struct vty *vty) else vty_out(vty, " no cs threshold%s", VTY_NEWLINE); - if (bts->cs_downgrade_threshold) + if (the_pcu->vty.cs_downgrade_threshold) vty_out(vty, " cs downgrade-threshold %d%s", - bts->cs_downgrade_threshold, VTY_NEWLINE); + the_pcu->vty.cs_downgrade_threshold, VTY_NEWLINE); else vty_out(vty, " no cs downgrade-threshold%s", VTY_NEWLINE); @@ -947,10 +947,7 @@ DEFUN_ATTR(cfg_pcu_cs_downgrade_thrsh, CS_STR CS_DOWNGRADE_STR "downgrade if less octets left\n", CMD_ATTR_IMMEDIATE) { - struct gprs_rlcmac_bts *bts = bts_main_data(); - - bts->cs_downgrade_threshold = atoi(argv[0]); - + the_pcu->vty.cs_downgrade_threshold = atoi(argv[0]); return CMD_SUCCESS; } @@ -960,10 +957,7 @@ DEFUN_ATTR(cfg_pcu_no_cs_downgrade_thrsh, NO_STR CS_STR CS_DOWNGRADE_STR, CMD_ATTR_IMMEDIATE) { - struct gprs_rlcmac_bts *bts = bts_main_data(); - - bts->cs_downgrade_threshold = 0; - + the_pcu->vty.cs_downgrade_threshold = 0; return CMD_SUCCESS; } diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp index b914f01b..d6c8f183 100644 --- a/tests/ms/MsTest.cpp +++ b/tests/ms/MsTest.cpp @@ -510,7 +510,7 @@ static void test_ms_cs_selection() bts->initial_cs_dl = 4; bts->initial_cs_ul = 1; - bts->cs_downgrade_threshold = 0; + the_pcu->vty.cs_downgrade_threshold = 0; the_pcu->vty.cs_adj_lower_limit = 0; ms = ms_alloc(&the_bts, tlli); @@ -525,7 +525,7 @@ static void test_ms_cs_selection() OSMO_ASSERT(mcs_chan_code(ms_current_cs_dl(ms)) == 3); - bts->cs_downgrade_threshold = 200; + the_pcu->vty.cs_downgrade_threshold = 200; OSMO_ASSERT(mcs_chan_code(ms_current_cs_dl(ms)) == 2); @@ -559,7 +559,7 @@ static void test_ms_mcs_mode() bts->initial_cs_dl = 4; bts->initial_cs_ul = 1; - bts->cs_downgrade_threshold = 0; + the_pcu->vty.cs_downgrade_threshold = 0; ms2 = ms_alloc(&the_bts, tlli + 1); dump_ms(ms2, "2: with BTS defaults"); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 52403e19..75b51bf9 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -3070,13 +3070,11 @@ static void test_tbf_egprs_retx_dl(void) { the_pcu->bts = bts_alloc(the_pcu); BTS *the_bts = the_pcu->bts; - gprs_rlcmac_bts *bts; uint8_t ts_no = 4; fprintf(stderr, "=== start %s ===\n", __func__); - bts = the_bts->bts_data(); - bts->cs_downgrade_threshold = 0; + the_pcu->vty.cs_downgrade_threshold = 0; setup_bts(the_bts, ts_no); OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2031, 200, OSMO_TDEF_MS) == 0); /* ARQ II */ @@ -3100,13 +3098,11 @@ static void test_tbf_egprs_spb_dl(void) { the_pcu->bts = bts_alloc(the_pcu); BTS *the_bts = the_pcu->bts; - gprs_rlcmac_bts *bts; uint8_t ts_no = 4; fprintf(stderr, "=== start %s ===\n", __func__); - bts = the_bts->bts_data(); - bts->cs_downgrade_threshold = 0; + the_pcu->vty.cs_downgrade_threshold = 0; setup_bts(the_bts, ts_no); OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2031, 200, OSMO_TDEF_MS) == 0);