Merge branch 'develop' into NR_RRC_PRACH_procedures

Conflicts:
	executables/nr-ue.c
	openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
	openair1/PHY/NR_UE_TRANSPORT/nr_prach.c
	openair1/PHY/defs_RU.h
	openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
	openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
	openair2/RRC/NR/rrc_gNB_nsa.c
	openair2/X2AP/x2ap_eNB_handler.c
This commit is contained in:
Thomas Schlichter
2020-04-30 18:54:37 +02:00
243 changed files with 16121 additions and 6036 deletions
+6
View File
@@ -3,6 +3,12 @@ This is an RF simulator that allows to test OAI without an RF board. It replaces
As much as possible, it works like an RF board, but not in real-time: It can run faster than real-time if there is enough CPU, or slower (it is CPU-bound instead of real-time RF sampling-bound).
It can be run either in:
- "noS1" mode: the generated IP traffic is sent and received between gNB and UE IP tunnel interfaces ("oaitun") by applications like ping and iperf
- "phy-test" mode: random UL and DL traffic is generated at every scheduling opportunity
# build
## From [build_oai](../../../doc/BUILD.md) script
+20 -3
View File
@@ -1,7 +1,24 @@
/*
Author: Laurent THOMAS, Open Cells for Nokia
copyleft: OpenAirInterface Software Alliance and it's licence
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Author and copyright: Laurent Thomas, open-cells.com
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
+36 -12
View File
@@ -1,8 +1,27 @@
/*
Author: Laurent THOMAS, Open Cells for Nokia
copyleft: OpenAirInterface Software Alliance and it's licence
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Author and copyright: Laurent Thomas, open-cells.com
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*
* Open issues and limitations
* The read and write should be called in the same thread, that is not new USRP UHD design
@@ -33,7 +52,7 @@
#include <openair1/SIMULATION/TOOLS/sim.h>
#define PORT 4043 //default TCP port for this simulator
#define CirSize 3072000 // 100ms is enough
#define CirSize 307200 // 100ms is enough
#define sampleToByte(a,b) ((a)*(b)*sizeof(sample_t))
#define byteToSample(a,b) ((a)/(sizeof(sample_t)*(b)))
@@ -346,7 +365,8 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp
if ( t->lastWroteTS != 0 && abs((double)t->lastWroteTS-timestamp) > (double)CirSize)
LOG_E(HW,"Discontinuous TX gap too large Tx:%lu, %lu\n", t->lastWroteTS, timestamp);
AssertFatal(t->lastWroteTS <= timestamp+1, " Not supported to send Tx out of order (same in USRP) %lu, %lu\n",
if (t->lastWroteTS > timestamp+nsamps)
LOG_E(HW,"Not supported to send Tx out of order (same in USRP) %lu, %lu\n",
t->lastWroteTS, timestamp);
t->lastWroteTS=timestamp+nsamps;
@@ -420,7 +440,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
if ( sz < 0 ) {
if ( errno != EAGAIN ) {
LOG_E(HW,"socket failed %s\n", strerror(errno));
abort();
//abort();
}
} else if ( sz == 0 )
continue;
@@ -439,11 +459,15 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
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 ? 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);
b->trashingPacket=true;
} else if ( b->lastReceivedTS < b->th.timestamp) {
t->nextTimestamp=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);
b->trashingPacket=true;
} else if ( b->lastReceivedTS < b->th.timestamp) {
int nbAnt= b->th.nbAnt;
for (uint64_t index=b->lastReceivedTS; index < b->th.timestamp; index++ ) {
@@ -463,8 +487,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
} else if ( b->lastReceivedTS == b->th.timestamp ) {
// normal case
} else {
abort();
AssertFatal(false, "received data in past: current is %lu, new reception: %lu!\n", b->lastReceivedTS, b->th.timestamp);
LOG_E(HW, "received data in past: current is %lu, new reception: %lu!\n", b->lastReceivedTS, b->th.timestamp);
b->trashingPacket=true;
}
pthread_mutex_lock(&Sockmutex);
+21 -2
View File
@@ -1,8 +1,27 @@
/*
Author: Laurent THOMAS, Open Cells
copyleft: OpenAirInterface Software Alliance and it's licence
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Author and copyright: Laurent Thomas, open-cells.com
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <common/utils/simple_executable.h>
volatile int oai_exit = 0;
+3 -2
View File
@@ -41,6 +41,7 @@
# include "f1ap_du_task.h"
# include "enb_app.h"
# include "openair2/LAYER2/MAC/mac_proto.h"
#include <executables/split_headers.h>
extern RAN_CONTEXT_t RC;
@@ -59,12 +60,12 @@ int create_tasks(uint32_t enb_nb) {
rc = itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL);
AssertFatal(rc >= 0, "Create task for RRC eNB failed\n");
if (EPC_MODE_ENABLED) {
if (EPC_MODE_ENABLED && ! ( split73==SPLIT73_DU ) ) {
rc = itti_create_task(TASK_SCTP, sctp_eNB_task, NULL);
AssertFatal(rc >= 0, "Create task for SCTP failed\n");
}
if (EPC_MODE_ENABLED && !NODE_IS_DU(type)) {
if (EPC_MODE_ENABLED && !NODE_IS_DU(type) && ! ( split73==SPLIT73_DU ) ) {
rc = itti_create_task(TASK_S1AP, s1ap_eNB_task, NULL);
AssertFatal(rc >= 0, "Create task for S1AP failed\n");
if (!(get_softmodem_params()->emulate_rf)){
+1 -1
View File
@@ -261,7 +261,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,
eNB->UL_INFO.subframe = proc->subframe_rx;
eNB->UL_INFO.module_id = eNB->Mod_id;
eNB->UL_INFO.CC_id = eNB->CC_id;
eNB->if_inst->UL_indication(&eNB->UL_INFO);
eNB->if_inst->UL_indication(&eNB->UL_INFO, proc);
AssertFatal((ret= pthread_mutex_unlock(&eNB->UL_INFO_mutex))==0,"error unlocking UL_INFO_mutex, return %d\n",ret);
/* this conflict resolution may be totally wrong, to be tested */
/* CONFLICT RESOLUTION: BEGIN */
+46 -27
View File
@@ -80,7 +80,7 @@ unsigned short config_frames[4] = {2,9,11,13};
//#include "PHY/TOOLS/time_meas.h"
#ifndef OPENAIR2
#include "UTIL/OTG/otg_vars.h"
#include "UTIL/OTG/otg_vars.h"
#endif
@@ -93,6 +93,7 @@ unsigned short config_frames[4] = {2,9,11,13};
#include "lte-softmodem.h"
#include "NB_IoT_interface.h"
#include <executables/split_headers.h>
pthread_cond_t nfapi_sync_cond;
@@ -152,6 +153,13 @@ int otg_enabled;
uint64_t num_missed_slots=0; // counter for the number of missed slots
int split73=0;
void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) {
AssertFatal(false, "Must not be called in this context\n");
}
void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask, uint16_t rnti, int32_t stat) {
AssertFatal(false, "Must not be called in this context\n");
}
extern void reset_opp_meas(void);
extern void print_opp_meas(void);
@@ -170,7 +178,7 @@ eth_params_t *eth_params;
double cpuf;
int oaisim_flag=0;
//threads_t threads= {-1,-1,-1,-1,-1,-1,-1,-1};
/* forward declarations */
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
@@ -539,7 +547,7 @@ int main ( int argc, char **argv )
cpuf=get_cpu_freq_GHz();
printf("ITTI init, useMME: %i\n",EPC_MODE_ENABLED);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
// allows to forward in wireshark L2 protocol for decoding
// initialize mscgen log after ITTI
if (get_softmodem_params()->start_msc) {
load_module_shlib("msc",NULL,0,&msc_interface);
@@ -547,8 +555,6 @@ int main ( int argc, char **argv )
MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
init_opt();
// to make a graceful exit when ctrl-c is pressed
set_softmodem_sighandler();
check_clock();
#ifndef PACKAGE_VERSION
# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
@@ -579,11 +585,11 @@ int main ( int argc, char **argv )
for (i = 0; i < RC.nb_inst; i++) {
flexran_agent_start(i);
}
/* initializes PDCP and sets correct RLC Request/PDCP Indication callbacks
* for monolithic/F1 modes */
init_pdcp();
init_pdcp();
if (create_tasks(1) < 0) {
printf("cannot create ITTI tasks\n");
exit(-1);
@@ -607,7 +613,7 @@ int main ( int argc, char **argv )
ctxt.subframe = 0;
pdcp_run(&ctxt);
}
/* start threads if only L1 or not a CU */
if (RC.nb_inst == 0 || !NODE_IS_CU(node_type) || NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) {
// init UE_PF_PO and mutex lock
@@ -618,31 +624,44 @@ int main ( int argc, char **argv )
pthread_mutex_init(&sync_mutex, NULL);
rt_sleep_ns(10*100000000ULL);
if (NFAPI_MODE!=NFAPI_MONOLITHIC) {
LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n");
pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL);
}
if (NFAPI_MODE==NFAPI_MODE_VNF) {// VNF
#if defined(PRE_SCD_THREAD)
init_ru_vnf(); // ru pointer is necessary for pre_scd.
#endif
wait_nfapi_init("main?");
}
LOG_I(ENB_APP,"START MAIN THREADS\n");
// start the main threads
number_of_cards = 1;
printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst);
if (RC.nb_L1_inst > 0) {
printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync);
init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync);
// for (inst=0;inst<RC.nb_L1_inst;inst++)
// for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0);
}
for (int x=0; x < RC.nb_L1_inst; x++)
for (int CC_id=0; CC_id<RC.nb_L1_CC[x]; CC_id++) {
L1_rxtx_proc_t *L1proc= &RC.eNB[x][CC_id]->proc.L1_proc;
L1proc->threadPool=(tpool_t*)malloc(sizeof(tpool_t));
L1proc->respEncode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
L1proc->respDecode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
if ( strlen(get_softmodem_params()->threadPoolConfig) > 0 )
initTpool(get_softmodem_params()->threadPoolConfig, L1proc->threadPool, true);
else
initTpool("n", L1proc->threadPool, true);
initNotifiedFIFO(L1proc->respEncode);
initNotifiedFIFO(L1proc->respDecode);
}
}
printf("wait_eNBs()\n");
@@ -660,23 +679,23 @@ int main ( int argc, char **argv )
RC.ru[ru_id]->rf_map.card=0;
RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset);
}
config_sync_var=0;
if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF
wait_nfapi_init("main?");
}
printf("wait RUs\n");
// CI -- Flushing the std outputs for the previous marker to show on the eNB / RRU log file
// end of CI modifications
fflush(stdout);
fflush(stderr);
// end of CI modifications
// wait_RUs() is wrong and over complex!
wait_RUs();
LOG_I(ENB_APP,"RC.nb_RU:%d\n", RC.nb_RU);
// once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration)
printf("ALL RUs ready - init eNBs\n");
if (NFAPI_MODE!=NFAPI_MODE_PNF && NFAPI_MODE!=NFAPI_MODE_VNF) {
LOG_I(ENB_APP,"Not NFAPI mode - call init_eNB_afterRU()\n");
init_eNB_afterRU();
@@ -723,7 +742,7 @@ int main ( int argc, char **argv )
for (int inst = 0; inst < NB_eNB_INST; inst++) {
for (int cc_id = 0; cc_id < RC.nb_CC[inst]; cc_id++) {
free_transport(RC.eNB[inst][cc_id]);
phy_free_lte_eNB(RC.eNB[inst][cc_id]);
phy_free_lte_eNB(RC.eNB[inst][cc_id]);
}
}
@@ -741,17 +760,17 @@ int main ( int argc, char **argv )
for(ru_id=0; ru_id<RC.nb_RU; ru_id++) {
if (RC.ru[ru_id]->rfdevice.trx_end_func) {
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
}
if (RC.ru[ru_id]->ifdevice.trx_end_func) {
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
}
}
}
terminate_opt();
logClean();
printf("Bye.\n");
+45 -40
View File
@@ -1132,6 +1132,11 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
pdu,
ue_num);
} else if (pdu->pdu_type == NFAPI_DL_CONFIG_MCH_PDU_TYPE) {
dl_config_req_UE_MAC_mch(NFAPI_SFNSF2SFN(dl_config_req->sfn_sf),
NFAPI_SFNSF2SF(dl_config_req->sfn_sf),
pdu,
ue_num);
}
}
}
@@ -1557,12 +1562,12 @@ void write_dummy(PHY_VARS_UE *UE, openair0_timestamp timestamp) {
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),"");
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),"");
}
void *UE_thread(void *arg)
@@ -1613,36 +1618,36 @@ 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
// 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];
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 ==
&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;
@@ -1672,10 +1677,10 @@ void *UE_thread(void *arg)
rxp,
UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx);
if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp);
}
}
if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp);
}
}
#endif
}
} // UE->is_synchronized==0
@@ -1686,17 +1691,17 @@ void *UE_thread(void *arg)
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);
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;
}
&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;
@@ -1737,7 +1742,7 @@ 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]);
+6 -6
View File
@@ -281,13 +281,13 @@ void exit_function(const char *file, const char *function, const int line, const
extern int16_t dlsch_demod_shift;
static void get_options(void) {
int CC_id;
int tddflag = 0;
char *loopfile = NULL;
int dumpframe = 0;
int timingadv = 0;
int CC_id=0;
int tddflag=0;
char *loopfile=NULL;
int dumpframe=0;
int timingadv=0;
uint8_t nfapi_mode = NFAPI_MONOLITHIC;
int simL1flag = 0;
int simL1flag =0;
set_default_frame_parms(frame_parms);
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);