blob: 2f18dfd04f91977168f74e01f746409bbf39a52d [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>
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +010024#include <osmocom/core/linuxlist.h>
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +010025
26#include "gprs_pcu.h"
27#include "bts.h"
28
29struct gprs_pcu *the_pcu;
30
Pau Espin Pedrol924aaad2021-01-14 12:01:42 +010031static struct osmo_tdef T_defs_pcu[] = {
32 { .T=1, .default_val=30, .unit=OSMO_TDEF_S, .desc="BSSGP (un)blocking procedures timer (s)", .val=0 },
33 { .T=2, .default_val=30, .unit=OSMO_TDEF_S, .desc="BSSGP reset procedure timer (s)", .val=0 },
34 { .T=3190, .default_val=5, .unit=OSMO_TDEF_S, .desc="Return to packet idle mode after Packet DL Assignment on CCCH (s)", .val=0},
35 { .T=-2000, .default_val=2, .unit=OSMO_TDEF_MS, .desc="Tbf reject for PRR timer (ms)", .val=0 },
36 { .T=-2001, .default_val=2, .unit=OSMO_TDEF_S, .desc="PACCH assignment timer (s)", .val=0 },
37 { .T=-2002, .default_val=200, .unit=OSMO_TDEF_MS, .desc="Waiting after IMM.ASS confirm timer (ms)", .val=0 },
38 { .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) */
39 { .T=-2031, .default_val=2000, .unit=OSMO_TDEF_MS, .desc="Time to keep an idle DL TBF alive (ms)", .val=0 },
40 { .T=0, .default_val=0, .unit=OSMO_TDEF_S, .desc=NULL, .val=0 } /* empty item at the end */
41};
42
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +010043struct gprs_pcu *gprs_pcu_alloc(void *ctx)
44{
45 struct gprs_pcu *pcu;
46
47 pcu = (struct gprs_pcu *)talloc_zero(ctx, struct gprs_pcu);
48 OSMO_ASSERT(pcu);
49
Pau Espin Pedrole8912222021-01-14 14:03:17 +010050 pcu->vty.fc_interval = 1;
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +010051 pcu->vty.max_cs_ul = MAX_GPRS_CS;
52 pcu->vty.max_cs_dl = MAX_GPRS_CS;
53 pcu->vty.max_mcs_ul = MAX_EDGE_MCS;
54 pcu->vty.max_mcs_dl = MAX_EDGE_MCS;
Pau Espin Pedrola2814952021-01-14 12:53:53 +010055 pcu->vty.alpha = 0; /* a = 0.0 */
Pau Espin Pedrol05f9f592021-01-14 12:56:58 +010056 pcu->vty.dl_tbf_preemptive_retransmission = true;
Pau Espin Pedrol97296b22021-01-14 13:08:02 +010057 /* By default resegmentation is supported in DL can also be configured
58 * through VTY */
59 pcu->vty.dl_arq_type = EGPRS_ARQ1;
Pau Espin Pedrole8dcf642021-01-14 13:17:01 +010060 pcu->vty.cs_adj_enabled = true;
61 pcu->vty.cs_adj_upper_limit = 33; /* Decrease CS if the error rate is above */
62 pcu->vty.cs_adj_lower_limit = 10; /* Increase CS if the error rate is below */
Pau Espin Pedrolad79b852021-01-14 13:20:55 +010063 pcu->vty.cs_downgrade_threshold = 200;
Pau Espin Pedrol54b159a2021-01-14 13:30:04 +010064 /* CS-1 to CS-4 */
65 pcu->vty.cs_lqual_ranges[0].low = -256;
66 pcu->vty.cs_lqual_ranges[0].high = 6;
67 pcu->vty.cs_lqual_ranges[1].low = 5;
68 pcu->vty.cs_lqual_ranges[1].high = 8;
69 pcu->vty.cs_lqual_ranges[2].low = 7;
70 pcu->vty.cs_lqual_ranges[2].high = 13;
71 pcu->vty.cs_lqual_ranges[3].low = 12;
72 pcu->vty.cs_lqual_ranges[3].high = 256;
73 /* MCS-1 to MCS-9 */
74 /* Default thresholds are referenced from literature */
75 /* Fig. 2.3, Chapter 2, Optimizing Wireless Communication Systems, Springer (2009) */
76 pcu->vty.mcs_lqual_ranges[0].low = -256;
77 pcu->vty.mcs_lqual_ranges[0].high = 6;
78 pcu->vty.mcs_lqual_ranges[1].low = 5;
79 pcu->vty.mcs_lqual_ranges[1].high = 8;
80 pcu->vty.mcs_lqual_ranges[2].low = 7;
81 pcu->vty.mcs_lqual_ranges[2].high = 13;
82 pcu->vty.mcs_lqual_ranges[3].low = 12;
83 pcu->vty.mcs_lqual_ranges[3].high = 15;
84 pcu->vty.mcs_lqual_ranges[4].low = 14;
85 pcu->vty.mcs_lqual_ranges[4].high = 17;
86 pcu->vty.mcs_lqual_ranges[5].low = 16;
87 pcu->vty.mcs_lqual_ranges[5].high = 18;
88 pcu->vty.mcs_lqual_ranges[6].low = 17;
89 pcu->vty.mcs_lqual_ranges[6].high = 20;
90 pcu->vty.mcs_lqual_ranges[7].low = 19;
91 pcu->vty.mcs_lqual_ranges[7].high = 24;
92 pcu->vty.mcs_lqual_ranges[8].low = 23;
93 pcu->vty.mcs_lqual_ranges[8].high = 256;
Pau Espin Pedrol113fb412021-01-14 13:36:02 +010094 pcu->vty.ns_dialect = NS2_DIALECT_IPACCESS;
Pau Espin Pedrol519d0712021-01-14 14:30:03 +010095 /* TODO: increase them when CRBB decoding is implemented */
96 pcu->vty.ws_base = 64;
97 pcu->vty.ws_pdch = 0;
Pau Espin Pedrolf473ec92021-01-14 14:45:14 +010098 pcu->vty.llc_codel_interval_msec = LLC_CODEL_USE_DEFAULT;
99 pcu->vty.llc_idle_ack_csec = 10;
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100100
Pau Espin Pedrol924aaad2021-01-14 12:01:42 +0100101 pcu->T_defs = T_defs_pcu;
102 osmo_tdefs_reset(pcu->T_defs);
103
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100104 INIT_LLIST_HEAD(&pcu->bts_list);
105
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100106 return pcu;
107}
108
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100109struct gprs_rlcmac_bts *gprs_pcu_get_bts_by_nr(struct gprs_pcu *pcu, uint8_t bts_nr)
110{
111 struct gprs_rlcmac_bts *pos;
112 llist_for_each_entry(pos, &pcu->bts_list, list) {
113 if (pos->nr == bts_nr)
114 return pos;
115 }
116 return NULL;
117}
118
Pau Espin Pedrol3a271022021-01-21 18:44:23 +0100119struct gprs_rlcmac_bts *gprs_pcu_get_bts_by_cgi_ps(struct gprs_pcu *pcu, struct osmo_cell_global_id_ps *cgi_ps)
120{
121 struct gprs_rlcmac_bts *pos;
122 llist_for_each_entry(pos, &pcu->bts_list, list) {
Pau Espin Pedrola100a6b2021-01-22 17:45:50 +0100123 if (osmo_cgi_ps_cmp(&pos->cgi_ps, cgi_ps) == 0)
Pau Espin Pedrol3a271022021-01-21 18:44:23 +0100124 return pos;
125 }
126 return NULL;
127}
128
Pau Espin Pedrol793583e2021-01-14 16:20:57 +0100129void gprs_pcu_set_initial_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul)
130{
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100131 struct gprs_rlcmac_bts *bts;
132
Pau Espin Pedrol793583e2021-01-14 16:20:57 +0100133 the_pcu->vty.initial_cs_dl = cs_dl;
134 the_pcu->vty.initial_cs_ul = cs_ul;
135
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100136 llist_for_each_entry(bts, &pcu->bts_list, list) {
137 bts_recalc_initial_cs(bts);
138 }
Pau Espin Pedrol793583e2021-01-14 16:20:57 +0100139}
140void gprs_pcu_set_initial_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul)
141{
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100142 struct gprs_rlcmac_bts *bts;
143
Pau Espin Pedrol793583e2021-01-14 16:20:57 +0100144 the_pcu->vty.initial_mcs_dl = mcs_dl;
145 the_pcu->vty.initial_mcs_ul = mcs_ul;
146
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100147 llist_for_each_entry(bts, &pcu->bts_list, list) {
148 bts_recalc_initial_mcs(bts);
149 }
Pau Espin Pedrol793583e2021-01-14 16:20:57 +0100150}
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100151
152void gprs_pcu_set_max_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul)
153{
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100154 struct gprs_rlcmac_bts *bts;
155
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100156 the_pcu->vty.max_cs_dl = cs_dl;
157 the_pcu->vty.max_cs_ul = cs_ul;
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100158
159 llist_for_each_entry(bts, &pcu->bts_list, list) {
160 bts_recalc_max_cs(bts);
161 }
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100162}
163void gprs_pcu_set_max_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul)
164{
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100165 struct gprs_rlcmac_bts *bts;
166
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100167 the_pcu->vty.max_mcs_dl = mcs_dl;
168 the_pcu->vty.max_mcs_ul = mcs_ul;
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100169
170 llist_for_each_entry(bts, &pcu->bts_list, list) {
171 bts_recalc_max_mcs(bts);
172 }
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100173}