From 196abbbea3f2a265902aa02ebd17822efa1d0744 Mon Sep 17 00:00:00 2001 From: Jon Szymaniak Date: Wed, 27 May 2015 18:21:47 -0400 Subject: [PATCH] nios: Time all operations performed by retune handler --- fpga_common/include/nios_pkt_retune.h | 5 ++--- .../software/bladeRF_nios/src/pkt_retune.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/fpga_common/include/nios_pkt_retune.h b/fpga_common/include/nios_pkt_retune.h index 6de07345..3cd34a76 100644 --- a/fpga_common/include/nios_pkt_retune.h +++ b/fpga_common/include/nios_pkt_retune.h @@ -219,7 +219,7 @@ static inline void nios_pkt_retune_unpack(const uint8_t *buf, * +================+=========================================================+ * | 0 | Magic Value | * +----------------+---------------------------------------------------------+ - * | 1 | 64-bit duration denoting how long the retune took to | + * | 1 | 64-bit duration denoting how long the operation took to | * | | complete, in units of timestamp ticks. (Note 1) | * +----------------+---------------------------------------------------------+ * | 9 | Bits [7:6] Reserved, set to 0. | @@ -231,8 +231,7 @@ static inline void nios_pkt_retune_unpack(const uint8_t *buf, * +----------------+---------------------------------------------------------+ * * (Note 1) This value will be zero if timestamps are not running for the - * associated module. This only includes the duration LMS6002D - * retune procedure, not NIOS II message handling overhead. + * associated module. * * (Note 2) Description of Status Flags: * diff --git a/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_retune.c b/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_retune.c index d7cf66ea..a01f7256 100644 --- a/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_retune.c +++ b/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_retune.c @@ -175,9 +175,9 @@ void pkt_retune(struct pkt_buf *b) uint8_t flags; struct lms_freq f; uint64_t timestamp; - uint64_t retune_start; - uint64_t retune_end; - uint64_t retune_duration = 0; + uint64_t start_time; + uint64_t end_time; + uint64_t duration; bool low_band; bool quick_tune; @@ -199,13 +199,13 @@ void pkt_retune(struct pkt_buf *b) f.flags |= LMS_FREQ_FLAGS_FORCE_VCOCAP; } + start_time = time_tamer_read(module); + if (timestamp == NIOS_PKT_RETUNE_NOW) { /* Fire off this retune operation now */ switch (module) { case BLADERF_MODULE_RX: case BLADERF_MODULE_TX: - retune_start = time_tamer_read(module); - status = lms_set_precalculated_frequency(NULL, module, &f); if (status != 0) { goto out; @@ -218,8 +218,6 @@ void pkt_retune(struct pkt_buf *b) goto out; } - retune_end = time_tamer_read(module); - retune_duration = retune_end - retune_start; status = 0; break; @@ -229,7 +227,6 @@ void pkt_retune(struct pkt_buf *b) } else { uint8_t queue_size = enqueue_retune(&f, module); - retune_duration = 0; if (queue_size == QUEUE_FULL) { status = -1; @@ -238,10 +235,13 @@ void pkt_retune(struct pkt_buf *b) } } + end_time = time_tamer_read(module); + duration = end_time - start_time; + out: if (status != 0) { flags &= ~(NIOS_PKT_RETUNERESP_FLAG_SUCCESS); } - nios_pkt_retune_resp_pack(b->resp, retune_duration, f.vcocap_result, flags); + nios_pkt_retune_resp_pack(b->resp, duration, f.vcocap_result, flags); }