David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1 | /* Wireless extensions support. |
| 2 | * |
| 3 | * See copyright notice in main.c |
| 4 | */ |
| 5 | #include <linux/kernel.h> |
| 6 | #include <linux/if_arp.h> |
| 7 | #include <linux/wireless.h> |
| 8 | #include <linux/ieee80211.h> |
| 9 | #include <net/iw_handler.h> |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 10 | #include <net/cfg80211.h> |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 11 | |
| 12 | #include "hermes.h" |
| 13 | #include "hermes_rid.h" |
| 14 | #include "orinoco.h" |
| 15 | |
| 16 | #include "hw.h" |
| 17 | #include "mic.h" |
| 18 | #include "scan.h" |
| 19 | #include "main.h" |
| 20 | |
| 21 | #include "wext.h" |
| 22 | |
| 23 | #define MAX_RID_LEN 1024 |
| 24 | |
| 25 | static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev) |
| 26 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 27 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 28 | hermes_t *hw = &priv->hw; |
| 29 | struct iw_statistics *wstats = &priv->wstats; |
| 30 | int err; |
| 31 | unsigned long flags; |
| 32 | |
| 33 | if (!netif_device_present(dev)) { |
| 34 | printk(KERN_WARNING "%s: get_wireless_stats() called while device not present\n", |
| 35 | dev->name); |
| 36 | return NULL; /* FIXME: Can we do better than this? */ |
| 37 | } |
| 38 | |
| 39 | /* If busy, return the old stats. Returning NULL may cause |
| 40 | * the interface to disappear from /proc/net/wireless */ |
| 41 | if (orinoco_lock(priv, &flags) != 0) |
| 42 | return wstats; |
| 43 | |
| 44 | /* We can't really wait for the tallies inquiry command to |
| 45 | * complete, so we just use the previous results and trigger |
| 46 | * a new tallies inquiry command for next time - Jean II */ |
| 47 | /* FIXME: Really we should wait for the inquiry to come back - |
| 48 | * as it is the stats we give don't make a whole lot of sense. |
| 49 | * Unfortunately, it's not clear how to do that within the |
| 50 | * wireless extensions framework: I think we're in user |
| 51 | * context, but a lock seems to be held by the time we get in |
| 52 | * here so we're not safe to sleep here. */ |
| 53 | hermes_inquire(hw, HERMES_INQ_TALLIES); |
| 54 | |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 55 | if (priv->iw_mode == NL80211_IFTYPE_ADHOC) { |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 56 | memset(&wstats->qual, 0, sizeof(wstats->qual)); |
| 57 | /* If a spy address is defined, we report stats of the |
| 58 | * first spy address - Jean II */ |
| 59 | if (SPY_NUMBER(priv)) { |
| 60 | wstats->qual.qual = priv->spy_data.spy_stat[0].qual; |
| 61 | wstats->qual.level = priv->spy_data.spy_stat[0].level; |
| 62 | wstats->qual.noise = priv->spy_data.spy_stat[0].noise; |
| 63 | wstats->qual.updated = |
| 64 | priv->spy_data.spy_stat[0].updated; |
| 65 | } |
| 66 | } else { |
| 67 | struct { |
| 68 | __le16 qual, signal, noise, unused; |
| 69 | } __attribute__ ((packed)) cq; |
| 70 | |
| 71 | err = HERMES_READ_RECORD(hw, USER_BAP, |
| 72 | HERMES_RID_COMMSQUALITY, &cq); |
| 73 | |
| 74 | if (!err) { |
| 75 | wstats->qual.qual = (int)le16_to_cpu(cq.qual); |
| 76 | wstats->qual.level = (int)le16_to_cpu(cq.signal) - 0x95; |
| 77 | wstats->qual.noise = (int)le16_to_cpu(cq.noise) - 0x95; |
| 78 | wstats->qual.updated = |
| 79 | IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | orinoco_unlock(priv, &flags); |
| 84 | return wstats; |
| 85 | } |
| 86 | |
| 87 | /********************************************************************/ |
| 88 | /* Wireless extensions */ |
| 89 | /********************************************************************/ |
| 90 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 91 | static int orinoco_ioctl_setwap(struct net_device *dev, |
| 92 | struct iw_request_info *info, |
| 93 | struct sockaddr *ap_addr, |
| 94 | char *extra) |
| 95 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 96 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 97 | int err = -EINPROGRESS; /* Call commit handler */ |
| 98 | unsigned long flags; |
| 99 | static const u8 off_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| 100 | static const u8 any_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 101 | |
| 102 | if (orinoco_lock(priv, &flags) != 0) |
| 103 | return -EBUSY; |
| 104 | |
| 105 | /* Enable automatic roaming - no sanity checks are needed */ |
| 106 | if (memcmp(&ap_addr->sa_data, off_addr, ETH_ALEN) == 0 || |
| 107 | memcmp(&ap_addr->sa_data, any_addr, ETH_ALEN) == 0) { |
| 108 | priv->bssid_fixed = 0; |
| 109 | memset(priv->desired_bssid, 0, ETH_ALEN); |
| 110 | |
| 111 | /* "off" means keep existing connection */ |
| 112 | if (ap_addr->sa_data[0] == 0) { |
| 113 | __orinoco_hw_set_wap(priv); |
| 114 | err = 0; |
| 115 | } |
| 116 | goto out; |
| 117 | } |
| 118 | |
| 119 | if (priv->firmware_type == FIRMWARE_TYPE_AGERE) { |
| 120 | printk(KERN_WARNING "%s: Lucent/Agere firmware doesn't " |
| 121 | "support manual roaming\n", |
| 122 | dev->name); |
| 123 | err = -EOPNOTSUPP; |
| 124 | goto out; |
| 125 | } |
| 126 | |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 127 | if (priv->iw_mode != NL80211_IFTYPE_STATION) { |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 128 | printk(KERN_WARNING "%s: Manual roaming supported only in " |
| 129 | "managed mode\n", dev->name); |
| 130 | err = -EOPNOTSUPP; |
| 131 | goto out; |
| 132 | } |
| 133 | |
| 134 | /* Intersil firmware hangs without Desired ESSID */ |
| 135 | if (priv->firmware_type == FIRMWARE_TYPE_INTERSIL && |
| 136 | strlen(priv->desired_essid) == 0) { |
| 137 | printk(KERN_WARNING "%s: Desired ESSID must be set for " |
| 138 | "manual roaming\n", dev->name); |
| 139 | err = -EOPNOTSUPP; |
| 140 | goto out; |
| 141 | } |
| 142 | |
| 143 | /* Finally, enable manual roaming */ |
| 144 | priv->bssid_fixed = 1; |
| 145 | memcpy(priv->desired_bssid, &ap_addr->sa_data, ETH_ALEN); |
| 146 | |
| 147 | out: |
| 148 | orinoco_unlock(priv, &flags); |
| 149 | return err; |
| 150 | } |
| 151 | |
| 152 | static int orinoco_ioctl_getwap(struct net_device *dev, |
| 153 | struct iw_request_info *info, |
| 154 | struct sockaddr *ap_addr, |
| 155 | char *extra) |
| 156 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 157 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 158 | |
| 159 | hermes_t *hw = &priv->hw; |
| 160 | int err = 0; |
| 161 | unsigned long flags; |
| 162 | |
| 163 | if (orinoco_lock(priv, &flags) != 0) |
| 164 | return -EBUSY; |
| 165 | |
| 166 | ap_addr->sa_family = ARPHRD_ETHER; |
| 167 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID, |
| 168 | ETH_ALEN, NULL, ap_addr->sa_data); |
| 169 | |
| 170 | orinoco_unlock(priv, &flags); |
| 171 | |
| 172 | return err; |
| 173 | } |
| 174 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 175 | static int orinoco_ioctl_setiwencode(struct net_device *dev, |
| 176 | struct iw_request_info *info, |
| 177 | struct iw_point *erq, |
| 178 | char *keybuf) |
| 179 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 180 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 181 | int index = (erq->flags & IW_ENCODE_INDEX) - 1; |
| 182 | int setindex = priv->tx_key; |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 183 | enum orinoco_alg encode_alg = priv->encode_alg; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 184 | int restricted = priv->wep_restrict; |
| 185 | u16 xlen = 0; |
| 186 | int err = -EINPROGRESS; /* Call commit handler */ |
| 187 | unsigned long flags; |
| 188 | |
| 189 | if (!priv->has_wep) |
| 190 | return -EOPNOTSUPP; |
| 191 | |
| 192 | if (erq->pointer) { |
| 193 | /* We actually have a key to set - check its length */ |
| 194 | if (erq->length > LARGE_KEY_SIZE) |
| 195 | return -E2BIG; |
| 196 | |
| 197 | if ((erq->length > SMALL_KEY_SIZE) && !priv->has_big_wep) |
| 198 | return -E2BIG; |
| 199 | } |
| 200 | |
| 201 | if (orinoco_lock(priv, &flags) != 0) |
| 202 | return -EBUSY; |
| 203 | |
| 204 | /* Clear any TKIP key we have */ |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 205 | if ((priv->has_wpa) && (priv->encode_alg == ORINOCO_ALG_TKIP)) |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 206 | (void) orinoco_clear_tkip_key(priv, setindex); |
| 207 | |
| 208 | if (erq->length > 0) { |
| 209 | if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) |
| 210 | index = priv->tx_key; |
| 211 | |
| 212 | /* Adjust key length to a supported value */ |
| 213 | if (erq->length > SMALL_KEY_SIZE) |
| 214 | xlen = LARGE_KEY_SIZE; |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 215 | else /* (erq->length > 0) */ |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 216 | xlen = SMALL_KEY_SIZE; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 217 | |
| 218 | /* Switch on WEP if off */ |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 219 | if (encode_alg != ORINOCO_ALG_WEP) { |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 220 | setindex = index; |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 221 | encode_alg = ORINOCO_ALG_WEP; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 222 | } |
| 223 | } else { |
| 224 | /* Important note : if the user do "iwconfig eth0 enc off", |
| 225 | * we will arrive there with an index of -1. This is valid |
| 226 | * but need to be taken care off... Jean II */ |
| 227 | if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) { |
| 228 | if ((index != -1) || (erq->flags == 0)) { |
| 229 | err = -EINVAL; |
| 230 | goto out; |
| 231 | } |
| 232 | } else { |
| 233 | /* Set the index : Check that the key is valid */ |
| 234 | if (priv->keys[index].len == 0) { |
| 235 | err = -EINVAL; |
| 236 | goto out; |
| 237 | } |
| 238 | setindex = index; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | if (erq->flags & IW_ENCODE_DISABLED) |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 243 | encode_alg = ORINOCO_ALG_NONE; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 244 | if (erq->flags & IW_ENCODE_OPEN) |
| 245 | restricted = 0; |
| 246 | if (erq->flags & IW_ENCODE_RESTRICTED) |
| 247 | restricted = 1; |
| 248 | |
| 249 | if (erq->pointer && erq->length > 0) { |
| 250 | priv->keys[index].len = cpu_to_le16(xlen); |
| 251 | memset(priv->keys[index].data, 0, |
| 252 | sizeof(priv->keys[index].data)); |
| 253 | memcpy(priv->keys[index].data, keybuf, erq->length); |
| 254 | } |
| 255 | priv->tx_key = setindex; |
| 256 | |
| 257 | /* Try fast key change if connected and only keys are changed */ |
| 258 | if ((priv->encode_alg == encode_alg) && |
| 259 | (priv->wep_restrict == restricted) && |
| 260 | netif_carrier_ok(dev)) { |
| 261 | err = __orinoco_hw_setup_wepkeys(priv); |
| 262 | /* No need to commit if successful */ |
| 263 | goto out; |
| 264 | } |
| 265 | |
| 266 | priv->encode_alg = encode_alg; |
| 267 | priv->wep_restrict = restricted; |
| 268 | |
| 269 | out: |
| 270 | orinoco_unlock(priv, &flags); |
| 271 | |
| 272 | return err; |
| 273 | } |
| 274 | |
| 275 | static int orinoco_ioctl_getiwencode(struct net_device *dev, |
| 276 | struct iw_request_info *info, |
| 277 | struct iw_point *erq, |
| 278 | char *keybuf) |
| 279 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 280 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 281 | int index = (erq->flags & IW_ENCODE_INDEX) - 1; |
| 282 | u16 xlen = 0; |
| 283 | unsigned long flags; |
| 284 | |
| 285 | if (!priv->has_wep) |
| 286 | return -EOPNOTSUPP; |
| 287 | |
| 288 | if (orinoco_lock(priv, &flags) != 0) |
| 289 | return -EBUSY; |
| 290 | |
| 291 | if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) |
| 292 | index = priv->tx_key; |
| 293 | |
| 294 | erq->flags = 0; |
| 295 | if (!priv->encode_alg) |
| 296 | erq->flags |= IW_ENCODE_DISABLED; |
| 297 | erq->flags |= index + 1; |
| 298 | |
| 299 | if (priv->wep_restrict) |
| 300 | erq->flags |= IW_ENCODE_RESTRICTED; |
| 301 | else |
| 302 | erq->flags |= IW_ENCODE_OPEN; |
| 303 | |
| 304 | xlen = le16_to_cpu(priv->keys[index].len); |
| 305 | |
| 306 | erq->length = xlen; |
| 307 | |
| 308 | memcpy(keybuf, priv->keys[index].data, ORINOCO_MAX_KEY_SIZE); |
| 309 | |
| 310 | orinoco_unlock(priv, &flags); |
| 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | static int orinoco_ioctl_setessid(struct net_device *dev, |
| 315 | struct iw_request_info *info, |
| 316 | struct iw_point *erq, |
| 317 | char *essidbuf) |
| 318 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 319 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 320 | unsigned long flags; |
| 321 | |
| 322 | /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it |
| 323 | * anyway... - Jean II */ |
| 324 | |
| 325 | /* Hum... Should not use Wireless Extension constant (may change), |
| 326 | * should use our own... - Jean II */ |
| 327 | if (erq->length > IW_ESSID_MAX_SIZE) |
| 328 | return -E2BIG; |
| 329 | |
| 330 | if (orinoco_lock(priv, &flags) != 0) |
| 331 | return -EBUSY; |
| 332 | |
| 333 | /* NULL the string (for NULL termination & ESSID = ANY) - Jean II */ |
| 334 | memset(priv->desired_essid, 0, sizeof(priv->desired_essid)); |
| 335 | |
| 336 | /* If not ANY, get the new ESSID */ |
| 337 | if (erq->flags) |
| 338 | memcpy(priv->desired_essid, essidbuf, erq->length); |
| 339 | |
| 340 | orinoco_unlock(priv, &flags); |
| 341 | |
| 342 | return -EINPROGRESS; /* Call commit handler */ |
| 343 | } |
| 344 | |
| 345 | static int orinoco_ioctl_getessid(struct net_device *dev, |
| 346 | struct iw_request_info *info, |
| 347 | struct iw_point *erq, |
| 348 | char *essidbuf) |
| 349 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 350 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 351 | int active; |
| 352 | int err = 0; |
| 353 | unsigned long flags; |
| 354 | |
| 355 | if (netif_running(dev)) { |
| 356 | err = orinoco_hw_get_essid(priv, &active, essidbuf); |
| 357 | if (err < 0) |
| 358 | return err; |
| 359 | erq->length = err; |
| 360 | } else { |
| 361 | if (orinoco_lock(priv, &flags) != 0) |
| 362 | return -EBUSY; |
| 363 | memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE); |
| 364 | erq->length = strlen(priv->desired_essid); |
| 365 | orinoco_unlock(priv, &flags); |
| 366 | } |
| 367 | |
| 368 | erq->flags = 1; |
| 369 | |
| 370 | return 0; |
| 371 | } |
| 372 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 373 | static int orinoco_ioctl_setfreq(struct net_device *dev, |
| 374 | struct iw_request_info *info, |
| 375 | struct iw_freq *frq, |
| 376 | char *extra) |
| 377 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 378 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 379 | int chan = -1; |
| 380 | unsigned long flags; |
| 381 | int err = -EINPROGRESS; /* Call commit handler */ |
| 382 | |
| 383 | /* In infrastructure mode the AP sets the channel */ |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 384 | if (priv->iw_mode == NL80211_IFTYPE_STATION) |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 385 | return -EBUSY; |
| 386 | |
| 387 | if ((frq->e == 0) && (frq->m <= 1000)) { |
| 388 | /* Setting by channel number */ |
| 389 | chan = frq->m; |
| 390 | } else { |
| 391 | /* Setting by frequency */ |
| 392 | int denom = 1; |
| 393 | int i; |
| 394 | |
| 395 | /* Calculate denominator to rescale to MHz */ |
| 396 | for (i = 0; i < (6 - frq->e); i++) |
| 397 | denom *= 10; |
| 398 | |
| 399 | chan = ieee80211_freq_to_dsss_chan(frq->m / denom); |
| 400 | } |
| 401 | |
| 402 | if ((chan < 1) || (chan > NUM_CHANNELS) || |
| 403 | !(priv->channel_mask & (1 << (chan-1)))) |
| 404 | return -EINVAL; |
| 405 | |
| 406 | if (orinoco_lock(priv, &flags) != 0) |
| 407 | return -EBUSY; |
| 408 | |
| 409 | priv->channel = chan; |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 410 | if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 411 | /* Fast channel change - no commit if successful */ |
| 412 | hermes_t *hw = &priv->hw; |
| 413 | err = hermes_docmd_wait(hw, HERMES_CMD_TEST | |
| 414 | HERMES_TEST_SET_CHANNEL, |
| 415 | chan, NULL); |
| 416 | } |
| 417 | orinoco_unlock(priv, &flags); |
| 418 | |
| 419 | return err; |
| 420 | } |
| 421 | |
| 422 | static int orinoco_ioctl_getfreq(struct net_device *dev, |
| 423 | struct iw_request_info *info, |
| 424 | struct iw_freq *frq, |
| 425 | char *extra) |
| 426 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 427 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 428 | int tmp; |
| 429 | |
| 430 | /* Locking done in there */ |
| 431 | tmp = orinoco_hw_get_freq(priv); |
| 432 | if (tmp < 0) |
| 433 | return tmp; |
| 434 | |
| 435 | frq->m = tmp * 100000; |
| 436 | frq->e = 1; |
| 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | static int orinoco_ioctl_getsens(struct net_device *dev, |
| 442 | struct iw_request_info *info, |
| 443 | struct iw_param *srq, |
| 444 | char *extra) |
| 445 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 446 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 447 | hermes_t *hw = &priv->hw; |
| 448 | u16 val; |
| 449 | int err; |
| 450 | unsigned long flags; |
| 451 | |
| 452 | if (!priv->has_sensitivity) |
| 453 | return -EOPNOTSUPP; |
| 454 | |
| 455 | if (orinoco_lock(priv, &flags) != 0) |
| 456 | return -EBUSY; |
| 457 | err = hermes_read_wordrec(hw, USER_BAP, |
| 458 | HERMES_RID_CNFSYSTEMSCALE, &val); |
| 459 | orinoco_unlock(priv, &flags); |
| 460 | |
| 461 | if (err) |
| 462 | return err; |
| 463 | |
| 464 | srq->value = val; |
| 465 | srq->fixed = 0; /* auto */ |
| 466 | |
| 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | static int orinoco_ioctl_setsens(struct net_device *dev, |
| 471 | struct iw_request_info *info, |
| 472 | struct iw_param *srq, |
| 473 | char *extra) |
| 474 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 475 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 476 | int val = srq->value; |
| 477 | unsigned long flags; |
| 478 | |
| 479 | if (!priv->has_sensitivity) |
| 480 | return -EOPNOTSUPP; |
| 481 | |
| 482 | if ((val < 1) || (val > 3)) |
| 483 | return -EINVAL; |
| 484 | |
| 485 | if (orinoco_lock(priv, &flags) != 0) |
| 486 | return -EBUSY; |
| 487 | priv->ap_density = val; |
| 488 | orinoco_unlock(priv, &flags); |
| 489 | |
| 490 | return -EINPROGRESS; /* Call commit handler */ |
| 491 | } |
| 492 | |
| 493 | static int orinoco_ioctl_setrts(struct net_device *dev, |
| 494 | struct iw_request_info *info, |
| 495 | struct iw_param *rrq, |
| 496 | char *extra) |
| 497 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 498 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 499 | int val = rrq->value; |
| 500 | unsigned long flags; |
| 501 | |
| 502 | if (rrq->disabled) |
| 503 | val = 2347; |
| 504 | |
| 505 | if ((val < 0) || (val > 2347)) |
| 506 | return -EINVAL; |
| 507 | |
| 508 | if (orinoco_lock(priv, &flags) != 0) |
| 509 | return -EBUSY; |
| 510 | |
| 511 | priv->rts_thresh = val; |
| 512 | orinoco_unlock(priv, &flags); |
| 513 | |
| 514 | return -EINPROGRESS; /* Call commit handler */ |
| 515 | } |
| 516 | |
| 517 | static int orinoco_ioctl_getrts(struct net_device *dev, |
| 518 | struct iw_request_info *info, |
| 519 | struct iw_param *rrq, |
| 520 | char *extra) |
| 521 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 522 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 523 | |
| 524 | rrq->value = priv->rts_thresh; |
| 525 | rrq->disabled = (rrq->value == 2347); |
| 526 | rrq->fixed = 1; |
| 527 | |
| 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | static int orinoco_ioctl_setfrag(struct net_device *dev, |
| 532 | struct iw_request_info *info, |
| 533 | struct iw_param *frq, |
| 534 | char *extra) |
| 535 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 536 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 537 | int err = -EINPROGRESS; /* Call commit handler */ |
| 538 | unsigned long flags; |
| 539 | |
| 540 | if (orinoco_lock(priv, &flags) != 0) |
| 541 | return -EBUSY; |
| 542 | |
| 543 | if (priv->has_mwo) { |
| 544 | if (frq->disabled) |
| 545 | priv->mwo_robust = 0; |
| 546 | else { |
| 547 | if (frq->fixed) |
| 548 | printk(KERN_WARNING "%s: Fixed fragmentation " |
| 549 | "is not supported on this firmware. " |
| 550 | "Using MWO robust instead.\n", |
| 551 | dev->name); |
| 552 | priv->mwo_robust = 1; |
| 553 | } |
| 554 | } else { |
| 555 | if (frq->disabled) |
| 556 | priv->frag_thresh = 2346; |
| 557 | else { |
| 558 | if ((frq->value < 256) || (frq->value > 2346)) |
| 559 | err = -EINVAL; |
| 560 | else |
| 561 | /* must be even */ |
| 562 | priv->frag_thresh = frq->value & ~0x1; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | orinoco_unlock(priv, &flags); |
| 567 | |
| 568 | return err; |
| 569 | } |
| 570 | |
| 571 | static int orinoco_ioctl_getfrag(struct net_device *dev, |
| 572 | struct iw_request_info *info, |
| 573 | struct iw_param *frq, |
| 574 | char *extra) |
| 575 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 576 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 577 | hermes_t *hw = &priv->hw; |
| 578 | int err; |
| 579 | u16 val; |
| 580 | unsigned long flags; |
| 581 | |
| 582 | if (orinoco_lock(priv, &flags) != 0) |
| 583 | return -EBUSY; |
| 584 | |
| 585 | if (priv->has_mwo) { |
| 586 | err = hermes_read_wordrec(hw, USER_BAP, |
| 587 | HERMES_RID_CNFMWOROBUST_AGERE, |
| 588 | &val); |
| 589 | if (err) |
| 590 | val = 0; |
| 591 | |
| 592 | frq->value = val ? 2347 : 0; |
| 593 | frq->disabled = !val; |
| 594 | frq->fixed = 0; |
| 595 | } else { |
| 596 | err = hermes_read_wordrec(hw, USER_BAP, |
| 597 | HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, |
| 598 | &val); |
| 599 | if (err) |
| 600 | val = 0; |
| 601 | |
| 602 | frq->value = val; |
| 603 | frq->disabled = (val >= 2346); |
| 604 | frq->fixed = 1; |
| 605 | } |
| 606 | |
| 607 | orinoco_unlock(priv, &flags); |
| 608 | |
| 609 | return err; |
| 610 | } |
| 611 | |
| 612 | static int orinoco_ioctl_setrate(struct net_device *dev, |
| 613 | struct iw_request_info *info, |
| 614 | struct iw_param *rrq, |
| 615 | char *extra) |
| 616 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 617 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 618 | int ratemode; |
| 619 | int bitrate; /* 100s of kilobits */ |
| 620 | unsigned long flags; |
| 621 | |
| 622 | /* As the user space doesn't know our highest rate, it uses -1 |
| 623 | * to ask us to set the highest rate. Test it using "iwconfig |
| 624 | * ethX rate auto" - Jean II */ |
| 625 | if (rrq->value == -1) |
| 626 | bitrate = 110; |
| 627 | else { |
| 628 | if (rrq->value % 100000) |
| 629 | return -EINVAL; |
| 630 | bitrate = rrq->value / 100000; |
| 631 | } |
| 632 | |
| 633 | ratemode = orinoco_get_bitratemode(bitrate, !rrq->fixed); |
| 634 | |
| 635 | if (ratemode == -1) |
| 636 | return -EINVAL; |
| 637 | |
| 638 | if (orinoco_lock(priv, &flags) != 0) |
| 639 | return -EBUSY; |
| 640 | priv->bitratemode = ratemode; |
| 641 | orinoco_unlock(priv, &flags); |
| 642 | |
| 643 | return -EINPROGRESS; |
| 644 | } |
| 645 | |
| 646 | static int orinoco_ioctl_getrate(struct net_device *dev, |
| 647 | struct iw_request_info *info, |
| 648 | struct iw_param *rrq, |
| 649 | char *extra) |
| 650 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 651 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 652 | int err = 0; |
| 653 | int bitrate, automatic; |
| 654 | unsigned long flags; |
| 655 | |
| 656 | if (orinoco_lock(priv, &flags) != 0) |
| 657 | return -EBUSY; |
| 658 | |
| 659 | orinoco_get_ratemode_cfg(priv->bitratemode, &bitrate, &automatic); |
| 660 | |
| 661 | /* If the interface is running we try to find more about the |
| 662 | current mode */ |
| 663 | if (netif_running(dev)) |
| 664 | err = orinoco_hw_get_act_bitrate(priv, &bitrate); |
| 665 | |
| 666 | orinoco_unlock(priv, &flags); |
| 667 | |
| 668 | rrq->value = bitrate; |
| 669 | rrq->fixed = !automatic; |
| 670 | rrq->disabled = 0; |
| 671 | |
| 672 | return err; |
| 673 | } |
| 674 | |
| 675 | static int orinoco_ioctl_setpower(struct net_device *dev, |
| 676 | struct iw_request_info *info, |
| 677 | struct iw_param *prq, |
| 678 | char *extra) |
| 679 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 680 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 681 | int err = -EINPROGRESS; /* Call commit handler */ |
| 682 | unsigned long flags; |
| 683 | |
| 684 | if (orinoco_lock(priv, &flags) != 0) |
| 685 | return -EBUSY; |
| 686 | |
| 687 | if (prq->disabled) { |
| 688 | priv->pm_on = 0; |
| 689 | } else { |
| 690 | switch (prq->flags & IW_POWER_MODE) { |
| 691 | case IW_POWER_UNICAST_R: |
| 692 | priv->pm_mcast = 0; |
| 693 | priv->pm_on = 1; |
| 694 | break; |
| 695 | case IW_POWER_ALL_R: |
| 696 | priv->pm_mcast = 1; |
| 697 | priv->pm_on = 1; |
| 698 | break; |
| 699 | case IW_POWER_ON: |
| 700 | /* No flags : but we may have a value - Jean II */ |
| 701 | break; |
| 702 | default: |
| 703 | err = -EINVAL; |
| 704 | goto out; |
| 705 | } |
| 706 | |
| 707 | if (prq->flags & IW_POWER_TIMEOUT) { |
| 708 | priv->pm_on = 1; |
| 709 | priv->pm_timeout = prq->value / 1000; |
| 710 | } |
| 711 | if (prq->flags & IW_POWER_PERIOD) { |
| 712 | priv->pm_on = 1; |
| 713 | priv->pm_period = prq->value / 1000; |
| 714 | } |
| 715 | /* It's valid to not have a value if we are just toggling |
| 716 | * the flags... Jean II */ |
| 717 | if (!priv->pm_on) { |
| 718 | err = -EINVAL; |
| 719 | goto out; |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | out: |
| 724 | orinoco_unlock(priv, &flags); |
| 725 | |
| 726 | return err; |
| 727 | } |
| 728 | |
| 729 | static int orinoco_ioctl_getpower(struct net_device *dev, |
| 730 | struct iw_request_info *info, |
| 731 | struct iw_param *prq, |
| 732 | char *extra) |
| 733 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 734 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 735 | hermes_t *hw = &priv->hw; |
| 736 | int err = 0; |
| 737 | u16 enable, period, timeout, mcast; |
| 738 | unsigned long flags; |
| 739 | |
| 740 | if (orinoco_lock(priv, &flags) != 0) |
| 741 | return -EBUSY; |
| 742 | |
| 743 | err = hermes_read_wordrec(hw, USER_BAP, |
| 744 | HERMES_RID_CNFPMENABLED, &enable); |
| 745 | if (err) |
| 746 | goto out; |
| 747 | |
| 748 | err = hermes_read_wordrec(hw, USER_BAP, |
| 749 | HERMES_RID_CNFMAXSLEEPDURATION, &period); |
| 750 | if (err) |
| 751 | goto out; |
| 752 | |
| 753 | err = hermes_read_wordrec(hw, USER_BAP, |
| 754 | HERMES_RID_CNFPMHOLDOVERDURATION, &timeout); |
| 755 | if (err) |
| 756 | goto out; |
| 757 | |
| 758 | err = hermes_read_wordrec(hw, USER_BAP, |
| 759 | HERMES_RID_CNFMULTICASTRECEIVE, &mcast); |
| 760 | if (err) |
| 761 | goto out; |
| 762 | |
| 763 | prq->disabled = !enable; |
| 764 | /* Note : by default, display the period */ |
| 765 | if ((prq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { |
| 766 | prq->flags = IW_POWER_TIMEOUT; |
| 767 | prq->value = timeout * 1000; |
| 768 | } else { |
| 769 | prq->flags = IW_POWER_PERIOD; |
| 770 | prq->value = period * 1000; |
| 771 | } |
| 772 | if (mcast) |
| 773 | prq->flags |= IW_POWER_ALL_R; |
| 774 | else |
| 775 | prq->flags |= IW_POWER_UNICAST_R; |
| 776 | |
| 777 | out: |
| 778 | orinoco_unlock(priv, &flags); |
| 779 | |
| 780 | return err; |
| 781 | } |
| 782 | |
| 783 | static int orinoco_ioctl_set_encodeext(struct net_device *dev, |
| 784 | struct iw_request_info *info, |
| 785 | union iwreq_data *wrqu, |
| 786 | char *extra) |
| 787 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 788 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 789 | struct iw_point *encoding = &wrqu->encoding; |
| 790 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
| 791 | int idx, alg = ext->alg, set_key = 1; |
| 792 | unsigned long flags; |
| 793 | int err = -EINVAL; |
| 794 | u16 key_len; |
| 795 | |
| 796 | if (orinoco_lock(priv, &flags) != 0) |
| 797 | return -EBUSY; |
| 798 | |
| 799 | /* Determine and validate the key index */ |
| 800 | idx = encoding->flags & IW_ENCODE_INDEX; |
| 801 | if (idx) { |
| 802 | if ((idx < 1) || (idx > 4)) |
| 803 | goto out; |
| 804 | idx--; |
| 805 | } else |
| 806 | idx = priv->tx_key; |
| 807 | |
| 808 | if (encoding->flags & IW_ENCODE_DISABLED) |
| 809 | alg = IW_ENCODE_ALG_NONE; |
| 810 | |
| 811 | if (priv->has_wpa && (alg != IW_ENCODE_ALG_TKIP)) { |
| 812 | /* Clear any TKIP TX key we had */ |
| 813 | (void) orinoco_clear_tkip_key(priv, priv->tx_key); |
| 814 | } |
| 815 | |
| 816 | if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { |
| 817 | priv->tx_key = idx; |
| 818 | set_key = ((alg == IW_ENCODE_ALG_TKIP) || |
| 819 | (ext->key_len > 0)) ? 1 : 0; |
| 820 | } |
| 821 | |
| 822 | if (set_key) { |
| 823 | /* Set the requested key first */ |
| 824 | switch (alg) { |
| 825 | case IW_ENCODE_ALG_NONE: |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 826 | priv->encode_alg = ORINOCO_ALG_NONE; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 827 | priv->keys[idx].len = 0; |
| 828 | break; |
| 829 | |
| 830 | case IW_ENCODE_ALG_WEP: |
| 831 | if (ext->key_len > SMALL_KEY_SIZE) |
| 832 | key_len = LARGE_KEY_SIZE; |
| 833 | else if (ext->key_len > 0) |
| 834 | key_len = SMALL_KEY_SIZE; |
| 835 | else |
| 836 | goto out; |
| 837 | |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 838 | priv->encode_alg = ORINOCO_ALG_WEP; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 839 | priv->keys[idx].len = cpu_to_le16(key_len); |
| 840 | |
| 841 | key_len = min(ext->key_len, key_len); |
| 842 | |
| 843 | memset(priv->keys[idx].data, 0, ORINOCO_MAX_KEY_SIZE); |
| 844 | memcpy(priv->keys[idx].data, ext->key, key_len); |
| 845 | break; |
| 846 | |
| 847 | case IW_ENCODE_ALG_TKIP: |
| 848 | { |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 849 | u8 *tkip_iv = NULL; |
| 850 | |
| 851 | if (!priv->has_wpa || |
| 852 | (ext->key_len > sizeof(priv->tkip_key[0]))) |
| 853 | goto out; |
| 854 | |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 855 | priv->encode_alg = ORINOCO_ALG_TKIP; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 856 | memset(&priv->tkip_key[idx], 0, |
| 857 | sizeof(priv->tkip_key[idx])); |
| 858 | memcpy(&priv->tkip_key[idx], ext->key, ext->key_len); |
| 859 | |
| 860 | if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) |
| 861 | tkip_iv = &ext->rx_seq[0]; |
| 862 | |
David Kilroy | 98e5f40 | 2009-06-18 23:21:25 +0100 | [diff] [blame] | 863 | err = __orinoco_hw_set_tkip_key(priv, idx, |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 864 | ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, |
| 865 | (u8 *) &priv->tkip_key[idx], |
| 866 | tkip_iv, NULL); |
| 867 | if (err) |
| 868 | printk(KERN_ERR "%s: Error %d setting TKIP key" |
| 869 | "\n", dev->name, err); |
| 870 | |
| 871 | goto out; |
| 872 | } |
| 873 | default: |
| 874 | goto out; |
| 875 | } |
| 876 | } |
| 877 | err = -EINPROGRESS; |
| 878 | out: |
| 879 | orinoco_unlock(priv, &flags); |
| 880 | |
| 881 | return err; |
| 882 | } |
| 883 | |
| 884 | static int orinoco_ioctl_get_encodeext(struct net_device *dev, |
| 885 | struct iw_request_info *info, |
| 886 | union iwreq_data *wrqu, |
| 887 | char *extra) |
| 888 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 889 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 890 | struct iw_point *encoding = &wrqu->encoding; |
| 891 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
| 892 | int idx, max_key_len; |
| 893 | unsigned long flags; |
| 894 | int err; |
| 895 | |
| 896 | if (orinoco_lock(priv, &flags) != 0) |
| 897 | return -EBUSY; |
| 898 | |
| 899 | err = -EINVAL; |
| 900 | max_key_len = encoding->length - sizeof(*ext); |
| 901 | if (max_key_len < 0) |
| 902 | goto out; |
| 903 | |
| 904 | idx = encoding->flags & IW_ENCODE_INDEX; |
| 905 | if (idx) { |
| 906 | if ((idx < 1) || (idx > 4)) |
| 907 | goto out; |
| 908 | idx--; |
| 909 | } else |
| 910 | idx = priv->tx_key; |
| 911 | |
| 912 | encoding->flags = idx + 1; |
| 913 | memset(ext, 0, sizeof(*ext)); |
| 914 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 915 | switch (priv->encode_alg) { |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 916 | case ORINOCO_ALG_NONE: |
| 917 | ext->alg = IW_ENCODE_ALG_NONE; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 918 | ext->key_len = 0; |
| 919 | encoding->flags |= IW_ENCODE_DISABLED; |
| 920 | break; |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 921 | case ORINOCO_ALG_WEP: |
| 922 | ext->alg = IW_ENCODE_ALG_WEP; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 923 | ext->key_len = min_t(u16, le16_to_cpu(priv->keys[idx].len), |
| 924 | max_key_len); |
| 925 | memcpy(ext->key, priv->keys[idx].data, ext->key_len); |
| 926 | encoding->flags |= IW_ENCODE_ENABLED; |
| 927 | break; |
David Kilroy | 5c9f41e | 2009-08-05 21:23:28 +0100 | [diff] [blame^] | 928 | case ORINOCO_ALG_TKIP: |
| 929 | ext->alg = IW_ENCODE_ALG_TKIP; |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 930 | ext->key_len = min_t(u16, sizeof(struct orinoco_tkip_key), |
| 931 | max_key_len); |
| 932 | memcpy(ext->key, &priv->tkip_key[idx], ext->key_len); |
| 933 | encoding->flags |= IW_ENCODE_ENABLED; |
| 934 | break; |
| 935 | } |
| 936 | |
| 937 | err = 0; |
| 938 | out: |
| 939 | orinoco_unlock(priv, &flags); |
| 940 | |
| 941 | return err; |
| 942 | } |
| 943 | |
| 944 | static int orinoco_ioctl_set_auth(struct net_device *dev, |
| 945 | struct iw_request_info *info, |
| 946 | union iwreq_data *wrqu, char *extra) |
| 947 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 948 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 949 | hermes_t *hw = &priv->hw; |
| 950 | struct iw_param *param = &wrqu->param; |
| 951 | unsigned long flags; |
| 952 | int ret = -EINPROGRESS; |
| 953 | |
| 954 | if (orinoco_lock(priv, &flags) != 0) |
| 955 | return -EBUSY; |
| 956 | |
| 957 | switch (param->flags & IW_AUTH_INDEX) { |
| 958 | case IW_AUTH_WPA_VERSION: |
| 959 | case IW_AUTH_CIPHER_PAIRWISE: |
| 960 | case IW_AUTH_CIPHER_GROUP: |
| 961 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: |
| 962 | case IW_AUTH_PRIVACY_INVOKED: |
| 963 | case IW_AUTH_DROP_UNENCRYPTED: |
| 964 | /* |
| 965 | * orinoco does not use these parameters |
| 966 | */ |
| 967 | break; |
| 968 | |
| 969 | case IW_AUTH_KEY_MGMT: |
| 970 | /* wl_lkm implies value 2 == PSK for Hermes I |
| 971 | * which ties in with WEXT |
| 972 | * no other hints tho :( |
| 973 | */ |
| 974 | priv->key_mgmt = param->value; |
| 975 | break; |
| 976 | |
| 977 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 978 | /* When countermeasures are enabled, shut down the |
| 979 | * card; when disabled, re-enable the card. This must |
| 980 | * take effect immediately. |
| 981 | * |
| 982 | * TODO: Make sure that the EAPOL message is getting |
| 983 | * out before card disabled |
| 984 | */ |
| 985 | if (param->value) { |
| 986 | priv->tkip_cm_active = 1; |
| 987 | ret = hermes_enable_port(hw, 0); |
| 988 | } else { |
| 989 | priv->tkip_cm_active = 0; |
| 990 | ret = hermes_disable_port(hw, 0); |
| 991 | } |
| 992 | break; |
| 993 | |
| 994 | case IW_AUTH_80211_AUTH_ALG: |
| 995 | if (param->value & IW_AUTH_ALG_SHARED_KEY) |
| 996 | priv->wep_restrict = 1; |
| 997 | else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) |
| 998 | priv->wep_restrict = 0; |
| 999 | else |
| 1000 | ret = -EINVAL; |
| 1001 | break; |
| 1002 | |
| 1003 | case IW_AUTH_WPA_ENABLED: |
| 1004 | if (priv->has_wpa) { |
| 1005 | priv->wpa_enabled = param->value ? 1 : 0; |
| 1006 | } else { |
| 1007 | if (param->value) |
| 1008 | ret = -EOPNOTSUPP; |
| 1009 | /* else silently accept disable of WPA */ |
| 1010 | priv->wpa_enabled = 0; |
| 1011 | } |
| 1012 | break; |
| 1013 | |
| 1014 | default: |
| 1015 | ret = -EOPNOTSUPP; |
| 1016 | } |
| 1017 | |
| 1018 | orinoco_unlock(priv, &flags); |
| 1019 | return ret; |
| 1020 | } |
| 1021 | |
| 1022 | static int orinoco_ioctl_get_auth(struct net_device *dev, |
| 1023 | struct iw_request_info *info, |
| 1024 | union iwreq_data *wrqu, char *extra) |
| 1025 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1026 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1027 | struct iw_param *param = &wrqu->param; |
| 1028 | unsigned long flags; |
| 1029 | int ret = 0; |
| 1030 | |
| 1031 | if (orinoco_lock(priv, &flags) != 0) |
| 1032 | return -EBUSY; |
| 1033 | |
| 1034 | switch (param->flags & IW_AUTH_INDEX) { |
| 1035 | case IW_AUTH_KEY_MGMT: |
| 1036 | param->value = priv->key_mgmt; |
| 1037 | break; |
| 1038 | |
| 1039 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 1040 | param->value = priv->tkip_cm_active; |
| 1041 | break; |
| 1042 | |
| 1043 | case IW_AUTH_80211_AUTH_ALG: |
| 1044 | if (priv->wep_restrict) |
| 1045 | param->value = IW_AUTH_ALG_SHARED_KEY; |
| 1046 | else |
| 1047 | param->value = IW_AUTH_ALG_OPEN_SYSTEM; |
| 1048 | break; |
| 1049 | |
| 1050 | case IW_AUTH_WPA_ENABLED: |
| 1051 | param->value = priv->wpa_enabled; |
| 1052 | break; |
| 1053 | |
| 1054 | default: |
| 1055 | ret = -EOPNOTSUPP; |
| 1056 | } |
| 1057 | |
| 1058 | orinoco_unlock(priv, &flags); |
| 1059 | return ret; |
| 1060 | } |
| 1061 | |
| 1062 | static int orinoco_ioctl_set_genie(struct net_device *dev, |
| 1063 | struct iw_request_info *info, |
| 1064 | union iwreq_data *wrqu, char *extra) |
| 1065 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1066 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1067 | u8 *buf; |
| 1068 | unsigned long flags; |
| 1069 | |
| 1070 | /* cut off at IEEE80211_MAX_DATA_LEN */ |
| 1071 | if ((wrqu->data.length > IEEE80211_MAX_DATA_LEN) || |
| 1072 | (wrqu->data.length && (extra == NULL))) |
| 1073 | return -EINVAL; |
| 1074 | |
| 1075 | if (wrqu->data.length) { |
| 1076 | buf = kmalloc(wrqu->data.length, GFP_KERNEL); |
| 1077 | if (buf == NULL) |
| 1078 | return -ENOMEM; |
| 1079 | |
| 1080 | memcpy(buf, extra, wrqu->data.length); |
| 1081 | } else |
| 1082 | buf = NULL; |
| 1083 | |
| 1084 | if (orinoco_lock(priv, &flags) != 0) { |
| 1085 | kfree(buf); |
| 1086 | return -EBUSY; |
| 1087 | } |
| 1088 | |
| 1089 | kfree(priv->wpa_ie); |
| 1090 | priv->wpa_ie = buf; |
| 1091 | priv->wpa_ie_len = wrqu->data.length; |
| 1092 | |
| 1093 | if (priv->wpa_ie) { |
| 1094 | /* Looks like wl_lkm wants to check the auth alg, and |
| 1095 | * somehow pass it to the firmware. |
| 1096 | * Instead it just calls the key mgmt rid |
| 1097 | * - we do this in set auth. |
| 1098 | */ |
| 1099 | } |
| 1100 | |
| 1101 | orinoco_unlock(priv, &flags); |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
| 1105 | static int orinoco_ioctl_get_genie(struct net_device *dev, |
| 1106 | struct iw_request_info *info, |
| 1107 | union iwreq_data *wrqu, char *extra) |
| 1108 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1109 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1110 | unsigned long flags; |
| 1111 | int err = 0; |
| 1112 | |
| 1113 | if (orinoco_lock(priv, &flags) != 0) |
| 1114 | return -EBUSY; |
| 1115 | |
| 1116 | if ((priv->wpa_ie_len == 0) || (priv->wpa_ie == NULL)) { |
| 1117 | wrqu->data.length = 0; |
| 1118 | goto out; |
| 1119 | } |
| 1120 | |
| 1121 | if (wrqu->data.length < priv->wpa_ie_len) { |
| 1122 | err = -E2BIG; |
| 1123 | goto out; |
| 1124 | } |
| 1125 | |
| 1126 | wrqu->data.length = priv->wpa_ie_len; |
| 1127 | memcpy(extra, priv->wpa_ie, priv->wpa_ie_len); |
| 1128 | |
| 1129 | out: |
| 1130 | orinoco_unlock(priv, &flags); |
| 1131 | return err; |
| 1132 | } |
| 1133 | |
| 1134 | static int orinoco_ioctl_set_mlme(struct net_device *dev, |
| 1135 | struct iw_request_info *info, |
| 1136 | union iwreq_data *wrqu, char *extra) |
| 1137 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1138 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1139 | hermes_t *hw = &priv->hw; |
| 1140 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
| 1141 | unsigned long flags; |
| 1142 | int ret = 0; |
| 1143 | |
| 1144 | if (orinoco_lock(priv, &flags) != 0) |
| 1145 | return -EBUSY; |
| 1146 | |
| 1147 | switch (mlme->cmd) { |
| 1148 | case IW_MLME_DEAUTH: |
| 1149 | /* silently ignore */ |
| 1150 | break; |
| 1151 | |
| 1152 | case IW_MLME_DISASSOC: |
| 1153 | { |
| 1154 | struct { |
| 1155 | u8 addr[ETH_ALEN]; |
| 1156 | __le16 reason_code; |
| 1157 | } __attribute__ ((packed)) buf; |
| 1158 | |
| 1159 | memcpy(buf.addr, mlme->addr.sa_data, ETH_ALEN); |
| 1160 | buf.reason_code = cpu_to_le16(mlme->reason_code); |
| 1161 | ret = HERMES_WRITE_RECORD(hw, USER_BAP, |
| 1162 | HERMES_RID_CNFDISASSOCIATE, |
| 1163 | &buf); |
| 1164 | break; |
| 1165 | } |
| 1166 | default: |
| 1167 | ret = -EOPNOTSUPP; |
| 1168 | } |
| 1169 | |
| 1170 | orinoco_unlock(priv, &flags); |
| 1171 | return ret; |
| 1172 | } |
| 1173 | |
| 1174 | static int orinoco_ioctl_getretry(struct net_device *dev, |
| 1175 | struct iw_request_info *info, |
| 1176 | struct iw_param *rrq, |
| 1177 | char *extra) |
| 1178 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1179 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1180 | hermes_t *hw = &priv->hw; |
| 1181 | int err = 0; |
| 1182 | u16 short_limit, long_limit, lifetime; |
| 1183 | unsigned long flags; |
| 1184 | |
| 1185 | if (orinoco_lock(priv, &flags) != 0) |
| 1186 | return -EBUSY; |
| 1187 | |
| 1188 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_SHORTRETRYLIMIT, |
| 1189 | &short_limit); |
| 1190 | if (err) |
| 1191 | goto out; |
| 1192 | |
| 1193 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_LONGRETRYLIMIT, |
| 1194 | &long_limit); |
| 1195 | if (err) |
| 1196 | goto out; |
| 1197 | |
| 1198 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_MAXTRANSMITLIFETIME, |
| 1199 | &lifetime); |
| 1200 | if (err) |
| 1201 | goto out; |
| 1202 | |
| 1203 | rrq->disabled = 0; /* Can't be disabled */ |
| 1204 | |
| 1205 | /* Note : by default, display the retry number */ |
| 1206 | if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { |
| 1207 | rrq->flags = IW_RETRY_LIFETIME; |
| 1208 | rrq->value = lifetime * 1000; /* ??? */ |
| 1209 | } else { |
| 1210 | /* By default, display the min number */ |
| 1211 | if ((rrq->flags & IW_RETRY_LONG)) { |
| 1212 | rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; |
| 1213 | rrq->value = long_limit; |
| 1214 | } else { |
| 1215 | rrq->flags = IW_RETRY_LIMIT; |
| 1216 | rrq->value = short_limit; |
| 1217 | if (short_limit != long_limit) |
| 1218 | rrq->flags |= IW_RETRY_SHORT; |
| 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | out: |
| 1223 | orinoco_unlock(priv, &flags); |
| 1224 | |
| 1225 | return err; |
| 1226 | } |
| 1227 | |
| 1228 | static int orinoco_ioctl_reset(struct net_device *dev, |
| 1229 | struct iw_request_info *info, |
| 1230 | void *wrqu, |
| 1231 | char *extra) |
| 1232 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1233 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1234 | |
| 1235 | if (!capable(CAP_NET_ADMIN)) |
| 1236 | return -EPERM; |
| 1237 | |
| 1238 | if (info->cmd == (SIOCIWFIRSTPRIV + 0x1)) { |
| 1239 | printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name); |
| 1240 | |
| 1241 | /* Firmware reset */ |
| 1242 | orinoco_reset(&priv->reset_work); |
| 1243 | } else { |
| 1244 | printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name); |
| 1245 | |
| 1246 | schedule_work(&priv->reset_work); |
| 1247 | } |
| 1248 | |
| 1249 | return 0; |
| 1250 | } |
| 1251 | |
| 1252 | static int orinoco_ioctl_setibssport(struct net_device *dev, |
| 1253 | struct iw_request_info *info, |
| 1254 | void *wrqu, |
| 1255 | char *extra) |
| 1256 | |
| 1257 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1258 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1259 | int val = *((int *) extra); |
| 1260 | unsigned long flags; |
| 1261 | |
| 1262 | if (orinoco_lock(priv, &flags) != 0) |
| 1263 | return -EBUSY; |
| 1264 | |
| 1265 | priv->ibss_port = val ; |
| 1266 | |
| 1267 | /* Actually update the mode we are using */ |
| 1268 | set_port_type(priv); |
| 1269 | |
| 1270 | orinoco_unlock(priv, &flags); |
| 1271 | return -EINPROGRESS; /* Call commit handler */ |
| 1272 | } |
| 1273 | |
| 1274 | static int orinoco_ioctl_getibssport(struct net_device *dev, |
| 1275 | struct iw_request_info *info, |
| 1276 | void *wrqu, |
| 1277 | char *extra) |
| 1278 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1279 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1280 | int *val = (int *) extra; |
| 1281 | |
| 1282 | *val = priv->ibss_port; |
| 1283 | return 0; |
| 1284 | } |
| 1285 | |
| 1286 | static int orinoco_ioctl_setport3(struct net_device *dev, |
| 1287 | struct iw_request_info *info, |
| 1288 | void *wrqu, |
| 1289 | char *extra) |
| 1290 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1291 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1292 | int val = *((int *) extra); |
| 1293 | int err = 0; |
| 1294 | unsigned long flags; |
| 1295 | |
| 1296 | if (orinoco_lock(priv, &flags) != 0) |
| 1297 | return -EBUSY; |
| 1298 | |
| 1299 | switch (val) { |
| 1300 | case 0: /* Try to do IEEE ad-hoc mode */ |
| 1301 | if (!priv->has_ibss) { |
| 1302 | err = -EINVAL; |
| 1303 | break; |
| 1304 | } |
| 1305 | priv->prefer_port3 = 0; |
| 1306 | |
| 1307 | break; |
| 1308 | |
| 1309 | case 1: /* Try to do Lucent proprietary ad-hoc mode */ |
| 1310 | if (!priv->has_port3) { |
| 1311 | err = -EINVAL; |
| 1312 | break; |
| 1313 | } |
| 1314 | priv->prefer_port3 = 1; |
| 1315 | break; |
| 1316 | |
| 1317 | default: |
| 1318 | err = -EINVAL; |
| 1319 | } |
| 1320 | |
| 1321 | if (!err) { |
| 1322 | /* Actually update the mode we are using */ |
| 1323 | set_port_type(priv); |
| 1324 | err = -EINPROGRESS; |
| 1325 | } |
| 1326 | |
| 1327 | orinoco_unlock(priv, &flags); |
| 1328 | |
| 1329 | return err; |
| 1330 | } |
| 1331 | |
| 1332 | static int orinoco_ioctl_getport3(struct net_device *dev, |
| 1333 | struct iw_request_info *info, |
| 1334 | void *wrqu, |
| 1335 | char *extra) |
| 1336 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1337 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1338 | int *val = (int *) extra; |
| 1339 | |
| 1340 | *val = priv->prefer_port3; |
| 1341 | return 0; |
| 1342 | } |
| 1343 | |
| 1344 | static int orinoco_ioctl_setpreamble(struct net_device *dev, |
| 1345 | struct iw_request_info *info, |
| 1346 | void *wrqu, |
| 1347 | char *extra) |
| 1348 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1349 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1350 | unsigned long flags; |
| 1351 | int val; |
| 1352 | |
| 1353 | if (!priv->has_preamble) |
| 1354 | return -EOPNOTSUPP; |
| 1355 | |
| 1356 | /* 802.11b has recently defined some short preamble. |
| 1357 | * Basically, the Phy header has been reduced in size. |
| 1358 | * This increase performance, especially at high rates |
| 1359 | * (the preamble is transmitted at 1Mb/s), unfortunately |
| 1360 | * this give compatibility troubles... - Jean II */ |
| 1361 | val = *((int *) extra); |
| 1362 | |
| 1363 | if (orinoco_lock(priv, &flags) != 0) |
| 1364 | return -EBUSY; |
| 1365 | |
| 1366 | if (val) |
| 1367 | priv->preamble = 1; |
| 1368 | else |
| 1369 | priv->preamble = 0; |
| 1370 | |
| 1371 | orinoco_unlock(priv, &flags); |
| 1372 | |
| 1373 | return -EINPROGRESS; /* Call commit handler */ |
| 1374 | } |
| 1375 | |
| 1376 | static int orinoco_ioctl_getpreamble(struct net_device *dev, |
| 1377 | struct iw_request_info *info, |
| 1378 | void *wrqu, |
| 1379 | char *extra) |
| 1380 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1381 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1382 | int *val = (int *) extra; |
| 1383 | |
| 1384 | if (!priv->has_preamble) |
| 1385 | return -EOPNOTSUPP; |
| 1386 | |
| 1387 | *val = priv->preamble; |
| 1388 | return 0; |
| 1389 | } |
| 1390 | |
| 1391 | /* ioctl interface to hermes_read_ltv() |
| 1392 | * To use with iwpriv, pass the RID as the token argument, e.g. |
| 1393 | * iwpriv get_rid [0xfc00] |
| 1394 | * At least Wireless Tools 25 is required to use iwpriv. |
| 1395 | * For Wireless Tools 25 and 26 append "dummy" are the end. */ |
| 1396 | static int orinoco_ioctl_getrid(struct net_device *dev, |
| 1397 | struct iw_request_info *info, |
| 1398 | struct iw_point *data, |
| 1399 | char *extra) |
| 1400 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1401 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1402 | hermes_t *hw = &priv->hw; |
| 1403 | int rid = data->flags; |
| 1404 | u16 length; |
| 1405 | int err; |
| 1406 | unsigned long flags; |
| 1407 | |
| 1408 | /* It's a "get" function, but we don't want users to access the |
| 1409 | * WEP key and other raw firmware data */ |
| 1410 | if (!capable(CAP_NET_ADMIN)) |
| 1411 | return -EPERM; |
| 1412 | |
| 1413 | if (rid < 0xfc00 || rid > 0xffff) |
| 1414 | return -EINVAL; |
| 1415 | |
| 1416 | if (orinoco_lock(priv, &flags) != 0) |
| 1417 | return -EBUSY; |
| 1418 | |
| 1419 | err = hermes_read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length, |
| 1420 | extra); |
| 1421 | if (err) |
| 1422 | goto out; |
| 1423 | |
| 1424 | data->length = min_t(u16, HERMES_RECLEN_TO_BYTES(length), |
| 1425 | MAX_RID_LEN); |
| 1426 | |
| 1427 | out: |
| 1428 | orinoco_unlock(priv, &flags); |
| 1429 | return err; |
| 1430 | } |
| 1431 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1432 | |
| 1433 | /* Commit handler, called after set operations */ |
| 1434 | static int orinoco_ioctl_commit(struct net_device *dev, |
| 1435 | struct iw_request_info *info, |
| 1436 | void *wrqu, |
| 1437 | char *extra) |
| 1438 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1439 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1440 | unsigned long flags; |
| 1441 | int err = 0; |
| 1442 | |
| 1443 | if (!priv->open) |
| 1444 | return 0; |
| 1445 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1446 | if (orinoco_lock(priv, &flags) != 0) |
| 1447 | return err; |
| 1448 | |
David Kilroy | 721aa2f | 2009-06-18 23:21:31 +0100 | [diff] [blame] | 1449 | err = orinoco_commit(priv); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1450 | |
| 1451 | orinoco_unlock(priv, &flags); |
| 1452 | return err; |
| 1453 | } |
| 1454 | |
| 1455 | static const struct iw_priv_args orinoco_privtab[] = { |
| 1456 | { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" }, |
| 1457 | { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" }, |
| 1458 | { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1459 | 0, "set_port3" }, |
| 1460 | { SIOCIWFIRSTPRIV + 0x3, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1461 | "get_port3" }, |
| 1462 | { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1463 | 0, "set_preamble" }, |
| 1464 | { SIOCIWFIRSTPRIV + 0x5, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1465 | "get_preamble" }, |
| 1466 | { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1467 | 0, "set_ibssport" }, |
| 1468 | { SIOCIWFIRSTPRIV + 0x7, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1469 | "get_ibssport" }, |
| 1470 | { SIOCIWFIRSTPRIV + 0x9, 0, IW_PRIV_TYPE_BYTE | MAX_RID_LEN, |
| 1471 | "get_rid" }, |
| 1472 | }; |
| 1473 | |
| 1474 | |
| 1475 | /* |
| 1476 | * Structures to export the Wireless Handlers |
| 1477 | */ |
| 1478 | |
| 1479 | #define STD_IW_HANDLER(id, func) \ |
| 1480 | [IW_IOCTL_IDX(id)] = (iw_handler) func |
| 1481 | static const iw_handler orinoco_handler[] = { |
| 1482 | STD_IW_HANDLER(SIOCSIWCOMMIT, orinoco_ioctl_commit), |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1483 | STD_IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1484 | STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq), |
| 1485 | STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq), |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 1486 | STD_IW_HANDLER(SIOCSIWMODE, cfg80211_wext_siwmode), |
| 1487 | STD_IW_HANDLER(SIOCGIWMODE, cfg80211_wext_giwmode), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1488 | STD_IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens), |
| 1489 | STD_IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens), |
David Kilroy | 934fd51 | 2009-06-18 23:21:34 +0100 | [diff] [blame] | 1490 | STD_IW_HANDLER(SIOCGIWRANGE, cfg80211_wext_giwrange), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1491 | STD_IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy), |
| 1492 | STD_IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy), |
| 1493 | STD_IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy), |
| 1494 | STD_IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy), |
| 1495 | STD_IW_HANDLER(SIOCSIWAP, orinoco_ioctl_setwap), |
| 1496 | STD_IW_HANDLER(SIOCGIWAP, orinoco_ioctl_getwap), |
David Kilroy | c63cdbe | 2009-06-18 23:21:33 +0100 | [diff] [blame] | 1497 | STD_IW_HANDLER(SIOCSIWSCAN, cfg80211_wext_siwscan), |
| 1498 | STD_IW_HANDLER(SIOCGIWSCAN, cfg80211_wext_giwscan), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1499 | STD_IW_HANDLER(SIOCSIWESSID, orinoco_ioctl_setessid), |
| 1500 | STD_IW_HANDLER(SIOCGIWESSID, orinoco_ioctl_getessid), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1501 | STD_IW_HANDLER(SIOCSIWRATE, orinoco_ioctl_setrate), |
| 1502 | STD_IW_HANDLER(SIOCGIWRATE, orinoco_ioctl_getrate), |
| 1503 | STD_IW_HANDLER(SIOCSIWRTS, orinoco_ioctl_setrts), |
| 1504 | STD_IW_HANDLER(SIOCGIWRTS, orinoco_ioctl_getrts), |
| 1505 | STD_IW_HANDLER(SIOCSIWFRAG, orinoco_ioctl_setfrag), |
| 1506 | STD_IW_HANDLER(SIOCGIWFRAG, orinoco_ioctl_getfrag), |
| 1507 | STD_IW_HANDLER(SIOCGIWRETRY, orinoco_ioctl_getretry), |
| 1508 | STD_IW_HANDLER(SIOCSIWENCODE, orinoco_ioctl_setiwencode), |
| 1509 | STD_IW_HANDLER(SIOCGIWENCODE, orinoco_ioctl_getiwencode), |
| 1510 | STD_IW_HANDLER(SIOCSIWPOWER, orinoco_ioctl_setpower), |
| 1511 | STD_IW_HANDLER(SIOCGIWPOWER, orinoco_ioctl_getpower), |
| 1512 | STD_IW_HANDLER(SIOCSIWGENIE, orinoco_ioctl_set_genie), |
| 1513 | STD_IW_HANDLER(SIOCGIWGENIE, orinoco_ioctl_get_genie), |
| 1514 | STD_IW_HANDLER(SIOCSIWMLME, orinoco_ioctl_set_mlme), |
| 1515 | STD_IW_HANDLER(SIOCSIWAUTH, orinoco_ioctl_set_auth), |
| 1516 | STD_IW_HANDLER(SIOCGIWAUTH, orinoco_ioctl_get_auth), |
| 1517 | STD_IW_HANDLER(SIOCSIWENCODEEXT, orinoco_ioctl_set_encodeext), |
| 1518 | STD_IW_HANDLER(SIOCGIWENCODEEXT, orinoco_ioctl_get_encodeext), |
| 1519 | }; |
| 1520 | |
| 1521 | |
| 1522 | /* |
| 1523 | Added typecasting since we no longer use iwreq_data -- Moustafa |
| 1524 | */ |
| 1525 | static const iw_handler orinoco_private_handler[] = { |
| 1526 | [0] = (iw_handler) orinoco_ioctl_reset, |
| 1527 | [1] = (iw_handler) orinoco_ioctl_reset, |
| 1528 | [2] = (iw_handler) orinoco_ioctl_setport3, |
| 1529 | [3] = (iw_handler) orinoco_ioctl_getport3, |
| 1530 | [4] = (iw_handler) orinoco_ioctl_setpreamble, |
| 1531 | [5] = (iw_handler) orinoco_ioctl_getpreamble, |
| 1532 | [6] = (iw_handler) orinoco_ioctl_setibssport, |
| 1533 | [7] = (iw_handler) orinoco_ioctl_getibssport, |
| 1534 | [9] = (iw_handler) orinoco_ioctl_getrid, |
| 1535 | }; |
| 1536 | |
| 1537 | const struct iw_handler_def orinoco_handler_def = { |
| 1538 | .num_standard = ARRAY_SIZE(orinoco_handler), |
| 1539 | .num_private = ARRAY_SIZE(orinoco_private_handler), |
| 1540 | .num_private_args = ARRAY_SIZE(orinoco_privtab), |
| 1541 | .standard = orinoco_handler, |
| 1542 | .private = orinoco_private_handler, |
| 1543 | .private_args = orinoco_privtab, |
| 1544 | .get_wireless_stats = orinoco_get_wireless_stats, |
| 1545 | }; |