diff --git a/openair1/PHY/CODING/3gpplte_sse.c b/openair1/PHY/CODING/3gpplte_sse.c index 96dbcc371711c709a0035ce8ddcea3321d6bce23..fdcc0e41325256e8798ff24e0d38babac3e8a3cc 100644 --- a/openair1/PHY/CODING/3gpplte_sse.c +++ b/openair1/PHY/CODING/3gpplte_sse.c @@ -213,7 +213,7 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns 0b00000010, 0b00000001}; #endif - + #ifndef __AVX2__ if ((n&15) > 0) @@ -226,9 +226,9 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns for (i=0; i<loop ; i++ ) { - // int cur_byte=i<<3; - // for (b=0;b<8;b++) - // expandInput[cur_byte+b] = (input[i]&(1<<(7-b)))>>(7-b); + // int cur_byte=i<<3; + // for (b=0;b<8;b++) + // expandInput[cur_byte+b] = (input[i]&(1<<(7-b)))>>(7-b); #if defined(__x86_64__) || defined(__i386__) #ifndef __AVX2__ @@ -317,8 +317,8 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns tmp3=_mm256_unpackhi_epi16(tmp2,tmp2); // tmp3 = B12 B13 B14 B15 B28 B29 B30 B31 tmp4=_mm256_unpacklo_epi32(tmp3,tmp3); // tmp4 = B12 B13 B28 B29 - tmp5=_mm256_unpackhi_epi32(tmp3,tmp3); // tmp5 = B14 B15 B30 B31 - tmp6=_mm256_insertf128_si256(tmp4,_mm256_extracti128_si256(tmp5,0),1); // tmp6 = B12 B13 B14 B15 + tmp5=_mm256_unpackhi_epi32(tmp3,tmp3); // tmp5 = B14 B15 B30 B31 + tmp6=_mm256_insertf128_si256(tmp4,_mm256_extracti128_si256(tmp5,0),1); // tmp6 = B12 B13 B14 B15 tmp7=_mm256_insertf128_si256(tmp5,_mm256_extracti128_si256(tmp4,1),0); // tmp7 = B28 B29 B30 B31 //print_bytes2("tmp2",(uint8_t*)&tmp2); //print_bytes2("tmp3",(uint8_t*)&tmp3); @@ -368,7 +368,7 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns //print_bytes("tmp4:",(uint8_t*)&tmp4); *o_128++=vceqq_u8(vandq_u8((uint8x16_t)tmp4,BIT_MASK),BIT_MASK); //4 - //and_tmp = vandq_u8((uint8x16_t)tmp4,BIT_MASK); print_bytes("and:",and_tmp); + //and_tmp = vandq_u8((uint8x16_t)tmp4,BIT_MASK); print_bytes("and:",and_tmp); //print_bytes("o:",(uint8_t*)(o_128-1)); @@ -408,7 +408,7 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns i_128++; #endif } - + short * ptr_intl=base_interleaver; #if defined(__x86_64) || defined(__i386__) @@ -421,7 +421,7 @@ char interleave_compact_byte(short * base_interleaver,unsigned char * input, uns #endif #elif defined(__arm__) uint8x16_t tmp; - const uint8_t __attribute__ ((aligned (16))) _Powers[16]= + const uint8_t __attribute__ ((aligned (16))) _Powers[16]= { 1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128 }; // Set the powers of 2 (do it once for all, if applicable) @@ -568,7 +568,7 @@ void threegpplte_turbo_encoder_sse(unsigned char *input, #if defined(__x86_64__) || defined(__i386__) __m64 *ptr_output=(__m64*) output; #elif defined(__arm__) - uint8x8_t *ptr_output=(uint8x8_t*)output; + uint8x8_t *ptr_output=(uint8x8_t*)output; #endif unsigned char cur_s1, cur_s2; int code_rate; @@ -587,14 +587,14 @@ void threegpplte_turbo_encoder_sse(unsigned char *input, *ptr_output++ = _mm_add_pi8(all_treillis[state0][cur_s1].systematic_andp1_64[code_rate], all_treillis[state1][cur_s2].parity2_64[code_rate]); - - + + #elif defined(__arm__) *ptr_output++ = vadd_u8(all_treillis[state0][cur_s1].systematic_andp1_64[code_rate], all_treillis[state0][cur_s1].parity2_64[code_rate]); #endif } - + state0=all_treillis[state0][cur_s1].exit_state; state1=all_treillis[state1][cur_s2].exit_state; } @@ -638,11 +638,11 @@ void threegpplte_turbo_encoder_sse(unsigned char *input, } void init_encoder_sse (void) { - treillis_table_init(); + treillis_table_init(); } /* function which will be called by the shared lib loader, to check shared lib version against main exec version. version mismatch no considered as fatal (interfaces not supposed to change) -*/ +*/ int coding_checkbuildver(char * mainexec_buildversion, char ** shlib_buildversion) { #ifndef PACKAGE_VERSION @@ -657,7 +657,7 @@ int coding_checkbuildver(char * mainexec_buildversion, char ** shlib_buildversi } #ifdef TC_MAIN -#define INPUT_LENGTH 20 +#define INPUT_LENGTH 20 #define F1 21 #define F2 120 diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index b3925060953332ec506afba59a6a2a371dc2315b..931335cbb05cd75c138ccfe3979066012a688ae9 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -142,6 +142,8 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0]; NR_DL_gNB_HARQ_t **harq = dlsch->harq_processes; + dlsch->harq_ids[subframe] = pdu_rel15->harq_pid; //New addition + uint16_t N_RB = params_rel15->n_RB_BWP; uint8_t fsize=0, pos=0, cand_idx=0; @@ -169,12 +171,12 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); pos=fsize; - *dci_pdu |= ((pdu_rel15->frequency_domain_assignment&((1<<fsize)-1)) << (dci_alloc->size-pos)); + *dci_pdu |= ((pdu_rel15->frequency_domain_assignment&((1<<fsize)-1)) << (dci_alloc->size-pos)); #ifdef DEBUG_FILL_DCI printf("frequency-domain assignment %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->frequency_domain_assignment,fsize,dci_alloc->size-pos,*dci_pdu); #endif // Time domain assignment - pos+=4; + pos+=4; *dci_pdu |= (((uint64_t)pdu_rel15->time_domain_assignment&0xf) << (dci_alloc->size-pos)); #ifdef DEBUG_FILL_DCI printf("time-domain assignment %d (3 bits)=> %d (0x%lx)\n",pdu_rel15->time_domain_assignment,dci_alloc->size-pos,*dci_pdu); @@ -233,22 +235,22 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // UL/SUL indicator 1 bit pos++; *dci_pdu |= (pdu_rel15->ul_sul_indicator&1)<<(dci_alloc->size-pos); - + // SS/PBCH index 6 bits pos+=6; *dci_pdu |= ((pdu_rel15->ss_pbch_index&0x3f)<<(dci_alloc->size-pos)); - + // prach_mask_index 4 bits pos+=4; *dci_pdu |= ((pdu_rel15->prach_mask_index&0xf)<<(dci_alloc->size-pos)); - + } //end if else { // Time domain assignment 4bit - pos+=4; + pos+=4; *dci_pdu |= ((pdu_rel15->time_domain_assignment&0xf) << (dci_alloc->size-pos)); #ifdef DEBUG_FILL_DCI printf("Time domain assignment %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->time_domain_assignment,4,dci_alloc->size-pos,*dci_pdu); @@ -273,7 +275,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, *dci_pdu |= (pdu_rel15->ndi&1)<<(dci_alloc->size-pos); #ifdef DEBUG_FILL_DCI printf("NDI %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->ndi,1,dci_alloc->size-pos,*dci_pdu); -#endif +#endif // Redundancy version 2bit pos+=2; @@ -321,7 +323,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, break; case NFAPI_NR_RNTI_P: - + // Short Messages Indicator – 2 bits for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->short_messages_indicator>>(1-i))&1)<<(dci_alloc->size-pos++); @@ -338,7 +340,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // VRB to PRB mapping 1 bit *dci_pdu |= ((uint64_t)pdu_rel15->vrb_to_prb_mapping&1)<<(dci_alloc->size-pos++); // MCS 5 bit - for (int i=0; i<5; i++) + for (int i=0; i<5; i++) *dci_pdu |= (((uint64_t)pdu_rel15->mcs>>(4-i))&1)<<(dci_alloc->size-pos++); // TB scaling 2 bit @@ -347,7 +349,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, break; - + case NFAPI_NR_RNTI_SI: // Freq domain assignment 0-16 bit fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); @@ -364,9 +366,9 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // Redundancy version 2bit for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++); - + break; - + case NFAPI_NR_RNTI_TC: // indicating a DL DCI format 1bit *dci_pdu |= ((uint64_t)pdu_rel15->format_indicator&1)<<(dci_alloc->size-pos++); @@ -387,14 +389,14 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // Redundancy version 2bit for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++); - // HARQ process number 4bit + // HARQ process number 4bit for (int i=0; i<4; i++) *dci_pdu |= (((uint64_t)pdu_rel15->harq_pid>>(3-i))&1)<<(dci_alloc->size-pos++); - + // Downlink assignment index – 2 bits for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->dai>>(1-i))&1)<<(dci_alloc->size-pos++); - + // TPC command for scheduled PUCCH – 2 bits for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->tpc>>(1-i))&1)<<(dci_alloc->size-pos++); @@ -407,7 +409,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // PDSCH-to-HARQ_feedback timing indicator – 3 bits for (int i=0; i<3; i++) *dci_pdu |= (((uint64_t)pdu_rel15->pdsch_to_harq_feedback_timing_indicator>>(2-i))&1)<<(dci_alloc->size-pos++); - + break; } break; @@ -435,10 +437,10 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // Redundancy version 2bit for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++); - // HARQ process number 4bit + // HARQ process number 4bit for (int i=0; i<4; i++) *dci_pdu |= (((uint64_t)pdu_rel15->harq_pid>>(3-i))&1)<<(dci_alloc->size-pos++); - + // TPC command for scheduled PUSCH – 2 bits for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->tpc>>(1-i))&1)<<(dci_alloc->size-pos++); @@ -450,11 +452,11 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // UL/SUL indicator – 1 bit if (cfg->pucch_config.pucch_GroupHopping.value) *dci_pdu |= ((uint64_t)pdu_rel15->ul_sul_indicator&1)<<(dci_alloc->size-pos++); - + break; - + case NFAPI_NR_RNTI_TC: - + // indicating a DL DCI format 1bit *dci_pdu |= (pdu_rel15->format_indicator&1)<<(dci_alloc->size-pos++); // Freq domain assignment max 16 bit @@ -474,7 +476,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // Redundancy version 2bit for (int i=0; i<2; i++) *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++); - // HARQ process number 4bit + // HARQ process number 4bit for (int i=0; i<4; i++) *dci_pdu |= (((uint64_t)pdu_rel15->harq_pid>>(3-i))&1)<<(dci_alloc->size-pos++); @@ -491,7 +493,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, *dci_pdu |= ((uint64_t)pdu_rel15->ul_sul_indicator&1)<<(dci_alloc->size-pos++); break; - } + } break; } diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index d663a95c358c0da965b11aa41c7ff318a7904e28..9c435ef2876a7b7e27621ad0bc9950771ff6b347 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -53,6 +53,44 @@ void handle_nr_nfapi_bch_pdu(PHY_VARS_gNB *gNB, // adjust transmit amplitude here based on NFAPI info } +void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int subframe,gNB_L1_rxtx_proc_t *proc, + uint8_t codeword_index, + uint8_t *sdu) +{ + + int UE_id = 0; //Hardcode UE_id for now + int harq_pid; + + NR_gNB_DLSCH_t *dlsch0=NULL, *dlsch1=NULL; + NR_DL_gNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; + + // Based on nr_fill_dci_and_dlsch only gNB->dlsch[0][0] gets filled now. So maybe we do not need dlsch1. + dlsch0 = gNB->dlsch[UE_id][0]; + dlsch1 = gNB->dlsch[UE_id][1]; + + harq_pid = dlsch0->harq_ids[subframe]; + dlsch0_harq = dlsch0->harq_processes[harq_pid]; + dlsch1_harq = dlsch1->harq_processes[harq_pid]; + + + //if (dlsch0_harq->round==0) { //get pointer to SDU if this a new SDU + if(sdu == NULL) { + LOG_E(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0 \n", + frame,subframe, + proc->frame_tx,proc->slot_tx); + return; + } + //AssertFatal(sdu!=NULL,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", + // frame,subframe, + // proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start); + if (codeword_index == 0) dlsch0_harq->pdu = sdu; + else dlsch1_harq->pdu = sdu; + LOG_I(PHY, "dlsch PDU filled \n"); +// } + +} + void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB, int frame, int slot, @@ -94,7 +132,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ nfapi_nr_dl_config_request_pdu_t *dl_config_pdu; nfapi_nr_dl_config_request_pdu_t *dl_config_dlsch_pdu; - + int i; 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", @@ -129,7 +167,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ break; case NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE: - dl_config_dlsch_pdu = &DL_req->dl_config_request_body.dl_config_pdu_list[++i]; + dl_config_dlsch_pdu = &DL_req->dl_config_request_body.dl_config_pdu_list[i+1]; handle_nfapi_nr_dci_dl_pdu(gNB, frame, slot, proc, @@ -139,9 +177,20 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ gNB->pdcch_vars.num_pdsch_rnti++; do_oai=1; break; + + case NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE: + + //gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; + //TX_req = TX_req->tx_request_body.tx_pdu_list[TX_req->tx_request_body.number_of_pdus].segments[0].segment_data; + LOG_I(PHY, "Before calling handle_nr_nfapi_dlsch_pdu() \n \n \n \n"); + handle_nr_nfapi_dlsch_pdu(gNB, frame,slot,proc, + 0, + TX_req->tx_request_body.tx_pdu_list[TX_req->tx_request_body.number_of_pdus].segments[0].segment_data); + + break; } } - + if (nfapi_mode && do_oai && !dont_send) { oai_nfapi_tx_req(Sched_INFO->TX_req); diff --git a/openair1/SCHED_NR/fapi_nr_l1.h b/openair1/SCHED_NR/fapi_nr_l1.h index 71ef6039f3a06a2e8c54ba1516273abdd1ed71fe..ff11f7533900f4cc6f2a389ce64ec3fcfc2d8ae6 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.h +++ b/openair1/SCHED_NR/fapi_nr_l1.h @@ -41,3 +41,6 @@ void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB, gNB_L1_rxtx_proc_t *proc, nfapi_nr_dl_config_request_pdu_t *dl_config_pdu, nfapi_nr_dl_config_request_pdu_t *dl_config_dlsch_pdu); +void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int subframe,gNB_L1_rxtx_proc_t *proc, + uint8_t codeword_index, + uint8_t *sdu); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 02c27930d3a462e22f8835123cdd75a3f972fad7..d1a80395e052184a320f9d29a6c604e6e488c3ad 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -70,9 +70,9 @@ extern uint8_t nfapi_mode; uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; -void clear_nr_nfapi_information(gNB_MAC_INST * gNB, +void clear_nr_nfapi_information(gNB_MAC_INST * gNB, int CC_idP, - frame_t frameP, + frame_t frameP, sub_frame_t slotP){ nfapi_nr_dl_config_request_t *DL_req = &gNB->DL_req[0]; @@ -102,10 +102,10 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, } } /* -void check_nr_ul_failure(module_id_t module_idP, - int CC_id, +void check_nr_ul_failure(module_id_t module_idP, + int CC_id, int UE_id, - frame_t frameP, + frame_t frameP, sub_frame_t slotP) { UE_list_t *UE_list = &RC.nrmac[module_idP]->UE_list; @@ -191,13 +191,13 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram uint8_t TSFC; uint16_t deltaTSFC; // bitmap uint8_t srs_SubframeConfig; - + // table for TSFC (Period) and deltaSFC (offset) const uint16_t deltaTSFCTabType1[15][2] = { {1, 1}, {1, 2}, {2, 2}, {1, 5}, {2, 5}, {4, 5}, {8, 5}, {3, 5}, {12, 5}, {1, 10}, {2, 10}, {4, 10}, {8, 10}, {351, 10}, {383, 10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD const uint16_t deltaTSFCTabType2[14][2] = { {2, 5}, {6, 5}, {10, 5}, {18, 5}, {14, 5}, {22, 5}, {26, 5}, {30, 5}, {70, 10}, {74, 10}, {194, 10}, {326, 10}, {586, 10}, {210, 10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD - + uint16_t srsPeriodicity, srsOffset; - + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { soundingRS_UL_ConfigCommon = &cc[CC_id].radioResourceConfigCommon->soundingRS_UL_ConfigCommon; // check if SRS is enabled in this frame/subframe @@ -212,7 +212,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram } // Sounding reference signal subframes are the subframes satisfying ns/2 mod TSFC (- deltaTSFC uint16_t tmp = (subframeP % TSFC); - + if ((1 << tmp) & deltaTSFC) { // This is an SRS subframe, loop over UEs for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) { @@ -220,11 +220,11 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram ul_req = &RC.nrmac[module_idP]->UL_req[CC_id].ul_config_request_body; // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue; - + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n", UE_id); - + if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated) != NULL) { if (soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) { get_srs_pos(&cc[CC_id], @@ -256,7 +256,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram } // if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) } // for (UE_id ... } // if((1<<tmp) & deltaTSFC) - + } // SRS config } } @@ -290,7 +290,7 @@ void copy_nr_ulreq(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) } } -void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, +void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ protocol_ctxt_t ctxt; @@ -331,13 +331,15 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, coreset, frameP, slotP, - *cfg)) + *cfg)){ + LOG_I(MAC, "About to call nr_schedule_uss_dlsch_phytest() because there is a dci opportunity... \n \n \n"); nr_schedule_uss_dlsch_phytest(module_idP, frameP, slotP); + } rnti = UE_RNTI(module_idP, i); CC_id = UE_PCCID(module_idP, i); //int spf = get_spf(cfg); - + if (((frameP&127) == 0) && (slotP == 0)) { LOG_I(MAC, "UE rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n", @@ -349,32 +351,32 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 128) / 2, (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 128) / 2); } - + RC.gNB[module_idP][CC_id]->pusch_stats_bsr[i][to_absslot(cfg,frameP,slotP)] = -63; - + if (i == UE_list->head) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,RC.gNB[module_idP][CC_id]-> pusch_stats_bsr[i][to_absslot(cfg,frameP,slotP)]); - + // increment this, it is cleared when we receive an sdu RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer++; RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer++; - - LOG_D(MAC, "UE %d/%x : ul_inactivity %d, cqi_req %d\n", - i, + + LOG_D(MAC, "UE %d/%x : ul_inactivity %d, cqi_req %d\n", + i, rnti, RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].ul_inactivity_timer, RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].cqi_req_timer); - + //check_nr_ul_failure(module_idP, CC_id, i, frameP, subframeP); - + if (RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer > 0) { RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer++; - + if(RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer >= RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer_thres) { RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer = 0; - + for (int ue_id_l = 0; ue_id_l < MAX_MOBILES_PER_GNB; ue_id_l++) { if (reestablish_rnti_map[ue_id_l][0] == rnti) { // clear currentC-RNTI from map @@ -383,10 +385,10 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, break; } } - + // Note: This should not be done in the MAC! for (int ii=0; ii<MAX_MOBILES_PER_GNB; ii++) { - NR_gNB_ULSCH_t *ulsch = RC.gNB[module_idP][CC_id]->ulsch[ii][0]; + NR_gNB_ULSCH_t *ulsch = RC.gNB[module_idP][CC_id]->ulsch[ii][0]; if((ulsch != NULL) && (ulsch->rnti == rnti)){ LOG_W(MAC, "TODO: clean_eNb_ulsch UE %x \n", rnti); clean_gNB_ulsch(ulsch); @@ -400,7 +402,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, clean_gNB_dlsch(dlsch); } } - + for(int j = 0; j < 10; j++){ nfapi_ul_config_request_body_t *ul_req_tmp = NULL; ul_req_tmp = &RC.nrmac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body; @@ -422,9 +424,9 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, } //END if (RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer > 0) } //END if (UE_list->active[i]) } //END for (i = 0; i < MAX_MOBILES_PER_GNB; i++) - + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES,NOT_A_RNTI, frameP, slotP,module_idP); - + pdcp_run(&ctxt); //rrc_rx_tx(&ctxt, CC_id); @@ -439,8 +441,10 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, /*if (slotP==2) nr_schedule_css_dlsch_phytest(module_idP, frameP, slotP);*/ - if (slotP==1) + if (slotP==1){ + LOG_I(MAC, "About to call nr_schedule_uss_dlsch_phytest() because we are on slotP=1... \n \n \n"); nr_schedule_uss_dlsch_phytest(module_idP, frameP, slotP); + } /* // Allocate CCEs for good after scheduling is done @@ -449,6 +453,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); */ - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index ce18158f186dd59c186b0c9d7ad89de37965531e..725625c688798f32ffe4bd1e31e83f452acd36f5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -104,7 +104,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, pdu_rel15->vrb_to_prb_mapping = 1; pdu_rel15->mcs = 9; pdu_rel15->tb_scaling = 1; - + pdu_rel15->ra_preamble_index = 25; pdu_rel15->format_indicator = 1; pdu_rel15->ndi = 1; @@ -177,16 +177,17 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, nr_mac->TX_req[CC_id].sfn_sf = sfn_sf; nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; - + } } -/*Scheduling of DLSCH with associated DCI in user specific search space - * current version has only a DCI for type 1 PDCCH for C_RNTI*/ + + void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) { + LOG_I(MAC, "In nr_schedule_uss_dlsch_phytest \n"); uint8_t CC_id; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; @@ -205,100 +206,287 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, // everything here is hard-coded to 30 kHz //int scs = get_dlscs(cfg); //int slots_per_frame = get_spf(cfg); - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - LOG_I(MAC, "Scheduling UE specific search space DCI type 1 for CC_id %d\n",CC_id); - nfapi_nr_coreset_t* coreset = &nr_mac->coreset[CC_id][1]; - nfapi_nr_search_space_t* search_space = &nr_mac->search_space[CC_id][1]; - dl_req = &nr_mac->DL_req[CC_id].dl_config_request_body; - dl_config_dci_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_dci_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); - dl_config_dci_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_dci_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dci_dl_pdu)); + //Connection with the LTE protocol stack + /* int ta_len = 0; + unsigned char sdu_lcids[NB_RB_MAX]; + int lcid, offset, num_sdus = 0; + int nb_rb, nb_rb_temp, nb_available_rb; + uint16_t sdu_lengths[NB_RB_MAX]; + int TBS, j, rnti, padding = 0, post_padding = 0; + unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; + int sdu_length_total = 0; + */ + + int TBS; + int lcid; + int ta_len = 0; + UE_sched_ctrl *ue_sched_ctl; + int header_length_total=0; + int header_length_last; + int sdu_length_total = 0; + mac_rlc_status_resp_t rlc_status; + uint16_t sdu_lengths[NB_RB_MAX]; + int num_sdus = 0; + unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; + int offset; + int UE_id; + unsigned char sdu_lcids[NB_RB_MAX]; + int padding = 0, post_padding = 0; + UE_list_t *UE_list = &nr_mac->UE_list; + + DLSCH_PDU DLSCH_pdu; + //DLSCH_PDU *DLSCH_pdu = (DLSCH_PDU*) malloc(sizeof(DLSCH_PDU)); + memset(&DLSCH_pdu, 0, sizeof(DLSCH_pdu)); - dl_config_dlsch_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu+1]; - memset((void*)dl_config_dlsch_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); - dl_config_dlsch_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_dlsch_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dlsch_pdu)); - nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_dci_pdu->dci_dl_pdu.dci_dl_pdu_rel15; - nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_dci_pdu->dci_dl_pdu.pdcch_params_rel15; - nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15; - - dlsch_pdu_rel15->start_prb = 0; - dlsch_pdu_rel15->n_prb = 50; - dlsch_pdu_rel15->start_symbol = 2; - dlsch_pdu_rel15->nb_symbols = 9; - dlsch_pdu_rel15->rnti = rnti; - dlsch_pdu_rel15->nb_layers =1; - dlsch_pdu_rel15->nb_codewords = 1; - dlsch_pdu_rel15->mcs_idx = 9; - dlsch_pdu_rel15->ndi = 1; - dlsch_pdu_rel15->redundancy_version = 0; - - nr_configure_dci_from_pdcch_config(params_rel15, - coreset, - search_space, - *cfg, - dl_carrier_bandwidth); - - pdu_rel15->frequency_domain_assignment = get_RIV(dlsch_pdu_rel15->start_prb, dlsch_pdu_rel15->n_prb, cfg->rf_config.dl_carrier_bandwidth.value); - pdu_rel15->time_domain_assignment = 3; // row index used here instead of SLIV; - pdu_rel15->vrb_to_prb_mapping = 1; - pdu_rel15->mcs = 9; - pdu_rel15->tb_scaling = 1; - - pdu_rel15->ra_preamble_index = 25; - pdu_rel15->format_indicator = 1; - pdu_rel15->ndi = 1; - pdu_rel15->rv = 0; - pdu_rel15->harq_pid = 0; - pdu_rel15->dai = 2; - pdu_rel15->tpc = 2; - pdu_rel15->pucch_resource_indicator = 7; - pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7; + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + LOG_I(MAC, "Scheduling UE specific search space DCI type 1 for CC_id %d\n",CC_id); - LOG_I(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", - pdu_rel15->frequency_domain_assignment, - pdu_rel15->time_domain_assignment, - pdu_rel15->vrb_to_prb_mapping, - pdu_rel15->mcs, - pdu_rel15->tb_scaling, - pdu_rel15->ndi, - pdu_rel15->rv); + nfapi_nr_coreset_t* coreset = &nr_mac->coreset[CC_id][1]; + nfapi_nr_search_space_t* search_space = &nr_mac->search_space[CC_id][1]; - params_rel15->rnti = rnti; - params_rel15->rnti_type = NFAPI_NR_RNTI_C; - params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; - //params_rel15->aggregation_level = 1; - LOG_I(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d, config type %d\n \ - coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ - ss params : first symb %d, ss type %d\n", - params_rel15->rnti, - params_rel15->rnti_type, - params_rel15->config_type, - params_rel15->dci_format, - params_rel15->mux_pattern, - params_rel15->n_rb, - params_rel15->n_symb, - params_rel15->rb_offset, - params_rel15->first_symbol, - params_rel15->search_space_type); - nr_get_tbs(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu, *cfg); - LOG_I(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d\n", - dlsch_pdu_rel15->start_prb, - dlsch_pdu_rel15->n_prb, - dlsch_pdu_rel15->start_symbol, - dlsch_pdu_rel15->nb_symbols, - dlsch_pdu_rel15->nb_layers, - dlsch_pdu_rel15->nb_codewords, - dlsch_pdu_rel15->mcs_idx); + //for (UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { + LOG_I(MAC, "UE list loop \n"); + + //Not sure if TA update procedures are required at this point. Maybe we can skip + //lines 326-337 + + + /*ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + int ta_update; + 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;*/ + + int ta_update = 31; + ta_len = 0; + + + /*dl_req = &nr_mac->DL_req[CC_id].dl_config_request_body; + dl_config_dlsch_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu+1]; + + dl_config_dci_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + nr_get_tbs(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu, *cfg); + TBS = dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15.transport_block_size;*/ + + dl_req = &nr_mac->DL_req[CC_id].dl_config_request_body; + dl_config_dci_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void*)dl_config_dci_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); + dl_config_dci_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_dci_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dci_dl_pdu)); + + dl_config_dlsch_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu+1]; + memset((void*)dl_config_dlsch_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); + dl_config_dlsch_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_dlsch_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dlsch_pdu)); + + nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_dci_pdu->dci_dl_pdu.dci_dl_pdu_rel15; + nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_dci_pdu->dci_dl_pdu.pdcch_params_rel15; + nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15; + + dlsch_pdu_rel15->start_prb = 0; + dlsch_pdu_rel15->n_prb = 50; + dlsch_pdu_rel15->start_symbol = 2; + dlsch_pdu_rel15->nb_symbols = 9; + dlsch_pdu_rel15->rnti = rnti; + dlsch_pdu_rel15->nb_layers =1; + dlsch_pdu_rel15->nb_codewords = 1; + dlsch_pdu_rel15->mcs_idx = 9; + dlsch_pdu_rel15->ndi = 1; + dlsch_pdu_rel15->redundancy_version = 0; + + nr_configure_dci_from_pdcch_config(params_rel15, + coreset, + search_space, + *cfg, + dl_carrier_bandwidth); + + pdu_rel15->frequency_domain_assignment = get_RIV(dlsch_pdu_rel15->start_prb, dlsch_pdu_rel15->n_prb, cfg->rf_config.dl_carrier_bandwidth.value); + pdu_rel15->time_domain_assignment = 3; // row index used here instead of SLIV; + pdu_rel15->vrb_to_prb_mapping = 1; + pdu_rel15->mcs = 9; + pdu_rel15->tb_scaling = 1; + + pdu_rel15->ra_preamble_index = 25; + pdu_rel15->format_indicator = 1; + pdu_rel15->ndi = 1; + pdu_rel15->rv = 0; + pdu_rel15->harq_pid = 0; + pdu_rel15->dai = 2; + pdu_rel15->tpc = 2; + pdu_rel15->pucch_resource_indicator = 7; + pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7; + + LOG_I(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n", + pdu_rel15->frequency_domain_assignment, + pdu_rel15->time_domain_assignment, + pdu_rel15->vrb_to_prb_mapping, + pdu_rel15->mcs, + pdu_rel15->tb_scaling, + pdu_rel15->ndi, + pdu_rel15->rv); + + params_rel15->rnti = rnti; + params_rel15->rnti_type = NFAPI_NR_RNTI_C; + params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; + + //params_rel15->aggregation_level = 1; + LOG_I(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d, config type %d\n \ + coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ + ss params : first symb %d, ss type %d\n", + params_rel15->rnti, + params_rel15->rnti_type, + params_rel15->config_type, + params_rel15->dci_format, + params_rel15->mux_pattern, + params_rel15->n_rb, + params_rel15->n_symb, + params_rel15->rb_offset, + params_rel15->first_symbol, + params_rel15->search_space_type); + nr_get_tbs(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu, *cfg); + TBS = dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15.transport_block_size; + LOG_I(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d\n", + dlsch_pdu_rel15->start_prb, + dlsch_pdu_rel15->n_prb, + dlsch_pdu_rel15->start_symbol, + dlsch_pdu_rel15->nb_symbols, + dlsch_pdu_rel15->nb_layers, + dlsch_pdu_rel15->nb_codewords, + dlsch_pdu_rel15->mcs_idx); + + dl_req->number_dci++; + dl_req->number_pdsch_rnti++; + dl_req->number_pdu+=2; + + for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { + // TODO: check if the lcid is active + + LOG_I(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_length_total - sdu_length_total - 3); + + if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + slotP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_length_total - sdu_length_total - 3 + #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,0, 0 + #endif + ); + + if (rlc_status.bytes_in_buffer > 0) { + LOG_I(MAC, + "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n \n", + module_idP, frameP, + TBS - ta_len - header_length_total - sdu_length_total - 3, + lcid, + header_length_total); + + 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] + #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,0, 0 + #endif + ); + + /* 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]++; + UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[num_sdus] = lcid; + UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[lcid] = sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; + + header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); + header_length_total += header_length_last; + + num_sdus++; + + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + } + } else { + // no TBS left + break; + } + } + + /* last header does not have length field */ + if (header_length_total) { + header_length_total -= header_length_last; + header_length_total++; + } + + + if (ta_len + sdu_length_total + header_length_total > 0) { + + + if (TBS - header_length_total - sdu_length_total - ta_len <= 2) { + padding = TBS - header_length_total - sdu_length_total - ta_len; + post_padding = 0; + } else { + padding = 0; + post_padding = 1; + } + + // Since we do not have an active UE_list for now we replace with a single DLSCH_pdu + /*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);*/ + + offset = generate_dlsch_header((unsigned char *) DLSCH_pdu.payload[0], + num_sdus, //num_sdus + sdu_lengths, // + sdu_lcids, 255, // no drx + ta_update, // timing advance + NULL, // contention res id + padding, post_padding); + + // Probably there should be other actions done before that + // cycle through SDUs and place in dlsch_buffer + + // Since we do not have an active UE_list for now we replace with a single DLSCH_pdu + //memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total); + memcpy(&DLSCH_pdu.payload[0][offset], dlsch_buffer, sdu_length_total); + + // fill remainder of DLSCH with 0 + for (int j = 0; j < (TBS - sdu_length_total - offset); j++) { + // Since we do not have an active UE_list for now we replace with a single DLSCH_pdu + //UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = 0; + DLSCH_pdu.payload[0][offset + sdu_length_total + j] = 0; + } - dl_req->number_dci++; - dl_req->number_pdsch_rnti++; - dl_req->number_pdu+=2; TX_req = &nr_mac->TX_req[CC_id].tx_request_body.tx_pdu_list[nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus]; TX_req->pdu_length = 6; @@ -315,10 +503,19 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, TX_req->pdu_index = nr_mac->pdu_index[CC_id]++; TX_req->num_segments = 1; TX_req->segments[0].segment_length = 8; + + // Since we do not have an active UE_list for now we replace with a single DLSCH_pdu + //TX_req->segments[0].segment_data = nr_mac->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0]; + TX_req->segments[0].segment_data = DLSCH_pdu.payload[0]; + nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus++; nr_mac->TX_req[CC_id].sfn_sf = sfn_sf; nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; - } + } //if (ta_len + sdu_length_total + header_length_total > 0) + + + //} //for (UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) + } //for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) } diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 7e6705d87f9c2ab161adf75c6c10fd207a4874f4..9f2e2baff4f02b699368b241728bd81296f1113a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -82,34 +82,34 @@ void mac_top_init_gNB(void) LOG_I(MAC, "[MAIN] Init function start:nb_nr_macrlc_inst=%d\n",RC.nb_nr_macrlc_inst); if (RC.nb_nr_macrlc_inst > 0) { - + RC.nrmac = (gNB_MAC_INST **) malloc16(RC.nb_nr_macrlc_inst *sizeof(gNB_MAC_INST *)); AssertFatal(RC.nrmac != NULL,"can't ALLOCATE %zu Bytes for %d gNB_MAC_INST with size %zu \n", RC.nb_nr_macrlc_inst * sizeof(gNB_MAC_INST *), RC.nb_nr_macrlc_inst, sizeof(gNB_MAC_INST)); - + for (i = 0; i < RC.nb_nr_macrlc_inst; i++) { RC.nrmac[i] = (gNB_MAC_INST *) malloc16(sizeof(gNB_MAC_INST)); AssertFatal(RC.nrmac != NULL,"can't ALLOCATE %zu Bytes for %d gNB_MAC_INST with size %zu \n", RC.nb_nr_macrlc_inst * sizeof(gNB_MAC_INST *), RC.nb_nr_macrlc_inst, sizeof(gNB_MAC_INST)); - + LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d gNB_MAC_INST @ %p\n",sizeof(gNB_MAC_INST), RC.nb_nr_macrlc_inst, RC.mac); bzero(RC.nrmac[i], sizeof(gNB_MAC_INST)); RC.nrmac[i]->Mod_id = i; - + for (j = 0; j < MAX_NUM_CCs; j++) { RC.nrmac[i]->DL_req[j].dl_config_request_body.dl_config_pdu_list = RC.nrmac[i]->dl_config_pdu_list[j]; RC.nrmac[i]->UL_req[j].ul_config_request_body.ul_config_pdu_list = RC.nrmac[i]->ul_config_pdu_list[j]; - + for (int k = 0; k < 10; k++) RC.nrmac[i]->UL_req_tmp[j][k].ul_config_request_body.ul_config_pdu_list =RC.nrmac[i]->ul_config_pdu_list_tmp[j][k]; - + RC.nrmac[i]->HI_DCI0_req[j].hi_dci0_request_body.hi_dci0_pdu_list = RC.nrmac[i]->hi_dci0_pdu_list[j]; RC.nrmac[i]->TX_req[j].tx_request_body.tx_pdu_list = RC.nrmac[i]->tx_request_pdu[j]; RC.nrmac[i]->ul_handle = 0; @@ -118,7 +118,7 @@ void mac_top_init_gNB(void) nr_init_coreset(&RC.nrmac[i]->coreset[j][1]); nr_init_search_space(&RC.nrmac[i]->search_space[j][1]); } - + }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) @@ -135,7 +135,7 @@ void mac_top_init_gNB(void) // Initialize Linked-List for Active UEs for (i = 0; i < RC.nb_nr_macrlc_inst; i++) { - + nrmac = RC.nrmac[i]; nrmac->if_inst = NR_IF_Module_init(i); @@ -152,6 +152,11 @@ void mac_top_init_gNB(void) UE_list->next[list_el] = -1; UE_list->next_ul[list_el] = -1; + /*memset(UE_list->DLSCH_pdu, 0, sizeof(UE_list->DLSCH_pdu)); + memset(UE_list->UE_template, 0, sizeof(UE_list->UE_template)); + memset(UE_list->eNB_UE_stats, 0, sizeof(UE_list->eNB_UE_stats)); + memset(UE_list->UE_sched_ctrl, 0, sizeof(UE_list->UE_sched_ctrl)); + memset(UE_list->active, 0, sizeof(UE_list->active));*/ } } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 05ddb4151f69513cb65b06d7aef3f91ec6315054..7ed0aa53a808319cf9c8c005851de5cf30206e00 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -126,6 +126,7 @@ boolean_t pdcp_data_req( T(T_ENB_PDCP_DL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_buffer_sizeP)); #endif + LOG_I(PDCP, "In pdcp_data_req \n \n"); if (sdu_buffer_sizeP == 0) { LOG_W(PDCP, "Handed SDU is of size 0! Ignoring...\n"); return FALSE; @@ -136,7 +137,7 @@ boolean_t pdcp_data_req( */ AssertFatal(sdu_buffer_sizeP<= MAX_IP_PACKET_SIZE,"Requested SDU size (%d) is bigger than that can be handled by PDCP (%u)!\n", sdu_buffer_sizeP, MAX_IP_PACKET_SIZE); - + if (modeP == PDCP_TRANSMISSION_MODE_TRANSPARENT) { AssertError (rb_idP < NB_RB_MBMS_MAX, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, NB_RB_MBMS_MAX, ctxt_pP->module_id, ctxt_pP->rnti); } else { @@ -162,7 +163,7 @@ boolean_t pdcp_data_req( // instance for a given RB is configured ctxt_pP->configured=TRUE; } - + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); } else { @@ -256,7 +257,7 @@ boolean_t pdcp_data_req( if (pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer((unsigned char*)pdcp_pdu_p->data, &pdu_header) == FALSE) { LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" Cannot fill PDU buffer with relevant header fields!\n", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p)); - + if (ctxt_pP->enb_flag == ENB_FLAG_YES) { stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].data_req); @@ -426,9 +427,9 @@ boolean_t pdcp_data_req( Pdcp_stats_tx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=current_sn; Pdcp_stats_tx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); - Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); + Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_tx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT); return ret; @@ -459,7 +460,7 @@ pdcp_data_ind( hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; uint8_t rb_offset= (srb_flagP == 0) ? DTCH -1 :0; - uint16_t pdcp_uid=0; + uint16_t pdcp_uid=0; uint8_t oo_flag=0; #if defined(LINK_ENB_PDCP_TO_GTPV1U) MessageDef *message_p = NULL; @@ -749,9 +750,9 @@ pdcp_data_ind( GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti; GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4; itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); - packet_forwarded = TRUE; + packet_forwarded = TRUE; } - + #else packet_forwarded = FALSE; #endif @@ -813,8 +814,8 @@ pdcp_data_ind( sdu_buffer_sizeP - payload_offset); list_add_tail_eurecom (new_sdu_p, sdu_list_p); - - + + } /* Print octets of incoming data in hexadecimal form */ @@ -823,33 +824,33 @@ pdcp_data_ind( sdu_buffer_sizeP - payload_offset); //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); //util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); - + /* * Update PDCP statistics * XXX Following two actions are identical, is there a merge error? */ - + for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ){ break; } - } - + } + Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); - + Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; - + if (oo_flag == 1 ) Pdcp_stats_rx_outoforder[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; - + Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; - + #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) else { AssertFatal(0, PROTOCOL_PDCP_CTXT_FMT" PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n", @@ -875,8 +876,8 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ uint16_t pdcp_uid = 0; uint8_t rb_id = 0; - - // these stats are measured for both eNB and UE on per seond basis + + // these stats are measured for both eNB and UE on per seond basis for (rb_id =0; rb_id < NB_RB_MAX; rb_id ++){ for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){ //printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe); @@ -892,11 +893,11 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ }else { Pdcp_stats_tx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; } - // reset the tmp vars + // reset the tmp vars Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; - + } if (Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 && pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ @@ -904,20 +905,20 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ Pdcp_stats_rx_goodput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8; Pdcp_stats_rx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; Pdcp_stats_rx_bytes_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; - + if(Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id] > 0){ Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]= (Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]/Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]); } else { Pdcp_stats_rx_aiat_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; } - - // reset the tmp vars + + // reset the tmp vars Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; - } + } } - + } } //----------------------------------------------------------------------------- @@ -927,7 +928,7 @@ pdcp_run ( ) //----------------------------------------------------------------------------- { - + if (ctxt_pP->enb_flag) { start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run); } else { @@ -935,10 +936,10 @@ pdcp_run ( } pdcp_enb[ctxt_pP->module_id].sfn++; // range: 0 to 18,446,744,073,709,551,615 - pdcp_enb[ctxt_pP->module_id].frame=ctxt_pP->frame; // 1023 + pdcp_enb[ctxt_pP->module_id].frame=ctxt_pP->frame; // 1023 pdcp_enb[ctxt_pP->module_id].subframe= ctxt_pP->subframe; pdcp_update_stats(ctxt_pP); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN); #if defined(ENABLE_ITTI) @@ -959,7 +960,7 @@ pdcp_run ( RRC_DCCH_DATA_REQ (msg_p).module_id, RRC_DCCH_DATA_REQ (msg_p).enb_flag, RRC_DCCH_DATA_REQ (msg_p).rnti, - RRC_DCCH_DATA_REQ (msg_p).frame, + RRC_DCCH_DATA_REQ (msg_p).frame, 0, RRC_DCCH_DATA_REQ (msg_p).eNB_index); LOG_I(PDCP, PROTOCOL_CTXT_FMT"Received %s from %s: instance %d, rb_id %d, muiP %d, confirmP %d, mode %d\n", @@ -1087,7 +1088,7 @@ pdcp_remove_UE( DRB_Identity_t drb_id = 0; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; - int i; + int i; // check and remove SRBs first for(int i = 0;i<MAX_MOBILES_PER_ENB;i++){ @@ -1122,7 +1123,7 @@ pdcp_remove_UE( break; } } - + return 1; } @@ -1141,7 +1142,7 @@ rrc_pdcp_config_asn1_req ( #if (RRC_VERSION >= MAKE_VERSION(9, 0, 0)) ,PMCH_InfoList_r9_t* const pmch_InfoList_r9_pP #endif - ,rb_id_t *const defaultDRB + ,rb_id_t *const defaultDRB ) //----------------------------------------------------------------------------- { @@ -1549,14 +1550,14 @@ pdcp_config_req_asn1 ( uint8_t *const kUPenc_pP) //----------------------------------------------------------------------------- { - + switch (actionP) { case CONFIG_ACTION_ADD: DevAssert(pdcp_pP != NULL); if (ctxt_pP->enb_flag == ENB_FLAG_YES) { pdcp_pP->is_ue = FALSE; pdcp_add_UE(ctxt_pP); - + //pdcp_eNB_UE_instance_to_rnti[ctxtP->module_id] = ctxt_pP->rnti; // pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti; if( srb_flagP == SRB_FLAG_NO ) { @@ -1922,14 +1923,14 @@ rrc_pdcp_config_req ( //----------------------------------------------------------------------------- - + int pdcp_module_init ( void ) //----------------------------------------------------------------------------- { - + #ifdef PDCP_USE_RT_FIFO int ret; @@ -2028,9 +2029,9 @@ void pdcp_layer_init(void) #endif pdcp_eNB_UE_instance_to_rnti[instance] = NOT_A_RNTI; } - pdcp_eNB_UE_instance_to_rnti_index = 0; + pdcp_eNB_UE_instance_to_rnti_index = 0; + - for (instance = 0; instance < NUMBER_OF_eNB_MAX; instance++) { #if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) @@ -2057,7 +2058,7 @@ void pdcp_layer_init(void) memset(pdcp_enb, 0, sizeof(pdcp_enb_t)); - + memset(Pdcp_stats_tx_window_ms, 0, sizeof(Pdcp_stats_tx_window_ms)); memset(Pdcp_stats_rx_window_ms, 0, sizeof(Pdcp_stats_rx_window_ms)); for (i =0; i< MAX_NUM_CCs ; i ++){ @@ -2066,7 +2067,7 @@ void pdcp_layer_init(void) Pdcp_stats_rx_window_ms[i][j]=100; } } - + memset(Pdcp_stats_tx, 0, sizeof(Pdcp_stats_tx)); memset(Pdcp_stats_tx_w, 0, sizeof(Pdcp_stats_tx_w)); memset(Pdcp_stats_tx_tmp_w, 0, sizeof(Pdcp_stats_tx_tmp_w)); @@ -2077,7 +2078,7 @@ void pdcp_layer_init(void) memset(Pdcp_stats_tx_throughput_w, 0, sizeof(Pdcp_stats_tx_throughput_w)); memset(Pdcp_stats_tx_aiat, 0, sizeof(Pdcp_stats_tx_aiat)); memset(Pdcp_stats_tx_iat, 0, sizeof(Pdcp_stats_tx_iat)); - + memset(Pdcp_stats_rx, 0, sizeof(Pdcp_stats_rx)); memset(Pdcp_stats_rx_w, 0, sizeof(Pdcp_stats_rx_w)); @@ -2090,7 +2091,111 @@ void pdcp_layer_init(void) memset(Pdcp_stats_rx_aiat, 0, sizeof(Pdcp_stats_rx_aiat)); memset(Pdcp_stats_rx_iat, 0, sizeof(Pdcp_stats_rx_iat)); memset(Pdcp_stats_rx_outoforder, 0, sizeof(Pdcp_stats_rx_outoforder)); - + + // Addition for the use-case of 4G stack on top of 5G-NR. + // We need to configure pdcp and rlc instances without having an actual + // UE RRC Connection. Just to be able to test the NR PHY with some injected + // on top of the LTE stack. + protocol_ctxt_t ctxt; + DRB_ToAddModList_t* DRB_configList=NULL; + DRB_configList = CALLOC(1, sizeof(DRB_ToAddModList_t)); + struct LogicalChannelConfig *DRB_lchan_config = NULL; + struct RLC_Config *DRB_rlc_config = NULL; + struct PDCP_Config *DRB_pdcp_config = NULL; + struct PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; + + struct DRB_ToAddMod *DRB_config = NULL; + struct LogicalChannelConfig__ul_SpecificParameters *DRB_ul_SpecificParameters = NULL; + long *logicalchannelgroup_drb; + + + //Static preconfiguration of DRB + DRB_config = CALLOC(1, sizeof(*DRB_config)); + + DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long)); + // allowed value 5..15, value : x+4 + *(DRB_config->eps_BearerIdentity) = 1; //ue_context_pP->ue_context.e_rab[i].param.e_rab_id;//+ 4; // especial case generation + // DRB_config->drb_Identity = 1 + drb_identity_index + e_rab_done;// + i ;// (DRB_Identity_t) ue_context_pP->ue_context.e_rab[i].param.e_rab_id; + // 1 + drb_identiy_index; + DRB_config->drb_Identity = 1; + DRB_config->logicalChannelIdentity = CALLOC(1, sizeof(long)); + *(DRB_config->logicalChannelIdentity) = DRB_config->drb_Identity + 2; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 + + DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config)); + DRB_config->rlc_Config = DRB_rlc_config; + + DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); + DRB_config->pdcp_Config = DRB_pdcp_config; + DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); + *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; + DRB_pdcp_config->rlc_AM = NULL; + DRB_pdcp_config->rlc_UM = NULL; + + DRB_rlc_config->present = RLC_Config_PR_um_Bi_Directional; + DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35; + // PDCP + PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM)); + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; + + DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed; + + DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config)); + DRB_config->logicalChannelConfig = DRB_lchan_config; + DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); + DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; + + DRB_ul_SpecificParameters->priority= 4; + + DRB_ul_SpecificParameters->prioritisedBitRate = LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + DRB_ul_SpecificParameters->bucketSizeDuration = + LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; + + logicalchannelgroup_drb = CALLOC(1, sizeof(long)); + *logicalchannelgroup_drb = 1;//(i+1) % 3; + DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; + + + // Have to dins out how to fill the DRB_config and then feed it back to the list + /* + if (DRB_configList != NULL) { + LOG_D(RRC, "get DRB_config from (ue_context_pP->ue_context.DRB_configList)\n"); + for (i = 0; (i < DRB_configList->list.count) && (i < 3); i++) { + DRB_config = DRB_configList->list.array[i]; + + // Add DRB to DRB configuration list, for RRCConnectionReconfigurationComplete + ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config); + } + } + */ + + + ASN_SEQUENCE_ADD(&DRB_configList->list,DRB_config); + + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_YES, 0x1234, 0, 0,0); + rrc_pdcp_config_asn1_req(&ctxt, + (SRB_ToAddModList_t *) NULL, + DRB_configList, + (DRB_ToReleaseList_t*) NULL, + 0xff, NULL, NULL, NULL +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + , (PMCH_InfoList_r9_t *) NULL +#endif + ,NULL); + +rrc_rlc_config_asn1_req(&ctxt, + (SRB_ToAddModList_t*)NULL, + DRB_configList, + (DRB_ToReleaseList_t*)NULL +#if (RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + ,(PMCH_InfoList_r9_t *)NULL + , 0, 0 +#endif + ); + } //----------------------------------------------------------------------------- diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 92409d96dcfc4f0eb877a33af061f87480a0440a..40e38fe6614d74f62fc3684921786c6ae20b40ed 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -516,7 +516,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); if (h_rc != HASH_TABLE_OK) { - LOG_W(PDCP, PROTOCOL_CTXT_FMT" Dropped IP PACKET cause no PDCP instanciated\n", + LOG_I(PDCP, PROTOCOL_CTXT_FMT" Dropped IP PACKET cause no PDCP instanciated\n", PROTOCOL_CTXT_ARGS(ctxt_pP)); free(data_p->data); free(data_p); @@ -529,7 +529,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB); if (rab_id != 0) { - LOG_D(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ " + LOG_I(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ " "/ %d Bytes --->][PDCP][MOD %u][RB %u]\n", ctxt_cpy.frame, (ctxt_cpy.enb_flag) ? "eNB" : "UE", @@ -625,6 +625,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) return 0; # else /* PDCP_USE_NETLINK_QUEUES*/ +//LOG_I(PDCP, "Not using PDCP_USE_NETLINK_QUEUES ! \n \n \n"); int len = 1; int msg_len; rb_id_t rab_id = 0; @@ -791,7 +792,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) pc5s_header->rb_id, rab_id, pc5s_header->data_size); - LOG_D(PDCP, + LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", ctxt.frame, pc5s_header->inst, @@ -849,37 +850,55 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) while ((len > 0) && (rlc_data_req_flag !=0)) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); - len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); + //len = read(nas_sock_fd, &nl_rx_buf, NL_MAX_PAYLOAD); + len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); //Initial VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); if (len<=0) { // nothing in pdcp NAS socket - //LOG_D(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); + LOG_I(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); } else { + LOG_I(PDCP, "Something in queue ! \n \n \n"); msg_len = len; - for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; + for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; //nas_msg_rx; NLMSG_OK (nas_nlh_rx, msg_len); nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, msg_len)) { if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { - LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); + LOG_I(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); //return; } - if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { - LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); + else if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { + LOG_I(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); + } + + else if (nas_nlh_rx->nlmsg_type == NLMSG_NOOP) { + LOG_I(PDCP, "[PDCP][NETLINK] RX NLMSG_NOOP\n"); + } + + else if (nas_nlh_rx->nlmsg_type == NLMSG_OVERRUN) { + LOG_I(PDCP, "[PDCP][NETLINK] RX NLMSG_OVERRUN\n"); + } + + else if (nas_nlh_rx->nlmsg_type == NLMSG_MIN_TYPE) { + LOG_I(PDCP, "[PDCP][NETLINK] RX NLMSG_OVERRUN\n"); + } + + else{ + LOG_I (PDCP, "[PDCP][NETLINK] No valid type received %hu \n", nas_nlh_rx->nlmsg_type); } if (pdcp_read_state_g == 0) { if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { pdcp_read_state_g = 1; //get memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); - LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d, source L2Id 0x%08x, destination L2Id 0x%08x\n", + LOG_I(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d, source L2Id 0x%08x, destination L2Id 0x%08x\n", pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size,pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id ); } else { - LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", - nas_nlh_rx->nlmsg_len); + LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t): %d + sizeof(struct nlmsghdr):%d, sum: %d \n", + nas_nlh_rx->nlmsg_len, sizeof (pdcp_data_req_header_t), sizeof(struct nlmsghdr), sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)); } } else { pdcp_read_state_g = 0; @@ -943,12 +962,13 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) if (h_rc == HASH_TABLE_OK) { #ifdef PDCP_DEBUG - LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", + LOG_I(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d for rnti: %d \n", ctxt.frame, pdcp_read_header_g.inst, len, nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), - pdcp_read_header_g.rb_id); + pdcp_read_header_g.rb_id, + ctxt.rnti); #endif MSC_LOG_RX_MESSAGE( @@ -962,7 +982,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) pdcp_read_header_g.rb_id, rab_id, pdcp_read_header_g.data_size); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n", + LOG_I(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n", ctxt_cpy.frame, pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, @@ -984,7 +1004,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) #endif ); } else { - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", + LOG_I(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", ctxt.frame, pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, @@ -1045,14 +1065,14 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) if (h_rc == HASH_TABLE_OK) { rab_id = pdcp_p->rb_id; #ifdef PDCP_DEBUG - LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", + LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", ctxt.frame, pdcp_read_header_g.inst, len, nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), pdcp_read_header_g.rb_id); - LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", ctxt.frame, pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, @@ -1099,7 +1119,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) pdcp_read_header_g.rb_id, rab_id, pdcp_read_header_g.data_size); - LOG_D(PDCP, + LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", ctxt.frame, pdcp_read_header_g.inst, diff --git a/openair2/NETWORK_DRIVER/MESH/classifier.c b/openair2/NETWORK_DRIVER/MESH/classifier.c index a22ac2f20045b4457b9ec6adaeed72d931a0555a..aa8f21199c3f93740a7a1f52691080eb1ca041d3 100644 --- a/openair2/NETWORK_DRIVER/MESH/classifier.c +++ b/openair2/NETWORK_DRIVER/MESH/classifier.c @@ -634,7 +634,7 @@ void nas_CLASS_send(struct sk_buff *skb,int inst) printk("[NAS][CLASS][SEND] Got packet from kernel:\n"); - for (i=0; i<256; i++) + for (int i=0; i<256; i++) printk("%2x ",((unsigned char *)skb->data)[i]); printk("\n"); @@ -790,6 +790,7 @@ void nas_CLASS_send(struct sk_buff *skb,int inst) dscp, sprotocol, sp->classref, sfct, sp->rab_id); #endif + //printk(" About to trigger a new message sending through nas_CLASS_send \n \n"); sp->fct(skb, cx, sp,inst, NULL); } // if classifier entry match found diff --git a/openair2/NETWORK_DRIVER/MESH/common.c b/openair2/NETWORK_DRIVER/MESH/common.c index 738f05ad9922f4f17221e817f33df7a3e747ab96..313f499963a54eabd42a52a868c6a91d0f0911b7 100644 --- a/openair2/NETWORK_DRIVER/MESH/common.c +++ b/openair2/NETWORK_DRIVER/MESH/common.c @@ -387,6 +387,11 @@ void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct class pdcph.data_size = skb->len; pdcph.rb_id = (gc->rb)->rab_id; pdcph.inst = inst; +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + pdcph.sourceL2Id = 0; + pdcph.destinationL2Id = 0; +#endif + #ifdef PDCP_USE_NETLINK diff --git a/openair2/NETWORK_DRIVER/MESH/local.h b/openair2/NETWORK_DRIVER/MESH/local.h index e23188d357006d2bebf16f58c5650cbea5d39266..0fbf2bfd2005c6455485d880824d8f7ef25c6abb 100644 --- a/openair2/NETWORK_DRIVER/MESH/local.h +++ b/openair2/NETWORK_DRIVER/MESH/local.h @@ -160,6 +160,10 @@ typedef struct pdcp_data_req_header_s { sdu_size_t data_size; signed int inst; ip_traffic_type_t traffic_type; +#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + uint32_t sourceL2Id; + uint32_t destinationL2Id; +#endif } pdcp_data_req_header_t; typedef struct pdcp_data_ind_header_s { diff --git a/openair2/NETWORK_DRIVER/MESH/netlink.c b/openair2/NETWORK_DRIVER/MESH/netlink.c index 9ac44453a94ab43e6dbc3c390d7a9dcfb25134bd..4908e007580921b19e104dd2abffd1c288d19256 100644 --- a/openair2/NETWORK_DRIVER/MESH/netlink.c +++ b/openair2/NETWORK_DRIVER/MESH/netlink.c @@ -161,7 +161,7 @@ int nas_netlink_send(unsigned char *data,unsigned int len) int status; - // printk("[NAS][NETLINK] Sending %d bytes (%d)\n",len,NLMSG_SPACE(len)); + //printk("[NAS][NETLINK] Sending %d bytes (%d)\n",len,NLMSG_SPACE(len)); skb_put(nl_skb, NLMSG_SPACE(len)); memcpy(NLMSG_DATA(nlh),data,len);