Commit 2c5f0af0 authored by Melissa Elkadi's avatar Melissa Elkadi

CFRA procedure is working! But gNB still crashes

How? Well, we had to properly allocate the
ul_config_req. We also had to update the
ue_get_rach function. There were several
places where the functionality would check
for a particular mode (ra, sa, phy_test, etc).
In some of these places we had to add NSA mode.
In the VNF, they start the scheduler after 3 sec,
this is sort of a hack, might want to revisit.
This commit also includes removal of printfs.
parent 933dcd28
......@@ -248,7 +248,10 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
}
sfn_slot_p = get_queue(&nr_sfn_slot_queue);
if (sfn_slot_p == NULL)
{
LOG_D(MAC, "get_queue(&nr_sfn_slot_queue) == NULL!\n");
continue;
}
sfn_slot = *sfn_slot_p;
if (sfn_slot == last_sfn_slot)
......@@ -263,6 +266,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
if (mac->scc == NULL)
{
LOG_D(MAC, "mac->scc == NULL!\n");
continue;
}
......@@ -320,7 +324,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
else if (nr_prach == 2)
{
LOG_I(NR_PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, mod_id);
nr_DRB_preconfiguration(mac->crnti);
//nr_DRB_preconfiguration(mac->crnti);
}
else if(nr_prach == 3)
{
......
This diff is collapsed.
......@@ -300,18 +300,21 @@ static uint8_t pack_dl_tti_pdsch_pdu_rel15_value(void *tlv, uint8_t **ppWritePac
static uint8_t pack_dl_tti_ssb_pdu_rel15_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) {
nfapi_nr_dl_tti_ssb_pdu_rel15_t *value = (nfapi_nr_dl_tti_ssb_pdu_rel15_t *)tlv;
return(
push16(value->PhysCellId, ppWritePackedMsg, end) &&
push8(value->BetaPss, ppWritePackedMsg, end) &&
push8(value->SsbBlockIndex, ppWritePackedMsg, end) &&
push8(value->SsbSubcarrierOffset, ppWritePackedMsg, end) &&
push16(value->ssbOffsetPointA, ppWritePackedMsg, end) &&
push8(value->bchPayloadFlag, ppWritePackedMsg, end) &&
push32(value->bchPayload, ppWritePackedMsg, end) &&
push8(value->ssbRsrp, ppWritePackedMsg, end)
// TODO: pack precoding_and_beamforming too
);
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "Packing ssb. \n");
nfapi_nr_dl_tti_ssb_pdu_rel15_t* value = (nfapi_nr_dl_tti_ssb_pdu_rel15_t*)tlv;
return(
push16(value->PhysCellId, ppWritePackedMsg, end) &&
push8(value->BetaPss, ppWritePackedMsg, end) &&
push8(value->SsbBlockIndex, ppWritePackedMsg, end) &&
push8(value->SsbSubcarrierOffset, ppWritePackedMsg, end) &&
push16(value->ssbOffsetPointA, ppWritePackedMsg, end) &&
push8(value->bchPayloadFlag, ppWritePackedMsg, end) &&
push32(value->bchPayload, ppWritePackedMsg, end) &&
push8(value->ssbRsrp, ppWritePackedMsg, end)
// TODO: pack precoding_and_beamforming too
);
}
......@@ -779,38 +782,41 @@ static uint8_t pack_dl_config_request_body_value(void *tlv, uint8_t **ppWritePac
}
static uint8_t pack_dl_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
nfapi_nr_dl_tti_request_t *pNfapiMsg = (nfapi_nr_dl_tti_request_t *)msg;
if (!(push16(pNfapiMsg->SFN, ppWritePackedMsg, end) &&
push16(pNfapiMsg->Slot, ppWritePackedMsg, end) &&
push8(pNfapiMsg->dl_tti_request_body.nGroup, ppWritePackedMsg, end) &&
push8(pNfapiMsg->dl_tti_request_body.nPDUs, ppWritePackedMsg, end) &&
pusharray8(pNfapiMsg->dl_tti_request_body.nUe,256,pNfapiMsg->dl_tti_request_body.nGroup, ppWritePackedMsg, end)
//pusharray8(pNfapiMsg->PduIdx[0] ,256,256, ppWritePackedMsg, end)
))
return 0;
int arr[12];
for(int i=0; i<pNfapiMsg->dl_tti_request_body.nGroup; i++) {
for(int j=0; j<pNfapiMsg->dl_tti_request_body.nUe[i]; j++) {
arr[j] = pNfapiMsg->dl_tti_request_body.PduIdx[i][j];
}
static uint8_t pack_dl_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config)
{
nfapi_nr_dl_tti_request_t *pNfapiMsg = (nfapi_nr_dl_tti_request_t*)msg;
if (!(push16(pNfapiMsg->SFN , ppWritePackedMsg, end) &&
push16(pNfapiMsg->Slot , ppWritePackedMsg, end) &&
push8(pNfapiMsg->dl_tti_request_body.nGroup , ppWritePackedMsg, end) &&
push8(pNfapiMsg->dl_tti_request_body.nPDUs , ppWritePackedMsg, end) &&
pusharray8(pNfapiMsg->dl_tti_request_body.nUe, 256, pNfapiMsg->dl_tti_request_body.nGroup, ppWritePackedMsg, end)
//pusharray8(pNfapiMsg->PduIdx[0] ,256,256, ppWritePackedMsg, end)
))
return 0;
if(!(pusharrays32(arr,12,pNfapiMsg->dl_tti_request_body.nUe[i],ppWritePackedMsg, end)))
return 0;
}
int arr[12];
for(int i=0;i<pNfapiMsg->dl_tti_request_body.nGroup;i++)
{
for(int j=0;j<pNfapiMsg->dl_tti_request_body.nUe[i];j++)
{
arr[j] = pNfapiMsg->dl_tti_request_body.PduIdx[i][j];
}
if(!(pusharrays32(arr, 12, pNfapiMsg->dl_tti_request_body.nUe[i], ppWritePackedMsg, end)))
return 0;
}
for(int i=0; i<pNfapiMsg->dl_tti_request_body.nPDUs; i++) {
if(!pack_dl_tti_request_body_value(&pNfapiMsg->dl_tti_request_body.dl_tti_pdu_list[i],ppWritePackedMsg,end))
return 0;
}
for(int i=0;i<pNfapiMsg->dl_tti_request_body.nPDUs;i++)
{
if(!pack_dl_tti_request_body_value(&pNfapiMsg->dl_tti_request_body.dl_tti_pdu_list[i],ppWritePackedMsg,end))
return 0;
}
return 1;
return 1;
}
static uint8_t pack_dl_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
nfapi_dl_config_request_t *pNfapiMsg = (nfapi_dl_config_request_t *)msg;
//return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) &&
......
......@@ -173,7 +173,7 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config)
clock_gettime(CLOCK_MONOTONIC, &curr_time);
setup_time = curr_time.tv_sec - ref_time.tv_sec;
if(setup_time > 10 && prev_slot != gNB->UL_INFO.slot){ //Give the VNF sufficient time to setup before starting scheduling
if(setup_time > 3 && prev_slot != gNB->UL_INFO.slot){ //Give the VNF sufficient time to setup before starting scheduling
//Call the scheduler
pthread_mutex_lock(&gNB->UL_INFO_mutex);
......
......@@ -739,13 +739,18 @@ int nr_rrc_mac_config_req_ue(
LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n");
mac->cg = cell_group_config;
mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0;
if(get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra==1) {
if(get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra==1 || get_softmodem_params()->nsa) {
config_control_ue(mac);
if (cell_group_config->spCellConfig->reconfigurationWithSync) {
if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) {
ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
}
mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
int num_slots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
if (mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) {
num_slots++;
}
mac->ul_config_request = calloc(num_slots, sizeof(*mac->ul_config_request));
config_common_ue(mac,module_id,cc_idP);
mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity;
LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti);
......
......@@ -518,10 +518,14 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
uint16_t sdu_lengths[NB_RB_MAX] = {0};
int num_sdus = 0;
int offset = 0;
int TBS_bytes = 848;
int header_length_total=0;
int mac_ce_len;
// 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 ( (mac->common_configuration_complete>0 || get_softmodem_params()->do_ra==1) && ((MAX_FRAME_NUMBER+frame-prach_resources->sync_frame)%MAX_FRAME_NUMBER)>150 ){
if ( (mac->common_configuration_complete>0 || get_softmodem_params()->do_ra==1 || get_softmodem_params()->nsa) &&
((MAX_FRAME_NUMBER + frame - prach_resources->sync_frame) % MAX_FRAME_NUMBER) > 150){
prach_resources->init_msg1 = 1;
} else {
LOG_D(NR_MAC,"PRACH Condition not met: frame %d, prach_resources->sync_frame %d\n",frame,prach_resources->sync_frame);
......@@ -539,9 +543,9 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
LOG_D(NR_MAC, "RA not active. Checking for data to transmit from upper layers...\n");
uint8_t TBS_max = 8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT);
int TBS_max = 848; //8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT);
payload = (uint8_t*) mac->CCCH_pdu.payload;
mac_ce_len = 0;
num_sdus = 1;
post_padding = 1;
sdu_lcids[0] = lcid;
......@@ -551,14 +555,23 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
// TODO: To be removed after RA procedures fully implemented
if(get_softmodem_params()->do_ra) {
nr_rrc_ue_generate_RRCSetupRequest(mod_id,gNB_id);
size_sdu = (uint16_t) nr_mac_rrc_data_req_ue(mod_id, CC_id, gNB_id, frame, CCCH, mac_sdus);
// CCCH PDU
sdu_lengths[0] = size_sdu;
LOG_D(NR_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];
}
// CCCH PDU
size_sdu = (uint16_t) nr_mac_rrc_data_req_ue(mod_id, CC_id, gNB_id, frame, CCCH, mac_sdus);
sdu_lengths[0] = size_sdu;
LOG_D(NR_MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", mod_id, frame, size_sdu);
if (size_sdu > 0) {
......@@ -592,7 +605,8 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
post_padding,
0);
AssertFatal(TBS_max > offset, "Frequency resources are not enough for Msg3!\n");
AssertFatal(TBS_max > offset, "Frequency resources are not enough for Msg3! TBS max = %d, offset = %d\n",
TBS_max, offset);
// Padding: fill remainder with 0
if (post_padding > 0){
......@@ -600,19 +614,20 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
payload[offset + j] = 0;
}
}
if(get_softmodem_params()->do_ra) {
LOG_D(MAC,"size_sdu = %i\n", size_sdu);
LOG_D(MAC,"offset = %i\n", offset);
for(int k = 0; k < TBS_max; k++) {
LOG_D(MAC,"(%i): %i\n", k, prach_resources->Msg3[k]);
}
LOG_D(MAC,"size_sdu = %i\n", size_sdu);
LOG_D(MAC,"offset = %i\n", offset);
for(int k = 0; k < TBS_max; k++) {
LOG_D(MAC,"(%i): %i\n", k, prach_resources->Msg3[k]);
// Msg3 was initialized with TBS_max bytes because the RA_Msg3_size will only be known after
// receiving Msg2 (which contains the Msg3 resource reserve).
// Msg3 will be transmitted with RA_Msg3_size bytes, removing unnecessary 0s.
mac->ulsch_pdu.Pdu_size = TBS_max;
memcpy(mac->ulsch_pdu.payload, prach_resources->Msg3, TBS_max);
}
// Msg3 was initialized with TBS_max bytes because the RA_Msg3_size will only be known after
// receiving Msg2 (which contains the Msg3 resource reserve).
// Msg3 will be transmitted with RA_Msg3_size bytes, removing unnecessary 0s.
mac->ulsch_pdu.Pdu_size = TBS_max;
memcpy(mac->ulsch_pdu.payload, prach_resources->Msg3, TBS_max);
} 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, ra->RA_window_cnt, ra->RA_backoff_cnt);
......
......@@ -769,7 +769,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
/* dmrs symbol positions*/
dlsch_config_pdu_1_0->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config,
mac->mib->dmrs_TypeA_Position,
mac->scc->dmrs_TypeA_Position,
dlsch_config_pdu_1_0->number_symbols,
dlsch_config_pdu_1_0->start_symbol,
mappingtype);
......
......@@ -1041,8 +1041,8 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator;
mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0;
} else {
if ( (mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator ||
if (!SOFTMODEM_NOS1_BIT && (mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] !=
ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator ||
mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id]==1)){
// Getting IP traffic to be transmitted
......@@ -1988,7 +1988,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
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; Melissa Elkadi come back here!
ul_config->number_pdus += 1; //Melissa Elkadi come back here!
fill_ul_config(ul_config, frameP, slotP, FAPI_NR_UL_CONFIG_TYPE_PRACH);
LOG_D(PHY, "In %s: (%p) %d UL PDUs:\n", __FUNCTION__, ul_config, ul_config->number_pdus);
......
......@@ -751,7 +751,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
if(ra->cfra) {
LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti);
LOG_A(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti);
nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti);
nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra);
UE_info->active[UE_id] = true;
......
......@@ -305,13 +305,6 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) {
module_id,CC_id, UL_info->rach_ind.number_of_pdus,
UL_info->rx_ind.number_of_pdus, UL_info->crc_ind.number_crcs);
handle_nr_rach(UL_info);
handle_nr_uci(UL_info);
// clear UL DCI prior to handling ULSCH
mac->UL_dci_req[CC_id].numPdus = 0;
handle_nr_ulsch(UL_info);
if (NFAPI_MODE != NFAPI_MODE_PNF) {
if (ifi->CC_mask==0) {
......
......@@ -769,7 +769,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){
module_id_t module_id = ul_info->module_id;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
if (ul_info->ue_sched_mode == ONLY_PUSCH) {
if (ul_info->ue_sched_mode == ONLY_PUSCH || mac->ra.ra_state == RA_SUCCEEDED) {
ret = nr_ue_scheduler(NULL, ul_info);
return 0;
}
......
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