Commit d4cdda31 authored by Florian Kaltenberger's avatar Florian Kaltenberger

Final changes for UE context management

parent fdb81c23
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "PHY/CODING/extern.h" #include "PHY/CODING/extern.h"
#include "PHY/CODING/lte_interleaver_inline.h" #include "PHY/CODING/lte_interleaver_inline.h"
#include "PHY/LTE_TRANSPORT/defs.h" #include "PHY/LTE_TRANSPORT/defs.h"
#include "PHY/LTE_TRANSPORT/proto.h"
#include "defs.h" #include "defs.h"
#include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/LOG/vcd_signal_dumper.h"
...@@ -91,11 +92,11 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) ...@@ -91,11 +92,11 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch)
#endif #endif
for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) { for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) {
#ifdef DEBUG_DLSCH_FREE #ifdef DEBUG_DLSCH_FREE
msg("Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]); msg("Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]);
#endif #endif
if (dlsch->harq_processes[i]->c[r]) { if (dlsch->harq_processes[i]->c[r]) {
free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768); free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768);
dlsch->harq_processes[i]->c[r] = NULL; dlsch->harq_processes[i]->c[r] = NULL;
...@@ -104,17 +105,17 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) ...@@ -104,17 +105,17 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch)
free16(dlsch->harq_processes[i]->d[r],(96+12+3+(3*6144))); free16(dlsch->harq_processes[i]->d[r],(96+12+3+(3*6144)));
dlsch->harq_processes[i]->d[r] = NULL; dlsch->harq_processes[i]->d[r] = NULL;
} }
}
}
free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t)); free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t));
dlsch->harq_processes[i] = NULL; dlsch->harq_processes[i] = NULL;
} }
} }
free16(dlsch,sizeof(LTE_eNB_DLSCH_t)); free16(dlsch,sizeof(LTE_eNB_DLSCH_t));
dlsch = NULL; dlsch = NULL;
} }
} }
LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_t Nsoft,unsigned char N_RB_DL, uint8_t abstraction_flag) LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_t Nsoft,unsigned char N_RB_DL, uint8_t abstraction_flag)
...@@ -204,28 +205,28 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_ ...@@ -204,28 +205,28 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_
for (i=0; i<Mdlharq; i++) { for (i=0; i<Mdlharq; i++) {
dlsch->harq_processes[i]->round=0; dlsch->harq_processes[i]->round=0;
if (abstraction_flag==0) { for (j=0; j<96; j++)
for (j=0; j<96; j++) for (r=0; r<MAX_NUM_DLSCH_SEGMENTS/bw_scaling; r++) {
for (r=0; r<MAX_NUM_DLSCH_SEGMENTS/bw_scaling; r++) { // printf("dlsch->harq_processes[%d]->d[%d] %p\n",i,r,dlsch->harq_processes[i]->d[r]);
// printf("dlsch->harq_processes[%d]->d[%d] %p\n",i,r,dlsch->harq_processes[i]->d[r]); if (dlsch->harq_processes[i]->d[r])
dlsch->harq_processes[i]->d[r][j] = LTE_NULL; dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
} }
}
} }
return(dlsch); return(dlsch);
} }
} }
LOG_D(PHY, "new_eNB_dlsch exit flag %d, size of %ld\n", LOG_D(PHY,"new_eNB_dlsch exit flag %d, size of %ld\n",
exit_flag, sizeof(LTE_eNB_DLSCH_t)); exit_flag, sizeof(LTE_eNB_DLSCH_t));
free_eNB_dlsch(dlsch); free_eNB_dlsch(dlsch);
return(NULL); return(NULL);
} }
void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch, uint8_t abstraction_flag) void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch)
{ {
unsigned char Mdlharq; unsigned char Mdlharq;
...@@ -245,12 +246,11 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch, uint8_t abstraction_flag) ...@@ -245,12 +246,11 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch, uint8_t abstraction_flag)
dlsch->harq_processes[i]->status = 0; dlsch->harq_processes[i]->status = 0;
dlsch->harq_processes[i]->round = 0; dlsch->harq_processes[i]->round = 0;
if (abstraction_flag==0) { for (j=0; j<96; j++)
for (j=0; j<96; j++) for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++)
for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) if (dlsch->harq_processes[i]->d[r])
if (dlsch->harq_processes[i]->d[r]) dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
dlsch->harq_processes[i]->d[r][j] = LTE_NULL;
}
} }
} }
} }
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
*/ */
void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch); void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch);
void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch, uint8_t abstraction_flag); void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch);
/** \fn new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag) /** \fn new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag)
\brief This function allocates structures for a particular DLSCH at eNB \brief This function allocates structures for a particular DLSCH at eNB
...@@ -85,7 +85,7 @@ void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch); ...@@ -85,7 +85,7 @@ void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch);
LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag); LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag);
void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch, uint8_t abstraction_flag); void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch);
void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch); void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch);
......
...@@ -179,7 +179,7 @@ LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t Mdlharq,uint8_t max_turbo_iterations,uint ...@@ -179,7 +179,7 @@ LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t Mdlharq,uint8_t max_turbo_iterations,uint
return(NULL); return(NULL);
} }
void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch, uint8_t abstraction_flag) void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch)
{ {
unsigned char Mdlharq; unsigned char Mdlharq;
......
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
#define AMP_OVER_2 (AMP>>1) #define AMP_OVER_2 (AMP>>1)
/// Threshold for PUCCH Format 1 detection /// Threshold for PUCCH Format 1 detection
#define PUCCH1_THRES 10 #define PUCCH1_THRES 7
/// Threshold for PUCCH Format 1a/1b detection /// Threshold for PUCCH Format 1a/1b detection
#define PUCCH1a_THRES 4 #define PUCCH1a_THRES 4
......
...@@ -405,7 +405,7 @@ void remove_harq_pid_from_freelist(LTE_eNB_DLSCH_t *DLSCH_ptr, int harq_pid); ...@@ -405,7 +405,7 @@ void remove_harq_pid_from_freelist(LTE_eNB_DLSCH_t *DLSCH_ptr, int harq_pid);
int8_t find_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB); int8_t find_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB);
int32_t add_ue(int16_t rnti, PHY_VARS_eNB *phy_vars_eNB); int32_t add_ue(int16_t rnti, PHY_VARS_eNB *phy_vars_eNB);
int32_t remove_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB,uint8_t abstraction_flag); int mac_phy_remove_ue(module_id_t Mod_idP,rnti_t rnti);
void process_timing_advance(module_id_t Mod_id,uint8_t CC_id,int16_t timing_advance); void process_timing_advance(module_id_t Mod_id,uint8_t CC_id,int16_t timing_advance);
void process_timing_advance_rar(PHY_VARS_UE *phy_vars_ue,uint16_t timing_advance); void process_timing_advance_rar(PHY_VARS_UE *phy_vars_ue,uint16_t timing_advance);
......
...@@ -198,41 +198,43 @@ int32_t add_ue(int16_t rnti, PHY_VARS_eNB *phy_vars_eNB) ...@@ -198,41 +198,43 @@ int32_t add_ue(int16_t rnti, PHY_VARS_eNB *phy_vars_eNB)
return(-1); return(-1);
} }
int32_t remove_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB, uint8_t abstraction_flag) int mac_phy_remove_ue(module_id_t Mod_idP,rnti_t rntiP) {
{
uint8_t i; uint8_t i;
int j; int j,CC_id;
PHY_VARS_eNB *phy_vars_eNB;
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
if ((phy_vars_eNB->dlsch_eNB[i]==NULL) || (phy_vars_eNB->ulsch_eNB[i]==NULL)) { for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
MSC_LOG_EVENT(MSC_PHY_ENB, "0 Failed remove ue %"PRIx16" (ENOMEM)", rnti); phy_vars_eNB = PHY_vars_eNB_g[Mod_idP][CC_id];
LOG_E(PHY,"Can't remove UE, not enough memory allocated\n"); for (i=0; i<NUMBER_OF_UE_MAX; i++) {
return(-1); if ((phy_vars_eNB->dlsch_eNB[i]==NULL) || (phy_vars_eNB->ulsch_eNB[i]==NULL)) {
} else { MSC_LOG_EVENT(MSC_PHY_ENB, "0 Failed remove ue %"PRIx16" (ENOMEM)", rnti);
if (phy_vars_eNB->eNB_UE_stats[i].crnti==rnti) { LOG_E(PHY,"Can't remove UE, not enough memory allocated\n");
MSC_LOG_EVENT(MSC_PHY_ENB, "0 Removed ue %"PRIx16" ", rnti); return(-1);
} else {
if (phy_vars_eNB->eNB_UE_stats[i].crnti==rntiP) {
MSC_LOG_EVENT(MSC_PHY_ENB, "0 Removed ue %"PRIx16" ", rntiP);
#ifdef DEBUG_PHY_PROC #ifdef DEBUG_PHY_PROC
LOG_I(PHY,"eNB %d removing UE %d with rnti %x\n",phy_vars_eNB->Mod_id,i,rnti); LOG_I(PHY,"eNB %d removing UE %d with rnti %x\n",phy_vars_eNB->Mod_id,i,rnti);
#endif #endif
//msg("[PHY] UE_id %d\n",i); //msg("[PHY] UE_id %d\n",i);
clean_eNb_dlsch(phy_vars_eNB->dlsch_eNB[i][0], abstraction_flag); clean_eNb_dlsch(phy_vars_eNB->dlsch_eNB[i][0]);
clean_eNb_ulsch(phy_vars_eNB->ulsch_eNB[i],abstraction_flag); clean_eNb_ulsch(phy_vars_eNB->ulsch_eNB[i]);
//phy_vars_eNB->eNB_UE_stats[i].crnti = 0; //phy_vars_eNB->eNB_UE_stats[i].crnti = 0;
memset(&phy_vars_eNB->eNB_UE_stats[i],0,sizeof(LTE_eNB_UE_stats)); memset(&phy_vars_eNB->eNB_UE_stats[i],0,sizeof(LTE_eNB_UE_stats));
// mac_exit_wrapper("Removing UE"); // mac_exit_wrapper("Removing UE");
/* clear the harq pid freelist */ /* clear the harq pid freelist */
phy_vars_eNB->dlsch_eNB[i][0]->head_freelist = 0; phy_vars_eNB->dlsch_eNB[i][0]->head_freelist = 0;
phy_vars_eNB->dlsch_eNB[i][0]->tail_freelist = 0; phy_vars_eNB->dlsch_eNB[i][0]->tail_freelist = 0;
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
put_harq_pid_in_freelist(phy_vars_eNB->dlsch_eNB[i][0], j); put_harq_pid_in_freelist(phy_vars_eNB->dlsch_eNB[i][0], j);
return(i); return(i);
}
} }
} }
} }
MSC_LOG_EVENT(MSC_PHY_ENB, "0 Failed remove ue %"PRIx16" (not found)", rntiP);
MSC_LOG_EVENT(MSC_PHY_ENB, "0 Failed remove ue %"PRIx16" (not found)", rnti);
return(-1); return(-1);
} }
...@@ -3523,7 +3525,7 @@ void phy_procedures_eNB_RX(const unsigned char sched_subframe,PHY_VARS_eNB *phy_ ...@@ -3523,7 +3525,7 @@ void phy_procedures_eNB_RX(const unsigned char sched_subframe,PHY_VARS_eNB *phy_
frame, frame,
phy_vars_eNB->eNB_UE_stats[i].crnti); phy_vars_eNB->eNB_UE_stats[i].crnti);
#endif #endif
remove_ue(phy_vars_eNB->eNB_UE_stats[i].crnti,phy_vars_eNB,abstraction_flag); mac_phy_remove_ue(phy_vars_eNB->Mod_id,phy_vars_eNB->eNB_UE_stats[i].crnti);
phy_vars_eNB->ulsch_eNB[(uint32_t)i]->Msg3_active = 0; phy_vars_eNB->ulsch_eNB[(uint32_t)i]->Msg3_active = 0;
//phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->phich_active = 0; //phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->phich_active = 0;
...@@ -3670,7 +3672,7 @@ void phy_procedures_eNB_RX(const unsigned char sched_subframe,PHY_VARS_eNB *phy_ ...@@ -3670,7 +3672,7 @@ void phy_procedures_eNB_RX(const unsigned char sched_subframe,PHY_VARS_eNB *phy_
phy_vars_eNB->CC_id, phy_vars_eNB->CC_id,
frame, frame,
phy_vars_eNB->eNB_UE_stats[i].crnti); phy_vars_eNB->eNB_UE_stats[i].crnti);
remove_ue(phy_vars_eNB->eNB_UE_stats[i].crnti,phy_vars_eNB,abstraction_flag); mac_phy_remove_ue(phy_vars_eNB->Mod_id,phy_vars_eNB->eNB_UE_stats[i].crnti);
phy_vars_eNB->ulsch_eNB[(uint32_t)i]->Msg3_active = 0; phy_vars_eNB->ulsch_eNB[(uint32_t)i]->Msg3_active = 0;
} }
......
...@@ -127,9 +127,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, ...@@ -127,9 +127,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
// increment this, it is cleared when we receive an sdu // increment this, it is cleared when we receive an sdu
eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].ul_inactivity_timer++; eNB_mac_inst[module_idP].UE_list.UE_sched_ctrl[i].ul_inactivity_timer++;
if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) { if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) {
mac_remove_ue(module_idP, i, frameP, subframeP); // mac_remove_ue(module_idP, i, frameP, subframeP);
} }
else { else {
// check uplink failure // check uplink failure
...@@ -210,7 +210,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, ...@@ -210,7 +210,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
0); 0);
} }
else { // ra_pdcch_sent==1 else { // ra_pdcch_sent==1
LOG_I(MAC,"UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer); LOG_D(MAC,"UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n",i,rnti,UE_list->UE_sched_ctrl[i].ul_failure_timer);
if ((UE_list->UE_sched_ctrl[i].ul_failure_timer % 40) == 0) if ((UE_list->UE_sched_ctrl[i].ul_failure_timer % 40) == 0)
UE_list->UE_sched_ctrl[i].ra_pdcch_order_sent=0; // resend every 4 frames UE_list->UE_sched_ctrl[i].ra_pdcch_order_sent=0; // resend every 4 frames
} }
......
...@@ -287,44 +287,38 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) ...@@ -287,44 +287,38 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP)
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP, sub_frame_t subframeP) int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ {
int prev,i, ret=-1; int prev,i, ret=-1;
rnti_t rnti;
UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list; UE_list_t *UE_list = &eNB_mac_inst[mod_idP].UE_list;
int pCC_id = UE_PCCID(mod_idP,ue_idP); int UE_id = find_UE_id(mod_idP,rntiP);
int pCC_id = UE_PCCID(mod_idP,UE_id);
rnti = UE_list->UE_template[pCC_id][ue_idP].rnti; LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP);
LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",ue_idP,pCC_id, rnti);
dump_ue_list(UE_list,0); dump_ue_list(UE_list,0);
// clear all remaining pending transmissions // clear all remaining pending transmissions
UE_list->UE_template[pCC_id][ue_idP].bsr_info[LCGID0] = 0; UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID0] = 0;
UE_list->UE_template[pCC_id][ue_idP].bsr_info[LCGID1] = 0; UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID1] = 0;
UE_list->UE_template[pCC_id][ue_idP].bsr_info[LCGID2] = 0; UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID2] = 0;
UE_list->UE_template[pCC_id][ue_idP].bsr_info[LCGID3] = 0; UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID3] = 0;
UE_list->UE_template[pCC_id][ue_idP].ul_SR = 0; UE_list->UE_template[pCC_id][UE_id].ul_SR = 0;
UE_list->UE_template[pCC_id][ue_idP].rnti = NOT_A_RNTI; UE_list->UE_template[pCC_id][UE_id].rnti = NOT_A_RNTI;
UE_list->UE_template[pCC_id][ue_idP].ul_active = FALSE; UE_list->UE_template[pCC_id][UE_id].ul_active = FALSE;
eNB_ulsch_info[mod_idP][pCC_id][ue_idP].rnti = NOT_A_RNTI; eNB_ulsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_ulsch_info[mod_idP][pCC_id][ue_idP].status = S_UL_NONE; eNB_ulsch_info[mod_idP][pCC_id][UE_id].status = S_UL_NONE;
eNB_dlsch_info[mod_idP][pCC_id][ue_idP].rnti = NOT_A_RNTI; eNB_dlsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_dlsch_info[mod_idP][pCC_id][ue_idP].status = S_DL_NONE; eNB_dlsch_info[mod_idP][pCC_id][UE_id].status = S_DL_NONE;
rrc_eNB_free_UE(
mod_idP,
rnti,
frameP,
subframeP);
prev = UE_list->head; prev = UE_list->head;
for (i=UE_list->head; i>=0; i=UE_list->next[i]) { for (i=UE_list->head; i>=0; i=UE_list->next[i]) {
if (i == ue_idP) { if (i == UE_id) {
// link prev to next in Active list // link prev to next in Active list
//if (prev==UE_list->head) //if (prev==UE_list->head)
if (i==UE_list->head) { if (i==UE_list->head) {
...@@ -349,7 +343,7 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP, sub_frame_t subfr ...@@ -349,7 +343,7 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP, sub_frame_t subfr
prev = UE_list->head_ul; prev = UE_list->head_ul;
for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) { for (i=UE_list->head_ul; i>=0; i=UE_list->next_ul[i]) {
if (i == ue_idP) { if (i == UE_id) {
// link prev to next in Active list // link prev to next in Active list
if (prev==UE_list->head_ul) { if (prev==UE_list->head_ul) {
UE_list->head_ul = UE_list->next_ul[i]; UE_list->head_ul = UE_list->next_ul[i];
...@@ -366,11 +360,13 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP, sub_frame_t subfr ...@@ -366,11 +360,13 @@ int mac_remove_ue(module_id_t mod_idP, int ue_idP, int frameP, sub_frame_t subfr
prev=i; prev=i;
} }
mac_phy_remove_ue(mod_idP,rntiP);
if (ret == 0) { if (ret == 0) {
return (0); return (0);
} }
LOG_E(MAC,"error in mac_remove_ue(), could not find previous to %d in UE_list, should never happen, Dumping UE list\n",ue_idP); LOG_E(MAC,"error in mac_remove_ue(), could not find previous to %d in UE_list, should never happen, Dumping UE list\n",UE_id);
dump_ue_list(UE_list,0); dump_ue_list(UE_list,0);
mac_xface->macphy_exit("mac_remove_ue: Problem in UE_list"); mac_xface->macphy_exit("mac_remove_ue: Problem in UE_list");
return(-1); return(-1);
......
...@@ -476,6 +476,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer,ui ...@@ -476,6 +476,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer,ui
mac_xface->Msg1_transmitted = Msg1_tx; mac_xface->Msg1_transmitted = Msg1_tx;
mac_xface->ra_failed = ra_failed; mac_xface->ra_failed = ra_failed;
mac_xface->ra_succeeded = ra_succeeded; mac_xface->ra_succeeded = ra_succeeded;
mac_xface->mac_phy_remove_ue = mac_phy_remove_ue;
LOG_I(MAC,"[MAIN] init UE MAC functions \n"); LOG_I(MAC,"[MAIN] init UE MAC functions \n");
mac_xface->ue_decode_si = ue_decode_si; mac_xface->ue_decode_si = ue_decode_si;
......
...@@ -499,7 +499,7 @@ uint8_t *parse_ulsch_header(uint8_t *mac_header, ...@@ -499,7 +499,7 @@ uint8_t *parse_ulsch_header(uint8_t *mac_header,
int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active);
int mac_init(void); int mac_init(void);
int add_new_ue(module_id_t Mod_id, int CC_id, rnti_t rnti,int harq_pid); int add_new_ue(module_id_t Mod_id, int CC_id, rnti_t rnti,int harq_pid);
int mac_remove_ue(module_id_t Mod_id, int UE_id,int frameP, sub_frame_t subframeP); int rrc_mac_remove_ue(module_id_t Mod_id, rnti_t rntiP);
int maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uint8_t ul_flag); int maxround(module_id_t Mod_id,uint16_t rnti,int frame,sub_frame_t subframe,uint8_t ul_flag);
......
...@@ -134,7 +134,7 @@ typedef struct { ...@@ -134,7 +134,7 @@ typedef struct {
/// get delta mcs for fast UL AMC /// get delta mcs for fast UL AMC
int16_t (*estimate_ue_tx_power)(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs); int16_t (*estimate_ue_tx_power)(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs);
int (*mac_phy_remove_ue)(module_id_t Mod_idP,rnti_t rntiP);
/// UE functions /// UE functions
/// reset the ue phy /// reset the ue phy
......
...@@ -716,19 +716,47 @@ mac_eNB_get_rrc_status( ...@@ -716,19 +716,47 @@ mac_eNB_get_rrc_status(
} }
void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP,
const int CC_id, const int CC_idP,
const frame_t frameP, const frame_t frameP,
const sub_frame_t subframeP, const sub_frame_t subframeP,
const rnti_t rnti) { const rnti_t rntiP) {
return; struct rrc_eNB_ue_context_s* ue_context_p = NULL;
ue_context_p = rrc_eNB_get_ue_context(
&eNB_rrc_inst[Mod_instP],
rntiP);
if (ue_context_p != NULL) {
LOG_I(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",rntiP);
ue_context_p->ue_context.ul_failure_timer=1;
}
else {
LOG_W(RRC,"Frame %d, Subframe %d: UE %x unknown \n",frameP,subframeP,rntiP);
rrc_mac_remove_ue(Mod_instP,rntiP);
}
} }
void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP,
const int CC_id, const int CC_idP,
const frame_t frameP, const frame_t frameP,
const sub_frame_t subframeP, const sub_frame_t subframeP,
const rnti_t rnti) { const rnti_t rntiP) {
struct rrc_eNB_ue_context_s* ue_context_p = NULL;
ue_context_p = rrc_eNB_get_ue_context(
&eNB_rrc_inst[Mod_instP],
rntiP);
if (ue_context_p != NULL) {
LOG_I(RRC,"Frame %d, Subframe %d: UE %x to UL in synch\n",rntiP);
ue_context_p->ue_context.ul_failure_timer=0;
}
else {
LOG_E(RRC,"Frame %d, Subframe %d: UE %x unknown \n",rntiP);
}
return; return;
} }
......
...@@ -357,6 +357,7 @@ typedef struct eNB_RRC_UE_s { ...@@ -357,6 +357,7 @@ typedef struct eNB_RRC_UE_s {
transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB]; transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB];
rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB]; rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB];
#endif #endif
uint32_t ul_failure_timer;
} eNB_RRC_UE_t; } eNB_RRC_UE_t;
typedef uid_t ue_uid_t; typedef uid_t ue_uid_t;
......
...@@ -439,10 +439,8 @@ rrc_eNB_free_mem_UE_context( ...@@ -439,10 +439,8 @@ rrc_eNB_free_mem_UE_context(
void void
rrc_eNB_free_UE( rrc_eNB_free_UE(
const module_id_t enb_mod_idP, const module_id_t enb_mod_idP,
const rnti_t rntiP, const struct rrc_eNB_ue_context_s* const ue_context_pP
const frame_t frameP,
const sub_frame_t subframeP
); );
long binary_search_int(int elements[], long numElem, int value); long binary_search_int(int elements[], long numElem, int value);
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "asn1_msg.h" #include "asn1_msg.h"
#include "pdcp.h" #include "pdcp.h"
#include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/LOG/vcd_signal_dumper.h"
#include "rrc_eNB_UE_context.h"
#ifdef LOCALIZATION #ifdef LOCALIZATION
#include <sys/time.h> #include <sys/time.h>
...@@ -414,9 +415,10 @@ rrc_rx_tx( ...@@ -414,9 +415,10 @@ rrc_rx_tx(
uint8_t UE_id; uint8_t UE_id;
int32_t current_timestamp_ms, ref_timestamp_ms; int32_t current_timestamp_ms, ref_timestamp_ms;
struct timeval ts; struct timeval ts;
struct rrc_eNB_ue_context_s *ue_context_p = NULL,*ue_to_be_removed = NULL;
#ifdef LOCALIZATION #ifdef LOCALIZATION
double estimated_distance; double estimated_distance;
struct rrc_eNB_ue_context_s* ue_context_p = NULL;
protocol_ctxt_t ctxt; protocol_ctxt_t ctxt;
#endif #endif
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN);
...@@ -517,6 +519,21 @@ rrc_rx_tx( ...@@ -517,6 +519,21 @@ rrc_rx_tx(
} else { // eNB } else { // eNB
check_handovers(ctxt_pP); check_handovers(ctxt_pP);
// counetr, and get the value and aggregate // counetr, and get the value and aggregate
// check for UL failure
RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head)) {
if (ue_context_p->ue_context.ul_failure_timer>0) {
ue_context_p->ue_context.ul_failure_timer++;
if (ue_context_p->ue_context.ul_failure_timer >= 20000) {
// remove UE after 20 seconds after MAC has indicated UL failure
LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti);
ue_to_be_removed = ue_context_p;
break;
}
}
}
if (ue_to_be_removed)
rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed);
#ifdef LOCALIZATION #ifdef LOCALIZATION
/* for the localization, only primary CC_id might be relevant*/ /* for the localization, only primary CC_id might be relevant*/
......
...@@ -790,35 +790,32 @@ rrc_eNB_free_mem_UE_context( ...@@ -790,35 +790,32 @@ rrc_eNB_free_mem_UE_context(
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// called by MAC layer only
// should be called when UE is lost by eNB // should be called when UE is lost by eNB
void void
rrc_eNB_free_UE( rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* const ue_context_pP)
const module_id_t enb_mod_idP,
const rnti_t rntiP,
const frame_t frameP,
const sub_frame_t subframeP
)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
struct rrc_eNB_ue_context_s* ue_context_p = NULL;
protocol_ctxt_t ctxt; protocol_ctxt_t ctxt;
#if !defined(ENABLE_USE_MME) #if !defined(ENABLE_USE_MME)
module_id_t ue_module_id; module_id_t ue_module_id;
#endif #endif
AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rntiP); rnti_t rnti = ue_context_pP->ue_context.rnti;
ue_context_p = rrc_eNB_get_ue_context(
AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rnti);
/* ue_context_p = rrc_eNB_get_ue_context(
&eNB_rrc_inst[enb_mod_idP], &eNB_rrc_inst[enb_mod_idP],
rntiP rntiP
); );
*/
if (NULL != ue_context_p) { if (NULL != ue_context_pP) {
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rntiP, frameP, subframeP,enb_mod_idP); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0,enb_mod_idP);
LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", enb_mod_idP, rntiP); LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", enb_mod_idP, rnti);