| 1 | /* |
| 2 | * Driver for KeyStream 11b/g wireless LAN |
| 3 | * |
| 4 | * ks_wlan_net.c |
| 5 | * $Id: ks_wlan_net.c 1020 2009-09-28 05:48:31Z sekine $ |
| 6 | * |
| 7 | * Copyright (C) 2005-2008 KeyStream Corp. |
| 8 | * Copyright (C) 2009 Renesas Technology Corp. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it undr the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Sotware Foundation. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/version.h> |
| 16 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) |
| 17 | #include <linux/config.h> |
| 18 | #endif |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/compiler.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/ioport.h> |
| 24 | #include <linux/netdevice.h> |
| 25 | #include <linux/etherdevice.h> |
| 26 | #include <linux/if_arp.h> |
| 27 | #include <linux/rtnetlink.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/completion.h> |
| 30 | #include <linux/mii.h> |
| 31 | #include <linux/pci.h> |
| 32 | #include <linux/ctype.h> |
| 33 | #include <linux/timer.h> |
| 34 | #include <asm/atomic.h> |
| 35 | #include <asm/io.h> |
| 36 | #include <asm/uaccess.h> |
| 37 | |
| 38 | #if (defined _SDIO_) |
| 39 | #include <linux/mmc/sdio_func.h> |
| 40 | #endif |
| 41 | |
| 42 | #include "ks_wlan.h" |
| 43 | #include "ks_hostif.h" |
| 44 | #include "ks_wlan_ioctl.h" |
| 45 | #include "ks_debug.h" |
| 46 | |
| 47 | /* Include Wireless Extension definition and check version */ |
| 48 | #include <linux/wireless.h> |
| 49 | #define WIRELESS_SPY /* enable iwspy support */ |
| 50 | #include <net/iw_handler.h> /* New driver API */ |
| 51 | |
| 52 | #ifdef WIRELESS_EXT |
| 53 | /* Frequency list (map channels to frequencies) */ |
| 54 | static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, |
| 55 | 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; |
| 56 | |
| 57 | /* A few details needed for WEP (Wireless Equivalent Privacy) */ |
| 58 | #define MAX_KEY_SIZE 13 /* 128 (?) bits */ |
| 59 | #define MIN_KEY_SIZE 5 /* 40 bits RC4 - WEP */ |
| 60 | typedef struct wep_key_t { |
| 61 | u16 len; |
| 62 | u8 key[16]; /* 40-bit and 104-bit keys */ |
| 63 | } wep_key_t; |
| 64 | |
| 65 | /* Backward compatibility */ |
| 66 | #ifndef IW_ENCODE_NOKEY |
| 67 | #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */ |
| 68 | #define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN) |
| 69 | #endif /* IW_ENCODE_NOKEY */ |
| 70 | |
| 71 | static int wep_on_off; |
| 72 | #define WEP_OFF 0 |
| 73 | #define WEP_ON_64BIT 1 |
| 74 | #define WEP_ON_128BIT 2 |
| 75 | |
| 76 | static int wep_type; |
| 77 | #define WEP_KEY_CHARACTER 0 |
| 78 | #define WEP_KEY_HEX 1 |
| 79 | |
| 80 | /* List of Wireless Handlers (new API) */ |
| 81 | static const struct iw_handler_def ks_wlan_handler_def; |
| 82 | |
| 83 | #define KSC_OPNOTSUPP /* Operation Not Support*/ |
| 84 | |
| 85 | #endif /* WIRELESS_EXT */ |
| 86 | |
| 87 | |
| 88 | /* |
| 89 | * function prototypes |
| 90 | */ |
| 91 | extern int ks_wlan_hw_tx(ks_wlan_private *priv, void *p, unsigned long size, |
| 92 | void (*complete_handler)(void *arg1, void *arg2), |
| 93 | void *arg1, |
| 94 | void *arg2 ); |
| 95 | static int ks_wlan_open (struct net_device *dev); |
| 96 | static void ks_wlan_tx_timeout (struct net_device *dev); |
| 97 | static int ks_wlan_start_xmit (struct sk_buff *skb, struct net_device *dev); |
| 98 | static int ks_wlan_close (struct net_device *dev); |
| 99 | static void ks_wlan_set_multicast_list (struct net_device *dev); |
| 100 | static struct net_device_stats *ks_wlan_get_stats (struct net_device *dev); |
| 101 | static int ks_wlan_set_mac_address(struct net_device *dev, void *addr); |
| 102 | static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
| 103 | |
| 104 | static |
| 105 | int atoi(char *str) |
| 106 | { |
| 107 | int cnt; |
| 108 | int num=0; |
| 109 | |
| 110 | for (cnt = 0; (str[cnt] >= '0') && (str[cnt] <= '9'); cnt++) { |
| 111 | num = 10 * num + (str[cnt] - '0'); |
| 112 | } |
| 113 | |
| 114 | return num; |
| 115 | } |
| 116 | |
| 117 | static |
| 118 | void analyze_character_wep_key(struct ks_wlan_parameter *param, int wep_key_index, char *value) |
| 119 | { |
| 120 | int i; |
| 121 | unsigned char wep_key[26], key_length; |
| 122 | |
| 123 | key_length = (wep_on_off == WEP_ON_64BIT) ? 5 : 13; |
| 124 | /* 64bit key_length = 5; 128bit key_length = 13; */ |
| 125 | |
| 126 | for (i=0; i<key_length; i++) { |
| 127 | wep_key[i] = value[i]; |
| 128 | } |
| 129 | |
| 130 | if(wep_key_index < 0 || wep_key_index > 3) |
| 131 | return ; |
| 132 | |
| 133 | param->wep_key[wep_key_index].size = key_length; |
| 134 | for (i=0; i<(param->wep_key[wep_key_index].size); i++) { |
| 135 | param->wep_key[wep_key_index].val[i] = wep_key[i]; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | static |
| 140 | void analyze_hex_wep_key(struct ks_wlan_parameter *param, int wep_key_index, char *value) |
| 141 | { |
| 142 | unsigned char wep_end[26], i, j, key_length; |
| 143 | |
| 144 | key_length = (wep_on_off == WEP_ON_64BIT) ? 10 : 26; |
| 145 | /* 64bit key_length = 10; 128bit key_length = 26; */ |
| 146 | |
| 147 | for (i=0; i<key_length; i++) { |
| 148 | wep_end[i] = value[i]; |
| 149 | if (i%2) { |
| 150 | /* Odd */ |
| 151 | for (j=0x00; j<0x10; j++) { |
| 152 | if (j<0x0a) { |
| 153 | if (wep_end[i] == j+0x30) |
| 154 | wep_end[i] = j; |
| 155 | } else { |
| 156 | if ((wep_end[i] == j+0x37) | (wep_end[i] == j+0x57)) |
| 157 | wep_end[i] = j; |
| 158 | } |
| 159 | } |
| 160 | } else { |
| 161 | /* Even */ |
| 162 | for (j=0x00; j<0x10; j++) { |
| 163 | if (j<0x0a) { |
| 164 | if (wep_end[i] == j+0x30) { |
| 165 | wep_end[i] = j*16; |
| 166 | } |
| 167 | } else { |
| 168 | if ((wep_end[i] == j+0x37) | (wep_end[i] == j+0x57)) |
| 169 | wep_end[i] = j*16; |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | for (i=0; i<key_length/2; i++) { |
| 176 | wep_end[i] = wep_end[i*2] + wep_end[(i*2)+1]; |
| 177 | } |
| 178 | |
| 179 | if(wep_key_index < 0 || wep_key_index > 3) |
| 180 | return ; |
| 181 | |
| 182 | param->wep_key[wep_key_index].size = key_length/2; |
| 183 | for (i=0; i<(param->wep_key[wep_key_index].size); i++) { |
| 184 | param->wep_key[wep_key_index].val[i] = wep_end[i]; |
| 185 | } |
| 186 | |
| 187 | } |
| 188 | |
| 189 | static atomic_t update_phyinfo; |
| 190 | static struct timer_list update_phyinfo_timer; |
| 191 | static |
| 192 | int ks_wlan_update_phy_information(ks_wlan_private *priv) |
| 193 | { |
| 194 | struct iw_statistics *wstats = &priv->wstats; |
| 195 | |
| 196 | DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); |
| 197 | |
| 198 | if (priv->dev_state < DEVICE_STATE_READY) { |
| 199 | return -1; /* not finished initialize */ |
| 200 | } |
| 201 | if(atomic_read(&update_phyinfo)) |
| 202 | return 1; |
| 203 | |
| 204 | /* The status */ |
| 205 | wstats->status = priv->reg.operation_mode; /* Operation mode */ |
| 206 | |
| 207 | /* Signal quality and co. But where is the noise level ??? */ |
| 208 | hostif_sme_enqueue(priv, SME_PHY_INFO_REQUEST); |
| 209 | |
| 210 | /* interruptible_sleep_on_timeout(&priv->confirm_wait, HZ/2); */ |
| 211 | if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,HZ/2)){ |
| 212 | DPRINTK(1,"wait time out!!\n"); |
| 213 | } |
| 214 | |
| 215 | atomic_inc(&update_phyinfo); |
| 216 | update_phyinfo_timer.expires = jiffies + HZ; /* 1sec */ |
| 217 | add_timer(&update_phyinfo_timer); |
| 218 | |
| 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | static |
| 223 | void ks_wlan_update_phyinfo_timeout(unsigned long ptr) |
| 224 | { |
| 225 | DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); |
| 226 | atomic_set(&update_phyinfo,0); |
| 227 | } |
| 228 | |
| 229 | |
| 230 | static |
| 231 | int rate_set_configuration(ks_wlan_private *priv, char *value) |
| 232 | { |
| 233 | int rc=0; |
| 234 | |
| 235 | priv->reg.tx_rate = TX_RATE_FIXED; |
| 236 | priv->reg.rate_set.size = 1; |
| 237 | |
| 238 | switch(*value){ |
| 239 | case '1': /* 1M 11M 12M 18M */ |
| 240 | if(*(value+1) == '8'){ |
| 241 | priv->reg.rate_set.body[0] = TX_RATE_18M; |
| 242 | } |
| 243 | else if(*(value+1) == '2'){ |
| 244 | priv->reg.rate_set.body[0] = TX_RATE_12M|BASIC_RATE; |
| 245 | } |
| 246 | else if(*(value+1) == '1'){ |
| 247 | priv->reg.rate_set.body[0] = TX_RATE_11M|BASIC_RATE; |
| 248 | } |
| 249 | else{ |
| 250 | priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; |
| 251 | } |
| 252 | break; |
| 253 | case '2': /* 2M 24M */ |
| 254 | if(*(value+1) == '4'){ |
| 255 | priv->reg.rate_set.body[0] = TX_RATE_24M|BASIC_RATE; |
| 256 | } |
| 257 | else{ |
| 258 | priv->reg.rate_set.body[0] = TX_RATE_2M|BASIC_RATE; |
| 259 | } |
| 260 | break; |
| 261 | case '3': /* 36M */ |
| 262 | priv->reg.rate_set.body[0] = TX_RATE_36M; |
| 263 | break; |
| 264 | case '4': /* 48M */ |
| 265 | priv->reg.rate_set.body[0] = TX_RATE_48M; |
| 266 | break; |
| 267 | case '5': /* 5.5M 54M */ |
| 268 | if(*(value+1) == '4'){ |
| 269 | priv->reg.rate_set.body[0] = TX_RATE_54M; |
| 270 | } |
| 271 | else{ |
| 272 | priv->reg.rate_set.body[0] = TX_RATE_5M|BASIC_RATE; |
| 273 | } |
| 274 | break; |
| 275 | case '6': /* 6M */ |
| 276 | priv->reg.rate_set.body[0] = TX_RATE_6M|BASIC_RATE; |
| 277 | break; |
| 278 | case '9': /* 9M */ |
| 279 | priv->reg.rate_set.body[0] = TX_RATE_9M; |
| 280 | break; |
| 281 | case 'K': |
| 282 | priv->reg.rate_set.body[6] = TX_RATE_36M; |
| 283 | priv->reg.rate_set.body[5] = TX_RATE_18M; |
| 284 | priv->reg.rate_set.body[4] = TX_RATE_24M|BASIC_RATE; |
| 285 | priv->reg.rate_set.body[3] = TX_RATE_12M|BASIC_RATE; |
| 286 | priv->reg.rate_set.body[2] = TX_RATE_6M|BASIC_RATE; |
| 287 | priv->reg.rate_set.body[1] = TX_RATE_11M|BASIC_RATE; |
| 288 | priv->reg.rate_set.body[0] = TX_RATE_2M|BASIC_RATE; |
| 289 | priv->reg.tx_rate = TX_RATE_FULL_AUTO; |
| 290 | priv->reg.rate_set.size = 7; |
| 291 | break; |
| 292 | default: |
| 293 | priv->reg.rate_set.body[11] = TX_RATE_54M; |
| 294 | priv->reg.rate_set.body[10] = TX_RATE_48M; |
| 295 | priv->reg.rate_set.body[9] = TX_RATE_36M; |
| 296 | priv->reg.rate_set.body[8] = TX_RATE_18M; |
| 297 | priv->reg.rate_set.body[7] = TX_RATE_9M; |
| 298 | priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; |
| 299 | priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; |
| 300 | priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; |
| 301 | priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; |
| 302 | priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; |
| 303 | priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; |
| 304 | priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; |
| 305 | priv->reg.tx_rate = TX_RATE_FULL_AUTO; |
| 306 | priv->reg.rate_set.size = 12; |
| 307 | break; |
| 308 | } |
| 309 | return rc; |
| 310 | } |
| 311 | |
| 312 | #ifndef NO_FIRMWARE_CLASS |
| 313 | #include <linux/firmware.h> |
| 314 | #else |
| 315 | #define MAX_CONFIG_FILE_SIZE (1024*10) |
| 316 | #endif |
| 317 | int ks_wlan_read_config_file(ks_wlan_private *priv) |
| 318 | { |
| 319 | struct { |
| 320 | const int key_len; |
| 321 | const char *key; |
| 322 | const char *val; |
| 323 | } cfg_tbl[] = { |
| 324 | {15,"BeaconLostCount", "20"}, /* 0 */ |
| 325 | {7,"Channel", "1"}, /* 1 */ |
| 326 | {17,"FragmentThreshold","2346"}, /* 2 */ |
| 327 | {13,"OperationMode","Infrastructure"}, /* 3 */ |
| 328 | {19,"PowerManagementMode","ACTIVE"}, /* 4 */ |
| 329 | {12,"RTSThreshold","2347"}, /* 5 */ |
| 330 | {4,"SSID","default"}, /* 6 */ |
| 331 | {6,"TxRate","Auto"}, /* 7 */ |
| 332 | {23,"AuthenticationAlgorithm",""}, /* 8 */ |
| 333 | {12,"WepKeyValue1",""}, /* 9 */ |
| 334 | {12,"WepKeyValue2",""}, /* 10 */ |
| 335 | {12,"WepKeyValue3",""}, /* 11 */ |
| 336 | {12,"WepKeyValue4",""}, /* 12 */ |
| 337 | {8,"WepIndex","1"}, /* 13 */ |
| 338 | {7,"WepType","STRING"}, /* 14 */ |
| 339 | {3,"Wep","OFF"}, /* 15 */ |
| 340 | {13,"PREAMBLE_TYPE","SHORT"}, /* 16 */ |
| 341 | {8,"ScanType","ACTIVE_SCAN"}, /* 17 */ |
| 342 | {8,"ROM_FILE", ROM_FILE}, /* 18 */ |
| 343 | {7,"PhyType", "BG_MODE"}, /* 19 */ |
| 344 | {7,"CtsMode", "FALSE"}, /* 20 */ |
| 345 | {19,"PhyInformationTimer", "0"}, /* 21 */ |
| 346 | {0,"",""}, |
| 347 | }; |
| 348 | |
| 349 | #ifndef NO_FIRMWARE_CLASS |
| 350 | const struct firmware *fw_entry; |
| 351 | struct device *dev = NULL; |
| 352 | int retval; |
| 353 | #else |
| 354 | struct file *srcf; |
| 355 | int nr_read ; |
| 356 | int retval; |
| 357 | char *cfg_buf=NULL; |
| 358 | int orgfsuid, orgfsgid; |
| 359 | mm_segment_t orgfs; |
| 360 | #endif |
| 361 | char cfg_file[]=CFG_FILE; |
| 362 | char *cur_p, *end_p; |
| 363 | char wk_buff[256], *wk_p; |
| 364 | |
| 365 | /* Initialize Variable */ |
| 366 | priv->reg.operation_mode = MODE_INFRASTRUCTURE; /* Infrastructure */ |
| 367 | priv->reg.channel = 10; /* 10 */ |
| 368 | memset(priv->reg.bssid, 0x0, ETH_ALEN); /* BSSID */ |
| 369 | priv->reg.ssid.body[0] = '\0'; /* SSID */ |
| 370 | priv->reg.ssid.size = 0; /* SSID size */ |
| 371 | priv->reg.tx_rate = TX_RATE_AUTO; /* TxRate Fully Auto */ |
| 372 | priv->reg.preamble = SHORT_PREAMBLE; /* Preamble = SHORT */ |
| 373 | priv->reg.powermgt = POWMGT_ACTIVE_MODE; /* POWMGT_ACTIVE_MODE */ |
| 374 | priv->reg.scan_type = ACTIVE_SCAN; /* Active */ |
| 375 | priv->reg.beacon_lost_count = 20; /* Beacon Lost Count */ |
| 376 | priv->reg.rts = 2347UL; /* RTS Threashold */ |
| 377 | priv->reg.fragment = 2346UL; /* Fragmentation Threashold */ |
| 378 | |
| 379 | strcpy(&priv->reg.rom_file[0], ROM_FILE); |
| 380 | |
| 381 | priv->skb = NULL; |
| 382 | |
| 383 | priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; /* AuthenticationAlgorithm */ |
| 384 | |
| 385 | priv->reg.privacy_invoked = 0x00; /* WEP */ |
| 386 | priv->reg.wep_index=0; |
| 387 | memset(&priv->reg.wep_key[0],0,sizeof(priv->reg.wep_key[0])); |
| 388 | memset(&priv->reg.wep_key[1],0,sizeof(priv->reg.wep_key[0])); |
| 389 | memset(&priv->reg.wep_key[2],0,sizeof(priv->reg.wep_key[0])); |
| 390 | memset(&priv->reg.wep_key[3],0,sizeof(priv->reg.wep_key[0])); |
| 391 | |
| 392 | priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; |
| 393 | priv->reg.cts_mode = CTS_MODE_FALSE; |
| 394 | priv->reg.phy_info_timer = 0; |
| 395 | priv->reg.rate_set.body[11] = TX_RATE_54M; |
| 396 | priv->reg.rate_set.body[10] = TX_RATE_48M; |
| 397 | priv->reg.rate_set.body[9] = TX_RATE_36M; |
| 398 | priv->reg.rate_set.body[8] = TX_RATE_18M; |
| 399 | priv->reg.rate_set.body[7] = TX_RATE_9M; |
| 400 | priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; |
| 401 | priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; |
| 402 | priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; |
| 403 | priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; |
| 404 | priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; |
| 405 | priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; |
| 406 | priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; |
| 407 | priv->reg.tx_rate = TX_RATE_FULL_AUTO; |
| 408 | priv->reg.rate_set.size = 12; |
| 409 | |
| 410 | #ifndef NO_FIRMWARE_CLASS |
| 411 | #if (defined _PCMCIA_) |
| 412 | dev = &priv->ks_wlan_hw.pcmcia_dev->dev; |
| 413 | #elif (defined _PCI_) |
| 414 | dev = &priv->ks_wlan_hw.pci_dev->dev; |
| 415 | #elif (defined _SDIO_) |
| 416 | dev = &priv->ks_wlan_hw.sdio_card->func->dev; |
| 417 | #endif |
| 418 | if((retval = request_firmware(&fw_entry, cfg_file, dev)) !=0 ){ |
| 419 | DPRINTK(1, "error request_firmware() file=%s ret=%d\n", cfg_file, retval); |
| 420 | return 1; |
| 421 | } |
| 422 | |
| 423 | DPRINTK(4, "success request_firmware() file=%s size=%d\n", cfg_file, fw_entry->size); |
| 424 | cur_p = fw_entry->data; |
| 425 | end_p = cur_p + fw_entry->size; |
| 426 | #else |
| 427 | orgfsuid=current->fsuid; |
| 428 | orgfsgid=current->fsgid; |
| 429 | orgfs=get_fs(); |
| 430 | set_fs(KERNEL_DS); |
| 431 | |
| 432 | srcf = filp_open(cfg_file, O_RDONLY, 0); |
| 433 | if (IS_ERR(srcf)) { |
| 434 | printk(KERN_ERR "error %ld opening %s\n", -PTR_ERR(srcf),cfg_file); |
| 435 | goto no_config_file; |
| 436 | } |
| 437 | |
| 438 | if (!(srcf->f_op && srcf->f_op->read)) { |
| 439 | printk(KERN_ERR "%s does not have a read method\n", cfg_file); |
| 440 | goto no_config_file; |
| 441 | } |
| 442 | |
| 443 | cfg_buf = (char *)kzalloc(MAX_CONFIG_FILE_SIZE, GFP_ATOMIC); |
| 444 | if (!cfg_buf) { |
| 445 | printk(KERN_ERR "%s does not read : out of memory \n", cfg_file); |
| 446 | goto no_config_file; |
| 447 | } |
| 448 | |
| 449 | nr_read = srcf->f_op->read(srcf, (unsigned char *)cfg_buf, MAX_CONFIG_FILE_SIZE, &srcf->f_pos); |
| 450 | |
| 451 | DPRINTK(1, "read retval=%d file=%s\n", nr_read, priv->reg.cfg_file); |
| 452 | retval=filp_close(srcf ,NULL); |
| 453 | if (retval) |
| 454 | DPRINTK(1, "error %d closing %s\n", -retval,priv->reg.cfg_file); |
| 455 | |
| 456 | if (nr_read < 1) { |
| 457 | printk(KERN_ERR "%s does not read : file is empty num=%d\n", cfg_file, nr_read); |
| 458 | goto no_config_file; |
| 459 | }else if(nr_read > MAX_CONFIG_FILE_SIZE){ |
| 460 | printk(KERN_ERR "%s does not read : file is too big \n", cfg_file); |
| 461 | goto no_config_file; |
| 462 | } |
| 463 | cur_p = cfg_buf; |
| 464 | end_p = cur_p + nr_read; |
| 465 | #endif |
| 466 | *end_p = '\0'; |
| 467 | |
| 468 | while (cur_p < end_p) { |
| 469 | int i, j, len; |
| 470 | |
| 471 | len = end_p - cur_p; |
| 472 | for (i=0; cfg_tbl[i].key_len != 0; i++) { |
| 473 | if (*cur_p == '#') { |
| 474 | break; |
| 475 | } |
| 476 | if (len < cfg_tbl[i].key_len) { |
| 477 | continue; |
| 478 | } |
| 479 | if (!strncmp(cfg_tbl[i].key, cur_p, cfg_tbl[i].key_len)) { |
| 480 | break; |
| 481 | } |
| 482 | } |
| 483 | if ((*cur_p == '#') || (cfg_tbl[i].key_len == 0)) { |
| 484 | while (*cur_p != '\n') { |
| 485 | if (cur_p >= end_p) { |
| 486 | break; |
| 487 | } |
| 488 | cur_p++; |
| 489 | } |
| 490 | cur_p++; |
| 491 | } else { |
| 492 | cur_p += cfg_tbl[i].key_len; |
| 493 | if (*cur_p != '=') { |
| 494 | while (*cur_p != '\n') { |
| 495 | if (cur_p >= end_p) { |
| 496 | break; |
| 497 | } |
| 498 | cur_p++; |
| 499 | } |
| 500 | continue; |
| 501 | } |
| 502 | cur_p++; |
| 503 | |
| 504 | for (j=0,wk_p=cur_p; *wk_p != '\n' && wk_p < end_p; j++,wk_p++) { |
| 505 | wk_buff[j] = *wk_p; |
| 506 | } |
| 507 | wk_buff[j] = '\0'; |
| 508 | cur_p = wk_p; |
| 509 | DPRINTK(4,"%s=%s\n",cfg_tbl[i].key, wk_buff); |
| 510 | wk_p = wk_buff; |
| 511 | |
| 512 | switch (i) { |
| 513 | case 0: /* "BeaconLostCount", "10" */ |
| 514 | priv->reg.beacon_lost_count = atoi(wk_buff); |
| 515 | break; |
| 516 | case 1: /* "Channel", "1" */ |
| 517 | priv->reg.channel = atoi(wk_buff); |
| 518 | break; |
| 519 | case 2: /* "FragmentThreshold","2346" */ |
| 520 | j = atoi(wk_buff); |
| 521 | priv->reg.fragment = (unsigned long)j; |
| 522 | break; |
| 523 | case 3: /* "OperationMode","Infrastructure" */ |
| 524 | switch (*wk_buff) { |
| 525 | case 'P': |
| 526 | priv->reg.operation_mode = MODE_PSEUDO_ADHOC; |
| 527 | break; |
| 528 | case 'I': |
| 529 | priv->reg.operation_mode = MODE_INFRASTRUCTURE; |
| 530 | break; |
| 531 | case '8': |
| 532 | priv->reg.operation_mode = MODE_ADHOC; |
| 533 | break; |
| 534 | default: |
| 535 | priv->reg.operation_mode = MODE_INFRASTRUCTURE; |
| 536 | } |
| 537 | break; |
| 538 | case 4: /* "PowerManagementMode","POWER_ACTIVE" */ |
| 539 | if (!strncmp(wk_buff, "SAVE1", 5)) { |
| 540 | priv->reg.powermgt = POWMGT_SAVE1_MODE; |
| 541 | } else if (!strncmp(wk_buff, "SAVE2", 5)){ |
| 542 | priv->reg.powermgt = POWMGT_SAVE2_MODE; |
| 543 | } else { |
| 544 | priv->reg.powermgt = POWMGT_ACTIVE_MODE; |
| 545 | } |
| 546 | break; |
| 547 | case 5: /* "RTSThreshold","2347" */ |
| 548 | j = atoi(wk_buff); |
| 549 | priv->reg.rts = (unsigned long)j; |
| 550 | break; |
| 551 | case 6: /* "SSID","" */ |
| 552 | if (*wk_p != '"') |
| 553 | break; |
| 554 | wk_p++; |
| 555 | for (j=0; *wk_p != '"'; j++) { |
| 556 | if (wk_p == '\0') { |
| 557 | break; |
| 558 | } |
| 559 | priv->reg.ssid.body[j] = *wk_p++; |
| 560 | } |
| 561 | priv->reg.ssid.body[j] = '\0'; |
| 562 | priv->reg.ssid.size = j; |
| 563 | wk_p++; |
| 564 | break; |
| 565 | case 7: /* "TxRate","Auto" */ |
| 566 | rate_set_configuration(priv, wk_p); |
| 567 | break; |
| 568 | case 8: /* "AuthenticationAlgorithm","OPEN_SYSTEM" */ |
| 569 | switch (*wk_p) { |
| 570 | case 'O': /* Authenticate System : Open System */ |
| 571 | priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; |
| 572 | break; |
| 573 | case 'S': /* Authenticate System : Shared Key */ |
| 574 | priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; |
| 575 | break; |
| 576 | } |
| 577 | break; |
| 578 | case 9: /* "WepKeyValue1","" */ |
| 579 | case 10: /* "WepKeyValue2","" */ |
| 580 | case 11: /* "WepKeyValue3","" */ |
| 581 | case 12: /* "WepKeyValue4","" */ |
| 582 | if (wep_on_off != WEP_OFF) { |
| 583 | switch (wep_type) { |
| 584 | case WEP_KEY_CHARACTER: |
| 585 | analyze_character_wep_key(&priv->reg, (i-9), wk_p); |
| 586 | break; |
| 587 | case WEP_KEY_HEX: |
| 588 | analyze_hex_wep_key(&priv->reg, (i-9), wk_p); |
| 589 | break; |
| 590 | } |
| 591 | } |
| 592 | break; |
| 593 | case 13: /* "WepIndex","1"->0 (So, Zero Origin) */ |
| 594 | priv->reg.wep_index = atoi(wk_buff) - 1; |
| 595 | break; |
| 596 | case 14: /* "WepType","STRING" */ |
| 597 | if (!strncmp(wk_buff, "STRING", 6)) { |
| 598 | wep_type = WEP_KEY_CHARACTER; |
| 599 | } else { |
| 600 | wep_type = WEP_KEY_HEX; |
| 601 | } |
| 602 | break; |
| 603 | case 15: /* "Wep","OFF" */ |
| 604 | if (!strncmp(wk_buff, "OFF", 3)) { |
| 605 | priv->reg.privacy_invoked = 0x00; |
| 606 | wep_on_off = WEP_OFF; |
| 607 | } else { /* 64bit or 128bit */ |
| 608 | priv->reg.privacy_invoked = 0x01; |
| 609 | if (*wk_buff == '6') { /* 64bit */ |
| 610 | wep_on_off = WEP_ON_64BIT; |
| 611 | } else { /* 128bit */ |
| 612 | wep_on_off = WEP_ON_128BIT; |
| 613 | } |
| 614 | } |
| 615 | break; |
| 616 | case 16: /* "PREAMBLE_TYPE","LONG" */ |
| 617 | if (!strncmp(wk_buff, "SHORT", 5)) { |
| 618 | priv->reg.preamble = SHORT_PREAMBLE; |
| 619 | } else { /* "LONG" */ |
| 620 | priv->reg.preamble = LONG_PREAMBLE; |
| 621 | } |
| 622 | break; |
| 623 | case 17: /* "ScanType","ACTIVE_SCAN" */ |
| 624 | if (!strncmp(wk_buff, "PASSIVE_SCAN", 12)) { |
| 625 | priv->reg.scan_type = PASSIVE_SCAN; |
| 626 | } else { /* "ACTIVE_SCAN" */ |
| 627 | priv->reg.scan_type = ACTIVE_SCAN; |
| 628 | } |
| 629 | break; |
| 630 | case 18: // "ROM_FILE",ROMFILE |
| 631 | if (*wk_p != '"') |
| 632 | break; |
| 633 | wk_p++; |
| 634 | for (j=0; *wk_p != '"'; j++) { |
| 635 | if (wk_p == '\0') { |
| 636 | break; |
| 637 | } |
| 638 | priv->reg.rom_file[j] = *wk_p++; |
| 639 | } |
| 640 | priv->reg.rom_file[j] = '\0'; |
| 641 | wk_p++; |
| 642 | break; |
| 643 | case 19: /*"PhyType", "BG_MODE" */ |
| 644 | if (!strncmp(wk_buff, "B_MODE", 6)) { |
| 645 | priv->reg.phy_type = D_11B_ONLY_MODE; |
| 646 | } else if (!strncmp(wk_buff, "G_MODE", 6)) { |
| 647 | priv->reg.phy_type = D_11G_ONLY_MODE; |
| 648 | } else { |
| 649 | priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; |
| 650 | } |
| 651 | break; |
| 652 | case 20: /* "CtsMode", "FALSE" */ |
| 653 | if (!strncmp(wk_buff, "TRUE", 4)) { |
| 654 | priv->reg.cts_mode = CTS_MODE_TRUE; |
| 655 | } else { |
| 656 | priv->reg.cts_mode = CTS_MODE_FALSE; |
| 657 | } |
| 658 | break; |
| 659 | case 21: /* "PhyInformationTimer", "0" */ |
| 660 | j = atoi(wk_buff); |
| 661 | priv->reg.phy_info_timer = (uint16_t)j; |
| 662 | break; |
| 663 | default: |
| 664 | break; |
| 665 | } |
| 666 | if (cur_p >= end_p) { |
| 667 | break; |
| 668 | } |
| 669 | cur_p++; |
| 670 | } |
| 671 | |
| 672 | } |
| 673 | #ifndef NO_FIRMWARE_CLASS |
| 674 | release_firmware(fw_entry); |
| 675 | #else |
| 676 | no_config_file: |
| 677 | kfree(cfg_buf); |
| 678 | set_fs(orgfs); |
| 679 | current->fsuid=orgfsuid; |
| 680 | current->fsgid=orgfsgid; |
| 681 | #endif |
| 682 | |
| 683 | DPRINTK(3,"\n operation_mode = %d\n channel = %d\n ssid = %s\n tx_rate = %d\n \ |
| 684 | preamble = %d\n powermgt = %d\n scan_type = %d\n beacon_lost_count = %d\n rts = %d\n \ |
| 685 | fragment = %d\n privacy_invoked = %d\n wep_type = %d\n wep_on_off = %d\n wep_index = %d\n romfile = %s\n", |
| 686 | priv->reg.operation_mode,priv->reg.channel,&priv->reg.ssid.body[0],priv->reg.tx_rate, |
| 687 | priv->reg.preamble,priv->reg.powermgt,priv->reg.scan_type,priv->reg.beacon_lost_count, |
| 688 | priv->reg.rts,priv->reg.fragment,priv->reg.privacy_invoked,wep_type,wep_on_off,priv->reg.wep_index, |
| 689 | &priv->reg.rom_file[0] |
| 690 | ); |
| 691 | DPRINTK(3,"\n phy_type = %d\n cts_mode = %d\n tx_rate = %d\n phy_info_timer = %d\n", |
| 692 | priv->reg.phy_type,priv->reg.cts_mode,priv->reg.tx_rate,priv->reg.phy_info_timer ); |
| 693 | |
| 694 | return(0); |
| 695 | } |
| 696 | |
| 697 | int ks_wlan_setup_parameter(ks_wlan_private *priv, unsigned int commit_flag) |
| 698 | { |
| 699 | DPRINTK(2,"\n"); |
| 700 | |
| 701 | hostif_sme_enqueue(priv, SME_STOP_REQUEST); |
| 702 | |
| 703 | if(commit_flag & SME_RTS) |
| 704 | hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST); |
| 705 | if(commit_flag & SME_FRAG) |
| 706 | hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST); |
| 707 | |
| 708 | if(commit_flag & SME_WEP_INDEX) |
| 709 | hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST); |
| 710 | if(commit_flag & SME_WEP_VAL1) |
| 711 | hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST); |
| 712 | if(commit_flag & SME_WEP_VAL2) |
| 713 | hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST); |
| 714 | if(commit_flag & SME_WEP_VAL3) |
| 715 | hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST); |
| 716 | if(commit_flag & SME_WEP_VAL4) |
| 717 | hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST); |
| 718 | if(commit_flag & SME_WEP_FLAG) |
| 719 | hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); |
| 720 | |
| 721 | if(commit_flag & SME_RSN){ |
| 722 | hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST); |
| 723 | hostif_sme_enqueue(priv, SME_RSN_MODE_REQUEST); |
| 724 | } |
| 725 | if(commit_flag & SME_RSN_MULTICAST) |
| 726 | hostif_sme_enqueue(priv, SME_RSN_MCAST_REQUEST); |
| 727 | if(commit_flag & SME_RSN_UNICAST) |
| 728 | hostif_sme_enqueue(priv, SME_RSN_UCAST_REQUEST); |
| 729 | if(commit_flag & SME_RSN_AUTH) |
| 730 | hostif_sme_enqueue(priv, SME_RSN_AUTH_REQUEST); |
| 731 | |
| 732 | hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST); |
| 733 | |
| 734 | hostif_sme_enqueue(priv, SME_START_REQUEST); |
| 735 | |
| 736 | return 0; |
| 737 | } |
| 738 | |
| 739 | |
| 740 | |
| 741 | #ifdef WIRELESS_EXT |
| 742 | /* |
| 743 | * Initial Wireless Extension code for Ks_Wlannet driver by : |
| 744 | * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 17 November 00 |
| 745 | * Conversion to new driver API by : |
| 746 | * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 26 March 02 |
| 747 | * Javier also did a good amount of work here, adding some new extensions |
| 748 | * and fixing my code. Let's just say that without him this code just |
| 749 | * would not work at all... - Jean II |
| 750 | */ |
| 751 | |
| 752 | /*------------------------------------------------------------------*/ |
| 753 | /* Wireless Handler : get protocol name */ |
| 754 | static int ks_wlan_get_name(struct net_device *dev, struct iw_request_info *info, |
| 755 | char *cwrq, char *extra) |
| 756 | { |
| 757 | ks_wlan_private *priv = (ks_wlan_private *) netdev_priv(dev); |
| 758 | |
| 759 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 760 | |
| 761 | if (priv->dev_state < DEVICE_STATE_READY) { |
| 762 | strcpy(cwrq, "NOT READY!"); |
| 763 | } |
| 764 | else if(priv->reg.phy_type == D_11B_ONLY_MODE){ |
| 765 | strcpy(cwrq, "IEEE 802.11b"); |
| 766 | } |
| 767 | else if(priv->reg.phy_type == D_11G_ONLY_MODE){ |
| 768 | strcpy(cwrq, "IEEE 802.11g"); |
| 769 | } |
| 770 | else { |
| 771 | strcpy(cwrq, "IEEE 802.11b/g"); |
| 772 | } |
| 773 | |
| 774 | return 0; |
| 775 | } |
| 776 | |
| 777 | /*------------------------------------------------------------------*/ |
| 778 | /* Wireless Handler : set frequency */ |
| 779 | static int ks_wlan_set_freq(struct net_device *dev, struct iw_request_info *info, |
| 780 | struct iw_freq *fwrq, char *extra) |
| 781 | { |
| 782 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 783 | int rc = -EINPROGRESS; /* Call commit handler */ |
| 784 | |
| 785 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 786 | |
| 787 | /* If setting by frequency, convert to a channel */ |
| 788 | if((fwrq->e == 1) && |
| 789 | (fwrq->m >= (int) 2.412e8) && |
| 790 | (fwrq->m <= (int) 2.487e8)) { |
| 791 | int f = fwrq->m / 100000; |
| 792 | int c = 0; |
| 793 | while((c < 14) && (f != frequency_list[c])) |
| 794 | c++; |
| 795 | /* Hack to fall through... */ |
| 796 | fwrq->e = 0; |
| 797 | fwrq->m = c + 1; |
| 798 | } |
| 799 | /* Setting by channel number */ |
| 800 | if((fwrq->m > 1000) || (fwrq->e > 0)) |
| 801 | rc = -EOPNOTSUPP; |
| 802 | else { |
| 803 | int channel = fwrq->m; |
| 804 | /* We should do a better check than that, |
| 805 | * based on the card capability !!! */ |
| 806 | if((channel < 1) || (channel > 14)) { |
| 807 | printk(KERN_DEBUG "%s: New channel value of %d is invalid!\n", dev->name, fwrq->m); |
| 808 | rc = -EINVAL; |
| 809 | } else { |
| 810 | /* Yes ! We can set it !!! */ |
| 811 | priv->reg.channel = (u8)(channel); |
| 812 | priv->need_commit |= SME_MODE_SET; |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | return rc; |
| 817 | } |
| 818 | |
| 819 | /*------------------------------------------------------------------*/ |
| 820 | /* Wireless Handler : get frequency */ |
| 821 | static int ks_wlan_get_freq(struct net_device *dev, struct iw_request_info *info, |
| 822 | struct iw_freq *fwrq, char *extra) |
| 823 | { |
| 824 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 825 | int f; |
| 826 | |
| 827 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 828 | |
| 829 | if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ |
| 830 | f = (int)priv->current_ap.channel; |
| 831 | } |
| 832 | else |
| 833 | f = (int)priv->reg.channel; |
| 834 | fwrq->m = frequency_list[f-1] * 100000; |
| 835 | fwrq->e = 1; |
| 836 | |
| 837 | return 0; |
| 838 | } |
| 839 | |
| 840 | /*------------------------------------------------------------------*/ |
| 841 | /* Wireless Handler : set ESSID */ |
| 842 | static int ks_wlan_set_essid(struct net_device *dev, struct iw_request_info *info, |
| 843 | struct iw_point *dwrq, char *extra) |
| 844 | { |
| 845 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 846 | size_t len; |
| 847 | |
| 848 | DPRINTK(2," %d\n", dwrq->flags); |
| 849 | |
| 850 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 851 | |
| 852 | /* Check if we asked for `any' */ |
| 853 | if(dwrq->flags == 0) { |
| 854 | /* Just send an empty SSID list */ |
| 855 | memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); |
| 856 | priv->reg.ssid.size = 0; |
| 857 | } else { |
| 858 | #if 1 |
| 859 | len = dwrq->length; |
| 860 | /* iwconfig uses nul termination in SSID.. */ |
| 861 | if (len > 0 && extra[len - 1] == '\0') |
| 862 | len--; |
| 863 | |
| 864 | /* Check the size of the string */ |
| 865 | if(len > IW_ESSID_MAX_SIZE) { |
| 866 | return -EINVAL; |
| 867 | } |
| 868 | #else |
| 869 | /* Check the size of the string */ |
| 870 | if(dwrq->length > IW_ESSID_MAX_SIZE+1) { |
| 871 | return -E2BIG ; |
| 872 | } |
| 873 | #endif |
| 874 | |
| 875 | /* Set the SSID */ |
| 876 | memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); |
| 877 | |
| 878 | #if 1 |
| 879 | memcpy(priv->reg.ssid.body, extra, len); |
| 880 | priv->reg.ssid.size = len; |
| 881 | #else |
| 882 | memcpy(priv->reg.ssid.body, extra, dwrq->length); |
| 883 | priv->reg.ssid.size = dwrq->length; |
| 884 | #endif |
| 885 | } |
| 886 | /* Write it to the card */ |
| 887 | priv->need_commit |= SME_MODE_SET; |
| 888 | |
| 889 | // return -EINPROGRESS; /* Call commit handler */ |
| 890 | ks_wlan_setup_parameter(priv, priv->need_commit); |
| 891 | priv->need_commit=0; |
| 892 | return 0; |
| 893 | } |
| 894 | |
| 895 | /*------------------------------------------------------------------*/ |
| 896 | /* Wireless Handler : get ESSID */ |
| 897 | static int ks_wlan_get_essid(struct net_device *dev, struct iw_request_info *info, |
| 898 | struct iw_point *dwrq, char *extra) |
| 899 | { |
| 900 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 901 | |
| 902 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 903 | |
| 904 | /* Note : if dwrq->flags != 0, we should |
| 905 | * get the relevant SSID from the SSID list... */ |
| 906 | |
| 907 | if(priv->reg.ssid.size){ |
| 908 | /* Get the current SSID */ |
| 909 | memcpy(extra, priv->reg.ssid.body, priv->reg.ssid.size); |
| 910 | #if 0 |
| 911 | extra[priv->reg.ssid.size] = '\0'; |
| 912 | #endif |
| 913 | /* If none, we may want to get the one that was set */ |
| 914 | |
| 915 | /* Push it out ! */ |
| 916 | #if 1 |
| 917 | dwrq->length = priv->reg.ssid.size; |
| 918 | #else |
| 919 | dwrq->length = priv->reg.ssid.size+1; |
| 920 | #endif |
| 921 | dwrq->flags = 1; /* active */ |
| 922 | }else{ |
| 923 | #if 1 |
| 924 | dwrq->length = 0; |
| 925 | #else |
| 926 | extra[0] = '\0'; |
| 927 | dwrq->length = 1; |
| 928 | #endif |
| 929 | dwrq->flags = 0; /* ANY */ |
| 930 | } |
| 931 | |
| 932 | return 0; |
| 933 | } |
| 934 | |
| 935 | /*------------------------------------------------------------------*/ |
| 936 | /* Wireless Handler : set AP address */ |
| 937 | static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, |
| 938 | struct sockaddr *ap_addr, char *extra) |
| 939 | { |
| 940 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 941 | |
| 942 | DPRINTK(2,"\n"); |
| 943 | |
| 944 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 945 | |
| 946 | if (priv->reg.operation_mode == MODE_ADHOC || |
| 947 | priv->reg.operation_mode == MODE_INFRASTRUCTURE) { |
| 948 | memcpy(priv->reg.bssid, (u8 *)&ap_addr->sa_data, ETH_ALEN); |
| 949 | |
| 950 | if (is_valid_ether_addr((u8 *)priv->reg.bssid)) { |
| 951 | priv->need_commit |= SME_MODE_SET; |
| 952 | } |
| 953 | } |
| 954 | else { |
| 955 | memset(priv->reg.bssid, 0x0, ETH_ALEN); |
| 956 | return -EOPNOTSUPP; |
| 957 | } |
| 958 | |
| 959 | DPRINTK(2, "bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", |
| 960 | priv->reg.bssid[0],priv->reg.bssid[1],priv->reg.bssid[2], |
| 961 | priv->reg.bssid[3],priv->reg.bssid[4],priv->reg.bssid[5]); |
| 962 | |
| 963 | /* Write it to the card */ |
| 964 | if (priv->need_commit) { |
| 965 | priv->need_commit |= SME_MODE_SET; |
| 966 | return -EINPROGRESS; /* Call commit handler */ |
| 967 | } |
| 968 | return 0; |
| 969 | } |
| 970 | |
| 971 | /*------------------------------------------------------------------*/ |
| 972 | /* Wireless Handler : get AP address */ |
| 973 | static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, |
| 974 | struct sockaddr *awrq, char *extra) |
| 975 | { |
| 976 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 977 | |
| 978 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 979 | |
| 980 | if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ |
| 981 | memcpy(awrq->sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN); |
| 982 | } |
| 983 | else{ |
| 984 | memset(awrq->sa_data, 0, ETH_ALEN); |
| 985 | } |
| 986 | |
| 987 | awrq->sa_family = ARPHRD_ETHER; |
| 988 | |
| 989 | return 0; |
| 990 | } |
| 991 | |
| 992 | /*------------------------------------------------------------------*/ |
| 993 | /* Wireless Handler : set Nickname */ |
| 994 | static int ks_wlan_set_nick(struct net_device *dev, struct iw_request_info *info, |
| 995 | struct iw_point *dwrq, char *extra) |
| 996 | { |
| 997 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 998 | |
| 999 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1000 | |
| 1001 | /* Check the size of the string */ |
| 1002 | if(dwrq->length > 16 + 1) { |
| 1003 | return -E2BIG; |
| 1004 | } |
| 1005 | memset(priv->nick, 0, sizeof(priv->nick)); |
| 1006 | memcpy(priv->nick, extra, dwrq->length); |
| 1007 | |
| 1008 | return -EINPROGRESS; /* Call commit handler */ |
| 1009 | } |
| 1010 | |
| 1011 | /*------------------------------------------------------------------*/ |
| 1012 | /* Wireless Handler : get Nickname */ |
| 1013 | static int ks_wlan_get_nick(struct net_device *dev, struct iw_request_info *info, |
| 1014 | struct iw_point *dwrq, char *extra) |
| 1015 | { |
| 1016 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1017 | |
| 1018 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1019 | |
| 1020 | strncpy(extra, priv->nick, 16); |
| 1021 | extra[16] = '\0'; |
| 1022 | dwrq->length = strlen(extra) + 1; |
| 1023 | |
| 1024 | return 0; |
| 1025 | } |
| 1026 | |
| 1027 | /*------------------------------------------------------------------*/ |
| 1028 | /* Wireless Handler : set Bit-Rate */ |
| 1029 | static int ks_wlan_set_rate(struct net_device *dev, struct iw_request_info *info, |
| 1030 | struct iw_param *vwrq, char *extra) |
| 1031 | { |
| 1032 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1033 | int i = 0; |
| 1034 | |
| 1035 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1036 | |
| 1037 | if(priv->reg.phy_type == D_11B_ONLY_MODE){ |
| 1038 | if(vwrq->fixed == 1) { |
| 1039 | switch(vwrq->value){ |
| 1040 | case 11000000: |
| 1041 | case 5500000: |
| 1042 | priv->reg.rate_set.body[0] = (uint8_t)(vwrq->value/500000); |
| 1043 | break; |
| 1044 | case 2000000: |
| 1045 | case 1000000: |
| 1046 | priv->reg.rate_set.body[0] = ((uint8_t)(vwrq->value/500000))|BASIC_RATE; |
| 1047 | break; |
| 1048 | default: |
| 1049 | return -EINVAL; |
| 1050 | } |
| 1051 | priv->reg.tx_rate = TX_RATE_FIXED; |
| 1052 | priv->reg.rate_set.size = 1; |
| 1053 | }else{ /* vwrq->fixed == 0 */ |
| 1054 | if(vwrq->value > 0){ |
| 1055 | switch(vwrq->value){ |
| 1056 | case 11000000: |
| 1057 | priv->reg.rate_set.body[3] = TX_RATE_11M; i++; |
| 1058 | case 5500000: |
| 1059 | priv->reg.rate_set.body[2] = TX_RATE_5M; i++; |
| 1060 | case 2000000: |
| 1061 | priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; i++; |
| 1062 | case 1000000: |
| 1063 | priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; i++; |
| 1064 | break; |
| 1065 | default: |
| 1066 | return -EINVAL; |
| 1067 | } |
| 1068 | priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; |
| 1069 | priv->reg.rate_set.size = i; |
| 1070 | }else{ |
| 1071 | priv->reg.rate_set.body[3] = TX_RATE_11M; |
| 1072 | priv->reg.rate_set.body[2] = TX_RATE_5M; |
| 1073 | priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; |
| 1074 | priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; |
| 1075 | priv->reg.tx_rate = TX_RATE_FULL_AUTO; |
| 1076 | priv->reg.rate_set.size = 4; |
| 1077 | } |
| 1078 | } |
| 1079 | }else{ /* D_11B_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ |
| 1080 | if(vwrq->fixed == 1) { |
| 1081 | switch(vwrq->value){ |
| 1082 | case 54000000: |
| 1083 | case 48000000: |
| 1084 | case 36000000: |
| 1085 | case 18000000: |
| 1086 | case 9000000: |
| 1087 | priv->reg.rate_set.body[0] = (uint8_t)(vwrq->value/500000); |
| 1088 | break; |
| 1089 | case 24000000: |
| 1090 | case 12000000: |
| 1091 | case 11000000: |
| 1092 | case 6000000: |
| 1093 | case 5500000: |
| 1094 | case 2000000: |
| 1095 | case 1000000: |
| 1096 | priv->reg.rate_set.body[0] = ((uint8_t)(vwrq->value/500000))|BASIC_RATE; |
| 1097 | break; |
| 1098 | default: |
| 1099 | return -EINVAL; |
| 1100 | } |
| 1101 | priv->reg.tx_rate = TX_RATE_FIXED; |
| 1102 | priv->reg.rate_set.size = 1; |
| 1103 | }else{ /* vwrq->fixed == 0 */ |
| 1104 | if(vwrq->value > 0){ |
| 1105 | switch(vwrq->value){ |
| 1106 | case 54000000: |
| 1107 | priv->reg.rate_set.body[11] = TX_RATE_54M; i++; |
| 1108 | case 48000000: |
| 1109 | priv->reg.rate_set.body[10] = TX_RATE_48M; i++; |
| 1110 | case 36000000: |
| 1111 | priv->reg.rate_set.body[9] = TX_RATE_36M; i++; |
| 1112 | case 24000000: case 18000000: case 12000000: |
| 1113 | case 11000000: case 9000000: case 6000000: |
| 1114 | if(vwrq->value == 24000000){ |
| 1115 | priv->reg.rate_set.body[8] = TX_RATE_18M; i++; |
| 1116 | priv->reg.rate_set.body[7] = TX_RATE_9M; i++; |
| 1117 | priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; i++; |
| 1118 | priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; |
| 1119 | priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; |
| 1120 | priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; |
| 1121 | }else if(vwrq->value == 18000000){ |
| 1122 | priv->reg.rate_set.body[7] = TX_RATE_18M; i++; |
| 1123 | priv->reg.rate_set.body[6] = TX_RATE_9M; i++; |
| 1124 | priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; |
| 1125 | priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; |
| 1126 | priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; |
| 1127 | }else if(vwrq->value == 12000000){ |
| 1128 | priv->reg.rate_set.body[6] = TX_RATE_9M; i++; |
| 1129 | priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; |
| 1130 | priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; |
| 1131 | priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; |
| 1132 | }else if(vwrq->value == 11000000){ |
| 1133 | priv->reg.rate_set.body[5] = TX_RATE_9M; i++; |
| 1134 | priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; |
| 1135 | priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; |
| 1136 | }else if(vwrq->value == 9000000){ |
| 1137 | priv->reg.rate_set.body[4] = TX_RATE_9M; i++; |
| 1138 | priv->reg.rate_set.body[3] = TX_RATE_6M|BASIC_RATE; i++; |
| 1139 | }else{ /* vwrq->value == 6000000 */ |
| 1140 | priv->reg.rate_set.body[3] = TX_RATE_6M|BASIC_RATE; i++; |
| 1141 | } |
| 1142 | case 5500000: |
| 1143 | priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; i++; |
| 1144 | case 2000000: |
| 1145 | priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; i++; |
| 1146 | case 1000000: |
| 1147 | priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; i++; |
| 1148 | break; |
| 1149 | default: |
| 1150 | return -EINVAL; |
| 1151 | } |
| 1152 | priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; |
| 1153 | priv->reg.rate_set.size = i; |
| 1154 | }else{ |
| 1155 | priv->reg.rate_set.body[11] = TX_RATE_54M; |
| 1156 | priv->reg.rate_set.body[10] = TX_RATE_48M; |
| 1157 | priv->reg.rate_set.body[9] = TX_RATE_36M; |
| 1158 | priv->reg.rate_set.body[8] = TX_RATE_18M; |
| 1159 | priv->reg.rate_set.body[7] = TX_RATE_9M; |
| 1160 | priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; |
| 1161 | priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; |
| 1162 | priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; |
| 1163 | priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; |
| 1164 | priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; |
| 1165 | priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; |
| 1166 | priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; |
| 1167 | priv->reg.tx_rate = TX_RATE_FULL_AUTO; |
| 1168 | priv->reg.rate_set.size = 12; |
| 1169 | } |
| 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | priv->need_commit |= SME_MODE_SET; |
| 1174 | |
| 1175 | return -EINPROGRESS; /* Call commit handler */ |
| 1176 | } |
| 1177 | |
| 1178 | /*------------------------------------------------------------------*/ |
| 1179 | /* Wireless Handler : get Bit-Rate */ |
| 1180 | static int ks_wlan_get_rate(struct net_device *dev, struct iw_request_info *info, |
| 1181 | struct iw_param *vwrq, char *extra) |
| 1182 | { |
| 1183 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1184 | |
| 1185 | DPRINTK(2, "in_interrupt = %ld update_phyinfo = %d\n", |
| 1186 | in_interrupt(),atomic_read(&update_phyinfo)); |
| 1187 | |
| 1188 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1189 | |
| 1190 | if(!atomic_read(&update_phyinfo)){ |
| 1191 | ks_wlan_update_phy_information(priv); |
| 1192 | } |
| 1193 | vwrq->value = ((priv->current_rate) & RATE_MASK) * 500000; |
| 1194 | if(priv->reg.tx_rate == TX_RATE_FIXED) |
| 1195 | vwrq->fixed = 1; |
| 1196 | else |
| 1197 | vwrq->fixed = 0; |
| 1198 | |
| 1199 | return 0; |
| 1200 | } |
| 1201 | |
| 1202 | /*------------------------------------------------------------------*/ |
| 1203 | /* Wireless Handler : set RTS threshold */ |
| 1204 | static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, |
| 1205 | struct iw_param *vwrq, char *extra) |
| 1206 | { |
| 1207 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1208 | int rthr = vwrq->value; |
| 1209 | |
| 1210 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1211 | |
| 1212 | if(vwrq->disabled) |
| 1213 | rthr = 2347; |
| 1214 | if((rthr < 0) || (rthr > 2347)) { |
| 1215 | return -EINVAL; |
| 1216 | } |
| 1217 | priv->reg.rts = rthr; |
| 1218 | priv->need_commit |= SME_RTS; |
| 1219 | |
| 1220 | return -EINPROGRESS; /* Call commit handler */ |
| 1221 | } |
| 1222 | |
| 1223 | /*------------------------------------------------------------------*/ |
| 1224 | /* Wireless Handler : get RTS threshold */ |
| 1225 | static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, |
| 1226 | struct iw_param *vwrq, char *extra) |
| 1227 | { |
| 1228 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1229 | |
| 1230 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1231 | |
| 1232 | vwrq->value = priv->reg.rts; |
| 1233 | vwrq->disabled = (vwrq->value >= 2347); |
| 1234 | vwrq->fixed = 1; |
| 1235 | |
| 1236 | return 0; |
| 1237 | } |
| 1238 | |
| 1239 | /*------------------------------------------------------------------*/ |
| 1240 | /* Wireless Handler : set Fragmentation threshold */ |
| 1241 | static int ks_wlan_set_frag(struct net_device *dev, struct iw_request_info *info, |
| 1242 | struct iw_param *vwrq, char *extra) |
| 1243 | { |
| 1244 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1245 | int fthr = vwrq->value; |
| 1246 | |
| 1247 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1248 | |
| 1249 | if(vwrq->disabled) |
| 1250 | fthr = 2346; |
| 1251 | if((fthr < 256) || (fthr > 2346)) { |
| 1252 | return -EINVAL; |
| 1253 | } |
| 1254 | fthr &= ~0x1; /* Get an even value - is it really needed ??? */ |
| 1255 | priv->reg.fragment = fthr; |
| 1256 | priv->need_commit |= SME_FRAG; |
| 1257 | |
| 1258 | return -EINPROGRESS; /* Call commit handler */ |
| 1259 | } |
| 1260 | |
| 1261 | /*------------------------------------------------------------------*/ |
| 1262 | /* Wireless Handler : get Fragmentation threshold */ |
| 1263 | static int ks_wlan_get_frag(struct net_device *dev, struct iw_request_info *info, |
| 1264 | struct iw_param *vwrq, char *extra) |
| 1265 | { |
| 1266 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1267 | |
| 1268 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1269 | |
| 1270 | vwrq->value = priv->reg.fragment; |
| 1271 | vwrq->disabled = (vwrq->value >= 2346); |
| 1272 | vwrq->fixed = 1; |
| 1273 | |
| 1274 | return 0; |
| 1275 | } |
| 1276 | |
| 1277 | /*------------------------------------------------------------------*/ |
| 1278 | /* Wireless Handler : set Mode of Operation */ |
| 1279 | static int ks_wlan_set_mode(struct net_device *dev, struct iw_request_info *info, |
| 1280 | __u32 *uwrq, char *extra) |
| 1281 | { |
| 1282 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1283 | |
| 1284 | DPRINTK(2,"mode=%d\n",*uwrq); |
| 1285 | |
| 1286 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1287 | |
| 1288 | switch(*uwrq) { |
| 1289 | case IW_MODE_ADHOC: |
| 1290 | priv->reg.operation_mode = MODE_ADHOC; |
| 1291 | priv->need_commit |= SME_MODE_SET; |
| 1292 | break; |
| 1293 | case IW_MODE_INFRA: |
| 1294 | priv->reg.operation_mode = MODE_INFRASTRUCTURE; |
| 1295 | priv->need_commit |= SME_MODE_SET; |
| 1296 | break; |
| 1297 | case IW_MODE_AUTO: |
| 1298 | case IW_MODE_MASTER: |
| 1299 | case IW_MODE_REPEAT: |
| 1300 | case IW_MODE_SECOND: |
| 1301 | case IW_MODE_MONITOR: |
| 1302 | default: |
| 1303 | return -EINVAL; |
| 1304 | } |
| 1305 | |
| 1306 | return -EINPROGRESS; /* Call commit handler */ |
| 1307 | } |
| 1308 | |
| 1309 | /*------------------------------------------------------------------*/ |
| 1310 | /* Wireless Handler : get Mode of Operation */ |
| 1311 | static int ks_wlan_get_mode(struct net_device *dev, struct iw_request_info *info, |
| 1312 | __u32 *uwrq, char *extra) |
| 1313 | { |
| 1314 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1315 | |
| 1316 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1317 | |
| 1318 | /* If not managed, assume it's ad-hoc */ |
| 1319 | switch (priv->reg.operation_mode) { |
| 1320 | case MODE_INFRASTRUCTURE: |
| 1321 | *uwrq = IW_MODE_INFRA; |
| 1322 | break; |
| 1323 | case MODE_ADHOC: |
| 1324 | *uwrq = IW_MODE_ADHOC; |
| 1325 | break; |
| 1326 | default: |
| 1327 | *uwrq = IW_MODE_ADHOC; |
| 1328 | } |
| 1329 | |
| 1330 | return 0; |
| 1331 | } |
| 1332 | |
| 1333 | /*------------------------------------------------------------------*/ |
| 1334 | /* Wireless Handler : set Encryption Key */ |
| 1335 | static int ks_wlan_set_encode(struct net_device *dev, struct iw_request_info *info, |
| 1336 | struct iw_point *dwrq, char *extra) |
| 1337 | { |
| 1338 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1339 | |
| 1340 | wep_key_t key; |
| 1341 | int index = (dwrq->flags & IW_ENCODE_INDEX); |
| 1342 | int current_index = priv->reg.wep_index; |
| 1343 | int i; |
| 1344 | |
| 1345 | DPRINTK(2,"flags=%04X\n",dwrq->flags); |
| 1346 | |
| 1347 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1348 | |
| 1349 | /* index check */ |
| 1350 | if((index<0) || (index>4)) |
| 1351 | return -EINVAL; |
| 1352 | else if (index==0) |
| 1353 | index = current_index; |
| 1354 | else |
| 1355 | index--; |
| 1356 | |
| 1357 | /* Is WEP supported ? */ |
| 1358 | /* Basic checking: do we have a key to set ? */ |
| 1359 | if (dwrq->length > 0) { |
| 1360 | if (dwrq->length > MAX_KEY_SIZE) { /* Check the size of the key */ |
| 1361 | return -EINVAL; |
| 1362 | } |
| 1363 | if (dwrq->length > MIN_KEY_SIZE) { /* Set the length */ |
| 1364 | key.len = MAX_KEY_SIZE; |
| 1365 | priv->reg.privacy_invoked = 0x01; |
| 1366 | priv->need_commit |= SME_WEP_FLAG; |
| 1367 | wep_on_off = WEP_ON_128BIT; |
| 1368 | } else { |
| 1369 | if (dwrq->length > 0) { |
| 1370 | key.len = MIN_KEY_SIZE; |
| 1371 | priv->reg.privacy_invoked = 0x01; |
| 1372 | priv->need_commit |= SME_WEP_FLAG; |
| 1373 | wep_on_off = WEP_ON_64BIT; |
| 1374 | } else { /* Disable the key */ |
| 1375 | key.len = 0; |
| 1376 | } |
| 1377 | } |
| 1378 | /* Check if the key is not marked as invalid */ |
| 1379 | if(!(dwrq->flags & IW_ENCODE_NOKEY)) { |
| 1380 | /* Cleanup */ |
| 1381 | memset(key.key, 0, MAX_KEY_SIZE); |
| 1382 | /* Copy the key in the driver */ |
| 1383 | if(copy_from_user(key.key,dwrq->pointer,dwrq->length)) { |
| 1384 | key.len = 0; |
| 1385 | return -EFAULT; |
| 1386 | } |
| 1387 | /* Send the key to the card */ |
| 1388 | priv->reg.wep_key[index].size = key.len; |
| 1389 | for (i=0; i<(priv->reg.wep_key[index].size); i++) { |
| 1390 | priv->reg.wep_key[index].val[i] = key.key[i]; |
| 1391 | } |
| 1392 | priv->need_commit |= (SME_WEP_VAL1<<index); |
| 1393 | priv->reg.wep_index = index; |
| 1394 | priv->need_commit |= SME_WEP_INDEX; |
| 1395 | } |
| 1396 | } else { |
| 1397 | if(dwrq->flags & IW_ENCODE_DISABLED){ |
| 1398 | priv->reg.wep_key[0].size = 0; |
| 1399 | priv->reg.wep_key[1].size = 0; |
| 1400 | priv->reg.wep_key[2].size = 0; |
| 1401 | priv->reg.wep_key[3].size = 0; |
| 1402 | priv->reg.privacy_invoked = 0x00; |
| 1403 | if(priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY){ |
| 1404 | priv->need_commit |= SME_MODE_SET; |
| 1405 | } |
| 1406 | priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; |
| 1407 | wep_on_off = WEP_OFF; |
| 1408 | priv->need_commit |= SME_WEP_FLAG; |
| 1409 | }else{ |
| 1410 | /* Do we want to just set the transmit key index ? */ |
| 1411 | if ((index>=0) && (index<4)) { |
| 1412 | /* set_wep_key(priv, index, 0, 0, 1); xxx */ |
| 1413 | if(priv->reg.wep_key[index].size){ |
| 1414 | priv->reg.wep_index = index; |
| 1415 | priv->need_commit |= SME_WEP_INDEX; |
| 1416 | } |
| 1417 | else |
| 1418 | return -EINVAL; |
| 1419 | } |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | /* Commit the changes if needed */ |
| 1424 | if(dwrq->flags & IW_ENCODE_MODE) |
| 1425 | priv->need_commit |= SME_WEP_FLAG; |
| 1426 | |
| 1427 | if(dwrq->flags & IW_ENCODE_OPEN) { |
| 1428 | if(priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY){ |
| 1429 | priv->need_commit |= SME_MODE_SET; |
| 1430 | } |
| 1431 | priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; |
| 1432 | } else if(dwrq->flags & IW_ENCODE_RESTRICTED) { |
| 1433 | if(priv->reg.authenticate_type == AUTH_TYPE_OPEN_SYSTEM){ |
| 1434 | priv->need_commit |= SME_MODE_SET; |
| 1435 | } |
| 1436 | priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; |
| 1437 | } |
| 1438 | |
| 1439 | // return -EINPROGRESS; /* Call commit handler */ |
| 1440 | if(priv->need_commit){ |
| 1441 | ks_wlan_setup_parameter(priv, priv->need_commit); |
| 1442 | priv->need_commit=0; |
| 1443 | } |
| 1444 | return 0; |
| 1445 | } |
| 1446 | |
| 1447 | /*------------------------------------------------------------------*/ |
| 1448 | /* Wireless Handler : get Encryption Key */ |
| 1449 | static int ks_wlan_get_encode(struct net_device *dev, struct iw_request_info *info, |
| 1450 | struct iw_point *dwrq, char *extra) |
| 1451 | { |
| 1452 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1453 | char zeros[16]; |
| 1454 | int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; |
| 1455 | |
| 1456 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1457 | |
| 1458 | dwrq->flags = IW_ENCODE_DISABLED; |
| 1459 | |
| 1460 | /* Check encryption mode */ |
| 1461 | switch(priv->reg.authenticate_type) { |
| 1462 | case AUTH_TYPE_OPEN_SYSTEM: |
| 1463 | dwrq->flags = IW_ENCODE_OPEN; |
| 1464 | break; |
| 1465 | case AUTH_TYPE_SHARED_KEY: |
| 1466 | dwrq->flags = IW_ENCODE_RESTRICTED; |
| 1467 | break; |
| 1468 | } |
| 1469 | |
| 1470 | memset(zeros,0, sizeof(zeros)); |
| 1471 | |
| 1472 | /* Which key do we want ? -1 -> tx index */ |
| 1473 | if((index < 0) || (index >= 4)) |
| 1474 | index = priv->reg.wep_index; |
| 1475 | if (priv->reg.privacy_invoked){ |
| 1476 | dwrq->flags &= ~IW_ENCODE_DISABLED; |
| 1477 | /* dwrq->flags |= IW_ENCODE_NOKEY; */ |
| 1478 | } |
| 1479 | dwrq->flags |= index + 1; |
| 1480 | DPRINTK(2,"encoding flag = 0x%04X\n",dwrq->flags); |
| 1481 | /* Copy the key to the user buffer */ |
| 1482 | if((index >= 0) && (index < 4)) |
| 1483 | dwrq->length = priv->reg.wep_key[index].size; |
| 1484 | if (dwrq->length > 16) { |
| 1485 | dwrq->length=0; |
| 1486 | } |
| 1487 | #if 1 /* IW_ENCODE_NOKEY; */ |
| 1488 | if (dwrq->length) { |
| 1489 | if((index >= 0) && (index < 4)) |
| 1490 | memcpy(extra,priv->reg.wep_key[index].val,dwrq->length); |
| 1491 | } else |
| 1492 | memcpy(extra,zeros,dwrq->length); |
| 1493 | #endif |
| 1494 | return 0; |
| 1495 | } |
| 1496 | |
| 1497 | #ifndef KSC_OPNOTSUPP |
| 1498 | /*------------------------------------------------------------------*/ |
| 1499 | /* Wireless Handler : set Tx-Power */ |
| 1500 | static int ks_wlan_set_txpow(struct net_device *dev, struct iw_request_info *info, |
| 1501 | struct iw_param *vwrq, char *extra) |
| 1502 | { |
| 1503 | return -EOPNOTSUPP; /* Not Support */ |
| 1504 | } |
| 1505 | |
| 1506 | /*------------------------------------------------------------------*/ |
| 1507 | /* Wireless Handler : get Tx-Power */ |
| 1508 | static int ks_wlan_get_txpow(struct net_device *dev, struct iw_request_info *info, |
| 1509 | struct iw_param *vwrq, char *extra) |
| 1510 | { |
| 1511 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1512 | |
| 1513 | /* Not Support */ |
| 1514 | vwrq->value = 0; |
| 1515 | vwrq->disabled = (vwrq->value == 0); |
| 1516 | vwrq->fixed = 1; |
| 1517 | return 0; |
| 1518 | } |
| 1519 | |
| 1520 | /*------------------------------------------------------------------*/ |
| 1521 | /* Wireless Handler : set Retry limits */ |
| 1522 | static int ks_wlan_set_retry(struct net_device *dev, struct iw_request_info *info, |
| 1523 | struct iw_param *vwrq, char *extra) |
| 1524 | { |
| 1525 | return -EOPNOTSUPP; /* Not Support */ |
| 1526 | } |
| 1527 | |
| 1528 | /*------------------------------------------------------------------*/ |
| 1529 | /* Wireless Handler : get Retry limits */ |
| 1530 | static int ks_wlan_get_retry(struct net_device *dev, struct iw_request_info *info, |
| 1531 | struct iw_param *vwrq, char *extra) |
| 1532 | { |
| 1533 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1534 | |
| 1535 | /* Not Support */ |
| 1536 | vwrq->value = 0; |
| 1537 | vwrq->disabled = (vwrq->value == 0); |
| 1538 | vwrq->fixed = 1; |
| 1539 | return 0; |
| 1540 | } |
| 1541 | #endif /* KSC_OPNOTSUPP */ |
| 1542 | |
| 1543 | /*------------------------------------------------------------------*/ |
| 1544 | /* Wireless Handler : get range info */ |
| 1545 | static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *info, |
| 1546 | struct iw_point *dwrq, char *extra) |
| 1547 | { |
| 1548 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1549 | struct iw_range *range = (struct iw_range *) extra; |
| 1550 | int i,k; |
| 1551 | |
| 1552 | DPRINTK(2,"\n"); |
| 1553 | |
| 1554 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1555 | |
| 1556 | dwrq->length = sizeof(struct iw_range); |
| 1557 | memset(range, 0, sizeof(*range)); |
| 1558 | range->min_nwid = 0x0000; |
| 1559 | range->max_nwid = 0x0000; |
| 1560 | range->num_channels = 14; |
| 1561 | /* Should be based on cap_rid.country to give only |
| 1562 | * what the current card support */ |
| 1563 | k = 0; |
| 1564 | for(i = 0; i < 13; i++) { /* channel 1 -- 13*/ |
| 1565 | range->freq[k].i = i + 1; /* List index */ |
| 1566 | range->freq[k].m = frequency_list[i] * 100000; |
| 1567 | range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ |
| 1568 | } |
| 1569 | range->num_frequency = k; |
| 1570 | if(priv->reg.phy_type == D_11B_ONLY_MODE || |
| 1571 | priv->reg.phy_type == D_11BG_COMPATIBLE_MODE){ /* channel 14 */ |
| 1572 | range->freq[13].i = 14; /* List index */ |
| 1573 | range->freq[13].m = frequency_list[13] * 100000; |
| 1574 | range->freq[13].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ |
| 1575 | range->num_frequency = 14; |
| 1576 | } |
| 1577 | |
| 1578 | /* Hum... Should put the right values there */ |
| 1579 | range->max_qual.qual = 100; |
| 1580 | range->max_qual.level = 256 - 128; /* 0 dBm? */ |
| 1581 | range->max_qual.noise = 256 - 128; |
| 1582 | range->sensitivity = 1; |
| 1583 | |
| 1584 | if(priv->reg.phy_type == D_11B_ONLY_MODE){ |
| 1585 | range->bitrate[0] = 1e6; |
| 1586 | range->bitrate[1] = 2e6; |
| 1587 | range->bitrate[2] = 5.5e6; |
| 1588 | range->bitrate[3] = 11e6; |
| 1589 | range->num_bitrates = 4; |
| 1590 | } |
| 1591 | else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ |
| 1592 | range->bitrate[0] = 1e6; |
| 1593 | range->bitrate[1] = 2e6; |
| 1594 | range->bitrate[2] = 5.5e6; |
| 1595 | range->bitrate[3] = 11e6; |
| 1596 | |
| 1597 | range->bitrate[4] = 6e6; |
| 1598 | range->bitrate[5] = 9e6; |
| 1599 | range->bitrate[6] = 12e6; |
| 1600 | if(IW_MAX_BITRATES < 9){ |
| 1601 | range->bitrate[7] = 54e6; |
| 1602 | range->num_bitrates = 8; |
| 1603 | }else{ |
| 1604 | range->bitrate[7] = 18e6; |
| 1605 | range->bitrate[8] = 24e6; |
| 1606 | range->bitrate[9] = 36e6; |
| 1607 | range->bitrate[10] = 48e6; |
| 1608 | range->bitrate[11] = 54e6; |
| 1609 | |
| 1610 | range->num_bitrates = 12; |
| 1611 | } |
| 1612 | } |
| 1613 | |
| 1614 | /* Set an indication of the max TCP throughput |
| 1615 | * in bit/s that we can expect using this interface. |
| 1616 | * May be use for QoS stuff... Jean II */ |
| 1617 | if(i > 2) |
| 1618 | range->throughput = 5000 * 1000; |
| 1619 | else |
| 1620 | range->throughput = 1500 * 1000; |
| 1621 | |
| 1622 | range->min_rts = 0; |
| 1623 | range->max_rts = 2347; |
| 1624 | range->min_frag = 256; |
| 1625 | range->max_frag = 2346; |
| 1626 | |
| 1627 | range->encoding_size[0] = 5; /* WEP: RC4 40 bits */ |
| 1628 | range->encoding_size[1] = 13; /* WEP: RC4 ~128 bits */ |
| 1629 | range->num_encoding_sizes = 2; |
| 1630 | range->max_encoding_tokens = 4; |
| 1631 | |
| 1632 | /* power management not support */ |
| 1633 | range->pmp_flags = IW_POWER_ON; |
| 1634 | range->pmt_flags = IW_POWER_ON; |
| 1635 | range->pm_capa = 0; |
| 1636 | |
| 1637 | /* Transmit Power - values are in dBm( or mW) */ |
| 1638 | range->txpower[0]=-256; |
| 1639 | range->num_txpower = 1; |
| 1640 | range->txpower_capa = IW_TXPOW_DBM; |
| 1641 | /* range->txpower_capa = IW_TXPOW_MWATT; */ |
| 1642 | |
| 1643 | range->we_version_source = 21; |
| 1644 | range->we_version_compiled = WIRELESS_EXT; |
| 1645 | |
| 1646 | range->retry_capa = IW_RETRY_ON; |
| 1647 | range->retry_flags = IW_RETRY_ON; |
| 1648 | range->r_time_flags = IW_RETRY_ON; |
| 1649 | |
| 1650 | /* Experimental measurements - boundary 11/5.5 Mb/s */ |
| 1651 | /* Note : with or without the (local->rssi), results |
| 1652 | * are somewhat different. - Jean II */ |
| 1653 | range->avg_qual.qual = 50; |
| 1654 | range->avg_qual.level = 186; /* -70 dBm */ |
| 1655 | range->avg_qual.noise = 0; |
| 1656 | |
| 1657 | #if defined(WIRELESS_EXT) |
| 1658 | /* Event capability (kernel + driver) */ |
| 1659 | range->event_capa[0] = (IW_EVENT_CAPA_K_0 | |
| 1660 | IW_EVENT_CAPA_MASK(SIOCGIWAP) | |
| 1661 | IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); |
| 1662 | range->event_capa[1] = IW_EVENT_CAPA_K_1; |
| 1663 | range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVCUSTOM) | |
| 1664 | IW_EVENT_CAPA_MASK(IWEVMICHAELMICFAILURE)); |
| 1665 | |
| 1666 | /* encode extension (WPA) capability */ |
| 1667 | range->enc_capa = (IW_ENC_CAPA_WPA | |
| 1668 | IW_ENC_CAPA_WPA2 | |
| 1669 | IW_ENC_CAPA_CIPHER_TKIP | |
| 1670 | IW_ENC_CAPA_CIPHER_CCMP); |
| 1671 | #endif |
| 1672 | return 0; |
| 1673 | } |
| 1674 | |
| 1675 | |
| 1676 | /*------------------------------------------------------------------*/ |
| 1677 | /* Wireless Handler : set Power Management */ |
| 1678 | static int ks_wlan_set_power(struct net_device *dev, struct iw_request_info *info, |
| 1679 | struct iw_param *vwrq, char *extra) |
| 1680 | { |
| 1681 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1682 | short enabled; |
| 1683 | |
| 1684 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1685 | |
| 1686 | enabled = vwrq->disabled ? 0 : 1; |
| 1687 | if(enabled == 0 ){ /* 0 */ |
| 1688 | priv->reg.powermgt = POWMGT_ACTIVE_MODE; |
| 1689 | }else if(enabled){ /* 1 */ |
| 1690 | if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) |
| 1691 | priv->reg.powermgt = POWMGT_SAVE1_MODE; |
| 1692 | else |
| 1693 | return -EINVAL; |
| 1694 | }else if(enabled){ /* 2 */ |
| 1695 | if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) |
| 1696 | priv->reg.powermgt = POWMGT_SAVE2_MODE; |
| 1697 | else |
| 1698 | return -EINVAL; |
| 1699 | }else |
| 1700 | return -EINVAL; |
| 1701 | |
| 1702 | hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); |
| 1703 | |
| 1704 | return 0; |
| 1705 | } |
| 1706 | |
| 1707 | /*------------------------------------------------------------------*/ |
| 1708 | /* Wireless Handler : get Power Management */ |
| 1709 | static int ks_wlan_get_power(struct net_device *dev, struct iw_request_info *info, |
| 1710 | struct iw_param *vwrq, char *extra) |
| 1711 | { |
| 1712 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1713 | |
| 1714 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1715 | |
| 1716 | if(priv->reg.powermgt > 0) |
| 1717 | vwrq->disabled = 0; |
| 1718 | else |
| 1719 | vwrq->disabled = 1; |
| 1720 | |
| 1721 | return 0; |
| 1722 | } |
| 1723 | |
| 1724 | /*------------------------------------------------------------------*/ |
| 1725 | /* Wireless Handler : get wirless statistics */ |
| 1726 | static int ks_wlan_get_iwstats(struct net_device *dev, struct iw_request_info *info, |
| 1727 | struct iw_quality *vwrq, char *extra) |
| 1728 | { |
| 1729 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1730 | |
| 1731 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1732 | |
| 1733 | vwrq->qual = 0; /* not supported */ |
| 1734 | vwrq->level = priv->wstats.qual.level; |
| 1735 | vwrq->noise = 0; /* not supported */ |
| 1736 | vwrq->updated = 0; |
| 1737 | |
| 1738 | return 0; |
| 1739 | } |
| 1740 | |
| 1741 | #ifndef KSC_OPNOTSUPP |
| 1742 | /*------------------------------------------------------------------*/ |
| 1743 | /* Wireless Handler : set Sensitivity */ |
| 1744 | static int ks_wlan_set_sens(struct net_device *dev, struct iw_request_info *info, |
| 1745 | struct iw_param *vwrq, char *extra) |
| 1746 | { |
| 1747 | return -EOPNOTSUPP; /* Not Support */ |
| 1748 | } |
| 1749 | |
| 1750 | /*------------------------------------------------------------------*/ |
| 1751 | /* Wireless Handler : get Sensitivity */ |
| 1752 | static int ks_wlan_get_sens(struct net_device *dev, struct iw_request_info *info, |
| 1753 | struct iw_param *vwrq, char *extra) |
| 1754 | { |
| 1755 | /* Not Support */ |
| 1756 | vwrq->value = 0; |
| 1757 | vwrq->disabled = (vwrq->value == 0); |
| 1758 | vwrq->fixed = 1; |
| 1759 | return 0; |
| 1760 | } |
| 1761 | #endif /* KSC_OPNOTSUPP */ |
| 1762 | |
| 1763 | |
| 1764 | /*------------------------------------------------------------------*/ |
| 1765 | /* Wireless Handler : get AP List */ |
| 1766 | /* Note : this is deprecated in favor of IWSCAN */ |
| 1767 | static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *info, |
| 1768 | struct iw_point *dwrq, char *extra) |
| 1769 | { |
| 1770 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1771 | struct sockaddr *address = (struct sockaddr *) extra; |
| 1772 | struct iw_quality qual[LOCAL_APLIST_MAX]; |
| 1773 | |
| 1774 | int i; |
| 1775 | |
| 1776 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1777 | |
| 1778 | for (i = 0; i < priv->aplist.size; i++) { |
| 1779 | memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]), ETH_ALEN); |
| 1780 | address[i].sa_family = ARPHRD_ETHER; |
| 1781 | qual[i].level = 256 - priv->aplist.ap[i].rssi; |
| 1782 | qual[i].qual = priv->aplist.ap[i].sq; |
| 1783 | qual[i].noise = 0; /* invalid noise value */ |
| 1784 | qual[i].updated = 7; |
| 1785 | } |
| 1786 | if (i){ |
| 1787 | dwrq->flags = 1; /* Should be define'd */ |
| 1788 | memcpy(extra + sizeof(struct sockaddr)*i, |
| 1789 | &qual, sizeof(struct iw_quality)*i); |
| 1790 | } |
| 1791 | dwrq->length = i; |
| 1792 | |
| 1793 | return 0; |
| 1794 | } |
| 1795 | |
| 1796 | #if defined(WIRELESS_EXT) |
| 1797 | /*------------------------------------------------------------------*/ |
| 1798 | /* Wireless Handler : Initiate Scan */ |
| 1799 | static int ks_wlan_set_scan(struct net_device *dev, struct iw_request_info *info, |
| 1800 | union iwreq_data *wrqu, char *extra) |
| 1801 | { |
| 1802 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1803 | struct iw_scan_req *req = NULL; |
| 1804 | DPRINTK(2,"\n"); |
| 1805 | |
| 1806 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1807 | |
| 1808 | /* specified SSID SCAN */ |
| 1809 | if(wrqu->data.length == sizeof(struct iw_scan_req) && wrqu->data.flags & IW_SCAN_THIS_ESSID){ |
| 1810 | req = (struct iw_scan_req *) extra; |
| 1811 | priv->scan_ssid_len = req->essid_len; |
| 1812 | memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len); |
| 1813 | }else{ |
| 1814 | priv->scan_ssid_len = 0; |
| 1815 | } |
| 1816 | |
| 1817 | |
| 1818 | priv->sme_i.sme_flag |= SME_AP_SCAN; |
| 1819 | hostif_sme_enqueue(priv, SME_BSS_SCAN_REQUEST); |
| 1820 | |
| 1821 | /* At this point, just return to the user. */ |
| 1822 | |
| 1823 | return 0; |
| 1824 | } |
| 1825 | |
| 1826 | /*------------------------------------------------------------------*/ |
| 1827 | /* |
| 1828 | * Translate scan data returned from the card to a card independent |
| 1829 | * format that the Wireless Tools will understand - Jean II |
| 1830 | */ |
| 1831 | static inline char *ks_wlan_translate_scan(struct net_device *dev, struct iw_request_info *info, char *current_ev, |
| 1832 | char *end_buf, struct local_ap_t *ap) |
| 1833 | { |
| 1834 | /* ks_wlan_private *priv = (ks_wlan_private *)dev->priv; */ |
| 1835 | struct iw_event iwe; /* Temporary buffer */ |
| 1836 | u16 capabilities; |
| 1837 | char *current_val; /* For rates */ |
| 1838 | int i; |
| 1839 | static const char rsn_leader[] = "rsn_ie="; |
| 1840 | static const char wpa_leader[] = "wpa_ie="; |
| 1841 | char buf0[RSN_IE_BODY_MAX*2 + 30]; |
| 1842 | char buf1[RSN_IE_BODY_MAX*2 + 30]; |
| 1843 | char *pbuf; |
| 1844 | /* First entry *MUST* be the AP MAC address */ |
| 1845 | iwe.cmd = SIOCGIWAP; |
| 1846 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; |
| 1847 | memcpy(iwe.u.ap_addr.sa_data, ap->bssid, ETH_ALEN); |
| 1848 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); |
| 1849 | |
| 1850 | /* Other entries will be displayed in the order we give them */ |
| 1851 | |
| 1852 | /* Add the ESSID */ |
| 1853 | iwe.u.data.length = ap->ssid.size; |
| 1854 | if(iwe.u.data.length > 32) |
| 1855 | iwe.u.data.length = 32; |
| 1856 | iwe.cmd = SIOCGIWESSID; |
| 1857 | iwe.u.data.flags = 1; |
| 1858 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &(ap->ssid.body[0])); |
| 1859 | |
| 1860 | /* Add mode */ |
| 1861 | iwe.cmd = SIOCGIWMODE; |
| 1862 | capabilities = le16_to_cpu(ap->capability); |
| 1863 | if(capabilities & (BSS_CAP_ESS | BSS_CAP_IBSS)) { |
| 1864 | if(capabilities & BSS_CAP_ESS) |
| 1865 | iwe.u.mode = IW_MODE_INFRA; |
| 1866 | else |
| 1867 | iwe.u.mode = IW_MODE_ADHOC; |
| 1868 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); |
| 1869 | } |
| 1870 | |
| 1871 | /* Add frequency */ |
| 1872 | iwe.cmd = SIOCGIWFREQ; |
| 1873 | iwe.u.freq.m = ap->channel; |
| 1874 | iwe.u.freq.m = frequency_list[iwe.u.freq.m-1] * 100000; |
| 1875 | iwe.u.freq.e = 1; |
| 1876 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); |
| 1877 | |
| 1878 | /* Add quality statistics */ |
| 1879 | iwe.cmd = IWEVQUAL; |
| 1880 | iwe.u.qual.level = 256 - ap->rssi; |
| 1881 | iwe.u.qual.qual = ap->sq; |
| 1882 | iwe.u.qual.noise = 0; /* invalid noise value */ |
| 1883 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); |
| 1884 | |
| 1885 | /* Add encryption capability */ |
| 1886 | iwe.cmd = SIOCGIWENCODE; |
| 1887 | if(capabilities & BSS_CAP_PRIVACY) |
| 1888 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; |
| 1889 | else |
| 1890 | iwe.u.data.flags = IW_ENCODE_DISABLED; |
| 1891 | iwe.u.data.length = 0; |
| 1892 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &(ap->ssid.body[0])); |
| 1893 | |
| 1894 | /* Rate : stuffing multiple values in a single event require a bit |
| 1895 | * more of magic - Jean II */ |
| 1896 | current_val = current_ev + IW_EV_LCP_LEN; |
| 1897 | |
| 1898 | iwe.cmd = SIOCGIWRATE; |
| 1899 | /* Those two flags are ignored... */ |
| 1900 | iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; |
| 1901 | |
| 1902 | /* Max 16 values */ |
| 1903 | for(i = 0 ; i < 16 ; i++) { |
| 1904 | /* NULL terminated */ |
| 1905 | if(i >= ap->rate_set.size) |
| 1906 | break; |
| 1907 | /* Bit rate given in 500 kb/s units (+ 0x80) */ |
| 1908 | iwe.u.bitrate.value = ((ap->rate_set.body[i] & 0x7f) * 500000); |
| 1909 | /* Add new value to event */ |
| 1910 | current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); |
| 1911 | } |
| 1912 | /* Check if we added any event */ |
| 1913 | if((current_val - current_ev) > IW_EV_LCP_LEN) |
| 1914 | current_ev = current_val; |
| 1915 | |
| 1916 | #define GENERIC_INFO_ELEM_ID 0xdd |
| 1917 | #define RSN_INFO_ELEM_ID 0x30 |
| 1918 | if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) { |
| 1919 | pbuf = &buf0[0]; |
| 1920 | memset(&iwe, 0, sizeof(iwe)); |
| 1921 | iwe.cmd = IWEVCUSTOM; |
| 1922 | memcpy(buf0,rsn_leader,sizeof(rsn_leader)-1); |
| 1923 | iwe.u.data.length += sizeof(rsn_leader)-1; |
| 1924 | pbuf += sizeof(rsn_leader)-1; |
| 1925 | |
| 1926 | pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.id); |
| 1927 | pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.size); |
| 1928 | iwe.u.data.length += 4; |
| 1929 | |
| 1930 | for (i = 0; i < ap->rsn_ie.size; i++) |
| 1931 | pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.body[i]); |
| 1932 | iwe.u.data.length += (ap->rsn_ie.size)*2; |
| 1933 | |
| 1934 | DPRINTK(4,"ap->rsn.size=%d\n",ap->rsn_ie.size); |
| 1935 | |
| 1936 | current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, &buf0[0]); |
| 1937 | } |
| 1938 | if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) { |
| 1939 | pbuf = &buf1[0]; |
| 1940 | memset(&iwe, 0, sizeof(iwe)); |
| 1941 | iwe.cmd = IWEVCUSTOM; |
| 1942 | memcpy(buf1,wpa_leader,sizeof(wpa_leader)-1); |
| 1943 | iwe.u.data.length += sizeof(wpa_leader)-1; |
| 1944 | pbuf += sizeof(wpa_leader)-1; |
| 1945 | |
| 1946 | pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.id); |
| 1947 | pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.size); |
| 1948 | iwe.u.data.length += 4; |
| 1949 | |
| 1950 | for (i = 0; i < ap->wpa_ie.size; i++) |
| 1951 | pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.body[i]); |
| 1952 | iwe.u.data.length += (ap->wpa_ie.size)*2; |
| 1953 | |
| 1954 | DPRINTK(4,"ap->rsn.size=%d\n",ap->wpa_ie.size); |
| 1955 | DPRINTK(4,"iwe.u.data.length=%d\n",iwe.u.data.length); |
| 1956 | |
| 1957 | current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, &buf1[0]); |
| 1958 | } |
| 1959 | |
| 1960 | /* The other data in the scan result are not really |
| 1961 | * interesting, so for now drop it - Jean II */ |
| 1962 | return current_ev; |
| 1963 | } |
| 1964 | |
| 1965 | /*------------------------------------------------------------------*/ |
| 1966 | /* Wireless Handler : Read Scan Results */ |
| 1967 | static int ks_wlan_get_scan(struct net_device *dev, struct iw_request_info *info, |
| 1968 | struct iw_point *dwrq, char *extra) |
| 1969 | { |
| 1970 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 1971 | int i; |
| 1972 | char *current_ev = extra; |
| 1973 | DPRINTK(2,"\n"); |
| 1974 | |
| 1975 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 1976 | |
| 1977 | if(priv->sme_i.sme_flag & SME_AP_SCAN) { |
| 1978 | DPRINTK(2,"flag AP_SCAN\n"); |
| 1979 | return -EAGAIN; |
| 1980 | } |
| 1981 | |
| 1982 | if(priv->aplist.size == 0) { |
| 1983 | /* Client error, no scan results... |
| 1984 | * The caller need to restart the scan. */ |
| 1985 | DPRINTK(2,"aplist 0\n"); |
| 1986 | return -ENODATA; |
| 1987 | } |
| 1988 | #if 0 |
| 1989 | /* current connect ap */ |
| 1990 | if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ |
| 1991 | if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { |
| 1992 | dwrq->length = 0; |
| 1993 | return -E2BIG; |
| 1994 | } |
| 1995 | current_ev = ks_wlan_translate_scan(dev, current_ev, |
| 1996 | // extra + IW_SCAN_MAX_DATA, |
| 1997 | extra + dwrq->length, |
| 1998 | &(priv->current_ap)); |
| 1999 | } |
| 2000 | #endif |
| 2001 | /* Read and parse all entries */ |
| 2002 | for(i=0; i < priv->aplist.size; i++) { |
| 2003 | if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { |
| 2004 | dwrq->length = 0; |
| 2005 | return -E2BIG; |
| 2006 | } |
| 2007 | /* Translate to WE format this entry */ |
| 2008 | current_ev = ks_wlan_translate_scan(dev, info, current_ev, |
| 2009 | // extra + IW_SCAN_MAX_DATA, |
| 2010 | extra + dwrq->length, |
| 2011 | &(priv->aplist.ap[i])); |
| 2012 | } |
| 2013 | /* Length of data */ |
| 2014 | dwrq->length = (current_ev - extra); |
| 2015 | dwrq->flags = 0; |
| 2016 | |
| 2017 | return 0; |
| 2018 | } |
| 2019 | #endif /* WIRELESS_EXT */ |
| 2020 | |
| 2021 | /*------------------------------------------------------------------*/ |
| 2022 | /* Commit handler : called after a bunch of SET operations */ |
| 2023 | static int ks_wlan_config_commit(struct net_device *dev, struct iw_request_info *info, |
| 2024 | void *zwrq, char *extra) |
| 2025 | { |
| 2026 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2027 | |
| 2028 | if (!priv->need_commit) |
| 2029 | return 0; |
| 2030 | |
| 2031 | ks_wlan_setup_parameter(priv, priv->need_commit); |
| 2032 | priv->need_commit=0; |
| 2033 | return 0; |
| 2034 | } |
| 2035 | |
| 2036 | #ifdef WIRELESS_EXT |
| 2037 | /*------------------------------------------------------------------*/ |
| 2038 | /* Wireless handler : set association ie params */ |
| 2039 | static int ks_wlan_set_genie(struct net_device *dev, struct iw_request_info *info, |
| 2040 | struct iw_point *dwrq, char *extra) |
| 2041 | { |
| 2042 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2043 | |
| 2044 | DPRINTK(2, "\n"); |
| 2045 | |
| 2046 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2047 | |
| 2048 | return 0; |
| 2049 | // return -EOPNOTSUPP; |
| 2050 | } |
| 2051 | |
| 2052 | /*------------------------------------------------------------------*/ |
| 2053 | /* Wireless handler : set authentication mode params */ |
| 2054 | static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info *info, |
| 2055 | struct iw_param *vwrq, char *extra) |
| 2056 | { |
| 2057 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2058 | int index = (vwrq->flags & IW_AUTH_INDEX); |
| 2059 | int value = vwrq->value; |
| 2060 | |
| 2061 | DPRINTK(2,"index=%d:value=%08X\n",index,value); |
| 2062 | |
| 2063 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2064 | |
| 2065 | switch(index){ |
| 2066 | case IW_AUTH_WPA_VERSION: /* 0 */ |
| 2067 | switch(value){ |
| 2068 | case IW_AUTH_WPA_VERSION_DISABLED: |
| 2069 | priv->wpa.version = value; |
| 2070 | if(priv->wpa.rsn_enabled){ |
| 2071 | priv->wpa.rsn_enabled = 0; |
| 2072 | } |
| 2073 | priv->need_commit |= SME_RSN; |
| 2074 | break; |
| 2075 | case IW_AUTH_WPA_VERSION_WPA: |
| 2076 | case IW_AUTH_WPA_VERSION_WPA2: |
| 2077 | priv->wpa.version = value; |
| 2078 | if(!(priv->wpa.rsn_enabled)){ |
| 2079 | priv->wpa.rsn_enabled = 1; |
| 2080 | } |
| 2081 | priv->need_commit |= SME_RSN; |
| 2082 | break; |
| 2083 | default: |
| 2084 | return -EOPNOTSUPP; |
| 2085 | } |
| 2086 | break; |
| 2087 | case IW_AUTH_CIPHER_PAIRWISE: /* 1 */ |
| 2088 | switch(value){ |
| 2089 | case IW_AUTH_CIPHER_NONE: |
| 2090 | if(priv->reg.privacy_invoked){ |
| 2091 | priv->reg.privacy_invoked = 0x00; |
| 2092 | priv->need_commit |= SME_WEP_FLAG; |
| 2093 | } |
| 2094 | break; |
| 2095 | case IW_AUTH_CIPHER_WEP40: |
| 2096 | case IW_AUTH_CIPHER_TKIP: |
| 2097 | case IW_AUTH_CIPHER_CCMP: |
| 2098 | case IW_AUTH_CIPHER_WEP104: |
| 2099 | if(!priv->reg.privacy_invoked){ |
| 2100 | priv->reg.privacy_invoked = 0x01; |
| 2101 | priv->need_commit |= SME_WEP_FLAG; |
| 2102 | } |
| 2103 | priv->wpa.pairwise_suite = value; |
| 2104 | priv->need_commit |= SME_RSN_UNICAST; |
| 2105 | break; |
| 2106 | default: |
| 2107 | return -EOPNOTSUPP; |
| 2108 | } |
| 2109 | break; |
| 2110 | case IW_AUTH_CIPHER_GROUP: /* 2 */ |
| 2111 | switch(value){ |
| 2112 | case IW_AUTH_CIPHER_NONE: |
| 2113 | if(priv->reg.privacy_invoked){ |
| 2114 | priv->reg.privacy_invoked = 0x00; |
| 2115 | priv->need_commit |= SME_WEP_FLAG; |
| 2116 | } |
| 2117 | break; |
| 2118 | case IW_AUTH_CIPHER_WEP40: |
| 2119 | case IW_AUTH_CIPHER_TKIP: |
| 2120 | case IW_AUTH_CIPHER_CCMP: |
| 2121 | case IW_AUTH_CIPHER_WEP104: |
| 2122 | if(!priv->reg.privacy_invoked){ |
| 2123 | priv->reg.privacy_invoked = 0x01; |
| 2124 | priv->need_commit |= SME_WEP_FLAG; |
| 2125 | } |
| 2126 | priv->wpa.group_suite = value; |
| 2127 | priv->need_commit |= SME_RSN_MULTICAST; |
| 2128 | break; |
| 2129 | default: |
| 2130 | return -EOPNOTSUPP; |
| 2131 | } |
| 2132 | break; |
| 2133 | case IW_AUTH_KEY_MGMT: /* 3 */ |
| 2134 | switch(value){ |
| 2135 | case IW_AUTH_KEY_MGMT_802_1X: |
| 2136 | case IW_AUTH_KEY_MGMT_PSK: |
| 2137 | case 0: /* NONE or 802_1X_NO_WPA */ |
| 2138 | case 4: /* WPA_NONE */ |
| 2139 | priv->wpa.key_mgmt_suite = value; |
| 2140 | priv->need_commit |= SME_RSN_AUTH; |
| 2141 | break; |
| 2142 | default: |
| 2143 | return -EOPNOTSUPP; |
| 2144 | } |
| 2145 | break; |
| 2146 | case IW_AUTH_80211_AUTH_ALG: /* 6 */ |
| 2147 | switch(value){ |
| 2148 | case IW_AUTH_ALG_OPEN_SYSTEM: |
| 2149 | priv->wpa.auth_alg = value; |
| 2150 | priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; |
| 2151 | break; |
| 2152 | case IW_AUTH_ALG_SHARED_KEY: |
| 2153 | priv->wpa.auth_alg = value; |
| 2154 | priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; |
| 2155 | break; |
| 2156 | case IW_AUTH_ALG_LEAP: |
| 2157 | default: |
| 2158 | return -EOPNOTSUPP; |
| 2159 | } |
| 2160 | priv->need_commit |= SME_MODE_SET; |
| 2161 | break; |
| 2162 | case IW_AUTH_WPA_ENABLED: /* 7 */ |
| 2163 | priv->wpa.wpa_enabled = value; |
| 2164 | break; |
| 2165 | case IW_AUTH_PRIVACY_INVOKED: /* 10 */ |
| 2166 | if((value && !priv->reg.privacy_invoked)|| |
| 2167 | (!value && priv->reg.privacy_invoked)){ |
| 2168 | priv->reg.privacy_invoked = value?0x01:0x00; |
| 2169 | priv->need_commit |= SME_WEP_FLAG; |
| 2170 | } |
| 2171 | break; |
| 2172 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* 4 */ |
| 2173 | case IW_AUTH_TKIP_COUNTERMEASURES: /* 5 */ |
| 2174 | case IW_AUTH_DROP_UNENCRYPTED: /* 8 */ |
| 2175 | case IW_AUTH_ROAMING_CONTROL: /* 9 */ |
| 2176 | default: |
| 2177 | break; |
| 2178 | } |
| 2179 | |
| 2180 | /* return -EINPROGRESS; */ |
| 2181 | if(priv->need_commit){ |
| 2182 | ks_wlan_setup_parameter(priv, priv->need_commit); |
| 2183 | priv->need_commit=0; |
| 2184 | } |
| 2185 | return 0; |
| 2186 | } |
| 2187 | |
| 2188 | /*------------------------------------------------------------------*/ |
| 2189 | /* Wireless handler : get authentication mode params */ |
| 2190 | static int ks_wlan_get_auth_mode(struct net_device *dev, struct iw_request_info *info, |
| 2191 | struct iw_param *vwrq, char *extra) |
| 2192 | { |
| 2193 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2194 | int index = (vwrq->flags & IW_AUTH_INDEX); |
| 2195 | DPRINTK(2,"index=%d\n",index); |
| 2196 | |
| 2197 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2198 | |
| 2199 | /* WPA (not used ?? wpa_supplicant) */ |
| 2200 | switch(index){ |
| 2201 | case IW_AUTH_WPA_VERSION: |
| 2202 | vwrq->value = priv->wpa.version; |
| 2203 | break; |
| 2204 | case IW_AUTH_CIPHER_PAIRWISE: |
| 2205 | vwrq->value = priv->wpa.pairwise_suite; |
| 2206 | break; |
| 2207 | case IW_AUTH_CIPHER_GROUP: |
| 2208 | vwrq->value = priv->wpa.group_suite; |
| 2209 | break; |
| 2210 | case IW_AUTH_KEY_MGMT: |
| 2211 | vwrq->value = priv->wpa.key_mgmt_suite; |
| 2212 | break; |
| 2213 | case IW_AUTH_80211_AUTH_ALG: |
| 2214 | vwrq->value = priv->wpa.auth_alg; |
| 2215 | break; |
| 2216 | case IW_AUTH_WPA_ENABLED: |
| 2217 | vwrq->value = priv->wpa.rsn_enabled; |
| 2218 | break; |
| 2219 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* OK??? */ |
| 2220 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 2221 | case IW_AUTH_DROP_UNENCRYPTED: |
| 2222 | default: |
| 2223 | /* return -EOPNOTSUPP; */ |
| 2224 | break; |
| 2225 | } |
| 2226 | return 0; |
| 2227 | } |
| 2228 | |
| 2229 | /*------------------------------------------------------------------*/ |
| 2230 | /* Wireless Handler : set encoding token & mode (WPA)*/ |
| 2231 | static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info *info, |
| 2232 | struct iw_point *dwrq, char *extra) |
| 2233 | { |
| 2234 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2235 | struct iw_encode_ext *enc; |
| 2236 | int index = dwrq->flags & IW_ENCODE_INDEX; |
| 2237 | unsigned int commit=0; |
| 2238 | |
| 2239 | enc = (struct iw_encode_ext *)extra; |
| 2240 | |
| 2241 | DPRINTK(2,"flags=%04X:: ext_flags=%08X\n",dwrq->flags, enc->ext_flags); |
| 2242 | |
| 2243 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2244 | |
| 2245 | if(index<1||index>4) |
| 2246 | return -EINVAL; |
| 2247 | else |
| 2248 | index--; |
| 2249 | |
| 2250 | if(dwrq->flags & IW_ENCODE_DISABLED){ |
| 2251 | priv->wpa.key[index].key_len=0; |
| 2252 | } |
| 2253 | |
| 2254 | if(enc){ |
| 2255 | priv->wpa.key[index].ext_flags=enc->ext_flags; |
| 2256 | if(enc->ext_flags&IW_ENCODE_EXT_SET_TX_KEY){ |
| 2257 | priv->wpa.txkey=index; |
| 2258 | commit |= SME_WEP_INDEX; |
| 2259 | }else if(enc->ext_flags&IW_ENCODE_EXT_RX_SEQ_VALID){ |
| 2260 | if(enc->rx_seq) |
| 2261 | memcpy(&priv->wpa.key[index].rx_seq[0], |
| 2262 | enc->rx_seq, IW_ENCODE_SEQ_MAX_SIZE); |
| 2263 | else |
| 2264 | return -EINVAL; |
| 2265 | } |
| 2266 | |
| 2267 | memcpy(&priv->wpa.key[index].addr.sa_data[0], |
| 2268 | &enc->addr.sa_data[0], ETH_ALEN); |
| 2269 | |
| 2270 | switch (enc->alg) { |
| 2271 | case IW_ENCODE_ALG_NONE: |
| 2272 | if(priv->reg.privacy_invoked){ |
| 2273 | priv->reg.privacy_invoked = 0x00; |
| 2274 | commit |= SME_WEP_FLAG; |
| 2275 | } |
| 2276 | priv->wpa.key[index].key_len = 0; |
| 2277 | |
| 2278 | break; |
| 2279 | case IW_ENCODE_ALG_WEP: |
| 2280 | case IW_ENCODE_ALG_CCMP: |
| 2281 | if(!priv->reg.privacy_invoked){ |
| 2282 | priv->reg.privacy_invoked = 0x01; |
| 2283 | commit |= SME_WEP_FLAG; |
| 2284 | } |
| 2285 | if(enc->key && enc->key_len){ |
| 2286 | memcpy(&priv->wpa.key[index].key_val[0], |
| 2287 | &enc->key[0], enc->key_len); |
| 2288 | priv->wpa.key[index].key_len = enc->key_len; |
| 2289 | commit |= (SME_WEP_VAL1 << index); |
| 2290 | } |
| 2291 | break; |
| 2292 | case IW_ENCODE_ALG_TKIP: |
| 2293 | if(!priv->reg.privacy_invoked){ |
| 2294 | priv->reg.privacy_invoked = 0x01; |
| 2295 | commit |= SME_WEP_FLAG; |
| 2296 | } |
| 2297 | if(enc->key && enc->key_len == 32){ |
| 2298 | memcpy(&priv->wpa.key[index].key_val[0], |
| 2299 | &enc->key[0], enc->key_len-16); |
| 2300 | priv->wpa.key[index].key_len = enc->key_len-16; |
| 2301 | if(priv->wpa.key_mgmt_suite==4){ /* WPA_NONE */ |
| 2302 | memcpy(&priv->wpa.key[index].tx_mic_key[0], |
| 2303 | &enc->key[16],8); |
| 2304 | memcpy(&priv->wpa.key[index].rx_mic_key[0], |
| 2305 | &enc->key[16],8); |
| 2306 | }else{ |
| 2307 | memcpy(&priv->wpa.key[index].tx_mic_key[0], |
| 2308 | &enc->key[16],8); |
| 2309 | memcpy(&priv->wpa.key[index].rx_mic_key[0], |
| 2310 | &enc->key[24],8); |
| 2311 | } |
| 2312 | commit |= (SME_WEP_VAL1 << index); |
| 2313 | } |
| 2314 | break; |
| 2315 | default: |
| 2316 | return -EINVAL; |
| 2317 | } |
| 2318 | priv->wpa.key[index].alg=enc->alg; |
| 2319 | } |
| 2320 | else |
| 2321 | return -EINVAL; |
| 2322 | |
| 2323 | if(commit){ |
| 2324 | if(commit&SME_WEP_INDEX) |
| 2325 | hostif_sme_enqueue(priv, SME_SET_TXKEY); |
| 2326 | if(commit&SME_WEP_VAL_MASK) |
| 2327 | hostif_sme_enqueue(priv, SME_SET_KEY1+index); |
| 2328 | if(commit&SME_WEP_FLAG) |
| 2329 | hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); |
| 2330 | } |
| 2331 | |
| 2332 | return 0; |
| 2333 | } |
| 2334 | |
| 2335 | /*------------------------------------------------------------------*/ |
| 2336 | /* Wireless Handler : get encoding token & mode (WPA)*/ |
| 2337 | static int ks_wlan_get_encode_ext(struct net_device *dev, struct iw_request_info *info, |
| 2338 | struct iw_point *dwrq, char *extra) |
| 2339 | { |
| 2340 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2341 | |
| 2342 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2343 | |
| 2344 | /* WPA (not used ?? wpa_supplicant) |
| 2345 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 2346 | struct iw_encode_ext *enc; |
| 2347 | enc = (struct iw_encode_ext *)extra; |
| 2348 | int index = dwrq->flags & IW_ENCODE_INDEX; |
| 2349 | WPA (not used ?? wpa_supplicant) */ |
| 2350 | return 0; |
| 2351 | } |
| 2352 | |
| 2353 | /*------------------------------------------------------------------*/ |
| 2354 | /* Wireless Handler : PMKSA cache operation (WPA2) */ |
| 2355 | static int ks_wlan_set_pmksa(struct net_device *dev, struct iw_request_info *info, |
| 2356 | struct iw_point *dwrq, char *extra) |
| 2357 | { |
| 2358 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2359 | struct iw_pmksa *pmksa ; |
| 2360 | int i; |
| 2361 | struct pmk_t *pmk; |
| 2362 | struct list_head *ptr; |
| 2363 | |
| 2364 | DPRINTK(2,"\n"); |
| 2365 | |
| 2366 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2367 | |
| 2368 | if(!extra){ |
| 2369 | return -EINVAL; |
| 2370 | } |
| 2371 | pmksa = (struct iw_pmksa *)extra; |
| 2372 | DPRINTK(2,"cmd=%d\n",pmksa->cmd); |
| 2373 | |
| 2374 | switch(pmksa->cmd){ |
| 2375 | case IW_PMKSA_ADD: |
| 2376 | if(list_empty(&priv->pmklist.head)){ /* new list */ |
| 2377 | for(i=0;i<PMK_LIST_MAX;i++){ |
| 2378 | pmk = &priv->pmklist.pmk[i]; |
| 2379 | if(!memcmp("\x00\x00\x00\x00\x00\x00",pmk->bssid,ETH_ALEN)) |
| 2380 | break; |
| 2381 | } |
| 2382 | memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); |
| 2383 | memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); |
| 2384 | list_add(&pmk->list,&priv->pmklist.head); |
| 2385 | priv->pmklist.size++; |
| 2386 | } |
| 2387 | else { /* search cache data */ |
| 2388 | list_for_each(ptr, &priv->pmklist.head){ |
| 2389 | pmk = list_entry(ptr, struct pmk_t, list); |
| 2390 | if(!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)){ /* match address! list move to head. */ |
| 2391 | memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); |
| 2392 | list_move(&pmk->list, &priv->pmklist.head); |
| 2393 | break; |
| 2394 | } |
| 2395 | } |
| 2396 | if(ptr == &priv->pmklist.head){ /* not find address. */ |
| 2397 | if(PMK_LIST_MAX > priv->pmklist.size){ /* new cache data */ |
| 2398 | for(i=0;i<PMK_LIST_MAX;i++){ |
| 2399 | pmk = &priv->pmklist.pmk[i]; |
| 2400 | if(!memcmp("\x00\x00\x00\x00\x00\x00",pmk->bssid,ETH_ALEN)) |
| 2401 | break; |
| 2402 | } |
| 2403 | memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); |
| 2404 | memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); |
| 2405 | list_add(&pmk->list,&priv->pmklist.head); |
| 2406 | priv->pmklist.size++; |
| 2407 | } |
| 2408 | else{ /* overwrite old cache data */ |
| 2409 | pmk = list_entry(priv->pmklist.head.prev, struct pmk_t, list); |
| 2410 | memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); |
| 2411 | memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); |
| 2412 | list_move(&pmk->list,&priv->pmklist.head); |
| 2413 | } |
| 2414 | } |
| 2415 | } |
| 2416 | break; |
| 2417 | case IW_PMKSA_REMOVE: |
| 2418 | if(list_empty(&priv->pmklist.head)){ /* list empty */ |
| 2419 | return -EINVAL; |
| 2420 | } |
| 2421 | else{ /* search cache data */ |
| 2422 | list_for_each(ptr, &priv->pmklist.head){ |
| 2423 | pmk = list_entry(ptr, struct pmk_t, list); |
| 2424 | if(!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)){ /* match address! list del. */ |
| 2425 | memset(pmk->bssid, 0, ETH_ALEN); |
| 2426 | memset(pmk->pmkid, 0, IW_PMKID_LEN); |
| 2427 | list_del_init(&pmk->list); |
| 2428 | break; |
| 2429 | } |
| 2430 | } |
| 2431 | if(ptr == &priv->pmklist.head){ /* not find address. */ |
| 2432 | return 0; |
| 2433 | } |
| 2434 | } |
| 2435 | break; |
| 2436 | case IW_PMKSA_FLUSH: |
| 2437 | memset(&(priv->pmklist), 0, sizeof(priv->pmklist)); |
| 2438 | INIT_LIST_HEAD(&priv->pmklist.head); |
| 2439 | for(i=0;i<PMK_LIST_MAX;i++) |
| 2440 | INIT_LIST_HEAD(&priv->pmklist.pmk[i].list); |
| 2441 | break; |
| 2442 | default: |
| 2443 | return -EINVAL; |
| 2444 | } |
| 2445 | |
| 2446 | hostif_sme_enqueue(priv, SME_SET_PMKSA); |
| 2447 | return 0; |
| 2448 | } |
| 2449 | |
| 2450 | static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev) |
| 2451 | { |
| 2452 | |
| 2453 | ks_wlan_private *priv = (ks_wlan_private *) netdev_priv(dev); |
| 2454 | struct iw_statistics *wstats = &priv->wstats; |
| 2455 | |
| 2456 | if(!atomic_read(&update_phyinfo)){ |
| 2457 | if (priv->dev_state < DEVICE_STATE_READY) |
| 2458 | return NULL; /* not finished initialize */ |
| 2459 | else |
| 2460 | return wstats; |
| 2461 | } |
| 2462 | |
| 2463 | /* Packets discarded in the wireless adapter due to wireless |
| 2464 | * specific problems */ |
| 2465 | wstats->discard.nwid = 0; /* Rx invalid nwid */ |
| 2466 | wstats->discard.code = 0; /* Rx invalid crypt */ |
| 2467 | wstats->discard.fragment = 0; /* Rx invalid frag */ |
| 2468 | wstats->discard.retries = 0; /* Tx excessive retries */ |
| 2469 | wstats->discard.misc = 0; /* Invalid misc */ |
| 2470 | wstats->miss.beacon = 0; /* Missed beacon */ |
| 2471 | |
| 2472 | return wstats; |
| 2473 | } |
| 2474 | |
| 2475 | /*------------------------------------------------------------------*/ |
| 2476 | /* Private handler : set stop request */ |
| 2477 | static int ks_wlan_set_stop_request(struct net_device *dev, struct iw_request_info *info, |
| 2478 | __u32 *uwrq, char *extra) |
| 2479 | { |
| 2480 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2481 | DPRINTK(2,"\n"); |
| 2482 | |
| 2483 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2484 | |
| 2485 | if(!(*uwrq)) |
| 2486 | return -EINVAL; |
| 2487 | |
| 2488 | hostif_sme_enqueue(priv, SME_STOP_REQUEST); |
| 2489 | return 0; |
| 2490 | } |
| 2491 | |
| 2492 | /*------------------------------------------------------------------*/ |
| 2493 | /* Wireless Handler : set MLME */ |
| 2494 | #include <linux/ieee80211.h> |
| 2495 | static int ks_wlan_set_mlme(struct net_device *dev, struct iw_request_info *info, |
| 2496 | struct iw_point *dwrq, char *extra) |
| 2497 | { |
| 2498 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2499 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
| 2500 | __u32 mode; |
| 2501 | |
| 2502 | DPRINTK(2, ":%d :%d\n", mlme->cmd, mlme->reason_code); |
| 2503 | |
| 2504 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2505 | |
| 2506 | switch (mlme->cmd) { |
| 2507 | case IW_MLME_DEAUTH: |
| 2508 | if (mlme->reason_code == WLAN_REASON_MIC_FAILURE) { |
| 2509 | return 0; |
| 2510 | } |
| 2511 | case IW_MLME_DISASSOC: |
| 2512 | mode = 1; |
| 2513 | return ks_wlan_set_stop_request(dev, NULL, &mode, NULL); |
| 2514 | default: |
| 2515 | return -EOPNOTSUPP; /* Not Support */ |
| 2516 | } |
| 2517 | } |
| 2518 | #endif /* WIRELESS_EXT */ |
| 2519 | |
| 2520 | /*------------------------------------------------------------------*/ |
| 2521 | /* Private handler : get driver version */ |
| 2522 | static int ks_wlan_get_driver_version(struct net_device *dev, struct iw_request_info *info, |
| 2523 | struct iw_point *dwrq, char *extra) |
| 2524 | { |
| 2525 | strcpy(extra, KS_WLAN_DRIVER_VERSION_INFO); |
| 2526 | dwrq->length = strlen(KS_WLAN_DRIVER_VERSION_INFO)+1; |
| 2527 | return 0; |
| 2528 | } |
| 2529 | |
| 2530 | /*------------------------------------------------------------------*/ |
| 2531 | /* Private handler : get firemware version */ |
| 2532 | static int ks_wlan_get_firmware_version(struct net_device *dev, struct iw_request_info *info, |
| 2533 | struct iw_point *dwrq, char *extra) |
| 2534 | { |
| 2535 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2536 | strcpy(extra, &(priv->firmware_version[0])); |
| 2537 | dwrq->length = priv->version_size+1; |
| 2538 | return 0; |
| 2539 | } |
| 2540 | |
| 2541 | #if 0 |
| 2542 | /*------------------------------------------------------------------*/ |
| 2543 | /* Private handler : set force disconnect status */ |
| 2544 | static int ks_wlan_set_detach(struct net_device *dev, struct iw_request_info *info, |
| 2545 | __u32 *uwrq, char *extra) |
| 2546 | { |
| 2547 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 2548 | |
| 2549 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2550 | |
| 2551 | if(*uwrq == CONNECT_STATUS){ /* 0 */ |
| 2552 | priv->connect_status &= ~FORCE_DISCONNECT; |
| 2553 | if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) |
| 2554 | netif_carrier_on(dev); |
| 2555 | }else if(*uwrq == DISCONNECT_STATUS){ /* 1 */ |
| 2556 | priv->connect_status |= FORCE_DISCONNECT; |
| 2557 | netif_carrier_off(dev); |
| 2558 | }else |
| 2559 | return -EINVAL; |
| 2560 | return 0; |
| 2561 | } |
| 2562 | |
| 2563 | /*------------------------------------------------------------------*/ |
| 2564 | /* Private handler : get force disconnect status */ |
| 2565 | static int ks_wlan_get_detach(struct net_device *dev, struct iw_request_info *info, |
| 2566 | __u32 *uwrq, char *extra) |
| 2567 | { |
| 2568 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 2569 | |
| 2570 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2571 | |
| 2572 | *uwrq = ((priv->connect_status & FORCE_DISCONNECT) ? 1 : 0 ); |
| 2573 | return 0; |
| 2574 | } |
| 2575 | |
| 2576 | /*------------------------------------------------------------------*/ |
| 2577 | /* Private handler : get connect status */ |
| 2578 | static int ks_wlan_get_connect(struct net_device *dev, struct iw_request_info *info, |
| 2579 | __u32 *uwrq, char *extra) |
| 2580 | { |
| 2581 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 2582 | |
| 2583 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2584 | |
| 2585 | *uwrq = (priv->connect_status & CONNECT_STATUS_MASK); |
| 2586 | return 0; |
| 2587 | } |
| 2588 | #endif |
| 2589 | |
| 2590 | /*------------------------------------------------------------------*/ |
| 2591 | /* Private handler : set preamble */ |
| 2592 | static int ks_wlan_set_preamble(struct net_device *dev, struct iw_request_info *info, |
| 2593 | __u32 *uwrq, char *extra) |
| 2594 | { |
| 2595 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2596 | |
| 2597 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2598 | |
| 2599 | if(*uwrq == LONG_PREAMBLE){ /* 0 */ |
| 2600 | priv->reg.preamble = LONG_PREAMBLE; |
| 2601 | }else if(*uwrq == SHORT_PREAMBLE){ /* 1 */ |
| 2602 | priv->reg.preamble = SHORT_PREAMBLE; |
| 2603 | }else |
| 2604 | return -EINVAL; |
| 2605 | |
| 2606 | priv->need_commit |= SME_MODE_SET; |
| 2607 | return -EINPROGRESS; /* Call commit handler */ |
| 2608 | |
| 2609 | } |
| 2610 | |
| 2611 | /*------------------------------------------------------------------*/ |
| 2612 | /* Private handler : get preamble */ |
| 2613 | static int ks_wlan_get_preamble(struct net_device *dev, struct iw_request_info *info, |
| 2614 | __u32 *uwrq, char *extra) |
| 2615 | { |
| 2616 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2617 | |
| 2618 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2619 | |
| 2620 | *uwrq = priv->reg.preamble; |
| 2621 | return 0; |
| 2622 | } |
| 2623 | |
| 2624 | /*------------------------------------------------------------------*/ |
| 2625 | /* Private handler : set power save mode */ |
| 2626 | static int ks_wlan_set_powermgt(struct net_device *dev, struct iw_request_info *info, |
| 2627 | __u32 *uwrq, char *extra) |
| 2628 | { |
| 2629 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2630 | |
| 2631 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2632 | |
| 2633 | if(*uwrq == POWMGT_ACTIVE_MODE){ /* 0 */ |
| 2634 | priv->reg.powermgt = POWMGT_ACTIVE_MODE; |
| 2635 | }else if(*uwrq == POWMGT_SAVE1_MODE){ /* 1 */ |
| 2636 | if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) |
| 2637 | priv->reg.powermgt = POWMGT_SAVE1_MODE; |
| 2638 | else |
| 2639 | return -EINVAL; |
| 2640 | }else if(*uwrq == POWMGT_SAVE2_MODE){ /* 2 */ |
| 2641 | if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) |
| 2642 | priv->reg.powermgt = POWMGT_SAVE2_MODE; |
| 2643 | else |
| 2644 | return -EINVAL; |
| 2645 | }else |
| 2646 | return -EINVAL; |
| 2647 | |
| 2648 | hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); |
| 2649 | |
| 2650 | return 0; |
| 2651 | } |
| 2652 | |
| 2653 | /*------------------------------------------------------------------*/ |
| 2654 | /* Private handler : get power save made */ |
| 2655 | static int ks_wlan_get_powermgt(struct net_device *dev, struct iw_request_info *info, |
| 2656 | __u32 *uwrq, char *extra) |
| 2657 | { |
| 2658 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2659 | |
| 2660 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2661 | |
| 2662 | *uwrq = priv->reg.powermgt; |
| 2663 | return 0; |
| 2664 | } |
| 2665 | |
| 2666 | /*------------------------------------------------------------------*/ |
| 2667 | /* Private handler : set scan type */ |
| 2668 | static int ks_wlan_set_scan_type(struct net_device *dev, struct iw_request_info *info, |
| 2669 | __u32 *uwrq, char *extra) |
| 2670 | { |
| 2671 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2672 | |
| 2673 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2674 | |
| 2675 | if(*uwrq == ACTIVE_SCAN){ /* 0 */ |
| 2676 | priv->reg.scan_type = ACTIVE_SCAN; |
| 2677 | }else if(*uwrq == PASSIVE_SCAN){ /* 1 */ |
| 2678 | priv->reg.scan_type = PASSIVE_SCAN; |
| 2679 | }else |
| 2680 | return -EINVAL; |
| 2681 | |
| 2682 | return 0; |
| 2683 | } |
| 2684 | |
| 2685 | /*------------------------------------------------------------------*/ |
| 2686 | /* Private handler : get scan type */ |
| 2687 | static int ks_wlan_get_scan_type(struct net_device *dev, struct iw_request_info *info, |
| 2688 | __u32 *uwrq, char *extra) |
| 2689 | { |
| 2690 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2691 | |
| 2692 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2693 | |
| 2694 | *uwrq = priv->reg.scan_type; |
| 2695 | return 0; |
| 2696 | } |
| 2697 | #if 0 |
| 2698 | /*------------------------------------------------------------------*/ |
| 2699 | /* Private handler : write raw data to device */ |
| 2700 | static int ks_wlan_data_write(struct net_device *dev, struct iw_request_info *info, |
| 2701 | struct iw_point *dwrq, char *extra) |
| 2702 | { |
| 2703 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 2704 | unsigned char *wbuff = NULL; |
| 2705 | |
| 2706 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2707 | |
| 2708 | wbuff = (unsigned char *)kmalloc(dwrq->length, GFP_ATOMIC); |
| 2709 | if(!wbuff) |
| 2710 | return -EFAULT; |
| 2711 | memcpy(wbuff, extra, dwrq->length); |
| 2712 | |
| 2713 | /* write to device */ |
| 2714 | ks_wlan_hw_tx( priv, wbuff, dwrq->length, NULL, NULL, NULL); |
| 2715 | |
| 2716 | return 0; |
| 2717 | } |
| 2718 | |
| 2719 | /*------------------------------------------------------------------*/ |
| 2720 | /* Private handler : read raw data form device */ |
| 2721 | static int ks_wlan_data_read(struct net_device *dev, struct iw_request_info *info, |
| 2722 | struct iw_point *dwrq, char *extra) |
| 2723 | { |
| 2724 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 2725 | unsigned short read_length; |
| 2726 | |
| 2727 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2728 | |
| 2729 | if(!atomic_read(&priv->event_count)){ |
| 2730 | if (priv->dev_state < DEVICE_STATE_BOOT) { /* Remove device */ |
| 2731 | read_length = 4; |
| 2732 | memset(extra,0xff,read_length); |
| 2733 | dwrq->length = read_length; |
| 2734 | return 0; |
| 2735 | } |
| 2736 | read_length = 0; |
| 2737 | memset(extra,0,1); |
| 2738 | dwrq->length = 0; |
| 2739 | return 0; |
| 2740 | } |
| 2741 | |
| 2742 | if(atomic_read(&priv->event_count)>0) |
| 2743 | atomic_dec(&priv->event_count); |
| 2744 | |
| 2745 | spin_lock(&priv->dev_read_lock); /* request spin lock */ |
| 2746 | |
| 2747 | /* Copy length max size 0x07ff */ |
| 2748 | if(priv->dev_size[priv->dev_count] > 2047) |
| 2749 | read_length = 2047; |
| 2750 | else |
| 2751 | read_length = priv->dev_size[priv->dev_count]; |
| 2752 | |
| 2753 | /* Copy data */ |
| 2754 | memcpy(extra, &(priv->dev_data[priv->dev_count][0]), read_length); |
| 2755 | |
| 2756 | spin_unlock(&priv->dev_read_lock); /* release spin lock */ |
| 2757 | |
| 2758 | /* Initialize */ |
| 2759 | priv->dev_data[priv->dev_count] = 0; |
| 2760 | priv->dev_size[priv->dev_count] = 0; |
| 2761 | |
| 2762 | priv->dev_count++; |
| 2763 | if(priv->dev_count == DEVICE_STOCK_COUNT) |
| 2764 | priv->dev_count=0; |
| 2765 | |
| 2766 | /* Set read size */ |
| 2767 | dwrq->length = read_length; |
| 2768 | |
| 2769 | return 0; |
| 2770 | } |
| 2771 | #endif |
| 2772 | |
| 2773 | #if 0 |
| 2774 | /*------------------------------------------------------------------*/ |
| 2775 | /* Private handler : get wep string */ |
| 2776 | #define WEP_ASCII_BUFF_SIZE (17+64*4+1) |
| 2777 | static int ks_wlan_get_wep_ascii(struct net_device *dev, struct iw_request_info *info, |
| 2778 | struct iw_point *dwrq, char *extra) |
| 2779 | { |
| 2780 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 2781 | int i,j,len=0; |
| 2782 | char tmp[WEP_ASCII_BUFF_SIZE]; |
| 2783 | |
| 2784 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2785 | |
| 2786 | strcpy(tmp," WEP keys ASCII \n"); |
| 2787 | len+=strlen(" WEP keys ASCII \n"); |
| 2788 | |
| 2789 | for(i=0;i<4;i++){ |
| 2790 | strcpy(tmp+len,"\t["); |
| 2791 | len+=strlen("\t["); |
| 2792 | tmp[len] = '1'+i; |
| 2793 | len++; |
| 2794 | strcpy(tmp+len,"] "); |
| 2795 | len+=strlen("] "); |
| 2796 | if(priv->reg.wep_key[i].size){ |
| 2797 | strcpy(tmp+len,(priv->reg.wep_key[i].size < 6 ? "(40bits) [" : "(104bits) [")); |
| 2798 | len+=strlen((priv->reg.wep_key[i].size < 6 ? "(40bits) [" : "(104bits) [")); |
| 2799 | for(j=0;j<priv->reg.wep_key[i].size;j++,len++) |
| 2800 | tmp[len]=(isprint(priv->reg.wep_key[i].val[j]) ? priv->reg.wep_key[i].val[j] : ' '); |
| 2801 | |
| 2802 | strcpy(tmp+len,"]\n"); |
| 2803 | len+=strlen("]\n"); |
| 2804 | } |
| 2805 | else{ |
| 2806 | strcpy(tmp+len,"off\n"); |
| 2807 | len+=strlen("off\n"); |
| 2808 | } |
| 2809 | } |
| 2810 | |
| 2811 | memcpy(extra, tmp, len); |
| 2812 | dwrq->length = len+1; |
| 2813 | return 0; |
| 2814 | } |
| 2815 | #endif |
| 2816 | |
| 2817 | /*------------------------------------------------------------------*/ |
| 2818 | /* Private handler : set beacon lost count */ |
| 2819 | static int ks_wlan_set_beacon_lost(struct net_device *dev, struct iw_request_info *info, |
| 2820 | __u32 *uwrq, char *extra) |
| 2821 | { |
| 2822 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2823 | |
| 2824 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2825 | |
| 2826 | if(*uwrq >= BEACON_LOST_COUNT_MIN && |
| 2827 | *uwrq <= BEACON_LOST_COUNT_MAX){ |
| 2828 | priv->reg.beacon_lost_count = *uwrq; |
| 2829 | }else |
| 2830 | return -EINVAL; |
| 2831 | |
| 2832 | if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ |
| 2833 | priv->need_commit |= SME_MODE_SET; |
| 2834 | return -EINPROGRESS; /* Call commit handler */ |
| 2835 | } |
| 2836 | else |
| 2837 | return 0; |
| 2838 | } |
| 2839 | |
| 2840 | /*------------------------------------------------------------------*/ |
| 2841 | /* Private handler : get beacon lost count */ |
| 2842 | static int ks_wlan_get_beacon_lost(struct net_device *dev, struct iw_request_info *info, |
| 2843 | __u32 *uwrq, char *extra) |
| 2844 | { |
| 2845 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2846 | |
| 2847 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2848 | |
| 2849 | *uwrq = priv->reg.beacon_lost_count; |
| 2850 | return 0; |
| 2851 | } |
| 2852 | |
| 2853 | /*------------------------------------------------------------------*/ |
| 2854 | /* Private handler : set phy type */ |
| 2855 | static int ks_wlan_set_phy_type(struct net_device *dev, struct iw_request_info *info, |
| 2856 | __u32 *uwrq, char *extra) |
| 2857 | { |
| 2858 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2859 | |
| 2860 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2861 | |
| 2862 | if(*uwrq == D_11B_ONLY_MODE){ /* 0 */ |
| 2863 | priv->reg.phy_type = D_11B_ONLY_MODE; |
| 2864 | }else if(*uwrq == D_11G_ONLY_MODE){ /* 1 */ |
| 2865 | priv->reg.phy_type = D_11G_ONLY_MODE; |
| 2866 | }else if(*uwrq == D_11BG_COMPATIBLE_MODE){ /* 2 */ |
| 2867 | priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; |
| 2868 | }else |
| 2869 | return -EINVAL; |
| 2870 | |
| 2871 | priv->need_commit |= SME_MODE_SET; |
| 2872 | return -EINPROGRESS; /* Call commit handler */ |
| 2873 | } |
| 2874 | |
| 2875 | /*------------------------------------------------------------------*/ |
| 2876 | /* Private handler : get phy type */ |
| 2877 | static int ks_wlan_get_phy_type(struct net_device *dev, struct iw_request_info *info, |
| 2878 | __u32 *uwrq, char *extra) |
| 2879 | { |
| 2880 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2881 | |
| 2882 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2883 | |
| 2884 | *uwrq = priv->reg.phy_type; |
| 2885 | return 0; |
| 2886 | } |
| 2887 | |
| 2888 | /*------------------------------------------------------------------*/ |
| 2889 | /* Private handler : set cts mode */ |
| 2890 | static int ks_wlan_set_cts_mode(struct net_device *dev, struct iw_request_info *info, |
| 2891 | __u32 *uwrq, char *extra) |
| 2892 | { |
| 2893 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2894 | |
| 2895 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2896 | |
| 2897 | if(*uwrq == CTS_MODE_FALSE){ /* 0 */ |
| 2898 | priv->reg.cts_mode = CTS_MODE_FALSE; |
| 2899 | }else if(*uwrq == CTS_MODE_TRUE){ /* 1 */ |
| 2900 | if(priv->reg.phy_type == D_11G_ONLY_MODE || |
| 2901 | priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) |
| 2902 | priv->reg.cts_mode = CTS_MODE_TRUE; |
| 2903 | else |
| 2904 | priv->reg.cts_mode = CTS_MODE_FALSE; |
| 2905 | }else |
| 2906 | return -EINVAL; |
| 2907 | |
| 2908 | priv->need_commit |= SME_MODE_SET; |
| 2909 | return -EINPROGRESS; /* Call commit handler */ |
| 2910 | } |
| 2911 | |
| 2912 | /*------------------------------------------------------------------*/ |
| 2913 | /* Private handler : get cts mode */ |
| 2914 | static int ks_wlan_get_cts_mode(struct net_device *dev, struct iw_request_info *info, |
| 2915 | __u32 *uwrq, char *extra) |
| 2916 | { |
| 2917 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2918 | |
| 2919 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2920 | |
| 2921 | *uwrq = priv->reg.cts_mode; |
| 2922 | return 0; |
| 2923 | } |
| 2924 | |
| 2925 | /*------------------------------------------------------------------*/ |
| 2926 | /* Private handler : set sleep mode */ |
| 2927 | static int ks_wlan_set_sleep_mode(struct net_device *dev, |
| 2928 | struct iw_request_info *info, |
| 2929 | __u32 *uwrq, char *extra) |
| 2930 | { |
| 2931 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2932 | |
| 2933 | DPRINTK(2,"\n"); |
| 2934 | |
| 2935 | if(*uwrq == SLP_SLEEP){ |
| 2936 | priv->sleep_mode = *uwrq; |
| 2937 | printk("SET_SLEEP_MODE %d\n", priv->sleep_mode); |
| 2938 | |
| 2939 | hostif_sme_enqueue(priv, SME_STOP_REQUEST); |
| 2940 | hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); |
| 2941 | |
| 2942 | }else if(*uwrq == SLP_ACTIVE) { |
| 2943 | priv->sleep_mode = *uwrq; |
| 2944 | printk("SET_SLEEP_MODE %d\n", priv->sleep_mode); |
| 2945 | hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); |
| 2946 | }else{ |
| 2947 | printk("SET_SLEEP_MODE %d errror\n", *uwrq); |
| 2948 | return -EINVAL; |
| 2949 | } |
| 2950 | |
| 2951 | return 0; |
| 2952 | } |
| 2953 | /*------------------------------------------------------------------*/ |
| 2954 | /* Private handler : get sleep mode */ |
| 2955 | static int ks_wlan_get_sleep_mode(struct net_device *dev, |
| 2956 | struct iw_request_info *info, |
| 2957 | __u32 *uwrq, char *extra) |
| 2958 | { |
| 2959 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 2960 | |
| 2961 | DPRINTK(2, "GET_SLEEP_MODE %d\n", priv->sleep_mode); |
| 2962 | *uwrq = priv->sleep_mode; |
| 2963 | |
| 2964 | return 0; |
| 2965 | } |
| 2966 | |
| 2967 | #if 0 |
| 2968 | /*------------------------------------------------------------------*/ |
| 2969 | /* Private handler : set phy information timer */ |
| 2970 | static int ks_wlan_set_phy_information_timer(struct net_device *dev, struct iw_request_info *info, |
| 2971 | __u32 *uwrq, char *extra) |
| 2972 | { |
| 2973 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 2974 | |
| 2975 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2976 | |
| 2977 | if(*uwrq >= 0 && *uwrq <= 0xFFFF) /* 0-65535 */ |
| 2978 | priv->reg.phy_info_timer = (uint16_t)*uwrq; |
| 2979 | else |
| 2980 | return -EINVAL; |
| 2981 | |
| 2982 | hostif_sme_enqueue(priv, SME_PHY_INFO_REQUEST); |
| 2983 | |
| 2984 | return 0; |
| 2985 | } |
| 2986 | |
| 2987 | /*------------------------------------------------------------------*/ |
| 2988 | /* Private handler : get phy information timer */ |
| 2989 | static int ks_wlan_get_phy_information_timer(struct net_device *dev, struct iw_request_info *info, |
| 2990 | __u32 *uwrq, char *extra) |
| 2991 | { |
| 2992 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 2993 | |
| 2994 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 2995 | |
| 2996 | *uwrq = priv->reg.phy_info_timer; |
| 2997 | return 0; |
| 2998 | } |
| 2999 | #endif |
| 3000 | |
| 3001 | #ifdef WPS |
| 3002 | /*------------------------------------------------------------------*/ |
| 3003 | /* Private handler : set WPS enable */ |
| 3004 | static int ks_wlan_set_wps_enable(struct net_device *dev, struct iw_request_info *info, |
| 3005 | __u32 *uwrq, char *extra) |
| 3006 | { |
| 3007 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 3008 | DPRINTK(2,"\n"); |
| 3009 | |
| 3010 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 3011 | |
| 3012 | if(*uwrq == 0 || *uwrq == 1) |
| 3013 | priv->wps.wps_enabled = *uwrq; |
| 3014 | else |
| 3015 | return -EINVAL; |
| 3016 | |
| 3017 | hostif_sme_enqueue(priv, SME_WPS_ENABLE_REQUEST); |
| 3018 | |
| 3019 | return 0; |
| 3020 | } |
| 3021 | /*------------------------------------------------------------------*/ |
| 3022 | /* Private handler : get WPS enable */ |
| 3023 | static int ks_wlan_get_wps_enable(struct net_device *dev, struct iw_request_info *info, |
| 3024 | __u32 *uwrq, char *extra) |
| 3025 | { |
| 3026 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 3027 | DPRINTK(2,"\n"); |
| 3028 | |
| 3029 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 3030 | |
| 3031 | *uwrq = priv->wps.wps_enabled; |
| 3032 | printk("return=%d\n", *uwrq); |
| 3033 | |
| 3034 | return 0; |
| 3035 | } |
| 3036 | /*------------------------------------------------------------------*/ |
| 3037 | /* Private handler : set WPS probe req */ |
| 3038 | static int ks_wlan_set_wps_probe_req(struct net_device *dev, |
| 3039 | struct iw_request_info *info, |
| 3040 | struct iw_point *dwrq, char *extra) |
| 3041 | { |
| 3042 | uint8_t *p = extra; |
| 3043 | unsigned char len; |
| 3044 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 3045 | |
| 3046 | DPRINTK(2,"\n"); |
| 3047 | |
| 3048 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 3049 | |
| 3050 | DPRINTK(2,"dwrq->length=%d\n", dwrq->length); |
| 3051 | |
| 3052 | /* length check */ |
| 3053 | if(p[1] + 2 != dwrq->length || dwrq->length > 256 ){ |
| 3054 | return -EINVAL; |
| 3055 | } |
| 3056 | |
| 3057 | priv->wps.ielen = p[1] + 2 + 1; /* IE header + IE + sizeof(len) */ |
| 3058 | len = p[1] + 2; /* IE header + IE */ |
| 3059 | |
| 3060 | memcpy(priv->wps.ie, &len, sizeof(len)); |
| 3061 | p = memcpy(priv->wps.ie+1, p, len); |
| 3062 | |
| 3063 | DPRINTK(2,"%d(%#x): %02X %02X %02X %02X ... %02X %02X %02X\n", |
| 3064 | priv->wps.ielen, priv->wps.ielen, p[0], p[1], p[2], p[3], |
| 3065 | p[priv->wps.ielen-3], p[priv->wps.ielen-2], p[priv->wps.ielen-1]); |
| 3066 | |
| 3067 | hostif_sme_enqueue(priv, SME_WPS_PROBE_REQUEST); |
| 3068 | |
| 3069 | return 0; |
| 3070 | } |
| 3071 | #if 0 |
| 3072 | /*------------------------------------------------------------------*/ |
| 3073 | /* Private handler : get WPS probe req */ |
| 3074 | static int ks_wlan_get_wps_probe_req(struct net_device *dev, |
| 3075 | struct iw_request_info *info, |
| 3076 | __u32 *uwrq, char *extra) |
| 3077 | { |
| 3078 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 3079 | DPRINTK(2,"\n"); |
| 3080 | |
| 3081 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 3082 | |
| 3083 | return 0; |
| 3084 | } |
| 3085 | #endif |
| 3086 | #endif /* WPS */ |
| 3087 | |
| 3088 | /*------------------------------------------------------------------*/ |
| 3089 | /* Private handler : set tx gain control value */ |
| 3090 | static int ks_wlan_set_tx_gain(struct net_device *dev, struct iw_request_info *info, |
| 3091 | __u32 *uwrq, char *extra) |
| 3092 | { |
| 3093 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 3094 | |
| 3095 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 3096 | |
| 3097 | if(*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ |
| 3098 | priv->gain.TxGain = (uint8_t)*uwrq; |
| 3099 | else |
| 3100 | return -EINVAL; |
| 3101 | |
| 3102 | if(priv->gain.TxGain < 0xFF) |
| 3103 | priv->gain.TxMode = 1; |
| 3104 | else |
| 3105 | priv->gain.TxMode = 0; |
| 3106 | |
| 3107 | |
| 3108 | hostif_sme_enqueue(priv, SME_SET_GAIN); |
| 3109 | return 0; |
| 3110 | } |
| 3111 | |
| 3112 | /*------------------------------------------------------------------*/ |
| 3113 | /* Private handler : get tx gain control value */ |
| 3114 | static int ks_wlan_get_tx_gain(struct net_device *dev, struct iw_request_info *info, |
| 3115 | __u32 *uwrq, char *extra) |
| 3116 | { |
| 3117 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 3118 | |
| 3119 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 3120 | |
| 3121 | *uwrq = priv->gain.TxGain; |
| 3122 | hostif_sme_enqueue(priv, SME_GET_GAIN); |
| 3123 | return 0; |
| 3124 | } |
| 3125 | |
| 3126 | /*------------------------------------------------------------------*/ |
| 3127 | /* Private handler : set rx gain control value */ |
| 3128 | static int ks_wlan_set_rx_gain(struct net_device *dev, struct iw_request_info *info, |
| 3129 | __u32 *uwrq, char *extra) |
| 3130 | { |
| 3131 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 3132 | |
| 3133 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 3134 | |
| 3135 | if(*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ |
| 3136 | priv->gain.RxGain = (uint8_t)*uwrq; |
| 3137 | else |
| 3138 | return -EINVAL; |
| 3139 | |
| 3140 | if(priv->gain.RxGain < 0xFF) |
| 3141 | priv->gain.RxMode = 1; |
| 3142 | else |
| 3143 | priv->gain.RxMode = 0; |
| 3144 | |
| 3145 | hostif_sme_enqueue(priv, SME_SET_GAIN); |
| 3146 | return 0; |
| 3147 | } |
| 3148 | |
| 3149 | /*------------------------------------------------------------------*/ |
| 3150 | /* Private handler : get rx gain control value */ |
| 3151 | static int ks_wlan_get_rx_gain(struct net_device *dev, struct iw_request_info *info, |
| 3152 | __u32 *uwrq, char *extra) |
| 3153 | { |
| 3154 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 3155 | |
| 3156 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 3157 | |
| 3158 | *uwrq = priv->gain.RxGain; |
| 3159 | hostif_sme_enqueue(priv, SME_GET_GAIN); |
| 3160 | return 0; |
| 3161 | } |
| 3162 | #if 0 |
| 3163 | /*------------------------------------------------------------------*/ |
| 3164 | /* Private handler : set region value */ |
| 3165 | static int ks_wlan_set_region(struct net_device *dev, struct iw_request_info *info, |
| 3166 | __u32 *uwrq, char *extra) |
| 3167 | { |
| 3168 | ks_wlan_private *priv = (ks_wlan_private *)dev->priv; |
| 3169 | |
| 3170 | if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ |
| 3171 | |
| 3172 | if(*uwrq >= 0x9 && *uwrq <= 0xF) /* 0x9-0xf */ |
| 3173 | priv->region = (uint8_t)*uwrq; |
| 3174 | else |
| 3175 | return -EINVAL; |
| 3176 | |
| 3177 | hostif_sme_enqueue(priv, SME_SET_REGION); |
| 3178 | return 0; |
| 3179 | } |
| 3180 | #endif |
| 3181 | |
| 3182 | /*------------------------------------------------------------------*/ |
| 3183 | /* Private handler : get eeprom checksum result */ |
| 3184 | static int ks_wlan_get_eeprom_cksum(struct net_device *dev, struct iw_request_info *info, |
| 3185 | __u32 *uwrq, char *extra) |
| 3186 | { |
| 3187 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 3188 | |
| 3189 | *uwrq = priv->eeprom_checksum; |
| 3190 | return 0; |
| 3191 | } |
| 3192 | |
| 3193 | static void print_hif_event(int event){ |
| 3194 | |
| 3195 | switch(event){ |
| 3196 | case HIF_DATA_REQ : |
| 3197 | printk("HIF_DATA_REQ\n"); |
| 3198 | break; |
| 3199 | case HIF_DATA_IND : |
| 3200 | printk("HIF_DATA_IND\n"); |
| 3201 | break; |
| 3202 | case HIF_MIB_GET_REQ : |
| 3203 | printk("HIF_MIB_GET_REQ\n"); |
| 3204 | break; |
| 3205 | case HIF_MIB_GET_CONF : |
| 3206 | printk("HIF_MIB_GET_CONF\n"); |
| 3207 | break; |
| 3208 | case HIF_MIB_SET_REQ : |
| 3209 | printk("HIF_MIB_SET_REQ\n"); |
| 3210 | break; |
| 3211 | case HIF_MIB_SET_CONF : |
| 3212 | printk("HIF_MIB_SET_CONF\n"); |
| 3213 | break; |
| 3214 | case HIF_POWERMGT_REQ : |
| 3215 | printk("HIF_POWERMGT_REQ\n"); |
| 3216 | break; |
| 3217 | case HIF_POWERMGT_CONF : |
| 3218 | printk("HIF_POWERMGT_CONF\n"); |
| 3219 | break; |
| 3220 | case HIF_START_REQ : |
| 3221 | printk("HIF_START_REQ\n"); |
| 3222 | break; |
| 3223 | case HIF_START_CONF : |
| 3224 | printk("HIF_START_CONF\n"); |
| 3225 | break; |
| 3226 | case HIF_CONNECT_IND : |
| 3227 | printk("HIF_CONNECT_IND\n"); |
| 3228 | break; |
| 3229 | case HIF_STOP_REQ : |
| 3230 | printk("HIF_STOP_REQ\n"); |
| 3231 | break; |
| 3232 | case HIF_STOP_CONF : |
| 3233 | printk("HIF_STOP_CONF\n"); |
| 3234 | break; |
| 3235 | case HIF_PS_ADH_SET_REQ : |
| 3236 | printk("HIF_PS_ADH_SET_REQ\n"); |
| 3237 | break; |
| 3238 | case HIF_PS_ADH_SET_CONF: |
| 3239 | printk("HIF_PS_ADH_SET_CONF\n"); |
| 3240 | break; |
| 3241 | case HIF_INFRA_SET_REQ : |
| 3242 | printk("HIF_INFRA_SET_REQ\n"); |
| 3243 | break; |
| 3244 | case HIF_INFRA_SET_CONF : |
| 3245 | printk("HIF_INFRA_SET_CONF\n"); |
| 3246 | break; |
| 3247 | case HIF_ADH_SET_REQ : |
| 3248 | printk("HIF_ADH_SET_REQ\n"); |
| 3249 | break; |
| 3250 | case HIF_ADH_SET_CONF : |
| 3251 | printk("HIF_ADH_SET_CONF\n"); |
| 3252 | break; |
| 3253 | case HIF_AP_SET_REQ : |
| 3254 | printk("HIF_AP_SET_REQ\n"); |
| 3255 | break; |
| 3256 | case HIF_AP_SET_CONF : |
| 3257 | printk("HIF_AP_SET_CONF\n"); |
| 3258 | break; |
| 3259 | case HIF_ASSOC_INFO_IND : |
| 3260 | printk("HIF_ASSOC_INFO_IND\n"); |
| 3261 | break; |
| 3262 | case HIF_MIC_FAILURE_REQ: |
| 3263 | printk("HIF_MIC_FAILURE_REQ\n"); |
| 3264 | break; |
| 3265 | case HIF_MIC_FAILURE_CONF : |
| 3266 | printk("HIF_MIC_FAILURE_CONF\n"); |
| 3267 | break; |
| 3268 | case HIF_SCAN_REQ : |
| 3269 | printk("HIF_SCAN_REQ\n"); |
| 3270 | break; |
| 3271 | case HIF_SCAN_CONF : |
| 3272 | printk("HIF_SCAN_CONF\n"); |
| 3273 | break; |
| 3274 | case HIF_PHY_INFO_REQ : |
| 3275 | printk("HIF_PHY_INFO_REQ\n"); |
| 3276 | break; |
| 3277 | case HIF_PHY_INFO_CONF : |
| 3278 | printk("HIF_PHY_INFO_CONF\n"); |
| 3279 | break; |
| 3280 | case HIF_SLEEP_REQ : |
| 3281 | printk("HIF_SLEEP_REQ\n"); |
| 3282 | break; |
| 3283 | case HIF_SLEEP_CONF : |
| 3284 | printk("HIF_SLEEP_CONF\n"); |
| 3285 | break; |
| 3286 | case HIF_PHY_INFO_IND : |
| 3287 | printk("HIF_PHY_INFO_IND\n"); |
| 3288 | break; |
| 3289 | case HIF_SCAN_IND : |
| 3290 | printk("HIF_SCAN_IND\n"); |
| 3291 | break; |
| 3292 | case HIF_INFRA_SET2_REQ : |
| 3293 | printk("HIF_INFRA_SET2_REQ\n"); |
| 3294 | break; |
| 3295 | case HIF_INFRA_SET2_CONF: |
| 3296 | printk("HIF_INFRA_SET2_CONF\n"); |
| 3297 | break; |
| 3298 | case HIF_ADH_SET2_REQ : |
| 3299 | printk("HIF_ADH_SET2_REQ\n"); |
| 3300 | break; |
| 3301 | case HIF_ADH_SET2_CONF : |
| 3302 | printk("HIF_ADH_SET2_CONF\n"); |
| 3303 | } |
| 3304 | } |
| 3305 | |
| 3306 | /*------------------------------------------------------------------*/ |
| 3307 | /* Private handler : get host command history */ |
| 3308 | static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info, |
| 3309 | __u32 *uwrq, char *extra) |
| 3310 | { |
| 3311 | int i,event; |
| 3312 | ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); |
| 3313 | |
| 3314 | for(i = 63; i >= 0; i--){ |
| 3315 | event = priv->hostt.buff[(priv->hostt.qtail -1 -i)%SME_EVENT_BUFF_SIZE] ; |
| 3316 | print_hif_event(event); |
| 3317 | } |
| 3318 | return 0; |
| 3319 | } |
| 3320 | |
| 3321 | /* Structures to export the Wireless Handlers */ |
| 3322 | |
| 3323 | static const struct iw_priv_args ks_wlan_private_args[] = { |
| 3324 | /*{ cmd, set_args, get_args, name[16] } */ |
| 3325 | { KS_WLAN_GET_DRIVER_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "GetDriverVer" }, |
| 3326 | { KS_WLAN_GET_FIRM_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "GetFirmwareVer" }, |
| 3327 | #ifdef WPS |
| 3328 | { KS_WLAN_SET_WPS_ENABLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetWPSEnable" }, |
| 3329 | { KS_WLAN_GET_WPS_ENABLE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetW" }, |
| 3330 | { KS_WLAN_SET_WPS_PROBE_REQ, IW_PRIV_TYPE_BYTE | 2047, IW_PRIV_TYPE_NONE, "SetWPSProbeReq" }, |
| 3331 | #endif /* WPS */ |
| 3332 | { KS_WLAN_SET_PREAMBLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPreamble" }, |
| 3333 | { KS_WLAN_GET_PREAMBLE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPreamble" }, |
| 3334 | { KS_WLAN_SET_POWER_SAVE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPowerSave" }, |
| 3335 | { KS_WLAN_GET_POWER_SAVE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPowerSave" }, |
| 3336 | { KS_WLAN_SET_SCAN_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetScanType" }, |
| 3337 | { KS_WLAN_GET_SCAN_TYPE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetScanType" }, |
| 3338 | { KS_WLAN_SET_RX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetRxGain" }, |
| 3339 | { KS_WLAN_GET_RX_GAIN, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetRxGain" }, |
| 3340 | { KS_WLAN_HOSTT, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "hostt" }, |
| 3341 | { KS_WLAN_SET_BEACON_LOST, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetBeaconLost" }, |
| 3342 | { KS_WLAN_GET_BEACON_LOST, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetBeaconLost" }, |
| 3343 | { KS_WLAN_SET_SLEEP_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetSleepMode" }, |
| 3344 | { KS_WLAN_GET_SLEEP_MODE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetSleepMode" }, |
| 3345 | { KS_WLAN_SET_TX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetTxGain" }, |
| 3346 | { KS_WLAN_GET_TX_GAIN, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetTxGain" }, |
| 3347 | { KS_WLAN_SET_PHY_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPhyType" }, |
| 3348 | { KS_WLAN_GET_PHY_TYPE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPhyType" }, |
| 3349 | { KS_WLAN_SET_CTS_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetCtsMode" }, |
| 3350 | { KS_WLAN_GET_CTS_MODE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetCtsMode" }, |
| 3351 | { KS_WLAN_GET_EEPROM_CKSUM, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetChecksum" }, |
| 3352 | }; |
| 3353 | static const iw_handler ks_wlan_handler[] = |
| 3354 | { |
| 3355 | (iw_handler) ks_wlan_config_commit, /* SIOCSIWCOMMIT */ |
| 3356 | (iw_handler) ks_wlan_get_name, /* SIOCGIWNAME */ |
| 3357 | (iw_handler) NULL, /* SIOCSIWNWID */ |
| 3358 | (iw_handler) NULL, /* SIOCGIWNWID */ |
| 3359 | (iw_handler) ks_wlan_set_freq, /* SIOCSIWFREQ */ |
| 3360 | (iw_handler) ks_wlan_get_freq, /* SIOCGIWFREQ */ |
| 3361 | (iw_handler) ks_wlan_set_mode, /* SIOCSIWMODE */ |
| 3362 | (iw_handler) ks_wlan_get_mode, /* SIOCGIWMODE */ |
| 3363 | #ifndef KSC_OPNOTSUPP |
| 3364 | (iw_handler) ks_wlan_set_sens, /* SIOCSIWSENS */ |
| 3365 | (iw_handler) ks_wlan_get_sens, /* SIOCGIWSENS */ |
| 3366 | #else /* KSC_OPNOTSUPP */ |
| 3367 | (iw_handler) NULL, /* SIOCSIWSENS */ |
| 3368 | (iw_handler) NULL, /* SIOCGIWSENS */ |
| 3369 | #endif /* KSC_OPNOTSUPP */ |
| 3370 | (iw_handler) NULL, /* SIOCSIWRANGE */ |
| 3371 | (iw_handler) ks_wlan_get_range, /* SIOCGIWRANGE */ |
| 3372 | (iw_handler) NULL, /* SIOCSIWPRIV */ |
| 3373 | (iw_handler) NULL, /* SIOCGIWPRIV */ |
| 3374 | (iw_handler) NULL, /* SIOCSIWSTATS */ |
| 3375 | (iw_handler) ks_wlan_get_iwstats, /* SIOCGIWSTATS */ |
| 3376 | (iw_handler) NULL, /* SIOCSIWSPY */ |
| 3377 | (iw_handler) NULL, /* SIOCGIWSPY */ |
| 3378 | (iw_handler) NULL, /* SIOCSIWTHRSPY */ |
| 3379 | (iw_handler) NULL, /* SIOCGIWTHRSPY */ |
| 3380 | (iw_handler) ks_wlan_set_wap, /* SIOCSIWAP */ |
| 3381 | (iw_handler) ks_wlan_get_wap, /* SIOCGIWAP */ |
| 3382 | // (iw_handler) NULL, /* SIOCSIWMLME */ |
| 3383 | (iw_handler) ks_wlan_set_mlme, /* SIOCSIWMLME */ |
| 3384 | (iw_handler) ks_wlan_get_aplist, /* SIOCGIWAPLIST */ |
| 3385 | (iw_handler) ks_wlan_set_scan, /* SIOCSIWSCAN */ |
| 3386 | (iw_handler) ks_wlan_get_scan, /* SIOCGIWSCAN */ |
| 3387 | (iw_handler) ks_wlan_set_essid, /* SIOCSIWESSID */ |
| 3388 | (iw_handler) ks_wlan_get_essid, /* SIOCGIWESSID */ |
| 3389 | (iw_handler) ks_wlan_set_nick, /* SIOCSIWNICKN */ |
| 3390 | (iw_handler) ks_wlan_get_nick, /* SIOCGIWNICKN */ |
| 3391 | (iw_handler) NULL, /* -- hole -- */ |
| 3392 | (iw_handler) NULL, /* -- hole -- */ |
| 3393 | (iw_handler) ks_wlan_set_rate, /* SIOCSIWRATE */ |
| 3394 | (iw_handler) ks_wlan_get_rate, /* SIOCGIWRATE */ |
| 3395 | (iw_handler) ks_wlan_set_rts, /* SIOCSIWRTS */ |
| 3396 | (iw_handler) ks_wlan_get_rts, /* SIOCGIWRTS */ |
| 3397 | (iw_handler) ks_wlan_set_frag, /* SIOCSIWFRAG */ |
| 3398 | (iw_handler) ks_wlan_get_frag, /* SIOCGIWFRAG */ |
| 3399 | #ifndef KSC_OPNOTSUPP |
| 3400 | (iw_handler) ks_wlan_set_txpow, /* SIOCSIWTXPOW */ |
| 3401 | (iw_handler) ks_wlan_get_txpow, /* SIOCGIWTXPOW */ |
| 3402 | (iw_handler) ks_wlan_set_retry, /* SIOCSIWRETRY */ |
| 3403 | (iw_handler) ks_wlan_get_retry, /* SIOCGIWRETRY */ |
| 3404 | #else /* KSC_OPNOTSUPP */ |
| 3405 | (iw_handler) NULL, /* SIOCSIWTXPOW */ |
| 3406 | (iw_handler) NULL, /* SIOCGIWTXPOW */ |
| 3407 | (iw_handler) NULL, /* SIOCSIWRETRY */ |
| 3408 | (iw_handler) NULL, /* SIOCGIWRETRY */ |
| 3409 | #endif /* KSC_OPNOTSUPP */ |
| 3410 | (iw_handler) ks_wlan_set_encode, /* SIOCSIWENCODE */ |
| 3411 | (iw_handler) ks_wlan_get_encode, /* SIOCGIWENCODE */ |
| 3412 | (iw_handler) ks_wlan_set_power, /* SIOCSIWPOWER */ |
| 3413 | (iw_handler) ks_wlan_get_power, /* SIOCGIWPOWER */ |
| 3414 | (iw_handler) NULL, /* -- hole -- */ |
| 3415 | (iw_handler) NULL, /* -- hole -- */ |
| 3416 | // (iw_handler) NULL, /* SIOCSIWGENIE */ |
| 3417 | (iw_handler) ks_wlan_set_genie, /* SIOCSIWGENIE */ |
| 3418 | (iw_handler) NULL, /* SIOCGIWGENIE */ |
| 3419 | (iw_handler) ks_wlan_set_auth_mode, /* SIOCSIWAUTH */ |
| 3420 | (iw_handler) ks_wlan_get_auth_mode, /* SIOCGIWAUTH */ |
| 3421 | (iw_handler) ks_wlan_set_encode_ext, /* SIOCSIWENCODEEXT */ |
| 3422 | (iw_handler) ks_wlan_get_encode_ext, /* SIOCGIWENCODEEXT */ |
| 3423 | (iw_handler) ks_wlan_set_pmksa, /* SIOCSIWPMKSA */ |
| 3424 | (iw_handler) NULL, /* -- hole -- */ |
| 3425 | }; |
| 3426 | |
| 3427 | /* private_handler */ |
| 3428 | static const iw_handler ks_wlan_private_handler[] = |
| 3429 | { |
| 3430 | (iw_handler) NULL, /* 0 */ |
| 3431 | (iw_handler) ks_wlan_get_driver_version, /* 1 KS_WLAN_GET_DRIVER_VERSION */ |
| 3432 | (iw_handler) NULL, /* 2 */ |
| 3433 | (iw_handler) ks_wlan_get_firmware_version, /* 3 KS_WLAN_GET_FIRM_VERSION */ |
| 3434 | #ifdef WPS |
| 3435 | (iw_handler) ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */ |
| 3436 | (iw_handler) ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */ |
| 3437 | (iw_handler) ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */ |
| 3438 | #else |
| 3439 | (iw_handler) NULL, /* 4 */ |
| 3440 | (iw_handler) NULL, /* 5 */ |
| 3441 | (iw_handler) NULL, /* 6 */ |
| 3442 | #endif /* WPS */ |
| 3443 | |
| 3444 | (iw_handler) ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */ |
| 3445 | (iw_handler) ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */ |
| 3446 | (iw_handler) ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */ |
| 3447 | (iw_handler) ks_wlan_set_powermgt, /* 10 KS_WLAN_SET_POWER_SAVE */ |
| 3448 | (iw_handler) ks_wlan_get_powermgt, /* 11 KS_WLAN_GET_POWER_SAVE */ |
| 3449 | (iw_handler) ks_wlan_set_scan_type, /* 12 KS_WLAN_SET_SCAN_TYPE */ |
| 3450 | (iw_handler) ks_wlan_get_scan_type, /* 13 KS_WLAN_GET_SCAN_TYPE */ |
| 3451 | (iw_handler) ks_wlan_set_rx_gain, /* 14 KS_WLAN_SET_RX_GAIN */ |
| 3452 | (iw_handler) ks_wlan_get_rx_gain, /* 15 KS_WLAN_GET_RX_GAIN */ |
| 3453 | (iw_handler) ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */ |
| 3454 | (iw_handler) NULL, /* 17 */ |
| 3455 | (iw_handler) ks_wlan_set_beacon_lost, /* 18 KS_WLAN_SET_BECAN_LOST */ |
| 3456 | (iw_handler) ks_wlan_get_beacon_lost, /* 19 KS_WLAN_GET_BECAN_LOST */ |
| 3457 | (iw_handler) ks_wlan_set_tx_gain, /* 20 KS_WLAN_SET_TX_GAIN */ |
| 3458 | (iw_handler) ks_wlan_get_tx_gain, /* 21 KS_WLAN_GET_TX_GAIN */ |
| 3459 | (iw_handler) ks_wlan_set_phy_type, /* 22 KS_WLAN_SET_PHY_TYPE */ |
| 3460 | (iw_handler) ks_wlan_get_phy_type, /* 23 KS_WLAN_GET_PHY_TYPE */ |
| 3461 | (iw_handler) ks_wlan_set_cts_mode, /* 24 KS_WLAN_SET_CTS_MODE */ |
| 3462 | (iw_handler) ks_wlan_get_cts_mode, /* 25 KS_WLAN_GET_CTS_MODE */ |
| 3463 | (iw_handler) NULL, /* 26 */ |
| 3464 | (iw_handler) NULL, /* 27 */ |
| 3465 | (iw_handler) ks_wlan_set_sleep_mode, /* 28 KS_WLAN_SET_SLEEP_MODE */ |
| 3466 | (iw_handler) ks_wlan_get_sleep_mode, /* 29 KS_WLAN_GET_SLEEP_MODE */ |
| 3467 | (iw_handler) NULL, /* 30 */ |
| 3468 | (iw_handler) NULL, /* 31 */ |
| 3469 | }; |
| 3470 | |
| 3471 | static const struct iw_handler_def ks_wlan_handler_def = |
| 3472 | { |
| 3473 | .num_standard = sizeof(ks_wlan_handler)/sizeof(iw_handler), |
| 3474 | .num_private = sizeof(ks_wlan_private_handler)/sizeof(iw_handler), |
| 3475 | .num_private_args = sizeof(ks_wlan_private_args)/sizeof(struct iw_priv_args), |
| 3476 | .standard = (iw_handler *) ks_wlan_handler, |
| 3477 | .private = (iw_handler *) ks_wlan_private_handler, |
| 3478 | .private_args = (struct iw_priv_args *) ks_wlan_private_args, |
| 3479 | .get_wireless_stats = ks_get_wireless_stats, |
| 3480 | }; |
| 3481 | |
| 3482 | #endif /* WIRELESS_EXT */ |
| 3483 | |
| 3484 | static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
| 3485 | { |
| 3486 | int rc = 0; |
| 3487 | #if defined(WIRELESS_EXT) |
| 3488 | struct iwreq *wrq = (struct iwreq *) rq; |
| 3489 | #endif /* WIRELESS_EXT */ |
| 3490 | switch (cmd) { |
| 3491 | #if defined(WIRELESS_EXT) |
| 3492 | case SIOCIWFIRSTPRIV+20: /* KS_WLAN_SET_STOP_REQ */ |
| 3493 | rc = ks_wlan_set_stop_request(dev, NULL, &(wrq->u.mode), NULL); |
| 3494 | break; |
| 3495 | #endif /* WIRELESS_EXT >17 */ |
| 3496 | // All other calls are currently unsupported |
| 3497 | default: |
| 3498 | rc = -EOPNOTSUPP; |
| 3499 | } |
| 3500 | |
| 3501 | DPRINTK(5,"return=%d\n",rc); |
| 3502 | return rc; |
| 3503 | } |
| 3504 | |
| 3505 | |
| 3506 | static |
| 3507 | struct net_device_stats *ks_wlan_get_stats(struct net_device *dev) |
| 3508 | { |
| 3509 | ks_wlan_private *priv = netdev_priv(dev); |
| 3510 | |
| 3511 | if (priv->dev_state < DEVICE_STATE_READY) { |
| 3512 | return NULL; /* not finished initialize */ |
| 3513 | } |
| 3514 | |
| 3515 | return &priv->nstats; |
| 3516 | } |
| 3517 | |
| 3518 | static |
| 3519 | int ks_wlan_set_mac_address(struct net_device *dev, void *addr) |
| 3520 | { |
| 3521 | ks_wlan_private *priv = netdev_priv(dev); |
| 3522 | struct sockaddr *mac_addr=(struct sockaddr *)addr; |
| 3523 | if (netif_running(dev)) |
| 3524 | return -EBUSY; |
| 3525 | memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); |
| 3526 | memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN); |
| 3527 | |
| 3528 | priv->mac_address_valid = 0; |
| 3529 | hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST); |
| 3530 | printk(KERN_INFO "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n", |
| 3531 | priv->eth_addr[0],priv->eth_addr[1],priv->eth_addr[2], |
| 3532 | priv->eth_addr[3],priv->eth_addr[4],priv->eth_addr[5]); |
| 3533 | return 0; |
| 3534 | } |
| 3535 | |
| 3536 | |
| 3537 | static |
| 3538 | void ks_wlan_tx_timeout(struct net_device *dev) |
| 3539 | { |
| 3540 | ks_wlan_private *priv = netdev_priv(dev); |
| 3541 | |
| 3542 | DPRINTK(1,"head(%d) tail(%d)!!\n",priv->tx_dev.qhead, priv->tx_dev.qtail); |
| 3543 | if(!netif_queue_stopped(dev)){ |
| 3544 | netif_stop_queue(dev); |
| 3545 | } |
| 3546 | priv->nstats.tx_errors++; |
| 3547 | netif_wake_queue(dev); |
| 3548 | |
| 3549 | return; |
| 3550 | } |
| 3551 | |
| 3552 | static |
| 3553 | int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 3554 | { |
| 3555 | ks_wlan_private *priv = netdev_priv(dev); |
| 3556 | int rc = 0; |
| 3557 | |
| 3558 | DPRINTK(3,"in_interrupt()=%ld\n",in_interrupt()); |
| 3559 | |
| 3560 | if ( skb == NULL ) { |
| 3561 | printk( KERN_ERR "ks_wlan: skb == NULL!!!\n" ); |
| 3562 | return 0; |
| 3563 | } |
| 3564 | if (priv->dev_state < DEVICE_STATE_READY) { |
| 3565 | dev_kfree_skb(skb); |
| 3566 | return 0; /* not finished initialize */ |
| 3567 | } |
| 3568 | |
| 3569 | if(netif_running(dev)) |
| 3570 | netif_stop_queue(dev); |
| 3571 | |
| 3572 | rc = hostif_data_request(priv, skb); |
| 3573 | dev->trans_start = jiffies; |
| 3574 | |
| 3575 | DPRINTK(4,"rc=%d\n",rc); |
| 3576 | if (rc){ |
| 3577 | rc=0; |
| 3578 | } |
| 3579 | |
| 3580 | return rc; |
| 3581 | } |
| 3582 | |
| 3583 | void send_packet_complete(void *arg1, void *arg2) |
| 3584 | { |
| 3585 | ks_wlan_private *priv = (ks_wlan_private *)arg1; |
| 3586 | struct sk_buff *packet = (struct sk_buff *)arg2; |
| 3587 | |
| 3588 | DPRINTK(3,"\n"); |
| 3589 | |
| 3590 | priv->nstats.tx_bytes += packet->len; |
| 3591 | priv->nstats.tx_packets++; |
| 3592 | |
| 3593 | if(netif_queue_stopped(priv->net_dev)) |
| 3594 | netif_wake_queue(priv->net_dev); |
| 3595 | |
| 3596 | if(packet){ |
| 3597 | dev_kfree_skb(packet); |
| 3598 | packet=NULL; |
| 3599 | } |
| 3600 | |
| 3601 | } |
| 3602 | |
| 3603 | /* Set or clear the multicast filter for this adaptor. |
| 3604 | This routine is not state sensitive and need not be SMP locked. */ |
| 3605 | static |
| 3606 | void ks_wlan_set_multicast_list(struct net_device *dev) |
| 3607 | { |
| 3608 | ks_wlan_private *priv = netdev_priv(dev); |
| 3609 | |
| 3610 | DPRINTK(4,"\n"); |
| 3611 | if (priv->dev_state < DEVICE_STATE_READY) { |
| 3612 | return ; /* not finished initialize */ |
| 3613 | } |
| 3614 | hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST); |
| 3615 | |
| 3616 | return; |
| 3617 | } |
| 3618 | |
| 3619 | static |
| 3620 | int ks_wlan_open(struct net_device *dev) |
| 3621 | { |
| 3622 | ks_wlan_private *priv = netdev_priv(dev); |
| 3623 | |
| 3624 | priv->cur_rx = 0; |
| 3625 | |
| 3626 | if(!priv->mac_address_valid){ |
| 3627 | printk(KERN_ERR "ks_wlan : %s Not READY !!\n", dev->name); |
| 3628 | return -EBUSY; |
| 3629 | } |
| 3630 | else |
| 3631 | netif_start_queue (dev); |
| 3632 | |
| 3633 | return 0; |
| 3634 | } |
| 3635 | |
| 3636 | static |
| 3637 | int ks_wlan_close(struct net_device *dev) |
| 3638 | { |
| 3639 | |
| 3640 | netif_stop_queue (dev); |
| 3641 | |
| 3642 | DPRINTK(4, "%s: Shutting down ethercard, status was 0x%4.4x.\n", |
| 3643 | dev->name, 0x00); |
| 3644 | |
| 3645 | return 0; |
| 3646 | } |
| 3647 | |
| 3648 | |
| 3649 | /* Operational parameters that usually are not changed. */ |
| 3650 | /* Time in jiffies before concluding the transmitter is hung. */ |
| 3651 | #define TX_TIMEOUT (3*HZ) |
| 3652 | static const unsigned char dummy_addr[] = {0x00,0x0b,0xe3,0x00,0x00,0x00}; |
| 3653 | |
| 3654 | static const struct net_device_ops ks_wlan_netdev_ops = { |
| 3655 | .ndo_start_xmit = ks_wlan_start_xmit, |
| 3656 | .ndo_open = ks_wlan_open, |
| 3657 | .ndo_stop = ks_wlan_close, |
| 3658 | .ndo_do_ioctl = ks_wlan_netdev_ioctl, |
| 3659 | .ndo_set_mac_address = ks_wlan_set_mac_address, |
| 3660 | .ndo_get_stats = ks_wlan_get_stats, |
| 3661 | .ndo_tx_timeout = ks_wlan_tx_timeout, |
| 3662 | .ndo_set_multicast_list = ks_wlan_set_multicast_list, |
| 3663 | }; |
| 3664 | |
| 3665 | int ks_wlan_net_start(struct net_device *dev) |
| 3666 | { |
| 3667 | ks_wlan_private *priv; |
| 3668 | /* int rc; */ |
| 3669 | |
| 3670 | priv = netdev_priv(dev); |
| 3671 | priv->mac_address_valid = 0; |
| 3672 | priv->need_commit = 0; |
| 3673 | |
| 3674 | priv->device_open_status = 1; |
| 3675 | |
| 3676 | /* phy information update timer */ |
| 3677 | atomic_set(&update_phyinfo,0); |
| 3678 | init_timer(&update_phyinfo_timer); |
| 3679 | update_phyinfo_timer.function=ks_wlan_update_phyinfo_timeout; |
| 3680 | update_phyinfo_timer.data = (unsigned long)priv; |
| 3681 | |
| 3682 | /* dummy address set */ |
| 3683 | memcpy(priv->eth_addr, dummy_addr, ETH_ALEN); |
| 3684 | dev->dev_addr[0] = priv->eth_addr[0]; |
| 3685 | dev->dev_addr[1] = priv->eth_addr[1]; |
| 3686 | dev->dev_addr[2] = priv->eth_addr[2]; |
| 3687 | dev->dev_addr[3] = priv->eth_addr[3]; |
| 3688 | dev->dev_addr[4] = priv->eth_addr[4]; |
| 3689 | dev->dev_addr[5] = priv->eth_addr[5]; |
| 3690 | dev->dev_addr[6] = 0x00; |
| 3691 | dev->dev_addr[7] = 0x00; |
| 3692 | |
| 3693 | /* The ks_wlan-specific entries in the device structure. */ |
| 3694 | dev->netdev_ops = &ks_wlan_netdev_ops; |
| 3695 | dev->wireless_handlers = (struct iw_handler_def *)&ks_wlan_handler_def; |
| 3696 | dev->watchdog_timeo = TX_TIMEOUT; |
| 3697 | |
| 3698 | netif_carrier_off(dev); |
| 3699 | |
| 3700 | return(0); |
| 3701 | } |
| 3702 | |
| 3703 | |
| 3704 | int ks_wlan_net_stop(struct net_device *dev) |
| 3705 | { |
| 3706 | ks_wlan_private *priv = netdev_priv(dev); |
| 3707 | |
| 3708 | int ret = 0; |
| 3709 | priv->device_open_status = 0; |
| 3710 | del_timer_sync(&update_phyinfo_timer); |
| 3711 | |
| 3712 | if(netif_running(dev)) |
| 3713 | netif_stop_queue(dev); |
| 3714 | |
| 3715 | return ret; |
| 3716 | } |
| 3717 | |
| 3718 | int ks_wlan_reset(struct net_device *dev) |
| 3719 | { |
| 3720 | return 0; |
| 3721 | } |
| 3722 | |