diff mbox series

[RFC,v1,230/256] cl8k: add utils/utils.h

Message ID 20210617160223.160998-231-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, 4:01 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/utils/utils.h    | 104 ++++++++++++++++++
 1 file changed, 104 insertions(+)
 create mode 100644 drivers/net/wireless/celeno/cl8k/utils/utils.h

--
2.30.0
diff mbox series

Patch

diff --git a/drivers/net/wireless/celeno/cl8k/utils/utils.h b/drivers/net/wireless/celeno/cl8k/utils/utils.h
new file mode 100644
index 000000000000..d08cb23513ef
--- /dev/null
+++ b/drivers/net/wireless/celeno/cl8k/utils/utils.h
@@ -0,0 +1,104 @@ 
+/* SPDX-License-Identifier: MIT */
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#ifndef CL_UTILS_H
+#define CL_UTILS_H
+
+#include "hw.h"
+#include "vendor_cmd.h"
+#include "vif.h"
+#include "ipc_shared.h"
+#include "ieee80211_i.h"
+
+static const u8 tid_to_ac[] = {
+       AC_BE, AC_BK, AC_BK, AC_BE, AC_VI, AC_VI, AC_VO, AC_VO
+};
+
+static inline struct cl_vif *NETDEV_TO_CL_VIF(struct net_device *dev)
+{
+       struct ieee80211_sub_if_data *sdata = netdev_priv(dev);
+
+       return (struct cl_vif *)(sdata->vif.drv_priv);
+}
+
+static inline struct cl_hw *NETDEV_TO_CL_HW(struct net_device *dev)
+{
+       struct ieee80211_sub_if_data *sdata = netdev_priv(dev);
+
+       return sdata->local->hw.priv;
+}
+
+static inline struct cl_hw *WIPHY_TO_CL_HW(struct wiphy *wiphy)
+{
+       struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+
+       return (struct cl_hw *)hw->priv;
+}
+
+void cl_hex_dump(char *caption, u8 *buffer, u32 length, u32 offset, bool is_byte);
+
+bool cl_is_valid_auth_mode(bool wpa_ie, u8 auth_mode);
+bool cl_is_open_auth_mode(u8 auth_mode);
+u8 convert_gi_format_wrs_to_fw(u8 wrs_mode, u8 gi);
+u8 convert_gi_format_fw_to_wrs(u8 format_mode, u8 gi);
+u8 cl_map_gi_to_ltf(u8 mode, u8 gi);
+
+s8 cl_calc_noise_floor(struct cl_hw *cl_hw, const s8 *reg_noise_floor);
+
+u8 cl_convert_signed_to_reg_value(s8 val);
+
+u8 width_to_bw(enum nl80211_chan_width width);
+enum nl80211_chan_width bw_to_width(u8 bw);
+u64 cl_get_tsf_u64(struct cl_hw *cl_hw);
+
+u8 cl_center_freq_offset(u8 bw);
+
+u8 max_bw_idx(u8 wrs_mode, bool is_24g);
+
+bool cl_hw_mode_is_b_or_bg(struct cl_hw *cl_hw);
+
+void cl_snprintf(char **buf, int *offset, size_t *size, const char *fmt, ...);
+
+bool cl_is_eapol(struct sk_buff *skb);
+
+static inline bool cl_are_host_bytes_le(void)
+{
+#ifdef __LITTLE_ENDIAN
+       return true;
+#else
+       return false;
+#endif /* __LITTLE_ENDIAN */
+}
+
+/* Most likely, bit endianess is the same as the byte endianess, but turn on
+ * paranoid mode and check separately */
+static inline bool cl_are_host_bits_le(void)
+{
+#ifdef __LITTLE_ENDIAN_BITFIELD
+       return true;
+#else
+       return false;
+#endif /* __LITTLE_ENDIAN_BITFIELD */
+}
+
+/* We could inverse *_le checks here, but the motivation is the, as per bits
+ * endianess - anyway, it is better to check */
+static inline bool cl_are_host_bytes_be(void)
+{
+#ifdef __BIG_ENDIAN
+       return true;
+#else
+       return false;
+#endif /* __BIG_ENDIAN */
+}
+
+static inline bool cl_are_host_bits_be(void)
+{
+#ifdef __BIG_ENDIAN_BITFIELD
+       return true;
+#else
+       return false;
+#endif /* __BIG_ENDIAN_BITFIELD */
+}
+
+#endif /* CL_UTILS_H */