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