treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / wireless / quantenna / qtnfmac / qlink_util.h
blobf873beed2ae75b34539d50a1ef190c03dcb4c160
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
4 #ifndef _QTN_FMAC_QLINK_UTIL_H_
5 #define _QTN_FMAC_QLINK_UTIL_H_
7 #include <linux/types.h>
8 #include <linux/skbuff.h>
9 #include <net/cfg80211.h>
11 #include "qlink.h"
13 static inline void
14 qtnf_cmd_skb_put_buffer(struct sk_buff *skb, const u8 *buf_src, size_t len)
16 skb_put_data(skb, buf_src, len);
19 static inline void qtnf_cmd_skb_put_tlv_arr(struct sk_buff *skb,
20 u16 tlv_id, const u8 arr[],
21 size_t arr_len)
23 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len);
25 hdr->type = cpu_to_le16(tlv_id);
26 hdr->len = cpu_to_le16(arr_len);
27 memcpy(hdr->val, arr, arr_len);
30 static inline void qtnf_cmd_skb_put_tlv_tag(struct sk_buff *skb, u16 tlv_id)
32 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr));
34 hdr->type = cpu_to_le16(tlv_id);
35 hdr->len = cpu_to_le16(0);
38 static inline void qtnf_cmd_skb_put_tlv_u8(struct sk_buff *skb, u16 tlv_id,
39 u8 value)
41 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
43 hdr->type = cpu_to_le16(tlv_id);
44 hdr->len = cpu_to_le16(sizeof(value));
45 *hdr->val = value;
48 static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb,
49 u16 tlv_id, u16 value)
51 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
52 __le16 tmp = cpu_to_le16(value);
54 hdr->type = cpu_to_le16(tlv_id);
55 hdr->len = cpu_to_le16(sizeof(value));
56 memcpy(hdr->val, &tmp, sizeof(tmp));
59 static inline void qtnf_cmd_skb_put_tlv_u32(struct sk_buff *skb,
60 u16 tlv_id, u32 value)
62 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
63 __le32 tmp = cpu_to_le32(value);
65 hdr->type = cpu_to_le16(tlv_id);
66 hdr->len = cpu_to_le16(sizeof(value));
67 memcpy(hdr->val, &tmp, sizeof(tmp));
70 u16 qlink_iface_type_to_nl_mask(u16 qlink_type);
71 u8 qlink_chan_width_mask_to_nl(u16 qlink_mask);
72 void qlink_chandef_q2cfg(struct wiphy *wiphy,
73 const struct qlink_chandef *qch,
74 struct cfg80211_chan_def *chdef);
75 void qlink_chandef_cfg2q(const struct cfg80211_chan_def *chdef,
76 struct qlink_chandef *qch);
77 enum qlink_hidden_ssid qlink_hidden_ssid_nl2q(enum nl80211_hidden_ssid nl_val);
78 bool qtnf_utils_is_bit_set(const u8 *arr, unsigned int bit,
79 unsigned int arr_max_len);
80 void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl,
81 struct qlink_acl_data *qacl);
82 enum qlink_band qlink_utils_band_cfg2q(enum nl80211_band band);
83 enum qlink_dfs_state qlink_utils_dfs_state_cfg2q(enum nl80211_dfs_state state);
84 u32 qlink_utils_chflags_cfg2q(u32 cfgflags);
85 void qlink_utils_regrule_q2nl(struct ieee80211_reg_rule *rule,
86 const struct qlink_tlv_reg_rule *tlv_rule);
88 #endif /* _QTN_FMAC_QLINK_UTIL_H_ */