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