Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 28 | struct gprs_pcu *the_pcu; |
| 29 | |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 30 | static 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 Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 42 | struct 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 | |
Pau Espin Pedrol | e891222 | 2021-01-14 14:03:17 +0100 | [diff] [blame] | 49 | pcu->vty.fc_interval = 1; |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 50 | pcu->vty.max_cs_ul = MAX_GPRS_CS; |
| 51 | pcu->vty.max_cs_dl = MAX_GPRS_CS; |
| 52 | pcu->vty.max_mcs_ul = MAX_EDGE_MCS; |
| 53 | pcu->vty.max_mcs_dl = MAX_EDGE_MCS; |
Pau Espin Pedrol | a281495 | 2021-01-14 12:53:53 +0100 | [diff] [blame] | 54 | pcu->vty.alpha = 0; /* a = 0.0 */ |
Pau Espin Pedrol | 05f9f59 | 2021-01-14 12:56:58 +0100 | [diff] [blame] | 55 | pcu->vty.dl_tbf_preemptive_retransmission = true; |
Pau Espin Pedrol | 97296b2 | 2021-01-14 13:08:02 +0100 | [diff] [blame] | 56 | /* By default resegmentation is supported in DL can also be configured |
| 57 | * through VTY */ |
| 58 | pcu->vty.dl_arq_type = EGPRS_ARQ1; |
Pau Espin Pedrol | e8dcf64 | 2021-01-14 13:17:01 +0100 | [diff] [blame] | 59 | pcu->vty.cs_adj_enabled = true; |
| 60 | pcu->vty.cs_adj_upper_limit = 33; /* Decrease CS if the error rate is above */ |
| 61 | pcu->vty.cs_adj_lower_limit = 10; /* Increase CS if the error rate is below */ |
Pau Espin Pedrol | ad79b85 | 2021-01-14 13:20:55 +0100 | [diff] [blame] | 62 | pcu->vty.cs_downgrade_threshold = 200; |
Pau Espin Pedrol | 54b159a | 2021-01-14 13:30:04 +0100 | [diff] [blame] | 63 | /* CS-1 to CS-4 */ |
| 64 | pcu->vty.cs_lqual_ranges[0].low = -256; |
| 65 | pcu->vty.cs_lqual_ranges[0].high = 6; |
| 66 | pcu->vty.cs_lqual_ranges[1].low = 5; |
| 67 | pcu->vty.cs_lqual_ranges[1].high = 8; |
| 68 | pcu->vty.cs_lqual_ranges[2].low = 7; |
| 69 | pcu->vty.cs_lqual_ranges[2].high = 13; |
| 70 | pcu->vty.cs_lqual_ranges[3].low = 12; |
| 71 | pcu->vty.cs_lqual_ranges[3].high = 256; |
| 72 | /* MCS-1 to MCS-9 */ |
| 73 | /* Default thresholds are referenced from literature */ |
| 74 | /* Fig. 2.3, Chapter 2, Optimizing Wireless Communication Systems, Springer (2009) */ |
| 75 | pcu->vty.mcs_lqual_ranges[0].low = -256; |
| 76 | pcu->vty.mcs_lqual_ranges[0].high = 6; |
| 77 | pcu->vty.mcs_lqual_ranges[1].low = 5; |
| 78 | pcu->vty.mcs_lqual_ranges[1].high = 8; |
| 79 | pcu->vty.mcs_lqual_ranges[2].low = 7; |
| 80 | pcu->vty.mcs_lqual_ranges[2].high = 13; |
| 81 | pcu->vty.mcs_lqual_ranges[3].low = 12; |
| 82 | pcu->vty.mcs_lqual_ranges[3].high = 15; |
| 83 | pcu->vty.mcs_lqual_ranges[4].low = 14; |
| 84 | pcu->vty.mcs_lqual_ranges[4].high = 17; |
| 85 | pcu->vty.mcs_lqual_ranges[5].low = 16; |
| 86 | pcu->vty.mcs_lqual_ranges[5].high = 18; |
| 87 | pcu->vty.mcs_lqual_ranges[6].low = 17; |
| 88 | pcu->vty.mcs_lqual_ranges[6].high = 20; |
| 89 | pcu->vty.mcs_lqual_ranges[7].low = 19; |
| 90 | pcu->vty.mcs_lqual_ranges[7].high = 24; |
| 91 | pcu->vty.mcs_lqual_ranges[8].low = 23; |
| 92 | pcu->vty.mcs_lqual_ranges[8].high = 256; |
Pau Espin Pedrol | 113fb41 | 2021-01-14 13:36:02 +0100 | [diff] [blame] | 93 | pcu->vty.ns_dialect = NS2_DIALECT_IPACCESS; |
Pau Espin Pedrol | 519d071 | 2021-01-14 14:30:03 +0100 | [diff] [blame] | 94 | /* TODO: increase them when CRBB decoding is implemented */ |
| 95 | pcu->vty.ws_base = 64; |
| 96 | pcu->vty.ws_pdch = 0; |
Pau Espin Pedrol | f473ec9 | 2021-01-14 14:45:14 +0100 | [diff] [blame] | 97 | pcu->vty.llc_codel_interval_msec = LLC_CODEL_USE_DEFAULT; |
| 98 | pcu->vty.llc_idle_ack_csec = 10; |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 99 | |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 100 | pcu->T_defs = T_defs_pcu; |
| 101 | osmo_tdefs_reset(pcu->T_defs); |
| 102 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 103 | return pcu; |
| 104 | } |
| 105 | |
Pau Espin Pedrol | 793583e | 2021-01-14 16:20:57 +0100 | [diff] [blame] | 106 | void gprs_pcu_set_initial_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul) |
| 107 | { |
| 108 | the_pcu->vty.initial_cs_dl = cs_dl; |
| 109 | the_pcu->vty.initial_cs_ul = cs_ul; |
| 110 | |
| 111 | /*TODO: once we support multiple bts, foreach(bts) apply */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 112 | bts_recalc_initial_cs(pcu->bts); |
Pau Espin Pedrol | 793583e | 2021-01-14 16:20:57 +0100 | [diff] [blame] | 113 | } |
| 114 | void gprs_pcu_set_initial_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul) |
| 115 | { |
| 116 | the_pcu->vty.initial_mcs_dl = mcs_dl; |
| 117 | the_pcu->vty.initial_mcs_ul = mcs_ul; |
| 118 | |
| 119 | /*TODO: once we support multiple bts, foreach(bts) apply */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 120 | bts_recalc_initial_mcs(pcu->bts); |
Pau Espin Pedrol | 793583e | 2021-01-14 16:20:57 +0100 | [diff] [blame] | 121 | } |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 122 | |
| 123 | void gprs_pcu_set_max_cs(struct gprs_pcu *pcu, uint8_t cs_dl, uint8_t cs_ul) |
| 124 | { |
| 125 | the_pcu->vty.max_cs_dl = cs_dl; |
| 126 | the_pcu->vty.max_cs_ul = cs_ul; |
| 127 | /*TODO: once we support multiple bts, foreach(bts) apply */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 128 | bts_recalc_max_cs(pcu->bts); |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 129 | } |
| 130 | void gprs_pcu_set_max_mcs(struct gprs_pcu *pcu, uint8_t mcs_dl, uint8_t mcs_ul) |
| 131 | { |
| 132 | the_pcu->vty.max_mcs_dl = mcs_dl; |
| 133 | the_pcu->vty.max_mcs_ul = mcs_ul; |
| 134 | /* TODO: once we support multiple bts, foreach(bts) apply */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 135 | bts_recalc_max_mcs(pcu->bts); |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 136 | } |