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