Commit 9e8bc938 authored by francescomani's avatar francescomani

new structure for UE timers and reworking of UE RRC timers

parent da5ce90d
...@@ -865,3 +865,44 @@ void nr_est_delay(int ofdm_symbol_size, const c16_t *ls_est, c16_t *ch_estimates ...@@ -865,3 +865,44 @@ void nr_est_delay(int ofdm_symbol_size, const c16_t *ls_est, c16_t *ch_estimates
delay->delay_max_val = max_val; delay->delay_max_val = max_val;
delay->est_delay = max_pos - sync_pos; delay->est_delay = max_pos - sync_pos;
} }
void nr_timer_start(NR_timer_t *timer)
{
timer->active = true;
timer->counter = 0;
}
void nr_timer_stop(NR_timer_t *timer)
{
timer->active = false;
timer->counter = 0;
}
bool is_nr_timer_active(NR_timer_t timer)
{
return timer.active;
}
bool nr_timer_tick(NR_timer_t *timer)
{
bool expired = false;
if (timer->active) {
timer->counter += timer->step;
expired = nr_timer_expired(*timer);
if (expired)
timer->active = false;
}
return expired;
}
bool nr_timer_expired(NR_timer_t timer)
{
return (timer.counter >= timer.target);
}
void nr_timer_setup(NR_timer_t *timer, const uint32_t target, const uint32_t step)
{
timer->target = target;
timer->step = step;
nr_timer_stop(timer);
}
...@@ -116,6 +116,49 @@ typedef struct { ...@@ -116,6 +116,49 @@ typedef struct {
int delay_max_val; int delay_max_val;
} delay_t; } delay_t;
typedef struct {
bool active;
uint32_t counter;
uint32_t target;
uint32_t step;
} NR_timer_t;
/**
* @brief To start a timer
* @param timer Timer to be started
*/
void nr_timer_start(NR_timer_t *timer);
/**
* @brief To stop a timer
* @param timer Timer to stopped
*/
void nr_timer_stop(NR_timer_t *timer);
/**
* @brief If active, it increases timer counter by an amout of units equal to step. It stops timer if expired
* @param timer Timer to be handled
* @return Indication if the timer is expired or not
*/
bool nr_timer_tick(NR_timer_t *timer);
/**
* @brief To setup a timer
* @param timer Timer to setup
* @param target Target value for timer (when reached, timer is considered expired)
* @param step Amount of units to add to timer counter every tick
*/
void nr_timer_setup(NR_timer_t *timer, const uint32_t target, const uint32_t step);
/**
* @brief To check if a timer is expired
* @param timer Timer to be checked
* @return Indication if the timer is expired or not
*/
bool nr_timer_expired(NR_timer_t timer);
/**
* @brief To check if a timer is active
* @param timer Timer to be checked
* @return Indication if the timer is active or not
*/
bool is_nr_timer_active(NR_timer_t timer);
extern const nr_bandentry_t nr_bandtable[]; extern const nr_bandentry_t nr_bandtable[];
static inline int get_num_dmrs(uint16_t dmrs_mask ) { static inline int get_num_dmrs(uint16_t dmrs_mask ) {
......
...@@ -621,7 +621,7 @@ static void nr_rrc_ue_generate_RRCSetupRequest(NR_UE_RRC_INST_t *rrc) ...@@ -621,7 +621,7 @@ static void nr_rrc_ue_generate_RRCSetupRequest(NR_UE_RRC_INST_t *rrc)
// start timer T300 // start timer T300
NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants; NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants;
tac->T300_active = true; nr_timer_start(&tac->T300);
/* convention: RNTI for SRB0 is zero, as it changes all the time */ /* convention: RNTI for SRB0 is zero, as it changes all the time */
nr_rlc_srb_recv_sdu(rrc->ue_id, 0, buf, len); nr_rlc_srb_recv_sdu(rrc->ue_id, 0, buf, len);
...@@ -766,13 +766,10 @@ void nr_rrc_cellgroup_configuration(rrcPerNB_t *rrcNB, NR_UE_RRC_INST_t *rrc, NR ...@@ -766,13 +766,10 @@ void nr_rrc_cellgroup_configuration(rrcPerNB_t *rrcNB, NR_UE_RRC_INST_t *rrc, NR
// with the release cause 'other' upon which the procedure ends // with the release cause 'other' upon which the procedure ends
// TODO // TODO
} }
if (tac->T310_active) { nr_timer_stop(&tac->T310);
tac->T310_active = false; int t304_value = nr_rrc_get_T304(reconfigurationWithSync->t304);
tac->T310_cnt = 0; nr_timer_setup(&tac->T304, t304_value, 10); // 10ms step
} nr_timer_start(&tac->T304);
nr_rrc_set_T304(&rrc->timers_and_constants, reconfigurationWithSync);
tac->T304_active = true;
tac->T304_cnt = 0;
rrc->rnti = reconfigurationWithSync->newUE_Identity; rrc->rnti = reconfigurationWithSync->newUE_Identity;
// resume suspended radio bearers // resume suspended radio bearers
for (int i = 0; i < NR_NUM_SRB; i++) { for (int i = 0; i < NR_NUM_SRB; i++) {
...@@ -877,16 +874,12 @@ static void nr_rrc_process_rrcsetup(NR_UE_RRC_INST_t *rrc, ...@@ -877,16 +874,12 @@ static void nr_rrc_process_rrcsetup(NR_UE_RRC_INST_t *rrc,
// TODO (not handled) if stored, discard the cell reselection priority information provided by // TODO (not handled) if stored, discard the cell reselection priority information provided by
// the cellReselectionPriorities or inherited from another RAT // the cellReselectionPriorities or inherited from another RAT
// stop timer T300, T301 or T319 if running; // stop timer T300, T301, T319, T320 if running;
NR_UE_Timers_Constants_t *timers = &rrc->timers_and_constants; NR_UE_Timers_Constants_t *timers = &rrc->timers_and_constants;
timers->T300_active = false; nr_timer_stop(&timers->T300);
timers->T300_cnt = 0; nr_timer_stop(&timers->T301);
timers->T301_active = false; nr_timer_stop(&timers->T319);
timers->T301_cnt = 0; nr_timer_stop(&timers->T320);
timers->T319_active = false;
timers->T319_cnt = 0;
timers->T320_active = false;
timers->T320_cnt = 0;
// TODO if T390 and T302 are running (not implemented) // TODO if T390 and T302 are running (not implemented)
...@@ -1389,10 +1382,9 @@ static int nr_rrc_ue_decode_dcch(NR_UE_RRC_INST_t *rrc, ...@@ -1389,10 +1382,9 @@ static int nr_rrc_ue_decode_dcch(NR_UE_RRC_INST_t *rrc,
void nr_rrc_handle_ra_indication(NR_UE_RRC_INST_t *rrc, bool ra_succeeded) void nr_rrc_handle_ra_indication(NR_UE_RRC_INST_t *rrc, bool ra_succeeded)
{ {
NR_UE_Timers_Constants_t *timers = &rrc->timers_and_constants; NR_UE_Timers_Constants_t *timers = &rrc->timers_and_constants;
if (ra_succeeded && timers->T304_active == true) { if (ra_succeeded && is_nr_timer_active(timers->T304)) {
// successful Random Access procedure triggered by reconfigurationWithSync // successful Random Access procedure triggered by reconfigurationWithSync
timers->T304_active = false; nr_timer_stop(&timers->T304);
timers->T304_cnt = 0;
// TODO handle the rest of procedures as described in 5.3.5.3 for when // TODO handle the rest of procedures as described in 5.3.5.3 for when
// reconfigurationWithSync is included in spCellConfig // reconfigurationWithSync is included in spCellConfig
} }
...@@ -1829,11 +1821,11 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc, ...@@ -1829,11 +1821,11 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc,
waitTime = rrcReleaseIEs->nonCriticalExtension ? waitTime = rrcReleaseIEs->nonCriticalExtension ?
rrcReleaseIEs->nonCriticalExtension->waitTime : NULL; rrcReleaseIEs->nonCriticalExtension->waitTime : NULL;
if (waitTime) { if (waitTime) {
if (tac->T302_active) nr_timer_stop(&tac->T302); // stop 302
tac->T302_cnt = 0; // stop 302
// start timer T302 with the value set to the waitTime // start timer T302 with the value set to the waitTime
tac->T302_active = true; int target = *waitTime * 1000; // waitTime is in seconds
tac->T302_k = *waitTime * 1000; // waitTime is in seconds nr_timer_setup(&tac->T302, target, 10);
nr_timer_start(&tac->T302);
// TODO inform upper layers that access barring is applicable // TODO inform upper layers that access barring is applicable
// for all access categories except categories '0' and '2'. // for all access categories except categories '0' and '2'.
LOG_E(NR_RRC,"Go to IDLE. Handling RRCRelease message including a waitTime not implemented\n"); LOG_E(NR_RRC,"Go to IDLE. Handling RRCRelease message including a waitTime not implemented\n");
...@@ -1841,17 +1833,15 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc, ...@@ -1841,17 +1833,15 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc,
} }
} }
if (!waitTime) { if (!waitTime) {
if (tac->T302_active) { if (is_nr_timer_active(tac->T302)) {
tac->T302_cnt = 0; nr_timer_stop(&tac->T302);
tac->T302_active = false;
// TODO barring alleviation as in 5.3.14.4 // TODO barring alleviation as in 5.3.14.4
// not implemented // not implemented
LOG_E(NR_RRC,"Go to IDLE. Barring alleviation not implemented\n"); LOG_E(NR_RRC,"Go to IDLE. Barring alleviation not implemented\n");
} }
} }
if (tac->T390_active) { if (is_nr_timer_active(tac->T390)) {
tac->T390_cnt = 0; nr_timer_stop(&tac->T390);
tac->T390_active = false;
// TODO barring alleviation as in 5.3.14.4 // TODO barring alleviation as in 5.3.14.4
// not implemented // not implemented
LOG_E(NR_RRC,"Go to IDLE. Barring alleviation not implemented\n"); LOG_E(NR_RRC,"Go to IDLE. Barring alleviation not implemented\n");
...@@ -1859,24 +1849,15 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc, ...@@ -1859,24 +1849,15 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc,
if (!RRCRelease && rrc->nrRrcState == RRC_STATE_INACTIVE_NR) { if (!RRCRelease && rrc->nrRrcState == RRC_STATE_INACTIVE_NR) {
// TODO discard the cell reselection priority information provided by the cellReselectionPriorities // TODO discard the cell reselection priority information provided by the cellReselectionPriorities
// cell reselection priorities not implemented yet // cell reselection priorities not implemented yet
if (tac->T320_active) { nr_timer_stop(&tac->T320);
tac->T320_cnt = 0;
tac->T320_active = false;
}
} }
// Stop all the timers except T302, T320 and T325 // Stop all the timers except T302, T320 and T325
tac->T300_active = false; nr_timer_stop(&tac->T300);
tac->T300_cnt = 0; nr_timer_stop(&tac->T301);
tac->T301_active = false; nr_timer_stop(&tac->T304);
tac->T301_cnt = 0; nr_timer_stop(&tac->T310);
tac->T304_active = false; nr_timer_stop(&tac->T311);
tac->T304_cnt = 0; nr_timer_stop(&tac->T319);
tac->T310_active = false;
tac->T310_cnt = 0;
tac->T311_active = false;
tac->T311_cnt = 0;
tac->T319_active = false;
tac->T319_cnt = 0;
// discard the UE Inactive AS context // discard the UE Inactive AS context
// TODO there is no inactive AS context // TODO there is no inactive AS context
......
...@@ -144,44 +144,23 @@ typedef struct UE_RRC_SI_INFO_NR_s { ...@@ -144,44 +144,23 @@ typedef struct UE_RRC_SI_INFO_NR_s {
} __attribute__ ((__packed__)) NR_UE_RRC_SI_INFO; } __attribute__ ((__packed__)) NR_UE_RRC_SI_INFO;
typedef struct NR_UE_Timers_Constants_s { typedef struct NR_UE_Timers_Constants_s {
// timers status
bool T300_active;
bool T301_active;
bool T302_active;
bool T304_active;
bool T310_active;
bool T311_active;
bool T319_active;
bool T320_active;
bool T325_active;
bool T390_active;
// timers // timers
uint32_t T300_cnt; NR_timer_t T300;
uint32_t T301_cnt; NR_timer_t T301;
uint32_t T302_cnt; NR_timer_t T302;
uint32_t T304_cnt; NR_timer_t T304;
uint32_t T310_cnt; NR_timer_t T310;
uint32_t T311_cnt; NR_timer_t T311;
uint32_t T319_cnt; NR_timer_t T319;
uint32_t T320_cnt; NR_timer_t T320;
uint32_t T325_cnt; NR_timer_t T325;
uint32_t T390_cnt; NR_timer_t T390;
// counters // counters
uint32_t N310_cnt; uint32_t N310_cnt;
uint32_t N311_cnt; uint32_t N311_cnt;
// constants (limits configured by the network) // constants (limits configured by the network)
uint32_t N310_k; uint32_t N310_k;
uint32_t N311_k; uint32_t N311_k;
uint32_t T300_k;
uint32_t T301_k;
uint32_t T302_k;
uint32_t T304_k;
uint32_t T310_k;
uint32_t T311_k;
uint32_t T319_k;
uint32_t T320_k;
uint32_t T325_k;
uint32_t T390_k;
} NR_UE_Timers_Constants_t; } NR_UE_Timers_Constants_t;
typedef enum { typedef enum {
......
...@@ -115,9 +115,8 @@ void handle_t300_expiry(NR_UE_RRC_INST_t *rrc); ...@@ -115,9 +115,8 @@ void handle_t300_expiry(NR_UE_RRC_INST_t *rrc);
void reset_rlf_timers_and_constants(NR_UE_Timers_Constants_t *tac); void reset_rlf_timers_and_constants(NR_UE_Timers_Constants_t *tac);
void set_default_timers_and_constants(NR_UE_Timers_Constants_t *tac); void set_default_timers_and_constants(NR_UE_Timers_Constants_t *tac);
void nr_rrc_set_sib1_timers_and_constants(NR_UE_Timers_Constants_t *tac, NR_SIB1_t *sib1); void nr_rrc_set_sib1_timers_and_constants(NR_UE_Timers_Constants_t *tac, NR_SIB1_t *sib1);
void nr_rrc_set_T304(NR_UE_Timers_Constants_t *tac, NR_ReconfigurationWithSync_t *reconfigurationWithSync); int nr_rrc_get_T304(long t304);
void handle_rlf_sync(NR_UE_Timers_Constants_t *tac, void handle_rlf_sync(NR_UE_Timers_Constants_t *tac, nr_sync_msg_t sync_msg);
nr_sync_msg_t sync_msg);
void nr_rrc_handle_SetupRelease_RLF_TimersAndConstants(NR_UE_RRC_INST_t *rrc, void nr_rrc_handle_SetupRelease_RLF_TimersAndConstants(NR_UE_RRC_INST_t *rrc,
struct NR_SetupRelease_RLF_TimersAndConstants *rlf_TimersAndConstants); struct NR_SetupRelease_RLF_TimersAndConstants *rlf_TimersAndConstants);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment