Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
0003 
0004 #ifndef _QTN_FMAC_QLINK_UTIL_H_
0005 #define _QTN_FMAC_QLINK_UTIL_H_
0006 
0007 #include <linux/types.h>
0008 #include <linux/skbuff.h>
0009 #include <net/cfg80211.h>
0010 
0011 #include "qlink.h"
0012 
0013 static inline void
0014 qtnf_cmd_skb_put_buffer(struct sk_buff *skb, const u8 *buf_src, size_t len)
0015 {
0016     skb_put_data(skb, buf_src, len);
0017 }
0018 
0019 static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb,
0020                         u16 tlv_id, const u8 arr[],
0021                         size_t arr_len)
0022 {
0023     struct qlink_tlv_hdr *hdr;
0024 
0025     hdr = skb_put(skb, sizeof(*hdr) + round_up(arr_len, QLINK_ALIGN));
0026     hdr->type = cpu_to_le16(tlv_id);
0027     hdr->len = cpu_to_le16(arr_len);
0028     memcpy(hdr->val, arr, arr_len);
0029 }
0030 
0031 static inline void qtnf_cmd_skb_put_tlv_u32(struct sk_buff *skb,
0032                         u16 tlv_id, u32 value)
0033 {
0034     struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
0035     __le32 tmp = cpu_to_le32(value);
0036 
0037     hdr->type = cpu_to_le16(tlv_id);
0038     hdr->len = cpu_to_le16(sizeof(value));
0039     memcpy(hdr->val, &tmp, sizeof(tmp));
0040 }
0041 
0042 u16 qlink_iface_type_to_nl_mask(u16 qlink_type);
0043 u8 qlink_chan_width_mask_to_nl(u16 qlink_mask);
0044 void qlink_chandef_q2cfg(struct wiphy *wiphy,
0045              const struct qlink_chandef *qch,
0046              struct cfg80211_chan_def *chdef);
0047 void qlink_chandef_cfg2q(const struct cfg80211_chan_def *chdef,
0048              struct qlink_chandef *qch);
0049 enum qlink_hidden_ssid qlink_hidden_ssid_nl2q(enum nl80211_hidden_ssid nl_val);
0050 bool qtnf_utils_is_bit_set(const u8 *arr, unsigned int bit,
0051                unsigned int arr_max_len);
0052 void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl,
0053               struct qlink_acl_data *qacl);
0054 enum qlink_band qlink_utils_band_cfg2q(enum nl80211_band band);
0055 enum qlink_dfs_state qlink_utils_dfs_state_cfg2q(enum nl80211_dfs_state state);
0056 u32 qlink_utils_chflags_cfg2q(u32 cfgflags);
0057 void qlink_utils_regrule_q2nl(struct ieee80211_reg_rule *rule,
0058                   const struct qlink_tlv_reg_rule *tlv_rule);
0059 
0060 #define qlink_for_each_tlv(_tlv, _start, _datalen)          \
0061     for (_tlv = (const struct qlink_tlv_hdr *)(_start);     \
0062          (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >=    \
0063         (int)sizeof(*_tlv) &&                   \
0064          (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >=    \
0065         (int)sizeof(*_tlv) + le16_to_cpu(_tlv->len);        \
0066          _tlv = (const struct qlink_tlv_hdr *)(_tlv->val +      \
0067         round_up(le16_to_cpu(_tlv->len), QLINK_ALIGN)))
0068 
0069 #define qlink_tlv_parsing_ok(_tlv_last, _start, _datalen)   \
0070     ((const u8 *)(_tlv_last) == \
0071         (const u8 *)(_start) + round_up(_datalen, QLINK_ALIGN))
0072 
0073 #endif /* _QTN_FMAC_QLINK_UTIL_H_ */