From 981655ccb1b96a94051ab236ba3f7e69d7829621 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Tue, 14 Jun 2016 17:05:07 +0200 Subject: [PATCH 1/9] integrate send_IF4 with alaw lut --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 69 +++++++++++++++----------- openair1/PHY/LTE_TRANSPORT/if4_tools.h | 4 +- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index cf41812c19..9c521f10ff 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -29,7 +29,7 @@ /*! \file PHY/LTE_TRANSPORT/if4_tools.c * \brief -* \author Mauricio Gunther, S. Sandeep Kumar, Raymond Knopp +* \author Fredrik Skretteberg, Tobias Schuster, Mauricio Gunther, S. Sandeep Kumar, Raymond Knopp * \date 2016 * \version 0.1 * \company Eurecom @@ -43,6 +43,7 @@ #include #else #include "PHY/LTE_TRANSPORT/if4_tools.h" +#include "PHY/TOOLS/ALAW/alaw_lut.h" #endif // Get device information @@ -50,11 +51,15 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { int frame = proc->frame_tx; int subframe = proc->subframe_tx; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - - uint16_t i; - - float_t data_block_length = 1200*(fp->ofdm_symbol_size/2048); - uint16_t *data_block = (uint16_t*)malloc(data_block_length*sizeof(uint16_t)); + int32_t **txdataF = eNB->common_vars.txdataF[0]; + + uint16_t symbol_id, element_id; + uint16_t db_fulllength = 12*fp->N_RB_DL; + uint16_t db_halflength = db_fulllength>>1; + int slotoffsetF = (subframe_tx)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1; + int blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength; + + int16_t *data_block = (int16_t*)malloc(db_fulllength*sizeof(int16_t)); // Caller: RCC - DL *** handle RRU case - UL and PRACH *** if (eNB->node_function == NGFI_RCC_IF4) { @@ -63,14 +68,17 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { dl_packet->data_block = data_block; - for(i=0; isymbols_per_tti; i++) { - - //Do compression of the two parts and generate data blocks + for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { - //symbol = eNB->common_vars.txdataF[0][0 /*antenna number*/][subframe*fp->ofdm_symbol_size*(fp->symbols_per_tti)] - //data_block[j] = Atan(symbol[fp->ofmd_symbol_size - NrOfNonZeroValues + j -1])<<16 + Atan(symbol[fp->ofmd_symbol_size - NrOfNonZeroValues + j]); - //data_block[j+NrOfNonZeroValues] = Atan(subframe[i][j+1])<<16 + Atan(subframe[i][j+2]); - + // Do compression of the two parts and generate data blocks + for (element_id=0; element_id>16 + 32768 ]<<8; + + data_block[element_id+db_halflength] = lin2alaw[ (txdataF[0][slotoffsetF+element_id])&0xffff + 32768 ]; + data_block[element_id+db_halflength] |= lin2alaw[ (txdataF[0][slotoffsetF+element_id])>>16 + 32768 ]<<8; + } + // Update information in generated packet dl_packet->frame_status.sym_num = i; @@ -82,7 +90,10 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { // dev->eth_dev.openair0_cfg->rx_num_channels, // 0)) < 0) { // perror("RCC : ETHERNET write"); - //} + //} + + slotoffsetF += fp->ofdm_symbol_size; + blockoffsetF += fp->ofdm_symbol_size; } }else { IF4_ul_packet_t *ul_packet = (IF4_ul_packet_t*)malloc(sizeof_IF4_ul_packet_t); @@ -90,32 +101,34 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { ul_packet->data_block = data_block; - for(i=0; isymbols_per_tti; i++) { - - //Do compression of the two parts and generate data blocks + for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { - //symbol = eNB->common_vars.txdataF[0][0 /*antenna number*/][subframe*fp->ofdm_symbol_size*(fp->symbols_per_tti)] - //data_block[j] = Atan(symbol[fp->ofmd_symbol_size - NrOfNonZeroValues + j -1])<<16 + Atan(symbol[fp->ofmd_symbol_size - NrOfNonZeroValues + j]); - //data_block[j+NrOfNonZeroValues] = Atan(subframe[i][j+1])<<16 + Atan(subframe[i][j+2]); - + // Do compression of the two parts and generate data blocks + for (element_id=0; element_id>16 + 32768 ]<<8; + + data_block[element_id+db_halflength] = lin2alaw[ (txdataF[0][slotoffsetF+element_id])&0xffff + 32768 ]; + data_block[element_id+db_halflength] |= lin2alaw[ (txdataF[0][slotoffsetF+element_id])>>16 + 32768 ]<<8; + } + // Update information in generated packet ul_packet->frame_status.sym_num = i; // Write the packet(s) to the fronthaul + slotoffsetF += fp->ofdm_symbol_size; + blockoffsetF += fp->ofdm_symbol_size; } } } -void recv_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { +void recv_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, uint16_t *packet_type, uint32_t *symbol_number) { // Caller: RRU - DL *** handle RCC case - UL and PRACH *** - if (eNB->node_function == NGFI_RRU_IF4) { - - for(i=0; isymbols_per_tti; i++) { // Read packet(s) from the fronthaul if (dev->eth_dev.trx_read_func (&dev->eth_dev, @@ -140,7 +153,7 @@ void recv_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { void gen_IF4_dl_packet(IF4_dl_packet_t *dl_packet, eNB_rxtx_proc_t *proc) { // Set Type and Sub-Type - dl_packet->type = 0x080A; + dl_packet->type = IF4_PACKET_TYPE; dl_packet->sub_type = IF4_PDLFFT; // Leave reserved as it is @@ -160,7 +173,7 @@ void gen_IF4_dl_packet(IF4_dl_packet_t *dl_packet, eNB_rxtx_proc_t *proc) { void gen_IF4_ul_packet(IF4_ul_packet_t *ul_packet, eNB_rxtx_proc_t *proc) { // Set Type and Sub-Type - ul_packet->type = 0x080A; + ul_packet->type = IF4_PACKET_TYPE; ul_packet->sub_type = IF4_PULFFT; // Leave reserved as it is @@ -184,7 +197,7 @@ void gen_IF4_ul_packet(IF4_ul_packet_t *ul_packet, eNB_rxtx_proc_t *proc) { void gen_IF4_prach_packet(IF4_prach_packet_t *prach_packet, eNB_rxtx_proc_t *proc) { // Set Type and Sub-Type - prach_packet->type = 0x080A; + prach_packet->type = IF4_PACKET_TYPE; prach_packet->sub_type = IF4_PRACH; // Leave reserved as it is diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.h b/openair1/PHY/LTE_TRANSPORT/if4_tools.h index 91a9e93d79..cadcb2f8c2 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.h @@ -38,6 +38,8 @@ * \warning */ +/// Macro for IF4 packet type +#define IF4_PACKET_TYPE 0x080A #define IF4_PULFFT 0x0019 #define IF4_PDLFFT 0x0020 #define IF4_PRACH 0x0021 @@ -179,4 +181,4 @@ void gen_IF4_prach_packet(IF4_prach_packet_t*, eNB_rxtx_proc_t*); void send_IF4(PHY_VARS_eNB*, eNB_rxtx_proc_t*); -void recv_IF4(PHY_VARS_eNB*, eNB_rxtx_proc_t*, int*, int*); +void recv_IF4(PHY_VARS_eNB*, eNB_rxtx_proc_t*, uint16_t*, uint32_t*); From b70b2ac4c49a3af0b8ac3dbc08c56d1346c1f703 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Thu, 16 Jun 2016 11:32:48 +0200 Subject: [PATCH 2/9] add openair0 device to eNB struct and per CC_id changes --- openair1/PHY/defs.h | 7 ++++ targets/RT/USER/lte-softmodem.c | 74 ++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 30 deletions(-) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 89fc1cd7ed..ed3ca5c251 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -139,6 +139,8 @@ static inline void* malloc16_clear( size_t size ) #include "PHY/LTE_TRANSPORT/defs.h" #include +#include "targets/ARCH/COMMON/common_lib.h" + #define NUM_DCI_MAX 32 #define NUMBER_OF_eNB_SECTORS_MAX 3 @@ -456,6 +458,11 @@ typedef struct PHY_VARS_eNB_s { SLIST_HEAD(ral_thresholds_gen_poll_enb_s, ral_threshold_phy_t) ral_thresholds_gen_polled[RAL_LINK_PARAM_GEN_MAX]; SLIST_HEAD(ral_thresholds_lte_poll_enb_s, ral_threshold_phy_t) ral_thresholds_lte_polled[RAL_LINK_PARAM_LTE_MAX]; #endif + + /// RF and Interface devices per CC + openair0_device rfdevice; + openair0_device ifdevice; + // *** Handle spatially distributed MIMO antenna ports } PHY_VARS_eNB; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index c92f28b332..8a2d8d9360 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -152,8 +152,6 @@ int sync_var=-1; //!< protected by mutex \ref sync_mutex. static pthread_t forms_thread; //xforms #endif -openair0_device openair0; - uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] @@ -1580,15 +1578,27 @@ int main( int argc, char **argv ) } LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); #endif - - /* device host type is set*/ - openair0.host_type = BBU_HOST; - /* device type is initialized NONE_DEV (no RF device) when the RF device will be initiated device type will be set */ - openair0.type = NONE_DEV; - /* transport type is initialized NONE_TP (no transport protocol) when the transport protocol will be initiated transport protocol type will be set */ - openair0.transp_type = NONE_TP; + openair0_cfg[0].log_level = glog_level; + for (CC_id=0; CC_idrfdevice.host_type = BBU_HOST; + PHY_vars_eNB_g[0][CC_id]->rfdevice.type = NONE_DEV; + PHY_vars_eNB_g[0][CC_id]->rfdevice.transp_type = NONE_TP; + + PHY_vars_eNB_g[0][CC_id]->ifdevice.host_type = BBU_HOST; + PHY_vars_eNB_g[0][CC_id]->ifdevice.type = NONE_DEV; + PHY_vars_eNB_g[0][CC_id]->ifdevice.transp_type = NONE_TP; + } + + /* device host type is set*/ + //openair0.host_type = BBU_HOST; + /* device type is initialized NONE_DEV (no RF device) when the RF device will be initiated device type will be set */ + //openair0.type = NONE_DEV; + /* transport type is initialized NONE_TP (no transport protocol) when the transport protocol will be initiated transport protocol type will be set */ + //openair0.transp_type = NONE_TP; + //openair0_cfg[0].log_level = glog_level; + // Legacy BBU - RRH init //int returns=-1; ///* BBU can have either a local or a remote radio head */ @@ -1619,36 +1629,40 @@ int main( int argc, char **argv ) //printf("Done\n"); int returns=-1; - + + // Handle spatially distributed MIMO antenna ports // Load RF device and initialize if (node_function == eNodeB_3GPP || node_function == NGFI_RRU_IF4) { - if (mode!=loop_through_memory) { - returns=openair0_device_load(&openair0, &openair0_cfg[0]); - printf("openair0_device_init returns %d\n",returns); - if (returns<0) { - printf("Exiting, cannot initialize device\n"); - exit(-1); + for (CC_id=0; CC_idrfdevice), &openair0_cfg[0]); + printf("openair0_device_init returns %d for CC_id %d\n",returns,CC_id); + if (returns<0) { + printf("Exiting, cannot initialize device\n"); + exit(-1); + } } - } - else if (mode==loop_through_memory) { + else if (mode==loop_through_memory) { + } } } // Load transport protocol and initialize if (node_function == NGFI_RCC_IF4 || node_function == NGFI_RRU_IF4){ - if (mode!=loop_through_memory) { - returns=openair0_transport_load(&openair0, &openair0_cfg[0], eth_params); - printf("openair0_transport_init returns %d\n",returns); - if (returns<0) { - printf("Exiting, cannot initialize transport protocol\n"); - exit(-1); + for (CC_id=0; CC_idifdevice), &openair0_cfg[0], (eth_params+CC_id)); + printf("openair0_transport_init returns %d for CC_id %d\n",returns,CC_id); + if (returns<0) { + printf("Exiting, cannot initialize transport protocol\n"); + exit(-1); + } } + else if (mode==loop_through_memory) { + } } - else if (mode==loop_through_memory) { - } - } - printf("Done\n"); + printf("Done initializing RF and IF devices\n"); mac_xface = malloc(sizeof(MAC_xface)); @@ -1819,7 +1833,7 @@ int main( int argc, char **argv ) - +// *** Handle per CC_id openair0 #ifndef USRP_DEBUG if ((UE_flag==1) && (mode!=loop_through_memory)) if (openair0.trx_start_func(&openair0) != 0 ) @@ -1889,7 +1903,7 @@ int main( int argc, char **argv ) pthread_cond_destroy(&sync_cond); pthread_mutex_destroy(&sync_mutex); - + // *** Handle per CC_id openair0 openair0.trx_end_func(&openair0); if (ouput_vcd) From dd6e1f9d87020e31222abf4e55da441cd5bc19ab Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Thu, 16 Jun 2016 12:45:08 +0200 Subject: [PATCH 3/9] fixes for if4_tools for compilation --- cmake_targets/CMakeLists.txt | 3 +- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 49 +++++++++++++------------- openair1/PHY/LTE_TRANSPORT/if4_tools.h | 8 +++-- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 5eca2e8d41..2101009016 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -138,7 +138,7 @@ else (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l") set(C_FLAGS_PROCESSOR "${C_FLAGS_PROCESSOR} -mavx2") endif() if (CPUINFO MATCHES "sse4_1") - set(C_FLAGS_PROCESSOR "${C_FLAGS_PROCESSOR} -msse4.1 -mavx2") + set(C_FLAGS_PROCESSOR "${C_FLAGS_PROCESSOR} -msse4.1") endif() if (CPUINFO MATCHES "ssse3") set(C_FLAGS_PROCESSOR "${C_FLAGS_PROCESSOR} -mssse3") @@ -959,6 +959,7 @@ add_boolean_option(OAI_NW_DRIVER_USE_NETLINK True "????") ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/rar_tools.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/print_stats.c ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/initial_sync.c + ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if4_tools.c ${OPENAIR1_DIR}/PHY/MODULATION/ofdm_mod.c ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep.c ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_mbsfn.c diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 9c521f10ff..06e057cdf0 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -42,21 +42,22 @@ #include "if4_tools.h" #include #else +#include +#include "PHY/defs.h" + #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/TOOLS/ALAW/alaw_lut.h" #endif // Get device information void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { - int frame = proc->frame_tx; - int subframe = proc->subframe_tx; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; int32_t **txdataF = eNB->common_vars.txdataF[0]; uint16_t symbol_id, element_id; uint16_t db_fulllength = 12*fp->N_RB_DL; uint16_t db_halflength = db_fulllength>>1; - int slotoffsetF = (subframe_tx)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1; + int slotoffsetF = (proc->subframe_tx)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1; int blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength; int16_t *data_block = (int16_t*)malloc(db_fulllength*sizeof(int16_t)); @@ -72,15 +73,15 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { // Do compression of the two parts and generate data blocks for (element_id=0; element_id>16 + 32768 ]<<8; + data_block[element_id] = lin2alaw[ (txdataF[0][blockoffsetF+element_id] & 0xffff) + 32768 ]; + data_block[element_id] |= lin2alaw[ (txdataF[0][blockoffsetF+element_id]>>16) + 32768 ]<<8; - data_block[element_id+db_halflength] = lin2alaw[ (txdataF[0][slotoffsetF+element_id])&0xffff + 32768 ]; - data_block[element_id+db_halflength] |= lin2alaw[ (txdataF[0][slotoffsetF+element_id])>>16 + 32768 ]<<8; + data_block[element_id+db_halflength] = lin2alaw[ (txdataF[0][slotoffsetF+element_id] & 0xffff) + 32768 ]; + data_block[element_id+db_halflength] |= lin2alaw[ (txdataF[0][slotoffsetF+element_id]>>16) + 32768 ]<<8; } // Update information in generated packet - dl_packet->frame_status.sym_num = i; + dl_packet->frame_status.sym_num = symbol_id; // Write the packet(s) to the fronthaul //if ((bytes_sent = dev->eth_dev.trx_write_func (&dev->eth_dev, @@ -105,15 +106,15 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { // Do compression of the two parts and generate data blocks for (element_id=0; element_id>16 + 32768 ]<<8; + data_block[element_id] = lin2alaw[ (txdataF[0][blockoffsetF+element_id] & 0xffff) + 32768 ]; + data_block[element_id] |= lin2alaw[ (txdataF[0][blockoffsetF+element_id]>>16) + 32768 ]<<8; - data_block[element_id+db_halflength] = lin2alaw[ (txdataF[0][slotoffsetF+element_id])&0xffff + 32768 ]; - data_block[element_id+db_halflength] |= lin2alaw[ (txdataF[0][slotoffsetF+element_id])>>16 + 32768 ]<<8; + data_block[element_id+db_halflength] = lin2alaw[ (txdataF[0][slotoffsetF+element_id] & 0xffff) + 32768 ]; + data_block[element_id+db_halflength] |= lin2alaw[ (txdataF[0][slotoffsetF+element_id]>>16) + 32768 ]<<8; } // Update information in generated packet - ul_packet->frame_status.sym_num = i; + ul_packet->frame_status.sym_num = symbol_id; // Write the packet(s) to the fronthaul @@ -129,23 +130,23 @@ void recv_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, uint16_t *packet_type, u // Caller: RRU - DL *** handle RCC case - UL and PRACH *** if (eNB->node_function == NGFI_RRU_IF4) { - for(i=0; isymbols_per_tti; i++) { +// for(i=0; isymbols_per_tti; i++) { // Read packet(s) from the fronthaul - if (dev->eth_dev.trx_read_func (&dev->eth_dev, - timestamp_rx, - rx_eNB, - spp_eth, - dev->eth_dev.openair0_cfg->rx_num_channels - ) < 0) { - perror("RRU : ETHERNET read"); - } +// if (dev->eth_dev.trx_read_func (&dev->eth_dev, +// timestamp_rx, +// rx_eNB, +// spp_eth, +// dev->eth_dev.openair0_cfg->rx_num_channels +// ) < 0) { +// perror("RRU : ETHERNET read"); +// } // Apply reverse processing - decompression // txAlawtolinear( Datablock ) // Generate and return the OFDM symbols (txdataF) - txDataF - } + //txDataF + //} }else { } diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.h b/openair1/PHY/LTE_TRANSPORT/if4_tools.h index cadcb2f8c2..d7a0461169 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.h @@ -38,6 +38,8 @@ * \warning */ +#include + /// Macro for IF4 packet type #define IF4_PACKET_TYPE 0x080A #define IF4_PULFFT 0x0019 @@ -105,7 +107,7 @@ struct IF4_dl_packet { /// Frame Status IF4_frame_status_t frame_status; /// Data Blocks - uint16_t *data_block; + int16_t *data_block; /// Frame Check Sequence uint32_t fcs; }; @@ -143,7 +145,7 @@ struct IF4_ul_packet { /// Gain 7 IF4_gain_t gain7; /// Data Blocks - uint16_t *data_block; + int16_t *data_block; /// Frame Check Sequence uint32_t fcs; }; @@ -165,7 +167,7 @@ struct IF4_prach_packet { /// LTE Prach Configuration IF4_lte_prach_conf_t prach_conf; /// Prach Data Block (one antenna) - uint16_t *data_block; + int16_t *data_block; /// Frame Check Sequence uint32_t fcs; }; From c76951a31904fbe73d04366cc3457f9ee13fd450 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Thu, 16 Jun 2016 12:49:15 +0200 Subject: [PATCH 4/9] handle per cc device for some tx/rx cases --- openair1/SCHED/phy_procedures_lte_eNb.c | 5 +++-- targets/RT/USER/lte-enb.c | 21 ++++++++++++++++----- targets/RT/USER/lte-softmodem.c | 10 +++++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 0e1685d266..a42d01fd32 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -73,7 +73,8 @@ void exit_fun(const char* s); extern int exit_openair; -extern openair0_device openair0; +// Fix per CC openair rf/if device update +// extern openair0_device openair0; unsigned char dlsch_input_buffer[2700] __attribute__ ((aligned(32))); int eNB_sync_buffer0[640*6] __attribute__ ((aligned(32))); @@ -2522,7 +2523,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][subframe*fp->samples_per_tti]; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); - rxs = openair0.trx_read_func(&openair0, + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, &proc->timestamp_rx, rxp, fp->samples_per_tti, diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 373a13e150..aa30f0874b 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -120,8 +120,8 @@ struct timing_info_t { unsigned int n_samples; } timing_info; - -extern openair0_device openair0; +// Fix per CC openair rf/if device update +// extern openair0_device openair0; #if defined(ENABLE_ITTI) extern volatile int start_eNB; @@ -524,7 +524,7 @@ static void* eNB_thread_rxtx( void* param ) for (i=0; iframe_parms.nb_antennas_tx; i++) txp[i] = (void*)&PHY_vars_eNB_g[0][0]->common_vars.txdata[0][i][proc->subframe_tx*PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti]; // if symb_written < spp ==> error - openair0.trx_write_func(&openair0, + PHY_vars_eNB_g[0][proc->CC_id]->rfdevice.trx_write_func(&PHY_vars_eNB_g[0][proc->CC_id]->rfdevice, (proc->timestamp_tx-openair0_cfg[0].tx_sample_advance), txp, PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti, @@ -741,8 +741,19 @@ static void* eNB_thread_rx_common( void* param ) #if defined(ENABLE_ITTI) wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB); #endif - if (openair0.trx_start_func(&openair0) != 0 ) - LOG_E(HW,"Could not start the device\n"); + + // Start RF device for this CC + if (eNB->node_function == eNodeB_3GPP || eNB->node_function == NGFI_RRU_IF4) { + if (eNB->rfdevice.trx_start_func(&eNB->rfdevice) != 0 ) + LOG_E(HW,"Could not start the RF device\n"); + } + + // Start IF device for this CC + if (eNB->node_function == NGFI_RCC_IF4 || eNB->node_function == NGFI_RRU_IF4) { + if (eNB->ifdevice.trx_start_func(&eNB->ifdevice) != 0 ) + LOG_E(HW,"Could not start the IF device\n"); + } + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices while (!oai_exit) { diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 8a2d8d9360..97feaed919 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -280,6 +280,9 @@ eth_params_t *eth_params; openair0_config_t openair0_cfg[MAX_CARDS]; +// Change to openair_global to handle UE +openair0_device openair0; + double cpuf; char uecap_xer[1024],uecap_xer_in=0; @@ -1592,11 +1595,11 @@ int main( int argc, char **argv ) } /* device host type is set*/ - //openair0.host_type = BBU_HOST; + openair0.host_type = BBU_HOST; /* device type is initialized NONE_DEV (no RF device) when the RF device will be initiated device type will be set */ - //openair0.type = NONE_DEV; + openair0.type = NONE_DEV; /* transport type is initialized NONE_TP (no transport protocol) when the transport protocol will be initiated transport protocol type will be set */ - //openair0.transp_type = NONE_TP; + openair0.transp_type = NONE_TP; //openair0_cfg[0].log_level = glog_level; // Legacy BBU - RRH init @@ -1661,6 +1664,7 @@ int main( int argc, char **argv ) else if (mode==loop_through_memory) { } } + } printf("Done initializing RF and IF devices\n"); From c5745c16226385fa4771eb3e60daa6cd5d6ea43b Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Thu, 16 Jun 2016 17:44:05 +0200 Subject: [PATCH 5/9] highlight send/recv if4 - midsave to swich pc --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 33 +++++---- openair1/PHY/LTE_TRANSPORT/prach.c | 6 +- openair1/SCHED/phy_procedures_lte_eNb.c | 32 ++------- targets/RT/USER/lte-enb.c | 89 ++++++++++++++----------- targets/RT/USER/lte-softmodem.c | 4 +- 5 files changed, 78 insertions(+), 86 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 06e057cdf0..a8a27b2c09 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -38,16 +38,11 @@ * \warning */ -#ifndef USER_MODE -#include "if4_tools.h" #include -#else -#include -#include "PHY/defs.h" +#include "PHY/defs.h" #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/TOOLS/ALAW/alaw_lut.h" -#endif // Get device information void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { @@ -70,6 +65,8 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { dl_packet->data_block = data_block; for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { + + printf("\n Send IF4 for frame %d, subframe %d and symbol %d\n", proc->frame_tx, proc->subframe_tx, symbol_id); // Do compression of the two parts and generate data blocks for (element_id=0; element_idframe_status.sym_num = symbol_id; // Write the packet(s) to the fronthaul - //if ((bytes_sent = dev->eth_dev.trx_write_func (&dev->eth_dev, - // timestamp_rx, - // rx_eNB, - // spp_eth, - // dev->eth_dev.openair0_cfg->rx_num_channels, - // 0)) < 0) { - // perror("RCC : ETHERNET write"); - //} + // if ((bytes_sent = eNB->ifdevice.trx_write_func(&eNB->ifdevice, + // (proc->timestamp_tx-eNB->ifdevice.openair0_cfg.tx_sample_advance), + // dl_packet, + // eNB->frame_parms.samples_per_tti, + // eNB->frame_parms.nb_antennas_tx, + // 0)) < 0) { + // perror("RCC : ETHERNET write"); + //} slotoffsetF += fp->ofdm_symbol_size; blockoffsetF += fp->ofdm_symbol_size; @@ -104,10 +101,10 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { - // Do compression of the two parts and generate data blocks + // Do compression of the two parts and generate data blocks - rxdataF for (element_id=0; element_id>16) + 32768 ]<<8; + data_block[element_id] = lin2alaw[ (rxdataF[0][blockoffsetF+element_id] & 0xffff) + 32768 ]; + data_block[element_id] |= lin2alaw[ (rxdataF[0][blockoffsetF+element_id]>>16) + 32768 ]<<8; data_block[element_id+db_halflength] = lin2alaw[ (txdataF[0][slotoffsetF+element_id] & 0xffff) + 32768 ]; data_block[element_id+db_halflength] |= lin2alaw[ (txdataF[0][slotoffsetF+element_id]>>16) + 32768 ]<<8; @@ -130,6 +127,8 @@ void recv_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, uint16_t *packet_type, u // Caller: RRU - DL *** handle RCC case - UL and PRACH *** if (eNB->node_function == NGFI_RRU_IF4) { + printf("\n Recv IF4 for frame %d, subframe %d and symbol %d\n", proc->frame_tx, proc->subframe_tx, symbol_id); + // for(i=0; isymbols_per_tti; i++) { // Read packet(s) from the fronthaul // if (dev->eth_dev.trx_read_func (&dev->eth_dev, diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index 0f806e2ea1..555685b23e 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -1269,16 +1269,16 @@ void rx_prach(PHY_VARS_eNB *eNB, } if (eNB->node_function == NGFI_RRU_IF4) { - //send prachF to RCC + /// **** send_IF4 of prachF to RCC **** /// return; } + // in case of RCC and prach received rx_thread wakes up prach //else if (eNB->node_function == NGFI_RCC_IF4) { - //wait for prachF from RRU and continue with PRACH processing + // wait for prachF from RRU and continue with PRACH processing //} - // here onwards is for eNodeB_3GPP or NGFI_RCC_IF4 preamble_offset_old = 99; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index a42d01fd32..087404d10a 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1430,24 +1430,6 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, #endif - // Clean up split point *** RRU only function to recv and do_OFDM_mod *** - if (eNB->node_function == eNodeB_3GPP) { - // Add above to IF4 split - // do_OFDM_mod - - }else if (eNB->node_function == NGFI_RCC_IF4) { - //send_IF4(eNB,subframe<<1); - //send_IF4(eNB,(subframe<<1)+1); - - }else if (eNB->node_function == NGFI_RRU_IF4) { // => acquisition from RCC (IF4) - // get frame/subframe information from IF4 interface - - //recv_IF4(eNB,subframe<<1); - //recv_IF4(eNB,1+(subframe<<1)); - - //do_OFDM_mod - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX,0); stop_meas(&eNB->phy_proc_tx); @@ -2572,12 +2554,14 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,0); if (eNB->node_function == NGFI_RRU_IF4) { - //send_IF4(eNB,subframe<<1); - //send_IF4(eNB,(subframe<<1)+1); + /// **** send_IF4 of rxdataF to RCC **** /// + /// Handle routing to prach thread for sending prach } } - else if (eNB->node_function == NGFI_RCC_IF4) { // => acquisition from RRU (IF4) + else if (eNB->node_function == NGFI_RCC_IF4) { + /// **** recv_IF4 of rxdataF from RRU **** /// + /// **** recv_IF4 of prachF from RRU **** /// // get frame/subframe information from IF4 interface // timed loop (200 us) @@ -2598,11 +2582,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl //symbol_mask = symbol_mask | (1<CC_id]->node_function != NGFI_RCC_IF4) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 1 ); - do_OFDM_mod_rt( proc->subframe_tx, PHY_vars_eNB_g[0][proc->CC_id] ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 0 ); - /* - short *txdata = (short*)&PHY_vars_eNB_g[0][proc->CC_id]->common_vars.txdata[0][0][proc->subframe_tx*PHY_vars_eNB_g[0][proc->CC_id]->frame_parms.samples_per_tti]; - int i; - for (i=0;iCC_id]->frame_parms.samples_per_tti*2;i+=8) { - txdata[i] = 2047; - txdata[i+1] = 0; - txdata[i+2] = 0; - txdata[i+3] = 2047; - txdata[i+4] = -2047; - txdata[i+5] = 0; - txdata[i+6] = 0; - txdata[i+7] = -2047; } - */ + // eNodeB_3GPP and RRU create txdata and write to RF device + if (PHY_vars_eNB_g[0][proc->CC_id]->node_function != NGFI_RCC_IF4) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 1 ); + do_OFDM_mod_rt( proc->subframe_tx, PHY_vars_eNB_g[0][proc->CC_id] ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 0 ); + /* + short *txdata = (short*)&PHY_vars_eNB_g[0][proc->CC_id]->common_vars.txdata[0][0][proc->subframe_tx*PHY_vars_eNB_g[0][proc->CC_id]->frame_parms.samples_per_tti]; + int i; + for (i=0;iCC_id]->frame_parms.samples_per_tti*2;i+=8) { + txdata[i] = 2047; + txdata[i+1] = 0; + txdata[i+2] = 0; + txdata[i+3] = 2047; + txdata[i+4] = -2047; + txdata[i+5] = 0; + txdata[i+6] = 0; + txdata[i+7] = -2047; } + */ - // Transmit TX buffer based on timestamp from RX + // Transmit TX buffer based on timestamp from RX + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + // prepare tx buffer pointers + int i; + for (i=0; iframe_parms.nb_antennas_tx; i++) + txp[i] = (void*)&PHY_vars_eNB_g[0][0]->common_vars.txdata[0][i][proc->subframe_tx*PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti]; + // if symb_written < spp ==> error + PHY_vars_eNB_g[0][proc->CC_id]->rfdevice.trx_write_func(&PHY_vars_eNB_g[0][proc->CC_id]->rfdevice, + (proc->timestamp_tx-openair0_cfg[0].tx_sample_advance), + txp, + PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti, + PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx, + 1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); - // prepare tx buffer pointers - int i; - for (i=0; iframe_parms.nb_antennas_tx; i++) - txp[i] = (void*)&PHY_vars_eNB_g[0][0]->common_vars.txdata[0][i][proc->subframe_tx*PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti]; - // if symb_written < spp ==> error - PHY_vars_eNB_g[0][proc->CC_id]->rfdevice.trx_write_func(&PHY_vars_eNB_g[0][proc->CC_id]->rfdevice, - (proc->timestamp_tx-openair0_cfg[0].tx_sample_advance), - txp, - PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti, - PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx, - 1); - - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-openair0_cfg[0].tx_sample_advance)&0xffffffff ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - } + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-openair0_cfg[0].tx_sample_advance)&0xffffffff ); + + } else { // RCC sends the txdataF using send_IF4 function + + /// **** send_IF4 of txdataF to RRU **** /// + //send_IF4(PHY_vars_eNB_g[0][proc->CC_id], proc); + + } if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { LOG_E( PHY, "[SCHED][eNB] error locking mutex for eNB TX proc\n"); @@ -743,13 +756,13 @@ static void* eNB_thread_rx_common( void* param ) #endif // Start RF device for this CC - if (eNB->node_function == eNodeB_3GPP || eNB->node_function == NGFI_RRU_IF4) { + if (eNB->node_function != NGFI_RCC_IF4) { if (eNB->rfdevice.trx_start_func(&eNB->rfdevice) != 0 ) LOG_E(HW,"Could not start the RF device\n"); } // Start IF device for this CC - if (eNB->node_function == NGFI_RCC_IF4 || eNB->node_function == NGFI_RRU_IF4) { + if (eNB->node_function != eNodeB_3GPP) { if (eNB->ifdevice.trx_start_func(&eNB->ifdevice) != 0 ) LOG_E(HW,"Could not start the IF device\n"); } @@ -769,7 +782,7 @@ static void* eNB_thread_rx_common( void* param ) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 1 ); // this spawns the prach inside and updates the frame and subframe counters phy_procedures_eNB_common_RX(eNB, 0); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 0 ); } diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 97feaed919..efc2291dde 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1635,7 +1635,7 @@ int main( int argc, char **argv ) // Handle spatially distributed MIMO antenna ports // Load RF device and initialize - if (node_function == eNodeB_3GPP || node_function == NGFI_RRU_IF4) { + if (node_function != NGFI_RCC_IF4) { for (CC_id=0; CC_idrfdevice), &openair0_cfg[0]); @@ -1651,7 +1651,7 @@ int main( int argc, char **argv ) } // Load transport protocol and initialize - if (node_function == NGFI_RCC_IF4 || node_function == NGFI_RRU_IF4){ + if (node_function != eNodeB_3GPP){ for (CC_id=0; CC_idifdevice), &openair0_cfg[0], (eth_params+CC_id)); From d7781f7a315e2d3558329f095597bd8d94b2f13e Mon Sep 17 00:00:00 2001 From: "S. Sandeep Kumar" Date: Fri, 17 Jun 2016 01:47:42 +0530 Subject: [PATCH 6/9] asthetic fixes for lte-enb.c --- targets/RT/USER/lte-enb.c | 632 +++++++++++++++++--------------------- 1 file changed, 285 insertions(+), 347 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 3afdb15ef1..918c1f82ee 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -108,10 +108,6 @@ unsigned short config_frames[4] = {2,9,11,13}; # endif #endif - - - - //#define DEBUG_THREADS 1 //#define USRP_DEBUG 1 @@ -158,15 +154,14 @@ static struct { volatile uint8_t phy_proc_CC_id; } sync_phy_proc; - void exit_fun(const char* s); void init_eNB(eNB_func_t node_function); void stop_eNB(void); -void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) -{ +void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) { + unsigned int aa,slot_offset, slot_offset_F; int dummy_tx_b[7680*4] __attribute__((aligned(32))); int i,j, tx_offset; @@ -183,7 +178,6 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) ((subframe_select(&phy_vars_eNB->frame_parms,subframe)==SF_S))) { // LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot); - for (aa=0; aaframe_parms.nb_antennas_tx; aa++) { if (phy_vars_eNB->frame_parms.Ncp == EXTENDED) { PHY_ofdm_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F], @@ -204,7 +198,7 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) 7, &(phy_vars_eNB->frame_parms)); // if S-subframe generate first slot only - if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) + if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_DL) normal_prefix_mod(&phy_vars_eNB->common_vars.txdataF[0][aa][slot_offset_F+slot_sizeF], dummy_tx_b+(phy_vars_eNB->frame_parms.samples_per_tti>>1), 7, @@ -237,9 +231,8 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) txdata[j++] = ((int16_t*)dummy_tx_b)[i]<(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)) { - tx_offset = (int)slot_offset+time_offset[aa]; txdata = (int16_t*)&phy_vars_eNB->common_vars.txdata[0][aa][tx_offset]; len2 = -tx_offset+LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; @@ -260,7 +253,6 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) } } - // if S-subframe switch to RX in second subframe /* if (subframe_select(&phy_vars_eNB->frame_parms,subframe) == SF_S) { @@ -270,34 +262,35 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) } */ if ((((phy_vars_eNB->frame_parms.tdd_config==0) || - (phy_vars_eNB->frame_parms.tdd_config==1) || - (phy_vars_eNB->frame_parms.tdd_config==2) || - (phy_vars_eNB->frame_parms.tdd_config==6)) && - (subframe==0)) || (subframe==5)) { + (phy_vars_eNB->frame_parms.tdd_config==1) || + (phy_vars_eNB->frame_parms.tdd_config==2) || + (phy_vars_eNB->frame_parms.tdd_config==6)) && + (subframe==0)) || (subframe==5)) { // turn on tx switch N_TA_offset before //LOG_D(HW,"subframe %d, time to switch to tx (N_TA_offset %d, slot_offset %d) \n",subframe,phy_vars_eNB->N_TA_offset,slot_offset); for (i=0; iN_TA_offset; i++) { - tx_offset = (int)slot_offset+time_offset[aa]+i-phy_vars_eNB->N_TA_offset/2; - if (tx_offset<0) - tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; + tx_offset = (int)slot_offset+time_offset[aa]+i-phy_vars_eNB->N_TA_offset/2; + if (tx_offset<0) + tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; - if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)) - tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; + if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti)) + tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->frame_parms.samples_per_tti; - phy_vars_eNB->common_vars.txdata[0][aa][tx_offset] = 0x00000000; + phy_vars_eNB->common_vars.txdata[0][aa][tx_offset] = 0x00000000; } } } } } + /*! * \brief The RX UE-specific and TX thread of eNB. * \param param is a \ref eNB_proc_t structure which contains the info what to process. * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* eNB_thread_rxtx( void* param ) -{ +static void* eNB_thread_rxtx( void* param ) { + static int eNB_thread_rxtx_status; eNB_rxtx_proc_t *proc = (eNB_rxtx_proc_t*)param; @@ -365,56 +358,47 @@ static void* eNB_thread_rxtx( void* param ) #endif //CPU_AFFINITY /* Check the actual affinity mask assigned to the thread */ - s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { + if (s != 0) { perror( "pthread_getaffinity_np"); exit_fun("Error getting processor affinity "); } memset(cpu_affinity,0,sizeof(cpu_affinity)); for (j = 0; j < CPU_SETSIZE; j++) - if (CPU_ISSET(j, &cpuset)) - { - char temp[1024]; - sprintf (temp, " CPU_%d", j); - strcat(cpu_affinity, temp); - } + if (CPU_ISSET(j, &cpuset)) { + char temp[1024]; + sprintf (temp, " CPU_%d", j); + strcat(cpu_affinity, temp); + } - memset(&sparam, 0 , sizeof (sparam)); + memset(&sparam, 0, sizeof(sparam)); sparam.sched_priority = sched_get_priority_max(SCHED_FIFO)-1; policy = SCHED_FIFO ; s = pthread_setschedparam(pthread_self(), policy, &sparam); - if (s != 0) - { - perror("pthread_setschedparam : "); - exit_fun("Error setting thread priority"); - } + if (s != 0) { + perror("pthread_setschedparam : "); + exit_fun("Error setting thread priority"); + } + s = pthread_getschedparam(pthread_self(), &policy, &sparam); - if (s != 0) - { - perror("pthread_getschedparam : "); - exit_fun("Error getting thread priority"); + if (s != 0) { + perror("pthread_getschedparam : "); + exit_fun("Error getting thread priority"); + } - } - - LOG_I( HW, "[SCHED][eNB] TX thread started on CPU %d TID %ld, sched_policy = %s , priority = %d, CPU Affinity=%s \n",sched_getcpu(),gettid(), + LOG_I(HW, "[SCHED][eNB] TX thread started on CPU %d TID %ld, sched_policy = %s , priority = %d, CPU Affinity=%s \n",sched_getcpu(),gettid(), (policy == SCHED_FIFO) ? "SCHED_FIFO" : (policy == SCHED_RR) ? "SCHED_RR" : (policy == SCHED_OTHER) ? "SCHED_OTHER" : "???", sparam.sched_priority, cpu_affinity ); - #endif //LOW_LATENCY - mlockall(MCL_CURRENT | MCL_FUTURE); - while (!oai_exit) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { @@ -462,6 +446,7 @@ static void* eNB_thread_rxtx( void* param ) exit_fun("nothing to add"); break; } + // wait for our turn or oai_exit while (sync_phy_proc.phy_proc_CC_id != proc->CC_id && !oai_exit) { pthread_cond_wait(&sync_phy_proc.cond_phy_proc_tx, @@ -473,28 +458,27 @@ static void* eNB_thread_rxtx( void* param ) exit_fun("nothing to add"); } - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX_ENB, proc->frame_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX_ENB, proc->subframe_tx ); - if (oai_exit) - break; + + if (oai_exit) break; + if (PHY_vars_eNB_g[0][proc->CC_id]->node_function != NGFI_RRU_IF4) { - phy_procedures_eNB_TX(PHY_vars_eNB_g[0][proc->CC_id], proc, 0, no_relay, NULL ); - - /* we're done, let the next one proceed */ - if (pthread_mutex_lock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { - LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX proc\n"); - exit_fun("nothing to add"); - break; - } - sync_phy_proc.phy_proc_CC_id++; - sync_phy_proc.phy_proc_CC_id %= MAX_NUM_CCs; - pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); - if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { - LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX proc\n"); - exit_fun("nothing to add"); - break; + phy_procedures_eNB_TX(PHY_vars_eNB_g[0][proc->CC_id], proc, 0, no_relay, NULL ); + + /* we're done, let the next one proceed */ + if (pthread_mutex_lock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { + LOG_E(PHY, "[SCHED][eNB] error locking PHY proc mutex for eNB TX proc\n"); + exit_fun("nothing to add"); + break; + } + sync_phy_proc.phy_proc_CC_id++; + sync_phy_proc.phy_proc_CC_id %= MAX_NUM_CCs; + pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); + if (pthread_mutex_unlock(&sync_phy_proc.mutex_phy_proc_tx) != 0) { + LOG_E(PHY, "[SCHED][eNB] error unlocking PHY proc mutex for eNB TX proc\n"); + exit_fun("nothing to add"); + break; } } else { @@ -504,53 +488,51 @@ static void* eNB_thread_rxtx( void* param ) } } - // eNodeB_3GPP and RRU create txdata and write to RF device - if (PHY_vars_eNB_g[0][proc->CC_id]->node_function != NGFI_RCC_IF4) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 1 ); - do_OFDM_mod_rt( proc->subframe_tx, PHY_vars_eNB_g[0][proc->CC_id] ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 0 ); - /* - short *txdata = (short*)&PHY_vars_eNB_g[0][proc->CC_id]->common_vars.txdata[0][0][proc->subframe_tx*PHY_vars_eNB_g[0][proc->CC_id]->frame_parms.samples_per_tti]; - int i; - for (i=0;iCC_id]->frame_parms.samples_per_tti*2;i+=8) { - txdata[i] = 2047; - txdata[i+1] = 0; - txdata[i+2] = 0; - txdata[i+3] = 2047; - txdata[i+4] = -2047; - txdata[i+5] = 0; - txdata[i+6] = 0; - txdata[i+7] = -2047; } - */ - - - // Transmit TX buffer based on timestamp from RX + // eNodeB_3GPP and RRU create txdata and write to RF device + if (PHY_vars_eNB_g[0][proc->CC_id]->node_function != NGFI_RCC_IF4) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 1 ); + do_OFDM_mod_rt( proc->subframe_tx, PHY_vars_eNB_g[0][proc->CC_id] ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 0 ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); - // prepare tx buffer pointers - int i; - for (i=0; iframe_parms.nb_antennas_tx; i++) - txp[i] = (void*)&PHY_vars_eNB_g[0][0]->common_vars.txdata[0][i][proc->subframe_tx*PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti]; - // if symb_written < spp ==> error - PHY_vars_eNB_g[0][proc->CC_id]->rfdevice.trx_write_func(&PHY_vars_eNB_g[0][proc->CC_id]->rfdevice, - (proc->timestamp_tx-openair0_cfg[0].tx_sample_advance), - txp, - PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti, - PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx, - 1); + /* + short *txdata = (short*)&PHY_vars_eNB_g[0][proc->CC_id]->common_vars.txdata[0][0][proc->subframe_tx*PHY_vars_eNB_g[0][proc->CC_id]->frame_parms.samples_per_tti]; + int i; + for (i=0;iCC_id]->frame_parms.samples_per_tti*2;i+=8) { + txdata[i] = 2047; + txdata[i+1] = 0; + txdata[i+2] = 0; + txdata[i+3] = 2047; + txdata[i+4] = -2047; + txdata[i+5] = 0; + txdata[i+6] = 0; + txdata[i+7] = -2047; } + */ + + // Transmit TX buffer based on timestamp from RX + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + // prepare tx buffer pointers + int i; + for (i=0; iframe_parms.nb_antennas_tx; i++) + txp[i] = (void*)&PHY_vars_eNB_g[0][0]->common_vars.txdata[0][i][proc->subframe_tx*PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti]; + // if symb_written < spp ==> error + PHY_vars_eNB_g[0][proc->CC_id]->rfdevice.trx_write_func(&PHY_vars_eNB_g[0][proc->CC_id]->rfdevice, + (proc->timestamp_tx-openair0_cfg[0].tx_sample_advance), + txp, + PHY_vars_eNB_g[0][0]->frame_parms.samples_per_tti, + PHY_vars_eNB_g[0][0]->frame_parms.nb_antennas_tx, + 1); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-openair0_cfg[0].tx_sample_advance)&0xffffffff ); + } else { + + /// **** send_IF4 of txdataF to RRU **** /// + //send_IF4(PHY_vars_eNB_g[0][proc->CC_id], proc); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); - - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-openair0_cfg[0].tx_sample_advance)&0xffffffff ); - - } else { // RCC sends the txdataF using send_IF4 function - - /// **** send_IF4 of txdataF to RRU **** /// - //send_IF4(PHY_vars_eNB_g[0][proc->CC_id], proc); - - } + } if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) { LOG_E( PHY, "[SCHED][eNB] error locking mutex for eNB TX proc\n"); @@ -567,19 +549,18 @@ static void* eNB_thread_rxtx( void* param ) } stop_meas( &softmodem_stats_rxtx_sf ); + #ifdef LOWLATENCY - if (opp_enabled){ - if(softmodem_stats_rxtx_sf.diff_now/(cpuf) > attr.sched_runtime){ - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RUNTIME_TX_ENB, (softmodem_stats_rxtx_sf.diff_now/cpuf - attr.sched_runtime)/1000000.0); + if (opp_enabled) { + if(softmodem_stats_rxtx_sf.diff_now/(cpuf) > attr.sched_runtime) { + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RUNTIME_TX_ENB, (softmodem_stats_rxtx_sf.diff_now/cpuf - attr.sched_runtime)/1000000.0); } } #endif + print_meas_now(&softmodem_stats_rxtx_sf,"eNB_TX_SF",tx_time_file); - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); #ifdef DEBUG_THREADS @@ -591,13 +572,11 @@ static void* eNB_thread_rxtx( void* param ) } #if defined(ENABLE_ITTI) -static void wait_system_ready (char *message, volatile int *start_flag) - - /* Wait for eNB application initialization to be complete (eNB registration to MME) */ -{ +/* Wait for eNB application initialization to be complete (eNB registration to MME) */ +static void wait_system_ready (char *message, volatile int *start_flag) { + static char *indicator[] = {". ", ".. ", "... ", ".... ", ".....", - " ....", " ...", " ..", " .", " " - }; + " ....", " ...", " ..", " .", " "}; int i = 0; while ((!oai_exit) && (*start_flag == 0)) { @@ -609,16 +588,16 @@ static void wait_system_ready (char *message, volatile int *start_flag) LOG_D(EMU,"\n"); } - #endif + /*! * \brief The RX common thread of eNB. * \param param is a \ref eNB_proc_t structure which contains the info what to process. * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* eNB_thread_rx_common( void* param ) -{ +static void* eNB_thread_rx_common( void* param ) { + static int eNB_thread_rx_status; eNB_proc_t *proc = (eNB_proc_t*)param; @@ -629,7 +608,7 @@ static void* eNB_thread_rx_common( void* param ) char rx_time_name[101]; //int i; - if (opp_enabled == 1){ + if (opp_enabled == 1) { snprintf(rx_time_name, 100,"/tmp/%s_rx_time_thread_sf", "eNB"); rx_time_file = fopen(rx_time_name,"w"); } @@ -674,14 +653,12 @@ static void* eNB_thread_rx_common( void* param ) /* Set CPU Affinity only if number of CPUs >2 */ CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY - if (get_nprocs() >2) - { + if (get_nprocs() >2) { for (j = 1; j < get_nprocs(); j++) - CPU_SET(j, &cpuset); + CPU_SET(j, &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { + if (s != 0) { perror( "pthread_setaffinity_np"); exit_fun (" Error setting processor affinity :"); } @@ -690,66 +667,58 @@ static void* eNB_thread_rx_common( void* param ) /* Check the actual affinity mask assigned to the thread */ s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { - perror ("pthread_getaffinity_np"); - exit_fun (" Error getting processor affinity :"); + if (s != 0) { + perror ("pthread_getaffinity_np"); + exit_fun (" Error getting processor affinity :"); } memset(cpu_affinity,0, sizeof(cpu_affinity)); for (j = 0; j < CPU_SETSIZE; j++) - if (CPU_ISSET(j, &cpuset)) - { - char temp[1024]; - sprintf (temp, " CPU_%d", j); - strcat(cpu_affinity, temp); - } - + if (CPU_ISSET(j, &cpuset)) { + char temp[1024]; + sprintf (temp, " CPU_%d", j); + strcat(cpu_affinity, temp); + } memset(&sparam, 0 , sizeof (sparam)); sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); policy = SCHED_FIFO ; s = pthread_setschedparam(pthread_self(), policy, &sparam); - if (s != 0) - { - perror("pthread_setschedparam : "); - exit_fun("Error setting thread priority"); - } + if (s != 0) { + perror("pthread_setschedparam : "); + exit_fun("Error setting thread priority"); + } memset(&sparam, 0 , sizeof (sparam)); s = pthread_getschedparam(pthread_self(), &policy, &sparam); - if (s != 0) - { - perror("pthread_getschedparam"); - exit_fun("Error getting thread priority"); - } + if (s != 0) { + perror("pthread_getschedparam"); + exit_fun("Error getting thread priority"); + } - - LOG_I( HW, "[SCHED][eNB] RX thread started on CPU %d TID %ld, sched_policy = %s, priority = %d, CPU Affinity = %s\n", sched_getcpu(),gettid(), + LOG_I(HW, "[SCHED][eNB] RX thread started on CPU %d TID %ld, sched_policy = %s, priority = %d, CPU Affinity = %s\n", sched_getcpu(),gettid(), (policy == SCHED_FIFO) ? "SCHED_FIFO" : (policy == SCHED_RR) ? "SCHED_RR" : (policy == SCHED_OTHER) ? "SCHED_OTHER" : "???", sparam.sched_priority, cpu_affinity); - - + #endif // LOWLATENCY - mlockall(MCL_CURRENT | MCL_FUTURE); + mlockall(MCL_CURRENT | MCL_FUTURE); + // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe of TX and RX threads + printf( "waiting for sync (eNB_thread_rx_common)\n"); + pthread_mutex_lock( &sync_mutex ); - // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe of TX and RX threads - printf( "waiting for sync (eNB_thread_rx_common)\n"); - pthread_mutex_lock( &sync_mutex ); - - while (sync_var<0) - pthread_cond_wait( &sync_cond, &sync_mutex ); + while (sync_var<0) + pthread_cond_wait( &sync_cond, &sync_mutex ); - pthread_mutex_unlock(&sync_mutex); + pthread_mutex_unlock(&sync_mutex); - printf( "got sync (eNB_thread)\n" ); + printf( "got sync (eNB_thread)\n" ); #if defined(ENABLE_ITTI) wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB); @@ -767,96 +736,90 @@ static void* eNB_thread_rx_common( void* param ) LOG_E(HW,"Could not start the IF device\n"); } - // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices - while (!oai_exit) { + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices + while (!oai_exit) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RX, 0 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 0 ); + start_meas( &softmodem_stats_rx_sf ); + if (oai_exit) break; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RX, 0 ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 0 ); - start_meas( &softmodem_stats_rx_sf ); - - if (oai_exit) break; - - if ((((fp->frame_type == TDD )&&(subframe_select(fp,proc->subframe_rx)==SF_UL)) || - (fp->frame_type == FDD))) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 1 ); - // this spawns the prach inside and updates the frame and subframe counters - phy_procedures_eNB_common_RX(eNB, 0); - - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 0 ); - } + if ((((fp->frame_type == TDD )&&(subframe_select(fp,proc->subframe_rx)==SF_UL)) || + (fp->frame_type == FDD))) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 1 ); + // this spawns the prach inside and updates the frame and subframe counters + phy_procedures_eNB_common_RX(eNB, 0); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, 0 ); + } - // choose even or odd thread for RXn-TXnp4 processing - eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[proc->subframe_rx&1]; + // choose even or odd thread for RXn-TXnp4 processing + eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[proc->subframe_rx&1]; - // wake up TX for subframe n+4 - // lock the TX mutex and make sure the thread is ready - if (pthread_mutex_lock(&proc_rxtx->mutex_rxtx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX thread %d (IC %d)\n", proc_rxtx->instance_cnt_rxtx ); - exit_fun( "error locking mutex_rxtx" ); - break; - } - int cnt_rxtx = ++proc_rxtx->instance_cnt_rxtx; - // We have just received and processed the common part of a subframe, say n. - // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired - // transmitted timestamp of the next TX slot (first). - // The last (TS_rx mod samples_pexr_frame) was n*samples_per_tti, - // we want to generate subframe (n+3), so TS_tx = TX_rx+3*samples_per_tti, - // and proc->subframe_tx = proc->subframe_rx+3 - proc_rxtx->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); - proc_rxtx->frame_rx = proc->frame_rx; - proc_rxtx->subframe_rx = proc->subframe_rx; - proc_rxtx->frame_tx = (proc_rxtx->subframe_rx > 5) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx; - proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + 4)%10; + // wake up TX for subframe n+4 + // lock the TX mutex and make sure the thread is ready + if (pthread_mutex_lock(&proc_rxtx->mutex_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX thread %d (IC %d)\n", proc_rxtx->instance_cnt_rxtx ); + exit_fun( "error locking mutex_rxtx" ); + break; + } + int cnt_rxtx = ++proc_rxtx->instance_cnt_rxtx; + // We have just received and processed the common part of a subframe, say n. + // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired + // transmitted timestamp of the next TX slot (first). + // The last (TS_rx mod samples_pexr_frame) was n*samples_per_tti, + // we want to generate subframe (n+3), so TS_tx = TX_rx+3*samples_per_tti, + // and proc->subframe_tx = proc->subframe_rx+3 + proc_rxtx->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); + proc_rxtx->frame_rx = proc->frame_rx; + proc_rxtx->subframe_rx = proc->subframe_rx; + proc_rxtx->frame_tx = (proc_rxtx->subframe_rx > 5) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx; + proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + 4)%10; - pthread_mutex_unlock( &proc_rxtx->mutex_rxtx ); + pthread_mutex_unlock( &proc_rxtx->mutex_rxtx ); - if (cnt_rxtx == 0){ - // the thread was presumably waiting where it should and can now be woken up - if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB RXn-TXnp4 thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - break; - } - } else { - LOG_W( PHY,"[eNB] Frame %d, eNB RXn-TXnp4 thread busy!! (cnt_rxtx %i)\n", proc_rxtx->frame_tx, cnt_rxtx ); - exit_fun( "TX thread busy" ); - break; - } + if (cnt_rxtx == 0) { + // the thread was presumably waiting where it should and can now be woken up + if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB RXn-TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + break; + } + } else { + LOG_W( PHY,"[eNB] Frame %d, eNB RXn-TXnp4 thread busy!! (cnt_rxtx %i)\n", proc_rxtx->frame_tx, cnt_rxtx ); + exit_fun( "TX thread busy" ); + break; + } - stop_meas( &softmodem_stats_rxtx_sf ); + stop_meas( &softmodem_stats_rxtx_sf ); + #ifdef LOWLATENCY - if (opp_enabled){ - if(softmodem_stats_rxtx_sf.diff_now/(cpuf) > attr.sched_runtime){ - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RUNTIME_RXTX_ENB, (softmodem_stats_rxtx_sf.diff_now/cpuf - attr.sched_runtime)/1000000.0); - } - } + if (opp_enabled){ + if(softmodem_stats_rxtx_sf.diff_now/(cpuf) > attr.sched_runtime){ + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RUNTIME_RXTX_ENB, (softmodem_stats_rxtx_sf.diff_now/cpuf - attr.sched_runtime)/1000000.0); + } + } #endif // LOWLATENCY - print_meas_now(&softmodem_stats_rx_sf,"eNB_RX_SF", rx_time_file); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); - - } - + print_meas_now(&softmodem_stats_rx_sf,"eNB_RX_SF", rx_time_file); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); + } #ifdef DEBUG_THREADS - printf( "Exiting eNB thread RXn-TXnp4\n"); + printf( "Exiting eNB thread RXn-TXnp4\n"); #endif - eNB_thread_rx_status = 0; - return &eNB_thread_rx_status; + eNB_thread_rx_status = 0; + return &eNB_thread_rx_status; } - /*! * \brief The prach receive thread of eNB. * \param param is a \ref eNB_proc_t structure which contains the info what to process. * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* eNB_thread_prach( void* param ) -{ +static void* eNB_thread_prach( void* param ) { static int eNB_thread_prach_status; eNB_proc_t *proc = (eNB_proc_t*)param; @@ -865,7 +828,6 @@ static void* eNB_thread_prach( void* param ) eNB_thread_prach_status = 0; MSC_START_USE(); - #ifdef LOWLATENCY struct sched_attr attr; @@ -903,113 +865,102 @@ static void* eNB_thread_prach( void* param ) /* Set CPU Affinity only if number of CPUs >2 */ CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY - if (get_nprocs() >2) - { + if (get_nprocs() >2) { for (j = 1; j < get_nprocs(); j++) - CPU_SET(j, &cpuset); + CPU_SET(j, &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { + if (s != 0) { perror( "pthread_setaffinity_np"); exit_fun (" Error setting processor affinity :"); } } #endif //CPU_AFFINITY - /* Check the actual affinity mask assigned to the thread */ + /* Check the actual affinity mask assigned to the thread */ s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - if (s != 0) - { - perror ("pthread_getaffinity_np"); - exit_fun (" Error getting processor affinity :"); + if (s != 0) { + perror ("pthread_getaffinity_np"); + exit_fun (" Error getting processor affinity :"); } memset(cpu_affinity,0, sizeof(cpu_affinity)); for (j = 0; j < CPU_SETSIZE; j++) - if (CPU_ISSET(j, &cpuset)) - { - char temp[1024]; - sprintf (temp, " CPU_%d", j); - strcat(cpu_affinity, temp); - } - + if (CPU_ISSET(j, &cpuset)) { + char temp[1024]; + sprintf (temp, " CPU_%d", j); + strcat(cpu_affinity, temp); + } memset(&sparam, 0 , sizeof (sparam)); sparam.sched_priority = sched_get_priority_max(SCHED_FIFO)-2; policy = SCHED_FIFO ; s = pthread_setschedparam(pthread_self(), policy, &sparam); - if (s != 0) - { - perror("pthread_setschedparam : "); - exit_fun("Error setting thread priority"); - } + if (s != 0) { + perror("pthread_setschedparam : "); + exit_fun("Error setting thread priority"); + } memset(&sparam, 0 , sizeof (sparam)); s = pthread_getschedparam(pthread_self(), &policy, &sparam); - if (s != 0) - { - perror("pthread_getschedparam"); - exit_fun("Error getting thread priority"); - } + if (s != 0) { + perror("pthread_getschedparam"); + exit_fun("Error getting thread priority"); + } - - LOG_I( HW, "[SCHED][eNB] PRACH thread started on CPU %d TID %ld, sched_policy = %s, priority = %d, CPU Affinity = %s\n", sched_getcpu(),gettid(), + LOG_I(HW, "[SCHED][eNB] PRACH thread started on CPU %d TID %ld, sched_policy = %s, priority = %d, CPU Affinity = %s\n", sched_getcpu(),gettid(), (policy == SCHED_FIFO) ? "SCHED_FIFO" : (policy == SCHED_RR) ? "SCHED_RR" : (policy == SCHED_OTHER) ? "SCHED_OTHER" : "???", sparam.sched_priority, cpu_affinity); - - + #endif // LOWLATENCY - mlockall(MCL_CURRENT | MCL_FUTURE); + mlockall(MCL_CURRENT | MCL_FUTURE); - - while (!oai_exit) { - - - if (oai_exit) break; - - if (pthread_mutex_lock(&proc->mutex_prach) != 0) { - LOG_E( PHY, "[SCHED][eNB] error locking mutex for eNB PRACH\n"); - exit_fun( "error locking mutex" ); - break; - } - - while (proc->instance_cnt_prach < 0) { - // most of the time the thread is waiting here - // proc->instance_cnt_prach is -1 - pthread_cond_wait( &proc->cond_prach, &proc->mutex_prach ); // this unlocks mutex_rxtx while waiting and then locks it again - } - - if (pthread_mutex_unlock(&proc->mutex_prach) != 0) { - LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for eNB PRACH\n"); - exit_fun( "error unlocking mutex" ); - break; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,1); - prach_procedures(eNB,0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,0); + while (!oai_exit) { - if (pthread_mutex_lock(&proc->mutex_prach) != 0) { - LOG_E( PHY, "[SCHED][eNB] error locking mutex for eNB PRACH proc %d\n"); - exit_fun( "error locking mutex" ); - break; - } + if (oai_exit) break; + + if (pthread_mutex_lock(&proc->mutex_prach) != 0) { + LOG_E( PHY, "[SCHED][eNB] error locking mutex for eNB PRACH\n"); + exit_fun( "error locking mutex" ); + break; + } + + while (proc->instance_cnt_prach < 0) { + // most of the time the thread is waiting here + // proc->instance_cnt_prach is -1 + pthread_cond_wait( &proc->cond_prach, &proc->mutex_prach ); // this unlocks mutex_rxtx while waiting and then locks it again + } + + if (pthread_mutex_unlock(&proc->mutex_prach) != 0) { + LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for eNB PRACH\n"); + exit_fun( "error unlocking mutex" ); + break; + } - proc->instance_cnt_prach--; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,1); + prach_procedures(eNB,0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,0); + + if (pthread_mutex_lock(&proc->mutex_prach) != 0) { + LOG_E( PHY, "[SCHED][eNB] error locking mutex for eNB PRACH proc %d\n"); + exit_fun( "error locking mutex" ); + break; + } - if (pthread_mutex_unlock(&proc->mutex_prach) != 0) { - LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for eNB RX proc %d\n"); - exit_fun( "error unlocking mutex" ); - break; - } - } + proc->instance_cnt_prach--; + + if (pthread_mutex_unlock(&proc->mutex_prach) != 0) { + LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for eNB RX proc %d\n"); + exit_fun( "error unlocking mutex" ); + break; + } + } #ifdef DEBUG_THREADS printf( "Exiting eNB thread PRACH\n"); @@ -1020,10 +971,8 @@ static void* eNB_thread_prach( void* param ) } - - -void init_eNB_proc(void) -{ +void init_eNB_proc(void) { + int i; int CC_id; PHY_VARS_eNB *eNB; @@ -1033,7 +982,6 @@ void init_eNB_proc(void) for (CC_id=0; CC_idproc; proc_rxtx = proc->proc_rxtx; #ifndef LOWLATENCY @@ -1097,7 +1045,6 @@ void init_eNB_proc(void) pthread_setname_np( proc->pthread_rx, name ); } - /* setup PHY proc TX sync mechanism */ pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL); pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL); @@ -1108,8 +1055,8 @@ void init_eNB_proc(void) /*! * \brief Terminate eNB TX and RX threads. */ -void kill_eNB_proc(void) -{ +void kill_eNB_proc(void) { + int *status; PHY_VARS_eNB *eNB; eNB_proc_t *proc; @@ -1133,6 +1080,7 @@ void kill_eNB_proc(void) #ifdef DEBUG_THREADS printf( "Joining eNB TX CC_id %d thread\n", CC_id); #endif + int result,i; for (i=0;i<1;i++) { pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); @@ -1148,16 +1096,14 @@ void kill_eNB_proc(void) printf( "The thread was killed. No status available.\n" ); } } - #else UNUSED(result); #endif pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); - - } + #ifdef DEBUG_THREADS printf( "Killing RX CC_id %d thread\n", CC_id); #endif @@ -1165,10 +1111,10 @@ void kill_eNB_proc(void) #ifdef DEBUG_THREADS printf( "Joining eNB RX CC_id %d thread ...\n", CC_id); #endif + result = pthread_join( proc->pthread_rx, (void**)&status ); -#ifdef DEBUG_THREADS - +#ifdef DEBUG_THREADS if (result != 0) { printf( "Error joining thread.\n" ); } else { @@ -1177,8 +1123,7 @@ void kill_eNB_proc(void) } else { printf( "The thread was killed. No status available.\n" ); } - } - + } #else UNUSED(result); #endif @@ -1193,17 +1138,17 @@ void kill_eNB_proc(void) Each rf chain is is addressed by the card number and the chain on the card. The rf_map specifies for each CC, on which rf chain the mapping should start. Multiple antennas are mapped to successive RF chains on the same card. */ -int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, 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]) { int i, CC_id; + #ifndef EXMIMO uint16_t N_TA_offset = 0; #else int j; #endif - LTE_DL_FRAME_PARMS *frame_parms; + LTE_DL_FRAME_PARMS *frame_parms; for (CC_id=0; CC_idframe_type == TDD) { - if (frame_parms->N_RB_DL == 100) - N_TA_offset = 624; - else if (frame_parms->N_RB_DL == 50) - N_TA_offset = 624/2; - else if (frame_parms->N_RB_DL == 25) - N_TA_offset = 624/4; - } - + if (frame_parms->frame_type == TDD) { + if (frame_parms->N_RB_DL == 100) + N_TA_offset = 624; + else if (frame_parms->N_RB_DL == 50) + N_TA_offset = 624/2; + else if (frame_parms->N_RB_DL == 25) + N_TA_offset = 624/4; + } #endif // replace RX signal buffers with mmaped HW versions @@ -1285,8 +1227,7 @@ int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_c rxdata[i] = (int32_t*)(32 + malloc16(32+openair0_cfg[rf_map[CC_id].card].samples_per_frame*sizeof(int32_t))); // FIXME broken memory allocation phy_vars_eNB[CC_id]->common_vars.rxdata[0][i] = rxdata[i]-N_TA_offset; // N_TA offset for TDD FIXME! N_TA_offset > 16 => access of unallocated memory memset(rxdata[i], 0, openair0_cfg[rf_map[CC_id].card].samples_per_frame*sizeof(int32_t)); - printf("rxdata[%d] @ %p (%p) (N_TA_OFFSET %d)\n", i, phy_vars_eNB[CC_id]->common_vars.rxdata[0][i],rxdata[i],N_TA_offset); - + printf("rxdata[%d] @ %p (%p) (N_TA_OFFSET %d)\n", i, phy_vars_eNB[CC_id]->common_vars.rxdata[0][i],rxdata[i],N_TA_offset); } for (i=0; inb_antennas_tx; i++) { @@ -1295,19 +1236,17 @@ int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_c phy_vars_eNB[CC_id]->common_vars.txdata[0][i] = txdata[i]; memset(txdata[i],0, openair0_cfg[rf_map[CC_id].card].samples_per_frame*sizeof(int32_t)); printf("txdata[%d] @ %p\n", i, phy_vars_eNB[CC_id]->common_vars.txdata[0][i]); - } - #endif + } return(0); } - - void reset_opp_meas(void) { + int sfn; reset_meas(&softmodem_stats_mt); reset_meas(&softmodem_stats_hw); @@ -1318,6 +1257,7 @@ void reset_opp_meas(void) { } } + void print_opp_meas(void) { int sfn=0; @@ -1333,7 +1273,6 @@ void print_opp_meas(void) { void init_eNB(eNB_func_t node_function) { - int CC_id; for (CC_id=0;CC_id Date: Fri, 17 Jun 2016 04:14:41 +0530 Subject: [PATCH 7/9] handle prach rx for enb node functions --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 53 +++-- openair1/PHY/LTE_TRANSPORT/if4_tools.h | 2 +- openair1/SCHED/phy_procedures_lte_eNb.c | 266 +++++++++++++----------- targets/RT/USER/lte-enb.c | 2 +- 4 files changed, 182 insertions(+), 141 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index a8a27b2c09..24b338f5a4 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -45,11 +45,11 @@ #include "PHY/TOOLS/ALAW/alaw_lut.h" // Get device information -void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - int32_t **txdataF = eNB->common_vars.txdataF[0]; +void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, uint16_t packet_type) { + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + int32_t **txdataF = eNB->common_vars.txdataF[0]; - uint16_t symbol_id, element_id; + uint16_t symbol_id, element_id; uint16_t db_fulllength = 12*fp->N_RB_DL; uint16_t db_halflength = db_fulllength>>1; int slotoffsetF = (proc->subframe_tx)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1; @@ -58,7 +58,7 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { int16_t *data_block = (int16_t*)malloc(db_fulllength*sizeof(int16_t)); // Caller: RCC - DL *** handle RRU case - UL and PRACH *** - if (eNB->node_function == NGFI_RCC_IF4) { + if (packet_type == IF4_PDLFFT) { IF4_dl_packet_t *dl_packet = (IF4_dl_packet_t*)malloc(sizeof_IF4_dl_packet_t); gen_IF4_dl_packet(dl_packet, proc); @@ -93,7 +93,7 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { slotoffsetF += fp->ofdm_symbol_size; blockoffsetF += fp->ofdm_symbol_size; } - }else { + } else if (packet_type == IF4_PULFFT) { IF4_ul_packet_t *ul_packet = (IF4_ul_packet_t*)malloc(sizeof_IF4_ul_packet_t); gen_IF4_ul_packet(ul_packet, proc); @@ -101,7 +101,7 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { for (symbol_id=0; symbol_idsymbols_per_tti; symbol_id++) { - // Do compression of the two parts and generate data blocks - rxdataF + // Do compression of the two parts and generate data blocks - rxdataF for (element_id=0; element_id>16) + 32768 ]<<8; @@ -118,19 +118,23 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc) { slotoffsetF += fp->ofdm_symbol_size; blockoffsetF += fp->ofdm_symbol_size; } - } - + } else if (packet_type == IF4_PRACH) { + + + } else { + AssertFatal(1==0, "send_IF4 - Unknown packet_type %x", packet_type); + } + + return; } void recv_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, uint16_t *packet_type, uint32_t *symbol_number) { - // Caller: RRU - DL *** handle RCC case - UL and PRACH *** - if (eNB->node_function == NGFI_RRU_IF4) { - - printf("\n Recv IF4 for frame %d, subframe %d and symbol %d\n", proc->frame_tx, proc->subframe_tx, symbol_id); - + *packet_type = 0; + int16_t *data_block=NULL; + + // Read packet(s) from the fronthaul // for(i=0; isymbols_per_tti; i++) { - // Read packet(s) from the fronthaul // if (dev->eth_dev.trx_read_func (&dev->eth_dev, // timestamp_rx, // rx_eNB, @@ -139,16 +143,27 @@ void recv_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, uint16_t *packet_type, u // ) < 0) { // perror("RRU : ETHERNET read"); // } +// printf("\n Recv IF4 for frame %d, subframe %d and symbol %d\n", proc->frame_tx, proc->subframe_tx, symbol_id); + + //*packet_type = ; + + if (*packet_type == IF4_PDLFFT) { // Apply reverse processing - decompression // txAlawtolinear( Datablock ) // Generate and return the OFDM symbols (txdataF) - //txDataF - //} - }else { + // txDataF - } + } else if (*packet_type == IF4_PULFFT) { + + } else if (*packet_type == IF4_PRACH) { + + } else { + AssertFatal(1==0, "recv_IF4 - Unknown packet_type %x", *packet_type); + } + + return; } void gen_IF4_dl_packet(IF4_dl_packet_t *dl_packet, eNB_rxtx_proc_t *proc) { diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.h b/openair1/PHY/LTE_TRANSPORT/if4_tools.h index d7a0461169..a6ca7eb5c0 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.h +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.h @@ -181,6 +181,6 @@ void gen_IF4_ul_packet(IF4_ul_packet_t*, eNB_rxtx_proc_t*); void gen_IF4_prach_packet(IF4_prach_packet_t*, eNB_rxtx_proc_t*); -void send_IF4(PHY_VARS_eNB*, eNB_rxtx_proc_t*); +void send_IF4(PHY_VARS_eNB*, eNB_rxtx_proc_t*, uint16_t); void recv_IF4(PHY_VARS_eNB*, eNB_rxtx_proc_t*, uint16_t*, uint32_t*); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 087404d10a..ae6627939c 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -44,6 +44,8 @@ #include "SCHED/defs.h" #include "SCHED/extern.h" +#include "PHY/LTE_TRANSPORT/if4_tools.h" + #ifdef EMOS #include "SCHED/phy_procedures_emos.h" #endif @@ -2471,7 +2473,6 @@ void cba_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,int UE_id,int harq_p } - void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_flag) { int i,l; @@ -2481,158 +2482,183 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl eNB_proc_t *proc = &eNB->proc; int subframe = proc->subframe_rx; int frame = proc->frame_rx; - int symbol_number, symbol_mask, symbol_mask_full, prach_rx, packet_type; + + int prach_rx; + + uint16_t packet_type; + uint32_t symbol_number; + uint32_t symbol_mask, symbol_mask_full; if (subframe==9) { subframe=0; frame++; frame&=1023; + } else { + subframe++; } - else subframe++; - + // VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_COMMON_RX,1); start_meas(&eNB->phy_proc_rx); + #ifdef DEBUG_PHY_PROC LOG_D(PHY,"[eNB %d] Frame %d: Doing phy_procedures_eNB_RX(%d)\n",eNB->Mod_id,frame, subframe); #endif if (abstraction_flag==0) { // grab signal in chunks of 500 us (1 slot) - + + if ((eNB->node_function == NGFI_RRU_IF4) || + (eNB->node_function == eNodeB_3GPP)) { // acquisition from RF and front-end processing - if ((eNB->node_function == NGFI_RRU_IF4) || - (eNB->node_function == eNodeB_3GPP)) { // acquisition from RF and front-end processing - for (i=0; inb_antennas_rx; i++) - rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][subframe*fp->samples_per_tti]; + for (i=0; inb_antennas_rx; i++) + rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][subframe*fp->samples_per_tti]; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); - rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, - &proc->timestamp_rx, - rxp, - fp->samples_per_tti, - fp->nb_antennas_rx); - proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; - proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; - if (proc->first_rx == 0) { - AssertFatal(proc->subframe_rx == subframe, "Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)",proc->subframe_rx,subframe); - AssertFatal(proc->frame_rx == frame, "Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)",proc->frame_rx,frame); - } - else - proc->first_rx = 0; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); + rxs = eNB->rfdevice.trx_read_func(&eNB->rfdevice, + &proc->timestamp_rx, + rxp, + fp->samples_per_tti, + fp->nb_antennas_rx); + proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; + proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; - // printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",proc->timestamp_rx,proc->frame_rx,frame,proc->subframe_rx,subframe); + if (proc->first_rx == 0) { + AssertFatal(proc->subframe_rx == subframe, "Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)",proc->subframe_rx,subframe); + AssertFatal(proc->frame_rx == frame, "Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d)",proc->frame_rx,frame); + } else { + proc->first_rx = 0; + } - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX_ENB, frame ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX_ENB, subframe ); + //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",proc->timestamp_rx,proc->frame_rx,frame,proc->subframe_rx,subframe); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX_ENB, frame ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX_ENB, subframe ); - if (rxs != fp->samples_per_tti) - exit_fun( "problem receiving samples" ); + if (rxs != fp->samples_per_tti) + exit_fun( "problem receiving samples" ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - // now do common RX processing for first slot in subframe - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,1); - remove_7_5_kHz(eNB,subframe<<1); - remove_7_5_kHz(eNB,1+(subframe<<1)); - for (l=0; lsymbols_per_tti/2; l++) { - slot_fep_ul(fp, - &eNB->common_vars, - l, - subframe<<1, - 0, - 0 - ); - slot_fep_ul(fp, - &eNB->common_vars, - l, - 1+(subframe<<1), - 0, - 0 - ); - } + // now do common RX processing for first slot in subframe + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,1); + remove_7_5_kHz(eNB,subframe<<1); + remove_7_5_kHz(eNB,1+(subframe<<1)); + for (l=0; lsymbols_per_tti/2; l++) { + slot_fep_ul(fp, + &eNB->common_vars, + l, + subframe<<1, + 0, + 0 + ); + slot_fep_ul(fp, + &eNB->common_vars, + l, + 1+(subframe<<1), + 0, + 0 + ); + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,0); - if (eNB->node_function == NGFI_RRU_IF4) { - /// **** send_IF4 of rxdataF to RCC **** /// - /// Handle routing to prach thread for sending prach - } + if (eNB->node_function == NGFI_RRU_IF4 && is_prach_subframe(fp, frame, subframe)<=0) { - } - else if (eNB->node_function == NGFI_RCC_IF4) { - /// **** recv_IF4 of rxdataF from RRU **** /// - /// **** recv_IF4 of prachF from RRU **** /// - // get frame/subframe information from IF4 interface - // timed loop (200 us) - - //symbol_mask = 0; - //symbol_mask_full = (1<symbols_per_tti)-1; - //if (is_prach_subframe(fp,frame,subframe)>0) - //prach_rx = 0; - //else - //prach_rx = 1; - - //do { - //recv_IF4(eNB, proc, &packet_type, &symbol_number); - //if (is_prach_subframe(fp,frame,subframe)>0 && packet_type == PRACH) { - //// wake up prach_rx - //prach_rx = 1; - //} - //if (packet_type == IF4_PULFFT) - //symbol_mask = symbol_mask | (1<node_function %d",eNB->node_function); - } - - - // check if we have to detect PRACH first - if (is_prach_subframe(fp,frame,subframe)>0) { - // wake up thread for PRACH RX - if (pthread_mutex_lock(&proc->mutex_prach) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB PRACH thread %d (IC %d)\n", proc->instance_cnt_prach ); - exit_fun( "error locking mutex_prach" ); - return; - } - - int cnt_prach = ++proc->instance_cnt_prach; - // set timing for prach thread - proc->frame_prach = frame; - proc->subframe_prach = subframe; - - pthread_mutex_unlock( &proc->mutex_prach ); - - if (cnt_prach == 0) { - // the thread was presumably waiting where it should and can now be woken up - if (pthread_cond_signal(&proc->cond_prach) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB PRACH thread %d\n", proc->thread_index); - exit_fun( "ERROR pthread_cond_signal" ); - return; - } - } else { - LOG_W( PHY,"[eNB] Frame %d, eNB PRACH thread busy!!\n", frame); - exit_fun( "PRACH thread busy" ); - return; + /// **** send_IF4 of rxdataF to RCC (no prach now) **** /// } + /// **** send_IF4 of prach to RCC **** /// done in prach thread (below) + // check if we have to detect PRACH first + if (is_prach_subframe(fp,frame,subframe)>0) { + // wake up thread for PRACH RX + if (pthread_mutex_lock(&proc->mutex_prach) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB PRACH thread %d (IC %d)\n", proc->instance_cnt_prach ); + exit_fun( "error locking mutex_prach" ); + return; + } + + int cnt_prach = ++proc->instance_cnt_prach; + // set timing for prach thread + proc->frame_prach = frame; + proc->subframe_prach = subframe; + pthread_mutex_unlock( &proc->mutex_prach ); + + if (cnt_prach == 0) { + // the thread was presumably waiting where it should and can now be woken up + if (pthread_cond_signal(&proc->cond_prach) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB PRACH thread %d\n", proc->thread_index); + exit_fun( "ERROR pthread_cond_signal" ); + return; + } + } else { + LOG_W( PHY,"[eNB] Frame %d, eNB PRACH thread busy!!\n", frame); + exit_fun( "PRACH thread busy" ); + return; + } + } + + } else if (eNB->node_function == NGFI_RCC_IF4) { + /// **** recv_IF4 of rxdataF from RRU **** /// + /// **** recv_IF4 of prachF from RRU **** /// + // get frame/subframe information from IF4 interface + // timed loop (200 us) + + symbol_mask = 0; + symbol_mask_full = (1<symbols_per_tti)-1; + prach_rx = 0; + + do { + //recv_IF4(eNB, proc, &packet_type, &symbol_number); + + if (packet_type == IF4_PULFFT) { + symbol_mask = symbol_mask | (1<0 && packet_type == PRACH) { + // wake up thread for PRACH RX + prach_rx = 1; + + if (pthread_mutex_lock(&proc->mutex_prach) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB PRACH thread %d (IC %d)\n", proc->instance_cnt_prach ); + exit_fun( "error locking mutex_prach" ); + return; + } + + int cnt_prach = ++proc->instance_cnt_prach; + // set timing for prach thread + proc->frame_prach = frame; + proc->subframe_prach = subframe; + + pthread_mutex_unlock( &proc->mutex_prach ); + + if (cnt_prach == 0) { + // the thread was presumably waiting where it should and can now be woken up + if (pthread_cond_signal(&proc->cond_prach) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB PRACH thread %d\n", proc->thread_index); + exit_fun( "ERROR pthread_cond_signal" ); + return; + } + } else { + LOG_W( PHY,"[eNB] Frame %d, eNB PRACH thread busy!!\n", frame); + exit_fun( "PRACH thread busy" ); + return; + } + } + + } while( (symbol_mask != symbol_mask_full) && (prach_rx == 0)); + + // Tobi aka mr monaco: ETH + + } else { // should not get here + AssertFatal(1==0, "Unknown eNB->node_function %d",eNB->node_function); } - - - } - - else { // grab transport channel information from network interface + } else { // grab transport channel information from network interface } + } + void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const uint8_t abstraction_flag,const relaying_type_t r_type) { //RX processing for ue-specific resources (i diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 918c1f82ee..3a836d6bdb 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -483,7 +483,7 @@ static void* eNB_thread_rxtx( void* param ) { } else { /// **** recv_IF4 of txdataF from RCC **** /// - //recv_IF4( eNB, proc, packet_type, symbol_number); + //recv_IF4(eNB, proc, packet_type, symbol_number); } } From e38dc81c16d7c132ac5ab721b079e94e7d7f670f Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Fri, 17 Jun 2016 12:19:36 +0200 Subject: [PATCH 8/9] just testing node function --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 8 ++++---- openair1/SCHED/phy_procedures_lte_eNb.c | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 24b338f5a4..15e98c36f6 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -103,11 +103,11 @@ void send_IF4(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, uint16_t packet_type) { // Do compression of the two parts and generate data blocks - rxdataF for (element_id=0; element_id>16) + 32768 ]<<8; + //data_block[element_id] = lin2alaw[ (rxdataF[0][blockoffsetF+element_id] & 0xffff) + 32768 ]; + //data_block[element_id] |= lin2alaw[ (rxdataF[0][blockoffsetF+element_id]>>16) + 32768 ]<<8; - data_block[element_id+db_halflength] = lin2alaw[ (txdataF[0][slotoffsetF+element_id] & 0xffff) + 32768 ]; - data_block[element_id+db_halflength] |= lin2alaw[ (txdataF[0][slotoffsetF+element_id]>>16) + 32768 ]<<8; + //data_block[element_id+db_halflength] = lin2alaw[ (txdataF[0][slotoffsetF+element_id] & 0xffff) + 32768 ]; + //data_block[element_id+db_halflength] |= lin2alaw[ (txdataF[0][slotoffsetF+element_id]>>16) + 32768 ]<<8; } // Update information in generated packet diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index ae6627939c..87153a3b10 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -2607,9 +2607,11 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl symbol_mask_full = (1<symbols_per_tti)-1; prach_rx = 0; + // Block from loop while testing + symbol_mask = symbol_mask_full; do { //recv_IF4(eNB, proc, &packet_type, &symbol_number); - + if (packet_type == IF4_PULFFT) { symbol_mask = symbol_mask | (1< Date: Fri, 17 Jun 2016 15:39:24 +0200 Subject: [PATCH 9/9] add vcd logging for send, recv if4 and delay for testing without recv --- openair1/PHY/LTE_TRANSPORT/prach.c | 7 +++++-- openair1/SCHED/phy_procedures_lte_eNb.c | 19 +++++++++++++++++-- openair2/UTIL/LOG/vcd_signal_dumper.c | 6 +++++- openair2/UTIL/LOG/vcd_signal_dumper.h | 5 +++++ targets/RT/USER/lte-enb.c | 12 +++++++++--- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index 555685b23e..85330b5a18 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -1269,7 +1269,11 @@ void rx_prach(PHY_VARS_eNB *eNB, } if (eNB->node_function == NGFI_RRU_IF4) { - /// **** send_IF4 of prachF to RCC **** /// + /// **** send_IF4 of prachF to RCC **** /// + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 ); + // send_IF4(); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 ); + return; } @@ -1278,7 +1282,6 @@ void rx_prach(PHY_VARS_eNB *eNB, // wait for prachF from RRU and continue with PRACH processing //} - // here onwards is for eNodeB_3GPP or NGFI_RCC_IF4 preamble_offset_old = 99; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 87153a3b10..92392070af 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -61,6 +61,8 @@ #include "assertions.h" #include "msc.h" +#include + #if defined(ENABLE_ITTI) # include "intertask_interface.h" #endif @@ -2488,7 +2490,11 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl uint16_t packet_type; uint32_t symbol_number; uint32_t symbol_mask, symbol_mask_full; - + + struct timespec time_req, time_rem; + time_req.tv_sec = 0; + time_req.tv_nsec = 300000; + if (subframe==9) { subframe=0; frame++; @@ -2564,6 +2570,11 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl if (eNB->node_function == NGFI_RRU_IF4 && is_prach_subframe(fp, frame, subframe)<=0) { /// **** send_IF4 of rxdataF to RCC (no prach now) **** /// + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 ); + // send_IF4(); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 ); + } /// **** send_IF4 of prach to RCC **** /// done in prach thread (below) @@ -2608,9 +2619,13 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl prach_rx = 0; // Block from loop while testing - symbol_mask = symbol_mask_full; + symbol_mask = symbol_mask_full; + nanosleep(&time_req, &time_rem); + do { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 ); //recv_IF4(eNB, proc, &packet_type, &symbol_number); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 0 ); if (packet_type == IF4_PULFFT) { symbol_mask = symbol_mask | (1<CC_id], proc); + /// **** send_IF4 of txdataF to RRU **** /// + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 ); + //send_IF4(PHY_vars_eNB_g[0][proc->CC_id], proc, 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 ); }