Commit 28c3205f authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/fix-rfsim-ue4G-sync' into integration_2022_wk17

Conflicts:
	targets/ARCH/rfsimulator/simulator.c
parents 327ccc08 2373b021
......@@ -51,7 +51,6 @@
#define CONFIG_HLP_UEFO "set UE to enable estimation and compensation of frequency offset\n"
#define CONFIG_HLP_DUMPFRAME "dump UE received frame to rxsig_frame0.dat and exit\n"
#define CONFIG_HLP_DLSHIFT "dynamic shift for LLR compuation for TM3/4 (default 0)\n"
#define CONFIG_HLP_UELOOP "get softmodem (UE) to loop through memory instead of acquiring from HW\n"
#define CONFIG_HLP_PHYTST "test UE phy layer, mac disabled\n"
#define CONFIG_HLP_DORA "test gNB and UE with RA procedures\n"
#define CONFIG_HLP_DMAMAP "sets flag for improved EXMIMO UE performance\n"
......
......@@ -573,17 +573,7 @@ static void UE_synch(void *arg) {
openair0_cfg[UE->rf_map.card].rx_freq[0],
openair0_cfg[UE->rf_map.card].tx_freq[0]);
if (UE->mode != loop_through_memory) {
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
//UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]);
//UE->rfdevice.trx_stop_func(&UE->rfdevice);
// sleep(1);
/*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {
LOG_E(HW,"Could not start the device\n");
oai_exit=1;
}*/
}
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
if (UE->UE_scan_carrier == 1) {
UE->UE_scan_carrier = 0;
} else {
......@@ -602,8 +592,7 @@ static void UE_synch(void *arg) {
LOG_I(PHY, "Initial sync failed: trying carrier off %d Hz\n", freq_offset);
if (UE->mode != loop_through_memory)
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
}
break;
......@@ -648,7 +637,7 @@ void processSlotTX(void *arg) {
stop_meas(&UE->ue_ul_indication_stats);
}
if ((UE->mode != loop_through_memory) && (rxtxD->ue_sched_mode != NOT_PUSCH)) {
if (rxtxD->ue_sched_mode != NOT_PUSCH) {
phy_procedures_nrUE_TX(UE,proc,0);
}
}
......@@ -738,9 +727,10 @@ void processSlotRX(void *arg) {
void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) {
void *dummy_tx[UE->frame_parms.nb_antennas_tx];
int16_t dummy_tx_data[UE->frame_parms.nb_antennas_tx][2*writeBlockSize]; // 2 because the function we call use pairs of int16_t implicitly as complex numbers
memset(dummy_tx_data, 0, sizeof(dummy_tx_data));
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
dummy_tx[i]=malloc16_clear(writeBlockSize*4);
dummy_tx[i]=dummy_tx_data[i];
AssertFatal( writeBlockSize ==
UE->rfdevice.trx_write_func(&UE->rfdevice,
......@@ -750,8 +740,6 @@ void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockS
UE->frame_parms.nb_antennas_tx,
4),"");
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
free(dummy_tx[i]);
}
void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, bool toTrash) {
......@@ -793,7 +781,7 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
*timestamp += UE->frame_parms.get_samples_per_slot(1,&UE->frame_parms);
for ( int size=UE->rx_offset ; size > 0 ; size -= UE->frame_parms.samples_per_subframe ) {
int unitTransfer=size>UE->frame_parms.samples_per_subframe ? UE->frame_parms.samples_per_subframe : size ;
// we write before read becasue gNB waits for UE to write and both executions halt
// we write before read because gNB waits for UE to write and both executions halt
// this happens here as the read size is samples_per_subframe which is very much larger than samp_per_slot
if (IS_SOFTMODEM_RFSIM) dummyWrite(UE,*timestamp, unitTransfer);
AssertFatal(unitTransfer ==
......
......@@ -53,7 +53,6 @@ extern "C"
#define CONFIG_HLP_DUMPFRAME "dump UE received frame to rxsig_frame0.dat and exit\n"
#define CONFIG_HLP_UELOOP "get softmodem (UE) to loop through memory instead of acquiring from HW\n"
#define CONFIG_HLP_PHYTST "test UE phy layer, mac disabled\n"
#define CONFIG_HLP_DORA "test gNB and UE with RA procedures\n"
#define CONFIG_HLP_SA "run gNB in standalone mode\n"
......
......@@ -54,7 +54,6 @@ typedef enum {
no_L2_connect=5,
calib_prach_tx=6,
rx_dump_frame=7,
loop_through_memory=8
} runmode_t;
/*! \brief Extension Type */
......
......@@ -833,7 +833,6 @@ typedef struct {
pthread_mutex_t timer_mutex;
pthread_cond_t timer_cond;
int instance_cnt_timer;
/// RF and Interface devices per CC
openair0_device rfdevice;
......
......@@ -587,9 +587,6 @@ typedef struct gNB_L1_proc_t_s {
int instance_cnt_te;
/// \internal This variable is protected by \ref mutex_prach.
int instance_cnt_prach;
// instance count for over-the-air gNB synchronization
int instance_cnt_synch;
/// \internal This variable is protected by \ref mutex_asynch_rxtx.
int instance_cnt_asynch_rxtx;
/// pthread structure for eNB single processing thread
......
......@@ -4870,109 +4870,3 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,
LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx);
return (0);
}
void phy_procedures_UE_lte(PHY_VARS_UE *ue,
UE_rxtx_proc_t *proc,
uint8_t eNB_id,
uint8_t abstraction_flag,
uint8_t do_pdcch_flag,
runmode_t mode) {
MessageDef *msg_p;
int result;
int frame_rx = proc->frame_rx;
int frame_tx = proc->frame_tx;
int subframe_rx = proc->subframe_rx;
int subframe_tx = proc->subframe_tx;
UE_L2_STATE_t ret;
int slot;
if (ue->mac_enabled == 0) {
ue->UE_mode[eNB_id]=PUSCH;
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,1);
if ( LOG_DEBUGFLAG(UE_TIMING)) {
start_meas(&ue->phy_proc[ue->current_thread_id[subframe_rx]]);
}
do {
// Checks if a message has been sent to PHY sub-task
itti_poll_msg (TASK_PHY_UE, &msg_p);
if (msg_p != NULL) {
switch (ITTI_MSG_ID(msg_p)) {
case PHY_FIND_CELL_REQ:
LOG_I(PHY, "[UE ] Received %s\n", ITTI_MSG_NAME (msg_p));
/* TODO process the message */
break;
default:
LOG_E(PHY, "[UE %ld] Received unexpected message %s\n", ITTI_MSG_DESTINATION_INSTANCE (msg_p), ITTI_MSG_NAME (msg_p));
break;
}
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
}
} while(msg_p != NULL);
for (slot=0; slot<2; slot++) {
if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_UL)||
(ue->frame_parms.frame_type == FDD)) {
phy_procedures_UE_TX(ue,proc,eNB_id,abstraction_flag,mode);
}
if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_DL) ||
(ue->frame_parms.frame_type == FDD)) {
phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode);
}
if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_S) &&
(slot==1)) {
phy_procedures_UE_S_TX(ue,eNB_id,abstraction_flag);
}
if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_S) &&
(slot==0)) {
phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode);
}
if (ue->mac_enabled==1) {
if (slot==0) {
//LOG_I(PHY,"[UE %d] Frame %d, subframe %d, star ue_scheduler\n", ue->Mod_id,frame_rx,subframe_tx);
ret = ue_scheduler(ue->Mod_id,
frame_rx,
subframe_rx,
frame_tx,
subframe_tx,
subframe_select(&ue->frame_parms,subframe_tx),
eNB_id,
0/*FIXME CC_id*/);
if (ret == CONNECTION_LOST) {
LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, returning to PRACH\n",ue->Mod_id,
frame_rx,subframe_tx);
ue->UE_mode[eNB_id] = PRACH;
// mac_xface->macphy_exit("Connection lost");
} else if (ret == PHY_RESYNCH) {
LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, trying to resynch\n",
ue->Mod_id,
frame_rx,subframe_tx);
ue->UE_mode[eNB_id] = RESYNCH;
// mac_xface->macphy_exit("Connection lost");
} else if (ret == PHY_HO_PRACH) {
LOG_I(PHY,"[UE %d] Frame %d, subframe %d, return to PRACH and perform a contention-free access\n",
ue->Mod_id,frame_rx,subframe_tx);
ue->UE_mode[eNB_id] = PRACH;
}
}
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,0);
if (LOG_DEBUGFLAG(UE_TIMING)) {
stop_meas(&ue->phy_proc[ue->current_thread_id[subframe_rx]]);
}
} // slot
}
......@@ -3175,7 +3175,8 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index,
const size_t num_plmn_data = sizeof(plmn_data) / sizeof(plmn_data[0]);
for (size_t plmn_ind = 0;; ++plmn_ind) {
if (plmn_ind == num_plmn_data) {
LOG_E( RRC, "Did not find name from internal table for %u %u\n", mcc, mnc);
LOG_W( RRC, "Did not find operator name from internal table for MCC %0*d, MNC %0*d\n",
mccdigits, mcc, mncdigits, mnc);
break;
}
if ((plmn_data[plmn_ind].mcc == mcc) && (plmn_data[plmn_ind].mnc == mnc)) {
......
......@@ -117,7 +117,7 @@ typedef struct buffer_s {
typedef struct {
int listen_sock, epollfd;
openair0_timestamp nextTimestamp;
openair0_timestamp nextRxTstamp;
openair0_timestamp lastWroteTS;
uint64_t typeStamp;
char *ip;
......@@ -196,7 +196,7 @@ static void removeCirBuf(rfsimulator_state_t *bridge, int sock) {
free(bridge->buf[sock].circularBuf);
// Fixme: no free_channel_desc_scm(bridge->buf[sock].channel_model) implemented
// a lot of mem leaks
free(bridge->buf[sock].channel_model);
//free(bridge->buf[sock].channel_model);
memset(&bridge->buf[sock], 0, sizeof(buffer_t));
bridge->buf[sock].conn_sock=-1;
}
......@@ -429,8 +429,6 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp
if (!alreadyLocked)
pthread_mutex_lock(&Sockmutex);
LOG_D(HW,"sending %d samples at time: %ld\n", nsamps, timestamp);
for (int i=0; i<FD_SETSIZE; i++) {
buffer_t *b=&t->buf[i];
......@@ -549,14 +547,14 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
(t->typeStamp == ENB_MAGICDL && b->th.magic==UE_MAGICDL), "Socket Error in protocol");
b->headerMode=false;
if ( t->nextTimestamp == 0 ) { // First block in UE, resync with the eNB current TS
t->nextTimestamp=b->th.timestamp> nsamps_for_initial ?
if ( t->nextRxTstamp == 0 ) { // First block in UE, resync with the eNB current TS
t->nextRxTstamp=b->th.timestamp> nsamps_for_initial ?
b->th.timestamp - nsamps_for_initial :
0;
b->lastReceivedTS=b->th.timestamp> nsamps_for_initial ?
b->th.timestamp :
nsamps_for_initial;
LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp);
LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextRxTstamp);
b->trashingPacket=true;
} else if ( b->lastReceivedTS < b->th.timestamp) {
int nbAnt= b->th.nbAnt;
......@@ -623,7 +621,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
}
rfsimulator_state_t *t = device->priv;
LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps);
LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextRxTstamp+nsamps);
// deliver data from received data
// check if a UE is connected
int first_sock;
......@@ -634,54 +632,22 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
if ( first_sock == FD_SETSIZE ) {
// no connected device (we are eNB, no UE is connected)
if ( t->nextTimestamp == 0)
if ( t->nextRxTstamp == 0)
LOG_W(HW,"No connected device, generating void samples...\n");
if (!flushInput(t, 10, nsamps)) {
for (int x=0; x < nbAnt; x++)
memset(samplesVoid[x],0,sampleToByte(nsamps,1));
t->nextTimestamp+=nsamps;
t->nextRxTstamp+=nsamps;
if ( ((t->nextTimestamp/nsamps)%100) == 0)
LOG_D(HW,"No UE, Generated void samples for Rx: %ld\n", t->nextTimestamp);
if ( ((t->nextRxTstamp/nsamps)%100) == 0)
LOG_D(HW,"No UE, Generated void samples for Rx: %ld\n", t->nextRxTstamp);
*ptimestamp = t->nextTimestamp-nsamps;
*ptimestamp = t->nextRxTstamp-nsamps;
return nsamps;
}
} else {
pthread_mutex_lock(&Sockmutex);
if ( t->nextTimestamp > 0 && t->lastWroteTS < t->nextTimestamp) {
pthread_mutex_unlock(&Sockmutex);
usleep(10000);
pthread_mutex_lock(&Sockmutex);
if ( t->lastWroteTS < t->nextTimestamp ) {
// Assuming Tx is not done fully in another thread
// We can never write is the past from the received time
// So, the node perform receive but will never write these symbols
// let's tell this to the opposite node
// We send timestamp for nb samples required
// assuming this should have been done earlier if a Tx would exist
pthread_mutex_unlock(&Sockmutex);
c16_t v= {0};
void *dummyS[t->tx_num_channels];
for ( int i=0; i < t->tx_num_channels; i++)
dummyS[i]=(void *)&v;
LOG_I(HW, "No samples Tx occured, so we send 1 sample to notify it: Tx:%lu, Rx:%lu\n",
t->lastWroteTS, t->nextTimestamp);
rfsimulator_write_internal(t, t->nextTimestamp,
dummyS, 1,
t->tx_num_channels, 1, true);
} else {
pthread_mutex_unlock(&Sockmutex);
LOG_W(HW, "trx_write came from another thread\n");
}
} else
pthread_mutex_unlock(&Sockmutex);
bool have_to_wait;
......@@ -692,7 +658,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
buffer_t *b=&t->buf[sock];
if ( b->circularBuf )
if ( t->nextTimestamp+nsamps > b->lastReceivedTS ) {
if ( t->nextRxTstamp+nsamps > b->lastReceivedTS ) {
have_to_wait=true;
break;
}
......@@ -701,7 +667,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
if (have_to_wait)
/*printf("Waiting on socket, current last ts: %ld, expected at least : %ld\n",
ptr->lastReceivedTS,
t->nextTimestamp+nsamps);
t->nextRxTstamp+nsamps);
*/
flushInput(t, 3, nsamps);
} while (have_to_wait);
......@@ -732,7 +698,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
a,
ptr->channel_model,
nsamps,
t->nextTimestamp,
t->nextRxTstamp,
CirSize
);
else { // no channel modeling
......@@ -747,8 +713,8 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
//LOG_I(HW, "nbAnt_tx %d\n",nbAnt_tx);
for (int i=0; i < nsamps; i++) {//loop over nsamps
for (int a_tx=0; a_tx<nbAnt_tx; a_tx++) { //sum up signals from nbAnt_tx antennas
out[i].r += (short)(ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]);
out[i].i += (short)(ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]);
out[i].r += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]);
out[i].i += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]);
} // end for a_tx
} // end for i (number of samps)
} // end of no channel modeling
......@@ -756,11 +722,11 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
}
}
*ptimestamp = t->nextTimestamp; // return the time of the first sample
t->nextTimestamp+=nsamps;
*ptimestamp = t->nextRxTstamp; // return the time of the first sample
t->nextRxTstamp+=nsamps;
LOG_D(HW,"Rx to upper layer: %d from %ld to %ld, energy in first antenna %d\n",
nsamps,
*ptimestamp, t->nextTimestamp,
*ptimestamp, t->nextRxTstamp,
signal_energy(samplesVoid[0], nsamps));
return nsamps;
}
......
......@@ -733,7 +733,7 @@ void tx_rf(RU_t *ru,
int sf_extension = 0;
if ((SF_type == SF_DL) ||
(SF_type == SF_S)) {
(SF_type == SF_S) ) {
int siglen=fp->samples_per_tti,flags=1;
if (SF_type == SF_S) {
......@@ -831,6 +831,23 @@ void tx_rf(RU_t *ru,
late_control=STATE_BURST_TERMINATE;
LOG_E(PHY,"TX : Timeout (sent %d/%d) state =%d\n",txs, siglen,late_control);
}
} else if (IS_SOFTMODEM_RFSIM ) {
// in case of rfsim, we always enable tx because we need to feed rx of the opposite side
// we write 1 single I/Q sample to trigger Rx (rfsim will fill gaps with 0 I/Q)
void *dummy_tx[ru->frame_parms->nb_antennas_tx];
int16_t dummy_tx_data[ru->frame_parms->nb_antennas_tx][2]; // 2 because the function we call use pairs of int16_t implicitly as complex numbers
memset(dummy_tx_data,0,sizeof(dummy_tx_data));
for (int i=0; i<ru->frame_parms->nb_antennas_tx; i++)
dummy_tx[i]= dummy_tx_data[i];
AssertFatal( 1 ==
ru->rfdevice.trx_write_func(&ru->rfdevice,
timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension,
dummy_tx,
1,
ru->frame_parms->nb_antennas_tx,
4),"");
}
}
......
......@@ -49,7 +49,6 @@
{"debug-ue-prach", CONFIG_HLP_DBGUEPR, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \
{"no-L2-connect", CONFIG_HLP_NOL2CN, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \
{"calib-prach-tx", CONFIG_HLP_CALPRACH, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \
{"loop-memory", CONFIG_HLP_UELOOP, 0, strptr:&loopfile, defstrval:"iqs.in", TYPE_STRING,0}, \
{"ue-dump-frame", CONFIG_HLP_DUMPFRAME, PARAMFLAG_BOOL, iptr:&dumpframe, defintval:0, TYPE_INT, 0}, \
}
#define CMDLINE_CALIBUERX_IDX 0
......
......@@ -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);
int tx_req_num_elems;
int tx_req_num_elems;
extern uint16_t sf_ahead;
//extern int tx_req_UE_MAC1();
......@@ -173,6 +173,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));
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
memcpy(&(ue->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS));
}
......@@ -201,8 +202,7 @@ void init_thread(int sched_runtime,
int sched_deadline,
int sched_fifo,
cpu_set_t *cpuset,
char *name)
{
char *name) {
#ifdef DEADLINE_SCHEDULER
if (sched_runtime!=0) {
......@@ -263,8 +263,7 @@ void init_UE(int nb_inst,
runmode_t mode,
int rxgain,
int txpowermax,
LTE_DL_FRAME_PARMS *fp0)
{
LTE_DL_FRAME_PARMS *fp0) {
PHY_VARS_UE *UE;
int inst;
int ret;
......@@ -280,9 +279,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 *));
LOG_I(PHY,"Allocating UE context %d\n",inst);
PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0);
// turn off timing control loop in UE
PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction;
UE = PHY_vars_UE_g[inst][0];
......@@ -359,7 +356,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]);
init_UE_threads(inst);
ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]);
if (ret !=0) {
......@@ -382,8 +378,7 @@ void init_UE(int nb_inst,
void init_UE_stub_single_thread(int nb_inst,
int eMBMS_active,
int uecap_xer_in,
char *emul_iface)
{
char *emul_iface) {
int 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,
......@@ -408,24 +403,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_rx_port = 3212 + ue_idx * 2;
ue_init_standalone_socket(standalone_tx_port, standalone_rx_port);
pthread_t thread;
if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) {
LOG_E(MAC, "pthread_create failed for calling ue_standalone_pnf_task");
}
pthread_setname_np(thread, "oai:ue-stand");
}
void init_UE_stub(int nb_inst,
int eMBMS_active,
int uecap_xer_in,
char *emul_iface)
{
char *emul_iface) {
int inst;
LOG_I(PHY,"UE : Calling Layer 2 for initialization\n");
l2_init_ue(eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
......@@ -459,8 +453,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.
*/
static void *UE_thread_synch(void *arg)
{
static void *UE_thread_synch(void *arg) {
static int UE_thread_synch_retval;
int i ;
PHY_VARS_UE *UE = (PHY_VARS_UE *) arg;
......@@ -475,6 +468,7 @@ static void *UE_thread_synch(void *arg)
printf("UE_thread_sync in with PHY_vars_UE %p\n",arg);
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
if ( threads.sync != -1 )
CPU_SET(threads.sync, &cpuset);
......@@ -754,8 +748,7 @@ static void *UE_thread_synch(void *arg)
* \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.
*/
const char *get_connectionloss_errstr(int errcode)
{
const char *get_connectionloss_errstr(int errcode) {
switch (errcode) {
case CONNECTION_LOST:
return "RRC Connection lost, returning to PRACH";
......@@ -770,8 +763,7 @@ const char *get_connectionloss_errstr(int errcode)
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;
struct rx_tx_thread_data *rtd = arg;
UE_rxtx_proc_t *proc = rtd->proc;
......@@ -864,13 +856,11 @@ static void *UE_thread_rxn_txnp4(void *arg)
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(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) &&
(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--;
......@@ -892,8 +882,7 @@ static void *UE_thread_rxn_txnp4(void *arg)
unsigned int emulator_absSF;
void ue_stub_rx_handler(unsigned int num_bytes,
char *rx_buffer)
{
char *rx_buffer) {
PHY_VARS_UE *UE;
UE = PHY_vars_UE_g[0][0];
UE_tport_t *pdu = (UE_tport_t *)rx_buffer;
......@@ -948,14 +937,14 @@ void ue_stub_rx_handler(unsigned int num_bytes,
}
}
uint64_t clock_usec(void)
{
struct timespec t;
if (clock_gettime(CLOCK_MONOTONIC, &t) == -1)
{
abort();
}
return (uint64_t)t.tv_sec * 1000000 + (t.tv_nsec / 1000);
uint64_t clock_usec(void) {
struct timespec t;
if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) {
abort();
}
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.
......@@ -965,23 +954,21 @@ uint64_t clock_usec(void)
* \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
{
struct sched_param sparam =
{
.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));
}
}
#else
thread_top_init("UE_phy_stub_thread_rxn_txnp4", 1, 870000L, 1000000L, 1000000L);
#endif
// for multipule UE's L2-emulator
//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
......@@ -1001,9 +988,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
PHY_VARS_UE *UE = NULL;
int ret;
proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0];
UE = rtd->UE;
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.number_of_pdus = 0;
......@@ -1016,19 +1001,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_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;
proc->subframe_rx = proc->sub_frame_start;
proc->subframe_tx = -1;
proc->frame_rx = -1;
proc->frame_tx = -1;
// Initializations for nfapi-L2-emulator mode
sync_var = 0;
//PANOS: CAREFUL HERE!
wait_sync("UE_phy_stub_standalone_pnf_task");
int last_sfn_sf = -1;
LOG_I(MAC, "Clearing Queues\n");
reset_queue(&dl_config_req_tx_req_queue);
reset_queue(&ul_config_req_queue);
......@@ -1036,72 +1017,77 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
while (!oai_exit) {
bool sent_any = false;
if (sem_wait(&sfn_semaphore) != 0) {
LOG_E(MAC, "sem_wait() error\n");
abort();
}
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",
sfn_sf >> 4, sfn_sf & 15);
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_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);
LOG_I(MAC, "received from proxy frame %d subframe %d\n",
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
if (ul_config_req != NULL) {
uint8_t ul_num_pdus = ul_config_req->ul_config_request_body.number_of_pdus;
if (ul_num_pdus > 0) {
char *ul_str = nfapi_ul_config_req_to_string(ul_config_req);
LOG_I(MAC, "ul_config_req: %s\n", ul_str);
free(ul_str);
}
}
if (hi_dci0_req != NULL) {
LOG_D(MAC, "hi_dci0_req pdus: %u Frame: %d Subframe: %d\n",
hi_dci0_req->hi_dci0_request_body.number_of_dci,
NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf));
hi_dci0_req->hi_dci0_request_body.number_of_dci,
NFAPI_SFNSF2SFN(hi_dci0_req->sfn_sf), NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf));
}
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_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;
LOG_I(MAC, "(OAI UE) Received dl_config_req from proxy at Frame: %d, Subframe: %d,"
" with number of PDUs: %u\n",
NFAPI_SFNSF2SFN(dl_config_req->sfn_sf), NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
dl_num_pdus);
if (dl_num_pdus > 0) {
char *dl_str = nfapi_dl_config_req_to_string(dl_config_req);
LOG_I(MAC, "dl_config_req: %s\n", 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:
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) {
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) {
i += 1;
AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu,
"Need PDU following DCI at index %d, but not found\n",
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) {
LOG_E(MAC, "expected DLSCH PDU at index %d\n", i);
continue;
}
dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),
NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
pdu,
......@@ -1122,8 +1108,10 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
}
}
}
if (hi_dci0_req) {
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++) {
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),
......@@ -1136,13 +1124,13 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
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 = PHY_vars_UE_g[ue_Mod_id][0];
#if UE_TIMING_TRACE
start_meas(&UE->generic_stat);
#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_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);
if (UE->mac_enabled == 1) {
ret = ue_scheduler(ue_Mod_id,
rx_frame,
......@@ -1165,67 +1153,60 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
// Prepare the future Tx data
if ((subframe_select(&UE->frame_parms, NFAPI_SFNSF2SF(sfn_sf)) == SF_UL) ||
(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 && rx_frame >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
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)))
{
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]);
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, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1)
{
// 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) ) {
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)
{
LOG_I(MAC, "preamble_received_tar_power: %d\n",
prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER);
UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf);
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));
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);
sent_any = true;
Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0);
UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
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->frame_parms.frame_type == FDD)) {
// 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[ue_Mod_id].UE_mode[0] == RA_RESPONSE &&
is_prach_subframe(&UE->frame_parms, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf))) {
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]);
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, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) {
// 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) ) {
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) {
LOG_I(MAC, "preamble_received_tar_power: %d\n",
prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER);
UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf);
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));
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);
sent_any = true;
Msg1_transmitted(ue_Mod_id, 0, NFAPI_SFNSF2SFN(sfn_sf), 0);
UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
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);
}
} // 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);
}
else
{
// 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);
}
} else {
LOG_I(MAC, "Skipping subframe select statement proxy SFN.SF: %d.%d\n",
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
if (ul_config_req != NULL)
{
NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf));
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));
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++)
......@@ -1240,12 +1221,10 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
}
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;
}
......@@ -1258,16 +1237,16 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
if (UL_INFO->harq_ind.harq_indication_body.number_of_harqs > 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;
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->sr_ind.sr_indication_body.number_of_srs > 0) {
//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);
send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id);
sent_any = true;
send_standalone_msg(UL_INFO, UL_INFO->sr_ind.header.message_id);
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;
}
......@@ -1283,12 +1262,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);
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);
dl_config_req_tx_req = NULL;
}
......@@ -1312,9 +1290,9 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
free(hi_dci0_req);
hi_dci0_req = NULL;
}
if (!sent_any)
{
send_standalone_dummy();
if (!sent_any) {
send_standalone_dummy();
}
}
......@@ -1333,7 +1311,6 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg)
UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL;
free(UL_INFO);
UL_INFO = NULL;
// thread finished
free(arg);
return NULL;
......@@ -1347,8 +1324,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.
*/
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
thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L);
// for multipule UE's L2-emulator
......@@ -1374,7 +1350,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
proc = &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0];
phy_stub_ticking->num_single_thread[ue_thread_id] = -1;
UE = rtd->UE;
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.number_of_pdus = 0;
......@@ -1486,19 +1461,23 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
}
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) {
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) {
i += 1;
AssertFatal(i < dl_config_req->dl_config_request_body.number_pdu,
"Need PDU following DCI at index %d, but not found\n",
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) {
LOG_E(MAC, "expected DLSCH PDU at index %d\n", i);
continue;
}
dl_config_req_UE_MAC_dci(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),
NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
pdu,
......@@ -1520,8 +1499,9 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
if (hi_dci0_req) {
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++) {
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),
NFAPI_SFNSF2SF(hi_dci0_req->sfn_sf),
pdu,
......@@ -1589,44 +1569,41 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(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 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);
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
}
}
}
} // 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++)
phy_stub_ticking->num_single_thread[ue_thread_id] = -1;
......@@ -1706,6 +1683,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
tx_req_pdu_list[i].segments[j].segment_data = NULL;
}
}
tx_req_num_elems = 0;
free(tx_req_pdu_list);
tx_req_pdu_list = NULL;
......@@ -1749,7 +1727,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
free(UL_INFO);
UL_INFO = NULL;
#endif // disabled UE_phy_stub_single_thread_rxn_txnp4
// thread finished
free(arg);
return NULL;
......@@ -1764,9 +1741,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.
*/
static void *UE_phy_stub_thread_rxn_txnp4(void *arg)
{
#if 0
static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
#if 0
thread_top_init("UE_phy_stub_thread_rxn_txnp4",1,870000L,1000000L,1000000L);
module_id_t Mod_id = 0;
static __thread int UE_thread_rxtx_retval;
......@@ -1877,45 +1853,42 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg)
if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD) )
if (UE->mode != loop_through_memory) {
if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH) ) {
// check if we have PRACH opportunity
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);
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);
Msg1_transmitted(Mod_id, 0, proc->frame_tx, 0);
UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE;
}
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH) ) {
// check if we have PRACH opportunity
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);
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);
Msg1_transmitted(Mod_id, 0, proc->frame_tx, 0);
UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE;
}
} // 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 && 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);
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
}
} // mode is PRACH
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;
}
// 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 && 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);
ul_config_req = NULL;
} else if(ul_config_req!=NULL) {
free(ul_config_req);
ul_config_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;
}
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
free(arg);
return NULL; //return &UE_thread_rxtx_retval;
......@@ -1937,20 +1910,19 @@ void write_dummy(PHY_VARS_UE *UE, openair0_timestamp timestamp) {
//
c16_t v= {0};
void *samplesVoid[UE->frame_parms.nb_antennas_tx];
for ( int i=0; i < UE->frame_parms.nb_antennas_tx; i++)
samplesVoid[i]=(void *)&v;
AssertFatal( 1 == UE->rfdevice.trx_write_func(&UE->rfdevice,
timestamp+2*UE->frame_parms.samples_per_tti,
samplesVoid,
1,
UE->frame_parms.nb_antennas_tx,
1),"");
timestamp+2*UE->frame_parms.samples_per_tti,
samplesVoid,
1,
UE->frame_parms.nb_antennas_tx,
1),"");
}
void *UE_thread(void *arg)
{
void *UE_thread(void *arg) {
PHY_VARS_UE *UE = (PHY_VARS_UE *) arg;
// int tx_enabled = 0;
int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32)));
......@@ -1963,10 +1935,11 @@ void *UE_thread(void *arg)
int ret;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
if ( threads.main != -1 )
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)
pthread_cond_wait(&sync_cond, &sync_mutex);
......@@ -1993,46 +1966,45 @@ void *UE_thread(void *arg)
int instance_cnt_synch = UE->proc.instance_cnt_synch;
int is_synchronized = UE->is_synchronized;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
if (is_synchronized == 0) {
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
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&dummy_rx[i][0];
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
UE->frame_parms.samples_per_tti/2,
UE->frame_parms.nb_antennas_rx);
// 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++)
rxp[i] = (void *)&dummy_rx[i][0];
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
UE->frame_parms.samples_per_tti/2,
UE->frame_parms.nb_antennas_rx);
// grab 10 ms of signal and wakeup synch thread
if (UE->mode != loop_through_memory) {
if (IS_SOFTMODEM_RFSIM ) {
for(int sf=0; sf<10; sf++) {
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];
AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx), "");
write_dummy(UE, timestamp);
}
} else {
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&UE->common_vars.rxdata[i][0];
AssertFatal( UE->frame_parms.samples_per_tti*10 ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
UE->frame_parms.samples_per_tti*10,
UE->frame_parms.nb_antennas_rx), "");
}
}
if (IS_SOFTMODEM_RFSIM ) {
for(int sf=0; sf<10; sf++) {
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];
AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx), "");
write_dummy(UE, timestamp);
}
} else {
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&UE->common_vars.rxdata[i][0];
AssertFatal( UE->frame_parms.samples_per_tti*10 ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
UE->frame_parms.samples_per_tti*10,
UE->frame_parms.nb_antennas_rx), "");
}
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
instance_cnt_synch = ++UE->proc.instance_cnt_synch;
......@@ -2046,69 +2018,62 @@ void *UE_thread(void *arg)
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
} else {
#if OAISIM
(void)dummy_rx; /* avoid gcc warnings */
usleep(500);
#else
// 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++)
rxp[i] = (void *)&dummy_rx[i][0];
for (int sf=0; sf<10; sf++) {
// printf("Reading dummy sf %d\n",sf);
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx);
if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp);
}
}
#endif
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&dummy_rx[i][0];
for (int sf=0; sf<10; sf++) {
// printf("Reading dummy sf %d\n",sf);
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx);
if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp);
}
}
} // UE->is_synchronized==0
else {
if (start_rx_stream==0) {
start_rx_stream=1;
if (UE->mode != loop_through_memory) {
if (UE->no_timing_correction==0) {
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;
}
}
if (UE->no_timing_correction==0) {
LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
UE->rx_offset=0;
UE->time_sync_cell=0;
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),"");
//UE->proc.proc_rxtx[0].frame_rx++;
//UE->proc.proc_rxtx[1].frame_rx++;
for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->proc.proc_rxtx[th_id].frame_rx++;
if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp);
UE->rx_offset-=s;
}
}
// read in first symbol
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);
} //UE->mode != loop_through_memory
else
rt_sleep_ns(1000*1000);
UE->rx_offset=0;
UE->time_sync_cell=0;
//UE->proc.proc_rxtx[0].frame_rx++;
//UE->proc.proc_rxtx[1].frame_rx++;
for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->proc.proc_rxtx[th_id].frame_rx++;
}
// read in first symbol
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 {
sub_frame++;
sub_frame%=10;
......@@ -2127,7 +2092,8 @@ void *UE_thread(void *arg)
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]);
......@@ -2136,130 +2102,129 @@ void *UE_thread(void *arg)
if(thread_idx>=RX_NB_TH)
thread_idx = 0;
if (UE->mode != loop_through_memory) {
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+
UE->frame_parms.nb_prefix_samples0+
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];
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+
UE->frame_parms.nb_prefix_samples0+
sub_frame*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) {
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;
int readBlockSize, writeBlockSize;
// 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) {
if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti &&
UE->rx_offset > 0 )
UE->rx_offset_diff = -1 ;
// compute TO compensation that should be applied for this frame
if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti &&
UE->rx_offset < 10*UE->frame_parms.samples_per_tti )
UE->rx_offset_diff = 1;
}
if (UE->no_timing_correction == 0) {
if ( UE->rx_offset < 5*UE->frame_parms.samples_per_tti &&
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);
readBlockSize=UE->frame_parms.samples_per_tti -
UE->frame_parms.ofdm_symbol_size -
UE->frame_parms.nb_prefix_samples0 -
UE->rx_offset_diff;
writeBlockSize=UE->frame_parms.samples_per_tti -
UE->rx_offset_diff;
if ( UE->rx_offset > 5*UE->frame_parms.samples_per_tti &&
UE->rx_offset < 10*UE->frame_parms.samples_per_tti )
UE->rx_offset_diff = 1;
}
AssertFatal(readBlockSize ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
readBlockSize,
UE->frame_parms.nb_antennas_rx),"");
AssertFatal( writeBlockSize ==
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);
}
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);
readBlockSize=UE->frame_parms.samples_per_tti -
UE->frame_parms.ofdm_symbol_size -
UE->frame_parms.nb_prefix_samples0 -
UE->rx_offset_diff;
writeBlockSize=UE->frame_parms.samples_per_tti -
UE->rx_offset_diff;
}
/* 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);
}
tv.tv_nsec += 10*1000;
if (tv.tv_nsec >= 1000 * 1000 * 1000) {
tv.tv_sec++;
tv.tv_nsec -= 1000 * 1000 * 1000;
}
ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv);
AssertFatal(readBlockSize ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
readBlockSize,
UE->frame_parms.nb_antennas_rx),"");
AssertFatal( writeBlockSize ==
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 */
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
if (ret != 0) {
if (ret == ETIMEDOUT) {
LOG_E(PHY,"Missed real time\n");
continue;
} else {
LOG_E(PHY,"System error %s (%d)\n",strerror(errno),errno);
abort();
}
tv.tv_nsec += 10*1000;
if (tv.tv_nsec >= 1000 * 1000 * 1000) {
tv.tv_sec++;
tv.tv_nsec -= 1000 * 1000 * 1000;
}
// usleep(3000);
if(sub_frame == 0) {
//UE->proc.proc_rxtx[0].frame_rx++;
//UE->proc.proc_rxtx[1].frame_rx++;
for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->proc.proc_rxtx[th_id].frame_rx++;
}
ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv);
}
// operate on thread sf mod 2
if (ret != 0) {
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;
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,"");
} else {
printf("Processing subframe %d",proc->subframe_rx);
getchar();
// usleep(3000);
if(sub_frame == 0) {
//UE->proc.proc_rxtx[0].frame_rx++;
//UE->proc.proc_rxtx[1].frame_rx++;
for (th_id=0; th_id < RX_NB_TH; th_id++) {
UE->proc.proc_rxtx[th_id].frame_rx++;
}
}
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
} // UE->is_synchronized==1
} // while !oai_exit
......@@ -2280,8 +2245,7 @@ void *UE_thread(void *arg)
* - UE_thread_dlsch_proc_slot1
* and the locking between them.
*/
void init_UE_threads(int inst)
{
void init_UE_threads(int inst) {
struct rx_tx_thread_data *rtd;
PHY_VARS_UE *UE;
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n");
......@@ -2336,8 +2300,7 @@ void init_UE_threads(int inst)
* - UE_thread_dlsch_proc_slot1
* 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;
PHY_VARS_UE *UE;
......@@ -2365,8 +2328,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
//int nb_threads=RX_NB_TH;
int nb_threads=1;
void *(*task_func)(void *);
void* (*task_func)(void*);
if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) {
task_func = UE_phy_stub_standalone_pnf_task;
} else {
......@@ -2410,8 +2373,7 @@ void init_UE_single_thread_stub(int nb_inst)
* - UE_thread_dlsch_proc_slot1
* 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;
PHY_VARS_UE *UE;
AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is NULL\n");
......@@ -2448,8 +2410,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;
int i,j;
bands_to_scan.nbands = UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count;
......@@ -2474,8 +2435,7 @@ void fill_ue_band_info(void)
}
int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue,
openair0_config_t *openair0_cfg)
{
openair0_config_t *openair0_cfg) {
int i, CC_id;
LTE_DL_FRAME_PARMS *frame_parms;
......@@ -2512,8 +2472,7 @@ int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue,
// playing the role of nfapi-pnf.
//02/02/2018
static void *timer_thread( void *param )
{
static void *timer_thread( void *param ) {
thread_top_init("timer_thread",1,870000L,1000000L,1000000L);
timer_subframe =9;
timer_frame =1023;
......@@ -2639,8 +2598,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][0];
phy_stub_ticking = (SF_ticking *)malloc(sizeof(SF_ticking));
......@@ -2662,8 +2620,7 @@ int init_timer_thread(void)
*/
int8_t find_dlsch(uint16_t rnti,
PHY_VARS_eNB *eNB,
find_type_t type)
{
find_type_t type) {
printf("you cannot read this\n");
abort();
}
......
......@@ -276,7 +276,6 @@ uint16_t node_number;
static void get_options(void) {
int CC_id=0;
int tddflag=0;
char *loopfile=NULL;
int dumpframe=0;
int timingadv=0;
uint8_t nfapi_mode = NFAPI_MONOLITHIC;
......@@ -293,14 +292,6 @@ static void get_options(void) {
config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL);
nfapi_setmode(nfapi_mode);
if (loopfile != NULL) {
printf("Input file for hardware emulation: %s",loopfile);
mode=loop_through_memory;
input_fd = fopen(loopfile,"r");
AssertFatal(input_fd != NULL,"Please provide a valid input file\n");
}
get_softmodem_params()->hw_timing_advance = timingadv;
if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue;
......
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