From 368977b3bb7a02c7e6fb6ade7bf3661db26d715e Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Fri, 12 Nov 2021 09:03:47 -0800 Subject: [PATCH 01/12] The NRUE and gNB are connected to the 5GCN! When IP traffic is started on the NRUE, the gNB immediately crashes --- .../episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf | 6 +++--- ci-scripts/conf_files/episci/episci_nr-ue.nfapi.conf | 8 ++++++++ ci-scripts/conf_files/episci/episci_ue_test_sfr.conf | 6 +++--- executables/nr-ue.c | 6 ++++++ openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 4 ++-- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 +- openair2/RRC/LTE/rrc_eNB.c | 2 +- targets/COMMON/create_tasks.c | 2 +- 8 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf index e0d31e46f7..3a14b8c7f7 100644 --- a/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/episci/episci_gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -10,10 +10,10 @@ gNBs = gNB_name = "gNB-OAI"; // Tracking area code, 0x0000 and 0xfffe are reserved values - tracking_area_code = 1; + tracking_area_code = 40960; plmn_list = ({ mcc = 208; - mnc = 99; + mnc = 95; mnc_length = 2; snssaiList = ( { @@ -205,7 +205,7 @@ gNBs = ////////// AMF parameters: - amf_ip_address = ( { ipv4 = "192.168.61.195"; + amf_ip_address = ( { ipv4 = "192.168.70.132"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; diff --git a/ci-scripts/conf_files/episci/episci_nr-ue.nfapi.conf b/ci-scripts/conf_files/episci/episci_nr-ue.nfapi.conf index b12e0c8d05..f5563ecc02 100644 --- a/ci-scripts/conf_files/episci/episci_nr-ue.nfapi.conf +++ b/ci-scripts/conf_files/episci/episci_nr-ue.nfapi.conf @@ -15,6 +15,14 @@ log_config = { rrc_log_verbosity ="full"; }; +uicc0 = { +imsi = "208950000000031"; +key = "0c0a34601d4f07677303652c0462535b"; +opc= "63bfa50ee6523365ff14c1f45f88737d"; +dnn= "oai"; +nssai_sst=222; +nssai_sd=123; +} L1s = ( { diff --git a/ci-scripts/conf_files/episci/episci_ue_test_sfr.conf b/ci-scripts/conf_files/episci/episci_ue_test_sfr.conf index e98e1b92f1..1ebe993038 100644 --- a/ci-scripts/conf_files/episci/episci_ue_test_sfr.conf +++ b/ci-scripts/conf_files/episci/episci_ue_test_sfr.conf @@ -92,14 +92,14 @@ UE0: }; SIM: { - MSIN="100000025"; + MSIN="0000000031"; USIM_API_K="0c0a34601d4f07677303652c0462535b"; - OPC="ba05688178e398bedc100674071002cb"; + OPC="63bfa50ee6523365ff14c1f45f88737d"; MSISDN="1011234561024"; }; # Home PLMN Selector with Access Technology - HPLMN= "320230"; + HPLMN= "20895"; # User controlled PLMN Selector with Access Technology UCPLMN_LIST = (); diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 99f71e4656..94d059ac7d 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -500,6 +500,12 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) nr_ue_ul_indication(&ul_info); check_nr_prach(mac, &ul_info, &prach_resources); } + if(IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) { + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + protocol_ctxt_t ctxt; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, mac->crnti, frame, slot, 0); + pdcp_run(&ctxt); + } process_queued_nr_nfapi_msgs(mac, sfn_slot); free(slot_ind); slot_ind = NULL; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 5d52aa70ca..c4f3b2d372 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1288,7 +1288,7 @@ pdcp_run ( // IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer // if (LINK_ENB_PDCP_TO_GTPV1U && ctxt_pP->enb_flag == ENB_FLAG_NO) { - if (!get_softmodem_params()->nsa && (!EPC_MODE_ENABLED || ctxt_pP->enb_flag == ENB_FLAG_NO)) { + if (!get_softmodem_params()->emulate_l1 && (!EPC_MODE_ENABLED || ctxt_pP->enb_flag == ENB_FLAG_NO)) { pdcp_fifo_read_input_sdus(ctxt_pP); } @@ -1298,7 +1298,7 @@ pdcp_run ( } else { start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip); } - if(!get_softmodem_params()->nsa) { + if(!get_softmodem_params()->emulate_l1) { pdcp_fifo_flush_sdus(ctxt_pP); } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index a63b5efc30..d12d390eb0 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -907,7 +907,7 @@ void *nrue_standalone_pnf_task(void *context) nr_phy_channel_params_t *ch_info = CALLOC(1, sizeof(*ch_info)); memcpy(ch_info, buffer, sizeof(*ch_info)); - LOG_I(NR_PHY, "Received_SINR = %f, sfn:slot %d:%d\n", + LOG_D(NR_PHY, "Received_SINR = %f, sfn:slot %d:%d\n", ch_info->sinr, NFAPI_SFNSLOT2SFN(ch_info->sfn_slot), NFAPI_SFNSLOT2SLOT(ch_info->sfn_slot)); if (!put_queue(&nr_chan_param_queue, ch_info)) diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index b6259d0161..79b5318b4b 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -7975,7 +7975,7 @@ rrc_eNB_decode_dcch( /*FK: left the condition as is for the case MME is used (S1 mode) but setting dedicated_DRB = 1 otherwise (noS1 mode) so that no second RRCReconfiguration message activationg more DRB is sent as this causes problems with the nasmesh driver.*/ int flexran_agent_handover = 0; - if (EPC_MODE_ENABLED || get_softmodem_params()->nsa) { + if (EPC_MODE_ENABLED || get_softmodem_params()->emulate_l1) { if (ue_context_p->ue_context.StatusRrc == RRC_RECONFIGURED) { dedicated_DRB = 1; LOG_I(RRC, diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index 55ad258b24..95b0798be5 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -59,7 +59,7 @@ int create_tasks(uint32_t enb_nb) { rc = itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL); AssertFatal(rc >= 0, "Create task for RRC eNB failed\n"); - if (get_softmodem_params()->nsa || (EPC_MODE_ENABLED && split73 != SPLIT73_DU)) { + if (get_softmodem_params()->emulate_l1 || (EPC_MODE_ENABLED && split73 != SPLIT73_DU)) { rc = itti_create_task(TASK_SCTP, sctp_eNB_task, NULL); AssertFatal(rc >= 0, "Create task for SCTP failed\n"); } From d28deb3c3455cf753377c619af31d65b97249b78 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Wed, 17 Nov 2021 11:33:05 -0800 Subject: [PATCH 02/12] Handling multiplexing of UCI indications The IP traffic of a single NRUE works most of the time in this commit. There seems to be a bug in the gNB and it will occassionally crash with a heap-buffer-overflow. This will be looked at in the next commit. The changes in this commit include gathering all of the UCI indications in the queue that have the same scheduled sfn_slot and sending them as one aggregated UCI when the scheduled sfn_slot matches the received ul_tti_request. --- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 65 ++++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index d12d390eb0..60b4f826a6 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -497,6 +497,68 @@ static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n dl_info->slot = ul_dci_req->Slot; } +static void copy_uci_inds_to_single_uci_ind(NR_UE_MAC_INST_t *mac, + nfapi_nr_uci_indication_t *uci_from_queue, + nfapi_nr_uci_indication_t *new_uci, + int index) +{ + /* In openair1/SCHED_NR_UE/fapi_nr_ue_l1.c nr_ue_schedule_response_stub(), the + number of UCIs is hard coded to 1. This is why we always use index 0 of the + queued UCI indication to fill the new multiplexed UCI indication */ + + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &new_uci->uci_list[index].pucch_pdu_format_0_1; + memset(pdu_0_1, 0, sizeof(*pdu_0_1)); + new_uci->uci_list[index].pdu_type = uci_from_queue->uci_list[0].pdu_type; + new_uci->uci_list[index].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); + + nfapi_nr_uci_pucch_pdu_format_0_1_t *queued_pdu_0_1 = &uci_from_queue->uci_list[0].pucch_pdu_format_0_1; + pdu_0_1->handle = queued_pdu_0_1->handle; + pdu_0_1->rnti = queued_pdu_0_1->rnti; + pdu_0_1->pucch_format = queued_pdu_0_1->pucch_format; + pdu_0_1->ul_cqi = queued_pdu_0_1->ul_cqi; + pdu_0_1->timing_advance = queued_pdu_0_1->timing_advance; + pdu_0_1->rssi = queued_pdu_0_1->rssi; + return; +} + +nfapi_nr_uci_indication_t *multiplex_uci_ind(NR_UE_MAC_INST_t *mac) +{ + int num_active_harqs = 0; + for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) + { + int harq_slot = mac->dl_harq_info[i].dl_slot + mac->dl_harq_info[i].feedback_to_ul; + frame_t harq_sfn = mac->dl_harq_info[i].dl_frame; + int harq_sfn_slot = NFAPI_SFNSLOT2HEX(harq_sfn, harq_slot); + if (harq_sfn_slot == mac->nr_ue_emul_l1.active_harq_sfn_slot) + { + LOG_D(NR_MAC, "The sfn_slot stored in the current harq UE mac " + "instance matches the active_harq_sfn_slot we have." + " mac->harq_info[%d].sfn_slot = %d %d and active = %d %d\n", + i, harq_sfn, harq_slot, + NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot), + NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot)); + num_active_harqs++; + } + } + nfapi_nr_uci_indication_t *uci_ind = MALLOC(sizeof(*uci_ind)); + uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; + uci_ind->sfn = NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot); + uci_ind->slot = NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot); + uci_ind->num_ucis = num_active_harqs; + uci_ind->uci_list = MALLOC(uci_ind->num_ucis * sizeof(*uci_ind->uci_list)); + if (num_active_harqs != nr_uci_ind_queue.num_items) + { + LOG_E(NR_MAC, "The number of active harqs %d should match the number of UCIs in the queue %lu\n", + num_active_harqs, nr_uci_ind_queue.num_items); + } + for (int j = 0; j < num_active_harqs; j++) + { + nfapi_nr_uci_indication_t *queued_uci_ind = get_queue(&nr_uci_ind_queue); + copy_uci_inds_to_single_uci_ind(mac, queued_uci_ind, uci_ind, j); + } + return uci_ind; +} + static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_ul_tti_request_t *ul_tti_req) { NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); @@ -516,8 +578,7 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n pdu_list->pdu_type, ul_tti_req->pdus_list[i].pucch_pdu.rnti, pdu_list->pucch_pdu.sr_flag, pdu_list->pucch_pdu.bit_len_harq); if (pdu_list->pdu_type == NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE && pdu_list->pucch_pdu.rnti == mac->crnti) { - LOG_I(NR_MAC, "This is the number of UCIs in the queue %ld\n", nr_uci_ind_queue.num_items); - nfapi_nr_uci_indication_t *uci_ind = get_queue(&nr_uci_ind_queue); + nfapi_nr_uci_indication_t *uci_ind = multiplex_uci_ind(mac); if (uci_ind && uci_ind->num_ucis > 0) { LOG_D(NR_MAC, "This is the SFN/SF [%d, %d] and RNTI %x of the UCI ind. ul_tti_req.pdu[%d]->rnti = %x \n", From bb4db86d6146640416b423a5a7705c97a94906e4 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Wed, 17 Nov 2021 15:38:43 -0800 Subject: [PATCH 03/12] Do not handle multiplexing of UCIs if nothing is in UCI queue --- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 60b4f826a6..9e7eb1ee35 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -578,6 +578,10 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n pdu_list->pdu_type, ul_tti_req->pdus_list[i].pucch_pdu.rnti, pdu_list->pucch_pdu.sr_flag, pdu_list->pucch_pdu.bit_len_harq); if (pdu_list->pdu_type == NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE && pdu_list->pucch_pdu.rnti == mac->crnti) { + if (nr_uci_ind_queue.num_items <= 0) + { + return; + } nfapi_nr_uci_indication_t *uci_ind = multiplex_uci_ind(mac); if (uci_ind && uci_ind->num_ucis > 0) { From c008c8e60da13d2465f18ea897abcb55931acafd Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Thu, 18 Nov 2021 08:26:12 -0800 Subject: [PATCH 04/12] IP TRAFFIC IS WORKING WITH ONE NR UE IN SA MODE This commit includes a hack fix that has allowed the Ip traffic to work in SA mode. Furthermore, NSA mode (without the EPC) works in this commit as well with up to 4 NSA UEs. We will need to understand better the issue with the UL_DCI handling in the NRUE that was causing the gNB to crash. The AssertFatal in the gNB when the gNB runs out of downlink HARQ PIDs is caused by the NRUE receiving a UL_DCI and then building BOTH a UCI and a CRC/RX pair. So we are essentially sending a UL and DL DCI to the gNB in this case which results in an unexpected HARQ PID being received in the gNB. The filtering in this commit stops the UCI being built in the NRUE when a UL_DCI is recevied. --- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 9e7eb1ee35..87a461d976 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1109,6 +1109,10 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ dl_info->dci_ind->dci_list+i); fapi_nr_dci_indication_pdu_t *dci_index = dl_info->dci_ind->dci_list+i; + if (dci_index->dci_format == 7 && mac->ra.ra_state == RA_SUCCEEDED) { + LOG_D(NR_MAC, "We are filtering a UL_DCI to prevent it from being treated like a DL_DCI\n"); + break; + } dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[dci_index->dci_format]; g_harq_pid = def_dci_pdu_rel15->harq_pid; LOG_D(NR_MAC, "Setting harq_pid = %d and dci_index = %d (based on format)\n", g_harq_pid, dci_index->dci_format); From 2205d6472dbf24a1f100cce5f260e6d2c35316c9 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Thu, 18 Nov 2021 10:43:15 -0800 Subject: [PATCH 05/12] Adding AssertFatal to check for array indicies --- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 87a461d976..4de9310878 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -508,6 +508,9 @@ static void copy_uci_inds_to_single_uci_ind(NR_UE_MAC_INST_t *mac, nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &new_uci->uci_list[index].pucch_pdu_format_0_1; memset(pdu_0_1, 0, sizeof(*pdu_0_1)); + AssertFatal(index <= new_uci->num_ucis, + "Attempting to index past end of uci_list array. Index = %d\n", + index); new_uci->uci_list[index].pdu_type = uci_from_queue->uci_list[0].pdu_type; new_uci->uci_list[index].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); From 16d82de9cf379c86a7f8fd096aa3cdf1ca1d3dbc Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Thu, 18 Nov 2021 11:08:53 -0800 Subject: [PATCH 06/12] Only call pdcp_run for SA 5GCN mode, not NSA mode --- executables/nr-ue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index d08f7cb0bd..9c1d896238 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -492,7 +492,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) nr_ue_ul_indication(&ul_info); check_nr_prach(mac, &ul_info, &prach_resources); } - if(IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) { + if(IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) { NR_UE_MAC_INST_t *mac = get_mac_inst(0); protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, mac->crnti, frame, slot, 0); From 6f69e836a891d713296fa0850fe06cddaa7d4ec2 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Thu, 18 Nov 2021 11:45:47 -0800 Subject: [PATCH 07/12] This commit allows IP traffic to work for 2 UEs in NSA mode The nr_rrc_ue_process_RadioBearerConfig() function call in the RRC layer of the NRUE was removed when it should not have been for NSA mode. This is now added back in for NSA mode. Also, the call to pdcp_run should only be when were NOT in NOS1 mode and ARE in SA mode. This was fixed as well. Ue-to-Ue IP traffic in NSA works, but eventually the NSA UE will crash due to an incorrect PDCCH configuration. This is a bug we will need to look into. It doesnt always crash, only about 40% of the time. And even when the NRUE does crash, it happens towards the end of the simulation. --- executables/nr-ue.c | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 9c1d896238..01444167b0 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -492,7 +492,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) nr_ue_ul_indication(&ul_info); check_nr_prach(mac, &ul_info, &prach_resources); } - if(IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) { + if (!IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) { NR_UE_MAC_INST_t *mac = get_mac_inst(0); protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, mac->crnti, frame, slot, 0); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index e02f500e63..f11dc65195 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -397,7 +397,19 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, SEQUENCE_free( &asn_DEF_NR_RadioBearerConfig, RadioBearerConfig, 1 ); return; } - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if (get_softmodem_params()->nsa) { + protocol_ctxt_t ctxt; + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_id, ENB_FLAG_YES, mac->crnti, 0, 0, 0); + xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)RadioBearerConfig); + LOG_D(NR_RRC, "Calling fill_default_rbconfig_ue at %d with: e_rab_id = %ld, drbID = %ld, cipher_algo = %ld, key = %ld \n", + __LINE__, RadioBearerConfig->drb_ToAddModList->list.array[0]->cnAssociation->choice.eps_BearerIdentity, + RadioBearerConfig->drb_ToAddModList->list.array[0]->drb_Identity, + RadioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm, + *RadioBearerConfig->securityConfig->keyToUse); + nr_rrc_ue_process_RadioBearerConfig(&ctxt, 0, RadioBearerConfig); + } + else if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void *) RadioBearerConfig); } } From a279503db0d3938d1cb9a5d0cd1ebcd6ecf6514d Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Thu, 18 Nov 2021 11:51:03 -0800 Subject: [PATCH 08/12] Fixing formatting for if statement --- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index fe9b68f622..f5372ae6ab 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1298,7 +1298,7 @@ pdcp_run ( } else { start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip); } - if(!get_softmodem_params()->emulate_l1) { + if (!get_softmodem_params()->emulate_l1) { pdcp_fifo_flush_sdus(ctxt_pP); } From 87097d97671ea3ae2cf3b14bf315f81d4a0ba61b Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Fri, 19 Nov 2021 07:55:03 -0800 Subject: [PATCH 09/12] Adding assertFatal to UCI multiplexing --- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 4de9310878..c3230ff37e 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -505,7 +505,10 @@ static void copy_uci_inds_to_single_uci_ind(NR_UE_MAC_INST_t *mac, /* In openair1/SCHED_NR_UE/fapi_nr_ue_l1.c nr_ue_schedule_response_stub(), the number of UCIs is hard coded to 1. This is why we always use index 0 of the queued UCI indication to fill the new multiplexed UCI indication */ - + if (!uci_from_queue) { + LOG_E(NR_MAC, "There was not a UCI in the queue!\n"); + return; + } nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &new_uci->uci_list[index].pucch_pdu_format_0_1; memset(pdu_0_1, 0, sizeof(*pdu_0_1)); AssertFatal(index <= new_uci->num_ucis, @@ -549,11 +552,10 @@ nfapi_nr_uci_indication_t *multiplex_uci_ind(NR_UE_MAC_INST_t *mac) uci_ind->slot = NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot); uci_ind->num_ucis = num_active_harqs; uci_ind->uci_list = MALLOC(uci_ind->num_ucis * sizeof(*uci_ind->uci_list)); - if (num_active_harqs != nr_uci_ind_queue.num_items) - { - LOG_E(NR_MAC, "The number of active harqs %d should match the number of UCIs in the queue %lu\n", - num_active_harqs, nr_uci_ind_queue.num_items); - } + AssertFatal(num_active_harqs == nr_uci_ind_queue.num_items, + "The number of active harqs %d should match the number of UCIs in the queue %lu\n", + num_active_harqs, nr_uci_ind_queue.num_items); + for (int j = 0; j < num_active_harqs; j++) { nfapi_nr_uci_indication_t *queued_uci_ind = get_queue(&nr_uci_ind_queue); From 7f7bda5421c8d2ce33aca359883dbcf4c9eb4f2d Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Fri, 19 Nov 2021 11:22:37 -0800 Subject: [PATCH 10/12] The number of active harqs is included in the UL_TTI_REQ Also, we had two heap-buffer-overflow crashes while filling the CRC_IND and RX_IND. The corrected CALLOC command is included in this commit as well. Lastly, we included a better fix for handling late DL_TTI_REQs. If the number of active harqs is larger than the number of UCIs we have built, this is a good indicator that the DL_TTI_REQ is late. To mitigate problems, we will requeue the UL_TTI_REQ to when the late DL_TTI_REQ comes in, we can handle the late UCI that is built from it. --- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 5 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 60 +++++++++++---------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index c2ae84963b..d3c8b43ddd 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -80,7 +80,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response rx_ind->sfn = scheduled_response->ul_config->sfn; rx_ind->slot = scheduled_response->ul_config->slot; rx_ind->number_of_pdus = scheduled_response->tx_request->number_of_pdus; - rx_ind->pdu_list = CALLOC(1, sizeof(*rx_ind->pdu_list)); + rx_ind->pdu_list = CALLOC(rx_ind->number_of_pdus, sizeof(*rx_ind->pdu_list)); for (int j = 0; j < rx_ind->number_of_pdus; j++) { fapi_nr_tx_request_body_t *tx_req_body = &scheduled_response->tx_request->tx_request_body[j]; @@ -102,7 +102,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response crc_ind->number_crcs = scheduled_response->ul_config->number_pdus; crc_ind->sfn = scheduled_response->ul_config->sfn; crc_ind->slot = scheduled_response->ul_config->slot; - crc_ind->crc_list = CALLOC(1, sizeof(*crc_ind->crc_list)); + crc_ind->crc_list = CALLOC(crc_ind->number_crcs, sizeof(*crc_ind->crc_list)); for (int j = 0; j < crc_ind->number_crcs; j++) { crc_ind->crc_list[j].handle = pusch_config_pdu->handle; @@ -204,6 +204,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response } } } + dl_config->number_pdus = 0; } } diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index c3230ff37e..d07171c352 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -511,7 +511,7 @@ static void copy_uci_inds_to_single_uci_ind(NR_UE_MAC_INST_t *mac, } nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &new_uci->uci_list[index].pucch_pdu_format_0_1; memset(pdu_0_1, 0, sizeof(*pdu_0_1)); - AssertFatal(index <= new_uci->num_ucis, + AssertFatal(index <= new_uci->num_ucis || uci_from_queue->num_ucis == 1, "Attempting to index past end of uci_list array. Index = %d\n", index); new_uci->uci_list[index].pdu_type = uci_from_queue->uci_list[0].pdu_type; @@ -527,34 +527,19 @@ static void copy_uci_inds_to_single_uci_ind(NR_UE_MAC_INST_t *mac, return; } -nfapi_nr_uci_indication_t *multiplex_uci_ind(NR_UE_MAC_INST_t *mac) +static nfapi_nr_uci_indication_t *multiplex_uci_ind(NR_UE_MAC_INST_t *mac, int num_active_harqs) { - int num_active_harqs = 0; - for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) - { - int harq_slot = mac->dl_harq_info[i].dl_slot + mac->dl_harq_info[i].feedback_to_ul; - frame_t harq_sfn = mac->dl_harq_info[i].dl_frame; - int harq_sfn_slot = NFAPI_SFNSLOT2HEX(harq_sfn, harq_slot); - if (harq_sfn_slot == mac->nr_ue_emul_l1.active_harq_sfn_slot) - { - LOG_D(NR_MAC, "The sfn_slot stored in the current harq UE mac " - "instance matches the active_harq_sfn_slot we have." - " mac->harq_info[%d].sfn_slot = %d %d and active = %d %d\n", - i, harq_sfn, harq_slot, - NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot), - NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot)); - num_active_harqs++; - } - } nfapi_nr_uci_indication_t *uci_ind = MALLOC(sizeof(*uci_ind)); uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; uci_ind->sfn = NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot); uci_ind->slot = NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot); uci_ind->num_ucis = num_active_harqs; uci_ind->uci_list = MALLOC(uci_ind->num_ucis * sizeof(*uci_ind->uci_list)); - AssertFatal(num_active_harqs == nr_uci_ind_queue.num_items, - "The number of active harqs %d should match the number of UCIs in the queue %lu\n", - num_active_harqs, nr_uci_ind_queue.num_items); + if (num_active_harqs != nr_uci_ind_queue.num_items) + { + LOG_I(NR_MAC, "The number of active harqs %d doesn't match the number of UCIs in the queue %lu\n", + num_active_harqs, nr_uci_ind_queue.num_items); + } for (int j = 0; j < num_active_harqs; j++) { @@ -587,7 +572,11 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n { return; } - nfapi_nr_uci_indication_t *uci_ind = multiplex_uci_ind(mac); + + int num_active_harqs = pdu_list->pucch_pdu.bit_len_harq; + LOG_I(NR_MAC, "The number of active harqs %d from ul_tti_req\n", num_active_harqs); + nfapi_nr_uci_indication_t *uci_ind = multiplex_uci_ind(mac, num_active_harqs); + if (uci_ind && uci_ind->num_ucis > 0) { LOG_D(NR_MAC, "This is the SFN/SF [%d, %d] and RNTI %x of the UCI ind. ul_tti_req.pdu[%d]->rnti = %x \n", @@ -642,14 +631,27 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n pdu_0_1->harq = NULL; } } - free(uci_ind->uci_list); - uci_ind->uci_list = NULL; - free(uci_ind); - uci_ind = NULL; } - + LOG_D(NR_MAC, "The num_active_harqs %d and uci_ind->num_ucis %d\n", + num_active_harqs, uci_ind->num_ucis); + if (num_active_harqs > uci_ind->num_ucis) + { + LOG_E(NR_MAC, "The num_active_harqs %d > uci_ind->num_ucis %d" + "Which means that the incoming dl_tti_req to build the UCI is late. " + "So we will requeue the ul_tti_req to capture the upcoming UCI\n", + num_active_harqs, uci_ind->num_ucis); + if (!put_queue(&nr_ul_tti_req_queue, ul_tti_req)) + { + LOG_E(NR_PHY, "put_queue failed for ul_tti_req.\n"); + free(ul_tti_req); + ul_tti_req = NULL; + } + } + free(uci_ind->uci_list); + uci_ind->uci_list = NULL; + free(uci_ind); + uci_ind = NULL; } - } } From e1d50ead743f988f593b960b57a4aad1e8619b7b Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Fri, 19 Nov 2021 11:37:02 -0800 Subject: [PATCH 11/12] Removing incorrect setting of num_pdus to 0 --- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 1 - 1 file changed, 1 deletion(-) diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index d3c8b43ddd..3487635063 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -204,7 +204,6 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response } } } - dl_config->number_pdus = 0; } } From 32cca2507506ea496a0ddf5310899269a035fef7 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Fri, 19 Nov 2021 14:14:21 -0800 Subject: [PATCH 12/12] Modifying how we handle the UCI multiplexing. In this commit, we changed the UCI handling. When the UL_TTI_REQ arrives at the NRUE it has info related to how many UCIs we should pull from the queue and send to the gNB. If we do not have that many UCIs available (likely becasue a DL_TTI_REQ is late), then we will requeue the UL_TTI_REQ and wait until we have all the UCI indications before multiplexing. This change makes it easier to handle multiple UCIs becasue previously we would send what we had and then try again later which made keeping track of the UL_TTI_REQ and second UCI more difficult. --- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 107 +++++++++----------- 1 file changed, 50 insertions(+), 57 deletions(-) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index d07171c352..4aafef54a1 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -497,54 +497,48 @@ static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n dl_info->slot = ul_dci_req->Slot; } -static void copy_uci_inds_to_single_uci_ind(NR_UE_MAC_INST_t *mac, - nfapi_nr_uci_indication_t *uci_from_queue, - nfapi_nr_uci_indication_t *new_uci, - int index) -{ - /* In openair1/SCHED_NR_UE/fapi_nr_ue_l1.c nr_ue_schedule_response_stub(), the - number of UCIs is hard coded to 1. This is why we always use index 0 of the - queued UCI indication to fill the new multiplexed UCI indication */ - if (!uci_from_queue) { - LOG_E(NR_MAC, "There was not a UCI in the queue!\n"); - return; - } - nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &new_uci->uci_list[index].pucch_pdu_format_0_1; - memset(pdu_0_1, 0, sizeof(*pdu_0_1)); - AssertFatal(index <= new_uci->num_ucis || uci_from_queue->num_ucis == 1, - "Attempting to index past end of uci_list array. Index = %d\n", - index); - new_uci->uci_list[index].pdu_type = uci_from_queue->uci_list[0].pdu_type; - new_uci->uci_list[index].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); - - nfapi_nr_uci_pucch_pdu_format_0_1_t *queued_pdu_0_1 = &uci_from_queue->uci_list[0].pucch_pdu_format_0_1; - pdu_0_1->handle = queued_pdu_0_1->handle; - pdu_0_1->rnti = queued_pdu_0_1->rnti; - pdu_0_1->pucch_format = queued_pdu_0_1->pucch_format; - pdu_0_1->ul_cqi = queued_pdu_0_1->ul_cqi; - pdu_0_1->timing_advance = queued_pdu_0_1->timing_advance; - pdu_0_1->rssi = queued_pdu_0_1->rssi; - return; -} - static nfapi_nr_uci_indication_t *multiplex_uci_ind(NR_UE_MAC_INST_t *mac, int num_active_harqs) { + if (num_active_harqs <= 0) + { + return NULL; + } + if (num_active_harqs != nr_uci_ind_queue.num_items) + { + LOG_I(NR_MAC, "The number of active harqs %d doesn't match the number of UCIs in the queue %lu\n", + num_active_harqs, nr_uci_ind_queue.num_items); + return NULL; + } + nfapi_nr_uci_indication_t *uci_ind = MALLOC(sizeof(*uci_ind)); uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; uci_ind->sfn = NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot); uci_ind->slot = NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot); uci_ind->num_ucis = num_active_harqs; uci_ind->uci_list = MALLOC(uci_ind->num_ucis * sizeof(*uci_ind->uci_list)); - if (num_active_harqs != nr_uci_ind_queue.num_items) - { - LOG_I(NR_MAC, "The number of active harqs %d doesn't match the number of UCIs in the queue %lu\n", - num_active_harqs, nr_uci_ind_queue.num_items); - } - - for (int j = 0; j < num_active_harqs; j++) + for (int i = 0; i < num_active_harqs; i++) { nfapi_nr_uci_indication_t *queued_uci_ind = get_queue(&nr_uci_ind_queue); - copy_uci_inds_to_single_uci_ind(mac, queued_uci_ind, uci_ind, j); + /* In openair1/SCHED_NR_UE/fapi_nr_ue_l1.c nr_ue_schedule_response_stub(), the + number of UCIs is hard coded to 1. This is why we always use index 0 of the + queued UCI indication to fill the new multiplexed UCI indication */ + AssertFatal(queued_uci_ind, "There was not a UCI in the queue!\n"); + + nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[i].pucch_pdu_format_0_1; + memset(pdu_0_1, 0, sizeof(*pdu_0_1)); + AssertFatal(i < uci_ind->num_ucis, + "Attempting to index past end of uci_list array. Index = %d\n", + i); + uci_ind->uci_list[i].pdu_type = queued_uci_ind->uci_list[0].pdu_type; + uci_ind->uci_list[i].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); + + nfapi_nr_uci_pucch_pdu_format_0_1_t *queued_pdu_0_1 = &queued_uci_ind->uci_list[0].pucch_pdu_format_0_1; + pdu_0_1->handle = queued_pdu_0_1->handle; + pdu_0_1->rnti = queued_pdu_0_1->rnti; + pdu_0_1->pucch_format = queued_pdu_0_1->pucch_format; + pdu_0_1->ul_cqi = queued_pdu_0_1->ul_cqi; + pdu_0_1->timing_advance = queued_pdu_0_1->timing_advance; + pdu_0_1->rssi = queued_pdu_0_1->rssi; } return uci_ind; } @@ -561,6 +555,7 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n AssertFatal(num_pdus <= sizeof(ul_tti_req->pdus_list) / sizeof(ul_tti_req->pdus_list[0]), "Too many pdus %d in ul_tti_req\n", num_pdus); + bool sent_uci = false; for (int i = 0; i < num_pdus; i++) { nfapi_nr_ul_tti_request_number_of_pdus_t *pdu_list = &ul_tti_req->pdus_list[i]; @@ -614,6 +609,7 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n .uci_ind = *uci_ind, }; send_nsa_standalone_msg(&UL_INFO, uci_ind->header.message_id); + sent_uci = true; for (int k = 0; k < uci_ind->num_ucis; k++) { @@ -631,26 +627,21 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n pdu_0_1->harq = NULL; } } + free(uci_ind->uci_list); + uci_ind->uci_list = NULL; + free(uci_ind); + uci_ind = NULL; } - LOG_D(NR_MAC, "The num_active_harqs %d and uci_ind->num_ucis %d\n", - num_active_harqs, uci_ind->num_ucis); - if (num_active_harqs > uci_ind->num_ucis) - { - LOG_E(NR_MAC, "The num_active_harqs %d > uci_ind->num_ucis %d" - "Which means that the incoming dl_tti_req to build the UCI is late. " - "So we will requeue the ul_tti_req to capture the upcoming UCI\n", - num_active_harqs, uci_ind->num_ucis); - if (!put_queue(&nr_ul_tti_req_queue, ul_tti_req)) - { - LOG_E(NR_PHY, "put_queue failed for ul_tti_req.\n"); - free(ul_tti_req); - ul_tti_req = NULL; - } - } - free(uci_ind->uci_list); - uci_ind->uci_list = NULL; - free(uci_ind); - uci_ind = NULL; + } + } + if (!sent_uci) + { + LOG_E(NR_MAC, "The UL_TTI_REQ did not sent a UCI to the gNB. \n"); + if (!put_queue(&nr_ul_tti_req_queue, ul_tti_req)) + { + LOG_E(NR_PHY, "put_queue failed for ul_tti_req.\n"); + free(ul_tti_req); + ul_tti_req = NULL; } } } @@ -1116,6 +1107,8 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ dl_info->dci_ind->dci_list+i); fapi_nr_dci_indication_pdu_t *dci_index = dl_info->dci_ind->dci_list+i; + + /* The check below filters out UL_DCIs (format 7) which are being processed as DL_DCIs. */ if (dci_index->dci_format == 7 && mac->ra.ra_state == RA_SUCCEEDED) { LOG_D(NR_MAC, "We are filtering a UL_DCI to prevent it from being treated like a DL_DCI\n"); break;