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;
108 int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
110 struct local_ap_t *ap;
111 union iwreq_data wrqu;
112 struct net_device *netdev = priv->net_dev;
115 ap = &priv->current_ap;
117 if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) {
118 memset(ap, 0, sizeof(struct local_ap_t));
123 memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
125 memcpy(ap->ssid.body, priv->reg.ssid.body,
126 priv->reg.ssid.size);
127 ap->ssid.size = priv->reg.ssid.size;
129 memcpy(ap->rate_set.body, ap_info->rate_set.body,
130 ap_info->rate_set.size);
131 ap->rate_set.size = ap_info->rate_set.size;
132 if (ap_info->ext_rate_set.size) {
134 memcpy(&ap->rate_set.body[ap->rate_set.size],
135 ap_info->ext_rate_set.body,
136 ap_info->ext_rate_set.size);
137 ap->rate_set.size += ap_info->ext_rate_set.size;
140 ap->channel = ap_info->ds_parameter.channel;
142 ap->rssi = ap_info->rssi;
144 ap->sq = ap_info->sq;
146 ap->noise = ap_info->noise;
148 ap->capability = ap_info->capability;
150 if ((ap_info->rsn_mode & RSN_MODE_WPA2)
151 && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
152 ap->rsn_ie.id = 0x30;
153 if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
154 ap->rsn_ie.size = ap_info->rsn.size;
155 memcpy(ap->rsn_ie.body, ap_info->rsn.body,
158 ap->rsn_ie.size = RSN_IE_BODY_MAX;
159 memcpy(ap->rsn_ie.body, ap_info->rsn.body,
162 } else if ((ap_info->rsn_mode & RSN_MODE_WPA)
163 && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)) {
164 ap->wpa_ie.id = 0xdd;
165 if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
166 ap->wpa_ie.size = ap_info->rsn.size;
167 memcpy(ap->wpa_ie.body, ap_info->rsn.body,
170 ap->wpa_ie.size = RSN_IE_BODY_MAX;
171 memcpy(ap->wpa_ie.body, ap_info->rsn.body,
181 wrqu.data.length = 0;
183 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
184 if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
185 memcpy(wrqu.ap_addr.sa_data,
186 priv->current_ap.bssid, ETH_ALEN);
188 "IWEVENT: connect bssid=%pM\n", wrqu.ap_addr.sa_data);
189 wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
191 DPRINTK(4, "\n Link AP\n");
192 DPRINTK(4, " bssid=%02X:%02X:%02X:%02X:%02X:%02X\n \
193 essid=%s\n rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n channel=%d\n \
194 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);
195 DPRINTK(4, "\n Link AP\n rsn.mode=%d\n rsn.size=%d\n",
196 ap_info->rsn_mode, ap_info->rsn.size);
197 DPRINTK(4, "\n ext_rate_set_size=%d\n rate_set_size=%d\n",
198 ap_info->ext_rate_set.size, ap_info->rate_set.size);
204 int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
205 struct local_ap_t *ap)
211 memset(ap, 0, sizeof(struct local_ap_t));
214 memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
216 ap->rssi = ap_info->rssi;
218 ap->sq = ap_info->sq;
220 ap->noise = ap_info->noise;
222 ap->capability = ap_info->capability;
224 ap->channel = ap_info->ch_info;
227 bsize = ap_info->body_size;
230 while (bsize > offset) {
231 /* DPRINTK(4, "Element ID=%d\n",*bp); */
234 if (*(bp + 1) <= SSID_MAX_SIZE) {
235 ap->ssid.size = *(bp + 1);
237 DPRINTK(1, "size over :: ssid size=%d\n",
239 ap->ssid.size = SSID_MAX_SIZE;
241 memcpy(ap->ssid.body, bp + 2, ap->ssid.size);
244 case 50: /* ext rate */
245 if ((*(bp + 1) + ap->rate_set.size) <=
247 memcpy(&ap->rate_set.body[ap->rate_set.size],
249 ap->rate_set.size += *(bp + 1);
251 DPRINTK(1, "size over :: rate size=%d\n",
252 (*(bp + 1) + ap->rate_set.size));
253 memcpy(&ap->rate_set.body[ap->rate_set.size],
255 RATE_SET_MAX_SIZE - ap->rate_set.size);
257 (RATE_SET_MAX_SIZE - ap->rate_set.size);
260 case 3: /* DS parameter */
262 case 48: /* RSN(WPA2) */
264 if (*(bp + 1) <= RSN_IE_BODY_MAX) {
265 ap->rsn_ie.size = *(bp + 1);
267 DPRINTK(1, "size over :: rsn size=%d\n",
269 ap->rsn_ie.size = RSN_IE_BODY_MAX;
271 memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size);
274 if (!memcmp(bp + 2, "\x00\x50\xf2\x01", 4)) { /* WPA OUI check */
276 if (*(bp + 1) <= RSN_IE_BODY_MAX) {
277 ap->wpa_ie.size = *(bp + 1);
280 "size over :: wpa size=%d\n",
282 ap->wpa_ie.size = RSN_IE_BODY_MAX;
284 memcpy(ap->wpa_ie.body, bp + 2,
289 case 2: /* FH parameter */
290 case 4: /* CF parameter */
292 case 6: /* IBSS parameter */
293 case 7: /* Country */
294 case 42: /* ERP information */
295 case 47: /* Reserve ID 47 Broadcom AP */
298 DPRINTK(4, "unknown Element ID=%d\n", *bp);
301 offset += 2; /* id & size field */
302 offset += *(bp + 1); /* +size offset */
303 bp += (*(bp + 1) + 2); /* pointer update */
310 int hostif_data_indication_wpa(struct ks_wlan_private *priv,
311 unsigned short auth_type)
313 struct ether_hdr *eth_hdr;
314 unsigned short eth_proto;
315 unsigned char RecvMIC[8];
318 struct mic_failure_t *mic_failure;
319 struct michael_mic_t michael_mic;
320 union iwreq_data wrqu;
321 unsigned int key_index = auth_type - 1;
322 struct wpa_key_t *key = &priv->wpa.key[key_index];
324 eth_hdr = (struct ether_hdr *)(priv->rxp);
325 eth_proto = ntohs(eth_hdr->h_proto);
327 /* source address check */
328 if (!memcmp(ð_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN))
331 if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) {
332 DPRINTK(1, "invalid data format\n");
333 priv->nstats.rx_errors++;
336 if (((auth_type == TYPE_PMK1 &&
337 priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) ||
338 (auth_type == TYPE_GMK1 &&
339 priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP) ||
340 (auth_type == TYPE_GMK2 &&
341 priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP)) &&
343 DPRINTK(4, "TKIP: protocol=%04X: size=%u\n",
344 eth_proto, priv->rx_size);
346 memcpy(&RecvMIC[0], (priv->rxp) + ((priv->rx_size) - 8), 8);
347 priv->rx_size = priv->rx_size - 8;
348 if (auth_type > 0 && auth_type < 4) { /* auth_type check */
349 MichaelMICFunction(&michael_mic,
350 (uint8_t *)key->rx_mic_key,
351 (uint8_t *)priv->rxp,
353 (uint8_t)0, /* priority */
354 (uint8_t *)michael_mic.Result);
356 if (memcmp(michael_mic.Result, RecvMIC, 8)) {
358 mic_failure = &priv->wpa.mic_failure;
360 if (mic_failure->last_failure_time &&
361 (now - mic_failure->last_failure_time) / HZ >= 60) {
362 mic_failure->failure = 0;
364 DPRINTK(4, "MIC FAILURE\n");
365 if (mic_failure->failure == 0) {
366 mic_failure->failure = 1;
367 mic_failure->counter = 0;
368 } else if (mic_failure->failure == 1) {
369 mic_failure->failure = 2;
370 mic_failure->counter =
371 (uint16_t)((now - mic_failure->last_failure_time) / HZ);
372 if (!mic_failure->counter) /* range 1-60 */
373 mic_failure->counter = 1;
375 priv->wpa.mic_failure.last_failure_time = now;
377 /* needed parameters: count, keyid, key type, TSC */
379 "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=%pM)",
381 eth_hdr->h_dest[0] & 0x01 ? "broad" : "uni",
383 memset(&wrqu, 0, sizeof(wrqu));
384 wrqu.data.length = strlen(buf);
385 DPRINTK(4, "IWEVENT:MICHAELMICFAILURE\n");
386 wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu,
395 void hostif_data_indication(struct ks_wlan_private *priv)
397 unsigned int rx_ind_size; /* indicate data size */
399 unsigned short auth_type;
400 unsigned char temp[256];
401 struct ether_hdr *eth_hdr;
402 unsigned short eth_proto;
403 struct ieee802_1x_hdr *aa1x_hdr;
404 struct wpa_eapol_key *eap_key;
409 /* min length check */
410 if (priv->rx_size <= ETH_HLEN) {
411 DPRINTK(3, "rx_size = %d\n", priv->rx_size);
412 priv->nstats.rx_errors++;
416 auth_type = get_WORD(priv); /* AuthType */
417 get_WORD(priv); /* Reserve Area */
419 eth_hdr = (struct ether_hdr *)(priv->rxp);
420 eth_proto = ntohs(eth_hdr->h_proto);
421 DPRINTK(3, "ether protocol = %04X\n", eth_proto);
423 /* source address check */
424 if (!memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN)) {
425 DPRINTK(1, "invalid : source is own mac address !!\n");
427 "eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
428 eth_hdr->h_source[0], eth_hdr->h_source[1],
429 eth_hdr->h_source[2], eth_hdr->h_source[3],
430 eth_hdr->h_source[4], eth_hdr->h_source[5]);
431 priv->nstats.rx_errors++;
436 if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled) {
437 rc = hostif_data_indication_wpa(priv, auth_type);
442 if ((priv->connect_status & FORCE_DISCONNECT) ||
443 priv->wpa.mic_failure.failure == 2) {
447 /* check 13th byte at rx data */
448 switch (*(priv->rxp + 12)) {
449 case 0xAA: /* SNAP */
450 rx_ind_size = priv->rx_size - 6;
451 skb = dev_alloc_skb(rx_ind_size);
452 DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size);
455 memcpy(skb_put(skb, 12), priv->rxp, 12); /* 8802/FDDI MAC copy */
456 /* (SNAP+UI..) skip */
457 memcpy(skb_put(skb, rx_ind_size - 12), priv->rxp + 18, rx_ind_size - 12); /* copy after Type */
459 aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 20);
460 if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY
461 && priv->wpa.rsn_enabled) {
463 (struct wpa_eapol_key *)(aa1x_hdr + 1);
464 atomic_set(&priv->psstatus.snooze_guard, 1);
468 skb->dev = priv->net_dev;
469 skb->protocol = eth_type_trans(skb, skb->dev);
470 priv->nstats.rx_packets++;
471 priv->nstats.rx_bytes += rx_ind_size;
474 priv->nstats.rx_dropped++;
477 case 0xF0: /* NETBEUI/NetBIOS */
478 rx_ind_size = (priv->rx_size + 2);
479 skb = dev_alloc_skb(rx_ind_size);
480 DPRINTK(3, "NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size);
483 memcpy(skb_put(skb, 12), priv->rxp, 12); /* 8802/FDDI MAC copy */
485 temp[0] = (((rx_ind_size - 12) >> 8) & 0xff); /* NETBEUI size add */
486 temp[1] = ((rx_ind_size - 12) & 0xff);
487 memcpy(skb_put(skb, 2), temp, 2);
489 memcpy(skb_put(skb, rx_ind_size - 14), priv->rxp + 12, rx_ind_size - 14); /* copy after Type */
491 aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
492 if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY
493 && priv->wpa.rsn_enabled) {
495 (struct wpa_eapol_key *)(aa1x_hdr + 1);
496 atomic_set(&priv->psstatus.snooze_guard, 1);
500 skb->dev = priv->net_dev;
501 skb->protocol = eth_type_trans(skb, skb->dev);
502 priv->nstats.rx_packets++;
503 priv->nstats.rx_bytes += rx_ind_size;
506 priv->nstats.rx_dropped++;
509 default: /* other rx data */
510 DPRINTK(2, "invalid data format\n");
511 priv->nstats.rx_errors++;
516 void hostif_mib_get_confirm(struct ks_wlan_private *priv)
518 struct net_device *dev = priv->net_dev;
526 mib_status = get_DWORD(priv); /* MIB status */
527 mib_attribute = get_DWORD(priv); /* MIB atttibute */
528 mib_val_size = get_WORD(priv); /* MIB value size */
529 mib_val_type = get_WORD(priv); /* MIB value type */
531 if (mib_status != 0) {
532 /* in case of error */
533 DPRINTK(1, "attribute=%08X, status=%08X\n", mib_attribute,
538 switch (mib_attribute) {
539 case DOT11_MAC_ADDRESS:
541 DPRINTK(3, " mib_attribute=DOT11_MAC_ADDRESS\n");
542 hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
543 memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
544 priv->mac_address_valid = 1;
545 dev->dev_addr[0] = priv->eth_addr[0];
546 dev->dev_addr[1] = priv->eth_addr[1];
547 dev->dev_addr[2] = priv->eth_addr[2];
548 dev->dev_addr[3] = priv->eth_addr[3];
549 dev->dev_addr[4] = priv->eth_addr[4];
550 dev->dev_addr[5] = priv->eth_addr[5];
551 dev->dev_addr[6] = 0x00;
552 dev->dev_addr[7] = 0x00;
553 netdev_info(dev, "MAC ADDRESS = %pM\n", priv->eth_addr);
555 case DOT11_PRODUCT_VERSION:
556 /* firmware version */
557 DPRINTK(3, " mib_attribute=DOT11_PRODUCT_VERSION\n");
558 priv->version_size = priv->rx_size;
559 memcpy(priv->firmware_version, priv->rxp, priv->rx_size);
560 priv->firmware_version[priv->rx_size] = '\0';
561 netdev_info(dev, "firmware ver. = %s\n",
562 priv->firmware_version);
563 hostif_sme_enqueue(priv, SME_GET_PRODUCT_VERSION);
564 /* wake_up_interruptible_all(&priv->confirm_wait); */
565 complete(&priv->confirm_wait);
568 memcpy(&priv->gain, priv->rxp, sizeof(priv->gain));
569 DPRINTK(3, "TxMode=%d, RxMode=%d, TxGain=%d, RxGain=%d\n",
570 priv->gain.TxMode, priv->gain.RxMode, priv->gain.TxGain,
573 case LOCAL_EEPROM_SUM:
574 memcpy(&priv->eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum));
575 DPRINTK(1, "eeprom_sum.type=%x, eeprom_sum.result=%x\n",
576 priv->eeprom_sum.type, priv->eeprom_sum.result);
577 if (priv->eeprom_sum.type == 0) {
578 priv->eeprom_checksum = EEPROM_CHECKSUM_NONE;
579 } else if (priv->eeprom_sum.type == 1) {
580 if (priv->eeprom_sum.result == 0) {
581 priv->eeprom_checksum = EEPROM_NG;
582 netdev_info(dev, "LOCAL_EEPROM_SUM NG\n");
583 } else if (priv->eeprom_sum.result == 1) {
584 priv->eeprom_checksum = EEPROM_OK;
587 netdev_err(dev, "LOCAL_EEPROM_SUM error!\n");
591 DPRINTK(1, "mib_attribute=%08x\n", (unsigned int)mib_attribute);
597 void hostif_mib_set_confirm(struct ks_wlan_private *priv)
599 u32 mib_status; /* +04 MIB Status */
600 u32 mib_attribute; /* +08 MIB attribute */
604 mib_status = get_DWORD(priv); /* MIB Status */
605 mib_attribute = get_DWORD(priv); /* MIB attribute */
607 if (mib_status != 0) {
608 /* in case of error */
609 DPRINTK(1, "error :: attribute=%08X, status=%08X\n",
610 mib_attribute, mib_status);
613 switch (mib_attribute) {
614 case DOT11_RTS_THRESHOLD:
615 hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_CONFIRM);
617 case DOT11_FRAGMENTATION_THRESHOLD:
618 hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_CONFIRM);
620 case DOT11_WEP_DEFAULT_KEY_ID:
621 if (!priv->wpa.wpa_enabled)
622 hostif_sme_enqueue(priv, SME_WEP_INDEX_CONFIRM);
624 case DOT11_WEP_DEFAULT_KEY_VALUE1:
625 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE1:mib_status=%d\n",
627 if (priv->wpa.rsn_enabled)
628 hostif_sme_enqueue(priv, SME_SET_PMK_TSC);
630 hostif_sme_enqueue(priv, SME_WEP_KEY1_CONFIRM);
632 case DOT11_WEP_DEFAULT_KEY_VALUE2:
633 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE2:mib_status=%d\n",
635 if (priv->wpa.rsn_enabled)
636 hostif_sme_enqueue(priv, SME_SET_GMK1_TSC);
638 hostif_sme_enqueue(priv, SME_WEP_KEY2_CONFIRM);
640 case DOT11_WEP_DEFAULT_KEY_VALUE3:
641 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE3:mib_status=%d\n",
643 if (priv->wpa.rsn_enabled)
644 hostif_sme_enqueue(priv, SME_SET_GMK2_TSC);
646 hostif_sme_enqueue(priv, SME_WEP_KEY3_CONFIRM);
648 case DOT11_WEP_DEFAULT_KEY_VALUE4:
649 DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE4:mib_status=%d\n",
651 if (!priv->wpa.rsn_enabled)
652 hostif_sme_enqueue(priv, SME_WEP_KEY4_CONFIRM);
654 case DOT11_PRIVACY_INVOKED:
655 if (!priv->wpa.rsn_enabled)
656 hostif_sme_enqueue(priv, SME_WEP_FLAG_CONFIRM);
658 case DOT11_RSN_ENABLED:
659 DPRINTK(2, "DOT11_RSN_ENABLED:mib_status=%d\n",
661 hostif_sme_enqueue(priv, SME_RSN_ENABLED_CONFIRM);
664 hostif_sme_enqueue(priv, SME_RSN_MODE_CONFIRM);
666 case LOCAL_MULTICAST_ADDRESS:
667 hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST);
669 case LOCAL_MULTICAST_FILTER:
670 hostif_sme_enqueue(priv, SME_MULTICAST_CONFIRM);
672 case LOCAL_CURRENTADDRESS:
673 priv->mac_address_valid = 1;
675 case DOT11_RSN_CONFIG_MULTICAST_CIPHER:
676 DPRINTK(2, "DOT11_RSN_CONFIG_MULTICAST_CIPHER:mib_status=%d\n",
678 hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM);
680 case DOT11_RSN_CONFIG_UNICAST_CIPHER:
681 DPRINTK(2, "DOT11_RSN_CONFIG_UNICAST_CIPHER:mib_status=%d\n",
683 hostif_sme_enqueue(priv, SME_RSN_UCAST_CONFIRM);
685 case DOT11_RSN_CONFIG_AUTH_SUITE:
686 DPRINTK(2, "DOT11_RSN_CONFIG_AUTH_SUITE:mib_status=%d\n",
688 hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM);
691 DPRINTK(2, "DOT11_PMK_TSC:mib_status=%d\n", (int)mib_status);
694 DPRINTK(2, "DOT11_GMK1_TSC:mib_status=%d\n", (int)mib_status);
695 if (atomic_read(&priv->psstatus.snooze_guard))
696 atomic_set(&priv->psstatus.snooze_guard, 0);
699 DPRINTK(2, "DOT11_GMK2_TSC:mib_status=%d\n", (int)mib_status);
700 if (atomic_read(&priv->psstatus.snooze_guard))
701 atomic_set(&priv->psstatus.snooze_guard, 0);
704 DPRINTK(2, "LOCAL_PMK:mib_status=%d\n", (int)mib_status);
707 DPRINTK(2, "LOCAL_GAIN:mib_status=%d\n", (int)mib_status);
710 case LOCAL_WPS_ENABLE:
711 DPRINTK(2, "LOCAL_WPS_ENABLE:mib_status=%d\n", (int)mib_status);
713 case LOCAL_WPS_PROBE_REQ:
714 DPRINTK(2, "LOCAL_WPS_PROBE_REQ:mib_status=%d\n",
719 DPRINTK(2, "LOCAL_REGION:mib_status=%d\n", (int)mib_status);
726 void hostif_power_mngmt_confirm(struct ks_wlan_private *priv)
730 if (priv->reg.powermgt > POWMGT_ACTIVE_MODE &&
731 priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
732 atomic_set(&priv->psstatus.confirm_wait, 0);
733 priv->dev_state = DEVICE_STATE_SLEEP;
734 ks_wlan_hw_power_save(priv);
736 priv->dev_state = DEVICE_STATE_READY;
741 void hostif_sleep_confirm(struct ks_wlan_private *priv)
745 atomic_set(&priv->sleepstatus.doze_request, 1);
746 queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
747 &priv->ks_wlan_hw.rw_wq, 1);
751 void hostif_start_confirm(struct ks_wlan_private *priv)
754 union iwreq_data wrqu;
756 wrqu.data.length = 0;
758 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
759 if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
760 eth_zero_addr(wrqu.ap_addr.sa_data);
761 DPRINTK(3, "IWEVENT: disconnect\n");
762 wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
765 DPRINTK(3, " scan_ind_count=%d\n", priv->scan_ind_count);
766 hostif_sme_enqueue(priv, SME_START_CONFIRM);
770 void hostif_connect_indication(struct ks_wlan_private *priv)
772 unsigned short connect_code;
773 unsigned int tmp = 0;
774 unsigned int old_status = priv->connect_status;
775 struct net_device *netdev = priv->net_dev;
776 union iwreq_data wrqu0;
778 connect_code = get_WORD(priv);
780 switch (connect_code) {
781 case RESULT_CONNECT: /* connect */
782 DPRINTK(3, "connect :: scan_ind_count=%d\n",
783 priv->scan_ind_count);
784 if (!(priv->connect_status & FORCE_DISCONNECT))
785 netif_carrier_on(netdev);
786 tmp = FORCE_DISCONNECT & priv->connect_status;
787 priv->connect_status = tmp + CONNECT_STATUS;
789 case RESULT_DISCONNECT: /* disconnect */
790 DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
791 priv->scan_ind_count);
792 netif_carrier_off(netdev);
793 tmp = FORCE_DISCONNECT & priv->connect_status;
794 priv->connect_status = tmp + DISCONNECT_STATUS;
797 DPRINTK(1, "unknown connect_code=%d :: scan_ind_count=%d\n",
798 connect_code, priv->scan_ind_count);
799 netif_carrier_off(netdev);
800 tmp = FORCE_DISCONNECT & priv->connect_status;
801 priv->connect_status = tmp + DISCONNECT_STATUS;
805 get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
806 if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS &&
807 (old_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) {
809 atomic_set(&priv->psstatus.snooze_guard, 0);
810 atomic_set(&priv->psstatus.confirm_wait, 0);
812 ks_wlan_do_power_save(priv);
814 wrqu0.data.length = 0;
815 wrqu0.data.flags = 0;
816 wrqu0.ap_addr.sa_family = ARPHRD_ETHER;
817 if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS &&
818 (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
819 eth_zero_addr(wrqu0.ap_addr.sa_data);
820 DPRINTK(3, "IWEVENT: disconnect\n");
821 DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
822 priv->scan_ind_count);
823 wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL);
825 priv->scan_ind_count = 0;
829 void hostif_scan_indication(struct ks_wlan_private *priv)
832 struct ap_info_t *ap_info;
834 DPRINTK(3, "scan_ind_count = %d\n", priv->scan_ind_count);
835 ap_info = (struct ap_info_t *)(priv->rxp);
837 if (priv->scan_ind_count != 0) {
838 for (i = 0; i < priv->aplist.size; i++) { /* bssid check */
841 priv->aplist.ap[i].bssid, ETH_ALEN)) {
842 if (ap_info->frame_type ==
843 FRAME_TYPE_PROBE_RESP)
844 get_ap_information(priv, ap_info,
845 &priv->aplist.ap[i]);
850 priv->scan_ind_count++;
851 if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
852 DPRINTK(4, " scan_ind_count=%d :: aplist.size=%d\n",
853 priv->scan_ind_count, priv->aplist.size);
854 get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
856 ap[priv->scan_ind_count - 1]));
857 priv->aplist.size = priv->scan_ind_count;
859 DPRINTK(4, " count over :: scan_ind_count=%d\n",
860 priv->scan_ind_count);
865 void hostif_stop_confirm(struct ks_wlan_private *priv)
867 unsigned int tmp = 0;
868 unsigned int old_status = priv->connect_status;
869 struct net_device *netdev = priv->net_dev;
870 union iwreq_data wrqu0;
873 if (priv->dev_state == DEVICE_STATE_SLEEP)
874 priv->dev_state = DEVICE_STATE_READY;
876 /* disconnect indication */
877 if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
878 netif_carrier_off(netdev);
879 tmp = FORCE_DISCONNECT & priv->connect_status;
880 priv->connect_status = tmp | DISCONNECT_STATUS;
881 netdev_info(netdev, "IWEVENT: disconnect\n");
883 wrqu0.data.length = 0;
884 wrqu0.data.flags = 0;
885 wrqu0.ap_addr.sa_family = ARPHRD_ETHER;
886 if ((priv->connect_status & CONNECT_STATUS_MASK) ==
888 && (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
889 eth_zero_addr(wrqu0.ap_addr.sa_data);
890 DPRINTK(3, "IWEVENT: disconnect\n");
891 netdev_info(netdev, "IWEVENT: disconnect\n");
892 DPRINTK(3, "disconnect :: scan_ind_count=%d\n",
893 priv->scan_ind_count);
894 wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL);
896 priv->scan_ind_count = 0;
899 hostif_sme_enqueue(priv, SME_STOP_CONFIRM);
903 void hostif_ps_adhoc_set_confirm(struct ks_wlan_private *priv)
906 priv->infra_status = 0; /* infrastructure mode cancel */
907 hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
911 void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
916 result_code = get_WORD(priv);
917 DPRINTK(3, "result code = %d\n", result_code);
918 priv->infra_status = 1; /* infrastructure mode set */
919 hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
923 void hostif_adhoc_set_confirm(struct ks_wlan_private *priv)
926 priv->infra_status = 1; /* infrastructure mode set */
927 hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
931 void hostif_associate_indication(struct ks_wlan_private *priv)
933 struct association_request_t *assoc_req;
934 struct association_response_t *assoc_resp;
936 union iwreq_data wrqu;
937 char buf[IW_CUSTOM_MAX];
938 char *pbuf = &buf[0];
941 static const char associnfo_leader0[] = "ASSOCINFO(ReqIEs=";
942 static const char associnfo_leader1[] = " RespIEs=";
945 assoc_req = (struct association_request_t *)(priv->rxp);
946 assoc_resp = (struct association_response_t *)(assoc_req + 1);
947 pb = (unsigned char *)(assoc_resp + 1);
949 memset(&wrqu, 0, sizeof(wrqu));
950 memcpy(pbuf, associnfo_leader0, sizeof(associnfo_leader0) - 1);
951 wrqu.data.length += sizeof(associnfo_leader0) - 1;
952 pbuf += sizeof(associnfo_leader0) - 1;
954 for (i = 0; i < assoc_req->reqIEs_size; i++)
955 pbuf += sprintf(pbuf, "%02x", *(pb + i));
956 wrqu.data.length += (assoc_req->reqIEs_size) * 2;
958 memcpy(pbuf, associnfo_leader1, sizeof(associnfo_leader1) - 1);
959 wrqu.data.length += sizeof(associnfo_leader1) - 1;
960 pbuf += sizeof(associnfo_leader1) - 1;
962 pb += assoc_req->reqIEs_size;
963 for (i = 0; i < assoc_resp->respIEs_size; i++)
964 pbuf += sprintf(pbuf, "%02x", *(pb + i));
965 wrqu.data.length += (assoc_resp->respIEs_size) * 2;
967 pbuf += sprintf(pbuf, ")");
968 wrqu.data.length += 1;
970 DPRINTK(3, "IWEVENT:ASSOCINFO\n");
971 wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf);
975 void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
977 unsigned int result_code;
978 struct net_device *dev = priv->net_dev;
979 union iwreq_data wrqu;
981 result_code = get_DWORD(priv);
982 DPRINTK(2, "result=%d :: scan_ind_count=%d\n", result_code,
983 priv->scan_ind_count);
985 priv->sme_i.sme_flag &= ~SME_AP_SCAN;
986 hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM);
988 wrqu.data.length = 0;
990 DPRINTK(3, "IWEVENT: SCAN CONFIRM\n");
991 wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
992 priv->scan_ind_count = 0;
996 void hostif_phy_information_confirm(struct ks_wlan_private *priv)
998 struct iw_statistics *wstats = &priv->wstats;
999 unsigned char rssi, signal, noise;
1000 unsigned char LinkSpeed;
1001 unsigned int TransmittedFrameCount, ReceivedFragmentCount;
1002 unsigned int FailedCount, FCSErrorCount;
1005 rssi = get_BYTE(priv);
1006 signal = get_BYTE(priv);
1007 noise = get_BYTE(priv);
1008 LinkSpeed = get_BYTE(priv);
1009 TransmittedFrameCount = get_DWORD(priv);
1010 ReceivedFragmentCount = get_DWORD(priv);
1011 FailedCount = get_DWORD(priv);
1012 FCSErrorCount = get_DWORD(priv);
1014 DPRINTK(4, "phyinfo confirm rssi=%d signal=%d\n", rssi, signal);
1015 priv->current_rate = (LinkSpeed & RATE_MASK);
1016 wstats->qual.qual = signal;
1017 wstats->qual.level = 256 - rssi;
1018 wstats->qual.noise = 0; /* invalid noise value */
1019 wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1021 DPRINTK(3, "\n rssi=%u\n signal=%u\n LinkSpeed=%ux500Kbps\n \
1022 TransmittedFrameCount=%u\n ReceivedFragmentCount=%u\n FailedCount=%u\n \
1023 FCSErrorCount=%u\n", rssi, signal, LinkSpeed, TransmittedFrameCount, ReceivedFragmentCount, FailedCount, FCSErrorCount);
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_POWERMGT_CONF:
1054 hostif_power_mngmt_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 #define CHECK_ALINE(size) (size % 4 ? (size + (4 - (size % 4))) : size)
1111 int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet)
1113 unsigned int packet_len = 0;
1115 unsigned char *buffer = NULL;
1116 unsigned int length = 0;
1117 struct hostif_data_request_t *pp;
1120 unsigned short eth_proto;
1121 struct ether_hdr *eth_hdr;
1122 struct michael_mic_t michael_mic;
1123 unsigned short keyinfo = 0;
1124 struct ieee802_1x_hdr *aa1x_hdr;
1125 struct wpa_eapol_key *eap_key;
1129 packet_len = packet->len;
1130 if (packet_len > ETH_FRAME_LEN) {
1131 DPRINTK(1, "bad length packet_len=%d\n", packet_len);
1136 if (((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS)
1137 || (priv->connect_status & FORCE_DISCONNECT)
1138 || priv->wpa.mic_failure.stop) {
1139 DPRINTK(3, " DISCONNECT\n");
1140 if (netif_queue_stopped(priv->net_dev))
1141 netif_wake_queue(priv->net_dev);
1143 dev_kfree_skb(packet);
1149 if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { /* power save wakeup */
1150 if (!netif_queue_stopped(priv->net_dev))
1151 netif_stop_queue(priv->net_dev);
1154 DPRINTK(4, "skb_buff length=%d\n", packet_len);
1155 pp = kmalloc(hif_align_size(sizeof(*pp) + 6 + packet_len + 8),
1159 DPRINTK(3, "allocate memory failed..\n");
1164 p = (unsigned char *)pp->data;
1166 buffer = packet->data;
1167 length = packet->len;
1170 eth = (struct ethhdr *)packet->data;
1171 if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN)) {
1172 DPRINTK(1, "invalid mac address !!\n");
1173 DPRINTK(1, "ethernet->h_source=%pM\n", eth->h_source);
1178 /* MAC address copy */
1179 memcpy(p, buffer, 12); /* DST/SRC MAC address */
1183 /* EtherType/Length check */
1184 if (*(buffer + 1) + (*buffer << 8) > 1500) {
1185 /* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
1186 /* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */
1187 /* SAP/CTL/OUI(6 byte) add */
1188 *p++ = 0xAA; /* DSAP */
1189 *p++ = 0xAA; /* SSAP */
1190 *p++ = 0x03; /* CTL */
1191 *p++ = 0x00; /* OUI ("000000") */
1192 *p++ = 0x00; /* OUI ("000000") */
1193 *p++ = 0x00; /* OUI ("000000") */
1196 DPRINTK(4, "DIX\n");
1197 /* Length(2 byte) delete */
1204 memcpy(p, buffer, length);
1209 eth_hdr = (struct ether_hdr *)&pp->data[0];
1210 eth_proto = ntohs(eth_hdr->h_proto);
1212 /* for MIC FAILURE REPORT check */
1213 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP
1214 && priv->wpa.mic_failure.failure > 0) {
1215 aa1x_hdr = (struct ieee802_1x_hdr *)(eth_hdr + 1);
1216 if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY) {
1217 eap_key = (struct wpa_eapol_key *)(aa1x_hdr + 1);
1218 keyinfo = ntohs(eap_key->key_info);
1222 if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len) {
1223 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP
1224 && !(priv->wpa.key[1].key_len)
1225 && !(priv->wpa.key[2].key_len)
1226 && !(priv->wpa.key[3].key_len)) {
1227 pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); /* no encryption */
1229 if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) {
1230 MichaelMICFunction(&michael_mic, (uint8_t *)priv->wpa.key[0].tx_mic_key, (uint8_t *)&pp->data[0], (int)packet_len, (uint8_t)0, /* priority */
1231 (uint8_t *)michael_mic.
1233 memcpy(p, michael_mic.Result, 8);
1238 cpu_to_le16((uint16_t)TYPE_DATA);
1240 } else if (priv->wpa.pairwise_suite ==
1241 IW_AUTH_CIPHER_CCMP) {
1243 cpu_to_le16((uint16_t)TYPE_DATA);
1247 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP)
1248 pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH);
1250 pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA);
1253 /* header value set */
1255 cpu_to_le16((uint16_t)
1256 (sizeof(*pp) - sizeof(pp->header.size) + packet_len));
1257 pp->header.event = cpu_to_le16((uint16_t)HIF_DATA_REQ);
1261 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + packet_len),
1262 (void *)send_packet_complete, (void *)priv,
1265 /* MIC FAILURE REPORT check */
1266 if (eth_proto == ETHER_PROTOCOL_TYPE_EAP
1267 && priv->wpa.mic_failure.failure > 0) {
1268 if (keyinfo & WPA_KEY_INFO_ERROR
1269 && keyinfo & WPA_KEY_INFO_REQUEST) {
1270 DPRINTK(3, " MIC ERROR Report SET : %04X\n", keyinfo);
1271 hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST);
1273 if (priv->wpa.mic_failure.failure == 2)
1274 priv->wpa.mic_failure.stop = 1;
1282 dev_kfree_skb(packet);
1287 #define ps_confirm_wait_inc(priv) do { \
1288 if (atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET) { \
1289 atomic_inc(&priv->psstatus.confirm_wait); \
1290 /* atomic_set(&priv->psstatus.status, PS_CONF_WAIT);*/ \
1294 void hostif_mib_get_request(struct ks_wlan_private *priv,
1295 unsigned long mib_attribute)
1297 struct hostif_mib_get_request_t *pp;
1301 /* make primitive */
1302 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1304 DPRINTK(3, "allocate memory failed..\n");
1308 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1309 pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_GET_REQ);
1310 pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
1312 /* send to device request */
1313 ps_confirm_wait_inc(priv);
1314 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1318 void hostif_mib_set_request(struct ks_wlan_private *priv,
1319 unsigned long mib_attribute, unsigned short size,
1320 unsigned short type, void *vp)
1322 struct hostif_mib_set_request_t *pp;
1326 if (priv->dev_state < DEVICE_STATE_BOOT) {
1327 DPRINTK(3, "DeviceRemove\n");
1331 /* make primitive */
1332 pp = kmalloc(hif_align_size(sizeof(*pp) + size), KS_WLAN_MEM_FLAG);
1334 DPRINTK(3, "allocate memory failed..\n");
1339 cpu_to_le16((uint16_t)
1340 (sizeof(*pp) - sizeof(pp->header.size) + size));
1341 pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_SET_REQ);
1342 pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
1343 pp->mib_value.size = cpu_to_le16((uint16_t)size);
1344 pp->mib_value.type = cpu_to_le16((uint16_t)type);
1345 memcpy(&pp->mib_value.body, vp, size);
1347 /* send to device request */
1348 ps_confirm_wait_inc(priv);
1349 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL,
1354 void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
1356 struct hostif_start_request_t *pp;
1360 /* make primitive */
1361 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1363 DPRINTK(3, "allocate memory failed..\n");
1367 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1368 pp->header.event = cpu_to_le16((uint16_t)HIF_START_REQ);
1369 pp->mode = cpu_to_le16((uint16_t)mode);
1371 /* send to device request */
1372 ps_confirm_wait_inc(priv);
1373 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1375 priv->aplist.size = 0;
1376 priv->scan_ind_count = 0;
1380 void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv)
1382 struct hostif_ps_adhoc_set_request_t *pp;
1387 /* make primitive */
1388 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1390 DPRINTK(3, "allocate memory failed..\n");
1393 memset(pp, 0, sizeof(*pp));
1395 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1396 pp->header.event = cpu_to_le16((uint16_t)HIF_PS_ADH_SET_REQ);
1397 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1398 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1399 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1400 pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
1401 pp->rate_set.size = priv->reg.rate_set.size;
1402 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1403 priv->reg.rate_set.size);
1405 capability = 0x0000;
1406 if (priv->reg.preamble == SHORT_PREAMBLE) {
1407 /* short preamble */
1408 capability |= BSS_CAP_SHORT_PREAMBLE;
1410 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1411 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1412 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1413 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM */
1415 pp->capability = cpu_to_le16((uint16_t)capability);
1417 /* send to device request */
1418 ps_confirm_wait_inc(priv);
1419 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1423 void hostif_infrastructure_set_request(struct ks_wlan_private *priv)
1425 struct hostif_infrastructure_set_request_t *pp;
1428 DPRINTK(3, "ssid.size=%d\n", priv->reg.ssid.size);
1430 /* make primitive */
1431 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1433 DPRINTK(3, "allocate memory failed..\n");
1437 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1438 pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET_REQ);
1439 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1440 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1441 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1443 pp->rate_set.size = priv->reg.rate_set.size;
1444 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1445 priv->reg.rate_set.size);
1446 pp->ssid.size = priv->reg.ssid.size;
1447 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1449 capability = 0x0000;
1450 if (priv->reg.preamble == SHORT_PREAMBLE) {
1451 /* short preamble */
1452 capability |= BSS_CAP_SHORT_PREAMBLE;
1454 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1455 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1456 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1457 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1459 pp->capability = cpu_to_le16((uint16_t)capability);
1460 pp->beacon_lost_count =
1461 cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
1462 pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type));
1464 pp->channel_list.body[0] = 1;
1465 pp->channel_list.body[1] = 8;
1466 pp->channel_list.body[2] = 2;
1467 pp->channel_list.body[3] = 9;
1468 pp->channel_list.body[4] = 3;
1469 pp->channel_list.body[5] = 10;
1470 pp->channel_list.body[6] = 4;
1471 pp->channel_list.body[7] = 11;
1472 pp->channel_list.body[8] = 5;
1473 pp->channel_list.body[9] = 12;
1474 pp->channel_list.body[10] = 6;
1475 pp->channel_list.body[11] = 13;
1476 pp->channel_list.body[12] = 7;
1477 if (priv->reg.phy_type == D_11G_ONLY_MODE) {
1478 pp->channel_list.size = 13;
1480 pp->channel_list.body[13] = 14;
1481 pp->channel_list.size = 14;
1484 /* send to device request */
1485 ps_confirm_wait_inc(priv);
1486 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1489 static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv)
1491 struct hostif_infrastructure_set2_request_t *pp;
1494 DPRINTK(2, "ssid.size=%d\n", priv->reg.ssid.size);
1496 /* make primitive */
1497 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1499 DPRINTK(3, "allocate memory failed..\n");
1503 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1504 pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET2_REQ);
1505 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1506 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1507 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1509 pp->rate_set.size = priv->reg.rate_set.size;
1510 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1511 priv->reg.rate_set.size);
1512 pp->ssid.size = priv->reg.ssid.size;
1513 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1515 capability = 0x0000;
1516 if (priv->reg.preamble == SHORT_PREAMBLE) {
1517 /* short preamble */
1518 capability |= BSS_CAP_SHORT_PREAMBLE;
1520 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1521 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1522 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1523 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1525 pp->capability = cpu_to_le16((uint16_t)capability);
1526 pp->beacon_lost_count =
1527 cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
1528 pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type));
1530 pp->channel_list.body[0] = 1;
1531 pp->channel_list.body[1] = 8;
1532 pp->channel_list.body[2] = 2;
1533 pp->channel_list.body[3] = 9;
1534 pp->channel_list.body[4] = 3;
1535 pp->channel_list.body[5] = 10;
1536 pp->channel_list.body[6] = 4;
1537 pp->channel_list.body[7] = 11;
1538 pp->channel_list.body[8] = 5;
1539 pp->channel_list.body[9] = 12;
1540 pp->channel_list.body[10] = 6;
1541 pp->channel_list.body[11] = 13;
1542 pp->channel_list.body[12] = 7;
1543 if (priv->reg.phy_type == D_11G_ONLY_MODE) {
1544 pp->channel_list.size = 13;
1546 pp->channel_list.body[13] = 14;
1547 pp->channel_list.size = 14;
1550 memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
1552 /* send to device request */
1553 ps_confirm_wait_inc(priv);
1554 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1558 void hostif_adhoc_set_request(struct ks_wlan_private *priv)
1560 struct hostif_adhoc_set_request_t *pp;
1565 /* make primitive */
1566 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1568 DPRINTK(3, "allocate memory failed..\n");
1571 memset(pp, 0, sizeof(*pp));
1573 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1574 pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ);
1575 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1576 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1577 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1578 pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
1579 pp->rate_set.size = priv->reg.rate_set.size;
1580 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1581 priv->reg.rate_set.size);
1582 pp->ssid.size = priv->reg.ssid.size;
1583 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1585 capability = 0x0000;
1586 if (priv->reg.preamble == SHORT_PREAMBLE) {
1587 /* short preamble */
1588 capability |= BSS_CAP_SHORT_PREAMBLE;
1590 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1591 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1592 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1593 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1595 pp->capability = cpu_to_le16((uint16_t)capability);
1597 /* send to device request */
1598 ps_confirm_wait_inc(priv);
1599 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1603 void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
1605 struct hostif_adhoc_set2_request_t *pp;
1610 /* make primitive */
1611 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1613 DPRINTK(3, "allocate memory failed..\n");
1616 memset(pp, 0, sizeof(*pp));
1618 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1619 pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ);
1620 pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
1621 pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
1622 pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
1623 pp->rate_set.size = priv->reg.rate_set.size;
1624 memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
1625 priv->reg.rate_set.size);
1626 pp->ssid.size = priv->reg.ssid.size;
1627 memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
1629 capability = 0x0000;
1630 if (priv->reg.preamble == SHORT_PREAMBLE) {
1631 /* short preamble */
1632 capability |= BSS_CAP_SHORT_PREAMBLE;
1634 capability &= ~(BSS_CAP_PBCC); /* pbcc not support */
1635 if (priv->reg.phy_type != D_11B_ONLY_MODE) {
1636 capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */
1637 capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */
1639 pp->capability = cpu_to_le16((uint16_t)capability);
1641 pp->channel_list.body[0] = priv->reg.channel;
1642 pp->channel_list.size = 1;
1643 memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
1645 /* send to device request */
1646 ps_confirm_wait_inc(priv);
1647 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1651 void hostif_stop_request(struct ks_wlan_private *priv)
1653 struct hostif_stop_request_t *pp;
1657 /* make primitive */
1658 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1660 DPRINTK(3, "allocate memory failed..\n");
1664 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1665 pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ);
1667 /* send to device request */
1668 ps_confirm_wait_inc(priv);
1669 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1673 void hostif_phy_information_request(struct ks_wlan_private *priv)
1675 struct hostif_phy_information_request_t *pp;
1679 /* make primitive */
1680 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1682 DPRINTK(3, "allocate memory failed..\n");
1686 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1687 pp->header.event = cpu_to_le16((uint16_t)HIF_PHY_INFO_REQ);
1688 if (priv->reg.phy_info_timer) {
1689 pp->type = cpu_to_le16((uint16_t)TIME_TYPE);
1690 pp->time = cpu_to_le16((uint16_t)(priv->reg.phy_info_timer));
1692 pp->type = cpu_to_le16((uint16_t)NORMAL_TYPE);
1693 pp->time = cpu_to_le16((uint16_t)0);
1696 /* send to device request */
1697 ps_confirm_wait_inc(priv);
1698 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1702 void hostif_power_mngmt_request(struct ks_wlan_private *priv,
1703 unsigned long mode, unsigned long wake_up,
1704 unsigned long receiveDTIMs)
1706 struct hostif_power_mngmt_request_t *pp;
1708 DPRINTK(3, "mode=%lu wake_up=%lu receiveDTIMs=%lu\n", mode, wake_up,
1710 /* make primitive */
1711 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1713 DPRINTK(3, "allocate memory failed..\n");
1717 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1718 pp->header.event = cpu_to_le16((uint16_t)HIF_POWERMGT_REQ);
1719 pp->mode = cpu_to_le32((uint32_t)mode);
1720 pp->wake_up = cpu_to_le32((uint32_t)wake_up);
1721 pp->receiveDTIMs = cpu_to_le32((uint32_t)receiveDTIMs);
1723 /* send to device request */
1724 ps_confirm_wait_inc(priv);
1725 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1729 void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode)
1731 struct hostif_sleep_request_t *pp;
1733 DPRINTK(3, "mode=%lu\n", mode);
1735 if (mode == SLP_SLEEP) {
1736 /* make primitive */
1737 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1739 DPRINTK(3, "allocate memory failed..\n");
1743 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1744 pp->header.event = cpu_to_le16((uint16_t)HIF_SLEEP_REQ);
1746 /* send to device request */
1747 ps_confirm_wait_inc(priv);
1748 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL,
1750 } else if (mode == SLP_ACTIVE) {
1751 atomic_set(&priv->sleepstatus.wakeup_request, 1);
1752 queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
1753 &priv->ks_wlan_hw.rw_wq, 1);
1755 DPRINTK(3, "invalid mode %ld\n", mode);
1761 void hostif_bss_scan_request(struct ks_wlan_private *priv,
1762 unsigned long scan_type, uint8_t *scan_ssid,
1763 uint8_t scan_ssid_len)
1765 struct hostif_bss_scan_request_t *pp;
1768 /* make primitive */
1769 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1771 DPRINTK(3, "allocate memory failed..\n");
1775 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1776 pp->header.event = cpu_to_le16((uint16_t)HIF_SCAN_REQ);
1777 pp->scan_type = scan_type;
1779 pp->ch_time_min = cpu_to_le32((uint32_t)110); /* default value */
1780 pp->ch_time_max = cpu_to_le32((uint32_t)130); /* default value */
1781 pp->channel_list.body[0] = 1;
1782 pp->channel_list.body[1] = 8;
1783 pp->channel_list.body[2] = 2;
1784 pp->channel_list.body[3] = 9;
1785 pp->channel_list.body[4] = 3;
1786 pp->channel_list.body[5] = 10;
1787 pp->channel_list.body[6] = 4;
1788 pp->channel_list.body[7] = 11;
1789 pp->channel_list.body[8] = 5;
1790 pp->channel_list.body[9] = 12;
1791 pp->channel_list.body[10] = 6;
1792 pp->channel_list.body[11] = 13;
1793 pp->channel_list.body[12] = 7;
1794 if (priv->reg.phy_type == D_11G_ONLY_MODE) {
1795 pp->channel_list.size = 13;
1797 pp->channel_list.body[13] = 14;
1798 pp->channel_list.size = 14;
1802 /* specified SSID SCAN */
1803 if (scan_ssid_len > 0 && scan_ssid_len <= 32) {
1804 pp->ssid.size = scan_ssid_len;
1805 memcpy(&pp->ssid.body[0], scan_ssid, scan_ssid_len);
1808 /* send to device request */
1809 ps_confirm_wait_inc(priv);
1810 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1812 priv->aplist.size = 0;
1813 priv->scan_ind_count = 0;
1817 void hostif_mic_failure_request(struct ks_wlan_private *priv,
1818 unsigned short failure_count,
1819 unsigned short timer)
1821 struct hostif_mic_failure_request_t *pp;
1823 DPRINTK(3, "count=%d :: timer=%d\n", failure_count, timer);
1824 /* make primitive */
1825 pp = kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG);
1827 DPRINTK(3, "allocate memory failed..\n");
1831 cpu_to_le16((uint16_t)(sizeof(*pp) - sizeof(pp->header.size)));
1832 pp->header.event = cpu_to_le16((uint16_t)HIF_MIC_FAILURE_REQ);
1833 pp->failure_count = cpu_to_le16((uint16_t)failure_count);
1834 pp->timer = cpu_to_le16((uint16_t)timer);
1836 /* send to device request */
1837 ps_confirm_wait_inc(priv);
1838 ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL);
1841 /* Device I/O Receive indicate */
1842 static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p,
1845 if (priv->device_open_status) {
1846 spin_lock(&priv->dev_read_lock); /* request spin lock */
1847 priv->dev_data[atomic_read(&priv->rec_count)] = p;
1848 priv->dev_size[atomic_read(&priv->rec_count)] = size;
1850 if (atomic_read(&priv->event_count) != DEVICE_STOCK_COUNT) {
1851 /* rx event count inc */
1852 atomic_inc(&priv->event_count);
1854 atomic_inc(&priv->rec_count);
1855 if (atomic_read(&priv->rec_count) == DEVICE_STOCK_COUNT)
1856 atomic_set(&priv->rec_count, 0);
1858 wake_up_interruptible_all(&priv->devread_wait);
1860 /* release spin lock */
1861 spin_unlock(&priv->dev_read_lock);
1865 void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
1870 devio_rec_ind(priv, p, size);
1873 priv->rx_size = size;
1875 if (get_WORD(priv) == priv->rx_size) { /* length check !! */
1876 hostif_event_check(priv); /* event check */
1881 void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
1886 case SME_WEP_INDEX_REQUEST:
1887 val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
1888 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
1889 sizeof(val), MIB_VALUE_TYPE_INT, &val);
1891 case SME_WEP_KEY1_REQUEST:
1892 if (!priv->wpa.wpa_enabled)
1893 hostif_mib_set_request(priv,
1894 DOT11_WEP_DEFAULT_KEY_VALUE1,
1895 priv->reg.wep_key[0].size,
1896 MIB_VALUE_TYPE_OSTRING,
1897 &priv->reg.wep_key[0].val[0]);
1899 case SME_WEP_KEY2_REQUEST:
1900 if (!priv->wpa.wpa_enabled)
1901 hostif_mib_set_request(priv,
1902 DOT11_WEP_DEFAULT_KEY_VALUE2,
1903 priv->reg.wep_key[1].size,
1904 MIB_VALUE_TYPE_OSTRING,
1905 &priv->reg.wep_key[1].val[0]);
1907 case SME_WEP_KEY3_REQUEST:
1908 if (!priv->wpa.wpa_enabled)
1909 hostif_mib_set_request(priv,
1910 DOT11_WEP_DEFAULT_KEY_VALUE3,
1911 priv->reg.wep_key[2].size,
1912 MIB_VALUE_TYPE_OSTRING,
1913 &priv->reg.wep_key[2].val[0]);
1915 case SME_WEP_KEY4_REQUEST:
1916 if (!priv->wpa.wpa_enabled)
1917 hostif_mib_set_request(priv,
1918 DOT11_WEP_DEFAULT_KEY_VALUE4,
1919 priv->reg.wep_key[3].size,
1920 MIB_VALUE_TYPE_OSTRING,
1921 &priv->reg.wep_key[3].val[0]);
1923 case SME_WEP_FLAG_REQUEST:
1924 val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
1925 hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
1926 sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
1931 struct wpa_suite_t {
1932 unsigned short size;
1933 unsigned char suite[4][CIPHER_ID_LEN];
1942 void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
1944 struct wpa_suite_t wpa_suite;
1945 struct rsn_mode_t rsn_mode;
1948 memset(&wpa_suite, 0, sizeof(wpa_suite));
1951 case SME_RSN_UCAST_REQUEST:
1952 wpa_suite.size = cpu_to_le16((uint16_t)1);
1953 switch (priv->wpa.pairwise_suite) {
1954 case IW_AUTH_CIPHER_NONE:
1955 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1956 memcpy(&wpa_suite.suite[0][0],
1957 CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
1959 memcpy(&wpa_suite.suite[0][0],
1960 CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
1962 case IW_AUTH_CIPHER_WEP40:
1963 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1964 memcpy(&wpa_suite.suite[0][0],
1965 CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
1967 memcpy(&wpa_suite.suite[0][0],
1968 CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
1970 case IW_AUTH_CIPHER_TKIP:
1971 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1972 memcpy(&wpa_suite.suite[0][0],
1973 CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
1975 memcpy(&wpa_suite.suite[0][0],
1976 CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
1978 case IW_AUTH_CIPHER_CCMP:
1979 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1980 memcpy(&wpa_suite.suite[0][0],
1981 CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
1983 memcpy(&wpa_suite.suite[0][0],
1984 CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
1986 case IW_AUTH_CIPHER_WEP104:
1987 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
1988 memcpy(&wpa_suite.suite[0][0],
1989 CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
1991 memcpy(&wpa_suite.suite[0][0],
1992 CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
1996 hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER,
1997 sizeof(wpa_suite.size) +
1998 CIPHER_ID_LEN * wpa_suite.size,
1999 MIB_VALUE_TYPE_OSTRING, &wpa_suite);
2001 case SME_RSN_MCAST_REQUEST:
2002 switch (priv->wpa.group_suite) {
2003 case IW_AUTH_CIPHER_NONE:
2004 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2005 memcpy(&wpa_suite.suite[0][0],
2006 CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
2008 memcpy(&wpa_suite.suite[0][0],
2009 CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
2011 case IW_AUTH_CIPHER_WEP40:
2012 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2013 memcpy(&wpa_suite.suite[0][0],
2014 CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
2016 memcpy(&wpa_suite.suite[0][0],
2017 CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
2019 case IW_AUTH_CIPHER_TKIP:
2020 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2021 memcpy(&wpa_suite.suite[0][0],
2022 CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
2024 memcpy(&wpa_suite.suite[0][0],
2025 CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
2027 case IW_AUTH_CIPHER_CCMP:
2028 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2029 memcpy(&wpa_suite.suite[0][0],
2030 CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
2032 memcpy(&wpa_suite.suite[0][0],
2033 CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
2035 case IW_AUTH_CIPHER_WEP104:
2036 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2037 memcpy(&wpa_suite.suite[0][0],
2038 CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
2040 memcpy(&wpa_suite.suite[0][0],
2041 CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
2045 hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER,
2046 CIPHER_ID_LEN, MIB_VALUE_TYPE_OSTRING,
2047 &wpa_suite.suite[0][0]);
2049 case SME_RSN_AUTH_REQUEST:
2050 wpa_suite.size = cpu_to_le16((uint16_t)1);
2051 switch (priv->wpa.key_mgmt_suite) {
2052 case IW_AUTH_KEY_MGMT_802_1X:
2053 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2054 memcpy(&wpa_suite.suite[0][0],
2055 KEY_MGMT_ID_WPA2_1X, KEY_MGMT_ID_LEN);
2057 memcpy(&wpa_suite.suite[0][0],
2058 KEY_MGMT_ID_WPA_1X, KEY_MGMT_ID_LEN);
2060 case IW_AUTH_KEY_MGMT_PSK:
2061 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2062 memcpy(&wpa_suite.suite[0][0],
2063 KEY_MGMT_ID_WPA2_PSK, KEY_MGMT_ID_LEN);
2065 memcpy(&wpa_suite.suite[0][0],
2066 KEY_MGMT_ID_WPA_PSK, KEY_MGMT_ID_LEN);
2069 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2070 memcpy(&wpa_suite.suite[0][0],
2071 KEY_MGMT_ID_WPA2_NONE, KEY_MGMT_ID_LEN);
2073 memcpy(&wpa_suite.suite[0][0],
2074 KEY_MGMT_ID_WPA_NONE, KEY_MGMT_ID_LEN);
2077 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
2078 memcpy(&wpa_suite.suite[0][0],
2079 KEY_MGMT_ID_WPA2_WPANONE,
2082 memcpy(&wpa_suite.suite[0][0],
2083 KEY_MGMT_ID_WPA_WPANONE,
2088 hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE,
2089 sizeof(wpa_suite.size) +
2090 KEY_MGMT_ID_LEN * wpa_suite.size,
2091 MIB_VALUE_TYPE_OSTRING, &wpa_suite);
2093 case SME_RSN_ENABLED_REQUEST:
2094 val = cpu_to_le32((uint32_t)(priv->wpa.rsn_enabled));
2095 hostif_mib_set_request(priv, DOT11_RSN_ENABLED,
2096 sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
2098 case SME_RSN_MODE_REQUEST:
2099 if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
2101 cpu_to_le32((uint32_t)RSN_MODE_WPA2);
2102 rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
2103 } else if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) {
2105 cpu_to_le32((uint32_t)RSN_MODE_WPA);
2106 rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
2109 cpu_to_le32((uint32_t)RSN_MODE_NONE);
2110 rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
2112 hostif_mib_set_request(priv, LOCAL_RSN_MODE, sizeof(rsn_mode),
2113 MIB_VALUE_TYPE_OSTRING, &rsn_mode);
2119 void hostif_sme_mode_setup(struct ks_wlan_private *priv)
2121 unsigned char rate_size;
2122 unsigned char rate_octet[RATE_SET_MAX_SIZE];
2125 /* rate setting if rate segging is auto for changing phy_type (#94) */
2126 if (priv->reg.tx_rate == TX_RATE_FULL_AUTO) {
2127 if (priv->reg.phy_type == D_11B_ONLY_MODE) {
2128 priv->reg.rate_set.body[3] = TX_RATE_11M;
2129 priv->reg.rate_set.body[2] = TX_RATE_5M;
2130 priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE;
2131 priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE;
2132 priv->reg.rate_set.size = 4;
2133 } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
2134 priv->reg.rate_set.body[11] = TX_RATE_54M;
2135 priv->reg.rate_set.body[10] = TX_RATE_48M;
2136 priv->reg.rate_set.body[9] = TX_RATE_36M;
2137 priv->reg.rate_set.body[8] = TX_RATE_18M;
2138 priv->reg.rate_set.body[7] = TX_RATE_9M;
2139 priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE;
2140 priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE;
2141 priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE;
2142 priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE;
2143 priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE;
2144 priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE;
2145 priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE;
2146 priv->reg.rate_set.size = 12;
2150 /* rate mask by phy setting */
2151 if (priv->reg.phy_type == D_11B_ONLY_MODE) {
2152 for (i = 0; i < priv->reg.rate_set.size; i++) {
2153 if (IS_11B_RATE(priv->reg.rate_set.body[i])) {
2154 if ((priv->reg.rate_set.body[i] & RATE_MASK) >=
2158 body[i] & RATE_MASK;
2161 priv->reg.rate_set.body[i];
2167 } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
2168 for (i = 0; i < priv->reg.rate_set.size; i++) {
2169 if (IS_11BG_RATE(priv->reg.rate_set.body[i])) {
2170 if (IS_OFDM_EXT_RATE
2171 (priv->reg.rate_set.body[i]))
2174 body[i] & RATE_MASK;
2177 priv->reg.rate_set.body[i];
2184 if (rate_size == 0) {
2185 if (priv->reg.phy_type == D_11G_ONLY_MODE)
2186 rate_octet[0] = TX_RATE_6M | BASIC_RATE;
2188 rate_octet[0] = TX_RATE_2M | BASIC_RATE;
2192 /* rate set update */
2193 priv->reg.rate_set.size = rate_size;
2194 memcpy(&priv->reg.rate_set.body[0], &rate_octet[0], rate_size);
2196 switch (priv->reg.operation_mode) {
2197 case MODE_PSEUDO_ADHOC:
2198 /* Pseudo Ad-Hoc mode */
2199 hostif_ps_adhoc_set_request(priv);
2201 case MODE_INFRASTRUCTURE:
2202 /* Infrastructure mode */
2203 if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
2204 hostif_infrastructure_set_request(priv);
2206 hostif_infrastructure_set2_request(priv);
2208 "Infra bssid = %pM\n", priv->reg.bssid);
2212 /* IEEE802.11 Ad-Hoc mode */
2213 if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
2214 hostif_adhoc_set_request(priv);
2216 hostif_adhoc_set2_request(priv);
2218 "Adhoc bssid = %pM\n", priv->reg.bssid);
2227 void hostif_sme_multicast_set(struct ks_wlan_private *priv)
2229 struct net_device *dev = priv->net_dev;
2231 struct netdev_hw_addr *ha;
2232 char set_address[NIC_MAX_MCAST_LIST * ETH_ALEN];
2233 unsigned long filter_type;
2238 spin_lock(&priv->multicast_spin);
2240 memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN);
2242 if (dev->flags & IFF_PROMISC) {
2243 filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_PROMISC);
2244 hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
2245 sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
2247 } else if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST)
2248 || (dev->flags & IFF_ALLMULTI)) {
2249 filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCASTALL);
2250 hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
2251 sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
2254 if (priv->sme_i.sme_flag & SME_MULTICAST) {
2255 mc_count = netdev_mc_count(dev);
2256 netdev_for_each_mc_addr(ha, dev) {
2257 memcpy(&set_address[i * ETH_ALEN], ha->addr,
2261 priv->sme_i.sme_flag &= ~SME_MULTICAST;
2262 hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS,
2263 (ETH_ALEN * mc_count),
2264 MIB_VALUE_TYPE_OSTRING,
2268 cpu_to_le32((uint32_t)MCAST_FILTER_MCAST);
2269 priv->sme_i.sme_flag |= SME_MULTICAST;
2270 hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
2271 sizeof(filter_type),
2272 MIB_VALUE_TYPE_BOOL,
2277 spin_unlock(&priv->multicast_spin);
2281 void hostif_sme_powermgt_set(struct ks_wlan_private *priv)
2283 unsigned long mode, wake_up, receiveDTIMs;
2286 switch (priv->reg.powermgt) {
2287 case POWMGT_ACTIVE_MODE:
2288 mode = POWER_ACTIVE;
2292 case POWMGT_SAVE1_MODE:
2293 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
2298 mode = POWER_ACTIVE;
2303 case POWMGT_SAVE2_MODE:
2304 if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
2309 mode = POWER_ACTIVE;
2315 mode = POWER_ACTIVE;
2320 hostif_power_mngmt_request(priv, mode, wake_up, receiveDTIMs);
2324 void hostif_sme_sleep_set(struct ks_wlan_private *priv)
2327 switch (priv->sleep_mode) {
2329 hostif_sleep_request(priv, priv->sleep_mode);
2332 hostif_sleep_request(priv, priv->sleep_mode);
2340 void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
2346 val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
2347 hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
2348 sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
2351 val = cpu_to_le32((uint32_t)(priv->wpa.txkey));
2352 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
2353 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2356 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1,
2357 priv->wpa.key[0].key_len,
2358 MIB_VALUE_TYPE_OSTRING,
2359 &priv->wpa.key[0].key_val[0]);
2362 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2,
2363 priv->wpa.key[1].key_len,
2364 MIB_VALUE_TYPE_OSTRING,
2365 &priv->wpa.key[1].key_val[0]);
2368 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3,
2369 priv->wpa.key[2].key_len,
2370 MIB_VALUE_TYPE_OSTRING,
2371 &priv->wpa.key[2].key_val[0]);
2374 hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4,
2375 priv->wpa.key[3].key_len,
2376 MIB_VALUE_TYPE_OSTRING,
2377 &priv->wpa.key[3].key_val[0]);
2379 case SME_SET_PMK_TSC:
2380 hostif_mib_set_request(priv, DOT11_PMK_TSC,
2381 WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
2382 &priv->wpa.key[0].rx_seq[0]);
2384 case SME_SET_GMK1_TSC:
2385 hostif_mib_set_request(priv, DOT11_GMK1_TSC,
2386 WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
2387 &priv->wpa.key[1].rx_seq[0]);
2389 case SME_SET_GMK2_TSC:
2390 hostif_mib_set_request(priv, DOT11_GMK2_TSC,
2391 WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
2392 &priv->wpa.key[2].rx_seq[0]);
2398 void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
2400 struct pmk_cache_t {
2404 u8 pmkid[IW_PMKID_LEN];
2405 } __packed list[PMK_LIST_MAX];
2406 } __packed pmkcache;
2410 DPRINTK(4, "pmklist.size=%d\n", priv->pmklist.size);
2412 list_for_each_entry(pmk, &priv->pmklist.head, list) {
2413 if (i < PMK_LIST_MAX) {
2414 memcpy(pmkcache.list[i].bssid, pmk->bssid, ETH_ALEN);
2415 memcpy(pmkcache.list[i].pmkid, pmk->pmkid,
2420 pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size));
2421 hostif_mib_set_request(priv, LOCAL_PMK,
2422 sizeof(priv->pmklist.size) + (ETH_ALEN +
2424 (priv->pmklist.size), MIB_VALUE_TYPE_OSTRING,
2430 void hostif_sme_execute(struct ks_wlan_private *priv, int event)
2434 DPRINTK(3, "event=%d\n", event);
2437 if (priv->dev_state == DEVICE_STATE_BOOT)
2438 hostif_mib_get_request(priv, DOT11_MAC_ADDRESS);
2440 case SME_MULTICAST_REQUEST:
2441 hostif_sme_multicast_set(priv);
2443 case SME_MACADDRESS_SET_REQUEST:
2444 hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN,
2445 MIB_VALUE_TYPE_OSTRING,
2446 &priv->eth_addr[0]);
2448 case SME_BSS_SCAN_REQUEST:
2449 hostif_bss_scan_request(priv, priv->reg.scan_type,
2450 priv->scan_ssid, priv->scan_ssid_len);
2452 case SME_POW_MNGMT_REQUEST:
2453 hostif_sme_powermgt_set(priv);
2455 case SME_PHY_INFO_REQUEST:
2456 hostif_phy_information_request(priv);
2458 case SME_MIC_FAILURE_REQUEST:
2459 if (priv->wpa.mic_failure.failure == 1)
2460 hostif_mic_failure_request(
2461 priv, priv->wpa.mic_failure.failure - 1, 0);
2462 else if (priv->wpa.mic_failure.failure == 2)
2463 hostif_mic_failure_request(
2464 priv, priv->wpa.mic_failure.failure - 1,
2465 priv->wpa.mic_failure.counter);
2467 DPRINTK(4, "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n",
2468 priv->wpa.mic_failure.failure);
2470 case SME_MIC_FAILURE_CONFIRM:
2471 if (priv->wpa.mic_failure.failure == 2) {
2472 if (priv->wpa.mic_failure.stop)
2473 priv->wpa.mic_failure.stop = 0;
2474 priv->wpa.mic_failure.failure = 0;
2475 hostif_start_request(priv, priv->reg.operation_mode);
2478 case SME_GET_MAC_ADDRESS:
2479 if (priv->dev_state == DEVICE_STATE_BOOT)
2480 hostif_mib_get_request(priv, DOT11_PRODUCT_VERSION);
2482 case SME_GET_PRODUCT_VERSION:
2483 if (priv->dev_state == DEVICE_STATE_BOOT)
2484 priv->dev_state = DEVICE_STATE_PREINIT;
2486 case SME_STOP_REQUEST:
2487 hostif_stop_request(priv);
2489 case SME_RTS_THRESHOLD_REQUEST:
2490 val = cpu_to_le32((uint32_t)(priv->reg.rts));
2491 hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD,
2492 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2494 case SME_FRAGMENTATION_THRESHOLD_REQUEST:
2495 val = cpu_to_le32((uint32_t)(priv->reg.fragment));
2496 hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD,
2497 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2499 case SME_WEP_INDEX_REQUEST:
2500 case SME_WEP_KEY1_REQUEST:
2501 case SME_WEP_KEY2_REQUEST:
2502 case SME_WEP_KEY3_REQUEST:
2503 case SME_WEP_KEY4_REQUEST:
2504 case SME_WEP_FLAG_REQUEST:
2505 hostif_sme_set_wep(priv, event);
2507 case SME_RSN_UCAST_REQUEST:
2508 case SME_RSN_MCAST_REQUEST:
2509 case SME_RSN_AUTH_REQUEST:
2510 case SME_RSN_ENABLED_REQUEST:
2511 case SME_RSN_MODE_REQUEST:
2512 hostif_sme_set_rsn(priv, event);
2520 case SME_SET_PMK_TSC:
2521 case SME_SET_GMK1_TSC:
2522 case SME_SET_GMK2_TSC:
2523 hostif_sme_set_key(priv, event);
2526 hostif_sme_set_pmksa(priv);
2529 case SME_WPS_ENABLE_REQUEST:
2530 hostif_mib_set_request(priv, LOCAL_WPS_ENABLE,
2531 sizeof(priv->wps.wps_enabled),
2533 &priv->wps.wps_enabled);
2535 case SME_WPS_PROBE_REQUEST:
2536 hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ,
2538 MIB_VALUE_TYPE_OSTRING, priv->wps.ie);
2541 case SME_MODE_SET_REQUEST:
2542 hostif_sme_mode_setup(priv);
2545 hostif_mib_set_request(priv, LOCAL_GAIN,
2547 MIB_VALUE_TYPE_OSTRING, &priv->gain);
2550 hostif_mib_get_request(priv, LOCAL_GAIN);
2552 case SME_GET_EEPROM_CKSUM:
2553 priv->eeprom_checksum = EEPROM_FW_NOT_SUPPORT; /* initialize */
2554 hostif_mib_get_request(priv, LOCAL_EEPROM_SUM);
2556 case SME_START_REQUEST:
2557 hostif_start_request(priv, priv->reg.operation_mode);
2559 case SME_START_CONFIRM:
2560 /* for power save */
2561 atomic_set(&priv->psstatus.snooze_guard, 0);
2562 atomic_set(&priv->psstatus.confirm_wait, 0);
2563 if (priv->dev_state == DEVICE_STATE_PREINIT)
2564 priv->dev_state = DEVICE_STATE_INIT;
2565 /* wake_up_interruptible_all(&priv->confirm_wait); */
2566 complete(&priv->confirm_wait);
2568 case SME_SLEEP_REQUEST:
2569 hostif_sme_sleep_set(priv);
2571 case SME_SET_REGION:
2572 val = cpu_to_le32((uint32_t)(priv->region));
2573 hostif_mib_set_request(priv, LOCAL_REGION,
2574 sizeof(val), MIB_VALUE_TYPE_INT, &val);
2576 case SME_MULTICAST_CONFIRM:
2577 case SME_BSS_SCAN_CONFIRM:
2578 case SME_POW_MNGMT_CONFIRM:
2579 case SME_PHY_INFO_CONFIRM:
2580 case SME_STOP_CONFIRM:
2581 case SME_RTS_THRESHOLD_CONFIRM:
2582 case SME_FRAGMENTATION_THRESHOLD_CONFIRM:
2583 case SME_WEP_INDEX_CONFIRM:
2584 case SME_WEP_KEY1_CONFIRM:
2585 case SME_WEP_KEY2_CONFIRM:
2586 case SME_WEP_KEY3_CONFIRM:
2587 case SME_WEP_KEY4_CONFIRM:
2588 case SME_WEP_FLAG_CONFIRM:
2589 case SME_RSN_UCAST_CONFIRM:
2590 case SME_RSN_MCAST_CONFIRM:
2591 case SME_RSN_AUTH_CONFIRM:
2592 case SME_RSN_ENABLED_CONFIRM:
2593 case SME_RSN_MODE_CONFIRM:
2594 case SME_MODE_SET_CONFIRM:
2603 void hostif_sme_task(unsigned long dev)
2605 struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;
2609 if (priv->dev_state >= DEVICE_STATE_BOOT) {
2610 if (cnt_smeqbody(priv) > 0
2611 && priv->dev_state >= DEVICE_STATE_BOOT) {
2612 hostif_sme_execute(priv,
2613 priv->sme_i.event_buff[priv->sme_i.
2616 if (cnt_smeqbody(priv) > 0)
2617 tasklet_schedule(&priv->sme_task);
2622 /* send to Station Management Entity module */
2623 void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
2627 /* enqueue sme event */
2628 if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) {
2629 priv->sme_i.event_buff[priv->sme_i.qtail] = event;
2631 #ifdef KS_WLAN_DEBUG
2632 if (priv->sme_i.max_event_count < cnt_smeqbody(priv))
2633 priv->sme_i.max_event_count = cnt_smeqbody(priv);
2634 #endif /* KS_WLAN_DEBUG */
2636 /* in case of buffer overflow */
2637 netdev_err(priv->net_dev, "sme queue buffer overflow\n");
2640 tasklet_schedule(&priv->sme_task);
2643 int hostif_init(struct ks_wlan_private *priv)
2649 priv->aplist.size = 0;
2650 for (i = 0; i < LOCAL_APLIST_MAX; i++)
2651 memset(&priv->aplist.ap[i], 0, sizeof(struct local_ap_t));
2652 priv->infra_status = 0;
2653 priv->current_rate = 4;
2654 priv->connect_status = DISCONNECT_STATUS;
2656 spin_lock_init(&priv->multicast_spin);
2658 spin_lock_init(&priv->dev_read_lock);
2659 init_waitqueue_head(&priv->devread_wait);
2660 priv->dev_count = 0;
2661 atomic_set(&priv->event_count, 0);
2662 atomic_set(&priv->rec_count, 0);
2664 /* for power save */
2665 atomic_set(&priv->psstatus.status, PS_NONE);
2666 atomic_set(&priv->psstatus.confirm_wait, 0);
2667 atomic_set(&priv->psstatus.snooze_guard, 0);
2668 /* init_waitqueue_head(&priv->psstatus.wakeup_wait); */
2669 init_completion(&priv->psstatus.wakeup_wait);
2670 //INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task, (void *)priv);
2671 INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task);
2674 memset(&priv->wpa, 0, sizeof(priv->wpa));
2675 priv->wpa.rsn_enabled = 0;
2676 priv->wpa.mic_failure.failure = 0;
2677 priv->wpa.mic_failure.last_failure_time = 0;
2678 priv->wpa.mic_failure.stop = 0;
2679 memset(&priv->pmklist, 0, sizeof(priv->pmklist));
2680 INIT_LIST_HEAD(&priv->pmklist.head);
2681 for (i = 0; i < PMK_LIST_MAX; i++)
2682 INIT_LIST_HEAD(&priv->pmklist.pmk[i].list);
2684 priv->sme_i.sme_status = SME_IDLE;
2685 priv->sme_i.qhead = priv->sme_i.qtail = 0;
2686 #ifdef KS_WLAN_DEBUG
2687 priv->sme_i.max_event_count = 0;
2689 spin_lock_init(&priv->sme_i.sme_spin);
2690 priv->sme_i.sme_flag = 0;
2692 tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv);
2697 void hostif_exit(struct ks_wlan_private *priv)
2699 tasklet_kill(&priv->sme_task);