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 @@
#include "LAYER2/nr_pdcp/nr_pdcp_entity.h"
//#include "executables/softmodem-common.h"
#include "SCHED_NR_UE/pucch_uci_ue_nr.h"
#include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h"
/*
* NR SLOT PROCESSING SEQUENCE
......@@ -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;
}
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:
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)
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)
{
LOG_I(MAC, "Clearing Queues\n");
......@@ -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__);
nr_ue_ul_indication(&ul_info);
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");
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);
check_nr_prach(mac, &ul_info, &prach_resources);
}
process_queued_nr_nfapi_msgs(sfn_slot);
}
return NULL;
}
......
......@@ -48,7 +48,6 @@ const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"};
queue_t nr_rx_ind_queue;
queue_t nr_crc_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) {
......
......@@ -55,6 +55,12 @@ static int g_harq_pid;
int current_sfn_slot;
sem_t sfn_slot_semaphore;
queue_t nr_sfn_slot_queue;
queue_t nr_dl_tti_req_queue;
queue_t nr_tx_req_queue;
queue_t nr_ul_dci_req_queue;
queue_t nr_ul_tti_req_queue;
void nrue_init_standalone_socket(int tx_port, int rx_port)
{
{
......@@ -532,10 +538,10 @@ static void fill_dci_from_dl_config(nr_downlink_indication_t*dl_ind, fapi_nr_dl_
}
}
static 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)
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)
{
frame_t frame = 0;
int slot = 0;
......@@ -560,7 +566,7 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
incoming tx_data_request is also destined for the current UE. If the
RAR hasn't been processed yet, we do not want to be filtering the
tx_data_requests. */
else if (tx_data_request && (mac->expected_dci || mac->ra.ra_state == WAIT_RAR))
if (tx_data_request && (mac->expected_dci || mac->ra.ra_state == WAIT_RAR))
{
frame = tx_data_request->SFN;
slot = tx_data_request->Slot;
......@@ -584,6 +590,7 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
else
{
if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort();
LOG_E(NR_MAC, "Error! All indications were NULL\n");
return;
}
......@@ -611,7 +618,7 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
}
}
static void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request)
void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request)
{
int num_pdus = dl_tti_request->dl_tti_request_body.nPDUs;
char buffer[MAX_MESSAGE_SIZE];
......@@ -647,26 +654,183 @@ static void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request)
nsa_sendmsg_to_lte_ue(buffer, pack_len, NR_UE_RRC_MEASUREMENT);
LOG_A(NR_RRC, "Populated NR_UE_RRC_MEASUREMENT information and sent to LTE UE\n");
}
# if 0
static void process_nr_dl_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_header_t header)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
char buffer_for_tx_data_req[NFAPI_MAX_PACKED_MESSAGE_SIZE];
ssize_t len_of_tx_data_req = 0;
int sfn_of_tx_data_req = 0;
int slot_of_tx_data_req = 0;
int sfn_of_dl_tti_req = 0;
int slot_of_dl_tti_req = 0;
int delta = 0;
nfapi_nr_dl_tti_request_t dl_tti_request;
nfapi_nr_ul_tti_request_t ul_tti_request;
nfapi_nr_tx_data_request_t tx_data_request;
nfapi_nr_ul_dci_request_t ul_dci_request;
if (dl_tti_req)
{
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message in sfn/slot %d %d. \n",
dl_tti_request.SFN, dl_tti_request.Slot);
save_nr_measurement_info(&dl_tti_request);
check_and_process_dci(&dl_tti_request, NULL, NULL, NULL);
if (mac->expected_dci)
{
sfn_of_dl_tti_req = dl_tti_request.SFN;
slot_of_dl_tti_req = dl_tti_request.Slot;
}
if (len_of_tx_data_req > 0
&& sfn_of_dl_tti_req == sfn_of_tx_data_req
&& slot_of_dl_tti_req == slot_of_tx_data_req)
{
if (nfapi_nr_p7_message_unpack((void *)buffer_for_tx_data_req, len_of_tx_data_req, &tx_data_request,
sizeof(tx_data_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message tx_data_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Processing an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n",
tx_data_request.SFN, tx_data_request.Slot);
check_and_process_dci(NULL, &tx_data_request, NULL, NULL);
len_of_tx_data_req = 0;
}
}
if (tx_request)
{
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n",
tx_data_request.SFN, tx_data_request.Slot);
if (tx_data_request.SFN == sfn_of_dl_tti_req && tx_data_request.Slot == slot_of_dl_tti_req
&& (mac->expected_dci || mac->ra.ra_state <= WAIT_RAR))
{
check_and_process_dci(NULL, &tx_data_request, NULL, NULL);
}
else
{
len_of_tx_data_req = len;
sfn_of_tx_data_req = tx_data_request.SFN;
slot_of_tx_data_req = tx_data_request.Slot;
memcpy(buffer_for_tx_data_req, buffer, len);
LOG_I(NR_PHY, "Saved an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n",
tx_data_request.SFN, tx_data_request.Slot);
}
}
if (ul_dci_request)
{
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message in SFN/slot %d %d. \n",
ul_dci_request.SFN, ul_dci_request.Slot);
delta = NFAPI_SFNSLOT2DEC(sfn, slot) - NFAPI_SFNSLOT2DEC(ul_dci_request.SFN, ul_dci_request.Slot);
if (delta < -NFAPI_SFNSLOT2DEC(512, 0))
{
delta += NFAPI_SFNSLOT2DEC(1024, 0);
}
if (delta < 6)
{
check_and_process_dci(NULL, NULL, &ul_dci_request, NULL);
}
}
if (ul_tti_request)
{
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message in SFN/slot %d %d. \n",
ul_tti_request.SFN, ul_tti_request.Slot);
check_and_process_dci(NULL, NULL, NULL, &ul_tti_request);
}
else
LOG_E(NR_PHY, "Case Statement has no corresponding nfapi message, this is the header ID %d\n", header.message_id);
}
#endif
static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_header_t header)
{
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;
switch (header.message_id)
{
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &dl_tti_request,
sizeof(dl_tti_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message dl_tti_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message in sfn/slot %d %d. \n",
dl_tti_request.SFN, dl_tti_request.Slot);
if (!put_queue(&nr_dl_tti_req_queue, &dl_tti_request))
{
LOG_E(NR_PHY, "put_queue failed for dl_tti_request.\n");
}
break;
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &tx_data_request,
sizeof(tx_data_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message tx_data_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n",
tx_data_request.SFN, tx_data_request.Slot);
if (!put_queue(&nr_tx_req_queue, &tx_data_request))
{
LOG_E(NR_PHY, "put_queue failed for tx_request.\n");
}
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &ul_dci_request,
sizeof(ul_dci_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message ul_dci_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message in SFN/slot %d %d. \n",
ul_dci_request.SFN, ul_dci_request.Slot);
if (!put_queue(&nr_ul_dci_req_queue, &ul_dci_request))
{
LOG_E(NR_PHY, "put_queue failed for ul_dci_request.\n");
}
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &ul_tti_request,
sizeof(ul_tti_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message ul_tti_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message in SFN/slot %d %d. \n",
ul_tti_request.SFN, ul_tti_request.Slot);
if (!put_queue(&nr_ul_tti_req_queue, &ul_tti_request))
{
LOG_E(NR_PHY, "put_queue failed for ul_tti_request.\n");
}
break;
default:
LOG_E(NR_PHY, "Invalid nFAPI message. Header ID %d\n",
header.message_id);
break;
}
return;
}
uint16_t sfn_slot_pool[512];
uint16_t sfn_slot_id;
void *nrue_standalone_pnf_task(void *context)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
struct sockaddr_in server_address;
socklen_t addr_len = sizeof(server_address);
int sd = ue_rx_sock_descriptor;
assert(sd > 0);
char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE];
char buffer_for_tx_data_req[NFAPI_MAX_PACKED_MESSAGE_SIZE];
ssize_t len_of_tx_data_req = 0;
int sfn_of_tx_data_req = 0;
int slot_of_tx_data_req = 0;
int sfn_of_dl_tti_req = 0;
int slot_of_dl_tti_req = 0;
int sfn = 0;
int slot = 0;
int delta = 0;
int sd = ue_rx_sock_descriptor;
assert(sd > 0);
LOG_I(NR_RRC, "Sucessfully started %s.\n", __FUNCTION__);
while (true)
......@@ -686,6 +850,61 @@ void *nrue_standalone_pnf_task(void *context)
{
uint16_t sfn_slot = 0;
memcpy((void *)&sfn_slot, buffer, sizeof(sfn_slot));
sfn = NFAPI_SFNSLOT2SFN(sfn_slot);
slot = NFAPI_SFNSLOT2SLOT(sfn_slot);
if (slot == 5)
{
slot = 19;
if (sfn == 0)
sfn = 1023;
else
sfn = sfn - 1;
}
else if (slot == 4)
{
slot = 18;
if (sfn == 0)
sfn = 1023;
else
sfn = sfn - 1;
}
else if (slot == 3)
{
slot = 17;
if (sfn == 0)
sfn = 1023;
else
sfn = sfn - 1;
}
else if (slot == 2)
{
slot = 16;
if (sfn == 0)
sfn = 1023;
else
sfn = sfn - 1;
}
else if (slot == 1)
{
slot = 15;
if (sfn == 0)
sfn = 1023;
else
sfn = sfn - 1;
}
else if (slot == 0)
{
slot = 14;
if (sfn == 0)
sfn = 1023;
else
sfn = sfn - 1;
}
else
{
slot = slot - 6;
}
sfn_slot = NFAPI_SFNSLOT2HEX(sfn, slot);
current_sfn_slot = sfn_slot;
sfn_slot_pool[sfn_slot_id] = sfn_slot;
......@@ -702,8 +921,7 @@ void *nrue_standalone_pnf_task(void *context)
LOG_E(NR_PHY, "sem_post() error\n");
abort();
}
sfn = NFAPI_SFNSLOT2SFN(sfn_slot);
slot = NFAPI_SFNSLOT2SLOT(sfn_slot);
LOG_I(NR_PHY, "Received from proxy sfn %d slot %d\n", sfn, slot);
}
else if (len == sizeof(nr_phy_channel_params_t))
......@@ -733,111 +951,12 @@ void *nrue_standalone_pnf_task(void *context)
else
{
nfapi_p7_message_header_t header;
nfapi_nr_dl_tti_request_t dl_tti_request;
nfapi_nr_ul_tti_request_t ul_tti_request;
nfapi_nr_tx_data_request_t tx_data_request;
nfapi_nr_ul_dci_request_t ul_dci_request;
if (nfapi_p7_message_header_unpack((void *)buffer, len, &header, sizeof(header), NULL) < 0)
{
LOG_E(NR_PHY, "Header unpack failed for nrue_standalone pnf\n");
continue;
}
else
{
switch (header.message_id)
{
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &dl_tti_request,
sizeof(nfapi_nr_dl_tti_request_t), NULL) < 0)
{
LOG_E(NR_PHY, "Message dl_tti_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message in sfn/slot %d %d. \n",
dl_tti_request.SFN, dl_tti_request.Slot);
save_nr_measurement_info(&dl_tti_request);
check_and_process_dci(&dl_tti_request, NULL, NULL, NULL);
if (mac->expected_dci)
{
sfn_of_dl_tti_req = dl_tti_request.SFN;
slot_of_dl_tti_req = dl_tti_request.Slot;
}
if (len_of_tx_data_req > 0
&& sfn_of_dl_tti_req == sfn_of_tx_data_req
&& slot_of_dl_tti_req == slot_of_tx_data_req)
{
if (nfapi_nr_p7_message_unpack((void *)buffer_for_tx_data_req, len_of_tx_data_req, &tx_data_request,
sizeof(tx_data_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message tx_data_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Processing an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n",
tx_data_request.SFN, tx_data_request.Slot);
check_and_process_dci(NULL, &tx_data_request, NULL, NULL);
len_of_tx_data_req = 0;
}
break;
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &tx_data_request,
sizeof(tx_data_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message tx_data_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n",
tx_data_request.SFN, tx_data_request.Slot);
if (tx_data_request.SFN == sfn_of_dl_tti_req && tx_data_request.Slot == slot_of_dl_tti_req
&& (mac->expected_dci || mac->ra.ra_state <= WAIT_RAR))
{
check_and_process_dci(NULL, &tx_data_request, NULL, NULL);
}
else
{
len_of_tx_data_req = len;
sfn_of_tx_data_req = tx_data_request.SFN;
slot_of_tx_data_req = tx_data_request.Slot;
memcpy(buffer_for_tx_data_req, buffer, len);
LOG_I(NR_PHY, "Saved an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n",
tx_data_request.SFN, tx_data_request.Slot);
}
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &ul_dci_request,
sizeof(ul_dci_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message ul_dci_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message in SFN/slot %d %d. \n",
ul_dci_request.SFN, ul_dci_request.Slot);
delta = NFAPI_SFNSLOT2DEC(sfn, slot) - NFAPI_SFNSLOT2DEC(ul_dci_request.SFN, ul_dci_request.Slot);
if (delta < -NFAPI_SFNSLOT2DEC(512, 0))
{
delta += NFAPI_SFNSLOT2DEC(1024, 0);
}
if (delta < 6)
{
check_and_process_dci(NULL, NULL, &ul_dci_request, NULL);
}
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &ul_tti_request,
sizeof(ul_tti_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message ul_tti_request failed to unpack\n");
break;
}
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message in SFN/slot %d %d. \n",
ul_tti_request.SFN, ul_tti_request.Slot);
check_and_process_dci(NULL, NULL, NULL, &ul_tti_request);
break;
default:
LOG_E(NR_PHY, "Case Statement has no corresponding nfapi message, this is the header ID %d\n", header.message_id);
break;
}
}
enqueue_nr_nfapi_msg(buffer, len, header);
}
} //while(true)
}
......
......@@ -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 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.
\param module_id module id*/
int nr_ue_if_module_kill(uint32_t module_id);
......
......@@ -2890,6 +2890,10 @@ static void start_oai_nrue_threads()
init_queue(&nr_crc_ind_queue);
init_queue(&nr_uci_ind_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)
{
......
......@@ -46,6 +46,10 @@ extern queue_t nr_rx_ind_queue;
extern queue_t nr_crc_ind_queue;
extern queue_t nr_uci_ind_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
//
......
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