fix lte-ue.c main loop with 5G common vars

This commit is contained in:
Laurent THOMAS
2022-04-11 09:39:16 +02:00
parent f2e6537195
commit b860d76cd6
+86 -125
View File
@@ -176,6 +176,7 @@ PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
{ {
PHY_VARS_UE *ue = (PHY_VARS_UE *)calloc(1,sizeof(PHY_VARS_UE)); PHY_VARS_UE *ue = (PHY_VARS_UE *)calloc(1,sizeof(PHY_VARS_UE));
AssertFatal(ue,""); AssertFatal(ue,"");
if (frame_parms!=(LTE_DL_FRAME_PARMS *)NULL) { // if we want to give initial frame parms, allocate the PHY_VARS_UE structure and put them in if (frame_parms!=(LTE_DL_FRAME_PARMS *)NULL) { // if we want to give initial frame parms, allocate the PHY_VARS_UE structure and put them in
memcpy(&(ue->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS)); memcpy(&(ue->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS));
} }
@@ -204,8 +205,7 @@ void init_thread(int sched_runtime,
int sched_deadline, int sched_deadline,
int sched_fifo, int sched_fifo,
cpu_set_t *cpuset, cpu_set_t *cpuset,
char *name) char *name) {
{
#ifdef DEADLINE_SCHEDULER #ifdef DEADLINE_SCHEDULER
if (sched_runtime!=0) { if (sched_runtime!=0) {
@@ -266,8 +266,7 @@ void init_UE(int nb_inst,
runmode_t mode, runmode_t mode,
int rxgain, int rxgain,
int txpowermax, int txpowermax,
LTE_DL_FRAME_PARMS *fp0) LTE_DL_FRAME_PARMS *fp0) {
{
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
int inst; int inst;
int ret; int ret;
@@ -283,9 +282,7 @@ void init_UE(int nb_inst,
if (PHY_vars_UE_g[inst]==NULL) PHY_vars_UE_g[inst] = (PHY_VARS_UE **)calloc(1+MAX_NUM_CCs,sizeof(PHY_VARS_UE *)); if (PHY_vars_UE_g[inst]==NULL) PHY_vars_UE_g[inst] = (PHY_VARS_UE **)calloc(1+MAX_NUM_CCs,sizeof(PHY_VARS_UE *));
LOG_I(PHY,"Allocating UE context %d\n",inst); LOG_I(PHY,"Allocating UE context %d\n",inst);
PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0); PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0);
// turn off timing control loop in UE // turn off timing control loop in UE
PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction; PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction;
UE = PHY_vars_UE_g[inst][0]; UE = PHY_vars_UE_g[inst][0];
@@ -362,7 +359,6 @@ void init_UE(int nb_inst,
LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]); LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]);
init_UE_threads(inst); init_UE_threads(inst);
ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]); ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]);
if (ret !=0) { if (ret !=0) {
@@ -385,8 +381,7 @@ void init_UE(int nb_inst,
void init_UE_stub_single_thread(int nb_inst, void init_UE_stub_single_thread(int nb_inst,
int eMBMS_active, int eMBMS_active,
int uecap_xer_in, int uecap_xer_in,
char *emul_iface) char *emul_iface) {
{
int inst; int inst;
LOG_I(PHY,"UE : Calling Layer 2 for initialization, nb_inst: %d \n", nb_inst); LOG_I(PHY,"UE : Calling Layer 2 for initialization, nb_inst: %d \n", nb_inst);
l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL, l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
@@ -411,24 +406,23 @@ void init_UE_stub_single_thread(int nb_inst,
} }
} }
void init_UE_standalone_thread(int ue_idx) void init_UE_standalone_thread(int ue_idx) {
{
int standalone_tx_port = 3211 + ue_idx * 2; int standalone_tx_port = 3211 + ue_idx * 2;
int standalone_rx_port = 3212 + ue_idx * 2; int standalone_rx_port = 3212 + ue_idx * 2;
ue_init_standalone_socket(standalone_tx_port, standalone_rx_port); ue_init_standalone_socket(standalone_tx_port, standalone_rx_port);
pthread_t thread; pthread_t thread;
if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) { if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) {
LOG_E(MAC, "pthread_create failed for calling ue_standalone_pnf_task"); LOG_E(MAC, "pthread_create failed for calling ue_standalone_pnf_task");
} }
pthread_setname_np(thread, "oai:ue-stand"); pthread_setname_np(thread, "oai:ue-stand");
} }
void init_UE_stub(int nb_inst, void init_UE_stub(int nb_inst,
int eMBMS_active, int eMBMS_active,
int uecap_xer_in, int uecap_xer_in,
char *emul_iface) char *emul_iface) {
{
int inst; int inst;
LOG_I(PHY,"UE : Calling Layer 2 for initialization\n"); LOG_I(PHY,"UE : Calling Layer 2 for initialization\n");
l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL, l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
@@ -462,8 +456,7 @@ void init_UE_stub(int nb_inst,
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
static void *UE_thread_synch(void *arg) static void *UE_thread_synch(void *arg) {
{
static int UE_thread_synch_retval; static int UE_thread_synch_retval;
int i ; int i ;
PHY_VARS_UE *UE = (PHY_VARS_UE *) arg; PHY_VARS_UE *UE = (PHY_VARS_UE *) arg;
@@ -478,6 +471,7 @@ static void *UE_thread_synch(void *arg)
printf("UE_thread_sync in with PHY_vars_UE %p\n",arg); printf("UE_thread_sync in with PHY_vars_UE %p\n",arg);
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
if ( threads.sync != -1 ) if ( threads.sync != -1 )
CPU_SET(threads.sync, &cpuset); CPU_SET(threads.sync, &cpuset);
@@ -757,8 +751,7 @@ static void *UE_thread_synch(void *arg)
* \param arg is a pointer to a \ref PHY_VARS_UE structure. * \param arg is a pointer to a \ref PHY_VARS_UE structure.
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
const char *get_connectionloss_errstr(int errcode) const char *get_connectionloss_errstr(int errcode) {
{
switch (errcode) { switch (errcode) {
case CONNECTION_LOST: case CONNECTION_LOST:
return "RRC Connection lost, returning to PRACH"; return "RRC Connection lost, returning to PRACH";
@@ -773,8 +766,7 @@ const char *get_connectionloss_errstr(int errcode)
return "UNKNOWN RETURN CODE"; return "UNKNOWN RETURN CODE";
} }
static void *UE_thread_rxn_txnp4(void *arg) static void *UE_thread_rxn_txnp4(void *arg) {
{
static __thread int UE_thread_rxtx_retval; static __thread int UE_thread_rxtx_retval;
struct rx_tx_thread_data *rtd = arg; struct rx_tx_thread_data *rtd = arg;
UE_rxtx_proc_t *proc = rtd->proc; UE_rxtx_proc_t *proc = rtd->proc;
@@ -867,12 +859,10 @@ static void *UE_thread_rxn_txnp4(void *arg)
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD) ) (UE->frame_parms.frame_type == FDD) )
if (UE->mode != loop_through_memory)
phy_procedures_UE_TX(UE,proc,0,0,UE->mode); phy_procedures_UE_TX(UE,proc,0,0,UE->mode);
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) && if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) &&
(UE->frame_parms.frame_type == TDD)) (UE->frame_parms.frame_type == TDD))
if (UE->mode != loop_through_memory)
phy_procedures_UE_S_TX(UE,0,0); phy_procedures_UE_S_TX(UE,0,0);
proc->instance_cnt_rxtx--; proc->instance_cnt_rxtx--;
@@ -895,8 +885,7 @@ static void *UE_thread_rxn_txnp4(void *arg)
unsigned int emulator_absSF; unsigned int emulator_absSF;
void ue_stub_rx_handler(unsigned int num_bytes, void ue_stub_rx_handler(unsigned int num_bytes,
char *rx_buffer) char *rx_buffer) {
{
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
UE = PHY_vars_UE_g[0][0]; UE = PHY_vars_UE_g[0][0];
UE_tport_t *pdu = (UE_tport_t *)rx_buffer; UE_tport_t *pdu = (UE_tport_t *)rx_buffer;
@@ -951,13 +940,13 @@ void ue_stub_rx_handler(unsigned int num_bytes,
} }
} }
uint64_t clock_usec(void) uint64_t clock_usec(void) {
{
struct timespec t; struct timespec t;
if (clock_gettime(CLOCK_MONOTONIC, &t) == -1)
{ if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) {
abort(); abort();
} }
return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000); return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000);
} }
/*! /*!
@@ -968,23 +957,21 @@ uint64_t clock_usec(void)
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
static void *UE_phy_stub_standalone_pnf_task(void *arg) static void *UE_phy_stub_standalone_pnf_task(void *arg) {
{
#if 1 #if 1
{ {
struct sched_param sparam = struct sched_param sparam =
{ {
.sched_priority = 79, .sched_priority = 79,
}; };
if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0)
{ if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0) {
LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno)); LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno));
} }
} }
#else #else
thread_top_init("UE_phy_stub_thread_rxn_txnp4", 1, 870000L, 1000000L, 1000000L); thread_top_init("UE_phy_stub_thread_rxn_txnp4", 1, 870000L, 1000000L, 1000000L);
#endif #endif
// for multipule UE's L2-emulator // for multipule UE's L2-emulator
//module_id_t Mod_id = 0; //module_id_t Mod_id = 0;
//int init_ra_UE = -1; // This counter is used to initiate the RA of each UE in different SFrames //int init_ra_UE = -1; // This counter is used to initiate the RA of each UE in different SFrames
@@ -1004,9 +991,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
PHY_VARS_UE *UE = NULL; PHY_VARS_UE *UE = NULL;
int ret; int ret;
proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0]; proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0];
UE = rtd->UE; UE = rtd->UE;
UL_INFO = (UL_IND_t *)calloc(1, sizeof(UL_IND_t)); UL_INFO = (UL_IND_t *)calloc(1, sizeof(UL_IND_t));
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NFAPI_RX_IND_MAX_PDU, sizeof(nfapi_rx_indication_pdu_t)); UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NFAPI_RX_IND_MAX_PDU, sizeof(nfapi_rx_indication_pdu_t));
UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
@@ -1019,19 +1004,15 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_pdu_t)); UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_pdu_t));
UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_raw_pdu_t)); UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = calloc(NFAPI_CQI_IND_MAX_PDU, sizeof(nfapi_cqi_indication_raw_pdu_t));
UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0; UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0;
proc->subframe_rx = proc->sub_frame_start; proc->subframe_rx = proc->sub_frame_start;
proc->subframe_tx = -1; proc->subframe_tx = -1;
proc->frame_rx = -1; proc->frame_rx = -1;
proc->frame_tx = -1; proc->frame_tx = -1;
// Initializations for nfapi-L2-emulator mode // Initializations for nfapi-L2-emulator mode
sync_var = 0; sync_var = 0;
//PANOS: CAREFUL HERE! //PANOS: CAREFUL HERE!
wait_sync("UE_phy_stub_standalone_pnf_task"); wait_sync("UE_phy_stub_standalone_pnf_task");
int last_sfn_sf = -1; int last_sfn_sf = -1;
LOG_I(MAC, "Clearing Queues\n"); LOG_I(MAC, "Clearing Queues\n");
reset_queue(&dl_config_req_tx_req_queue); reset_queue(&dl_config_req_tx_req_queue);
reset_queue(&ul_config_req_queue); reset_queue(&ul_config_req_queue);
@@ -1039,35 +1020,37 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
while (!oai_exit) { while (!oai_exit) {
bool sent_any = false; bool sent_any = false;
if (sem_wait(&sfn_semaphore) != 0) { if (sem_wait(&sfn_semaphore) != 0) {
LOG_E(MAC, "sem_wait() error\n"); LOG_E(MAC, "sem_wait() error\n");
abort(); abort();
} }
int sfn_sf = current_sfn_sf; int sfn_sf = current_sfn_sf;
if (sfn_sf == last_sfn_sf)
{ if (sfn_sf == last_sfn_sf) {
LOG_W(MAC, "repeated sfn_sf = %d.%d\n", LOG_W(MAC, "repeated sfn_sf = %d.%d\n",
sfn_sf >> 4, sfn_sf & 15); sfn_sf >> 4, sfn_sf & 15);
continue; continue;
} }
last_sfn_sf = sfn_sf;
last_sfn_sf = sfn_sf;
nfapi_dl_config_req_tx_req_t *dl_config_req_tx_req = get_queue(&dl_config_req_tx_req_queue); nfapi_dl_config_req_tx_req_t *dl_config_req_tx_req = get_queue(&dl_config_req_tx_req_queue);
nfapi_ul_config_request_t *ul_config_req = get_queue(&ul_config_req_queue); nfapi_ul_config_request_t *ul_config_req = get_queue(&ul_config_req_queue);
nfapi_hi_dci0_request_t *hi_dci0_req = get_queue(&hi_dci0_req_queue); nfapi_hi_dci0_request_t *hi_dci0_req = get_queue(&hi_dci0_req_queue);
LOG_I(MAC, "received from proxy frame %d subframe %d\n", LOG_I(MAC, "received from proxy frame %d subframe %d\n",
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
if (ul_config_req != NULL) { if (ul_config_req != NULL) {
uint8_t ul_num_pdus = ul_config_req->ul_config_request_body.number_of_pdus; uint8_t ul_num_pdus = ul_config_req->ul_config_request_body.number_of_pdus;
if (ul_num_pdus > 0) { if (ul_num_pdus > 0) {
char *ul_str = nfapi_ul_config_req_to_string(ul_config_req); char *ul_str = nfapi_ul_config_req_to_string(ul_config_req);
LOG_I(MAC, "ul_config_req: %s\n", ul_str); LOG_I(MAC, "ul_config_req: %s\n", ul_str);
free(ul_str); free(ul_str);
} }
} }
if (hi_dci0_req != NULL) { if (hi_dci0_req != NULL) {
LOG_D(MAC, "hi_dci0_req pdus: %u Frame: %d Subframe: %d\n", LOG_D(MAC, "hi_dci0_req pdus: %u Frame: %d Subframe: %d\n",
hi_dci0_req->hi_dci0_request_body.number_of_dci, hi_dci0_req->hi_dci0_request_body.number_of_dci,
@@ -1075,36 +1058,39 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
} }
if (dl_config_req_tx_req != NULL) { if (dl_config_req_tx_req != NULL) {
nfapi_tx_req_pdu_list_t *tx_req_pdu_list = dl_config_req_tx_req->tx_req_pdu_list; nfapi_tx_req_pdu_list_t *tx_req_pdu_list = dl_config_req_tx_req->tx_req_pdu_list;
nfapi_dl_config_request_t *dl_config_req = dl_config_req_tx_req->dl_config_req; nfapi_dl_config_request_t *dl_config_req = dl_config_req_tx_req->dl_config_req;
uint16_t dl_num_pdus = dl_config_req->dl_config_request_body.number_pdu; uint16_t dl_num_pdus = dl_config_req->dl_config_request_body.number_pdu;
LOG_I(MAC, "(OAI UE) Received dl_config_req from proxy at Frame: %d, Subframe: %d," LOG_I(MAC, "(OAI UE) Received dl_config_req from proxy at Frame: %d, Subframe: %d,"
" with number of PDUs: %u\n", " with number of PDUs: %u\n",
NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf), NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
dl_num_pdus); dl_num_pdus);
if (dl_num_pdus > 0) { if (dl_num_pdus > 0) {
char *dl_str = nfapi_dl_config_req_to_string(dl_config_req); char *dl_str = nfapi_dl_config_req_to_string(dl_config_req);
LOG_I(MAC, "dl_config_req: %s\n", dl_str); LOG_I(MAC, "dl_config_req: %s\n", dl_str);
free(dl_str); free(dl_str);
} }
LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus);
LOG_D(MAC, "tx_req pdus: %d\n", tx_req_pdu_list->num_pdus);
// Handling dl_config_req and tx_req: // Handling dl_config_req and tx_req:
nfapi_dl_config_request_body_t *dl_config_req_body = &dl_config_req->dl_config_request_body; nfapi_dl_config_request_body_t *dl_config_req_body = &dl_config_req->dl_config_request_body;
for (int i = 0; i < dl_config_req_body->number_pdu; ++i) { for (int i = 0; i < dl_config_req_body->number_pdu; ++i) {
nfapi_dl_config_request_pdu_t *pdu = &dl_config_req_body->dl_config_pdu_list[i]; nfapi_dl_config_request_pdu_t *pdu = &dl_config_req_body->dl_config_pdu_list[i];
if (pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) { if (pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) {
i += 1; i += 1;
AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu, AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu,
"Need PDU following DCI at index %d, but not found\n", "Need PDU following DCI at index %d, but not found\n",
i); i);
nfapi_dl_config_request_pdu_t *dlsch = &dl_config_req_body->dl_config_pdu_list[i]; nfapi_dl_config_request_pdu_t *dlsch = &dl_config_req_body->dl_config_pdu_list[i];
if (dlsch->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { if (dlsch->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) {
LOG_E(MAC, "expected DLSCH PDU at index %d\n", i); LOG_E(MAC, "expected DLSCH PDU at index %d\n", i);
continue; continue;
} }
dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),
NFAPI_SFNSF2SF(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
pdu, pdu,
@@ -1125,8 +1111,10 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
} }
} }
} }
if (hi_dci0_req) { if (hi_dci0_req) {
nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body;
for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) { for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) {
nfapi_hi_dci0_request_pdu_t *pdu = &hi_dci0_body->hi_dci0_pdu_list[i]; nfapi_hi_dci0_request_pdu_t *pdu = &hi_dci0_body->hi_dci0_pdu_list[i];
hi_dci0_req_UE_MAC(NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), hi_dci0_req_UE_MAC(NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf),
@@ -1139,13 +1127,13 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
for (ue_index = 0; ue_index < ue_num; ue_index++) { for (ue_index = 0; ue_index < ue_num; ue_index++) {
ue_Mod_id = ue_thread_id + NB_THREAD_INST * ue_index; // Always 0 in standalone pnf mode ue_Mod_id = ue_thread_id + NB_THREAD_INST * ue_index; // Always 0 in standalone pnf mode
UE = PHY_vars_UE_g[ue_Mod_id][0]; UE = PHY_vars_UE_g[ue_Mod_id][0];
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&UE->generic_stat); start_meas(&UE->generic_stat);
#endif #endif
int rx_frame = NFAPI_SFNSF2SF(sfn_sf) < 4 ? (NFAPI_SFNSF2SFN(sfn_sf) + 1023) % 1024 : NFAPI_SFNSF2SFN(sfn_sf); // subtracting 4 from subframe_tx int rx_frame = NFAPI_SFNSF2SF(sfn_sf) < 4 ? (NFAPI_SFNSF2SFN(sfn_sf) + 1023) % 1024 : NFAPI_SFNSF2SFN(sfn_sf); // subtracting 4 from subframe_tx
int rx_subframe = NFAPI_SFNSF2SF(sfn_sf) < 4 ? NFAPI_SFNSF2SF(sfn_sf) + 6 : NFAPI_SFNSF2SF(sfn_sf) - 4; int rx_subframe = NFAPI_SFNSF2SF(sfn_sf) < 4 ? NFAPI_SFNSF2SF(sfn_sf) + 6 : NFAPI_SFNSF2SF(sfn_sf) - 4;
LOG_D(MAC, "rx_frame %d rx_subframe %d\n", rx_frame, rx_subframe); LOG_D(MAC, "rx_frame %d rx_subframe %d\n", rx_frame, rx_subframe);
if (UE->mac_enabled == 1) { if (UE->mac_enabled == 1) {
ret = ue_scheduler(ue_Mod_id, ret = ue_scheduler(ue_Mod_id,
rx_frame, rx_frame,
@@ -1168,31 +1156,28 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
// Prepare the future Tx data // Prepare the future Tx data
if ((subframe_select(&UE->frame_parms, NFAPI_SFNSF2SF(sfn_sf)) == SF_UL) || if ((subframe_select(&UE->frame_parms, NFAPI_SFNSF2SF(sfn_sf)) == SF_UL) ||
(UE->frame_parms.frame_type == FDD)) (UE->frame_parms.frame_type == FDD)) {
{
if (UE->mode != loop_through_memory)
{
// We make the start of RA between consecutive UEs differ by 20 frames // We make the start of RA between consecutive UEs differ by 20 frames
//if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
if (UE_mac_inst[ue_Mod_id].UE_mode[0] == RA_RESPONSE && if (UE_mac_inst[ue_Mod_id].UE_mode[0] == RA_RESPONSE &&
is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf))) is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf))) {
{
UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH; UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH;
} }
LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]); LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]);
if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH)
{ //&& ue_Mod_id == next_Mod_id) { if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH) {
//&& ue_Mod_id == next_Mod_id) {
next_ra_frame++; next_ra_frame++;
if (next_ra_frame > 500)
{ if (next_ra_frame > 500) {
// check if we have PRACH opportunity // check if we have PRACH opportunity
if (is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) if (is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) {
{
// The one working strangely... // The one working strangely...
//if (is_prach_subframe(&UE->frame_parms,NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf) && Mod_id == (module_id_t) init_ra_UE) ) { //if (is_prach_subframe(&UE->frame_parms,NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf) && Mod_id == (module_id_t) init_ra_UE) ) {
PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf)); PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf));
if (prach_resources != NULL)
{ if (prach_resources != NULL) {
LOG_I(MAC, "preamble_received_tar_power: %d\n", LOG_I(MAC, "preamble_received_tar_power: %d\n",
prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER); prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER);
UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf); UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf);
@@ -1205,6 +1190,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
//next_ra_frame = (rx_frame + 20)%1000; //next_ra_frame = (rx_frame + 20)%1000;
next_ra_frame = 0; next_ra_frame = 0;
} }
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
} }
} }
@@ -1213,20 +1199,18 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
// Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
// UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB). // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
// Generate UL_indications which correspond to UL traffic. // Generate UL_indications which correspond to UL traffic.
if (ul_config_req != NULL) if (ul_config_req != NULL) {
{ //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){ //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id); ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id);
} }
} }
phy_procedures_UE_SL_RX(UE, proc); phy_procedures_UE_SL_RX(UE, proc);
} } else {
else
{
LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n", LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n",
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
if (ul_config_req != NULL)
{ if (ul_config_req != NULL) {
LOG_I(MAC, "Skipping subframe select statement ul_config_req SFN.SF: %d.%d\n", LOG_I(MAC, "Skipping subframe select statement ul_config_req SFN.SF: %d.%d\n",
NFAPI_SFNSF2SFN(ul_config_req->sfn_sf), NFAPI_SFNSF2SF(ul_config_req->sfn_sf)); NFAPI_SFNSF2SFN(ul_config_req->sfn_sf), NFAPI_SFNSF2SF(ul_config_req->sfn_sf));
} }
@@ -1243,12 +1227,10 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
} }
if (UL_INFO->rx_ind.rx_indication_body.number_of_pdus > 0) { if (UL_INFO->rx_ind.rx_indication_body.number_of_pdus > 0) {
//LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf)); //LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf));
//LOG_I(MAC, "ul_config_req_UE_MAC 2.3, SFN/SF of PNF counter:%d.%d, number_of_pdus: %d \n", timer_frame, timer_subframe, UL_INFO->rx_ind.rx_indication_body.number_of_pdus); //LOG_I(MAC, "ul_config_req_UE_MAC 2.3, SFN/SF of PNF counter:%d.%d, number_of_pdus: %d \n", timer_frame, timer_subframe, UL_INFO->rx_ind.rx_indication_body.number_of_pdus);
send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id); send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id);
sent_any = true; sent_any = true;
//LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n"); //LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n");
UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
} }
@@ -1286,12 +1268,11 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
free(dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list); free(dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list);
dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list = NULL; dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list = NULL;
} }
nfapi_free_tx_req_pdu_list(dl_config_req_tx_req->tx_req_pdu_list); nfapi_free_tx_req_pdu_list(dl_config_req_tx_req->tx_req_pdu_list);
dl_config_req_tx_req->tx_req_pdu_list = NULL; dl_config_req_tx_req->tx_req_pdu_list = NULL;
free(dl_config_req_tx_req->dl_config_req); free(dl_config_req_tx_req->dl_config_req);
dl_config_req_tx_req->dl_config_req = NULL; dl_config_req_tx_req->dl_config_req = NULL;
free(dl_config_req_tx_req); free(dl_config_req_tx_req);
dl_config_req_tx_req = NULL; dl_config_req_tx_req = NULL;
} }
@@ -1315,8 +1296,8 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
free(hi_dci0_req); free(hi_dci0_req);
hi_dci0_req = NULL; hi_dci0_req = NULL;
} }
if (!sent_any)
{ if (!sent_any) {
send_standalone_dummy(); send_standalone_dummy();
} }
} }
@@ -1350,8 +1331,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
{
#if 0 // TODO: doesn't currently compile, obviated by multi-ue proxy #if 0 // TODO: doesn't currently compile, obviated by multi-ue proxy
thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L); thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L);
// for multipule UE's L2-emulator // for multipule UE's L2-emulator
@@ -1377,7 +1357,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0]; proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0];
phy_stub_ticking->num_single_thread[ue_thread_id] = -1; phy_stub_ticking->num_single_thread[ue_thread_id] = -1;
UE = rtd->UE; UE = rtd->UE;
UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t)); UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t));
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_rx_indication_pdu_t)); UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_rx_indication_pdu_t));
UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
@@ -1490,18 +1469,22 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
if (dl_config_req && tx_req_pdu_list) { if (dl_config_req && tx_req_pdu_list) {
nfapi_dl_config_request_body_t *dl_config_req_body = &dl_config_req->dl_config_request_body; nfapi_dl_config_request_body_t *dl_config_req_body = &dl_config_req->dl_config_request_body;
for (int i = 0; i < dl_config_req_body->number_pdu; ++i) { for (int i = 0; i < dl_config_req_body->number_pdu; ++i) {
nfapi_dl_config_request_pdu_t *pdu = &dl_config_req_body->dl_config_pdu_list[i]; nfapi_dl_config_request_pdu_t *pdu = &dl_config_req_body->dl_config_pdu_list[i];
if (pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) { if (pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) {
i += 1; i += 1;
AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu, AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu,
"Need PDU following DCI at index %d, but not found\n", "Need PDU following DCI at index %d, but not found\n",
i); i);
nfapi_dl_config_request_pdu_t *dlsch = &dl_config_req_body->dl_config_pdu_list[i]; nfapi_dl_config_request_pdu_t *dlsch = &dl_config_req_body->dl_config_pdu_list[i];
if (dlsch->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { if (dlsch->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) {
LOG_E(MAC, "expected DLSCH PDU at index %d\n", i); LOG_E(MAC, "expected DLSCH PDU at index %d\n", i);
continue; continue;
} }
dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),
NFAPI_SFNSF2SF(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
pdu, pdu,
@@ -1523,6 +1506,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
if (hi_dci0_req) { if (hi_dci0_req) {
nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_body_t *hi_dci0_body = &hi_dci0_req->hi_dci0_request_body;
for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) { for (int i = 0; i < hi_dci0_body->number_of_dci + hi_dci0_body->number_of_hi; i++) {
nfapi_hi_dci0_request_pdu_t *pdu = &hi_dci0_body->hi_dci0_pdu_list[i]; nfapi_hi_dci0_request_pdu_t *pdu = &hi_dci0_body->hi_dci0_pdu_list[i];
hi_dci0_req_UE_MAC(NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), hi_dci0_req_UE_MAC(NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf),
@@ -1592,7 +1576,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD) ) (UE->frame_parms.frame_type == FDD) )
if (UE->mode != loop_through_memory) {
// We make the start of RA between consecutive UEs differ by 20 frames // We make the start of RA between consecutive UEs differ by 20 frames
//if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH && ue_Mod_id == next_Mod_id) { if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH && ue_Mod_id == next_Mod_id) {
@@ -1627,9 +1611,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
if(ul_config_req!=NULL) { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){ if(ul_config_req!=NULL) { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, ue_Mod_id); ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, ue_Mod_id);
} }
}
phy_procedures_UE_SL_RX(UE,proc);
} //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++) } //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++)
phy_stub_ticking->num_single_thread[ue_thread_id] = -1; phy_stub_ticking->num_single_thread[ue_thread_id] = -1;
@@ -1709,6 +1690,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
tx_req_pdu_list[i].segments[j].segment_data = NULL; tx_req_pdu_list[i].segments[j].segment_data = NULL;
} }
} }
tx_req_num_elems = 0; tx_req_num_elems = 0;
free(tx_req_pdu_list); free(tx_req_pdu_list);
tx_req_pdu_list = NULL; tx_req_pdu_list = NULL;
@@ -1752,7 +1734,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
free(UL_INFO); free(UL_INFO);
UL_INFO = NULL; UL_INFO = NULL;
#endif // disabled UE_phy_stub_single_thread_rxn_txnp4 #endif // disabled UE_phy_stub_single_thread_rxn_txnp4
// thread finished // thread finished
free(arg); free(arg);
return NULL; return NULL;
@@ -1767,8 +1748,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
static void *UE_phy_stub_thread_rxn_txnp4(void *arg) static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
{
#if 0 #if 0
thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L); thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L);
module_id_t Mod_id = 0; module_id_t Mod_id = 0;
@@ -1880,7 +1860,6 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg)
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD) ) (UE->frame_parms.frame_type == FDD) )
if (UE->mode != loop_through_memory) {
if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH) ) { if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH) ) {
// check if we have PRACH opportunity // check if we have PRACH opportunity
if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx)) { if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx)) {
@@ -1916,8 +1895,6 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg)
} }
} }
phy_procedures_UE_SL_RX(UE,proc);
}
#endif // disabled #endif // disabled
// thread finished // thread finished
free(arg); free(arg);
@@ -1952,8 +1929,7 @@ void write_dummy(PHY_VARS_UE *UE, openair0_timestamp timestamp) {
1),""); 1),"");
} }
void *UE_thread(void *arg) void *UE_thread(void *arg) {
{
PHY_VARS_UE *UE = (PHY_VARS_UE *) arg; PHY_VARS_UE *UE = (PHY_VARS_UE *) arg;
// int tx_enabled = 0; // int tx_enabled = 0;
int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32))); int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32)));
@@ -1966,10 +1942,11 @@ void *UE_thread(void *arg)
int ret; int ret;
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
if ( threads.main != -1 ) if ( threads.main != -1 )
CPU_SET(threads.main, &cpuset); CPU_SET(threads.main, &cpuset);
init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads");
init_thread(100000, 500000, FIFO_PRIORITY, &cpuset, "UHD Threads");
/* /*
while (sync_var<0) while (sync_var<0)
pthread_cond_wait(&sync_cond, &sync_mutex); pthread_cond_wait(&sync_cond, &sync_mutex);
@@ -2003,6 +1980,7 @@ void *UE_thread(void *arg)
// we shift in time flow because the UE doesn't detect sync when frame alignment is not easy // we shift in time flow because the UE doesn't detect sync when frame alignment is not easy
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&dummy_rx[i][0]; rxp[i] = (void *)&dummy_rx[i][0];
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
rxp, rxp,
@@ -2011,7 +1989,6 @@ void *UE_thread(void *arg)
// grab 10 ms of signal and wakeup synch thread // grab 10 ms of signal and wakeup synch thread
if (UE->mode != loop_through_memory) {
if (IS_SOFTMODEM_RFSIM ) { if (IS_SOFTMODEM_RFSIM ) {
for(int sf=0; sf<10; sf++) { for(int sf=0; sf<10; sf++) {
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
@@ -2035,7 +2012,6 @@ void *UE_thread(void *arg)
UE->frame_parms.samples_per_tti*10, UE->frame_parms.samples_per_tti*10,
UE->frame_parms.nb_antennas_rx), ""); UE->frame_parms.nb_antennas_rx), "");
} }
}
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
instance_cnt_synch = ++UE->proc.instance_cnt_synch; instance_cnt_synch = ++UE->proc.instance_cnt_synch;
@@ -2049,12 +2025,7 @@ void *UE_thread(void *arg)
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
} else { } else {
#if OAISIM
(void)dummy_rx; /* avoid gcc warnings */
usleep(500);
#else
// grab 10 ms of signal into dummy buffer // grab 10 ms of signal into dummy buffer
if (UE->mode != loop_through_memory) {
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&dummy_rx[i][0]; rxp[i] = (void *)&dummy_rx[i][0];
@@ -2065,20 +2036,19 @@ void *UE_thread(void *arg)
rxp, rxp,
UE->frame_parms.samples_per_tti, UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx); UE->frame_parms.nb_antennas_rx);
if (IS_SOFTMODEM_RFSIM ) if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp); write_dummy(UE, timestamp);
} }
} }
#endif
}
} // UE->is_synchronized==0 } // UE->is_synchronized==0
else { else {
if (start_rx_stream==0) { if (start_rx_stream==0) {
start_rx_stream=1; start_rx_stream=1;
if (UE->mode != loop_through_memory) {
if (UE->no_timing_correction==0) { if (UE->no_timing_correction==0) {
LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
while ( UE->rx_offset ) { while ( UE->rx_offset ) {
size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti); size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti);
AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice, AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice,
@@ -2086,8 +2056,10 @@ void *UE_thread(void *arg)
(void **)UE->common_vars.rxdata, (void **)UE->common_vars.rxdata,
s, s,
UE->frame_parms.nb_antennas_rx),""); UE->frame_parms.nb_antennas_rx),"");
if (IS_SOFTMODEM_RFSIM ) if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp); write_dummy(UE, timestamp);
UE->rx_offset-=s; UE->rx_offset-=s;
} }
} }
@@ -2109,9 +2081,6 @@ void *UE_thread(void *arg)
UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0,
UE->frame_parms.nb_antennas_rx),""); UE->frame_parms.nb_antennas_rx),"");
slot_fep(UE,0, 0, 0, 0, 0); slot_fep(UE,0, 0, 0, 0, 0);
} //UE->mode != loop_through_memory
else
rt_sleep_ns(1000*1000);
} else { } else {
sub_frame++; sub_frame++;
sub_frame%=10; sub_frame%=10;
@@ -2130,6 +2099,7 @@ void *UE_thread(void *arg)
pthread_mutex_unlock(&proc->mutex_rxtx); pthread_mutex_unlock(&proc->mutex_rxtx);
} }
usleep(300); usleep(300);
} }
@@ -2139,7 +2109,6 @@ void *UE_thread(void *arg)
if(thread_idx>=RX_NB_TH) if(thread_idx>=RX_NB_TH)
thread_idx = 0; thread_idx = 0;
if (UE->mode != loop_through_memory) {
for (i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+ rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+
UE->frame_parms.nb_prefix_samples0+ UE->frame_parms.nb_prefix_samples0+
@@ -2216,15 +2185,19 @@ void *UE_thread(void *arg)
ret = pthread_mutex_lock(&proc->mutex_rxtx); ret = pthread_mutex_lock(&proc->mutex_rxtx);
} else { } else {
struct timespec tv; struct timespec tv;
if (clock_gettime(CLOCK_REALTIME, &tv) != 0) { if (clock_gettime(CLOCK_REALTIME, &tv) != 0) {
perror("clock_gettime"); perror("clock_gettime");
exit(1); exit(1);
} }
tv.tv_nsec += 10*1000; tv.tv_nsec += 10*1000;
if (tv.tv_nsec >= 1000 * 1000 * 1000) { if (tv.tv_nsec >= 1000 * 1000 * 1000) {
tv.tv_sec++; tv.tv_sec++;
tv.tv_nsec -= 1000 * 1000 * 1000; tv.tv_nsec -= 1000 * 1000 * 1000;
} }
ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv); ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv);
} }
@@ -2259,10 +2232,6 @@ void *UE_thread(void *arg)
T(T_UE_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx)); T(T_UE_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx));
AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0,""); AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0,"");
AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,""); AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,"");
} else {
printf("Processing subframe %d",proc->subframe_rx);
getchar();
}
} // start_rx_stream==1 } // start_rx_stream==1
} // UE->is_synchronized==1 } // UE->is_synchronized==1
} // while !oai_exit } // while !oai_exit
@@ -2283,8 +2252,7 @@ void *UE_thread(void *arg)
* - UE_thread_dlsch_proc_slot1 * - UE_thread_dlsch_proc_slot1
* and the locking between them. * and the locking between them.
*/ */
void init_UE_threads(int inst) void init_UE_threads(int inst) {
{
struct rx_tx_thread_data *rtd; struct rx_tx_thread_data *rtd;
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n"); AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n");
@@ -2339,8 +2307,7 @@ void init_UE_threads(int inst)
* - UE_thread_dlsch_proc_slot1 * - UE_thread_dlsch_proc_slot1
* and the locking between them. * and the locking between them.
*/ */
void init_UE_single_thread_stub(int nb_inst) void init_UE_single_thread_stub(int nb_inst) {
{
struct rx_tx_thread_data *rtd; struct rx_tx_thread_data *rtd;
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
@@ -2368,8 +2335,8 @@ void init_UE_single_thread_stub(int nb_inst)
// In phy_stub_UE mode due to less heavy processing operations we don't need two threads // In phy_stub_UE mode due to less heavy processing operations we don't need two threads
//int nb_threads=RX_NB_TH; //int nb_threads=RX_NB_TH;
int nb_threads=1; int nb_threads=1;
void *(*task_func)(void *); void *(*task_func)(void *);
if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) {
task_func = UE_phy_stub_standalone_pnf_task; task_func = UE_phy_stub_standalone_pnf_task;
} else { } else {
@@ -2413,8 +2380,7 @@ void init_UE_single_thread_stub(int nb_inst)
* - UE_thread_dlsch_proc_slot1 * - UE_thread_dlsch_proc_slot1
* and the locking between them. * and the locking between them.
*/ */
void init_UE_threads_stub(int inst) void init_UE_threads_stub(int inst) {
{
struct rx_tx_thread_data *rtd; struct rx_tx_thread_data *rtd;
PHY_VARS_UE *UE; PHY_VARS_UE *UE;
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n"); AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n");
@@ -2451,8 +2417,7 @@ void init_UE_threads_stub(int inst)
} }
void fill_ue_band_info(void) void fill_ue_band_info(void) {
{
LTE_UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability; LTE_UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability;
int i,j; int i,j;
bands_to_scan.nbands = UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count; bands_to_scan.nbands = UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count;
@@ -2477,8 +2442,7 @@ void fill_ue_band_info(void)
} }
int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue,
openair0_config_t *openair0_cfg) openair0_config_t *openair0_cfg) {
{
int i, CC_id; int i, CC_id;
LTE_DL_FRAME_PARMS *frame_parms; LTE_DL_FRAME_PARMS *frame_parms;
@@ -2520,8 +2484,7 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue,
// playing the role of nfapi-pnf. // playing the role of nfapi-pnf.
//02/02/2018 //02/02/2018
static void *timer_thread( void *param ) static void *timer_thread( void *param ) {
{
thread_top_init("timer_thread",1,870000L,1000000L,1000000L); thread_top_init("timer_thread",1,870000L,1000000L,1000000L);
timer_subframe =9; timer_subframe =9;
timer_frame =1023; timer_frame =1023;
@@ -2647,8 +2610,7 @@ static void *timer_thread( void *param )
} }
int init_timer_thread(void) int init_timer_thread(void) {
{
//PHY_VARS_UE *UE=PHY_vars_UE_g[0]; //PHY_VARS_UE *UE=PHY_vars_UE_g[0];
PHY_VARS_UE *UE=PHY_vars_UE_g[0][0]; PHY_VARS_UE *UE=PHY_vars_UE_g[0][0];
phy_stub_ticking = (SF_ticking *)malloc(sizeof(SF_ticking)); phy_stub_ticking = (SF_ticking *)malloc(sizeof(SF_ticking));
@@ -2670,8 +2632,7 @@ int init_timer_thread(void)
*/ */
int8_t find_dlsch(uint16_t rnti, int8_t find_dlsch(uint16_t rnti,
PHY_VARS_eNB *eNB, PHY_VARS_eNB *eNB,
find_type_t type) find_type_t type) {
{
printf("you cannot read this\n"); printf("you cannot read this\n");
abort(); abort();
} }