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