diff options
Diffstat (limited to 'src/tbf.h')
-rw-r--r-- | src/tbf.h | 78 |
1 files changed, 20 insertions, 58 deletions
@@ -10,10 +10,6 @@ * 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 @@ -24,6 +20,7 @@ #include "llc.h" #include "rlc.h" +#include "rlc_window.h" #include "cxx_linuxlist.h" #include "pcu_utils.h" #include <gprs_debug.h> @@ -31,6 +28,7 @@ struct bssgp_bvc_ctx; struct gprs_rlcmac_bts; +struct alloc_resources_req; #endif @@ -112,11 +110,7 @@ enum tbf_counters { /* TBF counters from 3GPP TS 44.060 ยง13.4 */ #define GPRS_RLCMAC_FLAG_CCCH 0 /* assignment on CCCH */ #define GPRS_RLCMAC_FLAG_PACCH 1 /* assignment on PACCH */ -#define GPRS_RLCMAC_FLAG_DL_ACK 2 /* DL TBF: At least one DL ACK/NACK was recieved since it was assigned */ -#define GPRS_RLCMAC_FLAG_TO_DL_ACK 3 /* DL TBF: Failed to receive last polled DL ACK/NACK */ -#define GPRS_RLCMAC_FLAG_TO_MASK 0xf0 /* timeout bits */ - -#define TBF_CONTROL_TS_UNSET 0xff +#define TBF_TFI_UNSET 0xff #define T_START(tbf, t, T, r, f) tbf->t_start(t, T, r, f, __FILE__, __LINE__) @@ -128,6 +122,7 @@ const char *tbf_name(const struct gprs_rlcmac_tbf *tbf); enum tbf_fsm_states tbf_state(const struct gprs_rlcmac_tbf *tbf); struct osmo_fsm_inst *tbf_ul_ass_fi(const struct gprs_rlcmac_tbf *tbf); struct osmo_fsm_inst *tbf_dl_ass_fi(const struct gprs_rlcmac_tbf *tbf); +struct osmo_fsm_inst *tbf_state_fi(const struct gprs_rlcmac_tbf *tbf); enum gprs_rlcmac_tbf_direction tbf_direction(const struct gprs_rlcmac_tbf *tbf); void tbf_set_ms(struct gprs_rlcmac_tbf *tbf, struct GprsMs *ms); struct llist_head *tbf_ms_list(struct gprs_rlcmac_tbf *tbf); @@ -136,21 +131,24 @@ struct GprsMs *tbf_ms(const struct gprs_rlcmac_tbf *tbf); bool tbf_timers_pending(struct gprs_rlcmac_tbf *tbf, enum tbf_timers t); void tbf_free(struct gprs_rlcmac_tbf *tbf); struct gprs_llc *tbf_llc(struct gprs_rlcmac_tbf *tbf); -uint8_t tbf_first_common_ts(const struct gprs_rlcmac_tbf *tbf); uint8_t tbf_dl_slots(const struct gprs_rlcmac_tbf *tbf); uint8_t tbf_ul_slots(const struct gprs_rlcmac_tbf *tbf); bool tbf_is_tfi_assigned(const struct gprs_rlcmac_tbf *tbf); uint8_t tbf_tfi(const struct gprs_rlcmac_tbf *tbf); bool tbf_is_egprs_enabled(const struct gprs_rlcmac_tbf *tbf); void tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf); -int tbf_check_polling(const struct gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t ts, uint32_t *poll_fn, unsigned int *rrbp); -void tbf_set_polling(struct gprs_rlcmac_tbf *tbf, uint32_t new_poll_fn, uint8_t ts, enum pdch_ulc_tbf_poll_reason t); +int tbf_check_polling(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch, uint32_t fn, uint32_t *poll_fn, unsigned int *rrbp); +void tbf_set_polling(struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch, uint32_t new_poll_fn, enum pdch_ulc_tbf_poll_reason t); void tbf_poll_timeout(struct gprs_rlcmac_tbf *tbf, struct gprs_rlcmac_pdch *pdch, uint32_t poll_fn, enum pdch_ulc_tbf_poll_reason reason); void tbf_update_state_fsm_name(struct gprs_rlcmac_tbf *tbf); const char* tbf_rlcmac_diag(const struct gprs_rlcmac_tbf *tbf); -bool tbf_is_control_ts(const struct gprs_rlcmac_tbf *tbf, uint8_t ts); +bool tbf_is_control_ts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch); bool tbf_can_upgrade_to_multislot(const struct gprs_rlcmac_tbf *tbf); -int tbf_update(struct gprs_rlcmac_tbf *tbf); +struct gprs_rlcmac_pdch *tbf_get_first_ts(struct gprs_rlcmac_tbf *tbf); +const struct gprs_rlcmac_pdch *tbf_get_first_ts_const(const struct gprs_rlcmac_tbf *tbf); +struct gprs_rlcmac_trx *tbf_get_trx(struct gprs_rlcmac_tbf *tbf); +void tbf_unlink_pdch(struct gprs_rlcmac_tbf *tbf); +void tbf_stop_timers(struct gprs_rlcmac_tbf *tbf, const char *reason); #ifdef __cplusplus } #endif @@ -162,18 +160,17 @@ struct gprs_rlcmac_tbf { virtual ~gprs_rlcmac_tbf(); virtual gprs_rlc_window *window() = 0; + virtual void apply_allocated_resources(const struct alloc_resources_res *res) = 0; - int setup(int8_t use_trx, bool single_slot); bool state_is(enum tbf_fsm_states rhs) const; bool state_is_not(enum tbf_fsm_states rhs) const; bool dl_ass_state_is(enum tbf_dl_ass_fsm_states rhs) const; bool ul_ass_state_is(enum tbf_ul_ass_fsm_states rhs) const; void poll_sched_set(const char *file, int line); void poll_sched_unset(const char *file, int line); - bool check_n_clear(uint8_t state_flag); const char *state_name() const; - const char *name() const; + const char *name(bool enclousure = true) const; struct msgb *create_dl_ass(uint32_t fn, uint8_t ts); @@ -183,29 +180,19 @@ struct gprs_rlcmac_tbf { bool n_inc(enum tbf_counters n); void n_reset(enum tbf_counters n); - int update(); void handle_timeout(); void stop_timers(const char *reason); bool timers_pending(enum tbf_timers t); void t_stop(enum tbf_timers t, const char *reason); void t_start(enum tbf_timers t, int T, const char *reason, bool force, const char *file, unsigned line); - int establish_dl_tbf_on_pacch(); - - int check_polling(uint32_t fn, uint8_t ts, - uint32_t *poll_fn, unsigned int *rrbp) const; - void set_polling(uint32_t poll_fn, uint8_t ts, enum pdch_ulc_tbf_poll_reason reason); void poll_timeout(struct gprs_rlcmac_pdch *pdch, uint32_t poll_fn, enum pdch_ulc_tbf_poll_reason reason); /** tlli handling */ uint32_t tlli() const; bool is_tlli_valid() const; - /** MS updating */ - void update_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction); - uint8_t tfi() const; - bool is_tfi_assigned() const; const char *imsi() const; uint8_t ta() const; @@ -217,8 +204,6 @@ struct gprs_rlcmac_tbf { uint8_t dl_slots() const; uint8_t ul_slots() const; - bool is_control_ts(uint8_t ts) const; - /* EGPRS */ bool is_egprs_enabled() const; @@ -227,10 +212,7 @@ struct gprs_rlcmac_tbf { enum gprs_rlcmac_tbf_direction direction; struct gprs_rlcmac_trx *trx; - uint8_t first_ts; /* first TS used by TBF */ - uint8_t first_common_ts; /* first TS where the phone can send and - receive simultaniously */ - uint8_t control_ts; /* timeslot control messages and polling */ + struct gprs_rlcmac_pdch *control_ts; /* timeslot control messages and polling */ struct gprs_rlcmac_pdch *pdch[8]; /* list of PDCHs allocated to TBF */ gprs_llc m_llc; @@ -261,26 +243,26 @@ struct gprs_rlcmac_tbf { time_t m_created_ts; struct rate_ctr_group *m_ctrs; - struct tbf_fsm_ctx state_fsm; + struct osmo_fsm_inst *state_fi; struct tbf_ul_ass_fsm_ctx ul_ass_fsm; - struct tbf_ul_ass_fsm_ctx dl_ass_fsm; + struct tbf_dl_ass_fsm_ctx dl_ass_fsm; struct llist_item m_ms_list; struct llist_item m_trx_list; protected: void merge_and_clear_ms(GprsMs *old_ms); + void enable_egprs(void); gprs_llc_queue *llc_queue(); const gprs_llc_queue *llc_queue() const; struct GprsMs *m_ms; private: - void enable_egprs(); bool m_egprs_enabled; struct osmo_timer_list Tarr[T_MAX]; uint8_t Narr[N_MAX]; - mutable char m_name_buf[60]; + mutable char m_name_buf[128]; }; inline bool gprs_rlcmac_tbf::state_is(enum tbf_fsm_states rhs) const @@ -306,17 +288,7 @@ inline bool gprs_rlcmac_tbf::state_is_not(enum tbf_fsm_states rhs) const inline const char *gprs_rlcmac_tbf::state_name() const { - return osmo_fsm_inst_state_name(state_fsm.fi); -} - -inline bool gprs_rlcmac_tbf::check_n_clear(uint8_t state_flag) -{ - if ((state_fsm.state_flags & (1 << state_flag))) { - state_fsm.state_flags &= ~(1 << state_flag); - return true; - } - - return false; + return osmo_fsm_inst_state_name(state_fi); } inline GprsMs *gprs_rlcmac_tbf::ms() const @@ -329,16 +301,6 @@ inline bool gprs_rlcmac_tbf::is_tlli_valid() const return tlli() != GSM_RESERVED_TMSI; } -inline bool gprs_rlcmac_tbf::is_tfi_assigned() const -{ - /* The TBF is established or has been assigned by a IMM.ASS for - * download */ - return state_fsm.fi->state > TBF_ST_ASSIGN || - (direction == GPRS_RLCMAC_DL_TBF && - state_fsm.fi->state == TBF_ST_ASSIGN && - (state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))); -} - inline uint8_t gprs_rlcmac_tbf::tfi() const { return m_tfi; |