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 =
70 container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task);
71 int ps_status = atomic_read(&priv->psstatus.status);
74 if (ps_status == PS_SNOOZE) {
75 ks_wlan_hw_wakeup_request(priv);
76 time_left = wait_for_completion_interruptible_timeout(
77 &priv->psstatus.wakeup_wait,
78 msecs_to_jiffies(20));
80 DPRINTK(1, "wake up timeout or interrupted !!!\n");
81 schedule_work(&priv->ks_wlan_wakeup_task);
85 DPRINTK(1, "ps_status=%d\n", ps_status);
89 if (atomic_read(&priv->sme_task.count) > 0) {
90 DPRINTK(4, "sme task enable.\n");
91 tasklet_enable(&priv->sme_task);
96 int ks_wlan_do_power_save(struct ks_wlan_private *priv)
98 DPRINTK(4, "psstatus.status=%d\n", atomic_read(&priv->psstatus.status));
100 if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
101 hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
103 priv->dev_state = DEVICE_STATE_READY;
109 int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
111 struct local_ap_t *ap;
112 union iwreq_data wrqu;
113 struct net_device *netdev = priv->net_dev;
117 ap = &(priv->current_ap);
119 if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) {
120 memset(ap, 0, sizeof(struct local_ap_t));
125 memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
127 memcpy(&(ap->ssid.body[0]), &(priv->reg.ssid.body[0]),
128 priv->reg.ssid.size);
129 ap->ssid.size = priv->reg.ssid.size;
131 memcpy(&(ap->rate_set.body[0]), &(ap_info->rate_set.body[0]),
132 ap_info->rate_set.size);
133 ap->rate_set.size = ap_info->rate_set.size;
134 if (ap_info->ext_rate_set.size) {
136 memcpy(&(ap->rate_set.body[ap->rate_set.size]),
137 &(ap_info->ext_rate_set.body[0]),
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 = 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[0]), &(ap_info->rsn.body[0]),
160 ap->rsn_ie.size = RSN_IE_BODY_MAX;
161 memcpy(&(ap->rsn_ie.body[0]), &(ap_info->rsn.body[0]),
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[0]), &(ap_info->rsn.body[0]),
172 ap->wpa_ie.size = RSN_IE_BODY_MAX;
173 memcpy(&(ap->wpa_ie.body[0]), &(ap_info->rsn.body[0]),
183 wrqu.data.length = 0;
185 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
186 if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
187 memcpy(wrqu.ap_addr.sa_data,
188 &(priv->current_ap.bssid[0]), ETH_ALEN);
190 "IWEVENT: connect bssid=%02x:%02x:%02x:%02x:%02x:%02x\n",
191 (unsigned char)wrqu.ap_addr.sa_data[0],
192 (unsigned char)wrqu.ap_addr.sa_data[1],
193 (unsigned char)wrqu.ap_addr.sa_data[2],
194 (unsigned char)wrqu.ap_addr.sa_data[3],
195 (unsigned char)wrqu.ap_addr.sa_data[4],
196 (unsigned char)wrqu.ap_addr.sa_data[5]);
197 wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
199 DPRINTK(4, "\n Link AP\n");
200 DPRINTK(4, " bssid=%02X:%02X:%02X:%02X:%02X:%02X\n \
201 essid=%s\n rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n channel=%d\n \
202 rssi=%d\n sq=%d\n capability=%04X\n", ap->bssid[0], ap->bssid[1], ap->bssid[2], ap->bssid[3], ap->bssid[4], ap->bssid[5], &(ap->ssid.body[0]), ap->rate_set.body[0], ap->rate_set.body[1], ap->rate_set.body[2], ap->rate_set.body[3], ap->rate_set.body[4], ap->rate_set.body[5], ap->rate_set.body[6], ap->rate_set.body[7], ap->channel, ap->rssi, ap->sq, ap->capability);
203 DPRINTK(4, "\n Link AP\n rsn.mode=%d\n rsn.size=%d\n",
204 ap_info->rsn_mode, ap_info->rsn.size);
205 DPRINTK(4, "\n ext_rate_set_size=%d\n rate_set_size=%d\n",
206 ap_info->ext_rate_set.size, ap_info->rate_set.size);
212 int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
213 struct local_ap_t *ap)
219 memset(ap, 0, sizeof(struct local_ap_t));
222 memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
224 ap->rssi = ap_info->rssi;
226 ap->sq = ap_info->sq;
228 ap->noise = ap_info->noise;
230 ap->capability = ap_info->capability;
232 ap->channel = ap_info->ch_info;
234 bp = &(ap_info->body[0]);
235 bsize = ap_info->body_size;
238 while (bsize > offset) {
239 /* DPRINTK(4, "Element ID=%d\n",*bp); */
242 if (*(bp + 1) <= SSID_MAX_SIZE) {
243 ap->ssid.size = *(bp + 1);
245 DPRINTK(1, "size over :: ssid size=%d\n",
247 ap->ssid.size = SSID_MAX_SIZE;
249 memcpy(&(ap->ssid.body[0]), bp + 2, ap->ssid.size);
252 case 50: /* ext rate */
253 if ((*(bp + 1) + ap->rate_set.size) <=
255 memcpy(&(ap->rate_set.body[ap->rate_set.size]),
257 ap->rate_set.size += *(bp + 1);
259 DPRINTK(1, "size over :: rate size=%d\n",
260 (*(bp + 1) + ap->rate_set.size));
261 memcpy(&(ap->rate_set.body[ap->rate_set.size]),
263 RATE_SET_MAX_SIZE - ap->rate_set.size);
265 (RATE_SET_MAX_SIZE - ap->rate_set.size);
268 case 3: /* DS parameter */
270 case 48: /* RSN(WPA2) */
272 if (*(bp + 1) <= RSN_IE_BODY_MAX) {
273 ap->rsn_ie.size = *(bp + 1);
275 DPRINTK(1, "size over :: rsn size=%d\n",
277 ap->rsn_ie.size = RSN_IE_BODY_MAX;
279 memcpy(&(ap->rsn_ie.body[0]), bp + 2, ap->rsn_ie.size);
282 if (!memcmp(bp + 2, "\x00\x50\xf2\x01", 4)) { /* WPA OUI check */
284 if (*(bp + 1) <= RSN_IE_BODY_MAX) {
285 ap->wpa_ie.size = *(bp + 1);
288 "size over :: wpa size=%d\n",
290 ap->wpa_ie.size = RSN_IE_BODY_MAX;
292 memcpy(&(ap->wpa_ie.body[0]), bp + 2,
297 case 2: /* FH parameter */
298 case 4: /* CF parameter */
300 case 6: /* IBSS parameter */
301 case 7: /* Country */
302 case 42: /* ERP information */
303 case 47: /* Reserve ID 47 Broadcom AP */
306 DPRINTK(4, "unknown Element ID=%d\n", *bp);
309 offset += 2; /* id & size field */
310 offset += *(bp + 1); /* +size offset */
311 bp += (*(bp + 1) + 2); /* pointer update */
318 void hostif_data_indication(struct ks_wlan_private *priv)
320 unsigned int rx_ind_size; /* indicate data size */
322 unsigned short auth_type;
323 unsigned char temp[256];
325 unsigned char RecvMIC[8];
327 struct ether_hdr *eth_hdr;
328 unsigned short eth_proto;
330 struct mic_failure_t *mic_failure;
331 struct ieee802_1x_hdr *aa1x_hdr;
332 struct wpa_eapol_key *eap_key;
333 struct michel_mic_t michel_mic;
334 union iwreq_data wrqu;
338 /* min length check */
339 if (priv->rx_size <= ETH_HLEN) {
340 DPRINTK(3, "rx_size = %d\n", priv->rx_size);
341 priv->nstats.rx_errors++;
345 auth_type = get_WORD(priv); /* AuthType */
346 get_WORD(priv); /* Reserve Area */
348 eth_hdr = (struct ether_hdr *)(priv->rxp);
349 eth_proto = ntohs(eth_hdr->h_proto);
350 DPRINTK(3, "ether protocol = %04X\n", eth_proto);
352 /* source address check */
353 if (!memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN)) {
354 DPRINTK(1, "invalid : source is own mac address !!\n");
356 "eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
357 eth_hdr->h_source[0], eth_hdr->h_source[1],
358 eth_hdr->h_source[2], eth_hdr->h_source[3],
359 eth_hdr->h_source[4], eth_hdr->h_source[5]);
360 priv->nstats.rx_errors++;
365 if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled) {
366 if (memcmp(ð_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN)) { /* source address check */
367 if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) {
368 DPRINTK(1, "invalid data format\n");
369 priv->nstats.rx_errors++;
372 if (((auth_type == TYPE_PMK1
373 && priv->wpa.pairwise_suite ==
374 IW_AUTH_CIPHER_TKIP) || (auth_type == TYPE_GMK1
378 || (auth_type == TYPE_GMK2
379 && priv->wpa.group_suite ==
380 IW_AUTH_CIPHER_TKIP))
381 && priv->wpa.key[auth_type - 1].key_len) {
382 DPRINTK(4, "TKIP: protocol=%04X: size=%u\n",
383 eth_proto, priv->rx_size);
386 (priv->rxp) + ((priv->rx_size) - 8), 8);
387 priv->rx_size = priv->rx_size - 8;
388 if (auth_type > 0 && auth_type < 4) { /* auth_type check */
389 MichaelMICFunction(&michel_mic, (uint8_t *) priv->wpa.key[auth_type - 1].rx_mic_key, (uint8_t *) priv->rxp, (int)priv->rx_size, (uint8_t) 0, /* priority */
393 if (memcmp(michel_mic.Result, RecvMIC, 8)) {
395 mic_failure = &priv->wpa.mic_failure;
397 if (mic_failure->last_failure_time &&
399 mic_failure->last_failure_time) /
401 mic_failure->failure = 0;
403 DPRINTK(4, "MIC FAILURE\n");
404 if (mic_failure->failure == 0) {
405 mic_failure->failure = 1;
406 mic_failure->counter = 0;
407 } else if (mic_failure->failure == 1) {
408 mic_failure->failure = 2;
409 mic_failure->counter =
414 if (!mic_failure->counter) /* mic_failure counter value range 1-60 */
415 mic_failure->counter =
418 priv->wpa.mic_failure.
419 last_failure_time = now;
420 /* needed parameters: count, keyid, key type, TSC */
422 "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr="
423 "%02x:%02x:%02x:%02x:%02x:%02x)",
426 h_dest[0] & 0x01 ? "broad" :
427 "uni", eth_hdr->h_source[0],
428 eth_hdr->h_source[1],
429 eth_hdr->h_source[2],
430 eth_hdr->h_source[3],
431 eth_hdr->h_source[4],
432 eth_hdr->h_source[5]);
433 memset(&wrqu, 0, sizeof(wrqu));
434 wrqu.data.length = strlen(buf);
436 "IWEVENT:MICHAELMICFAILURE\n");
437 wireless_send_event(priv->net_dev,
446 if ((priv->connect_status & FORCE_DISCONNECT) ||
447 priv->wpa.mic_failure.failure == 2) {
451 /* check 13th byte at rx data */
452 switch (*(priv->rxp + 12)) {
453 case 0xAA: /* SNAP */
454 rx_ind_size = priv->rx_size - 6;
455 skb = dev_alloc_skb(rx_ind_size);
456 DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size);
459 memcpy(skb_put(skb, 12), priv->rxp, 12); /* 8802/FDDI MAC copy */
460 /* (SNAP+UI..) skip */
461 memcpy(skb_put(skb, rx_ind_size - 12), priv->rxp + 18, rx_ind_size - 12); /* copy after Type */
463 aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 20);
464 if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY
465 && priv->wpa.rsn_enabled) {
467 (struct wpa_eapol_key *)(aa1x_hdr + 1);
468 atomic_set(&priv->psstatus.snooze_guard, 1);
472 skb->dev = priv->net_dev;
473 skb->protocol = eth_type_trans(skb, skb->dev);
474 priv->nstats.rx_packets++;
475 priv->nstats.rx_bytes += rx_ind_size;
476 skb->dev->last_rx = jiffies;
480 "ks_wlan: Memory squeeze, dropping packet.\n");
481 priv->nstats.rx_dropped++;
484 case 0xF0: /* NETBEUI/NetBIOS */
485 rx_ind_size = (priv->rx_size + 2);
486 skb = dev_alloc_skb(rx_ind_size);
487 DPRINTK(3, "NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size);
490 memcpy(skb_put(skb, 12), priv->rxp, 12); /* 8802/FDDI MAC copy */
492 temp[0] = (((rx_ind_size - 12) >> 8) & 0xff); /* NETBEUI size add */
493 temp[1] = ((rx_ind_size - 12) & 0xff);
494 memcpy(skb_put(skb, 2), temp, 2);
496 memcpy(skb_put(skb, rx_ind_size - 14), priv->rxp + 12, rx_ind_size - 14); /* copy after Type */
498 aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
499 if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY
500 && priv->wpa.rsn_enabled) {
502 (struct wpa_eapol_key *)(aa1x_hdr + 1);
503 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;
511 skb->dev->last_rx = jiffies;
515 "ks_wlan: Memory squeeze, dropping packet.\n");
516 priv->nstats.rx_dropped++;
519 default: /* other rx data */
520 DPRINTK(2, "invalid data format\n");
521 priv->nstats.rx_errors++;
526 void hostif_mib_get_confirm(struct ks_wlan_private *priv)
528 struct net_device *dev = priv->net_dev;
530 uint32_t mib_attribute;
531 uint16_t mib_val_size;
532 uint16_t mib_val_type;
536 mib_status = get_DWORD(priv); /* MIB status */
537 mib_attribute = get_DWORD(priv); /* MIB atttibute */
538 mib_val_size = get_WORD(priv); /* MIB value size */
539 mib_val_type = get_WORD(priv); /* MIB value type */
541 if (mib_status != 0) {
542 /* in case of error */
543 DPRINTK(1, "attribute=%08X, status=%08X\n", mib_attribute,
548 switch (mib_attribute) {
549 case DOT11_MAC_ADDRESS:
551 DPRINTK(3, " mib_attribute=DOT11_MAC_ADDRESS\n");
552 hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
553 memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
554 priv->mac_address_valid = 1;
555 dev->dev_addr[0] = priv->eth_addr[0];
556 dev->dev_addr[1] = priv->eth_addr[1];
557 dev->dev_addr[2] = priv->eth_addr[2];
558 dev->dev_addr[3] = priv->eth_addr[3];
559 dev->dev_addr[4] = priv->eth_addr[4];
560 dev->dev_addr[5] = priv->eth_addr[5];
561 dev->dev_addr[6] = 0x00;
562 dev->dev_addr[7] = 0x00;
564 "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n",
565 priv->eth_addr[0], priv->eth_addr[1], priv->eth_addr[2],
566 priv->eth_addr[3], priv->eth_addr[4], priv->eth_addr[5]);
568 case DOT11_PRODUCT_VERSION:
569 /* firmware version */
570 DPRINTK(3, " mib_attribute=DOT11_PRODUCT_VERSION\n");
571 priv->version_size = priv->rx_size;
572 memcpy(priv->firmware_version, priv->rxp, priv->rx_size);
573 priv->firmware_version[priv->rx_size] = '\0';
574 printk(KERN_INFO "ks_wlan: firmware ver. = %s\n",
575 priv->firmware_version);
576 hostif_sme_enqueue(priv, SME_GET_PRODUCT_VERSION);
577 /* wake_up_interruptible_all(&priv->confirm_wait); */
578 complete(&priv->confirm_wait);
581 memcpy(&priv->gain, priv->rxp, sizeof(priv->gain));
582 DPRINTK(3, "TxMode=%d, RxMode=%d, TxGain=%d, RxGain=%d\n",
583 priv->gain.TxMode, priv->gain.RxMode, priv->gain.TxGain,
586 case LOCAL_EEPROM_SUM:
587 memcpy(&priv->eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum));
588 DPRINTK(1, "eeprom_sum.type=%x, eeprom_sum.result=%x\n",
589 priv->eeprom_sum.type, priv->eeprom_sum.result);
590 if (priv->eeprom_sum.type == 0) {
591 priv->eeprom_checksum = EEPROM_CHECKSUM_NONE;
592 } else if (priv->eeprom_sum.type == 1) {
593 if (priv->eeprom_sum.result == 0) {
594 priv->eeprom_checksum = EEPROM_NG;
595 printk("LOCAL_EEPROM_SUM NG\n");
596 } else if (priv->eeprom_sum.result == 1) {
597 priv->eeprom_checksum = EEPROM_OK;
600 printk("LOCAL_EEPROM_SUM error!\n");
604 DPRINTK(1, "mib_attribute=%08x\n", (unsigned int)mib_attribute);
610 void hostif_mib_set_confirm(struct ks_wlan_private *priv)
612 uint32_t mib_status; /* +04 MIB Status */
613 uint32_t mib_attribute; /* +08 MIB attribute */
617 mib_status = get_DWORD(priv); /* MIB Status */
618 mib_attribute = get_DWORD(priv); /* MIB attribute */
620 if (mib_status != 0) {
621 /* in case of error */
622 DPRINTK(1, "error :: attribute=%08X, status=%08X\n",
623 mib_attribute, mib_status);
626 switch (mib_attribute) {
627 case DOT11_RTS_THRESHOLD:
628 hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_CONFIRM);
630 case DOT11_FRAGMENTATION_THRESHOLD:
631 hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_CONFIRM);
633 case DOT11_WEP_DEFAULT_KEY_ID:
634 if (!priv->wpa.wpa_enabled)
635 hostif_sme_enqueue(priv, SME_WEP_INDEX_CONFIRM);
637 case DOT11_WEP_DEFAULT_KEY_VALUE1:
638 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE1:mib_status=%d\n",
640 if (priv->wpa.rsn_enabled)
641 hostif_sme_enqueue(priv, SME_SET_PMK_TSC);
643 hostif_sme_enqueue(priv, SME_WEP_KEY1_CONFIRM);
645 case DOT11_WEP_DEFAULT_KEY_VALUE2:
646 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE2:mib_status=%d\n",
648 if (priv->wpa.rsn_enabled)
649 hostif_sme_enqueue(priv, SME_SET_GMK1_TSC);
651 hostif_sme_enqueue(priv, SME_WEP_KEY2_CONFIRM);
653 case DOT11_WEP_DEFAULT_KEY_VALUE3:
654 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE3:mib_status=%d\n",
656 if (priv->wpa.rsn_enabled)
657 hostif_sme_enqueue(priv, SME_SET_GMK2_TSC);
659 hostif_sme_enqueue(priv, SME_WEP_KEY3_CONFIRM);
661 case DOT11_WEP_DEFAULT_KEY_VALUE4:
662 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE4:mib_status=%d\n",
664 if (!priv->wpa.rsn_enabled)
665 hostif_sme_enqueue(priv, SME_WEP_KEY4_CONFIRM);
667 case DOT11_PRIVACY_INVOKED:
668 if (!priv->wpa.rsn_enabled)
669 hostif_sme_enqueue(priv, SME_WEP_FLAG_CONFIRM);
671 case DOT11_RSN_ENABLED:
672 DPRINTK(2, "DOT11_RSN_ENABLED:mib_status=%d\n",
674 hostif_sme_enqueue(priv, SME_RSN_ENABLED_CONFIRM);
677 hostif_sme_enqueue(priv, SME_RSN_MODE_CONFIRM);
679 case LOCAL_MULTICAST_ADDRESS:
680 hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST);
682 case LOCAL_MULTICAST_FILTER:
683 hostif_sme_enqueue(priv, SME_MULTICAST_CONFIRM);
685 case LOCAL_CURRENTADDRESS:
686 priv->mac_address_valid = 1;
688 case DOT11_RSN_CONFIG_MULTICAST_CIPHER:
689 DPRINTK(2, "DOT11_RSN_CONFIG_MULTICAST_CIPHER:mib_status=%d\n",
691 hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM);
693 case DOT11_RSN_CONFIG_UNICAST_CIPHER:
694 DPRINTK(2, "DOT11_RSN_CONFIG_UNICAST_CIPHER:mib_status=%d\n",
696 hostif_sme_enqueue(priv, SME_RSN_UCAST_CONFIRM);
698 case DOT11_RSN_CONFIG_AUTH_SUITE:
699 DPRINTK(2, "DOT11_RSN_CONFIG_AUTH_SUITE:mib_status=%d\n",
701 hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM);
704 DPRINTK(2, "DOT11_PMK_TSC:mib_status=%d\n", (int)mib_status);
707 DPRINTK(2, "DOT11_GMK1_TSC:mib_status=%d\n", (int)mib_status);
708 if (atomic_read(&priv->psstatus.snooze_guard)) {
709 atomic_set(&priv->psstatus.snooze_guard, 0);
713 DPRINTK(2, "DOT11_GMK2_TSC:mib_status=%d\n", (int)mib_status);
714 if (atomic_read(&priv->psstatus.snooze_guard)) {
715 atomic_set(&priv->psstatus.snooze_guard, 0);
719 DPRINTK(2, "LOCAL_PMK:mib_status=%d\n", (int)mib_status);
722 DPRINTK(2, "LOCAL_GAIN:mib_status=%d\n", (int)mib_status);
725 case LOCAL_WPS_ENABLE:
726 DPRINTK(2, "LOCAL_WPS_ENABLE:mib_status=%d\n", (int)mib_status);
728 case LOCAL_WPS_PROBE_REQ:
729 DPRINTK(2, "LOCAL_WPS_PROBE_REQ:mib_status=%d\n",
734 DPRINTK(2, "LOCAL_REGION:mib_status=%d\n", (int)mib_status);
741 void hostif_power_mngmt_confirm(struct ks_wlan_private *priv)
745 if (priv->reg.powermgt > POWMGT_ACTIVE_MODE &&
746 priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
747 atomic_set(&priv->psstatus.confirm_wait, 0);
748 priv->dev_state = DEVICE_STATE_SLEEP;
749 ks_wlan_hw_power_save(priv);
751 priv->dev_state = DEVICE_STATE_READY;
757 void hostif_sleep_confirm(struct ks_wlan_private *priv)
761 atomic_set(&priv->sleepstatus.doze_request, 1);
762 queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
763 &priv->ks_wlan_hw.rw_wq, 1);
767 void hostif_start_confirm(struct ks_wlan_private *priv)
770 union iwreq_data wrqu;
771 wrqu.data.length = 0;
773 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
774 if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
775 eth_zero_addr(wrqu.ap_addr.sa_data);
776 DPRINTK(3, "IWEVENT: disconnect\n");
777 wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
780 DPRINTK(3, " scan_ind_count=%d\n", priv->scan_ind_count);
781 hostif_sme_enqueue(priv, SME_START_CONFIRM);
785 void hostif_connect_indication(struct ks_wlan_private *priv)
787 unsigned short connect_code;
788 unsigned int tmp = 0;
789 unsigned int old_status = priv->connect_status;
790 struct net_device *netdev = priv->net_dev;
791 union iwreq_data wrqu0;
792 connect_code = get_WORD(priv);
794 switch (connect_code) {
795 case RESULT_CONNECT: /* connect */
796 DPRINTK(3, "connect :: scan_ind_count=%d\n",
797 priv->scan_ind_count);
798 if (!(priv->connect_status & FORCE_DISCONNECT))
799 netif_carrier_on(netdev);
800 tmp = FORCE_DISCONNECT & priv->connect_status;
801 priv->connect_status = tmp + CONNECT_STATUS;
803 case RESULT_DISCONNECT: /* disconnect */
804 DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
805 priv->scan_ind_count);
806 netif_carrier_off(netdev);
807 tmp = FORCE_DISCONNECT & priv->connect_status;
808 priv->connect_status = tmp + DISCONNECT_STATUS;
811 DPRINTK(1, "unknown connect_code=%d :: scan_ind_count=%d\n",
812 connect_code, priv->scan_ind_count);
813 netif_carrier_off(netdev);
814 tmp = FORCE_DISCONNECT & priv->connect_status;
815 priv->connect_status = tmp + DISCONNECT_STATUS;
819 get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
820 if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS &&
821 (old_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) {
823 atomic_set(&priv->psstatus.snooze_guard, 0);
824 atomic_set(&priv->psstatus.confirm_wait, 0);
826 ks_wlan_do_power_save(priv);
828 wrqu0.data.length = 0;
829 wrqu0.data.flags = 0;
830 wrqu0.ap_addr.sa_family = ARPHRD_ETHER;
831 if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS &&
832 (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
833 eth_zero_addr(wrqu0.ap_addr.sa_data);
834 DPRINTK(3, "IWEVENT: disconnect\n");
835 DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
836 priv->scan_ind_count);
837 wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL);
839 priv->scan_ind_count = 0;
843 void hostif_scan_indication(struct ks_wlan_private *priv)
846 struct ap_info_t *ap_info;
848 DPRINTK(3, "scan_ind_count = %d\n", priv->scan_ind_count);
849 ap_info = (struct ap_info_t *)(priv->rxp);
851 if (priv->scan_ind_count != 0) {
852 for (i = 0; i < priv->aplist.size; i++) { /* bssid check */
854 (&(ap_info->bssid[0]),
855 &(priv->aplist.ap[i].bssid[0]), ETH_ALEN)) {
856 if (ap_info->frame_type ==
857 FRAME_TYPE_PROBE_RESP)
858 get_ap_information(priv, ap_info,
865 priv->scan_ind_count++;
866 if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
867 DPRINTK(4, " scan_ind_count=%d :: aplist.size=%d\n",
868 priv->scan_ind_count, priv->aplist.size);
869 get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
871 ap[priv->scan_ind_count - 1]));
872 priv->aplist.size = priv->scan_ind_count;
874 DPRINTK(4, " count over :: scan_ind_count=%d\n",
875 priv->scan_ind_count);
881 void hostif_stop_confirm(struct ks_wlan_private *priv)
883 unsigned int tmp = 0;
884 unsigned int old_status = priv->connect_status;
885 struct net_device *netdev = priv->net_dev;
886 union iwreq_data wrqu0;
889 if (priv->dev_state == DEVICE_STATE_SLEEP)
890 priv->dev_state = DEVICE_STATE_READY;
892 /* disconnect indication */
893 if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
894 netif_carrier_off(netdev);
895 tmp = FORCE_DISCONNECT & priv->connect_status;
896 priv->connect_status = tmp | DISCONNECT_STATUS;
897 printk("IWEVENT: disconnect\n");
899 wrqu0.data.length = 0;
900 wrqu0.data.flags = 0;
901 wrqu0.ap_addr.sa_family = ARPHRD_ETHER;
902 if ((priv->connect_status & CONNECT_STATUS_MASK) ==
904 && (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
905 eth_zero_addr(wrqu0.ap_addr.sa_data);
906 DPRINTK(3, "IWEVENT: disconnect\n");
907 printk("IWEVENT: disconnect\n");
908 DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
909 priv->scan_ind_count);
910 wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL);
912 priv->scan_ind_count = 0;
915 hostif_sme_enqueue(priv, SME_STOP_CONFIRM);
919 void hostif_ps_adhoc_set_confirm(struct ks_wlan_private *priv)
922 priv->infra_status = 0; /* infrastructure mode cancel */
923 hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
928 void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
930 uint16_t result_code;
932 result_code = get_WORD(priv);
933 DPRINTK(3, "result code = %d\n", result_code);
934 priv->infra_status = 1; /* infrastructure mode set */
935 hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
939 void hostif_adhoc_set_confirm(struct ks_wlan_private *priv)
942 priv->infra_status = 1; /* infrastructure mode set */
943 hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
947 void hostif_associate_indication(struct ks_wlan_private *priv)
949 struct association_request_t *assoc_req;
950 struct association_response_t *assoc_resp;
952 union iwreq_data wrqu;
953 char buf[IW_CUSTOM_MAX];
954 char *pbuf = &buf[0];
957 static const char associnfo_leader0[] = "ASSOCINFO(ReqIEs=";
958 static const char associnfo_leader1[] = " RespIEs=";
961 assoc_req = (struct association_request_t *)(priv->rxp);
962 assoc_resp = (struct association_response_t *)(assoc_req + 1);
963 pb = (unsigned char *)(assoc_resp + 1);
965 memset(&wrqu, 0, sizeof(wrqu));
966 memcpy(pbuf, associnfo_leader0, sizeof(associnfo_leader0) - 1);
967 wrqu.data.length += sizeof(associnfo_leader0) - 1;
968 pbuf += sizeof(associnfo_leader0) - 1;
970 for (i = 0; i < assoc_req->reqIEs_size; i++)
971 pbuf += sprintf(pbuf, "%02x", *(pb + i));
972 wrqu.data.length += (assoc_req->reqIEs_size) * 2;
974 memcpy(pbuf, associnfo_leader1, sizeof(associnfo_leader1) - 1);
975 wrqu.data.length += sizeof(associnfo_leader1) - 1;
976 pbuf += sizeof(associnfo_leader1) - 1;
978 pb += assoc_req->reqIEs_size;
979 for (i = 0; i < assoc_resp->respIEs_size; i++)
980 pbuf += sprintf(pbuf, "%02x", *(pb + i));
981 wrqu.data.length += (assoc_resp->respIEs_size) * 2;
983 pbuf += sprintf(pbuf, ")");
984 wrqu.data.length += 1;
986 DPRINTK(3, "IWEVENT:ASSOCINFO\n");
987 wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf);
991 void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
993 unsigned int result_code;
994 struct net_device *dev = priv->net_dev;
995 union iwreq_data wrqu;
996 result_code = get_DWORD(priv);
997 DPRINTK(2, "result=%d :: scan_ind_count=%d\n", result_code,
998 priv->scan_ind_count);
1000 priv->sme_i.sme_flag &= ~SME_AP_SCAN;
1001 hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM);
1003 wrqu.data.length = 0;
1004 wrqu.data.flags = 0;
1005 DPRINTK(3, "IWEVENT: SCAN CONFIRM\n");
1006 wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
1007 priv->scan_ind_count = 0;
1011 void hostif_phy_information_confirm(struct ks_wlan_private *priv)
1013 struct iw_statistics *wstats = &priv->wstats;
1014 unsigned char rssi, signal, noise;
1015 unsigned char LinkSpeed;
1016 unsigned int TransmittedFrameCount, ReceivedFragmentCount;
1017 unsigned int FailedCount, FCSErrorCount;
1020 rssi = get_BYTE(priv);
1021 signal = get_BYTE(priv);
1022 noise = get_BYTE(priv);
1023 LinkSpeed = get_BYTE(priv);
1024 TransmittedFrameCount = get_DWORD(priv);
1025 ReceivedFragmentCount = get_DWORD(priv);
1026 FailedCount = get_DWORD(priv);
1027 FCSErrorCount = get_DWORD(priv);
1029 DPRINTK(4, "phyinfo confirm rssi=%d signal=%d\n", rssi, signal);
1030 priv->current_rate = (LinkSpeed & RATE_MASK);
1031 wstats->qual.qual = signal;
1032 wstats->qual.level = 256 - rssi;
1033 wstats->qual.noise = 0; /* invalid noise value */
1034 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1036 DPRINTK(3, "\n rssi=%u\n signal=%u\n LinkSpeed=%ux500Kbps\n \
1037 TransmittedFrameCount=%u\n ReceivedFragmentCount=%u\n FailedCount=%u\n \
1038 FCSErrorCount=%u\n", rssi, signal, LinkSpeed, TransmittedFrameCount, ReceivedFragmentCount, FailedCount, FCSErrorCount);
1040 /* wake_up_interruptible_all(&priv->confirm_wait); */
1041 complete(&priv->confirm_wait);
1045 void hostif_mic_failure_confirm(struct ks_wlan_private *priv)
1047 DPRINTK(3, "mic_failure=%u\n", priv->wpa.mic_failure.failure);
1048 hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM);
1052 void hostif_event_check(struct ks_wlan_private *priv)
1054 unsigned short event;
1057 event = get_WORD(priv); /* get event */
1060 hostif_data_indication(priv);
1062 case HIF_MIB_GET_CONF:
1063 hostif_mib_get_confirm(priv);
1065 case HIF_MIB_SET_CONF:
1066 hostif_mib_set_confirm(priv);
1068 case HIF_POWERMGT_CONF:
1069 hostif_power_mngmt_confirm(priv);
1071 case HIF_SLEEP_CONF:
1072 hostif_sleep_confirm(priv);
1074 case HIF_START_CONF:
1075 hostif_start_confirm(priv);
1077 case HIF_CONNECT_IND:
1078 hostif_connect_indication(priv);
1081 hostif_stop_confirm(priv);
1083 case HIF_PS_ADH_SET_CONF:
1084 hostif_ps_adhoc_set_confirm(priv);
1086 case HIF_INFRA_SET_CONF:
1087 case HIF_INFRA_SET2_CONF:
1088 hostif_infrastructure_set_confirm(priv);
1090 case HIF_ADH_SET_CONF:
1091 case HIF_ADH_SET2_CONF:
1092 hostif_adhoc_set_confirm(priv);
1094 case HIF_ASSOC_INFO_IND:
1095 hostif_associate_indication(priv);
1097 case HIF_MIC_FAILURE_CONF:
1098 hostif_mic_failure_confirm(priv);
1101 hostif_bss_scan_confirm(priv);
1103 case HIF_PHY_INFO_CONF:
1104 case HIF_PHY_INFO_IND:
1105 hostif_phy_information_confirm(priv);
1108 hostif_scan_indication(priv);
1110 case HIF_AP_SET_CONF:
1112 //DPRINTK(1, "undefined event[%04X]\n", event);
1113 printk("undefined event[%04X]\n", event);
1114 /* wake_up_all(&priv->confirm_wait); */
1115 complete(&priv->confirm_wait);
1119 /* add event to hostt buffer */
1120 priv->hostt.buff[priv->hostt.qtail] = event;
1121 priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE;
1124 #define CHECK_ALINE(size) (size%4 ? (size+(4-(size%4))):size)
1126 int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet)
1128 unsigned int packet_len = 0;
1130 unsigned char *buffer = NULL;
1131 unsigned int length = 0;
1132 struct hostif_data_request_t *pp;
1135 unsigned short eth_proto;
1136 struct ether_hdr *eth_hdr;
1137 struct michel_mic_t michel_mic;
1138 unsigned short keyinfo = 0;
1139 struct ieee802_1x_hdr *aa1x_hdr;
1140 struct wpa_eapol_key *eap_key;
1143 packet_len = packet->len;
1144 if (packet_len > ETH_FRAME_LEN) {
1145 DPRINTK(1, "bad length packet_len=%d\n", packet_len);
1146 dev_kfree_skb(packet);
1150 if (((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_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);
1157 dev_kfree_skb(packet);
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 DPRINTK(4, "skb_buff length=%d\n", packet_len);
1169 pp = kmalloc(hif_align_size(sizeof(*pp) + 6 + packet_len + 8),
1173 DPRINTK(3, "allocate memory failed..\n");
1174 dev_kfree_skb(packet);
1178 p = (unsigned char *)pp->data;
1180 buffer = packet->data;
1181 length = packet->len;
1184 eth = (struct ethhdr *)packet->data;
1185 if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN)) {
1186 DPRINTK(1, "invalid mac address !!\n");
1187 DPRINTK(1, "ethernet->h_source=%02X:%02X:%02X:%02X:%02X:%02X\n",
1188 eth->h_source[0], eth->h_source[1], eth->h_source[2],
1189 eth->h_source[3], eth->h_source[4], eth->h_source[5]);
1190 dev_kfree_skb(packet);
1195 /* MAC address copy */
1196 memcpy(p, buffer, 12); /* DST/SRC MAC address */
1200 /* EtherType/Length check */
1201 if (*(buffer + 1) + (*buffer << 8) > 1500) {
1202 /* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
1203 /* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */
1204 /* SAP/CTL/OUI(6 byte) add */
1205 *p++ = 0xAA; /* DSAP */
1206 *p++ = 0xAA; /* SSAP */
1207 *p++ = 0x03; /* CTL */
1208 *p++ = 0x00; /* OUI ("000000") */
1209 *p++ = 0x00; /* OUI ("000000") */
1210 *p++ = 0x00; /* OUI ("000000") */
1213 DPRINTK(4, "DIX\n");
1214 /* Length(2 byte) delete */
1221 memcpy(p, buffer, length);
1226 eth_hdr = (struct ether_hdr *)&pp->data[0];
1227 eth_proto = ntohs(eth_hdr->h_proto);
1229 /* for MIC FAILURE REPORT check */
1230 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP
1231 && priv->wpa.mic_failure.failure > 0) {
1232 aa1x_hdr = (struct ieee802_1x_hdr *)(eth_hdr + 1);
1233 if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY) {
1234 eap_key = (struct wpa_eapol_key *)(aa1x_hdr + 1);
1235 keyinfo = ntohs(eap_key->key_info);
1239 if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len) {
1240 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP
1241 && !(priv->wpa.key[1].key_len)
1242 && !(priv->wpa.key[2].key_len)
1243 && !(priv->wpa.key[3].key_len)) {
1244 pp->auth_type = cpu_to_le16((uint16_t) TYPE_AUTH); /* no encryption */
1246 if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) {
1247 MichaelMICFunction(&michel_mic, (uint8_t *) priv->wpa.key[0].tx_mic_key, (uint8_t *) & pp->data[0], (int)packet_len, (uint8_t) 0, /* priority */
1248 (uint8_t *) michel_mic.
1250 memcpy(p, michel_mic.Result, 8);
1255 cpu_to_le16((uint16_t) TYPE_DATA);
1257 } else if (priv->wpa.pairwise_suite ==
1258 IW_AUTH_CIPHER_CCMP) {
1260 cpu_to_le16((uint16_t) TYPE_DATA);
1264 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP)
1265 pp->auth_type = cpu_to_le16((uint16_t) TYPE_AUTH);
1267 pp->auth_type = cpu_to_le16((uint16_t) TYPE_DATA);
1270 /* header value set */
1272 cpu_to_le16((uint16_t)
1273 (sizeof(*pp) - sizeof(pp->header.size) + packet_len));
1274 pp->header.event = cpu_to_le16((uint16_t) HIF_DATA_REQ);
1278 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + packet_len),
1279 (void *)send_packet_complete, (void *)priv,
1282 /* MIC FAILURE REPORT check */
1283 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP
1284 && priv->wpa.mic_failure.failure > 0) {
1285 if (keyinfo & WPA_KEY_INFO_ERROR
1286 && keyinfo & WPA_KEY_INFO_REQUEST) {
1287 DPRINTK(3, " MIC ERROR Report SET : %04X\n", keyinfo);
1288 hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST);
1290 if (priv->wpa.mic_failure.failure == 2)
1291 priv->wpa.mic_failure.stop = 1;
1297 #define ps_confirm_wait_inc(priv) do{if(atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET){ \
1298 atomic_inc(&priv->psstatus.confirm_wait); \
1299 /* atomic_set(&priv->psstatus.status, PS_CONF_WAIT);*/ \
1303 void hostif_mib_get_request(struct ks_wlan_private *priv,
1304 unsigned long mib_attribute)
1306 struct hostif_mib_get_request_t *pp;
1310 /* make primitive */
1311 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1313 DPRINTK(3, "allocate memory failed..\n");
1317 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1318 pp->header.event = cpu_to_le16((uint16_t) 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, 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 /* make primitive */
1341 pp = kmalloc(hif_align_size(sizeof(*pp) + size), KS_WLAN_MEM_FLAG);
1343 DPRINTK(3, "allocate memory failed..\n");
1348 cpu_to_le16((uint16_t)
1349 (sizeof(*pp) - sizeof(pp->header.size) + size));
1350 pp->header.event = cpu_to_le16((uint16_t) HIF_MIB_SET_REQ);
1351 pp->mib_attribute = cpu_to_le32((uint32_t) mib_attribute);
1352 pp->mib_value.size = cpu_to_le16((uint16_t) size);
1353 pp->mib_value.type = cpu_to_le16((uint16_t) type);
1354 memcpy(&pp->mib_value.body, vp, size);
1356 /* send to device request */
1357 ps_confirm_wait_inc(priv);
1358 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL,
1363 void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
1365 struct hostif_start_request_t *pp;
1369 /* make primitive */
1370 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1372 DPRINTK(3, "allocate memory failed..\n");
1376 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1377 pp->header.event = cpu_to_le16((uint16_t) HIF_START_REQ);
1378 pp->mode = cpu_to_le16((uint16_t) mode);
1380 /* send to device request */
1381 ps_confirm_wait_inc(priv);
1382 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1384 priv->aplist.size = 0;
1385 priv->scan_ind_count = 0;
1389 void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv)
1391 struct hostif_ps_adhoc_set_request_t *pp;
1392 uint16_t capability;
1396 /* make primitive */
1397 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1399 DPRINTK(3, "allocate memory failed..\n");
1402 memset(pp, 0, sizeof(*pp));
1404 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1405 pp->header.event = cpu_to_le16((uint16_t) HIF_PS_ADH_SET_REQ);
1406 pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type));
1407 pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode));
1408 pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type));
1409 pp->channel = cpu_to_le16((uint16_t) (priv->reg.channel));
1410 pp->rate_set.size = priv->reg.rate_set.size;
1411 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1412 priv->reg.rate_set.size);
1414 capability = 0x0000;
1415 if (priv->reg.preamble == SHORT_PREAMBLE) {
1416 /* short preamble */
1417 capability |= BSS_CAP_SHORT_PREAMBLE;
1419 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1420 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1421 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1422 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM */
1424 pp->capability = cpu_to_le16((uint16_t) capability);
1426 /* send to device request */
1427 ps_confirm_wait_inc(priv);
1428 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1432 void hostif_infrastructure_set_request(struct ks_wlan_private *priv)
1434 struct hostif_infrastructure_set_request_t *pp;
1435 uint16_t capability;
1437 DPRINTK(3, "ssid.size=%d\n", priv->reg.ssid.size);
1439 /* make primitive */
1440 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1442 DPRINTK(3, "allocate memory failed..\n");
1446 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1447 pp->header.event = cpu_to_le16((uint16_t) HIF_INFRA_SET_REQ);
1448 pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type));
1449 pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode));
1450 pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type));
1452 pp->rate_set.size = priv->reg.rate_set.size;
1453 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1454 priv->reg.rate_set.size);
1455 pp->ssid.size = priv->reg.ssid.size;
1456 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1458 capability = 0x0000;
1459 if (priv->reg.preamble == SHORT_PREAMBLE) {
1460 /* short preamble */
1461 capability |= BSS_CAP_SHORT_PREAMBLE;
1463 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1464 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1465 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1466 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1468 pp->capability = cpu_to_le16((uint16_t) capability);
1469 pp->beacon_lost_count =
1470 cpu_to_le16((uint16_t) (priv->reg.beacon_lost_count));
1471 pp->auth_type = cpu_to_le16((uint16_t) (priv->reg.authenticate_type));
1473 pp->channel_list.body[0] = 1;
1474 pp->channel_list.body[1] = 8;
1475 pp->channel_list.body[2] = 2;
1476 pp->channel_list.body[3] = 9;
1477 pp->channel_list.body[4] = 3;
1478 pp->channel_list.body[5] = 10;
1479 pp->channel_list.body[6] = 4;
1480 pp->channel_list.body[7] = 11;
1481 pp->channel_list.body[8] = 5;
1482 pp->channel_list.body[9] = 12;
1483 pp->channel_list.body[10] = 6;
1484 pp->channel_list.body[11] = 13;
1485 pp->channel_list.body[12] = 7;
1486 if (priv->reg.phy_type == D_11G_ONLY_MODE) {
1487 pp->channel_list.size = 13;
1489 pp->channel_list.body[13] = 14;
1490 pp->channel_list.size = 14;
1493 /* send to device request */
1494 ps_confirm_wait_inc(priv);
1495 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1498 static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv)
1500 struct hostif_infrastructure_set2_request_t *pp;
1501 uint16_t capability;
1503 DPRINTK(2, "ssid.size=%d\n", priv->reg.ssid.size);
1505 /* make primitive */
1506 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1508 DPRINTK(3, "allocate memory failed..\n");
1512 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1513 pp->header.event = cpu_to_le16((uint16_t) HIF_INFRA_SET2_REQ);
1514 pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type));
1515 pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode));
1516 pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type));
1518 pp->rate_set.size = priv->reg.rate_set.size;
1519 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1520 priv->reg.rate_set.size);
1521 pp->ssid.size = priv->reg.ssid.size;
1522 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1524 capability = 0x0000;
1525 if (priv->reg.preamble == SHORT_PREAMBLE) {
1526 /* short preamble */
1527 capability |= BSS_CAP_SHORT_PREAMBLE;
1529 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1530 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1531 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1532 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1534 pp->capability = cpu_to_le16((uint16_t) capability);
1535 pp->beacon_lost_count =
1536 cpu_to_le16((uint16_t) (priv->reg.beacon_lost_count));
1537 pp->auth_type = cpu_to_le16((uint16_t) (priv->reg.authenticate_type));
1539 pp->channel_list.body[0] = 1;
1540 pp->channel_list.body[1] = 8;
1541 pp->channel_list.body[2] = 2;
1542 pp->channel_list.body[3] = 9;
1543 pp->channel_list.body[4] = 3;
1544 pp->channel_list.body[5] = 10;
1545 pp->channel_list.body[6] = 4;
1546 pp->channel_list.body[7] = 11;
1547 pp->channel_list.body[8] = 5;
1548 pp->channel_list.body[9] = 12;
1549 pp->channel_list.body[10] = 6;
1550 pp->channel_list.body[11] = 13;
1551 pp->channel_list.body[12] = 7;
1552 if (priv->reg.phy_type == D_11G_ONLY_MODE) {
1553 pp->channel_list.size = 13;
1555 pp->channel_list.body[13] = 14;
1556 pp->channel_list.size = 14;
1559 memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
1561 /* send to device request */
1562 ps_confirm_wait_inc(priv);
1563 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1567 void hostif_adhoc_set_request(struct ks_wlan_private *priv)
1569 struct hostif_adhoc_set_request_t *pp;
1570 uint16_t capability;
1574 /* make primitive */
1575 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1577 DPRINTK(3, "allocate memory failed..\n");
1580 memset(pp, 0, sizeof(*pp));
1582 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1583 pp->header.event = cpu_to_le16((uint16_t) HIF_ADH_SET_REQ);
1584 pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type));
1585 pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode));
1586 pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type));
1587 pp->channel = cpu_to_le16((uint16_t) (priv->reg.channel));
1588 pp->rate_set.size = priv->reg.rate_set.size;
1589 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1590 priv->reg.rate_set.size);
1591 pp->ssid.size = priv->reg.ssid.size;
1592 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1594 capability = 0x0000;
1595 if (priv->reg.preamble == SHORT_PREAMBLE) {
1596 /* short preamble */
1597 capability |= BSS_CAP_SHORT_PREAMBLE;
1599 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1600 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1601 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1602 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1604 pp->capability = cpu_to_le16((uint16_t) capability);
1606 /* send to device request */
1607 ps_confirm_wait_inc(priv);
1608 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1612 void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
1614 struct hostif_adhoc_set2_request_t *pp;
1615 uint16_t capability;
1619 /* make primitive */
1620 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1622 DPRINTK(3, "allocate memory failed..\n");
1625 memset(pp, 0, sizeof(*pp));
1627 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1628 pp->header.event = cpu_to_le16((uint16_t) HIF_ADH_SET_REQ);
1629 pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type));
1630 pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode));
1631 pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type));
1632 pp->rate_set.size = priv->reg.rate_set.size;
1633 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1634 priv->reg.rate_set.size);
1635 pp->ssid.size = priv->reg.ssid.size;
1636 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1638 capability = 0x0000;
1639 if (priv->reg.preamble == SHORT_PREAMBLE) {
1640 /* short preamble */
1641 capability |= BSS_CAP_SHORT_PREAMBLE;
1643 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1644 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1645 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1646 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1648 pp->capability = cpu_to_le16((uint16_t) capability);
1650 pp->channel_list.body[0] = priv->reg.channel;
1651 pp->channel_list.size = 1;
1652 memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
1654 /* send to device request */
1655 ps_confirm_wait_inc(priv);
1656 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1660 void hostif_stop_request(struct ks_wlan_private *priv)
1662 struct hostif_stop_request_t *pp;
1666 /* make primitive */
1667 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1669 DPRINTK(3, "allocate memory failed..\n");
1673 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1674 pp->header.event = cpu_to_le16((uint16_t) HIF_STOP_REQ);
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, NULL);
1682 void hostif_phy_information_request(struct ks_wlan_private *priv)
1684 struct hostif_phy_information_request_t *pp;
1688 /* make primitive */
1689 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1691 DPRINTK(3, "allocate memory failed..\n");
1695 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1696 pp->header.event = cpu_to_le16((uint16_t) HIF_PHY_INFO_REQ);
1697 if (priv->reg.phy_info_timer) {
1698 pp->type = cpu_to_le16((uint16_t) TIME_TYPE);
1699 pp->time = cpu_to_le16((uint16_t) (priv->reg.phy_info_timer));
1701 pp->type = cpu_to_le16((uint16_t) NORMAL_TYPE);
1702 pp->time = cpu_to_le16((uint16_t) 0);
1705 /* send to device request */
1706 ps_confirm_wait_inc(priv);
1707 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1711 void hostif_power_mngmt_request(struct ks_wlan_private *priv,
1712 unsigned long mode, unsigned long wake_up,
1713 unsigned long receiveDTIMs)
1715 struct hostif_power_mngmt_request_t *pp;
1717 DPRINTK(3, "mode=%lu wake_up=%lu receiveDTIMs=%lu\n", mode, wake_up,
1719 /* make primitive */
1720 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1722 DPRINTK(3, "allocate memory failed..\n");
1726 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1727 pp->header.event = cpu_to_le16((uint16_t) HIF_POWERMGT_REQ);
1728 pp->mode = cpu_to_le32((uint32_t) mode);
1729 pp->wake_up = cpu_to_le32((uint32_t) wake_up);
1730 pp->receiveDTIMs = cpu_to_le32((uint32_t) receiveDTIMs);
1732 /* send to device request */
1733 ps_confirm_wait_inc(priv);
1734 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1738 void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode)
1740 struct hostif_sleep_request_t *pp;
1742 DPRINTK(3, "mode=%lu\n", mode);
1744 if (mode == SLP_SLEEP) {
1745 /* make primitive */
1746 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1748 DPRINTK(3, "allocate memory failed..\n");
1752 cpu_to_le16((uint16_t)
1753 (sizeof(*pp) - sizeof(pp->header.size)));
1754 pp->header.event = cpu_to_le16((uint16_t) HIF_SLEEP_REQ);
1756 /* send to device request */
1757 ps_confirm_wait_inc(priv);
1758 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL,
1760 } else if (mode == SLP_ACTIVE) {
1761 atomic_set(&priv->sleepstatus.wakeup_request, 1);
1762 queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
1763 &priv->ks_wlan_hw.rw_wq, 1);
1765 DPRINTK(3, "invalid mode %ld\n", mode);
1771 void hostif_bss_scan_request(struct ks_wlan_private *priv,
1772 unsigned long scan_type, uint8_t *scan_ssid,
1773 uint8_t scan_ssid_len)
1775 struct hostif_bss_scan_request_t *pp;
1778 /* make primitive */
1779 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1781 DPRINTK(3, "allocate memory failed..\n");
1785 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1786 pp->header.event = cpu_to_le16((uint16_t) HIF_SCAN_REQ);
1787 pp->scan_type = scan_type;
1789 pp->ch_time_min = cpu_to_le32((uint32_t) 110); /* default value */
1790 pp->ch_time_max = cpu_to_le32((uint32_t) 130); /* default value */
1791 pp->channel_list.body[0] = 1;
1792 pp->channel_list.body[1] = 8;
1793 pp->channel_list.body[2] = 2;
1794 pp->channel_list.body[3] = 9;
1795 pp->channel_list.body[4] = 3;
1796 pp->channel_list.body[5] = 10;
1797 pp->channel_list.body[6] = 4;
1798 pp->channel_list.body[7] = 11;
1799 pp->channel_list.body[8] = 5;
1800 pp->channel_list.body[9] = 12;
1801 pp->channel_list.body[10] = 6;
1802 pp->channel_list.body[11] = 13;
1803 pp->channel_list.body[12] = 7;
1804 if (priv->reg.phy_type == D_11G_ONLY_MODE) {
1805 pp->channel_list.size = 13;
1807 pp->channel_list.body[13] = 14;
1808 pp->channel_list.size = 14;
1812 /* specified SSID SCAN */
1813 if (scan_ssid_len > 0 && scan_ssid_len <= 32) {
1814 pp->ssid.size = scan_ssid_len;
1815 memcpy(&pp->ssid.body[0], scan_ssid, scan_ssid_len);
1818 /* send to device request */
1819 ps_confirm_wait_inc(priv);
1820 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1822 priv->aplist.size = 0;
1823 priv->scan_ind_count = 0;
1827 void hostif_mic_failure_request(struct ks_wlan_private *priv,
1828 unsigned short failure_count,
1829 unsigned short timer)
1831 struct hostif_mic_failure_request_t *pp;
1833 DPRINTK(3, "count=%d :: timer=%d\n", failure_count, timer);
1834 /* make primitive */
1835 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1837 DPRINTK(3, "allocate memory failed..\n");
1841 cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size)));
1842 pp->header.event = cpu_to_le16((uint16_t) HIF_MIC_FAILURE_REQ);
1843 pp->failure_count = cpu_to_le16((uint16_t) failure_count);
1844 pp->timer = cpu_to_le16((uint16_t) timer);
1846 /* send to device request */
1847 ps_confirm_wait_inc(priv);
1848 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1851 /* Device I/O Receive indicate */
1852 static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p,
1855 if (priv->device_open_status) {
1856 spin_lock(&priv->dev_read_lock); /* request spin lock */
1857 priv->dev_data[atomic_read(&priv->rec_count)] = p;
1858 priv->dev_size[atomic_read(&priv->rec_count)] = size;
1860 if (atomic_read(&priv->event_count) != DEVICE_STOCK_COUNT) {
1861 /* rx event count inc */
1862 atomic_inc(&priv->event_count);
1864 atomic_inc(&priv->rec_count);
1865 if (atomic_read(&priv->rec_count) == DEVICE_STOCK_COUNT)
1866 atomic_set(&priv->rec_count, 0);
1868 wake_up_interruptible_all(&priv->devread_wait);
1870 /* release spin lock */
1871 spin_unlock(&priv->dev_read_lock);
1875 void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
1880 devio_rec_ind(priv, p, size);
1883 priv->rx_size = size;
1885 if (get_WORD(priv) == priv->rx_size) { /* length check !! */
1886 hostif_event_check(priv); /* event check */
1891 void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
1895 case SME_WEP_INDEX_REQUEST:
1896 val = cpu_to_le32((uint32_t) (priv->reg.wep_index));
1897 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
1898 sizeof(val), MIB_VALUE_TYPE_INT, &val);
1900 case SME_WEP_KEY1_REQUEST:
1901 if (!priv->wpa.wpa_enabled)
1902 hostif_mib_set_request(priv,
1903 DOT11_WEP_DEFAULT_KEY_VALUE1,
1904 priv->reg.wep_key[0].size,
1905 MIB_VALUE_TYPE_OSTRING,
1906 &priv->reg.wep_key[0].val[0]);
1908 case SME_WEP_KEY2_REQUEST:
1909 if (!priv->wpa.wpa_enabled)
1910 hostif_mib_set_request(priv,
1911 DOT11_WEP_DEFAULT_KEY_VALUE2,
1912 priv->reg.wep_key[1].size,
1913 MIB_VALUE_TYPE_OSTRING,
1914 &priv->reg.wep_key[1].val[0]);
1916 case SME_WEP_KEY3_REQUEST:
1917 if (!priv->wpa.wpa_enabled)
1918 hostif_mib_set_request(priv,
1919 DOT11_WEP_DEFAULT_KEY_VALUE3,
1920 priv->reg.wep_key[2].size,
1921 MIB_VALUE_TYPE_OSTRING,
1922 &priv->reg.wep_key[2].val[0]);
1924 case SME_WEP_KEY4_REQUEST:
1925 if (!priv->wpa.wpa_enabled)
1926 hostif_mib_set_request(priv,
1927 DOT11_WEP_DEFAULT_KEY_VALUE4,
1928 priv->reg.wep_key[3].size,
1929 MIB_VALUE_TYPE_OSTRING,
1930 &priv->reg.wep_key[3].val[0]);
1932 case SME_WEP_FLAG_REQUEST:
1933 val = cpu_to_le32((uint32_t) (priv->reg.privacy_invoked));
1934 hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
1935 sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
1942 struct wpa_suite_t {
1943 unsigned short size;
1944 unsigned char suite[4][CIPHER_ID_LEN];
1945 } __attribute__ ((packed));
1949 uint16_t rsn_capability;
1950 } __attribute__ ((packed));
1953 void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
1955 struct wpa_suite_t wpa_suite;
1956 struct rsn_mode_t rsn_mode;
1959 memset(&wpa_suite, 0, sizeof(wpa_suite));
1962 case SME_RSN_UCAST_REQUEST:
1963 wpa_suite.size = cpu_to_le16((uint16_t) 1);
1964 switch (priv->wpa.pairwise_suite) {
1965 case IW_AUTH_CIPHER_NONE:
1966 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1967 memcpy(&wpa_suite.suite[0][0],
1968 CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
1970 memcpy(&wpa_suite.suite[0][0],
1971 CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
1973 case IW_AUTH_CIPHER_WEP40:
1974 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1975 memcpy(&wpa_suite.suite[0][0],
1976 CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
1978 memcpy(&wpa_suite.suite[0][0],
1979 CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
1981 case IW_AUTH_CIPHER_TKIP:
1982 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1983 memcpy(&wpa_suite.suite[0][0],
1984 CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
1986 memcpy(&wpa_suite.suite[0][0],
1987 CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
1989 case IW_AUTH_CIPHER_CCMP:
1990 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1991 memcpy(&wpa_suite.suite[0][0],
1992 CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
1994 memcpy(&wpa_suite.suite[0][0],
1995 CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
1997 case IW_AUTH_CIPHER_WEP104:
1998 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1999 memcpy(&wpa_suite.suite[0][0],
2000 CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
2002 memcpy(&wpa_suite.suite[0][0],
2003 CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
2007 hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER,
2008 sizeof(wpa_suite.size) +
2009 CIPHER_ID_LEN * wpa_suite.size,
2010 MIB_VALUE_TYPE_OSTRING, &wpa_suite);
2012 case SME_RSN_MCAST_REQUEST:
2013 switch (priv->wpa.group_suite) {
2014 case IW_AUTH_CIPHER_NONE:
2015 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2016 memcpy(&wpa_suite.suite[0][0],
2017 CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
2019 memcpy(&wpa_suite.suite[0][0],
2020 CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
2022 case IW_AUTH_CIPHER_WEP40:
2023 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2024 memcpy(&wpa_suite.suite[0][0],
2025 CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
2027 memcpy(&wpa_suite.suite[0][0],
2028 CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
2030 case IW_AUTH_CIPHER_TKIP:
2031 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2032 memcpy(&wpa_suite.suite[0][0],
2033 CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
2035 memcpy(&wpa_suite.suite[0][0],
2036 CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
2038 case IW_AUTH_CIPHER_CCMP:
2039 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2040 memcpy(&wpa_suite.suite[0][0],
2041 CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
2043 memcpy(&wpa_suite.suite[0][0],
2044 CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
2046 case IW_AUTH_CIPHER_WEP104:
2047 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2048 memcpy(&wpa_suite.suite[0][0],
2049 CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
2051 memcpy(&wpa_suite.suite[0][0],
2052 CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
2056 hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER,
2057 CIPHER_ID_LEN, MIB_VALUE_TYPE_OSTRING,
2058 &wpa_suite.suite[0][0]);
2060 case SME_RSN_AUTH_REQUEST:
2061 wpa_suite.size = cpu_to_le16((uint16_t) 1);
2062 switch (priv->wpa.key_mgmt_suite) {
2063 case IW_AUTH_KEY_MGMT_802_1X:
2064 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2065 memcpy(&wpa_suite.suite[0][0],
2066 KEY_MGMT_ID_WPA2_1X, KEY_MGMT_ID_LEN);
2068 memcpy(&wpa_suite.suite[0][0],
2069 KEY_MGMT_ID_WPA_1X, KEY_MGMT_ID_LEN);
2071 case IW_AUTH_KEY_MGMT_PSK:
2072 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2073 memcpy(&wpa_suite.suite[0][0],
2074 KEY_MGMT_ID_WPA2_PSK, KEY_MGMT_ID_LEN);
2076 memcpy(&wpa_suite.suite[0][0],
2077 KEY_MGMT_ID_WPA_PSK, KEY_MGMT_ID_LEN);
2080 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2081 memcpy(&wpa_suite.suite[0][0],
2082 KEY_MGMT_ID_WPA2_NONE, KEY_MGMT_ID_LEN);
2084 memcpy(&wpa_suite.suite[0][0],
2085 KEY_MGMT_ID_WPA_NONE, KEY_MGMT_ID_LEN);
2088 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2089 memcpy(&wpa_suite.suite[0][0],
2090 KEY_MGMT_ID_WPA2_WPANONE,
2093 memcpy(&wpa_suite.suite[0][0],
2094 KEY_MGMT_ID_WPA_WPANONE,
2099 hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE,
2100 sizeof(wpa_suite.size) +
2101 KEY_MGMT_ID_LEN * wpa_suite.size,
2102 MIB_VALUE_TYPE_OSTRING, &wpa_suite);
2104 case SME_RSN_ENABLED_REQUEST:
2105 val = cpu_to_le32((uint32_t) (priv->wpa.rsn_enabled));
2106 hostif_mib_set_request(priv, DOT11_RSN_ENABLED,
2107 sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
2109 case SME_RSN_MODE_REQUEST:
2110 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
2112 cpu_to_le32((uint32_t) RSN_MODE_WPA2);
2113 rsn_mode.rsn_capability = cpu_to_le16((uint16_t) 0);
2114 } else if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) {
2116 cpu_to_le32((uint32_t) RSN_MODE_WPA);
2117 rsn_mode.rsn_capability = cpu_to_le16((uint16_t) 0);
2120 cpu_to_le32((uint32_t) RSN_MODE_NONE);
2121 rsn_mode.rsn_capability = cpu_to_le16((uint16_t) 0);
2123 hostif_mib_set_request(priv, LOCAL_RSN_MODE, sizeof(rsn_mode),
2124 MIB_VALUE_TYPE_OSTRING, &rsn_mode);
2132 void hostif_sme_mode_setup(struct ks_wlan_private *priv)
2134 unsigned char rate_size;
2135 unsigned char rate_octet[RATE_SET_MAX_SIZE];
2138 /* rate setting if rate segging is auto for changing phy_type (#94) */
2139 if (priv->reg.tx_rate == TX_RATE_FULL_AUTO) {
2140 if (priv->reg.phy_type == D_11B_ONLY_MODE) {
2141 priv->reg.rate_set.body[3] = TX_RATE_11M;
2142 priv->reg.rate_set.body[2] = TX_RATE_5M;
2143 priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE;
2144 priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE;
2145 priv->reg.rate_set.size = 4;
2146 } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
2147 priv->reg.rate_set.body[11] = TX_RATE_54M;
2148 priv->reg.rate_set.body[10] = TX_RATE_48M;
2149 priv->reg.rate_set.body[9] = TX_RATE_36M;
2150 priv->reg.rate_set.body[8] = TX_RATE_18M;
2151 priv->reg.rate_set.body[7] = TX_RATE_9M;
2152 priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE;
2153 priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE;
2154 priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE;
2155 priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE;
2156 priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE;
2157 priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE;
2158 priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE;
2159 priv->reg.rate_set.size = 12;
2163 /* rate mask by phy setting */
2164 if (priv->reg.phy_type == D_11B_ONLY_MODE) {
2165 for (i = 0; i < priv->reg.rate_set.size; i++) {
2166 if (IS_11B_RATE(priv->reg.rate_set.body[i])) {
2167 if ((priv->reg.rate_set.body[i] & RATE_MASK) >=
2171 body[i] & RATE_MASK;
2174 priv->reg.rate_set.body[i];
2179 } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
2180 for (i = 0; i < priv->reg.rate_set.size; i++) {
2181 if (IS_11BG_RATE(priv->reg.rate_set.body[i])) {
2182 if (IS_OFDM_EXT_RATE
2183 (priv->reg.rate_set.body[i]))
2186 body[i] & RATE_MASK;
2189 priv->reg.rate_set.body[i];
2195 if (rate_size == 0) {
2196 if (priv->reg.phy_type == D_11G_ONLY_MODE)
2197 rate_octet[0] = TX_RATE_6M | BASIC_RATE;
2199 rate_octet[0] = TX_RATE_2M | BASIC_RATE;
2203 /* rate set update */
2204 priv->reg.rate_set.size = rate_size;
2205 memcpy(&priv->reg.rate_set.body[0], &rate_octet[0], rate_size);
2207 switch (priv->reg.operation_mode) {
2208 case MODE_PSEUDO_ADHOC:
2209 /* Pseudo Ad-Hoc mode */
2210 hostif_ps_adhoc_set_request(priv);
2212 case MODE_INFRASTRUCTURE:
2213 /* Infrastructure mode */
2214 if (!is_valid_ether_addr((u8 *) priv->reg.bssid)) {
2215 hostif_infrastructure_set_request(priv);
2217 hostif_infrastructure_set2_request(priv);
2219 "Infra bssid = %02x:%02x:%02x:%02x:%02x:%02x\n",
2220 priv->reg.bssid[0], priv->reg.bssid[1],
2221 priv->reg.bssid[2], priv->reg.bssid[3],
2222 priv->reg.bssid[4], priv->reg.bssid[5]);
2226 /* IEEE802.11 Ad-Hoc mode */
2227 if (!is_valid_ether_addr((u8 *) priv->reg.bssid)) {
2228 hostif_adhoc_set_request(priv);
2230 hostif_adhoc_set2_request(priv);
2232 "Adhoc bssid = %02x:%02x:%02x:%02x:%02x:%02x\n",
2233 priv->reg.bssid[0], priv->reg.bssid[1],
2234 priv->reg.bssid[2], priv->reg.bssid[3],
2235 priv->reg.bssid[4], priv->reg.bssid[5]);
2246 void hostif_sme_multicast_set(struct ks_wlan_private *priv)
2249 struct net_device *dev = priv->net_dev;
2251 struct netdev_hw_addr *ha;
2252 char set_address[NIC_MAX_MCAST_LIST * ETH_ALEN];
2253 unsigned long filter_type;
2258 spin_lock(&priv->multicast_spin);
2260 memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN);
2262 if (dev->flags & IFF_PROMISC) {
2263 filter_type = cpu_to_le32((uint32_t) MCAST_FILTER_PROMISC);
2264 hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
2265 sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
2267 } else if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST)
2268 || (dev->flags & IFF_ALLMULTI)) {
2269 filter_type = cpu_to_le32((uint32_t) MCAST_FILTER_MCASTALL);
2270 hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
2271 sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
2274 if (priv->sme_i.sme_flag & SME_MULTICAST) {
2275 mc_count = netdev_mc_count(dev);
2276 netdev_for_each_mc_addr(ha, dev) {
2277 memcpy(&set_address[i * ETH_ALEN], ha->addr,
2281 priv->sme_i.sme_flag &= ~SME_MULTICAST;
2282 hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS,
2283 (ETH_ALEN * mc_count),
2284 MIB_VALUE_TYPE_OSTRING,
2288 cpu_to_le32((uint32_t) MCAST_FILTER_MCAST);
2289 priv->sme_i.sme_flag |= SME_MULTICAST;
2290 hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
2291 sizeof(filter_type),
2292 MIB_VALUE_TYPE_BOOL,
2297 spin_unlock(&priv->multicast_spin);
2302 void hostif_sme_powermgt_set(struct ks_wlan_private *priv)
2304 unsigned long mode, wake_up, receiveDTIMs;
2307 switch (priv->reg.powermgt) {
2308 case POWMGT_ACTIVE_MODE:
2309 mode = POWER_ACTIVE;
2313 case POWMGT_SAVE1_MODE:
2314 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
2319 mode = POWER_ACTIVE;
2324 case POWMGT_SAVE2_MODE:
2325 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
2330 mode = POWER_ACTIVE;
2336 mode = POWER_ACTIVE;
2341 hostif_power_mngmt_request(priv, mode, wake_up, receiveDTIMs);
2347 void hostif_sme_sleep_set(struct ks_wlan_private *priv)
2350 switch (priv->sleep_mode) {
2352 hostif_sleep_request(priv, priv->sleep_mode);
2355 hostif_sleep_request(priv, priv->sleep_mode);
2365 void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
2370 val = cpu_to_le32((uint32_t) (priv->reg.privacy_invoked));
2371 hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
2372 sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
2375 val = cpu_to_le32((uint32_t) (priv->wpa.txkey));
2376 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
2377 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2380 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1,
2381 priv->wpa.key[0].key_len,
2382 MIB_VALUE_TYPE_OSTRING,
2383 &priv->wpa.key[0].key_val[0]);
2386 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2,
2387 priv->wpa.key[1].key_len,
2388 MIB_VALUE_TYPE_OSTRING,
2389 &priv->wpa.key[1].key_val[0]);
2392 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3,
2393 priv->wpa.key[2].key_len,
2394 MIB_VALUE_TYPE_OSTRING,
2395 &priv->wpa.key[2].key_val[0]);
2398 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4,
2399 priv->wpa.key[3].key_len,
2400 MIB_VALUE_TYPE_OSTRING,
2401 &priv->wpa.key[3].key_val[0]);
2403 case SME_SET_PMK_TSC:
2404 hostif_mib_set_request(priv, DOT11_PMK_TSC,
2405 WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
2406 &priv->wpa.key[0].rx_seq[0]);
2408 case SME_SET_GMK1_TSC:
2409 hostif_mib_set_request(priv, DOT11_GMK1_TSC,
2410 WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
2411 &priv->wpa.key[1].rx_seq[0]);
2413 case SME_SET_GMK2_TSC:
2414 hostif_mib_set_request(priv, DOT11_GMK2_TSC,
2415 WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
2416 &priv->wpa.key[2].rx_seq[0]);
2423 void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
2425 struct pmk_cache_t {
2428 uint8_t bssid[ETH_ALEN];
2429 uint8_t pmkid[IW_PMKID_LEN];
2430 } __attribute__ ((packed)) list[PMK_LIST_MAX];
2431 } __attribute__ ((packed)) pmkcache;
2433 struct list_head *ptr;
2436 DPRINTK(4, "pmklist.size=%d\n", priv->pmklist.size);
2438 list_for_each(ptr, &priv->pmklist.head) {
2439 pmk = list_entry(ptr, struct pmk_t, list);
2440 if (i < PMK_LIST_MAX) {
2441 memcpy(pmkcache.list[i].bssid, pmk->bssid, ETH_ALEN);
2442 memcpy(pmkcache.list[i].pmkid, pmk->pmkid,
2447 pmkcache.size = cpu_to_le16((uint16_t) (priv->pmklist.size));
2448 hostif_mib_set_request(priv, LOCAL_PMK,
2449 sizeof(priv->pmklist.size) + (ETH_ALEN +
2451 (priv->pmklist.size), MIB_VALUE_TYPE_OSTRING,
2457 void hostif_sme_execute(struct ks_wlan_private *priv, int event)
2461 DPRINTK(3, "event=%d\n", event);
2464 if (priv->dev_state == DEVICE_STATE_BOOT) {
2465 hostif_mib_get_request(priv, DOT11_MAC_ADDRESS);
2468 case SME_MULTICAST_REQUEST:
2469 hostif_sme_multicast_set(priv);
2471 case SME_MACADDRESS_SET_REQUEST:
2472 hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN,
2473 MIB_VALUE_TYPE_OSTRING,
2474 &priv->eth_addr[0]);
2476 case SME_BSS_SCAN_REQUEST:
2477 hostif_bss_scan_request(priv, priv->reg.scan_type,
2478 priv->scan_ssid, priv->scan_ssid_len);
2480 case SME_POW_MNGMT_REQUEST:
2481 hostif_sme_powermgt_set(priv);
2483 case SME_PHY_INFO_REQUEST:
2484 hostif_phy_information_request(priv);
2486 case SME_MIC_FAILURE_REQUEST:
2487 if (priv->wpa.mic_failure.failure == 1) {
2488 hostif_mic_failure_request(priv,
2489 priv->wpa.mic_failure.
2491 } else if (priv->wpa.mic_failure.failure == 2) {
2492 hostif_mic_failure_request(priv,
2493 priv->wpa.mic_failure.
2495 priv->wpa.mic_failure.
2499 "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n",
2500 priv->wpa.mic_failure.failure);
2502 case SME_MIC_FAILURE_CONFIRM:
2503 if (priv->wpa.mic_failure.failure == 2) {
2504 if (priv->wpa.mic_failure.stop)
2505 priv->wpa.mic_failure.stop = 0;
2506 priv->wpa.mic_failure.failure = 0;
2507 hostif_start_request(priv, priv->reg.operation_mode);
2510 case SME_GET_MAC_ADDRESS:
2511 if (priv->dev_state == DEVICE_STATE_BOOT) {
2512 hostif_mib_get_request(priv, DOT11_PRODUCT_VERSION);
2515 case SME_GET_PRODUCT_VERSION:
2516 if (priv->dev_state == DEVICE_STATE_BOOT) {
2517 priv->dev_state = DEVICE_STATE_PREINIT;
2520 case SME_STOP_REQUEST:
2521 hostif_stop_request(priv);
2523 case SME_RTS_THRESHOLD_REQUEST:
2524 val = cpu_to_le32((uint32_t) (priv->reg.rts));
2525 hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD,
2526 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2528 case SME_FRAGMENTATION_THRESHOLD_REQUEST:
2529 val = cpu_to_le32((uint32_t) (priv->reg.fragment));
2530 hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD,
2531 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2533 case SME_WEP_INDEX_REQUEST:
2534 case SME_WEP_KEY1_REQUEST:
2535 case SME_WEP_KEY2_REQUEST:
2536 case SME_WEP_KEY3_REQUEST:
2537 case SME_WEP_KEY4_REQUEST:
2538 case SME_WEP_FLAG_REQUEST:
2539 hostif_sme_set_wep(priv, event);
2541 case SME_RSN_UCAST_REQUEST:
2542 case SME_RSN_MCAST_REQUEST:
2543 case SME_RSN_AUTH_REQUEST:
2544 case SME_RSN_ENABLED_REQUEST:
2545 case SME_RSN_MODE_REQUEST:
2546 hostif_sme_set_rsn(priv, event);
2554 case SME_SET_PMK_TSC:
2555 case SME_SET_GMK1_TSC:
2556 case SME_SET_GMK2_TSC:
2557 hostif_sme_set_key(priv, event);
2560 hostif_sme_set_pmksa(priv);
2563 case SME_WPS_ENABLE_REQUEST:
2564 hostif_mib_set_request(priv, LOCAL_WPS_ENABLE,
2565 sizeof(priv->wps.wps_enabled),
2567 &priv->wps.wps_enabled);
2569 case SME_WPS_PROBE_REQUEST:
2570 hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ,
2572 MIB_VALUE_TYPE_OSTRING, priv->wps.ie);
2575 case SME_MODE_SET_REQUEST:
2576 hostif_sme_mode_setup(priv);
2579 hostif_mib_set_request(priv, LOCAL_GAIN,
2581 MIB_VALUE_TYPE_OSTRING, &priv->gain);
2584 hostif_mib_get_request(priv, LOCAL_GAIN);
2586 case SME_GET_EEPROM_CKSUM:
2587 priv->eeprom_checksum = EEPROM_FW_NOT_SUPPORT; /* initialize */
2588 hostif_mib_get_request(priv, LOCAL_EEPROM_SUM);
2590 case SME_START_REQUEST:
2591 hostif_start_request(priv, priv->reg.operation_mode);
2593 case SME_START_CONFIRM:
2594 /* for power save */
2595 atomic_set(&priv->psstatus.snooze_guard, 0);
2596 atomic_set(&priv->psstatus.confirm_wait, 0);
2597 if (priv->dev_state == DEVICE_STATE_PREINIT) {
2598 priv->dev_state = DEVICE_STATE_INIT;
2600 /* wake_up_interruptible_all(&priv->confirm_wait); */
2601 complete(&priv->confirm_wait);
2603 case SME_SLEEP_REQUEST:
2604 hostif_sme_sleep_set(priv);
2606 case SME_SET_REGION:
2607 val = cpu_to_le32((uint32_t) (priv->region));
2608 hostif_mib_set_request(priv, LOCAL_REGION,
2609 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2611 case SME_MULTICAST_CONFIRM:
2612 case SME_BSS_SCAN_CONFIRM:
2613 case SME_POW_MNGMT_CONFIRM:
2614 case SME_PHY_INFO_CONFIRM:
2615 case SME_STOP_CONFIRM:
2616 case SME_RTS_THRESHOLD_CONFIRM:
2617 case SME_FRAGMENTATION_THRESHOLD_CONFIRM:
2618 case SME_WEP_INDEX_CONFIRM:
2619 case SME_WEP_KEY1_CONFIRM:
2620 case SME_WEP_KEY2_CONFIRM:
2621 case SME_WEP_KEY3_CONFIRM:
2622 case SME_WEP_KEY4_CONFIRM:
2623 case SME_WEP_FLAG_CONFIRM:
2624 case SME_RSN_UCAST_CONFIRM:
2625 case SME_RSN_MCAST_CONFIRM:
2626 case SME_RSN_AUTH_CONFIRM:
2627 case SME_RSN_ENABLED_CONFIRM:
2628 case SME_RSN_MODE_CONFIRM:
2629 case SME_MODE_SET_CONFIRM:
2638 void hostif_sme_task(unsigned long dev)
2640 struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;
2644 if (priv->dev_state >= DEVICE_STATE_BOOT) {
2645 if (0 < cnt_smeqbody(priv)
2646 && priv->dev_state >= DEVICE_STATE_BOOT) {
2647 hostif_sme_execute(priv,
2648 priv->sme_i.event_buff[priv->sme_i.
2651 if (0 < cnt_smeqbody(priv))
2652 tasklet_schedule(&priv->sme_task);
2658 /* send to Station Management Entity module */
2659 void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
2663 /* enqueue sme event */
2664 if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) {
2665 priv->sme_i.event_buff[priv->sme_i.qtail] = event;
2667 //DPRINTK(3,"inc_smeqtail \n");
2668 #ifdef KS_WLAN_DEBUG
2669 if (priv->sme_i.max_event_count < cnt_smeqbody(priv))
2670 priv->sme_i.max_event_count = cnt_smeqbody(priv);
2671 #endif /* KS_WLAN_DEBUG */
2673 /* in case of buffer overflow */
2674 //DPRINTK(2,"sme queue buffer overflow\n");
2675 printk("sme queue buffer overflow\n");
2678 tasklet_schedule(&priv->sme_task);
2682 int hostif_init(struct ks_wlan_private *priv)
2688 priv->aplist.size = 0;
2689 for (i = 0; i < LOCAL_APLIST_MAX; i++)
2690 memset(&(priv->aplist.ap[i]), 0, sizeof(struct local_ap_t));
2691 priv->infra_status = 0;
2692 priv->current_rate = 4;
2693 priv->connect_status = DISCONNECT_STATUS;
2695 spin_lock_init(&priv->multicast_spin);
2697 spin_lock_init(&priv->dev_read_lock);
2698 init_waitqueue_head(&priv->devread_wait);
2699 priv->dev_count = 0;
2700 atomic_set(&priv->event_count, 0);
2701 atomic_set(&priv->rec_count, 0);
2703 /* for power save */
2704 atomic_set(&priv->psstatus.status, PS_NONE);
2705 atomic_set(&priv->psstatus.confirm_wait, 0);
2706 atomic_set(&priv->psstatus.snooze_guard, 0);
2707 /* init_waitqueue_head(&priv->psstatus.wakeup_wait); */
2708 init_completion(&priv->psstatus.wakeup_wait);
2709 //INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task, (void *)priv);
2710 INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task);
2713 memset(&(priv->wpa), 0, sizeof(priv->wpa));
2714 priv->wpa.rsn_enabled = 0;
2715 priv->wpa.mic_failure.failure = 0;
2716 priv->wpa.mic_failure.last_failure_time = 0;
2717 priv->wpa.mic_failure.stop = 0;
2718 memset(&(priv->pmklist), 0, sizeof(priv->pmklist));
2719 INIT_LIST_HEAD(&priv->pmklist.head);
2720 for (i = 0; i < PMK_LIST_MAX; i++)
2721 INIT_LIST_HEAD(&priv->pmklist.pmk[i].list);
2723 priv->sme_i.sme_status = SME_IDLE;
2724 priv->sme_i.qhead = priv->sme_i.qtail = 0;
2725 #ifdef KS_WLAN_DEBUG
2726 priv->sme_i.max_event_count = 0;
2728 spin_lock_init(&priv->sme_i.sme_spin);
2729 priv->sme_i.sme_flag = 0;
2731 tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv);
2736 void hostif_exit(struct ks_wlan_private *priv)
2738 tasklet_kill(&priv->sme_task);