From ff508f1d96bfbd47675cf56eee4d7266ff6aac6a Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 13 Oct 2019 10:13:03 +0200 Subject: [PATCH] added MAC configuration for secondaryCellGroup and addition of UE context in MAC --- cmake_targets/CMakeLists.txt | 39 ++------- executables/nr-gnb.c | 13 --- .../PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h | 42 --------- openair2/LAYER2/NR_MAC_gNB/config.c | 60 ++++++++----- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 86 +------------------ .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 4 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 84 ++++++++++++++++++ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 5 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 24 +++++- openair2/RRC/NR/rrc_gNB.c | 5 +- openair2/RRC/NR/rrc_gNB_nsa.c | 7 ++ openair2/RRC/NR/rrc_gNB_reconfig.c | 10 +-- 12 files changed, 173 insertions(+), 206 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 3244c84f5d..47b9aa7ab9 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2605,41 +2605,25 @@ add_executable(nr_dlschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/system.c -<<<<<<< HEAD ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${T_SOURCE}) target_link_libraries(nr_dlschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) -======= - ${UTIL_SRC} - ${T_SOURCE}) -target_link_libraries(nr_dlschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) ->>>>>>> origin/develop-nr add_executable(nr_pbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/system.c -<<<<<<< HEAD ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${T_SOURCE}) -target_link_libraries(nr_pbchsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) - -======= - ${UTIL_SRC} - ${T_SOURCE}) -target_link_libraries(nr_pbchsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) ->>>>>>> origin/develop-nr +target_link_libraries(nr_pbchsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} $(ITTI_LIB) dl) #PUCCH ---> Prashanth add_executable(nr_pucchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pucchsim.c ${OPENAIR_DIR}/common/utils/backtrace.c -<<<<<<< HEAD ${OPENAIR_DIR}/common/utils/nr/nr_common.c -======= ${OPENAIR_DIR}/common/utils/system.c ${UTIL_SRC} ->>>>>>> origin/develop-nr ${T_SOURCE}) target_link_libraries(nr_pucchsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) #PUCCH ---> Prashanth @@ -2648,10 +2632,10 @@ add_executable(nr_dlsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/system.c -<<<<<<< HEAD ${OPENAIR_DIR}/common/utils/nr/nr_common.c - ${T_SOURCE}) -target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON MAC_NR RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) + ${UTIL_SRC} + ${T_SOURCE}) +target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) add_executable(nr_prachsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/prachsim.c @@ -2661,35 +2645,22 @@ add_executable(nr_prachsim ${OPENAIR1_DIR}/SCHED_NR/phy_procedures_nr_common.c ${T_SOURCE}) target_link_libraries(nr_prachsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) -======= - ${UTIL_SRC} - ${T_SOURCE}) -target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) ->>>>>>> origin/develop-nr add_executable(nr_ulschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c ${OPENAIR_DIR}/common/utils/backtrace.c -<<<<<<< HEAD - ${OPENAIR_DIR}/common/utils/nr/nr_common.c - ${T_SOURCE}) -target_link_libraries(nr_ulschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) -======= ${OPENAIR_DIR}/common/utils/system.c ${UTIL_SRC} + ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${T_SOURCE}) target_link_libraries(nr_ulschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) ->>>>>>> origin/develop-nr add_executable(nr_ulsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c ${OPENAIR_DIR}/common/utils/backtrace.c -<<<<<<< HEAD ${OPENAIR_DIR}/common/utils/nr/nr_common.c -======= ${OPENAIR_DIR}/common/utils/system.c ${UTIL_SRC} ->>>>>>> origin/develop-nr ${T_SOURCE}) target_link_libraries(nr_ulsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 505deff70b..6ece377293 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -758,19 +758,6 @@ void init_gNB_proc(int inst) { AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); - - //pthread_create( &proc->pthread_prach, attr_prach, gNB_thread_prach, gNB ); - char name[16]; - - if (gNB->single_thread_flag==0) { - snprintf( name, sizeof(name), "L1 %d", i ); - pthread_setname_np( L1_proc->pthread, name ); - snprintf( name, sizeof(name), "L1TX %d", i ); - pthread_setname_np( L1_proc_tx->pthread, name ); - } - - AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); - /* setup PHY proc TX sync mechanism */ pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL); pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL); diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h index 02ff98f840..5470ab7973 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h @@ -812,32 +812,6 @@ static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf } } -static inline uint32_t *bn2cnmap(uint32_t* p_lut_cn2bn,int8_t *p_cnProcBuf,int8_t *bnProcBufRes,int M2) __attribute__((always_inline)); - -static inline uint32_t *bn2cnmap(uint32_t* p_lut_cn2bn,int8_t *p_cnProcBuf,int8_t *bnProcBufRes,int M2) { - - __m128i tmp; - - for (int i=0;i>4); nrLDPC_circ_memcpy(p_cnProcBuf, &bnProcBufRes[lut_startAddrBnProcBuf_CNG3[j][0]], Z, lut_circShift_CNG3[j][0]); } @@ -1175,21 +1148,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf } } -static inline void memcpy_printer(uint32_t* p_lut_cn2bn,int dest0,int M) { - - int dest=0,src=p_lut_cn2bn[0],len=1; - for (int i=1;issb_PositionsInBurst->present == NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap, "SSB Bitmap is not 8-bits!\n"); + if (scc != NULL ) { + AssertFatal(scc->ssb_PositionsInBurst->present == NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap, "SSB Bitmap is not 8-bits!\n"); - config_common(Mod_idP, - scc); - LOG_E(MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req); + config_common(Mod_idP, + scc); + LOG_E(MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req); + + // if in nFAPI mode + if ( (nfapi_mode == 1 || nfapi_mode == 2) && (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) ){ + while(RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) { + // DJP AssertFatal(RC.nrmac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n"); + usleep(100 * 1000); + printf("Waiting for PHY_config_req\n"); + } + } + + + NR_PHY_Config_t phycfg; + phycfg.Mod_id = Mod_idP; + phycfg.CC_id = 0; + phycfg.cfg = &RC.nrmac[Mod_idP]->config[0]; + + if (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req) RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req(&phycfg); + } + + if (secondaryCellGroup) { - // if in nFAPI mode - if ( (nfapi_mode == 1 || nfapi_mode == 2) && (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) ){ - while(RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) { - // DJP AssertFatal(RC.nrmac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n"); - usleep(100 * 1000); - printf("Waiting for PHY_config_req\n"); + NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list; + if (add_ue == 1) { + int UE_id = add_new_nr_ue(Mod_idP,rnti); + UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup; + } + else { // secondaryCellGroup has been updated + int UE_id = find_nr_UE_id(rnti); + UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup; } } - - - NR_PHY_Config_t phycfg; - phycfg.Mod_id = Mod_idP; - phycfg.CC_id = 0; - phycfg.cfg = &RC.nrmac[Mod_idP]->config[0]; - - if (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req) RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req(&phycfg); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); - + return(0); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index ea62e761da..4028eca56e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -310,7 +310,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, protocol_ctxt_t ctxt; int CC_id, i = -1; - UE_list_t *UE_list = &RC.nrmac[module_idP]->UE_list; + NR_UE_list_t *UE_list = &RC.nrmac[module_idP]->UE_list; rnti_t rnti; NR_COMMON_channels_t *cc = RC.nrmac[module_idP]->common_channels; @@ -351,90 +351,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, rnti = 0;//UE_RNTI(module_idP, i); CC_id = 0;//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", - rnti, - UE_list->UE_sched_ctrl[i].ul_out_of_sync == - 0 ? "in synch" : "out of sync", - UE_list->UE_template[CC_id][i].phr_info, - UE_list->UE_sched_ctrl[i].dl_cqi[CC_id], - (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]->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]-> - 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, - 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 - reestablish_rnti_map[ue_id_l][0] = 0; - reestablish_rnti_map[ue_id_l][1] = 0; - break; - } - }*/ - - // Note: This should not be done in the MAC! - for (int ii=0; iiulsch[ii][0]; - if((ulsch != NULL) && (ulsch->rnti == rnti)){ - LOG_W(MAC, "TODO: clean_eNb_ulsch UE %x \n", rnti); - clean_gNB_ulsch(ulsch); - } - } - - for (int ii=0; iidlsch[ii][0]; - if((dlsch != NULL) && (dlsch->rnti == rnti)){ - LOG_W(MAC, "TODO: clean_eNb_dlsch UE %x \n", rnti); - 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; - if(ul_req_tmp){ - int pdu_number = ul_req_tmp->number_of_pdus; - for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ - if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){ - LOG_I(MAC, "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(module_idP,rnti); - } - } //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++) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 0e44aecaba..986445f6f6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -308,11 +308,11 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, // HOT FIX for all zero pdu problem // ------------------------------------------------------------------------------------------------ for(int i = 0; i < dlsch_pdu_rel15->transport_block_size/8; i++) { - ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i] = (unsigned char) rand(); + ((uint8_t *)nr_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) rand(); } // ------------------------------------------------------------------------------------------------ - TX_req->segments[0].segment_data = nr_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0]; + TX_req->segments[0].segment_data = nr_mac->UE_list.DLSCH_pdu[0][0].payload[0]; TX_req->segments[0].segment_length = dlsch_pdu_rel15->transport_block_size+2; nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus++; nr_mac->TX_req[CC_id].sfn_sf = sfn_sf; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index d66949b2ad..b887566346 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -570,3 +570,87 @@ void fill_initialBWPULtimeDomainAllocaion(nfapi_nr_config_request_t *cfg,int tim *start_symbol = extract_startSymbol(cfg->pusch_config.PUSCHTimeDomainResourceAllocation_startSymbolAndLength[time_domain_assignment].value); *length = extract_length(cfg->pusch_config.PUSCHTimeDomainResourceAllocation_startSymbolAndLength[time_domain_assignment].value); } + +/* + * Dump the UL or DL UE_list into LOG_T(MAC) + */ +void +dump_nr_ue_list(NR_UE_list_t *listP, + int ul_flag) +//------------------------------------------------------------------------------ +{ + if (ul_flag == 0) { + for (int j = listP->head; j >= 0; j = listP->next[j]) { + LOG_T(MAC, "DL list node %d => %d\n", + j, + listP->next[j]); + } + } else { + for (int j = listP->head_ul; j >= 0; j = listP->next_ul[j]) { + LOG_T(MAC, "UL list node %d => %d\n", + j, + listP->next_ul[j]); + } + } + + return; +} + +int +find_nr_UE_id(module_id_t mod_idP, + rnti_t rntiP) +//------------------------------------------------------------------------------ +{ + int UE_id; + NR_UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list; + + for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) { + if (UE_list->active[UE_id] == TRUE) { + if (UE_list->rnti[UE_id] == rntiP) { + return UE_id; + } + } + } + + return -1; +} + +int add_new_nr_ue(module_id_t mod_idP, + rnti_t rntiP) { + + int UE_id; + int i, j; + NR_UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list; + LOG_D(MAC, "[gNB %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n", + mod_idP, + rntiP, + UE_list->avail, + UE_list->num_UEs); + dump_ue_list(UE_list, 0); + + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { + if (UE_list->active[i] == TRUE) + continue; + + UE_id = i; + UE_list->num_UEs++; + UE_list->active[UE_id] = TRUE; + UE_list->rnti[UE_id] = rntiP; + memset((void *) &UE_list->UE_sched_ctrl[UE_id], + 0, + sizeof(NR_UE_sched_ctrl_t)); + LOG_D(MAC, "gNB %d] Add NR UE_id %d : rnti %x\n", + mod_idP, + UE_id, + rntiP); + dump_nr_ue_list(UE_list, + 0); + return (UE_id); + } + + // printf("MAC: cannot add new UE for rnti %x\n", rntiP); + LOG_E(MAC, "error in add_new_ue(), could not find space in UE_list, Dumping UE list\n"); + dump_nr_ue_list(UE_list, + 0); + return -1; +} diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 882d2d3a12..c7fbf4b0b1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -41,7 +41,10 @@ void config_common(int Mod_idP, ); int rrc_mac_config_req_gNB(module_id_t Mod_idP, int ssb_SubcarrierOffset, - NR_ServingCellConfigCommon_t *scc + NR_ServingCellConfigCommon_t *scc, + int nsa_flag, + uint32_t rnti, + NR_CellGroupConfig_t *secondaryCellGroup ); int is_nr_UL_slot(NR_COMMON_channels_t * ccP, int slotP); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index c8d5d3f385..13e1aad048 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -95,6 +95,28 @@ typedef struct { uint8_t num_sf_allocation_pattern; } NR_COMMON_channels_t; +/*! \brief scheduling control information set through an API (not used)*/ +typedef struct { + int dummy; +} NR_UE_sched_ctrl_t; + +/*! \brief UE list used by eNB to order UEs/CC for scheduling*/ +typedef struct { + + DLSCH_PDU DLSCH_pdu[4][MAX_MOBILES_PER_GNB]; + /// scheduling control info + NR_UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB]; + int next[MAX_MOBILES_PER_GNB]; + int head; + int next_ul[MAX_MOBILES_PER_GNB]; + int head_ul; + int avail; + int num_UEs; + boolean_t active[MAX_MOBILES_PER_GNB]; + rnti_t rnti[MAX_MOBILES_PER_GNB]; + NR_CellGroupConfig_t *secondaryCellGroup[MAX_MOBILES_PER_GNB]; +} NR_UE_list_t; + /*! \brief top level eNB MAC structure */ typedef struct gNB_MAC_INST_s { /// Ethernet parameters for northbound midhaul interface @@ -141,7 +163,7 @@ typedef struct gNB_MAC_INST_s { /// NFAPI search space structure nfapi_nr_search_space_t search_space[NFAPI_CC_MAX][NFAPI_NR_MAX_NB_SEARCH_SPACES]; - UE_list_t UE_list; + NR_UE_list_t UE_list; /// UL handle uint32_t ul_handle; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 2baeb52150..5bd775ff77 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -196,7 +196,10 @@ static void init_NR_SI(gNB_RRC_INST *rrc) { rrc_mac_config_req_gNB(rrc->module_id, rrc->carrier.ssb_SubcarrierOffset, - (NR_ServingCellConfigCommon_t *)rrc->carrier.servingcellconfigcommon + (NR_ServingCellConfigCommon_t *)rrc->carrier.servingcellconfigcommon, + 0, + 0, + (NR_CellGroupConfig_t *)NULL ); diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 4bb4d57cc2..e4c77a8f00 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -133,6 +133,13 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ // Send to X2 entity to transport to MeNB rrc->Nb_ue++; + // configure MAC and RLC + rrc_mac_config_req_gNB(rrc->module_id, + rrc->carrier.ssb_SubcarrierOffset, + NULL, + 1, // add_ue flag + ue_context_p->ue_id_rnti, + ue_context_p->ue_context.secondaryCellGroup); } diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 1fdf53e91c..e5602615fe 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -45,11 +45,11 @@ #define true 1 void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon, - NR_CellGroupConfig_t *secondaryCellGroup, - int scg_id, - int servCellIndex, - int n_physical_antenna_ports, - int initial_csi_index) { + NR_CellGroupConfig_t *secondaryCellGroup, + int scg_id, + int servCellIndex, + int n_physical_antenna_ports, + int initial_csi_index) { AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n"); AssertFatal(secondaryCellGroup!=NULL,"secondaryCellGroup is null\n");