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>
83 #if (WLAN_HOSTIF == WLAN_USB)
84 #include <linux/usb.h>
87 #if (WLAN_HOSTIF == WLAN_PCMCIA)
88 #include <pcmcia/version.h>
89 #include <pcmcia/cs_types.h>
90 #include <pcmcia/cs.h>
91 #include <pcmcia/cistpl.h>
92 #include <pcmcia/ds.h>
93 #include <pcmcia/cisreg.h>
96 #include "wlan_compat.h"
98 /*================================================================*/
99 /* Project Includes */
101 #include "p80211types.h"
102 #include "p80211hdr.h"
103 #include "p80211mgmt.h"
104 #include "p80211conv.h"
105 #include "p80211msg.h"
106 #include "p80211netdev.h"
107 #include "p80211metadef.h"
108 #include "p80211metastruct.h"
110 #include "prism2mgmt.h"
112 /*================================================================*/
113 /* Local Constants */
116 /*================================================================*/
119 /* Converts 802.11 format rate specifications to prism2 */
120 #define p80211rate_to_p2bit(n) ((((n)&~BIT7) == 2) ? BIT0 : \
121 (((n)&~BIT7) == 4) ? BIT1 : \
122 (((n)&~BIT7) == 11) ? BIT2 : \
123 (((n)&~BIT7) == 22) ? BIT3 : 0)
125 /*================================================================*/
129 /*================================================================*/
130 /* Local Static Definitions */
133 /*================================================================*/
134 /* Local Function Declarations */
137 /*================================================================*/
138 /* Function Definitions */
141 /*----------------------------------------------------------------
142 * prism2mgmt_powermgmt
144 * Set the power management state of this station's MAC.
147 * wlandev wlan device structure
148 * msgp ptr to msg buffer
152 * <0 success, but we're waiting for something to finish.
153 * >0 an error occurred while handling the message.
157 * process thread (usually)
159 ----------------------------------------------------------------*/
160 int prism2mgmt_powermgmt(wlandevice_t *wlandev, void *msgp)
163 hfa384x_t *hw = wlandev->priv;
164 p80211msg_dot11req_powermgmt_t *msg = msgp;
173 * Set CNFPMENABLED (on or off)
174 * Set CNFMULTICASTRX (if PM on, otherwise clear)
175 * Spout a notice stating that SleepDuration and
176 * HoldoverDuration and PMEPS also have an impact.
178 /* Powermgmt is currently unsupported for STA */
179 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
180 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
183 /*** ACCESS POINT ***/
185 /* Powermgmt is never supported for AP */
186 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
187 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
195 /*----------------------------------------------------------------
198 * Initiate a scan for BSSs.
200 * This function corresponds to MLME-scan.request and part of
201 * MLME-scan.confirm. As far as I can tell in the standard, there
202 * are no restrictions on when a scan.request may be issued. We have
203 * to handle in whatever state the driver/MAC happen to be.
206 * wlandev wlan device structure
207 * msgp ptr to msg buffer
211 * <0 success, but we're waiting for something to finish.
212 * >0 an error occurred while handling the message.
216 * process thread (usually)
218 ----------------------------------------------------------------*/
219 int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
222 hfa384x_t *hw = wlandev->priv;
223 p80211msg_dot11req_scan_t *msg = msgp;
224 UINT16 roamingmode, word;
228 hfa384x_HostScanRequest_data_t scanreq;
233 WLAN_LOG_ERROR("Prism2 in AP mode cannot perform scans.\n");
235 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
239 /* gatekeeper check */
240 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
241 hw->ident_sta_fw.minor,
242 hw->ident_sta_fw.variant) <
243 HFA384x_FIRMWARE_VERSION(1,3,2)) {
244 WLAN_LOG_ERROR("HostScan not supported with current firmware (<1.3.2).\n");
246 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
250 memset(&scanreq, 0, sizeof(scanreq));
252 /* save current roaming mode */
253 result = hfa384x_drvr_getconfig16(hw,
254 HFA384x_RID_CNFROAMINGMODE, &roamingmode);
256 WLAN_LOG_ERROR("getconfig(ROAMMODE) failed. result=%d\n",
258 msg->resultcode.data =
259 P80211ENUM_resultcode_implementation_failure;
263 /* drop into mode 3 for the scan */
264 result = hfa384x_drvr_setconfig16(hw,
265 HFA384x_RID_CNFROAMINGMODE,
266 HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
268 WLAN_LOG_ERROR("setconfig(ROAMINGMODE) failed. result=%d\n",
270 msg->resultcode.data =
271 P80211ENUM_resultcode_implementation_failure;
275 /* active or passive? */
276 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
277 hw->ident_sta_fw.minor,
278 hw->ident_sta_fw.variant) >
279 HFA384x_FIRMWARE_VERSION(1,5,0)) {
280 if (msg->scantype.data != P80211ENUM_scantype_active) {
281 word = host2hfa384x_16(msg->maxchanneltime.data);
285 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL, word);
287 WLAN_LOG_WARNING("Passive scan not supported with "
288 "current firmware. (<1.5.1)\n");
292 /* set up the txrate to be 2MBPS. Should be fastest basicrate... */
293 word = HFA384x_RATEBIT_2;
294 scanreq.txRate = host2hfa384x_16(word);
296 /* set up the channel list */
298 for (i = 0; i < msg->channellist.data.len; i++) {
299 UINT8 channel = msg->channellist.data.data[i];
300 if (channel > 14) continue;
301 /* channel 1 is BIT0 ... channel 14 is BIT13 */
302 word |= (1 << (channel-1));
304 scanreq.channelList = host2hfa384x_16(word);
306 /* set up the ssid, if present. */
307 scanreq.ssid.len = host2hfa384x_16(msg->ssid.data.len);
308 memcpy(scanreq.ssid.data, msg->ssid.data.data, msg->ssid.data.len);
310 /* Enable the MAC port if it's not already enabled */
311 result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word);
313 WLAN_LOG_ERROR("getconfig(PORTSTATUS) failed. "
314 "result=%d\n", result);
315 msg->resultcode.data =
316 P80211ENUM_resultcode_implementation_failure;
319 if (word == HFA384x_PORTSTATUS_DISABLED) {
322 result = hfa384x_drvr_setconfig16(hw,
323 HFA384x_RID_CNFROAMINGMODE,
324 HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
326 WLAN_LOG_ERROR("setconfig(ROAMINGMODE) failed. result=%d\n", result);
327 msg->resultcode.data =
328 P80211ENUM_resultcode_implementation_failure;
331 /* Construct a bogus SSID and assign it to OwnSSID and
334 wordbuf[0] = host2hfa384x_16(WLAN_SSID_MAXLEN);
335 get_random_bytes(&wordbuf[1], WLAN_SSID_MAXLEN);
336 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
337 wordbuf, HFA384x_RID_CNFOWNSSID_LEN);
339 WLAN_LOG_ERROR("Failed to set OwnSSID.\n");
340 msg->resultcode.data =
341 P80211ENUM_resultcode_implementation_failure;
344 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID,
345 wordbuf, HFA384x_RID_CNFDESIREDSSID_LEN);
347 WLAN_LOG_ERROR("Failed to set DesiredSSID.\n");
348 msg->resultcode.data =
349 P80211ENUM_resultcode_implementation_failure;
353 result = hfa384x_drvr_setconfig16(hw,
354 HFA384x_RID_CNFPORTTYPE,
355 HFA384x_PORTTYPE_IBSS);
357 WLAN_LOG_ERROR("Failed to set CNFPORTTYPE.\n");
358 msg->resultcode.data =
359 P80211ENUM_resultcode_implementation_failure;
363 result = hfa384x_drvr_setconfig16(hw,
364 HFA384x_RID_CREATEIBSS,
365 HFA384x_CREATEIBSS_JOINCREATEIBSS);
367 WLAN_LOG_ERROR("Failed to set CREATEIBSS.\n");
368 msg->resultcode.data =
369 P80211ENUM_resultcode_implementation_failure;
372 result = hfa384x_drvr_enable(hw, 0);
374 WLAN_LOG_ERROR("drvr_enable(0) failed. "
375 "result=%d\n", result);
376 msg->resultcode.data =
377 P80211ENUM_resultcode_implementation_failure;
383 /* Figure out our timeout first Kus, then HZ */
384 timeout = msg->channellist.data.len * msg->maxchanneltime.data;
385 timeout = (timeout * HZ)/1000;
387 /* Issue the scan request */
390 WLAN_HEX_DUMP(5,"hscanreq", &scanreq, sizeof(scanreq));
392 result = hfa384x_drvr_setconfig( hw,
393 HFA384x_RID_HOSTSCAN, &scanreq,
394 sizeof(hfa384x_HostScanRequest_data_t));
396 WLAN_LOG_ERROR("setconfig(SCANREQUEST) failed. result=%d\n",
398 msg->resultcode.data =
399 P80211ENUM_resultcode_implementation_failure;
403 /* sleep until info frame arrives */
404 wait_event_interruptible_timeout(hw->cmdq, hw->scanflag, timeout);
406 msg->numbss.status = P80211ENUM_msgitem_status_data_ok;
407 if (hw->scanflag == -1)
410 msg->numbss.data = hw->scanflag;
414 /* Disable port if we temporarily enabled it. */
416 result = hfa384x_drvr_disable(hw, 0);
418 WLAN_LOG_ERROR("drvr_disable(0) failed. "
419 "result=%d\n", result);
420 msg->resultcode.data =
421 P80211ENUM_resultcode_implementation_failure;
426 /* restore original roaming mode */
427 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE,
430 WLAN_LOG_ERROR("setconfig(ROAMMODE) failed. result=%d\n",
432 msg->resultcode.data =
433 P80211ENUM_resultcode_implementation_failure;
438 msg->resultcode.data = P80211ENUM_resultcode_success;
441 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
448 /*----------------------------------------------------------------
449 * prism2mgmt_scan_results
451 * Retrieve the BSS description for one of the BSSs identified in
455 * wlandev wlan device structure
456 * msgp ptr to msg buffer
460 * <0 success, but we're waiting for something to finish.
461 * >0 an error occurred while handling the message.
465 * process thread (usually)
467 ----------------------------------------------------------------*/
468 int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
471 p80211msg_dot11req_scan_results_t *req;
472 hfa384x_t *hw = wlandev->priv;
473 hfa384x_HScanResultSub_t *item = NULL;
479 req = (p80211msg_dot11req_scan_results_t *) msgp;
481 req->resultcode.status = P80211ENUM_msgitem_status_data_ok;
485 req->resultcode.data = P80211ENUM_resultcode_not_supported;
489 if (! hw->scanresults) {
490 WLAN_LOG_ERROR("dot11req_scan_results can only be used after a successful dot11req_scan.\n");
492 req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
496 count = (hw->scanresults->framelen - 3) / 32;
497 if (count > 32) count = 32;
499 if (req->bssindex.data >= count) {
500 WLAN_LOG_DEBUG(0, "requested index (%d) out of range (%d)\n",
501 req->bssindex.data, count);
503 req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
507 item = &(hw->scanresults->info.hscanresult.result[req->bssindex.data]);
508 /* signal and noise */
509 req->signal.status = P80211ENUM_msgitem_status_data_ok;
510 req->noise.status = P80211ENUM_msgitem_status_data_ok;
511 req->signal.data = hfa384x2host_16(item->sl);
512 req->noise.data = hfa384x2host_16(item->anl);
515 req->bssid.status = P80211ENUM_msgitem_status_data_ok;
516 req->bssid.data.len = WLAN_BSSID_LEN;
517 memcpy(req->bssid.data.data, item->bssid, WLAN_BSSID_LEN);
520 req->ssid.status = P80211ENUM_msgitem_status_data_ok;
521 req->ssid.data.len = hfa384x2host_16(item->ssid.len);
522 memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len);
524 /* supported rates */
525 for (count = 0; count < 10 ; count++)
526 if (item->supprates[count] == 0)
529 #define REQBASICRATE(N) \
530 if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \
531 req->basicrate ## N .data = item->supprates[(N)-1]; \
532 req->basicrate ## N .status = P80211ENUM_msgitem_status_data_ok; \
544 #define REQSUPPRATE(N) \
546 req->supprate ## N .data = item->supprates[(N)-1]; \
547 req->supprate ## N .status = P80211ENUM_msgitem_status_data_ok; \
560 req->beaconperiod.status = P80211ENUM_msgitem_status_data_ok;
561 req->beaconperiod.data = hfa384x2host_16(item->bcnint);
564 req->timestamp.status = P80211ENUM_msgitem_status_data_ok;
565 req->timestamp.data = jiffies;
566 req->localtime.status = P80211ENUM_msgitem_status_data_ok;
567 req->localtime.data = jiffies;
570 req->ibssatimwindow.status = P80211ENUM_msgitem_status_data_ok;
571 req->ibssatimwindow.data = hfa384x2host_16(item->atim);
574 req->dschannel.status = P80211ENUM_msgitem_status_data_ok;
575 req->dschannel.data = hfa384x2host_16(item->chid);
578 count = hfa384x2host_16(item->capinfo);
581 req->privacy.status = P80211ENUM_msgitem_status_data_ok;
582 req->privacy.data = WLAN_GET_MGMT_CAP_INFO_PRIVACY(count);
585 req->cfpollable.status = P80211ENUM_msgitem_status_data_ok;
586 req->cfpollable.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(count);
589 req->cfpollreq.status = P80211ENUM_msgitem_status_data_ok;
590 req->cfpollreq.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(count);
593 req->bsstype.status = P80211ENUM_msgitem_status_data_ok;
594 req->bsstype.data = (WLAN_GET_MGMT_CAP_INFO_ESS(count)) ?
595 P80211ENUM_bsstype_infrastructure :
596 P80211ENUM_bsstype_independent;
598 // item->proberesp_rate
608 req->resultcode.data = P80211ENUM_resultcode_success;
616 /*----------------------------------------------------------------
619 * Join a BSS whose BSS description was previously obtained with
623 * wlandev wlan device structure
624 * msgp ptr to msg buffer
628 * <0 success, but we're waiting for something to finish.
629 * >0 an error occurred while handling the message.
633 * process thread (usually)
635 ----------------------------------------------------------------*/
636 int prism2mgmt_join(wlandevice_t *wlandev, void *msgp)
639 hfa384x_t *hw = wlandev->priv;
640 p80211msg_dot11req_join_t *msg = msgp;
647 /* TODO: Implement after scan */
648 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
649 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
652 /*** ACCESS POINT ***/
654 /* Never supported by APs */
655 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
656 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
664 /*----------------------------------------------------------------
667 * Join a specific BSS
670 * wlandev wlan device structure
671 * msgp ptr to msg buffer
675 * <0 success, but we're waiting for something to finish.
676 * >0 an error occurred while handling the message.
680 * process thread (usually)
682 ----------------------------------------------------------------*/
683 int prism2mgmt_p2_join(wlandevice_t *wlandev, void *msgp)
686 hfa384x_t *hw = wlandev->priv;
687 p80211msg_p2req_join_t *msg = msgp;
691 hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
692 hfa384x_JoinRequest_data_t joinreq;
697 wlandev->macmode = WLAN_MACMODE_NONE;
700 /* Set the PortType */
701 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
702 msg->resultcode.data = P80211ENUM_resultcode_success;
705 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 1);
707 WLAN_LOG_ERROR("Failed to set Port Type\n");
711 /* Set the auth type */
712 if ( msg->authtype.data == P80211ENUM_authalg_sharedkey ) {
713 reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY;
715 reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM;
717 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, reg);
719 WLAN_LOG_ERROR("Failed to set Authentication\n");
723 /* Turn off all roaming */
724 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, 3);
726 WLAN_LOG_ERROR("Failed to Turn off Roaming\n");
732 if ( msg->basicrate1.status == P80211ENUM_msgitem_status_data_ok ) {
733 reg = p80211rate_to_p2bit(msg->basicrate1.data);
735 if ( msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok ) {
736 reg |= p80211rate_to_p2bit(msg->basicrate2.data);
738 if ( msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok ) {
739 reg |= p80211rate_to_p2bit(msg->basicrate3.data);
741 if ( msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok ) {
742 reg |= p80211rate_to_p2bit(msg->basicrate4.data);
744 if ( msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok ) {
745 reg |= p80211rate_to_p2bit(msg->basicrate5.data);
747 if ( msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok ) {
748 reg |= p80211rate_to_p2bit(msg->basicrate6.data);
750 if ( msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok ) {
751 reg |= p80211rate_to_p2bit(msg->basicrate7.data);
753 if ( msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok ) {
754 reg |= p80211rate_to_p2bit(msg->basicrate8.data);
758 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, reg);
760 WLAN_LOG_ERROR("Failed to set basicrates=%d.\n", reg);
764 /* Operational rates (supprates and txratecontrol) */
766 if ( msg->operationalrate1.status == P80211ENUM_msgitem_status_data_ok ) {
767 reg = p80211rate_to_p2bit(msg->operationalrate1.data);
769 if ( msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok ) {
770 reg |= p80211rate_to_p2bit(msg->operationalrate2.data);
772 if ( msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok ) {
773 reg |= p80211rate_to_p2bit(msg->operationalrate3.data);
775 if ( msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok ) {
776 reg |= p80211rate_to_p2bit(msg->operationalrate4.data);
778 if ( msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok ) {
779 reg |= p80211rate_to_p2bit(msg->operationalrate5.data);
781 if ( msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok ) {
782 reg |= p80211rate_to_p2bit(msg->operationalrate6.data);
784 if ( msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok ) {
785 reg |= p80211rate_to_p2bit(msg->operationalrate7.data);
787 if ( msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok ) {
788 reg |= p80211rate_to_p2bit(msg->operationalrate8.data);
792 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, reg);
794 WLAN_LOG_ERROR("Failed to set supprates=%d.\n", reg);
798 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, reg);
800 WLAN_LOG_ERROR("Failed to set txrates=%d.\n", reg);
805 memset(bytebuf, 0, 256);
806 pstr = (p80211pstrd_t*)&(msg->ssid.data);
807 prism2mgmt_pstr2bytestr(p2bytestr, pstr);
808 result = hfa384x_drvr_setconfig(
809 hw, HFA384x_RID_CNFDESIREDSSID,
810 bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
812 WLAN_LOG_ERROR("Failed to set SSID\n");
816 /* Enable the Port */
817 result = hfa384x_cmd_enable(hw, 0);
819 WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result);
823 /* Fill in the join request */
824 joinreq.channel = msg->channel.data;
825 memcpy( joinreq.bssid, ((unsigned char *) &msg->bssid.data) + 1, WLAN_BSSID_LEN);
826 hw->joinreq = joinreq;
829 /* Send the join request */
830 result = hfa384x_drvr_setconfig( hw,
831 HFA384x_RID_JOINREQUEST,
832 &joinreq, HFA384x_RID_JOINREQUEST_LEN);
834 WLAN_LOG_ERROR("Join request failed, result=%d.\n", result);
840 /*** ACCESS POINT ***/
842 /* Never supported by APs */
843 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
844 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
849 WLAN_LOG_DEBUG(1, "Failed to set a config option, result=%d\n", result);
850 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
860 /*----------------------------------------------------------------
861 * prism2mgmt_authenticate
863 * Station should be begin an authentication exchange.
866 * wlandev wlan device structure
867 * msgp ptr to msg buffer
871 * <0 success, but we're waiting for something to finish.
872 * >0 an error occurred while handling the message.
876 * process thread (usually)
878 ----------------------------------------------------------------*/
879 int prism2mgmt_authenticate(wlandevice_t *wlandev, void *msgp)
882 hfa384x_t *hw = wlandev->priv;
883 p80211msg_dot11req_authenticate_t *msg = msgp;
890 /* TODO: Decide how we're going to handle this one w/ Prism2 */
891 /* It could be entertaining since Prism2 doesn't have */
892 /* an explicit way to control this */
893 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
894 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
897 /*** ACCESS POINT ***/
899 /* Never supported by APs */
900 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
901 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
909 /*----------------------------------------------------------------
910 * prism2mgmt_deauthenticate
912 * Send a deauthenticate notification.
915 * wlandev wlan device structure
916 * msgp ptr to msg buffer
920 * <0 success, but we're waiting for something to finish.
921 * >0 an error occurred while handling the message.
925 * process thread (usually)
927 ----------------------------------------------------------------*/
928 int prism2mgmt_deauthenticate(wlandevice_t *wlandev, void *msgp)
931 hfa384x_t *hw = wlandev->priv;
932 p80211msg_dot11req_deauthenticate_t *msg = msgp;
939 /* TODO: Decide how we're going to handle this one w/ Prism2 */
940 /* It could be entertaining since Prism2 doesn't have */
941 /* an explicit way to control this */
942 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
943 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
946 /*** ACCESS POINT ***/
947 hfa384x_drvr_handover(hw, msg->peerstaaddress.data.data);
948 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
949 msg->resultcode.data = P80211ENUM_resultcode_success;
957 /*----------------------------------------------------------------
958 * prism2mgmt_associate
960 * Associate with an ESS.
963 * wlandev wlan device structure
964 * msgp ptr to msg buffer
968 * <0 success, but we're waiting for something to finish.
969 * >0 an error occurred while handling the message.
973 * process thread (usually)
975 ----------------------------------------------------------------*/
976 int prism2mgmt_associate(wlandevice_t *wlandev, void *msgp)
978 hfa384x_t *hw = wlandev->priv;
980 p80211msg_dot11req_associate_t *msg = msgp;
988 /* Set the TxRates */
990 hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, reg);
993 /* Set the PortType */
995 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 1);
997 /* Enable the Port */
998 hfa384x_drvr_enable(hw, 0);
1000 /* Set the resultcode */
1001 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1002 msg->resultcode.data = P80211ENUM_resultcode_success;
1006 /*** ACCESS POINT ***/
1008 /* Never supported on AP */
1009 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1010 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1018 /*----------------------------------------------------------------
1019 * prism2mgmt_reassociate
1021 * Renew association because of a BSS change.
1024 * wlandev wlan device structure
1025 * msgp ptr to msg buffer
1028 * 0 success and done
1029 * <0 success, but we're waiting for something to finish.
1030 * >0 an error occurred while handling the message.
1034 * process thread (usually)
1036 ----------------------------------------------------------------*/
1037 int prism2mgmt_reassociate(wlandevice_t *wlandev, void *msgp)
1040 hfa384x_t *hw = wlandev->priv;
1041 p80211msg_dot11req_reassociate_t *msg = msgp;
1048 /* TODO: Not supported yet...not sure how we're going to do it */
1049 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1050 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1053 /*** ACCESS POINT ***/
1055 /* Never supported on AP */
1056 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1057 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1065 /*----------------------------------------------------------------
1066 * prism2mgmt_disassociate
1068 * Send a disassociation notification.
1071 * wlandev wlan device structure
1072 * msgp ptr to msg buffer
1075 * 0 success and done
1076 * <0 success, but we're waiting for something to finish.
1077 * >0 an error occurred while handling the message.
1081 * process thread (usually)
1083 ----------------------------------------------------------------*/
1084 int prism2mgmt_disassociate(wlandevice_t *wlandev, void *msgp)
1087 hfa384x_t *hw = wlandev->priv;
1088 p80211msg_dot11req_disassociate_t *msg = msgp;
1095 /* TODO: Not supported yet...not sure how to do it */
1096 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1097 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1100 /*** ACCESS POINT ***/
1101 hfa384x_drvr_handover(hw, msg->peerstaaddress.data.data);
1102 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1103 msg->resultcode.data = P80211ENUM_resultcode_success;
1111 /*----------------------------------------------------------------
1114 * Reset the MAC and MSD. The p80211 layer has it's own handling
1115 * that should be done before and after this function.
1117 * - disable system interrupts ??
1118 * - disable MAC interrupts
1119 * - restore system interrupts
1120 * - issue the MAC initialize command
1121 * - clear any MSD level state (including timers, queued events,
1122 * etc.). Note that if we're removing timer'd/queue events, we may
1123 * need to have remained in the system interrupt disabled state.
1124 * We should be left in the same state that we're in following
1125 * driver initialization.
1128 * wlandev wlan device structure
1129 * msgp ptr to msg buffer, MAY BE NULL! for a driver local
1133 * 0 success and done
1134 * <0 success, but we're waiting for something to finish.
1135 * >0 an error occurred while handling the message.
1139 * process thread, commonly wlanctl, but might be rmmod/pci_close.
1140 ----------------------------------------------------------------*/
1141 int prism2mgmt_reset(wlandevice_t *wlandev, void *msgp)
1144 hfa384x_t *hw = wlandev->priv;
1145 p80211msg_dot11req_reset_t *msg = msgp;
1149 * This is supported on both AP and STA and it's not allowed
1153 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1154 msg->resultcode.data = P80211ENUM_resultcode_success;
1155 WLAN_LOG_INFO("dot11req_reset: the macaddress and "
1156 "setdefaultmib arguments are currently unsupported.\n");
1160 * If we got this far, the MSD must be in the MSDRUNNING state
1161 * therefore, we must stop and then restart the hw/MAC combo.
1163 hfa384x_drvr_stop(hw);
1164 result = hfa384x_drvr_start(hw);
1166 WLAN_LOG_ERROR("dot11req_reset: Initialize command failed,"
1167 " bad things will happen from here.\n");
1176 /*----------------------------------------------------------------
1179 * Start a BSS. Any station can do this for IBSS, only AP for ESS.
1182 * wlandev wlan device structure
1183 * msgp ptr to msg buffer
1186 * 0 success and done
1187 * <0 success, but we're waiting for something to finish.
1188 * >0 an error occurred while handling the message.
1192 * process thread (usually)
1194 ----------------------------------------------------------------*/
1195 int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
1198 hfa384x_t *hw = wlandev->priv;
1199 p80211msg_dot11req_start_t *msg = msgp;
1201 p80211pstrd_t *pstr;
1203 hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
1204 hfa384x_PCFInfo_data_t *pcfinfo = (hfa384x_PCFInfo_data_t*)bytebuf;
1208 wlandev->macmode = WLAN_MACMODE_NONE;
1211 memcpy(&wlandev->ssid, &msg->ssid.data, sizeof(msg->ssid.data));
1214 /*** ADHOC IBSS ***/
1215 /* see if current f/w is less than 8c3 */
1216 if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
1217 hw->ident_sta_fw.minor,
1218 hw->ident_sta_fw.variant) <
1219 HFA384x_FIRMWARE_VERSION(0,8,3)) {
1220 /* Ad-Hoc not quite supported on Prism2 */
1221 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1222 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1226 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1229 /* Set the REQUIRED config items */
1231 pstr = (p80211pstrd_t*)&(msg->ssid.data);
1232 prism2mgmt_pstr2bytestr(p2bytestr, pstr);
1233 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
1234 bytebuf, HFA384x_RID_CNFOWNSSID_LEN);
1236 WLAN_LOG_ERROR("Failed to set CnfOwnSSID\n");
1239 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID,
1240 bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
1242 WLAN_LOG_ERROR("Failed to set CnfDesiredSSID\n");
1246 /* bsstype - we use the default in the ap firmware */
1248 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 0);
1251 word = msg->beaconperiod.data;
1252 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNINT, word);
1254 WLAN_LOG_ERROR("Failed to set beacon period=%d.\n", word);
1259 word = msg->dschannel.data;
1260 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word);
1262 WLAN_LOG_ERROR("Failed to set channel=%d.\n", word);
1266 word = p80211rate_to_p2bit(msg->basicrate1.data);
1267 if ( msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok ) {
1268 word |= p80211rate_to_p2bit(msg->basicrate2.data);
1270 if ( msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok ) {
1271 word |= p80211rate_to_p2bit(msg->basicrate3.data);
1273 if ( msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok ) {
1274 word |= p80211rate_to_p2bit(msg->basicrate4.data);
1276 if ( msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok ) {
1277 word |= p80211rate_to_p2bit(msg->basicrate5.data);
1279 if ( msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok ) {
1280 word |= p80211rate_to_p2bit(msg->basicrate6.data);
1282 if ( msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok ) {
1283 word |= p80211rate_to_p2bit(msg->basicrate7.data);
1285 if ( msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok ) {
1286 word |= p80211rate_to_p2bit(msg->basicrate8.data);
1288 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word);
1290 WLAN_LOG_ERROR("Failed to set basicrates=%d.\n", word);
1294 /* Operational rates (supprates and txratecontrol) */
1295 word = p80211rate_to_p2bit(msg->operationalrate1.data);
1296 if ( msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok ) {
1297 word |= p80211rate_to_p2bit(msg->operationalrate2.data);
1299 if ( msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok ) {
1300 word |= p80211rate_to_p2bit(msg->operationalrate3.data);
1302 if ( msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok ) {
1303 word |= p80211rate_to_p2bit(msg->operationalrate4.data);
1305 if ( msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok ) {
1306 word |= p80211rate_to_p2bit(msg->operationalrate5.data);
1308 if ( msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok ) {
1309 word |= p80211rate_to_p2bit(msg->operationalrate6.data);
1311 if ( msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok ) {
1312 word |= p80211rate_to_p2bit(msg->operationalrate7.data);
1314 if ( msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok ) {
1315 word |= p80211rate_to_p2bit(msg->operationalrate8.data);
1317 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word);
1319 WLAN_LOG_ERROR("Failed to set supprates=%d.\n", word);
1323 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word);
1325 WLAN_LOG_ERROR("Failed to set txrates=%d.\n", word);
1329 /* Set the macmode so the frame setup code knows what to do */
1330 if ( msg->bsstype.data == P80211ENUM_bsstype_independent ) {
1331 wlandev->macmode = WLAN_MACMODE_IBSS_STA;
1332 /* lets extend the data length a bit */
1333 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304);
1336 /* Enable the Port */
1337 result = hfa384x_drvr_enable(hw, 0);
1339 WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result);
1343 msg->resultcode.data = P80211ENUM_resultcode_success;
1348 /*** ACCESS POINT ***/
1350 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1352 /* Validate the command, if BSStype=infra is the tertiary loaded? */
1353 if ( msg->bsstype.data == P80211ENUM_bsstype_independent ) {
1354 WLAN_LOG_ERROR("AP driver cannot create IBSS.\n");
1356 } else if ( hw->cap_sup_sta.id != 5) {
1357 WLAN_LOG_ERROR("AP driver failed to detect AP firmware.\n");
1361 /* Set the REQUIRED config items */
1363 pstr = (p80211pstrd_t*)&(msg->ssid.data);
1364 prism2mgmt_pstr2bytestr(p2bytestr, pstr);
1365 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
1366 bytebuf, HFA384x_RID_CNFOWNSSID_LEN);
1368 WLAN_LOG_ERROR("Failed to set SSID, result=0x%04x\n", result);
1372 /* bsstype - we use the default in the ap firmware */
1375 word = msg->beaconperiod.data;
1376 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNINT, word);
1378 WLAN_LOG_ERROR("Failed to set beacon period=%d.\n", word);
1383 word = msg->dschannel.data;
1384 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word);
1386 WLAN_LOG_ERROR("Failed to set channel=%d.\n", word);
1390 word = p80211rate_to_p2bit(msg->basicrate1.data);
1391 if ( msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok ) {
1392 word |= p80211rate_to_p2bit(msg->basicrate2.data);
1394 if ( msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok ) {
1395 word |= p80211rate_to_p2bit(msg->basicrate3.data);
1397 if ( msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok ) {
1398 word |= p80211rate_to_p2bit(msg->basicrate4.data);
1400 if ( msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok ) {
1401 word |= p80211rate_to_p2bit(msg->basicrate5.data);
1403 if ( msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok ) {
1404 word |= p80211rate_to_p2bit(msg->basicrate6.data);
1406 if ( msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok ) {
1407 word |= p80211rate_to_p2bit(msg->basicrate7.data);
1409 if ( msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok ) {
1410 word |= p80211rate_to_p2bit(msg->basicrate8.data);
1412 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word);
1414 WLAN_LOG_ERROR("Failed to set basicrates=%d.\n", word);
1418 /* Operational rates (supprates and txratecontrol) */
1419 word = p80211rate_to_p2bit(msg->operationalrate1.data);
1420 if ( msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok ) {
1421 word |= p80211rate_to_p2bit(msg->operationalrate2.data);
1423 if ( msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok ) {
1424 word |= p80211rate_to_p2bit(msg->operationalrate3.data);
1426 if ( msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok ) {
1427 word |= p80211rate_to_p2bit(msg->operationalrate4.data);
1429 if ( msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok ) {
1430 word |= p80211rate_to_p2bit(msg->operationalrate5.data);
1432 if ( msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok ) {
1433 word |= p80211rate_to_p2bit(msg->operationalrate6.data);
1435 if ( msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok ) {
1436 word |= p80211rate_to_p2bit(msg->operationalrate7.data);
1438 if ( msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok ) {
1439 word |= p80211rate_to_p2bit(msg->operationalrate8.data);
1441 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word);
1443 WLAN_LOG_ERROR("Failed to set supprates=%d.\n", word);
1446 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL0, word);
1448 WLAN_LOG_ERROR("Failed to set txrates=%d.\n", word);
1452 /* ibssatimwindow */
1453 if (msg->ibssatimwindow.status == P80211ENUM_msgitem_status_data_ok) {
1454 WLAN_LOG_INFO("prism2mgmt_start: atimwindow not used in "
1455 "Infrastructure mode, ignored.\n");
1459 word = msg->dtimperiod.data;
1460 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNDTIMPER, word);
1462 WLAN_LOG_ERROR("Failed to set dtim period=%d.\n", word);
1467 if (msg->probedelay.status == P80211ENUM_msgitem_status_data_ok) {
1468 WLAN_LOG_INFO("prism2mgmt_start: probedelay not "
1469 "supported in prism2, ignored.\n");
1472 /* cfpollable, cfpollreq, cfpperiod, cfpmaxduration */
1473 if (msg->cfpollable.data == P80211ENUM_truth_true &&
1474 msg->cfpollreq.data == P80211ENUM_truth_true ) {
1475 WLAN_LOG_ERROR("cfpollable=cfpollreq=true is illegal.\n");
1480 /* read the PCFInfo and update */
1481 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFAPPCFINFO,
1482 pcfinfo, HFA384x_RID_CNFAPPCFINFO_LEN);
1484 WLAN_LOG_INFO("prism2mgmt_start: read(pcfinfo) failed, "
1486 "not supported, pcf settings ignored.\n");
1489 if ((msg->cfpollable.data == P80211ENUM_truth_false &&
1490 msg->cfpollreq.data == P80211ENUM_truth_false) ) {
1491 pcfinfo->MediumOccupancyLimit = 0;
1492 pcfinfo->CFPPeriod = 0;
1493 pcfinfo->CFPMaxDuration = 0;
1494 pcfinfo->CFPFlags &= host2hfa384x_16((UINT16)~BIT0);
1496 if ( msg->cfpperiod.status == P80211ENUM_msgitem_status_data_ok ||
1497 msg->cfpmaxduration.status == P80211ENUM_msgitem_status_data_ok ) {
1499 "Setting cfpperiod or cfpmaxduration when "
1500 "cfpollable and cfreq are false is pointless.\n");
1503 if ((msg->cfpollable.data == P80211ENUM_truth_true ||
1504 msg->cfpollreq.data == P80211ENUM_truth_true) ) {
1505 if ( msg->cfpollable.data == P80211ENUM_truth_true) {
1506 pcfinfo->CFPFlags |= host2hfa384x_16((UINT16)BIT0);
1509 if ( msg->cfpperiod.status == P80211ENUM_msgitem_status_data_ok) {
1510 pcfinfo->CFPPeriod = msg->cfpperiod.data;
1511 pcfinfo->CFPPeriod = host2hfa384x_16(pcfinfo->CFPPeriod);
1514 if ( msg->cfpmaxduration.status == P80211ENUM_msgitem_status_data_ok) {
1515 pcfinfo->CFPMaxDuration = msg->cfpmaxduration.data;
1516 pcfinfo->CFPMaxDuration = host2hfa384x_16(pcfinfo->CFPMaxDuration);
1517 pcfinfo->MediumOccupancyLimit = pcfinfo->CFPMaxDuration;
1520 result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFAPPCFINFO,
1521 pcfinfo, HFA384x_RID_CNFAPPCFINFO_LEN);
1523 WLAN_LOG_ERROR("write(pcfinfo) failed.\n");
1528 /* Set the macmode so the frame setup code knows what to do */
1529 if ( msg->bsstype.data == P80211ENUM_bsstype_infrastructure ) {
1530 wlandev->macmode = WLAN_MACMODE_ESS_AP;
1531 /* lets extend the data length a bit */
1532 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304);
1535 /* Set the BSSID to the same as our MAC */
1536 memcpy( wlandev->bssid, wlandev->netdev->dev_addr, WLAN_BSSID_LEN);
1538 /* Enable the Port */
1539 result = hfa384x_drvr_enable(hw, 0);
1541 WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result);
1545 msg->resultcode.data = P80211ENUM_resultcode_success;
1549 WLAN_LOG_DEBUG(1, "Failed to set a config option, result=%d\n", result);
1550 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
1560 /*----------------------------------------------------------------
1563 * Start a BSS. Any station can do this for IBSS, only AP for ESS.
1566 * wlandev wlan device structure
1567 * msgp ptr to msg buffer
1570 * 0 success and done
1571 * <0 success, but we're waiting for something to finish.
1572 * >0 an error occurred while handling the message.
1576 * process thread (usually)
1578 ----------------------------------------------------------------*/
1579 int prism2mgmt_enable(wlandevice_t *wlandev, void *msgp)
1582 hfa384x_t *hw = wlandev->priv;
1583 p80211msg_p2req_enable_t *msg = msgp;
1590 /* Ad-Hoc not quite supported on Prism2 */
1591 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1592 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1596 /*** ACCESS POINT ***/
1598 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1600 /* Is the tertiary loaded? */
1601 if ( hw->cap_sup_sta.id != 5) {
1602 WLAN_LOG_ERROR("AP driver failed to detect AP firmware.\n");
1606 /* Set the macmode so the frame setup code knows what to do */
1607 wlandev->macmode = WLAN_MACMODE_ESS_AP;
1609 /* Set the BSSID to the same as our MAC */
1610 memcpy( wlandev->bssid, wlandev->netdev->dev_addr, WLAN_BSSID_LEN);
1612 /* Enable the Port */
1613 result = hfa384x_drvr_enable(hw, 0);
1615 WLAN_LOG_ERROR("Enable macport failed, result=%d.\n", result);
1619 msg->resultcode.data = P80211ENUM_resultcode_success;
1623 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
1633 /*----------------------------------------------------------------
1634 * prism2mgmt_readpda
1636 * Collect the PDA data and put it in the message.
1639 * wlandev wlan device structure
1640 * msgp ptr to msg buffer
1643 * 0 success and done
1644 * <0 success, but we're waiting for something to finish.
1645 * >0 an error occurred while handling the message.
1649 * process thread (usually)
1650 ----------------------------------------------------------------*/
1651 int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp)
1653 hfa384x_t *hw = wlandev->priv;
1654 p80211msg_p2req_readpda_t *msg = msgp;
1658 /* We only support collecting the PDA when in the FWLOAD
1661 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
1663 "PDA may only be read "
1664 "in the fwload state.\n");
1665 msg->resultcode.data =
1666 P80211ENUM_resultcode_implementation_failure;
1667 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1669 /* Call drvr_readpda(), it handles the auxport enable
1670 * and validating the returned PDA.
1672 result = hfa384x_drvr_readpda(
1675 HFA384x_PDA_LEN_MAX);
1678 "hfa384x_drvr_readpda() failed, "
1682 msg->resultcode.data =
1683 P80211ENUM_resultcode_implementation_failure;
1684 msg->resultcode.status =
1685 P80211ENUM_msgitem_status_data_ok;
1689 msg->pda.status = P80211ENUM_msgitem_status_data_ok;
1690 msg->resultcode.data = P80211ENUM_resultcode_success;
1691 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1698 /*----------------------------------------------------------------
1699 * prism2mgmt_readcis
1701 * Collect the CIS data and put it in the message.
1704 * wlandev wlan device structure
1705 * msgp ptr to msg buffer
1708 * 0 success and done
1709 * <0 success, but we're waiting for something to finish.
1710 * >0 an error occurred while handling the message.
1714 * process thread (usually)
1715 ----------------------------------------------------------------*/
1716 int prism2mgmt_readcis(wlandevice_t *wlandev, void *msgp)
1719 hfa384x_t *hw = wlandev->priv;
1720 p80211msg_p2req_readcis_t *msg = msgp;
1724 memset(msg->cis.data, 0, sizeof(msg->cis.data));
1726 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CIS,
1727 msg->cis.data, HFA384x_RID_CIS_LEN);
1729 WLAN_LOG_INFO("prism2mgmt_readcis: read(cis) failed.\n");
1730 msg->cis.status = P80211ENUM_msgitem_status_no_value;
1731 msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
1735 msg->cis.status = P80211ENUM_msgitem_status_data_ok;
1736 msg->resultcode.data = P80211ENUM_resultcode_success;
1739 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1745 /*----------------------------------------------------------------
1746 * prism2mgmt_auxport_state
1748 * Enables/Disables the card's auxiliary port. Should be called
1749 * before and after a sequence of auxport_read()/auxport_write()
1753 * wlandev wlan device structure
1754 * msgp ptr to msg buffer
1757 * 0 success and done
1758 * <0 success, but we're waiting for something to finish.
1759 * >0 an error occurred while handling the message.
1763 * process thread (usually)
1764 ----------------------------------------------------------------*/
1765 int prism2mgmt_auxport_state(wlandevice_t *wlandev, void *msgp)
1767 p80211msg_p2req_auxport_state_t *msg = msgp;
1769 #if (WLAN_HOSTIF != WLAN_USB)
1770 hfa384x_t *hw = wlandev->priv;
1773 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1774 if (msg->enable.data == P80211ENUM_truth_true) {
1775 if ( hfa384x_cmd_aux_enable(hw, 0) ) {
1776 msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
1778 msg->resultcode.data = P80211ENUM_resultcode_success;
1781 hfa384x_cmd_aux_disable(hw);
1782 msg->resultcode.data = P80211ENUM_resultcode_success;
1788 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1789 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
1791 #endif /* WLAN_HOSTIF != WLAN_USB */
1798 /*----------------------------------------------------------------
1799 * prism2mgmt_auxport_read
1801 * Copies data from 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_read(wlandevice_t *wlandev, void *msgp)
1820 #if (WLAN_HOSTIF != WLAN_USB)
1821 hfa384x_t *hw = wlandev->priv;
1822 p80211msg_p2req_auxport_read_t *msg = msgp;
1826 UINT32 maxlen = sizeof(msg->data.data);
1830 addr = msg->addr.data;
1831 len = msg->len.data;
1832 buf = msg->data.data;
1833 if ( len <= maxlen ) { /* max read/write size */
1834 hfa384x_copy_from_aux(hw, addr, HFA384x_AUX_CTL_EXTDS, buf, len);
1835 msg->resultcode.data = P80211ENUM_resultcode_success;
1837 WLAN_LOG_DEBUG(1,"Attempt to read > maxlen from auxport.\n");
1838 msg->resultcode.data = P80211ENUM_resultcode_refused;
1842 msg->resultcode.data = P80211ENUM_resultcode_refused;
1844 msg->data.status = P80211ENUM_msgitem_status_data_ok;
1845 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1852 WLAN_LOG_ERROR("prism2mgmt_auxport_read: Not supported on USB.\n");
1860 /*----------------------------------------------------------------
1861 * prism2mgmt_auxport_write
1863 * Copies data to the card using the auxport. The auxport must
1864 * have previously been enabled. Note: this is not the way to
1865 * do downloads, see the [ram|flash]dl functions.
1868 * wlandev wlan device structure
1869 * msgp ptr to msg buffer
1872 * 0 success and done
1873 * <0 success, but we're waiting for something to finish.
1874 * >0 an error occurred while handling the message.
1878 * process thread (usually)
1879 ----------------------------------------------------------------*/
1880 int prism2mgmt_auxport_write(wlandevice_t *wlandev, void *msgp)
1882 #if (WLAN_HOSTIF != WLAN_USB)
1883 hfa384x_t *hw = wlandev->priv;
1884 p80211msg_p2req_auxport_write_t *msg = msgp;
1888 UINT32 maxlen = sizeof(msg->data.data);
1892 addr = msg->addr.data;
1893 len = msg->len.data;
1894 buf = msg->data.data;
1895 if ( len <= maxlen ) { /* max read/write size */
1896 hfa384x_copy_to_aux(hw, addr, HFA384x_AUX_CTL_EXTDS, buf, len);
1898 WLAN_LOG_DEBUG(1,"Attempt to write > maxlen from auxport.\n");
1899 msg->resultcode.data = P80211ENUM_resultcode_refused;
1903 msg->resultcode.data = P80211ENUM_resultcode_refused;
1905 msg->data.status = P80211ENUM_msgitem_status_data_ok;
1906 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1912 WLAN_LOG_ERROR("prism2mgmt_auxport_read: Not supported on USB.\n");
1918 /*----------------------------------------------------------------
1919 * prism2mgmt_low_level
1921 * Puts the card into the desired test mode.
1924 * wlandev wlan device structure
1925 * msgp ptr to msg buffer
1928 * 0 success and done
1929 * <0 success, but we're waiting for something to finish.
1930 * >0 an error occurred while handling the message.
1934 * process thread (usually)
1935 ----------------------------------------------------------------*/
1936 int prism2mgmt_low_level(wlandevice_t *wlandev, void *msgp)
1938 hfa384x_t *hw = wlandev->priv;
1939 p80211msg_p2req_low_level_t *msg = msgp;
1940 hfa384x_metacmd_t cmd;
1943 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1945 /* call some routine to execute the test command */
1946 cmd.cmd = (UINT16) msg->command.data;
1947 cmd.parm0 = (UINT16) msg->param0.data;
1948 cmd.parm1 = (UINT16) msg->param1.data;
1949 cmd.parm2 = (UINT16) msg->param2.data;
1951 hfa384x_drvr_low_level(hw,&cmd);
1953 msg->resp0.data = (UINT32) cmd.result.resp0;
1954 msg->resp1.data = (UINT32) cmd.result.resp1;
1955 msg->resp2.data = (UINT32) cmd.result.resp2;
1957 msg->resultcode.data = P80211ENUM_resultcode_success;
1963 /*----------------------------------------------------------------
1964 * prism2mgmt_test_command
1966 * Puts the card into the desired test mode.
1969 * wlandev wlan device structure
1970 * msgp ptr to msg buffer
1973 * 0 success and done
1974 * <0 success, but we're waiting for something to finish.
1975 * >0 an error occurred while handling the message.
1979 * process thread (usually)
1980 ----------------------------------------------------------------*/
1981 int prism2mgmt_test_command(wlandevice_t *wlandev, void *msgp)
1983 hfa384x_t *hw = wlandev->priv;
1984 p80211msg_p2req_test_command_t *msg = msgp;
1985 hfa384x_metacmd_t cmd;
1989 cmd.cmd = ((UINT16) msg->testcode.data) << 8 | 0x38;
1990 cmd.parm0 = (UINT16) msg->testparam.data;
1994 /* call some routine to execute the test command */
1996 hfa384x_drvr_low_level(hw,&cmd);
1998 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
1999 msg->resultcode.data = P80211ENUM_resultcode_success;
2001 msg->status.status = P80211ENUM_msgitem_status_data_ok;
2002 msg->status.data = cmd.result.status;
2003 msg->resp0.status = P80211ENUM_msgitem_status_data_ok;
2004 msg->resp0.data = cmd.result.resp0;
2005 msg->resp1.status = P80211ENUM_msgitem_status_data_ok;
2006 msg->resp1.data = cmd.result.resp1;
2007 msg->resp2.status = P80211ENUM_msgitem_status_data_ok;
2008 msg->resp2.data = cmd.result.resp2;
2015 /*----------------------------------------------------------------
2016 * prism2mgmt_mmi_read
2018 * Read from one of the MMI registers.
2021 * wlandev wlan device structure
2022 * msgp ptr to msg buffer
2025 * 0 success and done
2026 * <0 success, but we're waiting for something to finish.
2027 * >0 an error occurred while handling the message.
2031 * process thread (usually)
2032 ----------------------------------------------------------------*/
2033 int prism2mgmt_mmi_read(wlandevice_t *wlandev, void *msgp)
2035 hfa384x_t *hw = wlandev->priv;
2036 p80211msg_p2req_mmi_read_t *msg = msgp;
2041 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2043 /* call some routine to execute the test command */
2045 hfa384x_drvr_mmi_read(hw, msg->addr.data, &resp);
2047 /* I'm not sure if this is "architecturally" correct, but it
2050 msg->value.status = P80211ENUM_msgitem_status_data_ok;
2051 msg->value.data = resp;
2052 msg->resultcode.data = P80211ENUM_resultcode_success;
2058 /*----------------------------------------------------------------
2059 * prism2mgmt_mmi_write
2061 * Write a data value to one of the MMI registers.
2064 * wlandev wlan device structure
2065 * msgp ptr to msg buffer
2068 * 0 success and done
2069 * <0 success, but we're waiting for something to finish.
2070 * >0 an error occurred while handling the message.
2074 * process thread (usually)
2075 ----------------------------------------------------------------*/
2076 int prism2mgmt_mmi_write(wlandevice_t *wlandev, void *msgp)
2078 hfa384x_t *hw = wlandev->priv;
2079 p80211msg_p2req_mmi_write_t *msg = msgp;
2082 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2084 /* call some routine to execute the test command */
2086 hfa384x_drvr_mmi_write(hw, msg->addr.data, msg->data.data);
2088 msg->resultcode.data = P80211ENUM_resultcode_success;
2094 /*----------------------------------------------------------------
2095 * prism2mgmt_ramdl_state
2097 * Establishes the beginning/end of a card RAM download session.
2099 * It is expected that the ramdl_write() function will be called
2100 * one or more times between the 'enable' and 'disable' calls to
2103 * Note: This function should not be called when a mac comm port
2107 * wlandev wlan device structure
2108 * msgp ptr to msg buffer
2111 * 0 success and done
2112 * <0 success, but we're waiting for something to finish.
2113 * >0 an error occurred while handling the message.
2117 * process thread (usually)
2118 ----------------------------------------------------------------*/
2119 int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp)
2121 hfa384x_t *hw = wlandev->priv;
2122 p80211msg_p2req_ramdl_state_t *msg = msgp;
2125 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
2127 "ramdl_state(): may only be called "
2128 "in the fwload state.\n");
2129 msg->resultcode.data =
2130 P80211ENUM_resultcode_implementation_failure;
2131 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2137 ** Note: Interrupts are locked out if this is an AP and are NOT
2138 ** locked out if this is a station.
2141 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2142 if ( msg->enable.data == P80211ENUM_truth_true ) {
2143 if ( hfa384x_drvr_ramdl_enable(hw, msg->exeaddr.data) ) {
2144 msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
2146 msg->resultcode.data = P80211ENUM_resultcode_success;
2149 hfa384x_drvr_ramdl_disable(hw);
2150 msg->resultcode.data = P80211ENUM_resultcode_success;
2158 /*----------------------------------------------------------------
2159 * prism2mgmt_ramdl_write
2161 * Writes a buffer to the card RAM using the download state. This
2162 * is for writing code to card RAM. To just read or write raw data
2163 * use the aux functions.
2166 * wlandev wlan device structure
2167 * msgp ptr to msg buffer
2170 * 0 success and done
2171 * <0 success, but we're waiting for something to finish.
2172 * >0 an error occurred while handling the message.
2176 * process thread (usually)
2177 ----------------------------------------------------------------*/
2178 int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp)
2180 hfa384x_t *hw = wlandev->priv;
2181 p80211msg_p2req_ramdl_write_t *msg = msgp;
2187 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
2189 "ramdl_write(): may only be called "
2190 "in the fwload state.\n");
2191 msg->resultcode.data =
2192 P80211ENUM_resultcode_implementation_failure;
2193 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2198 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2199 /* first validate the length */
2200 if ( msg->len.data > sizeof(msg->data.data) ) {
2201 msg->resultcode.status = P80211ENUM_resultcode_invalid_parameters;
2204 /* call the hfa384x function to do the write */
2205 addr = msg->addr.data;
2206 len = msg->len.data;
2207 buf = msg->data.data;
2208 if ( hfa384x_drvr_ramdl_write(hw, addr, buf, len) ) {
2209 msg->resultcode.data = P80211ENUM_resultcode_refused;
2212 msg->resultcode.data = P80211ENUM_resultcode_success;
2219 /*----------------------------------------------------------------
2220 * prism2mgmt_flashdl_state
2222 * Establishes the beginning/end of a card Flash download session.
2224 * It is expected that the flashdl_write() function will be called
2225 * one or more times between the 'enable' and 'disable' calls to
2228 * Note: This function should not be called when a mac comm port
2232 * wlandev wlan device structure
2233 * msgp ptr to msg buffer
2236 * 0 success and done
2237 * <0 success, but we're waiting for something to finish.
2238 * >0 an error occurred while handling the message.
2242 * process thread (usually)
2243 ----------------------------------------------------------------*/
2244 int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
2247 hfa384x_t *hw = wlandev->priv;
2248 p80211msg_p2req_flashdl_state_t *msg = msgp;
2251 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
2253 "flashdl_state(): may only be called "
2254 "in the fwload state.\n");
2255 msg->resultcode.data =
2256 P80211ENUM_resultcode_implementation_failure;
2257 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2263 ** Note: Interrupts are locked out if this is an AP and are NOT
2264 ** locked out if this is a station.
2267 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2268 if ( msg->enable.data == P80211ENUM_truth_true ) {
2269 if ( hfa384x_drvr_flashdl_enable(hw) ) {
2270 msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
2272 msg->resultcode.data = P80211ENUM_resultcode_success;
2275 hfa384x_drvr_flashdl_disable(hw);
2276 msg->resultcode.data = P80211ENUM_resultcode_success;
2277 /* NOTE: At this point, the MAC is in the post-reset
2278 * state and the driver is in the fwload state.
2279 * We need to get the MAC back into the fwload
2280 * state. To do this, we set the nsdstate to HWPRESENT
2281 * and then call the ifstate function to redo everything
2282 * that got us into the fwload state.
2284 wlandev->msdstate = WLAN_MSD_HWPRESENT;
2285 result = prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload);
2286 if (result != P80211ENUM_resultcode_success) {
2287 WLAN_LOG_ERROR("prism2sta_ifstate(fwload) failed,"
2288 "P80211ENUM_resultcode=%d\n", result);
2289 msg->resultcode.data =
2290 P80211ENUM_resultcode_implementation_failure;
2300 /*----------------------------------------------------------------
2301 * prism2mgmt_flashdl_write
2306 * wlandev wlan device structure
2307 * msgp ptr to msg buffer
2310 * 0 success and done
2311 * <0 success, but we're waiting for something to finish.
2312 * >0 an error occurred while handling the message.
2316 * process thread (usually)
2317 ----------------------------------------------------------------*/
2318 int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp)
2320 hfa384x_t *hw = wlandev->priv;
2321 p80211msg_p2req_flashdl_write_t *msg = msgp;
2327 if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
2329 "flashdl_write(): may only be called "
2330 "in the fwload state.\n");
2331 msg->resultcode.data =
2332 P80211ENUM_resultcode_implementation_failure;
2333 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2339 ** Note: Interrupts are locked out if this is an AP and are NOT
2340 ** locked out if this is a station.
2343 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2344 /* first validate the length */
2345 if ( msg->len.data > sizeof(msg->data.data) ) {
2346 msg->resultcode.status =
2347 P80211ENUM_resultcode_invalid_parameters;
2350 /* call the hfa384x function to do the write */
2351 addr = msg->addr.data;
2352 len = msg->len.data;
2353 buf = msg->data.data;
2354 if ( hfa384x_drvr_flashdl_write(hw, addr, buf, len) ) {
2355 msg->resultcode.data = P80211ENUM_resultcode_refused;
2358 msg->resultcode.data = P80211ENUM_resultcode_success;
2365 /*----------------------------------------------------------------
2366 * prism2mgmt_dump_state
2368 * Dumps the driver's and hardware's current state via the kernel
2369 * log at KERN_NOTICE level.
2372 * wlandev wlan device structure
2373 * msgp ptr to msg buffer
2376 * 0 success and done
2377 * <0 success, but we're waiting for something to finish.
2378 * >0 an error occurred while handling the message.
2382 * process thread (usually)
2383 ----------------------------------------------------------------*/
2384 int prism2mgmt_dump_state(wlandevice_t *wlandev, void *msgp)
2386 p80211msg_p2req_dump_state_t *msg = msgp;
2389 #if (WLAN_HOSTIF != WLAN_USB)
2390 hfa384x_t *hw = wlandev->priv;
2394 WLAN_LOG_NOTICE("prism2 driver and hardware state:\n");
2395 if ( (result = hfa384x_cmd_aux_enable(hw, 0)) ) {
2396 WLAN_LOG_ERROR("aux_enable failed, result=%d\n", result);
2399 hfa384x_copy_from_aux(hw,
2401 HFA384x_AUX_CTL_EXTDS,
2404 hfa384x_cmd_aux_disable(hw);
2405 WLAN_LOG_NOTICE(" cmac: FreeBlocks=%d\n", auxbuf[5]);
2406 WLAN_LOG_NOTICE(" cmac: IntEn=0x%02x EvStat=0x%02x\n",
2407 hfa384x_getreg(hw, HFA384x_INTEN),
2408 hfa384x_getreg(hw, HFA384x_EVSTAT));
2410 #ifdef USE_FID_STACK
2411 WLAN_LOG_NOTICE(" drvr: txfid_top=%d stacksize=%d\n",
2412 hw->txfid_top,HFA384x_DRVR_FIDSTACKLEN_MAX);
2414 WLAN_LOG_NOTICE(" drvr: txfid_head=%d txfid_tail=%d txfid_N=%d\n",
2415 hw->txfid_head, hw->txfid_tail, hw->txfid_N);
2418 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2419 msg->resultcode.data = P80211ENUM_resultcode_success;
2421 #else /* (WLAN_HOSTIF == WLAN_USB) */
2425 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2426 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
2429 #endif /* (WLAN_HOSTIF != WLAN_USB) */
2436 /*----------------------------------------------------------------
2437 * prism2mgmt_channel_info
2439 * Issues a ChannelInfoRequest.
2442 * wlandev wlan device structure
2443 * msgp ptr to msg buffer
2446 * 0 success and done
2447 * <0 success, but we're waiting for something to finish.
2448 * >0 an error occurred while handling the message.
2452 * process thread (usually)
2453 ----------------------------------------------------------------*/
2454 int prism2mgmt_channel_info(wlandevice_t *wlandev, void *msgp)
2456 p80211msg_p2req_channel_info_t *msg=msgp;
2457 hfa384x_t *hw = wlandev->priv;
2459 UINT16 channel_mask=0;
2460 hfa384x_ChannelInfoRequest_data_t chinforeq;
2461 // unsigned long now;
2469 /* Not supported in STA f/w */
2470 P80211_SET_INT(msg->resultcode, P80211ENUM_resultcode_not_supported);
2474 /*** ACCESS POINT ***/
2476 #define CHINFO_TIMEOUT 2
2478 P80211_SET_INT(msg->resultcode, P80211ENUM_resultcode_success);
2480 /* setting default value for channellist = all channels */
2481 if (!msg->channellist.data) {
2482 P80211_SET_INT(msg->channellist, 0x00007FFE);
2484 /* setting default value for channeldwelltime = 100 ms */
2485 if (!msg->channeldwelltime.data) {
2486 P80211_SET_INT(msg->channeldwelltime, 100);
2488 channel_mask = (UINT16) (msg->channellist.data >> 1);
2489 for (i=0, n=0; i < 14; i++) {
2490 if (channel_mask & (1<<i)) {
2494 P80211_SET_INT(msg->numchinfo, n);
2495 chinforeq.channelList = host2hfa384x_16(channel_mask);
2496 chinforeq.channelDwellTime = host2hfa384x_16(msg->channeldwelltime.data);
2498 atomic_set(&hw->channel_info.done, 1);
2500 result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CHANNELINFOREQUEST,
2501 &chinforeq, HFA384x_RID_CHANNELINFOREQUEST_LEN);
2503 WLAN_LOG_ERROR("setconfig(CHANNELINFOREQUEST) failed. result=%d\n",
2505 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
2510 while (atomic_read(&hw->channel_info.done) != 1) {
2511 if ((jiffies - now) > CHINFO_TIMEOUT*HZ) {
2512 WLAN_LOG_NOTICE("ChannelInfo results not received in %d seconds, aborting.\n",
2514 msg->resultcode.data = P80211ENUM_resultcode_timeout;
2517 current->state = TASK_INTERRUPTIBLE;
2518 schedule_timeout(HZ/4);
2519 current->state = TASK_RUNNING;
2529 /*----------------------------------------------------------------
2530 * prism2mgmt_channel_info_results
2532 * Returns required ChannelInfo result.
2535 * wlandev wlan device structure
2536 * msgp ptr to msg buffer
2539 * 0 success and done
2540 * <0 success, but we're waiting for something to finish.
2541 * >0 an error occurred while handling the message.
2545 * process thread (usually)
2546 ----------------------------------------------------------------*/
2547 int prism2mgmt_channel_info_results(wlandevice_t *wlandev, void *msgp)
2549 hfa384x_t *hw = wlandev->priv;
2551 p80211msg_p2req_channel_info_results_t *msg=msgp;
2561 /* Not supported in STA f/w */
2562 P80211_SET_INT(msg->resultcode, P80211ENUM_resultcode_not_supported);
2566 /*** ACCESS POINT ***/
2568 switch (atomic_read(&hw->channel_info.done)) {
2569 case 0: msg->resultcode.status = P80211ENUM_msgitem_status_no_value;
2571 case 1: msg->resultcode.status = P80211ENUM_msgitem_status_incomplete_itemdata;
2575 P80211_SET_INT(msg->resultcode, P80211ENUM_resultcode_success);
2576 channel=msg->channel.data-1;
2578 if (channel < 0 || ! (hw->channel_info.results.scanchannels & 1<<channel) ) {
2579 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
2582 WLAN_LOG_DEBUG(2, "chinfo_results: channel %d, avg/peak level=%d/%d dB, active=%d\n",
2584 hw->channel_info.results.result[channel].anl,
2585 hw->channel_info.results.result[channel].pnl,
2586 hw->channel_info.results.result[channel].active
2588 P80211_SET_INT(msg->avgnoiselevel, hw->channel_info.results.result[channel].anl);
2589 P80211_SET_INT(msg->peaknoiselevel, hw->channel_info.results.result[channel].pnl);
2590 P80211_SET_INT(msg->bssactive, hw->channel_info.results.result[channel].active &
2591 HFA384x_CHINFORESULT_BSSACTIVE
2592 ? P80211ENUM_truth_true
2593 : P80211ENUM_truth_false) ;
2594 P80211_SET_INT(msg->pcfactive, hw->channel_info.results.result[channel].active &
2595 HFA384x_CHINFORESULT_PCFACTIVE
2596 ? P80211ENUM_truth_true
2597 : P80211ENUM_truth_false) ;
2605 /*----------------------------------------------------------------
2606 * prism2mgmt_autojoin
2608 * Associate with an ESS.
2611 * wlandev wlan device structure
2612 * msgp ptr to msg buffer
2615 * 0 success and done
2616 * <0 success, but we're waiting for something to finish.
2617 * >0 an error occurred while handling the message.
2621 * process thread (usually)
2623 ----------------------------------------------------------------*/
2624 int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
2626 hfa384x_t *hw = wlandev->priv;
2630 p80211msg_lnxreq_autojoin_t *msg = msgp;
2631 p80211pstrd_t *pstr;
2633 hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
2636 wlandev->macmode = WLAN_MACMODE_NONE;
2639 memcpy(&wlandev->ssid, &msg->ssid.data, sizeof(msg->ssid.data));
2643 /*** ACCESS POINT ***/
2645 /* Never supported on AP */
2646 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2647 msg->resultcode.data = P80211ENUM_resultcode_not_supported;
2651 /* Disable the Port */
2652 hfa384x_drvr_disable(hw, 0);
2655 /* Set the TxRates */
2656 hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, 0x000f);
2658 /* Set the auth type */
2659 if ( msg->authtype.data == P80211ENUM_authalg_sharedkey ) {
2660 reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY;
2662 reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM;
2664 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, reg);
2667 memset(bytebuf, 0, 256);
2668 pstr = (p80211pstrd_t*)&(msg->ssid.data);
2669 prism2mgmt_pstr2bytestr(p2bytestr, pstr);
2670 result = hfa384x_drvr_setconfig(
2671 hw, HFA384x_RID_CNFDESIREDSSID,
2672 bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
2674 /* we can use the new-fangled auto-unknown mode if the firmware
2675 is 1.3.3 or newer */
2676 if (HFA384x_FIRMARE_VERSION(hw->ident_sta_fw.major,
2677 hw->ident_sta_fw.minor,
2678 hw->ident_sta_fw.variant) >=
2679 HFA384x_FIRMWARE_VERSION(1,3,3)) {
2680 /* Set up the IBSS options */
2681 reg = HFA384x_CREATEIBSS_JOINESS_JOINCREATEIBSS;
2682 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CREATEIBSS, reg);
2684 /* Set the PortType */
2685 port_type = HFA384x_PORTTYPE_IBSS;
2687 port_type = HFA384x_PORTTYPE_BSS;
2690 port_type = HFA384x_PORTTYPE_BSS;
2692 /* Set the PortType */
2693 hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, port_type);
2695 /* Enable the Port */
2696 hfa384x_drvr_enable(hw, 0);
2698 /* Set the resultcode */
2699 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2700 msg->resultcode.data = P80211ENUM_resultcode_success;
2708 /*----------------------------------------------------------------
2709 * prism2mgmt_wlansniff
2711 * Start or stop sniffing.
2714 * wlandev wlan device structure
2715 * msgp ptr to msg buffer
2718 * 0 success and done
2719 * <0 success, but we're waiting for something to finish.
2720 * >0 an error occurred while handling the message.
2724 * process thread (usually)
2726 ----------------------------------------------------------------*/
2727 int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
2730 p80211msg_lnxreq_wlansniff_t *msg = msgp;
2732 hfa384x_t *hw = wlandev->priv;
2737 msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
2738 switch (msg->enable.data)
2740 case P80211ENUM_truth_false:
2741 /* Confirm that we're in monitor mode */
2742 if ( wlandev->netdev->type == ARPHRD_ETHER ) {
2743 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
2747 /* Disable monitor mode */
2748 result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
2751 "failed to disable monitor mode, result=%d\n",
2755 /* Disable port 0 */
2756 result = hfa384x_drvr_disable(hw, 0);
2759 "failed to disable port 0 after sniffing, result=%d\n",
2763 /* Clear the driver state */
2764 wlandev->netdev->type = ARPHRD_ETHER;
2766 /* Restore the wepflags */
2767 result = hfa384x_drvr_setconfig16(hw,
2768 HFA384x_RID_CNFWEPFLAGS,
2769 hw->presniff_wepflags);
2772 "failed to restore wepflags=0x%04x, result=%d\n",
2773 hw->presniff_wepflags,
2778 /* Set the port to its prior type and enable (if necessary) */
2779 if (hw->presniff_port_type != 0 ) {
2780 word = hw->presniff_port_type;
2781 result = hfa384x_drvr_setconfig16(hw,
2782 HFA384x_RID_CNFPORTTYPE, word);
2785 "failed to restore porttype, result=%d\n",
2790 /* Enable the port */
2791 result = hfa384x_drvr_enable(hw, 0);
2793 WLAN_LOG_DEBUG(1, "failed to enable port to presniff setting, result=%d\n", result);
2797 result = hfa384x_drvr_disable(hw, 0);
2801 WLAN_LOG_INFO("monitor mode disabled\n");
2802 msg->resultcode.data = P80211ENUM_resultcode_success;
2806 case P80211ENUM_truth_true:
2807 /* Disable the port (if enabled), only check Port 0 */
2808 if ( hw->port_enabled[0]) {
2809 if (wlandev->netdev->type == ARPHRD_ETHER) {
2810 /* Save macport 0 state */
2811 result = hfa384x_drvr_getconfig16(hw,
2812 HFA384x_RID_CNFPORTTYPE,
2813 &(hw->presniff_port_type));
2815 WLAN_LOG_DEBUG(1,"failed to read porttype, result=%d\n", result);
2818 /* Save the wepflags state */
2819 result = hfa384x_drvr_getconfig16(hw,
2820 HFA384x_RID_CNFWEPFLAGS,
2821 &(hw->presniff_wepflags));
2823 WLAN_LOG_DEBUG(1,"failed to read wepflags, result=%d\n", result);
2826 hfa384x_drvr_stop(hw);
2827 result = hfa384x_drvr_start(hw);
2830 "failed to restart the card for sniffing, result=%d\n",
2835 /* Disable the port */
2836 result = hfa384x_drvr_disable(hw, 0);
2839 "failed to enable port for sniffing, result=%d\n",
2845 hw->presniff_port_type = 0;
2848 /* Set the channel we wish to sniff */
2849 word = msg->channel.data;
2850 result = hfa384x_drvr_setconfig16(hw,
2851 HFA384x_RID_CNFOWNCHANNEL, word);
2852 hw->sniff_channel=word;
2856 "failed to set channel %d, result=%d\n",
2862 /* Now if we're already sniffing, we can skip the rest */
2863 if (wlandev->netdev->type != ARPHRD_ETHER) {
2864 /* Set the port type to pIbss */
2865 word = HFA384x_PORTTYPE_PSUEDOIBSS;
2866 result = hfa384x_drvr_setconfig16(hw,
2867 HFA384x_RID_CNFPORTTYPE, word);
2870 "failed to set porttype %d, result=%d\n",
2875 if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) {
2876 /* Set the wepflags for no decryption */
2877 word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT |
2878 HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
2879 result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word);
2884 "failed to set wepflags=0x%04x, result=%d\n",
2891 /* Do we want to strip the FCS in monitor mode? */
2892 if ((msg->stripfcs.status == P80211ENUM_msgitem_status_data_ok) && (msg->stripfcs.data == P80211ENUM_truth_true)) {
2898 /* Do we want to truncate the packets? */
2899 if (msg->packet_trunc.status == P80211ENUM_msgitem_status_data_ok) {
2900 hw->sniff_truncate = msg->packet_trunc.data;
2902 hw->sniff_truncate = 0;
2905 /* Enable the port */
2906 result = hfa384x_drvr_enable(hw, 0);
2909 "failed to enable port for sniffing, result=%d\n",
2913 /* Enable monitor mode */
2914 result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE);
2917 "failed to enable monitor mode, result=%d\n",
2922 if (wlandev->netdev->type == ARPHRD_ETHER) {
2923 WLAN_LOG_INFO("monitor mode enabled\n");
2926 /* Set the driver state */
2927 /* Do we want the prism2 header? */
2928 if ((msg->prismheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->prismheader.data == P80211ENUM_truth_true)) {
2930 wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
2931 } else if ((msg->wlanheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->wlanheader.data == P80211ENUM_truth_true)) {
2933 wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
2935 wlandev->netdev->type = ARPHRD_IEEE80211;
2938 msg->resultcode.data = P80211ENUM_resultcode_success;
2943 msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
2950 msg->resultcode.data = P80211ENUM_resultcode_refused;