From 8b265883e40edfb357a67cf021c54abf47eb037a Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 9 Apr 2020 12:43:55 +0200 Subject: [PATCH] SRSENB: UL TA measurement waits for a start order before start measuring --- srsenb/hdr/stack/mac/ta.h | 52 +++++++++++++++++++------------------ srsenb/hdr/stack/mac/ue.h | 7 +---- srsenb/src/stack/mac/mac.cc | 3 +++ 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/srsenb/hdr/stack/mac/ta.h b/srsenb/hdr/stack/mac/ta.h index 46fdd4c04..4fe9970ea 100644 --- a/srsenb/hdr/stack/mac/ta.h +++ b/srsenb/hdr/stack/mac/ta.h @@ -42,17 +42,18 @@ public: /** * UE's FSM for controlling Time Aligment command generation. * - * Initially the FSM starts at none state which automatically transitions to Measure. Measurements are collected while - * the FSM is in Measure state. Up to MAX_NOF_MEAS are stored. The FSM uses a minimum of MIN_NOF_MEAS measurements to - * compute the TA average. The TA command is triggered as soon as the TA average is higher than TA_N_THRESHOLD. After - * triggering a TA command, holds in prohibit state for PROHIBIT_PERIOD_MS before start collecting measurements. + * Initially the FSM starts at idle state which transitions to Measure as soon as start is called. Measurements are + * collected while the FSM is in Measure state. Up to MAX_NOF_MEAS are stored. The FSM uses a minimum of MIN_NOF_MEAS + * measurements to compute the TA average. The TA command is triggered as soon as the TA average is higher than + * TA_N_THRESHOLD. After triggering a TA command, holds in prohibit state for PROHIBIT_PERIOD_MS before start collecting + * measurements. * - * +------+ First call +---------+ Trigger +----------+ - * | None | ------------->| Measure |------------>| Prohibit | - * +------+ +---------+ +----------+ - * ^ ^ | - * | | Prohibit expires | - * --+ +------------------------+ + * +------+ Start +---------+ Trigger +----------+ + * | Idle | ------->| Measure |------------>| Prohibit | + * +------+ +---------+ +----------+ + * ^ ^ | + * | | Prohibit expires | + * --+ +------------------------+ * * */ @@ -82,11 +83,11 @@ private: // FSM states typedef enum { - state_none = 0, ///< NO state has been set yet + state_idle = 0, ///< Waits for start order state_measure, ///< Performing measurement state_prohibit ///< Waiting for HARQ to transmit CE command, NO measurement shall be stored } state_t; - state_t state = state_none; + state_t state = state_idle; /** * Reset Measurement and timer counter @@ -120,17 +121,6 @@ private: return static_cast(std::roundf(ta_us * 1e-6f / SRSLTE_LTE_TS / 16.0f)); } - /** - * Runs initial state none - * @return 0 - */ - uint32_t run_state_none() - { - reset_measurements(); - state = state_measure; - return 0; - } - /** * Runs measure state * @return the number of enqueued MAC CE carrying TA commands @@ -187,8 +177,9 @@ private: uint32_t run_fsm() { switch (state) { - case state_none: - return run_state_none(); + case state_idle: + // Waits for Start order, do nothing + return 0; case state_measure: return run_state_measure(); case state_prohibit: @@ -210,6 +201,17 @@ public: run_fsm(); } + /** + * Gives an start order to the FSM + */ + void start() + { + // Transition to idle only if the current state is idle + if (state == state_idle) { + state = state_measure; + } + } + /** * Pushes TA measurement and runs internal FSM * diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index 7074313bb..ab65d8a9c 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -59,15 +59,10 @@ public: uint32_t set_ta(int ta) override; + void start_ta() { ta_fsm.start(); }; uint32_t set_ta_us(float ta_us) { return ta_fsm.push_value(ta_us); }; uint32_t tick_ta_fsm() { return ta_fsm.tick(); }; - void config(uint16_t rnti, - uint32_t nof_prb, - sched_interface* sched, - rrc_interface_mac* rrc_, - rlc_interface_mac* rlc, - srslte::log* log_h); uint8_t* generate_pdu(uint32_t ue_cc_idx, uint32_t harq_pid, uint32_t tb_idx, diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 96ccf0e4c..8dc1cdcd8 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -202,6 +202,9 @@ int mac::ue_cfg(uint16_t rnti, sched_interface::ue_cfg_t* cfg) } ue_ptr = it->second.get(); + // Start TA FSM in UE entity + ue_ptr->start_ta(); + // Add RNTI to the PHY (pregenerate signals) now instead of after PRACH if (not ue_ptr->is_phy_added) { Info("Registering RNTI=0x%X to PHY...\n", rnti);