From 30065ef01432e6e53e6f797312eee431ad2bfe8d Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Mon, 20 Sep 2021 13:16:24 -0700 Subject: [PATCH] Removing hacks to gNB code for NSA mode --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 15 +--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 43 ++++------ .../NR_MAC_gNB/gNB_scheduler_primitives.c | 2 - .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 11 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 85 +------------------ openair2/LAYER2/NR_MAC_gNB/main.c | 1 - openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 - 7 files changed, 24 insertions(+), 137 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index a5ec98d115..07c8b7b75a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -151,10 +151,6 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, nfapi_nr_tx_data_request_t *TX_req = &gNB->TX_req[0]; gNB->pdu_index[CC_idP] = 0; - if (NFAPI_MODE == NFAPI_MODE_VNF) - { - memset(pdcch, 0, sizeof(**pdcch) * MAX_NUM_BWP * MAX_NUM_CORESET); - } DL_req[CC_idP].SFN = frameP; DL_req[CC_idP].Slot = slotP; @@ -358,12 +354,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP); const int bwp_id = 1; + gNB_MAC_INST *gNB = RC.nrmac[module_idP]; - if (frame == gNB->handled_frame && slot== gNB->handled_slot) { - LOG_E(NR_MAC, "Dropping becasue frame %d == gNB frame %d, slot %d == gNb slot %d\n", - frame, gNB->handled_frame, slot, gNB->handled_slot); - return; - } NR_COMMON_channels_t *cc = gNB->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -408,6 +400,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, const int last_slot = (slot + num_slots - 1) % num_slots; uint16_t *vrb_map_UL = cc[CC_id].vrb_map_UL; memset(&vrb_map_UL[last_slot * MAX_BWP_SIZE], 0, sizeof(uint16_t) * MAX_BWP_SIZE); + clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame, slot); /*VNF first entry into scheduler. Since frame numbers for future_ul_tti_req of some future slots @@ -460,8 +453,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_csirs_scheduling(module_idP, frame, slot, nr_slots_per_frame[*scc->ssbSubcarrierSpacing]); // Schedule CSI measurement reporting: check in slot 0 for the whole frame - //if (slot == 0) - // nr_csi_meas_reporting(module_idP, frame, slot); Melissa Elkadi, hack to keep from crashing + if (slot == 0) + nr_csi_meas_reporting(module_idP, frame, slot); // This schedule RA procedure if not in phy_test mode // Otherwise already consider 5G already connected diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index d9c5675ddc..44cde6137a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -56,7 +56,7 @@ #define HALFWORD 16 #define WORD 32 //#define SIZE_OF_POINTER sizeof (void *) -//static int loop_dcch_dtch = DL_SCH_LCID_DTCH; +static int loop_dcch_dtch = DL_SCH_LCID_DTCH; void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp) { @@ -135,8 +135,6 @@ void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t * } } -int harq_rounds = 0; -int harq_pid = 0; // Compute and write all MAC CEs and subheaders, and return number of written // bytes @@ -394,14 +392,14 @@ void nr_store_dlsch_buffer(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; sched_ctrl->num_total_bytes = 0; - if ((sched_ctrl->lcid_mask&(1<<4)) > 0 && UE_info->loop_dcch_dtch[UE_id] == DL_SCH_LCID_DCCH1) - UE_info->loop_dcch_dtch[UE_id] = DL_SCH_LCID_DTCH; - else if ((sched_ctrl->lcid_mask&(1<<1)) > 0 && UE_info->loop_dcch_dtch[UE_id] == DL_SCH_LCID_DTCH) - UE_info->loop_dcch_dtch[UE_id] = DL_SCH_LCID_DCCH; - else if ((sched_ctrl->lcid_mask&(1<<2)) > 0 && UE_info->loop_dcch_dtch[UE_id] == DL_SCH_LCID_DCCH) - UE_info->loop_dcch_dtch[UE_id] = DL_SCH_LCID_DCCH1; + if ((sched_ctrl->lcid_mask&(1<<4)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH1) + loop_dcch_dtch = DL_SCH_LCID_DTCH; + else if ((sched_ctrl->lcid_mask&(1<<1)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DTCH) + loop_dcch_dtch = DL_SCH_LCID_DCCH; + else if ((sched_ctrl->lcid_mask&(1<<2)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH) + loop_dcch_dtch = DL_SCH_LCID_DCCH1; - const int lcid = UE_info->loop_dcch_dtch[UE_id]; + const int lcid = loop_dcch_dtch; // const int lcid = DL_SCH_LCID_DTCH; const uint16_t rnti = UE_info->rnti[UE_id]; sched_ctrl->rlc_status[lcid] = mac_rlc_status_ind(module_id, @@ -416,25 +414,25 @@ void nr_store_dlsch_buffer(module_id_t module_id, 0); sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; LOG_D(NR_MAC, - "%d.%d, LCID%d:->DLSCH, RLC status %d bytes. sched_ctrl %p RC %p module_id %d UE_info %p UE_id %d \n", + "%d.%d, LCID%d:->DLSCH, RLC status %d bytes. \n", frame, slot, lcid, - sched_ctrl->num_total_bytes, sched_ctrl, &RC, module_id, UE_info, UE_id); + sched_ctrl->num_total_bytes); if (sched_ctrl->num_total_bytes == 0 && !sched_ctrl->ta_apply) /* If TA should be applied, give at least one RB */ - continue; + return; LOG_D(NR_MAC, - "[%s][%d.%d], %s%d->DLSCH, RLC status %d bytes TA %d sched_ctrl %p UE_id %d\n", + "[%s][%d.%d], %s%d->DLSCH, RLC status %d bytes TA %d\n", __func__, frame, slot, lcid<4?"DCCH":"DTCH", lcid, sched_ctrl->rlc_status[lcid].bytes_in_buffer, - sched_ctrl->ta_apply, sched_ctrl, UE_id); + sched_ctrl->ta_apply); } } @@ -884,15 +882,8 @@ void nr_schedule_ue_spec(module_id_t module_id, const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = bwp ? sched_ctrl->coreset->controlResourceSetId : gNB_mac->sched_ctrlCommon->coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = gNB_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid]; - //nfapi_nr_dl_tti_pdcch_pdu_rel15_t temp; - // if(NFAPI_MODE == NFAPI_MODE_VNF){ - // memcpy(temp,gNB_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid],sizeof(nfapi_nr_dl_tti_pdcch_pdu_rel15_t)); - // pdcch_pdu = temp; - - // } - if (!pdcch_pdu) { - printf("creating pdcch pdu, pdcch_pdu = NULL. \n"); + LOG_I(NR_MAC, "creating pdcch pdu, pdcch_pdu = NULL. \n"); nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset(dl_tti_pdcch_pdu, 0, sizeof(nfapi_nr_dl_tti_request_pdu_t)); dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE; @@ -1106,7 +1097,7 @@ void nr_schedule_ue_spec(module_id_t module_id, /* next, get RLC data */ // const int lcid = DL_SCH_LCID_DTCH; - const int lcid = UE_info->loop_dcch_dtch[UE_id]; + const int lcid = loop_dcch_dtch; int dlsch_total_bytes = 0; if (sched_ctrl->num_total_bytes > 0) { tbs_size_t len = 0; @@ -1133,8 +1124,8 @@ void nr_schedule_ue_spec(module_id_t module_id, 0, 0); - LOG_I(NR_MAC, - "Melissa Elkadi %4d.%2d RNTI %04x: %d bytes from %s %d (ndata %d, remaining size %d)\n", + LOG_D(NR_MAC, + "%4d.%2d RNTI %04x: %d bytes from %s %d (ndata %d, remaining size %d)\n", frame, slot, rnti, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 962b1de6a8..1948959d55 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -62,7 +62,6 @@ #include "common/ran_context.h" extern RAN_CONTEXT_t RC; -uint8_t count = 0; uint8_t harq_pid_ul = -1; int flag = 0; // Note the 2 scs values in the table names represent resp. scs_common and pdcch_scs /// LUT for the number of symbols in the coreset indexed by coreset index (4 MSB rmsi_pdcch_config) @@ -1884,7 +1883,6 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG int UE_id = i; UE_info->num_UEs++; UE_info->active[UE_id] = true; - UE_info->loop_dcch_dtch[UE_id] = DL_SCH_LCID_DTCH; if (CellGroup) UE_info->Msg4_ACKed[UE_id] = true; else UE_info->Msg4_ACKed[UE_id] = false; UE_info->rnti[UE_id] = rntiP; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index f015e93b63..b56f57c056 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -47,7 +47,6 @@ void nr_fill_nfapi_pucch(module_id_t mod_id, nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[mod_id]->UL_tti_req_ahead[0][pucch->ul_slot]; - future_ul_tti_req->SFN = pucch->frame; // Melissa Elkadi, hack so gNB doesnt crash below AssertFatal(future_ul_tti_req->SFN == pucch->frame && future_ul_tti_req->Slot == pucch->ul_slot, "future UL_tti_req's frame.slot %d.%d does not match PUCCH %d.%d\n", @@ -1113,9 +1112,6 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, sub_frame_t slot, const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_234) { - NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; - UE_info->active[0] = 1; - UE_info->rnti[0] = uci_234->rnti; int UE_id = find_nr_UE_id(mod_id, uci_234->rnti); if (UE_id < 0) { LOG_E(MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_234->rnti); @@ -1127,6 +1123,7 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, if ( RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->csi_MeasConfig==NULL) return; NR_CSI_MeasConfig_t *csi_MeasConfig = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; // tpc (power control) @@ -1240,7 +1237,7 @@ int nr_acknack_scheduling(int mod_id, get_pdsch_to_harq_feedback(mod_id, UE_id, ss_type, pdsch_to_harq_feedback); /* there is a HARQ. Check whether we can use it for this ACKNACK */ - if (pucch->dai_c > 0 && pucch->frame == frame) { + if (pucch->dai_c > 0) { /* this UE already has a PUCCH occasion */ DevAssert(pucch->frame == frame); @@ -1276,10 +1273,6 @@ int nr_acknack_scheduling(int mod_id, * scheduled a lot and used all AckNacks, pucch->frame might have been * wrapped around to next frame */ if (frame != pucch->frame || pucch->ul_slot < first_ul_slot_tdd) { - if (pucch->dai_c != 0) //Melissa Elkadi, hacking this code to stop gNB from crashing - { - pucch->dai_c = 0; - } AssertFatal(pucch->sr_flag + pucch->dai_c == 0, "expected no SR/AckNack for UE %d in %4d.%2d, but has %d/%d for %4d.%2d\n", diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 403ad3a219..378a729397 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -826,7 +826,6 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, } } - long get_K2(NR_ServingCellConfigCommon_t *scc,NR_BWP_Uplink_t *ubwp, int time_domain_assignment, int mu) { DevAssert(scc); const NR_PUSCH_TimeDomainResourceAllocation_t *tda_list = ubwp ? @@ -1278,6 +1277,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); const uint16_t symb = ((1 << nrOfSymbols) - 1) << startSymbolIndex; + int st = 0, e = 0, len = 0; for (int i = 0; i < bwpSize; i++) { while ((vrb_map_UL[i] & symb) != 0 && i < bwpSize) @@ -1292,7 +1292,6 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t } st = e - len + 1; - uint8_t rballoc_mask[bwpSize]; /* Calculate mask: if any RB in vrb_map_UL is blocked (1), the current RB will be 0 */ @@ -1310,23 +1309,6 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t return true; } -static inline int timespec_diff_in_milliseconds(struct timespec *a, struct timespec *b) -{ - int diff_in_ms = (a->tv_sec - b->tv_sec) * 1000 + a->tv_nsec /1000000 - b->tv_nsec / 1000000; - return diff_in_ms; -} - -typedef struct _sched_info -{ - uint16_t rnti; - uint16_t sfn; - uint16_t slot; - int8_t harq_id; - struct timespec ts; -} sched_info; - -sched_info prev_sched[MAX_MOBILES_PER_GNB]; - nr_pp_impl_ul nr_init_fr1_ulsch_preprocessor(module_id_t module_id, int CC_id) { /* in the PF algorithm, we have to use the TBsize to compute the coefficient. @@ -1394,55 +1376,6 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) if (sched_pusch->rbSize <= 0) continue; - struct timespec ts; - if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) - abort(); - - if (prev_sched[UE_id].rnti != 0) - { - uint16_t prev_frame = prev_sched[UE_id].sfn; - uint16_t prev_slot = prev_sched[UE_id].slot; - int sfnslot_delta = NFAPI_SFNSLOT2DEC(frame, slot) - NFAPI_SFNSLOT2DEC(prev_frame, prev_slot); - if (sfnslot_delta < 0) - { - sfnslot_delta += NFAPI_SFNSLOT2DEC(1024,0); - } - // If diff is more than half of maximum frame: we ignore it. - if (sfnslot_delta > NFAPI_SFNSLOT2DEC(512, 0)) - { - LOG_D(NR_MAC, "%s() SFN/SLOT DELTA between Sched and Previous. UEID %d, rnti %x Delta %d. " - "Current:%d.%d Prev(%d):%d.%d --> Skip\n\n\n\n\n\n\n\n\n", - __func__, UE_id, UE_info->rnti[UE_id], sfnslot_delta - NFAPI_SFNSLOT2DEC(1024,0), - frame, slot, - prev_sched[UE_id].harq_id, prev_frame, prev_slot); - continue; - } - else - { - LOG_D(NR_MAC, "%s() SFN/SLOT DELTA between Sched and Previous. UEID %d, rnti %x Delta %d. " - "Current:%d.%d Prev(%d):%d.%d\n\n\n\n\n\n\n\n\n", - __func__, UE_id, UE_info->rnti[UE_id], sfnslot_delta, - frame, slot, - prev_sched[UE_id].harq_id, prev_frame, prev_slot); - } - - int time_diff_in_ms = timespec_diff_in_milliseconds (&ts, &prev_sched[UE_id].ts); - - // The sched tx duration between ul dci req is assumed between 4 ms to 6 ms. - if (vnf_pnf_sfnslot_delta < 0 || time_diff_in_ms < 4 * (sfnslot_delta / 10) - || time_diff_in_ms > 6 * (sfnslot_delta / 10)) - { - continue; - } - else - { - LOG_D(NR_MAC, "%s() SFN/SLOT DELTA between Proxy and gNB. UEID %d, rnti %x Delta %3d. " - "gNB:%4d.%-2d slot_diff %4d time_diff %d\n\n\n\n\n\n\n\n\n", - __func__, UE_id, UE_info->rnti[UE_id], vnf_pnf_sfnslot_delta, - frame, slot, sfnslot_delta, time_diff_in_ms); - } - } - uint16_t rnti = UE_info->rnti[UE_id]; sched_ctrl->SR = false; @@ -1525,24 +1458,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) sched_ctrl->sched_ul_bytes, sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes); - - gNB_MAC_INST *gNB = RC.nrmac[0]; - if (sched_pusch->frame == gNB->handled_frame && sched_pusch->slot == gNB->handled_slot) { - LOG_E(NR_MAC, "Dropping because frame %d == gNB frame %d, slot %d == gNb slot %d\n", - sched_pusch->frame, gNB->handled_frame, sched_pusch->slot, gNB->handled_slot); - return; - } - gNB->handled_frame = frame; - gNB->handled_slot = slot; - prev_sched[UE_id].rnti = rnti; - prev_sched[UE_id].sfn = frame; - prev_sched[UE_id].slot = slot; - prev_sched[UE_id].harq_id = harq_id; - prev_sched[UE_id].ts = ts; - /* PUSCH in a later slot, but corresponding DCI now! */ nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[module_id]->UL_tti_req_ahead[0][sched_pusch->slot]; - future_ul_tti_req->SFN = sched_pusch->frame; // Melissa Elkadi, we hacked this to keep gNB from crashing AssertFatal(future_ul_tti_req->SFN == sched_pusch->frame && future_ul_tti_req->Slot == sched_pusch->slot, "%d.%d future UL_tti_req's frame.slot %d.%d does not match PUSCH %d.%d\n", diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 6b0e6553b8..117c18ae8d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -81,7 +81,6 @@ void mac_top_init_gNB(void) RC.nrmac[i]->ul_handle = 0; - RC.nrmac[i]->handled_frame = 1025; RC.nrmac[i]->first_MIB = true; if (get_softmodem_params()->phy_test) { diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 495fcca57e..22da5223c0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -641,7 +641,6 @@ typedef struct { // UE selected beam index uint8_t UE_beam_index[MAX_MOBILES_PER_GNB]; bool Msg4_ACKed[MAX_MOBILES_PER_GNB]; - int loop_dcch_dtch[MAX_MOBILES_PER_GNB]; } NR_UE_info_t; typedef void (*nr_pp_impl_dl)(module_id_t mod_id, @@ -754,9 +753,6 @@ typedef struct gNB_MAC_INST_s { NR_UE_sched_ctrl_t *sched_ctrlCommon; NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config[64]; - frame_t handled_frame; - sub_frame_t handled_slot; - bool first_MIB; } gNB_MAC_INST;