From a7e3e8a3120190e011b1c96337785ab42cf8c26a Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 24 Oct 2024 09:26:22 +0200 Subject: [PATCH] harmonization of functions to get info from PRACH config tables --- openair1/SIMULATION/NR_PHY/prachsim.c | 41 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 377 ++++++------------ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 51 ++- openair2/LAYER2/NR_MAC_UE/config_ue.c | 6 +- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 63 +-- openair2/LAYER2/NR_MAC_gNB/config.c | 3 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 120 ++---- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 + 8 files changed, 227 insertions(+), 435 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index ce00f6ae9e..eb3537650b 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -136,13 +136,11 @@ int main(int argc, char **argv){ c16_t **txdata; int N_RB_UL = 106, delay = 0, NCS_config = 13, rootSequenceIndex = 1, threequarter_fs = 0, mu = 1, fd_occasion = 0, loglvl = OAILOG_INFO, numRA = 0, prachStartSymbol = 0; uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format=0; - uint8_t config_index = 98, prach_sequence_length = 1, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol; - uint16_t Nid_cell = 0, preamble_tx = 0, preamble_delay, format, format0, format1; + uint8_t config_index = 98, prach_sequence_length = 1, restrictedSetConfig = 0; + uint16_t Nid_cell = 0, preamble_tx = 0, preamble_delay, format0, format1; uint32_t tx_lev = 10000, prach_errors = 0; //,tx_lev_dB; uint64_t SSB_positions = 0x01; uint16_t RA_sfn_index; - uint8_t N_RA_slot; - uint8_t config_period; int prachOccasion = 0; double DS_TDL = .03; @@ -482,25 +480,24 @@ int main(int argc, char **argv){ gNB->gNB_config.prach_config.num_prach_fd_occasions.value = num_prach_fd_occasions; gNB->gNB_config.prach_config.num_prach_fd_occasions_list = (nfapi_nr_num_prach_fd_occasions_t *) malloc(num_prach_fd_occasions*sizeof(nfapi_nr_num_prach_fd_occasions_t)); - gNB->proc.slot_rx = slot; + gNB->proc.slot_rx = slot; + frequency_range_t freq_range = absoluteFrequencyPointA > 2016666 ? FR2 : FR1; + nr_prach_info_t prach_info = get_nr_prach_occasion_info_from_index(config_index, freq_range, frame_parms->frame_type); + int ret = get_nr_prach_sched_from_info(prach_info, + config_index, + frame, + slot, + mu, + freq_range, + &RA_sfn_index, + frame_parms->frame_type); - int ret = get_nr_prach_info_from_index(config_index, - (int)frame, - (int)slot, - absoluteFrequencyPointA, - mu, - frame_parms->frame_type, - &format, - &start_symbol, - &N_t_slot, - &N_dur, - &RA_sfn_index, - &N_RA_slot, - &config_period); - - if (ret == 0) {printf("No prach in %d.%d, mu %d, config_index %d\n",frame,slot,mu,config_index); exit(-1);} - format0 = format&0xff; // first column of format from table - format1 = (format>>8)&0xff; // second column of format from table + if (ret == 0) { + printf("No prach in %d.%d, mu %d, config_index %d\n", frame, slot, mu, config_index); + exit(-1); + } + format0 = prach_info.format & 0xff; // first column of format from table + format1 = (prach_info.format >> 8) & 0xff; // second column of format from table if (format1 != 0xff) { switch(format0) { diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 29c5e2bfa1..fd3fb5e8e4 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1417,11 +1417,9 @@ static const int64_t table_6_3_3_2_4_prachConfig_Index[256][10] = { {0xa3, 0xb3, 1, 0, -1, 733007751850, 2, 1, 2, 6} // (subframe number :1,3,5,7,…,37,39) }; -int get_format0(uint8_t index, - uint8_t unpaired, - frequency_range_t frequency_range){ - - uint16_t format=0; +int get_format0(uint8_t index, uint8_t unpaired, frequency_range_t frequency_range) +{ + int format = 0; if (unpaired) { if (frequency_range==FR1) format = table_6_3_3_2_3_prachConfig_Index[index][0]; @@ -1437,23 +1435,6 @@ int get_format0(uint8_t index, return format; } -const int64_t *get_prach_config_info(frequency_range_t freq_range, uint8_t index, uint8_t unpaired) -{ - const int64_t *prach_config_info_p; - - if (freq_range == FR2) { //FR2 - prach_config_info_p = table_6_3_3_2_4_prachConfig_Index[index]; - } - else { // FR1 - if (unpaired) - prach_config_info_p = table_6_3_3_2_3_prachConfig_Index[index]; - else - prach_config_info_p = table_6_3_3_2_2_prachConfig_Index[index]; - } // FR2 / FR1 - - return prach_config_info_p; -} - void find_aggregation_candidates(uint8_t *aggregation_level, uint8_t *nr_of_candidates, const NR_SearchSpace_t *ss, @@ -1566,97 +1547,81 @@ void set_monitoring_periodicity_offset(NR_SearchSpace_t *ss, } -int get_nr_prach_occasion_info_from_index(uint8_t index, - uint32_t pointa, - uint8_t mu, - uint8_t unpaired, - uint16_t *format, - uint8_t *start_symbol, - uint8_t *N_t_slot, - uint8_t *N_dur, - uint8_t *N_RA_slot, - uint16_t *N_RA_sfn, - uint8_t *max_association_period) +nr_prach_info_t get_nr_prach_occasion_info_from_index(uint8_t index, frequency_range_t freq_range, uint8_t unpaired) { - int x; - uint64_t s_map; uint8_t format2 = 0xff; - if (pointa > 2016666) { //FR2 - x = table_6_3_3_2_4_prachConfig_Index[index][2]; - s_map = table_6_3_3_2_4_prachConfig_Index[index][5]; - *N_RA_sfn += count_bits64(s_map); - *N_RA_slot = table_6_3_3_2_4_prachConfig_Index[index][7]; // Number of RACH slots within a subframe - *max_association_period = 160/(x * 10); - if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){ - *start_symbol = table_6_3_3_2_4_prachConfig_Index[index][6];//multiple prach occasions in diff slot - *N_t_slot = table_6_3_3_2_4_prachConfig_Index[index][8]; - *N_dur = table_6_3_3_2_4_prachConfig_Index[index][9]; - if (table_6_3_3_2_4_prachConfig_Index[index][1] != -1) - format2 = (uint8_t) table_6_3_3_2_4_prachConfig_Index[index][1]; - - *format = ((uint8_t) table_6_3_3_2_4_prachConfig_Index[index][0]) | (format2<<8); - LOG_D(MAC,"Getting Total PRACH info from index %d absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_sfn = %u\n", - index, - pointa, - mu, - unpaired, - *start_symbol, - *N_t_slot, - *N_dur, - *N_RA_sfn); - } - return 1; - } - else { - if (unpaired) { - x = table_6_3_3_2_3_prachConfig_Index[index][2]; - s_map = table_6_3_3_2_3_prachConfig_Index[index][4]; - *N_RA_sfn += count_bits64(s_map); - *N_RA_slot = table_6_3_3_2_3_prachConfig_Index[index][6]; // Number of RACH slots within a subframe - *max_association_period = 160/(x * 10); - if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){ - *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_dur = table_6_3_3_2_3_prachConfig_Index[index][8]; - 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]; - *format = ((uint8_t) table_6_3_3_2_3_prachConfig_Index[index][0]) | (format2<<8); - LOG_D(NR_MAC,"Getting Total PRACH info from index %d (col %lu ) absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_sfn = %u\n", - index, table_6_3_3_2_3_prachConfig_Index[index][6], - pointa, - mu, - unpaired, - *start_symbol, - *N_t_slot, - *N_dur, - *N_RA_sfn); - } - return 1; - } - else { // FDD - x = table_6_3_3_2_2_prachConfig_Index[index][2]; - s_map = table_6_3_3_2_2_prachConfig_Index[index][4]; - *N_RA_sfn += count_bits64(s_map); - *N_RA_slot = table_6_3_3_2_2_prachConfig_Index[index][6]; - if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){ - *start_symbol = table_6_3_3_2_2_prachConfig_Index[index][5]; - *N_t_slot = table_6_3_3_2_2_prachConfig_Index[index][7]; - *N_dur = table_6_3_3_2_2_prachConfig_Index[index][8]; - if (table_6_3_3_2_2_prachConfig_Index[index][1] != -1) - format2 = (uint8_t) table_6_3_3_2_2_prachConfig_Index[index][1]; - *format = ((uint8_t) table_6_3_3_2_2_prachConfig_Index[index][0]) | (format2<<8); - LOG_D(MAC,"Getting Total PRACH info from index %d absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u \n", - index, - pointa, - mu, - unpaired, - *start_symbol, - *N_t_slot, - *N_dur); - } - return 1; - } + nr_prach_info_t info; + if (freq_range == FR2) { + info.x = table_6_3_3_2_4_prachConfig_Index[index][2]; + info.y = table_6_3_3_2_4_prachConfig_Index[index][3]; + info.y2 = table_6_3_3_2_4_prachConfig_Index[index][4]; + info.s_map = table_6_3_3_2_4_prachConfig_Index[index][5]; + info.N_RA_sfn += count_bits64(info.s_map); + info.N_RA_slot = table_6_3_3_2_4_prachConfig_Index[index][7]; + info.max_association_period = 160 / (info.x * 10); + info.start_symbol = table_6_3_3_2_4_prachConfig_Index[index][6]; + info.N_t_slot = table_6_3_3_2_4_prachConfig_Index[index][8]; + info.N_dur = table_6_3_3_2_4_prachConfig_Index[index][9]; + if (table_6_3_3_2_4_prachConfig_Index[index][1] != -1) + format2 = (uint8_t)table_6_3_3_2_4_prachConfig_Index[index][1]; + info.format = ((uint8_t)table_6_3_3_2_4_prachConfig_Index[index][0]) | (format2 << 8); + LOG_D(NR_MAC, + "PRACH info from index %d frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_sfn = %u\n", + index, + unpaired, + info.start_symbol, + info.N_t_slot, + info.N_dur, + info.N_RA_sfn); + return info; } + + if (unpaired) { // FR1 TDD + info.x = table_6_3_3_2_3_prachConfig_Index[index][2]; + info.y = table_6_3_3_2_3_prachConfig_Index[index][3]; + info.s_map = table_6_3_3_2_3_prachConfig_Index[index][4]; + info.N_RA_sfn += count_bits64(info.s_map); + info.N_RA_slot = table_6_3_3_2_3_prachConfig_Index[index][6]; + info.max_association_period = 160 / (info.x * 10); + info.start_symbol = table_6_3_3_2_3_prachConfig_Index[index][5]; + info.N_t_slot = table_6_3_3_2_3_prachConfig_Index[index][7]; + info.N_dur = table_6_3_3_2_3_prachConfig_Index[index][8]; + 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]; + info.format = ((uint8_t)table_6_3_3_2_3_prachConfig_Index[index][0]) | (format2 << 8); + LOG_D(NR_MAC, + "PRACH info from index %d (col %lu) frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_sfn = %u\n", + index, + table_6_3_3_2_3_prachConfig_Index[index][6], + unpaired, + info.start_symbol, + info.N_t_slot, + info.N_dur, + info.N_RA_sfn); + return info; + } + + // FR1 FDD + info.x = table_6_3_3_2_2_prachConfig_Index[index][2]; + info.y = table_6_3_3_2_2_prachConfig_Index[index][3]; + info.s_map = table_6_3_3_2_2_prachConfig_Index[index][4]; + info.N_RA_sfn += count_bits64(info.s_map); + info.N_RA_slot = table_6_3_3_2_2_prachConfig_Index[index][6]; + info.max_association_period = 160 / (info.x * 10); + info.start_symbol = table_6_3_3_2_2_prachConfig_Index[index][5]; + info.N_t_slot = table_6_3_3_2_2_prachConfig_Index[index][7]; + info.N_dur = table_6_3_3_2_2_prachConfig_Index[index][8]; + if (table_6_3_3_2_2_prachConfig_Index[index][1] != -1) + format2 = (uint8_t)table_6_3_3_2_2_prachConfig_Index[index][1]; + info.format = ((uint8_t)table_6_3_3_2_2_prachConfig_Index[index][0]) | (format2 << 8); + LOG_D(NR_MAC, + "PRACH info from index %d frame_type %u start_symbol %u N_t_slot %u N_dur %u \n", + index, + unpaired, + info.start_symbol, + info.N_t_slot, + info.N_dur); + return info; } uint16_t get_nr_prach_format_from_index(uint8_t index, uint32_t pointa, uint8_t unpaired) @@ -1681,177 +1646,83 @@ uint16_t get_nr_prach_format_from_index(uint8_t index, uint32_t pointa, uint8_t return format; } -int get_nr_prach_info_from_index(uint8_t index, - int frame, - int slot, - uint32_t pointa, - uint8_t mu, - uint8_t unpaired, - uint16_t *format, - uint8_t *start_symbol, - uint8_t *N_t_slot, - uint8_t *N_dur, - uint16_t *RA_sfn_index, - uint8_t *N_RA_slot, - uint8_t *config_period) +bool get_nr_prach_sched_from_info(nr_prach_info_t info, + int config_index, + int frame, + int slot, + int mu, + frequency_range_t freq_range, + uint16_t *RA_sfn_index, + uint8_t unpaired) { - int x,y; - int64_t s_map; - uint8_t format2 = 0xff; - - if (pointa > 2016666) { //FR2 - int y2; - uint8_t slot_60khz; - x = table_6_3_3_2_4_prachConfig_Index[index][2]; - y = table_6_3_3_2_4_prachConfig_Index[index][3]; - y2 = table_6_3_3_2_4_prachConfig_Index[index][4]; + if (freq_range == FR2) { // checking n_sfn mod x = y - if ((frame % x) == y || (frame % x) == y2) { - slot_60khz = slot >> (mu - 2); // in table slots are numbered wrt 60kHz - s_map = table_6_3_3_2_4_prachConfig_Index[index][5]; - if ((s_map >> slot_60khz) & 0x01) { + if ((frame % info.x) == info.y || (frame % info.x) == info.y2) { + int slot_60khz = slot >> (mu - 2); // in table slots are numbered wrt 60kHz + if ((info.s_map >> slot_60khz) & 0x01) { for(int i = 0; i <= slot_60khz ;i++) { - if ((s_map >> i) & 0x01) { + if ((info.s_map >> i) & 0x01) { (*RA_sfn_index)++; } } } - 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 + if (((info.s_map >> slot_60khz) & 0x01)) { if (mu == 3) { - if ((*N_RA_slot == 1) && (slot % 2 == 0) ) - return 0; // no prach in even slots @ 120kHz for 1 prach per 60khz slot + if ((info.N_RA_slot == 1) && (slot % 2 == 0)) + return false; // 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){ - *config_period = x; - *start_symbol = table_6_3_3_2_4_prachConfig_Index[index][6]; - *N_t_slot = table_6_3_3_2_4_prachConfig_Index[index][8]; - *N_dur = table_6_3_3_2_4_prachConfig_Index[index][9]; - if (table_6_3_3_2_4_prachConfig_Index[index][1] != -1) - format2 = (uint8_t) table_6_3_3_2_4_prachConfig_Index[index][1]; - *format = ((uint8_t) table_6_3_3_2_4_prachConfig_Index[index][0]) | (format2<<8); - LOG_D(MAC,"Frame %d slot %d: Getting PRACH info from index %d 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, - slot, - index, - pointa, - mu, - unpaired, - *start_symbol, - *N_t_slot, - *N_dur, - *N_RA_slot, - *RA_sfn_index); - } - return 1; - } - else - return 0; // no prach in current slot + return true; + } else + return false; // no prach in current slot } else - return 0; // no prach in current frame - } - else { - uint8_t subframe; - if (unpaired) { - x = table_6_3_3_2_3_prachConfig_Index[index][2]; - y = table_6_3_3_2_3_prachConfig_Index[index][3]; - if ((frame % x) == y) { - subframe = slot >> mu; - s_map = table_6_3_3_2_3_prachConfig_Index[index][4]; - if ((s_map >> subframe) & 0x01) { + return false; // no prach in current frame + } else { + if (unpaired) { // TDD + if ((frame % info.x) == info.y) { + int subframe = slot >> mu; + if ((info.s_map >> subframe) & 0x01) { for(int i = 0; i <= subframe ;i++) { - if ((s_map >> i) & 0x01) { + if ((info.s_map >> i) & 0x01) { (*RA_sfn_index)++; } } } - 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 - if (index >= 67) { - if ((mu == 1) && (*N_RA_slot <= 1) && (slot % 2 == 0)) - return 0; // no prach in even slots @ 30kHz for 1 prach per subframe + if ((info.s_map >> subframe) & 0x01) { + if (config_index >= 67) { + if ((mu == 1) && (info.N_RA_slot <= 1) && (slot % 2 == 0)) + return false; // no prach in even slots @ 30kHz for 1 prach per subframe } else { if ((slot % 2) && (mu > 0)) - return 0; // slot does not contain start symbol of this prach time resource + return false; // slot does not contain start symbol of this prach time resource } - if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL) { - *config_period = x; - *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_dur = table_6_3_3_2_3_prachConfig_Index[index][8]; - 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]; - *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, - slot, - index, - table_6_3_3_2_3_prachConfig_Index[index][6], - pointa, - mu, - unpaired, - *start_symbol, - *N_t_slot, - *N_dur, - *N_RA_slot, - *RA_sfn_index); - } - return 1; - } - else - return 0; // no prach in current slot - } - else - return 0; // no prach in current frame - } - else { // FDD - x = table_6_3_3_2_2_prachConfig_Index[index][2]; - y = table_6_3_3_2_2_prachConfig_Index[index][3]; - if ((frame % x) == y) { - subframe = slot >> mu; - s_map = table_6_3_3_2_2_prachConfig_Index[index][4]; - 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 - if (index >= 87) { - if ((mu == 1) && (*N_RA_slot <= 1) && (slot % 2 == 0)) { - return 0; // no prach in even slots @ 30kHz for 1 prach per subframe + return true; + } else + return false; // no prach in current slot + } else + return false; // no prach in current frame + } else { // FDD + if ((frame % info.x) == info.y) { + int subframe = slot >> mu; + if ((info.s_map >> subframe) & 0x01) { + if (config_index >= 87) { + if ((mu == 1) && (info.N_RA_slot <= 1) && (slot % 2 == 0)) { + return false; // no prach in even slots @ 30kHz for 1 prach per subframe } } else { if ((slot % 2) && (mu > 0)) return 0; // slot does not contain start symbol of this prach time resource } for(int i = 0; i <= subframe ; i++) { - if ((s_map >> i) & 0x01) { + if ((info.s_map >> i) & 0x01) { (*RA_sfn_index)++; } } - if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){ - *start_symbol = table_6_3_3_2_2_prachConfig_Index[index][5]; - *config_period = x; - *N_t_slot = table_6_3_3_2_2_prachConfig_Index[index][7]; - *N_dur = table_6_3_3_2_2_prachConfig_Index[index][8]; - if (table_6_3_3_2_2_prachConfig_Index[index][1] != -1) - format2 = (uint8_t) table_6_3_3_2_2_prachConfig_Index[index][1]; - *format = ((uint8_t) table_6_3_3_2_2_prachConfig_Index[index][0]) | (format2<<8); - LOG_D(MAC,"Frame %d slot %d: Getting PRACH info from index %d absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u \n", - frame, - slot, - index, - pointa, - mu, - unpaired, - *start_symbol, - *N_t_slot, - *N_dur); - } - return 1; - } - else - return 0; // no prach in current slot - } - else - return 0; // no prach in current frame + return true; + } else + return false; // no prach in current slot + } else + return false; // no prach in current frame } } } diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index e5f7fb4fcf..b8d1fae38c 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -52,6 +52,20 @@ typedef enum { pusch_len2 = 2 } pusch_maxLength_t; +typedef struct { + uint32_t format; + uint32_t start_symbol; + uint32_t N_t_slot; + uint32_t N_dur; + uint32_t N_RA_slot; + uint32_t N_RA_sfn; + uint32_t max_association_period; + int x; + int y; + int y2; + uint64_t s_map; +} nr_prach_info_t; + uint32_t get_Y(const NR_SearchSpace_t *ss, int slot, rnti_t rnti); uint8_t get_BG(uint32_t A, uint16_t R); @@ -144,31 +158,16 @@ void find_aggregation_candidates(uint8_t *aggregation_level, uint16_t get_nr_prach_format_from_index(uint8_t index, uint32_t pointa, uint8_t unpaired); -int get_nr_prach_info_from_index(uint8_t index, - int frame, - int slot, - uint32_t pointa, - uint8_t mu, - uint8_t unpaired, - uint16_t *format, - uint8_t *start_symbol, - uint8_t *N_t_slot, - uint8_t *N_dur, - uint16_t *RA_sfn_index, - uint8_t *N_RA_slot, - uint8_t *config_period); +bool get_nr_prach_sched_from_info(nr_prach_info_t info, + int config_index, + int frame, + int slot, + int mu, + frequency_range_t freq_range, + uint16_t *RA_sfn_index, + uint8_t unpaired); -int get_nr_prach_occasion_info_from_index(uint8_t index, - uint32_t pointa, - uint8_t mu, - uint8_t unpaired, - uint16_t *format, - uint8_t *start_symbol, - uint8_t *N_t_slot, - uint8_t *N_dur, - uint8_t *N_RA_slot, - uint16_t *N_RA_sfn, - uint8_t *max_association_period); +nr_prach_info_t get_nr_prach_occasion_info_from_index(uint8_t index, frequency_range_t freq_range, uint8_t unpaired); uint8_t get_pusch_mcs_table(long *mcs_Table, int is_tp, @@ -186,9 +185,7 @@ int ul_ant_bits(NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig, long transformPrec uint8_t get_pdsch_mcs_table(long *mcs_Table, int dci_format, int rnti_type, int ss_type); -int get_format0(uint8_t index, uint8_t unpaired,frequency_range_t); - -const int64_t *get_prach_config_info(frequency_range_t freq_range, uint8_t index, uint8_t unpaired); +int get_format0(uint8_t index, uint8_t unpaired, frequency_range_t frequency_range); uint16_t get_NCS(uint8_t index, uint16_t format, uint8_t restricted_set_config); int compute_pucch_crc_size(int O_uci); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 552f0676f6..cd266d8a1d 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -187,8 +187,7 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, NR_ServingCellConfigCommo else { // If absent, the UE applies the SCS as derived from the prach-ConfigurationIndex (for 839) int config_index = rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; - const int64_t *prach_config_info_p = get_prach_config_info(mac->frequency_range, config_index, frame_type); - int format = prach_config_info_p[0]; + int format = get_format0(config_index, frame_type, mac->frequency_range); cfg->prach_config.prach_sub_c_spacing = get_delta_f_RA_long(format); } @@ -411,8 +410,7 @@ static void config_common_ue(NR_UE_MAC_INST_t *mac, NR_ServingCellConfigCommon_t else { // If absent, the UE applies the SCS as derived from the prach-ConfigurationIndex (for 839) int config_index = rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; - const int64_t *prach_config_info_p = get_prach_config_info(mac->frequency_range, config_index, frame_type); - int format = prach_config_info_p[0]; + int format = get_format0(config_index, frame_type, mac->frequency_range); cfg->prach_config.prach_sub_c_spacing = format == 3 ? 5 : 4; } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 1bfdc034ee..ef6c902416 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1564,17 +1564,10 @@ int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac, // Build the list of all the valid RACH occasions in the maximum association pattern period according to the PRACH config static void build_ro_list(NR_UE_MAC_INST_t *mac) { - int x,y; // PRACH Configuration Index table variables used to compute the valid frame numbers int y2; // PRACH Configuration Index table additional variable used to compute the valid frame numbers uint8_t slot_shift_for_map; uint8_t map_shift; bool even_slot_invalid; - int64_t s_map; - uint8_t prach_conf_start_symbol; // Starting symbol of the PRACH occasions in the PRACH slot - uint8_t N_t_slot; // Number of PRACH occasions in a 14-symbols PRACH slot - uint8_t N_dur; // Duration of a PRACH occasion (nb of symbols) - uint16_t format = 0xffff; - uint8_t format2 = 0xff; int nb_fdm; uint8_t config_index; @@ -1604,61 +1597,35 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) int unpaired = mac->phy_config.config_req.cell_config.frame_duplex_type; - const int64_t *prach_config_info_p = get_prach_config_info(mac->frequency_range, config_index, unpaired); const int ul_mu = mac->current_UL_BWP->scs; const int mu = nr_get_prach_or_ul_mu(mac->current_UL_BWP->msgA_ConfigCommon_r16, setup, ul_mu); + nr_prach_info_t prach_config = get_nr_prach_occasion_info_from_index(config_index, mac->frequency_range, unpaired); // Identify the proper PRACH Configuration Index table according to the operating frequency LOG_D(NR_MAC,"mu = %u, PRACH config index = %u, unpaired = %u\n", mu, config_index, unpaired); if (mac->frequency_range == FR2) { //FR2 - - x = prach_config_info_p[2]; - y = prach_config_info_p[3]; - y2 = prach_config_info_p[4]; - - s_map = prach_config_info_p[5]; - - prach_conf_start_symbol = prach_config_info_p[6]; - N_t_slot = prach_config_info_p[8]; - N_dur = prach_config_info_p[9]; - if (prach_config_info_p[1] != -1) - format2 = (uint8_t) prach_config_info_p[1]; - format = ((uint8_t) prach_config_info_p[0]) | (format2<<8); - + y2 = prach_config.y2; slot_shift_for_map = mu-2; - if ( (mu == 3) && (prach_config_info_p[7] == 1) ) + if ((mu == 3) && (prach_config.N_RA_slot == 1)) even_slot_invalid = true; else even_slot_invalid = false; } else { // FR1 - x = prach_config_info_p[2]; - y = prach_config_info_p[3]; - y2 = y; - - s_map = prach_config_info_p[4]; - - prach_conf_start_symbol = prach_config_info_p[5]; - N_t_slot = prach_config_info_p[7]; - N_dur = prach_config_info_p[8]; - LOG_D(NR_MAC,"N_t_slot %d, N_dur %d\n",N_t_slot,N_dur); - if (prach_config_info_p[1] != -1) - format2 = (uint8_t) prach_config_info_p[1]; - format = ((uint8_t) prach_config_info_p[0]) | (format2<<8); - + y2 = prach_config.y; slot_shift_for_map = mu; - if ( (mu == 1) && (prach_config_info_p[6] == 1) && ((format & 0xff) > 3) ) + if ((mu == 1) && (prach_config.N_RA_slot == 1) && ((prach_config.format & 0xff) > 3)) // no prach in even slots @ 30kHz for 1 prach per subframe even_slot_invalid = true; else even_slot_invalid = false; - } // FR2 / FR1 + } // FR1 const int bwp_id = mac->current_UL_BWP->bwp_id; prach_association_pattern_t *prach_assoc_pattern = &mac->prach_assoc_pattern[bwp_id]; - prach_assoc_pattern->nb_of_prach_conf_period_in_max_period = MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD / x; - nb_of_frames_per_prach_conf_period = x; + prach_assoc_pattern->nb_of_prach_conf_period_in_max_period = MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD / prach_config.x; + nb_of_frames_per_prach_conf_period = prach_config.x; int slots_per_frame = mac->frame_structure.numb_slots_frame; LOG_D(NR_MAC,"nb_of_prach_conf_period_in_max_period %d\n", prach_assoc_pattern->nb_of_prach_conf_period_in_max_period); @@ -1682,14 +1649,14 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) LOG_D(NR_MAC,"PRACH Conf Period Frame Idx %d - Frame %d\n", frame_idx, frame_rach); // Is it a valid frame for this PRACH configuration index? (n_sfn mod x = y) - if ((frame_rach % x) == y || (frame_rach % x) == y2) { + if ((frame_rach % prach_config.x) == prach_config.y || (frame_rach % prach_config.x) == y2) { // For every slot in a frame // ------------------------- for (int slot = 0; slot < slots_per_frame; slot++) { // Is it a valid slot? map_shift = slot >> slot_shift_for_map; // in PRACH configuration index table slots are numbered wrt 60kHz - if ((s_map>>map_shift) & 0x01) { + if ((prach_config.s_map >> map_shift) & 0x01) { // Valid slot // Additionally, for 30kHz/120kHz, we must check for the n_RA_Slot param also @@ -1700,12 +1667,12 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) // Compute all the PRACH occasions in the slot prach_occasion_slot_t *slot_map = &prach_conf_period_list->prach_occasion_slot_map[frame_idx][slot]; - slot_map->nb_of_prach_occasion_in_time = N_t_slot; + slot_map->nb_of_prach_occasion_in_time = prach_config.N_t_slot; slot_map->nb_of_prach_occasion_in_freq = nb_fdm; - slot_map->prach_occasion = malloc(N_t_slot * nb_fdm * sizeof(*slot_map->prach_occasion)); + slot_map->prach_occasion = malloc(prach_config.N_t_slot * nb_fdm * sizeof(*slot_map->prach_occasion)); AssertFatal(slot_map->prach_occasion, "no memory available\n"); - for (int n_prach_occ_in_time = 0; n_prach_occ_in_time < N_t_slot; n_prach_occ_in_time++) { - uint8_t start_symbol = prach_conf_start_symbol + n_prach_occ_in_time * N_dur; + for (int n_prach_occ_in_time = 0; n_prach_occ_in_time < prach_config.N_t_slot; n_prach_occ_in_time++) { + uint8_t start_symbol = prach_config.start_symbol + n_prach_occ_in_time * prach_config.N_dur; LOG_D(NR_MAC,"PRACH Occ in time %d\n", n_prach_occ_in_time); for (int n_prach_occ_in_freq = 0; n_prach_occ_in_freq < nb_fdm; n_prach_occ_in_freq++) { @@ -1714,7 +1681,7 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) .fdm = n_prach_occ_in_freq, .frame = frame_idx, .slot = slot, - .format = format}; + .format = prach_config.format}; prach_assoc_pattern->prach_conf_period_list[period_idx].nb_of_prach_occasion++; LOG_D(NR_MAC, diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index d7b9b5e129..0abe35b80d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -521,8 +521,7 @@ static void config_common(gNB_MAC_INST *nrmac, // If absent, use SCS as derived from the prach-ConfigurationIndex (for 839) int config_index = rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; int frame_type = get_frame_type(band, frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing); - const int64_t *prach_config_info_p = get_prach_config_info(frequency_range, config_index, frame_type); - int format = prach_config_info_p[0]; + int format = get_nr_prach_format_from_index(config_index, UL_pointA, frame_type) & 0xff; cfg->prach_config.prach_sub_c_spacing.value = get_delta_f_RA_long(format); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index cc0317cf51..9044927f34 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -83,9 +83,8 @@ static int16_t ssb_index_from_prach(module_id_t module_idP, float num_ssb_per_RO = ssb_per_rach_occasion[cfg->prach_config.ssb_per_rach.value]; uint16_t start_symbol_index = 0; - uint8_t N_dur=0,N_t_slot=0,start_symbol = 0, temp_start_symbol = 0, N_RA_slot=0; - uint16_t format,RA_sfn_index = -1; - uint8_t config_period = 1; + uint8_t temp_start_symbol = 0; + uint16_t RA_sfn_index = -1; uint16_t prach_occasion_id = -1; uint8_t num_active_ssb = cc->num_active_ssb; NR_MsgA_ConfigCommon_r16_t *msgacc = NULL; @@ -93,42 +92,32 @@ static int16_t ssb_index_from_prach(module_id_t module_idP, msgacc = scc->uplinkConfigCommon->initialUplinkBWP->ext1->msgA_ConfigCommon_r16->choice.setup; const int ul_mu = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; const int mu = nr_get_prach_or_ul_mu(msgacc, rach_ConfigCommon, ul_mu); + frequency_range_t freq_range = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA > 2016666 ? FR2 : FR1; + get_nr_prach_sched_from_info(cc->prach_info, config_index, frameP, slotP, mu, freq_range, &RA_sfn_index, cc->frame_type); - get_nr_prach_info_from_index(config_index, - (int)frameP, - (int)slotP, - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA, - mu, - cc->frame_type, - &format, - &start_symbol, - &N_t_slot, - &N_dur, - &RA_sfn_index, - &N_RA_slot, - &config_period); uint8_t index = 0, slot_index = 0; - for (slot_index = 0; slot_index < N_RA_slot; slot_index++) { - if (N_RA_slot <= 1) { //1 PRACH slot in a subframe + for (slot_index = 0; slot_index < cc->prach_info.N_RA_slot; slot_index++) { + if (cc->prach_info.N_RA_slot <= 1) { // 1 PRACH slot in a subframe 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++) { - temp_start_symbol = (start_symbol + i * N_dur + 14 * slot_index) % 14; + for (int i = 0; i < cc->prach_info.N_t_slot; i++) { + temp_start_symbol = (cc->prach_info.start_symbol + i * cc->prach_info.N_dur + 14 * slot_index) % 14; if(symbol == temp_start_symbol) { start_symbol_index = i; break; } } } - if (N_RA_slot <= 1) { //1 PRACH slot in a subframe + if (cc->prach_info.N_RA_slot <= 1) { // 1 PRACH slot in a subframe if((mu == 1) || (mu == 3)) - slot_index = 0; //For scs = 30khz and 120khz + slot_index = 0; // For scs = 30khz and 120khz } - + int config_period = cc->prach_info.x; // prach_occasion_id = subframe_index * N_t_slot * N_RA_slot * fdm + N_RA_slot_index * N_t_slot * fdm + freq_index + fdm * start_symbol_index; - 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; + prach_occasion_id = + (((frameP % (cc->max_association_period * config_period)) / config_period) * cc->total_prach_occasions_per_config_period) + + (RA_sfn_index + slot_index) * cc->prach_info.N_t_slot * fdm + start_symbol_index * fdm + freq_index; //one SSB have more than one continuous RO if(num_ssb_per_RO <= 1) @@ -159,14 +148,12 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac) nfapi_nr_config_request_scf_t *cfg = &nrmac->config[0]; NR_RACH_ConfigCommon_t *rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; uint8_t config_index = rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; - uint8_t N_dur=0,N_t_slot=0,start_symbol=0,N_RA_slot = 0; - uint16_t format,N_RA_sfn = 0,unused_RA_occasion,repetition = 0; + uint16_t unused_RA_occasion, repetition = 0; uint8_t num_active_ssb = 0; - uint8_t max_association_period = 1; struct NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB *ssb_perRACH_OccasionAndCB_PreamblesPerSSB = rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB; - switch (ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present){ + switch (ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present) { case NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth: cc->cb_preambles_per_ssb = 4 * (ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneEighth + 1); break; @@ -194,31 +181,16 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac) default: AssertFatal(1 == 0, "Unsupported ssb_perRACH_config %d\n", ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present); break; - } - - NR_MsgA_ConfigCommon_r16_t *msgacc = NULL; - if (scc->uplinkConfigCommon->initialUplinkBWP->ext1 && scc->uplinkConfigCommon->initialUplinkBWP->ext1->msgA_ConfigCommon_r16) - msgacc = scc->uplinkConfigCommon->initialUplinkBWP->ext1->msgA_ConfigCommon_r16->choice.setup; - const int ul_mu = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; - const int mu = nr_get_prach_or_ul_mu(msgacc, rach_ConfigCommon, ul_mu); + } // prach is scheduled according to configuration index and tables 6.3.3.2.2 to 6.3.3.2.4 - get_nr_prach_occasion_info_from_index(config_index, - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA, - mu, - cc->frame_type, - &format, - &start_symbol, - &N_t_slot, - &N_dur, - &N_RA_slot, - &N_RA_sfn, - &max_association_period); + frequency_range_t freq_range = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA > 2016666 ? FR2 : FR1; + nr_prach_info_t prach_info = get_nr_prach_occasion_info_from_index(config_index, freq_range, cc->frame_type); 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; 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 = prach_info.N_RA_sfn * prach_info.N_t_slot * prach_info.N_RA_slot * fdm; 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 @@ -228,7 +200,7 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac) } 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)) <= prach_info.max_association_period; i++) { cc->max_association_period = (1 << (i - 1)); total_RA_occasions = total_RA_occasions * cc->max_association_period; if(total_RA_occasions >= (int) (num_active_ssb / num_ssb_per_RO)) { @@ -240,14 +212,16 @@ void find_SSB_and_RO_available(gNB_MAC_INST *nrmac) 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->num_active_ssb = num_active_ssb; + cc->prach_info = prach_info; LOG_D(NR_MAC, - "Total available RO %d, num of active SSB %d: unused RO = %d association_period %u N_RA_sfn %u total_prach_occasions_per_config_period %u\n", + "Total available RO %d, num of active SSB %d: unused RO = %d association_period %u N_RA_sfn %u " + "total_prach_occasions_per_config_period %u\n", cc->total_prach_occasions, cc->num_active_ssb, unused_RA_occasion, cc->max_association_period, - N_RA_sfn, + prach_info.N_RA_sfn, cc->total_prach_occasions_per_config_period); } @@ -396,10 +370,6 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, slot_t slotP) if (is_ul_slot(slotP, &RC.nrmac[module_idP]->frame_structure)) { const NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &rach_ConfigCommon->rach_ConfigGeneric; uint8_t config_index = rach_ConfigGeneric->prach_ConfigurationIndex; - uint8_t N_dur, N_t_slot, start_symbol = 0, N_RA_slot; - uint16_t RA_sfn_index = -1; - uint8_t config_period = 1; - uint16_t format; int slot_index = 0; uint16_t prach_occasion_id = -1; @@ -409,29 +379,18 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, slot_t slotP) const int ul_mu = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; const int mu = nr_get_prach_or_ul_mu(msgacc, rach_ConfigCommon, ul_mu); // prach is scheduled according to configuration index and tables 6.3.3.2.2 to 6.3.3.2.4 - if (get_nr_prach_info_from_index(config_index, - (int)frameP, - (int)slotP, - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA, - mu, - cc->frame_type, - &format, - &start_symbol, - &N_t_slot, - &N_dur, - &RA_sfn_index, - &N_RA_slot, - &config_period)) { + uint16_t RA_sfn_index = -1; + frequency_range_t freq_range = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA > 2016666 ? FR2 : FR1; + if (get_nr_prach_sched_from_info(cc->prach_info, config_index, frameP, slotP, mu, freq_range, &RA_sfn_index, cc->frame_type)) { + uint16_t format0 = cc->prach_info.format & 0xff; // first column of format from table + uint16_t format1 = (cc->prach_info.format >> 8) & 0xff; // second column of format from table - uint16_t format0 = format & 0xff; // first column of format from table - uint16_t format1 = (format >> 8) & 0xff; // second column of format from table - - if (N_RA_slot > 1) { //more than 1 PRACH slot in a subframe + if (cc->prach_info.N_RA_slot > 1) { // more than 1 PRACH slot in a subframe if (slotP % 2 == 1) slot_index = 1; else slot_index = 0; - } else if (N_RA_slot <= 1) { //1 PRACH slot in a subframe + } else if (cc->prach_info.N_RA_slot <= 1) { // 1 PRACH slot in a subframe slot_index = 0; } @@ -439,9 +398,11 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, slot_t slotP) UL_tti_req->Slot = slotP; UL_tti_req->rach_present = 1; NR_beam_alloc_t beam = {0}; + uint32_t N_t_slot = cc->prach_info.N_t_slot; + uint32_t start_symb = cc->prach_info.start_symbol; 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++) { - + uint32_t config_period = cc->prach_info.x; 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; @@ -482,7 +443,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, slot_t slotP) // filling the prach fapi structure prach_pdu->phys_cell_id = *scc->physCellId; prach_pdu->num_prach_ocas = N_t_slot; - prach_pdu->prach_start_symbol = start_symbol; + prach_pdu->prach_start_symbol = start_symb; prach_pdu->num_ra = fdm_index; prach_pdu->num_cs = get_NCS(rach_ConfigGeneric->zeroCorrelationZoneConfig, format0, @@ -499,7 +460,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, slot_t slotP) slotP, prach_occasion_id, prach_pdu->num_ra, - prach_pdu->prach_start_symbol, + start_symb, slot_index, RA_sfn_index); // SCF PRACH PDU format field does not consider A1/B1 etc. possibilities @@ -579,13 +540,14 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, slot_t slotP) const int16_t n_ra_rb = get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, mu_pusch); // mark PRBs as occupied for current and future slots if prach extends beyond current slot int total_prach_slots; + uint32_t N_dur = cc->prach_info.N_dur; if (format0 < 4) { N_dur = 14; // number of PRACH symbols in PRACH slot total_prach_slots = get_long_prach_dur(format0, mu_pusch); AssertFatal(slotP + total_prach_slots - 1 < slots_frame, "PRACH cannot extend across frames\n"); } else { // TODO: to be revisited for format B4 (also extends beyond current slot for FR1 30kHz SCS and FR2) - AssertFatal((format != 0xb4) || (mu_pusch < 1), "Format B4 not supported for this PUSCH SCS\n"); + AssertFatal((format0 != 0xb4) || (mu_pusch < 1), "Format B4 not supported for this PUSCH SCS\n"); total_prach_slots = 1; } // reserve PRBs occupied by PRACH in all PRACH slot. @@ -597,7 +559,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, slot_t slotP) gNB->vrb_map_UL_size, slots_frame, bwp_start + rach_ConfigGeneric->msg1_FrequencyStart, - start_symbol, + start_symb, N_t_slot * N_dur, cc); } diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 3f992f0409..8b1bb3ec5c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -302,6 +302,7 @@ typedef struct { int cb_preambles_per_ssb; /// Max prach length in slots int prach_len; + nr_prach_info_t prach_info; } NR_COMMON_channels_t; // SP ZP CSI-RS Resource Set Activation/Deactivation MAC CE