Commit 46488432 authored by Melissa Elkadi's avatar Melissa Elkadi

This commit includes the iisc pnf_p7 slot tick fix

It also includes the queuing development. The idea
is that the 5G Userplane messages will be filled
and configured the same as previous commit, but
the uplink messages will be queued and then sent to
the gNB during the correct slot. Still WIP.
parent 912cba16
......@@ -97,6 +97,8 @@ typedef enum {
si = 2
} sync_mode_t;
queue_t nr_rach_ind_queue;
static void *NRUE_phy_stub_standalone_pnf_task(void *arg);
void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
......@@ -147,8 +149,7 @@ void init_nrUE_standalone_thread(int ue_idx)
static void L1_nsa_prach_procedures(frame_t frame, int slot, fapi_nr_ul_config_prach_pdu *prach_pdu)
{
NR_UL_IND_t UL_INFO;
nfapi_nr_rach_indication_t *rach_ind = &UL_INFO.rach_ind;
nfapi_nr_rach_indication_t *rach_ind = CALLOC(1, sizeof(*rach_ind));
rach_ind->sfn = frame;
rach_ind->slot = slot;
rach_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION;
......@@ -170,18 +171,35 @@ static void L1_nsa_prach_procedures(frame_t frame, int slot, fapi_nr_ul_config_p
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(&UL_INFO, rach_ind->header.message_id);
free(rach_ind->pdu_list[pdu_index].preamble_list);
free(rach_ind->pdu_list);
if (!put_queue(&nr_rach_ind_queue, rach_ind))
{
free(rach_ind->pdu_list);
}
LOG_I(NR_MAC, "Melissa, We have successfully filled the rach_ind queue with the recently filled rach ind\n");
}
static void reset_queue(queue_t *q)
{
void *p;
while ((p = get_queue(q)) != NULL)
{
free(p);
}
}
static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
{
LOG_I(MAC, "Clearing Queues\n");
reset_queue(&nr_rach_ind_queue);
reset_queue(&nr_rx_ind_queue);
reset_queue(&nr_crc_ind_queue);
NR_PRACH_RESOURCES_t prach_resources;
memset(&prach_resources, 0, sizeof(prach_resources));
NR_UL_TIME_ALIGNMENT_t ul_time_alignment;
memset(&ul_time_alignment, 0, sizeof(ul_time_alignment));
int last_sfn_slot = -1;
while (!oai_exit)
{
if (sem_wait(&sfn_slot_semaphore) != 0)
......@@ -232,7 +250,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
mac->dl_info.dci_ind = NULL;
mac->dl_info.rx_ind = NULL;
if (is_nr_UL_slot(mac->scc, ul_info.slot_rx))
if (is_nr_DL_slot(mac->scc, ul_info.slot_rx))
{
nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment);
}
......@@ -246,29 +264,67 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
LOG_E(NR_MAC, "mac->ul_config is null! \n");
continue;
}
if (mac->ra.ra_state == RA_SUCCEEDED)
continue;
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 (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;
}
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);
}
}
}
if (nr_prach == 1)
if (slot == 19)
{
nfapi_nr_rach_indication_t *rach_ind = get_queue(&nr_rach_ind_queue);
if (rach_ind != NULL && rach_ind->number_of_pdus > 0 && (rach_ind->sfn == frame && rach_ind->slot == slot))
{
ul_config->number_pdus = 0;
L1_nsa_prach_procedures(ul_info.frame_tx, ul_info.slot_tx, prach_pdu);
LOG_I(NR_PHY, "Calling nr_Msg1_transmitted for slot %d\n", ul_info.slot_tx);
nr_Msg1_transmitted(mod_id, CC_id, ul_info.frame_tx, gNB_id);
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);
nr_Msg1_transmitted(mod_id, CC_id, frame, gNB_id);
}
else if (nr_prach == 2)
}
if (slot == 17)
{
nfapi_nr_rx_data_indication_t *rx_ind = get_queue(&nr_rx_ind_queue);
if (rx_ind != NULL && rx_ind->number_of_pdus > 0 && (rx_ind->sfn == frame && rx_ind->slot == slot))
{
LOG_I(NR_PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, mod_id);
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);
}
else if(nr_prach == 3)
nfapi_nr_crc_indication_t *crc_ind = get_queue(&nr_crc_ind_queue);
if (crc_ind != NULL && crc_ind->number_crcs > 0 && (crc_ind->sfn == frame && crc_ind->slot == slot))
{
LOG_I(NR_PHY, "In %s: [UE %d] RA failed, setting UE mode to PRACH\n", __FUNCTION__, mod_id);
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);
}
}
}
return NULL;
}
......
......@@ -3206,6 +3206,38 @@ int pnf_p7_message_pump(pnf_p7_t* pnf_p7)
return 0;
}
struct timespec pnf_timespec_add(struct timespec lhs, struct timespec rhs)
{
struct timespec result;
result.tv_sec = lhs.tv_sec + rhs.tv_sec;
result.tv_nsec = lhs.tv_nsec + rhs.tv_nsec;
if(result.tv_nsec > 1e9)
{
result.tv_sec++;
result.tv_nsec-= 1e9;
}
return result;
}
struct timespec pnf_timespec_sub(struct timespec lhs, struct timespec rhs)
{
struct timespec result;
if ((lhs.tv_nsec-rhs.tv_nsec)<0)
{
result.tv_sec = lhs.tv_sec-rhs.tv_sec-1;
result.tv_nsec = 1000000000+lhs.tv_nsec-rhs.tv_nsec;
}
else
{
result.tv_sec = lhs.tv_sec-rhs.tv_sec;
result.tv_nsec = lhs.tv_nsec-rhs.tv_nsec;
}
return result;
}
int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
{
......@@ -3281,6 +3313,23 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
}
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF P7 bind succeeded...\n");
//Initializaing timing structures needed for slot ticking
struct timespec slot_start;
clock_gettime(CLOCK_MONOTONIC, &slot_start);
struct timespec pselect_start;
struct timespec timeout;
timeout.tv_sec = 0;
timeout.tv_nsec = 500000;
struct timespec slot_duration;
slot_duration.tv_sec = 0;
slot_duration.tv_nsec = 0.5e6;
//Infinite loop
while(pnf_p7->terminate == 0)
{
fd_set rfds;
......@@ -3290,11 +3339,26 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
FD_ZERO(&rfds);
FD_SET(pnf_p7->p7_sock, &rfds);
struct timeval timeout;
timeout.tv_sec = 1;
timeout.tv_usec = 0;
clock_gettime(CLOCK_MONOTONIC, &pselect_start);
selectRetval = select(pnf_p7->p7_sock+1, &rfds, NULL, NULL, &timeout);
//setting the timeout
if((pselect_start.tv_sec > slot_start.tv_sec) || ((pselect_start.tv_sec == slot_start.tv_sec) && (pselect_start.tv_nsec > slot_start.tv_nsec)))
{
// overran the end of the subframe we do not want to wait
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
//struct timespec overrun = pnf_timespec_sub(pselect_start, sf_start);
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Subframe overrun detected of %d.%d running to catchup\n", overrun.tv_sec, overrun.tv_nsec);
}
else
{
// still time before the end of the subframe wait
timeout = pnf_timespec_sub(slot_start, pselect_start);
}
selectRetval = pselect(pnf_p7->p7_sock+1, &rfds, NULL, NULL, &timeout, NULL);
uint32_t now_hr_time = pnf_get_current_time_hr();
......@@ -3304,6 +3368,17 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
if(selectRetval == 0)
{
// timeout
//update slot start timing
slot_start = pnf_timespec_add(slot_start, slot_duration);
//increment sfn/slot
if (++pnf_p7->slot == 20)
{
pnf_p7->slot = 0;
pnf_p7->sfn = (pnf_p7->sfn + 1) % 1024;
}
continue;
}
else if (selectRetval == -1 && (errno == EINTR))
......@@ -3322,7 +3397,7 @@ int pnf_nr_p7_message_pump(pnf_p7_t* pnf_p7)
if(FD_ISSET(pnf_p7->p7_sock, &rfds))
{
pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7, now_hr_time);
pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7, now_hr_time);
}
}
NFAPI_TRACE(NFAPI_TRACE_ERROR, "PNF_P7 Terminating..\n");
......
......@@ -44,6 +44,8 @@ extern PHY_VARS_NR_UE ***PHY_vars_UE_g;
const char *dl_pdu_type[]={"DCI", "DLSCH", "RA_DLSCH"};
const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"};
queue_t nr_rx_ind_queue;
queue_t nr_crc_ind_queue;
int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) {
......@@ -64,9 +66,8 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
{
case (FAPI_NR_UL_CONFIG_TYPE_PUSCH):
{
NR_UL_IND_t UL_INFO;
nfapi_nr_rx_data_indication_t *rx_ind = &UL_INFO.rx_ind;
nfapi_nr_crc_indication_t *crc_ind = &UL_INFO.crc_ind;
nfapi_nr_rx_data_indication_t *rx_ind = CALLOC(1, sizeof(*rx_ind));
nfapi_nr_crc_indication_t *crc_ind = CALLOC(1, sizeof(*crc_ind));
nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[i].pusch_config_pdu;
if (scheduled_response->tx_request)
{
......@@ -74,8 +75,8 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
sizeof(scheduled_response->tx_request->tx_request_body) / sizeof(scheduled_response->tx_request->tx_request_body[0]),
"Too many tx_req pdus %d", scheduled_response->tx_request->number_of_pdus);
rx_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION;
rx_ind->slot = scheduled_response->ul_config->slot;
rx_ind->sfn = scheduled_response->ul_config->sfn;
rx_ind->slot = scheduled_response->ul_config->slot;
rx_ind->number_of_pdus = scheduled_response->tx_request->number_of_pdus;
rx_ind->pdu_list = CALLOC(1, sizeof(*rx_ind->pdu_list));
for (int j = 0; j < rx_ind->number_of_pdus; j++)
......@@ -109,12 +110,21 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
crc_ind->crc_list[j].ul_cqi = scheduled_response->tx_request->tx_config.ul_cqi;
}
LOG_I(PHY, "In %s: Filled rx/crc_ind with ulconfig. \n", __FUNCTION__);
LOG_I(PHY, "In %s: Filled queue rx/crc_ind which was filled by ulconfig. \n", __FUNCTION__);
if (!put_queue(&nr_rx_ind_queue, rx_ind))
{
LOG_E(NR_MAC, "Put_queue failed for rx_ind\n");
free(rx_ind->pdu_list);
free(rx_ind);
}
if (!put_queue(&nr_crc_ind_queue, crc_ind))
{
LOG_E(NR_MAC, "Put_queue failed for crc_ind\n");
free(crc_ind->crc_list);
free(crc_ind);
}
scheduled_response->tx_request->number_of_pdus = 0;
send_nsa_standalone_msg(&UL_INFO, rx_ind->header.message_id);
send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id);
free(rx_ind->pdu_list);
free(crc_ind->crc_list);
}
break;
}
......
......@@ -45,9 +45,6 @@
const char *dl_indication_type[] = {"MIB", "SIB", "DLSCH", "DCI", "RAR"};
queue_t dl_itti_config_req_tx_data_req_queue;
queue_t ul_dci_config_req_queue;
UL_IND_t *UL_INFO = NULL;
......
......@@ -217,9 +217,6 @@ void *nrue_standalone_pnf_task(void *context);
extern int current_sfn_slot;
extern sem_t sfn_slot_semaphore;
extern queue_t dl_itti_config_req_tx_data_req_queue;
extern queue_t ul_dci_config_req_queue;
typedef struct nfapi_dl_tti_config_req_tx_data_req_t
{
nfapi_nr_dl_tti_request_pdu_t *dl_itti_config_req;
......
......@@ -2965,8 +2965,9 @@ void init_connections_with_lte_ue(void)
static void start_oai_nrue_threads()
{
init_queue(&dl_itti_config_req_tx_data_req_queue);
init_queue(&ul_dci_config_req_queue);
init_queue(&nr_rach_ind_queue);
init_queue(&nr_rx_ind_queue);
init_queue(&nr_crc_ind_queue);
if (sem_init(&sfn_slot_semaphore, 0, 0) != 0)
{
......
......@@ -39,6 +39,11 @@
#include "NR_MeasConfig.h"
#include "NR_CellGroupConfig.h"
#include "NR_RadioBearerConfig.h"
#include "openair2/PHY_INTERFACE/queue.h"
extern queue_t nr_rach_ind_queue;
extern queue_t nr_rx_ind_queue;
extern queue_t nr_crc_ind_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