diff mbox series

[RFC,v1,013/256] cl8k: add band.c

Message ID 20210617160223.160998-14-viktor.barna@celeno.com
State New
Headers show
Series wireless: cl8k driver for Celeno IEEE 802.11ax devices | expand

Commit Message

Viktor Barna June 17, 2021, 3:58 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/band.c | 60 +++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 drivers/net/wireless/celeno/cl8k/band.c

--
2.30.0
diff mbox series

Patch

diff --git a/drivers/net/wireless/celeno/cl8k/band.c b/drivers/net/wireless/celeno/cl8k/band.c
new file mode 100644
index 000000000000..6fc688613a51
--- /dev/null
+++ b/drivers/net/wireless/celeno/cl8k/band.c
@@ -0,0 +1,60 @@ 
+// SPDX-License-Identifier: MIT
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#include "band.h"
+
+bool cl_band_is_6g(struct cl_hw *cl_hw)
+{
+       return (cl_hw->conf->ci_band_num == 6);
+}
+
+bool cl_band_is_6g_freq(u16 freq)
+{
+       return (freq > 5935) ? true : false;
+}
+
+bool cl_band_is_5g(struct cl_hw *cl_hw)
+{
+       return (cl_hw->conf->ci_band_num == 5);
+}
+
+bool cl_band_is_5g_freq(u16 freq)
+{
+       return (freq > 5000 && freq <= 5835) ? true : false;
+}
+
+bool cl_band_is_24g(struct cl_hw *cl_hw)
+{
+       return (cl_hw->conf->ci_band_num == 24);
+}
+
+bool cl_band_is_24g_freq(u16 freq)
+{
+       return (freq < 5000) ? true : false;
+}
+
+u8 cl_band_to_fw_idx(struct cl_hw *cl_hw)
+{
+       if (cl_hw->nl_band == NL80211_BAND_6GHZ)
+               return FW_BAND_6GHZ;
+
+       if (cl_hw->nl_band == NL80211_BAND_5GHZ)
+               return FW_BAND_5GHZ;
+
+       return FW_BAND_2GHZ;
+}
+
+static u8 fw_to_nl_band[FW_BAND_MAX] = {
+       [FW_BAND_6GHZ] = NL80211_BAND_6GHZ,
+       [FW_BAND_5GHZ] = NL80211_BAND_5GHZ,
+       [FW_BAND_2GHZ] = NL80211_BAND_2GHZ,
+};
+
+u8 cl_band_from_fw_idx(u32 phy_band)
+{
+       if (phy_band < FW_BAND_MAX)
+               return fw_to_nl_band[phy_band];
+
+       return FW_BAND_MAX;
+}
+