Commit 2b4e5290 authored by Robert Schmidt's avatar Robert Schmidt

Simplify add_ue_list(), remove_ue_list(); add init_ue_list()

parent a74f4c12
...@@ -2131,33 +2131,36 @@ dump_ue_list(UE_list_t *listP) { ...@@ -2131,33 +2131,36 @@ dump_ue_list(UE_list_t *listP) {
* Add a UE to UE_list listP * Add a UE to UE_list listP
*/ */
inline void add_ue_list(UE_list_t *listP, int UE_id) { inline void add_ue_list(UE_list_t *listP, int UE_id) {
if (listP->head == -1) { int *cur = &listP->head;
listP->head = UE_id; while (*cur >= 0)
listP->next[UE_id] = -1; cur = &listP->next[*cur];
} else { *cur = UE_id;
int i = listP->head;
while (listP->next[i] >= 0)
i = listP->next[i];
listP->next[i] = UE_id;
listP->next[UE_id] = -1;
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/* /*
* Remove a UE from the UE_list listP, return the previous element * Remove a UE from the UE_list listP
*/ */
inline int remove_ue_list(UE_list_t *listP, int UE_id) { inline int remove_ue_list(UE_list_t *listP, int UE_id) {
listP->next[UE_id] = -1; int *cur = &listP->head;
if (listP->head == UE_id) { while (*cur != -1 && *cur != UE_id)
listP->head = listP->next[UE_id]; cur = &listP->next[*cur];
return -1; if (*cur == -1)
} return 0;
int *next = &listP->next[*cur];
*cur = listP->next[*cur];
*next = -1;
return 1;
}
int previous = prev(listP, UE_id); //------------------------------------------------------------------------------
if (previous != -1) /*
listP->next[previous] = listP->next[UE_id]; * Initialize the UE_list listP
return previous; */
inline void init_ue_list(UE_list_t *listP) {
listP->head = -1;
for (int i = 0; i < MAX_MOBILES_PER_ENB; ++i)
listP->next[i] = -1;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -659,6 +659,7 @@ int prev(UE_list_t *listP, int nodeP); ...@@ -659,6 +659,7 @@ int prev(UE_list_t *listP, int nodeP);
void add_ue_list(UE_list_t *listP, int UE_id); void add_ue_list(UE_list_t *listP, int UE_id);
int remove_ue_list(UE_list_t *listP, int UE_id); int remove_ue_list(UE_list_t *listP, int UE_id);
void dump_ue_list(UE_list_t *listP); void dump_ue_list(UE_list_t *listP);
void init_ue_list(UE_list_t *listP);
int UE_num_active_CC(UE_info_t *listP, int ue_idP); int UE_num_active_CC(UE_info_t *listP, int ue_idP);
int UE_PCCID(module_id_t mod_idP, int ue_idP); int UE_PCCID(module_id_t mod_idP, int ue_idP);
rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP); rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP);
......
...@@ -45,11 +45,8 @@ extern RAN_CONTEXT_t RC; ...@@ -45,11 +45,8 @@ extern RAN_CONTEXT_t RC;
void init_UE_info(UE_info_t *UE_info) void init_UE_info(UE_info_t *UE_info)
{ {
int list_el;
UE_info->num_UEs = 0; UE_info->num_UEs = 0;
UE_info->list.head = -1; init_ue_list(&UE_info->list);
for (list_el = 0; list_el < MAX_MOBILES_PER_ENB; list_el++)
UE_info->list.next[list_el] = -1;
memset(UE_info->DLSCH_pdu, 0, sizeof(UE_info->DLSCH_pdu)); memset(UE_info->DLSCH_pdu, 0, sizeof(UE_info->DLSCH_pdu));
memset(UE_info->UE_template, 0, sizeof(UE_info->UE_template)); memset(UE_info->UE_template, 0, sizeof(UE_info->UE_template));
memset(UE_info->eNB_UE_stats, 0, sizeof(UE_info->eNB_UE_stats)); memset(UE_info->eNB_UE_stats, 0, sizeof(UE_info->eNB_UE_stats));
......
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