Commit b32e3f73 authored by Melissa Elkadi's avatar Melissa Elkadi

This commit breaks in RACH procedure

However, we are not properly calling the
nr_ue_get_rach() function. The RA is being
properly initialized. In the nr_ue_get_rach()
the pRACH is not scheduled. Tried to add in
the scheduling of this, but it crashes here.
The other changes include revering the
nr_ue_get_rach() changes from previous commit.
Also, changed a few log levels and reverted
a previous change in the NR UE RRC layer that
was incorrect.
parent eecd5935
......@@ -147,7 +147,10 @@ void init_nrUE_standalone_thread(int ue_idx)
static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
{
sem_t sfn_slot_semaphore;
NR_PRACH_RESOURCES_t prach_resources;
memset(&prach_resources, 0, sizeof(prach_resources));
fapi_nr_ul_config_prach_pdu prach_pdu;
memset(&prach_pdu, 0, sizeof(prach_pdu));
int last_sfn_slot = -1;
while (!oai_exit)
{
......@@ -160,7 +163,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
int sfn_slot = current_sfn_slot;
if (sfn_slot == last_sfn_slot)
{
LOG_W(NR_MAC, "repeated sfn_sf = %d.%d\n",
LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n",
sfn_slot >> 6, sfn_slot & 0x3F);
continue;
}
......@@ -168,15 +171,11 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
frame_t frame_tx = NFAPI_SFNSLOT2SFN(sfn_slot);
int nr_slot_tx = NFAPI_SFNSLOT2SLOT(sfn_slot);
NR_PRACH_RESOURCES_t *prach_resources = NULL;
fapi_nr_ul_config_prach_pdu *prach_pdu = NULL;
module_id_t mod_id = 0;
int CC_id = 0;
uint8_t gNB_id = 0;
LOG_I(NR_PHY, "Melissa In %s:[%d.%d] getting PRACH resources\n", __FUNCTION__, frame_tx, nr_slot_tx);
uint8_t nr_prach = nr_ue_get_rach(prach_resources, prach_pdu, mod_id, CC_id, frame_tx, gNB_id, nr_slot_tx);
LOG_I(NR_PHY, "In %s: [UE %d] This is nr_prach: %d\n", __FUNCTION__, mod_id, nr_prach);
uint8_t nr_prach = nr_ue_get_rach(&prach_resources, &prach_pdu, mod_id, CC_id, frame_tx, gNB_id, nr_slot_tx);
if (nr_prach == 1)
{
......
......@@ -500,32 +500,15 @@ 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);
NR_CellGroupConfig_t *secondaryCellGroup = calloc(1, sizeof(*secondaryCellGroup));
//NR_ServingCellConfigCommon_t *scc = calloc(1, sizeof(*scc));
prepare_scc(mac->scc);
uint64_t ssb_bitmap;
fill_scc(mac->scc, &ssb_bitmap, 106, 106, 1, 1);
fix_scc(mac->scc, ssb_bitmap);
fill_default_secondaryCellGroup(mac->scc, secondaryCellGroup, 0, 1, 1, 0);
if (mac == NULL){
LOG_I(MAC, "Melissa mac is null\n");
}
if (&mac->ra == NULL){
LOG_I(MAC, "Melissa mac->ra is null\n");
}
if (mac->scc == NULL){
LOG_I(MAC, "Melissa scc is null\n");
return 0;
}
LOG_I(MAC, "Melissa got here %s: %d\n", __FUNCTION__, __LINE__);
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;
unsigned short post_padding;
NR_ServingCellConfigCommon_t *scc = mac->scc;
if (scc == NULL) {
return 0;
}
AssertFatal(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup != NULL, "In %s: FATAL! nr_rach_ConfigCommon is NULL...\n", __FUNCTION__);
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__);
......@@ -534,13 +517,8 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
uint8_t sdu_lcids[NB_RB_MAX] = {0};
uint16_t sdu_lengths[NB_RB_MAX] = {0};
int TBS_bytes = 848, header_length_total=0, num_sdus, offset, mac_ce_len;
int mac_ce_len = 0;
unsigned short post_padding = 1;
int header_length_total = 0;
uint16_t size_sdu = 0;
int TBS_bytes = 848;
uint8_t mac_sdus[MAX_NR_ULSCH_PAYLOAD_BYTES];
// Delay init RA procedure to allow the convergence of the IIR filter on PRACH noise measurements at gNB side
if (!prach_resources->init_msg1) {
if (((MAX_FRAME_NUMBER + frame - prach_resources->sync_frame) % MAX_FRAME_NUMBER) > 150){
......@@ -555,25 +533,45 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
if (ra->RA_active == 0) {
/* RA not active - checking if RRC is ready to initiate the RA procedure */
LOG_I(MAC, "RA not active. Checking for data to transmit from upper layers...\n");
for (int i = 0; i < TBS_bytes; i++){
mac_sdus[i] = (unsigned char) (lrand48()&0xff);
LOG_D(MAC, "RA not active. Checking for data to transmit from upper layers...\n");
payload = (uint8_t*) &mac->CCCH_pdu.payload;
mac_ce_len = 0;
num_sdus = 1;
post_padding = 1;
if (0){
// initialisation by RRC
// CCCH PDU
// size_sdu = (uint16_t) mac_rrc_data_req_ue(mod_id,
// CC_id,
// frame,
// CCCH,
// 1,
// mac_sdus,
// gNB_id,
// 0);
LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", mod_id, frame, size_sdu);
} else {
// fill ulsch_buffer with random data
for (int i = 0; i < TBS_bytes; i++){
mac_sdus[i] = (unsigned char) (lrand48()&0xff);
}
//Sending SDUs with size 1
//Initialize elements of sdu_lcids and sdu_lengths
sdu_lcids[0] = lcid;
sdu_lengths[0] = TBS_bytes - 3 - post_padding - mac_ce_len;
header_length_total += 2 + (sdu_lengths[0] >= 128);
size_sdu += sdu_lengths[0];
}
sdu_lcids[0] = UL_SCH_LCID_CCCH_MSG3;
sdu_lengths[0] = TBS_bytes - 3 - post_padding - mac_ce_len;
header_length_total += 2 + (sdu_lengths[0] >= 128);
size_sdu += sdu_lengths[0];
if (size_sdu > 0) {
LOG_I(MAC, "[UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", mod_id, frame, nr_slot_tx);
LOG_D(MAC, "[UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", mod_id, frame, nr_slot_tx);
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);
uint8_t *payload = (uint8_t*) &mac->CCCH_pdu.payload;
prach_resources->Msg3 = payload;
nr_get_RA_window(mac);
......@@ -581,9 +579,9 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
if (ra->generate_nr_prach == 1)
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
int offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer
offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer
(uint8_t *) payload, // UL MAC pdu pointer
1, // num sdus
num_sdus, // num sdus
sdu_lengths, // sdu length
sdu_lcids, // sdu lcid
0, // power headroom
......@@ -602,7 +600,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
}
} else if (ra->RA_window_cnt != -1) { // RACH is active
LOG_I(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);
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 (ra->RA_BI_found){
prach_resources->RA_PREAMBLE_BACKOFF = prach_resources->RA_SCALING_FACTOR_BI * ra->RA_backoff_indicator;
......@@ -628,16 +626,21 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
// Fill in preamble and PRACH resources
ra->RA_window_cnt--;
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
if (is_nr_UL_slot(mac->scc, nr_slot_tx)) {
nr_ue_scheduler(NULL, mac->ul_config_request);
nr_ue_prach_scheduler(mod_id, frame, nr_slot_tx, 0);
}
} else if (ra->RA_backoff_cnt > 0) {
LOG_I(MAC, "[UE %d][%d.%d]: RAR not received yet (RA backoff count %d) \n", mod_id, frame, nr_slot_tx, ra->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->RA_backoff_cnt--;
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);
}
}
}
}
......@@ -647,6 +650,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
}
return ra->generate_nr_prach;
}
void nr_get_RA_window(NR_UE_MAC_INST_t *mac){
......
......@@ -1650,6 +1650,17 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
//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];
#if 0 //Melissa
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP);
fill_ul_config(ul_config, frameP, slotP, FAPI_NR_UL_CONFIG_TYPE_PRACH);
if (!ul_config) {
LOG_W(MAC, "In %s: ul_config request is NULL. "
"Probably due to unexpected UL DCI in frame.slot %d.%d. Ignoring DCI!\n",
__FUNCTION__, frameP, slotP);
return;
}
#endif
fapi_nr_ul_config_prach_pdu *prach_config_pdu;
fapi_nr_config_request_t *cfg = &mac->phy_config.config_req;
fapi_nr_prach_config_t *prach_config = &cfg->prach_config;
......@@ -1682,11 +1693,12 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
format = prach_occasion_info_p->format;
format0 = format & 0xff; // single PRACH format
format1 = (format >> 8) & 0xff; // dual PRACH format
#if 1 //Melissa
ul_config->sfn = frameP;
ul_config->slot = slotP;
ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PRACH;
#endif
prach_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].prach_config_pdu;
memset(prach_config_pdu, 0, sizeof(fapi_nr_ul_config_prach_pdu));
ul_config->number_pdus += 1;
......
......@@ -226,13 +226,13 @@ void *nrue_standalone_pnf_task(void *context)
save_nr_measurement_info(&dl_tti_request);
break;
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message. \n");
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message. \n");
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message. \n");
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message. \n");
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message. \n");
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message. \n");
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &dl_tti_request,
sizeof(dl_tti_request), NULL) < 0)
{
......
......@@ -287,9 +287,9 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR
nr_rrc_ue_process_scg_config(module_id,cellGroupConfig);
}else{
// after first time, update it and free the memory after.
SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)NR_UE_rrc_inst[module_id].cell_group_config, 0);
NR_UE_rrc_inst[module_id].cell_group_config = cellGroupConfig;
nr_rrc_ue_process_scg_config(module_id,cellGroupConfig);
SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)NR_UE_rrc_inst[module_id].cell_group_config, 0);
}
}
if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->measConfig != NULL){
......@@ -341,6 +341,8 @@ int8_t nr_rrc_ue_process_scg_config(const module_id_t module_id, NR_CellGroupCon
}else{
// maintain list
if(cell_group_config->spCellConfig != NULL){
nr_rrc_mac_config_req_ue(0, 0, 0, NULL, cell_group_config);
LOG_I(NR_RRC, "Melissa, we filled scc now \n");
if(cell_group_config->spCellConfig->spCellConfigDedicated != NULL){
// process element of list to be add by RRC message
if(cell_group_config->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList != NULL){
......
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