Commit 53d0fc05 authored by rmagueta's avatar rmagueta

Add more RA_state_t to accommodate all the output values from nr_ue_get_rach

parent e2627f80
...@@ -2162,7 +2162,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ...@@ -2162,7 +2162,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t
} }
if (nr_prach == 1) { if (nr_prach == GENERATE_PREAMBLE) {
if (ue->mac_enabled == 1) { if (ue->mac_enabled == 1) {
int16_t pathloss = get_nr_PL(mod_id, ue->CC_id, gNB_id); int16_t pathloss = get_nr_PL(mod_id, ue->CC_id, gNB_id);
...@@ -2208,14 +2208,14 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ...@@ -2208,14 +2208,14 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t
if (ue->mac_enabled == 1) if (ue->mac_enabled == 1)
nr_Msg1_transmitted(mod_id, ue->CC_id, frame_tx, gNB_id); nr_Msg1_transmitted(mod_id, ue->CC_id, frame_tx, gNB_id);
} else if (nr_prach == 2) { } else if (nr_prach == WAIT_CONTENTION_RESOLUTION) {
LOG_W(PHY, "In %s: [UE %d] RA waiting contention resolution\n", __FUNCTION__, mod_id); LOG_D(PHY, "In %s: [UE %d] RA waiting contention resolution\n", __FUNCTION__, mod_id);
ue->UE_mode[gNB_id] = RA_WAIT_CR; ue->UE_mode[gNB_id] = RA_WAIT_CR;
} else if (nr_prach == 3) { } else if (nr_prach == RA_SUCCEEDED) {
LOG_W(PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, mod_id); LOG_D(PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, mod_id);
ue->UE_mode[gNB_id] = PUSCH; ue->UE_mode[gNB_id] = PUSCH;
} else if(nr_prach == 4){ } else if(nr_prach == RA_FAILED){
LOG_W(PHY, "In %s: [UE %d] RA failed, setting UE mode to PRACH\n", __FUNCTION__, mod_id); LOG_D(PHY, "In %s: [UE %d] RA failed, setting UE mode to PRACH\n", __FUNCTION__, mod_id);
ue->UE_mode[gNB_id] = PRACH; ue->UE_mode[gNB_id] = PRACH;
} }
......
...@@ -234,9 +234,12 @@ typedef struct { ...@@ -234,9 +234,12 @@ typedef struct {
typedef enum { typedef enum {
RA_UE_IDLE = 0, RA_UE_IDLE = 0,
WAIT_RAR = 1, GENERATE_IDLE = 0,
WAIT_CONTENTION_RESOLUTION = 2, GENERATE_PREAMBLE = 1,
RA_SUCCEEDED = 3 WAIT_RAR = 2,
WAIT_CONTENTION_RESOLUTION = 3,
RA_SUCCEEDED = 4,
RA_FAILED = 5
} RA_state_t; } RA_state_t;
typedef struct { typedef struct {
...@@ -260,7 +263,7 @@ typedef struct { ...@@ -260,7 +263,7 @@ typedef struct {
/// Random-access preamble index /// Random-access preamble index
int ra_PreambleIndex; int ra_PreambleIndex;
/// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot /// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot
uint8_t generate_nr_prach; RA_state_t generate_nr_prach;
/// Random-access window counter /// Random-access window counter
int16_t RA_window_cnt; int16_t RA_window_cnt;
......
...@@ -582,7 +582,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -582,7 +582,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
nr_get_RA_window(mac); nr_get_RA_window(mac);
// Fill in preamble and PRACH resources // Fill in preamble and PRACH resources
if (ra->generate_nr_prach == 1) if (ra->generate_nr_prach == GENERATE_PREAMBLE)
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated); 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 offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer
...@@ -635,7 +635,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -635,7 +635,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
// Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213) // Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213)
nr_ra_succeeded(mod_id, frame, nr_slot_tx); nr_ra_succeeded(mod_id, frame, nr_slot_tx);
} else { } else {
ra->generate_nr_prach = 2; ra->generate_nr_prach = GENERATE_IDLE;
} }
} else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) { } else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) {
...@@ -658,21 +658,23 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -658,21 +658,23 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
ra->RA_backoff_cnt--; ra->RA_backoff_cnt--;
if ((ra->RA_backoff_cnt > 0 && ra->generate_nr_prach == 1) || ra->RA_backoff_cnt == 0){ if ((ra->RA_backoff_cnt > 0 && ra->generate_nr_prach == GENERATE_PREAMBLE) || ra->RA_backoff_cnt == 0){
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated); nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
} }
} }
} }
} else {
return 3;
} }
if (ra->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); nr_ue_contention_resolution(mod_id, CC_id, frame, nr_slot_tx, prach_resources);
} }
return ra->generate_nr_prach; if(ra->generate_nr_prach != GENERATE_IDLE) {
return ra->generate_nr_prach;
} else {
return ra->ra_state;
}
} }
...@@ -781,7 +783,7 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){ ...@@ -781,7 +783,7 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){
LOG_D(MAC, "In %s: [UE %d] clearing RA_active flag...\n", __FUNCTION__, mod_id); LOG_D(MAC, "In %s: [UE %d] clearing RA_active flag...\n", __FUNCTION__, mod_id);
ra->RA_active = 0; ra->RA_active = 0;
ra->generate_nr_prach = 3; ra->generate_nr_prach = GENERATE_IDLE;
ra->ra_state = RA_SUCCEEDED; ra->ra_state = RA_SUCCEEDED;
} }
...@@ -797,7 +799,7 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res ...@@ -797,7 +799,7 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
ra->first_Msg3 = 0; ra->first_Msg3 = 0;
ra->generate_nr_prach = 4; ra->generate_nr_prach = RA_FAILED;
ra->ra_state = RA_UE_IDLE; ra->ra_state = RA_UE_IDLE;
prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER++; prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER++;
......
...@@ -1669,7 +1669,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ...@@ -1669,7 +1669,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric;
ra->RA_offset = 2; // to compensate the rx frame offset at the gNB ra->RA_offset = 2; // to compensate the rx frame offset at the gNB
ra->generate_nr_prach = 0; // Reset flag for PRACH generation ra->generate_nr_prach = GENERATE_IDLE; // Reset flag for PRACH generation
if (is_nr_UL_slot(scc, slotP)) { if (is_nr_UL_slot(scc, slotP)) {
...@@ -1686,7 +1686,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ...@@ -1686,7 +1686,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
if (is_nr_prach_slot && ra->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"); AssertFatal(NULL != prach_occasion_info_p,"PRACH Occasion Info not returned in a valid NR Prach Slot\n");
ra->generate_nr_prach = 1; ra->generate_nr_prach = GENERATE_PREAMBLE;
format = prach_occasion_info_p->format; format = prach_occasion_info_p->format;
format0 = format & 0xff; // single PRACH format format0 = format & 0xff; // single PRACH format
......
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