From 9ad19ffdcfdf77baf3abd4fcc933fd3dc8e791a5 Mon Sep 17 00:00:00 2001
From: Murat Sezgin <msezgin@codeaurora.org>
Date: Sat, 20 Jun 2020 09:41:01 -0700
Subject: [qca-nss-ecm] Fix NSS stats request roll over issue

Use the correct timer API to check the next request time
when jiffies wrap happens.

Signed-off-by: Murat Sezgin <msezgin@codeaurora.org>
Change-Id: I18646d28df7e17daeff2986dfe4bd73866d47668
---
 frontends/nss/ecm_nss_ipv4.c | 4 ++--
 frontends/nss/ecm_nss_ipv6.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/frontends/nss/ecm_nss_ipv4.c b/frontends/nss/ecm_nss_ipv4.c
index 3eaf5d8..80e1aee 100644
--- a/frontends/nss/ecm_nss_ipv4.c
+++ b/frontends/nss/ecm_nss_ipv4.c
@@ -2421,10 +2421,10 @@ static void ecm_nss_ipv4_stats_sync_req_work(struct work_struct *work)
 		current_jiffies = jiffies;
 
 		if (time_is_after_jiffies(ecm_nss_ipv4_roll_check_jiffies))  {
-			ecm_nss_ipv4_next_req_time = 0;
+			ecm_nss_ipv4_next_req_time = jiffies + ECM_NSS_IPV4_STATS_SYNC_PERIOD;
 		}
 
-		if (ecm_nss_ipv4_next_req_time > current_jiffies) {
+		if (time_after(ecm_nss_ipv4_next_req_time, current_jiffies)) {
 			msleep_interruptible(jiffies_to_msecs(ecm_nss_ipv4_next_req_time - current_jiffies));
 		}
 		ecm_nss_ipv4_roll_check_jiffies = jiffies;
diff --git a/frontends/nss/ecm_nss_ipv6.c b/frontends/nss/ecm_nss_ipv6.c
index 288dc55..483421e 100644
--- a/frontends/nss/ecm_nss_ipv6.c
+++ b/frontends/nss/ecm_nss_ipv6.c
@@ -2135,10 +2135,10 @@ static void ecm_nss_ipv6_stats_sync_req_work(struct work_struct *work)
 		current_jiffies = jiffies;
 
 		if (time_is_after_jiffies(ecm_nss_ipv6_roll_check_jiffies))  {
-			ecm_nss_ipv6_next_req_time = 0;
+			ecm_nss_ipv6_next_req_time = jiffies + ECM_NSS_IPV6_STATS_SYNC_PERIOD;
 		}
 
-		if (ecm_nss_ipv6_next_req_time > current_jiffies) {
+		if (time_after(ecm_nss_ipv6_next_req_time, current_jiffies)) {
 			msleep_interruptible(jiffies_to_msecs(ecm_nss_ipv6_next_req_time - current_jiffies));
 		}
 		ecm_nss_ipv6_roll_check_jiffies = jiffies;
-- 
cgit v1.1

