nr_timer: consistently pass by ref, rename to nr_timer_is_active()
Pass consistently the NR_timer_t object through a pointer. Since we have to modify all occurrences of is_nr_timer_active(), we use that occasion and rename that function to nr_timer_is_active() to make it consistent with all other functions, starting with nr_timer.
This commit is contained in:
@@ -1161,9 +1161,9 @@ void nr_timer_stop(NR_timer_t *timer)
|
||||
timer->counter = 0;
|
||||
}
|
||||
|
||||
bool is_nr_timer_active(NR_timer_t timer)
|
||||
bool nr_timer_is_active(const NR_timer_t *timer)
|
||||
{
|
||||
return timer.active;
|
||||
return timer->active;
|
||||
}
|
||||
|
||||
bool nr_timer_tick(NR_timer_t *timer)
|
||||
@@ -1173,23 +1173,23 @@ bool nr_timer_tick(NR_timer_t *timer)
|
||||
timer->counter += timer->step;
|
||||
if (timer->target == UINT_MAX) // infinite target, never expires
|
||||
return false;
|
||||
expired = nr_timer_expired(*timer);
|
||||
expired = nr_timer_expired(timer);
|
||||
if (expired)
|
||||
timer->active = false;
|
||||
}
|
||||
return expired;
|
||||
}
|
||||
|
||||
bool nr_timer_expired(NR_timer_t timer)
|
||||
bool nr_timer_expired(const NR_timer_t *timer)
|
||||
{
|
||||
if (timer.target == UINT_MAX) // infinite target, never expires
|
||||
if (timer->target == UINT_MAX) // infinite target, never expires
|
||||
return false;
|
||||
return (timer.counter >= timer.target);
|
||||
return timer->counter >= timer->target;
|
||||
}
|
||||
|
||||
uint32_t nr_timer_elapsed_time(NR_timer_t timer)
|
||||
uint32_t nr_timer_elapsed_time(const NR_timer_t *timer)
|
||||
{
|
||||
return timer.counter;
|
||||
return timer->counter;
|
||||
}
|
||||
|
||||
void nr_timer_setup(NR_timer_t *timer, const uint32_t target, const uint32_t step)
|
||||
|
||||
@@ -163,19 +163,19 @@ void nr_timer_setup(NR_timer_t *timer, const uint32_t target, const uint32_t ste
|
||||
* @param timer Timer to be checked
|
||||
* @return Indication if the timer is expired or not
|
||||
*/
|
||||
bool nr_timer_expired(NR_timer_t timer);
|
||||
bool nr_timer_expired(const 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);
|
||||
bool nr_timer_is_active(const NR_timer_t *timer);
|
||||
/**
|
||||
* @brief To return how much time has passed since start of timer
|
||||
* @param timer Timer to be checked
|
||||
* @return Time passed since start of timer
|
||||
*/
|
||||
uint32_t nr_timer_elapsed_time(NR_timer_t timer);
|
||||
uint32_t nr_timer_elapsed_time(const NR_timer_t *timer);
|
||||
|
||||
|
||||
extern const nr_bandentry_t nr_bandtable[];
|
||||
|
||||
@@ -29,13 +29,13 @@ TEST(nr_common, nr_timer) {
|
||||
NR_timer_t timer;
|
||||
nr_timer_setup(&timer, 10, 1);
|
||||
nr_timer_start(&timer);
|
||||
EXPECT_TRUE(is_nr_timer_active(timer));
|
||||
EXPECT_FALSE(nr_timer_expired(timer));
|
||||
EXPECT_TRUE(nr_timer_is_active(&timer));
|
||||
EXPECT_FALSE(nr_timer_expired(&timer));
|
||||
for (auto i = 0; i < 10; i++) {
|
||||
nr_timer_tick(&timer);
|
||||
}
|
||||
EXPECT_FALSE(is_nr_timer_active(timer));
|
||||
EXPECT_TRUE(nr_timer_expired(timer));
|
||||
EXPECT_FALSE(nr_timer_is_active(&timer));
|
||||
EXPECT_TRUE(nr_timer_expired(&timer));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -790,7 +790,7 @@ void nr_ue_get_rach(NR_UE_MAC_INST_t *mac, int CC_id, frame_t frame, uint8_t gNB
|
||||
}
|
||||
}
|
||||
|
||||
if (is_nr_timer_active(ra->contention_resolution_timer)) {
|
||||
if (nr_timer_is_active(&ra->contention_resolution_timer)) {
|
||||
nr_ue_contention_resolution(mac, CC_id, frame, nr_slot_tx, prach_resources);
|
||||
}
|
||||
}
|
||||
@@ -851,7 +851,7 @@ void nr_ue_contention_resolution(NR_UE_MAC_INST_t *mac, int cc_id, frame_t frame
|
||||
{
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
if (nr_timer_expired(ra->contention_resolution_timer)) {
|
||||
if (nr_timer_expired(&ra->contention_resolution_timer)) {
|
||||
ra->t_crnti = 0;
|
||||
nr_timer_stop(&ra->contention_resolution_timer);
|
||||
// Signal PHY to quit RA procedure
|
||||
|
||||
@@ -2543,7 +2543,7 @@ int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frame, slot_t slot, NR_Schedu
|
||||
sr_id); // todo
|
||||
|
||||
// TODO check if the PUCCH resource for the SR transmission occasion does not overlap with a UL-SCH resource
|
||||
if (!sr_info->pending || is_nr_timer_active(sr_info->prohibitTimer))
|
||||
if (!sr_info->pending || nr_timer_is_active(&sr_info->prohibitTimer))
|
||||
return 0;
|
||||
|
||||
if (sr_info->counter < sr_info->maxTransmissions) {
|
||||
|
||||
@@ -1297,7 +1297,7 @@ static void nr_update_sr(NR_UE_MAC_INST_t *mac)
|
||||
|
||||
// if a Regular BSR has been triggered and logicalChannelSR-DelayTimer is not running
|
||||
if (((sched_info->BSR_reporting_active & NR_BSR_TRIGGER_REGULAR) == 0)
|
||||
|| is_nr_timer_active(sched_info->sr_DelayTimer))
|
||||
|| nr_timer_is_active(&sched_info->sr_DelayTimer))
|
||||
return;
|
||||
|
||||
nr_lcordered_info_t *lc_info = get_lc_info_from_lcid(mac, sched_info->regularBSR_trigger_lcid);
|
||||
@@ -1527,7 +1527,7 @@ void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info)
|
||||
NR_LC_SCHEDULING_INFO *sched_info = get_scheduling_info_from_lcid(mac, lcid);
|
||||
int32_t bj = sched_info->Bj;
|
||||
if (lc_info->pbr < UINT_MAX) {
|
||||
uint32_t slots_elapsed = nr_timer_elapsed_time(sched_info->Bj_timer); // slots elapsed since Bj was last incremented
|
||||
uint32_t slots_elapsed = nr_timer_elapsed_time(&sched_info->Bj_timer); // slots elapsed since Bj was last incremented
|
||||
// it is safe to divide by 1k since pbr in lc_info is computed multiplying by 1000 the RRC value to convert kB/s to B/s
|
||||
uint32_t pbr_ms = lc_info->pbr / 1000;
|
||||
bj += ((pbr_ms * slots_elapsed) >> mac->current_UL_BWP->scs); // each slot length is 1/scs ms
|
||||
|
||||
@@ -479,7 +479,7 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc,
|
||||
|
||||
// Actions following cell selection while T311 is running
|
||||
NR_UE_Timers_Constants_t *timers = &rrc->timers_and_constants;
|
||||
if (is_nr_timer_active(timers->T311)) {
|
||||
if (nr_timer_is_active(&timers->T311)) {
|
||||
nr_timer_stop(&timers->T311);
|
||||
rrc->ra_trigger = RRC_CONNECTION_REESTABLISHMENT;
|
||||
|
||||
@@ -1695,7 +1695,7 @@ 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)
|
||||
{
|
||||
NR_UE_Timers_Constants_t *timers = &rrc->timers_and_constants;
|
||||
if (ra_succeeded && is_nr_timer_active(timers->T304)) {
|
||||
if (ra_succeeded && nr_timer_is_active(&timers->T304)) {
|
||||
// successful Random Access procedure triggered by reconfigurationWithSync
|
||||
nr_timer_stop(&timers->T304);
|
||||
// TODO handle the rest of procedures as described in 5.3.5.3 for when
|
||||
@@ -2218,14 +2218,14 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc,
|
||||
}
|
||||
}
|
||||
if (!waitTime) {
|
||||
if (is_nr_timer_active(tac->T302)) {
|
||||
if (nr_timer_is_active(&tac->T302)) {
|
||||
nr_timer_stop(&tac->T302);
|
||||
// TODO barring alleviation as in 5.3.14.4
|
||||
// not implemented
|
||||
LOG_E(NR_RRC,"Go to IDLE. Barring alleviation not implemented\n");
|
||||
}
|
||||
}
|
||||
if (is_nr_timer_active(tac->T390)) {
|
||||
if (nr_timer_is_active(&tac->T390)) {
|
||||
nr_timer_stop(&tac->T390);
|
||||
// TODO barring alleviation as in 5.3.14.4
|
||||
// not implemented
|
||||
|
||||
@@ -560,7 +560,7 @@ void handle_rlf_sync(NR_UE_Timers_Constants_t *tac,
|
||||
{
|
||||
if (sync_msg == IN_SYNC) {
|
||||
tac->N310_cnt = 0;
|
||||
if (is_nr_timer_active(tac->T310)) {
|
||||
if (nr_timer_is_active(&tac->T310)) {
|
||||
tac->N311_cnt++;
|
||||
// Upon receiving N311 consecutive "in-sync" indications
|
||||
if (tac->N311_cnt >= tac->N311_k) {
|
||||
@@ -573,12 +573,12 @@ void handle_rlf_sync(NR_UE_Timers_Constants_t *tac,
|
||||
else {
|
||||
// OUT_OF_SYNC
|
||||
tac->N311_cnt = 0;
|
||||
if(is_nr_timer_active(tac->T300) ||
|
||||
is_nr_timer_active(tac->T301) ||
|
||||
is_nr_timer_active(tac->T304) ||
|
||||
is_nr_timer_active(tac->T310) ||
|
||||
is_nr_timer_active(tac->T311) ||
|
||||
is_nr_timer_active(tac->T319))
|
||||
if(nr_timer_is_active(&tac->T300) ||
|
||||
nr_timer_is_active(&tac->T301) ||
|
||||
nr_timer_is_active(&tac->T304) ||
|
||||
nr_timer_is_active(&tac->T310) ||
|
||||
nr_timer_is_active(&tac->T311) ||
|
||||
nr_timer_is_active(&tac->T319))
|
||||
return;
|
||||
tac->N310_cnt++;
|
||||
// upon receiving N310 consecutive "out-of-sync" indications
|
||||
|
||||
Reference in New Issue
Block a user