1 /* 2 * Driver for KeyStream 11b/g wireless LAN 3 * 4 * Copyright (C) 2005-2008 KeyStream Corp. 5 * Copyright (C) 2009 Renesas Technology Corp. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 */ 11 12 #include <linux/module.h> 13 #include <linux/kernel.h> 14 #include <linux/compiler.h> 15 #include <linux/init.h> 16 #include <linux/ioport.h> 17 #include <linux/netdevice.h> 18 #include <linux/etherdevice.h> 19 #include <linux/if_arp.h> 20 #include <linux/rtnetlink.h> 21 #include <linux/delay.h> 22 #include <linux/completion.h> 23 #include <linux/mii.h> 24 #include <linux/pci.h> 25 #include <linux/ctype.h> 26 #include <linux/timer.h> 27 #include <linux/atomic.h> 28 #include <linux/io.h> 29 #include <linux/uaccess.h> 30 31 static int wep_on_off; 32 #define WEP_OFF 0 33 #define WEP_ON_64BIT 1 34 #define WEP_ON_128BIT 2 35 36 #include "ks_wlan.h" 37 #include "ks_hostif.h" 38 #include "ks_wlan_ioctl.h" 39 40 /* Include Wireless Extension definition and check version */ 41 #include <linux/wireless.h> 42 #define WIRELESS_SPY /* enable iwspy support */ 43 #include <net/iw_handler.h> /* New driver API */ 44 45 /* Frequency list (map channels to frequencies) */ 46 static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 47 2447, 2452, 2457, 2462, 2467, 2472, 2484 48 }; 49 50 /* A few details needed for WEP (Wireless Equivalent Privacy) */ 51 #define MAX_KEY_SIZE 13 /* 128 (?) bits */ 52 #define MIN_KEY_SIZE 5 /* 40 bits RC4 - WEP */ 53 struct wep_key { 54 u16 len; 55 u8 key[16]; /* 40-bit and 104-bit keys */ 56 }; 57 58 /* Backward compatibility */ 59 #ifndef IW_ENCODE_NOKEY 60 #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */ 61 #define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN) 62 #endif /* IW_ENCODE_NOKEY */ 63 64 /* List of Wireless Handlers (new API) */ 65 static const struct iw_handler_def ks_wlan_handler_def; 66 67 #define KSC_OPNOTSUPP /* Operation Not Support */ 68 69 /* 70 * function prototypes 71 */ 72 static int ks_wlan_open(struct net_device *dev); 73 static void ks_wlan_tx_timeout(struct net_device *dev); 74 static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev); 75 static int ks_wlan_close(struct net_device *dev); 76 static void ks_wlan_set_multicast_list(struct net_device *dev); 77 static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev); 78 static int ks_wlan_set_mac_address(struct net_device *dev, void *addr); 79 static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, 80 int cmd); 81 82 static atomic_t update_phyinfo; 83 static struct timer_list update_phyinfo_timer; 84 static 85 int ks_wlan_update_phy_information(struct ks_wlan_private *priv) 86 { 87 struct iw_statistics *wstats = &priv->wstats; 88 89 netdev_dbg(priv->net_dev, "in_interrupt = %ld\n", in_interrupt()); 90 91 if (priv->dev_state < DEVICE_STATE_READY) 92 return -EBUSY; /* not finished initialize */ 93 94 if (atomic_read(&update_phyinfo)) 95 return -EPERM; 96 97 /* The status */ 98 wstats->status = priv->reg.operation_mode; /* Operation mode */ 99 100 /* Signal quality and co. But where is the noise level ??? */ 101 hostif_sme_enqueue(priv, SME_PHY_INFO_REQUEST); 102 103 /* interruptible_sleep_on_timeout(&priv->confirm_wait, HZ/2); */ 104 if (!wait_for_completion_interruptible_timeout 105 (&priv->confirm_wait, HZ / 2)) { 106 netdev_dbg(priv->net_dev, "wait time out!!\n"); 107 } 108 109 atomic_inc(&update_phyinfo); 110 update_phyinfo_timer.expires = jiffies + HZ; /* 1sec */ 111 add_timer(&update_phyinfo_timer); 112 113 return 0; 114 } 115 116 static 117 void ks_wlan_update_phyinfo_timeout(struct timer_list *unused) 118 { 119 pr_debug("in_interrupt = %ld\n", in_interrupt()); 120 atomic_set(&update_phyinfo, 0); 121 } 122 123 int ks_wlan_setup_parameter(struct ks_wlan_private *priv, 124 unsigned int commit_flag) 125 { 126 hostif_sme_enqueue(priv, SME_STOP_REQUEST); 127 128 if (commit_flag & SME_RTS) 129 hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST); 130 if (commit_flag & SME_FRAG) 131 hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST); 132 133 if (commit_flag & SME_WEP_INDEX) 134 hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST); 135 if (commit_flag & SME_WEP_VAL1) 136 hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST); 137 if (commit_flag & SME_WEP_VAL2) 138 hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST); 139 if (commit_flag & SME_WEP_VAL3) 140 hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST); 141 if (commit_flag & SME_WEP_VAL4) 142 hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST); 143 if (commit_flag & SME_WEP_FLAG) 144 hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); 145 146 if (commit_flag & SME_RSN) { 147 hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST); 148 hostif_sme_enqueue(priv, SME_RSN_MODE_REQUEST); 149 } 150 if (commit_flag & SME_RSN_MULTICAST) 151 hostif_sme_enqueue(priv, SME_RSN_MCAST_REQUEST); 152 if (commit_flag & SME_RSN_UNICAST) 153 hostif_sme_enqueue(priv, SME_RSN_UCAST_REQUEST); 154 if (commit_flag & SME_RSN_AUTH) 155 hostif_sme_enqueue(priv, SME_RSN_AUTH_REQUEST); 156 157 hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST); 158 159 hostif_sme_enqueue(priv, SME_START_REQUEST); 160 161 return 0; 162 } 163 164 /* 165 * Initial Wireless Extension code for Ks_Wlannet driver by : 166 * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 17 November 00 167 * Conversion to new driver API by : 168 * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 26 March 02 169 * Javier also did a good amount of work here, adding some new extensions 170 * and fixing my code. Let's just say that without him this code just 171 * would not work at all... - Jean II 172 */ 173 174 static int ks_wlan_get_name(struct net_device *dev, 175 struct iw_request_info *info, char *cwrq, 176 char *extra) 177 { 178 struct ks_wlan_private *priv = netdev_priv(dev); 179 180 if (priv->sleep_mode == SLP_SLEEP) 181 return -EPERM; 182 183 /* for SLEEP MODE */ 184 if (priv->dev_state < DEVICE_STATE_READY) 185 strcpy(cwrq, "NOT READY!"); 186 else if (priv->reg.phy_type == D_11B_ONLY_MODE) 187 strcpy(cwrq, "IEEE 802.11b"); 188 else if (priv->reg.phy_type == D_11G_ONLY_MODE) 189 strcpy(cwrq, "IEEE 802.11g"); 190 else 191 strcpy(cwrq, "IEEE 802.11b/g"); 192 193 return 0; 194 } 195 196 static int ks_wlan_set_freq(struct net_device *dev, 197 struct iw_request_info *info, struct iw_freq *fwrq, 198 char *extra) 199 { 200 struct ks_wlan_private *priv = netdev_priv(dev); 201 int channel; 202 203 if (priv->sleep_mode == SLP_SLEEP) 204 return -EPERM; 205 206 /* for SLEEP MODE */ 207 /* If setting by frequency, convert to a channel */ 208 if ((fwrq->e == 1) && 209 (fwrq->m >= (int)2.412e8) && (fwrq->m <= (int)2.487e8)) { 210 int f = fwrq->m / 100000; 211 int c = 0; 212 213 while ((c < 14) && (f != frequency_list[c])) 214 c++; 215 /* Hack to fall through... */ 216 fwrq->e = 0; 217 fwrq->m = c + 1; 218 } 219 /* Setting by channel number */ 220 if ((fwrq->m > 1000) || (fwrq->e > 0)) 221 return -EOPNOTSUPP; 222 223 channel = fwrq->m; 224 /* We should do a better check than that, 225 * based on the card capability !!! 226 */ 227 if ((channel < 1) || (channel > 14)) { 228 netdev_dbg(dev, "%s: New channel value of %d is invalid!\n", 229 dev->name, fwrq->m); 230 return -EINVAL; 231 } 232 233 /* Yes ! We can set it !!! */ 234 priv->reg.channel = (u8)(channel); 235 priv->need_commit |= SME_MODE_SET; 236 237 return -EINPROGRESS; /* Call commit handler */ 238 } 239 240 static int ks_wlan_get_freq(struct net_device *dev, 241 struct iw_request_info *info, struct iw_freq *fwrq, 242 char *extra) 243 { 244 struct ks_wlan_private *priv = netdev_priv(dev); 245 int f; 246 247 if (priv->sleep_mode == SLP_SLEEP) 248 return -EPERM; 249 250 /* for SLEEP MODE */ 251 if (is_connect_status(priv->connect_status)) 252 f = (int)priv->current_ap.channel; 253 else 254 f = (int)priv->reg.channel; 255 256 fwrq->m = frequency_list[f - 1] * 100000; 257 fwrq->e = 1; 258 259 return 0; 260 } 261 262 static int ks_wlan_set_essid(struct net_device *dev, 263 struct iw_request_info *info, 264 struct iw_point *dwrq, char *extra) 265 { 266 struct ks_wlan_private *priv = netdev_priv(dev); 267 size_t len; 268 269 if (priv->sleep_mode == SLP_SLEEP) 270 return -EPERM; 271 272 /* for SLEEP MODE */ 273 /* Check if we asked for `any' */ 274 if (!dwrq->flags) { 275 /* Just send an empty SSID list */ 276 memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); 277 priv->reg.ssid.size = 0; 278 } else { 279 len = dwrq->length; 280 /* iwconfig uses nul termination in SSID.. */ 281 if (len > 0 && extra[len - 1] == '\0') 282 len--; 283 284 /* Check the size of the string */ 285 if (len > IW_ESSID_MAX_SIZE) 286 return -EINVAL; 287 288 /* Set the SSID */ 289 memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); 290 memcpy(priv->reg.ssid.body, extra, len); 291 priv->reg.ssid.size = len; 292 } 293 /* Write it to the card */ 294 priv->need_commit |= SME_MODE_SET; 295 296 ks_wlan_setup_parameter(priv, priv->need_commit); 297 priv->need_commit = 0; 298 return 0; 299 } 300 301 static int ks_wlan_get_essid(struct net_device *dev, 302 struct iw_request_info *info, 303 struct iw_point *dwrq, char *extra) 304 { 305 struct ks_wlan_private *priv = netdev_priv(dev); 306 307 if (priv->sleep_mode == SLP_SLEEP) 308 return -EPERM; 309 310 /* for SLEEP MODE */ 311 /* Note : if dwrq->flags != 0, we should 312 * get the relevant SSID from the SSID list... 313 */ 314 if (priv->reg.ssid.size != 0) { 315 /* Get the current SSID */ 316 memcpy(extra, priv->reg.ssid.body, priv->reg.ssid.size); 317 318 /* If none, we may want to get the one that was set */ 319 320 /* Push it out ! */ 321 dwrq->length = priv->reg.ssid.size; 322 dwrq->flags = 1; /* active */ 323 } else { 324 dwrq->length = 0; 325 dwrq->flags = 0; /* ANY */ 326 } 327 328 return 0; 329 } 330 331 static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, 332 struct sockaddr *ap_addr, char *extra) 333 { 334 struct ks_wlan_private *priv = netdev_priv(dev); 335 336 if (priv->sleep_mode == SLP_SLEEP) 337 return -EPERM; 338 339 /* for SLEEP MODE */ 340 if (priv->reg.operation_mode == MODE_ADHOC || 341 priv->reg.operation_mode == MODE_INFRASTRUCTURE) { 342 memcpy(priv->reg.bssid, &ap_addr->sa_data, ETH_ALEN); 343 344 if (is_valid_ether_addr((u8 *)priv->reg.bssid)) 345 priv->need_commit |= SME_MODE_SET; 346 347 } else { 348 eth_zero_addr(priv->reg.bssid); 349 return -EOPNOTSUPP; 350 } 351 352 netdev_dbg(dev, "bssid = %pM\n", priv->reg.bssid); 353 354 /* Write it to the card */ 355 if (priv->need_commit) { 356 priv->need_commit |= SME_MODE_SET; 357 return -EINPROGRESS; /* Call commit handler */ 358 } 359 return 0; 360 } 361 362 static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, 363 struct sockaddr *awrq, char *extra) 364 { 365 struct ks_wlan_private *priv = netdev_priv(dev); 366 367 if (priv->sleep_mode == SLP_SLEEP) 368 return -EPERM; 369 370 /* for SLEEP MODE */ 371 if (is_connect_status(priv->connect_status)) 372 memcpy(awrq->sa_data, priv->current_ap.bssid, ETH_ALEN); 373 else 374 eth_zero_addr(awrq->sa_data); 375 376 awrq->sa_family = ARPHRD_ETHER; 377 378 return 0; 379 } 380 381 static int ks_wlan_set_nick(struct net_device *dev, 382 struct iw_request_info *info, struct iw_point *dwrq, 383 char *extra) 384 { 385 struct ks_wlan_private *priv = netdev_priv(dev); 386 387 if (priv->sleep_mode == SLP_SLEEP) 388 return -EPERM; 389 390 /* for SLEEP MODE */ 391 /* Check the size of the string */ 392 if (dwrq->length > 16 + 1) 393 return -E2BIG; 394 395 memset(priv->nick, 0, sizeof(priv->nick)); 396 memcpy(priv->nick, extra, dwrq->length); 397 398 return -EINPROGRESS; /* Call commit handler */ 399 } 400 401 static int ks_wlan_get_nick(struct net_device *dev, 402 struct iw_request_info *info, struct iw_point *dwrq, 403 char *extra) 404 { 405 struct ks_wlan_private *priv = netdev_priv(dev); 406 407 if (priv->sleep_mode == SLP_SLEEP) 408 return -EPERM; 409 410 /* for SLEEP MODE */ 411 strncpy(extra, priv->nick, 16); 412 extra[16] = '\0'; 413 dwrq->length = strlen(extra) + 1; 414 415 return 0; 416 } 417 418 static int ks_wlan_set_rate(struct net_device *dev, 419 struct iw_request_info *info, struct iw_param *vwrq, 420 char *extra) 421 { 422 struct ks_wlan_private *priv = netdev_priv(dev); 423 int i = 0; 424 425 if (priv->sleep_mode == SLP_SLEEP) 426 return -EPERM; 427 428 /* for SLEEP MODE */ 429 if (priv->reg.phy_type == D_11B_ONLY_MODE) { 430 if (vwrq->fixed == 1) { 431 switch (vwrq->value) { 432 case 11000000: 433 case 5500000: 434 priv->reg.rate_set.body[0] = 435 (uint8_t)(vwrq->value / 500000); 436 break; 437 case 2000000: 438 case 1000000: 439 priv->reg.rate_set.body[0] = 440 ((uint8_t)(vwrq->value / 500000)) | 441 BASIC_RATE; 442 break; 443 default: 444 return -EINVAL; 445 } 446 priv->reg.tx_rate = TX_RATE_FIXED; 447 priv->reg.rate_set.size = 1; 448 } else { /* vwrq->fixed == 0 */ 449 if (vwrq->value > 0) { 450 switch (vwrq->value) { 451 case 11000000: 452 priv->reg.rate_set.body[3] = 453 TX_RATE_11M; 454 i++; 455 /* fall through */ 456 case 5500000: 457 priv->reg.rate_set.body[2] = TX_RATE_5M; 458 i++; 459 /* fall through */ 460 case 2000000: 461 priv->reg.rate_set.body[1] = 462 TX_RATE_2M | BASIC_RATE; 463 i++; 464 /* fall through */ 465 case 1000000: 466 priv->reg.rate_set.body[0] = 467 TX_RATE_1M | BASIC_RATE; 468 i++; 469 break; 470 default: 471 return -EINVAL; 472 } 473 priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; 474 priv->reg.rate_set.size = i; 475 } else { 476 priv->reg.rate_set.body[3] = TX_RATE_11M; 477 priv->reg.rate_set.body[2] = TX_RATE_5M; 478 priv->reg.rate_set.body[1] = 479 TX_RATE_2M | BASIC_RATE; 480 priv->reg.rate_set.body[0] = 481 TX_RATE_1M | BASIC_RATE; 482 priv->reg.tx_rate = TX_RATE_FULL_AUTO; 483 priv->reg.rate_set.size = 4; 484 } 485 } 486 } else { /* D_11B_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ 487 if (vwrq->fixed == 1) { 488 switch (vwrq->value) { 489 case 54000000: 490 case 48000000: 491 case 36000000: 492 case 18000000: 493 case 9000000: 494 priv->reg.rate_set.body[0] = 495 (uint8_t)(vwrq->value / 500000); 496 break; 497 case 24000000: 498 case 12000000: 499 case 11000000: 500 case 6000000: 501 case 5500000: 502 case 2000000: 503 case 1000000: 504 priv->reg.rate_set.body[0] = 505 ((uint8_t)(vwrq->value / 500000)) | 506 BASIC_RATE; 507 break; 508 default: 509 return -EINVAL; 510 } 511 priv->reg.tx_rate = TX_RATE_FIXED; 512 priv->reg.rate_set.size = 1; 513 } else { /* vwrq->fixed == 0 */ 514 if (vwrq->value > 0) { 515 switch (vwrq->value) { 516 case 54000000: 517 priv->reg.rate_set.body[11] = 518 TX_RATE_54M; 519 i++; 520 /* fall through */ 521 case 48000000: 522 priv->reg.rate_set.body[10] = 523 TX_RATE_48M; 524 i++; 525 /* fall through */ 526 case 36000000: 527 priv->reg.rate_set.body[9] = 528 TX_RATE_36M; 529 i++; 530 /* fall through */ 531 case 24000000: 532 case 18000000: 533 case 12000000: 534 case 11000000: 535 case 9000000: 536 case 6000000: 537 if (vwrq->value == 24000000) { 538 priv->reg.rate_set.body[8] = 539 TX_RATE_18M; 540 i++; 541 priv->reg.rate_set.body[7] = 542 TX_RATE_9M; 543 i++; 544 priv->reg.rate_set.body[6] = 545 TX_RATE_24M | BASIC_RATE; 546 i++; 547 priv->reg.rate_set.body[5] = 548 TX_RATE_12M | BASIC_RATE; 549 i++; 550 priv->reg.rate_set.body[4] = 551 TX_RATE_6M | BASIC_RATE; 552 i++; 553 priv->reg.rate_set.body[3] = 554 TX_RATE_11M | BASIC_RATE; 555 i++; 556 } else if (vwrq->value == 18000000) { 557 priv->reg.rate_set.body[7] = 558 TX_RATE_18M; 559 i++; 560 priv->reg.rate_set.body[6] = 561 TX_RATE_9M; 562 i++; 563 priv->reg.rate_set.body[5] = 564 TX_RATE_12M | BASIC_RATE; 565 i++; 566 priv->reg.rate_set.body[4] = 567 TX_RATE_6M | BASIC_RATE; 568 i++; 569 priv->reg.rate_set.body[3] = 570 TX_RATE_11M | BASIC_RATE; 571 i++; 572 } else if (vwrq->value == 12000000) { 573 priv->reg.rate_set.body[6] = 574 TX_RATE_9M; 575 i++; 576 priv->reg.rate_set.body[5] = 577 TX_RATE_12M | BASIC_RATE; 578 i++; 579 priv->reg.rate_set.body[4] = 580 TX_RATE_6M | BASIC_RATE; 581 i++; 582 priv->reg.rate_set.body[3] = 583 TX_RATE_11M | BASIC_RATE; 584 i++; 585 } else if (vwrq->value == 11000000) { 586 priv->reg.rate_set.body[5] = 587 TX_RATE_9M; 588 i++; 589 priv->reg.rate_set.body[4] = 590 TX_RATE_6M | BASIC_RATE; 591 i++; 592 priv->reg.rate_set.body[3] = 593 TX_RATE_11M | BASIC_RATE; 594 i++; 595 } else if (vwrq->value == 9000000) { 596 priv->reg.rate_set.body[4] = 597 TX_RATE_9M; 598 i++; 599 priv->reg.rate_set.body[3] = 600 TX_RATE_6M | BASIC_RATE; 601 i++; 602 } else { /* vwrq->value == 6000000 */ 603 priv->reg.rate_set.body[3] = 604 TX_RATE_6M | BASIC_RATE; 605 i++; 606 } 607 /* fall through */ 608 case 5500000: 609 priv->reg.rate_set.body[2] = 610 TX_RATE_5M | BASIC_RATE; 611 i++; 612 /* fall through */ 613 case 2000000: 614 priv->reg.rate_set.body[1] = 615 TX_RATE_2M | BASIC_RATE; 616 i++; 617 /* fall through */ 618 case 1000000: 619 priv->reg.rate_set.body[0] = 620 TX_RATE_1M | BASIC_RATE; 621 i++; 622 break; 623 default: 624 return -EINVAL; 625 } 626 priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; 627 priv->reg.rate_set.size = i; 628 } else { 629 priv->reg.rate_set.body[11] = TX_RATE_54M; 630 priv->reg.rate_set.body[10] = TX_RATE_48M; 631 priv->reg.rate_set.body[9] = TX_RATE_36M; 632 priv->reg.rate_set.body[8] = TX_RATE_18M; 633 priv->reg.rate_set.body[7] = TX_RATE_9M; 634 priv->reg.rate_set.body[6] = 635 TX_RATE_24M | BASIC_RATE; 636 priv->reg.rate_set.body[5] = 637 TX_RATE_12M | BASIC_RATE; 638 priv->reg.rate_set.body[4] = 639 TX_RATE_6M | BASIC_RATE; 640 priv->reg.rate_set.body[3] = 641 TX_RATE_11M | BASIC_RATE; 642 priv->reg.rate_set.body[2] = 643 TX_RATE_5M | BASIC_RATE; 644 priv->reg.rate_set.body[1] = 645 TX_RATE_2M | BASIC_RATE; 646 priv->reg.rate_set.body[0] = 647 TX_RATE_1M | BASIC_RATE; 648 priv->reg.tx_rate = TX_RATE_FULL_AUTO; 649 priv->reg.rate_set.size = 12; 650 } 651 } 652 } 653 654 priv->need_commit |= SME_MODE_SET; 655 656 return -EINPROGRESS; /* Call commit handler */ 657 } 658 659 static int ks_wlan_get_rate(struct net_device *dev, 660 struct iw_request_info *info, struct iw_param *vwrq, 661 char *extra) 662 { 663 struct ks_wlan_private *priv = netdev_priv(dev); 664 665 netdev_dbg(dev, "in_interrupt = %ld update_phyinfo = %d\n", 666 in_interrupt(), atomic_read(&update_phyinfo)); 667 668 if (priv->sleep_mode == SLP_SLEEP) 669 return -EPERM; 670 671 /* for SLEEP MODE */ 672 if (!atomic_read(&update_phyinfo)) 673 ks_wlan_update_phy_information(priv); 674 675 vwrq->value = ((priv->current_rate) & RATE_MASK) * 500000; 676 if (priv->reg.tx_rate == TX_RATE_FIXED) 677 vwrq->fixed = 1; 678 else 679 vwrq->fixed = 0; 680 681 return 0; 682 } 683 684 static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, 685 struct iw_param *vwrq, char *extra) 686 { 687 struct ks_wlan_private *priv = netdev_priv(dev); 688 int rthr = vwrq->value; 689 690 if (priv->sleep_mode == SLP_SLEEP) 691 return -EPERM; 692 693 /* for SLEEP MODE */ 694 if (vwrq->disabled) 695 rthr = 2347; 696 if ((rthr < 0) || (rthr > 2347)) 697 return -EINVAL; 698 699 priv->reg.rts = rthr; 700 priv->need_commit |= SME_RTS; 701 702 return -EINPROGRESS; /* Call commit handler */ 703 } 704 705 static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, 706 struct iw_param *vwrq, char *extra) 707 { 708 struct ks_wlan_private *priv = netdev_priv(dev); 709 710 if (priv->sleep_mode == SLP_SLEEP) 711 return -EPERM; 712 713 /* for SLEEP MODE */ 714 vwrq->value = priv->reg.rts; 715 vwrq->disabled = (vwrq->value >= 2347); 716 vwrq->fixed = 1; 717 718 return 0; 719 } 720 721 static int ks_wlan_set_frag(struct net_device *dev, 722 struct iw_request_info *info, struct iw_param *vwrq, 723 char *extra) 724 { 725 struct ks_wlan_private *priv = netdev_priv(dev); 726 int fthr = vwrq->value; 727 728 if (priv->sleep_mode == SLP_SLEEP) 729 return -EPERM; 730 731 /* for SLEEP MODE */ 732 if (vwrq->disabled) 733 fthr = 2346; 734 if ((fthr < 256) || (fthr > 2346)) 735 return -EINVAL; 736 737 fthr &= ~0x1; /* Get an even value - is it really needed ??? */ 738 priv->reg.fragment = fthr; 739 priv->need_commit |= SME_FRAG; 740 741 return -EINPROGRESS; /* Call commit handler */ 742 } 743 744 static int ks_wlan_get_frag(struct net_device *dev, 745 struct iw_request_info *info, struct iw_param *vwrq, 746 char *extra) 747 { 748 struct ks_wlan_private *priv = netdev_priv(dev); 749 750 if (priv->sleep_mode == SLP_SLEEP) 751 return -EPERM; 752 753 /* for SLEEP MODE */ 754 vwrq->value = priv->reg.fragment; 755 vwrq->disabled = (vwrq->value >= 2346); 756 vwrq->fixed = 1; 757 758 return 0; 759 } 760 761 static int ks_wlan_set_mode(struct net_device *dev, 762 struct iw_request_info *info, __u32 *uwrq, 763 char *extra) 764 { 765 struct ks_wlan_private *priv = netdev_priv(dev); 766 767 if (priv->sleep_mode == SLP_SLEEP) 768 return -EPERM; 769 770 /* for SLEEP MODE */ 771 switch (*uwrq) { 772 case IW_MODE_ADHOC: 773 priv->reg.operation_mode = MODE_ADHOC; 774 priv->need_commit |= SME_MODE_SET; 775 break; 776 case IW_MODE_INFRA: 777 priv->reg.operation_mode = MODE_INFRASTRUCTURE; 778 priv->need_commit |= SME_MODE_SET; 779 break; 780 case IW_MODE_AUTO: 781 case IW_MODE_MASTER: 782 case IW_MODE_REPEAT: 783 case IW_MODE_SECOND: 784 case IW_MODE_MONITOR: 785 default: 786 return -EINVAL; 787 } 788 789 return -EINPROGRESS; /* Call commit handler */ 790 } 791 792 static int ks_wlan_get_mode(struct net_device *dev, 793 struct iw_request_info *info, __u32 *uwrq, 794 char *extra) 795 { 796 struct ks_wlan_private *priv = netdev_priv(dev); 797 798 if (priv->sleep_mode == SLP_SLEEP) 799 return -EPERM; 800 801 /* for SLEEP MODE */ 802 /* If not managed, assume it's ad-hoc */ 803 switch (priv->reg.operation_mode) { 804 case MODE_INFRASTRUCTURE: 805 *uwrq = IW_MODE_INFRA; 806 break; 807 case MODE_ADHOC: 808 *uwrq = IW_MODE_ADHOC; 809 break; 810 default: 811 *uwrq = IW_MODE_ADHOC; 812 } 813 814 return 0; 815 } 816 817 static int ks_wlan_set_encode(struct net_device *dev, 818 struct iw_request_info *info, 819 struct iw_point *dwrq, char *extra) 820 { 821 struct ks_wlan_private *priv = netdev_priv(dev); 822 823 struct wep_key key; 824 int index = (dwrq->flags & IW_ENCODE_INDEX); 825 int current_index = priv->reg.wep_index; 826 int i; 827 828 if (priv->sleep_mode == SLP_SLEEP) 829 return -EPERM; 830 831 /* for SLEEP MODE */ 832 /* index check */ 833 if ((index < 0) || (index > 4)) 834 return -EINVAL; 835 else if (index == 0) 836 index = current_index; 837 else 838 index--; 839 840 /* Is WEP supported ? */ 841 /* Basic checking: do we have a key to set ? */ 842 if (dwrq->length > 0) { 843 if (dwrq->length > MAX_KEY_SIZE) { /* Check the size of the key */ 844 return -EINVAL; 845 } 846 if (dwrq->length > MIN_KEY_SIZE) { /* Set the length */ 847 key.len = MAX_KEY_SIZE; 848 priv->reg.privacy_invoked = 0x01; 849 priv->need_commit |= SME_WEP_FLAG; 850 wep_on_off = WEP_ON_128BIT; 851 } else { 852 if (dwrq->length > 0) { 853 key.len = MIN_KEY_SIZE; 854 priv->reg.privacy_invoked = 0x01; 855 priv->need_commit |= SME_WEP_FLAG; 856 wep_on_off = WEP_ON_64BIT; 857 } else { /* Disable the key */ 858 key.len = 0; 859 } 860 } 861 /* Check if the key is not marked as invalid */ 862 if (!(dwrq->flags & IW_ENCODE_NOKEY)) { 863 /* Cleanup */ 864 memset(key.key, 0, MAX_KEY_SIZE); 865 /* Copy the key in the driver */ 866 if (copy_from_user 867 (key.key, dwrq->pointer, dwrq->length)) { 868 key.len = 0; 869 return -EFAULT; 870 } 871 /* Send the key to the card */ 872 priv->reg.wep_key[index].size = key.len; 873 for (i = 0; i < (priv->reg.wep_key[index].size); i++) 874 priv->reg.wep_key[index].val[i] = key.key[i]; 875 876 priv->need_commit |= (SME_WEP_VAL1 << index); 877 priv->reg.wep_index = index; 878 priv->need_commit |= SME_WEP_INDEX; 879 } 880 } else { 881 if (dwrq->flags & IW_ENCODE_DISABLED) { 882 priv->reg.wep_key[0].size = 0; 883 priv->reg.wep_key[1].size = 0; 884 priv->reg.wep_key[2].size = 0; 885 priv->reg.wep_key[3].size = 0; 886 priv->reg.privacy_invoked = 0x00; 887 if (priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY) 888 priv->need_commit |= SME_MODE_SET; 889 890 priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; 891 wep_on_off = WEP_OFF; 892 priv->need_commit |= SME_WEP_FLAG; 893 } else { 894 /* Do we want to just set the transmit key index ? */ 895 if ((index >= 0) && (index < 4)) { 896 /* set_wep_key(priv, index, 0, 0, 1); xxx */ 897 if (priv->reg.wep_key[index].size != 0) { 898 priv->reg.wep_index = index; 899 priv->need_commit |= SME_WEP_INDEX; 900 } else { 901 return -EINVAL; 902 } 903 } 904 } 905 } 906 907 /* Commit the changes if needed */ 908 if (dwrq->flags & IW_ENCODE_MODE) 909 priv->need_commit |= SME_WEP_FLAG; 910 911 if (dwrq->flags & IW_ENCODE_OPEN) { 912 if (priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY) 913 priv->need_commit |= SME_MODE_SET; 914 915 priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; 916 } else if (dwrq->flags & IW_ENCODE_RESTRICTED) { 917 if (priv->reg.authenticate_type == AUTH_TYPE_OPEN_SYSTEM) 918 priv->need_commit |= SME_MODE_SET; 919 920 priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; 921 } 922 // return -EINPROGRESS; /* Call commit handler */ 923 if (priv->need_commit) { 924 ks_wlan_setup_parameter(priv, priv->need_commit); 925 priv->need_commit = 0; 926 } 927 return 0; 928 } 929 930 static int ks_wlan_get_encode(struct net_device *dev, 931 struct iw_request_info *info, 932 struct iw_point *dwrq, char *extra) 933 { 934 struct ks_wlan_private *priv = netdev_priv(dev); 935 char zeros[16]; 936 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 937 938 if (priv->sleep_mode == SLP_SLEEP) 939 return -EPERM; 940 941 /* for SLEEP MODE */ 942 dwrq->flags = IW_ENCODE_DISABLED; 943 944 /* Check encryption mode */ 945 switch (priv->reg.authenticate_type) { 946 case AUTH_TYPE_OPEN_SYSTEM: 947 dwrq->flags = IW_ENCODE_OPEN; 948 break; 949 case AUTH_TYPE_SHARED_KEY: 950 dwrq->flags = IW_ENCODE_RESTRICTED; 951 break; 952 } 953 954 memset(zeros, 0, sizeof(zeros)); 955 956 /* Which key do we want ? -1 -> tx index */ 957 if ((index < 0) || (index >= 4)) 958 index = priv->reg.wep_index; 959 if (priv->reg.privacy_invoked) { 960 dwrq->flags &= ~IW_ENCODE_DISABLED; 961 /* dwrq->flags |= IW_ENCODE_NOKEY; */ 962 } 963 dwrq->flags |= index + 1; 964 /* Copy the key to the user buffer */ 965 if ((index >= 0) && (index < 4)) 966 dwrq->length = priv->reg.wep_key[index].size; 967 if (dwrq->length > 16) 968 dwrq->length = 0; 969 #if 1 /* IW_ENCODE_NOKEY; */ 970 if (dwrq->length) { 971 if ((index >= 0) && (index < 4)) 972 memcpy(extra, priv->reg.wep_key[index].val, 973 dwrq->length); 974 } else { 975 memcpy(extra, zeros, dwrq->length); 976 } 977 #endif 978 return 0; 979 } 980 981 #ifndef KSC_OPNOTSUPP 982 static int ks_wlan_set_txpow(struct net_device *dev, 983 struct iw_request_info *info, 984 struct iw_param *vwrq, char *extra) 985 { 986 return -EOPNOTSUPP; /* Not Support */ 987 } 988 989 static int ks_wlan_get_txpow(struct net_device *dev, 990 struct iw_request_info *info, 991 struct iw_param *vwrq, char *extra) 992 { 993 if (priv->sleep_mode == SLP_SLEEP) 994 return -EPERM; 995 996 /* for SLEEP MODE */ 997 /* Not Support */ 998 vwrq->value = 0; 999 vwrq->disabled = (vwrq->value == 0); 1000 vwrq->fixed = 1; 1001 return 0; 1002 } 1003 1004 static int ks_wlan_set_retry(struct net_device *dev, 1005 struct iw_request_info *info, 1006 struct iw_param *vwrq, char *extra) 1007 { 1008 return -EOPNOTSUPP; /* Not Support */ 1009 } 1010 1011 static int ks_wlan_get_retry(struct net_device *dev, 1012 struct iw_request_info *info, 1013 struct iw_param *vwrq, char *extra) 1014 { 1015 if (priv->sleep_mode == SLP_SLEEP) 1016 return -EPERM; 1017 1018 /* for SLEEP MODE */ 1019 /* Not Support */ 1020 vwrq->value = 0; 1021 vwrq->disabled = (vwrq->value == 0); 1022 vwrq->fixed = 1; 1023 return 0; 1024 } 1025 #endif /* KSC_OPNOTSUPP */ 1026 1027 static int ks_wlan_get_range(struct net_device *dev, 1028 struct iw_request_info *info, 1029 struct iw_point *dwrq, char *extra) 1030 { 1031 struct ks_wlan_private *priv = netdev_priv(dev); 1032 struct iw_range *range = (struct iw_range *)extra; 1033 int i, k; 1034 1035 if (priv->sleep_mode == SLP_SLEEP) 1036 return -EPERM; 1037 1038 /* for SLEEP MODE */ 1039 dwrq->length = sizeof(struct iw_range); 1040 memset(range, 0, sizeof(*range)); 1041 range->min_nwid = 0x0000; 1042 range->max_nwid = 0x0000; 1043 range->num_channels = 14; 1044 /* Should be based on cap_rid.country to give only 1045 * what the current card support 1046 */ 1047 k = 0; 1048 for (i = 0; i < 13; i++) { /* channel 1 -- 13 */ 1049 range->freq[k].i = i + 1; /* List index */ 1050 range->freq[k].m = frequency_list[i] * 100000; 1051 range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ 1052 } 1053 range->num_frequency = k; 1054 if (priv->reg.phy_type == D_11B_ONLY_MODE || priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) { /* channel 14 */ 1055 range->freq[13].i = 14; /* List index */ 1056 range->freq[13].m = frequency_list[13] * 100000; 1057 range->freq[13].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ 1058 range->num_frequency = 14; 1059 } 1060 1061 /* Hum... Should put the right values there */ 1062 range->max_qual.qual = 100; 1063 range->max_qual.level = 256 - 128; /* 0 dBm? */ 1064 range->max_qual.noise = 256 - 128; 1065 range->sensitivity = 1; 1066 1067 if (priv->reg.phy_type == D_11B_ONLY_MODE) { 1068 range->bitrate[0] = 1e6; 1069 range->bitrate[1] = 2e6; 1070 range->bitrate[2] = 5.5e6; 1071 range->bitrate[3] = 11e6; 1072 range->num_bitrates = 4; 1073 } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ 1074 range->bitrate[0] = 1e6; 1075 range->bitrate[1] = 2e6; 1076 range->bitrate[2] = 5.5e6; 1077 range->bitrate[3] = 11e6; 1078 1079 range->bitrate[4] = 6e6; 1080 range->bitrate[5] = 9e6; 1081 range->bitrate[6] = 12e6; 1082 if (IW_MAX_BITRATES < 9) { 1083 range->bitrate[7] = 54e6; 1084 range->num_bitrates = 8; 1085 } else { 1086 range->bitrate[7] = 18e6; 1087 range->bitrate[8] = 24e6; 1088 range->bitrate[9] = 36e6; 1089 range->bitrate[10] = 48e6; 1090 range->bitrate[11] = 54e6; 1091 1092 range->num_bitrates = 12; 1093 } 1094 } 1095 1096 /* Set an indication of the max TCP throughput 1097 * in bit/s that we can expect using this interface. 1098 * May be use for QoS stuff... Jean II 1099 */ 1100 if (i > 2) 1101 range->throughput = 5000 * 1000; 1102 else 1103 range->throughput = 1500 * 1000; 1104 1105 range->min_rts = 0; 1106 range->max_rts = 2347; 1107 range->min_frag = 256; 1108 range->max_frag = 2346; 1109 1110 range->encoding_size[0] = 5; /* WEP: RC4 40 bits */ 1111 range->encoding_size[1] = 13; /* WEP: RC4 ~128 bits */ 1112 range->num_encoding_sizes = 2; 1113 range->max_encoding_tokens = 4; 1114 1115 /* power management not support */ 1116 range->pmp_flags = IW_POWER_ON; 1117 range->pmt_flags = IW_POWER_ON; 1118 range->pm_capa = 0; 1119 1120 /* Transmit Power - values are in dBm( or mW) */ 1121 range->txpower[0] = -256; 1122 range->num_txpower = 1; 1123 range->txpower_capa = IW_TXPOW_DBM; 1124 /* range->txpower_capa = IW_TXPOW_MWATT; */ 1125 1126 range->we_version_source = 21; 1127 range->we_version_compiled = WIRELESS_EXT; 1128 1129 range->retry_capa = IW_RETRY_ON; 1130 range->retry_flags = IW_RETRY_ON; 1131 range->r_time_flags = IW_RETRY_ON; 1132 1133 /* Experimental measurements - boundary 11/5.5 Mb/s 1134 * 1135 * Note : with or without the (local->rssi), results 1136 * are somewhat different. - Jean II 1137 */ 1138 range->avg_qual.qual = 50; 1139 range->avg_qual.level = 186; /* -70 dBm */ 1140 range->avg_qual.noise = 0; 1141 1142 /* Event capability (kernel + driver) */ 1143 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | 1144 IW_EVENT_CAPA_MASK(SIOCGIWAP) | 1145 IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); 1146 range->event_capa[1] = IW_EVENT_CAPA_K_1; 1147 range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVCUSTOM) | 1148 IW_EVENT_CAPA_MASK(IWEVMICHAELMICFAILURE)); 1149 1150 /* encode extension (WPA) capability */ 1151 range->enc_capa = (IW_ENC_CAPA_WPA | 1152 IW_ENC_CAPA_WPA2 | 1153 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP); 1154 return 0; 1155 } 1156 1157 static int ks_wlan_set_power(struct net_device *dev, 1158 struct iw_request_info *info, 1159 struct iw_param *vwrq, char *extra) 1160 { 1161 struct ks_wlan_private *priv = netdev_priv(dev); 1162 1163 if (priv->sleep_mode == SLP_SLEEP) 1164 return -EPERM; 1165 1166 if (vwrq->disabled) { 1167 priv->reg.power_mgmt = POWER_MGMT_ACTIVE; 1168 } else { 1169 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) 1170 priv->reg.power_mgmt = POWER_MGMT_SAVE1; 1171 else 1172 return -EINVAL; 1173 } 1174 1175 hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); 1176 1177 return 0; 1178 } 1179 1180 static int ks_wlan_get_power(struct net_device *dev, 1181 struct iw_request_info *info, 1182 struct iw_param *vwrq, char *extra) 1183 { 1184 struct ks_wlan_private *priv = netdev_priv(dev); 1185 1186 if (priv->sleep_mode == SLP_SLEEP) 1187 return -EPERM; 1188 /* for SLEEP MODE */ 1189 if (priv->reg.power_mgmt > 0) 1190 vwrq->disabled = 0; 1191 else 1192 vwrq->disabled = 1; 1193 1194 return 0; 1195 } 1196 1197 static int ks_wlan_get_iwstats(struct net_device *dev, 1198 struct iw_request_info *info, 1199 struct iw_quality *vwrq, char *extra) 1200 { 1201 struct ks_wlan_private *priv = netdev_priv(dev); 1202 1203 if (priv->sleep_mode == SLP_SLEEP) 1204 return -EPERM; 1205 /* for SLEEP MODE */ 1206 vwrq->qual = 0; /* not supported */ 1207 vwrq->level = priv->wstats.qual.level; 1208 vwrq->noise = 0; /* not supported */ 1209 vwrq->updated = 0; 1210 1211 return 0; 1212 } 1213 1214 #ifndef KSC_OPNOTSUPP 1215 1216 static int ks_wlan_set_sens(struct net_device *dev, 1217 struct iw_request_info *info, struct iw_param *vwrq, 1218 char *extra) 1219 { 1220 return -EOPNOTSUPP; /* Not Support */ 1221 } 1222 1223 static int ks_wlan_get_sens(struct net_device *dev, 1224 struct iw_request_info *info, struct iw_param *vwrq, 1225 char *extra) 1226 { 1227 /* Not Support */ 1228 vwrq->value = 0; 1229 vwrq->disabled = (vwrq->value == 0); 1230 vwrq->fixed = 1; 1231 return 0; 1232 } 1233 #endif /* KSC_OPNOTSUPP */ 1234 1235 /* Note : this is deprecated in favor of IWSCAN */ 1236 static int ks_wlan_get_aplist(struct net_device *dev, 1237 struct iw_request_info *info, 1238 struct iw_point *dwrq, char *extra) 1239 { 1240 struct ks_wlan_private *priv = netdev_priv(dev); 1241 struct sockaddr *address = (struct sockaddr *)extra; 1242 struct iw_quality qual[LOCAL_APLIST_MAX]; 1243 1244 int i; 1245 1246 if (priv->sleep_mode == SLP_SLEEP) 1247 return -EPERM; 1248 /* for SLEEP MODE */ 1249 for (i = 0; i < priv->aplist.size; i++) { 1250 memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]), 1251 ETH_ALEN); 1252 address[i].sa_family = ARPHRD_ETHER; 1253 qual[i].level = 256 - priv->aplist.ap[i].rssi; 1254 qual[i].qual = priv->aplist.ap[i].sq; 1255 qual[i].noise = 0; /* invalid noise value */ 1256 qual[i].updated = 7; 1257 } 1258 if (i) { 1259 dwrq->flags = 1; /* Should be define'd */ 1260 memcpy(extra + sizeof(struct sockaddr) * i, 1261 &qual, sizeof(struct iw_quality) * i); 1262 } 1263 dwrq->length = i; 1264 1265 return 0; 1266 } 1267 1268 static int ks_wlan_set_scan(struct net_device *dev, 1269 struct iw_request_info *info, 1270 union iwreq_data *wrqu, char *extra) 1271 { 1272 struct ks_wlan_private *priv = netdev_priv(dev); 1273 struct iw_scan_req *req = NULL; 1274 1275 if (priv->sleep_mode == SLP_SLEEP) 1276 return -EPERM; 1277 1278 /* for SLEEP MODE */ 1279 /* specified SSID SCAN */ 1280 if (wrqu->data.length == sizeof(struct iw_scan_req) && 1281 wrqu->data.flags & IW_SCAN_THIS_ESSID) { 1282 req = (struct iw_scan_req *)extra; 1283 priv->scan_ssid_len = req->essid_len; 1284 memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len); 1285 } else { 1286 priv->scan_ssid_len = 0; 1287 } 1288 1289 priv->sme_i.sme_flag |= SME_AP_SCAN; 1290 hostif_sme_enqueue(priv, SME_BSS_SCAN_REQUEST); 1291 1292 /* At this point, just return to the user. */ 1293 1294 return 0; 1295 } 1296 1297 /* 1298 * Translate scan data returned from the card to a card independent 1299 * format that the Wireless Tools will understand - Jean II 1300 */ 1301 static inline char *ks_wlan_translate_scan(struct net_device *dev, 1302 struct iw_request_info *info, 1303 char *current_ev, char *end_buf, 1304 struct local_ap_t *ap) 1305 { 1306 /* struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; */ 1307 struct iw_event iwe; /* Temporary buffer */ 1308 u16 capabilities; 1309 char *current_val; /* For rates */ 1310 int i; 1311 static const char rsn_leader[] = "rsn_ie="; 1312 static const char wpa_leader[] = "wpa_ie="; 1313 char buf0[RSN_IE_BODY_MAX * 2 + 30]; 1314 char buf1[RSN_IE_BODY_MAX * 2 + 30]; 1315 char *pbuf; 1316 /* First entry *MUST* be the AP MAC address */ 1317 iwe.cmd = SIOCGIWAP; 1318 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 1319 memcpy(iwe.u.ap_addr.sa_data, ap->bssid, ETH_ALEN); 1320 current_ev = 1321 iwe_stream_add_event(info, current_ev, end_buf, &iwe, 1322 IW_EV_ADDR_LEN); 1323 1324 /* Other entries will be displayed in the order we give them */ 1325 1326 /* Add the ESSID */ 1327 iwe.u.data.length = ap->ssid.size; 1328 if (iwe.u.data.length > 32) 1329 iwe.u.data.length = 32; 1330 iwe.cmd = SIOCGIWESSID; 1331 iwe.u.data.flags = 1; 1332 current_ev = 1333 iwe_stream_add_point(info, current_ev, end_buf, &iwe, 1334 ap->ssid.body); 1335 1336 /* Add mode */ 1337 iwe.cmd = SIOCGIWMODE; 1338 capabilities = ap->capability; 1339 if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { 1340 if (capabilities & WLAN_CAPABILITY_ESS) 1341 iwe.u.mode = IW_MODE_INFRA; 1342 else 1343 iwe.u.mode = IW_MODE_ADHOC; 1344 current_ev = 1345 iwe_stream_add_event(info, current_ev, end_buf, &iwe, 1346 IW_EV_UINT_LEN); 1347 } 1348 1349 /* Add frequency */ 1350 iwe.cmd = SIOCGIWFREQ; 1351 iwe.u.freq.m = ap->channel; 1352 iwe.u.freq.m = frequency_list[iwe.u.freq.m - 1] * 100000; 1353 iwe.u.freq.e = 1; 1354 current_ev = 1355 iwe_stream_add_event(info, current_ev, end_buf, &iwe, 1356 IW_EV_FREQ_LEN); 1357 1358 /* Add quality statistics */ 1359 iwe.cmd = IWEVQUAL; 1360 iwe.u.qual.level = 256 - ap->rssi; 1361 iwe.u.qual.qual = ap->sq; 1362 iwe.u.qual.noise = 0; /* invalid noise value */ 1363 current_ev = 1364 iwe_stream_add_event(info, current_ev, end_buf, &iwe, 1365 IW_EV_QUAL_LEN); 1366 1367 /* Add encryption capability */ 1368 iwe.cmd = SIOCGIWENCODE; 1369 if (capabilities & WLAN_CAPABILITY_PRIVACY) 1370 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; 1371 else 1372 iwe.u.data.flags = IW_ENCODE_DISABLED; 1373 iwe.u.data.length = 0; 1374 current_ev = 1375 iwe_stream_add_point(info, current_ev, end_buf, &iwe, 1376 ap->ssid.body); 1377 1378 /* Rate : stuffing multiple values in a single event require a bit 1379 * more of magic - Jean II 1380 */ 1381 current_val = current_ev + IW_EV_LCP_LEN; 1382 1383 iwe.cmd = SIOCGIWRATE; 1384 1385 /* These two flags are ignored... */ 1386 iwe.u.bitrate.fixed = 0; 1387 iwe.u.bitrate.disabled = 0; 1388 1389 /* Max 16 values */ 1390 for (i = 0; i < 16; i++) { 1391 /* NULL terminated */ 1392 if (i >= ap->rate_set.size) 1393 break; 1394 /* Bit rate given in 500 kb/s units (+ 0x80) */ 1395 iwe.u.bitrate.value = ((ap->rate_set.body[i] & 0x7f) * 500000); 1396 /* Add new value to event */ 1397 current_val = 1398 iwe_stream_add_value(info, current_ev, current_val, end_buf, 1399 &iwe, IW_EV_PARAM_LEN); 1400 } 1401 /* Check if we added any event */ 1402 if ((current_val - current_ev) > IW_EV_LCP_LEN) 1403 current_ev = current_val; 1404 1405 #define GENERIC_INFO_ELEM_ID 0xdd 1406 #define RSN_INFO_ELEM_ID 0x30 1407 if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) { 1408 pbuf = &buf0[0]; 1409 memset(&iwe, 0, sizeof(iwe)); 1410 iwe.cmd = IWEVCUSTOM; 1411 memcpy(buf0, rsn_leader, sizeof(rsn_leader) - 1); 1412 iwe.u.data.length += sizeof(rsn_leader) - 1; 1413 pbuf += sizeof(rsn_leader) - 1; 1414 1415 pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.id); 1416 pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.size); 1417 iwe.u.data.length += 4; 1418 1419 for (i = 0; i < ap->rsn_ie.size; i++) 1420 pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.body[i]); 1421 iwe.u.data.length += (ap->rsn_ie.size) * 2; 1422 1423 netdev_dbg(dev, "ap->rsn.size=%d\n", ap->rsn_ie.size); 1424 1425 current_ev = 1426 iwe_stream_add_point(info, current_ev, end_buf, &iwe, 1427 &buf0[0]); 1428 } 1429 if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) { 1430 pbuf = &buf1[0]; 1431 memset(&iwe, 0, sizeof(iwe)); 1432 iwe.cmd = IWEVCUSTOM; 1433 memcpy(buf1, wpa_leader, sizeof(wpa_leader) - 1); 1434 iwe.u.data.length += sizeof(wpa_leader) - 1; 1435 pbuf += sizeof(wpa_leader) - 1; 1436 1437 pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.id); 1438 pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.size); 1439 iwe.u.data.length += 4; 1440 1441 for (i = 0; i < ap->wpa_ie.size; i++) 1442 pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.body[i]); 1443 iwe.u.data.length += (ap->wpa_ie.size) * 2; 1444 1445 netdev_dbg(dev, "ap->rsn.size=%d\n", ap->wpa_ie.size); 1446 netdev_dbg(dev, "iwe.u.data.length=%d\n", iwe.u.data.length); 1447 1448 current_ev = 1449 iwe_stream_add_point(info, current_ev, end_buf, &iwe, 1450 &buf1[0]); 1451 } 1452 1453 /* The other data in the scan result are not really 1454 * interesting, so for now drop it - Jean II 1455 */ 1456 return current_ev; 1457 } 1458 1459 static int ks_wlan_get_scan(struct net_device *dev, 1460 struct iw_request_info *info, struct iw_point *dwrq, 1461 char *extra) 1462 { 1463 struct ks_wlan_private *priv = netdev_priv(dev); 1464 int i; 1465 char *current_ev = extra; 1466 1467 if (priv->sleep_mode == SLP_SLEEP) 1468 return -EPERM; 1469 /* for SLEEP MODE */ 1470 if (priv->sme_i.sme_flag & SME_AP_SCAN) 1471 return -EAGAIN; 1472 1473 if (priv->aplist.size == 0) { 1474 /* Client error, no scan results... 1475 * The caller need to restart the scan. 1476 */ 1477 return -ENODATA; 1478 } 1479 1480 /* Read and parse all entries */ 1481 for (i = 0; i < priv->aplist.size; i++) { 1482 if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { 1483 dwrq->length = 0; 1484 return -E2BIG; 1485 } 1486 /* Translate to WE format this entry */ 1487 current_ev = ks_wlan_translate_scan(dev, info, current_ev, 1488 extra + dwrq->length, 1489 &priv->aplist.ap[i]); 1490 } 1491 /* Length of data */ 1492 dwrq->length = (current_ev - extra); 1493 dwrq->flags = 0; 1494 1495 return 0; 1496 } 1497 1498 /* called after a bunch of SET operations */ 1499 static int ks_wlan_config_commit(struct net_device *dev, 1500 struct iw_request_info *info, void *zwrq, 1501 char *extra) 1502 { 1503 struct ks_wlan_private *priv = netdev_priv(dev); 1504 1505 if (!priv->need_commit) 1506 return 0; 1507 1508 ks_wlan_setup_parameter(priv, priv->need_commit); 1509 priv->need_commit = 0; 1510 return 0; 1511 } 1512 1513 /* set association ie params */ 1514 static int ks_wlan_set_genie(struct net_device *dev, 1515 struct iw_request_info *info, 1516 struct iw_point *dwrq, char *extra) 1517 { 1518 struct ks_wlan_private *priv = netdev_priv(dev); 1519 1520 if (priv->sleep_mode == SLP_SLEEP) 1521 return -EPERM; 1522 /* for SLEEP MODE */ 1523 return 0; 1524 // return -EOPNOTSUPP; 1525 } 1526 1527 static int ks_wlan_set_auth_mode(struct net_device *dev, 1528 struct iw_request_info *info, 1529 struct iw_param *vwrq, char *extra) 1530 { 1531 struct ks_wlan_private *priv = netdev_priv(dev); 1532 int index = (vwrq->flags & IW_AUTH_INDEX); 1533 int value = vwrq->value; 1534 1535 if (priv->sleep_mode == SLP_SLEEP) 1536 return -EPERM; 1537 /* for SLEEP MODE */ 1538 switch (index) { 1539 case IW_AUTH_WPA_VERSION: /* 0 */ 1540 switch (value) { 1541 case IW_AUTH_WPA_VERSION_DISABLED: 1542 priv->wpa.version = value; 1543 if (priv->wpa.rsn_enabled) 1544 priv->wpa.rsn_enabled = 0; 1545 priv->need_commit |= SME_RSN; 1546 break; 1547 case IW_AUTH_WPA_VERSION_WPA: 1548 case IW_AUTH_WPA_VERSION_WPA2: 1549 priv->wpa.version = value; 1550 if (!(priv->wpa.rsn_enabled)) 1551 priv->wpa.rsn_enabled = 1; 1552 priv->need_commit |= SME_RSN; 1553 break; 1554 default: 1555 return -EOPNOTSUPP; 1556 } 1557 break; 1558 case IW_AUTH_CIPHER_PAIRWISE: /* 1 */ 1559 switch (value) { 1560 case IW_AUTH_CIPHER_NONE: 1561 if (priv->reg.privacy_invoked) { 1562 priv->reg.privacy_invoked = 0x00; 1563 priv->need_commit |= SME_WEP_FLAG; 1564 } 1565 break; 1566 case IW_AUTH_CIPHER_WEP40: 1567 case IW_AUTH_CIPHER_TKIP: 1568 case IW_AUTH_CIPHER_CCMP: 1569 case IW_AUTH_CIPHER_WEP104: 1570 if (!priv->reg.privacy_invoked) { 1571 priv->reg.privacy_invoked = 0x01; 1572 priv->need_commit |= SME_WEP_FLAG; 1573 } 1574 priv->wpa.pairwise_suite = value; 1575 priv->need_commit |= SME_RSN_UNICAST; 1576 break; 1577 default: 1578 return -EOPNOTSUPP; 1579 } 1580 break; 1581 case IW_AUTH_CIPHER_GROUP: /* 2 */ 1582 switch (value) { 1583 case IW_AUTH_CIPHER_NONE: 1584 if (priv->reg.privacy_invoked) { 1585 priv->reg.privacy_invoked = 0x00; 1586 priv->need_commit |= SME_WEP_FLAG; 1587 } 1588 break; 1589 case IW_AUTH_CIPHER_WEP40: 1590 case IW_AUTH_CIPHER_TKIP: 1591 case IW_AUTH_CIPHER_CCMP: 1592 case IW_AUTH_CIPHER_WEP104: 1593 if (!priv->reg.privacy_invoked) { 1594 priv->reg.privacy_invoked = 0x01; 1595 priv->need_commit |= SME_WEP_FLAG; 1596 } 1597 priv->wpa.group_suite = value; 1598 priv->need_commit |= SME_RSN_MULTICAST; 1599 break; 1600 default: 1601 return -EOPNOTSUPP; 1602 } 1603 break; 1604 case IW_AUTH_KEY_MGMT: /* 3 */ 1605 switch (value) { 1606 case IW_AUTH_KEY_MGMT_802_1X: 1607 case IW_AUTH_KEY_MGMT_PSK: 1608 case 0: /* NONE or 802_1X_NO_WPA */ 1609 case 4: /* WPA_NONE */ 1610 priv->wpa.key_mgmt_suite = value; 1611 priv->need_commit |= SME_RSN_AUTH; 1612 break; 1613 default: 1614 return -EOPNOTSUPP; 1615 } 1616 break; 1617 case IW_AUTH_80211_AUTH_ALG: /* 6 */ 1618 switch (value) { 1619 case IW_AUTH_ALG_OPEN_SYSTEM: 1620 priv->wpa.auth_alg = value; 1621 priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; 1622 break; 1623 case IW_AUTH_ALG_SHARED_KEY: 1624 priv->wpa.auth_alg = value; 1625 priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; 1626 break; 1627 case IW_AUTH_ALG_LEAP: 1628 default: 1629 return -EOPNOTSUPP; 1630 } 1631 priv->need_commit |= SME_MODE_SET; 1632 break; 1633 case IW_AUTH_WPA_ENABLED: /* 7 */ 1634 priv->wpa.wpa_enabled = value; 1635 break; 1636 case IW_AUTH_PRIVACY_INVOKED: /* 10 */ 1637 if ((value && !priv->reg.privacy_invoked) || 1638 (!value && priv->reg.privacy_invoked)) { 1639 priv->reg.privacy_invoked = value ? 0x01 : 0x00; 1640 priv->need_commit |= SME_WEP_FLAG; 1641 } 1642 break; 1643 case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* 4 */ 1644 case IW_AUTH_TKIP_COUNTERMEASURES: /* 5 */ 1645 case IW_AUTH_DROP_UNENCRYPTED: /* 8 */ 1646 case IW_AUTH_ROAMING_CONTROL: /* 9 */ 1647 default: 1648 break; 1649 } 1650 1651 /* return -EINPROGRESS; */ 1652 if (priv->need_commit) { 1653 ks_wlan_setup_parameter(priv, priv->need_commit); 1654 priv->need_commit = 0; 1655 } 1656 return 0; 1657 } 1658 1659 static int ks_wlan_get_auth_mode(struct net_device *dev, 1660 struct iw_request_info *info, 1661 struct iw_param *vwrq, char *extra) 1662 { 1663 struct ks_wlan_private *priv = netdev_priv(dev); 1664 int index = (vwrq->flags & IW_AUTH_INDEX); 1665 1666 if (priv->sleep_mode == SLP_SLEEP) 1667 return -EPERM; 1668 1669 /* for SLEEP MODE */ 1670 /* WPA (not used ?? wpa_supplicant) */ 1671 switch (index) { 1672 case IW_AUTH_WPA_VERSION: 1673 vwrq->value = priv->wpa.version; 1674 break; 1675 case IW_AUTH_CIPHER_PAIRWISE: 1676 vwrq->value = priv->wpa.pairwise_suite; 1677 break; 1678 case IW_AUTH_CIPHER_GROUP: 1679 vwrq->value = priv->wpa.group_suite; 1680 break; 1681 case IW_AUTH_KEY_MGMT: 1682 vwrq->value = priv->wpa.key_mgmt_suite; 1683 break; 1684 case IW_AUTH_80211_AUTH_ALG: 1685 vwrq->value = priv->wpa.auth_alg; 1686 break; 1687 case IW_AUTH_WPA_ENABLED: 1688 vwrq->value = priv->wpa.rsn_enabled; 1689 break; 1690 case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* OK??? */ 1691 case IW_AUTH_TKIP_COUNTERMEASURES: 1692 case IW_AUTH_DROP_UNENCRYPTED: 1693 default: 1694 /* return -EOPNOTSUPP; */ 1695 break; 1696 } 1697 return 0; 1698 } 1699 1700 /* set encoding token & mode (WPA)*/ 1701 static int ks_wlan_set_encode_ext(struct net_device *dev, 1702 struct iw_request_info *info, 1703 struct iw_point *dwrq, char *extra) 1704 { 1705 struct ks_wlan_private *priv = netdev_priv(dev); 1706 struct iw_encode_ext *enc; 1707 int index = dwrq->flags & IW_ENCODE_INDEX; 1708 unsigned int commit = 0; 1709 struct wpa_key_t *key; 1710 1711 enc = (struct iw_encode_ext *)extra; 1712 if (!enc) 1713 return -EINVAL; 1714 1715 if (priv->sleep_mode == SLP_SLEEP) 1716 return -EPERM; 1717 1718 /* for SLEEP MODE */ 1719 if (index < 1 || index > 4) 1720 return -EINVAL; 1721 index--; 1722 key = &priv->wpa.key[index]; 1723 1724 if (dwrq->flags & IW_ENCODE_DISABLED) 1725 key->key_len = 0; 1726 1727 key->ext_flags = enc->ext_flags; 1728 if (enc->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { 1729 priv->wpa.txkey = index; 1730 commit |= SME_WEP_INDEX; 1731 } else if (enc->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { 1732 memcpy(&key->rx_seq[0], &enc->rx_seq[0], IW_ENCODE_SEQ_MAX_SIZE); 1733 } 1734 1735 memcpy(&key->addr.sa_data[0], &enc->addr.sa_data[0], ETH_ALEN); 1736 1737 switch (enc->alg) { 1738 case IW_ENCODE_ALG_NONE: 1739 if (priv->reg.privacy_invoked) { 1740 priv->reg.privacy_invoked = 0x00; 1741 commit |= SME_WEP_FLAG; 1742 } 1743 key->key_len = 0; 1744 1745 break; 1746 case IW_ENCODE_ALG_WEP: 1747 case IW_ENCODE_ALG_CCMP: 1748 if (!priv->reg.privacy_invoked) { 1749 priv->reg.privacy_invoked = 0x01; 1750 commit |= SME_WEP_FLAG; 1751 } 1752 if (enc->key_len) { 1753 memcpy(&key->key_val[0], &enc->key[0], enc->key_len); 1754 key->key_len = enc->key_len; 1755 commit |= (SME_WEP_VAL1 << index); 1756 } 1757 break; 1758 case IW_ENCODE_ALG_TKIP: 1759 if (!priv->reg.privacy_invoked) { 1760 priv->reg.privacy_invoked = 0x01; 1761 commit |= SME_WEP_FLAG; 1762 } 1763 if (enc->key_len == 32) { 1764 memcpy(&key->key_val[0], &enc->key[0], enc->key_len - 16); 1765 key->key_len = enc->key_len - 16; 1766 if (priv->wpa.key_mgmt_suite == 4) { /* WPA_NONE */ 1767 memcpy(&key->tx_mic_key[0], &enc->key[16], 8); 1768 memcpy(&key->rx_mic_key[0], &enc->key[16], 8); 1769 } else { 1770 memcpy(&key->tx_mic_key[0], &enc->key[16], 8); 1771 memcpy(&key->rx_mic_key[0], &enc->key[24], 8); 1772 } 1773 commit |= (SME_WEP_VAL1 << index); 1774 } 1775 break; 1776 default: 1777 return -EINVAL; 1778 } 1779 key->alg = enc->alg; 1780 1781 if (commit) { 1782 if (commit & SME_WEP_INDEX) 1783 hostif_sme_enqueue(priv, SME_SET_TXKEY); 1784 if (commit & SME_WEP_VAL_MASK) 1785 hostif_sme_enqueue(priv, SME_SET_KEY1 + index); 1786 if (commit & SME_WEP_FLAG) 1787 hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); 1788 } 1789 1790 return 0; 1791 } 1792 1793 /* get encoding token & mode (WPA)*/ 1794 static int ks_wlan_get_encode_ext(struct net_device *dev, 1795 struct iw_request_info *info, 1796 struct iw_point *dwrq, char *extra) 1797 { 1798 struct ks_wlan_private *priv = netdev_priv(dev); 1799 1800 if (priv->sleep_mode == SLP_SLEEP) 1801 return -EPERM; 1802 1803 /* for SLEEP MODE */ 1804 /* WPA (not used ?? wpa_supplicant) 1805 * struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; 1806 * struct iw_encode_ext *enc; 1807 * enc = (struct iw_encode_ext *)extra; 1808 * int index = dwrq->flags & IW_ENCODE_INDEX; 1809 * WPA (not used ?? wpa_supplicant) 1810 */ 1811 return 0; 1812 } 1813 1814 static int ks_wlan_set_pmksa(struct net_device *dev, 1815 struct iw_request_info *info, 1816 struct iw_point *dwrq, char *extra) 1817 { 1818 struct ks_wlan_private *priv = netdev_priv(dev); 1819 struct iw_pmksa *pmksa; 1820 int i; 1821 struct pmk_t *pmk; 1822 struct list_head *ptr; 1823 1824 if (priv->sleep_mode == SLP_SLEEP) 1825 return -EPERM; 1826 1827 /* for SLEEP MODE */ 1828 if (!extra) 1829 return -EINVAL; 1830 1831 pmksa = (struct iw_pmksa *)extra; 1832 1833 switch (pmksa->cmd) { 1834 case IW_PMKSA_ADD: 1835 if (list_empty(&priv->pmklist.head)) { /* new list */ 1836 for (i = 0; i < PMK_LIST_MAX; i++) { 1837 pmk = &priv->pmklist.pmk[i]; 1838 if (memcmp("\x00\x00\x00\x00\x00\x00", 1839 pmk->bssid, ETH_ALEN) == 0) 1840 break; /* loop */ 1841 } 1842 memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); 1843 memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); 1844 list_add(&pmk->list, &priv->pmklist.head); 1845 priv->pmklist.size++; 1846 break; /* case */ 1847 } 1848 /* search cache data */ 1849 list_for_each(ptr, &priv->pmklist.head) { 1850 pmk = list_entry(ptr, struct pmk_t, list); 1851 if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) { 1852 memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); 1853 list_move(&pmk->list, &priv->pmklist.head); 1854 break; /* list_for_each */ 1855 } 1856 } 1857 if (ptr != &priv->pmklist.head) /* not find address. */ 1858 break; /* case */ 1859 1860 if (priv->pmklist.size < PMK_LIST_MAX) { /* new cache data */ 1861 for (i = 0; i < PMK_LIST_MAX; i++) { 1862 pmk = &priv->pmklist.pmk[i]; 1863 if (memcmp("\x00\x00\x00\x00\x00\x00", 1864 pmk->bssid, ETH_ALEN) == 0) 1865 break; /* loop */ 1866 } 1867 memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); 1868 memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); 1869 list_add(&pmk->list, &priv->pmklist.head); 1870 priv->pmklist.size++; 1871 } else { /* overwrite old cache data */ 1872 pmk = list_entry(priv->pmklist.head.prev, struct pmk_t, 1873 list); 1874 memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); 1875 memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); 1876 list_move(&pmk->list, &priv->pmklist.head); 1877 } 1878 break; 1879 case IW_PMKSA_REMOVE: 1880 if (list_empty(&priv->pmklist.head)) { /* list empty */ 1881 return -EINVAL; 1882 } 1883 /* search cache data */ 1884 list_for_each(ptr, &priv->pmklist.head) { 1885 pmk = list_entry(ptr, struct pmk_t, list); 1886 if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) { 1887 eth_zero_addr(pmk->bssid); 1888 memset(pmk->pmkid, 0, IW_PMKID_LEN); 1889 list_del_init(&pmk->list); 1890 break; 1891 } 1892 } 1893 if (ptr == &priv->pmklist.head) { /* not find address. */ 1894 return 0; 1895 } 1896 1897 break; 1898 case IW_PMKSA_FLUSH: 1899 memset(&priv->pmklist, 0, sizeof(priv->pmklist)); 1900 INIT_LIST_HEAD(&priv->pmklist.head); 1901 for (i = 0; i < PMK_LIST_MAX; i++) 1902 INIT_LIST_HEAD(&priv->pmklist.pmk[i].list); 1903 break; 1904 default: 1905 return -EINVAL; 1906 } 1907 1908 hostif_sme_enqueue(priv, SME_SET_PMKSA); 1909 return 0; 1910 } 1911 1912 static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev) 1913 { 1914 struct ks_wlan_private *priv = netdev_priv(dev); 1915 struct iw_statistics *wstats = &priv->wstats; 1916 1917 if (!atomic_read(&update_phyinfo)) { 1918 if (priv->dev_state < DEVICE_STATE_READY) 1919 return NULL; /* not finished initialize */ 1920 else 1921 return wstats; 1922 } 1923 1924 /* Packets discarded in the wireless adapter due to wireless 1925 * specific problems 1926 */ 1927 wstats->discard.nwid = 0; /* Rx invalid nwid */ 1928 wstats->discard.code = 0; /* Rx invalid crypt */ 1929 wstats->discard.fragment = 0; /* Rx invalid frag */ 1930 wstats->discard.retries = 0; /* Tx excessive retries */ 1931 wstats->discard.misc = 0; /* Invalid misc */ 1932 wstats->miss.beacon = 0; /* Missed beacon */ 1933 1934 return wstats; 1935 } 1936 1937 static int ks_wlan_set_stop_request(struct net_device *dev, 1938 struct iw_request_info *info, __u32 *uwrq, 1939 char *extra) 1940 { 1941 struct ks_wlan_private *priv = netdev_priv(dev); 1942 1943 if (priv->sleep_mode == SLP_SLEEP) 1944 return -EPERM; 1945 1946 /* for SLEEP MODE */ 1947 if (!(*uwrq)) 1948 return -EINVAL; 1949 1950 hostif_sme_enqueue(priv, SME_STOP_REQUEST); 1951 return 0; 1952 } 1953 1954 #include <linux/ieee80211.h> 1955 static int ks_wlan_set_mlme(struct net_device *dev, 1956 struct iw_request_info *info, struct iw_point *dwrq, 1957 char *extra) 1958 { 1959 struct ks_wlan_private *priv = netdev_priv(dev); 1960 struct iw_mlme *mlme = (struct iw_mlme *)extra; 1961 __u32 mode; 1962 1963 if (priv->sleep_mode == SLP_SLEEP) 1964 return -EPERM; 1965 1966 /* for SLEEP MODE */ 1967 switch (mlme->cmd) { 1968 case IW_MLME_DEAUTH: 1969 if (mlme->reason_code == WLAN_REASON_MIC_FAILURE) 1970 return 0; 1971 /* fall through */ 1972 case IW_MLME_DISASSOC: 1973 mode = 1; 1974 return ks_wlan_set_stop_request(dev, NULL, &mode, NULL); 1975 default: 1976 return -EOPNOTSUPP; /* Not Support */ 1977 } 1978 } 1979 1980 static int ks_wlan_get_firmware_version(struct net_device *dev, 1981 struct iw_request_info *info, 1982 struct iw_point *dwrq, char *extra) 1983 { 1984 struct ks_wlan_private *priv = netdev_priv(dev); 1985 1986 strcpy(extra, priv->firmware_version); 1987 dwrq->length = priv->version_size + 1; 1988 return 0; 1989 } 1990 1991 static int ks_wlan_set_preamble(struct net_device *dev, 1992 struct iw_request_info *info, __u32 *uwrq, 1993 char *extra) 1994 { 1995 struct ks_wlan_private *priv = netdev_priv(dev); 1996 1997 if (priv->sleep_mode == SLP_SLEEP) 1998 return -EPERM; 1999 2000 /* for SLEEP MODE */ 2001 if (*uwrq == LONG_PREAMBLE) { /* 0 */ 2002 priv->reg.preamble = LONG_PREAMBLE; 2003 } else if (*uwrq == SHORT_PREAMBLE) { /* 1 */ 2004 priv->reg.preamble = SHORT_PREAMBLE; 2005 } else { 2006 return -EINVAL; 2007 } 2008 2009 priv->need_commit |= SME_MODE_SET; 2010 return -EINPROGRESS; /* Call commit handler */ 2011 } 2012 2013 static int ks_wlan_get_preamble(struct net_device *dev, 2014 struct iw_request_info *info, __u32 *uwrq, 2015 char *extra) 2016 { 2017 struct ks_wlan_private *priv = netdev_priv(dev); 2018 2019 if (priv->sleep_mode == SLP_SLEEP) 2020 return -EPERM; 2021 2022 /* for SLEEP MODE */ 2023 *uwrq = priv->reg.preamble; 2024 return 0; 2025 } 2026 2027 static int ks_wlan_set_power_mgmt(struct net_device *dev, 2028 struct iw_request_info *info, __u32 *uwrq, 2029 char *extra) 2030 { 2031 struct ks_wlan_private *priv = netdev_priv(dev); 2032 2033 if (priv->sleep_mode == SLP_SLEEP) 2034 return -EPERM; 2035 2036 /* for SLEEP MODE */ 2037 if (*uwrq == POWER_MGMT_ACTIVE) { /* 0 */ 2038 priv->reg.power_mgmt = POWER_MGMT_ACTIVE; 2039 } else if (*uwrq == POWER_MGMT_SAVE1) { /* 1 */ 2040 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) 2041 priv->reg.power_mgmt = POWER_MGMT_SAVE1; 2042 else 2043 return -EINVAL; 2044 } else if (*uwrq == POWER_MGMT_SAVE2) { /* 2 */ 2045 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) 2046 priv->reg.power_mgmt = POWER_MGMT_SAVE2; 2047 else 2048 return -EINVAL; 2049 } else { 2050 return -EINVAL; 2051 } 2052 2053 hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); 2054 2055 return 0; 2056 } 2057 2058 static int ks_wlan_get_power_mgmt(struct net_device *dev, 2059 struct iw_request_info *info, __u32 *uwrq, 2060 char *extra) 2061 { 2062 struct ks_wlan_private *priv = netdev_priv(dev); 2063 2064 if (priv->sleep_mode == SLP_SLEEP) 2065 return -EPERM; 2066 2067 /* for SLEEP MODE */ 2068 *uwrq = priv->reg.power_mgmt; 2069 return 0; 2070 } 2071 2072 static int ks_wlan_set_scan_type(struct net_device *dev, 2073 struct iw_request_info *info, __u32 *uwrq, 2074 char *extra) 2075 { 2076 struct ks_wlan_private *priv = netdev_priv(dev); 2077 2078 if (priv->sleep_mode == SLP_SLEEP) 2079 return -EPERM; 2080 /* for SLEEP MODE */ 2081 if (*uwrq == ACTIVE_SCAN) { /* 0 */ 2082 priv->reg.scan_type = ACTIVE_SCAN; 2083 } else if (*uwrq == PASSIVE_SCAN) { /* 1 */ 2084 priv->reg.scan_type = PASSIVE_SCAN; 2085 } else { 2086 return -EINVAL; 2087 } 2088 2089 return 0; 2090 } 2091 2092 static int ks_wlan_get_scan_type(struct net_device *dev, 2093 struct iw_request_info *info, __u32 *uwrq, 2094 char *extra) 2095 { 2096 struct ks_wlan_private *priv = netdev_priv(dev); 2097 2098 if (priv->sleep_mode == SLP_SLEEP) 2099 return -EPERM; 2100 /* for SLEEP MODE */ 2101 *uwrq = priv->reg.scan_type; 2102 return 0; 2103 } 2104 2105 static int ks_wlan_set_beacon_lost(struct net_device *dev, 2106 struct iw_request_info *info, __u32 *uwrq, 2107 char *extra) 2108 { 2109 struct ks_wlan_private *priv = netdev_priv(dev); 2110 2111 if (priv->sleep_mode == SLP_SLEEP) 2112 return -EPERM; 2113 /* for SLEEP MODE */ 2114 if (*uwrq >= BEACON_LOST_COUNT_MIN && *uwrq <= BEACON_LOST_COUNT_MAX) 2115 priv->reg.beacon_lost_count = *uwrq; 2116 else 2117 return -EINVAL; 2118 2119 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) { 2120 priv->need_commit |= SME_MODE_SET; 2121 return -EINPROGRESS; /* Call commit handler */ 2122 } else { 2123 return 0; 2124 } 2125 } 2126 2127 static int ks_wlan_get_beacon_lost(struct net_device *dev, 2128 struct iw_request_info *info, __u32 *uwrq, 2129 char *extra) 2130 { 2131 struct ks_wlan_private *priv = netdev_priv(dev); 2132 2133 if (priv->sleep_mode == SLP_SLEEP) 2134 return -EPERM; 2135 /* for SLEEP MODE */ 2136 *uwrq = priv->reg.beacon_lost_count; 2137 return 0; 2138 } 2139 2140 static int ks_wlan_set_phy_type(struct net_device *dev, 2141 struct iw_request_info *info, __u32 *uwrq, 2142 char *extra) 2143 { 2144 struct ks_wlan_private *priv = netdev_priv(dev); 2145 2146 if (priv->sleep_mode == SLP_SLEEP) 2147 return -EPERM; 2148 /* for SLEEP MODE */ 2149 if (*uwrq == D_11B_ONLY_MODE) { /* 0 */ 2150 priv->reg.phy_type = D_11B_ONLY_MODE; 2151 } else if (*uwrq == D_11G_ONLY_MODE) { /* 1 */ 2152 priv->reg.phy_type = D_11G_ONLY_MODE; 2153 } else if (*uwrq == D_11BG_COMPATIBLE_MODE) { /* 2 */ 2154 priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; 2155 } else { 2156 return -EINVAL; 2157 } 2158 2159 priv->need_commit |= SME_MODE_SET; 2160 return -EINPROGRESS; /* Call commit handler */ 2161 } 2162 2163 static int ks_wlan_get_phy_type(struct net_device *dev, 2164 struct iw_request_info *info, __u32 *uwrq, 2165 char *extra) 2166 { 2167 struct ks_wlan_private *priv = netdev_priv(dev); 2168 2169 if (priv->sleep_mode == SLP_SLEEP) 2170 return -EPERM; 2171 /* for SLEEP MODE */ 2172 *uwrq = priv->reg.phy_type; 2173 return 0; 2174 } 2175 2176 static int ks_wlan_set_cts_mode(struct net_device *dev, 2177 struct iw_request_info *info, __u32 *uwrq, 2178 char *extra) 2179 { 2180 struct ks_wlan_private *priv = netdev_priv(dev); 2181 2182 if (priv->sleep_mode == SLP_SLEEP) 2183 return -EPERM; 2184 /* for SLEEP MODE */ 2185 if (*uwrq == CTS_MODE_FALSE) { /* 0 */ 2186 priv->reg.cts_mode = CTS_MODE_FALSE; 2187 } else if (*uwrq == CTS_MODE_TRUE) { /* 1 */ 2188 if (priv->reg.phy_type == D_11G_ONLY_MODE || 2189 priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) { 2190 priv->reg.cts_mode = CTS_MODE_TRUE; 2191 } else { 2192 priv->reg.cts_mode = CTS_MODE_FALSE; 2193 } 2194 } else { 2195 return -EINVAL; 2196 } 2197 2198 priv->need_commit |= SME_MODE_SET; 2199 return -EINPROGRESS; /* Call commit handler */ 2200 } 2201 2202 static int ks_wlan_get_cts_mode(struct net_device *dev, 2203 struct iw_request_info *info, __u32 *uwrq, 2204 char *extra) 2205 { 2206 struct ks_wlan_private *priv = netdev_priv(dev); 2207 2208 if (priv->sleep_mode == SLP_SLEEP) 2209 return -EPERM; 2210 /* for SLEEP MODE */ 2211 *uwrq = priv->reg.cts_mode; 2212 return 0; 2213 } 2214 2215 static int ks_wlan_set_sleep_mode(struct net_device *dev, 2216 struct iw_request_info *info, 2217 __u32 *uwrq, char *extra) 2218 { 2219 struct ks_wlan_private *priv = netdev_priv(dev); 2220 2221 if (*uwrq == SLP_SLEEP) { 2222 priv->sleep_mode = *uwrq; 2223 netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode); 2224 2225 hostif_sme_enqueue(priv, SME_STOP_REQUEST); 2226 hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); 2227 2228 } else if (*uwrq == SLP_ACTIVE) { 2229 priv->sleep_mode = *uwrq; 2230 netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode); 2231 hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); 2232 } else { 2233 netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq); 2234 return -EINVAL; 2235 } 2236 2237 return 0; 2238 } 2239 2240 static int ks_wlan_get_sleep_mode(struct net_device *dev, 2241 struct iw_request_info *info, 2242 __u32 *uwrq, char *extra) 2243 { 2244 struct ks_wlan_private *priv = netdev_priv(dev); 2245 2246 *uwrq = priv->sleep_mode; 2247 2248 return 0; 2249 } 2250 2251 #ifdef WPS 2252 2253 static int ks_wlan_set_wps_enable(struct net_device *dev, 2254 struct iw_request_info *info, __u32 *uwrq, 2255 char *extra) 2256 { 2257 struct ks_wlan_private *priv = netdev_priv(dev); 2258 2259 if (priv->sleep_mode == SLP_SLEEP) 2260 return -EPERM; 2261 /* for SLEEP MODE */ 2262 if (*uwrq == 0 || *uwrq == 1) 2263 priv->wps.wps_enabled = *uwrq; 2264 else 2265 return -EINVAL; 2266 2267 hostif_sme_enqueue(priv, SME_WPS_ENABLE_REQUEST); 2268 2269 return 0; 2270 } 2271 2272 static int ks_wlan_get_wps_enable(struct net_device *dev, 2273 struct iw_request_info *info, __u32 *uwrq, 2274 char *extra) 2275 { 2276 struct ks_wlan_private *priv = netdev_priv(dev); 2277 2278 if (priv->sleep_mode == SLP_SLEEP) 2279 return -EPERM; 2280 /* for SLEEP MODE */ 2281 *uwrq = priv->wps.wps_enabled; 2282 netdev_info(dev, "return=%d\n", *uwrq); 2283 2284 return 0; 2285 } 2286 2287 static int ks_wlan_set_wps_probe_req(struct net_device *dev, 2288 struct iw_request_info *info, 2289 struct iw_point *dwrq, char *extra) 2290 { 2291 u8 *p = extra; 2292 unsigned char len; 2293 struct ks_wlan_private *priv = netdev_priv(dev); 2294 2295 if (priv->sleep_mode == SLP_SLEEP) 2296 return -EPERM; 2297 2298 /* length check */ 2299 if (p[1] + 2 != dwrq->length || dwrq->length > 256) 2300 return -EINVAL; 2301 2302 priv->wps.ielen = p[1] + 2 + 1; /* IE header + IE + sizeof(len) */ 2303 len = p[1] + 2; /* IE header + IE */ 2304 2305 memcpy(priv->wps.ie, &len, sizeof(len)); 2306 p = memcpy(priv->wps.ie + 1, p, len); 2307 2308 netdev_dbg(dev, "%d(%#x): %02X %02X %02X %02X ... %02X %02X %02X\n", 2309 priv->wps.ielen, priv->wps.ielen, p[0], p[1], p[2], p[3], 2310 p[priv->wps.ielen - 3], p[priv->wps.ielen - 2], 2311 p[priv->wps.ielen - 1]); 2312 2313 hostif_sme_enqueue(priv, SME_WPS_PROBE_REQUEST); 2314 2315 return 0; 2316 } 2317 #endif /* WPS */ 2318 2319 static int ks_wlan_set_tx_gain(struct net_device *dev, 2320 struct iw_request_info *info, __u32 *uwrq, 2321 char *extra) 2322 { 2323 struct ks_wlan_private *priv = netdev_priv(dev); 2324 2325 if (priv->sleep_mode == SLP_SLEEP) 2326 return -EPERM; 2327 /* for SLEEP MODE */ 2328 if (*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ 2329 priv->gain.tx_gain = (uint8_t)*uwrq; 2330 else 2331 return -EINVAL; 2332 2333 if (priv->gain.tx_gain < 0xFF) 2334 priv->gain.tx_mode = 1; 2335 else 2336 priv->gain.tx_mode = 0; 2337 2338 hostif_sme_enqueue(priv, SME_SET_GAIN); 2339 return 0; 2340 } 2341 2342 static int ks_wlan_get_tx_gain(struct net_device *dev, 2343 struct iw_request_info *info, __u32 *uwrq, 2344 char *extra) 2345 { 2346 struct ks_wlan_private *priv = netdev_priv(dev); 2347 2348 if (priv->sleep_mode == SLP_SLEEP) 2349 return -EPERM; 2350 /* for SLEEP MODE */ 2351 *uwrq = priv->gain.tx_gain; 2352 hostif_sme_enqueue(priv, SME_GET_GAIN); 2353 return 0; 2354 } 2355 2356 static int ks_wlan_set_rx_gain(struct net_device *dev, 2357 struct iw_request_info *info, __u32 *uwrq, 2358 char *extra) 2359 { 2360 struct ks_wlan_private *priv = netdev_priv(dev); 2361 2362 if (priv->sleep_mode == SLP_SLEEP) 2363 return -EPERM; 2364 /* for SLEEP MODE */ 2365 if (*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ 2366 priv->gain.rx_gain = (uint8_t)*uwrq; 2367 else 2368 return -EINVAL; 2369 2370 if (priv->gain.rx_gain < 0xFF) 2371 priv->gain.rx_mode = 1; 2372 else 2373 priv->gain.rx_mode = 0; 2374 2375 hostif_sme_enqueue(priv, SME_SET_GAIN); 2376 return 0; 2377 } 2378 2379 static int ks_wlan_get_rx_gain(struct net_device *dev, 2380 struct iw_request_info *info, __u32 *uwrq, 2381 char *extra) 2382 { 2383 struct ks_wlan_private *priv = netdev_priv(dev); 2384 2385 if (priv->sleep_mode == SLP_SLEEP) 2386 return -EPERM; 2387 /* for SLEEP MODE */ 2388 *uwrq = priv->gain.rx_gain; 2389 hostif_sme_enqueue(priv, SME_GET_GAIN); 2390 return 0; 2391 } 2392 2393 static int ks_wlan_get_eeprom_cksum(struct net_device *dev, 2394 struct iw_request_info *info, __u32 *uwrq, 2395 char *extra) 2396 { 2397 struct ks_wlan_private *priv = netdev_priv(dev); 2398 2399 *uwrq = priv->eeprom_checksum; 2400 return 0; 2401 } 2402 2403 static void print_hif_event(struct net_device *dev, int event) 2404 { 2405 switch (event) { 2406 case HIF_DATA_REQ: 2407 netdev_info(dev, "HIF_DATA_REQ\n"); 2408 break; 2409 case HIF_DATA_IND: 2410 netdev_info(dev, "HIF_DATA_IND\n"); 2411 break; 2412 case HIF_MIB_GET_REQ: 2413 netdev_info(dev, "HIF_MIB_GET_REQ\n"); 2414 break; 2415 case HIF_MIB_GET_CONF: 2416 netdev_info(dev, "HIF_MIB_GET_CONF\n"); 2417 break; 2418 case HIF_MIB_SET_REQ: 2419 netdev_info(dev, "HIF_MIB_SET_REQ\n"); 2420 break; 2421 case HIF_MIB_SET_CONF: 2422 netdev_info(dev, "HIF_MIB_SET_CONF\n"); 2423 break; 2424 case HIF_POWER_MGMT_REQ: 2425 netdev_info(dev, "HIF_POWER_MGMT_REQ\n"); 2426 break; 2427 case HIF_POWER_MGMT_CONF: 2428 netdev_info(dev, "HIF_POWER_MGMT_CONF\n"); 2429 break; 2430 case HIF_START_REQ: 2431 netdev_info(dev, "HIF_START_REQ\n"); 2432 break; 2433 case HIF_START_CONF: 2434 netdev_info(dev, "HIF_START_CONF\n"); 2435 break; 2436 case HIF_CONNECT_IND: 2437 netdev_info(dev, "HIF_CONNECT_IND\n"); 2438 break; 2439 case HIF_STOP_REQ: 2440 netdev_info(dev, "HIF_STOP_REQ\n"); 2441 break; 2442 case HIF_STOP_CONF: 2443 netdev_info(dev, "HIF_STOP_CONF\n"); 2444 break; 2445 case HIF_PS_ADH_SET_REQ: 2446 netdev_info(dev, "HIF_PS_ADH_SET_REQ\n"); 2447 break; 2448 case HIF_PS_ADH_SET_CONF: 2449 netdev_info(dev, "HIF_PS_ADH_SET_CONF\n"); 2450 break; 2451 case HIF_INFRA_SET_REQ: 2452 netdev_info(dev, "HIF_INFRA_SET_REQ\n"); 2453 break; 2454 case HIF_INFRA_SET_CONF: 2455 netdev_info(dev, "HIF_INFRA_SET_CONF\n"); 2456 break; 2457 case HIF_ADH_SET_REQ: 2458 netdev_info(dev, "HIF_ADH_SET_REQ\n"); 2459 break; 2460 case HIF_ADH_SET_CONF: 2461 netdev_info(dev, "HIF_ADH_SET_CONF\n"); 2462 break; 2463 case HIF_AP_SET_REQ: 2464 netdev_info(dev, "HIF_AP_SET_REQ\n"); 2465 break; 2466 case HIF_AP_SET_CONF: 2467 netdev_info(dev, "HIF_AP_SET_CONF\n"); 2468 break; 2469 case HIF_ASSOC_INFO_IND: 2470 netdev_info(dev, "HIF_ASSOC_INFO_IND\n"); 2471 break; 2472 case HIF_MIC_FAILURE_REQ: 2473 netdev_info(dev, "HIF_MIC_FAILURE_REQ\n"); 2474 break; 2475 case HIF_MIC_FAILURE_CONF: 2476 netdev_info(dev, "HIF_MIC_FAILURE_CONF\n"); 2477 break; 2478 case HIF_SCAN_REQ: 2479 netdev_info(dev, "HIF_SCAN_REQ\n"); 2480 break; 2481 case HIF_SCAN_CONF: 2482 netdev_info(dev, "HIF_SCAN_CONF\n"); 2483 break; 2484 case HIF_PHY_INFO_REQ: 2485 netdev_info(dev, "HIF_PHY_INFO_REQ\n"); 2486 break; 2487 case HIF_PHY_INFO_CONF: 2488 netdev_info(dev, "HIF_PHY_INFO_CONF\n"); 2489 break; 2490 case HIF_SLEEP_REQ: 2491 netdev_info(dev, "HIF_SLEEP_REQ\n"); 2492 break; 2493 case HIF_SLEEP_CONF: 2494 netdev_info(dev, "HIF_SLEEP_CONF\n"); 2495 break; 2496 case HIF_PHY_INFO_IND: 2497 netdev_info(dev, "HIF_PHY_INFO_IND\n"); 2498 break; 2499 case HIF_SCAN_IND: 2500 netdev_info(dev, "HIF_SCAN_IND\n"); 2501 break; 2502 case HIF_INFRA_SET2_REQ: 2503 netdev_info(dev, "HIF_INFRA_SET2_REQ\n"); 2504 break; 2505 case HIF_INFRA_SET2_CONF: 2506 netdev_info(dev, "HIF_INFRA_SET2_CONF\n"); 2507 break; 2508 case HIF_ADH_SET2_REQ: 2509 netdev_info(dev, "HIF_ADH_SET2_REQ\n"); 2510 break; 2511 case HIF_ADH_SET2_CONF: 2512 netdev_info(dev, "HIF_ADH_SET2_CONF\n"); 2513 } 2514 } 2515 2516 /* get host command history */ 2517 static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info, 2518 __u32 *uwrq, char *extra) 2519 { 2520 int i, event; 2521 struct ks_wlan_private *priv = netdev_priv(dev); 2522 2523 for (i = 63; i >= 0; i--) { 2524 event = 2525 priv->hostt.buff[(priv->hostt.qtail - 1 - i) % 2526 SME_EVENT_BUFF_SIZE]; 2527 print_hif_event(dev, event); 2528 } 2529 return 0; 2530 } 2531 2532 /* Structures to export the Wireless Handlers */ 2533 2534 static const struct iw_priv_args ks_wlan_private_args[] = { 2535 /*{ cmd, set_args, get_args, name[16] } */ 2536 {KS_WLAN_GET_FIRM_VERSION, IW_PRIV_TYPE_NONE, 2537 IW_PRIV_TYPE_CHAR | (128 + 1), "GetFirmwareVer"}, 2538 #ifdef WPS 2539 {KS_WLAN_SET_WPS_ENABLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2540 IW_PRIV_TYPE_NONE, "SetWPSEnable"}, 2541 {KS_WLAN_GET_WPS_ENABLE, IW_PRIV_TYPE_NONE, 2542 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetW"}, 2543 {KS_WLAN_SET_WPS_PROBE_REQ, IW_PRIV_TYPE_BYTE | 2047, IW_PRIV_TYPE_NONE, 2544 "SetWPSProbeReq"}, 2545 #endif /* WPS */ 2546 {KS_WLAN_SET_PREAMBLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2547 IW_PRIV_TYPE_NONE, "SetPreamble"}, 2548 {KS_WLAN_GET_PREAMBLE, IW_PRIV_TYPE_NONE, 2549 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPreamble"}, 2550 {KS_WLAN_SET_POWER_SAVE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2551 IW_PRIV_TYPE_NONE, "SetPowerSave"}, 2552 {KS_WLAN_GET_POWER_SAVE, IW_PRIV_TYPE_NONE, 2553 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPowerSave"}, 2554 {KS_WLAN_SET_SCAN_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2555 IW_PRIV_TYPE_NONE, "SetScanType"}, 2556 {KS_WLAN_GET_SCAN_TYPE, IW_PRIV_TYPE_NONE, 2557 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetScanType"}, 2558 {KS_WLAN_SET_RX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2559 IW_PRIV_TYPE_NONE, "SetRxGain"}, 2560 {KS_WLAN_GET_RX_GAIN, IW_PRIV_TYPE_NONE, 2561 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetRxGain"}, 2562 {KS_WLAN_HOSTT, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128 + 1), 2563 "hostt"}, 2564 {KS_WLAN_SET_BEACON_LOST, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2565 IW_PRIV_TYPE_NONE, "SetBeaconLost"}, 2566 {KS_WLAN_GET_BEACON_LOST, IW_PRIV_TYPE_NONE, 2567 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetBeaconLost"}, 2568 {KS_WLAN_SET_SLEEP_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2569 IW_PRIV_TYPE_NONE, "SetSleepMode"}, 2570 {KS_WLAN_GET_SLEEP_MODE, IW_PRIV_TYPE_NONE, 2571 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetSleepMode"}, 2572 {KS_WLAN_SET_TX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2573 IW_PRIV_TYPE_NONE, "SetTxGain"}, 2574 {KS_WLAN_GET_TX_GAIN, IW_PRIV_TYPE_NONE, 2575 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetTxGain"}, 2576 {KS_WLAN_SET_PHY_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2577 IW_PRIV_TYPE_NONE, "SetPhyType"}, 2578 {KS_WLAN_GET_PHY_TYPE, IW_PRIV_TYPE_NONE, 2579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPhyType"}, 2580 {KS_WLAN_SET_CTS_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 2581 IW_PRIV_TYPE_NONE, "SetCtsMode"}, 2582 {KS_WLAN_GET_CTS_MODE, IW_PRIV_TYPE_NONE, 2583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetCtsMode"}, 2584 {KS_WLAN_GET_EEPROM_CKSUM, IW_PRIV_TYPE_NONE, 2585 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetChecksum"}, 2586 }; 2587 2588 static const iw_handler ks_wlan_handler[] = { 2589 (iw_handler)ks_wlan_config_commit, /* SIOCSIWCOMMIT */ 2590 (iw_handler)ks_wlan_get_name, /* SIOCGIWNAME */ 2591 (iw_handler)NULL, /* SIOCSIWNWID */ 2592 (iw_handler)NULL, /* SIOCGIWNWID */ 2593 (iw_handler)ks_wlan_set_freq, /* SIOCSIWFREQ */ 2594 (iw_handler)ks_wlan_get_freq, /* SIOCGIWFREQ */ 2595 (iw_handler)ks_wlan_set_mode, /* SIOCSIWMODE */ 2596 (iw_handler)ks_wlan_get_mode, /* SIOCGIWMODE */ 2597 #ifndef KSC_OPNOTSUPP 2598 (iw_handler)ks_wlan_set_sens, /* SIOCSIWSENS */ 2599 (iw_handler)ks_wlan_get_sens, /* SIOCGIWSENS */ 2600 #else /* KSC_OPNOTSUPP */ 2601 (iw_handler)NULL, /* SIOCSIWSENS */ 2602 (iw_handler)NULL, /* SIOCGIWSENS */ 2603 #endif /* KSC_OPNOTSUPP */ 2604 (iw_handler)NULL, /* SIOCSIWRANGE */ 2605 (iw_handler)ks_wlan_get_range, /* SIOCGIWRANGE */ 2606 (iw_handler)NULL, /* SIOCSIWPRIV */ 2607 (iw_handler)NULL, /* SIOCGIWPRIV */ 2608 (iw_handler)NULL, /* SIOCSIWSTATS */ 2609 (iw_handler)ks_wlan_get_iwstats, /* SIOCGIWSTATS */ 2610 (iw_handler)NULL, /* SIOCSIWSPY */ 2611 (iw_handler)NULL, /* SIOCGIWSPY */ 2612 (iw_handler)NULL, /* SIOCSIWTHRSPY */ 2613 (iw_handler)NULL, /* SIOCGIWTHRSPY */ 2614 (iw_handler)ks_wlan_set_wap, /* SIOCSIWAP */ 2615 (iw_handler)ks_wlan_get_wap, /* SIOCGIWAP */ 2616 // (iw_handler)NULL, /* SIOCSIWMLME */ 2617 (iw_handler)ks_wlan_set_mlme, /* SIOCSIWMLME */ 2618 (iw_handler)ks_wlan_get_aplist, /* SIOCGIWAPLIST */ 2619 (iw_handler)ks_wlan_set_scan, /* SIOCSIWSCAN */ 2620 (iw_handler)ks_wlan_get_scan, /* SIOCGIWSCAN */ 2621 (iw_handler)ks_wlan_set_essid, /* SIOCSIWESSID */ 2622 (iw_handler)ks_wlan_get_essid, /* SIOCGIWESSID */ 2623 (iw_handler)ks_wlan_set_nick, /* SIOCSIWNICKN */ 2624 (iw_handler)ks_wlan_get_nick, /* SIOCGIWNICKN */ 2625 (iw_handler)NULL, /* -- hole -- */ 2626 (iw_handler)NULL, /* -- hole -- */ 2627 (iw_handler)ks_wlan_set_rate, /* SIOCSIWRATE */ 2628 (iw_handler)ks_wlan_get_rate, /* SIOCGIWRATE */ 2629 (iw_handler)ks_wlan_set_rts, /* SIOCSIWRTS */ 2630 (iw_handler)ks_wlan_get_rts, /* SIOCGIWRTS */ 2631 (iw_handler)ks_wlan_set_frag, /* SIOCSIWFRAG */ 2632 (iw_handler)ks_wlan_get_frag, /* SIOCGIWFRAG */ 2633 #ifndef KSC_OPNOTSUPP 2634 (iw_handler)ks_wlan_set_txpow, /* SIOCSIWTXPOW */ 2635 (iw_handler)ks_wlan_get_txpow, /* SIOCGIWTXPOW */ 2636 (iw_handler)ks_wlan_set_retry, /* SIOCSIWRETRY */ 2637 (iw_handler)ks_wlan_get_retry, /* SIOCGIWRETRY */ 2638 #else /* KSC_OPNOTSUPP */ 2639 (iw_handler)NULL, /* SIOCSIWTXPOW */ 2640 (iw_handler)NULL, /* SIOCGIWTXPOW */ 2641 (iw_handler)NULL, /* SIOCSIWRETRY */ 2642 (iw_handler)NULL, /* SIOCGIWRETRY */ 2643 #endif /* KSC_OPNOTSUPP */ 2644 (iw_handler)ks_wlan_set_encode, /* SIOCSIWENCODE */ 2645 (iw_handler)ks_wlan_get_encode, /* SIOCGIWENCODE */ 2646 (iw_handler)ks_wlan_set_power, /* SIOCSIWPOWER */ 2647 (iw_handler)ks_wlan_get_power, /* SIOCGIWPOWER */ 2648 (iw_handler)NULL, /* -- hole -- */ 2649 (iw_handler)NULL, /* -- hole -- */ 2650 // (iw_handler)NULL, /* SIOCSIWGENIE */ 2651 (iw_handler)ks_wlan_set_genie, /* SIOCSIWGENIE */ 2652 (iw_handler)NULL, /* SIOCGIWGENIE */ 2653 (iw_handler)ks_wlan_set_auth_mode, /* SIOCSIWAUTH */ 2654 (iw_handler)ks_wlan_get_auth_mode, /* SIOCGIWAUTH */ 2655 (iw_handler)ks_wlan_set_encode_ext, /* SIOCSIWENCODEEXT */ 2656 (iw_handler)ks_wlan_get_encode_ext, /* SIOCGIWENCODEEXT */ 2657 (iw_handler)ks_wlan_set_pmksa, /* SIOCSIWPMKSA */ 2658 (iw_handler)NULL, /* -- hole -- */ 2659 }; 2660 2661 /* private_handler */ 2662 static const iw_handler ks_wlan_private_handler[] = { 2663 (iw_handler)NULL, /* 0 */ 2664 (iw_handler)NULL, /* 1, used to be: KS_WLAN_GET_DRIVER_VERSION */ 2665 (iw_handler)NULL, /* 2 */ 2666 (iw_handler)ks_wlan_get_firmware_version, /* 3 KS_WLAN_GET_FIRM_VERSION */ 2667 #ifdef WPS 2668 (iw_handler)ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */ 2669 (iw_handler)ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */ 2670 (iw_handler)ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */ 2671 #else 2672 (iw_handler)NULL, /* 4 */ 2673 (iw_handler)NULL, /* 5 */ 2674 (iw_handler)NULL, /* 6 */ 2675 #endif /* WPS */ 2676 2677 (iw_handler)ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */ 2678 (iw_handler)ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */ 2679 (iw_handler)ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */ 2680 (iw_handler)ks_wlan_set_power_mgmt, /* 10 KS_WLAN_SET_POWER_SAVE */ 2681 (iw_handler)ks_wlan_get_power_mgmt, /* 11 KS_WLAN_GET_POWER_SAVE */ 2682 (iw_handler)ks_wlan_set_scan_type, /* 12 KS_WLAN_SET_SCAN_TYPE */ 2683 (iw_handler)ks_wlan_get_scan_type, /* 13 KS_WLAN_GET_SCAN_TYPE */ 2684 (iw_handler)ks_wlan_set_rx_gain, /* 14 KS_WLAN_SET_RX_GAIN */ 2685 (iw_handler)ks_wlan_get_rx_gain, /* 15 KS_WLAN_GET_RX_GAIN */ 2686 (iw_handler)ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */ 2687 (iw_handler)NULL, /* 17 */ 2688 (iw_handler)ks_wlan_set_beacon_lost, /* 18 KS_WLAN_SET_BECAN_LOST */ 2689 (iw_handler)ks_wlan_get_beacon_lost, /* 19 KS_WLAN_GET_BECAN_LOST */ 2690 (iw_handler)ks_wlan_set_tx_gain, /* 20 KS_WLAN_SET_TX_GAIN */ 2691 (iw_handler)ks_wlan_get_tx_gain, /* 21 KS_WLAN_GET_TX_GAIN */ 2692 (iw_handler)ks_wlan_set_phy_type, /* 22 KS_WLAN_SET_PHY_TYPE */ 2693 (iw_handler)ks_wlan_get_phy_type, /* 23 KS_WLAN_GET_PHY_TYPE */ 2694 (iw_handler)ks_wlan_set_cts_mode, /* 24 KS_WLAN_SET_CTS_MODE */ 2695 (iw_handler)ks_wlan_get_cts_mode, /* 25 KS_WLAN_GET_CTS_MODE */ 2696 (iw_handler)NULL, /* 26 */ 2697 (iw_handler)NULL, /* 27 */ 2698 (iw_handler)ks_wlan_set_sleep_mode, /* 28 KS_WLAN_SET_SLEEP_MODE */ 2699 (iw_handler)ks_wlan_get_sleep_mode, /* 29 KS_WLAN_GET_SLEEP_MODE */ 2700 (iw_handler)NULL, /* 30 */ 2701 (iw_handler)NULL, /* 31 */ 2702 }; 2703 2704 static const struct iw_handler_def ks_wlan_handler_def = { 2705 .num_standard = sizeof(ks_wlan_handler) / sizeof(iw_handler), 2706 .num_private = sizeof(ks_wlan_private_handler) / sizeof(iw_handler), 2707 .num_private_args = 2708 sizeof(ks_wlan_private_args) / sizeof(struct iw_priv_args), 2709 .standard = (iw_handler *)ks_wlan_handler, 2710 .private = (iw_handler *)ks_wlan_private_handler, 2711 .private_args = (struct iw_priv_args *)ks_wlan_private_args, 2712 .get_wireless_stats = ks_get_wireless_stats, 2713 }; 2714 2715 static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, 2716 int cmd) 2717 { 2718 int ret; 2719 struct iwreq *wrq = (struct iwreq *)rq; 2720 2721 switch (cmd) { 2722 case SIOCIWFIRSTPRIV + 20: /* KS_WLAN_SET_STOP_REQ */ 2723 ret = ks_wlan_set_stop_request(dev, NULL, &wrq->u.mode, NULL); 2724 break; 2725 // All other calls are currently unsupported 2726 default: 2727 ret = -EOPNOTSUPP; 2728 } 2729 2730 return ret; 2731 } 2732 2733 static 2734 struct net_device_stats *ks_wlan_get_stats(struct net_device *dev) 2735 { 2736 struct ks_wlan_private *priv = netdev_priv(dev); 2737 2738 if (priv->dev_state < DEVICE_STATE_READY) 2739 return NULL; /* not finished initialize */ 2740 2741 return &priv->nstats; 2742 } 2743 2744 static 2745 int ks_wlan_set_mac_address(struct net_device *dev, void *addr) 2746 { 2747 struct ks_wlan_private *priv = netdev_priv(dev); 2748 struct sockaddr *mac_addr = (struct sockaddr *)addr; 2749 2750 if (netif_running(dev)) 2751 return -EBUSY; 2752 memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); 2753 memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN); 2754 2755 priv->mac_address_valid = false; 2756 hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST); 2757 netdev_info(dev, "ks_wlan: MAC ADDRESS = %pM\n", priv->eth_addr); 2758 return 0; 2759 } 2760 2761 static 2762 void ks_wlan_tx_timeout(struct net_device *dev) 2763 { 2764 struct ks_wlan_private *priv = netdev_priv(dev); 2765 2766 netdev_dbg(dev, "head(%d) tail(%d)!!\n", priv->tx_dev.qhead, 2767 priv->tx_dev.qtail); 2768 if (!netif_queue_stopped(dev)) 2769 netif_stop_queue(dev); 2770 priv->nstats.tx_errors++; 2771 netif_wake_queue(dev); 2772 } 2773 2774 static 2775 int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) 2776 { 2777 struct ks_wlan_private *priv = netdev_priv(dev); 2778 int ret; 2779 2780 netdev_dbg(dev, "in_interrupt()=%ld\n", in_interrupt()); 2781 2782 if (!skb) { 2783 netdev_err(dev, "ks_wlan: skb == NULL!!!\n"); 2784 return 0; 2785 } 2786 if (priv->dev_state < DEVICE_STATE_READY) { 2787 dev_kfree_skb(skb); 2788 return 0; /* not finished initialize */ 2789 } 2790 2791 if (netif_running(dev)) 2792 netif_stop_queue(dev); 2793 2794 ret = hostif_data_request(priv, skb); 2795 netif_trans_update(dev); 2796 2797 if (ret) 2798 netdev_err(dev, "hostif_data_request error: =%d\n", ret); 2799 2800 return 0; 2801 } 2802 2803 void send_packet_complete(struct ks_wlan_private *priv, struct sk_buff *skb) 2804 { 2805 priv->nstats.tx_packets++; 2806 2807 if (netif_queue_stopped(priv->net_dev)) 2808 netif_wake_queue(priv->net_dev); 2809 2810 if (skb) { 2811 priv->nstats.tx_bytes += skb->len; 2812 dev_kfree_skb(skb); 2813 } 2814 } 2815 2816 /* 2817 * Set or clear the multicast filter for this adaptor. 2818 * This routine is not state sensitive and need not be SMP locked. 2819 */ 2820 static 2821 void ks_wlan_set_multicast_list(struct net_device *dev) 2822 { 2823 struct ks_wlan_private *priv = netdev_priv(dev); 2824 2825 if (priv->dev_state < DEVICE_STATE_READY) 2826 return; /* not finished initialize */ 2827 hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST); 2828 } 2829 2830 static 2831 int ks_wlan_open(struct net_device *dev) 2832 { 2833 struct ks_wlan_private *priv = netdev_priv(dev); 2834 2835 priv->cur_rx = 0; 2836 2837 if (!priv->mac_address_valid) { 2838 netdev_err(dev, "ks_wlan : %s Not READY !!\n", dev->name); 2839 return -EBUSY; 2840 } 2841 netif_start_queue(dev); 2842 2843 return 0; 2844 } 2845 2846 static 2847 int ks_wlan_close(struct net_device *dev) 2848 { 2849 netif_stop_queue(dev); 2850 2851 return 0; 2852 } 2853 2854 /* Operational parameters that usually are not changed. */ 2855 /* Time in jiffies before concluding the transmitter is hung. */ 2856 #define TX_TIMEOUT (3 * HZ) 2857 static const unsigned char dummy_addr[] = { 2858 0x00, 0x0b, 0xe3, 0x00, 0x00, 0x00 2859 }; 2860 2861 static const struct net_device_ops ks_wlan_netdev_ops = { 2862 .ndo_start_xmit = ks_wlan_start_xmit, 2863 .ndo_open = ks_wlan_open, 2864 .ndo_stop = ks_wlan_close, 2865 .ndo_do_ioctl = ks_wlan_netdev_ioctl, 2866 .ndo_set_mac_address = ks_wlan_set_mac_address, 2867 .ndo_get_stats = ks_wlan_get_stats, 2868 .ndo_tx_timeout = ks_wlan_tx_timeout, 2869 .ndo_set_rx_mode = ks_wlan_set_multicast_list, 2870 }; 2871 2872 int ks_wlan_net_start(struct net_device *dev) 2873 { 2874 struct ks_wlan_private *priv; 2875 /* int rc; */ 2876 2877 priv = netdev_priv(dev); 2878 priv->mac_address_valid = false; 2879 priv->need_commit = 0; 2880 2881 priv->device_open_status = 1; 2882 2883 /* phy information update timer */ 2884 atomic_set(&update_phyinfo, 0); 2885 timer_setup(&update_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0); 2886 2887 /* dummy address set */ 2888 memcpy(priv->eth_addr, dummy_addr, ETH_ALEN); 2889 dev->dev_addr[0] = priv->eth_addr[0]; 2890 dev->dev_addr[1] = priv->eth_addr[1]; 2891 dev->dev_addr[2] = priv->eth_addr[2]; 2892 dev->dev_addr[3] = priv->eth_addr[3]; 2893 dev->dev_addr[4] = priv->eth_addr[4]; 2894 dev->dev_addr[5] = priv->eth_addr[5]; 2895 dev->dev_addr[6] = 0x00; 2896 dev->dev_addr[7] = 0x00; 2897 2898 /* The ks_wlan-specific entries in the device structure. */ 2899 dev->netdev_ops = &ks_wlan_netdev_ops; 2900 dev->wireless_handlers = &ks_wlan_handler_def; 2901 dev->watchdog_timeo = TX_TIMEOUT; 2902 2903 netif_carrier_off(dev); 2904 2905 return 0; 2906 } 2907 2908 int ks_wlan_net_stop(struct net_device *dev) 2909 { 2910 struct ks_wlan_private *priv = netdev_priv(dev); 2911 2912 priv->device_open_status = 0; 2913 del_timer_sync(&update_phyinfo_timer); 2914 2915 if (netif_running(dev)) 2916 netif_stop_queue(dev); 2917 2918 return 0; 2919 } 2920 2921 /** 2922 * is_connect_status() - return true if status is 'connected' 2923 * @status: high bit is used as FORCE_DISCONNECT, low bits used for 2924 * connect status. 2925 */ 2926 bool is_connect_status(u32 status) 2927 { 2928 return (status & CONNECT_STATUS_MASK) == CONNECT_STATUS; 2929 } 2930 2931 /** 2932 * is_disconnect_status() - return true if status is 'disconnected' 2933 * @status: high bit is used as FORCE_DISCONNECT, low bits used for 2934 * disconnect status. 2935 */ 2936 bool is_disconnect_status(u32 status) 2937 { 2938 return (status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS; 2939 } 2940