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" { |
| 26 | #include <osmocom/core/linuxlist.h> |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 27 | #include <osmocom/core/rate_ctr.h> |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 28 | #include <osmocom/core/stat_item.h> |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 29 | #include <osmocom/core/timer.h> |
Max | 2efdf69 | 2016-02-22 11:39:30 +0100 | [diff] [blame] | 30 | #include <osmocom/core/gsmtap.h> |
bhargava | 959d1de | 2016-08-17 15:17:21 +0530 | [diff] [blame] | 31 | #include <osmocom/gsm/l1sap.h> |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 32 | } |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 33 | |
| 34 | #include "poll_controller.h" |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 35 | #include "sba.h" |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 36 | #include "tbf.h" |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 37 | #include "gprs_ms_storage.h" |
Jacob Erlbeck | 9e862e1 | 2015-12-14 15:19:12 +0100 | [diff] [blame] | 38 | #include "gprs_coding_scheme.h" |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 39 | #endif |
| 40 | |
| 41 | #include <stdint.h> |
| 42 | |
Jacob Erlbeck | d4ad731 | 2015-07-17 16:39:09 +0200 | [diff] [blame] | 43 | #define LLC_CODEL_DISABLE 0 |
| 44 | #define LLC_CODEL_USE_DEFAULT (-1) |
Aravind Sirsikar | 99ab0a8 | 2016-06-15 17:46:41 +0530 | [diff] [blame] | 45 | #define MAX_GPRS_CS 9 |
| 46 | |
Jacob Erlbeck | d4ad731 | 2015-07-17 16:39:09 +0200 | [diff] [blame] | 47 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 48 | struct BTS; |
Jacob Erlbeck | e2e004e | 2015-06-18 17:16:26 +0200 | [diff] [blame] | 49 | struct GprsMs; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 50 | |
| 51 | /* |
| 52 | * PDCH instance |
| 53 | */ |
| 54 | struct gprs_rlcmac_pdch { |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 55 | #ifdef __cplusplus |
Holger Hans Peter Freyther | 24e98d0 | 2013-10-19 18:15:44 +0200 | [diff] [blame] | 56 | struct gprs_rlcmac_paging *dequeue_paging(); |
| 57 | struct msgb *packet_paging_request(); |
| 58 | |
Holger Hans Peter Freyther | f098489 | 2013-10-19 18:28:59 +0200 | [diff] [blame] | 59 | void add_paging(struct gprs_rlcmac_paging *pag); |
Holger Hans Peter Freyther | 24e98d0 | 2013-10-19 18:15:44 +0200 | [diff] [blame] | 60 | |
Holger Hans Peter Freyther | 09ef27a | 2013-10-20 16:37:05 +0200 | [diff] [blame] | 61 | void free_resources(); |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 62 | |
| 63 | bool is_enabled() const; |
| 64 | |
| 65 | void enable(); |
| 66 | void disable(); |
Holger Hans Peter Freyther | 9ae367f | 2013-10-26 16:42:38 +0200 | [diff] [blame] | 67 | |
| 68 | /* dispatching of messages */ |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 69 | int rcv_block(uint8_t *data, uint8_t len, uint32_t fn, |
| 70 | struct pcu_l1_meas *meas); |
Jacob Erlbeck | 9e862e1 | 2015-12-14 15:19:12 +0100 | [diff] [blame] | 71 | int rcv_block_gprs(uint8_t *data, uint32_t fn, |
| 72 | struct pcu_l1_meas *meas, GprsCodingScheme cs); |
Jacob Erlbeck | 554a835 | 2015-12-09 17:39:56 +0100 | [diff] [blame] | 73 | int rcv_data_block(uint8_t *data, uint32_t fn, |
Jacob Erlbeck | 690a734 | 2015-11-30 18:09:17 +0100 | [diff] [blame] | 74 | struct pcu_l1_meas *meas, GprsCodingScheme cs); |
Holger Hans Peter Freyther | 65be480 | 2013-10-26 18:39:36 +0200 | [diff] [blame] | 75 | |
| 76 | gprs_rlcmac_bts *bts_data() const; |
| 77 | BTS *bts() const; |
Holger Hans Peter Freyther | 05f8efc | 2013-10-26 18:53:16 +0200 | [diff] [blame] | 78 | uint8_t trx_no() const; |
Daniel Willmann | 1e0c610 | 2014-06-04 14:56:09 +0200 | [diff] [blame] | 79 | |
Daniel Willmann | fe6e2e4 | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 80 | struct gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi); |
| 81 | struct gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi); |
Jacob Erlbeck | ccc34e4 | 2015-06-29 13:45:05 +0200 | [diff] [blame] | 82 | |
| 83 | void attach_tbf(gprs_rlcmac_tbf *tbf); |
| 84 | void detach_tbf(gprs_rlcmac_tbf *tbf); |
| 85 | |
| 86 | unsigned num_tbfs(enum gprs_rlcmac_tbf_direction dir) const; |
Jacob Erlbeck | 23f93a1 | 2015-06-30 08:52:54 +0200 | [diff] [blame] | 87 | |
| 88 | void reserve(enum gprs_rlcmac_tbf_direction dir); |
| 89 | void unreserve(enum gprs_rlcmac_tbf_direction dir); |
| 90 | unsigned num_reserved(enum gprs_rlcmac_tbf_direction dir) const; |
Jacob Erlbeck | cc9358f | 2015-06-30 14:10:13 +0200 | [diff] [blame] | 91 | |
| 92 | uint8_t assigned_usf() const; |
Jacob Erlbeck | 47a57f6 | 2015-07-08 12:53:16 +0200 | [diff] [blame] | 93 | uint32_t assigned_tfi(enum gprs_rlcmac_tbf_direction dir) const; |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 94 | #endif |
| 95 | |
| 96 | uint8_t m_is_enabled; /* TS is enabled */ |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 97 | uint8_t tsc; /* TSC of this slot */ |
| 98 | uint8_t next_ul_tfi; /* next uplink TBF/TFI to schedule (0..31) */ |
| 99 | uint8_t next_dl_tfi; /* next downlink TBF/TFI to schedule (0..31) */ |
Holger Hans Peter Freyther | 705653b | 2013-11-26 16:39:28 +0100 | [diff] [blame] | 100 | uint8_t next_ctrl_prio; /* next kind of ctrl message to schedule */ |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 101 | struct llist_head paging_list; /* list of paging messages */ |
| 102 | uint32_t last_rts_fn; /* store last frame number of RTS */ |
Holger Hans Peter Freyther | 4ed1dae | 2013-10-20 10:14:03 +0200 | [diff] [blame] | 103 | |
| 104 | /* back pointers */ |
| 105 | struct gprs_rlcmac_trx *trx; |
| 106 | uint8_t ts_no; |
Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 107 | |
| 108 | #ifdef __cplusplus |
| 109 | private: |
Holger Hans Peter Freyther | 05f8efc | 2013-10-26 18:53:16 +0200 | [diff] [blame] | 110 | int rcv_control_block(bitvec *rlc_block, uint32_t fn); |
Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 111 | |
Holger Hans Peter Freyther | e1a075a | 2013-10-27 13:35:30 +0100 | [diff] [blame] | 112 | void rcv_control_ack(Packet_Control_Acknowledgement_t *, uint32_t fn); |
Holger Hans Peter Freyther | 5da2014 | 2013-10-27 11:41:01 +0100 | [diff] [blame] | 113 | void rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *, uint32_t fn); |
Jacob Erlbeck | ae9c575 | 2016-01-13 13:55:44 +0100 | [diff] [blame] | 114 | void rcv_control_egprs_dl_ack_nack(EGPRS_PD_AckNack_t *, uint32_t fn); |
Holger Hans Peter Freyther | 7a34471 | 2013-10-27 11:37:53 +0100 | [diff] [blame] | 115 | void rcv_resource_request(Packet_Resource_Request_t *t, uint32_t fn); |
Holger Hans Peter Freyther | cb5c49b | 2013-10-27 11:19:13 +0100 | [diff] [blame] | 116 | void rcv_measurement_report(Packet_Measurement_Report_t *t, uint32_t fn); |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 117 | gprs_rlcmac_tbf *tbf_from_list_by_tfi( |
| 118 | LListHead<gprs_rlcmac_tbf> *tbf_list, uint8_t tfi, |
Daniel Willmann | 2207c5e | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 119 | enum gprs_rlcmac_tbf_direction dir); |
Jacob Erlbeck | 3a10dbd | 2015-07-10 19:52:37 +0200 | [diff] [blame] | 120 | gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, |
| 121 | enum gprs_rlcmac_tbf_direction dir); |
Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 122 | #endif |
Jacob Erlbeck | ccc34e4 | 2015-06-29 13:45:05 +0200 | [diff] [blame] | 123 | |
| 124 | uint8_t m_num_tbfs[2]; |
Jacob Erlbeck | 23f93a1 | 2015-06-30 08:52:54 +0200 | [diff] [blame] | 125 | uint8_t m_num_reserved[2]; |
Jacob Erlbeck | cc9358f | 2015-06-30 14:10:13 +0200 | [diff] [blame] | 126 | uint8_t m_assigned_usf; /* bit set */ |
Jacob Erlbeck | 47a57f6 | 2015-07-08 12:53:16 +0200 | [diff] [blame] | 127 | uint32_t m_assigned_tfi[2]; /* bit set */ |
Jacob Erlbeck | 3a10dbd | 2015-07-10 19:52:37 +0200 | [diff] [blame] | 128 | struct gprs_rlcmac_tbf *m_tbfs[2][32]; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | struct gprs_rlcmac_trx { |
| 132 | void *fl1h; |
| 133 | uint16_t arfcn; |
| 134 | struct gprs_rlcmac_pdch pdch[8]; |
Holger Hans Peter Freyther | 4ed1dae | 2013-10-20 10:14:03 +0200 | [diff] [blame] | 135 | |
| 136 | /* back pointers */ |
| 137 | struct BTS *bts; |
| 138 | uint8_t trx_no; |
Jacob Erlbeck | 23f93a1 | 2015-06-30 08:52:54 +0200 | [diff] [blame] | 139 | |
| 140 | #ifdef __cplusplus |
| 141 | void reserve_slots(enum gprs_rlcmac_tbf_direction dir, uint8_t slots); |
| 142 | void unreserve_slots(enum gprs_rlcmac_tbf_direction dir, uint8_t slots); |
| 143 | #endif |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 144 | }; |
| 145 | |
Max | d71e8b3 | 2016-09-19 16:17:06 +0200 | [diff] [blame] | 146 | #ifdef __cplusplus |
| 147 | extern "C" { |
| 148 | #endif |
| 149 | void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, |
| 150 | uint8_t ta); |
| 151 | #ifdef __cplusplus |
| 152 | } |
| 153 | #endif |
| 154 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 155 | /** |
| 156 | * This is the data from C. As soon as our minimal compiler is gcc 4.7 |
| 157 | * we can start to compile pcu_vty.c with c++ and remove the split. |
| 158 | */ |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 159 | struct gprs_rlcmac_bts { |
| 160 | uint8_t bsic; |
| 161 | uint8_t fc_interval; |
Jacob Erlbeck | 0288cdb | 2015-05-06 10:47:30 +0200 | [diff] [blame] | 162 | uint16_t fc_bucket_time; |
Jacob Erlbeck | 87d7341 | 2015-04-21 12:56:48 +0200 | [diff] [blame] | 163 | uint32_t fc_bvc_bucket_size; |
| 164 | uint32_t fc_bvc_leak_rate; |
| 165 | uint32_t fc_ms_bucket_size; |
| 166 | uint32_t fc_ms_leak_rate; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 167 | uint8_t cs1; |
| 168 | uint8_t cs2; |
| 169 | uint8_t cs3; |
| 170 | uint8_t cs4; |
| 171 | uint8_t initial_cs_dl, initial_cs_ul; |
Jacob Erlbeck | 96ccea8 | 2016-01-07 15:00:43 +0100 | [diff] [blame] | 172 | uint8_t initial_mcs_dl, initial_mcs_ul; |
Jacob Erlbeck | b33e675 | 2015-06-04 19:04:30 +0200 | [diff] [blame] | 173 | uint8_t max_cs_dl, max_cs_ul; |
Jacob Erlbeck | 0d05805 | 2016-01-07 11:48:28 +0100 | [diff] [blame] | 174 | uint8_t max_mcs_dl, max_mcs_ul; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 175 | uint8_t force_cs; /* 0=use from BTS 1=use from VTY */ |
| 176 | uint16_t force_llc_lifetime; /* overrides lifetime from SGSN */ |
Jacob Erlbeck | 0c1c877 | 2015-03-20 12:02:42 +0100 | [diff] [blame] | 177 | uint32_t llc_discard_csec; |
Jacob Erlbeck | d0261b7 | 2015-04-02 13:58:09 +0200 | [diff] [blame] | 178 | uint32_t llc_idle_ack_csec; |
Jacob Erlbeck | d4ad731 | 2015-07-17 16:39:09 +0200 | [diff] [blame] | 179 | uint32_t llc_codel_interval_msec; /* 0=disabled, -1=use default interval */ |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 180 | uint8_t t3142; |
| 181 | uint8_t t3169; |
| 182 | uint8_t t3191; |
| 183 | uint16_t t3193_msec; |
| 184 | uint8_t t3195; |
| 185 | uint8_t n3101; |
| 186 | uint8_t n3103; |
| 187 | uint8_t n3105; |
Max | 2efdf69 | 2016-02-22 11:39:30 +0100 | [diff] [blame] | 188 | struct gsmtap_inst *gsmtap; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 189 | struct gprs_rlcmac_trx trx[8]; |
| 190 | int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts, |
Jacob Erlbeck | e2e004e | 2015-06-18 17:16:26 +0200 | [diff] [blame] | 191 | struct GprsMs *ms, |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame] | 192 | struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, |
| 193 | int use_tbf); |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 194 | uint32_t alloc_algorithm_curst; /* options to customize algorithm */ |
| 195 | uint8_t force_two_phase; |
| 196 | uint8_t alpha, gamma; |
Jacob Erlbeck | 953c789 | 2015-09-28 18:12:57 +0200 | [diff] [blame] | 197 | uint8_t egprs_enabled; |
Jacob Erlbeck | 3bed5d1 | 2015-03-19 11:22:38 +0100 | [diff] [blame] | 198 | uint32_t dl_tbf_idle_msec; /* hold time for idle DL TBFs */ |
Aravind Sirsikar | e6cadb4 | 2016-08-16 16:32:59 +0530 | [diff] [blame] | 199 | |
| 200 | /* 0 to support resegmentation in DL, 1 for no reseg */ |
| 201 | uint8_t dl_arq_type; |
| 202 | |
Jacob Erlbeck | a098c19 | 2015-05-28 16:11:19 +0200 | [diff] [blame] | 203 | uint32_t ms_idle_sec; |
Jacob Erlbeck | 1751c62 | 2015-06-04 12:12:32 +0200 | [diff] [blame] | 204 | uint8_t cs_adj_enabled; |
| 205 | uint8_t cs_adj_upper_limit; |
| 206 | uint8_t cs_adj_lower_limit; |
Aravind Sirsikar | 99ab0a8 | 2016-06-15 17:46:41 +0530 | [diff] [blame] | 207 | struct {int16_t low; int16_t high; } cs_lqual_ranges[MAX_GPRS_CS]; |
Jacob Erlbeck | 70b96aa | 2015-06-12 10:52:34 +0200 | [diff] [blame] | 208 | uint16_t cs_downgrade_threshold; /* downgrade if less packets left (DL) */ |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 209 | uint16_t ws_base; |
| 210 | 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] | 211 | |
Jacob Erlbeck | 77da355 | 2015-07-16 18:33:46 +0200 | [diff] [blame] | 212 | /* State for dynamic algorithm selection */ |
| 213 | int multislot_disabled; |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 214 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 215 | /** |
| 216 | * Point back to the C++ object. This is used during the transition |
| 217 | * period. |
| 218 | */ |
| 219 | struct BTS *bts; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 220 | }; |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 221 | |
| 222 | #ifdef __cplusplus |
| 223 | /** |
| 224 | * I represent a GSM BTS. I have one or more TRX, I know the current |
| 225 | * GSM time and I have controllers that help with allocating resources |
| 226 | * on my TRXs. |
| 227 | */ |
| 228 | struct BTS { |
| 229 | public: |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 230 | enum { |
| 231 | CTR_TBF_DL_ALLOCATED, |
| 232 | CTR_TBF_DL_FREED, |
Jacob Erlbeck | 0316dc6 | 2016-01-21 20:12:04 +0100 | [diff] [blame] | 233 | CTR_TBF_DL_ABORTED, |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 234 | CTR_TBF_UL_ALLOCATED, |
| 235 | CTR_TBF_UL_FREED, |
Jacob Erlbeck | 0316dc6 | 2016-01-21 20:12:04 +0100 | [diff] [blame] | 236 | CTR_TBF_UL_ABORTED, |
Holger Hans Peter Freyther | aa35ba7 | 2013-11-13 15:02:50 +0100 | [diff] [blame] | 237 | CTR_TBF_REUSED, |
Jacob Erlbeck | 5979fe9 | 2015-07-14 14:02:41 +0200 | [diff] [blame] | 238 | CTR_TBF_ALLOC_ALGO_A, |
| 239 | CTR_TBF_ALLOC_ALGO_B, |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 240 | CTR_TBF_FAILED_EGPRS_ONLY, |
Holger Hans Peter Freyther | e9429b5 | 2013-11-13 19:36:57 +0100 | [diff] [blame] | 241 | CTR_RLC_SENT, |
| 242 | CTR_RLC_RESENT, |
Holger Hans Peter Freyther | ef93bdb | 2013-11-24 00:01:50 +0100 | [diff] [blame] | 243 | CTR_RLC_RESTARTED, |
Holger Hans Peter Freyther | c70aae4 | 2013-11-19 17:09:37 +0100 | [diff] [blame] | 244 | CTR_RLC_STALLED, |
Holger Hans Peter Freyther | 092478f | 2013-11-23 01:01:19 +0100 | [diff] [blame] | 245 | CTR_RLC_NACKED, |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 246 | CTR_RLC_FINAL_BLOCK_RESENT, |
Jacob Erlbeck | c91c18e | 2015-07-07 09:33:29 +0200 | [diff] [blame] | 247 | CTR_RLC_ASS_TIMEDOUT, |
Jacob Erlbeck | 7c8d39a | 2015-09-07 14:04:56 +0200 | [diff] [blame] | 248 | CTR_RLC_ASS_FAILED, |
Jacob Erlbeck | c91c18e | 2015-07-07 09:33:29 +0200 | [diff] [blame] | 249 | CTR_RLC_ACK_TIMEDOUT, |
Jacob Erlbeck | 7c8d39a | 2015-09-07 14:04:56 +0200 | [diff] [blame] | 250 | CTR_RLC_ACK_FAILED, |
Jacob Erlbeck | c91c18e | 2015-07-07 09:33:29 +0200 | [diff] [blame] | 251 | CTR_RLC_REL_TIMEDOUT, |
Jacob Erlbeck | be4a08b | 2015-08-25 15:19:31 +0200 | [diff] [blame] | 252 | CTR_RLC_LATE_BLOCK, |
Alexander Couzens | 2cb1547 | 2016-05-18 16:43:10 +0200 | [diff] [blame] | 253 | CTR_RLC_SENT_DUMMY, |
Alexander Couzens | f929e62 | 2016-05-22 00:02:56 +0200 | [diff] [blame] | 254 | CTR_RLC_SENT_CONTROL, |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 255 | CTR_RLC_DL_BYTES, |
| 256 | CTR_RLC_DL_PAYLOAD_BYTES, |
| 257 | CTR_RLC_UL_BYTES, |
| 258 | CTR_RLC_UL_PAYLOAD_BYTES, |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 259 | CTR_DECODE_ERRORS, |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 260 | CTR_SBA_ALLOCATED, |
| 261 | CTR_SBA_FREED, |
| 262 | CTR_SBA_TIMEDOUT, |
Holger Hans Peter Freyther | 1997787 | 2013-10-27 10:34:31 +0100 | [diff] [blame] | 263 | CTR_LLC_FRAME_TIMEDOUT, |
| 264 | CTR_LLC_FRAME_DROPPED, |
Holger Hans Peter Freyther | b3d5ee2 | 2013-11-13 16:43:26 +0100 | [diff] [blame] | 265 | CTR_LLC_FRAME_SCHED, |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 266 | CTR_LLC_DL_BYTES, |
| 267 | CTR_LLC_UL_BYTES, |
Holger Hans Peter Freyther | c1ae226 | 2013-10-27 10:50:35 +0100 | [diff] [blame] | 268 | CTR_RACH_REQUESTS, |
sivasankari | 67b89ca | 2016-12-29 16:25:30 +0530 | [diff] [blame] | 269 | CTR_11BIT_RACH_REQUESTS, |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 270 | CTR_SPB_UL_FIRST_SEGMENT, |
| 271 | CTR_SPB_UL_SECOND_SEGMENT, |
| 272 | CTR_SPB_DL_FIRST_SEGMENT, |
| 273 | CTR_SPB_DL_SECOND_SEGMENT, |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 274 | CTR_IMMEDIATE_ASSIGN_UL_TBF, |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 275 | CTR_IMMEDIATE_ASSIGN_REJ, |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 276 | CTR_IMMEDIATE_ASSIGN_DL_TBF, |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 277 | CTR_CHANNEL_REQUEST_DESCRIPTION, |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 278 | CTR_PKT_UL_ASSIGNMENT, |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 279 | CTR_PKT_ACCESS_REJ, |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 280 | CTR_PKT_DL_ASSIGNMENT, |
| 281 | CTR_RLC_RECV_CONTROL, |
| 282 | CTR_PUA_POLL_TIMEDOUT, |
| 283 | CTR_PUA_POLL_FAILED, |
| 284 | CTR_PDA_POLL_TIMEDOUT, |
| 285 | CTR_PDA_POLL_FAILED, |
| 286 | CTR_PUAN_POLL_TIMEDOUT, |
| 287 | CTR_PUAN_POLL_FAILED, |
| 288 | CTR_PDAN_POLL_TIMEDOUT, |
| 289 | CTR_PDAN_POLL_FAILED, |
| 290 | CTR_GPRS_DL_CS1, |
| 291 | CTR_GPRS_DL_CS2, |
| 292 | CTR_GPRS_DL_CS3, |
| 293 | CTR_GPRS_DL_CS4, |
| 294 | CTR_EGPRS_DL_MCS1, |
| 295 | CTR_EGPRS_DL_MCS2, |
| 296 | CTR_EGPRS_DL_MCS3, |
| 297 | CTR_EGPRS_DL_MCS4, |
| 298 | CTR_EGPRS_DL_MCS5, |
| 299 | CTR_EGPRS_DL_MCS6, |
| 300 | CTR_EGPRS_DL_MCS7, |
| 301 | CTR_EGPRS_DL_MCS8, |
| 302 | CTR_EGPRS_DL_MCS9, |
| 303 | CTR_GPRS_UL_CS1, |
| 304 | CTR_GPRS_UL_CS2, |
| 305 | CTR_GPRS_UL_CS3, |
| 306 | CTR_GPRS_UL_CS4, |
| 307 | CTR_EGPRS_UL_MCS1, |
| 308 | CTR_EGPRS_UL_MCS2, |
| 309 | CTR_EGPRS_UL_MCS3, |
| 310 | CTR_EGPRS_UL_MCS4, |
| 311 | CTR_EGPRS_UL_MCS5, |
| 312 | CTR_EGPRS_UL_MCS6, |
| 313 | CTR_EGPRS_UL_MCS7, |
| 314 | CTR_EGPRS_UL_MCS8, |
| 315 | CTR_EGPRS_UL_MCS9, |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 316 | }; |
| 317 | |
Jacob Erlbeck | 502bd1f | 2015-03-20 14:26:05 +0100 | [diff] [blame] | 318 | enum { |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 319 | STAT_MS_PRESENT, |
| 320 | }; |
| 321 | |
| 322 | enum { |
Jacob Erlbeck | 502bd1f | 2015-03-20 14:26:05 +0100 | [diff] [blame] | 323 | TIMER_T3190_MSEC = 5000, |
| 324 | }; |
| 325 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 326 | BTS(); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 327 | ~BTS(); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 328 | |
| 329 | static BTS* main_bts(); |
| 330 | |
| 331 | struct gprs_rlcmac_bts *bts_data(); |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 332 | SBAController *sba(); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 333 | |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 334 | /** TODO: change the number to unsigned */ |
| 335 | void set_current_frame_number(int frame_number); |
Jacob Erlbeck | af75ce8 | 2015-08-26 13:22:28 +0200 | [diff] [blame] | 336 | 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] | 337 | int current_frame_number() const; |
| 338 | |
Holger Hans Peter Freyther | f098489 | 2013-10-19 18:28:59 +0200 | [diff] [blame] | 339 | /** add paging to paging queue(s) */ |
| 340 | int add_paging(uint8_t chan_needed, uint8_t *identity_lv); |
| 341 | |
Daniel Willmann | fe6e2e4 | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 342 | gprs_rlcmac_dl_tbf *dl_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts); |
| 343 | 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] | 344 | gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); |
| 345 | 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] | 346 | |
Holger Hans Peter Freyther | 70ddde6 | 2013-10-26 19:17:58 +0200 | [diff] [blame] | 347 | int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); |
| 348 | |
Holger Hans Peter Freyther | 40cfaa6 | 2013-10-26 19:49:16 +0200 | [diff] [blame] | 349 | int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); |
bhargava | 628dcfb | 2016-09-14 20:30:31 +0530 | [diff] [blame] | 350 | uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, |
| 351 | uint8_t is_11bit, uint16_t *ms_class, uint16_t *priority); |
Philipp Maier | 1275a3f | 2017-02-21 19:35:23 +0100 | [diff] [blame] | 352 | |
Max | 5dd8d1b | 2017-03-08 12:06:42 +0100 | [diff] [blame] | 353 | uint32_t rfn_to_fn(int32_t rfn); |
bhargava | 959d1de | 2016-08-17 15:17:21 +0530 | [diff] [blame] | 354 | int rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, |
| 355 | enum ph_burst_type burst_type); |
Holger Hans Peter Freyther | 40cfaa6 | 2013-10-26 19:49:16 +0200 | [diff] [blame] | 356 | |
Jacob Erlbeck | 71e5511 | 2015-05-21 11:10:15 +0200 | [diff] [blame] | 357 | void trigger_dl_ass(gprs_rlcmac_dl_tbf *tbf, gprs_rlcmac_tbf *old_tbf); |
Holger Hans Peter Freyther | d9262b3 | 2013-10-26 20:12:59 +0200 | [diff] [blame] | 358 | void snd_dl_ass(gprs_rlcmac_tbf *tbf, uint8_t poll, const char *imsi); |
| 359 | |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 360 | GprsMsStorage &ms_store(); |
| 361 | GprsMs *ms_by_tlli(uint32_t tlli, uint32_t old_tlli = 0); |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 362 | GprsMs *ms_by_imsi(const char *imsi); |
Jacob Erlbeck | 86b6f05 | 2015-11-27 15:17:34 +0100 | [diff] [blame] | 363 | 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] | 364 | |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 365 | /* |
| 366 | * Statistics |
| 367 | */ |
| 368 | void tbf_dl_created(); |
| 369 | void tbf_dl_freed(); |
Jacob Erlbeck | 0316dc6 | 2016-01-21 20:12:04 +0100 | [diff] [blame] | 370 | void tbf_dl_aborted(); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 371 | void tbf_ul_created(); |
| 372 | void tbf_ul_freed(); |
Jacob Erlbeck | 0316dc6 | 2016-01-21 20:12:04 +0100 | [diff] [blame] | 373 | void tbf_ul_aborted(); |
Holger Hans Peter Freyther | aa35ba7 | 2013-11-13 15:02:50 +0100 | [diff] [blame] | 374 | void tbf_reused(); |
Jacob Erlbeck | 5979fe9 | 2015-07-14 14:02:41 +0200 | [diff] [blame] | 375 | void tbf_alloc_algo_a(); |
| 376 | void tbf_alloc_algo_b(); |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 377 | void tbf_failed_egprs_only(); |
Holger Hans Peter Freyther | e9429b5 | 2013-11-13 19:36:57 +0100 | [diff] [blame] | 378 | void rlc_sent(); |
| 379 | void rlc_resent(); |
Holger Hans Peter Freyther | ef93bdb | 2013-11-24 00:01:50 +0100 | [diff] [blame] | 380 | void rlc_restarted(); |
Holger Hans Peter Freyther | c70aae4 | 2013-11-19 17:09:37 +0100 | [diff] [blame] | 381 | void rlc_stalled(); |
Holger Hans Peter Freyther | 092478f | 2013-11-23 01:01:19 +0100 | [diff] [blame] | 382 | void rlc_nacked(); |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 383 | void rlc_final_block_resent(); |
Jacob Erlbeck | c91c18e | 2015-07-07 09:33:29 +0200 | [diff] [blame] | 384 | void rlc_ass_timedout(); |
Jacob Erlbeck | 7c8d39a | 2015-09-07 14:04:56 +0200 | [diff] [blame] | 385 | void rlc_ass_failed(); |
Jacob Erlbeck | c91c18e | 2015-07-07 09:33:29 +0200 | [diff] [blame] | 386 | void rlc_ack_timedout(); |
Jacob Erlbeck | 7c8d39a | 2015-09-07 14:04:56 +0200 | [diff] [blame] | 387 | void rlc_ack_failed(); |
Jacob Erlbeck | c91c18e | 2015-07-07 09:33:29 +0200 | [diff] [blame] | 388 | void rlc_rel_timedout(); |
Jacob Erlbeck | be4a08b | 2015-08-25 15:19:31 +0200 | [diff] [blame] | 389 | void rlc_late_block(); |
Alexander Couzens | 2cb1547 | 2016-05-18 16:43:10 +0200 | [diff] [blame] | 390 | void rlc_sent_dummy(); |
Alexander Couzens | f929e62 | 2016-05-22 00:02:56 +0200 | [diff] [blame] | 391 | void rlc_sent_control(); |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 392 | void rlc_dl_bytes(int bytes); |
| 393 | void rlc_dl_payload_bytes(int bytes); |
| 394 | void rlc_ul_bytes(int bytes); |
| 395 | void rlc_ul_payload_bytes(int bytes); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 396 | void decode_error(); |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 397 | void sba_allocated(); |
| 398 | void sba_freed(); |
| 399 | void sba_timedout(); |
Holger Hans Peter Freyther | b3d5ee2 | 2013-11-13 16:43:26 +0100 | [diff] [blame] | 400 | void llc_timedout_frame(); |
| 401 | void llc_dropped_frame(); |
| 402 | void llc_frame_sched(); |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 403 | void llc_dl_bytes(int bytes); |
| 404 | void llc_ul_bytes(int bytes); |
Holger Hans Peter Freyther | c1ae226 | 2013-10-27 10:50:35 +0100 | [diff] [blame] | 405 | void rach_frame(); |
sivasankari | 67b89ca | 2016-12-29 16:25:30 +0530 | [diff] [blame] | 406 | void rach_frame_11bit(); |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 407 | void spb_uplink_first_segment(); |
| 408 | void spb_uplink_second_segment(); |
| 409 | void spb_downlink_first_segment(); |
| 410 | void spb_downlink_second_segment(); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 411 | void immediate_assignment_ul_tbf(); |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 412 | void immediate_assignment_reject(); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 413 | void immediate_assignment_dl_tbf(); |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 414 | void channel_request_description(); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 415 | void pkt_ul_assignment(); |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 416 | void pkt_access_reject(); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 417 | void pkt_dl_assignemnt(); |
| 418 | void rlc_rcvd_control(); |
| 419 | void pua_poll_timedout(); |
| 420 | void pua_poll_failed(); |
| 421 | void pda_poll_timedout(); |
| 422 | void pda_poll_failed(); |
| 423 | void pkt_ul_ack_nack_poll_timedout(); |
| 424 | void pkt_ul_ack_nack_poll_failed(); |
| 425 | void pkt_dl_ack_nack_poll_timedout(); |
| 426 | void pkt_dl_ack_nack_poll_failed(); |
| 427 | void gprs_dl_cs1(); |
| 428 | void gprs_dl_cs2(); |
| 429 | void gprs_dl_cs3(); |
| 430 | void gprs_dl_cs4(); |
| 431 | void egprs_dl_mcs1(); |
| 432 | void egprs_dl_mcs2(); |
| 433 | void egprs_dl_mcs3(); |
| 434 | void egprs_dl_mcs4(); |
| 435 | void egprs_dl_mcs5(); |
| 436 | void egprs_dl_mcs6(); |
| 437 | void egprs_dl_mcs7(); |
| 438 | void egprs_dl_mcs8(); |
| 439 | void egprs_dl_mcs9(); |
| 440 | void gprs_ul_cs1(); |
| 441 | void gprs_ul_cs2(); |
| 442 | void gprs_ul_cs3(); |
| 443 | void gprs_ul_cs4(); |
| 444 | void egprs_ul_mcs1(); |
| 445 | void egprs_ul_mcs2(); |
| 446 | void egprs_ul_mcs3(); |
| 447 | void egprs_ul_mcs4(); |
| 448 | void egprs_ul_mcs5(); |
| 449 | void egprs_ul_mcs6(); |
| 450 | void egprs_ul_mcs7(); |
| 451 | void egprs_ul_mcs8(); |
| 452 | void egprs_ul_mcs9(); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 453 | |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 454 | void ms_present(int32_t n); |
| 455 | int32_t ms_present_get(); |
| 456 | |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 457 | /* |
| 458 | * Below for C interface for the VTY |
| 459 | */ |
| 460 | struct rate_ctr_group *rate_counters() const; |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 461 | struct osmo_stat_item_group *stat_items() const; |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 462 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 463 | LListHead<gprs_rlcmac_tbf>& ul_tbfs(); |
| 464 | LListHead<gprs_rlcmac_tbf>& dl_tbfs(); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 465 | private: |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 466 | int m_cur_fn; |
Jacob Erlbeck | 60f7703 | 2015-08-24 14:35:14 +0200 | [diff] [blame] | 467 | int m_cur_blk_fn; |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 468 | struct gprs_rlcmac_bts m_bts; |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 469 | PollController m_pollController; |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 470 | SBAController m_sba; |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 471 | struct rate_ctr_group *m_ratectrs; |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 472 | struct osmo_stat_item_group *m_statg; |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 473 | |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 474 | GprsMsStorage m_ms_store; |
| 475 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 476 | /* list of uplink TBFs */ |
| 477 | LListHead<gprs_rlcmac_tbf> m_ul_tbfs; |
| 478 | /* list of downlink TBFs */ |
| 479 | LListHead<gprs_rlcmac_tbf> m_dl_tbfs; |
| 480 | |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 481 | private: |
| 482 | /* disable copying to avoid slicing */ |
| 483 | BTS(const BTS&); |
| 484 | BTS& operator=(const BTS&); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 485 | }; |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 486 | |
| 487 | inline int BTS::current_frame_number() const |
| 488 | { |
| 489 | return m_cur_fn; |
| 490 | } |
Holger Hans Peter Freyther | 111614a | 2013-10-19 20:04:57 +0200 | [diff] [blame] | 491 | |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 492 | inline SBAController *BTS::sba() |
| 493 | { |
| 494 | return &m_sba; |
| 495 | } |
Holger Hans Peter Freyther | 65be480 | 2013-10-26 18:39:36 +0200 | [diff] [blame] | 496 | |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 497 | inline GprsMsStorage &BTS::ms_store() |
| 498 | { |
| 499 | return m_ms_store; |
| 500 | } |
| 501 | |
| 502 | inline GprsMs *BTS::ms_by_tlli(uint32_t tlli, uint32_t old_tlli) |
| 503 | { |
| 504 | return ms_store().get_ms(tlli, old_tlli); |
| 505 | } |
| 506 | |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 507 | inline GprsMs *BTS::ms_by_imsi(const char *imsi) |
| 508 | { |
| 509 | return ms_store().get_ms(0, 0, imsi); |
| 510 | } |
| 511 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 512 | inline LListHead<gprs_rlcmac_tbf>& BTS::ul_tbfs() |
| 513 | { |
| 514 | return m_ul_tbfs; |
| 515 | } |
| 516 | |
| 517 | inline LListHead<gprs_rlcmac_tbf>& BTS::dl_tbfs() |
| 518 | { |
| 519 | return m_dl_tbfs; |
| 520 | } |
| 521 | |
Holger Hans Peter Freyther | 65be480 | 2013-10-26 18:39:36 +0200 | [diff] [blame] | 522 | inline BTS *gprs_rlcmac_pdch::bts() const |
| 523 | { |
| 524 | return trx->bts; |
| 525 | } |
| 526 | |
Jacob Erlbeck | ccc34e4 | 2015-06-29 13:45:05 +0200 | [diff] [blame] | 527 | inline unsigned gprs_rlcmac_pdch::num_tbfs(enum gprs_rlcmac_tbf_direction dir) const |
| 528 | { |
| 529 | return m_num_tbfs[dir]; |
| 530 | } |
| 531 | |
Jacob Erlbeck | 23f93a1 | 2015-06-30 08:52:54 +0200 | [diff] [blame] | 532 | inline unsigned gprs_rlcmac_pdch::num_reserved( |
| 533 | enum gprs_rlcmac_tbf_direction dir) const |
| 534 | { |
| 535 | return gprs_rlcmac_pdch::m_num_reserved[dir]; |
| 536 | } |
| 537 | |
Jacob Erlbeck | cc9358f | 2015-06-30 14:10:13 +0200 | [diff] [blame] | 538 | inline uint8_t gprs_rlcmac_pdch::assigned_usf() const |
| 539 | { |
| 540 | return m_assigned_usf; |
| 541 | } |
| 542 | |
Jacob Erlbeck | 47a57f6 | 2015-07-08 12:53:16 +0200 | [diff] [blame] | 543 | inline uint32_t gprs_rlcmac_pdch::assigned_tfi( |
| 544 | enum gprs_rlcmac_tbf_direction dir) const |
Jacob Erlbeck | cc9358f | 2015-06-30 14:10:13 +0200 | [diff] [blame] | 545 | { |
Jacob Erlbeck | 47a57f6 | 2015-07-08 12:53:16 +0200 | [diff] [blame] | 546 | return m_assigned_tfi[dir]; |
Jacob Erlbeck | cc9358f | 2015-06-30 14:10:13 +0200 | [diff] [blame] | 547 | } |
| 548 | |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 549 | inline struct rate_ctr_group *BTS::rate_counters() const |
| 550 | { |
| 551 | return m_ratectrs; |
| 552 | } |
| 553 | |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 554 | inline struct osmo_stat_item_group *BTS::stat_items() const |
| 555 | { |
| 556 | return m_statg; |
| 557 | } |
| 558 | |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 559 | #define CREATE_COUNT_ADD_INLINE(func_name, ctr_name) \ |
| 560 | inline void BTS::func_name(int inc) {\ |
| 561 | rate_ctr_add(&m_ratectrs->ctr[ctr_name], inc); \ |
| 562 | } |
| 563 | |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 564 | #define CREATE_COUNT_INLINE(func_name, ctr_name) \ |
| 565 | inline void BTS::func_name() {\ |
| 566 | rate_ctr_inc(&m_ratectrs->ctr[ctr_name]); \ |
| 567 | } |
Holger Hans Peter Freyther | 1587764 | 2013-10-27 09:50:15 +0100 | [diff] [blame] | 568 | |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 569 | CREATE_COUNT_INLINE(tbf_dl_created, CTR_TBF_DL_ALLOCATED) |
| 570 | CREATE_COUNT_INLINE(tbf_dl_freed, CTR_TBF_DL_FREED) |
Jacob Erlbeck | 0316dc6 | 2016-01-21 20:12:04 +0100 | [diff] [blame] | 571 | CREATE_COUNT_INLINE(tbf_dl_aborted, CTR_TBF_DL_ABORTED) |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 572 | CREATE_COUNT_INLINE(tbf_ul_created, CTR_TBF_UL_ALLOCATED) |
| 573 | CREATE_COUNT_INLINE(tbf_ul_freed, CTR_TBF_UL_FREED) |
Jacob Erlbeck | 0316dc6 | 2016-01-21 20:12:04 +0100 | [diff] [blame] | 574 | CREATE_COUNT_INLINE(tbf_ul_aborted, CTR_TBF_UL_ABORTED) |
Holger Hans Peter Freyther | aa35ba7 | 2013-11-13 15:02:50 +0100 | [diff] [blame] | 575 | CREATE_COUNT_INLINE(tbf_reused, CTR_TBF_REUSED) |
Jacob Erlbeck | 5979fe9 | 2015-07-14 14:02:41 +0200 | [diff] [blame] | 576 | CREATE_COUNT_INLINE(tbf_alloc_algo_a, CTR_TBF_ALLOC_ALGO_A) |
| 577 | CREATE_COUNT_INLINE(tbf_alloc_algo_b, CTR_TBF_ALLOC_ALGO_B) |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 578 | CREATE_COUNT_INLINE(tbf_failed_egprs_only, CTR_TBF_FAILED_EGPRS_ONLY) |
Holger Hans Peter Freyther | e9429b5 | 2013-11-13 19:36:57 +0100 | [diff] [blame] | 579 | CREATE_COUNT_INLINE(rlc_sent, CTR_RLC_SENT) |
| 580 | CREATE_COUNT_INLINE(rlc_resent, CTR_RLC_RESENT) |
Holger Hans Peter Freyther | ef93bdb | 2013-11-24 00:01:50 +0100 | [diff] [blame] | 581 | CREATE_COUNT_INLINE(rlc_restarted, CTR_RLC_RESTARTED) |
Holger Hans Peter Freyther | c70aae4 | 2013-11-19 17:09:37 +0100 | [diff] [blame] | 582 | CREATE_COUNT_INLINE(rlc_stalled, CTR_RLC_STALLED) |
Holger Hans Peter Freyther | 092478f | 2013-11-23 01:01:19 +0100 | [diff] [blame] | 583 | CREATE_COUNT_INLINE(rlc_nacked, CTR_RLC_NACKED) |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 584 | CREATE_COUNT_INLINE(rlc_final_block_resent, CTR_RLC_FINAL_BLOCK_RESENT); |
Jacob Erlbeck | c91c18e | 2015-07-07 09:33:29 +0200 | [diff] [blame] | 585 | CREATE_COUNT_INLINE(rlc_ass_timedout, CTR_RLC_ASS_TIMEDOUT); |
Jacob Erlbeck | 7c8d39a | 2015-09-07 14:04:56 +0200 | [diff] [blame] | 586 | CREATE_COUNT_INLINE(rlc_ass_failed, CTR_RLC_ASS_FAILED); |
Jacob Erlbeck | c91c18e | 2015-07-07 09:33:29 +0200 | [diff] [blame] | 587 | CREATE_COUNT_INLINE(rlc_ack_timedout, CTR_RLC_ACK_TIMEDOUT); |
Jacob Erlbeck | 7c8d39a | 2015-09-07 14:04:56 +0200 | [diff] [blame] | 588 | CREATE_COUNT_INLINE(rlc_ack_failed, CTR_RLC_ACK_FAILED); |
Jacob Erlbeck | c91c18e | 2015-07-07 09:33:29 +0200 | [diff] [blame] | 589 | CREATE_COUNT_INLINE(rlc_rel_timedout, CTR_RLC_REL_TIMEDOUT); |
Jacob Erlbeck | be4a08b | 2015-08-25 15:19:31 +0200 | [diff] [blame] | 590 | CREATE_COUNT_INLINE(rlc_late_block, CTR_RLC_LATE_BLOCK); |
Alexander Couzens | 2cb1547 | 2016-05-18 16:43:10 +0200 | [diff] [blame] | 591 | CREATE_COUNT_INLINE(rlc_sent_dummy, CTR_RLC_SENT_DUMMY); |
Alexander Couzens | f929e62 | 2016-05-22 00:02:56 +0200 | [diff] [blame] | 592 | CREATE_COUNT_INLINE(rlc_sent_control, CTR_RLC_SENT_CONTROL); |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 593 | CREATE_COUNT_ADD_INLINE(rlc_dl_bytes, CTR_RLC_DL_BYTES); |
| 594 | CREATE_COUNT_ADD_INLINE(rlc_dl_payload_bytes, CTR_RLC_DL_PAYLOAD_BYTES); |
| 595 | CREATE_COUNT_ADD_INLINE(rlc_ul_bytes, CTR_RLC_UL_BYTES); |
| 596 | CREATE_COUNT_ADD_INLINE(rlc_ul_payload_bytes, CTR_RLC_UL_PAYLOAD_BYTES); |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 597 | CREATE_COUNT_INLINE(decode_error, CTR_DECODE_ERRORS) |
| 598 | CREATE_COUNT_INLINE(sba_allocated, CTR_SBA_ALLOCATED) |
| 599 | CREATE_COUNT_INLINE(sba_freed, CTR_SBA_FREED) |
| 600 | CREATE_COUNT_INLINE(sba_timedout, CTR_SBA_TIMEDOUT) |
Holger Hans Peter Freyther | b3d5ee2 | 2013-11-13 16:43:26 +0100 | [diff] [blame] | 601 | CREATE_COUNT_INLINE(llc_timedout_frame, CTR_LLC_FRAME_TIMEDOUT); |
| 602 | CREATE_COUNT_INLINE(llc_dropped_frame, CTR_LLC_FRAME_DROPPED); |
| 603 | CREATE_COUNT_INLINE(llc_frame_sched, CTR_LLC_FRAME_SCHED); |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 604 | CREATE_COUNT_ADD_INLINE(llc_dl_bytes, CTR_LLC_DL_BYTES); |
| 605 | CREATE_COUNT_ADD_INLINE(llc_ul_bytes, CTR_LLC_UL_BYTES); |
Holger Hans Peter Freyther | c1ae226 | 2013-10-27 10:50:35 +0100 | [diff] [blame] | 606 | CREATE_COUNT_INLINE(rach_frame, CTR_RACH_REQUESTS); |
sivasankari | 67b89ca | 2016-12-29 16:25:30 +0530 | [diff] [blame] | 607 | CREATE_COUNT_INLINE(rach_frame_11bit, CTR_11BIT_RACH_REQUESTS); |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 608 | CREATE_COUNT_INLINE(spb_uplink_first_segment, CTR_SPB_UL_FIRST_SEGMENT); |
| 609 | CREATE_COUNT_INLINE(spb_uplink_second_segment, CTR_SPB_UL_SECOND_SEGMENT); |
| 610 | CREATE_COUNT_INLINE(spb_downlink_first_segment, CTR_SPB_DL_FIRST_SEGMENT); |
| 611 | CREATE_COUNT_INLINE(spb_downlink_second_segment, CTR_SPB_DL_SECOND_SEGMENT); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 612 | CREATE_COUNT_INLINE(immediate_assignment_ul_tbf, CTR_IMMEDIATE_ASSIGN_UL_TBF); |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 613 | CREATE_COUNT_INLINE(immediate_assignment_reject, CTR_IMMEDIATE_ASSIGN_REJ); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 614 | CREATE_COUNT_INLINE(immediate_assignment_dl_tbf, CTR_IMMEDIATE_ASSIGN_DL_TBF); |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 615 | CREATE_COUNT_INLINE(channel_request_description, CTR_CHANNEL_REQUEST_DESCRIPTION); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 616 | CREATE_COUNT_INLINE(pkt_ul_assignment, CTR_PKT_UL_ASSIGNMENT); |
sivasankari | 168911b | 2016-11-25 19:53:36 +0530 | [diff] [blame] | 617 | CREATE_COUNT_INLINE(pkt_access_reject, CTR_PKT_ACCESS_REJ); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 618 | CREATE_COUNT_INLINE(pkt_dl_assignemnt, CTR_PKT_DL_ASSIGNMENT); |
| 619 | CREATE_COUNT_INLINE(rlc_rcvd_control, CTR_RLC_RECV_CONTROL); |
| 620 | CREATE_COUNT_INLINE(pua_poll_timedout, CTR_PUA_POLL_TIMEDOUT); |
| 621 | CREATE_COUNT_INLINE(pua_poll_failed, CTR_PUA_POLL_FAILED); |
| 622 | CREATE_COUNT_INLINE(pda_poll_timedout, CTR_PDA_POLL_TIMEDOUT); |
| 623 | CREATE_COUNT_INLINE(pda_poll_failed, CTR_PDA_POLL_FAILED); |
| 624 | CREATE_COUNT_INLINE(pkt_ul_ack_nack_poll_timedout, CTR_PUAN_POLL_TIMEDOUT); |
| 625 | CREATE_COUNT_INLINE(pkt_ul_ack_nack_poll_failed, CTR_PUAN_POLL_FAILED); |
| 626 | CREATE_COUNT_INLINE(pkt_dl_ack_nack_poll_timedout, CTR_PDAN_POLL_TIMEDOUT); |
| 627 | CREATE_COUNT_INLINE(pkt_dl_ack_nack_poll_failed, CTR_PDAN_POLL_FAILED); |
| 628 | CREATE_COUNT_INLINE(gprs_dl_cs1, CTR_GPRS_DL_CS1); |
| 629 | CREATE_COUNT_INLINE(gprs_dl_cs2, CTR_GPRS_DL_CS2); |
| 630 | CREATE_COUNT_INLINE(gprs_dl_cs3, CTR_GPRS_DL_CS3); |
| 631 | CREATE_COUNT_INLINE(gprs_dl_cs4, CTR_GPRS_DL_CS4); |
| 632 | CREATE_COUNT_INLINE(egprs_dl_mcs1, CTR_EGPRS_DL_MCS1); |
| 633 | CREATE_COUNT_INLINE(egprs_dl_mcs2, CTR_EGPRS_DL_MCS2); |
| 634 | CREATE_COUNT_INLINE(egprs_dl_mcs3, CTR_EGPRS_DL_MCS3); |
| 635 | CREATE_COUNT_INLINE(egprs_dl_mcs4, CTR_EGPRS_DL_MCS4); |
| 636 | CREATE_COUNT_INLINE(egprs_dl_mcs5, CTR_EGPRS_DL_MCS5); |
| 637 | CREATE_COUNT_INLINE(egprs_dl_mcs6, CTR_EGPRS_DL_MCS6); |
| 638 | CREATE_COUNT_INLINE(egprs_dl_mcs7, CTR_EGPRS_DL_MCS7); |
| 639 | CREATE_COUNT_INLINE(egprs_dl_mcs8, CTR_EGPRS_DL_MCS8); |
| 640 | CREATE_COUNT_INLINE(egprs_dl_mcs9, CTR_EGPRS_DL_MCS9); |
| 641 | CREATE_COUNT_INLINE(gprs_ul_cs1, CTR_GPRS_UL_CS1); |
| 642 | CREATE_COUNT_INLINE(gprs_ul_cs2, CTR_GPRS_UL_CS2); |
| 643 | CREATE_COUNT_INLINE(gprs_ul_cs3, CTR_GPRS_UL_CS3); |
| 644 | CREATE_COUNT_INLINE(gprs_ul_cs4, CTR_GPRS_UL_CS4); |
| 645 | CREATE_COUNT_INLINE(egprs_ul_mcs1, CTR_EGPRS_UL_MCS1); |
| 646 | CREATE_COUNT_INLINE(egprs_ul_mcs2, CTR_EGPRS_UL_MCS2); |
| 647 | CREATE_COUNT_INLINE(egprs_ul_mcs3, CTR_EGPRS_UL_MCS3); |
| 648 | CREATE_COUNT_INLINE(egprs_ul_mcs4, CTR_EGPRS_UL_MCS4); |
| 649 | CREATE_COUNT_INLINE(egprs_ul_mcs5, CTR_EGPRS_UL_MCS5); |
| 650 | CREATE_COUNT_INLINE(egprs_ul_mcs6, CTR_EGPRS_UL_MCS6); |
| 651 | CREATE_COUNT_INLINE(egprs_ul_mcs7, CTR_EGPRS_UL_MCS7); |
| 652 | CREATE_COUNT_INLINE(egprs_ul_mcs8, CTR_EGPRS_UL_MCS8); |
| 653 | CREATE_COUNT_INLINE(egprs_ul_mcs9, CTR_EGPRS_UL_MCS9); |
Holger Hans Peter Freyther | 1587764 | 2013-10-27 09:50:15 +0100 | [diff] [blame] | 654 | |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 655 | #undef CREATE_COUNT_INLINE |
Holger Hans Peter Freyther | 1587764 | 2013-10-27 09:50:15 +0100 | [diff] [blame] | 656 | |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 657 | #define CREATE_STAT_INLINE(func_name, func_name_get, stat_name) \ |
| 658 | inline void BTS::func_name(int32_t val) {\ |
| 659 | osmo_stat_item_set(m_statg->items[stat_name], val); \ |
| 660 | } \ |
| 661 | inline int32_t BTS::func_name_get() {\ |
| 662 | return osmo_stat_item_get_last(m_statg->items[stat_name]); \ |
| 663 | } |
| 664 | |
| 665 | CREATE_STAT_INLINE(ms_present, ms_present_get, STAT_MS_PRESENT); |
| 666 | |
| 667 | #undef CREATE_STAT_INLINE |
Holger Hans Peter Freyther | 1587764 | 2013-10-27 09:50:15 +0100 | [diff] [blame] | 668 | |
Holger Hans Peter Freyther | 65be480 | 2013-10-26 18:39:36 +0200 | [diff] [blame] | 669 | inline gprs_rlcmac_bts *gprs_rlcmac_pdch::bts_data() const |
| 670 | { |
| 671 | return trx->bts->bts_data(); |
| 672 | } |
Holger Hans Peter Freyther | 05f8efc | 2013-10-26 18:53:16 +0200 | [diff] [blame] | 673 | |
| 674 | inline uint8_t gprs_rlcmac_pdch::trx_no() const |
| 675 | { |
| 676 | return trx->trx_no; |
| 677 | } |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 678 | #endif |
| 679 | |
| 680 | #ifdef __cplusplus |
| 681 | extern "C" { |
| 682 | #endif |
| 683 | struct gprs_rlcmac_bts *bts_main_data(); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 684 | struct rate_ctr_group *bts_main_data_stats(); |
Jacob Erlbeck | f5898a0 | 2015-11-27 19:05:13 +0100 | [diff] [blame] | 685 | struct osmo_stat_item_group *bts_main_data_stat_items(); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 686 | #ifdef __cplusplus |
| 687 | } |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 688 | |
| 689 | inline bool gprs_rlcmac_pdch::is_enabled() const |
| 690 | { |
| 691 | return m_is_enabled; |
| 692 | } |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 693 | #endif |