From a31432e37ed07dcdc916b1a5b9702d454a9810a5 Mon Sep 17 00:00:00 2001 From: Cedric Roux <roux@eurecom.fr> Date: Fri, 4 Dec 2015 09:15:08 +0100 Subject: [PATCH] some cleanup --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 26 ++++++++++++------------- openair1/SCHED/defs.h | 2 +- openair1/SCHED/phy_procedures_lte_eNb.c | 15 +++++++++----- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 49d83aadef..6d6f36bc63 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -1105,7 +1105,7 @@ int generate_eNB_dlsch_params_from_dci(int frame, if (dlsch0_harq->round == 0) { /* necessary test? */ if (dlsch0_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch[0], harq_pid); + remove_harq_pid_from_freelist(dlsch[0], harq_pid); dlsch0_harq->status = ACTIVE; } @@ -1243,7 +1243,7 @@ int generate_eNB_dlsch_params_from_dci(int frame, if (dlsch0_harq->round == 0) { /* necessary test? */ if (dlsch0_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch[0], harq_pid); + remove_harq_pid_from_freelist(dlsch[0], harq_pid); dlsch0_harq->status = ACTIVE; // printf("Setting DLSCH process %d to ACTIVE\n",harq_pid); // MCS and TBS don't change across HARQ rounds @@ -1614,14 +1614,14 @@ int generate_eNB_dlsch_params_from_dci(int frame, if (dlsch0_harq->round == 0) { /* necessary test? */ if (dlsch0_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch0, harq_pid); + remove_harq_pid_from_freelist(dlsch0, harq_pid); dlsch0_harq->status = ACTIVE; } if (dlsch1_harq->round == 0) { /* necessary test? */ if (dlsch1_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch1, harq_pid); + remove_harq_pid_from_freelist(dlsch1, harq_pid); dlsch1_harq->status = ACTIVE; } @@ -2001,14 +2001,14 @@ int generate_eNB_dlsch_params_from_dci(int frame, if ((dlsch0->active==1) && (dlsch0_harq->round == 0)) { /* necessary test? */ if (dlsch0_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch0, harq_pid); + remove_harq_pid_from_freelist(dlsch0, harq_pid); dlsch0_harq->status = ACTIVE; } if ((dlsch1->active==1) && (dlsch1_harq->round == 0)) { /* necessary test? */ if (dlsch1_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch1, harq_pid); + remove_harq_pid_from_freelist(dlsch1, harq_pid); dlsch1_harq->status = ACTIVE; } @@ -2151,12 +2151,12 @@ int generate_eNB_dlsch_params_from_dci(int frame, if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) { - LOG_W(PHY, "what to do with respect to get_harq_pid_from_freelist?\n"); + LOG_W(PHY, "what to do with respect to remove_harq_pid_from_freelist?\n"); dlsch0_harq->status = DISABLED; } if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) { - LOG_W(PHY, "what to do with respect to get_harq_pid_from_freelist?\n"); + LOG_W(PHY, "what to do with respect to remove_harq_pid_from_freelist?\n"); dlsch1_harq->status = DISABLED; } @@ -2166,7 +2166,7 @@ int generate_eNB_dlsch_params_from_dci(int frame, if (dlsch0_harq->round == 0) { /* necessary test? */ if (dlsch0_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch0, harq_pid); + remove_harq_pid_from_freelist(dlsch0, harq_pid); dlsch0_harq->status = ACTIVE; // printf("Setting DLSCH process %d to ACTIVE\n",harq_pid); } @@ -2333,7 +2333,7 @@ int generate_eNB_dlsch_params_from_dci(int frame, if ((dlsch0_harq->round == 0) && (dlsch0->active == 1) ) { /* necessary test? */ if (dlsch0_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch0, harq_pid); + remove_harq_pid_from_freelist(dlsch0, harq_pid); dlsch0_harq->status = ACTIVE; dlsch0_harq->mcs = mcs1; } @@ -2341,7 +2341,7 @@ int generate_eNB_dlsch_params_from_dci(int frame, if ((dlsch1_harq->round == 0) && (dlsch1->active == 1) ) { /* necessary test? */ if (dlsch1_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch1, harq_pid); + remove_harq_pid_from_freelist(dlsch1, harq_pid); dlsch1_harq->status = ACTIVE; dlsch1_harq->mcs = mcs2; } @@ -2507,7 +2507,7 @@ int generate_eNB_dlsch_params_from_dci(int frame, if (dlsch0_harq->round == 0) { /* necessary test? */ if (dlsch0_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch0, harq_pid); + remove_harq_pid_from_freelist(dlsch0, harq_pid); dlsch0_harq->status = ACTIVE; // printf("Setting DLSCH process %d to ACTIVE\n",harq_pid); } @@ -2639,7 +2639,7 @@ int generate_eNB_dlsch_params_from_dci(int frame, if (dlsch0_harq->round == 0) { /* necessary test? */ if (dlsch0_harq->status == SCH_IDLE) - get_harq_pid_from_freelist(dlsch0, harq_pid); + remove_harq_pid_from_freelist(dlsch0, harq_pid); dlsch0_harq->status = ACTIVE; // printf("Setting DLSCH process %d to ACTIVE\n",harq_pid); } diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h index 34c814a3c8..a88327ba92 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/defs.h @@ -402,7 +402,7 @@ uint16_t get_Np(uint8_t N_RB_DL,uint8_t nCCE,uint8_t plus1); int get_nCCE_offset(unsigned char L, int nCCE, int common_dci, unsigned short rnti, unsigned char subframe); void put_harq_pid_in_freelist(LTE_eNB_DLSCH_t *DLSCH_ptr, int harq_pid); -void get_harq_pid_from_freelist(LTE_eNB_DLSCH_t *DLSCH_ptr, int harq_pid); +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); int32_t add_ue(int16_t rnti, PHY_VARS_eNB *phy_vars_eNB); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 4d5971c074..d073657519 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -142,12 +142,21 @@ void put_harq_pid_in_freelist(LTE_eNB_DLSCH_t *DLSCH_ptr, int harq_pid) DLSCH_ptr->tail_freelist = (DLSCH_ptr->tail_freelist + 1) % 10; } -void get_harq_pid_from_freelist(LTE_eNB_DLSCH_t *DLSCH_ptr, int harq_pid) +void remove_harq_pid_from_freelist(LTE_eNB_DLSCH_t *DLSCH_ptr, int harq_pid) { if (DLSCH_ptr->head_freelist == DLSCH_ptr->tail_freelist) { LOG_E(PHY, "%s:%d: you cannot read this!\n", __FILE__, __LINE__); abort(); } + /* basic check, in case several threads deal with the free list at the same time + * in normal situations it should not happen, that's also why we don't use any + * locking mechanism to protect the free list + * to be refined in case things don't work properly + */ + if (harq_pid != DLSCH_ptr->harq_pid_freelist[DLSCH_ptr->head_freelist]) { + LOG_E(PHY, "%s:%d: critical error, get in touch with the authors\n", __FILE__, __LINE__); + abort(); + } DLSCH_ptr->head_freelist = (DLSCH_ptr->head_freelist + 1) % 10; } @@ -247,15 +256,12 @@ int8_t find_next_ue_index(PHY_VARS_eNB *phy_vars_eNB) int get_ue_active_harq_pid(const uint8_t Mod_id,const uint8_t CC_id,const uint16_t rnti, const int frame, const uint8_t subframe,uint8_t *harq_pid,uint8_t *round,const uint8_t ul_flag) { - int hp2sf[] = { 1, 2, 3, 4, 6, 7, 8, 9 }; - LTE_eNB_DLSCH_t *DLSCH_ptr; LTE_eNB_ULSCH_t *ULSCH_ptr; uint8_t ulsch_subframe,ulsch_frame; uint8_t i; int8_t UE_id = find_ue(rnti,PHY_vars_eNB_g[Mod_id][CC_id]); int sf1=(10*frame)+subframe,sf2,sfdiff,sfdiff_max=7; - int first_proc_found=0; if (UE_id==-1) { LOG_D(PHY,"Cannot find UE with rnti %x (Mod_id %d, CC_id %d)\n",rnti, Mod_id, CC_id); @@ -283,7 +289,6 @@ int get_ue_active_harq_pid(const uint8_t Mod_id,const uint8_t CC_id,const uint16 sfdiff_max = sfdiff; *harq_pid = i; *round = DLSCH_ptr->harq_processes[i]->round; - first_proc_found = 1; } } } else { // a process is not defined -- GitLab