Revert back part of commit
9fa316261d7d9
The function abs_diff was erroneously changed to diff_or_zero.
This function was supposed to measure the difference between rx and
tx time; when rx time overflowed and tx time not yet (i.e.
rx time ~= 0 and tx_time ~=UINT32_MAX, this function added UINT32_MAX
to rx_time. The name of the function was confusing and caused the
previous commit. Net effect of previous commit was that every four seconds
the minimum latency was 0
This commit reverse back to the original behavior, with a function name
diff_time.
Change-Id: Ia1b80e48a756cf5df411dcf58ca1cbc835214d13
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
FILE *fp_tx;
struct prox_port_cfg *port;
};
FILE *fp_tx;
struct prox_port_cfg *port;
};
-
-static uint32_t diff_or_zero(uint32_t a, uint32_t b)
+/* This function calculate the difference between rx and tx_time
+ * Both values are uint32_t (see handle_lat_bulk)
+ * rx time should be higher than tx_time...except every UINT32_MAX
+ * cycles, when rx_time overflows.
+ * As the return value is also uint32_t, returning (rx_time - tx_time)
+ * is also fine when it overflows.
+ */
+static uint32_t diff_time(uint32_t rx_time, uint32_t tx_time)
- return a < b? 0 : a - b;
+ return rx_time - tx_time;
}
struct lat_test *task_lat_get_latency_meassurement(struct task_lat *task)
}
struct lat_test *task_lat_get_latency_meassurement(struct task_lat *task)
static uint64_t lat_info_get_lat_tsc(struct lat_info *lat_info)
{
static uint64_t lat_info_get_lat_tsc(struct lat_info *lat_info)
{
- uint64_t lat = diff_or_zero(lat_info->rx_time, lat_info->tx_time);
+ uint64_t lat = diff_time(lat_info->rx_time, lat_info->tx_time);
return lat << LATENCY_ACCURACY;
}
return lat << LATENCY_ACCURACY;
}
{
if (tx_time == 0)
return;
{
if (tx_time == 0)
return;
- uint32_t lat_tsc = diff_or_zero(rx_time, tx_time) << LATENCY_ACCURACY;
+ uint32_t lat_tsc = diff_time(rx_time, tx_time) << LATENCY_ACCURACY;
lat_test_add_latency(task->lat_test, lat_tsc, rx_error + tx_error);
lat_test_add_latency(task->lat_test, lat_tsc, rx_error + tx_error);