Commit b860d76c authored by Laurent THOMAS's avatar Laurent THOMAS

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

parent f2e65371
...@@ -87,7 +87,7 @@ extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *), ...@@ -87,7 +87,7 @@ extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *),
extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP);
int tx_req_num_elems; int tx_req_num_elems;
extern uint16_t sf_ahead; extern uint16_t sf_ahead;
//extern int tx_req_UE_MAC1(); //extern int tx_req_UE_MAC1();
...@@ -176,6 +176,7 @@ PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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,13 +859,11 @@ static void *UE_thread_rxn_txnp4(void *arg) ...@@ -867,13 +859,11 @@ 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) ...@@ -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,14 +940,14 @@ void ue_stub_rx_handler(unsigned int num_bytes, ...@@ -951,14 +940,14 @@ 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);
} }
/*! /*!
* \brief This is the UE thread for RX subframe n and TX subframe n+4. * \brief This is the UE thread for RX subframe n and TX subframe n+4.
...@@ -968,23 +957,21 @@ uint64_t clock_usec(void) ...@@ -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) ...@@ -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) ...@@ -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,72 +1020,77 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) ...@@ -1039,72 +1020,77 @@ 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,
NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf)); NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf));
} }
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) ...@@ -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) ...@@ -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,178 +1156,171 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) ...@@ -1168,178 +1156,171 @@ 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)) {
{ // We make the start of RA between consecutive UEs differ by 20 frames
if (UE->mode != loop_through_memory) //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 &&
// We make the start of RA between consecutive UEs differ by 20 frames is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf))) {
//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) ) { UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH;
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)))
{ LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]);
UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH;
} if (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]); //&& ue_Mod_id == next_Mod_id) {
if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH) next_ra_frame++;
{ //&& ue_Mod_id == next_Mod_id) {
next_ra_frame++; if (next_ra_frame > 500) {
if (next_ra_frame > 500) // 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) {
// check if we have PRACH opportunity // The one working strangely...
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) && 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));
// 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 (prach_resources != NULL) {
PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0, NFAPI_SFNSF2SF(sfn_sf)); LOG_I(MAC, "preamble_received_tar_power: %d\n",
if (prach_resources != NULL) prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER);
{ UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf);
LOG_I(MAC, "preamble_received_tar_power: %d\n", LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER); fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf); sent_any = true;
LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0);
fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
sent_any = true; next_Mod_id = ue_Mod_id + 1;
Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0); //next_ra_frame = (rx_frame + 20)%1000;
UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE; next_ra_frame = 0;
next_Mod_id = ue_Mod_id + 1;
//next_ra_frame = (rx_frame + 20)%1000;
next_ra_frame = 0;
}
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
} }
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
} }
} // mode is PRACH
// 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).
// Generate UL_indications which correspond to UL traffic.
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, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id);
} }
} } // mode is PRACH
phy_procedures_UE_SL_RX(UE, proc); // 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).
else // Generate UL_indications which correspond to UL traffic.
{ if (ul_config_req != NULL) {
LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n", //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); ul_config_req_UE_MAC(ul_config_req, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), ue_Mod_id);
if (ul_config_req != NULL)
{
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));
} }
} }
} //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++)
if (UL_INFO->crc_ind.crc_indication_body.number_of_crcs > 0) { phy_procedures_UE_SL_RX(UE, proc);
//LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf)); } else {
//LOG_I(MAC, "ul_config_req_UE_MAC 2.2, SFN/SF of PNF counter:%d.%d, number_of_crcs: %d \n", timer_frame, timer_subframe, UL_INFO->crc_ind.crc_indication_body.number_of_crcs); LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n",
send_standalone_msg(UL_INFO, UL_INFO->crc_ind.header.message_id); NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
sent_any = true;
//LOG_I(MAC, "ul_config_req_UE_MAC 2.21 \n"); if (ul_config_req != NULL) {
UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0; 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));
}
} }
} //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++)
if (UL_INFO->crc_ind.crc_indication_body.number_of_crcs > 0) {
//LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf));
//LOG_I(MAC, "ul_config_req_UE_MAC 2.2, SFN/SF of PNF counter:%d.%d, number_of_crcs: %d \n", timer_frame, timer_subframe, UL_INFO->crc_ind.crc_indication_body.number_of_crcs);
send_standalone_msg(UL_INFO, UL_INFO->crc_ind.header.message_id);
sent_any = true;
//LOG_I(MAC, "ul_config_req_UE_MAC 2.21 \n");
UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0;
}
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_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);
sent_any = true;
//LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n");
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)); if (UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis > 0) {
//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->cqi_ind.header.message_id);
send_standalone_msg(UL_INFO, UL_INFO->rx_ind.header.message_id); sent_any = true;
sent_any = true; UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0;
}
//LOG_I(MAC, "ul_config_req_UE_MAC 2.31 \n"); if (UL_INFO->harq_ind.harq_indication_body.number_of_harqs > 0) {
UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0; //LOG_D(MAC, "ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
} send_standalone_msg(UL_INFO, UL_INFO->harq_ind.header.message_id);
sent_any = true;
//LOG_I(MAC, "ul_config_req_UE_MAC 2.41 \n");
UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0;
}
if (UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis > 0) { if (UL_INFO->sr_ind.sr_indication_body.number_of_srs > 0) {
send_standalone_msg(UL_INFO, UL_INFO->cqi_ind.header.message_id); //LOG_I(MAC, "ul_config_req_UE_MAC 2.5, SFN/SF of PNF counter:%d.%d, number_of_srs: %d \n", timer_frame, timer_subframe, UL_INFO->sr_ind.sr_indication_body.number_of_srs);
sent_any = true; send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id);
UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0; sent_any = true;
} //LOG_I(MAC, "ul_config_req_UE_MAC 2.51 \n");
UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
}
if (UL_INFO->harq_ind.harq_indication_body.number_of_harqs > 0) { // De-allocate memory of nfapi requests copies before next subframe round
//LOG_D(MAC, "ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs); if (dl_config_req_tx_req != NULL) {
send_standalone_msg(UL_INFO, UL_INFO->harq_ind.header.message_id); if (dl_config_req_tx_req->dl_config_req->vendor_extension != NULL) {
sent_any = true; free(dl_config_req_tx_req->dl_config_req->vendor_extension);
//LOG_I(MAC, "ul_config_req_UE_MAC 2.41 \n"); dl_config_req_tx_req->dl_config_req->vendor_extension = NULL;
UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0;
} }
if (UL_INFO->sr_ind.sr_indication_body.number_of_srs > 0) { if (dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list != NULL) {
//LOG_I(MAC, "ul_config_req_UE_MAC 2.5, SFN/SF of PNF counter:%d.%d, number_of_srs: %d \n", timer_frame, timer_subframe, UL_INFO->sr_ind.sr_indication_body.number_of_srs); free(dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list);
send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id); dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list = NULL;
sent_any = true;
//LOG_I(MAC, "ul_config_req_UE_MAC 2.51 \n");
UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
} }
// De-allocate memory of nfapi requests copies before next subframe round nfapi_free_tx_req_pdu_list(dl_config_req_tx_req->tx_req_pdu_list);
if (dl_config_req_tx_req != NULL) { dl_config_req_tx_req->tx_req_pdu_list = NULL;
if (dl_config_req_tx_req->dl_config_req->vendor_extension != NULL) { free(dl_config_req_tx_req->dl_config_req);
free(dl_config_req_tx_req->dl_config_req->vendor_extension); dl_config_req_tx_req->dl_config_req = NULL;
dl_config_req_tx_req->dl_config_req->vendor_extension = NULL; free(dl_config_req_tx_req);
} dl_config_req_tx_req = NULL;
}
if (dl_config_req_tx_req->dl_config_req->dl_config_request_body.dl_config_pdu_list != NULL) {
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;
}
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;
free(dl_config_req_tx_req->dl_config_req);
dl_config_req_tx_req->dl_config_req = NULL;
free(dl_config_req_tx_req); if (ul_config_req != NULL) {
dl_config_req_tx_req = NULL; if (ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) {
free(ul_config_req->ul_config_request_body.ul_config_pdu_list);
ul_config_req->ul_config_request_body.ul_config_pdu_list = NULL;
} }
if (ul_config_req != NULL) { free(ul_config_req);
if (ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) { ul_config_req = NULL;
free(ul_config_req->ul_config_request_body.ul_config_pdu_list); }
ul_config_req->ul_config_request_body.ul_config_pdu_list = NULL;
}
free(ul_config_req); if (hi_dci0_req != NULL) {
ul_config_req = NULL; if (hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list != NULL) {
free(hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list);
hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = NULL;
} }
if (hi_dci0_req != NULL) { free(hi_dci0_req);
if (hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list != NULL) { hi_dci0_req = NULL;
free(hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list);
hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = NULL;
}
free(hi_dci0_req);
hi_dci0_req = NULL;
}
if (!sent_any)
{
send_standalone_dummy();
}
} }
// Free UL_INFO messages if (!sent_any) {
free(UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list); send_standalone_dummy();
UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = NULL; }
free(UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list); }
UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = NULL;
free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list);
UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL;
free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list);
UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL;
free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list);
UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL;
free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list);
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL;
free(UL_INFO);
UL_INFO = NULL;
// thread finished // Free UL_INFO messages
free(arg); free(UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list);
return NULL; UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = NULL;
free(UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list);
UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = NULL;
free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list);
UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL;
free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list);
UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL;
free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list);
UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL;
free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list);
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL;
free(UL_INFO);
UL_INFO = NULL;
// thread finished
free(arg);
return NULL;
} }
/*! /*!
...@@ -1350,8 +1331,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) ...@@ -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) ...@@ -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;
...@@ -1489,19 +1468,23 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) ...@@ -1489,19 +1468,23 @@ 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,8 +1506,9 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) ...@@ -1523,8 +1506,9 @@ 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),
NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf),
pdu, pdu,
...@@ -1592,44 +1576,41 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) ...@@ -1592,44 +1576,41 @@ 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
//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) {
next_ra_frame++;
if(next_ra_frame > 500) {
// check if we have PRACH opportunity
if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) {
// The one working strangely...
//if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx && Mod_id == (module_id_t) init_ra_UE) ) {
PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx);
if(prach_resources!=NULL ) {
UE_mac_inst[ue_Mod_id].ra_frame = proc->frame_rx;
LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id,proc->frame_tx, proc->subframe_tx);
fill_rach_indication_UE_MAC(ue_Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
Msg1_transmitted(ue_Mod_id, 0, proc->frame_tx, 0);
UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
next_Mod_id = ue_Mod_id + 1;
//next_ra_frame = (proc->frame_rx + 20)%1000;
next_ra_frame = 0;
}
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); // 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[ue_Mod_id].UE_mode[0] == PRACH && ue_Mod_id == next_Mod_id) {
next_ra_frame++;
if(next_ra_frame > 500) {
// check if we have PRACH opportunity
if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) {
// The one working strangely...
//if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx && Mod_id == (module_id_t) init_ra_UE) ) {
PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx);
if(prach_resources!=NULL ) {
UE_mac_inst[ue_Mod_id].ra_frame = proc->frame_rx;
LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id,proc->frame_tx, proc->subframe_tx);
fill_rach_indication_UE_MAC(ue_Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
Msg1_transmitted(ue_Mod_id, 0, proc->frame_tx, 0);
UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
next_Mod_id = ue_Mod_id + 1;
//next_ra_frame = (proc->frame_rx + 20)%1000;
next_ra_frame = 0;
} }
}
} // mode is PRACH
// Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
// 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.
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);
} }
} } // mode is PRACH
phy_procedures_UE_SL_RX(UE,proc); // 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).
// Generate UL_indications which correspond to UL traffic.
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);
}
} //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) ...@@ -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) ...@@ -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,9 +1748,8 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) ...@@ -1767,9 +1748,8 @@ 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;
static __thread int UE_thread_rxtx_retval; static __thread int UE_thread_rxtx_retval;
...@@ -1880,45 +1860,42 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) ...@@ -1880,45 +1860,42 @@ 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)) { PRACH_RESOURCES_t *prach_resources = ue_get_rach(Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx);
PRACH_RESOURCES_t *prach_resources = ue_get_rach(Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx);
if(prach_resources!=NULL) {
if(prach_resources!=NULL) { fill_rach_indication_UE_MAC(Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
fill_rach_indication_UE_MAC(Mod_id, proc->frame_tx,proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); Msg1_transmitted(Mod_id, 0, proc->frame_tx, 0);
Msg1_transmitted(Mod_id, 0, proc->frame_tx, 0); UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE;
UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE;
}
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
} }
} // mode is PRACH
// Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger //ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
// 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. } // mode is PRACH
if(ul_config_req!= NULL && ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) {
//LOG_I(MAC, "UE_phy_stub_thread_rxn_txnp4 ul_config_req is not NULL \n");
ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, Mod_id);
if(ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) { // Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
free(ul_config_req->ul_config_request_body.ul_config_pdu_list); // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
ul_config_req->ul_config_request_body.ul_config_pdu_list = NULL; // Generate UL_indications which correspond to UL traffic.
} if(ul_config_req!= NULL && ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) {
//LOG_I(MAC, "UE_phy_stub_thread_rxn_txnp4 ul_config_req is not NULL \n");
ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, Mod_id);
free(ul_config_req); if(ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL) {
ul_config_req = NULL; free(ul_config_req->ul_config_request_body.ul_config_pdu_list);
} else if(ul_config_req!=NULL) { ul_config_req->ul_config_request_body.ul_config_pdu_list = NULL;
free(ul_config_req);
ul_config_req = NULL;
}
} }
phy_procedures_UE_SL_RX(UE,proc); free(ul_config_req);
ul_config_req = NULL;
} else if(ul_config_req!=NULL) {
free(ul_config_req);
ul_config_req = NULL;
}
} }
#endif // disabled
#endif // disabled
// thread finished // thread finished
free(arg); free(arg);
return NULL; //return &UE_thread_rxtx_retval; return NULL; //return &UE_thread_rxtx_retval;
...@@ -1940,20 +1917,19 @@ void write_dummy(PHY_VARS_UE *UE, openair0_timestamp timestamp) { ...@@ -1940,20 +1917,19 @@ void write_dummy(PHY_VARS_UE *UE, openair0_timestamp timestamp) {
// //
struct complex16 v= {0}; struct complex16 v= {0};
void *samplesVoid[UE->frame_parms.nb_antennas_tx]; void *samplesVoid[UE->frame_parms.nb_antennas_tx];
for ( int i=0; i < UE->frame_parms.nb_antennas_tx; i++) for ( int i=0; i < UE->frame_parms.nb_antennas_tx; i++)
samplesVoid[i]=(void *)&v; samplesVoid[i]=(void *)&v;
AssertFatal( 1 == UE->rfdevice.trx_write_func(&UE->rfdevice, AssertFatal( 1 == UE->rfdevice.trx_write_func(&UE->rfdevice,
timestamp+2*UE->frame_parms.samples_per_tti, timestamp+2*UE->frame_parms.samples_per_tti,
samplesVoid, samplesVoid,
1, 1,
UE->frame_parms.nb_antennas_tx, UE->frame_parms.nb_antennas_tx,
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) ...@@ -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);
...@@ -1996,46 +1973,45 @@ void *UE_thread(void *arg) ...@@ -1996,46 +1973,45 @@ void *UE_thread(void *arg)
int instance_cnt_synch = UE->proc.instance_cnt_synch; int instance_cnt_synch = UE->proc.instance_cnt_synch;
int is_synchronized = UE->is_synchronized; int is_synchronized = UE->is_synchronized;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
if (is_synchronized == 0) { if (is_synchronized == 0) {
if (instance_cnt_synch < 0) { // we can invoke the synch if (instance_cnt_synch < 0) { // we can invoke the synch
// 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,
&timestamp, UE->rfdevice.trx_read_func(&UE->rfdevice,
rxp, &timestamp,
UE->frame_parms.samples_per_tti/2, rxp,
UE->frame_parms.nb_antennas_rx); UE->frame_parms.samples_per_tti/2,
UE->frame_parms.nb_antennas_rx);
// 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++) rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf];
rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf];
AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice,
AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice, &timestamp,
&timestamp, 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), ""); write_dummy(UE, timestamp);
write_dummy(UE, timestamp); }
} } else {
} else { 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 *)&UE->common_vars.rxdata[i][0];
rxp[i] = (void *)&UE->common_vars.rxdata[i][0];
AssertFatal( UE->frame_parms.samples_per_tti*10 ==
AssertFatal( UE->frame_parms.samples_per_tti*10 == UE->rfdevice.trx_read_func(&UE->rfdevice,
UE->rfdevice.trx_read_func(&UE->rfdevice, &timestamp,
&timestamp, rxp,
rxp, 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,69 +2025,62 @@ void *UE_thread(void *arg) ...@@ -2049,69 +2025,62 @@ 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];
for (int sf=0; sf<10; sf++) {
for (int sf=0; sf<10; sf++) { // printf("Reading dummy sf %d\n",sf);
// printf("Reading dummy sf %d\n",sf); UE->rfdevice.trx_read_func(&UE->rfdevice,
UE->rfdevice.trx_read_func(&UE->rfdevice, &timestamp,
&timestamp, 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 ) {
size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti);
AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
(void **)UE->common_vars.rxdata,
s,
UE->frame_parms.nb_antennas_rx),"");
if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp);
UE->rx_offset-=s;
}
}
UE->rx_offset=0; while ( UE->rx_offset ) {
UE->time_sync_cell=0; size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti);
AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
(void **)UE->common_vars.rxdata,
s,
UE->frame_parms.nb_antennas_rx),"");
//UE->proc.proc_rxtx[0].frame_rx++; if (IS_SOFTMODEM_RFSIM )
//UE->proc.proc_rxtx[1].frame_rx++; write_dummy(UE, timestamp);
for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->proc.proc_rxtx[th_id].frame_rx++; UE->rx_offset-=s;
} }
}
// read in first symbol UE->rx_offset=0;
AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 == UE->time_sync_cell=0;
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, //UE->proc.proc_rxtx[0].frame_rx++;
(void **)UE->common_vars.rxdata, //UE->proc.proc_rxtx[1].frame_rx++;
UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->frame_parms.nb_antennas_rx),""); UE->proc.proc_rxtx[th_id].frame_rx++;
slot_fep(UE,0, 0, 0, 0, 0); }
} //UE->mode != loop_through_memory
else // read in first symbol
rt_sleep_ns(1000*1000); AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
(void **)UE->common_vars.rxdata,
UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0,
UE->frame_parms.nb_antennas_rx),"");
slot_fep(UE,0, 0, 0, 0, 0);
} else { } else {
sub_frame++; sub_frame++;
sub_frame%=10; sub_frame%=10;
...@@ -2130,7 +2099,8 @@ void *UE_thread(void *arg) ...@@ -2130,7 +2099,8 @@ void *UE_thread(void *arg)
pthread_mutex_unlock(&proc->mutex_rxtx); pthread_mutex_unlock(&proc->mutex_rxtx);
} }
usleep(300);
usleep(300);
} }
LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]); LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]);
...@@ -2139,130 +2109,129 @@ void *UE_thread(void *arg) ...@@ -2139,130 +2109,129 @@ 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+ sub_frame*UE->frame_parms.samples_per_tti];
sub_frame*UE->frame_parms.samples_per_tti];
for (i=0; i<UE->frame_parms.nb_antennas_tx; i++)
txp[i] = (void *)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti];
int readBlockSize, writeBlockSize; for (i=0; i<UE->frame_parms.nb_antennas_tx; i++)
txp[i] = (void *)&UE->common_vars.txdata[i][((sub_frame+2)%10)*UE->frame_parms.samples_per_tti];
if (sub_frame<9) { int readBlockSize, writeBlockSize;
readBlockSize=UE->frame_parms.samples_per_tti;
writeBlockSize=UE->frame_parms.samples_per_tti;
} else {
// set TO compensation to zero
UE->rx_offset_diff = 0;
// compute TO compensation that should be applied for this frame if (sub_frame<9) {
readBlockSize=UE->frame_parms.samples_per_tti;
writeBlockSize=UE->frame_parms.samples_per_tti;
} else {
// set TO compensation to zero
UE->rx_offset_diff = 0;
if (UE->no_timing_correction == 0) { // compute TO compensation that should be applied for this frame
if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti &&
UE->rx_offset > 0 )
UE->rx_offset_diff = -1 ;
if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti && if (UE->no_timing_correction == 0) {
UE->rx_offset < 10*UE->frame_parms.samples_per_tti ) if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti &&
UE->rx_offset_diff = 1; UE->rx_offset > 0 )
} UE->rx_offset_diff = -1 ;
LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset); if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti &&
readBlockSize=UE->frame_parms.samples_per_tti - UE->rx_offset < 10*UE->frame_parms.samples_per_tti )
UE->frame_parms.ofdm_symbol_size - UE->rx_offset_diff = 1;
UE->frame_parms.nb_prefix_samples0 -
UE->rx_offset_diff;
writeBlockSize=UE->frame_parms.samples_per_tti -
UE->rx_offset_diff;
} }
AssertFatal(readBlockSize == LOG_D(PHY,"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,sub_frame,UE->rx_offset_diff,UE->rx_offset);
UE->rfdevice.trx_read_func(&UE->rfdevice, readBlockSize=UE->frame_parms.samples_per_tti -
&timestamp, UE->frame_parms.ofdm_symbol_size -
rxp, UE->frame_parms.nb_prefix_samples0 -
readBlockSize, UE->rx_offset_diff;
UE->frame_parms.nb_antennas_rx),""); writeBlockSize=UE->frame_parms.samples_per_tti -
AssertFatal( writeBlockSize == UE->rx_offset_diff;
UE->rfdevice.trx_write_func(&UE->rfdevice, }
timestamp+
(2*UE->frame_parms.samples_per_tti) -
UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 -
openair0_cfg[0].tx_sample_advance,
txp,
writeBlockSize,
UE->frame_parms.nb_antennas_tx,
1),"");
if( sub_frame==9) {
// read in first symbol of next frame and adjust for timing drift
int first_symbols=writeBlockSize-readBlockSize;
if ( first_symbols > 0 )
AssertFatal(first_symbols ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp1,
(void **)UE->common_vars.rxdata,
first_symbols,
UE->frame_parms.nb_antennas_rx),"");
if ( first_symbols <0 )
LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
}
/* no timeout in IS_SOFTMODEM_RFSIM mode */ AssertFatal(readBlockSize ==
if (IS_SOFTMODEM_RFSIM) { UE->rfdevice.trx_read_func(&UE->rfdevice,
ret = pthread_mutex_lock(&proc->mutex_rxtx); &timestamp,
} else { rxp,
struct timespec tv; readBlockSize,
if (clock_gettime(CLOCK_REALTIME, &tv) != 0) { UE->frame_parms.nb_antennas_rx),"");
perror("clock_gettime"); AssertFatal( writeBlockSize ==
exit(1); UE->rfdevice.trx_write_func(&UE->rfdevice,
} timestamp+
tv.tv_nsec += 10*1000; (2*UE->frame_parms.samples_per_tti) -
if (tv.tv_nsec >= 1000 * 1000 * 1000) { UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 -
tv.tv_sec++; openair0_cfg[0].tx_sample_advance,
tv.tv_nsec -= 1000 * 1000 * 1000; txp,
} writeBlockSize,
ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv); UE->frame_parms.nb_antennas_tx,
1),"");
if( sub_frame==9) {
// read in first symbol of next frame and adjust for timing drift
int first_symbols=writeBlockSize-readBlockSize;
if ( first_symbols > 0 )
AssertFatal(first_symbols ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp1,
(void **)UE->common_vars.rxdata,
first_symbols,
UE->frame_parms.nb_antennas_rx),"");
if ( first_symbols <0 )
LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
}
/* no timeout in IS_SOFTMODEM_RFSIM mode */
if (IS_SOFTMODEM_RFSIM) {
ret = pthread_mutex_lock(&proc->mutex_rxtx);
} else {
struct timespec tv;
if (clock_gettime(CLOCK_REALTIME, &tv) != 0) {
perror("clock_gettime");
exit(1);
} }
// operate on thread sf mod 2 tv.tv_nsec += 10*1000;
if (ret != 0) {
if (ret == ETIMEDOUT) { if (tv.tv_nsec >= 1000 * 1000 * 1000) {
LOG_E(PHY,"Missed real time\n"); tv.tv_sec++;
continue; tv.tv_nsec -= 1000 * 1000 * 1000;
} else {
LOG_E(PHY,"System error %s (%d)\n",strerror(errno),errno);
abort();
}
} }
// usleep(3000); ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv);
if(sub_frame == 0) { }
//UE->proc.proc_rxtx[0].frame_rx++;
//UE->proc.proc_rxtx[1].frame_rx++; // operate on thread sf mod 2
for (th_id=0; th_id < RX_NB_TH; th_id++) { if (ret != 0) {
UE->proc.proc_rxtx[th_id].frame_rx++; if (ret == ETIMEDOUT) {
} LOG_E(PHY,"Missed real time\n");
continue;
} else {
LOG_E(PHY,"System error %s (%d)\n",strerror(errno),errno);
abort();
} }
}
proc->subframe_rx=sub_frame; // usleep(3000);
proc->subframe_tx=(sub_frame+4)%10; if(sub_frame == 0) {
proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0); //UE->proc.proc_rxtx[0].frame_rx++;
proc->timestamp_tx = timestamp+ //UE->proc.proc_rxtx[1].frame_rx++;
(4*UE->frame_parms.samples_per_tti)- for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0; UE->proc.proc_rxtx[th_id].frame_rx++;
proc->instance_cnt_rxtx++; }
LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,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_mutex_unlock(&proc->mutex_rxtx) ==0,"");
} else {
printf("Processing subframe %d",proc->subframe_rx);
getchar();
} }
proc->subframe_rx=sub_frame;
proc->subframe_tx=(sub_frame+4)%10;
proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
proc->timestamp_tx = timestamp+
(4*UE->frame_parms.samples_per_tti)-
UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0;
proc->instance_cnt_rxtx++;
LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,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_mutex_unlock(&proc->mutex_rxtx) ==0,"");
} // 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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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 ) ...@@ -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) ...@@ -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();
} }
......
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