Commit 2d73a4a3 authored by Florian Kaltenberger's avatar Florian Kaltenberger

added functionality to map UEs and eNBs to different cards and RF chains

moved some functionality from device_init to dump_config in openair0 library


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5744 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 111c43ac
......@@ -40,6 +40,10 @@ typedef struct openair0_device_t openair0_device;
/* structrue holds the parameters to configure USRP devices
*/
#ifdef USRP
#define MAX_CARDS 1
#endif
typedef enum {
max_gain=0,med_gain,byp_gain
} rx_gain_t;
......@@ -68,6 +72,15 @@ typedef struct {
double tx_bw;
} openair0_config_t;
typedef struct {
/* card id */
int card;
/* rf chain id */
int chain;
} openair0_rf_map;
struct openair0_device_t {
/* USRP RF frontend parameters set by application */
openair0_config_t openair0_cfg;
......
......@@ -80,7 +80,6 @@ int openair0_open(void)
int card;
int ant;
int openair0_num_antennas[4];
PAGE_SHIFT = log2_int( sysconf( _SC_PAGESIZE ) );
......@@ -220,10 +219,12 @@ int openair0_close(void)
return 0;
}
/*
int openair0_dump_config(int card)
{
return ioctl(openair0_fd, openair_DUMP_CONFIG, card);
}
*/
int openair0_get_frame(int card)
{
......@@ -245,18 +246,15 @@ int openair0_stop_without_reset(int card)
return ioctl(openair0_fd, openair_STOP_WITHOUT_RESET, card);
}
static exmimo_config_t *p_exmimo_config;
static exmimo_id_t *p_exmimo_id;
#define MY_RF_MODE (RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + DMAMODE_RX + DMAMODE_TX)
#define RF_MODE_BASE (LNA1ON +LNAMax + RFBBNORM)
int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
// Initialize card
exmimo_config_t *p_exmimo_config;
exmimo_id_t *p_exmimo_id;
int ret;
int ant;
int resampling_factor=2;
int rx_filter=RXLPF25, tx_filter=TXLPF25;
ret = openair0_open();
......@@ -271,115 +269,141 @@ int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cf
return(ret);
}
printf ("Detected %d number of cards, %d number of antennas.\n", openair0_num_detected_cards, openair0_num_antennas[0]);
if (openair0_num_detected_cards>MAX_CARDS) {
printf ("Detected %d number of cards, but MAX_CARDS=%d\n", openair0_num_detected_cards, MAX_CARDS);
}
else {
printf ("Detected %d number of cards, %d number of antennas.\n", openair0_num_detected_cards, openair0_num_antennas[0]);
}
p_exmimo_config = openair0_exmimo_pci[0].exmimo_config_ptr;
p_exmimo_id = openair0_exmimo_pci[0].exmimo_id_ptr;
printf("Card %d: ExpressMIMO %d, HW Rev %d, SW Rev 0x%d\n", 0, p_exmimo_id->board_exmimoversion, p_exmimo_id->board_hwrev, p_exmimo_id->board_swrev);
// check if the software matches firmware
if (p_exmimo_id->board_swrev!=BOARD_SWREV_CNTL2) {
printf("Software revision %d and firmware revision %d do not match. Please update either the firmware or the software!\n",BOARD_SWREV_CNTL2,p_exmimo_id->board_swrev);
exit(-1);
}
if (!openair0_cfg) {
printf("Error, openair0_cfg is null!!\n");
return(-1);
}
if (p_exmimo_id->board_swrev>=9)
p_exmimo_config->framing.eNB_flag = 0;
else
p_exmimo_config->framing.eNB_flag = 1;//!UE_flag;
return(0);
}
p_exmimo_config->framing.tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
int openair0_dump_config(openair0_config_t *openair0_cfg, int UE_flag)
{
int ret;
int ant, card;
int resampling_factor=2;
int rx_filter=RXLPF25, tx_filter=TXLPF25;
if (openair0_cfg->sample_rate==30.72e6) {
resampling_factor = 0;
rx_filter = RXLPF10;
tx_filter = TXLPF10;
}
else if (openair0_cfg->sample_rate==15.36e6) {
resampling_factor = 1;
rx_filter = RXLPF5;
tx_filter = TXLPF5;
}
else if (openair0_cfg->sample_rate==7.68e6) {
resampling_factor = 2;
rx_filter = RXLPF25;
tx_filter = TXLPF25;
}
else {
printf("Sampling rate not supported, using default 7.68MHz");
resampling_factor = 2;
rx_filter = RXLPF25;
tx_filter = TXLPF25;
exmimo_config_t *p_exmimo_config;
exmimo_id_t *p_exmimo_id;
if (!openair0_cfg) {
printf("Error, openair0_cfg is null!!\n");
return(-1);
}
#if (BOARD_SWREV_CNTL2>=0x0A)
for (ant=0; ant<4; ant++)
p_exmimo_config->framing.resampling_factor[ant] = resampling_factor;
#else
p_exmimo_config->framing.resampling_factor = resampling_factor;
#endif
for (card=0; card<openair0_num_detected_cards; card++) {
for (ant=0;ant<max(openair0_cfg->tx_num_channels,openair0_cfg->rx_num_channels);ant++)
p_exmimo_config->rf.rf_mode[ant] = RF_MODE_BASE;
for (ant=0;ant<openair0_cfg->tx_num_channels;ant++)
p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX + TXLPFNORM + TXLPFEN + tx_filter);
for (ant=0;ant<openair0_cfg->rx_num_channels;ant++) {
p_exmimo_config->rf.rf_mode[ant] += (RXEN + DMAMODE_RX + RXLPFNORM + RXLPFEN + rx_filter);
switch (openair0_cfg->rxg_mode[ant]) {
default:
case max_gain:
p_exmimo_config->rf.rf_mode[ant] = (p_exmimo_config->rf.rf_mode[ant]&(~LNAGAINMASK))|LNAMax;
break;
case med_gain:
p_exmimo_config->rf.rf_mode[ant] = (p_exmimo_config->rf.rf_mode[ant]&(~LNAGAINMASK))|LNAMed;
break;
case byp_gain:
p_exmimo_config->rf.rf_mode[ant] = (p_exmimo_config->rf.rf_mode[ant]&(~LNAGAINMASK))|LNAByp;
break;
p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr;
p_exmimo_id = openair0_exmimo_pci[card].exmimo_id_ptr;
if (p_exmimo_id->board_swrev>=9)
p_exmimo_config->framing.eNB_flag = 0;
else
p_exmimo_config->framing.eNB_flag = !UE_flag;
p_exmimo_config->framing.tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
if (openair0_cfg[card].sample_rate==30.72e6) {
resampling_factor = 0;
rx_filter = RXLPF10;
tx_filter = TXLPF10;
}
}
for (ant=max(openair0_cfg->tx_num_channels,openair0_cfg->rx_num_channels);ant<4;ant++) {
p_exmimo_config->rf.rf_mode[ant] = 0;
}
for (ant = 0; ant<openair0_cfg->rx_num_channels; ant++) {
p_exmimo_config->rf.do_autocal[ant] = 1;
p_exmimo_config->rf.rf_freq_rx[ant] = (unsigned int)openair0_cfg->rx_freq[ant];
p_exmimo_config->rf.rx_gain[ant][0] = (unsigned int)openair0_cfg->rx_gain[ant];
printf("openair0 : programming RX antenna %d (freq %d, gain %d)\n",ant,p_exmimo_config->rf.rf_freq_rx[ant],p_exmimo_config->rf.rx_gain[ant][0]);
}
for (ant = 0; ant<openair0_cfg->tx_num_channels; ant++) {
p_exmimo_config->rf.rf_freq_tx[ant] = (unsigned int)openair0_cfg->tx_freq[ant];
p_exmimo_config->rf.tx_gain[ant][0] = (unsigned int)openair0_cfg->tx_gain[ant];
printf("openair0 : programming TX antenna %d (freq %d, gain %d)\n",ant,p_exmimo_config->rf.rf_freq_tx[ant],p_exmimo_config->rf.tx_gain[ant][0]);
}
p_exmimo_config->rf.rf_local[ant] = rf_local[ant];
p_exmimo_config->rf.rf_rxdc[ant] = rf_rxdc[ant];
for (ant=0;ant<4;ant++) {
p_exmimo_config->rf.rf_local[ant] = rf_local[ant];
p_exmimo_config->rf.rf_rxdc[ant] = rf_rxdc[ant];
if (( p_exmimo_config->rf.rf_freq_tx[ant] >= 850000000) && ( p_exmimo_config->rf.rf_freq_tx[ant] <= 865000000)) {
p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal_850[ant];
p_exmimo_config->rf.rffe_band_mode[ant] = DD_TDD;
else if (openair0_cfg[card].sample_rate==15.36e6) {
resampling_factor = 1;
rx_filter = RXLPF5;
tx_filter = TXLPF5;
}
else if (( p_exmimo_config->rf.rf_freq_tx[ant] >= 1900000000) && ( p_exmimo_config->rf.rf_freq_tx[ant] <= 2000000000)) {
p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant];
p_exmimo_config->rf.rffe_band_mode[ant] = B19G_TDD;
else if (openair0_cfg[card].sample_rate==7.68e6) {
resampling_factor = 2;
rx_filter = RXLPF25;
tx_filter = TXLPF25;
}
else {
p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant];
p_exmimo_config->rf.rffe_band_mode[ant] = 0;
printf("Sampling rate not supported, using default 7.68MHz");
resampling_factor = 2;
rx_filter = RXLPF25;
tx_filter = TXLPF25;
}
#if (BOARD_SWREV_CNTL2>=0x0A)
for (ant=0; ant<4; ant++)
p_exmimo_config->framing.resampling_factor[ant] = resampling_factor;
#else
p_exmimo_config->framing.resampling_factor = resampling_factor;
#endif
for (ant=0;ant<4;ant++) {
if (openair0_cfg[card].rx_freq[ant] || openair0_cfg[card].tx_freq[ant]) {
p_exmimo_config->rf.rf_mode[ant] = RF_MODE_BASE;
p_exmimo_config->rf.do_autocal[ant] = 1;
}
if (openair0_cfg[card].tx_freq[ant]) {
p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX + TXLPFNORM + TXLPFEN + tx_filter);
p_exmimo_config->rf.rf_freq_tx[ant] = (unsigned int)openair0_cfg[card].tx_freq[ant];
p_exmimo_config->rf.tx_gain[ant][0] = (unsigned int)openair0_cfg[card].tx_gain[ant];
printf("openair0 : programming TX antenna %d (freq %u, gain %d)\n",ant,p_exmimo_config->rf.rf_freq_tx[ant],p_exmimo_config->rf.tx_gain[ant][0]);
}
if (openair0_cfg[card].rx_freq[ant]) {
p_exmimo_config->rf.rf_mode[ant] += (RXEN + DMAMODE_RX + RXLPFNORM + RXLPFEN + rx_filter);
p_exmimo_config->rf.rf_freq_rx[ant] = (unsigned int)openair0_cfg[card].rx_freq[ant];
p_exmimo_config->rf.rx_gain[ant][0] = (unsigned int)openair0_cfg[card].rx_gain[ant];
printf("openair0 : programming RX antenna %d (freq %u, gain %d)\n",ant,p_exmimo_config->rf.rf_freq_rx[ant],p_exmimo_config->rf.rx_gain[ant][0]);
switch (openair0_cfg[card].rxg_mode[ant]) {
default:
case max_gain:
p_exmimo_config[card].rf.rf_mode[ant] = (p_exmimo_config->rf.rf_mode[ant]&(~LNAGAINMASK))|LNAMax;
break;
case med_gain:
p_exmimo_config[card].rf.rf_mode[ant] = (p_exmimo_config->rf.rf_mode[ant]&(~LNAGAINMASK))|LNAMed;
break;
case byp_gain:
p_exmimo_config[card].rf.rf_mode[ant] = (p_exmimo_config->rf.rf_mode[ant]&(~LNAGAINMASK))|LNAByp;
break;
}
}
else {
p_exmimo_config->rf.rf_mode[ant] = 0;
p_exmimo_config->rf.do_autocal[ant] = 0;
}
p_exmimo_config->rf.rf_local[ant] = rf_local[ant];
p_exmimo_config->rf.rf_rxdc[ant] = rf_rxdc[ant];
if (( p_exmimo_config->rf.rf_freq_tx[ant] >= 850000000) && ( p_exmimo_config->rf.rf_freq_tx[ant] <= 865000000)) {
p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal_850[ant];
p_exmimo_config->rf.rffe_band_mode[ant] = DD_TDD;
}
else if (( p_exmimo_config->rf.rf_freq_tx[ant] >= 1900000000) && ( p_exmimo_config->rf.rf_freq_tx[ant] <= 2000000000)) {
p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant];
p_exmimo_config->rf.rffe_band_mode[ant] = B19G_TDD;
}
else {
p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant];
p_exmimo_config->rf.rffe_band_mode[ant] = 0;
}
}
ret = ioctl(openair0_fd, openair_DUMP_CONFIG, card);
if (ret!=0)
return(-1);
}
return(0);
......
......@@ -63,7 +63,8 @@ int openair0_close(void);
// trigger config update on card
// return 0 on success
int openair0_dump_config(int card);
int openair0_dump_config(openair0_config_t *openair0_cfg, int UE_flag);
//int openair0_dump_config(int card);
// triggers recording of exactly 1 frame
// in case of synchronized multiple cards, send this only to the master card
......
......@@ -6,16 +6,13 @@ msg_many:lxrt+sem+mbx+msg+fifos:!sudo ./msg_test;sleep 1;popall:control_c
eNB:lxrt+sem+mbx+msg+fifos:!sudo ./synctest;sleep 1;popall:control_c
eNB_test:lxrt+sem+mbx+msg+smi:!sudo ./lte-softmodem -S -F enb2tx;sleep 1;popall:control_c
UE:lxrt+sem+mbx+msg+fifos:!sudo ./synctest -U -d -T 108;sleep 1;popall:control_c
#UE0:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907602944 -V;sleep 1;popall:control_c
#EXMIMO2 card 1
#UE0:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907600480 -V;sleep 1;popall:control_c
UE0:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907600480 -V -K /tmp/itti_UE0.log;sleep 1;popall:control_c
#EXMIMO2 card 5
#UE0:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907597240 -V;sleep 1;popall:control_c
#EXMIMO2 card 5
#UE0_smbv:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907598252 -V;sleep 1;popall:control_c
#EXMIMO2 card 24
#UE0_smbv:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907595776 -V;sleep 1;popall:control_c
#EXMIMO2 card 5?
UE0_smbv:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907598252 -V;sleep 1;popall:control_c
#EXMIMO2 card 38
UE0_smbv:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907592704 -V;sleep 1;popall:control_c
UE850:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 859498000 -F ex2_850;sleep 1;popall:control_c
eNB850:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -d -C 859500000 -F ex2_850;sleep 1;popall:control_c
UE0noL2:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907600480 --no-L2-connect;sleep 1;popall:control_c
......@@ -31,9 +28,9 @@ UE2prach:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907600000 -F ue2
UE2noL2:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -U -d -C 1907600000 -F ue2 --no-L2-connect;sleep 1;popall:control_c
#eNB0:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -C 1907600000 -d -V;sleep 1;popall:control_c
#eNB0:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -C 1907598252 -d -V;sleep 1;popall:control_c
eNB0:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -d -O../../PROJECTS/GENERIC-LTE-EPC/CONF/enb.sfr.sud.conf -V -K /tmp/itti_eNB0.log;sleep 1;popall:control_c
eNB1:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -C 1907600000 -F ex2_2 -d;sleep 1;popall:control_c
eNB2:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -C 1907600000 -F ue2 -d;sleep 1;popall:control_c
eNB0:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -d -O../../PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.conf -V -K /tmp/itti_eNB0.log;sleep 1;popall:control_c
eNB1:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -C 2680000000 -r 50 -d -V;sleep 1;popall:control_c
eNB2:lxrt+sem+mbx+msg+fifos:!sudo ./lte-softmodem -C 2680000000 -r 100 -d -V;sleep 1;popall:control_c
dot11:lxrt+sem+mbx+msg+fifos:!sudo ./dot11 -C 1907600000 -d;sleep 1;popall:control_c
dot11_tx_test: lxrt+sem+mbx+msg+fifos:!sudo ./dot11 -C 1907600000 -d -t;sleep 1;popall:control_c
eNB2_750:lxrt+sem+mbx+msg+fifos:!sudo ./synctest_eNB -C 746000000 -F enb1tx_750 -d;sleep 1;popall:control_c
......
......@@ -132,7 +132,8 @@ OBJ += $(OPENAIR1_DIR)/SIMULATION/ETH_TRANSPORT/netlink_init.o
CFLAGS += -DOPENAIR2 -DNO_RRM -DPUCCH -DMAC_CONTEXT=1
endif
RTAI_OBJ += $(UTILS_OBJS)
#RTAI_
OBJ += $(UTILS_OBJS)
......
......@@ -146,11 +146,12 @@ void cleanup_dlsch_threads(void);
int32_t init_rx_pdsch_thread(void);
void cleanup_rx_pdsch_thread(void);
openair0_config_t openair0_cfg[MAX_CARDS];
int32_t *rxdata;
int32_t *txdata;
void setup_ue_buffers(PHY_VARS_UE *phy_vars_ue, LTE_DL_FRAME_PARMS *frame_parms, int carrier);
void setup_eNB_buffers(PHY_VARS_eNB *phy_vars_eNB, LTE_DL_FRAME_PARMS *frame_parms, int carrier);
int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg, openair0_rf_map rf_map[MAX_NUM_CCs]);
int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg, openair0_rf_map rf_map[MAX_NUM_CCs]);
#ifdef XFORMS
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
......@@ -221,11 +222,11 @@ static int time_offset[4] = {0,0,0,0};
static char UE_flag=0;
static uint8_t eNB_id=0,UE_id=0;
static uint8_t eNB_id=0,UE_id=0;
uint32_t carrier_freq[4] = {1907600000,1907600000,1907600000,1907600000}; /* For UE! */
static uint32_t downlink_frequency[4] = {1907600000,1907600000,1907600000,1907600000};
static int32_t uplink_frequency_offset[4]= {-120000000,-120000000,-120000000,-120000000};
uint32_t carrier_freq[MAX_NUM_CCs][4] = {{1907600000,1907600000,1907600000,1907600000}}; /* For UE! */
static uint32_t downlink_frequency[MAX_NUM_CCs][4] = {{1907600000,1907600000,1907600000,1907600000}};
static int32_t uplink_frequency_offset[MAX_NUM_CCs][4]= {{-120000000,-120000000,-120000000,-120000000}};
static char *conf_config_file_name = NULL;
#if defined(ENABLE_ITTI)
......@@ -1025,7 +1026,7 @@ static void * eNB_thread_rx(void *param) {
void init_eNB_proc() {
void init_eNB_proc(void) {
int i;
int CC_id;
......@@ -1085,7 +1086,7 @@ void init_eNB_proc() {
}
}
void kill_eNB_proc() {
void kill_eNB_proc(void) {
int i;
int *status_tx,*status_rx;
......@@ -1491,7 +1492,7 @@ static void *UE_thread(void *arg) {
int i, ret;
volatile unsigned int *DAQ_MBOX = openair0_daq_cnt();
#ifndef USRP
exmimo_config_t *p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr;;
//exmimo_config_t *p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr;;
#endif
......@@ -1657,19 +1658,19 @@ static void *UE_thread(void *arg) {
else {
LOG_I(PHY,"[initial_sync] trying carrier off %d Hz\n",openair_daq_vars.freq_offset);
#ifndef USRP
for (i=0; i<4; i++) {
if (p_exmimo_config->rf.rf_freq_rx[i])
p_exmimo_config->rf.rf_freq_rx[i] = carrier_freq[i]+openair_daq_vars.freq_offset;
if (p_exmimo_config->rf.rf_freq_tx[i])
p_exmimo_config->rf.rf_freq_tx[i] = carrier_freq[i]+openair_daq_vars.freq_offset;
for (card=0;card<MAX_CARDS;card++) {
for (i=0; i<openair0_cfg[card].rx_num_channels; i++) {
openair0_cfg[card].rx_freq[i] = carrier_freq[card][i]+openair_daq_vars.freq_offset;
openair0_cfg[card].tx_freq[i] = carrier_freq[card][i]+openair_daq_vars.freq_offset;
}
}
openair0_dump_config(&openair0_cfg[0],UE_flag);
#endif
openair0_dump_config(card);
rt_sleep_ns(FRAME_PERIOD);
}
}
}
/*
if ((slot%2000)<10)
LOG_D(HW,"fun0: doing very hard work\n");
......@@ -1703,7 +1704,7 @@ static void *UE_thread(void *arg) {
static void get_options (int argc, char **argv) {
int c;
int c;
// char line[1000];
// int l;
int k;//i,j,k;
......@@ -1772,15 +1773,17 @@ static void get_options (int argc, char **argv) {
multi_thread=0;
break;
case 'C':
downlink_frequency[0] = atof(optarg); // Use float to avoid issue with frequency over 2^31.
downlink_frequency[1] = downlink_frequency[0];
downlink_frequency[2] = downlink_frequency[0];
downlink_frequency[3] = downlink_frequency[0];
carrier_freq[0] = downlink_frequency[0];
carrier_freq[1] = downlink_frequency[1];
carrier_freq[2] = downlink_frequency[2];
carrier_freq[3] = downlink_frequency[3];
printf("Downlink frequency set to %u\n", downlink_frequency[0]);
for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
downlink_frequency[CC_id][0] = atof(optarg); // Use float to avoid issue with frequency over 2^31.
downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0];
downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0];
downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0];
carrier_freq[CC_id][0] = downlink_frequency[CC_id][0];
carrier_freq[CC_id][1] = downlink_frequency[CC_id][1];
carrier_freq[CC_id][2] = downlink_frequency[CC_id][2];
carrier_freq[CC_id][3] = downlink_frequency[CC_id][3];
}
printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]);
break;
case 'd':
......@@ -1908,13 +1911,16 @@ static void get_options (int argc, char **argv) {
rrc_log_verbosity = enb_properties->properties[i]->rrc_log_verbosity;
// adjust the log
for (k = 0 ; k < (sizeof(downlink_frequency) / sizeof (downlink_frequency[0])); k++) {
downlink_frequency[k] = enb_properties->properties[i]->downlink_frequency[0];
printf("Downlink frequency set to %u\n", downlink_frequency[k]);
uplink_frequency_offset[k] = enb_properties->properties[i]->uplink_frequency_offset[0];
} // k
// adjust the log
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
for (k = 0 ; k < 4; k++) {
downlink_frequency[CC_id][k] = enb_properties->properties[i]->downlink_frequency[CC_id];
uplink_frequency_offset[CC_id][k] = enb_properties->properties[i]->uplink_frequency_offset[CC_id];
}
printf("Downlink frequency/ uplink offset of CC_id %d set to %llu/%d\n", CC_id,
enb_properties->properties[i]->downlink_frequency[CC_id],
enb_properties->properties[i]->uplink_frequency_offset[CC_id]);
} // CC_id
}// i
}
}
......@@ -1954,7 +1960,8 @@ int main(int argc, char **argv) {
#if defined (EMOS) || (! defined (RTAI))
int error_code;
#endif
openair0_config_t openair0_cfg;
memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS);
set_latency_target();
......@@ -2159,17 +2166,17 @@ int main(int argc, char **argv) {
if ((mode == normal_txrx) || (mode == rx_calib_ue) || (mode == no_L2_connect) || (mode == debug_prach)) {
for (i=0;i<4;i++)
openair0_cfg.rxg_mode[i] = max_gain;
openair0_cfg[CC_id].rxg_mode[i] = max_gain;
PHY_vars_UE_g[CC_id][0]->rx_total_gain_dB = PHY_vars_UE_g[CC_id][0]->rx_gain_max[0] + (int)rx_gain - 30; //-30 because it was calibrated with a 30dB gain
}
else if ((mode == rx_calib_ue_med)) {
for (i=0;i<4;i++)
openair0_cfg.rxg_mode[i] = med_gain;
openair0_cfg[CC_id].rxg_mode[i] = med_gain;
PHY_vars_UE_g[CC_id][0]->rx_total_gain_dB = PHY_vars_UE_g[CC_id][0]->rx_gain_med[0] + (int)rx_gain - 30; //-30 because it was calibrated with a 30dB gain;
}
else if ((mode == rx_calib_ue_byp)) {
for (i=0;i<4;i++)
openair0_cfg.rxg_mode[i] = byp_gain;
openair0_cfg[CC_id].rxg_mode[i] = byp_gain;
PHY_vars_UE_g[CC_id][0]->rx_total_gain_dB = PHY_vars_UE_g[CC_id][0]->rx_gain_byp[0] + (int)rx_gain - 30; //-30 because it was calibrated with a 30dB gain;
}
......@@ -2214,6 +2221,9 @@ int main(int argc, char **argv) {
PHY_vars_eNB_g[0][CC_id]->rx_total_gain_eNB_dB = rxg_max[0] + (int)rx_gain - 30; //was measured at rxgain=30;
// set eNB to max gain
for (i=0;i<4;i++)
openair0_cfg[CC_id].rxg_mode[i] = max_gain;
}
NB_eNB_INST=1;
NB_INST=1;
......@@ -2223,9 +2233,6 @@ int main(int argc, char **argv) {
openair_daq_vars.ue_ul_nb_rb=6;
openair_daq_vars.target_ue_ul_mcs=6;
// set eNB to max gain
for (i=0;i<4;i++)
openair0_cfg.rxg_mode[i] = max_gain;
}
......@@ -2267,34 +2274,25 @@ int main(int argc, char **argv) {
#endif
}
mac_xface = malloc(sizeof(MAC_xface));
openair0_cfg.sample_rate = sample_rate;
openair0_cfg.tx_num_channels = frame_parms[0]->nb_antennas_tx;
openair0_cfg.rx_num_channels = frame_parms[0]->nb_antennas_rx;
for (i=0;i<4;i++) {
if (UE_flag==1) {
openair0_cfg.tx_freq[i] = downlink_frequency[i]+uplink_frequency_offset[i];
openair0_cfg.rx_freq[i] = downlink_frequency[i];
}
else {
openair0_cfg.rx_freq[i] = downlink_frequency[i]+uplink_frequency_offset[i];
openair0_cfg.tx_freq[i] = downlink_frequency[i];
for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
openair0_cfg[CC_id].sample_rate = sample_rate;
openair0_cfg[CC_id].tx_bw = bw;
openair0_cfg[CC_id].rx_bw = bw;
for (i=0;i<4;i++) {
openair0_cfg[CC_id].tx_gain[i] = tx_gain;
openair0_cfg[CC_id].rx_gain[i] = rx_gain;
}
}
openair0_cfg.tx_bw = bw;
openair0_cfg.rx_bw = bw;
for (i=0;i<4;i++) {
openair0_cfg.tx_gain[i] = tx_gain;
openair0_cfg.rx_gain[i] = rx_gain;
}
if (openair0_device_init(&openair0, &openair0_cfg) <0) {
if (openair0_device_init(&openair0, &openair0_cfg[0]) <0) {
printf("Exiting, cannot initialize device\n");
exit(-1);
}
mac_xface = malloc(sizeof(MAC_xface));
#ifdef OPENAIR2
int eMBMS_active=0;
......@@ -2338,30 +2336,37 @@ int main(int argc, char **argv) {
openair_daq_vars.timing_advance = 0;
openair0_rf_map rf_map[MAX_NUM_CCs];
rf_map[0].card=0;
rf_map[0].chain=1;
// connect the TX/RX buffers
if (UE_flag==1) {
setup_ue_buffers(PHY_vars_UE_g[0],&openair0_cfg[0],rf_map);
printf("Setting UE buffer to all-RX\n");
// Set LSBs for antenna switch (ExpressMIMO)
for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
setup_ue_buffers(PHY_vars_UE_g[CC_id][0],frame_parms[CC_id],ant_offset);
printf("Setting UE buffer to all-RX\n");
// Set LSBs for antenna switch (ExpressMIMO)
for (i=0; i<frame_parms[CC_id]->samples_per_tti*10; i++)
for (aa=0; aa<frame_parms[CC_id]->nb_antennas_tx; aa++)
PHY_vars_UE_g[CC_id][0]->lte_ue_common_vars.txdata[aa][i] = 0x00010001;
PHY_vars_UE_g[0][CC_id]->lte_ue_common_vars.txdata[aa][i] = 0x00010001;
}
//p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX;
}
else {
if (setup_eNB_buffers(PHY_vars_eNB_g[0],&openair0_cfg[0],rf_map)!=0) {
printf("Error setting up eNB buffer\n");
exit(-1);
}
printf("Setting eNB buffer to all-RX\n");
// Set LSBs for antenna switch (ExpressMIMO)
for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
setup_eNB_buffers(PHY_vars_eNB_g[CC_id][0],frame_parms[CC_id],ant_offset);
printf("Setting eNB buffer to all-RX\n");
// Set LSBs for antenna switch (ExpressMIMO)
for (i=0; i<frame_parms[CC_id]->samples_per_tti*10; i++)
for (aa=0; aa<frame_parms[CC_id]->nb_antennas_tx; aa++)
PHY_vars_eNB_g[CC_id][0]->lte_eNB_common_vars.txdata[0][aa][i] = 0x00010001;
PHY_vars_eNB_g[0][CC_id]->lte_eNB_common_vars.txdata[0][aa][i] = 0x00010001;
}
}
#ifndef USRP
openair0_dump_config(card);
openair0_dump_config(&openair0_cfg[0],UE_flag);
#endif
/*
......@@ -2652,109 +2657,158 @@ int main(int argc, char **argv) {
return 0;
}
void setup_ue_buffers(PHY_VARS_UE *phy_vars_ue, LTE_DL_FRAME_PARMS *frame_parms, int carrier) {
int i;
int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg, openair0_rf_map rf_map[MAX_NUM_CCs])
{
#ifndef USRP
if (phy_vars_ue) {
if ((frame_parms[0]->nb_antennas_rx>1) && (carrier>0)) {
printf("RX antennas > 1 and carrier > 0 not possible\n");
exit(-1);
int i, CC_id;
LTE_DL_FRAME_PARMS *frame_parms;
for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
if (phy_vars_ue[CC_id]) {
frame_parms = &(phy_vars_ue[CC_id]->lte_frame_parms);
}
if ((frame_parms[0]->nb_antennas_tx>1) && (carrier>0)) {
printf("TX antennas > 1 and carrier > 0 not possible\n");
exit(-1);
else {
printf("phy_vars_eNB[%d] not initialized\n", CC_id);
return(-1);
}
// replace RX signal buffers with mmaped HW versions
for (i=0;i<frame_parms[0]->nb_antennas_rx;i++) {
free(phy_vars_ue->lte_ue_common_vars.rxdata[i]);
phy_vars_ue->lte_ue_common_vars.rxdata[i] = (int32_t*) openair0_exmimo_pci[card].adc_head[i+carrier];
openair0_cfg[CC_id].tx_num_channels = 0;
openair0_cfg[CC_id].rx_num_channels = 0;
// replace RX signal buffers with mmaped HW versions
for (i=0;i<frame_parms->nb_antennas_rx;i++) {
printf("Mapping eNB CC_id %d, rx_ant %d, freq %u on card %d, chain %d\n",CC_id,i,downlink_frequency[CC_id][i],rf_map[CC_id].card,rf_map[CC_id].chain+i);
free(phy_vars_ue[CC_id]->lte_ue_common_vars.rxdata[i]);
phy_vars_ue[CC_id]->lte_ue_common_vars.rxdata[i] = (int32_t*) openair0_exmimo_pci[rf_map[CC_id].card].adc_head[rf_map[CC_id].chain+i];
if (openair0_cfg[rf_map[CC_id].card].rx_freq[rf_map[CC_id].chain+i]) {
printf("Error with rf_map! A channel has already been allocated!\n");
return(-1);
}
else {
openair0_cfg[rf_map[CC_id].card].rx_freq[rf_map[CC_id].chain+i] = downlink_frequency[CC_id][i];
openair0_cfg[rf_map[CC_id].card].rx_num_channels++;
}
printf("rxdata[%d] @ %p\n",i,phy_vars_ue->lte_ue_common_vars.rxdata[i]);