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/wireless.h>
67 #include <linux/netdevice.h>
68 #include <linux/delay.h>
70 #include <asm/byteorder.h>
71 #include <linux/random.h>
72 #include <linux/usb.h>
73 #include <linux/bitops.h>
75 #include "p80211types.h"
76 #include "p80211hdr.h"
77 #include "p80211mgmt.h"
78 #include "p80211conv.h"
79 #include "p80211msg.h"
80 #include "p80211netdev.h"
81 #include "p80211metadef.h"
82 #include "p80211metastruct.h"
84 #include "prism2mgmt.h"
86 /* Converts 802.11 format rate specifications to prism2 */
87 #define p80211rate_to_p2bit(n) ((((n)&~BIT(7)) == 2) ? BIT(0) : \
88 (((n)&~BIT(7)) == 4) ? BIT(1) : \
89 (((n)&~BIT(7)) == 11) ? BIT(2) : \
90 (((n)&~BIT(7)) == 22) ? BIT(3) : 0)
92 /*----------------------------------------------------------------
95 * Initiate a scan for BSSs.
97 * This function corresponds to MLME-scan.request and part of
98 * MLME-scan.confirm. As far as I can tell in the standard, there
99 * are no restrictions on when a scan.request may be issued. We have
100 * to handle in whatever state the driver/MAC happen to be.
103 * wlandev wlan device structure
104 * msgp ptr to msg buffer
108 * <0 success, but we're waiting for something to finish.
109 * >0 an error occurred while handling the message.
113 * process thread (usually)
115 ----------------------------------------------------------------*/
116 int prism2mgmt_scan(wlandevice_t
*wlandev
, void *msgp
)
119 hfa384x_t
*hw
= wlandev
->priv
;
120 p80211msg_dot11req_scan_t
*msg
= msgp
;
121 u16 roamingmode
, word
;
125 hfa384x_HostScanRequest_data_t scanreq
;
127 /* gatekeeper check */
128 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
129 hw
->ident_sta_fw
.minor
,
130 hw
->ident_sta_fw
.variant
) <
131 HFA384x_FIRMWARE_VERSION(1, 3, 2)) {
133 "HostScan not supported with current firmware (<1.3.2).\n");
135 msg
->resultcode
.data
= P80211ENUM_resultcode_not_supported
;
139 memset(&scanreq
, 0, sizeof(scanreq
));
141 /* save current roaming mode */
142 result
= hfa384x_drvr_getconfig16(hw
,
143 HFA384x_RID_CNFROAMINGMODE
,
146 printk(KERN_ERR
"getconfig(ROAMMODE) failed. result=%d\n",
148 msg
->resultcode
.data
=
149 P80211ENUM_resultcode_implementation_failure
;
153 /* drop into mode 3 for the scan */
154 result
= hfa384x_drvr_setconfig16(hw
,
155 HFA384x_RID_CNFROAMINGMODE
,
156 HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM
);
158 printk(KERN_ERR
"setconfig(ROAMINGMODE) failed. result=%d\n",
160 msg
->resultcode
.data
=
161 P80211ENUM_resultcode_implementation_failure
;
165 /* active or passive? */
166 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
167 hw
->ident_sta_fw
.minor
,
168 hw
->ident_sta_fw
.variant
) >
169 HFA384x_FIRMWARE_VERSION(1, 5, 0)) {
170 if (msg
->scantype
.data
!= P80211ENUM_scantype_active
)
171 word
= cpu_to_le16(msg
->maxchanneltime
.data
);
176 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFPASSIVESCANCTRL
,
179 printk(KERN_WARNING
"Passive scan not supported with "
180 "current firmware. (<1.5.1)\n");
184 /* set up the txrate to be 2MBPS. Should be fastest basicrate... */
185 word
= HFA384x_RATEBIT_2
;
186 scanreq
.txRate
= cpu_to_le16(word
);
188 /* set up the channel list */
190 for (i
= 0; i
< msg
->channellist
.data
.len
; i
++) {
191 u8 channel
= msg
->channellist
.data
.data
[i
];
194 /* channel 1 is BIT 0 ... channel 14 is BIT 13 */
195 word
|= (1 << (channel
- 1));
197 scanreq
.channelList
= cpu_to_le16(word
);
199 /* set up the ssid, if present. */
200 scanreq
.ssid
.len
= cpu_to_le16(msg
->ssid
.data
.len
);
201 memcpy(scanreq
.ssid
.data
, msg
->ssid
.data
.data
, msg
->ssid
.data
.len
);
203 /* Enable the MAC port if it's not already enabled */
204 result
= hfa384x_drvr_getconfig16(hw
, HFA384x_RID_PORTSTATUS
, &word
);
206 printk(KERN_ERR
"getconfig(PORTSTATUS) failed. "
207 "result=%d\n", result
);
208 msg
->resultcode
.data
=
209 P80211ENUM_resultcode_implementation_failure
;
212 if (word
== HFA384x_PORTSTATUS_DISABLED
) {
215 result
= hfa384x_drvr_setconfig16(hw
,
216 HFA384x_RID_CNFROAMINGMODE
,
217 HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM
);
220 "setconfig(ROAMINGMODE) failed. result=%d\n",
222 msg
->resultcode
.data
=
223 P80211ENUM_resultcode_implementation_failure
;
226 /* Construct a bogus SSID and assign it to OwnSSID and
229 wordbuf
[0] = cpu_to_le16(WLAN_SSID_MAXLEN
);
230 get_random_bytes(&wordbuf
[1], WLAN_SSID_MAXLEN
);
231 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFOWNSSID
,
233 HFA384x_RID_CNFOWNSSID_LEN
);
235 printk(KERN_ERR
"Failed to set OwnSSID.\n");
236 msg
->resultcode
.data
=
237 P80211ENUM_resultcode_implementation_failure
;
240 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFDESIREDSSID
,
242 HFA384x_RID_CNFDESIREDSSID_LEN
);
244 printk(KERN_ERR
"Failed to set DesiredSSID.\n");
245 msg
->resultcode
.data
=
246 P80211ENUM_resultcode_implementation_failure
;
250 result
= hfa384x_drvr_setconfig16(hw
,
251 HFA384x_RID_CNFPORTTYPE
,
252 HFA384x_PORTTYPE_IBSS
);
254 printk(KERN_ERR
"Failed to set CNFPORTTYPE.\n");
255 msg
->resultcode
.data
=
256 P80211ENUM_resultcode_implementation_failure
;
260 result
= hfa384x_drvr_setconfig16(hw
,
261 HFA384x_RID_CREATEIBSS
,
262 HFA384x_CREATEIBSS_JOINCREATEIBSS
);
264 printk(KERN_ERR
"Failed to set CREATEIBSS.\n");
265 msg
->resultcode
.data
=
266 P80211ENUM_resultcode_implementation_failure
;
269 result
= hfa384x_drvr_enable(hw
, 0);
271 printk(KERN_ERR
"drvr_enable(0) failed. "
272 "result=%d\n", result
);
273 msg
->resultcode
.data
=
274 P80211ENUM_resultcode_implementation_failure
;
280 /* Figure out our timeout first Kus, then HZ */
281 timeout
= msg
->channellist
.data
.len
* msg
->maxchanneltime
.data
;
282 timeout
= (timeout
* HZ
) / 1000;
284 /* Issue the scan request */
287 result
= hfa384x_drvr_setconfig(hw
,
288 HFA384x_RID_HOSTSCAN
, &scanreq
,
289 sizeof(hfa384x_HostScanRequest_data_t
));
291 printk(KERN_ERR
"setconfig(SCANREQUEST) failed. result=%d\n",
293 msg
->resultcode
.data
=
294 P80211ENUM_resultcode_implementation_failure
;
298 /* sleep until info frame arrives */
299 wait_event_interruptible_timeout(hw
->cmdq
, hw
->scanflag
, timeout
);
301 msg
->numbss
.status
= P80211ENUM_msgitem_status_data_ok
;
302 if (hw
->scanflag
== -1)
305 msg
->numbss
.data
= hw
->scanflag
;
309 /* Disable port if we temporarily enabled it. */
311 result
= hfa384x_drvr_disable(hw
, 0);
313 printk(KERN_ERR
"drvr_disable(0) failed. "
314 "result=%d\n", result
);
315 msg
->resultcode
.data
=
316 P80211ENUM_resultcode_implementation_failure
;
321 /* restore original roaming mode */
322 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFROAMINGMODE
,
325 printk(KERN_ERR
"setconfig(ROAMMODE) failed. result=%d\n",
327 msg
->resultcode
.data
=
328 P80211ENUM_resultcode_implementation_failure
;
333 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
336 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
341 /*----------------------------------------------------------------
342 * prism2mgmt_scan_results
344 * Retrieve the BSS description for one of the BSSs identified in
348 * wlandev wlan device structure
349 * msgp ptr to msg buffer
353 * <0 success, but we're waiting for something to finish.
354 * >0 an error occurred while handling the message.
358 * process thread (usually)
360 ----------------------------------------------------------------*/
361 int prism2mgmt_scan_results(wlandevice_t
*wlandev
, void *msgp
)
364 p80211msg_dot11req_scan_results_t
*req
;
365 hfa384x_t
*hw
= wlandev
->priv
;
366 hfa384x_HScanResultSub_t
*item
= NULL
;
370 req
= (p80211msg_dot11req_scan_results_t
*) msgp
;
372 req
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
374 if (!hw
->scanresults
) {
376 "dot11req_scan_results can only be used after a successful dot11req_scan.\n");
378 req
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
382 count
= (hw
->scanresults
->framelen
- 3) / 32;
386 if (req
->bssindex
.data
>= count
) {
387 pr_debug("requested index (%d) out of range (%d)\n",
388 req
->bssindex
.data
, count
);
390 req
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
394 item
= &(hw
->scanresults
->info
.hscanresult
.result
[req
->bssindex
.data
]);
395 /* signal and noise */
396 req
->signal
.status
= P80211ENUM_msgitem_status_data_ok
;
397 req
->noise
.status
= P80211ENUM_msgitem_status_data_ok
;
398 req
->signal
.data
= le16_to_cpu(item
->sl
);
399 req
->noise
.data
= le16_to_cpu(item
->anl
);
402 req
->bssid
.status
= P80211ENUM_msgitem_status_data_ok
;
403 req
->bssid
.data
.len
= WLAN_BSSID_LEN
;
404 memcpy(req
->bssid
.data
.data
, item
->bssid
, WLAN_BSSID_LEN
);
407 req
->ssid
.status
= P80211ENUM_msgitem_status_data_ok
;
408 req
->ssid
.data
.len
= le16_to_cpu(item
->ssid
.len
);
409 memcpy(req
->ssid
.data
.data
, item
->ssid
.data
, req
->ssid
.data
.len
);
411 /* supported rates */
412 for (count
= 0; count
< 10; count
++)
413 if (item
->supprates
[count
] == 0)
416 #define REQBASICRATE(N) \
417 if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \
418 req->basicrate ## N .data = item->supprates[(N)-1]; \
419 req->basicrate ## N .status = P80211ENUM_msgitem_status_data_ok; \
431 #define REQSUPPRATE(N) \
433 req->supprate ## N .data = item->supprates[(N)-1]; \
434 req->supprate ## N .status = P80211ENUM_msgitem_status_data_ok; \
447 req
->beaconperiod
.status
= P80211ENUM_msgitem_status_data_ok
;
448 req
->beaconperiod
.data
= le16_to_cpu(item
->bcnint
);
451 req
->timestamp
.status
= P80211ENUM_msgitem_status_data_ok
;
452 req
->timestamp
.data
= jiffies
;
453 req
->localtime
.status
= P80211ENUM_msgitem_status_data_ok
;
454 req
->localtime
.data
= jiffies
;
457 req
->ibssatimwindow
.status
= P80211ENUM_msgitem_status_data_ok
;
458 req
->ibssatimwindow
.data
= le16_to_cpu(item
->atim
);
461 req
->dschannel
.status
= P80211ENUM_msgitem_status_data_ok
;
462 req
->dschannel
.data
= le16_to_cpu(item
->chid
);
465 count
= le16_to_cpu(item
->capinfo
);
468 req
->privacy
.status
= P80211ENUM_msgitem_status_data_ok
;
469 req
->privacy
.data
= WLAN_GET_MGMT_CAP_INFO_PRIVACY(count
);
472 req
->cfpollable
.status
= P80211ENUM_msgitem_status_data_ok
;
473 req
->cfpollable
.data
= WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(count
);
476 req
->cfpollreq
.status
= P80211ENUM_msgitem_status_data_ok
;
477 req
->cfpollreq
.data
= WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(count
);
480 req
->bsstype
.status
= P80211ENUM_msgitem_status_data_ok
;
481 req
->bsstype
.data
= (WLAN_GET_MGMT_CAP_INFO_ESS(count
)) ?
482 P80211ENUM_bsstype_infrastructure
: P80211ENUM_bsstype_independent
;
485 req
->resultcode
.data
= P80211ENUM_resultcode_success
;
491 /*----------------------------------------------------------------
494 * Start a BSS. Any station can do this for IBSS, only AP for ESS.
497 * wlandev wlan device structure
498 * msgp ptr to msg buffer
502 * <0 success, but we're waiting for something to finish.
503 * >0 an error occurred while handling the message.
507 * process thread (usually)
509 ----------------------------------------------------------------*/
510 int prism2mgmt_start(wlandevice_t
*wlandev
, void *msgp
)
513 hfa384x_t
*hw
= wlandev
->priv
;
514 p80211msg_dot11req_start_t
*msg
= msgp
;
518 hfa384x_bytestr_t
*p2bytestr
= (hfa384x_bytestr_t
*) bytebuf
;
521 wlandev
->macmode
= WLAN_MACMODE_NONE
;
524 memcpy(&wlandev
->ssid
, &msg
->ssid
.data
, sizeof(msg
->ssid
.data
));
527 /* see if current f/w is less than 8c3 */
528 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
529 hw
->ident_sta_fw
.minor
,
530 hw
->ident_sta_fw
.variant
) <
531 HFA384x_FIRMWARE_VERSION(0, 8, 3)) {
532 /* Ad-Hoc not quite supported on Prism2 */
533 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
534 msg
->resultcode
.data
= P80211ENUM_resultcode_not_supported
;
538 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
541 /* Set the REQUIRED config items */
543 pstr
= (p80211pstrd_t
*) &(msg
->ssid
.data
);
544 prism2mgmt_pstr2bytestr(p2bytestr
, pstr
);
545 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFOWNSSID
,
546 bytebuf
, HFA384x_RID_CNFOWNSSID_LEN
);
548 printk(KERN_ERR
"Failed to set CnfOwnSSID\n");
551 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFDESIREDSSID
,
553 HFA384x_RID_CNFDESIREDSSID_LEN
);
555 printk(KERN_ERR
"Failed to set CnfDesiredSSID\n");
559 /* bsstype - we use the default in the ap firmware */
561 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFPORTTYPE
, 0);
564 word
= msg
->beaconperiod
.data
;
565 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFAPBCNint
, word
);
567 printk(KERN_ERR
"Failed to set beacon period=%d.\n", word
);
572 word
= msg
->dschannel
.data
;
573 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFOWNCHANNEL
, word
);
575 printk(KERN_ERR
"Failed to set channel=%d.\n", word
);
579 word
= p80211rate_to_p2bit(msg
->basicrate1
.data
);
580 if (msg
->basicrate2
.status
== P80211ENUM_msgitem_status_data_ok
)
581 word
|= p80211rate_to_p2bit(msg
->basicrate2
.data
);
583 if (msg
->basicrate3
.status
== P80211ENUM_msgitem_status_data_ok
)
584 word
|= p80211rate_to_p2bit(msg
->basicrate3
.data
);
586 if (msg
->basicrate4
.status
== P80211ENUM_msgitem_status_data_ok
)
587 word
|= p80211rate_to_p2bit(msg
->basicrate4
.data
);
589 if (msg
->basicrate5
.status
== P80211ENUM_msgitem_status_data_ok
)
590 word
|= p80211rate_to_p2bit(msg
->basicrate5
.data
);
592 if (msg
->basicrate6
.status
== P80211ENUM_msgitem_status_data_ok
)
593 word
|= p80211rate_to_p2bit(msg
->basicrate6
.data
);
595 if (msg
->basicrate7
.status
== P80211ENUM_msgitem_status_data_ok
)
596 word
|= p80211rate_to_p2bit(msg
->basicrate7
.data
);
598 if (msg
->basicrate8
.status
== P80211ENUM_msgitem_status_data_ok
)
599 word
|= p80211rate_to_p2bit(msg
->basicrate8
.data
);
601 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFBASICRATES
, word
);
603 printk(KERN_ERR
"Failed to set basicrates=%d.\n", word
);
607 /* Operational rates (supprates and txratecontrol) */
608 word
= p80211rate_to_p2bit(msg
->operationalrate1
.data
);
609 if (msg
->operationalrate2
.status
== P80211ENUM_msgitem_status_data_ok
)
610 word
|= p80211rate_to_p2bit(msg
->operationalrate2
.data
);
612 if (msg
->operationalrate3
.status
== P80211ENUM_msgitem_status_data_ok
)
613 word
|= p80211rate_to_p2bit(msg
->operationalrate3
.data
);
615 if (msg
->operationalrate4
.status
== P80211ENUM_msgitem_status_data_ok
)
616 word
|= p80211rate_to_p2bit(msg
->operationalrate4
.data
);
618 if (msg
->operationalrate5
.status
== P80211ENUM_msgitem_status_data_ok
)
619 word
|= p80211rate_to_p2bit(msg
->operationalrate5
.data
);
621 if (msg
->operationalrate6
.status
== P80211ENUM_msgitem_status_data_ok
)
622 word
|= p80211rate_to_p2bit(msg
->operationalrate6
.data
);
624 if (msg
->operationalrate7
.status
== P80211ENUM_msgitem_status_data_ok
)
625 word
|= p80211rate_to_p2bit(msg
->operationalrate7
.data
);
627 if (msg
->operationalrate8
.status
== P80211ENUM_msgitem_status_data_ok
)
628 word
|= p80211rate_to_p2bit(msg
->operationalrate8
.data
);
630 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFSUPPRATES
, word
);
632 printk(KERN_ERR
"Failed to set supprates=%d.\n", word
);
636 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_TXRATECNTL
, word
);
638 printk(KERN_ERR
"Failed to set txrates=%d.\n", word
);
642 /* Set the macmode so the frame setup code knows what to do */
643 if (msg
->bsstype
.data
== P80211ENUM_bsstype_independent
) {
644 wlandev
->macmode
= WLAN_MACMODE_IBSS_STA
;
645 /* lets extend the data length a bit */
646 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFMAXDATALEN
, 2304);
649 /* Enable the Port */
650 result
= hfa384x_drvr_enable(hw
, 0);
652 printk(KERN_ERR
"Enable macport failed, result=%d.\n", result
);
656 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
660 pr_debug("Failed to set a config option, result=%d\n", result
);
661 msg
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
669 /*----------------------------------------------------------------
672 * Collect the PDA data and put it in the message.
675 * wlandev wlan device structure
676 * msgp ptr to msg buffer
680 * <0 success, but we're waiting for something to finish.
681 * >0 an error occurred while handling the message.
685 * process thread (usually)
686 ----------------------------------------------------------------*/
687 int prism2mgmt_readpda(wlandevice_t
*wlandev
, void *msgp
)
689 hfa384x_t
*hw
= wlandev
->priv
;
690 p80211msg_p2req_readpda_t
*msg
= msgp
;
693 /* We only support collecting the PDA when in the FWLOAD
696 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
698 "PDA may only be read " "in the fwload state.\n");
699 msg
->resultcode
.data
=
700 P80211ENUM_resultcode_implementation_failure
;
701 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
703 /* Call drvr_readpda(), it handles the auxport enable
704 * and validating the returned PDA.
706 result
= hfa384x_drvr_readpda(hw
,
708 HFA384x_PDA_LEN_MAX
);
711 "hfa384x_drvr_readpda() failed, "
712 "result=%d\n", result
);
714 msg
->resultcode
.data
=
715 P80211ENUM_resultcode_implementation_failure
;
716 msg
->resultcode
.status
=
717 P80211ENUM_msgitem_status_data_ok
;
720 msg
->pda
.status
= P80211ENUM_msgitem_status_data_ok
;
721 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
722 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
728 /*----------------------------------------------------------------
729 * prism2mgmt_ramdl_state
731 * Establishes the beginning/end of a card RAM download session.
733 * It is expected that the ramdl_write() function will be called
734 * one or more times between the 'enable' and 'disable' calls to
737 * Note: This function should not be called when a mac comm port
741 * wlandev wlan device structure
742 * msgp ptr to msg buffer
746 * <0 success, but we're waiting for something to finish.
747 * >0 an error occurred while handling the message.
751 * process thread (usually)
752 ----------------------------------------------------------------*/
753 int prism2mgmt_ramdl_state(wlandevice_t
*wlandev
, void *msgp
)
755 hfa384x_t
*hw
= wlandev
->priv
;
756 p80211msg_p2req_ramdl_state_t
*msg
= msgp
;
758 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
760 "ramdl_state(): may only be called "
761 "in the fwload state.\n");
762 msg
->resultcode
.data
=
763 P80211ENUM_resultcode_implementation_failure
;
764 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
769 ** Note: Interrupts are locked out if this is an AP and are NOT
770 ** locked out if this is a station.
773 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
774 if (msg
->enable
.data
== P80211ENUM_truth_true
) {
775 if (hfa384x_drvr_ramdl_enable(hw
, msg
->exeaddr
.data
)) {
776 msg
->resultcode
.data
=
777 P80211ENUM_resultcode_implementation_failure
;
779 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
782 hfa384x_drvr_ramdl_disable(hw
);
783 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
789 /*----------------------------------------------------------------
790 * prism2mgmt_ramdl_write
792 * Writes a buffer to the card RAM using the download state. This
793 * is for writing code to card RAM. To just read or write raw data
794 * use the aux functions.
797 * wlandev wlan device structure
798 * msgp ptr to msg buffer
802 * <0 success, but we're waiting for something to finish.
803 * >0 an error occurred while handling the message.
807 * process thread (usually)
808 ----------------------------------------------------------------*/
809 int prism2mgmt_ramdl_write(wlandevice_t
*wlandev
, void *msgp
)
811 hfa384x_t
*hw
= wlandev
->priv
;
812 p80211msg_p2req_ramdl_write_t
*msg
= msgp
;
817 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
819 "ramdl_write(): may only be called "
820 "in the fwload state.\n");
821 msg
->resultcode
.data
=
822 P80211ENUM_resultcode_implementation_failure
;
823 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
827 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
828 /* first validate the length */
829 if (msg
->len
.data
> sizeof(msg
->data
.data
)) {
830 msg
->resultcode
.status
=
831 P80211ENUM_resultcode_invalid_parameters
;
834 /* call the hfa384x function to do the write */
835 addr
= msg
->addr
.data
;
837 buf
= msg
->data
.data
;
838 if (hfa384x_drvr_ramdl_write(hw
, addr
, buf
, len
))
839 msg
->resultcode
.data
= P80211ENUM_resultcode_refused
;
841 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
846 /*----------------------------------------------------------------
847 * prism2mgmt_flashdl_state
849 * Establishes the beginning/end of a card Flash download session.
851 * It is expected that the flashdl_write() function will be called
852 * one or more times between the 'enable' and 'disable' calls to
855 * Note: This function should not be called when a mac comm port
859 * wlandev wlan device structure
860 * msgp ptr to msg buffer
864 * <0 success, but we're waiting for something to finish.
865 * >0 an error occurred while handling the message.
869 * process thread (usually)
870 ----------------------------------------------------------------*/
871 int prism2mgmt_flashdl_state(wlandevice_t
*wlandev
, void *msgp
)
874 hfa384x_t
*hw
= wlandev
->priv
;
875 p80211msg_p2req_flashdl_state_t
*msg
= msgp
;
877 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
879 "flashdl_state(): may only be called "
880 "in the fwload state.\n");
881 msg
->resultcode
.data
=
882 P80211ENUM_resultcode_implementation_failure
;
883 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
888 ** Note: Interrupts are locked out if this is an AP and are NOT
889 ** locked out if this is a station.
892 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
893 if (msg
->enable
.data
== P80211ENUM_truth_true
) {
894 if (hfa384x_drvr_flashdl_enable(hw
)) {
895 msg
->resultcode
.data
=
896 P80211ENUM_resultcode_implementation_failure
;
898 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
901 hfa384x_drvr_flashdl_disable(hw
);
902 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
903 /* NOTE: At this point, the MAC is in the post-reset
904 * state and the driver is in the fwload state.
905 * We need to get the MAC back into the fwload
906 * state. To do this, we set the nsdstate to HWPRESENT
907 * and then call the ifstate function to redo everything
908 * that got us into the fwload state.
910 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
911 result
= prism2sta_ifstate(wlandev
, P80211ENUM_ifstate_fwload
);
912 if (result
!= P80211ENUM_resultcode_success
) {
913 printk(KERN_ERR
"prism2sta_ifstate(fwload) failed,"
914 "P80211ENUM_resultcode=%d\n", result
);
915 msg
->resultcode
.data
=
916 P80211ENUM_resultcode_implementation_failure
;
924 /*----------------------------------------------------------------
925 * prism2mgmt_flashdl_write
930 * wlandev wlan device structure
931 * msgp ptr to msg buffer
935 * <0 success, but we're waiting for something to finish.
936 * >0 an error occurred while handling the message.
940 * process thread (usually)
941 ----------------------------------------------------------------*/
942 int prism2mgmt_flashdl_write(wlandevice_t
*wlandev
, void *msgp
)
944 hfa384x_t
*hw
= wlandev
->priv
;
945 p80211msg_p2req_flashdl_write_t
*msg
= msgp
;
950 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
952 "flashdl_write(): may only be called "
953 "in the fwload state.\n");
954 msg
->resultcode
.data
=
955 P80211ENUM_resultcode_implementation_failure
;
956 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
961 ** Note: Interrupts are locked out if this is an AP and are NOT
962 ** locked out if this is a station.
965 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
966 /* first validate the length */
967 if (msg
->len
.data
> sizeof(msg
->data
.data
)) {
968 msg
->resultcode
.status
=
969 P80211ENUM_resultcode_invalid_parameters
;
972 /* call the hfa384x function to do the write */
973 addr
= msg
->addr
.data
;
975 buf
= msg
->data
.data
;
976 if (hfa384x_drvr_flashdl_write(hw
, addr
, buf
, len
))
977 msg
->resultcode
.data
= P80211ENUM_resultcode_refused
;
979 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
984 /*----------------------------------------------------------------
985 * prism2mgmt_autojoin
987 * Associate with an ESS.
990 * wlandev wlan device structure
991 * msgp ptr to msg buffer
995 * <0 success, but we're waiting for something to finish.
996 * >0 an error occurred while handling the message.
1000 * process thread (usually)
1002 ----------------------------------------------------------------*/
1003 int prism2mgmt_autojoin(wlandevice_t
*wlandev
, void *msgp
)
1005 hfa384x_t
*hw
= wlandev
->priv
;
1009 p80211msg_lnxreq_autojoin_t
*msg
= msgp
;
1010 p80211pstrd_t
*pstr
;
1012 hfa384x_bytestr_t
*p2bytestr
= (hfa384x_bytestr_t
*) bytebuf
;
1014 wlandev
->macmode
= WLAN_MACMODE_NONE
;
1017 memcpy(&wlandev
->ssid
, &msg
->ssid
.data
, sizeof(msg
->ssid
.data
));
1019 /* Disable the Port */
1020 hfa384x_drvr_disable(hw
, 0);
1023 /* Set the TxRates */
1024 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_TXRATECNTL
, 0x000f);
1026 /* Set the auth type */
1027 if (msg
->authtype
.data
== P80211ENUM_authalg_sharedkey
)
1028 reg
= HFA384x_CNFAUTHENTICATION_SHAREDKEY
;
1030 reg
= HFA384x_CNFAUTHENTICATION_OPENSYSTEM
;
1032 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFAUTHENTICATION
, reg
);
1035 memset(bytebuf
, 0, 256);
1036 pstr
= (p80211pstrd_t
*) &(msg
->ssid
.data
);
1037 prism2mgmt_pstr2bytestr(p2bytestr
, pstr
);
1038 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFDESIREDSSID
,
1040 HFA384x_RID_CNFDESIREDSSID_LEN
);
1041 port_type
= HFA384x_PORTTYPE_BSS
;
1042 /* Set the PortType */
1043 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFPORTTYPE
, port_type
);
1045 /* Enable the Port */
1046 hfa384x_drvr_enable(hw
, 0);
1048 /* Set the resultcode */
1049 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
1050 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
1055 /*----------------------------------------------------------------
1056 * prism2mgmt_wlansniff
1058 * Start or stop sniffing.
1061 * wlandev wlan device structure
1062 * msgp ptr to msg buffer
1065 * 0 success and done
1066 * <0 success, but we're waiting for something to finish.
1067 * >0 an error occurred while handling the message.
1071 * process thread (usually)
1073 ----------------------------------------------------------------*/
1074 int prism2mgmt_wlansniff(wlandevice_t
*wlandev
, void *msgp
)
1077 p80211msg_lnxreq_wlansniff_t
*msg
= msgp
;
1079 hfa384x_t
*hw
= wlandev
->priv
;
1082 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
1083 switch (msg
->enable
.data
) {
1084 case P80211ENUM_truth_false
:
1085 /* Confirm that we're in monitor mode */
1086 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1087 msg
->resultcode
.data
=
1088 P80211ENUM_resultcode_invalid_parameters
;
1092 /* Disable monitor mode */
1093 result
= hfa384x_cmd_monitor(hw
, HFA384x_MONITOR_DISABLE
);
1095 pr_debug("failed to disable monitor mode, result=%d\n",
1099 /* Disable port 0 */
1100 result
= hfa384x_drvr_disable(hw
, 0);
1103 ("failed to disable port 0 after sniffing, result=%d\n",
1107 /* Clear the driver state */
1108 wlandev
->netdev
->type
= ARPHRD_ETHER
;
1110 /* Restore the wepflags */
1111 result
= hfa384x_drvr_setconfig16(hw
,
1112 HFA384x_RID_CNFWEPFLAGS
,
1113 hw
->presniff_wepflags
);
1116 ("failed to restore wepflags=0x%04x, result=%d\n",
1117 hw
->presniff_wepflags
, result
);
1121 /* Set the port to its prior type and enable (if necessary) */
1122 if (hw
->presniff_port_type
!= 0) {
1123 word
= hw
->presniff_port_type
;
1124 result
= hfa384x_drvr_setconfig16(hw
,
1125 HFA384x_RID_CNFPORTTYPE
,
1129 ("failed to restore porttype, result=%d\n",
1134 /* Enable the port */
1135 result
= hfa384x_drvr_enable(hw
, 0);
1138 ("failed to enable port to presniff setting, result=%d\n",
1143 result
= hfa384x_drvr_disable(hw
, 0);
1147 printk(KERN_INFO
"monitor mode disabled\n");
1148 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
1152 case P80211ENUM_truth_true
:
1153 /* Disable the port (if enabled), only check Port 0 */
1154 if (hw
->port_enabled
[0]) {
1155 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1156 /* Save macport 0 state */
1157 result
= hfa384x_drvr_getconfig16(hw
,
1158 HFA384x_RID_CNFPORTTYPE
,
1159 &(hw
->presniff_port_type
));
1162 ("failed to read porttype, result=%d\n",
1166 /* Save the wepflags state */
1167 result
= hfa384x_drvr_getconfig16(hw
,
1168 HFA384x_RID_CNFWEPFLAGS
,
1169 &(hw
->presniff_wepflags
));
1172 ("failed to read wepflags, result=%d\n",
1176 hfa384x_drvr_stop(hw
);
1177 result
= hfa384x_drvr_start(hw
);
1180 ("failed to restart the card for sniffing, result=%d\n",
1185 /* Disable the port */
1186 result
= hfa384x_drvr_disable(hw
, 0);
1189 ("failed to enable port for sniffing, result=%d\n",
1195 hw
->presniff_port_type
= 0;
1198 /* Set the channel we wish to sniff */
1199 word
= msg
->channel
.data
;
1200 result
= hfa384x_drvr_setconfig16(hw
,
1201 HFA384x_RID_CNFOWNCHANNEL
,
1203 hw
->sniff_channel
= word
;
1206 pr_debug("failed to set channel %d, result=%d\n",
1211 /* Now if we're already sniffing, we can skip the rest */
1212 if (wlandev
->netdev
->type
!= ARPHRD_ETHER
) {
1213 /* Set the port type to pIbss */
1214 word
= HFA384x_PORTTYPE_PSUEDOIBSS
;
1215 result
= hfa384x_drvr_setconfig16(hw
,
1216 HFA384x_RID_CNFPORTTYPE
,
1220 ("failed to set porttype %d, result=%d\n",
1224 if ((msg
->keepwepflags
.status
==
1225 P80211ENUM_msgitem_status_data_ok
)
1226 && (msg
->keepwepflags
.data
!=
1227 P80211ENUM_truth_true
)) {
1228 /* Set the wepflags for no decryption */
1229 word
= HFA384x_WEPFLAGS_DISABLE_TXCRYPT
|
1230 HFA384x_WEPFLAGS_DISABLE_RXCRYPT
;
1232 hfa384x_drvr_setconfig16(hw
,
1233 HFA384x_RID_CNFWEPFLAGS
,
1239 ("failed to set wepflags=0x%04x, result=%d\n",
1245 /* Do we want to strip the FCS in monitor mode? */
1246 if ((msg
->stripfcs
.status
== P80211ENUM_msgitem_status_data_ok
)
1247 && (msg
->stripfcs
.data
== P80211ENUM_truth_true
)) {
1253 /* Do we want to truncate the packets? */
1254 if (msg
->packet_trunc
.status
==
1255 P80211ENUM_msgitem_status_data_ok
) {
1256 hw
->sniff_truncate
= msg
->packet_trunc
.data
;
1258 hw
->sniff_truncate
= 0;
1261 /* Enable the port */
1262 result
= hfa384x_drvr_enable(hw
, 0);
1265 ("failed to enable port for sniffing, result=%d\n",
1269 /* Enable monitor mode */
1270 result
= hfa384x_cmd_monitor(hw
, HFA384x_MONITOR_ENABLE
);
1272 pr_debug("failed to enable monitor mode, result=%d\n",
1277 if (wlandev
->netdev
->type
== ARPHRD_ETHER
)
1278 printk(KERN_INFO
"monitor mode enabled\n");
1280 /* Set the driver state */
1281 /* Do we want the prism2 header? */
1282 if ((msg
->prismheader
.status
==
1283 P80211ENUM_msgitem_status_data_ok
)
1284 && (msg
->prismheader
.data
== P80211ENUM_truth_true
)) {
1286 wlandev
->netdev
->type
= ARPHRD_IEEE80211_PRISM
;
1288 if ((msg
->wlanheader
.status
==
1289 P80211ENUM_msgitem_status_data_ok
)
1290 && (msg
->wlanheader
.data
== P80211ENUM_truth_true
)) {
1292 wlandev
->netdev
->type
= ARPHRD_IEEE80211_PRISM
;
1294 wlandev
->netdev
->type
= ARPHRD_IEEE80211
;
1297 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
1302 msg
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
1309 msg
->resultcode
.data
= P80211ENUM_resultcode_refused
;