blob: cfe88960f7f1c47e0415613be7522aa8c03bb3d4 [file] [log] [blame]
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +01001/*
2 * Copyright (C) 2013 by Holger Hans Peter Freyther
3 * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
4 * Author: Pau Espin Pedrol <pespin@sysmocom.de>
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#include <osmocom/core/utils.h>
24
25#include "gprs_pcu.h"
26#include "bts.h"
27
28struct gprs_pcu *the_pcu;
29
Pau Espin Pedrol924aaad2021-01-14 12:01:42 +010030static struct osmo_tdef T_defs_pcu[] = {
31 { .T=1, .default_val=30, .unit=OSMO_TDEF_S, .desc="BSSGP (un)blocking procedures timer (s)", .val=0 },
32 { .T=2, .default_val=30, .unit=OSMO_TDEF_S, .desc="BSSGP reset procedure timer (s)", .val=0 },
33 { .T=3190, .default_val=5, .unit=OSMO_TDEF_S, .desc="Return to packet idle mode after Packet DL Assignment on CCCH (s)", .val=0},
34 { .T=-2000, .default_val=2, .unit=OSMO_TDEF_MS, .desc="Tbf reject for PRR timer (ms)", .val=0 },
35 { .T=-2001, .default_val=2, .unit=OSMO_TDEF_S, .desc="PACCH assignment timer (s)", .val=0 },
36 { .T=-2002, .default_val=200, .unit=OSMO_TDEF_MS, .desc="Waiting after IMM.ASS confirm timer (ms)", .val=0 },
37 { .T=-2030, .default_val=60, .unit=OSMO_TDEF_S, .desc="Time to keep an idle MS object alive (s)", .val=0 }, /* slightly above T3314 (default 44s, 24.008, 11.2.2) */
38 { .T=-2031, .default_val=2000, .unit=OSMO_TDEF_MS, .desc="Time to keep an idle DL TBF alive (ms)", .val=0 },
39 { .T=0, .default_val=0, .unit=OSMO_TDEF_S, .desc=NULL, .val=0 } /* empty item at the end */
40};
41
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +010042struct gprs_pcu *gprs_pcu_alloc(void *ctx)
43{
44 struct gprs_pcu *pcu;
45
46 pcu = (struct gprs_pcu *)talloc_zero(ctx, struct gprs_pcu);
47 OSMO_ASSERT(pcu);
48
49 pcu->vty.max_cs_ul = MAX_GPRS_CS;
50 pcu->vty.max_cs_dl = MAX_GPRS_CS;
51 pcu->vty.max_mcs_ul = MAX_EDGE_MCS;
52 pcu->vty.max_mcs_dl = MAX_EDGE_MCS;
Pau Espin Pedrola2814952021-01-14 12:53:53 +010053 pcu->vty.alpha = 0; /* a = 0.0 */
Pau Espin Pedrol05f9f592021-01-14 12:56:58 +010054 pcu->vty.dl_tbf_preemptive_retransmission = true;
Pau Espin Pedrol97296b22021-01-14 13:08:02 +010055 /* By default resegmentation is supported in DL can also be configured
56 * through VTY */
57 pcu->vty.dl_arq_type = EGPRS_ARQ1;
Pau Espin Pedrole8dcf642021-01-14 13:17:01 +010058 pcu->vty.cs_adj_enabled = true;
59 pcu->vty.cs_adj_upper_limit = 33; /* Decrease CS if the error rate is above */
60 pcu->vty.cs_adj_lower_limit = 10; /* Increase CS if the error rate is below */
Pau Espin Pedrolad79b852021-01-14 13:20:55 +010061 pcu->vty.cs_downgrade_threshold = 200;
Pau Espin Pedrol54b159a2021-01-14 13:30:04 +010062 /* CS-1 to CS-4 */
63 pcu->vty.cs_lqual_ranges[0].low = -256;
64 pcu->vty.cs_lqual_ranges[0].high = 6;
65 pcu->vty.cs_lqual_ranges[1].low = 5;
66 pcu->vty.cs_lqual_ranges[1].high = 8;
67 pcu->vty.cs_lqual_ranges[2].low = 7;
68 pcu->vty.cs_lqual_ranges[2].high = 13;
69 pcu->vty.cs_lqual_ranges[3].low = 12;
70 pcu->vty.cs_lqual_ranges[3].high = 256;
71 /* MCS-1 to MCS-9 */
72 /* Default thresholds are referenced from literature */
73 /* Fig. 2.3, Chapter 2, Optimizing Wireless Communication Systems, Springer (2009) */
74 pcu->vty.mcs_lqual_ranges[0].low = -256;
75 pcu->vty.mcs_lqual_ranges[0].high = 6;
76 pcu->vty.mcs_lqual_ranges[1].low = 5;
77 pcu->vty.mcs_lqual_ranges[1].high = 8;
78 pcu->vty.mcs_lqual_ranges[2].low = 7;
79 pcu->vty.mcs_lqual_ranges[2].high = 13;
80 pcu->vty.mcs_lqual_ranges[3].low = 12;
81 pcu->vty.mcs_lqual_ranges[3].high = 15;
82 pcu->vty.mcs_lqual_ranges[4].low = 14;
83 pcu->vty.mcs_lqual_ranges[4].high = 17;
84 pcu->vty.mcs_lqual_ranges[5].low = 16;
85 pcu->vty.mcs_lqual_ranges[5].high = 18;
86 pcu->vty.mcs_lqual_ranges[6].low = 17;
87 pcu->vty.mcs_lqual_ranges[6].high = 20;
88 pcu->vty.mcs_lqual_ranges[7].low = 19;
89 pcu->vty.mcs_lqual_ranges[7].high = 24;
90 pcu->vty.mcs_lqual_ranges[8].low = 23;
91 pcu->vty.mcs_lqual_ranges[8].high = 256;
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +010092
Pau Espin Pedrol924aaad2021-01-14 12:01:42 +010093 pcu->T_defs = T_defs_pcu;
94 osmo_tdefs_reset(pcu->T_defs);
95
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +010096 return pcu;
97}
98
99
100void gprs_pcu_set_max_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul)
101{
102 the_pcu->vty.max_cs_dl = cs_dl;
103 the_pcu->vty.max_cs_ul = cs_ul;
104 /*TODO: once we support multiple bts, foreach(bts) apply */
105 struct gprs_rlcmac_bts *bts = bts_data(pcu->bts);
106 bts_recalc_max_cs(bts);
107}
108void gprs_pcu_set_max_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul)
109{
110 the_pcu->vty.max_mcs_dl = mcs_dl;
111 the_pcu->vty.max_mcs_ul = mcs_ul;
112 /* TODO: once we support multiple bts, foreach(bts) apply */
113 struct gprs_rlcmac_bts *bts = bts_data(pcu->bts);
114 bts_recalc_max_mcs(bts);
115}