From 6da3f494f4daaf0696a929746807e6768164122f Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Fri, 5 Aug 2016 15:26:36 +0200 Subject: [PATCH 01/14] update nettle to new interface, update deadline scheduler option (doesnt compile without this), update build/install script to use regular nettle and gnutls in ubuntu 16.04 (should also be fine with 14.04 up-to-date), update init_exmimo2 for ubuntu 16.04) --- cmake_targets/tools/build_helper | 11 ++++++++--- cmake_targets/tools/init_exmimo2 | 8 -------- openair2/UTIL/OSA/osa_stream_eea.c | 2 +- openair3/SECU/nas_stream_eea2.c | 2 +- openair3/TEST/test_aes128_ctr_decrypt.c | 2 +- targets/RT/USER/lte-enb.c | 18 ++++++++++-------- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 4738acb7f3..8dbdd33823 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -386,9 +386,14 @@ check_install_oai_software() { $SUDO update-alternatives --set liblapack.so /usr/lib/atlas-base/atlas/liblapack.so # First we remove gnutls/nettle installation and then install from sources - $SUDO apt-get remove -y libgnutls-dev nettle-dev nettle-bin - install_nettle_from_source - install_gnutls_from_source + v=$(lsb_release -ris | tr -d '\n') + if [ "$v" == Ubuntu16.04 ] ; then + $SUDO apt-get install libgnutls-dev nettle-dev nettle-bin + else + $SUDO apt-get remove -y libgnutls-dev nettle-dev nettle-bin + install_nettle_from_source + install_gnutls_from_source + fi install_asn1c_from_source } diff --git a/cmake_targets/tools/init_exmimo2 b/cmake_targets/tools/init_exmimo2 index 66eedf93dd..363e42ea25 100755 --- a/cmake_targets/tools/init_exmimo2 +++ b/cmake_targets/tools/init_exmimo2 @@ -71,15 +71,7 @@ if [ ! -e /dev/openair0 ]; then sudo chmod a+rw /dev/openair0 fi -DEVICE=`echo $PCI | awk -F\" '{print $(NF-1)}' | awk '{print $2}'` -DEVICE_SWID=${DEVICE:2:2} -if [ $DEVICE_SWID == '0a' ]; then - echo "Using firware version 10" $OPENAIR_DIR/targets/bin/updatefw -s 0x43fffff0 -b -f $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT/sdr_expressmimo2_v10 -else - echo 'No corresponding firmware found' - return -fi } main "$@" diff --git a/openair2/UTIL/OSA/osa_stream_eea.c b/openair2/UTIL/OSA/osa_stream_eea.c index 8e346631ec..acd341232e 100644 --- a/openair2/UTIL/OSA/osa_stream_eea.c +++ b/openair2/UTIL/OSA/osa_stream_eea.c @@ -199,7 +199,7 @@ int stream_encrypt_eea2(stream_cipher_t *stream_cipher, uint8_t **out) } #endif - nettle_aes128.set_encrypt_key(ctx, stream_cipher->key_length, + nettle_aes128.set_encrypt_key(ctx, stream_cipher->key); nettle_ctr_crypt(ctx, nettle_aes128.encrypt, diff --git a/openair3/SECU/nas_stream_eea2.c b/openair3/SECU/nas_stream_eea2.c index 25ef340f4e..799aaaf432 100644 --- a/openair3/SECU/nas_stream_eea2.c +++ b/openair3/SECU/nas_stream_eea2.c @@ -85,7 +85,7 @@ int nas_stream_encrypt_eea2(nas_stream_cipher_t *stream_cipher, uint8_t *out) } #endif - nettle_aes128.set_encrypt_key(ctx, stream_cipher->key_length, + nettle_aes128.set_encrypt_key(ctx, stream_cipher->key); nettle_ctr_crypt(ctx, nettle_aes128.encrypt, diff --git a/openair3/TEST/test_aes128_ctr_decrypt.c b/openair3/TEST/test_aes128_ctr_decrypt.c index f3740b48ff..251f80fa70 100644 --- a/openair3/TEST/test_aes128_ctr_decrypt.c +++ b/openair3/TEST/test_aes128_ctr_decrypt.c @@ -48,7 +48,7 @@ void test_uncipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key, uint8_t *data = malloc(length); uint8_t *ctr = malloc(cipher->block_size); - cipher->set_encrypt_key(ctx, key_length, key); + cipher->set_encrypt_key(ctx, key); memcpy(ctr, ictr, cipher->block_size); ctr_crypt(ctx, cipher->encrypt, diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 7381e37bff..ae781092f0 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -157,6 +157,8 @@ static struct { volatile uint8_t phy_proc_CC_id; } sync_phy_proc; +extern double cpuf; + void exit_fun(const char* s); void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst,eth_params_t *); @@ -432,6 +434,10 @@ static void* eNB_thread_rxtx( void* param ) { MSC_START_USE(); + struct timespec wait; + + wait.tv_sec=0; + wait.tv_nsec=5000000L; #ifdef DEADLINE_SCHEDULER struct sched_attr attr; @@ -462,10 +468,6 @@ static void* eNB_thread_rxtx( void* param ) { struct sched_param sparam; char cpu_affinity[1024]; cpu_set_t cpuset; - struct timespec wait; - - wait.tv_sec=0; - wait.tv_nsec=5000000L; /* Set affinity mask to include CPUs 1 to MAX_CPUS */ /* CPU 0 is reserved for UHD threads */ @@ -819,7 +821,7 @@ static void* eNB_thread_asynch_rxtx( void* param ) { if (sched_setattr(0, &attr, flags) < 0 ) { perror("[SCHED] eNB FH sched_setattr failed\n"); - return &eNB_thread_FH_status; + return &eNB_thread_asynch_rxtx_status; } LOG_I( HW, "[SCHED] eNB asynch RX deadline thread (TID %ld) started on CPU %d\n", gettid(), sched_getcpu() ); @@ -1403,7 +1405,7 @@ static void* eNB_thread_FH( void* param ) { #ifdef DEADLINE_SCHEDULER 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); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, (softmodem_stats_rxtx_sf.diff_now/cpuf - attr.sched_runtime)/1000000.0); } } #endif // DEADLINE_SCHEDULER @@ -1664,8 +1666,8 @@ void init_eNB_proc(int inst) { (eNB->node_function == NGFI_RRU_IF4p5)) pthread_create( &proc->pthread_asynch_rxtx, &proc->attr_asynch_rxtx, eNB_thread_asynch_rxtx, &eNB->proc ); #else - pthread_create( &proc_rxtx[0].pthread_rxtx, NULL, eNB_thread_rxtx, &eNB->proc_rxtx[0] ); - pthread_create( &proc_rxtx[1].pthread_rxtx, NULL, eNB_thread_rxtx, &eNB->proc_rxtx[1] ); + pthread_create( &proc_rxtx[0].pthread_rxtx, NULL, eNB_thread_rxtx, &proc_rxtx[0] ); + pthread_create( &proc_rxtx[1].pthread_rxtx, NULL, eNB_thread_rxtx, &proc_rxtx[1] ); pthread_create( &proc->pthread_FH, NULL, eNB_thread_FH, &eNB->proc ); pthread_create( &proc->pthread_prach, NULL, eNB_thread_prach, &eNB->proc ); if (eNB->node_timing == synch_to_other) From e1aed5af9aecab110c4b558fd1e113f15609bd61 Mon Sep 17 00:00:00 2001 From: Laurent Thomas Date: Tue, 16 Aug 2016 08:42:35 +0200 Subject: [PATCH 02/14] fix nettle, gnutls to use latest API version, fix eth_raw interface with errno==EAGAIN --- cmake_targets/tools/build_helper | 61 -- targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c | 1 + .../ETHERNET/USERSPACE/LIB/ethernet_lib.c | 744 +++++++++--------- 3 files changed, 373 insertions(+), 433 deletions(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 8dbdd33823..19ebe9e30f 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -172,57 +172,6 @@ compilations() { # External packages installers ############################################ -install_nettle_from_source() { - nettle_install_log=$OPENAIR_DIR/cmake_targets/log/nettle_install_log.txt - echo_info "\nInstalling Nettle. The log file for nettle installation is here: $nettle_install_log " - ( - cd /tmp - echo "Downloading nettle archive" - $SUDO rm -rf /tmp/nettle-2.5.tar.gz* /tmp/nettle-2.5 - wget https://ftp.gnu.org/gnu/nettle/nettle-2.5.tar.gz - if [ $? -ne 0 ]; then - wget ftp://ftp.lysator.liu.se/pub/security/lsh/nettle-2.5.tar.gz - fi - if [ ! -f nettle-2.5.tar.gz ]; then - echo_error "Could not download nettle source files" - cd - - return - fi - tar -xzf nettle-2.5.tar.gz - cd nettle-2.5/ - ./configure --disable-openssl --enable-shared --prefix=/usr - echo "Compiling nettle" - make -j`nproc` - make check - $SUDO make install - ) >& $nettle_install_log -} - -install_gnutls_from_source(){ - gnutls_install_log=$OPENAIR_DIR/cmake_targets/log/gnutls_install_log.txt - echo_info "\nInstalling Gnutls. The log file for Gnutls installation is here: $gnutls_install_log " - ( - cd /tmp - echo "Downloading gnutls archive" - $SUDO rm -rf /tmp/gnutls-3.1.23.tar.xz* /tmp/gnutls-3.1.23 - wget http://mirrors.dotsrc.org/gcrypt/gnutls/v3.1/gnutls-3.1.23.tar.xz || \ - wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-3.1.23.tar.xz - if [ ! -f gnutls-3.1.23.tar.xz ]; then - echo_error "Could not download gnutls source files" - cd - - return - fi - tar -xJf gnutls-3.1.23.tar.xz - cd gnutls-3.1.23/ - ./configure --prefix=/usr - echo "Compiling gnutls" - make -j`nproc` - $SUDO make install - )>& $gnutls_install_log -} - - - check_install_usrp_uhd_driver(){ #first we remove old installation $SUDO apt-get remove -y uhd || true @@ -384,17 +333,7 @@ check_install_oai_software() { wget $SUDO update-alternatives --set liblapack.so /usr/lib/atlas-base/atlas/liblapack.so - - # First we remove gnutls/nettle installation and then install from sources - v=$(lsb_release -ris | tr -d '\n') - if [ "$v" == Ubuntu16.04 ] ; then $SUDO apt-get install libgnutls-dev nettle-dev nettle-bin - else - $SUDO apt-get remove -y libgnutls-dev nettle-dev nettle-bin - install_nettle_from_source - install_gnutls_from_source - fi - install_asn1c_from_source } diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c index 126030d3d4..5de8c9a4f3 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c @@ -271,6 +271,7 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi if (bytes_received ==-1) { eth->num_rx_errors++; perror("ETHERNET IF5 READ: "); + if (errno == EAGAIN) continue; exit(-1); } else { /* store the timestamp value from packet's header */ diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c index 6079781ba1..d2bc98d776 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c @@ -26,7 +26,7 @@ Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE *******************************************************************************/ -/*! \file ethernet_lib.c +/*! \file ethernet_lib.c * \brief API to stream I/Q samples over standard ethernet * \author add alcatel Katerina Trilyraki, Navid Nikaein, Pedro Dinis, Lucio Ferreira, Raymond Knopp * \date 2015 @@ -34,7 +34,7 @@ * \company Eurecom * \maintainer: navid.nikaein@eurecom.fr * \note - * \warning + * \warning */ #include @@ -59,366 +59,366 @@ int dest_addr_len[MAX_INST]; int trx_eth_start(openair0_device *device) { - eth_state_t *eth = (eth_state_t*)device->priv; - - /* initialize socket */ - if (eth->flags == ETH_RAW_MODE) { - printf("Setting ETHERNET to ETH_RAW_IF5_MODE\n"); - if (eth_socket_init_raw(device)!=0) return -1; - /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/ - if (device->host_type == BBU_HOST) { - if(eth_set_dev_conf_raw(device)!=0) return -1; - } else { - if(eth_get_dev_conf_raw(device)!=0) return -1; - } - /* adjust MTU wrt number of samples per packet */ - if(ethernet_tune (device,MTU_SIZE,RAW_PACKET_SIZE_BYTES(device->openair0_cfg->samples_per_packet))!=0) return -1; - if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1; - } else if (eth->flags == ETH_RAW_IF4p5_MODE) { + eth_state_t *eth = (eth_state_t*)device->priv; - printf("Setting ETHERNET to ETH_RAW_IF4p5_MODE\n"); - if (eth_socket_init_raw(device)!=0) return -1; - /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/ - if (device->host_type == BBU_HOST) { - if(eth_set_dev_conf_raw_IF4p5(device)!=0) return -1; - } else { - if(eth_get_dev_conf_raw_IF4p5(device)!=0) return -1; - } - /* adjust MTU wrt number of samples per packet */ - if(ethernet_tune (device,MTU_SIZE,RAW_IF4p5_PRACH_SIZE_BYTES)!=0) return -1; + /* initialize socket */ + if (eth->flags == ETH_RAW_MODE) { + printf("Setting ETHERNET to ETH_RAW_IF5_MODE\n"); + if (eth_socket_init_raw(device)!=0) return -1; + /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/ + if (device->host_type == BBU_HOST) { + if(eth_set_dev_conf_raw(device)!=0) return -1; + } else { + if(eth_get_dev_conf_raw(device)!=0) return -1; + } + /* adjust MTU wrt number of samples per packet */ + if(ethernet_tune (device,MTU_SIZE,RAW_PACKET_SIZE_BYTES(device->openair0_cfg->samples_per_packet))!=0) return -1; + if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1; + } else if (eth->flags == ETH_RAW_IF4p5_MODE) { - if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1; - } else if (eth->flags == ETH_UDP_IF4p5_MODE) { - printf("Setting ETHERNET to UDP_IF4p5_MODE\n"); - if (eth_socket_init_udp(device)!=0) return -1; - if (device->host_type == BBU_HOST) { - if(eth_set_dev_conf_udp(device)!=0) return -1; + printf("Setting ETHERNET to ETH_RAW_IF4p5_MODE\n"); + if (eth_socket_init_raw(device)!=0) return -1; + /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/ + if (device->host_type == BBU_HOST) { + if(eth_set_dev_conf_raw_IF4p5(device)!=0) return -1; + } else { + if(eth_get_dev_conf_raw_IF4p5(device)!=0) return -1; + } + /* adjust MTU wrt number of samples per packet */ + if(ethernet_tune (device,MTU_SIZE,RAW_IF4p5_PRACH_SIZE_BYTES)!=0) return -1; + + if(ethernet_tune (device,RCV_TIMEOUT,999999)!=0) return -1; + } else if (eth->flags == ETH_UDP_IF4p5_MODE) { + printf("Setting ETHERNET to UDP_IF4p5_MODE\n"); + if (eth_socket_init_udp(device)!=0) return -1; + if (device->host_type == BBU_HOST) { + if(eth_set_dev_conf_udp(device)!=0) return -1; + } else { + if(eth_get_dev_conf_udp(device)!=0) return -1; + } + } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) { + printf("Setting ETHERNET to RAW_IF5_MODE\n"); + if (eth_socket_init_raw(device)!=0) return -1; } else { - if(eth_get_dev_conf_udp(device)!=0) return -1; + if (eth_socket_init_udp(device)!=0) return -1; + /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/ + if (device->host_type == BBU_HOST) { + if(eth_set_dev_conf_udp(device)!=0) return -1; + } else { + if(eth_get_dev_conf_udp(device)!=0) return -1; + } } - } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) { - printf("Setting ETHERNET to RAW_IF5_MODE\n"); - if (eth_socket_init_raw(device)!=0) return -1; - } else { - if (eth_socket_init_udp(device)!=0) return -1; - /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/ - if (device->host_type == BBU_HOST) { - if(eth_set_dev_conf_udp(device)!=0) return -1; - } else { - if(eth_get_dev_conf_udp(device)!=0) return -1; - } - } - /* apply additional configuration */ - if(ethernet_tune (device, SND_BUF_SIZE,2000000000)!=0) return -1; - if(ethernet_tune (device, RCV_BUF_SIZE,2000000000)!=0) return -1; - - return 0; + /* apply additional configuration */ + if(ethernet_tune (device, SND_BUF_SIZE,2000000000)!=0) return -1; + if(ethernet_tune (device, RCV_BUF_SIZE,2000000000)!=0) return -1; + + return 0; } void trx_eth_end(openair0_device *device) { - eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; - /* destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */ - if ( close(eth->sockfd[Mod_id]) <0 ) { - perror("ETHERNET: Failed to close socket"); - exit(0); - } else { - printf("[%s] socket for mod_id %d has been successfully closed.\n",(device->host_type == BBU_HOST)? "BBU":"RRH",Mod_id); - } - + eth_state_t *eth = (eth_state_t*)device->priv; + int Mod_id = device->Mod_id; + /* destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */ + if ( close(eth->sockfd[Mod_id]) <0 ) { + perror("ETHERNET: Failed to close socket"); + exit(0); + } else { + printf("[%s] socket for mod_id %d has been successfully closed.\n",(device->host_type == BBU_HOST)? "BBU":"RRH",Mod_id); + } + } int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) { - int Mod_id = device->Mod_id; - eth_state_t *eth = (eth_state_t*)device->priv; - - /* BBU sends a message to RRH */ - if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],dest_addr_len[Mod_id])==-1) { - perror("ETHERNET: "); - exit(0); - } - - return 0; + int Mod_id = device->Mod_id; + eth_state_t *eth = (eth_state_t*)device->priv; + + /* BBU sends a message to RRH */ + if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&dest_addr[Mod_id],dest_addr_len[Mod_id])==-1) { + perror("ETHERNET: "); + exit(0); + } + + return 0; } int trx_eth_reply(openair0_device *device, void *msg, ssize_t msg_len) { - eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id = device->Mod_id; + eth_state_t *eth = (eth_state_t*)device->priv; + int Mod_id = device->Mod_id; - /* RRH receives from BBU a message */ - if (recvfrom(eth->sockfd[Mod_id], - msg, - msg_len, - 0, - (struct sockaddr *)&dest_addr[Mod_id], - (socklen_t *)&dest_addr_len[Mod_id])==-1) { - perror("ETHERNET: "); - exit(0); - } - - return 0; + /* RRH receives from BBU a message */ + if (recvfrom(eth->sockfd[Mod_id], + msg, + msg_len, + 0, + (struct sockaddr *)&dest_addr[Mod_id], + (socklen_t *)&dest_addr_len[Mod_id])==-1) { + perror("ETHERNET: "); + exit(0); + } + + return 0; } int trx_eth_stop(openair0_device *device) { - return(0); + return(0); } int trx_eth_set_freq(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config) { - return(0); + return(0); } int trx_eth_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) { - return(0); + return(0); } int trx_eth_get_stats(openair0_device* device) { - return(0); + return(0); } int trx_eth_reset_stats(openair0_device* device) { - return(0); + return(0); } int ethernet_tune(openair0_device *device, unsigned int option, int value) { - - eth_state_t *eth = (eth_state_t*)device->priv; - int Mod_id=device->Mod_id; - struct timeval timeout; - struct ifreq ifr; - char system_cmd[256]; - // char* if_name=DEFAULT_IF; - // struct in_addr ia; - // struct if_nameindex *ids; - int ret=0; - // int i=0; - - /****************** socket level options ************************/ - switch(option) { - case SND_BUF_SIZE: /* transmit socket buffer size */ - if (setsockopt(eth->sockfd[Mod_id], - SOL_SOCKET, - SO_SNDBUF, - &value,sizeof(value))) { - perror("[ETHERNET] setsockopt()"); - } else { - printf("send buffer size= %d bytes\n",value); - } - break; - - case RCV_BUF_SIZE: /* receive socket buffer size */ - if (setsockopt(eth->sockfd[Mod_id], - SOL_SOCKET, - SO_RCVBUF, - &value,sizeof(value))) { - perror("[ETHERNET] setsockopt()"); - } else { - printf("receive bufffer size= %d bytes\n",value); - } - break; - - case RCV_TIMEOUT: - timeout.tv_sec = value/1000000; - timeout.tv_usec = value%1000000;//less than rt_period? - if (setsockopt(eth->sockfd[Mod_id], - SOL_SOCKET, - SO_RCVTIMEO, - (char *)&timeout,sizeof(timeout))) { - perror("[ETHERNET] setsockopt()"); - } else { - printf( "receive timeout= %u usec\n",(unsigned int)timeout.tv_usec); - } - break; - - case SND_TIMEOUT: - timeout.tv_sec = value/1000000000; - timeout.tv_usec = value%1000000000;//less than rt_period? - if (setsockopt(eth->sockfd[Mod_id], - SOL_SOCKET, - SO_SNDTIMEO, - (char *)&timeout,sizeof(timeout))) { - perror("[ETHERNET] setsockopt()"); - } else { - printf( "send timeout= %d,%d sec\n",(int)timeout.tv_sec,(int)timeout.tv_usec); - } - break; - - + + eth_state_t *eth = (eth_state_t*)device->priv; + int Mod_id=device->Mod_id; + struct timeval timeout; + struct ifreq ifr; + char system_cmd[256]; + // char* if_name=DEFAULT_IF; + // struct in_addr ia; + // struct if_nameindex *ids; + int ret=0; + // int i=0; + + /****************** socket level options ************************/ + switch(option) { + case SND_BUF_SIZE: /* transmit socket buffer size */ + if (setsockopt(eth->sockfd[Mod_id], + SOL_SOCKET, + SO_SNDBUF, + &value,sizeof(value))) { + perror("[ETHERNET] setsockopt()"); + } else { + printf("send buffer size= %d bytes\n",value); + } + break; + + case RCV_BUF_SIZE: /* receive socket buffer size */ + if (setsockopt(eth->sockfd[Mod_id], + SOL_SOCKET, + SO_RCVBUF, + &value,sizeof(value))) { + perror("[ETHERNET] setsockopt()"); + } else { + printf("receive bufffer size= %d bytes\n",value); + } + break; + + case RCV_TIMEOUT: + timeout.tv_sec = value/1000000; + timeout.tv_usec = value%1000000;//less than rt_period? + if (setsockopt(eth->sockfd[Mod_id], + SOL_SOCKET, + SO_RCVTIMEO, + (char *)&timeout,sizeof(timeout))) { + perror("[ETHERNET] setsockopt()"); + } else { + printf( "receive timeout= %u usec\n",(unsigned int)timeout.tv_usec); + } + break; + + case SND_TIMEOUT: + timeout.tv_sec = value/1000000000; + timeout.tv_usec = value%1000000000;//less than rt_period? + if (setsockopt(eth->sockfd[Mod_id], + SOL_SOCKET, + SO_SNDTIMEO, + (char *)&timeout,sizeof(timeout))) { + perror("[ETHERNET] setsockopt()"); + } else { + printf( "send timeout= %d,%d sec\n",(int)timeout.tv_sec,(int)timeout.tv_usec); + } + break; + + /******************* interface level options *************************/ - case MTU_SIZE: /* change MTU of the eth interface */ - ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name)); - ifr.ifr_mtu =value; - if (ioctl(eth->sockfd[Mod_id],SIOCSIFMTU,(caddr_t)&ifr) < 0 ) - perror ("[ETHERNET] Can't set the MTU"); - else - printf("[ETHERNET] %s MTU size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_mtu); - break; - - case TX_Q_LEN: /* change TX queue length of eth interface */ - ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name)); - ifr.ifr_qlen =value; - if (ioctl(eth->sockfd[Mod_id],SIOCSIFTXQLEN,(caddr_t)&ifr) < 0 ) - perror ("[ETHERNET] Can't set the txqueuelen"); - else - printf("[ETHERNET] %s txqueuelen size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_qlen); - break; - + case MTU_SIZE: /* change MTU of the eth interface */ + ifr.ifr_addr.sa_family = AF_INET; + strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name)); + ifr.ifr_mtu =value; + if (ioctl(eth->sockfd[Mod_id],SIOCSIFMTU,(caddr_t)&ifr) < 0 ) + perror ("[ETHERNET] Can't set the MTU"); + else + printf("[ETHERNET] %s MTU size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_mtu); + break; + + case TX_Q_LEN: /* change TX queue length of eth interface */ + ifr.ifr_addr.sa_family = AF_INET; + strncpy(ifr.ifr_name,eth->if_name[Mod_id], sizeof(ifr.ifr_name)); + ifr.ifr_qlen =value; + if (ioctl(eth->sockfd[Mod_id],SIOCSIFTXQLEN,(caddr_t)&ifr) < 0 ) + perror ("[ETHERNET] Can't set the txqueuelen"); + else + printf("[ETHERNET] %s txqueuelen size has changed to %d\n",eth->if_name[Mod_id],ifr.ifr_qlen); + break; + /******************* device level options *************************/ - case COALESCE_PAR: - ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -C %s rx-usecs %d",eth->if_name[Mod_id],value); - if (ret > 0) { - ret=system(system_cmd); - if (ret == -1) { - fprintf (stderr,"[ETHERNET] Can't start shell to execute %s %s",system_cmd, strerror(errno)); - } else { - printf ("[ETHERNET] status of %s is %i\n",WEXITSTATUS(ret)); - } - printf("[ETHERNET] Coalesce parameters %s\n",system_cmd); - } else { - perror("[ETHERNET] Can't set coalesce parameters\n"); + case COALESCE_PAR: + ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -C %s rx-usecs %d",eth->if_name[Mod_id],value); + if (ret > 0) { + ret=system(system_cmd); + if (ret == -1) { + fprintf (stderr,"[ETHERNET] Can't start shell to execute %s %s",system_cmd, strerror(errno)); + } else { + printf ("[ETHERNET] status of %s is %i\n",WEXITSTATUS(ret)); + } + printf("[ETHERNET] Coalesce parameters %s\n",system_cmd); + } else { + perror("[ETHERNET] Can't set coalesce parameters\n"); + } + break; + + case PAUSE_PAR: + if (value==1) ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -A %s autoneg off rx off tx off",eth->if_name[Mod_id]); + else if (value==0) ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -A %s autoneg on rx on tx on",eth->if_name[Mod_id]); + else break; + if (ret > 0) { + ret=system(system_cmd); + if (ret == -1) { + fprintf (stderr,"[ETHERNET] Can't start shell to execute %s %s",system_cmd, strerror(errno)); + } else { + printf ("[ETHERNET] status of %s is %i\n",WEXITSTATUS(ret)); + } + printf("[ETHERNET] Pause parameters %s\n",system_cmd); + } else { + perror("[ETHERNET] Can't set pause parameters\n"); + } + break; + + case RING_PAR: + ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -G %s val %d",eth->if_name[Mod_id],value); + if (ret > 0) { + ret=system(system_cmd); + if (ret == -1) { + fprintf (stderr,"[ETHERNET] Can't start shell to execute %s %s",system_cmd, strerror(errno)); + } else { + printf ("[ETHERNET] status of %s is %i\n",WEXITSTATUS(ret)); + } + printf("[ETHERNET] Ring parameters %s\n",system_cmd); + } else { + perror("[ETHERNET] Can't set ring parameters\n"); + } + break; + + default: + break; } - break; - - case PAUSE_PAR: - if (value==1) ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -A %s autoneg off rx off tx off",eth->if_name[Mod_id]); - else if (value==0) ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -A %s autoneg on rx on tx on",eth->if_name[Mod_id]); - else break; - if (ret > 0) { - ret=system(system_cmd); - if (ret == -1) { - fprintf (stderr,"[ETHERNET] Can't start shell to execute %s %s",system_cmd, strerror(errno)); - } else { - printf ("[ETHERNET] status of %s is %i\n",WEXITSTATUS(ret)); - } - printf("[ETHERNET] Pause parameters %s\n",system_cmd); - } else { - perror("[ETHERNET] Can't set pause parameters\n"); - } - break; - - case RING_PAR: - ret=snprintf(system_cmd,sizeof(system_cmd),"ethtool -G %s val %d",eth->if_name[Mod_id],value); - if (ret > 0) { - ret=system(system_cmd); - if (ret == -1) { - fprintf (stderr,"[ETHERNET] Can't start shell to execute %s %s",system_cmd, strerror(errno)); - } else { - printf ("[ETHERNET] status of %s is %i\n",WEXITSTATUS(ret)); - } - printf("[ETHERNET] Ring parameters %s\n",system_cmd); - } else { - perror("[ETHERNET] Can't set ring parameters\n"); - } - break; - - default: - break; - } - - return 0; + + return 0; } int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * eth_params ) { - eth_state_t *eth = (eth_state_t*)malloc(sizeof(eth_state_t)); - memset(eth, 0, sizeof(eth_state_t)); + eth_state_t *eth = (eth_state_t*)malloc(sizeof(eth_state_t)); + memset(eth, 0, sizeof(eth_state_t)); - if (eth_params->transp_preference == 1) { - eth->flags = ETH_RAW_MODE; - } else if (eth_params->transp_preference == 0) { - eth->flags = ETH_UDP_MODE; - } else if (eth_params->transp_preference == 3) { - eth->flags = ETH_RAW_IF4p5_MODE; - } else if (eth_params->transp_preference == 2) { - eth->flags = ETH_UDP_IF4p5_MODE; - } else if (eth_params->transp_preference == 4) { - eth->flags = ETH_RAW_IF5_MOBIPASS; - } else { - printf("transport_init: Unknown transport preference %d - default to RAW", eth_params->transp_preference); - eth->flags = ETH_RAW_MODE; - } - - printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == BBU_HOST) ? "BBU": "RRH")); - device->Mod_id = num_devices_eth++; - device->transp_type = ETHERNET_TP; - device->trx_start_func = trx_eth_start; - device->trx_request_func = trx_eth_request; - device->trx_reply_func = trx_eth_reply; - device->trx_get_stats_func = trx_eth_get_stats; - device->trx_reset_stats_func = trx_eth_reset_stats; - device->trx_end_func = trx_eth_end; - device->trx_stop_func = trx_eth_stop; - device->trx_set_freq_func = trx_eth_set_freq; - device->trx_set_gains_func = trx_eth_set_gains; - - if (eth->flags == ETH_RAW_MODE) { - device->trx_write_func = trx_eth_write_raw; - device->trx_read_func = trx_eth_read_raw; - } else if (eth->flags == ETH_UDP_MODE) { - device->trx_write_func = trx_eth_write_udp; - device->trx_read_func = trx_eth_read_udp; - } else if (eth->flags == ETH_RAW_IF4p5_MODE) { - device->trx_write_func = trx_eth_write_raw_IF4p5; - device->trx_read_func = trx_eth_read_raw_IF4p5; - } else if (eth->flags == ETH_UDP_IF4p5_MODE) { - device->trx_write_func = trx_eth_write_udp_IF4p5; - device->trx_read_func = trx_eth_read_udp_IF4p5; - } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) { - device->trx_write_func = trx_eth_write_raw_IF4p5; - device->trx_read_func = trx_eth_read_raw_IF4p5; - } else { - //device->trx_write_func = trx_eth_write_udp_IF4p5; - //device->trx_read_func = trx_eth_read_udp_IF4p5; - } - - eth->if_name[device->Mod_id] = eth_params->local_if_name; - device->priv = eth; - - /* device specific */ - openair0_cfg[0].iq_rxrescale = 15;//rescale iqs - openair0_cfg[0].iq_txshift = eth_params->iq_txshift;// shift - openair0_cfg[0].tx_sample_advance = eth_params->tx_sample_advance; - - /* RRH does not have any information to make this configuration atm */ - if (device->host_type == BBU_HOST) { - /*Note scheduling advance values valid only for case 7680000 */ - switch ((int)openair0_cfg[0].sample_rate) { - case 30720000: - openair0_cfg[0].samples_per_packet = 3840; - break; - case 23040000: - openair0_cfg[0].samples_per_packet = 2880; - break; - case 15360000: - openair0_cfg[0].samples_per_packet = 1920; - break; - case 7680000: - openair0_cfg[0].samples_per_packet = 960; - break; - case 1920000: - openair0_cfg[0].samples_per_packet = 240; - break; - default: - printf("Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate); - exit(-1); - break; + if (eth_params->transp_preference == 1) { + eth->flags = ETH_RAW_MODE; + } else if (eth_params->transp_preference == 0) { + eth->flags = ETH_UDP_MODE; + } else if (eth_params->transp_preference == 3) { + eth->flags = ETH_RAW_IF4p5_MODE; + } else if (eth_params->transp_preference == 2) { + eth->flags = ETH_UDP_IF4p5_MODE; + } else if (eth_params->transp_preference == 4) { + eth->flags = ETH_RAW_IF5_MOBIPASS; + } else { + printf("transport_init: Unknown transport preference %d - default to RAW", eth_params->transp_preference); + eth->flags = ETH_RAW_MODE; } - } - - device->openair0_cfg=&openair0_cfg[0]; - return 0; + + printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == BBU_HOST) ? "BBU": "RRH")); + device->Mod_id = num_devices_eth++; + device->transp_type = ETHERNET_TP; + device->trx_start_func = trx_eth_start; + device->trx_request_func = trx_eth_request; + device->trx_reply_func = trx_eth_reply; + device->trx_get_stats_func = trx_eth_get_stats; + device->trx_reset_stats_func = trx_eth_reset_stats; + device->trx_end_func = trx_eth_end; + device->trx_stop_func = trx_eth_stop; + device->trx_set_freq_func = trx_eth_set_freq; + device->trx_set_gains_func = trx_eth_set_gains; + + if (eth->flags == ETH_RAW_MODE) { + device->trx_write_func = trx_eth_write_raw; + device->trx_read_func = trx_eth_read_raw; + } else if (eth->flags == ETH_UDP_MODE) { + device->trx_write_func = trx_eth_write_udp; + device->trx_read_func = trx_eth_read_udp; + } else if (eth->flags == ETH_RAW_IF4p5_MODE) { + device->trx_write_func = trx_eth_write_raw_IF4p5; + device->trx_read_func = trx_eth_read_raw_IF4p5; + } else if (eth->flags == ETH_UDP_IF4p5_MODE) { + device->trx_write_func = trx_eth_write_udp_IF4p5; + device->trx_read_func = trx_eth_read_udp_IF4p5; + } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) { + device->trx_write_func = trx_eth_write_raw_IF4p5; + device->trx_read_func = trx_eth_read_raw_IF4p5; + } else { + //device->trx_write_func = trx_eth_write_udp_IF4p5; + //device->trx_read_func = trx_eth_read_udp_IF4p5; + } + + eth->if_name[device->Mod_id] = eth_params->local_if_name; + device->priv = eth; + + /* device specific */ + openair0_cfg[0].iq_rxrescale = 15;//rescale iqs + openair0_cfg[0].iq_txshift = eth_params->iq_txshift;// shift + openair0_cfg[0].tx_sample_advance = eth_params->tx_sample_advance; + + /* RRH does not have any information to make this configuration atm */ + if (device->host_type == BBU_HOST) { + /*Note scheduling advance values valid only for case 7680000 */ + switch ((int)openair0_cfg[0].sample_rate) { + case 30720000: + openair0_cfg[0].samples_per_packet = 3840; + break; + case 23040000: + openair0_cfg[0].samples_per_packet = 2880; + break; + case 15360000: + openair0_cfg[0].samples_per_packet = 1920; + break; + case 7680000: + openair0_cfg[0].samples_per_packet = 960; + break; + case 1920000: + openair0_cfg[0].samples_per_packet = 240; + break; + default: + printf("Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate); + exit(-1); + break; + } + } + + device->openair0_cfg=&openair0_cfg[0]; + return 0; } @@ -426,85 +426,85 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth * DEBUGING-RELATED FUNCTIONS * **************************************************************************************************************************/ void dump_packet(char *title, unsigned char* pkt, int bytes, unsigned int tx_rx_flag) { - - static int numSend = 1; - static int numRecv = 1; - int num, k; - char tmp[48]; - unsigned short int cksum; - - num = (tx_rx_flag)? numSend++:numRecv++; - for (k = 0; k < 24; k++) sprintf(tmp+k, "%02X", pkt[k]); - cksum = calc_csum((unsigned short *)pkt, bytes>>2); - printf("%s-%s (%06d): %s 0x%04X\n", title,(tx_rx_flag)? "TX":"RX", num, tmp, cksum); + + static int numSend = 1; + static int numRecv = 1; + int num, k; + char tmp[48]; + unsigned short int cksum; + + num = (tx_rx_flag)? numSend++:numRecv++; + for (k = 0; k < 24; k++) sprintf(tmp+k, "%02X", pkt[k]); + cksum = calc_csum((unsigned short *)pkt, bytes>>2); + printf("%s-%s (%06d): %s 0x%04X\n", title,(tx_rx_flag)? "TX":"RX", num, tmp, cksum); } unsigned short calc_csum (unsigned short *buf, int nwords) { - - unsigned long sum; - for (sum = 0; nwords > 0; nwords--) - sum += *buf++; - sum = (sum >> 16) + (sum & 0xffff); - sum += (sum >> 16); - return ~sum; + + unsigned long sum; + for (sum = 0; nwords > 0; nwords--) + sum += *buf++; + sum = (sum >> 16) + (sum & 0xffff); + sum += (sum >> 16); + return ~sum; } void dump_dev(openair0_device *device) { - eth_state_t *eth = (eth_state_t*)device->priv; - - printf("Ethernet device interface %i configuration:\n" ,device->openair0_cfg->Mod_id); - printf(" Log level is %i :\n" ,device->openair0_cfg->log_level); - printf(" RB number: %i, sample rate: %lf \n" , - device->openair0_cfg->num_rb_dl, device->openair0_cfg->sample_rate); - printf(" BBU configured for %i tx/%i rx channels)\n", - device->openair0_cfg->tx_num_channels,device->openair0_cfg->rx_num_channels); - printf(" Running flags: %s %s (\n", - ((eth->flags & ETH_RAW_MODE) ? "RAW socket mode - ":""), - ((eth->flags & ETH_UDP_MODE) ? "UDP socket mode - ":"")); - printf(" Number of iqs dumped when displaying packets: %i\n\n",eth->iqdumpcnt); - + eth_state_t *eth = (eth_state_t*)device->priv; + + printf("Ethernet device interface %i configuration:\n" ,device->openair0_cfg->Mod_id); + printf(" Log level is %i :\n" ,device->openair0_cfg->log_level); + printf(" RB number: %i, sample rate: %lf \n" , + device->openair0_cfg->num_rb_dl, device->openair0_cfg->sample_rate); + printf(" BBU configured for %i tx/%i rx channels)\n", + device->openair0_cfg->tx_num_channels,device->openair0_cfg->rx_num_channels); + printf(" Running flags: %s %s (\n", + ((eth->flags & ETH_RAW_MODE) ? "RAW socket mode - ":""), + ((eth->flags & ETH_UDP_MODE) ? "UDP socket mode - ":"")); + printf(" Number of iqs dumped when displaying packets: %i\n\n",eth->iqdumpcnt); + } void inline dump_txcounters(openair0_device *device) { - eth_state_t *eth = (eth_state_t*)device->priv; - printf(" Ethernet device interface %i, tx counters:\n" ,device->openair0_cfg->Mod_id); - printf(" Sent packets: %llu send errors: %i\n", (long long unsigned int)eth->tx_count, eth->num_tx_errors); + eth_state_t *eth = (eth_state_t*)device->priv; + printf(" Ethernet device interface %i, tx counters:\n" ,device->openair0_cfg->Mod_id); + printf(" Sent packets: %llu send errors: %i\n", (long long unsigned int)eth->tx_count, eth->num_tx_errors); } void inline dump_rxcounters(openair0_device *device) { - eth_state_t *eth = (eth_state_t*)device->priv; - printf(" Ethernet device interface %i rx counters:\n" ,device->openair0_cfg->Mod_id); - printf(" Received packets: %llu missed packets errors: %i\n", (long long unsigned int)eth->rx_count, eth->num_underflows); -} + eth_state_t *eth = (eth_state_t*)device->priv; + printf(" Ethernet device interface %i rx counters:\n" ,device->openair0_cfg->Mod_id); + printf(" Received packets: %llu missed packets errors: %i\n", (long long unsigned int)eth->rx_count, eth->num_underflows); +} void inline dump_buff(openair0_device *device, char *buff,unsigned int tx_rx_flag, int nsamps) { - - char *strptr; - eth_state_t *eth = (eth_state_t*)device->priv; - /*need to add ts number of iqs in printf need to fix dump iqs call */ - strptr = (( tx_rx_flag == TX_FLAG) ? "TX" : "RX"); - printf("\n %s, nsamps=%i \n" ,strptr,nsamps); - - if (tx_rx_flag == 1) { - dump_txcounters(device); - printf(" First %i iqs of TX buffer\n",eth->iqdumpcnt); - dump_iqs(buff,eth->iqdumpcnt); - } else { - dump_rxcounters(device); - printf(" First %i iqs of RX buffer\n",eth->iqdumpcnt); - dump_iqs(buff,eth->iqdumpcnt); - } - + + char *strptr; + eth_state_t *eth = (eth_state_t*)device->priv; + /*need to add ts number of iqs in printf need to fix dump iqs call */ + strptr = (( tx_rx_flag == TX_FLAG) ? "TX" : "RX"); + printf("\n %s, nsamps=%i \n" ,strptr,nsamps); + + if (tx_rx_flag == 1) { + dump_txcounters(device); + printf(" First %i iqs of TX buffer\n",eth->iqdumpcnt); + dump_iqs(buff,eth->iqdumpcnt); + } else { + dump_rxcounters(device); + printf(" First %i iqs of RX buffer\n",eth->iqdumpcnt); + dump_iqs(buff,eth->iqdumpcnt); + } + } void dump_iqs(char * buff, int iq_cnt) { - int i; - for (i=0;i Date: Fri, 30 Sep 2016 12:32:33 +0200 Subject: [PATCH 03/14] small update --- cmake_targets/CMakeLists.txt | 2 +- openair1/PHY/defs.h | 13 ++++++++++++- openair1/PHY/extern.h | 8 +++++++- openair1/PHY/impl_defs_lte.h | 10 ++++++++-- openair2/X2AP/x2ap_common.h | 2 ++ targets/RT/USER/lte-enb.c | 8 ++++++-- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index e1396b6398..94f17872b7 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -881,7 +881,7 @@ set(UTIL_SRC ${OPENAIR2_DIR}/UTIL/OMG/job.c ${OPENAIR2_DIR}/UTIL/OMG/mobility_parser.c ${OPENAIR2_DIR}/UTIL/OMG/omg.c - ${OPENAIR2_DIR}/UTIL/OMG/omg_hashtable.c + #${OPENAIR2_DIR}/UTIL/OMG/omg_hashtable.c ${OPENAIR2_DIR}/UTIL/OMG/rwalk.c ${OPENAIR2_DIR}/UTIL/OMG/rwp.c ${OPENAIR2_DIR}/UTIL/OMG/socket_traci_OMG.c diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index abf6038543..aa398f2fdc 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -53,6 +53,11 @@ # define msg mexPrintf #else # ifdef OPENAIR2 +# if ENABLE_RAL +# include "collection/hashtable/hashtable.h" +# include "COMMON/ral_messages_types.h" +# include "UTIL/queue.h" +# endif # include "log.h" # define msg(aRGS...) LOG_D(PHY, ##aRGS) # else @@ -127,6 +132,8 @@ static inline void* malloc16_clear( size_t size ) #include "PHY/TOOLS/defs.h" #include "platform_types.h" +#ifdef OPENAIR_LTE + #include "PHY/LTE_TRANSPORT/defs.h" #include @@ -138,6 +145,9 @@ static inline void* malloc16_clear( size_t size ) #define NB_BANDS_MAX 8 +#ifdef OCP_FRAMEWORK +#include +#else typedef enum {normal_txrx=0,rx_calib_ue=1,rx_calib_ue_med=2,rx_calib_ue_byp=3,debug_prach=4,no_L2_connect=5,calib_prach_tx=6,rx_dump_frame=7,loop_through_memory=8} runmode_t; enum transmission_access_mode { @@ -161,6 +171,7 @@ typedef enum { synch_to_ext_device=0, // synch to RF or Ethernet device synch_to_other // synch to another source (timer, other CC_id) } eNB_timing_t; +#endif typedef struct UE_SCAN_INFO_s { /// 10 best amplitudes (linear) for each pss signals @@ -837,5 +848,5 @@ typedef struct { #include "PHY/LTE_ESTIMATION/defs.h" #include "SIMULATION/ETH_TRANSPORT/defs.h" - +#endif #endif // __PHY_DEFS__H__ diff --git a/openair1/PHY/extern.h b/openair1/PHY/extern.h index 8a5bf5e8f5..009057838b 100755 --- a/openair1/PHY/extern.h +++ b/openair1/PHY/extern.h @@ -47,11 +47,17 @@ extern int number_of_cards; //extern PHY_CONFIG *PHY_config; //extern PHY_VARS *PHY_vars; - +#ifndef OCP_FRAMEWORK extern PHY_VARS_UE ***PHY_vars_UE_g; extern PHY_VARS_eNB ***PHY_vars_eNB_g; extern PHY_VARS_RN **PHY_vars_RN_g; extern LTE_DL_FRAME_PARMS *lte_frame_parms_g; +#else +#define MAX_UE 10 +#define MAX_eNB 20 +extern PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]; +extern PHY_VARS_eNB * PHY_vars_eNB_g[MAX_eNB][MAX_NUM_CCs]; +#endif extern MAC_xface *mac_xface; diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index bed2057800..eed53bce09 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -62,7 +62,9 @@ #define MAX_MBSFN_AREA 8 - +#ifdef OCP_FRAMEWORK +#include "enums.h" +#else typedef enum {TDD=1,FDD=0} lte_frame_type_t; typedef enum {EXTENDED=1,NORMAL=0} lte_prefix_type_t; @@ -82,7 +84,7 @@ typedef enum { one=6, two=12 } PHICH_RESOURCE_t; - +#endif /// PHICH-Config from 36.331 RRC spec typedef struct { /// Parameter: PHICH-Duration, see TS 36.211 (Table 6.9.3-1). @@ -169,10 +171,12 @@ typedef struct { } UL_REFERENCE_SIGNALS_PUSCH_t; /// Enumeration for parameter Hopping-mode \ref PUSCH_CONFIG_COMMON::hoppingMode. +#ifndef OCP_FRAMEWORK typedef enum { interSubFrame=0, intraAndInterSubFrame=1 } PUSCH_HOPPING_t; +#endif /// PUSCH-ConfigCommon from 36.331 RRC spec. typedef struct { @@ -337,6 +341,7 @@ typedef struct { uint8_t filterCoefficient; } UL_POWER_CONTROL_DEDICATED; +#ifndef OCP_FRAMEWORK /// Enumeration for parameter \f$\alpha\f$ \ref UL_POWER_CONTROL_CONFIG_COMMON::alpha. typedef enum { al0=0, @@ -348,6 +353,7 @@ typedef enum { al09=6, al1=7 } PUSCH_alpha_t; +#endif /// \note UNUSED typedef enum { diff --git a/openair2/X2AP/x2ap_common.h b/openair2/X2AP/x2ap_common.h index 04ad77f8e3..b2f8617572 100755 --- a/openair2/X2AP/x2ap_common.h +++ b/openair2/X2AP/x2ap_common.h @@ -290,8 +290,10 @@ # define X2AP_PORT 36422 #endif +#ifndef TRUE #define TRUE 1 #define FALSE 0 +#endif extern int asn_debug; extern int asn1_xer_print; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 1023ccc04f..cf4f6e9568 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -190,10 +190,10 @@ static inline void thread_top_init(char *thread_name, if (sched_setattr(0, &attr, flags) < 0 ) { perror("[SCHED] eNB tx thread: sched_setattr failed\n"); - exit_fun("Error setting deadline scheduler"); + exit(1); } - LOG_I( HW, "[SCHED] eNB %s deadline thread (TID %ld) started on CPU %d\n", gettid(), thread_name,sched_getcpu() ); + LOG_I( HW, "[SCHED] eNB RXn-TXnp4 deadline thread (TID %ld) started on CPU %d\n", gettid(), sched_getcpu() ); #else //LOW_LATENCY int policy, s, j; @@ -1352,7 +1352,9 @@ void init_eNB_proc(int inst) { for (CC_id=0; CC_idnode_function],eNB_timing[eNB->node_timing]); +#endif proc = &eNB->proc; proc_rxtx = proc->proc_rxtx; @@ -1625,7 +1627,9 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst eNB->node_timing = node_timing[CC_id]; eNB->abstraction_flag = 0; eNB->single_thread_flag = single_thread_flag; +#ifndef OCP_FRAMEWORK LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]); +#endif switch (node_function[CC_id]) { case NGFI_RRU_IF5: From 5822c850cb6adffd839a372730b009aa7e092371 Mon Sep 17 00:00:00 2001 From: laurent Date: Fri, 30 Sep 2016 12:34:57 +0200 Subject: [PATCH 04/14] small2 --- cmake_targets/tools/build_helper | 4 ++-- openair1/PHY/defs.h | 9 +++++++++ openair1/PHY/extern.h | 8 +++++++- openair1/PHY/impl_defs_lte.h | 10 ++++++++-- openair2/X2AP/x2ap_common.h | 2 ++ targets/RT/USER/lte-enb.c | 8 ++++++-- 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 94e80e2358..9c6f846f6c 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -332,7 +332,7 @@ check_install_oai_software() { wget $SUDO update-alternatives --set liblapack.so /usr/lib/atlas-base/atlas/liblapack.so - $SUDO apt-get install libgnutls-dev nettle-dev nettle-bin + $SUDO apt-get install -y libgnutls-dev nettle-dev nettle-bin install_asn1c_from_source } @@ -342,7 +342,7 @@ install_asn1c_from_source(){ echo_info "\nInstalling ASN1. The log file for ASN1 installation is here: $asn1_install_log " ( $SUDO rm -rf /tmp/asn1c - git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c + $SUDO GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c cd /tmp/asn1c ./configure make -j`nproc` diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index abf6038543..e8eae39ad6 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -53,6 +53,11 @@ # define msg mexPrintf #else # ifdef OPENAIR2 +# if ENABLE_RAL +# include "collection/hashtable/hashtable.h" +# include "COMMON/ral_messages_types.h" +# include "UTIL/queue.h" +# endif # include "log.h" # define msg(aRGS...) LOG_D(PHY, ##aRGS) # else @@ -138,6 +143,9 @@ static inline void* malloc16_clear( size_t size ) #define NB_BANDS_MAX 8 +#ifdef OCP_FRAMEWORK +#include +#else typedef enum {normal_txrx=0,rx_calib_ue=1,rx_calib_ue_med=2,rx_calib_ue_byp=3,debug_prach=4,no_L2_connect=5,calib_prach_tx=6,rx_dump_frame=7,loop_through_memory=8} runmode_t; enum transmission_access_mode { @@ -161,6 +169,7 @@ typedef enum { synch_to_ext_device=0, // synch to RF or Ethernet device synch_to_other // synch to another source (timer, other CC_id) } eNB_timing_t; +#endif typedef struct UE_SCAN_INFO_s { /// 10 best amplitudes (linear) for each pss signals diff --git a/openair1/PHY/extern.h b/openair1/PHY/extern.h index 8a5bf5e8f5..009057838b 100755 --- a/openair1/PHY/extern.h +++ b/openair1/PHY/extern.h @@ -47,11 +47,17 @@ extern int number_of_cards; //extern PHY_CONFIG *PHY_config; //extern PHY_VARS *PHY_vars; - +#ifndef OCP_FRAMEWORK extern PHY_VARS_UE ***PHY_vars_UE_g; extern PHY_VARS_eNB ***PHY_vars_eNB_g; extern PHY_VARS_RN **PHY_vars_RN_g; extern LTE_DL_FRAME_PARMS *lte_frame_parms_g; +#else +#define MAX_UE 10 +#define MAX_eNB 20 +extern PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]; +extern PHY_VARS_eNB * PHY_vars_eNB_g[MAX_eNB][MAX_NUM_CCs]; +#endif extern MAC_xface *mac_xface; diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index bed2057800..eed53bce09 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -62,7 +62,9 @@ #define MAX_MBSFN_AREA 8 - +#ifdef OCP_FRAMEWORK +#include "enums.h" +#else typedef enum {TDD=1,FDD=0} lte_frame_type_t; typedef enum {EXTENDED=1,NORMAL=0} lte_prefix_type_t; @@ -82,7 +84,7 @@ typedef enum { one=6, two=12 } PHICH_RESOURCE_t; - +#endif /// PHICH-Config from 36.331 RRC spec typedef struct { /// Parameter: PHICH-Duration, see TS 36.211 (Table 6.9.3-1). @@ -169,10 +171,12 @@ typedef struct { } UL_REFERENCE_SIGNALS_PUSCH_t; /// Enumeration for parameter Hopping-mode \ref PUSCH_CONFIG_COMMON::hoppingMode. +#ifndef OCP_FRAMEWORK typedef enum { interSubFrame=0, intraAndInterSubFrame=1 } PUSCH_HOPPING_t; +#endif /// PUSCH-ConfigCommon from 36.331 RRC spec. typedef struct { @@ -337,6 +341,7 @@ typedef struct { uint8_t filterCoefficient; } UL_POWER_CONTROL_DEDICATED; +#ifndef OCP_FRAMEWORK /// Enumeration for parameter \f$\alpha\f$ \ref UL_POWER_CONTROL_CONFIG_COMMON::alpha. typedef enum { al0=0, @@ -348,6 +353,7 @@ typedef enum { al09=6, al1=7 } PUSCH_alpha_t; +#endif /// \note UNUSED typedef enum { diff --git a/openair2/X2AP/x2ap_common.h b/openair2/X2AP/x2ap_common.h index 04ad77f8e3..b2f8617572 100755 --- a/openair2/X2AP/x2ap_common.h +++ b/openair2/X2AP/x2ap_common.h @@ -290,8 +290,10 @@ # define X2AP_PORT 36422 #endif +#ifndef TRUE #define TRUE 1 #define FALSE 0 +#endif extern int asn_debug; extern int asn1_xer_print; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 1023ccc04f..cf4f6e9568 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -190,10 +190,10 @@ static inline void thread_top_init(char *thread_name, if (sched_setattr(0, &attr, flags) < 0 ) { perror("[SCHED] eNB tx thread: sched_setattr failed\n"); - exit_fun("Error setting deadline scheduler"); + exit(1); } - LOG_I( HW, "[SCHED] eNB %s deadline thread (TID %ld) started on CPU %d\n", gettid(), thread_name,sched_getcpu() ); + LOG_I( HW, "[SCHED] eNB RXn-TXnp4 deadline thread (TID %ld) started on CPU %d\n", gettid(), sched_getcpu() ); #else //LOW_LATENCY int policy, s, j; @@ -1352,7 +1352,9 @@ void init_eNB_proc(int inst) { for (CC_id=0; CC_idnode_function],eNB_timing[eNB->node_timing]); +#endif proc = &eNB->proc; proc_rxtx = proc->proc_rxtx; @@ -1625,7 +1627,9 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst eNB->node_timing = node_timing[CC_id]; eNB->abstraction_flag = 0; eNB->single_thread_flag = single_thread_flag; +#ifndef OCP_FRAMEWORK LOG_I(PHY,"Initializing eNB %d CC_id %d : (%s,%s)\n",inst,CC_id,eNB_functions[node_function[CC_id]],eNB_timing[node_timing[CC_id]]); +#endif switch (node_function[CC_id]) { case NGFI_RRU_IF5: From 4ac71a6e46e986981e93342d4cb14f0708d7fdc4 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Sat, 1 Oct 2016 15:03:56 +0200 Subject: [PATCH 05/14] fixes for automatic version detection of nettle for 14.04/16.04 --- cmake_targets/CMakeLists.txt | 18 +++++++++ cmake_targets/tools/build_helper | 59 +++++++++++++++++++++++++++++- openair2/UTIL/OSA/osa_stream_eea.c | 5 +++ openair3/SECU/nas_stream_eea2.c | 5 +++ 4 files changed, 85 insertions(+), 2 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c763be3309..b3c7942fae 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -186,6 +186,24 @@ set(GIT_BRANCH "UNKNOWN") set(GIT_COMMIT_HASH "UNKNOWN") set(GIT_COMMIT_DATE "UNKNOWN") +#This is to detect nettle version changes between Ubuntu 14.04/16.04 +set ( nettle_cmd "nettle-hash" ) +set ( nettle_arg "-V" ) +execute_process(COMMAND ${nettle_cmd} ${nettle_arg} RESULT_VARIABLE rv OUTPUT_VARIABLE ov ERROR_VARIABLE ev) + +string(REGEX MATCH "[+-]?[0-9]+([.][0-9]+)?" nv ${ov}) + +message("NETTLE_VERSION = ${nv}") + +# we need to remove decimal as floating point arithematic does not work properly with C preprocessor +STRING(REGEX REPLACE "[.]" "" nv ${nv}) + +if ("${nv}" STREQUAL "") + message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" ) +endif() + +set (NETTLE_VERSION "${nv}") +add_definitions("-DNETTLE_VERSION=${NETTLE_VERSION}") find_package(Git) if(GIT_FOUND) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 8d6de5d61c..99504b3dc8 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -334,17 +334,72 @@ check_install_oai_software() { wget $SUDO update-alternatives --set liblapack.so /usr/lib/atlas-base/atlas/liblapack.so - $SUDO apt-get install -y libgnutls-dev nettle-dev nettle-bin + + #Remove old gnutls/nettle installation that was done from sources + remove_nettle_from_source + + $SUDO apt-get install -y nettle-dev nettle-bin + remove_gnutls_from_source + + $SUDO apt-get install -y libgnutls-dev install_asn1c_from_source } +### Remove Nettle installation which was done from sources +remove_nettle_from_source() { + nettle_uninstall_log=$OPENAIR_DIR/cmake_targets/log/nettle_uninstall_log.txt + echo_info "\nUn-Installing Nettle from sources. The log file for nettle un-installation is here: $nettle_uninstall_log " + ( + $SUDO apt-get remove -y nettle-dev nettle-bin + cd /tmp + echo "Downloading nettle archive" + $SUDO rm -rf /tmp/nettle-2.5.tar.gz* /tmp/nettle-2.5 + wget https://ftp.gnu.org/gnu/nettle/nettle-2.5.tar.gz + if [ $? -ne 0 ]; then + wget ftp://ftp.lysator.liu.se/pub/security/lsh/nettle-2.5.tar.gz + fi + if [ ! -f nettle-2.5.tar.gz ]; then + echo_error "Could not download nettle source files" + cd - + return + fi + tar -xzf nettle-2.5.tar.gz + cd nettle-2.5/ + ./configure --disable-openssl --enable-shared --prefix=/usr + $SUDO make uninstall || true + ) >& $nettle_uninstall_log +} + +### Remove Gnutls from source +remove_gnutls_from_source(){ + gnutls_uninstall_log=$OPENAIR_DIR/cmake_targets/log/gnutls_uninstall_log.txt + echo_info "\nUn-Installing Gnutls. The log file for Gnutls un-installation is here: $gnutls_uninstall_log " + ( + $SUDO apt-get remove -y libgnutls-dev + cd /tmp + echo "Downloading gnutls archive" + $SUDO rm -rf /tmp/gnutls-3.1.23.tar.xz* /tmp/gnutls-3.1.23 + wget http://mirrors.dotsrc.org/gcrypt/gnutls/v3.1/gnutls-3.1.23.tar.xz || \ + wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-3.1.23.tar.xz + if [ ! -f gnutls-3.1.23.tar.xz ]; then + echo_error "Could not download gnutls source files" + cd - + return + fi + tar -xJf gnutls-3.1.23.tar.xz + cd gnutls-3.1.23/ + ./configure --prefix=/usr + $SUDO make uninstall || true + )>& $gnutls_uninstall_log +} + install_asn1c_from_source(){ asn1_install_log=$OPENAIR_DIR/cmake_targets/log/asn1c_install_log.txt echo_info "\nInstalling ASN1. The log file for ASN1 installation is here: $asn1_install_log " ( $SUDO rm -rf /tmp/asn1c - $SUDO GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c + GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c cd /tmp/asn1c ./configure make -j`nproc` diff --git a/openair2/UTIL/OSA/osa_stream_eea.c b/openair2/UTIL/OSA/osa_stream_eea.c index acd341232e..08e0d44441 100644 --- a/openair2/UTIL/OSA/osa_stream_eea.c +++ b/openair2/UTIL/OSA/osa_stream_eea.c @@ -199,8 +199,13 @@ int stream_encrypt_eea2(stream_cipher_t *stream_cipher, uint8_t **out) } #endif +#if NETTLE_VERSION <= 27 + nettle_aes128.set_encrypt_key(ctx, stream_cipher->key_length, + stream_cipher->key); +#else nettle_aes128.set_encrypt_key(ctx, stream_cipher->key); +#endif nettle_ctr_crypt(ctx, nettle_aes128.encrypt, nettle_aes128.block_size, m, diff --git a/openair3/SECU/nas_stream_eea2.c b/openair3/SECU/nas_stream_eea2.c index 799aaaf432..df3a1ed82c 100644 --- a/openair3/SECU/nas_stream_eea2.c +++ b/openair3/SECU/nas_stream_eea2.c @@ -85,8 +85,13 @@ int nas_stream_encrypt_eea2(nas_stream_cipher_t *stream_cipher, uint8_t *out) } #endif +#if NETTLE_VERSION <= 27 + nettle_aes128.set_encrypt_key(ctx, stream_cipher->key_length, + stream_cipher->key); +#else nettle_aes128.set_encrypt_key(ctx, stream_cipher->key); +#endif nettle_ctr_crypt(ctx, nettle_aes128.encrypt, nettle_aes128.block_size, m, From 42b00ead01775c3fafb26fc00e1ea6b45667da9a Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Sat, 1 Oct 2016 08:54:27 -0700 Subject: [PATCH 06/14] cmake list fix for detecting nettle version for at_commands --- cmake_targets/at_commands/CMakeLists.txt | 18 ++++++++++++++++++ cmake_targets/autotests/README.txt | 1 - 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cmake_targets/at_commands/CMakeLists.txt b/cmake_targets/at_commands/CMakeLists.txt index 0b8bfed25b..951384bd02 100755 --- a/cmake_targets/at_commands/CMakeLists.txt +++ b/cmake_targets/at_commands/CMakeLists.txt @@ -92,6 +92,24 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2 -std=gnu99 -Wall -Wstrict-prototype set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -DMALLOC_CHECK_=3") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ggdb -DMALLOC_CHECK_=3 -O2") +#This is to detect nettle version changes between Ubuntu 14.04/16.04 +set ( nettle_cmd "nettle-hash" ) +set ( nettle_arg "-V" ) +execute_process(COMMAND ${nettle_cmd} ${nettle_arg} RESULT_VARIABLE rv OUTPUT_VARIABLE ov ERROR_VARIABLE ev) + +string(REGEX MATCH "[+-]?[0-9]+([.][0-9]+)?" nv ${ov}) + +message("NETTLE_VERSION = ${nv}") + +# we need to remove decimal as floating point arithematic does not work properly with C preprocessor +STRING(REGEX REPLACE "[.]" "" nv ${nv}) + +if ("${nv}" STREQUAL "") + message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" ) +endif() + +set (NETTLE_VERSION "${nv}") +add_definitions("-DNETTLE_VERSION=${NETTLE_VERSION}") include(FindPkgConfig) diff --git a/cmake_targets/autotests/README.txt b/cmake_targets/autotests/README.txt index f4e50a7e51..2a1b57c0b2 100644 --- a/cmake_targets/autotests/README.txt +++ b/cmake_targets/autotests/README.txt @@ -1,5 +1,4 @@ OAI Test PLAN -#UNDER CONSTRUCTION. Not correct at the moment Obj.# Case# Test# Description From d9398cdb1e52a5975a25611cc3dc2056ea916c60 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Sat, 1 Oct 2016 18:03:07 +0200 Subject: [PATCH 07/14] minor fix for compilation of itti assertions --- common/utils/itti/assertions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/utils/itti/assertions.h b/common/utils/itti/assertions.h index f6a6b772cd..768b40cc72 100644 --- a/common/utils/itti/assertions.h +++ b/common/utils/itti/assertions.h @@ -34,7 +34,7 @@ #include #endif -#if defined(ENB_MODE2) +#if defined(ENB_MODE) # define display_backtrace() #else # include "backtrace.h" From e63475debb4247e286c911832d1f50e35f567d27 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Sat, 1 Oct 2016 22:03:37 +0200 Subject: [PATCH 08/14] minor fix for compilation of core simulators --- openair3/TEST/test_aes128_ctr_decrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair3/TEST/test_aes128_ctr_decrypt.c b/openair3/TEST/test_aes128_ctr_decrypt.c index 251f80fa70..209ce8977a 100644 --- a/openair3/TEST/test_aes128_ctr_decrypt.c +++ b/openair3/TEST/test_aes128_ctr_decrypt.c @@ -48,7 +48,7 @@ void test_uncipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key, uint8_t *data = malloc(length); uint8_t *ctr = malloc(cipher->block_size); - cipher->set_encrypt_key(ctx, key); + cipher->set_encrypt_key(ctx, key_length, key); memcpy(ctr, ictr, cipher->block_size); ctr_crypt(ctx, cipher->encrypt, From 93559037f64a56ab76d5ed1560f2ed3b1a54ab5f Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Sat, 1 Oct 2016 13:10:17 -0700 Subject: [PATCH 09/14] compilation fix for nettle API change in 16.04 --- openair3/TEST/test_aes128_ctr_decrypt.c | 5 +++++ openair3/TEST/test_aes128_ctr_encrypt.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/openair3/TEST/test_aes128_ctr_decrypt.c b/openair3/TEST/test_aes128_ctr_decrypt.c index 209ce8977a..15416c5e4b 100644 --- a/openair3/TEST/test_aes128_ctr_decrypt.c +++ b/openair3/TEST/test_aes128_ctr_decrypt.c @@ -48,7 +48,12 @@ void test_uncipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key, uint8_t *data = malloc(length); uint8_t *ctr = malloc(cipher->block_size); +#if NETTLE_VERSION <= 27 cipher->set_encrypt_key(ctx, key_length, key); +#else + cipher->set_encrypt_key(ctx, key); +#endif + memcpy(ctr, ictr, cipher->block_size); ctr_crypt(ctx, cipher->encrypt, diff --git a/openair3/TEST/test_aes128_ctr_encrypt.c b/openair3/TEST/test_aes128_ctr_encrypt.c index a089ac549d..dab80b3602 100644 --- a/openair3/TEST/test_aes128_ctr_encrypt.c +++ b/openair3/TEST/test_aes128_ctr_encrypt.c @@ -47,7 +47,12 @@ static void test_cipher_ctr(const struct nettle_cipher *cipher, const uint8_t *k uint8_t *data = malloc(length); uint8_t *ctr = malloc(cipher->block_size); +#if NETTLE_VERSION <= 27 cipher->set_encrypt_key(ctx, key_length, key); +#else + cipher->set_encrypt_key(ctx, key); +#endif + memcpy(ctr, ictr, cipher->block_size); ctr_crypt(ctx, cipher->encrypt, From 7c6e48d9c449a90932693114a295155bd063165d Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Sun, 2 Oct 2016 19:56:43 +0200 Subject: [PATCH 10/14] detect nettle version using cmake --- cmake_targets/CMakeLists.txt | 38 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index b3c7942fae..db03e98c23 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -186,25 +186,6 @@ set(GIT_BRANCH "UNKNOWN") set(GIT_COMMIT_HASH "UNKNOWN") set(GIT_COMMIT_DATE "UNKNOWN") -#This is to detect nettle version changes between Ubuntu 14.04/16.04 -set ( nettle_cmd "nettle-hash" ) -set ( nettle_arg "-V" ) -execute_process(COMMAND ${nettle_cmd} ${nettle_arg} RESULT_VARIABLE rv OUTPUT_VARIABLE ov ERROR_VARIABLE ev) - -string(REGEX MATCH "[+-]?[0-9]+([.][0-9]+)?" nv ${ov}) - -message("NETTLE_VERSION = ${nv}") - -# we need to remove decimal as floating point arithematic does not work properly with C preprocessor -STRING(REGEX REPLACE "[.]" "" nv ${nv}) - -if ("${nv}" STREQUAL "") - message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" ) -endif() - -set (NETTLE_VERSION "${nv}") -add_definitions("-DNETTLE_VERSION=${NETTLE_VERSION}") - find_package(Git) if(GIT_FOUND) message("git found: ${GIT_EXECUTABLE}") @@ -1550,11 +1531,28 @@ endif() pkg_search_module(NETTLE nettle) if(NOT ${NETTLE_FOUND}) - message("PACKAGE nettle not found: some targets will fail") + message( FATAL_ERROR "PACKAGE nettle not found: some targets will fail. Run build_oai -I again!") else() include_directories(${NETTLE_INCLUDE_DIRS}) endif() +message ("NETTLE VERSION_INSTALLED = ${NETTLE_VERSION}") + +string(REGEX MATCH "[+-]?[0-9]+([.][0-9]+)?" nv ${NETTLE_VERSION}) + +# WE only pass the major and first minor in the define and ignore the rest +#message("NETTLE_VERSION USED = ${nv}") + +# we need to remove decimal as floating point arithematic does not work properly with C preprocessor +STRING(REGEX REPLACE "[.]" "" nv ${nv}) + +if ("${nv}" STREQUAL "") + message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" ) +endif() + +set (NETTLE_VERSION "${nv}") +add_definitions("-DNETTLE_VERSION=${NETTLE_VERSION}") + pkg_search_module(XPM xpm) if(NOT ${XPM_FOUND}) message("PACKAGE xpm not found: some targets will fail") From 27bb59d3af887f9c8c9501203a85badba082ecc1 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 3 Oct 2016 10:38:46 +0200 Subject: [PATCH 11/14] better handling of NETTLE version in CMake --- cmake_targets/CMakeLists.txt | 17 +++++++---------- openair3/TEST/test_aes128_ctr_decrypt.c | 2 +- openair3/TEST/test_aes128_ctr_encrypt.c | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index db03e98c23..e1d5fcb12a 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1538,20 +1538,17 @@ endif() message ("NETTLE VERSION_INSTALLED = ${NETTLE_VERSION}") -string(REGEX MATCH "[+-]?[0-9]+([.][0-9]+)?" nv ${NETTLE_VERSION}) +string(REGEX REPLACE "([0-9]+).*" "\\1" NETTLE_VERSION_MAJOR ${NETTLE_VERSION}) +string(REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" NETTLE_VERSION_MINOR ${NETTLE_VERSION}) +message ("NETTLE_VERSION_MAJOR = ${NETTLE_VERSION_MAJOR}") +message ("NETTLE_VERSION_MINOR = ${NETTLE_VERSION_MINOR}") -# WE only pass the major and first minor in the define and ignore the rest -#message("NETTLE_VERSION USED = ${nv}") - -# we need to remove decimal as floating point arithematic does not work properly with C preprocessor -STRING(REGEX REPLACE "[.]" "" nv ${nv}) - -if ("${nv}" STREQUAL "") +if ("${NETTLE_VERSION_MAJOR}" STREQUAL "" OR "${NETTLE_VERSION_MINOR}" STREQUAL "") message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" ) endif() -set (NETTLE_VERSION "${nv}") -add_definitions("-DNETTLE_VERSION=${NETTLE_VERSION}") +add_definitions("-DNETTLE_VERSION_MAJOR=${NETTLE_VERSION_MAJOR}") +add_definitions("-DNETTLE_VERSION_MINOR=${NETTLE_VERSION_MINOR}") pkg_search_module(XPM xpm) if(NOT ${XPM_FOUND}) diff --git a/openair3/TEST/test_aes128_ctr_decrypt.c b/openair3/TEST/test_aes128_ctr_decrypt.c index 15416c5e4b..4106cb90bb 100644 --- a/openair3/TEST/test_aes128_ctr_decrypt.c +++ b/openair3/TEST/test_aes128_ctr_decrypt.c @@ -48,7 +48,7 @@ void test_uncipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key, uint8_t *data = malloc(length); uint8_t *ctr = malloc(cipher->block_size); -#if NETTLE_VERSION <= 27 +#if NETTLE_VERSION_MAJOR < 3 cipher->set_encrypt_key(ctx, key_length, key); #else cipher->set_encrypt_key(ctx, key); diff --git a/openair3/TEST/test_aes128_ctr_encrypt.c b/openair3/TEST/test_aes128_ctr_encrypt.c index dab80b3602..399200aab4 100644 --- a/openair3/TEST/test_aes128_ctr_encrypt.c +++ b/openair3/TEST/test_aes128_ctr_encrypt.c @@ -47,7 +47,7 @@ static void test_cipher_ctr(const struct nettle_cipher *cipher, const uint8_t *k uint8_t *data = malloc(length); uint8_t *ctr = malloc(cipher->block_size); -#if NETTLE_VERSION <= 27 +#if NETTLE_VERSION_MAJOR < 3 cipher->set_encrypt_key(ctx, key_length, key); #else cipher->set_encrypt_key(ctx, key); From 494e0dc2769c038b338094ed0b1d6dbcd892202e Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 3 Oct 2016 10:41:29 +0200 Subject: [PATCH 12/14] bugfix: forgot to reprocess files in the previous commit --- openair2/UTIL/OSA/osa_stream_eea.c | 2 +- openair3/SECU/nas_stream_eea2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/UTIL/OSA/osa_stream_eea.c b/openair2/UTIL/OSA/osa_stream_eea.c index 08e0d44441..17020bf7de 100644 --- a/openair2/UTIL/OSA/osa_stream_eea.c +++ b/openair2/UTIL/OSA/osa_stream_eea.c @@ -199,7 +199,7 @@ int stream_encrypt_eea2(stream_cipher_t *stream_cipher, uint8_t **out) } #endif -#if NETTLE_VERSION <= 27 +#if NETTLE_VERSION_MAJOR < 3 nettle_aes128.set_encrypt_key(ctx, stream_cipher->key_length, stream_cipher->key); #else diff --git a/openair3/SECU/nas_stream_eea2.c b/openair3/SECU/nas_stream_eea2.c index df3a1ed82c..14ab5c3b73 100644 --- a/openair3/SECU/nas_stream_eea2.c +++ b/openair3/SECU/nas_stream_eea2.c @@ -85,7 +85,7 @@ int nas_stream_encrypt_eea2(nas_stream_cipher_t *stream_cipher, uint8_t *out) } #endif -#if NETTLE_VERSION <= 27 +#if NETTLE_VERSION_MAJOR < 3 nettle_aes128.set_encrypt_key(ctx, stream_cipher->key_length, stream_cipher->key); #else From 13496a4c6b0151af17cb191d0cdc4b1734de12d6 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Mon, 3 Oct 2016 12:59:00 +0200 Subject: [PATCH 13/14] minor fix to add some log message in oarf compilation fir EXMIMO drivers --- cmake_targets/build_oai | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index f637254e18..65f1548058 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -561,6 +561,7 @@ function main() { compilations \ $lte_build_dir updatefw \ updatefw $dbin/updatefw + echo_info "Compiling oarf tools. The logfile for compilation is here: $dlog/oarf.txt" make -C $OPENAIR_DIR/cmake_targets/$lte_build_dir/build oarf > $dlog/oarf.txt 2>&1 cp $OPENAIR_DIR/cmake_targets/$lte_build_dir/build/*.oct $dbin if [ -s $dbin/oarf_config_exmimo.oct ] ; then From 433d058ba94e8bf908c94cd892c334b04b9719bc Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Tue, 11 Oct 2016 18:48:24 +0200 Subject: [PATCH 14/14] Gitlab CI: delete wildcard programs for kill script --- cmake_targets/autotests/test_case_list.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 8235963c52..4ab8a6885f 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -7,7 +7,7 @@ https://gitlab.eurecom.fr/oai/openair-cn.git develop develop - oaisim oaisim_nos1 lte-softmodem lte-softmodem-nos1 mme_gw run_epc auth_request run_hss oai_hss mme spgw hss hss_sim configure_cots* wvdial iperf iperf_script iperf_script_phone ping tshark rrh_gw iperf3 iperf3_script iperf3_script_phone pppd starthss start_ltebox stop_ltebox configure_cots_sony_experia_m4_ue configure_cots_huaweiE398_ue configure_cots_bandrich_ue + oaisim oaisim_nos1 lte-softmodem lte-softmodem-nos1 mme_gw run_epc auth_request run_hss oai_hss mme spgw hss hss_sim wvdial iperf iperf_script iperf_script_phone ping tshark rrh_gw iperf3 iperf3_script iperf3_script_phone pppd starthss start_ltebox stop_ltebox configure_cots_sony_experia_m4_ue configure_cots_huaweiE398_ue configure_cots_bandrich_ue sudo -S -E /opt/ltebox/tools/stop_ltebox exmimo_pci=`lspci -m | grep Xilinx`; if [ -n "$exmimo_pci" ] ; then $OPENAIR_DIR/cmake_targets/build_oai -w EXMIMO -c; sudo -S -E $OPENAIR_DIR/cmake_targets/tools/stop_exmimo2; fi; sudo -E $OPENAIR_DIR/cmake_targets/autotests/tools/configure_cots_bandrich_ue.py --reset-ue; sudo -E $OPENAIR_DIR/cmake_targets/autotests/tools/configure_cots_huaweiE398_ue.py --reset-ue; sudo -E $OPENAIR_DIR/cmake_targets/autotests/tools/configure_cots_sony_experia_m4_ue.py --stop-ue; uname -a; sudo -E dmesg 36000