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 /*================================================================*/
62 #define WLAN_DBVAR prism2_debug
67 #include <linux/version.h>
69 #include <linux/if_arp.h>
70 #include <linux/module.h>
71 #include <linux/kernel.h>
72 #include <linux/wait.h>
73 #include <linux/sched.h>
74 #include <linux/types.h>
75 #include <linux/slab.h>
76 #include <linux/wireless.h>
77 #include <linux/netdevice.h>
78 #include <linux/delay.h>
80 #include <asm/byteorder.h>
81 #include <linux/random.h>
82 #include <linux/usb.h>
84 #include "wlan_compat.h"
86 /*================================================================*/
87 /* Project Includes */
89 #include "p80211types.h"
90 #include "p80211hdr.h"
91 #include "p80211mgmt.h"
92 #include "p80211conv.h"
93 #include "p80211msg.h"
94 #include "p80211netdev.h"
95 #include "p80211metadef.h"
96 #include "p80211metastruct.h"
98 #include "prism2mgmt.h"
100 /*================================================================*/
101 /* Local Constants */
104 /*================================================================*/
107 /* Converts 802.11 format rate specifications to prism2 */
108 #define p80211rate_to_p2bit(n) ((((n)&~BIT7) == 2) ? BIT0 : \
109 (((n)&~BIT7) == 4) ? BIT1 : \
110 (((n)&~BIT7) == 11) ? BIT2 : \
111 (((n)&~BIT7) == 22) ? BIT3 : 0)
113 /*================================================================*/
117 /*================================================================*/
118 /* Local Static Definitions */
121 /*================================================================*/
122 /* Local Function Declarations */
125 /*================================================================*/
126 /* Function Definitions */
129 /*----------------------------------------------------------------
130 * prism2mgmt_powermgmt
132 * Set the power management state of this station's MAC.
135 * wlandev wlan device structure
136 * msgp ptr to msg buffer
140 * <0 success, but we're waiting for something to finish.
141 * >0 an error occurred while handling the message.
145 * process thread (usually)
147 ----------------------------------------------------------------*/
148 int prism2mgmt_powermgmt(wlandevice_t *wlandev, void *msgp)
151 hfa384x_t *hw = wlandev->priv;
152 p80211msg_dot11req_powermgmt_t *msg = msgp;
161 * Set CNFPMENABLED (on or off)
162 * Set CNFMULTICASTRX (if PM on, otherwise clear)
163 * Spout a notice stating that SleepDuration and
164 * HoldoverDuration and PMEPS also have an impact.
166 /* Powermgmt is currently unsupported for STA */
167 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
168 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
171 /*** ACCESS POINT ***/
173 /* Powermgmt is never supported for AP */
174 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
175 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
183 /*----------------------------------------------------------------
186 * Initiate a scan for BSSs.
188 * This function corresponds to MLME-scan.request and part of
189 * MLME-scan.confirm. As far as I can tell in the standard, there
190 * are no restrictions on when a scan.request may be issued. We have
191 * to handle in whatever state the driver/MAC happen to be.
194 * wlandev wlan device structure
195 * msgp ptr to msg buffer
199 * <0 success, but we're waiting for something to finish.
200 * >0 an error occurred while handling the message.
204 * process thread (usually)
206 ----------------------------------------------------------------*/
207 int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
210 hfa384x_t *hw = wlandev->priv;
211 p80211msg_dot11req_scan_t *msg = msgp;
212 UINT16 roamingmode, word;
216 hfa384x_HostScanRequest_data_t scanreq;
221 WLAN_LOG_ERROR("Prism2 in AP mode cannot perform scans.\n");
223 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
227 /* gatekeeper check */
228 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
229 hw->ident_sta_fw.minor,
230 hw->ident_sta_fw.variant) <
231 HFA384x_FIRMWARE_VERSION(1,3,2)) {
232 WLAN_LOG_ERROR("HostScan not supported with current firmware (<1.3.2).\n");
234 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
238 memset(&scanreq, 0, sizeof(scanreq));
240 /* save current roaming mode */
241 result = hfa384x_drvr_getconfig16(hw,
242 HFA384x_RID_CNFROAMINGMODE, &roamingmode);
244 WLAN_LOG_ERROR("getconfig(ROAMMODE) failed. result=%d\n",
246 msg->resultcode.data =
247 P80211ENUM_resultcode_implementation_failure;
251 /* drop into mode 3 for the scan */
252 result = hfa384x_drvr_setconfig16(hw,
253 HFA384x_RID_CNFROAMINGMODE,
254 HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
256 WLAN_LOG_ERROR("setconfig(ROAMINGMODE) failed. result=%d\n",
258 msg->resultcode.data =
259 P80211ENUM_resultcode_implementation_failure;
263 /* active or passive? */
264 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
265 hw->ident_sta_fw.minor,
266 hw->ident_sta_fw.variant) >
267 HFA384x_FIRMWARE_VERSION(1,5,0)) {
268 if (msg->scantype.data != P80211ENUM_scantype_active) {
269 word = host2hfa384x_16(msg->maxchanneltime.data);
273 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL, word);
275 WLAN_LOG_WARNING("Passive scan not supported with "
276 "current firmware. (<1.5.1)\n");
280 /* set up the txrate to be 2MBPS. Should be fastest basicrate... */
281 word = HFA384x_RATEBIT_2;
282 scanreq.txRate = host2hfa384x_16(word);
284 /* set up the channel list */
286 for (i = 0; i < msg->channellist.data.len; i++) {
287 UINT8 channel = msg->channellist.data.data[i];
288 if (channel > 14) continue;
289 /* channel 1 is BIT0 ... channel 14 is BIT13 */
290 word |= (1 << (channel-1));
292 scanreq.channelList = host2hfa384x_16(word);
294 /* set up the ssid, if present. */
295 scanreq.ssid.len = host2hfa384x_16(msg->ssid.data.len);
296 memcpy(scanreq.ssid.data, msg->ssid.data.data, msg->ssid.data.len);
298 /* Enable the MAC port if it's not already enabled */
299 result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word);
301 WLAN_LOG_ERROR("getconfig(PORTSTATUS) failed. "
302 "result=%d\n", result);
303 msg->resultcode.data =
304 P80211ENUM_resultcode_implementation_failure;
307 if (word == HFA384x_PORTSTATUS_DISABLED) {
310 result = hfa384x_drvr_setconfig16(hw,
311 HFA384x_RID_CNFROAMINGMODE,
312 HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
314 WLAN_LOG_ERROR("setconfig(ROAMINGMODE) failed. result=%d\n", result);
315 msg->resultcode.data =
316 P80211ENUM_resultcode_implementation_failure;
319 /* Construct a bogus SSID and assign it to OwnSSID and
322 wordbuf[0] = host2hfa384x_16(WLAN_SSID_MAXLEN);
323 get_random_bytes(&wordbuf[1], WLAN_SSID_MAXLEN);
324 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
325 wordbuf, HFA384x_RID_CNFOWNSSID_LEN);
327 WLAN_LOG_ERROR("Failed to set OwnSSID.\n");
328 msg->resultcode.data =
329 P80211ENUM_resultcode_implementation_failure;
332 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID,
333 wordbuf, HFA384x_RID_CNFDESIREDSSID_LEN);
335 WLAN_LOG_ERROR("Failed to set DesiredSSID.\n");
336 msg->resultcode.data =
337 P80211ENUM_resultcode_implementation_failure;
341 result = hfa384x_drvr_setconfig16(hw,
342 HFA384x_RID_CNFPORTTYPE,
343 HFA384x_PORTTYPE_IBSS);
345 WLAN_LOG_ERROR("Failed to set CNFPORTTYPE.\n");
346 msg->resultcode.data =
347 P80211ENUM_resultcode_implementation_failure;
351 result = hfa384x_drvr_setconfig16(hw,
352 HFA384x_RID_CREATEIBSS,
353 HFA384x_CREATEIBSS_JOINCREATEIBSS);
355 WLAN_LOG_ERROR("Failed to set CREATEIBSS.\n");
356 msg->resultcode.data =
357 P80211ENUM_resultcode_implementation_failure;
360 result = hfa384x_drvr_enable(hw, 0);
362 WLAN_LOG_ERROR("drvr_enable(0) failed. "
363 "result=%d\n", result);
364 msg->resultcode.data =
365 P80211ENUM_resultcode_implementation_failure;
371 /* Figure out our timeout first Kus, then HZ */
372 timeout = msg->channellist.data.len * msg->maxchanneltime.data;
373 timeout = (timeout * HZ)/1000;
375 /* Issue the scan request */
378 WLAN_HEX_DUMP(5,"hscanreq", &scanreq, sizeof(scanreq));
380 result = hfa384x_drvr_setconfig( hw,
381 HFA384x_RID_HOSTSCAN, &scanreq,
382 sizeof(hfa384x_HostScanRequest_data_t));
384 WLAN_LOG_ERROR("setconfig(SCANREQUEST) failed. result=%d\n",
386 msg->resultcode.data =
387 P80211ENUM_resultcode_implementation_failure;
391 /* sleep until info frame arrives */
392 wait_event_interruptible_timeout(hw->cmdq, hw->scanflag, timeout);
394 msg->numbss.status = P80211ENUM_msgitem_status_data_ok;
395 if (hw->scanflag == -1)
398 msg->numbss.data = hw->scanflag;
402 /* Disable port if we temporarily enabled it. */
404 result = hfa384x_drvr_disable(hw, 0);
406 WLAN_LOG_ERROR("drvr_disable(0) failed. "
407 "result=%d\n", result);
408 msg->resultcode.data =
409 P80211ENUM_resultcode_implementation_failure;
414 /* restore original roaming mode */
415 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE,
418 WLAN_LOG_ERROR("setconfig(ROAMMODE) failed. result=%d\n",
420 msg->resultcode.data =
421 P80211ENUM_resultcode_implementation_failure;
426 msg->resultcode.data = P80211ENUM_resultcode_success;
429 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
436 /*----------------------------------------------------------------
437 * prism2mgmt_scan_results
439 * Retrieve the BSS description for one of the BSSs identified in
443 * wlandev wlan device structure
444 * msgp ptr to msg buffer
448 * <0 success, but we're waiting for something to finish.
449 * >0 an error occurred while handling the message.
453 * process thread (usually)
455 ----------------------------------------------------------------*/
456 int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
459 p80211msg_dot11req_scan_results_t *req;
460 hfa384x_t *hw = wlandev->priv;
461 hfa384x_HScanResultSub_t *item = NULL;
467 req = (p80211msg_dot11req_scan_results_t *) msgp;
469 req->resultcode.status = P80211ENUM_msgitem_status_data_ok;
473 req->resultcode.data = P80211ENUM_resultcode_not_supported;
477 if (! hw->scanresults) {
478 WLAN_LOG_ERROR("dot11req_scan_results can only be used after a successful dot11req_scan.\n");
480 req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
484 count = (hw->scanresults->framelen - 3) / 32;
485 if (count > 32) count = 32;
487 if (req->bssindex.data >= count) {
488 WLAN_LOG_DEBUG(0, "requested index (%d) out of range (%d)\n",
489 req->bssindex.data, count);
491 req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
495 item = &(hw->scanresults->info.hscanresult.result[req->bssindex.data]);
496 /* signal and noise */
497 req->signal.status = P80211ENUM_msgitem_status_data_ok;
498 req->noise.status = P80211ENUM_msgitem_status_data_ok;
499 req->signal.data = hfa384x2host_16(item->sl);
500 req->noise.data = hfa384x2host_16(item->anl);
503 req->bssid.status = P80211ENUM_msgitem_status_data_ok;
504 req->bssid.data.len = WLAN_BSSID_LEN;
505 memcpy(req->bssid.data.data, item->bssid, WLAN_BSSID_LEN);
508 req->ssid.status = P80211ENUM_msgitem_status_data_ok;
509 req->ssid.data.len = hfa384x2host_16(item->ssid.len);
510 memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len);
512 /* supported rates */
513 for (count = 0; count < 10 ; count++)
514 if (item->supprates[count] == 0)
517 #define REQBASICRATE(N) \
518 if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \
519 req->basicrate ## N .data = item->supprates[(N)-1]; \
520 req->basicrate ## N .status = P80211ENUM_msgitem_status_data_ok; \
532 #define REQSUPPRATE(N) \
534 req->supprate ## N .data = item->supprates[(N)-1]; \
535 req->supprate ## N .status = P80211ENUM_msgitem_status_data_ok; \
548 req->beaconperiod.status = P80211ENUM_msgitem_status_data_ok;
549 req->beaconperiod.data = hfa384x2host_16(item->bcnint);
552 req->timestamp.status = P80211ENUM_msgitem_status_data_ok;
553 req->timestamp.data = jiffies;
554 req->localtime.status = P80211ENUM_msgitem_status_data_ok;
555 req->localtime.data = jiffies;
558 req->ibssatimwindow.status = P80211ENUM_msgitem_status_data_ok;
559 req->ibssatimwindow.data = hfa384x2host_16(item->atim);
562 req->dschannel.status = P80211ENUM_msgitem_status_data_ok;
563 req->dschannel.data = hfa384x2host_16(item->chid);
566 count = hfa384x2host_16(item->capinfo);
569 req->privacy.status = P80211ENUM_msgitem_status_data_ok;
570 req->privacy.data = WLAN_GET_MGMT_CAP_INFO_PRIVACY(count);
573 req->cfpollable.status = P80211ENUM_msgitem_status_data_ok;
574 req->cfpollable.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(count);
577 req->cfpollreq.status = P80211ENUM_msgitem_status_data_ok;
578 req->cfpollreq.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(count);
581 req->bsstype.status = P80211ENUM_msgitem_status_data_ok;
582 req->bsstype.data = (WLAN_GET_MGMT_CAP_INFO_ESS(count)) ?
583 P80211ENUM_bsstype_infrastructure :
584 P80211ENUM_bsstype_independent;
586 // item->proberesp_rate
596 req->resultcode.data = P80211ENUM_resultcode_success;
604 /*----------------------------------------------------------------
607 * Join a BSS whose BSS description was previously obtained with
611 * wlandev wlan device structure
612 * msgp ptr to msg buffer
616 * <0 success, but we're waiting for something to finish.
617 * >0 an error occurred while handling the message.
621 * process thread (usually)
623 ----------------------------------------------------------------*/
624 int prism2mgmt_join(wlandevice_t *wlandev, void *msgp)
627 hfa384x_t *hw = wlandev->priv;
628 p80211msg_dot11req_join_t *msg = msgp;
635 /* TODO: Implement after scan */
636 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
637 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
640 /*** ACCESS POINT ***/
642 /* Never supported by APs */
643 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
644 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
652 /*----------------------------------------------------------------
655 * Join a specific BSS
658 * wlandev wlan device structure
659 * msgp ptr to msg buffer
663 * <0 success, but we're waiting for something to finish.
664 * >0 an error occurred while handling the message.
668 * process thread (usually)
670 ----------------------------------------------------------------*/
671 int prism2mgmt_p2_join(wlandevice_t *wlandev, void *msgp)
674 hfa384x_t *hw = wlandev->priv;
675 p80211msg_p2req_join_t *msg = msgp;
679 hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
680 hfa384x_JoinRequest_data_t joinreq;
685 wlandev->macmode = WLAN_MACMODE_NONE;
688 /* Set the PortType */
689 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
690 msg->resultcode.data = P80211ENUM_resultcode_success;
693 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 1);
695 WLAN_LOG_ERROR("Failed to set Port Type\n");
699 /* Set the auth type */
700 if ( msg->authtype.data == P80211ENUM_authalg_sharedkey ) {
701 reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY;
703 reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM;
705 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, reg);
707 WLAN_LOG_ERROR("Failed to set Authentication\n");
711 /* Turn off all roaming */
712 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, 3);
714 WLAN_LOG_ERROR("Failed to Turn off Roaming\n");
720 if ( msg->basicrate1.status == P80211ENUM_msgitem_status_data_ok ) {
721 reg = p80211rate_to_p2bit(msg->basicrate1.data);
723 if ( msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok ) {
724 reg |= p80211rate_to_p2bit(msg->basicrate2.data);
726 if ( msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok ) {
727 reg |= p80211rate_to_p2bit(msg->basicrate3.data);
729 if ( msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok ) {
730 reg |= p80211rate_to_p2bit(msg->basicrate4.data);
732 if ( msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok ) {
733 reg |= p80211rate_to_p2bit(msg->basicrate5.data);
735 if ( msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok ) {
736 reg |= p80211rate_to_p2bit(msg->basicrate6.data);
738 if ( msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok ) {
739 reg |= p80211rate_to_p2bit(msg->basicrate7.data);
741 if ( msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok ) {
742 reg |= p80211rate_to_p2bit(msg->basicrate8.data);
746 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, reg);
748 WLAN_LOG_ERROR("Failed to set basicrates=%d.\n", reg);
752 /* Operational rates (supprates and txratecontrol) */
754 if ( msg->operationalrate1.status == P80211ENUM_msgitem_status_data_ok ) {
755 reg = p80211rate_to_p2bit(msg->operationalrate1.data);
757 if ( msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok ) {
758 reg |= p80211rate_to_p2bit(msg->operationalrate2.data);
760 if ( msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok ) {
761 reg |= p80211rate_to_p2bit(msg->operationalrate3.data);
763 if ( msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok ) {
764 reg |= p80211rate_to_p2bit(msg->operationalrate4.data);
766 if ( msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok ) {
767 reg |= p80211rate_to_p2bit(msg->operationalrate5.data);
769 if ( msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok ) {
770 reg |= p80211rate_to_p2bit(msg->operationalrate6.data);
772 if ( msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok ) {
773 reg |= p80211rate_to_p2bit(msg->operationalrate7.data);
775 if ( msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok ) {
776 reg |= p80211rate_to_p2bit(msg->operationalrate8.data);
780 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, reg);
782 WLAN_LOG_ERROR("Failed to set supprates=%d.\n", reg);
786 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, reg);
788 WLAN_LOG_ERROR("Failed to set txrates=%d.\n", reg);
793 memset(bytebuf, 0, 256);
794 pstr = (p80211pstrd_t*)&(msg->ssid.data);
795 prism2mgmt_pstr2bytestr(p2bytestr, pstr);
796 result = hfa384x_drvr_setconfig(
797 hw, HFA384x_RID_CNFDESIREDSSID,
798 bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
800 WLAN_LOG_ERROR("Failed to set SSID\n");
804 /* Enable the Port */
805 result = hfa384x_cmd_enable(hw, 0);
807 WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result);
811 /* Fill in the join request */
812 joinreq.channel = msg->channel.data;
813 memcpy( joinreq.bssid, ((unsigned char *) &msg->bssid.data) + 1, WLAN_BSSID_LEN);
814 hw->joinreq = joinreq;
817 /* Send the join request */
818 result = hfa384x_drvr_setconfig( hw,
819 HFA384x_RID_JOINREQUEST,
820 &joinreq, HFA384x_RID_JOINREQUEST_LEN);
822 WLAN_LOG_ERROR("Join request failed, result=%d.\n", result);
828 /*** ACCESS POINT ***/
830 /* Never supported by APs */
831 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
832 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
837 WLAN_LOG_DEBUG(1, "Failed to set a config option, result=%d\n", result);
838 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
848 /*----------------------------------------------------------------
849 * prism2mgmt_authenticate
851 * Station should be begin an authentication exchange.
854 * wlandev wlan device structure
855 * msgp ptr to msg buffer
859 * <0 success, but we're waiting for something to finish.
860 * >0 an error occurred while handling the message.
864 * process thread (usually)
866 ----------------------------------------------------------------*/
867 int prism2mgmt_authenticate(wlandevice_t *wlandev, void *msgp)
870 hfa384x_t *hw = wlandev->priv;
871 p80211msg_dot11req_authenticate_t *msg = msgp;
878 /* TODO: Decide how we're going to handle this one w/ Prism2 */
879 /* It could be entertaining since Prism2 doesn't have */
880 /* an explicit way to control this */
881 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
882 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
885 /*** ACCESS POINT ***/
887 /* Never supported by APs */
888 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
889 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
897 /*----------------------------------------------------------------
898 * prism2mgmt_deauthenticate
900 * Send a deauthenticate notification.
903 * wlandev wlan device structure
904 * msgp ptr to msg buffer
908 * <0 success, but we're waiting for something to finish.
909 * >0 an error occurred while handling the message.
913 * process thread (usually)
915 ----------------------------------------------------------------*/
916 int prism2mgmt_deauthenticate(wlandevice_t *wlandev, void *msgp)
919 hfa384x_t *hw = wlandev->priv;
920 p80211msg_dot11req_deauthenticate_t *msg = msgp;
927 /* TODO: Decide how we're going to handle this one w/ Prism2 */
928 /* It could be entertaining since Prism2 doesn't have */
929 /* an explicit way to control this */
930 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
931 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
934 /*** ACCESS POINT ***/
935 hfa384x_drvr_handover(hw, msg->peerstaaddress.data.data);
936 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
937 msg->resultcode.data = P80211ENUM_resultcode_success;
945 /*----------------------------------------------------------------
946 * prism2mgmt_associate
948 * Associate with an ESS.
951 * wlandev wlan device structure
952 * msgp ptr to msg buffer
956 * <0 success, but we're waiting for something to finish.
957 * >0 an error occurred while handling the message.
961 * process thread (usually)
963 ----------------------------------------------------------------*/
964 int prism2mgmt_associate(wlandevice_t *wlandev, void *msgp)
966 hfa384x_t *hw = wlandev->priv;
968 p80211msg_dot11req_associate_t *msg = msgp;
976 /* Set the TxRates */
978 hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, reg);
981 /* Set the PortType */
983 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 1);
985 /* Enable the Port */
986 hfa384x_drvr_enable(hw, 0);
988 /* Set the resultcode */
989 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
990 msg->resultcode.data = P80211ENUM_resultcode_success;
994 /*** ACCESS POINT ***/
996 /* Never supported on AP */
997 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
998 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1006 /*----------------------------------------------------------------
1007 * prism2mgmt_reassociate
1009 * Renew association because of a BSS change.
1012 * wlandev wlan device structure
1013 * msgp ptr to msg buffer
1016 * 0 success and done
1017 * <0 success, but we're waiting for something to finish.
1018 * >0 an error occurred while handling the message.
1022 * process thread (usually)
1024 ----------------------------------------------------------------*/
1025 int prism2mgmt_reassociate(wlandevice_t *wlandev, void *msgp)
1028 hfa384x_t *hw = wlandev->priv;
1029 p80211msg_dot11req_reassociate_t *msg = msgp;
1036 /* TODO: Not supported yet...not sure how we're going to do it */
1037 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1038 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1041 /*** ACCESS POINT ***/
1043 /* Never supported on AP */
1044 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1045 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1053 /*----------------------------------------------------------------
1054 * prism2mgmt_disassociate
1056 * Send a disassociation notification.
1059 * wlandev wlan device structure
1060 * msgp ptr to msg buffer
1063 * 0 success and done
1064 * <0 success, but we're waiting for something to finish.
1065 * >0 an error occurred while handling the message.
1069 * process thread (usually)
1071 ----------------------------------------------------------------*/
1072 int prism2mgmt_disassociate(wlandevice_t *wlandev, void *msgp)
1075 hfa384x_t *hw = wlandev->priv;
1076 p80211msg_dot11req_disassociate_t *msg = msgp;
1083 /* TODO: Not supported yet...not sure how to do it */
1084 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1085 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1088 /*** ACCESS POINT ***/
1089 hfa384x_drvr_handover(hw, msg->peerstaaddress.data.data);
1090 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1091 msg->resultcode.data = P80211ENUM_resultcode_success;
1099 /*----------------------------------------------------------------
1102 * Reset the MAC and MSD. The p80211 layer has it's own handling
1103 * that should be done before and after this function.
1105 * - disable system interrupts ??
1106 * - disable MAC interrupts
1107 * - restore system interrupts
1108 * - issue the MAC initialize command
1109 * - clear any MSD level state (including timers, queued events,
1110 * etc.). Note that if we're removing timer'd/queue events, we may
1111 * need to have remained in the system interrupt disabled state.
1112 * We should be left in the same state that we're in following
1113 * driver initialization.
1116 * wlandev wlan device structure
1117 * msgp ptr to msg buffer, MAY BE NULL! for a driver local
1121 * 0 success and done
1122 * <0 success, but we're waiting for something to finish.
1123 * >0 an error occurred while handling the message.
1127 * process thread, commonly wlanctl, but might be rmmod/pci_close.
1128 ----------------------------------------------------------------*/
1129 int prism2mgmt_reset(wlandevice_t *wlandev, void *msgp)
1132 hfa384x_t *hw = wlandev->priv;
1133 p80211msg_dot11req_reset_t *msg = msgp;
1137 * This is supported on both AP and STA and it's not allowed
1141 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1142 msg->resultcode.data = P80211ENUM_resultcode_success;
1143 WLAN_LOG_INFO("dot11req_reset: the macaddress and "
1144 "setdefaultmib arguments are currently unsupported.\n");
1148 * If we got this far, the MSD must be in the MSDRUNNING state
1149 * therefore, we must stop and then restart the hw/MAC combo.
1151 hfa384x_drvr_stop(hw);
1152 result = hfa384x_drvr_start(hw);
1154 WLAN_LOG_ERROR("dot11req_reset: Initialize command failed,"
1155 " bad things will happen from here.\n");
1164 /*----------------------------------------------------------------
1167 * Start a BSS. Any station can do this for IBSS, only AP for ESS.
1170 * wlandev wlan device structure
1171 * msgp ptr to msg buffer
1174 * 0 success and done
1175 * <0 success, but we're waiting for something to finish.
1176 * >0 an error occurred while handling the message.
1180 * process thread (usually)
1182 ----------------------------------------------------------------*/
1183 int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
1186 hfa384x_t *hw = wlandev->priv;
1187 p80211msg_dot11req_start_t *msg = msgp;
1189 p80211pstrd_t *pstr;
1191 hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
1192 hfa384x_PCFInfo_data_t *pcfinfo = (hfa384x_PCFInfo_data_t*)bytebuf;
1196 wlandev->macmode = WLAN_MACMODE_NONE;
1199 memcpy(&wlandev->ssid, &msg->ssid.data, sizeof(msg->ssid.data));
1202 /*** ADHOC IBSS ***/
1203 /* see if current f/w is less than 8c3 */
1204 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
1205 hw->ident_sta_fw.minor,
1206 hw->ident_sta_fw.variant) <
1207 HFA384x_FIRMWARE_VERSION(0,8,3)) {
1208 /* Ad-Hoc not quite supported on Prism2 */
1209 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1210 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1214 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1217 /* Set the REQUIRED config items */
1219 pstr = (p80211pstrd_t*)&(msg->ssid.data);
1220 prism2mgmt_pstr2bytestr(p2bytestr, pstr);
1221 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
1222 bytebuf, HFA384x_RID_CNFOWNSSID_LEN);
1224 WLAN_LOG_ERROR("Failed to set CnfOwnSSID\n");
1227 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID,
1228 bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
1230 WLAN_LOG_ERROR("Failed to set CnfDesiredSSID\n");
1234 /* bsstype - we use the default in the ap firmware */
1236 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 0);
1239 word = msg->beaconperiod.data;
1240 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNINT, word);
1242 WLAN_LOG_ERROR("Failed to set beacon period=%d.\n", word);
1247 word = msg->dschannel.data;
1248 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word);
1250 WLAN_LOG_ERROR("Failed to set channel=%d.\n", word);
1254 word = p80211rate_to_p2bit(msg->basicrate1.data);
1255 if ( msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok ) {
1256 word |= p80211rate_to_p2bit(msg->basicrate2.data);
1258 if ( msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok ) {
1259 word |= p80211rate_to_p2bit(msg->basicrate3.data);
1261 if ( msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok ) {
1262 word |= p80211rate_to_p2bit(msg->basicrate4.data);
1264 if ( msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok ) {
1265 word |= p80211rate_to_p2bit(msg->basicrate5.data);
1267 if ( msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok ) {
1268 word |= p80211rate_to_p2bit(msg->basicrate6.data);
1270 if ( msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok ) {
1271 word |= p80211rate_to_p2bit(msg->basicrate7.data);
1273 if ( msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok ) {
1274 word |= p80211rate_to_p2bit(msg->basicrate8.data);
1276 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word);
1278 WLAN_LOG_ERROR("Failed to set basicrates=%d.\n", word);
1282 /* Operational rates (supprates and txratecontrol) */
1283 word = p80211rate_to_p2bit(msg->operationalrate1.data);
1284 if ( msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok ) {
1285 word |= p80211rate_to_p2bit(msg->operationalrate2.data);
1287 if ( msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok ) {
1288 word |= p80211rate_to_p2bit(msg->operationalrate3.data);
1290 if ( msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok ) {
1291 word |= p80211rate_to_p2bit(msg->operationalrate4.data);
1293 if ( msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok ) {
1294 word |= p80211rate_to_p2bit(msg->operationalrate5.data);
1296 if ( msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok ) {
1297 word |= p80211rate_to_p2bit(msg->operationalrate6.data);
1299 if ( msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok ) {
1300 word |= p80211rate_to_p2bit(msg->operationalrate7.data);
1302 if ( msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok ) {
1303 word |= p80211rate_to_p2bit(msg->operationalrate8.data);
1305 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word);
1307 WLAN_LOG_ERROR("Failed to set supprates=%d.\n", word);
1311 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word);
1313 WLAN_LOG_ERROR("Failed to set txrates=%d.\n", word);
1317 /* Set the macmode so the frame setup code knows what to do */
1318 if ( msg->bsstype.data == P80211ENUM_bsstype_independent ) {
1319 wlandev->macmode = WLAN_MACMODE_IBSS_STA;
1320 /* lets extend the data length a bit */
1321 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304);
1324 /* Enable the Port */
1325 result = hfa384x_drvr_enable(hw, 0);
1327 WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result);
1331 msg->resultcode.data = P80211ENUM_resultcode_success;
1336 /*** ACCESS POINT ***/
1338 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1340 /* Validate the command, if BSStype=infra is the tertiary loaded? */
1341 if ( msg->bsstype.data == P80211ENUM_bsstype_independent ) {
1342 WLAN_LOG_ERROR("AP driver cannot create IBSS.\n");
1344 } else if ( hw->cap_sup_sta.id != 5) {
1345 WLAN_LOG_ERROR("AP driver failed to detect AP firmware.\n");
1349 /* Set the REQUIRED config items */
1351 pstr = (p80211pstrd_t*)&(msg->ssid.data);
1352 prism2mgmt_pstr2bytestr(p2bytestr, pstr);
1353 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
1354 bytebuf, HFA384x_RID_CNFOWNSSID_LEN);
1356 WLAN_LOG_ERROR("Failed to set SSID, result=0x%04x\n", result);
1360 /* bsstype - we use the default in the ap firmware */
1363 word = msg->beaconperiod.data;
1364 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNINT, word);
1366 WLAN_LOG_ERROR("Failed to set beacon period=%d.\n", word);
1371 word = msg->dschannel.data;
1372 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word);
1374 WLAN_LOG_ERROR("Failed to set channel=%d.\n", word);
1378 word = p80211rate_to_p2bit(msg->basicrate1.data);
1379 if ( msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok ) {
1380 word |= p80211rate_to_p2bit(msg->basicrate2.data);
1382 if ( msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok ) {
1383 word |= p80211rate_to_p2bit(msg->basicrate3.data);
1385 if ( msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok ) {
1386 word |= p80211rate_to_p2bit(msg->basicrate4.data);
1388 if ( msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok ) {
1389 word |= p80211rate_to_p2bit(msg->basicrate5.data);
1391 if ( msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok ) {
1392 word |= p80211rate_to_p2bit(msg->basicrate6.data);
1394 if ( msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok ) {
1395 word |= p80211rate_to_p2bit(msg->basicrate7.data);
1397 if ( msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok ) {
1398 word |= p80211rate_to_p2bit(msg->basicrate8.data);
1400 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word);
1402 WLAN_LOG_ERROR("Failed to set basicrates=%d.\n", word);
1406 /* Operational rates (supprates and txratecontrol) */
1407 word = p80211rate_to_p2bit(msg->operationalrate1.data);
1408 if ( msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok ) {
1409 word |= p80211rate_to_p2bit(msg->operationalrate2.data);
1411 if ( msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok ) {
1412 word |= p80211rate_to_p2bit(msg->operationalrate3.data);
1414 if ( msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok ) {
1415 word |= p80211rate_to_p2bit(msg->operationalrate4.data);
1417 if ( msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok ) {
1418 word |= p80211rate_to_p2bit(msg->operationalrate5.data);
1420 if ( msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok ) {
1421 word |= p80211rate_to_p2bit(msg->operationalrate6.data);
1423 if ( msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok ) {
1424 word |= p80211rate_to_p2bit(msg->operationalrate7.data);
1426 if ( msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok ) {
1427 word |= p80211rate_to_p2bit(msg->operationalrate8.data);
1429 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word);
1431 WLAN_LOG_ERROR("Failed to set supprates=%d.\n", word);
1434 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL0, word);
1436 WLAN_LOG_ERROR("Failed to set txrates=%d.\n", word);
1440 /* ibssatimwindow */
1441 if (msg->ibssatimwindow.status == P80211ENUM_msgitem_status_data_ok) {
1442 WLAN_LOG_INFO("prism2mgmt_start: atimwindow not used in "
1443 "Infrastructure mode, ignored.\n");
1447 word = msg->dtimperiod.data;
1448 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNDTIMPER, word);
1450 WLAN_LOG_ERROR("Failed to set dtim period=%d.\n", word);
1455 if (msg->probedelay.status == P80211ENUM_msgitem_status_data_ok) {
1456 WLAN_LOG_INFO("prism2mgmt_start: probedelay not "
1457 "supported in prism2, ignored.\n");
1460 /* cfpollable, cfpollreq, cfpperiod, cfpmaxduration */
1461 if (msg->cfpollable.data == P80211ENUM_truth_true &&
1462 msg->cfpollreq.data == P80211ENUM_truth_true ) {
1463 WLAN_LOG_ERROR("cfpollable=cfpollreq=true is illegal.\n");
1468 /* read the PCFInfo and update */
1469 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFAPPCFINFO,
1470 pcfinfo, HFA384x_RID_CNFAPPCFINFO_LEN);
1472 WLAN_LOG_INFO("prism2mgmt_start: read(pcfinfo) failed, "
1474 "not supported, pcf settings ignored.\n");
1477 if ((msg->cfpollable.data == P80211ENUM_truth_false &&
1478 msg->cfpollreq.data == P80211ENUM_truth_false) ) {
1479 pcfinfo->MediumOccupancyLimit = 0;
1480 pcfinfo->CFPPeriod = 0;
1481 pcfinfo->CFPMaxDuration = 0;
1482 pcfinfo->CFPFlags &= host2hfa384x_16((UINT16)~BIT0);
1484 if ( msg->cfpperiod.status == P80211ENUM_msgitem_status_data_ok ||
1485 msg->cfpmaxduration.status == P80211ENUM_msgitem_status_data_ok ) {
1487 "Setting cfpperiod or cfpmaxduration when "
1488 "cfpollable and cfreq are false is pointless.\n");
1491 if ((msg->cfpollable.data == P80211ENUM_truth_true ||
1492 msg->cfpollreq.data == P80211ENUM_truth_true) ) {
1493 if ( msg->cfpollable.data == P80211ENUM_truth_true) {
1494 pcfinfo->CFPFlags |= host2hfa384x_16((UINT16)BIT0);
1497 if ( msg->cfpperiod.status == P80211ENUM_msgitem_status_data_ok) {
1498 pcfinfo->CFPPeriod = msg->cfpperiod.data;
1499 pcfinfo->CFPPeriod = host2hfa384x_16(pcfinfo->CFPPeriod);
1502 if ( msg->cfpmaxduration.status == P80211ENUM_msgitem_status_data_ok) {
1503 pcfinfo->CFPMaxDuration = msg->cfpmaxduration.data;
1504 pcfinfo->CFPMaxDuration = host2hfa384x_16(pcfinfo->CFPMaxDuration);
1505 pcfinfo->MediumOccupancyLimit = pcfinfo->CFPMaxDuration;
1508 result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFAPPCFINFO,
1509 pcfinfo, HFA384x_RID_CNFAPPCFINFO_LEN);
1511 WLAN_LOG_ERROR("write(pcfinfo) failed.\n");
1516 /* Set the macmode so the frame setup code knows what to do */
1517 if ( msg->bsstype.data == P80211ENUM_bsstype_infrastructure ) {
1518 wlandev->macmode = WLAN_MACMODE_ESS_AP;
1519 /* lets extend the data length a bit */
1520 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304);
1523 /* Set the BSSID to the same as our MAC */
1524 memcpy( wlandev->bssid, wlandev->netdev->dev_addr, WLAN_BSSID_LEN);
1526 /* Enable the Port */
1527 result = hfa384x_drvr_enable(hw, 0);
1529 WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result);
1533 msg->resultcode.data = P80211ENUM_resultcode_success;
1537 WLAN_LOG_DEBUG(1, "Failed to set a config option, result=%d\n", result);
1538 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
1548 /*----------------------------------------------------------------
1551 * Start a BSS. Any station can do this for IBSS, only AP for ESS.
1554 * wlandev wlan device structure
1555 * msgp ptr to msg buffer
1558 * 0 success and done
1559 * <0 success, but we're waiting for something to finish.
1560 * >0 an error occurred while handling the message.
1564 * process thread (usually)
1566 ----------------------------------------------------------------*/
1567 int prism2mgmt_enable(wlandevice_t *wlandev, void *msgp)
1570 hfa384x_t *hw = wlandev->priv;
1571 p80211msg_p2req_enable_t *msg = msgp;
1578 /* Ad-Hoc not quite supported on Prism2 */
1579 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1580 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1584 /*** ACCESS POINT ***/
1586 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1588 /* Is the tertiary loaded? */
1589 if ( hw->cap_sup_sta.id != 5) {
1590 WLAN_LOG_ERROR("AP driver failed to detect AP firmware.\n");
1594 /* Set the macmode so the frame setup code knows what to do */
1595 wlandev->macmode = WLAN_MACMODE_ESS_AP;
1597 /* Set the BSSID to the same as our MAC */
1598 memcpy( wlandev->bssid, wlandev->netdev->dev_addr, WLAN_BSSID_LEN);
1600 /* Enable the Port */
1601 result = hfa384x_drvr_enable(hw, 0);
1603 WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result);
1607 msg->resultcode.data = P80211ENUM_resultcode_success;
1611 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
1621 /*----------------------------------------------------------------
1622 * prism2mgmt_readpda
1624 * Collect the PDA data and put it in the message.
1627 * wlandev wlan device structure
1628 * msgp ptr to msg buffer
1631 * 0 success and done
1632 * <0 success, but we're waiting for something to finish.
1633 * >0 an error occurred while handling the message.
1637 * process thread (usually)
1638 ----------------------------------------------------------------*/
1639 int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp)
1641 hfa384x_t *hw = wlandev->priv;
1642 p80211msg_p2req_readpda_t *msg = msgp;
1646 /* We only support collecting the PDA when in the FWLOAD
1649 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
1651 "PDA may only be read "
1652 "in the fwload state.\n");
1653 msg->resultcode.data =
1654 P80211ENUM_resultcode_implementation_failure;
1655 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1657 /* Call drvr_readpda(), it handles the auxport enable
1658 * and validating the returned PDA.
1660 result = hfa384x_drvr_readpda(
1663 HFA384x_PDA_LEN_MAX);
1666 "hfa384x_drvr_readpda() failed, "
1670 msg->resultcode.data =
1671 P80211ENUM_resultcode_implementation_failure;
1672 msg->resultcode.status =
1673 P80211ENUM_msgitem_status_data_ok;
1677 msg->pda.status = P80211ENUM_msgitem_status_data_ok;
1678 msg->resultcode.data = P80211ENUM_resultcode_success;
1679 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1686 /*----------------------------------------------------------------
1687 * prism2mgmt_readcis
1689 * Collect the CIS data and put it in the message.
1692 * wlandev wlan device structure
1693 * msgp ptr to msg buffer
1696 * 0 success and done
1697 * <0 success, but we're waiting for something to finish.
1698 * >0 an error occurred while handling the message.
1702 * process thread (usually)
1703 ----------------------------------------------------------------*/
1704 int prism2mgmt_readcis(wlandevice_t *wlandev, void *msgp)
1707 hfa384x_t *hw = wlandev->priv;
1708 p80211msg_p2req_readcis_t *msg = msgp;
1712 memset(msg->cis.data, 0, sizeof(msg->cis.data));
1714 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CIS,
1715 msg->cis.data, HFA384x_RID_CIS_LEN);
1717 WLAN_LOG_INFO("prism2mgmt_readcis: read(cis) failed.\n");
1718 msg->cis.status = P80211ENUM_msgitem_status_no_value;
1719 msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
1723 msg->cis.status = P80211ENUM_msgitem_status_data_ok;
1724 msg->resultcode.data = P80211ENUM_resultcode_success;
1727 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1733 /*----------------------------------------------------------------
1734 * prism2mgmt_auxport_state
1736 * Enables/Disables the card's auxiliary port. Should be called
1737 * before and after a sequence of auxport_read()/auxport_write()
1741 * wlandev wlan device structure
1742 * msgp ptr to msg buffer
1745 * 0 success and done
1746 * <0 success, but we're waiting for something to finish.
1747 * >0 an error occurred while handling the message.
1751 * process thread (usually)
1752 ----------------------------------------------------------------*/
1753 int prism2mgmt_auxport_state(wlandevice_t *wlandev, void *msgp)
1755 p80211msg_p2req_auxport_state_t *msg = msgp;
1759 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1760 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1767 /*----------------------------------------------------------------
1768 * prism2mgmt_auxport_read
1770 * Copies data from the card using the auxport. The auxport must
1771 * have previously been enabled. Note: this is not the way to
1772 * do downloads, see the [ram|flash]dl functions.
1775 * wlandev wlan device structure
1776 * msgp ptr to msg buffer
1779 * 0 success and done
1780 * <0 success, but we're waiting for something to finish.
1781 * >0 an error occurred while handling the message.
1785 * process thread (usually)
1786 ----------------------------------------------------------------*/
1787 int prism2mgmt_auxport_read(wlandevice_t *wlandev, void *msgp)
1791 WLAN_LOG_ERROR("prism2mgmt_auxport_read: Not supported on USB.\n");
1798 /*----------------------------------------------------------------
1799 * prism2mgmt_auxport_write
1801 * Copies data to the card using the auxport. The auxport must
1802 * have previously been enabled. Note: this is not the way to
1803 * do downloads, see the [ram|flash]dl functions.
1806 * wlandev wlan device structure
1807 * msgp ptr to msg buffer
1810 * 0 success and done
1811 * <0 success, but we're waiting for something to finish.
1812 * >0 an error occurred while handling the message.
1816 * process thread (usually)
1817 ----------------------------------------------------------------*/
1818 int prism2mgmt_auxport_write(wlandevice_t *wlandev, void *msgp)
1821 WLAN_LOG_ERROR("prism2mgmt_auxport_read: Not supported on USB.\n");
1826 /*----------------------------------------------------------------
1827 * prism2mgmt_low_level
1829 * Puts the card into the desired test mode.
1832 * wlandev wlan device structure
1833 * msgp ptr to msg buffer
1836 * 0 success and done
1837 * <0 success, but we're waiting for something to finish.
1838 * >0 an error occurred while handling the message.
1842 * process thread (usually)
1843 ----------------------------------------------------------------*/
1844 int prism2mgmt_low_level(wlandevice_t *wlandev, void *msgp)
1846 hfa384x_t *hw = wlandev->priv;
1847 p80211msg_p2req_low_level_t *msg = msgp;
1848 hfa384x_metacmd_t cmd;
1851 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1853 /* call some routine to execute the test command */
1854 cmd.cmd = (UINT16) msg->command.data;
1855 cmd.parm0 = (UINT16) msg->param0.data;
1856 cmd.parm1 = (UINT16) msg->param1.data;
1857 cmd.parm2 = (UINT16) msg->param2.data;
1859 hfa384x_drvr_low_level(hw,&cmd);
1861 msg->resp0.data = (UINT32) cmd.result.resp0;
1862 msg->resp1.data = (UINT32) cmd.result.resp1;
1863 msg->resp2.data = (UINT32) cmd.result.resp2;
1865 msg->resultcode.data = P80211ENUM_resultcode_success;
1871 /*----------------------------------------------------------------
1872 * prism2mgmt_test_command
1874 * Puts the card into the desired test mode.
1877 * wlandev wlan device structure
1878 * msgp ptr to msg buffer
1881 * 0 success and done
1882 * <0 success, but we're waiting for something to finish.
1883 * >0 an error occurred while handling the message.
1887 * process thread (usually)
1888 ----------------------------------------------------------------*/
1889 int prism2mgmt_test_command(wlandevice_t *wlandev, void *msgp)
1891 hfa384x_t *hw = wlandev->priv;
1892 p80211msg_p2req_test_command_t *msg = msgp;
1893 hfa384x_metacmd_t cmd;
1897 cmd.cmd = ((UINT16) msg->testcode.data) << 8 | 0x38;
1898 cmd.parm0 = (UINT16) msg->testparam.data;
1902 /* call some routine to execute the test command */
1904 hfa384x_drvr_low_level(hw,&cmd);
1906 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1907 msg->resultcode.data = P80211ENUM_resultcode_success;
1909 msg->status.status = P80211ENUM_msgitem_status_data_ok;
1910 msg->status.data = cmd.result.status;
1911 msg->resp0.status = P80211ENUM_msgitem_status_data_ok;
1912 msg->resp0.data = cmd.result.resp0;
1913 msg->resp1.status = P80211ENUM_msgitem_status_data_ok;
1914 msg->resp1.data = cmd.result.resp1;
1915 msg->resp2.status = P80211ENUM_msgitem_status_data_ok;
1916 msg->resp2.data = cmd.result.resp2;
1923 /*----------------------------------------------------------------
1924 * prism2mgmt_mmi_read
1926 * Read from one of the MMI registers.
1929 * wlandev wlan device structure
1930 * msgp ptr to msg buffer
1933 * 0 success and done
1934 * <0 success, but we're waiting for something to finish.
1935 * >0 an error occurred while handling the message.
1939 * process thread (usually)
1940 ----------------------------------------------------------------*/
1941 int prism2mgmt_mmi_read(wlandevice_t *wlandev, void *msgp)
1943 hfa384x_t *hw = wlandev->priv;
1944 p80211msg_p2req_mmi_read_t *msg = msgp;
1949 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1951 /* call some routine to execute the test command */
1953 hfa384x_drvr_mmi_read(hw, msg->addr.data, &resp);
1955 /* I'm not sure if this is "architecturally" correct, but it
1958 msg->value.status = P80211ENUM_msgitem_status_data_ok;
1959 msg->value.data = resp;
1960 msg->resultcode.data = P80211ENUM_resultcode_success;
1966 /*----------------------------------------------------------------
1967 * prism2mgmt_mmi_write
1969 * Write a data value to one of the MMI registers.
1972 * wlandev wlan device structure
1973 * msgp ptr to msg buffer
1976 * 0 success and done
1977 * <0 success, but we're waiting for something to finish.
1978 * >0 an error occurred while handling the message.
1982 * process thread (usually)
1983 ----------------------------------------------------------------*/
1984 int prism2mgmt_mmi_write(wlandevice_t *wlandev, void *msgp)
1986 hfa384x_t *hw = wlandev->priv;
1987 p80211msg_p2req_mmi_write_t *msg = msgp;
1990 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1992 /* call some routine to execute the test command */
1994 hfa384x_drvr_mmi_write(hw, msg->addr.data, msg->data.data);
1996 msg->resultcode.data = P80211ENUM_resultcode_success;
2002 /*----------------------------------------------------------------
2003 * prism2mgmt_ramdl_state
2005 * Establishes the beginning/end of a card RAM download session.
2007 * It is expected that the ramdl_write() function will be called
2008 * one or more times between the 'enable' and 'disable' calls to
2011 * Note: This function should not be called when a mac comm port
2015 * wlandev wlan device structure
2016 * msgp ptr to msg buffer
2019 * 0 success and done
2020 * <0 success, but we're waiting for something to finish.
2021 * >0 an error occurred while handling the message.
2025 * process thread (usually)
2026 ----------------------------------------------------------------*/
2027 int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp)
2029 hfa384x_t *hw = wlandev->priv;
2030 p80211msg_p2req_ramdl_state_t *msg = msgp;
2033 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
2035 "ramdl_state(): may only be called "
2036 "in the fwload state.\n");
2037 msg->resultcode.data =
2038 P80211ENUM_resultcode_implementation_failure;
2039 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2045 ** Note: Interrupts are locked out if this is an AP and are NOT
2046 ** locked out if this is a station.
2049 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2050 if ( msg->enable.data == P80211ENUM_truth_true ) {
2051 if ( hfa384x_drvr_ramdl_enable(hw, msg->exeaddr.data) ) {
2052 msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
2054 msg->resultcode.data = P80211ENUM_resultcode_success;
2057 hfa384x_drvr_ramdl_disable(hw);
2058 msg->resultcode.data = P80211ENUM_resultcode_success;
2066 /*----------------------------------------------------------------
2067 * prism2mgmt_ramdl_write
2069 * Writes a buffer to the card RAM using the download state. This
2070 * is for writing code to card RAM. To just read or write raw data
2071 * use the aux functions.
2074 * wlandev wlan device structure
2075 * msgp ptr to msg buffer
2078 * 0 success and done
2079 * <0 success, but we're waiting for something to finish.
2080 * >0 an error occurred while handling the message.
2084 * process thread (usually)
2085 ----------------------------------------------------------------*/
2086 int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp)
2088 hfa384x_t *hw = wlandev->priv;
2089 p80211msg_p2req_ramdl_write_t *msg = msgp;
2095 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
2097 "ramdl_write(): may only be called "
2098 "in the fwload state.\n");
2099 msg->resultcode.data =
2100 P80211ENUM_resultcode_implementation_failure;
2101 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2106 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2107 /* first validate the length */
2108 if ( msg->len.data > sizeof(msg->data.data) ) {
2109 msg->resultcode.status = P80211ENUM_resultcode_invalid_parameters;
2112 /* call the hfa384x function to do the write */
2113 addr = msg->addr.data;
2114 len = msg->len.data;
2115 buf = msg->data.data;
2116 if ( hfa384x_drvr_ramdl_write(hw, addr, buf, len) ) {
2117 msg->resultcode.data = P80211ENUM_resultcode_refused;
2120 msg->resultcode.data = P80211ENUM_resultcode_success;
2127 /*----------------------------------------------------------------
2128 * prism2mgmt_flashdl_state
2130 * Establishes the beginning/end of a card Flash download session.
2132 * It is expected that the flashdl_write() function will be called
2133 * one or more times between the 'enable' and 'disable' calls to
2136 * Note: This function should not be called when a mac comm port
2140 * wlandev wlan device structure
2141 * msgp ptr to msg buffer
2144 * 0 success and done
2145 * <0 success, but we're waiting for something to finish.
2146 * >0 an error occurred while handling the message.
2150 * process thread (usually)
2151 ----------------------------------------------------------------*/
2152 int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
2155 hfa384x_t *hw = wlandev->priv;
2156 p80211msg_p2req_flashdl_state_t *msg = msgp;
2159 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
2161 "flashdl_state(): may only be called "
2162 "in the fwload state.\n");
2163 msg->resultcode.data =
2164 P80211ENUM_resultcode_implementation_failure;
2165 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2171 ** Note: Interrupts are locked out if this is an AP and are NOT
2172 ** locked out if this is a station.
2175 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2176 if ( msg->enable.data == P80211ENUM_truth_true ) {
2177 if ( hfa384x_drvr_flashdl_enable(hw) ) {
2178 msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
2180 msg->resultcode.data = P80211ENUM_resultcode_success;
2183 hfa384x_drvr_flashdl_disable(hw);
2184 msg->resultcode.data = P80211ENUM_resultcode_success;
2185 /* NOTE: At this point, the MAC is in the post-reset
2186 * state and the driver is in the fwload state.
2187 * We need to get the MAC back into the fwload
2188 * state. To do this, we set the nsdstate to HWPRESENT
2189 * and then call the ifstate function to redo everything
2190 * that got us into the fwload state.
2192 wlandev->msdstate = WLAN_MSD_HWPRESENT;
2193 result = prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload);
2194 if (result != P80211ENUM_resultcode_success) {
2195 WLAN_LOG_ERROR("prism2sta_ifstate(fwload) failed,"
2196 "P80211ENUM_resultcode=%d\n", result);
2197 msg->resultcode.data =
2198 P80211ENUM_resultcode_implementation_failure;
2208 /*----------------------------------------------------------------
2209 * prism2mgmt_flashdl_write
2214 * wlandev wlan device structure
2215 * msgp ptr to msg buffer
2218 * 0 success and done
2219 * <0 success, but we're waiting for something to finish.
2220 * >0 an error occurred while handling the message.
2224 * process thread (usually)
2225 ----------------------------------------------------------------*/
2226 int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp)
2228 hfa384x_t *hw = wlandev->priv;
2229 p80211msg_p2req_flashdl_write_t *msg = msgp;
2235 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
2237 "flashdl_write(): may only be called "
2238 "in the fwload state.\n");
2239 msg->resultcode.data =
2240 P80211ENUM_resultcode_implementation_failure;
2241 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2247 ** Note: Interrupts are locked out if this is an AP and are NOT
2248 ** locked out if this is a station.
2251 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2252 /* first validate the length */
2253 if ( msg->len.data > sizeof(msg->data.data) ) {
2254 msg->resultcode.status =
2255 P80211ENUM_resultcode_invalid_parameters;
2258 /* call the hfa384x function to do the write */
2259 addr = msg->addr.data;
2260 len = msg->len.data;
2261 buf = msg->data.data;
2262 if ( hfa384x_drvr_flashdl_write(hw, addr, buf, len) ) {
2263 msg->resultcode.data = P80211ENUM_resultcode_refused;
2266 msg->resultcode.data = P80211ENUM_resultcode_success;
2273 /*----------------------------------------------------------------
2274 * prism2mgmt_dump_state
2276 * Dumps the driver's and hardware's current state via the kernel
2277 * log at KERN_NOTICE level.
2280 * wlandev wlan device structure
2281 * msgp ptr to msg buffer
2284 * 0 success and done
2285 * <0 success, but we're waiting for something to finish.
2286 * >0 an error occurred while handling the message.
2290 * process thread (usually)
2291 ----------------------------------------------------------------*/
2292 int prism2mgmt_dump_state(wlandevice_t *wlandev, void *msgp)
2294 p80211msg_p2req_dump_state_t *msg = msgp;
2299 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2300 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
2308 /*----------------------------------------------------------------
2309 * prism2mgmt_autojoin
2311 * Associate with an ESS.
2314 * wlandev wlan device structure
2315 * msgp ptr to msg buffer
2318 * 0 success and done
2319 * <0 success, but we're waiting for something to finish.
2320 * >0 an error occurred while handling the message.
2324 * process thread (usually)
2326 ----------------------------------------------------------------*/
2327 int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
2329 hfa384x_t *hw = wlandev->priv;
2333 p80211msg_lnxreq_autojoin_t *msg = msgp;
2334 p80211pstrd_t *pstr;
2336 hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
2339 wlandev->macmode = WLAN_MACMODE_NONE;
2342 memcpy(&wlandev->ssid, &msg->ssid.data, sizeof(msg->ssid.data));
2346 /*** ACCESS POINT ***/
2348 /* Never supported on AP */
2349 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2350 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
2354 /* Disable the Port */
2355 hfa384x_drvr_disable(hw, 0);
2358 /* Set the TxRates */
2359 hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, 0x000f);
2361 /* Set the auth type */
2362 if ( msg->authtype.data == P80211ENUM_authalg_sharedkey ) {
2363 reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY;
2365 reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM;
2367 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, reg);
2370 memset(bytebuf, 0, 256);
2371 pstr = (p80211pstrd_t*)&(msg->ssid.data);
2372 prism2mgmt_pstr2bytestr(p2bytestr, pstr);
2373 result = hfa384x_drvr_setconfig(
2374 hw, HFA384x_RID_CNFDESIREDSSID,
2375 bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
2377 /* we can use the new-fangled auto-unknown mode if the firmware
2378 is 1.3.3 or newer */
2379 if (HFA384x_FIRMARE_VERSION(hw->ident_sta_fw.major,
2380 hw->ident_sta_fw.minor,
2381 hw->ident_sta_fw.variant) >=
2382 HFA384x_FIRMWARE_VERSION(1,3,3)) {
2383 /* Set up the IBSS options */
2384 reg = HFA384x_CREATEIBSS_JOINESS_JOINCREATEIBSS;
2385 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CREATEIBSS, reg);
2387 /* Set the PortType */
2388 port_type = HFA384x_PORTTYPE_IBSS;
2390 port_type = HFA384x_PORTTYPE_BSS;
2393 port_type = HFA384x_PORTTYPE_BSS;
2395 /* Set the PortType */
2396 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, port_type);
2398 /* Enable the Port */
2399 hfa384x_drvr_enable(hw, 0);
2401 /* Set the resultcode */
2402 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2403 msg->resultcode.data = P80211ENUM_resultcode_success;
2411 /*----------------------------------------------------------------
2412 * prism2mgmt_wlansniff
2414 * Start or stop sniffing.
2417 * wlandev wlan device structure
2418 * msgp ptr to msg buffer
2421 * 0 success and done
2422 * <0 success, but we're waiting for something to finish.
2423 * >0 an error occurred while handling the message.
2427 * process thread (usually)
2429 ----------------------------------------------------------------*/
2430 int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
2433 p80211msg_lnxreq_wlansniff_t *msg = msgp;
2435 hfa384x_t *hw = wlandev->priv;
2440 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2441 switch (msg->enable.data)
2443 case P80211ENUM_truth_false:
2444 /* Confirm that we're in monitor mode */
2445 if ( wlandev->netdev->type == ARPHRD_ETHER ) {
2446 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
2450 /* Disable monitor mode */
2451 result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
2454 "failed to disable monitor mode, result=%d\n",
2458 /* Disable port 0 */
2459 result = hfa384x_drvr_disable(hw, 0);
2462 "failed to disable port 0 after sniffing, result=%d\n",
2466 /* Clear the driver state */
2467 wlandev->netdev->type = ARPHRD_ETHER;
2469 /* Restore the wepflags */
2470 result = hfa384x_drvr_setconfig16(hw,
2471 HFA384x_RID_CNFWEPFLAGS,
2472 hw->presniff_wepflags);
2475 "failed to restore wepflags=0x%04x, result=%d\n",
2476 hw->presniff_wepflags,
2481 /* Set the port to its prior type and enable (if necessary) */
2482 if (hw->presniff_port_type != 0 ) {
2483 word = hw->presniff_port_type;
2484 result = hfa384x_drvr_setconfig16(hw,
2485 HFA384x_RID_CNFPORTTYPE, word);
2488 "failed to restore porttype, result=%d\n",
2493 /* Enable the port */
2494 result = hfa384x_drvr_enable(hw, 0);
2496 WLAN_LOG_DEBUG(1, "failed to enable port to presniff setting, result=%d\n", result);
2500 result = hfa384x_drvr_disable(hw, 0);
2504 WLAN_LOG_INFO("monitor mode disabled\n");
2505 msg->resultcode.data = P80211ENUM_resultcode_success;
2509 case P80211ENUM_truth_true:
2510 /* Disable the port (if enabled), only check Port 0 */
2511 if ( hw->port_enabled[0]) {
2512 if (wlandev->netdev->type == ARPHRD_ETHER) {
2513 /* Save macport 0 state */
2514 result = hfa384x_drvr_getconfig16(hw,
2515 HFA384x_RID_CNFPORTTYPE,
2516 &(hw->presniff_port_type));
2518 WLAN_LOG_DEBUG(1,"failed to read porttype, result=%d\n", result);
2521 /* Save the wepflags state */
2522 result = hfa384x_drvr_getconfig16(hw,
2523 HFA384x_RID_CNFWEPFLAGS,
2524 &(hw->presniff_wepflags));
2526 WLAN_LOG_DEBUG(1,"failed to read wepflags, result=%d\n", result);
2529 hfa384x_drvr_stop(hw);
2530 result = hfa384x_drvr_start(hw);
2533 "failed to restart the card for sniffing, result=%d\n",
2538 /* Disable the port */
2539 result = hfa384x_drvr_disable(hw, 0);
2542 "failed to enable port for sniffing, result=%d\n",
2548 hw->presniff_port_type = 0;
2551 /* Set the channel we wish to sniff */
2552 word = msg->channel.data;
2553 result = hfa384x_drvr_setconfig16(hw,
2554 HFA384x_RID_CNFOWNCHANNEL, word);
2555 hw->sniff_channel=word;
2559 "failed to set channel %d, result=%d\n",
2565 /* Now if we're already sniffing, we can skip the rest */
2566 if (wlandev->netdev->type != ARPHRD_ETHER) {
2567 /* Set the port type to pIbss */
2568 word = HFA384x_PORTTYPE_PSUEDOIBSS;
2569 result = hfa384x_drvr_setconfig16(hw,
2570 HFA384x_RID_CNFPORTTYPE, word);
2573 "failed to set porttype %d, result=%d\n",
2578 if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) {
2579 /* Set the wepflags for no decryption */
2580 word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT |
2581 HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
2582 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word);
2587 "failed to set wepflags=0x%04x, result=%d\n",
2594 /* Do we want to strip the FCS in monitor mode? */
2595 if ((msg->stripfcs.status == P80211ENUM_msgitem_status_data_ok) && (msg->stripfcs.data == P80211ENUM_truth_true)) {
2601 /* Do we want to truncate the packets? */
2602 if (msg->packet_trunc.status == P80211ENUM_msgitem_status_data_ok) {
2603 hw->sniff_truncate = msg->packet_trunc.data;
2605 hw->sniff_truncate = 0;
2608 /* Enable the port */
2609 result = hfa384x_drvr_enable(hw, 0);
2612 "failed to enable port for sniffing, result=%d\n",
2616 /* Enable monitor mode */
2617 result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE);
2620 "failed to enable monitor mode, result=%d\n",
2625 if (wlandev->netdev->type == ARPHRD_ETHER) {
2626 WLAN_LOG_INFO("monitor mode enabled\n");
2629 /* Set the driver state */
2630 /* Do we want the prism2 header? */
2631 if ((msg->prismheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->prismheader.data == P80211ENUM_truth_true)) {
2633 wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
2634 } else if ((msg->wlanheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->wlanheader.data == P80211ENUM_truth_true)) {
2636 wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
2638 wlandev->netdev->type = ARPHRD_IEEE80211;
2641 msg->resultcode.data = P80211ENUM_resultcode_success;
2646 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
2653 msg->resultcode.data = P80211ENUM_resultcode_refused;