forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
....@@ -1,18 +1,5 @@
1
-/*
2
- * Copyright (c) 2015-2016 Quantenna Communications, Inc.
3
- * All rights reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU General Public License
7
- * as published by the Free Software Foundation; either version 2
8
- * of the License, or (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- */
1
+/* SPDX-License-Identifier: GPL-2.0+ */
2
+/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
163
174 #ifndef _QTN_FMAC_QLINK_UTIL_H_
185 #define _QTN_FMAC_QLINK_UTIL_H_
....@@ -33,28 +20,19 @@
3320 u16 tlv_id, const u8 arr[],
3421 size_t arr_len)
3522 {
36
- struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + arr_len);
23
+ struct qlink_tlv_hdr *hdr;
3724
25
+ hdr = skb_put(skb, sizeof(*hdr) + round_up(arr_len, QLINK_ALIGN));
3826 hdr->type = cpu_to_le16(tlv_id);
3927 hdr->len = cpu_to_le16(arr_len);
4028 memcpy(hdr->val, arr, arr_len);
4129 }
4230
43
-static inline void qtnf_cmd_skb_put_tlv_u8(struct sk_buff *skb, u16 tlv_id,
44
- u8 value)
31
+static inline void qtnf_cmd_skb_put_tlv_u32(struct sk_buff *skb,
32
+ u16 tlv_id, u32 value)
4533 {
4634 struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
47
-
48
- hdr->type = cpu_to_le16(tlv_id);
49
- hdr->len = cpu_to_le16(sizeof(value));
50
- *hdr->val = value;
51
-}
52
-
53
-static inline void qtnf_cmd_skb_put_tlv_u16(struct sk_buff *skb,
54
- u16 tlv_id, u16 value)
55
-{
56
- struct qlink_tlv_hdr *hdr = skb_put(skb, sizeof(*hdr) + sizeof(value));
57
- __le16 tmp = cpu_to_le16(value);
35
+ __le32 tmp = cpu_to_le32(value);
5836
5937 hdr->type = cpu_to_le16(tlv_id);
6038 hdr->len = cpu_to_le16(sizeof(value));
....@@ -73,5 +51,23 @@
7351 unsigned int arr_max_len);
7452 void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl,
7553 struct qlink_acl_data *qacl);
54
+enum qlink_band qlink_utils_band_cfg2q(enum nl80211_band band);
55
+enum qlink_dfs_state qlink_utils_dfs_state_cfg2q(enum nl80211_dfs_state state);
56
+u32 qlink_utils_chflags_cfg2q(u32 cfgflags);
57
+void qlink_utils_regrule_q2nl(struct ieee80211_reg_rule *rule,
58
+ const struct qlink_tlv_reg_rule *tlv_rule);
59
+
60
+#define qlink_for_each_tlv(_tlv, _start, _datalen) \
61
+ for (_tlv = (const struct qlink_tlv_hdr *)(_start); \
62
+ (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >= \
63
+ (int)sizeof(*_tlv) && \
64
+ (const u8 *)(_start) + (_datalen) - (const u8 *)_tlv >= \
65
+ (int)sizeof(*_tlv) + le16_to_cpu(_tlv->len); \
66
+ _tlv = (const struct qlink_tlv_hdr *)(_tlv->val + \
67
+ round_up(le16_to_cpu(_tlv->len), QLINK_ALIGN)))
68
+
69
+#define qlink_tlv_parsing_ok(_tlv_last, _start, _datalen) \
70
+ ((const u8 *)(_tlv_last) == \
71
+ (const u8 *)(_start) + round_up(_datalen, QLINK_ALIGN))
7672
7773 #endif /* _QTN_FMAC_QLINK_UTIL_H_ */