Commit 7ecba96f authored by Mario Hudon's avatar Mario Hudon

Fixed compilation errors and warnings

parent 2d1b7f78
......@@ -36,6 +36,43 @@
#include "NR_CellGroupConfig.h"
#include "nr_mac.h"
#define MAX_NB_PRACH_ASSOC_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD (16) // Maximum number of association periods in max association pattern period (160ms)
#define MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PERIOD (16) // Maximum association period is 16
#define MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD (16) // Max association pattern period is 160ms and minimum PRACH configuration period is 10ms
#define MAX_NB_FRAMES_IN_PRACH_CONF_PERIOD (16) // Max PRACH configuration period is 160ms and frame is 10ms
#define MAX_NB_SLOTS_IN_FRAME (160) // Max number of slots in a frame (@ SCS 240kHz = 160)
#define MAX_NB_PRACH_OCCASIONS_IN_TIME (7) // Max number of PRACH occasions in time per slot
#define MAX_NB_PRACH_OCCASIONS_IN_FREQ (8) // Max number of PRACH occasions in frequency per slot
#define MAX_NB_FRAMES_IN_ASSOCIATION_PATTERN_PERIOD (16) // Maximum number of frames in the maximum association pattern period
#define MAX_NB_ASSOCIATION_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD (16) // Max nb of association periods in an association pattern period of 160ms
#define MAX_FDM (8) // Maximum nb of PRACH occasions FDMed in a slot
#define MAX_NB_SSBS (64)
#define MAX_RO_PER_SSB_RATIO (8)
#define MAX_SSB_PER_RO_RATIO (16)
// Maximum number of SSBs that can be mapped in an association pattern
// Here we chose an arbitrary maximum number - maximum number of slots in an association pattern * maximum number of ROs in a slot
#define MAX_NB_SSBS_IN_ASSOCIATION_PATTERN (MAX_NB_PRACH_OCCASIONS_IN_TIME*MAX_NB_PRACH_OCCASIONS_IN_FREQ*MAX_NB_SLOTS_IN_FRAME*MAX_NB_FRAMES_IN_ASSOCIATION_PATTERN_PERIOD)
// PRACH occasion details
typedef struct prach_occasion_info {
uint8_t start_symbol; // 0 - 13 (14 symbols in a slot)
uint8_t fdm; // 1, 2, 4 or 8 (possible values of msg1-FDM)
uint8_t slot; // 0 - 159 (maximum number of slots in a 10ms frame - @ 240kHz)
uint8_t frame; // 0 - 15 (maximum number of frames in a 160ms association pattern)
uint8_t mapped_ssb_idx[MAX_SSB_PER_RO_RATIO]; // List of mapped SSBs
uint8_t nb_mapped_ssbs;
uint16_t format; // RO preamble format
} prach_occasion_info_t;
// PRACH occasions details in a slot
// A PRACH occasion slot is a series of PRACH occasions in time (symbols) and frequency
typedef struct prach_occasion_slot {
prach_occasion_info_t prach_occasion[MAX_NB_PRACH_OCCASIONS_IN_TIME][MAX_FDM]; // Starting symbol of each PRACH occasions in a slot - 0Xff when no more valid PRACH occasion in that slot
uint8_t nb_of_prach_occasions_in_time;
uint8_t nb_of_prach_occasions_in_freq;
} prach_occasion_slot_t;
typedef enum {
NR_DL_DCI_FORMAT_1_0 = 0,
NR_DL_DCI_FORMAT_1_1,
......@@ -88,6 +125,9 @@ void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss,
uint16_t *slot_period,
uint16_t *offset);
void build_ssb_to_ro_map(NR_ServingCellConfigCommon_t *scc);
int get_nr_prach_info_from_ssb_index(uint8_t ssb_idx, int frame, int slot, prach_occasion_slot_t *prach_occasion_slot_p);
int get_nr_prach_info_from_index(uint8_t index,
int frame,
int slot,
......
......@@ -357,6 +357,8 @@ int nr_rrc_mac_config_req_ue(
}
mac->scg = cell_group_config;
build_ssb_to_ro_map(mac->scc);
/*
if(mac_cell_group_configP != NULL){
if(mac_cell_group_configP->drx_Config != NULL ){
......
......@@ -945,15 +945,16 @@ void nr_ue_msg2_scheduler(module_id_t mod_id,
}
// This function schedules the PRACH according to prach_ConfigurationIndex and TS 38.211, tables 6.3.3.2.x
// It fills the PRACH PDU per each FD occasion.
// PRACH formats 9, 10, 11 are corresponding to dual PRACH format configurations A1/B1, A2/B2, A3/B3.
// - todo:
// - Partial configuration is actually already stored in (fapi_nr_prach_config_t) &mac->phy_config.config_req->prach_config
void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) {
uint8_t config_index, mu, N_dur, N_t_slot, start_symbol;
// uint8_t config_index, mu, N_dur, N_t_slot, start_symbol;
prach_occasion_slot_t prach_occasion_slot;
uint16_t format, format0, format1, ncs;
int msg1_FDM, is_nr_prach_slot, fdm;
// int msg1_FDM, is_nr_prach_slot, fdm;
int is_nr_prach_slot;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
......@@ -964,54 +965,68 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_RACH_ConfigCommon_t *setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
NR_FrequencyInfoDL_t *frequencyInfoDL = scc->downlinkConfigCommon->frequencyInfoDL;
// NR_FrequencyInfoDL_t *frequencyInfoDL = scc->downlinkConfigCommon->frequencyInfoDL;
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric;
config_index = rach_ConfigGeneric->prach_ConfigurationIndex;
// config_index = rach_ConfigGeneric->prach_ConfigurationIndex;
mac->RA_offset = 2; // to compensate the rx frame offset at the gNB
if (is_nr_UL_slot(scc, slotP)) {
if (setup->msg1_SubcarrierSpacing)
mu = *setup->msg1_SubcarrierSpacing;
else
mu = frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing;
is_nr_prach_slot = get_nr_prach_info_from_index(config_index,
// if (setup->msg1_SubcarrierSpacing)
// mu = *setup->msg1_SubcarrierSpacing;
// else
// mu = frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing;
// is_nr_prach_slot = get_nr_prach_info_from_index(config_index,
// (int)frameP,
// (int)slotP,
// frequencyInfoDL->absoluteFrequencyPointA,
// mu,
// cfg->cell_config.frame_duplex_type,
// &format,
// &start_symbol,
// &N_t_slot,
// &N_dur);
uint8_t selected_gnb_ssb_idx = 0; // WIP Need to get the proper selected ssb_idx
mac->generate_nr_prach = 0;
is_nr_prach_slot = get_nr_prach_info_from_ssb_index(selected_gnb_ssb_idx,
(int)frameP,
(int)slotP,
frequencyInfoDL->absoluteFrequencyPointA,
mu,
cfg->cell_config.frame_duplex_type,
&format,
&start_symbol,
&N_t_slot,
&N_dur);
&prach_occasion_slot);
if (is_nr_prach_slot && mac->ra_state == RA_UE_IDLE) {
mac->generate_nr_prach = 1;
fdm = rach_ConfigGeneric->msg1_FDM;
switch (fdm){
case 0:
case 1:
case 2:
case 3:
msg1_FDM = 1 << fdm;
break;
default:
AssertFatal(1 == 0, "Unknown msg1_FDM from rach_ConfigGeneric %d\n", fdm);
}
// fdm = rach_ConfigGeneric->msg1_FDM;
//
// switch (fdm){
// case 0:
// case 1:
// case 2:
// case 3:
// msg1_FDM = 1 << fdm;
// break;
// default:
// AssertFatal(1 == 0, "Unknown msg1_FDM from rach_ConfigGeneric %d\n", fdm);
// }
format = prach_occasion_slot.prach_occasion[0][0].format;
format0 = format & 0xff; // single PRACH format
format1 = (format >> 8) & 0xff; // dual PRACH format
ul_config->sfn = frameP;
ul_config->slot = slotP;
for (int n = 0; n < msg1_FDM; n++) { // one structure per frequency domain occasion
// for (int n = 0; n < msg1_FDM; n++) { // one structure per frequency domain occasion
// Go through all the ROs in the slot and find the first that is mapped to the selected SSB index
for (int ro_in_time=0; ro_in_time < prach_occasion_slot.nb_of_prach_occasions_in_time; ro_in_time++) {
for (int ro_in_freq=0; ro_in_freq < prach_occasion_slot.nb_of_prach_occasions_in_freq; ro_in_freq++) {
prach_occasion_info_t *prach_occasion_info_p = &prach_occasion_slot.prach_occasion[ro_in_time][ro_in_freq];
for (uint8_t ssb_nb=0; ssb_nb<prach_occasion_info_p->nb_mapped_ssbs; ssb_nb++) {
if (prach_occasion_info_p->mapped_ssb_idx[ssb_nb] == selected_gnb_ssb_idx) {
ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PRACH;
prach_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].prach_config_pdu;
......@@ -1022,13 +1037,18 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
// filling PRACH PDU for FAPI config request
prach_config_pdu->phys_cell_id = *scc->physCellId;
prach_config_pdu->num_prach_ocas = N_t_slot;
prach_config_pdu->prach_start_symbol = start_symbol;
prach_config_pdu->num_ra = n;
// prach_config_pdu->num_prach_ocas = N_t_slot;
prach_config_pdu->num_prach_ocas = 1;
// prach_config_pdu->prach_start_symbol = start_symbol;
prach_config_pdu->prach_start_symbol = prach_occasion_info_p->start_symbol;
// prach_config_pdu->num_ra = n;
prach_config_pdu->num_ra = prach_occasion_info_p->fdm;
prach_config_pdu->num_cs = ncs;
prach_config_pdu->root_seq_id = prach_config->num_prach_fd_occasions_list[n].prach_root_sequence_index;
// prach_config_pdu->root_seq_id = prach_config->num_prach_fd_occasions_list[n].prach_root_sequence_index;
prach_config_pdu->root_seq_id = prach_config->num_prach_fd_occasions_list[prach_occasion_info_p->fdm].prach_root_sequence_index;
prach_config_pdu->restricted_set = prach_config->restricted_set_config;
prach_config_pdu->freq_msg1 = prach_config->num_prach_fd_occasions_list[n].k1;
// prach_config_pdu->freq_msg1 = prach_config->num_prach_fd_occasions_list[n].k1;
prach_config_pdu->freq_msg1 = prach_config->num_prach_fd_occasions_list[prach_occasion_info_p->fdm].k1;
if (format1 != 0xff) {
switch(format0) { // dual PRACH format
......@@ -1088,10 +1108,21 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
default:
AssertFatal(1 == 0, "Invalid PRACH format");
}
}
}
} else {
mac->generate_nr_prach = 0;
} // if format1
// RO matching the SSB is found -> get out of mapping loop
mac->generate_nr_prach = 1;
break;
} // if selected_gnb_ssb_idx
} // for ssb_nb
// RO matching the SSB is found -> get out of mapping loop
if (1 == mac->generate_nr_prach) break;
} // for ro_in_freq
// RO matching the SSB is found -> get out of mapping loop
if (1 == mac->generate_nr_prach) break;
} // for ro_in_time
}
mac->scheduled_response.ul_config = ul_config;
}
......
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