Commit 746d0746 authored by Melissa Elkadi's avatar Melissa Elkadi

Queuing all nFAPI messages and handling after slot ind

This commit changes the stub functionality entirely.
We are now queueing any received NR nFAPI message
and handling it only after we recevie a slot ind
that corresponds with the nFAPI message's sfn/slot
value. When doing this, an existing issue has been
brought to light. The gNB and NR UE are not in sync
when it comes to their slot indications. Generally,
the NR UE seems to be ahead of the gNB by around 6-7
slots. This commit has a hack... when we receive a
slot indication at the moment, we decrament it by 6
to try to keep the NRUE from being ahead of the gNB.
This will be fixed shortly... This was a temporary
fix..
parent 98bc149e
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "LAYER2/nr_pdcp/nr_pdcp_entity.h" #include "LAYER2/nr_pdcp/nr_pdcp_entity.h"
//#include "executables/softmodem-common.h" //#include "executables/softmodem-common.h"
#include "SCHED_NR_UE/pucch_uci_ue_nr.h" #include "SCHED_NR_UE/pucch_uci_ue_nr.h"
#include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h"
/* /*
* NR SLOT PROCESSING SEQUENCE * NR SLOT PROCESSING SEQUENCE
...@@ -224,6 +225,30 @@ static bool sfn_slot_matcher(void *wanted, void *candidate) ...@@ -224,6 +225,30 @@ static bool sfn_slot_matcher(void *wanted, void *candidate)
return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot; return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->sfn && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->slot;
} }
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
{
nfapi_nr_dl_tti_request_t *ind = candidate;
return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot;
}
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
{
nfapi_nr_tx_data_request_t *ind = candidate;
return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot;
}
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
{
nfapi_nr_ul_dci_request_t *ind = candidate;
return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot;
}
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
{
nfapi_nr_ul_tti_request_t *ind = candidate;
return NFAPI_SFNSLOT2SFN(sfn_sf) == ind->SFN && NFAPI_SFNSLOT2SLOT(sfn_sf) == ind->Slot;
}
default: default:
LOG_E(NR_MAC, "sfn_slot_match bad ID: %d\n", msg->message_id); LOG_E(NR_MAC, "sfn_slot_match bad ID: %d\n", msg->message_id);
...@@ -232,6 +257,130 @@ static bool sfn_slot_matcher(void *wanted, void *candidate) ...@@ -232,6 +257,130 @@ static bool sfn_slot_matcher(void *wanted, void *candidate)
return false; return false;
} }
static void process_queued_nr_nfapi_msgs(int sfn_slot)
{
nfapi_nr_rach_indication_t *rach_ind = unqueue_matching(&nr_rach_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
nfapi_nr_rx_data_indication_t *rx_ind = unqueue_matching(&nr_rx_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
nfapi_nr_crc_indication_t *crc_ind = unqueue_matching(&nr_crc_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
nfapi_nr_dl_tti_request_t *dl_tti_request = unqueue_matching(&nr_dl_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
nfapi_nr_tx_data_request_t *tx_data_request = unqueue_matching(&nr_tx_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
nfapi_nr_ul_dci_request_t *ul_dci_request = unqueue_matching(&nr_ul_dci_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
nfapi_nr_ul_tti_request_t *ul_tti_request = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
if (rach_ind && rach_ind->number_of_pdus > 0)
{
NR_UL_IND_t UL_INFO = {
.rach_ind = *rach_ind,
};
send_nsa_standalone_msg(&UL_INFO, rach_ind->header.message_id);
for (int i = 0; i < rach_ind->number_of_pdus; i++)
{
free(rach_ind->pdu_list[i].preamble_list);
}
free(rach_ind->pdu_list);
free(rach_ind);
nr_Msg1_transmitted(0, 0, NFAPI_SFNSLOT2SFN(sfn_slot), 0);
}
if (crc_ind && crc_ind->number_crcs > 0)
{
NR_UL_IND_t UL_INFO = {
.crc_ind = *crc_ind,
};
send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id);
free(crc_ind->crc_list);
free(crc_ind);
}
if (rx_ind && rx_ind->number_of_pdus > 0)
{
NR_UL_IND_t UL_INFO = {
.rx_ind = *rx_ind,
};
send_nsa_standalone_msg(&UL_INFO, rx_ind->header.message_id);
free(rx_ind->pdu_list);
free(rx_ind);
}
if (dl_tti_request || tx_data_request)
{
if (!tx_data_request)
{
save_nr_measurement_info(dl_tti_request);
LOG_E(NR_MAC, "[%d %d] No corresponding tx_data_request for given dl_tti_request\n",
NFAPI_SFNSLOT2SFN(sfn_slot), NFAPI_SFNSLOT2SLOT(sfn_slot));
if (!put_queue(&nr_dl_tti_req_queue, dl_tti_request))
{
LOG_E(NR_PHY, "put_queue failed for dl_tti_request.\n");
free(dl_tti_request);
dl_tti_request = NULL;
}
}
else if (!dl_tti_request)
{
LOG_E(NR_MAC, "[%d %d] No corresponding dl_tti_request for given tx_data_request \n",
NFAPI_SFNSLOT2SFN(sfn_slot), NFAPI_SFNSLOT2SLOT(sfn_slot));
if (!put_queue(&nr_tx_req_queue, tx_data_request))
{
LOG_E(NR_PHY, "put_queue failed for tx_request.\n");
free(tx_data_request);
tx_data_request = NULL;
}
}
else if (dl_tti_request->dl_tti_request_body.nPDUs > 0 && tx_data_request->Number_of_PDUs > 0)
{
save_nr_measurement_info(dl_tti_request);
check_and_process_dci(dl_tti_request, tx_data_request, NULL, NULL);
}
}
if (ul_dci_request && ul_dci_request->numPdus > 0)
{
check_and_process_dci(NULL, NULL, ul_dci_request, NULL);
//free(ul_dci_request);
//ul_dci_request = NULL;
}
if (ul_tti_request && ul_tti_request->n_pdus > 0)
{
check_and_process_dci(NULL, NULL, NULL, ul_tti_request);
//free(ul_tti_request);
//ul_tti_request = NULL;
}
}
static void check_nr_prach(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info, NR_PRACH_RESOURCES_t *prach_resources)
{
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, ul_info->slot_tx);
if (!ul_config)
{
LOG_E(NR_MAC, "mac->ul_config is null! \n");
return;
}
if (mac->ra.ra_state != RA_SUCCEEDED)
{
AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]),
"Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus);
fapi_nr_ul_config_prach_pdu *prach_pdu = &ul_config->ul_config_list[ul_config->number_pdus].prach_config_pdu;
uint8_t nr_prach = nr_ue_get_rach(prach_resources,
prach_pdu,
ul_info->module_id,
ul_info->cc_id,
ul_info->frame_tx,
ul_info->gNB_index,
ul_info->slot_tx);
if (nr_prach == 1)
{
L1_nsa_prach_procedures(ul_info->frame_tx, ul_info->slot_tx, prach_pdu);
ul_config->number_pdus = 0;
ul_info->ue_sched_mode = SCHED_ALL;
}
else if (nr_prach == 2)
{
LOG_I(NR_PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, ul_info->module_id);
}
else if(nr_prach == 3)
{
LOG_I(NR_PHY, "In %s: [UE %d] RA failed, setting UE mode to PRACH\n", __FUNCTION__, ul_info->module_id);
}
}
}
static void *NRUE_phy_stub_standalone_pnf_task(void *arg) static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
{ {
LOG_I(MAC, "Clearing Queues\n"); LOG_I(MAC, "Clearing Queues\n");
...@@ -319,71 +468,9 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -319,71 +468,9 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
{ {
LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", ul_info.slot_tx, __FUNCTION__); LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", ul_info.slot_tx, __FUNCTION__);
nr_ue_ul_indication(&ul_info); nr_ue_ul_indication(&ul_info);
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, ul_info.slot_tx); check_nr_prach(mac, &ul_info, &prach_resources);
if (!ul_config)
{
LOG_E(NR_MAC, "mac->ul_config is null! \n");
continue;
}
if (mac->ra.ra_state != RA_SUCCEEDED)
{
AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]),
"Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus);
fapi_nr_ul_config_prach_pdu *prach_pdu = &ul_config->ul_config_list[ul_config->number_pdus].prach_config_pdu;
uint8_t nr_prach = nr_ue_get_rach(&prach_resources, prach_pdu, mod_id, CC_id, ul_info.frame_tx, gNB_id, ul_info.slot_tx);
if (nr_prach == 1)
{
L1_nsa_prach_procedures(ul_info.frame_tx, ul_info.slot_tx, prach_pdu);
ul_config->number_pdus = 0;
ul_info.ue_sched_mode = SCHED_ALL;
}
else if (nr_prach == 2)
{
LOG_I(NR_PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, mod_id);
}
else if(nr_prach == 3)
{
LOG_I(NR_PHY, "In %s: [UE %d] RA failed, setting UE mode to PRACH\n", __FUNCTION__, mod_id);
}
}
}
nfapi_nr_rach_indication_t *rach_ind = unqueue_matching(&nr_rach_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
nfapi_nr_rx_data_indication_t *rx_ind = unqueue_matching(&nr_rx_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
nfapi_nr_crc_indication_t *crc_ind = unqueue_matching(&nr_crc_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
if (rach_ind && rach_ind->number_of_pdus > 0)
{
NR_UL_IND_t UL_INFO = {
.rach_ind = *rach_ind,
};
send_nsa_standalone_msg(&UL_INFO, rach_ind->header.message_id);
for (int i = 0; i < rach_ind->number_of_pdus; i++)
{
free(rach_ind->pdu_list[i].preamble_list);
}
free(rach_ind->pdu_list);
free(rach_ind);
nr_Msg1_transmitted(mod_id, CC_id, frame, gNB_id);
}
if (crc_ind && crc_ind->number_crcs > 0)
{
NR_UL_IND_t UL_INFO = {
.crc_ind = *crc_ind,
};
send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id);
free(crc_ind->crc_list);
free(crc_ind);
}
if (rx_ind && rx_ind->number_of_pdus > 0)
{
NR_UL_IND_t UL_INFO = {
.rx_ind = *rx_ind,
};
send_nsa_standalone_msg(&UL_INFO, rx_ind->header.message_id);
free(rx_ind->pdu_list);
free(rx_ind);
} }
process_queued_nr_nfapi_msgs(sfn_slot);
} }
return NULL; return NULL;
} }
......
...@@ -48,7 +48,6 @@ const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"}; ...@@ -48,7 +48,6 @@ const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"};
queue_t nr_rx_ind_queue; queue_t nr_rx_ind_queue;
queue_t nr_crc_ind_queue; queue_t nr_crc_ind_queue;
queue_t nr_uci_ind_queue; queue_t nr_uci_ind_queue;
queue_t nr_sfn_slot_queue;
int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) { int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) {
......
This diff is collapsed.
...@@ -234,6 +234,13 @@ typedef struct nfapi_dl_tti_config_req_tx_data_req_t ...@@ -234,6 +234,13 @@ typedef struct nfapi_dl_tti_config_req_tx_data_req_t
void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id); void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id);
void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request);
void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
nfapi_nr_tx_data_request_t *tx_data_request,
nfapi_nr_ul_dci_request_t *ul_dci_request,
nfapi_nr_ul_tti_request_t *ul_tti_request);
/**\brief done free of memory allocation by module_id and release to pointer pool. /**\brief done free of memory allocation by module_id and release to pointer pool.
\param module_id module id*/ \param module_id module id*/
int nr_ue_if_module_kill(uint32_t module_id); int nr_ue_if_module_kill(uint32_t module_id);
......
...@@ -2890,6 +2890,10 @@ static void start_oai_nrue_threads() ...@@ -2890,6 +2890,10 @@ static void start_oai_nrue_threads()
init_queue(&nr_crc_ind_queue); init_queue(&nr_crc_ind_queue);
init_queue(&nr_uci_ind_queue); init_queue(&nr_uci_ind_queue);
init_queue(&nr_sfn_slot_queue); init_queue(&nr_sfn_slot_queue);
init_queue(&nr_dl_tti_req_queue);
init_queue(&nr_tx_req_queue);
init_queue(&nr_ul_dci_req_queue);
init_queue(&nr_ul_tti_req_queue);
if (sem_init(&sfn_slot_semaphore, 0, 0) != 0) if (sem_init(&sfn_slot_semaphore, 0, 0) != 0)
{ {
......
...@@ -46,6 +46,10 @@ extern queue_t nr_rx_ind_queue; ...@@ -46,6 +46,10 @@ extern queue_t nr_rx_ind_queue;
extern queue_t nr_crc_ind_queue; extern queue_t nr_crc_ind_queue;
extern queue_t nr_uci_ind_queue; extern queue_t nr_uci_ind_queue;
extern queue_t nr_sfn_slot_queue; extern queue_t nr_sfn_slot_queue;
extern queue_t nr_dl_tti_req_queue;
extern queue_t nr_tx_req_queue;
extern queue_t nr_ul_dci_req_queue;
extern queue_t nr_ul_tti_req_queue;
// //
// main_rrc.c // main_rrc.c
// //
......
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