2 * Driver for KeyStream wireless LAN cards.
4 * Copyright (C) 2005-2008 KeyStream Corp.
5 * Copyright (C) 2009 Renesas Technology Corp.
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.
13 #include "ks_hostif.h"
14 #include "eap_packet.h"
15 #include "michael_mic.h"
17 #include <linux/etherdevice.h>
18 #include <linux/if_ether.h>
19 #include <linux/if_arp.h>
21 /* Include Wireless Extension definition and check version */
22 #include <net/iw_handler.h> /* New driver API */
25 #define inc_smeqhead(priv) \
26 (priv->sme_i.qhead = (priv->sme_i.qhead + 1) % SME_EVENT_BUFF_SIZE)
27 #define inc_smeqtail(priv) \
28 (priv->sme_i.qtail = (priv->sme_i.qtail + 1) % SME_EVENT_BUFF_SIZE)
29 #define cnt_smeqbody(priv) \
30 (((priv->sme_i.qtail + SME_EVENT_BUFF_SIZE) - (priv->sme_i.qhead)) % SME_EVENT_BUFF_SIZE)
32 #define KS_WLAN_MEM_FLAG (GFP_ATOMIC)
35 inline u8 get_BYTE(struct ks_wlan_private *priv)
39 data = *(priv->rxp)++;
40 /* length check in advance ! */
46 inline u16 get_WORD(struct ks_wlan_private *priv)
50 data = (get_BYTE(priv) & 0xff);
51 data |= ((get_BYTE(priv) << 8) & 0xff00);
56 inline u32 get_DWORD(struct ks_wlan_private *priv)
60 data = (get_BYTE(priv) & 0xff);
61 data |= ((get_BYTE(priv) << 8) & 0x0000ff00);
62 data |= ((get_BYTE(priv) << 16) & 0x00ff0000);
63 data |= ((get_BYTE(priv) << 24) & 0xff000000);
67 static void ks_wlan_hw_wakeup_task(struct work_struct *work)
69 struct ks_wlan_private *priv;
73 priv = container_of(work, struct ks_wlan_private, wakeup_work);
74 ps_status = atomic_read(&priv->psstatus.status);
76 if (ps_status == PS_SNOOZE) {
77 ks_wlan_hw_wakeup_request(priv);
78 time_left = wait_for_completion_interruptible_timeout(
79 &priv->psstatus.wakeup_wait,
80 msecs_to_jiffies(20));
82 DPRINTK(1, "wake up timeout or interrupted !!!\n");
83 schedule_work(&priv->wakeup_work);
87 DPRINTK(1, "ps_status=%d\n", ps_status);
91 if (atomic_read(&priv->sme_task.count) > 0) {
92 DPRINTK(4, "sme task enable.\n");
93 tasklet_enable(&priv->sme_task);
98 int ks_wlan_do_power_save(struct ks_wlan_private *priv)
100 DPRINTK(4, "psstatus.status=%d\n", atomic_read(&priv->psstatus.status));
102 if (is_connect_status(priv->connect_status))
103 hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
105 priv->dev_state = DEVICE_STATE_READY;
110 int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
112 struct local_ap_t *ap;
113 union iwreq_data wrqu;
114 struct net_device *netdev = priv->net_dev;
117 ap = &priv->current_ap;
119 if (is_disconnect_status(priv->connect_status)) {
120 memset(ap, 0, sizeof(struct local_ap_t));
125 memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
127 memcpy(ap->ssid.body, priv->reg.ssid.body,
128 priv->reg.ssid.size);
129 ap->ssid.size = priv->reg.ssid.size;
131 memcpy(ap->rate_set.body, ap_info->rate_set.body,
132 ap_info->rate_set.size);
133 ap->rate_set.size = ap_info->rate_set.size;
134 if (ap_info->ext_rate_set.size != 0) {
136 memcpy(&ap->rate_set.body[ap->rate_set.size],
137 ap_info->ext_rate_set.body,
138 ap_info->ext_rate_set.size);
139 ap->rate_set.size += ap_info->ext_rate_set.size;
142 ap->channel = ap_info->ds_parameter.channel;
144 ap->rssi = ap_info->rssi;
146 ap->sq = ap_info->sq;
148 ap->noise = ap_info->noise;
150 ap->capability = le16_to_cpu(ap_info->capability);
152 if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
153 (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
154 ap->rsn_ie.id = 0x30;
155 if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
156 ap->rsn_ie.size = ap_info->rsn.size;
157 memcpy(ap->rsn_ie.body, ap_info->rsn.body,
160 ap->rsn_ie.size = RSN_IE_BODY_MAX;
161 memcpy(ap->rsn_ie.body, ap_info->rsn.body,
164 } else if ((ap_info->rsn_mode & RSN_MODE_WPA) &&
165 (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)) {
166 ap->wpa_ie.id = 0xdd;
167 if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
168 ap->wpa_ie.size = ap_info->rsn.size;
169 memcpy(ap->wpa_ie.body, ap_info->rsn.body,
172 ap->wpa_ie.size = RSN_IE_BODY_MAX;
173 memcpy(ap->wpa_ie.body, ap_info->rsn.body,
183 wrqu.data.length = 0;
185 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
186 if (is_connect_status(priv->connect_status)) {
187 memcpy(wrqu.ap_addr.sa_data,
188 priv->current_ap.bssid, ETH_ALEN);
190 "IWEVENT: connect bssid=%pM\n", wrqu.ap_addr.sa_data);
191 wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
193 DPRINTK(4, "\n Link AP\n");
194 DPRINTK(4, " bssid=%02X:%02X:%02X:%02X:%02X:%02X\n"
196 " rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n"
200 " capability=%04X\n",
201 ap->bssid[0], ap->bssid[1], ap->bssid[2],
202 ap->bssid[3], ap->bssid[4], ap->bssid[5],
204 ap->rate_set.body[0], ap->rate_set.body[1],
205 ap->rate_set.body[2], ap->rate_set.body[3],
206 ap->rate_set.body[4], ap->rate_set.body[5],
207 ap->rate_set.body[6], ap->rate_set.body[7],
208 ap->channel, ap->rssi, ap->sq, ap->capability);
209 DPRINTK(4, "\n Link AP\n rsn.mode=%d\n rsn.size=%d\n",
210 ap_info->rsn_mode, ap_info->rsn.size);
211 DPRINTK(4, "\n ext_rate_set_size=%d\n rate_set_size=%d\n",
212 ap_info->ext_rate_set.size, ap_info->rate_set.size);
218 int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
219 struct local_ap_t *ap)
225 memset(ap, 0, sizeof(struct local_ap_t));
228 memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
230 ap->rssi = ap_info->rssi;
232 ap->sq = ap_info->sq;
234 ap->noise = ap_info->noise;
236 ap->capability = le16_to_cpu(ap_info->capability);
238 ap->channel = ap_info->ch_info;
241 bsize = le16_to_cpu(ap_info->body_size);
244 while (bsize > offset) {
245 switch (*bp) { /* Information Element ID */
247 if (*(bp + 1) <= SSID_MAX_SIZE) {
248 ap->ssid.size = *(bp + 1);
250 DPRINTK(1, "size over :: ssid size=%d\n",
252 ap->ssid.size = SSID_MAX_SIZE;
254 memcpy(ap->ssid.body, bp + 2, ap->ssid.size);
256 case WLAN_EID_SUPP_RATES:
257 case WLAN_EID_EXT_SUPP_RATES:
258 if ((*(bp + 1) + ap->rate_set.size) <=
260 memcpy(&ap->rate_set.body[ap->rate_set.size],
262 ap->rate_set.size += *(bp + 1);
264 DPRINTK(1, "size over :: rate size=%d\n",
265 (*(bp + 1) + ap->rate_set.size));
266 memcpy(&ap->rate_set.body[ap->rate_set.size],
268 RATE_SET_MAX_SIZE - ap->rate_set.size);
270 (RATE_SET_MAX_SIZE - ap->rate_set.size);
273 case WLAN_EID_DS_PARAMS:
277 if (*(bp + 1) <= RSN_IE_BODY_MAX) {
278 ap->rsn_ie.size = *(bp + 1);
280 DPRINTK(1, "size over :: rsn size=%d\n",
282 ap->rsn_ie.size = RSN_IE_BODY_MAX;
284 memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size);
286 case WLAN_EID_VENDOR_SPECIFIC: /* WPA */
287 if (memcmp(bp + 2, "\x00\x50\xf2\x01", 4) == 0) { /* WPA OUI check */
289 if (*(bp + 1) <= RSN_IE_BODY_MAX) {
290 ap->wpa_ie.size = *(bp + 1);
293 "size over :: wpa size=%d\n",
295 ap->wpa_ie.size = RSN_IE_BODY_MAX;
297 memcpy(ap->wpa_ie.body, bp + 2,
302 case WLAN_EID_FH_PARAMS:
303 case WLAN_EID_CF_PARAMS:
305 case WLAN_EID_IBSS_PARAMS:
306 case WLAN_EID_COUNTRY:
307 case WLAN_EID_ERP_INFO:
310 DPRINTK(4, "unknown Element ID=%d\n", *bp);
314 offset += 2; /* id & size field */
315 offset += *(bp + 1); /* +size offset */
316 bp += (*(bp + 1) + 2); /* pointer update */
323 int hostif_data_indication_wpa(struct ks_wlan_private *priv,
324 unsigned short auth_type)
326 struct ether_hdr *eth_hdr;
327 unsigned short eth_proto;
328 unsigned char recv_mic[8];
331 struct mic_failure_t *mic_failure;
332 struct michael_mic_t michael_mic;
333 union iwreq_data wrqu;
334 unsigned int key_index = auth_type - 1;
335 struct wpa_key_t *key = &priv->wpa.key[key_index];
337 eth_hdr = (struct ether_hdr *)(priv->rxp);
338 eth_proto = ntohs(eth_hdr->h_proto);
340 if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) {
341 DPRINTK(1, "invalid data format\n");
342 priv->nstats.rx_errors++;
345 if (((auth_type == TYPE_PMK1 &&
346 priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) ||
347 (auth_type == TYPE_GMK1 &&
348 priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP) ||
349 (auth_type == TYPE_GMK2 &&
350 priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP)) &&
352 DPRINTK(4, "TKIP: protocol=%04X: size=%u\n",
353 eth_proto, priv->rx_size);
355 memcpy(&recv_mic[0], (priv->rxp) + ((priv->rx_size) - 8), 8);
356 priv->rx_size = priv->rx_size - 8;
357 if (auth_type > 0 && auth_type < 4) { /* auth_type check */
358 MichaelMICFunction(&michael_mic,
359 (uint8_t *)key->rx_mic_key,
360 (uint8_t *)priv->rxp,
362 (uint8_t)0, /* priority */
363 (uint8_t *)michael_mic.Result);
365 if (memcmp(michael_mic.Result, recv_mic, 8) != 0) {
367 mic_failure = &priv->wpa.mic_failure;
369 if (mic_failure->last_failure_time &&
370 (now - mic_failure->last_failure_time) / HZ >= 60) {
371 mic_failure->failure = 0;
373 DPRINTK(4, "MIC FAILURE\n");
374 if (mic_failure->failure == 0) {
375 mic_failure->failure = 1;
376 mic_failure->counter = 0;
377 } else if (mic_failure->failure == 1) {
378 mic_failure->failure = 2;
379 mic_failure->counter =
380 (uint16_t)((now - mic_failure->last_failure_time) / HZ);
381 if (!mic_failure->counter) /* range 1-60 */
382 mic_failure->counter = 1;
384 priv->wpa.mic_failure.last_failure_time = now;
386 /* needed parameters: count, keyid, key type, TSC */
388 "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=%pM)",
390 eth_hdr->h_dest[0] & 0x01 ? "broad" : "uni",
392 memset(&wrqu, 0, sizeof(wrqu));
393 wrqu.data.length = strlen(buf);
394 DPRINTK(4, "IWEVENT:MICHAELMICFAILURE\n");
395 wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu,
404 void hostif_data_indication(struct ks_wlan_private *priv)
406 unsigned int rx_ind_size; /* indicate data size */
408 unsigned short auth_type;
409 unsigned char temp[256];
410 struct ether_hdr *eth_hdr;
411 unsigned short eth_proto;
412 struct ieee802_1x_hdr *aa1x_hdr;
418 /* min length check */
419 if (priv->rx_size <= ETH_HLEN) {
420 DPRINTK(3, "rx_size = %d\n", priv->rx_size);
421 priv->nstats.rx_errors++;
425 auth_type = get_WORD(priv); /* AuthType */
426 get_WORD(priv); /* Reserve Area */
428 eth_hdr = (struct ether_hdr *)(priv->rxp);
429 eth_proto = ntohs(eth_hdr->h_proto);
430 DPRINTK(3, "ether protocol = %04X\n", eth_proto);
432 /* source address check */
433 if (memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN) == 0) {
434 DPRINTK(1, "invalid : source is own mac address !!\n");
436 "eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
437 eth_hdr->h_source[0], eth_hdr->h_source[1],
438 eth_hdr->h_source[2], eth_hdr->h_source[3],
439 eth_hdr->h_source[4], eth_hdr->h_source[5]);
440 priv->nstats.rx_errors++;
445 if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled) {
446 ret = hostif_data_indication_wpa(priv, auth_type);
451 if ((priv->connect_status & FORCE_DISCONNECT) ||
452 priv->wpa.mic_failure.failure == 2) {
456 /* check 13th byte at rx data */
457 switch (*(priv->rxp + 12)) {
458 case 0xAA: /* SNAP */
459 rx_ind_size = priv->rx_size - 6;
460 skb = dev_alloc_skb(rx_ind_size);
462 priv->nstats.rx_dropped++;
465 DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size);
468 skb_put_data(skb, priv->rxp, size);
470 /* (SNAP+UI..) skip */
472 size = rx_ind_size - (ETH_ALEN * 2);
473 skb_put_data(skb, ð_hdr->h_proto, size);
475 aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + ETHER_HDR_SIZE);
477 case 0xF0: /* NETBEUI/NetBIOS */
478 rx_ind_size = (priv->rx_size + 2);
479 skb = dev_alloc_skb(rx_ind_size);
481 priv->nstats.rx_dropped++;
484 DPRINTK(3, "NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size);
486 skb_put_data(skb, priv->rxp, 12); /* 8802/FDDI MAC copy */
488 temp[0] = (((rx_ind_size - 12) >> 8) & 0xff); /* NETBEUI size add */
489 temp[1] = ((rx_ind_size - 12) & 0xff);
490 skb_put_data(skb, temp, 2);
492 skb_put_data(skb, priv->rxp + 12, rx_ind_size - 14); /* copy after Type */
494 aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
496 default: /* other rx data */
497 DPRINTK(2, "invalid data format\n");
498 priv->nstats.rx_errors++;
502 if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
503 priv->wpa.rsn_enabled)
504 atomic_set(&priv->psstatus.snooze_guard, 1);
507 skb->dev = priv->net_dev;
508 skb->protocol = eth_type_trans(skb, skb->dev);
509 priv->nstats.rx_packets++;
510 priv->nstats.rx_bytes += rx_ind_size;
515 void hostif_mib_get_confirm(struct ks_wlan_private *priv)
517 struct net_device *dev = priv->net_dev;
525 mib_status = get_DWORD(priv); /* MIB status */
526 mib_attribute = get_DWORD(priv); /* MIB atttibute */
527 mib_val_size = get_WORD(priv); /* MIB value size */
528 mib_val_type = get_WORD(priv); /* MIB value type */
531 /* in case of error */
532 DPRINTK(1, "attribute=%08X, status=%08X\n", mib_attribute,
537 switch (mib_attribute) {
538 case DOT11_MAC_ADDRESS:
540 DPRINTK(3, " mib_attribute=DOT11_MAC_ADDRESS\n");
541 hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
542 memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
543 priv->mac_address_valid = 1;
544 dev->dev_addr[0] = priv->eth_addr[0];
545 dev->dev_addr[1] = priv->eth_addr[1];
546 dev->dev_addr[2] = priv->eth_addr[2];
547 dev->dev_addr[3] = priv->eth_addr[3];
548 dev->dev_addr[4] = priv->eth_addr[4];
549 dev->dev_addr[5] = priv->eth_addr[5];
550 dev->dev_addr[6] = 0x00;
551 dev->dev_addr[7] = 0x00;
552 netdev_info(dev, "MAC ADDRESS = %pM\n", priv->eth_addr);
554 case DOT11_PRODUCT_VERSION:
555 /* firmware version */
556 DPRINTK(3, " mib_attribute=DOT11_PRODUCT_VERSION\n");
557 priv->version_size = priv->rx_size;
558 memcpy(priv->firmware_version, priv->rxp, priv->rx_size);
559 priv->firmware_version[priv->rx_size] = '\0';
560 netdev_info(dev, "firmware ver. = %s\n",
561 priv->firmware_version);
562 hostif_sme_enqueue(priv, SME_GET_PRODUCT_VERSION);
563 /* wake_up_interruptible_all(&priv->confirm_wait); */
564 complete(&priv->confirm_wait);
567 memcpy(&priv->gain, priv->rxp, sizeof(priv->gain));
568 DPRINTK(3, "tx_mode=%d, rx_mode=%d, tx_gain=%d, rx_gain=%d\n",
569 priv->gain.tx_mode, priv->gain.rx_mode,
570 priv->gain.tx_gain, priv->gain.rx_gain);
572 case LOCAL_EEPROM_SUM:
573 memcpy(&priv->eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum));
574 DPRINTK(1, "eeprom_sum.type=%x, eeprom_sum.result=%x\n",
575 priv->eeprom_sum.type, priv->eeprom_sum.result);
576 if (priv->eeprom_sum.type == 0) {
577 priv->eeprom_checksum = EEPROM_CHECKSUM_NONE;
578 } else if (priv->eeprom_sum.type == 1) {
579 if (priv->eeprom_sum.result == 0) {
580 priv->eeprom_checksum = EEPROM_NG;
581 netdev_info(dev, "LOCAL_EEPROM_SUM NG\n");
582 } else if (priv->eeprom_sum.result == 1) {
583 priv->eeprom_checksum = EEPROM_OK;
586 netdev_err(dev, "LOCAL_EEPROM_SUM error!\n");
590 DPRINTK(1, "mib_attribute=%08x\n", (unsigned int)mib_attribute);
596 void hostif_mib_set_confirm(struct ks_wlan_private *priv)
598 u32 mib_status; /* +04 MIB Status */
599 u32 mib_attribute; /* +08 MIB attribute */
603 mib_status = get_DWORD(priv); /* MIB Status */
604 mib_attribute = get_DWORD(priv); /* MIB attribute */
607 /* in case of error */
608 DPRINTK(1, "error :: attribute=%08X, status=%08X\n",
609 mib_attribute, mib_status);
612 switch (mib_attribute) {
613 case DOT11_RTS_THRESHOLD:
614 hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_CONFIRM);
616 case DOT11_FRAGMENTATION_THRESHOLD:
617 hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_CONFIRM);
619 case DOT11_WEP_DEFAULT_KEY_ID:
620 if (!priv->wpa.wpa_enabled)
621 hostif_sme_enqueue(priv, SME_WEP_INDEX_CONFIRM);
623 case DOT11_WEP_DEFAULT_KEY_VALUE1:
624 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE1:mib_status=%d\n",
626 if (priv->wpa.rsn_enabled)
627 hostif_sme_enqueue(priv, SME_SET_PMK_TSC);
629 hostif_sme_enqueue(priv, SME_WEP_KEY1_CONFIRM);
631 case DOT11_WEP_DEFAULT_KEY_VALUE2:
632 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE2:mib_status=%d\n",
634 if (priv->wpa.rsn_enabled)
635 hostif_sme_enqueue(priv, SME_SET_GMK1_TSC);
637 hostif_sme_enqueue(priv, SME_WEP_KEY2_CONFIRM);
639 case DOT11_WEP_DEFAULT_KEY_VALUE3:
640 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE3:mib_status=%d\n",
642 if (priv->wpa.rsn_enabled)
643 hostif_sme_enqueue(priv, SME_SET_GMK2_TSC);
645 hostif_sme_enqueue(priv, SME_WEP_KEY3_CONFIRM);
647 case DOT11_WEP_DEFAULT_KEY_VALUE4:
648 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE4:mib_status=%d\n",
650 if (!priv->wpa.rsn_enabled)
651 hostif_sme_enqueue(priv, SME_WEP_KEY4_CONFIRM);
653 case DOT11_PRIVACY_INVOKED:
654 if (!priv->wpa.rsn_enabled)
655 hostif_sme_enqueue(priv, SME_WEP_FLAG_CONFIRM);
657 case DOT11_RSN_ENABLED:
658 DPRINTK(2, "DOT11_RSN_ENABLED:mib_status=%d\n",
660 hostif_sme_enqueue(priv, SME_RSN_ENABLED_CONFIRM);
663 hostif_sme_enqueue(priv, SME_RSN_MODE_CONFIRM);
665 case LOCAL_MULTICAST_ADDRESS:
666 hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST);
668 case LOCAL_MULTICAST_FILTER:
669 hostif_sme_enqueue(priv, SME_MULTICAST_CONFIRM);
671 case LOCAL_CURRENTADDRESS:
672 priv->mac_address_valid = 1;
674 case DOT11_RSN_CONFIG_MULTICAST_CIPHER:
675 DPRINTK(2, "DOT11_RSN_CONFIG_MULTICAST_CIPHER:mib_status=%d\n",
677 hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM);
679 case DOT11_RSN_CONFIG_UNICAST_CIPHER:
680 DPRINTK(2, "DOT11_RSN_CONFIG_UNICAST_CIPHER:mib_status=%d\n",
682 hostif_sme_enqueue(priv, SME_RSN_UCAST_CONFIRM);
684 case DOT11_RSN_CONFIG_AUTH_SUITE:
685 DPRINTK(2, "DOT11_RSN_CONFIG_AUTH_SUITE:mib_status=%d\n",
687 hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM);
690 DPRINTK(2, "DOT11_PMK_TSC:mib_status=%d\n", (int)mib_status);
693 DPRINTK(2, "DOT11_GMK1_TSC:mib_status=%d\n", (int)mib_status);
694 if (atomic_read(&priv->psstatus.snooze_guard))
695 atomic_set(&priv->psstatus.snooze_guard, 0);
698 DPRINTK(2, "DOT11_GMK2_TSC:mib_status=%d\n", (int)mib_status);
699 if (atomic_read(&priv->psstatus.snooze_guard))
700 atomic_set(&priv->psstatus.snooze_guard, 0);
703 DPRINTK(2, "LOCAL_PMK:mib_status=%d\n", (int)mib_status);
706 DPRINTK(2, "LOCAL_GAIN:mib_status=%d\n", (int)mib_status);
709 case LOCAL_WPS_ENABLE:
710 DPRINTK(2, "LOCAL_WPS_ENABLE:mib_status=%d\n", (int)mib_status);
712 case LOCAL_WPS_PROBE_REQ:
713 DPRINTK(2, "LOCAL_WPS_PROBE_REQ:mib_status=%d\n",
718 DPRINTK(2, "LOCAL_REGION:mib_status=%d\n", (int)mib_status);
725 void hostif_power_mgmt_confirm(struct ks_wlan_private *priv)
729 if (priv->reg.power_mgmt > POWER_MGMT_ACTIVE &&
730 priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
731 atomic_set(&priv->psstatus.confirm_wait, 0);
732 priv->dev_state = DEVICE_STATE_SLEEP;
733 ks_wlan_hw_power_save(priv);
735 priv->dev_state = DEVICE_STATE_READY;
740 void hostif_sleep_confirm(struct ks_wlan_private *priv)
744 atomic_set(&priv->sleepstatus.doze_request, 1);
745 queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
749 void hostif_start_confirm(struct ks_wlan_private *priv)
752 union iwreq_data wrqu;
754 wrqu.data.length = 0;
756 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
757 if (is_connect_status(priv->connect_status)) {
758 eth_zero_addr(wrqu.ap_addr.sa_data);
759 DPRINTK(3, "IWEVENT: disconnect\n");
760 wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
763 DPRINTK(3, " scan_ind_count=%d\n", priv->scan_ind_count);
764 hostif_sme_enqueue(priv, SME_START_CONFIRM);
768 void hostif_connect_indication(struct ks_wlan_private *priv)
770 unsigned short connect_code;
771 unsigned int tmp = 0;
772 unsigned int old_status = priv->connect_status;
773 struct net_device *netdev = priv->net_dev;
774 union iwreq_data wrqu0;
776 connect_code = get_WORD(priv);
778 switch (connect_code) {
779 case RESULT_CONNECT: /* connect */
780 DPRINTK(3, "connect :: scan_ind_count=%d\n",
781 priv->scan_ind_count);
782 if (!(priv->connect_status & FORCE_DISCONNECT))
783 netif_carrier_on(netdev);
784 tmp = FORCE_DISCONNECT & priv->connect_status;
785 priv->connect_status = tmp + CONNECT_STATUS;
787 case RESULT_DISCONNECT: /* disconnect */
788 DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
789 priv->scan_ind_count);
790 netif_carrier_off(netdev);
791 tmp = FORCE_DISCONNECT & priv->connect_status;
792 priv->connect_status = tmp + DISCONNECT_STATUS;
795 DPRINTK(1, "unknown connect_code=%d :: scan_ind_count=%d\n",
796 connect_code, priv->scan_ind_count);
797 netif_carrier_off(netdev);
798 tmp = FORCE_DISCONNECT & priv->connect_status;
799 priv->connect_status = tmp + DISCONNECT_STATUS;
803 get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
804 if (is_connect_status(priv->connect_status) &&
805 is_disconnect_status(old_status)) {
807 atomic_set(&priv->psstatus.snooze_guard, 0);
808 atomic_set(&priv->psstatus.confirm_wait, 0);
810 ks_wlan_do_power_save(priv);
812 wrqu0.data.length = 0;
813 wrqu0.data.flags = 0;
814 wrqu0.ap_addr.sa_family = ARPHRD_ETHER;
815 if (is_disconnect_status(priv->connect_status) &&
816 is_connect_status(old_status)) {
817 eth_zero_addr(wrqu0.ap_addr.sa_data);
818 DPRINTK(3, "IWEVENT: disconnect\n");
819 DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
820 priv->scan_ind_count);
821 wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL);
823 priv->scan_ind_count = 0;
827 void hostif_scan_indication(struct ks_wlan_private *priv)
830 struct ap_info_t *ap_info;
832 DPRINTK(3, "scan_ind_count = %d\n", priv->scan_ind_count);
833 ap_info = (struct ap_info_t *)(priv->rxp);
835 if (priv->scan_ind_count) {
836 for (i = 0; i < priv->aplist.size; i++) { /* bssid check */
837 if (memcmp(ap_info->bssid,
838 priv->aplist.ap[i].bssid, ETH_ALEN) != 0)
841 if (ap_info->frame_type == FRAME_TYPE_PROBE_RESP)
842 get_ap_information(priv, ap_info,
843 &priv->aplist.ap[i]);
847 priv->scan_ind_count++;
848 if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
849 DPRINTK(4, " scan_ind_count=%d :: aplist.size=%d\n",
850 priv->scan_ind_count, priv->aplist.size);
851 get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
852 &(priv->aplist.ap[priv->scan_ind_count - 1]));
853 priv->aplist.size = priv->scan_ind_count;
855 DPRINTK(4, " count over :: scan_ind_count=%d\n",
856 priv->scan_ind_count);
861 void hostif_stop_confirm(struct ks_wlan_private *priv)
863 unsigned int tmp = 0;
864 unsigned int old_status = priv->connect_status;
865 struct net_device *netdev = priv->net_dev;
866 union iwreq_data wrqu0;
869 if (priv->dev_state == DEVICE_STATE_SLEEP)
870 priv->dev_state = DEVICE_STATE_READY;
872 /* disconnect indication */
873 if (is_connect_status(priv->connect_status)) {
874 netif_carrier_off(netdev);
875 tmp = FORCE_DISCONNECT & priv->connect_status;
876 priv->connect_status = tmp | DISCONNECT_STATUS;
877 netdev_info(netdev, "IWEVENT: disconnect\n");
879 wrqu0.data.length = 0;
880 wrqu0.data.flags = 0;
881 wrqu0.ap_addr.sa_family = ARPHRD_ETHER;
882 if (is_disconnect_status(priv->connect_status) &&
883 is_connect_status(old_status)) {
884 eth_zero_addr(wrqu0.ap_addr.sa_data);
885 DPRINTK(3, "IWEVENT: disconnect\n");
886 netdev_info(netdev, "IWEVENT: disconnect\n");
887 DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
888 priv->scan_ind_count);
889 wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL);
891 priv->scan_ind_count = 0;
894 hostif_sme_enqueue(priv, SME_STOP_CONFIRM);
898 void hostif_ps_adhoc_set_confirm(struct ks_wlan_private *priv)
901 priv->infra_status = 0; /* infrastructure mode cancel */
902 hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
906 void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
911 result_code = get_WORD(priv);
912 DPRINTK(3, "result code = %d\n", result_code);
913 priv->infra_status = 1; /* infrastructure mode set */
914 hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
918 void hostif_adhoc_set_confirm(struct ks_wlan_private *priv)
921 priv->infra_status = 1; /* infrastructure mode set */
922 hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
926 void hostif_associate_indication(struct ks_wlan_private *priv)
928 struct association_request_t *assoc_req;
929 struct association_response_t *assoc_resp;
931 union iwreq_data wrqu;
932 char buf[IW_CUSTOM_MAX];
933 char *pbuf = &buf[0];
936 static const char associnfo_leader0[] = "ASSOCINFO(ReqIEs=";
937 static const char associnfo_leader1[] = " RespIEs=";
940 assoc_req = (struct association_request_t *)(priv->rxp);
941 assoc_resp = (struct association_response_t *)(assoc_req + 1);
942 pb = (unsigned char *)(assoc_resp + 1);
944 memset(&wrqu, 0, sizeof(wrqu));
945 memcpy(pbuf, associnfo_leader0, sizeof(associnfo_leader0) - 1);
946 wrqu.data.length += sizeof(associnfo_leader0) - 1;
947 pbuf += sizeof(associnfo_leader0) - 1;
949 for (i = 0; i < le16_to_cpu(assoc_req->req_ies_size); i++)
950 pbuf += sprintf(pbuf, "%02x", *(pb + i));
951 wrqu.data.length += (le16_to_cpu(assoc_req->req_ies_size)) * 2;
953 memcpy(pbuf, associnfo_leader1, sizeof(associnfo_leader1) - 1);
954 wrqu.data.length += sizeof(associnfo_leader1) - 1;
955 pbuf += sizeof(associnfo_leader1) - 1;
957 pb += le16_to_cpu(assoc_req->req_ies_size);
958 for (i = 0; i < le16_to_cpu(assoc_resp->resp_ies_size); i++)
959 pbuf += sprintf(pbuf, "%02x", *(pb + i));
960 wrqu.data.length += (le16_to_cpu(assoc_resp->resp_ies_size)) * 2;
962 pbuf += sprintf(pbuf, ")");
963 wrqu.data.length += 1;
965 DPRINTK(3, "IWEVENT:ASSOCINFO\n");
966 wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf);
970 void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
972 unsigned int result_code;
973 struct net_device *dev = priv->net_dev;
974 union iwreq_data wrqu;
976 result_code = get_DWORD(priv);
977 DPRINTK(2, "result=%d :: scan_ind_count=%d\n", result_code,
978 priv->scan_ind_count);
980 priv->sme_i.sme_flag &= ~SME_AP_SCAN;
981 hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM);
983 wrqu.data.length = 0;
985 DPRINTK(3, "IWEVENT: SCAN CONFIRM\n");
986 wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
987 priv->scan_ind_count = 0;
991 void hostif_phy_information_confirm(struct ks_wlan_private *priv)
993 struct iw_statistics *wstats = &priv->wstats;
994 unsigned char rssi, signal, noise;
995 unsigned char link_speed;
996 unsigned int transmitted_frame_count, received_fragment_count;
997 unsigned int failed_count, fcs_error_count;
1000 rssi = get_BYTE(priv);
1001 signal = get_BYTE(priv);
1002 noise = get_BYTE(priv);
1003 link_speed = get_BYTE(priv);
1004 transmitted_frame_count = get_DWORD(priv);
1005 received_fragment_count = get_DWORD(priv);
1006 failed_count = get_DWORD(priv);
1007 fcs_error_count = get_DWORD(priv);
1009 DPRINTK(4, "phyinfo confirm rssi=%d signal=%d\n", rssi, signal);
1010 priv->current_rate = (link_speed & RATE_MASK);
1011 wstats->qual.qual = signal;
1012 wstats->qual.level = 256 - rssi;
1013 wstats->qual.noise = 0; /* invalid noise value */
1014 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1016 DPRINTK(3, "\n rssi=%u\n"
1018 " link_speed=%ux500Kbps\n"
1019 " transmitted_frame_count=%u\n"
1020 " received_fragment_count=%u\n"
1021 " failed_count=%u\n"
1022 " fcs_error_count=%u\n",
1023 rssi, signal, link_speed, transmitted_frame_count,
1024 received_fragment_count, failed_count, fcs_error_count);
1025 /* wake_up_interruptible_all(&priv->confirm_wait); */
1026 complete(&priv->confirm_wait);
1030 void hostif_mic_failure_confirm(struct ks_wlan_private *priv)
1032 DPRINTK(3, "mic_failure=%u\n", priv->wpa.mic_failure.failure);
1033 hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM);
1037 void hostif_event_check(struct ks_wlan_private *priv)
1039 unsigned short event;
1042 event = get_WORD(priv); /* get event */
1045 hostif_data_indication(priv);
1047 case HIF_MIB_GET_CONF:
1048 hostif_mib_get_confirm(priv);
1050 case HIF_MIB_SET_CONF:
1051 hostif_mib_set_confirm(priv);
1053 case HIF_POWER_MGMT_CONF:
1054 hostif_power_mgmt_confirm(priv);
1056 case HIF_SLEEP_CONF:
1057 hostif_sleep_confirm(priv);
1059 case HIF_START_CONF:
1060 hostif_start_confirm(priv);
1062 case HIF_CONNECT_IND:
1063 hostif_connect_indication(priv);
1066 hostif_stop_confirm(priv);
1068 case HIF_PS_ADH_SET_CONF:
1069 hostif_ps_adhoc_set_confirm(priv);
1071 case HIF_INFRA_SET_CONF:
1072 case HIF_INFRA_SET2_CONF:
1073 hostif_infrastructure_set_confirm(priv);
1075 case HIF_ADH_SET_CONF:
1076 case HIF_ADH_SET2_CONF:
1077 hostif_adhoc_set_confirm(priv);
1079 case HIF_ASSOC_INFO_IND:
1080 hostif_associate_indication(priv);
1082 case HIF_MIC_FAILURE_CONF:
1083 hostif_mic_failure_confirm(priv);
1086 hostif_bss_scan_confirm(priv);
1088 case HIF_PHY_INFO_CONF:
1089 case HIF_PHY_INFO_IND:
1090 hostif_phy_information_confirm(priv);
1093 hostif_scan_indication(priv);
1095 case HIF_AP_SET_CONF:
1097 //DPRINTK(1, "undefined event[%04X]\n", event);
1098 netdev_err(priv->net_dev, "undefined event[%04X]\n", event);
1099 /* wake_up_all(&priv->confirm_wait); */
1100 complete(&priv->confirm_wait);
1104 /* add event to hostt buffer */
1105 priv->hostt.buff[priv->hostt.qtail] = event;
1106 priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE;
1109 /* allocate size bytes, set header size and event */
1110 static void *hostif_generic_request(size_t size, int event)
1112 struct hostif_hdr *p;
1114 p = kzalloc(hif_align_size(size), KS_WLAN_MEM_FLAG);
1118 p->size = cpu_to_le16((u16)(size - sizeof(p->size)));
1119 p->event = cpu_to_le16(event);
1124 int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
1126 unsigned int skb_len = 0;
1128 unsigned char *buffer = NULL;
1129 unsigned int length = 0;
1130 struct hostif_data_request_t *pp;
1133 unsigned short eth_proto;
1134 struct ether_hdr *eth_hdr;
1135 struct michael_mic_t michael_mic;
1136 unsigned short keyinfo = 0;
1137 struct ieee802_1x_hdr *aa1x_hdr;
1138 struct wpa_eapol_key *eap_key;
1144 if (skb_len > ETH_FRAME_LEN) {
1145 DPRINTK(1, "bad length skb_len=%d\n", skb_len);
1150 if (is_disconnect_status(priv->connect_status) ||
1151 (priv->connect_status & FORCE_DISCONNECT) ||
1152 priv->wpa.mic_failure.stop) {
1153 DPRINTK(3, " DISCONNECT\n");
1154 if (netif_queue_stopped(priv->net_dev))
1155 netif_wake_queue(priv->net_dev);
1163 if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { /* power save wakeup */
1164 if (!netif_queue_stopped(priv->net_dev))
1165 netif_stop_queue(priv->net_dev);
1168 size = sizeof(*pp) + 6 + skb_len + 8;
1169 pp = kmalloc(hif_align_size(size), KS_WLAN_MEM_FLAG);
1175 p = (unsigned char *)pp->data;
1181 eth = (struct ethhdr *)skb->data;
1182 if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN) != 0) {
1183 DPRINTK(1, "invalid mac address !!\n");
1184 DPRINTK(1, "ethernet->h_source=%pM\n", eth->h_source);
1189 /* dest and src MAC address copy */
1190 size = ETH_ALEN * 2;
1191 memcpy(p, buffer, size);
1196 /* EtherType/Length check */
1197 if (*(buffer + 1) + (*buffer << 8) > 1500) {
1198 /* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
1199 /* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */
1200 /* SAP/CTL/OUI(6 byte) add */
1201 *p++ = 0xAA; /* DSAP */
1202 *p++ = 0xAA; /* SSAP */
1203 *p++ = 0x03; /* CTL */
1204 *p++ = 0x00; /* OUI ("000000") */
1205 *p++ = 0x00; /* OUI ("000000") */
1206 *p++ = 0x00; /* OUI ("000000") */
1209 DPRINTK(4, "DIX\n");
1210 /* Length(2 byte) delete */
1217 memcpy(p, buffer, length);
1222 eth_hdr = (struct ether_hdr *)&pp->data[0];
1223 eth_proto = ntohs(eth_hdr->h_proto);
1225 /* for MIC FAILURE REPORT check */
1226 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP &&
1227 priv->wpa.mic_failure.failure > 0) {
1228 aa1x_hdr = (struct ieee802_1x_hdr *)(eth_hdr + 1);
1229 if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY) {
1230 eap_key = (struct wpa_eapol_key *)(aa1x_hdr + 1);
1231 keyinfo = ntohs(eap_key->key_info);
1235 if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len) {
1236 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP &&
1237 priv->wpa.key[1].key_len == 0 &&
1238 priv->wpa.key[2].key_len == 0 &&
1239 priv->wpa.key[3].key_len == 0) {
1240 pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); /* no encryption */
1242 if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) {
1243 MichaelMICFunction(&michael_mic,
1244 (uint8_t *)priv->wpa.key[0].tx_mic_key,
1245 (uint8_t *)&pp->data[0],
1247 (uint8_t)0, /* priority */
1248 (uint8_t *)michael_mic.Result);
1249 memcpy(p, michael_mic.Result, 8);
1254 cpu_to_le16((uint16_t)TYPE_DATA);
1256 } else if (priv->wpa.pairwise_suite ==
1257 IW_AUTH_CIPHER_CCMP) {
1259 cpu_to_le16((uint16_t)TYPE_DATA);
1263 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP)
1264 pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH);
1266 pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA);
1269 /* header value set */
1271 cpu_to_le16((uint16_t)
1272 (sizeof(*pp) - sizeof(pp->header.size) + skb_len));
1273 pp->header.event = cpu_to_le16((uint16_t)HIF_DATA_REQ);
1276 result = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + skb_len),
1277 send_packet_complete, skb);
1279 /* MIC FAILURE REPORT check */
1280 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP &&
1281 priv->wpa.mic_failure.failure > 0) {
1282 if (keyinfo & WPA_KEY_INFO_ERROR &&
1283 keyinfo & WPA_KEY_INFO_REQUEST) {
1284 DPRINTK(3, " MIC ERROR Report SET : %04X\n", keyinfo);
1285 hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST);
1287 if (priv->wpa.mic_failure.failure == 2)
1288 priv->wpa.mic_failure.stop = 1;
1301 #define ps_confirm_wait_inc(priv) \
1303 if (atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET) \
1304 atomic_inc(&priv->psstatus.confirm_wait); \
1308 void hostif_mib_get_request(struct ks_wlan_private *priv,
1309 unsigned long mib_attribute)
1311 struct hostif_mib_get_request_t *pp;
1315 pp = hostif_generic_request(sizeof(*pp), HIF_MIB_GET_REQ);
1319 pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
1321 /* send to device request */
1322 ps_confirm_wait_inc(priv);
1323 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1327 void hostif_mib_set_request(struct ks_wlan_private *priv,
1328 unsigned long mib_attribute, unsigned short size,
1329 unsigned short type, void *vp)
1331 struct hostif_mib_set_request_t *pp;
1335 if (priv->dev_state < DEVICE_STATE_BOOT) {
1336 DPRINTK(3, "DeviceRemove\n");
1340 pp = hostif_generic_request(sizeof(*pp), HIF_MIB_SET_REQ);
1344 pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
1345 pp->mib_value.size = cpu_to_le16((uint16_t)size);
1346 pp->mib_value.type = cpu_to_le16((uint16_t)type);
1347 memcpy(&pp->mib_value.body, vp, size);
1349 /* send to device request */
1350 ps_confirm_wait_inc(priv);
1351 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL);
1355 void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
1357 struct hostif_start_request_t *pp;
1361 pp = hostif_generic_request(sizeof(*pp), HIF_START_REQ);
1365 pp->mode = cpu_to_le16((uint16_t)mode);
1367 /* send to device request */
1368 ps_confirm_wait_inc(priv);
1369 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1371 priv->aplist.size = 0;
1372 priv->scan_ind_count = 0;
1376 void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv)
1378 struct hostif_ps_adhoc_set_request_t *pp;
1383 pp = hostif_generic_request(sizeof(*pp), HIF_PS_ADH_SET_REQ);
1387 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1388 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1389 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1390 pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
1391 pp->rate_set.size = priv->reg.rate_set.size;
1392 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1393 priv->reg.rate_set.size);
1395 capability = 0x0000;
1396 if (priv->reg.preamble == SHORT_PREAMBLE) {
1397 /* short preamble */
1398 capability |= BSS_CAP_SHORT_PREAMBLE;
1400 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1401 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1402 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1403 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM */
1405 pp->capability = cpu_to_le16((uint16_t)capability);
1407 /* send to device request */
1408 ps_confirm_wait_inc(priv);
1409 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1413 void hostif_infrastructure_set_request(struct ks_wlan_private *priv)
1415 struct hostif_infrastructure_set_request_t *pp;
1418 DPRINTK(3, "ssid.size=%d\n", priv->reg.ssid.size);
1420 pp = hostif_generic_request(sizeof(*pp), HIF_INFRA_SET_REQ);
1424 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1425 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1426 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1428 pp->rate_set.size = priv->reg.rate_set.size;
1429 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1430 priv->reg.rate_set.size);
1431 pp->ssid.size = priv->reg.ssid.size;
1432 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1434 capability = 0x0000;
1435 if (priv->reg.preamble == SHORT_PREAMBLE) {
1436 /* short preamble */
1437 capability |= BSS_CAP_SHORT_PREAMBLE;
1439 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1440 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1441 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1442 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1444 pp->capability = cpu_to_le16((uint16_t)capability);
1445 pp->beacon_lost_count =
1446 cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
1447 pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type));
1449 pp->channel_list.body[0] = 1;
1450 pp->channel_list.body[1] = 8;
1451 pp->channel_list.body[2] = 2;
1452 pp->channel_list.body[3] = 9;
1453 pp->channel_list.body[4] = 3;
1454 pp->channel_list.body[5] = 10;
1455 pp->channel_list.body[6] = 4;
1456 pp->channel_list.body[7] = 11;
1457 pp->channel_list.body[8] = 5;
1458 pp->channel_list.body[9] = 12;
1459 pp->channel_list.body[10] = 6;
1460 pp->channel_list.body[11] = 13;
1461 pp->channel_list.body[12] = 7;
1462 if (priv->reg.phy_type == D_11G_ONLY_MODE) {
1463 pp->channel_list.size = 13;
1465 pp->channel_list.body[13] = 14;
1466 pp->channel_list.size = 14;
1469 /* send to device request */
1470 ps_confirm_wait_inc(priv);
1471 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1474 static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv)
1476 struct hostif_infrastructure_set2_request_t *pp;
1479 DPRINTK(2, "ssid.size=%d\n", priv->reg.ssid.size);
1481 pp = hostif_generic_request(sizeof(*pp), HIF_INFRA_SET2_REQ);
1485 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1486 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1487 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1489 pp->rate_set.size = priv->reg.rate_set.size;
1490 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1491 priv->reg.rate_set.size);
1492 pp->ssid.size = priv->reg.ssid.size;
1493 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1495 capability = 0x0000;
1496 if (priv->reg.preamble == SHORT_PREAMBLE) {
1497 /* short preamble */
1498 capability |= BSS_CAP_SHORT_PREAMBLE;
1500 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1501 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1502 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1503 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1505 pp->capability = cpu_to_le16((uint16_t)capability);
1506 pp->beacon_lost_count =
1507 cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
1508 pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type));
1510 pp->channel_list.body[0] = 1;
1511 pp->channel_list.body[1] = 8;
1512 pp->channel_list.body[2] = 2;
1513 pp->channel_list.body[3] = 9;
1514 pp->channel_list.body[4] = 3;
1515 pp->channel_list.body[5] = 10;
1516 pp->channel_list.body[6] = 4;
1517 pp->channel_list.body[7] = 11;
1518 pp->channel_list.body[8] = 5;
1519 pp->channel_list.body[9] = 12;
1520 pp->channel_list.body[10] = 6;
1521 pp->channel_list.body[11] = 13;
1522 pp->channel_list.body[12] = 7;
1523 if (priv->reg.phy_type == D_11G_ONLY_MODE) {
1524 pp->channel_list.size = 13;
1526 pp->channel_list.body[13] = 14;
1527 pp->channel_list.size = 14;
1530 memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
1532 /* send to device request */
1533 ps_confirm_wait_inc(priv);
1534 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1538 void hostif_adhoc_set_request(struct ks_wlan_private *priv)
1540 struct hostif_adhoc_set_request_t *pp;
1545 pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
1549 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1550 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1551 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1552 pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
1553 pp->rate_set.size = priv->reg.rate_set.size;
1554 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1555 priv->reg.rate_set.size);
1556 pp->ssid.size = priv->reg.ssid.size;
1557 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1559 capability = 0x0000;
1560 if (priv->reg.preamble == SHORT_PREAMBLE) {
1561 /* short preamble */
1562 capability |= BSS_CAP_SHORT_PREAMBLE;
1564 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1565 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1566 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1567 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1569 pp->capability = cpu_to_le16((uint16_t)capability);
1571 /* send to device request */
1572 ps_confirm_wait_inc(priv);
1573 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1577 void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
1579 struct hostif_adhoc_set2_request_t *pp;
1584 pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
1588 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1589 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1590 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1591 pp->rate_set.size = priv->reg.rate_set.size;
1592 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1593 priv->reg.rate_set.size);
1594 pp->ssid.size = priv->reg.ssid.size;
1595 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1597 capability = 0x0000;
1598 if (priv->reg.preamble == SHORT_PREAMBLE) {
1599 /* short preamble */
1600 capability |= BSS_CAP_SHORT_PREAMBLE;
1602 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1603 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1604 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1605 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1607 pp->capability = cpu_to_le16((uint16_t)capability);
1609 pp->channel_list.body[0] = priv->reg.channel;
1610 pp->channel_list.size = 1;
1611 memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
1613 /* send to device request */
1614 ps_confirm_wait_inc(priv);
1615 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1619 void hostif_stop_request(struct ks_wlan_private *priv)
1621 struct hostif_stop_request_t *pp;
1625 pp = hostif_generic_request(sizeof(*pp), HIF_STOP_REQ);
1629 /* send to device request */
1630 ps_confirm_wait_inc(priv);
1631 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1635 void hostif_phy_information_request(struct ks_wlan_private *priv)
1637 struct hostif_phy_information_request_t *pp;
1641 pp = hostif_generic_request(sizeof(*pp), HIF_PHY_INFO_REQ);
1645 if (priv->reg.phy_info_timer) {
1646 pp->type = cpu_to_le16((uint16_t)TIME_TYPE);
1647 pp->time = cpu_to_le16((uint16_t)(priv->reg.phy_info_timer));
1649 pp->type = cpu_to_le16((uint16_t)NORMAL_TYPE);
1650 pp->time = cpu_to_le16((uint16_t)0);
1653 /* send to device request */
1654 ps_confirm_wait_inc(priv);
1655 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1659 void hostif_power_mgmt_request(struct ks_wlan_private *priv,
1660 unsigned long mode, unsigned long wake_up,
1661 unsigned long receive_dtims)
1663 struct hostif_power_mgmt_request_t *pp;
1665 DPRINTK(3, "mode=%lu wake_up=%lu receive_dtims=%lu\n", mode, wake_up,
1668 pp = hostif_generic_request(sizeof(*pp), HIF_POWER_MGMT_REQ);
1672 pp->mode = cpu_to_le32((uint32_t)mode);
1673 pp->wake_up = cpu_to_le32((uint32_t)wake_up);
1674 pp->receive_dtims = cpu_to_le32((uint32_t)receive_dtims);
1676 /* send to device request */
1677 ps_confirm_wait_inc(priv);
1678 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1682 void hostif_sleep_request(struct ks_wlan_private *priv,
1683 enum sleep_mode_type mode)
1685 struct hostif_sleep_request_t *pp;
1687 DPRINTK(3, "mode=%lu\n", (long)mode);
1689 if (mode == SLP_SLEEP) {
1690 pp = hostif_generic_request(sizeof(*pp), HIF_SLEEP_REQ);
1694 /* send to device request */
1695 ps_confirm_wait_inc(priv);
1696 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL,
1698 } else if (mode == SLP_ACTIVE) {
1699 atomic_set(&priv->sleepstatus.wakeup_request, 1);
1700 queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
1702 DPRINTK(3, "invalid mode %ld\n", (long)mode);
1708 void hostif_bss_scan_request(struct ks_wlan_private *priv,
1709 unsigned long scan_type, uint8_t *scan_ssid,
1710 uint8_t scan_ssid_len)
1712 struct hostif_bss_scan_request_t *pp;
1716 pp = hostif_generic_request(sizeof(*pp), HIF_SCAN_REQ);
1720 pp->scan_type = scan_type;
1722 pp->ch_time_min = cpu_to_le32((uint32_t)110); /* default value */
1723 pp->ch_time_max = cpu_to_le32((uint32_t)130); /* default value */
1724 pp->channel_list.body[0] = 1;
1725 pp->channel_list.body[1] = 8;
1726 pp->channel_list.body[2] = 2;
1727 pp->channel_list.body[3] = 9;
1728 pp->channel_list.body[4] = 3;
1729 pp->channel_list.body[5] = 10;
1730 pp->channel_list.body[6] = 4;
1731 pp->channel_list.body[7] = 11;
1732 pp->channel_list.body[8] = 5;
1733 pp->channel_list.body[9] = 12;
1734 pp->channel_list.body[10] = 6;
1735 pp->channel_list.body[11] = 13;
1736 pp->channel_list.body[12] = 7;
1737 if (priv->reg.phy_type == D_11G_ONLY_MODE) {
1738 pp->channel_list.size = 13;
1740 pp->channel_list.body[13] = 14;
1741 pp->channel_list.size = 14;
1745 /* specified SSID SCAN */
1746 if (scan_ssid_len > 0 && scan_ssid_len <= 32) {
1747 pp->ssid.size = scan_ssid_len;
1748 memcpy(&pp->ssid.body[0], scan_ssid, scan_ssid_len);
1751 /* send to device request */
1752 ps_confirm_wait_inc(priv);
1753 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1755 priv->aplist.size = 0;
1756 priv->scan_ind_count = 0;
1760 void hostif_mic_failure_request(struct ks_wlan_private *priv,
1761 unsigned short failure_count,
1762 unsigned short timer)
1764 struct hostif_mic_failure_request_t *pp;
1766 DPRINTK(3, "count=%d :: timer=%d\n", failure_count, timer);
1768 pp = hostif_generic_request(sizeof(*pp), HIF_MIC_FAILURE_REQ);
1772 pp->failure_count = cpu_to_le16((uint16_t)failure_count);
1773 pp->timer = cpu_to_le16((uint16_t)timer);
1775 /* send to device request */
1776 ps_confirm_wait_inc(priv);
1777 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
1780 /* Device I/O Receive indicate */
1781 static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p,
1784 if (priv->device_open_status) {
1785 spin_lock(&priv->dev_read_lock); /* request spin lock */
1786 priv->dev_data[atomic_read(&priv->rec_count)] = p;
1787 priv->dev_size[atomic_read(&priv->rec_count)] = size;
1789 if (atomic_read(&priv->event_count) != DEVICE_STOCK_COUNT) {
1790 /* rx event count inc */
1791 atomic_inc(&priv->event_count);
1793 atomic_inc(&priv->rec_count);
1794 if (atomic_read(&priv->rec_count) == DEVICE_STOCK_COUNT)
1795 atomic_set(&priv->rec_count, 0);
1797 wake_up_interruptible_all(&priv->devread_wait);
1799 /* release spin lock */
1800 spin_unlock(&priv->dev_read_lock);
1804 void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
1809 devio_rec_ind(priv, p, size);
1812 priv->rx_size = size;
1814 if (get_WORD(priv) == priv->rx_size) { /* length check !! */
1815 hostif_event_check(priv); /* event check */
1820 void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
1825 case SME_WEP_INDEX_REQUEST:
1826 val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
1827 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
1828 sizeof(val), MIB_VALUE_TYPE_INT, &val);
1830 case SME_WEP_KEY1_REQUEST:
1831 if (!priv->wpa.wpa_enabled)
1832 hostif_mib_set_request(priv,
1833 DOT11_WEP_DEFAULT_KEY_VALUE1,
1834 priv->reg.wep_key[0].size,
1835 MIB_VALUE_TYPE_OSTRING,
1836 &priv->reg.wep_key[0].val[0]);
1838 case SME_WEP_KEY2_REQUEST:
1839 if (!priv->wpa.wpa_enabled)
1840 hostif_mib_set_request(priv,
1841 DOT11_WEP_DEFAULT_KEY_VALUE2,
1842 priv->reg.wep_key[1].size,
1843 MIB_VALUE_TYPE_OSTRING,
1844 &priv->reg.wep_key[1].val[0]);
1846 case SME_WEP_KEY3_REQUEST:
1847 if (!priv->wpa.wpa_enabled)
1848 hostif_mib_set_request(priv,
1849 DOT11_WEP_DEFAULT_KEY_VALUE3,
1850 priv->reg.wep_key[2].size,
1851 MIB_VALUE_TYPE_OSTRING,
1852 &priv->reg.wep_key[2].val[0]);
1854 case SME_WEP_KEY4_REQUEST:
1855 if (!priv->wpa.wpa_enabled)
1856 hostif_mib_set_request(priv,
1857 DOT11_WEP_DEFAULT_KEY_VALUE4,
1858 priv->reg.wep_key[3].size,
1859 MIB_VALUE_TYPE_OSTRING,
1860 &priv->reg.wep_key[3].val[0]);
1862 case SME_WEP_FLAG_REQUEST:
1863 val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
1864 hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
1865 sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
1870 struct wpa_suite_t {
1872 unsigned char suite[4][CIPHER_ID_LEN];
1877 __le16 rsn_capability;
1881 void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
1883 struct wpa_suite_t wpa_suite;
1884 struct rsn_mode_t rsn_mode;
1887 memset(&wpa_suite, 0, sizeof(wpa_suite));
1890 case SME_RSN_UCAST_REQUEST:
1891 wpa_suite.size = cpu_to_le16((uint16_t)1);
1892 switch (priv->wpa.pairwise_suite) {
1893 case IW_AUTH_CIPHER_NONE:
1894 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1895 memcpy(&wpa_suite.suite[0][0],
1896 CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
1898 memcpy(&wpa_suite.suite[0][0],
1899 CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
1901 case IW_AUTH_CIPHER_WEP40:
1902 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1903 memcpy(&wpa_suite.suite[0][0],
1904 CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
1906 memcpy(&wpa_suite.suite[0][0],
1907 CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
1909 case IW_AUTH_CIPHER_TKIP:
1910 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1911 memcpy(&wpa_suite.suite[0][0],
1912 CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
1914 memcpy(&wpa_suite.suite[0][0],
1915 CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
1917 case IW_AUTH_CIPHER_CCMP:
1918 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1919 memcpy(&wpa_suite.suite[0][0],
1920 CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
1922 memcpy(&wpa_suite.suite[0][0],
1923 CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
1925 case IW_AUTH_CIPHER_WEP104:
1926 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1927 memcpy(&wpa_suite.suite[0][0],
1928 CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
1930 memcpy(&wpa_suite.suite[0][0],
1931 CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
1935 hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER,
1936 sizeof(wpa_suite.size) +
1938 le16_to_cpu(wpa_suite.size),
1939 MIB_VALUE_TYPE_OSTRING, &wpa_suite);
1941 case SME_RSN_MCAST_REQUEST:
1942 switch (priv->wpa.group_suite) {
1943 case IW_AUTH_CIPHER_NONE:
1944 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1945 memcpy(&wpa_suite.suite[0][0],
1946 CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
1948 memcpy(&wpa_suite.suite[0][0],
1949 CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
1951 case IW_AUTH_CIPHER_WEP40:
1952 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1953 memcpy(&wpa_suite.suite[0][0],
1954 CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
1956 memcpy(&wpa_suite.suite[0][0],
1957 CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
1959 case IW_AUTH_CIPHER_TKIP:
1960 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1961 memcpy(&wpa_suite.suite[0][0],
1962 CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
1964 memcpy(&wpa_suite.suite[0][0],
1965 CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
1967 case IW_AUTH_CIPHER_CCMP:
1968 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1969 memcpy(&wpa_suite.suite[0][0],
1970 CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
1972 memcpy(&wpa_suite.suite[0][0],
1973 CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
1975 case IW_AUTH_CIPHER_WEP104:
1976 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1977 memcpy(&wpa_suite.suite[0][0],
1978 CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
1980 memcpy(&wpa_suite.suite[0][0],
1981 CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
1985 hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER,
1986 CIPHER_ID_LEN, MIB_VALUE_TYPE_OSTRING,
1987 &wpa_suite.suite[0][0]);
1989 case SME_RSN_AUTH_REQUEST:
1990 wpa_suite.size = cpu_to_le16((uint16_t)1);
1991 switch (priv->wpa.key_mgmt_suite) {
1992 case IW_AUTH_KEY_MGMT_802_1X:
1993 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1994 memcpy(&wpa_suite.suite[0][0],
1995 KEY_MGMT_ID_WPA2_1X, KEY_MGMT_ID_LEN);
1997 memcpy(&wpa_suite.suite[0][0],
1998 KEY_MGMT_ID_WPA_1X, KEY_MGMT_ID_LEN);
2000 case IW_AUTH_KEY_MGMT_PSK:
2001 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2002 memcpy(&wpa_suite.suite[0][0],
2003 KEY_MGMT_ID_WPA2_PSK, KEY_MGMT_ID_LEN);
2005 memcpy(&wpa_suite.suite[0][0],
2006 KEY_MGMT_ID_WPA_PSK, KEY_MGMT_ID_LEN);
2009 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2010 memcpy(&wpa_suite.suite[0][0],
2011 KEY_MGMT_ID_WPA2_NONE, KEY_MGMT_ID_LEN);
2013 memcpy(&wpa_suite.suite[0][0],
2014 KEY_MGMT_ID_WPA_NONE, KEY_MGMT_ID_LEN);
2017 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2018 memcpy(&wpa_suite.suite[0][0],
2019 KEY_MGMT_ID_WPA2_WPANONE,
2022 memcpy(&wpa_suite.suite[0][0],
2023 KEY_MGMT_ID_WPA_WPANONE,
2028 hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE,
2029 sizeof(wpa_suite.size) +
2031 le16_to_cpu(wpa_suite.size),
2032 MIB_VALUE_TYPE_OSTRING, &wpa_suite);
2034 case SME_RSN_ENABLED_REQUEST:
2035 val = cpu_to_le32((uint32_t)(priv->wpa.rsn_enabled));
2036 hostif_mib_set_request(priv, DOT11_RSN_ENABLED,
2037 sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
2039 case SME_RSN_MODE_REQUEST:
2040 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
2042 cpu_to_le32((uint32_t)RSN_MODE_WPA2);
2043 rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
2044 } else if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) {
2046 cpu_to_le32((uint32_t)RSN_MODE_WPA);
2047 rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
2050 cpu_to_le32((uint32_t)RSN_MODE_NONE);
2051 rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
2053 hostif_mib_set_request(priv, LOCAL_RSN_MODE, sizeof(rsn_mode),
2054 MIB_VALUE_TYPE_OSTRING, &rsn_mode);
2060 void hostif_sme_mode_setup(struct ks_wlan_private *priv)
2062 unsigned char rate_size;
2063 unsigned char rate_octet[RATE_SET_MAX_SIZE];
2066 /* rate setting if rate segging is auto for changing phy_type (#94) */
2067 if (priv->reg.tx_rate == TX_RATE_FULL_AUTO) {
2068 if (priv->reg.phy_type == D_11B_ONLY_MODE) {
2069 priv->reg.rate_set.body[3] = TX_RATE_11M;
2070 priv->reg.rate_set.body[2] = TX_RATE_5M;
2071 priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE;
2072 priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE;
2073 priv->reg.rate_set.size = 4;
2074 } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
2075 priv->reg.rate_set.body[11] = TX_RATE_54M;
2076 priv->reg.rate_set.body[10] = TX_RATE_48M;
2077 priv->reg.rate_set.body[9] = TX_RATE_36M;
2078 priv->reg.rate_set.body[8] = TX_RATE_18M;
2079 priv->reg.rate_set.body[7] = TX_RATE_9M;
2080 priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE;
2081 priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE;
2082 priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE;
2083 priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE;
2084 priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE;
2085 priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE;
2086 priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE;
2087 priv->reg.rate_set.size = 12;
2091 /* rate mask by phy setting */
2092 if (priv->reg.phy_type == D_11B_ONLY_MODE) {
2093 for (i = 0; i < priv->reg.rate_set.size; i++) {
2094 if (!IS_11B_RATE(priv->reg.rate_set.body[i]))
2097 if ((priv->reg.rate_set.body[i] & RATE_MASK) >= TX_RATE_5M) {
2098 rate_octet[i] = priv->reg.rate_set.body[i] &
2101 rate_octet[i] = priv->reg.rate_set.body[i];
2105 } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
2106 for (i = 0; i < priv->reg.rate_set.size; i++) {
2107 if (!IS_11BG_RATE(priv->reg.rate_set.body[i]))
2110 if (IS_OFDM_EXT_RATE(priv->reg.rate_set.body[i])) {
2111 rate_octet[i] = priv->reg.rate_set.body[i] &
2114 rate_octet[i] = priv->reg.rate_set.body[i];
2119 if (rate_size == 0) {
2120 if (priv->reg.phy_type == D_11G_ONLY_MODE)
2121 rate_octet[0] = TX_RATE_6M | BASIC_RATE;
2123 rate_octet[0] = TX_RATE_2M | BASIC_RATE;
2127 /* rate set update */
2128 priv->reg.rate_set.size = rate_size;
2129 memcpy(&priv->reg.rate_set.body[0], &rate_octet[0], rate_size);
2131 switch (priv->reg.operation_mode) {
2132 case MODE_PSEUDO_ADHOC:
2133 /* Pseudo Ad-Hoc mode */
2134 hostif_ps_adhoc_set_request(priv);
2136 case MODE_INFRASTRUCTURE:
2137 /* Infrastructure mode */
2138 if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
2139 hostif_infrastructure_set_request(priv);
2141 hostif_infrastructure_set2_request(priv);
2143 "Infra bssid = %pM\n", priv->reg.bssid);
2147 /* IEEE802.11 Ad-Hoc mode */
2148 if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
2149 hostif_adhoc_set_request(priv);
2151 hostif_adhoc_set2_request(priv);
2153 "Adhoc bssid = %pM\n", priv->reg.bssid);
2162 void hostif_sme_multicast_set(struct ks_wlan_private *priv)
2164 struct net_device *dev = priv->net_dev;
2166 struct netdev_hw_addr *ha;
2167 char set_address[NIC_MAX_MCAST_LIST * ETH_ALEN];
2173 spin_lock(&priv->multicast_spin);
2175 memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN);
2177 if (dev->flags & IFF_PROMISC) {
2178 filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_PROMISC);
2179 hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
2180 sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
2185 if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) ||
2186 (dev->flags & IFF_ALLMULTI)) {
2187 filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCASTALL);
2188 hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
2189 sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
2194 if (priv->sme_i.sme_flag & SME_MULTICAST) {
2195 mc_count = netdev_mc_count(dev);
2196 netdev_for_each_mc_addr(ha, dev) {
2197 memcpy(&set_address[i * ETH_ALEN], ha->addr, ETH_ALEN);
2200 priv->sme_i.sme_flag &= ~SME_MULTICAST;
2201 hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS,
2202 ETH_ALEN * mc_count,
2203 MIB_VALUE_TYPE_OSTRING,
2206 filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCAST);
2207 priv->sme_i.sme_flag |= SME_MULTICAST;
2208 hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
2209 sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
2214 spin_unlock(&priv->multicast_spin);
2218 void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
2220 unsigned long mode, wake_up, receive_dtims;
2223 switch (priv->reg.power_mgmt) {
2224 case POWER_MGMT_ACTIVE:
2225 mode = POWER_ACTIVE;
2229 case POWER_MGMT_SAVE1:
2230 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
2235 mode = POWER_ACTIVE;
2240 case POWER_MGMT_SAVE2:
2241 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
2246 mode = POWER_ACTIVE;
2252 mode = POWER_ACTIVE;
2257 hostif_power_mgmt_request(priv, mode, wake_up, receive_dtims);
2261 void hostif_sme_sleep_set(struct ks_wlan_private *priv)
2264 switch (priv->sleep_mode) {
2266 hostif_sleep_request(priv, priv->sleep_mode);
2269 hostif_sleep_request(priv, priv->sleep_mode);
2277 void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
2283 val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
2284 hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
2285 sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
2288 val = cpu_to_le32((uint32_t)(priv->wpa.txkey));
2289 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
2290 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2293 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1,
2294 priv->wpa.key[0].key_len,
2295 MIB_VALUE_TYPE_OSTRING,
2296 &priv->wpa.key[0].key_val[0]);
2299 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2,
2300 priv->wpa.key[1].key_len,
2301 MIB_VALUE_TYPE_OSTRING,
2302 &priv->wpa.key[1].key_val[0]);
2305 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3,
2306 priv->wpa.key[2].key_len,
2307 MIB_VALUE_TYPE_OSTRING,
2308 &priv->wpa.key[2].key_val[0]);
2311 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4,
2312 priv->wpa.key[3].key_len,
2313 MIB_VALUE_TYPE_OSTRING,
2314 &priv->wpa.key[3].key_val[0]);
2316 case SME_SET_PMK_TSC:
2317 hostif_mib_set_request(priv, DOT11_PMK_TSC,
2318 WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
2319 &priv->wpa.key[0].rx_seq[0]);
2321 case SME_SET_GMK1_TSC:
2322 hostif_mib_set_request(priv, DOT11_GMK1_TSC,
2323 WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
2324 &priv->wpa.key[1].rx_seq[0]);
2326 case SME_SET_GMK2_TSC:
2327 hostif_mib_set_request(priv, DOT11_GMK2_TSC,
2328 WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
2329 &priv->wpa.key[2].rx_seq[0]);
2335 void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
2337 struct pmk_cache_t {
2341 u8 pmkid[IW_PMKID_LEN];
2342 } __packed list[PMK_LIST_MAX];
2343 } __packed pmkcache;
2347 DPRINTK(4, "pmklist.size=%d\n", priv->pmklist.size);
2349 list_for_each_entry(pmk, &priv->pmklist.head, list) {
2350 if (i < PMK_LIST_MAX) {
2351 memcpy(pmkcache.list[i].bssid, pmk->bssid, ETH_ALEN);
2352 memcpy(pmkcache.list[i].pmkid, pmk->pmkid,
2357 pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size));
2358 hostif_mib_set_request(priv, LOCAL_PMK,
2359 sizeof(priv->pmklist.size) + (ETH_ALEN +
2361 (priv->pmklist.size), MIB_VALUE_TYPE_OSTRING,
2367 void hostif_sme_execute(struct ks_wlan_private *priv, int event)
2371 DPRINTK(3, "event=%d\n", event);
2374 if (priv->dev_state == DEVICE_STATE_BOOT)
2375 hostif_mib_get_request(priv, DOT11_MAC_ADDRESS);
2377 case SME_MULTICAST_REQUEST:
2378 hostif_sme_multicast_set(priv);
2380 case SME_MACADDRESS_SET_REQUEST:
2381 hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN,
2382 MIB_VALUE_TYPE_OSTRING,
2383 &priv->eth_addr[0]);
2385 case SME_BSS_SCAN_REQUEST:
2386 hostif_bss_scan_request(priv, priv->reg.scan_type,
2387 priv->scan_ssid, priv->scan_ssid_len);
2389 case SME_POW_MNGMT_REQUEST:
2390 hostif_sme_power_mgmt_set(priv);
2392 case SME_PHY_INFO_REQUEST:
2393 hostif_phy_information_request(priv);
2395 case SME_MIC_FAILURE_REQUEST:
2396 if (priv->wpa.mic_failure.failure == 1) {
2397 hostif_mic_failure_request(priv,
2398 priv->wpa.mic_failure.failure - 1,
2400 } else if (priv->wpa.mic_failure.failure == 2) {
2401 hostif_mic_failure_request(priv,
2402 priv->wpa.mic_failure.failure - 1,
2403 priv->wpa.mic_failure.counter);
2405 DPRINTK(4, "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n",
2406 priv->wpa.mic_failure.failure);
2409 case SME_MIC_FAILURE_CONFIRM:
2410 if (priv->wpa.mic_failure.failure == 2) {
2411 if (priv->wpa.mic_failure.stop)
2412 priv->wpa.mic_failure.stop = 0;
2413 priv->wpa.mic_failure.failure = 0;
2414 hostif_start_request(priv, priv->reg.operation_mode);
2417 case SME_GET_MAC_ADDRESS:
2418 if (priv->dev_state == DEVICE_STATE_BOOT)
2419 hostif_mib_get_request(priv, DOT11_PRODUCT_VERSION);
2421 case SME_GET_PRODUCT_VERSION:
2422 if (priv->dev_state == DEVICE_STATE_BOOT)
2423 priv->dev_state = DEVICE_STATE_PREINIT;
2425 case SME_STOP_REQUEST:
2426 hostif_stop_request(priv);
2428 case SME_RTS_THRESHOLD_REQUEST:
2429 val = cpu_to_le32((uint32_t)(priv->reg.rts));
2430 hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD,
2431 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2433 case SME_FRAGMENTATION_THRESHOLD_REQUEST:
2434 val = cpu_to_le32((uint32_t)(priv->reg.fragment));
2435 hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD,
2436 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2438 case SME_WEP_INDEX_REQUEST:
2439 case SME_WEP_KEY1_REQUEST:
2440 case SME_WEP_KEY2_REQUEST:
2441 case SME_WEP_KEY3_REQUEST:
2442 case SME_WEP_KEY4_REQUEST:
2443 case SME_WEP_FLAG_REQUEST:
2444 hostif_sme_set_wep(priv, event);
2446 case SME_RSN_UCAST_REQUEST:
2447 case SME_RSN_MCAST_REQUEST:
2448 case SME_RSN_AUTH_REQUEST:
2449 case SME_RSN_ENABLED_REQUEST:
2450 case SME_RSN_MODE_REQUEST:
2451 hostif_sme_set_rsn(priv, event);
2459 case SME_SET_PMK_TSC:
2460 case SME_SET_GMK1_TSC:
2461 case SME_SET_GMK2_TSC:
2462 hostif_sme_set_key(priv, event);
2465 hostif_sme_set_pmksa(priv);
2468 case SME_WPS_ENABLE_REQUEST:
2469 hostif_mib_set_request(priv, LOCAL_WPS_ENABLE,
2470 sizeof(priv->wps.wps_enabled),
2472 &priv->wps.wps_enabled);
2474 case SME_WPS_PROBE_REQUEST:
2475 hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ,
2477 MIB_VALUE_TYPE_OSTRING, priv->wps.ie);
2480 case SME_MODE_SET_REQUEST:
2481 hostif_sme_mode_setup(priv);
2484 hostif_mib_set_request(priv, LOCAL_GAIN,
2486 MIB_VALUE_TYPE_OSTRING, &priv->gain);
2489 hostif_mib_get_request(priv, LOCAL_GAIN);
2491 case SME_GET_EEPROM_CKSUM:
2492 priv->eeprom_checksum = EEPROM_FW_NOT_SUPPORT; /* initialize */
2493 hostif_mib_get_request(priv, LOCAL_EEPROM_SUM);
2495 case SME_START_REQUEST:
2496 hostif_start_request(priv, priv->reg.operation_mode);
2498 case SME_START_CONFIRM:
2499 /* for power save */
2500 atomic_set(&priv->psstatus.snooze_guard, 0);
2501 atomic_set(&priv->psstatus.confirm_wait, 0);
2502 if (priv->dev_state == DEVICE_STATE_PREINIT)
2503 priv->dev_state = DEVICE_STATE_INIT;
2504 /* wake_up_interruptible_all(&priv->confirm_wait); */
2505 complete(&priv->confirm_wait);
2507 case SME_SLEEP_REQUEST:
2508 hostif_sme_sleep_set(priv);
2510 case SME_SET_REGION:
2511 val = cpu_to_le32((uint32_t)(priv->region));
2512 hostif_mib_set_request(priv, LOCAL_REGION,
2513 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2515 case SME_MULTICAST_CONFIRM:
2516 case SME_BSS_SCAN_CONFIRM:
2517 case SME_POW_MNGMT_CONFIRM:
2518 case SME_PHY_INFO_CONFIRM:
2519 case SME_STOP_CONFIRM:
2520 case SME_RTS_THRESHOLD_CONFIRM:
2521 case SME_FRAGMENTATION_THRESHOLD_CONFIRM:
2522 case SME_WEP_INDEX_CONFIRM:
2523 case SME_WEP_KEY1_CONFIRM:
2524 case SME_WEP_KEY2_CONFIRM:
2525 case SME_WEP_KEY3_CONFIRM:
2526 case SME_WEP_KEY4_CONFIRM:
2527 case SME_WEP_FLAG_CONFIRM:
2528 case SME_RSN_UCAST_CONFIRM:
2529 case SME_RSN_MCAST_CONFIRM:
2530 case SME_RSN_AUTH_CONFIRM:
2531 case SME_RSN_ENABLED_CONFIRM:
2532 case SME_RSN_MODE_CONFIRM:
2533 case SME_MODE_SET_CONFIRM:
2542 void hostif_sme_task(unsigned long dev)
2544 struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;
2548 if (priv->dev_state < DEVICE_STATE_BOOT)
2551 if (cnt_smeqbody(priv) <= 0)
2554 hostif_sme_execute(priv, priv->sme_i.event_buff[priv->sme_i.qhead]);
2556 if (cnt_smeqbody(priv) > 0)
2557 tasklet_schedule(&priv->sme_task);
2560 /* send to Station Management Entity module */
2561 void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
2565 /* enqueue sme event */
2566 if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) {
2567 priv->sme_i.event_buff[priv->sme_i.qtail] = event;
2569 #ifdef KS_WLAN_DEBUG
2570 if (priv->sme_i.max_event_count < cnt_smeqbody(priv))
2571 priv->sme_i.max_event_count = cnt_smeqbody(priv);
2572 #endif /* KS_WLAN_DEBUG */
2574 /* in case of buffer overflow */
2575 netdev_err(priv->net_dev, "sme queue buffer overflow\n");
2578 tasklet_schedule(&priv->sme_task);
2581 int hostif_init(struct ks_wlan_private *priv)
2587 priv->aplist.size = 0;
2588 for (i = 0; i < LOCAL_APLIST_MAX; i++)
2589 memset(&priv->aplist.ap[i], 0, sizeof(struct local_ap_t));
2590 priv->infra_status = 0;
2591 priv->current_rate = 4;
2592 priv->connect_status = DISCONNECT_STATUS;
2594 spin_lock_init(&priv->multicast_spin);
2596 spin_lock_init(&priv->dev_read_lock);
2597 init_waitqueue_head(&priv->devread_wait);
2598 priv->dev_count = 0;
2599 atomic_set(&priv->event_count, 0);
2600 atomic_set(&priv->rec_count, 0);
2602 /* for power save */
2603 atomic_set(&priv->psstatus.status, PS_NONE);
2604 atomic_set(&priv->psstatus.confirm_wait, 0);
2605 atomic_set(&priv->psstatus.snooze_guard, 0);
2606 init_completion(&priv->psstatus.wakeup_wait);
2607 INIT_WORK(&priv->wakeup_work, ks_wlan_hw_wakeup_task);
2610 memset(&priv->wpa, 0, sizeof(priv->wpa));
2611 priv->wpa.rsn_enabled = 0;
2612 priv->wpa.mic_failure.failure = 0;
2613 priv->wpa.mic_failure.last_failure_time = 0;
2614 priv->wpa.mic_failure.stop = 0;
2615 memset(&priv->pmklist, 0, sizeof(priv->pmklist));
2616 INIT_LIST_HEAD(&priv->pmklist.head);
2617 for (i = 0; i < PMK_LIST_MAX; i++)
2618 INIT_LIST_HEAD(&priv->pmklist.pmk[i].list);
2620 priv->sme_i.sme_status = SME_IDLE;
2621 priv->sme_i.qhead = 0;
2622 priv->sme_i.qtail = 0;
2623 #ifdef KS_WLAN_DEBUG
2624 priv->sme_i.max_event_count = 0;
2626 spin_lock_init(&priv->sme_i.sme_spin);
2627 priv->sme_i.sme_flag = 0;
2629 tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv);
2634 void hostif_exit(struct ks_wlan_private *priv)
2636 tasklet_kill(&priv->sme_task);