Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1 | /* src/prism2/driver/prism2sta.c |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 2 | * |
| 3 | * Implements the station functionality for prism2 |
| 4 | * |
| 5 | * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved. |
| 6 | * -------------------------------------------------------------------- |
| 7 | * |
| 8 | * linux-wlan |
| 9 | * |
| 10 | * The contents of this file are subject to the Mozilla Public |
| 11 | * License Version 1.1 (the "License"); you may not use this file |
| 12 | * except in compliance with the License. You may obtain a copy of |
| 13 | * the License at http://www.mozilla.org/MPL/ |
| 14 | * |
| 15 | * Software distributed under the License is distributed on an "AS |
| 16 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
| 17 | * implied. See the License for the specific language governing |
| 18 | * rights and limitations under the License. |
| 19 | * |
| 20 | * Alternatively, the contents of this file may be used under the |
| 21 | * terms of the GNU Public License version 2 (the "GPL"), in which |
| 22 | * case the provisions of the GPL are applicable instead of the |
| 23 | * above. If you wish to allow the use of your version of this file |
| 24 | * only under the terms of the GPL and not to allow others to use |
| 25 | * your version of this file under the MPL, indicate your decision |
| 26 | * by deleting the provisions above and replace them with the notice |
| 27 | * and other provisions required by the GPL. If you do not delete |
| 28 | * the provisions above, a recipient may use your version of this |
| 29 | * file under either the MPL or the GPL. |
| 30 | * |
| 31 | * -------------------------------------------------------------------- |
| 32 | * |
| 33 | * Inquiries regarding the linux-wlan Open Source project can be |
| 34 | * made directly to: |
| 35 | * |
| 36 | * AbsoluteValue Systems Inc. |
| 37 | * info@linux-wlan.com |
| 38 | * http://www.linux-wlan.com |
| 39 | * |
| 40 | * -------------------------------------------------------------------- |
| 41 | * |
| 42 | * Portions of the development of this software were funded by |
| 43 | * Intersil Corporation as part of PRISM(R) chipset product development. |
| 44 | * |
| 45 | * -------------------------------------------------------------------- |
| 46 | * |
| 47 | * This file implements the module and linux pcmcia routines for the |
| 48 | * prism2 driver. |
| 49 | * |
| 50 | * -------------------------------------------------------------------- |
| 51 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 52 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 53 | #include <linux/module.h> |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 54 | #include <linux/kernel.h> |
| 55 | #include <linux/sched.h> |
| 56 | #include <linux/types.h> |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 57 | #include <linux/slab.h> |
| 58 | #include <linux/wireless.h> |
| 59 | #include <linux/netdevice.h> |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 60 | #include <linux/workqueue.h> |
Moritz Muehlenhoff | ae26230 | 2009-01-21 22:00:45 +0100 | [diff] [blame] | 61 | #include <linux/byteorder/generic.h> |
Ioana Ciornei | 7078db9 | 2015-03-18 15:26:05 +0200 | [diff] [blame] | 62 | #include <linux/etherdevice.h> |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 63 | |
Andrew Elwell | ef1a0ed | 2010-02-18 23:56:12 +0100 | [diff] [blame] | 64 | #include <linux/io.h> |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 65 | #include <linux/delay.h> |
| 66 | #include <asm/byteorder.h> |
| 67 | #include <linux/if_arp.h> |
Moritz Muehlenhoff | 28b17a4 | 2009-01-21 22:00:41 +0100 | [diff] [blame] | 68 | #include <linux/if_ether.h> |
Moritz Muehlenhoff | 7f6e0e4 | 2009-01-25 21:54:55 +0100 | [diff] [blame] | 69 | #include <linux/bitops.h> |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 70 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 71 | #include "p80211types.h" |
| 72 | #include "p80211hdr.h" |
| 73 | #include "p80211mgmt.h" |
| 74 | #include "p80211conv.h" |
| 75 | #include "p80211msg.h" |
| 76 | #include "p80211netdev.h" |
| 77 | #include "p80211req.h" |
| 78 | #include "p80211metadef.h" |
| 79 | #include "p80211metastruct.h" |
| 80 | #include "hfa384x.h" |
| 81 | #include "prism2mgmt.h" |
| 82 | |
Solomon Peachy | e02c69b | 2008-10-29 10:42:59 -0400 | [diff] [blame] | 83 | static char *dev_info = "prism2_usb"; |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 84 | static struct wlandevice *create_wlan(void); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 85 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 86 | int prism2_reset_holdtime = 30; /* Reset hold time in ms */ |
| 87 | int prism2_reset_settletime = 100; /* Reset settle time in ms */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 88 | |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 89 | static int prism2_doreset; /* Do a reset at init? */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 90 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 91 | module_param(prism2_doreset, int, 0644); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 92 | MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization"); |
| 93 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 94 | module_param(prism2_reset_holdtime, int, 0644); |
| 95 | MODULE_PARM_DESC(prism2_reset_holdtime, "reset hold time in ms"); |
| 96 | module_param(prism2_reset_settletime, int, 0644); |
| 97 | MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 98 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 99 | MODULE_LICENSE("Dual MPL/GPL"); |
| 100 | |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 101 | static int prism2sta_open(struct wlandevice *wlandev); |
| 102 | static int prism2sta_close(struct wlandevice *wlandev); |
| 103 | static void prism2sta_reset(struct wlandevice *wlandev); |
| 104 | static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb, |
Edgardo Hames | 93df38e | 2010-07-30 22:51:55 -0300 | [diff] [blame] | 105 | union p80211_hdr *p80211_hdr, |
Edgardo Hames | 51e4896 | 2010-07-31 13:06:52 -0300 | [diff] [blame] | 106 | struct p80211_metawep *p80211_wep); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 107 | static int prism2sta_mlmerequest(struct wlandevice *wlandev, struct p80211msg *msg); |
| 108 | static int prism2sta_getcardinfo(struct wlandevice *wlandev); |
| 109 | static int prism2sta_globalsetup(struct wlandevice *wlandev); |
Sergio Paracuellos | 1906698 | 2016-09-27 19:33:51 +0200 | [diff] [blame] | 110 | static int prism2sta_setmulticast(struct wlandevice *wlandev, |
| 111 | struct net_device *dev); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 112 | |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 113 | static void prism2sta_inf_handover(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 114 | struct hfa384x_InfFrame *inf); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 115 | static void prism2sta_inf_tallies(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 116 | struct hfa384x_InfFrame *inf); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 117 | static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 118 | struct hfa384x_InfFrame *inf); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 119 | static void prism2sta_inf_scanresults(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 120 | struct hfa384x_InfFrame *inf); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 121 | static void prism2sta_inf_chinforesults(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 122 | struct hfa384x_InfFrame *inf); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 123 | static void prism2sta_inf_linkstatus(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 124 | struct hfa384x_InfFrame *inf); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 125 | static void prism2sta_inf_assocstatus(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 126 | struct hfa384x_InfFrame *inf); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 127 | static void prism2sta_inf_authreq(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 128 | struct hfa384x_InfFrame *inf); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 129 | static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 130 | struct hfa384x_InfFrame *inf); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 131 | static void prism2sta_inf_psusercnt(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 132 | struct hfa384x_InfFrame *inf); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 133 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 134 | /* |
| 135 | * prism2sta_open |
| 136 | * |
| 137 | * WLAN device open method. Called from p80211netdev when kernel |
| 138 | * device open (start) method is called in response to the |
| 139 | * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP |
| 140 | * from clear to set. |
| 141 | * |
| 142 | * Arguments: |
| 143 | * wlandev wlan device structure |
| 144 | * |
| 145 | * Returns: |
| 146 | * 0 success |
| 147 | * >0 f/w reported error |
| 148 | * <0 driver reported error |
| 149 | * |
| 150 | * Side effects: |
| 151 | * |
| 152 | * Call context: |
| 153 | * process thread |
| 154 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 155 | static int prism2sta_open(struct wlandevice *wlandev) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 156 | { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 157 | /* We don't currently have to do anything else. |
| 158 | * The setup of the MAC should be subsequently completed via |
| 159 | * the mlme commands. |
| 160 | * Higher layers know we're ready from dev->start==1 and |
| 161 | * dev->tbusy==0. Our rx path knows to pass up received/ |
| 162 | * frames because of dev->flags&IFF_UP is true. |
| 163 | */ |
| 164 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 165 | return 0; |
| 166 | } |
| 167 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 168 | /* |
| 169 | * prism2sta_close |
| 170 | * |
| 171 | * WLAN device close method. Called from p80211netdev when kernel |
| 172 | * device close method is called in response to the |
| 173 | * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP |
| 174 | * from set to clear. |
| 175 | * |
| 176 | * Arguments: |
| 177 | * wlandev wlan device structure |
| 178 | * |
| 179 | * Returns: |
| 180 | * 0 success |
| 181 | * >0 f/w reported error |
| 182 | * <0 driver reported error |
| 183 | * |
| 184 | * Side effects: |
| 185 | * |
| 186 | * Call context: |
| 187 | * process thread |
| 188 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 189 | static int prism2sta_close(struct wlandevice *wlandev) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 190 | { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 191 | /* We don't currently have to do anything else. |
| 192 | * Higher layers know we're not ready from dev->start==0 and |
| 193 | * dev->tbusy==1. Our rx path knows to not pass up received |
| 194 | * frames because of dev->flags&IFF_UP is false. |
| 195 | */ |
| 196 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 197 | return 0; |
| 198 | } |
| 199 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 200 | /* |
| 201 | * prism2sta_reset |
| 202 | * |
| 203 | * Currently not implemented. |
| 204 | * |
| 205 | * Arguments: |
| 206 | * wlandev wlan device structure |
| 207 | * none |
| 208 | * |
| 209 | * Returns: |
| 210 | * nothing |
| 211 | * |
| 212 | * Side effects: |
| 213 | * |
| 214 | * Call context: |
| 215 | * process thread |
| 216 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 217 | static void prism2sta_reset(struct wlandevice *wlandev) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 218 | { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 221 | /* |
| 222 | * prism2sta_txframe |
| 223 | * |
| 224 | * Takes a frame from p80211 and queues it for transmission. |
| 225 | * |
| 226 | * Arguments: |
| 227 | * wlandev wlan device structure |
| 228 | * pb packet buffer struct. Contains an 802.11 |
| 229 | * data frame. |
| 230 | * p80211_hdr points to the 802.11 header for the packet. |
| 231 | * Returns: |
| 232 | * 0 Success and more buffs available |
| 233 | * 1 Success but no more buffs |
| 234 | * 2 Allocation failure |
| 235 | * 4 Buffer full or queue busy |
| 236 | * |
| 237 | * Side effects: |
| 238 | * |
| 239 | * Call context: |
| 240 | * process thread |
| 241 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 242 | static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb, |
Edgardo Hames | 93df38e | 2010-07-30 22:51:55 -0300 | [diff] [blame] | 243 | union p80211_hdr *p80211_hdr, |
Edgardo Hames | 51e4896 | 2010-07-31 13:06:52 -0300 | [diff] [blame] | 244 | struct p80211_metawep *p80211_wep) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 245 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 246 | struct hfa384x *hw = wlandev->priv; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 247 | |
| 248 | /* If necessary, set the 802.11 WEP bit */ |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 249 | if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == |
| 250 | HOSTWEP_PRIVACYINVOKED) { |
Moritz Muehlenhoff | ae26230 | 2009-01-21 22:00:45 +0100 | [diff] [blame] | 251 | p80211_hdr->a3.fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1)); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Aya Mahfouz | 9110e0a | 2015-02-27 14:49:27 +0200 | [diff] [blame] | 254 | return hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 257 | /* |
| 258 | * prism2sta_mlmerequest |
| 259 | * |
| 260 | * wlan command message handler. All we do here is pass the message |
| 261 | * over to the prism2sta_mgmt_handler. |
| 262 | * |
| 263 | * Arguments: |
| 264 | * wlandev wlan device structure |
| 265 | * msg wlan command message |
| 266 | * Returns: |
| 267 | * 0 success |
| 268 | * <0 successful acceptance of message, but we're |
| 269 | * waiting for an async process to finish before |
| 270 | * we're done with the msg. When the asynch |
| 271 | * process is done, we'll call the p80211 |
| 272 | * function p80211req_confirm() . |
| 273 | * >0 An error occurred while we were handling |
| 274 | * the message. |
| 275 | * |
| 276 | * Side effects: |
| 277 | * |
| 278 | * Call context: |
| 279 | * process thread |
| 280 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 281 | static int prism2sta_mlmerequest(struct wlandevice *wlandev, struct p80211msg *msg) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 282 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 283 | struct hfa384x *hw = wlandev->priv; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 284 | |
| 285 | int result = 0; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 286 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 287 | switch (msg->msgcode) { |
| 288 | case DIDmsg_dot11req_mibget: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 289 | pr_debug("Received mibget request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 290 | result = prism2mgmt_mibset_mibget(wlandev, msg); |
| 291 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 292 | case DIDmsg_dot11req_mibset: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 293 | pr_debug("Received mibset request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 294 | result = prism2mgmt_mibset_mibget(wlandev, msg); |
| 295 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 296 | case DIDmsg_dot11req_scan: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 297 | pr_debug("Received scan request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 298 | result = prism2mgmt_scan(wlandev, msg); |
| 299 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 300 | case DIDmsg_dot11req_scan_results: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 301 | pr_debug("Received scan_results request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 302 | result = prism2mgmt_scan_results(wlandev, msg); |
| 303 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 304 | case DIDmsg_dot11req_start: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 305 | pr_debug("Received mlme start request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 306 | result = prism2mgmt_start(wlandev, msg); |
| 307 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 308 | /* |
| 309 | * Prism2 specific messages |
| 310 | */ |
| 311 | case DIDmsg_p2req_readpda: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 312 | pr_debug("Received mlme readpda request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 313 | result = prism2mgmt_readpda(wlandev, msg); |
| 314 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 315 | case DIDmsg_p2req_ramdl_state: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 316 | pr_debug("Received mlme ramdl_state request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 317 | result = prism2mgmt_ramdl_state(wlandev, msg); |
| 318 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 319 | case DIDmsg_p2req_ramdl_write: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 320 | pr_debug("Received mlme ramdl_write request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 321 | result = prism2mgmt_ramdl_write(wlandev, msg); |
| 322 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 323 | case DIDmsg_p2req_flashdl_state: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 324 | pr_debug("Received mlme flashdl_state request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 325 | result = prism2mgmt_flashdl_state(wlandev, msg); |
| 326 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 327 | case DIDmsg_p2req_flashdl_write: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 328 | pr_debug("Received mlme flashdl_write request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 329 | result = prism2mgmt_flashdl_write(wlandev, msg); |
| 330 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 331 | /* |
| 332 | * Linux specific messages |
| 333 | */ |
| 334 | case DIDmsg_lnxreq_hostwep: |
| 335 | break; /* ignore me. */ |
| 336 | case DIDmsg_lnxreq_ifstate: |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 337 | { |
Edgardo Hames | b6bb56e | 2010-08-02 16:20:39 -0300 | [diff] [blame] | 338 | struct p80211msg_lnxreq_ifstate *ifstatemsg; |
Johannes Stadlinger | f9d0175 | 2014-06-19 21:20:20 +0200 | [diff] [blame] | 339 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 340 | pr_debug("Received mlme ifstate request\n"); |
Jannik Becher | 0e21fa4 | 2016-09-23 01:02:10 +0200 | [diff] [blame] | 341 | ifstatemsg = (struct p80211msg_lnxreq_ifstate *)msg; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 342 | result = |
| 343 | prism2sta_ifstate(wlandev, |
| 344 | ifstatemsg->ifstate.data); |
| 345 | ifstatemsg->resultcode.status = |
| 346 | P80211ENUM_msgitem_status_data_ok; |
| 347 | ifstatemsg->resultcode.data = result; |
| 348 | result = 0; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 349 | } |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 350 | break; |
| 351 | case DIDmsg_lnxreq_wlansniff: |
| 352 | pr_debug("Received mlme wlansniff request\n"); |
| 353 | result = prism2mgmt_wlansniff(wlandev, msg); |
| 354 | break; |
| 355 | case DIDmsg_lnxreq_autojoin: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 356 | pr_debug("Received mlme autojoin request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 357 | result = prism2mgmt_autojoin(wlandev, msg); |
| 358 | break; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 359 | case DIDmsg_lnxreq_commsquality:{ |
Edgardo Hames | b6bb56e | 2010-08-02 16:20:39 -0300 | [diff] [blame] | 360 | struct p80211msg_lnxreq_commsquality *qualmsg; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 361 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 362 | pr_debug("Received commsquality request\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 363 | |
Jannik Becher | 0e21fa4 | 2016-09-23 01:02:10 +0200 | [diff] [blame] | 364 | qualmsg = (struct p80211msg_lnxreq_commsquality *)msg; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 365 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 366 | qualmsg->link.status = |
| 367 | P80211ENUM_msgitem_status_data_ok; |
| 368 | qualmsg->level.status = |
| 369 | P80211ENUM_msgitem_status_data_ok; |
| 370 | qualmsg->noise.status = |
| 371 | P80211ENUM_msgitem_status_data_ok; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 372 | |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 373 | qualmsg->link.data = le16_to_cpu(hw->qual.CQ_currBSS); |
| 374 | qualmsg->level.data = le16_to_cpu(hw->qual.ASL_currBSS); |
| 375 | qualmsg->noise.data = le16_to_cpu(hw->qual.ANL_currFC); |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 376 | qualmsg->txrate.data = hw->txrate; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 377 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 378 | break; |
| 379 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 380 | default: |
Vitaly Osipov | 02d9b1e | 2014-05-18 16:59:36 +1000 | [diff] [blame] | 381 | netdev_warn(wlandev->netdev, |
| 382 | "Unknown mgmt request message 0x%08x", |
| 383 | msg->msgcode); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 384 | break; |
| 385 | } |
| 386 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 387 | return result; |
| 388 | } |
| 389 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 390 | /* |
| 391 | * prism2sta_ifstate |
| 392 | * |
| 393 | * Interface state. This is the primary WLAN interface enable/disable |
| 394 | * handler. Following the driver/load/deviceprobe sequence, this |
| 395 | * function must be called with a state of "enable" before any other |
| 396 | * commands will be accepted. |
| 397 | * |
| 398 | * Arguments: |
| 399 | * wlandev wlan device structure |
| 400 | * msgp ptr to msg buffer |
| 401 | * |
| 402 | * Returns: |
| 403 | * A p80211 message resultcode value. |
| 404 | * |
| 405 | * Side effects: |
| 406 | * |
| 407 | * Call context: |
| 408 | * process thread (usually) |
| 409 | * interrupt |
| 410 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 411 | u32 prism2sta_ifstate(struct wlandevice *wlandev, u32 ifstate) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 412 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 413 | struct hfa384x *hw = wlandev->priv; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 414 | u32 result; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 415 | |
| 416 | result = P80211ENUM_resultcode_implementation_failure; |
| 417 | |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 418 | pr_debug("Current MSD state(%d), requesting(%d)\n", |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 419 | wlandev->msdstate, ifstate); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 420 | switch (ifstate) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 421 | case P80211ENUM_ifstate_fwload: |
| 422 | switch (wlandev->msdstate) { |
| 423 | case WLAN_MSD_HWPRESENT: |
| 424 | wlandev->msdstate = WLAN_MSD_FWLOAD_PENDING; |
| 425 | /* |
| 426 | * Initialize the device+driver sufficiently |
| 427 | * for firmware loading. |
| 428 | */ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 429 | result = hfa384x_drvr_start(hw); |
| 430 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 431 | netdev_err(wlandev->netdev, |
chaehyun lim | 613462e | 2015-05-15 22:13:43 +0900 | [diff] [blame] | 432 | "hfa384x_drvr_start() failed,result=%d\n", |
| 433 | (int)result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 434 | result = |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 435 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 436 | wlandev->msdstate = WLAN_MSD_HWPRESENT; |
| 437 | break; |
| 438 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 439 | wlandev->msdstate = WLAN_MSD_FWLOAD; |
| 440 | result = P80211ENUM_resultcode_success; |
| 441 | break; |
| 442 | case WLAN_MSD_FWLOAD: |
| 443 | hfa384x_cmd_initialize(hw); |
| 444 | result = P80211ENUM_resultcode_success; |
| 445 | break; |
| 446 | case WLAN_MSD_RUNNING: |
Vitaly Osipov | 02d9b1e | 2014-05-18 16:59:36 +1000 | [diff] [blame] | 447 | netdev_warn(wlandev->netdev, |
Johannes Stadlinger | 392cdc9 | 2014-06-19 21:20:19 +0200 | [diff] [blame] | 448 | "Cannot enter fwload state from enable state, you must disable first.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 449 | result = P80211ENUM_resultcode_invalid_parameters; |
| 450 | break; |
| 451 | case WLAN_MSD_HWFAIL: |
| 452 | default: |
| 453 | /* probe() had a problem or the msdstate contains |
| 454 | * an unrecognized value, there's nothing we can do. |
| 455 | */ |
| 456 | result = P80211ENUM_resultcode_implementation_failure; |
| 457 | break; |
| 458 | } |
| 459 | break; |
| 460 | case P80211ENUM_ifstate_enable: |
| 461 | switch (wlandev->msdstate) { |
| 462 | case WLAN_MSD_HWPRESENT: |
| 463 | case WLAN_MSD_FWLOAD: |
| 464 | wlandev->msdstate = WLAN_MSD_RUNNING_PENDING; |
| 465 | /* Initialize the device+driver for full |
| 466 | * operation. Note that this might me an FWLOAD to |
| 467 | * to RUNNING transition so we must not do a chip |
| 468 | * or board level reset. Note that on failure, |
| 469 | * the MSD state is set to HWPRESENT because we |
| 470 | * can't make any assumptions about the state |
| 471 | * of the hardware or a previous firmware load. |
| 472 | */ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 473 | result = hfa384x_drvr_start(hw); |
| 474 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 475 | netdev_err(wlandev->netdev, |
chaehyun lim | 613462e | 2015-05-15 22:13:43 +0900 | [diff] [blame] | 476 | "hfa384x_drvr_start() failed,result=%d\n", |
| 477 | (int)result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 478 | result = |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 479 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 480 | wlandev->msdstate = WLAN_MSD_HWPRESENT; |
| 481 | break; |
| 482 | } |
| 483 | |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 484 | result = prism2sta_getcardinfo(wlandev); |
| 485 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 486 | netdev_err(wlandev->netdev, |
chaehyun lim | 613462e | 2015-05-15 22:13:43 +0900 | [diff] [blame] | 487 | "prism2sta_getcardinfo() failed,result=%d\n", |
| 488 | (int)result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 489 | result = |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 490 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 491 | hfa384x_drvr_stop(hw); |
| 492 | wlandev->msdstate = WLAN_MSD_HWPRESENT; |
| 493 | break; |
| 494 | } |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 495 | result = prism2sta_globalsetup(wlandev); |
| 496 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 497 | netdev_err(wlandev->netdev, |
chaehyun lim | 613462e | 2015-05-15 22:13:43 +0900 | [diff] [blame] | 498 | "prism2sta_globalsetup() failed,result=%d\n", |
| 499 | (int)result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 500 | result = |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 501 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 502 | hfa384x_drvr_stop(hw); |
| 503 | wlandev->msdstate = WLAN_MSD_HWPRESENT; |
| 504 | break; |
| 505 | } |
| 506 | wlandev->msdstate = WLAN_MSD_RUNNING; |
| 507 | hw->join_ap = 0; |
| 508 | hw->join_retries = 60; |
| 509 | result = P80211ENUM_resultcode_success; |
| 510 | break; |
| 511 | case WLAN_MSD_RUNNING: |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 512 | /* Do nothing, we're already in this state. */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 513 | result = P80211ENUM_resultcode_success; |
| 514 | break; |
| 515 | case WLAN_MSD_HWFAIL: |
| 516 | default: |
| 517 | /* probe() had a problem or the msdstate contains |
| 518 | * an unrecognized value, there's nothing we can do. |
| 519 | */ |
| 520 | result = P80211ENUM_resultcode_implementation_failure; |
| 521 | break; |
| 522 | } |
| 523 | break; |
| 524 | case P80211ENUM_ifstate_disable: |
| 525 | switch (wlandev->msdstate) { |
| 526 | case WLAN_MSD_HWPRESENT: |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 527 | /* Do nothing, we're already in this state. */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 528 | result = P80211ENUM_resultcode_success; |
| 529 | break; |
| 530 | case WLAN_MSD_FWLOAD: |
| 531 | case WLAN_MSD_RUNNING: |
| 532 | wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING; |
| 533 | /* |
| 534 | * TODO: Shut down the MAC completely. Here a chip |
| 535 | * or board level reset is probably called for. |
| 536 | * After a "disable" _all_ results are lost, even |
| 537 | * those from a fwload. |
| 538 | */ |
| 539 | if (!wlandev->hwremoved) |
| 540 | netif_carrier_off(wlandev->netdev); |
| 541 | |
| 542 | hfa384x_drvr_stop(hw); |
| 543 | |
| 544 | wlandev->macmode = WLAN_MACMODE_NONE; |
| 545 | wlandev->msdstate = WLAN_MSD_HWPRESENT; |
| 546 | result = P80211ENUM_resultcode_success; |
| 547 | break; |
| 548 | case WLAN_MSD_HWFAIL: |
| 549 | default: |
| 550 | /* probe() had a problem or the msdstate contains |
| 551 | * an unrecognized value, there's nothing we can do. |
| 552 | */ |
| 553 | result = P80211ENUM_resultcode_implementation_failure; |
| 554 | break; |
| 555 | } |
| 556 | break; |
| 557 | default: |
| 558 | result = P80211ENUM_resultcode_invalid_parameters; |
| 559 | break; |
| 560 | } |
| 561 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 562 | return result; |
| 563 | } |
| 564 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 565 | /* |
| 566 | * prism2sta_getcardinfo |
| 567 | * |
| 568 | * Collect the NICID, firmware version and any other identifiers |
| 569 | * we'd like to have in host-side data structures. |
| 570 | * |
| 571 | * Arguments: |
| 572 | * wlandev wlan device structure |
| 573 | * |
| 574 | * Returns: |
| 575 | * 0 success |
| 576 | * >0 f/w reported error |
| 577 | * <0 driver reported error |
| 578 | * |
| 579 | * Side effects: |
| 580 | * |
| 581 | * Call context: |
| 582 | * Either. |
| 583 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 584 | static int prism2sta_getcardinfo(struct wlandevice *wlandev) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 585 | { |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 586 | int result = 0; |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 587 | struct hfa384x *hw = wlandev->priv; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 588 | u16 temp; |
| 589 | u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN]; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 590 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 591 | /* Collect version and compatibility info */ |
| 592 | /* Some are critical, some are not */ |
| 593 | /* NIC identity */ |
| 594 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 595 | &hw->ident_nic, |
Sergio Paracuellos | 5f04645 | 2016-09-28 20:18:55 +0200 | [diff] [blame] | 596 | sizeof(struct hfa384x_compident)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 597 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 598 | netdev_err(wlandev->netdev, "Failed to retrieve NICIDENTITY\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 599 | goto failed; |
| 600 | } |
| 601 | |
| 602 | /* get all the nic id fields in host byte order */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 603 | hw->ident_nic.id = le16_to_cpu(hw->ident_nic.id); |
| 604 | hw->ident_nic.variant = le16_to_cpu(hw->ident_nic.variant); |
| 605 | hw->ident_nic.major = le16_to_cpu(hw->ident_nic.major); |
| 606 | hw->ident_nic.minor = le16_to_cpu(hw->ident_nic.minor); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 607 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 608 | netdev_info(wlandev->netdev, "ident: nic h/w: id=0x%02x %d.%d.%d\n", |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 609 | hw->ident_nic.id, hw->ident_nic.major, |
| 610 | hw->ident_nic.minor, hw->ident_nic.variant); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 611 | |
| 612 | /* Primary f/w identity */ |
| 613 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 614 | &hw->ident_pri_fw, |
Sergio Paracuellos | 5f04645 | 2016-09-28 20:18:55 +0200 | [diff] [blame] | 615 | sizeof(struct hfa384x_compident)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 616 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 617 | netdev_err(wlandev->netdev, "Failed to retrieve PRIIDENTITY\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 618 | goto failed; |
| 619 | } |
| 620 | |
| 621 | /* get all the private fw id fields in host byte order */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 622 | hw->ident_pri_fw.id = le16_to_cpu(hw->ident_pri_fw.id); |
| 623 | hw->ident_pri_fw.variant = le16_to_cpu(hw->ident_pri_fw.variant); |
| 624 | hw->ident_pri_fw.major = le16_to_cpu(hw->ident_pri_fw.major); |
| 625 | hw->ident_pri_fw.minor = le16_to_cpu(hw->ident_pri_fw.minor); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 626 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 627 | netdev_info(wlandev->netdev, "ident: pri f/w: id=0x%02x %d.%d.%d\n", |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 628 | hw->ident_pri_fw.id, hw->ident_pri_fw.major, |
| 629 | hw->ident_pri_fw.minor, hw->ident_pri_fw.variant); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 630 | |
| 631 | /* Station (Secondary?) f/w identity */ |
| 632 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 633 | &hw->ident_sta_fw, |
Sergio Paracuellos | 5f04645 | 2016-09-28 20:18:55 +0200 | [diff] [blame] | 634 | sizeof(struct hfa384x_compident)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 635 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 636 | netdev_err(wlandev->netdev, "Failed to retrieve STAIDENTITY\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 637 | goto failed; |
| 638 | } |
| 639 | |
| 640 | if (hw->ident_nic.id < 0x8000) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 641 | netdev_err(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 642 | "FATAL: Card is not an Intersil Prism2/2.5/3\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 643 | result = -1; |
| 644 | goto failed; |
| 645 | } |
| 646 | |
| 647 | /* get all the station fw id fields in host byte order */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 648 | hw->ident_sta_fw.id = le16_to_cpu(hw->ident_sta_fw.id); |
| 649 | hw->ident_sta_fw.variant = le16_to_cpu(hw->ident_sta_fw.variant); |
| 650 | hw->ident_sta_fw.major = le16_to_cpu(hw->ident_sta_fw.major); |
| 651 | hw->ident_sta_fw.minor = le16_to_cpu(hw->ident_sta_fw.minor); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 652 | |
| 653 | /* strip out the 'special' variant bits */ |
Moritz Muehlenhoff | 7f6e0e4 | 2009-01-25 21:54:55 +0100 | [diff] [blame] | 654 | hw->mm_mods = hw->ident_sta_fw.variant & (BIT(14) | BIT(15)); |
Jannik Becher | 0e21fa4 | 2016-09-23 01:02:10 +0200 | [diff] [blame] | 655 | hw->ident_sta_fw.variant &= ~((u16)(BIT(14) | BIT(15))); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 656 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 657 | if (hw->ident_sta_fw.id == 0x1f) { |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 658 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 659 | "ident: sta f/w: id=0x%02x %d.%d.%d\n", |
| 660 | hw->ident_sta_fw.id, hw->ident_sta_fw.major, |
| 661 | hw->ident_sta_fw.minor, hw->ident_sta_fw.variant); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 662 | } else { |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 663 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 664 | "ident: ap f/w: id=0x%02x %d.%d.%d\n", |
| 665 | hw->ident_sta_fw.id, hw->ident_sta_fw.major, |
| 666 | hw->ident_sta_fw.minor, hw->ident_sta_fw.variant); |
Masanari Iida | 1a6dfce | 2014-12-01 00:29:00 +0900 | [diff] [blame] | 667 | netdev_err(wlandev->netdev, "Unsupported Tertiary AP firmware loaded!\n"); |
Solomon Peachy | 5db8dcc | 2008-10-27 11:14:02 -0400 | [diff] [blame] | 668 | goto failed; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | /* Compatibility range, Modem supplier */ |
| 672 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 673 | &hw->cap_sup_mfi, |
Sergio Paracuellos | 65f170c | 2016-09-28 20:18:57 +0200 | [diff] [blame] | 674 | sizeof(struct hfa384x_caplevel)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 675 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 676 | netdev_err(wlandev->netdev, "Failed to retrieve MFISUPRANGE\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 677 | goto failed; |
| 678 | } |
| 679 | |
| 680 | /* get all the Compatibility range, modem interface supplier |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 681 | * fields in byte order |
| 682 | */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 683 | hw->cap_sup_mfi.role = le16_to_cpu(hw->cap_sup_mfi.role); |
| 684 | hw->cap_sup_mfi.id = le16_to_cpu(hw->cap_sup_mfi.id); |
| 685 | hw->cap_sup_mfi.variant = le16_to_cpu(hw->cap_sup_mfi.variant); |
| 686 | hw->cap_sup_mfi.bottom = le16_to_cpu(hw->cap_sup_mfi.bottom); |
| 687 | hw->cap_sup_mfi.top = le16_to_cpu(hw->cap_sup_mfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 688 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 689 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 690 | "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", |
| 691 | hw->cap_sup_mfi.role, hw->cap_sup_mfi.id, |
| 692 | hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom, |
| 693 | hw->cap_sup_mfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 694 | |
| 695 | /* Compatibility range, Controller supplier */ |
| 696 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 697 | &hw->cap_sup_cfi, |
Sergio Paracuellos | 65f170c | 2016-09-28 20:18:57 +0200 | [diff] [blame] | 698 | sizeof(struct hfa384x_caplevel)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 699 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 700 | netdev_err(wlandev->netdev, "Failed to retrieve CFISUPRANGE\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 701 | goto failed; |
| 702 | } |
| 703 | |
| 704 | /* get all the Compatibility range, controller interface supplier |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 705 | * fields in byte order |
| 706 | */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 707 | hw->cap_sup_cfi.role = le16_to_cpu(hw->cap_sup_cfi.role); |
| 708 | hw->cap_sup_cfi.id = le16_to_cpu(hw->cap_sup_cfi.id); |
| 709 | hw->cap_sup_cfi.variant = le16_to_cpu(hw->cap_sup_cfi.variant); |
| 710 | hw->cap_sup_cfi.bottom = le16_to_cpu(hw->cap_sup_cfi.bottom); |
| 711 | hw->cap_sup_cfi.top = le16_to_cpu(hw->cap_sup_cfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 712 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 713 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 714 | "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", |
| 715 | hw->cap_sup_cfi.role, hw->cap_sup_cfi.id, |
| 716 | hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom, |
| 717 | hw->cap_sup_cfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 718 | |
| 719 | /* Compatibility range, Primary f/w supplier */ |
| 720 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 721 | &hw->cap_sup_pri, |
Sergio Paracuellos | 65f170c | 2016-09-28 20:18:57 +0200 | [diff] [blame] | 722 | sizeof(struct hfa384x_caplevel)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 723 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 724 | netdev_err(wlandev->netdev, "Failed to retrieve PRISUPRANGE\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 725 | goto failed; |
| 726 | } |
| 727 | |
| 728 | /* get all the Compatibility range, primary firmware supplier |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 729 | * fields in byte order |
| 730 | */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 731 | hw->cap_sup_pri.role = le16_to_cpu(hw->cap_sup_pri.role); |
| 732 | hw->cap_sup_pri.id = le16_to_cpu(hw->cap_sup_pri.id); |
| 733 | hw->cap_sup_pri.variant = le16_to_cpu(hw->cap_sup_pri.variant); |
| 734 | hw->cap_sup_pri.bottom = le16_to_cpu(hw->cap_sup_pri.bottom); |
| 735 | hw->cap_sup_pri.top = le16_to_cpu(hw->cap_sup_pri.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 736 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 737 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 738 | "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", |
| 739 | hw->cap_sup_pri.role, hw->cap_sup_pri.id, |
| 740 | hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom, |
| 741 | hw->cap_sup_pri.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 742 | |
| 743 | /* Compatibility range, Station f/w supplier */ |
| 744 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 745 | &hw->cap_sup_sta, |
Sergio Paracuellos | 65f170c | 2016-09-28 20:18:57 +0200 | [diff] [blame] | 746 | sizeof(struct hfa384x_caplevel)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 747 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 748 | netdev_err(wlandev->netdev, "Failed to retrieve STASUPRANGE\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 749 | goto failed; |
| 750 | } |
| 751 | |
| 752 | /* get all the Compatibility range, station firmware supplier |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 753 | * fields in byte order |
| 754 | */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 755 | hw->cap_sup_sta.role = le16_to_cpu(hw->cap_sup_sta.role); |
| 756 | hw->cap_sup_sta.id = le16_to_cpu(hw->cap_sup_sta.id); |
| 757 | hw->cap_sup_sta.variant = le16_to_cpu(hw->cap_sup_sta.variant); |
| 758 | hw->cap_sup_sta.bottom = le16_to_cpu(hw->cap_sup_sta.bottom); |
| 759 | hw->cap_sup_sta.top = le16_to_cpu(hw->cap_sup_sta.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 760 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 761 | if (hw->cap_sup_sta.id == 0x04) { |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 762 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 763 | "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", |
| 764 | hw->cap_sup_sta.role, hw->cap_sup_sta.id, |
| 765 | hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom, |
| 766 | hw->cap_sup_sta.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 767 | } else { |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 768 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 769 | "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", |
| 770 | hw->cap_sup_sta.role, hw->cap_sup_sta.id, |
| 771 | hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom, |
| 772 | hw->cap_sup_sta.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | /* Compatibility range, primary f/w actor, CFI supplier */ |
| 776 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 777 | &hw->cap_act_pri_cfi, |
Sergio Paracuellos | 65f170c | 2016-09-28 20:18:57 +0200 | [diff] [blame] | 778 | sizeof(struct hfa384x_caplevel)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 779 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 780 | netdev_err(wlandev->netdev, "Failed to retrieve PRI_CFIACTRANGES\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 781 | goto failed; |
| 782 | } |
| 783 | |
| 784 | /* get all the Compatibility range, primary f/w actor, CFI supplier |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 785 | * fields in byte order |
| 786 | */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 787 | hw->cap_act_pri_cfi.role = le16_to_cpu(hw->cap_act_pri_cfi.role); |
| 788 | hw->cap_act_pri_cfi.id = le16_to_cpu(hw->cap_act_pri_cfi.id); |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 789 | hw->cap_act_pri_cfi.variant = le16_to_cpu(hw->cap_act_pri_cfi.variant); |
| 790 | hw->cap_act_pri_cfi.bottom = le16_to_cpu(hw->cap_act_pri_cfi.bottom); |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 791 | hw->cap_act_pri_cfi.top = le16_to_cpu(hw->cap_act_pri_cfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 792 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 793 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 794 | "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", |
| 795 | hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id, |
| 796 | hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom, |
| 797 | hw->cap_act_pri_cfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 798 | |
| 799 | /* Compatibility range, sta f/w actor, CFI supplier */ |
| 800 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 801 | &hw->cap_act_sta_cfi, |
Sergio Paracuellos | 65f170c | 2016-09-28 20:18:57 +0200 | [diff] [blame] | 802 | sizeof(struct hfa384x_caplevel)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 803 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 804 | netdev_err(wlandev->netdev, "Failed to retrieve STA_CFIACTRANGES\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 805 | goto failed; |
| 806 | } |
| 807 | |
| 808 | /* get all the Compatibility range, station f/w actor, CFI supplier |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 809 | * fields in byte order |
| 810 | */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 811 | hw->cap_act_sta_cfi.role = le16_to_cpu(hw->cap_act_sta_cfi.role); |
| 812 | hw->cap_act_sta_cfi.id = le16_to_cpu(hw->cap_act_sta_cfi.id); |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 813 | hw->cap_act_sta_cfi.variant = le16_to_cpu(hw->cap_act_sta_cfi.variant); |
| 814 | hw->cap_act_sta_cfi.bottom = le16_to_cpu(hw->cap_act_sta_cfi.bottom); |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 815 | hw->cap_act_sta_cfi.top = le16_to_cpu(hw->cap_act_sta_cfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 816 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 817 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 818 | "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", |
| 819 | hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id, |
| 820 | hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom, |
| 821 | hw->cap_act_sta_cfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 822 | |
| 823 | /* Compatibility range, sta f/w actor, MFI supplier */ |
| 824 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 825 | &hw->cap_act_sta_mfi, |
Sergio Paracuellos | 65f170c | 2016-09-28 20:18:57 +0200 | [diff] [blame] | 826 | sizeof(struct hfa384x_caplevel)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 827 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 828 | netdev_err(wlandev->netdev, "Failed to retrieve STA_MFIACTRANGES\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 829 | goto failed; |
| 830 | } |
| 831 | |
| 832 | /* get all the Compatibility range, station f/w actor, MFI supplier |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 833 | * fields in byte order |
| 834 | */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 835 | hw->cap_act_sta_mfi.role = le16_to_cpu(hw->cap_act_sta_mfi.role); |
| 836 | hw->cap_act_sta_mfi.id = le16_to_cpu(hw->cap_act_sta_mfi.id); |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 837 | hw->cap_act_sta_mfi.variant = le16_to_cpu(hw->cap_act_sta_mfi.variant); |
| 838 | hw->cap_act_sta_mfi.bottom = le16_to_cpu(hw->cap_act_sta_mfi.bottom); |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 839 | hw->cap_act_sta_mfi.top = le16_to_cpu(hw->cap_act_sta_mfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 840 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 841 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 842 | "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", |
| 843 | hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id, |
| 844 | hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom, |
| 845 | hw->cap_act_sta_mfi.top); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 846 | |
| 847 | /* Serial Number */ |
| 848 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 849 | snum, HFA384x_RID_NICSERIALNUMBER_LEN); |
| 850 | if (!result) { |
Andy Shevchenko | 068c11d | 2014-10-13 15:55:29 -0700 | [diff] [blame] | 851 | netdev_info(wlandev->netdev, "Prism2 card SN: %*pEhp\n", |
| 852 | HFA384x_RID_NICSERIALNUMBER_LEN, snum); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 853 | } else { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 854 | netdev_err(wlandev->netdev, "Failed to retrieve Prism2 Card SN\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 855 | goto failed; |
| 856 | } |
| 857 | |
| 858 | /* Collect the MAC address */ |
| 859 | result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 860 | wlandev->netdev->dev_addr, ETH_ALEN); |
| 861 | if (result != 0) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 862 | netdev_err(wlandev->netdev, "Failed to retrieve mac address\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 863 | goto failed; |
| 864 | } |
| 865 | |
| 866 | /* short preamble is always implemented */ |
| 867 | wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE; |
| 868 | |
| 869 | /* find out if hardware wep is implemented */ |
| 870 | hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp); |
| 871 | if (temp) |
| 872 | wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP; |
| 873 | |
| 874 | /* get the dBm Scaling constant */ |
| 875 | hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFDBMADJUST, &temp); |
| 876 | hw->dbmadjust = temp; |
| 877 | |
| 878 | /* Only enable scan by default on newer firmware */ |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 879 | if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, |
| 880 | hw->ident_sta_fw.minor, |
| 881 | hw->ident_sta_fw.variant) < |
| 882 | HFA384x_FIRMWARE_VERSION(1, 5, 5)) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 883 | wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN; |
| 884 | } |
| 885 | |
| 886 | /* TODO: Set any internally managed config items */ |
| 887 | |
| 888 | goto done; |
| 889 | failed: |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 890 | netdev_err(wlandev->netdev, "Failed, result=%d\n", result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 891 | done: |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 892 | return result; |
| 893 | } |
| 894 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 895 | /* |
| 896 | * prism2sta_globalsetup |
| 897 | * |
| 898 | * Set any global RIDs that we want to set at device activation. |
| 899 | * |
| 900 | * Arguments: |
| 901 | * wlandev wlan device structure |
| 902 | * |
| 903 | * Returns: |
| 904 | * 0 success |
| 905 | * >0 f/w reported error |
| 906 | * <0 driver reported error |
| 907 | * |
| 908 | * Side effects: |
| 909 | * |
| 910 | * Call context: |
| 911 | * process thread |
| 912 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 913 | static int prism2sta_globalsetup(struct wlandevice *wlandev) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 914 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 915 | struct hfa384x *hw = wlandev->priv; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 916 | |
| 917 | /* Set the maximum frame size */ |
| 918 | return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 919 | WLAN_DATA_MAXLEN); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 920 | } |
| 921 | |
Sergio Paracuellos | 1906698 | 2016-09-27 19:33:51 +0200 | [diff] [blame] | 922 | static int prism2sta_setmulticast(struct wlandevice *wlandev, |
| 923 | struct net_device *dev) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 924 | { |
| 925 | int result = 0; |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 926 | struct hfa384x *hw = wlandev->priv; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 927 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 928 | u16 promisc; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 929 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 930 | /* If we're not ready, what's the point? */ |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 931 | if (hw->state != HFA384x_STATE_RUNNING) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 932 | goto exit; |
| 933 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 934 | if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 935 | promisc = P80211ENUM_truth_true; |
| 936 | else |
| 937 | promisc = P80211ENUM_truth_false; |
| 938 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 939 | result = |
| 940 | hfa384x_drvr_setconfig16_async(hw, HFA384x_RID_PROMISCMODE, |
| 941 | promisc); |
| 942 | exit: |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 943 | return result; |
| 944 | } |
| 945 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 946 | /* |
| 947 | * prism2sta_inf_handover |
| 948 | * |
| 949 | * Handles the receipt of a Handover info frame. Should only be present |
| 950 | * in APs only. |
| 951 | * |
| 952 | * Arguments: |
| 953 | * wlandev wlan device structure |
| 954 | * inf ptr to info frame (contents in hfa384x order) |
| 955 | * |
| 956 | * Returns: |
| 957 | * nothing |
| 958 | * |
| 959 | * Side effects: |
| 960 | * |
| 961 | * Call context: |
| 962 | * interrupt |
| 963 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 964 | static void prism2sta_inf_handover(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 965 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 966 | { |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 967 | pr_debug("received infoframe:HANDOVER (unhandled)\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 968 | } |
| 969 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 970 | /* |
| 971 | * prism2sta_inf_tallies |
| 972 | * |
| 973 | * Handles the receipt of a CommTallies info frame. |
| 974 | * |
| 975 | * Arguments: |
| 976 | * wlandev wlan device structure |
| 977 | * inf ptr to info frame (contents in hfa384x order) |
| 978 | * |
| 979 | * Returns: |
| 980 | * nothing |
| 981 | * |
| 982 | * Side effects: |
| 983 | * |
| 984 | * Call context: |
| 985 | * interrupt |
| 986 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 987 | static void prism2sta_inf_tallies(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 988 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 989 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 990 | struct hfa384x *hw = wlandev->priv; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 991 | u16 *src16; |
| 992 | u32 *dst; |
| 993 | u32 *src32; |
| 994 | int i; |
| 995 | int cnt; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 996 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 997 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 998 | * Determine if these are 16-bit or 32-bit tallies, based on the |
| 999 | * record length of the info record. |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1000 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1001 | |
Sergio Paracuellos | cfc6cb1 | 2016-09-28 20:19:08 +0200 | [diff] [blame] | 1002 | cnt = sizeof(struct hfa384x_CommTallies32) / sizeof(u32); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1003 | if (inf->framelen > 22) { |
Jannik Becher | 0e21fa4 | 2016-09-23 01:02:10 +0200 | [diff] [blame] | 1004 | dst = (u32 *)&hw->tallies; |
| 1005 | src32 = (u32 *)&inf->info.commtallies32; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1006 | for (i = 0; i < cnt; i++, dst++, src32++) |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 1007 | *dst += le32_to_cpu(*src32); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1008 | } else { |
Jannik Becher | 0e21fa4 | 2016-09-23 01:02:10 +0200 | [diff] [blame] | 1009 | dst = (u32 *)&hw->tallies; |
| 1010 | src16 = (u16 *)&inf->info.commtallies16; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1011 | for (i = 0; i < cnt; i++, dst++, src16++) |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 1012 | *dst += le16_to_cpu(*src16); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1013 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1014 | } |
| 1015 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1016 | /* |
| 1017 | * prism2sta_inf_scanresults |
| 1018 | * |
| 1019 | * Handles the receipt of a Scan Results info frame. |
| 1020 | * |
| 1021 | * Arguments: |
| 1022 | * wlandev wlan device structure |
| 1023 | * inf ptr to info frame (contents in hfa384x order) |
| 1024 | * |
| 1025 | * Returns: |
| 1026 | * nothing |
| 1027 | * |
| 1028 | * Side effects: |
| 1029 | * |
| 1030 | * Call context: |
| 1031 | * interrupt |
| 1032 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1033 | static void prism2sta_inf_scanresults(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1034 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1035 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1036 | struct hfa384x *hw = wlandev->priv; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1037 | int nbss; |
Sergio Paracuellos | dc0bb00 | 2016-09-28 20:19:10 +0200 | [diff] [blame] | 1038 | struct hfa384x_ScanResult *sr = &(inf->info.scanresult); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1039 | int i; |
Sergio Paracuellos | f0ffa0e | 2016-09-28 20:18:59 +0200 | [diff] [blame] | 1040 | struct hfa384x_JoinRequest_data joinreq; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1041 | int result; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1042 | |
| 1043 | /* Get the number of results, first in bytes, then in results */ |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 1044 | nbss = (inf->framelen * sizeof(u16)) - |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1045 | sizeof(inf->infotype) - sizeof(inf->info.scanresult.scanreason); |
Sergio Paracuellos | 4400334 | 2016-09-28 20:19:09 +0200 | [diff] [blame] | 1046 | nbss /= sizeof(struct hfa384x_ScanResultSub); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1047 | |
| 1048 | /* Print em */ |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 1049 | pr_debug("rx scanresults, reason=%d, nbss=%d:\n", |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1050 | inf->info.scanresult.scanreason, nbss); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1051 | for (i = 0; i < nbss; i++) { |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 1052 | pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n", |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1053 | sr->result[i].chid, |
| 1054 | sr->result[i].anl, |
| 1055 | sr->result[i].sl, sr->result[i].bcnint); |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 1056 | pr_debug(" capinfo=0x%04x proberesp_rate=%d\n", |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1057 | sr->result[i].capinfo, sr->result[i].proberesp_rate); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1058 | } |
| 1059 | /* issue a join request */ |
| 1060 | joinreq.channel = sr->result[0].chid; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1061 | memcpy(joinreq.bssid, sr->result[0].bssid, WLAN_BSSID_LEN); |
| 1062 | result = hfa384x_drvr_setconfig(hw, |
| 1063 | HFA384x_RID_JOINREQUEST, |
| 1064 | &joinreq, HFA384x_RID_JOINREQUEST_LEN); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1065 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 1066 | netdev_err(wlandev->netdev, "setconfig(joinreq) failed, result=%d\n", |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1067 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1068 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1069 | } |
| 1070 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1071 | /* |
| 1072 | * prism2sta_inf_hostscanresults |
| 1073 | * |
| 1074 | * Handles the receipt of a Scan Results info frame. |
| 1075 | * |
| 1076 | * Arguments: |
| 1077 | * wlandev wlan device structure |
| 1078 | * inf ptr to info frame (contents in hfa384x order) |
| 1079 | * |
| 1080 | * Returns: |
| 1081 | * nothing |
| 1082 | * |
| 1083 | * Side effects: |
| 1084 | * |
| 1085 | * Call context: |
| 1086 | * interrupt |
| 1087 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1088 | static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1089 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1090 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1091 | struct hfa384x *hw = wlandev->priv; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1092 | int nbss; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1093 | |
| 1094 | nbss = (inf->framelen - 3) / 32; |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 1095 | pr_debug("Received %d hostscan results\n", nbss); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1096 | |
| 1097 | if (nbss > 32) |
| 1098 | nbss = 32; |
| 1099 | |
Moritz Muehlenhoff | 7c98f71 | 2009-02-09 19:33:42 +0100 | [diff] [blame] | 1100 | kfree(hw->scanresults); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1101 | |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1102 | hw->scanresults = kmemdup(inf, sizeof(struct hfa384x_InfFrame), GFP_ATOMIC); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1103 | |
| 1104 | if (nbss == 0) |
| 1105 | nbss = -1; |
| 1106 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1107 | /* Notify/wake the sleeping caller. */ |
| 1108 | hw->scanflag = nbss; |
| 1109 | wake_up_interruptible(&hw->cmdq); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1110 | }; |
| 1111 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1112 | /* |
| 1113 | * prism2sta_inf_chinforesults |
| 1114 | * |
| 1115 | * Handles the receipt of a Channel Info Results info frame. |
| 1116 | * |
| 1117 | * Arguments: |
| 1118 | * wlandev wlan device structure |
| 1119 | * inf ptr to info frame (contents in hfa384x order) |
| 1120 | * |
| 1121 | * Returns: |
| 1122 | * nothing |
| 1123 | * |
| 1124 | * Side effects: |
| 1125 | * |
| 1126 | * Call context: |
| 1127 | * interrupt |
| 1128 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1129 | static void prism2sta_inf_chinforesults(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1130 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1131 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1132 | struct hfa384x *hw = wlandev->priv; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1133 | unsigned int i, n; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1134 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1135 | hw->channel_info.results.scanchannels = |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 1136 | le16_to_cpu(inf->info.chinforesult.scanchannels); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1137 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1138 | for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) { |
Sergio Paracuellos | 1bc4292a | 2016-09-28 20:19:11 +0200 | [diff] [blame] | 1139 | struct hfa384x_ChInfoResultSub *result; |
| 1140 | struct hfa384x_ChInfoResultSub *chinforesult; |
Dan Carpenter | a0cdd2e | 2013-02-27 08:12:06 +0300 | [diff] [blame] | 1141 | int chan; |
| 1142 | |
| 1143 | if (!(hw->channel_info.results.scanchannels & (1 << i))) |
| 1144 | continue; |
| 1145 | |
| 1146 | result = &inf->info.chinforesult.result[n]; |
| 1147 | chan = le16_to_cpu(result->chid) - 1; |
| 1148 | |
Dan Carpenter | 72c1c06 | 2013-02-27 08:13:45 +0300 | [diff] [blame] | 1149 | if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX) |
| 1150 | continue; |
| 1151 | |
Dan Carpenter | a0cdd2e | 2013-02-27 08:12:06 +0300 | [diff] [blame] | 1152 | chinforesult = &hw->channel_info.results.result[chan]; |
| 1153 | chinforesult->chid = chan; |
| 1154 | chinforesult->anl = le16_to_cpu(result->anl); |
| 1155 | chinforesult->pnl = le16_to_cpu(result->pnl); |
| 1156 | chinforesult->active = le16_to_cpu(result->active); |
| 1157 | |
| 1158 | pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n", |
| 1159 | chan + 1, |
| 1160 | (chinforesult->active & HFA384x_CHINFORESULT_BSSACTIVE) |
| 1161 | ? "signal" : "noise", |
| 1162 | chinforesult->anl, chinforesult->pnl, |
| 1163 | (chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE) |
| 1164 | ? 1 : 0); |
| 1165 | n++; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1166 | } |
| 1167 | atomic_set(&hw->channel_info.done, 2); |
| 1168 | |
| 1169 | hw->channel_info.count = n; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1170 | } |
| 1171 | |
| 1172 | void prism2sta_processing_defer(struct work_struct *data) |
| 1173 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1174 | struct hfa384x *hw = container_of(data, struct hfa384x, link_bh); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1175 | struct wlandevice *wlandev = hw->wlandev; |
Sergio Paracuellos | 03c2975 | 2016-09-28 20:18:54 +0200 | [diff] [blame] | 1176 | struct hfa384x_bytestr32 ssid; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1177 | int result; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1178 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1179 | /* First let's process the auth frames */ |
| 1180 | { |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1181 | struct sk_buff *skb; |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1182 | struct hfa384x_InfFrame *inf; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1183 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1184 | while ((skb = skb_dequeue(&hw->authq))) { |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1185 | inf = (struct hfa384x_InfFrame *)skb->data; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1186 | prism2sta_inf_authreq_defer(wlandev, inf); |
| 1187 | } |
| 1188 | |
| 1189 | } |
| 1190 | |
| 1191 | /* Now let's handle the linkstatus stuff */ |
| 1192 | if (hw->link_status == hw->link_status_new) |
Devendra Naga | 5d6f505 | 2012-09-13 15:01:39 +0530 | [diff] [blame] | 1193 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1194 | |
| 1195 | hw->link_status = hw->link_status_new; |
| 1196 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1197 | switch (hw->link_status) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1198 | case HFA384x_LINK_NOTCONNECTED: |
| 1199 | /* I'm currently assuming that this is the initial link |
| 1200 | * state. It should only be possible immediately |
| 1201 | * following an Enable command. |
| 1202 | * Response: |
| 1203 | * Block Transmits, Ignore receives of data frames |
| 1204 | */ |
| 1205 | netif_carrier_off(wlandev->netdev); |
| 1206 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 1207 | netdev_info(wlandev->netdev, "linkstatus=NOTCONNECTED (unhandled)\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1208 | break; |
| 1209 | |
| 1210 | case HFA384x_LINK_CONNECTED: |
| 1211 | /* This one indicates a successful scan/join/auth/assoc. |
| 1212 | * When we have the full MLME complement, this event will |
| 1213 | * signify successful completion of both mlme_authenticate |
| 1214 | * and mlme_associate. State management will get a little |
| 1215 | * ugly here. |
| 1216 | * Response: |
| 1217 | * Indicate authentication and/or association |
| 1218 | * Enable Transmits, Receives and pass up data frames |
| 1219 | */ |
| 1220 | |
| 1221 | netif_carrier_on(wlandev->netdev); |
| 1222 | |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 1223 | /* If we are joining a specific AP, set our |
| 1224 | * state and reset retries |
| 1225 | */ |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1226 | if (hw->join_ap == 1) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1227 | hw->join_ap = 2; |
| 1228 | hw->join_retries = 60; |
| 1229 | |
| 1230 | /* Don't call this in monitor mode */ |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1231 | if (wlandev->netdev->type == ARPHRD_ETHER) { |
| 1232 | u16 portstatus; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1233 | |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 1234 | netdev_info(wlandev->netdev, "linkstatus=CONNECTED\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1235 | |
| 1236 | /* For non-usb devices, we can use the sync versions */ |
| 1237 | /* Collect the BSSID, and set state to allow tx */ |
| 1238 | |
| 1239 | result = hfa384x_drvr_getconfig(hw, |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 1240 | HFA384x_RID_CURRENTBSSID, |
| 1241 | wlandev->bssid, |
| 1242 | WLAN_BSSID_LEN); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1243 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1244 | pr_debug |
| 1245 | ("getconfig(0x%02x) failed, result = %d\n", |
| 1246 | HFA384x_RID_CURRENTBSSID, result); |
Devendra Naga | 5d6f505 | 2012-09-13 15:01:39 +0530 | [diff] [blame] | 1247 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1248 | } |
| 1249 | |
| 1250 | result = hfa384x_drvr_getconfig(hw, |
| 1251 | HFA384x_RID_CURRENTSSID, |
| 1252 | &ssid, sizeof(ssid)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1253 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1254 | pr_debug |
| 1255 | ("getconfig(0x%02x) failed, result = %d\n", |
| 1256 | HFA384x_RID_CURRENTSSID, result); |
Devendra Naga | 5d6f505 | 2012-09-13 15:01:39 +0530 | [diff] [blame] | 1257 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1258 | } |
chaehyun lim | 613462e | 2015-05-15 22:13:43 +0900 | [diff] [blame] | 1259 | prism2mgmt_bytestr2pstr( |
Jannik Becher | 0e21fa4 | 2016-09-23 01:02:10 +0200 | [diff] [blame] | 1260 | (struct hfa384x_bytestr *)&ssid, |
Sergio Paracuellos | 3fd1e3f | 2016-09-25 15:34:52 +0200 | [diff] [blame] | 1261 | (struct p80211pstrd *)&wlandev->ssid); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1262 | |
| 1263 | /* Collect the port status */ |
| 1264 | result = hfa384x_drvr_getconfig16(hw, |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 1265 | HFA384x_RID_PORTSTATUS, |
| 1266 | &portstatus); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1267 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1268 | pr_debug |
| 1269 | ("getconfig(0x%02x) failed, result = %d\n", |
| 1270 | HFA384x_RID_PORTSTATUS, result); |
Devendra Naga | 5d6f505 | 2012-09-13 15:01:39 +0530 | [diff] [blame] | 1271 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1272 | } |
| 1273 | wlandev->macmode = |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1274 | (portstatus == HFA384x_PSTATUS_CONN_IBSS) ? |
| 1275 | WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1276 | |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 1277 | /* signal back up to cfg80211 layer */ |
| 1278 | prism2_connect_result(wlandev, P80211ENUM_truth_false); |
| 1279 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1280 | /* Get the ball rolling on the comms quality stuff */ |
| 1281 | prism2sta_commsqual_defer(&hw->commsqual_bh); |
| 1282 | } |
| 1283 | break; |
| 1284 | |
| 1285 | case HFA384x_LINK_DISCONNECTED: |
| 1286 | /* This one indicates that our association is gone. We've |
| 1287 | * lost connection with the AP and/or been disassociated. |
| 1288 | * This indicates that the MAC has completely cleared it's |
| 1289 | * associated state. We * should send a deauth indication |
| 1290 | * (implying disassoc) up * to the MLME. |
| 1291 | * Response: |
| 1292 | * Indicate Deauthentication |
| 1293 | * Block Transmits, Ignore receives of data frames |
| 1294 | */ |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 1295 | if (wlandev->netdev->type == ARPHRD_ETHER) |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 1296 | netdev_info(wlandev->netdev, |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 1297 | "linkstatus=DISCONNECTED (unhandled)\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1298 | wlandev->macmode = WLAN_MACMODE_NONE; |
| 1299 | |
| 1300 | netif_carrier_off(wlandev->netdev); |
| 1301 | |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 1302 | /* signal back up to cfg80211 layer */ |
| 1303 | prism2_disconnected(wlandev); |
| 1304 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1305 | break; |
| 1306 | |
| 1307 | case HFA384x_LINK_AP_CHANGE: |
| 1308 | /* This one indicates that the MAC has decided to and |
| 1309 | * successfully completed a change to another AP. We |
| 1310 | * should probably implement a reassociation indication |
| 1311 | * in response to this one. I'm thinking that the the |
| 1312 | * p80211 layer needs to be notified in case of |
| 1313 | * buffering/queueing issues. User mode also needs to be |
| 1314 | * notified so that any BSS dependent elements can be |
| 1315 | * updated. |
| 1316 | * associated state. We * should send a deauth indication |
| 1317 | * (implying disassoc) up * to the MLME. |
| 1318 | * Response: |
| 1319 | * Indicate Reassociation |
| 1320 | * Enable Transmits, Receives and pass up data frames |
| 1321 | */ |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 1322 | netdev_info(wlandev->netdev, "linkstatus=AP_CHANGE\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1323 | |
| 1324 | result = hfa384x_drvr_getconfig(hw, |
| 1325 | HFA384x_RID_CURRENTBSSID, |
| 1326 | wlandev->bssid, WLAN_BSSID_LEN); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1327 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1328 | pr_debug("getconfig(0x%02x) failed, result = %d\n", |
| 1329 | HFA384x_RID_CURRENTBSSID, result); |
Devendra Naga | 5d6f505 | 2012-09-13 15:01:39 +0530 | [diff] [blame] | 1330 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1331 | } |
| 1332 | |
| 1333 | result = hfa384x_drvr_getconfig(hw, |
| 1334 | HFA384x_RID_CURRENTSSID, |
| 1335 | &ssid, sizeof(ssid)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1336 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1337 | pr_debug("getconfig(0x%02x) failed, result = %d\n", |
| 1338 | HFA384x_RID_CURRENTSSID, result); |
Devendra Naga | 5d6f505 | 2012-09-13 15:01:39 +0530 | [diff] [blame] | 1339 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1340 | } |
Jannik Becher | 0e21fa4 | 2016-09-23 01:02:10 +0200 | [diff] [blame] | 1341 | prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid, |
Sergio Paracuellos | 3fd1e3f | 2016-09-25 15:34:52 +0200 | [diff] [blame] | 1342 | (struct p80211pstrd *)&wlandev->ssid); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1343 | |
| 1344 | hw->link_status = HFA384x_LINK_CONNECTED; |
| 1345 | netif_carrier_on(wlandev->netdev); |
| 1346 | |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 1347 | /* signal back up to cfg80211 layer */ |
| 1348 | prism2_roamed(wlandev); |
| 1349 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1350 | break; |
| 1351 | |
| 1352 | case HFA384x_LINK_AP_OUTOFRANGE: |
| 1353 | /* This one indicates that the MAC has decided that the |
| 1354 | * AP is out of range, but hasn't found a better candidate |
| 1355 | * so the MAC maintains its "associated" state in case |
| 1356 | * we get back in range. We should block transmits and |
| 1357 | * receives in this state. Do we need an indication here? |
| 1358 | * Probably not since a polling user-mode element would |
| 1359 | * get this status from from p2PortStatus(FD40). What about |
| 1360 | * p80211? |
| 1361 | * Response: |
| 1362 | * Block Transmits, Ignore receives of data frames |
| 1363 | */ |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 1364 | netdev_info(wlandev->netdev, "linkstatus=AP_OUTOFRANGE (unhandled)\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1365 | |
| 1366 | netif_carrier_off(wlandev->netdev); |
| 1367 | |
| 1368 | break; |
| 1369 | |
| 1370 | case HFA384x_LINK_AP_INRANGE: |
| 1371 | /* This one indicates that the MAC has decided that the |
| 1372 | * AP is back in range. We continue working with our |
| 1373 | * existing association. |
| 1374 | * Response: |
| 1375 | * Enable Transmits, Receives and pass up data frames |
| 1376 | */ |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 1377 | netdev_info(wlandev->netdev, "linkstatus=AP_INRANGE\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1378 | |
| 1379 | hw->link_status = HFA384x_LINK_CONNECTED; |
| 1380 | netif_carrier_on(wlandev->netdev); |
| 1381 | |
| 1382 | break; |
| 1383 | |
| 1384 | case HFA384x_LINK_ASSOCFAIL: |
| 1385 | /* This one is actually a peer to CONNECTED. We've |
| 1386 | * requested a join for a given SSID and optionally BSSID. |
| 1387 | * We can use this one to indicate authentication and |
| 1388 | * association failures. The trick is going to be |
| 1389 | * 1) identifying the failure, and 2) state management. |
| 1390 | * Response: |
| 1391 | * Disable Transmits, Ignore receives of data frames |
| 1392 | */ |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1393 | if (hw->join_ap && --hw->join_retries > 0) { |
Sergio Paracuellos | f0ffa0e | 2016-09-28 20:18:59 +0200 | [diff] [blame] | 1394 | struct hfa384x_JoinRequest_data joinreq; |
Johannes Stadlinger | f9d0175 | 2014-06-19 21:20:20 +0200 | [diff] [blame] | 1395 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1396 | joinreq = hw->joinreq; |
| 1397 | /* Send the join request */ |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1398 | hfa384x_drvr_setconfig(hw, |
| 1399 | HFA384x_RID_JOINREQUEST, |
| 1400 | &joinreq, |
| 1401 | HFA384x_RID_JOINREQUEST_LEN); |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 1402 | netdev_info(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1403 | "linkstatus=ASSOCFAIL (re-submitting join)\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1404 | } else { |
Tugce Sirin | 1f99741 | 2014-03-17 16:02:05 +0200 | [diff] [blame] | 1405 | netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL (unhandled)\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1406 | } |
| 1407 | |
| 1408 | netif_carrier_off(wlandev->netdev); |
| 1409 | |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 1410 | /* signal back up to cfg80211 layer */ |
| 1411 | prism2_connect_result(wlandev, P80211ENUM_truth_true); |
| 1412 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1413 | break; |
| 1414 | |
| 1415 | default: |
| 1416 | /* This is bad, IO port problems? */ |
Vitaly Osipov | 02d9b1e | 2014-05-18 16:59:36 +1000 | [diff] [blame] | 1417 | netdev_warn(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1418 | "unknown linkstatus=0x%02x\n", hw->link_status); |
Devendra Naga | 5d6f505 | 2012-09-13 15:01:39 +0530 | [diff] [blame] | 1419 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1420 | } |
| 1421 | |
| 1422 | wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1423 | } |
| 1424 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1425 | /* |
| 1426 | * prism2sta_inf_linkstatus |
| 1427 | * |
| 1428 | * Handles the receipt of a Link Status info frame. |
| 1429 | * |
| 1430 | * Arguments: |
| 1431 | * wlandev wlan device structure |
| 1432 | * inf ptr to info frame (contents in hfa384x order) |
| 1433 | * |
| 1434 | * Returns: |
| 1435 | * nothing |
| 1436 | * |
| 1437 | * Side effects: |
| 1438 | * |
| 1439 | * Call context: |
| 1440 | * interrupt |
| 1441 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1442 | static void prism2sta_inf_linkstatus(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1443 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1444 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1445 | struct hfa384x *hw = wlandev->priv; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1446 | |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 1447 | hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1448 | |
| 1449 | schedule_work(&hw->link_bh); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1450 | } |
| 1451 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1452 | /* |
| 1453 | * prism2sta_inf_assocstatus |
| 1454 | * |
| 1455 | * Handles the receipt of an Association Status info frame. Should |
| 1456 | * be present in APs only. |
| 1457 | * |
| 1458 | * Arguments: |
| 1459 | * wlandev wlan device structure |
| 1460 | * inf ptr to info frame (contents in hfa384x order) |
| 1461 | * |
| 1462 | * Returns: |
| 1463 | * nothing |
| 1464 | * |
| 1465 | * Side effects: |
| 1466 | * |
| 1467 | * Call context: |
| 1468 | * interrupt |
| 1469 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1470 | static void prism2sta_inf_assocstatus(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1471 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1472 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1473 | struct hfa384x *hw = wlandev->priv; |
Sergio Paracuellos | 5383f13 | 2016-09-28 20:19:16 +0200 | [diff] [blame] | 1474 | struct hfa384x_AssocStatus rec; |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1475 | int i; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1476 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1477 | memcpy(&rec, &inf->info.assocstatus, sizeof(rec)); |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 1478 | rec.assocstatus = le16_to_cpu(rec.assocstatus); |
| 1479 | rec.reason = le16_to_cpu(rec.reason); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1480 | |
| 1481 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1482 | * Find the address in the list of authenticated stations. |
| 1483 | * If it wasn't found, then this address has not been previously |
| 1484 | * authenticated and something weird has happened if this is |
| 1485 | * anything other than an "authentication failed" message. |
| 1486 | * If the address was found, then set the "associated" flag for |
| 1487 | * that station, based on whether the station is associating or |
| 1488 | * losing its association. Something weird has also happened |
| 1489 | * if we find the address in the list of authenticated stations |
| 1490 | * but we are getting an "authentication failed" message. |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1491 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1492 | |
| 1493 | for (i = 0; i < hw->authlist.cnt; i++) |
Maciek Borzecki | a305cf3 | 2015-10-03 16:01:36 +0200 | [diff] [blame] | 1494 | if (ether_addr_equal(rec.sta_addr, hw->authlist.addr[i])) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1495 | break; |
| 1496 | |
| 1497 | if (i >= hw->authlist.cnt) { |
| 1498 | if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL) |
Vitaly Osipov | 02d9b1e | 2014-05-18 16:59:36 +1000 | [diff] [blame] | 1499 | netdev_warn(wlandev->netdev, |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 1500 | "assocstatus info frame received for non-authenticated station.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1501 | } else { |
| 1502 | hw->authlist.assoc[i] = |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1503 | (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC || |
| 1504 | rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1505 | |
| 1506 | if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL) |
Vitaly Osipov | 02d9b1e | 2014-05-18 16:59:36 +1000 | [diff] [blame] | 1507 | netdev_warn(wlandev->netdev, |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 1508 | "authfail assocstatus info frame received for authenticated station.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1509 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1510 | } |
| 1511 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1512 | /* |
| 1513 | * prism2sta_inf_authreq |
| 1514 | * |
| 1515 | * Handles the receipt of an Authentication Request info frame. Should |
| 1516 | * be present in APs only. |
| 1517 | * |
| 1518 | * Arguments: |
| 1519 | * wlandev wlan device structure |
| 1520 | * inf ptr to info frame (contents in hfa384x order) |
| 1521 | * |
| 1522 | * Returns: |
| 1523 | * nothing |
| 1524 | * |
| 1525 | * Side effects: |
| 1526 | * |
| 1527 | * Call context: |
| 1528 | * interrupt |
| 1529 | * |
| 1530 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1531 | static void prism2sta_inf_authreq(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1532 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1533 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1534 | struct hfa384x *hw = wlandev->priv; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1535 | struct sk_buff *skb; |
| 1536 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1537 | skb = dev_alloc_skb(sizeof(*inf)); |
| 1538 | if (skb) { |
| 1539 | skb_put(skb, sizeof(*inf)); |
| 1540 | memcpy(skb->data, inf, sizeof(*inf)); |
| 1541 | skb_queue_tail(&hw->authq, skb); |
| 1542 | schedule_work(&hw->link_bh); |
| 1543 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1544 | } |
| 1545 | |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1546 | static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1547 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1548 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1549 | struct hfa384x *hw = wlandev->priv; |
Sergio Paracuellos | 17fb19f | 2016-09-28 20:19:00 +0200 | [diff] [blame] | 1550 | struct hfa384x_authenticateStation_data rec; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1551 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1552 | int i, added, result, cnt; |
| 1553 | u8 *addr; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1554 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1555 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1556 | * Build the AuthenticateStation record. Initialize it for denying |
| 1557 | * authentication. |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1558 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1559 | |
Ioana Ciornei | 7078db9 | 2015-03-18 15:26:05 +0200 | [diff] [blame] | 1560 | ether_addr_copy(rec.address, inf->info.authreq.sta_addr); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1561 | rec.status = P80211ENUM_status_unspec_failure; |
| 1562 | |
| 1563 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1564 | * Authenticate based on the access mode. |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1565 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1566 | |
| 1567 | switch (hw->accessmode) { |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1568 | case WLAN_ACCESS_NONE: |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1569 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1570 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1571 | * Deny all new authentications. However, if a station |
| 1572 | * is ALREADY authenticated, then accept it. |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1573 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1574 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1575 | for (i = 0; i < hw->authlist.cnt; i++) |
Maciek Borzecki | a305cf3 | 2015-10-03 16:01:36 +0200 | [diff] [blame] | 1576 | if (ether_addr_equal(rec.address, |
| 1577 | hw->authlist.addr[i])) { |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1578 | rec.status = P80211ENUM_status_successful; |
| 1579 | break; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1580 | } |
| 1581 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1582 | break; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1583 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1584 | case WLAN_ACCESS_ALL: |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1585 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1586 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1587 | * Allow all authentications. |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1588 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1589 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1590 | rec.status = P80211ENUM_status_successful; |
| 1591 | break; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1592 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1593 | case WLAN_ACCESS_ALLOW: |
| 1594 | |
| 1595 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1596 | * Only allow the authentication if the MAC address |
| 1597 | * is in the list of allowed addresses. |
| 1598 | * |
| 1599 | * Since this is the interrupt handler, we may be here |
| 1600 | * while the access list is in the middle of being |
| 1601 | * updated. Choose the list which is currently okay. |
| 1602 | * See "prism2mib_priv_accessallow()" for details. |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1603 | */ |
| 1604 | |
| 1605 | if (hw->allow.modify == 0) { |
| 1606 | cnt = hw->allow.cnt; |
| 1607 | addr = hw->allow.addr[0]; |
| 1608 | } else { |
| 1609 | cnt = hw->allow.cnt1; |
| 1610 | addr = hw->allow.addr1[0]; |
| 1611 | } |
| 1612 | |
| 1613 | for (i = 0; i < cnt; i++, addr += ETH_ALEN) |
Maciek Borzecki | a305cf3 | 2015-10-03 16:01:36 +0200 | [diff] [blame] | 1614 | if (ether_addr_equal(rec.address, addr)) { |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1615 | rec.status = P80211ENUM_status_successful; |
| 1616 | break; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1617 | } |
| 1618 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1619 | break; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1620 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1621 | case WLAN_ACCESS_DENY: |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1622 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1623 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1624 | * Allow the authentication UNLESS the MAC address is |
| 1625 | * in the list of denied addresses. |
| 1626 | * |
| 1627 | * Since this is the interrupt handler, we may be here |
| 1628 | * while the access list is in the middle of being |
| 1629 | * updated. Choose the list which is currently okay. |
| 1630 | * See "prism2mib_priv_accessdeny()" for details. |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1631 | */ |
| 1632 | |
| 1633 | if (hw->deny.modify == 0) { |
| 1634 | cnt = hw->deny.cnt; |
| 1635 | addr = hw->deny.addr[0]; |
| 1636 | } else { |
| 1637 | cnt = hw->deny.cnt1; |
| 1638 | addr = hw->deny.addr1[0]; |
| 1639 | } |
| 1640 | |
| 1641 | rec.status = P80211ENUM_status_successful; |
| 1642 | |
| 1643 | for (i = 0; i < cnt; i++, addr += ETH_ALEN) |
Maciek Borzecki | a305cf3 | 2015-10-03 16:01:36 +0200 | [diff] [blame] | 1644 | if (ether_addr_equal(rec.address, addr)) { |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1645 | rec.status = P80211ENUM_status_unspec_failure; |
| 1646 | break; |
| 1647 | } |
| 1648 | |
| 1649 | break; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1650 | } |
| 1651 | |
| 1652 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1653 | * If the authentication is okay, then add the MAC address to the |
| 1654 | * list of authenticated stations. Don't add the address if it |
| 1655 | * is already in the list. (802.11b does not seem to disallow |
| 1656 | * a station from issuing an authentication request when the |
| 1657 | * station is already authenticated. Does this sort of thing |
| 1658 | * ever happen? We might as well do the check just in case.) |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1659 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1660 | |
| 1661 | added = 0; |
| 1662 | |
| 1663 | if (rec.status == P80211ENUM_status_successful) { |
| 1664 | for (i = 0; i < hw->authlist.cnt; i++) |
Maciek Borzecki | a305cf3 | 2015-10-03 16:01:36 +0200 | [diff] [blame] | 1665 | if (ether_addr_equal(rec.address, |
| 1666 | hw->authlist.addr[i])) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1667 | break; |
| 1668 | |
| 1669 | if (i >= hw->authlist.cnt) { |
| 1670 | if (hw->authlist.cnt >= WLAN_AUTH_MAX) { |
| 1671 | rec.status = P80211ENUM_status_ap_full; |
| 1672 | } else { |
chaehyun lim | 613462e | 2015-05-15 22:13:43 +0900 | [diff] [blame] | 1673 | ether_addr_copy( |
| 1674 | hw->authlist.addr[hw->authlist.cnt], |
| 1675 | rec.address); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1676 | hw->authlist.cnt++; |
| 1677 | added = 1; |
| 1678 | } |
| 1679 | } |
| 1680 | } |
| 1681 | |
| 1682 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1683 | * Send back the results of the authentication. If this doesn't work, |
| 1684 | * then make sure to remove the address from the authenticated list if |
| 1685 | * it was added. |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1686 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1687 | |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 1688 | rec.status = cpu_to_le16(rec.status); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1689 | rec.algorithm = inf->info.authreq.algorithm; |
| 1690 | |
| 1691 | result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1692 | &rec, sizeof(rec)); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1693 | if (result) { |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1694 | if (added) |
| 1695 | hw->authlist.cnt--; |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 1696 | netdev_err(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1697 | "setconfig(authenticatestation) failed, result=%d\n", |
| 1698 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1699 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1700 | } |
| 1701 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1702 | /* |
| 1703 | * prism2sta_inf_psusercnt |
| 1704 | * |
| 1705 | * Handles the receipt of a PowerSaveUserCount info frame. Should |
| 1706 | * be present in APs only. |
| 1707 | * |
| 1708 | * Arguments: |
| 1709 | * wlandev wlan device structure |
| 1710 | * inf ptr to info frame (contents in hfa384x order) |
| 1711 | * |
| 1712 | * Returns: |
| 1713 | * nothing |
| 1714 | * |
| 1715 | * Side effects: |
| 1716 | * |
| 1717 | * Call context: |
| 1718 | * interrupt |
| 1719 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1720 | static void prism2sta_inf_psusercnt(struct wlandevice *wlandev, |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1721 | struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1722 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1723 | struct hfa384x *hw = wlandev->priv; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1724 | |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 1725 | hw->psusercount = le16_to_cpu(inf->info.psusercnt.usercnt); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1726 | } |
| 1727 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1728 | /* |
| 1729 | * prism2sta_ev_info |
| 1730 | * |
| 1731 | * Handles the Info event. |
| 1732 | * |
| 1733 | * Arguments: |
| 1734 | * wlandev wlan device structure |
| 1735 | * inf ptr to a generic info frame |
| 1736 | * |
| 1737 | * Returns: |
| 1738 | * nothing |
| 1739 | * |
| 1740 | * Side effects: |
| 1741 | * |
| 1742 | * Call context: |
| 1743 | * interrupt |
| 1744 | */ |
Sergio Paracuellos | f69de9e | 2016-09-28 20:19:21 +0200 | [diff] [blame] | 1745 | void prism2sta_ev_info(struct wlandevice *wlandev, struct hfa384x_InfFrame *inf) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1746 | { |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 1747 | inf->infotype = le16_to_cpu(inf->infotype); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1748 | /* Dispatch */ |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1749 | switch (inf->infotype) { |
| 1750 | case HFA384x_IT_HANDOVERADDR: |
| 1751 | prism2sta_inf_handover(wlandev, inf); |
| 1752 | break; |
| 1753 | case HFA384x_IT_COMMTALLIES: |
| 1754 | prism2sta_inf_tallies(wlandev, inf); |
| 1755 | break; |
| 1756 | case HFA384x_IT_HOSTSCANRESULTS: |
| 1757 | prism2sta_inf_hostscanresults(wlandev, inf); |
| 1758 | break; |
| 1759 | case HFA384x_IT_SCANRESULTS: |
| 1760 | prism2sta_inf_scanresults(wlandev, inf); |
| 1761 | break; |
| 1762 | case HFA384x_IT_CHINFORESULTS: |
| 1763 | prism2sta_inf_chinforesults(wlandev, inf); |
| 1764 | break; |
| 1765 | case HFA384x_IT_LINKSTATUS: |
| 1766 | prism2sta_inf_linkstatus(wlandev, inf); |
| 1767 | break; |
| 1768 | case HFA384x_IT_ASSOCSTATUS: |
| 1769 | prism2sta_inf_assocstatus(wlandev, inf); |
| 1770 | break; |
| 1771 | case HFA384x_IT_AUTHREQ: |
| 1772 | prism2sta_inf_authreq(wlandev, inf); |
| 1773 | break; |
| 1774 | case HFA384x_IT_PSUSERCNT: |
| 1775 | prism2sta_inf_psusercnt(wlandev, inf); |
| 1776 | break; |
| 1777 | case HFA384x_IT_KEYIDCHANGED: |
Vitaly Osipov | 02d9b1e | 2014-05-18 16:59:36 +1000 | [diff] [blame] | 1778 | netdev_warn(wlandev->netdev, "Unhandled IT_KEYIDCHANGED\n"); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1779 | break; |
| 1780 | case HFA384x_IT_ASSOCREQ: |
Vitaly Osipov | 02d9b1e | 2014-05-18 16:59:36 +1000 | [diff] [blame] | 1781 | netdev_warn(wlandev->netdev, "Unhandled IT_ASSOCREQ\n"); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1782 | break; |
| 1783 | case HFA384x_IT_MICFAILURE: |
Vitaly Osipov | 02d9b1e | 2014-05-18 16:59:36 +1000 | [diff] [blame] | 1784 | netdev_warn(wlandev->netdev, "Unhandled IT_MICFAILURE\n"); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1785 | break; |
| 1786 | default: |
Vitaly Osipov | 02d9b1e | 2014-05-18 16:59:36 +1000 | [diff] [blame] | 1787 | netdev_warn(wlandev->netdev, |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1788 | "Unknown info type=0x%02x\n", inf->infotype); |
| 1789 | break; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1790 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1791 | } |
| 1792 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1793 | /* |
| 1794 | * prism2sta_ev_txexc |
| 1795 | * |
| 1796 | * Handles the TxExc event. A Transmit Exception event indicates |
| 1797 | * that the MAC's TX process was unsuccessful - so the packet did |
| 1798 | * not get transmitted. |
| 1799 | * |
| 1800 | * Arguments: |
| 1801 | * wlandev wlan device structure |
| 1802 | * status tx frame status word |
| 1803 | * |
| 1804 | * Returns: |
| 1805 | * nothing |
| 1806 | * |
| 1807 | * Side effects: |
| 1808 | * |
| 1809 | * Call context: |
| 1810 | * interrupt |
| 1811 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1812 | void prism2sta_ev_txexc(struct wlandevice *wlandev, u16 status) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1813 | { |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 1814 | pr_debug("TxExc status=0x%x.\n", status); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1815 | } |
| 1816 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1817 | /* |
| 1818 | * prism2sta_ev_tx |
| 1819 | * |
| 1820 | * Handles the Tx event. |
| 1821 | * |
| 1822 | * Arguments: |
| 1823 | * wlandev wlan device structure |
| 1824 | * status tx frame status word |
| 1825 | * Returns: |
| 1826 | * nothing |
| 1827 | * |
| 1828 | * Side effects: |
| 1829 | * |
| 1830 | * Call context: |
| 1831 | * interrupt |
| 1832 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1833 | void prism2sta_ev_tx(struct wlandevice *wlandev, u16 status) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1834 | { |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 1835 | pr_debug("Tx Complete, status=0x%04x\n", status); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1836 | /* update linux network stats */ |
Tobias Klauser | 9630f6b | 2014-07-08 08:37:00 +0200 | [diff] [blame] | 1837 | wlandev->netdev->stats.tx_packets++; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1838 | } |
| 1839 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1840 | /* |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1841 | * prism2sta_ev_alloc |
| 1842 | * |
| 1843 | * Handles the Alloc event. |
| 1844 | * |
| 1845 | * Arguments: |
| 1846 | * wlandev wlan device structure |
| 1847 | * |
| 1848 | * Returns: |
| 1849 | * nothing |
| 1850 | * |
| 1851 | * Side effects: |
| 1852 | * |
| 1853 | * Call context: |
| 1854 | * interrupt |
| 1855 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1856 | void prism2sta_ev_alloc(struct wlandevice *wlandev) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1857 | { |
Solomon Peachy | cbec30c | 2008-10-29 10:42:57 -0400 | [diff] [blame] | 1858 | netif_wake_queue(wlandev->netdev); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1859 | } |
| 1860 | |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1861 | /* |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1862 | * create_wlan |
| 1863 | * |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1864 | * Called at module init time. This creates the struct wlandevice structure |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1865 | * and initializes it with relevant bits. |
| 1866 | * |
| 1867 | * Arguments: |
| 1868 | * none |
| 1869 | * |
| 1870 | * Returns: |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1871 | * the created struct wlandevice structure. |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1872 | * |
| 1873 | * Side effects: |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 1874 | * also allocates the priv/hw structures. |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1875 | * |
| 1876 | * Call context: |
| 1877 | * process thread |
| 1878 | * |
Ioana Ciornei | 60ec47f | 2015-09-30 22:28:32 +0300 | [diff] [blame] | 1879 | */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1880 | static struct wlandevice *create_wlan(void) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1881 | { |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1882 | struct wlandevice *wlandev = NULL; |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1883 | struct hfa384x *hw = NULL; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1884 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1885 | /* Alloc our structures */ |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1886 | wlandev = kzalloc(sizeof(struct wlandevice), GFP_KERNEL); |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1887 | hw = kzalloc(sizeof(struct hfa384x), GFP_KERNEL); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1888 | |
| 1889 | if (!wlandev || !hw) { |
Moritz Muehlenhoff | 7c98f71 | 2009-02-09 19:33:42 +0100 | [diff] [blame] | 1890 | kfree(wlandev); |
| 1891 | kfree(hw); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1892 | return NULL; |
| 1893 | } |
| 1894 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1895 | /* Initialize the network device object. */ |
| 1896 | wlandev->nsdname = dev_info; |
| 1897 | wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING; |
| 1898 | wlandev->priv = hw; |
| 1899 | wlandev->open = prism2sta_open; |
| 1900 | wlandev->close = prism2sta_close; |
| 1901 | wlandev->reset = prism2sta_reset; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1902 | wlandev->txframe = prism2sta_txframe; |
| 1903 | wlandev->mlmerequest = prism2sta_mlmerequest; |
| 1904 | wlandev->set_multicast_list = prism2sta_setmulticast; |
| 1905 | wlandev->tx_timeout = hfa384x_tx_timeout; |
| 1906 | |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1907 | wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT | P80211_NSDCAP_AUTOJOIN; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1908 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 1909 | /* Initialize the device private data structure. */ |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1910 | hw->dot11_desired_bss_type = 1; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1911 | |
| 1912 | return wlandev; |
| 1913 | } |
| 1914 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1915 | void prism2sta_commsqual_defer(struct work_struct *data) |
| 1916 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 1917 | struct hfa384x *hw = container_of(data, struct hfa384x, commsqual_bh); |
sayli karnik | c9573a8 | 2016-09-18 15:11:14 +0530 | [diff] [blame] | 1918 | struct wlandevice *wlandev = hw->wlandev; |
Sergio Paracuellos | 03c2975 | 2016-09-28 20:18:54 +0200 | [diff] [blame] | 1919 | struct hfa384x_bytestr32 ssid; |
Edgardo Hames | b6bb56e | 2010-08-02 16:20:39 -0300 | [diff] [blame] | 1920 | struct p80211msg_dot11req_mibget msg; |
Sergio Paracuellos | b26b232 | 2016-09-25 15:35:00 +0200 | [diff] [blame] | 1921 | struct p80211item_uint32 *mibitem = (struct p80211item_uint32 *) |
Edgardo Hames | b6bb56e | 2010-08-02 16:20:39 -0300 | [diff] [blame] | 1922 | &msg.mibattribute.data; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1923 | int result = 0; |
| 1924 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1925 | if (hw->wlandev->hwremoved) |
Devendra Naga | 102db1f | 2012-09-09 18:41:00 +0530 | [diff] [blame] | 1926 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1927 | |
| 1928 | /* we don't care if we're in AP mode */ |
| 1929 | if ((wlandev->macmode == WLAN_MACMODE_NONE) || |
| 1930 | (wlandev->macmode == WLAN_MACMODE_ESS_AP)) { |
Devendra Naga | 102db1f | 2012-09-09 18:41:00 +0530 | [diff] [blame] | 1931 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1932 | } |
| 1933 | |
| 1934 | /* It only makes sense to poll these in non-IBSS */ |
| 1935 | if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) { |
Christos Tzoumakis | f9bd649 | 2010-05-07 06:17:24 +0300 | [diff] [blame] | 1936 | result = hfa384x_drvr_getconfig( |
| 1937 | hw, HFA384x_RID_DBMCOMMSQUALITY, |
| 1938 | &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1939 | |
| 1940 | if (result) { |
Tugce Sirin | 80135b1 | 2014-03-17 16:01:51 +0200 | [diff] [blame] | 1941 | netdev_err(wlandev->netdev, "error fetching commsqual\n"); |
Devendra Naga | 102db1f | 2012-09-09 18:41:00 +0530 | [diff] [blame] | 1942 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1943 | } |
| 1944 | |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 1945 | pr_debug("commsqual %d %d %d\n", |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1946 | le16_to_cpu(hw->qual.CQ_currBSS), |
| 1947 | le16_to_cpu(hw->qual.ASL_currBSS), |
| 1948 | le16_to_cpu(hw->qual.ANL_currFC)); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1949 | } |
| 1950 | |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 1951 | /* Get the signal rate */ |
| 1952 | msg.msgcode = DIDmsg_dot11req_mibget; |
| 1953 | mibitem->did = DIDmib_p2_p2MAC_p2CurrentTxRate; |
Jannik Becher | 0e21fa4 | 2016-09-23 01:02:10 +0200 | [diff] [blame] | 1954 | result = p80211req_dorequest(wlandev, (u8 *)&msg); |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 1955 | |
| 1956 | if (result) { |
| 1957 | pr_debug("get signal rate failed, result = %d\n", |
| 1958 | result); |
Devendra Naga | 102db1f | 2012-09-09 18:41:00 +0530 | [diff] [blame] | 1959 | return; |
Karl Relton | cb3126e | 2010-06-03 23:04:06 +0100 | [diff] [blame] | 1960 | } |
| 1961 | |
| 1962 | switch (mibitem->data) { |
| 1963 | case HFA384x_RATEBIT_1: |
| 1964 | hw->txrate = 10; |
| 1965 | break; |
| 1966 | case HFA384x_RATEBIT_2: |
| 1967 | hw->txrate = 20; |
| 1968 | break; |
| 1969 | case HFA384x_RATEBIT_5dot5: |
| 1970 | hw->txrate = 55; |
| 1971 | break; |
| 1972 | case HFA384x_RATEBIT_11: |
| 1973 | hw->txrate = 110; |
| 1974 | break; |
| 1975 | default: |
| 1976 | pr_debug("Bad ratebit (%d)\n", mibitem->data); |
| 1977 | } |
| 1978 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1979 | /* Lastly, we need to make sure the BSSID didn't change on us */ |
| 1980 | result = hfa384x_drvr_getconfig(hw, |
| 1981 | HFA384x_RID_CURRENTBSSID, |
| 1982 | wlandev->bssid, WLAN_BSSID_LEN); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1983 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1984 | pr_debug("getconfig(0x%02x) failed, result = %d\n", |
| 1985 | HFA384x_RID_CURRENTBSSID, result); |
Devendra Naga | 102db1f | 2012-09-09 18:41:00 +0530 | [diff] [blame] | 1986 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1987 | } |
| 1988 | |
| 1989 | result = hfa384x_drvr_getconfig(hw, |
| 1990 | HFA384x_RID_CURRENTSSID, |
| 1991 | &ssid, sizeof(ssid)); |
Moritz Muehlenhoff | f342288 | 2009-02-08 02:21:04 +0100 | [diff] [blame] | 1992 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1993 | pr_debug("getconfig(0x%02x) failed, result = %d\n", |
| 1994 | HFA384x_RID_CURRENTSSID, result); |
Devendra Naga | 102db1f | 2012-09-09 18:41:00 +0530 | [diff] [blame] | 1995 | return; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1996 | } |
Jannik Becher | 0e21fa4 | 2016-09-23 01:02:10 +0200 | [diff] [blame] | 1997 | prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid, |
Sergio Paracuellos | 3fd1e3f | 2016-09-25 15:34:52 +0200 | [diff] [blame] | 1998 | (struct p80211pstrd *)&wlandev->ssid); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1999 | |
| 2000 | /* Reschedule timer */ |
| 2001 | mod_timer(&hw->commsqual_timer, jiffies + HZ); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 2002 | } |
| 2003 | |
| 2004 | void prism2sta_commsqual_timer(unsigned long data) |
| 2005 | { |
Sergio Paracuellos | 5a2214e | 2016-09-28 20:20:19 +0200 | [diff] [blame] | 2006 | struct hfa384x *hw = (struct hfa384x *)data; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 2007 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 2008 | schedule_work(&hw->commsqual_bh); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 2009 | } |