Commit b6d217ee authored by magounak's avatar magounak

added gsl function to compute calibration coefficients in real-time, compute...

added gsl function to compute calibration coefficients in real-time, compute beam weights and do precoding
parent efbee833
......@@ -36,6 +36,7 @@ set (OPENAIR_TARGETS ${OPENAIR_DIR}/targets)
set (OPENAIR3_DIR ${OPENAIR_DIR}/openair3)
set (OPENAIR_CMAKE ${OPENAIR_DIR}/cmake_targets)
set (OPENAIR_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY})
set (GSL_DIR /home/eurecom/gsl)
project (OpenAirInterface)
......@@ -127,7 +128,7 @@ endfunction()
#set(CMAKE_BUILD_TYPE "Debug")
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
add_list_string_option(CMAKE_BUILD_TYPE "RelWithDebInfo" "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." Debug Release RelWithDebInfo MinSizeRel)
......@@ -2298,6 +2299,8 @@ if(EXISTS "/usr/include/atlas/cblas.h" OR EXISTS "/usr/include/cblas.h")
LINK_DIRECTORIES("/usr/lib64")
LINK_DIRECTORIES("/usr/lib64/atlas") #Added because atlas libraries in CentOS 7 are here!
include_directories("${GSL_DIR}/include/gsl")
if(EXISTS "/usr/lib64/libblas.so" OR EXISTS "/usr/lib/libblas.so") #Case for CentOS7
list(APPEND ATLAS_LIBRARIES blas)
......@@ -2433,6 +2436,7 @@ target_link_libraries (measurement_display minimal_lib)
# lte-softmodem is both eNB and UE implementation
###################################################
LINK_DIRECTORIES("${GSL_DIR}/lib")
add_executable(lte-softmodem
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-enb.c
......@@ -2473,6 +2477,7 @@ target_link_libraries (lte-softmodem ${LIBXML2_LIBRARIES})
target_link_libraries (lte-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
target_link_libraries (lte-softmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-softmodem ${T_LIB})
target_link_libraries(lte-softmodem gsl gslcblas)
add_executable(cu_test
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/cu_test.c
......
......@@ -400,8 +400,14 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
common_vars->rxdata = (int32_t **)NULL;
common_vars->txdataF = (int32_t **)malloc16(NB_ANTENNA_PORTS_ENB*sizeof(int32_t *));
common_vars->rxdataF = (int32_t **)malloc16(64*sizeof(int32_t *));
common_vars->calib_coeffs = (int32_t **)malloc16(2*sizeof(int32_t *));
LOG_I(PHY,"[INIT] NB_ANTENNA_PORTS_ENB:%d fp->nb_antenna_ports_eNB:%d\n", NB_ANTENNA_PORTS_ENB, fp->nb_antenna_ports_eNB);
for (i=0; i<2; i++) {
common_vars->calib_coeffs[i] = (int32_t *)malloc16_clear(sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); // 2 RRUs
LOG_I(PHY,"[INIT] common_vars->calib_coeffs[%d] = %p (%lu bytes)\n", i,common_vars->calib_coeffs[i], fp->N_RB_UL*12*fp->symbols_per_tti*sizeof(int32_t));
}
for (i=0; i<NB_ANTENNA_PORTS_ENB; i++) {
if (i<fp->nb_antenna_ports_eNB || i==5) {
common_vars->txdataF[i] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) );
......@@ -528,6 +534,12 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) {
free_and_zero(common_vars->txdataF);
free_and_zero(common_vars->rxdataF);
for (i=0; i<2; i++) {
free_and_zero(common_vars->calib_coeffs[i]);
}
free_and_zero(common_vars->calib_coeffs);
// Channel estimates for SRS
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
for (i=0; i<64; i++) {
......
......@@ -103,11 +103,24 @@ int phy_init_RU(RU_t *ru) {
// allocate FFT output buffers after extraction (RX)
calibration->rxdataF_ext = (int32_t**)malloc16(2*sizeof(int32_t*));
calibration->drs_ch_estimates = (int32_t**)malloc16(2*sizeof(int32_t*));
for (i=0; i<ru->nb_rx; i++) {
calibration->rxdataF_calib = (int32_t****)malloc16(2*sizeof(int32_t***));
//calibration->rxdataF_calib = (int32_t***)malloc16(2*sizeof(int32_t**)); // 2 frames to collect calibration data
//calibration->rxdataF_calib = (int32_t**)malloc16(2*sizeof(int32_t*)); // 2 RRUs
for (i=0; i<ru->nb_rx; i++) {
calibration->rxdataF_calib[i] = (int32_t***)malloc16(2*sizeof(int32_t**)); // 2 frames to collect calibration data
for (j=0; j<2; j++) {
calibration->rxdataF_calib[i][j] = (int32_t**)malloc16(2*sizeof(int32_t*)); // 2 RRUs
for (int k=0; k<2; k++) {
calibration->rxdataF_calib[i][j][k] = (int32_t*)malloc16_clear(sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
}
}
}
for (i=0; i<ru->nb_rx; i++) {
// allocate 2 subframes of I/Q signal data (frequency)
calibration->rxdataF_ext[i] = (int32_t*)malloc16_clear(sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
LOG_I(PHY,"rxdataF_ext[%d] %p for RU %d\n",i,calibration->rxdataF_ext[i],ru->idx);
calibration->drs_ch_estimates[i] = (int32_t*)malloc16_clear(sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti);
//calibration->rxdataF_calib[i] = (int32_t*)malloc16_clear(sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
}
/* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) */
......@@ -138,7 +151,7 @@ int phy_init_RU(RU_t *ru) {
for (p=0; p<15; p++) {
LOG_D(PHY,"[INIT] %s() nb_antenna_ports_eNB:%d \n", __FUNCTION__, ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB);
if (p<ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB || p==5) {
if (p<ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB || p==5 || p==7 || p==8) {
LOG_D(PHY,"[INIT] %s() DO BEAM WEIGHTS nb_antenna_ports_eNB:%d nb_tx:%d\n", __FUNCTION__, ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB, ru->nb_tx);
ru->beam_weights[i][p] = (int32_t **)malloc16_clear(ru->nb_tx*sizeof(int32_t *));
......@@ -209,9 +222,11 @@ void phy_free_RU(RU_t *ru) {
for (i = 0; i < ru->nb_rx; i++) {
free_and_zero(calibration->rxdataF_ext[i]);
free_and_zero(calibration->drs_ch_estimates[i]);
free_and_zero(calibration->rxdataF_calib[i]);
}
free_and_zero(calibration->rxdataF_ext);
free_and_zero(calibration->drs_ch_estimates);
free_and_zero(calibration->rxdataF_calib);
for (i = 0; i < ru->nb_rx; i++) {
free_and_zero(ru->prach_rxsigF[i]);
......
......@@ -2,6 +2,7 @@
#include <stdint.h>
#include <stdlib.h>
#include "PHY/defs_common.h"
#include "PHY/defs_eNB.h"
int f_read(char *calibF_fname, int nb_ant, int nb_freq, int32_t **tdd_calib_coeffs){
......@@ -52,6 +53,24 @@ int compute_BF_weights(int32_t **beam_weights, int32_t **calib_dl_ch_estimates,
}
/* TODO: what to return? is this code used at all? */
return 0;
}
int compute_beam_weights(int32_t **beam_weights[NUMBER_OF_eNB_MAX+1][15], int32_t **calib_coeffs, int32_t **ul_ch_estimates, PHY_VARS_eNB *eNB, int l1_id, int p, int aa, int ru_id) {
//PHY_VARS_eNB *eNB = RC.eNB[0][0];
LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
int d_f = 597;
//LOG_I(PHY,"compute_beam_weights : l1_id %d, p %d, aa %d, ru_id %d \n",l1_id,p,aa,ru_id);
//LOG_I(PHY,"(int16_t*)&beam_weights[%d][%d][%d][0] %p\n", l1_id,p,aa,(int16_t*)&beam_weights[l1_id][p][aa][0]);
//LOG_I(PHY,"[compute_beam_weights] : calib_coeffs[1][%d] : %d %d i\n",d_f,calib_coeffs[1][d_f],calib_coeffs[1][d_f+1]);
mult_cpx_vector((int16_t *)calib_coeffs[ru_id],
(int16_t*)&ul_ch_estimates[aa][0],
(int16_t*)&beam_weights[l1_id][p][aa][0],
fp->N_RB_UL*12,
15);
return 0;
}
// temporal test function
......
......@@ -84,7 +84,7 @@ int estimate_DLCSI_from_ULCSI(int32_t **calib_dl_ch_estimates, int32_t **ul_ch_e
int compute_BF_weights(int32_t **beam_weights, int32_t **calib_dl_ch_estimates, PRECODE_TYPE_t precode_type, int nb_ant, int nb_freq);
int compute_beam_weights(int32_t **beam_weights[NUMBER_OF_eNB_MAX+1][15], int32_t **calib_coeffs, int32_t **ul_ch_estimates, PHY_VARS_eNB *eNB, int l1_id, int p, int aa, int ru_id);
/** @}*/
#endif
......@@ -138,16 +138,41 @@ typedef struct {
typedef struct {
/// \brief Received frequency-domain signal after extraction.
/// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
/// - second index: ? [0..168*N_RB_DL[
/// - second index: ? [0..168*N_RB_DL]
int32_t **rxdataF_ext;
/// \brief Hold the channel estimates in time domain based on DRS.
/// - first index: rx antenna id [0..nb_antennas_rx[
/// - second index: ? [0..4*ofdm_symbol_size[
/// - first index: rx antenna id [0..nb_antennas_rx]
/// - second index: ? [0..4*ofdm_symbol_size]
int32_t **drs_ch_estimates_time;
/// \brief Hold the channel estimates in frequency domain based on DRS.
/// - first index: rx antenna id [0..nb_antennas_rx[
/// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[
/// - first index: rx antenna id [0..nb_antennas_rx]
/// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti]
int32_t **drs_ch_estimates;
/// \brief Holds all the received data required for one calibration round in the frequency domain at calibration symbol 10/SSF1
/// \brief calibration round = required frames to collect calibration symbols from all active RRUs = number of RRUs
/// e.x. if we need to calibrate 3 RRUs, the calibration round consists of 3 frames
/// - first index: frame number
/// - second index: RRU tag
/// - third index: rx antenna id [0..nb_antennas_rx]
/// - fourth index: [0..168*N_RB_DL]
int32_t ****rxdataF_calib;
/// \brief Holds the tdd reciprocity calibration coefficients
/// - first index: tx antenna [0..nb_antennas_tx]
/// - second index: number of RRUs
/// - third index: subcarriers [0..168*N_RB_DL]
int32_t ***calib_coeffs;
/// mutex for calibration thread
pthread_mutex_t mutex_calib;
/// condition variable for calibration processing thread
pthread_cond_t cond_calib;
/// This variable is protected by mutex_calib.
int instance_cnt_calib;
// pthread structure for calibration processing thread
pthread_t pthread_calib;
// pthread attributes for calibration processing thread
pthread_attr_t attr_calib;
// calibration frame counter
int calib_frame;
} RU_CALIBRATION;
......
......@@ -86,6 +86,11 @@ typedef struct {
/// - first index: tx antenna [0..14[ where 14 is the total supported antenna ports.
/// - second index: sample [0..]
int32_t **txdataF;
/// \brief Holds the tdd reciprocity calibration coefficients
/// - first index: tx antenna [0..nb_antennas_tx]
/// - second index: number of RRUs
/// - third index: subcarriers [0..168*N_RB_DL]
int32_t **calib_coeffs;
} LTE_eNB_COMMON;
typedef struct {
......@@ -574,6 +579,8 @@ typedef struct PHY_VARS_eNB_s {
/// if ==0 enables phy only test mode
int mac_enabled;
/// enable precoding with calibration coefficients
int calib_prec_enabled;
// PDSCH Varaibles
PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_UE_MAX];
......
......@@ -117,11 +117,11 @@ void feptx0(RU_t *ru,
fp->frame_type,ru->is_slave);
*/
int num_symb = 7;
/*
if (subframe_select(fp,subframe) == SF_S)
num_symb = fp->dl_symbols_in_S_subframe+1;
if (ru->generate_dmrs_sync == 1 && slot == 0 && subframe == 1 && aa==0) {
*/
if (ru->generate_dmrs_sync == 1 && /*slot == 2 &&*/ subframe == 1 && aa==0) {
//int32_t dmrs[ru->frame_parms.ofdm_symbol_size*14] __attribute__((aligned(32)));
//int32_t *dmrsp[2] ={dmrs,NULL}; //{&dmrs[(3-ru->frame_parms.Ncp)*ru->frame_parms.ofdm_symbol_size],NULL};
......@@ -443,12 +443,16 @@ void feptx_prec(RU_t *ru,
int l,i,aa;
PHY_VARS_eNB **eNB_list = ru->eNB_list, *eNB;
LTE_DL_FRAME_PARMS *fp;
RU_CALIBRATION *calibration = &ru->calibration;
if (ru->num_eNB == 1)
{
eNB = eNB_list[0];
//PHY_VARS_eNB *eNB = RC.eNB[0][0];
LTE_eNB_COMMON *const common_vars = &eNB->common_vars;
fp = &eNB->frame_parms;
LTE_eNB_PDCCH *pdcch_vars = &eNB->pdcch_vars[subframe&1];
LTE_eNB_PDCCH *pdcch_vars = &eNB->pdcch_vars[subframe&1];
LTE_eNB_SRS *srs_vars = eNB->srs_vars;
if (subframe_select(fp,subframe) == SF_UL) return;
......@@ -457,6 +461,22 @@ void feptx_prec(RU_t *ru,
for (aa=0;aa<ru->nb_tx;aa++) {
memset(ru->common.txdataF_BF[aa],0,sizeof(int32_t)*fp->ofdm_symbol_size*fp->symbols_per_tti);
for (int p=0;p<NB_ANTENNA_PORTS_ENB;p++) {
if (eNB->calib_prec_enabled==1 && (p==0 || p==5 || p==7 || p==8)) {
//LOG_I(PHY,"[feptx_prec] common_vars->calib_coeffs[%d] = %p \n",ru->idx,common_vars->calib_coeffs[ru->idx]);
//LOG_I(PHY,"feptx_prec : calib_coeffs[%d][597] : %d %d i\n",ru->idx,((int16_t*)&RC.eNB[0][0]->common_vars.calib_coeffs[ru->idx])[597], ((int16_t*)&RC.eNB[0][0]->common_vars.calib_coeffs[ru->idx])[597+1]);
compute_beam_weights(ru->beam_weights, common_vars->calib_coeffs, srs_vars->srs_ch_estimates, eNB, eNB->Mod_id, p, aa, ru->idx);
for (l=pdcch_vars->num_pdcch_symbols;l<fp->symbols_per_tti;l++) {
beam_precoding(eNB->common_vars.txdataF,
ru->common.txdataF_BF,
subframe,
fp,
ru->beam_weights,
l,
aa,
p,
eNB->Mod_id);
}
}
if (ru->do_precoding == 0) {
if (p==0)
memcpy((void*)ru->common.txdataF_BF[aa],
......@@ -638,8 +658,13 @@ void ru_fep_full_2thread(RU_t *ru,
int check_sync_pos,Ns,l;
struct timespec wait;
if (subframe==1){
if ((fp->frame_type == TDD) && (subframe_select(fp,subframe) != SF_UL)) return;
}
else if ((fp->frame_type == TDD) && (subframe_select(fp,subframe) != SF_UL)) {
return;
}
if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 );
......
This diff is collapsed.
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