Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1 | /* src/prism2/driver/prism2mgmt.c |
| 2 | * |
| 3 | * Management request handler functions. |
| 4 | * |
| 5 | * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved. |
| 6 | * -------------------------------------------------------------------- |
| 7 | * |
| 8 | * linux-wlan |
| 9 | * |
| 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/ |
| 14 | * |
| 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. |
| 19 | * |
| 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. |
| 30 | * |
| 31 | * -------------------------------------------------------------------- |
| 32 | * |
| 33 | * Inquiries regarding the linux-wlan Open Source project can be |
| 34 | * made directly to: |
| 35 | * |
| 36 | * AbsoluteValue Systems Inc. |
| 37 | * info@linux-wlan.com |
| 38 | * http://www.linux-wlan.com |
| 39 | * |
| 40 | * -------------------------------------------------------------------- |
| 41 | * |
| 42 | * Portions of the development of this software were funded by |
| 43 | * Intersil Corporation as part of PRISM(R) chipset product development. |
| 44 | * |
| 45 | * -------------------------------------------------------------------- |
| 46 | * |
| 47 | * The functions in this file handle management requests sent from |
| 48 | * user mode. |
| 49 | * |
| 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. |
| 56 | * |
| 57 | * -------------------------------------------------------------------- |
| 58 | */ |
| 59 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 60 | #include <linux/if_arp.h> |
| 61 | #include <linux/module.h> |
| 62 | #include <linux/kernel.h> |
| 63 | #include <linux/wait.h> |
| 64 | #include <linux/sched.h> |
| 65 | #include <linux/types.h> |
| 66 | #include <linux/slab.h> |
| 67 | #include <linux/wireless.h> |
| 68 | #include <linux/netdevice.h> |
| 69 | #include <linux/delay.h> |
Andrew Elwell | ef1a0ed | 2010-02-18 23:56:12 +0100 | [diff] [blame^] | 70 | #include <linux/io.h> |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 71 | #include <asm/byteorder.h> |
| 72 | #include <linux/random.h> |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 73 | #include <linux/usb.h> |
Moritz Muehlenhoff | 7f6e0e4 | 2009-01-25 21:54:55 +0100 | [diff] [blame] | 74 | #include <linux/bitops.h> |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 75 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 76 | #include "p80211types.h" |
| 77 | #include "p80211hdr.h" |
| 78 | #include "p80211mgmt.h" |
| 79 | #include "p80211conv.h" |
| 80 | #include "p80211msg.h" |
| 81 | #include "p80211netdev.h" |
| 82 | #include "p80211metadef.h" |
| 83 | #include "p80211metastruct.h" |
| 84 | #include "hfa384x.h" |
| 85 | #include "prism2mgmt.h" |
| 86 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 87 | /* Converts 802.11 format rate specifications to prism2 */ |
Moritz Muehlenhoff | 7f6e0e4 | 2009-01-25 21:54:55 +0100 | [diff] [blame] | 88 | #define p80211rate_to_p2bit(n) ((((n)&~BIT(7)) == 2) ? BIT(0) : \ |
| 89 | (((n)&~BIT(7)) == 4) ? BIT(1) : \ |
| 90 | (((n)&~BIT(7)) == 11) ? BIT(2) : \ |
| 91 | (((n)&~BIT(7)) == 22) ? BIT(3) : 0) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 92 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 93 | /*---------------------------------------------------------------- |
| 94 | * prism2mgmt_scan |
| 95 | * |
| 96 | * Initiate a scan for BSSs. |
| 97 | * |
| 98 | * This function corresponds to MLME-scan.request and part of |
| 99 | * MLME-scan.confirm. As far as I can tell in the standard, there |
| 100 | * are no restrictions on when a scan.request may be issued. We have |
| 101 | * to handle in whatever state the driver/MAC happen to be. |
| 102 | * |
| 103 | * Arguments: |
| 104 | * wlandev wlan device structure |
| 105 | * msgp ptr to msg buffer |
| 106 | * |
| 107 | * Returns: |
| 108 | * 0 success and done |
| 109 | * <0 success, but we're waiting for something to finish. |
| 110 | * >0 an error occurred while handling the message. |
| 111 | * Side effects: |
| 112 | * |
| 113 | * Call context: |
| 114 | * process thread (usually) |
| 115 | * interrupt |
| 116 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 117 | int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 118 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 119 | int result = 0; |
| 120 | hfa384x_t *hw = wlandev->priv; |
| 121 | p80211msg_dot11req_scan_t *msg = msgp; |
| 122 | u16 roamingmode, word; |
| 123 | int i, timeout; |
| 124 | int istmpenable = 0; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 125 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 126 | hfa384x_HostScanRequest_data_t scanreq; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 127 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 128 | /* gatekeeper check */ |
| 129 | if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, |
| 130 | hw->ident_sta_fw.minor, |
| 131 | hw->ident_sta_fw.variant) < |
| 132 | HFA384x_FIRMWARE_VERSION(1, 3, 2)) { |
| 133 | printk(KERN_ERR |
| 134 | "HostScan not supported with current firmware (<1.3.2).\n"); |
| 135 | result = 1; |
| 136 | msg->resultcode.data = P80211ENUM_resultcode_not_supported; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 137 | goto exit; |
| 138 | } |
| 139 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 140 | memset(&scanreq, 0, sizeof(scanreq)); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 141 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 142 | /* save current roaming mode */ |
| 143 | result = hfa384x_drvr_getconfig16(hw, |
| 144 | HFA384x_RID_CNFROAMINGMODE, |
| 145 | &roamingmode); |
| 146 | if (result) { |
| 147 | printk(KERN_ERR "getconfig(ROAMMODE) failed. result=%d\n", |
| 148 | result); |
| 149 | msg->resultcode.data = |
| 150 | P80211ENUM_resultcode_implementation_failure; |
| 151 | goto exit; |
| 152 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 153 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 154 | /* drop into mode 3 for the scan */ |
| 155 | result = hfa384x_drvr_setconfig16(hw, |
| 156 | HFA384x_RID_CNFROAMINGMODE, |
| 157 | HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); |
| 158 | if (result) { |
| 159 | printk(KERN_ERR "setconfig(ROAMINGMODE) failed. result=%d\n", |
| 160 | result); |
| 161 | msg->resultcode.data = |
| 162 | P80211ENUM_resultcode_implementation_failure; |
| 163 | goto exit; |
| 164 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 165 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 166 | /* active or passive? */ |
| 167 | if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, |
| 168 | hw->ident_sta_fw.minor, |
| 169 | hw->ident_sta_fw.variant) > |
| 170 | HFA384x_FIRMWARE_VERSION(1, 5, 0)) { |
| 171 | if (msg->scantype.data != P80211ENUM_scantype_active) |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 172 | word = cpu_to_le16(msg->maxchanneltime.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 173 | else |
| 174 | word = 0; |
| 175 | |
| 176 | result = |
| 177 | hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL, |
| 178 | word); |
| 179 | if (result) { |
| 180 | printk(KERN_WARNING "Passive scan not supported with " |
| 181 | "current firmware. (<1.5.1)\n"); |
| 182 | } |
| 183 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 184 | |
| 185 | /* set up the txrate to be 2MBPS. Should be fastest basicrate... */ |
| 186 | word = HFA384x_RATEBIT_2; |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 187 | scanreq.txRate = cpu_to_le16(word); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 188 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 189 | /* set up the channel list */ |
| 190 | word = 0; |
| 191 | for (i = 0; i < msg->channellist.data.len; i++) { |
| 192 | u8 channel = msg->channellist.data.data[i]; |
| 193 | if (channel > 14) |
| 194 | continue; |
| 195 | /* channel 1 is BIT 0 ... channel 14 is BIT 13 */ |
| 196 | word |= (1 << (channel - 1)); |
| 197 | } |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 198 | scanreq.channelList = cpu_to_le16(word); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 199 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 200 | /* set up the ssid, if present. */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 201 | scanreq.ssid.len = cpu_to_le16(msg->ssid.data.len); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 202 | memcpy(scanreq.ssid.data, msg->ssid.data.data, msg->ssid.data.len); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 203 | |
| 204 | /* Enable the MAC port if it's not already enabled */ |
| 205 | result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 206 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 207 | printk(KERN_ERR "getconfig(PORTSTATUS) failed. " |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 208 | "result=%d\n", result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 209 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 210 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 211 | goto exit; |
| 212 | } |
| 213 | if (word == HFA384x_PORTSTATUS_DISABLED) { |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 214 | u16 wordbuf[17]; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 215 | |
| 216 | result = hfa384x_drvr_setconfig16(hw, |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 217 | HFA384x_RID_CNFROAMINGMODE, |
| 218 | HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); |
| 219 | if (result) { |
| 220 | printk(KERN_ERR |
| 221 | "setconfig(ROAMINGMODE) failed. result=%d\n", |
| 222 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 223 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 224 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 225 | goto exit; |
| 226 | } |
| 227 | /* Construct a bogus SSID and assign it to OwnSSID and |
| 228 | * DesiredSSID |
| 229 | */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 230 | wordbuf[0] = cpu_to_le16(WLAN_SSID_MAXLEN); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 231 | get_random_bytes(&wordbuf[1], WLAN_SSID_MAXLEN); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 232 | result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFOWNSSID, |
| 233 | wordbuf, |
| 234 | HFA384x_RID_CNFOWNSSID_LEN); |
| 235 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 236 | printk(KERN_ERR "Failed to set OwnSSID.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 237 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 238 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 239 | goto exit; |
| 240 | } |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 241 | result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID, |
| 242 | wordbuf, |
| 243 | HFA384x_RID_CNFDESIREDSSID_LEN); |
| 244 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 245 | printk(KERN_ERR "Failed to set DesiredSSID.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 246 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 247 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 248 | goto exit; |
| 249 | } |
| 250 | /* bsstype */ |
| 251 | result = hfa384x_drvr_setconfig16(hw, |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 252 | HFA384x_RID_CNFPORTTYPE, |
| 253 | HFA384x_PORTTYPE_IBSS); |
| 254 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 255 | printk(KERN_ERR "Failed to set CNFPORTTYPE.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 256 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 257 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 258 | goto exit; |
| 259 | } |
| 260 | /* ibss options */ |
| 261 | result = hfa384x_drvr_setconfig16(hw, |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 262 | HFA384x_RID_CREATEIBSS, |
| 263 | HFA384x_CREATEIBSS_JOINCREATEIBSS); |
| 264 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 265 | printk(KERN_ERR "Failed to set CREATEIBSS.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 266 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 267 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 268 | goto exit; |
| 269 | } |
| 270 | result = hfa384x_drvr_enable(hw, 0); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 271 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 272 | printk(KERN_ERR "drvr_enable(0) failed. " |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 273 | "result=%d\n", result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 274 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 275 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 276 | goto exit; |
| 277 | } |
| 278 | istmpenable = 1; |
| 279 | } |
| 280 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 281 | /* Figure out our timeout first Kus, then HZ */ |
| 282 | timeout = msg->channellist.data.len * msg->maxchanneltime.data; |
| 283 | timeout = (timeout * HZ) / 1000; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 284 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 285 | /* Issue the scan request */ |
| 286 | hw->scanflag = 0; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 287 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 288 | result = hfa384x_drvr_setconfig(hw, |
| 289 | HFA384x_RID_HOSTSCAN, &scanreq, |
| 290 | sizeof(hfa384x_HostScanRequest_data_t)); |
| 291 | if (result) { |
| 292 | printk(KERN_ERR "setconfig(SCANREQUEST) failed. result=%d\n", |
| 293 | result); |
| 294 | msg->resultcode.data = |
| 295 | P80211ENUM_resultcode_implementation_failure; |
| 296 | goto exit; |
| 297 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 298 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 299 | /* sleep until info frame arrives */ |
| 300 | wait_event_interruptible_timeout(hw->cmdq, hw->scanflag, timeout); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 301 | |
| 302 | msg->numbss.status = P80211ENUM_msgitem_status_data_ok; |
| 303 | if (hw->scanflag == -1) |
| 304 | hw->scanflag = 0; |
| 305 | |
| 306 | msg->numbss.data = hw->scanflag; |
| 307 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 308 | hw->scanflag = 0; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 309 | |
| 310 | /* Disable port if we temporarily enabled it. */ |
| 311 | if (istmpenable) { |
| 312 | result = hfa384x_drvr_disable(hw, 0); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 313 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 314 | printk(KERN_ERR "drvr_disable(0) failed. " |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 315 | "result=%d\n", result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 316 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 317 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 318 | goto exit; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | /* restore original roaming mode */ |
| 323 | result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, |
| 324 | roamingmode); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 325 | if (result) { |
| 326 | printk(KERN_ERR "setconfig(ROAMMODE) failed. result=%d\n", |
| 327 | result); |
| 328 | msg->resultcode.data = |
| 329 | P80211ENUM_resultcode_implementation_failure; |
| 330 | goto exit; |
| 331 | } |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 332 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 333 | result = 0; |
| 334 | msg->resultcode.data = P80211ENUM_resultcode_success; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 335 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 336 | exit: |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 337 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
| 338 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 339 | return result; |
| 340 | } |
| 341 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 342 | /*---------------------------------------------------------------- |
| 343 | * prism2mgmt_scan_results |
| 344 | * |
| 345 | * Retrieve the BSS description for one of the BSSs identified in |
| 346 | * a scan. |
| 347 | * |
| 348 | * Arguments: |
| 349 | * wlandev wlan device structure |
| 350 | * msgp ptr to msg buffer |
| 351 | * |
| 352 | * Returns: |
| 353 | * 0 success and done |
| 354 | * <0 success, but we're waiting for something to finish. |
| 355 | * >0 an error occurred while handling the message. |
| 356 | * Side effects: |
| 357 | * |
| 358 | * Call context: |
| 359 | * process thread (usually) |
| 360 | * interrupt |
| 361 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 362 | int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 363 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 364 | int result = 0; |
| 365 | p80211msg_dot11req_scan_results_t *req; |
| 366 | hfa384x_t *hw = wlandev->priv; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 367 | hfa384x_HScanResultSub_t *item = NULL; |
| 368 | |
| 369 | int count; |
| 370 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 371 | req = (p80211msg_dot11req_scan_results_t *) msgp; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 372 | |
| 373 | req->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
| 374 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 375 | if (!hw->scanresults) { |
| 376 | printk(KERN_ERR |
| 377 | "dot11req_scan_results can only be used after a successful dot11req_scan.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 378 | result = 2; |
| 379 | req->resultcode.data = P80211ENUM_resultcode_invalid_parameters; |
| 380 | goto exit; |
| 381 | } |
| 382 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 383 | count = (hw->scanresults->framelen - 3) / 32; |
| 384 | if (count > 32) |
| 385 | count = 32; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 386 | |
| 387 | if (req->bssindex.data >= count) { |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 388 | pr_debug("requested index (%d) out of range (%d)\n", |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 389 | req->bssindex.data, count); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 390 | result = 2; |
| 391 | req->resultcode.data = P80211ENUM_resultcode_invalid_parameters; |
| 392 | goto exit; |
| 393 | } |
| 394 | |
| 395 | item = &(hw->scanresults->info.hscanresult.result[req->bssindex.data]); |
| 396 | /* signal and noise */ |
| 397 | req->signal.status = P80211ENUM_msgitem_status_data_ok; |
| 398 | req->noise.status = P80211ENUM_msgitem_status_data_ok; |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 399 | req->signal.data = le16_to_cpu(item->sl); |
| 400 | req->noise.data = le16_to_cpu(item->anl); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 401 | |
| 402 | /* BSSID */ |
| 403 | req->bssid.status = P80211ENUM_msgitem_status_data_ok; |
| 404 | req->bssid.data.len = WLAN_BSSID_LEN; |
| 405 | memcpy(req->bssid.data.data, item->bssid, WLAN_BSSID_LEN); |
| 406 | |
| 407 | /* SSID */ |
| 408 | req->ssid.status = P80211ENUM_msgitem_status_data_ok; |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 409 | req->ssid.data.len = le16_to_cpu(item->ssid.len); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 410 | memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len); |
| 411 | |
| 412 | /* supported rates */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 413 | for (count = 0; count < 10; count++) |
| 414 | if (item->supprates[count] == 0) |
| 415 | break; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 416 | |
| 417 | #define REQBASICRATE(N) \ |
| 418 | if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \ |
| 419 | req->basicrate ## N .data = item->supprates[(N)-1]; \ |
| 420 | req->basicrate ## N .status = P80211ENUM_msgitem_status_data_ok; \ |
| 421 | } |
| 422 | |
| 423 | REQBASICRATE(1); |
| 424 | REQBASICRATE(2); |
| 425 | REQBASICRATE(3); |
| 426 | REQBASICRATE(4); |
| 427 | REQBASICRATE(5); |
| 428 | REQBASICRATE(6); |
| 429 | REQBASICRATE(7); |
| 430 | REQBASICRATE(8); |
| 431 | |
| 432 | #define REQSUPPRATE(N) \ |
| 433 | if (count >= N) { \ |
| 434 | req->supprate ## N .data = item->supprates[(N)-1]; \ |
| 435 | req->supprate ## N .status = P80211ENUM_msgitem_status_data_ok; \ |
| 436 | } |
| 437 | |
| 438 | REQSUPPRATE(1); |
| 439 | REQSUPPRATE(2); |
| 440 | REQSUPPRATE(3); |
| 441 | REQSUPPRATE(4); |
| 442 | REQSUPPRATE(5); |
| 443 | REQSUPPRATE(6); |
| 444 | REQSUPPRATE(7); |
| 445 | REQSUPPRATE(8); |
| 446 | |
| 447 | /* beacon period */ |
| 448 | req->beaconperiod.status = P80211ENUM_msgitem_status_data_ok; |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 449 | req->beaconperiod.data = le16_to_cpu(item->bcnint); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 450 | |
| 451 | /* timestamps */ |
| 452 | req->timestamp.status = P80211ENUM_msgitem_status_data_ok; |
| 453 | req->timestamp.data = jiffies; |
| 454 | req->localtime.status = P80211ENUM_msgitem_status_data_ok; |
| 455 | req->localtime.data = jiffies; |
| 456 | |
| 457 | /* atim window */ |
| 458 | req->ibssatimwindow.status = P80211ENUM_msgitem_status_data_ok; |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 459 | req->ibssatimwindow.data = le16_to_cpu(item->atim); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 460 | |
| 461 | /* Channel */ |
| 462 | req->dschannel.status = P80211ENUM_msgitem_status_data_ok; |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 463 | req->dschannel.data = le16_to_cpu(item->chid); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 464 | |
| 465 | /* capinfo bits */ |
Moritz Muehlenhoff | 18c7f79 | 2009-02-18 19:50:07 +0100 | [diff] [blame] | 466 | count = le16_to_cpu(item->capinfo); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 467 | |
| 468 | /* privacy flag */ |
| 469 | req->privacy.status = P80211ENUM_msgitem_status_data_ok; |
| 470 | req->privacy.data = WLAN_GET_MGMT_CAP_INFO_PRIVACY(count); |
| 471 | |
| 472 | /* cfpollable */ |
| 473 | req->cfpollable.status = P80211ENUM_msgitem_status_data_ok; |
| 474 | req->cfpollable.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(count); |
| 475 | |
| 476 | /* cfpollreq */ |
| 477 | req->cfpollreq.status = P80211ENUM_msgitem_status_data_ok; |
| 478 | req->cfpollreq.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(count); |
| 479 | |
| 480 | /* bsstype */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 481 | req->bsstype.status = P80211ENUM_msgitem_status_data_ok; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 482 | req->bsstype.data = (WLAN_GET_MGMT_CAP_INFO_ESS(count)) ? |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 483 | P80211ENUM_bsstype_infrastructure : P80211ENUM_bsstype_independent; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 484 | |
| 485 | result = 0; |
| 486 | req->resultcode.data = P80211ENUM_resultcode_success; |
| 487 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 488 | exit: |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 489 | return result; |
| 490 | } |
| 491 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 492 | /*---------------------------------------------------------------- |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 493 | * prism2mgmt_start |
| 494 | * |
| 495 | * Start a BSS. Any station can do this for IBSS, only AP for ESS. |
| 496 | * |
| 497 | * Arguments: |
| 498 | * wlandev wlan device structure |
| 499 | * msgp ptr to msg buffer |
| 500 | * |
| 501 | * Returns: |
| 502 | * 0 success and done |
| 503 | * <0 success, but we're waiting for something to finish. |
| 504 | * >0 an error occurred while handling the message. |
| 505 | * Side effects: |
| 506 | * |
| 507 | * Call context: |
| 508 | * process thread (usually) |
| 509 | * interrupt |
| 510 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 511 | int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 512 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 513 | int result = 0; |
| 514 | hfa384x_t *hw = wlandev->priv; |
| 515 | p80211msg_dot11req_start_t *msg = msgp; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 516 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 517 | p80211pstrd_t *pstr; |
| 518 | u8 bytebuf[80]; |
| 519 | hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t *) bytebuf; |
| 520 | u16 word; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 521 | |
| 522 | wlandev->macmode = WLAN_MACMODE_NONE; |
| 523 | |
| 524 | /* Set the SSID */ |
| 525 | memcpy(&wlandev->ssid, &msg->ssid.data, sizeof(msg->ssid.data)); |
| 526 | |
Solomon Peachy | 5db8dcc | 2008-10-27 11:14:02 -0400 | [diff] [blame] | 527 | /*** ADHOC IBSS ***/ |
| 528 | /* see if current f/w is less than 8c3 */ |
| 529 | if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, |
| 530 | hw->ident_sta_fw.minor, |
| 531 | hw->ident_sta_fw.variant) < |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 532 | HFA384x_FIRMWARE_VERSION(0, 8, 3)) { |
Solomon Peachy | 5db8dcc | 2008-10-27 11:14:02 -0400 | [diff] [blame] | 533 | /* Ad-Hoc not quite supported on Prism2 */ |
| 534 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
| 535 | msg->resultcode.data = P80211ENUM_resultcode_not_supported; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 536 | goto done; |
| 537 | } |
| 538 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 539 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
| 540 | |
Solomon Peachy | 5db8dcc | 2008-10-27 11:14:02 -0400 | [diff] [blame] | 541 | /*** STATION ***/ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 542 | /* Set the REQUIRED config items */ |
| 543 | /* SSID */ |
Andrew Elwell | ef1a0ed | 2010-02-18 23:56:12 +0100 | [diff] [blame^] | 544 | pstr = (p80211pstrd_t *) &(msg->ssid.data); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 545 | prism2mgmt_pstr2bytestr(p2bytestr, pstr); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 546 | result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFOWNSSID, |
| 547 | bytebuf, HFA384x_RID_CNFOWNSSID_LEN); |
| 548 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 549 | printk(KERN_ERR "Failed to set CnfOwnSSID\n"); |
Solomon Peachy | 5db8dcc | 2008-10-27 11:14:02 -0400 | [diff] [blame] | 550 | goto failed; |
| 551 | } |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 552 | result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID, |
| 553 | bytebuf, |
| 554 | HFA384x_RID_CNFDESIREDSSID_LEN); |
| 555 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 556 | printk(KERN_ERR "Failed to set CnfDesiredSSID\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 557 | goto failed; |
| 558 | } |
| 559 | |
| 560 | /* bsstype - we use the default in the ap firmware */ |
Solomon Peachy | 5db8dcc | 2008-10-27 11:14:02 -0400 | [diff] [blame] | 561 | /* IBSS port */ |
| 562 | hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, 0); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 563 | |
| 564 | /* beacon period */ |
| 565 | word = msg->beaconperiod.data; |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 566 | result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNint, word); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 567 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 568 | printk(KERN_ERR "Failed to set beacon period=%d.\n", word); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 569 | goto failed; |
| 570 | } |
| 571 | |
| 572 | /* dschannel */ |
| 573 | word = msg->dschannel.data; |
| 574 | result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 575 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 576 | printk(KERN_ERR "Failed to set channel=%d.\n", word); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 577 | goto failed; |
| 578 | } |
| 579 | /* Basic rates */ |
| 580 | word = p80211rate_to_p2bit(msg->basicrate1.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 581 | if (msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 582 | word |= p80211rate_to_p2bit(msg->basicrate2.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 583 | |
| 584 | if (msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 585 | word |= p80211rate_to_p2bit(msg->basicrate3.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 586 | |
| 587 | if (msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 588 | word |= p80211rate_to_p2bit(msg->basicrate4.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 589 | |
| 590 | if (msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 591 | word |= p80211rate_to_p2bit(msg->basicrate5.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 592 | |
| 593 | if (msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 594 | word |= p80211rate_to_p2bit(msg->basicrate6.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 595 | |
| 596 | if (msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 597 | word |= p80211rate_to_p2bit(msg->basicrate7.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 598 | |
| 599 | if (msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 600 | word |= p80211rate_to_p2bit(msg->basicrate8.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 601 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 602 | result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 603 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 604 | printk(KERN_ERR "Failed to set basicrates=%d.\n", word); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 605 | goto failed; |
| 606 | } |
| 607 | |
| 608 | /* Operational rates (supprates and txratecontrol) */ |
| 609 | word = p80211rate_to_p2bit(msg->operationalrate1.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 610 | if (msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 611 | word |= p80211rate_to_p2bit(msg->operationalrate2.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 612 | |
| 613 | if (msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 614 | word |= p80211rate_to_p2bit(msg->operationalrate3.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 615 | |
| 616 | if (msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 617 | word |= p80211rate_to_p2bit(msg->operationalrate4.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 618 | |
| 619 | if (msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 620 | word |= p80211rate_to_p2bit(msg->operationalrate5.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 621 | |
| 622 | if (msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 623 | word |= p80211rate_to_p2bit(msg->operationalrate6.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 624 | |
| 625 | if (msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 626 | word |= p80211rate_to_p2bit(msg->operationalrate7.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 627 | |
| 628 | if (msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 629 | word |= p80211rate_to_p2bit(msg->operationalrate8.data); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 630 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 631 | result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 632 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 633 | printk(KERN_ERR "Failed to set supprates=%d.\n", word); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 634 | goto failed; |
| 635 | } |
Solomon Peachy | 5db8dcc | 2008-10-27 11:14:02 -0400 | [diff] [blame] | 636 | |
| 637 | result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 638 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 639 | printk(KERN_ERR "Failed to set txrates=%d.\n", word); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 640 | goto failed; |
| 641 | } |
| 642 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 643 | /* Set the macmode so the frame setup code knows what to do */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 644 | if (msg->bsstype.data == P80211ENUM_bsstype_independent) { |
Solomon Peachy | 5db8dcc | 2008-10-27 11:14:02 -0400 | [diff] [blame] | 645 | wlandev->macmode = WLAN_MACMODE_IBSS_STA; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 646 | /* lets extend the data length a bit */ |
| 647 | hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304); |
| 648 | } |
| 649 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 650 | /* Enable the Port */ |
| 651 | result = hfa384x_drvr_enable(hw, 0); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 652 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 653 | printk(KERN_ERR "Enable macport failed, result=%d.\n", result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 654 | goto failed; |
| 655 | } |
| 656 | |
| 657 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 658 | |
| 659 | goto done; |
| 660 | failed: |
Moritz Muehlenhoff | a7cf7ba | 2009-02-08 02:01:00 +0100 | [diff] [blame] | 661 | pr_debug("Failed to set a config option, result=%d\n", result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 662 | msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters; |
| 663 | |
| 664 | done: |
| 665 | result = 0; |
| 666 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 667 | return result; |
| 668 | } |
| 669 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 670 | /*---------------------------------------------------------------- |
| 671 | * prism2mgmt_readpda |
| 672 | * |
| 673 | * Collect the PDA data and put it in the message. |
| 674 | * |
| 675 | * Arguments: |
| 676 | * wlandev wlan device structure |
| 677 | * msgp ptr to msg buffer |
| 678 | * |
| 679 | * Returns: |
| 680 | * 0 success and done |
| 681 | * <0 success, but we're waiting for something to finish. |
| 682 | * >0 an error occurred while handling the message. |
| 683 | * Side effects: |
| 684 | * |
| 685 | * Call context: |
| 686 | * process thread (usually) |
| 687 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 688 | int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 689 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 690 | hfa384x_t *hw = wlandev->priv; |
| 691 | p80211msg_p2req_readpda_t *msg = msgp; |
| 692 | int result; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 693 | |
| 694 | /* We only support collecting the PDA when in the FWLOAD |
| 695 | * state. |
| 696 | */ |
| 697 | if (wlandev->msdstate != WLAN_MSD_FWLOAD) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 698 | printk(KERN_ERR |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 699 | "PDA may only be read " "in the fwload state.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 700 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 701 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 702 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
| 703 | } else { |
| 704 | /* Call drvr_readpda(), it handles the auxport enable |
| 705 | * and validating the returned PDA. |
| 706 | */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 707 | result = hfa384x_drvr_readpda(hw, |
| 708 | msg->pda.data, |
| 709 | HFA384x_PDA_LEN_MAX); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 710 | if (result) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 711 | printk(KERN_ERR |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 712 | "hfa384x_drvr_readpda() failed, " |
| 713 | "result=%d\n", result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 714 | |
| 715 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 716 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 717 | msg->resultcode.status = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 718 | P80211ENUM_msgitem_status_data_ok; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 719 | return 0; |
| 720 | } |
| 721 | msg->pda.status = P80211ENUM_msgitem_status_data_ok; |
| 722 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 723 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
| 724 | } |
| 725 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 726 | return 0; |
| 727 | } |
| 728 | |
| 729 | /*---------------------------------------------------------------- |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 730 | * prism2mgmt_ramdl_state |
| 731 | * |
| 732 | * Establishes the beginning/end of a card RAM download session. |
| 733 | * |
| 734 | * It is expected that the ramdl_write() function will be called |
| 735 | * one or more times between the 'enable' and 'disable' calls to |
| 736 | * this function. |
| 737 | * |
| 738 | * Note: This function should not be called when a mac comm port |
| 739 | * is active. |
| 740 | * |
| 741 | * Arguments: |
| 742 | * wlandev wlan device structure |
| 743 | * msgp ptr to msg buffer |
| 744 | * |
| 745 | * Returns: |
| 746 | * 0 success and done |
| 747 | * <0 success, but we're waiting for something to finish. |
| 748 | * >0 an error occurred while handling the message. |
| 749 | * Side effects: |
| 750 | * |
| 751 | * Call context: |
| 752 | * process thread (usually) |
| 753 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 754 | int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 755 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 756 | hfa384x_t *hw = wlandev->priv; |
| 757 | p80211msg_p2req_ramdl_state_t *msg = msgp; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 758 | |
| 759 | if (wlandev->msdstate != WLAN_MSD_FWLOAD) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 760 | printk(KERN_ERR |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 761 | "ramdl_state(): may only be called " |
| 762 | "in the fwload state.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 763 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 764 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 765 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 766 | return 0; |
| 767 | } |
| 768 | |
| 769 | /* |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 770 | ** Note: Interrupts are locked out if this is an AP and are NOT |
| 771 | ** locked out if this is a station. |
| 772 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 773 | |
| 774 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 775 | if (msg->enable.data == P80211ENUM_truth_true) { |
| 776 | if (hfa384x_drvr_ramdl_enable(hw, msg->exeaddr.data)) { |
| 777 | msg->resultcode.data = |
| 778 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 779 | } else { |
| 780 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 781 | } |
| 782 | } else { |
| 783 | hfa384x_drvr_ramdl_disable(hw); |
| 784 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 785 | } |
| 786 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 787 | return 0; |
| 788 | } |
| 789 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 790 | /*---------------------------------------------------------------- |
| 791 | * prism2mgmt_ramdl_write |
| 792 | * |
| 793 | * Writes a buffer to the card RAM using the download state. This |
| 794 | * is for writing code to card RAM. To just read or write raw data |
| 795 | * use the aux functions. |
| 796 | * |
| 797 | * Arguments: |
| 798 | * wlandev wlan device structure |
| 799 | * msgp ptr to msg buffer |
| 800 | * |
| 801 | * Returns: |
| 802 | * 0 success and done |
| 803 | * <0 success, but we're waiting for something to finish. |
| 804 | * >0 an error occurred while handling the message. |
| 805 | * Side effects: |
| 806 | * |
| 807 | * Call context: |
| 808 | * process thread (usually) |
| 809 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 810 | int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 811 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 812 | hfa384x_t *hw = wlandev->priv; |
| 813 | p80211msg_p2req_ramdl_write_t *msg = msgp; |
| 814 | u32 addr; |
| 815 | u32 len; |
| 816 | u8 *buf; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 817 | |
| 818 | if (wlandev->msdstate != WLAN_MSD_FWLOAD) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 819 | printk(KERN_ERR |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 820 | "ramdl_write(): may only be called " |
| 821 | "in the fwload state.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 822 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 823 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 824 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 825 | return 0; |
| 826 | } |
| 827 | |
| 828 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
| 829 | /* first validate the length */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 830 | if (msg->len.data > sizeof(msg->data.data)) { |
| 831 | msg->resultcode.status = |
| 832 | P80211ENUM_resultcode_invalid_parameters; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 833 | return 0; |
| 834 | } |
| 835 | /* call the hfa384x function to do the write */ |
| 836 | addr = msg->addr.data; |
| 837 | len = msg->len.data; |
| 838 | buf = msg->data.data; |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 839 | if (hfa384x_drvr_ramdl_write(hw, addr, buf, len)) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 840 | msg->resultcode.data = P80211ENUM_resultcode_refused; |
| 841 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 842 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 843 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 844 | return 0; |
| 845 | } |
| 846 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 847 | /*---------------------------------------------------------------- |
| 848 | * prism2mgmt_flashdl_state |
| 849 | * |
| 850 | * Establishes the beginning/end of a card Flash download session. |
| 851 | * |
| 852 | * It is expected that the flashdl_write() function will be called |
| 853 | * one or more times between the 'enable' and 'disable' calls to |
| 854 | * this function. |
| 855 | * |
| 856 | * Note: This function should not be called when a mac comm port |
| 857 | * is active. |
| 858 | * |
| 859 | * Arguments: |
| 860 | * wlandev wlan device structure |
| 861 | * msgp ptr to msg buffer |
| 862 | * |
| 863 | * Returns: |
| 864 | * 0 success and done |
| 865 | * <0 success, but we're waiting for something to finish. |
| 866 | * >0 an error occurred while handling the message. |
| 867 | * Side effects: |
| 868 | * |
| 869 | * Call context: |
| 870 | * process thread (usually) |
| 871 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 872 | int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 873 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 874 | int result = 0; |
| 875 | hfa384x_t *hw = wlandev->priv; |
| 876 | p80211msg_p2req_flashdl_state_t *msg = msgp; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 877 | |
| 878 | if (wlandev->msdstate != WLAN_MSD_FWLOAD) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 879 | printk(KERN_ERR |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 880 | "flashdl_state(): may only be called " |
| 881 | "in the fwload state.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 882 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 883 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 884 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | /* |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 889 | ** Note: Interrupts are locked out if this is an AP and are NOT |
| 890 | ** locked out if this is a station. |
| 891 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 892 | |
| 893 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 894 | if (msg->enable.data == P80211ENUM_truth_true) { |
| 895 | if (hfa384x_drvr_flashdl_enable(hw)) { |
| 896 | msg->resultcode.data = |
| 897 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 898 | } else { |
| 899 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 900 | } |
| 901 | } else { |
| 902 | hfa384x_drvr_flashdl_disable(hw); |
| 903 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 904 | /* NOTE: At this point, the MAC is in the post-reset |
| 905 | * state and the driver is in the fwload state. |
| 906 | * We need to get the MAC back into the fwload |
| 907 | * state. To do this, we set the nsdstate to HWPRESENT |
| 908 | * and then call the ifstate function to redo everything |
| 909 | * that got us into the fwload state. |
| 910 | */ |
| 911 | wlandev->msdstate = WLAN_MSD_HWPRESENT; |
| 912 | result = prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload); |
| 913 | if (result != P80211ENUM_resultcode_success) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 914 | printk(KERN_ERR "prism2sta_ifstate(fwload) failed," |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 915 | "P80211ENUM_resultcode=%d\n", result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 916 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 917 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 918 | result = -1; |
| 919 | } |
| 920 | } |
| 921 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 922 | return 0; |
| 923 | } |
| 924 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 925 | /*---------------------------------------------------------------- |
| 926 | * prism2mgmt_flashdl_write |
| 927 | * |
| 928 | * |
| 929 | * |
| 930 | * Arguments: |
| 931 | * wlandev wlan device structure |
| 932 | * msgp ptr to msg buffer |
| 933 | * |
| 934 | * Returns: |
| 935 | * 0 success and done |
| 936 | * <0 success, but we're waiting for something to finish. |
| 937 | * >0 an error occurred while handling the message. |
| 938 | * Side effects: |
| 939 | * |
| 940 | * Call context: |
| 941 | * process thread (usually) |
| 942 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 943 | int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 944 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 945 | hfa384x_t *hw = wlandev->priv; |
| 946 | p80211msg_p2req_flashdl_write_t *msg = msgp; |
| 947 | u32 addr; |
| 948 | u32 len; |
| 949 | u8 *buf; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 950 | |
| 951 | if (wlandev->msdstate != WLAN_MSD_FWLOAD) { |
Moritz Muehlenhoff | edbd606 | 2009-01-25 21:55:00 +0100 | [diff] [blame] | 952 | printk(KERN_ERR |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 953 | "flashdl_write(): may only be called " |
| 954 | "in the fwload state.\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 955 | msg->resultcode.data = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 956 | P80211ENUM_resultcode_implementation_failure; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 957 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 958 | return 0; |
| 959 | } |
| 960 | |
| 961 | /* |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 962 | ** Note: Interrupts are locked out if this is an AP and are NOT |
| 963 | ** locked out if this is a station. |
| 964 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 965 | |
| 966 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
| 967 | /* first validate the length */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 968 | if (msg->len.data > sizeof(msg->data.data)) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 969 | msg->resultcode.status = |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 970 | P80211ENUM_resultcode_invalid_parameters; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 971 | return 0; |
| 972 | } |
| 973 | /* call the hfa384x function to do the write */ |
| 974 | addr = msg->addr.data; |
| 975 | len = msg->len.data; |
| 976 | buf = msg->data.data; |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 977 | if (hfa384x_drvr_flashdl_write(hw, addr, buf, len)) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 978 | msg->resultcode.data = P80211ENUM_resultcode_refused; |
| 979 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 980 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 981 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 982 | return 0; |
| 983 | } |
| 984 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 985 | /*---------------------------------------------------------------- |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 986 | * prism2mgmt_autojoin |
| 987 | * |
| 988 | * Associate with an ESS. |
| 989 | * |
| 990 | * Arguments: |
| 991 | * wlandev wlan device structure |
| 992 | * msgp ptr to msg buffer |
| 993 | * |
| 994 | * Returns: |
| 995 | * 0 success and done |
| 996 | * <0 success, but we're waiting for something to finish. |
| 997 | * >0 an error occurred while handling the message. |
| 998 | * Side effects: |
| 999 | * |
| 1000 | * Call context: |
| 1001 | * process thread (usually) |
| 1002 | * interrupt |
| 1003 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 1004 | int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1005 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1006 | hfa384x_t *hw = wlandev->priv; |
| 1007 | int result = 0; |
| 1008 | u16 reg; |
| 1009 | u16 port_type; |
| 1010 | p80211msg_lnxreq_autojoin_t *msg = msgp; |
| 1011 | p80211pstrd_t *pstr; |
| 1012 | u8 bytebuf[256]; |
| 1013 | hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t *) bytebuf; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1014 | |
| 1015 | wlandev->macmode = WLAN_MACMODE_NONE; |
| 1016 | |
| 1017 | /* Set the SSID */ |
| 1018 | memcpy(&wlandev->ssid, &msg->ssid.data, sizeof(msg->ssid.data)); |
| 1019 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1020 | /* Disable the Port */ |
| 1021 | hfa384x_drvr_disable(hw, 0); |
| 1022 | |
| 1023 | /*** STATION ***/ |
| 1024 | /* Set the TxRates */ |
| 1025 | hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, 0x000f); |
| 1026 | |
| 1027 | /* Set the auth type */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1028 | if (msg->authtype.data == P80211ENUM_authalg_sharedkey) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1029 | reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY; |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1030 | else |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1031 | reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM; |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1032 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1033 | hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, reg); |
| 1034 | |
| 1035 | /* Set the ssid */ |
| 1036 | memset(bytebuf, 0, 256); |
Andrew Elwell | ef1a0ed | 2010-02-18 23:56:12 +0100 | [diff] [blame^] | 1037 | pstr = (p80211pstrd_t *) &(msg->ssid.data); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1038 | prism2mgmt_pstr2bytestr(p2bytestr, pstr); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1039 | result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID, |
| 1040 | bytebuf, |
| 1041 | HFA384x_RID_CNFDESIREDSSID_LEN); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1042 | port_type = HFA384x_PORTTYPE_BSS; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1043 | /* Set the PortType */ |
| 1044 | hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, port_type); |
| 1045 | |
| 1046 | /* Enable the Port */ |
| 1047 | hfa384x_drvr_enable(hw, 0); |
| 1048 | |
| 1049 | /* Set the resultcode */ |
| 1050 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
| 1051 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 1052 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1053 | return result; |
| 1054 | } |
| 1055 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1056 | /*---------------------------------------------------------------- |
| 1057 | * prism2mgmt_wlansniff |
| 1058 | * |
| 1059 | * Start or stop sniffing. |
| 1060 | * |
| 1061 | * Arguments: |
| 1062 | * wlandev wlan device structure |
| 1063 | * msgp ptr to msg buffer |
| 1064 | * |
| 1065 | * Returns: |
| 1066 | * 0 success and done |
| 1067 | * <0 success, but we're waiting for something to finish. |
| 1068 | * >0 an error occurred while handling the message. |
| 1069 | * Side effects: |
| 1070 | * |
| 1071 | * Call context: |
| 1072 | * process thread (usually) |
| 1073 | * interrupt |
| 1074 | ----------------------------------------------------------------*/ |
Mithlesh Thukral | 297f06c | 2009-06-10 19:36:11 +0530 | [diff] [blame] | 1075 | int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1076 | { |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1077 | int result = 0; |
| 1078 | p80211msg_lnxreq_wlansniff_t *msg = msgp; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1079 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1080 | hfa384x_t *hw = wlandev->priv; |
| 1081 | u16 word; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1082 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1083 | msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1084 | switch (msg->enable.data) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1085 | case P80211ENUM_truth_false: |
| 1086 | /* Confirm that we're in monitor mode */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1087 | if (wlandev->netdev->type == ARPHRD_ETHER) { |
| 1088 | msg->resultcode.data = |
| 1089 | P80211ENUM_resultcode_invalid_parameters; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1090 | result = 0; |
| 1091 | goto exit; |
| 1092 | } |
| 1093 | /* Disable monitor mode */ |
| 1094 | result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1095 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1096 | pr_debug("failed to disable monitor mode, result=%d\n", |
| 1097 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1098 | goto failed; |
| 1099 | } |
| 1100 | /* Disable port 0 */ |
| 1101 | result = hfa384x_drvr_disable(hw, 0); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1102 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1103 | pr_debug |
| 1104 | ("failed to disable port 0 after sniffing, result=%d\n", |
| 1105 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1106 | goto failed; |
| 1107 | } |
| 1108 | /* Clear the driver state */ |
| 1109 | wlandev->netdev->type = ARPHRD_ETHER; |
| 1110 | |
| 1111 | /* Restore the wepflags */ |
| 1112 | result = hfa384x_drvr_setconfig16(hw, |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1113 | HFA384x_RID_CNFWEPFLAGS, |
| 1114 | hw->presniff_wepflags); |
| 1115 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1116 | pr_debug |
| 1117 | ("failed to restore wepflags=0x%04x, result=%d\n", |
| 1118 | hw->presniff_wepflags, result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1119 | goto failed; |
| 1120 | } |
| 1121 | |
| 1122 | /* Set the port to its prior type and enable (if necessary) */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1123 | if (hw->presniff_port_type != 0) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1124 | word = hw->presniff_port_type; |
| 1125 | result = hfa384x_drvr_setconfig16(hw, |
Andrew Elwell | ef1a0ed | 2010-02-18 23:56:12 +0100 | [diff] [blame^] | 1126 | HFA384x_RID_CNFPORTTYPE, |
| 1127 | word); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1128 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1129 | pr_debug |
| 1130 | ("failed to restore porttype, result=%d\n", |
| 1131 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1132 | goto failed; |
| 1133 | } |
| 1134 | |
| 1135 | /* Enable the port */ |
| 1136 | result = hfa384x_drvr_enable(hw, 0); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1137 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1138 | pr_debug |
| 1139 | ("failed to enable port to presniff setting, result=%d\n", |
| 1140 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1141 | goto failed; |
| 1142 | } |
| 1143 | } else { |
| 1144 | result = hfa384x_drvr_disable(hw, 0); |
| 1145 | |
| 1146 | } |
| 1147 | |
Moritz Muehlenhoff | 350f2f4b | 2009-01-25 21:54:57 +0100 | [diff] [blame] | 1148 | printk(KERN_INFO "monitor mode disabled\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1149 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 1150 | result = 0; |
| 1151 | goto exit; |
| 1152 | break; |
| 1153 | case P80211ENUM_truth_true: |
| 1154 | /* Disable the port (if enabled), only check Port 0 */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1155 | if (hw->port_enabled[0]) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1156 | if (wlandev->netdev->type == ARPHRD_ETHER) { |
| 1157 | /* Save macport 0 state */ |
| 1158 | result = hfa384x_drvr_getconfig16(hw, |
Andrew Elwell | ef1a0ed | 2010-02-18 23:56:12 +0100 | [diff] [blame^] | 1159 | HFA384x_RID_CNFPORTTYPE, |
| 1160 | &(hw->presniff_port_type)); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1161 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1162 | pr_debug |
| 1163 | ("failed to read porttype, result=%d\n", |
| 1164 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1165 | goto failed; |
| 1166 | } |
| 1167 | /* Save the wepflags state */ |
| 1168 | result = hfa384x_drvr_getconfig16(hw, |
Andrew Elwell | ef1a0ed | 2010-02-18 23:56:12 +0100 | [diff] [blame^] | 1169 | HFA384x_RID_CNFWEPFLAGS, |
| 1170 | &(hw->presniff_wepflags)); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1171 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1172 | pr_debug |
| 1173 | ("failed to read wepflags, result=%d\n", |
| 1174 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1175 | goto failed; |
| 1176 | } |
| 1177 | hfa384x_drvr_stop(hw); |
| 1178 | result = hfa384x_drvr_start(hw); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1179 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1180 | pr_debug |
| 1181 | ("failed to restart the card for sniffing, result=%d\n", |
| 1182 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1183 | goto failed; |
| 1184 | } |
| 1185 | } else { |
| 1186 | /* Disable the port */ |
| 1187 | result = hfa384x_drvr_disable(hw, 0); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1188 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1189 | pr_debug |
| 1190 | ("failed to enable port for sniffing, result=%d\n", |
| 1191 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1192 | goto failed; |
| 1193 | } |
| 1194 | } |
| 1195 | } else { |
| 1196 | hw->presniff_port_type = 0; |
| 1197 | } |
| 1198 | |
| 1199 | /* Set the channel we wish to sniff */ |
| 1200 | word = msg->channel.data; |
| 1201 | result = hfa384x_drvr_setconfig16(hw, |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1202 | HFA384x_RID_CNFOWNCHANNEL, |
| 1203 | word); |
| 1204 | hw->sniff_channel = word; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1205 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1206 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1207 | pr_debug("failed to set channel %d, result=%d\n", |
| 1208 | word, result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1209 | goto failed; |
| 1210 | } |
| 1211 | |
| 1212 | /* Now if we're already sniffing, we can skip the rest */ |
| 1213 | if (wlandev->netdev->type != ARPHRD_ETHER) { |
| 1214 | /* Set the port type to pIbss */ |
| 1215 | word = HFA384x_PORTTYPE_PSUEDOIBSS; |
| 1216 | result = hfa384x_drvr_setconfig16(hw, |
Andrew Elwell | ef1a0ed | 2010-02-18 23:56:12 +0100 | [diff] [blame^] | 1217 | HFA384x_RID_CNFPORTTYPE, |
| 1218 | word); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1219 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1220 | pr_debug |
| 1221 | ("failed to set porttype %d, result=%d\n", |
| 1222 | word, result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1223 | goto failed; |
| 1224 | } |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1225 | if ((msg->keepwepflags.status == |
| 1226 | P80211ENUM_msgitem_status_data_ok) |
| 1227 | && (msg->keepwepflags.data != |
| 1228 | P80211ENUM_truth_true)) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1229 | /* Set the wepflags for no decryption */ |
| 1230 | word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1231 | HFA384x_WEPFLAGS_DISABLE_RXCRYPT; |
| 1232 | result = |
| 1233 | hfa384x_drvr_setconfig16(hw, |
Andrew Elwell | ef1a0ed | 2010-02-18 23:56:12 +0100 | [diff] [blame^] | 1234 | HFA384x_RID_CNFWEPFLAGS, |
| 1235 | word); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1236 | } |
| 1237 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1238 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1239 | pr_debug |
| 1240 | ("failed to set wepflags=0x%04x, result=%d\n", |
| 1241 | word, result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1242 | goto failed; |
| 1243 | } |
| 1244 | } |
| 1245 | |
| 1246 | /* Do we want to strip the FCS in monitor mode? */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1247 | if ((msg->stripfcs.status == P80211ENUM_msgitem_status_data_ok) |
| 1248 | && (msg->stripfcs.data == P80211ENUM_truth_true)) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1249 | hw->sniff_fcs = 0; |
| 1250 | } else { |
| 1251 | hw->sniff_fcs = 1; |
| 1252 | } |
| 1253 | |
| 1254 | /* Do we want to truncate the packets? */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1255 | if (msg->packet_trunc.status == |
| 1256 | P80211ENUM_msgitem_status_data_ok) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1257 | hw->sniff_truncate = msg->packet_trunc.data; |
| 1258 | } else { |
| 1259 | hw->sniff_truncate = 0; |
| 1260 | } |
| 1261 | |
| 1262 | /* Enable the port */ |
| 1263 | result = hfa384x_drvr_enable(hw, 0); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1264 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1265 | pr_debug |
| 1266 | ("failed to enable port for sniffing, result=%d\n", |
| 1267 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1268 | goto failed; |
| 1269 | } |
| 1270 | /* Enable monitor mode */ |
| 1271 | result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE); |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1272 | if (result) { |
Mithlesh Thukral | 75f49e0 | 2009-05-25 19:06:16 +0530 | [diff] [blame] | 1273 | pr_debug("failed to enable monitor mode, result=%d\n", |
| 1274 | result); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1275 | goto failed; |
| 1276 | } |
| 1277 | |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1278 | if (wlandev->netdev->type == ARPHRD_ETHER) |
Moritz Muehlenhoff | 350f2f4b | 2009-01-25 21:54:57 +0100 | [diff] [blame] | 1279 | printk(KERN_INFO "monitor mode enabled\n"); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1280 | |
| 1281 | /* Set the driver state */ |
| 1282 | /* Do we want the prism2 header? */ |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1283 | if ((msg->prismheader.status == |
| 1284 | P80211ENUM_msgitem_status_data_ok) |
| 1285 | && (msg->prismheader.data == P80211ENUM_truth_true)) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1286 | hw->sniffhdr = 0; |
| 1287 | wlandev->netdev->type = ARPHRD_IEEE80211_PRISM; |
Moritz Muehlenhoff | 450238e | 2009-02-08 02:20:48 +0100 | [diff] [blame] | 1288 | } else |
| 1289 | if ((msg->wlanheader.status == |
| 1290 | P80211ENUM_msgitem_status_data_ok) |
| 1291 | && (msg->wlanheader.data == P80211ENUM_truth_true)) { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1292 | hw->sniffhdr = 1; |
| 1293 | wlandev->netdev->type = ARPHRD_IEEE80211_PRISM; |
| 1294 | } else { |
| 1295 | wlandev->netdev->type = ARPHRD_IEEE80211; |
| 1296 | } |
| 1297 | |
| 1298 | msg->resultcode.data = P80211ENUM_resultcode_success; |
| 1299 | result = 0; |
| 1300 | goto exit; |
| 1301 | break; |
| 1302 | default: |
| 1303 | msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters; |
| 1304 | result = 0; |
| 1305 | goto exit; |
| 1306 | break; |
| 1307 | } |
| 1308 | |
| 1309 | failed: |
| 1310 | msg->resultcode.data = P80211ENUM_resultcode_refused; |
| 1311 | result = 0; |
| 1312 | exit: |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1313 | return result; |
| 1314 | } |