Commit 455e3d83 authored by Melissa Elkadi's avatar Melissa Elkadi

This commit gets rid of sfn_slot sleep

In the previous commit, the NRUE would record
the time it received a slot and compare this
rx time to the next slot. If the next slot
came in before it had been 500us, the NRUE
would sleep a delta amount to make the duration
between the two slot indications 500 us. This
change complicated the code and did not
improve the performance so it was removed.
Furthermore, this commit removes the old
queueing mechanism of the slot indications and
uses calloc rather than an array.
parent 3ec52106
......@@ -265,7 +265,7 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot)
nfapi_nr_dl_tti_request_t *dl_tti_request = get_queue(&nr_dl_tti_req_queue);
nfapi_nr_ul_dci_request_t *ul_dci_request = get_queue(&nr_ul_dci_req_queue);
LOG_D(NR_MAC, "Try to get a ul_tti_req for sfn/slot %d %d from queue with %d items\n",
LOG_D(NR_MAC, "Try to get a ul_tti_req for sfn/slot %d %d from queue with %lu items\n",
NFAPI_SFNSLOT2SFN(mac->active_harq_sfn_slot),NFAPI_SFNSLOT2SLOT(mac->active_harq_sfn_slot), nr_ul_tti_req_queue.num_items);
nfapi_nr_ul_tti_request_t *ul_tti_request = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->active_harq_sfn_slot);
if (!ul_tti_request)
......@@ -394,9 +394,6 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
NR_UL_TIME_ALIGNMENT_t ul_time_alignment;
memset(&ul_time_alignment, 0, sizeof(ul_time_alignment));
int last_sfn_slot = -1;
int sfn_slot;
uint64_t last_time_stamp = 0;
sfn_slot_info_t *sfn_slot_info;
while (!oai_exit)
{
......@@ -405,32 +402,26 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
LOG_E(NR_MAC, "sem_wait() error\n");
abort();
}
sfn_slot_info = get_queue(&nr_sfn_slot_queue);
if (sfn_slot_info == NULL)
uint16_t *sfn_slot = get_queue(&nr_sfn_slot_queue);
if (sfn_slot == NULL)
{
LOG_D(MAC, "get_queue(&nr_sfn_slot_queue) == NULL!\n");
continue;
}
sfn_slot = sfn_slot_info->sfn_slot;
if (sfn_slot == last_sfn_slot)
frame_t frame = NFAPI_SFNSLOT2SFN(*sfn_slot);
int slot = NFAPI_SFNSLOT2SLOT(*sfn_slot);
if (*sfn_slot == last_sfn_slot)
{
LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n",
sfn_slot >> 6, sfn_slot & 0x3F);
frame, slot);
continue;
}
last_sfn_slot = sfn_slot;
LOG_D(NR_MAC, "The received sfn/slot [%d %d], last time stamp %ld, current time stamp %ld\n",
NFAPI_SFNSLOT2SFN(sfn_slot), NFAPI_SFNSLOT2SLOT(sfn_slot), last_time_stamp, sfn_slot_info->time_stamp);
last_sfn_slot = *sfn_slot;
uint64_t delta = sfn_slot_info->time_stamp - last_time_stamp;
if (delta < 500)
{
LOG_D(NR_MAC, "sfn/slot [%d %d] has been received too quickly! Delta = %ld. Will sleep for %ld us\n",
NFAPI_SFNSLOT2SFN(sfn_slot), NFAPI_SFNSLOT2SLOT(sfn_slot), delta, 500 - delta);
usleep(500 - delta);
}
last_time_stamp = sfn_slot_info->time_stamp;
LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n",
frame, slot);
module_id_t mod_id = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
......@@ -443,8 +434,6 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
mac->ra.generate_nr_prach = 0;
int CC_id = 0;
uint8_t gNB_id = 0;
frame_t frame = NFAPI_SFNSLOT2SFN(sfn_slot);
int slot = NFAPI_SFNSLOT2SLOT(sfn_slot);
nr_uplink_indication_t ul_info;
int slots_per_frame = 20; //30 kHZ subcarrier spacing
int slot_ahead = 2; // TODO: Make this dynamic
......@@ -479,7 +468,9 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
nr_ue_ul_indication(&ul_info);
check_nr_prach(mac, &ul_info, &prach_resources);
}
process_queued_nr_nfapi_msgs(mac, sfn_slot);
process_queued_nr_nfapi_msgs(mac, *sfn_slot);
free(sfn_slot);
sfn_slot = NULL;
}
return NULL;
}
......
......@@ -443,11 +443,6 @@ typedef struct {
} NR_UE_MAC_INST_t;
typedef struct sfn_slot_info {
uint16_t sfn_slot;
uint64_t time_stamp;
} sfn_slot_info_t;
typedef enum seach_space_mask_e {
type0_pdcch = 0x1,
type0a_pdcch = 0x2,
......
......@@ -52,7 +52,6 @@ static nr_ue_if_module_t *nr_ue_if_module_inst[MAX_IF_MODULES];
static int ue_tx_sock_descriptor = -1;
static int ue_rx_sock_descriptor = -1;
static int g_harq_pid;
int current_sfn_slot;
sem_t sfn_slot_semaphore;
queue_t nr_sfn_slot_queue;
......@@ -789,18 +788,6 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea
return;
}
static uint64_t clock_usec()
{
struct timespec t;
if (clock_gettime(CLOCK_MONOTONIC, &t) == -1)
{
abort();
}
return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000);
}
sfn_slot_info_t sfn_slot_pool[512];
uint16_t sfn_slot_id;
void *nrue_standalone_pnf_task(void *context)
{
struct sockaddr_in server_address;
......@@ -809,9 +796,6 @@ void *nrue_standalone_pnf_task(void *context)
assert(sd > 0);
char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE];
int sfn = 0;
int slot = 0;
LOG_I(NR_RRC, "Successfully started %s.\n", __FUNCTION__);
......@@ -830,24 +814,17 @@ void *nrue_standalone_pnf_task(void *context)
}
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 = sfn_slot;
sfn_slot_pool[sfn_slot_id].time_stamp = clock_usec();
sfn = NFAPI_SFNSLOT2SFN(sfn_slot);
slot = NFAPI_SFNSLOT2SLOT(sfn_slot);
LOG_I(NR_PHY, "Received from proxy sfn %d slot %d and time_stamp = %ld\n",
sfn, slot, sfn_slot_pool[sfn_slot_id].time_stamp);
if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id]))
uint16_t *sfn_slot = CALLOC(1, sizeof(*sfn_slot));
memcpy(sfn_slot, buffer, sizeof(*sfn_slot));
LOG_I(NR_PHY, "Received from proxy sfn %d slot %d\n",
NFAPI_SFNSLOT2SFN(*sfn_slot), NFAPI_SFNSLOT2SLOT(*sfn_slot));
if (!put_queue(&nr_sfn_slot_queue, sfn_slot))
{
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");
......@@ -856,28 +833,22 @@ void *nrue_standalone_pnf_task(void *context)
}
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;
nr_phy_channel_params_t *ch_info = CALLOC(1, sizeof(*ch_info));
memcpy(ch_info, buffer, sizeof(*ch_info));
sfn_slot_pool[sfn_slot_id].sfn_slot = ch_info.sfn_slot;
sfn_slot_pool[sfn_slot_id].time_stamp = clock_usec();
LOG_I(NR_PHY, "Received_SINR = %f, sfn:slot %d:%d\n",
ch_info->sinr, NFAPI_SFNSLOT2SFN(ch_info->sfn_slot), NFAPI_SFNSLOT2SLOT(ch_info->sfn_slot));
if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id]))
if (!put_queue(&nr_sfn_slot_queue, ch_info))
{
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
{
......
......@@ -223,7 +223,6 @@ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id);
void nrue_init_standalone_socket(int tx_port, int rx_port);
void *nrue_standalone_pnf_task(void *context);
extern int current_sfn_slot;
extern sem_t sfn_slot_semaphore;
typedef struct nfapi_dl_tti_config_req_tx_data_req_t
......
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