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> |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 28 | #include <osmocom/core/timer.h> |
| 29 | } |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 30 | |
| 31 | #include "poll_controller.h" |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 32 | #include "sba.h" |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 33 | #include "tbf.h" |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 34 | #include "gprs_ms_storage.h" |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 35 | #endif |
| 36 | |
| 37 | #include <stdint.h> |
| 38 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 39 | struct BTS; |
Jacob Erlbeck | e2e004e | 2015-06-18 17:16:26 +0200 | [diff] [blame] | 40 | struct GprsMs; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 41 | |
| 42 | /* |
| 43 | * PDCH instance |
| 44 | */ |
| 45 | struct gprs_rlcmac_pdch { |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 46 | #ifdef __cplusplus |
Holger Hans Peter Freyther | 24e98d0 | 2013-10-19 18:15:44 +0200 | [diff] [blame] | 47 | struct gprs_rlcmac_paging *dequeue_paging(); |
| 48 | struct msgb *packet_paging_request(); |
| 49 | |
Holger Hans Peter Freyther | f098489 | 2013-10-19 18:28:59 +0200 | [diff] [blame] | 50 | void add_paging(struct gprs_rlcmac_paging *pag); |
Holger Hans Peter Freyther | 24e98d0 | 2013-10-19 18:15:44 +0200 | [diff] [blame] | 51 | |
Holger Hans Peter Freyther | 09ef27a | 2013-10-20 16:37:05 +0200 | [diff] [blame] | 52 | void free_resources(); |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 53 | |
| 54 | bool is_enabled() const; |
| 55 | |
| 56 | void enable(); |
| 57 | void disable(); |
Holger Hans Peter Freyther | 9ae367f | 2013-10-26 16:42:38 +0200 | [diff] [blame] | 58 | |
| 59 | /* dispatching of messages */ |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 60 | int rcv_block(uint8_t *data, uint8_t len, uint32_t fn, |
| 61 | struct pcu_l1_meas *meas); |
Holger Hans Peter Freyther | 65be480 | 2013-10-26 18:39:36 +0200 | [diff] [blame] | 62 | |
| 63 | gprs_rlcmac_bts *bts_data() const; |
| 64 | BTS *bts() const; |
Holger Hans Peter Freyther | 05f8efc | 2013-10-26 18:53:16 +0200 | [diff] [blame] | 65 | uint8_t trx_no() const; |
Daniel Willmann | 1e0c610 | 2014-06-04 14:56:09 +0200 | [diff] [blame] | 66 | |
Daniel Willmann | fe6e2e4 | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 67 | struct gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi); |
| 68 | struct gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi); |
Jacob Erlbeck | ccc34e4 | 2015-06-29 13:45:05 +0200 | [diff] [blame] | 69 | |
| 70 | void attach_tbf(gprs_rlcmac_tbf *tbf); |
| 71 | void detach_tbf(gprs_rlcmac_tbf *tbf); |
| 72 | |
| 73 | unsigned num_tbfs(enum gprs_rlcmac_tbf_direction dir) const; |
Jacob Erlbeck | 23f93a1 | 2015-06-30 08:52:54 +0200 | [diff] [blame] | 74 | |
| 75 | void reserve(enum gprs_rlcmac_tbf_direction dir); |
| 76 | void unreserve(enum gprs_rlcmac_tbf_direction dir); |
| 77 | unsigned num_reserved(enum gprs_rlcmac_tbf_direction dir) const; |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 78 | #endif |
| 79 | |
| 80 | uint8_t m_is_enabled; /* TS is enabled */ |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 81 | uint8_t tsc; /* TSC of this slot */ |
| 82 | uint8_t next_ul_tfi; /* next uplink TBF/TFI to schedule (0..31) */ |
| 83 | 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] | 84 | 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] | 85 | struct llist_head paging_list; /* list of paging messages */ |
| 86 | 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] | 87 | |
| 88 | /* back pointers */ |
| 89 | struct gprs_rlcmac_trx *trx; |
| 90 | uint8_t ts_no; |
Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 91 | |
| 92 | #ifdef __cplusplus |
| 93 | private: |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 94 | int rcv_data_block_acknowledged(uint8_t *data, uint8_t len, |
| 95 | struct pcu_l1_meas *meas); |
Holger Hans Peter Freyther | 05f8efc | 2013-10-26 18:53:16 +0200 | [diff] [blame] | 96 | int rcv_control_block(bitvec *rlc_block, uint32_t fn); |
Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 97 | |
Holger Hans Peter Freyther | e1a075a | 2013-10-27 13:35:30 +0100 | [diff] [blame] | 98 | 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] | 99 | void rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *, uint32_t fn); |
Holger Hans Peter Freyther | 7a34471 | 2013-10-27 11:37:53 +0100 | [diff] [blame] | 100 | 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] | 101 | void rcv_measurement_report(Packet_Measurement_Report_t *t, uint32_t fn); |
Daniel Willmann | 2207c5e | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 102 | gprs_rlcmac_tbf *tbf_from_list_by_tfi(struct llist_head *tbf_list, uint8_t tfi, |
| 103 | enum gprs_rlcmac_tbf_direction dir); |
Holger Hans Peter Freyther | d11290b | 2013-10-26 17:32:04 +0200 | [diff] [blame] | 104 | #endif |
Jacob Erlbeck | ccc34e4 | 2015-06-29 13:45:05 +0200 | [diff] [blame] | 105 | |
| 106 | uint8_t m_num_tbfs[2]; |
Jacob Erlbeck | 23f93a1 | 2015-06-30 08:52:54 +0200 | [diff] [blame] | 107 | uint8_t m_num_reserved[2]; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | struct gprs_rlcmac_trx { |
| 111 | void *fl1h; |
| 112 | uint16_t arfcn; |
| 113 | struct gprs_rlcmac_pdch pdch[8]; |
| 114 | struct gprs_rlcmac_tbf *ul_tbf[32]; /* array of UL TBF, by UL TFI */ |
| 115 | struct gprs_rlcmac_tbf *dl_tbf[32]; /* array of DL TBF, by DL TFI */ |
Holger Hans Peter Freyther | 4ed1dae | 2013-10-20 10:14:03 +0200 | [diff] [blame] | 116 | |
| 117 | /* back pointers */ |
| 118 | struct BTS *bts; |
| 119 | uint8_t trx_no; |
Jacob Erlbeck | 23f93a1 | 2015-06-30 08:52:54 +0200 | [diff] [blame] | 120 | |
| 121 | #ifdef __cplusplus |
| 122 | void reserve_slots(enum gprs_rlcmac_tbf_direction dir, uint8_t slots); |
| 123 | void unreserve_slots(enum gprs_rlcmac_tbf_direction dir, uint8_t slots); |
| 124 | #endif |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 125 | }; |
| 126 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 127 | /** |
| 128 | * This is the data from C. As soon as our minimal compiler is gcc 4.7 |
| 129 | * we can start to compile pcu_vty.c with c++ and remove the split. |
| 130 | */ |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 131 | struct gprs_rlcmac_bts { |
| 132 | uint8_t bsic; |
| 133 | uint8_t fc_interval; |
Jacob Erlbeck | 0288cdb | 2015-05-06 10:47:30 +0200 | [diff] [blame] | 134 | uint16_t fc_bucket_time; |
Jacob Erlbeck | 87d7341 | 2015-04-21 12:56:48 +0200 | [diff] [blame] | 135 | uint32_t fc_bvc_bucket_size; |
| 136 | uint32_t fc_bvc_leak_rate; |
| 137 | uint32_t fc_ms_bucket_size; |
| 138 | uint32_t fc_ms_leak_rate; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 139 | uint8_t cs1; |
| 140 | uint8_t cs2; |
| 141 | uint8_t cs3; |
| 142 | uint8_t cs4; |
| 143 | uint8_t initial_cs_dl, initial_cs_ul; |
Jacob Erlbeck | b33e675 | 2015-06-04 19:04:30 +0200 | [diff] [blame] | 144 | uint8_t max_cs_dl, max_cs_ul; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 145 | uint8_t force_cs; /* 0=use from BTS 1=use from VTY */ |
| 146 | uint16_t force_llc_lifetime; /* overrides lifetime from SGSN */ |
Jacob Erlbeck | 0c1c877 | 2015-03-20 12:02:42 +0100 | [diff] [blame] | 147 | uint32_t llc_discard_csec; |
Jacob Erlbeck | d0261b7 | 2015-04-02 13:58:09 +0200 | [diff] [blame] | 148 | uint32_t llc_idle_ack_csec; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 149 | uint8_t t3142; |
| 150 | uint8_t t3169; |
| 151 | uint8_t t3191; |
| 152 | uint16_t t3193_msec; |
| 153 | uint8_t t3195; |
| 154 | uint8_t n3101; |
| 155 | uint8_t n3103; |
| 156 | uint8_t n3105; |
| 157 | struct gprs_rlcmac_trx trx[8]; |
| 158 | int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts, |
Jacob Erlbeck | e2e004e | 2015-06-18 17:16:26 +0200 | [diff] [blame] | 159 | struct GprsMs *ms, |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 160 | struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single); |
| 161 | uint32_t alloc_algorithm_curst; /* options to customize algorithm */ |
| 162 | uint8_t force_two_phase; |
| 163 | uint8_t alpha, gamma; |
Jacob Erlbeck | 3bed5d1 | 2015-03-19 11:22:38 +0100 | [diff] [blame] | 164 | uint32_t dl_tbf_idle_msec; /* hold time for idle DL TBFs */ |
Jacob Erlbeck | a098c19 | 2015-05-28 16:11:19 +0200 | [diff] [blame] | 165 | uint32_t ms_idle_sec; |
Jacob Erlbeck | 1751c62 | 2015-06-04 12:12:32 +0200 | [diff] [blame] | 166 | uint8_t cs_adj_enabled; |
| 167 | uint8_t cs_adj_upper_limit; |
| 168 | uint8_t cs_adj_lower_limit; |
Jacob Erlbeck | 94cde13 | 2015-06-09 09:44:36 +0200 | [diff] [blame] | 169 | struct {int16_t low; int16_t high;} cs_lqual_ranges[4]; |
Jacob Erlbeck | 70b96aa | 2015-06-12 10:52:34 +0200 | [diff] [blame] | 170 | uint16_t cs_downgrade_threshold; /* downgrade if less packets left (DL) */ |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 171 | |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 172 | /* TBF handling, make private or move into TBFController */ |
| 173 | /* list of uplink TBFs */ |
| 174 | struct llist_head ul_tbfs; |
| 175 | /* list of downlink TBFs */ |
| 176 | struct llist_head dl_tbfs; |
| 177 | |
| 178 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 179 | /** |
| 180 | * Point back to the C++ object. This is used during the transition |
| 181 | * period. |
| 182 | */ |
| 183 | struct BTS *bts; |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 184 | }; |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 185 | |
| 186 | #ifdef __cplusplus |
| 187 | /** |
| 188 | * I represent a GSM BTS. I have one or more TRX, I know the current |
| 189 | * GSM time and I have controllers that help with allocating resources |
| 190 | * on my TRXs. |
| 191 | */ |
| 192 | struct BTS { |
| 193 | public: |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 194 | enum { |
| 195 | CTR_TBF_DL_ALLOCATED, |
| 196 | CTR_TBF_DL_FREED, |
| 197 | CTR_TBF_UL_ALLOCATED, |
| 198 | CTR_TBF_UL_FREED, |
Holger Hans Peter Freyther | aa35ba7 | 2013-11-13 15:02:50 +0100 | [diff] [blame] | 199 | CTR_TBF_REUSED, |
Holger Hans Peter Freyther | e9429b5 | 2013-11-13 19:36:57 +0100 | [diff] [blame] | 200 | CTR_RLC_SENT, |
| 201 | CTR_RLC_RESENT, |
Holger Hans Peter Freyther | ef93bdb | 2013-11-24 00:01:50 +0100 | [diff] [blame] | 202 | CTR_RLC_RESTARTED, |
Holger Hans Peter Freyther | c70aae4 | 2013-11-19 17:09:37 +0100 | [diff] [blame] | 203 | CTR_RLC_STALLED, |
Holger Hans Peter Freyther | 092478f | 2013-11-23 01:01:19 +0100 | [diff] [blame] | 204 | CTR_RLC_NACKED, |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 205 | CTR_DECODE_ERRORS, |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 206 | CTR_SBA_ALLOCATED, |
| 207 | CTR_SBA_FREED, |
| 208 | CTR_SBA_TIMEDOUT, |
Holger Hans Peter Freyther | 1997787 | 2013-10-27 10:34:31 +0100 | [diff] [blame] | 209 | CTR_LLC_FRAME_TIMEDOUT, |
| 210 | CTR_LLC_FRAME_DROPPED, |
Holger Hans Peter Freyther | b3d5ee2 | 2013-11-13 16:43:26 +0100 | [diff] [blame] | 211 | CTR_LLC_FRAME_SCHED, |
Holger Hans Peter Freyther | c1ae226 | 2013-10-27 10:50:35 +0100 | [diff] [blame] | 212 | CTR_RACH_REQUESTS, |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 213 | }; |
| 214 | |
Jacob Erlbeck | 502bd1f | 2015-03-20 14:26:05 +0100 | [diff] [blame] | 215 | enum { |
| 216 | TIMER_T3190_MSEC = 5000, |
| 217 | }; |
| 218 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 219 | BTS(); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 220 | ~BTS(); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 221 | |
| 222 | static BTS* main_bts(); |
| 223 | |
| 224 | struct gprs_rlcmac_bts *bts_data(); |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 225 | SBAController *sba(); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 226 | |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 227 | /** TODO: change the number to unsigned */ |
| 228 | void set_current_frame_number(int frame_number); |
| 229 | int current_frame_number() const; |
| 230 | |
Holger Hans Peter Freyther | f098489 | 2013-10-19 18:28:59 +0200 | [diff] [blame] | 231 | /** add paging to paging queue(s) */ |
| 232 | int add_paging(uint8_t chan_needed, uint8_t *identity_lv); |
| 233 | |
Daniel Willmann | fe6e2e4 | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 234 | gprs_rlcmac_dl_tbf *dl_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts); |
| 235 | gprs_rlcmac_ul_tbf *ul_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts); |
| 236 | gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx); |
| 237 | gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx); |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 238 | |
Holger Hans Peter Freyther | 70ddde6 | 2013-10-26 19:17:58 +0200 | [diff] [blame] | 239 | int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); |
| 240 | |
Holger Hans Peter Freyther | 40cfaa6 | 2013-10-26 19:49:16 +0200 | [diff] [blame] | 241 | int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); |
Holger Hans Peter Freyther | 02beed5 | 2013-10-26 20:56:20 +0200 | [diff] [blame] | 242 | int rcv_rach(uint8_t ra, uint32_t Fn, int16_t qta); |
Holger Hans Peter Freyther | 40cfaa6 | 2013-10-26 19:49:16 +0200 | [diff] [blame] | 243 | |
Jacob Erlbeck | 71e5511 | 2015-05-21 11:10:15 +0200 | [diff] [blame] | 244 | 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] | 245 | void snd_dl_ass(gprs_rlcmac_tbf *tbf, uint8_t poll, const char *imsi); |
| 246 | |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 247 | GprsMsStorage &ms_store(); |
| 248 | GprsMs *ms_by_tlli(uint32_t tlli, uint32_t old_tlli = 0); |
Jacob Erlbeck | cb1b494 | 2015-06-19 10:59:58 +0200 | [diff] [blame] | 249 | GprsMs *ms_alloc(uint8_t ms_class); |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 250 | |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 251 | /* |
| 252 | * Statistics |
| 253 | */ |
| 254 | void tbf_dl_created(); |
| 255 | void tbf_dl_freed(); |
| 256 | void tbf_ul_created(); |
| 257 | void tbf_ul_freed(); |
Holger Hans Peter Freyther | aa35ba7 | 2013-11-13 15:02:50 +0100 | [diff] [blame] | 258 | void tbf_reused(); |
Holger Hans Peter Freyther | e9429b5 | 2013-11-13 19:36:57 +0100 | [diff] [blame] | 259 | void rlc_sent(); |
| 260 | void rlc_resent(); |
Holger Hans Peter Freyther | ef93bdb | 2013-11-24 00:01:50 +0100 | [diff] [blame] | 261 | void rlc_restarted(); |
Holger Hans Peter Freyther | c70aae4 | 2013-11-19 17:09:37 +0100 | [diff] [blame] | 262 | void rlc_stalled(); |
Holger Hans Peter Freyther | 092478f | 2013-11-23 01:01:19 +0100 | [diff] [blame] | 263 | void rlc_nacked(); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 264 | void decode_error(); |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 265 | void sba_allocated(); |
| 266 | void sba_freed(); |
| 267 | void sba_timedout(); |
Holger Hans Peter Freyther | b3d5ee2 | 2013-11-13 16:43:26 +0100 | [diff] [blame] | 268 | void llc_timedout_frame(); |
| 269 | void llc_dropped_frame(); |
| 270 | void llc_frame_sched(); |
Holger Hans Peter Freyther | c1ae226 | 2013-10-27 10:50:35 +0100 | [diff] [blame] | 271 | void rach_frame(); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 272 | |
| 273 | /* |
| 274 | * Below for C interface for the VTY |
| 275 | */ |
| 276 | struct rate_ctr_group *rate_counters() const; |
| 277 | |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 278 | private: |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 279 | int m_cur_fn; |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 280 | struct gprs_rlcmac_bts m_bts; |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 281 | PollController m_pollController; |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 282 | SBAController m_sba; |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 283 | struct rate_ctr_group *m_ratectrs; |
Daniel Willmann | 54044b0 | 2014-07-02 17:58:15 +0200 | [diff] [blame] | 284 | gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, uint8_t trx, enum gprs_rlcmac_tbf_direction dir); |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 285 | |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 286 | GprsMsStorage m_ms_store; |
| 287 | |
Holger Hans Peter Freyther | b78adcd | 2013-10-17 20:12:37 +0200 | [diff] [blame] | 288 | private: |
| 289 | /* disable copying to avoid slicing */ |
| 290 | BTS(const BTS&); |
| 291 | BTS& operator=(const BTS&); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 292 | }; |
Holger Hans Peter Freyther | 9b30c7f | 2013-10-17 19:59:56 +0200 | [diff] [blame] | 293 | |
| 294 | inline int BTS::current_frame_number() const |
| 295 | { |
| 296 | return m_cur_fn; |
| 297 | } |
Holger Hans Peter Freyther | 111614a | 2013-10-19 20:04:57 +0200 | [diff] [blame] | 298 | |
Holger Hans Peter Freyther | cedf890 | 2013-10-19 20:47:12 +0200 | [diff] [blame] | 299 | inline SBAController *BTS::sba() |
| 300 | { |
| 301 | return &m_sba; |
| 302 | } |
Holger Hans Peter Freyther | 65be480 | 2013-10-26 18:39:36 +0200 | [diff] [blame] | 303 | |
Jacob Erlbeck | e43460b | 2015-05-13 13:33:12 +0200 | [diff] [blame] | 304 | inline GprsMsStorage &BTS::ms_store() |
| 305 | { |
| 306 | return m_ms_store; |
| 307 | } |
| 308 | |
| 309 | inline GprsMs *BTS::ms_by_tlli(uint32_t tlli, uint32_t old_tlli) |
| 310 | { |
| 311 | return ms_store().get_ms(tlli, old_tlli); |
| 312 | } |
| 313 | |
Holger Hans Peter Freyther | 65be480 | 2013-10-26 18:39:36 +0200 | [diff] [blame] | 314 | inline BTS *gprs_rlcmac_pdch::bts() const |
| 315 | { |
| 316 | return trx->bts; |
| 317 | } |
| 318 | |
Jacob Erlbeck | ccc34e4 | 2015-06-29 13:45:05 +0200 | [diff] [blame] | 319 | inline unsigned gprs_rlcmac_pdch::num_tbfs(enum gprs_rlcmac_tbf_direction dir) const |
| 320 | { |
| 321 | return m_num_tbfs[dir]; |
| 322 | } |
| 323 | |
Jacob Erlbeck | 23f93a1 | 2015-06-30 08:52:54 +0200 | [diff] [blame] | 324 | inline unsigned gprs_rlcmac_pdch::num_reserved( |
| 325 | enum gprs_rlcmac_tbf_direction dir) const |
| 326 | { |
| 327 | return gprs_rlcmac_pdch::m_num_reserved[dir]; |
| 328 | } |
| 329 | |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 330 | inline struct rate_ctr_group *BTS::rate_counters() const |
| 331 | { |
| 332 | return m_ratectrs; |
| 333 | } |
| 334 | |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 335 | #define CREATE_COUNT_INLINE(func_name, ctr_name) \ |
| 336 | inline void BTS::func_name() {\ |
| 337 | rate_ctr_inc(&m_ratectrs->ctr[ctr_name]); \ |
| 338 | } |
Holger Hans Peter Freyther | 1587764 | 2013-10-27 09:50:15 +0100 | [diff] [blame] | 339 | |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 340 | CREATE_COUNT_INLINE(tbf_dl_created, CTR_TBF_DL_ALLOCATED) |
| 341 | CREATE_COUNT_INLINE(tbf_dl_freed, CTR_TBF_DL_FREED) |
| 342 | CREATE_COUNT_INLINE(tbf_ul_created, CTR_TBF_UL_ALLOCATED) |
| 343 | CREATE_COUNT_INLINE(tbf_ul_freed, CTR_TBF_UL_FREED) |
Holger Hans Peter Freyther | aa35ba7 | 2013-11-13 15:02:50 +0100 | [diff] [blame] | 344 | CREATE_COUNT_INLINE(tbf_reused, CTR_TBF_REUSED) |
Holger Hans Peter Freyther | e9429b5 | 2013-11-13 19:36:57 +0100 | [diff] [blame] | 345 | CREATE_COUNT_INLINE(rlc_sent, CTR_RLC_SENT) |
| 346 | CREATE_COUNT_INLINE(rlc_resent, CTR_RLC_RESENT) |
Holger Hans Peter Freyther | ef93bdb | 2013-11-24 00:01:50 +0100 | [diff] [blame] | 347 | CREATE_COUNT_INLINE(rlc_restarted, CTR_RLC_RESTARTED) |
Holger Hans Peter Freyther | c70aae4 | 2013-11-19 17:09:37 +0100 | [diff] [blame] | 348 | CREATE_COUNT_INLINE(rlc_stalled, CTR_RLC_STALLED) |
Holger Hans Peter Freyther | 092478f | 2013-11-23 01:01:19 +0100 | [diff] [blame] | 349 | CREATE_COUNT_INLINE(rlc_nacked, CTR_RLC_NACKED) |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 350 | CREATE_COUNT_INLINE(decode_error, CTR_DECODE_ERRORS) |
| 351 | CREATE_COUNT_INLINE(sba_allocated, CTR_SBA_ALLOCATED) |
| 352 | CREATE_COUNT_INLINE(sba_freed, CTR_SBA_FREED) |
| 353 | CREATE_COUNT_INLINE(sba_timedout, CTR_SBA_TIMEDOUT) |
Holger Hans Peter Freyther | b3d5ee2 | 2013-11-13 16:43:26 +0100 | [diff] [blame] | 354 | CREATE_COUNT_INLINE(llc_timedout_frame, CTR_LLC_FRAME_TIMEDOUT); |
| 355 | CREATE_COUNT_INLINE(llc_dropped_frame, CTR_LLC_FRAME_DROPPED); |
| 356 | CREATE_COUNT_INLINE(llc_frame_sched, CTR_LLC_FRAME_SCHED); |
Holger Hans Peter Freyther | c1ae226 | 2013-10-27 10:50:35 +0100 | [diff] [blame] | 357 | CREATE_COUNT_INLINE(rach_frame, CTR_RACH_REQUESTS); |
Holger Hans Peter Freyther | 1587764 | 2013-10-27 09:50:15 +0100 | [diff] [blame] | 358 | |
Holger Hans Peter Freyther | 93e048f | 2013-10-27 10:00:47 +0100 | [diff] [blame] | 359 | #undef CREATE_COUNT_INLINE |
Holger Hans Peter Freyther | 1587764 | 2013-10-27 09:50:15 +0100 | [diff] [blame] | 360 | |
Holger Hans Peter Freyther | 1587764 | 2013-10-27 09:50:15 +0100 | [diff] [blame] | 361 | |
Holger Hans Peter Freyther | 65be480 | 2013-10-26 18:39:36 +0200 | [diff] [blame] | 362 | inline gprs_rlcmac_bts *gprs_rlcmac_pdch::bts_data() const |
| 363 | { |
| 364 | return trx->bts->bts_data(); |
| 365 | } |
Holger Hans Peter Freyther | 05f8efc | 2013-10-26 18:53:16 +0200 | [diff] [blame] | 366 | |
| 367 | inline uint8_t gprs_rlcmac_pdch::trx_no() const |
| 368 | { |
| 369 | return trx->trx_no; |
| 370 | } |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 371 | #endif |
| 372 | |
| 373 | #ifdef __cplusplus |
| 374 | extern "C" { |
| 375 | #endif |
| 376 | struct gprs_rlcmac_bts *bts_main_data(); |
Holger Hans Peter Freyther | f537298 | 2013-10-27 09:02:31 +0100 | [diff] [blame] | 377 | struct rate_ctr_group *bts_main_data_stats(); |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 378 | #ifdef __cplusplus |
| 379 | } |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 380 | |
| 381 | inline bool gprs_rlcmac_pdch::is_enabled() const |
| 382 | { |
| 383 | return m_is_enabled; |
| 384 | } |
Holger Hans Peter Freyther | b6acfda | 2013-10-17 19:41:11 +0200 | [diff] [blame] | 385 | #endif |