From 9b30c7f46e2c55aed06cea8d1daa9093f331fb20 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 17 Oct 2013 19:59:56 +0200 Subject: [PATCH] bts: Move the frame_number into the BTS sructure The current_frame is an attribute of the BTS. Move it from the pcu_l1_if.cpp into the BTS. As the next step we can trigger actions depending on the change of the frame. --- src/bts.cpp | 6 ++++++ src/bts.h | 10 ++++++++++ src/gsm_timer.cpp | 12 ++++++++++++ src/pcu_l1_if.cpp | 16 ++-------------- src/pcu_l1_if.h | 2 -- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/bts.cpp b/src/bts.cpp index 0609a5fe..b278ecfb 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -39,7 +39,13 @@ struct gprs_rlcmac_bts *bts_main_data() } BTS::BTS() + : m_cur_fn(0) { memset(&m_bts, 0, sizeof(m_bts)); m_bts.bts = this; } + +void BTS::set_current_frame_number(int fn) +{ + m_cur_fn = fn; +} diff --git a/src/bts.h b/src/bts.h index 9a5b570a..507c79fb 100644 --- a/src/bts.h +++ b/src/bts.h @@ -106,9 +106,19 @@ public: struct gprs_rlcmac_bts *bts_data(); + /** TODO: change the number to unsigned */ + void set_current_frame_number(int frame_number); + int current_frame_number() const; + private: + int m_cur_fn; struct gprs_rlcmac_bts m_bts; }; + +inline int BTS::current_frame_number() const +{ + return m_cur_fn; +} #endif #ifdef __cplusplus diff --git a/src/gsm_timer.cpp b/src/gsm_timer.cpp index 95513b47..d3c59cbc 100644 --- a/src/gsm_timer.cpp +++ b/src/gsm_timer.cpp @@ -33,9 +33,21 @@ static int *nearest_p; #include #include #include +#include + static struct rb_root timer_root = RB_ROOT; +/* + * TODO: make this depend on the BTS. This means that + * all time functions schedule based on the BTS they + * are scheduled on. + */ +static int get_current_fn() +{ + return BTS::main_bts()->current_frame_number(); +} + static void __add_gsm_timer(struct osmo_gsm_timer_list *timer) { struct rb_node **new_node = &(timer_root.rb_node); diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 82392473..ad0887ea 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -50,19 +50,6 @@ int l1if_pdch_req(void *obj, uint8_t ts, int is_ptcch, uint32_t fn, extern void *tall_pcu_ctx; -// Variable for storage current FN. -int frame_number; - -int get_current_fn() -{ - return frame_number; -} - -void set_current_fn(int fn) -{ - frame_number = fn; -} - /* * PCU messages */ @@ -512,6 +499,7 @@ static int pcu_rx_time_ind(struct gsm_pcu_if_time_ind *time_ind) struct gprs_rlcmac_sba *sba, *sba2; uint32_t elapsed; uint8_t fn13 = time_ind->fn % 13; + int frame_number = time_ind->fn; /* omit frame numbers not starting at a MAC block */ if (fn13 != 0 && fn13 != 4 && fn13 != 8) @@ -520,7 +508,7 @@ static int pcu_rx_time_ind(struct gsm_pcu_if_time_ind *time_ind) // LOGP(DL1IF, LOGL_DEBUG, "Time indication received: %d\n", // time_ind->fn % 52); - set_current_fn(time_ind->fn); + BTS::main_bts()->set_current_frame_number(time_ind->fn); /* check for poll timeout */ llist_for_each_entry(tbf, &gprs_rlcmac_ul_tbfs, list) { diff --git a/src/pcu_l1_if.h b/src/pcu_l1_if.h index f01b95ad..bd8fe940 100644 --- a/src/pcu_l1_if.h +++ b/src/pcu_l1_if.h @@ -32,8 +32,6 @@ extern "C" { #ifdef __cplusplus } -int get_current_fn(); - void pcu_l1if_tx_pdtch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn, uint32_t fn, uint8_t block_nr); void pcu_l1if_tx_ptcch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn,