1 /* 2 * Copyright (c) 2012-2020 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 #ifndef __HDD_TDLS_H 20 #define __HDD_TDLS_H 21 /** 22 * DOC: wlan_hdd_tdls.h 23 * WLAN Host Device Driver TDLS include file 24 */ 25 26 #include "qca_vendor.h" 27 28 struct hdd_context; 29 30 #ifdef FEATURE_WLAN_TDLS 31 32 extern const struct nla_policy 33 wlan_hdd_tdls_mode_configuration_policy 34 [QCA_WLAN_VENDOR_ATTR_TDLS_CONFIG_MAX + 1]; 35 36 #define FEATURE_TDLS_VENDOR_COMMANDS \ 37 { \ 38 .info.vendor_id = QCA_NL80211_VENDOR_ID, \ 39 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_CONFIGURE_TDLS, \ 40 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \ 41 WIPHY_VENDOR_CMD_NEED_NETDEV | \ 42 WIPHY_VENDOR_CMD_NEED_RUNNING, \ 43 .doit = wlan_hdd_cfg80211_configure_tdls_mode, \ 44 vendor_command_policy(wlan_hdd_tdls_mode_configuration_policy, \ 45 QCA_WLAN_VENDOR_ATTR_TDLS_CONFIG_MAX) \ 46 }, \ 47 { \ 48 .info.vendor_id = QCA_NL80211_VENDOR_ID, \ 49 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE, \ 50 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \ 51 WIPHY_VENDOR_CMD_NEED_NETDEV | \ 52 WIPHY_VENDOR_CMD_NEED_RUNNING, \ 53 .doit = wlan_hdd_cfg80211_exttdls_enable, \ 54 vendor_command_policy(VENDOR_CMD_RAW_DATA, 0) \ 55 }, \ 56 { \ 57 .info.vendor_id = QCA_NL80211_VENDOR_ID, \ 58 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE, \ 59 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \ 60 WIPHY_VENDOR_CMD_NEED_NETDEV | \ 61 WIPHY_VENDOR_CMD_NEED_RUNNING, \ 62 .doit = wlan_hdd_cfg80211_exttdls_disable, \ 63 vendor_command_policy(VENDOR_CMD_RAW_DATA, 0) \ 64 }, \ 65 { \ 66 .info.vendor_id = QCA_NL80211_VENDOR_ID, \ 67 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS, \ 68 .flags = WIPHY_VENDOR_CMD_NEED_WDEV | \ 69 WIPHY_VENDOR_CMD_NEED_NETDEV, \ 70 .doit = wlan_hdd_cfg80211_exttdls_get_status, \ 71 vendor_command_policy(VENDOR_CMD_RAW_DATA, 0) \ 72 }, 73 74 /* Bit mask flag for tdls_option to FW */ 75 #define ENA_TDLS_OFFCHAN (1 << 0) /* TDLS Off Channel support */ 76 #define ENA_TDLS_BUFFER_STA (1 << 1) /* TDLS Buffer STA support */ 77 #define ENA_TDLS_SLEEP_STA (1 << 2) /* TDLS Sleep STA support */ 78 79 int wlan_hdd_tdls_get_all_peers(struct hdd_adapter *adapter, char *buf, 80 int buflen); 81 82 int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy, 83 struct wireless_dev *wdev, 84 const void *data, 85 int data_len); 86 87 int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy, 88 struct wireless_dev *wdev, 89 const void *data, 90 int data_len); 91 92 int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy, 93 struct wireless_dev *wdev, 94 const void *data, 95 int data_len); 96 97 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) 98 int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, 99 struct net_device *dev, 100 const uint8_t *peer, 101 enum nl80211_tdls_operation oper); 102 #else 103 int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, 104 struct net_device *dev, 105 uint8_t *peer, 106 enum nl80211_tdls_operation oper); 107 #endif 108 109 #ifdef TDLS_MGMT_VERSION2 110 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, 111 struct net_device *dev, u8 *peer, 112 u8 action_code, u8 dialog_token, 113 u16 status_code, u32 peer_capability, 114 const u8 *buf, size_t len); 115 #else 116 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) 117 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, 118 struct net_device *dev, const uint8_t *peer, 119 uint8_t action_code, uint8_t dialog_token, 120 uint16_t status_code, uint32_t peer_capability, 121 bool initiator, const uint8_t *buf, 122 size_t len); 123 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) 124 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, 125 struct net_device *dev, const uint8_t *peer, 126 uint8_t action_code, uint8_t dialog_token, 127 uint16_t status_code, uint32_t peer_capability, 128 const uint8_t *buf, size_t len); 129 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) 130 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, 131 struct net_device *dev, uint8_t *peer, 132 uint8_t action_code, uint8_t dialog_token, 133 uint16_t status_code, uint32_t peer_capability, 134 const uint8_t *buf, size_t len); 135 #else 136 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, 137 struct net_device *dev, uint8_t *peer, 138 uint8_t action_code, uint8_t dialog_token, 139 uint16_t status_code, const uint8_t *buf, 140 size_t len); 141 #endif 142 #endif 143 144 /** 145 * hdd_set_tdls_offchannel() - set tdls off-channel number 146 * @hdd_ctx: Pointer to the HDD context 147 * @adapter: Pointer to the HDD adapter 148 * @offchannel: tdls off-channel number 149 * 150 * This function sets tdls off-channel number 151 * 152 * Return: 0 on success; negative errno otherwise 153 */ 154 int hdd_set_tdls_offchannel(struct hdd_context *hdd_ctx, 155 struct hdd_adapter *adapter, 156 int offchannel); 157 158 /** 159 * hdd_set_tdls_secoffchanneloffset() - set secondary tdls off-channel offset 160 * @hdd_ctx: Pointer to the HDD context 161 * @adapter: Pointer to the HDD adapter 162 * @offchanoffset: tdls off-channel offset 163 * 164 * This function sets secondary tdls off-channel offset 165 * 166 * Return: 0 on success; negative errno otherwise 167 */ 168 int hdd_set_tdls_secoffchanneloffset(struct hdd_context *hdd_ctx, 169 struct hdd_adapter *adapter, 170 int offchanoffset); 171 172 /** 173 * hdd_set_tdls_offchannelmode() - set tdls off-channel mode 174 * @hdd_ctx: Pointer to the HDD context 175 * @adapter: Pointer to the HDD adapter 176 * @offchanmode: tdls off-channel mode 177 * 1-Enable Channel Switch 178 * 2-Disable Channel Switch 179 * 180 * This function sets tdls off-channel mode 181 * 182 * Return: 0 on success; negative errno otherwise 183 */ 184 int hdd_set_tdls_offchannelmode(struct hdd_context *hdd_ctx, 185 struct hdd_adapter *adapter, 186 int offchanmode); 187 int hdd_set_tdls_scan_type(struct hdd_context *hdd_ctx, int val); 188 int wlan_hdd_tdls_antenna_switch(struct hdd_context *hdd_ctx, 189 struct hdd_adapter *adapter, 190 uint32_t mode); 191 192 /** 193 * wlan_hdd_cfg80211_configure_tdls_mode() - configure tdls mode 194 * @wiphy: pointer to wireless wiphy structure. 195 * @wdev: pointer to wireless_dev structure. 196 * @data: Pointer to the data to be passed via vendor interface 197 * @data_len:Length of the data to be passed 198 * 199 * Return: Return the Success or Failure code. 200 */ 201 int wlan_hdd_cfg80211_configure_tdls_mode(struct wiphy *wiphy, 202 struct wireless_dev *wdev, 203 const void *data, 204 int data_len); 205 206 QDF_STATUS hdd_tdls_register_peer(void *userdata, uint32_t vdev_id, 207 const uint8_t *mac, uint8_t qos); 208 209 /** 210 * hdd_init_tdls_config() - initialize tdls config 211 * @tdls_cfg: pointer to tdls_start_params structure 212 * 213 * Return: none 214 */ 215 void hdd_init_tdls_config(struct tdls_start_params *tdls_cfg); 216 217 /** 218 * hdd_config_tdls_with_band_switch() - configure tdls when band changes 219 * Disable tdls offchmode if only one of 220 * bands is supported 221 * Enable tdls offchmode if all band enable 222 * @hdd_ctx: Pointer to the HDD context 223 * 224 * Return: none 225 */ 226 void hdd_config_tdls_with_band_switch(struct hdd_context *hdd_ctx); 227 #else 228 229 #define FEATURE_TDLS_VENDOR_COMMANDS 230 231 static inline int wlan_hdd_tdls_antenna_switch(struct hdd_context *hdd_ctx, 232 struct hdd_adapter *adapter, 233 uint32_t mode) 234 { 235 return 0; 236 } 237 238 static inline int wlan_hdd_cfg80211_configure_tdls_mode(struct wiphy *wiphy, 239 struct wireless_dev *wdev, 240 const void *data, 241 int data_len) 242 { 243 return 0; 244 } 245 246 static inline 247 QDF_STATUS hdd_tdls_register_peer(void *userdata, uint32_t vdev_id, 248 const uint8_t *mac, uint8_t qos) 249 { 250 return QDF_STATUS_SUCCESS; 251 } 252 253 static inline void hdd_init_tdls_config(struct tdls_start_params *tdls_cfg) 254 { 255 } 256 257 static inline void hdd_config_tdls_with_band_switch(struct hdd_context *hdd_ctx) 258 { 259 } 260 261 #endif /* End of FEATURE_WLAN_TDLS */ 262 #endif /* __HDD_TDLS_H */ 263