Skip to content
Snippets Groups Projects
Commit e4a73188 authored by Wang Tsu-Han's avatar Wang Tsu-Han
Browse files

Merge branch 'develop' into parallel-phy-test-EMUFH

Conflicts:
	openair1/PHY/defs_eNB.h
	targets/RT/USER/lte-enb.c
parents 0915a0e6 07678191
No related branches found
No related tags found
No related merge requests found
Showing
with 611 additions and 303 deletions
// Comments
pipeline {
agent {
label 'bellatrix'
}
options {
disableConcurrentBuilds()
timestamps()
gitLabConnection('OAI GitLab')
//gitlabBuilds(builds: ["Build", "Test"])
}
stages {
stage ("Verify Parameters") {
steps {
echo 'Verify Parameters'
echo "Git URL is ${GIT_URL}"
echo "GitLab Act is ${env.gitlabActionType}"
script {
if ("MERGE".equals(env.gitlabActionType)) {
// GitLab-Jenkins pugin integration is lacking to perform the merge by itself
// Doing it manually --> it may have merge conflicts
sh "./ci-scripts/doGitLabMerge.sh ${env.gitlabSourceBranch} ${env.gitlabMergeRequestLastCommit} ${env.gitlabTargetBranch} ${GIT_COMMIT}"
sh "./ci-scripts/checkCodingFormattingRules.sh ${env.gitlabSourceBranch} ${env.gitlabTargetBranch}"
def res=readFile('./oai_rules_result.txt').trim();
if ("0".equals(res)) {
addGitLabMRComment comment: "All Changed files in Merge Request follow OAI Formatting Rules"
} else {
addGitLabMRComment comment: "Some Changed files in Merge Request DO NOT follow OAI Formatting Rules"
}
} else {
echo "Git Branch is ${GIT_BRANCH}"
echo "Git Commit is ${GIT_COMMIT}"
sh "./ci-scripts/checkCodingFormattingRules.sh"
}
}
}
}
}
post {
always {
script {
echo "End of script"
}
}
success {
script {
def message = "OAI build #" + BUILD_ID + " passed (" + BUILD_URL + ")"
if ("MERGE".equals(env.gitlabActionType)) {
echo "This is a MERGE event"
addGitLabMRComment comment: message
def message2 = "OAI build #" + BUILD_ID + " passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
slackSend channel: 'ci-enb', color: 'good', message: message2
} else {
slackSend channel: 'ci-enb', color: 'good', message: message
}
}
}
failure {
script {
def message = "OAI build #" + BUILD_ID + " failed (" + BUILD_URL + ")"
if ("MERGE".equals(env.gitlabActionType)) {
echo "This is a MERGE event"
addGitLabMRComment comment: message
def message2 = "OAI build #" + BUILD_ID + " failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
slackSend channel: 'ci-enb', color: 'danger', message: message2
} else {
slackSend channel: 'ci-enb', color: 'danger', message: message
}
}
}
}
}
# OAI is using a style that is similar to the Google style
--style=google
# long options can be written without the preceding '--'
# Convert tabs to spaces
convert-tabs
# Indentation is 2 spaces
indent=spaces=2
# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block.
indent-switches
# Indent C++ comments beginning in column one.
indent-col1-comments
# Pad empty lines around header blocks
break-blocks
delete-empty-lines
# Attach a pointer or reference operator (*, &, or ^) to the variable name (right)
align-pointer=name
# The code line length is 200 characters/columns
max-code-length=200
break-after-logical
lineend=linux
#!/bin/bash
if [ $# -eq 0 ]
then
NB_FILES_TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt --recursive *.c *.h | grep -c Formatted `
echo "Nb Files that do NOT follow OAI rules: $NB_FILES_TO_FORMAT"
exit 0
fi
if [ $# -eq 2 ]
then
# Merge request scenario
SOURCE_BRANCH=$1
echo "Source Branch is : $SOURCE_BRANCH"
TARGET_BRANCH=$2
echo "Target Branch is : $TARGET_BRANCH"
MERGE_COMMMIT=`git log -n1 | grep commit | sed -e "s@commit @@"`
echo "Merged Commit is : $MERGE_COMMMIT"
TARGET_INIT_COMMIT=`cat .git/refs/remotes/origin/$TARGET_BRANCH`
echo "Target Init is : $TARGET_INIT_COMMIT"
# Retrieve the list of modified files since the latest develop commit
MODIFIED_FILES=`git log $TARGET_INIT_COMMIT..$MERGE_COMMMIT --oneline --name-status | egrep "^M|^A" | sed -e "s@^M\t*@@" -e "s@^A\t*@@" | sort | uniq`
NB_TO_FORMAT=0
for FULLFILE in $MODIFIED_FILES
do
echo $FULLFILE
filename=$(basename -- "$FULLFILE")
EXT="${filename##*.}"
if [ $EXT = "c" ] || [ $EXT = "h" ] || [ $EXT = "cpp" ] || [ $EXT = "hpp" ]
then
TO_FORMAT=`astyle --dry-run --options=ci-scripts/astyle-options.txt $FULLFILE | grep -c Formatted `
NB_TO_FORMAT=$((NB_TO_FORMAT + TO_FORMAT))
fi
done
echo "Nb Files that do NOT follow OAI rules: $NB_TO_FORMAT"
echo $NB_TO_FORMAT > ./oai_rules_result.txt
exit 0
fi
if [ $# -ne 0 ] || [ $# -ne 2 ]
then
echo "Syntax error: $0 without any option will check all files in repository"
echo " or: $0 source-branch target-branch"
echo " will only check files that are pushed for a merge-request"
exit 1
fi
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Syntax Error: $0 src-branch src-commit-id dest-branch dest-commit-id"
exit 1
fi
SOURCE_BRANCH=$1
echo "Source Branch is : $SOURCE_BRANCH"
SOURCE_COMMIT_ID=$2
echo "Source Commit ID is : $SOURCE_COMMIT_ID"
TARGET_BRANCH=$3
echo "Target Branch is : $TARGET_BRANCH"
TARGET_COMMIT_ID=$4
echo "Target Commit ID is : $TARGET_COMMIT_ID"
git config user.email "jenkins@openairinterface.org"
git config user.name "OAI Jenkins"
git checkout -f $SOURCE_COMMIT_ID
git merge --ff $TARGET_COMMIT_ID -m "Temporary merge for CI"
This diff is collapsed.
...@@ -68,6 +68,7 @@ DISABLE_LOG_X="False" ...@@ -68,6 +68,7 @@ DISABLE_LOG_X="False"
USRP_REC_PLAY="False" USRP_REC_PLAY="False"
BUILD_ECLIPSE=0 BUILD_ECLIPSE=0
UE_NAS_USE_TUN="False" UE_NAS_USE_TUN="False"
BASIC_SIMULATOR=0
trap handle_ctrl_c INT trap handle_ctrl_c INT
function print_help() { function print_help() {
...@@ -159,6 +160,9 @@ Options ...@@ -159,6 +160,9 @@ Options
Build for I/Q record-playback modes Build for I/Q record-playback modes
--ue-nas-use-tun --ue-nas-use-tun
Use TUN devices for the UEs instead of ue_ip.ko Use TUN devices for the UEs instead of ue_ip.ko
--basic-simulator
Generates a basic [1 UE + 1 eNB + no channel] simulator.
See targets/ARCH/tcp_bridge/README.tcp_bridge_oai for documentation.
Usage (first build): Usage (first build):
oaisim (eNB + UE): ./build_oai -I --oaisim -x --install-system-files oaisim (eNB + UE): ./build_oai -I --oaisim -x --install-system-files
Eurecom EXMIMO + COTS UE : ./build_oai -I --eNB -x --install-system-files Eurecom EXMIMO + COTS UE : ./build_oai -I --eNB -x --install-system-files
...@@ -354,6 +358,10 @@ function main() { ...@@ -354,6 +358,10 @@ function main() {
UE_NAS_USE_TUN="True" UE_NAS_USE_TUN="True"
echo_info "Enabling UE NAS TUN device usage instead of ue_ip.ko" echo_info "Enabling UE NAS TUN device usage instead of ue_ip.ko"
shift 1;; shift 1;;
--basic-simulator)
BASIC_SIMULATOR=1
echo_info "Compiling the basic simulator"
shift 1;;
-h | --help) -h | --help)
print_help print_help
exit 1;; exit 1;;
...@@ -919,6 +927,122 @@ fi ...@@ -919,6 +927,122 @@ fi
else else
echo_info "10. Bypassing the Tests ..." echo_info "10. Bypassing the Tests ..."
fi fi
# basic simulator
#####################
if [ "$BASIC_SIMULATOR" = "1" ]; then
echo_info "Build basic simulator"
[ "$CLEAN" = "1" ] && rm -rf $OPENAIR_DIR/cmake_targets/basic_simulator
[ "$CLEAN" = "1" ] && rm -rf $OPENAIR_DIR/cmake_targets/nas_sim_tools/build
mkdir -p $OPENAIR_DIR/cmake_targets/basic_simulator
mkdir -p $OPENAIR_DIR/cmake_targets/basic_simulator/enb
mkdir -p $OPENAIR_DIR/cmake_targets/basic_simulator/ue
mkdir -p $OPENAIR_DIR/cmake_targets/nas_sim_tools/build
# enb
cmake_file=$OPENAIR_DIR/cmake_targets/basic_simulator/enb/CMakeLists.txt
echo "cmake_minimum_required(VERSION 2.8)" > $cmake_file
echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file
echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file
echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file
echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file
echo "set ( XFORMS $XFORMS )" >> $cmake_file
echo "set ( RF_BOARD \"OAI_USRP\")" >> $cmake_file
echo "set ( TRANSP_PRO \"None\")" >> $cmake_file
echo "set(PACKAGE_NAME \"simulator_enb\")" >> $cmake_file
echo "set (DEADLINE_SCHEDULER \"False\" )" >> $cmake_file
echo "set (CPU_AFFINITY \"False\" )" >> $cmake_file
echo "set ( T_TRACER \"True\" )" >> $cmake_file
echo "set (UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE)" >> $cmake_file
echo "set (UE_DEBUG_TRACE $UE_DEBUG_TRACE)" >> $cmake_file
echo "set (UE_TIMING_TRACE $UE_TIMING_TRACE)" >> $cmake_file
echo "set (DISABLE_LOG_X $DISABLE_LOG_X)" >> $cmake_file
echo "set (USRP_REC_PLAY $USRP_REC_PLAY)" >> $cmake_file
echo "set (BASIC_SIMULATOR \"True\" )" >> $cmake_file
echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt)' >> $cmake_file
echo_info "Build eNB"
echo_info "logs are in $dlog/basic_simulator_enb.txt"
set +e
{
cd $OPENAIR_DIR/cmake_targets/basic_simulator/enb
cmake .
make -j`nproc` coding params_libconfig tcp_bridge_oai lte-softmodem
ln -sf libtcp_bridge_oai.so liboai_device.so
cd ../..
} > $dlog/basic_simulator_enb.txt 2>&1
set -e
if [ -s $OPENAIR_DIR/cmake_targets/basic_simulator/enb/lte-softmodem -a \
-s $OPENAIR_DIR/cmake_targets/basic_simulator/enb/libcoding.so -a \
-s $OPENAIR_DIR/cmake_targets/basic_simulator/enb/libparams_libconfig.so -a \
-s $OPENAIR_DIR/cmake_targets/basic_simulator/enb/libtcp_bridge_oai.so ] ; then
echo_success "eNB compiled"
check_warnings "$dlog/basic_simulator_enb.txt"
else
echo_error "eNB compilation failed"
exit 1
fi
# ue
echo_info "Compile conf2uedata"
cd $OPENAIR_DIR/cmake_targets/nas_sim_tools/build
eval $CMAKE_CMD
compilations \
nas_sim_tools conf2uedata \
conf2uedata $dbin/conf2uedata
cmake_file=$OPENAIR_DIR/cmake_targets/basic_simulator/ue/CMakeLists.txt
echo "cmake_minimum_required(VERSION 2.8)" > $cmake_file
echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file
echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >> $cmake_file
echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file
echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file
echo "set ( XFORMS $XFORMS )" >> $cmake_file
echo "set ( RF_BOARD \"OAI_USRP\")" >> $cmake_file
echo "set ( TRANSP_PRO \"None\")" >> $cmake_file
echo "set(PACKAGE_NAME \"simulator_ue\")" >> $cmake_file
echo "set (DEADLINE_SCHEDULER \"False\" )" >> $cmake_file
echo "set (CPU_AFFINITY \"False\" )" >> $cmake_file
echo "set ( T_TRACER \"False\" )" >> $cmake_file
echo "set (UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE)" >> $cmake_file
echo "set (UE_DEBUG_TRACE $UE_DEBUG_TRACE)" >> $cmake_file
echo "set (UE_TIMING_TRACE $UE_TIMING_TRACE)" >> $cmake_file
echo "set (DISABLE_LOG_X $DISABLE_LOG_X)" >> $cmake_file
echo "set (USRP_REC_PLAY $USRP_REC_PLAY)" >> $cmake_file
echo "set (LINUX True )" >> $cmake_file
echo "set (PDCP_USE_NETLINK True )" >> $cmake_file
echo "set (BASIC_SIMULATOR \"True\" )" >> $cmake_file
echo "set (UE_NAS_USE_TUN \"True\" )" >> $cmake_file
echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt)' >> $cmake_file
echo_info "Build UE"
echo_info "logs are in $dlog/basic_simulator_ue.txt"
set +e
{
cd $OPENAIR_DIR/cmake_targets/basic_simulator/ue
cmake .
make -j`nproc` coding params_libconfig tcp_bridge_oai lte-uesoftmodem
ln -sf libtcp_bridge_oai.so liboai_device.so
cd ../..
} > $dlog/basic_simulator_ue.txt 2>&1
set -e
if [ -s $OPENAIR_DIR/cmake_targets/basic_simulator/ue/lte-uesoftmodem -a \
-s $OPENAIR_DIR/cmake_targets/basic_simulator/ue/libcoding.so -a \
-s $OPENAIR_DIR/cmake_targets/basic_simulator/ue/libparams_libconfig.so -a \
-s $OPENAIR_DIR/cmake_targets/basic_simulator/ue/libtcp_bridge_oai.so ] ; then
echo_success "UE compiled"
check_warnings "$dlog/basic_simulator_ue.txt"
else
echo_error "UE compilation failed"
exit 1
fi
echo_info "Generate UE SIM data"
$OPENAIR_DIR/targets/bin/conf2uedata -c $OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -o $OPENAIR_DIR/cmake_targets/basic_simulator/ue
fi
} }
main "$@" main "$@"
...@@ -8,5 +8,5 @@ set(DEBUG_PHY False) ...@@ -8,5 +8,5 @@ set(DEBUG_PHY False)
set(MU_RECIEVER False) set(MU_RECIEVER False)
set(NAS_UE False) set(NAS_UE False)
set(MESSAGE_CHART_GENERATOR False) set(MESSAGE_CHART_GENERATOR False)
set(RRC_ASN1_VERSION "Rel14")
include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt) include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)
...@@ -95,6 +95,7 @@ get_distribution_release() { ...@@ -95,6 +95,7 @@ get_distribution_release() {
check_supported_distribution() { check_supported_distribution() {
local distribution=$(get_distribution_release) local distribution=$(get_distribution_release)
case "$distribution" in case "$distribution" in
"ubuntu18.04") return 0 ;;
"ubuntu17.10") return 0 ;; "ubuntu17.10") return 0 ;;
"ubuntu17.04") return 0 ;; "ubuntu17.04") return 0 ;;
"ubuntu16.04") return 0 ;; "ubuntu16.04") return 0 ;;
...@@ -267,7 +268,7 @@ check_install_usrp_uhd_driver(){ ...@@ -267,7 +268,7 @@ check_install_usrp_uhd_driver(){
if [[ "$OS_DISTRO" == "ubuntu" ]]; then if [[ "$OS_DISTRO" == "ubuntu" ]]; then
#first we remove old installation #first we remove old installation
$SUDO apt-get remove -y uhd || true $SUDO apt-get remove -y uhd || true
$SUDO apt-get remove libuhd-dev libuhd003 uhd-host -y $SUDO apt-get remove libuhd-dev libuhd003 uhd-host -y || true
v=$(lsb_release -cs) v=$(lsb_release -cs)
$SUDO apt-add-repository --remove "deb http://files.ettus.com/binaries/uhd/repo/uhd/ubuntu/$v $v main" $SUDO apt-add-repository --remove "deb http://files.ettus.com/binaries/uhd/repo/uhd/ubuntu/$v $v main"
#The new USRP repository #The new USRP repository
...@@ -488,19 +489,24 @@ check_install_oai_software() { ...@@ -488,19 +489,24 @@ check_install_oai_software() {
$SUDO apt install -y software-properties-common $SUDO apt install -y software-properties-common
case "$(get_distribution_release)" in case "$(get_distribution_release)" in
"ubuntu14.04") "ubuntu14.04")
specific_packages="libtasn1-3-dev gccxml libgnutls-dev libatlas-dev" specific_packages="libtasn1-3-dev gccxml libgnutls-dev libatlas-dev iproute libconfig8-dev"
# For iperf3 # For iperf3
$SUDO add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports universe" $SUDO add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports universe"
$SUDO apt-get update $SUDO apt-get update
;; ;;
"ubuntu16.04") "ubuntu16.04")
specific_packages="libtasn1-6-dev gccxml libgnutls-dev libatlas-dev" specific_packages="libtasn1-6-dev gccxml libgnutls-dev libatlas-dev iproute libconfig8-dev"
;; ;;
"ubuntu17.04") "ubuntu17.04")
specific_packages="libtasn1-6-dev castxml libgnutls28-dev libatlas-dev" specific_packages="libtasn1-6-dev castxml libgnutls28-dev libatlas-dev iproute libconfig8-dev"
;; ;;
"ubuntu17.10") "ubuntu17.10")
specific_packages="libtasn1-6-dev castxml libgnutls28-dev" specific_packages="libtasn1-6-dev castxml libgnutls28-dev iproute libconfig8-dev"
LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu"
LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so"
;;
"ubuntu18.04")
specific_packages="libtasn1-6-dev castxml libgnutls28-dev iproute2 libconfig-dev"
LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu"
LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so"
;; ;;
...@@ -524,12 +530,10 @@ check_install_oai_software() { ...@@ -524,12 +530,10 @@ check_install_oai_software() {
gtkwave \ gtkwave \
guile-2.0-dev \ guile-2.0-dev \
iperf \ iperf \
iproute \
iptables \ iptables \
iptables-dev \ iptables-dev \
libatlas-base-dev \ libatlas-base-dev \
libblas-dev \ libblas-dev \
libconfig8-dev \
libffi-dev \ libffi-dev \
libforms-bin \ libforms-bin \
libforms-dev \ libforms-dev \
......
...@@ -35,11 +35,11 @@ ...@@ -35,11 +35,11 @@
#include <pthread.h> #include <pthread.h>
#include "COMMON/platform_constants.h" #include "COMMON/platform_constants.h"
#include "PHY/defs.h" #include "PHY/defs_eNB.h"
#include "PHY/types.h" #include "PHY/types.h"
#include "PHY/impl_defs_top.h" #include "PHY/impl_defs_top.h"
#include "PHY/impl_defs_lte.h" #include "PHY/impl_defs_lte.h"
#include "RRC/LITE/defs.h" #include "RRC/LTE/rrc_defs.h"
#include "flexran_agent_defs.h" #include "flexran_agent_defs.h"
#include "gtpv1u.h" #include "gtpv1u.h"
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include "gtpv1u_eNB_defs.h" #include "gtpv1u_eNB_defs.h"
#include "PHY/defs_L1_NB_IoT.h" #include "PHY/defs_L1_NB_IoT.h"
#include "RRC/LITE/defs_NB_IoT.h" #include "RRC/LTE/defs_NB_IoT.h"
typedef struct { typedef struct {
/// RAN context config file name /// RAN context config file name
char *config_file_name; char *config_file_name;
......
...@@ -88,7 +88,7 @@ static void new_thread(void *(*f)(void *), void *data) ...@@ -88,7 +88,7 @@ static void new_thread(void *(*f)(void *), void *data)
/* defined in local_tracer.c */ /* defined in local_tracer.c */
void T_local_tracer_main(int remote_port, int wait_for_tracer, void T_local_tracer_main(int remote_port, int wait_for_tracer,
int local_socket); int local_socket, char *shm_file);
/* We monitor the tracee and the local tracer processes. /* We monitor the tracee and the local tracer processes.
* When one dies we forcefully kill the other. * When one dies we forcefully kill the other.
...@@ -113,6 +113,9 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) ...@@ -113,6 +113,9 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork)
int s; int s;
int T_shm_fd; int T_shm_fd;
int child1, child2; int child1, child2;
char shm_file[128];
sprintf(shm_file, "/%s%d", T_SHM_FILENAME, getpid());
if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair)) if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair))
{ perror("socketpair"); abort(); } { perror("socketpair"); abort(); }
...@@ -122,7 +125,8 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) ...@@ -122,7 +125,8 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork)
child1 = fork(); if (child1 == -1) abort(); child1 = fork(); if (child1 == -1) abort();
if (child1 == 0) { if (child1 == 0) {
close(socket_pair[1]); close(socket_pair[1]);
T_local_tracer_main(remote_port, wait_for_tracer, socket_pair[0]); T_local_tracer_main(remote_port, wait_for_tracer, socket_pair[0],
shm_file);
exit(0); exit(0);
} }
close(socket_pair[0]); close(socket_pair[0]);
...@@ -142,13 +146,13 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) ...@@ -142,13 +146,13 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork)
T_socket = s; T_socket = s;
/* setup shared memory */ /* setup shared memory */
T_shm_fd = shm_open(T_SHM_FILENAME, O_RDWR /*| O_SYNC*/, 0666); T_shm_fd = shm_open(shm_file, O_RDWR /*| O_SYNC*/, 0666);
shm_unlink(T_SHM_FILENAME); shm_unlink(shm_file);
if (T_shm_fd == -1) { perror(T_SHM_FILENAME); abort(); } if (T_shm_fd == -1) { perror(shm_file); abort(); }
T_cache = mmap(NULL, T_CACHE_SIZE * sizeof(T_cache_t), T_cache = mmap(NULL, T_CACHE_SIZE * sizeof(T_cache_t),
PROT_READ | PROT_WRITE, MAP_SHARED, T_shm_fd, 0); PROT_READ | PROT_WRITE, MAP_SHARED, T_shm_fd, 0);
if (T_cache == NULL) if (T_cache == MAP_FAILED)
{ perror(T_SHM_FILENAME); abort(); } { perror(shm_file); abort(); }
close(T_shm_fd); close(T_shm_fd);
new_thread(T_receive_thread, NULL); new_thread(T_receive_thread, NULL);
......
...@@ -110,6 +110,16 @@ typedef struct { ...@@ -110,6 +110,16 @@ typedef struct {
extern volatile int *T_freelist_head; extern volatile int *T_freelist_head;
extern T_cache_t *T_cache; extern T_cache_t *T_cache;
/* When running the basic simulator, we may fill the T cache too fast.
* Let's not crash if it's full, just wait.
*/
#if BASIC_SIMULATOR
# define T_BASIC_SIMULATOR_WAIT \
while (T_cache[T_LOCAL_slot].busy) usleep(100)
#else
# define T_BASIC_SIMULATOR_WAIT /* */
#endif
/* used at header of Tn, allocates buffer */ /* used at header of Tn, allocates buffer */
#define T_LOCAL_DATA \ #define T_LOCAL_DATA \
char *T_LOCAL_buf; \ char *T_LOCAL_buf; \
...@@ -118,6 +128,7 @@ extern T_cache_t *T_cache; ...@@ -118,6 +128,7 @@ extern T_cache_t *T_cache;
T_LOCAL_slot = __sync_fetch_and_add(T_freelist_head, 1) \ T_LOCAL_slot = __sync_fetch_and_add(T_freelist_head, 1) \
& (T_CACHE_SIZE - 1); \ & (T_CACHE_SIZE - 1); \
(void)__sync_fetch_and_and(T_freelist_head, T_CACHE_SIZE - 1); \ (void)__sync_fetch_and_and(T_freelist_head, T_CACHE_SIZE - 1); \
T_BASIC_SIMULATOR_WAIT; \
if (T_cache[T_LOCAL_slot].busy) { \ if (T_cache[T_LOCAL_slot].busy) { \
printf("%s:%d:%s: T cache is full - consider increasing its size\n", \ printf("%s:%d:%s: T cache is full - consider increasing its size\n", \
__FILE__, __LINE__, __FUNCTION__); \ __FILE__, __LINE__, __FUNCTION__); \
......
...@@ -8,10 +8,20 @@ ...@@ -8,10 +8,20 @@
#define T_MAX_ARGS 16 #define T_MAX_ARGS 16
/* maximum size of a message - increase if needed */ /* maximum size of a message - increase if needed */
#define T_BUFFER_MAX (1024*64) #if BASIC_SIMULATOR
/* let's have 100 RBs functional for the basic simulator */
# define T_BUFFER_MAX (1024*64*2)
#else
# define T_BUFFER_MAX (1024*64)
#endif
/* size of the local cache for messages (must be pow(2,something)) */ /* size of the local cache for messages (must be pow(2,something)) */
#define T_CACHE_SIZE (8192 * 2) #if BASIC_SIMULATOR
/* we don't need much space for the basic simulator */
# define T_CACHE_SIZE 1024
#else
# define T_CACHE_SIZE (8192 * 2)
#endif
/* maximum number of bytes a message can contain */ /* maximum number of bytes a message can contain */
#ifdef T_SEND_TIME #ifdef T_SEND_TIME
......
...@@ -300,6 +300,20 @@ static void forward(void *_forwarder, char *buf, int size) ...@@ -300,6 +300,20 @@ static void forward(void *_forwarder, char *buf, int size)
if (f->tail != NULL) f->tail->next = new; if (f->tail != NULL) f->tail->next = new;
f->tail = new; f->tail = new;
#if BASIC_SIMULATOR
/* When runnng the basic simulator, the tracer may be too slow.
* Let's not take too much memory in the tracee and
* wait if there is too much data to send. 200MB is
* arbitrary.
*/
while (f->memusage > 200 * 1024 * 1024) {
if (pthread_cond_signal(&f->cond)) abort();
if (pthread_mutex_unlock(&f->lock)) abort();
usleep(1000);
if (pthread_mutex_lock(&f->lock)) abort();
}
#endif /* BASIC_SIMULATOR */
f->memusage += size+4; f->memusage += size+4;
/* warn every 100MB */ /* warn every 100MB */
if (f->memusage > f->last_warning_memusage && if (f->memusage > f->last_warning_memusage &&
...@@ -326,17 +340,17 @@ static void wait_message(void) ...@@ -326,17 +340,17 @@ static void wait_message(void)
while (T_local_cache[T_busylist_head].busy == 0) usleep(1000); while (T_local_cache[T_busylist_head].busy == 0) usleep(1000);
} }
static void init_shm(void) static void init_shm(char *shm_file)
{ {
int i; int i;
int s = shm_open(T_SHM_FILENAME, O_RDWR | O_CREAT /*| O_SYNC*/, 0666); int s = shm_open(shm_file, O_RDWR | O_CREAT /*| O_SYNC*/, 0666);
if (s == -1) { perror(T_SHM_FILENAME); abort(); } if (s == -1) { perror(shm_file); abort(); }
if (ftruncate(s, T_CACHE_SIZE * sizeof(T_cache_t))) if (ftruncate(s, T_CACHE_SIZE * sizeof(T_cache_t)))
{ perror(T_SHM_FILENAME); abort(); } { perror(shm_file); abort(); }
T_local_cache = mmap(NULL, T_CACHE_SIZE * sizeof(T_cache_t), T_local_cache = mmap(NULL, T_CACHE_SIZE * sizeof(T_cache_t),
PROT_READ | PROT_WRITE, MAP_SHARED, s, 0); PROT_READ | PROT_WRITE, MAP_SHARED, s, 0);
if (T_local_cache == NULL) if (T_local_cache == MAP_FAILED)
{ perror(T_SHM_FILENAME); abort(); } { perror(shm_file); abort(); }
close(s); close(s);
/* let's garbage the memory to catch some potential problems /* let's garbage the memory to catch some potential problems
...@@ -347,7 +361,7 @@ static void init_shm(void) ...@@ -347,7 +361,7 @@ static void init_shm(void)
} }
void T_local_tracer_main(int remote_port, int wait_for_tracer, void T_local_tracer_main(int remote_port, int wait_for_tracer,
int local_socket) int local_socket, char *shm_file)
{ {
int s; int s;
int port = remote_port; int port = remote_port;
...@@ -357,7 +371,7 @@ void T_local_tracer_main(int remote_port, int wait_for_tracer, ...@@ -357,7 +371,7 @@ void T_local_tracer_main(int remote_port, int wait_for_tracer,
/* write on a socket fails if the other end is closed and we get SIGPIPE */ /* write on a socket fails if the other end is closed and we get SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort(); if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
init_shm(); init_shm(shm_file);
s = local_socket; s = local_socket;
if (dont_wait) { if (dont_wait) {
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "gui/gui.h" #include "gui/gui.h"
#include "filter/filter.h" #include "filter/filter.h"
#include "utils.h" #include "utils.h"
#include "../T_defs.h"
#include "event_selector.h" #include "event_selector.h"
#include "openair_logo.h" #include "openair_logo.h"
#include "config.h" #include "config.h"
...@@ -875,6 +874,8 @@ int main(int n, char **v) ...@@ -875,6 +874,8 @@ int main(int n, char **v)
if (pthread_mutex_init(&enb_data.lock, NULL)) abort(); if (pthread_mutex_init(&enb_data.lock, NULL)) abort();
setup_event_selector(g, database, is_on, is_on_changed, &enb_data); setup_event_selector(g, database, is_on, is_on_changed, &enb_data);
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
restart: restart:
clear_remote_config(); clear_remote_config();
enb_data.socket = connect_to(ip, port); enb_data.socket = connect_to(ip, port);
...@@ -884,9 +885,8 @@ restart: ...@@ -884,9 +885,8 @@ restart:
/* read messages */ /* read messages */
while (1) { while (1) {
char v[T_BUFFER_MAX];
event e; event e;
e = get_event(enb_data.socket, v, database); e = get_event(enb_data.socket, &ebuf, database);
if (e.type == -1) goto restart; if (e.type == -1) goto restart;
if (pthread_mutex_lock(&enb_data.lock)) abort(); if (pthread_mutex_lock(&enb_data.lock)) abort();
handle_event(h, e); handle_event(h, e);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
event get_event(int socket, char *event_buffer, void *database) event get_event(int socket, OBUF *event_buffer, void *database)
{ {
#ifdef T_SEND_TIME #ifdef T_SEND_TIME
struct timespec t; struct timespec t;
...@@ -29,17 +29,23 @@ again: ...@@ -29,17 +29,23 @@ again:
#endif #endif
if (fullread(socket, &type, sizeof(int)) == -1) goto read_error; if (fullread(socket, &type, sizeof(int)) == -1) goto read_error;
length -= sizeof(int); length -= sizeof(int);
if (fullread(socket, event_buffer, length) == -1) goto read_error; if (event_buffer->omaxsize < length) {
event_buffer->omaxsize = (length + 65535) & ~65535;
event_buffer->obuf = realloc(event_buffer->obuf, event_buffer->omaxsize);
if (event_buffer->obuf == NULL) { printf("out of memory\n"); exit(1); }
}
if (fullread(socket, event_buffer->obuf, length) == -1) goto read_error;
event_buffer->osize = length;
if (type == -1) append_received_config_chunk(event_buffer, length); if (type == -1) append_received_config_chunk(event_buffer->obuf, length);
if (type == -2) verify_config(); if (type == -2) verify_config();
if (type == -1 || type == -2) goto again; if (type == -1 || type == -2) goto again;
#ifdef T_SEND_TIME #ifdef T_SEND_TIME
return new_event(t, type, length, event_buffer, database); return new_event(t, type, length, event_buffer->obuf, database);
#else #else
return new_event(type, length, event_buffer, database); return new_event(type, length, event_buffer->obuf, database);
#endif #endif
read_error: read_error:
......
#ifndef _EVENT_H_ #ifndef _EVENT_H_
#define _EVENT_H_ #define _EVENT_H_
#include "utils.h"
#include "../T_defs.h" #include "../T_defs.h"
#ifdef T_SEND_TIME #ifdef T_SEND_TIME
#include <time.h> #include <time.h>
...@@ -37,7 +38,7 @@ typedef struct { ...@@ -37,7 +38,7 @@ typedef struct {
int ecount; int ecount;
} event; } event;
event get_event(int s, char *v, void *d); event get_event(int s, OBUF *v, void *d);
#ifdef T_SEND_TIME #ifdef T_SEND_TIME
event new_event(struct timespec sending_time, int type, event new_event(struct timespec sending_time, int type,
......
...@@ -99,10 +99,11 @@ int main(int n, char **v) ...@@ -99,10 +99,11 @@ int main(int n, char **v)
found = 0; found = 0;
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
while (1) { while (1) {
char v[T_BUFFER_MAX];
event e; event e;
e = get_event(fd, v, database); e = get_event(fd, &ebuf, database);
if (e.type == -1) break; if (e.type == -1) break;
if (e.type != input_event_id) continue; if (e.type != input_event_id) continue;
for (i = 0; i < filter_count; i++) for (i = 0; i < filter_count; i++)
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "utils.h"
#include "../T_defs.h" #include "../T_defs.h"
void usage(void) void usage(void)
...@@ -35,14 +36,22 @@ int main(int n, char **v) ...@@ -35,14 +36,22 @@ int main(int n, char **v)
in = fopen(input_filename, "r"); in = fopen(input_filename, "r");
if (in == NULL) { perror(input_filename); abort(); } if (in == NULL) { perror(input_filename); abort(); }
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
while (1) { while (1) {
int type; int type;
int32_t length; int32_t length;
char v[T_BUFFER_MAX]; char *v;
int vpos = 0; int vpos = 0;
/* read event from file */ /* read event from file */
if (fread(&length, 4, 1, in) != 1) break; if (fread(&length, 4, 1, in) != 1) break;
if (ebuf.omaxsize < length) {
ebuf.omaxsize = (length + 65535) & ~65535;
ebuf.obuf = realloc(ebuf.obuf, ebuf.omaxsize);
if (ebuf.obuf == NULL) { printf("out of memory\n"); exit(1); }
}
v = ebuf.obuf;
memcpy(v+vpos, &length, 4); memcpy(v+vpos, &length, 4);
vpos += 4; vpos += 4;
#ifdef T_SEND_TIME #ifdef T_SEND_TIME
......
...@@ -104,11 +104,12 @@ err: ...@@ -104,11 +104,12 @@ err:
fd = open(file, O_RDONLY); fd = open(file, O_RDONLY);
if (fd == -1) { perror(file); exit(1); } if (fd == -1) { perror(file); exit(1); }
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
/* get wanted frame/subframe */ /* get wanted frame/subframe */
while (1) { while (1) {
char v[T_BUFFER_MAX];
event e; event e;
e = get_event(fd, v, database); e = get_event(fd, &ebuf, database);
if (e.type == -1) break; if (e.type == -1) break;
if (e.type != input_event_id) continue; if (e.type != input_event_id) continue;
if (verbose) if (verbose)
......
...@@ -100,10 +100,12 @@ err: ...@@ -100,10 +100,12 @@ err:
int last_frame = -1; int last_frame = -1;
int last_subframe = -1; int last_subframe = -1;
int subframe_written = 0; int subframe_written = 0;
OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL };
while (1) { while (1) {
char v[T_BUFFER_MAX];
event e; event e;
e = get_event(fd, v, database); e = get_event(fd, &ebuf, database);
if (e.type == -1) break; if (e.type == -1) break;
if (e.type != output_event_id) continue; if (e.type != output_event_id) continue;
if (verbose) if (verbose)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment