1 /* 2 * Copyright (c) 2016-2018 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 cfg80211_log(level, args...) \ 34 QDF_TRACE(QDF_MODULE_ID_OS_IF, level, ## args) 35 #define cfg80211_logfl(level, format, args...) \ 36 cfg80211_log(level, FL(format), ## args) 37 38 #define cfg80211_alert(format, args...) \ 39 cfg80211_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args) 40 #define cfg80211_err(format, args...) \ 41 cfg80211_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args) 42 #define cfg80211_warn(format, args...) \ 43 cfg80211_logfl(QDF_TRACE_LEVEL_WARN, format, ## args) 44 #define cfg80211_notice(format, args...) \ 45 cfg80211_logfl(QDF_TRACE_LEVEL_INFO, format, ## args) 46 #define cfg80211_info(format, args...) \ 47 cfg80211_logfl(QDF_TRACE_LEVEL_INFO_HIGH, format, ## args) 48 #define cfg80211_debug(format, args...) \ 49 cfg80211_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args) 50 51 #define COMMON_VENDOR_COMMANDS \ 52 { \ 53 .info.vendor_id = OUI_QCA, \ 54 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION,\ 55 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \ 56 WIPHY_VENDOR_CMD_NEED_NETDEV, \ 57 .doit = NULL \ 58 }, \ 59 { \ 60 .info.vendor_id = OUI_QCA, \ 61 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_CONFIGURATION,\ 62 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \ 63 WIPHY_VENDOR_CMD_NEED_NETDEV, \ 64 .doit = NULL \ 65 }, 66 67 #undef nla_parse 68 #undef nla_parse_nested 69 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) 70 static inline int wlan_cfg80211_nla_parse(struct nlattr **tb, 71 int maxtype, 72 const struct nlattr *head, 73 int len, 74 const struct nla_policy *policy) 75 { 76 return nla_parse(tb, maxtype, head, len, policy); 77 } 78 79 static inline int 80 wlan_cfg80211_nla_parse_nested(struct nlattr *tb[], 81 int maxtype, 82 const struct nlattr *nla, 83 const struct nla_policy *policy) 84 { 85 return nla_parse_nested(tb, maxtype, nla, policy); 86 } 87 #else 88 static inline int wlan_cfg80211_nla_parse(struct nlattr **tb, 89 int maxtype, 90 const struct nlattr *head, 91 int len, 92 const struct nla_policy *policy) 93 { 94 return nla_parse(tb, maxtype, head, len, policy, NULL); 95 } 96 97 static inline int 98 wlan_cfg80211_nla_parse_nested(struct nlattr *tb[], 99 int maxtype, 100 const struct nlattr *nla, 101 const struct nla_policy *policy) 102 { 103 return nla_parse_nested(tb, maxtype, nla, policy, NULL); 104 } 105 #endif 106 #define nla_parse(...) (obsolete, use wlan_cfg80211_nla_parse) 107 #define nla_parse_nested(...) (obsolete, use wlan_cfg80211_nla_parse_nested) 108 109 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)) 110 static inline int 111 wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value) 112 { 113 return nla_put_u64(skb, attrtype, value); 114 } 115 #else 116 static inline int 117 wlan_cfg80211_nla_put_u64(struct sk_buff *skb, int attrtype, u64 value) 118 { 119 return nla_put_u64_64bit(skb, attrtype, value, NL80211_ATTR_PAD); 120 } 121 #endif 122 123 #endif 124