xref: /wlan-dirver/qca-wifi-host-cmn/os_if/linux/wlan_cfg80211.h (revision 11f5a63a6cbdda84849a730de22f0a71e635d58c)
1 /*
2  * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: declares driver functions interfacing with linux kernel
21  */
22 
23 
24 #ifndef _WLAN_CFG80211_H_
25 #define _WLAN_CFG80211_H_
26 
27 #include <linux/version.h>
28 #include <linux/netdevice.h>
29 #include <net/netlink.h>
30 #include <net/cfg80211.h>
31 #include <qca_vendor.h>
32 
33 #define osif_alert(params...) \
34 	QDF_TRACE_FATAL(QDF_MODULE_ID_OS_IF, params)
35 #define osif_err(params...) \
36 	QDF_TRACE_ERROR(QDF_MODULE_ID_OS_IF, params)
37 #define osif_warn(params...) \
38 	QDF_TRACE_WARN(QDF_MODULE_ID_OS_IF, params)
39 #define osif_notice(params...) \
40 	QDF_TRACE_INFO(QDF_MODULE_ID_OS_IF, params)
41 #define osif_info(params...) \
42 	QDF_TRACE_INFO(QDF_MODULE_ID_OS_IF, params)
43 #define osif_debug(params...) \
44 	QDF_TRACE_DEBUG(QDF_MODULE_ID_OS_IF, params)
45 #define osif_rl_debug(params...) \
46 	QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_OS_IF, params)
47 
48 #define osif_nofl_alert(params...) \
49 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_OS_IF, params)
50 #define osif_nofl_err(params...) \
51 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_OS_IF, params)
52 #define osif_nofl_warn(params...) \
53 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_OS_IF, params)
54 #define osif_nofl_info(params...) \
55 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_OS_IF, params)
56 #define osif_nofl_debug(params...) \
57 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_OS_IF, params)
58 
59 #undef nla_parse
60 #undef nla_parse_nested
61 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
62 static inline int wlan_cfg80211_nla_parse(struct nlattr **tb,
63 					  int maxtype,
64 					  const struct nlattr *head,
65 					  int len,
66 					  const struct nla_policy *policy)
67 {
68 	return nla_parse(tb, maxtype, head, len, policy);
69 }
70 
71 static inline int
72 wlan_cfg80211_nla_parse_nested(struct nlattr *tb[],
73 			       int maxtype,
74 			       const struct nlattr *nla,
75 			       const struct nla_policy *policy)
76 {
77 	return nla_parse_nested(tb, maxtype, nla, policy);
78 }
79 #else
80 static inline int wlan_cfg80211_nla_parse(struct nlattr **tb,
81 					  int maxtype,
82 					  const struct nlattr *head,
83 					  int len,
84 					  const struct nla_policy *policy)
85 {
86 	return nla_parse(tb, maxtype, head, len, policy, NULL);
87 }
88 
89 static inline int
90 wlan_cfg80211_nla_parse_nested(struct nlattr *tb[],
91 			       int maxtype,
92 			       const struct nlattr *nla,
93 			       const struct nla_policy *policy)
94 {
95 	return nla_parse_nested(tb, maxtype, nla, policy, NULL);
96 }
97 #endif
98 #define nla_parse(...) (obsolete, use wlan_cfg80211_nla_parse)
99 #define nla_parse_nested(...) (obsolete, use wlan_cfg80211_nla_parse_nested)
100 
101 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0))
102 static inline int
103 wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
104 {
105 	return nla_put_u64(skb, attrtype, value);
106 }
107 #else
108 static inline int
109 wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)
110 {
111 	return nla_put_u64_64bit(skb, attrtype, value, NL80211_ATTR_PAD);
112 }
113 #endif
114 
115 #endif
116