1 /* src/prism2/driver/prism2mgmt.c
3 * Management request handler functions.
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
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/
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.
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.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
36 * AbsoluteValue Systems Inc.
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
47 * The functions in this file handle management requests sent from
50 * Most of these functions have two separate blocks of code that are
51 * conditional on whether this is a station or an AP. This is used
52 * to separate out the STA and AP responses to these management primitives.
53 * It's a choice (good, bad, indifferent?) to have the code in the same
54 * place so it's clear that the same primitive is implemented in both
55 * cases but has different behavior.
57 * --------------------------------------------------------------------
60 #include <linux/if_arp.h>
61 #include <linux/module.h>
62 #include <linux/kernel.h>
63 #include <linux/wait.h>
64 #include <linux/sched.h>
65 #include <linux/types.h>
66 #include <linux/slab.h>
67 #include <linux/wireless.h>
68 #include <linux/netdevice.h>
69 #include <linux/delay.h>
71 #include <asm/byteorder.h>
72 #include <linux/random.h>
73 #include <linux/usb.h>
74 #include <linux/bitops.h>
76 #include "p80211types.h"
77 #include "p80211hdr.h"
78 #include "p80211mgmt.h"
79 #include "p80211conv.h"
80 #include "p80211msg.h"
81 #include "p80211netdev.h"
82 #include "p80211metadef.h"
83 #include "p80211metastruct.h"
85 #include "prism2mgmt.h"
87 /* Converts 802.11 format rate specifications to prism2 */
88 #define p80211rate_to_p2bit(n) ((((n)&~BIT(7)) == 2) ? BIT(0) : \
89 (((n)&~BIT(7)) == 4) ? BIT(1) : \
90 (((n)&~BIT(7)) == 11) ? BIT(2) : \
91 (((n)&~BIT(7)) == 22) ? BIT(3) : 0)
93 /*----------------------------------------------------------------
96 * Initiate a scan for BSSs.
98 * This function corresponds to MLME-scan.request and part of
99 * MLME-scan.confirm. As far as I can tell in the standard, there
100 * are no restrictions on when a scan.request may be issued. We have
101 * to handle in whatever state the driver/MAC happen to be.
104 * wlandev wlan device structure
105 * msgp ptr to msg buffer
109 * <0 success, but we're waiting for something to finish.
110 * >0 an error occurred while handling the message.
114 * process thread (usually)
116 ----------------------------------------------------------------*/
117 int prism2mgmt_scan(wlandevice_t
*wlandev
, void *msgp
)
120 hfa384x_t
*hw
= wlandev
->priv
;
121 p80211msg_dot11req_scan_t
*msg
= msgp
;
122 u16 roamingmode
, word
;
126 hfa384x_HostScanRequest_data_t scanreq
;
128 /* gatekeeper check */
129 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
130 hw
->ident_sta_fw
.minor
,
131 hw
->ident_sta_fw
.variant
) <
132 HFA384x_FIRMWARE_VERSION(1, 3, 2)) {
134 "HostScan not supported with current firmware (<1.3.2).\n");
136 msg
->resultcode
.data
= P80211ENUM_resultcode_not_supported
;
140 memset(&scanreq
, 0, sizeof(scanreq
));
142 /* save current roaming mode */
143 result
= hfa384x_drvr_getconfig16(hw
,
144 HFA384x_RID_CNFROAMINGMODE
,
147 printk(KERN_ERR
"getconfig(ROAMMODE) failed. result=%d\n",
149 msg
->resultcode
.data
=
150 P80211ENUM_resultcode_implementation_failure
;
154 /* drop into mode 3 for the scan */
155 result
= hfa384x_drvr_setconfig16(hw
,
156 HFA384x_RID_CNFROAMINGMODE
,
157 HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM
);
159 printk(KERN_ERR
"setconfig(ROAMINGMODE) failed. result=%d\n",
161 msg
->resultcode
.data
=
162 P80211ENUM_resultcode_implementation_failure
;
166 /* active or passive? */
167 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
168 hw
->ident_sta_fw
.minor
,
169 hw
->ident_sta_fw
.variant
) >
170 HFA384x_FIRMWARE_VERSION(1, 5, 0)) {
171 if (msg
->scantype
.data
!= P80211ENUM_scantype_active
)
172 word
= cpu_to_le16(msg
->maxchanneltime
.data
);
177 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFPASSIVESCANCTRL
,
180 printk(KERN_WARNING
"Passive scan not supported with "
181 "current firmware. (<1.5.1)\n");
185 /* set up the txrate to be 2MBPS. Should be fastest basicrate... */
186 word
= HFA384x_RATEBIT_2
;
187 scanreq
.txRate
= cpu_to_le16(word
);
189 /* set up the channel list */
191 for (i
= 0; i
< msg
->channellist
.data
.len
; i
++) {
192 u8 channel
= msg
->channellist
.data
.data
[i
];
195 /* channel 1 is BIT 0 ... channel 14 is BIT 13 */
196 word
|= (1 << (channel
- 1));
198 scanreq
.channelList
= cpu_to_le16(word
);
200 /* set up the ssid, if present. */
201 scanreq
.ssid
.len
= cpu_to_le16(msg
->ssid
.data
.len
);
202 memcpy(scanreq
.ssid
.data
, msg
->ssid
.data
.data
, msg
->ssid
.data
.len
);
204 /* Enable the MAC port if it's not already enabled */
205 result
= hfa384x_drvr_getconfig16(hw
, HFA384x_RID_PORTSTATUS
, &word
);
207 printk(KERN_ERR
"getconfig(PORTSTATUS) failed. "
208 "result=%d\n", result
);
209 msg
->resultcode
.data
=
210 P80211ENUM_resultcode_implementation_failure
;
213 if (word
== HFA384x_PORTSTATUS_DISABLED
) {
216 result
= hfa384x_drvr_setconfig16(hw
,
217 HFA384x_RID_CNFROAMINGMODE
,
218 HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM
);
221 "setconfig(ROAMINGMODE) failed. result=%d\n",
223 msg
->resultcode
.data
=
224 P80211ENUM_resultcode_implementation_failure
;
227 /* Construct a bogus SSID and assign it to OwnSSID and
230 wordbuf
[0] = cpu_to_le16(WLAN_SSID_MAXLEN
);
231 get_random_bytes(&wordbuf
[1], WLAN_SSID_MAXLEN
);
232 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFOWNSSID
,
234 HFA384x_RID_CNFOWNSSID_LEN
);
236 printk(KERN_ERR
"Failed to set OwnSSID.\n");
237 msg
->resultcode
.data
=
238 P80211ENUM_resultcode_implementation_failure
;
241 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFDESIREDSSID
,
243 HFA384x_RID_CNFDESIREDSSID_LEN
);
245 printk(KERN_ERR
"Failed to set DesiredSSID.\n");
246 msg
->resultcode
.data
=
247 P80211ENUM_resultcode_implementation_failure
;
251 result
= hfa384x_drvr_setconfig16(hw
,
252 HFA384x_RID_CNFPORTTYPE
,
253 HFA384x_PORTTYPE_IBSS
);
255 printk(KERN_ERR
"Failed to set CNFPORTTYPE.\n");
256 msg
->resultcode
.data
=
257 P80211ENUM_resultcode_implementation_failure
;
261 result
= hfa384x_drvr_setconfig16(hw
,
262 HFA384x_RID_CREATEIBSS
,
263 HFA384x_CREATEIBSS_JOINCREATEIBSS
);
265 printk(KERN_ERR
"Failed to set CREATEIBSS.\n");
266 msg
->resultcode
.data
=
267 P80211ENUM_resultcode_implementation_failure
;
270 result
= hfa384x_drvr_enable(hw
, 0);
272 printk(KERN_ERR
"drvr_enable(0) failed. "
273 "result=%d\n", result
);
274 msg
->resultcode
.data
=
275 P80211ENUM_resultcode_implementation_failure
;
281 /* Figure out our timeout first Kus, then HZ */
282 timeout
= msg
->channellist
.data
.len
* msg
->maxchanneltime
.data
;
283 timeout
= (timeout
* HZ
) / 1000;
285 /* Issue the scan request */
288 result
= hfa384x_drvr_setconfig(hw
,
289 HFA384x_RID_HOSTSCAN
, &scanreq
,
290 sizeof(hfa384x_HostScanRequest_data_t
));
292 printk(KERN_ERR
"setconfig(SCANREQUEST) failed. result=%d\n",
294 msg
->resultcode
.data
=
295 P80211ENUM_resultcode_implementation_failure
;
299 /* sleep until info frame arrives */
300 wait_event_interruptible_timeout(hw
->cmdq
, hw
->scanflag
, timeout
);
302 msg
->numbss
.status
= P80211ENUM_msgitem_status_data_ok
;
303 if (hw
->scanflag
== -1)
306 msg
->numbss
.data
= hw
->scanflag
;
310 /* Disable port if we temporarily enabled it. */
312 result
= hfa384x_drvr_disable(hw
, 0);
314 printk(KERN_ERR
"drvr_disable(0) failed. "
315 "result=%d\n", result
);
316 msg
->resultcode
.data
=
317 P80211ENUM_resultcode_implementation_failure
;
322 /* restore original roaming mode */
323 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFROAMINGMODE
,
326 printk(KERN_ERR
"setconfig(ROAMMODE) failed. result=%d\n",
328 msg
->resultcode
.data
=
329 P80211ENUM_resultcode_implementation_failure
;
334 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
337 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
342 /*----------------------------------------------------------------
343 * prism2mgmt_scan_results
345 * Retrieve the BSS description for one of the BSSs identified in
349 * wlandev wlan device structure
350 * msgp ptr to msg buffer
354 * <0 success, but we're waiting for something to finish.
355 * >0 an error occurred while handling the message.
359 * process thread (usually)
361 ----------------------------------------------------------------*/
362 int prism2mgmt_scan_results(wlandevice_t
*wlandev
, void *msgp
)
365 p80211msg_dot11req_scan_results_t
*req
;
366 hfa384x_t
*hw
= wlandev
->priv
;
367 hfa384x_HScanResultSub_t
*item
= NULL
;
371 req
= (p80211msg_dot11req_scan_results_t
*) msgp
;
373 req
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
375 if (!hw
->scanresults
) {
377 "dot11req_scan_results can only be used after a successful dot11req_scan.\n");
379 req
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
383 count
= (hw
->scanresults
->framelen
- 3) / 32;
387 if (req
->bssindex
.data
>= count
) {
388 pr_debug("requested index (%d) out of range (%d)\n",
389 req
->bssindex
.data
, count
);
391 req
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
395 item
= &(hw
->scanresults
->info
.hscanresult
.result
[req
->bssindex
.data
]);
396 /* signal and noise */
397 req
->signal
.status
= P80211ENUM_msgitem_status_data_ok
;
398 req
->noise
.status
= P80211ENUM_msgitem_status_data_ok
;
399 req
->signal
.data
= le16_to_cpu(item
->sl
);
400 req
->noise
.data
= le16_to_cpu(item
->anl
);
403 req
->bssid
.status
= P80211ENUM_msgitem_status_data_ok
;
404 req
->bssid
.data
.len
= WLAN_BSSID_LEN
;
405 memcpy(req
->bssid
.data
.data
, item
->bssid
, WLAN_BSSID_LEN
);
408 req
->ssid
.status
= P80211ENUM_msgitem_status_data_ok
;
409 req
->ssid
.data
.len
= le16_to_cpu(item
->ssid
.len
);
410 memcpy(req
->ssid
.data
.data
, item
->ssid
.data
, req
->ssid
.data
.len
);
412 /* supported rates */
413 for (count
= 0; count
< 10; count
++)
414 if (item
->supprates
[count
] == 0)
417 #define REQBASICRATE(N) \
418 if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \
419 req->basicrate ## N .data = item->supprates[(N)-1]; \
420 req->basicrate ## N .status = P80211ENUM_msgitem_status_data_ok; \
432 #define REQSUPPRATE(N) \
434 req->supprate ## N .data = item->supprates[(N)-1]; \
435 req->supprate ## N .status = P80211ENUM_msgitem_status_data_ok; \
448 req
->beaconperiod
.status
= P80211ENUM_msgitem_status_data_ok
;
449 req
->beaconperiod
.data
= le16_to_cpu(item
->bcnint
);
452 req
->timestamp
.status
= P80211ENUM_msgitem_status_data_ok
;
453 req
->timestamp
.data
= jiffies
;
454 req
->localtime
.status
= P80211ENUM_msgitem_status_data_ok
;
455 req
->localtime
.data
= jiffies
;
458 req
->ibssatimwindow
.status
= P80211ENUM_msgitem_status_data_ok
;
459 req
->ibssatimwindow
.data
= le16_to_cpu(item
->atim
);
462 req
->dschannel
.status
= P80211ENUM_msgitem_status_data_ok
;
463 req
->dschannel
.data
= le16_to_cpu(item
->chid
);
466 count
= le16_to_cpu(item
->capinfo
);
469 req
->privacy
.status
= P80211ENUM_msgitem_status_data_ok
;
470 req
->privacy
.data
= WLAN_GET_MGMT_CAP_INFO_PRIVACY(count
);
473 req
->cfpollable
.status
= P80211ENUM_msgitem_status_data_ok
;
474 req
->cfpollable
.data
= WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(count
);
477 req
->cfpollreq
.status
= P80211ENUM_msgitem_status_data_ok
;
478 req
->cfpollreq
.data
= WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(count
);
481 req
->bsstype
.status
= P80211ENUM_msgitem_status_data_ok
;
482 req
->bsstype
.data
= (WLAN_GET_MGMT_CAP_INFO_ESS(count
)) ?
483 P80211ENUM_bsstype_infrastructure
: P80211ENUM_bsstype_independent
;
486 req
->resultcode
.data
= P80211ENUM_resultcode_success
;
492 /*----------------------------------------------------------------
495 * Start a BSS. Any station can do this for IBSS, only AP for ESS.
498 * wlandev wlan device structure
499 * msgp ptr to msg buffer
503 * <0 success, but we're waiting for something to finish.
504 * >0 an error occurred while handling the message.
508 * process thread (usually)
510 ----------------------------------------------------------------*/
511 int prism2mgmt_start(wlandevice_t
*wlandev
, void *msgp
)
514 hfa384x_t
*hw
= wlandev
->priv
;
515 p80211msg_dot11req_start_t
*msg
= msgp
;
519 hfa384x_bytestr_t
*p2bytestr
= (hfa384x_bytestr_t
*) bytebuf
;
522 wlandev
->macmode
= WLAN_MACMODE_NONE
;
525 memcpy(&wlandev
->ssid
, &msg
->ssid
.data
, sizeof(msg
->ssid
.data
));
528 /* see if current f/w is less than 8c3 */
529 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
530 hw
->ident_sta_fw
.minor
,
531 hw
->ident_sta_fw
.variant
) <
532 HFA384x_FIRMWARE_VERSION(0, 8, 3)) {
533 /* Ad-Hoc not quite supported on Prism2 */
534 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
535 msg
->resultcode
.data
= P80211ENUM_resultcode_not_supported
;
539 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
542 /* Set the REQUIRED config items */
544 pstr
= (p80211pstrd_t
*) & (msg
->ssid
.data
);
545 prism2mgmt_pstr2bytestr(p2bytestr
, pstr
);
546 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFOWNSSID
,
547 bytebuf
, HFA384x_RID_CNFOWNSSID_LEN
);
549 printk(KERN_ERR
"Failed to set CnfOwnSSID\n");
552 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFDESIREDSSID
,
554 HFA384x_RID_CNFDESIREDSSID_LEN
);
556 printk(KERN_ERR
"Failed to set CnfDesiredSSID\n");
560 /* bsstype - we use the default in the ap firmware */
562 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFPORTTYPE
, 0);
565 word
= msg
->beaconperiod
.data
;
566 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFAPBCNint
, word
);
568 printk(KERN_ERR
"Failed to set beacon period=%d.\n", word
);
573 word
= msg
->dschannel
.data
;
574 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFOWNCHANNEL
, word
);
576 printk(KERN_ERR
"Failed to set channel=%d.\n", word
);
580 word
= p80211rate_to_p2bit(msg
->basicrate1
.data
);
581 if (msg
->basicrate2
.status
== P80211ENUM_msgitem_status_data_ok
)
582 word
|= p80211rate_to_p2bit(msg
->basicrate2
.data
);
584 if (msg
->basicrate3
.status
== P80211ENUM_msgitem_status_data_ok
)
585 word
|= p80211rate_to_p2bit(msg
->basicrate3
.data
);
587 if (msg
->basicrate4
.status
== P80211ENUM_msgitem_status_data_ok
)
588 word
|= p80211rate_to_p2bit(msg
->basicrate4
.data
);
590 if (msg
->basicrate5
.status
== P80211ENUM_msgitem_status_data_ok
)
591 word
|= p80211rate_to_p2bit(msg
->basicrate5
.data
);
593 if (msg
->basicrate6
.status
== P80211ENUM_msgitem_status_data_ok
)
594 word
|= p80211rate_to_p2bit(msg
->basicrate6
.data
);
596 if (msg
->basicrate7
.status
== P80211ENUM_msgitem_status_data_ok
)
597 word
|= p80211rate_to_p2bit(msg
->basicrate7
.data
);
599 if (msg
->basicrate8
.status
== P80211ENUM_msgitem_status_data_ok
)
600 word
|= p80211rate_to_p2bit(msg
->basicrate8
.data
);
602 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFBASICRATES
, word
);
604 printk(KERN_ERR
"Failed to set basicrates=%d.\n", word
);
608 /* Operational rates (supprates and txratecontrol) */
609 word
= p80211rate_to_p2bit(msg
->operationalrate1
.data
);
610 if (msg
->operationalrate2
.status
== P80211ENUM_msgitem_status_data_ok
)
611 word
|= p80211rate_to_p2bit(msg
->operationalrate2
.data
);
613 if (msg
->operationalrate3
.status
== P80211ENUM_msgitem_status_data_ok
)
614 word
|= p80211rate_to_p2bit(msg
->operationalrate3
.data
);
616 if (msg
->operationalrate4
.status
== P80211ENUM_msgitem_status_data_ok
)
617 word
|= p80211rate_to_p2bit(msg
->operationalrate4
.data
);
619 if (msg
->operationalrate5
.status
== P80211ENUM_msgitem_status_data_ok
)
620 word
|= p80211rate_to_p2bit(msg
->operationalrate5
.data
);
622 if (msg
->operationalrate6
.status
== P80211ENUM_msgitem_status_data_ok
)
623 word
|= p80211rate_to_p2bit(msg
->operationalrate6
.data
);
625 if (msg
->operationalrate7
.status
== P80211ENUM_msgitem_status_data_ok
)
626 word
|= p80211rate_to_p2bit(msg
->operationalrate7
.data
);
628 if (msg
->operationalrate8
.status
== P80211ENUM_msgitem_status_data_ok
)
629 word
|= p80211rate_to_p2bit(msg
->operationalrate8
.data
);
631 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFSUPPRATES
, word
);
633 printk(KERN_ERR
"Failed to set supprates=%d.\n", word
);
637 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_TXRATECNTL
, word
);
639 printk(KERN_ERR
"Failed to set txrates=%d.\n", word
);
643 /* Set the macmode so the frame setup code knows what to do */
644 if (msg
->bsstype
.data
== P80211ENUM_bsstype_independent
) {
645 wlandev
->macmode
= WLAN_MACMODE_IBSS_STA
;
646 /* lets extend the data length a bit */
647 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFMAXDATALEN
, 2304);
650 /* Enable the Port */
651 result
= hfa384x_drvr_enable(hw
, 0);
653 printk(KERN_ERR
"Enable macport failed, result=%d.\n", result
);
657 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
661 pr_debug("Failed to set a config option, result=%d\n", result
);
662 msg
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
670 /*----------------------------------------------------------------
673 * Collect the PDA data and put it in the message.
676 * wlandev wlan device structure
677 * msgp ptr to msg buffer
681 * <0 success, but we're waiting for something to finish.
682 * >0 an error occurred while handling the message.
686 * process thread (usually)
687 ----------------------------------------------------------------*/
688 int prism2mgmt_readpda(wlandevice_t
*wlandev
, void *msgp
)
690 hfa384x_t
*hw
= wlandev
->priv
;
691 p80211msg_p2req_readpda_t
*msg
= msgp
;
694 /* We only support collecting the PDA when in the FWLOAD
697 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
699 "PDA may only be read " "in the fwload state.\n");
700 msg
->resultcode
.data
=
701 P80211ENUM_resultcode_implementation_failure
;
702 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
704 /* Call drvr_readpda(), it handles the auxport enable
705 * and validating the returned PDA.
707 result
= hfa384x_drvr_readpda(hw
,
709 HFA384x_PDA_LEN_MAX
);
712 "hfa384x_drvr_readpda() failed, "
713 "result=%d\n", result
);
715 msg
->resultcode
.data
=
716 P80211ENUM_resultcode_implementation_failure
;
717 msg
->resultcode
.status
=
718 P80211ENUM_msgitem_status_data_ok
;
721 msg
->pda
.status
= P80211ENUM_msgitem_status_data_ok
;
722 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
723 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
729 /*----------------------------------------------------------------
730 * prism2mgmt_ramdl_state
732 * Establishes the beginning/end of a card RAM download session.
734 * It is expected that the ramdl_write() function will be called
735 * one or more times between the 'enable' and 'disable' calls to
738 * Note: This function should not be called when a mac comm port
742 * wlandev wlan device structure
743 * msgp ptr to msg buffer
747 * <0 success, but we're waiting for something to finish.
748 * >0 an error occurred while handling the message.
752 * process thread (usually)
753 ----------------------------------------------------------------*/
754 int prism2mgmt_ramdl_state(wlandevice_t
*wlandev
, void *msgp
)
756 hfa384x_t
*hw
= wlandev
->priv
;
757 p80211msg_p2req_ramdl_state_t
*msg
= msgp
;
759 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
761 "ramdl_state(): may only be called "
762 "in the fwload state.\n");
763 msg
->resultcode
.data
=
764 P80211ENUM_resultcode_implementation_failure
;
765 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
770 ** Note: Interrupts are locked out if this is an AP and are NOT
771 ** locked out if this is a station.
774 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
775 if (msg
->enable
.data
== P80211ENUM_truth_true
) {
776 if (hfa384x_drvr_ramdl_enable(hw
, msg
->exeaddr
.data
)) {
777 msg
->resultcode
.data
=
778 P80211ENUM_resultcode_implementation_failure
;
780 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
783 hfa384x_drvr_ramdl_disable(hw
);
784 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
790 /*----------------------------------------------------------------
791 * prism2mgmt_ramdl_write
793 * Writes a buffer to the card RAM using the download state. This
794 * is for writing code to card RAM. To just read or write raw data
795 * use the aux functions.
798 * wlandev wlan device structure
799 * msgp ptr to msg buffer
803 * <0 success, but we're waiting for something to finish.
804 * >0 an error occurred while handling the message.
808 * process thread (usually)
809 ----------------------------------------------------------------*/
810 int prism2mgmt_ramdl_write(wlandevice_t
*wlandev
, void *msgp
)
812 hfa384x_t
*hw
= wlandev
->priv
;
813 p80211msg_p2req_ramdl_write_t
*msg
= msgp
;
818 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
820 "ramdl_write(): may only be called "
821 "in the fwload state.\n");
822 msg
->resultcode
.data
=
823 P80211ENUM_resultcode_implementation_failure
;
824 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
828 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
829 /* first validate the length */
830 if (msg
->len
.data
> sizeof(msg
->data
.data
)) {
831 msg
->resultcode
.status
=
832 P80211ENUM_resultcode_invalid_parameters
;
835 /* call the hfa384x function to do the write */
836 addr
= msg
->addr
.data
;
838 buf
= msg
->data
.data
;
839 if (hfa384x_drvr_ramdl_write(hw
, addr
, buf
, len
))
840 msg
->resultcode
.data
= P80211ENUM_resultcode_refused
;
842 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
847 /*----------------------------------------------------------------
848 * prism2mgmt_flashdl_state
850 * Establishes the beginning/end of a card Flash download session.
852 * It is expected that the flashdl_write() function will be called
853 * one or more times between the 'enable' and 'disable' calls to
856 * Note: This function should not be called when a mac comm port
860 * wlandev wlan device structure
861 * msgp ptr to msg buffer
865 * <0 success, but we're waiting for something to finish.
866 * >0 an error occurred while handling the message.
870 * process thread (usually)
871 ----------------------------------------------------------------*/
872 int prism2mgmt_flashdl_state(wlandevice_t
*wlandev
, void *msgp
)
875 hfa384x_t
*hw
= wlandev
->priv
;
876 p80211msg_p2req_flashdl_state_t
*msg
= msgp
;
878 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
880 "flashdl_state(): may only be called "
881 "in the fwload state.\n");
882 msg
->resultcode
.data
=
883 P80211ENUM_resultcode_implementation_failure
;
884 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
889 ** Note: Interrupts are locked out if this is an AP and are NOT
890 ** locked out if this is a station.
893 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
894 if (msg
->enable
.data
== P80211ENUM_truth_true
) {
895 if (hfa384x_drvr_flashdl_enable(hw
)) {
896 msg
->resultcode
.data
=
897 P80211ENUM_resultcode_implementation_failure
;
899 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
902 hfa384x_drvr_flashdl_disable(hw
);
903 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
904 /* NOTE: At this point, the MAC is in the post-reset
905 * state and the driver is in the fwload state.
906 * We need to get the MAC back into the fwload
907 * state. To do this, we set the nsdstate to HWPRESENT
908 * and then call the ifstate function to redo everything
909 * that got us into the fwload state.
911 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
912 result
= prism2sta_ifstate(wlandev
, P80211ENUM_ifstate_fwload
);
913 if (result
!= P80211ENUM_resultcode_success
) {
914 printk(KERN_ERR
"prism2sta_ifstate(fwload) failed,"
915 "P80211ENUM_resultcode=%d\n", result
);
916 msg
->resultcode
.data
=
917 P80211ENUM_resultcode_implementation_failure
;
925 /*----------------------------------------------------------------
926 * prism2mgmt_flashdl_write
931 * wlandev wlan device structure
932 * msgp ptr to msg buffer
936 * <0 success, but we're waiting for something to finish.
937 * >0 an error occurred while handling the message.
941 * process thread (usually)
942 ----------------------------------------------------------------*/
943 int prism2mgmt_flashdl_write(wlandevice_t
*wlandev
, void *msgp
)
945 hfa384x_t
*hw
= wlandev
->priv
;
946 p80211msg_p2req_flashdl_write_t
*msg
= msgp
;
951 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
953 "flashdl_write(): may only be called "
954 "in the fwload state.\n");
955 msg
->resultcode
.data
=
956 P80211ENUM_resultcode_implementation_failure
;
957 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
962 ** Note: Interrupts are locked out if this is an AP and are NOT
963 ** locked out if this is a station.
966 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
967 /* first validate the length */
968 if (msg
->len
.data
> sizeof(msg
->data
.data
)) {
969 msg
->resultcode
.status
=
970 P80211ENUM_resultcode_invalid_parameters
;
973 /* call the hfa384x function to do the write */
974 addr
= msg
->addr
.data
;
976 buf
= msg
->data
.data
;
977 if (hfa384x_drvr_flashdl_write(hw
, addr
, buf
, len
))
978 msg
->resultcode
.data
= P80211ENUM_resultcode_refused
;
980 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
985 /*----------------------------------------------------------------
986 * prism2mgmt_autojoin
988 * Associate with an ESS.
991 * wlandev wlan device structure
992 * msgp ptr to msg buffer
996 * <0 success, but we're waiting for something to finish.
997 * >0 an error occurred while handling the message.
1001 * process thread (usually)
1003 ----------------------------------------------------------------*/
1004 int prism2mgmt_autojoin(wlandevice_t
*wlandev
, void *msgp
)
1006 hfa384x_t
*hw
= wlandev
->priv
;
1010 p80211msg_lnxreq_autojoin_t
*msg
= msgp
;
1011 p80211pstrd_t
*pstr
;
1013 hfa384x_bytestr_t
*p2bytestr
= (hfa384x_bytestr_t
*) bytebuf
;
1015 wlandev
->macmode
= WLAN_MACMODE_NONE
;
1018 memcpy(&wlandev
->ssid
, &msg
->ssid
.data
, sizeof(msg
->ssid
.data
));
1020 /* Disable the Port */
1021 hfa384x_drvr_disable(hw
, 0);
1024 /* Set the TxRates */
1025 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_TXRATECNTL
, 0x000f);
1027 /* Set the auth type */
1028 if (msg
->authtype
.data
== P80211ENUM_authalg_sharedkey
)
1029 reg
= HFA384x_CNFAUTHENTICATION_SHAREDKEY
;
1031 reg
= HFA384x_CNFAUTHENTICATION_OPENSYSTEM
;
1033 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFAUTHENTICATION
, reg
);
1036 memset(bytebuf
, 0, 256);
1037 pstr
= (p80211pstrd_t
*) & (msg
->ssid
.data
);
1038 prism2mgmt_pstr2bytestr(p2bytestr
, pstr
);
1039 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFDESIREDSSID
,
1041 HFA384x_RID_CNFDESIREDSSID_LEN
);
1042 port_type
= HFA384x_PORTTYPE_BSS
;
1043 /* Set the PortType */
1044 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFPORTTYPE
, port_type
);
1046 /* Enable the Port */
1047 hfa384x_drvr_enable(hw
, 0);
1049 /* Set the resultcode */
1050 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
1051 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
1056 /*----------------------------------------------------------------
1057 * prism2mgmt_wlansniff
1059 * Start or stop sniffing.
1062 * wlandev wlan device structure
1063 * msgp ptr to msg buffer
1066 * 0 success and done
1067 * <0 success, but we're waiting for something to finish.
1068 * >0 an error occurred while handling the message.
1072 * process thread (usually)
1074 ----------------------------------------------------------------*/
1075 int prism2mgmt_wlansniff(wlandevice_t
*wlandev
, void *msgp
)
1078 p80211msg_lnxreq_wlansniff_t
*msg
= msgp
;
1080 hfa384x_t
*hw
= wlandev
->priv
;
1083 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
1084 switch (msg
->enable
.data
) {
1085 case P80211ENUM_truth_false
:
1086 /* Confirm that we're in monitor mode */
1087 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1088 msg
->resultcode
.data
=
1089 P80211ENUM_resultcode_invalid_parameters
;
1093 /* Disable monitor mode */
1094 result
= hfa384x_cmd_monitor(hw
, HFA384x_MONITOR_DISABLE
);
1096 pr_debug("failed to disable monitor mode, result=%d\n",
1100 /* Disable port 0 */
1101 result
= hfa384x_drvr_disable(hw
, 0);
1104 ("failed to disable port 0 after sniffing, result=%d\n",
1108 /* Clear the driver state */
1109 wlandev
->netdev
->type
= ARPHRD_ETHER
;
1111 /* Restore the wepflags */
1112 result
= hfa384x_drvr_setconfig16(hw
,
1113 HFA384x_RID_CNFWEPFLAGS
,
1114 hw
->presniff_wepflags
);
1117 ("failed to restore wepflags=0x%04x, result=%d\n",
1118 hw
->presniff_wepflags
, result
);
1122 /* Set the port to its prior type and enable (if necessary) */
1123 if (hw
->presniff_port_type
!= 0) {
1124 word
= hw
->presniff_port_type
;
1125 result
= hfa384x_drvr_setconfig16(hw
,
1126 HFA384x_RID_CNFPORTTYPE
,
1130 ("failed to restore porttype, result=%d\n",
1135 /* Enable the port */
1136 result
= hfa384x_drvr_enable(hw
, 0);
1139 ("failed to enable port to presniff setting, result=%d\n",
1144 result
= hfa384x_drvr_disable(hw
, 0);
1148 printk(KERN_INFO
"monitor mode disabled\n");
1149 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
1153 case P80211ENUM_truth_true
:
1154 /* Disable the port (if enabled), only check Port 0 */
1155 if (hw
->port_enabled
[0]) {
1156 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1157 /* Save macport 0 state */
1158 result
= hfa384x_drvr_getconfig16(hw
,
1159 HFA384x_RID_CNFPORTTYPE
,
1162 presniff_port_type
));
1165 ("failed to read porttype, result=%d\n",
1169 /* Save the wepflags state */
1170 result
= hfa384x_drvr_getconfig16(hw
,
1171 HFA384x_RID_CNFWEPFLAGS
,
1174 presniff_wepflags
));
1177 ("failed to read wepflags, result=%d\n",
1181 hfa384x_drvr_stop(hw
);
1182 result
= hfa384x_drvr_start(hw
);
1185 ("failed to restart the card for sniffing, result=%d\n",
1190 /* Disable the port */
1191 result
= hfa384x_drvr_disable(hw
, 0);
1194 ("failed to enable port for sniffing, result=%d\n",
1200 hw
->presniff_port_type
= 0;
1203 /* Set the channel we wish to sniff */
1204 word
= msg
->channel
.data
;
1205 result
= hfa384x_drvr_setconfig16(hw
,
1206 HFA384x_RID_CNFOWNCHANNEL
,
1208 hw
->sniff_channel
= word
;
1211 pr_debug("failed to set channel %d, result=%d\n",
1216 /* Now if we're already sniffing, we can skip the rest */
1217 if (wlandev
->netdev
->type
!= ARPHRD_ETHER
) {
1218 /* Set the port type to pIbss */
1219 word
= HFA384x_PORTTYPE_PSUEDOIBSS
;
1220 result
= hfa384x_drvr_setconfig16(hw
,
1221 HFA384x_RID_CNFPORTTYPE
,
1225 ("failed to set porttype %d, result=%d\n",
1229 if ((msg
->keepwepflags
.status
==
1230 P80211ENUM_msgitem_status_data_ok
)
1231 && (msg
->keepwepflags
.data
!=
1232 P80211ENUM_truth_true
)) {
1233 /* Set the wepflags for no decryption */
1234 word
= HFA384x_WEPFLAGS_DISABLE_TXCRYPT
|
1235 HFA384x_WEPFLAGS_DISABLE_RXCRYPT
;
1237 hfa384x_drvr_setconfig16(hw
,
1238 HFA384x_RID_CNFWEPFLAGS
,
1244 ("failed to set wepflags=0x%04x, result=%d\n",
1250 /* Do we want to strip the FCS in monitor mode? */
1251 if ((msg
->stripfcs
.status
== P80211ENUM_msgitem_status_data_ok
)
1252 && (msg
->stripfcs
.data
== P80211ENUM_truth_true
)) {
1258 /* Do we want to truncate the packets? */
1259 if (msg
->packet_trunc
.status
==
1260 P80211ENUM_msgitem_status_data_ok
) {
1261 hw
->sniff_truncate
= msg
->packet_trunc
.data
;
1263 hw
->sniff_truncate
= 0;
1266 /* Enable the port */
1267 result
= hfa384x_drvr_enable(hw
, 0);
1270 ("failed to enable port for sniffing, result=%d\n",
1274 /* Enable monitor mode */
1275 result
= hfa384x_cmd_monitor(hw
, HFA384x_MONITOR_ENABLE
);
1277 pr_debug("failed to enable monitor mode, result=%d\n",
1282 if (wlandev
->netdev
->type
== ARPHRD_ETHER
)
1283 printk(KERN_INFO
"monitor mode enabled\n");
1285 /* Set the driver state */
1286 /* Do we want the prism2 header? */
1287 if ((msg
->prismheader
.status
==
1288 P80211ENUM_msgitem_status_data_ok
)
1289 && (msg
->prismheader
.data
== P80211ENUM_truth_true
)) {
1291 wlandev
->netdev
->type
= ARPHRD_IEEE80211_PRISM
;
1293 if ((msg
->wlanheader
.status
==
1294 P80211ENUM_msgitem_status_data_ok
)
1295 && (msg
->wlanheader
.data
== P80211ENUM_truth_true
)) {
1297 wlandev
->netdev
->type
= ARPHRD_IEEE80211_PRISM
;
1299 wlandev
->netdev
->type
= ARPHRD_IEEE80211
;
1302 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
1307 msg
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
1314 msg
->resultcode
.data
= P80211ENUM_resultcode_refused
;