2010-04-25 16:28:24 +00:00
|
|
|
#ifndef _GSM48_RR_H
|
|
|
|
#define _GSM48_RR_H
|
|
|
|
|
2011-04-26 00:55:30 +00:00
|
|
|
#include <osmocom/gsm/protocol/gsm_04_08.h>
|
2010-04-25 16:28:24 +00:00
|
|
|
|
2010-05-06 08:48:24 +00:00
|
|
|
#define GSM_TA_CM 55385
|
|
|
|
|
2010-04-25 16:28:24 +00:00
|
|
|
/* GSM 04.07 9.1.2 */
|
|
|
|
#define GSM48_RR_EST_REQ 0x10
|
|
|
|
#define GSM48_RR_EST_IND 0x12
|
|
|
|
#define GSM48_RR_EST_CNF 0x11
|
|
|
|
#define GSM48_RR_REL_IND 0x22
|
|
|
|
#define GSM48_RR_SYNC_IND 0x32
|
|
|
|
#define GSM48_RR_DATA_REQ 0x40
|
|
|
|
#define GSM48_RR_DATA_IND 0x42
|
|
|
|
#define GSM48_RR_UNIT_DATA_IND 0x52
|
|
|
|
#define GSM48_RR_ABORT_REQ 0x60
|
|
|
|
#define GSM48_RR_ABORT_IND 0x62
|
|
|
|
#define GSM48_RR_ACT_REQ 0x70
|
|
|
|
|
|
|
|
#define RR_EST_CAUSE_EMERGENCY 1
|
|
|
|
#define RR_EST_CAUSE_REESTAB_TCH_F 2
|
|
|
|
#define RR_EST_CAUSE_REESTAB_TCH_H 3
|
|
|
|
#define RR_EST_CAUSE_REESTAB_2_TCH_H 4
|
|
|
|
#define RR_EST_CAUSE_ANS_PAG_ANY 5
|
|
|
|
#define RR_EST_CAUSE_ANS_PAG_SDCCH 6
|
|
|
|
#define RR_EST_CAUSE_ANS_PAG_TCH_F 7
|
|
|
|
#define RR_EST_CAUSE_ANS_PAG_TCH_ANY 8
|
|
|
|
#define RR_EST_CAUSE_ORIG_TCHF 9
|
|
|
|
#define RR_EST_CAUSE_LOC_UPD 12
|
|
|
|
#define RR_EST_CAUSE_OTHER_SDCCH 13
|
|
|
|
|
|
|
|
#define RR_REL_CAUSE_UNDEFINED 0
|
2010-06-12 18:44:21 +00:00
|
|
|
#define RR_REL_CAUSE_NORMAL 1
|
|
|
|
#define RR_REL_CAUSE_NOT_AUTHORIZED 2
|
|
|
|
#define RR_REL_CAUSE_RA_FAILURE 3
|
|
|
|
#define RR_REL_CAUSE_T3122 4
|
|
|
|
#define RR_REL_CAUSE_TRY_LATER 5
|
|
|
|
#define RR_REL_CAUSE_EMERGENCY_ONLY 6
|
|
|
|
#define RR_REL_CAUSE_LOST_SIGNAL 7
|
2010-08-21 15:10:30 +00:00
|
|
|
#define RR_REL_CAUSE_LINK_FAILURE 8
|
2010-04-25 16:28:24 +00:00
|
|
|
|
2010-09-17 09:07:29 +00:00
|
|
|
#define RR_SYNC_CAUSE_CIPHERING 1
|
|
|
|
|
2010-04-25 16:28:24 +00:00
|
|
|
#define L3_ALLOC_SIZE 256
|
|
|
|
#define L3_ALLOC_HEADROOM 64
|
|
|
|
|
2010-07-13 14:21:52 +00:00
|
|
|
#define RSL_ALLOC_SIZE 256
|
|
|
|
#define RSL_ALLOC_HEADROOM 64
|
|
|
|
|
2010-04-25 16:28:24 +00:00
|
|
|
#define RR_ALLOC_SIZE 256
|
|
|
|
#define RR_ALLOC_HEADROOM 64
|
|
|
|
|
|
|
|
/* GSM 04.08 RR-SAP header */
|
|
|
|
struct gsm48_rr_hdr {
|
|
|
|
uint32_t msg_type; /* RR-* primitive */
|
|
|
|
uint8_t cause;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* GSM 04.07 9.1.1 */
|
|
|
|
#define GSM48_RR_ST_IDLE 0
|
|
|
|
#define GSM48_RR_ST_CONN_PEND 1
|
|
|
|
#define GSM48_RR_ST_DEDICATED 2
|
2010-06-12 16:16:54 +00:00
|
|
|
#define GSM48_RR_ST_REL_PEND 3
|
2010-04-25 16:28:24 +00:00
|
|
|
|
2010-08-21 15:10:30 +00:00
|
|
|
/* modify state */
|
|
|
|
#define GSM48_RR_MOD_NONE 0
|
|
|
|
#define GSM48_RR_MOD_IMM_ASS 1
|
|
|
|
#define GSM48_RR_MOD_ASSIGN 2
|
|
|
|
#define GSM48_RR_MOD_HANDO 3
|
|
|
|
#define GSM48_RR_MOD_ASSIGN_RESUME 4
|
|
|
|
#define GSM48_RR_MOD_HANDO_RESUME 5
|
|
|
|
|
2010-04-25 16:28:24 +00:00
|
|
|
/* channel description */
|
|
|
|
struct gsm48_rr_cd {
|
|
|
|
uint8_t tsc;
|
|
|
|
uint8_t h; /* using hopping */
|
2010-05-05 08:40:10 +00:00
|
|
|
uint16_t arfcn; /* dedicated mode */
|
2010-04-25 16:28:24 +00:00
|
|
|
uint8_t maio;
|
|
|
|
uint8_t hsn;
|
|
|
|
uint8_t chan_nr; /* type, slot, sub slot */
|
|
|
|
uint8_t link_id;
|
2010-08-14 17:10:26 +00:00
|
|
|
uint8_t ind_tx_power; /* last indicated power */
|
|
|
|
uint8_t ind_ta; /* last indicated ta */
|
2010-04-25 16:28:24 +00:00
|
|
|
uint8_t mob_alloc_lv[9]; /* len + up to 64 bits */
|
2010-08-14 17:10:26 +00:00
|
|
|
uint8_t freq_list_lv[131]; /* len + 130 octets */
|
|
|
|
uint8_t freq_seq_lv[10]; /* len + 9 octets */
|
|
|
|
uint8_t cell_desc_lv[17]; /* len + 16 octets */
|
|
|
|
uint8_t start; /* start time available */
|
|
|
|
struct gsm_time start_tm; /* start time */
|
|
|
|
uint8_t mode; /* mode of channel */
|
|
|
|
uint8_t cipher; /* ciphering of channel */
|
2010-04-25 16:28:24 +00:00
|
|
|
};
|
|
|
|
|
2010-06-25 01:13:52 +00:00
|
|
|
struct gsm48_cr_hist {
|
2010-07-13 14:21:52 +00:00
|
|
|
uint8_t valid;
|
|
|
|
struct gsm48_req_ref ref;
|
2010-06-25 01:13:52 +00:00
|
|
|
};
|
|
|
|
|
2010-09-26 10:35:46 +00:00
|
|
|
/* neighbor cell measurements */
|
|
|
|
struct gsm48_rr_meas {
|
|
|
|
/* note: must be sorted by arfcn 1..1023,0 according to SI5* */
|
|
|
|
uint8_t nc_num; /* number of measured cells (32 max) */
|
|
|
|
int8_t nc_rxlev[32]; /* -128 = no value */
|
|
|
|
uint8_t nc_bsic[32];
|
|
|
|
uint16_t nc_arfcn[32];
|
|
|
|
};
|
|
|
|
|
2010-04-25 16:28:24 +00:00
|
|
|
/* RR sublayer instance */
|
|
|
|
struct gsm48_rrlayer {
|
|
|
|
struct osmocom_ms *ms;
|
|
|
|
int state;
|
|
|
|
|
|
|
|
/* queue for RSL-SAP message upwards */
|
|
|
|
struct llist_head rsl_upqueue;
|
|
|
|
|
|
|
|
/* queue for messages while RR connection is built up */
|
|
|
|
struct llist_head downqueue;
|
|
|
|
|
|
|
|
/* timers */
|
2010-08-21 15:10:30 +00:00
|
|
|
struct timer_list t_starting; /* starting time for chan. access */
|
2010-06-12 16:16:54 +00:00
|
|
|
struct timer_list t_rel_wait; /* wait for L2 to transmit UA */
|
|
|
|
struct timer_list t3110;
|
2010-04-25 16:28:24 +00:00
|
|
|
struct timer_list t3122;
|
|
|
|
struct timer_list t3124;
|
|
|
|
struct timer_list t3126;
|
|
|
|
int t3126_value;
|
|
|
|
#ifndef TODO
|
|
|
|
struct timer_list temp_rach_ti; /* temporary timer */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* states if RR-EST-REQ was used */
|
2010-05-05 08:40:10 +00:00
|
|
|
uint8_t rr_est_req;
|
2010-04-25 16:28:24 +00:00
|
|
|
struct msgb *rr_est_msg;
|
2010-07-17 09:37:58 +00:00
|
|
|
uint8_t est_cause; /* cause used for establishment */
|
2010-04-25 16:28:24 +00:00
|
|
|
|
|
|
|
/* channel request states */
|
|
|
|
uint8_t wait_assign; /* waiting for assignment state */
|
|
|
|
uint8_t n_chan_req; /* number left, incl. current */
|
|
|
|
uint8_t chan_req_val; /* current request value */
|
2010-07-13 14:21:52 +00:00
|
|
|
uint8_t chan_req_mask; /* mask of random bits */
|
2010-06-25 01:13:52 +00:00
|
|
|
|
2010-09-26 10:35:46 +00:00
|
|
|
/* state of dedicated mdoe */
|
|
|
|
uint8_t dm_est;
|
|
|
|
|
2010-07-13 14:21:52 +00:00
|
|
|
/* cr_hist */
|
|
|
|
uint8_t cr_ra; /* stores requested ra until confirmed */
|
2010-06-25 01:13:52 +00:00
|
|
|
struct gsm48_cr_hist cr_hist[3];
|
2010-04-25 16:28:24 +00:00
|
|
|
|
2010-08-10 19:31:07 +00:00
|
|
|
/* V(SD) sequence numbers */
|
|
|
|
uint16_t v_sd; /* 16 PD 1-bit sequence numbers packed */
|
|
|
|
|
2010-04-25 16:28:24 +00:00
|
|
|
/* current channel descriptions */
|
|
|
|
struct gsm48_rr_cd cd_now;
|
|
|
|
|
|
|
|
/* current cipering */
|
|
|
|
uint8_t cipher_on;
|
|
|
|
uint8_t cipher_type; /* 10.5.2.9 */
|
|
|
|
|
2010-08-21 15:10:30 +00:00
|
|
|
/* special states when assigning channel */
|
|
|
|
uint8_t modify_state;
|
|
|
|
uint8_t hando_sync_ind, hando_rot, hando_nci, hando_act;
|
2010-08-14 17:10:26 +00:00
|
|
|
struct gsm48_rr_cd cd_last; /* store last cd in case of failure */
|
|
|
|
struct gsm48_rr_cd cd_before; /* before start time */
|
|
|
|
struct gsm48_rr_cd cd_after; /* after start time */
|
2010-04-25 16:28:24 +00:00
|
|
|
|
2010-06-12 16:16:54 +00:00
|
|
|
/* BA range */
|
|
|
|
uint8_t ba_ranges;
|
|
|
|
uint32_t ba_range[16];
|
2010-07-16 10:52:38 +00:00
|
|
|
|
2010-09-26 10:35:46 +00:00
|
|
|
/* measurements */
|
|
|
|
struct timer_list t_meas;
|
|
|
|
struct gsm48_rr_meas meas;
|
2010-07-16 10:52:38 +00:00
|
|
|
uint8_t monitor;
|
2010-04-25 16:28:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const char *get_rr_name(int value);
|
|
|
|
extern int gsm48_rr_init(struct osmocom_ms *ms);
|
|
|
|
extern int gsm48_rr_exit(struct osmocom_ms *ms);
|
|
|
|
int gsm48_rsl_dequeue(struct osmocom_ms *ms);
|
|
|
|
int gsm48_rr_downmsg(struct osmocom_ms *ms, struct msgb *msg);
|
|
|
|
struct msgb *gsm48_l3_msgb_alloc(void);
|
|
|
|
struct msgb *gsm48_rr_msgb_alloc(int msg_type);
|
|
|
|
int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc,
|
|
|
|
uint16_t *mnc, uint16_t *lac);
|
2010-08-28 09:46:36 +00:00
|
|
|
int gsm48_encode_lai(struct gsm48_loc_area_id *lai, uint16_t mcc,
|
|
|
|
uint16_t mnc, uint16_t lac);
|
2010-04-25 16:28:24 +00:00
|
|
|
int gsm48_rr_enc_cm2(struct osmocom_ms *ms, struct gsm48_classmark2 *cm);
|
2010-05-06 08:48:24 +00:00
|
|
|
int gsm48_rr_tx_rand_acc(struct osmocom_ms *ms, struct msgb *msg);
|
2010-06-12 16:16:54 +00:00
|
|
|
int gsm48_rr_los(struct osmocom_ms *ms);
|
2010-06-26 09:35:27 +00:00
|
|
|
int gsm48_rr_rach_conf(struct osmocom_ms *ms, uint32_t fn);
|
2010-06-16 17:17:29 +00:00
|
|
|
extern const char *gsm48_rr_state_names[];
|
2010-07-16 10:52:38 +00:00
|
|
|
int gsm48_rr_start_monitor(struct osmocom_ms *ms);
|
|
|
|
int gsm48_rr_stop_monitor(struct osmocom_ms *ms);
|
2010-09-27 18:53:03 +00:00
|
|
|
int gsm48_rr_alter_delay(struct osmocom_ms *ms);
|
2010-04-25 16:28:24 +00:00
|
|
|
|
|
|
|
#endif /* _GSM48_RR_H */
|