From 1dec9dd9f6624436dc108e77615accf35e83c0d2 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Fri, 29 Oct 2021 13:49:56 -0700 Subject: [PATCH] First attempt at receiving MIB and SIB in SA mode --- .../gnb.band78.sa.fr1.106PRB.usrpn310.conf | 30 +++++++----- common/utils/LOG/log.h | 2 +- executables/nr-ue.c | 16 +++++-- executables/nr-uesoftmodem.c | 5 +- executables/nr-uesoftmodem.h | 1 + executables/softmodem-common.h | 4 ++ openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 7 +-- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 2 + .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 5 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 16 +++++-- openair2/RRC/NR/rrc_gNB.c | 13 +++-- openair2/RRC/NR_UE/rrc_UE.c | 5 +- openair2/RRC/NR_UE/rrc_proto.h | 2 + .../gnb.sa.band78.fr1.106PRB.usrpb210.conf | 48 +++++++------------ 14 files changed, 89 insertions(+), 67 deletions(-) diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf index 1cca2c9268..740313abfc 100644 --- a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -205,7 +205,7 @@ gNBs = ////////// AMF parameters: - amf_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; + amf_ip_address = ( { ipv4 = "192.168.61.195"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; @@ -215,10 +215,10 @@ gNBs = NETWORK_INTERFACES : { - GNB_INTERFACE_NAME_FOR_NG_AMF = "eth0"; - GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; - GNB_INTERFACE_NAME_FOR_NGU = "eth0"; - GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; + GNB_INTERFACE_NAME_FOR_NG_AMF = "lo:"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "127.0.0.2"; + GNB_INTERFACE_NAME_FOR_NGU = "lo:"; + GNB_IPV4_ADDRESS_FOR_NGU = "127.0.0.2"; GNB_PORT_FOR_NGU = 2152; # Spec 2152 }; @@ -226,14 +226,18 @@ gNBs = ); MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "local_RRC"; - pusch_TargetSNRx10 = 200; - pucch_TargetSNRx10 = 150; - ulsch_max_slots_inactivity = 10; - } + { + num_cc = 1; + local_s_if_name = "lo:"; + remote_s_address = "127.0.0.1"; // pnf addr [!] + local_s_address = "127.0.0.2"; // vnf addr + local_s_portc = 50601; // vnf p5 port + remote_s_portc = 50600; // pnf p5 port [!] + local_s_portd = 50611; // vnf p7 port [!] + remote_s_portd = 50610; // pnf p7 port [!] + tr_s_preference = "nfapi"; + tr_n_preference = "local_RRC"; + } ); L1s = ( diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 6083d23580..ce3ada3972 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -426,7 +426,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int # define LOG_W(COMPONENT, ...) do if (1) logMinimal(COMPONENT, 'W', __VA_ARGS__); while (0) # define LOG_A(COMPONENT, ...) do if (1) logMinimal(COMPONENT, 'A', __VA_ARGS__); while (0) /* logs intended for analysis */ # define LOG_I(COMPONENT, ...) do if (1) logMinimal(COMPONENT, 'I', __VA_ARGS__); while (0) -# define LOG_D(COMPONENT, ...) do if (0) logMinimal(COMPONENT, 'D', __VA_ARGS__); while (0) +# define LOG_D(COMPONENT, ...) do if (1) logMinimal(COMPONENT, 'D', __VA_ARGS__); while (0) # define LOG_T(COMPONENT, ...) do if (0) logMinimal(COMPONENT, 'T', __VA_ARGS__); while (0) # define LOG_M(FILE, VECTOR, DATA, LEN, DEC, FORMAT) ((void) 0) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index fc69cf2722..e1c04bc1a9 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -314,13 +314,15 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot) { LOG_E(NR_MAC, "[%d %d] No corresponding tx_data_request for given dl_tti_request sfn/slot\n", NFAPI_SFNSLOT2SFN(dl_tti_sfn_slot), NFAPI_SFNSLOT2SLOT(dl_tti_sfn_slot)); - save_nr_measurement_info(dl_tti_request); + if (get_softmodem_params()->nsa) + save_nr_measurement_info(dl_tti_request); free(dl_tti_request); dl_tti_request = NULL; } else if (dl_tti_request->dl_tti_request_body.nPDUs > 0 && tx_data_request->Number_of_PDUs > 0) { - save_nr_measurement_info(dl_tti_request); + if (get_softmodem_params()->nsa) + save_nr_measurement_info(dl_tti_request); check_and_process_dci(dl_tti_request, tx_data_request, NULL, NULL); } else @@ -432,9 +434,15 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) module_id_t mod_id = 0; NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); - if (mac->scc == NULL) + if (mac->scc == NULL || mac->scc_SIB == NULL) //Melissa TODO this isnt correct { - LOG_D(MAC, "mac->scc == NULL!\n"); + if (get_softmodem_params()->sa && get_softmodem_params()->emulate_l2) + { + LOG_D(NR_MAC, "We haven't gotten MIB or SIB yet. Lets see if we received it\n"); + nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); + process_queued_nr_nfapi_msgs(mac, sfn_slot); + } + LOG_D(MAC, "mac->scc == NULL or mac->scc_SIB == NULL!\n"); continue; } diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index fc72eb51dc..3e279f6108 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -493,7 +493,10 @@ int main( int argc, char **argv ) { exit(-1); } - if (!get_softmodem_params()->nsa) { + if (get_softmodem_params()->emulate_l2) + start_oai_nrue_threads(); + + if (!get_softmodem_params()->nsa && !get_softmodem_params()->emulate_l2) { for (int CC_id=0; CC_iddef_dci_pdu_rel15[dci->dci_format]; - if ((dci->rnti != mac->crnti) && (dci->rnti != mac->ra.ra_rnti)) { + if ((dci->rnti != mac->crnti) && (dci->rnti != mac->ra.ra_rnti) && (dci->rnti != 0xffff)) { LOG_D(MAC,"We skip for the received dci indication rnti %4x != mac->crnti %4x frame slot %4d.%2d RA state %d\n", dci->rnti, mac->crnti, frame, slot, mac->ra.ra_state); return 0; @@ -2512,7 +2512,8 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, N_RB_UL = NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } - LOG_D(MAC,"nr_extract_dci_info : dci_pdu %lx, size %d\n",*dci_pdu,dci_size); + LOG_D(MAC,"nr_extract_dci_info : dci_pdu %lx, size %d, rnti_type %d, dci_format %d\n", + *dci_pdu, dci_size, rnti_type, dci_format); switch(dci_format) { case NR_DL_DCI_FORMAT_1_0: @@ -2568,7 +2569,7 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, dci_pdu_rel15 = &mac->def_dci_pdu_rel15[NR_UL_DCI_FORMAT_0_0]; return 2+nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, dci_pdu, dci_pdu_rel15); } -#ifdef DEBUG_EXTRACT_DCI +#if 1 LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu); #endif diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index bfdb07a61c..24da89763c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -887,8 +887,10 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in nr_scheduled_response_t scheduled_response; nr_dcireq_t dcireq; + LOG_D(MAC,"Melissa we got herre %s():%d\n", __FUNCTION__, __LINE__); if(mac->cg != NULL){ // we have a cg + LOG_D(MAC,"Melissa we got herre %s():%d\n", __FUNCTION__, __LINE__); dcireq.module_id = mod_id; dcireq.gNB_index = gNB_index; dcireq.cc_id = cc_id; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 79f6dbee1b..a4a7e18a3f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -396,8 +396,9 @@ uint32_t schedule_control_sib1(module_id_t module_id, rbSize, nrOfSymbols, N_PRB_DMRS * dmrs_length,0, 0,1) >> 3; } while (TBS < gNB_mac->sched_ctrlCommon->num_total_bytes); - AssertFatal(TBS>=gNB_mac->sched_ctrlCommon->num_total_bytes,"Couldn't allocate enough resources for %d bytes in SIB1 PDSCH\n", - gNB_mac->sched_ctrlCommon->num_total_bytes); + AssertFatal(TBS>=gNB_mac->sched_ctrlCommon->num_total_bytes, + "Couldn't allocate (TBS = %d) enough resources for %d bytes in SIB1 PDSCH\n", + TBS, gNB_mac->sched_ctrlCommon->num_total_bytes); gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize = rbSize; gNB_mac->sched_ctrlCommon->sched_pdsch.rbStart = 0; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index ed33aa58f9..ad1d68028e 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -271,6 +271,7 @@ static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_ { nfapi_nr_dl_dci_pdu_t *dci_pdu_list = &pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[j]; if ((dci_pdu_list->RNTI != mac->crnti) && + (dci_pdu_list->RNTI != 0xffff) && ((dci_pdu_list->RNTI != mac->ra.ra_rnti) || mac->ra.RA_RAPID_found)) { LOG_D(NR_MAC, "We are filtering PDCCH DCI pdu because RNTI doesnt match!\n"); @@ -341,7 +342,12 @@ static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi for (int i = 0; i < num_pdus; i++) { nfapi_nr_pdu_t *pdu_list = &tx_data_request->pdu_list[i]; - if(mac->ra.ra_state <= WAIT_RAR) + if (dl_info->dci_ind->number_of_dcis > 0 && dl_info->dci_ind->dci_list[i].rnti == 0xffff) //Melissa this is bad find a better way + { + fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_SIB); + pdu_idx++; + } + else if(mac->ra.ra_state <= WAIT_RAR) { fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_RAR); pdu_idx++; @@ -548,7 +554,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, int slot = 0; NR_UE_MAC_INST_t *mac = get_mac_inst(0); - if (mac->scc == NULL) + if (mac->scc == NULL) //Melissa, if we comment this out, we see the SIB! { return; } @@ -734,10 +740,11 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea ul_tti_request->SFN, ul_tti_request->Slot); if (nr_uci_ind_queue.num_items > 0) //TODO: In the future UL_TTIs can be for ULSCH and SRS. { - LOG_I(NR_MAC, "Melissa, we added UL_TTI_REQ to queue for sfn slot %d %d\n", + LOG_D(NR_MAC, "We added UL_TTI_REQ to queue for sfn slot %d %d\n", ul_tti_request->SFN, ul_tti_request->Slot); if (!put_queue(&nr_ul_tti_req_queue, ul_tti_request)) { + LOG_D(NR_PHY, "put_queue failed for nr_ul_tti_req_queue.\n"); reset_queue(&nr_ul_tti_req_queue); if (!put_queue(&nr_ul_tti_req_queue, ul_tti_request)) { @@ -754,10 +761,11 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea mitigate proxy timing issues. */ else if (nr_uci_ind_queue.num_items == 0) { - LOG_I(NR_MAC, "Melissa, we added UL_TTI_REQ to queue for sfn slot %d %d\n", + LOG_D(NR_MAC, "We added UL_TTI_REQ to wait queue for sfn slot %d %d\n", ul_tti_request->SFN, ul_tti_request->Slot); if (!put_queue(&nr_wait_ul_tti_req_queue, ul_tti_request)) { + LOG_D(NR_PHY, "put_queue failed for nr_wait_ul_tti_req_queue.\n"); reset_queue(&nr_wait_ul_tti_req_queue); if (!put_queue(&nr_wait_ul_tti_req_queue, ul_tti_request)) { diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 2c05528a57..071d61ec1d 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -214,16 +214,19 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration) { LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__); - if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { + if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type) || get_softmodem_params()->emulate_l2) { rrc->carrier.MIB = (uint8_t *) malloc16(4); rrc->carrier.sizeof_MIB = do_MIB_NR(rrc,0); } - if((get_softmodem_params()->sa) && ( (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)))) { - rrc->carrier.sizeof_SIB1 = do_SIB1_NR(&rrc->carrier,configuration); + if(get_softmodem_params()->sa && + ((NODE_IS_DU(rrc->node_type) || + NODE_IS_MONOLITHIC(rrc->node_type) || + get_softmodem_params()->emulate_l2))) { + rrc->carrier.sizeof_SIB1 = do_SIB1_NR(&rrc->carrier, configuration); } - if (!NODE_IS_DU(rrc->node_type)) { + else if (!NODE_IS_DU(rrc->node_type)) { rrc->carrier.SIB23 = (uint8_t *) malloc16(100); AssertFatal(rrc->carrier.SIB23 != NULL, "cannot allocate memory for SIB"); rrc->carrier.sizeof_SIB23 = do_SIB23_NR(&rrc->carrier, configuration); @@ -233,7 +236,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration LOG_I(NR_RRC,"Done init_NR_SI\n"); - if (NODE_IS_MONOLITHIC(rrc->node_type)){ + if (NODE_IS_MONOLITHIC(rrc->node_type) || get_softmodem_params()->emulate_l2){ rrc_mac_config_req_gNB(rrc->module_id, rrc->carrier.ssb_SubcarrierOffset, rrc->carrier.pdsch_AntennaPorts, diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 6a45794e16..d6b1e00336 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -201,8 +201,6 @@ extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * con const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); -static void start_oai_nrue_threads(void); - // from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded) int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const module_id_t module_id, const uint8_t *buffer, @@ -2767,7 +2765,8 @@ void *recv_msgs_from_lte_ue(void *args_p) } return NULL; } -static void start_oai_nrue_threads() + +void start_oai_nrue_threads() { init_queue(&nr_rach_ind_queue); init_queue(&nr_rx_ind_queue); diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 3c074b04ef..f13ad8805d 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -169,6 +169,8 @@ void init_connections_with_lte_ue(void); void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, MessagesIds msg_type); +void start_oai_nrue_threads(void); + /**\brief RRC UE generate RRCSetupRequest message. \param module_id module id \param gNB_index gNB index */ diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index 9c0427789d..7412b79b23 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -205,7 +205,7 @@ gNBs = ////////// MME parameters: - amf_ip_address = ( { ipv4 = "192.168.70.132"; + amf_ip_address = ( { ipv4 = "192.168.16.195"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; @@ -215,10 +215,10 @@ gNBs = NETWORK_INTERFACES : { - GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; - GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; - GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; - GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NG_AMF = "lo:"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "127.0.0.2"; + GNB_INTERFACE_NAME_FOR_NGU = "lo:"; + GNB_IPV4_ADDRESS_FOR_NGU = "127.0.0.2"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 }; @@ -226,26 +226,20 @@ gNBs = ); MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "local_RRC"; - ulsch_max_slots_inactivity = 10; - pusch_TargetSNRx10 = 150; - pucch_TargetSNRx10 = 200; - } + { + num_cc = 1; + local_s_if_name = "lo:"; + remote_s_address = "127.0.0.1"; // pnf addr [!] + local_s_address = "127.0.0.2"; // vnf addr + local_s_portc = 50601; // vnf p5 port + remote_s_portc = 50600; // pnf p5 port [!] + local_s_portd = 50611; // vnf p7 port [!] + remote_s_portd = 50610; // pnf p7 port [!] + tr_s_preference = "nfapi"; + tr_n_preference = "local_RRC"; + } ); -L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - pusch_proc_threads = 8; - prach_dtx_threshold = 120; - pucch0_dtx_threshold = 150; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 - } -); RUs = ( { @@ -273,14 +267,6 @@ THREAD_STRUCT = ( } ); -rfsimulator : -{ - serveraddr = "server"; - serverport = "4043"; - options = (); #("saviq"); or/and "chanmod" - modelname = "AWGN"; - IQfile = "/tmp/rfsimulator.iqs"; -}; security = { # preferred ciphering algorithms