Commit e93f056b authored by francescomani's avatar francescomani

beam association for prach

parent 9b54d47f
...@@ -1770,8 +1770,8 @@ int get_nr_prach_info_from_index(uint8_t index, ...@@ -1770,8 +1770,8 @@ int get_nr_prach_info_from_index(uint8_t index,
uint8_t *N_dur, uint8_t *N_dur,
uint16_t *RA_sfn_index, uint16_t *RA_sfn_index,
uint8_t *N_RA_slot, uint8_t *N_RA_slot,
uint8_t *config_period) { uint8_t *config_period)
{
int x,y; int x,y;
int64_t s_map; int64_t s_map;
uint8_t format2 = 0xff; uint8_t format2 = 0xff;
...@@ -1783,20 +1783,20 @@ int get_nr_prach_info_from_index(uint8_t index, ...@@ -1783,20 +1783,20 @@ int get_nr_prach_info_from_index(uint8_t index,
y = table_6_3_3_2_4_prachConfig_Index[index][3]; y = table_6_3_3_2_4_prachConfig_Index[index][3];
y2 = table_6_3_3_2_4_prachConfig_Index[index][4]; y2 = table_6_3_3_2_4_prachConfig_Index[index][4];
// checking n_sfn mod x = y // checking n_sfn mod x = y
if ( (frame%x)==y || (frame%x)==y2 ) { if ((frame % x) == y || (frame % x) == y2) {
slot_60khz = slot >> (mu-2); // in table slots are numbered wrt 60kHz slot_60khz = slot >> (mu - 2); // in table slots are numbered wrt 60kHz
s_map = table_6_3_3_2_4_prachConfig_Index[index][5]; s_map = table_6_3_3_2_4_prachConfig_Index[index][5];
if ((s_map >> slot_60khz) & 0x01 ) { if ((s_map >> slot_60khz) & 0x01) {
for(int i = 0; i <= slot_60khz ;i++) { for(int i = 0; i <= slot_60khz ;i++) {
if ( (s_map >> i) & 0x01) { if ((s_map >> i) & 0x01) {
(*RA_sfn_index)++; (*RA_sfn_index)++;
} }
} }
} }
if ( ((s_map>>slot_60khz)&0x01) ) { if (((s_map >> slot_60khz) & 0x01)) {
*N_RA_slot = table_6_3_3_2_4_prachConfig_Index[index][7]; // Number of RACH slots within a subframe *N_RA_slot = table_6_3_3_2_4_prachConfig_Index[index][7]; // Number of RACH slots within a subframe
if (mu == 3) { if (mu == 3) {
if ( (*N_RA_slot == 1) && (slot%2 == 0) ) if ((*N_RA_slot == 1) && (slot % 2 == 0) )
return 0; // no prach in even slots @ 120kHz for 1 prach per 60khz slot return 0; // no prach in even slots @ 120kHz for 1 prach per 60khz slot
} }
if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){ if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){
...@@ -1833,23 +1833,23 @@ int get_nr_prach_info_from_index(uint8_t index, ...@@ -1833,23 +1833,23 @@ int get_nr_prach_info_from_index(uint8_t index,
if (unpaired) { if (unpaired) {
x = table_6_3_3_2_3_prachConfig_Index[index][2]; x = table_6_3_3_2_3_prachConfig_Index[index][2];
y = table_6_3_3_2_3_prachConfig_Index[index][3]; y = table_6_3_3_2_3_prachConfig_Index[index][3];
if ( (frame%x)==y ) { if ((frame % x) == y) {
subframe = slot >> mu; subframe = slot >> mu;
s_map = table_6_3_3_2_3_prachConfig_Index[index][4]; s_map = table_6_3_3_2_3_prachConfig_Index[index][4];
if ((s_map >> subframe) & 0x01 ) { if ((s_map >> subframe) & 0x01) {
for(int i = 0; i <= subframe ;i++) { for(int i = 0; i <= subframe ;i++) {
if ( (s_map >> i) & 0x01) { if ((s_map >> i) & 0x01) {
(*RA_sfn_index)++; (*RA_sfn_index)++;
} }
} }
} }
if ( (s_map>>subframe)&0x01 ) { if ((s_map >> subframe) & 0x01 ) {
*N_RA_slot = table_6_3_3_2_3_prachConfig_Index[index][6]; // Number of RACH slots within a subframe *N_RA_slot = table_6_3_3_2_3_prachConfig_Index[index][6]; // Number of RACH slots within a subframe
if (mu == 1 && index >= 67) { if (mu == 1 && index >= 67) {
if ( (*N_RA_slot <= 1) && (slot%2 == 0) ) if ((*N_RA_slot <= 1) && (slot % 2 == 0))
return 0; // no prach in even slots @ 30kHz for 1 prach per subframe return 0; // no prach in even slots @ 30kHz for 1 prach per subframe
} }
if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){ if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL) {
*config_period = x; *config_period = x;
*start_symbol = table_6_3_3_2_3_prachConfig_Index[index][5]; *start_symbol = table_6_3_3_2_3_prachConfig_Index[index][5];
*N_t_slot = table_6_3_3_2_3_prachConfig_Index[index][7]; *N_t_slot = table_6_3_3_2_3_prachConfig_Index[index][7];
...@@ -1857,17 +1857,19 @@ int get_nr_prach_info_from_index(uint8_t index, ...@@ -1857,17 +1857,19 @@ int get_nr_prach_info_from_index(uint8_t index,
if (table_6_3_3_2_3_prachConfig_Index[index][1] != -1) if (table_6_3_3_2_3_prachConfig_Index[index][1] != -1)
format2 = (uint8_t) table_6_3_3_2_3_prachConfig_Index[index][1]; format2 = (uint8_t) table_6_3_3_2_3_prachConfig_Index[index][1];
*format = ((uint8_t) table_6_3_3_2_3_prachConfig_Index[index][0]) | (format2<<8); *format = ((uint8_t) table_6_3_3_2_3_prachConfig_Index[index][0]) | (format2<<8);
LOG_D(MAC,"Frame %d slot %d: Getting PRACH info from index %d (col 6 %lu) absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_slot %u RA_sfn_index %u \n", frame, LOG_D(MAC,"Frame %d slot %d: Getting PRACH info from index %d (col 6 %lu) absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_slot %u RA_sfn_index %u \n",
slot, frame,
index, table_6_3_3_2_3_prachConfig_Index[index][6], slot,
pointa, index,
mu, table_6_3_3_2_3_prachConfig_Index[index][6],
unpaired, pointa,
*start_symbol, mu,
*N_t_slot, unpaired,
*N_dur, *start_symbol,
*N_RA_slot, *N_t_slot,
*RA_sfn_index); *N_dur,
*N_RA_slot,
*RA_sfn_index);
} }
return 1; return 1;
} }
...@@ -1880,10 +1882,10 @@ int get_nr_prach_info_from_index(uint8_t index, ...@@ -1880,10 +1882,10 @@ int get_nr_prach_info_from_index(uint8_t index,
else { // FDD else { // FDD
x = table_6_3_3_2_2_prachConfig_Index[index][2]; x = table_6_3_3_2_2_prachConfig_Index[index][2];
y = table_6_3_3_2_2_prachConfig_Index[index][3]; y = table_6_3_3_2_2_prachConfig_Index[index][3];
if ( (frame%x)==y ) { if ((frame % x) == y) {
subframe = slot >> mu; subframe = slot >> mu;
s_map = table_6_3_3_2_2_prachConfig_Index[index][4]; s_map = table_6_3_3_2_2_prachConfig_Index[index][4];
if ( (s_map>>subframe)&0x01 ) { if ((s_map>>subframe) & 0x01) {
*N_RA_slot = table_6_3_3_2_2_prachConfig_Index[index][6]; // Number of RACH slots within a subframe *N_RA_slot = table_6_3_3_2_2_prachConfig_Index[index][6]; // Number of RACH slots within a subframe
if (mu == 1) { if (mu == 1) {
if ((*N_RA_slot <= 1) && (slot % 2 == 0)){ if ((*N_RA_slot <= 1) && (slot % 2 == 0)){
...@@ -1891,7 +1893,7 @@ int get_nr_prach_info_from_index(uint8_t index, ...@@ -1891,7 +1893,7 @@ int get_nr_prach_info_from_index(uint8_t index,
} }
} }
for(int i = 0; i <= subframe ; i++) { for(int i = 0; i <= subframe ; i++) {
if ( (s_map >> i) & 0x01) { if ((s_map >> i) & 0x01) {
(*RA_sfn_index)++; (*RA_sfn_index)++;
} }
} }
......
...@@ -115,13 +115,13 @@ static int16_t ssb_index_from_prach(module_id_t module_idP, ...@@ -115,13 +115,13 @@ static int16_t ssb_index_from_prach(module_id_t module_idP,
&RA_sfn_index, &RA_sfn_index,
&N_RA_slot, &N_RA_slot,
&config_period); &config_period);
uint8_t index = 0,slot_index = 0; uint8_t index = 0, slot_index = 0;
for (slot_index = 0;slot_index < N_RA_slot; slot_index++) { for (slot_index = 0; slot_index < N_RA_slot; slot_index++) {
if (N_RA_slot <= 1) { //1 PRACH slot in a subframe if (N_RA_slot <= 1) { //1 PRACH slot in a subframe
if((mu == 1) || (mu == 3)) if((mu == 1) || (mu == 3))
slot_index = 1; //For scs = 30khz and 120khz slot_index = 1; //For scs = 30khz and 120khz
} }
for (int i=0; i< N_t_slot; i++) { for (int i = 0; i < N_t_slot; i++) {
temp_start_symbol = (start_symbol + i * N_dur + 14 * slot_index) % 14; temp_start_symbol = (start_symbol + i * N_dur + 14 * slot_index) % 14;
if(symbol == temp_start_symbol) { if(symbol == temp_start_symbol) {
start_symbol_index = i; start_symbol_index = i;
...@@ -138,14 +138,14 @@ static int16_t ssb_index_from_prach(module_id_t module_idP, ...@@ -138,14 +138,14 @@ static int16_t ssb_index_from_prach(module_id_t module_idP,
prach_occasion_id = (((frameP % (cc->max_association_period * config_period)) / config_period) * cc->total_prach_occasions_per_config_period) + prach_occasion_id = (((frameP % (cc->max_association_period * config_period)) / config_period) * cc->total_prach_occasions_per_config_period) +
(RA_sfn_index + slot_index) * N_t_slot * fdm + start_symbol_index * fdm + freq_index; (RA_sfn_index + slot_index) * N_t_slot * fdm + start_symbol_index * fdm + freq_index;
//one RO is shared by one or more SSB
if(num_ssb_per_RO <= 1 )
index = (int) (prach_occasion_id / (int)(1/num_ssb_per_RO)) % num_active_ssb;
//one SSB have more than one continuous RO //one SSB have more than one continuous RO
else if ( num_ssb_per_RO > 1) { if(num_ssb_per_RO <= 1)
index = (prach_occasion_id * (int)num_ssb_per_RO)% num_active_ssb ; index = (int) (prach_occasion_id / (int)(1 / num_ssb_per_RO)) % num_active_ssb;
for(int j = 0;j < num_ssb_per_RO;j++) { //one RO is shared by one or more SSB
if(preamble_index < (((j + 1) * total_RApreambles) / num_ssb_per_RO)) else if (num_ssb_per_RO > 1) {
index = (prach_occasion_id * (int)num_ssb_per_RO) % num_active_ssb;
for(int j = 0; j < num_ssb_per_RO; j++) {
if(preamble_index < ((j + 1) * cc->cb_preambles_per_ssb))
index = index + j; index = index + j;
} }
} }
...@@ -227,24 +227,24 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac) ...@@ -227,24 +227,24 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac)
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 = N_RA_sfn * N_t_slot * N_RA_slot * fdm; uint32_t total_RA_occasions = N_RA_sfn * N_t_slot * 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
cc->ssb_index[num_active_ssb] = i; cc->ssb_index[num_active_ssb] = i;
num_active_ssb++; num_active_ssb++;
} }
} }
cc->total_prach_occasions_per_config_period = total_RA_occasions; cc->total_prach_occasions_per_config_period = total_RA_occasions;
for(int i=1; (1 << (i-1)) <= max_association_period; i++) { for(int i = 1; (1 << (i-1)) <= 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; total_RA_occasions = total_RA_occasions * cc->max_association_period;
if(total_RA_occasions >= (int) (num_active_ssb/num_ssb_per_RO)) { if(total_RA_occasions >= (int) (num_active_ssb / num_ssb_per_RO)) {
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;
} }
} }
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;
cc->num_active_ssb = num_active_ssb; cc->num_active_ssb = num_active_ssb;
...@@ -319,13 +319,30 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP ...@@ -319,13 +319,30 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP
UL_tti_req->SFN = frameP; UL_tti_req->SFN = frameP;
UL_tti_req->Slot = slotP; UL_tti_req->Slot = slotP;
UL_tti_req->rach_present = 1; UL_tti_req->rach_present = 1;
int beam_idx = 0;
for (int fdm_index = 0; fdm_index < fdm; fdm_index++) { // one structure per frequency domain occasion for (int fdm_index = 0; fdm_index < fdm; fdm_index++) { // one structure per frequency domain occasion
for (int td_index = 0; td_index < N_t_slot; td_index++) { for (int td_index = 0; td_index < N_t_slot; td_index++) {
prach_occasion_id = (((frameP % (cc->max_association_period * config_period))/config_period) * cc->total_prach_occasions_per_config_period) + prach_occasion_id = (((frameP % (cc->max_association_period * config_period))/config_period) * cc->total_prach_occasions_per_config_period) +
(RA_sfn_index + slot_index) * N_t_slot * fdm + td_index * fdm + fdm_index; (RA_sfn_index + slot_index) * N_t_slot * fdm + td_index * fdm + fdm_index;
if((prach_occasion_id < cc->total_prach_occasions) && (td_index == 0)){ if (prach_occasion_id >= cc->total_prach_occasions) // to be confirmed: unused occasion?
continue;
float num_ssb_per_RO = ssb_per_rach_occasion[cfg->prach_config.ssb_per_rach.value];
if(num_ssb_per_RO <= 1) {
int ssb_index = (int) (prach_occasion_id / (int)(1 / num_ssb_per_RO)) % cc->num_active_ssb;
beam_idx = beam_allocation_procedure(&gNB->beam_info, frameP, slotP, ssb_index, nr_slots_per_frame[mu]);
AssertFatal(beam_idx >= 0, "Cannot allocate PRACH corresponding to SSB %d in any available beam\n", ssb_index);
}
else {
int first_ssb_index = (prach_occasion_id * (int)num_ssb_per_RO) % cc->num_active_ssb;
for(int j = first_ssb_index; j < num_ssb_per_RO; j++) {
beam_idx = beam_allocation_procedure(&gNB->beam_info, frameP, slotP, j, nr_slots_per_frame[mu]);
AssertFatal(beam_idx >= 0, "Cannot allocate PRACH corresponding to SSB %d in any available beam\n", j);
}
}
if(td_index == 0) {
AssertFatal(UL_tti_req->n_pdus < sizeof(UL_tti_req->pdus_list) / sizeof(UL_tti_req->pdus_list[0]), AssertFatal(UL_tti_req->n_pdus < sizeof(UL_tti_req->pdus_list) / sizeof(UL_tti_req->pdus_list[0]),
"Invalid UL_tti_req->n_pdus %d\n", UL_tti_req->n_pdus); "Invalid UL_tti_req->n_pdus %d\n", UL_tti_req->n_pdus);
...@@ -414,10 +431,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP ...@@ -414,10 +431,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP
} }
// block resources in vrb_map_UL // block resources in vrb_map_UL
// TODO properly allocate beam index for PRACH const int mu_pusch = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing;
int beam_idx = 0;
const uint8_t mu_pusch =
scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing;
const int16_t n_ra_rb = get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, mu_pusch); const int16_t n_ra_rb = get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, mu_pusch);
index = ul_buffer_index(frameP, slotP, mu, gNB->vrb_map_UL_size); index = ul_buffer_index(frameP, slotP, mu, gNB->vrb_map_UL_size);
uint16_t *vrb_map_UL = &cc->vrb_map_UL[beam_idx][index * MAX_BWP_SIZE]; uint16_t *vrb_map_UL = &cc->vrb_map_UL[beam_idx][index * MAX_BWP_SIZE];
......
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