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