Commit 7db52420 authored by Melissa Elkadi's avatar Melissa Elkadi

Created new fill_rach function in the NR UE

Also calling the new L1_nsa_prach_procedures()
function after using the nr_ue_scheduler. Added
some error checking in the nr_ue_scheduler. Added
some error checking in the process_nsa_msg in both
the NR and LTE UE
parent 4fb87f9d
......@@ -145,6 +145,34 @@ void init_nrUE_standalone_thread(int ue_idx)
pthread_setname_np(phy_thread, "oai:nrue-stand-phy");
}
static void L1_nsa_prach_procedures(nfapi_nr_rach_indication_t *rach_ind, frame_t frame, int slot)
{
rach_ind->sfn = frame;
rach_ind->slot = slot;
rach_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION;
uint8_t pdu_index = 0;
rach_ind->pdu_list = CALLOC(1, sizeof(*rach_ind->pdu_list));
rach_ind->number_of_pdus = 1;
rach_ind->pdu_list[pdu_index].phy_cell_id = 0;
rach_ind->pdu_list[pdu_index].symbol_index = 0;
rach_ind->pdu_list[pdu_index].slot_index = slot;
rach_ind->pdu_list[pdu_index].freq_index = 1;
rach_ind->pdu_list[pdu_index].avg_rssi = 128;
rach_ind->pdu_list[pdu_index].avg_snr = 0xff; // invalid for now
rach_ind->pdu_list[pdu_index].num_preamble = 1;
const int num_p = rach_ind->pdu_list[pdu_index].num_preamble;
rach_ind->pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t));
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = 0;
rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0;
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff;
send_nsa_standalone_msg(rach_ind);
free(rach_ind->pdu_list);
//free(rach_ind->pdu_list[pdu_index].preamble_list); Melissa hack maybe
}
static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
{
NR_PRACH_RESOURCES_t prach_resources;
......@@ -169,34 +197,43 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
}
last_sfn_slot = sfn_slot;
frame_t frame_tx = NFAPI_SFNSLOT2SFN(sfn_slot);
int nr_slot_tx = NFAPI_SFNSLOT2SLOT(sfn_slot);
module_id_t mod_id = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
if (mac->scc == NULL) {
continue;
}
frame_t frame = NFAPI_SFNSLOT2SFN(sfn_slot);
int slot = NFAPI_SFNSLOT2SLOT(sfn_slot);
int slots_per_frame = 2048;
int slots_per_subframe = 2;
int slot_ahead = 6;
nr_uplink_indication_t ul_info;
ul_info.frame_rx = frame;
ul_info.slot_rx = slot;
ul_info.frame_tx = (slot > slots_per_frame - 1 - (slots_per_subframe*slot_ahead)) ? frame & 1023 : frame;
ul_info.slot_tx = slot + slots_per_subframe*slot_ahead % slots_per_frame;
if (is_nr_UL_slot(mac->scc, slot)) {
LOG_I(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", slot, __FUNCTION__);
nr_ue_ul_indication(&ul_info);
}
int CC_id = 0;
uint8_t gNB_id = 0;
uint8_t nr_prach = nr_ue_get_rach(&prach_resources, &prach_pdu, mod_id, CC_id, frame_tx, gNB_id, nr_slot_tx);
uint8_t nr_prach = nr_ue_get_rach(&prach_resources, &prach_pdu, mod_id, CC_id, frame, gNB_id, slot);
if (nr_prach == 1)
{
nfapi_nr_rach_indication_t rach_ind = {
.header = {
.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION,
},
.sfn = frame_tx,
.slot = nr_slot_tx,
.pdu_list = NULL,
.number_of_pdus = 0,
};
send_nsa_standalone_msg(&rach_ind);
nfapi_nr_rach_indication_t *ind = CALLOC(1, sizeof(*ind));
L1_nsa_prach_procedures(ind, frame, slot);
free(ind);
/* Fill rach indication here and send to proxy. Basically take pieces from
L1_nr_prach_procedures() and send it to the proxy. prach from ue->gNb->gnb sends rach->ue receives rach
The UE is basically filling the rach and proxy will receive and think that it came from the gNB. The
received rach in the proxy will trigger gNB to send back the RAR. RAR will go to proxy then goes to UE
and the UE will get the DCI for RAR and the payload. have to handle receving the RAR once we get it. */
LOG_I(NR_PHY, "Melissa! Calling nr_Msg1_transmitted!!!\n");
nr_Msg1_transmitted(mod_id, CC_id, frame_tx, gNB_id); //This is called when phy layer has sent the prach
LOG_I(NR_PHY, "Calling nr_Msg1_transmitted!!!\n");
nr_Msg1_transmitted(mod_id, CC_id, frame, gNB_id); //This is called when phy layer has sent the prach
}
else if (nr_prach == 2)
{
......
......@@ -1547,6 +1547,7 @@ void vnf_handle_nr_rach_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf
}
else
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Melissa %s: HANDLING RACH IND\n", __FUNCTION__);
nfapi_nr_rach_indication_t ind;
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0)
......
......@@ -529,10 +529,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
}
if (prach_resources->init_msg1) {
if (is_nr_UL_slot(mac->scc, nr_slot_tx)) {
LOG_D(MAC, "calling nr_ue_prach_scheduler\n");
nr_ue_prach_scheduler(mod_id, nr_slot_tx, frame, 0);
}
if (ra->RA_active == 0) {
/* RA not active - checking if RRC is ready to initiate the RA procedure */
......
......@@ -138,6 +138,8 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl
num_slots_per_tdd,
num_slots_ul,
index);
if(!mac->ul_config_request)
return NULL;
return &mac->ul_config_request[index];
}
......@@ -869,10 +871,12 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
RA_config_t *ra = &mac->ra;
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx);
if (!ul_config) {
LOG_E(NR_MAC, "mac->ul_config is null!\n");
}
// Schedule ULSCH only if the current frame and slot match those in ul_config_req
// AND if a UL grant (UL DCI or Msg3) has been received (as indicated by num_pdus)
if ((ul_info->slot_tx == ul_config->slot && ul_info->frame_tx == ul_config->sfn) && ul_config->number_pdus > 0){
else if (ul_info->slot_tx == ul_config->slot && ul_info->frame_tx == ul_config->sfn && ul_config->number_pdus > 0) {
LOG_D(MAC, "In %s:[%d.%d]: number of UL PDUs: %d with UL transmission in [%d.%d]\n", __FUNCTION__, frame_tx, slot_tx, ul_config->number_pdus, ul_config->sfn, ul_config->slot);
......
......@@ -56,7 +56,7 @@ extern uint16_t sl_ahead;
void handle_nr_rach(NR_UL_IND_t *UL_info) {
if (UL_info->rach_ind.number_of_pdus>0) {
LOG_I(MAC,"UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SLOT:%d/%d\n",UL_info->frame,UL_info->slot, UL_info->rach_ind.sfn,UL_info->rach_ind.slot);
LOG_I(MAC,"Melissa UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SLOT:%d/%d\n",UL_info->frame,UL_info->slot, UL_info->rach_ind.sfn,UL_info->rach_ind.slot);
int npdus = UL_info->rach_ind.number_of_pdus;
for(int i = 0; i < npdus; i++) {
UL_info->rach_ind.number_of_pdus--;
......
......@@ -304,7 +304,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){
ret = nr_ue_scheduler(NULL, ul_info);
if (is_nr_UL_slot(mac->scc, ul_info->slot_tx) && get_softmodem_params()->do_ra)
if (is_nr_UL_slot(mac->scc, ul_info->slot_tx))
nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->thread_id);
switch(ret){
......
......@@ -6571,6 +6571,11 @@ void init_connections_with_nr_ue(void)
void process_nr_nsa_msg(nsa_msg_t *msg, int msg_len)
{
if (msg_len < sizeof(msg->msg_type))
{
LOG_E(RRC, "Msg_len = %d\n", msg_len);
return;
}
LOG_D(RRC, "We are processing an NSA message %d \n", msg->msg_type);
Rrc_Msg_Type_t msg_type = msg->msg_type;
uint8_t *const msg_buffer = msg->msg_buffer;
......
......@@ -3016,6 +3016,11 @@ static void nsa_rrc_ue_process_ueCapabilityEnquiry(void)
void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len)
{
if (msg_len < sizeof(msg->msg_type))
{
LOG_E(RRC, "Msg_len = %d\n", msg_len);
return;
}
LOG_D(NR_RRC, "Processing an NSA message\n");
Rrc_Msg_Type_t msg_type = msg->msg_type;
uint8_t *const msg_buffer = msg->msg_buffer;
......
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