Commit e8f07008 authored by francescomani's avatar francescomani

free RACH structures in the right place for the right triggering cause

parent 1244c9a2
......@@ -1425,7 +1425,7 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id,
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
switch (cause) {
case GO_TO_IDLE:
reset_ra(&mac->ra);
reset_ra(mac, cause);
release_mac_configuration(mac, cause);
nr_ue_init_mac(mac);
nr_ue_mac_default_configs(mac);
......@@ -1433,14 +1433,14 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id,
nr_ue_send_synch_request(mac, module_id, 0, -1);
break;
case DETACH:
reset_ra(&mac->ra);
reset_ra(mac, cause);
reset_mac_inst(mac);
nr_ue_reset_sync_state(mac);
release_mac_configuration(mac, cause);
break;
case T300_EXPIRY:
reset_ra(mac, cause);
reset_mac_inst(mac);
reset_ra(&mac->ra);
mac->state = UE_SYNC; // still in sync but need to restart RA
break;
case RE_ESTABLISHMENT:
......
......@@ -100,7 +100,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(int nb_inst);
NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id);
void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac);
void reset_ra(RA_config_t *ra);
void reset_ra(NR_UE_MAC_INST_t *nr_mac, NR_UE_MAC_reset_cause_t cause);
void release_mac_configuration(NR_UE_MAC_INST_t *mac,
NR_UE_MAC_reset_cause_t cause);
......@@ -307,7 +307,7 @@ void init_RA(NR_UE_MAC_INST_t *mac,
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated);
int16_t get_prach_tx_power(NR_UE_MAC_INST_t *mac);
void free_rach_structures(NR_UE_MAC_INST_t *nr_mac, int bwp_id);
void nr_Msg1_transmitted(NR_UE_MAC_INST_t *mac);
void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id);
void nr_get_msg3_payload(NR_UE_MAC_INST_t *mac, uint8_t *buf, int TBS_max);
......
......@@ -207,14 +207,6 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
// release, if any, Temporary C-RNTI
nr_mac->ra.t_crnti = 0;
// free RACH structs
for (int i = 0; i < MAX_NUM_BWP_UE; i++) {
free(nr_mac->ssb_list[i].tx_ssb);
for (int j = 0; j < MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD; j++)
for (int k = 0; k < MAX_NB_FRAME_IN_PRACH_CONF_PERIOD; k++)
for (int l = 0; l < MAX_NB_SLOT_IN_FRAME; l++)
free(nr_mac->prach_assoc_pattern[i].prach_conf_period_list[j].prach_occasion_slot_map[k][l].prach_occasion);
}
// reset BFI_COUNTER
// TODO beam failure procedure not implemented
......@@ -287,9 +279,26 @@ void release_mac_configuration(NR_UE_MAC_INST_t *mac,
memset(&mac->ul_time_alignment, 0, sizeof(mac->ul_time_alignment));
}
void reset_ra(RA_config_t *ra)
void free_rach_structures(NR_UE_MAC_INST_t *nr_mac, int bwp_id)
{
for (int j = 0; j < MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD; j++)
for (int k = 0; k < MAX_NB_FRAME_IN_PRACH_CONF_PERIOD; k++)
for (int l = 0; l < MAX_NB_SLOT_IN_FRAME; l++)
free(nr_mac->prach_assoc_pattern[bwp_id].prach_conf_period_list[j].prach_occasion_slot_map[k][l].prach_occasion);
free(nr_mac->ssb_list[bwp_id].tx_ssb);
}
void reset_ra(NR_UE_MAC_INST_t *nr_mac, NR_UE_MAC_reset_cause_t cause)
{
RA_config_t *ra = &nr_mac->ra;
if(ra->rach_ConfigDedicated)
asn1cFreeStruc(asn_DEF_NR_RACH_ConfigDedicated, ra->rach_ConfigDedicated);
memset(ra, 0, sizeof(RA_config_t));
if (cause == T300_EXPIRY)
return;
for (int i = 0; i < MAX_NUM_BWP_UE; i++)
free_rach_structures(nr_mac, i);
}
......@@ -1917,6 +1917,7 @@ void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac)
{
// Clear all the lists and maps
const int bwp_id = mac->current_UL_BWP->bwp_id;
free_rach_structures(mac, bwp_id);
memset(&mac->ssb_list[bwp_id], 0, sizeof(ssb_list_info_t));
memset(&mac->prach_assoc_pattern[bwp_id], 0, sizeof(prach_association_pattern_t));
......
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