2013-10-17 15:01:54 +00:00
|
|
|
/* bts.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Ivan Klyuchnikov
|
|
|
|
* Copyright (C) 2013 by Holger Hans Peter Freyther
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#include <osmocom/core/linuxlist.h>
|
2013-10-27 08:02:31 +00:00
|
|
|
#include <osmocom/core/rate_ctr.h>
|
2015-11-27 18:05:13 +00:00
|
|
|
#include <osmocom/core/stat_item.h>
|
2013-10-17 15:01:54 +00:00
|
|
|
#include <osmocom/core/timer.h>
|
2016-02-22 10:39:30 +00:00
|
|
|
#include <osmocom/core/gsmtap.h>
|
2013-10-17 15:01:54 +00:00
|
|
|
}
|
2013-10-17 18:12:37 +00:00
|
|
|
|
|
|
|
#include "poll_controller.h"
|
2013-10-19 18:47:12 +00:00
|
|
|
#include "sba.h"
|
2013-10-19 19:10:38 +00:00
|
|
|
#include "tbf.h"
|
2015-05-13 11:33:12 +00:00
|
|
|
#include "gprs_ms_storage.h"
|
2015-12-14 14:19:12 +00:00
|
|
|
#include "gprs_coding_scheme.h"
|
2013-10-17 15:01:54 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
llc: Use CoDel to drop packages from the LLC queue
Currently packets are only dropped if they have reached their maximum
life time. This leads to LLC queues being constantly filled under
load, increasing the latency up to the maximum life time. This kind
of bufferbloat hinders TCP's congestion avoidance algorithms. To keep
the queues short, the CoDel active queue management algorithm can be
used.
This commit changes to llc_dequeue method to apply the CoDel
algorithm to selectively drop LLC frames before they passed to the
TBF layer to be encoded in BSNs. This feature is currently disabled
by default.
The CoDel state is managed per MS since the LLC queues are also kept
in the MS objects.
Note that there is still some buffering in the TBF objects, in the
worst case (CS4) 3.5kByte + LLC-MTU octets are stored there. The
resulting additional packet delay is not (yet) taken into account for
CoDel.
Also note that configuration changes are applied to new MS objects
only.
The following VTY commands are added to the 'pcu' node:
- queue codel activates CoDel, the interval is selected by
the implementation
- queue codel interval <1-1000>
activates CoDel with a fixed interval given
in centiseconds (10ms-10s)
- no queue codel deactivates CoDel
Which interval value to use is still an open issue. For high speed
links (e.g. Ethernet), CoDel suggests 100ms. For slower links, the
expected RTT is recommended. The current implementation uses a
default value of 2000ms.
Measurements:
Note that the following measurements depend on several other factors,
most notably the interaction with the SGSN's flow control. They are
just examples to give an idea how CoDel might influence some
parameters.
The measurements have been done with a single E71, first with a
running ping only (Idle), then with an additional TCP download
of a 360k file (Busy). The CoDel interval was set to 1s.
- Idle :
ping ~400ms, avg queue delay 0ms, dropped 0
- Busy, No CoDel:
ping ~6s, avg queue delay 4-6s,
dropped 0, scheduled 948, duration 54s
- Busy, CoDel:
ping 500-1500ms, avg queue delay ~600ms,
dropped 77, scheduled 1040, duration 60s
More measurements with two MS downloading in parallel (two
independant measurements per case).
- Busy, No CoDel:
dropped 0, scheduled 1883, duration 121s
dropped 19, scheduled 2003, duration 133s
- Busy, CoDel:
dropped 22, scheduled 1926, duration 116s
dropped 22, scheduled 1955, duration 108s
Sponsored-by: On-Waves ehf
2015-07-17 14:39:09 +00:00
|
|
|
#define LLC_CODEL_DISABLE 0
|
|
|
|
#define LLC_CODEL_USE_DEFAULT (-1)
|
2016-06-15 12:16:41 +00:00
|
|
|
#define MAX_GPRS_CS 9
|
|
|
|
|
llc: Use CoDel to drop packages from the LLC queue
Currently packets are only dropped if they have reached their maximum
life time. This leads to LLC queues being constantly filled under
load, increasing the latency up to the maximum life time. This kind
of bufferbloat hinders TCP's congestion avoidance algorithms. To keep
the queues short, the CoDel active queue management algorithm can be
used.
This commit changes to llc_dequeue method to apply the CoDel
algorithm to selectively drop LLC frames before they passed to the
TBF layer to be encoded in BSNs. This feature is currently disabled
by default.
The CoDel state is managed per MS since the LLC queues are also kept
in the MS objects.
Note that there is still some buffering in the TBF objects, in the
worst case (CS4) 3.5kByte + LLC-MTU octets are stored there. The
resulting additional packet delay is not (yet) taken into account for
CoDel.
Also note that configuration changes are applied to new MS objects
only.
The following VTY commands are added to the 'pcu' node:
- queue codel activates CoDel, the interval is selected by
the implementation
- queue codel interval <1-1000>
activates CoDel with a fixed interval given
in centiseconds (10ms-10s)
- no queue codel deactivates CoDel
Which interval value to use is still an open issue. For high speed
links (e.g. Ethernet), CoDel suggests 100ms. For slower links, the
expected RTT is recommended. The current implementation uses a
default value of 2000ms.
Measurements:
Note that the following measurements depend on several other factors,
most notably the interaction with the SGSN's flow control. They are
just examples to give an idea how CoDel might influence some
parameters.
The measurements have been done with a single E71, first with a
running ping only (Idle), then with an additional TCP download
of a 360k file (Busy). The CoDel interval was set to 1s.
- Idle :
ping ~400ms, avg queue delay 0ms, dropped 0
- Busy, No CoDel:
ping ~6s, avg queue delay 4-6s,
dropped 0, scheduled 948, duration 54s
- Busy, CoDel:
ping 500-1500ms, avg queue delay ~600ms,
dropped 77, scheduled 1040, duration 60s
More measurements with two MS downloading in parallel (two
independant measurements per case).
- Busy, No CoDel:
dropped 0, scheduled 1883, duration 121s
dropped 19, scheduled 2003, duration 133s
- Busy, CoDel:
dropped 22, scheduled 1926, duration 116s
dropped 22, scheduled 1955, duration 108s
Sponsored-by: On-Waves ehf
2015-07-17 14:39:09 +00:00
|
|
|
|
2013-10-17 17:41:11 +00:00
|
|
|
struct BTS;
|
2015-06-18 15:16:26 +00:00
|
|
|
struct GprsMs;
|
2013-10-17 15:01:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* PDCH instance
|
|
|
|
*/
|
|
|
|
struct gprs_rlcmac_pdch {
|
2013-10-19 15:37:48 +00:00
|
|
|
#ifdef __cplusplus
|
2013-10-19 16:15:44 +00:00
|
|
|
struct gprs_rlcmac_paging *dequeue_paging();
|
|
|
|
struct msgb *packet_paging_request();
|
|
|
|
|
2013-10-19 16:28:59 +00:00
|
|
|
void add_paging(struct gprs_rlcmac_paging *pag);
|
2013-10-19 16:15:44 +00:00
|
|
|
|
2013-10-20 14:37:05 +00:00
|
|
|
void free_resources();
|
2013-10-19 15:37:48 +00:00
|
|
|
|
|
|
|
bool is_enabled() const;
|
|
|
|
|
|
|
|
void enable();
|
|
|
|
void disable();
|
2013-10-26 14:42:38 +00:00
|
|
|
|
|
|
|
/* dispatching of messages */
|
2015-06-08 09:05:45 +00:00
|
|
|
int rcv_block(uint8_t *data, uint8_t len, uint32_t fn,
|
|
|
|
struct pcu_l1_meas *meas);
|
2015-12-14 14:19:12 +00:00
|
|
|
int rcv_block_gprs(uint8_t *data, uint32_t fn,
|
|
|
|
struct pcu_l1_meas *meas, GprsCodingScheme cs);
|
2015-12-09 16:39:56 +00:00
|
|
|
int rcv_data_block(uint8_t *data, uint32_t fn,
|
2015-11-30 17:09:17 +00:00
|
|
|
struct pcu_l1_meas *meas, GprsCodingScheme cs);
|
2013-10-26 16:39:36 +00:00
|
|
|
|
|
|
|
gprs_rlcmac_bts *bts_data() const;
|
|
|
|
BTS *bts() const;
|
2013-10-26 16:53:16 +00:00
|
|
|
uint8_t trx_no() const;
|
2014-06-04 12:56:09 +00:00
|
|
|
|
2014-07-10 15:44:06 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi);
|
|
|
|
struct gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi);
|
2015-06-29 11:45:05 +00:00
|
|
|
|
|
|
|
void attach_tbf(gprs_rlcmac_tbf *tbf);
|
|
|
|
void detach_tbf(gprs_rlcmac_tbf *tbf);
|
|
|
|
|
|
|
|
unsigned num_tbfs(enum gprs_rlcmac_tbf_direction dir) const;
|
2015-06-30 06:52:54 +00:00
|
|
|
|
|
|
|
void reserve(enum gprs_rlcmac_tbf_direction dir);
|
|
|
|
void unreserve(enum gprs_rlcmac_tbf_direction dir);
|
|
|
|
unsigned num_reserved(enum gprs_rlcmac_tbf_direction dir) const;
|
2015-06-30 12:10:13 +00:00
|
|
|
|
|
|
|
uint8_t assigned_usf() const;
|
2015-07-08 10:53:16 +00:00
|
|
|
uint32_t assigned_tfi(enum gprs_rlcmac_tbf_direction dir) const;
|
2013-10-19 15:37:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
uint8_t m_is_enabled; /* TS is enabled */
|
2013-10-17 15:01:54 +00:00
|
|
|
uint8_t tsc; /* TSC of this slot */
|
|
|
|
uint8_t next_ul_tfi; /* next uplink TBF/TFI to schedule (0..31) */
|
|
|
|
uint8_t next_dl_tfi; /* next downlink TBF/TFI to schedule (0..31) */
|
2013-11-26 15:39:28 +00:00
|
|
|
uint8_t next_ctrl_prio; /* next kind of ctrl message to schedule */
|
2013-10-17 15:01:54 +00:00
|
|
|
struct llist_head paging_list; /* list of paging messages */
|
|
|
|
uint32_t last_rts_fn; /* store last frame number of RTS */
|
2013-10-20 08:14:03 +00:00
|
|
|
|
|
|
|
/* back pointers */
|
|
|
|
struct gprs_rlcmac_trx *trx;
|
|
|
|
uint8_t ts_no;
|
2013-10-26 15:32:04 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
private:
|
2013-10-26 16:53:16 +00:00
|
|
|
int rcv_control_block(bitvec *rlc_block, uint32_t fn);
|
2013-10-26 15:32:04 +00:00
|
|
|
|
2013-10-27 12:35:30 +00:00
|
|
|
void rcv_control_ack(Packet_Control_Acknowledgement_t *, uint32_t fn);
|
2013-10-27 10:41:01 +00:00
|
|
|
void rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *, uint32_t fn);
|
2016-01-13 12:55:44 +00:00
|
|
|
void rcv_control_egprs_dl_ack_nack(EGPRS_PD_AckNack_t *, uint32_t fn);
|
2013-10-27 10:37:53 +00:00
|
|
|
void rcv_resource_request(Packet_Resource_Request_t *t, uint32_t fn);
|
2013-10-27 10:19:13 +00:00
|
|
|
void rcv_measurement_report(Packet_Measurement_Report_t *t, uint32_t fn);
|
2015-12-28 18:15:40 +00:00
|
|
|
gprs_rlcmac_tbf *tbf_from_list_by_tfi(
|
|
|
|
LListHead<gprs_rlcmac_tbf> *tbf_list, uint8_t tfi,
|
2014-07-10 15:44:06 +00:00
|
|
|
enum gprs_rlcmac_tbf_direction dir);
|
2015-07-10 17:52:37 +00:00
|
|
|
gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi,
|
|
|
|
enum gprs_rlcmac_tbf_direction dir);
|
2013-10-26 15:32:04 +00:00
|
|
|
#endif
|
2015-06-29 11:45:05 +00:00
|
|
|
|
|
|
|
uint8_t m_num_tbfs[2];
|
2015-06-30 06:52:54 +00:00
|
|
|
uint8_t m_num_reserved[2];
|
2015-06-30 12:10:13 +00:00
|
|
|
uint8_t m_assigned_usf; /* bit set */
|
2015-07-08 10:53:16 +00:00
|
|
|
uint32_t m_assigned_tfi[2]; /* bit set */
|
2015-07-10 17:52:37 +00:00
|
|
|
struct gprs_rlcmac_tbf *m_tbfs[2][32];
|
2013-10-17 15:01:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct gprs_rlcmac_trx {
|
|
|
|
void *fl1h;
|
|
|
|
uint16_t arfcn;
|
|
|
|
struct gprs_rlcmac_pdch pdch[8];
|
2013-10-20 08:14:03 +00:00
|
|
|
|
|
|
|
/* back pointers */
|
|
|
|
struct BTS *bts;
|
|
|
|
uint8_t trx_no;
|
2015-06-30 06:52:54 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
void reserve_slots(enum gprs_rlcmac_tbf_direction dir, uint8_t slots);
|
|
|
|
void unreserve_slots(enum gprs_rlcmac_tbf_direction dir, uint8_t slots);
|
|
|
|
#endif
|
2013-10-17 15:01:54 +00:00
|
|
|
};
|
|
|
|
|
2013-10-17 17:41:11 +00:00
|
|
|
/**
|
|
|
|
* This is the data from C. As soon as our minimal compiler is gcc 4.7
|
|
|
|
* we can start to compile pcu_vty.c with c++ and remove the split.
|
|
|
|
*/
|
2013-10-17 15:01:54 +00:00
|
|
|
struct gprs_rlcmac_bts {
|
|
|
|
uint8_t bsic;
|
|
|
|
uint8_t fc_interval;
|
2015-05-06 08:47:30 +00:00
|
|
|
uint16_t fc_bucket_time;
|
2015-04-21 10:56:48 +00:00
|
|
|
uint32_t fc_bvc_bucket_size;
|
|
|
|
uint32_t fc_bvc_leak_rate;
|
|
|
|
uint32_t fc_ms_bucket_size;
|
|
|
|
uint32_t fc_ms_leak_rate;
|
2013-10-17 15:01:54 +00:00
|
|
|
uint8_t cs1;
|
|
|
|
uint8_t cs2;
|
|
|
|
uint8_t cs3;
|
|
|
|
uint8_t cs4;
|
|
|
|
uint8_t initial_cs_dl, initial_cs_ul;
|
2016-01-07 14:00:43 +00:00
|
|
|
uint8_t initial_mcs_dl, initial_mcs_ul;
|
2015-06-04 17:04:30 +00:00
|
|
|
uint8_t max_cs_dl, max_cs_ul;
|
2016-01-07 10:48:28 +00:00
|
|
|
uint8_t max_mcs_dl, max_mcs_ul;
|
2013-10-17 15:01:54 +00:00
|
|
|
uint8_t force_cs; /* 0=use from BTS 1=use from VTY */
|
|
|
|
uint16_t force_llc_lifetime; /* overrides lifetime from SGSN */
|
2015-03-20 11:02:42 +00:00
|
|
|
uint32_t llc_discard_csec;
|
2015-04-02 11:58:09 +00:00
|
|
|
uint32_t llc_idle_ack_csec;
|
llc: Use CoDel to drop packages from the LLC queue
Currently packets are only dropped if they have reached their maximum
life time. This leads to LLC queues being constantly filled under
load, increasing the latency up to the maximum life time. This kind
of bufferbloat hinders TCP's congestion avoidance algorithms. To keep
the queues short, the CoDel active queue management algorithm can be
used.
This commit changes to llc_dequeue method to apply the CoDel
algorithm to selectively drop LLC frames before they passed to the
TBF layer to be encoded in BSNs. This feature is currently disabled
by default.
The CoDel state is managed per MS since the LLC queues are also kept
in the MS objects.
Note that there is still some buffering in the TBF objects, in the
worst case (CS4) 3.5kByte + LLC-MTU octets are stored there. The
resulting additional packet delay is not (yet) taken into account for
CoDel.
Also note that configuration changes are applied to new MS objects
only.
The following VTY commands are added to the 'pcu' node:
- queue codel activates CoDel, the interval is selected by
the implementation
- queue codel interval <1-1000>
activates CoDel with a fixed interval given
in centiseconds (10ms-10s)
- no queue codel deactivates CoDel
Which interval value to use is still an open issue. For high speed
links (e.g. Ethernet), CoDel suggests 100ms. For slower links, the
expected RTT is recommended. The current implementation uses a
default value of 2000ms.
Measurements:
Note that the following measurements depend on several other factors,
most notably the interaction with the SGSN's flow control. They are
just examples to give an idea how CoDel might influence some
parameters.
The measurements have been done with a single E71, first with a
running ping only (Idle), then with an additional TCP download
of a 360k file (Busy). The CoDel interval was set to 1s.
- Idle :
ping ~400ms, avg queue delay 0ms, dropped 0
- Busy, No CoDel:
ping ~6s, avg queue delay 4-6s,
dropped 0, scheduled 948, duration 54s
- Busy, CoDel:
ping 500-1500ms, avg queue delay ~600ms,
dropped 77, scheduled 1040, duration 60s
More measurements with two MS downloading in parallel (two
independant measurements per case).
- Busy, No CoDel:
dropped 0, scheduled 1883, duration 121s
dropped 19, scheduled 2003, duration 133s
- Busy, CoDel:
dropped 22, scheduled 1926, duration 116s
dropped 22, scheduled 1955, duration 108s
Sponsored-by: On-Waves ehf
2015-07-17 14:39:09 +00:00
|
|
|
uint32_t llc_codel_interval_msec; /* 0=disabled, -1=use default interval */
|
2013-10-17 15:01:54 +00:00
|
|
|
uint8_t t3142;
|
|
|
|
uint8_t t3169;
|
|
|
|
uint8_t t3191;
|
|
|
|
uint16_t t3193_msec;
|
|
|
|
uint8_t t3195;
|
|
|
|
uint8_t n3101;
|
|
|
|
uint8_t n3103;
|
|
|
|
uint8_t n3105;
|
2016-02-22 10:39:30 +00:00
|
|
|
struct gsmtap_inst *gsmtap;
|
2013-10-17 15:01:54 +00:00
|
|
|
struct gprs_rlcmac_trx trx[8];
|
|
|
|
int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts,
|
2015-06-18 15:16:26 +00:00
|
|
|
struct GprsMs *ms,
|
2015-07-10 08:41:36 +00:00
|
|
|
struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single,
|
|
|
|
int use_tbf);
|
2013-10-17 15:01:54 +00:00
|
|
|
uint32_t alloc_algorithm_curst; /* options to customize algorithm */
|
|
|
|
uint8_t force_two_phase;
|
|
|
|
uint8_t alpha, gamma;
|
2015-09-28 16:12:57 +00:00
|
|
|
uint8_t egprs_enabled;
|
2015-03-19 10:22:38 +00:00
|
|
|
uint32_t dl_tbf_idle_msec; /* hold time for idle DL TBFs */
|
2015-05-28 14:11:19 +00:00
|
|
|
uint32_t ms_idle_sec;
|
2015-06-04 10:12:32 +00:00
|
|
|
uint8_t cs_adj_enabled;
|
|
|
|
uint8_t cs_adj_upper_limit;
|
|
|
|
uint8_t cs_adj_lower_limit;
|
2016-06-15 12:16:41 +00:00
|
|
|
struct {int16_t low; int16_t high; } cs_lqual_ranges[MAX_GPRS_CS];
|
2015-06-12 08:52:34 +00:00
|
|
|
uint16_t cs_downgrade_threshold; /* downgrade if less packets left (DL) */
|
2016-01-19 14:53:30 +00:00
|
|
|
uint16_t ws_base;
|
|
|
|
uint16_t ws_pdch; /* increase WS by this value per PDCH */
|
2013-10-17 17:41:11 +00:00
|
|
|
|
2015-07-16 16:33:46 +00:00
|
|
|
/* State for dynamic algorithm selection */
|
|
|
|
int multislot_disabled;
|
2013-10-19 19:10:38 +00:00
|
|
|
|
2013-10-17 17:41:11 +00:00
|
|
|
/**
|
|
|
|
* Point back to the C++ object. This is used during the transition
|
|
|
|
* period.
|
|
|
|
*/
|
|
|
|
struct BTS *bts;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
/**
|
|
|
|
* I represent a GSM BTS. I have one or more TRX, I know the current
|
|
|
|
* GSM time and I have controllers that help with allocating resources
|
|
|
|
* on my TRXs.
|
|
|
|
*/
|
|
|
|
struct BTS {
|
|
|
|
public:
|
2013-10-27 08:02:31 +00:00
|
|
|
enum {
|
|
|
|
CTR_TBF_DL_ALLOCATED,
|
|
|
|
CTR_TBF_DL_FREED,
|
2016-01-21 19:12:04 +00:00
|
|
|
CTR_TBF_DL_ABORTED,
|
2013-10-27 08:02:31 +00:00
|
|
|
CTR_TBF_UL_ALLOCATED,
|
|
|
|
CTR_TBF_UL_FREED,
|
2016-01-21 19:12:04 +00:00
|
|
|
CTR_TBF_UL_ABORTED,
|
2013-11-13 14:02:50 +00:00
|
|
|
CTR_TBF_REUSED,
|
2015-07-14 12:02:41 +00:00
|
|
|
CTR_TBF_ALLOC_ALGO_A,
|
|
|
|
CTR_TBF_ALLOC_ALGO_B,
|
2016-01-19 09:44:42 +00:00
|
|
|
CTR_TBF_FAILED_EGPRS_ONLY,
|
2013-11-13 18:36:57 +00:00
|
|
|
CTR_RLC_SENT,
|
|
|
|
CTR_RLC_RESENT,
|
2013-11-23 23:01:50 +00:00
|
|
|
CTR_RLC_RESTARTED,
|
2013-11-19 16:09:37 +00:00
|
|
|
CTR_RLC_STALLED,
|
2013-11-23 00:01:19 +00:00
|
|
|
CTR_RLC_NACKED,
|
2015-07-07 07:33:29 +00:00
|
|
|
CTR_RLC_ASS_TIMEDOUT,
|
2015-09-07 12:04:56 +00:00
|
|
|
CTR_RLC_ASS_FAILED,
|
2015-07-07 07:33:29 +00:00
|
|
|
CTR_RLC_ACK_TIMEDOUT,
|
2015-09-07 12:04:56 +00:00
|
|
|
CTR_RLC_ACK_FAILED,
|
2015-07-07 07:33:29 +00:00
|
|
|
CTR_RLC_REL_TIMEDOUT,
|
2015-08-25 13:19:31 +00:00
|
|
|
CTR_RLC_LATE_BLOCK,
|
2016-05-18 14:43:10 +00:00
|
|
|
CTR_RLC_SENT_DUMMY,
|
2016-05-21 22:02:56 +00:00
|
|
|
CTR_RLC_SENT_CONTROL,
|
2016-05-21 17:45:23 +00:00
|
|
|
CTR_RLC_DL_BYTES,
|
|
|
|
CTR_RLC_DL_PAYLOAD_BYTES,
|
|
|
|
CTR_RLC_UL_BYTES,
|
|
|
|
CTR_RLC_UL_PAYLOAD_BYTES,
|
2013-10-27 08:02:31 +00:00
|
|
|
CTR_DECODE_ERRORS,
|
2013-10-27 09:00:47 +00:00
|
|
|
CTR_SBA_ALLOCATED,
|
|
|
|
CTR_SBA_FREED,
|
|
|
|
CTR_SBA_TIMEDOUT,
|
2013-10-27 09:34:31 +00:00
|
|
|
CTR_LLC_FRAME_TIMEDOUT,
|
|
|
|
CTR_LLC_FRAME_DROPPED,
|
2013-11-13 15:43:26 +00:00
|
|
|
CTR_LLC_FRAME_SCHED,
|
2016-05-21 17:45:23 +00:00
|
|
|
CTR_LLC_DL_BYTES,
|
|
|
|
CTR_LLC_UL_BYTES,
|
2013-10-27 09:50:35 +00:00
|
|
|
CTR_RACH_REQUESTS,
|
2013-10-27 08:02:31 +00:00
|
|
|
};
|
|
|
|
|
2015-11-27 18:05:13 +00:00
|
|
|
enum {
|
|
|
|
STAT_MS_PRESENT,
|
|
|
|
};
|
|
|
|
|
2015-03-20 13:26:05 +00:00
|
|
|
enum {
|
|
|
|
TIMER_T3190_MSEC = 5000,
|
|
|
|
};
|
|
|
|
|
2013-10-17 17:41:11 +00:00
|
|
|
BTS();
|
2013-10-27 08:02:31 +00:00
|
|
|
~BTS();
|
2013-10-17 17:41:11 +00:00
|
|
|
|
|
|
|
static BTS* main_bts();
|
|
|
|
|
|
|
|
struct gprs_rlcmac_bts *bts_data();
|
2013-10-19 18:47:12 +00:00
|
|
|
SBAController *sba();
|
2013-10-17 17:41:11 +00:00
|
|
|
|
2013-10-17 17:59:56 +00:00
|
|
|
/** TODO: change the number to unsigned */
|
|
|
|
void set_current_frame_number(int frame_number);
|
2015-08-26 11:22:28 +00:00
|
|
|
void set_current_block_frame_number(int frame_number, unsigned max_delay);
|
2013-10-17 17:59:56 +00:00
|
|
|
int current_frame_number() const;
|
|
|
|
|
2013-10-19 16:28:59 +00:00
|
|
|
/** add paging to paging queue(s) */
|
|
|
|
int add_paging(uint8_t chan_needed, uint8_t *identity_lv);
|
|
|
|
|
2014-07-10 15:44:06 +00:00
|
|
|
gprs_rlcmac_dl_tbf *dl_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts);
|
|
|
|
gprs_rlcmac_ul_tbf *ul_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts);
|
2015-07-10 17:52:37 +00:00
|
|
|
gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts);
|
|
|
|
gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts);
|
2013-10-19 19:10:38 +00:00
|
|
|
|
2013-10-26 17:17:58 +00:00
|
|
|
int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx);
|
|
|
|
|
2013-10-26 17:49:16 +00:00
|
|
|
int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn);
|
2013-10-26 18:56:20 +00:00
|
|
|
int rcv_rach(uint8_t ra, uint32_t Fn, int16_t qta);
|
2013-10-26 17:49:16 +00:00
|
|
|
|
2015-05-21 09:10:15 +00:00
|
|
|
void trigger_dl_ass(gprs_rlcmac_dl_tbf *tbf, gprs_rlcmac_tbf *old_tbf);
|
2013-10-26 18:12:59 +00:00
|
|
|
void snd_dl_ass(gprs_rlcmac_tbf *tbf, uint8_t poll, const char *imsi);
|
|
|
|
|
2015-05-13 11:33:12 +00:00
|
|
|
GprsMsStorage &ms_store();
|
|
|
|
GprsMs *ms_by_tlli(uint32_t tlli, uint32_t old_tlli = 0);
|
2015-08-21 16:00:54 +00:00
|
|
|
GprsMs *ms_by_imsi(const char *imsi);
|
2015-11-27 14:17:34 +00:00
|
|
|
GprsMs *ms_alloc(uint8_t ms_class, uint8_t egprs_ms_class = 0);
|
2015-05-13 11:33:12 +00:00
|
|
|
|
2013-10-27 08:02:31 +00:00
|
|
|
/*
|
|
|
|
* Statistics
|
|
|
|
*/
|
|
|
|
void tbf_dl_created();
|
|
|
|
void tbf_dl_freed();
|
2016-01-21 19:12:04 +00:00
|
|
|
void tbf_dl_aborted();
|
2013-10-27 08:02:31 +00:00
|
|
|
void tbf_ul_created();
|
|
|
|
void tbf_ul_freed();
|
2016-01-21 19:12:04 +00:00
|
|
|
void tbf_ul_aborted();
|
2013-11-13 14:02:50 +00:00
|
|
|
void tbf_reused();
|
2015-07-14 12:02:41 +00:00
|
|
|
void tbf_alloc_algo_a();
|
|
|
|
void tbf_alloc_algo_b();
|
2016-01-19 09:44:42 +00:00
|
|
|
void tbf_failed_egprs_only();
|
2013-11-13 18:36:57 +00:00
|
|
|
void rlc_sent();
|
|
|
|
void rlc_resent();
|
2013-11-23 23:01:50 +00:00
|
|
|
void rlc_restarted();
|
2013-11-19 16:09:37 +00:00
|
|
|
void rlc_stalled();
|
2013-11-23 00:01:19 +00:00
|
|
|
void rlc_nacked();
|
2015-07-07 07:33:29 +00:00
|
|
|
void rlc_ass_timedout();
|
2015-09-07 12:04:56 +00:00
|
|
|
void rlc_ass_failed();
|
2015-07-07 07:33:29 +00:00
|
|
|
void rlc_ack_timedout();
|
2015-09-07 12:04:56 +00:00
|
|
|
void rlc_ack_failed();
|
2015-07-07 07:33:29 +00:00
|
|
|
void rlc_rel_timedout();
|
2015-08-25 13:19:31 +00:00
|
|
|
void rlc_late_block();
|
2016-05-18 14:43:10 +00:00
|
|
|
void rlc_sent_dummy();
|
2016-05-21 22:02:56 +00:00
|
|
|
void rlc_sent_control();
|
2016-05-21 17:45:23 +00:00
|
|
|
void rlc_dl_bytes(int bytes);
|
|
|
|
void rlc_dl_payload_bytes(int bytes);
|
|
|
|
void rlc_ul_bytes(int bytes);
|
|
|
|
void rlc_ul_payload_bytes(int bytes);
|
2013-10-27 08:02:31 +00:00
|
|
|
void decode_error();
|
2013-10-27 09:00:47 +00:00
|
|
|
void sba_allocated();
|
|
|
|
void sba_freed();
|
|
|
|
void sba_timedout();
|
2013-11-13 15:43:26 +00:00
|
|
|
void llc_timedout_frame();
|
|
|
|
void llc_dropped_frame();
|
|
|
|
void llc_frame_sched();
|
2016-05-21 17:45:23 +00:00
|
|
|
void llc_dl_bytes(int bytes);
|
|
|
|
void llc_ul_bytes(int bytes);
|
2013-10-27 09:50:35 +00:00
|
|
|
void rach_frame();
|
2013-10-27 08:02:31 +00:00
|
|
|
|
2015-11-27 18:05:13 +00:00
|
|
|
void ms_present(int32_t n);
|
|
|
|
int32_t ms_present_get();
|
|
|
|
|
2013-10-27 08:02:31 +00:00
|
|
|
/*
|
|
|
|
* Below for C interface for the VTY
|
|
|
|
*/
|
|
|
|
struct rate_ctr_group *rate_counters() const;
|
2015-11-27 18:05:13 +00:00
|
|
|
struct osmo_stat_item_group *stat_items() const;
|
2013-10-27 08:02:31 +00:00
|
|
|
|
2015-12-28 18:15:40 +00:00
|
|
|
LListHead<gprs_rlcmac_tbf>& ul_tbfs();
|
|
|
|
LListHead<gprs_rlcmac_tbf>& dl_tbfs();
|
2013-10-17 17:41:11 +00:00
|
|
|
private:
|
2013-10-17 17:59:56 +00:00
|
|
|
int m_cur_fn;
|
2015-08-24 12:35:14 +00:00
|
|
|
int m_cur_blk_fn;
|
2013-10-17 17:41:11 +00:00
|
|
|
struct gprs_rlcmac_bts m_bts;
|
2013-10-17 18:12:37 +00:00
|
|
|
PollController m_pollController;
|
2013-10-19 18:47:12 +00:00
|
|
|
SBAController m_sba;
|
2013-10-27 08:02:31 +00:00
|
|
|
struct rate_ctr_group *m_ratectrs;
|
2015-11-27 18:05:13 +00:00
|
|
|
struct osmo_stat_item_group *m_statg;
|
2013-10-17 18:12:37 +00:00
|
|
|
|
2015-05-13 11:33:12 +00:00
|
|
|
GprsMsStorage m_ms_store;
|
|
|
|
|
2015-12-28 18:15:40 +00:00
|
|
|
/* list of uplink TBFs */
|
|
|
|
LListHead<gprs_rlcmac_tbf> m_ul_tbfs;
|
|
|
|
/* list of downlink TBFs */
|
|
|
|
LListHead<gprs_rlcmac_tbf> m_dl_tbfs;
|
|
|
|
|
2013-10-17 18:12:37 +00:00
|
|
|
private:
|
|
|
|
/* disable copying to avoid slicing */
|
|
|
|
BTS(const BTS&);
|
|
|
|
BTS& operator=(const BTS&);
|
2013-10-17 15:01:54 +00:00
|
|
|
};
|
2013-10-17 17:59:56 +00:00
|
|
|
|
|
|
|
inline int BTS::current_frame_number() const
|
|
|
|
{
|
|
|
|
return m_cur_fn;
|
|
|
|
}
|
2013-10-19 18:04:57 +00:00
|
|
|
|
2013-10-19 18:47:12 +00:00
|
|
|
inline SBAController *BTS::sba()
|
|
|
|
{
|
|
|
|
return &m_sba;
|
|
|
|
}
|
2013-10-26 16:39:36 +00:00
|
|
|
|
2015-05-13 11:33:12 +00:00
|
|
|
inline GprsMsStorage &BTS::ms_store()
|
|
|
|
{
|
|
|
|
return m_ms_store;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GprsMs *BTS::ms_by_tlli(uint32_t tlli, uint32_t old_tlli)
|
|
|
|
{
|
|
|
|
return ms_store().get_ms(tlli, old_tlli);
|
|
|
|
}
|
|
|
|
|
2015-08-21 16:00:54 +00:00
|
|
|
inline GprsMs *BTS::ms_by_imsi(const char *imsi)
|
|
|
|
{
|
|
|
|
return ms_store().get_ms(0, 0, imsi);
|
|
|
|
}
|
|
|
|
|
2015-12-28 18:15:40 +00:00
|
|
|
inline LListHead<gprs_rlcmac_tbf>& BTS::ul_tbfs()
|
|
|
|
{
|
|
|
|
return m_ul_tbfs;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline LListHead<gprs_rlcmac_tbf>& BTS::dl_tbfs()
|
|
|
|
{
|
|
|
|
return m_dl_tbfs;
|
|
|
|
}
|
|
|
|
|
2013-10-26 16:39:36 +00:00
|
|
|
inline BTS *gprs_rlcmac_pdch::bts() const
|
|
|
|
{
|
|
|
|
return trx->bts;
|
|
|
|
}
|
|
|
|
|
2015-06-29 11:45:05 +00:00
|
|
|
inline unsigned gprs_rlcmac_pdch::num_tbfs(enum gprs_rlcmac_tbf_direction dir) const
|
|
|
|
{
|
|
|
|
return m_num_tbfs[dir];
|
|
|
|
}
|
|
|
|
|
2015-06-30 06:52:54 +00:00
|
|
|
inline unsigned gprs_rlcmac_pdch::num_reserved(
|
|
|
|
enum gprs_rlcmac_tbf_direction dir) const
|
|
|
|
{
|
|
|
|
return gprs_rlcmac_pdch::m_num_reserved[dir];
|
|
|
|
}
|
|
|
|
|
2015-06-30 12:10:13 +00:00
|
|
|
inline uint8_t gprs_rlcmac_pdch::assigned_usf() const
|
|
|
|
{
|
|
|
|
return m_assigned_usf;
|
|
|
|
}
|
|
|
|
|
2015-07-08 10:53:16 +00:00
|
|
|
inline uint32_t gprs_rlcmac_pdch::assigned_tfi(
|
|
|
|
enum gprs_rlcmac_tbf_direction dir) const
|
2015-06-30 12:10:13 +00:00
|
|
|
{
|
2015-07-08 10:53:16 +00:00
|
|
|
return m_assigned_tfi[dir];
|
2015-06-30 12:10:13 +00:00
|
|
|
}
|
|
|
|
|
2013-10-27 08:02:31 +00:00
|
|
|
inline struct rate_ctr_group *BTS::rate_counters() const
|
|
|
|
{
|
|
|
|
return m_ratectrs;
|
|
|
|
}
|
|
|
|
|
2015-11-27 18:05:13 +00:00
|
|
|
inline struct osmo_stat_item_group *BTS::stat_items() const
|
|
|
|
{
|
|
|
|
return m_statg;
|
|
|
|
}
|
|
|
|
|
2016-05-21 17:45:23 +00:00
|
|
|
#define CREATE_COUNT_ADD_INLINE(func_name, ctr_name) \
|
|
|
|
inline void BTS::func_name(int inc) {\
|
|
|
|
rate_ctr_add(&m_ratectrs->ctr[ctr_name], inc); \
|
|
|
|
}
|
|
|
|
|
2013-10-27 09:00:47 +00:00
|
|
|
#define CREATE_COUNT_INLINE(func_name, ctr_name) \
|
|
|
|
inline void BTS::func_name() {\
|
|
|
|
rate_ctr_inc(&m_ratectrs->ctr[ctr_name]); \
|
|
|
|
}
|
2013-10-27 08:50:15 +00:00
|
|
|
|
2013-10-27 09:00:47 +00:00
|
|
|
CREATE_COUNT_INLINE(tbf_dl_created, CTR_TBF_DL_ALLOCATED)
|
|
|
|
CREATE_COUNT_INLINE(tbf_dl_freed, CTR_TBF_DL_FREED)
|
2016-01-21 19:12:04 +00:00
|
|
|
CREATE_COUNT_INLINE(tbf_dl_aborted, CTR_TBF_DL_ABORTED)
|
2013-10-27 09:00:47 +00:00
|
|
|
CREATE_COUNT_INLINE(tbf_ul_created, CTR_TBF_UL_ALLOCATED)
|
|
|
|
CREATE_COUNT_INLINE(tbf_ul_freed, CTR_TBF_UL_FREED)
|
2016-01-21 19:12:04 +00:00
|
|
|
CREATE_COUNT_INLINE(tbf_ul_aborted, CTR_TBF_UL_ABORTED)
|
2013-11-13 14:02:50 +00:00
|
|
|
CREATE_COUNT_INLINE(tbf_reused, CTR_TBF_REUSED)
|
2015-07-14 12:02:41 +00:00
|
|
|
CREATE_COUNT_INLINE(tbf_alloc_algo_a, CTR_TBF_ALLOC_ALGO_A)
|
|
|
|
CREATE_COUNT_INLINE(tbf_alloc_algo_b, CTR_TBF_ALLOC_ALGO_B)
|
2016-01-19 09:44:42 +00:00
|
|
|
CREATE_COUNT_INLINE(tbf_failed_egprs_only, CTR_TBF_FAILED_EGPRS_ONLY)
|
2013-11-13 18:36:57 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_sent, CTR_RLC_SENT)
|
|
|
|
CREATE_COUNT_INLINE(rlc_resent, CTR_RLC_RESENT)
|
2013-11-23 23:01:50 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_restarted, CTR_RLC_RESTARTED)
|
2013-11-19 16:09:37 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_stalled, CTR_RLC_STALLED)
|
2013-11-23 00:01:19 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_nacked, CTR_RLC_NACKED)
|
2015-07-07 07:33:29 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_ass_timedout, CTR_RLC_ASS_TIMEDOUT);
|
2015-09-07 12:04:56 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_ass_failed, CTR_RLC_ASS_FAILED);
|
2015-07-07 07:33:29 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_ack_timedout, CTR_RLC_ACK_TIMEDOUT);
|
2015-09-07 12:04:56 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_ack_failed, CTR_RLC_ACK_FAILED);
|
2015-07-07 07:33:29 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_rel_timedout, CTR_RLC_REL_TIMEDOUT);
|
2015-08-25 13:19:31 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_late_block, CTR_RLC_LATE_BLOCK);
|
2016-05-18 14:43:10 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_sent_dummy, CTR_RLC_SENT_DUMMY);
|
2016-05-21 22:02:56 +00:00
|
|
|
CREATE_COUNT_INLINE(rlc_sent_control, CTR_RLC_SENT_CONTROL);
|
2016-05-21 17:45:23 +00:00
|
|
|
CREATE_COUNT_ADD_INLINE(rlc_dl_bytes, CTR_RLC_DL_BYTES);
|
|
|
|
CREATE_COUNT_ADD_INLINE(rlc_dl_payload_bytes, CTR_RLC_DL_PAYLOAD_BYTES);
|
|
|
|
CREATE_COUNT_ADD_INLINE(rlc_ul_bytes, CTR_RLC_UL_BYTES);
|
|
|
|
CREATE_COUNT_ADD_INLINE(rlc_ul_payload_bytes, CTR_RLC_UL_PAYLOAD_BYTES);
|
2013-10-27 09:00:47 +00:00
|
|
|
CREATE_COUNT_INLINE(decode_error, CTR_DECODE_ERRORS)
|
|
|
|
CREATE_COUNT_INLINE(sba_allocated, CTR_SBA_ALLOCATED)
|
|
|
|
CREATE_COUNT_INLINE(sba_freed, CTR_SBA_FREED)
|
|
|
|
CREATE_COUNT_INLINE(sba_timedout, CTR_SBA_TIMEDOUT)
|
2013-11-13 15:43:26 +00:00
|
|
|
CREATE_COUNT_INLINE(llc_timedout_frame, CTR_LLC_FRAME_TIMEDOUT);
|
|
|
|
CREATE_COUNT_INLINE(llc_dropped_frame, CTR_LLC_FRAME_DROPPED);
|
|
|
|
CREATE_COUNT_INLINE(llc_frame_sched, CTR_LLC_FRAME_SCHED);
|
2016-05-21 17:45:23 +00:00
|
|
|
CREATE_COUNT_ADD_INLINE(llc_dl_bytes, CTR_LLC_DL_BYTES);
|
|
|
|
CREATE_COUNT_ADD_INLINE(llc_ul_bytes, CTR_LLC_UL_BYTES);
|
2013-10-27 09:50:35 +00:00
|
|
|
CREATE_COUNT_INLINE(rach_frame, CTR_RACH_REQUESTS);
|
2013-10-27 08:50:15 +00:00
|
|
|
|
2013-10-27 09:00:47 +00:00
|
|
|
#undef CREATE_COUNT_INLINE
|
2013-10-27 08:50:15 +00:00
|
|
|
|
2015-11-27 18:05:13 +00:00
|
|
|
#define CREATE_STAT_INLINE(func_name, func_name_get, stat_name) \
|
|
|
|
inline void BTS::func_name(int32_t val) {\
|
|
|
|
osmo_stat_item_set(m_statg->items[stat_name], val); \
|
|
|
|
} \
|
|
|
|
inline int32_t BTS::func_name_get() {\
|
|
|
|
return osmo_stat_item_get_last(m_statg->items[stat_name]); \
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_STAT_INLINE(ms_present, ms_present_get, STAT_MS_PRESENT);
|
|
|
|
|
|
|
|
#undef CREATE_STAT_INLINE
|
2013-10-27 08:50:15 +00:00
|
|
|
|
2013-10-26 16:39:36 +00:00
|
|
|
inline gprs_rlcmac_bts *gprs_rlcmac_pdch::bts_data() const
|
|
|
|
{
|
|
|
|
return trx->bts->bts_data();
|
|
|
|
}
|
2013-10-26 16:53:16 +00:00
|
|
|
|
|
|
|
inline uint8_t gprs_rlcmac_pdch::trx_no() const
|
|
|
|
{
|
|
|
|
return trx->trx_no;
|
|
|
|
}
|
2013-10-17 17:41:11 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
struct gprs_rlcmac_bts *bts_main_data();
|
2013-10-27 08:02:31 +00:00
|
|
|
struct rate_ctr_group *bts_main_data_stats();
|
2015-11-27 18:05:13 +00:00
|
|
|
struct osmo_stat_item_group *bts_main_data_stat_items();
|
2013-10-17 17:41:11 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2013-10-19 15:37:48 +00:00
|
|
|
|
|
|
|
inline bool gprs_rlcmac_pdch::is_enabled() const
|
|
|
|
{
|
|
|
|
return m_is_enabled;
|
|
|
|
}
|
2013-10-17 17:41:11 +00:00
|
|
|
#endif
|