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