From 10d7599d082b38d01de59ee66bd98d7b16425760 Mon Sep 17 00:00:00 2001 From: Xu Bo Date: Sat, 3 Feb 2018 17:52:03 +0900 Subject: [PATCH 01/91] fix merge error --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index eac6658464..05dbd76d14 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -983,8 +983,8 @@ schedule_ue_spec(module_id_t module_idP, if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit LOG_D(MAC, - "[eNB %d] Frame %d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, frameP, CC_id, + "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, subframeP, CC_id, TBS - header_len_dcch); sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used (char *) @@ -1469,7 +1469,10 @@ schedule_ue_spec(module_id_t module_idP, ue_sched_ctl->round[CC_id][harq_pid] = 0; 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; // Toggle NDI for next time LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", CC_id, frameP,subframeP,UE_id, From 9c820805fab88a6e457fb43f92480c54390d6927 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 5 Feb 2018 15:43:20 +0800 Subject: [PATCH 02/91] TDD config1 initial merge --- nfapi/oai_integration/nfapi_pnf.c | 2 +- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 17 +- openair1/PHY/LTE_TRANSPORT/defs.h | 2 +- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 12 +- openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 7 +- openair1/PHY/LTE_TRANSPORT/proto.h | 1 + openair1/SCHED/fapi_l1.c | 47 +++-- openair1/SCHED/phy_procedures_lte_common.c | 24 +++ openair1/SCHED/phy_procedures_lte_eNb.c | 30 ++- openair1/SIMULATION/LTE_PHY/dlsim_tm4.c | 1 + openair1/SIMULATION/LTE_PHY/dlsim_tm7.c | 1 + openair2/LAYER2/MAC/defs.h | 4 +- openair2/LAYER2/MAC/eNB_scheduler.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 50 +++-- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 18 +- .../LAYER2/MAC/eNB_scheduler_primitives.c | 195 +++++++++++++++--- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 51 +++-- .../MAC/flexran_agent_scheduler_dlsch_ue.c | 4 +- openair2/LAYER2/MAC/main.c | 7 +- openair2/LAYER2/MAC/pre_processor.c | 25 ++- openair2/LAYER2/MAC/proto.h | 11 +- openair2/PHY_INTERFACE/IF_Module.c | 16 +- 22 files changed, 372 insertions(+), 155 deletions(-) diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index c63d504e43..628acf2e77 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= %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/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index e0c9c043c5..722341ea65 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -1266,14 +1266,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 +1454,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<harq_process); @@ -1621,8 +1621,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 +2076,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 +2290,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; @@ -2533,7 +2534,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; diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h index b293e56b87..293f931363 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 bd5c1b05c2..69e7d7424a 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; iharq_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; iharq_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 49b41615f4..9fef0f1f4f 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 be13e5938d..10e45af9b1 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 d4f4bec4b3..dd02154e9c 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -161,24 +161,24 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr 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]; @@ -331,6 +331,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 +681,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_I(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_I(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_I(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 bbb6986ce9..fc63c12b8e 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); } +unsigned char 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 3: + //TODO + break; + case 4: + //TODO + break; + case 1: + return(((subframe_tx > subframe ) ? frame-1 : frame)+1024)%1024; + break; + } + } + + return(0); +} + + unsigned char ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char subframe) { @@ -383,6 +406,7 @@ unsigned char ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char s break; 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 diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index d53ddf7c96..79758c884c 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -379,6 +379,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 +541,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) @@ -1341,7 +1342,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) const int frame = proc->frame_rx; if (fp->frame_type == FDD) harq_pid = ((10*frame) + subframe)&7; - else harq_pid = subframe%10; + else harq_pid = subframe2harq_pid(&eNB->frame_parms,frame,subframe); for (i=0; iulsch[i]; @@ -1638,7 +1639,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 +1649,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 +1674,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< 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 +1699,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 +1709,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 +1820,7 @@ void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq, for (i=0;iO_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 +1922,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 +1984,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;// anaake 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;// anaake release_harq(eNB,UE_id,0,frame,subframe,0xffff); release_harq(eNB,UE_id,1,frame,subframe,0xffff); } @@ -1993,6 +2003,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;// anaake release_harq(eNB,UE_id,0,frame,subframe,0xffff); release_harq(eNB,UE_id,1,frame,subframe,0xffff); } @@ -2000,6 +2011,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;// anaake 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 90ba1ec804..20682a57be 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 3c4b3d0cd3..e1385e68f1 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/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 884efc4433..fbf2c4316e 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -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 b307db29b7..adf81a3f92 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -573,7 +573,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[0][subframeP]; nfapi_tx_request_t *TX_req = &eNB->TX_req[0]; eNB->pdu_index[CC_idP] = 0; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 3fd7504a8e..f14cce1707 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) { @@ -851,7 +854,7 @@ 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; + ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); else ra->harq_pid = ((frameP * 10) + subframeP) & 7; @@ -1298,10 +1301,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, @@ -1310,7 +1311,7 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, // put HARQ process round to 0 if (cc->tdd_Config) - ra->harq_pid = ((frameP * 10) + subframeP) % 10; + ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); else ra->harq_pid = ((frameP * 10) + subframeP) & 7; UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = @@ -1592,10 +1593,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 +1643,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, @@ -1729,11 +1727,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); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 05dbd76d14..bed93bbde5 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -499,8 +499,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 +508,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; @@ -690,7 +688,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; + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); else harq_pid = ((frameP * 10) + subframeP) & 7; @@ -758,7 +756,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 +1387,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,7 +1607,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; + if (cc->tdd_Config) harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); else harq_pid = ((frameP*10)+subframeP)&7; nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; @@ -1691,12 +1689,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]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 17bd5398d9..1d6c60c5df 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,32 @@ int is_UL_sf(COMMON_channels_t * ccP, sub_frame_t subframeP) } } +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 +619,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 +692,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 +1276,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 +1285,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 +1306,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 +1367,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 +1379,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; } @@ -3110,7 +3159,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 = @@ -3575,7 +3624,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 +3679,73 @@ 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 + get_dl_subframe_count(tdd_Config->subframeAssignment,subframeP))%7;//4 dl subframe in a frame + LOG_I(MAC,"[frame_subframe2_dl_harq_pid] (%d,%d) calculate harq_pid (( %d * 1024 + %d) *4 + %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; + } + } + return -1; +} + void extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, @@ -3647,8 +3763,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 +3788,37 @@ 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;m5) + frame_tx= -1; + else + frame_tx = subframeP < 5 ? frameP-1:frameP; // not formal + 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; + }else{ //nack + if( sched_ctl->round[CC_idP][harq_pid]<8) + sched_ctl->round[CC_idP][harq_pid]++; + } + } + } break; case 1: // Channel Selection break; @@ -3700,7 +3835,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 fc08dd585f..09c7bc84e2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -216,8 +216,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); } @@ -659,9 +660,15 @@ rx_sdu(const module_id_t enb_mod_idP, + if(mac->common_channels[CC_idP].tdd_Config!=NULL){ + ra->Msg4_frame = frameP + ((subframeP > 2) ? 1 : 0); + ra->Msg4_subframe = (subframeP + 7) % 10; // 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 +800,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 +817,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 */ @@ -1002,10 +1012,8 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, 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: @@ -1029,7 +1037,7 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, 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: @@ -1153,7 +1161,7 @@ schedule_ulsch_rnti(module_id_t module_idP, 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; @@ -1465,7 +1473,7 @@ schedule_ulsch_rnti(module_id_t module_idP, UE_template->DAI_ul[sched_subframeP]; 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! @@ -1661,23 +1669,28 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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_idHI_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; + ULSCH_first_end = 0; cc = &eNB->common_channels[CC_id]; // This is the actual CC_id in the list @@ -1827,7 +1840,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, // 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); @@ -1845,7 +1858,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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]; - eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++; + hi_dci0_req->number_of_dci++; 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); @@ -1941,7 +1954,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); @@ -1959,7 +1972,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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]; - 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)); diff --git a/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c b/openair2/LAYER2/MAC/flexran_agent_scheduler_dlsch_ue.c index 3a491bd7ea..bf1db6c613 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 2ad3e6a038..b067d87cd4 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 49cdbb1769..ae4f9b8112 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -300,7 +300,7 @@ maxround(module_id_t Mod_id, uint16_t rnti, int frame, UE_id = find_UE_id(Mod_id, rnti); if (cc->tdd_Config) - harq_pid = ((frame * 10) + subframe) % 10; + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frame ,subframe); else harq_pid = ((frame * 10) + subframe) & 7; @@ -1128,7 +1128,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; + if (cc->tdd_Config) harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); else harq_pid = ((frameP*10)+subframeP)&7; Round = ue_sched_ctl->round[CC_id][harq_pid]; @@ -1866,6 +1866,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 +1998,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 +2397,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 +2428,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 +2454,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 +2469,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_subframePUE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]; @@ -2519,7 +2521,7 @@ void ulsch_scheduler_pre_ue_select( } 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,7 +2588,7 @@ 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) ) { hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; @@ -2623,10 +2625,10 @@ void ulsch_scheduler_pre_ue_select( } 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 +2670,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; @@ -2687,7 +2690,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, rnti_t rnti; 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++ ) { diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index d42c8f38dc..dd3c06fc97 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -640,10 +640,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 +822,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 +1121,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/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index d0b8e57558..6152e439eb 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++; + 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; From 4387070cda914ac3cd605df46309722d3718066c Mon Sep 17 00:00:00 2001 From: Xu Bo Date: Mon, 5 Feb 2018 17:25:57 +0900 Subject: [PATCH 03/91] fix merge bug --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 09c7bc84e2..ab3f32c83c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1169,7 +1169,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"); From 5ece3937d49e11b407a3cf889da3d01a598d513d Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 5 Feb 2018 17:37:34 +0800 Subject: [PATCH 04/91] CRS only send on first symbol in special subframe config 0 --- openair1/SCHED/phy_procedures_lte_eNb.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 79758c884c..c0662b5b8e 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, From f9f20c7300103a7644cba636b11b393ca05fc659 Mon Sep 17 00:00:00 2001 From: Xu Bo Date: Mon, 5 Feb 2018 20:17:53 +0900 Subject: [PATCH 05/91] allocate_CCEs only called on dl subframes --- openair2/LAYER2/MAC/eNB_scheduler.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index adf81a3f92..176503ca1c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -817,9 +817,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); From 5c76360c2d831ce2b2394bc0e67e7915492204f4 Mon Sep 17 00:00:00 2001 From: Xu Bo Date: Tue, 6 Feb 2018 11:01:05 +0900 Subject: [PATCH 06/91] Fix special subframe only use 2 symbols to transmit pdcch --- .../LAYER2/MAC/eNB_scheduler_primitives.c | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 1d6c60c5df..7c8794e307 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -580,6 +580,30 @@ 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 @@ -3170,10 +3194,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, @@ -3203,7 +3233,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", @@ -3225,7 +3255,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, @@ -3301,7 +3331,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", @@ -3323,7 +3353,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, @@ -3391,7 +3421,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", @@ -3414,7 +3444,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, From 367e07634722993788a59c3e36f0cbc9fa181a48 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Tue, 6 Feb 2018 11:58:25 +0800 Subject: [PATCH 07/91] Fix merge bug in return value of ul_ACK_subframe2_dl_frame --- openair1/SCHED/phy_procedures_lte_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index fc63c12b8e..83ba5b4b97 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -336,7 +336,7 @@ unsigned char ul_ACK_subframe2_dl_subframe(LTE_DL_FRAME_PARMS *frame_parms,unsig return(0); } -unsigned char ul_ACK_subframe2_dl_frame(LTE_DL_FRAME_PARMS *frame_parms,int frame, unsigned char subframe,unsigned char subframe_tx) +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) { From e8300aa944b783061a930af69dd2c74fce4209a9 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Tue, 6 Feb 2018 16:50:27 +0800 Subject: [PATCH 08/91] Don't use assert since the comment above said it's perfectly possible to have this NULL here. --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 7c8794e307..7fc7733f12 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -1446,12 +1446,15 @@ 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"); +// 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 != NULL) + && (UE_list-> UE_template[CC_idP][UE_id].physicalConfigDedicated-> pucch_ConfigDedicated->tdd_AckNackFeedbackMode != NULL) && (*UE_list-> From 8fffe90dbe875b0dbd59ec0d56f768c038ce5ef2 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 8 Feb 2018 02:24:54 +0000 Subject: [PATCH 09/91] fix hundreds_of_ues issue(n1_PUCCH_AN DAI) for TDD cofnig1 --- .../nfapi/public_inc/nfapi_interface.h | 1 + openair1/PHY/LTE_TRANSPORT/dci_tools.c | 9 ++ openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 2 + openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 92 +++++++++++++++---- openair2/RRC/LITE/MESSAGES/asn1_msg.c | 27 +++++- 5 files changed, 111 insertions(+), 20 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h index d5b1ce6af6..282739e315 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/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 722341ea65..9f75a87b50 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -2565,6 +2565,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 */), @@ -2710,6 +2712,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) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index bed93bbde5..bb73f8c8bb 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; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index ab3f32c83c..2c0524bcb2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1097,10 +1097,25 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, for (i=0; ira[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; @@ -1696,25 +1711,62 @@ void schedule_ulsch_rnti(module_id_t module_idP, // 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 @@ -1857,6 +1909,7 @@ 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; hi_dci0_req->number_of_dci++; @@ -1971,6 +2024,7 @@ 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; hi_dci0_req->number_of_dci++; // fill in NAK information diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index 94d8c17f0a..724b30a3d1 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 From 89b261efe55202f6c3ee059dbfb6a9efec0fffd1 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Thu, 8 Feb 2018 16:08:57 +0800 Subject: [PATCH 10/91] Fix bug in schedule_ulsch --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index ab3f32c83c..70bc926e3c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1004,8 +1004,8 @@ 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: @@ -1026,11 +1026,11 @@ 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; From 9ba035500063a39e2b5a87892dac9cbf38bf35c1 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Thu, 8 Feb 2018 18:04:23 +0800 Subject: [PATCH 11/91] add switch tdd config to Msg4 timing setting --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 70bc926e3c..68515b5bc5 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -661,8 +661,13 @@ rx_sdu(const module_id_t enb_mod_idP, if(mac->common_channels[CC_idP].tdd_Config!=NULL){ - ra->Msg4_frame = frameP + ((subframeP > 2) ? 1 : 0); - ra->Msg4_subframe = (subframeP + 7) % 10; // TODO need to be complete for other tdd configs. + 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); From 593ebc4732f361aa798d38f0fdd55bd3a49a3b80 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Thu, 8 Feb 2018 18:08:38 +0800 Subject: [PATCH 12/91] Fix bug in subframe2harq_pid. Remove if tdd condition while calling this method since there is already if-else in the method. --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 5 ----- openair1/SCHED/phy_procedures_lte_eNb.c | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 722341ea65..855571fe54 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -6587,12 +6587,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: diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index c0662b5b8e..bc9b0e4f4e 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1351,8 +1351,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 = subframe2harq_pid(&eNB->frame_parms,frame,subframe); + harq_pid = subframe2harq_pid(&eNB->frame_parms,frame,subframe); for (i=0; iulsch[i]; From 4898d609e698d8c1f84723db1c4ae00c0c317049 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Sun, 11 Feb 2018 16:42:12 +0800 Subject: [PATCH 13/91] Fix a bug in HI_DCI0_req clear --- openair2/LAYER2/MAC/eNB_scheduler.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 176503ca1c..19ba879032 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -573,7 +573,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][subframeP]; + 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 +586,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; From dcdda7ba356c0318e994fc77b2c0e6b275b7491e Mon Sep 17 00:00:00 2001 From: Xu Bo Date: Sun, 11 Feb 2018 18:10:11 +0900 Subject: [PATCH 14/91] set UL schedule period to 5Frame for TDD config1 --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 11 ++++++++++- openair2/LAYER2/MAC/pre_processor.c | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 3740071299..1f004cc9e3 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1832,7 +1832,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, @@ -1917,6 +1916,11 @@ void schedule_ulsch_rnti(module_id_t module_idP, hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; 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); @@ -2042,6 +2046,11 @@ void schedule_ulsch_rnti(module_id_t module_idP, hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; hi_dci0_req->number_of_hi++; + 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], ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb, ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb, diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index ae4f9b8112..b16ee172fd 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -2509,7 +2509,13 @@ void ulsch_scheduler_pre_ue_select( } 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] ++; @@ -2615,7 +2621,13 @@ 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] ) { 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]++; From 2974c20c696d10fc42184ccfa01e8eb0c1bea36b Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Sun, 11 Feb 2018 19:55:52 +0800 Subject: [PATCH 15/91] Move tdd config case 1 to top --- openair1/SCHED/phy_procedures_lte_common.c | 41 +++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index 83ba5b4b97..1981f53ee2 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -343,15 +343,15 @@ int ul_ACK_subframe2_dl_frame(LTE_DL_FRAME_PARMS *frame_parms,int frame, unsigne 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; - case 1: - return(((subframe_tx > subframe ) ? frame-1 : frame)+1024)%1024; - break; } } @@ -366,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 @@ -404,24 +421,6 @@ unsigned char ul_ACK_subframe2_M(LTE_DL_FRAME_PARMS *frame_parms,unsigned char s } break; - - 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; } } From bba24dc2fa9d6c7a1a29034968991f18264be356 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Sun, 11 Feb 2018 20:33:07 +0800 Subject: [PATCH 16/91] Remove comments --- openair1/SCHED/phy_procedures_lte_eNb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index bc9b0e4f4e..51231ded48 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1999,12 +1999,12 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, switch (harq_ack[0]) { case 0: - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0;// anaake + 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;// anaake + 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); } @@ -2012,7 +2012,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;// anaake + 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); } @@ -2020,7 +2020,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;// anaake + 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); } From 19a2b37c751445ef2a82ba41b0e21efc8124c19f Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 12 Feb 2018 16:52:48 +0800 Subject: [PATCH 17/91] Fix bug in Adaptive Retransmission for ULSCH. Fix Qm,mcs,TBS setting. --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 1 + openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 4 +++- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 13 +++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index dc55a28ea0..4b857fffbd 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -2783,6 +2783,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; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 7fc7733f12..a5fd7c7e6a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -1705,8 +1705,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. diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 1f004cc9e3..db9025b258 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1997,8 +1997,13 @@ 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; - - 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); + if(rvidx_tab[round&3]==1){ + UE_template->mcs_UL[harq_pid] = 29; + }else if(rvidx_tab[round&3]==2){ + UE_template->mcs_UL[harq_pid] = 30; + }else if(rvidx_tab[round&3]==3){ + UE_template->mcs_UL[harq_pid] = 31; + } 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) @@ -2045,6 +2050,7 @@ 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]; @@ -2077,8 +2083,7 @@ 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 From c641f334bb4114a9c79d20170aedeae5da2133b0 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Mon, 12 Feb 2018 18:38:26 +0900 Subject: [PATCH 18/91] fix total usable RBs when pucch rb=6 --- openair2/ENB_APP/enb_config.c | 4 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 11 +++++ openair2/LAYER2/MAC/pre_processor.c | 52 ++++++++++++++++++----- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 2 +- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 09e00a8f6b..c87421a2c0 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -876,9 +876,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/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index db9025b258..bc15372823 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1710,6 +1710,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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]; @@ -1959,6 +1960,12 @@ void schedule_ulsch_rnti(module_id_t module_idP, #endif 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, @@ -2096,6 +2103,10 @@ void schedule_ulsch_rnti(module_id_t module_idP, #endif 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/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index b16ee172fd..af34a1774b 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -2700,6 +2700,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, 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,sched_subframeP,ulsch_ue_select); @@ -2730,22 +2731,51 @@ 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 ){ + cc = &RC.mac[module_idP]->common_channels[CC_id]; + if (cc->tdd_Config) { + 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 (frame_parms->N_RB_UL == 50) { + 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]; + } else { + if (first_rb[CC_id] >= frame_parms->N_RB_UL-3 ) { + 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-3-first_rb[CC_id]; + } + } else { + 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 ){ + 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; + break; + } + // calculate the average rb ( remain UE) + total_rbs = frame_parms->N_RB_UL-2-first_rb[CC_id]; } - // calculate the average rb ( remain UE) - total_rbs = frame_parms->N_RB_UL-2-first_rb[CC_id]; } average_rbs = (int)round((double)total_rbs/(double)ue_num_temp); if ( average_rbs < 3 ) { 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 881c7b14cc..318ec64d02 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -550,7 +550,7 @@ rlc_am_mac_status_indication ( } rlc->last_absolute_subframe_status_indication = PROTOCOL_CTXT_TIME_MILLI_SECONDS(ctxt_pP); - + 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); From ebecb55733672aa03d8cb389656401c92ae2a2f9 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Tue, 13 Feb 2018 12:30:25 +0900 Subject: [PATCH 19/91] add if-else case for first_rb=3 when TDD config1 20MHz in ULSCH_pre_processor --- openair2/LAYER2/MAC/pre_processor.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index af34a1774b..b09601a0ac 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -2707,12 +2707,23 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, // 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) { + first_rb[CC_id] = 1; + } else if (frame_parms->N_RB_UL == 50) { + first_rb[CC_id] = 2; + } else { + first_rb[CC_id] = 3; + } + } else {//FDD + if (frame_parms->N_RB_UL == 25) { + first_rb[CC_id] = 1; + } else { + first_rb[CC_id] = 2; + } + } 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++ ) { @@ -2731,7 +2742,6 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, } rnti = UE_RNTI(CC_id,UE_id); - cc = &RC.mac[module_idP]->common_channels[CC_id]; if (cc->tdd_Config) { if (frame_parms->N_RB_UL == 25) { if (first_rb[CC_id] >= frame_parms->N_RB_UL-1 ) { From 831ce2e910f215b90bfee5504cadfdbb71e001a7 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Tue, 13 Feb 2018 17:08:32 +0800 Subject: [PATCH 20/91] Fix frame_cnt to prevent it from getting too big --- openair2/PHY_INTERFACE/IF_Module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index 6152e439eb..175fcb2e67 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -546,8 +546,8 @@ 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++; + 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); } From c80246a9a5b904654bddc06b3ac5a9b45c2a2c11 Mon Sep 17 00:00:00 2001 From: tomita Date: Mon, 19 Feb 2018 19:18:15 +0900 Subject: [PATCH 21/91] Changed log level. --- openair1/PHY/INIT/lte_init.c | 4 ++-- openair2/LAYER2/MAC/config.c | 6 +++--- targets/RT/USER/lte-ru.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index d662cf19de..b8a7495ebc 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; irf_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/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 7f5d1d9ab9..203217be2a 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -2222,7 +2222,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]; From a53e22c2944b64acd24fce7116f4f72d9cdc83c1 Mon Sep 17 00:00:00 2001 From: tomita Date: Mon, 19 Feb 2018 19:31:09 +0900 Subject: [PATCH 22/91] Fixed harq_pid calculation. --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index a5fd7c7e6a..186ade03d3 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -3770,8 +3770,8 @@ uint8_t frame_subframe2_dl_harq_pid(TDD_Config_t *tdd_Config, int abs_frameP, su switch(tdd_Config->subframeAssignment){ //TODO fill in other tdd config case 1: - harq_pid = ((frame_cnt*1024 + abs_frameP) * 4 + get_dl_subframe_count(tdd_Config->subframeAssignment,subframeP))%7;//4 dl subframe in a frame - LOG_I(MAC,"[frame_subframe2_dl_harq_pid] (%d,%d) calculate harq_pid (( %d * 1024 + %d) *4 + %d)%7 = %d \n", + harq_pid = (((frame_cnt*1024 + abs_frameP) * 4) - 1 + get_dl_subframe_count(tdd_Config->subframeAssignment,subframeP))%7;//4 dl subframe in a frame + LOG_I(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; From ea3aecf486f2296c044cbcf505fdb92c167c85c2 Mon Sep 17 00:00:00 2001 From: tomita Date: Mon, 19 Feb 2018 19:42:06 +0900 Subject: [PATCH 23/91] Bug fix about harq_pid calculation (harq_pid is calculated less than 0). --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 186ade03d3..e7831ffe93 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -3839,10 +3839,15 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, int M = ul_ACK_subframe2_M(fp,subframeP); for(m=0;m5) - frame_tx= -1; - else - frame_tx = subframeP < 5 ? frameP-1:frameP; // not formal + switch (cc->tdd_Config->subframeAssignment){ + case 1: + if(frameP==0&&subframeP<4) + frame_tx= 0; + else + frame_tx = subframeP < 4 ? frameP-1:frameP; // not formal + break; + // TODO : Other TDD Config + } 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 From 19509f08eb76ed2e83f5ae2bcdcf43da23246f6a Mon Sep 17 00:00:00 2001 From: tomita Date: Tue, 20 Feb 2018 18:40:05 +0900 Subject: [PATCH 24/91] Changed log level. --- openair1/SCHED/fapi_l1.c | 6 +++--- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index dd02154e9c..0a5ff283c6 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -681,16 +681,16 @@ 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_I(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", + 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_I(PHY,"NFAPI: hi_dci0:SFN/SF:%04d%d:pdus:%d\n", + 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_I(PHY,"NFAPI: ul_cfg:SFN/SF:%04d%d:pdus:%d num_pdcch_symbols:%d\n", + 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); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index e7831ffe93..ea9ca52678 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -3771,7 +3771,7 @@ uint8_t frame_subframe2_dl_harq_pid(TDD_Config_t *tdd_Config, int abs_frameP, su 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 - LOG_I(MAC,"[frame_subframe2_dl_harq_pid] (%d,%d) calculate harq_pid ((( %d * 1024 + %d) *4) - 1 + %d)%7 = %d \n", + 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; From 1008080e3185606c6ea818a1a8e16ff8e7450df1 Mon Sep 17 00:00:00 2001 From: tomita Date: Thu, 22 Feb 2018 16:40:27 +0900 Subject: [PATCH 25/91] Bug fix for harq_pid calculation in MAC layer. --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index ea9ca52678..2aae8a7eab 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -3771,6 +3771,8 @@ uint8_t frame_subframe2_dl_harq_pid(TDD_Config_t *tdd_Config, int abs_frameP, su 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); @@ -3839,15 +3841,10 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, int M = ul_ACK_subframe2_M(fp,subframeP); for(m=0;mtdd_Config->subframeAssignment){ - case 1: - if(frameP==0&&subframeP<4) - frame_tx= 0; - else - frame_tx = subframeP < 4 ? frameP-1:frameP; // not formal - break; - // TODO : Other TDD Config - } + 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 From 2f4c21ced37f6e7f7c7f906d6210116558887b3b Mon Sep 17 00:00:00 2001 From: tomita Date: Thu, 22 Feb 2018 17:10:21 +0900 Subject: [PATCH 26/91] Fix to avoid Segmemtation Fault in case of physicalConfigDedicated is NULL. --- .../LAYER2/MAC/eNB_scheduler_primitives.c | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 2aae8a7eab..7f933a192a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -1451,24 +1451,30 @@ fill_nfapi_harq_information(module_id_t module_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 != 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 - } - harq_information->harq_information_rel10_tdd.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG; + 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; harq_information->harq_information_rel10_tdd.n_pucch_1_0 = cc->radioResourceConfigCommon->pucch_ConfigCommon. n1PUCCH_AN + cce_idxP; From 0504659eb8b764bc0f819d4f3ef513fad7df8ef4 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Sat, 24 Feb 2018 15:16:17 +0900 Subject: [PATCH 27/91] fix RM778 PRACH failure by adding reset RA when CRNTI_ACK in extract_harq --- .../LAYER2/MAC/eNB_scheduler_primitives.c | 22 +++++++++++++++---- openair2/LAYER2/MAC/pre_processor.c | 9 ++++++++ openair2/LAYER2/MAC/rar_tools.c | 7 +++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 7f933a192a..2b0b5d7e53 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -1475,9 +1475,9 @@ fill_nfapi_harq_information(module_id_t module_idP, 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; + 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 { @@ -3860,7 +3860,21 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, if( sched_ctl->round[CC_idP][harq_pid]<8) 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 diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index b09601a0ac..497c896133 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -2843,12 +2843,21 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, tx_power= estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); } }else{ + if (cc->tdd_Config && frame_parms->N_RB_UL == 100) { + while ( (tbs < UE_template->ul_total_buffer) && (rb_table[rb_table_index]<(frame_parms->N_RB_UL-3-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/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index f48a53636f..4af67c8316 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 From 699bbcb80fef8cf699d3138c64846e70cef1b55f Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Sat, 24 Feb 2018 17:27:18 +0800 Subject: [PATCH 28/91] simplify source of ulsch_scheduler_pre_processor --- openair2/LAYER2/MAC/pre_processor.c | 93 +++++++---------------------- 1 file changed, 21 insertions(+), 72 deletions(-) diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 497c896133..6ff45e732f 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -2696,6 +2696,7 @@ 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; @@ -2711,19 +2712,21 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, frame_parms = &(RC.eNB[module_idP][CC_id]->frame_parms); if (cc->tdd_Config) { //TDD if (frame_parms->N_RB_UL == 25) { - first_rb[CC_id] = 1; + num_pucch_rb = 1; } else if (frame_parms->N_RB_UL == 50) { - first_rb[CC_id] = 2; + num_pucch_rb = 2; } else { - first_rb[CC_id] = 3; + num_pucch_rb = 3; } } else {//FDD if (frame_parms->N_RB_UL == 25) { - first_rb[CC_id] = 1; + num_pucch_rb = 1; } else { - first_rb[CC_id] = 2; + 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++ ) { @@ -2742,51 +2745,14 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, } rnti = UE_RNTI(CC_id,UE_id); - if (cc->tdd_Config) { - 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 (frame_parms->N_RB_UL == 50) { - 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]; - } else { - if (first_rb[CC_id] >= frame_parms->N_RB_UL-3 ) { - 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-3-first_rb[CC_id]; - } - } else { - 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--; @@ -2835,30 +2801,13 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, 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{ - if (cc->tdd_Config && frame_parms->N_RB_UL == 100) { - while ( (tbs < UE_template->ul_total_buffer) && (rb_table[rb_table_index]<(frame_parms->N_RB_UL-3-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); - } - } + 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 ( rb_table[rb_table_index]<3 ) { rb_table_index=2; } From 9f31d41b4497ba3a0cf1417547ce47e3bb661e26 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 26 Feb 2018 17:31:43 +0800 Subject: [PATCH 29/91] Add the setting ofharq_information_rel10_tdd.n_pucch_1_0 for tdd in allocate_CCEs --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 2b0b5d7e53..272e8b383a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -3511,8 +3511,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) ; } } } @@ -3852,13 +3856,16 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, 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]; From 5808ce3934dff6bdd64d9fff1f431b6d01179893 Mon Sep 17 00:00:00 2001 From: "Wang.shanshan" Date: Mon, 26 Feb 2018 20:21:16 +0900 Subject: [PATCH 30/91] Fix:harq_pid for TDD is not completely fixed in pre processer. --- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 9 ++------- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 6 +----- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 2 ++ openair2/LAYER2/MAC/pre_processor.c | 18 ++++++------------ 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index f14cce1707..03ec9ddcf9 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -853,10 +853,7 @@ 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 = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); - else - ra->harq_pid = ((frameP * 10) + subframeP) & 7; // Get RRCConnectionSetup for Piggyback rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block @@ -1310,10 +1307,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 = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); - 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; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index bb73f8c8bb..768a9926f5 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -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 = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); - else - harq_pid = ((frameP * 10) + subframeP) & 7; round = ue_sched_ctl->round[CC_id][harq_pid]; @@ -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 = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); - 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]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 272e8b383a..41db5b3d90 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -3789,6 +3789,8 @@ uint8_t frame_subframe2_dl_harq_pid(TDD_Config_t *tdd_Config, int abs_frameP, su return harq_pid; break; } + }else{ + return ((abs_frameP*10)+subframeP)&7; } return -1; } diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 6ff45e732f..0a0a3e014e 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_subframe2_dl_harq_pid(cc->tdd_Config,frame ,subframe); - 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->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 = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); - 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) { From dab82a27056b493ed9e59a9d98f516fac5afc01a Mon Sep 17 00:00:00 2001 From: Xu Bo Date: Tue, 27 Feb 2018 11:24:44 +0900 Subject: [PATCH 31/91] fix for-loop index in pdate_ul_dci --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 768a9926f5..39bed78c37 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -1703,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)) From 87fb55c79271c75f671eac7225135d7f294c3d9d Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Tue, 27 Feb 2018 11:55:53 +0800 Subject: [PATCH 32/91] Fix a bug in previous commit Fix:harq_pid.... --- openair2/LAYER2/MAC/pre_processor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 0a0a3e014e..ef25fbf718 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -901,7 +901,7 @@ void dlsch_scheduler_pre_ue_select( if(i < dlsch_ue_select[CC_id].ue_num) continue; - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + 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) { From 57a9156f8866dedbd7333fe4e755330b28be52fe Mon Sep 17 00:00:00 2001 From: "Wang.shanshan" Date: Thu, 1 Mar 2018 18:59:19 +0900 Subject: [PATCH 33/91] Fix index used while checking harq result with SR collision --- openair1/SCHED/phy_procedures_lte_eNb.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 51231ded48..b402c7c0a5 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -904,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) { @@ -1021,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]; From 54cf2d9aef452cfe334509aa89ed144bb6d22d5b Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Tue, 6 Mar 2018 16:15:24 +0900 Subject: [PATCH 34/91] fix TBS_UL data_type from uint8_t to uint16_t --- openair2/LAYER2/MAC/defs.h | 2 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index fbf2c4316e..0338cd8c3c 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) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index bc15372823..96450c8604 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -2090,7 +2090,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, 0, // ul_tx_mode 0, // current_tx_nb 0, // n_srs - 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) ); #ifdef Rel14 if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation From 8a89a16fde6b8ccae542bcb906776853625416d7 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 8 Mar 2018 12:01:43 +0900 Subject: [PATCH 35/91] fix issue about att_rx and att_tx config --- openair2/ENB_APP/enb_config.c | 4 +++- targets/RT/USER/lte-ru.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index c87421a2c0..121400f2b4 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;inum_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); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index e12fc3161e..5211ff6f53 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", From f58d4aa05f8ba9501f7d0e23a77ed1bd7cddd924 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 8 Mar 2018 12:26:39 +0900 Subject: [PATCH 36/91] fix pdcch_alloc2ul_subframe when TDD config1 --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 33 ++++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 4b857fffbd..974c3eb36d 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -6665,10 +6665,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); @@ -6688,10 +6691,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); @@ -6705,13 +6711,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)); From d45572446c27de35e769a3d0e3bd3af782b91b73 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 8 Mar 2018 12:38:54 +0900 Subject: [PATCH 37/91] fix mcs when retranssmission --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 33 +++++++++-------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 3e8ad2b9e2..be566331d1 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -997,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; @@ -1050,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_idul_scheduled |= (1<head) 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]); - 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); // 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 @@ -1977,10 +1968,13 @@ void schedule_ulsch_rnti(module_id_t module_idP, first_rb[CC_id]+=rb_table[rb_table_index]; 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){ + 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; } @@ -2002,20 +1996,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){ - UE_template->mcs_UL[harq_pid] = 29; + mcs_rv = 29; }else if(rvidx_tab[round&3]==2){ - UE_template->mcs_UL[harq_pid] = 30; + mcs_rv = 30; }else if(rvidx_tab[round&3]==3){ - UE_template->mcs_UL[harq_pid] = 31; + 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 @@ -2036,7 +2030,7 @@ 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]; @@ -2063,7 +2057,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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 @@ -2088,8 +2082,7 @@ 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] + UE_template->TBS_UL[harq_pid] ); #ifdef Rel14 if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation From 485b7fc060d9171aa40254669b04268a5dbd9b80 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 12 Mar 2018 11:07:59 +0800 Subject: [PATCH 38/91] Fix the defecitve process while there is an uci scheduled before an ulsch. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 51 +++++++++++++++++++---- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index be566331d1..7558e41617 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -196,7 +196,7 @@ 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]. @@ -1683,7 +1683,8 @@ 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; @@ -1915,8 +1916,17 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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, @@ -1940,14 +1950,22 @@ 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; @@ -2063,7 +2081,16 @@ void schedule_ulsch_rnti(module_id_t module_idP, // 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, @@ -2086,14 +2113,22 @@ 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 = 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; From 2505f15eabdbab9be9e701fa8c72cd553b900e60 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 12 Mar 2018 12:49:34 +0800 Subject: [PATCH 39/91] Fix previous problem for no-ue-extension version of schedule_ulsch_rnti --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 52 +++++++++++++++++++---- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 7558e41617..515adad525 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1174,7 +1174,8 @@ 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++; @@ -1501,9 +1502,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 @@ -1521,15 +1530,24 @@ 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++; @@ -1588,7 +1606,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 @@ -1603,14 +1630,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 = 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++; + } + mac->ul_handle++; ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; From 1846c56d54cce69c50142f80c4f9c43f7ad5ea06 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Wed, 4 Apr 2018 15:54:44 +0800 Subject: [PATCH 40/91] Add the missing part of DAI setting and harq_pid calculation to OAI SCD --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 5 +++-- openair2/LAYER2/MAC/pre_processor.c | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 44c8e33a0a..ea33715596 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1489,6 +1489,7 @@ 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(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4) @@ -1554,7 +1555,7 @@ schedule_ulsch_rnti(module_id_t module_idP, 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, @@ -1641,7 +1642,7 @@ schedule_ulsch_rnti(module_id_t module_idP, 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]; + 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++; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index ee8e9f124c..7429489334 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -1182,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; From dbddecb775de6424eb804bb2beddbfc901fa9eb8 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Wed, 4 Apr 2018 18:56:56 +0900 Subject: [PATCH 41/91] fix Paging bug when PO=subframe0 and sfn_sf error --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 39bed78c37..2ac618ccd3 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -1844,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 @@ -1963,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: @@ -2051,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; @@ -2091,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); From 901c0da0134b59dc9a80901adc99fc9a74c26cb9 Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Mon, 9 Apr 2018 15:10:23 +0900 Subject: [PATCH 42/91] Fix attach NG on FDD 10MHz 20MHz. --- targets/RT/USER/lte-ru.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 5211ff6f53..7676411882 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1814,7 +1814,7 @@ static void* eNB_thread_phy_tx( void* param ) { 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++; + late_control=STATE_BURST_TERMINATE; } pthread_mutex_unlock( &ru->proc.mutex_rf_tx ); } From 7ced1a2eb1e869a16f6a0c991dca9c83346eb43f Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Mon, 9 Apr 2018 19:56:33 +0900 Subject: [PATCH 43/91] Remove nb_rb = 64 form rb_table in SCD. Because PHY UL cannot decode nb_rb = 64. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 4e5eda84f0..a041885165 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -65,7 +65,7 @@ // This table holds the allowable PRB sizes for ULSCH transmissions uint8_t rb_table[34] = { 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, - 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100 + 36, 40, 45, 48, 50, 54, 60, 72, 75, 80, 81, 90, 96, 100, 100 }; extern mui_t rrc_eNB_mui; From 8b44c8bfb66095fe3ae6b04cf1070940ccdc0730 Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Mon, 9 Apr 2018 19:57:33 +0900 Subject: [PATCH 44/91] modify: skip RLC assertion. --- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c | 6 +- .../RLC/UM_v9.3.0/rlc_um_control_primitives.c | 54 +++++++++---- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c | 78 ++++++++++++++----- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c | 2 +- .../LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c | 12 ++- openair2/LAYER2/RLC/rlc.c | 12 ++- 6 files changed, 122 insertions(+), 42 deletions(-) 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 864921ff88..0718cdd93c 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -568,7 +568,11 @@ rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP,cons l_rlc_p->stat_tx_data_pdu += 1; l_rlc_p->stat_tx_data_bytes += tb_size_in_bytes; - AssertFatal( tb_size_in_bytes > 0 , "RLC UM PDU LENGTH %d", tb_size_in_bytes); + //AssertFatal( tb_size_in_bytes > 0 , "RLC UM PDU LENGTH %d", tb_size_in_bytes); + if(tb_size_in_bytes <= 0) { + LOG_E(RLC, "RLC UM PDU LENGTH %d\n", tb_size_in_bytes); + } + #if TRACE_RLC_UM_PDU || MESSAGE_CHART_GENERATOR rlc_um_get_pdu_infos(ctxt_pP, l_rlc_p,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_req*) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); #endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c index 4e2723a8f4..499cdc7080 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c @@ -106,28 +106,48 @@ void config_req_rlc_um_asn1 ( #if defined(Rel10) || defined(Rel14) if (mbms_flagP) { - AssertFatal(dl_rlc_pP, "No RLC UM DL config"); - AssertFatal(ul_rlc_pP == NULL, "RLC UM UL config present"); + //AssertFatal(dl_rlc_pP, "No RLC UM DL config"); + if(dl_rlc_pP == NULL) { + LOG_E(RLC, "No RLC UM DL config\n"); + return; + } + //AssertFatal(ul_rlc_pP == NULL, "RLC UM UL config present"); + if(ul_rlc_pP != NULL) { + LOG_E(RLC, "RLC UM UL config present\n"); + return; + } + key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_service_idP, mbms_session_idP); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); - AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u rnti %i enb flag %u service id %u, session id %u", - ctxt_pP->module_id, - ctxt_pP->rnti, - ctxt_pP->enb_flag, - mbms_service_idP, - mbms_session_idP); + //AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u rnti %i enb flag %u service id %u, session id %u", + // ctxt_pP->module_id, + // ctxt_pP->rnti, + // ctxt_pP->enb_flag, + // mbms_service_idP, + // mbms_session_idP); + if(h_rc != HASH_TABLE_OK) { + LOG_E(RLC, "RLC NOT FOUND enb id %u rnti %i enb flag %u service id %u, session id %u\n", + ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_service_idP, mbms_session_idP); + return; + } + rlc_p = &rlc_union_p->rlc.um; } else #endif { key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); - AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u ue id %i enb flag %u rb id %u, srb flag %u", - ctxt_pP->module_id, - ctxt_pP->rnti, - ctxt_pP->enb_flag, - rb_idP, - srb_flagP); + //AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u ue id %i enb flag %u rb id %u, srb flag %u", + // ctxt_pP->module_id, + // ctxt_pP->rnti, + // ctxt_pP->enb_flag, + // rb_idP, + // srb_flagP); + if(h_rc != HASH_TABLE_OK) { + LOG_E(RLC, "RLC NOT FOUND enb id %u ue id %i enb flag %u rb id %u, srb flag %u\n", + ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); + return; + } rlc_p = &rlc_union_p->rlc.um; } @@ -269,7 +289,11 @@ rlc_um_init ( ) { - AssertFatal(rlc_pP, "Bad RLC UM pointer (NULL)"); + //AssertFatal(rlc_pP, "Bad RLC UM pointer (NULL)"); + if(rlc_pP == NULL) { + LOG_E(RLC, "Bad RLC UM pointer (NULL)\n"); + return; + } if (rlc_pP->initialized) { LOG_D(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [INIT] ALREADY DONE, DOING NOTHING\n", diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c index fe71839231..cd92cf2c5e 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c @@ -47,7 +47,11 @@ signed int rlc_um_get_pdu_infos( pdu_info_pP->num_li = 0; - AssertFatal( total_sizeP > 0 , "RLC UM PDU LENGTH %d", total_sizeP); + //AssertFatal( total_sizeP > 0 , "RLC UM PDU LENGTH %d", total_sizeP); + if(total_sizeP <= 0) { + LOG_E(RLC, "RLC UM PDU LENGTH %d\n", total_sizeP); + return -1; + } if (sn_lengthP == 10) { pdu_info_pP->fi = (header_pP->b1 >> 3) & 0x03; @@ -62,7 +66,11 @@ signed int rlc_um_get_pdu_infos( pdu_info_pP->header_size = 1; pdu_info_pP->payload = &header_pP->b2; } else { - AssertFatal( sn_lengthP == 5 || sn_lengthP == 10, "RLC UM SN LENGTH %d", sn_lengthP); + //AssertFatal( sn_lengthP == 5 || sn_lengthP == 10, "RLC UM SN LENGTH %d", sn_lengthP); + if(!(sn_lengthP == 5 || sn_lengthP == 10)) { + LOG_E(RLC, "RLC UM SN LENGTH %d\n", sn_lengthP); + return -1; + } } @@ -77,15 +85,23 @@ signed int rlc_um_get_pdu_infos( li_length_in_bytes = li_length_in_bytes ^ 3; if (li_length_in_bytes == 2) { - AssertFatal( total_sizeP >= ((uint64_t)(&e_li_p->b2) - (uint64_t)header_pP), - "DECODING PDU TOO FAR PDU size %d", total_sizeP); + //AssertFatal( total_sizeP >= ((uint64_t)(&e_li_p->b2) - (uint64_t)header_pP), + // "DECODING PDU TOO FAR PDU size %d", total_sizeP); + if(total_sizeP < ((uint64_t)(&e_li_p->b2) - (uint64_t)header_pP)) { + LOG_E(RLC, "DECODING PDU TOO FAR PDU size %d\n", total_sizeP); + return -1; + } pdu_info_pP->li_list[pdu_info_pP->num_li] = ((uint16_t)(e_li_p->b1 << 4)) & 0x07F0; pdu_info_pP->li_list[pdu_info_pP->num_li] |= (((uint8_t)(e_li_p->b2 >> 4)) & 0x000F); li_to_read = e_li_p->b1 & 0x80; pdu_info_pP->header_size += 2; } else { - AssertFatal( total_sizeP >= ((uint64_t)(&e_li_p->b3) - (uint64_t)header_pP), - "DECODING PDU TOO FAR PDU size %d", total_sizeP); + //AssertFatal( total_sizeP >= ((uint64_t)(&e_li_p->b3) - (uint64_t)header_pP), + // "DECODING PDU TOO FAR PDU size %d", total_sizeP); + if(total_sizeP < ((uint64_t)(&e_li_p->b3) - (uint64_t)header_pP)) { + LOG_E(RLC, "DECODING PDU TOO FAR PDU size %d\n", total_sizeP); + return -1; + } pdu_info_pP->li_list[pdu_info_pP->num_li] = ((uint16_t)(e_li_p->b2 << 8)) & 0x0700; pdu_info_pP->li_list[pdu_info_pP->num_li] |= e_li_p->b3; li_to_read = e_li_p->b2 & 0x08; @@ -93,10 +109,16 @@ signed int rlc_um_get_pdu_infos( pdu_info_pP->header_size += 1; } - AssertFatal( pdu_info_pP->num_li <= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU, - PROTOCOL_RLC_UM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs ", + //AssertFatal( pdu_info_pP->num_li <= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU, + // PROTOCOL_RLC_UM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs ", + // PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + // pdu_info_pP->sn); + if(pdu_info_pP->num_li > RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[GET PDU INFO] SN %04d TOO MANY LIs \n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), pdu_info_pP->sn); + return -1; + } sum_li += pdu_info_pP->li_list[pdu_info_pP->num_li]; pdu_info_pP->num_li = pdu_info_pP->num_li + 1; @@ -308,9 +330,17 @@ rlc_um_try_reassembly( __LINE__); #endif } - AssertFatal(size >= 0, "invalid size!"); - AssertFatal((e==0) || (e==1), "invalid e!"); - AssertFatal((fi >= 0) && (fi <= 3), "invalid fi!"); + //AssertFatal(size >= 0, "invalid size!"); + //AssertFatal((e==0) || (e==1), "invalid e!"); + //AssertFatal((fi >= 0) && (fi <= 3), "invalid fi!"); + if((size < 0) || ((e!=0) && (e!=1)) || ((fi < 0) || (fi > 3))){ + LOG_E(RLC, "invalid size %d, e %d, fi %d\n", size, e, fi); + sn = (sn + 1) % rlc_pP->rx_sn_modulo; + if ((sn == rlc_pP->vr_uh) || (sn == end_snP)) { + continue_reassembly = 0; + } + continue; + } if (e == RLC_E_FIXED_PART_DATA_FIELD_FOLLOW) { switch (fi) { @@ -400,11 +430,14 @@ rlc_um_try_reassembly( break; default: - AssertFatal( 0 , PROTOCOL_RLC_UM_CTXT_FMT" fi=%d! TRY REASSEMBLY SHOULD NOT GO HERE (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - fi, - __FILE__, - __LINE__); + //AssertFatal( 0 , PROTOCOL_RLC_UM_CTXT_FMT" fi=%d! TRY REASSEMBLY SHOULD NOT GO HERE (%s:%u)\n", + // PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + // fi, + // __FILE__, + // __LINE__); + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" fi=%d! TRY REASSEMBLY SHOULD NOT GO HERE (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), fi, __FILE__, __LINE__); + } } else { if (rlc_um_read_length_indicators(&data_p, e_li_p, li_array, &num_li, &size ) >= 0) { @@ -543,11 +576,14 @@ rlc_um_try_reassembly( // data_p is already ok, done by last loop above rlc_um_reassembly (ctxt_pP, rlc_pP, data_p, size); } else { - AssertFatal( 0 !=0, PROTOCOL_RLC_UM_CTXT_FMT" size=%d! SHOULD NOT GO HERE (%s:%u)\n", - PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), - size, - __FILE__, - __LINE__); + //AssertFatal( 0 !=0, PROTOCOL_RLC_UM_CTXT_FMT" size=%d! SHOULD NOT GO HERE (%s:%u)\n", + // PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), + // size, + // __FILE__, + // __LINE__); + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" size=%d! SHOULD NOT GO HERE (%s:%u)\n", + PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), size, __FILE__, __LINE__); + //rlc_pP->stat_rx_data_pdu_dropped += 1; rlc_pP->stat_rx_data_bytes_dropped += size; } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c index 758630b3cc..0a6bf44dda 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c @@ -52,7 +52,7 @@ rlc_um_fsm_notify_event ( LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM NULL_STATE\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP, rlc_pP), eventP); - AssertFatal(1==0,"RLC-UM FSM WARNING PROTOCOL ERROR - EVENT NOT EXPECTED FROM NULL_STATE"); + //AssertFatal(1==0,"RLC-UM FSM WARNING PROTOCOL ERROR - EVENT NOT EXPECTED FROM NULL_STATE"); return 0; } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c index f9af7c1cc2..26a68849dd 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c @@ -411,7 +411,11 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP #if TRACE_RLC_PAYLOAD rlc_util_print_hex_octets(RLC, pdu_mem_p->data, data_pdu_size); #endif - AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT10: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); + //AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT10: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); + if(pdu_tb_req_p->tb_size <= 0) { + LOG_E(RLC, "SEGMENT10: FINAL RLC UM PDU LENGTH %d\n", pdu_tb_req_p->tb_size); + break; + } pdu_p = NULL; pdu_mem_p = NULL; @@ -792,7 +796,11 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) #if TRACE_RLC_PAYLOAD rlc_util_print_hex_octets(RLC, (unsigned char*)pdu_mem_p->data, data_pdu_size); #endif - AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT5: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); + //AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT5: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); + if(pdu_tb_req_p->tb_size <= 0) { + LOG_E(RLC, "SEGMENT5: FINAL RLC UM PDU LENGTH %d\n", pdu_tb_req_p->tb_size); + break; + } pdu_p = NULL; pdu_mem_p = NULL; diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index d25b30e7cc..8aabed81ba 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -354,7 +354,11 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, } DevAssert(sdu_pP != NULL); - DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0); + //DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0); + if(sdu_sizeP <= 0) { + LOG_E(RLC, "sdu_sizeP %d, file %s, line %s\n", sdu_sizeP, __FILE__ ,__LINE__); + return RLC_OP_STATUS_BAD_PARAMETER; + } #if !defined(Rel10) && !defined(Rel14) DevCheck(MBMS_flagP == 0, MBMS_flagP, 0, 0); @@ -608,7 +612,11 @@ rlc_module_init (void) rlc_rrc_data_conf = NULL; rlc_coll_p = hashtable_create ((maxDRB + 2) * 16, NULL, rb_free_rlc_union); - AssertFatal(rlc_coll_p != NULL, "UNRECOVERABLE error, RLC hashtable_create failed"); + //AssertFatal(rlc_coll_p != NULL, "UNRECOVERABLE error, RLC hashtable_create failed"); + if(rlc_coll_p == NULL) { + LOG_E(RLC, "UNRECOVERABLE error, RLC hashtable_create failed\n"); + return -1; + } for (module_id1=0; module_id1 < NUMBER_OF_UE_MAX; module_id1++) { #if defined(Rel10) || defined(Rel14) From b58ecfc5d8155259d31e90ea81cc99acd27d61e2 Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Mon, 9 Apr 2018 20:01:38 +0900 Subject: [PATCH 45/91] Change SCH_PAYLOAD_SIZE_MAX from 4096 to 8192. --- openair2/LAYER2/MAC/defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index f6c598976e..bf0e53b4af 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -84,7 +84,7 @@ #define PCCH_PAYLOAD_SIZE_MAX 128 #define RAR_PAYLOAD_SIZE_MAX 128 -#define SCH_PAYLOAD_SIZE_MAX 4096 +#define SCH_PAYLOAD_SIZE_MAX 8192 /// Logical channel ids from 36-311 (Note BCCH is not specified in 36-311, uses the same as first DRB) #if defined(Rel10) || defined(Rel14) From f8f149fd1b5a4f9d84980c220833fd017768cc25 Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Mon, 9 Apr 2018 20:05:45 +0900 Subject: [PATCH 46/91] Fix calculation of ul_total_buffer. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index a041885165..2a3a13d8d2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1868,10 +1868,10 @@ 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]); + 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,get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index])); if(ulsch_ue_select[CC_id].list[ulsch_ue_num].ul_total_buffer > 0){ - if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid]) - UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid]; + if (UE_template->ul_total_buffer > get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index])) + UE_template->ul_total_buffer -= get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); else UE_template->ul_total_buffer = 0; } else { From 43382defeceda18dc2316ff181cc1db29f7a5535 Mon Sep 17 00:00:00 2001 From: "teramoto.genki" Date: Mon, 9 Apr 2018 21:00:13 +0900 Subject: [PATCH 47/91] eNB RLC Assertions skip. --- .../RLC/AM_v9.3.0/rlc_am_status_report.c | 30 ++++++++++++--- .../AM_v9.3.0/rlc_am_timer_poll_retransmit.c | 13 +++++-- .../RLC/AM_v9.3.0/rlc_am_timer_reordering.c | 15 ++++++-- openair2/LAYER2/RLC/rlc.c | 31 ++++++++++++--- openair2/LAYER2/RLC/rlc_mac.c | 23 ++++++++--- openair2/LAYER2/RLC/rlc_rrc.c | 38 +++++++++++++++---- 6 files changed, 122 insertions(+), 28 deletions(-) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c index 092c7c65f1..22c5604708 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c @@ -611,7 +611,10 @@ rlc_am_send_status_pdu( /* Now process all Segments of sn_cursor if PDU not fully received */ if ((!status_report_completed) && (all_segments_received == 0) && (sn_cursor != rlc_pP->vr_ms)) { - AssertFatal (sn_nack == sn_cursor, "RLC AM Tx Status PDU Data sn_nack=%d and sn_cursor=%d should be equal LcId=%d\n",sn_nack,sn_cursor, rlc_pP->channel_id); + //AssertFatal (sn_nack == sn_cursor, "RLC AM Tx Status PDU Data sn_nack=%d and sn_cursor=%d should be equal LcId=%d\n",sn_nack,sn_cursor, rlc_pP->channel_id); + if(sn_nack != sn_cursor){ + LOG_E(RLC, "RLC AM Tx Status PDU Data sn_nack=%d and sn_cursor=%d should be equal LcId=%d\n",sn_nack,sn_cursor, rlc_pP->channel_id); + } /* First ensure there is enough TBS for at least 1 SOStart/SOEnd, else break */ if ((nb_bits_transmitted + RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)) <= nb_bits_to_transmit) { @@ -757,8 +760,14 @@ rlc_am_send_status_pdu( } // End main while NACK_SN /* Clear E1 of last nack_sn entry */ - AssertFatal ((control_pdu_info.num_nack) || (all_segments_received == 0), "RLC AM Tx Status PDU Data Error no NACK_SN vrR=%d vrMS=%d lastSN_NACK=%d Completed=%d NbBytesAvailable=%d LcId=%d\n", - rlc_pP->vr_r,rlc_pP->vr_ms,sn_nack,status_report_completed,(nb_bits_to_transmit >> 3),rlc_pP->channel_id); +// AssertFatal ((control_pdu_info.num_nack) || (all_segments_received == 0), "RLC AM Tx Status PDU Data Error no NACK_SN vrR=%d vrMS=%d lastSN_NACK=%d Completed=%d NbBytesAvailable=%d LcId=%d\n", +// rlc_pP->vr_r,rlc_pP->vr_ms,sn_nack,status_report_completed,(nb_bits_to_transmit >> 3),rlc_pP->channel_id); + if (!((control_pdu_info.num_nack) || (all_segments_received == 0))){ + LOG_E(RLC, "RLC AM Tx Status PDU Data Error no NACK_SN vrR=%d vrMS=%d lastSN_NACK=%d Completed=%d NbBytesAvailable=%d LcId=%d\n", + rlc_pP->vr_r,rlc_pP->vr_ms,sn_nack,status_report_completed,(nb_bits_to_transmit >> 3),rlc_pP->channel_id); + return; + } + if (control_pdu_info.num_nack) { control_pdu_info.nack_list[control_pdu_info.num_nack - 1].e1 = 0; } @@ -796,8 +805,13 @@ rlc_am_send_status_pdu( /* encode the control pdu */ pdu_size = (nb_bits_transmitted + 7) >> 3; - AssertFatal (pdu_size <= rlc_pP->nb_bytes_requested_by_mac, "RLC AM Tx Status PDU Data size=%d bigger than remaining TBS=%d nb_bits_transmitted=%d LcId=%d\n", +// AssertFatal (pdu_size <= rlc_pP->nb_bytes_requested_by_mac, "RLC AM Tx Status PDU Data size=%d bigger than remaining TBS=%d nb_bits_transmitted=%d LcId=%d\n", +// pdu_size,rlc_pP->nb_bytes_requested_by_mac,nb_bits_transmitted, rlc_pP->channel_id); + if(pdu_size > rlc_pP->nb_bytes_requested_by_mac){ + LOG_E(RLC, "RLC AM Tx Status PDU Data size=%d bigger than remaining TBS=%d nb_bits_transmitted=%d LcId=%d\n", pdu_size,rlc_pP->nb_bytes_requested_by_mac,nb_bits_transmitted, rlc_pP->channel_id); + return; + } #if TRACE_RLC_AM_STATUS_CREATION @@ -825,8 +839,14 @@ rlc_am_send_status_pdu( nb_bits_to_transmit >> 3); #endif - AssertFatal (pdu_size == ((nb_bits_transmitted + 7) >> 3), "RLC AM Tx Status PDU Data encoding size=%d different than expected=%d LcId=%d\n", +// AssertFatal (pdu_size == ((nb_bits_transmitted + 7) >> 3), "RLC AM Tx Status PDU Data encoding size=%d different than expected=%d LcId=%d\n", +// pdu_size,((nb_bits_transmitted + 7) >> 3), rlc_pP->channel_id); + if(pdu_size != ((nb_bits_transmitted + 7) >> 3)){ + LOG_E(RLC, "RLC AM Tx Status PDU Data encoding size=%d different than expected=%d LcId=%d\n", pdu_size,((nb_bits_transmitted + 7) >> 3), rlc_pP->channel_id); + pdu_size = 0; + return; + } // remaining bytes to transmit for RLC (retrans pdus and new data pdus) rlc_pP->nb_bytes_requested_by_mac = rlc_pP->nb_bytes_requested_by_mac - pdu_size; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c index 0b88e7c650..7069e099eb 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c @@ -87,9 +87,16 @@ rlc_am_check_timer_poll_retransmit( /* Look for the first retransmittable PDU starting from vtS - 1 */ while (sn != sn_end) { - tx_data_pdu_buffer_p = &rlc_pP->tx_data_pdu_buffer[sn % RLC_AM_WINDOW_SIZE]; - AssertFatal (tx_data_pdu_buffer_p->mem_block != NULL, "RLC AM Tpoll Retx expiry sn=%d ack=%d is empty vtA=%d vtS=%d LcId=%d\n", - sn, tx_data_pdu_buffer_p->flags.ack,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + tx_data_pdu_buffer_p = &rlc_pP->tx_data_pdu_buffer[sn % RLC_AM_WINDOW_SIZE]; + //AssertFatal (tx_data_pdu_buffer_p->mem_block != NULL, "RLC AM Tpoll Retx expiry sn=%d ack=%d is empty vtA=%d vtS=%d LcId=%d\n", + // sn, tx_data_pdu_buffer_p->flags.ack,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + if(tx_data_pdu_buffer_p->mem_block == NULL){ + LOG_E(RLC, "RLC AM Tpoll Retx expiry sn=%d ack=%d is empty vtA=%d vtS=%d LcId=%d\n", + sn, tx_data_pdu_buffer_p->flags.ack,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + sn = RLC_AM_PREV_SN(sn); + continue; + } + if ((tx_data_pdu_buffer_p->flags.ack == 0) && (tx_data_pdu_buffer_p->flags.max_retransmit == 0)) { tx_data_pdu_buffer_p->flags.retransmit = 1; tx_data_pdu_buffer_p->retx_payload_size = tx_data_pdu_buffer_p->payload_size; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c index b9383980a4..92bb3d6155 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c @@ -70,7 +70,12 @@ rlc_am_check_timer_reordering( PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP,rlc_pP)); #endif - AssertFatal (rlc_pP->vr_x != RLC_SN_UNDEFINED, "RLC AM TReordering Expiry vrX not defined LcId=%d\n", rlc_pP->channel_id); + //AssertFatal (rlc_pP->vr_x != RLC_SN_UNDEFINED, "RLC AM TReordering Expiry vrX not defined LcId=%d\n", rlc_pP->channel_id); + if(rlc_pP->vr_x == RLC_SN_UNDEFINED){ + LOG_E(RLC, "RLC AM TReordering Expiry vrX not defined LcId=%d\n", rlc_pP->channel_id); + return; + } + rlc_pP->t_reordering.running = 0; rlc_pP->t_reordering.timed_out = 1; @@ -81,8 +86,12 @@ rlc_am_check_timer_reordering( cursor = rlc_pP->receiver_buffer.head; rlc_usn_t vr_ms_new = rlc_pP->vr_x; - AssertFatal (cursor != NULL, "RLC AM TReordering Expiry Rx PDU list empty LcId=%d\n", rlc_pP->channel_id); - + //AssertFatal (cursor != NULL, "RLC AM TReordering Expiry Rx PDU list empty LcId=%d\n", rlc_pP->channel_id); + if(cursor == NULL){ + LOG_E(RLC, "RLC AM TReordering Expiry Rx PDU list empty LcId=%d\n", rlc_pP->channel_id); + return; + } + /* go to memblock up to vrX*/ pdu_info = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; while ((cursor != NULL) && (RLC_AM_DIFF_SN(pdu_info->sn,rlc_pP->vr_r) < RLC_AM_DIFF_SN(vr_ms_new,rlc_pP->vr_r))) { diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index d25b30e7cc..780012683a 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -135,7 +135,12 @@ rlc_op_status_t rlc_stat_req ( hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; - AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + if(rb_idP >= NB_RB_MAX){ + LOG_E(RLC, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + return RLC_OP_STATUS_BAD_PARAMETER; + } + key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -348,12 +353,26 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, #endif if (MBMS_flagP) { - AssertFatal (rb_idP < NB_RB_MBMS_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MBMS_MAX); + //AssertFatal (rb_idP < NB_RB_MBMS_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MBMS_MAX); + if(rb_idP >= NB_RB_MBMS_MAX){ + LOG_E(RLC, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MBMS_MAX); + return RLC_OP_STATUS_BAD_PARAMETER; + } } else { - AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + if(rb_idP >= NB_RB_MAX){ + LOG_E(RLC, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + return RLC_OP_STATUS_BAD_PARAMETER; + } } - DevAssert(sdu_pP != NULL); + //DevAssert(sdu_pP != NULL); + if(sdu_pP == NULL){ + LOG_E(RLC, "sdu_pP == NULL\n"); + return RLC_OP_STATUS_BAD_PARAMETER; + } + + DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0); #if !defined(Rel10) && !defined(Rel14) @@ -386,7 +405,9 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, rlc_mode = rlc_union_p->mode; } else { rlc_mode = RLC_MODE_NONE; - AssertFatal (0 , "RLC not configured key %ju\n", key); + //AssertFatal (0 , "RLC not configured key %ju\n", key); + LOG_E("RLC not configured key %ju\n", key); + return RLC_OP_STATUS_OUT_OF_RESSOURCES; } if (MBMS_flagP == 0) { diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index da9c29c4de..c949702ea3 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -152,9 +152,17 @@ tbs_size_t mac_rlc_data_req( #endif // DEBUG_MAC_INTERFACE if (MBMS_flagP) { - AssertFatal (channel_idP < RLC_MAX_MBMS_LC, "channel id is too high (%u/%d)!\n", channel_idP, RLC_MAX_MBMS_LC); + //AssertFatal (channel_idP < RLC_MAX_MBMS_LC, "channel id is too high (%u/%d)!\n", channel_idP, RLC_MAX_MBMS_LC); + if(channel_idP >= RLC_MAX_MBMS_LC){ + LOG_E(RLC, "channel id is too high (%u/%d)!\n", channel_idP, RLC_MAX_MBMS_LC); + return 0; + } } else { - AssertFatal (channel_idP < NB_RB_MAX, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); + //AssertFatal (channel_idP < NB_RB_MAX, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); + if(channel_idP >= NB_RB_MAX){ + LOG_E(RLC, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); + return 0; + } } if (MBMS_flagP) { @@ -174,7 +182,8 @@ tbs_size_t mac_rlc_data_req( rlc_mode = rlc_union_p->mode; } else { rlc_mode = RLC_MODE_NONE; - AssertFatal (0 , "RLC not configured lcid %u RNTI %x!\n", channel_idP, rntiP); + //AssertFatal (0 , "RLC not configured lcid %u RNTI %x!\n", channel_idP, rntiP); + LOG_E(RLC, "RLC not configured lcid %u RNTI %x!\n", channel_idP, rntiP); } switch (rlc_mode) { @@ -419,8 +428,12 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( /* Assumptions : for UE only */ /* At each TTI, Buffer Occupancy is first computed in mac_rlc_status_ind called by MAC ue_scheduler() function */ /* Then this function is called during MAC multiplexing ue_get_sdu(), and it may be call several times for the same bearer if it is in AM mode and there are several PDU types to transmit */ - AssertFatal(enb_flagP == FALSE,"RLC Tx mac_rlc_get_buffer_occupancy_ind function is not implemented for eNB LcId=%d\n", channel_idP); - + //AssertFatal(enb_flagP == FALSE,"RLC Tx mac_rlc_get_buffer_occupancy_ind function is not implemented for eNB LcId=%d\n", channel_idP); + if(enb_flagP != FALSE){ + LOG_E("RLC Tx mac_rlc_get_buffer_occupancy_ind function is not implemented for eNB LcId=%d\n", channel_idP); + return 0; + } + key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag); diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index dee6ba7000..f4acdb29df 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -373,7 +373,10 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP rb_id, lc_id, RLC_MODE_UM); - AssertFatal(rlc_union_p != NULL, "ADD MBMS RLC UM FAILED"); + //AssertFatal(rlc_union_p != NULL, "ADD MBMS RLC UM FAILED"); + if(rlc_union_p == NULL){ + LOG_E(RLC, "ADD MBMS RLC UM FAILED\n"); + } } LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG REQ MBMS ASN1 LC ID %u RB ID %u SESSION ID %u SERVICE ID %u\n", @@ -511,7 +514,11 @@ rlc_op_status_t rrc_rlc_remove_rlc ( } - AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + if(rb_idP >= NB_RB_MAX){ + LOG_E(RLC, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + return RLC_OP_STATUS_BAD_PARAMETER; + } h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); @@ -585,8 +592,17 @@ rlc_union_t* rrc_rlc_add_rlc ( #endif if (MBMS_flagP == FALSE) { - AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); - AssertFatal (chan_idP < RLC_MAX_LC, "LC id is too high (%u/%d)!\n", chan_idP, RLC_MAX_LC); + //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + //AssertFatal (chan_idP < RLC_MAX_LC, "LC id is too high (%u/%d)!\n", chan_idP, RLC_MAX_LC); + if(rb_idP >= NB_RB_MAX){ + LOG_E(RLC, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + return NULL; + } + if(chan_idP >= RLC_MAX_LC){ + LOG_E(RLC, "LC id is too high (%u/%d)!\n", chan_idP, RLC_MAX_LC); + return NULL; + } + } #if defined(Rel10) || defined(Rel14) @@ -623,8 +639,12 @@ rlc_union_t* rrc_rlc_add_rlc ( (srb_flagP) ? "SRB" : "DRB", rb_idP, (srb_flagP) ? "SRB" : "DRB"); - AssertFatal(rlc_union_p->mode == rlc_modeP, "Error rrc_rlc_add_rlc , already exist but RLC mode differ"); - return rlc_union_p; + //AssertFatal(rlc_union_p->mode == rlc_modeP, "Error rrc_rlc_add_rlc , already exist but RLC mode differ"); + if(rlc_union_p->mode != rlc_modeP){ + LOG_E(RLC, "Error rrc_rlc_add_rlc , already exist but RLC mode differ\n"); + return NULL; + } + return rlc_union_p; } else if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) { rlc_union_p = calloc(1, sizeof(rlc_union_t)); h_rc = hashtable_insert(rlc_coll_p, key, rlc_union_p); @@ -687,7 +707,11 @@ rlc_op_status_t rrc_rlc_config_req ( PROTOCOL_CTXT_ARGS(ctxt_pP), rb_idP); - AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + //AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + if(rb_idP >= NB_RB_MAX){ + LOG_E(RLC, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + return RLC_OP_STATUS_BAD_PARAMETER; + } switch (actionP) { From 03232d30c2a326c7f0bd835e3f2014147fd0f709 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Tue, 10 Apr 2018 15:37:30 +0900 Subject: [PATCH 48/91] RLC assertion 760~796 add 1428 1429 --- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c | 9 + .../LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c | 14 +- .../LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c | 18 +- .../LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c | 172 ++++++++++++++++-- .../LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c | 105 ++++++++++- 5 files changed, 287 insertions(+), 31 deletions(-) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c index a133ce0992..dff1545612 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c @@ -42,8 +42,17 @@ void rlc_am_free_in_sdu( { if (index_in_bufferP <= RLC_AM_SDU_CONTROL_BUFFER_SIZE) { /* BugFix: SDU shall have been already freed during initial PDU segmentation or concatenation !! */ +//Assertion(eNB)_PRAN_DesignDocument_annex No.761 + if(rlcP->input_sdus[index_in_bufferP].mem_block != NULL) + { + LOG_E(RLC, "RLC AM Tx SDU Conf: Data Part is not empty index=%d LcId=%d\n", + index_in_bufferP,rlcP->channel_id); + return; + } +/* AssertFatal(rlcP->input_sdus[index_in_bufferP].mem_block == NULL, "RLC AM Tx SDU Conf: Data Part is not empty index=%d LcId=%d\n", index_in_bufferP,rlcP->channel_id); +*/ /* if (rlcP->input_sdus[index_in_bufferP].mem_block != NULL) { free_mem_block(rlcP->input_sdus[index_in_bufferP].mem_block, __func__); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c index d0b5b52395..43a946cb0c 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c @@ -198,10 +198,16 @@ rlc_am_send_sdu ( PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); //msg("[RLC_AM][MOD %d] Freeing mem_block ...\n", rlc_pP->module_id); //free_mem_block (rlc_pP->output_sdu_in_construction, __func__); +//Assertion(eNB)_PRAN_DesignDocument_annex No.764 + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" SEND SDU REQUESTED %d bytes\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), + rlc_pP->output_sdu_size_to_write); +/* AssertFatal(3==4, PROTOCOL_RLC_AM_CTXT_FMT" SEND SDU REQUESTED %d bytes", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->output_sdu_size_to_write); +*/ } rlc_pP->output_sdu_size_to_write = 0; @@ -270,7 +276,9 @@ rlc_am_reassemble_pdu( break; default: - assert(0 != 0); +//Assertion(eNB)_PRAN_DesignDocument_annex No.1428 + LOG_E(RLC, "RLC_E_FIXED_PART_DATA_FIELD_FOLLOW error pdu_info->fi[%d]\n", pdu_info->fi); +// assert(0 != 0); } } else { switch (pdu_info->fi) { @@ -386,7 +394,9 @@ rlc_am_reassemble_pdu( break; default: - assert(1 != 1); +//Assertion(eNB)_PRAN_DesignDocument_annex No.1429 + LOG_E(RLC, "not RLC_E_FIXED_PART_DATA_FIELD_FOLLOW error pdu_info->fi[%d]\n", pdu_info->fi); +// assert(1 != 1); } } 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 42bdd56e77..06fc3a5416 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 @@ -47,9 +47,15 @@ rlc_am_get_data_pdu_infos( pdu_info_pP->d_c = header_pP->b1 >> 7; pdu_info_pP->num_li = 0; - +//Assertion(eNB)_PRAN_DesignDocument_annex No.766 + if(pdu_info_pP->d_c == 0) + { + LOG_E(RLC, "RLC AM Rx PDU Data D/C Header Error LcId=%d\n", rlc_pP->channel_id); + return -2; + } +/* AssertFatal (pdu_info_pP->d_c != 0, "RLC AM Rx PDU Data D/C Header Error LcId=%d\n", rlc_pP->channel_id); - +*/ pdu_info_pP->rf = (header_pP->b1 >> 6) & 0x01; pdu_info_pP->p = (header_pP->b1 >> 5) & 0x01; pdu_info_pP->fi = (header_pP->b1 >> 3) & 0x03; @@ -264,9 +270,17 @@ rlc_am_receive_routing ( rlc_pP->stat_rx_control_pdu += 1; rlc_am_receive_process_control_pdu (ctxt_pP, rlc_pP, tb_p, &first_byte_p, &tb_size_in_bytes); // Test if remaining bytes not processed (up to know, highest probability is bug in MAC) +//Assertion(eNB)_PRAN_DesignDocument_annex No.767 + if(tb_size_in_bytes != 0) + { + LOG_E(RLC, "Remaining %d bytes following a control PDU\n", + tb_size_in_bytes); + } +/* AssertFatal( tb_size_in_bytes == 0, "Remaining %d bytes following a control PDU", tb_size_in_bytes); +*/ } LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[RX ROUTING] VR(R)=%03d VR(MR)=%03d\n", diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c index 9e1db8a95b..eb47b9ba28 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c @@ -225,9 +225,18 @@ void rlc_am_ack_pdu ( } if (tx_data_pdu_buffer->retx_payload_size) { +//Assertion(eNB)_PRAN_DesignDocument_annex No.768 + if(tx_data_pdu_buffer->flags.ack != 0) + { + LOG_E(RLC, "RLC AM Rx Status Report sn=%d acked twice but is pending for Retx vtA=%d vtS=%d LcId=%d\n", + snP, rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal (tx_data_pdu_buffer->flags.ack == 0, "RLC AM Rx Status Report sn=%d acked twice but is pending for Retx vtA=%d vtS=%d LcId=%d\n", snP, rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); +*/ rlc_pP->retrans_num_bytes_to_retransmit -= tx_data_pdu_buffer->retx_payload_size; tx_data_pdu_buffer->retx_payload_size = 0; tx_data_pdu_buffer->num_holes = 0; @@ -256,10 +265,17 @@ mem_block_t* rlc_am_retransmit_get_copy ( const rlc_sn_t snP) { mem_block_t* mb_original_p = rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE].mem_block; - +//Assertion(eNB)_PRAN_DesignDocument_annex No.784 + if(mb_original_p == NULL) + { + LOG_E(RLC,"RLC AM PDU Copy Error: Empty block sn=%d vtA=%d vtS=%d LcId=%d !\n", + snP,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal (mb_original_p != NULL, "RLC AM PDU Copy Error: Empty block sn=%d vtA=%d vtS=%d LcId=%d !\n", snP,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - +*/ rlc_am_tx_data_pdu_management_t *pdu_mngt = &rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE]; /* We need to allocate a new buffer and copy to it because header content may change for Polling bit */ @@ -295,20 +311,43 @@ mem_block_t* rlc_am_retransmit_get_am_segment( uint8_t li_bit_offset = 4; /* toggle between 0 and 4 */ uint8_t li_jump_offset = 1; /* toggle between 1 and 2 */ - +//Assertion(eNB)_PRAN_DesignDocument_annex No.774 + if(mb_original_p == NULL) + { + LOG_E(RLC,"RLC AM PDU Segment Error: Empty block sn=%d vtA=%d vtS=%d LcId=%d !\n", + sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal (mb_original_p != NULL, "RLC AM PDU Segment Error: Empty block sn=%d vtA=%d vtS=%d LcId=%d !\n", sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - - +*/ +//Assertion(eNB)_PRAN_DesignDocument_annex No.775 + if(pdu_mngt->payload != mb_original_p->data + sizeof(struct mac_tb_req) + pdu_mngt->header_and_payload_size - pdu_mngt->payload_size) + { + LOG_E(RLC,"RLC AM PDU Segment Error: Inconsistent data pointers p1=%p p2=%p sn = %d total size = %d data size = %d LcId=%d !\n", + pdu_mngt->payload,mb_original_p->data + sizeof(struct mac_tb_req),pdu_mngt->header_and_payload_size,pdu_mngt->payload_size,sn,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal (pdu_mngt->payload == mb_original_p->data + sizeof(struct mac_tb_req) + pdu_mngt->header_and_payload_size - pdu_mngt->payload_size, "RLC AM PDU Segment Error: Inconsistent data pointers p1=%p p2=%p sn = %d total size = %d data size = %d LcId=%d !\n", pdu_mngt->payload,mb_original_p->data + sizeof(struct mac_tb_req),pdu_mngt->header_and_payload_size,pdu_mngt->payload_size,sn,rlc_pP->channel_id); - +*/ /* Init ReTx Hole list if not configured, ie the whole PDU has to be retransmitted */ if (pdu_mngt->num_holes == 0) { +//Assertion(eNB)_PRAN_DesignDocument_annex No.776 + if(pdu_mngt->retx_payload_size != pdu_mngt->payload_size) + { + LOG_E(RLC,"RLC AM PDU ReTx Segment: Expecting full PDU size ReTxSize=%d DataSize=%d sn=%d vtA=%d vtS=%d LcId=%d !\n", + pdu_mngt->retx_payload_size,pdu_mngt->payload_size,sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal (pdu_mngt->retx_payload_size == pdu_mngt->payload_size,"RLC AM PDU ReTx Segment: Expecting full PDU size ReTxSize=%d DataSize=%d sn=%d vtA=%d vtS=%d LcId=%d !\n", pdu_mngt->retx_payload_size,pdu_mngt->payload_size,sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); +*/ pdu_mngt->retx_hole_index = 0; pdu_mngt->hole_so_start[0] = 0; pdu_mngt->hole_so_stop[0] = pdu_mngt->payload_size - 1; @@ -318,11 +357,18 @@ mem_block_t* rlc_am_retransmit_get_am_segment( /* Init SO Start and SO Stop */ retx_so_start = pdu_mngt->hole_so_start[pdu_mngt->retx_hole_index]; retx_so_stop = pdu_mngt->hole_so_stop[pdu_mngt->retx_hole_index]; - +//Assertion(eNB)_PRAN_DesignDocument_annex No.777 + if((retx_so_start > retx_so_stop) || (retx_so_stop - retx_so_start + 1 > pdu_mngt->payload_size)) + { + LOG_E(RLC,"RLC AM Tx PDU Segment Data SO Error: retx_so_start=%d retx_so_stop=%d OriginalPDUDataLength=%d sn=%d LcId=%d!\n", + retx_so_start,retx_so_stop,pdu_mngt->payload_size,sn,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal ((retx_so_start <= retx_so_stop) && (retx_so_stop - retx_so_start + 1 <= pdu_mngt->payload_size), "RLC AM Tx PDU Segment Data SO Error: retx_so_start=%d retx_so_stop=%d OriginalPDUDataLength=%d sn=%d LcId=%d!\n", retx_so_start,retx_so_stop,pdu_mngt->payload_size,sn,rlc_pP->channel_id); - +*/ /* Init FI to the same value as original PDU */ fi_start = (!(RLC_AM_PDU_GET_FI_START(*(pdu_mngt->first_byte)))); fi_end = (!(RLC_AM_PDU_GET_FI_END(*(pdu_mngt->first_byte)))); @@ -408,8 +454,17 @@ mem_block_t* rlc_am_retransmit_get_am_segment( /* Set FI Start if retx_so_start = cumulated data size */ fi_start = TRUE; /* there must be at least one SDU more */ +//Assertion(eNB)_PRAN_DesignDocument_annex No.778 + if(sdu_index >= pdu_mngt->nb_sdus) + { + LOG_E(RLC,"RLC AM Tx PDU Segment Error: sdu_index=%d nb_sdus=%d sn=%d LcId=%d !\n", + sdu_index,pdu_mngt->nb_sdus,sn,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal (sdu_index < pdu_mngt->nb_sdus, "RLC AM Tx PDU Segment Error: sdu_index=%d nb_sdus=%d sn=%d LcId=%d !\n", sdu_index,pdu_mngt->nb_sdus,sn,rlc_pP->channel_id); +*/ if (sdu_index < pdu_mngt->nb_sdus - 1) { temp_read = ((*pdu_original_header_p) << 8) | (*(pdu_original_header_p + 1)); @@ -487,17 +542,33 @@ mem_block_t* rlc_am_retransmit_get_am_segment( /* Set number of LIs in the segment */ num_LIs_pdu_segment = sdu_segment_index - 1; - +//Assertion(eNB)_PRAN_DesignDocument_annex No.779 + if(num_LIs_pdu_segment > pdu_mngt->nb_sdus - 1) + { + LOG_E(RLC, "RLC AM Tx PDU Segment Data Error: nbLISegment=%d nbLIPDU=%d sn=%d LcId=%d !\n", + num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,sn,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal (num_LIs_pdu_segment <= pdu_mngt->nb_sdus - 1, "RLC AM Tx PDU Segment Data Error: nbLISegment=%d nbLIPDU=%d sn=%d LcId=%d !\n", num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,sn,rlc_pP->channel_id); - +*/ /* Bound to available TBS taking into account min PDU segment header*/ sdu_segment_index = 0; while ((sdu_segment_index < num_LIs_pdu_segment + 1) && (rlc_pP->nb_bytes_requested_by_mac > *payload_sizeP + RLC_AM_PDU_SEGMENT_HEADER_SIZE(sdu_segment_index))) { +//Assertion(eNB)_PRAN_DesignDocument_annex No.780 + if(sdus_segment_size[sdu_segment_index] <= 0) + { + LOG_E(RLC, "RLC AM Tx PDU Segment Data Error: EMpty LI index=%d numLISegment=%d numLIPDU=%d PDULength=%d SOStart=%d SOStop=%d sn=%d LcId=%d !\n", + sdu_segment_index,num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,pdu_mngt->payload_size,retx_so_start,retx_so_stop,sn,rlc_pP->channel_id); + sdu_segment_index++; + continue; + } +/* AssertFatal (sdus_segment_size[sdu_segment_index] > 0, "RLC AM Tx PDU Segment Data Error: EMpty LI index=%d numLISegment=%d numLIPDU=%d PDULength=%d SOStart=%d SOStop=%d sn=%d LcId=%d !\n", sdu_segment_index,num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,pdu_mngt->payload_size,retx_so_start,retx_so_stop,sn,rlc_pP->channel_id); - +*/ /* Add next sdu_segment_index to data part */ if (RLC_AM_PDU_SEGMENT_HEADER_SIZE(sdu_segment_index) + (*payload_sizeP) + sdus_segment_size[sdu_segment_index] <= rlc_pP->nb_bytes_requested_by_mac) { @@ -519,11 +590,18 @@ mem_block_t* rlc_am_retransmit_get_am_segment( /* update retx_so_stop */ retx_so_stop = retx_so_start + (*payload_sizeP) - 1; - +//Assertion(eNB)_PRAN_DesignDocument_annex No.781 + if((retx_so_stop > pdu_mngt->payload_size - 1) || (retx_so_stop - retx_so_start + 1 >= pdu_mngt->payload_size)) + { + LOG_E(RLC,"RLC AM Tx PDU Segment Data Error: retx_so_stop=%d OriginalPDUDataLength=%d SOStart=%d SegmentLength=%d numLISegment=%d numLIPDU=%d sn=%d LcId=%d !\n", + retx_so_stop,pdu_mngt->payload_size,retx_so_start,*payload_sizeP,num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,sn,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal ((retx_so_stop <= pdu_mngt->payload_size - 1) && (retx_so_stop - retx_so_start + 1 < pdu_mngt->payload_size), "RLC AM Tx PDU Segment Data Error: retx_so_stop=%d OriginalPDUDataLength=%d SOStart=%d SegmentLength=%d numLISegment=%d numLIPDU=%d sn=%d LcId=%d !\n", retx_so_stop,pdu_mngt->payload_size,retx_so_start,*payload_sizeP,num_LIs_pdu_segment,pdu_mngt->nb_sdus - 1,sn,rlc_pP->channel_id); - +*/ /* init FI End to FALSE if retx_so_stop is not end of PDU */ if (retx_so_stop != pdu_mngt->payload_size - 1) { @@ -541,15 +619,31 @@ mem_block_t* rlc_am_retransmit_get_am_segment( fi_end = TRUE; } } - +//Assertion(eNB)_PRAN_DesignDocument_annex No.782 + if(data_size != *payload_sizeP) + { + LOG_E(RLC,"RLC AM Tx PDU Segment Data Error: SduSum=%d Data=%d sn=%d LcId=%d !\n", + data_size,*payload_sizeP,sn,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal (data_size == *payload_sizeP, "RLC AM Tx PDU Segment Data Error: SduSum=%d Data=%d sn=%d LcId=%d !\n", data_size,*payload_sizeP,sn,rlc_pP->channel_id); - +*/ /* Allocation */ +//Assertion(eNB)_PRAN_DesignDocument_annex No.783 + if(header_segment_length + *payload_sizeP > pdu_mngt->header_and_payload_size + 2) + { + LOG_E(RLC, "RLC AM PDU Segment Error: Hdr=%d Data=%d Original Hdr+Data =%d sn=%d LcId=%d !\n", + header_segment_length,*payload_sizeP,pdu_mngt->header_and_payload_size,sn,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal (header_segment_length + *payload_sizeP <= pdu_mngt->header_and_payload_size + 2, "RLC AM PDU Segment Error: Hdr=%d Data=%d Original Hdr+Data =%d sn=%d LcId=%d !\n", header_segment_length,*payload_sizeP,pdu_mngt->header_and_payload_size,sn,rlc_pP->channel_id); +*/ mem_pdu_segment_p = get_free_mem_block((*payload_sizeP + header_segment_length + sizeof(struct mac_tb_req)), __func__); pdu_segment_header_p = (uint8_t *)&mem_pdu_segment_p->data[sizeof(struct mac_tb_req)]; ((struct mac_tb_req*)(mem_pdu_segment_p->data))->data_ptr = pdu_segment_header_p; @@ -1193,22 +1287,50 @@ mem_block_t * rlc_am_get_pdu_to_retransmit( rlc_sn_t sn_end = rlc_pP->vt_s; mem_block_t* pdu_p = NULL; rlc_am_tx_data_pdu_management_t* tx_data_pdu_management; - +//Assertion(eNB)_PRAN_DesignDocument_annex No.769 + if((rlc_pP->retrans_num_pdus <= 0) || (rlc_pP->vt_a == rlc_pP->vt_s)) + { + LOG_E(RLC, "RLC AM ReTx start process Error: NbPDUtoRetx=%d vtA=%d vtS=%d LcId=%d !\n", + rlc_pP->retrans_num_pdus,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + return NULL; + } +/* AssertFatal ((rlc_pP->retrans_num_pdus > 0) && (rlc_pP->vt_a != rlc_pP->vt_s), "RLC AM ReTx start process Error: NbPDUtoRetx=%d vtA=%d vtS=%d LcId=%d !\n", rlc_pP->retrans_num_pdus,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - +*/ do { tx_data_pdu_management = &rlc_pP->tx_data_pdu_buffer[sn % RLC_AM_WINDOW_SIZE]; if ((tx_data_pdu_management->flags.retransmit) && (tx_data_pdu_management->flags.max_retransmit == 0)) { +//Assertion(eNB)_PRAN_DesignDocument_annex No.770 + if(tx_data_pdu_management->sn != sn) + { + LOG_E(RLC, "RLC AM ReTx PDU Error: SN Error pdu_sn=%d sn=%d vtA=%d vtS=%d LcId=%d !\n", + tx_data_pdu_management->sn,sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + } +//Assertion(eNB)_PRAN_DesignDocument_annex No.771 + else if(tx_data_pdu_management->flags.transmitted != 1) + { + LOG_E(RLC, "RLC AM ReTx PDU Error: State Error sn=%d vtA=%d vtS=%d LcId=%d !\n", + sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + } +//Assertion(eNB)_PRAN_DesignDocument_annex No.772 + else if(tx_data_pdu_management->retx_payload_size <= 0) + { + LOG_E(RLC, "RLC AM ReTx PDU Error: No Data to Retx sn=%d vtA=%d vtS=%d LcId=%d !\n", + sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); + } + else + { +/* AssertFatal (tx_data_pdu_management->sn == sn, "RLC AM ReTx PDU Error: SN Error pdu_sn=%d sn=%d vtA=%d vtS=%d LcId=%d !\n", tx_data_pdu_management->sn,sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); AssertFatal (tx_data_pdu_management->flags.transmitted == 1, "RLC AM ReTx PDU Error: State Error sn=%d vtA=%d vtS=%d LcId=%d !\n", sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); AssertFatal (tx_data_pdu_management->retx_payload_size > 0, "RLC AM ReTx PDU Error: No Data to Retx sn=%d vtA=%d vtS=%d LcId=%d !\n", sn,rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - +*/ /* Either the whole RLC PDU is to be transmitted and there is enough MAC TBS or there is minimum TBS size for transmitting 1 AM PDU segment */ if ((tx_data_pdu_management->retx_payload_size == tx_data_pdu_management->payload_size) && (rlc_pP->nb_bytes_requested_by_mac >= tx_data_pdu_management->header_and_payload_size)) { @@ -1256,9 +1378,18 @@ mem_block_t * rlc_am_get_pdu_to_retransmit( if (pdu_p != NULL) { +//Assertion(eNB)_PRAN_DesignDocument_annex No.773 + if((tx_data_pdu_management->retx_payload_size < pdu_data_size)|| (rlc_pP->retrans_num_bytes_to_retransmit < pdu_data_size)) + { + LOG_E(RLC, "RLC AM ReTx PDU Segment Error: DataSize=%d PDUReTxsize=%d TotalReTxsize=%d sn=%d LcId=%d !\n", + pdu_data_size,tx_data_pdu_management->retx_payload_size,rlc_pP->retrans_num_bytes_to_retransmit,sn,rlc_pP->channel_id); + } + else + { +/* AssertFatal ((tx_data_pdu_management->retx_payload_size >= pdu_data_size) && (rlc_pP->retrans_num_bytes_to_retransmit >= pdu_data_size), "RLC AM ReTx PDU Segment Error: DataSize=%d PDUReTxsize=%d TotalReTxsize=%d sn=%d LcId=%d !\n", pdu_data_size,tx_data_pdu_management->retx_payload_size,rlc_pP->retrans_num_bytes_to_retransmit,sn,rlc_pP->channel_id); - +*/ tx_data_pdu_management->retx_payload_size -= pdu_data_size; rlc_pP->retrans_num_bytes_to_retransmit -= pdu_data_size; if (tx_data_pdu_management->retx_payload_size == 0) @@ -1276,6 +1407,7 @@ mem_block_t * rlc_am_get_pdu_to_retransmit( rlc_pP->stat_tx_retransmit_bytes += pdu_data_size; rlc_pP->stat_tx_retransmit_bytes_by_status += pdu_data_size; + }//Assertion(eNB)_PRAN_DesignDocument_annex No.773 } } else @@ -1300,8 +1432,8 @@ mem_block_t * rlc_am_get_pdu_to_retransmit( break; } + }//Assertion(eNB)_PRAN_DesignDocument_annex No.770 No.771 No.772 } - sn = RLC_AM_NEXT_SN(sn); } while((sn != sn_end) && (rlc_pP->retrans_num_pdus > 0)); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c index dc1ed21163..2691107f02 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c @@ -53,8 +53,17 @@ boolean_t rlc_am_rx_check_vr_reassemble( if (pdu_info_p->rf) { pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); next_waited_so = 0; +//Assertion(eNB)_PRAN_DesignDocument_annex No.785 + if(pdu_cursor_mgnt_p->all_segments_received <= 0) + { + LOG_E(RLC, "AM Rx Check Reassembly head SN=%d with PDU segments != vrR=%d should be fully received LCID=%d\n", + sn_ref,rlc_pP->vr_r,rlc_pP->channel_id); + return FALSE; + } +/* AssertFatal(pdu_cursor_mgnt_p->all_segments_received > 0,"AM Rx Check Reassembly head SN=%d with PDU segments != vrR=%d should be fully received LCID=%d\n", sn_ref,rlc_pP->vr_r,rlc_pP->channel_id); +*/ while ((cursor_p != NULL) && (pdu_info_p->sn == sn_ref) && (pdu_info_p->so == next_waited_so)) { if (pdu_cursor_mgnt_p->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO) { pdu_cursor_mgnt_p->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING; @@ -80,8 +89,17 @@ boolean_t rlc_am_rx_check_vr_reassemble( if ((cursor_p != NULL) && (pdu_info_p->sn == rlc_pP->vr_r)) { pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); next_waited_so = 0; +//Assertion(eNB)_PRAN_DesignDocument_annex No.786 + if(pdu_cursor_mgnt_p->all_segments_received != 0) + { + LOG_E(RLC, "AM Rx Check Reassembly vr=%d should be partly received SNHead=%d LCID=%d\n", + rlc_pP->vr_r,sn_ref,rlc_pP->channel_id); + return FALSE; + } +/* AssertFatal(pdu_cursor_mgnt_p->all_segments_received == 0,"AM Rx Check Reassembly vr=%d should be partly received SNHead=%d LCID=%d\n", rlc_pP->vr_r,sn_ref,rlc_pP->channel_id); +*/ while ((cursor_p != NULL) && (pdu_info_p->sn == rlc_pP->vr_r) && (pdu_info_p->so == next_waited_so)) { if (pdu_cursor_mgnt_p->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO) { pdu_cursor_mgnt_p->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING; @@ -100,8 +118,17 @@ boolean_t rlc_am_rx_check_vr_reassemble( pdu_cursor_mgnt_p = (rlc_am_rx_pdu_management_t *) (cursor_p->data); next_waited_so = 0; +//Assertion(eNB)_PRAN_DesignDocument_annex No.787 + if(pdu_cursor_mgnt_p->all_segments_received != 0) + { + LOG_E(RLC, "AM Rx Check Reassembly SNHead=vr=%d should be partly received LCID=%d\n", + rlc_pP->vr_r,rlc_pP->channel_id); + return FALSE; + } +/* AssertFatal(pdu_cursor_mgnt_p->all_segments_received == 0,"AM Rx Check Reassembly SNHead=vr=%d should be partly received LCID=%d\n", rlc_pP->vr_r,rlc_pP->channel_id); +*/ while ((cursor_p != NULL) && (pdu_info_p->sn == rlc_pP->vr_r) && (pdu_info_p->so == next_waited_so)) { if (pdu_cursor_mgnt_p->segment_reassembled == RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_NO) { pdu_cursor_mgnt_p->segment_reassembled = RLC_AM_RX_PDU_SEGMENT_REASSEMBLE_PENDING; @@ -333,8 +360,15 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu_segment( /*****************************************************/ // 1) Find previous cursor to the PDU to insert /*****************************************************/ +//Assertion(eNB)_PRAN_DesignDocument_annex No.791 + if(cursor_p == NULL) + { + LOG_E(RLC, "AM Rx PDU Error, received buffer empty LcID=%d\n",rlc_pP->channel_id); + return RLC_AM_DATA_PDU_STATUS_HEADER_ERROR; + } +/* AssertFatal(cursor_p != NULL,"AM Rx PDU Error, received buffer empty LcID=%d\n",rlc_pP->channel_id); - +*/ do { pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; @@ -483,11 +517,20 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu_segment( } } +//Assertion(eNB)_PRAN_DesignDocument_annex No.792 + if((so_start_segment > so_end_segment) || (pdu_rx_info_p->so > so_start_segment) || + (so_end_segment > pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1)) + { + LOG_E(RLC, " AM RX PDU Segment Duplicate elimination error FirstSO=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", + pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); + return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; + } +/* AssertFatal((so_start_segment <= so_end_segment) && (pdu_rx_info_p->so <= so_start_segment) && (so_end_segment <= pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1), " AM RX PDU Segment Duplicate elimination error FirstSO=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); - +*/ } // end pdu_info_cursor_p->so == 0 else { // Handle most likely case : PDU Segment without duplicate is inserted before first stored PDU segment @@ -527,12 +570,20 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu_segment( so_end_segment = pdu_info_cursor_p->so - 1; } } - +//Assertion(eNB)_PRAN_DesignDocument_annex No.793 + if((so_start_segment > so_end_segment) || + (so_end_segment > pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1)) + { + LOG_E(RLC, " AM RX PDU Segment Duplicate elimination at the end error FirstSO!=0 SOStart=%d OldSOEnd=%d newSOEnd =%d SN=%d\n", + pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_end_segment,pdu_rx_info_p->sn); + return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; + } +/* AssertFatal((so_start_segment <= so_end_segment) && (so_end_segment <= pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1), " AM RX PDU Segment Duplicate elimination at the end error FirstSO!=0 SOStart=%d OldSOEnd=%d newSOEnd =%d SN=%d\n", pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_end_segment,pdu_rx_info_p->sn); - +*/ } else { // Second Case: Duplicate at the begining and potentially at the end @@ -618,21 +669,38 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu_segment( so_end_segment = pdu_info_cursor_p->so - 1; } } - +//Assertion(eNB)_PRAN_DesignDocument_annex No.794 + if((so_start_segment > so_end_segment) || (pdu_rx_info_p->so > so_start_segment) || + (so_end_segment > pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1)) + { + LOG_E(RLC, " AM RX PDU Segment Duplicate elimination error FirstSO!=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", + pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); + return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; + } +/* AssertFatal((so_start_segment <= so_end_segment) && (pdu_rx_info_p->so <= so_start_segment) && (so_end_segment <= pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1), " AM RX PDU Segment Duplicate elimination error FirstSO!=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); +*/ } } // end pdu_info_cursor_p->so != 0 /* Last step : duplicate bytes had been removed, build a new PDU segment */ +//Assertion(eNB)_PRAN_DesignDocument_annex No.795 + if((pdu_rx_info_p->so == so_start_segment) && (so_end_segment == pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1)) + { + LOG_E(RLC, " AM RX PDU Segment Duplicate elimination error FirstSO!=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", + pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); + return RLC_AM_DATA_PDU_STATUS_AM_SEGMENT_DUPLICATE; + } +/* AssertFatal((pdu_rx_info_p->so != so_start_segment) || (so_end_segment != pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1), " AM RX PDU Segment Duplicate elimination error FirstSO!=0 OldSOStart=%d OldSOEnd=%d newSOStart=%d newSOEnd =%d SN=%d\n", pdu_rx_info_p->so,pdu_rx_info_p->so + pdu_rx_info_p->payload_size - 1,so_start_segment,so_end_segment,pdu_rx_info_p->sn); - +*/ mem_block_t* trunc_segment = create_new_segment_from_pdu(tb_pP,so_start_segment - pdu_rx_info_p->so,so_end_segment - so_start_segment + 1); if (trunc_segment != NULL) { LOG_I(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[PROCESS RX PDU SEGMENT] CREATE SEGMENT FROM SEGMENT OFFSET=%d DATA LENGTH=%d SN=%d\n", @@ -672,8 +740,15 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu( /*****************************************************/ // 1) Find previous cursor to the PDU to insert /*****************************************************/ +//Assertion(eNB)_PRAN_DesignDocument_annex No.788 + if(cursor_p == NULL) + { + LOG_E(RLC, "AM Rx PDU Error, received buffer empty LcID=%d\n",rlc_pP->channel_id); + return RLC_AM_DATA_PDU_STATUS_HEADER_ERROR; + } +/* AssertFatal(cursor_p != NULL,"AM Rx PDU Error, received buffer empty LcID=%d\n",rlc_pP->channel_id); - +*/ do { pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; @@ -749,9 +824,25 @@ rlc_am_rx_pdu_status_t rlc_am_rx_list_handle_pdu( else { /* First update cursor until discontinuity */ previous_cursor_p = cursor_p; +//Assertion(eNB)_PRAN_DesignDocument_annex No.789 + if(pdu_info_cursor_p->rf == 0) + { + LOG_E(RLC, "AM Rx PDU Error, stored SN=%d should be a PDU segment\n",pdu_info_cursor_p->sn); + return RLC_AM_DATA_PDU_STATUS_HEADER_ERROR; + } +/* AssertFatal(pdu_info_cursor_p->rf != 0,"AM Rx PDU Error, stored SN=%d should be a PDU segment\n",pdu_info_cursor_p->sn); +*/ +//Assertion(eNB)_PRAN_DesignDocument_annex No.790 + if(((rlc_am_rx_pdu_management_t *) (cursor_p->data))->all_segments_received != 0) + { + LOG_E(RLC, "AM Rx PDU Error, stored SN=%d already fully received\n",pdu_info_cursor_p->sn); + return RLC_AM_DATA_PDU_STATUS_SN_DUPLICATE; + } +/* AssertFatal(((rlc_am_rx_pdu_management_t *) (cursor_p->data))->all_segments_received == 0, "AM Rx PDU Error, stored SN=%d already fully received\n",pdu_info_cursor_p->sn); +*/ sdu_size_t next_waited_so = 0; while ((cursor_p != NULL) && (pdu_info_cursor_p->sn == pdu_rx_info_p->sn) && (pdu_info_cursor_p->so == next_waited_so)) { next_waited_so += pdu_info_cursor_p->payload_size; From aca800dae9ce4f16b71959e7a9a4d10fa65851d4 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Tue, 10 Apr 2018 17:19:52 +0900 Subject: [PATCH 49/91] fix SegmentFault by harq_pid==8 after clean_dlsch_eNB --- openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 12 ++++++++++++ openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 9fef0f1f4f..219d618170 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2064,6 +2064,10 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, if ((dlsch0 != NULL) && (dlsch1 != NULL)){ harq_pid = dlsch0->harq_ids[frame%2][subframe_offset]; + if(harq_pid >= dlsch0->Mdlharq) { + LOG_E(PHY,"illegal harq_pid %d\n", harq_pid); + return(-1); + } dlsch0_harq = dlsch0->harq_processes[harq_pid]; mimo_mode = dlsch0_harq->mimo_mode; mod_order0 = dlsch0_harq->Qm; @@ -2081,6 +2085,10 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, }else if ((dlsch0 != NULL) && (dlsch1 == NULL)){ harq_pid = dlsch0->harq_ids[frame%2][subframe_offset]; + if(harq_pid >= dlsch0->Mdlharq) { + LOG_E(PHY,"illegal harq_pid %d\n", harq_pid); + return(-1); + } dlsch0_harq = dlsch0->harq_processes[harq_pid]; mimo_mode = dlsch0_harq->mimo_mode; mod_order0 = dlsch0_harq->Qm; @@ -2098,6 +2106,10 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, }else if ((dlsch0 == NULL) && (dlsch1 != NULL)){ harq_pid = dlsch1->harq_ids[frame%2][subframe_offset]; + if(harq_pid >= dlsch1->Mdlharq) { + LOG_E(PHY,"illegal harq_pid %d\n", harq_pid); + return(-1); + } dlsch1_harq = dlsch1->harq_processes[harq_pid]; mimo_mode = dlsch1_harq->mimo_mode; mod_order0 = dlsch1_harq->Qm; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index b402c7c0a5..2ac83d1118 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1689,7 +1689,7 @@ void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subf frame_tx = ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame,subframe,subframe_tx); if (((1< 0) { harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx]; - if ((harq_pid>=0) && (harq_pid<10)) { + if ((harq_pid>=0) && (harq_pidMdlharq)) { dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; AssertFatal(dlsch0_harq!=NULL,"dlsch0_harq is null\n"); From b7a8889741e6c7c185f974d52de6359b47d77703 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Tue, 10 Apr 2018 17:31:52 +0900 Subject: [PATCH 50/91] fix Assertion because of round==8 in extract_harq when re-establishment happen --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index ea33715596..91a6c18fa9 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1964,7 +1964,8 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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){ + if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && + (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ 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; @@ -2131,7 +2132,8 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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){ + if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && + (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ 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; From b27984349d0a13a351b45e41cec9c0546d553c7e Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Wed, 11 Apr 2018 13:44:56 +0900 Subject: [PATCH 51/91] fix ct test bug 2_37 2_72 --- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c | 2 +- openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c index 22c5604708..72b106d1c0 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c @@ -617,7 +617,7 @@ rlc_am_send_status_pdu( } /* First ensure there is enough TBS for at least 1 SOStart/SOEnd, else break */ - if ((nb_bits_transmitted + RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)) <= nb_bits_to_transmit) { + else if ((nb_bits_transmitted + RLC_AM_SN_BITS + (RLC_AM_PDU_E_BITS << 1) + (RLC_AM_STATUS_PDU_SO_LENGTH << 1)) <= nb_bits_to_transmit) { /* Init loop flags */ /* Check lsf */ segment_loop_end = (pdu_info_cursor_p->lsf == 1); 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 0718cdd93c..b1c455aee0 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -571,6 +571,8 @@ rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP,cons //AssertFatal( tb_size_in_bytes > 0 , "RLC UM PDU LENGTH %d", tb_size_in_bytes); if(tb_size_in_bytes <= 0) { LOG_E(RLC, "RLC UM PDU LENGTH %d\n", tb_size_in_bytes); + tb_p = tb_p->next; + continue; } #if TRACE_RLC_UM_PDU || MESSAGE_CHART_GENERATOR From 597890ab6108059d71995c5f797fbb7e40ea0f64 Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Wed, 11 Apr 2018 19:01:43 +0900 Subject: [PATCH 52/91] eNB RLC Assertions(assert macros) skip & fix warning. --- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c | 9 +++++-- .../LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c | 7 ++++- .../LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c | 27 ++++++++++++++----- .../LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c | 9 ++++--- .../LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c | 17 +++++++++--- .../RLC/AM_v9.3.0/rlc_am_status_report.c | 14 +++++++--- .../LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c | 6 ++--- openair2/LAYER2/RLC/rlc.c | 4 +-- openair2/LAYER2/RLC/rlc_mac.c | 2 +- 9 files changed, 68 insertions(+), 27 deletions(-) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c index dff1545612..64e1847f90 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c @@ -130,8 +130,13 @@ rlc_am_pdu_sdu_data_cnf( for (pdu_sdu_index = 0; pdu_sdu_index < rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE].nb_sdus; pdu_sdu_index++) { sdu_index = rlc_pP->tx_data_pdu_buffer[snP % RLC_AM_WINDOW_SIZE].sdus_index[pdu_sdu_index]; - assert(sdu_index >= 0); - assert(sdu_index < RLC_AM_SDU_CONTROL_BUFFER_SIZE); + //assert(sdu_index >= 0); + //assert(sdu_index < RLC_AM_SDU_CONTROL_BUFFER_SIZE); + if(sdu_index < 0 || sdu_index >= RLC_AM_SDU_CONTROL_BUFFER_SIZE) { + LOG_E(RLC, "sdu_index error. sdu_index %d, pdu_sdu_index %d\n", sdu_index, pdu_sdu_index); + continue; + } + rlc_pP->input_sdus[sdu_index].nb_pdus_ack += 1; if ((rlc_pP->input_sdus[sdu_index].nb_pdus_ack == rlc_pP->input_sdus[sdu_index].nb_pdus) && diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c index 43a946cb0c..469b3461c0 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c @@ -57,7 +57,12 @@ rlc_am_reassembly ( if (rlc_pP->output_sdu_in_construction == NULL) { rlc_pP->output_sdu_in_construction = get_free_mem_block (RLC_SDU_MAX_SIZE, __func__); rlc_pP->output_sdu_size_to_write = 0; - assert(rlc_pP->output_sdu_in_construction != NULL); + //assert(rlc_pP->output_sdu_in_construction != NULL); + if(rlc_pP->output_sdu_in_construction == NULL) { + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[REASSEMBLY PAYLOAD] output_sdu_in_construction is NULL\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); + return; + } } if (rlc_pP->output_sdu_in_construction != NULL) { diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c index eb47b9ba28..1bde8ad1d0 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c @@ -60,10 +60,14 @@ boolean_t rlc_am_nack_pdu ( sdu_size_t pdu_data_to_retx = 0; if (mb_p != NULL) { - assert(so_startP <= so_endP); - + //assert(so_startP <= so_endP); + if(so_startP > so_endP) { + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[NACK-PDU] ERROR NACK MISSING PDU, so_startP %d, so_endP %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),so_startP, so_endP); + status = FALSE; + } // Handle full PDU NACK first - if ((so_startP == 0) && (so_endP == 0x7FFF)) { + else if ((so_startP == 0) && (so_endP == 0x7FFF)) { if ((prev_nack_snP != snP) && (tx_data_pdu_buffer_p->flags.ack == 0) && (tx_data_pdu_buffer_p->flags.max_retransmit == 0)) { pdu_data_to_retx = tx_data_pdu_buffer_p->payload_size; /* Increment VtReTxNext if this is the first NACK or if some segments have already been transmitted */ @@ -82,12 +86,17 @@ boolean_t rlc_am_nack_pdu ( snP, so_stopP); #endif - assert(tx_data_pdu_buffer_p->nack_so_start < tx_data_pdu_buffer_p->payload_size); + //assert(tx_data_pdu_buffer_p->nack_so_start < tx_data_pdu_buffer_p->payload_size); + if(tx_data_pdu_buffer_p->nack_so_start >= tx_data_pdu_buffer_p->payload_size){ + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[NACK-PDU] ERROR NACK MISSING PDU, nack_so_start %d, payload_size %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),tx_data_pdu_buffer_p->nack_so_start, tx_data_pdu_buffer_p->payload_size); + status = FALSE; + } } else { status = FALSE; } - } + } else if (tx_data_pdu_buffer_p->flags.max_retransmit == 0) { // Handle Segment offset if (so_endP == 0x7FFF) { @@ -230,7 +239,7 @@ void rlc_am_ack_pdu ( { LOG_E(RLC, "RLC AM Rx Status Report sn=%d acked twice but is pending for Retx vtA=%d vtS=%d LcId=%d\n", snP, rlc_pP->vt_a,rlc_pP->vt_s,rlc_pP->channel_id); - return NULL; + return; } /* AssertFatal (tx_data_pdu_buffer->flags.ack == 0, @@ -1264,7 +1273,11 @@ void rlc_am_tx_buffer_display ( LOG_D(RLC, "SO:%04d->%04d)\t", tx_data_pdu_buffer_p->nack_so_start, tx_data_pdu_buffer_p->nack_so_stop); } else { for (i=0; inum_holes; i++) { - assert(i < RLC_AM_MAX_HOLES_REPORT_PER_PDU); + //assert(i < RLC_AM_MAX_HOLES_REPORT_PER_PDU); + if(i >= RLC_AM_MAX_HOLES_REPORT_PER_PDU) { + LOG_E(RLC, "num_holes error. %d %d %d\n", tx_data_pdu_buffer_p->num_holes, i, RLC_AM_MAX_HOLES_REPORT_PER_PDU); + break; + } LOG_D(RLC, "SO:%04d->%04d)\t", tx_data_pdu_buffer_p->hole_so_start[i], tx_data_pdu_buffer_p->hole_so_stop[i]); } } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c index 2691107f02..383fd489b9 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c @@ -1649,7 +1649,8 @@ list2_insert_before_element ( return element_to_insert_pP; } else { - assert(2==1); + //assert(2==1); + LOG_E(RLC, "list2_insert_before_element error. element_to_insert_pP %p, element_pP %p\n", element_to_insert_pP,element_pP); return NULL; } } @@ -1676,7 +1677,8 @@ list2_insert_after_element ( return element_to_insert_pP; } else { - assert(2==1); + //assert(2==1); + LOG_E(RLC, "list2_insert_after_element error. element_to_insert_pP %p, element_pP %p\n", element_to_insert_pP,element_pP); return NULL; } } @@ -1726,7 +1728,8 @@ rlc_am_rx_list_display ( //if (cursor_p == cursor_p->next) { // rlc_am_v9_3_0_test_print_trace(); //} - assert(cursor_p != cursor_p->next); + //assert(cursor_p != cursor_p->next); + LOG_E(RLC, "rlc_am_rx_list_display error. cursor_p %p, cursor_p->next %p\n", cursor_p, cursor_p->next); cursor_p = cursor_p->next; loop++; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c index c16e897bb6..1bd0dce9cb 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c @@ -299,7 +299,12 @@ void rlc_am_segment_10 ( pdu_mngt_p->sdus_index[pdu_mngt_p->nb_sdus++] = sdu_buffer_index; sdu_mngt_p->pdus_index[sdu_mngt_p->nb_pdus++] = rlc_pP->vt_s % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE; - assert(sdu_mngt_p->nb_pdus < RLC_AM_MAX_SDU_FRAGMENTS); + //assert(sdu_mngt_p->nb_pdus < RLC_AM_MAX_SDU_FRAGMENTS); + if(sdu_mngt_p->nb_pdus >= RLC_AM_MAX_SDU_FRAGMENTS) { + LOG_E(RLC,PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] loop error. %d %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->nb_pdus, RLC_AM_MAX_SDU_FRAGMENTS); + break; + } sdu_buffer_index = (sdu_buffer_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; } @@ -462,11 +467,11 @@ void rlc_am_segment_10 ( rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; } } else { - LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); - assert(1!=1); + //assert(1!=1); memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; pdu_remaining_size = pdu_remaining_size - sdu_mngt_p->sdu_remaining_size; @@ -520,7 +525,11 @@ void rlc_am_segment_10 ( pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; //#warning "why 3000: changed to RLC_SDU_MAX_SIZE " - assert(pdu_tb_req_p->tb_size < RLC_SDU_MAX_SIZE ); + //assert(pdu_tb_req_p->tb_size < RLC_SDU_MAX_SIZE ); + if(pdu_tb_req_p->tb_size >= RLC_SDU_MAX_SIZE) { + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] tb_size error. %d, %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),pdu_tb_req_p->tb_size, RLC_SDU_MAX_SIZE); + } rlc_am_pdu_polling(ctxt_pP, rlc_pP, pdu_p, pdu_mngt_p->payload_size,true); //list_add_tail_eurecom (pdu_mem_p, &rlc_pP->segmentation_pdu_list); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c index 72b106d1c0..2640dc8072 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c @@ -154,7 +154,10 @@ rlc_am_write16_bit_field( signed int bits_to_writeP, const uint16_t valueP) { - assert(bits_to_writeP <= 16); + //assert(bits_to_writeP <= 16); + if(bits_to_writeP > 16) { + LOG_E(RLC, "bits_to_writeP error. %d\n", bits_to_writeP); + } if (bits_to_writeP > 8) { rlc_am_write8_bit_field(data_ppP,bit_pos_pP, bits_to_writeP - 8, (uint8_t)(valueP >> 8)); @@ -309,8 +312,13 @@ rlc_am_receive_process_control_pdu( // POLL_SN: // - if t-PollRetransmit is running: // - stop and reset t-PollRetransmit. - assert(ack_sn < RLC_AM_SN_MODULO); - assert(rlc_pP->control_pdu_info.num_nack < RLC_AM_MAX_NACK_IN_STATUS_PDU); + //assert(ack_sn < RLC_AM_SN_MODULO); + //assert(rlc_pP->control_pdu_info.num_nack < RLC_AM_MAX_NACK_IN_STATUS_PDU); + if(ack_sn >= RLC_AM_SN_MODULO || rlc_pP->control_pdu_info.num_nack >= RLC_AM_MAX_NACK_IN_STATUS_PDU) { + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" illegal ack_sn %d, num_nack %d\n", + PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), ack_sn, rlc_pP->control_pdu_info.num_nack); + return; + } /* Note : ackSn can be equal to current vtA only in case the status pdu contains a list of nack_sn with same value = vtA with SOStart/SOEnd */ /* and meaning the report is not complete due to not enough ressources to fill all SOStart/SOEnd of this NACK_SN */ diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c index 26a68849dd..6e5393f48a 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c @@ -748,13 +748,11 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) sdu_mngt_p = NULL; } else { -#if TRACE_RLC_UM_SEGMENT - LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", + LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_mngt_p->sdu_remaining_size, pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); -#endif - assert(1!=1); + //assert(1!=1); memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); // reduce the size of the PDU continue_fill_pdu_with_sdu = 0; diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index 4353e213dc..c40d3472e6 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -374,7 +374,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, //DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0); if(sdu_sizeP <= 0) { - LOG_E(RLC, "sdu_sizeP %d, file %s, line %s\n", sdu_sizeP, __FILE__ ,__LINE__); + LOG_E(RLC, "sdu_sizeP %d, file %s, line %d\n", sdu_sizeP, __FILE__ ,__LINE__); return RLC_OP_STATUS_BAD_PARAMETER; } @@ -409,7 +409,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t* const ctxt_pP, } else { rlc_mode = RLC_MODE_NONE; //AssertFatal (0 , "RLC not configured key %ju\n", key); - LOG_E("RLC not configured key %ju\n", key); + LOG_E(RLC, "not configured key %lu\n", key); return RLC_OP_STATUS_OUT_OF_RESSOURCES; } diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index c949702ea3..53b801d78e 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -430,7 +430,7 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( /* Then this function is called during MAC multiplexing ue_get_sdu(), and it may be call several times for the same bearer if it is in AM mode and there are several PDU types to transmit */ //AssertFatal(enb_flagP == FALSE,"RLC Tx mac_rlc_get_buffer_occupancy_ind function is not implemented for eNB LcId=%d\n", channel_idP); if(enb_flagP != FALSE){ - LOG_E("RLC Tx mac_rlc_get_buffer_occupancy_ind function is not implemented for eNB LcId=%d\n", channel_idP); + LOG_E(RLC, "Tx mac_rlc_get_buffer_occupancy_ind function is not implemented for eNB LcId=%u\n", channel_idP); return 0; } From afcdb1e6a9921b99b57bc6c716f8a40eeb378bc5 Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Thu, 12 Apr 2018 10:53:44 +0900 Subject: [PATCH 53/91] enb-log-mem_sp2.patch into closed_item (cherry picked from commit 3432385280c3155ee63a54be7c2e4846a17299de) # Conflicts: # openair2/UTIL/LOG/log.c --- common/utils/itti/assertions.h | 2 + common/utils/itti/signals.c | 3 + openair2/UTIL/LOG/log.c | 163 ++++++++++++++++++++++++++++++++ openair2/UTIL/LOG/log.h | 4 + openair2/UTIL/LOG/log_extern.h | 3 + targets/RT/USER/lte-softmodem.c | 9 +- targets/RT/USER/lte-softmodem.h | 1 + 7 files changed, 183 insertions(+), 2 deletions(-) diff --git a/common/utils/itti/assertions.h b/common/utils/itti/assertions.h index bb6c27cbab..803c3d001e 100644 --- a/common/utils/itti/assertions.h +++ b/common/utils/itti/assertions.h @@ -35,9 +35,11 @@ #ifndef ASSERTIONS_H_ #define ASSERTIONS_H_ +void output_log_mem(void); #define _Assert_Exit_ \ { \ fprintf(stderr, "\nExiting execution\n"); \ + output_log_mem(); \ display_backtrace(); \ fflush(stdout); \ fflush(stderr); \ diff --git a/common/utils/itti/signals.c b/common/utils/itti/signals.c index 9767ba3f67..4804e6b731 100644 --- a/common/utils/itti/signals.c +++ b/common/utils/itti/signals.c @@ -117,16 +117,19 @@ int signal_handle(int *end) case SIGUSR1: SIG_DEBUG("Received SIGUSR1\n"); *end = 1; + output_log_mem(); break; case SIGSEGV: /* Fall through */ case SIGABRT: SIG_DEBUG("Received SIGABORT\n"); + output_log_mem(); backtrace_handle_signal(&info); break; case SIGINT: printf("Received SIGINT\n"); + output_log_mem(); itti_send_terminate_message(TASK_UNKNOWN); *end = 1; break; diff --git a/openair2/UTIL/LOG/log.c b/openair2/UTIL/LOG/log.c index 948425e8da..579cd675c1 100644 --- a/openair2/UTIL/LOG/log.c +++ b/openair2/UTIL/LOG/log.c @@ -48,6 +48,26 @@ // main log variables log_t *g_log; +typedef struct { + char* buf_p; + int buf_index; + int enable_flag; +} log_mem_cnt_t; + +log_mem_cnt_t log_mem_d[2]; +int log_mem_flag=0; +int log_mem_multi=1; +volatile int log_mem_side=0; +pthread_mutex_t log_mem_lock; +pthread_cond_t log_mem_notify; +pthread_t log_mem_thread; +int log_mem_file_cnt=0; +volatile int log_mem_write_flag=0; +volatile int log_mem_write_side=0; + +char __log_mem_filename[1024]={0}; +char * log_mem_filename = &__log_mem_filename[0]; + mapping log_level_names[] = { {"emerg", LOG_EMERG}, {"alert", LOG_ALERT}, @@ -494,6 +514,81 @@ int logInit (void) return 0; } +extern int oai_exit; +void * log_mem_write(void) +{ + int *fp; + char f_name[1024]; + struct timespec slp_tm; + slp_tm.tv_sec = 0; + slp_tm.tv_nsec = 10000; + + pthread_setname_np( pthread_self(), "log_mem_write"); + + while (!oai_exit) { + pthread_mutex_lock(&log_mem_lock); + log_mem_write_flag=0; + pthread_cond_wait(&log_mem_notify, &log_mem_lock); + log_mem_write_flag=1; + pthread_mutex_unlock(&log_mem_lock); + // write! + if(log_mem_d[log_mem_write_side].enable_flag==0){ + if(log_mem_file_cnt>1){ + log_mem_file_cnt=1; + printf("log over write!!!\n"); + } + snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt); + fp=open(f_name, O_WRONLY | O_CREAT, 0666); + write(fp, log_mem_d[log_mem_write_side].buf_p, log_mem_d[log_mem_write_side].buf_index); + close(fp); + log_mem_file_cnt++; + log_mem_d[log_mem_write_side].buf_index=0; + log_mem_d[log_mem_write_side].enable_flag=1; + }else{ + printf("If you'd like to write log, you should set enable flag to 0!!!\n"); + nanosleep(&slp_tm,NULL); + } + } +} + +int logInit_log_mem (void) +{ + if(log_mem_flag==1){ + if(log_mem_multi==1){ + printf("log-mem multi!!!\n"); + log_mem_d[0].buf_p = malloc(LOG_MEM_SIZE); + log_mem_d[0].buf_index=0; + log_mem_d[0].enable_flag=1; + log_mem_d[1].buf_p = malloc(LOG_MEM_SIZE); + log_mem_d[1].buf_index=0; + log_mem_d[1].enable_flag=1; + log_mem_side=0; + if ((pthread_mutex_init (&log_mem_lock, NULL) != 0) + || (pthread_cond_init (&log_mem_notify, NULL) != 0)) { + log_mem_d[1].enable_flag=0; + return; + } + pthread_create(&log_mem_thread, NULL, log_mem_write, (void*)NULL); + }else{ + printf("log-mem single!!!\n"); + log_mem_d[0].buf_p = malloc(LOG_MEM_SIZE); + log_mem_d[0].buf_index=0; + log_mem_d[0].enable_flag=1; + log_mem_d[1].enable_flag=0; + log_mem_side=0; + } + }else{ + log_mem_d[0].buf_p=NULL; + log_mem_d[1].buf_p=NULL; + log_mem_d[0].enable_flag=0; + log_mem_d[1].enable_flag=0; + } + + printf("log init done\n"); + + return 0; +} + void nfapi_log(char *file, char *func, int line, int comp, int level, const char* format, va_list args) { //logRecord_mt(file,func,line, pthread_self(), comp, level, format, ##args) @@ -1295,6 +1390,7 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, * big enough so that the buffer is never full. */ char log_buffer[MAX_LOG_TOTAL]; + int temp_index; /* for no gcc warnings */ (void)log_start; @@ -1392,7 +1488,41 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, // OAI printf compatibility if ((g_log->onlinelog == 1) && (level != LOG_FILE)) + if(log_mem_flag==1){ + if(log_mem_d[log_mem_side].enable_flag==1){ + temp_index=log_mem_d[log_mem_side].buf_index; + if(temp_index+len+1 < LOG_MEM_SIZE){ + log_mem_d[log_mem_side].buf_index+=len; + memcpy(&log_mem_d[log_mem_side].buf_p[temp_index],log_buffer,len); + }else{ + log_mem_d[log_mem_side].enable_flag=0; + if(log_mem_d[1-log_mem_side].enable_flag==1){ + temp_index=log_mem_d[1-log_mem_side].buf_index; + if(temp_index+len+1 < LOG_MEM_SIZE){ + log_mem_d[1-log_mem_side].buf_index+=len; + log_mem_side=1-log_mem_side; + memcpy(&log_mem_d[log_mem_side].buf_p[temp_index],log_buffer,len); + /* write down !*/ + if (pthread_mutex_lock(&log_mem_lock) != 0) { + return; + } + if(log_mem_write_flag==0){ + log_mem_write_side=1-log_mem_side; + if(pthread_cond_signal(&log_mem_notify) != 0) { + } + } + if(pthread_mutex_unlock(&log_mem_lock) != 0) { + return; + } + }else{ + log_mem_d[1-log_mem_side].enable_flag=0; + } + } + } + } + }else{ fwrite(log_buffer, len, 1, stdout); + } if (g_log->syslog) { syslog(g_log->level, "%s", log_buffer); @@ -1719,7 +1849,40 @@ void log_set_instance_type (log_instance_type_t instance) log_instance_type = instance; } #endif + +void output_log_mem(void){ + int cnt,cnt2; + int *fp; + char f_name[1024]; + if(log_mem_flag==1){ + log_mem_d[0].enable_flag=0; + log_mem_d[1].enable_flag=0; + usleep(10); // wait for log writing + while(log_mem_write_flag==1){ + usleep(100); + } + if(log_mem_multi==1){ + snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt); + fp=open(f_name, O_WRONLY | O_CREAT, 0666); + write(fp, log_mem_d[0].buf_p, log_mem_d[0].buf_index); + close(fp); + free(log_mem_d[0].buf_p); + + snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt); + fp=open(f_name, O_WRONLY | O_CREAT, 0666); + write(fp, log_mem_d[1].buf_p, log_mem_d[1].buf_index); + close(fp); + free(log_mem_d[1].buf_p); + }else{ + fp=open(log_mem_filename, O_WRONLY | O_CREAT, 0666); + write(fp, log_mem_d[0].buf_p, log_mem_d[0].buf_index); + close(fp); + free(log_mem_d[0].buf_p); + } + } +} + #ifdef LOG_TEST int main(int argc, char *argv[]) diff --git a/openair2/UTIL/LOG/log.h b/openair2/UTIL/LOG/log.h index c21407f6eb..120262c621 100644 --- a/openair2/UTIL/LOG/log.h +++ b/openair2/UTIL/LOG/log.h @@ -253,6 +253,10 @@ typedef enum log_instance_type_e { void log_set_instance_type (log_instance_type_t instance); #endif +#define LOG_MEM_SIZE 100*1024*1024 +#define LOG_MEM_FILE "./logmem.log" +int logInit_log_mem(void); +void output_log_mem(void); /*--- INCLUDES ---------------------------------------------------------------*/ # include "log_if.h" diff --git a/openair2/UTIL/LOG/log_extern.h b/openair2/UTIL/LOG/log_extern.h index 611487ffea..0e7c49cc8d 100644 --- a/openair2/UTIL/LOG/log_extern.h +++ b/openair2/UTIL/LOG/log_extern.h @@ -32,3 +32,6 @@ extern int log_shutdown; extern mapping log_level_names[]; extern mapping log_verbosity_names[]; + +extern int log_mem_flag; +extern char * log_mem_filename; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 8bc3c65b88..cabebd2c52 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -144,8 +144,7 @@ static char threequarter_fs=0; uint32_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; - - +char logmem_filename[1024] = {0}; #if defined(ENABLE_ITTI) static char *itti_dump_file = NULL; #endif @@ -605,6 +604,12 @@ static void get_options(void) { if (start_telnetsrv) { load_module_shlib("telnetsrv",NULL,0); } + if (strlen(logmem_filename) > 0) { + log_mem_filename = &logmem_filename[0]; + log_mem_flag = 1; + printf("Enabling OPT for log save at memory %s\n",log_mem_filename); + logInit_log_mem(); + } if (UE_flag > 0) { diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 0e5e6b6081..3b2bd5bf2c 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -182,6 +182,7 @@ extern int16_t dlsch_demod_shift; {"g" , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \ {"G" , CONFIG_HLP_LOGV, 0, uptr:&glog_verbosity, defintval:0, TYPE_UINT16, 0}, \ {"telnetsrv", CONFIG_HLP_TELN, PARAMFLAG_BOOL, uptr:&start_telnetsrv, defintval:0, TYPE_UINT, 0}, \ +{"log-mem", NULL, 0, strptr:(char **)&logmem_filename, defstrval:"./logmem.log", TYPE_STRING, sizeof(logmem_filename)}, \ } #define CMDLINE_ONLINELOG_IDX 0 #define CMDLINE_GLOGLEVEL_IDX 1 From 5d06a1cabd723128dbca767cf8a6645165888dbb Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 12 Apr 2018 11:06:35 +0900 Subject: [PATCH 54/91] RLC assert fix ct 2_114 bug --- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c index 383fd489b9..5315548498 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c @@ -1729,7 +1729,11 @@ rlc_am_rx_list_display ( // rlc_am_v9_3_0_test_print_trace(); //} //assert(cursor_p != cursor_p->next); - LOG_E(RLC, "rlc_am_rx_list_display error. cursor_p %p, cursor_p->next %p\n", cursor_p, cursor_p->next); + if(cursor_p == cursor_p->next) + { + LOG_E(RLC, "rlc_am_rx_list_display error. cursor_p %p, cursor_p->next %p\n", cursor_p, cursor_p->next); + break; + } cursor_p = cursor_p->next; loop++; } From 675fd0af4e3d0c2cb9a76e91d9567e3cbf80c8ca Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 1 Feb 2018 14:46:34 +0900 Subject: [PATCH 55/91] patch develop-get-freememblock.patch into closed_item --- .../LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c | 1 + openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c | 4 ++++ .../LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c | 15 ++++++++++++--- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c | 4 ++-- openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c | 1 + openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c | 7 +++---- openair2/UTIL/MEM/mem_block.c | 6 +++--- openair2/UTIL/MEM/mem_block.h | 2 +- openair2/UTIL/TIMER/umts_timer.c | 1 + targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c | 2 +- 10 files changed, 29 insertions(+), 14 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c index abec97ddfd..0ef6893d08 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_control_primitive.c @@ -45,6 +45,7 @@ configure_pdcp_req (struct pdcp_entity *pdcpP, void *rlcP, uint8_t rlc_sap_typeP mem_block *mb; mb = get_free_mem_block (sizeof (struct cpdcp_primitive), __func__); + if(mb==NULL) return; ((struct cpdcp_primitive *) mb->data)->type = CPDCP_CONFIG_REQ; ((struct cpdcp_primitive *) mb->data)->primitive.config_req.rlc_sap = rlcP; ((struct cpdcp_primitive *) mb->data)->primitive.config_req.rlc_type_sap = rlc_sap_typeP; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c index 9e1db8a95b..add950786c 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c @@ -265,6 +265,7 @@ mem_block_t* rlc_am_retransmit_get_copy ( /* We need to allocate a new buffer and copy to it because header content may change for Polling bit */ int size = pdu_mngt->header_and_payload_size + sizeof(struct mac_tb_req); mem_block_t* mb_copy = get_free_mem_block(size, __func__); + if(mb_copy == NULL) return NULL; memcpy(mb_copy->data, mb_original_p->data, size); rlc_am_pdu_sn_10_t *pdu_p = (rlc_am_pdu_sn_10_t*) (&mb_copy->data[sizeof(struct mac_tb_req)]); @@ -339,6 +340,7 @@ mem_block_t* rlc_am_retransmit_get_am_segment( *payload_sizeP = retx_so_stop - retx_so_start + 1; mem_pdu_segment_p = get_free_mem_block((*payload_sizeP + RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE + sizeof(struct mac_tb_req)), __func__); + if(mem_pdu_segment_p == NULL) return NULL; pdu_segment_header_p = (uint8_t *)&mem_pdu_segment_p->data[sizeof(struct mac_tb_req)]; ((struct mac_tb_req*)(mem_pdu_segment_p->data))->data_ptr = pdu_segment_header_p; ((struct mac_tb_req*)(mem_pdu_segment_p->data))->tb_size = RLC_AM_PDU_SEGMENT_HEADER_MIN_SIZE + *payload_sizeP; @@ -551,6 +553,7 @@ mem_block_t* rlc_am_retransmit_get_am_segment( AssertFatal (header_segment_length + *payload_sizeP <= pdu_mngt->header_and_payload_size + 2, "RLC AM PDU Segment Error: Hdr=%d Data=%d Original Hdr+Data =%d sn=%d LcId=%d !\n", header_segment_length,*payload_sizeP,pdu_mngt->header_and_payload_size,sn,rlc_pP->channel_id); mem_pdu_segment_p = get_free_mem_block((*payload_sizeP + header_segment_length + sizeof(struct mac_tb_req)), __func__); + if(mem_pdu_segment_p == NULL) return NULL; pdu_segment_header_p = (uint8_t *)&mem_pdu_segment_p->data[sizeof(struct mac_tb_req)]; ((struct mac_tb_req*)(mem_pdu_segment_p->data))->data_ptr = pdu_segment_header_p; ((struct mac_tb_req*)(mem_pdu_segment_p->data))->tb_size = header_segment_length + *payload_sizeP; @@ -718,6 +721,7 @@ mem_block_t* rlc_am_retransmit_get_subsegment( if (mb_original_p != NULL) { mem_block_t* mb_sub_segment_p = get_free_mem_block(*sizeP + sizeof(struct mac_tb_req), __func__); + if(mb_sub_segment_p == NULL) return NULL; rlc_am_pdu_sn_10_t* pdu_original_p = (rlc_am_pdu_sn_10_t*) (&mb_original_p->data[sizeof(struct mac_tb_req)]); rlc_am_pdu_sn_10_t* pdu_sub_segment_p = (rlc_am_pdu_sn_10_t*) (&mb_sub_segment_p->data[sizeof(struct mac_tb_req)]); rlc_am_pdu_info_t pdu_info; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c index 092c7c65f1..cb9a6a3621 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c @@ -212,6 +212,9 @@ rlc_am_get_control_pdu_infos( if (!pdu_info_pP->nack_list[pdu_info_pP->num_nack - 1].e1) { nack_to_read = 0; *total_size_pP = *total_size_pP - (sdu_size_t)((uint64_t)byte_pos_p + (uint64_t)((bit_pos + 7)/8) - (uint64_t)header_pP); + if (*total_size_pP != 0) { + LOG_E(RLC, "[RLC_AM_GET_CONTROL_PDU_INFOS][FIRST]header_pP->b1=%d,header_pP->b2=%d\n",header_pP->b1,header_pP->b2); + } return 0; } @@ -225,7 +228,9 @@ rlc_am_get_control_pdu_infos( } else { *total_size_pP = *total_size_pP - 2; } - + if (*total_size_pP != 0) { + LOG_E(RLC, "[RLC_AM_GET_CONTROL_PDU_INFOS][SECOND]header_pP->b1=%d,header_pP->b2=%d\n",header_pP->b1,header_pP->b2); + } return 0; } else { return -1; @@ -388,13 +393,15 @@ rlc_am_receive_process_control_pdu( } else { - LOG_N(RLC, PROTOCOL_RLC_AM_CTXT_FMT" WARNING CONTROL PDU ACK SN %d OUT OF WINDOW vtA=%d vtS=%d\n", + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" WARNING CONTROL PDU ACK SN %d OUT OF WINDOW vtA=%d vtS=%d\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP),ack_sn,rlc_pP->vt_a,rlc_pP->vt_s); + *tb_size_in_bytes_pP = 0; status = FALSE; } } else { - LOG_W(RLC, PROTOCOL_RLC_AM_CTXT_FMT" ERROR IN DECODING CONTROL PDU\n", + LOG_E(RLC, PROTOCOL_RLC_AM_CTXT_FMT" ERROR IN DECODING CONTROL PDU\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); + *tb_size_in_bytes_pP = 0; status = FALSE; } @@ -807,6 +814,7 @@ rlc_am_send_status_pdu( pdu_size); #endif tb_p = get_free_mem_block(sizeof(struct mac_tb_req) + pdu_size, __func__); + if(tb_p == NULL) return; memset(tb_p->data, 0, sizeof(struct mac_tb_req) + pdu_size); //estimation only ((struct mac_tb_req*)(tb_p->data))->tb_size = pdu_size; ((struct mac_tb_req*)(tb_p->data))->data_ptr = (uint8_t*)&(tb_p->data[sizeof(struct mac_tb_req)]); @@ -1151,6 +1159,7 @@ end_push_nack: pdu_size); #endif tb_p = get_free_mem_block(sizeof(struct mac_tb_req) + pdu_size, __func__); + if(tb_p == NULL) return; memset(tb_p->data, 0, sizeof(struct mac_tb_req) + pdu_size); //estimation only ((struct mac_tb_req*)(tb_p->data))->tb_size = pdu_size; ((struct mac_tb_req*)(tb_p->data))->data_ptr = (uint8_t*)&(tb_p->data[sizeof(struct mac_tb_req)]); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c index ff969c0b6e..d9eb6de7cc 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_test.c @@ -534,7 +534,7 @@ void rlc_am_v9_3_0_test_send_sdu(rlc_am_entity_t *am_txP, int sdu_indexP) assert(g_send_id_write_index[am_txP->rb_id] < TEST_MAX_SEND_SDU); } else { printf("Out of memory error\n"); - exit(-1); +// exit(-1); } } //----------------------------------------------------------------------------- @@ -577,7 +577,7 @@ void rlc_am_v9_3_0_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct ma data_indP->no_tb += 1; } else { printf("Out of memory error\n"); - exit(-1); +// exit(-1); } } else { printf("[RLC-LOOP] DROPPING 1 TB\n"); diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c index 15dc90f175..972d40bb3f 100644 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c @@ -83,6 +83,7 @@ void rlc_tm_init ( if ((rlcP->input_sdus_alloc == NULL) && (rlcP->size_input_sdus_buffer > 0)) { rlcP->input_sdus_alloc = get_free_mem_block (rlcP->size_input_sdus_buffer * sizeof (void *), __func__); + if(rlcP->input_sdus_alloc == NULL) return; rlcP->input_sdus = (mem_block_t **) (rlcP->input_sdus_alloc->data); memset (rlcP->input_sdus, 0, rlcP->size_input_sdus_buffer * sizeof (void *)); } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c index 2c1fa9333f..4d238ea841 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_test.c @@ -317,7 +317,7 @@ void rlc_um_v9_3_0_test_send_sdu(rlc_um_entity_t *um_txP, int sdu_indexP) assert(g_send_id_write_index[um_txP->rb_id] < TEST_MAX_SEND_SDU); } else { printf("Out of memory error\n"); - exit(-1); +// exit(-1); } } @@ -406,9 +406,8 @@ void rlc_um_v9_3_0_test_mac_rlc_loop (struct mac_data_ind* data_indP, struct ma if (*drop_countP == 0) { tb_dst = get_free_mem_block(sizeof (mac_rlc_max_rx_header_size_t) + tb_size, __func__); - memset(tb_dst->data, 0, sizeof (mac_rlc_max_rx_header_size_t) + tb_size); - if (tb_dst != NULL) { + memset(tb_dst->data, 0, sizeof (mac_rlc_max_rx_header_size_t) + tb_size); //printf("[RLC-LOOP] Testing tb_dst (1)\n"); check_free_mem_block(tb_dst, __func__); tb_dst->next = NULL; @@ -427,7 +426,7 @@ void rlc_um_v9_3_0_test_mac_rlc_loop (struct mac_data_ind* data_indP, struct ma check_free_mem_block(tb_dst, __func__); } else { printf("Out of memory error\n"); - exit(-1); +// exit(-1); } } else { printf("[RLC-LOOP] DROPPING 1 TB\n"); diff --git a/openair2/UTIL/MEM/mem_block.c b/openair2/UTIL/MEM/mem_block.c index 9c3a50467a..cfc8081a4b 100644 --- a/openair2/UTIL/MEM/mem_block.c +++ b/openair2/UTIL/MEM/mem_block.c @@ -275,9 +275,9 @@ get_free_mem_block (uint32_t sizeP, const char* caller) } while (pool_selected++ < 12); LOG_E(PHY, "[MEM_MNGT][ERROR][FATAL] failed allocating MEM_BLOCK size %d byes (pool_selected=%d size=%d)\n", sizeP, pool_selected, size); - display_mem_load(); - AssertFatal(1==0,"get_free_mem_block failed"); - +// display_mem_load(); +// AssertFatal(1==0,"get_free_mem_block failed"); + LOG_E(MAC,"[MEM_MNGT][ERROR][FATAL] get_free_mem_block failed!!!\n"); #ifdef MEMBLOCK_BIG_LOCK if (pthread_mutex_unlock(&mtex)) abort(); #endif diff --git a/openair2/UTIL/MEM/mem_block.h b/openair2/UTIL/MEM/mem_block.h index e967380269..30554c518a 100644 --- a/openair2/UTIL/MEM/mem_block.h +++ b/openair2/UTIL/MEM/mem_block.h @@ -91,7 +91,7 @@ private_mem_block(void check_free_mem_block (mem_block_t * leP);) # define MEM_MNGT_MB5_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*32 // 2048 -# define MEM_MNGT_MB5_NB_BLOCKS 1024 * MEM_SCALE // LG WAS 1024 +# define MEM_MNGT_MB5_NB_BLOCKS 1024 * MEM_SCALE * 50 // LG WAS 1024 # define MEM_MNGT_POOL_ID5 5 # define MEM_MNGT_MB6_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*64 diff --git a/openair2/UTIL/TIMER/umts_timer.c b/openair2/UTIL/TIMER/umts_timer.c index 9bbb6c2df9..1691fac363 100644 --- a/openair2/UTIL/TIMER/umts_timer.c +++ b/openair2/UTIL/TIMER/umts_timer.c @@ -94,6 +94,7 @@ umts_add_timer_list_up (list2_t * atimer_listP, void (*procP) (void *, void *), uint8_t inserted = 0; mb = get_free_mem_block (sizeof (struct timer_unit), __func__); + if(mb==NULL) return NULL; ((struct timer_unit *) (mb->data))->proc = procP; ((struct timer_unit *) (mb->data))->protocol = protocolP; ((struct timer_unit *) (mb->data))->timer_id = timer_idP; diff --git a/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c b/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c index 1cadea3715..3e1dd2ea8e 100644 --- a/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c +++ b/targets/TEST/PDCP/with_rlc/test_pdcp_rlc.c @@ -148,7 +148,7 @@ void pdcp_rlc_test_mac_rlc_loop (struct mac_data_ind *data_indP, struct mac_dat data_indP->no_tb += 1; } else { printf("Out of memory error\n"); - exit(-1); +// exit(-1); } } else { printf("[RLC-LOOP] DROPPING 1 TB\n"); From a8ab765fe5978091c8d026a397226cae86669baa Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 1 Feb 2018 14:48:53 +0900 Subject: [PATCH 56/91] patch rrc_assertion.patch into closed_item # Conflicts: # openair2/RRC/LITE/rrc_eNB.c --- openair2/RRC/LITE/L2_interface.c | 8 ++ openair2/RRC/LITE/MESSAGES/asn1_msg.c | 103 ++++++++++++++++++++++---- openair2/RRC/LITE/rrc_eNB.c | 46 +++++++++++- openair2/RRC/LITE/rrc_eNB_S1AP.c | 8 ++ 4 files changed, 151 insertions(+), 14 deletions(-) diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index a95db63d53..5b0971a4bd 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -613,6 +613,14 @@ rrc_data_req( ) //------------------------------------------------------------------------------ { +#ifdef UE_EXPANSION + if(sdu_sizeP == 255) + { + LOG_I(RRC,"sdu_sizeP == 255"); + return FALSE; + } +#else +#endif MSC_LOG_TX_MESSAGE( ctxt_pP->enb_flag ? MSC_RRC_ENB : MSC_RRC_UE, ctxt_pP->enb_flag ? MSC_PDCP_ENB : MSC_PDCP_UE, diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index 724b30a3d1..08dd65bea7 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -1620,9 +1620,17 @@ do_RRCConnectionSetup( (void*)&dl_ccch_msg, buffer, 100); +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - +#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1691,9 +1699,17 @@ do_SecurityModeCommand( (void*)&dl_dcch_msg, buffer, 100); +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - +#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1767,9 +1783,17 @@ do_UECapabilityEnquiry( (void*)&dl_dcch_msg, buffer, 100); +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - +#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1927,9 +1951,17 @@ do_RRCConnectionReconfiguration( (void*)&dl_dcch_msg, buffer, RRC_BUF_SIZE); +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %zd)!\n", enc_rval.failed_type->name, enc_rval.encoded); - +#endif #ifdef XER_PRINT xer_fprint(stdout,&asn_DEF_DL_DCCH_Message,(void*)&dl_dcch_msg); #endif @@ -2140,9 +2172,17 @@ do_RRCConnectionReestablishment( (void*)&dl_ccch_msg, buffer, 100); +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - +#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2198,9 +2238,17 @@ do_RRCConnectionReestablishmentReject( (void*)&dl_ccch_msg, buffer, 100); +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - +#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2257,9 +2305,17 @@ do_RRCConnectionReject( (void*)&dl_ccch_msg, buffer, 100); +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %ld)!\n", enc_rval.failed_type->name, enc_rval.encoded); - +#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2446,9 +2502,17 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, (void*)mcch_message, buffer, 100); +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - +#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2575,12 +2639,17 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ (void*)&ul_dcch_msg, buffer, 100); - - - +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - +#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2706,9 +2775,17 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count); enc_rval = uper_encode_to_buffer(&asn_DEF_PCCH_Message, (void*)&pcch_msg, buffer, RRC_BUF_SIZE); - +#ifdef UE_EXPANSION + if(enc_rval.encoded == -1) + { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } +#else AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); +#endif #ifdef XER_PRINT xer_fprint(stdout, &asn_DEF_PCCH_Message, (void*)&pcch_msg); #endif diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 6c4413318f..4058613c3a 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -813,8 +813,14 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* PHY_VARS_eNB *eNB_PHY = NULL; eNB_MAC_INST *eNB_MAC = RC.mac[enb_mod_idP]; #endif - +#ifdef UE_EXPANSION + if (enb_mod_idP >= NB_eNB_INST) { + LOG_I(RRC, "eNB inst invalid (%d/%d) for UE %x!\n",enb_mod_idP, NB_eNB_INST,rnti); + return; + } +#else AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rnti); +#endif /* ue_context_p = rrc_eNB_get_ue_context( &RC.rrc[enb_mod_idP], rntiP @@ -3931,7 +3937,15 @@ check_handovers( ue_context_p->ue_context.handover_info->size, ue_context_p->ue_context.handover_info->buf, PDCP_TRANSMISSION_MODE_CONTROL); +#ifdef UE_EXPANSION + if(result != TRUE) + { + LOG_I(RRC, "PDCP data request failed!\n"); + return; + } +#else AssertFatal(result == TRUE, "PDCP data request failed!\n"); +#endif ue_context_p->ue_context.handover_info->ho_complete = 0xF2; } } @@ -5829,9 +5843,18 @@ rrc_eNB_decode_ccch( rrcConnectionRequest = &ul_ccch_msg->message.choice.c1.choice.rrcConnectionRequest.criticalExtensions.choice.rrcConnectionRequest_r8; { if (InitialUE_Identity_PR_randomValue == rrcConnectionRequest->ue_Identity.present) { + #ifdef UE_EXPANSION + if(rrcConnectionRequest->ue_Identity.choice.randomValue.size != 5) + { + LOG_I(RRC, "wrong InitialUE-Identity randomValue size, expected 5, provided %d", + rrcConnectionRequest->ue_Identity.choice.randomValue.size); + return -1; + } + #else AssertFatal(rrcConnectionRequest->ue_Identity.choice.randomValue.size == 5, "wrong InitialUE-Identity randomValue size, expected 5, provided %d", rrcConnectionRequest->ue_Identity.choice.randomValue.size); + #endif memcpy(((uint8_t*) & random_value) + 3, rrcConnectionRequest->ue_Identity.choice.randomValue.buf, rrcConnectionRequest->ue_Identity.choice.randomValue.size); @@ -6838,9 +6861,16 @@ rrc_enb_task( LOG_I(RRC,"Decoding CCCH : inst %d, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n", instance,CC_id,&ctxt, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); +#ifdef UE_EXPANSION + if (RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= RRC_BUFFER_SIZE_MAX) { + LOG_I(RRC, "CCCH message has size %d > %d\n",RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX); + break; + } +#else AssertFatal(RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size < RRC_BUFFER_SIZE_MAX, "CCCH message has size %d > %d\n", RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX); +#endif memcpy(srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND(msg_p).sdu, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); @@ -6868,7 +6898,14 @@ rrc_enb_task( // Message buffer has been processed, free it now. result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND(msg_p).sdu_p); +#ifdef UE_EXPANSION + if (result != EXIT_SUCCESS) { + LOG_I(RRC, "Failed to free memory (%d)!\n",result); + break; + } +#else AssertFatal(result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); +#endif break; # if defined(ENABLE_USE_MME) @@ -6937,7 +6974,14 @@ rrc_enb_task( } result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p); +#ifdef UE_EXPANSION + if (result != EXIT_SUCCESS) { + LOG_I(RRC, "Failed to free memory (%d)!\n",result); + continue; + } +#else AssertFatal(result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); +#endif msg_p = NULL; } } diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index 0ecf8f569a..98b842147b 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -1957,6 +1957,14 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance buffer, S1AP_PAGING_IND(msg_p).ue_paging_identity, S1AP_PAGING_IND(msg_p).cn_domain); + #ifdef UE_EXPANSION + if(length == -1) + { + LOG_I(RRC, "do_Paging error"); + return -1; + } + #else + #endif message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length); /* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */ memcpy (message_buffer, buffer, length); From 6e7db95981d522444a4394aa45b3c62bf0853680 Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Mon, 16 Apr 2018 16:54:02 +0900 Subject: [PATCH 57/91] clean log. --- openair1/SCHED/phy_procedures_lte_eNb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 2ac83d1118..13c274c2c6 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1021,10 +1021,11 @@ 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", +#ifdef DEBUG_PHY_PROC + LOG_D(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]); - +#endif + 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 From 33b652c5dfed9701a8332695622e2a738beb6666 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Mon, 16 Apr 2018 19:40:18 +0900 Subject: [PATCH 58/91] fix RM886 bug --- openair2/RRC/LITE/rrc_common.c | 1 + openair2/RRC/LITE/rrc_eNB.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c index adf213de0f..bb1e6c8235 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LITE/rrc_common.c @@ -333,6 +333,7 @@ rrc_rx_tx( // check for UL failure RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { + ctxt_pP->rnti = ue_context_p->ue_id_rnti; if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe==0)) { if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { LOG_I(RRC,"UE rnti %x:S-TMSI %x failure timer %d/8\n", diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 4058613c3a..d94ff0d162 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -2066,7 +2066,7 @@ rrc_eNB_generate_RRCConnectionRelease( // ue_context_pP->ue_context.ue_release_timer_thres_rrc = 100; ue_context_pP->ue_context.ue_reestablishment_timer = 0; ue_context_pP->ue_context.ue_release_timer = 0; - ue_context_pP->ue_context.ue_release_timer_s1 = 0; + //ue_context_pP->ue_context.ue_release_timer_s1 = 0; LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), From 22da1eac0c8da0167c0cb0725cbe2a43b1ca0593 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Tue, 17 Apr 2018 20:12:16 +0900 Subject: [PATCH 59/91] fix rm894 bug --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index dfd2e69506..12f960b546 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -231,6 +231,11 @@ rx_sdu(const module_id_t enb_mod_idP, payload_ptr = parse_ulsch_header(sduP, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths, sdu_lenP); + if(payload_ptr == NULL){ + LOG_E(MAC,"[eNB %d][PUSCH %d] CC_id %d ulsch header unknown lcid(rnti %x, UE_id %d)\n", + enb_mod_idP, harq_pid, CC_idP,current_rnti, UE_id); + return; + } T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), @@ -944,7 +949,9 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, ce_len++; } else { LOG_E(MAC, "unknown CE %d \n", lcid); - AssertFatal(1 == 0, "unknown CE"); + //RM894 + //AssertFatal(1 == 0, "unknown CE"); + return NULL; } } } From 7813e898ba04f86cf08e96ae566ec599c4d6fd7a Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 19 Apr 2018 12:26:20 +0900 Subject: [PATCH 60/91] RM884 fix, when cqi received is 0, don not update dl_cqi --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 9cc5ef0476..3b37f032c5 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -4489,8 +4489,11 @@ extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id, curbyte++; } } - sched_ctl->dl_cqi[CC_idP] = + LOG_I(MAC, "RM884 UE_id %d, frame %d, subframe %d, aperiodic_wideband_cqi0 %d, dl_cqi %d\n", frameP, subframeP, sched_ctl->aperiodic_wideband_cqi0[CC_idP], sched_ctl->dl_cqi[CC_idP]); + if (sched_ctl->aperiodic_wideband_cqi0[CC_idP] > 0) { + sched_ctl->dl_cqi[CC_idP] = sched_ctl->aperiodic_wideband_cqi0[CC_idP]; + } break; case CQI_ReportModeAperiodic_rm31: AssertFatal(0 == 1, "to be fixed, don't use p but pdu directly\n"); From 2bf209e469b05c6c364e53871024546a39b22ab8 Mon Sep 17 00:00:00 2001 From: tomita Date: Thu, 19 Apr 2018 18:25:34 +0900 Subject: [PATCH 61/91] Delete LOG_I . --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 1 - 1 file changed, 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 3b37f032c5..2efc91571c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -4489,7 +4489,6 @@ extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id, curbyte++; } } - LOG_I(MAC, "RM884 UE_id %d, frame %d, subframe %d, aperiodic_wideband_cqi0 %d, dl_cqi %d\n", frameP, subframeP, sched_ctl->aperiodic_wideband_cqi0[CC_idP], sched_ctl->dl_cqi[CC_idP]); if (sched_ctl->aperiodic_wideband_cqi0[CC_idP] > 0) { sched_ctl->dl_cqi[CC_idP] = sched_ctl->aperiodic_wideband_cqi0[CC_idP]; From e2a1b986582f8a1e789a32c461f360127223f7f8 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Fri, 20 Apr 2018 17:56:47 +0900 Subject: [PATCH 62/91] fix rm898 SecurityModeFailure --- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 2ac618ccd3..f8a5b8289c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -1101,8 +1101,9 @@ schedule_ue_spec(module_id_t module_idP, header_len_dtch_last = 0; // the header length of the last mac sdu // lcid has to be sorted before the actual allocation (similar struct as ue_list). #if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) - lcid = DTCH; - { +// lcid = DTCH; +// { + for (lcid = DTCH; lcid >= DTCH; lcid--) { #else for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { #endif @@ -1196,13 +1197,15 @@ schedule_ue_spec(module_id_t module_idP, } mcs = eNB_UE_stats->dlsch_mcs1; - +#ifdef UE_EXPANSION + nb_rb = min_rb_unit[CC_id]; +#else if (mcs == 0) { nb_rb = 4; // don't let the TBS get too small } else { nb_rb = min_rb_unit[CC_id]; } - +#endif TBS = get_TBS_DL(mcs, nb_rb); while (TBS < From c8267c2cf96d69c4a70053bd8e05ddfa22cc3f90 Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Fri, 20 Apr 2018 18:41:35 +0900 Subject: [PATCH 63/91] Revert "Merge branch 'rm884_bugfix' into 'sp3_master'" This reverts commit fad303fe3705fc8968aa7b3bb3e5cda2780c07d5, reversing changes made to e35921cf961b44d0659c9625632c7cf0ec1cd827. --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 2efc91571c..9cc5ef0476 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -4489,10 +4489,8 @@ extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id, curbyte++; } } - if (sched_ctl->aperiodic_wideband_cqi0[CC_idP] > 0) { - sched_ctl->dl_cqi[CC_idP] = + sched_ctl->dl_cqi[CC_idP] = sched_ctl->aperiodic_wideband_cqi0[CC_idP]; - } break; case CQI_ReportModeAperiodic_rm31: AssertFatal(0 == 1, "to be fixed, don't use p but pdu directly\n"); From 0889d799698aeb37bfbd11b3a25925837b246fed Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 23 Apr 2018 09:45:08 +0800 Subject: [PATCH 64/91] Modify CQI scheduling strategy --- openair1/SCHED/phy_procedures_lte_eNb.c | 6 ++++++ openair2/LAYER2/MAC/defs.h | 1 + openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 1 + openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 3 ++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 13c274c2c6..0be8d49a84 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1447,6 +1447,12 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) fill_ulsch_cqi_indication(eNB,frame,subframe, ulsch_harq, ulsch->rnti); + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag = 0; + }else{ + if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag==1){ + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30; + LOG_I(PHY,"RM804 Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe); + } } if (ret == (1+MAX_TURBO_ITERATIONS)) { diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 52d40355a9..3652c84595 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -864,6 +864,7 @@ typedef struct { uint8_t dl_cqi[NFAPI_CC_MAX]; int32_t uplane_inactivity_timer; uint8_t crnti_reconfigurationcomplete_flag; + uint8_t cqi_req_flag; } UE_sched_ctrl; /*! \brief eNB template for the Random access information */ typedef struct { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 9cc5ef0476..0b5271630f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -4625,6 +4625,7 @@ cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, extract_pusch_csi(mod_idP, CC_idP, UE_id, frameP, subframeP, pdu, rel9->length); + LOG_I(MAC,"Frame %d Subframe %d update CQI:%d\n",frameP,subframeP,sched_ctl->dl_cqi); } // timing advance diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index dfd2e69506..6325e3ef45 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1837,6 +1837,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, else if (UE_sched_ctrl->cqi_req_timer>30) { cqi_req = 1; UE_sched_ctrl->cqi_req_timer=0; + UE_sched_ctrl->cqi_req_flag=1; } else cqi_req = 0; @@ -1894,7 +1895,6 @@ void schedule_ulsch_rnti(module_id_t module_idP, UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); rb_table_index=5; // for PHR } - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid]; UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); @@ -2071,6 +2071,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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,mcs_rv,first_rb[CC_id],rb_table[rb_table_index],rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); From ef5ff53ecfc67879d4bc99d00c6f46a24ee23f0e Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 23 Apr 2018 09:58:50 +0800 Subject: [PATCH 65/91] change log level to debug --- openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 0be8d49a84..1251463ef4 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1451,7 +1451,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) }else{ if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag==1){ RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30; - LOG_I(PHY,"RM804 Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe); + LOG_D(PHY,"RM804 Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe); } } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 0b5271630f..1cbe27edf8 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -4625,7 +4625,7 @@ cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, extract_pusch_csi(mod_idP, CC_idP, UE_id, frameP, subframeP, pdu, rel9->length); - LOG_I(MAC,"Frame %d Subframe %d update CQI:%d\n",frameP,subframeP,sched_ctl->dl_cqi); + LOG_D(MAC,"Frame %d Subframe %d update CQI:%d\n",frameP,subframeP,sched_ctl->dl_cqi); } // timing advance From c5b3aaa2dd127333be3eba736d81c0af1ea09bd9 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 23 Apr 2018 14:26:43 +0800 Subject: [PATCH 66/91] Fix a bug in log --- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 1cbe27edf8..1627d3751c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -4625,7 +4625,7 @@ cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, extract_pusch_csi(mod_idP, CC_idP, UE_id, frameP, subframeP, pdu, rel9->length); - LOG_D(MAC,"Frame %d Subframe %d update CQI:%d\n",frameP,subframeP,sched_ctl->dl_cqi); + LOG_D(MAC,"Frame %d Subframe %d update CQI:%d\n",frameP,subframeP,sched_ctl->dl_cqi[CC_idP]); } // timing advance From a60ac1132067f77b94d8d86f636b7612dc4c32bc Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Wed, 25 Apr 2018 17:05:12 +0800 Subject: [PATCH 67/91] fix ul config pdu type while there are cqi,harq and ulsch at the same time. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 6325e3ef45..f99235f41c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -2004,7 +2004,10 @@ void schedule_ulsch_rnti(module_id_t module_idP, } #endif if(dlsch_flag == 1){ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + if(cqi_req == 1) + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + else + 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]; @@ -2169,7 +2172,10 @@ void schedule_ulsch_rnti(module_id_t module_idP, } #endif if(dlsch_flag == 1){ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + if(cqi_req == 1) + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + else + 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; From 2160f8758c85bcb8996dbf2933efcc511d278b4a Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 8 Mar 2018 09:58:13 +0100 Subject: [PATCH 68/91] cleanup - remove unnecessary calls to get_cpu_freq_GHz The one in lte-enb.c disrupts the realtime. Using a B200mini with 20MHz bandwidth leads to the UE unable to connect for it seesms like the UL and DL are not properly time synched because of this sleep of one second that happens after the USRP streaming has started. We see some random access attempts but the decoded preamble is wrong. This may be dependant on the setup. I had sporadic errors with a B210, where sometimes the UE could connect and sometimes not. (cherry picked from commit 5a61f9944c93bc33157361330dbdc5165427330c) --- targets/RT/USER/lte-enb.c | 7 ------- targets/RT/USER/lte-softmodem.c | 6 ++---- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 3f27e38726..8c8bc83120 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -164,13 +164,6 @@ extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset); static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_name) { - - static double cpu_freq_GHz = 0.0; - - if (cpu_freq_GHz == 0.0) - cpu_freq_GHz = get_cpu_freq_GHz(); - - start_meas(&softmodem_stats_rxtx_sf); // ******************************************************************* diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index cabebd2c52..5861ba6cb2 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1131,10 +1131,8 @@ int main( int argc, char **argv ) printf("Runtime table\n"); fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); - cpuf=get_cpu_freq_GHz(); - - - + + #ifndef DEADLINE_SCHEDULER printf("NO deadline scheduler\n"); From ebbc7fadd09fd8257896993afb172d35057a9cb6 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Thu, 26 Apr 2018 09:29:29 +0800 Subject: [PATCH 69/91] add previous fix to non-ue-extension --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index f99235f41c..ff35553a85 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1539,7 +1539,11 @@ schedule_ulsch_rnti(module_id_t module_idP, } #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; + if(cqi_req == 1) + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + else + ul_req_tmp->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]; @@ -1639,7 +1643,11 @@ schedule_ulsch_rnti(module_id_t module_idP, } #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; + if(cqi_req == 1) + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + else + ul_req_tmp->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]; From 30427be126aceb9b9a993d3abfbc0b16cff7a96c Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Thu, 26 Apr 2018 13:26:09 +0900 Subject: [PATCH 70/91] Fix problem of RF-IF on TDD system. --- openair1/SCHED/ru_procedures.c | 4 ++-- targets/RT/USER/lte-ru.c | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index dcab55d66f..2c2fe6ecae 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -112,7 +112,7 @@ void feptx0(RU_t *ru,int slot) { } */ // TDD: turn on tx switch N_TA_offset before by setting buffer in these samples to 0 - if ((slot == 0) && +/* if ((slot == 0) && (fp->frame_type == TDD) && ((fp->tdd_config==0) || (fp->tdd_config==1) || @@ -129,7 +129,7 @@ void feptx0(RU_t *ru,int slot) { ru->common.txdata[aa][tx_offset] = 0x00000000; } - } + }*/ } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM+slot , 0); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 7676411882..4210ccf07c 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -817,7 +817,7 @@ void tx_rf(RU_t *ru) { (prevSF_type == SF_UL) && (nextSF_type == SF_DL)) { flags = 2; // start of burst - sf_extension = ru->N_TA_offset<<1; + sf_extension = ru->N_TA_offset; } if ((fp->frame_type == TDD) && @@ -825,9 +825,18 @@ void tx_rf(RU_t *ru) { (prevSF_type == SF_UL) && (nextSF_type == SF_UL)) { flags = 4; // start of burst and end of burst (only one DL SF between two UL) - sf_extension = ru->N_TA_offset<<1; + sf_extension = ru->N_TA_offset; } - +#if defined(__x86_64) || defined(__i386__) +#ifdef __AVX2__ + sf_extension = (sf_extension)&0xfffffff8; +#else + sf_extension = (sf_extension)&0xfffffffc; +#endif +#elif defined(__arm__) + sf_extension = (sf_extension)&0xfffffffc; +#endif + for (i=0; inb_tx; i++) txp[i] = (void*)&ru->common.txdata[i][(proc->subframe_tx*fp->samples_per_tti)-sf_extension]; /* add fail safe for late command */ @@ -1799,9 +1808,6 @@ static void* eNB_thread_phy_tx( void* param ) { proc_rxtx.subframe_tx = proc->subframe_phy_tx; proc_rxtx.frame_tx = proc->frame_phy_tx; phy_procedures_eNB_TX(eNB_list[0], &proc_rxtx, no_relay, NULL, 1); - ru->proc.frame_tx = proc->frame_phy_tx; - ru->proc.subframe_tx = proc->subframe_phy_tx; - ru->proc.timestamp_tx = proc->timestamp_phy_tx; phy_tx_txdataF_end = 1; if(pthread_mutex_lock(&ru->proc.mutex_rf_tx) != 0){ LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for rf tx thread (IC %d)\n", ru->proc.instance_cnt_rf_tx); @@ -1809,6 +1815,9 @@ static void* eNB_thread_phy_tx( void* param ) { } if (ru->proc.instance_cnt_rf_tx==-1) { ++ru->proc.instance_cnt_rf_tx; + ru->proc.frame_tx = proc->frame_phy_tx; + ru->proc.subframe_tx = proc->subframe_phy_tx; + ru->proc.timestamp_tx = proc->timestamp_phy_tx; // 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"); From 55ed45df8d8377f6fc654bb261f385ddb603952f Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Fri, 27 Apr 2018 09:28:32 +0900 Subject: [PATCH 71/91] Fix: avoid "U" and "L" RF messages during eNB start up. --- targets/RT/USER/lte-enb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8c8bc83120..b6e6133593 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -506,7 +506,7 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { if (is_prach_subframe(fp,frame,subframe)>0) { LOG_D(PHY,"Triggering prach processing, frame %d, subframe %d\n",frame,subframe); if (proc->instance_cnt_prach == 0) { - LOG_W(PHY,"[eNB] Frame %d Subframe %d, dropping PRACH\n", frame,subframe); + //LOG_W(PHY,"[eNB] Frame %d Subframe %d, dropping PRACH\n", frame,subframe); return; } @@ -566,7 +566,7 @@ void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { if (is_prach_subframe(fp,frame,subframe)>0) { LOG_D(PHY,"Triggering prach br processing, frame %d, subframe %d\n",frame,subframe); if (proc->instance_cnt_prach_br == 0) { - LOG_W(PHY,"[eNB] Frame %d Subframe %d, dropping PRACH BR\n", frame,subframe); + //LOG_W(PHY,"[eNB] Frame %d Subframe %d, dropping PRACH BR\n", frame,subframe); return; } @@ -895,7 +895,7 @@ void init_transport(PHY_VARS_eNB *eNB) { LOG_I(PHY, "Initialise transport\n"); for (i=0; idlsch[i][j] = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL,0,fp); if (!eNB->dlsch[i][j]) { @@ -907,7 +907,7 @@ void init_transport(PHY_VARS_eNB *eNB) { } } - LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i); + LOG_D(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i); eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0); if (!eNB->ulsch[1+i]) { From 6f4ee013d29b3860407892626ead414aaf8e54a3 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Mon, 7 May 2018 18:15:42 +0900 Subject: [PATCH 72/91] fix RM912 SegmentFault in dlsch_coding while using a UE which has been removed --- nfapi/oai_integration/nfapi_pnf.c | 4 ++++ openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 628acf2e77..9d75407cb9 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -840,6 +840,10 @@ int pnf_phy_dl_config_req(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request 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[sfn%2][sf]; + if(harq_pid >= dlsch0->Mdlharq) { + LOG_E(PHY,"pnf_phy_dl_config_req illegal harq_pid %d\n", harq_pid); + return(-1); + } 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/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 69e7d7424a..80ab4a401c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -400,6 +400,10 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, unsigned short iind; unsigned char harq_pid = dlsch->harq_ids[frame%2][subframe]; + if(harq_pid >= dlsch->Mdlharq) { + LOG_E(PHY,"dlsch_encoding_2threads illegal harq_pid %d\n", harq_pid); + return(-1); + } unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; unsigned int A; unsigned char mod_order; @@ -584,6 +588,10 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; unsigned char harq_pid = dlsch->harq_ids[frame%2][subframe]; + if(harq_pid >= dlsch->Mdlharq) { + LOG_E(PHY,"dlsch_encoding illegal harq_pid %d\n", harq_pid); + return(-1); + } unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; unsigned int A; unsigned char mod_order; From f1cd05c1e09666ea2351ea7d40e67783d029da72 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Wed, 9 May 2018 11:56:45 +0800 Subject: [PATCH 73/91] Fix ul config pdu info setting missing problem --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 86 +++++++++++++++-------- 1 file changed, 56 insertions(+), 30 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index ff35553a85..0f7572a863 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1185,7 +1185,7 @@ schedule_ulsch_rnti(module_id_t module_idP, nfapi_ul_config_request_t *ul_req_tmp = &mac->UL_req_tmp[CC_id][sched_subframeP]; nfapi_ul_config_request_body_t *ul_req_tmp_body = &ul_req_tmp->ul_config_request_body; - + nfapi_ul_config_ulsch_harq_information *ulsch_harq_information; //LOG_D(MAC, "entering ulsch preprocesor\n"); ulsch_scheduler_pre_processor(module_idP, frameP, subframeP,sched_subframeP, first_rb); @@ -1539,15 +1539,21 @@ schedule_ulsch_rnti(module_id_t module_idP, } #endif if(dlsch_flag == 1){ - if(cqi_req == 1) - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - else - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + if(cqi_req == 1){ + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_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_cqi_harq_ri_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_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; - 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->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + 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, ulsch_harq_information,subframeP); }else{ ul_req_tmp_body->number_of_pdus++; } @@ -1643,15 +1649,21 @@ schedule_ulsch_rnti(module_id_t module_idP, } #endif if(dlsch_flag == 1){ - if(cqi_req == 1) - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - else - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + if(cqi_req == 1){ + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_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_cqi_harq_ri_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_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = UE_template->nb_rb_ul[harq_pid]; - 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->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + 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, ulsch_harq_information,subframeP); }else{ ul_req_tmp_body->number_of_pdus++; } @@ -1736,7 +1748,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; nfapi_ul_config_request_body_t *ul_req_tmp; - + nfapi_ul_config_ulsch_harq_information *ulsch_harq_information; LOG_D(MAC,"entering ulsch preprocesor\n"); ulsch_scheduler_pre_processor(module_idP, frameP, @@ -2012,14 +2024,21 @@ void schedule_ulsch_rnti(module_id_t module_idP, } #endif if(dlsch_flag == 1){ - if(cqi_req == 1) + if(cqi_req == 1){ ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - else + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_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_cqi_harq_ri_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_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + + }else{ 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); + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + 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, ulsch_harq_information,subframeP); }else{ ul_req_tmp->number_of_pdus++; } @@ -2180,14 +2199,21 @@ void schedule_ulsch_rnti(module_id_t module_idP, } #endif if(dlsch_flag == 1){ - if(cqi_req == 1) + if(cqi_req == 1){ ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - else + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_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_cqi_harq_ri_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_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + + }else{ 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); + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + 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, ulsch_harq_information,subframeP); }else{ ul_req_tmp->number_of_pdus++; } From 0928f049bb9e73fda2bec6376dc678c56d81d613 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Wed, 9 May 2018 18:22:22 +0800 Subject: [PATCH 74/91] Fix cqi_req_flag, to prevent continously schedule cqi after set it to 1 and before actually receive it at the right subframe. --- openair1/SCHED/phy_procedures_lte_eNb.c | 5 +++-- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 1251463ef4..45ebc0b078 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1447,9 +1447,10 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) fill_ulsch_cqi_indication(eNB,frame,subframe, ulsch_harq, ulsch->rnti); - RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag = 0; + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe)); }else{ - if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag==1){ + if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag & (1 << subframe) ){ + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe)); RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30; LOG_D(PHY,"RM804 Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 0f7572a863..1eb3070c0f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1324,6 +1324,7 @@ schedule_ulsch_rnti(module_id_t module_idP, cqi_req = 0; } else { cqi_req = 1; + UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; } UE_sched_ctrl->cqi_req_timer = 0; } else @@ -1857,7 +1858,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, else if (UE_sched_ctrl->cqi_req_timer>30) { cqi_req = 1; UE_sched_ctrl->cqi_req_timer=0; - UE_sched_ctrl->cqi_req_flag=1; + UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; } else cqi_req = 0; From 7807e677e7b720aec1d366c2dce1c38b95af8f93 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 10 May 2018 11:53:06 +0900 Subject: [PATCH 75/91] fix RM902 base on sp3_master --- openair2/COMMON/mac_rlc_primitives.h | 1 - openair2/LAYER2/MAC/defs.h | 6 +++ openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 53 ++++++++++++------- .../LAYER2/MAC/eNB_scheduler_primitives.c | 48 +++++++++++++++-- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 5 +- openair2/LAYER2/MAC/extern.h | 2 +- openair2/LAYER2/MAC/pre_processor.c | 15 ++++++ openair2/LAYER2/MAC/vars.h | 2 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 1 - .../LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c | 10 ++++ openair2/LAYER2/RLC/rlc.h | 1 - openair2/LAYER2/RLC/rlc_mac.c | 2 +- openair2/RRC/LITE/rrc_eNB.c | 5 +- 13 files changed, 121 insertions(+), 30 deletions(-) diff --git a/openair2/COMMON/mac_rlc_primitives.h b/openair2/COMMON/mac_rlc_primitives.h index b96a7b7b82..4e3e22781c 100644 --- a/openair2/COMMON/mac_rlc_primitives.h +++ b/openair2/COMMON/mac_rlc_primitives.h @@ -191,7 +191,6 @@ struct mac_status_resp { uint32_t head_sdu_remaining_size_to_send; unsigned char head_sdu_is_segmented; struct rlc_entity_info rlc_info; /*!< xxx*/ - mui_t rrc_mui; }; struct mac_tb_ind { diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 3652c84595..8dd570c69f 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -1413,6 +1413,12 @@ typedef struct { uint16_t num_UEs; RRC_release_ctrl RRC_release_ctrl[NUMBER_OF_UE_MAX]; } RRC_release_list_t; + +typedef struct { + uint8_t rrc_mui_num; + mui_t rrc_mui[128]; +}mac_rlc_am_muilist_t; + #include "proto.h" /*@}*/ #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index f8a5b8289c..8e3eb86300 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -988,22 +988,36 @@ schedule_ue_spec(module_id_t module_idP, &dlsch_buffer [0]); pthread_mutex_lock(&rrc_release_freelist); - if(rrc_release_info.num_UEs > 0){ + if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)){ uint16_t release_total = 0; for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ + if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0){ + release_total++; + }else{ + continue; + } + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1){ - release_total++; - if( (rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) && - (rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_status.rrc_mui)){ - rrc_release_info.RRC_release_ctrl[release_num].flag = 3; + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ + for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + rrc_release_info.RRC_release_ctrl[release_num].flag = 3; + LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 1->3\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); + break; + } + } } } if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2){ - release_total++; - if( (rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) && - (rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_status.rrc_mui)){ - rrc_release_info.RRC_release_ctrl[release_num].flag = 4; + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ + for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + rrc_release_info.RRC_release_ctrl[release_num].flag = 4; + LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 2->4\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); + break; + } } + } } if(release_total >= rrc_release_info.num_UEs) break; @@ -1013,21 +1027,24 @@ schedule_ue_spec(module_id_t module_idP, RA_t *ra = &eNB->common_channels[CC_id].ra[0]; for (uint8_t ra_ii = 0; ra_ii < NB_RA_PROC_MAX; ra_ii++) { - if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI) && - (ra[ra_ii].crnti_rrc_mui == rlc_status.rrc_mui)){ - ra[ra_ii].crnti_harq_pid = harq_pid; - ra[ra_ii].state = MSGCRNTI_ACK; - break; + if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)){ + for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ + if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]){ + ra[ra_ii].crnti_harq_pid = harq_pid; + ra[ra_ii].state = MSGCRNTI_ACK; + break; + } + } } } T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), T_INT(sdu_lengths[0])); - - LOG_D(MAC, - "[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n", - module_idP, CC_id, sdu_lengths[0]); + LOG_D(MAC, + "[eNB %d][DCCH] CC_id %d frame %d subframe %d UE_id %d/%x Got %d bytes bytes_in_buffer %d from release_num %d\n", + module_idP, CC_id, frameP, subframeP, UE_id, rnti, sdu_lengths[0],rlc_status.bytes_in_buffer,rrc_release_info.num_UEs); + sdu_length_total = sdu_lengths[0]; sdu_lcids[0] = DCCH; UE_list->eNB_UE_stats[CC_id][UE_id]. diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 1627d3751c..13da611c96 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -2277,6 +2277,27 @@ int rrc_mac_remove_ue(module_id_t mod_idP, rnti_t rntiP) cancel_ra_proc(mod_idP, pCC_id, 0, rntiP); } + pthread_mutex_lock(&rrc_release_freelist); + if(rrc_release_info.num_UEs > 0){ + uint16_t release_total = 0; + for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ + if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0){ + release_total++; + }else{ + continue; + } + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rntiP){ + rrc_release_info.RRC_release_ctrl[release_num].flag = 0; + rrc_release_info.num_UEs--; + release_total--; + } + if(release_total >= rrc_release_info.num_UEs){ + break; + } + } + } + pthread_mutex_unlock(&rrc_release_freelist); + return 0; } @@ -3456,7 +3477,7 @@ allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t subframeP, for (j = 0; j <= i; j++) { if (dl_config_pdu[j].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) - LOG_I(MAC, + LOG_D(MAC, "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", j, DL_req->number_dci + @@ -3850,6 +3871,7 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, else frame_tx = subframeP < 4 ? frameP -1 : frameP; harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frame_tx,subframe_tx); + RA_t *ra = &RC.mac[mod_idP]->common_channels[CC_idP].ra[0]; if(num_ack_nak==1){ if(harq_indication_tdd->harq_data[0].bundling.value_0==1){ //ack @@ -3860,9 +3882,18 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, 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]); + if(sched_ctl->round[CC_idP][harq_pid] == 8){ + for (uint8_t ra_i = 0; ra_i < NB_RA_PROC_MAX; ra_i++) { + if((ra[ra_i].rnti == rnti) && (ra[ra_i].state == WAITMSG4ACK)){ + //Msg NACK num to MAC ,remove UE + // add UE info to freeList + LOG_I(RRC, "put UE %x into freeList\n", rnti); + put_UE_in_freelist(mod_idP, rnti, 1); + } + } + } } } - 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); @@ -3936,8 +3967,19 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, if (pdu[0] == 1) { // ACK sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process sched_ctl->tbcnt[CC_idP][harq_pid] = 0; - } else if (pdu[0] == 2 || pdu[0] == 4) // NAK (treat DTX as NAK) + } else if (pdu[0] == 2 || pdu[0] == 4){ // NAK (treat DTX as NAK) sched_ctl->round[CC_idP][harq_pid]++; // increment round + if(sched_ctl->round[CC_idP][harq_pid] == 8){ + for (uint8_t ra_i = 0; ra_i < NB_RA_PROC_MAX; ra_i++) { + if((ra[ra_i].rnti == rnti) && (ra[ra_i].state == WAITMSG4ACK)){ + //Msg NACK num to MAC ,remove UE + // add UE info to freeList + LOG_I(RRC, "put UE %x into freeList\n", rnti); + put_UE_in_freelist(mod_idP, rnti, 1); + } + } + } + } } else { // one or two ACK/NAK bits AssertFatal(num_ack_nak > 2, diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 887feb1ff5..f951f3677d 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -629,8 +629,9 @@ rx_sdu(const module_id_t enb_mod_idP, ra[ii].rach_resource_type #endif )) == -1) { - AssertFatal(1 == 0, - "[MAC][eNB] Max user count reached\n"); + LOG_E(MAC,"[MAC][eNB] Max user count reached\n"); + cancel_ra_proc(enb_mod_idP, CC_idP, frameP,current_rnti); + break; // kill RA procedure } else LOG_D(MAC, diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index 90b5864ba1..3cbb40cb10 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -110,5 +110,5 @@ extern uint8_t new_dlsch_ue_select_tbl_in_use; extern boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; extern eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; #endif - +extern mac_rlc_am_muilist_t rlc_am_mui; #endif //DEF_H diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 7429489334..c183af43dc 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -668,6 +668,10 @@ void dlsch_scheduler_pre_ue_select( continue; } + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + continue; + } + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; #if 0 if (ue_sched_ctl->ul_out_of_sync == 1) { @@ -774,6 +778,10 @@ void dlsch_scheduler_pre_ue_select( if (rnti == NOT_A_RNTI) continue; + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + continue; + } + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; #if 0 if (ue_sched_ctl->ul_out_of_sync == 1) { @@ -887,6 +895,10 @@ void dlsch_scheduler_pre_ue_select( if (rnti == NOT_A_RNTI) continue; + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + continue; + } + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; #if 0 if (ue_sched_ctl->ul_out_of_sync == 1) { @@ -1159,6 +1171,9 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, dlsch_ue_select[CC_id].ue_num = i+1; break; } + LOG_D(MAC,"DLSCH UE Select: frame %d subframe %d pre_nb_available_rbs %d(i %d UE_id %d nb_rbs_required %d nb_rbs_required_remaining %d average_rbs_per_user %d (temp_total rbs_count %d ue_num %d) available_prbs %d)\n", + frameP,subframeP,ue_sched_ctl->pre_nb_available_rbs[CC_id],i,UE_id,nb_rbs_required[CC_id][UE_id],nb_rbs_required_remaining[CC_id][UE_id], + average_rbs_per_user[CC_id],temp_total_rbs_count,temp_total_ue_count,RC.mac[Mod_id]->eNB_stats[CC_id].available_prbs); #ifdef TM5 // TODO: data channel TM5: to be re-visited #endif diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 6c950fb841..b06191c91d 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -155,5 +155,5 @@ uint8_t new_dlsch_ue_select_tbl_in_use; boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; #endif - +mac_rlc_am_muilist_t rlc_am_mui; #endif 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 6f1516d3b9..a0610170d4 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -588,7 +588,6 @@ rlc_am_mac_status_indication ( sdu_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_size; sdu_remaining_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_remaining_size; - status_resp.rrc_mui = rlc->input_sdus[rlc->current_sdu_index].mui; status_resp.head_sdu_remaining_size_to_send = sdu_remaining_size; if (sdu_size == sdu_remaining_size) { diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c index 1bd0dce9cb..3f62b05c55 100644 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c @@ -358,6 +358,8 @@ void rlc_am_segment_10 ( PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_remaining_size); //msg ("[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] pdu_mem_p %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", rlc_pP->module_id, rlc_pP->rb_id, ctxt_pP->frame, pdu_mem_p, pdu_p, pdu_p->data, data, data_sdu_p,pdu_remaining_size); + rlc_am_mui.rrc_mui[rlc_am_mui.rrc_mui_num] = sdu_mngt_p->mui; + rlc_am_mui.rrc_mui_num++; memcpy(data, data_sdu_p, pdu_remaining_size); pdu_mngt_p->payload_size += pdu_remaining_size; @@ -376,6 +378,9 @@ void rlc_am_segment_10 ( LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] Exactly Filling remaining PDU with %d remaining bytes of SDU\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), pdu_remaining_size); + rlc_am_mui.rrc_mui[rlc_am_mui.rrc_mui_num] = sdu_mngt_p->mui; + rlc_am_mui.rrc_mui_num++; + memcpy(data, data_sdu_p, pdu_remaining_size); pdu_mngt_p->payload_size += pdu_remaining_size; @@ -392,6 +397,8 @@ void rlc_am_segment_10 ( continue_fill_pdu_with_sdu = 0; pdu_remaining_size = 0; } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { + rlc_am_mui.rrc_mui[rlc_am_mui.rrc_mui_num] = sdu_mngt_p->mui; + rlc_am_mui.rrc_mui_num++; if (fill_num_li == (RLC_AM_MAX_SDU_IN_PDU - 1)) { LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] [SIZE %d] REACHING RLC_AM_MAX_SDU_IN_PDU LIs -> STOP SEGMENTATION FOR THIS PDU SDU\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP), @@ -472,6 +479,9 @@ void rlc_am_segment_10 ( sdu_mngt_p->sdu_remaining_size, pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); //assert(1!=1); + rlc_am_mui.rrc_mui[rlc_am_mui.rrc_mui_num] = sdu_mngt_p->mui; + rlc_am_mui.rrc_mui_num++; + memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; pdu_remaining_size = pdu_remaining_size - sdu_mngt_p->sdu_remaining_size; diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index b38da4dd5b..ffd963204e 100644 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -151,7 +151,6 @@ typedef struct { frame_t head_sdu_creation_time; /*!< \brief Head SDU creation time. */ sdu_size_t head_sdu_remaining_size_to_send; /*!< \brief remaining size of sdu: could be the total size or the remaining size of already segmented sdu */ boolean_t head_sdu_is_segmented; /*!< \brief 0 if head SDU has not been segmented, 1 if already segmented */ - mui_t rrc_mui; } mac_rlc_status_resp_t; diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index 53b801d78e..cc15414913 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -192,6 +192,7 @@ tbs_size_t mac_rlc_data_req( break; case RLC_MODE_AM: + rlc_am_mui.rrc_mui_num = 0; if (!enb_flagP) rlc_am_set_nb_bytes_requested_by_mac(&rlc_union_p->rlc.am,tb_sizeP); data_request = rlc_am_mac_data_request(&ctxt, &rlc_union_p->rlc.am,enb_flagP); ret_tb_size =mac_rlc_serialize_tb(buffer_pP, data_request.data); @@ -372,7 +373,6 @@ mac_rlc_status_resp_t mac_rlc_status_ind( mac_rlc_status_resp.head_sdu_creation_time = status_resp.head_sdu_creation_time; mac_rlc_status_resp.head_sdu_remaining_size_to_send = status_resp.head_sdu_remaining_size_to_send; mac_rlc_status_resp.head_sdu_is_segmented = status_resp.head_sdu_is_segmented; - mac_rlc_status_resp.rrc_mui = status_resp.rrc_mui; //return mac_rlc_status_resp; break; diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index d94ff0d162..d92ea8b4cd 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -831,7 +831,8 @@ 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 >= 20000 ) { + if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && + (mac_eNB_get_rrc_status(enb_mod_idP,rnti) >= RRC_CONNECTED)) { 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) @@ -2100,6 +2101,8 @@ rrc_eNB_generate_RRCConnectionRelease( rrc_release_info.RRC_release_ctrl[release_num].rnti = ctxt_pP->rnti; rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui = rrc_eNB_mui; rrc_release_info.num_UEs++; + LOG_D(RRC,"Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n",release_num, + ctxt_pP->rnti, rrc_eNB_mui,rrc_release_info.RRC_release_ctrl[release_num].flag); break; } } From 38363b10e3613c1b7fa8111e7368f28d28d2dfe2 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Tue, 15 May 2018 14:42:33 +0900 Subject: [PATCH 76/91] fix rm916 bug --- openair1/SCHED/phy_procedures_lte_eNb.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index a0b13cdb7b..33fdffa536 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -889,7 +889,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) LOG_E(PHY,"Unknown number for N_RB_UL %d\n",fp->N_RB_UL); break; } - + SR_payload = 0; switch (uci->type) { case SR: case HARQ_SR: @@ -2010,6 +2010,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, switch (harq_ack[0]) { case 0: + case 4: pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; break; case 1: // check if M=1,4,7 @@ -2018,7 +2019,9 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, 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); - } + }else{ + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; + } break; case 2: // check if M=2,5,8 if (uci->num_pucch_resources == 2 || tdd_config5_sf2scheds == 2 || @@ -2026,7 +2029,9 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, 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); - } + }else{ + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; + } break; case 3: // check if M=3,6,9 if (uci->num_pucch_resources == 3 || tdd_config5_sf2scheds == 3 || @@ -2034,7 +2039,9 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, 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); - } + }else{ + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; + } break; } break; From 24c669f394ee8290a8118b9e2d1053fc2d1d1233 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Tue, 15 May 2018 14:51:13 +0900 Subject: [PATCH 77/91] fix DLSCH no retransmission --- openair1/SCHED/phy_procedures_lte_eNb.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 33fdffa536..ab01b980a6 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1043,6 +1043,14 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) harq_ack[0] = 0; } uci->stat = metric[0]; + if(harq_ack[0] != 1){ + LOG_E(PHY,"PUCCH ACK/NACK(SR): frame %d subframe %d rnti %x n_pucch_1_0_sr[0] %d pucch_fmt %d harq_ack[0]:%d -> 1\n ", + frame,subframe,uci->rnti,uci->n_pucch_1_0_sr[0],uci->pucch_fmt,harq_ack[0]); + harq_ack[0] =1; + }else{ + LOG_E(PHY,"PUCCH ACK/NACK(SR): frame %d subframe %d rnti %x n_pucch_1_0_sr[0] %d pucch_fmt %d\n ", + frame,subframe,uci->rnti,uci->n_pucch_1_0_sr[0],uci->pucch_fmt); + } fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,2,0xffff); // special_bundling mode } else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==2)){ // multiplexing + no SR, implement Table 10.1.3-5 (Rel14) for multiplexing with M=2 @@ -1310,6 +1318,14 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) harq_ack[0] = pucch_b0b1[0][0]; harq_ack[1] = pucch_b0b1[0][1]; uci->stat = metric[0]; + if(harq_ack[0] != 1){ + LOG_E(PHY,"PUCCH ACK/NACK(no SR): frame %d subframe %d rnti %x n_pucch_1[0][0] %d pucch_fmt %d harq_ack[0]:%d -> 1\n", + frame,subframe,uci->rnti,uci->n_pucch_1[0][0],uci->pucch_fmt,harq_ack[0]); + harq_ack[0] =1; + }else{ + LOG_E(PHY,"PUCCH ACK/NACK(no SR): frame %d subframe %d rnti %x n_pucch_1[0][0] %d pucch_fmt %d \n", + frame,subframe,uci->rnti,uci->n_pucch_1[0][0],uci->pucch_fmt); + } fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,0,0xffff); // special_bundling mode } From de1996ec3e32653a5295d1787d05d94b9b4e0255 Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Tue, 15 May 2018 17:37:43 +0900 Subject: [PATCH 78/91] change compile option from UE_EXPANSION to UE_EXPANSION,PHY_TX_THREAD,PRE_SCD_THREAD. --- common/utils/itti/intertask_interface.c | 10 --- openair1/PHY/INIT/lte_init.c | 4 -- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 65 +++++++------------ openair1/PHY/LTE_TRANSPORT/defs.h | 6 +- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 2 +- openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c | 8 +-- openair1/PHY/LTE_TRANSPORT/proto.h | 8 --- openair1/PHY/LTE_TRANSPORT/uci_tools.c | 10 +-- openair1/PHY/defs.h | 4 +- openair1/SCHED/defs.h | 4 -- openair1/SCHED/fapi_l1.c | 20 +++--- openair1/SCHED/phy_procedures_lte_eNb.c | 10 +-- openair1/SCHED/pusch_pc.c | 8 --- openair2/COMMON/platform_types.h | 4 -- openair2/LAYER2/MAC/eNB_scheduler.c | 4 +- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 16 ++--- openair2/LAYER2/MAC/extern.h | 2 +- openair2/LAYER2/MAC/pre_processor.c | 4 +- openair2/LAYER2/MAC/proto.h | 2 +- openair2/LAYER2/MAC/vars.h | 2 +- openair2/RRC/LITE/L2_interface.c | 3 - openair2/RRC/LITE/MESSAGES/asn1_msg.c | 52 --------------- openair2/RRC/LITE/rrc_common.c | 2 - openair2/RRC/LITE/rrc_eNB.c | 60 ++--------------- openair2/RRC/LITE/rrc_eNB_S1AP.c | 3 - targets/RT/USER/lte-enb.c | 2 +- targets/RT/USER/lte-ru.c | 34 ++++------ targets/RT/USER/lte-softmodem.c | 2 - targets/RT/USER/lte-softmodem.h | 2 - 29 files changed, 76 insertions(+), 277 deletions(-) diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c index 78d4deacb7..f96c9b3bc6 100644 --- a/common/utils/itti/intertask_interface.c +++ b/common/utils/itti/intertask_interface.c @@ -54,9 +54,7 @@ #include "signals.h" #include "timer.h" -#ifdef UE_EXPANSION #include "log.h" -#endif /* ITTI DEBUG groups */ #define ITTI_DEBUG_POLL (1<<0) @@ -361,7 +359,6 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me /* Enqueue message in destination task queue */ if (lfds611_queue_enqueue(itti_desc.tasks[destination_task_id].message_queue, new) == 0) { -#ifdef UE_EXPANSION LOG_I(UDP_, " Assertion Message %s(id:%d), number %lu with priority %d can not be sent from (%u:%s) to queue (%u:%s). discarding...\n", itti_desc.messages_info[message_id].name, message_id, @@ -374,9 +371,6 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me int result = itti_free(origin_task_id, message); AssertFatal( result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); return 0; -#else - AssertFatal(0, "Error: lfds611_queue_enqueue returns 0, queue is full, exiting\n"); -#endif } { @@ -530,14 +524,10 @@ static inline void itti_receive_msg_internal_event_fd(task_id_t task_id, uint8_t if (lfds611_queue_dequeue (itti_desc.tasks[task_id].message_queue, (void **) &message) == 0) { /* No element in list -> this should not happen */ -#ifdef UE_EXPANSION LOG_I(UDP_, "Assertion No message in queue for task %d while there are %d events and some for the messages queue!\n", task_id, epoll_ret); /* Mark that the event has been processed */ itti_desc.threads[thread_id].events[i].events &= ~EPOLLIN; return; -#else - AssertFatal (0, "No message in queue for task %d while there are %d events and some for the messages queue!\n", task_id, epoll_ret); -#endif } AssertFatal(message != NULL, "Message from message queue is NULL!\n"); diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index b8a7495ebc..d5a1262e8d 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -649,11 +649,7 @@ void phy_config_sib13_eNB(module_id_t Mod_id,int CC_id,int mbsfn_Area_idx, void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *eNB) { -#ifndef UE_EXPANSION - uint8_t UE_id; -#else uint16_t UE_id; -#endif struct PhysicalConfigDedicated *physicalConfigDedicated; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 61fb92e252..a832b97e70 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -800,19 +800,11 @@ void generate_RIV_tables() // n_tilde_PRB(2,3) = (3,5) // n_tilde_PRB(0,1) = (0,2) -#ifndef UE_EXPANSION -int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) -#else + int16_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) -#endif { -#ifndef UE_EXPANSION - uint8_t i; - int8_t first_free_index=-1; -#else uint16_t i; int16_t first_free_index=-1; -#endif AssertFatal(eNB!=NULL,"eNB is null\n"); for (i=0; indi = rel8->new_data_indicator_1; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; #else dlsch0->active = 1; @@ -1271,7 +1254,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t dlsch0_harq->Qm = 2; dlsch0_harq->TBS = TBStable[I_mcs][NPRB-1]; dlsch0->harq_ids[frame%2][subframe] = rel8->harq_process; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; #else dlsch0->active = 1; @@ -1289,7 +1272,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t case NFAPI_DL_DCI_FORMAT_1: dci_alloc->format = format1; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; #else dlsch0->active = 1; @@ -1438,7 +1421,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t dlsch0_harq->dl_power_off = 1; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; #else dlsch0->active = 1; @@ -1653,7 +1636,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t // assume both TBs are active dlsch0_harq->Nl = 1; dlsch1_harq->Nl = 1; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; dlsch1->active[subframe] = 1; #else @@ -1665,7 +1648,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t // check if either TB is disabled (see 36-213 V11.3 Section ) if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) { -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 0; #else dlsch0->active = 0; @@ -1674,7 +1657,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t } if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) { -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch1->active[subframe]= 0; #else dlsch1->active = 0; @@ -1690,7 +1673,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch0_harq->nb_rb-1]; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if ((dlsch0->active[subframe]==1) && (dlsch1->active[subframe]==1)) { #else if ((dlsch0->active==1) && (dlsch1->active==1)) { @@ -1704,7 +1687,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t dlsch1_harq->mimo_mode = ALAMOUTI; } } else if (fp->nb_antenna_ports_eNB == 4) { // 4 antenna case -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if ((dlsch0->active[subframe]==1) && (dlsch1->active[subframe]==1)) { #else if ((dlsch0->active==1) && (dlsch1->active==1)) { @@ -1748,7 +1731,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t LOG_E(PHY,"Illegal value (3) for TPMI in Format 2A DCI\n"); break; } -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD } else if (dlsch0->active[subframe] == 1) { #else } else if (dlsch0->active == 1) { @@ -1772,7 +1755,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",rel8->precoding_information); break; } -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD } else if (dlsch1->active[subframe] == 1) { #else } else if (dlsch1->active == 1) { @@ -1802,14 +1785,14 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t } // reset HARQ process if this is the first transmission -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if ((dlsch0->active[subframe]==1) && (dlsch0_harq->round == 0)) #else if ((dlsch0->active==1) && (dlsch0_harq->round == 0)) #endif dlsch0_harq->status = ACTIVE; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if ((dlsch1->active[subframe]==1) && (dlsch1_harq->round == 0)) #else if ((dlsch1->active==1) && (dlsch1_harq->round == 0)) @@ -1987,7 +1970,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t printf("RV0 = %d, RV1 = %d. MCS0 = %d, MCS1=%d\n", rel8->redundancy_version_1, rel8->redundancy_version_2, rel8->mcs_1, rel8->mcs_2); #endif if (TB0_active && TB1_active && rel8->transport_block_to_codeword_swap_flag==0) { -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; dlsch1->active[subframe] = 1; #else @@ -2015,7 +1998,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t else if (TB0_active && TB1_active && rel8->transport_block_to_codeword_swap_flag==1) { dlsch0 = eNB->dlsch[UE_id][1]; dlsch1 = eNB->dlsch[UE_id][0]; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; dlsch1->active[subframe] = 1; #else @@ -2039,7 +2022,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t dlsch1_harq->codeword=0; } else if (TB0_active && (TB1_active==0)) { -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; #else dlsch0->active = 1; @@ -2058,7 +2041,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t #endif } else if ((TB0_active==0) && TB1_active) { -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch1->active[subframe] = 1; #else dlsch1->active = 1; @@ -2330,7 +2313,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d case 10: // Format 6-1A dci_alloc->format = format6_1A; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; #else dlsch0->active = 1; @@ -2390,7 +2373,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d break; case 11: // Format 6-1B dci_alloc->format = format6_1B; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; #else dlsch0->active = 1; @@ -2437,7 +2420,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d } case 12: // Format 6-2 dci_alloc->format = format6_2; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; #else dlsch0->active = 1; @@ -2525,7 +2508,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d dlsch0_harq->dl_power_off = 1; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[subframe] = 1; #else dlsch0->active = 1; @@ -2813,15 +2796,11 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu ulsch->harq_processes[harq_pid]->Or1 = 0; ulsch->harq_processes[harq_pid]->Or2 = 0; } -#ifndef UE_EXPANSION - else ulsch->harq_processes[harq_pid]->round++; -#else else { ulsch->harq_processes[harq_pid]->round++; ulsch->harq_processes[harq_pid]->TBS = ulsch_pdu->ulsch_pdu_rel8.size<<3; ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch_pdu->ulsch_pdu_rel8.number_of_resource_blocks; } -#endif ulsch->rnti = ulsch_pdu->ulsch_pdu_rel8.rnti; LOG_D(PHY,"Filling ULSCH %x (UE_id %d) (new_ulsch %d) for Frame %d, Subframe %d : harq_pid %d, status %d, handled %d, first_rb %d, nb_rb %d, rvidx %d, Qm %d, TBS %d, round %d \n", ulsch->rnti, diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h index 293f931363..aa465cfa57 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/defs.h @@ -184,7 +184,7 @@ typedef struct { uint8_t first_layer; /// codeword this transport block is mapped to uint8_t codeword; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD #ifdef Rel14 /// indicator that this DLSCH corresponds to SIB1-BR, needed for c_init for scrambling uint8_t sib1_br_flag; @@ -279,7 +279,7 @@ typedef struct { /// Allocated RNTI (0 means DLSCH_t is not currently used) uint16_t rnti; /// Active flag for baseband transmitter processing -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD uint8_t active[10]; #else uint8_t active; @@ -314,7 +314,7 @@ typedef struct { int16_t sqrt_rho_a; /// amplitude of PDSCH (compared to RS) in symbols containing pilots int16_t sqrt_rho_b; -#ifndef UE_EXPANSION +#ifndef PHY_TX_THREAD #ifdef Rel14 /// indicator that this DLSCH corresponds to SIB1-BR, needed for c_init for scrambling uint8_t sib1_br_flag; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 80ab4a401c..b04a8bb665 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -246,7 +246,7 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) if (dlsch) { Mdlharq = dlsch->Mdlharq; dlsch->rnti = 0; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD for (i=0; i<10; i++) dlsch->active[i] = 0; #else diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c index 83392b18a9..1345f0e404 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c @@ -92,19 +92,19 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, uint8_t Nacc=4; uint16_t j0,j,idelta; uint16_t i = (Ns>>1) + (10*frame); -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD uint16_t i0 = dlsch->harq_processes[harq_pid]->i0; #else uint16_t i0 = dlsch->i0; #endif -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if (dlsch->harq_processes[harq_pid]->sib1_br_flag==1) Nacc=1; #else if (dlsch->sib1_br_flag==1) Nacc=1; #endif else if (dlsch->rnti == 0xFFFF || dlsch->rnti == 0xFFFE) Nacc = (frame_parms->frame_type == TDD) ? 10 : 4; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD // Note: above SC-RNTI will also have to be added when/if implemented else if (dlsch->harq_processes[harq_pid]->CEmode == CEmodeA) Nacc=1; else if (dlsch->harq_processes[harq_pid]->CEmode == CEmodeB) Nacc = (frame_parms->frame_type == TDD) ? 10 : 4; @@ -125,7 +125,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, // x1 is set in lte_gold_generic if (mbsfn_flag == 0) { #ifdef Rel14 -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if (dlsch->harq_processes[harq_pid]->i0 != 0xFFFF) { #else if (dlsch->i0 != 0xFFFF) { diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 10e45af9b1..051f3cd92e 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -2260,18 +2260,10 @@ uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); -#ifndef UE_EXPANSION -int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); - -int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); - -int8_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type); -#else int16_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); int16_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); int16_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type); -#endif /**@}*/ #endif diff --git a/openair1/PHY/LTE_TRANSPORT/uci_tools.c b/openair1/PHY/LTE_TRANSPORT/uci_tools.c index 33fa677f29..14b55569b8 100644 --- a/openair1/PHY/LTE_TRANSPORT/uci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/uci_tools.c @@ -788,18 +788,10 @@ void print_CQI(void *o,UCI_format_t uci_format,unsigned char eNB_id,int N_RB_DL) } -#ifndef UE_EXPANSION -int8_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type) { -#else + int16_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type) { -#endif -#ifndef UE_EXPANSION - uint8_t i; - int8_t first_free_index=-1; -#else uint16_t i; int16_t first_free_index=-1; -#endif AssertFatal(eNB!=NULL,"eNB is null\n"); for (i=0; iuci_vars[i].active >0) && diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index f8b0b205b2..e15978106d 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -422,7 +422,7 @@ typedef struct RU_proc_t_s { int num_slaves; /// array of pointers to slaves struct RU_proc_t_s **slave_proc; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD /// pthread structure for PRACH thread pthread_t pthread_phy_tx; pthread_mutex_t mutex_phy_tx; @@ -442,7 +442,7 @@ typedef struct RU_proc_t_s { /// \internal This variable is protected by \ref mutex_rf_tx. int instance_cnt_rf_tx; #endif -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) pthread_t pthread_pre_scd; /// condition variable for time processing thread pthread_cond_t cond_pre_scd; diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h index e6ffd33a02..84b7b46b81 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/defs.h @@ -511,11 +511,7 @@ LTE_DL_FRAME_PARMS *get_lte_frame_parms(module_id_t Mod_id, uint8_t CC_id); MU_MIMO_mode* get_mu_mimo_mode (module_id_t Mod_id, uint8_t CC_id, rnti_t rnti); int16_t get_hundred_times_delta_IF(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t harq_pid); -#ifndef UE_EXPANSION -int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *phy_vars_eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor); -#else int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *phy_vars_eNB,uint16_t UE_id,uint8_t harq_pid, uint8_t bw_factor); -#endif int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid); int16_t get_target_pusch_rx_power(module_id_t module_idP, uint8_t CC_id); diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index f459d9df9f..63e4d9248e 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -191,7 +191,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr // compute DL power control parameters eNB->pdsch_config_dedicated[UE_id].p_a = rel8->pa; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if (dlsch0->active[proc->subframe_tx]){ # else if (dlsch0->active){ @@ -199,7 +199,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr computeRhoA_eNB(&eNB->pdsch_config_dedicated[UE_id], dlsch0,dlsch0_harq->dl_power_off, eNB->frame_parms.nb_antenna_ports_eNB); computeRhoB_eNB(&eNB->pdsch_config_dedicated[UE_id],&(eNB->frame_parms.pdsch_config_common),eNB->frame_parms.nb_antenna_ports_eNB,dlsch0,dlsch0_harq->dl_power_off); } -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if (dlsch1->active[proc->subframe_tx]){ #else if (dlsch1->active){ @@ -231,7 +231,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr } #ifdef Rel14 -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0_harq->sib1_br_flag=0; #else dlsch0->sib1_br_flag=0; @@ -243,7 +243,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr dlsch0->Mdlharq = 4; dlsch0->Nsoft = 25344; -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if (rel13->pdsch_payload_type == 0) dlsch0_harq->sib1_br_flag=1; #else if (rel13->pdsch_payload_type == 0) dlsch0->sib1_br_flag=1; @@ -274,7 +274,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr dlsch0_harq->rb_alloc[3] = localRIV2alloc_LUT100_3[rel8->resource_block_coding]; } -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0->active[proc->subframe_tx]= 1; #else dlsch0->active = 1; @@ -294,21 +294,21 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr dlsch0_harq->pdsch_start = rel10->pdsch_start; } else { -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0_harq->i0 = 0xFFFF; #else dlsch0->i0 = 0xFFFF; #endif } #endif -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0_harq->i0 = rel13->initial_transmission_sf_io; #else dlsch0->i0 = rel13->initial_transmission_sf_io; #endif LOG_D(PHY,"dlsch->i0:%04x dlsch0_harq[pdsch_start:%d nb_rb:%d vrb_type:%d rvidx:%d Nl:%d mimo_mode:%d dl_power_off:%d round:%d status:%d TBS:%d Qm:%d codeword:%d rb_alloc:%d] rel8[length:%d]\n", -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch0_harq->i0, #else dlsch0->i0, @@ -566,11 +566,7 @@ void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, uint16_t frame,uint8_t subframe,uint8_t srs_present) { nfapi_ul_config_ulsch_pdu_rel8_t *rel8 = &ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8; -#ifndef UE_EXPANSION - int8_t UE_id; -#else int16_t UE_id; -#endif // check if we have received a dci for this ue and ulsch descriptor is configured diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index a0b13cdb7b..3bc0ccfc9e 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -397,7 +397,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, stop_meas(&eNB->dlsch_modulation_stats); } -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD dlsch->active[subframe] = 0; #else dlsch->active = 0; @@ -420,11 +420,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, int subframe=proc->subframe_tx; uint32_t i,aa; uint8_t harq_pid; -#ifndef UE_EXPANSION - int8_t UE_id=0; -#else int16_t UE_id=0; -#endif uint8_t num_pdcch_symbols=0; uint8_t num_dci=0; uint8_t ul_subframe; @@ -544,7 +540,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, if ((dlsch0)&& (dlsch0->rnti>0)&& -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD (dlsch0->active[subframe] == 1)) { #else (dlsch0->active == 1)) { @@ -576,7 +572,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, else if ((dlsch0)&& (dlsch0->rnti>0)&& -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD (dlsch0->active[subframe] == 0)) { #else (dlsch0->active == 0)) { diff --git a/openair1/SCHED/pusch_pc.c b/openair1/SCHED/pusch_pc.c index be4c8f870c..5e23f701e0 100644 --- a/openair1/SCHED/pusch_pc.c +++ b/openair1/SCHED/pusch_pc.c @@ -38,11 +38,7 @@ // This is the formula from Section 5.1.1.1 in 36.213 100*10*log10((2^(MPR*Ks)-1)), where MPR is in the range [0,6] and Ks=1.25 int16_t hundred_times_delta_TF[100] = {-32768,-1268,-956,-768,-631,-523,-431,-352,-282,-219,-161,-107,-57,-9,36,79,120,159,197,234,269,304,337,370,402,434,465,495,525,555,583,612,640,668,696,723,750,777,803,829,856,881,907,933,958,983,1008,1033,1058,1083,1108,1132,1157,1181,1205,1229,1254,1278,1302,1325,1349,1373,1397,1421,1444,1468,1491,1515,1538,1562,1585,1609,1632,1655,1679,1702,1725,1748,1772,1795,1818,1841,1864,1887,1910,1933,1956,1980,2003,2026,2049,2072,2095,2118,2141,2164,2186,2209,2232,2255}; uint16_t hundred_times_log10_NPRB[100] = {0,301,477,602,698,778,845,903,954,1000,1041,1079,1113,1146,1176,1204,1230,1255,1278,1301,1322,1342,1361,1380,1397,1414,1431,1447,1462,1477,1491,1505,1518,1531,1544,1556,1568,1579,1591,1602,1612,1623,1633,1643,1653,1662,1672,1681,1690,1698,1707,1716,1724,1732,1740,1748,1755,1763,1770,1778,1785,1792,1799,1806,1812,1819,1826,1832,1838,1845,1851,1857,1863,1869,1875,1880,1886,1892,1897,1903,1908,1913,1919,1924,1929,1934,1939,1944,1949,1954,1959,1963,1968,1973,1977,1982,1986,1991,1995,2000}; -#ifndef UE_EXPANSION -int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor) -#else int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t harq_pid, uint8_t bw_factor) -#endif { uint32_t Nre,sumKr,MPR_x100,Kr,r; @@ -93,11 +89,7 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid) { -#ifndef UE_EXPANSION - int8_t UE_id; -#else int16_t UE_id; -#endif if ((RC.eNB == NULL) || (module_idP > RC.nb_inst) || (CC_id > RC.nb_CC[module_idP])) { LOG_E(PHY,"get_UE_stats: No eNB found (or not allocated) for Mod_id %d,CC_id %d\n",module_idP,CC_id); return -1; diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index 17ce7fba2f..cc46598cbe 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -68,11 +68,7 @@ typedef int32_t sdu_size_t; typedef uint32_t frame_t; typedef int32_t sframe_t; typedef uint32_t sub_frame_t; -#ifndef UE_EXPANSION -typedef uint8_t module_id_t; -#else typedef uint16_t module_id_t; -#endif typedef uint8_t eNB_index_t; typedef uint16_t ue_id_t; typedef int16_t smodule_id_t; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 7d11a6385f..91ad68d007 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -768,7 +768,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, } -#if (!defined(UE_EXPANSION_SIM2)) &&(!defined(UE_EXPANSION)) +#if (!defined(PRE_SCD_THREAD)) PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, subframeP, module_idP); @@ -821,7 +821,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, 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_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 8e3eb86300..72f6f46838 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -413,7 +413,7 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, } -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD extern volatile int16_t phy_tx_txdataF_end; extern int oai_exit; #endif @@ -553,11 +553,6 @@ schedule_ue_spec(module_id_t module_idP, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); -#ifdef UE_EXPANSION - struct timespec time_req, time_rem; - time_req.tv_sec = 0; - time_req.tv_nsec = 10000; -#endif for (CC_id=0; CC_id= DTCH; lcid--) { + for (lcid = DTCH; lcid >= DTCH; lcid--) { #else for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { #endif @@ -1327,7 +1320,10 @@ schedule_ue_spec(module_id_t module_idP, post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header } -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD + struct timespec time_req, time_rem; + time_req.tv_sec = 0; + time_req.tv_nsec = 10000; while((!oai_exit)&&(phy_tx_txdataF_end == 0)){ nanosleep(&time_req,&time_rem); continue; diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index 3cbb40cb10..b20846c5b5 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -103,7 +103,7 @@ extern int last_dlsch_ue_id[MAX_NUM_CCs]; extern int last_ulsch_ue_id[MAX_NUM_CCs]; #endif -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) extern uint16_t pre_nb_rbs_required[2][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; extern uint8_t dlsch_ue_select_tbl_in_use; extern uint8_t new_dlsch_ue_select_tbl_in_use; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index c183af43dc..2f221b0a0a 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -540,7 +540,7 @@ void sort_UEs(module_id_t Mod_idP, int frameP, sub_frame_t subframeP) #endif } -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, uint16_t step_size){ uint16_t nb_rb,i_TBS,tmp_TBS; i_TBS=get_I_TBS(mcs); @@ -1078,7 +1078,7 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, } } -#if (!defined(UE_EXPANSION_SIM2)) &&(!defined(UE_EXPANSION)) +#if (!defined(PRE_SCD_THREAD)) // Store the DLSCH buffer for each logical channel store_dlsch_buffer(Mod_id, frameP, subframeP); diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index df094392f1..fe7d9c96f6 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -227,7 +227,7 @@ void dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) void pre_scd_nb_rbs_required(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index b06191c91d..7e199ec074 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -148,7 +148,7 @@ int last_dlsch_ue_id[MAX_NUM_CCs] = {-1}; int last_ulsch_ue_id[MAX_NUM_CCs] = {-1}; #endif -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) uint16_t pre_nb_rbs_required[2][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint8_t dlsch_ue_select_tbl_in_use; uint8_t new_dlsch_ue_select_tbl_in_use; diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index 5b0971a4bd..90c447c763 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -613,14 +613,11 @@ rrc_data_req( ) //------------------------------------------------------------------------------ { -#ifdef UE_EXPANSION if(sdu_sizeP == 255) { LOG_I(RRC,"sdu_sizeP == 255"); return FALSE; } -#else -#endif MSC_LOG_TX_MESSAGE( ctxt_pP->enb_flag ? MSC_RRC_ENB : MSC_RRC_UE, ctxt_pP->enb_flag ? MSC_PDCP_ENB : MSC_PDCP_UE, diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index 08dd65bea7..58ac5a3f87 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -1267,9 +1267,7 @@ 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; @@ -1620,17 +1618,12 @@ do_RRCConnectionSetup( (void*)&dl_ccch_msg, buffer, 100); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1699,17 +1692,12 @@ do_SecurityModeCommand( (void*)&dl_dcch_msg, buffer, 100); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1783,17 +1771,12 @@ do_UECapabilityEnquiry( (void*)&dl_dcch_msg, buffer, 100); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -1951,17 +1934,12 @@ do_RRCConnectionReconfiguration( (void*)&dl_dcch_msg, buffer, RRC_BUF_SIZE); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %zd)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #ifdef XER_PRINT xer_fprint(stdout,&asn_DEF_DL_DCCH_Message,(void*)&dl_dcch_msg); #endif @@ -2172,17 +2150,12 @@ do_RRCConnectionReestablishment( (void*)&dl_ccch_msg, buffer, 100); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2238,17 +2211,12 @@ do_RRCConnectionReestablishmentReject( (void*)&dl_ccch_msg, buffer, 100); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2305,17 +2273,12 @@ do_RRCConnectionReject( (void*)&dl_ccch_msg, buffer, 100); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %ld)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2502,17 +2465,12 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, (void*)mcch_message, buffer, 100); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2639,17 +2597,12 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ (void*)&ul_dcch_msg, buffer, 100); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) { @@ -2775,17 +2728,12 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count); enc_rval = uper_encode_to_buffer(&asn_DEF_PCCH_Message, (void*)&pcch_msg, buffer, RRC_BUF_SIZE); -#ifdef UE_EXPANSION if(enc_rval.encoded == -1) { LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } -#else - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); -#endif #ifdef XER_PRINT xer_fprint(stdout, &asn_DEF_PCCH_Message, (void*)&pcch_msg); #endif diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c index bb1e6c8235..75ce529ac7 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LITE/rrc_common.c @@ -506,9 +506,7 @@ rrc_rx_tx( ue_context_p->ue_context.ue_release_timer_thres) { LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); ue_to_be_removed = ue_context_p; -#ifdef UE_EXPANSION ue_context_p->ue_context.ue_release_timer = 0; -#endif break; } } diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index d92ea8b4cd..37c33c45b9 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -574,18 +574,6 @@ rrc_eNB_get_next_free_ue_context( ctxt_pP->rnti); if (ue_context_p == NULL) { -#ifndef UE_EXPANSION - RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { - if (ue_context_p->ue_context.random_ue_identity == ue_identityP) { - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, already exist rand UE id 0x%"PRIx64", uid %u\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_identityP, - ue_context_p->local_uid); - return NULL; - } - } -#endif ue_context_p = rrc_eNB_allocate_new_UE_context(RC.rrc[ctxt_pP->module_id]); if (ue_context_p == NULL) { @@ -813,14 +801,10 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* PHY_VARS_eNB *eNB_PHY = NULL; eNB_MAC_INST *eNB_MAC = RC.mac[enb_mod_idP]; #endif -#ifdef UE_EXPANSION if (enb_mod_idP >= NB_eNB_INST) { LOG_I(RRC, "eNB inst invalid (%d/%d) for UE %x!\n",enb_mod_idP, NB_eNB_INST,rnti); return; } -#else - AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rnti); -#endif /* ue_context_p = rrc_eNB_get_ue_context( &RC.rrc[enb_mod_idP], rntiP @@ -3940,15 +3924,11 @@ check_handovers( ue_context_p->ue_context.handover_info->size, ue_context_p->ue_context.handover_info->buf, PDCP_TRANSMISSION_MODE_CONTROL); -#ifdef UE_EXPANSION if(result != TRUE) { LOG_I(RRC, "PDCP data request failed!\n"); return; } -#else - AssertFatal(result == TRUE, "PDCP data request failed!\n"); -#endif ue_context_p->ue_context.handover_info->ho_complete = 0xF2; } } @@ -5846,42 +5826,24 @@ rrc_eNB_decode_ccch( rrcConnectionRequest = &ul_ccch_msg->message.choice.c1.choice.rrcConnectionRequest.criticalExtensions.choice.rrcConnectionRequest_r8; { if (InitialUE_Identity_PR_randomValue == rrcConnectionRequest->ue_Identity.present) { - #ifdef UE_EXPANSION if(rrcConnectionRequest->ue_Identity.choice.randomValue.size != 5) { LOG_I(RRC, "wrong InitialUE-Identity randomValue size, expected 5, provided %d", rrcConnectionRequest->ue_Identity.choice.randomValue.size); return -1; } - #else - AssertFatal(rrcConnectionRequest->ue_Identity.choice.randomValue.size == 5, - "wrong InitialUE-Identity randomValue size, expected 5, provided %d", - rrcConnectionRequest->ue_Identity.choice.randomValue.size); - #endif memcpy(((uint8_t*) & random_value) + 3, rrcConnectionRequest->ue_Identity.choice.randomValue.buf, rrcConnectionRequest->ue_Identity.choice.randomValue.size); /* if there is already a registered UE (with another RNTI) with this random_value, * the current one must be removed from MAC/PHY (zombie UE) */ -#ifndef UE_EXPANSION - if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) { - LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n", - ctxt_pP->rnti, ue_context_p->ue_context.rnti, ctxt_pP->rnti); - rrc_mac_remove_ue(ctxt_pP->module_id, ctxt_pP->rnti); - ue_context_p = NULL; - return 0; - } else { - ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value); - } -#else if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) { LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n", ctxt_pP->rnti, ue_context_p->ue_context.rnti, ue_context_p->ue_context.rnti); ue_context_p->ue_context.ul_failure_timer = 20000; } ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value); -#endif } else if (InitialUE_Identity_PR_s_TMSI == rrcConnectionRequest->ue_Identity.present) { /* Save s-TMSI */ S_TMSI_t s_TMSI = rrcConnectionRequest->ue_Identity.choice.s_TMSI; @@ -6864,16 +6826,10 @@ rrc_enb_task( LOG_I(RRC,"Decoding CCCH : inst %d, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n", instance,CC_id,&ctxt, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); -#ifdef UE_EXPANSION if (RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= RRC_BUFFER_SIZE_MAX) { LOG_I(RRC, "CCCH message has size %d > %d\n",RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX); break; } -#else - AssertFatal(RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size < RRC_BUFFER_SIZE_MAX, - "CCCH message has size %d > %d\n", - RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX); -#endif memcpy(srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND(msg_p).sdu, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); @@ -6901,14 +6857,10 @@ rrc_enb_task( // Message buffer has been processed, free it now. result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND(msg_p).sdu_p); -#ifdef UE_EXPANSION if (result != EXIT_SUCCESS) { LOG_I(RRC, "Failed to free memory (%d)!\n",result); break; } -#else - AssertFatal(result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); -#endif break; # if defined(ENABLE_USE_MME) @@ -6977,14 +6929,10 @@ rrc_enb_task( } result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p); -#ifdef UE_EXPANSION - if (result != EXIT_SUCCESS) { - LOG_I(RRC, "Failed to free memory (%d)!\n",result); - continue; - } -#else - AssertFatal(result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); -#endif + if (result != EXIT_SUCCESS) { + LOG_I(RRC, "Failed to free memory (%d)!\n",result); + continue; + } msg_p = NULL; } } diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index 98b842147b..047a767fed 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -1957,14 +1957,11 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance buffer, S1AP_PAGING_IND(msg_p).ue_paging_identity, S1AP_PAGING_IND(msg_p).cn_domain); - #ifdef UE_EXPANSION if(length == -1) { LOG_I(RRC, "do_Paging error"); return -1; } - #else - #endif message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length); /* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */ memcpy (message_buffer, buffer, length); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index b6e6133593..f9fc5d676b 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -243,7 +243,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam //if (wait_CCs(proc)<0) return(-1); if (oai_exit) return(-1); -#if (!defined(UE_EXPANSION_SIM2)) &&(!defined(UE_EXPANSION)) +#ifndef PHY_TX_THREAD phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); #endif if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) return(-1); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 4210ccf07c..11e421d6f0 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -110,9 +110,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "T.h" -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) #include "pdcp.h" -#endif extern volatile int oai_exit; @@ -736,7 +734,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; // synchronize first reception to frame 0 subframe 0 -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD proc->timestamp_phy_tx = proc->timestamp_rx+(3*fp->samples_per_tti); proc->subframe_phy_tx = (proc->subframe_rx+3)%10; proc->frame_phy_tx = (proc->subframe_rx>6) ? (proc->frame_rx+1)&1023 : proc->frame_rx; @@ -1416,7 +1414,7 @@ static void* ru_stats_thread(void* param) { return(NULL); } -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD int first_phy_tx = 1; volatile int16_t phy_tx_txdataF_end; volatile int16_t phy_tx_end; @@ -1434,15 +1432,13 @@ static void* ru_thread( void* param ) { // set default return value ru_thread_status = 0; -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) dlsch_ue_select_tbl_in_use = 1; #endif -#ifdef UE_EXPANSION struct timespec time_req, time_rem; time_req.tv_sec = 0; time_req.tv_nsec = 10000; -#endif // set default return value thread_top_init("ru_thread",0,870000,1000000,1000000); @@ -1522,7 +1518,7 @@ static void* ru_thread( void* param ) { if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&subframe); else AssertFatal(1==0, "No fronthaul interface at south port"); -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if(first_phy_tx == 0) { phy_tx_end = 0; @@ -1579,7 +1575,7 @@ static void* ru_thread( void* param ) { // If this proc is to provide synchronization, do so wakeup_slaves(proc); -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) new_dlsch_ue_select_tbl_in_use = dlsch_ue_select_tbl_in_use; dlsch_ue_select_tbl_in_use = !dlsch_ue_select_tbl_in_use; memcpy(&pre_scd_eNB_UE_stats,&RC.mac[ru->eNB_list[0]->Mod_id]->UE_list.eNB_UE_stats, sizeof(eNB_UE_STATS)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); @@ -1614,7 +1610,7 @@ static void* ru_thread( void* param ) { wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); -#ifndef UE_EXPANSION +#ifndef PHY_TX_THREAD // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); @@ -1720,7 +1716,7 @@ void *ru_thread_synch(void *arg) { } -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) void* pre_scd_thread( void* param ){ static int eNB_pre_scd_status; protocol_ctxt_t ctxt; @@ -1774,7 +1770,7 @@ void* pre_scd_thread( void* param ){ } #endif -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD /*! * \brief The phy tx thread of eNB. * \param param is a \ref eNB_proc_t structure which contains the info what to process. @@ -1952,7 +1948,7 @@ void init_RU_proc(RU_t *ru) { pthread_attr_init( &proc->attr_prach_br); #endif -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD proc->instance_cnt_phy_tx = -1; pthread_mutex_init( &proc->mutex_phy_tx, NULL); pthread_cond_init( &proc->cond_phy_tx, NULL); @@ -1972,7 +1968,7 @@ void init_RU_proc(RU_t *ru) { #endif pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru ); -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) proc->instance_pre_scd = -1; pthread_mutex_init( &proc->mutex_pre_scd, NULL); pthread_cond_init( &proc->cond_pre_scd, NULL); @@ -1980,7 +1976,7 @@ void init_RU_proc(RU_t *ru) { pthread_setname_np(proc->pthread_pre_scd, "pre_scd_thread"); #endif -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD pthread_create( &proc->pthread_phy_tx, NULL, eNB_thread_phy_tx, (void*)ru ); pthread_setname_np( proc->pthread_phy_tx, "phy_tx_thread" ); pthread_create( &proc->pthread_rf_tx, NULL, rf_tx, (void*)ru ); @@ -2428,11 +2424,9 @@ void init_RU(char *rf_config_file) { void stop_ru(RU_t *ru) { -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) - int *status; -#endif + int *status; printf("Stopping RU %p processing threads\n",(void*)ru); -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) +#if defined(PRE_SCD_THREAD) if(ru){ ru->proc.instance_pre_scd = 0; pthread_cond_signal( &ru->proc.cond_pre_scd ); @@ -2441,7 +2435,7 @@ void stop_ru(RU_t *ru) { pthread_cond_destroy(&ru->proc.cond_pre_scd ); } #endif -#ifdef UE_EXPANSION +#ifdef PHY_TX_THREAD if(ru){ ru->proc.instance_cnt_phy_tx = 0; pthread_cond_signal(&ru->proc.cond_phy_tx); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 5861ba6cb2..b1b3d11045 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1454,11 +1454,9 @@ int main( int argc, char **argv ) // cleanup if (UE_flag == 1) { } else { -#ifdef UE_EXPANSION for (ru_id=0;ru_id Date: Tue, 15 May 2018 20:14:58 +0900 Subject: [PATCH 79/91] Change default value of PHY_TX_THREAD and PRE_SCD_THREAD, when UE_EXPANSION is true. --- cmake_targets/CMakeLists.txt | 2 ++ cmake_targets/build_oai | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index f0e0ecb4b9..e1ff105452 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -601,6 +601,8 @@ add_boolean_option(MESSAGE_CHART_GENERATOR_PHY False "trace some PHY exchang add_boolean_option(FLEXRAN_AGENT_SB_IF False "enable FlexRAN agent to inteface with a SDN controller") add_boolean_option(UE_EXPANSION False "enable UE_EXPANSION with max 256 UE") +add_boolean_option(PHY_TX_THREAD False "enable UE_EXPANSION with max 256 UE") +add_boolean_option(PRE_SCD_THREAD False "enable UE_EXPANSION with max 256 UE") ######################## # Include order diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index fb81a0a268..a9ba2c56d1 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -526,6 +526,8 @@ function main() { echo "set ( FLEXRAN_AGENT_SB_IF $FLEXRAN_AGENT_SB_IF )" >> $cmake_file fi echo "set ( UE_EXPANSION $UE_EXPANSION )" >> $cmake_file + echo "set ( PHY_TX_THREAD $UE_EXPANSION )" >> $cmake_file + echo "set ( PRE_SCD_THREAD $UE_EXPANSION )" >> $cmake_file echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file echo "set ( RF_BOARD \"${HW}\")" >> $cmake_file @@ -689,6 +691,8 @@ function main() { echo "set ( FLEXRAN_AGENT_SB_IF $FLEXRAN_AGENT_SB_IF )" >> $cmake_file fi echo "set ( UE_EXPANSION $UE_EXPANSION )" >> $cmake_file + echo "set ( PHY_TX_THREAD $UE_EXPANSION )" >> $cmake_file + echo "set ( PRE_SCD_THREAD $UE_EXPANSION )" >> $cmake_file echo "set ( PRINT_STATS $PRINT_STATS )" >> $cmake_file echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file @@ -773,6 +777,8 @@ function main() { echo "set ( FLEXRAN_AGENT_SB_IF $FLEXRAN_AGENT_SB_IF )" >> $cmake_file fi echo "set ( UE_EXPANSION $UE_EXPANSION )" >> $cmake_file + echo "set ( PHY_TX_THREAD $UE_EXPANSION )" >> $cmake_file + echo "set ( PRE_SCD_THREAD $UE_EXPANSION )" >> $cmake_file echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file echo "set ( T_TRACER $T_TRACER )" >> $cmake_file From 677ad4298c75452ec74ea1607e3b49248ffcc4f9 Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Thu, 17 May 2018 10:48:39 +0900 Subject: [PATCH 80/91] Devide source file of scheduler --- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 2 +- openair1/PHY/impl_defs_lte.h | 3 +- openair2/COMMON/rrc_messages_types.h | 2 - openair2/ENB_APP/enb_config.c | 21 +- openair2/LAYER2/MAC/defs.h | 41 - openair2/LAYER2/MAC/eNB_scheduler.c | 14 +- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 47 +- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 88 +- openair2/LAYER2/MAC/eNB_scheduler_fairRR.c | 3053 +++++++++++++++++++ openair2/LAYER2/MAC/eNB_scheduler_fairRR.h | 130 + openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 586 +--- openair2/LAYER2/MAC/extern.h | 7 +- openair2/LAYER2/MAC/pre_processor.c | 1038 ------- openair2/LAYER2/MAC/proto.h | 24 +- openair2/LAYER2/MAC/vars.h | 13 - openair2/RRC/LITE/rrc_eNB.c | 65 - 16 files changed, 3234 insertions(+), 1900 deletions(-) create mode 100644 openair2/LAYER2/MAC/eNB_scheduler_fairRR.c create mode 100644 openair2/LAYER2/MAC/eNB_scheduler_fairRR.h diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 5d93178b7c..11a0bc5d14 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -934,7 +934,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, nb_rb); //#endif -#ifndef UE_EXPANSION +#ifndef UE_EXPANSION // TODO check this modified if (ulsch_harq->round == 0) { #endif // This is a new packet, so compute quantities regarding segmentation diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index 3a5b920aa7..31276c84b8 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -637,9 +637,8 @@ typedef struct { uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3]; struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[MAX_MBSFN_AREA]; -#ifdef UE_EXPANSION + /// for fair RR scheduler uint32_t ue_multiple_max; -#endif } LTE_DL_FRAME_PARMS; typedef enum { diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 576972f4bb..79edbd3209 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -166,9 +166,7 @@ typedef struct RrcConfigurationReq_s { long ue_TimersAndConstants_n310[MAX_NUM_CCs]; long ue_TimersAndConstants_n311[MAX_NUM_CCs]; long ue_TransmissionMode[MAX_NUM_CCs]; -#ifdef UE_EXPANSION long ue_multiple_max[MAX_NUM_CCs]; -#endif } RrcConfigurationReq; // UE: NAS -> RRC messages diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 121400f2b4..b82fe37fc6 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -868,21 +868,10 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RC.config_file_name, i, prach_zero_correlation); RRC_CONFIGURATION_REQ (msg_p).prach_freq_offset[j] = prach_freq_offset; -#ifndef UE_EXPANSION if ((prach_freq_offset <0) || (prach_freq_offset > 94)) AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for prach_freq_offset choice: 0..94!\n", RC.config_file_name, i, prach_freq_offset); -#else - if ((N_RB_DL == 25) && (prach_freq_offset != 2)) - 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)) - AssertFatal (0, - "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 RRC_CONFIGURATION_REQ (msg_p).pucch_delta_shift[j] = pucch_delta_shift-1; @@ -1768,7 +1757,6 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { break; } -#ifdef UE_EXPANSION RRC_CONFIGURATION_REQ (msg_p).ue_multiple_max[j] = ue_multiple_max; switch (N_RB_DL) { @@ -1779,15 +1767,15 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RC.config_file_name, i, ue_multiple_max); break; case 50: - if ((ue_multiple_max < 1) || (ue_multiple_max > 6)) + if ((ue_multiple_max < 1) || (ue_multiple_max > 8)) AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..6!\n", + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..8!\n", RC.config_file_name, i, ue_multiple_max); break; case 100: - if ((ue_multiple_max < 1) || (ue_multiple_max > 10)) + if ((ue_multiple_max < 1) || (ue_multiple_max > 16)) AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..10!\n", + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..16!\n", RC.config_file_name, i, ue_multiple_max); break; default: @@ -1796,7 +1784,6 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { RC.config_file_name, i, N_RB_DL); break; } -#endif } } char srb1path[MAX_OPTNAME_SIZE*2 + 8]; diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 8dd570c69f..54fb9254ef 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -1361,47 +1361,6 @@ typedef struct { uint8_t n_adj_cells; } neigh_cell_id_t; -#ifdef UE_EXPANSION -enum SCH_UE_PRIORITY { - SCH_PRIORITY_NONE, - SCH_DL_SI, - SCH_DL_PAGING, - SCH_DL_MSG2, - SCH_DL_MSG4, - SCH_UL_PRACH, - SCH_UL_MSG3, - SCH_DL_RETRANS, - SCH_UL_RETRANS, - SCH_DL_FIRST, - SCH_UL_FIRST, - SCH_UL_INACTIVE -}; - -typedef struct { - int UE_id; - enum SCH_UE_PRIORITY ue_priority; - rnti_t rnti; - uint16_t nb_rb; -} DLSCH_UE_INFO; - -typedef struct { - uint16_t ue_num; - DLSCH_UE_INFO list[20]; -} DLSCH_UE_SELECT; - -typedef struct { - int UE_id; - enum SCH_UE_PRIORITY ue_priority; - uint8_t start_rb; - uint8_t nb_rb; - uint16_t ul_total_buffer; -} ULSCH_UE_INFO; - -typedef struct { - uint8_t ue_num; - ULSCH_UE_INFO list[20]; -} ULSCH_UE_SELECT; -#endif typedef struct { volatile uint8_t flag; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 91ad68d007..bb79424c62 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -59,6 +59,9 @@ #include "flexran_agent_mac_proto.h" #endif +/* for fair round robin SCHED */ +#include "eNB_scheduler_fairRR.h" + #if defined(ENABLE_ITTI) #include "intertask_interface.h" #endif @@ -806,16 +809,25 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, copy_ulreq(module_idP, frameP, subframeP); // This schedules SRS in subframeP schedule_SRS(module_idP, frameP, subframeP); +#ifdef UE_EXPANSION + // This schedules ULSCH in subframeP (dci0) + schedule_ulsch_fairRR(module_idP, frameP, subframeP); +#else // This schedules ULSCH in subframeP (dci0) schedule_ulsch(module_idP, frameP, subframeP); +#endif // This schedules UCI_SR in subframeP schedule_SR(module_idP, frameP, subframeP); // This schedules UCI_CSI in subframeP schedule_CSI(module_idP, frameP, subframeP); +#ifdef UE_EXPANSION + // This schedules DLSCH in subframeP + schedule_ue_spec_fairRR(module_idP, frameP, subframeP, mbsfn_status); +#else // This schedules DLSCH in subframeP schedule_ue_spec(module_idP, frameP, subframeP, mbsfn_status); - +#endif // Allocate CCEs for good after scheduling is done for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++){ diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 79d8548683..933c2ffbf2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -64,7 +64,22 @@ #include "SIMULATION/TOOLS/defs.h" // for taus #include "T.h" - +#ifdef UE_EXPANSION +enum SCH_UE_PRIORITY { + SCH_PRIORITY_NONE, + SCH_DL_SI, + SCH_DL_PAGING, + SCH_DL_MSG2, + SCH_DL_MSG4, + SCH_UL_PRACH, + SCH_UL_MSG3, + SCH_DL_RETRANS, + SCH_UL_RETRANS, + SCH_DL_FIRST, + SCH_UL_FIRST, + SCH_UL_INACTIVE +}; +#endif extern uint8_t nfapi_mode; extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); @@ -582,11 +597,7 @@ generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP, cc[CC_idP].RAR_pdu.payload; mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; #ifdef UE_EXPANSION - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].ue_priority = SCH_DL_MSG2; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].nb_rb = 4; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].UE_id = -1; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].rnti = ra->rnti; - dlsch_ue_select[CC_idP].ue_num++; + set_dl_ue_select(CC_idP, SCH_DL_MSG2, 4, -1, ra->rnti); #endif } } @@ -720,11 +731,7 @@ generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP, cc[CC_idP].RAR_pdu.payload; mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; #ifdef UE_EXPANSION - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].ue_priority = SCH_DL_MSG2; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].nb_rb = 4; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].UE_id = -1; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].rnti = ra->rnti; - dlsch_ue_select[CC_idP].ue_num++; + set_dl_ue_select(CC_idP, SCH_DL_MSG2, 4, -1, ra->rnti); #endif } // PDCCH CCE allocation is feasible } // Msg2 frame/subframe condition @@ -1212,11 +1219,7 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, rrc_sdu_length); } #ifdef UE_EXPANSION - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].ue_priority = SCH_DL_MSG4; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].nb_rb = 4; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].rnti = ra->rnti; - dlsch_ue_select[CC_idP].ue_num++; + set_dl_ue_select(CC_idP, SCH_DL_MSG4, 4, UE_id, ra->rnti); #endif } // Msg4 frame/subframe } // msg4_mpdcch_repetition_count @@ -1420,11 +1423,7 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, rrc_sdu_length); } #ifdef UE_EXPANSION - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].ue_priority = SCH_DL_MSG4; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].nb_rb = 4; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].rnti = ra->rnti; - dlsch_ue_select[CC_idP].ue_num++; + set_dl_ue_select(CC_idP, SCH_DL_MSG4, 4, UE_id, ra->rnti); #endif } // CCE Allocation feasible } // msg4 frame/subframe @@ -1570,11 +1569,7 @@ check_Msg4_retransmission(module_id_t module_idP, int CC_idP, 1, // num_bf_prb_per_subband 1); // num_bf_vector #ifdef UE_EXPANSION - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].ue_priority = SCH_DL_MSG4; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].nb_rb = 4; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].rnti = ra->rnti; - dlsch_ue_select[CC_idP].ue_num++; + set_dl_ue_select(CC_idP, SCH_DL_MSG4, 4, UE_id, ra->rnti); #endif } else LOG_D(MAC, diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 72f6f46838..0d108894fb 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -413,10 +413,6 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, } -#ifdef PHY_TX_THREAD -extern volatile int16_t phy_tx_txdataF_end; -extern int oai_exit; -#endif // changes to pre-processor for eMTC //------------------------------------------------------------------------------ @@ -561,53 +557,6 @@ schedule_ue_spec(module_id_t module_idP, if (mbsfn_flag[CC_id]>0) continue; -#ifdef UE_EXPANSION - for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ - continue; - } - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ - continue; - } - UE_id = dlsch_ue_select[CC_id].list[i].UE_id; - rnti = UE_RNTI(module_idP,UE_id); - if (rnti==NOT_A_RNTI) { - LOG_E(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n",UE_id,UE_list->num_UEs); - continue; - } - - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - - switch(get_tmode(module_idP,CC_id,UE_id)){ - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } - - if (cc[CC_id].tdd_Config != NULL) { //TDD - set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); - // update UL DAI after DLSCH scheduling - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } -#else for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { continue_flag=0; // reset the flag to allow allocation for the remaining UEs @@ -672,7 +621,6 @@ schedule_ue_spec(module_id_t module_idP, CC_id, UE_id, subframeP, S_DL_NONE); continue; } -#endif #warning RK->CR This old API call has to be revisited for FAPI, or logic must be changed #if 0 /* add "fake" DCI to have CCE_allocation_infeasible work properly for next allocations */ @@ -1112,11 +1060,7 @@ schedule_ue_spec(module_id_t module_idP, header_len_dtch = 0; header_len_dtch_last = 0; // the header length of the last mac sdu // lcid has to be sorted before the actual allocation (similar struct as ue_list). -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) - for (lcid = DTCH; lcid >= DTCH; lcid--) { -#else for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { -#endif // TBD: check if the lcid is active header_len_dtch += 3; @@ -1207,15 +1151,12 @@ schedule_ue_spec(module_id_t module_idP, } mcs = eNB_UE_stats->dlsch_mcs1; -#ifdef UE_EXPANSION - nb_rb = min_rb_unit[CC_id]; -#else + if (mcs == 0) { nb_rb = 4; // don't let the TBS get too small } else { nb_rb = min_rb_unit[CC_id]; } -#endif TBS = get_TBS_DL(mcs, nb_rb); while (TBS < @@ -1320,16 +1261,6 @@ schedule_ue_spec(module_id_t module_idP, post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header } -#ifdef PHY_TX_THREAD - struct timespec time_req, time_rem; - time_req.tv_sec = 0; - time_req.tv_nsec = 10000; - while((!oai_exit)&&(phy_tx_txdataF_end == 0)){ - nanosleep(&time_req,&time_rem); - continue; - } -#endif - offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus sdu_lengths, // sdu_lcids, 255, // no drx @@ -1531,9 +1462,6 @@ schedule_ue_spec(module_id_t module_idP, eNB->pdu_index[CC_id]++; program_dlsch_acknak(module_idP,CC_id,UE_id,frameP,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); -#ifdef UE_EXPANSION - last_dlsch_ue_id[CC_id] = UE_id; -#endif } else { LOG_W(MAC,"Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", @@ -1586,9 +1514,6 @@ fill_DLSCH_dci( int N_RBG; int N_RB_DL; COMMON_channels_t *cc; -#ifdef UE_EXPANSION - int j; -#endif start_meas(&eNB->fill_DLSCH_dci); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI,VCD_FUNCTION_IN); @@ -1603,18 +1528,7 @@ fill_DLSCH_dci( N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); // UE specific DCIs -#ifdef UE_EXPANSION - for (j = 0; j < dlsch_ue_select[CC_id].ue_num; j++) { - if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG2){ - continue; - } - if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG4){ - continue; - } - UE_id = dlsch_ue_select[CC_id].list[j].UE_id; -#else for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { -#endif LOG_T(MAC,"CC_id %d, UE_id: %d => status %d\n",CC_id,UE_id,eNB_dlsch_info[module_idP][CC_id][UE_id].status); if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == S_DL_SCHEDULED) { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c new file mode 100644 index 0000000000..1b8d212cb4 --- /dev/null +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c @@ -0,0 +1,3053 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file eNB_scheduler_fairRR.h + * \brief eNB scheduler fair round robin + * \author Masayuki Harada + * \date 2018 + * \email masayuki.harada@jp.fujitsu.com + * \version 1.0 + * @ingroup _mac + */ + +#define _GNU_SOURCE +#include + +#include "assertions.h" +#include "PHY/defs.h" +#include "PHY/extern.h" + +#include "SCHED/defs.h" +#include "SCHED/extern.h" + +#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/extern.h" +#include "LAYER2/MAC/eNB_scheduler_fairRR.h" +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "UTIL/OPT/opt.h" +#include "OCG.h" +#include "OCG_extern.h" +#include "RRC/LITE/extern.h" +#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" +#include "rlc.h" + +#include "T.h" + +extern uint8_t nfapi_mode; +#ifdef PHY_TX_THREAD +extern volatile int16_t phy_tx_txdataF_end; +extern int oai_exit; +#endif +/* internal vars */ +DLSCH_UE_SELECT dlsch_ue_select[MAX_NUM_CCs]; +int last_dlsch_ue_id[MAX_NUM_CCs] = {-1}; +int last_ulsch_ue_id[MAX_NUM_CCs] = {-1}; + +#if defined(PRE_SCD_THREAD) +uint16_t pre_nb_rbs_required[2][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; +uint8_t dlsch_ue_select_tbl_in_use; +uint8_t new_dlsch_ue_select_tbl_in_use; +boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; +eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; +#endif + +#define DEBUG_eNB_SCHEDULER 1 +#define DEBUG_HEADER_PARSING 1 +//#define DEBUG_PACKET_TRACE 1 + +void set_dl_ue_select(int CC_idP, enum SCH_UE_PRIORITY ue_priority,uint16_t nb_rb, int UE_id, rnti_t rnti) { + dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].ue_priority = ue_priority; + dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].nb_rb = nb_rb; + dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].UE_id = UE_id; + dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].rnti = rnti; + dlsch_ue_select[CC_idP].ue_num++; +} + +#if defined(PRE_SCD_THREAD) +inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, uint16_t step_size){ + uint16_t nb_rb,i_TBS,tmp_TBS; + i_TBS=get_I_TBS(mcs); + for(nb_rb=step_size;nb_rb>3; + if(TBScommon_channels[CC_id].mib->message.dl_Bandwidth); + if(N_RB_DL==50) step_size=3; + if(N_RB_DL==100) step_size=4; + memset(nb_rbs_required, 0, sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; + + for (UE_id = 0; UE_id dlsch_mcs1 = cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; + + + if (UE_template.dl_buffer_total > 0) { + nb_rbs_required[CC_id][UE_id] = search_rbs_required(eNB_UE_stats->dlsch_mcs1, UE_template.dl_buffer_total, N_RB_DL, step_size); + } + } +} +#endif + +int cc_id_end(uint8_t *cc_id_flag ) +{ + int end_flag = 1; + for (int CC_id=0;CC_idcommon_channels; + UE_list_t *UE_list = &eNB->UE_list; + UE_sched_ctrl *ue_sched_ctl; + uint8_t CC_id; + int UE_id; + unsigned char round = 0; + unsigned char harq_pid = 0; + rnti_t rnti; + uint16_t i; + unsigned char aggregation; + int format_flag; + nfapi_dl_config_request_body_t *DL_req; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + uint16_t dlsch_ue_max_num[MAX_NUM_CCs] = {0}; + uint16_t saved_dlsch_dci[MAX_NUM_CCs] = {0}; + uint8_t end_flag[MAX_NUM_CCs] = {0}; + + // Initialization + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + dlsch_ue_max_num[CC_id] = (uint16_t)RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id]; + + // save origin DL PDU number + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + saved_dlsch_dci[CC_id] = DL_req->number_pdu; + } + + // Insert DLSCH(retransmission) UE into selected UE list + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + if (mbsfn_flag[CC_id]>0) { + continue; + } + + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + if (UE_list->active[UE_id] == FALSE) { + continue; + } + + rnti = UE_RNTI(module_idP, UE_id); + if (rnti == NOT_A_RNTI) { + continue; + } + + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + continue; + } + + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; +#if 0 + if (ue_sched_ctl->ul_out_of_sync == 1) { + continue; + } +#endif + 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 + if(UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] == 0){ + continue; + } + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + break; + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; + } + format_flag = 1; + if (!CCE_allocation_infeasible(module_idP, + CC_id, + format_flag, + subframeP, + aggregation, + rnti)) { + dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; + DL_req->number_pdu++; + + nb_rbs_required[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + // Insert DLSCH(retransmission) UE into selected UE list + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_RETRANS; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; + dlsch_ue_select[CC_id].ue_num++; + if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { + end_flag[CC_id] = 1; + break; + } + } else { + if (cc[CC_id].tdd_Config != NULL) { //TDD + set_ue_dai (subframeP, + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); + // update UL DAI after DLSCH scheduling + set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); + } + + add_ue_dlsch_info(module_idP, + CC_id, + UE_id, + subframeP, + S_DL_NONE); + end_flag[CC_id] = 1; + break; + } + } + } + } + if(cc_id_end(end_flag) == 1){ + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + DL_req->number_pdu = saved_dlsch_dci[CC_id]; + } + return; + } + + // Insert DLSCH(first transmission) UE into selected UE list (UE_id > last_dlsch_ue_id[CC_id]) + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + if (mbsfn_flag[CC_id]>0) { + continue; + } + + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + for (UE_id = (last_dlsch_ue_id[CC_id]+1); UE_id active[UE_id] == FALSE) { + continue; + } + + rnti = UE_RNTI(module_idP,UE_id); + if (rnti == NOT_A_RNTI) + continue; + + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + continue; + } + + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; +#if 0 + if (ue_sched_ctl->ul_out_of_sync == 1) { + continue; + } +#endif + for(i = 0;iround[CC_id][harq_pid]; + if (round == 8) { + if (nb_rbs_required[CC_id][UE_id] == 0) { + continue; + } + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + break; + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; + } + format_flag = 1; + if (!CCE_allocation_infeasible(module_idP, + CC_id, + format_flag, + subframeP, + aggregation, + rnti)) { + dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; + DL_req->number_pdu++; + + // Insert DLSCH(first transmission) UE into selected selected UE list + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; + dlsch_ue_select[CC_id].ue_num++; + + if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { + end_flag[CC_id] = 1; + break; + } + }else { + if (cc[CC_id].tdd_Config != NULL) { //TDD + set_ue_dai (subframeP, + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); + // update UL DAI after DLSCH scheduling + set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); + } + add_ue_dlsch_info(module_idP, + CC_id, + UE_id, + subframeP, + S_DL_NONE); + end_flag[CC_id] = 1; + break; + } + } + } + } + if(cc_id_end(end_flag) == 1){ + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + DL_req->number_pdu = saved_dlsch_dci[CC_id]; + } + return; + } + + // Insert DLSCH(first transmission) UE into selected UE list (UE_id <= last_dlsch_ue_id[CC_id]) + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + if (mbsfn_flag[CC_id]>0) { + continue; + } + + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + for (UE_id = 0; UE_id <= last_dlsch_ue_id[CC_id]; UE_id++) { + if(end_flag[CC_id] == 1){ + break; + } + + if (UE_list->active[UE_id] == FALSE) { + continue; + } + + rnti = UE_RNTI(module_idP,UE_id); + if (rnti == NOT_A_RNTI) + continue; + + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + continue; + } + + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; +#if 0 + if (ue_sched_ctl->ul_out_of_sync == 1) { + continue; + } +#endif + for(i = 0;iround[CC_id][harq_pid]; + if (round == 8) { + if (nb_rbs_required[CC_id][UE_id] == 0) { + continue; + } + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + break; + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; + } + format_flag = 1; + if (!CCE_allocation_infeasible(module_idP, + CC_id, + format_flag, + subframeP, + aggregation, + rnti)) { + dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; + DL_req->number_pdu++; + + // Insert DLSCH(first transmission) UE into selected selected UE list + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; + dlsch_ue_select[CC_id].ue_num++; + + if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { + end_flag[CC_id] = 1; + break; + } + } else { + if (cc[CC_id].tdd_Config != NULL) { //TDD + set_ue_dai (subframeP, + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); + // update UL DAI after DLSCH scheduling + set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); + } + add_ue_dlsch_info(module_idP, + CC_id, + UE_id, + subframeP, + S_DL_NONE); + end_flag[CC_id] = 1; + break; + } + } + } + } + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + DL_req->number_pdu = saved_dlsch_dci[CC_id]; + } + return; +} + + + +// This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done +void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, + frame_t frameP, + sub_frame_t subframeP, + int N_RBG[MAX_NUM_CCs], + int *mbsfn_flag) +{ + + unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX],harq_pid=0,Round=0; + uint16_t temp_total_rbs_count; + unsigned char temp_total_ue_count; + unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; + int UE_id, i; + uint16_t j; + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; +// uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t average_rbs_per_user[MAX_NUM_CCs] = {0}; + rnti_t rnti; + int min_rb_unit[MAX_NUM_CCs]; +// uint16_t r1=0; + uint8_t CC_id; + UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; + + int N_RB_DL; + int transmission_mode = 0; + UE_sched_ctrl *ue_sched_ctl; + // int rrc_status = RRC_IDLE; + COMMON_channels_t *cc; + +#ifdef TM5 + int harq_pid1 = 0; + int round1 = 0, round2 = 0; + int UE_id2; + uint16_t i1, i2, i3; + rnti_t rnti1, rnti2; + LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; + LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; + UE_sched_ctrl *ue_sched_ctl1, *ue_sched_ctl2; +#endif + + for (CC_id=0; CC_id 0) // If this CC is allocated for MBSFN skip it here + continue; + + + + min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); + + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) + continue; + + UE_id = i; + // Initialize scheduling information for all active UEs + + + + dlsch_scheduler_pre_processor_reset(Mod_id, + UE_id, + CC_id, + frameP, + subframeP, + N_RBG[CC_id], + nb_rbs_required, + nb_rbs_required_remaining, + rballoc_sub, + MIMO_mode_indicator); + + } + } + +#if (!defined(PRE_SCD_THREAD)) + // Store the DLSCH buffer for each logical channel + store_dlsch_buffer(Mod_id, frameP, subframeP); + + + + // Calculate the number of RBs required by each UE on the basis of logical channel's buffer + assign_rbs_required(Mod_id, frameP, subframeP, nb_rbs_required, + min_rb_unit); +#else + memcpy(nb_rbs_required, pre_nb_rbs_required[dlsch_ue_select_tbl_in_use] , sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); +#endif + + dlsch_scheduler_pre_ue_select_fairRR(Mod_id,frameP,subframeP, mbsfn_flag,nb_rbs_required,dlsch_ue_select); + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + average_rbs_per_user[CC_id] = 0; + cc = &RC.mac[Mod_id]->common_channels[CC_id]; + // Get total available RBS count and total UE count + N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + temp_total_rbs_count = RC.mac[Mod_id]->eNB_stats[CC_id].available_prbs; + temp_total_ue_count = dlsch_ue_select[CC_id].ue_num; + + for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ + temp_total_ue_count--; + continue; + } + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ + temp_total_ue_count--; + continue; + } + UE_id = dlsch_ue_select[CC_id].list[i].UE_id; + nb_rbs_required[CC_id][UE_id] = dlsch_ue_select[CC_id].list[i].nb_rb; + + average_rbs_per_user[CC_id] = (uint16_t)round((double)temp_total_rbs_count/(double)temp_total_ue_count); + if( average_rbs_per_user[CC_id] < min_rb_unit[CC_id] ){ + temp_total_ue_count--; + dlsch_ue_select[CC_id].ue_num--; + i--; + continue; + } + + rnti = dlsch_ue_select[CC_id].list[i].rnti; + + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + 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) { + if (mac_eNB_get_rrc_status(Mod_id, rnti) < RRC_RECONFIGURED || Round != 8) { // FIXME + nb_rbs_required_remaining[CC_id][UE_id] = dlsch_ue_select[CC_id].list[i].nb_rb; + } else { + nb_rbs_required_remaining[CC_id][UE_id] = cmin(average_rbs_per_user[CC_id], dlsch_ue_select[CC_id].list[i].nb_rb); + } + + transmission_mode = get_tmode(Mod_id,CC_id,UE_id); + + LOG_T(MAC,"calling dlsch_scheduler_pre_processor_allocate .. \n "); + dlsch_scheduler_pre_processor_allocate (Mod_id, + UE_id, + CC_id, + N_RBG[CC_id], + transmission_mode, + min_rb_unit[CC_id], + N_RB_DL, + nb_rbs_required, + nb_rbs_required_remaining, + rballoc_sub, + MIMO_mode_indicator); + temp_total_rbs_count -= ue_sched_ctl->pre_nb_available_rbs[CC_id]; + temp_total_ue_count--; + + if (ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) { + dlsch_ue_select[CC_id].ue_num = i; + break; + } + + if (temp_total_rbs_count == 0) { + dlsch_ue_select[CC_id].ue_num = i+1; + break; + } + LOG_D(MAC,"DLSCH UE Select: frame %d subframe %d pre_nb_available_rbs %d(i %d UE_id %d nb_rbs_required %d nb_rbs_required_remaining %d average_rbs_per_user %d (temp_total rbs_count %d ue_num %d) available_prbs %d)\n", + frameP,subframeP,ue_sched_ctl->pre_nb_available_rbs[CC_id],i,UE_id,nb_rbs_required[CC_id][UE_id],nb_rbs_required_remaining[CC_id][UE_id], + average_rbs_per_user[CC_id],temp_total_rbs_count,temp_total_ue_count,RC.mac[Mod_id]->eNB_stats[CC_id].available_prbs); +#ifdef TM5 + // TODO: data channel TM5: to be re-visited +#endif + } + } + +#ifdef TM5 + + // This has to be revisited!!!! + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + i1 = 0; + i2 = 0; + i3 = 0; + + for (j = 0; j < N_RBG[CC_id]; j++) { + if (MIMO_mode_indicator[CC_id][j] == 2) { + i1 = i1 + 1; + } else if (MIMO_mode_indicator[CC_id][j] == 1) { + i2 = i2 + 1; + } else if (MIMO_mode_indicator[CC_id][j] == 0) { + i3 = i3 + 1; + } + } + + if ((i1 < N_RBG[CC_id]) && (i2 > 0) && (i3 == 0)) { + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]-> + check_for_SUMIMO_transmissions + 1; + } + + if (i3 == N_RBG[CC_id] && i1 == 0 && i2 == 0) { + PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions + + 1; + } + + if((i1 < N_RBG[CC_id]) && (i3 > 0)) { + PHY_vars_eNB_g[Mod_id][CC_id]-> + check_for_MUMIMO_transmissions + 1; + } + + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions + + 1; + + } + +#endif + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ + continue; + } + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ + continue; + } + UE_id = dlsch_ue_select[CC_id].list[i].UE_id; + ue_sched_ctl = &RC.mac[Mod_id]->UE_list.UE_sched_ctrl[UE_id]; + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; + + if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0) { + LOG_D(MAC, + "******************DL Scheduling Information for UE%d ************************\n", + UE_id); + LOG_D(MAC, "dl power offset UE%d = %d \n", UE_id, + ue_sched_ctl->dl_pow_off[CC_id]); + LOG_D(MAC, + "***********RB Alloc for every subband for UE%d ***********\n", + UE_id); + + for (j = 0; j < N_RBG[CC_id]; j++) { + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; + LOG_D(MAC, "RB Alloc for UE%d and Subband%d = %d\n", + UE_id, j, + ue_sched_ctl->rballoc_sub_UE[CC_id][j]); + } + + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; + LOG_D(MAC, "Total RBs allocated for UE%d = %d\n", UE_id, + ue_sched_ctl->pre_nb_available_rbs[CC_id]); + } + } + } +} + + +//------------------------------------------------------------------------------ +void +schedule_ue_spec_fairRR(module_id_t module_idP, + frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) +//------------------------------------------------------------------------------ +{ + + + uint8_t CC_id; + int UE_id; + unsigned char aggregation; + mac_rlc_status_resp_t rlc_status; + unsigned char header_len_dcch = 0, header_len_dcch_tmp = 0; + unsigned char header_len_dtch = 0, header_len_dtch_tmp = + 0, header_len_dtch_last = 0; + unsigned char ta_len = 0; + unsigned char sdu_lcids[NB_RB_MAX], lcid, offset, num_sdus = 0; + uint16_t nb_rb, nb_rb_temp, nb_available_rb; + uint16_t TBS, j, sdu_lengths[NB_RB_MAX], rnti, padding = + 0, post_padding = 0; + unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; + unsigned char round = 0; + unsigned char harq_pid = 0; + eNB_UE_STATS *eNB_UE_stats = NULL; + uint16_t sdu_length_total = 0; + + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = eNB->common_channels; + UE_list_t *UE_list = &eNB->UE_list; + int continue_flag = 0; + int32_t normalized_rx_power, target_rx_power; + int32_t tpc = 1; + static int32_t tpc_accumulated = 0; + UE_sched_ctrl *ue_sched_ctl; + int mcs; + int i; + int min_rb_unit[MAX_NUM_CCs]; + int N_RB_DL[MAX_NUM_CCs]; + int total_nb_available_rb[MAX_NUM_CCs]; + int N_RBG[MAX_NUM_CCs]; + nfapi_dl_config_request_body_t *dl_req; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + int tdd_sfa; + int ta_update; + +#if 0 + if (UE_list->head == -1) { + return; + } +#endif + + start_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); + + + // for TDD: check that we have to act here, otherwise return + if (cc[0].tdd_Config) { + tdd_sfa = cc[0].tdd_Config->subframeAssignment; + switch (subframeP) { + case 0: + // always continue + break; + case 1: + return; + break; + case 2: + return; + break; + case 3: + if ((tdd_sfa != 2) && (tdd_sfa != 5)) + return; + break; + case 4: + if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) + && (tdd_sfa != 5)) + return; + break; + case 5: + break; + case 6: + case 7: + if ((tdd_sfa != 3)&& (tdd_sfa != 4) && (tdd_sfa != 5)) + return; + break; + case 8: + if ((tdd_sfa != 2) && (tdd_sfa != 3) && (tdd_sfa != 4) + && (tdd_sfa != 5)) + return; + break; + case 9: + if (tdd_sfa == 0) + return; + break; + + } + } + + //weight = get_ue_weight(module_idP,UE_id); + aggregation = 2; + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth); + min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id); + // get number of PRBs less those used by common channels + total_nb_available_rb[CC_id] = N_RB_DL[CC_id]; + for (i = 0; i < N_RB_DL[CC_id]; i++) + if (cc[CC_id].vrb_map[i] != 0) + total_nb_available_rb[CC_id]--; + + N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth); + + // store the global enb stats: + eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; + eNB->eNB_stats[CC_id].available_prbs = + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].total_available_prbs += + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].dlsch_bytes_tx = 0; + eNB->eNB_stats[CC_id].dlsch_pdus_tx = 0; + } + + /// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band) + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_IN); + start_meas(&eNB->schedule_dlsch_preprocessor); + dlsch_scheduler_pre_processor_fairRR(module_idP, + frameP, + subframeP, + N_RBG, + mbsfn_flag); + stop_meas(&eNB->schedule_dlsch_preprocessor); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); + + + for (CC_id=0; CC_idDL_req[CC_id].dl_config_request_body; + + if (mbsfn_flag[CC_id]>0) + continue; + + for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ + continue; + } + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ + continue; + } + UE_id = dlsch_ue_select[CC_id].list[i].UE_id; + rnti = UE_RNTI(module_idP,UE_id); + if (rnti==NOT_A_RNTI) { + LOG_E(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n",UE_id,UE_list->num_UEs); + continue; + } + + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + switch(get_tmode(module_idP,CC_id,UE_id)){ + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + break; + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; + } + + if (cc[CC_id].tdd_Config != NULL) { //TDD + set_ue_dai (subframeP, + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); + // update UL DAI after DLSCH scheduling + set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); + } +#warning RK->CR This old API call has to be revisited for FAPI, or logic must be changed +#if 0 + /* add "fake" DCI to have CCE_allocation_infeasible work properly for next allocations */ + /* if we don't add it, next allocations may succeed but overall allocations may fail */ + /* will be removed at the end of this function */ + add_ue_spec_dci(&eNB->common_channels[CC_id].DCI_pdu, &(char[]) { + 0}, rnti, 1, aggregation, 1, format1, 0); +#endif + + nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; + + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + + round = ue_sched_ctl->round[CC_id][harq_pid]; + + UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = + mac_eNB_get_rrc_status(module_idP, rnti); + UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; + UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; + + + if (UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status < + RRC_CONNECTED) + continue; + + sdu_length_total = 0; + num_sdus = 0; + + /* + DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)), + eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); + */ + if (nfapi_mode) { + eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + } + else { + eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + } + eNB_UE_stats->dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; //cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); + + + // store stats + //UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->dl_cqi; + + // initializing the rb allocation indicator for each UE + for (j = 0; j < N_RBG[CC_id]; j++) { + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] + = 0; + } + + LOG_D(MAC, + "[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", + module_idP, frameP, UE_id, CC_id, rnti, harq_pid, round, + nb_available_rb, ue_sched_ctl->dl_cqi[CC_id], + eNB_UE_stats->dlsch_mcs1, + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); + + + + /* process retransmission */ + + if (round != 8) { + + // get freq_allocation + nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + TBS = + get_TBS_DL(UE_list-> + UE_template[CC_id][UE_id].oldmcs1[harq_pid], + nb_rb); + + if (nb_rb <= nb_available_rb) { + if (cc[CC_id].tdd_Config != NULL) { + 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); + LOG_D(MAC, + "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", + CC_id, subframeP, UE_id, + UE_list->UE_template[CC_id][UE_id].DAI); + } + + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id]. + rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; + + while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) { + if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == + 1) { + if (UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j]) + printf + ("WARN: rballoc_subband not free for retrans?\n"); + UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if ((j == N_RBG[CC_id] - 1) && + ((N_RB_DL[CC_id] == 25) || + (N_RB_DL[CC_id] == 50))) { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id] + + 1; + } else { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id]; + } + } + + j = j + 1; + } + } + + nb_available_rb -= nb_rb; + /* + eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; + eNB->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; + + for(j=0; jmu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + } + */ + + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + default: + LOG_D(MAC,"retransmission DL_REQ: rnti:%x\n",rnti); + + 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_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + dci_format = NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level = + get_aggregation(get_bw_index + (module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = + rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.new_data_indicator_1 = + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = + UE_list->UE_template[CC_id][UE_id]. + oldmcs1[harq_pid]; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.redundancy_version_1 = + round & 3; + + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.downlink_assignment_index = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + LOG_D(MAC, + "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n", + module_idP, CC_id, harq_pid, round, + (UE_list->UE_template[CC_id][UE_id].DAI - + 1), + UE_list-> + UE_template[CC_id][UE_id].oldmcs1 + [harq_pid]); + } else { + LOG_D(MAC, + "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n", + module_idP, CC_id, harq_pid, round, + UE_list-> + UE_template[CC_id][UE_id].oldmcs1 + [harq_pid]); + + } + if (!CCE_allocation_infeasible + (module_idP, CC_id, 1, subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, rnti)) { + 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; + + fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1 + /* retransmission, no pdu_index */ + , rnti, 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]), round & 3, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + + LOG_D(MAC, + "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n", + eNB->pdu_index[CC_id], round); + + program_dlsch_acknak(module_idP, CC_id, UE_id, + frameP, subframeP, + dl_config_pdu-> + dci_dl_pdu.dci_dl_pdu_rel8. + cce_idx); + // No TX request for retransmission (check if null request for FAPI) + } else { + LOG_W(MAC, + "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d\%x, infeasible CCE allocation\n", + frameP, subframeP, UE_id, rnti); + } + } + + + add_ue_dlsch_info(module_idP, + CC_id, UE_id, subframeP, + S_DL_SCHEDULED); + + //eNB_UE_stats->dlsch_trials[round]++; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_retransmission += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = + nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id]. + total_rbs_used_retx += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = + eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = + eNB_UE_stats->dlsch_mcs1; + } else { + LOG_D(MAC, + "[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", + module_idP, frameP, CC_id, UE_id); + } + } else { /* This is a potentially new SDU opportunity */ + + rlc_status.bytes_in_buffer = 0; + // Now check RLC information to compute number of required RBs + // get maximum TBS size for RLC request + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); + // check first for RLC data on DCCH + // add the length for all the control elements (timing adv, drx, etc) : header + payload + + if (ue_sched_ctl->ta_timer == 0) { + ta_update = ue_sched_ctl->ta_update; + /* if we send TA then set timer to not send it for a while */ + if (ta_update != 31) + ue_sched_ctl->ta_timer = 20; + /* reset ta_update */ + ue_sched_ctl->ta_update = 31; + } else { + ta_update = 31; + } + + ta_len = (ta_update != 31) ? 2 : 0; + + header_len_dcch = 2; // 2 bytes DCCH SDU subheader + + if (TBS - ta_len - header_len_dcch > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, (TBS - ta_len - header_len_dcch)); // transport block set size + + sdu_lengths[0] = 0; + + if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit + LOG_D(MAC, + "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, subframeP, CC_id, + TBS - header_len_dcch); + sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used + (char *) + &dlsch_buffer + [0]); + pthread_mutex_lock(&rrc_release_freelist); + if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)){ + uint16_t release_total = 0; + for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ + if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0){ + release_total++; + }else{ + continue; + } + + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1){ + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ + for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + rrc_release_info.RRC_release_ctrl[release_num].flag = 3; + LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 1->3\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); + break; + } + } + } + } + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2){ + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ + for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + rrc_release_info.RRC_release_ctrl[release_num].flag = 4; + LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 2->4\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); + break; + } + } + } + } + if(release_total >= rrc_release_info.num_UEs) + break; + } + } + pthread_mutex_unlock(&rrc_release_freelist); + + RA_t *ra = &eNB->common_channels[CC_id].ra[0]; + for (uint8_t ra_ii = 0; ra_ii < NB_RA_PROC_MAX; ra_ii++) { + if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)){ + for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ + if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]){ + ra[ra_ii].crnti_harq_pid = harq_pid; + ra[ra_ii].state = MSGCRNTI_ACK; + break; + } + } + } + } + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), + T_INT(sdu_lengths[0])); + LOG_D(MAC, + "[eNB %d][DCCH] CC_id %d frame %d subframe %d UE_id %d/%x Got %d bytes bytes_in_buffer %d from release_num %d\n", + module_idP, CC_id, frameP, subframeP, UE_id, rnti, sdu_lengths[0],rlc_status.bytes_in_buffer,rrc_release_info.num_UEs); + + sdu_length_total = sdu_lengths[0]; + sdu_lcids[0] = DCCH; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_pdu_tx[DCCH] += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] + += sdu_lengths[0]; + num_sdus = 1; +#ifdef DEBUG_eNB_SCHEDULER + LOG_T(MAC, + "[eNB %d][DCCH] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[0]); + + for (j = 0; j < sdu_lengths[0]; j++) { + LOG_T(MAC, "%x ", dlsch_buffer[j]); + } + + LOG_T(MAC, "\n"); +#endif + } else { + header_len_dcch = 0; + sdu_length_total = 0; + } + } + // check for DCCH1 and update header information (assume 2 byte sub-header) + if (TBS - ta_len - header_len_dcch - sdu_length_total > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, (TBS - ta_len - header_len_dcch - sdu_length_total)); // transport block set size less allocations for timing advance and + // DCCH SDU + sdu_lengths[num_sdus] = 0; + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, + "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, CC_id, + TBS - header_len_dcch - sdu_length_total); + sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, TBS, //not used + (char *) + &dlsch_buffer + [sdu_length_total]); + + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_INT(DCCH + 1), T_INT(sdu_lengths[num_sdus])); + + sdu_lcids[num_sdus] = DCCH1; + sdu_length_total += sdu_lengths[num_sdus]; + header_len_dcch += 2; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_pdu_tx[DCCH1] += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] + += sdu_lengths[num_sdus]; + num_sdus++; +#ifdef DEBUG_eNB_SCHEDULER + LOG_T(MAC, + "[eNB %d][DCCH1] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[num_sdus]); + + for (j = 0; j < sdu_lengths[num_sdus]; j++) { + LOG_T(MAC, "%x ", dlsch_buffer[j]); + } + + LOG_T(MAC, "\n"); +#endif + + } + } + // assume the max dtch header size, and adjust it later + header_len_dtch = 0; + header_len_dtch_last = 0; // the header length of the last mac sdu + // lcid has to be sorted before the actual allocation (similar struct as ue_list). + /* TODO limited lcid for performance */ + for (lcid = DTCH; lcid >= DTCH; lcid--) { + // TBD: check if the lcid is active + + header_len_dtch += 3; + header_len_dtch_last = 3; + LOG_D(MAC, + "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", + module_idP, frameP, lcid, TBS, + TBS - ta_len - header_len_dcch - + sdu_length_total - header_len_dtch); + + if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - + header_len_dcch - + sdu_length_total - + header_len_dtch); + + + if (rlc_status.bytes_in_buffer > 0) { + + LOG_D(MAC, + "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", + module_idP, frameP, + TBS - header_len_dcch - + sdu_length_total - header_len_dtch, lcid, + header_len_dtch); + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, TBS, //not used + (char + *) + &dlsch_buffer + [sdu_length_total]); + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_INT(lcid), T_INT(sdu_lengths[num_sdus])); + + LOG_D(MAC, + "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, sdu_lengths[num_sdus], lcid); + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] + += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx + [lcid] += sdu_lengths[num_sdus]; + if (sdu_lengths[num_sdus] < 128) { + header_len_dtch--; + header_len_dtch_last--; + } + num_sdus++; + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + } // no data for this LCID + else { + header_len_dtch -= 3; + } + } // no TBS left + else { + header_len_dtch -= 3; + break; + } + } + if (header_len_dtch == 0) + header_len_dtch_last = 0; + // there is at least one SDU + // if (num_sdus > 0 ){ + if ((sdu_length_total + header_len_dcch + + header_len_dtch) > 0) { + + // Now compute number of required RBs for total sdu length + // Assume RAH format 2 + // adjust header lengths + header_len_dcch_tmp = header_len_dcch; + header_len_dtch_tmp = header_len_dtch; + if (header_len_dtch == 0) { + header_len_dcch = (header_len_dcch > 0) ? 1 : 0; //header_len_dcch; // remove length field + } else { + header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU + header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU + } + + mcs = eNB_UE_stats->dlsch_mcs1; + nb_rb = min_rb_unit[CC_id]; + TBS = get_TBS_DL(mcs, nb_rb); + + while (TBS < + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) { + nb_rb += min_rb_unit[CC_id]; // + + if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs + // (can happen if N_RB_DL is odd) + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, + nb_available_rb); + nb_rb = nb_available_rb; + break; + } + + TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb); + } + + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id]. + rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; + + while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) { + if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == + 1) { + UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if ((j == N_RBG[CC_id] - 1) && + ((N_RB_DL[CC_id] == 25) || + (N_RB_DL[CC_id] == 50))) { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id] + + 1; + } else { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id]; + } + } + + j = j + 1; + } + } + + // decrease mcs until TBS falls below required length + while ((TBS > + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) && (mcs > 0)) { + mcs--; + TBS = get_TBS_DL(mcs, nb_rb); + } + + // if we have decreased too much or we don't have enough RBs, increase MCS + while ((TBS < + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) + && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) + && (mcs < 28)) + || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) + && (mcs <= 15)))) { + mcs++; + TBS = get_TBS_DL(mcs, nb_rb); + } + + LOG_D(MAC, + "dlsch_mcs before and after the rate matching = (%d, %d)\n", + eNB_UE_stats->dlsch_mcs1, mcs); + +#ifdef DEBUG_eNB_SCHEDULER + LOG_D(MAC, + "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", + module_idP, CC_id, mcs, TBS, nb_rb); + // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", + // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); +#endif + + if ((TBS - header_len_dcch - header_len_dtch - + sdu_length_total - ta_len) <= 2) { + padding = + (TBS - header_len_dcch - header_len_dtch - + sdu_length_total - ta_len); + post_padding = 0; + } else { + padding = 0; + + // adjust the header len + if (header_len_dtch == 0) { + header_len_dcch = header_len_dcch_tmp; + } else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) + header_len_dtch = header_len_dtch_tmp; + } + + post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header + } + +#ifdef PHY_TX_THREAD + struct timespec time_req, time_rem; + time_req.tv_sec = 0; + time_req.tv_nsec = 10000; + while((!oai_exit)&&(phy_tx_txdataF_end == 0)){ + nanosleep(&time_req,&time_rem); + continue; + } +#endif + + offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus + sdu_lengths, // + sdu_lcids, 255, // no drx + ta_update, // timing advance + NULL, // contention res id + padding, post_padding); + + //#ifdef DEBUG_eNB_SCHEDULER + if (ta_update != 31) { + LOG_D(MAC, + "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", + module_idP, frameP, UE_id, CC_id, + sdu_length_total, num_sdus, sdu_lengths[0], + sdu_lcids[0], offset, ta_update, padding, + post_padding, mcs, TBS, nb_rb, + header_len_dcch, header_len_dtch); + } + //#endif +#ifdef DEBUG_eNB_SCHEDULER + LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n"); + + for (i = 0; i < 16; i++) { + LOG_T(MAC, "%x.", dlsch_buffer[i]); + } + + LOG_T(MAC, "\n"); +#endif + + // cycle through SDUs and place in dlsch_buffer + memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset],dlsch_buffer,sdu_length_total); + // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); + + // fill remainder of DLSCH with random data + for (j=0; j<(TBS-sdu_length_total-offset); j++) { + UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff); + } + + if (opt_enabled == 1) { + trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], + TBS, module_idP, 3, UE_RNTI(module_idP,UE_id), + eNB->frame, eNB->subframe,0,0); + LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", + module_idP, CC_id, frameP, UE_RNTI(module_idP,UE_id), TBS); + } + + T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), + T_INT(harq_pid), T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); + + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; + + add_ue_dlsch_info(module_idP, + CC_id, + UE_id, + subframeP, + S_DL_SCHEDULED); + // store stats + eNB->eNB_stats[CC_id].dlsch_bytes_tx+=sdu_length_total; + eNB->eNB_stats[CC_id].dlsch_pdus_tx+=1; + + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2=mcs; + UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; + + UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes= TBS- sdu_length_total; + UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes+= sdu_length_total; + UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes+= TBS; + UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus+=1; + + 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,subframeP); + } + + // do PUCCH power control + // this is the normalized RX power + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; + + /* TODO: fix how we deal with power, unit is not dBm, it's special from nfapi */ + normalized_rx_power = ue_sched_ctl->pucch1_snr[CC_id]; + target_rx_power = 208; + + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; + if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case + ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around + if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { + ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; + + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP; + + if (normalized_rx_power>(target_rx_power+4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power<(target_rx_power-4)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + + LOG_D(MAC,"[eNB %d] DLSCH 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, + tpc_accumulated,normalized_rx_power,target_rx_power); + + } // Po_PUCCH has been updated + else { + tpc = 1; //0 + } // time to do TPC update + else { + tpc = 1; //0 + } + + 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_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),ue_sched_ctl->dl_cqi[CC_id],format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; + //deactivate second codeword + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1; + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", + module_idP,CC_id,harq_pid, + (UE_list->UE_template[CC_id][UE_id].DAI-1), + mcs); + } else { + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", + module_idP,CC_id,harq_pid,mcs); + + } + LOG_D(MAC,"Checking feasibility pdu %d (new sdu)\n",dl_req->number_pdu); + if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,rnti)) { + + + ue_sched_ctl->round[CC_id][harq_pid] = 0; + 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; + // Toggle NDI for next time + LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", + CC_id, frameP,subframeP,UE_id, + rnti,harq_pid,UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); + + UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]=1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated is NULL\n"); + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated!=NULL,"physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); + + fill_nfapi_dlsch_config(eNB,dl_req, + TBS, + eNB->pdu_index[CC_id], + rnti, + 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(mcs), + 0, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, + 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, + (frameP*10)+subframeP, + TBS, + eNB->pdu_index[CC_id], + eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]); + + LOG_D(MAC,"Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n",eNB->pdu_index[CC_id]); + + eNB->pdu_index[CC_id]++; + program_dlsch_acknak(module_idP,CC_id,UE_id,frameP,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); + last_dlsch_ue_id[CC_id] = UE_id; + } + else { + LOG_W(MAC,"Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", + frameP,subframeP,UE_id,rnti); + } + } else { // There is no data from RLC or MAC header, so don't schedule + + } + } + + if (cc[CC_id].tdd_Config != NULL){ // TDD + set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); + } + + } // UE_id loop + } // CC_id loop + + + fill_DLSCH_dci_fairRR(module_idP,frameP,subframeP,mbsfn_flag); + stop_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_OUT); + + +} + +//------------------------------------------------------------------------------ +void +fill_DLSCH_dci_fairRR( + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + int* mbsfn_flagP) +//------------------------------------------------------------------------------ +{ + + // loop over all allocated UEs and compute frequency allocations for PDSCH + int UE_id = -1; + uint8_t /* first_rb, */ nb_rb=3; + rnti_t rnti; + //unsigned char *vrb_map; + uint8_t rballoc_sub[25]; + //uint8_t number_of_subbands=13; + + //unsigned char round; + unsigned char harq_pid; + int i; + int CC_id; + eNB_MAC_INST *eNB =RC.mac[module_idP]; + UE_list_t *UE_list = &eNB->UE_list; + int N_RBG; + int N_RB_DL; + COMMON_channels_t *cc; + int j; + start_meas(&eNB->fill_DLSCH_dci); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI,VCD_FUNCTION_IN); + + for (CC_id=0; CC_id0) + continue; + + cc = &eNB->common_channels[CC_id]; + N_RBG = to_rbg(cc->mib->message.dl_Bandwidth); + N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + + // UE specific DCIs + for (j = 0; j < dlsch_ue_select[CC_id].ue_num; j++) { + if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG2){ + continue; + } + if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG4){ + continue; + } + UE_id = dlsch_ue_select[CC_id].list[j].UE_id; + LOG_T(MAC,"CC_id %d, UE_id: %d => status %d\n",CC_id,UE_id,eNB_dlsch_info[module_idP][CC_id][UE_id].status); + + if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == S_DL_SCHEDULED) { + + // clear scheduling flag + eNB_dlsch_info[module_idP][CC_id][UE_id].status = S_DL_WAITING; + rnti = UE_RNTI(module_idP,UE_id); + 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]; + + + + /// Synchronizing rballoc with rballoc_sub + for(i=0; iUE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; + } + + nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; + nfapi_dl_config_request_pdu_t* dl_config_pdu; + + for (i=0;ipdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& + (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti) && + (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1)) { + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; + } + else if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE)&& + (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti) && + (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type==0)) { + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); + } + } + } + } + } + + stop_meas(&eNB->fill_DLSCH_dci); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_OUT); +} + + + +void ulsch_scheduler_pre_ue_select_fairRR( + 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]; + COMMON_channels_t *cc; + int CC_id,UE_id; + int ret; + uint16_t i; + uint8_t ue_first_num[MAX_NUM_CCs]; + uint8_t first_ue_total[MAX_NUM_CCs][20]; + uint8_t first_ue_id[MAX_NUM_CCs][20]; + uint8_t ul_inactivity_num[MAX_NUM_CCs]; + uint8_t ul_inactivity_id[MAX_NUM_CCs][20]; +// LTE_DL_FRAME_PARMS *frame_parms; + uint8_t ulsch_ue_max_num[MAX_NUM_CCs]; + uint16_t saved_ulsch_dci[MAX_NUM_CCs]; + rnti_t rnti; + UE_sched_ctrl *UE_sched_ctl = NULL; + uint8_t cc_id_flag[MAX_NUM_CCs]; + uint8_t harq_pid = 0,round = 0; + UE_list_t *UE_list= &eNB->UE_list; + + + uint8_t aggregation = 2; + int format_flag; + nfapi_hi_dci0_request_body_t *HI_DCI0_req; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; + + + 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][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]; + + cc_id_flag[CC_id] = 0; + ue_first_num[CC_id] = 0; + ul_inactivity_num[CC_id] = 0; + + } + // UE round >0 + for ( UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++ ) { + if (UE_list->active[UE_id] == FALSE) + continue; + + rnti = UE_RNTI(module_idP,UE_id); + if (rnti ==NOT_A_RNTI) + continue; + + CC_id = UE_PCCID(module_idP,UE_id); + if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) + continue; + + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) + continue; + + // UL DCI + 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]; + ret = cc_id_end(cc_id_flag); + if ( ret == 0 ) { + continue; + } + if ( ret == 1 ) { + return; + } + } + + cc = &eNB->common_channels[CC_id]; + //harq_pid + harq_pid = subframe2harqpid(cc,(frameP+(sched_subframePUE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]; + + if ( round > 0 ) { + 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) { + cc_id_flag[CC_id] = 1; + continue; + } else { + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_RETRANS; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = eNB->UE_list.UE_template[CC_id][UE_id].first_rb_ul[harq_pid]; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = eNB->UE_list.UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; + ulsch_ue_select[CC_id].ue_num++; + continue; + } + } + // + if ( UE_id > last_ulsch_ue_id[CC_id] && ((ulsch_ue_select[CC_id].ue_num+ue_first_num[CC_id]) < ulsch_ue_max_num[CC_id]) ) { + if ( UE_list->UE_template[CC_id][UE_id].ul_total_buffer > 0 ) { + first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; + first_ue_total[CC_id][ue_first_num[CC_id]] = UE_list->UE_template[CC_id][UE_id].ul_total_buffer; + ue_first_num[CC_id]++; + continue; + } + if ( UE_list->UE_template[CC_id][UE_id].ul_SR > 0 ) { + 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; + } + 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]; + 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][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; + HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; + break; + } + + 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; + rnti = UE_RNTI(module_idP,first_ue_id[CC_id][temp]); + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { + cc_id_flag[CC_id] = 1; + break; + } else { + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = first_ue_total[CC_id][temp]; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = first_ue_id[CC_id][temp]; + ulsch_ue_select[CC_id].ue_num++; + } + } + } + + for ( UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++ ) { + if (UE_list->active[UE_id] == FALSE) + continue; + + rnti = UE_RNTI(module_idP,UE_id); + if (rnti ==NOT_A_RNTI) + continue; + + CC_id = UE_PCCID(module_idP,UE_id); + + if (UE_id > last_ulsch_ue_id[CC_id]) + continue; + + if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) + continue; + + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) + continue; + + 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]; + ret = cc_id_end(cc_id_flag); + if ( ret == 0 ) { + continue; + } + if ( ret == 1 ) { + return; + } + } + + for(i = 0;iHI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + //SR BSR + 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) { + cc_id_flag[CC_id] = 1; + continue; + } else { + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; + if(UE_list->UE_template[CC_id][UE_id].ul_total_buffer > 0) + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = UE_list->UE_template[CC_id][UE_id].ul_total_buffer; + else if(UE_list->UE_template[CC_id][UE_id].ul_SR > 0) + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; + ulsch_ue_select[CC_id].ue_num++; + continue; + } + } + //inactivity UE +/* 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]; + 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][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][subframeP].hi_dci0_request_body; + cc_id_flag[CC_id] = 1; + break; + } + + 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; + rnti = UE_RNTI(module_idP,ul_inactivity_id[CC_id][temp]); + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { + cc_id_flag[CC_id] = 1; + continue; + } else { + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_INACTIVE; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = ul_inactivity_id[CC_id][temp]; + ulsch_ue_select[CC_id].ue_num++; + } + } + HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; + } + return; +} + +uint8_t find_rb_table_index(uint8_t average_rbs) +{ + int i; + for ( i = 0; i < 34; i++ ) { + if ( rb_table[i] > average_rbs ) { + return (i-1); + } + } + return i; +} + +void ulsch_scheduler_pre_processor_fairRR(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; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + UE_list_t *UE_list= &eNB->UE_list; + UE_TEMPLATE *UE_template = NULL; + LTE_DL_FRAME_PARMS *frame_parms = NULL; + uint8_t ue_num_temp; + uint8_t total_rbs=0; + uint8_t average_rbs; + 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_fairRR(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 (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++ ) { + + UE_id = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; + + if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_MSG3) { + first_rb[CC_id] ++; + ue_num_temp--; + continue; + } + + if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_PRACH) { + first_rb[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb+ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + ue_num_temp--; + continue; + } + + rnti = UE_RNTI(CC_id,UE_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--; + ulsch_ue_num--; + ulsch_ue_select[CC_id].ue_num--; + continue; + } + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS ) { + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb <= average_rbs ) { + // assigne RBS(nb_rb) + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; + first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + } + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb > average_rbs ) { + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb <= total_rbs ) { + // assigne RBS(average_rbs) + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; + first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + } else { + // assigne RBS(remain rbs) + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; + rb_table_index = 2; + while(rb_table[rb_table_index] <= total_rbs){ + rb_table_index++; + } + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb = rb_table[rb_table_index-1]; + first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index-1]; + } + } + }else{ + UE_template = &UE_list->UE_template[CC_id][UE_id]; + if ( UE_list->UE_sched_ctrl[UE_id].phr_received == 1 ) { + mcs = 20; + } else { + mcs = 10; + } + 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]); + 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 ( rb_table[rb_table_index]<3 ) { + rb_table_index=2; + } + if ( rb_table[rb_table_index] <= average_rbs ) { + // assigne RBS( nb_rb) + first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index]; + UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul = rb_table[rb_table_index]; + UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = rb_table_index; + UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = mcs; + } + if ( rb_table[rb_table_index] > average_rbs ) { + // assigne RBS(average_rbs) + rb_table_index = find_rb_table_index(average_rbs); + if (rb_table_index>=34){ + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: average RBs %d > 100\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id,average_rbs); + break; + } + first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index]; + UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul = rb_table[rb_table_index]; + UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = rb_table_index; + UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = mcs; + } + }else { + // assigne RBS( 3 RBs) + first_rb[CC_id] = first_rb[CC_id] + 3; + UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul = 3; + UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = 2; + UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; + } + }else if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE ) { + // assigne RBS( 3 RBs) + first_rb[CC_id] = first_rb[CC_id] + 3; + UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul = 3; + UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = 2; + UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; + } + } + ue_num_temp--; + } + } +} + + +void +schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, + sub_frame_t subframeP) +{ + uint16_t i; + int CC_id; + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc; + int sched_frame=frameP; + + start_meas(&mac->schedule_ulsch); + + int sched_subframe = (subframeP+4)%10; + + cc = &mac->common_channels[0]; + int tdd_sfa; + // for TDD: check subframes where we have to act and return if nothing should be done now + if (cc->tdd_Config) { + tdd_sfa = cc->tdd_Config->subframeAssignment; + switch (subframeP) { + case 0: + if ((tdd_sfa == 0)|| + (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; + case 2: // Don't schedule UL in subframe 2 for TDD + return; + case 3: + if (tdd_sfa==2) sched_subframe = 7; + else return; + break; + case 4: + if (tdd_sfa==1) sched_subframe = 8; + else return; + break; + case 5: + if (tdd_sfa==0) sched_subframe = 9; + else if (tdd_sfa==6) sched_subframe = 2; + else return; + break; + case 6: + 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; + else return; + break; + case 9: + if ((tdd_sfa==1) || (tdd_sfa==3) || (tdd_sfa==4)) sched_subframe=3; + else if (tdd_sfa==6) sched_subframe=4; + else return; + break; + } + } + if (sched_subframe < subframeP) sched_frame++; + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]; + memset(ulsch_ue_select, 0, sizeof(ulsch_ue_select)); + + LTE_DL_FRAME_PARMS *frame_parms ; + + for (CC_id=0; CC_idcommon_channels[CC_id]; + frame_parms= &RC.eNB[module_idP][CC_id]->frame_parms; + // output of scheduling, the UE numbers in RBs, where it is in the code??? + // check if RA (Msg3) is active in this subframeP, if so skip the PRBs used for Msg3 + // Msg3 is using 1 PRB so we need to increase first_rb accordingly + // not sure about the break (can there be more than 1 active RA procedure?) + for (i=0; ira[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 (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; + ulsch_ue_select[CC_id].ue_num++; + break; + } + } + + //PRACH + if (is_prach_subframe(frame_parms,sched_frame,sched_subframe)==1) { + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_PRACH; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = get_prach_prb_offset( + frame_parms, + frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset, + 0,//tdd_mapindex + frameP); //Nf + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = 6; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = -1; + ulsch_ue_select[CC_id].ue_num++; + } + } + + schedule_ulsch_rnti_fairRR(module_idP, frameP, subframeP, sched_subframe,ulsch_ue_select); + stop_meas(&mac->schedule_ulsch); +} + +void schedule_ulsch_rnti_fairRR(module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframeP, + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) +{ + int16_t UE_id; + uint8_t aggregation = 2; + uint16_t first_rb[MAX_NUM_CCs]; + uint8_t ULSCH_first_end; + rnti_t rnti = -1; + uint8_t round = 0; + uint8_t harq_pid = 0; + uint8_t status = 0; + uint8_t rb_table_index = -1; + uint32_t cqi_req,cshift,ndi,tpc; + int32_t normalized_rx_power; + int32_t target_rx_power=-90; + static int32_t tpc_accumulated=0; + int CC_id,ulsch_ue_num; + int N_RB_UL; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc; + UE_list_t *UE_list=&eNB->UE_list; + UE_TEMPLATE *UE_template; + 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; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; + + nfapi_ul_config_request_body_t *ul_req_tmp; + nfapi_ul_config_ulsch_harq_information *ulsch_harq_information; + LOG_D(MAC,"entering ulsch preprocesor\n"); + ulsch_scheduler_pre_processor_fairRR(module_idP, + frameP, + subframeP, + sched_subframeP, + ulsch_ue_select); + + LOG_D(MAC,"exiting ulsch preprocesor\n"); + + + + // loop over all active UEs + for (CC_id=0; CC_idHI_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 (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 (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 + if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_MSG3) { + first_rb[CC_id] ++; + continue; + } + //PRACH + if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_PRACH) { + first_rb[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb+ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + continue; + } + + UE_template = &UE_list->UE_template[CC_id][UE_id]; + UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + harq_pid = subframe2harqpid(cc,sched_frame,sched_subframeP); + rnti = UE_RNTI(CC_id,UE_id); + LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", + module_idP,frameP,subframeP,harq_pid,UE_id,rnti,CC_id, aggregation,N_RB_UL); + + RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]); + + status = mac_eNB_get_rrc_status(module_idP,rnti); + if (status < RRC_CONNECTED) + cqi_req = 0; + else if (UE_sched_ctrl->cqi_req_timer>30) { + cqi_req = 1; + UE_sched_ctrl->cqi_req_timer=0; + UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; + } + else + cqi_req = 0; + + //power control + //compute the expected ULSCH RX power (for the stats) + + // this is the normalized RX power and this should be constant (regardless of mcs + normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; + target_rx_power = 178; + + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe; + if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case + ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around + { + UE_template->pusch_tpc_tx_frame=frameP; + UE_template->pusch_tpc_tx_subframe=subframeP; + if (normalized_rx_power>(target_rx_power+4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power<(target_rx_power-4)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + } 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, + tpc_accumulated,normalized_rx_power,target_rx_power); + } + // new transmission + if ((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) || + (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE)) { + LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x (SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", + module_idP,harq_pid,frameP,subframeP,UE_id,rnti,UE_template->ul_SR, + UE_sched_ctrl->ul_inactivity_timer, + UE_sched_ctrl->ul_failure_timer, + UE_sched_ctrl->cqi_req_timer); + + ndi = 1-UE_template->oldNDI_UL[harq_pid]; + UE_template->oldNDI_UL[harq_pid]=ndi; + 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; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul; + UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + if (UE_template->pre_allocated_rb_table_index_ul >=0) { + rb_table_index=UE_template->pre_allocated_rb_table_index_ul; + } else { + UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); + rb_table_index=5; // for PHR + } + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid]; + + UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index]; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; + + T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), + T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); + + 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); + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; + UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; + + UE_sched_ctrl->ul_scheduled |= (1<head) + 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]); + 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);*/ + // 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[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); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; + 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 = ndi; + 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; + + 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) && + (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ + 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_index], + cqi_req, + cc, + UE_template->physicalConfigDedicated, + get_tmode(module_idP,CC_id,UE_id), + eNB->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 + 0, // frequency_hopping_bits + ndi, // new_data_indication + 0, // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + get_TBS_UL(UE_template->mcs_UL[harq_pid], + rb_table[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->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){ + if(cqi_req == 1){ + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_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_cqi_harq_ri_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_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + + }else{ + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + 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, ulsch_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, + UE_id, + subframeP, + S_UL_SCHEDULED); + + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id); + + // 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,get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index])); + if(ulsch_ue_select[CC_id].list[ulsch_ue_num].ul_total_buffer > 0){ + if (UE_template->ul_total_buffer > get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index])) + UE_template->ul_total_buffer -= get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); + 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; + last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num-1].UE_id; + } + if((ulsch_ue_num == ulsch_ue_select[CC_id].ue_num-1) && (ULSCH_first_end == 0)) { + ULSCH_first_end = 1; + last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; + } + } + else if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS) { // round > 0 => retransmission + T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), + T_INT(round)); + + 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,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 + UE_template->nb_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + UE_template->first_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; + + UE_sched_ctrl->ul_scheduled |= (1<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); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + 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 = 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; + + 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)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_hi_pdu); + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; + 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,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); + 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) && + (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ + 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, + get_tmode(module_idP,CC_id,UE_id), + eNB->ul_handle, + rnti, + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb, // resource_block_start + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb, // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + UE_template->oldNDI_UL[harq_pid], // new_data_indication + rvidx_tab[round&3], // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + 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_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){ + if(cqi_req == 1){ + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_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_cqi_harq_ri_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_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + + }else{ + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + 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, ulsch_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 + first_rb[CC_id]+=ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + } + } // loop over UE_id + } // loop of CC_id +} diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h new file mode 100644 index 0000000000..e79bff8386 --- /dev/null +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h @@ -0,0 +1,130 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file eNB_scheduler_fairRR.h + * \brief eNB scheduler fair round robin header + * \author Masayuki Harada + * \date 2018 + * \email masayuki.harada@jp.fujitsu.com + * \version 1.0 + * @ingroup _mac + */ + + +#ifndef __LAYER2_MAC_ENB_SCHEDULER_FAIRRR_H__ +#define __LAYER2_MAC_ENB_SCHEDULER_FAIRRR_H__ + +/* define */ +enum SCH_UE_PRIORITY { + SCH_PRIORITY_NONE, + SCH_DL_SI, + SCH_DL_PAGING, + SCH_DL_MSG2, + SCH_DL_MSG4, + SCH_UL_PRACH, + SCH_UL_MSG3, + SCH_DL_RETRANS, + SCH_UL_RETRANS, + SCH_DL_FIRST, + SCH_UL_FIRST, + SCH_UL_INACTIVE +}; + +typedef struct { + int UE_id; + enum SCH_UE_PRIORITY ue_priority; + rnti_t rnti; + uint16_t nb_rb; +} DLSCH_UE_INFO; + +typedef struct { + uint16_t ue_num; + DLSCH_UE_INFO list[20]; +} DLSCH_UE_SELECT; + +typedef struct { + int UE_id; + enum SCH_UE_PRIORITY ue_priority; + uint8_t start_rb; + uint8_t nb_rb; + uint16_t ul_total_buffer; +} ULSCH_UE_INFO; + +typedef struct { + uint8_t ue_num; + ULSCH_UE_INFO list[20]; +} ULSCH_UE_SELECT; + +/* proto */ +void set_dl_ue_select(int CC_idP, enum SCH_UE_PRIORITY ue_priority,uint16_t nb_rb, int UE_id, rnti_t rnti); + +void dlsch_scheduler_pre_ue_select_fairRR( + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + int* mbsfn_flag, + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + DLSCH_UE_SELECT dlsch_ue_select[MAX_NUM_CCs]); + +void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, + frame_t frameP, + sub_frame_t subframeP, + int N_RBG[MAX_NUM_CCs], + int *mbsfn_flag); + +void fill_DLSCH_dci_fairRR( + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + int* mbsfn_flagP); + +void schedule_ue_spec_fairRR(module_id_t module_idP, + frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag); + +void ulsch_scheduler_pre_ue_select_fairRR( + 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_processor_fairRR(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 schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, + sub_frame_t subframeP); + +void schedule_ulsch_rnti_fairRR(module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframeP, + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]); + + +/* extern */ +extern DLSCH_UE_SELECT dlsch_ue_select[MAX_NUM_CCs]; +extern int last_dlsch_ue_id[MAX_NUM_CCs]; +extern int last_ulsch_ue_id[MAX_NUM_CCs]; + +#endif diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 76067ab663..48189cf347 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -992,9 +992,7 @@ void schedule_ulsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { -#ifndef UE_EXPANSION uint16_t first_rb[MAX_NUM_CCs]; -#endif uint16_t i; int CC_id; eNB_MAC_INST *mac = RC.mac[module_idP]; @@ -1057,7 +1055,7 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, } } if (sched_subframe < subframeP) sched_frame++; -#ifndef UE_EXPANSION + for (CC_id=0; CC_idcommon_channels[CC_id]; - frame_parms= &RC.eNB[module_idP][CC_id]->frame_parms; - // output of scheduling, the UE numbers in RBs, where it is in the code??? - // check if RA (Msg3) is active in this subframeP, if so skip the PRBs used for Msg3 - // Msg3 is using 1 PRB so we need to increase first_rb accordingly - // not sure about the break (can there be more than 1 active RA procedure?) - for (i=0; ira[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 (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; - ulsch_ue_select[CC_id].ue_num++; - break; - } - } - - //PRACH - if (is_prach_subframe(frame_parms,sched_frame,sched_subframe)==1) { - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_PRACH; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = get_prach_prb_offset( - frame_parms, - frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset, - 0,//tdd_mapindex - frameP); //Nf - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = 6; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = -1; - ulsch_ue_select[CC_id].ue_num++; - } - } - - schedule_ulsch_rnti(module_idP, frameP, subframeP, sched_subframe,ulsch_ue_select); -#endif stop_meas(&mac->schedule_ulsch); } -#ifndef UE_EXPANSION void schedule_ulsch_rnti(module_id_t module_idP, frame_t frameP, @@ -1719,524 +1656,3 @@ schedule_ulsch_rnti(module_id_t module_idP, } // loop over UE_id } // loop of CC_id } -#else -void schedule_ulsch_rnti(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframeP, - ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) -{ - int16_t UE_id; - uint8_t aggregation = 2; - uint16_t first_rb[MAX_NUM_CCs]; - uint8_t ULSCH_first_end; - rnti_t rnti = -1; - uint8_t round = 0; - uint8_t harq_pid = 0; - uint8_t status = 0; - uint8_t rb_table_index = -1; - uint32_t cqi_req,cshift,ndi,tpc; - int32_t normalized_rx_power; - int32_t target_rx_power=-90; - static int32_t tpc_accumulated=0; - int CC_id,ulsch_ue_num; - int N_RB_UL; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc; - UE_list_t *UE_list=&eNB->UE_list; - UE_TEMPLATE *UE_template; - 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; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - - nfapi_ul_config_request_body_t *ul_req_tmp; - nfapi_ul_config_ulsch_harq_information *ulsch_harq_information; - 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"); - - - - // loop over all active UEs - for (CC_id=0; CC_idHI_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 (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 (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 - if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_MSG3) { - first_rb[CC_id] ++; - continue; - } - //PRACH - if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_PRACH) { - first_rb[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb+ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - continue; - } - - UE_template = &UE_list->UE_template[CC_id][UE_id]; - UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - harq_pid = subframe2harqpid(cc,sched_frame,sched_subframeP); - rnti = UE_RNTI(CC_id,UE_id); - LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", - module_idP,frameP,subframeP,harq_pid,UE_id,rnti,CC_id, aggregation,N_RB_UL); - - RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]); - - status = mac_eNB_get_rrc_status(module_idP,rnti); - if (status < RRC_CONNECTED) - cqi_req = 0; - else if (UE_sched_ctrl->cqi_req_timer>30) { - cqi_req = 1; - UE_sched_ctrl->cqi_req_timer=0; - UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; - } - else - cqi_req = 0; - - //power control - //compute the expected ULSCH RX power (for the stats) - - // this is the normalized RX power and this should be constant (regardless of mcs - normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; - target_rx_power = 178; - - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe; - if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case - ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around - { - UE_template->pusch_tpc_tx_frame=frameP; - UE_template->pusch_tpc_tx_subframe=subframeP; - if (normalized_rx_power>(target_rx_power+4)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-4)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - } 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, - tpc_accumulated,normalized_rx_power,target_rx_power); - } - // new transmission - if ((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) || - (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE)) { - LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x (SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", - module_idP,harq_pid,frameP,subframeP,UE_id,rnti,UE_template->ul_SR, - UE_sched_ctrl->ul_inactivity_timer, - UE_sched_ctrl->ul_failure_timer, - UE_sched_ctrl->cqi_req_timer); - - ndi = 1-UE_template->oldNDI_UL[harq_pid]; - UE_template->oldNDI_UL[harq_pid]=ndi; - 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; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul; - UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS - if (UE_template->pre_allocated_rb_table_index_ul >=0) { - rb_table_index=UE_template->pre_allocated_rb_table_index_ul; - } else { - UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); - rb_table_index=5; // for PHR - } - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid]; - - UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index]; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; - - T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); - - 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); - - // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) - //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; - UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; - - UE_sched_ctrl->ul_scheduled |= (1<head) - 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]); - 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);*/ - // 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[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); - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; - 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 = ndi; - 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; - - 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) && - (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ - 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_index], - cqi_req, - cc, - UE_template->physicalConfigDedicated, - get_tmode(module_idP,CC_id,UE_id), - eNB->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 - 0, // frequency_hopping_bits - ndi, // new_data_indication - 0, // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - get_TBS_UL(UE_template->mcs_UL[harq_pid], - rb_table[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->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){ - if(cqi_req == 1){ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_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_cqi_harq_ri_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_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; - - }else{ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - 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, ulsch_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, - UE_id, - subframeP, - S_UL_SCHEDULED); - - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id); - - // 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,get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index])); - if(ulsch_ue_select[CC_id].list[ulsch_ue_num].ul_total_buffer > 0){ - if (UE_template->ul_total_buffer > get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index])) - UE_template->ul_total_buffer -= get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); - 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; - last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num-1].UE_id; - } - if((ulsch_ue_num == ulsch_ue_select[CC_id].ue_num-1) && (ULSCH_first_end == 0)) { - ULSCH_first_end = 1; - last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; - } - } - else if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS) { // round > 0 => retransmission - T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(round)); - - 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,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 - UE_template->nb_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - UE_template->first_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; - - UE_sched_ctrl->ul_scheduled |= (1<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); - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - 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 = 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; - - 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)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_hi_pdu); - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; - 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,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); - 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) && - (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ - 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, - get_tmode(module_idP,CC_id,UE_id), - eNB->ul_handle, - rnti, - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb, // resource_block_start - ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb, // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - UE_template->oldNDI_UL[harq_pid], // new_data_indication - rvidx_tab[round&3], // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - 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_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){ - if(cqi_req == 1){ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_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_cqi_harq_ri_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_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - - }else{ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - 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, ulsch_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 - first_rb[CC_id]+=ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - } - } // loop over UE_id - } // loop of CC_id - -} -#endif diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index b20846c5b5..1005b8687a 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -97,12 +97,6 @@ extern DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu1; extern DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu2; extern DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu1E; -#ifdef UE_EXPANSION -extern DLSCH_UE_SELECT dlsch_ue_select[MAX_NUM_CCs]; -extern int last_dlsch_ue_id[MAX_NUM_CCs]; -extern int last_ulsch_ue_id[MAX_NUM_CCs]; -#endif - #if defined(PRE_SCD_THREAD) extern uint16_t pre_nb_rbs_required[2][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; extern uint8_t dlsch_ue_select_tbl_in_use; @@ -110,5 +104,6 @@ extern uint8_t new_dlsch_ue_select_tbl_in_use; extern boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; extern eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; #endif + extern mac_rlc_am_muilist_t rlc_am_mui; #endif //DEF_H diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 2f221b0a0a..3bc05c538d 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -113,11 +113,7 @@ store_dlsch_buffer(module_id_t Mod_id, frame_t frameP, rnti = UE_RNTI(Mod_id, UE_id); -#if defined(UE_EXPANSION) || defined(UE_EXPANSION_SIM2) - for (i = DCCH; i <=DTCH; i++) { // loop over DCCH, DCCH1 and DTCH -#else for (i = 0; i < MAX_NUM_LCID; i++) { // loop over all the logical channels -#endif rlc_status = mac_rlc_status_ind(Mod_id, rnti, Mod_id, frameP, subframeP, @@ -540,461 +536,6 @@ void sort_UEs(module_id_t Mod_idP, int frameP, sub_frame_t subframeP) #endif } -#if defined(PRE_SCD_THREAD) -inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, uint16_t step_size){ - uint16_t nb_rb,i_TBS,tmp_TBS; - i_TBS=get_I_TBS(mcs); - for(nb_rb=step_size;nb_rb>3; - if(TBScommon_channels[CC_id].mib->message.dl_Bandwidth); - if(N_RB_DL==50) step_size=3; - if(N_RB_DL==100) step_size=4; - memset(nb_rbs_required, 0, sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); - UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - - for (UE_id = 0; UE_id dlsch_mcs1 = cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; - - - if (UE_template.dl_buffer_total > 0) { - nb_rbs_required[CC_id][UE_id] = search_rbs_required(eNB_UE_stats->dlsch_mcs1, UE_template.dl_buffer_total, N_RB_DL, step_size); - } - } -} -#endif - -#ifdef UE_EXPANSION -int cc_id_end(uint8_t *cc_id_flag ) -{ - int end_flag = 1; - for (int CC_id=0;CC_idcommon_channels; - UE_list_t *UE_list = &eNB->UE_list; - UE_sched_ctrl *ue_sched_ctl; - uint8_t CC_id; - int UE_id; - unsigned char round = 0; - unsigned char harq_pid = 0; - rnti_t rnti; - uint16_t i; - unsigned char aggregation; - int format_flag; - nfapi_dl_config_request_body_t *DL_req; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - uint16_t dlsch_ue_max_num[MAX_NUM_CCs] = {0}; - uint16_t saved_dlsch_dci[MAX_NUM_CCs] = {0}; - uint8_t end_flag[MAX_NUM_CCs] = {0}; - - // Initialization - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - dlsch_ue_max_num[CC_id] = (uint16_t)RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id]; - - // save origin DL PDU number - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - saved_dlsch_dci[CC_id] = DL_req->number_pdu; - } - - // Insert DLSCH(retransmission) UE into selected UE list - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (mbsfn_flag[CC_id]>0) { - continue; - } - - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (UE_list->active[UE_id] == FALSE) { - continue; - } - - rnti = UE_RNTI(module_idP, UE_id); - if (rnti == NOT_A_RNTI) { - continue; - } - - if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ - continue; - } - - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; -#if 0 - if (ue_sched_ctl->ul_out_of_sync == 1) { - continue; - } -#endif - 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 - if(UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] == 0){ - continue; - } - switch (get_tmode(module_idP, CC_id, UE_id)) { - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } - format_flag = 1; - if (!CCE_allocation_infeasible(module_idP, - CC_id, - format_flag, - subframeP, - aggregation, - rnti)) { - dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; - DL_req->number_pdu++; - - nb_rbs_required[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - // Insert DLSCH(retransmission) UE into selected UE list - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_RETRANS; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; - dlsch_ue_select[CC_id].ue_num++; - if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { - end_flag[CC_id] = 1; - break; - } - } else { - if (cc[CC_id].tdd_Config != NULL) { //TDD - set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); - // update UL DAI after DLSCH scheduling - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } - - add_ue_dlsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_DL_NONE); - end_flag[CC_id] = 1; - break; - } - } - } - } - if(cc_id_end(end_flag) == 1){ - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - DL_req->number_pdu = saved_dlsch_dci[CC_id]; - } - return; - } - - // Insert DLSCH(first transmission) UE into selected UE list (UE_id > last_dlsch_ue_id[CC_id]) - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (mbsfn_flag[CC_id]>0) { - continue; - } - - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - for (UE_id = (last_dlsch_ue_id[CC_id]+1); UE_id active[UE_id] == FALSE) { - continue; - } - - rnti = UE_RNTI(module_idP,UE_id); - if (rnti == NOT_A_RNTI) - continue; - - if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ - continue; - } - - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; -#if 0 - if (ue_sched_ctl->ul_out_of_sync == 1) { - continue; - } -#endif - for(i = 0;iround[CC_id][harq_pid]; - if (round == 8) { - if (nb_rbs_required[CC_id][UE_id] == 0) { - continue; - } - switch (get_tmode(module_idP, CC_id, UE_id)) { - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } - format_flag = 1; - if (!CCE_allocation_infeasible(module_idP, - CC_id, - format_flag, - subframeP, - aggregation, - rnti)) { - dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; - DL_req->number_pdu++; - - // Insert DLSCH(first transmission) UE into selected selected UE list - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; - dlsch_ue_select[CC_id].ue_num++; - - if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { - end_flag[CC_id] = 1; - break; - } - }else { - if (cc[CC_id].tdd_Config != NULL) { //TDD - set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); - // update UL DAI after DLSCH scheduling - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } - add_ue_dlsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_DL_NONE); - end_flag[CC_id] = 1; - break; - } - } - } - } - if(cc_id_end(end_flag) == 1){ - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - DL_req->number_pdu = saved_dlsch_dci[CC_id]; - } - return; - } - - // Insert DLSCH(first transmission) UE into selected UE list (UE_id <= last_dlsch_ue_id[CC_id]) - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (mbsfn_flag[CC_id]>0) { - continue; - } - - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - for (UE_id = 0; UE_id <= last_dlsch_ue_id[CC_id]; UE_id++) { - if(end_flag[CC_id] == 1){ - break; - } - - if (UE_list->active[UE_id] == FALSE) { - continue; - } - - rnti = UE_RNTI(module_idP,UE_id); - if (rnti == NOT_A_RNTI) - continue; - - if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ - continue; - } - - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; -#if 0 - if (ue_sched_ctl->ul_out_of_sync == 1) { - continue; - } -#endif - for(i = 0;iround[CC_id][harq_pid]; - if (round == 8) { - if (nb_rbs_required[CC_id][UE_id] == 0) { - continue; - } - switch (get_tmode(module_idP, CC_id, UE_id)) { - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } - format_flag = 1; - if (!CCE_allocation_infeasible(module_idP, - CC_id, - format_flag, - subframeP, - aggregation, - rnti)) { - dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; - DL_req->number_pdu++; - - // Insert DLSCH(first transmission) UE into selected selected UE list - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; - dlsch_ue_select[CC_id].ue_num++; - - if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { - end_flag[CC_id] = 1; - break; - } - } else { - if (cc[CC_id].tdd_Config != NULL) { //TDD - set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); - // update UL DAI after DLSCH scheduling - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } - add_ue_dlsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_DL_NONE); - end_flag[CC_id] = 1; - break; - } - } - } - } - - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - DL_req->number_pdu = saved_dlsch_dci[CC_id]; - } - return; -} - - - -#endif // This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done @@ -1005,17 +546,11 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, int *mbsfn_flag) { -#ifndef UE_EXPANSION unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX],harq_pid=0,round=0,total_ue_count; uint16_t ii; uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint16_t r1=0; // int rrc_status = RRC_IDLE; -#else - unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX],harq_pid=0,Round=0; - uint16_t temp_total_rbs_count; - unsigned char temp_total_ue_count; -#endif unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; int UE_id, i; uint16_t j; @@ -1078,7 +613,6 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, } } -#if (!defined(PRE_SCD_THREAD)) // Store the DLSCH buffer for each logical channel store_dlsch_buffer(Mod_id, frameP, subframeP); @@ -1087,100 +621,14 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, // Calculate the number of RBs required by each UE on the basis of logical channel's buffer assign_rbs_required(Mod_id, frameP, subframeP, nb_rbs_required, min_rb_unit); -#else - memcpy(nb_rbs_required, pre_nb_rbs_required[dlsch_ue_select_tbl_in_use] , sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); -#endif -#ifdef UE_EXPANSION - dlsch_scheduler_pre_ue_select(Mod_id,frameP,subframeP, mbsfn_flag,nb_rbs_required,dlsch_ue_select); -#else // Sorts the user on the basis of dlsch logical channel buffer and CQI sort_UEs (Mod_id,frameP,subframeP); total_ue_count =0; -#endif - //total_ue_count =0; -#ifdef UE_EXPANSION - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - average_rbs_per_user[CC_id] = 0; - cc = &RC.mac[Mod_id]->common_channels[CC_id]; - // Get total available RBS count and total UE count - N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); - temp_total_rbs_count = RC.mac[Mod_id]->eNB_stats[CC_id].available_prbs; - temp_total_ue_count = dlsch_ue_select[CC_id].ue_num; - - for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ - temp_total_ue_count--; - continue; - } - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ - temp_total_ue_count--; - continue; - } - UE_id = dlsch_ue_select[CC_id].list[i].UE_id; - nb_rbs_required[CC_id][UE_id] = dlsch_ue_select[CC_id].list[i].nb_rb; - - average_rbs_per_user[CC_id] = (uint16_t)round((double)temp_total_rbs_count/(double)temp_total_ue_count); - if( average_rbs_per_user[CC_id] < min_rb_unit[CC_id] ){ - temp_total_ue_count--; - dlsch_ue_select[CC_id].ue_num--; - i--; - continue; - } - - rnti = dlsch_ue_select[CC_id].list[i].rnti; - - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - 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) { - if (mac_eNB_get_rrc_status(Mod_id, rnti) < RRC_RECONFIGURED || Round != 8) { // FIXME - nb_rbs_required_remaining[CC_id][UE_id] = dlsch_ue_select[CC_id].list[i].nb_rb; - } else { - nb_rbs_required_remaining[CC_id][UE_id] = cmin(average_rbs_per_user[CC_id], dlsch_ue_select[CC_id].list[i].nb_rb); - } - - transmission_mode = get_tmode(Mod_id,CC_id,UE_id); - - LOG_T(MAC,"calling dlsch_scheduler_pre_processor_allocate .. \n "); - dlsch_scheduler_pre_processor_allocate (Mod_id, - UE_id, - CC_id, - N_RBG[CC_id], - transmission_mode, - min_rb_unit[CC_id], - N_RB_DL, - nb_rbs_required, - nb_rbs_required_remaining, - rballoc_sub, - MIMO_mode_indicator); - temp_total_rbs_count -= ue_sched_ctl->pre_nb_available_rbs[CC_id]; - temp_total_ue_count--; - - if (ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) { - dlsch_ue_select[CC_id].ue_num = i; - break; - } - - if (temp_total_rbs_count == 0) { - dlsch_ue_select[CC_id].ue_num = i+1; - break; - } - LOG_D(MAC,"DLSCH UE Select: frame %d subframe %d pre_nb_available_rbs %d(i %d UE_id %d nb_rbs_required %d nb_rbs_required_remaining %d average_rbs_per_user %d (temp_total rbs_count %d ue_num %d) available_prbs %d)\n", - frameP,subframeP,ue_sched_ctl->pre_nb_available_rbs[CC_id],i,UE_id,nb_rbs_required[CC_id][UE_id],nb_rbs_required_remaining[CC_id][UE_id], - average_rbs_per_user[CC_id],temp_total_rbs_count,temp_total_ue_count,RC.mac[Mod_id]->eNB_stats[CC_id].available_prbs); -#ifdef TM5 - // TODO: data channel TM5: to be re-visited -#endif - } - } - -#else // loop over all active UEs for (i = UE_list->head; i >= 0; i = UE_list->next[i]) { rnti = UE_RNTI(Mod_id, i); @@ -1511,7 +959,6 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, } } // total_ue_count } // end of for for r1 and r2 -#endif // end of #ifndef UE_EXPANSION #ifdef TM5 // This has to be revisited!!!! @@ -1555,25 +1002,12 @@ void dlsch_scheduler_pre_processor (module_id_t Mod_id, #endif -#ifdef UE_EXPANSION - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ - continue; - } - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ - continue; - } - UE_id = dlsch_ue_select[CC_id].list[i].UE_id; - ue_sched_ctl = &RC.mac[Mod_id]->UE_list.UE_sched_ctrl[UE_id]; -#else for(i=UE_list->head; i>=0; i=UE_list->next[i]) { UE_id = i; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; for (ii=0; iiordered_CCids[ii][UE_id]; -#endif //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0) { @@ -1868,7 +1302,6 @@ dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id, /// ULSCH PRE_PROCESSOR -#ifndef UE_EXPANSION void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, sub_frame_t subframeP, @@ -2085,7 +1518,6 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, } } } -#endif void assign_max_mcs_min_rb(module_id_t module_idP, int frameP, @@ -2398,473 +1830,3 @@ void sort_ue_ul(module_id_t module_idP, int frameP, sub_frame_t subframeP) } #endif } -#ifdef UE_EXPANSION -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]; - COMMON_channels_t *cc; - int CC_id,UE_id; - int ret; - uint16_t i; - uint8_t ue_first_num[MAX_NUM_CCs]; - uint8_t first_ue_total[MAX_NUM_CCs][20]; - uint8_t first_ue_id[MAX_NUM_CCs][20]; - uint8_t ul_inactivity_num[MAX_NUM_CCs]; - uint8_t ul_inactivity_id[MAX_NUM_CCs][20]; -// LTE_DL_FRAME_PARMS *frame_parms; - uint8_t ulsch_ue_max_num[MAX_NUM_CCs]; - uint16_t saved_ulsch_dci[MAX_NUM_CCs]; - rnti_t rnti; - UE_sched_ctrl *UE_sched_ctl = NULL; - uint8_t cc_id_flag[MAX_NUM_CCs]; - uint8_t harq_pid = 0,round = 0; - UE_list_t *UE_list= &eNB->UE_list; - - - uint8_t aggregation = 2; - int format_flag; - nfapi_hi_dci0_request_body_t *HI_DCI0_req; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - - - 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][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]; - - cc_id_flag[CC_id] = 0; - ue_first_num[CC_id] = 0; - ul_inactivity_num[CC_id] = 0; - - } - // UE round >0 - for ( UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++ ) { - if (UE_list->active[UE_id] == FALSE) - continue; - - rnti = UE_RNTI(module_idP,UE_id); - if (rnti ==NOT_A_RNTI) - continue; - - CC_id = UE_PCCID(module_idP,UE_id); - if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) - continue; - - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) - continue; - - // UL DCI - 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]; - ret = cc_id_end(cc_id_flag); - if ( ret == 0 ) { - continue; - } - if ( ret == 1 ) { - return; - } - } - - cc = &eNB->common_channels[CC_id]; - //harq_pid - harq_pid = subframe2harqpid(cc,(frameP+(sched_subframePUE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]; - - if ( round > 0 ) { - 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) { - cc_id_flag[CC_id] = 1; - continue; - } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_RETRANS; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = eNB->UE_list.UE_template[CC_id][UE_id].first_rb_ul[harq_pid]; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = eNB->UE_list.UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; - ulsch_ue_select[CC_id].ue_num++; - continue; - } - } - // - if ( UE_id > last_ulsch_ue_id[CC_id] && ((ulsch_ue_select[CC_id].ue_num+ue_first_num[CC_id]) < ulsch_ue_max_num[CC_id]) ) { - if ( UE_list->UE_template[CC_id][UE_id].ul_total_buffer > 0 ) { - first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; - first_ue_total[CC_id][ue_first_num[CC_id]] = UE_list->UE_template[CC_id][UE_id].ul_total_buffer; - ue_first_num[CC_id]++; - continue; - } - if ( UE_list->UE_template[CC_id][UE_id].ul_SR > 0 ) { - 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; - } - 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]; - 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][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; - HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; - break; - } - - 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; - rnti = UE_RNTI(module_idP,first_ue_id[CC_id][temp]); - if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - break; - } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = first_ue_total[CC_id][temp]; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = first_ue_id[CC_id][temp]; - ulsch_ue_select[CC_id].ue_num++; - } - } - } - - for ( UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++ ) { - if (UE_list->active[UE_id] == FALSE) - continue; - - rnti = UE_RNTI(module_idP,UE_id); - if (rnti ==NOT_A_RNTI) - continue; - - CC_id = UE_PCCID(module_idP,UE_id); - - if (UE_id > last_ulsch_ue_id[CC_id]) - continue; - - if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) - continue; - - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) - continue; - - 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]; - ret = cc_id_end(cc_id_flag); - if ( ret == 0 ) { - continue; - } - if ( ret == 1 ) { - return; - } - } - - for(i = 0;iHI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; - //SR BSR - 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) { - cc_id_flag[CC_id] = 1; - continue; - } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; - if(UE_list->UE_template[CC_id][UE_id].ul_total_buffer > 0) - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = UE_list->UE_template[CC_id][UE_id].ul_total_buffer; - else if(UE_list->UE_template[CC_id][UE_id].ul_SR > 0) - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; - ulsch_ue_select[CC_id].ue_num++; - continue; - } - } - //inactivity UE -/* 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]; - 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][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][subframeP].hi_dci0_request_body; - cc_id_flag[CC_id] = 1; - break; - } - - 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; - rnti = UE_RNTI(module_idP,ul_inactivity_id[CC_id][temp]); - if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - continue; - } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_INACTIVE; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = ul_inactivity_id[CC_id][temp]; - ulsch_ue_select[CC_id].ue_num++; - } - } - HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; - } - return; -} - -uint8_t find_rb_table_index(uint8_t average_rbs) -{ - int i; - for ( i = 0; i < 34; i++ ) { - if ( rb_table[i] > average_rbs ) { - return (i-1); - } - } - return i; -} - -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; - eNB_MAC_INST *eNB = RC.mac[module_idP]; - UE_list_t *UE_list= &eNB->UE_list; - UE_TEMPLATE *UE_template = NULL; - LTE_DL_FRAME_PARMS *frame_parms = NULL; - uint8_t ue_num_temp; - uint8_t total_rbs=0; - uint8_t average_rbs; - 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,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 (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++ ) { - - UE_id = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; - - if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_MSG3) { - first_rb[CC_id] ++; - ue_num_temp--; - continue; - } - - if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_PRACH) { - first_rb[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb+ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - ue_num_temp--; - continue; - } - - rnti = UE_RNTI(CC_id,UE_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--; - ulsch_ue_num--; - ulsch_ue_select[CC_id].ue_num--; - continue; - } - if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS ) { - if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb <= average_rbs ) { - // assigne RBS(nb_rb) - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; - first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - } - if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb > average_rbs ) { - if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb <= total_rbs ) { - // assigne RBS(average_rbs) - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; - first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - } else { - // assigne RBS(remain rbs) - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; - rb_table_index = 2; - while(rb_table[rb_table_index] <= total_rbs){ - rb_table_index++; - } - ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb = rb_table[rb_table_index-1]; - first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index-1]; - } - } - }else{ - UE_template = &UE_list->UE_template[CC_id][UE_id]; - if ( UE_list->UE_sched_ctrl[UE_id].phr_received == 1 ) { - mcs = 20; - } else { - mcs = 10; - } - 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]); - 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 ( rb_table[rb_table_index]<3 ) { - rb_table_index=2; - } - if ( rb_table[rb_table_index] <= average_rbs ) { - // assigne RBS( nb_rb) - first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index]; - UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul = rb_table[rb_table_index]; - UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = rb_table_index; - UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = mcs; - } - if ( rb_table[rb_table_index] > average_rbs ) { - // assigne RBS(average_rbs) - rb_table_index = find_rb_table_index(average_rbs); - if (rb_table_index>=34){ - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: average RBs %d > 100\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id,average_rbs); - break; - } - first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index]; - UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul = rb_table[rb_table_index]; - UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = rb_table_index; - UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = mcs; - } - }else { - // assigne RBS( 3 RBs) - first_rb[CC_id] = first_rb[CC_id] + 3; - UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul = 3; - UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = 2; - UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; - } - }else if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE ) { - // assigne RBS( 3 RBs) - first_rb[CC_id] = first_rb[CC_id] + 3; - UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul = 3; - UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = 2; - UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; - } - } - ue_num_temp--; - } - } -} -#endif diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index fe7d9c96f6..1e33f3ac8d 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -106,11 +106,7 @@ void schedule_ulsch(module_id_t module_idP, frame_t frameP, @param subframe Subframe number on which to act @param sched_subframe Subframe number where PUSCH is transmitted (for DAI lookup) */ -#ifndef UE_EXPANSION void schedule_ulsch_rnti(module_id_t module_idP, frame_t frameP, sub_frame_t subframe, unsigned char sched_subframe, uint16_t *first_rb); -#else -void schedule_ulsch_rnti(module_id_t module_idP, frame_t frameP, sub_frame_t subframe, unsigned char sched_subframe, ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]); -#endif /** \brief Second stage of DLSCH scheduling, after schedule_SI, schedule_RA and schedule_dlsch have been called. This routine first allocates random frequency assignments for SI and RA SDUs using distributed VRB allocations and adds the corresponding DCI SDU to the DCI buffer for PHY. It then loops over the UE specific DCIs previously allocated and fills in the remaining DCI fields related to frequency allocation. It assumes localized allocation of type 0 (DCI.rah=0). The allocation is done for tranmission modes 1,2,4. @param Mod_id Instance of eNB @@ -227,13 +223,6 @@ void dlsch_scheduler_pre_processor_allocate (module_id_t Mod_id, unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX], unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]); -#if defined(PRE_SCD_THREAD) -void pre_scd_nb_rbs_required(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - int min_rb_unit[MAX_NUM_CCs], - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]); -#endif /* \brief Function to trigger the eNB scheduling procedure. It is called by PHY at the beginning of each subframe, \f$n$\f and generates all DLSCH allocations for subframe \f$n\f$ and ULSCH allocations for subframe \f$n+k$\f. @param Mod_id Instance ID of eNB @@ -642,12 +631,8 @@ int UE_PCCID(module_id_t mod_idP, int ue_idP); 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, 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, 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( int module_idP, @@ -1174,6 +1159,13 @@ uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn); int32_t get_uldl_offset(int eutra_bandP); int l2_init_ue(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); +#if defined(PRE_SCD_THREAD) +void pre_scd_nb_rbs_required( module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + int min_rb_unit[MAX_NUM_CCs], + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]); +#endif #endif /** @}*/ diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 7e199ec074..65a299ffb7 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -142,18 +142,5 @@ DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu2; DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu1E; -#ifdef UE_EXPANSION -DLSCH_UE_SELECT dlsch_ue_select[MAX_NUM_CCs]; -int last_dlsch_ue_id[MAX_NUM_CCs] = {-1}; -int last_ulsch_ue_id[MAX_NUM_CCs] = {-1}; -#endif - -#if defined(PRE_SCD_THREAD) -uint16_t pre_nb_rbs_required[2][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; -uint8_t dlsch_ue_select_tbl_in_use; -uint8_t new_dlsch_ue_select_tbl_in_use; -boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; -eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; -#endif mac_rlc_am_muilist_t rlc_am_mui; #endif diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 37c33c45b9..d74dce1890 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -793,14 +793,6 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* (void)ue_module_id; #endif rnti_t rnti = ue_context_pP->ue_context.rnti; -#ifndef UE_EXPANSION - int i, j , CC_id, pdu_number; - 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; - eNB_MAC_INST *eNB_MAC = RC.mac[enb_mod_idP]; -#endif if (enb_mod_idP >= NB_eNB_INST) { LOG_I(RRC, "eNB inst invalid (%d/%d) for UE %x!\n",enb_mod_idP, NB_eNB_INST,rnti); return; @@ -828,66 +820,9 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* return; } #endif -#ifndef UE_EXPANSION - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - eNB_PHY = RC.eNB[enb_mod_idP][CC_id]; - for (i=0; iulsch[i]; - if((ulsch != NULL) && (ulsch->rnti == rnti)){ - LOG_I(RRC, "clean_eNb_ulsch UE %x \n", rnti); - //clean_eNb_ulsch(ulsch); - ulsch->rnti = 0; - } - 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++){ - ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; - 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) || - (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--; - } - } - } - } - } - rrc_mac_remove_ue(enb_mod_idP,rnti); - rrc_rlc_remove_ue(&ctxt); - pdcp_remove_UE(&ctxt); - - rrc_eNB_remove_ue_context( - &ctxt, - RC.rrc[enb_mod_idP], - (struct rrc_eNB_ue_context_s*) ue_context_pP); -#else // add UE info to freeList LOG_I(RRC, "put UE %x into freeList\n", rnti); put_UE_in_freelist(enb_mod_idP, rnti, 1); -#endif } } From dc76ce82f39bbfe2239f602d6ee91bd0609fb62c Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Thu, 17 May 2018 11:36:18 +0900 Subject: [PATCH 81/91] Fix link error --- cmake_targets/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index e1ff105452..6d402d2a4c 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1199,6 +1199,7 @@ set (MAC_SRC ${MAC_DIR}/eNB_scheduler_bch.c ${MAC_DIR}/eNB_scheduler_primitives.c ${MAC_DIR}/eNB_scheduler_RA.c + ${MAC_DIR}/eNB_scheduler_fairRR.c ${MAC_DIR}/pre_processor.c ${MAC_DIR}/config.c ) From f55bd83d552c93ff657e2a13c9641294f2441edf Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Thu, 17 May 2018 18:27:09 +0900 Subject: [PATCH 82/91] select scheduler by config file --- openair2/ENB_APP/enb_config.c | 12 +++++- openair2/ENB_APP/enb_paramdef.h | 3 ++ openair2/LAYER2/MAC/config.c | 1 + openair2/LAYER2/MAC/defs.h | 9 +++++ openair2/LAYER2/MAC/eNB_scheduler.c | 33 +++++++-------- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 47 ++++++++-------------- openair2/LAYER2/MAC/eNB_scheduler_fairRR.c | 12 ++++-- openair2/LAYER2/MAC/eNB_scheduler_fairRR.h | 3 +- openair2/LAYER2/MAC/extern.h | 1 + openair2/LAYER2/MAC/vars.h | 1 + 10 files changed, 70 insertions(+), 52 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index b82fe37fc6..4d37307fae 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -384,7 +384,17 @@ void RCconfig_macrlc() { printf("**************** RETURNED FROM configure_nfapi_vnf() vnf_port:%d\n", RC.mac[j]->eth_params_s.my_portc); } else { // other midhaul AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr)); - } + } + if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr), "default") == 0){ + global_scheduler_mode=SCHED_MODE_DEFAULT; + printf("sched mode = default %d [%s]\n",global_scheduler_mode,*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr)); + }else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr), "fairRR") == 0){ + global_scheduler_mode=SCHED_MODE_FAIR_RR; + printf("sched mode = fairRR %d [%s]\n",global_scheduler_mode,*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr)); + }else{ + global_scheduler_mode=SCHED_MODE_DEFAULT; + printf("sched mode = default %d [%s]\n",global_scheduler_mode,*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr)); + } }// j=0..num_inst } else {// MacRLC_ParamList.numelt > 0 AssertFatal (0, diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index 8f32a1206b..a9441dc245 100755 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -652,6 +652,7 @@ static int DEFENBS[] = {0}; #define CONFIG_STRING_MACRLC_REMOTE_S_PORTC "remote_s_portc" #define CONFIG_STRING_MACRLC_LOCAL_S_PORTD "local_s_portd" #define CONFIG_STRING_MACRLC_REMOTE_S_PORTD "remote_s_portd" +#define CONFIG_STRING_MACRLC_SCHED_MODE "scheduler_mode" /*-------------------------------------------------------------------------------------------------------------------------------------------------------*/ @@ -676,6 +677,7 @@ static int DEFENBS[] = {0}; {CONFIG_STRING_MACRLC_REMOTE_S_PORTC, NULL, 0, uptr:NULL, defintval:50020, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_LOCAL_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_REMOTE_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ +{CONFIG_STRING_MACRLC_SCHED_MODE, NULL, 0, strptr:NULL, defintval:"default", TYPE_STRING, 0}, \ } #define MACRLC_CC_IDX 0 #define MACRLC_TRANSPORT_N_PREFERENCE_IDX 1 @@ -694,4 +696,5 @@ static int DEFENBS[] = {0}; #define MACRLC_REMOTE_S_PORTC_IDX 14 #define MACRLC_LOCAL_S_PORTD_IDX 15 #define MACRLC_REMOTE_S_PORTD_IDX 16 +#define MACRLC_SCHED_MODE_IDX 17 /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 4dadb529ee..95809957b3 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -1021,6 +1021,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_OUT); } + RC.mac[Mod_idP]->scheduler_mode = global_scheduler_mode; return(0); } diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 54fb9254ef..2315d59b8f 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -432,6 +432,12 @@ typedef enum { CBA_RS /// random allocation } CBA_POLICY; +/*!\brief scheduler mode */ +typedef enum { + SCHED_MODE_DEFAULT = 0, /// default cheduler + SCHED_MODE_FAIR_RR /// fair raund robin +} SCHEDULER_MODES; + /*! \brief temporary struct for ULSCH sched */ typedef struct { @@ -1138,6 +1144,9 @@ typedef struct eNB_MAC_INST_s { time_stats_t schedule_pch; UE_free_list_t UE_free_list; + /// for scheduling selection + SCHEDULER_MODES scheduler_mode; + } eNB_MAC_INST; /* diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index bb79424c62..e1e2e48583 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -793,9 +793,21 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, } #endif -#ifdef UE_EXPANSION - memset(dlsch_ue_select, 0, sizeof(dlsch_ue_select)); -#endif + static int debug_flag=0; + void (*schedule_ulsch_p)(module_id_t module_idP, frame_t frameP, sub_frame_t subframe); + void (*schedule_ue_spec_p)(module_id_t module_idP, frame_t frameP, sub_frame_t subframe, int *mbsfn_flag); + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_DEFAULT){ + schedule_ulsch_p = schedule_ulsch; + schedule_ue_spec_p = schedule_ue_spec; + }else if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ + memset(dlsch_ue_select, 0, sizeof(dlsch_ue_select)); + schedule_ulsch_p = schedule_ulsch_fairRR; + schedule_ue_spec_p = schedule_ue_spec_fairRR; + } + if(debug_flag==0){ + LOG_E(MAC,"SCHED_MODE=%d\n",RC.mac[module_idP]->scheduler_mode); + debug_flag=1; + } // This schedules MIB if ((subframeP == 0) && (frameP & 3) == 0) schedule_mib(module_idP, frameP, subframeP); @@ -809,25 +821,14 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, copy_ulreq(module_idP, frameP, subframeP); // This schedules SRS in subframeP schedule_SRS(module_idP, frameP, subframeP); -#ifdef UE_EXPANSION // This schedules ULSCH in subframeP (dci0) - schedule_ulsch_fairRR(module_idP, frameP, subframeP); -#else - // This schedules ULSCH in subframeP (dci0) - schedule_ulsch(module_idP, frameP, subframeP); -#endif + schedule_ulsch_p(module_idP, frameP, subframeP); // This schedules UCI_SR in subframeP schedule_SR(module_idP, frameP, subframeP); // This schedules UCI_CSI in subframeP schedule_CSI(module_idP, frameP, subframeP); - -#ifdef UE_EXPANSION // This schedules DLSCH in subframeP - schedule_ue_spec_fairRR(module_idP, frameP, subframeP, mbsfn_status); -#else - // This schedules DLSCH in subframeP - schedule_ue_spec(module_idP, frameP, subframeP, mbsfn_status); -#endif + schedule_ue_spec_p(module_idP, frameP, subframeP, mbsfn_status); // Allocate CCEs for good after scheduling is done for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++){ diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 933c2ffbf2..73b14af19b 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -64,22 +64,7 @@ #include "SIMULATION/TOOLS/defs.h" // for taus #include "T.h" -#ifdef UE_EXPANSION -enum SCH_UE_PRIORITY { - SCH_PRIORITY_NONE, - SCH_DL_SI, - SCH_DL_PAGING, - SCH_DL_MSG2, - SCH_DL_MSG4, - SCH_UL_PRACH, - SCH_UL_MSG3, - SCH_DL_RETRANS, - SCH_UL_RETRANS, - SCH_DL_FIRST, - SCH_UL_FIRST, - SCH_UL_INACTIVE -}; -#endif + extern uint8_t nfapi_mode; extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); @@ -596,9 +581,9 @@ generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP, TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload; mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; -#ifdef UE_EXPANSION - set_dl_ue_select(CC_idP, SCH_DL_MSG2, 4, -1, ra->rnti); -#endif + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ + set_dl_ue_select_msg2(CC_idP, 4, -1, ra->rnti); + } } } @@ -730,9 +715,9 @@ generate_Msg2(module_id_t module_idP, int CC_idP, frame_t frameP, TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload; mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; -#ifdef UE_EXPANSION - set_dl_ue_select(CC_idP, SCH_DL_MSG2, 4, -1, ra->rnti); -#endif + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ + set_dl_ue_select_msg2(CC_idP, 4, -1, ra->rnti); + } } // PDCCH CCE allocation is feasible } // Msg2 frame/subframe condition } // else BL/CE @@ -1218,9 +1203,9 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, UE_id), rrc_sdu_length); } -#ifdef UE_EXPANSION - set_dl_ue_select(CC_idP, SCH_DL_MSG4, 4, UE_id, ra->rnti); -#endif + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ + set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti); + } } // Msg4 frame/subframe } // msg4_mpdcch_repetition_count } // rach_resource_type > 0 @@ -1422,9 +1407,9 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, UE_id), rrc_sdu_length); } -#ifdef UE_EXPANSION - set_dl_ue_select(CC_idP, SCH_DL_MSG4, 4, UE_id, ra->rnti); -#endif + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ + set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti); + } } // CCE Allocation feasible } // msg4 frame/subframe } // else rach_resource_type @@ -1568,9 +1553,9 @@ check_Msg4_retransmission(module_id_t module_idP, int CC_idP, (cc->p_eNB == 1) ? 1 : 2, // transmission mode 1, // num_bf_prb_per_subband 1); // num_bf_vector -#ifdef UE_EXPANSION - set_dl_ue_select(CC_idP, SCH_DL_MSG4, 4, UE_id, ra->rnti); -#endif + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ + set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti); + } } else LOG_D(MAC, "msg4 retransmission for rnti %x (round %d) fsf %d/%d CCE allocation failed!\n", diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c index 1b8d212cb4..6b6f13dac1 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c @@ -75,14 +75,20 @@ eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; #define DEBUG_HEADER_PARSING 1 //#define DEBUG_PACKET_TRACE 1 -void set_dl_ue_select(int CC_idP, enum SCH_UE_PRIORITY ue_priority,uint16_t nb_rb, int UE_id, rnti_t rnti) { - dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].ue_priority = ue_priority; +void set_dl_ue_select_msg2(int CC_idP, uint16_t nb_rb, int UE_id, rnti_t rnti) { + dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].ue_priority = SCH_DL_MSG2; + dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].nb_rb = nb_rb; + dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].UE_id = UE_id; + dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].rnti = rnti; + dlsch_ue_select[CC_idP].ue_num++; +} +void set_dl_ue_select_msg4(int CC_idP, uint16_t nb_rb, int UE_id, rnti_t rnti) { + dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].ue_priority = SCH_DL_MSG4; dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].nb_rb = nb_rb; dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].UE_id = UE_id; dlsch_ue_select[CC_idP].list[dlsch_ue_select[CC_idP].ue_num].rnti = rnti; dlsch_ue_select[CC_idP].ue_num++; } - #if defined(PRE_SCD_THREAD) inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, uint16_t step_size){ uint16_t nb_rb,i_TBS,tmp_TBS; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h index e79bff8386..8c90118609 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.h @@ -74,7 +74,8 @@ typedef struct { } ULSCH_UE_SELECT; /* proto */ -void set_dl_ue_select(int CC_idP, enum SCH_UE_PRIORITY ue_priority,uint16_t nb_rb, int UE_id, rnti_t rnti); +void set_dl_ue_select_msg2(int CC_idP, uint16_t nb_rb, int UE_id, rnti_t rnti); +void set_dl_ue_select_msg4(int CC_idP, uint16_t nb_rb, int UE_id, rnti_t rnti); void dlsch_scheduler_pre_ue_select_fairRR( module_id_t module_idP, diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index 1005b8687a..8f5d55dfd3 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -106,4 +106,5 @@ extern eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; #endif extern mac_rlc_am_muilist_t rlc_am_mui; +extern SCHEDULER_MODES global_scheduler_mode; #endif //DEF_H diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 65a299ffb7..51aa3c0112 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -143,4 +143,5 @@ DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu2; DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu1E; mac_rlc_am_muilist_t rlc_am_mui; +SCHEDULER_MODES global_scheduler_mode; #endif From 8bec50653f2a3d6971c70e6e381e0b9255190e21 Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Fri, 18 May 2018 10:01:07 +0900 Subject: [PATCH 83/91] Fix: eNB output core dump file when exiting eNB process. --- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 1 + targets/RT/USER/lte-softmodem.c | 35 +++++++++++++------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 6bb7e2e82f..3e58f281b4 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -376,6 +376,7 @@ static void trx_usrp_end(openair0_device *device) { s->tx_md.end_of_burst = true; s->tx_stream->send("", 0, s->tx_md); s->tx_md.end_of_burst = false; + sleep(1); #if defined(USRP_REC_PLAY) } #endif diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 5861ba6cb2..a6d1a9af47 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -332,10 +332,14 @@ void exit_fun(const char* s) if (UE_flag==0) { for (ru_id=0; ru_idrfdevice.trx_end_func) - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - if (RC.ru[ru_id]->ifdevice.trx_end_func) - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + if (RC.ru[ru_id]->rfdevice.trx_end_func) { + RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); + RC.ru[ru_id]->rfdevice.trx_end_func = NULL; + } + if (RC.ru[ru_id]->ifdevice.trx_end_func) { + RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + RC.ru[ru_id]->ifdevice.trx_end_func = NULL; + } } } @@ -346,8 +350,10 @@ void exit_fun(const char* s) for(CC_id=0; CC_idrfdevice.trx_end_func) - PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][CC_id]->rfdevice); + if (PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func) { + PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][CC_id]->rfdevice); + PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func = NULL; + } } } @@ -1473,16 +1479,21 @@ int main( int argc, char **argv ) // *** Handle per CC_id openair0 if (UE_flag==1) { - if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func) + if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func) { PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice); + PHY_vars_UE_g[0][0]->rfdevice.trx_end_func = NULL; + } } else { for(ru_id=0; ru_idrfdevice.trx_end_func) - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - if (RC.ru[ru_id]->ifdevice.trx_end_func) - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); - + if (RC.ru[ru_id]->rfdevice.trx_end_func) { + RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); + RC.ru[ru_id]->rfdevice.trx_end_func = NULL; + } + if (RC.ru[ru_id]->ifdevice.trx_end_func) { + RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + RC.ru[ru_id]->ifdevice.trx_end_func = NULL; + } } } if (ouput_vcd) From ff604660fe7bae808c9c11c2194b63690fe0bb1b Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Fri, 18 May 2018 10:58:26 +0900 Subject: [PATCH 84/91] delete UE_EXPANSION route --- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 8 ++------ openair2/RRC/LITE/MESSAGES/asn1_msg.c | 4 ---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 11a0bc5d14..32fab5f4a2 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -934,9 +934,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, nb_rb); //#endif -#ifndef UE_EXPANSION // TODO check this modified - if (ulsch_harq->round == 0) { -#endif + //if (ulsch_harq->round == 0) { // delete for RB shortage pattern // This is a new packet, so compute quantities regarding segmentation ulsch_harq->B = A+24; lte_segmentation(NULL, @@ -949,9 +947,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, &ulsch_harq->Kminus, &ulsch_harq->F); // CLEAR LLR's HERE for first packet in process -#ifndef UE_EXPANSION - } -#endif + //} // printf("after segmentation c[%d] = %p\n",0,ulsch_harq->c[0]); sumKr = 0; diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index 58ac5a3f87..934df18fbc 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -1534,7 +1534,6 @@ do_RRCConnectionSetup( // SchedulingRequestConfig physicalConfigDedicated2->schedulingRequestConfig->present = SchedulingRequestConfig_PR_setup; -#ifdef UE_EXPANSION 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 { @@ -1557,9 +1556,6 @@ do_RRCConnectionSetup( break; } } -#else - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; -#endif if (carrier->sib1->tdd_Config == NULL) { // FDD physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 5+(ue_context_pP->local_uid%10); // Isr = 5 (every 10 subframes, offset=2+UE_id mod3) From 843e7c8fc4e7e53abb7f8bde43a8aac443c41c89 Mon Sep 17 00:00:00 2001 From: jftt_wangshanshan Date: Mon, 21 May 2018 16:43:12 +0800 Subject: [PATCH 85/91] Change SR detection for TDD for compliance with FDD. (try) --- openair1/SCHED/phy_procedures_lte_eNb.c | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index ab01b980a6..3ab8f9ce04 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -973,8 +973,34 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) } else { // frame_type == TDD +#if 1 + metric[0] = rx_pucch(eNB, + uci->pucch_fmt, + i, + uci->n_pucch_1[0][0], + 0, //n2_pucch + uci->srs_active, // shortened format + pucch_b0b1[0], + frame, + subframe, + PUCCH1a_THRES); + if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0; + else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); - + if (uci->type==HARQ_SR && metric[0] <= metric_SR) { + SR_payload = 1; + metric[0] = rx_pucch(eNB, + pucch_format1b, + i, + uci->n_pucch_1_0_sr[0], + 0, //n2_pucch + uci->srs_active, // shortened format + pucch_b0b1[0], + frame, + subframe, + PUCCH1a_THRES); + } +#else // if SR was detected, use the n1_pucch from SR if (SR_payload==1) { #ifdef DEBUG_PHY_PROC @@ -1025,7 +1051,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) LOG_D(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]); #endif - +#endif 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 From fadba8a1ede47daa1561455ca7296cb6e7bcc469 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Tue, 22 May 2018 18:42:35 +0900 Subject: [PATCH 86/91] fix rm917 bug --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 31 ++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 76067ab663..59e890fe72 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -175,6 +175,32 @@ rx_sdu(const module_id_t enb_mod_idP, 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]++; + + first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; + + // Program NACK for PHICH + LOG_D(MAC, + "Programming PHICH NACK for rnti %x harq_pid %d (first_rb %d)\n", + current_rnti, harq_pid, first_rb); + 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]; + memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu); + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = first_rb; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; + 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,sf_ahead_dl); + hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; return; } @@ -1592,7 +1618,7 @@ schedule_ulsch_rnti(module_id_t module_idP, T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), T_INT(round)); - +#if 0 // fill in NAK information 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]; @@ -1620,6 +1646,7 @@ schedule_ulsch_rnti(module_id_t module_idP, UE_template->first_rb_ul[harq_pid], UE_template->nb_rb_ul[harq_pid], UE_template->TBS_UL[harq_pid], round); +#endif // 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", @@ -2143,6 +2170,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; hi_dci0_req->number_of_dci++; +#if 0 // 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)); @@ -2163,6 +2191,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, 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); +#endif // 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); From 44210a0a88eb761a9f5527f6bf88c56727dbec4d Mon Sep 17 00:00:00 2001 From: Masayuki HARADA Date: Thu, 24 May 2018 13:21:37 +0900 Subject: [PATCH 87/91] Fix PUSCH decode failure when recieve power is too high situation. --- .../PHY/LTE_TRANSPORT/ulsch_demodulation.c | 24 ++++++++++--------- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 3 +++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index 93c1af8d91..93f92062ea 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -1035,6 +1035,11 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, +#if defined(__x86_64__) || defined(__i386__) +__m128 avg128U; +#elif defined(__arm__) +int32x4_t avg128U; +#endif void ulsch_channel_level(int32_t **drs_ch_estimates_ext, LTE_DL_FRAME_PARMS *frame_parms, @@ -1045,24 +1050,21 @@ void ulsch_channel_level(int32_t **drs_ch_estimates_ext, int16_t rb; uint8_t aarx; #if defined(__x86_64__) || defined(__i386__) - __m128i avg128U; __m128i *ul_ch128; #elif defined(__arm__) int16x4_t *ul_ch128; - int32x4_t avg128U; #endif - for (aarx=0; aarxnb_antennas_rx; aarx++) { //clear average level #if defined(__x86_64__) || defined(__i386__) - avg128U = _mm_setzero_si128(); + avg128U = _mm_setzero_ps(); ul_ch128=(__m128i *)drs_ch_estimates_ext[aarx]; for (rb=0; rbUE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], ul_cqi); + if(ul_cqi>200){ // too high energy pattern + UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = 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)); From a37c29eb80fe3c3d04bb564b1ff840c79448e8f8 Mon Sep 17 00:00:00 2001 From: Wu Jing Date: Thu, 24 May 2018 16:44:28 +0900 Subject: [PATCH 88/91] fix rm971 bug(delete #if 0) --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 51 ----------------------- 1 file changed, 51 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 59e890fe72..79f8e8b0d6 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1618,35 +1618,6 @@ schedule_ulsch_rnti(module_id_t module_idP, T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), T_INT(round)); -#if 0 - // fill in NAK information - - 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)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; - hi_dci0_pdu->pdu_size = - 2 + sizeof(nfapi_hi_dci0_hi_pdu); - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = - UE_template->first_rb_ul[harq_pid]; - 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_body->number_of_hi++; - hi_dci0_req_body->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); - hi_dci0_req->sfn_sf = frameP<<4|subframeP; - 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], - UE_template->first_rb_ul[harq_pid], - UE_template->nb_rb_ul[harq_pid], - UE_template->TBS_UL[harq_pid], round); -#endif // 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", @@ -2170,28 +2141,6 @@ void schedule_ulsch_rnti(module_id_t module_idP, hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; hi_dci0_req->number_of_dci++; -#if 0 - // 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)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_hi_pdu); - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; - 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,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); -#endif // 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); From ab32cefbe23fa36393003b6663da26b3fdc8801d Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Thu, 24 May 2018 20:01:37 +0900 Subject: [PATCH 89/91] Revert "fix DLSCH no retransmission" This reverts commit 24c669f394ee8290a8118b9e2d1053fc2d1d1233. --- openair1/SCHED/phy_procedures_lte_eNb.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 3ab8f9ce04..da636a9635 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1069,14 +1069,6 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) harq_ack[0] = 0; } uci->stat = metric[0]; - if(harq_ack[0] != 1){ - LOG_E(PHY,"PUCCH ACK/NACK(SR): frame %d subframe %d rnti %x n_pucch_1_0_sr[0] %d pucch_fmt %d harq_ack[0]:%d -> 1\n ", - frame,subframe,uci->rnti,uci->n_pucch_1_0_sr[0],uci->pucch_fmt,harq_ack[0]); - harq_ack[0] =1; - }else{ - LOG_E(PHY,"PUCCH ACK/NACK(SR): frame %d subframe %d rnti %x n_pucch_1_0_sr[0] %d pucch_fmt %d\n ", - frame,subframe,uci->rnti,uci->n_pucch_1_0_sr[0],uci->pucch_fmt); - } fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,2,0xffff); // special_bundling mode } else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==2)){ // multiplexing + no SR, implement Table 10.1.3-5 (Rel14) for multiplexing with M=2 @@ -1344,14 +1336,6 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) harq_ack[0] = pucch_b0b1[0][0]; harq_ack[1] = pucch_b0b1[0][1]; uci->stat = metric[0]; - if(harq_ack[0] != 1){ - LOG_E(PHY,"PUCCH ACK/NACK(no SR): frame %d subframe %d rnti %x n_pucch_1[0][0] %d pucch_fmt %d harq_ack[0]:%d -> 1\n", - frame,subframe,uci->rnti,uci->n_pucch_1[0][0],uci->pucch_fmt,harq_ack[0]); - harq_ack[0] =1; - }else{ - LOG_E(PHY,"PUCCH ACK/NACK(no SR): frame %d subframe %d rnti %x n_pucch_1[0][0] %d pucch_fmt %d \n", - frame,subframe,uci->rnti,uci->n_pucch_1[0][0],uci->pucch_fmt); - } fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,0,0xffff); // special_bundling mode } From c652a883ffde103974c65f58bcefb8df011428fe Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Thu, 24 May 2018 20:08:27 +0900 Subject: [PATCH 90/91] Fix: TDD uci_procedures misdeal pucch format1a. --- openair1/SCHED/phy_procedures_lte_eNb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index da636a9635..f2ba478313 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -990,7 +990,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) if (uci->type==HARQ_SR && metric[0] <= metric_SR) { SR_payload = 1; metric[0] = rx_pucch(eNB, - pucch_format1b, + uci->pucch_fmt, i, uci->n_pucch_1_0_sr[0], 0, //n2_pucch @@ -1052,6 +1052,15 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) uci->rnti,uci->type,SR_payload,frame,subframe,pucch_b0b1[0][0],pucch_b0b1[0][1],pucch_b0b1[1][0],pucch_b0b1[1][1]); #endif #endif + + if(uci->pucch_fmt == pucch_format1a) { + LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d pucch1a (TDD) payload %d (metric %d)\n", + eNB->Mod_id,uci->rnti,frame,subframe,pucch_b0b1[0][0],metric[0]); + + uci->stat = metric[0]; + fill_uci_harq_indication(eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff); + } + else if(uci->pucch_fmt == pucch_format1b) { 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 @@ -1351,6 +1360,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) AssertFatal(1==0,"Unsupported UCI type %d\n",uci->type); break; } + } if (SR_payload == 1) { LOG_D(PHY,"[eNB %d][SR %x] Frame %d subframe %d Got SR for PUSCH, transmitting to MAC\n",eNB->Mod_id, From 18bd37f9139dfca6f691260ba596c658fe07c6d2 Mon Sep 17 00:00:00 2001 From: Haruki NAOI Date: Tue, 29 May 2018 14:29:00 +0900 Subject: [PATCH 91/91] Revert "Fix: TDD uci_procedures misdeal pucch format1a." This reverts commit c652a883ffde103974c65f58bcefb8df011428fe. --- openair1/SCHED/phy_procedures_lte_eNb.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index f2ba478313..da636a9635 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -990,7 +990,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) if (uci->type==HARQ_SR && metric[0] <= metric_SR) { SR_payload = 1; metric[0] = rx_pucch(eNB, - uci->pucch_fmt, + pucch_format1b, i, uci->n_pucch_1_0_sr[0], 0, //n2_pucch @@ -1052,15 +1052,6 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) uci->rnti,uci->type,SR_payload,frame,subframe,pucch_b0b1[0][0],pucch_b0b1[0][1],pucch_b0b1[1][0],pucch_b0b1[1][1]); #endif #endif - - if(uci->pucch_fmt == pucch_format1a) { - LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d pucch1a (TDD) payload %d (metric %d)\n", - eNB->Mod_id,uci->rnti,frame,subframe,pucch_b0b1[0][0],metric[0]); - - uci->stat = metric[0]; - fill_uci_harq_indication(eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff); - } - else if(uci->pucch_fmt == pucch_format1b) { 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 @@ -1360,7 +1351,6 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) AssertFatal(1==0,"Unsupported UCI type %d\n",uci->type); break; } - } if (SR_payload == 1) { LOG_D(PHY,"[eNB %d][SR %x] Frame %d subframe %d Got SR for PUSCH, transmitting to MAC\n",eNB->Mod_id,