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