diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 6e9e333167f66788e212d440322f81b740019835..a330cf45b93e710611d935752cd69b177a04bbc3 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -352,32 +352,30 @@ static void UE_synch(void *arg) { } } -void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { - - nr_dcireq_t dcireq; - nr_scheduled_response_t scheduled_response; +void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { uint32_t nb_rb, start_rb; uint8_t nb_symb_sch, start_symbol, mcs, precod_nbr_layers, harq_pid, rvidx; uint16_t n_rnti; - // Process Rx data for one sub-frame - if (nr_slot_select(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) { - //TODO: all of this has to be moved to the MAC!!! + nr_dcireq_t dcireq; + nr_scheduled_response_t scheduled_response; + + // program PUSCH. this should actually be done by the MAC upon reception of an UL DCI + if (proc->nr_tti_tx == NR_UPLINK_SLOT || UE->frame_parms.frame_type == FDD){ + dcireq.module_id = UE->Mod_id; dcireq.gNB_index = 0; dcireq.cc_id = 0; dcireq.frame = proc->frame_rx; dcireq.slot = proc->nr_tti_rx; - nr_ue_dcireq(&dcireq); //to be replaced with function pointer later - scheduled_response.dl_config = &dcireq.dl_config_req; + scheduled_response.dl_config = NULL; scheduled_response.ul_config = &dcireq.ul_config_req; scheduled_response.tx_request = NULL; scheduled_response.module_id = UE->Mod_id; scheduled_response.CC_id = 0; scheduled_response.frame = proc->frame_rx; scheduled_response.slot = proc->nr_tti_rx; - //--------------------------Temporary configuration-----------------------------// n_rnti = 0x1234; nb_rb = 50; @@ -388,7 +386,7 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { mcs = 9; harq_pid = 0; rvidx = 0; - //------------------------------------------------------------------------------// + //------------------------------------------------------------------------------// scheduled_response.ul_config->sfn_slot = NR_UPLINK_SLOT; scheduled_response.ul_config->number_pdus = 1; @@ -403,8 +401,45 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = rvidx; scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers; scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid; + + nr_ue_scheduled_response(&scheduled_response); + + if (UE->mode != loop_through_memory) { + uint8_t thread_id = PHY_vars_UE_g[UE->Mod_id][0]->current_thread_id[proc->nr_tti_tx]; + phy_procedures_nrUE_TX(UE,proc,0,thread_id); + } + } +} + +void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { + + nr_dcireq_t dcireq; + nr_scheduled_response_t scheduled_response; + + //program DCI for slot 1 + //TODO: all of this has to be moved to the MAC!!! + if (proc->nr_tti_tx == NR_DOWNLINK_SLOT || UE->frame_parms.frame_type == FDD){ + dcireq.module_id = UE->Mod_id; + dcireq.gNB_index = 0; + dcireq.cc_id = 0; + dcireq.frame = proc->frame_rx; + dcireq.slot = proc->nr_tti_rx; + nr_ue_dcireq(&dcireq); //to be replaced with function pointer later + + // we should have received a DL DCI here, so configure DL accordingly + scheduled_response.dl_config = &dcireq.dl_config_req; + scheduled_response.ul_config = NULL; + scheduled_response.tx_request = NULL; + scheduled_response.module_id = UE->Mod_id; + scheduled_response.CC_id = 0; + scheduled_response.frame = proc->frame_rx; + scheduled_response.slot = proc->nr_tti_rx; + nr_ue_scheduled_response(&scheduled_response); + } + // Process Rx data for one sub-frame + if ( proc->nr_tti_rx >=0 && proc->nr_tti_rx <= 1 ) { #ifdef UE_SLOT_PARALLELISATION phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else @@ -413,15 +448,15 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { LOG_D(PHY,"phy_procedures_nrUE_RX: slot:%d, time %lu\n", proc->nr_tti_rx, (rdtsc()-a)/3500); //printf(">>> nr_ue_pdcch_procedures ended\n"); #endif - if(IS_SOFTMODEM_NOS1){ //&& proc->nr_tti_rx==1 - //Hardcoded rnti value - protocol_ctxt_t ctxt; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO, - 0x1234, proc->frame_rx, - proc->nr_tti_rx, 0); - pdcp_run(&ctxt); - pdcp_fifo_flush_sdus(&ctxt); - } + if(IS_SOFTMODEM_NOS1){ //&& proc->nr_tti_rx==1 + //Hardcoded rnti value + protocol_ctxt_t ctxt; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO, + 0x1234, proc->frame_rx, + proc->nr_tti_rx, 0); + pdcp_run(&ctxt); + pdcp_fifo_flush_sdus(&ctxt); + } } @@ -456,45 +491,14 @@ typedef struct processingData_s { } processingData_t; void UE_processing(void *arg) { - uint8_t thread_id; processingData_t *rxtxD=(processingData_t *) arg; UE_nr_rxtx_proc_t *proc = &rxtxD->proc; PHY_VARS_NR_UE *UE = rxtxD->UE; - processSlotRX(UE, proc); - //printf(">>> mac ended\n"); - // Prepare the future Tx data -/* -#ifndef NO_RAT_NR - - if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_UPLINK_SLOT) -#else - if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || - (UE->frame_parms.frame_type == FDD) ) -#endif -*/ - - - if (proc->nr_tti_tx == NR_UPLINK_SLOT || UE->frame_parms.frame_type == FDD){ - - thread_id = PHY_vars_UE_g[UE->Mod_id][0]->current_thread_id[proc->nr_tti_tx]; - - - if (UE->mode != loop_through_memory) - phy_procedures_nrUE_TX(UE,proc,0,thread_id); - } - - //phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay); - -#if 0 + processSlotRX(UE, proc); - if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) && - (UE->frame_parms.frame_type == TDD)) - if (UE->mode != loop_through_memory) - //phy_procedures_UE_S_TX(UE,0,0,no_relay); - updateTimes(current, &t3, 10000, timing_proc_name); + processSlotTX(UE, proc); -#endif } void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { @@ -812,12 +816,12 @@ if (slot_nr==18) void init_NR_UE(int nb_inst, char* rrc_config_path) { int inst; NR_UE_MAC_INST_t *mac_inst; - + NR_UE_RRC_INST_t* rrc_inst; + for (inst=0; inst < nb_inst; inst++) { - nr_l3_init_ue(rrc_config_path); - nr_l2_init_ue(); - mac_inst = get_mac_inst(inst); - AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initial IF module\n"); + AssertFatal((rrc_inst = nr_l3_init_ue(rrc_config_path)) != NULL, "can not initialize RRC module\n"); + AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n"); + AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n"); } } @@ -838,6 +842,4 @@ void init_NR_UE_threads(int nb_inst) { #endif } - - printf("UE threads created by %ld\n", gettid()); } diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index d569a55772a5f8c13a2df07ba74f7fdf4274a598..13992e88fcf19440dffc82d2f3f57fc1bc6de4f8 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -766,11 +766,14 @@ int main( int argc, char **argv ) { #else PHY_vars_UE_g[0][CC_id]->hw_timing_advance = 160; #endif + } + init_NR_UE_threads(1); + printf("UE threads created by %ld\n", gettid()); + // wait for end of program printf("TYPE <CTRL-C> TO TERMINATE\n"); - init_NR_UE_threads(1); while(true) sleep(3600); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index cdd1d3ebef1be6f1b8f09ca5d966be0b3e0db6c3..0a6d05f4607abfc59593603fb0e151149b5db7ff 100755 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -268,27 +268,24 @@ int nr_rrc_mac_config_req_ue( int cc_idP, uint8_t gNB_index, NR_MIB_t *mibP, - NR_ServingCellConfigCommon_t *sccP, + // NR_ServingCellConfigCommon_t *sccP, // NR_MAC_CellGroupConfig_t *mac_cell_group_configP, // NR_PhysicalCellGroupConfig_t *phy_cell_group_configP, NR_SpCellConfig_t *spCell_ConfigP ){ NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); -// NR_ServingCellConfig_t *serving_cell_config = spcell_configP->spCellConfigDedicated; -// TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc. + // NR_ServingCellConfig_t *serving_cell_config = spcell_configP->spCellConfigDedicated; + // TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc. - NR_ServingCellConfigCommon_t *scc; if(mibP != NULL){ mac->mib = mibP; // update by every reception } - - if(spCell_ConfigP != NULL ){ - mac->servCellIndex = spCell_ConfigP->servCellIndex; + mac->servCellIndex = *spCell_ConfigP->servCellIndex; if (spCell_ConfigP->reconfigurationWithSync) { mac->scc = spCell_ConfigP->reconfigurationWithSync->spCellConfigCommon; config_common_ue(mac); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index b59f22b9a68a21023f790951448c8f395fc5aed9..511f53edf1a287894a088659c854cf866fab20d0 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -35,7 +35,9 @@ #include "mac_defs.h" #include "mac.h" -#include <openair1/PHY/defs_nr_UE.h> +#include "PHY/defs_nr_UE.h" +#include "RRC/NR_UE/rrc_defs.h" + /**\brief decode mib pdu in NR_UE, from if_module ul_ind with P7 tx_ind message \param module_id module id @@ -70,11 +72,11 @@ int nr_rrc_mac_config_req_ue( int cc_idP, uint8_t gNB_index, NR_MIB_t *mibP, - NR_ServingCellConfigCommon_t *sccP, + //NR_ServingCellConfigCommon_t *sccP, NR_SpCellConfig_t *spCell_ConfigP); /**\brief initialization NR UE MAC instance(s), total number of MAC instance based on NB_NR_UE_MAC_INST*/ -int nr_l2_init_ue(void); +NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst); /**\brief fetch MAC instance by module_id, within 0 - (NB_NR_UE_MAC_INST-1) \param module_id index of MAC instance(s)*/ diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 0478a6b7d51464fe885023ce0a81dc3b14f7fbce..b142d54642b5c27e3b08b1badae4deea77fb88e8 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -36,8 +36,7 @@ static NR_UE_MAC_INST_t *nr_ue_mac_inst; -int -nr_l2_init_ue(void) +NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { //LOG_I(MAC, "[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n"); @@ -45,6 +44,8 @@ nr_l2_init_ue(void) //init mac here nr_ue_mac_inst = (NR_UE_MAC_INST_t *)malloc(sizeof(NR_UE_MAC_INST_t)*NB_NR_UE_MAC_INST); + + nr_rrc_mac_config_req_ue(0,0,0,NULL,rrc_inst->cell_group_config->spCellConfig); if (IS_SOFTMODEM_NOS1){ if (rlc_module_init(0) != 0) { @@ -55,7 +56,7 @@ nr_l2_init_ue(void) } - return (1); + return (nr_ue_mac_inst); } NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id){ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index b78532476f1dbf5856dc361198c77723e751cd3f..cdbc868971d2ff678417d483f84e96fccd886497 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1826,7 +1826,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, if(dlsch_config_pdu != NULL){ NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; if (mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList; + pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup; else if (mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; if (pdsch_TimeDomainAllocationList) { @@ -1866,7 +1866,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, if(ulsch_config_pdu != NULL){ NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; if (mac->ULbwp[0]->bwp_Dedicated->pusch_Config) - pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList; + pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup; if (pusch_TimeDomainAllocationList) { AssertFatal(pusch_TimeDomainAllocationList->list.count > time_domain_ind, diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c index 2c6b5e40bdeaddb5c2611218c9adbd1e1cb7c8cb..89075331efb2be4169de51d9f90e6c9aabdd8d91 100644 --- a/openair2/RRC/NR_UE/main_ue.c +++ b/openair2/RRC/NR_UE/main_ue.c @@ -33,11 +33,9 @@ #include "defs.h" #include "rrc_proto.h" -int nr_l3_init_ue(char* rrc_config_path){ +NR_UE_RRC_INST_t* nr_l3_init_ue(char* rrc_config_path){ //LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n"); - openair_rrc_top_init_ue_nr(rrc_config_path); - - return 0; + return openair_rrc_top_init_ue_nr(rrc_config_path); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index bf22b85f8bf1d98d424265fd51aca64d3e8135a8..8a6823a5723f8b8951724e41d7e5431b92a715d9 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -80,7 +80,7 @@ int8_t nr_rrc_ue_decode_secondary_cellgroup_config( SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)cell_group_config, 0); } - //nr_rrc_mac_config_req_ue( module_id_t module_id, int CC_id, uint8_t gNB_index, NR_MIB_t *mibP, NR_MAC_CellGroupConfig_t *mac_cell_group_configP, NR_PhysicalCellGroupConfig_t *phy_cell_group_configP, NR_SpCellConfig_t *spcell_configP ); + //nr_rrc_mac_config_req_ue( 0,0,0,NULL, cell_group_config->mac_CellGroupConfig, cell_group_config->physicalCellGroupConfig, cell_group_config->spCellConfig ); return 0; } @@ -124,8 +124,9 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfig nr_rrc_ue_process_scg_config(cellGroupConfig); }else{ // after first time, update it and free the memory after. + SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)NR_UE_rrc_inst->cell_group_config, 0); + NR_UE_rrc_inst->cell_group_config = cellGroupConfig; nr_rrc_ue_process_scg_config(cellGroupConfig); - SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)cellGroupConfig, 0); } } @@ -168,8 +169,7 @@ int8_t nr_rrc_ue_process_meas_config(NR_MeasConfig_t *meas_config){ int8_t nr_rrc_ue_process_scg_config(NR_CellGroupConfig_t *cell_group_config){ int i; if(NR_UE_rrc_inst->cell_group_config==NULL){ - // initial list - + // initial list if(cell_group_config->spCellConfig != NULL){ if(cell_group_config->spCellConfig->spCellConfigDedicated != NULL){ if(cell_group_config->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList != NULL){ @@ -179,8 +179,6 @@ int8_t nr_rrc_ue_process_scg_config(NR_CellGroupConfig_t *cell_group_config){ } } } - - }else{ // maintain list if(cell_group_config->spCellConfig != NULL){ @@ -259,7 +257,7 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, } -int8_t openair_rrc_top_init_ue_nr(char* rrc_config_path){ +NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){ if(NB_NR_UE_INST > 0){ NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)malloc(NB_NR_UE_INST * sizeof(NR_UE_RRC_INST_t)); @@ -347,7 +345,7 @@ int8_t openair_rrc_top_init_ue_nr(char* rrc_config_path){ NR_UE_rrc_inst = NULL; } - return 0; + return NR_UE_rrc_inst; } @@ -418,7 +416,7 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( // (void *)&bcch_message->message.choice.mib, // sizeof(NR_MIB_t) ); - nr_rrc_mac_config_req_ue( 0, 0, 0, mib, NULL, NULL); + nr_rrc_mac_config_req_ue( 0, 0, 0, mib, NULL); } return 0; diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index da636fed99c14e673486c0b33abfa610957cd06f..4e1485ac5f19fac04937bffa74da9e1b192ce5a5 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -67,7 +67,7 @@ typedef struct NR_UE_RRC_INST_s { NR_MeasConfig_t *meas_config; NR_CellGroupConfig_t *cell_group_config; NR_RadioBearerConfig_t *radio_bearer_config; - + NR_MIB_t *mib; // lists diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index d195de76af5209d685fae843be341cc5a4e84a81..6e0d0a10deaef8c35afb09cd3fec8182ed9929b1 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -43,14 +43,14 @@ // main_rrc.c // /**\brief Layer 3 initialization*/ -int nr_l3_init_ue(char*); +NR_UE_RRC_INST_t* nr_l3_init_ue(char*); // // UE_rrc.c // /**\brief Initial the top level RRC structure instance*/ -int8_t openair_rrc_top_init_ue_nr(char*); +NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char*); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf index 778f91bf74f8f622f56e14b923da089de966c045..d5e8ddbac8fd2f64263f3a4c56158bd6a13f3cca 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf @@ -33,7 +33,7 @@ gNBs = # downlinkConfigCommon #frequencyInfoDL # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP) - absoluteFrequencySSB = 642016; + absoluteFrequencySSB = 642364; dl_frequencyBand = 78; # this is 3600 MHz dl_absoluteFrequencyPointA = 640000; @@ -152,7 +152,7 @@ gNBs = # ssb_periodicityServingCell # 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 - ssb_periodicityServingCell = 2; + ssb_periodicityServingCell = 1; # dmrs_TypeA_position # 0 = pos2, 1 = pos3