Commit 232d4680 authored by francescomani's avatar francescomani Committed by Laurent THOMAS

apply structure to sib timers

parent ae8b0d54
......@@ -315,10 +315,12 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file)
rrc->dl_bwp_id = 0;
rrc->ul_bwp_id = 0;
rrc->as_security_activated = false;
memset(&rrc->timers_and_constants, 0, sizeof(rrc->timers_and_constants));
for (int i = 0; i < NB_CNX_UE; i++) {
rrcPerNB_t *ptr = &rrc->perNB[i];
ptr->SInfo = (NR_UE_RRC_SI_INFO){0};
init_SI_timers(&ptr->SInfo);
for (int j = 0; j < NR_NUM_SRB; j++)
ptr->Srb[j] = RB_NOT_PRESENT;
for (int j = 0; j < MAX_DRBS_PER_UE; j++)
......@@ -345,57 +347,70 @@ bool check_si_validity(NR_UE_RRC_SI_INFO *SI_info, int si_type)
{
switch (si_type) {
case NR_SIB_TypeInfo__type_sibType2:
if (!SI_info->sib2 || SI_info->sib2_timer == -1)
if (!SI_info->sib2 || nr_timer_expired(SI_info->sib2_timer)) {
nr_timer_stop(&SI_info->sib2_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType3:
if (!SI_info->sib3 || SI_info->sib3_timer == -1)
if (!SI_info->sib3 || nr_timer_expired(SI_info->sib3_timer)) {
nr_timer_stop(&SI_info->sib3_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType4:
if (!SI_info->sib4 || SI_info->sib4_timer == -1)
if (!SI_info->sib4 || nr_timer_expired(SI_info->sib4_timer)) {
nr_timer_stop(&SI_info->sib4_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType5:
if (!SI_info->sib5 || SI_info->sib5_timer == -1)
if (!SI_info->sib5 || nr_timer_expired(SI_info->sib5_timer)) {
nr_timer_stop(&SI_info->sib5_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType6:
if (!SI_info->sib6 || SI_info->sib6_timer == -1)
if (!SI_info->sib6 || nr_timer_expired(SI_info->sib6_timer)) {
nr_timer_stop(&SI_info->sib6_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType7:
if (!SI_info->sib7 || SI_info->sib7_timer == -1)
if (!SI_info->sib7 || nr_timer_expired(SI_info->sib7_timer)) {
nr_timer_stop(&SI_info->sib7_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType8:
if (!SI_info->sib8 || SI_info->sib8_timer == -1)
if (!SI_info->sib8 || nr_timer_expired(SI_info->sib8_timer)) {
nr_timer_stop(&SI_info->sib8_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType9:
if (!SI_info->sib9 || SI_info->sib9_timer == -1)
if (!SI_info->sib9 || nr_timer_expired(SI_info->sib9_timer)) {
nr_timer_stop(&SI_info->sib9_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType10_v1610:
if (!SI_info->sib10 || SI_info->sib10_timer == -1)
if (!SI_info->sib10 || nr_timer_expired(SI_info->sib10_timer)) {
nr_timer_stop(&SI_info->sib10_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType11_v1610:
if (!SI_info->sib11 || SI_info->sib11_timer == -1)
if (!SI_info->sib11 || nr_timer_expired(SI_info->sib11_timer)) {
nr_timer_stop(&SI_info->sib11_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType12_v1610:
if (!SI_info->sib12 || SI_info->sib12_timer == -1)
if (!SI_info->sib12 || nr_timer_expired(SI_info->sib12_timer)) {
nr_timer_stop(&SI_info->sib12_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType13_v1610:
if (!SI_info->sib13 || SI_info->sib13_timer == -1)
if (!SI_info->sib13 || nr_timer_expired(SI_info->sib13_timer)) {
nr_timer_stop(&SI_info->sib13_timer);
return false;
break;
}
case NR_SIB_TypeInfo__type_sibType14_v1610:
if (!SI_info->sib14 || SI_info->sib14_timer == -1)
if (!SI_info->sib14 || nr_timer_expired(SI_info->sib14_timer)) {
nr_timer_stop(&SI_info->sib14_timer);
return false;
break;
}
default :
AssertFatal(false, "Invalid SIB type %d\n", si_type);
}
......@@ -406,8 +421,10 @@ int check_si_status(NR_UE_RRC_SI_INFO *SI_info)
{
// schedule reception of SIB1 if RRC doesn't have it
// or if the timer expired
if (!SI_info->sib1 || SI_info->sib1_timer == -1)
if (!SI_info->sib1 || nr_timer_expired(SI_info->sib1_timer)) {
nr_timer_stop(&SI_info->sib1_timer);
return 1;
}
else {
if (SI_info->sib1->si_SchedulingInfo) {
// Check if RRC has configured default SI
......@@ -478,91 +495,91 @@ static int nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si)
if(!SI_info->sib2)
SI_info->sib2 = calloc(1, sizeof(*SI_info->sib2));
memcpy(SI_info->sib2, typeandinfo->choice.sib2, sizeof(NR_SIB2_t));
SI_info->sib2_timer = 0;
nr_timer_start(&SI_info->sib2_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib3:
if(!SI_info->sib3)
SI_info->sib3 = calloc(1, sizeof(*SI_info->sib3));
memcpy(SI_info->sib3, typeandinfo->choice.sib3, sizeof(NR_SIB3_t));
SI_info->sib3_timer = 0;
nr_timer_start(&SI_info->sib3_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib4:
if(!SI_info->sib4)
SI_info->sib4 = calloc(1, sizeof(*SI_info->sib4));
memcpy(SI_info->sib4, typeandinfo->choice.sib4, sizeof(NR_SIB4_t));
SI_info->sib4_timer = 0;
nr_timer_start(&SI_info->sib4_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib5:
if(!SI_info->sib5)
SI_info->sib5 = calloc(1, sizeof(*SI_info->sib5));
memcpy(SI_info->sib5, typeandinfo->choice.sib5, sizeof(NR_SIB5_t));
SI_info->sib5_timer = 0;
nr_timer_start(&SI_info->sib5_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib6:
if(!SI_info->sib6)
SI_info->sib6 = calloc(1, sizeof(*SI_info->sib6));
memcpy(SI_info->sib6, typeandinfo->choice.sib6, sizeof(NR_SIB6_t));
SI_info->sib6_timer = 0;
nr_timer_start(&SI_info->sib6_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib7:
if(!SI_info->sib7)
SI_info->sib7 = calloc(1, sizeof(*SI_info->sib7));
memcpy(SI_info->sib7, typeandinfo->choice.sib7, sizeof(NR_SIB7_t));
SI_info->sib7_timer = 0;
nr_timer_start(&SI_info->sib7_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib8:
if(!SI_info->sib8)
SI_info->sib8 = calloc(1, sizeof(*SI_info->sib8));
memcpy(SI_info->sib8, typeandinfo->choice.sib8, sizeof(NR_SIB8_t));
SI_info->sib8_timer = 0;
nr_timer_start(&SI_info->sib8_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib9:
if(!SI_info->sib9)
SI_info->sib9 = calloc(1, sizeof(*SI_info->sib9));
memcpy(SI_info->sib9, typeandinfo->choice.sib9, sizeof(NR_SIB9_t));
SI_info->sib9_timer = 0;
nr_timer_start(&SI_info->sib9_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib10_v1610:
if(!SI_info->sib10)
SI_info->sib10 = calloc(1, sizeof(*SI_info->sib10));
memcpy(SI_info->sib10, typeandinfo->choice.sib10_v1610, sizeof(NR_SIB10_r16_t));
SI_info->sib10_timer = 0;
nr_timer_start(&SI_info->sib10_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib11_v1610:
if(!SI_info->sib11)
SI_info->sib11 = calloc(1, sizeof(*SI_info->sib11));
memcpy(SI_info->sib11, typeandinfo->choice.sib11_v1610, sizeof(NR_SIB11_r16_t));
SI_info->sib11_timer = 0;
nr_timer_start(&SI_info->sib11_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib12_v1610:
if(!SI_info->sib12)
SI_info->sib12 = calloc(1, sizeof(*SI_info->sib12));
memcpy(SI_info->sib12, typeandinfo->choice.sib12_v1610, sizeof(NR_SIB12_r16_t));
SI_info->sib12_timer = 0;
nr_timer_start(&SI_info->sib12_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib13_v1610:
if(!SI_info->sib13)
SI_info->sib13 = calloc(1, sizeof(*SI_info->sib13));
memcpy(SI_info->sib13, typeandinfo->choice.sib13_v1610, sizeof(NR_SIB13_r16_t));
SI_info->sib13_timer = 0;
nr_timer_start(&SI_info->sib13_timer);
break;
case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib14_v1610:
if(!SI_info->sib14)
SI_info->sib14 = calloc(1, sizeof(*SI_info->sib14));
memcpy(SI_info->sib12, typeandinfo->choice.sib14_v1610, sizeof(NR_SIB14_r16_t));
SI_info->sib14_timer = 0;
nr_timer_start(&SI_info->sib14_timer);
break;
default:
break;
......@@ -698,7 +715,7 @@ static int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(instance_t instance,
if(g_log->log_component[NR_RRC].level >= OAILOG_DEBUG)
xer_fprint(stdout, &asn_DEF_NR_SIB1, (const void *) SI_info->sib1);
LOG_A(NR_RRC, "SIB1 decoded\n");
SI_info->sib1_timer = 0;
nr_timer_start(&SI_info->sib1_timer);
// FIXME: improve condition for the RA trigger
if (rrc->nrRrcState == RRC_STATE_IDLE_NR) {
LOG_D(PHY,"Setting state to RRC_STATE_IDLE_NR\n");
......@@ -1936,6 +1953,7 @@ void nr_rrc_going_to_IDLE(instance_t instance,
for (int i = 0; i < NB_CNX_UE; i++) {
rrcPerNB_t *nb = &rrc->perNB[i];
NR_UE_RRC_SI_INFO *SI_info = &nb->SInfo;
init_SI_timers(SI_info);
asn1cFreeStruc(asn_DEF_NR_SIB1, SI_info->sib1);
asn1cFreeStruc(asn_DEF_NR_SIB2, SI_info->sib2);
asn1cFreeStruc(asn_DEF_NR_SIB3, SI_info->sib3);
......
......@@ -115,34 +115,34 @@ typedef enum RA_trigger_e {
typedef struct UE_RRC_SI_INFO_NR_s {
uint32_t default_otherSI_map;
NR_SIB1_t *sib1;
int sib1_timer;
NR_timer_t sib1_timer;
NR_SIB2_t *sib2;
int sib2_timer;
NR_timer_t sib2_timer;
NR_SIB3_t *sib3;
int sib3_timer;
NR_timer_t sib3_timer;
NR_SIB4_t *sib4;
int sib4_timer;
NR_timer_t sib4_timer;
NR_SIB5_t *sib5;
int sib5_timer;
NR_timer_t sib5_timer;
NR_SIB6_t *sib6;
int sib6_timer;
NR_timer_t sib6_timer;
NR_SIB7_t *sib7;
int sib7_timer;
NR_timer_t sib7_timer;
NR_SIB8_t *sib8;
int sib8_timer;
NR_timer_t sib8_timer;
NR_SIB9_t *sib9;
int sib9_timer;
NR_timer_t sib9_timer;
NR_SIB10_r16_t *sib10;
int sib10_timer;
NR_timer_t sib10_timer;
NR_SIB11_r16_t *sib11;
int sib11_timer;
NR_timer_t sib11_timer;
NR_SIB12_r16_t *sib12;
int sib12_timer;
NR_timer_t sib12_timer;
NR_SIB13_r16_t *sib13;
int sib13_timer;
NR_timer_t sib13_timer;
NR_SIB14_r16_t *sib14;
int sib14_timer;
} __attribute__ ((__packed__)) NR_UE_RRC_SI_INFO;
NR_timer_t sib14_timer;
} NR_UE_RRC_SI_INFO;
typedef struct NR_UE_Timers_Constants_s {
// timers
......
......@@ -120,6 +120,7 @@ extern void start_oai_nrue_threads(void);
int get_from_lte_ue_fd();
void nr_rrc_SI_timers(NR_UE_RRC_SI_INFO *SInfo);
void init_SI_timers(NR_UE_RRC_SI_INFO *SInfo);
void nr_ue_rrc_timer_trigger(int module_id, int frame, int gnb_id);
void handle_t300_expiry(instance_t instance);
......
......@@ -21,81 +21,70 @@
#include "openair2/RRC/NR_UE/rrc_proto.h"
void nr_rrc_SI_timers(NR_UE_RRC_SI_INFO *SInfo)
void init_SI_timers(NR_UE_RRC_SI_INFO *SInfo)
{
// delete any stored version of a SIB after 3 hours
// from the moment it was successfully confirmed as valid
if (SInfo->sib1 && SInfo->sib1_timer >= 0) {
SInfo->sib1_timer += 10;
if (SInfo->sib1_timer > 10800000)
SInfo->sib1_timer = -1;
}
if (SInfo->sib2 && SInfo->sib2_timer >= 0) {
SInfo->sib2_timer += 10;
if (SInfo->sib2_timer > 10800000)
SInfo->sib2_timer = -1;
}
if (SInfo->sib3 && SInfo->sib3_timer >= 0) {
SInfo->sib3_timer += 10;
if (SInfo->sib3_timer > 10800000)
SInfo->sib3_timer = -1;
}
if (SInfo->sib4 && SInfo->sib4_timer >= 0) {
SInfo->sib4_timer += 10;
if (SInfo->sib4_timer > 10800000)
SInfo->sib4_timer = -1;
}
if (SInfo->sib5 && SInfo->sib5_timer >= 0) {
SInfo->sib5_timer += 10;
if (SInfo->sib5_timer > 10800000)
SInfo->sib5_timer = -1;
}
if (SInfo->sib6 && SInfo->sib6_timer >= 0) {
SInfo->sib6_timer += 10;
if (SInfo->sib6_timer > 10800000)
SInfo->sib6_timer = -1;
}
if (SInfo->sib7 && SInfo->sib7_timer >= 0) {
SInfo->sib7_timer += 10;
if (SInfo->sib7_timer > 10800000)
SInfo->sib7_timer = -1;
}
if (SInfo->sib8 && SInfo->sib8_timer >= 0) {
SInfo->sib8_timer += 10;
if (SInfo->sib8_timer > 10800000)
SInfo->sib8_timer = -1;
}
if (SInfo->sib9 && SInfo->sib9_timer >= 0) {
SInfo->sib9_timer += 10;
if (SInfo->sib9_timer > 10800000)
SInfo->sib9_timer = -1;
SInfo->sib1_timer.active = false;
nr_timer_setup(&SInfo->sib1_timer, 10800000, 10);
SInfo->sib2_timer.active = false;
nr_timer_setup(&SInfo->sib2_timer, 10800000, 10);
SInfo->sib3_timer.active = false;
nr_timer_setup(&SInfo->sib3_timer, 10800000, 10);
SInfo->sib4_timer.active = false;
nr_timer_setup(&SInfo->sib4_timer, 10800000, 10);
SInfo->sib5_timer.active = false;
nr_timer_setup(&SInfo->sib5_timer, 10800000, 10);
SInfo->sib6_timer.active = false;
nr_timer_setup(&SInfo->sib6_timer, 10800000, 10);
SInfo->sib7_timer.active = false;
nr_timer_setup(&SInfo->sib7_timer, 10800000, 10);
SInfo->sib8_timer.active = false;
nr_timer_setup(&SInfo->sib8_timer, 10800000, 10);
SInfo->sib9_timer.active = false;
nr_timer_setup(&SInfo->sib9_timer, 10800000, 10);
SInfo->sib10_timer.active = false;
nr_timer_setup(&SInfo->sib10_timer, 10800000, 10);
SInfo->sib11_timer.active = false;
nr_timer_setup(&SInfo->sib11_timer, 10800000, 10);
SInfo->sib12_timer.active = false;
nr_timer_setup(&SInfo->sib12_timer, 10800000, 10);
SInfo->sib13_timer.active = false;
nr_timer_setup(&SInfo->sib13_timer, 10800000, 10);
SInfo->sib14_timer.active = false;
nr_timer_setup(&SInfo->sib14_timer, 10800000, 10);
}
}
if (SInfo->sib10 && SInfo->sib10_timer >= 0) {
SInfo->sib10_timer += 10;
if (SInfo->sib10_timer > 10800000)
SInfo->sib10_timer = -1;
}
if (SInfo->sib11 && SInfo->sib11_timer >= 0) {
SInfo->sib11_timer += 10;
if (SInfo->sib11_timer > 10800000)
SInfo->sib11_timer = -1;
}
if (SInfo->sib12 && SInfo->sib12_timer >= 0) {
SInfo->sib12_timer += 10;
if (SInfo->sib12_timer > 10800000)
SInfo->sib12_timer = -1;
}
if (SInfo->sib13 && SInfo->sib13_timer >= 0) {
SInfo->sib13_timer += 10;
if (SInfo->sib13_timer > 10800000)
SInfo->sib13_timer = -1;
}
if (SInfo->sib14 && SInfo->sib14_timer >= 0) {
SInfo->sib14_timer += 10;
if (SInfo->sib14_timer > 10800000)
SInfo->sib14_timer = -1;
}
void nr_rrc_SI_timers(NR_UE_RRC_SI_INFO *SInfo)
{
if (SInfo->sib1 && SInfo->sib1_timer.active)
nr_timer_tick(&SInfo->sib1_timer);
if (SInfo->sib2 && SInfo->sib2_timer.active)
nr_timer_tick(&SInfo->sib2_timer);
if (SInfo->sib3 && SInfo->sib3_timer.active)
nr_timer_tick(&SInfo->sib3_timer);
if (SInfo->sib4 && SInfo->sib4_timer.active)
nr_timer_tick(&SInfo->sib4_timer);
if (SInfo->sib5 && SInfo->sib5_timer.active)
nr_timer_tick(&SInfo->sib5_timer);
if (SInfo->sib6 && SInfo->sib6_timer.active)
nr_timer_tick(&SInfo->sib6_timer);
if (SInfo->sib7 && SInfo->sib7_timer.active)
nr_timer_tick(&SInfo->sib7_timer);
if (SInfo->sib8 && SInfo->sib8_timer.active)
nr_timer_tick(&SInfo->sib8_timer);
if (SInfo->sib9 && SInfo->sib9_timer.active)
nr_timer_tick(&SInfo->sib9_timer);
if (SInfo->sib10 && SInfo->sib10_timer.active)
nr_timer_tick(&SInfo->sib10_timer);
if (SInfo->sib11 && SInfo->sib11_timer.active)
nr_timer_tick(&SInfo->sib11_timer);
if (SInfo->sib12 && SInfo->sib12_timer.active)
nr_timer_tick(&SInfo->sib12_timer);
if (SInfo->sib13 && SInfo->sib13_timer.active)
nr_timer_tick(&SInfo->sib13_timer);
if (SInfo->sib14 && SInfo->sib14_timer.active)
nr_timer_tick(&SInfo->sib14_timer);
}
void nr_rrc_handle_timers(NR_UE_RRC_INST_t *rrc, instance_t instance)
......
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