diff mbox series

[RFC,v1,139/256] cl8k: add prot_mode.c

Message ID 20210617160223.160998-140-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, 4 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>
---
 drivers/net/wireless/celeno/cl8k/prot_mode.c | 53 ++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 drivers/net/wireless/celeno/cl8k/prot_mode.c

--
2.30.0
diff mbox series

Patch

diff --git a/drivers/net/wireless/celeno/cl8k/prot_mode.c b/drivers/net/wireless/celeno/cl8k/prot_mode.c
new file mode 100644
index 000000000000..34e20328772e
--- /dev/null
+++ b/drivers/net/wireless/celeno/cl8k/prot_mode.c
@@ -0,0 +1,53 @@ 
+// SPDX-License-Identifier: MIT
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#include "prot_mode.h"
+#include "fw/msg_tx.h"
+#include <linux/string.h>
+
+void cl_prot_mode_init(struct cl_hw *cl_hw)
+{
+       struct cl_prot_mode *prot_mode = &cl_hw->prot_mode;
+       u8 init = cl_hw->conf->ce_prot_mode;
+
+       prot_mode->current_val = init;
+       prot_mode->default_val = init;
+       prot_mode->dynamic_val = (init != TXL_NO_PROT) ? init : TXL_PROT_RTS;
+}
+
+void cl_prot_mode_set(struct cl_hw *cl_hw, u8 prot_mode_new)
+{
+       struct cl_prot_mode *prot_mode = &cl_hw->prot_mode;
+       struct cl_tcv_conf *conf = cl_hw->conf;
+
+       if (prot_mode->current_val != prot_mode_new) {
+               prot_mode->current_val = prot_mode_new;
+               cl_msg_tx_prot_mode(cl_hw,
+                                   conf->ce_prot_log_nav_en,
+                                   prot_mode_new,
+                                   conf->ce_prot_rate_format,
+                                   conf->ce_prot_rate_mcs,
+                                   conf->ce_prot_rate_pre_type);
+       }
+}
+
+void cl_prot_mode_disable(struct cl_hw *cl_hw)
+{
+       cl_prot_mode_set(cl_hw, TXL_NO_PROT);
+}
+
+void cl_prot_mode_enable(struct cl_hw *cl_hw)
+{
+       cl_prot_mode_set(cl_hw, cl_hw->prot_mode.dynamic_val);
+}
+
+void cl_prot_mode_restore_default(struct cl_hw *cl_hw)
+{
+       cl_prot_mode_set(cl_hw, cl_hw->prot_mode.default_val);
+}
+
+u8 cl_prot_mode_get(struct cl_hw *cl_hw)
+{
+       return cl_hw->prot_mode.current_val;
+}
+