Commit ae4d721b authored by Cedric Roux's avatar Cedric Roux

integration fix: have a central place of definition for clock_difftime_ns

Prior to this commit, the following command failed to build dlsim:
    ./build_oai --phy_simulators -c

Choice has been made to define it in a .h file as a static inline
function.
parent 1d08e05a
#ifndef _TIME_UTILS_H_
#define _TIME_UTILS_H_
#include <time.h>
#include <stdint.h>
static inline int64_t clock_difftime_ns(struct timespec start, struct timespec end)
{
struct timespec temp;
int64_t temp_ns;
if ((end.tv_nsec-start.tv_nsec)<0) {
temp.tv_sec = end.tv_sec-start.tv_sec-1;
temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
} else {
temp.tv_sec = end.tv_sec-start.tv_sec;
temp.tv_nsec = end.tv_nsec-start.tv_nsec;
}
temp_ns = (int64_t)(temp.tv_sec) * (int64_t)1000000000 + (temp.tv_nsec);
return temp_ns;
}
#endif /* _TIME_UTILS_H_ */
......@@ -33,6 +33,8 @@
#include "PHY/defs.h"
#include "PHY/TOOLS/alaw_lut.h"
#include "time_utils.h"
//#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h"
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
......@@ -83,7 +85,7 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
}
}
clock_gettime( CLOCK_MONOTONIC, &end_comp);
LOG_D(HW,"[SF %d] Compress_Time: %d\n",subframe,clock_difftime_ns(start_comp, end_comp));
LOG_D(HW,"[SF %d] Compress_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_comp, end_comp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_COMPR_IF, 0 );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 1 );
clock_gettime( CLOCK_MONOTONIC, &start_comp);
......@@ -94,7 +96,7 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
fp->nb_antennas_tx,
0);
clock_gettime( CLOCK_MONOTONIC, &end_comp);
LOG_D(HW,"[SF %d] IF_Write_Time: %d\n",subframe,clock_difftime_ns(start_comp, end_comp));
LOG_D(HW,"[SF %d] IF_Write_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_comp, end_comp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 0 );
}
} else if (eth->compression == NO_COMPRESS) {
......@@ -112,7 +114,7 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
fp->nb_antennas_tx,
0);
clock_gettime( CLOCK_MONOTONIC, &end_comp);
LOG_D(HW,"[SF %d] IF_Write_Time: %d\n",subframe,clock_difftime_ns(start_comp, end_comp));
LOG_D(HW,"[SF %d] IF_Write_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_comp, end_comp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 0 );
for (i=0; i < fp->nb_antennas_tx; i++)
txp[i] += spp_eth;
......@@ -140,7 +142,7 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
}
}
clock_gettime( CLOCK_MONOTONIC, &end_comp);
LOG_D(HW,"[SF %d] Compress_Time: %d\n",subframe,clock_difftime_ns(start_comp, end_comp));
LOG_D(HW,"[SF %d] Compress_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_comp, end_comp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_COMPR_IF, 0 );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 1 );
clock_gettime( CLOCK_MONOTONIC, &start_comp);
......@@ -151,7 +153,7 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
fp->nb_antennas_rx,
0);
clock_gettime( CLOCK_MONOTONIC, &end_comp);
LOG_D(HW,"[SF %d] IF_Write_Time: %d\n",subframe,clock_difftime_ns(start_comp, end_comp));
LOG_D(HW,"[SF %d] IF_Write_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_comp, end_comp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 0 );
}
} else if (eth->compression == NO_COMPRESS) {
......@@ -169,7 +171,7 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
fp->nb_antennas_rx,
0);
clock_gettime( CLOCK_MONOTONIC, &end_comp);
LOG_D(HW,"[SF %d] IF_Write_Time: %d\n",subframe,clock_difftime_ns(start_comp, end_comp));
LOG_D(HW,"[SF %d] IF_Write_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_comp, end_comp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_IF, 0 );
for (i=0; i < fp->nb_antennas_rx; i++)
rxp[i] += spp_eth;
......@@ -291,7 +293,7 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
fp->nb_antennas_tx);
clock_gettime( CLOCK_MONOTONIC, &end_decomp);
LOG_D(HW,"[SF %d] IF_Read_Time: %d\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
LOG_D(HW,"[SF %d] IF_Read_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 0 );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 1 );
clock_gettime( CLOCK_MONOTONIC, &start_decomp);
......@@ -303,7 +305,7 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
}
}
clock_gettime( CLOCK_MONOTONIC, &end_decomp);
LOG_D(HW,"[SF %d] Decomperss_Time: %d\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
LOG_D(HW,"[SF %d] Decomperss_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 0 );
}
} else if (eth->compression == NO_COMPRESS) {
......@@ -320,7 +322,7 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
spp_eth,
fp->nb_antennas_tx);
clock_gettime( CLOCK_MONOTONIC, &end_decomp);
LOG_D(HW,"[SF %d] IF_Read_Time: %d\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
LOG_D(HW,"[SF %d] IF_Read_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 0 );
for (i=0; i < fp->nb_antennas_tx; i++)
txp[i] += spp_eth;
......@@ -346,7 +348,7 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
spp_eth,
fp->nb_antennas_rx);
clock_gettime( CLOCK_MONOTONIC, &end_decomp);
LOG_D(HW,"[SF %d] IF_Read_Time: %d\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
LOG_D(HW,"[SF %d] IF_Read_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 0 );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 1 );
clock_gettime( CLOCK_MONOTONIC, &start_decomp);
......@@ -358,7 +360,7 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
}
}
clock_gettime( CLOCK_MONOTONIC, &end_decomp);
LOG_D(HW,"[SF %d] Decomperss_Time: %d\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
LOG_D(HW,"[SF %d] Decomperss_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_DECOMPR_IF, 0 );
}
} else if (eth->compression == NO_COMPRESS) {
......@@ -375,7 +377,7 @@ void recv_IF5(PHY_VARS_eNB *eNB, openair0_timestamp *proc_timestamp, int subfram
spp_eth,
fp->nb_antennas_rx);
clock_gettime( CLOCK_MONOTONIC, &end_decomp);
LOG_D(HW,"[SF %d] IF_Read_Time: %d\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
LOG_D(HW,"[SF %d] IF_Read_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ_IF, 0 );
for (i=0; i < fp->nb_antennas_rx; i++)
rxp[i] += spp_eth;
......
......@@ -45,6 +45,8 @@
#include <sys/sysinfo.h>
#include "rt_wrapper.h"
#include "time_utils.h"
#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
#include "assertions.h"
......@@ -170,21 +172,6 @@ extern struct timespec start_fh, start_fh_prev;
extern int start_fh_sf, start_fh_prev_sf;
struct timespec end_fh;
int end_fh_sf;
int clock_difftime_ns(struct timespec start, struct timespec end)
{
struct timespec temp;
int temp_ns;
if ((end.tv_nsec-start.tv_nsec)<0) {
temp.tv_sec = end.tv_sec-start.tv_sec-1;
temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
} else {
temp.tv_sec = end.tv_sec-start.tv_sec;
temp.tv_nsec = end.tv_nsec-start.tv_nsec;
}
temp_ns = (temp.tv_sec) * 1000000000 + (temp.tv_nsec);
return temp_ns;
}
static inline void thread_top_init(char *thread_name,
int affinity,
......@@ -776,7 +763,7 @@ void fh_if5_asynch_DL(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
clock_gettime( CLOCK_MONOTONIC, &end_fh);
end_fh_sf = *subframe;
recv_if_count = recv_if_count + 1;
LOG_D(HW,"[From SF %d to SF %d] RTT_FH: %d\n", start_fh_prev_sf, end_fh_sf, clock_difftime_ns(start_fh_prev, end_fh));
LOG_D(HW,"[From SF %d to SF %d] RTT_FH: %"PRId64"\n", start_fh_prev_sf, end_fh_sf, clock_difftime_ns(start_fh_prev, end_fh));
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF5, 0 );
......@@ -985,8 +972,8 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
end_rf_ts = proc->timestamp_rx+eNB->ts_offset+(tx_sfoffset*fp->samples_per_tti)-openair0_cfg[0].tx_sample_advance;
if (recv_if_count != 0 ) {
recv_if_count = recv_if_count-1;
LOG_D(HW,"[From Timestamp %d to Timestamp %d] RTT_RF: %d; RTT_RF\n", start_rf_prev_ts, end_rf_ts, clock_difftime_ns(start_rf_prev, end_rf));
LOG_D(HW,"[From Timestamp %d to Timestamp %d] RTT_RF: %d; RTT_RF\n",start_rf_prev2_ts, end_rf_ts, clock_difftime_ns(start_rf_prev2, end_rf));
LOG_D(HW,"[From Timestamp %d to Timestamp %d] RTT_RF: %"PRId64"; RTT_RF\n", start_rf_prev_ts, end_rf_ts, clock_difftime_ns(start_rf_prev, end_rf));
LOG_D(HW,"[From Timestamp %d to Timestamp %d] RTT_RF: %"PRId64"; RTT_RF\n",start_rf_prev2_ts, end_rf_ts, clock_difftime_ns(start_rf_prev2, end_rf));
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
......
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