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) {
......
...@@ -55,6 +55,12 @@ static int g_harq_pid; ...@@ -55,6 +55,12 @@ static int g_harq_pid;
int current_sfn_slot; int current_sfn_slot;
sem_t sfn_slot_semaphore; 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) void nrue_init_standalone_socket(int tx_port, int rx_port)
{ {
{ {
...@@ -532,7 +538,7 @@ static void fill_dci_from_dl_config(nr_downlink_indication_t*dl_ind, fapi_nr_dl_ ...@@ -532,7 +538,7 @@ 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, 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_tx_data_request_t *tx_data_request,
nfapi_nr_ul_dci_request_t *ul_dci_request, nfapi_nr_ul_dci_request_t *ul_dci_request,
nfapi_nr_ul_tti_request_t *ul_tti_request) nfapi_nr_ul_tti_request_t *ul_tti_request)
...@@ -560,7 +566,7 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -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 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 RAR hasn't been processed yet, we do not want to be filtering the
tx_data_requests. */ 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; frame = tx_data_request->SFN;
slot = tx_data_request->Slot; slot = tx_data_request->Slot;
...@@ -584,6 +590,7 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -584,6 +590,7 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
else else
{ {
if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort();
LOG_E(NR_MAC, "Error! All indications were NULL\n");
return; return;
} }
...@@ -611,7 +618,7 @@ static void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -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; int num_pdus = dl_tti_request->dl_tti_request_body.nPDUs;
char buffer[MAX_MESSAGE_SIZE]; char buffer[MAX_MESSAGE_SIZE];
...@@ -647,112 +654,23 @@ static void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request) ...@@ -647,112 +654,23 @@ 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); 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"); LOG_A(NR_RRC, "Populated NR_UE_RRC_MEASUREMENT information and sent to LTE UE\n");
} }
uint16_t sfn_slot_pool[512]; # if 0
uint16_t sfn_slot_id; static void process_nr_dl_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_header_t header)
void *nrue_standalone_pnf_task(void *context)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(0); NR_UE_MAC_INST_t *mac = get_mac_inst(0);
struct sockaddr_in server_address;
socklen_t addr_len = sizeof(server_address);
char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE];
char buffer_for_tx_data_req[NFAPI_MAX_PACKED_MESSAGE_SIZE]; char buffer_for_tx_data_req[NFAPI_MAX_PACKED_MESSAGE_SIZE];
ssize_t len_of_tx_data_req = 0; ssize_t len_of_tx_data_req = 0;
int sfn_of_tx_data_req = 0; int sfn_of_tx_data_req = 0;
int slot_of_tx_data_req = 0; int slot_of_tx_data_req = 0;
int sfn_of_dl_tti_req = 0; int sfn_of_dl_tti_req = 0;
int slot_of_dl_tti_req = 0; int slot_of_dl_tti_req = 0;
int sfn = 0;
int slot = 0;
int delta = 0; int delta = 0;
int sd = ue_rx_sock_descriptor;
assert(sd > 0);
LOG_I(NR_RRC, "Sucessfully started %s.\n", __FUNCTION__);
while (true)
{
ssize_t len = recvfrom(sd, buffer, sizeof(buffer), MSG_TRUNC, (struct sockaddr *)&server_address, &addr_len);
if (len == -1)
{
LOG_E(NR_PHY, "reading from standalone pnf sctp socket failed \n");
continue;
}
if (len > sizeof(buffer))
{
LOG_E(NR_PHY, "%s(%d). Message truncated. %zd\n", __FUNCTION__, __LINE__, len);
continue;
}
if (len == sizeof(uint16_t))
{
uint16_t sfn_slot = 0;
memcpy((void *)&sfn_slot, buffer, sizeof(sfn_slot));
current_sfn_slot = sfn_slot;
sfn_slot_pool[sfn_slot_id] = sfn_slot;
if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id]))
{
LOG_E(NR_PHY, "put_queue failed for sfn slot.\n");
}
sfn_slot_id = (sfn_slot_id + 1) % 512;
if (sem_post(&sfn_slot_semaphore) != 0)
{
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))
{
nr_phy_channel_params_t ch_info;
memcpy(&ch_info, buffer, sizeof(nr_phy_channel_params_t));
current_sfn_slot = ch_info.sfn_slot;
sfn_slot_pool[sfn_slot_id] = ch_info.sfn_slot;
if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id]))
{
LOG_E(NR_PHY, "put_queue failed for sfn slot.\n");
}
sfn_slot_id = (sfn_slot_id + 1) % 512;
if (sem_post(&sfn_slot_semaphore) != 0)
{
LOG_E(MAC, "sem_post() error\n");
abort();
}
sfn = NFAPI_SFNSLOT2SFN(ch_info.sfn_slot);
slot = NFAPI_SFNSLOT2SLOT(ch_info.sfn_slot);
LOG_I(NR_PHY, "Received_SINR = %f, sfn:slot %d:%d\n", ch_info.sinr, sfn, slot);
}
else
{
nfapi_p7_message_header_t header;
nfapi_nr_dl_tti_request_t dl_tti_request; nfapi_nr_dl_tti_request_t dl_tti_request;
nfapi_nr_ul_tti_request_t ul_tti_request; nfapi_nr_ul_tti_request_t ul_tti_request;
nfapi_nr_tx_data_request_t tx_data_request; nfapi_nr_tx_data_request_t tx_data_request;
nfapi_nr_ul_dci_request_t ul_dci_request; nfapi_nr_ul_dci_request_t ul_dci_request;
if (nfapi_p7_message_header_unpack((void *)buffer, len, &header, sizeof(header), NULL) < 0) if (dl_tti_req)
{ {
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", 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); dl_tti_request.SFN, dl_tti_request.Slot);
save_nr_measurement_info(&dl_tti_request); save_nr_measurement_info(&dl_tti_request);
...@@ -777,14 +695,9 @@ void *nrue_standalone_pnf_task(void *context) ...@@ -777,14 +695,9 @@ void *nrue_standalone_pnf_task(void *context)
check_and_process_dci(NULL, &tx_data_request, NULL, NULL); check_and_process_dci(NULL, &tx_data_request, NULL, NULL);
len_of_tx_data_req = 0; 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;
} }
if (tx_request)
{
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n", 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); tx_data_request.SFN, tx_data_request.Slot);
...@@ -802,14 +715,9 @@ void *nrue_standalone_pnf_task(void *context) ...@@ -802,14 +715,9 @@ void *nrue_standalone_pnf_task(void *context)
LOG_I(NR_PHY, "Saved an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n", 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); 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;
} }
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", 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); ul_dci_request.SFN, ul_dci_request.Slot);
delta = NFAPI_SFNSLOT2DEC(sfn, slot) - NFAPI_SFNSLOT2DEC(ul_dci_request.SFN, ul_dci_request.Slot); delta = NFAPI_SFNSLOT2DEC(sfn, slot) - NFAPI_SFNSLOT2DEC(ul_dci_request.SFN, ul_dci_request.Slot);
...@@ -821,7 +729,71 @@ void *nrue_standalone_pnf_task(void *context) ...@@ -821,7 +729,71 @@ void *nrue_standalone_pnf_task(void *context)
{ {
check_and_process_dci(NULL, NULL, &ul_dci_request, NULL); 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; 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: case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &ul_tti_request, if (nfapi_nr_p7_message_unpack((void *)buffer, len, &ul_tti_request,
sizeof(ul_tti_request), NULL) < 0) sizeof(ul_tti_request), NULL) < 0)
...@@ -831,13 +803,160 @@ void *nrue_standalone_pnf_task(void *context) ...@@ -831,13 +803,160 @@ void *nrue_standalone_pnf_task(void *context)
} }
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message in SFN/slot %d %d. \n", 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); ul_tti_request.SFN, ul_tti_request.Slot);
check_and_process_dci(NULL, NULL, NULL, &ul_tti_request); if (!put_queue(&nr_ul_tti_req_queue, &ul_tti_request))
{
LOG_E(NR_PHY, "put_queue failed for ul_tti_request.\n");
}
break; break;
default: default:
LOG_E(NR_PHY, "Case Statement has no corresponding nfapi message, this is the header ID %d\n", header.message_id); LOG_E(NR_PHY, "Invalid nFAPI message. Header ID %d\n",
header.message_id);
break; break;
} }
return;
}
uint16_t sfn_slot_pool[512];
uint16_t sfn_slot_id;
void *nrue_standalone_pnf_task(void *context)
{
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];
int sfn = 0;
int slot = 0;
LOG_I(NR_RRC, "Sucessfully started %s.\n", __FUNCTION__);
while (true)
{
ssize_t len = recvfrom(sd, buffer, sizeof(buffer), MSG_TRUNC, (struct sockaddr *)&server_address, &addr_len);
if (len == -1)
{
LOG_E(NR_PHY, "reading from standalone pnf sctp socket failed \n");
continue;
}
if (len > sizeof(buffer))
{
LOG_E(NR_PHY, "%s(%d). Message truncated. %zd\n", __FUNCTION__, __LINE__, len);
continue;
}
if (len == sizeof(uint16_t))
{
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;
if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id]))
{
LOG_E(NR_PHY, "put_queue failed for sfn slot.\n");
}
sfn_slot_id = (sfn_slot_id + 1) % 512;
if (sem_post(&sfn_slot_semaphore) != 0)
{
LOG_E(NR_PHY, "sem_post() error\n");
abort();
}
LOG_I(NR_PHY, "Received from proxy sfn %d slot %d\n", sfn, slot);
}
else if (len == sizeof(nr_phy_channel_params_t))
{
nr_phy_channel_params_t ch_info;
memcpy(&ch_info, buffer, sizeof(nr_phy_channel_params_t));
current_sfn_slot = ch_info.sfn_slot;
sfn_slot_pool[sfn_slot_id] = ch_info.sfn_slot;
if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id]))
{
LOG_E(NR_PHY, "put_queue failed for sfn slot.\n");
}
sfn_slot_id = (sfn_slot_id + 1) % 512;
if (sem_post(&sfn_slot_semaphore) != 0)
{
LOG_E(MAC, "sem_post() error\n");
abort();
}
sfn = NFAPI_SFNSLOT2SFN(ch_info.sfn_slot);
slot = NFAPI_SFNSLOT2SLOT(ch_info.sfn_slot);
LOG_I(NR_PHY, "Received_SINR = %f, sfn:slot %d:%d\n", ch_info.sinr, sfn, slot);
}
else
{
nfapi_p7_message_header_t header;
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;
} }
enqueue_nr_nfapi_msg(buffer, len, header);
} }
} //while(true) } //while(true)
} }
......
...@@ -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