Merge remote-tracking branch 'origin/develop-nr' into develop-nr-less-logging
Conflicts: openair1/SCHED_NR/sched_nr.h
This commit is contained in:
@@ -19,8 +19,8 @@
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file common_lib.h
|
||||
* \brief common APIs for different RF frontend device
|
||||
/*! \file common_lib.h
|
||||
* \brief common APIs for different RF frontend device
|
||||
* \author HongliangXU, Navid Nikaein
|
||||
* \date 2015
|
||||
* \version 0.2
|
||||
@@ -45,21 +45,16 @@
|
||||
#define RAU_REMOTE_RADIO_HEAD 1
|
||||
|
||||
#ifndef MAX_CARDS
|
||||
#define MAX_CARDS 8
|
||||
#define MAX_CARDS 8
|
||||
#endif
|
||||
|
||||
typedef int64_t openair0_timestamp;
|
||||
typedef volatile int64_t openair0_vtimestamp;
|
||||
|
||||
|
||||
|
||||
/*!\brief structrue holds the parameters to configure USRP devices*/
|
||||
typedef struct openair0_device_t openair0_device;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//#define USRP_GAIN_OFFSET (56.0) // 86 calibrated for USRP B210 @ 2.6 GHz to get equivalent RS EPRE in OAI to SMBV100 output
|
||||
|
||||
typedef enum {
|
||||
@@ -80,9 +75,6 @@ typedef enum {
|
||||
*/
|
||||
/*!\brief RF device types
|
||||
*/
|
||||
#ifdef OCP_FRAMEWORK
|
||||
#include <enums.h>
|
||||
#else
|
||||
typedef enum {
|
||||
MIN_RF_DEV_TYPE = 0,
|
||||
/*!\brief device is ExpressMIMO */
|
||||
@@ -104,7 +96,6 @@ typedef enum {
|
||||
MAX_RF_DEV_TYPE
|
||||
|
||||
} dev_type_t;
|
||||
#endif
|
||||
|
||||
/*!\brief transport protocol types
|
||||
*/
|
||||
@@ -122,16 +113,16 @@ typedef enum {
|
||||
/*!\brief openair0 device host type */
|
||||
typedef enum {
|
||||
MIN_HOST_TYPE = 0,
|
||||
/*!\brief device functions within a RAU */
|
||||
/*!\brief device functions within a RAU */
|
||||
RAU_HOST,
|
||||
/*!\brief device functions within a RRU */
|
||||
/*!\brief device functions within a RRU */
|
||||
RRU_HOST,
|
||||
MAX_HOST_TYPE
|
||||
|
||||
}host_type_t;
|
||||
} host_type_t;
|
||||
|
||||
|
||||
/*! \brief RF Gain clibration */
|
||||
/*! \brief RF Gain clibration */
|
||||
typedef struct {
|
||||
//! Frequency for which RX chain was calibrated
|
||||
double freq;
|
||||
@@ -159,7 +150,7 @@ typedef struct {
|
||||
duplex_mode_t duplex_mode;
|
||||
//! number of downlink resource blocks
|
||||
int num_rb_dl;
|
||||
//! number of samples per frame
|
||||
//! number of samples per frame
|
||||
unsigned int samples_per_frame;
|
||||
//! the sample rate for both transmit and receive.
|
||||
double sample_rate;
|
||||
@@ -174,9 +165,9 @@ typedef struct {
|
||||
//! number of TX channels (=TX antennas)
|
||||
int tx_num_channels;
|
||||
//! \brief RX base addresses for mmapped_dma
|
||||
int32_t* rxbase[4];
|
||||
int32_t *rxbase[4];
|
||||
//! \brief TX base addresses for mmapped_dma
|
||||
int32_t* txbase[4];
|
||||
int32_t *txbase[4];
|
||||
//! \brief Center frequency in Hz for RX.
|
||||
//! index: [0..rx_num_channels[
|
||||
double rx_freq[4];
|
||||
@@ -187,7 +178,7 @@ typedef struct {
|
||||
//! \brief Pointer to Calibration table for RX gains
|
||||
rx_gain_calib_table_t *rx_gain_calib_table;
|
||||
|
||||
//! mode for rxgain (ExpressMIMO2)
|
||||
//! mode for rxgain (ExpressMIMO2)
|
||||
rx_gain_t rxg_mode[4];
|
||||
//! \brief Gain for RX in dB.
|
||||
//! index: [0..rx_num_channels]
|
||||
@@ -201,15 +192,15 @@ typedef struct {
|
||||
double rx_bw;
|
||||
//! TX bandwidth in Hz
|
||||
double tx_bw;
|
||||
//! clock source
|
||||
//! clock source
|
||||
clock_source_t clock_source;
|
||||
//! Manual SDR IP address
|
||||
//#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
|
||||
//#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
|
||||
char *sdr_addrs;
|
||||
//! Auto calibration flag
|
||||
int autocal[4];
|
||||
//! rf devices work with x bits iqs when oai have its own iq format
|
||||
//! the two following parameters are used to convert iqs
|
||||
//! the two following parameters are used to convert iqs
|
||||
int iq_txshift;
|
||||
int iq_rxrescale;
|
||||
//! Configuration file for LMS7002M
|
||||
@@ -230,7 +221,7 @@ typedef struct {
|
||||
unsigned int sf_read_delay; // read delay in replay mode
|
||||
unsigned int sf_write_delay; // write delay in replay mode
|
||||
unsigned int eth_mtu; // ethernet MTU
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! number of samples per tti
|
||||
unsigned int samples_per_tti;
|
||||
@@ -243,7 +234,7 @@ typedef struct {
|
||||
|
||||
} openair0_config_t;
|
||||
|
||||
/*! \brief RF mapping */
|
||||
/*! \brief RF mapping */
|
||||
typedef struct {
|
||||
//! card id
|
||||
int card;
|
||||
@@ -290,14 +281,14 @@ struct openair0_device_t {
|
||||
|
||||
/*!brief Component Carrier ID of this device */
|
||||
int CC_id;
|
||||
|
||||
|
||||
/*!brief Type of this device */
|
||||
dev_type_t type;
|
||||
|
||||
/*!brief Transport protocol type that the device suppports (in case I/Q samples need to be transported) */
|
||||
transport_type_t transp_type;
|
||||
|
||||
/*!brief Type of the device's host (RAU/RRU) */
|
||||
/*!brief Type of the device's host (RAU/RRU) */
|
||||
host_type_t host_type;
|
||||
|
||||
/* !brief RF frontend parameters set by application */
|
||||
@@ -319,25 +310,25 @@ struct openair0_device_t {
|
||||
/*! \brief Called to send a request message between RAU-RRU on control port
|
||||
@param device pointer to the device structure specific to the RF hardware target
|
||||
@param msg pointer to the message structure passed between RAU-RRU
|
||||
@param msg_len length of the message
|
||||
*/
|
||||
@param msg_len length of the message
|
||||
*/
|
||||
int (*trx_ctlsend_func)(openair0_device *device, void *msg, ssize_t msg_len);
|
||||
|
||||
/*! \brief Called to receive a reply message between RAU-RRU on control port
|
||||
@param device pointer to the device structure specific to the RF hardware target
|
||||
@param msg pointer to the message structure passed between RAU-RRU
|
||||
@param msg_len length of the message
|
||||
*/
|
||||
@param msg_len length of the message
|
||||
*/
|
||||
int (*trx_ctlrecv_func)(openair0_device *device, void *msg, ssize_t msg_len);
|
||||
|
||||
/*! \brief Called to send samples to the RF target
|
||||
@param device pointer to the device structure specific to the RF hardware target
|
||||
@param timestamp The timestamp at whicch the first sample MUST be sent
|
||||
@param timestamp The timestamp at whicch the first sample MUST be sent
|
||||
@param buff Buffer which holds the samples
|
||||
@param nsamps number of samples to be sent
|
||||
@param antenna_id index of the antenna if the device has multiple anteannas
|
||||
@param flags flags must be set to TRUE if timestamp parameter needs to be applied
|
||||
*/
|
||||
*/
|
||||
int (*trx_write_func)(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int antenna_id, int flags);
|
||||
|
||||
/*! \brief Receive samples from hardware.
|
||||
@@ -353,55 +344,80 @@ struct openair0_device_t {
|
||||
*/
|
||||
int (*trx_read_func)(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps,int antenna_id);
|
||||
|
||||
/*! \brief print the device statistics
|
||||
/*! \brief print the device statistics
|
||||
* \param device the hardware to use
|
||||
* \returns 0 on success
|
||||
*/
|
||||
int (*trx_get_stats_func)(openair0_device *device);
|
||||
|
||||
/*! \brief Reset device statistics
|
||||
/*! \brief Reset device statistics
|
||||
* \param device the hardware to use
|
||||
* \returns 0 in success
|
||||
* \returns 0 in success
|
||||
*/
|
||||
int (*trx_reset_stats_func)(openair0_device *device);
|
||||
|
||||
/*! \brief Terminate operation of the transceiver -- free all associated resources
|
||||
/*! \brief Terminate operation of the transceiver -- free all associated resources
|
||||
* \param device the hardware to use
|
||||
*/
|
||||
void (*trx_end_func)(openair0_device *device);
|
||||
|
||||
/*! \brief Stop operation of the transceiver
|
||||
/*! \brief Stop operation of the transceiver
|
||||
*/
|
||||
int (*trx_stop_func)(openair0_device *device);
|
||||
|
||||
/* Functions API related to UE*/
|
||||
|
||||
/*! \brief Set RX feaquencies
|
||||
/*! \brief Set RX feaquencies
|
||||
* \param device the hardware to use
|
||||
* \param openair0_cfg RF frontend parameters set by application
|
||||
* \param exmimo_dump_config dump EXMIMO configuration
|
||||
* \returns 0 in success
|
||||
* \param exmimo_dump_config dump EXMIMO configuration
|
||||
* \returns 0 in success
|
||||
*/
|
||||
int (*trx_set_freq_func)(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config);
|
||||
|
||||
int (*trx_set_freq_func)(openair0_device *device, openair0_config_t *openair0_cfg,int exmimo_dump_config);
|
||||
|
||||
/*! \brief Set gains
|
||||
* \param device the hardware to use
|
||||
* \param openair0_cfg RF frontend parameters set by application
|
||||
* \returns 0 in success
|
||||
* \returns 0 in success
|
||||
*/
|
||||
int (*trx_set_gains_func)(openair0_device* device, openair0_config_t *openair0_cfg);
|
||||
int (*trx_set_gains_func)(openair0_device *device, openair0_config_t *openair0_cfg);
|
||||
|
||||
/*! \brief RRU Configuration callback
|
||||
* \param idx RU index
|
||||
* \param arg pointer to capabilities or configuration
|
||||
*/
|
||||
void (*configure_rru)(int idx, void* arg);
|
||||
void (*configure_rru)(int idx, void *arg);
|
||||
};
|
||||
|
||||
/* type of device init function, implemented in shared lib */
|
||||
typedef int(*oai_device_initfunc_t)(openair0_device *device, openair0_config_t *openair0_cfg);
|
||||
/* type of transport init function, implemented in shared lib */
|
||||
typedef int(*oai_transport_initfunc_t)(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * eth_params);
|
||||
typedef int(*oai_transport_initfunc_t)(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params);
|
||||
#define UE_MAGICDL_FDD 0xA5A5A5A5A5A5A5A5 // UE DL FDD record
|
||||
#define UE_MAGICUL_FDD 0x5A5A5A5A5A5A5A5A // UE UL FDD record
|
||||
#define UE_MAGICDL_TDD 0xA6A6A6A6A6A6A6A6 // UE DL TDD record
|
||||
#define UE_MAGICUL_TDD 0x6A6A6A6A6A6A6A6A // UE UL TDD record
|
||||
|
||||
#define ENB_MAGICDL_FDD 0xB5B5B5B5B5B5B5B5 // eNB DL FDD record
|
||||
#define ENB_MAGICUL_FDD 0x5B5B5B5B5B5B5B5B // eNB UL FDD record
|
||||
#define ENB_MAGICDL_TDD 0xB6B6B6B6B6B6B6B6 // eNB DL TDD record
|
||||
#define ENB_MAGICUL_TDD 0x6B6B6B6B6B6B6B6B // eNB UL TDD record
|
||||
|
||||
#define OPTION_LZ4 0x00000001 // LZ4 compression (option_value is set to compressed size)
|
||||
|
||||
#define sample_t uint32_t // 2*16 bits complex number
|
||||
|
||||
typedef struct {
|
||||
uint64_t magic; // Magic value (see defines above)
|
||||
uint32_t size; // Number of samples per antenna to follow this header
|
||||
uint32_t nbAnt; // Total number of antennas following this header
|
||||
// Samples per antenna follow this header,
|
||||
// i.e. nbAnt = 2 => this header+samples_antenna_0+samples_antenna_1
|
||||
// data following this header in bytes is nbAnt*size*sizeof(sample_t)
|
||||
uint64_t timestamp; // Timestamp value of first sample
|
||||
uint32_t option_value; // Option value
|
||||
uint32_t option_flag; // Option flag
|
||||
} samplesBlockHeader_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@@ -409,23 +425,23 @@ extern "C"
|
||||
#endif
|
||||
|
||||
|
||||
/*! \brief Initialize openair RF target. It returns 0 if OK */
|
||||
int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cfg);
|
||||
/*! \brief Initialize transport protocol . It returns 0 if OK */
|
||||
int openair0_transport_load(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * eth_params);
|
||||
/*! \brief Initialize openair RF target. It returns 0 if OK */
|
||||
int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cfg);
|
||||
/*! \brief Initialize transport protocol . It returns 0 if OK */
|
||||
int openair0_transport_load(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params);
|
||||
|
||||
|
||||
/*! \brief Get current timestamp of USRP
|
||||
* \param device the hardware to use
|
||||
*/
|
||||
openair0_timestamp get_usrp_time(openair0_device *device);
|
||||
|
||||
/*! \brief Set RX frequencies
|
||||
* \param device the hardware to use
|
||||
* \param openair0_cfg RF frontend parameters set by application
|
||||
* \returns 0 in success
|
||||
*/
|
||||
int openair0_set_rx_frequencies(openair0_device* device, openair0_config_t *openair0_cfg);
|
||||
/*! \brief Get current timestamp of USRP
|
||||
* \param device the hardware to use
|
||||
*/
|
||||
openair0_timestamp get_usrp_time(openair0_device *device);
|
||||
|
||||
/*! \brief Set RX frequencies
|
||||
* \param device the hardware to use
|
||||
* \param openair0_cfg RF frontend parameters set by application
|
||||
* \returns 0 in success
|
||||
*/
|
||||
int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg);
|
||||
#define gettid() syscall(__NR_gettid)
|
||||
/*@}*/
|
||||
|
||||
|
||||
@@ -299,6 +299,7 @@ static int trx_usrp_start(openair0_device *device) {
|
||||
|
||||
if (u_sf_mode != 2) { // not replay mode
|
||||
#endif
|
||||
uhd::set_thread_priority_safe(1.0);
|
||||
usrp_state_t *s = (usrp_state_t *)device->priv;
|
||||
// setup GPIO for TDD, GPIO(4) = ATR_RX
|
||||
//set data direction register (DDR) to output
|
||||
@@ -1098,7 +1099,6 @@ extern "C" {
|
||||
<< use_mmap << std::endl;
|
||||
} else {
|
||||
#endif
|
||||
uhd::set_thread_priority_safe(1.0);
|
||||
usrp_state_t *s = (usrp_state_t *)calloc(sizeof(usrp_state_t),1);
|
||||
|
||||
if (openair0_cfg[0].clock_source==gpsdo)
|
||||
@@ -1163,6 +1163,9 @@ extern "C" {
|
||||
device->type=USRP_X300_DEV;
|
||||
usrp_master_clock = 184.32e6;
|
||||
args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock);
|
||||
// USRP recommended: https://files.ettus.com/manual/page_usrp_x3x0_config.html
|
||||
if ( 0 != system("sysctl -w net.core.rmem_max=33554432 net.core.wmem_max=33554432") )
|
||||
LOG_W(HW,"Can't set kernel paramters for X3xx\n");
|
||||
}
|
||||
|
||||
s->usrp = uhd::usrp::multi_usrp::make(args);
|
||||
|
||||
@@ -27,22 +27,15 @@
|
||||
#define sample_t uint32_t // 2*16 bits complex number
|
||||
#define sampleToByte(a,b) ((a)*(b)*sizeof(sample_t))
|
||||
#define byteToSample(a,b) ((a)/(sizeof(sample_t)*(b)))
|
||||
#define MAGICeNB 0xA5A5A5A5A5A5A5A5
|
||||
#define MAGICUE 0x5A5A5A5A5A5A5A5A
|
||||
|
||||
typedef struct {
|
||||
uint64_t magic;
|
||||
uint32_t size;
|
||||
uint32_t nbAnt;
|
||||
uint64_t timestamp;
|
||||
} transferHeader;
|
||||
#define sample_t uint32_t // 2*16 bits complex number
|
||||
|
||||
typedef struct buffer_s {
|
||||
int conn_sock;
|
||||
bool alreadyRead;
|
||||
uint64_t lastReceivedTS;
|
||||
bool headerMode;
|
||||
transferHeader th;
|
||||
samplesBlockHeader_t th;
|
||||
char *transferPtr;
|
||||
uint64_t remainToTransfer;
|
||||
char *circularBufEnd;
|
||||
@@ -53,8 +46,8 @@ typedef struct {
|
||||
int listen_sock, epollfd;
|
||||
uint64_t nextTimestamp;
|
||||
uint64_t typeStamp;
|
||||
uint64_t initialAhead;
|
||||
char *ip;
|
||||
int saveIQfile;
|
||||
buffer_t buf[FD_SETSIZE];
|
||||
} rfsimulator_state_t;
|
||||
|
||||
@@ -63,9 +56,11 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) {
|
||||
AssertFatal ( (ptr->circularBuf=(sample_t *) malloc(sampleToByte(CirSize,1))) != NULL, "");
|
||||
ptr->circularBufEnd=((char *)ptr->circularBuf)+sampleToByte(CirSize,1);
|
||||
ptr->conn_sock=sock;
|
||||
ptr->alreadyRead=false;
|
||||
ptr->lastReceivedTS=0;
|
||||
ptr->headerMode=true;
|
||||
ptr->transferPtr=(char *)&ptr->th;
|
||||
ptr->remainToTransfer=sizeof(transferHeader);
|
||||
ptr->remainToTransfer=sizeof(samplesBlockHeader_t);
|
||||
int sendbuff=1000*1000*10;
|
||||
AssertFatal ( setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &sendbuff, sizeof(sendbuff)) == 0, "");
|
||||
struct epoll_event ev= {0};
|
||||
@@ -87,12 +82,11 @@ void socketError(rfsimulator_state_t *bridge, int sock) {
|
||||
LOG_W(HW,"Lost socket \n");
|
||||
removeCirBuf(bridge, sock);
|
||||
|
||||
if (bridge->typeStamp==MAGICUE)
|
||||
if (bridge->typeStamp==UE_MAGICDL_FDD)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define helpTxt "\
|
||||
\x1b[31m\
|
||||
rfsimulator: error: you have to run one UE and one eNB\n\
|
||||
@@ -119,9 +113,17 @@ void setblocking(int sock, enum blocking_t active) {
|
||||
|
||||
static bool flushInput(rfsimulator_state_t *t);
|
||||
|
||||
void fullwrite(int fd, void *_buf, int count, rfsimulator_state_t *t) {
|
||||
void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t) {
|
||||
if (t->saveIQfile != -1) {
|
||||
if (write(t->saveIQfile, _buf, count) != count )
|
||||
LOG_E(HW,"write in save iq file failed (%s)\n",strerror(errno));
|
||||
}
|
||||
|
||||
AssertFatal(fd>=0 && _buf && count >0 && t,
|
||||
"Bug: %d/%p/%zd/%p", fd, _buf, count, t);
|
||||
|
||||
char *buf = _buf;
|
||||
int l;
|
||||
ssize_t l;
|
||||
setblocking(fd, notBlocking);
|
||||
|
||||
while (count) {
|
||||
@@ -145,7 +147,7 @@ void fullwrite(int fd, void *_buf, int count, rfsimulator_state_t *t) {
|
||||
|
||||
int server_start(openair0_device *device) {
|
||||
rfsimulator_state_t *t = (rfsimulator_state_t *) device->priv;
|
||||
t->typeStamp=MAGICeNB;
|
||||
t->typeStamp=ENB_MAGICDL_FDD;
|
||||
AssertFatal((t->listen_sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0, "");
|
||||
int enable = 1;
|
||||
AssertFatal(setsockopt(t->listen_sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) == 0, "");
|
||||
@@ -168,7 +170,7 @@ sin_addr:
|
||||
|
||||
int start_ue(openair0_device *device) {
|
||||
rfsimulator_state_t *t = device->priv;
|
||||
t->typeStamp=MAGICUE;
|
||||
t->typeStamp=UE_MAGICDL_FDD;
|
||||
int sock;
|
||||
AssertFatal((sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0, "");
|
||||
struct sockaddr_in addr = {
|
||||
@@ -200,14 +202,16 @@ sin_addr:
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t lastW=-1;
|
||||
int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, void **samplesVoid, int nsamps, int nbAnt, int flags) {
|
||||
rfsimulator_state_t *t = device->priv;
|
||||
LOG_D(HW,"sending %d samples at time: %ld\n", nsamps, timestamp);
|
||||
|
||||
for (int i=0; i<FD_SETSIZE; i++) {
|
||||
buffer_t *ptr=&t->buf[i];
|
||||
|
||||
if (ptr->conn_sock >= 0 ) {
|
||||
transferHeader header= {t->typeStamp, nsamps, nbAnt, timestamp};
|
||||
samplesBlockHeader_t header= {t->typeStamp, nsamps, nbAnt, timestamp};
|
||||
fullwrite(ptr->conn_sock,&header, sizeof(header), t);
|
||||
sample_t tmpSamples[nsamps][nbAnt];
|
||||
|
||||
@@ -222,7 +226,7 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi
|
||||
fullwrite(ptr->conn_sock, (void *)tmpSamples, sampleToByte(nsamps,nbAnt), t);
|
||||
}
|
||||
}
|
||||
|
||||
lastW=timestamp;
|
||||
LOG_D(HW,"sent %d samples at time: %ld->%ld, energy in first antenna: %d\n",
|
||||
nsamps, timestamp, timestamp+nsamps, signal_energy(samplesVoid[0], nsamps) );
|
||||
return nsamps;
|
||||
@@ -232,7 +236,7 @@ static bool flushInput(rfsimulator_state_t *t) {
|
||||
// Process all incoming events on sockets
|
||||
// store the data in lists
|
||||
struct epoll_event events[FD_SETSIZE]= {0};
|
||||
int nfds = epoll_wait(t->epollfd, events, FD_SETSIZE, 200);
|
||||
int nfds = epoll_wait(t->epollfd, events, FD_SETSIZE, 20);
|
||||
|
||||
if ( nfds==-1 ) {
|
||||
if ( errno==EINTR || errno==EAGAIN )
|
||||
@@ -263,7 +267,7 @@ static bool flushInput(rfsimulator_state_t *t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int blockSz;
|
||||
ssize_t blockSz;
|
||||
|
||||
if ( b->headerMode)
|
||||
blockSz=b->remainToTransfer;
|
||||
@@ -272,7 +276,7 @@ static bool flushInput(rfsimulator_state_t *t) {
|
||||
b->remainToTransfer :
|
||||
b->circularBufEnd - 1 - b->transferPtr ;
|
||||
|
||||
int sz=recv(fd, b->transferPtr, blockSz, MSG_DONTWAIT);
|
||||
ssize_t sz=recv(fd, b->transferPtr, blockSz, MSG_DONTWAIT);
|
||||
|
||||
if ( sz < 0 ) {
|
||||
if ( errno != EAGAIN ) {
|
||||
@@ -282,6 +286,7 @@ static bool flushInput(rfsimulator_state_t *t) {
|
||||
} else if ( sz == 0 )
|
||||
continue;
|
||||
|
||||
LOG_D(HW, "Socket rcv %zd bytes\n", sz);
|
||||
AssertFatal((b->remainToTransfer-=sz) >= 0, "");
|
||||
b->transferPtr+=sz;
|
||||
|
||||
@@ -290,8 +295,8 @@ static bool flushInput(rfsimulator_state_t *t) {
|
||||
|
||||
// check the header and start block transfer
|
||||
if ( b->headerMode==true && b->remainToTransfer==0) {
|
||||
AssertFatal( (t->typeStamp == MAGICUE && b->th.magic==MAGICeNB) ||
|
||||
(t->typeStamp == MAGICeNB && b->th.magic==MAGICUE), "Socket Error in protocol");
|
||||
AssertFatal( (t->typeStamp == UE_MAGICDL_FDD && b->th.magic==ENB_MAGICDL_FDD) ||
|
||||
(t->typeStamp == ENB_MAGICDL_FDD && b->th.magic==UE_MAGICDL_FDD), "Socket Error in protocol");
|
||||
b->headerMode=false;
|
||||
b->alreadyRead=true;
|
||||
|
||||
@@ -306,23 +311,24 @@ static bool flushInput(rfsimulator_state_t *t) {
|
||||
}
|
||||
|
||||
b->lastReceivedTS=b->th.timestamp;
|
||||
AssertFatal(lastW == -1 || ( abs((double)lastW-b->lastReceivedTS) < (double)CirSize),
|
||||
"Tx/Rx shift too large Tx:%lu, Rx:%lu\n", lastW, b->lastReceivedTS);
|
||||
b->transferPtr=(char *)&b->circularBuf[b->lastReceivedTS%CirSize];
|
||||
b->remainToTransfer=sampleToByte(b->th.size, b->th.nbAnt);
|
||||
}
|
||||
|
||||
if ( b->headerMode==false ) {
|
||||
LOG_D(HW,"Set b->lastReceivedTS %ld\n", b->lastReceivedTS);
|
||||
b->lastReceivedTS=b->th.timestamp+b->th.size-byteToSample(b->remainToTransfer,b->th.nbAnt);
|
||||
|
||||
// First block in UE, resync with the eNB current TS
|
||||
if ( t->nextTimestamp == 0 )
|
||||
t->nextTimestamp=b->lastReceivedTS-b->th.size;
|
||||
|
||||
if ( b->remainToTransfer==0) {
|
||||
LOG_D(HW,"Completed block reception: %ld\n", b->lastReceivedTS);
|
||||
|
||||
// First block in UE, resync with the eNB current TS
|
||||
if ( t->nextTimestamp == 0 )
|
||||
t->nextTimestamp=b->lastReceivedTS-b->th.size;
|
||||
|
||||
b->headerMode=true;
|
||||
b->transferPtr=(char *)&b->th;
|
||||
b->remainToTransfer=sizeof(transferHeader);
|
||||
b->remainToTransfer=sizeof(samplesBlockHeader_t);
|
||||
b->th.magic=-1;
|
||||
}
|
||||
}
|
||||
@@ -365,13 +371,14 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
|
||||
do {
|
||||
have_to_wait=false;
|
||||
|
||||
for ( int sock=0; sock<FD_SETSIZE; sock++)
|
||||
if ( t->buf[sock].circularBuf &&
|
||||
t->buf[sock].alreadyRead && //>= t->initialAhead &&
|
||||
(t->nextTimestamp+nsamps) > t->buf[sock].lastReceivedTS ) {
|
||||
have_to_wait=true;
|
||||
break;
|
||||
}
|
||||
for ( int sock=0; sock<FD_SETSIZE; sock++) {
|
||||
if ( t->buf[sock].circularBuf && t->buf[sock].alreadyRead )
|
||||
if ( t->buf[sock].lastReceivedTS == 0 ||
|
||||
(t->nextTimestamp+nsamps) > t->buf[sock].lastReceivedTS ) {
|
||||
have_to_wait=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (have_to_wait)
|
||||
/*printf("Waiting on socket, current last ts: %ld, expected at least : %ld\n",
|
||||
@@ -439,6 +446,7 @@ int rfsimulator_set_gains(openair0_device *device, openair0_config_t *openair0_c
|
||||
__attribute__((__visibility__("default")))
|
||||
int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
|
||||
//set_log(HW,OAILOG_DEBUG);
|
||||
//set_log(PHY,OAILOG_DEBUG);
|
||||
rfsimulator_state_t *rfsimulator = (rfsimulator_state_t *)calloc(sizeof(rfsimulator_state_t),1);
|
||||
|
||||
if ((rfsimulator->ip=getenv("RFSIMULATOR")) == NULL ) {
|
||||
@@ -446,11 +454,26 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rfsimulator->typeStamp = strncasecmp(rfsimulator->ip,"enb",3) == 0 ?
|
||||
MAGICeNB:
|
||||
MAGICUE;
|
||||
LOG_I(HW,"rfsimulator: running as %s\n", rfsimulator-> typeStamp == MAGICeNB ? "eNB" : "UE");
|
||||
device->trx_start_func = rfsimulator->typeStamp == MAGICeNB ?
|
||||
if ( strncasecmp(rfsimulator->ip,"enb",3) == 0 ||
|
||||
strncasecmp(rfsimulator->ip,"server",3) == 0 )
|
||||
rfsimulator->typeStamp = ENB_MAGICDL_FDD;
|
||||
else
|
||||
rfsimulator->typeStamp = UE_MAGICDL_FDD;
|
||||
|
||||
LOG_I(HW,"rfsimulator: running as %s\n", rfsimulator-> typeStamp == ENB_MAGICDL_FDD ? "(eg)NB" : "UE");
|
||||
char *saveF;
|
||||
|
||||
if ((saveF=getenv("saveIQfile")) != NULL) {
|
||||
rfsimulator->saveIQfile=open(saveF,O_APPEND| O_CREAT|O_TRUNC | O_WRONLY, 0666);
|
||||
|
||||
if ( rfsimulator->saveIQfile != -1 )
|
||||
LOG_I(HW,"rfsimulator: will save written IQ samples in %s\n", saveF);
|
||||
else
|
||||
LOG_E(HW, "can't open %s for IQ saving (%s)\n", saveF, strerror(errno));
|
||||
} else
|
||||
rfsimulator->saveIQfile = -1;
|
||||
|
||||
device->trx_start_func = rfsimulator->typeStamp == ENB_MAGICDL_FDD ?
|
||||
server_start :
|
||||
start_ue;
|
||||
device->trx_get_stats_func = rfsimulator_get_stats;
|
||||
@@ -470,6 +493,5 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
|
||||
rfsimulator->buf[i].conn_sock=-1;
|
||||
|
||||
AssertFatal((rfsimulator->epollfd = epoll_create1(0)) != -1,"");
|
||||
rfsimulator->initialAhead=openair0_cfg[0].sample_rate/1000; // One sub frame
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
Author: Laurent THOMAS, Open Cells
|
||||
copyleft: OpenAirInterface Software Alliance and it's licence
|
||||
*/
|
||||
|
||||
#include <common/utils/simple_executable.h>
|
||||
|
||||
|
||||
void fullwrite(int fd, void *_buf, int count) {
|
||||
char *buf = _buf;
|
||||
int l;
|
||||
|
||||
while (count) {
|
||||
l = write(fd, buf, count);
|
||||
|
||||
if (l <= 0) {
|
||||
if (errno==EINTR)
|
||||
continue;
|
||||
|
||||
if(errno==EAGAIN) {
|
||||
continue;
|
||||
} else {
|
||||
AssertFatal(false,"Lost socket\n");
|
||||
}
|
||||
} else {
|
||||
count -= l;
|
||||
buf += l;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int server_start(short port) {
|
||||
int listen_sock;
|
||||
AssertFatal((listen_sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0, "");
|
||||
int enable = 1;
|
||||
AssertFatal(setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) == 0, "");
|
||||
struct sockaddr_in addr = {
|
||||
sin_family:
|
||||
AF_INET,
|
||||
sin_port:
|
||||
htons(port),
|
||||
sin_addr:
|
||||
{ s_addr: INADDR_ANY }
|
||||
};
|
||||
bind(listen_sock, (struct sockaddr *)&addr, sizeof(addr));
|
||||
AssertFatal(listen(listen_sock, 5) == 0, "");
|
||||
return accept(listen_sock,NULL,NULL);
|
||||
}
|
||||
|
||||
int client_start(char *IP, short port) {
|
||||
int sock;
|
||||
AssertFatal((sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0, "");
|
||||
struct sockaddr_in addr = {
|
||||
sin_family:
|
||||
AF_INET,
|
||||
sin_port:
|
||||
htons(port),
|
||||
sin_addr:
|
||||
{ s_addr: INADDR_ANY }
|
||||
};
|
||||
addr.sin_addr.s_addr = inet_addr(IP);
|
||||
bool connected=false;
|
||||
|
||||
while(!connected) {
|
||||
LOG_I(HW,"rfsimulator: trying to connect to %s:%d\n", IP, port);
|
||||
|
||||
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) {
|
||||
LOG_I(HW,"rfsimulator: connection established\n");
|
||||
connected=true;
|
||||
}
|
||||
|
||||
perror("simulated node");
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
enum blocking_t {
|
||||
notBlocking,
|
||||
blocking
|
||||
};
|
||||
|
||||
void setblocking(int sock, enum blocking_t active) {
|
||||
int opts;
|
||||
AssertFatal( (opts = fcntl(sock, F_GETFL)) >= 0,"");
|
||||
|
||||
if (active==blocking)
|
||||
opts = opts & ~O_NONBLOCK;
|
||||
else
|
||||
opts = opts | O_NONBLOCK;
|
||||
|
||||
AssertFatal(fcntl(sock, F_SETFL, opts) >= 0, "");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if(argc != 4) {
|
||||
printf("Need parameters: source file, server or destination IP, TCP port\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int fd;
|
||||
AssertFatal((fd=open(argv[1],O_RDONLY)) != -1, "file: %s", argv[1]);
|
||||
off_t fileSize=lseek(fd, 0, SEEK_END);
|
||||
int serviceSock;
|
||||
|
||||
if (strcmp(argv[2],"server")==0) {
|
||||
serviceSock=server_start(atoi(argv[3]));
|
||||
} else {
|
||||
client_start(argv[2],atoi(argv[3]));
|
||||
}
|
||||
|
||||
samplesBlockHeader_t header;
|
||||
int bufSize=100000;
|
||||
void *buff=malloc(bufSize);
|
||||
|
||||
while (1) {
|
||||
//Rewind the file to loop on the samples
|
||||
if ( lseek(fd, 0, SEEK_CUR) >= fileSize )
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
// Read one block and send it
|
||||
setblocking(serviceSock, blocking);
|
||||
AssertFatal(read(fd,&header,sizeof(header)), "");
|
||||
fullwrite(serviceSock, &header, sizeof(header));
|
||||
int dataSize=sizeof(sample_t)*header.size*header.nbAnt;
|
||||
|
||||
if (dataSize>bufSize)
|
||||
buff=realloc(buff,dataSize);
|
||||
|
||||
AssertFatal(read(fd,buff,dataSize) == dataSize, "");
|
||||
fullwrite(serviceSock, buff, dataSize);
|
||||
// Purge incoming samples
|
||||
setblocking(serviceSock, notBlocking);
|
||||
|
||||
while(recv(serviceSock,buff, bufSize, MSG_DONTWAIT) > 0) {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
# define NUMBER_OF_NR_ULSCH_MAX 16
|
||||
# ifndef PHYSIM
|
||||
# ifndef UE_EXPANSION
|
||||
# define NUMBER_OF_UE_MAX 16
|
||||
# define NUMBER_OF_NR_UE_MAX 16
|
||||
# define NUMBER_OF_CONNECTED_eNB_MAX 3
|
||||
# define NUMBER_OF_CONNECTED_gNB_MAX 3
|
||||
# define NUMBER_OF_UE_MAX 4
|
||||
# define NUMBER_OF_NR_UE_MAX 4
|
||||
# define NUMBER_OF_CONNECTED_eNB_MAX 1
|
||||
# define NUMBER_OF_CONNECTED_gNB_MAX 1
|
||||
# else
|
||||
# define NUMBER_OF_UE_MAX 256
|
||||
# define NUMBER_OF_NR_UE_MAX 256
|
||||
|
||||
+17
-17
@@ -646,8 +646,8 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *subframe) {
|
||||
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, tti_tx );
|
||||
}
|
||||
|
||||
if (ru->feptx_ofdm) ru->feptx_ofdm(ru);
|
||||
if (ru->fh_south_out) ru->fh_south_out(ru);
|
||||
if (ru->feptx_ofdm) ru->feptx_ofdm(ru,frame_tx,tti_tx);
|
||||
if (ru->fh_south_out) ru->fh_south_out(ru,frame_tx,tti_tx,proc->timestamp_tx);
|
||||
}
|
||||
|
||||
void fh_if5_north_out(RU_t *ru) {
|
||||
@@ -1558,13 +1558,13 @@ static void* ru_thread_tx( void* param ) {
|
||||
if (oai_exit) break;
|
||||
|
||||
// do TX front-end processing if needed (precoding and/or IDFTs)
|
||||
if (ru->feptx_prec) ru->feptx_prec(ru);
|
||||
if (ru->feptx_prec) ru->feptx_prec(ru,proc->frame_tx,proc->tti_tx);
|
||||
|
||||
// do OFDM if needed
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru);
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru,proc->frame_tx,proc->tti_tx);
|
||||
if(!emulate_rf){
|
||||
// do outgoing fronthaul (south) if needed
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru);
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx);
|
||||
|
||||
if (ru->fh_north_out) ru->fh_north_out(ru);
|
||||
}
|
||||
@@ -1804,13 +1804,13 @@ static void* ru_thread( void* param ) {
|
||||
#ifndef PHY_TX_THREAD
|
||||
if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD || ru->num_eNB==0){
|
||||
// do TX front-end processing if needed (precoding and/or IDFTs)
|
||||
if (ru->feptx_prec) ru->feptx_prec(ru);
|
||||
if (ru->feptx_prec) ru->feptx_prec(ru,proc->frame_tx,proc->tti_tx);
|
||||
|
||||
// do OFDM if needed
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru);
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru,proc->frame_tx,proc->tti_tx);
|
||||
if(!emulate_rf){
|
||||
// do outgoing fronthaul (south) if needed
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru);
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx);
|
||||
|
||||
if (ru->fh_north_out) ru->fh_north_out(ru);
|
||||
}
|
||||
@@ -2074,10 +2074,10 @@ static void* rf_tx( void* param ) {
|
||||
// do TX front-end processing if needed (precoding and/or IDFTs)
|
||||
if (ru->feptx_prec) ru->feptx_prec(ru);
|
||||
// do OFDM if needed
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru);
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru,proc->frame_tx,proc->tti_tx);
|
||||
if(!emulate_rf){
|
||||
// do outgoing fronthaul (south) if needed
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru);
|
||||
if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx);
|
||||
|
||||
if (ru->fh_north_out) ru->fh_north_out(ru);
|
||||
}
|
||||
@@ -2114,11 +2114,11 @@ int stop_rf(RU_t *ru)
|
||||
|
||||
extern void fep_full(RU_t *ru);
|
||||
extern void ru_fep_full_2thread(RU_t *ru);
|
||||
extern void feptx_ofdm(RU_t *ru);
|
||||
extern void feptx_ofdm_2thread(RU_t *ru);
|
||||
extern void feptx_prec(RU_t *ru);
|
||||
extern void init_fep_thread(RU_t *ru,pthread_attr_t *attr);
|
||||
extern void init_feptx_thread(RU_t *ru,pthread_attr_t *attr);
|
||||
extern void feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx);
|
||||
extern void feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx);
|
||||
extern void feptx_prec(RU_t *ru,int frame_tx,int tti_tx);
|
||||
extern void init_fep_thread(RU_t *ru);
|
||||
extern void init_feptx_thread(RU_t *ru);
|
||||
extern void kill_fep_thread(RU_t *ru);
|
||||
extern void kill_feptx_thread(RU_t *ru);
|
||||
|
||||
@@ -2256,8 +2256,8 @@ void init_RU_proc(RU_t *ru) {
|
||||
}
|
||||
|
||||
if (get_thread_worker_conf() == WORKER_ENABLE) {
|
||||
init_fep_thread(ru,NULL);
|
||||
init_feptx_thread(ru,NULL);
|
||||
init_fep_thread(ru);
|
||||
init_feptx_thread(ru);
|
||||
}
|
||||
if (opp_enabled == 1) pthread_create(&ru->ru_stats_thread,NULL,ru_stats_thread,(void*)ru);
|
||||
|
||||
|
||||
@@ -431,6 +431,7 @@ static void *scope_thread(void *arg) {
|
||||
PHY_vars_UE_g[0][0],
|
||||
0,
|
||||
0,7);
|
||||
usleep(10000);
|
||||
|
||||
// printf("%s",stats_buffer);
|
||||
}
|
||||
@@ -1004,7 +1005,7 @@ printf("~~~~~~~~~~~~~~~~~~~~successfully get the parallel config[%d], worker con
|
||||
|
||||
|
||||
|
||||
#ifndef DEADLINE_SCHEDULER
|
||||
#if 0 // #ifndef DEADLINE_SCHEDULER
|
||||
|
||||
printf("NO deadline scheduler\n");
|
||||
/* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */
|
||||
|
||||
@@ -254,7 +254,6 @@ static void* gNB_L1_thread_tx(void* param) {
|
||||
|
||||
thread_top_init(thread_name,1,870000L,1000000L,1000000L);
|
||||
|
||||
// This tells L1_thread (RX) that L1_thread_tx is ready
|
||||
pthread_mutex_lock(&L1_proc_tx->mutex);
|
||||
L1_proc_tx->instance_cnt++;
|
||||
pthread_mutex_unlock(&L1_proc_tx->mutex);
|
||||
|
||||
@@ -1681,12 +1681,6 @@ int stop_rf(RU_t *ru)
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern void fep_full(RU_t *ru);
|
||||
extern void ru_fep_full_2thread(RU_t *ru);
|
||||
extern void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx);
|
||||
extern void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx);
|
||||
extern void feptx_prec(RU_t *ru, int frame_tx,int tti_tx);
|
||||
extern void init_fep_thread(RU_t *ru,pthread_attr_t *attr);
|
||||
extern void init_nr_feptx_thread(RU_t *ru,pthread_attr_t *attr);
|
||||
|
||||
void init_RU_proc(RU_t *ru) {
|
||||
|
||||
@@ -1239,6 +1239,8 @@ int main( int argc, char **argv )
|
||||
|
||||
// wait for end of program
|
||||
printf("TYPE <CTRL-C> TO TERMINATE\n");
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
//getchar();
|
||||
|
||||
#if defined(ENABLE_ITTI)
|
||||
|
||||
Reference in New Issue
Block a user