Commit cc154da5 authored by francescomani's avatar francescomani

Procedures for Random Access Response reception

parent 108fdae1
...@@ -283,8 +283,6 @@ typedef struct { ...@@ -283,8 +283,6 @@ typedef struct {
int ra_preamble_rx_target_power; int ra_preamble_rx_target_power;
/// RA Preamble Power Ramping Step in dB /// RA Preamble Power Ramping Step in dB
uint32_t preamble_power_ramping_step; uint32_t preamble_power_ramping_step;
uint8_t preamble_backoff;
uint8_t scaling_factor_bi;
/// UE configured maximum output power /// UE configured maximum output power
int Pc_max; int Pc_max;
} NR_PRACH_RESOURCES_t; } NR_PRACH_RESOURCES_t;
...@@ -310,8 +308,6 @@ typedef struct { ...@@ -310,8 +308,6 @@ typedef struct {
bool cfra; bool cfra;
/// RA type /// RA type
nr_ra_type_t ra_type; nr_ra_type_t ra_type;
/// RA rx frame offset: compensate RA rx offset introduced by OAI gNB.
uint8_t RA_offset;
/// MsgB SuccessRAR MAC subheader /// MsgB SuccessRAR MAC subheader
int8_t MsgB_R; int8_t MsgB_R;
int8_t MsgB_CH_ACESS_CPEXT; int8_t MsgB_CH_ACESS_CPEXT;
...@@ -333,18 +329,15 @@ typedef struct { ...@@ -333,18 +329,15 @@ typedef struct {
int restricted_set_config; int restricted_set_config;
// selected SSB for RACH (not the SSB-Index but the cumulative index, excluding not trasmitted SSBs) // selected SSB for RACH (not the SSB-Index but the cumulative index, excluding not trasmitted SSBs)
int ra_ssb; int ra_ssb;
/// Random-access window counter /// Random-access response window timer
int16_t RA_window_cnt; NR_timer_t response_window_timer;
/// Flag to monitor if matching RAPID was received in RAR bool start_response_window;
uint8_t RA_RAPID_found; /// Random-access backoff timer
/// Flag to monitor if BI was received in RAR NR_timer_t RA_backoff_timer;
uint8_t RA_BI_found; int RA_backoff_limit;
/// Random-access backoff counter uint8_t scaling_factor_bi;
int16_t RA_backoff_indicator;
/// Flag to indicate whether preambles Group A is selected /// Flag to indicate whether preambles Group A is selected
bool RA_GroupA; bool RA_GroupA;
/// RA backoff counter
int16_t RA_backoff_cnt;
/// RA max number of preamble transmissions /// RA max number of preamble transmissions
int preambleTransMax; int preambleTransMax;
/// Received TPC command (in dB) from RAR /// Received TPC command (in dB) from RAR
......
...@@ -212,7 +212,6 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, ...@@ -212,7 +212,6 @@ void set_harq_status(NR_UE_MAC_INST_t *mac,
bool get_downlink_ack(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCCH_sched_t *pucch); bool get_downlink_ack(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCCH_sched_t *pucch);
initial_pucch_resource_t get_initial_pucch_resource(const int idx); initial_pucch_resource_t get_initial_pucch_resource(const int idx);
void multiplex_pucch_resource(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, int num_res); void multiplex_pucch_resource(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, int num_res);
uint32_t get_backoff_indicator(int idx);
int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac,
int scs, int scs,
NR_PUCCH_Config_t *pucch_Config, NR_PUCCH_Config_t *pucch_Config,
...@@ -307,10 +306,6 @@ void nr_ra_failed(NR_UE_MAC_INST_t *mac, uint8_t CC_id, NR_PRACH_RESOURCES_t *pr ...@@ -307,10 +306,6 @@ void nr_ra_failed(NR_UE_MAC_INST_t *mac, uint8_t CC_id, NR_PRACH_RESOURCES_t *pr
void nr_ra_succeeded(NR_UE_MAC_INST_t *mac, const uint8_t gNB_index, const frame_t frame, const int slot); void nr_ra_succeeded(NR_UE_MAC_INST_t *mac, const uint8_t gNB_index, const frame_t frame, const int slot);
int16_t nr_get_RA_window_2Step(const NR_MsgA_ConfigCommon_r16_t *msgA_ConfigCommon_r16);
int16_t nr_get_RA_window_4Step(const NR_RACH_ConfigCommon_t *rach_ConfigCommon);
void nr_get_RA_window(NR_UE_MAC_INST_t *mac); void nr_get_RA_window(NR_UE_MAC_INST_t *mac);
/*@mac pointer to MAC instance /*@mac pointer to MAC instance
...@@ -336,6 +331,8 @@ NR_UE_L2_STATE_t nr_ue_get_sync_state(module_id_t mod_id); ...@@ -336,6 +331,8 @@ NR_UE_L2_STATE_t nr_ue_get_sync_state(module_id_t mod_id);
int16_t get_prach_tx_power(NR_UE_MAC_INST_t *mac); int16_t get_prach_tx_power(NR_UE_MAC_INST_t *mac);
void schedule_RA_after_SR_failure(NR_UE_MAC_INST_t *mac); void schedule_RA_after_SR_failure(NR_UE_MAC_INST_t *mac);
void nr_rar_not_successful(NR_UE_MAC_INST_t *mac);
void ra_resource_selection(NR_UE_MAC_INST_t *mac);
void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id); void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id);
void trigger_MAC_UE_RA(NR_UE_MAC_INST_t *mac, dci_pdu_rel15_t *pdcch_order); void trigger_MAC_UE_RA(NR_UE_MAC_INST_t *mac, dci_pdu_rel15_t *pdcch_order);
void nr_get_Msg3_MsgA_PUSCH_payload(NR_UE_MAC_INST_t *mac, uint8_t *buf, int TBS_max); void nr_get_Msg3_MsgA_PUSCH_payload(NR_UE_MAC_INST_t *mac, uint8_t *buf, int TBS_max);
......
...@@ -412,30 +412,6 @@ static const uint8_t table_7_3_2_3_3_4_twoCodeword[6][14] = { ...@@ -412,30 +412,6 @@ static const uint8_t table_7_3_2_3_3_4_twoCodeword[6][14] = {
{2,1,1,1,1,0,0,1,1,1,1,0,0,2}, {2,1,1,1,1,0,0,1,1,1,1,0,0,2},
}; };
// table 7.2-1 TS 38.321
static const uint32_t table_7_2_1[16] = {
5, // row index 0
10, // row index 1
20, // row index 2
30, // row index 3
40, // row index 4
60, // row index 5
80, // row index 6
120, // row index 7
160, // row index 8
240, // row index 9
320, // row index 10
480, // row index 11
960, // row index 12
1920, // row index 13
};
uint32_t get_backoff_indicator(int idx)
{
AssertFatal(idx < 16, "Backoff indicator index %d exeeding table size\n", idx);
return table_7_2_1[idx];
}
static inline uint16_t packBits(const uint8_t *toPack, const int nb) static inline uint16_t packBits(const uint8_t *toPack, const int nb)
{ {
int res = 0; int res = 0;
......
...@@ -563,6 +563,12 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl ...@@ -563,6 +563,12 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
if (mac->state == UE_PERFORMING_RA && mac->ra.ra_state >= nrRA_WAIT_RAR) { if (mac->state == UE_PERFORMING_RA && mac->ra.ra_state >= nrRA_WAIT_RAR) {
// if RA is ongoing use RA search space // if RA is ongoing use RA search space
if (is_ss_monitor_occasion(frame, slot, slots_per_frame, pdcch_config->ra_SS)) { if (is_ss_monitor_occasion(frame, slot, slots_per_frame, pdcch_config->ra_SS)) {
// The RA response window starts at the first symbol of the earliest CORESET
// the UE is configured to receive PDCCH for Type1-PDCCH CSS set
if (mac->ra.start_response_window) {
nr_timer_start(&mac->ra.response_window_timer);
mac->ra.start_response_window = false;
}
nr_rnti_type_t rnti_type = 0; nr_rnti_type_t rnti_type = 0;
if (mac->ra.ra_type == RA_4_STEP) { if (mac->ra.ra_type == RA_4_STEP) {
rnti_type = mac->ra.ra_state == nrRA_WAIT_RAR ? TYPE_RA_RNTI_ : TYPE_TC_RNTI_; rnti_type = mac->ra.ra_state == nrRA_WAIT_RAR ? TYPE_RA_RNTI_ : TYPE_TC_RNTI_;
......
...@@ -492,9 +492,7 @@ int get_pusch_tx_power_ue(NR_UE_MAC_INST_t *mac, ...@@ -492,9 +492,7 @@ int get_pusch_tx_power_ue(NR_UE_MAC_INST_t *mac,
if (current_UL_BWP->msg3_DeltaPreamble) { if (current_UL_BWP->msg3_DeltaPreamble) {
DELTA_PREAMBLE_MSG3 = *current_UL_BWP->msg3_DeltaPreamble; DELTA_PREAMBLE_MSG3 = *current_UL_BWP->msg3_DeltaPreamble;
} }
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = current_UL_BWP->rach_ConfigCommon; int P_O_PRE = mac->ra.prach_resources.ra_preamble_rx_target_power;
long preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower;
int P_O_PRE = preambleReceivedTargetPower;
P_O_NOMINAL_PUSCH = P_O_PRE + DELTA_PREAMBLE_MSG3; P_O_NOMINAL_PUSCH = P_O_PRE + DELTA_PREAMBLE_MSG3;
if (has_pusch_power_control_config && pusch_Config->pusch_PowerControl->msg3_Alpha) { if (has_pusch_power_control_config && pusch_Config->pusch_PowerControl->msg3_Alpha) {
......
...@@ -236,6 +236,15 @@ void update_mac_timers(NR_UE_MAC_INST_t *mac) ...@@ -236,6 +236,15 @@ void update_mac_timers(NR_UE_MAC_INST_t *mac)
phr_info->phr_reporting |= (1 << phr_cause_periodic_timer); phr_info->phr_reporting |= (1 << phr_cause_periodic_timer);
} }
} }
bool ra_window_expired = nr_timer_tick(&mac->ra.response_window_timer);
if (ra_window_expired) // consider the Random Access Response reception not successful
nr_rar_not_successful(mac);
bool ra_backoff_expired = nr_timer_tick(&mac->ra.RA_backoff_timer);
if (ra_backoff_expired) {
// perform the Random Access Resource selection procedure after the backoff time
mac->ra.ra_state = nrRA_GENERATE_PREAMBLE;
ra_resource_selection(mac);
}
} }
void remove_ul_config_last_item(fapi_nr_ul_config_request_pdu_t *pdu) void remove_ul_config_last_item(fapi_nr_ul_config_request_pdu_t *pdu)
...@@ -2064,7 +2073,6 @@ static bool is_prach_frame(frame_t frame, prach_occasion_info_t *prach_occasion_ ...@@ -2064,7 +2073,6 @@ static bool is_prach_frame(frame_t frame, prach_occasion_info_t *prach_occasion_
static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP) static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP)
{ {
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
ra->RA_offset = 2; // to compensate the rx frame offset at the gNB
if (ra->ra_state != nrRA_GENERATE_PREAMBLE) if (ra->ra_state != nrRA_GENERATE_PREAMBLE)
return; return;
...@@ -2076,7 +2084,6 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t ...@@ -2076,7 +2084,6 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t
if (is_ul_slot(slotP, &mac->frame_structure)) { if (is_ul_slot(slotP, &mac->frame_structure)) {
if (slotP == prach_occasion_info->slot) { if (slotP == prach_occasion_info->slot) {
nr_get_RA_window(mac);
fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frameP, slotP, FAPI_NR_UL_CONFIG_TYPE_PRACH); fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frameP, slotP, FAPI_NR_UL_CONFIG_TYPE_PRACH);
if (!pdu) { if (!pdu) {
LOG_E(NR_MAC, "Error in PRACH allocation\n"); LOG_E(NR_MAC, "Error in PRACH allocation\n");
...@@ -2156,6 +2163,7 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t ...@@ -2156,6 +2163,7 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t
if (ra->ra_type == RA_4_STEP) { if (ra->ra_type == RA_4_STEP) {
ra->ra_state = nrRA_WAIT_RAR; ra->ra_state = nrRA_WAIT_RAR;
ra->start_response_window = true;
} else if (ra->ra_type == RA_2_STEP) { } else if (ra->ra_type == RA_2_STEP) {
NR_MsgA_PUSCH_Resource_r16_t *msgA_PUSCH_Resource = NR_MsgA_PUSCH_Resource_r16_t *msgA_PUSCH_Resource =
mac->current_UL_BWP->msgA_ConfigCommon_r16->msgA_PUSCH_Config_r16->msgA_PUSCH_ResourceGroupA_r16; mac->current_UL_BWP->msgA_ConfigCommon_r16->msgA_PUSCH_Config_r16->msgA_PUSCH_ResourceGroupA_r16;
......
...@@ -192,8 +192,6 @@ TEST(pusch_power_control, pusch_power_control_msg3) ...@@ -192,8 +192,6 @@ TEST(pusch_power_control, pusch_power_control_msg3)
current_UL_BWP.BWPSize = 106; current_UL_BWP.BWPSize = 106;
current_UL_BWP.channel_bandwidth = 40; current_UL_BWP.channel_bandwidth = 40;
mac.current_UL_BWP = &current_UL_BWP; mac.current_UL_BWP = &current_UL_BWP;
NR_RACH_ConfigCommon_t nr_rach_ConfigCommon = {0};
current_UL_BWP.rach_ConfigCommon = &nr_rach_ConfigCommon;
mac.nr_band = 78; mac.nr_band = 78;
NR_PUSCH_Config_t pusch_Config = {0}; NR_PUSCH_Config_t pusch_Config = {0};
current_UL_BWP.pusch_Config = &pusch_Config; current_UL_BWP.pusch_Config = &pusch_Config;
...@@ -229,8 +227,8 @@ TEST(pusch_power_control, pusch_power_control_msg3) ...@@ -229,8 +227,8 @@ TEST(pusch_power_control, pusch_power_control_msg3)
num_rb, num_rb,
start_prb); start_prb);
long preambleReceivedTargetPower = -96; int preambleReceivedTargetPower = -96;
nr_rach_ConfigCommon.rach_ConfigGeneric.preambleReceivedTargetPower = preambleReceivedTargetPower; mac.ra.prach_resources.ra_preamble_rx_target_power = preambleReceivedTargetPower;
int power = get_pusch_tx_power_ue(&mac, int power = get_pusch_tx_power_ue(&mac,
num_rb, num_rb,
...@@ -247,7 +245,7 @@ TEST(pusch_power_control, pusch_power_control_msg3) ...@@ -247,7 +245,7 @@ TEST(pusch_power_control, pusch_power_control_msg3)
false); false);
EXPECT_EQ(power, -84); EXPECT_EQ(power, -84);
EXPECT_LT(power, P_CMAX); EXPECT_LT(power, P_CMAX);
nr_rach_ConfigCommon.rach_ConfigGeneric.preambleReceivedTargetPower -= 2; mac.ra.prach_resources.ra_preamble_rx_target_power -= 2;
int reduced_power = get_pusch_tx_power_ue(&mac, int reduced_power = get_pusch_tx_power_ue(&mac,
num_rb, num_rb,
...@@ -372,8 +370,6 @@ TEST(pusch_power_control, pusch_power_control_state_initialization) ...@@ -372,8 +370,6 @@ TEST(pusch_power_control, pusch_power_control_state_initialization)
current_UL_BWP.BWPSize = 106; current_UL_BWP.BWPSize = 106;
current_UL_BWP.channel_bandwidth = 40; current_UL_BWP.channel_bandwidth = 40;
mac.current_UL_BWP = &current_UL_BWP; mac.current_UL_BWP = &current_UL_BWP;
NR_RACH_ConfigCommon_t nr_rach_ConfigCommon = {0};
current_UL_BWP.rach_ConfigCommon = &nr_rach_ConfigCommon;
mac.nr_band = 78; mac.nr_band = 78;
NR_PUSCH_Config_t pusch_Config = {0}; NR_PUSCH_Config_t pusch_Config = {0};
current_UL_BWP.pusch_Config = &pusch_Config; current_UL_BWP.pusch_Config = &pusch_Config;
...@@ -393,8 +389,8 @@ TEST(pusch_power_control, pusch_power_control_state_initialization) ...@@ -393,8 +389,8 @@ TEST(pusch_power_control, pusch_power_control_state_initialization)
uint32_t sum_bits_in_codeblocks = 56; uint32_t sum_bits_in_codeblocks = 56;
int delta_pusch = 0; int delta_pusch = 0;
bool is_rar_tx_retx = true; bool is_rar_tx_retx = true;
long preambleReceivedTargetPower = -96; int preambleReceivedTargetPower = -96;
nr_rach_ConfigCommon.rach_ConfigGeneric.preambleReceivedTargetPower = preambleReceivedTargetPower; mac.ra.prach_resources.ra_preamble_rx_target_power = preambleReceivedTargetPower;
get_pusch_tx_power_ue(&mac, get_pusch_tx_power_ue(&mac,
num_rb, num_rb,
......
...@@ -101,6 +101,7 @@ TEST(test_init_ra, four_step_cbra) ...@@ -101,6 +101,7 @@ TEST(test_init_ra, four_step_cbra)
mac.p_Max = 23; mac.p_Max = 23;
mac.nr_band = 78; mac.nr_band = 78;
mac.frame_structure.frame_type = TDD; mac.frame_structure.frame_type = TDD;
mac.frame_structure.numb_slots_frame = 20;
mac.frequency_range = FR1; mac.frequency_range = FR1;
mac.first_sync_frame = 0; mac.first_sync_frame = 0;
int frame = 151; int frame = 151;
...@@ -135,6 +136,7 @@ TEST(test_init_ra, four_step_cfra) ...@@ -135,6 +136,7 @@ TEST(test_init_ra, four_step_cfra)
mac.p_Max = 23; mac.p_Max = 23;
mac.nr_band = 78; mac.nr_band = 78;
mac.frame_structure.frame_type = TDD; mac.frame_structure.frame_type = TDD;
mac.frame_structure.numb_slots_frame = 20;
mac.frequency_range = FR1; mac.frequency_range = FR1;
mac.first_sync_frame = 0; mac.first_sync_frame = 0;
int frame = 151; int frame = 151;
......
...@@ -390,8 +390,7 @@ static bool is_my_dci(NR_UE_MAC_INST_t *mac, nfapi_nr_dl_dci_pdu_t *received_pdu ...@@ -390,8 +390,7 @@ static bool is_my_dci(NR_UE_MAC_INST_t *mac, nfapi_nr_dl_dci_pdu_t *received_pdu
already. Only once the RA procedure succeeds is the CRNTI value updated already. Only once the RA procedure succeeds is the CRNTI value updated
to the TC_RNTI. */ to the TC_RNTI. */
if (get_softmodem_params()->nsa) { if (get_softmodem_params()->nsa) {
if (received_pdu->RNTI != mac->crnti && if (received_pdu->RNTI != mac->crnti && (received_pdu->RNTI != mac->ra.ra_rnti))
(received_pdu->RNTI != mac->ra.ra_rnti || mac->ra.RA_RAPID_found))
return false; return false;
} }
if (IS_SA_MODE(get_softmodem_params())) { if (IS_SA_MODE(get_softmodem_params())) {
...@@ -1292,11 +1291,11 @@ static uint32_t nr_ue_dl_processing(NR_UE_MAC_INST_t *mac, nr_downlink_indicatio ...@@ -1292,11 +1291,11 @@ static uint32_t nr_ue_dl_processing(NR_UE_MAC_INST_t *mac, nr_downlink_indicatio
ret_mask |= (handle_dlsch(mac, dl_info, i)) << FAPI_NR_RX_PDU_TYPE_DLSCH; ret_mask |= (handle_dlsch(mac, dl_info, i)) << FAPI_NR_RX_PDU_TYPE_DLSCH;
break; break;
case FAPI_NR_RX_PDU_TYPE_RAR: case FAPI_NR_RX_PDU_TYPE_RAR:
ret_mask |= (handle_dlsch(mac, dl_info, i)) << FAPI_NR_RX_PDU_TYPE_RAR;
if (!dl_info->rx_ind->rx_indication_body[i].pdsch_pdu.ack_nack) if (!dl_info->rx_ind->rx_indication_body[i].pdsch_pdu.ack_nack)
LOG_W(PHY, "Received a RAR-Msg2 but LDPC decode failed\n"); LOG_W(PHY, "Received a RAR-Msg2 but LDPC decode failed\n");
else else
LOG_I(PHY, "RAR-Msg2 decoded\n"); LOG_I(PHY, "RAR-Msg2 decoded\n");
ret_mask |= (handle_dlsch(mac, dl_info, i)) << FAPI_NR_RX_PDU_TYPE_RAR;
break; break;
case FAPI_NR_CSIRS_IND: case FAPI_NR_CSIRS_IND:
ret_mask |= (handle_csirs_measurements(mac, ret_mask |= (handle_csirs_measurements(mac,
......
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