Commit 4b019293 authored by francescomani's avatar francescomani

reset MAC

parent b2c5f4bc
......@@ -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
......
......@@ -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
}
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment