Commit c4bf6ff4 authored by Cedric Roux's avatar Cedric Roux

add a FAPI tracer for replay purpose

use --fapi-tracer with build_oai to activate
(basically set FAPI_TRACER to True in CMakeLists.txt)

the file /tmp/fapi.c will be produced at runtime

then cd openair2/LAYER2/MAC and compile fapi_replay.c to replay it
parent 2c4258fd
......@@ -234,6 +234,7 @@ if (${RTAI})
endif (${RTAI})
add_boolean_option(FAPI True "Use FAPI scheduler")
add_boolean_option(FAPI_TRACER False "Activate FAPI tracer (generates /tmp/fapi.c that can be used for replay)")
#############################
# ASN.1 grammar C code generation & dependancies
......@@ -934,6 +935,7 @@ set (MAC_SRC
${MAC_DIR}/pre_processor.c
${MAC_DIR}/config.c
)
if (${FAPI})
set (MAC_SRC ${MAC_SRC}
${MAC_DIR}/ff-mac.c
......@@ -941,6 +943,12 @@ set (MAC_SRC ${MAC_SRC}
)
endif (${FAPI})
if (${FAPI_TRACER})
set (MAC_SRC ${MAC_SRC}
${MAC_DIR}/ffdebug.c
)
endif (${FAPI_TRACER})
set (ENB_APP_SRC
${OPENAIR2_DIR}/ENB_APP/enb_app.c
${OPENAIR2_DIR}/ENB_APP/enb_config.c
......
......@@ -53,6 +53,7 @@ NOS1=0
EPC=0
VERBOSE_COMPILE=0
FAPI="False"
FAPI_TRACER="False"
CFLAGS_PROCESSOR_USER=""
RUN_GROUP=0
TEST_CASE_GROUP=""
......@@ -116,6 +117,8 @@ Options
Shows detailed compilation instructions in makefile
--fapi
Compiles using the FAPI scheduler
--fapi-tracer
Activates FAPI tracer
--cflags_processor
Manually Add CFLAGS of processor if they are not detected correctly by script. Only add these flags if you know your processor supports them. Example flags: -msse3 -msse4.1 -msse4.2 -mavx2
--disable-deadline
......@@ -229,6 +232,10 @@ function main() {
FAPI="True"
echo_info "Will compile with FAPI scheduler"
shift;;
--fapi-tracer)
FAPI_TRACER="True"
echo_info "Will activate the FAPI tracer"
shift;;
--verbose-compile)
VERBOSE_COMPILE=1
echo_info "Will compile with verbose instructions"
......@@ -279,6 +286,13 @@ function main() {
LOWLATENCY_FLAG_USER=$FORCE_LOWLATENCY_FLAG_USER
fi
if [ "$FAPI_TRACER" == "True" ]; then
if [ "$FAPI" == "False" ]; then
echo_error "ERROR: cannot use --fapi-tracer without --fapi"
exit
fi
fi
echo_info "Flags for Deadline scheduler: $LOWLATENCY_FLAG_USER"
############################################
......@@ -367,6 +381,7 @@ function main() {
echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file
echo "set ( RF_BOARD \"${HW}\")" >> $cmake_file
echo "set ( FAPI $FAPI )" >> $cmake_file
echo "set ( FAPI_TRACER $FAPI_TRACER )" >> $cmake_file
echo "set(PACKAGE_NAME \"${lte_exec}\")" >> $cmake_file
echo "set (LOWLATENCY \"${LOWLATENCY_FLAG_USER}\" )" >>$cmake_file
echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
......@@ -498,6 +513,7 @@ function main() {
echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file
echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file
echo "set ( FAPI $FAPI )" >> $cmake_file
echo "set ( FAPI_TRACER $FAPI_TRACER )" >> $cmake_file
echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
[ "$CLEAN" = "1" ] && rm -rf $DIR/$oaisim_build_dir/build
mkdir -p $DIR/$oaisim_build_dir/build
......@@ -564,6 +580,7 @@ function main() {
echo "set(RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file
echo "set(ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file
echo "set ( FAPI $FAPI )" >> $cmake_file
echo "set ( FAPI_TRACER $FAPI_TRACER )" >> $cmake_file
echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
#[ "$CLEAN" = "1" ] && rm -rf $DIR/oaisim_mme_build_oai/build
#mkdir -p $DIR/oaisim_mme_build_oai/build
......
/*
gcc -Wall fapi_replay.c ./libscheduler.a -pthread -lm -g -o fapi_replay
*/
#define MAX_NUM_CCs 2
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "ff-mac.h"
#include "ff-mac-csched-sap.h"
#include "ff-mac-sched-sap.h"
#include "ff-mac-init.h"
#undef CschedCellConfigReq
#undef CschedUeConfigReq
#undef CschedLcConfigReq
#undef CschedLcReleaseReq
#undef CschedUeReleaseReq
#undef SchedDlRlcBufferReq
#undef SchedDlPagingBufferReq
#undef SchedDlMacBufferReq
#undef SchedDlTriggerReq
#undef SchedDlRachInfoReq
#undef SchedDlCqiInfoReq
#undef SchedUlTriggerReq
#undef SchedUlNoiseInterferenceReq
#undef SchedUlSrInfoReq
#undef SchedUlMacCtrlInfoReq
#undef SchedUlCqiInfoReq
int pipe_queue_read;
int pipe_queue_write;
void ok(int x)
{
if (write(pipe_queue_write, &x, sizeof(int)) != sizeof(int)) abort();
}
void wt(int x)
{
int y;
if (read(pipe_queue_read, &y, sizeof(int)) != sizeof(int)) abort();
if (x != y) { printf("possible?\n"); abort(); }
}
enum __ {
e_SchedDlConfigInd,
e_SchedUlConfigInd,
e_CschedCellConfigCnf,
e_CschedUeConfigCnf,
e_CschedLcConfigCnf,
e_CschedLcReleaseCnf,
e_CschedUeReleaseCnf,
e_CschedUeConfigUpdateInd,
e_CschedCellConfigUpdateInd
};
void SchedDlConfigInd(fapi_interface_t *x, struct SchedDlConfigIndParameters* params) { wt(e_SchedDlConfigInd); }
void SchedUlConfigInd(fapi_interface_t *x, struct SchedUlConfigIndParameters* params) { wt(e_SchedUlConfigInd); }
void CschedCellConfigCnf(fapi_interface_t *x, struct CschedCellConfigCnfParameters *params) { wt(e_CschedCellConfigCnf); }
void CschedUeConfigCnf(fapi_interface_t *x, struct CschedUeConfigCnfParameters *params) { wt(e_CschedUeConfigCnf); }
void CschedLcConfigCnf(fapi_interface_t *x, struct CschedLcConfigCnfParameters *params) { wt(e_CschedLcConfigCnf); }
void CschedLcReleaseCnf(fapi_interface_t *x, struct CschedLcReleaseCnfParameters *params) { wt(e_CschedLcReleaseCnf); }
void CschedUeReleaseCnf(fapi_interface_t *x, struct CschedUeReleaseCnfParameters *params) { wt(e_CschedUeReleaseCnf); }
void CschedUeConfigUpdateInd(fapi_interface_t *x, struct CschedUeConfigUpdateIndParameters *params) { wt(e_CschedUeConfigUpdateInd); }
void CschedCellConfigUpdateInd(fapi_interface_t *x, struct CschedCellConfigUpdateIndParameters *params) { wt(e_CschedCellConfigUpdateInd); }
void SchedDlConfigInd_callback(void *callback_data, const struct SchedDlConfigIndParameters *params) { ok(e_SchedDlConfigInd); }
void SchedUlConfigInd_callback(void *callback_data, const struct SchedUlConfigIndParameters *params) { ok(e_SchedUlConfigInd); }
void CschedCellConfigCnf_callback(void *callback_data, const struct CschedCellConfigCnfParameters *params) { ok(e_CschedCellConfigCnf); }
void CschedUeConfigCnf_callback(void *callback_data, const struct CschedUeConfigCnfParameters *params) { ok(e_CschedUeConfigCnf); }
void CschedLcConfigCnf_callback(void *callback_data, const struct CschedLcConfigCnfParameters *params) { ok(e_CschedLcConfigCnf); }
void CschedLcReleaseCnf_callback(void *callback_data, const struct CschedLcReleaseCnfParameters *params) { ok(e_CschedLcReleaseCnf); }
void CschedUeReleaseCnf_callback(void *callback_data, const struct CschedUeReleaseCnfParameters *params) { ok(e_CschedUeReleaseCnf); }
void CschedUeConfigUpdateInd_callback(void *callback_data, const struct CschedUeConfigUpdateIndParameters *params) { abort(); }
void CschedCellConfigUpdateInd_callback(void *callback_data, const struct CschedCellConfigUpdateIndParameters *params) { abort(); }
int main(void)
{
int p[2];
if (pipe(p)) abort();
pipe_queue_read = p[0];
pipe_queue_write = p[1];
void *y;
void * x = SchedInit(&y,
SchedDlConfigInd_callback,
SchedUlConfigInd_callback,
CschedCellConfigCnf_callback,
CschedUeConfigCnf_callback,
CschedLcConfigCnf_callback,
CschedLcReleaseCnf_callback,
CschedUeReleaseCnf_callback,
CschedUeConfigUpdateInd_callback,
CschedCellConfigUpdateInd_callback);
#include "/tmp/fapi.c"
return 0;
}
......@@ -874,6 +874,16 @@ struct CschedCellConfigUpdateIndParameters
//CSCHED SAP MAC->scheduler primitives are defined as callbacks in separate file ff-mac-callback.h
#if FAPI_TRACER
#define CschedCellConfigReq _CschedCellConfigReq
#define CschedUeConfigReq _CschedUeConfigReq
#define CschedLcConfigReq _CschedLcConfigReq
#define CschedLcReleaseReq _CschedLcReleaseReq
#define CschedUeReleaseReq _CschedUeReleaseReq
#endif /* FAPI_TRACER */
#if defined (__cplusplus)
}
#endif
......
......@@ -583,6 +583,22 @@ struct SchedUlConfigIndParameters
// Primitives defined as callbacks in separate file ff-mac-callback.h
#if FAPI_TRACER
#define SchedDlRlcBufferReq _SchedDlRlcBufferReq
#define SchedDlPagingBufferReq _SchedDlPagingBufferReq
#define SchedDlMacBufferReq _SchedDlMacBufferReq
#define SchedDlTriggerReq _SchedDlTriggerReq
#define SchedDlRachInfoReq _SchedDlRachInfoReq
#define SchedDlCqiInfoReq _SchedDlCqiInfoReq
#define SchedUlTriggerReq _SchedUlTriggerReq
#define SchedUlNoiseInterferenceReq _SchedUlNoiseInterferenceReq
#define SchedUlSrInfoReq _SchedUlSrInfoReq
#define SchedUlMacCtrlInfoReq _SchedUlMacCtrlInfoReq
#define SchedUlCqiInfoReq _SchedUlCqiInfoReq
#endif /* FAPI_TRACER */
#if defined (__cplusplus)
}
#endif
......
......@@ -426,6 +426,10 @@ abort();
/* init function */
/************************************************************************/
#if FAPI_TRACER
FILE *Q;
#endif
fapi_interface_t *init_fapi(void)
{
struct fapi *ret;
......@@ -520,5 +524,9 @@ fapi_interface_t *init_fapi(void)
return NULL;
}
#if FAPI_TRACER
Q = fopen("/tmp/fapi.c", "w"); if (Q == NULL) abort();
#endif
return (fapi_interface_t *)ret;
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment