diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index f30e700614a719a1c5479e2ec465cf4629ff454e..7d200b9a22dea6d38319397ee15e3e97f1248f92 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -175,6 +175,8 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(); \param module_id index of MAC instance(s)*/ NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id); +void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac); + /**\brief called at each slot, slot length based on numerology. now use u=0, scs=15kHz, slot=1ms performs BSR/SR/PHR procedures, random access procedure handler and DLSCH/ULSCH procedures. \param dl_info DL indication diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 9371c8c7df0c1e317add3a48ecd0cb21c2f05596..6b2f4398232d43302d201d9dd1303a414e4a6eb7 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -78,6 +78,58 @@ NR_UE_MAC_INST_t * nr_l2_init_ue() return (nr_ue_mac_inst); } -NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id){ +NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id) +{ return &nr_ue_mac_inst[(int)module_id]; } + +void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) +{ + // MAC reset according to 38.321 Section 5.12 + + nr_ue_mac_default_configs(nr_mac); + // initialize Bj for each logical channel to zero + // Done in default config but to -1 (is that correct?) + + // stop all running timers + // TODO + + // consider all timeAlignmentTimers as expired and perform the corresponding actions in clause 5.2 + // TODO + + // set the NDIs for all uplink HARQ processes to the value 0 + for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) + nr_mac->UL_ndi[k] = -1; // initialize to invalid value + + // stop any ongoing RACH procedure + if (nr_mac->ra.ra_state < RA_SUCCEEDED) + nr_mac->ra.ra_state = RA_UE_IDLE; + + // discard explicitly signalled contention-free Random Access Resources + // TODO not sure what needs to be done here + + // flush Msg3 buffer + // TODO we don't have a Msg3 buffer + + // cancel any triggered Scheduling Request procedure + // Done in default config + + // cancel any triggered Buffer Status Reporting procedure + // Done in default config + + // cancel any triggered Power Headroom Reporting procedure + // TODO PHR not implemented yet + + // flush the soft buffers for all DL HARQ processes + for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) + memset(&nr_mac->dl_harq_info[k], 0, sizeof(NR_UE_HARQ_STATUS_t)); + + // for each DL HARQ process, consider the next received transmission for a TB as the very first transmission + // TODO there is nothing in the MAC indicating first transmission + + // release, if any, Temporary C-RNTI + nr_mac->ra.t_crnti = 0; + + // reset BFI_COUNTER + // TODO beam failure procedure not implemented +} diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c5e8b9d95a3c7fe9352e06fb81f4bb1bd0c154bf..2eee621acebc2c484cc3f456ac4f9aa6c879a90f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -179,6 +179,7 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) mac->scheduling_info.retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf10240; mac->scheduling_info.periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_infinity; mac->scheduling_info.SR_COUNTER = 0; + mac->scheduling_info.SR_pending = 0; mac->scheduling_info.sr_ProhibitTimer = 0; mac->scheduling_info.sr_ProhibitTimer_Running = 0; mac->scheduling_info.sr_id = -1; // invalid init value diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 5874f8fec9ca8a6f5f54eb7f2067f85090fe728b..8107f97abcc34b879fe9677b9231d770fc88b249 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1043,16 +1043,13 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) } mac_pdu_exist = 1; } else { - if (ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator && (mac->state == UE_CONNECTED || (ra->ra_state == WAIT_RAR && ra->cfra))){ - // Getting IP traffic to be transmitted nr_ue_get_sdu(mod_id, cc_id,frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes); mac_pdu_exist = 1; } - } // Config UL TX PDU