summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2018-03-16 04:18:54 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-03-16 04:18:54 +0000
commit2adcda4042d4b20a5df956df854b834aa4d9f2dc (patch)
tree303983f51c2f3717d911bc176c1eff1adf0c39e5
parent883e96028c8dcfe9ceea7911b028953b4776b970 (diff)
parentca950778df863a2408cbec9ba8b6fcbfe9745d76 (diff)
Merge "Fix minimum latency"
-rw-r--r--VNFs/DPPD-PROX/handle_lat.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/VNFs/DPPD-PROX/handle_lat.c b/VNFs/DPPD-PROX/handle_lat.c
index 3962b21..f6ecbf7 100644
--- a/VNFs/DPPD-PROX/handle_lat.c
+++ b/VNFs/DPPD-PROX/handle_lat.c
@@ -115,10 +115,16 @@ struct task_lat {
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)
@@ -257,7 +263,7 @@ static uint64_t lat_latency_buffer_get_min_tsc(struct task_lat *task)
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;
}
@@ -498,7 +504,7 @@ static void task_lat_store_lat(struct task_lat *task, uint64_t rx_packet_index,
{
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);