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 struct p80211msg_dot11req_scan
*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 struct p80211msg_dot11req_scan_results
*req
;
365 hfa384x_t
*hw
= wlandev
->priv
;
366 hfa384x_HScanResultSub_t
*item
= NULL
;
370 req
= (struct p80211msg_dot11req_scan_results
*) 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
);
466 req
->capinfo
.status
= P80211ENUM_msgitem_status_data_ok
;
467 req
->capinfo
.data
= count
;
470 req
->privacy
.status
= P80211ENUM_msgitem_status_data_ok
;
471 req
->privacy
.data
= WLAN_GET_MGMT_CAP_INFO_PRIVACY(count
);
474 req
->cfpollable
.status
= P80211ENUM_msgitem_status_data_ok
;
475 req
->cfpollable
.data
= WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(count
);
478 req
->cfpollreq
.status
= P80211ENUM_msgitem_status_data_ok
;
479 req
->cfpollreq
.data
= WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(count
);
482 req
->bsstype
.status
= P80211ENUM_msgitem_status_data_ok
;
483 req
->bsstype
.data
= (WLAN_GET_MGMT_CAP_INFO_ESS(count
)) ?
484 P80211ENUM_bsstype_infrastructure
: P80211ENUM_bsstype_independent
;
487 req
->resultcode
.data
= P80211ENUM_resultcode_success
;
493 /*----------------------------------------------------------------
496 * Start a BSS. Any station can do this for IBSS, only AP for ESS.
499 * wlandev wlan device structure
500 * msgp ptr to msg buffer
504 * <0 success, but we're waiting for something to finish.
505 * >0 an error occurred while handling the message.
509 * process thread (usually)
511 ----------------------------------------------------------------*/
512 int prism2mgmt_start(wlandevice_t
*wlandev
, void *msgp
)
515 hfa384x_t
*hw
= wlandev
->priv
;
516 struct p80211msg_dot11req_start
*msg
= msgp
;
520 hfa384x_bytestr_t
*p2bytestr
= (hfa384x_bytestr_t
*) bytebuf
;
523 wlandev
->macmode
= WLAN_MACMODE_NONE
;
526 memcpy(&wlandev
->ssid
, &msg
->ssid
.data
, sizeof(msg
->ssid
.data
));
529 /* see if current f/w is less than 8c3 */
530 if (HFA384x_FIRMWARE_VERSION(hw
->ident_sta_fw
.major
,
531 hw
->ident_sta_fw
.minor
,
532 hw
->ident_sta_fw
.variant
) <
533 HFA384x_FIRMWARE_VERSION(0, 8, 3)) {
534 /* Ad-Hoc not quite supported on Prism2 */
535 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
536 msg
->resultcode
.data
= P80211ENUM_resultcode_not_supported
;
540 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
543 /* Set the REQUIRED config items */
545 pstr
= (p80211pstrd_t
*) &(msg
->ssid
.data
);
546 prism2mgmt_pstr2bytestr(p2bytestr
, pstr
);
547 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFOWNSSID
,
548 bytebuf
, HFA384x_RID_CNFOWNSSID_LEN
);
550 printk(KERN_ERR
"Failed to set CnfOwnSSID\n");
553 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFDESIREDSSID
,
555 HFA384x_RID_CNFDESIREDSSID_LEN
);
557 printk(KERN_ERR
"Failed to set CnfDesiredSSID\n");
561 /* bsstype - we use the default in the ap firmware */
563 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFPORTTYPE
, 0);
566 word
= msg
->beaconperiod
.data
;
567 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFAPBCNint
, word
);
569 printk(KERN_ERR
"Failed to set beacon period=%d.\n", word
);
574 word
= msg
->dschannel
.data
;
575 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFOWNCHANNEL
, word
);
577 printk(KERN_ERR
"Failed to set channel=%d.\n", word
);
581 word
= p80211rate_to_p2bit(msg
->basicrate1
.data
);
582 if (msg
->basicrate2
.status
== P80211ENUM_msgitem_status_data_ok
)
583 word
|= p80211rate_to_p2bit(msg
->basicrate2
.data
);
585 if (msg
->basicrate3
.status
== P80211ENUM_msgitem_status_data_ok
)
586 word
|= p80211rate_to_p2bit(msg
->basicrate3
.data
);
588 if (msg
->basicrate4
.status
== P80211ENUM_msgitem_status_data_ok
)
589 word
|= p80211rate_to_p2bit(msg
->basicrate4
.data
);
591 if (msg
->basicrate5
.status
== P80211ENUM_msgitem_status_data_ok
)
592 word
|= p80211rate_to_p2bit(msg
->basicrate5
.data
);
594 if (msg
->basicrate6
.status
== P80211ENUM_msgitem_status_data_ok
)
595 word
|= p80211rate_to_p2bit(msg
->basicrate6
.data
);
597 if (msg
->basicrate7
.status
== P80211ENUM_msgitem_status_data_ok
)
598 word
|= p80211rate_to_p2bit(msg
->basicrate7
.data
);
600 if (msg
->basicrate8
.status
== P80211ENUM_msgitem_status_data_ok
)
601 word
|= p80211rate_to_p2bit(msg
->basicrate8
.data
);
603 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFBASICRATES
, word
);
605 printk(KERN_ERR
"Failed to set basicrates=%d.\n", word
);
609 /* Operational rates (supprates and txratecontrol) */
610 word
= p80211rate_to_p2bit(msg
->operationalrate1
.data
);
611 if (msg
->operationalrate2
.status
== P80211ENUM_msgitem_status_data_ok
)
612 word
|= p80211rate_to_p2bit(msg
->operationalrate2
.data
);
614 if (msg
->operationalrate3
.status
== P80211ENUM_msgitem_status_data_ok
)
615 word
|= p80211rate_to_p2bit(msg
->operationalrate3
.data
);
617 if (msg
->operationalrate4
.status
== P80211ENUM_msgitem_status_data_ok
)
618 word
|= p80211rate_to_p2bit(msg
->operationalrate4
.data
);
620 if (msg
->operationalrate5
.status
== P80211ENUM_msgitem_status_data_ok
)
621 word
|= p80211rate_to_p2bit(msg
->operationalrate5
.data
);
623 if (msg
->operationalrate6
.status
== P80211ENUM_msgitem_status_data_ok
)
624 word
|= p80211rate_to_p2bit(msg
->operationalrate6
.data
);
626 if (msg
->operationalrate7
.status
== P80211ENUM_msgitem_status_data_ok
)
627 word
|= p80211rate_to_p2bit(msg
->operationalrate7
.data
);
629 if (msg
->operationalrate8
.status
== P80211ENUM_msgitem_status_data_ok
)
630 word
|= p80211rate_to_p2bit(msg
->operationalrate8
.data
);
632 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFSUPPRATES
, word
);
634 printk(KERN_ERR
"Failed to set supprates=%d.\n", word
);
638 result
= hfa384x_drvr_setconfig16(hw
, HFA384x_RID_TXRATECNTL
, word
);
640 printk(KERN_ERR
"Failed to set txrates=%d.\n", word
);
644 /* Set the macmode so the frame setup code knows what to do */
645 if (msg
->bsstype
.data
== P80211ENUM_bsstype_independent
) {
646 wlandev
->macmode
= WLAN_MACMODE_IBSS_STA
;
647 /* lets extend the data length a bit */
648 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFMAXDATALEN
, 2304);
651 /* Enable the Port */
652 result
= hfa384x_drvr_enable(hw
, 0);
654 printk(KERN_ERR
"Enable macport failed, result=%d.\n", result
);
658 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
662 pr_debug("Failed to set a config option, result=%d\n", result
);
663 msg
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
671 /*----------------------------------------------------------------
674 * Collect the PDA data and put it in the message.
677 * wlandev wlan device structure
678 * msgp ptr to msg buffer
682 * <0 success, but we're waiting for something to finish.
683 * >0 an error occurred while handling the message.
687 * process thread (usually)
688 ----------------------------------------------------------------*/
689 int prism2mgmt_readpda(wlandevice_t
*wlandev
, void *msgp
)
691 hfa384x_t
*hw
= wlandev
->priv
;
692 struct p80211msg_p2req_readpda
*msg
= msgp
;
695 /* We only support collecting the PDA when in the FWLOAD
698 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
700 "PDA may only be read " "in the fwload state.\n");
701 msg
->resultcode
.data
=
702 P80211ENUM_resultcode_implementation_failure
;
703 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
705 /* Call drvr_readpda(), it handles the auxport enable
706 * and validating the returned PDA.
708 result
= hfa384x_drvr_readpda(hw
,
710 HFA384x_PDA_LEN_MAX
);
713 "hfa384x_drvr_readpda() failed, "
714 "result=%d\n", result
);
716 msg
->resultcode
.data
=
717 P80211ENUM_resultcode_implementation_failure
;
718 msg
->resultcode
.status
=
719 P80211ENUM_msgitem_status_data_ok
;
722 msg
->pda
.status
= P80211ENUM_msgitem_status_data_ok
;
723 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
724 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
730 /*----------------------------------------------------------------
731 * prism2mgmt_ramdl_state
733 * Establishes the beginning/end of a card RAM download session.
735 * It is expected that the ramdl_write() function will be called
736 * one or more times between the 'enable' and 'disable' calls to
739 * Note: This function should not be called when a mac comm port
743 * wlandev wlan device structure
744 * msgp ptr to msg buffer
748 * <0 success, but we're waiting for something to finish.
749 * >0 an error occurred while handling the message.
753 * process thread (usually)
754 ----------------------------------------------------------------*/
755 int prism2mgmt_ramdl_state(wlandevice_t
*wlandev
, void *msgp
)
757 hfa384x_t
*hw
= wlandev
->priv
;
758 struct p80211msg_p2req_ramdl_state
*msg
= msgp
;
760 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
762 "ramdl_state(): may only be called "
763 "in the fwload state.\n");
764 msg
->resultcode
.data
=
765 P80211ENUM_resultcode_implementation_failure
;
766 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
771 ** Note: Interrupts are locked out if this is an AP and are NOT
772 ** locked out if this is a station.
775 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
776 if (msg
->enable
.data
== P80211ENUM_truth_true
) {
777 if (hfa384x_drvr_ramdl_enable(hw
, msg
->exeaddr
.data
)) {
778 msg
->resultcode
.data
=
779 P80211ENUM_resultcode_implementation_failure
;
781 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
784 hfa384x_drvr_ramdl_disable(hw
);
785 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
791 /*----------------------------------------------------------------
792 * prism2mgmt_ramdl_write
794 * Writes a buffer to the card RAM using the download state. This
795 * is for writing code to card RAM. To just read or write raw data
796 * use the aux functions.
799 * wlandev wlan device structure
800 * msgp ptr to msg buffer
804 * <0 success, but we're waiting for something to finish.
805 * >0 an error occurred while handling the message.
809 * process thread (usually)
810 ----------------------------------------------------------------*/
811 int prism2mgmt_ramdl_write(wlandevice_t
*wlandev
, void *msgp
)
813 hfa384x_t
*hw
= wlandev
->priv
;
814 struct p80211msg_p2req_ramdl_write
*msg
= msgp
;
819 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
821 "ramdl_write(): may only be called "
822 "in the fwload state.\n");
823 msg
->resultcode
.data
=
824 P80211ENUM_resultcode_implementation_failure
;
825 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
829 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
830 /* first validate the length */
831 if (msg
->len
.data
> sizeof(msg
->data
.data
)) {
832 msg
->resultcode
.status
=
833 P80211ENUM_resultcode_invalid_parameters
;
836 /* call the hfa384x function to do the write */
837 addr
= msg
->addr
.data
;
839 buf
= msg
->data
.data
;
840 if (hfa384x_drvr_ramdl_write(hw
, addr
, buf
, len
))
841 msg
->resultcode
.data
= P80211ENUM_resultcode_refused
;
843 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
848 /*----------------------------------------------------------------
849 * prism2mgmt_flashdl_state
851 * Establishes the beginning/end of a card Flash download session.
853 * It is expected that the flashdl_write() function will be called
854 * one or more times between the 'enable' and 'disable' calls to
857 * Note: This function should not be called when a mac comm port
861 * wlandev wlan device structure
862 * msgp ptr to msg buffer
866 * <0 success, but we're waiting for something to finish.
867 * >0 an error occurred while handling the message.
871 * process thread (usually)
872 ----------------------------------------------------------------*/
873 int prism2mgmt_flashdl_state(wlandevice_t
*wlandev
, void *msgp
)
876 hfa384x_t
*hw
= wlandev
->priv
;
877 struct p80211msg_p2req_flashdl_state
*msg
= msgp
;
879 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
881 "flashdl_state(): may only be called "
882 "in the fwload state.\n");
883 msg
->resultcode
.data
=
884 P80211ENUM_resultcode_implementation_failure
;
885 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
890 ** Note: Interrupts are locked out if this is an AP and are NOT
891 ** locked out if this is a station.
894 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
895 if (msg
->enable
.data
== P80211ENUM_truth_true
) {
896 if (hfa384x_drvr_flashdl_enable(hw
)) {
897 msg
->resultcode
.data
=
898 P80211ENUM_resultcode_implementation_failure
;
900 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
903 hfa384x_drvr_flashdl_disable(hw
);
904 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
905 /* NOTE: At this point, the MAC is in the post-reset
906 * state and the driver is in the fwload state.
907 * We need to get the MAC back into the fwload
908 * state. To do this, we set the nsdstate to HWPRESENT
909 * and then call the ifstate function to redo everything
910 * that got us into the fwload state.
912 wlandev
->msdstate
= WLAN_MSD_HWPRESENT
;
913 result
= prism2sta_ifstate(wlandev
, P80211ENUM_ifstate_fwload
);
914 if (result
!= P80211ENUM_resultcode_success
) {
915 printk(KERN_ERR
"prism2sta_ifstate(fwload) failed,"
916 "P80211ENUM_resultcode=%d\n", result
);
917 msg
->resultcode
.data
=
918 P80211ENUM_resultcode_implementation_failure
;
926 /*----------------------------------------------------------------
927 * prism2mgmt_flashdl_write
932 * wlandev wlan device structure
933 * msgp ptr to msg buffer
937 * <0 success, but we're waiting for something to finish.
938 * >0 an error occurred while handling the message.
942 * process thread (usually)
943 ----------------------------------------------------------------*/
944 int prism2mgmt_flashdl_write(wlandevice_t
*wlandev
, void *msgp
)
946 hfa384x_t
*hw
= wlandev
->priv
;
947 struct p80211msg_p2req_flashdl_write
*msg
= msgp
;
952 if (wlandev
->msdstate
!= WLAN_MSD_FWLOAD
) {
954 "flashdl_write(): may only be called "
955 "in the fwload state.\n");
956 msg
->resultcode
.data
=
957 P80211ENUM_resultcode_implementation_failure
;
958 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
963 ** Note: Interrupts are locked out if this is an AP and are NOT
964 ** locked out if this is a station.
967 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
968 /* first validate the length */
969 if (msg
->len
.data
> sizeof(msg
->data
.data
)) {
970 msg
->resultcode
.status
=
971 P80211ENUM_resultcode_invalid_parameters
;
974 /* call the hfa384x function to do the write */
975 addr
= msg
->addr
.data
;
977 buf
= msg
->data
.data
;
978 if (hfa384x_drvr_flashdl_write(hw
, addr
, buf
, len
))
979 msg
->resultcode
.data
= P80211ENUM_resultcode_refused
;
981 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
986 /*----------------------------------------------------------------
987 * prism2mgmt_autojoin
989 * Associate with an ESS.
992 * wlandev wlan device structure
993 * msgp ptr to msg buffer
997 * <0 success, but we're waiting for something to finish.
998 * >0 an error occurred while handling the message.
1002 * process thread (usually)
1004 ----------------------------------------------------------------*/
1005 int prism2mgmt_autojoin(wlandevice_t
*wlandev
, void *msgp
)
1007 hfa384x_t
*hw
= wlandev
->priv
;
1011 struct p80211msg_lnxreq_autojoin
*msg
= msgp
;
1012 p80211pstrd_t
*pstr
;
1014 hfa384x_bytestr_t
*p2bytestr
= (hfa384x_bytestr_t
*) bytebuf
;
1016 wlandev
->macmode
= WLAN_MACMODE_NONE
;
1019 memcpy(&wlandev
->ssid
, &msg
->ssid
.data
, sizeof(msg
->ssid
.data
));
1021 /* Disable the Port */
1022 hfa384x_drvr_disable(hw
, 0);
1025 /* Set the TxRates */
1026 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_TXRATECNTL
, 0x000f);
1028 /* Set the auth type */
1029 if (msg
->authtype
.data
== P80211ENUM_authalg_sharedkey
)
1030 reg
= HFA384x_CNFAUTHENTICATION_SHAREDKEY
;
1032 reg
= HFA384x_CNFAUTHENTICATION_OPENSYSTEM
;
1034 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFAUTHENTICATION
, reg
);
1037 memset(bytebuf
, 0, 256);
1038 pstr
= (p80211pstrd_t
*) &(msg
->ssid
.data
);
1039 prism2mgmt_pstr2bytestr(p2bytestr
, pstr
);
1040 result
= hfa384x_drvr_setconfig(hw
, HFA384x_RID_CNFDESIREDSSID
,
1042 HFA384x_RID_CNFDESIREDSSID_LEN
);
1043 port_type
= HFA384x_PORTTYPE_BSS
;
1044 /* Set the PortType */
1045 hfa384x_drvr_setconfig16(hw
, HFA384x_RID_CNFPORTTYPE
, port_type
);
1047 /* Enable the Port */
1048 hfa384x_drvr_enable(hw
, 0);
1050 /* Set the resultcode */
1051 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
1052 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
1057 /*----------------------------------------------------------------
1058 * prism2mgmt_wlansniff
1060 * Start or stop sniffing.
1063 * wlandev wlan device structure
1064 * msgp ptr to msg buffer
1067 * 0 success and done
1068 * <0 success, but we're waiting for something to finish.
1069 * >0 an error occurred while handling the message.
1073 * process thread (usually)
1075 ----------------------------------------------------------------*/
1076 int prism2mgmt_wlansniff(wlandevice_t
*wlandev
, void *msgp
)
1079 struct p80211msg_lnxreq_wlansniff
*msg
= msgp
;
1081 hfa384x_t
*hw
= wlandev
->priv
;
1084 msg
->resultcode
.status
= P80211ENUM_msgitem_status_data_ok
;
1085 switch (msg
->enable
.data
) {
1086 case P80211ENUM_truth_false
:
1087 /* Confirm that we're in monitor mode */
1088 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1089 msg
->resultcode
.data
=
1090 P80211ENUM_resultcode_invalid_parameters
;
1094 /* Disable monitor mode */
1095 result
= hfa384x_cmd_monitor(hw
, HFA384x_MONITOR_DISABLE
);
1097 pr_debug("failed to disable monitor mode, result=%d\n",
1101 /* Disable port 0 */
1102 result
= hfa384x_drvr_disable(hw
, 0);
1105 ("failed to disable port 0 after sniffing, result=%d\n",
1109 /* Clear the driver state */
1110 wlandev
->netdev
->type
= ARPHRD_ETHER
;
1112 /* Restore the wepflags */
1113 result
= hfa384x_drvr_setconfig16(hw
,
1114 HFA384x_RID_CNFWEPFLAGS
,
1115 hw
->presniff_wepflags
);
1118 ("failed to restore wepflags=0x%04x, result=%d\n",
1119 hw
->presniff_wepflags
, result
);
1123 /* Set the port to its prior type and enable (if necessary) */
1124 if (hw
->presniff_port_type
!= 0) {
1125 word
= hw
->presniff_port_type
;
1126 result
= hfa384x_drvr_setconfig16(hw
,
1127 HFA384x_RID_CNFPORTTYPE
,
1131 ("failed to restore porttype, result=%d\n",
1136 /* Enable the port */
1137 result
= hfa384x_drvr_enable(hw
, 0);
1140 ("failed to enable port to presniff setting, result=%d\n",
1145 result
= hfa384x_drvr_disable(hw
, 0);
1149 printk(KERN_INFO
"monitor mode disabled\n");
1150 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
1154 case P80211ENUM_truth_true
:
1155 /* Disable the port (if enabled), only check Port 0 */
1156 if (hw
->port_enabled
[0]) {
1157 if (wlandev
->netdev
->type
== ARPHRD_ETHER
) {
1158 /* Save macport 0 state */
1159 result
= hfa384x_drvr_getconfig16(hw
,
1160 HFA384x_RID_CNFPORTTYPE
,
1161 &(hw
->presniff_port_type
));
1164 ("failed to read porttype, result=%d\n",
1168 /* Save the wepflags state */
1169 result
= hfa384x_drvr_getconfig16(hw
,
1170 HFA384x_RID_CNFWEPFLAGS
,
1171 &(hw
->presniff_wepflags
));
1174 ("failed to read wepflags, result=%d\n",
1178 hfa384x_drvr_stop(hw
);
1179 result
= hfa384x_drvr_start(hw
);
1182 ("failed to restart the card for sniffing, result=%d\n",
1187 /* Disable the port */
1188 result
= hfa384x_drvr_disable(hw
, 0);
1191 ("failed to enable port for sniffing, result=%d\n",
1197 hw
->presniff_port_type
= 0;
1200 /* Set the channel we wish to sniff */
1201 word
= msg
->channel
.data
;
1202 result
= hfa384x_drvr_setconfig16(hw
,
1203 HFA384x_RID_CNFOWNCHANNEL
,
1205 hw
->sniff_channel
= word
;
1208 pr_debug("failed to set channel %d, result=%d\n",
1213 /* Now if we're already sniffing, we can skip the rest */
1214 if (wlandev
->netdev
->type
!= ARPHRD_ETHER
) {
1215 /* Set the port type to pIbss */
1216 word
= HFA384x_PORTTYPE_PSUEDOIBSS
;
1217 result
= hfa384x_drvr_setconfig16(hw
,
1218 HFA384x_RID_CNFPORTTYPE
,
1222 ("failed to set porttype %d, result=%d\n",
1226 if ((msg
->keepwepflags
.status
==
1227 P80211ENUM_msgitem_status_data_ok
)
1228 && (msg
->keepwepflags
.data
!=
1229 P80211ENUM_truth_true
)) {
1230 /* Set the wepflags for no decryption */
1231 word
= HFA384x_WEPFLAGS_DISABLE_TXCRYPT
|
1232 HFA384x_WEPFLAGS_DISABLE_RXCRYPT
;
1234 hfa384x_drvr_setconfig16(hw
,
1235 HFA384x_RID_CNFWEPFLAGS
,
1241 ("failed to set wepflags=0x%04x, result=%d\n",
1247 /* Do we want to strip the FCS in monitor mode? */
1248 if ((msg
->stripfcs
.status
== P80211ENUM_msgitem_status_data_ok
)
1249 && (msg
->stripfcs
.data
== P80211ENUM_truth_true
)) {
1255 /* Do we want to truncate the packets? */
1256 if (msg
->packet_trunc
.status
==
1257 P80211ENUM_msgitem_status_data_ok
) {
1258 hw
->sniff_truncate
= msg
->packet_trunc
.data
;
1260 hw
->sniff_truncate
= 0;
1263 /* Enable the port */
1264 result
= hfa384x_drvr_enable(hw
, 0);
1267 ("failed to enable port for sniffing, result=%d\n",
1271 /* Enable monitor mode */
1272 result
= hfa384x_cmd_monitor(hw
, HFA384x_MONITOR_ENABLE
);
1274 pr_debug("failed to enable monitor mode, result=%d\n",
1279 if (wlandev
->netdev
->type
== ARPHRD_ETHER
)
1280 printk(KERN_INFO
"monitor mode enabled\n");
1282 /* Set the driver state */
1283 /* Do we want the prism2 header? */
1284 if ((msg
->prismheader
.status
==
1285 P80211ENUM_msgitem_status_data_ok
)
1286 && (msg
->prismheader
.data
== P80211ENUM_truth_true
)) {
1288 wlandev
->netdev
->type
= ARPHRD_IEEE80211_PRISM
;
1290 if ((msg
->wlanheader
.status
==
1291 P80211ENUM_msgitem_status_data_ok
)
1292 && (msg
->wlanheader
.data
== P80211ENUM_truth_true
)) {
1294 wlandev
->netdev
->type
= ARPHRD_IEEE80211_PRISM
;
1296 wlandev
->netdev
->type
= ARPHRD_IEEE80211
;
1299 msg
->resultcode
.data
= P80211ENUM_resultcode_success
;
1304 msg
->resultcode
.data
= P80211ENUM_resultcode_invalid_parameters
;
1311 msg
->resultcode
.data
= P80211ENUM_resultcode_refused
;