Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /** |
| 2 | * This file contains ioctl functions |
| 3 | */ |
| 4 | #include <linux/ctype.h> |
| 5 | #include <linux/delay.h> |
| 6 | #include <linux/if.h> |
| 7 | #include <linux/if_arp.h> |
| 8 | #include <linux/wireless.h> |
| 9 | #include <linux/bitops.h> |
| 10 | |
John W. Linville | 7e272fc | 2008-09-24 18:13:14 -0400 | [diff] [blame] | 11 | #include <net/lib80211.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 12 | #include <net/iw_handler.h> |
| 13 | |
| 14 | #include "host.h" |
| 15 | #include "radiotap.h" |
| 16 | #include "decl.h" |
| 17 | #include "defs.h" |
| 18 | #include "dev.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 19 | #include "wext.h" |
Holger Schurig | 245bf20 | 2008-04-02 16:27:42 +0200 | [diff] [blame] | 20 | #include "scan.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 21 | #include "assoc.h" |
Dan Williams | 8e3c91b | 2007-12-11 15:50:59 -0500 | [diff] [blame] | 22 | #include "cmd.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 23 | |
| 24 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 25 | static inline void lbs_postpone_association_work(struct lbs_private *priv) |
Holger Schurig | 9f9dac2 | 2007-10-26 10:12:14 +0200 | [diff] [blame] | 26 | { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 27 | if (priv->surpriseremoved) |
Holger Schurig | 9f9dac2 | 2007-10-26 10:12:14 +0200 | [diff] [blame] | 28 | return; |
| 29 | cancel_delayed_work(&priv->assoc_work); |
| 30 | queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2); |
| 31 | } |
| 32 | |
Javier Cardona | 9c31fd63 | 2008-09-11 15:32:50 -0700 | [diff] [blame] | 33 | static inline void lbs_do_association_work(struct lbs_private *priv) |
| 34 | { |
| 35 | if (priv->surpriseremoved) |
| 36 | return; |
| 37 | cancel_delayed_work(&priv->assoc_work); |
| 38 | queue_delayed_work(priv->work_thread, &priv->assoc_work, 0); |
| 39 | } |
| 40 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 41 | static inline void lbs_cancel_association_work(struct lbs_private *priv) |
Holger Schurig | 9f9dac2 | 2007-10-26 10:12:14 +0200 | [diff] [blame] | 42 | { |
| 43 | cancel_delayed_work(&priv->assoc_work); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 44 | kfree(priv->pending_assoc_req); |
| 45 | priv->pending_assoc_req = NULL; |
Holger Schurig | 9f9dac2 | 2007-10-26 10:12:14 +0200 | [diff] [blame] | 46 | } |
| 47 | |
Amitkumar Karwar | 4912545 | 2009-09-30 20:04:38 -0700 | [diff] [blame] | 48 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 49 | * @brief Find the channel frequency power info with specific channel |
| 50 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 51 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 52 | * @param band it can be BAND_A, BAND_G or BAND_B |
| 53 | * @param channel the channel for looking |
| 54 | * @return A pointer to struct chan_freq_power structure or NULL if not find. |
| 55 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 56 | struct chan_freq_power *lbs_find_cfp_by_band_and_channel( |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 57 | struct lbs_private *priv, |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 58 | u8 band, |
| 59 | u16 channel) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 60 | { |
| 61 | struct chan_freq_power *cfp = NULL; |
| 62 | struct region_channel *rc; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 63 | int i, j; |
| 64 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 65 | for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) { |
| 66 | rc = &priv->region_channel[j]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 67 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 68 | if (!rc->valid || !rc->CFP) |
| 69 | continue; |
| 70 | if (rc->band != band) |
| 71 | continue; |
| 72 | for (i = 0; i < rc->nrcfp; i++) { |
| 73 | if (rc->CFP[i].channel == channel) { |
| 74 | cfp = &rc->CFP[i]; |
| 75 | break; |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if (!cfp && channel) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 81 | lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find " |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 82 | "cfp by band %d / channel %d\n", band, channel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 83 | |
| 84 | return cfp; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * @brief Find the channel frequency power info with specific frequency |
| 89 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 90 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 91 | * @param band it can be BAND_A, BAND_G or BAND_B |
| 92 | * @param freq the frequency for looking |
| 93 | * @return A pointer to struct chan_freq_power structure or NULL if not find. |
| 94 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 95 | static struct chan_freq_power *find_cfp_by_band_and_freq( |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 96 | struct lbs_private *priv, |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 97 | u8 band, |
| 98 | u32 freq) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 99 | { |
| 100 | struct chan_freq_power *cfp = NULL; |
| 101 | struct region_channel *rc; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 102 | int i, j; |
| 103 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 104 | for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) { |
| 105 | rc = &priv->region_channel[j]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 106 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 107 | if (!rc->valid || !rc->CFP) |
| 108 | continue; |
| 109 | if (rc->band != band) |
| 110 | continue; |
| 111 | for (i = 0; i < rc->nrcfp; i++) { |
| 112 | if (rc->CFP[i].freq == freq) { |
| 113 | cfp = &rc->CFP[i]; |
| 114 | break; |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | if (!cfp && freq) |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 120 | lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by " |
| 121 | "band %d / freq %d\n", band, freq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 122 | |
| 123 | return cfp; |
| 124 | } |
| 125 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 126 | /** |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 127 | * @brief Copy active data rates based on adapter mode and status |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 128 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 129 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 130 | * @param rate The buf to return the active rates |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 131 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 132 | static void copy_active_data_rates(struct lbs_private *priv, u8 *rates) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 133 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 134 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 135 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 136 | if ((priv->connect_status != LBS_CONNECTED) && |
| 137 | (priv->mesh_connect_status != LBS_CONNECTED)) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 138 | memcpy(rates, lbs_bg_rates, MAX_RATES); |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 139 | else |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 140 | memcpy(rates, priv->curbssparams.rates, MAX_RATES); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 141 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 142 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 143 | } |
| 144 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 145 | static int lbs_get_name(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 146 | char *cwrq, char *extra) |
| 147 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 148 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 149 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 150 | |
Jean Tourrilhes | 9483f03 | 2007-08-02 13:16:30 -0400 | [diff] [blame] | 151 | /* We could add support for 802.11n here as needed. Jean II */ |
| 152 | snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 153 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 154 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 155 | return 0; |
| 156 | } |
| 157 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 158 | static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 159 | struct iw_freq *fwrq, char *extra) |
| 160 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 161 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 162 | struct chan_freq_power *cfp; |
| 163 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 164 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 165 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 166 | cfp = lbs_find_cfp_by_band_and_channel(priv, 0, |
| 167 | priv->curbssparams.channel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 168 | |
| 169 | if (!cfp) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 170 | if (priv->curbssparams.channel) |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 171 | lbs_deb_wext("invalid channel %d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 172 | priv->curbssparams.channel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 173 | return -EINVAL; |
| 174 | } |
| 175 | |
| 176 | fwrq->m = (long)cfp->freq * 100000; |
| 177 | fwrq->e = 1; |
| 178 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 179 | lbs_deb_wext("freq %u\n", fwrq->m); |
| 180 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 181 | return 0; |
| 182 | } |
| 183 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 184 | static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 185 | struct sockaddr *awrq, char *extra) |
| 186 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 187 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 188 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 189 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 190 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 191 | if (priv->connect_status == LBS_CONNECTED) { |
| 192 | memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 193 | } else { |
| 194 | memset(awrq->sa_data, 0, ETH_ALEN); |
| 195 | } |
| 196 | awrq->sa_family = ARPHRD_ETHER; |
| 197 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 198 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 199 | return 0; |
| 200 | } |
| 201 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 202 | static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 203 | struct iw_point *dwrq, char *extra) |
| 204 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 205 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 206 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 207 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 208 | |
| 209 | /* |
| 210 | * Check the size of the string |
| 211 | */ |
| 212 | |
| 213 | if (dwrq->length > 16) { |
| 214 | return -E2BIG; |
| 215 | } |
| 216 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 217 | mutex_lock(&priv->lock); |
| 218 | memset(priv->nodename, 0, sizeof(priv->nodename)); |
| 219 | memcpy(priv->nodename, extra, dwrq->length); |
| 220 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 221 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 222 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 223 | return 0; |
| 224 | } |
| 225 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 226 | static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 227 | struct iw_point *dwrq, char *extra) |
| 228 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 229 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 230 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 231 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 232 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 233 | dwrq->length = strlen(priv->nodename); |
| 234 | memcpy(extra, priv->nodename, dwrq->length); |
Holger Schurig | 04799fa | 2007-10-09 15:04:14 +0200 | [diff] [blame] | 235 | extra[dwrq->length] = '\0'; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 236 | |
Holger Schurig | 04799fa | 2007-10-09 15:04:14 +0200 | [diff] [blame] | 237 | dwrq->flags = 1; /* active */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 238 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 239 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 240 | return 0; |
| 241 | } |
| 242 | |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 243 | static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info, |
| 244 | struct iw_point *dwrq, char *extra) |
| 245 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 246 | struct lbs_private *priv = dev->ml_priv; |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 247 | |
| 248 | lbs_deb_enter(LBS_DEB_WEXT); |
| 249 | |
| 250 | /* Use nickname to indicate that mesh is on */ |
| 251 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 252 | if (priv->mesh_connect_status == LBS_CONNECTED) { |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 253 | strncpy(extra, "Mesh", 12); |
| 254 | extra[12] = '\0'; |
Jean Tourrilhes | 9483f03 | 2007-08-02 13:16:30 -0400 | [diff] [blame] | 255 | dwrq->length = strlen(extra); |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | else { |
| 259 | extra[0] = '\0'; |
Jean Tourrilhes | 9483f03 | 2007-08-02 13:16:30 -0400 | [diff] [blame] | 260 | dwrq->length = 0; |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | lbs_deb_leave(LBS_DEB_WEXT); |
| 264 | return 0; |
| 265 | } |
Holger Schurig | 04799fa | 2007-10-09 15:04:14 +0200 | [diff] [blame] | 266 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 267 | static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 268 | struct iw_param *vwrq, char *extra) |
| 269 | { |
| 270 | int ret = 0; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 271 | struct lbs_private *priv = dev->ml_priv; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 272 | u32 val = vwrq->value; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 273 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 274 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 275 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 276 | if (vwrq->disabled) |
| 277 | val = MRVDRV_RTS_MAX_VALUE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 278 | |
John W. Linville | 375da53 | 2008-09-15 17:25:54 -0400 | [diff] [blame] | 279 | if (val > MRVDRV_RTS_MAX_VALUE) /* min rts value is 0 */ |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 280 | return -EINVAL; |
| 281 | |
| 282 | ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 283 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 284 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 285 | return ret; |
| 286 | } |
| 287 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 288 | static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 289 | struct iw_param *vwrq, char *extra) |
| 290 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 291 | struct lbs_private *priv = dev->ml_priv; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 292 | int ret = 0; |
| 293 | u16 val = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 294 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 295 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 296 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 297 | ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 298 | if (ret) |
| 299 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 300 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 301 | vwrq->value = val; |
John W. Linville | 375da53 | 2008-09-15 17:25:54 -0400 | [diff] [blame] | 302 | vwrq->disabled = val > MRVDRV_RTS_MAX_VALUE; /* min rts value is 0 */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 303 | vwrq->fixed = 1; |
| 304 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 305 | out: |
| 306 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 307 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 308 | } |
| 309 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 310 | static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 311 | struct iw_param *vwrq, char *extra) |
| 312 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 313 | struct lbs_private *priv = dev->ml_priv; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 314 | int ret = 0; |
| 315 | u32 val = vwrq->value; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 316 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 317 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 318 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 319 | if (vwrq->disabled) |
| 320 | val = MRVDRV_FRAG_MAX_VALUE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 321 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 322 | if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE) |
| 323 | return -EINVAL; |
| 324 | |
| 325 | ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 326 | |
| 327 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 328 | return ret; |
| 329 | } |
| 330 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 331 | static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 332 | struct iw_param *vwrq, char *extra) |
| 333 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 334 | struct lbs_private *priv = dev->ml_priv; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 335 | int ret = 0; |
| 336 | u16 val = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 337 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 338 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 339 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 340 | ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 341 | if (ret) |
| 342 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 343 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 344 | vwrq->value = val; |
| 345 | vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE) |
| 346 | || (val > MRVDRV_FRAG_MAX_VALUE)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 347 | vwrq->fixed = 1; |
| 348 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 349 | out: |
| 350 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 351 | return ret; |
| 352 | } |
| 353 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 354 | static int lbs_get_mode(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 355 | struct iw_request_info *info, u32 * uwrq, char *extra) |
| 356 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 357 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 358 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 359 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 360 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 361 | *uwrq = priv->mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 362 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 363 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 364 | return 0; |
| 365 | } |
| 366 | |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 367 | static int mesh_wlan_get_mode(struct net_device *dev, |
| 368 | struct iw_request_info *info, u32 * uwrq, |
| 369 | char *extra) |
| 370 | { |
| 371 | lbs_deb_enter(LBS_DEB_WEXT); |
| 372 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 373 | *uwrq = IW_MODE_REPEAT; |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 374 | |
| 375 | lbs_deb_leave(LBS_DEB_WEXT); |
| 376 | return 0; |
| 377 | } |
| 378 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 379 | static int lbs_get_txpow(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 380 | struct iw_request_info *info, |
| 381 | struct iw_param *vwrq, char *extra) |
| 382 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 383 | struct lbs_private *priv = dev->ml_priv; |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 384 | s16 curlevel = 0; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 385 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 386 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 387 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 388 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 389 | if (!priv->radio_on) { |
| 390 | lbs_deb_wext("tx power off\n"); |
| 391 | vwrq->value = 0; |
| 392 | vwrq->disabled = 1; |
| 393 | goto out; |
| 394 | } |
| 395 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 396 | ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 397 | if (ret) |
| 398 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 399 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 400 | lbs_deb_wext("tx power level %d dbm\n", curlevel); |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 401 | priv->txpower_cur = curlevel; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 402 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 403 | vwrq->value = curlevel; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 404 | vwrq->fixed = 1; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 405 | vwrq->disabled = 0; |
| 406 | vwrq->flags = IW_TXPOW_DBM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 407 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 408 | out: |
| 409 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 410 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 411 | } |
| 412 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 413 | static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 414 | struct iw_param *vwrq, char *extra) |
| 415 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 416 | struct lbs_private *priv = dev->ml_priv; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 417 | int ret = 0; |
| 418 | u16 slimit = 0, llimit = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 419 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 420 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 421 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 422 | if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) |
| 423 | return -EOPNOTSUPP; |
| 424 | |
| 425 | /* The MAC has a 4-bit Total_Tx_Count register |
| 426 | Total_Tx_Count = 1 + Tx_Retry_Count */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 427 | #define TX_RETRY_MIN 0 |
| 428 | #define TX_RETRY_MAX 14 |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 429 | if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX) |
| 430 | return -EINVAL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 431 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 432 | /* Add 1 to convert retry count to try count */ |
| 433 | if (vwrq->flags & IW_RETRY_SHORT) |
| 434 | slimit = (u16) (vwrq->value + 1); |
| 435 | else if (vwrq->flags & IW_RETRY_LONG) |
| 436 | llimit = (u16) (vwrq->value + 1); |
| 437 | else |
| 438 | slimit = llimit = (u16) (vwrq->value + 1); /* set both */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 439 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 440 | if (llimit) { |
| 441 | ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, |
| 442 | llimit); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 443 | if (ret) |
| 444 | goto out; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | if (slimit) { |
| 448 | /* txretrycount follows the short retry limit */ |
| 449 | priv->txretrycount = slimit; |
| 450 | ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, |
| 451 | slimit); |
| 452 | if (ret) |
| 453 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 454 | } |
| 455 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 456 | out: |
| 457 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 458 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 459 | } |
| 460 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 461 | static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 462 | struct iw_param *vwrq, char *extra) |
| 463 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 464 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 465 | int ret = 0; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 466 | u16 val = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 467 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 468 | lbs_deb_enter(LBS_DEB_WEXT); |
| 469 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 470 | vwrq->disabled = 0; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 471 | |
| 472 | if (vwrq->flags & IW_RETRY_LONG) { |
| 473 | ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val); |
| 474 | if (ret) |
| 475 | goto out; |
| 476 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 477 | /* Subtract 1 to convert try count to retry count */ |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 478 | vwrq->value = val - 1; |
| 479 | vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; |
| 480 | } else { |
| 481 | ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val); |
| 482 | if (ret) |
| 483 | goto out; |
| 484 | |
| 485 | /* txretry count follows the short retry limit */ |
| 486 | priv->txretrycount = val; |
| 487 | /* Subtract 1 to convert try count to retry count */ |
| 488 | vwrq->value = val - 1; |
| 489 | vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 490 | } |
| 491 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 492 | out: |
| 493 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 494 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | static inline void sort_channels(struct iw_freq *freq, int num) |
| 498 | { |
| 499 | int i, j; |
| 500 | struct iw_freq temp; |
| 501 | |
| 502 | for (i = 0; i < num; i++) |
| 503 | for (j = i + 1; j < num; j++) |
| 504 | if (freq[i].i > freq[j].i) { |
| 505 | temp.i = freq[i].i; |
| 506 | temp.m = freq[i].m; |
| 507 | |
| 508 | freq[i].i = freq[j].i; |
| 509 | freq[i].m = freq[j].m; |
| 510 | |
| 511 | freq[j].i = temp.i; |
| 512 | freq[j].m = temp.m; |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | /* data rate listing |
| 517 | MULTI_BANDS: |
| 518 | abg a b b/g |
| 519 | Infra G(12) A(8) B(4) G(12) |
| 520 | Adhoc A+B(12) A(8) B(4) B(4) |
| 521 | |
| 522 | non-MULTI_BANDS: |
| 523 | b b/g |
| 524 | Infra B(4) G(12) |
| 525 | Adhoc B(4) B(4) |
| 526 | */ |
| 527 | /** |
| 528 | * @brief Get Range Info |
| 529 | * |
| 530 | * @param dev A pointer to net_device structure |
| 531 | * @param info A pointer to iw_request_info structure |
| 532 | * @param vwrq A pointer to iw_param structure |
| 533 | * @param extra A pointer to extra data buf |
| 534 | * @return 0 --success, otherwise fail |
| 535 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 536 | static int lbs_get_range(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 537 | struct iw_point *dwrq, char *extra) |
| 538 | { |
| 539 | int i, j; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 540 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 541 | struct iw_range *range = (struct iw_range *)extra; |
| 542 | struct chan_freq_power *cfp; |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 543 | u8 rates[MAX_RATES + 1]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 544 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 545 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 546 | |
| 547 | dwrq->length = sizeof(struct iw_range); |
| 548 | memset(range, 0, sizeof(struct iw_range)); |
| 549 | |
| 550 | range->min_nwid = 0; |
| 551 | range->max_nwid = 0; |
| 552 | |
| 553 | memset(rates, 0, sizeof(rates)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 554 | copy_active_data_rates(priv, rates); |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 555 | range->num_bitrates = strnlen(rates, IW_MAX_BITRATES); |
| 556 | for (i = 0; i < range->num_bitrates; i++) |
| 557 | range->bitrate[i] = rates[i] * 500000; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 558 | range->num_bitrates = i; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 559 | lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 560 | range->num_bitrates); |
| 561 | |
| 562 | range->num_frequency = 0; |
Holger Schurig | 52933d8 | 2008-03-05 07:05:32 +0100 | [diff] [blame] | 563 | |
| 564 | range->scan_capa = IW_SCAN_CAPA_ESSID; |
| 565 | |
Holger Schurig | d37b4fd | 2009-10-22 15:30:45 +0200 | [diff] [blame] | 566 | for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES) |
| 567 | && (j < ARRAY_SIZE(priv->region_channel)); j++) { |
| 568 | cfp = priv->region_channel[j].CFP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 569 | for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES) |
Holger Schurig | d37b4fd | 2009-10-22 15:30:45 +0200 | [diff] [blame] | 570 | && priv->region_channel[j].valid |
| 571 | && cfp |
| 572 | && (i < priv->region_channel[j].nrcfp); i++) { |
| 573 | range->freq[range->num_frequency].i = |
| 574 | (long)cfp->channel; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 575 | range->freq[range->num_frequency].m = |
Holger Schurig | d37b4fd | 2009-10-22 15:30:45 +0200 | [diff] [blame] | 576 | (long)cfp->freq * 100000; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 577 | range->freq[range->num_frequency].e = 1; |
Holger Schurig | d37b4fd | 2009-10-22 15:30:45 +0200 | [diff] [blame] | 578 | cfp++; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 579 | range->num_frequency++; |
| 580 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 581 | } |
| 582 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 583 | lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 584 | IW_MAX_FREQUENCIES, range->num_frequency); |
| 585 | |
| 586 | range->num_channels = range->num_frequency; |
| 587 | |
| 588 | sort_channels(&range->freq[0], range->num_frequency); |
| 589 | |
| 590 | /* |
| 591 | * Set an indication of the max TCP throughput in bit/s that we can |
| 592 | * expect using this interface |
| 593 | */ |
| 594 | if (i > 2) |
| 595 | range->throughput = 5000 * 1000; |
| 596 | else |
| 597 | range->throughput = 1500 * 1000; |
| 598 | |
| 599 | range->min_rts = MRVDRV_RTS_MIN_VALUE; |
| 600 | range->max_rts = MRVDRV_RTS_MAX_VALUE; |
| 601 | range->min_frag = MRVDRV_FRAG_MIN_VALUE; |
| 602 | range->max_frag = MRVDRV_FRAG_MAX_VALUE; |
| 603 | |
| 604 | range->encoding_size[0] = 5; |
| 605 | range->encoding_size[1] = 13; |
| 606 | range->num_encoding_sizes = 2; |
| 607 | range->max_encoding_tokens = 4; |
| 608 | |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame] | 609 | /* |
| 610 | * Right now we support only "iwconfig ethX power on|off" |
| 611 | */ |
| 612 | range->pm_capa = IW_POWER_ON; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 613 | |
| 614 | /* |
| 615 | * Minimum version we recommend |
| 616 | */ |
| 617 | range->we_version_source = 15; |
| 618 | |
| 619 | /* |
| 620 | * Version we are compiled with |
| 621 | */ |
| 622 | range->we_version_compiled = WIRELESS_EXT; |
| 623 | |
| 624 | range->retry_capa = IW_RETRY_LIMIT; |
| 625 | range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX; |
| 626 | |
| 627 | range->min_retry = TX_RETRY_MIN; |
| 628 | range->max_retry = TX_RETRY_MAX; |
| 629 | |
| 630 | /* |
| 631 | * Set the qual, level and noise range values |
| 632 | */ |
| 633 | range->max_qual.qual = 100; |
| 634 | range->max_qual.level = 0; |
| 635 | range->max_qual.noise = 0; |
| 636 | range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; |
| 637 | |
| 638 | range->avg_qual.qual = 70; |
| 639 | /* TODO: Find real 'good' to 'bad' threshold value for RSSI */ |
| 640 | range->avg_qual.level = 0; |
| 641 | range->avg_qual.noise = 0; |
| 642 | range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; |
| 643 | |
| 644 | range->sensitivity = 0; |
| 645 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 646 | /* Setup the supported power level ranges */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 647 | memset(range->txpower, 0, sizeof(range->txpower)); |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 648 | range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE; |
| 649 | range->txpower[0] = priv->txpower_min; |
| 650 | range->txpower[1] = priv->txpower_max; |
| 651 | range->num_txpower = 2; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 652 | |
| 653 | range->event_capa[0] = (IW_EVENT_CAPA_K_0 | |
| 654 | IW_EVENT_CAPA_MASK(SIOCGIWAP) | |
| 655 | IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); |
| 656 | range->event_capa[1] = IW_EVENT_CAPA_K_1; |
| 657 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 658 | if (priv->fwcapinfo & FW_CAPINFO_WPA) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 659 | range->enc_capa = IW_ENC_CAPA_WPA |
| 660 | | IW_ENC_CAPA_WPA2 |
| 661 | | IW_ENC_CAPA_CIPHER_TKIP |
| 662 | | IW_ENC_CAPA_CIPHER_CCMP; |
| 663 | } |
| 664 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 665 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 666 | return 0; |
| 667 | } |
| 668 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 669 | static int lbs_set_power(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 670 | struct iw_param *vwrq, char *extra) |
| 671 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 672 | struct lbs_private *priv = dev->ml_priv; |
Amitkumar Karwar | 4912545 | 2009-09-30 20:04:38 -0700 | [diff] [blame] | 673 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 674 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 675 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 676 | |
Andrey Yurovsky | e0d6133 | 2009-06-16 13:20:01 -0700 | [diff] [blame] | 677 | if (!(priv->fwcapinfo & FW_CAPINFO_PS)) { |
David Woodhouse | b2c57ee | 2007-12-17 14:41:13 -0500 | [diff] [blame] | 678 | if (vwrq->disabled) |
| 679 | return 0; |
| 680 | else |
| 681 | return -EINVAL; |
| 682 | } |
| 683 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 684 | /* PS is currently supported only in Infrastructure mode |
| 685 | * Remove this check if it is to be supported in IBSS mode also |
| 686 | */ |
| 687 | |
| 688 | if (vwrq->disabled) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 689 | priv->psmode = LBS802_11POWERMODECAM; |
| 690 | if (priv->psstate != PS_STATE_FULL_POWER) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 691 | lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 692 | } |
| 693 | |
| 694 | return 0; |
| 695 | } |
| 696 | |
| 697 | if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 698 | lbs_deb_wext( |
| 699 | "setting power timeout is not supported\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 700 | return -EINVAL; |
| 701 | } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) { |
Amitkumar Karwar | 4912545 | 2009-09-30 20:04:38 -0700 | [diff] [blame] | 702 | vwrq->value = vwrq->value / 1000; |
| 703 | if (!priv->enter_deep_sleep) { |
| 704 | lbs_pr_err("deep sleep feature is not implemented " |
| 705 | "for this interface driver\n"); |
| 706 | return -EINVAL; |
| 707 | } |
| 708 | |
| 709 | if (priv->connect_status == LBS_CONNECTED) { |
| 710 | if ((priv->is_auto_deep_sleep_enabled) && |
| 711 | (vwrq->value == -1000)) { |
| 712 | lbs_exit_auto_deep_sleep(priv); |
| 713 | return 0; |
| 714 | } else { |
| 715 | lbs_pr_err("can't use deep sleep cmd in " |
| 716 | "connected state\n"); |
| 717 | return -EINVAL; |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | if ((vwrq->value < 0) && (vwrq->value != -1000)) { |
| 722 | lbs_pr_err("unknown option\n"); |
| 723 | return -EINVAL; |
| 724 | } |
| 725 | |
| 726 | if (vwrq->value > 0) { |
| 727 | if (!priv->is_auto_deep_sleep_enabled) { |
| 728 | priv->is_activity_detected = 0; |
| 729 | priv->auto_deep_sleep_timeout = vwrq->value; |
| 730 | lbs_enter_auto_deep_sleep(priv); |
| 731 | } else { |
| 732 | priv->auto_deep_sleep_timeout = vwrq->value; |
| 733 | lbs_deb_debugfs("auto deep sleep: " |
| 734 | "already enabled\n"); |
| 735 | } |
| 736 | return 0; |
| 737 | } else { |
| 738 | if (priv->is_auto_deep_sleep_enabled) { |
| 739 | lbs_exit_auto_deep_sleep(priv); |
| 740 | /* Try to exit deep sleep if auto */ |
| 741 | /*deep sleep disabled */ |
| 742 | ret = lbs_set_deep_sleep(priv, 0); |
| 743 | } |
| 744 | if (vwrq->value == 0) |
| 745 | ret = lbs_set_deep_sleep(priv, 1); |
| 746 | else if (vwrq->value == -1000) |
| 747 | ret = lbs_set_deep_sleep(priv, 0); |
| 748 | return ret; |
| 749 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 750 | } |
| 751 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 752 | if (priv->psmode != LBS802_11POWERMODECAM) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 753 | return 0; |
| 754 | } |
| 755 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 756 | priv->psmode = LBS802_11POWERMODEMAX_PSP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 757 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 758 | if (priv->connect_status == LBS_CONNECTED) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 759 | lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 760 | } |
| 761 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 762 | lbs_deb_leave(LBS_DEB_WEXT); |
Amitkumar Karwar | 4912545 | 2009-09-30 20:04:38 -0700 | [diff] [blame] | 763 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 764 | return 0; |
| 765 | } |
| 766 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 767 | static int lbs_get_power(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 768 | struct iw_param *vwrq, char *extra) |
| 769 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 770 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 771 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 772 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 773 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 774 | vwrq->value = 0; |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame] | 775 | vwrq->flags = 0; |
| 776 | vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM |
| 777 | || priv->connect_status == LBS_DISCONNECTED; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 778 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 779 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 780 | return 0; |
| 781 | } |
| 782 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 783 | static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 784 | { |
| 785 | enum { |
| 786 | POOR = 30, |
| 787 | FAIR = 60, |
| 788 | GOOD = 80, |
| 789 | VERY_GOOD = 90, |
| 790 | EXCELLENT = 95, |
| 791 | PERFECT = 100 |
| 792 | }; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 793 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 794 | u32 rssi_qual; |
| 795 | u32 tx_qual; |
| 796 | u32 quality = 0; |
Amitkumar Karwar | c0bbd57 | 2009-10-08 19:38:45 -0700 | [diff] [blame] | 797 | int ret, stats_valid = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 798 | u8 rssi; |
| 799 | u32 tx_retries; |
Holger Schurig | c49c3b7 | 2008-03-17 12:45:58 +0100 | [diff] [blame] | 800 | struct cmd_ds_802_11_get_log log; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 801 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 802 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 803 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 804 | priv->wstats.status = priv->mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 805 | |
| 806 | /* If we're not associated, all quality values are meaningless */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 807 | if ((priv->connect_status != LBS_CONNECTED) && |
| 808 | (priv->mesh_connect_status != LBS_CONNECTED)) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 809 | goto out; |
| 810 | |
| 811 | /* Quality by RSSI */ |
| 812 | priv->wstats.qual.level = |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 813 | CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG], |
| 814 | priv->NF[TYPE_BEACON][TYPE_NOAVG]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 815 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 816 | if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 817 | priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; |
| 818 | } else { |
| 819 | priv->wstats.qual.noise = |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 820 | CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 821 | } |
| 822 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 823 | lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level); |
| 824 | lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 825 | |
| 826 | rssi = priv->wstats.qual.level - priv->wstats.qual.noise; |
| 827 | if (rssi < 15) |
| 828 | rssi_qual = rssi * POOR / 10; |
| 829 | else if (rssi < 20) |
| 830 | rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR; |
| 831 | else if (rssi < 30) |
| 832 | rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR; |
| 833 | else if (rssi < 40) |
| 834 | rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) / |
| 835 | 10 + GOOD; |
| 836 | else |
| 837 | rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) / |
| 838 | 10 + VERY_GOOD; |
| 839 | quality = rssi_qual; |
| 840 | |
| 841 | /* Quality by TX errors */ |
Stephen Hemminger | bbfc6b7 | 2009-03-20 19:36:36 +0000 | [diff] [blame] | 842 | priv->wstats.discard.retries = dev->stats.tx_errors; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 843 | |
Holger Schurig | c49c3b7 | 2008-03-17 12:45:58 +0100 | [diff] [blame] | 844 | memset(&log, 0, sizeof(log)); |
| 845 | log.hdr.size = cpu_to_le16(sizeof(log)); |
Amitkumar Karwar | c0bbd57 | 2009-10-08 19:38:45 -0700 | [diff] [blame] | 846 | ret = lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log); |
| 847 | if (ret) |
| 848 | goto out; |
Holger Schurig | c49c3b7 | 2008-03-17 12:45:58 +0100 | [diff] [blame] | 849 | |
| 850 | tx_retries = le32_to_cpu(log.retry); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 851 | |
| 852 | if (tx_retries > 75) |
| 853 | tx_qual = (90 - tx_retries) * POOR / 15; |
| 854 | else if (tx_retries > 70) |
| 855 | tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR; |
| 856 | else if (tx_retries > 65) |
| 857 | tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR; |
| 858 | else if (tx_retries > 50) |
| 859 | tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) / |
| 860 | 15 + GOOD; |
| 861 | else |
| 862 | tx_qual = (50 - tx_retries) * |
| 863 | (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; |
| 864 | quality = min(quality, tx_qual); |
| 865 | |
Holger Schurig | c49c3b7 | 2008-03-17 12:45:58 +0100 | [diff] [blame] | 866 | priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 867 | priv->wstats.discard.retries = tx_retries; |
Holger Schurig | c49c3b7 | 2008-03-17 12:45:58 +0100 | [diff] [blame] | 868 | priv->wstats.discard.misc = le32_to_cpu(log.ackfailure); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 869 | |
| 870 | /* Calculate quality */ |
Holger Schurig | cad9d9b | 2007-08-02 13:07:15 -0400 | [diff] [blame] | 871 | priv->wstats.qual.qual = min_t(u8, quality, 100); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 872 | priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; |
| 873 | stats_valid = 1; |
| 874 | |
| 875 | /* update stats asynchronously for future calls */ |
Amitkumar Karwar | c0bbd57 | 2009-10-08 19:38:45 -0700 | [diff] [blame] | 876 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 877 | 0, 0, NULL); |
Amitkumar Karwar | c0bbd57 | 2009-10-08 19:38:45 -0700 | [diff] [blame] | 878 | if (ret) |
| 879 | lbs_pr_err("RSSI command failed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 880 | out: |
| 881 | if (!stats_valid) { |
| 882 | priv->wstats.miss.beacon = 0; |
| 883 | priv->wstats.discard.retries = 0; |
| 884 | priv->wstats.qual.qual = 0; |
| 885 | priv->wstats.qual.level = 0; |
| 886 | priv->wstats.qual.noise = 0; |
| 887 | priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED; |
| 888 | priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID | |
| 889 | IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; |
| 890 | } |
| 891 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 892 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 893 | return &priv->wstats; |
| 894 | |
| 895 | |
| 896 | } |
| 897 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 898 | static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 899 | struct iw_freq *fwrq, char *extra) |
| 900 | { |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 901 | int ret = -EINVAL; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 902 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 903 | struct chan_freq_power *cfp; |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 904 | struct assoc_request * assoc_req; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 905 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 906 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 907 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 908 | mutex_lock(&priv->lock); |
| 909 | assoc_req = lbs_get_association_request(priv); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 910 | if (!assoc_req) { |
| 911 | ret = -ENOMEM; |
| 912 | goto out; |
| 913 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 914 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 915 | /* If setting by frequency, convert to a channel */ |
| 916 | if (fwrq->e == 1) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 917 | long f = fwrq->m / 100000; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 918 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 919 | cfp = find_cfp_by_band_and_freq(priv, 0, f); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 920 | if (!cfp) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 921 | lbs_deb_wext("invalid freq %ld\n", f); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 922 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 923 | } |
| 924 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 925 | fwrq->e = 0; |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 926 | fwrq->m = (int) cfp->channel; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 927 | } |
| 928 | |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 929 | /* Setting by channel number */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 930 | if (fwrq->m > 1000 || fwrq->e > 0) { |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 931 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 932 | } |
| 933 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 934 | cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 935 | if (!cfp) { |
| 936 | goto out; |
| 937 | } |
| 938 | |
| 939 | assoc_req->channel = fwrq->m; |
| 940 | ret = 0; |
| 941 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 942 | out: |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 943 | if (ret == 0) { |
| 944 | set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 945 | lbs_postpone_association_work(priv); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 946 | } else { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 947 | lbs_cancel_association_work(priv); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 948 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 949 | mutex_unlock(&priv->lock); |
Dan Williams | ef9a264 | 2007-05-25 16:46:33 -0400 | [diff] [blame] | 950 | |
| 951 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 952 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 953 | } |
| 954 | |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 955 | static int lbs_mesh_set_freq(struct net_device *dev, |
| 956 | struct iw_request_info *info, |
| 957 | struct iw_freq *fwrq, char *extra) |
| 958 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 959 | struct lbs_private *priv = dev->ml_priv; |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 960 | struct chan_freq_power *cfp; |
| 961 | int ret = -EINVAL; |
| 962 | |
| 963 | lbs_deb_enter(LBS_DEB_WEXT); |
| 964 | |
| 965 | /* If setting by frequency, convert to a channel */ |
| 966 | if (fwrq->e == 1) { |
| 967 | long f = fwrq->m / 100000; |
| 968 | |
| 969 | cfp = find_cfp_by_band_and_freq(priv, 0, f); |
| 970 | if (!cfp) { |
| 971 | lbs_deb_wext("invalid freq %ld\n", f); |
| 972 | goto out; |
| 973 | } |
| 974 | |
| 975 | fwrq->e = 0; |
| 976 | fwrq->m = (int) cfp->channel; |
| 977 | } |
| 978 | |
| 979 | /* Setting by channel number */ |
| 980 | if (fwrq->m > 1000 || fwrq->e > 0) { |
| 981 | goto out; |
| 982 | } |
| 983 | |
| 984 | cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m); |
| 985 | if (!cfp) { |
| 986 | goto out; |
| 987 | } |
| 988 | |
| 989 | if (fwrq->m != priv->curbssparams.channel) { |
| 990 | lbs_deb_wext("mesh channel change forces eth disconnect\n"); |
| 991 | if (priv->mode == IW_MODE_INFRA) |
Dan Williams | 191bb40 | 2008-08-21 17:46:18 -0400 | [diff] [blame] | 992 | lbs_cmd_80211_deauthenticate(priv, |
| 993 | priv->curbssparams.bssid, |
| 994 | WLAN_REASON_DEAUTH_LEAVING); |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 995 | else if (priv->mode == IW_MODE_ADHOC) |
Dan Williams | f5fe1fd | 2008-08-21 21:46:59 -0400 | [diff] [blame] | 996 | lbs_adhoc_stop(priv); |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 997 | } |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 998 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m); |
David Woodhouse | 8606213 | 2007-12-13 00:32:36 -0500 | [diff] [blame] | 999 | lbs_update_channel(priv); |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 1000 | ret = 0; |
| 1001 | |
| 1002 | out: |
| 1003 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 1004 | return ret; |
| 1005 | } |
| 1006 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1007 | static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1008 | struct iw_param *vwrq, char *extra) |
| 1009 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1010 | struct lbs_private *priv = dev->ml_priv; |
Dan Williams | 8e3c91b | 2007-12-11 15:50:59 -0500 | [diff] [blame] | 1011 | u8 new_rate = 0; |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1012 | int ret = -EINVAL; |
| 1013 | u8 rates[MAX_RATES + 1]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1014 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1015 | lbs_deb_enter(LBS_DEB_WEXT); |
Amitkumar Karwar | 4912545 | 2009-09-30 20:04:38 -0700 | [diff] [blame] | 1016 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1017 | lbs_deb_wext("vwrq->value %d\n", vwrq->value); |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1018 | lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed); |
| 1019 | |
| 1020 | if (vwrq->fixed && vwrq->value == -1) |
| 1021 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1022 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1023 | /* Auto rate? */ |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1024 | priv->enablehwauto = !vwrq->fixed; |
| 1025 | |
| 1026 | if (vwrq->value == -1) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1027 | priv->cur_rate = 0; |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1028 | else { |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1029 | if (vwrq->value % 100000) |
| 1030 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1031 | |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1032 | new_rate = vwrq->value / 500000; |
| 1033 | priv->cur_rate = new_rate; |
| 1034 | /* the rest is only needed for lbs_set_data_rate() */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1035 | memset(rates, 0, sizeof(rates)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1036 | copy_active_data_rates(priv, rates); |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1037 | if (!memchr(rates, new_rate, sizeof(rates))) { |
| 1038 | lbs_pr_alert("fixed data rate 0x%X out of range\n", |
| 1039 | new_rate); |
| 1040 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1041 | } |
Anna Neal | 3ed6e08 | 2008-09-26 11:34:35 -0400 | [diff] [blame] | 1042 | if (priv->fwrelease < 0x09000000) { |
| 1043 | ret = lbs_set_power_adapt_cfg(priv, 0, |
| 1044 | POW_ADAPT_DEFAULT_P0, |
| 1045 | POW_ADAPT_DEFAULT_P1, |
| 1046 | POW_ADAPT_DEFAULT_P2); |
| 1047 | if (ret) |
| 1048 | goto out; |
| 1049 | } |
| 1050 | ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1, |
| 1051 | TPC_DEFAULT_P2, 1); |
| 1052 | if (ret) |
| 1053 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1054 | } |
| 1055 | |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1056 | /* Try the newer command first (Firmware Spec 5.1 and above) */ |
| 1057 | ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET); |
| 1058 | |
| 1059 | /* Fallback to older version */ |
| 1060 | if (ret) |
| 1061 | ret = lbs_set_data_rate(priv, new_rate); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1062 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1063 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1064 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1065 | return ret; |
| 1066 | } |
| 1067 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1068 | static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1069 | struct iw_param *vwrq, char *extra) |
| 1070 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1071 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1072 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1073 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1074 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1075 | if (priv->connect_status == LBS_CONNECTED) { |
| 1076 | vwrq->value = priv->cur_rate * 500000; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1077 | |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 1078 | if (priv->enablehwauto) |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1079 | vwrq->fixed = 0; |
| 1080 | else |
| 1081 | vwrq->fixed = 1; |
| 1082 | |
| 1083 | } else { |
| 1084 | vwrq->fixed = 0; |
| 1085 | vwrq->value = 0; |
| 1086 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1087 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1088 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1089 | return 0; |
| 1090 | } |
| 1091 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1092 | static int lbs_set_mode(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1093 | struct iw_request_info *info, u32 * uwrq, char *extra) |
| 1094 | { |
| 1095 | int ret = 0; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1096 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1097 | struct assoc_request * assoc_req; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1098 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1099 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1100 | |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1101 | if ( (*uwrq != IW_MODE_ADHOC) |
| 1102 | && (*uwrq != IW_MODE_INFRA) |
| 1103 | && (*uwrq != IW_MODE_AUTO)) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1104 | lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq); |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1105 | ret = -EINVAL; |
| 1106 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1107 | } |
| 1108 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1109 | mutex_lock(&priv->lock); |
| 1110 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1111 | if (!assoc_req) { |
| 1112 | ret = -ENOMEM; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1113 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1114 | } else { |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1115 | assoc_req->mode = *uwrq; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1116 | set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1117 | lbs_postpone_association_work(priv); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1118 | lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1119 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1120 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1121 | |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1122 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1123 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1124 | return ret; |
| 1125 | } |
| 1126 | |
| 1127 | |
| 1128 | /** |
| 1129 | * @brief Get Encryption key |
| 1130 | * |
| 1131 | * @param dev A pointer to net_device structure |
| 1132 | * @param info A pointer to iw_request_info structure |
| 1133 | * @param vwrq A pointer to iw_param structure |
| 1134 | * @param extra A pointer to extra data buf |
| 1135 | * @return 0 --success, otherwise fail |
| 1136 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1137 | static int lbs_get_encode(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1138 | struct iw_request_info *info, |
| 1139 | struct iw_point *dwrq, u8 * extra) |
| 1140 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1141 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1142 | int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; |
| 1143 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1144 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1145 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1146 | lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1147 | dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1148 | |
| 1149 | dwrq->flags = 0; |
| 1150 | |
| 1151 | /* Authentication method */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1152 | switch (priv->secinfo.auth_mode) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1153 | case IW_AUTH_ALG_OPEN_SYSTEM: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1154 | dwrq->flags = IW_ENCODE_OPEN; |
| 1155 | break; |
| 1156 | |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1157 | case IW_AUTH_ALG_SHARED_KEY: |
| 1158 | case IW_AUTH_ALG_LEAP: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1159 | dwrq->flags = IW_ENCODE_RESTRICTED; |
| 1160 | break; |
| 1161 | default: |
| 1162 | dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN; |
| 1163 | break; |
| 1164 | } |
| 1165 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1166 | memset(extra, 0, 16); |
| 1167 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1168 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1169 | |
| 1170 | /* Default to returning current transmit key */ |
| 1171 | if (index < 0) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1172 | index = priv->wep_tx_keyidx; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1173 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1174 | if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) { |
| 1175 | memcpy(extra, priv->wep_keys[index].key, |
| 1176 | priv->wep_keys[index].len); |
| 1177 | dwrq->length = priv->wep_keys[index].len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1178 | |
| 1179 | dwrq->flags |= (index + 1); |
| 1180 | /* Return WEP enabled */ |
| 1181 | dwrq->flags &= ~IW_ENCODE_DISABLED; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1182 | } else if ((priv->secinfo.WPAenabled) |
| 1183 | || (priv->secinfo.WPA2enabled)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1184 | /* return WPA enabled */ |
| 1185 | dwrq->flags &= ~IW_ENCODE_DISABLED; |
David Woodhouse | c12bdc4 | 2007-12-07 19:32:12 +0000 | [diff] [blame] | 1186 | dwrq->flags |= IW_ENCODE_NOKEY; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1187 | } else { |
| 1188 | dwrq->flags |= IW_ENCODE_DISABLED; |
| 1189 | } |
| 1190 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1191 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1192 | |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 1193 | lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1194 | extra[0], extra[1], extra[2], |
| 1195 | extra[3], extra[4], extra[5], dwrq->length); |
| 1196 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1197 | lbs_deb_wext("return flags 0x%x\n", dwrq->flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1198 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1199 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1200 | return 0; |
| 1201 | } |
| 1202 | |
| 1203 | /** |
| 1204 | * @brief Set Encryption key (internal) |
| 1205 | * |
| 1206 | * @param priv A pointer to private card structure |
| 1207 | * @param key_material A pointer to key material |
| 1208 | * @param key_length length of key material |
| 1209 | * @param index key index to set |
| 1210 | * @param set_tx_key Force set TX key (1 = yes, 0 = no) |
| 1211 | * @return 0 --success, otherwise fail |
| 1212 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1213 | static int lbs_set_wep_key(struct assoc_request *assoc_req, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1214 | const char *key_material, |
| 1215 | u16 key_length, |
| 1216 | u16 index, |
| 1217 | int set_tx_key) |
| 1218 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1219 | int ret = 0; |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1220 | struct enc_key *pkey; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1221 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1222 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1223 | |
| 1224 | /* Paranoid validation of key index */ |
| 1225 | if (index > 3) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1226 | ret = -EINVAL; |
| 1227 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | /* validate max key length */ |
| 1231 | if (key_length > KEY_LEN_WEP_104) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1232 | ret = -EINVAL; |
| 1233 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1234 | } |
| 1235 | |
| 1236 | pkey = &assoc_req->wep_keys[index]; |
| 1237 | |
| 1238 | if (key_length > 0) { |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1239 | memset(pkey, 0, sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1240 | pkey->type = KEY_TYPE_ID_WEP; |
| 1241 | |
| 1242 | /* Standardize the key length */ |
| 1243 | pkey->len = (key_length > KEY_LEN_WEP_40) ? |
| 1244 | KEY_LEN_WEP_104 : KEY_LEN_WEP_40; |
| 1245 | memcpy(pkey->key, key_material, key_length); |
| 1246 | } |
| 1247 | |
| 1248 | if (set_tx_key) { |
| 1249 | /* Ensure the chosen key is valid */ |
| 1250 | if (!pkey->len) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1251 | lbs_deb_wext("key not set, so cannot enable it\n"); |
| 1252 | ret = -EINVAL; |
| 1253 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1254 | } |
| 1255 | assoc_req->wep_tx_keyidx = index; |
| 1256 | } |
| 1257 | |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1258 | assoc_req->secinfo.wep_enabled = 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1259 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1260 | out: |
| 1261 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 1262 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | static int validate_key_index(u16 def_index, u16 raw_index, |
| 1266 | u16 *out_index, u16 *is_default) |
| 1267 | { |
| 1268 | if (!out_index || !is_default) |
| 1269 | return -EINVAL; |
| 1270 | |
| 1271 | /* Verify index if present, otherwise use default TX key index */ |
| 1272 | if (raw_index > 0) { |
| 1273 | if (raw_index > 4) |
| 1274 | return -EINVAL; |
| 1275 | *out_index = raw_index - 1; |
| 1276 | } else { |
| 1277 | *out_index = def_index; |
| 1278 | *is_default = 1; |
| 1279 | } |
| 1280 | return 0; |
| 1281 | } |
| 1282 | |
| 1283 | static void disable_wep(struct assoc_request *assoc_req) |
| 1284 | { |
| 1285 | int i; |
| 1286 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1287 | lbs_deb_enter(LBS_DEB_WEXT); |
| 1288 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1289 | /* Set Open System auth mode */ |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1290 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1291 | |
| 1292 | /* Clear WEP keys and mark WEP as disabled */ |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1293 | assoc_req->secinfo.wep_enabled = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1294 | for (i = 0; i < 4; i++) |
| 1295 | assoc_req->wep_keys[i].len = 0; |
| 1296 | |
| 1297 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
| 1298 | set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1299 | |
| 1300 | lbs_deb_leave(LBS_DEB_WEXT); |
| 1301 | } |
| 1302 | |
| 1303 | static void disable_wpa(struct assoc_request *assoc_req) |
| 1304 | { |
| 1305 | lbs_deb_enter(LBS_DEB_WEXT); |
| 1306 | |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1307 | memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key)); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1308 | assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST; |
| 1309 | set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); |
| 1310 | |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1311 | memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key)); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1312 | assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST; |
| 1313 | set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); |
| 1314 | |
| 1315 | assoc_req->secinfo.WPAenabled = 0; |
| 1316 | assoc_req->secinfo.WPA2enabled = 0; |
| 1317 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
| 1318 | |
| 1319 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1320 | } |
| 1321 | |
| 1322 | /** |
| 1323 | * @brief Set Encryption key |
| 1324 | * |
| 1325 | * @param dev A pointer to net_device structure |
| 1326 | * @param info A pointer to iw_request_info structure |
| 1327 | * @param vwrq A pointer to iw_param structure |
| 1328 | * @param extra A pointer to extra data buf |
| 1329 | * @return 0 --success, otherwise fail |
| 1330 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1331 | static int lbs_set_encode(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1332 | struct iw_request_info *info, |
| 1333 | struct iw_point *dwrq, char *extra) |
| 1334 | { |
| 1335 | int ret = 0; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1336 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1337 | struct assoc_request * assoc_req; |
| 1338 | u16 is_default = 0, index = 0, set_tx_key = 0; |
| 1339 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1340 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1341 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1342 | mutex_lock(&priv->lock); |
| 1343 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1344 | if (!assoc_req) { |
| 1345 | ret = -ENOMEM; |
| 1346 | goto out; |
| 1347 | } |
| 1348 | |
| 1349 | if (dwrq->flags & IW_ENCODE_DISABLED) { |
| 1350 | disable_wep (assoc_req); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1351 | disable_wpa (assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1352 | goto out; |
| 1353 | } |
| 1354 | |
| 1355 | ret = validate_key_index(assoc_req->wep_tx_keyidx, |
| 1356 | (dwrq->flags & IW_ENCODE_INDEX), |
| 1357 | &index, &is_default); |
| 1358 | if (ret) { |
| 1359 | ret = -EINVAL; |
| 1360 | goto out; |
| 1361 | } |
| 1362 | |
| 1363 | /* If WEP isn't enabled, or if there is no key data but a valid |
| 1364 | * index, set the TX key. |
| 1365 | */ |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1366 | if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default)) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1367 | set_tx_key = 1; |
| 1368 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1369 | ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1370 | if (ret) |
| 1371 | goto out; |
| 1372 | |
| 1373 | if (dwrq->length) |
| 1374 | set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); |
| 1375 | if (set_tx_key) |
| 1376 | set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); |
| 1377 | |
| 1378 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1379 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1380 | } else if (dwrq->flags & IW_ENCODE_OPEN) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1381 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1382 | } |
| 1383 | |
| 1384 | out: |
| 1385 | if (ret == 0) { |
| 1386 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1387 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1388 | } else { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1389 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1390 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1391 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1392 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1393 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1394 | return ret; |
| 1395 | } |
| 1396 | |
| 1397 | /** |
| 1398 | * @brief Get Extended Encryption key (WPA/802.1x and WEP) |
| 1399 | * |
| 1400 | * @param dev A pointer to net_device structure |
| 1401 | * @param info A pointer to iw_request_info structure |
| 1402 | * @param vwrq A pointer to iw_param structure |
| 1403 | * @param extra A pointer to extra data buf |
| 1404 | * @return 0 on success, otherwise failure |
| 1405 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1406 | static int lbs_get_encodeext(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1407 | struct iw_request_info *info, |
| 1408 | struct iw_point *dwrq, |
| 1409 | char *extra) |
| 1410 | { |
| 1411 | int ret = -EINVAL; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1412 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1413 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
| 1414 | int index, max_key_len; |
| 1415 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1416 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1417 | |
| 1418 | max_key_len = dwrq->length - sizeof(*ext); |
| 1419 | if (max_key_len < 0) |
| 1420 | goto out; |
| 1421 | |
| 1422 | index = dwrq->flags & IW_ENCODE_INDEX; |
| 1423 | if (index) { |
| 1424 | if (index < 1 || index > 4) |
| 1425 | goto out; |
| 1426 | index--; |
| 1427 | } else { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1428 | index = priv->wep_tx_keyidx; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1429 | } |
| 1430 | |
Roel Kluin | f59d978 | 2007-10-26 21:51:26 +0200 | [diff] [blame] | 1431 | if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) && |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1432 | ext->alg != IW_ENCODE_ALG_WEP) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1433 | if (index != 0 || priv->mode != IW_MODE_INFRA) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1434 | goto out; |
| 1435 | } |
| 1436 | |
| 1437 | dwrq->flags = index + 1; |
| 1438 | memset(ext, 0, sizeof(*ext)); |
| 1439 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1440 | if ( !priv->secinfo.wep_enabled |
| 1441 | && !priv->secinfo.WPAenabled |
| 1442 | && !priv->secinfo.WPA2enabled) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1443 | ext->alg = IW_ENCODE_ALG_NONE; |
| 1444 | ext->key_len = 0; |
| 1445 | dwrq->flags |= IW_ENCODE_DISABLED; |
| 1446 | } else { |
| 1447 | u8 *key = NULL; |
| 1448 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1449 | if ( priv->secinfo.wep_enabled |
| 1450 | && !priv->secinfo.WPAenabled |
| 1451 | && !priv->secinfo.WPA2enabled) { |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1452 | /* WEP */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1453 | ext->alg = IW_ENCODE_ALG_WEP; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1454 | ext->key_len = priv->wep_keys[index].len; |
| 1455 | key = &priv->wep_keys[index].key[0]; |
| 1456 | } else if ( !priv->secinfo.wep_enabled |
| 1457 | && (priv->secinfo.WPAenabled || |
| 1458 | priv->secinfo.WPA2enabled)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1459 | /* WPA */ |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1460 | struct enc_key * pkey = NULL; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1461 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1462 | if ( priv->wpa_mcast_key.len |
| 1463 | && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED)) |
| 1464 | pkey = &priv->wpa_mcast_key; |
| 1465 | else if ( priv->wpa_unicast_key.len |
| 1466 | && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED)) |
| 1467 | pkey = &priv->wpa_unicast_key; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1468 | |
| 1469 | if (pkey) { |
| 1470 | if (pkey->type == KEY_TYPE_ID_AES) { |
| 1471 | ext->alg = IW_ENCODE_ALG_CCMP; |
| 1472 | } else { |
| 1473 | ext->alg = IW_ENCODE_ALG_TKIP; |
| 1474 | } |
| 1475 | ext->key_len = pkey->len; |
| 1476 | key = &pkey->key[0]; |
| 1477 | } else { |
| 1478 | ext->alg = IW_ENCODE_ALG_TKIP; |
| 1479 | ext->key_len = 0; |
| 1480 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1481 | } else { |
| 1482 | goto out; |
| 1483 | } |
| 1484 | |
| 1485 | if (ext->key_len > max_key_len) { |
| 1486 | ret = -E2BIG; |
| 1487 | goto out; |
| 1488 | } |
| 1489 | |
| 1490 | if (ext->key_len) |
| 1491 | memcpy(ext->key, key, ext->key_len); |
| 1492 | else |
| 1493 | dwrq->flags |= IW_ENCODE_NOKEY; |
| 1494 | dwrq->flags |= IW_ENCODE_ENABLED; |
| 1495 | } |
| 1496 | ret = 0; |
| 1497 | |
| 1498 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1499 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1500 | return ret; |
| 1501 | } |
| 1502 | |
| 1503 | /** |
| 1504 | * @brief Set Encryption key Extended (WPA/802.1x and WEP) |
| 1505 | * |
| 1506 | * @param dev A pointer to net_device structure |
| 1507 | * @param info A pointer to iw_request_info structure |
| 1508 | * @param vwrq A pointer to iw_param structure |
| 1509 | * @param extra A pointer to extra data buf |
| 1510 | * @return 0 --success, otherwise fail |
| 1511 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1512 | static int lbs_set_encodeext(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1513 | struct iw_request_info *info, |
| 1514 | struct iw_point *dwrq, |
| 1515 | char *extra) |
| 1516 | { |
| 1517 | int ret = 0; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1518 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1519 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
| 1520 | int alg = ext->alg; |
| 1521 | struct assoc_request * assoc_req; |
| 1522 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1523 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1524 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1525 | mutex_lock(&priv->lock); |
| 1526 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1527 | if (!assoc_req) { |
| 1528 | ret = -ENOMEM; |
| 1529 | goto out; |
| 1530 | } |
| 1531 | |
| 1532 | if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) { |
| 1533 | disable_wep (assoc_req); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1534 | disable_wpa (assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1535 | } else if (alg == IW_ENCODE_ALG_WEP) { |
| 1536 | u16 is_default = 0, index, set_tx_key = 0; |
| 1537 | |
| 1538 | ret = validate_key_index(assoc_req->wep_tx_keyidx, |
| 1539 | (dwrq->flags & IW_ENCODE_INDEX), |
| 1540 | &index, &is_default); |
| 1541 | if (ret) |
| 1542 | goto out; |
| 1543 | |
| 1544 | /* If WEP isn't enabled, or if there is no key data but a valid |
| 1545 | * index, or if the set-TX-key flag was passed, set the TX key. |
| 1546 | */ |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1547 | if ( !assoc_req->secinfo.wep_enabled |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1548 | || (dwrq->length == 0 && !is_default) |
| 1549 | || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) |
| 1550 | set_tx_key = 1; |
| 1551 | |
| 1552 | /* Copy key to driver */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1553 | ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1554 | set_tx_key); |
| 1555 | if (ret) |
| 1556 | goto out; |
| 1557 | |
| 1558 | if (dwrq->flags & IW_ENCODE_RESTRICTED) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1559 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1560 | } else if (dwrq->flags & IW_ENCODE_OPEN) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1561 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1562 | } |
| 1563 | |
| 1564 | /* Mark the various WEP bits as modified */ |
| 1565 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
| 1566 | if (dwrq->length) |
| 1567 | set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); |
| 1568 | if (set_tx_key) |
| 1569 | set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1570 | } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) { |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1571 | struct enc_key * pkey; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1572 | |
| 1573 | /* validate key length */ |
| 1574 | if (((alg == IW_ENCODE_ALG_TKIP) |
| 1575 | && (ext->key_len != KEY_LEN_WPA_TKIP)) |
| 1576 | || ((alg == IW_ENCODE_ALG_CCMP) |
| 1577 | && (ext->key_len != KEY_LEN_WPA_AES))) { |
Joe Perches | 8376e7a | 2007-11-19 17:48:27 -0800 | [diff] [blame] | 1578 | lbs_deb_wext("invalid size %d for key of alg " |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1579 | "type %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1580 | ext->key_len, |
| 1581 | alg); |
| 1582 | ret = -EINVAL; |
| 1583 | goto out; |
| 1584 | } |
| 1585 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1586 | if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1587 | pkey = &assoc_req->wpa_mcast_key; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1588 | set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); |
| 1589 | } else { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1590 | pkey = &assoc_req->wpa_unicast_key; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1591 | set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); |
| 1592 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1593 | |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 1594 | memset(pkey, 0, sizeof (struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1595 | memcpy(pkey->key, ext->key, ext->key_len); |
| 1596 | pkey->len = ext->key_len; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1597 | if (pkey->len) |
| 1598 | pkey->flags |= KEY_INFO_WPA_ENABLED; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1599 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1600 | /* Do this after zeroing key structure */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1601 | if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { |
| 1602 | pkey->flags |= KEY_INFO_WPA_MCAST; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1603 | } else { |
| 1604 | pkey->flags |= KEY_INFO_WPA_UNICAST; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1605 | } |
| 1606 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1607 | if (alg == IW_ENCODE_ALG_TKIP) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1608 | pkey->type = KEY_TYPE_ID_TKIP; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1609 | } else if (alg == IW_ENCODE_ALG_CCMP) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1610 | pkey->type = KEY_TYPE_ID_AES; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1611 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1612 | |
| 1613 | /* If WPA isn't enabled yet, do that now */ |
| 1614 | if ( assoc_req->secinfo.WPAenabled == 0 |
| 1615 | && assoc_req->secinfo.WPA2enabled == 0) { |
| 1616 | assoc_req->secinfo.WPAenabled = 1; |
| 1617 | assoc_req->secinfo.WPA2enabled = 1; |
| 1618 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
| 1619 | } |
| 1620 | |
Javier Cardona | 9c31fd63 | 2008-09-11 15:32:50 -0700 | [diff] [blame] | 1621 | /* Only disable wep if necessary: can't waste time here. */ |
| 1622 | if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE) |
| 1623 | disable_wep(assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1624 | } |
| 1625 | |
| 1626 | out: |
Javier Cardona | 9c40fc5 | 2008-09-16 18:08:39 -0700 | [diff] [blame] | 1627 | if (ret == 0) { |
| 1628 | /* 802.1x and WPA rekeying must happen as quickly as possible, |
| 1629 | * especially during the 4-way handshake; thus if in |
| 1630 | * infrastructure mode, and either (a) 802.1x is enabled or |
| 1631 | * (b) WPA is being used, set the key right away. |
| 1632 | */ |
| 1633 | if (assoc_req->mode == IW_MODE_INFRA && |
| 1634 | ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) || |
| 1635 | (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) || |
| 1636 | assoc_req->secinfo.WPAenabled || |
| 1637 | assoc_req->secinfo.WPA2enabled)) { |
| 1638 | lbs_do_association_work(priv); |
| 1639 | } else |
| 1640 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1641 | } else { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1642 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1643 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1644 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1645 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1646 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1647 | return ret; |
| 1648 | } |
| 1649 | |
| 1650 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1651 | static int lbs_set_genie(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1652 | struct iw_request_info *info, |
| 1653 | struct iw_point *dwrq, |
| 1654 | char *extra) |
| 1655 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1656 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1657 | int ret = 0; |
| 1658 | struct assoc_request * assoc_req; |
| 1659 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1660 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1661 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1662 | mutex_lock(&priv->lock); |
| 1663 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1664 | if (!assoc_req) { |
| 1665 | ret = -ENOMEM; |
| 1666 | goto out; |
| 1667 | } |
| 1668 | |
| 1669 | if (dwrq->length > MAX_WPA_IE_LEN || |
| 1670 | (dwrq->length && extra == NULL)) { |
| 1671 | ret = -EINVAL; |
| 1672 | goto out; |
| 1673 | } |
| 1674 | |
| 1675 | if (dwrq->length) { |
| 1676 | memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length); |
| 1677 | assoc_req->wpa_ie_len = dwrq->length; |
| 1678 | } else { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1679 | memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1680 | assoc_req->wpa_ie_len = 0; |
| 1681 | } |
| 1682 | |
| 1683 | out: |
| 1684 | if (ret == 0) { |
| 1685 | set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1686 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1687 | } else { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1688 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1689 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1690 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1691 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1692 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1693 | return ret; |
| 1694 | } |
| 1695 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1696 | static int lbs_get_genie(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1697 | struct iw_request_info *info, |
| 1698 | struct iw_point *dwrq, |
| 1699 | char *extra) |
| 1700 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1701 | int ret = 0; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1702 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1703 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1704 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1705 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1706 | if (priv->wpa_ie_len == 0) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1707 | dwrq->length = 0; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1708 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1709 | } |
| 1710 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1711 | if (dwrq->length < priv->wpa_ie_len) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1712 | ret = -E2BIG; |
| 1713 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1714 | } |
| 1715 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1716 | dwrq->length = priv->wpa_ie_len; |
| 1717 | memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1718 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1719 | out: |
| 1720 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 1721 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1722 | } |
| 1723 | |
| 1724 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1725 | static int lbs_set_auth(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1726 | struct iw_request_info *info, |
| 1727 | struct iw_param *dwrq, |
| 1728 | char *extra) |
| 1729 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1730 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1731 | struct assoc_request * assoc_req; |
| 1732 | int ret = 0; |
| 1733 | int updated = 0; |
| 1734 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1735 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1736 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1737 | mutex_lock(&priv->lock); |
| 1738 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1739 | if (!assoc_req) { |
| 1740 | ret = -ENOMEM; |
| 1741 | goto out; |
| 1742 | } |
| 1743 | |
| 1744 | switch (dwrq->flags & IW_AUTH_INDEX) { |
Maithili Hinge | 2c8d510 | 2009-07-31 20:02:19 -0700 | [diff] [blame] | 1745 | case IW_AUTH_PRIVACY_INVOKED: |
| 1746 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1747 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 1748 | case IW_AUTH_CIPHER_PAIRWISE: |
| 1749 | case IW_AUTH_CIPHER_GROUP: |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1750 | case IW_AUTH_DROP_UNENCRYPTED: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1751 | /* |
| 1752 | * libertas does not use these parameters |
| 1753 | */ |
| 1754 | break; |
| 1755 | |
Javier Cardona | 9c40fc5 | 2008-09-16 18:08:39 -0700 | [diff] [blame] | 1756 | case IW_AUTH_KEY_MGMT: |
| 1757 | assoc_req->secinfo.key_mgmt = dwrq->value; |
| 1758 | updated = 1; |
| 1759 | break; |
| 1760 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1761 | case IW_AUTH_WPA_VERSION: |
| 1762 | if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) { |
| 1763 | assoc_req->secinfo.WPAenabled = 0; |
| 1764 | assoc_req->secinfo.WPA2enabled = 0; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1765 | disable_wpa (assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1766 | } |
| 1767 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { |
| 1768 | assoc_req->secinfo.WPAenabled = 1; |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1769 | assoc_req->secinfo.wep_enabled = 0; |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1770 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1771 | } |
| 1772 | if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) { |
| 1773 | assoc_req->secinfo.WPA2enabled = 1; |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1774 | assoc_req->secinfo.wep_enabled = 0; |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1775 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1776 | } |
| 1777 | updated = 1; |
| 1778 | break; |
| 1779 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1780 | case IW_AUTH_80211_AUTH_ALG: |
| 1781 | if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1782 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1783 | } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1784 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1785 | } else if (dwrq->value & IW_AUTH_ALG_LEAP) { |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1786 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1787 | } else { |
| 1788 | ret = -EINVAL; |
| 1789 | } |
| 1790 | updated = 1; |
| 1791 | break; |
| 1792 | |
| 1793 | case IW_AUTH_WPA_ENABLED: |
| 1794 | if (dwrq->value) { |
| 1795 | if (!assoc_req->secinfo.WPAenabled && |
| 1796 | !assoc_req->secinfo.WPA2enabled) { |
| 1797 | assoc_req->secinfo.WPAenabled = 1; |
| 1798 | assoc_req->secinfo.WPA2enabled = 1; |
Dan Williams | 889c05b | 2007-05-10 22:57:23 -0400 | [diff] [blame] | 1799 | assoc_req->secinfo.wep_enabled = 0; |
Dan Williams | 6affe78 | 2007-05-10 22:56:42 -0400 | [diff] [blame] | 1800 | assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1801 | } |
| 1802 | } else { |
| 1803 | assoc_req->secinfo.WPAenabled = 0; |
| 1804 | assoc_req->secinfo.WPA2enabled = 0; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1805 | disable_wpa (assoc_req); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1806 | } |
| 1807 | updated = 1; |
| 1808 | break; |
| 1809 | |
| 1810 | default: |
| 1811 | ret = -EOPNOTSUPP; |
| 1812 | break; |
| 1813 | } |
| 1814 | |
| 1815 | out: |
| 1816 | if (ret == 0) { |
| 1817 | if (updated) |
| 1818 | set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1819 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1820 | } else if (ret != -EOPNOTSUPP) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1821 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1822 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1823 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1824 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1825 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1826 | return ret; |
| 1827 | } |
| 1828 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1829 | static int lbs_get_auth(struct net_device *dev, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1830 | struct iw_request_info *info, |
| 1831 | struct iw_param *dwrq, |
| 1832 | char *extra) |
| 1833 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1834 | int ret = 0; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1835 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1836 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1837 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1838 | |
| 1839 | switch (dwrq->flags & IW_AUTH_INDEX) { |
Javier Cardona | 9c40fc5 | 2008-09-16 18:08:39 -0700 | [diff] [blame] | 1840 | case IW_AUTH_KEY_MGMT: |
| 1841 | dwrq->value = priv->secinfo.key_mgmt; |
| 1842 | break; |
| 1843 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1844 | case IW_AUTH_WPA_VERSION: |
| 1845 | dwrq->value = 0; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1846 | if (priv->secinfo.WPAenabled) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1847 | dwrq->value |= IW_AUTH_WPA_VERSION_WPA; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1848 | if (priv->secinfo.WPA2enabled) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1849 | dwrq->value |= IW_AUTH_WPA_VERSION_WPA2; |
| 1850 | if (!dwrq->value) |
| 1851 | dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED; |
| 1852 | break; |
| 1853 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1854 | case IW_AUTH_80211_AUTH_ALG: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1855 | dwrq->value = priv->secinfo.auth_mode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1856 | break; |
| 1857 | |
| 1858 | case IW_AUTH_WPA_ENABLED: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1859 | if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1860 | dwrq->value = 1; |
| 1861 | break; |
| 1862 | |
| 1863 | default: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1864 | ret = -EOPNOTSUPP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1865 | } |
| 1866 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1867 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 1868 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1869 | } |
| 1870 | |
| 1871 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1872 | static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1873 | struct iw_param *vwrq, char *extra) |
| 1874 | { |
| 1875 | int ret = 0; |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1876 | struct lbs_private *priv = dev->ml_priv; |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1877 | s16 dbm = (s16) vwrq->value; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1878 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1879 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1880 | |
| 1881 | if (vwrq->disabled) { |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 1882 | lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0); |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1883 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1884 | } |
| 1885 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1886 | if (vwrq->fixed == 0) { |
Anna Neal | 0112c9e | 2008-09-11 11:17:25 -0700 | [diff] [blame] | 1887 | /* User requests automatic tx power control, however there are |
| 1888 | * many auto tx settings. For now use firmware defaults until |
| 1889 | * we come up with a good way to expose these to the user. */ |
| 1890 | if (priv->fwrelease < 0x09000000) { |
| 1891 | ret = lbs_set_power_adapt_cfg(priv, 1, |
| 1892 | POW_ADAPT_DEFAULT_P0, |
| 1893 | POW_ADAPT_DEFAULT_P1, |
| 1894 | POW_ADAPT_DEFAULT_P2); |
| 1895 | if (ret) |
| 1896 | goto out; |
| 1897 | } |
| 1898 | ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1, |
| 1899 | TPC_DEFAULT_P2, 1); |
| 1900 | if (ret) |
| 1901 | goto out; |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1902 | dbm = priv->txpower_max; |
| 1903 | } else { |
| 1904 | /* Userspace check in iwrange if it should use dBm or mW, |
| 1905 | * therefore this should never happen... Jean II */ |
| 1906 | if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) { |
| 1907 | ret = -EOPNOTSUPP; |
| 1908 | goto out; |
| 1909 | } |
| 1910 | |
Anna Neal | 0112c9e | 2008-09-11 11:17:25 -0700 | [diff] [blame] | 1911 | /* Validate requested power level against firmware allowed |
| 1912 | * levels */ |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1913 | if (priv->txpower_min && (dbm < priv->txpower_min)) { |
| 1914 | ret = -EINVAL; |
| 1915 | goto out; |
| 1916 | } |
| 1917 | |
| 1918 | if (priv->txpower_max && (dbm > priv->txpower_max)) { |
| 1919 | ret = -EINVAL; |
| 1920 | goto out; |
| 1921 | } |
Anna Neal | 0112c9e | 2008-09-11 11:17:25 -0700 | [diff] [blame] | 1922 | if (priv->fwrelease < 0x09000000) { |
| 1923 | ret = lbs_set_power_adapt_cfg(priv, 0, |
| 1924 | POW_ADAPT_DEFAULT_P0, |
| 1925 | POW_ADAPT_DEFAULT_P1, |
| 1926 | POW_ADAPT_DEFAULT_P2); |
| 1927 | if (ret) |
| 1928 | goto out; |
| 1929 | } |
| 1930 | ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1, |
| 1931 | TPC_DEFAULT_P2, 1); |
| 1932 | if (ret) |
| 1933 | goto out; |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1934 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1935 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 1936 | /* If the radio was off, turn it on */ |
| 1937 | if (!priv->radio_on) { |
| 1938 | ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1); |
| 1939 | if (ret) |
| 1940 | goto out; |
| 1941 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1942 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1943 | lbs_deb_wext("txpower set %d dBm\n", dbm); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1944 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1945 | ret = lbs_set_tx_power(priv, dbm); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1946 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 1947 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1948 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1949 | return ret; |
| 1950 | } |
| 1951 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1952 | static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1953 | struct iw_point *dwrq, char *extra) |
| 1954 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1955 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1956 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1957 | lbs_deb_enter(LBS_DEB_WEXT); |
| 1958 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1959 | /* |
| 1960 | * Note : if dwrq->flags != 0, we should get the relevant SSID from |
| 1961 | * the SSID list... |
| 1962 | */ |
| 1963 | |
| 1964 | /* |
| 1965 | * Get the current SSID |
| 1966 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1967 | if (priv->connect_status == LBS_CONNECTED) { |
| 1968 | memcpy(extra, priv->curbssparams.ssid, |
| 1969 | priv->curbssparams.ssid_len); |
| 1970 | extra[priv->curbssparams.ssid_len] = '\0'; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1971 | } else { |
| 1972 | memset(extra, 0, 32); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1973 | extra[priv->curbssparams.ssid_len] = '\0'; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1974 | } |
| 1975 | /* |
| 1976 | * If none, we may want to get the one that was set |
| 1977 | */ |
| 1978 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1979 | dwrq->length = priv->curbssparams.ssid_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1980 | |
| 1981 | dwrq->flags = 1; /* active */ |
| 1982 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1983 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1984 | return 0; |
| 1985 | } |
| 1986 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1987 | static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1988 | struct iw_point *dwrq, char *extra) |
| 1989 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 1990 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1991 | int ret = 0; |
Holger Schurig | 243e84e | 2009-10-22 15:30:47 +0200 | [diff] [blame^] | 1992 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1993 | u8 ssid_len = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1994 | struct assoc_request * assoc_req; |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1995 | int in_ssid_len = dwrq->length; |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 1996 | DECLARE_SSID_BUF(ssid_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1997 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1998 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1999 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 2000 | if (!priv->radio_on) { |
| 2001 | ret = -EINVAL; |
| 2002 | goto out; |
| 2003 | } |
| 2004 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2005 | /* Check the size of the string */ |
Holger Schurig | 243e84e | 2009-10-22 15:30:47 +0200 | [diff] [blame^] | 2006 | if (in_ssid_len > IEEE80211_MAX_SSID_LEN) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2007 | ret = -E2BIG; |
| 2008 | goto out; |
| 2009 | } |
| 2010 | |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 2011 | memset(&ssid, 0, sizeof(ssid)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2012 | |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 2013 | if (!dwrq->flags || !in_ssid_len) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2014 | /* "any" SSID requested; leave SSID blank */ |
| 2015 | } else { |
| 2016 | /* Specific SSID requested */ |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 2017 | memcpy(&ssid, extra, in_ssid_len); |
| 2018 | ssid_len = in_ssid_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2019 | } |
| 2020 | |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 2021 | if (!ssid_len) { |
| 2022 | lbs_deb_wext("requested any SSID\n"); |
| 2023 | } else { |
| 2024 | lbs_deb_wext("requested SSID '%s'\n", |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 2025 | print_ssid(ssid_buf, ssid, ssid_len)); |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 2026 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2027 | |
| 2028 | out: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2029 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2030 | if (ret == 0) { |
| 2031 | /* Get or create the current association request */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2032 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2033 | if (!assoc_req) { |
| 2034 | ret = -ENOMEM; |
| 2035 | } else { |
| 2036 | /* Copy the SSID to the association request */ |
Holger Schurig | 243e84e | 2009-10-22 15:30:47 +0200 | [diff] [blame^] | 2037 | memcpy(&assoc_req->ssid, &ssid, IEEE80211_MAX_SSID_LEN); |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 2038 | assoc_req->ssid_len = ssid_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2039 | set_bit(ASSOC_FLAG_SSID, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2040 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2041 | } |
| 2042 | } |
| 2043 | |
| 2044 | /* Cancel the association request if there was an error */ |
| 2045 | if (ret != 0) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2046 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2047 | } |
| 2048 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2049 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2050 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 2051 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2052 | return ret; |
| 2053 | } |
| 2054 | |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 2055 | static int lbs_mesh_get_essid(struct net_device *dev, |
| 2056 | struct iw_request_info *info, |
| 2057 | struct iw_point *dwrq, char *extra) |
| 2058 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 2059 | struct lbs_private *priv = dev->ml_priv; |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 2060 | |
| 2061 | lbs_deb_enter(LBS_DEB_WEXT); |
| 2062 | |
| 2063 | memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len); |
| 2064 | |
| 2065 | dwrq->length = priv->mesh_ssid_len; |
| 2066 | |
| 2067 | dwrq->flags = 1; /* active */ |
| 2068 | |
| 2069 | lbs_deb_leave(LBS_DEB_WEXT); |
| 2070 | return 0; |
| 2071 | } |
| 2072 | |
| 2073 | static int lbs_mesh_set_essid(struct net_device *dev, |
| 2074 | struct iw_request_info *info, |
| 2075 | struct iw_point *dwrq, char *extra) |
| 2076 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 2077 | struct lbs_private *priv = dev->ml_priv; |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 2078 | int ret = 0; |
| 2079 | |
| 2080 | lbs_deb_enter(LBS_DEB_WEXT); |
| 2081 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 2082 | if (!priv->radio_on) { |
| 2083 | ret = -EINVAL; |
| 2084 | goto out; |
| 2085 | } |
| 2086 | |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 2087 | /* Check the size of the string */ |
Holger Schurig | 243e84e | 2009-10-22 15:30:47 +0200 | [diff] [blame^] | 2088 | if (dwrq->length > IEEE80211_MAX_SSID_LEN) { |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 2089 | ret = -E2BIG; |
| 2090 | goto out; |
| 2091 | } |
| 2092 | |
| 2093 | if (!dwrq->flags || !dwrq->length) { |
| 2094 | ret = -EINVAL; |
| 2095 | goto out; |
| 2096 | } else { |
| 2097 | /* Specific SSID requested */ |
| 2098 | memcpy(priv->mesh_ssid, extra, dwrq->length); |
| 2099 | priv->mesh_ssid_len = dwrq->length; |
| 2100 | } |
| 2101 | |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 2102 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, |
| 2103 | priv->curbssparams.channel); |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 2104 | out: |
| 2105 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
| 2106 | return ret; |
| 2107 | } |
| 2108 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2109 | /** |
| 2110 | * @brief Connect to the AP or Ad-hoc Network with specific bssid |
| 2111 | * |
| 2112 | * @param dev A pointer to net_device structure |
| 2113 | * @param info A pointer to iw_request_info structure |
| 2114 | * @param awrq A pointer to iw_param structure |
| 2115 | * @param extra A pointer to extra data buf |
| 2116 | * @return 0 --success, otherwise fail |
| 2117 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2118 | static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2119 | struct sockaddr *awrq, char *extra) |
| 2120 | { |
Kiran Divekar | ab65f64 | 2009-02-19 19:32:39 -0500 | [diff] [blame] | 2121 | struct lbs_private *priv = dev->ml_priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2122 | struct assoc_request * assoc_req; |
| 2123 | int ret = 0; |
| 2124 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 2125 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2126 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 2127 | if (!priv->radio_on) |
| 2128 | return -EINVAL; |
| 2129 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2130 | if (awrq->sa_family != ARPHRD_ETHER) |
| 2131 | return -EINVAL; |
| 2132 | |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 2133 | lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2134 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2135 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2136 | |
| 2137 | /* Get or create the current association request */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2138 | assoc_req = lbs_get_association_request(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2139 | if (!assoc_req) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2140 | lbs_cancel_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2141 | ret = -ENOMEM; |
| 2142 | } else { |
| 2143 | /* Copy the BSSID to the association request */ |
| 2144 | memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN); |
| 2145 | set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2146 | lbs_postpone_association_work(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2147 | } |
| 2148 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2149 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2150 | |
| 2151 | return ret; |
| 2152 | } |
| 2153 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2154 | /* |
| 2155 | * iwconfig settable callbacks |
| 2156 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2157 | static const iw_handler lbs_handler[] = { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2158 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2159 | (iw_handler) lbs_get_name, /* SIOCGIWNAME */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2160 | (iw_handler) NULL, /* SIOCSIWNWID */ |
| 2161 | (iw_handler) NULL, /* SIOCGIWNWID */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2162 | (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */ |
| 2163 | (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */ |
| 2164 | (iw_handler) lbs_set_mode, /* SIOCSIWMODE */ |
| 2165 | (iw_handler) lbs_get_mode, /* SIOCGIWMODE */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2166 | (iw_handler) NULL, /* SIOCSIWSENS */ |
| 2167 | (iw_handler) NULL, /* SIOCGIWSENS */ |
| 2168 | (iw_handler) NULL, /* SIOCSIWRANGE */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2169 | (iw_handler) lbs_get_range, /* SIOCGIWRANGE */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2170 | (iw_handler) NULL, /* SIOCSIWPRIV */ |
| 2171 | (iw_handler) NULL, /* SIOCGIWPRIV */ |
| 2172 | (iw_handler) NULL, /* SIOCSIWSTATS */ |
| 2173 | (iw_handler) NULL, /* SIOCGIWSTATS */ |
| 2174 | iw_handler_set_spy, /* SIOCSIWSPY */ |
| 2175 | iw_handler_get_spy, /* SIOCGIWSPY */ |
| 2176 | iw_handler_set_thrspy, /* SIOCSIWTHRSPY */ |
| 2177 | iw_handler_get_thrspy, /* SIOCGIWTHRSPY */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2178 | (iw_handler) lbs_set_wap, /* SIOCSIWAP */ |
| 2179 | (iw_handler) lbs_get_wap, /* SIOCGIWAP */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2180 | (iw_handler) NULL, /* SIOCSIWMLME */ |
| 2181 | (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2182 | (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */ |
| 2183 | (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */ |
| 2184 | (iw_handler) lbs_set_essid, /* SIOCSIWESSID */ |
| 2185 | (iw_handler) lbs_get_essid, /* SIOCGIWESSID */ |
| 2186 | (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */ |
| 2187 | (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2188 | (iw_handler) NULL, /* -- hole -- */ |
| 2189 | (iw_handler) NULL, /* -- hole -- */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2190 | (iw_handler) lbs_set_rate, /* SIOCSIWRATE */ |
| 2191 | (iw_handler) lbs_get_rate, /* SIOCGIWRATE */ |
| 2192 | (iw_handler) lbs_set_rts, /* SIOCSIWRTS */ |
| 2193 | (iw_handler) lbs_get_rts, /* SIOCGIWRTS */ |
| 2194 | (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */ |
| 2195 | (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */ |
| 2196 | (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */ |
| 2197 | (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */ |
| 2198 | (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */ |
| 2199 | (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */ |
| 2200 | (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */ |
| 2201 | (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */ |
| 2202 | (iw_handler) lbs_set_power, /* SIOCSIWPOWER */ |
| 2203 | (iw_handler) lbs_get_power, /* SIOCGIWPOWER */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2204 | (iw_handler) NULL, /* -- hole -- */ |
| 2205 | (iw_handler) NULL, /* -- hole -- */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2206 | (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */ |
| 2207 | (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */ |
| 2208 | (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */ |
| 2209 | (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */ |
| 2210 | (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */ |
| 2211 | (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2212 | (iw_handler) NULL, /* SIOCSIWPMKSA */ |
| 2213 | }; |
| 2214 | |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2215 | static const iw_handler mesh_wlan_handler[] = { |
| 2216 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2217 | (iw_handler) lbs_get_name, /* SIOCGIWNAME */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2218 | (iw_handler) NULL, /* SIOCSIWNWID */ |
| 2219 | (iw_handler) NULL, /* SIOCGIWNWID */ |
David Woodhouse | 823eaa2 | 2007-12-11 19:56:28 -0500 | [diff] [blame] | 2220 | (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2221 | (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2222 | (iw_handler) NULL, /* SIOCSIWMODE */ |
| 2223 | (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */ |
| 2224 | (iw_handler) NULL, /* SIOCSIWSENS */ |
| 2225 | (iw_handler) NULL, /* SIOCGIWSENS */ |
| 2226 | (iw_handler) NULL, /* SIOCSIWRANGE */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2227 | (iw_handler) lbs_get_range, /* SIOCGIWRANGE */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2228 | (iw_handler) NULL, /* SIOCSIWPRIV */ |
| 2229 | (iw_handler) NULL, /* SIOCGIWPRIV */ |
| 2230 | (iw_handler) NULL, /* SIOCSIWSTATS */ |
| 2231 | (iw_handler) NULL, /* SIOCGIWSTATS */ |
| 2232 | iw_handler_set_spy, /* SIOCSIWSPY */ |
| 2233 | iw_handler_get_spy, /* SIOCGIWSPY */ |
| 2234 | iw_handler_set_thrspy, /* SIOCSIWTHRSPY */ |
| 2235 | iw_handler_get_thrspy, /* SIOCGIWTHRSPY */ |
| 2236 | (iw_handler) NULL, /* SIOCSIWAP */ |
| 2237 | (iw_handler) NULL, /* SIOCGIWAP */ |
| 2238 | (iw_handler) NULL, /* SIOCSIWMLME */ |
| 2239 | (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2240 | (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */ |
| 2241 | (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */ |
David Woodhouse | f5956bf | 2007-12-11 19:30:57 -0500 | [diff] [blame] | 2242 | (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */ |
| 2243 | (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2244 | (iw_handler) NULL, /* SIOCSIWNICKN */ |
| 2245 | (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */ |
| 2246 | (iw_handler) NULL, /* -- hole -- */ |
| 2247 | (iw_handler) NULL, /* -- hole -- */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2248 | (iw_handler) lbs_set_rate, /* SIOCSIWRATE */ |
| 2249 | (iw_handler) lbs_get_rate, /* SIOCGIWRATE */ |
| 2250 | (iw_handler) lbs_set_rts, /* SIOCSIWRTS */ |
| 2251 | (iw_handler) lbs_get_rts, /* SIOCGIWRTS */ |
| 2252 | (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */ |
| 2253 | (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */ |
| 2254 | (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */ |
| 2255 | (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */ |
| 2256 | (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */ |
| 2257 | (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */ |
| 2258 | (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */ |
| 2259 | (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */ |
| 2260 | (iw_handler) lbs_set_power, /* SIOCSIWPOWER */ |
| 2261 | (iw_handler) lbs_get_power, /* SIOCGIWPOWER */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2262 | (iw_handler) NULL, /* -- hole -- */ |
| 2263 | (iw_handler) NULL, /* -- hole -- */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2264 | (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */ |
| 2265 | (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */ |
| 2266 | (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */ |
| 2267 | (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */ |
| 2268 | (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */ |
| 2269 | (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */ |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2270 | (iw_handler) NULL, /* SIOCSIWPMKSA */ |
| 2271 | }; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2272 | struct iw_handler_def lbs_handler_def = { |
| 2273 | .num_standard = ARRAY_SIZE(lbs_handler), |
| 2274 | .standard = (iw_handler *) lbs_handler, |
| 2275 | .get_wireless_stats = lbs_get_wireless_stats, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2276 | }; |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2277 | |
| 2278 | struct iw_handler_def mesh_handler_def = { |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 2279 | .num_standard = ARRAY_SIZE(mesh_wlan_handler), |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2280 | .standard = (iw_handler *) mesh_wlan_handler, |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2281 | .get_wireless_stats = lbs_get_wireless_stats, |
Luis Carlos Cobo Rus | f5e05b6 | 2007-05-25 23:08:34 -0400 | [diff] [blame] | 2282 | }; |