aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/osmo-bts/Makefile.am1
-rw-r--r--include/osmo-bts/abis.h16
-rw-r--r--include/osmo-bts/bts.h18
-rw-r--r--include/osmo-bts/bts_shutdown_fsm.h4
-rw-r--r--include/osmo-bts/bts_trx.h2
-rw-r--r--include/osmo-bts/cbch.h2
-rw-r--r--include/osmo-bts/gsm_data.h395
-rw-r--r--include/osmo-bts/l1sap.h3
-rw-r--r--include/osmo-bts/lchan.h371
-rw-r--r--include/osmo-bts/measurement.h2
-rw-r--r--include/osmo-bts/nm_common_fsm.h10
-rw-r--r--include/osmo-bts/oml.h3
-rw-r--r--include/osmo-bts/pcu_if.h3
-rw-r--r--include/osmo-bts/phy_link.h5
-rw-r--r--include/osmo-bts/power_control.h85
-rw-r--r--include/osmo-bts/rsl.h4
-rw-r--r--include/osmo-bts/scheduler.h4
-rw-r--r--include/osmo-bts/scheduler_backend.h2
-rw-r--r--include/osmo-bts/signal.h6
-rw-r--r--include/osmo-bts/ta_control.h2
-rw-r--r--include/osmo-bts/tx_power.h1
21 files changed, 519 insertions, 420 deletions
diff --git a/include/osmo-bts/Makefile.am b/include/osmo-bts/Makefile.am
index d52c9aa4..247e43e0 100644
--- a/include/osmo-bts/Makefile.am
+++ b/include/osmo-bts/Makefile.am
@@ -22,6 +22,7 @@ noinst_HEADERS = \
control_if.h \
cbch.h \
l1sap.h \
+ lchan.h \
power_control.h \
scheduler.h \
scheduler_backend.h \
diff --git a/include/osmo-bts/abis.h b/include/osmo-bts/abis.h
index 62407ece..40707cd1 100644
--- a/include/osmo-bts/abis.h
+++ b/include/osmo-bts/abis.h
@@ -6,19 +6,15 @@
#include <osmo-bts/gsm_data.h>
-#define OML_RETRY_TIMER 5
-#define OML_PING_TIMER 20
-
-enum {
- LINK_STATE_IDLE = 0,
- LINK_STATE_RETRYING,
- LINK_STATE_CONNECTING,
- LINK_STATE_CONNECT,
+enum abis_link_fsm_event {
+ ABIS_LINK_EV_SIGN_LINK_OML_UP,
+ ABIS_LINK_EV_SIGN_LINK_DOWN,
+ ABIS_LINK_EV_VTY_RM_ADDR, /* data: struct bsc_oml_host* being removed */
};
void abis_init(struct gsm_bts *bts);
-struct e1inp_line *abis_open(struct gsm_bts *bts, char *dst_host,
- char *model_name);
+int abis_open(struct gsm_bts *bts, char *model_name);
+
int abis_oml_sendmsg(struct msgb *msg);
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index 6a61d015..8832588e 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -62,6 +62,8 @@ const char *btsvariant2str(enum gsm_bts_type_variant v);
/* Whether the BTS model requires RadioCarrier MO to be in Enabled state
* (OPSTARTed) before OPSTARTing the RadioChannel MOs. See OS#5157 */
#define BTS_INTERNAL_FLAG_NM_RCHANNEL_DEPENDS_RCARRIER (1 << 2)
+/* Whether the BTS model reports interference measurements to L1SAP. */
+#define BTS_INTERNAL_FLAG_INTERF_MEAS (1 << 3)
/* BTS implementation flags (internal use, not exposed via OML) */
#define bts_internal_flag_get(bts, flag) \
@@ -133,6 +135,12 @@ struct gsm_bts_sm {
struct gsm_abis_mo mo;
};
+/* Struct that holds one OML-Address (Address of the BSC) */
+struct bsc_oml_host {
+ struct llist_head list;
+ char *addr;
+};
+
/* One BTS */
struct gsm_bts {
/* list header in net->bts_list */
@@ -295,8 +303,7 @@ struct gsm_bts {
} etws;
struct paging_state *paging_state;
- char *bsc_oml_host;
- struct llist_head oml_queue;
+ struct llist_head bsc_oml_hosts;
unsigned int rtp_jitter_buf_ms;
bool rtp_jitter_adaptive;
@@ -363,6 +370,8 @@ struct gsm_bts {
} gsmtap;
struct osmo_fsm_inst *shutdown_fi; /* FSM instance to manage shutdown procedure during process exit */
+ bool shutdown_fi_exit_proc; /* exit process when shutdown_fsm is finished? */
+ struct osmo_fsm_inst *abis_link_fi; /* FSM instance to manage abis connection during process startup and link failure */
struct osmo_tdef *T_defs; /* Timer defines */
void *model_priv; /* Allocated by bts_model, contains model specific data pointer */
@@ -384,6 +393,7 @@ struct gsm_bts *gsm_bts_num(const struct gsm_network *net, int num);
int bts_init(struct gsm_bts *bts);
void bts_shutdown(struct gsm_bts *bts, const char *reason);
+void bts_shutdown_ext(struct gsm_bts *bts, const char *reason, bool exit_proc);
int bts_link_estab(struct gsm_bts *bts);
@@ -397,10 +407,10 @@ uint8_t *bts_sysinfo_get(struct gsm_bts *bts, const struct gsm_time *g_time);
void regenerate_si3_restoctets(struct gsm_bts *bts);
void regenerate_si4_restoctets(struct gsm_bts *bts);
int get_si4_ro_offset(const uint8_t *si4_buf);
-uint8_t *lchan_sacch_get(struct gsm_lchan *lchan);
-int lchan_init_lapdm(struct gsm_lchan *lchan);
void load_timer_start(struct gsm_bts *bts);
+void load_timer_stop(struct gsm_bts *bts);
+bool load_timer_is_running(const struct gsm_bts *bts);
void bts_update_status(enum bts_global_status which, int on);
struct gsm_time *get_time(struct gsm_bts *bts);
diff --git a/include/osmo-bts/bts_shutdown_fsm.h b/include/osmo-bts/bts_shutdown_fsm.h
index 1e74ac6b..fe526253 100644
--- a/include/osmo-bts/bts_shutdown_fsm.h
+++ b/include/osmo-bts/bts_shutdown_fsm.h
@@ -24,7 +24,6 @@
#include <osmocom/core/fsm.h>
-/* 3GPP TS 24.008 § 4.1.3.3 GMM mobility management states on the network side */
enum bts_shutdown_fsm_states {
BTS_SHUTDOWN_ST_NONE,
BTS_SHUTDOWN_ST_WAIT_RAMP_DOWN_COMPL,
@@ -39,3 +38,6 @@ enum bts_shutdown_fsm_events {
};
extern struct osmo_fsm bts_shutdown_fsm;
+
+struct gsm_bts;
+bool bts_shutdown_in_progress(const struct gsm_bts *bts);
diff --git a/include/osmo-bts/bts_trx.h b/include/osmo-bts/bts_trx.h
index f033573f..c0dcb1ce 100644
--- a/include/osmo-bts/bts_trx.h
+++ b/include/osmo-bts/bts_trx.h
@@ -30,6 +30,7 @@ struct gsm_bts_trx {
uint8_t max_power_backoff_8psk; /* in actual dB OC-2G only */
uint8_t c0_idle_power_red; /* in actual dB OC-2G only */
+ uint8_t ta_ctrl_interval; /* 1 step is 2 SACCH periods */
struct trx_power_params power_params;
struct gsm_power_ctrl_params *bs_dpc_params; /* BS Dynamic Power Control */
@@ -49,6 +50,7 @@ static inline struct gsm_bts_trx *gsm_bts_bb_trx_get_trx(struct gsm_bts_bb_trx *
struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
void gsm_bts_trx_init_shadow_ts(struct gsm_bts_trx *trx);
+void gsm_bts_trx_free_shadow_ts(struct gsm_bts_trx *trx);
char *gsm_trx_name(const struct gsm_bts_trx *trx);
const char *gsm_trx_unit_id(struct gsm_bts_trx *trx);
diff --git a/include/osmo-bts/cbch.h b/include/osmo-bts/cbch.h
index 6bba5fa2..d5521f06 100644
--- a/include/osmo-bts/cbch.h
+++ b/include/osmo-bts/cbch.h
@@ -21,3 +21,5 @@ int bts_process_smscb_cmd(struct gsm_bts *bts, struct rsl_ie_cb_cmd_type cmd_typ
/* call-back from bts model specific code when it wants to obtain a CBCH
* block for a given gsm_time. outbuf must have 23 bytes of space. */
int bts_cbch_get(struct gsm_bts *bts, uint8_t *outbuf, struct gsm_time *g_time);
+
+void bts_cbch_reset(struct gsm_bts *bts);
diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 0ed63612..dcb357f1 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -9,15 +9,13 @@
#include <osmocom/core/statistics.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/linuxlist.h>
-#include <osmocom/codec/ecu.h>
-#include <osmocom/gsm/lapdm.h>
+#include <osmocom/core/tdef.h>
#include <osmocom/gsm/gsm23003.h>
#include <osmocom/gsm/gsm0502.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gsm/rxlev_stat.h>
#include <osmocom/gsm/sysinfo.h>
-#include <osmocom/gsm/meas_rep.h>
#include <osmocom/gsm/bts_features.h>
#include <osmocom/gsm/gsm48_rest_octets.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
@@ -29,6 +27,7 @@
#include <osmo-bts/paging.h>
#include <osmo-bts/tx_power.h>
#include <osmo-bts/oml.h>
+#include <osmo-bts/lchan.h>
#define GSM_FR_BITS 260
#define GSM_EFR_BITS 244
@@ -42,8 +41,6 @@
#define GSM_BTS_AGCH_QUEUE_LOW_LEVEL_DEFAULT 41
#define GSM_BTS_AGCH_QUEUE_HIGH_LEVEL_DEFAULT 91
-#define LOGPLCHAN(lchan, ss, lvl, fmt, args...) LOGP(ss, lvl, "%s " fmt, gsm_lchan_name(lchan), ## args)
-
struct gsm_network {
struct llist_head bts_list;
unsigned int num_bts;
@@ -51,15 +48,6 @@ struct gsm_network {
struct pcu_sock_state *pcu_state;
};
-enum lchan_ciph_state {
- LCHAN_CIPH_NONE,
- LCHAN_CIPH_RX_REQ,
- LCHAN_CIPH_RX_CONF,
- LCHAN_CIPH_RXTX_REQ,
- LCHAN_CIPH_RX_CONF_TX_REQ,
- LCHAN_CIPH_RXTX_CONF,
-};
-
/* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1:
4-bit index is used (2#1111 = 10#15) */
#define SI2Q_MAX_NUM 16
@@ -76,350 +64,6 @@ enum lchan_ciph_state {
#define MAX_VERSION_LENGTH 64
-struct gsm_lchan;
-struct osmo_rtp_socket;
-struct pcu_sock_state;
-struct smscb_msg;
-
-#define MAX_A5_KEY_LEN (128/8)
-#define RSL_ENC_ALG_A5(x) (x+1)
-
-/* state of a logical channel */
-enum gsm_lchan_state {
- LCHAN_S_NONE, /* channel is not active */
- LCHAN_S_ACT_REQ, /* channel activation requested */
- LCHAN_S_ACTIVE, /* channel is active and operational */
- LCHAN_S_REL_REQ, /* channel release has been requested */
- LCHAN_S_REL_ERR, /* channel is in an error state */
- LCHAN_S_BROKEN, /* channel is somehow unusable */
- LCHAN_S_INACTIVE, /* channel is set inactive */
-};
-
-#define MAX_NUM_UL_MEAS 104
-#define LC_UL_M_F_L1_VALID (1 << 0)
-#define LC_UL_M_F_RES_VALID (1 << 1)
-#define LC_UL_M_F_OSMO_EXT_VALID (1 << 2)
-
-struct bts_ul_meas {
- /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
- uint16_t ber10k;
- /* timing advance offset (in 1/256 bits) */
- int16_t ta_offs_256bits;
- /* C/I ratio in dB */
- float c_i;
- /* flags */
- uint8_t is_sub:1;
- /* RSSI in dBm * -1 */
- uint8_t inv_rssi;
-};
-
-struct amr_mode {
- uint8_t mode;
- uint8_t threshold;
- uint8_t hysteresis;
-};
-
-struct amr_multirate_conf {
- uint8_t gsm48_ie[2];
- struct amr_mode ms_mode[4];
- struct amr_mode bts_mode[4];
- uint8_t num_modes;
-};
-
-enum lchan_csd_mode {
- LCHAN_CSD_M_NT,
- LCHAN_CSD_M_T_1200_75,
- LCHAN_CSD_M_T_600,
- LCHAN_CSD_M_T_1200,
- LCHAN_CSD_M_T_2400,
- LCHAN_CSD_M_T_9600,
- LCHAN_CSD_M_T_14400,
- LCHAN_CSD_M_T_29000,
- LCHAN_CSD_M_T_32000,
-};
-
-/* State of the SAPIs in the lchan */
-enum lchan_sapi_state {
- LCHAN_SAPI_S_NONE,
- LCHAN_SAPI_S_REQ,
- LCHAN_SAPI_S_ASSIGNED,
- LCHAN_SAPI_S_REL,
- LCHAN_SAPI_S_ERROR,
-};
-
-/* What kind of release/activation is done? A silent one for
- * the PDCH or one triggered through RSL? */
-enum lchan_rel_act_kind {
- LCHAN_REL_ACT_RSL,
- LCHAN_REL_ACT_PCU,
- LCHAN_REL_ACT_OML,
- LCHAN_REL_ACT_REACT, /* remove once auto-activation hack is removed from opstart_compl() */
-};
-
-struct gsm_rep_facch {
- struct msgb *msg;
- uint32_t fn;
-};
-
-/* MS/BS Power related measurement averaging algo */
-enum gsm_power_ctrl_meas_avg_algo {
- GSM_PWR_CTRL_MEAS_AVG_ALGO_NONE = 0x00,
- GSM_PWR_CTRL_MEAS_AVG_ALGO_UNWEIGHTED = 0x01,
- GSM_PWR_CTRL_MEAS_AVG_ALGO_WEIGHTED = 0x02,
- GSM_PWR_CTRL_MEAS_AVG_ALGO_MOD_MEDIAN = 0x03,
- /* EWMA is an Osmocom specific algo */
- GSM_PWR_CTRL_MEAS_AVG_ALGO_OSMO_EWMA = 0x04,
-};
-
-/* MS/BS Power related measurement parameters */
-struct gsm_power_ctrl_meas_params {
- /* Thresholds (see 3GPP TS 45.008, section A.3.2.1) */
- uint8_t lower_thresh; /* lower (decreasing) direction */
- uint8_t upper_thresh; /* upper (increasing) direction */
-
- /* Threshold Comparators for lower (decreasing) direction */
- uint8_t lower_cmp_p; /* P1 for RxLev, P3 for RxQual */
- uint8_t lower_cmp_n; /* N1 for RxLev, N3 for RxQual */
- /* Threshold Comparators for upper (increasing) direction */
- uint8_t upper_cmp_p; /* P2 for RxLev, P4 for RxQual */
- uint8_t upper_cmp_n; /* N2 for RxLev, N4 for RxQual */
-
- /* Hreqave and Hreqt (see 3GPP TS 45.008, Annex A) */
- uint8_t h_reqave;
- uint8_t h_reqt;
-
- /* AVG algorithm and its specific parameters */
- enum gsm_power_ctrl_meas_avg_algo algo;
- union {
- /* Exponentially Weighted Moving Average */
- struct {
- /* Smoothing factor: higher the value - less smoothing */
- uint8_t alpha; /* 1 .. 99 (in %) */
- } ewma;
- };
-};
-
-/* MS/BS Power Control parameters */
-struct gsm_power_ctrl_params {
- /* Minimum interval between power level changes */
- uint8_t ctrl_interval; /* 1 step is 2 SACCH periods */
-
- /* Power change step size (maximum) */
- uint8_t inc_step_size_db; /* increasing direction */
- uint8_t red_step_size_db; /* reducing direction */
-
- /* Measurement averaging parameters for RxLev & RxQual */
- struct gsm_power_ctrl_meas_params rxqual_meas;
- struct gsm_power_ctrl_meas_params rxlev_meas;
-};
-
-/* Default MS/BS Power Control parameters */
-extern const struct gsm_power_ctrl_params power_ctrl_params_def;
-
-/* Measurement pre-processing state */
-struct gsm_power_ctrl_meas_proc_state {
- /* Number of measurements processed */
- unsigned int meas_num;
- /* Algorithm specific data */
- union {
- struct {
- /* Scaled up 100 times average value */
- int Avg100;
- } ewma;
- };
-};
-
-struct lchan_power_ctrl_state {
- /* Dynamic Power Control parameters (NULL in static mode) */
- const struct gsm_power_ctrl_params *dpc_params;
- /* Measurement pre-processing state (for dynamic mode) */
- struct gsm_power_ctrl_meas_proc_state rxlev_meas_proc;
- /* Number of SACCH blocks to skip (for dynamic mode) */
- int skip_block_num;
-
- /* Depending on the context (MS or BS power control), fields 'current' and 'max'
- * reflect either the MS power level (magic numbers), or BS Power reduction level
- * (attenuation, in dB). */
- uint8_t current;
- uint8_t max;
-};
-
-struct gsm_lchan {
- /* The TS that we're part of */
- struct gsm_bts_trx_ts *ts;
- /* The logical subslot number in the TS */
- uint8_t nr;
- /* The logical channel type */
- enum gsm_chan_t type;
- /* RSL channel mode */
- enum rsl_cmod_spd rsl_cmode;
- /* If TCH, traffic channel mode */
- enum gsm48_chan_mode tch_mode;
- enum lchan_csd_mode csd_mode;
- /* State */
- enum gsm_lchan_state state;
- const char *broken_reason;
- /* Encryption information */
- struct {
- uint8_t alg_id;
- uint8_t key_len;
- uint8_t key[MAX_A5_KEY_LEN];
- } encr;
-
- struct {
- uint32_t bound_ip;
- uint32_t connect_ip;
- uint16_t bound_port;
- uint16_t connect_port;
- uint16_t conn_id;
- uint8_t rtp_payload;
- uint8_t rtp_payload2;
- uint8_t speech_mode;
- struct osmo_rtp_socket *rtp_socket;
- } abis_ip;
-
- uint8_t rqd_ta;
-
- char *name;
-
- /* For handover, activation is described in 3GPP TS 48.058 4.1.3 and 4.1.4:
- *
- * | | Access || transmit | activate
- * | MS Power | Delay || on main channel | dl SACCH
- * ----------------------------------------------------------------------
- * async ho no * --> yes no
- * async ho yes * --> yes may be started
- * sync ho no no --> yes no
- * sync ho yes no --> yes may be started
- * sync ho yes yes --> yes shall be started
- *
- * Always start the main channel immediately.
- * want_dl_sacch_active indicates whether dl SACCH should be activated on CHAN ACT.
- */
- bool want_dl_sacch_active;
-
- /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
- * Currently we don't share these headers so this is a magic number. */
- struct llist_head sapi_cmds;
- uint8_t sapis_dl[23];
- uint8_t sapis_ul[23];
- struct lapdm_channel lapdm_ch;
- struct llist_head dl_tch_queue;
- struct {
- /* bitmask of all SI that are present/valid in si_buf */
- uint32_t valid;
- /* bitmask of all SI that do not mirror the BTS-global SI values */
- uint32_t overridden;
- uint32_t last;
- /* buffers where we put the pre-computed SI:
- SI2Q_MAX_NUM is the max number of SI2quater messages (see 3GPP TS 44.018) */
- sysinfo_buf_t buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM];
- } si;
- struct {
- uint8_t flags;
- /* RSL measurement result number, 0 at lchan_act */
- uint8_t res_nr;
- /* number of measurements stored in array below */
- uint8_t num_ul_meas;
- struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
- /* last L1 header from the MS */
- struct rsl_l1_info l1_info;
- struct gsm_meas_rep_unidir ul_res;
- int16_t ms_toa256;
- /* Frame number of the last measurement indication receceived */
- uint32_t last_fn;
- /* Osmocom extended measurement results, see LC_UL_M_F_EXTD_VALID */
- struct {
- /* minimum value of toa256 during measurement period */
- int16_t toa256_min;
- /* maximum value of toa256 during measurement period */
- int16_t toa256_max;
- /* standard deviation of toa256 value during measurement period */
- uint16_t toa256_std_dev;
- } ext;
- /* Interference levels reported by PHY (in dBm) */
- int16_t interf_meas_dbm[31]; /* Intave max is 31 */
- uint8_t interf_meas_num;
- } meas;
- struct {
- struct amr_multirate_conf amr_mr;
- struct {
- struct osmo_fsm_inst *dl_amr_fsm;
- /* TCH cache */
- uint8_t cache[20];
- /* FACCH cache */
- uint8_t facch[GSM_MACBLOCK_LEN];
- uint8_t len;
- uint32_t fn;
- bool is_update;
- /* set for each SID frame to detect talkspurt for codecs
- without explicit ONSET event */
- bool ul_sid;
- /* indicates if DTXd was active during DL measurement
- period */
- bool dl_active;
- /* last UL SPEECH resume flag */
- bool is_speech_resume;
- } dtx;
- uint8_t last_cmr;
- uint32_t last_fn;
-
- /* SLOT #0 and #1 to store FACCH for repetition */
- struct gsm_rep_facch rep_facch[2];
-
- } tch;
-
- /* 3GPP TS 48.058 § 9.3.37: [0; 255] ok, -1 means invalid*/
- int16_t ms_t_offs;
- /* 3GPP TS 45.010 § 1.2 round trip propagation delay (in symbols) or -1 */
- int16_t p_offs;
-
- /* BTS-side ciphering state (rx only, bi-directional, ...) */
- uint8_t ciph_state;
- uint8_t ciph_ns;
- uint8_t loopback;
- struct {
- uint8_t active;
- uint8_t ref;
- /* T3105: PHYS INF retransmission */
- struct osmo_timer_list t3105;
- /* counts up to Ny1 */
- unsigned int phys_info_count;
- } ho;
- /* S counter for link loss */
- int s;
- /* Kind of the release/activation. E.g. RSL or PCU */
- enum lchan_rel_act_kind rel_act_kind;
- /* RTP header Marker bit to indicate beginning of speech after pause */
- bool rtp_tx_marker;
-
- /* MS/BS power control state */
- struct lchan_power_ctrl_state ms_power_ctrl;
- struct lchan_power_ctrl_state bs_power_ctrl;
-
- /* MS/BS Dynamic Power Control parameters */
- struct gsm_power_ctrl_params ms_dpc_params;
- struct gsm_power_ctrl_params bs_dpc_params;
-
- struct msgb *pending_rel_ind_msg;
-
- /* ECU (Error Concealment Unit) state */
- struct osmo_ecu_state *ecu_state;
-
- struct abis_rsl_osmo_rep_acch_cap repeated_acch_capability;
- bool repeated_dl_facch_active;
- bool repeated_ul_sacch_active;
- bool repeated_dl_sacch_active;
-
- /* Message buffer to store DL-SACCH repeation candidate */
- struct msgb *rep_sacch;
-};
-
-extern const struct value_string lchan_ciph_state_names[];
-static inline const char *lchan_ciph_state_name(uint8_t state) {
- return get_value_string(lchan_ciph_state_names, state);
-}
-
enum gsm_bts_trx_ts_flags {
TS_F_PDCH_ACTIVE = 0x1000,
TS_F_PDCH_ACT_PENDING = 0x2000,
@@ -439,7 +83,6 @@ struct gsm_bts_trx_ts {
struct {
enum gsm_phys_chan_config pchan_is;
enum gsm_phys_chan_config pchan_want;
- struct msgb *pending_chan_activ;
} dyn;
unsigned int flags;
@@ -479,8 +122,6 @@ struct gsm_bts_trx_ts {
struct gsm_lchan lchan[TS_MAX_LCHAN];
};
-#define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0])
-
enum gprs_rlc_par {
RLC_T3142,
RLC_T3169,
@@ -517,6 +158,9 @@ enum gprs_cs {
* OML connection will cause a special warning to be logged. */
#define OSMO_BTS_OML_CONN_EARLY_DISCONNECT 10 /* in seconds */
+extern struct osmo_tdef_group bts_tdef_groups[];
+extern struct osmo_tdef bts_T_defs[];
+extern struct osmo_tdef abis_T_defs[];
extern const struct value_string gsm_pchant_names[13];
extern const struct value_string gsm_pchant_descs[13];
@@ -524,8 +168,6 @@ const char *gsm_pchan_name(enum gsm_phys_chan_config c);
const char *gsm_lchant_name(enum gsm_chan_t c);
char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);
-void gsm_lchan_name_update(struct gsm_lchan *lchan);
-const char *gsm_lchans_name(enum gsm_lchan_state s);
#define GSM_TS_NAME_FMT \
"bts=%u,trx=%u,ts=%u" "%s"
@@ -533,18 +175,6 @@ const char *gsm_lchans_name(enum gsm_lchan_state s);
(ts)->trx->bts->nr, (ts)->trx->nr, (ts)->nr, \
(ts)->vamos.is_shadow ? ",shadow" : ""
-static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
-{
- return lchan->name;
-}
-
-uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
-uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan,
- enum gsm_phys_chan_config as_pchan);
-
-void gsm_lchan_interf_meas_push(struct gsm_lchan *lchan, int dbm);
-int gsm_lchan_interf_meas_calc_band(struct gsm_lchan *lchan);
-
#define BSIC2BCC(bsic) ((bsic) & 0x07)
#define BTS_TSC(bts) BSIC2BCC((bts)->bsic)
@@ -555,9 +185,6 @@ enum gsm_phys_chan_config ts_pchan(const struct gsm_bts_trx_ts *ts);
uint8_t ts_subslots(const struct gsm_bts_trx_ts *ts);
bool ts_is_tch(const struct gsm_bts_trx_ts *ts);
-int lchan2ecu_codec(const struct gsm_lchan *lchan);
-
-void lchan_set_state(struct gsm_lchan *lchan, enum gsm_lchan_state state);
int conf_lchans_as_pchan(struct gsm_bts_trx_ts *ts,
enum gsm_phys_chan_config pchan);
@@ -566,16 +193,6 @@ int conf_lchans_as_pchan(struct gsm_bts_trx_ts *ts,
bool ts_is_pdch(const struct gsm_bts_trx_ts *ts);
-static inline bool lchan_is_dcch(const struct gsm_lchan *lchan)
-{
- switch (lchan->type) {
- case GSM_LCHAN_SDCCH:
- case GSM_LCHAN_TCH_F:
- case GSM_LCHAN_TCH_H:
- return true;
- default:
- return false;
- }
-}
+void gsm_ts_release(struct gsm_bts_trx_ts *ts);
#endif /* _GSM_DATA_H */
diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h
index f78d1143..93c532f8 100644
--- a/include/osmo-bts/l1sap.h
+++ b/include/osmo-bts/l1sap.h
@@ -144,7 +144,4 @@ int bts_check_for_first_ciphrd(struct gsm_lchan *lchan,
int is_ccch_for_agch(struct gsm_bts_trx *trx, uint32_t fn);
-void repeated_dl_facch_active_decision(struct gsm_lchan *lchan,
- const uint8_t *l3, size_t l3_len);
-
#endif /* L1SAP_H */
diff --git a/include/osmo-bts/lchan.h b/include/osmo-bts/lchan.h
new file mode 100644
index 00000000..3aaa75ab
--- /dev/null
+++ b/include/osmo-bts/lchan.h
@@ -0,0 +1,371 @@
+#pragma once
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <osmocom/core/timer.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/codec/ecu.h>
+#include <osmocom/gsm/lapdm.h>
+#include <osmocom/gsm/sysinfo.h>
+#include <osmocom/gsm/protocol/gsm_08_58.h>
+#include <osmocom/gsm/gsm48_rest_octets.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/meas_rep.h>
+
+#include <osmo-bts/power_control.h>
+
+#define LOGPLCHAN(lchan, ss, lvl, fmt, args...) LOGP(ss, lvl, "%s " fmt, gsm_lchan_name(lchan), ## args)
+
+enum lchan_ciph_state {
+ LCHAN_CIPH_NONE,
+ LCHAN_CIPH_RX_REQ,
+ LCHAN_CIPH_RX_CONF,
+ LCHAN_CIPH_RXTX_REQ,
+ LCHAN_CIPH_RX_CONF_TX_REQ,
+ LCHAN_CIPH_RXTX_CONF,
+};
+
+/* state of a logical channel */
+enum gsm_lchan_state {
+ LCHAN_S_NONE, /* channel is not active */
+ LCHAN_S_ACT_REQ, /* channel activation requested */
+ LCHAN_S_ACTIVE, /* channel is active and operational */
+ LCHAN_S_REL_REQ, /* channel release has been requested */
+ LCHAN_S_REL_ERR, /* channel is in an error state */
+ LCHAN_S_BROKEN, /* channel is somehow unusable */
+};
+
+#define MAX_NUM_UL_MEAS 104
+#define LC_UL_M_F_L1_VALID (1 << 0)
+#define LC_UL_M_F_RES_VALID (1 << 1)
+#define LC_UL_M_F_OSMO_EXT_VALID (1 << 2)
+
+#define MAX_A5_KEY_LEN (128/8)
+#define RSL_ENC_ALG_A5(x) (x+1)
+
+struct bts_ul_meas {
+ /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
+ uint16_t ber10k;
+ /* timing advance offset (in 1/256 bits) */
+ int16_t ta_offs_256bits;
+ /* C/I ratio in cB */
+ int16_t c_i;
+ /* flags */
+ uint8_t is_sub:1;
+ /* RSSI in dBm * -1 */
+ uint8_t inv_rssi;
+};
+
+struct amr_mode {
+ uint8_t mode;
+ uint8_t threshold;
+ uint8_t hysteresis;
+};
+
+struct amr_multirate_conf {
+ uint8_t gsm48_ie[2];
+ struct amr_mode ms_mode[4];
+ struct amr_mode bts_mode[4];
+ uint8_t num_modes;
+};
+
+enum lchan_csd_mode {
+ LCHAN_CSD_M_NT,
+ LCHAN_CSD_M_T_1200_75,
+ LCHAN_CSD_M_T_600,
+ LCHAN_CSD_M_T_1200,
+ LCHAN_CSD_M_T_2400,
+ LCHAN_CSD_M_T_9600,
+ LCHAN_CSD_M_T_14400,
+ LCHAN_CSD_M_T_29000,
+ LCHAN_CSD_M_T_32000,
+};
+
+/* State of the SAPIs in the lchan */
+enum lchan_sapi_state {
+ LCHAN_SAPI_S_NONE,
+ LCHAN_SAPI_S_REQ,
+ LCHAN_SAPI_S_ASSIGNED,
+ LCHAN_SAPI_S_REL,
+ LCHAN_SAPI_S_ERROR,
+};
+
+/* What kind of release/activation is done? A silent one for
+ * the PDCH or one triggered through RSL? */
+enum lchan_rel_act_kind {
+ LCHAN_REL_ACT_RSL,
+ LCHAN_REL_ACT_PCU,
+ LCHAN_REL_ACT_OML,
+ LCHAN_REL_ACT_REACT, /* FIXME: remove once auto-activation hack is removed from opstart_compl() (OS#1575) */
+};
+
+struct gsm_rep_facch {
+ struct msgb *msg;
+ uint32_t fn;
+};
+
+
+struct lchan_power_ctrl_state {
+ /* Dynamic Power Control parameters (NULL in static mode) */
+ const struct gsm_power_ctrl_params *dpc_params;
+ /* Measurement pre-processing state (for dynamic mode) */
+ struct gsm_power_ctrl_meas_proc_state rxlev_meas_proc;
+ struct gsm_power_ctrl_meas_proc_state rxqual_meas_proc;
+ struct gsm_power_ctrl_meas_proc_state ci_meas_proc;
+ /* Number of SACCH blocks to skip (for dynamic mode) */
+ int skip_block_num;
+
+ /* Depending on the context (MS or BS power control), fields 'current' and 'max'
+ * reflect either the MS power level (magic numbers), or BS Power reduction level
+ * (attenuation, in dB). */
+ uint8_t current;
+ uint8_t max;
+};
+
+struct lchan_ta_ctrl_state {
+ /* Number of SACCH blocks to skip */
+ int skip_block_num;
+ /* Currently requested TA */
+ uint8_t current;
+};
+
+struct gsm_lchan {
+ /* The TS that we're part of */
+ struct gsm_bts_trx_ts *ts;
+ /* The logical subslot number in the TS */
+ uint8_t nr;
+ /* The logical channel type */
+ enum gsm_chan_t type;
+ /* RSL channel mode */
+ enum rsl_cmod_spd rsl_cmode;
+ /* If TCH, traffic channel mode */
+ enum gsm48_chan_mode tch_mode;
+ enum lchan_csd_mode csd_mode;
+ /* State */
+ enum gsm_lchan_state state;
+ const char *broken_reason;
+ /* Encryption information */
+ struct {
+ uint8_t alg_id;
+ uint8_t key_len;
+ uint8_t key[MAX_A5_KEY_LEN];
+ } encr;
+
+ struct {
+ uint32_t bound_ip;
+ uint32_t connect_ip;
+ uint16_t bound_port;
+ uint16_t connect_port;
+ uint16_t conn_id;
+ uint8_t rtp_payload;
+ uint8_t rtp_payload2;
+ uint8_t speech_mode;
+ struct osmo_rtp_socket *rtp_socket;
+ } abis_ip;
+
+ char *name;
+
+ /* For handover, activation is described in 3GPP TS 48.058 4.1.3 and 4.1.4:
+ *
+ * | | Access || transmit | activate
+ * | MS Power | Delay || on main channel | dl SACCH
+ * ----------------------------------------------------------------------
+ * async ho no * --> yes no
+ * async ho yes * --> yes may be started
+ * sync ho no no --> yes no
+ * sync ho yes no --> yes may be started
+ * sync ho yes yes --> yes shall be started
+ *
+ * Always start the main channel immediately.
+ * want_dl_sacch_active indicates whether dl SACCH should be activated on CHAN ACT.
+ */
+ bool want_dl_sacch_active;
+
+ /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
+ * Currently we don't share these headers so this is a magic number. */
+ struct llist_head sapi_cmds;
+ uint8_t sapis_dl[23];
+ uint8_t sapis_ul[23];
+ struct lapdm_channel lapdm_ch;
+ struct llist_head dl_tch_queue;
+ struct {
+ /* bitmask of all SI that are present/valid in si_buf */
+ uint32_t valid;
+ /* bitmask of all SI that do not mirror the BTS-global SI values */
+ uint32_t overridden;
+ uint32_t last;
+ /* buffers where we put the pre-computed SI:
+ SI2Q_MAX_NUM is the max number of SI2quater messages (see 3GPP TS 44.018) */
+ sysinfo_buf_t buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM];
+ } si;
+ struct {
+ uint8_t flags;
+ /* RSL measurement result number, 0 at lchan_act */
+ uint8_t res_nr;
+ /* number of measurements stored in array below */
+ uint8_t num_ul_meas;
+ struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
+ /* last L1 header from the MS */
+ struct rsl_l1_info l1_info;
+ struct gsm_meas_rep_unidir ul_res;
+ int16_t ms_toa256;
+ int16_t ul_ci_cb_full;
+ int16_t ul_ci_cb_sub;
+ /* Frame number of the last measurement indication receceived */
+ uint32_t last_fn;
+ /* Osmocom extended measurement results, see LC_UL_M_F_EXTD_VALID */
+ struct {
+ /* minimum value of toa256 during measurement period */
+ int16_t toa256_min;
+ /* maximum value of toa256 during measurement period */
+ int16_t toa256_max;
+ /* standard deviation of toa256 value during measurement period */
+ uint16_t toa256_std_dev;
+ } ext;
+ /* Interference levels reported by PHY (in dBm) */
+ int16_t interf_meas_avg_dbm; /* Average value */
+ int16_t interf_meas_dbm[31]; /* Intave max is 31 */
+ uint8_t interf_meas_num;
+ uint8_t interf_band;
+ } meas;
+ struct {
+ struct amr_multirate_conf amr_mr;
+ struct {
+ struct osmo_fsm_inst *dl_amr_fsm;
+ /* TCH cache */
+ uint8_t cache[20];
+ /* FACCH cache */
+ uint8_t facch[GSM_MACBLOCK_LEN];
+ uint8_t len;
+ uint32_t fn;
+ bool is_update;
+ /* set for each SID frame to detect talkspurt for codecs
+ without explicit ONSET event */
+ bool ul_sid;
+ /* indicates if DTXd was active during DL measurement
+ period */
+ bool dl_active;
+ /* last UL SPEECH resume flag */
+ bool is_speech_resume;
+ } dtx;
+ uint8_t last_cmr;
+ uint32_t last_fn;
+
+ } tch;
+
+ /* 3GPP TS 48.058 § 9.3.37: [0; 255] ok, -1 means invalid*/
+ int16_t ms_t_offs;
+ /* 3GPP TS 45.010 § 1.2 round trip propagation delay (in symbols) or -1 */
+ int16_t p_offs;
+
+ /* BTS-side ciphering state (rx only, bi-directional, ...) */
+ uint8_t ciph_state;
+ uint8_t ciph_ns;
+ uint8_t loopback;
+ struct {
+ uint8_t active;
+ uint8_t ref;
+ /* T3105: PHYS INF retransmission */
+ struct osmo_timer_list t3105;
+ /* counts up to Ny1 */
+ unsigned int phys_info_count;
+ } ho;
+ /* S counter for link loss */
+ int s;
+ /* Kind of the release/activation. E.g. RSL or PCU */
+ enum lchan_rel_act_kind rel_act_kind;
+ /* Pending RSL CHANnel ACTIVation message */
+ struct msgb *pending_chan_activ;
+ /* RTP header Marker bit to indicate beginning of speech after pause */
+ bool rtp_tx_marker;
+
+ /* TA Control Loop */
+ struct lchan_ta_ctrl_state ta_ctrl;
+
+ /* MS/BS power control state */
+ struct lchan_power_ctrl_state ms_power_ctrl;
+ struct lchan_power_ctrl_state bs_power_ctrl;
+
+ /* MS/BS Dynamic Power Control parameters */
+ struct gsm_power_ctrl_params ms_dpc_params;
+ struct gsm_power_ctrl_params bs_dpc_params;
+
+ /* Temporary ACCH overpower capabilities and state */
+ struct abis_rsl_osmo_temp_ovp_acch_cap top_acch_cap;
+ bool top_acch_active;
+
+ struct msgb *pending_rel_ind_msg;
+
+ /* ECU (Error Concealment Unit) state */
+ struct osmo_ecu_state *ecu_state;
+
+ /* Repeated ACCH capabilities and current state */
+ struct abis_rsl_osmo_rep_acch_cap rep_acch_cap;
+ struct {
+ bool dl_facch_active;
+ bool ul_sacch_active;
+ bool dl_sacch_active;
+
+ /* Message buffers to store repeation candidates */
+ struct gsm_rep_facch dl_facch[2];
+ struct msgb *dl_sacch_msg;
+ } rep_acch;
+
+ /* Cached early Immediate Assignment message: if the Immediate Assignment arrives before the channel is
+ * confirmed active, then cache it here and send it once the channel is confirmed to be active. This is related
+ * to the Early IA feature, see OsmoBSC config option 'immediate-assignment pre-chan-ack'. */
+ struct msgb *early_rr_ia;
+ struct osmo_timer_list early_rr_ia_delay;
+};
+
+extern const struct value_string lchan_ciph_state_names[];
+static inline const char *lchan_ciph_state_name(uint8_t state)
+{
+ return get_value_string(lchan_ciph_state_names, state);
+}
+
+#define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0])
+
+void gsm_lchan_init(struct gsm_lchan *lchan, struct gsm_bts_trx_ts *ts, unsigned int lchan_nr);
+void gsm_lchan_name_update(struct gsm_lchan *lchan);
+int lchan_init_lapdm(struct gsm_lchan *lchan);
+void gsm_lchan_release(struct gsm_lchan *lchan, enum lchan_rel_act_kind rel_kind);
+int lchan_deactivate(struct gsm_lchan *lchan);
+const char *gsm_lchans_name(enum gsm_lchan_state s);
+
+static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
+{
+ return lchan->name;
+}
+
+uint8_t *lchan_sacch_get(struct gsm_lchan *lchan);
+
+uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
+uint8_t gsm_lchan2chan_nr_rsl(const struct gsm_lchan *lchan);
+uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan,
+ enum gsm_phys_chan_config as_pchan);
+
+void gsm_lchan_interf_meas_push(struct gsm_lchan *lchan, int dbm);
+void gsm_lchan_interf_meas_calc_avg(struct gsm_lchan *lchan);
+
+int lchan2ecu_codec(const struct gsm_lchan *lchan);
+
+void lchan_set_state(struct gsm_lchan *lchan, enum gsm_lchan_state state);
+
+static inline bool lchan_is_dcch(const struct gsm_lchan *lchan)
+{
+ switch (lchan->type) {
+ case GSM_LCHAN_SDCCH:
+ case GSM_LCHAN_TCH_F:
+ case GSM_LCHAN_TCH_H:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#define lchan_is_tch(lchan) \
+ ((lchan)->type == GSM_LCHAN_TCH_F || (lchan)->type == GSM_LCHAN_TCH_H)
diff --git a/include/osmo-bts/measurement.h b/include/osmo-bts/measurement.h
index 45f275f1..ad86d8de 100644
--- a/include/osmo-bts/measurement.h
+++ b/include/osmo-bts/measurement.h
@@ -20,4 +20,6 @@ bool ts45008_83_is_sub(struct gsm_lchan *lchan, uint32_t fn);
int is_meas_complete(struct gsm_lchan *lchan, uint32_t fn);
+void lchan_meas_handle_sacch(struct gsm_lchan *lchan, struct msgb *msg);
+
#endif
diff --git a/include/osmo-bts/nm_common_fsm.h b/include/osmo-bts/nm_common_fsm.h
index 4679b235..1f0accc5 100644
--- a/include/osmo-bts/nm_common_fsm.h
+++ b/include/osmo-bts/nm_common_fsm.h
@@ -25,12 +25,17 @@
#include <osmocom/core/fsm.h>
#include <osmocom/core/utils.h>
+#include <osmocom/core/msgb.h>
/* Common */
enum nm_fsm_events {
NM_EV_SW_ACT,
+ NM_EV_SETATTR_ACK, /* data: struct nm_fsm_ev_setattr_data */
+ NM_EV_SETATTR_NACK, /* data: struct nm_fsm_ev_setattr_data */
NM_EV_OPSTART_ACK,
NM_EV_OPSTART_NACK,
+ NM_EV_SHUTDOWN_START,
+ NM_EV_SHUTDOWN_FINISH,
NM_EV_RSL_UP, /* RadioCarrier and BaseBand Transceiver only */
NM_EV_RSL_DOWN, /* RadioCarrier and BaseBand Transceiver only */
NM_EV_PHYLINK_UP, /* RadioCarrier and BaseBand Transceiver only */
@@ -44,6 +49,11 @@ enum nm_fsm_events {
};
extern const struct value_string nm_fsm_event_names[];
+struct nm_fsm_ev_setattr_data {
+ struct msgb *msg; /* msgb ownership is transferred to FSM */
+ int cause;
+};
+
/* BTS SiteManager */
enum nm_bts_sm_op_fsm_states {
diff --git a/include/osmo-bts/oml.h b/include/osmo-bts/oml.h
index 27afc538..90c90770 100644
--- a/include/osmo-bts/oml.h
+++ b/include/osmo-bts/oml.h
@@ -32,6 +32,7 @@ struct gsm_abis_mo {
struct gsm_bts *bts;
/* NM BTS Site Manager FSM */
struct osmo_fsm_inst *fi;
+ bool setattr_success;
bool opstart_success;
};
@@ -47,7 +48,7 @@ int oml_mo_statechg_ack(const struct gsm_abis_mo *mo);
int oml_mo_statechg_nack(const struct gsm_abis_mo *mo, uint8_t nack_cause);
/* Change the state and send STATE CHG REP */
-int oml_mo_state_chg(struct gsm_abis_mo *mo, int op_state, int avail_state);
+int oml_mo_state_chg(struct gsm_abis_mo *mo, int op_state, int avail_state, int adm_state);
/* First initialization of MO, does _not_ generate state changes */
void oml_mo_state_init(struct gsm_abis_mo *mo, int op_state, int avail_state);
diff --git a/include/osmo-bts/pcu_if.h b/include/osmo-bts/pcu_if.h
index 12a8abc9..bc30f341 100644
--- a/include/osmo-bts/pcu_if.h
+++ b/include/osmo-bts/pcu_if.h
@@ -19,8 +19,7 @@ int pcu_tx_rach_ind(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
int16_t qta, uint16_t ra, uint32_t fn, uint8_t is_11bit,
enum ph_burst_type burst_type, uint8_t sapi);
int pcu_tx_time_ind(uint32_t fn);
-int pcu_tx_interf_ind(uint8_t bts_nr, uint8_t trx_nr, uint32_t fn,
- const uint8_t *pdch_interf);
+int pcu_tx_interf_ind(const struct gsm_bts_trx *trx, uint32_t fn);
int pcu_tx_pag_req(const uint8_t *identity_lv, uint8_t chan_needed);
int pcu_tx_pch_data_cnf(uint32_t fn, uint8_t *data, uint8_t len);
int pcu_tx_susp_req(struct gsm_lchan *lchan, uint32_t tlli, const uint8_t *ra_id, uint8_t cause);
diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index 4b8a8633..862ed48f 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -50,7 +50,8 @@ struct phy_link {
bool use_legacy_setbsic;
uint8_t trxd_pdu_ver_max; /* Maximum TRXD PDU version to negotiate */
bool powered; /* last POWERON (true) or POWEROFF (false) confirmed */
- bool poweronoff_sent; /* is there a POWERON/POWEROFF in transit? (one or the other based on ->powered) */
+ bool poweron_sent; /* is there a POWERON in transit? */
+ bool poweroff_sent; /* is there a POWEROFF in transit? */
} osmotrx;
struct {
char *mcast_dev; /* Network device for multicast */
@@ -112,7 +113,6 @@ struct phy_instance {
} sysmobts;
struct {
struct trx_l1h *hdl;
- bool sw_act_reported;
struct trx_dl_burst_req br[TRX_NR_TS];
} osmotrx;
struct {
@@ -175,6 +175,7 @@ static inline struct phy_instance *trx_phy_instance(const struct gsm_bts_trx *tr
}
int bts_model_phy_link_open(struct phy_link *plink);
+int bts_model_phy_link_close(struct phy_link *plink);
#define LOGPPHL(plink, section, lvl, fmt, args...) LOGP(section, lvl, "%s: " fmt, phy_link_name(plink), ##args)
#define LOGPPHI(pinst, section, lvl, fmt, args...) LOGP(section, lvl, "%s: " fmt, phy_instance_name(pinst), ##args)
diff --git a/include/osmo-bts/power_control.h b/include/osmo-bts/power_control.h
index f2e14cfe..0764ba76 100644
--- a/include/osmo-bts/power_control.h
+++ b/include/osmo-bts/power_control.h
@@ -1,11 +1,90 @@
#pragma once
#include <stdint.h>
-#include <osmo-bts/gsm_data.h>
+#include <stdbool.h>
+/* MS/BS Power related measurement averaging algo */
+enum gsm_power_ctrl_meas_avg_algo {
+ GSM_PWR_CTRL_MEAS_AVG_ALGO_NONE = 0x00,
+ GSM_PWR_CTRL_MEAS_AVG_ALGO_UNWEIGHTED = 0x01,
+ GSM_PWR_CTRL_MEAS_AVG_ALGO_WEIGHTED = 0x02,
+ GSM_PWR_CTRL_MEAS_AVG_ALGO_MOD_MEDIAN = 0x03,
+ /* EWMA is an Osmocom specific algo */
+ GSM_PWR_CTRL_MEAS_AVG_ALGO_OSMO_EWMA = 0x04,
+};
+
+/* MS/BS Power related measurement parameters */
+struct gsm_power_ctrl_meas_params {
+ /* Thresholds (see 3GPP TS 45.008, section A.3.2.1) */
+ uint8_t lower_thresh; /* lower (decreasing) direction */
+ uint8_t upper_thresh; /* upper (increasing) direction */
+
+ /* Threshold Comparators for lower (decreasing) direction */
+ uint8_t lower_cmp_p; /* P1 for RxLev, P3 for RxQual */
+ uint8_t lower_cmp_n; /* N1 for RxLev, N3 for RxQual */
+ /* Threshold Comparators for upper (increasing) direction */
+ uint8_t upper_cmp_p; /* P2 for RxLev, P4 for RxQual */
+ uint8_t upper_cmp_n; /* N2 for RxLev, N4 for RxQual */
+
+ /* Hreqave and Hreqt (see 3GPP TS 45.008, Annex A) */
+ uint8_t h_reqave;
+ uint8_t h_reqt;
+
+ /* AVG algorithm and its specific parameters */
+ enum gsm_power_ctrl_meas_avg_algo algo;
+ union {
+ /* Exponentially Weighted Moving Average */
+ struct {
+ /* Smoothing factor: higher the value - less smoothing */
+ uint8_t alpha; /* 1 .. 99 (in %) */
+ } ewma;
+ };
+};
+
+/* MS/BS Power Control parameters */
+struct gsm_power_ctrl_params {
+ /* Minimum interval between power level changes */
+ uint8_t ctrl_interval; /* 1 step is 2 SACCH periods */
+
+ /* Power change step size (maximum) */
+ uint8_t inc_step_size_db; /* increasing direction */
+ uint8_t red_step_size_db; /* reducing direction */
+
+ /* Measurement averaging parameters for RxLev & RxQual */
+ struct gsm_power_ctrl_meas_params rxqual_meas;
+ struct gsm_power_ctrl_meas_params rxlev_meas;
+
+ /* Measurement averaging parameters for C/I, per chan type */
+ struct gsm_power_ctrl_meas_params ci_fr_meas;
+ struct gsm_power_ctrl_meas_params ci_hr_meas;
+ struct gsm_power_ctrl_meas_params ci_amr_fr_meas;
+ struct gsm_power_ctrl_meas_params ci_amr_hr_meas;
+ struct gsm_power_ctrl_meas_params ci_sdcch_meas;
+ struct gsm_power_ctrl_meas_params ci_gprs_meas;
+};
+
+/* Measurement pre-processing state */
+struct gsm_power_ctrl_meas_proc_state {
+ /* Number of measurements processed */
+ unsigned int meas_num;
+ /* Algorithm specific data */
+ union {
+ struct {
+ /* Scaled up 100 times average value */
+ int Avg100;
+ } ewma;
+ };
+};
+
+/* Default MS/BS Power Control parameters */
+extern const struct gsm_power_ctrl_params power_ctrl_params_def;
+void power_ctrl_params_def_reset(struct gsm_power_ctrl_params *params, bool is_bs_pwr);
+
+struct gsm_lchan;
int lchan_ms_pwr_ctrl(struct gsm_lchan *lchan,
const uint8_t ms_power_lvl,
- const int8_t ul_rssi_dbm);
+ const int8_t ul_rssi_dbm,
+ const int16_t ul_lqual_cb);
int lchan_bs_pwr_ctrl(struct gsm_lchan *lchan,
- const struct gsm48_hdr *gh);
+ const struct gsm48_meas_res *mr);
diff --git a/include/osmo-bts/rsl.h b/include/osmo-bts/rsl.h
index 4e79de5e..dcd476c5 100644
--- a/include/osmo-bts/rsl.h
+++ b/include/osmo-bts/rsl.h
@@ -17,8 +17,6 @@ int rsl_tx_conn_fail(const struct gsm_lchan *lchan, uint8_t cause);
int rsl_tx_rf_rel_ack(struct gsm_lchan *lchan);
int rsl_tx_hando_det(struct gsm_lchan *lchan, uint8_t *ho_delay);
-int lchan_deactivate(struct gsm_lchan *lchan);
-
/* call-back for LAPDm code, called when it wants to send msgs UP */
int lapdm_rll_tx_cb(struct msgb *msg, struct lapdm_entity *le, void *ctx);
@@ -34,6 +32,6 @@ void ipacc_dyn_pdch_complete(struct gsm_bts_trx_ts *ts, int rc);
int rsl_tx_cbch_load_indication(struct gsm_bts *bts, bool ext_cbch, bool overflow, uint8_t amount);
-int rsl_tx_meas_res(struct gsm_lchan *lchan, uint8_t *l3, int l3_len, const struct lapdm_entity *le);
+int rsl_tx_meas_res(struct gsm_lchan *lchan, const uint8_t *l3, int l3_len, int timing_offset);
#endif // _RSL_H */
diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index 80a260fe..d6406474 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -128,6 +128,8 @@ struct l1sched_chan_state {
struct l1sched_meas_set meas_avg_facch; /* measurement results for last FACCH */
uint16_t ber10k_facch; /* bit error rate for last FACCH */
+ uint8_t dl_facch_bursts; /* number of remaining DL FACCH bursts */
+
/* encryption */
int ul_encr_algo; /* A5/x encry algo downlink */
int dl_encr_algo; /* A5/x encry algo uplink */
@@ -272,6 +274,8 @@ struct trx_ul_burst_ind {
size_t burst_len;
};
+#define TRX_BR_F_FACCH (1 << 0)
+
/*! DL burst request with the corresponding meta info */
struct trx_dl_burst_req {
uint8_t flags; /*!< see TRX_BR_F_* */
diff --git a/include/osmo-bts/scheduler_backend.h b/include/osmo-bts/scheduler_backend.h
index 50ba8228..3b1388f4 100644
--- a/include/osmo-bts/scheduler_backend.h
+++ b/include/osmo-bts/scheduler_backend.h
@@ -51,7 +51,7 @@ int _sched_compose_ph_data_ind(struct l1sched_ts *l1ts, uint32_t fn,
int _sched_compose_tch_ind(struct l1sched_ts *l1ts, uint32_t fn,
enum trx_chan_type chan, uint8_t *tch, uint8_t tch_len,
int16_t ta_offs_256bits, uint16_t ber10k, float rssi,
- uint8_t is_sub);
+ int16_t link_qual_cb, uint8_t is_sub);
int tx_fcch_fn(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br);
int tx_sch_fn(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br);
diff --git a/include/osmo-bts/signal.h b/include/osmo-bts/signal.h
index c8168a26..8359f021 100644
--- a/include/osmo-bts/signal.h
+++ b/include/osmo-bts/signal.h
@@ -15,4 +15,10 @@ enum signals_global {
S_NEW_NSVC_ATTR,
};
+struct nm_statechg_signal_data {
+ struct gsm_abis_mo *mo;
+ uint8_t old_state;
+ uint8_t new_state;
+};
+
#endif
diff --git a/include/osmo-bts/ta_control.h b/include/osmo-bts/ta_control.h
index 168f14a7..bf993319 100644
--- a/include/osmo-bts/ta_control.h
+++ b/include/osmo-bts/ta_control.h
@@ -2,4 +2,4 @@
#include <osmo-bts/gsm_data.h>
-void lchan_ms_ta_ctrl(struct gsm_lchan *lchan);
+void lchan_ms_ta_ctrl(struct gsm_lchan *lchan, uint8_t ms_tx_ta, int16_t toa256);
diff --git a/include/osmo-bts/tx_power.h b/include/osmo-bts/tx_power.h
index 8f68d8a5..a7f846e8 100644
--- a/include/osmo-bts/tx_power.h
+++ b/include/osmo-bts/tx_power.h
@@ -78,6 +78,7 @@ int get_p_trxout_actual_mdBm(const struct gsm_bts_trx *trx, uint8_t bs_power_red
int get_p_trxout_actual_mdBm_lchan(const struct gsm_lchan *lchan);
int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass, ramp_compl_cb_t ramp_compl_cb);
+void power_ramp_abort(struct gsm_bts_trx *trx);
void power_trx_change_compl(struct gsm_bts_trx *trx, int p_trxout_cur_mdBm);