diff options
Diffstat (limited to 'drivers/staging/ks7010/ks_hostif.c')
-rw-r--r-- | drivers/staging/ks7010/ks_hostif.c | 756 |
1 files changed, 279 insertions, 477 deletions
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 975dbbb3abd0..676961cf4103 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -21,18 +21,26 @@ /* Include Wireless Extension definition and check version */ #include <net/iw_handler.h> /* New driver API */ -/* macro */ -#define inc_smeqhead(priv) \ - (priv->sme_i.qhead = (priv->sme_i.qhead + 1) % SME_EVENT_BUFF_SIZE) -#define inc_smeqtail(priv) \ - (priv->sme_i.qtail = (priv->sme_i.qtail + 1) % SME_EVENT_BUFF_SIZE) -#define cnt_smeqbody(priv) \ - (((priv->sme_i.qtail + SME_EVENT_BUFF_SIZE) - (priv->sme_i.qhead)) % SME_EVENT_BUFF_SIZE) +static inline void inc_smeqhead(struct ks_wlan_private *priv) +{ + priv->sme_i.qhead = (priv->sme_i.qhead + 1) % SME_EVENT_BUFF_SIZE; +} + +static inline void inc_smeqtail(struct ks_wlan_private *priv) +{ + priv->sme_i.qtail = (priv->sme_i.qtail + 1) % SME_EVENT_BUFF_SIZE; +} + +static inline unsigned int cnt_smeqbody(struct ks_wlan_private *priv) +{ + unsigned int sme_cnt = priv->sme_i.qtail - priv->sme_i.qhead; + + return (sme_cnt + SME_EVENT_BUFF_SIZE) % SME_EVENT_BUFF_SIZE; +} #define KS_WLAN_MEM_FLAG (GFP_ATOMIC) -static -inline u8 get_BYTE(struct ks_wlan_private *priv) +static inline u8 get_byte(struct ks_wlan_private *priv) { u8 data; @@ -42,25 +50,23 @@ inline u8 get_BYTE(struct ks_wlan_private *priv) return data; } -static -inline u16 get_WORD(struct ks_wlan_private *priv) +static inline u16 get_word(struct ks_wlan_private *priv) { u16 data; - data = (get_BYTE(priv) & 0xff); - data |= ((get_BYTE(priv) << 8) & 0xff00); + data = (get_byte(priv) & 0xff); + data |= ((get_byte(priv) << 8) & 0xff00); return data; } -static -inline u32 get_DWORD(struct ks_wlan_private *priv) +static inline u32 get_dword(struct ks_wlan_private *priv) { u32 data; - data = (get_BYTE(priv) & 0xff); - data |= ((get_BYTE(priv) << 8) & 0x0000ff00); - data |= ((get_BYTE(priv) << 16) & 0x00ff0000); - data |= ((get_BYTE(priv) << 24) & 0xff000000); + data = (get_byte(priv) & 0xff); + data |= ((get_byte(priv) << 8) & 0x0000ff00); + data |= ((get_byte(priv) << 16) & 0x00ff0000); + data |= ((get_byte(priv) << 24) & 0xff000000); return data; } @@ -79,26 +85,20 @@ static void ks_wlan_hw_wakeup_task(struct work_struct *work) &priv->psstatus.wakeup_wait, msecs_to_jiffies(20)); if (time_left <= 0) { - DPRINTK(1, "wake up timeout or interrupted !!!\n"); + netdev_dbg(priv->net_dev, "wake up timeout or interrupted !!!\n"); schedule_work(&priv->wakeup_work); return; } - } else { - DPRINTK(1, "ps_status=%d\n", ps_status); } /* power save */ - if (atomic_read(&priv->sme_task.count) > 0) { - DPRINTK(4, "sme task enable.\n"); + if (atomic_read(&priv->sme_task.count) > 0) tasklet_enable(&priv->sme_task); - } } static int ks_wlan_do_power_save(struct ks_wlan_private *priv) { - DPRINTK(4, "psstatus.status=%d\n", atomic_read(&priv->psstatus.status)); - if (is_connect_status(priv->connect_status)) hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); else @@ -113,7 +113,6 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) union iwreq_data wrqu; struct net_device *netdev = priv->net_dev; - DPRINTK(3, "\n"); ap = &priv->current_ap; if (is_disconnect_status(priv->connect_status)) { @@ -186,34 +185,43 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) if (is_connect_status(priv->connect_status)) { memcpy(wrqu.ap_addr.sa_data, priv->current_ap.bssid, ETH_ALEN); - DPRINTK(3, - "IWEVENT: connect bssid=%pM\n", wrqu.ap_addr.sa_data); + netdev_dbg(priv->net_dev, + "IWEVENT: connect bssid=%pM\n", wrqu.ap_addr.sa_data); wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL); } - DPRINTK(4, "\n Link AP\n"); - DPRINTK(4, " bssid=%02X:%02X:%02X:%02X:%02X:%02X\n" + netdev_dbg(priv->net_dev, " Link AP\n"); + netdev_dbg(priv->net_dev, " bssid=%02X:%02X:%02X:%02X:%02X:%02X\n" " essid=%s\n" " rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n" " channel=%d\n" " 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); - DPRINTK(4, "\n Link AP\n rsn.mode=%d\n rsn.size=%d\n", - ap_info->rsn_mode, ap_info->rsn.size); - DPRINTK(4, "\n ext_rate_set_size=%d\n rate_set_size=%d\n", - ap_info->ext_rate_set.size, ap_info->rate_set.size); + 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); + netdev_dbg(priv->net_dev, " Link AP\n rsn.mode=%d\n rsn.size=%d\n", + ap_info->rsn_mode, ap_info->rsn.size); + netdev_dbg(priv->net_dev, " ext_rate_set_size=%d\n rate_set_size=%d\n", + ap_info->ext_rate_set.size, ap_info->rate_set.size); return 0; } +static u8 read_ie(unsigned char *bp, u8 max, u8 *body) +{ + u8 size = (*(bp + 1) <= max) ? *(bp + 1) : max; + + memcpy(body, bp + 2, size); + return size; +} + + static int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, struct local_ap_t *ap) @@ -221,7 +229,6 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, unsigned char *bp; int bsize, offset; - DPRINTK(3, "\n"); memset(ap, 0, sizeof(struct local_ap_t)); /* bssid */ @@ -242,28 +249,19 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, offset = 0; while (bsize > offset) { - /* DPRINTK(4, "Element ID=%d\n",*bp); */ - switch (*bp) { - case 0: /* ssid */ - if (*(bp + 1) <= SSID_MAX_SIZE) { - ap->ssid.size = *(bp + 1); - } else { - DPRINTK(1, "size over :: ssid size=%d\n", - *(bp + 1)); - ap->ssid.size = SSID_MAX_SIZE; - } - memcpy(ap->ssid.body, bp + 2, ap->ssid.size); + switch (*bp) { /* Information Element ID */ + case WLAN_EID_SSID: + ap->ssid.size = read_ie(bp, IEEE80211_MAX_SSID_LEN, + ap->ssid.body); break; - case 1: /* rate */ - case 50: /* ext rate */ + case WLAN_EID_SUPP_RATES: + case WLAN_EID_EXT_SUPP_RATES: if ((*(bp + 1) + ap->rate_set.size) <= RATE_SET_MAX_SIZE) { memcpy(&ap->rate_set.body[ap->rate_set.size], bp + 2, *(bp + 1)); ap->rate_set.size += *(bp + 1); } else { - DPRINTK(1, "size over :: rate size=%d\n", - (*(bp + 1) + ap->rate_set.size)); memcpy(&ap->rate_set.body[ap->rate_set.size], bp + 2, RATE_SET_MAX_SIZE - ap->rate_set.size); @@ -271,47 +269,34 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, (RATE_SET_MAX_SIZE - ap->rate_set.size); } break; - case 3: /* DS parameter */ + case WLAN_EID_DS_PARAMS: break; - case 48: /* RSN(WPA2) */ + case WLAN_EID_RSN: ap->rsn_ie.id = *bp; - if (*(bp + 1) <= RSN_IE_BODY_MAX) { - ap->rsn_ie.size = *(bp + 1); - } else { - DPRINTK(1, "size over :: rsn size=%d\n", - *(bp + 1)); - ap->rsn_ie.size = RSN_IE_BODY_MAX; - } - memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size); + ap->rsn_ie.size = read_ie(bp, RSN_IE_BODY_MAX, + ap->rsn_ie.body); break; - case 221: /* WPA */ - if (memcmp(bp + 2, "\x00\x50\xf2\x01", 4) == 0) { /* WPA OUI check */ + case WLAN_EID_VENDOR_SPECIFIC: /* WPA */ + /* WPA OUI check */ + if (memcmp(bp + 2, CIPHER_ID_WPA_WEP40, 4) == 0) { ap->wpa_ie.id = *bp; - if (*(bp + 1) <= RSN_IE_BODY_MAX) { - ap->wpa_ie.size = *(bp + 1); - } else { - DPRINTK(1, - "size over :: wpa size=%d\n", - *(bp + 1)); - ap->wpa_ie.size = RSN_IE_BODY_MAX; - } - memcpy(ap->wpa_ie.body, bp + 2, - ap->wpa_ie.size); + ap->wpa_ie.size = read_ie(bp, RSN_IE_BODY_MAX, + ap->wpa_ie.body); } break; - case 2: /* FH parameter */ - case 4: /* CF parameter */ - case 5: /* TIM */ - case 6: /* IBSS parameter */ - case 7: /* Country */ - case 42: /* ERP information */ - case 47: /* Reserve ID 47 Broadcom AP */ + case WLAN_EID_FH_PARAMS: + case WLAN_EID_CF_PARAMS: + case WLAN_EID_TIM: + case WLAN_EID_IBSS_PARAMS: + case WLAN_EID_COUNTRY: + case WLAN_EID_ERP_INFO: break; default: - DPRINTK(4, "unknown Element ID=%d\n", *bp); + netdev_err(priv->net_dev, "unknown Element ID=%d\n", *bp); break; } + offset += 2; /* id & size field */ offset += *(bp + 1); /* +size offset */ bp += (*(bp + 1) + 2); /* pointer update */ @@ -339,7 +324,7 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv, eth_proto = ntohs(eth_hdr->h_proto); if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) { - DPRINTK(1, "invalid data format\n"); + netdev_err(priv->net_dev, "invalid data format\n"); priv->nstats.rx_errors++; return -EINVAL; } @@ -350,20 +335,20 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv, (auth_type == TYPE_GMK2 && priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP)) && key->key_len) { - DPRINTK(4, "TKIP: protocol=%04X: size=%u\n", - eth_proto, priv->rx_size); + netdev_dbg(priv->net_dev, "TKIP: protocol=%04X: size=%u\n", + eth_proto, priv->rx_size); /* MIC save */ memcpy(&recv_mic[0], (priv->rxp) + ((priv->rx_size) - 8), 8); priv->rx_size = priv->rx_size - 8; if (auth_type > 0 && auth_type < 4) { /* auth_type check */ - MichaelMICFunction(&michael_mic, - (uint8_t *)key->rx_mic_key, - (uint8_t *)priv->rxp, - (int)priv->rx_size, - (uint8_t)0, /* priority */ - (uint8_t *)michael_mic.Result); + michael_mic_function(&michael_mic, + (uint8_t *)key->rx_mic_key, + (uint8_t *)priv->rxp, + (int)priv->rx_size, + (uint8_t)0, /* priority */ + (uint8_t *)michael_mic.result); } - if (memcmp(michael_mic.Result, recv_mic, 8) != 0) { + if (memcmp(michael_mic.result, recv_mic, 8) != 0) { now = jiffies; mic_failure = &priv->wpa.mic_failure; /* MIC FAILURE */ @@ -371,7 +356,7 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv, (now - mic_failure->last_failure_time) / HZ >= 60) { mic_failure->failure = 0; } - DPRINTK(4, "MIC FAILURE\n"); + netdev_err(priv->net_dev, "MIC FAILURE\n"); if (mic_failure->failure == 0) { mic_failure->failure = 1; mic_failure->counter = 0; @@ -392,7 +377,6 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv, eth_hdr->h_source); memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = strlen(buf); - DPRINTK(4, "IWEVENT:MICHAELMICFAILURE\n"); wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); return -EINVAL; @@ -414,30 +398,26 @@ void hostif_data_indication(struct ks_wlan_private *priv) size_t size; int ret; - DPRINTK(3, "\n"); - /* min length check */ if (priv->rx_size <= ETH_HLEN) { - DPRINTK(3, "rx_size = %d\n", priv->rx_size); priv->nstats.rx_errors++; return; } - auth_type = get_WORD(priv); /* AuthType */ - get_WORD(priv); /* Reserve Area */ + auth_type = get_word(priv); /* AuthType */ + get_word(priv); /* Reserve Area */ eth_hdr = (struct ether_hdr *)(priv->rxp); eth_proto = ntohs(eth_hdr->h_proto); - DPRINTK(3, "ether protocol = %04X\n", eth_proto); /* source address check */ if (memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN) == 0) { - DPRINTK(1, "invalid : source is own mac address !!\n"); - DPRINTK(1, - "eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n", - eth_hdr->h_source[0], eth_hdr->h_source[1], - eth_hdr->h_source[2], eth_hdr->h_source[3], - eth_hdr->h_source[4], eth_hdr->h_source[5]); + netdev_err(priv->net_dev, "invalid : source is own mac address !!\n"); + netdev_err(priv->net_dev, + "eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n", + eth_hdr->h_source[0], eth_hdr->h_source[1], + eth_hdr->h_source[2], eth_hdr->h_source[3], + eth_hdr->h_source[4], eth_hdr->h_source[5]); priv->nstats.rx_errors++; return; } @@ -463,7 +443,8 @@ void hostif_data_indication(struct ks_wlan_private *priv) priv->nstats.rx_dropped++; return; } - DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size); + netdev_dbg(priv->net_dev, "SNAP, rx_ind_size = %d\n", + rx_ind_size); size = ETH_ALEN * 2; skb_put_data(skb, priv->rxp, size); @@ -482,20 +463,24 @@ void hostif_data_indication(struct ks_wlan_private *priv) priv->nstats.rx_dropped++; return; } - DPRINTK(3, "NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size); + netdev_dbg(priv->net_dev, "NETBEUI/NetBIOS rx_ind_size=%d\n", + rx_ind_size); - skb_put_data(skb, priv->rxp, 12); /* 8802/FDDI MAC copy */ + /* 8802/FDDI MAC copy */ + skb_put_data(skb, priv->rxp, 12); - temp[0] = (((rx_ind_size - 12) >> 8) & 0xff); /* NETBEUI size add */ + /* NETBEUI size add */ + temp[0] = (((rx_ind_size - 12) >> 8) & 0xff); temp[1] = ((rx_ind_size - 12) & 0xff); skb_put_data(skb, temp, 2); - skb_put_data(skb, priv->rxp + 12, rx_ind_size - 14); /* copy after Type */ + /* copy after Type */ + skb_put_data(skb, priv->rxp + 12, rx_ind_size - 14); aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14); break; default: /* other rx data */ - DPRINTK(2, "invalid data format\n"); + netdev_err(priv->net_dev, "invalid data format\n"); priv->nstats.rx_errors++; return; } @@ -521,27 +506,24 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv) u16 mib_val_size; u16 mib_val_type; - DPRINTK(3, "\n"); - - mib_status = get_DWORD(priv); /* MIB status */ - mib_attribute = get_DWORD(priv); /* MIB atttibute */ - mib_val_size = get_WORD(priv); /* MIB value size */ - mib_val_type = get_WORD(priv); /* MIB value type */ + mib_status = get_dword(priv); /* MIB status */ + mib_attribute = get_dword(priv); /* MIB atttibute */ + mib_val_size = get_word(priv); /* MIB value size */ + mib_val_type = get_word(priv); /* MIB value type */ if (mib_status) { /* in case of error */ - DPRINTK(1, "attribute=%08X, status=%08X\n", mib_attribute, - mib_status); + netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n", + mib_attribute, mib_status); return; } switch (mib_attribute) { case DOT11_MAC_ADDRESS: /* MAC address */ - DPRINTK(3, " mib_attribute=DOT11_MAC_ADDRESS\n"); hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS); memcpy(priv->eth_addr, priv->rxp, ETH_ALEN); - priv->mac_address_valid = 1; + priv->mac_address_valid = true; dev->dev_addr[0] = priv->eth_addr[0]; dev->dev_addr[1] = priv->eth_addr[1]; dev->dev_addr[2] = priv->eth_addr[2]; @@ -554,7 +536,6 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv) break; case DOT11_PRODUCT_VERSION: /* firmware version */ - DPRINTK(3, " mib_attribute=DOT11_PRODUCT_VERSION\n"); priv->version_size = priv->rx_size; memcpy(priv->firmware_version, priv->rxp, priv->rx_size); priv->firmware_version[priv->rx_size] = '\0'; @@ -566,14 +547,12 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv) break; case LOCAL_GAIN: memcpy(&priv->gain, priv->rxp, sizeof(priv->gain)); - DPRINTK(3, "tx_mode=%d, rx_mode=%d, tx_gain=%d, rx_gain=%d\n", - priv->gain.tx_mode, priv->gain.rx_mode, - priv->gain.tx_gain, priv->gain.rx_gain); + netdev_dbg(priv->net_dev, "tx_mode=%d, rx_mode=%d, tx_gain=%d, rx_gain=%d\n", + priv->gain.tx_mode, priv->gain.rx_mode, + priv->gain.tx_gain, priv->gain.rx_gain); break; case LOCAL_EEPROM_SUM: memcpy(&priv->eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum)); - DPRINTK(1, "eeprom_sum.type=%x, eeprom_sum.result=%x\n", - priv->eeprom_sum.type, priv->eeprom_sum.result); if (priv->eeprom_sum.type == 0) { priv->eeprom_checksum = EEPROM_CHECKSUM_NONE; } else if (priv->eeprom_sum.type == 1) { @@ -588,7 +567,8 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv) } break; default: - DPRINTK(1, "mib_attribute=%08x\n", (unsigned int)mib_attribute); + netdev_err(priv->net_dev, "mib_attribute=%08x\n", + (unsigned int)mib_attribute); break; } } @@ -599,15 +579,13 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) u32 mib_status; /* +04 MIB Status */ u32 mib_attribute; /* +08 MIB attribute */ - DPRINTK(3, "\n"); - - mib_status = get_DWORD(priv); /* MIB Status */ - mib_attribute = get_DWORD(priv); /* MIB attribute */ + mib_status = get_dword(priv); /* MIB Status */ + mib_attribute = get_dword(priv); /* MIB attribute */ if (mib_status) { /* in case of error */ - DPRINTK(1, "error :: attribute=%08X, status=%08X\n", - mib_attribute, mib_status); + netdev_err(priv->net_dev, "error :: attribute=%08X, status=%08X\n", + mib_attribute, mib_status); } switch (mib_attribute) { @@ -622,32 +600,24 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) hostif_sme_enqueue(priv, SME_WEP_INDEX_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_VALUE1: - DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE1:mib_status=%d\n", - (int)mib_status); if (priv->wpa.rsn_enabled) hostif_sme_enqueue(priv, SME_SET_PMK_TSC); else hostif_sme_enqueue(priv, SME_WEP_KEY1_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_VALUE2: - DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE2:mib_status=%d\n", - (int)mib_status); if (priv->wpa.rsn_enabled) hostif_sme_enqueue(priv, SME_SET_GMK1_TSC); else hostif_sme_enqueue(priv, SME_WEP_KEY2_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_VALUE3: - DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE3:mib_status=%d\n", - (int)mib_status); if (priv->wpa.rsn_enabled) hostif_sme_enqueue(priv, SME_SET_GMK2_TSC); else hostif_sme_enqueue(priv, SME_WEP_KEY3_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_VALUE4: - DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE4:mib_status=%d\n", - (int)mib_status); if (!priv->wpa.rsn_enabled) hostif_sme_enqueue(priv, SME_WEP_KEY4_CONFIRM); break; @@ -656,8 +626,6 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) hostif_sme_enqueue(priv, SME_WEP_FLAG_CONFIRM); break; case DOT11_RSN_ENABLED: - DPRINTK(2, "DOT11_RSN_ENABLED:mib_status=%d\n", - (int)mib_status); hostif_sme_enqueue(priv, SME_RSN_ENABLED_CONFIRM); break; case LOCAL_RSN_MODE: @@ -670,53 +638,38 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) hostif_sme_enqueue(priv, SME_MULTICAST_CONFIRM); break; case LOCAL_CURRENTADDRESS: - priv->mac_address_valid = 1; + priv->mac_address_valid = true; break; case DOT11_RSN_CONFIG_MULTICAST_CIPHER: - DPRINTK(2, "DOT11_RSN_CONFIG_MULTICAST_CIPHER:mib_status=%d\n", - (int)mib_status); hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM); break; case DOT11_RSN_CONFIG_UNICAST_CIPHER: - DPRINTK(2, "DOT11_RSN_CONFIG_UNICAST_CIPHER:mib_status=%d\n", - (int)mib_status); hostif_sme_enqueue(priv, SME_RSN_UCAST_CONFIRM); break; case DOT11_RSN_CONFIG_AUTH_SUITE: - DPRINTK(2, "DOT11_RSN_CONFIG_AUTH_SUITE:mib_status=%d\n", - (int)mib_status); hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM); break; case DOT11_PMK_TSC: - DPRINTK(2, "DOT11_PMK_TSC:mib_status=%d\n", (int)mib_status); break; case DOT11_GMK1_TSC: - DPRINTK(2, "DOT11_GMK1_TSC:mib_status=%d\n", (int)mib_status); if (atomic_read(&priv->psstatus.snooze_guard)) atomic_set(&priv->psstatus.snooze_guard, 0); break; case DOT11_GMK2_TSC: - DPRINTK(2, "DOT11_GMK2_TSC:mib_status=%d\n", (int)mib_status); if (atomic_read(&priv->psstatus.snooze_guard)) atomic_set(&priv->psstatus.snooze_guard, 0); break; case LOCAL_PMK: - DPRINTK(2, "LOCAL_PMK:mib_status=%d\n", (int)mib_status); break; case LOCAL_GAIN: - DPRINTK(2, "LOCAL_GAIN:mib_status=%d\n", (int)mib_status); break; #ifdef WPS case LOCAL_WPS_ENABLE: - DPRINTK(2, "LOCAL_WPS_ENABLE:mib_status=%d\n", (int)mib_status); break; case LOCAL_WPS_PROBE_REQ: - DPRINTK(2, "LOCAL_WPS_PROBE_REQ:mib_status=%d\n", - (int)mib_status); break; #endif /* WPS */ case LOCAL_REGION: - DPRINTK(2, "LOCAL_REGION:mib_status=%d\n", (int)mib_status); default: break; } @@ -725,8 +678,6 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) static void hostif_power_mgmt_confirm(struct ks_wlan_private *priv) { - DPRINTK(3, "\n"); - if (priv->reg.power_mgmt > POWER_MGMT_ACTIVE && priv->reg.operation_mode == MODE_INFRASTRUCTURE) { atomic_set(&priv->psstatus.confirm_wait, 0); @@ -740,8 +691,6 @@ void hostif_power_mgmt_confirm(struct ks_wlan_private *priv) static void hostif_sleep_confirm(struct ks_wlan_private *priv) { - DPRINTK(3, "\n"); - atomic_set(&priv->sleepstatus.doze_request, 1); queue_delayed_work(priv->wq, &priv->rw_dwork, 1); } @@ -757,11 +706,10 @@ void hostif_start_confirm(struct ks_wlan_private *priv) wrqu.ap_addr.sa_family = ARPHRD_ETHER; if (is_connect_status(priv->connect_status)) { eth_zero_addr(wrqu.ap_addr.sa_data); - DPRINTK(3, "IWEVENT: disconnect\n"); wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); } #endif - DPRINTK(3, " scan_ind_count=%d\n", priv->scan_ind_count); + netdev_dbg(priv->net_dev, " scan_ind_count=%d\n", priv->scan_ind_count); hostif_sme_enqueue(priv, SME_START_CONFIRM); } @@ -774,27 +722,23 @@ void hostif_connect_indication(struct ks_wlan_private *priv) struct net_device *netdev = priv->net_dev; union iwreq_data wrqu0; - connect_code = get_WORD(priv); + connect_code = get_word(priv); switch (connect_code) { case RESULT_CONNECT: /* connect */ - DPRINTK(3, "connect :: scan_ind_count=%d\n", - priv->scan_ind_count); if (!(priv->connect_status & FORCE_DISCONNECT)) netif_carrier_on(netdev); tmp = FORCE_DISCONNECT & priv->connect_status; priv->connect_status = tmp + CONNECT_STATUS; break; - case RESULT_DISCONNECT: /* disconnect */ - DPRINTK(3, "disconnect :: scan_ind_count=%d\n", - priv->scan_ind_count); + case RESULT_DISCONNECT: /* disconnect */ netif_carrier_off(netdev); tmp = FORCE_DISCONNECT & priv->connect_status; priv->connect_status = tmp + DISCONNECT_STATUS; break; default: - DPRINTK(1, "unknown connect_code=%d :: scan_ind_count=%d\n", - connect_code, priv->scan_ind_count); + netdev_dbg(priv->net_dev, "unknown connect_code=%d :: scan_ind_count=%d\n", + connect_code, priv->scan_ind_count); netif_carrier_off(netdev); tmp = FORCE_DISCONNECT & priv->connect_status; priv->connect_status = tmp + DISCONNECT_STATUS; @@ -816,9 +760,8 @@ void hostif_connect_indication(struct ks_wlan_private *priv) if (is_disconnect_status(priv->connect_status) && is_connect_status(old_status)) { eth_zero_addr(wrqu0.ap_addr.sa_data); - DPRINTK(3, "IWEVENT: disconnect\n"); - DPRINTK(3, "disconnect :: scan_ind_count=%d\n", - priv->scan_ind_count); + netdev_dbg(priv->net_dev, "disconnect :: scan_ind_count=%d\n", + priv->scan_ind_count); wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL); } priv->scan_ind_count = 0; @@ -830,16 +773,18 @@ void hostif_scan_indication(struct ks_wlan_private *priv) int i; struct ap_info_t *ap_info; - DPRINTK(3, "scan_ind_count = %d\n", priv->scan_ind_count); + netdev_dbg(priv->net_dev, "scan_ind_count = %d\n", priv->scan_ind_count); ap_info = (struct ap_info_t *)(priv->rxp); if (priv->scan_ind_count) { - for (i = 0; i < priv->aplist.size; i++) { /* bssid check */ - if (memcmp(ap_info->bssid, - priv->aplist.ap[i].bssid, ETH_ALEN) != 0) + /* bssid check */ + for (i = 0; i < priv->aplist.size; i++) { + u8 *bssid = priv->aplist.ap[i].bssid; + + if (ether_addr_equal(ap_info->bssid, bssid)) continue; - if (ap_info->frame_type == FRAME_TYPE_PROBE_RESP) + if (ap_info->frame_type == IEEE80211_STYPE_PROBE_RESP) get_ap_information(priv, ap_info, &priv->aplist.ap[i]); return; @@ -847,14 +792,14 @@ void hostif_scan_indication(struct ks_wlan_private *priv) } priv->scan_ind_count++; if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) { - DPRINTK(4, " scan_ind_count=%d :: aplist.size=%d\n", + netdev_dbg(priv->net_dev, " scan_ind_count=%d :: aplist.size=%d\n", priv->scan_ind_count, priv->aplist.size); get_ap_information(priv, (struct ap_info_t *)(priv->rxp), &(priv->aplist.ap[priv->scan_ind_count - 1])); priv->aplist.size = priv->scan_ind_count; } else { - DPRINTK(4, " count over :: scan_ind_count=%d\n", - priv->scan_ind_count); + netdev_dbg(priv->net_dev, " count over :: scan_ind_count=%d\n", + priv->scan_ind_count); } } @@ -866,7 +811,6 @@ void hostif_stop_confirm(struct ks_wlan_private *priv) struct net_device *netdev = priv->net_dev; union iwreq_data wrqu0; - DPRINTK(3, "\n"); if (priv->dev_state == DEVICE_STATE_SLEEP) priv->dev_state = DEVICE_STATE_READY; @@ -883,10 +827,7 @@ void hostif_stop_confirm(struct ks_wlan_private *priv) if (is_disconnect_status(priv->connect_status) && is_connect_status(old_status)) { eth_zero_addr(wrqu0.ap_addr.sa_data); - DPRINTK(3, "IWEVENT: disconnect\n"); netdev_info(netdev, "IWEVENT: disconnect\n"); - DPRINTK(3, "disconnect :: scan_ind_count=%d\n", - priv->scan_ind_count); wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL); } priv->scan_ind_count = 0; @@ -898,7 +839,6 @@ void hostif_stop_confirm(struct ks_wlan_private *priv) static void hostif_ps_adhoc_set_confirm(struct ks_wlan_private *priv) { - DPRINTK(3, "\n"); priv->infra_status = 0; /* infrastructure mode cancel */ hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); } @@ -908,9 +848,7 @@ void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv) { u16 result_code; - DPRINTK(3, "\n"); - result_code = get_WORD(priv); - DPRINTK(3, "result code = %d\n", result_code); + result_code = get_word(priv); priv->infra_status = 1; /* infrastructure mode set */ hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); } @@ -918,7 +856,6 @@ void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv) static void hostif_adhoc_set_confirm(struct ks_wlan_private *priv) { - DPRINTK(3, "\n"); priv->infra_status = 1; /* infrastructure mode set */ hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); } @@ -937,7 +874,6 @@ void hostif_associate_indication(struct ks_wlan_private *priv) static const char associnfo_leader0[] = "ASSOCINFO(ReqIEs="; static const char associnfo_leader1[] = " RespIEs="; - DPRINTK(3, "\n"); assoc_req = (struct association_request_t *)(priv->rxp); assoc_resp = (struct association_response_t *)(assoc_req + 1); pb = (unsigned char *)(assoc_resp + 1); @@ -963,7 +899,6 @@ void hostif_associate_indication(struct ks_wlan_private *priv) pbuf += sprintf(pbuf, ")"); wrqu.data.length += 1; - DPRINTK(3, "IWEVENT:ASSOCINFO\n"); wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); } @@ -974,16 +909,15 @@ void hostif_bss_scan_confirm(struct ks_wlan_private *priv) struct net_device *dev = priv->net_dev; union iwreq_data wrqu; - result_code = get_DWORD(priv); - DPRINTK(2, "result=%d :: scan_ind_count=%d\n", result_code, - priv->scan_ind_count); + result_code = get_dword(priv); + netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n", result_code, + priv->scan_ind_count); priv->sme_i.sme_flag &= ~SME_AP_SCAN; hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM); wrqu.data.length = 0; wrqu.data.flags = 0; - DPRINTK(3, "IWEVENT: SCAN CONFIRM\n"); wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); priv->scan_ind_count = 0; } @@ -997,32 +931,32 @@ void hostif_phy_information_confirm(struct ks_wlan_private *priv) unsigned int transmitted_frame_count, received_fragment_count; unsigned int failed_count, fcs_error_count; - DPRINTK(3, "\n"); - rssi = get_BYTE(priv); - signal = get_BYTE(priv); - noise = get_BYTE(priv); - link_speed = get_BYTE(priv); - transmitted_frame_count = get_DWORD(priv); - received_fragment_count = get_DWORD(priv); - failed_count = get_DWORD(priv); - fcs_error_count = get_DWORD(priv); - - DPRINTK(4, "phyinfo confirm rssi=%d signal=%d\n", rssi, signal); + rssi = get_byte(priv); + signal = get_byte(priv); + noise = get_byte(priv); + link_speed = get_byte(priv); + transmitted_frame_count = get_dword(priv); + received_fragment_count = get_dword(priv); + failed_count = get_dword(priv); + fcs_error_count = get_dword(priv); + + netdev_dbg(priv->net_dev, "phyinfo confirm rssi=%d signal=%d\n", + rssi, signal); priv->current_rate = (link_speed & RATE_MASK); wstats->qual.qual = signal; wstats->qual.level = 256 - rssi; wstats->qual.noise = 0; /* invalid noise value */ wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; - DPRINTK(3, "\n rssi=%u\n" + netdev_dbg(priv->net_dev, "\n rssi=%u\n" " signal=%u\n" " link_speed=%ux500Kbps\n" " transmitted_frame_count=%u\n" " received_fragment_count=%u\n" " failed_count=%u\n" " fcs_error_count=%u\n", - rssi, signal, link_speed, transmitted_frame_count, - received_fragment_count, failed_count, fcs_error_count); + rssi, signal, link_speed, transmitted_frame_count, + received_fragment_count, failed_count, fcs_error_count); /* wake_up_interruptible_all(&priv->confirm_wait); */ complete(&priv->confirm_wait); } @@ -1030,7 +964,7 @@ void hostif_phy_information_confirm(struct ks_wlan_private *priv) static void hostif_mic_failure_confirm(struct ks_wlan_private *priv) { - DPRINTK(3, "mic_failure=%u\n", priv->wpa.mic_failure.failure); + netdev_dbg(priv->net_dev, "mic_failure=%u\n", priv->wpa.mic_failure.failure); hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM); } @@ -1039,8 +973,7 @@ void hostif_event_check(struct ks_wlan_private *priv) { unsigned short event; - DPRINTK(4, "\n"); - event = get_WORD(priv); /* get event */ + event = get_word(priv); /* get event */ switch (event) { case HIF_DATA_IND: hostif_data_indication(priv); @@ -1095,7 +1028,6 @@ void hostif_event_check(struct ks_wlan_private *priv) break; case HIF_AP_SET_CONF: default: - //DPRINTK(1, "undefined event[%04X]\n", event); netdev_err(priv->net_dev, "undefined event[%04X]\n", event); /* wake_up_all(&priv->confirm_wait); */ complete(&priv->confirm_wait); @@ -1143,7 +1075,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) skb_len = skb->len; if (skb_len > ETH_FRAME_LEN) { - DPRINTK(1, "bad length skb_len=%d\n", skb_len); + netdev_err(priv->net_dev, "bad length skb_len=%d\n", skb_len); ret = -EOVERFLOW; goto err_kfree_skb; } @@ -1151,7 +1083,6 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) if (is_disconnect_status(priv->connect_status) || (priv->connect_status & FORCE_DISCONNECT) || priv->wpa.mic_failure.stop) { - DPRINTK(3, " DISCONNECT\n"); if (netif_queue_stopped(priv->net_dev)) netif_wake_queue(priv->net_dev); if (skb) @@ -1160,8 +1091,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) return 0; } - /* for PowerSave */ - if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { /* power save wakeup */ + /* power save wakeup */ + if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { if (!netif_queue_stopped(priv->net_dev)) netif_stop_queue(priv->net_dev); } @@ -1181,8 +1112,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) /* skb check */ eth = (struct ethhdr *)skb->data; if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN) != 0) { - DPRINTK(1, "invalid mac address !!\n"); - DPRINTK(1, "ethernet->h_source=%pM\n", eth->h_source); + netdev_err(priv->net_dev, "invalid mac address !!\n"); + netdev_err(priv->net_dev, "ethernet->h_source=%pM\n", eth->h_source); ret = -ENXIO; goto err_kfree; } @@ -1197,7 +1128,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) /* EtherType/Length check */ if (*(buffer + 1) + (*buffer << 8) > 1500) { /* ProtocolEAP = *(buffer+1) + (*buffer << 8); */ - /* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */ + /* netdev_dbg(priv->net_dev, "Send [SNAP]Type %x\n",ProtocolEAP); */ /* SAP/CTL/OUI(6 byte) add */ *p++ = 0xAA; /* DSAP */ *p++ = 0xAA; /* SSAP */ @@ -1207,7 +1138,6 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) *p++ = 0x00; /* OUI ("000000") */ skb_len += 6; } else { - DPRINTK(4, "DIX\n"); /* Length(2 byte) delete */ buffer += 2; length -= 2; @@ -1224,7 +1154,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) eth_proto = ntohs(eth_hdr->h_proto); /* for MIC FAILURE REPORT check */ - if (eth_proto == ETHER_PROTOCOL_TYPE_EAP && + if (eth_proto == ETH_P_PAE && priv->wpa.mic_failure.failure > 0) { aa1x_hdr = (struct ieee802_1x_hdr *)(eth_hdr + 1); if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY) { @@ -1234,20 +1164,21 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) } if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len) { - if (eth_proto == ETHER_PROTOCOL_TYPE_EAP && + /* no encryption */ + if (eth_proto == ETH_P_PAE && priv->wpa.key[1].key_len == 0 && priv->wpa.key[2].key_len == 0 && priv->wpa.key[3].key_len == 0) { - pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); /* no encryption */ + pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); } else { if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) { - MichaelMICFunction(&michael_mic, - (uint8_t *)priv->wpa.key[0].tx_mic_key, - (uint8_t *)&pp->data[0], - (int)skb_len, - (uint8_t)0, /* priority */ - (uint8_t *)michael_mic.Result); - memcpy(p, michael_mic.Result, 8); + michael_mic_function(&michael_mic, + (uint8_t *)priv->wpa.key[0].tx_mic_key, + (uint8_t *)&pp->data[0], + (int)skb_len, + (uint8_t)0, /* priority */ + (uint8_t *)michael_mic.result); + memcpy(p, michael_mic.result, 8); length += 8; skb_len += 8; p += 8; @@ -1261,7 +1192,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) } } } else { - if (eth_proto == ETHER_PROTOCOL_TYPE_EAP) + if (eth_proto == ETH_P_PAE) pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); else pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); @@ -1278,11 +1209,11 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) send_packet_complete, skb); /* MIC FAILURE REPORT check */ - if (eth_proto == ETHER_PROTOCOL_TYPE_EAP && + if (eth_proto == ETH_P_PAE && priv->wpa.mic_failure.failure > 0) { if (keyinfo & WPA_KEY_INFO_ERROR && keyinfo & WPA_KEY_INFO_REQUEST) { - DPRINTK(3, " MIC ERROR Report SET : %04X\n", keyinfo); + netdev_err(priv->net_dev, " MIC ERROR Report SET : %04X\n", keyinfo); hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST); } if (priv->wpa.mic_failure.failure == 2) @@ -1299,11 +1230,11 @@ err_kfree_skb: return ret; } -#define ps_confirm_wait_inc(priv) \ - do { \ - if (atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET) \ - atomic_inc(&priv->psstatus.confirm_wait); \ - } while (0) +static inline void ps_confirm_wait_inc(struct ks_wlan_private *priv) +{ + if (atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET) + atomic_inc(&priv->psstatus.confirm_wait); +} static void hostif_mib_get_request(struct ks_wlan_private *priv, @@ -1311,8 +1242,6 @@ void hostif_mib_get_request(struct ks_wlan_private *priv, { struct hostif_mib_get_request_t *pp; - DPRINTK(3, "\n"); - pp = hostif_generic_request(sizeof(*pp), HIF_MIB_GET_REQ); if (!pp) return; @@ -1331,12 +1260,8 @@ void hostif_mib_set_request(struct ks_wlan_private *priv, { struct hostif_mib_set_request_t *pp; - DPRINTK(3, "\n"); - - if (priv->dev_state < DEVICE_STATE_BOOT) { - DPRINTK(3, "DeviceRemove\n"); + if (priv->dev_state < DEVICE_STATE_BOOT) return; - } pp = hostif_generic_request(sizeof(*pp), HIF_MIB_SET_REQ); if (!pp) @@ -1357,8 +1282,6 @@ void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode) { struct hostif_start_request_t *pp; - DPRINTK(3, "\n"); - pp = hostif_generic_request(sizeof(*pp), HIF_START_REQ); if (!pp) return; @@ -1373,137 +1296,63 @@ void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode) priv->scan_ind_count = 0; } -static -void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) +static __le16 ks_wlan_cap(struct ks_wlan_private *priv) { - struct hostif_ps_adhoc_set_request_t *pp; - u16 capability; + u16 capability = 0x0000; - DPRINTK(3, "\n"); + if (priv->reg.preamble == SHORT_PREAMBLE) + capability |= WLAN_CAPABILITY_SHORT_PREAMBLE; - pp = hostif_generic_request(sizeof(*pp), HIF_PS_ADH_SET_REQ); - if (!pp) - return; + capability &= ~(WLAN_CAPABILITY_PBCC); /* pbcc not support */ - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); - pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); - - capability = 0x0000; - if (priv->reg.preamble == SHORT_PREAMBLE) { - /* short preamble */ - capability |= BSS_CAP_SHORT_PREAMBLE; - } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ if (priv->reg.phy_type != D_11B_ONLY_MODE) { - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM */ + capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME; + capability &= ~(WLAN_CAPABILITY_DSSS_OFDM); } - pp->capability = cpu_to_le16((uint16_t)capability); - /* send to device request */ - ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); + return cpu_to_le16((uint16_t)capability); } -static -void hostif_infrastructure_set_request(struct ks_wlan_private *priv) +static void init_request(struct ks_wlan_private *priv, struct hostif_request_t *req) { - struct hostif_infrastructure_set_request_t *pp; - u16 capability; + req->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); + req->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); + req->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + req->rate_set.size = priv->reg.rate_set.size; + req->capability = ks_wlan_cap(priv); + memcpy(&req->rate_set.body[0], &priv->reg.rate_set.body[0], + priv->reg.rate_set.size); +} - DPRINTK(3, "ssid.size=%d\n", priv->reg.ssid.size); +static +void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) +{ + struct hostif_ps_adhoc_set_request_t *pp; - pp = hostif_generic_request(sizeof(*pp), HIF_INFRA_SET_REQ); + pp = hostif_generic_request(sizeof(*pp), HIF_PS_ADH_SET_REQ); if (!pp) return; - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - - pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); - pp->ssid.size = priv->reg.ssid.size; - memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); - - capability = 0x0000; - if (priv->reg.preamble == SHORT_PREAMBLE) { - /* short preamble */ - capability |= BSS_CAP_SHORT_PREAMBLE; - } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ - if (priv->reg.phy_type != D_11B_ONLY_MODE) { - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ - } - pp->capability = cpu_to_le16((uint16_t)capability); - pp->beacon_lost_count = - cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); - pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); - - pp->channel_list.body[0] = 1; - pp->channel_list.body[1] = 8; - pp->channel_list.body[2] = 2; - pp->channel_list.body[3] = 9; - pp->channel_list.body[4] = 3; - pp->channel_list.body[5] = 10; - pp->channel_list.body[6] = 4; - pp->channel_list.body[7] = 11; - pp->channel_list.body[8] = 5; - pp->channel_list.body[9] = 12; - pp->channel_list.body[10] = 6; - pp->channel_list.body[11] = 13; - pp->channel_list.body[12] = 7; - if (priv->reg.phy_type == D_11G_ONLY_MODE) { - pp->channel_list.size = 13; - } else { - pp->channel_list.body[13] = 14; - pp->channel_list.size = 14; - } + init_request(priv, &pp->request); + pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); /* send to device request */ ps_confirm_wait_inc(priv); ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); } -static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) +static +void hostif_infrastructure_set_request(struct ks_wlan_private *priv, int event) { - struct hostif_infrastructure_set2_request_t *pp; - u16 capability; - - DPRINTK(2, "ssid.size=%d\n", priv->reg.ssid.size); + struct hostif_infrastructure_set_request_t *pp; - pp = hostif_generic_request(sizeof(*pp), HIF_INFRA_SET2_REQ); + pp = hostif_generic_request(sizeof(*pp), event); if (!pp) return; - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - - pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); + init_request(priv, &pp->request); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); - - capability = 0x0000; - if (priv->reg.preamble == SHORT_PREAMBLE) { - /* short preamble */ - capability |= BSS_CAP_SHORT_PREAMBLE; - } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ - if (priv->reg.phy_type != D_11B_ONLY_MODE) { - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ - } - pp->capability = cpu_to_le16((uint16_t)capability); pp->beacon_lost_count = cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); @@ -1528,8 +1377,6 @@ static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) pp->channel_list.size = 14; } - memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN); - /* send to device request */ ps_confirm_wait_inc(priv); ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); @@ -1539,36 +1386,16 @@ static void hostif_adhoc_set_request(struct ks_wlan_private *priv) { struct hostif_adhoc_set_request_t *pp; - u16 capability; - - DPRINTK(3, "\n"); pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ); if (!pp) return; - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + init_request(priv, &pp->request); pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); - pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); - capability = 0x0000; - if (priv->reg.preamble == SHORT_PREAMBLE) { - /* short preamble */ - capability |= BSS_CAP_SHORT_PREAMBLE; - } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ - if (priv->reg.phy_type != D_11B_ONLY_MODE) { - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ - } - pp->capability = cpu_to_le16((uint16_t)capability); - /* send to device request */ ps_confirm_wait_inc(priv); ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL); @@ -1578,35 +1405,15 @@ static void hostif_adhoc_set2_request(struct ks_wlan_private *priv) { struct hostif_adhoc_set2_request_t *pp; - u16 capability; - - DPRINTK(3, "\n"); pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ); if (!pp) return; - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); + init_request(priv, &pp->request); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); - capability = 0x0000; - if (priv->reg.preamble == SHORT_PREAMBLE) { - /* short preamble */ - capability |= BSS_CAP_SHORT_PREAMBLE; - } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ - if (priv->reg.phy_type != D_11B_ONLY_MODE) { - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ - } - pp->capability = cpu_to_le16((uint16_t)capability); - pp->channel_list.body[0] = priv->reg.channel; pp->channel_list.size = 1; memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN); @@ -1621,8 +1428,6 @@ void hostif_stop_request(struct ks_wlan_private *priv) { struct hostif_stop_request_t *pp; - DPRINTK(3, "\n"); - pp = hostif_generic_request(sizeof(*pp), HIF_STOP_REQ); if (!pp) return; @@ -1637,8 +1442,6 @@ void hostif_phy_information_request(struct ks_wlan_private *priv) { struct hostif_phy_information_request_t *pp; - DPRINTK(3, "\n"); - pp = hostif_generic_request(sizeof(*pp), HIF_PHY_INFO_REQ); if (!pp) return; @@ -1663,9 +1466,6 @@ void hostif_power_mgmt_request(struct ks_wlan_private *priv, { struct hostif_power_mgmt_request_t *pp; - DPRINTK(3, "mode=%lu wake_up=%lu receive_dtims=%lu\n", mode, wake_up, - receive_dtims); - pp = hostif_generic_request(sizeof(*pp), HIF_POWER_MGMT_REQ); if (!pp) return; @@ -1685,8 +1485,6 @@ void hostif_sleep_request(struct ks_wlan_private *priv, { struct hostif_sleep_request_t *pp; - DPRINTK(3, "mode=%lu\n", (long)mode); - if (mode == SLP_SLEEP) { pp = hostif_generic_request(sizeof(*pp), HIF_SLEEP_REQ); if (!pp) @@ -1700,7 +1498,7 @@ void hostif_sleep_request(struct ks_wlan_private *priv, atomic_set(&priv->sleepstatus.wakeup_request, 1); queue_delayed_work(priv->wq, &priv->rw_dwork, 1); } else { - DPRINTK(3, "invalid mode %ld\n", (long)mode); + netdev_err(priv->net_dev, "invalid mode %ld\n", (long)mode); return; } } @@ -1712,8 +1510,6 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv, { struct hostif_bss_scan_request_t *pp; - DPRINTK(2, "\n"); - pp = hostif_generic_request(sizeof(*pp), HIF_SCAN_REQ); if (!pp) return; @@ -1764,8 +1560,6 @@ void hostif_mic_failure_request(struct ks_wlan_private *priv, { struct hostif_mic_failure_request_t *pp; - DPRINTK(3, "count=%d :: timer=%d\n", failure_count, timer); - pp = hostif_generic_request(sizeof(*pp), HIF_MIC_FAILURE_REQ); if (!pp) return; @@ -1805,14 +1599,12 @@ static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p, void hostif_receive(struct ks_wlan_private *priv, unsigned char *p, unsigned int size) { - DPRINTK(4, "\n"); - devio_rec_ind(priv, p, size); priv->rxp = p; priv->rx_size = size; - if (get_WORD(priv) == priv->rx_size) { /* length check !! */ + if (get_word(priv) == priv->rx_size) { /* length check !! */ hostif_event_check(priv); /* event check */ } } @@ -2137,11 +1929,11 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv) case MODE_INFRASTRUCTURE: /* Infrastructure mode */ if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) { - hostif_infrastructure_set_request(priv); + hostif_infrastructure_set_request(priv, HIF_INFRA_SET_REQ); } else { - hostif_infrastructure_set2_request(priv); - DPRINTK(2, - "Infra bssid = %pM\n", priv->reg.bssid); + hostif_infrastructure_set_request(priv, HIF_INFRA_SET2_REQ); + netdev_dbg(priv->net_dev, + "Infra bssid = %pM\n", priv->reg.bssid); } break; case MODE_ADHOC: @@ -2150,8 +1942,8 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv) hostif_adhoc_set_request(priv); } else { hostif_adhoc_set2_request(priv); - DPRINTK(2, - "Adhoc bssid = %pM\n", priv->reg.bssid); + netdev_dbg(priv->net_dev, + "Adhoc bssid = %pM\n", priv->reg.bssid); } break; default: @@ -2169,8 +1961,6 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv) __le32 filter_type; int i = 0; - DPRINTK(3, "\n"); - spin_lock(&priv->multicast_spin); memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN); @@ -2220,7 +2010,6 @@ void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv) { unsigned long mode, wake_up, receive_dtims; - DPRINTK(3, "\n"); switch (priv->reg.power_mgmt) { case POWER_MGMT_ACTIVE: mode = POWER_ACTIVE; @@ -2261,7 +2050,6 @@ void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv) static void hostif_sme_sleep_set(struct ks_wlan_private *priv) { - DPRINTK(3, "\n"); switch (priv->sleep_mode) { case SLP_SLEEP: hostif_sleep_request(priv, priv->sleep_mode); @@ -2345,7 +2133,6 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv) struct pmk_t *pmk; int i; - DPRINTK(4, "pmklist.size=%d\n", priv->pmklist.size); i = 0; list_for_each_entry(pmk, &priv->pmklist.head, list) { if (i < PMK_LIST_MAX) { @@ -2369,7 +2156,6 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) { __le32 val; - DPRINTK(3, "event=%d\n", event); switch (event) { case SME_START: if (priv->dev_state == DEVICE_STATE_BOOT) @@ -2403,8 +2189,8 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) priv->wpa.mic_failure.failure - 1, priv->wpa.mic_failure.counter); } else { - DPRINTK(4, "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n", - priv->wpa.mic_failure.failure); + netdev_err(priv->net_dev, "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n", + priv->wpa.mic_failure.failure); } break; case SME_MIC_FAILURE_CONFIRM: @@ -2544,8 +2330,6 @@ void hostif_sme_task(unsigned long dev) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; - DPRINTK(3, "\n"); - if (priv->dev_state < DEVICE_STATE_BOOT) return; @@ -2561,16 +2345,10 @@ void hostif_sme_task(unsigned long dev) /* send to Station Management Entity module */ void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event) { - DPRINTK(3, "\n"); - /* enqueue sme event */ if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) { priv->sme_i.event_buff[priv->sme_i.qtail] = event; inc_smeqtail(priv); -#ifdef KS_WLAN_DEBUG - if (priv->sme_i.max_event_count < cnt_smeqbody(priv)) - priv->sme_i.max_event_count = cnt_smeqbody(priv); -#endif /* KS_WLAN_DEBUG */ } else { /* in case of buffer overflow */ netdev_err(priv->net_dev, "sme queue buffer overflow\n"); @@ -2579,55 +2357,79 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event) tasklet_schedule(&priv->sme_task); } -int hostif_init(struct ks_wlan_private *priv) +static inline void hostif_aplist_init(struct ks_wlan_private *priv) { - int i; - - DPRINTK(3, "\n"); - + size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap_t); priv->aplist.size = 0; - for (i = 0; i < LOCAL_APLIST_MAX; i++) - memset(&priv->aplist.ap[i], 0, sizeof(struct local_ap_t)); + memset(&priv->aplist.ap[0], 0, size); +} + +static inline void hostif_status_init(struct ks_wlan_private *priv) +{ priv->infra_status = 0; priv->current_rate = 4; priv->connect_status = DISCONNECT_STATUS; +} - spin_lock_init(&priv->multicast_spin); +static inline void hostif_sme_init(struct ks_wlan_private *priv) +{ + priv->sme_i.sme_status = SME_IDLE; + priv->sme_i.qhead = 0; + priv->sme_i.qtail = 0; + spin_lock_init(&priv->sme_i.sme_spin); + priv->sme_i.sme_flag = 0; + tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv); +} - spin_lock_init(&priv->dev_read_lock); - init_waitqueue_head(&priv->devread_wait); - priv->dev_count = 0; - atomic_set(&priv->event_count, 0); - atomic_set(&priv->rec_count, 0); +static inline void hostif_wpa_init(struct ks_wlan_private *priv) +{ + memset(&priv->wpa, 0, sizeof(priv->wpa)); + priv->wpa.rsn_enabled = 0; + priv->wpa.mic_failure.failure = 0; + priv->wpa.mic_failure.last_failure_time = 0; + priv->wpa.mic_failure.stop = 0; +} - /* for power save */ +static inline void hostif_power_save_init(struct ks_wlan_private *priv) +{ atomic_set(&priv->psstatus.status, PS_NONE); atomic_set(&priv->psstatus.confirm_wait, 0); atomic_set(&priv->psstatus.snooze_guard, 0); init_completion(&priv->psstatus.wakeup_wait); INIT_WORK(&priv->wakeup_work, ks_wlan_hw_wakeup_task); +} + +static inline void hostif_pmklist_init(struct ks_wlan_private *priv) +{ + int i; - /* WPA */ - memset(&priv->wpa, 0, sizeof(priv->wpa)); - priv->wpa.rsn_enabled = 0; - priv->wpa.mic_failure.failure = 0; - priv->wpa.mic_failure.last_failure_time = 0; - priv->wpa.mic_failure.stop = 0; memset(&priv->pmklist, 0, sizeof(priv->pmklist)); INIT_LIST_HEAD(&priv->pmklist.head); for (i = 0; i < PMK_LIST_MAX; i++) INIT_LIST_HEAD(&priv->pmklist.pmk[i].list); +} - priv->sme_i.sme_status = SME_IDLE; - priv->sme_i.qhead = 0; - priv->sme_i.qtail = 0; -#ifdef KS_WLAN_DEBUG - priv->sme_i.max_event_count = 0; -#endif - spin_lock_init(&priv->sme_i.sme_spin); - priv->sme_i.sme_flag = 0; +static inline void hostif_counters_init(struct ks_wlan_private *priv) +{ + priv->dev_count = 0; + atomic_set(&priv->event_count, 0); + atomic_set(&priv->rec_count, 0); +} - tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv); +int hostif_init(struct ks_wlan_private *priv) +{ + hostif_aplist_init(priv); + hostif_status_init(priv); + + spin_lock_init(&priv->multicast_spin); + spin_lock_init(&priv->dev_read_lock); + init_waitqueue_head(&priv->devread_wait); + + hostif_counters_init(priv); + hostif_power_save_init(priv); + hostif_wpa_init(priv); + hostif_pmklist_init(priv); + hostif_sme_init(priv); return 0; } |