From f2b1a193df0901dbaf4651c4c6442ca36e701f41 Mon Sep 17 00:00:00 2001 From: ismagom Date: Tue, 30 Jun 2015 18:02:36 +0200 Subject: [PATCH] Added MAC execution time traces. Increased preamble length to 0.4 ms --- matlab/common/read_trace_uint.m | 2 +- srsapps/common/include/srsapps/common/trace.h | 2 +- .../radio/include/srsapps/radio/radio_uhd.h | 2 +- srsapps/ue/mac/include/srsapps/ue/mac/mac.h | 12 ++++-- srsapps/ue/mac/src/mac.cc | 43 ++++++++++++++++--- 5 files changed, 50 insertions(+), 11 deletions(-) diff --git a/matlab/common/read_trace_uint.m b/matlab/common/read_trace_uint.m index cdaeea99a..b383798e7 100644 --- a/matlab/common/read_trace_uint.m +++ b/matlab/common/read_trace_uint.m @@ -1,4 +1,4 @@ -function [ tti, values ] = read_trace_uint( filename, count ) +function [ values, tti] = read_trace_uint( filename, count ) [tidin msg]=fopen(filename,'r'); if (tidin==-1) diff --git a/srsapps/common/include/srsapps/common/trace.h b/srsapps/common/include/srsapps/common/trace.h index af0f52a9b..bb48583d3 100644 --- a/srsapps/common/include/srsapps/common/trace.h +++ b/srsapps/common/include/srsapps/common/trace.h @@ -69,7 +69,7 @@ public: if (st >= nof_elems) { st=0; } - } while(ston RF transition time) + static const double burst_settle_time = 0.4e-3; // Start of burst settle time (off->on RF transition time) const static uint32_t burst_settle_max_samples = 30720000; // 30.72 MHz is maximum frequency srslte_timestamp_t end_of_burst_time; diff --git a/srsapps/ue/mac/include/srsapps/ue/mac/mac.h b/srsapps/ue/mac/include/srsapps/ue/mac/mac.h index e6b3c8f83..5b1e74f02 100644 --- a/srsapps/ue/mac/include/srsapps/ue/mac/mac.h +++ b/srsapps/ue/mac/include/srsapps/ue/mac/mac.h @@ -60,7 +60,7 @@ typedef _Complex float cf_t; class mac : public timer_callback { public: - mac() : timers_db((uint32_t) NOF_MAC_TIMERS), tr_end_time(1024*10), tr_start_time(1024*10) {started=false; pcap = NULL; } + mac() : timers_db((uint32_t) NOF_MAC_TIMERS), tr_exec_total(1024*10), tr_exec_dl(1024*10), tr_exec_ul(1024*10) {started=false; pcap = NULL; } bool init(phy *phy_h, tti_sync *ttisync, log *log_h); void stop(); int get_tti(); @@ -156,12 +156,18 @@ private: mac_pcap* pcap; // Variables for Execution time Trace - trace tr_start_time; - trace tr_end_time; + trace tr_exec_total; + trace tr_exec_dl; + trace tr_exec_ul; + struct timeval tr_time_total[3]; + struct timeval tr_time_ul[3]; + struct timeval tr_time_dl[3]; bool tr_enabled; bool is_first_of_burst; void tr_log_start(uint32_t tti); void tr_log_end(uint32_t tti); + void tr_log_dl(uint32_t tti); + void tr_log_ul(uint32_t tti); void set_phy_crnti(uint16_t phy_rnti); }; diff --git a/srsapps/ue/mac/src/mac.cc b/srsapps/ue/mac/src/mac.cc index b93e2ccab..6e9d30191 100644 --- a/srsapps/ue/mac/src/mac.cc +++ b/srsapps/ue/mac/src/mac.cc @@ -96,21 +96,49 @@ void mac::start_trace() void mac::write_trace(std::string filename) { - tr_start_time.writeToBinary(filename + ".start"); - tr_end_time.writeToBinary(filename + ".end"); + tr_exec_total.writeToBinary(filename + ".total"); + tr_exec_dl.writeToBinary(filename + ".dl"); + tr_exec_ul.writeToBinary(filename + ".ul"); } void mac::tr_log_start(uint32_t tti) { if (tr_enabled) { - tr_start_time.push_cur_time_us(tti); + gettimeofday(&tr_time_total[1], NULL); } } void mac::tr_log_end(uint32_t tti) { if (tr_enabled) { - tr_end_time.push_cur_time_us(tti); + /* compute total execution time */ + gettimeofday(&tr_time_total[2], NULL); + get_time_interval(tr_time_total); + tr_exec_total.push(tti, tr_time_total[0].tv_usec); + + /* ul execution time is from the call to tr_log_ul */ + memcpy(&tr_time_ul[2], &tr_time_total[2], sizeof(struct timeval)); + get_time_interval(tr_time_ul); + tr_exec_ul.push(tti, tr_time_ul[0].tv_usec); + } +} + +void mac::tr_log_ul(uint32_t tti) +{ + if (tr_enabled) { + /* DL execution time is from the call to tr_log_dl to the call to tr_log_ul */ + gettimeofday(&tr_time_dl[2], NULL); + get_time_interval(tr_time_dl); + tr_exec_dl.push(tti, tr_time_dl[0].tv_usec); + + memcpy(&tr_time_ul[1], &tr_time_dl[2], sizeof(struct timeval)); + } +} + +void mac::tr_log_dl(uint32_t tti) +{ + if (tr_enabled) { + gettimeofday(&tr_time_dl[1], NULL); } } @@ -204,7 +232,6 @@ void mac::main_radio_loop() { } if (is_synchronized) { /* Warning: Here order of invocation of procedures is important!! */ - tr_log_end(tti); tti = ttisync->wait(); tr_log_start(tti); log_h->step(tti); @@ -236,6 +263,8 @@ void mac::main_radio_loop() { // Receive PCH, if requested receive_pch(tti); + tr_log_dl(tti); + // Process DL grants always process_dl_grants(tti); @@ -247,6 +276,8 @@ void mac::main_radio_loop() { dl_harq.send_pending_ack_contention_resolution(); } } + + tr_log_ul(tti); // Process UL grants if RA procedure is done and we have pending data or in contention resolution if (ra_procedure.is_contention_resolution() || ra_procedure.is_successful()) { @@ -279,6 +310,8 @@ void mac::main_radio_loop() { } } + tr_log_end(tti); + timers_db.step_all(); // Check if there is pending CCCH SDU in Multiplexing Unit