diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c index d3f62ae0f4e26eab2aaf91c5b76ac3cd0b92e2fe..78d4deacb7e993c7d49f35666c7b5d383a81b298 100644 --- a/common/utils/itti/intertask_interface.c +++ b/common/utils/itti/intertask_interface.c @@ -650,6 +650,15 @@ void itti_mark_task_ready(task_id_t task_id) /* Mark the thread as using LFDS queue */ lfds611_queue_use(itti_desc.tasks[task_id].message_queue); +#if defined(UE_EXPANSION) || defined(RTAI) + /* Assign low priority to created threads */ + { + struct sched_param sched_param; + sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO) + 1; + sched_setscheduler(0, SCHED_FIFO, &sched_param); + } +#endif + itti_desc.threads[thread_id].task_state = TASK_STATE_READY; itti_desc.ready_tasks ++; diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index c63d504e43d569f2cf9c3045aa2dca1c3b7056d8..628acf2e77611f7c579da7d52084cd1c9a4bfa79 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -839,7 +839,7 @@ int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); LTE_eNB_DLSCH_t *dlsch0 = eNB->dlsch[UE_id][0]; //LTE_eNB_DLSCH_t *dlsch1 = eNB->dlsch[UE_id][1]; - int harq_pid = dlsch0->harq_ids[sf]; + int harq_pid = dlsch0->harq_ids[sfn%2][sf]; uint8_t *dlsch_sdu = tx_pdus[UE_id][harq_pid]; memcpy(dlsch_sdu, tx_pdu->segments[0].segment_data, tx_pdu->segments[0].segment_length); diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h index d5b1ce6af67eccabdec65c155161ea0bef39d29e..282739e31597782fd46a1e5e50f154d01c801708 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h @@ -2218,6 +2218,7 @@ typedef struct { uint8_t dl_assignment_index; uint32_t tpc_bitmap; uint16_t transmission_power; + uint8_t harq_pid; } nfapi_hi_dci0_dci_pdu_rel8_t; #define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG 0x2020 diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index d662cf19de8110968f7a91e1cb6ac07421146220..b8a7495ebc778beff2df41e8ff959e51c28a48ab 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -256,7 +256,7 @@ void phy_config_request(PHY_Config_t *phy_config) { AssertFatal(fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0] > 0, "prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0]==0\n"); #else - LOG_E(PHY,"***DJP*** removed assert on preamble fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0]:%d expecting >0 %s:%d\n\n\n", fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0], __FILE__, __LINE__); + LOG_D(PHY,"***DJP*** removed assert on preamble fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0]:%d expecting >0 %s:%d\n\n\n", fp->prach_emtc_config_common.prach_ConfigInfo.prach_numRepetitionPerPreambleAttempt[0], __FILE__, __LINE__); #endif fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[0] = cfg->emtc_config.prach_ce_level_0_configuration_index.value; fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[0] = cfg->emtc_config.prach_ce_level_0_frequency_offset.value; @@ -1779,7 +1779,7 @@ int phy_init_RU(RU_t *ru) { AssertFatal(RC.nb_L1_inst <= NUMBER_OF_eNB_MAX,"eNB instances %d > %d\n", RC.nb_L1_inst,NUMBER_OF_eNB_MAX); - LOG_E(PHY,"[INIT] %s() RC.nb_L1_inst:%d \n", __FUNCTION__, RC.nb_L1_inst); + LOG_D(PHY,"[INIT] %s() RC.nb_L1_inst:%d \n", __FUNCTION__, RC.nb_L1_inst); for (i=0; i<RC.nb_L1_inst; i++) { for (p=0;p<15;p++) { diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index e0c9c043c5084e55d05218c2bc2d487f201ff3fd..61fb92e252ad89d19542eef08e332a05b0773085 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -1052,8 +1052,12 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t if ((rel8->rnti_type == 2 ) && (rel8->rnti != SI_RNTI) && (rel8->rnti != P_RNTI)) dci_alloc->ra_flag = 1; UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); - AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); - AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); + if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ){ + LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rel8->rnti,UE_id); + return; + } + //AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); + //AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); dlsch0 = eNB->dlsch[UE_id][0]; dlsch1 = eNB->dlsch[UE_id][1]; @@ -1266,14 +1270,14 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t dlsch0_harq->mcs = rel8->mcs_1; dlsch0_harq->Qm = 2; dlsch0_harq->TBS = TBStable[I_mcs][NPRB-1]; - dlsch0->harq_ids[subframe] = rel8->harq_process; + dlsch0->harq_ids[frame%2][subframe] = rel8->harq_process; #ifdef UE_EXPANSION dlsch0->active[subframe] = 1; #else dlsch0->active = 1; #endif dlsch0->rnti = rel8->rnti; - dlsch0->harq_ids[subframe] = rel8->harq_process; + //dlsch0->harq_ids[subframe] = rel8->harq_process; if (dlsch0_harq->round == 0) dlsch0_harq->status = ACTIVE; @@ -1454,7 +1458,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t } LOG_D(PHY,"DCI: Set harq_ids[%d] to %d (%p)\n",subframe,rel8->harq_process,dlsch0); - dlsch0->harq_ids[subframe] = rel8->harq_process; + dlsch0->harq_ids[frame%2][subframe] = rel8->harq_process; dlsch0->harq_mask |= (1<<rel8->harq_process); @@ -1621,8 +1625,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t dlsch0->subframe_tx[subframe] = 1; - dlsch0->harq_ids[subframe] = rel8->harq_process; - dlsch1->harq_ids[subframe] = rel8->harq_process; + dlsch0->harq_ids[frame%2][subframe] = rel8->harq_process; + dlsch1->harq_ids[frame%2][subframe] = rel8->harq_process; // printf("Setting DLSCH harq id %d to subframe %d\n",harq_pid,subframe); @@ -2076,11 +2080,11 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t if (dlsch0 != NULL){ dlsch0->subframe_tx[subframe] = 1; - dlsch0->harq_ids[subframe] = rel8->harq_process; + dlsch0->harq_ids[frame%2][subframe] = rel8->harq_process; } if (dlsch1_harq != NULL){ - dlsch1->harq_ids[subframe] = rel8->harq_process; + dlsch1->harq_ids[frame%2][subframe] = rel8->harq_process; } @@ -2290,6 +2294,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL; int UE_id; int subframe = proc->subframe_tx; + int frame = proc->frame_tx; dci_alloc->firstCCE = rel13->ecce_index; dci_alloc->L = rel13->aggregation_level; @@ -2308,8 +2313,12 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d if (rel13->rnti_type == 2 ) dci_alloc->ra_flag = 1; UE_id = find_dlsch(rel13->rnti,eNB,SEARCH_EXIST_OR_FREE); - AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); - AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); + if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ){ + LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rel13->rnti,UE_id); + return; + } + //AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); + //AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); dlsch0 = eNB->dlsch[UE_id][0]; dlsch0_harq = dlsch0->harq_processes[rel13->harq_process]; @@ -2533,7 +2542,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d } - dlsch0->harq_ids[subframe] = rel13->harq_process; + dlsch0->harq_ids[frame%2][subframe] = rel13->harq_process; @@ -2564,6 +2573,8 @@ void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, uint32_t ndi = pdu->dci_pdu_rel8.new_data_indication_1; + uint16_t UE_id = -1; + #ifdef T_TRACER T(T_ENB_PHY_ULSCH_UE_DCI, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(pdu->dci_pdu_rel8.rnti), T_INT(((frame*10+subframe+4) % 8) /* TODO: correct harq pid */), @@ -2709,6 +2720,13 @@ void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, DevParam (frame_parms->N_RB_DL, 0, 0); break; } + + if(frame_parms->frame_type == TDD){ + UE_id = find_ulsch(pdu->dci_pdu_rel8.rnti, eNB,SEARCH_EXIST_OR_FREE); + if(UE_id != -1){ + eNB->ulsch[UE_id]->harq_processes[pdu->dci_pdu_rel8.harq_pid]->V_UL_DAI = dai +1; + } + } } void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame,int subframe) @@ -2773,6 +2791,7 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu ulsch->harq_processes[harq_pid]->ndi, ulsch_pdu->ulsch_pdu_rel8.new_data_indication, new_ulsch, ulsch->harq_processes[harq_pid]->status); ulsch->harq_processes[harq_pid]->rvidx = ulsch_pdu->ulsch_pdu_rel8.redundancy_version; + if(ulsch_pdu->ulsch_pdu_rel8.modulation_type!=0) ulsch->harq_processes[harq_pid]->Qm = ulsch_pdu->ulsch_pdu_rel8.modulation_type; // Set O_ACK to 0 by default, will be set of DLSCH is scheduled and needs to be ulsch->harq_processes[harq_pid]->O_ACK = 0; @@ -6586,12 +6605,7 @@ uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t } else { switch (frame_parms->tdd_config) { - case 1: - if ((subframe==2) || - (subframe==3) || - (subframe==7) || - (subframe==8)) switch (subframe) { case 2: case 3: @@ -6659,10 +6673,13 @@ uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) uint8_t ul_subframe = 255; if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 - ul_subframe = ((n+6)%10); - else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 1)) { + if ((n==1)||(n==6)) { // tdd_config 0,1 SF 1,5 + ul_subframe = ((n+6)%10); + } else if ((n==4)||(n==9)) { + ul_subframe = ((n+4)%10); + } + } else if ((frame_parms->frame_type == TDD) && (frame_parms->tdd_config == 6) && ((n==0)||(n==1)||(n==5)||(n==6))) ul_subframe = ((n+7)%10); @@ -6682,10 +6699,13 @@ uint8_t pdcch_alloc2ul_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n) { if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==7)||(n==2))) // tdd_config 0,1 SF 1,5 - return((n==7)? 1 : 6); - else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 1)) { + if ((n==7)||(n==2)) { // tdd_config 0,1 SF 1,5 + return((n==7)? 1 : 6); + } else if ((n==3)||(n==8)) { + return((n==3)? 9 : 4); + } + } else if ((frame_parms->frame_type == TDD) && (frame_parms->tdd_config == 6) && ((n==7)||(n==8)||(n==2)||(n==3))) return((n+3)%10); @@ -6699,13 +6719,14 @@ uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n) { - uint32_t ul_frame; + uint32_t ul_frame = frame; if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5 - ul_frame = (frame + (n==1 ? 0 : 1)); - else if ((frame_parms->frame_type == TDD) && + (frame_parms->tdd_config == 1)) { + if ((n==1)||(n==6)||(n==4)||(n==9)) { // tdd_config 0,1 SF 1,5 + ul_frame = (frame + (n < 5 ? 0 : 1)); + } + } else if ((frame_parms->frame_type == TDD) && (frame_parms->tdd_config == 6) && ((n==0)||(n==1)||(n==5)||(n==6))) ul_frame = (frame + (n>=5 ? 1 : 0)); diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h index b293e56b87950d7a5bffc5d92f72ecd9e964730d..293f9313638159fb0178007116e0f964c6dbf2c4 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/defs.h @@ -291,7 +291,7 @@ typedef struct { /// First CCE of last PDSCH scheduling per subframe. Again used during PUCCH detection for ACK/NAK. uint8_t nCCE[10]; /// Process ID's per subframe. Used to associate received ACKs on PUSCH/PUCCH to DLSCH harq process ids - uint8_t harq_ids[10]; + uint8_t harq_ids[2][10]; /// Window size (in outgoing transport blocks) for fine-grain rate adaptation uint8_t ra_window_size; /// First-round error threshold for fine-grain rate adaptation diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index bd5c1b05c2b0c4834b51222ff63173aa1fcac2a6..69e7d7424a608d647b873620b488d86c44b11842 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -167,8 +167,8 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_ }*/ - for (i=0; i<10; i++) - dlsch->harq_ids[i] = Mdlharq; + for (i=0; i<20; i++) + dlsch->harq_ids[i/10][i%10] = Mdlharq; for (i=0; i<Mdlharq; i++) { dlsch->harq_processes[i] = (LTE_DL_eNB_HARQ_t *)malloc16(sizeof(LTE_DL_eNB_HARQ_t)); @@ -254,8 +254,8 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) #endif dlsch->harq_mask = 0; - for (i=0; i<10; i++) - dlsch->harq_ids[i] = Mdlharq; + for (i=0; i<20; i++) + dlsch->harq_ids[i/10][i%10] = Mdlharq; for (i=0; i<Mdlharq; i++) { if (dlsch->harq_processes[i]) { @@ -399,7 +399,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, unsigned int crc=1; unsigned short iind; - unsigned char harq_pid = dlsch->harq_ids[subframe]; + unsigned char harq_pid = dlsch->harq_ids[frame%2][subframe]; unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; unsigned int A; unsigned char mod_order; @@ -583,7 +583,7 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, unsigned short iind; LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; - unsigned char harq_pid = dlsch->harq_ids[subframe]; + unsigned char harq_pid = dlsch->harq_ids[frame%2][subframe]; unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; unsigned int A; unsigned char mod_order; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 49b41615f4cd91d43ed5b0f59ae6f2a1a90d3fca..9fef0f1f4f3ef0a5661866cdace71ffd977244f7 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -1990,6 +1990,7 @@ inline int check_skip_dc(int rb,LTE_DL_FRAME_PARMS *frame_parms) { int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, int32_t **txdataF, int16_t amp, + int frame, uint32_t subframe_offset, uint8_t num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch0, @@ -2062,7 +2063,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, if ((dlsch0 != NULL) && (dlsch1 != NULL)){ - harq_pid = dlsch0->harq_ids[subframe_offset]; + harq_pid = dlsch0->harq_ids[frame%2][subframe_offset]; dlsch0_harq = dlsch0->harq_processes[harq_pid]; mimo_mode = dlsch0_harq->mimo_mode; mod_order0 = dlsch0_harq->Qm; @@ -2079,7 +2080,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, }else if ((dlsch0 != NULL) && (dlsch1 == NULL)){ - harq_pid = dlsch0->harq_ids[subframe_offset]; + harq_pid = dlsch0->harq_ids[frame%2][subframe_offset]; dlsch0_harq = dlsch0->harq_processes[harq_pid]; mimo_mode = dlsch0_harq->mimo_mode; mod_order0 = dlsch0_harq->Qm; @@ -2096,7 +2097,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, }else if ((dlsch0 == NULL) && (dlsch1 != NULL)){ - harq_pid = dlsch1->harq_ids[subframe_offset]; + harq_pid = dlsch1->harq_ids[frame%2][subframe_offset]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; mimo_mode = dlsch1_harq->mimo_mode; mod_order0 = dlsch1_harq->Qm; diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index be13e5938dd836cf962b3a6fe2270d61adb4525e..10e45af9b1b9ce5a5ec632d892e998c2dd4a8ed2 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -290,6 +290,7 @@ int32_t allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB, int32_t dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, int32_t **txdataF, int16_t amp, + int frame, uint32_t sub_frame_offset, uint8_t num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch0, diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index d4f4bec4b3faf4d5d8533373a0d730cb318abb88..f459d9df9f5126ad0148c3ddeb3526cba5aaad33 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -154,31 +154,35 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr int harq_pid; UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); - AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); - AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); + if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ){ + LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rel8->rnti,UE_id); + return; + } + //AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); + //AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); dlsch0 = eNB->dlsch[UE_id][0]; dlsch1 = eNB->dlsch[UE_id][1]; #ifdef Rel14 - if ((rel13->pdsch_payload_type < 2) && (rel13->ue_type>0)) dlsch0->harq_ids[subframe] = 0; + if ((rel13->pdsch_payload_type < 2) && (rel13->ue_type>0)) dlsch0->harq_ids[frame%2][subframe] = 0; #endif - harq_pid = dlsch0->harq_ids[subframe]; + harq_pid = dlsch0->harq_ids[frame%2][subframe]; AssertFatal((harq_pid>=0) && (harq_pid<8),"harq_pid %d not in 0...7 frame:%d subframe:%d subframe(TX):%d rnti:%x UE_id:%d dlsch0[harq_ids:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d]\n", harq_pid, frame,subframe, proc->subframe_tx,rel8->rnti,UE_id, - dlsch0->harq_ids[0], - dlsch0->harq_ids[1], - dlsch0->harq_ids[2], - dlsch0->harq_ids[3], - dlsch0->harq_ids[4], - dlsch0->harq_ids[5], - dlsch0->harq_ids[6], - dlsch0->harq_ids[7], - dlsch0->harq_ids[8], - dlsch0->harq_ids[9] + dlsch0->harq_ids[frame%2][0], + dlsch0->harq_ids[frame%2][1], + dlsch0->harq_ids[frame%2][2], + dlsch0->harq_ids[frame%2][3], + dlsch0->harq_ids[frame%2][4], + dlsch0->harq_ids[frame%2][5], + dlsch0->harq_ids[frame%2][6], + dlsch0->harq_ids[frame%2][7], + dlsch0->harq_ids[frame%2][8], + dlsch0->harq_ids[frame%2][9] ); dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; @@ -207,12 +211,16 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr dlsch0_harq->pdsch_start = eNB->pdcch_vars[subframe & 1].num_pdcch_symbols; if (dlsch0_harq->round==0) { //get pointer to SDU if this a new SDU - AssertFatal(sdu!=NULL,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", - frame,subframe, - proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start); - if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d, subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d\n", - frame,subframe,proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid); + if(sdu == NULL) { + LOG_E(PHY,"NFAPI: frame %d, subframe %d: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d\n", + proc->frame_tx, proc->subframe_tx, rel8->rnti, UE_id, harq_pid, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index); + return; + } + //AssertFatal(sdu!=NULL,"NFAPI: frame %d, subframe %d: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d\n", + // proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index); + if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: frame %d, subframe %d: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d\n", + proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid); if (codeword_index == 0) dlsch0_harq->pdu = sdu; else dlsch1_harq->pdu = sdu; } @@ -331,6 +339,9 @@ void handle_ulsch_harq_pdu( ulsch_harq->subframe = subframe; ulsch_harq->O_ACK = harq_information->harq_information_rel10.harq_size; ulsch->beta_offset_harqack_times8 = to_beta_offset_harqack[harq_information->harq_information_rel10.delta_offset_harq]; + if (harq_information->harq_information_rel10.ack_nack_mode==0) //bundling + ulsch->bundling = 1; + } uint16_t to_beta_offset_ri[16]={9,13,16,20,25,32,40,50,64,80,101,127,160,0,0,0}; @@ -678,13 +689,19 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) eNB->pdcch_vars[subframe&1].num_dci = 0; eNB->phich_vars[subframe&1].num_hi = 0; - LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%04d%d DL_req:SFN/SF:%04d%d:dl_pdu:%d tx_req:SFN/SF:%04d%d:pdus:%d hi_dci0:SFN/SF:%04d%d:pdus:%d ul_cfg:SFN/SF:%04d%d:pdus:%d num_pdcch_symbols:%d\n", - frame,subframe, - NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),number_dl_pdu, - NFAPI_SFNSF2SFN(TX_req->sfn_sf),NFAPI_SFNSF2SF(TX_req->sfn_sf),TX_req->tx_request_body.number_of_pdus, - NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),number_hi_dci0_pdu, - NFAPI_SFNSF2SFN(UL_req->sfn_sf),NFAPI_SFNSF2SF(UL_req->sfn_sf),number_ul_pdu, - eNB->pdcch_vars[subframe&1].num_pdcch_symbols); + LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%04d%d DL_req:SFN/SF:%04d%d:dl_pdu:%d tx_req:SFN/SF:%04d%d:pdus:%d\n", + frame,subframe, + NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),number_dl_pdu, + NFAPI_SFNSF2SFN(TX_req->sfn_sf),NFAPI_SFNSF2SF(TX_req->sfn_sf),TX_req->tx_request_body.number_of_pdus + ); + LOG_D(PHY,"NFAPI: hi_dci0:SFN/SF:%04d%d:pdus:%d\n", + NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),number_hi_dci0_pdu + ); + if(UL_req!=NULL) + LOG_D(PHY,"NFAPI: ul_cfg:SFN/SF:%04d%d:pdus:%d num_pdcch_symbols:%d\n", + NFAPI_SFNSF2SFN(UL_req->sfn_sf),NFAPI_SFNSF2SF(UL_req->sfn_sf),number_ul_pdu, + eNB->pdcch_vars[subframe&1].num_pdcch_symbols); + int do_oai =0; int dont_send =0; diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index bbb6986ce9c7c3ac375e79eb170e5c4c77b2ab72..1981f53ee2dde06461a25e854deee02952fae652 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -336,6 +336,29 @@ unsigned char ul_ACK_subframe2_dl_subframe(LTE_DL_FRAME_PARMS *frame_parms,unsig return(0); } +int ul_ACK_subframe2_dl_frame(LTE_DL_FRAME_PARMS *frame_parms,int frame, unsigned char subframe,unsigned char subframe_tx) +{ + + if (frame_parms->frame_type == FDD) { + return (((subframe_tx > subframe ) ? frame-1 : frame)+1024)%1024; + } else { + switch (frame_parms->tdd_config) { + case 1: + return(((subframe_tx > subframe ) ? frame-1 : frame)+1024)%1024; + break; + case 3: + //TODO + break; + case 4: + //TODO + break; + } + } + + return(0); +} + + unsigned char ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe) { @@ -343,6 +366,23 @@ unsigned char ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char s return(1); } else { switch (frame_parms->tdd_config) { + case 1: + return 1; // don't ACK special subframe for now + if (subframe == 2) { // ACK subframes 5 and 6 + return(2); + } else if (subframe == 3) { // ACK subframe 9 + return(1); // To be updated + } else if (subframe == 7) { // ACK subframes 0 and 1 + return(2); // To be updated + } else if (subframe == 8) { // ACK subframe 4 + return(1); // To be updated + } else { + LOG_E(PHY,"phy_procedures_lte_common.c/subframe2_dl_harq_pid: illegal subframe %d for tdd_config %d\n", + subframe,frame_parms->tdd_config); + return(0); + } + + break; case 3: if (subframe == 2) { // ACK subframes 5 and 6 return(2); // should be 3 @@ -381,23 +421,6 @@ unsigned char ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char s } break; - - case 1: - if (subframe == 2) { // ACK subframes 5 and 6 - return(2); - } else if (subframe == 3) { // ACK subframe 9 - return(1); // To be updated - } else if (subframe == 7) { // ACK subframes 0 and 1 - return(2); // To be updated - } else if (subframe == 8) { // ACK subframe 4 - return(1); // To be updated - } else { - LOG_E(PHY,"phy_procedures_lte_common.c/subframe2_dl_harq_pid: illegal subframe %d for tdd_config %d\n", - subframe,frame_parms->tdd_config); - return(0); - } - - break; } } diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index d53ddf7c96620376ca911ec8cf743d4466550785..b402c7c0a50249fbbf058666c18034d8b47dbecf 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -149,10 +149,20 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe) { // generate Cell-Specific Reference Signals for both slots VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX,1); - generate_pilots_slot(eNB, - txdataF, - AMP, - subframe<<1,0); + + if(subframe_select(fp,subframe) == SF_S) + generate_pilots_slot(eNB, + txdataF, + AMP, + subframe<<1,1); + else + generate_pilots_slot(eNB, + txdataF, + AMP, + subframe<<1,0); + + // check that 2nd slot is for DL + // check that 2nd slot is for DL if (subframe_select(fp,subframe) == SF_DL) generate_pilots_slot(eNB, @@ -379,6 +389,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, dlsch_modulation(eNB, eNB->common_vars.txdataF, AMP, + frame, subframe, dlsch_harq->pdsch_start, dlsch, @@ -540,7 +551,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, #endif // get harq_pid - harq_pid = dlsch0->harq_ids[subframe]; + harq_pid = dlsch0->harq_ids[frame%2][subframe]; AssertFatal(harq_pid>=0,"harq_pid is negative\n"); if (harq_pid>=8) @@ -893,12 +904,13 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) frame, subframe, PUCCH1_THRES); - LOG_D(PHY,"[eNB %d][SR %x] Frame %d subframe %d Checking SR is %d (SR n1pucch is %d)\n", + LOG_D(PHY,"[eNB %d][SR %x] Frame %d subframe %d Checking SR is %d (uci.type %d SR n1pucch is %d)\n", eNB->Mod_id, uci->rnti, frame, subframe, SR_payload, + uci->type, uci->n_pucch_1_0_sr[0]); if (uci->type == SR) { if (SR_payload == 1) { @@ -1010,21 +1022,23 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) } - + LOG_I(PHY,"RNTI %x type %d SR_payload %d Frame %d Subframe %d pucch_b0b1[0][0] %d pucch_b0b1[0][1] %d pucch_b0b1[1][0] %d pucch_b0b1[1][1] %d \n", + uci->rnti,uci->type,SR_payload,frame,subframe,pucch_b0b1[0][0],pucch_b0b1[0][1],pucch_b0b1[1][0],pucch_b0b1[1][1]); + if (SR_payload == 1) { // this implements Table 7.3.1 from 36.213 if (pucch_b0b1[0][0] == 4) { // there isn't a likely transmission harq_ack[0] = 4; // DTX } - else if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] == 1) { // 1/4/7 ACKs + else if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] == 1) { // 1/4/7 ACKs harq_ack[0] = 1; } - else if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] != 1) { // 2/5/8 ACKs + else if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] != 1) { // 2/5/8 ACKs harq_ack[0] = 2; } - else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] == 1) { // 3/6/9 ACKs + else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] == 1) { // 3/6/9 ACKs harq_ack[0] = 3; } - else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] != 1) { // 0 ACKs, or at least one DL assignment missed + else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] != 1) { // 0 ACKs, or at least one DL assignment missed harq_ack[0] = 0; } uci->stat = metric[0]; @@ -1340,8 +1354,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; - if (fp->frame_type == FDD) harq_pid = ((10*frame) + subframe)&7; - else harq_pid = subframe%10; + harq_pid = subframe2harq_pid(&eNB->frame_parms,frame,subframe); for (i=0; i<NUMBER_OF_UE_MAX; i++) { ulsch = eNB->ulsch[i]; @@ -1638,7 +1651,7 @@ void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subf LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; int harq_pid; - int subframe_tx; + int subframe_tx,frame_tx; int M,m; AssertFatal(UE_id!=-1,"no existing dlsch context\n"); @@ -1648,7 +1661,9 @@ void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subf if (eNB->frame_parms.frame_type == FDD) { subframe_tx = (subframe+6)%10; - harq_pid = dlsch0->harq_ids[subframe_tx]; + frame_tx = ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame,subframe,subframe_tx); + harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx]; // or just use 0 for fdd? + AssertFatal((harq_pid>=0) && (harq_pid<10),"harq_pid %d not in 0...9\n",harq_pid); dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; @@ -1671,8 +1686,9 @@ void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subf subframe_tx = ul_ACK_subframe2_dl_subframe(&eNB->frame_parms, subframe, m); + frame_tx = ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame,subframe,subframe_tx); if (((1<<m)&mask) > 0) { - harq_pid = dlsch0->harq_ids[subframe_tx]; + harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx]; if ((harq_pid>=0) && (harq_pid<10)) { dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; @@ -1695,7 +1711,7 @@ int getM(PHY_VARS_eNB *eNB,int frame,int subframe) { LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; int harq_pid; - int subframe_tx; + int subframe_tx,frame_tx; int m; M=ul_ACK_subframe2_M(&eNB->frame_parms, @@ -1705,7 +1721,10 @@ int getM(PHY_VARS_eNB *eNB,int frame,int subframe) { subframe_tx = ul_ACK_subframe2_dl_subframe(&eNB->frame_parms, subframe, m); - harq_pid = dlsch0->harq_ids[subframe_tx]; + frame_tx = ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame, + subframe,subframe_tx); + harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx]; + if (harq_pid>=0 && harq_pid<10) { dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; @@ -1813,7 +1832,7 @@ void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq, for (i=0;i<ulsch_harq->O_ACK;i++) { AssertFatal(ulsch_harq->o_ACK[i] == 0 || ulsch_harq->o_ACK[i] == 1, "harq_ack[%d] is %d, should be 1,2 or 4\n",i,ulsch_harq->o_ACK[i]); - pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = 2-ulsch_harq->o_ACK[i]; + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 2-ulsch_harq->o_ACK[i]; // release DLSCH if needed if (ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,i,frame,subframe,0xffff); if (M==1 && ulsch_harq->O_ACK==1 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff); @@ -1915,7 +1934,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; pdu->harq_indication_tdd_rel13.mode = tdd_mapping_mode; - + LOG_D(PHY,"%s(eNB, uci_harq format %d, rnti:%04x, frame:%d, subframe:%d, tdd_mapping_mode:%d) harq_ack[0]:%d harq_ack[1]:%d\n", __FUNCTION__, uci->pucch_fmt,uci->rnti, frame, subframe, tdd_mapping_mode,harq_ack[0],harq_ack[1]); switch (tdd_mapping_mode) { case 0: // bundling @@ -1977,15 +1996,18 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, case 2: // special bundling (SR collision) pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; + pdu->harq_indication_tdd_rel13.mode = 0; int tdd_config5_sf2scheds=0; if (eNB->frame_parms.tdd_config==5) tdd_config5_sf2scheds = getM(eNB,frame,subframe); switch (harq_ack[0]) { case 0: + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; break; case 1: // check if M=1,4,7 if (uci->num_pucch_resources == 1 || uci->num_pucch_resources == 4 || tdd_config5_sf2scheds == 1 || tdd_config5_sf2scheds == 4 || tdd_config5_sf2scheds == 7) { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; release_harq(eNB,UE_id,0,frame,subframe,0xffff); release_harq(eNB,UE_id,1,frame,subframe,0xffff); } @@ -1993,6 +2015,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, case 2: // check if M=2,5,8 if (uci->num_pucch_resources == 2 || tdd_config5_sf2scheds == 2 || tdd_config5_sf2scheds == 5 || tdd_config5_sf2scheds == 8) { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; release_harq(eNB,UE_id,0,frame,subframe,0xffff); release_harq(eNB,UE_id,1,frame,subframe,0xffff); } @@ -2000,6 +2023,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, case 3: // check if M=3,6,9 if (uci->num_pucch_resources == 3 || tdd_config5_sf2scheds == 3 || tdd_config5_sf2scheds == 6 || tdd_config5_sf2scheds == 9) { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; release_harq(eNB,UE_id,0,frame,subframe,0xffff); release_harq(eNB,UE_id,1,frame,subframe,0xffff); } diff --git a/openair1/SIMULATION/LTE_PHY/dlsim_tm4.c b/openair1/SIMULATION/LTE_PHY/dlsim_tm4.c index 90ba1ec8044e81b6491e98a82e26a14c3909ad73..20682a57be8e87cd48019a8f5bc5ad399a3a0822 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim_tm4.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim_tm4.c @@ -3426,6 +3426,7 @@ int main(int argc, char **argv) re_allocated = dlsch_modulation(eNB, eNB->common_vars.txdataF[eNB_id], AMP, + frame, subframe, num_pdcch_symbols, ((TB0_active == 1)? eNB->dlsch[k][0]: NULL), diff --git a/openair1/SIMULATION/LTE_PHY/dlsim_tm7.c b/openair1/SIMULATION/LTE_PHY/dlsim_tm7.c index 3c4b3d0cd308cf8ea52667ff25f8ade505607f88..e1385e68f1fd064de1fc9b90e972730354868db0 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim_tm7.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim_tm7.c @@ -2679,6 +2679,7 @@ PMI_FEEDBACK: re_allocated = dlsch_modulation(eNB, eNB->common_vars.txdataF[eNB_id], AMP, + frame, subframe, num_pdcch_symbols, eNB->dlsch[k][0], diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 09e00a8f6b6809b6eda4805bf4a45e64245f0391..121400f2b401285d062a94c1e22e4d14eccb6737 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -180,6 +180,8 @@ void RCconfig_RU(void) { RC.ru[j]->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; RC.ru[j]->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); RC.ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; + RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); + RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); for (i=0;i<RC.ru[j]->num_bands;i++) RC.ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; } //strcmp(local_rf, "yes") == 0 else { @@ -215,7 +217,7 @@ void RCconfig_RU(void) { RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF5_MOBIPASS; } RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); - RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); + RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); } /* strcmp(local_rf, "yes") != 0 */ RC.ru[j]->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); @@ -876,9 +878,9 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 2(N_RB_DL %d)!\n", RC.config_file_name, i, prach_freq_offset,N_RB_DL); - if (((N_RB_DL == 50) || (N_RB_DL == 100)) && (prach_freq_offset != 3)) + if (((N_RB_DL == 50) || (N_RB_DL == 100)) && (prach_freq_offset < 3)) AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 3(N_RB_DL %d)!\n", + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 3,4(N_RB_DL %d)!\n", RC.config_file_name, i, prach_freq_offset,N_RB_DL); #endif diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 1aa3a8563686bf90ebbda590bbc29d356ea2af48..4dadb529ee2296eaaa154b4eb92afe94c3a18af1 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -251,7 +251,7 @@ void config_mib(int Mod_idP, cfg->rf_config.dl_channel_bandwidth.value = to_prb(dl_BandwidthP); cfg->rf_config.dl_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG; cfg->num_tlv++; -LOG_E(PHY,"%s() dl_BandwidthP:%d\n", __FUNCTION__, dl_BandwidthP); +LOG_D(PHY,"%s() dl_BandwidthP:%d\n", __FUNCTION__, dl_BandwidthP); cfg->rf_config.ul_channel_bandwidth.value = to_prb(dl_BandwidthP); cfg->rf_config.ul_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG; @@ -762,7 +762,7 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN); - LOG_E(MAC, "RC.mac:%p mib:%p\n", RC.mac, mib); + LOG_D(MAC, "RC.mac:%p mib:%p\n", RC.mac, mib); if (mib != NULL) { if (RC.mac == NULL) @@ -997,7 +997,7 @@ rrc_mac_config_req_eNB(module_id_t Mod_idP, } #endif - LOG_E(MAC, "%s() %s:%d RC.mac[Mod_idP]->if_inst->PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.mac[Mod_idP]->if_inst->PHY_config_req); + LOG_D(MAC, "%s() %s:%d RC.mac[Mod_idP]->if_inst->PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.mac[Mod_idP]->if_inst->PHY_config_req); // if in nFAPI mode if ( diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 884efc4433076c2ea2c94edce02d51763cb4a4c7..0338cd8c3c9a02a9d9593c8cb2c7c7aaf19fd8ff 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -667,7 +667,7 @@ typedef struct { /// mcs from last UL scheduling uint8_t mcs_UL[8]; /// TBS from last UL scheduling - uint8_t TBS_UL[8]; + uint16_t TBS_UL[8]; /// Flag to indicate UL has been scheduled at least once boolean_t ul_active; /// Flag to indicate UE has been configured (ACK from RRCConnectionSetup received) @@ -1094,9 +1094,9 @@ typedef struct eNB_MAC_INST_s { nfapi_ul_config_request_t UL_req_tmp[MAX_NUM_CCs][10]; /// Preallocated HI_DCI0 pdu list nfapi_hi_dci0_request_pdu_t - hi_dci0_pdu_list[MAX_NUM_CCs][MAX_NUM_HI_DCI0_PDU]; + hi_dci0_pdu_list[MAX_NUM_CCs][10][MAX_NUM_HI_DCI0_PDU]; /// NFAPI HI/DCI0 Config Request Structure - nfapi_hi_dci0_request_t HI_DCI0_req[MAX_NUM_CCs]; + nfapi_hi_dci0_request_t HI_DCI0_req[MAX_NUM_CCs][10]; /// Prealocated TX pdu list nfapi_tx_request_pdu_t tx_request_pdu[MAX_NUM_CCs][MAX_NUM_TX_REQUEST_PDU]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index b307db29b7312cc3556f70a1f984f145a2f69bd7..7d11a6385fb7eb2b856e47163333a284a2540834 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -541,13 +541,14 @@ check_ul_failure(module_id_t module_idP, int CC_id, int UE_id, "UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n", UE_id, rnti, UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); - if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer % 40) == 0) - UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 4 frames + if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer % 80) == 0) + UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 8 frames } UE_list->UE_sched_ctrl[UE_id].ul_failure_timer++; // check threshold - if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 20000) { + if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 4000) { + // note: probably ul_failure_timer is should be less than UE radio link failure time(see T310/N310/N311) // inform RRC of failure and clear timer LOG_I(MAC, "UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n", @@ -573,7 +574,7 @@ clear_nfapi_information(eNB_MAC_INST * eNB, int CC_idP, { nfapi_dl_config_request_t *DL_req = &eNB->DL_req[0]; nfapi_ul_config_request_t *UL_req = &eNB->UL_req[0]; - nfapi_hi_dci0_request_t *HI_DCI0_req = &eNB->HI_DCI0_req[0]; + nfapi_hi_dci0_request_t *HI_DCI0_req = &eNB->HI_DCI0_req[CC_idP][subframeP]; nfapi_tx_request_t *TX_req = &eNB->TX_req[0]; eNB->pdu_index[CC_idP] = 0; @@ -586,8 +587,8 @@ clear_nfapi_information(eNB_MAC_INST * eNB, int CC_idP, DL_req[CC_idP].dl_config_request_body.number_pdsch_rnti = 0; DL_req[CC_idP].dl_config_request_body.transmission_power_pcfich = 6000; - HI_DCI0_req[CC_idP].hi_dci0_request_body.sfnsf = subframeP + (frameP<<4); - HI_DCI0_req[CC_idP].hi_dci0_request_body.number_of_dci = 0; + HI_DCI0_req->hi_dci0_request_body.sfnsf = subframeP + (frameP<<4); + HI_DCI0_req->hi_dci0_request_body.number_of_dci = 0; UL_req[CC_idP].ul_config_request_body.number_of_pdus = 0; @@ -817,9 +818,10 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, // Allocate CCEs for good after scheduling is done - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) - allocate_CCEs(module_idP, CC_id, frameP, subframeP, 2); - + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++){ + if(cc[CC_id].tdd_Config == NULL || !(is_UL_sf(&cc[CC_id],subframeP))) + allocate_CCEs(module_idP, CC_id, frameP, subframeP, 2); +} stop_meas(&RC.mac[module_idP]->eNB_scheduler); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 3fd7504a8e6553629fec4ec6d2253fa426245203..79d8548683b11b6247ebd0448f3fd3c494ae94e4 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -106,10 +106,10 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP, nfapi_ul_config_request_t *ul_req; nfapi_ul_config_request_body_t *ul_req_body; nfapi_ul_config_request_pdu_t *ul_config_pdu; - nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_id]; - nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; + nfapi_hi_dci0_request_t *hi_dci0_req; + nfapi_hi_dci0_request_body_t *hi_dci0_req_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - + uint8_t sf_ahead_dl; uint8_t rvseq[4] = { 0, 2, 3, 1 }; @@ -234,6 +234,9 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP, LOG_D(MAC, "MSG3: UL_CONFIG SFN/SF:%d number_of_pdus:%d ra->msg3_round:%d\n", NFAPI_SFNSF2DEC(ul_req->sfn_sf), ul_req_body->number_of_pdus, ra->msg3_round); if (ra->msg3_round != 0) { // program HI too + sf_ahead_dl = ul_subframe2_k_phich(cc, subframeP); + hi_dci0_req = &mac->HI_DCI0_req[CC_id][(subframeP+sf_ahead_dl)%10]; + hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t)); @@ -249,7 +252,7 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP, hi_dci0_req_body->sfnsf = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 0); hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - hi_dci0_req->sfn_sf = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 4); + hi_dci0_req->sfn_sf = hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP, subframeP, sf_ahead_dl); hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; if (nfapi_mode) { @@ -307,7 +310,7 @@ generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP, LOG_D(MAC,"absSF:%d absSF_Msg2:%d ra->rach_resource_type:%d\n",absSF,absSF_Msg2,ra->rach_resource_type); - if (absSF > absSF_Msg2) + if (absSF < absSF_Msg2) return; // we're not ready yet, need to be to start == if (cc[CC_idP].radioResourceConfigCommon_BR) { @@ -850,17 +853,18 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, // set HARQ process round to 0 for this UE - if (cc->tdd_Config) - ra->harq_pid = ((frameP * 10) + subframeP) % 10; - else - ra->harq_pid = ((frameP * 10) + subframeP) & 7; + ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); // Get RRCConnectionSetup for Piggyback rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0); // not used in this case - - AssertFatal(rrc_sdu_length > 0, - "[MAC][eNB Scheduler] CCCH not allocated\n"); + + if(rrc_sdu_length <= 0) { + LOG_D(MAC,"[MAC][eNB Scheduler] CCCH not allocated\n %d",rrc_sdu_length); + return; + } + //AssertFatal(rrc_sdu_length > 0, + //"[MAC][eNB Scheduler] CCCH not allocated\n"); LOG_D(MAC, @@ -1298,10 +1302,8 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, "Frame %d, Subframe %d: Preparing for Msg4 retransmission currently %d.%d\n", frameP, subframeP, ra->Msg4_frame, ra->Msg4_subframe); - if (ra->Msg4_subframe > 1) - ra->Msg4_frame++; - ra->Msg4_frame &= 1023; - ra->Msg4_subframe = (ra->Msg4_subframe + 8) % 10; + get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe); + LOG_D(MAC, "Frame %d, Subframe %d: Msg4 retransmission in %d.%d\n", frameP, subframeP, ra->Msg4_frame, @@ -1309,10 +1311,8 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, lcid = 0; // put HARQ process round to 0 - if (cc->tdd_Config) - ra->harq_pid = ((frameP * 10) + subframeP) % 10; - else - ra->harq_pid = ((frameP * 10) + subframeP) & 7; + ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = 0; @@ -1592,10 +1592,7 @@ check_Msg4_retransmission(module_id_t module_idP, int CC_idP, dci_dl_pdu_rel8.cce_idx); // prepare frame for retransmission - if (ra->Msg4_subframe > 1) - ra->Msg4_frame++; - ra->Msg4_frame &= 1023; - ra->Msg4_subframe = (ra->Msg4_subframe + 8) % 10; + get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe); LOG_W(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission round %d in %d.%d)\n", @@ -1645,7 +1642,7 @@ schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) if (ra->state == MSG2) generate_Msg2(module_idP, CC_id, frameP, subframeP, ra); - else if (ra->state == MSG4) + else if (ra->state == MSG4 && ra->Msg4_frame == frameP && ra->Msg4_subframe == subframeP ) generate_Msg4(module_idP, CC_id, frameP, subframeP, ra); else if (ra->state == WAITMSG4ACK) check_Msg4_retransmission(module_idP, CC_id, frameP, @@ -1679,6 +1676,8 @@ initiate_ra_proc(module_id_t module_idP, struct PRACH_ConfigSIB_v1310 *ext4_prach = NULL; PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL; + + static uint8_t failure_cnt = 0; if (cc->radioResourceConfigCommon_BR && cc->radioResourceConfigCommon_BR->ext4) { @@ -1729,11 +1728,21 @@ initiate_ra_proc(module_id_t module_idP, ra[i].msg4_mpdcch_repetition_cnt = 0; #endif - // DJP - this is because VNF is 2 subframes ahead of PNF and TX needs 4 subframes - if (nfapi_mode) - offset = 7; - else - offset = 5; + + //TODO Fill in other TDD config. What about nfapi_mode? + if(cc->tdd_Config!=NULL){ + switch(cc->tdd_Config->subframeAssignment){ + case 1 : + offset = 6; + break; + } + }else{//FDD + // DJP - this is because VNF is 2 subframes ahead of PNF and TX needs 4 subframes + if (nfapi_mode) + offset = 7; + else + offset = 5; + } add_subframe(&msg2_frame, &msg2_subframe, offset); @@ -1780,6 +1789,7 @@ initiate_ra_proc(module_id_t module_idP, } ra[i].RA_rnti = ra_rnti; ra[i].preamble_index = preamble_index; + failure_cnt = 0; LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation in Frame %d, subframe %d for process %d, rnti %x, state %d\n", module_idP, CC_id, frameP, ra[i].Msg2_frame, @@ -1792,6 +1802,13 @@ initiate_ra_proc(module_id_t module_idP, LOG_E(MAC, "[eNB %d][RAPROC] FAILURE: CC_id %d Frame %d Initiating RA procedure for preamble index %d\n", module_idP, CC_id, frameP, preamble_index); + + failure_cnt++; + if(failure_cnt > 20) { + LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Clear Random access information\n", module_idP, CC_id, frameP); + clear_ra_proc(module_idP, CC_id, frameP); + } + } void @@ -1814,6 +1831,22 @@ cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, ra[i].RRC_timer = 20; ra[i].rnti = 0; ra[i].msg3_round = 0; + LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Canceled RA procedure for UE rnti %x\n", module_idP, CC_id, frameP, rnti); } } } + +void clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP) +{ + unsigned char i; + RA_t *ra = (RA_t *) & RC.mac[module_idP]->common_channels[CC_id].ra[0]; + + for (i = 0; i < NB_RA_PROC_MAX; i++) { + LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Clear Random access information rnti %x\n", module_idP, CC_id, frameP, ra[i].rnti); + ra[i].state = IDLE; + ra[i].timing_offset = 0; + ra[i].RRC_timer = 20; + ra[i].rnti = 0; + ra[i].msg3_round = 0; + } +} diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 05dbd76d14cf5895ca52ec9733cbde34202267df..2ac618ccd3d22b04bcae030133b9840b3d037754 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -338,6 +338,7 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, case 1: switch (subframeP) { + case 0: case 1: UE_list->UE_template[CC_idP][UE_idP].DAI_ul[7] = DAI; break; @@ -346,6 +347,7 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, UE_list->UE_template[CC_idP][UE_idP].DAI_ul[8] = DAI; break; + case 5: case 6: UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI; break; @@ -499,8 +501,7 @@ schedule_ue_spec(module_id_t module_idP, break; case 6: case 7: - if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) - && (tdd_sfa != 5)) + if ((tdd_sfa != 3)&& (tdd_sfa != 4) && (tdd_sfa != 5)) return; break; case 8: @@ -509,8 +510,7 @@ schedule_ue_spec(module_id_t module_idP, return; break; case 9: - if ((tdd_sfa != 1) && (tdd_sfa != 3) && (tdd_sfa != 4) - && (tdd_sfa != 6)) + if (tdd_sfa == 0) return; break; @@ -689,10 +689,7 @@ schedule_ue_spec(module_id_t module_idP, nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; - if (cc->tdd_Config) - harq_pid = ((frameP * 10) + subframeP) % 10; - else - harq_pid = ((frameP * 10) + subframeP) & 7; + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); round = ue_sched_ctl->round[CC_id][harq_pid]; @@ -758,7 +755,7 @@ schedule_ue_spec(module_id_t module_idP, UE_list->UE_template[CC_id][UE_id].DAI++; update_ul_dci(module_idP, CC_id, rnti, UE_list->UE_template[CC_id][UE_id]. - DAI); + DAI,subframeP); LOG_D(MAC, "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", CC_id, subframeP, UE_id, @@ -1389,7 +1386,7 @@ schedule_ue_spec(module_id_t module_idP, if (cc[CC_id].tdd_Config != NULL) { // TDD UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(module_idP,CC_id,rnti,UE_list->UE_template[CC_id][UE_id].DAI); + update_ul_dci(module_idP,CC_id,rnti,UE_list->UE_template[CC_id][UE_id].DAI,subframeP); } // do PUCCH power control @@ -1609,8 +1606,7 @@ fill_DLSCH_dci( // clear scheduling flag eNB_dlsch_info[module_idP][CC_id][UE_id].status = S_DL_WAITING; rnti = UE_RNTI(module_idP,UE_id); - if (cc->tdd_Config) harq_pid = ((frameP*10)+subframeP)%10; - else harq_pid = ((frameP*10)+subframeP)&7; + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; @@ -1691,12 +1687,12 @@ unsigned char *get_dlsch_sdu(module_id_t module_idP, //------------------------------------------------------------------------------ void update_ul_dci(module_id_t module_idP, - uint8_t CC_idP, rnti_t rntiP, uint8_t daiP) + uint8_t CC_idP, rnti_t rntiP, uint8_t daiP, sub_frame_t subframe) //------------------------------------------------------------------------------ { nfapi_hi_dci0_request_t *HI_DCI0_req = - &RC.mac[module_idP]->HI_DCI0_req[CC_idP]; + &RC.mac[module_idP]->HI_DCI0_req[CC_idP][subframe]; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0]; COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_idP]; @@ -1707,7 +1703,7 @@ update_ul_dci(module_id_t module_idP, for (i = 0; i < HI_DCI0_req->hi_dci0_request_body.number_of_dci + - HI_DCI0_req->hi_dci0_request_body.number_of_dci; i++) { + HI_DCI0_req->hi_dci0_request_body.number_of_hi; i++) { if ((hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) && (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti == rntiP)) @@ -1848,7 +1844,7 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) LOG_D(MAC,"[eNB %d] Frame %d subframe %d: PCCH->PCH CC_id %d UE_id %d, Received %d bytes \n", module_idP, frameP, subframeP, CC_id,i, pcch_sdu_length); #ifdef FORMAT1C //NO SIB - if ((subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || + if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { switch (n_rb_dl) { #if 0 @@ -1967,7 +1963,7 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) } #else //NO SIB - if ((subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || + if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { switch (n_rb_dl) { case 25: @@ -2055,6 +2051,10 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for P_RNTI\n", frameP,subframeP); dl_req->number_dci++; dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; + eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; @@ -2095,6 +2095,7 @@ void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) TX_req->num_segments = 1; TX_req->segments[0].segment_length = pcch_sdu_length; TX_req->segments[0].segment_data = cc[CC_id].PCCH_pdu.payload; + eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; } else { LOG_E(MAC,"[eNB %d] CCid %d Frame %d, subframe %d : Cannot add DCI 1A/1C for Paging\n",module_idP, CC_id, frameP, subframeP); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 17bd5398d96717314ea7ed3441cabdd2e2a9b044..9cc5ef0476ba377e04a7b21b26116e430a70423c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -60,6 +60,7 @@ #define ENABLE_MAC_PAYLOAD_DEBUG #define DEBUG_eNB_SCHEDULER 1 +extern uint16_t frame_cnt; int choose(int n, int k) { @@ -579,6 +580,56 @@ int is_UL_sf(COMMON_channels_t * ccP, sub_frame_t subframeP) } } +int is_S_sf(COMMON_channels_t * ccP, sub_frame_t subframeP) +{ + // if FDD return dummy value + if (ccP->tdd_Config == NULL) + return (0); + + switch (subframeP) { + case 1: + return (1); + break; + + case 6: + if(ccP->tdd_Config->subframeAssignment == 0 || ccP->tdd_Config->subframeAssignment == 1 + || ccP->tdd_Config->subframeAssignment == 2 || ccP->tdd_Config->subframeAssignment == 6) + return (1); + break; + + default: + return (0); + break; + } + return 0; +} + +uint8_t ul_subframe2_k_phich(COMMON_channels_t * cc, sub_frame_t ul_subframe){ + + if(cc->tdd_Config){//TODO fill other tdd config + switch(cc->tdd_Config->subframeAssignment){ + case 0: + break; + case 1: + if(ul_subframe == 2 || ul_subframe == 7) + return 4; + else if(ul_subframe == 3 || ul_subframe == 8) + return 6; + else return 255; + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + } + } + return 4; //idk sf_ahead? +} + uint16_t get_pucch1_absSF(COMMON_channels_t * cc, uint16_t dlsch_absSF) { uint16_t sf, f, nextf; @@ -592,40 +643,52 @@ uint16_t get_pucch1_absSF(COMMON_channels_t * cc, uint16_t dlsch_absSF) switch (cc->tdd_Config->subframeAssignment) { case 0: - AssertFatal(1 == 0, "SFA 0 to be filled in now, :-)\n"); + if ((sf == 0) || (sf == 5)) + return ((10 * f) + sf + 4)% 10240; // ACK/NAK in SF 4,9 same frame + else if (sf == 6) + return ((10 * nextf) + 2)% 10240; // ACK/NAK in SF 2 next frame + else if (sf == 1) + return ((10 * f) + 7)% 10240; // ACK/NAK in SF 7 same frame + else + AssertFatal(1 == 0, + "Impossible dlsch subframe %d for TDD configuration 0\n", + sf); + break; case 1: if ((sf == 5) || (sf == 6)) - return ((10 * nextf) + 2); // ACK/NAK in SF 2 next frame + return ((10 * nextf) + 2)% 10240; // ACK/NAK in SF 2 next frame else if (sf == 9) - return ((10 * nextf) + 3); // ACK/NAK in SF 3 next frame + return ((10 * nextf) + 3)% 10240; // ACK/NAK in SF 3 next frame else if ((sf == 0) || (sf == 1)) - return ((10 * f) + 2); // ACK/NAK in SF 7 same frame + return ((10 * f) + 7)% 10240; // ACK/NAK in SF 7 same frame + else if (sf == 4) + return ((10 * f) + 8)% 10240; // ACK/NAK in SF 8 same frame else AssertFatal(1 == 0, - "Impossible dlsch subframe %d for TDD configuration 3\n", + "Impossible dlsch subframe %d for TDD configuration 1\n", sf); break; case 2: if ((sf == 4) || (sf == 5) || (sf == 6) || (sf == 8)) - return ((10 * nextf) + 2); // ACK/NAK in SF 2 next frame + return ((10 * nextf) + 2)% 10240; // ACK/NAK in SF 2 next frame else if (sf == 9) - return ((10 * nextf) + 7); // ACK/NAK in SF 7 next frame + return ((10 * nextf) + 7)% 10240; // ACK/NAK in SF 7 next frame else if ((sf == 0) || (sf == 1) || (sf == 3)) - return ((10 * f) + 7); // ACK/NAK in SF 7 same frame + return ((10 * f) + 7)% 10240; // ACK/NAK in SF 7 same frame else AssertFatal(1 == 0, - "Impossible dlsch subframe %d for TDD configuration 3\n", + "Impossible dlsch subframe %d for TDD configuration 2\n", sf); break; case 3: if ((sf == 5) || (sf == 6) || (sf == 7) || (sf == 8) || (sf == 9)) - return ((10 * nextf) + (sf >> 1)); // ACK/NAK in 2,3,4 resp. next frame + return ((10 * nextf) + ((sf-1) >> 1))% 10240; // ACK/NAK in 2,3,4 resp. next frame else if (sf == 1) - return ((10 * nextf) + 2); // ACK/NAK in 2 next frame + return ((10 * nextf) + 2)% 10240; // ACK/NAK in 2 next frame else if (sf == 0) - return ((10 * f) + 4); // ACK/NAK in 4 same frame + return ((10 * f) + 4)% 10240; // ACK/NAK in 4 same frame else AssertFatal(1 == 0, "Impossible dlsch subframe %d for TDD configuration 3\n", @@ -653,7 +716,16 @@ uint16_t get_pucch1_absSF(COMMON_channels_t * cc, uint16_t dlsch_absSF) sf); break; case 6: - AssertFatal(1 == 0, "SFA 6 To be filled in now, :-)\n"); + if ((sf == 5) || (sf == 6)) + return ((10 * f) + sf + 7)% 10240; // ACK/NAK in SF 2,3 next frame + else if (sf == 9) + return ((10 * nextf) + 4)% 10240; // ACK/NAK in SF 4 next frame + else if ((sf == 1) || (sf == 0)) + return ((10 * f) + sf + 7)% 10240; // ACK/NAK in SF 7 same frame + else + AssertFatal(1 == 0, + "Impossible dlsch subframe %d for TDD configuration 6\n", + sf); break; default: AssertFatal(1 == 0, "Illegal TDD subframe Assigment %d\n", @@ -1228,7 +1300,7 @@ program_dlsch_acknak(module_id_t module_idP, int CC_idP, int UE_idP, if (ulsch_harq_information) fill_nfapi_ulsch_harq_information(module_idP, CC_idP, - rnti, ulsch_harq_information); + rnti, ulsch_harq_information,subframeP); if (harq_information) fill_nfapi_harq_information(module_idP, CC_idP, @@ -1237,10 +1309,10 @@ program_dlsch_acknak(module_id_t module_idP, int CC_idP, int UE_idP, harq_information, cce_idx); } -uint8_t get_V_UL_DAI(module_id_t module_idP, int CC_idP, uint16_t rntiP) +uint8_t get_V_UL_DAI(module_id_t module_idP, int CC_idP, uint16_t rntiP,sub_frame_t subframeP) { nfapi_hi_dci0_request_body_t *HI_DCI0_req = - &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; + &RC.mac[module_idP]->HI_DCI0_req[CC_idP][subframeP].hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[0]; @@ -1258,7 +1330,8 @@ fill_nfapi_ulsch_harq_information(module_id_t module_idP, int CC_idP, uint16_t rntiP, nfapi_ul_config_ulsch_harq_information - * harq_information) + * harq_information, + sub_frame_t subframeP) { eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; @@ -1318,7 +1391,7 @@ fill_nfapi_ulsch_harq_information(module_id_t module_idP, if (harq_information->harq_information_rel10.ack_nack_mode == 1) harq_information->harq_information_rel10.harq_size = - get_V_UL_DAI(module_idP, CC_idP, rntiP); + get_V_UL_DAI(module_idP, CC_idP, rntiP,subframeP); else harq_information->harq_information_rel10.harq_size = 1; } @@ -1330,7 +1403,7 @@ fill_nfapi_ulsch_harq_information(module_id_t module_idP, if (harq_information->harq_information_rel10.ack_nack_mode == 1) harq_information->harq_information_rel10.harq_size = - get_V_UL_DAI(module_idP, CC_idP, rntiP); + get_V_UL_DAI(module_idP, CC_idP, rntiP,subframeP); else harq_information->harq_information_rel10.harq_size = 2; } @@ -1373,29 +1446,38 @@ fill_nfapi_harq_information(module_id_t module_idP, case 6: case 7: if (cc->tdd_Config != NULL) { - AssertFatal(UE_list-> - UE_template[CC_idP] - [UE_id].physicalConfigDedicated-> - pucch_ConfigDedicated != NULL, - "pucch_ConfigDedicated is null for TDD!\n"); - if ((UE_list-> - UE_template[CC_idP][UE_id].physicalConfigDedicated-> - pucch_ConfigDedicated->tdd_AckNackFeedbackMode != NULL) - && (*UE_list-> - UE_template[CC_idP][UE_id].physicalConfigDedicated-> - pucch_ConfigDedicated->tdd_AckNackFeedbackMode == - PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing)) - { - harq_information->harq_information_rel10_tdd.harq_size = 2; // 2-bit ACK/NAK - harq_information->harq_information_rel10_tdd.ack_nack_mode = 1; // multiplexing - } else { - harq_information->harq_information_rel10_tdd.harq_size = 1; // 1-bit ACK/NAK - harq_information->harq_information_rel10_tdd.ack_nack_mode = 0; // bundling - } - harq_information->harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG; - harq_information->harq_information_rel10_tdd.n_pucch_1_0 = - cc->radioResourceConfigCommon->pucch_ConfigCommon. - n1PUCCH_AN + cce_idxP; +// AssertFatal(UE_list-> +// UE_template[CC_idP] +// [UE_id].physicalConfigDedicated-> +// pucch_ConfigDedicated != NULL, +// "pucch_ConfigDedicated is null for TDD!\n"); + if (UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated != NULL){ + if ((UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated != NULL) + && (UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated->tdd_AckNackFeedbackMode != NULL) + && (*UE_list-> + UE_template[CC_idP][UE_id].physicalConfigDedicated-> + pucch_ConfigDedicated->tdd_AckNackFeedbackMode == + PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing)) + { + harq_information->harq_information_rel10_tdd.harq_size = 2; // 2-bit ACK/NAK + harq_information->harq_information_rel10_tdd.ack_nack_mode = 1; // multiplexing + } else { + harq_information->harq_information_rel10_tdd.harq_size = 1; // 1-bit ACK/NAK + harq_information->harq_information_rel10_tdd.ack_nack_mode = 0; // bundling + } + } else { + harq_information->harq_information_rel10_tdd.harq_size = 1; // 1-bit ACK/NAK + harq_information->harq_information_rel10_tdd.ack_nack_mode = 0; // bundling + } + harq_information->harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG; + LTE_DL_FRAME_PARMS *frame_parms = &RC.eNB[module_idP][CC_idP]->frame_parms; + harq_information->harq_information_rel10_tdd.n_pucch_1_0 = get_Np(frame_parms->N_RB_DL,cce_idxP,0) + + cc->radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN + cce_idxP; harq_information-> harq_information_rel10_tdd.number_of_pucch_resources = 1; } else { @@ -1629,8 +1711,10 @@ fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t * ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; else if (mcs < 21) ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 4; - else + else if(mcs < 29) ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 6; + else + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 0; ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = cyclic_shift_2_for_drms; ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8. @@ -2189,16 +2273,8 @@ int rrc_mac_remove_ue(module_id_t mod_idP, rnti_t rntiP) eNB_dlsch_info[mod_idP][pCC_id][UE_id].serving_num = 0; // check if this has an RA process active - RA_t *ra; - for (i = 0; i < NB_RA_PROC_MAX; i++) { - ra = (RA_t *) & RC.mac[mod_idP]->common_channels[pCC_id].ra[i]; - if (ra->rnti == rntiP) { - ra->state = IDLE; - ra->timing_offset = 0; - ra->RRC_timer = 20; - ra->rnti = 0; - //break; - } + if(find_RA_id(mod_idP, pCC_id, rntiP) != -1) { + cancel_ra_proc(mod_idP, pCC_id, 0, rntiP); } return 0; @@ -3110,7 +3186,7 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[CC_idP].dl_config_request_body; nfapi_hi_dci0_request_body_t *HI_DCI0_req = - &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; + &RC.mac[module_idP]->HI_DCI0_req[CC_idP][subframeP].hi_dci0_request_body; nfapi_dl_config_request_pdu_t *dl_config_pdu = &DL_req->dl_config_pdu_list[0]; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = @@ -3121,10 +3197,16 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, int fCCE; int i, j, idci; int nCCE = 0; + int max_symbol; eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; int ackNAK_absSF = get_pucch1_absSF(cc, (frameP*10+subframeP)); + if (cc->tdd_Config!=NULL && is_S_sf(cc,subframeP) > 0) + max_symbol = 2; + else + max_symbol = 3; + nfapi_ul_config_request_body_t *ul_req = &eNB->UL_req_tmp[CC_idP][ackNAK_absSF % 10].ul_config_request_body; LOG_D(MAC, @@ -3154,7 +3236,7 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, if (nCCE + (dl_config_pdu[i].dci_dl_pdu. dci_dl_pdu_rel8.aggregation_level) > nCCE_max) { - if (DL_req->number_pdcch_ofdm_symbols == 3) + if (DL_req->number_pdcch_ofdm_symbols == max_symbol) goto failed; LOG_D(MAC, "Can't fit DCI allocations with %d PDCCH symbols, increasing by 1\n", @@ -3176,7 +3258,7 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, dci_dl_pdu.dci_dl_pdu_rel8.rnti, subframeP); if (fCCE == -1) { - if (DL_req->number_pdcch_ofdm_symbols == 3) { + if (DL_req->number_pdcch_ofdm_symbols == max_symbol) { LOG_D(MAC, "subframe %d: Dropping Allocation for RNTI %x\n", subframeP, @@ -3252,7 +3334,7 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, if (nCCE + (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.aggregation_level) > nCCE_max) { - if (DL_req->number_pdcch_ofdm_symbols == 3) + if (DL_req->number_pdcch_ofdm_symbols == max_symbol) goto failed; LOG_D(MAC, "Can't fit DCI allocations with %d PDCCH symbols, increasing by 1\n", @@ -3274,7 +3356,7 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8. rnti, subframeP); if (fCCE == -1) { - if (DL_req->number_pdcch_ofdm_symbols == 3) { + if (DL_req->number_pdcch_ofdm_symbols == max_symbol) { LOG_D(MAC, "subframe %d: Dropping Allocation for RNTI %x\n", subframeP, @@ -3342,7 +3424,7 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, if (nCCE + (dl_config_pdu[i].dci_dl_pdu. dci_dl_pdu_rel8.aggregation_level) > nCCE_max) { - if (DL_req->number_pdcch_ofdm_symbols == 3) + if (DL_req->number_pdcch_ofdm_symbols == max_symbol) goto failed; LOG_D(MAC, "Can't fit DCI allocations with %d PDCCH symbols, increasing by 1\n", @@ -3365,7 +3447,7 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, dci_dl_pdu.dci_dl_pdu_rel8.rnti, subframeP); if (fCCE == -1) { - if (DL_req->number_pdcch_ofdm_symbols == 3) { + if (DL_req->number_pdcch_ofdm_symbols == max_symbol) { LOG_I(MAC, "subframe %d: Dropping Allocation for RNTI %x\n", subframeP, @@ -3421,8 +3503,12 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, if(((ul_req->ul_config_pdu_list[ack_int].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) || (ul_req->ul_config_pdu_list[ack_int].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE)) && (ul_req->ul_config_pdu_list[ack_int].uci_harq_pdu.ue_information.ue_information_rel8.rnti == dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti)){ - ul_req->ul_config_pdu_list[ack_int].uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = + if (cc->tdd_Config==NULL) + ul_req->ul_config_pdu_list[ack_int].uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = cc->radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN + fCCE; + else + ul_req->ul_config_pdu_list[ack_int].uci_harq_pdu.harq_information.harq_information_rel10_tdd.n_pucch_1_0 = + cc->radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN + fCCE + get_Np(to_prb(cc->mib->message.dl_Bandwidth),fCCE,0) ; } } } @@ -3575,7 +3661,7 @@ CCE_allocation_infeasible(int module_idP, nfapi_dl_config_request_pdu_t *dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; nfapi_hi_dci0_request_body_t *HI_DCI0_req = - &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; + &RC.mac[module_idP]->HI_DCI0_req[CC_idP][subframe].hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci + HI_DCI0_req->number_of_hi]; @@ -3630,6 +3716,77 @@ CCE_allocation_infeasible(int module_idP, return res; } +void get_retransmission_timing(TDD_Config_t *tdd_Config, frame_t *frameP, + sub_frame_t *subframeP) +{ + + if (tdd_Config == NULL) + { + if (*subframeP > 1) + *frameP = (*frameP + 1) % 1024; + *subframeP = (*subframeP + 8) % 10; + } + else + { + switch (tdd_Config->subframeAssignment)//TODO fill in other TDD configs + { + case 1: + if (*subframeP == 0 || *subframeP == 5) + { + *subframeP += 19; + *frameP = (*frameP + *subframeP/10) % 1024; + *subframeP %= 10; + } + else if (*subframeP == 4 || *subframeP == 9) + { + *subframeP += 16; + *frameP = (*frameP + *subframeP/10) % 1024; + *subframeP %= 10; + } + else + { + AssertFatal(2 == 1, + "Illegal dl subframe %d for tdd config %d\n", *subframeP, + tdd_Config->subframeAssignment); + } + break; + } + } +} + +uint8_t get_dl_subframe_count(int tdd_config_sfa, sub_frame_t subframeP){ + + uint8_t tdd1[10] = {1,-1,-1,-1,2,3,-1,-1,-1,4}; // special subframes 1,6 are excluded + + switch(tdd_config_sfa){// TODO fill in other tdd configs + case 1 : + return tdd1[subframeP]; + break; + } + return -1; +} + +uint8_t frame_subframe2_dl_harq_pid(TDD_Config_t *tdd_Config, int abs_frameP, sub_frame_t subframeP){ + int harq_pid; + if(tdd_Config){ + + switch(tdd_Config->subframeAssignment){ //TODO fill in other tdd config + case 1: + harq_pid = (((frame_cnt*1024 + abs_frameP) * 4) - 1 + get_dl_subframe_count(tdd_Config->subframeAssignment,subframeP))%7;//4 dl subframe in a frame + if(harq_pid < 0) + harq_pid += 7; + LOG_D(MAC,"[frame_subframe2_dl_harq_pid] (%d,%d) calculate harq_pid ((( %d * 1024 + %d) *4) - 1 + %d)%7 = %d \n", + (abs_frameP+1024)%1024,subframeP,frame_cnt,abs_frameP, + get_dl_subframe_count(tdd_Config->subframeAssignment,subframeP),harq_pid); + return harq_pid; + break; + } + }else{ + return ((abs_frameP*10)+subframeP)&7; + } + return -1; +} + void extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, @@ -3647,8 +3804,12 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, int pCCid = UE_list->pCC_id[UE_id]; int spatial_bundling = 0; int tmode[5]; - int i, j; + int i, j, m; uint8_t *pdu; + LTE_DL_FRAME_PARMS *fp; + sub_frame_t subframe_tx; + int frame_tx; + uint8_t harq_pid; #ifdef Rel14 if (UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated != NULL && @@ -3668,22 +3829,54 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, && (format == 1)))) spatial_bundling = 1; #endif - + fp=&(RC.eNB[mod_idP][CC_idP]->frame_parms); for (i = 0; i < numCC; i++) tmode[i] = get_tmode(mod_idP, i, UE_id); if (cc->tdd_Config) { - harq_indication_tdd = - (nfapi_harq_indication_tdd_rel13_t *) harq_indication; + harq_indication_tdd = (nfapi_harq_indication_tdd_rel13_t *) harq_indication; // pdu = &harq_indication_tdd->harq_tb_n[0]; num_ack_nak = harq_indication_tdd->number_of_ack_nack; switch (harq_indication_tdd->mode) { - case 0: // Format 1a/b - AssertFatal(numCC == 1, - "numCC %d > 1, should not be using Format1a/b\n", - numCC); + case 0: // Format 1a/b bundling + AssertFatal(numCC == 1, "numCC %d > 1, should not be using Format1a/b\n", numCC); + int M = ul_ACK_subframe2_M(fp,subframeP); + for(m=0;m<M;m++){ + subframe_tx = ul_ACK_subframe2_dl_subframe(fp,subframeP,m); + if(frameP==1023&&subframeP>5) + frame_tx=-1; + else + frame_tx = subframeP < 4 ? frameP -1 : frameP; + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frame_tx,subframe_tx); + + if(num_ack_nak==1){ + if(harq_indication_tdd->harq_data[0].bundling.value_0==1){ //ack + sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process + sched_ctl->tbcnt[CC_idP][harq_pid] = 0; + LOG_D(MAC,"frame %d subframe %d Acking (%d,%d) harq_pid %d round %d\n",frameP,subframeP,frame_tx,subframe_tx,harq_pid,sched_ctl->round[CC_idP][harq_pid]); + }else{ //nack + if( sched_ctl->round[CC_idP][harq_pid]<8) + sched_ctl->round[CC_idP][harq_pid]++; + LOG_D(MAC,"frame %d subframe %d Nacking (%d,%d) harq_pid %d round %d\n",frameP,subframeP,frame_tx,subframe_tx,harq_pid,sched_ctl->round[CC_idP][harq_pid]); + } + } + RA_t *ra = &RC.mac[mod_idP]->common_channels[CC_idP].ra[0]; + for (uint8_t ra_i = 0; ra_i < NB_RA_PROC_MAX; ra_i++) { + if ((ra[ra_i].rnti == rnti) && (ra[ra_i].state == MSGCRNTI_ACK) && (ra[ra_i].crnti_harq_pid == harq_pid)) { + LOG_D(MAC,"CRNTI Reconfiguration: ACK %d rnti %x round %d frame %d subframe %d \n",harq_indication_tdd->harq_data[0].bundling.value_0,rnti,sched_ctl->round[CC_idP][harq_pid],frameP,subframeP); + if(num_ack_nak == 1 && harq_indication_tdd->harq_data[0].bundling.value_0 == 1) { + cancel_ra_proc(mod_idP, CC_idP, frameP, ra[ra_i].rnti); + }else{ + if(sched_ctl->round[CC_idP][harq_pid] == 7){ + cancel_ra_proc(mod_idP, CC_idP, frameP, ra[ra_i].rnti); + } + } + break; + } + } + } break; case 1: // Channel Selection break; @@ -3700,7 +3893,7 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, num_ack_nak = harq_indication_fdd->number_of_ack_nack; pdu = &harq_indication_fdd->harq_tb_n[0]; - uint8_t harq_pid = ((10 * frameP) + subframeP + 10236) & 7; + harq_pid = ((10 * frameP) + subframeP + 10236) & 7; LOG_D(MAC,"frame %d subframe %d harq_pid %d mode %d tmode[0] %d num_ack_nak %d round %d\n",frameP,subframeP,harq_pid,harq_indication_fdd->mode,tmode[0],num_ack_nak,sched_ctl->round[CC_idP][harq_pid]); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index fc08dd585f3ac0e4b2ace7226b5d0957e72019b1..ea33715596fdc7ca7cca6b2daa3d0bb52156eeff 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -165,18 +165,16 @@ rx_sdu(const module_id_t enb_mod_idP, UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], ul_cqi); - // AssertFatal(1==0,"ulsch in error\n"); - if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] == - 3) { - UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= - (~(1 << harq_pid)); - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = - 0; - if (UE_list->UE_sched_ctrl[UE_id]. - ul_consecutive_errors++ == 10) - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1; - } else - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; + // AssertFatal(1==0,"ulsch in error\n"); + if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] == 3) { + UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1 << harq_pid)); + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; + if (UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors++ == 10) + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1; + if(find_RA_id(enb_mod_idP, CC_idP, current_rnti) != -1) + cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); + } else + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; return; } @@ -198,13 +196,13 @@ rx_sdu(const module_id_t enb_mod_idP, if (sduP == NULL) { // we've got an error on Msg3 LOG_D(MAC, - "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n", + "[eNB %d] CC_id %d, RA %d ULSCH in error in round(Msg3) %d/%d\n", enb_mod_idP, CC_idP, RA_id, ra[RA_id].msg3_round, (int) mac->common_channels[CC_idP]. radioResourceConfigCommon->rach_ConfigCommon. maxHARQ_Msg3Tx); - if (ra[RA_id].msg3_round == + if (ra[RA_id].msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon-> rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); @@ -216,8 +214,9 @@ rx_sdu(const module_id_t enb_mod_idP, first_rb_ul[harq_pid]; ra[RA_id].msg3_round++; // prepare handling of retransmission - ra[RA_id].Msg3_frame = (ra[RA_id].Msg3_frame + ((ra[RA_id].Msg3_subframe > 1) ? 1 : 0)) % 1024; - ra[RA_id].Msg3_subframe = (ra[RA_id].Msg3_subframe + 8) % 10; + get_Msg3allocret(&mac->common_channels[CC_idP], + ra[RA_id].Msg3_subframe, ra[RA_id].Msg3_frame, + &ra[RA_id].Msg3_frame, &ra[RA_id].Msg3_subframe); add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, subframeP); } @@ -308,7 +307,7 @@ rx_sdu(const module_id_t enb_mod_idP, // prepare transmission of Msg4(RRCConnectionReconfiguration) ra->state = MSGCRNTI; LOG_I(MAC, - "[eNB %d] Frame %d, Subframe %d CC_id %d : (rnti %x UE_id %d) RRCConnectionReconfiguration(Msg4)", + "[eNB %d] Frame %d, Subframe %d CC_id %d : (rnti %x UE_id %d) RRCConnectionReconfiguration(Msg4)\n", enb_mod_idP, frameP, subframeP, CC_idP, old_rnti, old_UE_id); // UE_id = old_UE_id; @@ -659,9 +658,20 @@ rx_sdu(const module_id_t enb_mod_idP, + if(mac->common_channels[CC_idP].tdd_Config!=NULL){ + switch(mac->common_channels[CC_idP].tdd_Config->subframeAssignment){ + case 1: + ra->Msg4_frame = frameP + ((subframeP > 2) ? 1 : 0); + ra->Msg4_subframe = (subframeP + 7) % 10; + break; + // TODO need to be complete for other tdd configs. + } + }else{ // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different - ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0); - ra->Msg4_subframe = (subframeP + 4) % 10; + ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0); + ra->Msg4_subframe = (subframeP + 4) % 10; + } + UE_list->UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0; } // if process is active } // loop on RA processes @@ -793,7 +803,10 @@ rx_sdu(const module_id_t enb_mod_idP, LOG_D(MAC, "Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n", current_rnti, harq_pid, first_rb); - nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_idP]; + nfapi_hi_dci0_request_t *hi_dci0_req; + uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP] , subframeP); + hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP+sf_ahead_dl)%10]; + nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; @@ -807,7 +820,7 @@ rx_sdu(const module_id_t enb_mod_idP, hi_dci0_req_body->number_of_hi++; hi_dci0_req_body->sfnsf = sfnsf_add_subframe(frameP,subframeP, 0); hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP,subframeP, 4); + hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP,subframeP,sf_ahead_dl); hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; /* NN--> FK: we could either check the payload, or use a phy helper to detect a false msg3 */ @@ -984,7 +997,6 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, start_meas(&mac->schedule_ulsch); int sched_subframe = (subframeP+4)%10; - if (sched_subframe < subframeP) sched_frame++; cc = &mac->common_channels[0]; int tdd_sfa; @@ -994,18 +1006,16 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, switch (subframeP) { case 0: if ((tdd_sfa == 0)|| - (tdd_sfa == 3)|| - (tdd_sfa == 6)) sched_subframe = 4; + (tdd_sfa == 3)) sched_subframe = 4; + else if (tdd_sfa==6) sched_subframe = 7; else return; break; case 1: if ((tdd_sfa==0)|| (tdd_sfa==1)) sched_subframe = 7; else if (tdd_sfa==6) sched_subframe = 8; + else return; break; - default: - return; - case 2: // Don't schedule UL in subframe 2 for TDD return; case 3: @@ -1018,18 +1028,18 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, break; case 5: if (tdd_sfa==0) sched_subframe = 9; - else if (tdd_sfa==6) sched_subframe = 3; + else if (tdd_sfa==6) sched_subframe = 2; else return; break; case 6: - if (tdd_sfa==1) sched_subframe = 2; + if (tdd_sfa==0 || tdd_sfa==1) sched_subframe = 2; else if (tdd_sfa==6) sched_subframe = 3; else return; break; case 7: return; case 8: - if ((tdd_sfa>=2) || (tdd_sfa<=5)) sched_subframe=2; + if ((tdd_sfa>=2) && (tdd_sfa<=5)) sched_subframe=2; else return; break; case 9: @@ -1039,7 +1049,7 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, break; } } - + if (sched_subframe < subframeP) sched_frame++; #ifndef UE_EXPANSION for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { @@ -1089,10 +1099,25 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, for (i=0; i<NB_RA_PROC_MAX; i++) { if ((cc->ra[i].state == WAITMSG3) &&(cc->ra[i].Msg3_subframe == sched_subframe)) { ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_MSG3; - if(frame_parms->N_RB_UL == 25){ - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; - }else{ - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 2; + if (cc->tdd_Config == NULL) { + if(frame_parms->N_RB_UL == 25){ + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; + }else{ + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 2; + } + } else { + switch(frame_parms->N_RB_UL){ + case 25: + default: + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; + break; + case 50: + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 2; + break; + case 100: + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 3; + break; + } } ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = 1; ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = -1; @@ -1149,11 +1174,12 @@ schedule_ulsch_rnti(module_id_t module_idP, UE_sched_ctrl *UE_sched_ctrl; int sched_frame = frameP; int rvidx_tab[4] = { 0, 2, 3, 1 }; - + uint16_t ul_req_index; + uint8_t dlsch_flag; if (sched_subframeP < subframeP) sched_frame++; - nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_id]; + nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_id][subframeP]; nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; @@ -1161,7 +1187,7 @@ schedule_ulsch_rnti(module_id_t module_idP, nfapi_ul_config_request_body_t *ul_req_tmp_body = &ul_req_tmp->ul_config_request_body; //LOG_D(MAC, "entering ulsch preprocesor\n"); - ulsch_scheduler_pre_processor(module_idP, frameP, subframeP, first_rb); + ulsch_scheduler_pre_processor(module_idP, frameP, subframeP,sched_subframeP, first_rb); //LOG_D(MAC, "exiting ulsch preprocesor\n"); @@ -1463,9 +1489,10 @@ schedule_ulsch_rnti(module_id_t module_idP, cqi_req; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; hi_dci0_req_body->number_of_dci++; - hi_dci0_req_body->sfnsf = sfnsf_add_subframe(frameP, subframeP, 4); + hi_dci0_req_body->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4) hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! @@ -1476,9 +1503,17 @@ schedule_ulsch_rnti(module_id_t module_idP, "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", harq_pid, frameP, subframeP, UE_id, rnti, sched_frame, sched_subframeP); - + ul_req_index = 0; + dlsch_flag = 0; + for(ul_req_index = 0;ul_req_index < ul_req_tmp_body->number_of_pdus;ul_req_index++){ + if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE){ + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); + break; + } + } // Add UL_config PDUs - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, first_rb[CC_id], // resource_block_start + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, first_rb[CC_id], // resource_block_start rb_table[rb_table_index], // number_of_resource_blocks UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms 0, // frequency_hopping_enabled_flag @@ -1496,22 +1531,31 @@ schedule_ulsch_rnti(module_id_t module_idP, [rb_table_index])); #ifdef Rel14 if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions 1, //repetition_number (frameP * 10) + subframeP); } #endif + if(dlsch_flag == 1){ + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information,subframeP); + }else{ + ul_req_tmp_body->number_of_pdus++; + } ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req_tmp_body->number_of_pdus++; + ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; mac->ul_handle++; uint16_t ul_sched_frame = sched_frame; uint16_t ul_sched_subframeP = sched_subframeP; - add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); + // add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); ul_req_tmp->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; add_ue_ulsch_info(module_idP, @@ -1563,7 +1607,16 @@ schedule_ulsch_rnti(module_id_t module_idP, "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", harq_pid, frameP, subframeP, UE_id, rnti, sched_frame, sched_subframeP); - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, UE_template->first_rb_ul[harq_pid], // resource_block_start + ul_req_index = 0; + dlsch_flag = 0; + for(ul_req_index = 0;ul_req_index < ul_req_tmp_body->number_of_pdus;ul_req_index++){ + if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE){ + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); + break; + } + } + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, UE_template->first_rb_ul[harq_pid], // resource_block_start UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms 0, // frequency_hopping_enabled_flag @@ -1578,14 +1631,23 @@ schedule_ulsch_rnti(module_id_t module_idP, TBS_UL[harq_pid]); #ifdef Rel14 if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_tmp_body->number_of_pdus], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions 1, //repetition_number (frameP * 10) + subframeP); } #endif - ul_req_tmp_body->number_of_pdus++; + if(dlsch_flag == 1){ + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = UE_template->nb_rb_ul[harq_pid]; + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information,subframeP); + }else{ + ul_req_tmp_body->number_of_pdus++; + } + mac->ul_handle++; ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; @@ -1658,50 +1720,94 @@ void schedule_ulsch_rnti(module_id_t module_idP, UE_sched_ctrl *UE_sched_ctrl; int sched_frame=frameP; int rvidx_tab[4] = {0,2,3,1}; - + uint16_t ul_req_index; + uint8_t dlsch_flag; if (sched_subframeP < subframeP) sched_frame++; - nfapi_hi_dci0_request_body_t *hi_dci0_req = &eNB->HI_DCI0_req[module_idP].hi_dci0_request_body; + nfapi_hi_dci0_request_body_t *hi_dci0_req; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - nfapi_ul_config_request_body_t *ul_req_tmp = &eNB->UL_req_tmp[module_idP][sched_subframeP].ul_config_request_body; + nfapi_ul_config_request_body_t *ul_req_tmp; LOG_D(MAC,"entering ulsch preprocesor\n"); ulsch_scheduler_pre_processor(module_idP, frameP, subframeP, + sched_subframeP, ulsch_ue_select); LOG_D(MAC,"exiting ulsch preprocesor\n"); - eNB->HI_DCI0_req[module_idP].sfn_sf = (frameP<<4)+subframeP; + // loop over all active UEs for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + eNB->HI_DCI0_req[CC_id][subframeP].sfn_sf = (frameP<<4)+subframeP; + ul_req_tmp = &eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body; + nfapi_ul_config_request_t *ul_req = &eNB->UL_req_tmp[CC_id][sched_subframeP]; + ULSCH_first_end = 0; cc = &eNB->common_channels[CC_id]; // This is the actual CC_id in the list N_RB_UL = to_prb(cc->mib->message.dl_Bandwidth); //leave out first RB for PUCCH - if(N_RB_UL == 25){ - first_rb[CC_id] = 1; - }else{ - first_rb[CC_id] = 2; + if (cc->tdd_Config == NULL) { + if(N_RB_UL == 25){ + first_rb[CC_id] = 1; + }else{ + first_rb[CC_id] = 2; + } + }else { + switch(N_RB_UL){ + case 25: + default: + first_rb[CC_id] = 1; + break; + case 50: + first_rb[CC_id] = 2; + break; + case 100: + first_rb[CC_id] = 3; + break; + } } for ( ulsch_ue_num = 0; ulsch_ue_num < ulsch_ue_select[CC_id].ue_num; ulsch_ue_num++ ) { UE_id = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; /* be sure that there are some free RBs */ - if(N_RB_UL == 25){ - if (first_rb[CC_id] >= N_RB_UL-1) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - break; - } - }else{ - if (first_rb[CC_id] >= N_RB_UL-2) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - break; + if (cc->tdd_Config == NULL){ + if(N_RB_UL == 25){ + if (first_rb[CC_id] >= N_RB_UL-1) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id); + break; + } + }else{ + if (first_rb[CC_id] >= N_RB_UL-2) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id); + break; + } + } + } else { + if(N_RB_UL == 25){ + if (first_rb[CC_id] >= N_RB_UL-1) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb); + break; + } + }else if(N_RB_UL == 50){ + if (first_rb[CC_id] >= N_RB_UL-2) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb); + break; + } + }else if(N_RB_UL == 100){ + if (first_rb[CC_id] >= N_RB_UL-3) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb); + break; + } } } //MSG3 @@ -1762,7 +1868,6 @@ void schedule_ulsch_rnti(module_id_t module_idP, } else { tpc = 1; //0 } - if (tpc!=1) { LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", module_idP,frameP,subframeP,harq_pid,tpc, @@ -1816,18 +1921,18 @@ void schedule_ulsch_rnti(module_id_t module_idP, VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled); // adjust total UL buffer status by TBS, wait for UL sdus to do final update - LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,UE_template->TBS_UL[harq_pid]); + /*LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,UE_template->TBS_UL[harq_pid]); if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid]) UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid]; else UE_template->ul_total_buffer = 0; - LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer); + LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer);*/ // Cyclic shift for DM RS cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) // save it for a potential retransmission UE_template->cshift[harq_pid] = cshift; - hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci+eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi]; + hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); @@ -1844,14 +1949,29 @@ void schedule_ulsch_rnti(module_id_t module_idP, hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; - eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++; + hi_dci0_req->number_of_dci++; + hi_dci0_req->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4) + hi_dci0_req->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + nfapi_hi_dci0_request_t *nfapi_hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP]; + nfapi_hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! + nfapi_hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); + ul_req_index = 0; + dlsch_flag = 0; + for(ul_req_index = 0;ul_req_index < ul_req_tmp->number_of_pdus;ul_req_index++){ + if(ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE){ + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); + break; + } + } // Add UL_config PDUs - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, @@ -1875,15 +1995,29 @@ void schedule_ulsch_rnti(module_id_t module_idP, ); #ifdef Rel14 if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type>2 ? 2 : 1, 1, //total_number_of_repetitions 1, //repetition_number (frameP*10)+subframeP); } #endif - ul_req_tmp->number_of_pdus++; + if(dlsch_flag == 1){ + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information,subframeP); + }else{ + ul_req_tmp->number_of_pdus++; + } eNB->ul_handle++; + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + uint16_t ul_sched_frame = sched_frame; + uint16_t ul_sched_subframeP = sched_subframeP; + add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); + ul_req->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; add_ue_ulsch_info(module_idP, CC_id, @@ -1896,14 +2030,19 @@ void schedule_ulsch_rnti(module_id_t module_idP, // increment first rb for next UE allocation first_rb[CC_id]+=rb_table[rb_table_index]; if(ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) { + LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,UE_template->TBS_UL[harq_pid]); if(ulsch_ue_select[CC_id].list[ulsch_ue_num].ul_total_buffer > 0){ + LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", + module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,UE_template->TBS_UL[harq_pid]); if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid]) UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid]; else UE_template->ul_total_buffer = 0; + LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer); } else { UE_template->ul_SR = 0; } + LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer); } if((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE) && (ULSCH_first_end == 0)) { ULSCH_first_end = 1; @@ -1922,15 +2061,20 @@ void schedule_ulsch_rnti(module_id_t module_idP, round = UE_sched_ctrl->round_UL[CC_id][harq_pid]; UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; - + uint8_t mcs_rv = 0; + if(rvidx_tab[round&3]==1){ + mcs_rv = 29; + }else if(rvidx_tab[round&3]==2){ + mcs_rv = 30; + }else if(rvidx_tab[round&3]==3){ + mcs_rv = 31; + } UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb); UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", - module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,UE_template->mcs_UL[harq_pid], - first_rb[CC_id],rb_table[rb_table_index], - rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); + module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs_rv,first_rb[CC_id],rb_table[rb_table_index],rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) //store for possible retransmission @@ -1941,7 +2085,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, // Cyclic shift for DM RS cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) - hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci+eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi]; + hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); @@ -1951,15 +2095,16 @@ void schedule_ulsch_rnti(module_id_t module_idP, hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = mcs_rv; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = UE_template->oldNDI_UL[harq_pid]; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; - eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++; + hi_dci0_req->number_of_dci++; // fill in NAK information hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); @@ -1969,15 +2114,30 @@ void schedule_ulsch_rnti(module_id_t module_idP, hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = UE_template->cshift[harq_pid]; hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; hi_dci0_req->number_of_hi++; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; + + hi_dci0_req->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4) + nfapi_hi_dci0_request_t *nfapi_hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP]; + nfapi_hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! + nfapi_hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) UE %d (mcs %d, first rb %d, nb_rb %d, TBS %d, round %d)\n", - module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,UE_template->mcs_UL[harq_pid], + module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs_rv, ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb, ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb, UE_template->TBS_UL[harq_pid],round); // Add UL_config PDUs LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], + ul_req_index = 0; + dlsch_flag = 0; + for(ul_req_index = 0;ul_req_index < ul_req_tmp->number_of_pdus;ul_req_index++){ + if(ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE){ + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(phich)\n",frameP,subframeP,rnti,ul_req_index); + break; + } + } + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, @@ -1996,20 +2156,31 @@ void schedule_ulsch_rnti(module_id_t module_idP, 0, // ul_tx_mode 0, // current_tx_nb 0, // n_srs - get_TBS_UL(UE_template->mcs_UL[harq_pid], - ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb) + UE_template->TBS_UL[harq_pid] ); #ifdef Rel14 if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type>2 ? 2 : 1, 1, //total_number_of_repetitions 1, //repetition_number (frameP*10)+subframeP); } #endif - ul_req_tmp->number_of_pdus++; + if(dlsch_flag == 1){ + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information,subframeP); + }else{ + ul_req_tmp->number_of_pdus++; + } eNB->ul_handle++; + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_req->sfn_sf = sched_frame<<4|sched_subframeP; + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0(round >0)\n", module_idP,CC_id,frameP,subframeP,UE_id); // increment first rb for next UE allocation diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 3a491bd7ea8488d31953d8084935517a6ab81e19..bf1db6c613a32b768fe96fdf382945c7df6aabb8 100644 --- a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c +++ b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c @@ -1277,7 +1277,7 @@ flexran_schedule_ue_spec_common(mid_t mod_id, PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD) { UE_list->UE_template[CC_id][UE_id].DAI++; update_ul_dci(mod_id, CC_id, rnti, - UE_list->UE_template[CC_id][UE_id].DAI); + UE_list->UE_template[CC_id][UE_id].DAI,subframe); LOG_D(MAC, "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", CC_id, subframe, UE_id, @@ -1642,7 +1642,7 @@ flexran_schedule_ue_spec_common(mid_t mod_id, //#warning only for 5MHz channel update_ul_dci(mod_id, CC_id, rnti, UE_list->UE_template[CC_id][UE_id]. - DAI); + DAI,frame); } // do PUCCH power control // this is the normalized RX power diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c index 2ad3e6a038beb82b26e41deb647add79ed44317c..b067d87cd42d0c013785382e12802e6fc964480d 100644 --- a/openair2/LAYER2/MAC/main.c +++ b/openair2/LAYER2/MAC/main.c @@ -158,9 +158,10 @@ void mac_top_init_eNB(void) RC.mac[i]->UL_req_tmp[j][k]. ul_config_request_body.ul_config_pdu_list = RC.mac[i]->ul_config_pdu_list_tmp[j][k]; - RC.mac[i]->HI_DCI0_req[j]. - hi_dci0_request_body.hi_dci0_pdu_list = - RC.mac[i]->hi_dci0_pdu_list[j]; + for(int sf=0;sf<10;sf++){ + RC.mac[i]->HI_DCI0_req[j][sf].hi_dci0_request_body.hi_dci0_pdu_list =RC.mac[i]->hi_dci0_pdu_list[j][sf]; + } + RC.mac[i]->TX_req[j].tx_request_body.tx_pdu_list = RC.mac[i]->tx_request_pdu[j]; RC.mac[i]->ul_handle = 0; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 49cdbb1769a2b33d90f1be28f579562ded75076c..7429489334df4375931923e31b7a013cf2bee7e0 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -299,10 +299,8 @@ maxround(module_id_t Mod_id, uint16_t rnti, int frame, cc = &RC.mac[Mod_id]->common_channels[CC_id]; UE_id = find_UE_id(Mod_id, rnti); - if (cc->tdd_Config) - harq_pid = ((frame * 10) + subframe) % 10; - else - harq_pid = ((frame * 10) + subframe) & 7; + + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frame ,subframe); round = UE_list->UE_sched_ctrl[UE_id].round[CC_id][harq_pid]; if (round > round_max) { @@ -676,8 +674,7 @@ void dlsch_scheduler_pre_ue_select( continue; } #endif - if (cc[CC_id].tdd_Config) harq_pid = ((frameP*10)+subframeP)%10; - else harq_pid = ((frameP*10)+subframeP)&7; + harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP ,subframeP); round = ue_sched_ctl->round[CC_id][harq_pid]; if (round != 8) { // retransmission @@ -791,8 +788,7 @@ void dlsch_scheduler_pre_ue_select( if(i < dlsch_ue_select[CC_id].ue_num) continue; - if (cc[CC_id].tdd_Config) harq_pid = ((frameP*10)+subframeP)%10; - else harq_pid = ((frameP*10)+subframeP)&7; + harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP ,subframeP); round = ue_sched_ctl->round[CC_id][harq_pid]; if (round == 8) { @@ -905,8 +901,7 @@ void dlsch_scheduler_pre_ue_select( if(i < dlsch_ue_select[CC_id].ue_num) continue; - if (cc[CC_id].tdd_Config) harq_pid = ((frameP*10)+subframeP)%10; - else harq_pid = ((frameP*10)+subframeP)&7; + harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP ,subframeP); round = ue_sched_ctl->round[CC_id][harq_pid]; if (round == 8) { @@ -1128,8 +1123,7 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, rnti = dlsch_ue_select[CC_id].list[i].rnti; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - if (cc->tdd_Config) harq_pid = ((frameP*10)+subframeP)%10; - else harq_pid = ((frameP*10)+subframeP)&7; + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); Round = ue_sched_ctl->round[CC_id][harq_pid]; //if (mac_eNB_get_rrc_status(Mod_id, rnti) < RRC_RECONFIGURED || round > 0) { @@ -1188,10 +1182,7 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, CC_id = UE_list->ordered_CCids[ii][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; cc = &RC.mac[Mod_id]->common_channels[ii]; - if (cc->tdd_Config) - harq_pid = ((frameP * 10) + subframeP) % 10; - else - harq_pid = ((frameP * 10) + subframeP) & 7; + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); round = ue_sched_ctl->round[CC_id][harq_pid]; average_rbs_per_user[CC_id] = 0; @@ -1866,6 +1857,7 @@ dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, sub_frame_t subframeP, + unsigned char sched_subframeP, uint16_t *first_rb) { @@ -1997,7 +1989,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, harq_pid = subframe2harqpid(&RC.mac[module_idP]-> common_channels[CC_id], frameP, - subframeP); + sched_subframeP); // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); @@ -2396,6 +2388,7 @@ void ulsch_scheduler_pre_ue_select( module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, + sub_frame_t sched_subframeP, ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) { eNB_MAC_INST *eNB=RC.mac[module_idP]; @@ -2426,7 +2419,7 @@ void ulsch_scheduler_pre_ue_select( for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { //save ulsch dci number - saved_ulsch_dci[CC_id] = eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci; + saved_ulsch_dci[CC_id] = eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body.number_of_dci; // maximum multiplicity number ulsch_ue_max_num[CC_id] =RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id]; @@ -2452,7 +2445,7 @@ void ulsch_scheduler_pre_ue_select( continue; // UL DCI - HI_DCI0_req = &eNB->HI_DCI0_req[CC_id].hi_dci0_request_body; + HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { cc_id_flag[CC_id] = 1; HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; @@ -2467,7 +2460,7 @@ void ulsch_scheduler_pre_ue_select( cc = &eNB->common_channels[CC_id]; //harq_pid - harq_pid = subframe2harqpid(cc,(frameP+(subframeP>=6 ? 1 : 0)),((subframeP+4)%10)); + harq_pid = subframe2harqpid(cc,(frameP+(sched_subframeP<subframeP ? 1 : 0)),sched_subframeP); //round round = UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]; @@ -2505,21 +2498,35 @@ void ulsch_scheduler_pre_ue_select( ue_first_num[CC_id]++; continue; } - if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id] ) < ulsch_ue_max_num[CC_id] ) { + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + if ( ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { + first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; + first_ue_total[CC_id] [ue_first_num[CC_id]] = 0; + ue_first_num[CC_id]++; + continue; + } + /*if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id] ) < ulsch_ue_max_num[CC_id] ) { UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - if ( ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + uint8_t ul_period = 0; + if (cc->tdd_Config) { + ul_period = 50; + } else { + ul_period = 20; + } + if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; ul_inactivity_num[CC_id] ++; continue; } - } + }*/ } } for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { - HI_DCI0_req = &eNB->HI_DCI0_req[CC_id].hi_dci0_request_body; + HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; for ( int temp = 0; temp < ue_first_num[CC_id]; temp++ ) { if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { cc_id_flag[CC_id] = 1; @@ -2586,9 +2593,12 @@ void ulsch_scheduler_pre_ue_select( if(i < ulsch_ue_select[CC_id].ue_num) continue; - HI_DCI0_req = &eNB->HI_DCI0_req[CC_id].hi_dci0_request_body; + HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; //SR BSR - if ( (UE_list->UE_template[CC_id][UE_id].ul_total_buffer > 0) || (UE_list->UE_template[CC_id][UE_id].ul_SR > 0) ) { + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + if ( (UE_list->UE_template[CC_id][UE_id].ul_total_buffer > 0) || (UE_list->UE_template[CC_id][UE_id].ul_SR > 0) || + ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED)) ){ hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; format_flag = 2; if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { @@ -2611,22 +2621,28 @@ void ulsch_scheduler_pre_ue_select( } } //inactivity UE - if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id]) < ulsch_ue_max_num[CC_id] ) { +/* if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id]) < ulsch_ue_max_num[CC_id] ) { UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - if ( ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + uint8_t ul_period = 0; + if (cc->tdd_Config) { + ul_period = 50; + } else { + ul_period = 20; + } + if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; ul_inactivity_num[CC_id]++; continue; } - } + }*/ } for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { - HI_DCI0_req = &eNB->HI_DCI0_req[CC_id].hi_dci0_request_body; + HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; for ( int temp = 0; temp < ul_inactivity_num[CC_id]; temp++ ) { if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { - HI_DCI0_req = &eNB->HI_DCI0_req[CC_id].hi_dci0_request_body; + HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; cc_id_flag[CC_id] = 1; break; } @@ -2668,6 +2684,7 @@ uint8_t find_rb_table_index(uint8_t average_rbs) void ulsch_scheduler_pre_processor(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, + sub_frame_t sched_subframeP, ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) { int CC_id,ulsch_ue_num; @@ -2681,22 +2698,37 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, uint16_t first_rb[MAX_NUM_CCs]; uint8_t mcs; uint8_t rb_table_index; + uint8_t num_pucch_rb; uint32_t tbs; int16_t tx_power; int UE_id; rnti_t rnti; + COMMON_channels_t *cc; LOG_D(MAC,"In ulsch_preprocessor: ulsch ue select\n"); //ue select - ulsch_scheduler_pre_ue_select(module_idP,frameP,subframeP,ulsch_ue_select); + ulsch_scheduler_pre_ue_select(module_idP,frameP,subframeP,sched_subframeP,ulsch_ue_select); // MCS and RB assgin for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { + cc = &RC.mac[module_idP]->common_channels[CC_id]; frame_parms = &(RC.eNB[module_idP][CC_id]->frame_parms); - if(frame_parms->N_RB_UL == 25){ - first_rb[CC_id] = 1; - }else{ - first_rb[CC_id] = 2; - } + if (cc->tdd_Config) { //TDD + if (frame_parms->N_RB_UL == 25) { + num_pucch_rb = 1; + } else if (frame_parms->N_RB_UL == 50) { + num_pucch_rb = 2; + } else { + num_pucch_rb = 3; + } + } else {//FDD + if (frame_parms->N_RB_UL == 25) { + num_pucch_rb = 1; + } else { + num_pucch_rb = 2; + } + } + + first_rb[CC_id] = num_pucch_rb; ue_num_temp = ulsch_ue_select[CC_id].ue_num; for ( ulsch_ue_num = 0; ulsch_ue_num < ulsch_ue_select[CC_id].ue_num; ulsch_ue_num++ ) { @@ -2715,23 +2747,14 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, } rnti = UE_RNTI(CC_id,UE_id); - if(frame_parms->N_RB_UL == 25){ - if ( first_rb[CC_id] >= frame_parms->N_RB_UL-1 ){ - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - break; - } - // calculate the average rb ( remain UE) - total_rbs = frame_parms->N_RB_UL-1-first_rb[CC_id]; - }else{ - if ( first_rb[CC_id] >= frame_parms->N_RB_UL-2 ){ - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - break; - } - // calculate the average rb ( remain UE) - total_rbs = frame_parms->N_RB_UL-2-first_rb[CC_id]; + + if (first_rb[CC_id] >= frame_parms->N_RB_UL-num_pucch_rb ) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id); + break; } + total_rbs = frame_parms->N_RB_UL-num_pucch_rb-first_rb[CC_id]; + average_rbs = (int)round((double)total_rbs/(double)ue_num_temp); if ( average_rbs < 3 ) { ue_num_temp--; @@ -2771,30 +2794,22 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST ) { if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ul_total_buffer > 0 ) { rb_table_index = 2; - tbs = get_TBS_UL(mcs,rb_table[rb_table_index])<<3; - tx_power= estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); + tbs = get_TBS_UL(mcs,rb_table[rb_table_index]); + tx_power= estimate_ue_tx_power(tbs*8,rb_table[rb_table_index],0,frame_parms->Ncp,0); while ( (((UE_template->phr_info - tx_power) < 0 ) || (tbs > UE_template->ul_total_buffer)) && (mcs > 3) ) { mcs--; + tbs = get_TBS_UL(mcs,rb_table[rb_table_index]); + tx_power= estimate_ue_tx_power(tbs*8,rb_table[rb_table_index],0,frame_parms->Ncp,0); + } + + while ( (tbs < UE_template->ul_total_buffer) && (rb_table[rb_table_index]<(frame_parms->N_RB_UL-num_pucch_rb-first_rb[CC_id])) && + ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { + rb_table_index++; tbs = get_TBS_UL(mcs,rb_table[rb_table_index])<<3; tx_power= estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); } - if(frame_parms->N_RB_UL == 25){ - while ( (tbs < UE_template->ul_total_buffer) && (rb_table[rb_table_index]<(frame_parms->N_RB_UL-1-first_rb[CC_id])) && - ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { - rb_table_index++; - tbs = get_TBS_UL(mcs,rb_table[rb_table_index])<<3; - tx_power= estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); - } - }else{ - while ( (tbs < UE_template->ul_total_buffer) && (rb_table[rb_table_index]<(frame_parms->N_RB_UL-2-first_rb[CC_id])) && - ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { - rb_table_index++; - tbs = get_TBS_UL(mcs,rb_table[rb_table_index])<<3; - tx_power= estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); - } - } if ( rb_table[rb_table_index]<3 ) { rb_table_index=2; } diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index d42c8f38dcf647b4ec29c7a2db6371afc7316531..df094392f190ab97cd0c6d750275400d499bed8e 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -299,6 +299,9 @@ void cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, @param Msg3_frame frame where scheduling takes place @param Msg3_subframe subframe where scheduling takes place */ + +void clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP); + void set_msg3_subframe(module_id_t Mod_id, int CC_id, int frame, @@ -640,10 +643,10 @@ rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP); uint8_t find_rb_table_index(uint8_t average_rbs); #ifndef UE_EXPANSION -void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, sub_frame_t subframeP, uint16_t *first_rb); +void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, sub_frame_t subframeP, unsigned char sched_subframeP,uint16_t *first_rb); #else -void ulsch_scheduler_pre_processor(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]); -void ulsch_scheduler_pre_ue_select(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP,ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]); +void ulsch_scheduler_pre_processor(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, sub_frame_t sched_subframeP,ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]); +void ulsch_scheduler_pre_ue_select(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP,sub_frame_t sched_subframeP,ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]); #endif void set_ul_DAI( @@ -822,7 +825,7 @@ uint32_t allocate_prbs_sub(int nb_rb, int N_RB_DL, int N_RBG, uint8_t * rballoc); void update_ul_dci(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, - uint8_t dai); + uint8_t dai, sub_frame_t subframe); int get_bw_index(module_id_t module_id, uint8_t CC_id); @@ -1121,7 +1124,8 @@ void fill_nfapi_ulsch_harq_information(module_id_t module_idP, int CC_idP, uint16_t rntiP, nfapi_ul_config_ulsch_harq_information - * harq_information); + * harq_information, + sub_frame_t subframeP); uint16_t fill_nfapi_uci_acknak(module_id_t module_idP, int CC_idP, diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index f48a53636f8e00e85bebf07133ffa6ed8f82ae1b..28dba58a3edff319441342d9da1d2ade5bd711c1 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -71,10 +71,15 @@ fill_rar(const module_id_t module_idP, ra->timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps rar[0] = (uint8_t) (ra->timing_offset >> (2 + 4)); // 7 MSBs of timing advance + divide by 4 rar[1] = (uint8_t) (ra->timing_offset << (4 - 2)) & 0xf0; // 4 LSBs of timing advance + divide by 4 + COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id]; if(N_RB_UL == 25){ ra->msg3_first_rb = 1; }else{ - ra->msg3_first_rb = 2; + if (cc->tdd_Config && N_RB_UL == 100) { + ra->msg3_first_rb = 3; + } else { + ra->msg3_first_rb = 2; + } } ra->msg3_nb_rb = 1; uint16_t rballoc = mac_computeRIV(N_RB_UL, ra->msg3_first_rb, ra->msg3_nb_rb); // first PRB only for UL Grant @@ -84,6 +89,7 @@ fill_rar(const module_id_t module_idP, ra->msg3_TPC = 3; ra->msg3_ULdelay = 0; ra->msg3_cqireq = 0; + ra->msg3_round = 0; rar[2] |= ((ra->msg3_mcs & 0x8) >> 3); // mcs 10 rar[3] = (((ra->msg3_mcs & 0x7) << 5)) | ((ra->msg3_TPC & 7) << 2) | diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index 881c7b14ccacb87beda77987e020df08e5b47bb2..6f1516d3b99ff3a3e58dda785f7eb8db3ed61f33 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -509,6 +509,7 @@ rlc_am_rx ( default: LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" TX UNKNOWN PROTOCOL STATE 0x%02X\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP, rlc), rlc->protocol_state); + list_free (&data_indP.data); } } @@ -551,7 +552,9 @@ rlc_am_mac_status_indication ( rlc->last_absolute_subframe_status_indication = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); - rlc->nb_bytes_requested_by_mac = tb_sizeP; + if (tb_sizeP > 0) { + rlc->nb_bytes_requested_by_mac = tb_sizeP; + } status_resp.buffer_occupancy_in_bytes = rlc_am_get_buffer_occupancy_in_bytes(ctxt_pP, rlc); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c index b1facdfb023671b9e948280b6031c1ade079e285..42bdd56e77583b741deb1efd1d97a6d78b933a47 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c @@ -396,14 +396,20 @@ rlc_am_receive_process_data_pdu ( } if (pdu_info_p->sn == rlc_pP->vr_r) { +mem_block_t* cursor_p = rlc_pP->receiver_buffer.head; +rlc_am_rx_pdu_management_t * pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); +if( (((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received) == (pdu_cursor_mgnt_p->all_segments_received)){ if (((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received) { rlc_am_rx_update_vr_r(ctxt_pP, rlc_pP, tb_pP); rlc_pP->vr_mr = (rlc_pP->vr_r + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; } - reassemble = rlc_am_rx_check_vr_reassemble(ctxt_pP, rlc_pP); //TODO : optimization : check whether a reassembly is needed by looking at LI, FI, SO, etc... - +}else{ + LOG_E(RLC, "BAD all_segments_received!!! discard buffer!!!\n"); + /* Discard received block if out of window, duplicate or header error */ + free_mem_block (tb_pP, __func__); +} } //FNA: fix check VrX out of receiving window diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c index 7bd0da83a903e40f909f8538a73d5f1c7c192232..864921ff8850dbe239f524fb5c89eb0850174b32 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -421,6 +421,7 @@ rlc_um_rx (const protocol_ctxt_t* const ctxt_pP, void *argP, struct mac_data_ind LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" TX UNKNOWN PROTOCOL STATE %02X hex\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,l_rlc_p), l_rlc_p->protocol_state); + list_free (&data_indP.data); } } diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index d27d46ff4282b4ca3488a85ffb649f6f5d7d80ee..d25b30e7cc56b3dee8cfff62b736939bbff0c5c5 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -431,6 +431,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, return RLC_OP_STATUS_OK; } else { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); + free_mem_block(sdu_pP, __func__); return RLC_OP_STATUS_INTERNAL_ERROR; } @@ -455,6 +456,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, return RLC_OP_STATUS_OK; } else { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); + free_mem_block(sdu_pP, __func__); return RLC_OP_STATUS_INTERNAL_ERROR; } @@ -477,6 +479,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, } else { //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : out of memory\n", __FILE__, __LINE__); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); + free_mem_block(sdu_pP, __func__); return RLC_OP_STATUS_INTERNAL_ERROR; } @@ -511,6 +514,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, return RLC_OP_STATUS_OK; } else { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_DATA_REQ,VCD_FUNCTION_OUT); + free_mem_block(sdu_pP, __func__); return RLC_OP_STATUS_BAD_PARAMETER; } } else { diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index 5e5f0161da6477bf2ae96db31ac6a64094ee3a8d..da9c29c4dee2dcb747cde6b3806eb103169e45c2 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -280,6 +280,7 @@ void mac_rlc_data_ind ( switch (rlc_mode) { case RLC_MODE_NONE: //handle_event(WARNING,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no radio bearer configured :%d\n", __FILE__, __LINE__, channel_idP); + list_free (&data_ind.data); break; case RLC_MODE_AM: diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index d0b8e5755858bbaf3ac64711016a8debce09b04c..175fcb2e67f472463c66d65de42b14b56add155c 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -17,7 +17,7 @@ extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind); extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); extern uint8_t nfapi_mode; extern uint16_t sf_ahead; - +uint16_t frame_cnt=0; void handle_rach(UL_IND_t *UL_info) { int i; @@ -546,6 +546,10 @@ void UL_indication(UL_IND_t *UL_info) UL_info->frame,UL_info->subframe, module_id,CC_id, UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->harq_ind.harq_indication_body.number_of_harqs, UL_info->crc_ind.crc_indication_body.number_of_crcs, UL_info->cqi_ind.number_of_cqis, UL_info->rach_ind.rach_indication_body.number_of_preambles, UL_info->sr_ind.sr_indication_body.number_of_srs); + if(UL_info->frame==1023&&UL_info->subframe==6){ // dl scheduling (0,0) + frame_cnt= (frame_cnt + 1)%7; // to prevent frame_cnt get too big + LOG_D(MAC,"current (%d,%d) frame count dl is %d\n",UL_info->frame,UL_info->subframe,frame_cnt); + } if (nfapi_mode != 1) { @@ -574,7 +578,11 @@ void UL_indication(UL_IND_t *UL_info) handle_harq(UL_info); // clear HI prior to handling ULSCH - mac->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi = 0; + uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_id] , UL_info->subframe); + if(sf_ahead_dl!=255){ + mac->HI_DCI0_req[CC_id][(UL_info->subframe+sf_ahead_dl)%10].hi_dci0_request_body.number_of_hi = 0; + LOG_D(MAC,"current (%d,%d) clear HI_DCI0_req[0][%d]\n",UL_info->frame,UL_info->subframe,(UL_info->subframe+sf_ahead_dl)%10); + } handle_ulsch(UL_info); @@ -593,9 +601,9 @@ void UL_indication(UL_IND_t *UL_info) sched_info->frame = (UL_info->frame + ((UL_info->subframe>(9-sf_ahead)) ? 1 : 0)) % 1024; sched_info->subframe = (UL_info->subframe+sf_ahead)%10; sched_info->DL_req = &mac->DL_req[CC_id]; - sched_info->HI_DCI0_req = &mac->HI_DCI0_req[CC_id]; + sched_info->HI_DCI0_req = &mac->HI_DCI0_req[CC_id][sched_info->subframe]; if ((mac->common_channels[CC_id].tdd_Config==NULL) || - (is_UL_sf(&mac->common_channels[CC_id],(sched_info->subframe+sf_ahead)%10)>0)) + (is_UL_sf(&mac->common_channels[CC_id],sched_info->subframe)>0)) sched_info->UL_req = &mac->UL_req[CC_id]; else sched_info->UL_req = NULL; diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index 94d8c17f0a640d5e26acab1be46e965588a8b170..724b30a3d194c2feb50aa7d9621f3a7da0c24bbc 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -1267,6 +1267,10 @@ do_RRCConnectionSetup( RRCConnectionSetup_t* rrcConnectionSetup = NULL; +#ifdef UE_EXPANSION + LTE_DL_FRAME_PARMS *frame_parms = &RC.eNB[ctxt_pP->module_id][CC_id]->frame_parms; +#endif + memset((void *)&dl_ccch_msg,0,sizeof(DL_CCCH_Message_t)); dl_ccch_msg.message.present = DL_CCCH_MessageType_PR_c1; dl_ccch_msg.message.choice.c1.present = DL_CCCH_MessageType__c1_PR_rrcConnectionSetup; @@ -1533,7 +1537,28 @@ do_RRCConnectionSetup( physicalConfigDedicated2->schedulingRequestConfig->present = SchedulingRequestConfig_PR_setup; #ifdef UE_EXPANSION - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 31 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; + if (carrier->sib1->tdd_Config == NULL) { + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 31 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; + } else { + switch (carrier->sib1->tdd_Config->subframeAssignment) { + case 1: + switch(frame_parms->N_RB_UL){ + case 25: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 15 - ue_context_pP->local_uid/4; + break; + case 50: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 31 - ue_context_pP->local_uid/4; + break; + case 100: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 63 - ue_context_pP->local_uid/4; + break; + } + break; + default: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; + break; + } + } #else physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; #endif diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c index f44886dcc577bbd99af6646efc14cee5e133ef8b..adf213de0f3e3b04f38d6db81fbad446d0b053b6 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LITE/rrc_common.c @@ -348,7 +348,7 @@ rrc_rx_tx( } 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 >= 8) { + 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; @@ -513,14 +513,14 @@ rrc_rx_tx( } } if (ue_to_be_removed) { - if(ue_to_be_removed->ue_context.ul_failure_timer >= 8) { + if(ue_to_be_removed->ue_context.ul_failure_timer >= 20000) { ue_to_be_removed->ue_context.ue_release_timer_s1 = 1; ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 200; ue_to_be_removed->ue_context.ue_release_timer = 0; ue_to_be_removed->ue_context.ue_reestablishment_timer = 0; } rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed); - if(ue_to_be_removed->ue_context.ul_failure_timer >= 8){ + if(ue_to_be_removed->ue_context.ul_failure_timer >= 20000){ ue_to_be_removed->ue_context.ul_failure_timer = 0; } } diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index b7c17259ccd0d638cb9d35580328f4d882a8f77f..6c4413318f34d777f7aa0d548957293d66e16169 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -825,7 +825,7 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", enb_mod_idP, rnti); #if defined(ENABLE_USE_MME) - if( ue_context_pP->ue_context.ul_failure_timer >= 8 ) { + if( ue_context_pP->ue_context.ul_failure_timer >= 20000 ) { LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ RNTI %x\n", enb_mod_idP, rnti); rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) @@ -844,15 +844,24 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* ulsch = eNB_PHY->ulsch[i]; if((ulsch != NULL) && (ulsch->rnti == rnti)){ LOG_I(RRC, "clean_eNb_ulsch UE %x \n", rnti); - clean_eNb_ulsch(ulsch); + //clean_eNb_ulsch(ulsch); + ulsch->rnti = 0; } - } - for (i=0; i<NUMBER_OF_UE_MAX; i++) { dlsch = eNB_PHY->dlsch[i][0]; if((dlsch != NULL) && (dlsch->rnti == rnti)){ LOG_I(RRC, "clean_eNb_dlsch UE %x \n", rnti); clean_eNb_dlsch(dlsch); } + if(eNB_PHY->uci_vars[i].rnti == rnti){ + LOG_I(MAC, "clean eNb uci_vars[%d] UE %x \n",i, rnti); + memset(&eNB_PHY->uci_vars[i],0,sizeof(LTE_eNB_UCI)); + } + } + ulsch = eNB_PHY->ulsch[i]; + if((ulsch != NULL) && (ulsch->rnti == rnti)){ + LOG_I(RRC, "clean_eNb_ulsch UE %x \n", rnti); + //clean_eNb_ulsch(ulsch); + ulsch->rnti = 0; } for(j = 0; j < 10; j++){ @@ -860,12 +869,16 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* if(ul_req_tmp){ pdu_number = ul_req_tmp->number_of_pdus; for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ - if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){ - LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); - if(pdu_index < pdu_number -1){ - memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); - } - ul_req_tmp->number_of_pdus--; + if((ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_cqi_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].srs_pdu.srs_pdu_rel8.rnti == rnti)){ + LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); + if(pdu_index < pdu_number -1){ + memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + } + ul_req_tmp->number_of_pdus--; } } } @@ -917,6 +930,7 @@ void release_UE_in_freeList(module_id_t mod_id) int i, j , CC_id, pdu_number; protocol_ctxt_t ctxt; LTE_eNB_ULSCH_t *ulsch = NULL; + LTE_eNB_DLSCH_t *dlsch = NULL; nfapi_ul_config_request_body_t *ul_req_tmp = NULL; PHY_VARS_eNB *eNB_PHY = NULL; struct rrc_eNB_ue_context_s *ue_context_pP = NULL; @@ -945,12 +959,23 @@ void release_UE_in_freeList(module_id_t mod_id) PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, rnti, 0, 0,mod_id); for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { eNB_PHY = RC.eNB[mod_id][CC_id]; - for (i=0; i<=NUMBER_OF_UE_MAX; i++) { + for (i=0; i<NUMBER_OF_UE_MAX; i++) { ulsch = eNB_PHY->ulsch[i]; if((ulsch != NULL) && (ulsch->rnti == rnti)){ - LOG_I(RRC, "clean_eNb_ulsch ulsch[%d] UE %x\n", i, rnti); - clean_eNb_ulsch(ulsch); - } + LOG_I(RRC, "clean_eNb_ulsch ulsch[%d] UE %x\n", i, rnti); + clean_eNb_ulsch(ulsch); + } + if(eNB_PHY->uci_vars[i].rnti == rnti){ + LOG_I(MAC, "clean eNb uci_vars[%d] UE %x \n",i, rnti); + memset(&eNB_PHY->uci_vars[i],0,sizeof(LTE_eNB_UCI)); + } + } + for (i=0; i<NUMBER_OF_UE_MAX; i++) { + dlsch = eNB_PHY->dlsch[i][0]; + if((dlsch != NULL) && (dlsch->rnti == rnti)){ + LOG_I(RRC, "clean_eNb_dlsch dlsch[%d] UE %x \n", i, rnti); + clean_eNb_dlsch(dlsch); + } } for(j = 0; j < 10; j++){ @@ -958,12 +983,16 @@ void release_UE_in_freeList(module_id_t mod_id) if(ul_req_tmp){ pdu_number = ul_req_tmp->number_of_pdus; for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ - if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){ - LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); - if(pdu_index < pdu_number -1){ - memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); - } - ul_req_tmp->number_of_pdus--; + if((ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_cqi_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].srs_pdu.srs_pdu_rel8.rnti == rnti)){ + LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); + if(pdu_index < pdu_number -1){ + memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + } + ul_req_tmp->number_of_pdus--; } } } @@ -1371,8 +1400,10 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[xid]; // get old configuration of SRB2 if (*SRB_configList2 != NULL) { - LOG_D(RRC, "SRB_configList2(%p) count is %d\n SRB_configList2->list.array[0] addr is %p", + if((*SRB_configList2)->list.count!=0){ + LOG_D(RRC, "SRB_configList2(%p) count is %d\n SRB_configList2->list.array[0] addr is %p", SRB_configList2, (*SRB_configList2)->list.count, (*SRB_configList2)->list.array[0]); + } for (i = 0; (i < (*SRB_configList2)->list.count) && (i < 3); i++) { if ((*SRB_configList2)->list.array[i]->srb_Identity == 2 ){ LOG_D(RRC, "get SRB2_config from (ue_context_pP->ue_context.SRB_configList2[%d])\n", xid); @@ -1384,9 +1415,13 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[next_xid]; DRB_configList2 = &ue_context_pP->ue_context.DRB_configList2[next_xid]; - if (*SRB_configList2) { - free(*SRB_configList2); - LOG_D(RRC, "free(ue_context_pP->ue_context.SRB_configList2[%d])\n", next_xid); + if(SRB_configList2!=NULL){ + if (*SRB_configList2) { + free(*SRB_configList2); + LOG_D(RRC, "free(ue_context_pP->ue_context.SRB_configList2[%d])\n", next_xid); + } + }else{ + LOG_E(RRC, "SRB_configList2 is null\n"); } *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2)); if (SRB2_config != NULL) { @@ -1406,9 +1441,13 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( - if (*DRB_configList2) { - free(*DRB_configList2); - LOG_D(RRC, "free(ue_context_pP->ue_context.DRB_configList2[%d])\n", next_xid); + if(DRB_configList2!=NULL){ + if (*DRB_configList2) { + free(*DRB_configList2); + LOG_D(RRC, "free(ue_context_pP->ue_context.DRB_configList2[%d])\n", next_xid); + } + }else{ + LOG_E(RRC, "DRB_configList2 is null\n"); } *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); @@ -1448,7 +1487,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req)); for (j = 0, i = 0; i < NB_RB_MAX; i++) { - if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED) { + if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED || ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_DONE) { create_tunnel_req.eps_bearer_id[j] = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; create_tunnel_req.sgw_S1u_teid[j] = ue_context_pP->ue_context.e_rab[i].param.gtp_teid; @@ -1863,35 +1902,39 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( } #endif + if(size==65535){ + LOG_E(RRC,"RRC decode err!!! do_RRCConnectionReconfiguration\n"); + put_UE_in_freelist(ctxt_pP->module_id, reestablish_rnti, 0); + return; + }else{ + LOG_I(RRC, + "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %x)\n", + ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - LOG_I(RRC, - "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %x)\n", - ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - - LOG_D(RRC, - "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", - ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); - - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - buffer, - size, - MSC_AS_TIME_FMT" rrcConnectionReconfiguration UE %x MUI %d size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_pP->ue_context.rnti, - rrc_eNB_mui, - size); - - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - + LOG_D(RRC, + "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", + ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); + + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + buffer, + size, + MSC_AS_TIME_FMT" rrcConnectionReconfiguration UE %x MUI %d size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_context.rnti, + rrc_eNB_mui, + size); + + rrc_data_req( + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + } // delete UE data of prior RNTI. UE use current RNTI. // protocol_ctxt_t ctxt_prior = *ctxt_pP; // ctxt_prior.rnti = reestablish_rnti; @@ -6251,7 +6294,7 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { ue_context_p, ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); } - }else { + }else if(dedicated_DRB == 0){ if(ue_context_p->ue_context.reestablishment_cause == ReestablishmentCause_spare1){ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, ue_context_p); @@ -6265,7 +6308,15 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { } } } - } + }else if(dedicated_DRB == 2){ + for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; + } else { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; + } + } + } } #else // establish a dedicated bearer if (dedicated_DRB == 0 ) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 7f5d1d9ab9a653e141f52825da0e879796b6933c..5211ff6f536f2d38552076ead90b11b9c5017f99 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1308,8 +1308,8 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->tx_freq[i] = (double)fp->dl_CarrierFreq; cfg->rx_freq[i] = (double)fp->ul_CarrierFreq; - cfg->tx_gain[i] = (double)fp->att_tx; - cfg->rx_gain[i] = ru->max_rxgain-(double)fp->att_rx; + cfg->tx_gain[i] = (double)ru->att_tx; + cfg->rx_gain[i] = ru->max_rxgain-(double)ru->att_rx; cfg->configFilename = rf_config_file; printf("channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n", @@ -1527,8 +1527,10 @@ static void* ru_thread( void* param ) { // the thread can now be woken up AssertFatal(pthread_cond_signal(&ru->proc.cond_phy_tx) == 0, "ERROR pthread_cond_signal for phy_tx thread\n"); + }else{ + LOG_E(PHY,"phy tx thread busy, skipping\n"); + ++ru->proc.instance_cnt_phy_tx; } - else LOG_W(PHY,"phy tx thread busy, skipping\n"); pthread_mutex_unlock( &ru->proc.mutex_phy_tx ); } else { phy_tx_end = 1; @@ -1810,8 +1812,10 @@ static void* eNB_thread_phy_tx( void* param ) { // the thread can now be woken up AssertFatal(pthread_cond_signal(&ru->proc.cond_rf_tx) == 0, "ERROR pthread_cond_signal for rf_tx thread\n"); + }else{ + LOG_E(PHY,"rf tx thread busy, skipping\n"); + ru->proc.instance_cnt_rf_tx++; } - else LOG_W(PHY,"rf tx thread busy, skipping\n"); pthread_mutex_unlock( &ru->proc.mutex_rf_tx ); } if (release_thread(&proc->mutex_phy_tx,&proc->instance_cnt_phy_tx,"eNB_thread_phy_tx") < 0) break; @@ -1855,6 +1859,10 @@ static void* rf_tx( void* param ) { if (ru->fh_north_out) ru->fh_north_out(ru); } if (release_thread(&proc->mutex_rf_tx,&proc->instance_cnt_rf_tx,"rf_tx") < 0) break; + if(proc->instance_cnt_rf_tx >= 0){ + late_control=STATE_BURST_TERMINATE; + LOG_E(PHY,"detect rf tx busy change mode TX failsafe\n"); + } } LOG_I(PHY, "Exiting rf TX\n"); @@ -2222,7 +2230,7 @@ void init_RU(char *rf_config_file) { } else { - LOG_E(PHY,"DJP - delete code above this %s:%d\n", __FILE__, __LINE__); + LOG_D(PHY,"DJP - delete code above this %s:%d\n", __FILE__, __LINE__); } eNB0 = ru->eNB_list[0];