From: Viktor Barna <viktor.barna@xxxxxxxxxx> (Part of the split. Please, take a look at the cover letter for more details). Signed-off-by: Viktor Barna <viktor.barna@xxxxxxxxxx> --- .../net/wireless/celeno/cl8k/maintenance.c | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 drivers/net/wireless/celeno/cl8k/maintenance.c 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)); +} -- 2.36.1