Migration of UE MAC RA-related members to a new data struct
- new data struct is RA_config_t - all RA-related members have been moved to the new struct - static variables have been migrated too
This commit is contained in:
@@ -457,6 +457,7 @@ int nr_rrc_mac_config_req_ue(
|
||||
NR_CellGroupConfig_t *cell_group_config ){
|
||||
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
// TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc.
|
||||
|
||||
@@ -469,7 +470,7 @@ int nr_rrc_mac_config_req_ue(
|
||||
mac->servCellIndex = *cell_group_config->spCellConfig->servCellIndex;
|
||||
config_control_ue(mac);
|
||||
if (cell_group_config->spCellConfig->reconfigurationWithSync) {
|
||||
mac->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
|
||||
ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
|
||||
mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
|
||||
config_common_ue(mac,module_id,cc_idP);
|
||||
mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity;
|
||||
|
||||
@@ -245,12 +245,71 @@ typedef enum {
|
||||
RA_SUCCEEDED = 3
|
||||
} RA_state_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
// pointer to RACH config dedicated
|
||||
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated;
|
||||
/// state of RA procedure
|
||||
RA_state_t ra_state;
|
||||
/// RA contention type
|
||||
uint8_t cfra;
|
||||
/// RA rx frame offset: compensate RA rx offset introduced by OAI gNB.
|
||||
uint8_t RA_offset;
|
||||
/// RA-rnti
|
||||
uint16_t ra_rnti;
|
||||
/// Temporary CRNTI
|
||||
uint16_t t_crnti;
|
||||
/// number of attempt for rach
|
||||
uint8_t RA_attempt_number;
|
||||
/// Random-access procedure flag
|
||||
uint8_t RA_active;
|
||||
/// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot
|
||||
uint8_t generate_nr_prach;
|
||||
|
||||
/// Random-access window counter
|
||||
int16_t RA_window_cnt;
|
||||
/// Flag to monitor if matching RAPID was received in RAR
|
||||
uint8_t RA_RAPID_found;
|
||||
/// Flag to monitor if BI was received in RAR
|
||||
uint8_t RA_BI_found;
|
||||
/// Random-access backoff counter
|
||||
int16_t RA_backoff_indicator;
|
||||
/// Flag to indicate whether preambles Group A was used
|
||||
uint8_t RA_usedGroupA;
|
||||
/// RA backoff counter
|
||||
int16_t RA_backoff_cnt;
|
||||
/// RA max number of preamble transmissions
|
||||
int preambleTransMax;
|
||||
/// Nb of preambles per SSB
|
||||
long cb_preambles_per_ssb;
|
||||
int starting_preamble_nb;
|
||||
|
||||
/// Scheduled TX frame for RA Msg3
|
||||
frame_t msg3_frame;
|
||||
/// Scheduled TX slot for RA Msg3
|
||||
slot_t msg3_slot;
|
||||
/// Received TPC command (in dB) from RAR
|
||||
int8_t Msg3_TPC;
|
||||
/// Flag to indicate whether it is the first Msg3 to be transmitted
|
||||
uint8_t first_Msg3;
|
||||
/// RA Msg3 size in bytes
|
||||
uint8_t Msg3_size;
|
||||
|
||||
/// Random-access Contention Resolution Timer active flag
|
||||
uint8_t RA_contention_resolution_timer_active;
|
||||
/// Random-access Contention Resolution Timer count value
|
||||
uint8_t RA_contention_resolution_cnt;
|
||||
|
||||
/// BeamfailurerecoveryConfig
|
||||
NR_BeamFailureRecoveryConfig_t RA_BeamFailureRecoveryConfig;
|
||||
|
||||
} RA_config_t;
|
||||
|
||||
/*!\brief Top level UE MAC structure */
|
||||
typedef struct {
|
||||
|
||||
NR_ServingCellConfigCommon_t *scc;
|
||||
NR_CellGroupConfig_t *scg;
|
||||
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated;
|
||||
int servCellIndex;
|
||||
NR_CSI_ReportConfig_t *csirc;
|
||||
//// MAC config
|
||||
@@ -285,45 +344,11 @@ typedef struct {
|
||||
CCCH_PDU CCCH_pdu;
|
||||
ULSCH_PDU ulsch_pdu;
|
||||
|
||||
/* Random Access parameters */
|
||||
/// state of RA procedure
|
||||
RA_state_t ra_state;
|
||||
/// RA contention type
|
||||
uint8_t cfra;
|
||||
/// RA rx frame offset: compensate RA rx offset introduced by OAI gNB.
|
||||
uint8_t RA_offset;
|
||||
/// RA-rnti
|
||||
uint16_t ra_rnti;
|
||||
/// Temporary CRNTI
|
||||
uint16_t t_crnti;
|
||||
/* Random Access */
|
||||
/// CRNTI
|
||||
uint16_t crnti;
|
||||
/// number of attempt for rach
|
||||
uint8_t RA_attempt_number;
|
||||
/// Random-access procedure flag
|
||||
uint8_t RA_active;
|
||||
/// Random-access window counter
|
||||
int16_t RA_window_cnt;
|
||||
/// BeamfailurerecoveryConfig
|
||||
NR_BeamFailureRecoveryConfig_t RA_BeamFailureRecoveryConfig;
|
||||
/// Random-access backoff counter
|
||||
int16_t RA_backoff_indicator;
|
||||
/// Scheduled TX frame for RA Msg3
|
||||
frame_t msg3_frame;
|
||||
/// Scheduled TX slot for RA Msg3
|
||||
slot_t msg3_slot;
|
||||
/// Random-access Contention Resolution Timer active flag
|
||||
uint8_t RA_contention_resolution_timer_active;
|
||||
/// Random-access Contention Resolution Timer count value
|
||||
uint8_t RA_contention_resolution_cnt;
|
||||
/// Received TPC command (in dB) from RAR
|
||||
int8_t Msg3_TPC;
|
||||
/// Flag to monitor if matching RAPID was received in RAR
|
||||
uint8_t RA_RAPID_found;
|
||||
/// Flag to monitor if BI was received in RAR
|
||||
uint8_t RA_BI_found;
|
||||
/// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot
|
||||
uint8_t generate_nr_prach;
|
||||
/// RA configuration
|
||||
RA_config_t ra;
|
||||
|
||||
//// FAPI-like interface message
|
||||
fapi_nr_ul_config_request_t *ul_config_request;
|
||||
|
||||
@@ -47,16 +47,6 @@
|
||||
#include "NR_MAC_COMMON/nr_mac.h"
|
||||
#include "LAYER2/NR_MAC_UE/mac_proto.h"
|
||||
|
||||
static uint8_t first_Msg3 = 0;
|
||||
static int starting_preamble_nb = 0;
|
||||
static long cb_preambles_per_ssb; // Nb of preambles per SSB
|
||||
static uint8_t RA_usedGroupA;
|
||||
// Random-access Msg3 size in bytes
|
||||
static uint8_t Msg3_size;
|
||||
// Random-access backoff counter
|
||||
static int16_t RA_backoff_cnt;
|
||||
static int preambleTransMax = -1;
|
||||
|
||||
void nr_get_RA_window(NR_UE_MAC_INST_t *mac);
|
||||
|
||||
// Random Access procedure initialization as per 5.1.1 and initialization of variables specific
|
||||
@@ -70,8 +60,13 @@ void init_RA(module_id_t mod_id,
|
||||
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated) {
|
||||
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
|
||||
mac->RA_active = 1;
|
||||
mac->RA_RAPID_found = 0;
|
||||
|
||||
RA_config_t *ra = &mac->ra;
|
||||
ra->RA_active = 1;
|
||||
ra->RA_RAPID_found = 0;
|
||||
ra->preambleTransMax = -1;
|
||||
ra->first_Msg3 = 0;
|
||||
ra->starting_preamble_nb = 0;
|
||||
|
||||
prach_resources->RA_PREAMBLE_BACKOFF = 0;
|
||||
prach_resources->RA_PCMAX = nr_get_Pcmax(mod_id);
|
||||
@@ -84,7 +79,7 @@ void init_RA(module_id_t mod_id,
|
||||
if (rach_ConfigDedicated->cfra){
|
||||
LOG_I(MAC, "Initialization of 4-step contention-free random access procedure\n");
|
||||
prach_resources->RA_TYPE = RA_4STEP;
|
||||
mac->cfra = 1;
|
||||
ra->cfra = 1;
|
||||
}
|
||||
} else if (rach_ConfigDedicated->ext1){
|
||||
if (rach_ConfigDedicated->ext1->cfra_TwoStep_r16){
|
||||
@@ -114,37 +109,37 @@ void init_RA(module_id_t mod_id,
|
||||
|
||||
switch (rach_ConfigGeneric->preambleTransMax) {
|
||||
case 0:
|
||||
preambleTransMax = 3;
|
||||
ra->preambleTransMax = 3;
|
||||
break;
|
||||
case 1:
|
||||
preambleTransMax = 4;
|
||||
ra->preambleTransMax = 4;
|
||||
break;
|
||||
case 2:
|
||||
preambleTransMax = 5;
|
||||
ra->preambleTransMax = 5;
|
||||
break;
|
||||
case 3:
|
||||
preambleTransMax = 6;
|
||||
ra->preambleTransMax = 6;
|
||||
break;
|
||||
case 4:
|
||||
preambleTransMax = 7;
|
||||
ra->preambleTransMax = 7;
|
||||
break;
|
||||
case 5:
|
||||
preambleTransMax = 8;
|
||||
ra->preambleTransMax = 8;
|
||||
break;
|
||||
case 6:
|
||||
preambleTransMax = 10;
|
||||
ra->preambleTransMax = 10;
|
||||
break;
|
||||
case 7:
|
||||
preambleTransMax = 20;
|
||||
ra->preambleTransMax = 20;
|
||||
break;
|
||||
case 8:
|
||||
preambleTransMax = 50;
|
||||
ra->preambleTransMax = 50;
|
||||
break;
|
||||
case 9:
|
||||
preambleTransMax = 100;
|
||||
ra->preambleTransMax = 100;
|
||||
break;
|
||||
case 10:
|
||||
preambleTransMax = 200;
|
||||
ra->preambleTransMax = 200;
|
||||
break;
|
||||
}
|
||||
if (nr_rach_ConfigCommon->ext1) {
|
||||
@@ -158,7 +153,7 @@ void init_RA(module_id_t mod_id,
|
||||
|
||||
}
|
||||
|
||||
void ssb_rach_config(NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon, fapi_nr_ul_config_prach_pdu *prach_pdu){
|
||||
void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon, fapi_nr_ul_config_prach_pdu *prach_pdu){
|
||||
|
||||
// Determine the SSB to RACH mapping ratio
|
||||
// =======================================
|
||||
@@ -174,42 +169,42 @@ void ssb_rach_config(NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon
|
||||
case NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth:
|
||||
multiple_ssb_per_ro = false;
|
||||
ssb_rach_ratio = 8;
|
||||
cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneEighth + 1);
|
||||
ra->cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneEighth + 1);
|
||||
break;
|
||||
case NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth:
|
||||
multiple_ssb_per_ro = false;
|
||||
ssb_rach_ratio = 4;
|
||||
cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneFourth + 1);
|
||||
ra->cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneFourth + 1);
|
||||
break;
|
||||
case NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf:
|
||||
multiple_ssb_per_ro = false;
|
||||
ssb_rach_ratio = 2;
|
||||
cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneHalf + 1);
|
||||
ra->cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneHalf + 1);
|
||||
break;
|
||||
case NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one:
|
||||
multiple_ssb_per_ro = true;
|
||||
ssb_rach_ratio = 1;
|
||||
cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one + 1);
|
||||
ra->cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one + 1);
|
||||
break;
|
||||
case NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two:
|
||||
multiple_ssb_per_ro = true;
|
||||
ssb_rach_ratio = 2;
|
||||
cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.two + 1);
|
||||
ra->cb_preambles_per_ssb = 4 * (nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.two + 1);
|
||||
break;
|
||||
case NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four:
|
||||
multiple_ssb_per_ro = true;
|
||||
ssb_rach_ratio = 4;
|
||||
cb_preambles_per_ssb = nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.four;
|
||||
ra->cb_preambles_per_ssb = nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.four;
|
||||
break;
|
||||
case NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight:
|
||||
multiple_ssb_per_ro = true;
|
||||
ssb_rach_ratio = 8;
|
||||
cb_preambles_per_ssb = nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.eight;
|
||||
ra->cb_preambles_per_ssb = nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.eight;
|
||||
break;
|
||||
case NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen:
|
||||
multiple_ssb_per_ro = true;
|
||||
ssb_rach_ratio = 16;
|
||||
cb_preambles_per_ssb = nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.sixteen;
|
||||
ra->cb_preambles_per_ssb = nr_rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.sixteen;
|
||||
break;
|
||||
default:
|
||||
AssertFatal(1 == 0, "Unsupported ssb_perRACH_config %d\n", ssb_perRACH_config);
|
||||
@@ -225,11 +220,11 @@ void ssb_rach_config(NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon
|
||||
total_preambles_per_ssb = numberOfRA_Preambles / ssb_rach_ratio;
|
||||
|
||||
ssb_nb_in_ro = prach_pdu->ssb_nb_in_ro;
|
||||
starting_preamble_nb = total_preambles_per_ssb * ssb_nb_in_ro;
|
||||
ra->starting_preamble_nb = total_preambles_per_ssb * ssb_nb_in_ro;
|
||||
}
|
||||
else {
|
||||
total_preambles_per_ssb = numberOfRA_Preambles;
|
||||
starting_preamble_nb = 0;
|
||||
ra->starting_preamble_nb = 0;
|
||||
}
|
||||
} else {
|
||||
LOG_E(MAC, "In %s:%d: missing implementation for 2-step RA...\n", __FUNCTION__, __LINE__);
|
||||
@@ -246,6 +241,7 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
|
||||
int PLThreshold;
|
||||
long deltaPreamble_Msg3 = 0;
|
||||
uint8_t noGroupB = 0;
|
||||
RA_config_t *ra = &mac->ra;
|
||||
NR_ServingCellConfigCommon_t *scc = mac->scc;
|
||||
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
|
||||
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &nr_rach_ConfigCommon->rach_ConfigGeneric;
|
||||
@@ -344,30 +340,30 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
|
||||
LOG_E(MAC, "In %s:%d: missing implementation for 2-step RA...\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
/* Msg3 has not been transmitted yet */
|
||||
if (first_Msg3) {
|
||||
if (ra->first_Msg3) {
|
||||
if (noGroupB) {
|
||||
// use Group A preamble
|
||||
prach_resources->ra_PreambleIndex = starting_preamble_nb + ((taus()) % cb_preambles_per_ssb);
|
||||
RA_usedGroupA = 1;
|
||||
} else if ((Msg3_size < messageSizeGroupA) && (dl_pathloss > PLThreshold)) {
|
||||
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
|
||||
ra->RA_usedGroupA = 1;
|
||||
} else if ((ra->Msg3_size < messageSizeGroupA) && (dl_pathloss > PLThreshold)) {
|
||||
// Group B is configured and RA preamble Group A is used
|
||||
// - todo add condition on CCCH_sdu_size for initiation by CCCH
|
||||
prach_resources->ra_PreambleIndex = starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
|
||||
RA_usedGroupA = 1;
|
||||
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
|
||||
ra->RA_usedGroupA = 1;
|
||||
} else {
|
||||
// Group B preamble is configured and used
|
||||
// the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A
|
||||
// the remaining belong to RA Preambles Group B
|
||||
prach_resources->ra_PreambleIndex = starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
|
||||
RA_usedGroupA = 0;
|
||||
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
|
||||
ra->RA_usedGroupA = 0;
|
||||
}
|
||||
} else { // Msg3 is being retransmitted
|
||||
if (RA_usedGroupA && noGroupB) {
|
||||
prach_resources->ra_PreambleIndex = starting_preamble_nb + ((taus()) % cb_preambles_per_ssb);
|
||||
} else if (RA_usedGroupA && !noGroupB){
|
||||
prach_resources->ra_PreambleIndex = starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
|
||||
if (ra->RA_usedGroupA && noGroupB) {
|
||||
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
|
||||
} else if (ra->RA_usedGroupA && !noGroupB){
|
||||
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
|
||||
} else {
|
||||
prach_resources->ra_PreambleIndex = starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
|
||||
prach_resources->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -380,13 +376,19 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
|
||||
// - s_id is starting symbol of the PRACH occasion [0...14]
|
||||
// - t_id is the first slot of the PRACH occasion in a system frame [0...80]
|
||||
uint16_t set_ra_rnti(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_prach_pdu *prach_pdu){
|
||||
|
||||
RA_config_t *ra = &mac->ra;
|
||||
uint8_t ul_carrier_id = 0; // NUL
|
||||
uint8_t f_id = prach_pdu->num_ra;
|
||||
uint8_t t_id = prach_pdu->prach_slot;
|
||||
uint8_t s_id = prach_pdu->prach_start_symbol;
|
||||
mac->ra_rnti = 1 + s_id + 14 * t_id + 1120 * f_id + 8960 * ul_carrier_id;
|
||||
LOG_D(MAC, "Computed ra_RNTI is %x \n", mac->ra_rnti);
|
||||
return mac->ra_rnti;
|
||||
|
||||
ra->ra_rnti = 1 + s_id + 14 * t_id + 1120 * f_id + 8960 * ul_carrier_id;
|
||||
|
||||
LOG_D(MAC, "Computed ra_RNTI is %x \n", ra->ra_rnti);
|
||||
|
||||
return ra->ra_rnti;
|
||||
|
||||
}
|
||||
|
||||
// This routine implements Section 5.1.2 (UE Random Access Resource Selection)
|
||||
@@ -417,9 +419,10 @@ void nr_get_prach_resources(module_id_t mod_id,
|
||||
NR_RACH_ConfigDedicated_t * rach_ConfigDedicated){
|
||||
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
|
||||
|
||||
LOG_D(PHY, "In %s: getting PRACH resources frame (first_Msg3 %d)\n", __FUNCTION__, first_Msg3);
|
||||
LOG_D(PHY, "In %s: getting PRACH resources frame (first_Msg3 %d)\n", __FUNCTION__, ra->first_Msg3);
|
||||
|
||||
if (rach_ConfigDedicated) {
|
||||
if (rach_ConfigDedicated->cfra){
|
||||
@@ -429,7 +432,7 @@ void nr_get_prach_resources(module_id_t mod_id,
|
||||
}
|
||||
} else {
|
||||
int16_t dl_pathloss = get_nr_PL(mod_id, CC_id, gNB_id);
|
||||
ssb_rach_config(prach_resources, nr_rach_ConfigCommon, prach_pdu);
|
||||
ssb_rach_config(ra, prach_resources, nr_rach_ConfigCommon, prach_pdu);
|
||||
ra_preambles_config(prach_resources, mac, dl_pathloss);
|
||||
LOG_D(MAC, "[RAPROC] - Selected RA preamble index %d for contention-based random access procedure... \n", prach_resources->ra_PreambleIndex);
|
||||
}
|
||||
@@ -444,20 +447,22 @@ void nr_get_prach_resources(module_id_t mod_id,
|
||||
// TbD: RA_attempt_number not used
|
||||
void nr_Msg1_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id){
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
|
||||
mac->ra_state = WAIT_RAR;
|
||||
mac->RA_attempt_number++;
|
||||
RA_config_t *ra = &mac->ra;
|
||||
ra->ra_state = WAIT_RAR;
|
||||
ra->RA_attempt_number++;
|
||||
}
|
||||
|
||||
void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id){
|
||||
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
|
||||
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
LOG_D(MAC,"In %s: [UE %d] Frame %d, CB-RA: starting contention resolution timer\n", __FUNCTION__, mod_id, frameP);
|
||||
|
||||
// start contention resolution timer
|
||||
mac->RA_contention_resolution_cnt = (nr_rach_ConfigCommon->ra_ContentionResolutionTimer + 1) * 8;
|
||||
mac->RA_contention_resolution_timer_active = 1;
|
||||
ra->RA_contention_resolution_cnt = (nr_rach_ConfigCommon->ra_ContentionResolutionTimer + 1) * 8;
|
||||
ra->RA_contention_resolution_timer_active = 1;
|
||||
|
||||
}
|
||||
|
||||
@@ -486,6 +491,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
|
||||
int nr_slot_tx){
|
||||
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
uint8_t mac_sdus[MAX_NR_ULSCH_PAYLOAD_BYTES];
|
||||
uint8_t lcid = UL_SCH_LCID_CCCH_MSG3, *payload;
|
||||
uint16_t size_sdu = 0;
|
||||
@@ -495,7 +501,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
|
||||
NR_RACH_ConfigCommon_t *setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
|
||||
AssertFatal(&setup->rach_ConfigGeneric != NULL, "In %s: FATAL! rach_ConfigGeneric is NULL...\n", __FUNCTION__);
|
||||
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric;
|
||||
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated = mac->rach_ConfigDedicated;
|
||||
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated = ra->rach_ConfigDedicated;
|
||||
|
||||
uint8_t sdu_lcids[NB_RB_MAX] = {0};
|
||||
uint16_t sdu_lengths[NB_RB_MAX] = {0};
|
||||
@@ -503,7 +509,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
|
||||
|
||||
if (prach_resources->init_msg1) {
|
||||
|
||||
if (mac->RA_active == 0) {
|
||||
if (ra->RA_active == 0) {
|
||||
/* RA not active - checking if RRC is ready to initiate the RA procedure */
|
||||
|
||||
LOG_D(MAC, "RA not active. Checking for data to transmit from upper layers...\n");
|
||||
@@ -542,16 +548,16 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
|
||||
|
||||
LOG_D(MAC, "[UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", mod_id, frame, nr_slot_tx);
|
||||
|
||||
first_Msg3 = 1;
|
||||
RA_backoff_cnt = 0;
|
||||
Msg3_size = size_sdu + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT);
|
||||
ra->first_Msg3 = 1;
|
||||
ra->RA_backoff_cnt = 0;
|
||||
ra->Msg3_size = size_sdu + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT);
|
||||
|
||||
init_RA(mod_id, prach_resources, setup, rach_ConfigGeneric, rach_ConfigDedicated);
|
||||
prach_resources->Msg3 = payload;
|
||||
nr_get_RA_window(mac);
|
||||
|
||||
// Fill in preamble and PRACH resources
|
||||
if (mac->generate_nr_prach == 1)
|
||||
if (ra->generate_nr_prach == 1)
|
||||
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
|
||||
|
||||
offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer
|
||||
@@ -573,43 +579,43 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
|
||||
payload[offset + j] = 0; // mac_pdu[offset + j] = 0;
|
||||
}
|
||||
}
|
||||
} else if (mac->RA_window_cnt != -1) { // RACH is active
|
||||
} else if (ra->RA_window_cnt != -1) { // RACH is active
|
||||
|
||||
LOG_D(MAC, "In %s [%d.%d] RA is active: RA window count %d, RA backoff count %d\n", __FUNCTION__, frame, nr_slot_tx, mac->RA_window_cnt, RA_backoff_cnt);
|
||||
LOG_D(MAC, "In %s [%d.%d] RA is active: RA window count %d, RA backoff count %d\n", __FUNCTION__, frame, nr_slot_tx, ra->RA_window_cnt, ra->RA_backoff_cnt);
|
||||
|
||||
if (mac->RA_BI_found){
|
||||
prach_resources->RA_PREAMBLE_BACKOFF = prach_resources->RA_SCALING_FACTOR_BI * mac->RA_backoff_indicator;
|
||||
if (ra->RA_BI_found){
|
||||
prach_resources->RA_PREAMBLE_BACKOFF = prach_resources->RA_SCALING_FACTOR_BI * ra->RA_backoff_indicator;
|
||||
} else {
|
||||
prach_resources->RA_PREAMBLE_BACKOFF = 0;
|
||||
}
|
||||
|
||||
if (mac->RA_window_cnt >= 0 && mac->RA_RAPID_found == 1) {
|
||||
if (ra->RA_window_cnt >= 0 && ra->RA_RAPID_found == 1) {
|
||||
// Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213)
|
||||
// TbD Msg3 Retransmissions to be scheduled by DCI 0_0
|
||||
|
||||
nr_ra_succeeded(mod_id, frame, nr_slot_tx);
|
||||
|
||||
} else if (mac->RA_window_cnt == 0 && !mac->RA_RAPID_found) {
|
||||
} else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) {
|
||||
|
||||
LOG_I(MAC, "[UE %d][%d:%d] RAR reception failed \n", mod_id, frame, nr_slot_tx);
|
||||
|
||||
nr_ra_failed(mod_id, CC_id, prach_resources, frame, nr_slot_tx);
|
||||
|
||||
} else if (mac->RA_window_cnt > 0) {
|
||||
} else if (ra->RA_window_cnt > 0) {
|
||||
|
||||
LOG_D(MAC, "[UE %d][%d.%d]: RAR not received yet (RA window count %d) \n", mod_id, frame, nr_slot_tx, mac->RA_window_cnt);
|
||||
LOG_D(MAC, "[UE %d][%d.%d]: RAR not received yet (RA window count %d) \n", mod_id, frame, nr_slot_tx, ra->RA_window_cnt);
|
||||
|
||||
// Fill in preamble and PRACH resources
|
||||
mac->RA_window_cnt--;
|
||||
ra->RA_window_cnt--;
|
||||
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
|
||||
|
||||
} else if (RA_backoff_cnt > 0) {
|
||||
} else if (ra->RA_backoff_cnt > 0) {
|
||||
|
||||
LOG_D(MAC, "[UE %d][%d.%d]: RAR not received yet (RA backoff count %d) \n", mod_id, frame, nr_slot_tx, RA_backoff_cnt);
|
||||
LOG_D(MAC, "[UE %d][%d.%d]: RAR not received yet (RA backoff count %d) \n", mod_id, frame, nr_slot_tx, ra->RA_backoff_cnt);
|
||||
|
||||
RA_backoff_cnt--;
|
||||
ra->RA_backoff_cnt--;
|
||||
|
||||
if ((RA_backoff_cnt > 0 && mac->generate_nr_prach == 1) || RA_backoff_cnt == 0){
|
||||
if ((ra->RA_backoff_cnt > 0 && ra->generate_nr_prach == 1) || ra->RA_backoff_cnt == 0){
|
||||
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
|
||||
}
|
||||
|
||||
@@ -617,17 +623,18 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
|
||||
}
|
||||
}
|
||||
|
||||
if (mac->RA_contention_resolution_timer_active){
|
||||
if (ra->RA_contention_resolution_timer_active){
|
||||
nr_ue_contention_resolution(mod_id, CC_id, frame, nr_slot_tx, prach_resources);
|
||||
}
|
||||
|
||||
return mac->generate_nr_prach;
|
||||
return ra->generate_nr_prach;
|
||||
|
||||
}
|
||||
|
||||
void nr_get_RA_window(NR_UE_MAC_INST_t *mac){
|
||||
|
||||
uint8_t mu, ra_ResponseWindow;
|
||||
RA_config_t *ra = &mac->ra;
|
||||
NR_ServingCellConfigCommon_t *scc = mac->scc;
|
||||
NR_RACH_ConfigCommon_t *setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
|
||||
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric;
|
||||
@@ -640,32 +647,32 @@ void nr_get_RA_window(NR_UE_MAC_INST_t *mac){
|
||||
else
|
||||
mu = frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing;
|
||||
|
||||
mac->RA_window_cnt = mac->RA_offset*nr_slots_per_frame[mu]; // taking into account the 2 frames gap introduced by OAI gNB
|
||||
ra->RA_window_cnt = ra->RA_offset*nr_slots_per_frame[mu]; // taking into account the 2 frames gap introduced by OAI gNB
|
||||
|
||||
switch (ra_ResponseWindow) {
|
||||
case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl1:
|
||||
mac->RA_window_cnt += 1;
|
||||
ra->RA_window_cnt += 1;
|
||||
break;
|
||||
case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl2:
|
||||
mac->RA_window_cnt += 2;
|
||||
ra->RA_window_cnt += 2;
|
||||
break;
|
||||
case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl4:
|
||||
mac->RA_window_cnt += 4;
|
||||
ra->RA_window_cnt += 4;
|
||||
break;
|
||||
case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl8:
|
||||
mac->RA_window_cnt += 8;
|
||||
ra->RA_window_cnt += 8;
|
||||
break;
|
||||
case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl10:
|
||||
mac->RA_window_cnt += 10;
|
||||
ra->RA_window_cnt += 10;
|
||||
break;
|
||||
case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl20:
|
||||
mac->RA_window_cnt += 20;
|
||||
ra->RA_window_cnt += 20;
|
||||
break;
|
||||
case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl40:
|
||||
mac->RA_window_cnt += 40;
|
||||
ra->RA_window_cnt += 40;
|
||||
break;
|
||||
case NR_RACH_ConfigGeneric__ra_ResponseWindow_sl80:
|
||||
mac->RA_window_cnt += 80;
|
||||
ra->RA_window_cnt += 80;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -680,17 +687,18 @@ void nr_get_RA_window(NR_UE_MAC_INST_t *mac){
|
||||
void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame, int slot, NR_PRACH_RESOURCES_t *prach_resources){
|
||||
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
if (mac->RA_contention_resolution_timer_active == 1) {
|
||||
if (ra->RA_contention_resolution_timer_active == 1) {
|
||||
|
||||
mac->RA_contention_resolution_cnt--;
|
||||
ra->RA_contention_resolution_cnt--;
|
||||
|
||||
LOG_D(MAC, "In %s: [%d.%d] RA contention resolution timer %d\n", __FUNCTION__, frame, slot, mac->RA_contention_resolution_cnt);
|
||||
LOG_D(MAC, "In %s: [%d.%d] RA contention resolution timer %d\n", __FUNCTION__, frame, slot, ra->RA_contention_resolution_cnt);
|
||||
|
||||
if (mac->RA_contention_resolution_cnt == 0) {
|
||||
mac->t_crnti = 0;
|
||||
mac->RA_active = 0;
|
||||
mac->RA_contention_resolution_timer_active = 0;
|
||||
if (ra->RA_contention_resolution_cnt == 0) {
|
||||
ra->t_crnti = 0;
|
||||
ra->RA_active = 0;
|
||||
ra->RA_contention_resolution_timer_active = 0;
|
||||
// Signal PHY to quit RA procedure
|
||||
LOG_E(MAC, "[UE %d] CB-RA: Contention resolution timer has expired, RA procedure has failed...\n", module_id);
|
||||
nr_ra_failed(module_id, cc_id, prach_resources, frame, slot);
|
||||
@@ -706,20 +714,21 @@ void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame
|
||||
void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){
|
||||
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
if (mac->cfra) {
|
||||
if (ra->cfra) {
|
||||
|
||||
LOG_I(MAC, "[UE %d][%d.%d] CF-RA: RAR successfully received, RA procedure is completed\n", mod_id, frame, slot);
|
||||
|
||||
mac->RA_window_cnt = -1;
|
||||
ra->RA_window_cnt = -1;
|
||||
|
||||
} else {
|
||||
|
||||
LOG_I(MAC, "[UE %d][%d.%d] CB-RA: Contention Resolution is successful, RA is completed\n", mod_id, frame, slot);
|
||||
|
||||
mac->RA_contention_resolution_cnt = -1;
|
||||
mac->RA_contention_resolution_timer_active = 0;
|
||||
mac->t_crnti = 0;
|
||||
ra->RA_contention_resolution_cnt = -1;
|
||||
ra->RA_contention_resolution_timer_active = 0;
|
||||
ra->t_crnti = 0;
|
||||
|
||||
LOG_D(MAC, "In %s: [UE %d][%d.%d] CB-RA: cleared contention resolution timer...\n", __FUNCTION__, mod_id, frame, slot);
|
||||
|
||||
@@ -740,20 +749,21 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){
|
||||
void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_resources, frame_t frame, int slot) {
|
||||
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
first_Msg3 = 0;
|
||||
mac->generate_nr_prach = 3;
|
||||
mac->ra_state = RA_UE_IDLE;
|
||||
ra->first_Msg3 = 0;
|
||||
ra->generate_nr_prach = 3;
|
||||
ra->ra_state = RA_UE_IDLE;
|
||||
|
||||
prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER++;
|
||||
|
||||
if(prach_resources->RA_TYPE == RA_4STEP){
|
||||
|
||||
if (prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax + 1){
|
||||
if (prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER == ra->preambleTransMax + 1){
|
||||
|
||||
LOG_D(MAC, "In %s: [UE %d][%d.%d] Maximum number of RACH attempts (%d) reached, selecting backoff time...\n", __FUNCTION__, mod_id, frame, slot, preambleTransMax);
|
||||
LOG_D(MAC, "In %s: [UE %d][%d.%d] Maximum number of RACH attempts (%d) reached, selecting backoff time...\n", __FUNCTION__, mod_id, frame, slot, ra->preambleTransMax);
|
||||
|
||||
RA_backoff_cnt = rand() % (prach_resources->RA_PREAMBLE_BACKOFF + 1);
|
||||
ra->RA_backoff_cnt = rand() % (prach_resources->RA_PREAMBLE_BACKOFF + 1);
|
||||
|
||||
prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER = 1;
|
||||
prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP += 2; // 2 dB increment
|
||||
|
||||
@@ -68,6 +68,7 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd
|
||||
|
||||
void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id){
|
||||
|
||||
RA_config_t *ra = &mac->ra;
|
||||
uint16_t monitoringSymbolsWithinSlot = 0;
|
||||
uint8_t coreset_id = 1;
|
||||
int sps = 0;
|
||||
@@ -103,7 +104,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
|
||||
// Scrambling RNTI
|
||||
if (coreset->pdcch_DMRS_ScramblingID) {
|
||||
rel15->coreset.pdcch_dmrs_scrambling_id = *coreset->pdcch_DMRS_ScramblingID;
|
||||
rel15->coreset.scrambling_rnti = mac->t_crnti;
|
||||
rel15->coreset.scrambling_rnti = ra->t_crnti;
|
||||
} else {
|
||||
rel15->coreset.pdcch_dmrs_scrambling_id = *scc->physCellId;
|
||||
rel15->coreset.scrambling_rnti = 0;
|
||||
@@ -132,7 +133,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
|
||||
// we use the initial DL BWP
|
||||
sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12;
|
||||
monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
|
||||
rel15->rnti = mac->ra_rnti;
|
||||
rel15->rnti = ra->ra_rnti;
|
||||
rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
|
||||
rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); //NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275);
|
||||
rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing;
|
||||
@@ -185,13 +186,14 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
|
||||
|
||||
void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) {
|
||||
|
||||
RA_config_t *ra = &mac->ra;
|
||||
int ss_id;
|
||||
uint8_t bwp_id = 1, coreset_id = 1;
|
||||
//NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated;
|
||||
NR_BWP_Downlink_t *bwp = mac->DLbwp[bwp_id - 1];
|
||||
|
||||
#ifdef DEBUG_DCI
|
||||
LOG_D(MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &mac->ra_rnti, mac->ra_rnti, &mac->crnti, mac->crnti, &mac->t_crnti, mac->t_crnti);
|
||||
LOG_D(MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti);
|
||||
#endif
|
||||
|
||||
// loop over all available SS for BWP ID 1, CORESET ID 1
|
||||
@@ -215,7 +217,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
|
||||
// check available SS IDs
|
||||
if (pdcch_ConfigCommon->choice.setup->ra_SearchSpace){
|
||||
if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->ra_SearchSpace){
|
||||
switch(mac->ra_state){
|
||||
switch(ra->ra_state){
|
||||
case WAIT_RAR:
|
||||
LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space\n");
|
||||
rel15->num_dci_options = 1;
|
||||
@@ -224,7 +226,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
|
||||
fill_dci_search_candidates(ss, rel15);
|
||||
break;
|
||||
case WAIT_CONTENTION_RESOLUTION:
|
||||
rel15->rnti = mac->t_crnti;
|
||||
rel15->rnti = ra->t_crnti;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -289,7 +291,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
|
||||
if (ss->searchSpaceType->choice.ue_Specific){
|
||||
if(ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1){
|
||||
// Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI
|
||||
if ((mac->ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test) && mac->crnti > 0) {
|
||||
if ((ra->ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test) && mac->crnti > 0) {
|
||||
LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n");
|
||||
rel15->num_dci_options = 2;
|
||||
rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1;
|
||||
|
||||
@@ -1275,10 +1275,11 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
|
||||
|
||||
module_id_t mod_id = ul_info->module_id;
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
if (mac->ra_state == WAIT_RAR){
|
||||
if (ra->ra_state == WAIT_RAR){
|
||||
|
||||
if (mac->RA_active && ul_info->slot_tx == mac->msg3_slot && ul_info->frame_tx == mac->msg3_frame){
|
||||
if (ra->RA_active && ul_info->slot_tx == ra->msg3_slot && ul_info->frame_tx == ra->msg3_frame){
|
||||
|
||||
uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES];
|
||||
nr_scheduled_response_t scheduled_response;
|
||||
@@ -1319,7 +1320,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
|
||||
ul_info->module_id,
|
||||
ul_info->frame_tx,
|
||||
ul_info->slot_tx,
|
||||
mac->t_crnti);
|
||||
ra->t_crnti);
|
||||
|
||||
// Config UL TX PDU
|
||||
tx_req.slot = ul_info->slot_tx;
|
||||
@@ -1336,12 +1337,12 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
|
||||
mac->if_module->scheduled_response(&scheduled_response);
|
||||
}
|
||||
|
||||
if (!mac->cfra){
|
||||
if (!ra->cfra){
|
||||
nr_Msg3_transmitted(ul_info->module_id, ul_info->cc_id, ul_info->frame_tx, ul_info->gNB_index);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (mac->ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test) {
|
||||
} else if (ra->ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test) {
|
||||
|
||||
uint8_t nb_dmrs_re_per_rb;
|
||||
uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES];
|
||||
@@ -1499,6 +1500,7 @@ void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac,
|
||||
uint8_t Msg3_tda_id){
|
||||
|
||||
int delta = 0;
|
||||
RA_config_t *ra = &mac->ra;
|
||||
NR_BWP_Uplink_t *ubwp = mac->ULbwp[0];
|
||||
int mu = ubwp->bwp_Common->genericParameters.subcarrierSpacing;
|
||||
struct NR_PUSCH_TimeDomainResourceAllocationList *pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList;
|
||||
@@ -1521,14 +1523,14 @@ void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac,
|
||||
break;
|
||||
}
|
||||
|
||||
mac->msg3_slot = (current_slot + k2 + delta) % nr_slots_per_frame[mu];
|
||||
ra->msg3_slot = (current_slot + k2 + delta) % nr_slots_per_frame[mu];
|
||||
if (current_slot + k2 + delta > nr_slots_per_frame[mu])
|
||||
mac->msg3_frame = (current_frame + 1) % 1024;
|
||||
ra->msg3_frame = (current_frame + 1) % 1024;
|
||||
else
|
||||
mac->msg3_frame = current_frame;
|
||||
ra->msg3_frame = current_frame;
|
||||
|
||||
#ifdef DEBUG_MSG3
|
||||
LOG_D(MAC, "[DEBUG_MSG3] current_slot %d k2 %d delta %d temp_slot %d mac->msg3_frame %d mac->msg3_slot %d \n", current_slot, k2, delta, current_slot + k2 + delta, mac->msg3_frame, mac->msg3_slot);
|
||||
LOG_D(MAC, "[DEBUG_MSG3] current_slot %d k2 %d delta %d temp_slot %d msg3_frame %d msg3_slot %d \n", current_slot, k2, delta, current_slot + k2 + delta, ra->msg3_frame, ra->msg3_slot);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1543,6 +1545,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
|
||||
prach_occasion_info_t *prach_occasion_info_p;
|
||||
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
//fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP);
|
||||
fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request[0];
|
||||
@@ -1555,8 +1558,8 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
|
||||
NR_RACH_ConfigCommon_t *setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
|
||||
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric;
|
||||
|
||||
mac->RA_offset = 2; // to compensate the rx frame offset at the gNB
|
||||
mac->generate_nr_prach = 0; // Reset flag for PRACH generation
|
||||
ra->RA_offset = 2; // to compensate the rx frame offset at the gNB
|
||||
ra->generate_nr_prach = 0; // Reset flag for PRACH generation
|
||||
|
||||
if (is_nr_UL_slot(scc, slotP)) {
|
||||
|
||||
@@ -1570,10 +1573,10 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
|
||||
(int)slotP,
|
||||
&prach_occasion_info_p);
|
||||
|
||||
if (is_nr_prach_slot && mac->ra_state == RA_UE_IDLE) {
|
||||
if (is_nr_prach_slot && ra->ra_state == RA_UE_IDLE) {
|
||||
AssertFatal(NULL != prach_occasion_info_p,"PRACH Occasion Info not returned in a valid NR Prach Slot\n");
|
||||
|
||||
mac->generate_nr_prach = 1;
|
||||
ra->generate_nr_prach = 1;
|
||||
|
||||
format = prach_occasion_info_p->format;
|
||||
format0 = format & 0xff; // single PRACH format
|
||||
@@ -1951,6 +1954,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
|
||||
uint16_t frame_tx = 0, slot_tx = 0;
|
||||
bool valid_ptrs_setup = 0;
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
NR_BWP_Id_t bwp_id = mac->UL_BWP_Id;
|
||||
fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
|
||||
fapi_nr_ul_config_request_t *ul_config = NULL;
|
||||
@@ -1960,7 +1964,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
|
||||
AssertFatal(mac->DLbwp[0]!=NULL,"DLbwp[0] should not be zero here!\n");
|
||||
AssertFatal(mac->ULbwp[0]!=NULL,"DLbwp[0] should not be zero here!\n");
|
||||
|
||||
const uint16_t n_RB_DLBWP = (mac->ra_state == WAIT_RAR) ? NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
|
||||
const uint16_t n_RB_DLBWP = (ra->ra_state == WAIT_RAR) ? NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
|
||||
const uint16_t n_RB_ULBWP = NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
|
||||
|
||||
LOG_D(MAC,"nr_ue_process_dci at MAC layer with dci_format=%d (DL BWP %d, UL BWP %d)\n",dci_format,n_RB_DLBWP,n_RB_ULBWP);
|
||||
@@ -2024,7 +2028,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
|
||||
pusch_config_pdu_0_0->start_symbol_index,
|
||||
pusch_config_pdu_0_0->nr_of_symbols);
|
||||
|
||||
if (mac->RA_active && mac->crnti){
|
||||
if (ra->RA_active && mac->crnti){
|
||||
nr_ra_succeeded(module_id, frame, slot);
|
||||
}
|
||||
|
||||
@@ -2158,7 +2162,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
|
||||
pusch_config_pdu_0_1->start_symbol_index,
|
||||
pusch_config_pdu_0_1->nr_of_symbols);
|
||||
|
||||
if (mac->RA_active && mac->crnti){
|
||||
if (ra->RA_active && mac->crnti){
|
||||
nr_ra_succeeded(module_id, frame, slot);
|
||||
}
|
||||
|
||||
@@ -2612,7 +2616,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
|
||||
dlsch_config_pdu_1_0->pucch_resource_id,
|
||||
dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind);
|
||||
|
||||
if (mac->RA_window_cnt >= 0 && rnti == mac->ra_rnti){
|
||||
if (ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti){
|
||||
dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH;
|
||||
} else {
|
||||
dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
|
||||
@@ -2958,9 +2962,11 @@ int nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
|
||||
dci_pdu_rel15_t *dci_pdu_rel15) {
|
||||
int rnti_type=-1;
|
||||
|
||||
if (rnti == mac->ra_rnti) rnti_type = NR_RNTI_RA;
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
if (rnti == ra->ra_rnti) rnti_type = NR_RNTI_RA;
|
||||
else if (rnti == mac->crnti) rnti_type = NR_RNTI_C;
|
||||
else if (rnti == mac->t_crnti) rnti_type = NR_RNTI_TC;
|
||||
else if (rnti == ra->t_crnti) rnti_type = NR_RNTI_TC;
|
||||
else if (rnti == 0xFFFE) rnti_type = NR_RNTI_P;
|
||||
else if (rnti == 0xFFFF) rnti_type = NR_RNTI_SI;
|
||||
|
||||
@@ -3562,6 +3568,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
|
||||
uint8_t CC_id = dl_info->cc_id;
|
||||
uint8_t done = 0;
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
|
||||
RA_config_t *ra = &mac->ra;
|
||||
|
||||
if (!pduP){
|
||||
return;
|
||||
@@ -3705,7 +3712,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
|
||||
|
||||
LOG_I(MAC, "[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", module_idP, frameP, pduP[0], pduP[1], pduP[2], pduP[3], pduP[4], pduP[5]);
|
||||
|
||||
if (mac->RA_active == 1) {
|
||||
if (ra->RA_active == 1) {
|
||||
nr_ra_succeeded(module_idP, frameP, slot);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac,
|
||||
uint8_t mcs,
|
||||
uint8_t freq_hopping){
|
||||
|
||||
RA_config_t *ra = &mac->ra;
|
||||
int f_alloc, mask, StartSymbolIndex, NrOfSymbols;
|
||||
uint8_t nb_dmrs_re_per_rb;
|
||||
uint16_t number_dmrs_symbols = 0;
|
||||
@@ -125,7 +126,7 @@ void nr_config_Msg3_pdu(NR_UE_MAC_INST_t *mac,
|
||||
// Frequency hopping
|
||||
pusch_config_pdu->frequency_hopping = freq_hopping;
|
||||
// TC-RNTI
|
||||
pusch_config_pdu->rnti = mac->t_crnti;
|
||||
pusch_config_pdu->rnti = ra->t_crnti;
|
||||
|
||||
// DM-RS configuration according to 6.2.2 UE DM-RS transmission procedure in 38.214
|
||||
pusch_config_pdu->dmrs_config_type = pusch_dmrs_type1;
|
||||
@@ -219,6 +220,7 @@ void nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
int cc_id = dl_info->cc_id;
|
||||
uint8_t gNB_id = dl_info->gNB_index;
|
||||
NR_UE_MAC_INST_t *ue_mac = get_mac_inst(mod_id);
|
||||
RA_config_t *ra = &ue_mac->ra;
|
||||
uint8_t n_subPDUs = 0; // number of RAR payloads
|
||||
uint8_t n_subheaders = 0; // number of MAC RAR subheaders
|
||||
uint8_t *dlsch_buffer = dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.pdu;
|
||||
@@ -235,14 +237,14 @@ void nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
LOG_D(MAC, "[UE %d][RAPROC] Got RAPID RAR subPDU\n", mod_id);
|
||||
} else {
|
||||
n_subPDUs++;
|
||||
ue_mac->RA_backoff_indicator = table_7_2_1[((NR_RA_HEADER_BI *)rarh)->BI];
|
||||
ue_mac->RA_BI_found = 1;
|
||||
LOG_D(MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d\n", mod_id, ue_mac->RA_backoff_indicator);
|
||||
ra->RA_backoff_indicator = table_7_2_1[((NR_RA_HEADER_BI *)rarh)->BI];
|
||||
ra->RA_BI_found = 1;
|
||||
LOG_D(MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d\n", mod_id, ra->RA_backoff_indicator);
|
||||
}
|
||||
if (rarh->RAPID == preamble_index) {
|
||||
LOG_I(MAC, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mod_id, frame, slot, rarh->RAPID);
|
||||
rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR));
|
||||
ue_mac->RA_RAPID_found = 1;
|
||||
ra->RA_RAPID_found = 1;
|
||||
break;
|
||||
}
|
||||
if (rarh->E == 0) {
|
||||
@@ -258,7 +260,7 @@ void nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
LOG_D(MAC, "[DEBUG_RAR] Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n", *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index);
|
||||
#endif
|
||||
|
||||
if (ue_mac->RA_RAPID_found) {
|
||||
if (ra->RA_RAPID_found) {
|
||||
|
||||
uint8_t freq_hopping, mcs, Msg3_t_alloc, Msg3_f_alloc;
|
||||
unsigned char tpc_command;
|
||||
@@ -267,7 +269,7 @@ void nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
#endif
|
||||
|
||||
// TC-RNTI
|
||||
ue_mac->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
|
||||
ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
|
||||
|
||||
// TA command
|
||||
ul_time_alignment->apply_ta = 1;
|
||||
@@ -282,28 +284,28 @@ void nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
tpc_command = (unsigned char) ((rar->UL_GRANT_4 >> 1) & 0x07);
|
||||
switch (tpc_command){
|
||||
case 0:
|
||||
ue_mac->Msg3_TPC = -6;
|
||||
ra->Msg3_TPC = -6;
|
||||
break;
|
||||
case 1:
|
||||
ue_mac->Msg3_TPC = -4;
|
||||
ra->Msg3_TPC = -4;
|
||||
break;
|
||||
case 2:
|
||||
ue_mac->Msg3_TPC = -2;
|
||||
ra->Msg3_TPC = -2;
|
||||
break;
|
||||
case 3:
|
||||
ue_mac->Msg3_TPC = 0;
|
||||
ra->Msg3_TPC = 0;
|
||||
break;
|
||||
case 4:
|
||||
ue_mac->Msg3_TPC = 2;
|
||||
ra->Msg3_TPC = 2;
|
||||
break;
|
||||
case 5:
|
||||
ue_mac->Msg3_TPC = 4;
|
||||
ra->Msg3_TPC = 4;
|
||||
break;
|
||||
case 6:
|
||||
ue_mac->Msg3_TPC = 6;
|
||||
ra->Msg3_TPC = 6;
|
||||
break;
|
||||
case 7:
|
||||
ue_mac->Msg3_TPC = 8;
|
||||
ra->Msg3_TPC = 8;
|
||||
break;
|
||||
}
|
||||
// MCS
|
||||
@@ -328,7 +330,7 @@ void nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
freq_hopping,
|
||||
tpc_command,
|
||||
csi_req,
|
||||
ue_mac->t_crnti);
|
||||
ra->t_crnti);
|
||||
#endif
|
||||
|
||||
// Config Msg3 PDU
|
||||
@@ -337,7 +339,7 @@ void nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
nr_ue_msg3_scheduler(ue_mac, frame, slot, Msg3_t_alloc);
|
||||
|
||||
} else {
|
||||
ue_mac->t_crnti = 0;
|
||||
ra->t_crnti = 0;
|
||||
ul_time_alignment->ta_command = (0xffff);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user