diff mbox series

[RFC,v2,44/96] cl8k: add maintenance.c

Message ID 20220524113502.1094459-45-viktor.barna@celeno.com (mailing list archive)
State RFC
Delegated to: Kalle Valo
Headers show
Series wireless: cl8k driver for Celeno IEEE 802.11ax devices | expand

Commit Message

Viktor Barna May 24, 2022, 11:34 a.m. UTC
From: Viktor Barna <viktor.barna@celeno.com>

(Part of the split. Please, take a look at the cover letter for more
details).

Signed-off-by: Viktor Barna <viktor.barna@celeno.com>
---
 .../net/wireless/celeno/cl8k/maintenance.c    | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 drivers/net/wireless/celeno/cl8k/maintenance.c
diff mbox series

Patch

diff --git a/drivers/net/wireless/celeno/cl8k/maintenance.c b/drivers/net/wireless/celeno/cl8k/maintenance.c
new file mode 100644
index 000000000000..3230757edacc
--- /dev/null
+++ b/drivers/net/wireless/celeno/cl8k/maintenance.c
@@ -0,0 +1,81 @@ 
+// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+/* Copyright(c) 2019-2022, Celeno Communications Ltd. */
+
+#include "maintenance.h"
+#include "traffic.h"
+#include "vns.h"
+#include "reg/reg_access.h"
+#include "sounding.h"
+#include "sta.h"
+#include "motion_sense.h"
+#include "radio.h"
+
+static void cl_maintenance_callback_slow(struct timer_list *t)
+{
+	struct cl_hw *cl_hw = from_timer(cl_hw, t, maintenance_slow_timer);
+
+	cl_cca_maintenance(cl_hw);
+	cl_noise_maintenance(cl_hw);
+
+	if (cl_hw_is_prod_or_listener(cl_hw))
+		goto reschedule_timer;
+
+	cl_vns_maintenance(cl_hw);
+
+	if (cl_hw->conf->ci_traffic_mon_en)
+		cl_sta_loop(cl_hw, cl_traffic_mon_sta_maintenance);
+
+	if (cl_sta_num(cl_hw) == 0)
+		goto reschedule_timer;
+
+	cl_motion_sense_maintenance(cl_hw);
+	cl_sounding_maintenance(cl_hw);
+
+reschedule_timer:
+	mod_timer(&cl_hw->maintenance_slow_timer,
+		  jiffies + msecs_to_jiffies(CL_MAINTENANCE_PERIOD_SLOW_MS));
+}
+
+static void cl_maintenance_callback_fast(struct timer_list *t)
+{
+	struct cl_hw *cl_hw = from_timer(cl_hw, t, maintenance_fast_timer);
+
+	if (cl_sta_num(cl_hw) == 0)
+		goto reschedule_timer;
+
+	cl_traffic_maintenance(cl_hw);
+
+reschedule_timer:
+	mod_timer(&cl_hw->maintenance_fast_timer,
+		  jiffies + msecs_to_jiffies(CL_MAINTENANCE_PERIOD_FAST_MS));
+}
+
+void cl_maintenance_init(struct cl_hw *cl_hw)
+{
+	timer_setup(&cl_hw->maintenance_slow_timer, cl_maintenance_callback_slow, 0);
+	timer_setup(&cl_hw->maintenance_fast_timer, cl_maintenance_callback_fast, 0);
+
+	cl_maintenance_start(cl_hw);
+}
+
+void cl_maintenance_close(struct cl_hw *cl_hw)
+{
+	del_timer_sync(&cl_hw->maintenance_slow_timer);
+	del_timer_sync(&cl_hw->maintenance_fast_timer);
+}
+
+void cl_maintenance_stop(struct cl_hw *cl_hw)
+{
+	del_timer(&cl_hw->maintenance_slow_timer);
+	del_timer(&cl_hw->maintenance_fast_timer);
+}
+
+void cl_maintenance_start(struct cl_hw *cl_hw)
+{
+	mod_timer(&cl_hw->maintenance_slow_timer,
+		  jiffies + msecs_to_jiffies(CL_MAINTENANCE_PERIOD_SLOW_MS));
+
+	if (!cl_hw_is_prod_or_listener(cl_hw))
+		mod_timer(&cl_hw->maintenance_fast_timer,
+			  jiffies + msecs_to_jiffies(CL_MAINTENANCE_PERIOD_FAST_MS));
+}