Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 1 | /* bts.h |
| 2 | * |
| 3 | * Copyright (C) 2012 Ivan Klyuchnikov |
| 4 | * Copyright (C) 2013 by Holger Hans Peter Freyther |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | |
| 21 | #pragma once |
| 22 | |
| 23 | |
| 24 | #ifdef __cplusplus |
| 25 | extern "C" { |
Alexander Couzens | 5012e07 | 2020-12-06 01:23:51 +0100 | [diff] [blame] | 26 | #endif |
| 27 | |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 28 | #include <osmocom/core/linuxlist.h> |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 29 | #include <osmocom/core/rate_ctr.h> |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 30 | #include <osmocom/core/stat_item.h> |
Pau Espin Pedrol | 28f160e | 2019-09-05 14:48:35 +0200 | [diff] [blame] | 31 | #include <osmocom/core/tdef.h> |
Alexander Couzens | 5012e07 | 2020-12-06 01:23:51 +0100 | [diff] [blame] | 32 | #include <osmocom/gprs/gprs_ns2.h> |
bhargava | 959d1de | 2016-08-17 15:17:21 +0530 | [diff] [blame] | 33 | #include <osmocom/gsm/l1sap.h> |
Max | 84bf0fa | 2017-09-01 11:02:40 +0200 | [diff] [blame] | 34 | #include <osmocom/gsm/protocol/gsm_04_08.h> |
Vadim Yanitskiy | cb98894 | 2020-11-08 13:27:35 +0700 | [diff] [blame] | 35 | #include <osmocom/gsm/gsm48.h> |
Pau Espin Pedrol | b2653fe | 2020-03-26 15:14:01 +0100 | [diff] [blame] | 36 | #include "mslot_class.h" |
| 37 | #include "gsm_rlcmac.h" |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 38 | #include "gprs_pcu.h" |
Alexander Couzens | 5012e07 | 2020-12-06 01:23:51 +0100 | [diff] [blame] | 39 | #ifdef __cplusplus |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 40 | } |
Alexander Couzens | 5012e07 | 2020-12-06 01:23:51 +0100 | [diff] [blame] | 41 | #endif |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 42 | |
Alexander Couzens | 5012e07 | 2020-12-06 01:23:51 +0100 | [diff] [blame] | 43 | #ifdef __cplusplus |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 44 | #include "poll_controller.h" |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 45 | #include "sba.h" |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 46 | #include "tbf.h" |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 47 | #include "gprs_ms_storage.h" |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 48 | #include "coding_scheme.h" |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 49 | #include <cxx_linuxlist.h> |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 50 | #endif |
| 51 | |
Daniel Willmann | fb3fd09 | 2019-03-06 17:09:43 +0100 | [diff] [blame] | 52 | #include <pdch.h> |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 53 | #include <stdint.h> |
Pau Espin Pedrol | 4d16635 | 2020-10-26 18:39:51 +0100 | [diff] [blame] | 54 | #include <stdbool.h> |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 55 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 56 | struct BTS; |
Jacob Erlbeck | e2e004e | 2015-06-18 17:16:26 +0200 | [diff] [blame] | 57 | struct GprsMs; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 58 | |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 59 | struct gprs_rlcmac_trx { |
| 60 | void *fl1h; |
| 61 | uint16_t arfcn; |
| 62 | struct gprs_rlcmac_pdch pdch[8]; |
Holger Hans Peter Freyther | 4ed1dae | 2013-10-20 10:14:03 +0200 | [diff] [blame] | 63 | |
| 64 | /* back pointers */ |
| 65 | struct BTS *bts; |
| 66 | uint8_t trx_no; |
Jacob Erlbeck | 23f93a1 | 2015-06-30 08:52:54 +0200 | [diff] [blame] | 67 | |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 68 | }; |
| 69 | |
Max | d71e8b3 | 2016-09-19 16:17:06 +0200 | [diff] [blame] | 70 | #ifdef __cplusplus |
| 71 | extern "C" { |
| 72 | #endif |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 73 | void bts_trx_reserve_slots(struct gprs_rlcmac_trx *trx, enum gprs_rlcmac_tbf_direction dir, uint8_t slots); |
| 74 | void bts_trx_unreserve_slots(struct gprs_rlcmac_trx *trx, enum gprs_rlcmac_tbf_direction dir, uint8_t slots); |
| 75 | |
Minh-Quang Nguyen | 1bcfa9a | 2017-11-01 14:41:37 -0400 | [diff] [blame] | 76 | void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, int8_t ta, bool is_rach); |
Max | d71e8b3 | 2016-09-19 16:17:06 +0200 | [diff] [blame] | 77 | #ifdef __cplusplus |
| 78 | } |
| 79 | #endif |
| 80 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 81 | /** |
| 82 | * This is the data from C. As soon as our minimal compiler is gcc 4.7 |
| 83 | * we can start to compile pcu_vty.c with c++ and remove the split. |
| 84 | */ |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 85 | struct gprs_rlcmac_bts { |
Stefan Sperling | 5b22fb7 | 2018-02-14 19:46:33 +0100 | [diff] [blame] | 86 | bool active; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 87 | uint8_t bsic; |
| 88 | uint8_t fc_interval; |
Jacob Erlbeck | 0288cdb | 2015-05-06 10:47:30 +0200 | [diff] [blame] | 89 | uint16_t fc_bucket_time; |
Jacob Erlbeck | 87d7341 | 2015-04-21 12:56:48 +0200 | [diff] [blame] | 90 | uint32_t fc_bvc_bucket_size; |
| 91 | uint32_t fc_bvc_leak_rate; |
| 92 | uint32_t fc_ms_bucket_size; |
| 93 | uint32_t fc_ms_leak_rate; |
Pau Espin Pedrol | d87722d | 2020-10-30 17:14:26 +0100 | [diff] [blame] | 94 | uint8_t cs_mask; /* Allowed CS mask from BTS */ |
| 95 | uint16_t mcs_mask; /* Allowed MCS mask from BTS */ |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 96 | uint8_t initial_cs_dl, initial_cs_ul; |
Jacob Erlbeck | 96ccea8 | 2016-01-07 15:00:43 +0100 | [diff] [blame] | 97 | uint8_t initial_mcs_dl, initial_mcs_ul; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 98 | uint16_t force_llc_lifetime; /* overrides lifetime from SGSN */ |
Jacob Erlbeck | 0c1c877 | 2015-03-20 12:02:42 +0100 | [diff] [blame] | 99 | uint32_t llc_discard_csec; |
Jacob Erlbeck | d0261b7 | 2015-04-02 13:58:09 +0200 | [diff] [blame] | 100 | uint32_t llc_idle_ack_csec; |
Jacob Erlbeck | d4ad731 | 2015-07-17 16:39:09 +0200 | [diff] [blame] | 101 | uint32_t llc_codel_interval_msec; /* 0=disabled, -1=use default interval */ |
Pau Espin Pedrol | 28f160e | 2019-09-05 14:48:35 +0200 | [diff] [blame] | 102 | /* Timer defintions */ |
| 103 | struct osmo_tdef *T_defs_bts; /* timers controlled by BTS, received through PCUIF */ |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 104 | uint8_t n3101; |
| 105 | uint8_t n3103; |
| 106 | uint8_t n3105; |
| 107 | struct gprs_rlcmac_trx trx[8]; |
Max | e9fe0e3 | 2017-09-28 15:56:05 +0200 | [diff] [blame] | 108 | |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 109 | uint8_t alpha, gamma; |
Oliver Smith | 45fdc44 | 2019-09-05 15:12:20 +0200 | [diff] [blame] | 110 | bool dl_tbf_preemptive_retransmission; |
Max | 84bf0fa | 2017-09-01 11:02:40 +0200 | [diff] [blame] | 111 | uint8_t si13[GSM_MACBLOCK_LEN]; |
| 112 | bool si13_is_set; |
Aravind Sirsikar | e6cadb4 | 2016-08-16 16:32:59 +0530 | [diff] [blame] | 113 | /* 0 to support resegmentation in DL, 1 for no reseg */ |
| 114 | uint8_t dl_arq_type; |
| 115 | |
Pau Espin Pedrol | 1e6eb30 | 2019-11-28 17:00:44 +0100 | [diff] [blame] | 116 | uint8_t cs_adj_enabled; /* whether cs_adj_{upper,lower}_limit are used to adjust DL CS */ |
| 117 | uint8_t cs_adj_upper_limit; /* downgrade DL CS if error rate above its value */ |
| 118 | uint8_t cs_adj_lower_limit; /* upgrade DL CS if error rate below its value */ |
| 119 | /* downgrade DL CS when less than specified octets are left in tx queue. Optimization, see paper: |
| 120 | "Theoretical Analysis of GPRS Throughput and Delay" */ |
| 121 | uint16_t cs_downgrade_threshold; |
| 122 | /* Link quality range for each UL (M)CS. Below or above, next/prev (M)CS is selected. */ |
Aravind Sirsikar | 99ab0a8 | 2016-06-15 17:46:41 +0530 | [diff] [blame] | 123 | struct {int16_t low; int16_t high; } cs_lqual_ranges[MAX_GPRS_CS]; |
Max | 8119ecd | 2019-03-06 19:03:01 +0100 | [diff] [blame] | 124 | struct {int16_t low; int16_t high; } mcs_lqual_ranges[MAX_EDGE_MCS]; |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 125 | uint16_t ws_base; |
| 126 | uint16_t ws_pdch; /* increase WS by this value per PDCH */ |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 127 | |
Jacob Erlbeck | 77da355 | 2015-07-16 18:33:46 +0200 | [diff] [blame] | 128 | /* State for dynamic algorithm selection */ |
| 129 | int multislot_disabled; |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 130 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 131 | /** |
| 132 | * Point back to the C++ object. This is used during the transition |
| 133 | * period. |
| 134 | */ |
| 135 | struct BTS *bts; |
Pau Espin Pedrol | c4178e5 | 2017-08-08 15:03:50 +0200 | [diff] [blame] | 136 | |
Harald Welte | 57d3515 | 2018-07-05 03:11:17 +0200 | [diff] [blame] | 137 | /* Are we talking Gb with IP-SNS (true) or classic Gb? */ |
Alexander Couzens | 5012e07 | 2020-12-06 01:23:51 +0100 | [diff] [blame] | 138 | enum gprs_ns2_dialect ns_dialect; |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 139 | |
| 140 | /* Packet Application Information (3GPP TS 44.060 11.2.47, usually ETWS primary message). We don't need to store |
| 141 | * more than one message, because they get sent so rarely. */ |
| 142 | struct msgb *app_info; |
| 143 | uint32_t app_info_pending; /* Count of MS with active TBF, to which we did not send app_info yet */ |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 144 | |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 145 | /* main nsei */ |
| 146 | struct gprs_ns2_nse *nse; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 147 | }; |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 148 | |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 149 | enum { |
| 150 | CTR_TBF_DL_ALLOCATED, |
| 151 | CTR_TBF_DL_FREED, |
| 152 | CTR_TBF_DL_ABORTED, |
| 153 | CTR_TBF_UL_ALLOCATED, |
| 154 | CTR_TBF_UL_FREED, |
| 155 | CTR_TBF_UL_ABORTED, |
| 156 | CTR_TBF_REUSED, |
| 157 | CTR_TBF_ALLOC_ALGO_A, |
| 158 | CTR_TBF_ALLOC_ALGO_B, |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 159 | CTR_RLC_SENT, |
| 160 | CTR_RLC_RESENT, |
| 161 | CTR_RLC_RESTARTED, |
| 162 | CTR_RLC_STALLED, |
| 163 | CTR_RLC_NACKED, |
| 164 | CTR_RLC_FINAL_BLOCK_RESENT, |
| 165 | CTR_RLC_ASS_TIMEDOUT, |
| 166 | CTR_RLC_ASS_FAILED, |
| 167 | CTR_RLC_ACK_TIMEDOUT, |
| 168 | CTR_RLC_ACK_FAILED, |
| 169 | CTR_RLC_REL_TIMEDOUT, |
| 170 | CTR_RLC_LATE_BLOCK, |
| 171 | CTR_RLC_SENT_DUMMY, |
| 172 | CTR_RLC_SENT_CONTROL, |
| 173 | CTR_RLC_DL_BYTES, |
| 174 | CTR_RLC_DL_PAYLOAD_BYTES, |
| 175 | CTR_RLC_UL_BYTES, |
| 176 | CTR_RLC_UL_PAYLOAD_BYTES, |
| 177 | CTR_DECODE_ERRORS, |
| 178 | CTR_SBA_ALLOCATED, |
| 179 | CTR_SBA_FREED, |
| 180 | CTR_SBA_TIMEDOUT, |
| 181 | CTR_LLC_FRAME_TIMEDOUT, |
| 182 | CTR_LLC_FRAME_DROPPED, |
| 183 | CTR_LLC_FRAME_SCHED, |
| 184 | CTR_LLC_DL_BYTES, |
| 185 | CTR_LLC_UL_BYTES, |
| 186 | CTR_RACH_REQUESTS, |
| 187 | CTR_11BIT_RACH_REQUESTS, |
| 188 | CTR_SPB_UL_FIRST_SEGMENT, |
| 189 | CTR_SPB_UL_SECOND_SEGMENT, |
| 190 | CTR_SPB_DL_FIRST_SEGMENT, |
| 191 | CTR_SPB_DL_SECOND_SEGMENT, |
| 192 | CTR_IMMEDIATE_ASSIGN_UL_TBF, |
| 193 | CTR_IMMEDIATE_ASSIGN_REJ, |
| 194 | CTR_IMMEDIATE_ASSIGN_DL_TBF, |
| 195 | CTR_CHANNEL_REQUEST_DESCRIPTION, |
| 196 | CTR_PKT_UL_ASSIGNMENT, |
| 197 | CTR_PKT_ACCESS_REJ, |
| 198 | CTR_PKT_DL_ASSIGNMENT, |
| 199 | CTR_RLC_RECV_CONTROL, |
| 200 | CTR_PUA_POLL_TIMEDOUT, |
| 201 | CTR_PUA_POLL_FAILED, |
| 202 | CTR_PDA_POLL_TIMEDOUT, |
| 203 | CTR_PDA_POLL_FAILED, |
| 204 | CTR_PUAN_POLL_TIMEDOUT, |
| 205 | CTR_PUAN_POLL_FAILED, |
| 206 | CTR_PDAN_POLL_TIMEDOUT, |
| 207 | CTR_PDAN_POLL_FAILED, |
| 208 | CTR_GPRS_DL_CS1, |
| 209 | CTR_GPRS_DL_CS2, |
| 210 | CTR_GPRS_DL_CS3, |
| 211 | CTR_GPRS_DL_CS4, |
| 212 | CTR_EGPRS_DL_MCS1, |
| 213 | CTR_EGPRS_DL_MCS2, |
| 214 | CTR_EGPRS_DL_MCS3, |
| 215 | CTR_EGPRS_DL_MCS4, |
| 216 | CTR_EGPRS_DL_MCS5, |
| 217 | CTR_EGPRS_DL_MCS6, |
| 218 | CTR_EGPRS_DL_MCS7, |
| 219 | CTR_EGPRS_DL_MCS8, |
| 220 | CTR_EGPRS_DL_MCS9, |
| 221 | CTR_GPRS_UL_CS1, |
| 222 | CTR_GPRS_UL_CS2, |
| 223 | CTR_GPRS_UL_CS3, |
| 224 | CTR_GPRS_UL_CS4, |
| 225 | CTR_EGPRS_UL_MCS1, |
| 226 | CTR_EGPRS_UL_MCS2, |
| 227 | CTR_EGPRS_UL_MCS3, |
| 228 | CTR_EGPRS_UL_MCS4, |
| 229 | CTR_EGPRS_UL_MCS5, |
| 230 | CTR_EGPRS_UL_MCS6, |
| 231 | CTR_EGPRS_UL_MCS7, |
| 232 | CTR_EGPRS_UL_MCS8, |
| 233 | CTR_EGPRS_UL_MCS9, |
| 234 | }; |
| 235 | |
Pau Espin Pedrol | 97e88fd | 2020-05-12 22:45:04 +0200 | [diff] [blame] | 236 | enum { |
| 237 | STAT_MS_PRESENT, |
| 238 | }; |
| 239 | |
Vadim Yanitskiy | a0a0b7f | 2020-05-21 19:55:46 +0700 | [diff] [blame] | 240 | /* RACH.ind parameters (to be parsed) */ |
| 241 | struct rach_ind_params { |
| 242 | enum ph_burst_type burst_type; |
| 243 | bool is_11bit; |
| 244 | uint16_t ra; |
| 245 | uint8_t trx_nr; |
| 246 | uint8_t ts_nr; |
| 247 | uint32_t rfn; |
| 248 | int16_t qta; |
| 249 | }; |
| 250 | |
| 251 | /* [EGPRS Packet] Channel Request parameters (parsed) */ |
| 252 | struct chan_req_params { |
| 253 | unsigned int egprs_mslot_class; |
| 254 | unsigned int priority; |
| 255 | bool single_block; |
| 256 | }; |
| 257 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 258 | #ifdef __cplusplus |
| 259 | /** |
| 260 | * I represent a GSM BTS. I have one or more TRX, I know the current |
| 261 | * GSM time and I have controllers that help with allocating resources |
| 262 | * on my TRXs. |
| 263 | */ |
| 264 | struct BTS { |
| 265 | public: |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 266 | BTS(struct gprs_pcu *pcu); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 267 | ~BTS(); |
Max | d5ffeb5 | 2019-03-18 15:48:38 +0100 | [diff] [blame] | 268 | void cleanup(); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 269 | |
| 270 | static BTS* main_bts(); |
| 271 | |
| 272 | struct gprs_rlcmac_bts *bts_data(); |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 273 | SBAController *sba(); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 274 | |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 275 | /** TODO: change the number to unsigned */ |
| 276 | void set_current_frame_number(int frame_number); |
Jacob Erlbeck | af75ce8 | 2015-08-26 13:22:28 +0200 | [diff] [blame] | 277 | void set_current_block_frame_number(int frame_number, unsigned max_delay); |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 278 | int current_frame_number() const; |
| 279 | |
Holger Hans Peter Freyther | f098489 | 2013-10-19 18:28:59 +0200 | [diff] [blame] | 280 | /** add paging to paging queue(s) */ |
Neels Hofmeyr | 59fc0bd | 2020-08-21 16:21:23 +0200 | [diff] [blame] | 281 | int add_paging(uint8_t chan_needed, const struct osmo_mobile_identity *mi); |
Holger Hans Peter Freyther | f098489 | 2013-10-19 18:28:59 +0200 | [diff] [blame] | 282 | |
Daniel Willmann | fe6e2e4 | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 283 | gprs_rlcmac_dl_tbf *dl_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts); |
| 284 | gprs_rlcmac_ul_tbf *ul_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts); |
Jacob Erlbeck | 3a10dbd | 2015-07-10 19:52:37 +0200 | [diff] [blame] | 285 | gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); |
| 286 | gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 287 | |
Max | a76a7d0 | 2018-01-26 11:09:16 +0100 | [diff] [blame] | 288 | int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const; |
Holger Hans Peter Freyther | 70ddde6 | 2013-10-26 19:17:58 +0200 | [diff] [blame] | 289 | |
Holger Hans Peter Freyther | 40cfaa6 | 2013-10-26 19:49:16 +0200 | [diff] [blame] | 290 | int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); |
Philipp Maier | 1275a3f | 2017-02-21 19:35:23 +0100 | [diff] [blame] | 291 | |
Max | 5dd8d1b | 2017-03-08 12:06:42 +0100 | [diff] [blame] | 292 | uint32_t rfn_to_fn(int32_t rfn); |
Vadim Yanitskiy | a0a0b7f | 2020-05-21 19:55:46 +0700 | [diff] [blame] | 293 | int rcv_rach(const struct rach_ind_params *rip); |
| 294 | int rcv_ptcch_rach(const struct rach_ind_params *rip); |
Holger Hans Peter Freyther | 40cfaa6 | 2013-10-26 19:49:16 +0200 | [diff] [blame] | 295 | |
Pau Espin Pedrol | d7c3265 | 2019-12-23 12:41:34 +0100 | [diff] [blame] | 296 | void snd_dl_ass(gprs_rlcmac_tbf *tbf, bool poll, uint16_t pgroup); |
Holger Hans Peter Freyther | d9262b3 | 2013-10-26 20:12:59 +0200 | [diff] [blame] | 297 | |
Pau Espin Pedrol | 343ec9b | 2020-10-30 18:35:54 +0100 | [diff] [blame] | 298 | uint8_t max_cs_dl(void) const; |
| 299 | uint8_t max_cs_ul(void) const; |
| 300 | uint8_t max_mcs_dl(void) const; |
| 301 | uint8_t max_mcs_ul(void) const; |
| 302 | void set_max_cs_dl(uint8_t cs_dl); |
| 303 | void set_max_cs_ul(uint8_t cs_ul); |
| 304 | void set_max_mcs_dl(uint8_t mcs_dl); |
| 305 | void set_max_mcs_ul(uint8_t mcs_ul); |
Pau Espin Pedrol | 022f9e5 | 2020-11-16 18:49:39 +0100 | [diff] [blame] | 306 | bool cs_dl_is_supported(CodingScheme cs); |
Pau Espin Pedrol | 343ec9b | 2020-10-30 18:35:54 +0100 | [diff] [blame] | 307 | |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 308 | GprsMsStorage &ms_store(); |
Vadim Yanitskiy | cb98894 | 2020-11-08 13:27:35 +0700 | [diff] [blame] | 309 | GprsMs *ms_by_tlli(uint32_t tlli, uint32_t old_tlli = GSM_RESERVED_TMSI); |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 310 | GprsMs *ms_by_imsi(const char *imsi); |
Jacob Erlbeck | 86b6f05 | 2015-11-27 15:17:34 +0100 | [diff] [blame] | 311 | GprsMs *ms_alloc(uint8_t ms_class, uint8_t egprs_ms_class = 0); |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 312 | |
Harald Welte | 717cdf5 | 2017-07-21 21:56:23 +0200 | [diff] [blame] | 313 | void send_gsmtap(enum pcu_gsmtap_category categ, bool uplink, uint8_t trx_no, |
| 314 | uint8_t ts_no, uint8_t channel, uint32_t fn, |
| 315 | const uint8_t *data, unsigned int len); |
Pau Espin Pedrol | 0b0391f | 2020-05-19 17:23:23 +0200 | [diff] [blame] | 316 | void send_gsmtap_meas(enum pcu_gsmtap_category categ, bool uplink, uint8_t trx_no, |
| 317 | uint8_t ts_no, uint8_t channel, uint32_t fn, |
| 318 | const uint8_t *data, unsigned int len, struct pcu_l1_meas *meas); |
Vadim Yanitskiy | 07b6487 | 2020-06-11 00:26:15 +0700 | [diff] [blame] | 319 | void send_gsmtap_rach(enum pcu_gsmtap_category categ, uint8_t channel, |
| 320 | const struct rach_ind_params *rip); |
Harald Welte | 717cdf5 | 2017-07-21 21:56:23 +0200 | [diff] [blame] | 321 | |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 322 | /* |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 323 | * Below for C interface for the VTY |
| 324 | */ |
| 325 | struct rate_ctr_group *rate_counters() const; |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 326 | struct osmo_stat_item_group *stat_items() const; |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 327 | void do_rate_ctr_inc(unsigned int ctr_id); |
Pau Espin Pedrol | a107f8f | 2020-05-12 22:32:24 +0200 | [diff] [blame] | 328 | void do_rate_ctr_add(unsigned int ctr_id, int inc); |
Pau Espin Pedrol | 97e88fd | 2020-05-12 22:45:04 +0200 | [diff] [blame] | 329 | void stat_item_add(unsigned int stat_id, int inc); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 330 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 331 | LListHead<gprs_rlcmac_tbf>& ul_tbfs(); |
| 332 | LListHead<gprs_rlcmac_tbf>& dl_tbfs(); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 333 | |
| 334 | struct gprs_rlcmac_bts m_bts; |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 335 | |
| 336 | /* back pointer to PCU object */ |
| 337 | struct gprs_pcu *pcu; |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 338 | private: |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 339 | |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 340 | int m_cur_fn; |
Jacob Erlbeck | 60f7703 | 2015-08-24 14:35:14 +0200 | [diff] [blame] | 341 | int m_cur_blk_fn; |
Pau Espin Pedrol | 343ec9b | 2020-10-30 18:35:54 +0100 | [diff] [blame] | 342 | uint8_t m_max_cs_dl, m_max_cs_ul; |
| 343 | uint8_t m_max_mcs_dl, m_max_mcs_ul; |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 344 | PollController m_pollController; |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 345 | SBAController m_sba; |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 346 | struct rate_ctr_group *m_ratectrs; |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 347 | struct osmo_stat_item_group *m_statg; |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 348 | |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 349 | GprsMsStorage m_ms_store; |
| 350 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 351 | /* list of uplink TBFs */ |
| 352 | LListHead<gprs_rlcmac_tbf> m_ul_tbfs; |
| 353 | /* list of downlink TBFs */ |
| 354 | LListHead<gprs_rlcmac_tbf> m_dl_tbfs; |
| 355 | |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 356 | /* disable copying to avoid slicing */ |
| 357 | BTS(const BTS&); |
| 358 | BTS& operator=(const BTS&); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 359 | }; |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 360 | |
| 361 | inline int BTS::current_frame_number() const |
| 362 | { |
| 363 | return m_cur_fn; |
| 364 | } |
Holger Hans Peter Freyther | 111614a | 2013-10-19 20:04:57 +0200 | [diff] [blame] | 365 | |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 366 | inline SBAController *BTS::sba() |
| 367 | { |
| 368 | return &m_sba; |
| 369 | } |
Holger Hans Peter Freyther | 65be480 | 2013-10-26 18:39:36 +0200 | [diff] [blame] | 370 | |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 371 | inline GprsMsStorage &BTS::ms_store() |
| 372 | { |
| 373 | return m_ms_store; |
| 374 | } |
| 375 | |
| 376 | inline GprsMs *BTS::ms_by_tlli(uint32_t tlli, uint32_t old_tlli) |
| 377 | { |
| 378 | return ms_store().get_ms(tlli, old_tlli); |
| 379 | } |
| 380 | |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 381 | inline GprsMs *BTS::ms_by_imsi(const char *imsi) |
| 382 | { |
| 383 | return ms_store().get_ms(0, 0, imsi); |
| 384 | } |
| 385 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 386 | inline LListHead<gprs_rlcmac_tbf>& BTS::ul_tbfs() |
| 387 | { |
| 388 | return m_ul_tbfs; |
| 389 | } |
| 390 | |
| 391 | inline LListHead<gprs_rlcmac_tbf>& BTS::dl_tbfs() |
| 392 | { |
| 393 | return m_dl_tbfs; |
| 394 | } |
| 395 | |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 396 | inline struct rate_ctr_group *BTS::rate_counters() const |
| 397 | { |
| 398 | return m_ratectrs; |
| 399 | } |
| 400 | |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 401 | inline struct osmo_stat_item_group *BTS::stat_items() const |
| 402 | { |
| 403 | return m_statg; |
| 404 | } |
| 405 | |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 406 | inline void BTS::do_rate_ctr_inc(unsigned int ctr_id) { |
| 407 | rate_ctr_inc(&m_ratectrs->ctr[ctr_id]); |
| 408 | } |
| 409 | |
Pau Espin Pedrol | a107f8f | 2020-05-12 22:32:24 +0200 | [diff] [blame] | 410 | inline void BTS::do_rate_ctr_add(unsigned int ctr_id, int inc) { |
| 411 | rate_ctr_add(&m_ratectrs->ctr[ctr_id], inc); |
| 412 | } |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 413 | |
Pau Espin Pedrol | 97e88fd | 2020-05-12 22:45:04 +0200 | [diff] [blame] | 414 | inline void BTS::stat_item_add(unsigned int stat_id, int inc) { |
| 415 | int32_t val = osmo_stat_item_get_last(m_statg->items[stat_id]); |
| 416 | osmo_stat_item_set(m_statg->items[stat_id], val + inc); |
| 417 | } |
Holger Hans Peter Freyther | 1587764 | 2013-10-27 09:50:15 +0100 | [diff] [blame] | 418 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 419 | struct gprs_pcu; |
| 420 | struct BTS* bts_alloc(struct gprs_pcu *pcu); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 421 | #endif |
| 422 | |
| 423 | #ifdef __cplusplus |
| 424 | extern "C" { |
| 425 | #endif |
Max | d5ffeb5 | 2019-03-18 15:48:38 +0100 | [diff] [blame] | 426 | void bts_cleanup(); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 427 | struct gprs_rlcmac_bts *bts_data(struct BTS *bts); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 428 | struct gprs_rlcmac_bts *bts_main_data(); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 429 | struct rate_ctr_group *bts_main_data_stats(); |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 430 | struct osmo_stat_item_group *bts_main_data_stat_items(); |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 431 | void bts_recalc_max_cs(struct gprs_rlcmac_bts *bts); |
| 432 | void bts_recalc_max_mcs(struct gprs_rlcmac_bts *bts); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 433 | struct GprsMs *bts_ms_by_imsi(struct BTS *bts, const char *imsi); |
| 434 | uint8_t bts_max_cs_dl(const struct BTS *bts); |
| 435 | uint8_t bts_max_cs_ul(const struct BTS *bts); |
| 436 | uint8_t bts_max_mcs_dl(const struct BTS *bts); |
| 437 | uint8_t bts_max_mcs_ul(const struct BTS *bts); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 438 | #ifdef __cplusplus |
| 439 | } |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 440 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 441 | #endif |