diff mbox series

[RFC,v1,111/256] cl8k: add maintenance.c

Message ID 20210617160223.160998-112-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 June 17, 2021, 3:59 p.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    | 80 +++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 drivers/net/wireless/celeno/cl8k/maintenance.c

--
2.30.0
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..82c1255b8872
--- /dev/null
+++ b/drivers/net/wireless/celeno/cl8k/maintenance.c
@@ -0,0 +1,80 @@ 
+// SPDX-License-Identifier: MIT
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#include "maintenance.h"
+#include "utils/timer.h"
+#include "traffic.h"
+#include "vns.h"
+#include "reg/reg_access.h"
+#include "sounding.h"
+#include "utils/utils.h"
+#include "sta.h"
+#include "motion_sense.h"
+#include "cca.h"
+#include "noise.h"
+
+static void cl_maintenance_callback_slow(unsigned long data)
+{
+       struct cl_hw *cl_hw = (struct cl_hw *)data;
+
+       cl_cca_maintenance(cl_hw);
+       cl_noise_maintenance(cl_hw);
+
+       if (cl_hw->chip->conf->ce_production_mode)
+               return;
+
+       cl_vns_maintenance(cl_hw);
+
+       if (cl_sta_num(cl_hw) == 0)
+               return;
+
+       cl_motion_sense_maintenance(cl_hw);
+       cl_sounding_maintenance(cl_hw);
+}
+
+static void cl_maintenance_callback_fast(unsigned long data)
+{
+       struct cl_hw *cl_hw = (struct cl_hw *)data;
+
+       if (cl_sta_num(cl_hw) == 0)
+               return;
+
+       cl_traffic_maintenance(cl_hw);
+}
+
+void cl_maintenance_init(struct cl_hw *cl_hw)
+{
+       cl_timer_init(&cl_hw->maintenance_slow_timer,
+                     cl_maintenance_callback_slow,
+                     (unsigned long)cl_hw,
+                     CL_MAINTENANCE_PERIOD_SLOW_MS,
+                     true);
+
+       cl_timer_init(&cl_hw->maintenance_fast_timer,
+                     cl_maintenance_callback_fast,
+                     (unsigned long)cl_hw,
+                     CL_MAINTENANCE_PERIOD_FAST_MS,
+                     true);
+
+       cl_maintenance_start(cl_hw);
+}
+
+void cl_maintenance_close(struct cl_hw *cl_hw)
+{
+       cl_timer_disable_sync(&cl_hw->maintenance_slow_timer);
+       cl_timer_disable_sync(&cl_hw->maintenance_fast_timer);
+}
+
+void cl_maintenance_stop(struct cl_hw *cl_hw)
+{
+       cl_timer_disable(&cl_hw->maintenance_slow_timer);
+       cl_timer_disable(&cl_hw->maintenance_fast_timer);
+}
+
+void cl_maintenance_start(struct cl_hw *cl_hw)
+{
+       cl_timer_enable(&cl_hw->maintenance_slow_timer);
+
+       if (!cl_hw->chip->conf->ce_production_mode)
+               cl_timer_enable(&cl_hw->maintenance_fast_timer);
+}