Commit a026c87b authored by Florian Kaltenberger's avatar Florian Kaltenberger

updating EXMIMO2 firmware (corresponding to r5585 of openair0) and driver

updating emos-raw (seperate thread for logfile, GPS supported again)
small cosmetic changes in openair1


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5241 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 2d1f1ef3
......@@ -44,6 +44,8 @@ phy_measurements_struct = struct(...
'n_adj_cells_id', uint32(zeros(1,6)),...
'rsrq', int32(zeros(1,7)),...
'rsrp', int32(zeros(1,7)),...
'rsrp_filtered', single(zeros(1,7)),...
'rsrq_filtered', single(zeros(1,7)),...
'n0_power', uint32(zeros(1,NB_ANTENNAS_RX)),...
'n0_power_dB', uint16(zeros(1,NB_ANTENNAS_RX)),...
'n0_power_tot', uint32(0),...
......
......@@ -1582,7 +1582,7 @@ int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci) {
break;
case format1E_2A_M10PRB:
msg("DCI format1E_2A_M10PRB, rnti %x (%8x): harq_pid %d, rah %d, rb_alloc %x, mcs %d, rv %d, tpmi %d, ndi %d, dl_power_offset %d\n",
LOG_D(PHY,"DCI format1E_2A_M10PRB, rnti %x (%8x): harq_pid %d, rah %d, rb_alloc %x, mcs %d, rv %d, tpmi %d, ndi %d, dl_power_offset %d\n",
dci->rnti,
((uint32_t *)&dci->dci_pdu)[0],
((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->harq_pid,
......
......@@ -44,8 +44,9 @@
#include "SCHED/extern.h"
#include "defs.h"
#include "extern.h"
#ifdef EXMIMO
#include "gain_control.h"
#endif
//#define DEBUG_INITIAL_SYNCH
......@@ -270,9 +271,12 @@ int initial_sync(PHY_VARS_UE *phy_vars_ue, runmode_t mode) {
LOG_I(PHY,"[UE%d] Initial sync : Estimated power: %d dB\n",phy_vars_ue->Mod_id,phy_vars_ue->PHY_measurements.rx_power_avg_dB[0] );
#endif
#ifdef EXMIMO
if ((openair_daq_vars.rx_gain_mode == DAQ_AGC_ON) &&
(mode != rx_calib_ue) && (mode != rx_calib_ue_med) && (mode != rx_calib_ue_byp) )
phy_adjust_gain(phy_vars_ue,0);
//phy_adjust_gain(phy_vars_ue,0);
gain_control_all(phy_vars_ue->PHY_measurements.rx_power_avg_dB[0],0);
#endif
// SSS detection
......
......@@ -95,9 +95,9 @@ int dump_ue_stats(PHY_VARS_UE *phy_vars_ue, char* buffer, int length, runmode_t
#else
#ifdef EXMIMO
#ifdef DRIVER2013
len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB (rf_mode %d, vga %d dB)\n",phy_vars_ue->rx_total_gain_dB, phy_vars_ue->rx_gain_mode[0],p_exmimo_config->rf.rx_gain[0][0]);
len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB (LNA %d, vga %d dB)\n",phy_vars_ue->rx_total_gain_dB, (p_exmimo_config->rf.rf_mode[0]& LNAGAINMASK) >> 14,p_exmimo_config->rf.rx_gain[0][0]);
#else
len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB (rf_mode %d, vga %d dB)\n",phy_vars_ue->rx_total_gain_dB, phy_vars_ue->rx_gain_mode[0],exmimo_pci_interface->rf.rx_gain00);
len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB (LNA %d, vga %d dB)\n",phy_vars_ue->rx_total_gain_dB, (p_exmimo_config->rf.rf_mode[0]& LNAGAINMASK) >> 14,exmimo_pci_interface->rf.rx_gain00);
#endif
#else
len += sprintf(&buffer[len], "[UE PROC] RX Gain %d dB\n",phy_vars_ue->rx_total_gain_dB);
......@@ -199,6 +199,11 @@ int dump_ue_stats(PHY_VARS_UE *phy_vars_ue, char* buffer, int length, runmode_t
len += sprintf(&buffer[len],"[UE PROC] RSRP[0] %d, RSSI %d, RSRQ[0] %d\n",phy_vars_ue->PHY_measurements.rsrp[0], phy_vars_ue->PHY_measurements.rssi, phy_vars_ue->PHY_measurements.rsrq[0]);
len += sprintf(&buffer[len], "[UE PROC] Transmission Mode %d (mode1_flag %d)\n",phy_vars_ue->transmission_mode[eNB],phy_vars_ue->lte_frame_parms.mode1_flag);
len += sprintf(&buffer[len], "[UE PROC] PBCH err conseq %d, PBCH error total %d, PBCH FER %d\n",
phy_vars_ue->lte_ue_pbch_vars[eNB]->pdu_errors_conseq,
phy_vars_ue->lte_ue_pbch_vars[eNB]->pdu_errors,
phy_vars_ue->lte_ue_pbch_vars[eNB]->pdu_fer);
if (phy_vars_ue->transmission_mode[eNB] == 6)
len += sprintf(&buffer[len], "[UE PROC] Mode 6 Wideband CQI eNB %d : %d dB\n",eNB,phy_vars_ue->PHY_measurements.precoded_cqi_dB[eNB][0]);
if (phy_vars_ue->dlsch_ue[0] && phy_vars_ue->dlsch_ue[0][0] && phy_vars_ue->dlsch_ue[0][1]) {
......
......@@ -7,13 +7,8 @@
* @{
*/
#ifndef NO_OPENAIR1
#include "PHY/defs.h"
#else
#include <stdint.h>
#define msg printf
#endif
#ifdef __SSE2__
#include <emmintrin.h>
......
......@@ -171,9 +171,9 @@
#ifdef EXMIMO
#define TARGET_RX_POWER 40 // Target digital power for the AGC
#define TARGET_RX_POWER_MAX 65 // Maximum digital power, such that signal does not saturate (value found by simulation)
#define TARGET_RX_POWER_MIN 30 // Minimum digital power, anything below will be discarded (value found by simulation)
#define TARGET_RX_POWER 55 // Target digital power for the AGC
#define TARGET_RX_POWER_MAX 55 // Maximum digital power, such that signal does not saturate (value found by simulation)
#define TARGET_RX_POWER_MIN 50 // Minimum digital power, anything below will be discarded (value found by simulation)
#else
#define TARGET_RX_POWER 50 // Target digital power for the AGC
#define TARGET_RX_POWER_MAX 65 // Maximum digital power, such that signal does not saturate (value found by simulation)
......
......@@ -541,7 +541,7 @@ void fill_dci(DCI_PDU *DCI_pdu, uint8_t subframe, PHY_VARS_eNB *phy_vars_eNB) {
BCCH_alloc_pdu.type = 1;
BCCH_alloc_pdu.vrb_type = 0;
BCCH_alloc_pdu.rballoc = computeRIV(25,10,3);
BCCH_alloc_pdu.ndi = 1;
BCCH_alloc_pdu.ndi = phy_vars_eNB->frame&1;
BCCH_alloc_pdu.rv = 1;
BCCH_alloc_pdu.mcs = 1;
BCCH_alloc_pdu.harq_pid = 0;
......@@ -586,7 +586,7 @@ void fill_dci(DCI_PDU *DCI_pdu, uint8_t subframe, PHY_VARS_eNB *phy_vars_eNB) {
DLSCH_alloc_pdu.harq_pid = 0;
DLSCH_alloc_pdu.mcs = openair_daq_vars.target_ue_dl_mcs;
//DLSCH_alloc_pdu.mcs = (unsigned char) ((phy_vars_eNB->frame%1024)%28);
DLSCH_alloc_pdu.ndi = 1;
DLSCH_alloc_pdu.ndi = phy_vars_eNB->frame&1;
DLSCH_alloc_pdu.rv = 0;
memcpy((void*)&DCI_pdu->dci_alloc[0].dci_pdu[0],(void *)&DLSCH_alloc_pdu,sizeof(DCI1_5MHz_TDD_t));
......@@ -620,7 +620,7 @@ void fill_dci(DCI_PDU *DCI_pdu, uint8_t subframe, PHY_VARS_eNB *phy_vars_eNB) {
DLSCH_alloc_pdu1E.tpmi = 5; //5=use feedback
DLSCH_alloc_pdu1E.rv = 0;
DLSCH_alloc_pdu1E.ndi = 1;
DLSCH_alloc_pdu1E.ndi = phy_vars_eNB->frame&1;
//DLSCH_alloc_pdu1E.mcs = cqi_to_mcs[phy_vars_eNB->eNB_UE_stats->DL_cqi[0]];
//DLSCH_alloc_pdu1E.mcs = (unsigned char) (taus()%28);
DLSCH_alloc_pdu1E.mcs = openair_daq_vars.target_ue_dl_mcs;
......@@ -687,7 +687,7 @@ void fill_dci(DCI_PDU *DCI_pdu, uint8_t subframe, PHY_VARS_eNB *phy_vars_eNB) {
UL_alloc_pdu.hopping = 0;
UL_alloc_pdu.rballoc = computeRIV(25,2,openair_daq_vars.ue_ul_nb_rb);
UL_alloc_pdu.mcs = openair_daq_vars.target_ue_ul_mcs;
UL_alloc_pdu.ndi = 1;
UL_alloc_pdu.ndi = phy_vars_eNB->frame&1;
UL_alloc_pdu.TPC = 0;
UL_alloc_pdu.cshift = 0;
UL_alloc_pdu.dai = 0;
......@@ -707,7 +707,7 @@ void fill_dci(DCI_PDU *DCI_pdu, uint8_t subframe, PHY_VARS_eNB *phy_vars_eNB) {
else
UL_alloc_pdu.rballoc = computeRIV(25,0,openair_daq_vars.ue_ul_nb_rb);
UL_alloc_pdu.mcs = openair_daq_vars.target_ue_ul_mcs;
UL_alloc_pdu.ndi = 1;
UL_alloc_pdu.ndi = phy_vars_eNB->frame&1;
UL_alloc_pdu.TPC = 0;
if ((cooperation_flag==0) || (cooperation_flag==1))
UL_alloc_pdu.cshift = 0;
......@@ -1377,11 +1377,13 @@ void phy_procedures_eNB_TX(unsigned char next_slot,PHY_VARS_eNB *phy_vars_eNB,ui
#else
DCI_pdu = &DCI_pdu_tmp;
#ifdef EMOS
/*
if (((phy_vars_eNB->frame%1024)%3 == 0) && (next_slot == 0)) {
//openair_daq_vars.target_ue_dl_mcs = (openair_daq_vars.target_ue_dl_mcs+1)%28;
openair_daq_vars.target_ue_dl_mcs = taus()%28;
LOG_D(PHY,"[MYEMOS] frame %d, increasing MCS to %d\n",phy_vars_eNB->frame,openair_daq_vars.target_ue_dl_mcs);
}
*/
/*
if (phy_vars_eNB->frame > 28000) {
LOG_E(PHY,"More that 28000 frames reached! Exiting!\n");
......
......@@ -54,6 +54,7 @@
#ifdef EXMIMO
#ifdef DRIVER2013
#include "openair0_lib.h"
#include "gain_control.h"
extern int card;
#else
#include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h"
......@@ -1480,11 +1481,13 @@ void lte_ue_measurement_procedures(uint8_t last_slot, uint16_t l, PHY_VARS_UE *p
if ((last_slot==1) && (l==(4-frame_parms->Ncp))) {
// AGC
#ifdef EXMIMO
if ((openair_daq_vars.rx_gain_mode == DAQ_AGC_ON) &&
(mode != rx_calib_ue) && (mode != rx_calib_ue_med) && (mode != rx_calib_ue_byp) )
phy_adjust_gain (phy_vars_ue,0);
//phy_adjust_gain (phy_vars_ue,0);
gain_control_all(phy_vars_ue->PHY_measurements.rx_power_avg_dB[eNB_id],0);
#endif
eNB_id = 0;
if (abstraction_flag == 0)
......@@ -2284,7 +2287,11 @@ int lte_ue_pdcch_procedures(uint8_t eNB_id,uint8_t last_slot, PHY_VARS_UE *phy_v
openair_daq_vars.use_ia_receiver = 0;
else
openair_daq_vars.use_ia_receiver = (openair_daq_vars.use_ia_receiver+1)%3;
LOG_I(PHY,"[MYEMOS] frame %d, IA receiver %d, MCS %d, bitrate %d\n",phy_vars_ue->frame,openair_daq_vars.use_ia_receiver, phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs,phy_vars_ue->bitrate[eNB_id]);
LOG_I(PHY,"[MYEMOS] frame %d, IA receiver %d, MCS %d, bitrate %d\n",
phy_vars_ue->frame,
openair_daq_vars.use_ia_receiver,
phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[phy_vars_ue->dlsch_ue[eNB_id][0]->current_harq_pid]->mcs,
phy_vars_ue->bitrate[eNB_id]);
}
#endif
......@@ -2405,7 +2412,7 @@ int lte_ue_pdcch_procedures(uint8_t eNB_id,uint8_t last_slot, PHY_VARS_UE *phy_v
if (phy_vars_ue->dlsch_ue[eNB_id][0]->active == 1) {
#ifndef DLSCH_THREAD //USER_MODE
harq_pid = phy_vars_ue->dlsch_ue[eNB_id][0]->current_harq_pid;
// printf("PDSCH active in subframe %d, harq_pid %d\n",(last_slot>>1)-1,harq_pid);
//printf("PDSCH active in subframe %d, harq_pid %d\n",(last_slot>>1)-1,harq_pid);
if ((phy_vars_ue->transmission_mode[eNB_id] == 5) &&
(phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->dl_power_off==0) &&
(openair_daq_vars.use_ia_receiver ==1)) {
......
#define DEBUG_DAC 1
#include <math.h>
#include <stdio.h>
#include "PHY/TOOLS/defs.h"
void dac(double **s_re,
......
#ifndef __SIMULATION_TOOLS_DEFS_H__
#define __SIMULATION_TOOLS_DEFS_H__
#include "PHY/TOOLS/defs.h"
#include "PHY/defs.h"
/** @defgroup _numerical_ Useful Numerical Functions
*@{
......
......@@ -4,8 +4,8 @@
// Maximum number of concurrently supported cards
//
#define MAX_CARDS 20
#define INIT_ZEROS {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define MAX_CARDS 8
#define INIT_ZEROS {0, 0, 0, 0, 0, 0, 0, 0};
/** PCIe subsystem configuration Space
......
......@@ -49,6 +49,7 @@ static int __init openair_init_module( void )
unsigned int readback;
unsigned int card, j;
unsigned int vid,did;
unsigned int val;
unsigned short vendor, subid;
exmimo_id_t exmimo_id_tmp[MAX_CARDS];
......@@ -94,15 +95,16 @@ static int __init openair_init_module( void )
// Now look for more cards on the same bus
while (card<MAX_CARDS)
{
{
pdev[card] = pci_get_device(vid,did, pdev[card-1]);
if(pdev[card])
{
// This print does not work for 64 bit kernels
// printk("[openair][INIT_MODULE][INFO]: openair card %d found, bus 0x%x, primary 0x%x, secondary 0x%x\n",card,
// pdev[card]->bus->number,pdev[card]->bus->primary,pdev[card]->bus->secondary);
pci_read_config_word(pdev[card], PCI_SUBSYSTEM_ID, &subid);
{
// This print does not work for 64 bit kernels
// printk("[openair][INIT_MODULE][INFO]: openair card %d found, bus 0x%x, primary 0x%x, secondary 0x%x\n",card,
// pdev[card]->bus->number,pdev[card]->bus->primary,pdev[card]->bus->secondary);
pci_read_config_word(pdev[card], PCI_SUBSYSTEM_ID, &subid);
pci_read_config_word(pdev[card], PCI_SUBSYSTEM_VENDOR_ID, &vendor);
exmimo_id_tmp[card].board_vendor = vendor;
......@@ -194,7 +196,13 @@ static int __init openair_init_module( void )
udelay(1000);
readback = ioread32( bar[card] +PCIE_CONTROL0);
printk("CONTROL0 readback %x\n",readback);
// This is for displaying the card number in the leds of the exmimo card
val = ioread32(bar[card]+PCIE_CONTROL0);
iowrite32(val| ((card & 0x1F) << 9),bar[card]+PCIE_CONTROL0);
//val = ioread32(bar[card]+PCIE_CONTROL0);
//printk("[openair][INIT_MODULE][INFO]: writing leds for card %d control0 %x\n",card,val);
// allocating buffers
if ( exmimo_memory_alloc( card ) ) {
printk("[openair][MODULE][ERROR] exmimo_memory_alloc() failed!\n");
......
#include "openair0_lib.h"
#include "gain_control.h"
//#define DEBUG_PHY
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
void gain_control_all (unsigned int rx_power_fil_dB, unsigned int card) {
unsigned int ant;
......
#define TARGET_RX_POWER 55 // Target digital power for the AGC
#define TARGET_RX_POWER_MAX 55 // Maximum digital power for AGC
#define TARGET_RX_POWER_MIN 50 // Minimum digital power for AGC
#define TARGET_RX_POWER 50 // Target digital power for the AGC
#define TARGET_RX_POWER_MAX 53 // Maximum digital power for AGC
#define TARGET_RX_POWER_MIN 48 // Minimum digital power for AGC
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
void gain_control_all (unsigned int rx_power_fil_dB, unsigned int card);
void gain_control (unsigned int rx_power_fil_dB, unsigned int ant, unsigned int card);
......@@ -156,15 +156,10 @@ CFLAGS += -DNAS_NETLINK -DLINUX
OBJ += $(NAS_OBJS)
endif
LDFLAGS += -lpthread -lm -lforms -lconfig
LDFLAGS += -lpthread -lm -lforms -lconfig -lrt
ifeq ($(RTAI),1)
RTAI_CFLAGS += $(shell rtai-config --lxrt-cflags) -DRTAI
LDFLAGS += $(shell rtai-config --lxrt-ldflags)
ifdef ENABLE_ITTI
LDFLAGS += -lrt
endif
else
LDFLAGS += -lrt
endif
ifeq ($(USRP),1)
......
......@@ -93,14 +93,16 @@ char title[255];
#ifdef EMOS
#include <gps.h>
struct gps_fix_t dummy_gps_data;
#ifdef RTAI
#include <rtai_fifos.h>
#endif
//#define CHANSOUNDER_FIFO_SIZE 10485760 // 10 Mbytes FIFO
#define CHANSOUNDER_FIFO_SIZE 20971520 // 20 Mbytes FIFO
//#define CHANSOUNDER_FIFO_SIZE 52428800 // 50 Mbytes FIFO
//#define CHANSOUNDER_FIFO_SIZE 20971520 // 20 Mbytes FIFO
#define CHANSOUNDER_FIFO_SIZE 52428800 // 50 Mbytes FIFO
//#define CHANSOUNDER_FIFO_SIZE 104857600 // 100 Mbytes FIFO
//#define CHANSOUNDER_FIFO_SIZE 1073741824 // 1Gbyte FIFO
#define CHANSOUNDER_FIFO_MINOR 4 // minor of the FIFO device - this is /dev/rtf3
#define CHANSOUNDER_FIFO_DEV "/dev/rtf4"
#endif
......@@ -118,7 +120,7 @@ static SEM *mutex;
//static CND *cond;
static long int thread0;
static long int thread1;
//static long int thread1;
//static long int sync_thread;
#else
pthread_t thread0;
......@@ -130,6 +132,7 @@ struct sched_param sched_param_dlsch;
pthread_t thread2; //xforms
pthread_t thread3; //emos
pthread_t thread4; //GPS
pthread_t thread5; //log
/*
static int instance_cnt=-1; //0 means worker is busy, -1 means its free
......@@ -155,11 +158,30 @@ char UE_flag=0;
uint8_t eNB_id=0,UE_id=0;
// this array sets the bandwidth used for each card (and applies to all chains on one card).
exmimo_bw_t bandwidth[MAX_CARDS] = {BW20,BW10,BW5,BW5};
exmimo_bw_t bandwidth[MAX_CARDS] = {BW5,BW5,BW5,BW5};
// the array carrier_freq sets the frequency for each chain of each card. A 0 means that the chain is disabled.
// Please make sure that the total number of channels enabled per card is in accordance with the following rules:
// BW20: one channel, BW10: 2 channels, BW5: 4 channels
uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0},{0,0,0,0}};
//uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0}};
//uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0},{0,0,0,0}};
uint32_t carrier_freq[MAX_CARDS][4] = {{771500000,771500000,771500000,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
// the following paramters set the aquisition time and period. These parameters have to be set in accordance with the write speed of your harddisk and the required throughput according to the setting above (see also channel_buffer_size which is computed later).
#define AQU_LENGTH_FRAMES 100 //Aquisition time in frames
#define AQU_PERIOD_FRAMES 100 //Repetition time of aquisition in frames
#define AQU_LENGTH_SLOTS (AQU_LENGTH_FRAMES*LTE_SLOTS_PER_FRAME) //Aquisition time in slots
#define AQU_PERIOD_SLOTS (AQU_PERIOD_FRAMES*LTE_SLOTS_PER_FRAME) //Repetition time of aquisition in slots
int32_t rx_total_gain_dB[3] = {-112, -124, -136};
/*
// this array sets the bandwidth used for each card (and applies to all chains on one card).
exmimo_bw_t bandwidth[MAX_CARDS] = {BW20,BW20,BW10,BW5};
// the array carrier_freq sets the frequency for each chain of each card. A 0 means that the chain is disabled.
// Please make sure that the total number of channels enabled per card is in accordance with the following rules:
// BW20: one channel, BW10: 2 channels, BW5: 4 channels
uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0}};
//uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0},{0,0,0,0}};
//uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
// the following paramters set the aquisition time and period. These parameters have to be set in accordance with the write speed of your harddisk and the required throughput according to the setting above (see also channel_buffer_size which is computed later).
......@@ -168,13 +190,17 @@ uint32_t carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2605000000,26050
#define AQU_LENGTH_SLOTS (AQU_LENGTH_FRAMES*LTE_SLOTS_PER_FRAME) //Aquisition time in slots
#define AQU_PERIOD_SLOTS (AQU_PERIOD_FRAMES*LTE_SLOTS_PER_FRAME) //Repetition time of aquisition in slots
int32_t rx_total_gain_dB[3] = {-105, -110, -115};
*/
char dumpfile_dir[256] = "/mnt/emos";
char *conf_config_file_name = NULL;
unsigned int lost_bytes=0;
int rssi_lin,rssi_lin_avg;
int8_t rssi_avg_dB;
unsigned int rssi_lin[MAX_CARDS][4],rssi_lin_max[MAX_CARDS],rssi_lin_avg[MAX_CARDS];
uint8_t rssi_avg_dB[MAX_CARDS];
long long unsigned int total_bytes=0;
struct timing_info_t {
//unsigned int frame, hw_slot, last_slot, next_slot;
......@@ -197,13 +223,6 @@ int otg_enabled;
int mbox_bounds[20] = {8,16,24,30,38,46,54,60,68,76,84,90,98,106,114,120,128,136,144, 0}; ///boundaries of slots in terms ob mbox counter rounded up to even numbers
//int mbox_bounds[20] = {6,14,22,28,36,44,52,58,66,74,82,88,96,104,112,118,126,134,142, 148}; ///boundaries of slots in terms ob mbox counter rounded up to even numbers
int init_dlsch_threads(void);
void cleanup_dlsch_threads(void);
int32_t init_rx_pdsch_thread(void);
void cleanup_rx_pdsch_thread(void);
int init_ulsch_threads(void);
void cleanup_ulsch_threads(void);
//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);
void test_config(int card, int ant, unsigned int rf_mode, int UE_flag);
......@@ -305,7 +324,7 @@ void *scope_thread(void *arg) {
idx = 0;
for (card=0;card<number_of_cards;card++) {
for (ant=0;ant<4;ant++) {
if (carrier_freq[card][ant] != 0) {
if ((carrier_freq[card][ant] != 0) && (idx<4)) {
len = FRAME_LENGTH_COMPLEX_SAMPLES/(1<<openair0_exmimo_pci[card].exmimo_config_ptr->framing.resampling_factor[ant]);
for (i=0; i<len; i++) {
//rxsig_t_dB[0][i] = 10*log10(1.0+(float) ((((int16_t*) openair0_exmimo_pci[card].adc_head[0])[2*i])*(((int16_t*) openair0_exmimo_pci[card].adc_head[0])[2*i])+(((int16_t*) openair0_exmimo_pci[card].adc_head[0])[2*i+1])*(((int16_t*) openair0_exmimo_pci[card].adc_head[0])[2*i+1])));
......@@ -333,13 +352,13 @@ void *scope_thread(void *arg) {
int dummy_tx_buffer[3840*4] __attribute__((aligned(16)));
#ifdef EMOS
#ifdef EMOS
void* gps_thread (void *arg)
{
struct gps_data_t *gps_data = NULL;
struct gps_fix_t dummy_gps_data;
struct gps_data_t gps_data;
struct gps_data_t *gps_data_ptr = &gps_data;
struct sched_param sched_param;
int ret;
......@@ -351,71 +370,121 @@ void* gps_thread (void *arg)
memset(&dummy_gps_data,0,sizeof(struct gps_fix_t));
#if GPSD_API_MAJOR_VERSION>=5
ret = gps_open("127.0.0.1","2947",gps_data);
ret = gps_open("127.0.0.1","2947",gps_data_ptr);
if (ret!=0)
#else
gps_data = gps_open("127.0.0.1","2947");
if (gps_data == NULL)
gps_data_ptr = gps_open("127.0.0.1","2947");
if (gps_data_ptr == NULL)
#endif
{
printf("[EMOS] Could not open GPS\n");
pthread_exit((void*)arg);
}
#if GPSD_API_MAJOR_VERSION>=4
else if (gps_stream(gps_data, WATCH_ENABLE,NULL) != 0)
else if (gps_stream(gps_data_ptr, WATCH_ENABLE,NULL) != 0)
#else
else if (gps_query(gps_data, "w+x") != 0)
else if (gps_query(gps_data_ptr, "w+x") != 0)
#endif
{
printf("[EMOS] Error sending command to GPS\n");
pthread_exit((void*) arg);
}
else
printf("[EMOS] Opened GPS, gps_data=%p\n", gps_data);
printf("[EMOS] Opened GPS, gps_data=%p\n", gps_data_ptr);
while (!oai_exit)
{
printf("[EMOS] polling data from gps\n");
#if GPSD_API_MAJOR_VERSION>=5
if (gps_waiting(gps_data,500)) {
if (gps_read(gps_data) != 0) {
if (gps_waiting(gps_data_ptr,500)) {
if (gps_read(gps_data_ptr) <= 0) {
#else
if (gps_waiting(gps_data)) {
if (gps_poll(gps_data) != 0) {
if (gps_waiting(gps_data_ptr)) {
if (gps_poll(gps_data_ptr) != 0) {
#endif
printf("[EMOS] problem polling data from gps\n");
}
else {
memcpy(&dummy_gps_data,gps_data,sizeof(struct gps_fix_t));
printf("[EMOS] lat %g, lon %g\n",gps_data->fix.latitude,gps_data->fix.longitude);
memcpy(&dummy_gps_data,&(gps_data_ptr->fix),sizeof(struct gps_fix_t));
printf("[EMOS] lat %g, lon %g\n",gps_data_ptr->fix.latitude,gps_data_ptr->fix.longitude);
}
} //gps_waiting
else {
printf("[EMOS] WARNING: No GPS data available, storing dummy packet\n");
}
rt_sleep_ns(1000000000LL);
//rt_sleep_ns(1000000000LL);
sleep(1);
} //oai_exit
pthread_exit((void*) arg);
}
void *log_thread (void *arg)
{
//struct tm now_sec;
struct timeval now;
int card;
FILE *logfile_id;
char logfile_name[1024];
time_t starttime_tmp;
struct tm starttime;
//open file
time(&starttime_tmp);
localtime_r(&starttime_tmp,&starttime);
snprintf(logfile_name,1024,"%s/%s_data_%d%02d%02d_%02d%02d%02d.log",
dumpfile_dir,
(UE_flag==0) ? "eNB" : "UE",
1900+starttime.tm_year, starttime.tm_mon+1, starttime.tm_mday, starttime.tm_hour, starttime.tm_min, starttime.tm_sec);
logfile_id = fopen(logfile_name,"w");
if ((logfile_id == NULL))
{
fprintf(stderr, "[EMOS] Error opening logfile %s\n",logfile_name);
exit(EXIT_FAILURE);
}
fprintf(logfile_id,"#time, frame, total bytes wrote, total bytes lost, GPS time, GPS mode, lat, lon, alt, speed, rssi_lin_max[0], rssi_lin_avg[0], rssi_avg_dBm[0], rssi_avg_dB[0], rx_gain[0], LNA[0], ...\n");
while (!oai_exit) {
gettimeofday(&now,NULL);
//localtime_r(&(now.tv_sec),&now_sec);
fprintf(logfile_id,"%d.%06d, %d, %llu, %u, %e, %d, %e, %e, %e, %e, ",
(int) now.tv_sec, (int)now.tv_usec,
frame, total_bytes,lost_bytes,
dummy_gps_data.time, dummy_gps_data.mode, dummy_gps_data.latitude, dummy_gps_data.longitude, dummy_gps_data.altitude, dummy_gps_data.speed);
for (card=0;card<number_of_cards;card++)
if (carrier_freq[card][0] != 0)
fprintf(logfile_id,"%d, %d, %d, %d, %d, %d, ", rssi_lin_max[card], rssi_lin_avg[card],
rssi_avg_dB[card] + rx_total_gain_dB[((openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0] & LNAGAINMASK) >> 14)-1] - openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0],
rssi_avg_dB[card], openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0], (openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0] & LNAGAINMASK) >> 14);
fprintf(logfile_id,"\n");
usleep(10000);
}
//close file
fclose(logfile_id);
pthread_exit((void*) arg);
}
void *emos_thread (void *arg)
{
char c;
char *fifo2file_buffer, *fifo2file_ptr;
int fifo, counter=0, bytes;
long long unsigned int total_bytes=0;
FILE *dumpfile_id;
char dumpfile_name[1024];
time_t starttime_tmp;
struct tm starttime;
time_t timer;
struct tm *now;
//time_t timer;
struct tm now_sec;
struct timeval now;
struct sched_param sched_param;
int ret;
......@@ -423,19 +492,20 @@ void *emos_thread (void *arg)
int card, ant;
int channel_buffer_size=0; //in bytes
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL);
sched_param.sched_priority = sched_get_priority_max(SCHED_FIFO)-1;
sched_setscheduler(0, SCHED_FIFO,&sched_param);
printf("EMOS thread has priority %d\n",sched_param.sched_priority);
timer = time(NULL);
now = localtime(&timer);
//timer = time(NULL);
//now = localtime(&timer);
for (card=0; card<number_of_cards; card++)
for (ant=0; ant<4; ant++)
if (carrier_freq[card][ant] != 0) {
printf("card %d, ant %d\n",card,ant);
printf("card %d, ant %d: freq %u, BW %d\n",card,ant,carrier_freq[card][ant],bandwidth[card]);
channel_buffer_size += SAMPLES_PER_SLOT/(1<<openair0_exmimo_pci[card].exmimo_config_ptr->framing.resampling_factor[ant]);
}
channel_buffer_size *= 4; //4 bytes per sample
......@@ -460,12 +530,12 @@ void *emos_thread (void *arg)
time(&starttime_tmp);
localtime_r(&starttime_tmp,&starttime);
snprintf(dumpfile_name,1024,"%s/%s_data_%d%02d%02d_%02d%02d%02d.EMOS",
dumpfile_dir,
dumpfile_dir,
(UE_flag==0) ? "eNB" : "UE",
1900+starttime.tm_year, starttime.tm_mon+1, starttime.tm_mday, starttime.tm_hour, starttime.tm_min, starttime.tm_sec);
dumpfile_id = fopen(dumpfile_name,"w");
if (dumpfile_id == NULL)
if ((dumpfile_id == NULL))
{
fprintf(stderr, "[EMOS] Error opening dumpfile %s\n",dumpfile_name);
exit(EXIT_FAILURE);
......@@ -475,9 +545,15 @@ void *emos_thread (void *arg)
while (!oai_exit)
{
bytes = rtf_read_timed(fifo, fifo2file_ptr, channel_buffer_size,100);
if (bytes<=0)
//bytes = rtf_read_timed(fifo, fifo2file_ptr, channel_buffer_size,100);
bytes = rtf_read_all_at_once(fifo, fifo2file_ptr, channel_buffer_size);
if (bytes<=0) {
usleep(100);
continue;
}
if (bytes != channel_buffer_size) {
printf("[EMOS] Frame %d: ERROR! Only got %d bytes instead of %d!\n",frame,bytes,channel_buffer_size);
}
/*
if (UE_flag==0)
printf("eNB: count %d, frame %d, read: %d bytes from the fifo\n",counter, ((fifo_dump_emos_eNB*)fifo2file_ptr)->frame_tx,bytes);
......@@ -495,6 +571,8 @@ void *emos_thread (void *arg)
fifo2file_ptr = fifo2file_buffer;
//counter = 0;
printf("[EMOS] Frame %d: start writing %d bytes to disk\n",frame,AQU_LENGTH_SLOTS*channel_buffer_size);
//flush buffer to disk
if (fwrite(fifo2file_buffer, sizeof(char), AQU_LENGTH_SLOTS*channel_buffer_size, dumpfile_id) != AQU_LENGTH_SLOTS*channel_buffer_size)
{
......@@ -507,10 +585,17 @@ void *emos_thread (void *arg)
}
if ((counter%AQU_LENGTH_SLOTS)==0) {
time(&starttime_tmp);
localtime_r(&starttime_tmp,&starttime);
printf("[EMOS] %02d:%02d:%02d, frame %d, total bytes wrote %llu, bytes lost %d\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, frame, total_bytes,lost_bytes);
printf("[EMOS] %02d:%02d:%02d, frame %d, rssi_lin %d, rssi_lin_avg %d, rssi_avg_dB %d, rx_gain %d, LNA %d\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, frame, rssi_lin, rssi_lin_avg, rssi_avg_dB, p_exmimo_config->rf.rx_gain[0][0], (p_exmimo_config->rf.rf_mode[0] & LNAGAINMASK) >> 14);
//time(&starttime_tmp);
gettimeofday(&now,NULL);
localtime_r(&(now.tv_sec),&now_sec);
printf("[EMOS] %02d:%02d:%02d.%03d, frame %d, total bytes wrote %llu, bytes lost %u\n",
now_sec.tm_hour, now_sec.tm_min, now_sec.tm_sec, (int)(now.tv_usec/1000), frame, total_bytes,lost_bytes);
for (card=0;card<number_of_cards;card++)
if (carrier_freq[card][0] != 0)
printf("[EMOS] %02d:%02d:%02d.%03d, card %d, rssi_lin_max %d, rssi_lin_avg %d, rssi_avg_dBm %d (rssi_avg_dB %d, rx_gain %d, LNA %d)\n",
now_sec.tm_hour, now_sec.tm_min, now_sec.tm_sec, (int)(now.tv_usec/1000), card, rssi_lin_max[card], rssi_lin_avg[card],
rssi_avg_dB[card] + rx_total_gain_dB[((openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0] & LNAGAINMASK) >> 14)-1] - openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0],
rssi_avg_dB[card], openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0], (openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0] & LNAGAINMASK) >> 14);
//printf("[EMOS] %02d:%02d:%02d, frame %d, GPS time %e, GPS mode %d, lat %e, lon %e, alt %e, speed %e\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, counter/20, dummy_gps_data.time, dummy_gps_data.mode, dummy_gps_data.latitude, dummy_gps_data.longitude, dummy_gps_data.altitude, dummy_gps_data.speed);
}
}
......@@ -539,7 +624,7 @@ static void *eNB_thread(void *arg)
int mbox_target=0,mbox_current=0;
int i,ret;
int tx_offset;
int bytes, bytes_tot, bytes_len;
int bytes, bytes_tot=0, bytes_len;
long long int k1=1000;
long long int k2=1024-k1;
int ant,len,card = 0;
......@@ -581,8 +666,8 @@ static void *eNB_thread(void *arg)
// at the eNB, even slots have double as much time since most of the processing is done here and almost nothing in odd slots
LOG_D(HW,"eNB Frame %d, time %llu: missed slot, proceeding with next one (slot %d, hw_slot %d, diff %d)\n",frame, rt_get_time_ns(), slot, hw_slot, diff);
slot++;
if (frame>0)
oai_exit=1;
//if (frame>0)
//oai_exit=1;
if (slot==20){
slot=0;
frame++;
......@@ -623,7 +708,7 @@ static void *eNB_thread(void *arg)
last_slot+=20;
next_slot = (slot+3)%LTE_SLOTS_PER_FRAME;
if (frame>AQU_LENGTH_FRAMES)
if (frame>=AQU_LENGTH_FRAMES)
{
timing_info.time_last = timing_info.time_now;
timing_info.time_now = rt_get_time_ns();
......@@ -643,11 +728,17 @@ static void *eNB_thread(void *arg)
if (last_slot==0) {
for (card=0;card<number_of_cards;card++) {
len = SAMPLES_PER_SLOT/(1<<openair0_exmimo_pci[card].exmimo_config_ptr->framing.resampling_factor[0]);
rssi_lin = signal_energy(&(((int32_t*) openair0_exmimo_pci[card].adc_head[0])[last_slot*len]), len);
rssi_lin_avg = (int) ((k1*((long long int)(rssi_lin_avg)) + (k2*((long long int)(rssi_lin))))>>10);
rssi_avg_dB = dB_fixed(rssi_lin_avg);
rssi_lin_max[card] = 0;
for (ant=0;ant<4;ant++) {
if (carrier_freq[card][ant] != 0) {
rssi_lin[card][ant] = signal_energy(&(((int32_t*) openair0_exmimo_pci[card].adc_head[ant])[last_slot*len]), len);
rssi_lin_max[card] = max(rssi_lin_max[card],rssi_lin[card][ant]);
}
}
rssi_lin_avg[card] = (int) ((k1*((long long int)(rssi_lin_avg[card])) + (k2*((long long int)(rssi_lin_max[card]))))>>10);
rssi_avg_dB[card] = dB_fixed(rssi_lin_avg[card]);
if (frame%100==0) {
gain_control_all(rssi_avg_dB,card);
gain_control_all(rssi_avg_dB[card],card);
//printf("AGC for card %d: rx_power_fil_dB=%d, rx_gain=%d, LNA=%d (1=Byp,2=Med,3=Max)\n",card,rssi_avg_dB,openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0],(openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0]&LNAGAINMASK)>>14);
}
}
......@@ -724,7 +815,7 @@ int main(int argc, char **argv) {
uint32_t rf_vcocal[4] = {910,910,910,910};
uint32_t rf_vcocal_850[4] = {2015, 2015, 2015, 2015};
uint32_t rf_rxdc[4] = {32896,32896,32896,32896};
uint32_t rxgain[4] = {0,0,0,0};
uint32_t rxgain[4] = {30,30,30,30};
uint32_t txgain[4] = {0,0,0,0};
uint16_t Nid_cell = 0;
......@@ -995,11 +1086,13 @@ int main(int argc, char **argv) {
else
p_exmimo_config->framing.eNB_flag = !UE_flag;
//p_exmimo_config->framing.multicard_syncmode = SYNCMODE_FREE;
if (card==0)
p_exmimo_config->framing.multicard_syncmode = SYNCMODE_MASTER;
else
else
p_exmimo_config->framing.multicard_syncmode = SYNCMODE_SLAVE;
//p_exmimo_config->framing.multicard_syncmode = SYNCMODE_FREE;
p_exmimo_config->framing.tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTRX; //TXRXSWITCH_LSB;
......@@ -1146,7 +1239,7 @@ int main(int argc, char **argv) {
printf("mutex=%p\n",mutex);
#endif
DAQ_MBOX = (volatile unsigned int *) openair0_exmimo_pci[card].rxcnt_ptr[0];
DAQ_MBOX = (volatile unsigned int *) openair0_exmimo_pci[0].rxcnt_ptr[0];
// this starts the DMA transfers
if (UE_flag!=1)
......@@ -1207,6 +1300,8 @@ int main(int argc, char **argv) {
printf("EMOS thread created, ret=%d\n",ret);
ret = pthread_create(&thread4, NULL, gps_thread, NULL);
printf("GPS thread created, ret=%d\n",ret);
ret = pthread_create(&thread5, NULL, log_thread, NULL);
printf("LOG thread created, ret=%d\n",ret);
#endif
rt_sleep_ns(10*FRAME_PERIOD);
......@@ -1340,10 +1435,15 @@ int main(int argc, char **argv) {
printf("waiting for GPS thread\n");
pthread_cancel(thread4);
pthread_join(thread4,&status);
printf("waiting for log thread\n");
pthread_cancel(thread5);
pthread_join(thread5,&status);
#endif
#ifdef EMOS
error_code = rtf_destroy(CHANSOUNDER_FIFO_MINOR);
while (error_code>0)
error_code = rtf_destroy(CHANSOUNDER_FIFO_MINOR);
printf("[OPENAIR][SCHED][CLEANUP] EMOS FIFO closed, error_code %d\n", error_code);
#endif
......
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