Commit f2a7fb53 authored by francescomani's avatar francescomani

fix computation of RA occasions and association period in gNB

parent 91e7030c
...@@ -178,7 +178,7 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac) ...@@ -178,7 +178,7 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac)
float num_ssb_per_RO = ssb_per_rach_occasion[cfg->prach_config.ssb_per_rach.value]; float num_ssb_per_RO = ssb_per_rach_occasion[cfg->prach_config.ssb_per_rach.value];
uint8_t fdm = cfg->prach_config.num_prach_fd_occasions.value; uint8_t fdm = cfg->prach_config.num_prach_fd_occasions.value;
uint64_t L_ssb = (((uint64_t) cfg->ssb_table.ssb_mask_list[0].ssb_mask.value) << 32) | cfg->ssb_table.ssb_mask_list[1].ssb_mask.value; uint64_t L_ssb = (((uint64_t) cfg->ssb_table.ssb_mask_list[0].ssb_mask.value) << 32) | cfg->ssb_table.ssb_mask_list[1].ssb_mask.value;
uint32_t total_RA_occasions = prach_info.N_RA_sfn * prach_info.N_t_slot * prach_info.N_RA_slot * fdm; cc->total_prach_occasions_per_config_period = prach_info.N_RA_sfn * prach_info.N_t_slot * prach_info.N_RA_slot * fdm;
for(int i = 0; i < 64; i++) { for(int i = 0; i < 64; i++) {
if ((L_ssb >> (63 - i)) & 0x01) { // only if the bit of L_ssb at current ssb index is 1 if ((L_ssb >> (63 - i)) & 0x01) { // only if the bit of L_ssb at current ssb index is 1
...@@ -187,15 +187,22 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac) ...@@ -187,15 +187,22 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac)
} }
} }
cc->total_prach_occasions_per_config_period = total_RA_occasions; // An association period, starting from frame 0, for mapping SS/PBCH block indexes to PRACH occasions is the smallest
// value in the set determined by the PRACH configuration period according Table 8.1-1 of 38.213
// such that all tx SSB indexes are mapped at least once to the PRACH occasions within the association period
// An association pattern period includes one or more association periods and is determined
// so that a pattern between PRACH occasions and SS/PBCH block indexes repeats at most every 160 msec
int total_RA_occasions = 0;
for (int i = 1; (1 << (i - 1)) <= prach_info.max_association_period; i++) { for (int i = 1; (1 << (i - 1)) <= prach_info.max_association_period; i++) {
cc->max_association_period = (1 << (i - 1)); cc->max_association_period = (1 << (i - 1));
total_RA_occasions = total_RA_occasions * cc->max_association_period; int temp_RA_occasions = cc->total_prach_occasions_per_config_period * cc->max_association_period;
if(total_RA_occasions >= (int) (num_active_ssb / num_ssb_per_RO)) { if(temp_RA_occasions >= (int) (num_active_ssb / num_ssb_per_RO)) {
total_RA_occasions = temp_RA_occasions;
repetition = (uint16_t)((total_RA_occasions * num_ssb_per_RO) / num_active_ssb); repetition = (uint16_t)((total_RA_occasions * num_ssb_per_RO) / num_active_ssb);
break; break;
} }
} }
AssertFatal(total_RA_occasions > 0, "Couldn't find a valid association period for PRACH occasions\n");
unused_RA_occasion = total_RA_occasions - (int)((num_active_ssb * repetition) / num_ssb_per_RO); unused_RA_occasion = total_RA_occasions - (int)((num_active_ssb * repetition) / num_ssb_per_RO);
cc->total_prach_occasions = total_RA_occasions - unused_RA_occasion; cc->total_prach_occasions = total_RA_occasions - unused_RA_occasion;
...@@ -756,7 +763,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ...@@ -756,7 +763,7 @@ void nr_initiate_ra_proc(module_id_t module_idP,
// return current SSB order in the list of tranmitted SSBs // return current SSB order in the list of tranmitted SSBs
int n_ssb = ssb_index_from_prach(module_idP, frame, slot, preamble_index, freq_index, symbol); int n_ssb = ssb_index_from_prach(module_idP, frame, slot, preamble_index, freq_index, symbol);
UE->UE_beam_index = get_fapi_beamforming_index(nr_mac, cc->ssb_index[n_ssb]); UE->UE_beam_index = get_fapi_beamforming_index(nr_mac, cc->ssb_index[n_ssb]);
LOG_I(NR_MAC, "UE %04x: Sync beam index %d\n", UE->rnti, UE->UE_beam_index);
NR_SCHED_UNLOCK(&nr_mac->sched_lock); NR_SCHED_UNLOCK(&nr_mac->sched_lock);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0);
} }
......
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