Commit b17a5189 authored by Melissa Elkadi's avatar Melissa Elkadi

Adding timing informtion to rx'd slot indictions

Ensuring in the NRUE that the slot indications we
process are 500us apart.
parent f37264e6
...@@ -391,8 +391,9 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -391,8 +391,9 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
NR_UL_TIME_ALIGNMENT_t ul_time_alignment; NR_UL_TIME_ALIGNMENT_t ul_time_alignment;
memset(&ul_time_alignment, 0, sizeof(ul_time_alignment)); memset(&ul_time_alignment, 0, sizeof(ul_time_alignment));
int last_sfn_slot = -1; int last_sfn_slot = -1;
uint16_t *sfn_slot_p;
int sfn_slot; int sfn_slot;
uint64_t last_time_stamp = 0;
sfn_slot_info_t *sfn_slot_info;
while (!oai_exit) while (!oai_exit)
{ {
...@@ -401,14 +402,14 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -401,14 +402,14 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
LOG_E(NR_MAC, "sem_wait() error\n"); LOG_E(NR_MAC, "sem_wait() error\n");
abort(); abort();
} }
sfn_slot_p = get_queue(&nr_sfn_slot_queue); sfn_slot_info = get_queue(&nr_sfn_slot_queue);
if (sfn_slot_p == NULL) if (sfn_slot_info == NULL)
{ {
LOG_D(MAC, "get_queue(&nr_sfn_slot_queue) == NULL!\n"); LOG_D(MAC, "get_queue(&nr_sfn_slot_queue) == NULL!\n");
continue; continue;
} }
sfn_slot = *sfn_slot_p; sfn_slot = sfn_slot_info->sfn_slot;
if (sfn_slot == last_sfn_slot) if (sfn_slot == last_sfn_slot)
{ {
LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n", LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n",
...@@ -416,6 +417,17 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -416,6 +417,17 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
continue; continue;
} }
last_sfn_slot = sfn_slot; 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);
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;
module_id_t mod_id = 0; module_id_t mod_id = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
......
...@@ -443,6 +443,11 @@ typedef struct { ...@@ -443,6 +443,11 @@ typedef struct {
} NR_UE_MAC_INST_t; } 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 { typedef enum seach_space_mask_e {
type0_pdcch = 0x1, type0_pdcch = 0x1,
type0a_pdcch = 0x2, type0a_pdcch = 0x2,
......
...@@ -748,7 +748,17 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea ...@@ -748,7 +748,17 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea
return; return;
} }
uint16_t sfn_slot_pool[512]; 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; uint16_t sfn_slot_id;
void *nrue_standalone_pnf_task(void *context) void *nrue_standalone_pnf_task(void *context)
{ {
...@@ -783,7 +793,12 @@ void *nrue_standalone_pnf_task(void *context) ...@@ -783,7 +793,12 @@ void *nrue_standalone_pnf_task(void *context)
memcpy((void *)&sfn_slot, buffer, sizeof(sfn_slot)); memcpy((void *)&sfn_slot, buffer, sizeof(sfn_slot));
current_sfn_slot = sfn_slot; current_sfn_slot = sfn_slot;
sfn_slot_pool[sfn_slot_id] = 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])) if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id]))
{ {
...@@ -797,10 +812,6 @@ void *nrue_standalone_pnf_task(void *context) ...@@ -797,10 +812,6 @@ void *nrue_standalone_pnf_task(void *context)
LOG_E(NR_PHY, "sem_post() error\n"); LOG_E(NR_PHY, "sem_post() error\n");
abort(); 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)) else if (len == sizeof(nr_phy_channel_params_t))
{ {
...@@ -808,7 +819,8 @@ void *nrue_standalone_pnf_task(void *context) ...@@ -808,7 +819,8 @@ void *nrue_standalone_pnf_task(void *context)
memcpy(&ch_info, buffer, sizeof(nr_phy_channel_params_t)); memcpy(&ch_info, buffer, sizeof(nr_phy_channel_params_t));
current_sfn_slot = ch_info.sfn_slot; current_sfn_slot = ch_info.sfn_slot;
sfn_slot_pool[sfn_slot_id] = ch_info.sfn_slot; sfn_slot_pool[sfn_slot_id].sfn_slot = ch_info.sfn_slot;
sfn_slot_pool[sfn_slot_id].time_stamp = clock_usec();
if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id])) if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id]))
{ {
......
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