blob: 040386eb82c0ae4988f786113ca6fed62b52a4ee [file] [log] [blame]
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +02001/* 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
25extern "C" {
Alexander Couzens5012e072020-12-06 01:23:51 +010026#endif
27
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020028#include <osmocom/core/linuxlist.h>
Holger Hans Peter Freytherf5372982013-10-27 09:02:31 +010029#include <osmocom/core/rate_ctr.h>
Jacob Erlbeckf5898a02015-11-27 19:05:13 +010030#include <osmocom/core/stat_item.h>
Pau Espin Pedrol28f160e2019-09-05 14:48:35 +020031#include <osmocom/core/tdef.h>
Alexander Couzens5012e072020-12-06 01:23:51 +010032#include <osmocom/gprs/gprs_ns2.h>
bhargava959d1de2016-08-17 15:17:21 +053033#include <osmocom/gsm/l1sap.h>
Max84bf0fa2017-09-01 11:02:40 +020034#include <osmocom/gsm/protocol/gsm_04_08.h>
Vadim Yanitskiycb988942020-11-08 13:27:35 +070035#include <osmocom/gsm/gsm48.h>
Pau Espin Pedrolb2653fe2020-03-26 15:14:01 +010036#include "mslot_class.h"
37#include "gsm_rlcmac.h"
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +010038#include "gprs_pcu.h"
Alexander Couzens5012e072020-12-06 01:23:51 +010039#ifdef __cplusplus
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020040}
Alexander Couzens5012e072020-12-06 01:23:51 +010041#endif
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020042
Alexander Couzens5012e072020-12-06 01:23:51 +010043#ifdef __cplusplus
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +020044#include "poll_controller.h"
Holger Hans Peter Freythercedf8902013-10-19 20:47:12 +020045#include "sba.h"
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +020046#include "tbf.h"
Jacob Erlbecke43460b2015-05-13 13:33:12 +020047#include "gprs_ms_storage.h"
Pau Espin Pedrol2ae83372020-05-18 11:35:35 +020048#include "coding_scheme.h"
Max1187a772018-01-26 13:31:42 +010049#include <cxx_linuxlist.h>
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020050#endif
51
Daniel Willmannfb3fd092019-03-06 17:09:43 +010052#include <pdch.h>
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020053#include <stdint.h>
Pau Espin Pedrol4d166352020-10-26 18:39:51 +010054#include <stdbool.h>
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020055
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +020056struct BTS;
Jacob Erlbecke2e004e2015-06-18 17:16:26 +020057struct GprsMs;
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020058
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020059struct gprs_rlcmac_trx {
60 void *fl1h;
61 uint16_t arfcn;
62 struct gprs_rlcmac_pdch pdch[8];
Holger Hans Peter Freyther4ed1dae2013-10-20 10:14:03 +020063
64 /* back pointers */
65 struct BTS *bts;
66 uint8_t trx_no;
Jacob Erlbeck23f93a12015-06-30 08:52:54 +020067
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020068};
69
Maxd71e8b32016-09-19 16:17:06 +020070#ifdef __cplusplus
71extern "C" {
72#endif
Pau Espin Pedrolda971ee2020-12-16 15:59:45 +010073void bts_trx_reserve_slots(struct gprs_rlcmac_trx *trx, enum gprs_rlcmac_tbf_direction dir, uint8_t slots);
74void bts_trx_unreserve_slots(struct gprs_rlcmac_trx *trx, enum gprs_rlcmac_tbf_direction dir, uint8_t slots);
75
Minh-Quang Nguyen1bcfa9a2017-11-01 14:41:37 -040076void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, int8_t ta, bool is_rach);
Maxd71e8b32016-09-19 16:17:06 +020077#ifdef __cplusplus
78}
79#endif
80
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +020081/**
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 Freyther67ed34e2013-10-17 17:01:54 +020085struct gprs_rlcmac_bts {
Stefan Sperling5b22fb72018-02-14 19:46:33 +010086 bool active;
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020087 uint8_t bsic;
88 uint8_t fc_interval;
Jacob Erlbeck0288cdb2015-05-06 10:47:30 +020089 uint16_t fc_bucket_time;
Jacob Erlbeck87d73412015-04-21 12:56:48 +020090 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 Pedrold87722d2020-10-30 17:14:26 +010094 uint8_t cs_mask; /* Allowed CS mask from BTS */
95 uint16_t mcs_mask; /* Allowed MCS mask from BTS */
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020096 uint8_t initial_cs_dl, initial_cs_ul;
Jacob Erlbeck96ccea82016-01-07 15:00:43 +010097 uint8_t initial_mcs_dl, initial_mcs_ul;
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020098 uint16_t force_llc_lifetime; /* overrides lifetime from SGSN */
Jacob Erlbeck0c1c8772015-03-20 12:02:42 +010099 uint32_t llc_discard_csec;
Jacob Erlbeckd0261b72015-04-02 13:58:09 +0200100 uint32_t llc_idle_ack_csec;
Jacob Erlbeckd4ad7312015-07-17 16:39:09 +0200101 uint32_t llc_codel_interval_msec; /* 0=disabled, -1=use default interval */
Pau Espin Pedrol28f160e2019-09-05 14:48:35 +0200102 /* Timer defintions */
103 struct osmo_tdef *T_defs_bts; /* timers controlled by BTS, received through PCUIF */
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +0200104 uint8_t n3101;
105 uint8_t n3103;
106 uint8_t n3105;
107 struct gprs_rlcmac_trx trx[8];
Maxe9fe0e32017-09-28 15:56:05 +0200108
Max84bf0fa2017-09-01 11:02:40 +0200109 uint8_t si13[GSM_MACBLOCK_LEN];
110 bool si13_is_set;
Jacob Erlbeck36df7742016-01-19 15:53:30 +0100111 uint16_t ws_base;
112 uint16_t ws_pdch; /* increase WS by this value per PDCH */
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200113
Jacob Erlbeck77da3552015-07-16 18:33:46 +0200114 /* State for dynamic algorithm selection */
115 int multislot_disabled;
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +0200116
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200117 /**
118 * Point back to the C++ object. This is used during the transition
119 * period.
120 */
121 struct BTS *bts;
Pau Espin Pedrolc4178e52017-08-08 15:03:50 +0200122
Harald Welte57d35152018-07-05 03:11:17 +0200123 /* Are we talking Gb with IP-SNS (true) or classic Gb? */
Alexander Couzens5012e072020-12-06 01:23:51 +0100124 enum gprs_ns2_dialect ns_dialect;
Oliver Smithcfb63212019-09-05 17:13:33 +0200125
126 /* Packet Application Information (3GPP TS 44.060 11.2.47, usually ETWS primary message). We don't need to store
127 * more than one message, because they get sent so rarely. */
128 struct msgb *app_info;
129 uint32_t app_info_pending; /* Count of MS with active TBF, to which we did not send app_info yet */
Alexander Couzens290d9032020-09-16 21:52:02 +0200130
Alexander Couzens290d9032020-09-16 21:52:02 +0200131 /* main nsei */
132 struct gprs_ns2_nse *nse;
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +0200133};
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200134
Pau Espin Pedrol2338e532020-05-12 20:54:35 +0200135enum {
136 CTR_TBF_DL_ALLOCATED,
137 CTR_TBF_DL_FREED,
138 CTR_TBF_DL_ABORTED,
139 CTR_TBF_UL_ALLOCATED,
140 CTR_TBF_UL_FREED,
141 CTR_TBF_UL_ABORTED,
142 CTR_TBF_REUSED,
143 CTR_TBF_ALLOC_ALGO_A,
144 CTR_TBF_ALLOC_ALGO_B,
Pau Espin Pedrol2338e532020-05-12 20:54:35 +0200145 CTR_RLC_SENT,
146 CTR_RLC_RESENT,
147 CTR_RLC_RESTARTED,
148 CTR_RLC_STALLED,
149 CTR_RLC_NACKED,
150 CTR_RLC_FINAL_BLOCK_RESENT,
151 CTR_RLC_ASS_TIMEDOUT,
152 CTR_RLC_ASS_FAILED,
153 CTR_RLC_ACK_TIMEDOUT,
154 CTR_RLC_ACK_FAILED,
155 CTR_RLC_REL_TIMEDOUT,
156 CTR_RLC_LATE_BLOCK,
157 CTR_RLC_SENT_DUMMY,
158 CTR_RLC_SENT_CONTROL,
159 CTR_RLC_DL_BYTES,
160 CTR_RLC_DL_PAYLOAD_BYTES,
161 CTR_RLC_UL_BYTES,
162 CTR_RLC_UL_PAYLOAD_BYTES,
163 CTR_DECODE_ERRORS,
164 CTR_SBA_ALLOCATED,
165 CTR_SBA_FREED,
166 CTR_SBA_TIMEDOUT,
167 CTR_LLC_FRAME_TIMEDOUT,
168 CTR_LLC_FRAME_DROPPED,
169 CTR_LLC_FRAME_SCHED,
170 CTR_LLC_DL_BYTES,
171 CTR_LLC_UL_BYTES,
172 CTR_RACH_REQUESTS,
173 CTR_11BIT_RACH_REQUESTS,
174 CTR_SPB_UL_FIRST_SEGMENT,
175 CTR_SPB_UL_SECOND_SEGMENT,
176 CTR_SPB_DL_FIRST_SEGMENT,
177 CTR_SPB_DL_SECOND_SEGMENT,
178 CTR_IMMEDIATE_ASSIGN_UL_TBF,
179 CTR_IMMEDIATE_ASSIGN_REJ,
180 CTR_IMMEDIATE_ASSIGN_DL_TBF,
181 CTR_CHANNEL_REQUEST_DESCRIPTION,
182 CTR_PKT_UL_ASSIGNMENT,
183 CTR_PKT_ACCESS_REJ,
184 CTR_PKT_DL_ASSIGNMENT,
185 CTR_RLC_RECV_CONTROL,
186 CTR_PUA_POLL_TIMEDOUT,
187 CTR_PUA_POLL_FAILED,
188 CTR_PDA_POLL_TIMEDOUT,
189 CTR_PDA_POLL_FAILED,
190 CTR_PUAN_POLL_TIMEDOUT,
191 CTR_PUAN_POLL_FAILED,
192 CTR_PDAN_POLL_TIMEDOUT,
193 CTR_PDAN_POLL_FAILED,
194 CTR_GPRS_DL_CS1,
195 CTR_GPRS_DL_CS2,
196 CTR_GPRS_DL_CS3,
197 CTR_GPRS_DL_CS4,
198 CTR_EGPRS_DL_MCS1,
199 CTR_EGPRS_DL_MCS2,
200 CTR_EGPRS_DL_MCS3,
201 CTR_EGPRS_DL_MCS4,
202 CTR_EGPRS_DL_MCS5,
203 CTR_EGPRS_DL_MCS6,
204 CTR_EGPRS_DL_MCS7,
205 CTR_EGPRS_DL_MCS8,
206 CTR_EGPRS_DL_MCS9,
207 CTR_GPRS_UL_CS1,
208 CTR_GPRS_UL_CS2,
209 CTR_GPRS_UL_CS3,
210 CTR_GPRS_UL_CS4,
211 CTR_EGPRS_UL_MCS1,
212 CTR_EGPRS_UL_MCS2,
213 CTR_EGPRS_UL_MCS3,
214 CTR_EGPRS_UL_MCS4,
215 CTR_EGPRS_UL_MCS5,
216 CTR_EGPRS_UL_MCS6,
217 CTR_EGPRS_UL_MCS7,
218 CTR_EGPRS_UL_MCS8,
219 CTR_EGPRS_UL_MCS9,
220};
221
Pau Espin Pedrol97e88fd2020-05-12 22:45:04 +0200222enum {
223 STAT_MS_PRESENT,
224};
225
Vadim Yanitskiya0a0b7f2020-05-21 19:55:46 +0700226/* RACH.ind parameters (to be parsed) */
227struct rach_ind_params {
228 enum ph_burst_type burst_type;
229 bool is_11bit;
230 uint16_t ra;
231 uint8_t trx_nr;
232 uint8_t ts_nr;
233 uint32_t rfn;
234 int16_t qta;
235};
236
237/* [EGPRS Packet] Channel Request parameters (parsed) */
238struct chan_req_params {
239 unsigned int egprs_mslot_class;
240 unsigned int priority;
241 bool single_block;
242};
243
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200244#ifdef __cplusplus
245/**
246 * I represent a GSM BTS. I have one or more TRX, I know the current
247 * GSM time and I have controllers that help with allocating resources
248 * on my TRXs.
249 */
250struct BTS {
251public:
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100252 BTS(struct gprs_pcu *pcu);
Holger Hans Peter Freytherf5372982013-10-27 09:02:31 +0100253 ~BTS();
Maxd5ffeb52019-03-18 15:48:38 +0100254 void cleanup();
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200255
256 static BTS* main_bts();
257
258 struct gprs_rlcmac_bts *bts_data();
Holger Hans Peter Freythercedf8902013-10-19 20:47:12 +0200259 SBAController *sba();
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200260
Holger Hans Peter Freyther9b30c7f2013-10-17 19:59:56 +0200261 /** TODO: change the number to unsigned */
262 void set_current_frame_number(int frame_number);
Jacob Erlbeckaf75ce82015-08-26 13:22:28 +0200263 void set_current_block_frame_number(int frame_number, unsigned max_delay);
Holger Hans Peter Freyther9b30c7f2013-10-17 19:59:56 +0200264 int current_frame_number() const;
265
Holger Hans Peter Freytherf0984892013-10-19 18:28:59 +0200266 /** add paging to paging queue(s) */
Neels Hofmeyr59fc0bd2020-08-21 16:21:23 +0200267 int add_paging(uint8_t chan_needed, const struct osmo_mobile_identity *mi);
Holger Hans Peter Freytherf0984892013-10-19 18:28:59 +0200268
Daniel Willmannfe6e2e42014-07-10 17:44:06 +0200269 gprs_rlcmac_dl_tbf *dl_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts);
270 gprs_rlcmac_ul_tbf *ul_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts);
Jacob Erlbeck3a10dbd2015-07-10 19:52:37 +0200271 gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts);
272 gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts);
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +0200273
Maxa76a7d02018-01-26 11:09:16 +0100274 int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) const;
Holger Hans Peter Freyther70ddde62013-10-26 19:17:58 +0200275
Holger Hans Peter Freyther40cfaa62013-10-26 19:49:16 +0200276 int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn);
Philipp Maier1275a3f2017-02-21 19:35:23 +0100277
Max5dd8d1b2017-03-08 12:06:42 +0100278 uint32_t rfn_to_fn(int32_t rfn);
Vadim Yanitskiya0a0b7f2020-05-21 19:55:46 +0700279 int rcv_rach(const struct rach_ind_params *rip);
280 int rcv_ptcch_rach(const struct rach_ind_params *rip);
Holger Hans Peter Freyther40cfaa62013-10-26 19:49:16 +0200281
Pau Espin Pedrold7c32652019-12-23 12:41:34 +0100282 void snd_dl_ass(gprs_rlcmac_tbf *tbf, bool poll, uint16_t pgroup);
Holger Hans Peter Freytherd9262b32013-10-26 20:12:59 +0200283
Pau Espin Pedrol343ec9b2020-10-30 18:35:54 +0100284 uint8_t max_cs_dl(void) const;
285 uint8_t max_cs_ul(void) const;
286 uint8_t max_mcs_dl(void) const;
287 uint8_t max_mcs_ul(void) const;
288 void set_max_cs_dl(uint8_t cs_dl);
289 void set_max_cs_ul(uint8_t cs_ul);
290 void set_max_mcs_dl(uint8_t mcs_dl);
291 void set_max_mcs_ul(uint8_t mcs_ul);
Pau Espin Pedrol022f9e52020-11-16 18:49:39 +0100292 bool cs_dl_is_supported(CodingScheme cs);
Pau Espin Pedrol343ec9b2020-10-30 18:35:54 +0100293
Jacob Erlbecke43460b2015-05-13 13:33:12 +0200294 GprsMsStorage &ms_store();
Vadim Yanitskiycb988942020-11-08 13:27:35 +0700295 GprsMs *ms_by_tlli(uint32_t tlli, uint32_t old_tlli = GSM_RESERVED_TMSI);
Jacob Erlbeck076f5c72015-08-21 18:00:54 +0200296 GprsMs *ms_by_imsi(const char *imsi);
Jacob Erlbeck86b6f052015-11-27 15:17:34 +0100297 GprsMs *ms_alloc(uint8_t ms_class, uint8_t egprs_ms_class = 0);
Jacob Erlbecke43460b2015-05-13 13:33:12 +0200298
Harald Welte717cdf52017-07-21 21:56:23 +0200299 void send_gsmtap(enum pcu_gsmtap_category categ, bool uplink, uint8_t trx_no,
300 uint8_t ts_no, uint8_t channel, uint32_t fn,
301 const uint8_t *data, unsigned int len);
Pau Espin Pedrol0b0391f2020-05-19 17:23:23 +0200302 void send_gsmtap_meas(enum pcu_gsmtap_category categ, bool uplink, uint8_t trx_no,
303 uint8_t ts_no, uint8_t channel, uint32_t fn,
304 const uint8_t *data, unsigned int len, struct pcu_l1_meas *meas);
Vadim Yanitskiy07b64872020-06-11 00:26:15 +0700305 void send_gsmtap_rach(enum pcu_gsmtap_category categ, uint8_t channel,
306 const struct rach_ind_params *rip);
Harald Welte717cdf52017-07-21 21:56:23 +0200307
Holger Hans Peter Freytherf5372982013-10-27 09:02:31 +0100308 /*
Holger Hans Peter Freytherf5372982013-10-27 09:02:31 +0100309 * Below for C interface for the VTY
310 */
311 struct rate_ctr_group *rate_counters() const;
Jacob Erlbeckf5898a02015-11-27 19:05:13 +0100312 struct osmo_stat_item_group *stat_items() const;
Pau Espin Pedrol2338e532020-05-12 20:54:35 +0200313 void do_rate_ctr_inc(unsigned int ctr_id);
Pau Espin Pedrola107f8f2020-05-12 22:32:24 +0200314 void do_rate_ctr_add(unsigned int ctr_id, int inc);
Pau Espin Pedrol97e88fd2020-05-12 22:45:04 +0200315 void stat_item_add(unsigned int stat_id, int inc);
Holger Hans Peter Freytherf5372982013-10-27 09:02:31 +0100316
Jacob Erlbecked2dbf62015-12-28 19:15:40 +0100317 LListHead<gprs_rlcmac_tbf>& ul_tbfs();
318 LListHead<gprs_rlcmac_tbf>& dl_tbfs();
Pau Espin Pedrolda971ee2020-12-16 15:59:45 +0100319
320 struct gprs_rlcmac_bts m_bts;
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100321
322 /* back pointer to PCU object */
323 struct gprs_pcu *pcu;
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200324private:
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100325
Holger Hans Peter Freyther9b30c7f2013-10-17 19:59:56 +0200326 int m_cur_fn;
Jacob Erlbeck60f77032015-08-24 14:35:14 +0200327 int m_cur_blk_fn;
Pau Espin Pedrol343ec9b2020-10-30 18:35:54 +0100328 uint8_t m_max_cs_dl, m_max_cs_ul;
329 uint8_t m_max_mcs_dl, m_max_mcs_ul;
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +0200330 PollController m_pollController;
Holger Hans Peter Freythercedf8902013-10-19 20:47:12 +0200331 SBAController m_sba;
Holger Hans Peter Freytherf5372982013-10-27 09:02:31 +0100332 struct rate_ctr_group *m_ratectrs;
Jacob Erlbeckf5898a02015-11-27 19:05:13 +0100333 struct osmo_stat_item_group *m_statg;
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +0200334
Jacob Erlbecke43460b2015-05-13 13:33:12 +0200335 GprsMsStorage m_ms_store;
336
Jacob Erlbecked2dbf62015-12-28 19:15:40 +0100337 /* list of uplink TBFs */
338 LListHead<gprs_rlcmac_tbf> m_ul_tbfs;
339 /* list of downlink TBFs */
340 LListHead<gprs_rlcmac_tbf> m_dl_tbfs;
341
Holger Hans Peter Freytherb78adcd2013-10-17 20:12:37 +0200342 /* disable copying to avoid slicing */
343 BTS(const BTS&);
344 BTS& operator=(const BTS&);
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200345};
Holger Hans Peter Freyther9b30c7f2013-10-17 19:59:56 +0200346
347inline int BTS::current_frame_number() const
348{
349 return m_cur_fn;
350}
Holger Hans Peter Freyther111614a2013-10-19 20:04:57 +0200351
Holger Hans Peter Freythercedf8902013-10-19 20:47:12 +0200352inline SBAController *BTS::sba()
353{
354 return &m_sba;
355}
Holger Hans Peter Freyther65be4802013-10-26 18:39:36 +0200356
Jacob Erlbecke43460b2015-05-13 13:33:12 +0200357inline GprsMsStorage &BTS::ms_store()
358{
359 return m_ms_store;
360}
361
362inline GprsMs *BTS::ms_by_tlli(uint32_t tlli, uint32_t old_tlli)
363{
364 return ms_store().get_ms(tlli, old_tlli);
365}
366
Jacob Erlbeck076f5c72015-08-21 18:00:54 +0200367inline GprsMs *BTS::ms_by_imsi(const char *imsi)
368{
369 return ms_store().get_ms(0, 0, imsi);
370}
371
Jacob Erlbecked2dbf62015-12-28 19:15:40 +0100372inline LListHead<gprs_rlcmac_tbf>& BTS::ul_tbfs()
373{
374 return m_ul_tbfs;
375}
376
377inline LListHead<gprs_rlcmac_tbf>& BTS::dl_tbfs()
378{
379 return m_dl_tbfs;
380}
381
Holger Hans Peter Freytherf5372982013-10-27 09:02:31 +0100382inline struct rate_ctr_group *BTS::rate_counters() const
383{
384 return m_ratectrs;
385}
386
Jacob Erlbeckf5898a02015-11-27 19:05:13 +0100387inline struct osmo_stat_item_group *BTS::stat_items() const
388{
389 return m_statg;
390}
391
Pau Espin Pedrol2338e532020-05-12 20:54:35 +0200392inline void BTS::do_rate_ctr_inc(unsigned int ctr_id) {
393 rate_ctr_inc(&m_ratectrs->ctr[ctr_id]);
394}
395
Pau Espin Pedrola107f8f2020-05-12 22:32:24 +0200396inline void BTS::do_rate_ctr_add(unsigned int ctr_id, int inc) {
397 rate_ctr_add(&m_ratectrs->ctr[ctr_id], inc);
398}
Alexander Couzens7fdbf892016-05-21 19:45:23 +0200399
Pau Espin Pedrol97e88fd2020-05-12 22:45:04 +0200400inline void BTS::stat_item_add(unsigned int stat_id, int inc) {
401 int32_t val = osmo_stat_item_get_last(m_statg->items[stat_id]);
402 osmo_stat_item_set(m_statg->items[stat_id], val + inc);
403}
Holger Hans Peter Freyther15877642013-10-27 09:50:15 +0100404
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100405struct gprs_pcu;
406struct BTS* bts_alloc(struct gprs_pcu *pcu);
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200407#endif
408
409#ifdef __cplusplus
410extern "C" {
411#endif
Maxd5ffeb52019-03-18 15:48:38 +0100412 void bts_cleanup();
Pau Espin Pedrolda971ee2020-12-16 15:59:45 +0100413 struct gprs_rlcmac_bts *bts_data(struct BTS *bts);
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200414 struct gprs_rlcmac_bts *bts_main_data();
Holger Hans Peter Freytherf5372982013-10-27 09:02:31 +0100415 struct rate_ctr_group *bts_main_data_stats();
Jacob Erlbeckf5898a02015-11-27 19:05:13 +0100416 struct osmo_stat_item_group *bts_main_data_stat_items();
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100417 void bts_recalc_max_cs(struct gprs_rlcmac_bts *bts);
418 void bts_recalc_max_mcs(struct gprs_rlcmac_bts *bts);
Pau Espin Pedrolda971ee2020-12-16 15:59:45 +0100419 struct GprsMs *bts_ms_by_imsi(struct BTS *bts, const char *imsi);
420 uint8_t bts_max_cs_dl(const struct BTS *bts);
421 uint8_t bts_max_cs_ul(const struct BTS *bts);
422 uint8_t bts_max_mcs_dl(const struct BTS *bts);
423 uint8_t bts_max_mcs_ul(const struct BTS *bts);
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200424#ifdef __cplusplus
425}
Holger Hans Peter Freyther17b0d832013-10-19 17:37:48 +0200426
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +0200427#endif