blob: e1b4a94292ff9b6b8b4a40cb44d0f9f93f7e67b0 [file] [log] [blame]
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001/* src/prism2/driver/prism2sta.c
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03002 *
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-Hartman00b3ed12008-10-02 11:29:28 -070052
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070053#include <linux/module.h>
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070054#include <linux/kernel.h>
55#include <linux/sched.h>
56#include <linux/types.h>
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070057#include <linux/slab.h>
58#include <linux/wireless.h>
59#include <linux/netdevice.h>
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070060#include <linux/workqueue.h>
Moritz Muehlenhoffae262302009-01-21 22:00:45 +010061#include <linux/byteorder/generic.h>
Ioana Ciornei7078db92015-03-18 15:26:05 +020062#include <linux/etherdevice.h>
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070063
Andrew Elwellef1a0ed2010-02-18 23:56:12 +010064#include <linux/io.h>
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070065#include <linux/delay.h>
66#include <asm/byteorder.h>
67#include <linux/if_arp.h>
Moritz Muehlenhoff28b17a42009-01-21 22:00:41 +010068#include <linux/if_ether.h>
Moritz Muehlenhoff7f6e0e42009-01-25 21:54:55 +010069#include <linux/bitops.h>
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070070
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070071#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 Peachye02c69b2008-10-29 10:42:59 -040083static char *dev_info = "prism2_usb";
sayli karnikc9573a82016-09-18 15:11:14 +053084static struct wlandevice *create_wlan(void);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070085
Moritz Muehlenhofff3422882009-02-08 02:21:04 +010086int prism2_reset_holdtime = 30; /* Reset hold time in ms */
87int prism2_reset_settletime = 100; /* Reset settle time in ms */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070088
Mithlesh Thukral297f06c2009-06-10 19:36:11 +053089static int prism2_doreset; /* Do a reset at init? */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070090
Moritz Muehlenhofff3422882009-02-08 02:21:04 +010091module_param(prism2_doreset, int, 0644);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070092MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");
93
Moritz Muehlenhofff3422882009-02-08 02:21:04 +010094module_param(prism2_reset_holdtime, int, 0644);
95MODULE_PARM_DESC(prism2_reset_holdtime, "reset hold time in ms");
96module_param(prism2_reset_settletime, int, 0644);
97MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070098
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070099MODULE_LICENSE("Dual MPL/GPL");
100
sayli karnikc9573a82016-09-18 15:11:14 +0530101static int prism2sta_open(struct wlandevice *wlandev);
102static int prism2sta_close(struct wlandevice *wlandev);
103static void prism2sta_reset(struct wlandevice *wlandev);
104static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb,
Edgardo Hames93df38e2010-07-30 22:51:55 -0300105 union p80211_hdr *p80211_hdr,
Edgardo Hames51e48962010-07-31 13:06:52 -0300106 struct p80211_metawep *p80211_wep);
sayli karnikc9573a82016-09-18 15:11:14 +0530107static int prism2sta_mlmerequest(struct wlandevice *wlandev, struct p80211msg *msg);
108static int prism2sta_getcardinfo(struct wlandevice *wlandev);
109static int prism2sta_globalsetup(struct wlandevice *wlandev);
Sergio Paracuellos19066982016-09-27 19:33:51 +0200110static int prism2sta_setmulticast(struct wlandevice *wlandev,
111 struct net_device *dev);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700112
sayli karnikc9573a82016-09-18 15:11:14 +0530113static void prism2sta_inf_handover(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200114 struct hfa384x_InfFrame *inf);
sayli karnikc9573a82016-09-18 15:11:14 +0530115static void prism2sta_inf_tallies(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200116 struct hfa384x_InfFrame *inf);
sayli karnikc9573a82016-09-18 15:11:14 +0530117static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200118 struct hfa384x_InfFrame *inf);
sayli karnikc9573a82016-09-18 15:11:14 +0530119static void prism2sta_inf_scanresults(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200120 struct hfa384x_InfFrame *inf);
sayli karnikc9573a82016-09-18 15:11:14 +0530121static void prism2sta_inf_chinforesults(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200122 struct hfa384x_InfFrame *inf);
sayli karnikc9573a82016-09-18 15:11:14 +0530123static void prism2sta_inf_linkstatus(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200124 struct hfa384x_InfFrame *inf);
sayli karnikc9573a82016-09-18 15:11:14 +0530125static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200126 struct hfa384x_InfFrame *inf);
sayli karnikc9573a82016-09-18 15:11:14 +0530127static void prism2sta_inf_authreq(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200128 struct hfa384x_InfFrame *inf);
sayli karnikc9573a82016-09-18 15:11:14 +0530129static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200130 struct hfa384x_InfFrame *inf);
sayli karnikc9573a82016-09-18 15:11:14 +0530131static void prism2sta_inf_psusercnt(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200132 struct hfa384x_InfFrame *inf);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700133
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300134/*
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 karnikc9573a82016-09-18 15:11:14 +0530155static int prism2sta_open(struct wlandevice *wlandev)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700156{
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700157 /* 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-Hartman00b3ed12008-10-02 11:29:28 -0700165 return 0;
166}
167
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300168/*
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 karnikc9573a82016-09-18 15:11:14 +0530189static int prism2sta_close(struct wlandevice *wlandev)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700190{
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700191 /* 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-Hartman00b3ed12008-10-02 11:29:28 -0700197 return 0;
198}
199
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300200/*
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 karnikc9573a82016-09-18 15:11:14 +0530217static void prism2sta_reset(struct wlandevice *wlandev)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700218{
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700219}
220
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300221/*
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 karnikc9573a82016-09-18 15:11:14 +0530242static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb,
Edgardo Hames93df38e2010-07-30 22:51:55 -0300243 union p80211_hdr *p80211_hdr,
Edgardo Hames51e48962010-07-31 13:06:52 -0300244 struct p80211_metawep *p80211_wep)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700245{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +0200246 struct hfa384x *hw = wlandev->priv;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700247
248 /* If necessary, set the 802.11 WEP bit */
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100249 if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) ==
250 HOSTWEP_PRIVACYINVOKED) {
Moritz Muehlenhoffae262302009-01-21 22:00:45 +0100251 p80211_hdr->a3.fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700252 }
253
Aya Mahfouz9110e0a2015-02-27 14:49:27 +0200254 return hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700255}
256
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300257/*
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 karnikc9573a82016-09-18 15:11:14 +0530281static int prism2sta_mlmerequest(struct wlandevice *wlandev, struct p80211msg *msg)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700282{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +0200283 struct hfa384x *hw = wlandev->priv;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700284
285 int result = 0;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700286
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100287 switch (msg->msgcode) {
288 case DIDmsg_dot11req_mibget:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100289 pr_debug("Received mibget request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700290 result = prism2mgmt_mibset_mibget(wlandev, msg);
291 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100292 case DIDmsg_dot11req_mibset:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100293 pr_debug("Received mibset request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700294 result = prism2mgmt_mibset_mibget(wlandev, msg);
295 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100296 case DIDmsg_dot11req_scan:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100297 pr_debug("Received scan request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700298 result = prism2mgmt_scan(wlandev, msg);
299 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100300 case DIDmsg_dot11req_scan_results:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100301 pr_debug("Received scan_results request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700302 result = prism2mgmt_scan_results(wlandev, msg);
303 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100304 case DIDmsg_dot11req_start:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100305 pr_debug("Received mlme start request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700306 result = prism2mgmt_start(wlandev, msg);
307 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100308 /*
309 * Prism2 specific messages
310 */
311 case DIDmsg_p2req_readpda:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100312 pr_debug("Received mlme readpda request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700313 result = prism2mgmt_readpda(wlandev, msg);
314 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100315 case DIDmsg_p2req_ramdl_state:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100316 pr_debug("Received mlme ramdl_state request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700317 result = prism2mgmt_ramdl_state(wlandev, msg);
318 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100319 case DIDmsg_p2req_ramdl_write:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100320 pr_debug("Received mlme ramdl_write request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700321 result = prism2mgmt_ramdl_write(wlandev, msg);
322 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100323 case DIDmsg_p2req_flashdl_state:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100324 pr_debug("Received mlme flashdl_state request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700325 result = prism2mgmt_flashdl_state(wlandev, msg);
326 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100327 case DIDmsg_p2req_flashdl_write:
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100328 pr_debug("Received mlme flashdl_write request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700329 result = prism2mgmt_flashdl_write(wlandev, msg);
330 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100331 /*
332 * Linux specific messages
333 */
334 case DIDmsg_lnxreq_hostwep:
335 break; /* ignore me. */
336 case DIDmsg_lnxreq_ifstate:
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700337 {
Edgardo Hamesb6bb56e2010-08-02 16:20:39 -0300338 struct p80211msg_lnxreq_ifstate *ifstatemsg;
Johannes Stadlingerf9d01752014-06-19 21:20:20 +0200339
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100340 pr_debug("Received mlme ifstate request\n");
Jannik Becher0e21fa42016-09-23 01:02:10 +0200341 ifstatemsg = (struct p80211msg_lnxreq_ifstate *)msg;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100342 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-Hartman00b3ed12008-10-02 11:29:28 -0700349 }
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100350 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 Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100356 pr_debug("Received mlme autojoin request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700357 result = prism2mgmt_autojoin(wlandev, msg);
358 break;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100359 case DIDmsg_lnxreq_commsquality:{
Edgardo Hamesb6bb56e2010-08-02 16:20:39 -0300360 struct p80211msg_lnxreq_commsquality *qualmsg;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700361
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100362 pr_debug("Received commsquality request\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700363
Jannik Becher0e21fa42016-09-23 01:02:10 +0200364 qualmsg = (struct p80211msg_lnxreq_commsquality *)msg;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700365
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100366 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-Hartman00b3ed12008-10-02 11:29:28 -0700372
Mithlesh Thukral75f49e02009-05-25 19:06:16 +0530373 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 Reltoncb3126e2010-06-03 23:04:06 +0100376 qualmsg->txrate.data = hw->txrate;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700377
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100378 break;
379 }
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700380 default:
Vitaly Osipov02d9b1e2014-05-18 16:59:36 +1000381 netdev_warn(wlandev->netdev,
382 "Unknown mgmt request message 0x%08x",
383 msg->msgcode);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700384 break;
385 }
386
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700387 return result;
388}
389
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300390/*
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 karnikc9573a82016-09-18 15:11:14 +0530411u32 prism2sta_ifstate(struct wlandevice *wlandev, u32 ifstate)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700412{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +0200413 struct hfa384x *hw = wlandev->priv;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100414 u32 result;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700415
416 result = P80211ENUM_resultcode_implementation_failure;
417
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100418 pr_debug("Current MSD state(%d), requesting(%d)\n",
Mithlesh Thukral75f49e02009-05-25 19:06:16 +0530419 wlandev->msdstate, ifstate);
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100420 switch (ifstate) {
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700421 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 Thukral297f06c2009-06-10 19:36:11 +0530429 result = hfa384x_drvr_start(hw);
430 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200431 netdev_err(wlandev->netdev,
chaehyun lim613462e2015-05-15 22:13:43 +0900432 "hfa384x_drvr_start() failed,result=%d\n",
433 (int)result);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700434 result =
Christos Tzoumakisf9bd6492010-05-07 06:17:24 +0300435 P80211ENUM_resultcode_implementation_failure;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700436 wlandev->msdstate = WLAN_MSD_HWPRESENT;
437 break;
438 }
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700439 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 Osipov02d9b1e2014-05-18 16:59:36 +1000447 netdev_warn(wlandev->netdev,
Johannes Stadlinger392cdc92014-06-19 21:20:19 +0200448 "Cannot enter fwload state from enable state, you must disable first.\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700449 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 Thukral297f06c2009-06-10 19:36:11 +0530473 result = hfa384x_drvr_start(hw);
474 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200475 netdev_err(wlandev->netdev,
chaehyun lim613462e2015-05-15 22:13:43 +0900476 "hfa384x_drvr_start() failed,result=%d\n",
477 (int)result);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700478 result =
Christos Tzoumakisf9bd6492010-05-07 06:17:24 +0300479 P80211ENUM_resultcode_implementation_failure;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700480 wlandev->msdstate = WLAN_MSD_HWPRESENT;
481 break;
482 }
483
Mithlesh Thukral297f06c2009-06-10 19:36:11 +0530484 result = prism2sta_getcardinfo(wlandev);
485 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200486 netdev_err(wlandev->netdev,
chaehyun lim613462e2015-05-15 22:13:43 +0900487 "prism2sta_getcardinfo() failed,result=%d\n",
488 (int)result);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700489 result =
Christos Tzoumakisf9bd6492010-05-07 06:17:24 +0300490 P80211ENUM_resultcode_implementation_failure;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700491 hfa384x_drvr_stop(hw);
492 wlandev->msdstate = WLAN_MSD_HWPRESENT;
493 break;
494 }
Mithlesh Thukral297f06c2009-06-10 19:36:11 +0530495 result = prism2sta_globalsetup(wlandev);
496 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200497 netdev_err(wlandev->netdev,
chaehyun lim613462e2015-05-15 22:13:43 +0900498 "prism2sta_globalsetup() failed,result=%d\n",
499 (int)result);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700500 result =
Christos Tzoumakisf9bd6492010-05-07 06:17:24 +0300501 P80211ENUM_resultcode_implementation_failure;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700502 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 Muehlenhofff3422882009-02-08 02:21:04 +0100512 /* Do nothing, we're already in this state. */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700513 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 Muehlenhofff3422882009-02-08 02:21:04 +0100527 /* Do nothing, we're already in this state. */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700528 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-Hartman00b3ed12008-10-02 11:29:28 -0700562 return result;
563}
564
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300565/*
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 karnikc9573a82016-09-18 15:11:14 +0530584static int prism2sta_getcardinfo(struct wlandevice *wlandev)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700585{
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100586 int result = 0;
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +0200587 struct hfa384x *hw = wlandev->priv;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100588 u16 temp;
589 u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN];
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700590
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700591 /* 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 Muehlenhofff3422882009-02-08 02:21:04 +0100595 &hw->ident_nic,
Sergio Paracuellos5f046452016-09-28 20:18:55 +0200596 sizeof(struct hfa384x_compident));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100597 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200598 netdev_err(wlandev->netdev, "Failed to retrieve NICIDENTITY\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700599 goto failed;
600 }
601
602 /* get all the nic id fields in host byte order */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100603 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-Hartman00b3ed12008-10-02 11:29:28 -0700607
Tugce Sirin1f997412014-03-17 16:02:05 +0200608 netdev_info(wlandev->netdev, "ident: nic h/w: id=0x%02x %d.%d.%d\n",
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100609 hw->ident_nic.id, hw->ident_nic.major,
610 hw->ident_nic.minor, hw->ident_nic.variant);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700611
612 /* Primary f/w identity */
613 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100614 &hw->ident_pri_fw,
Sergio Paracuellos5f046452016-09-28 20:18:55 +0200615 sizeof(struct hfa384x_compident));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100616 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200617 netdev_err(wlandev->netdev, "Failed to retrieve PRIIDENTITY\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700618 goto failed;
619 }
620
621 /* get all the private fw id fields in host byte order */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100622 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-Hartman00b3ed12008-10-02 11:29:28 -0700626
Tugce Sirin1f997412014-03-17 16:02:05 +0200627 netdev_info(wlandev->netdev, "ident: pri f/w: id=0x%02x %d.%d.%d\n",
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100628 hw->ident_pri_fw.id, hw->ident_pri_fw.major,
629 hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700630
631 /* Station (Secondary?) f/w identity */
632 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100633 &hw->ident_sta_fw,
Sergio Paracuellos5f046452016-09-28 20:18:55 +0200634 sizeof(struct hfa384x_compident));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100635 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200636 netdev_err(wlandev->netdev, "Failed to retrieve STAIDENTITY\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700637 goto failed;
638 }
639
640 if (hw->ident_nic.id < 0x8000) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200641 netdev_err(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100642 "FATAL: Card is not an Intersil Prism2/2.5/3\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700643 result = -1;
644 goto failed;
645 }
646
647 /* get all the station fw id fields in host byte order */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100648 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-Hartman00b3ed12008-10-02 11:29:28 -0700652
653 /* strip out the 'special' variant bits */
Moritz Muehlenhoff7f6e0e42009-01-25 21:54:55 +0100654 hw->mm_mods = hw->ident_sta_fw.variant & (BIT(14) | BIT(15));
Jannik Becher0e21fa42016-09-23 01:02:10 +0200655 hw->ident_sta_fw.variant &= ~((u16)(BIT(14) | BIT(15)));
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700656
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100657 if (hw->ident_sta_fw.id == 0x1f) {
Tugce Sirin1f997412014-03-17 16:02:05 +0200658 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100659 "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-Hartman00b3ed12008-10-02 11:29:28 -0700662 } else {
Tugce Sirin1f997412014-03-17 16:02:05 +0200663 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100664 "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 Iida1a6dfce2014-12-01 00:29:00 +0900667 netdev_err(wlandev->netdev, "Unsupported Tertiary AP firmware loaded!\n");
Solomon Peachy5db8dcc2008-10-27 11:14:02 -0400668 goto failed;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700669 }
670
671 /* Compatibility range, Modem supplier */
672 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100673 &hw->cap_sup_mfi,
Sergio Paracuellos65f170c2016-09-28 20:18:57 +0200674 sizeof(struct hfa384x_caplevel));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100675 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200676 netdev_err(wlandev->netdev, "Failed to retrieve MFISUPRANGE\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700677 goto failed;
678 }
679
680 /* get all the Compatibility range, modem interface supplier
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300681 * fields in byte order
682 */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100683 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-Hartman00b3ed12008-10-02 11:29:28 -0700688
Tugce Sirin1f997412014-03-17 16:02:05 +0200689 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100690 "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-Hartman00b3ed12008-10-02 11:29:28 -0700694
695 /* Compatibility range, Controller supplier */
696 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100697 &hw->cap_sup_cfi,
Sergio Paracuellos65f170c2016-09-28 20:18:57 +0200698 sizeof(struct hfa384x_caplevel));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100699 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200700 netdev_err(wlandev->netdev, "Failed to retrieve CFISUPRANGE\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700701 goto failed;
702 }
703
704 /* get all the Compatibility range, controller interface supplier
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300705 * fields in byte order
706 */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100707 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-Hartman00b3ed12008-10-02 11:29:28 -0700712
Tugce Sirin1f997412014-03-17 16:02:05 +0200713 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100714 "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-Hartman00b3ed12008-10-02 11:29:28 -0700718
719 /* Compatibility range, Primary f/w supplier */
720 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100721 &hw->cap_sup_pri,
Sergio Paracuellos65f170c2016-09-28 20:18:57 +0200722 sizeof(struct hfa384x_caplevel));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100723 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200724 netdev_err(wlandev->netdev, "Failed to retrieve PRISUPRANGE\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700725 goto failed;
726 }
727
728 /* get all the Compatibility range, primary firmware supplier
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300729 * fields in byte order
730 */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100731 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-Hartman00b3ed12008-10-02 11:29:28 -0700736
Tugce Sirin1f997412014-03-17 16:02:05 +0200737 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100738 "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-Hartman00b3ed12008-10-02 11:29:28 -0700742
743 /* Compatibility range, Station f/w supplier */
744 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100745 &hw->cap_sup_sta,
Sergio Paracuellos65f170c2016-09-28 20:18:57 +0200746 sizeof(struct hfa384x_caplevel));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100747 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200748 netdev_err(wlandev->netdev, "Failed to retrieve STASUPRANGE\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700749 goto failed;
750 }
751
752 /* get all the Compatibility range, station firmware supplier
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300753 * fields in byte order
754 */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100755 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-Hartman00b3ed12008-10-02 11:29:28 -0700760
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100761 if (hw->cap_sup_sta.id == 0x04) {
Tugce Sirin1f997412014-03-17 16:02:05 +0200762 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100763 "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-Hartman00b3ed12008-10-02 11:29:28 -0700767 } else {
Tugce Sirin1f997412014-03-17 16:02:05 +0200768 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100769 "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-Hartman00b3ed12008-10-02 11:29:28 -0700773 }
774
775 /* Compatibility range, primary f/w actor, CFI supplier */
776 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100777 &hw->cap_act_pri_cfi,
Sergio Paracuellos65f170c2016-09-28 20:18:57 +0200778 sizeof(struct hfa384x_caplevel));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100779 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200780 netdev_err(wlandev->netdev, "Failed to retrieve PRI_CFIACTRANGES\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700781 goto failed;
782 }
783
784 /* get all the Compatibility range, primary f/w actor, CFI supplier
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300785 * fields in byte order
786 */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100787 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 Thukral75f49e02009-05-25 19:06:16 +0530789 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 Muehlenhoff18c7f792009-02-18 19:50:07 +0100791 hw->cap_act_pri_cfi.top = le16_to_cpu(hw->cap_act_pri_cfi.top);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700792
Tugce Sirin1f997412014-03-17 16:02:05 +0200793 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100794 "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-Hartman00b3ed12008-10-02 11:29:28 -0700798
799 /* Compatibility range, sta f/w actor, CFI supplier */
800 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100801 &hw->cap_act_sta_cfi,
Sergio Paracuellos65f170c2016-09-28 20:18:57 +0200802 sizeof(struct hfa384x_caplevel));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100803 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200804 netdev_err(wlandev->netdev, "Failed to retrieve STA_CFIACTRANGES\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700805 goto failed;
806 }
807
808 /* get all the Compatibility range, station f/w actor, CFI supplier
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300809 * fields in byte order
810 */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100811 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 Thukral75f49e02009-05-25 19:06:16 +0530813 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 Muehlenhoff18c7f792009-02-18 19:50:07 +0100815 hw->cap_act_sta_cfi.top = le16_to_cpu(hw->cap_act_sta_cfi.top);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700816
Tugce Sirin1f997412014-03-17 16:02:05 +0200817 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100818 "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-Hartman00b3ed12008-10-02 11:29:28 -0700822
823 /* Compatibility range, sta f/w actor, MFI supplier */
824 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100825 &hw->cap_act_sta_mfi,
Sergio Paracuellos65f170c2016-09-28 20:18:57 +0200826 sizeof(struct hfa384x_caplevel));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100827 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200828 netdev_err(wlandev->netdev, "Failed to retrieve STA_MFIACTRANGES\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700829 goto failed;
830 }
831
832 /* get all the Compatibility range, station f/w actor, MFI supplier
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300833 * fields in byte order
834 */
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +0100835 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 Thukral75f49e02009-05-25 19:06:16 +0530837 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 Muehlenhoff18c7f792009-02-18 19:50:07 +0100839 hw->cap_act_sta_mfi.top = le16_to_cpu(hw->cap_act_sta_mfi.top);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700840
Tugce Sirin1f997412014-03-17 16:02:05 +0200841 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100842 "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-Hartman00b3ed12008-10-02 11:29:28 -0700846
847 /* Serial Number */
848 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100849 snum, HFA384x_RID_NICSERIALNUMBER_LEN);
850 if (!result) {
Andy Shevchenko068c11d2014-10-13 15:55:29 -0700851 netdev_info(wlandev->netdev, "Prism2 card SN: %*pEhp\n",
852 HFA384x_RID_NICSERIALNUMBER_LEN, snum);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700853 } else {
Tugce Sirin80135b12014-03-17 16:01:51 +0200854 netdev_err(wlandev->netdev, "Failed to retrieve Prism2 Card SN\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700855 goto failed;
856 }
857
858 /* Collect the MAC address */
859 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100860 wlandev->netdev->dev_addr, ETH_ALEN);
861 if (result != 0) {
Tugce Sirin80135b12014-03-17 16:01:51 +0200862 netdev_err(wlandev->netdev, "Failed to retrieve mac address\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700863 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 Muehlenhofff3422882009-02-08 02:21:04 +0100879 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-Hartman00b3ed12008-10-02 11:29:28 -0700883 wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN;
884 }
885
886 /* TODO: Set any internally managed config items */
887
888 goto done;
889failed:
Tugce Sirin80135b12014-03-17 16:01:51 +0200890 netdev_err(wlandev->netdev, "Failed, result=%d\n", result);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700891done:
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700892 return result;
893}
894
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300895/*
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 karnikc9573a82016-09-18 15:11:14 +0530913static int prism2sta_globalsetup(struct wlandevice *wlandev)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700914{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +0200915 struct hfa384x *hw = wlandev->priv;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700916
917 /* Set the maximum frame size */
918 return hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100919 WLAN_DATA_MAXLEN);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700920}
921
Sergio Paracuellos19066982016-09-27 19:33:51 +0200922static int prism2sta_setmulticast(struct wlandevice *wlandev,
923 struct net_device *dev)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700924{
925 int result = 0;
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +0200926 struct hfa384x *hw = wlandev->priv;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700927
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100928 u16 promisc;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700929
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700930 /* If we're not ready, what's the point? */
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100931 if (hw->state != HFA384x_STATE_RUNNING)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700932 goto exit;
933
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100934 if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700935 promisc = P80211ENUM_truth_true;
936 else
937 promisc = P80211ENUM_truth_false;
938
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100939 result =
940 hfa384x_drvr_setconfig16_async(hw, HFA384x_RID_PROMISCMODE,
941 promisc);
942exit:
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700943 return result;
944}
945
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300946/*
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 karnikc9573a82016-09-18 15:11:14 +0530964static void prism2sta_inf_handover(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200965 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700966{
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +0100967 pr_debug("received infoframe:HANDOVER (unhandled)\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700968}
969
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300970/*
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 karnikc9573a82016-09-18 15:11:14 +0530987static void prism2sta_inf_tallies(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +0200988 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700989{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +0200990 struct hfa384x *hw = wlandev->priv;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +0100991 u16 *src16;
992 u32 *dst;
993 u32 *src32;
994 int i;
995 int cnt;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700996
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700997 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +0300998 * Determine if these are 16-bit or 32-bit tallies, based on the
999 * record length of the info record.
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001000 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001001
Sergio Paracuelloscfc6cb12016-09-28 20:19:08 +02001002 cnt = sizeof(struct hfa384x_CommTallies32) / sizeof(u32);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001003 if (inf->framelen > 22) {
Jannik Becher0e21fa42016-09-23 01:02:10 +02001004 dst = (u32 *)&hw->tallies;
1005 src32 = (u32 *)&inf->info.commtallies32;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001006 for (i = 0; i < cnt; i++, dst++, src32++)
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +01001007 *dst += le32_to_cpu(*src32);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001008 } else {
Jannik Becher0e21fa42016-09-23 01:02:10 +02001009 dst = (u32 *)&hw->tallies;
1010 src16 = (u16 *)&inf->info.commtallies16;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001011 for (i = 0; i < cnt; i++, dst++, src16++)
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +01001012 *dst += le16_to_cpu(*src16);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001013 }
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001014}
1015
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001016/*
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 karnikc9573a82016-09-18 15:11:14 +05301033static void prism2sta_inf_scanresults(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001034 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001035{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001036 struct hfa384x *hw = wlandev->priv;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001037 int nbss;
Sergio Paracuellosdc0bb002016-09-28 20:19:10 +02001038 struct hfa384x_ScanResult *sr = &(inf->info.scanresult);
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001039 int i;
Sergio Paracuellosf0ffa0e2016-09-28 20:18:59 +02001040 struct hfa384x_JoinRequest_data joinreq;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001041 int result;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001042
1043 /* Get the number of results, first in bytes, then in results */
Solomon Peachyaaad4302008-10-29 10:42:53 -04001044 nbss = (inf->framelen * sizeof(u16)) -
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001045 sizeof(inf->infotype) - sizeof(inf->info.scanresult.scanreason);
Sergio Paracuellos44003342016-09-28 20:19:09 +02001046 nbss /= sizeof(struct hfa384x_ScanResultSub);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001047
1048 /* Print em */
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +01001049 pr_debug("rx scanresults, reason=%d, nbss=%d:\n",
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301050 inf->info.scanresult.scanreason, nbss);
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001051 for (i = 0; i < nbss; i++) {
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +01001052 pr_debug("chid=%d anl=%d sl=%d bcnint=%d\n",
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301053 sr->result[i].chid,
1054 sr->result[i].anl,
1055 sr->result[i].sl, sr->result[i].bcnint);
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +01001056 pr_debug(" capinfo=0x%04x proberesp_rate=%d\n",
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301057 sr->result[i].capinfo, sr->result[i].proberesp_rate);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001058 }
1059 /* issue a join request */
1060 joinreq.channel = sr->result[0].chid;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001061 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-Hartman00b3ed12008-10-02 11:29:28 -07001065 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +02001066 netdev_err(wlandev->netdev, "setconfig(joinreq) failed, result=%d\n",
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001067 result);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001068 }
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001069}
1070
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001071/*
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 karnikc9573a82016-09-18 15:11:14 +05301088static void prism2sta_inf_hostscanresults(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001089 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001090{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001091 struct hfa384x *hw = wlandev->priv;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001092 int nbss;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001093
1094 nbss = (inf->framelen - 3) / 32;
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +01001095 pr_debug("Received %d hostscan results\n", nbss);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001096
1097 if (nbss > 32)
1098 nbss = 32;
1099
Moritz Muehlenhoff7c98f712009-02-09 19:33:42 +01001100 kfree(hw->scanresults);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001101
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001102 hw->scanresults = kmemdup(inf, sizeof(struct hfa384x_InfFrame), GFP_ATOMIC);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001103
1104 if (nbss == 0)
1105 nbss = -1;
1106
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001107 /* Notify/wake the sleeping caller. */
1108 hw->scanflag = nbss;
1109 wake_up_interruptible(&hw->cmdq);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001110};
1111
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001112/*
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 karnikc9573a82016-09-18 15:11:14 +05301129static void prism2sta_inf_chinforesults(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001130 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001131{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001132 struct hfa384x *hw = wlandev->priv;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001133 unsigned int i, n;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001134
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001135 hw->channel_info.results.scanchannels =
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +01001136 le16_to_cpu(inf->info.chinforesult.scanchannels);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001137
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001138 for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) {
Sergio Paracuellos1bc4292a2016-09-28 20:19:11 +02001139 struct hfa384x_ChInfoResultSub *result;
1140 struct hfa384x_ChInfoResultSub *chinforesult;
Dan Carpentera0cdd2e2013-02-27 08:12:06 +03001141 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 Carpenter72c1c062013-02-27 08:13:45 +03001149 if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX)
1150 continue;
1151
Dan Carpentera0cdd2e2013-02-27 08:12:06 +03001152 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-Hartman00b3ed12008-10-02 11:29:28 -07001166 }
1167 atomic_set(&hw->channel_info.done, 2);
1168
1169 hw->channel_info.count = n;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001170}
1171
1172void prism2sta_processing_defer(struct work_struct *data)
1173{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001174 struct hfa384x *hw = container_of(data, struct hfa384x, link_bh);
sayli karnikc9573a82016-09-18 15:11:14 +05301175 struct wlandevice *wlandev = hw->wlandev;
Sergio Paracuellos03c29752016-09-28 20:18:54 +02001176 struct hfa384x_bytestr32 ssid;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001177 int result;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001178
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001179 /* First let's process the auth frames */
1180 {
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001181 struct sk_buff *skb;
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001182 struct hfa384x_InfFrame *inf;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001183
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001184 while ((skb = skb_dequeue(&hw->authq))) {
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001185 inf = (struct hfa384x_InfFrame *)skb->data;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001186 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 Naga5d6f5052012-09-13 15:01:39 +05301193 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001194
1195 hw->link_status = hw->link_status_new;
1196
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001197 switch (hw->link_status) {
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001198 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 Sirin1f997412014-03-17 16:02:05 +02001207 netdev_info(wlandev->netdev, "linkstatus=NOTCONNECTED (unhandled)\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001208 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 Tzoumakisf9bd6492010-05-07 06:17:24 +03001223 /* If we are joining a specific AP, set our
1224 * state and reset retries
1225 */
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001226 if (hw->join_ap == 1)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001227 hw->join_ap = 2;
1228 hw->join_retries = 60;
1229
1230 /* Don't call this in monitor mode */
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001231 if (wlandev->netdev->type == ARPHRD_ETHER) {
1232 u16 portstatus;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001233
Tugce Sirin1f997412014-03-17 16:02:05 +02001234 netdev_info(wlandev->netdev, "linkstatus=CONNECTED\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001235
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 Tzoumakisf9bd6492010-05-07 06:17:24 +03001240 HFA384x_RID_CURRENTBSSID,
1241 wlandev->bssid,
1242 WLAN_BSSID_LEN);
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001243 if (result) {
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301244 pr_debug
1245 ("getconfig(0x%02x) failed, result = %d\n",
1246 HFA384x_RID_CURRENTBSSID, result);
Devendra Naga5d6f5052012-09-13 15:01:39 +05301247 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001248 }
1249
1250 result = hfa384x_drvr_getconfig(hw,
1251 HFA384x_RID_CURRENTSSID,
1252 &ssid, sizeof(ssid));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001253 if (result) {
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301254 pr_debug
1255 ("getconfig(0x%02x) failed, result = %d\n",
1256 HFA384x_RID_CURRENTSSID, result);
Devendra Naga5d6f5052012-09-13 15:01:39 +05301257 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001258 }
chaehyun lim613462e2015-05-15 22:13:43 +09001259 prism2mgmt_bytestr2pstr(
Jannik Becher0e21fa42016-09-23 01:02:10 +02001260 (struct hfa384x_bytestr *)&ssid,
Sergio Paracuellos3fd1e3f2016-09-25 15:34:52 +02001261 (struct p80211pstrd *)&wlandev->ssid);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001262
1263 /* Collect the port status */
1264 result = hfa384x_drvr_getconfig16(hw,
Christos Tzoumakisf9bd6492010-05-07 06:17:24 +03001265 HFA384x_RID_PORTSTATUS,
1266 &portstatus);
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001267 if (result) {
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301268 pr_debug
1269 ("getconfig(0x%02x) failed, result = %d\n",
1270 HFA384x_RID_PORTSTATUS, result);
Devendra Naga5d6f5052012-09-13 15:01:39 +05301271 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001272 }
1273 wlandev->macmode =
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001274 (portstatus == HFA384x_PSTATUS_CONN_IBSS) ?
1275 WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001276
Karl Reltoncb3126e2010-06-03 23:04:06 +01001277 /* signal back up to cfg80211 layer */
1278 prism2_connect_result(wlandev, P80211ENUM_truth_false);
1279
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001280 /* 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 Reltoncb3126e2010-06-03 23:04:06 +01001295 if (wlandev->netdev->type == ARPHRD_ETHER)
Tugce Sirin1f997412014-03-17 16:02:05 +02001296 netdev_info(wlandev->netdev,
Karl Reltoncb3126e2010-06-03 23:04:06 +01001297 "linkstatus=DISCONNECTED (unhandled)\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001298 wlandev->macmode = WLAN_MACMODE_NONE;
1299
1300 netif_carrier_off(wlandev->netdev);
1301
Karl Reltoncb3126e2010-06-03 23:04:06 +01001302 /* signal back up to cfg80211 layer */
1303 prism2_disconnected(wlandev);
1304
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001305 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 Sirin1f997412014-03-17 16:02:05 +02001322 netdev_info(wlandev->netdev, "linkstatus=AP_CHANGE\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001323
1324 result = hfa384x_drvr_getconfig(hw,
1325 HFA384x_RID_CURRENTBSSID,
1326 wlandev->bssid, WLAN_BSSID_LEN);
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001327 if (result) {
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301328 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1329 HFA384x_RID_CURRENTBSSID, result);
Devendra Naga5d6f5052012-09-13 15:01:39 +05301330 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001331 }
1332
1333 result = hfa384x_drvr_getconfig(hw,
1334 HFA384x_RID_CURRENTSSID,
1335 &ssid, sizeof(ssid));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001336 if (result) {
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301337 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1338 HFA384x_RID_CURRENTSSID, result);
Devendra Naga5d6f5052012-09-13 15:01:39 +05301339 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001340 }
Jannik Becher0e21fa42016-09-23 01:02:10 +02001341 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
Sergio Paracuellos3fd1e3f2016-09-25 15:34:52 +02001342 (struct p80211pstrd *)&wlandev->ssid);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001343
1344 hw->link_status = HFA384x_LINK_CONNECTED;
1345 netif_carrier_on(wlandev->netdev);
1346
Karl Reltoncb3126e2010-06-03 23:04:06 +01001347 /* signal back up to cfg80211 layer */
1348 prism2_roamed(wlandev);
1349
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001350 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 Sirin1f997412014-03-17 16:02:05 +02001364 netdev_info(wlandev->netdev, "linkstatus=AP_OUTOFRANGE (unhandled)\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001365
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 Sirin1f997412014-03-17 16:02:05 +02001377 netdev_info(wlandev->netdev, "linkstatus=AP_INRANGE\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001378
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 Muehlenhofff3422882009-02-08 02:21:04 +01001393 if (hw->join_ap && --hw->join_retries > 0) {
Sergio Paracuellosf0ffa0e2016-09-28 20:18:59 +02001394 struct hfa384x_JoinRequest_data joinreq;
Johannes Stadlingerf9d01752014-06-19 21:20:20 +02001395
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001396 joinreq = hw->joinreq;
1397 /* Send the join request */
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001398 hfa384x_drvr_setconfig(hw,
1399 HFA384x_RID_JOINREQUEST,
1400 &joinreq,
1401 HFA384x_RID_JOINREQUEST_LEN);
Tugce Sirin1f997412014-03-17 16:02:05 +02001402 netdev_info(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001403 "linkstatus=ASSOCFAIL (re-submitting join)\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001404 } else {
Tugce Sirin1f997412014-03-17 16:02:05 +02001405 netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL (unhandled)\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001406 }
1407
1408 netif_carrier_off(wlandev->netdev);
1409
Karl Reltoncb3126e2010-06-03 23:04:06 +01001410 /* signal back up to cfg80211 layer */
1411 prism2_connect_result(wlandev, P80211ENUM_truth_true);
1412
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001413 break;
1414
1415 default:
1416 /* This is bad, IO port problems? */
Vitaly Osipov02d9b1e2014-05-18 16:59:36 +10001417 netdev_warn(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001418 "unknown linkstatus=0x%02x\n", hw->link_status);
Devendra Naga5d6f5052012-09-13 15:01:39 +05301419 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001420 }
1421
1422 wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001423}
1424
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001425/*
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 karnikc9573a82016-09-18 15:11:14 +05301442static void prism2sta_inf_linkstatus(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001443 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001444{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001445 struct hfa384x *hw = wlandev->priv;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001446
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +01001447 hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001448
1449 schedule_work(&hw->link_bh);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001450}
1451
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001452/*
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 karnikc9573a82016-09-18 15:11:14 +05301470static void prism2sta_inf_assocstatus(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001471 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001472{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001473 struct hfa384x *hw = wlandev->priv;
Sergio Paracuellos5383f132016-09-28 20:19:16 +02001474 struct hfa384x_AssocStatus rec;
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001475 int i;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001476
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001477 memcpy(&rec, &inf->info.assocstatus, sizeof(rec));
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +01001478 rec.assocstatus = le16_to_cpu(rec.assocstatus);
1479 rec.reason = le16_to_cpu(rec.reason);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001480
1481 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001482 * 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 Muehlenhofff3422882009-02-08 02:21:04 +01001491 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001492
1493 for (i = 0; i < hw->authlist.cnt; i++)
Maciek Borzeckia305cf32015-10-03 16:01:36 +02001494 if (ether_addr_equal(rec.sta_addr, hw->authlist.addr[i]))
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001495 break;
1496
1497 if (i >= hw->authlist.cnt) {
1498 if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL)
Vitaly Osipov02d9b1e2014-05-18 16:59:36 +10001499 netdev_warn(wlandev->netdev,
Christos Tzoumakisf9bd6492010-05-07 06:17:24 +03001500 "assocstatus info frame received for non-authenticated station.\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001501 } else {
1502 hw->authlist.assoc[i] =
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001503 (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC ||
1504 rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001505
1506 if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL)
Vitaly Osipov02d9b1e2014-05-18 16:59:36 +10001507 netdev_warn(wlandev->netdev,
Christos Tzoumakisf9bd6492010-05-07 06:17:24 +03001508"authfail assocstatus info frame received for authenticated station.\n");
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001509 }
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001510}
1511
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001512/*
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 karnikc9573a82016-09-18 15:11:14 +05301531static void prism2sta_inf_authreq(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001532 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001533{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001534 struct hfa384x *hw = wlandev->priv;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001535 struct sk_buff *skb;
1536
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001537 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-Hartman00b3ed12008-10-02 11:29:28 -07001544}
1545
sayli karnikc9573a82016-09-18 15:11:14 +05301546static void prism2sta_inf_authreq_defer(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001547 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001548{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001549 struct hfa384x *hw = wlandev->priv;
Sergio Paracuellos17fb19f2016-09-28 20:19:00 +02001550 struct hfa384x_authenticateStation_data rec;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001551
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001552 int i, added, result, cnt;
1553 u8 *addr;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001554
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001555 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001556 * Build the AuthenticateStation record. Initialize it for denying
1557 * authentication.
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001558 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001559
Ioana Ciornei7078db92015-03-18 15:26:05 +02001560 ether_addr_copy(rec.address, inf->info.authreq.sta_addr);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001561 rec.status = P80211ENUM_status_unspec_failure;
1562
1563 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001564 * Authenticate based on the access mode.
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001565 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001566
1567 switch (hw->accessmode) {
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001568 case WLAN_ACCESS_NONE:
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001569
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001570 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001571 * Deny all new authentications. However, if a station
1572 * is ALREADY authenticated, then accept it.
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001573 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001574
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001575 for (i = 0; i < hw->authlist.cnt; i++)
Maciek Borzeckia305cf32015-10-03 16:01:36 +02001576 if (ether_addr_equal(rec.address,
1577 hw->authlist.addr[i])) {
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001578 rec.status = P80211ENUM_status_successful;
1579 break;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001580 }
1581
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001582 break;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001583
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001584 case WLAN_ACCESS_ALL:
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001585
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001586 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001587 * Allow all authentications.
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001588 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001589
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001590 rec.status = P80211ENUM_status_successful;
1591 break;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001592
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001593 case WLAN_ACCESS_ALLOW:
1594
1595 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001596 * 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 Muehlenhofff3422882009-02-08 02:21:04 +01001603 */
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 Borzeckia305cf32015-10-03 16:01:36 +02001614 if (ether_addr_equal(rec.address, addr)) {
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001615 rec.status = P80211ENUM_status_successful;
1616 break;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001617 }
1618
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001619 break;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001620
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001621 case WLAN_ACCESS_DENY:
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001622
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001623 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001624 * 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 Muehlenhofff3422882009-02-08 02:21:04 +01001631 */
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 Borzeckia305cf32015-10-03 16:01:36 +02001644 if (ether_addr_equal(rec.address, addr)) {
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001645 rec.status = P80211ENUM_status_unspec_failure;
1646 break;
1647 }
1648
1649 break;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001650 }
1651
1652 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001653 * 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 Muehlenhofff3422882009-02-08 02:21:04 +01001659 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001660
1661 added = 0;
1662
1663 if (rec.status == P80211ENUM_status_successful) {
1664 for (i = 0; i < hw->authlist.cnt; i++)
Maciek Borzeckia305cf32015-10-03 16:01:36 +02001665 if (ether_addr_equal(rec.address,
1666 hw->authlist.addr[i]))
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001667 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 lim613462e2015-05-15 22:13:43 +09001673 ether_addr_copy(
1674 hw->authlist.addr[hw->authlist.cnt],
1675 rec.address);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001676 hw->authlist.cnt++;
1677 added = 1;
1678 }
1679 }
1680 }
1681
1682 /*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001683 * 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 Muehlenhofff3422882009-02-08 02:21:04 +01001686 */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001687
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +01001688 rec.status = cpu_to_le16(rec.status);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001689 rec.algorithm = inf->info.authreq.algorithm;
1690
1691 result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001692 &rec, sizeof(rec));
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001693 if (result) {
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001694 if (added)
1695 hw->authlist.cnt--;
Tugce Sirin80135b12014-03-17 16:01:51 +02001696 netdev_err(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001697 "setconfig(authenticatestation) failed, result=%d\n",
1698 result);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001699 }
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001700}
1701
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001702/*
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 karnikc9573a82016-09-18 15:11:14 +05301720static void prism2sta_inf_psusercnt(struct wlandevice *wlandev,
Sergio Paracuellosf69de9e2016-09-28 20:19:21 +02001721 struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001722{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001723 struct hfa384x *hw = wlandev->priv;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001724
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +01001725 hw->psusercount = le16_to_cpu(inf->info.psusercnt.usercnt);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001726}
1727
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001728/*
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 Paracuellosf69de9e2016-09-28 20:19:21 +02001745void prism2sta_ev_info(struct wlandevice *wlandev, struct hfa384x_InfFrame *inf)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001746{
Moritz Muehlenhoff18c7f792009-02-18 19:50:07 +01001747 inf->infotype = le16_to_cpu(inf->infotype);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001748 /* Dispatch */
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001749 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 Osipov02d9b1e2014-05-18 16:59:36 +10001778 netdev_warn(wlandev->netdev, "Unhandled IT_KEYIDCHANGED\n");
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001779 break;
1780 case HFA384x_IT_ASSOCREQ:
Vitaly Osipov02d9b1e2014-05-18 16:59:36 +10001781 netdev_warn(wlandev->netdev, "Unhandled IT_ASSOCREQ\n");
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001782 break;
1783 case HFA384x_IT_MICFAILURE:
Vitaly Osipov02d9b1e2014-05-18 16:59:36 +10001784 netdev_warn(wlandev->netdev, "Unhandled IT_MICFAILURE\n");
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001785 break;
1786 default:
Vitaly Osipov02d9b1e2014-05-18 16:59:36 +10001787 netdev_warn(wlandev->netdev,
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001788 "Unknown info type=0x%02x\n", inf->infotype);
1789 break;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001790 }
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001791}
1792
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001793/*
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 karnikc9573a82016-09-18 15:11:14 +05301812void prism2sta_ev_txexc(struct wlandevice *wlandev, u16 status)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001813{
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +01001814 pr_debug("TxExc status=0x%x.\n", status);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001815}
1816
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001817/*
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 karnikc9573a82016-09-18 15:11:14 +05301833void prism2sta_ev_tx(struct wlandevice *wlandev, u16 status)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001834{
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +01001835 pr_debug("Tx Complete, status=0x%04x\n", status);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001836 /* update linux network stats */
Tobias Klauser9630f6b2014-07-08 08:37:00 +02001837 wlandev->netdev->stats.tx_packets++;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001838}
1839
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001840/*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001841 * 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 karnikc9573a82016-09-18 15:11:14 +05301856void prism2sta_ev_alloc(struct wlandevice *wlandev)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001857{
Solomon Peachycbec30c2008-10-29 10:42:57 -04001858 netif_wake_queue(wlandev->netdev);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001859}
1860
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001861/*
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001862* create_wlan
1863*
sayli karnikc9573a82016-09-18 15:11:14 +05301864* Called at module init time. This creates the struct wlandevice structure
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001865* and initializes it with relevant bits.
1866*
1867* Arguments:
1868* none
1869*
1870* Returns:
sayli karnikc9573a82016-09-18 15:11:14 +05301871* the created struct wlandevice structure.
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001872*
1873* Side effects:
Christos Tzoumakisf9bd6492010-05-07 06:17:24 +03001874* also allocates the priv/hw structures.
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001875*
1876* Call context:
1877* process thread
1878*
Ioana Ciornei60ec47f2015-09-30 22:28:32 +03001879*/
sayli karnikc9573a82016-09-18 15:11:14 +05301880static struct wlandevice *create_wlan(void)
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001881{
sayli karnikc9573a82016-09-18 15:11:14 +05301882 struct wlandevice *wlandev = NULL;
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001883 struct hfa384x *hw = NULL;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001884
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001885 /* Alloc our structures */
sayli karnikc9573a82016-09-18 15:11:14 +05301886 wlandev = kzalloc(sizeof(struct wlandevice), GFP_KERNEL);
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001887 hw = kzalloc(sizeof(struct hfa384x), GFP_KERNEL);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001888
1889 if (!wlandev || !hw) {
Moritz Muehlenhoff7c98f712009-02-09 19:33:42 +01001890 kfree(wlandev);
1891 kfree(hw);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001892 return NULL;
1893 }
1894
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001895 /* 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-Hartman00b3ed12008-10-02 11:29:28 -07001902 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 Muehlenhofff3422882009-02-08 02:21:04 +01001907 wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT | P80211_NSDCAP_AUTOJOIN;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001908
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001909 /* Initialize the device private data structure. */
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001910 hw->dot11_desired_bss_type = 1;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001911
1912 return wlandev;
1913}
1914
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001915void prism2sta_commsqual_defer(struct work_struct *data)
1916{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02001917 struct hfa384x *hw = container_of(data, struct hfa384x, commsqual_bh);
sayli karnikc9573a82016-09-18 15:11:14 +05301918 struct wlandevice *wlandev = hw->wlandev;
Sergio Paracuellos03c29752016-09-28 20:18:54 +02001919 struct hfa384x_bytestr32 ssid;
Edgardo Hamesb6bb56e2010-08-02 16:20:39 -03001920 struct p80211msg_dot11req_mibget msg;
Sergio Paracuellosb26b2322016-09-25 15:35:00 +02001921 struct p80211item_uint32 *mibitem = (struct p80211item_uint32 *)
Edgardo Hamesb6bb56e2010-08-02 16:20:39 -03001922 &msg.mibattribute.data;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001923 int result = 0;
1924
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001925 if (hw->wlandev->hwremoved)
Devendra Naga102db1f2012-09-09 18:41:00 +05301926 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001927
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 Naga102db1f2012-09-09 18:41:00 +05301931 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001932 }
1933
1934 /* It only makes sense to poll these in non-IBSS */
1935 if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) {
Christos Tzoumakisf9bd6492010-05-07 06:17:24 +03001936 result = hfa384x_drvr_getconfig(
1937 hw, HFA384x_RID_DBMCOMMSQUALITY,
1938 &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001939
1940 if (result) {
Tugce Sirin80135b12014-03-17 16:01:51 +02001941 netdev_err(wlandev->netdev, "error fetching commsqual\n");
Devendra Naga102db1f2012-09-09 18:41:00 +05301942 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001943 }
1944
Moritz Muehlenhoffa7cf7ba2009-02-08 02:01:00 +01001945 pr_debug("commsqual %d %d %d\n",
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301946 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-Hartman00b3ed12008-10-02 11:29:28 -07001949 }
1950
Karl Reltoncb3126e2010-06-03 23:04:06 +01001951 /* Get the signal rate */
1952 msg.msgcode = DIDmsg_dot11req_mibget;
1953 mibitem->did = DIDmib_p2_p2MAC_p2CurrentTxRate;
Jannik Becher0e21fa42016-09-23 01:02:10 +02001954 result = p80211req_dorequest(wlandev, (u8 *)&msg);
Karl Reltoncb3126e2010-06-03 23:04:06 +01001955
1956 if (result) {
1957 pr_debug("get signal rate failed, result = %d\n",
1958 result);
Devendra Naga102db1f2012-09-09 18:41:00 +05301959 return;
Karl Reltoncb3126e2010-06-03 23:04:06 +01001960 }
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-Hartman00b3ed12008-10-02 11:29:28 -07001979 /* 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 Muehlenhofff3422882009-02-08 02:21:04 +01001983 if (result) {
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301984 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1985 HFA384x_RID_CURRENTBSSID, result);
Devendra Naga102db1f2012-09-09 18:41:00 +05301986 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001987 }
1988
1989 result = hfa384x_drvr_getconfig(hw,
1990 HFA384x_RID_CURRENTSSID,
1991 &ssid, sizeof(ssid));
Moritz Muehlenhofff3422882009-02-08 02:21:04 +01001992 if (result) {
Mithlesh Thukral75f49e02009-05-25 19:06:16 +05301993 pr_debug("getconfig(0x%02x) failed, result = %d\n",
1994 HFA384x_RID_CURRENTSSID, result);
Devendra Naga102db1f2012-09-09 18:41:00 +05301995 return;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001996 }
Jannik Becher0e21fa42016-09-23 01:02:10 +02001997 prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *)&ssid,
Sergio Paracuellos3fd1e3f2016-09-25 15:34:52 +02001998 (struct p80211pstrd *)&wlandev->ssid);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001999
2000 /* Reschedule timer */
2001 mod_timer(&hw->commsqual_timer, jiffies + HZ);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07002002}
2003
2004void prism2sta_commsqual_timer(unsigned long data)
2005{
Sergio Paracuellos5a2214e2016-09-28 20:20:19 +02002006 struct hfa384x *hw = (struct hfa384x *)data;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07002007
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07002008 schedule_work(&hw->commsqual_bh);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07002009}