From 20c4f9c52e619a12e0a63eea708f0225b248e788 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:30 +0200 Subject: [PATCH] staging: ks7010: indent ks_hostif.c Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 1960 +++++++++++++++------------- 1 file changed, 1080 insertions(+), 880 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 497b8aaf6dae..f2a65c0ae630 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -23,9 +23,10 @@ /* Include Wireless Extension definition and check version */ #include /* New driver API */ -extern int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, - void (*complete_handler)(void *arg1, void *arg2), - void *arg1, void *arg2 ); +extern int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, + unsigned long size, + void (*complete_handler) (void *arg1, void *arg2), + void *arg1, void *arg2); extern void send_packet_complete(void *, void *); extern void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv); @@ -55,7 +56,7 @@ static inline u16 get_WORD(struct ks_wlan_private *priv) { u16 data; - data = (get_BYTE(priv) & 0xff); + data = (get_BYTE(priv) & 0xff); data |= ((get_BYTE(priv) << 8) & 0xff00); return data; } @@ -64,7 +65,7 @@ static inline u32 get_DWORD(struct ks_wlan_private *priv) { u32 data; - data = (get_BYTE(priv) & 0xff); + data = (get_BYTE(priv) & 0xff); data |= ((get_BYTE(priv) << 8) & 0x0000ff00); data |= ((get_BYTE(priv) << 16) & 0x00ff0000); data |= ((get_BYTE(priv) << 24) & 0xff000000); @@ -73,24 +74,24 @@ inline u32 get_DWORD(struct ks_wlan_private *priv) void ks_wlan_hw_wakeup_task(struct work_struct *work) { - struct ks_wlan_private *priv = container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task); + struct ks_wlan_private *priv = + container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task); int ps_status = atomic_read(&priv->psstatus.status); - if(ps_status==PS_SNOOZE){ + if (ps_status == PS_SNOOZE) { ks_wlan_hw_wakeup_request(priv); - if(!wait_for_completion_interruptible_timeout(&priv->psstatus.wakeup_wait,HZ/50)){ /* 20ms timeout */ - DPRINTK(1,"wake up timeout !!!\n"); + if (!wait_for_completion_interruptible_timeout(&priv->psstatus.wakeup_wait, HZ / 50)) { /* 20ms timeout */ + DPRINTK(1, "wake up timeout !!!\n"); schedule_work(&priv->ks_wlan_wakeup_task); return; } - } - else{ - DPRINTK(1,"ps_status=%d\n",ps_status); + } 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) { + DPRINTK(4, "sme task enable.\n"); tasklet_enable(&priv->sme_task); } } @@ -98,14 +99,13 @@ void ks_wlan_hw_wakeup_task(struct work_struct *work) static int ks_wlan_do_power_save(struct ks_wlan_private *priv) { - int rc=0; + int rc = 0; - DPRINTK(4,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status)); + DPRINTK(4, "psstatus.status=%d\n", atomic_read(&priv->psstatus.status)); - if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); - } - else{ + } else { priv->dev_state = DEVICE_STATE_READY; } return rc; @@ -116,26 +116,28 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) { struct local_ap_t *ap; union iwreq_data wrqu; - struct net_device *netdev=priv->net_dev; - int rc=0; + struct net_device *netdev = priv->net_dev; + int rc = 0; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); ap = &(priv->current_ap); - if((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS){ - memset(ap,0,sizeof(struct local_ap_t)); + if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) { + memset(ap, 0, sizeof(struct local_ap_t)); return 1; } /* bssid */ - memcpy(&(ap->bssid[0]),&(ap_info->bssid[0]),ETH_ALEN); + memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN); /* essid */ - memcpy(&(ap->ssid.body[0]),&(priv->reg.ssid.body[0]),priv->reg.ssid.size); + memcpy(&(ap->ssid.body[0]), &(priv->reg.ssid.body[0]), + priv->reg.ssid.size); ap->ssid.size = priv->reg.ssid.size; /* rate_set */ - memcpy(&(ap->rate_set.body[0]),&(ap_info->rate_set.body[0]),ap_info->rate_set.size); + memcpy(&(ap->rate_set.body[0]), &(ap_info->rate_set.body[0]), + ap_info->rate_set.size); ap->rate_set.size = ap_info->rate_set.size; - if(ap_info->ext_rate_set.size){ + if (ap_info->ext_rate_set.size) { /* rate_set */ memcpy(&(ap->rate_set.body[ap->rate_set.size]), &(ap_info->ext_rate_set.body[0]), @@ -153,29 +155,31 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) /* capability */ ap->capability = ap_info->capability; /* rsn */ - if((ap_info->rsn_mode & RSN_MODE_WPA2) && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)){ + if ((ap_info->rsn_mode & RSN_MODE_WPA2) + && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) { ap->rsn_ie.id = 0x30; - if(ap_info->rsn.size <= RSN_IE_BODY_MAX){ + if (ap_info->rsn.size <= RSN_IE_BODY_MAX) { ap->rsn_ie.size = ap_info->rsn.size; - memcpy(&(ap->rsn_ie.body[0]),&(ap_info->rsn.body[0]),ap_info->rsn.size); - } - else{ + memcpy(&(ap->rsn_ie.body[0]), &(ap_info->rsn.body[0]), + ap_info->rsn.size); + } else { ap->rsn_ie.size = RSN_IE_BODY_MAX; - memcpy(&(ap->rsn_ie.body[0]),&(ap_info->rsn.body[0]),RSN_IE_BODY_MAX); + memcpy(&(ap->rsn_ie.body[0]), &(ap_info->rsn.body[0]), + RSN_IE_BODY_MAX); } - } - else if((ap_info->rsn_mode & RSN_MODE_WPA) && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)){ + } else if ((ap_info->rsn_mode & RSN_MODE_WPA) + && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)) { ap->wpa_ie.id = 0xdd; - if(ap_info->rsn.size <= RSN_IE_BODY_MAX){ + if (ap_info->rsn.size <= RSN_IE_BODY_MAX) { ap->wpa_ie.size = ap_info->rsn.size; - memcpy(&(ap->wpa_ie.body[0]),&(ap_info->rsn.body[0]),ap_info->rsn.size); - } - else{ + memcpy(&(ap->wpa_ie.body[0]), &(ap_info->rsn.body[0]), + ap_info->rsn.size); + } else { ap->wpa_ie.size = RSN_IE_BODY_MAX; - memcpy(&(ap->wpa_ie.body[0]),&(ap_info->rsn.body[0]),RSN_IE_BODY_MAX); + memcpy(&(ap->wpa_ie.body[0]), &(ap_info->rsn.body[0]), + RSN_IE_BODY_MAX); } - } - else{ + } else { ap->rsn_ie.id = 0; ap->rsn_ie.size = 0; ap->wpa_ie.id = 0; @@ -185,45 +189,44 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) wrqu.data.length = 0; wrqu.data.flags = 0; wrqu.ap_addr.sa_family = ARPHRD_ETHER; - if((priv->connect_status & CONNECT_STATUS_MASK)==CONNECT_STATUS){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { memcpy(wrqu.ap_addr.sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN); - DPRINTK(3,"IWEVENT: connect bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", - (unsigned char)wrqu.ap_addr.sa_data[0],(unsigned char)wrqu.ap_addr.sa_data[1], - (unsigned char)wrqu.ap_addr.sa_data[2],(unsigned char)wrqu.ap_addr.sa_data[3], - (unsigned char)wrqu.ap_addr.sa_data[4],(unsigned char)wrqu.ap_addr.sa_data[5]); + DPRINTK(3, + "IWEVENT: connect bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", + (unsigned char)wrqu.ap_addr.sa_data[0], + (unsigned char)wrqu.ap_addr.sa_data[1], + (unsigned char)wrqu.ap_addr.sa_data[2], + (unsigned char)wrqu.ap_addr.sa_data[3], + (unsigned char)wrqu.ap_addr.sa_data[4], + (unsigned char)wrqu.ap_addr.sa_data[5]); wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL); } - DPRINTK(4,"\n Link AP\n"); - DPRINTK(4," bssid=%02X:%02X:%02X:%02X:%02X:%02X\n \ + DPRINTK(4, "\n Link AP\n"); + DPRINTK(4, " 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); - + 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); return rc; } static -int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, struct local_ap_t *ap) +int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, + struct local_ap_t *ap) { unsigned char *bp; - int bsize,offset; - int rc=0; + int bsize, offset; + int rc = 0; - DPRINTK(3,"\n"); - memset(ap,0,sizeof(struct local_ap_t)); + DPRINTK(3, "\n"); + memset(ap, 0, sizeof(struct local_ap_t)); /* bssid */ - memcpy(&(ap->bssid[0]),&(ap_info->bssid[0]),ETH_ALEN); + memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN); /* rssi */ ap->rssi = ap_info->rssi; /* sq */ @@ -239,73 +242,80 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, bsize = ap_info->body_size; offset = 0; - while(bsize > offset){ + 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)); + 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[0]),bp+2,ap->ssid.size); + memcpy(&(ap->ssid.body[0]), bp + 2, ap->ssid.size); break; - case 1: /* rate */ - case 50: /* ext rate */ - 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{ + case 1: /* rate */ + case 50: /* ext rate */ + 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, + (*(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); - ap->rate_set.size += (RATE_SET_MAX_SIZE - ap->rate_set.size); + ap->rate_set.size += + (RATE_SET_MAX_SIZE - ap->rate_set.size); } break; - case 3: /* DS parameter */ + case 3: /* DS parameter */ break; - case 48: /* RSN(WPA2) */ + case 48: /* RSN(WPA2) */ 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)); + 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[0]),bp+2,ap->rsn_ie.size); + memcpy(&(ap->rsn_ie.body[0]), bp + 2, ap->rsn_ie.size); break; - case 221: /* WPA */ - if(!memcmp(bp+2, "\x00\x50\xf2\x01", 4)){ /* WPA OUI check */ + case 221: /* WPA */ + if (!memcmp(bp + 2, "\x00\x50\xf2\x01", 4)) { /* WPA OUI check */ 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)); + 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[0]),bp+2,ap->wpa_ie.size); + memcpy(&(ap->wpa_ie.body[0]), bp + 2, + ap->wpa_ie.size); } 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 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 */ break; default: - DPRINTK(4, "unknown Element ID=%d \n",*bp); + DPRINTK(4, "unknown Element ID=%d \n", *bp); break; } - offset += 2; /* id & size field */ - offset += *(bp+1); /* +size offset */ - bp += (*(bp+1) + 2); /* pointer update */ + offset += 2; /* id & size field */ + offset += *(bp + 1); /* +size offset */ + bp += (*(bp + 1) + 2); /* pointer update */ } return rc; @@ -314,12 +324,12 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, static void hostif_data_indication(struct ks_wlan_private *priv) { - unsigned int rx_ind_size; /* indicate data size */ + unsigned int rx_ind_size; /* indicate data size */ struct sk_buff *skb; - unsigned short auth_type; - unsigned char temp[256]; + unsigned short auth_type; + unsigned char temp[256]; - unsigned char RecvMIC[8]; + unsigned char RecvMIC[8]; char buf[128]; struct ether_hdr *eth_hdr; unsigned short eth_proto; @@ -330,162 +340,193 @@ void hostif_data_indication(struct ks_wlan_private *priv) struct michel_mic_t michel_mic; union iwreq_data wrqu; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* min length check */ if (priv->rx_size <= ETH_HLEN) { - DPRINTK(3,"rx_size = %d\n", priv->rx_size); + 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); + DPRINTK(3, "ether protocol = %04X\n", eth_proto); /* source address check */ - if (!memcmp(&priv->eth_addr[0],eth_hdr->h_source, ETH_ALEN)){ + if (!memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN)) { 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]); + 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]); priv->nstats.rx_errors++; return; } /* for WPA */ - if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled){ - if(memcmp(ð_hdr->h_source[0],&priv->eth_addr[0],ETH_ALEN)){ /* source address check */ - if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap){ - DPRINTK(1,"invalid data format\n"); + if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled) { + if (memcmp(ð_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN)) { /* source address check */ + if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) { + DPRINTK(1, "invalid data format\n"); priv->nstats.rx_errors++; return; } - if(((auth_type==TYPE_PMK1 && priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP)|| - (auth_type==TYPE_GMK1 && priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP)|| - (auth_type==TYPE_GMK2 && priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP)) - && priv->wpa.key[auth_type-1].key_len){ - DPRINTK(4,"TKIP: protocol=%04X: size=%u\n", eth_proto, priv->rx_size); + if (((auth_type == TYPE_PMK1 + && priv->wpa.pairwise_suite == + IW_AUTH_CIPHER_TKIP) || (auth_type == TYPE_GMK1 + && priv->wpa. + group_suite == + IW_AUTH_CIPHER_TKIP) + || (auth_type == TYPE_GMK2 + && priv->wpa.group_suite == + IW_AUTH_CIPHER_TKIP)) + && priv->wpa.key[auth_type - 1].key_len) { + DPRINTK(4, "TKIP: protocol=%04X: size=%u\n", + eth_proto, priv->rx_size); /* MIC save */ - memcpy(&RecvMIC[0], (priv->rxp)+((priv->rx_size)-8), 8); + memcpy(&RecvMIC[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(&michel_mic, - (uint8_t*)priv->wpa.key[auth_type-1].rx_mic_key, - (uint8_t*)priv->rxp, - (int)priv->rx_size, - (uint8_t)0, /* priority */ - (uint8_t*)michel_mic.Result); + if (auth_type > 0 && auth_type < 4) { /* auth_type check */ + MichaelMICFunction(&michel_mic, (uint8_t *) priv->wpa.key[auth_type - 1].rx_mic_key, (uint8_t *) priv->rxp, (int)priv->rx_size, (uint8_t) 0, /* priority */ + (uint8_t *) + michel_mic.Result); } - if(memcmp(michel_mic.Result, RecvMIC, 8)){ + if (memcmp(michel_mic.Result, RecvMIC, 8)) { now = jiffies; mic_failure = &priv->wpa.mic_failure; /* MIC FAILURE */ - if(mic_failure->last_failure_time && - (now - mic_failure->last_failure_time)/HZ >= 60){ - mic_failure->failure=0; + if (mic_failure->last_failure_time && + (now - + mic_failure->last_failure_time) / + HZ >= 60) { + mic_failure->failure = 0; } - DPRINTK(4,"MIC FAILURE \n"); - if(mic_failure->failure==0){ - mic_failure->failure=1; - mic_failure->counter=0; - }else if(mic_failure->failure==1){ - mic_failure->failure=2; + DPRINTK(4, "MIC FAILURE \n"); + if (mic_failure->failure == 0) { + mic_failure->failure = 1; + mic_failure->counter = 0; + } else if (mic_failure->failure == 1) { + mic_failure->failure = 2; mic_failure->counter = - (uint16_t)((now - mic_failure->last_failure_time)/HZ); - if(!mic_failure->counter) /* mic_failure counter value range 1-60 */ - mic_failure->counter = 1; + (uint16_t) ((now - + mic_failure-> + last_failure_time) + / HZ); + if (!mic_failure->counter) /* mic_failure counter value range 1-60 */ + mic_failure->counter = + 1; } - priv->wpa.mic_failure.last_failure_time = now; + priv->wpa.mic_failure. + last_failure_time = now; /* needed parameters: count, keyid, key type, TSC */ - sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=" + sprintf(buf, + "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=" "%02x:%02x:%02x:%02x:%02x:%02x)", - auth_type-1, eth_hdr->h_dest[0] & 0x01 ? "broad" : "uni", - 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]); + auth_type - 1, + eth_hdr-> + h_dest[0] & 0x01 ? "broad" : + "uni", 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]); memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = strlen(buf); - DPRINTK(4,"IWEVENT:MICHAELMICFAILURE\n"); - wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); + DPRINTK(4, + "IWEVENT:MICHAELMICFAILURE\n"); + wireless_send_event(priv->net_dev, + IWEVCUSTOM, &wrqu, + buf); return; } } } } - if((priv->connect_status & FORCE_DISCONNECT)|| - priv->wpa.mic_failure.failure==2){ + if ((priv->connect_status & FORCE_DISCONNECT) || + priv->wpa.mic_failure.failure == 2) { return; } /* check 13th byte at rx data */ - switch (*(priv->rxp+12)) { - case 0xAA: /* SNAP */ + switch (*(priv->rxp + 12)) { + case 0xAA: /* SNAP */ rx_ind_size = priv->rx_size - 6; - skb = dev_alloc_skb (rx_ind_size); - DPRINTK(4,"SNAP, rx_ind_size = %d\n", rx_ind_size); - - if(skb) { - memcpy(skb_put(skb,12),priv->rxp,12); /* 8802/FDDI MAC copy */ - /* (SNAP+UI..) skip */ - memcpy(skb_put(skb,rx_ind_size-12),priv->rxp+18,rx_ind_size-12); /* copy after Type */ - - aa1x_hdr=(struct ieee802_1x_hdr *)(priv->rxp+20); - if(aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY && priv->wpa.rsn_enabled){ - eap_key = (struct wpa_eapol_key *)(aa1x_hdr+1); + skb = dev_alloc_skb(rx_ind_size); + DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size); + + if (skb) { + memcpy(skb_put(skb, 12), priv->rxp, 12); /* 8802/FDDI MAC copy */ + /* (SNAP+UI..) skip */ + memcpy(skb_put(skb, rx_ind_size - 12), priv->rxp + 18, rx_ind_size - 12); /* copy after Type */ + + aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 20); + if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY + && priv->wpa.rsn_enabled) { + eap_key = + (struct wpa_eapol_key *)(aa1x_hdr + 1); atomic_set(&priv->psstatus.snooze_guard, 1); } /* rx indication */ skb->dev = priv->net_dev; - skb->protocol = eth_type_trans (skb, skb->dev); + skb->protocol = eth_type_trans(skb, skb->dev); priv->nstats.rx_packets++; priv->nstats.rx_bytes += rx_ind_size; skb->dev->last_rx = jiffies; - netif_rx (skb); + netif_rx(skb); } else { - printk (KERN_WARNING"%s: Memory squeeze, dropping packet.\n",skb->dev->name); + printk(KERN_WARNING + "%s: Memory squeeze, dropping packet.\n", + skb->dev->name); priv->nstats.rx_dropped++; } break; - case 0xF0: /* NETBEUI/NetBIOS */ + case 0xF0: /* NETBEUI/NetBIOS */ rx_ind_size = (priv->rx_size + 2); - skb = dev_alloc_skb (rx_ind_size); - DPRINTK(3,"NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size); + skb = dev_alloc_skb(rx_ind_size); + DPRINTK(3, "NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size); - if(skb) { - memcpy(skb_put(skb,12),priv->rxp,12); /* 8802/FDDI MAC copy */ + if (skb) { + memcpy(skb_put(skb, 12), priv->rxp, 12); /* 8802/FDDI MAC copy */ - temp[0] = (((rx_ind_size-12) >> 8) & 0xff); /* NETBEUI size add */ - temp[1] = ((rx_ind_size-12) & 0xff); - memcpy(skb_put(skb,2),temp,2); + temp[0] = (((rx_ind_size - 12) >> 8) & 0xff); /* NETBEUI size add */ + temp[1] = ((rx_ind_size - 12) & 0xff); + memcpy(skb_put(skb, 2), temp, 2); - memcpy(skb_put(skb,rx_ind_size-14),priv->rxp+12,rx_ind_size-14); /* copy after Type */ + memcpy(skb_put(skb, rx_ind_size - 14), priv->rxp + 12, rx_ind_size - 14); /* copy after Type */ - aa1x_hdr=(struct ieee802_1x_hdr *)(priv->rxp+14); - if(aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY && priv->wpa.rsn_enabled){ - eap_key = (struct wpa_eapol_key *)(aa1x_hdr+1); + aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14); + if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY + && priv->wpa.rsn_enabled) { + eap_key = + (struct wpa_eapol_key *)(aa1x_hdr + 1); atomic_set(&priv->psstatus.snooze_guard, 1); } /* rx indication */ skb->dev = priv->net_dev; - skb->protocol = eth_type_trans (skb, skb->dev); + skb->protocol = eth_type_trans(skb, skb->dev); priv->nstats.rx_packets++; priv->nstats.rx_bytes += rx_ind_size; skb->dev->last_rx = jiffies; - netif_rx (skb); + netif_rx(skb); } else { - printk (KERN_WARNING"%s: Memory squeeze, dropping packet.\n",skb->dev->name); + printk(KERN_WARNING + "%s: Memory squeeze, dropping packet.\n", + skb->dev->name); priv->nstats.rx_dropped++; } break; - default: /* other rx data */ - DPRINTK(2,"invalid data format\n"); + default: /* other rx data */ + DPRINTK(2, "invalid data format\n"); priv->nstats.rx_errors++; } } @@ -493,29 +534,30 @@ void hostif_data_indication(struct ks_wlan_private *priv) static void hostif_mib_get_confirm(struct ks_wlan_private *priv) { - struct net_device *dev=priv->net_dev; - uint32_t mib_status; - uint32_t mib_attribute; - uint16_t mib_val_size; - uint16_t mib_val_type; + struct net_device *dev = priv->net_dev; + uint32_t mib_status; + uint32_t mib_attribute; + uint16_t mib_val_size; + uint16_t 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 != 0) { /* in case of error */ - DPRINTK(1, "attribute=%08X, status=%08X\n", mib_attribute, mib_status); + DPRINTK(1, "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"); + 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; @@ -527,44 +569,48 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv) dev->dev_addr[5] = priv->eth_addr[5]; dev->dev_addr[6] = 0x00; dev->dev_addr[7] = 0x00; - printk(KERN_INFO "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n", - priv->eth_addr[0],priv->eth_addr[1],priv->eth_addr[2], - priv->eth_addr[3],priv->eth_addr[4],priv->eth_addr[5]); + printk(KERN_INFO + "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->eth_addr[0], priv->eth_addr[1], priv->eth_addr[2], + priv->eth_addr[3], priv->eth_addr[4], priv->eth_addr[5]); break; case DOT11_PRODUCT_VERSION: /* firmware version */ - DPRINTK(3," mib_attribute=DOT11_PRODUCT_VERSION\n"); + 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'; - printk(KERN_INFO "ks_wlan: firmware ver. = %s\n",priv->firmware_version); + printk(KERN_INFO "ks_wlan: firmware ver. = %s\n", + priv->firmware_version); hostif_sme_enqueue(priv, SME_GET_PRODUCT_VERSION); /* wake_up_interruptible_all(&priv->confirm_wait); */ complete(&priv->confirm_wait); break; case LOCAL_GAIN: memcpy(&priv->gain, priv->rxp, sizeof(priv->gain)); - DPRINTK(3, "TxMode=%d, RxMode=%d, TxGain=%d, RxGain=%d\n", - priv->gain.TxMode, priv->gain.RxMode, priv->gain.TxGain, priv->gain.RxGain); + DPRINTK(3, "TxMode=%d, RxMode=%d, TxGain=%d, RxGain=%d\n", + priv->gain.TxMode, priv->gain.RxMode, priv->gain.TxGain, + priv->gain.RxGain); 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){ + 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){ - if(priv->eeprom_sum.result == 0){ + } else if (priv->eeprom_sum.type == 1) { + if (priv->eeprom_sum.result == 0) { priv->eeprom_checksum = EEPROM_NG; printk("LOCAL_EEPROM_SUM NG\n"); - }else if(priv->eeprom_sum.result == 1){ + } else if (priv->eeprom_sum.result == 1) { priv->eeprom_checksum = EEPROM_OK; } - }else{ + } else { printk("LOCAL_EEPROM_SUM error!\n"); } break; default: - DPRINTK(1,"mib_attribute=%08x\n",(unsigned int)mib_attribute); + DPRINTK(1, "mib_attribute=%08x\n", (unsigned int)mib_attribute); break; } } @@ -572,17 +618,18 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv) static void hostif_mib_set_confirm(struct ks_wlan_private *priv) { - uint32_t mib_status; /* +04 MIB Status */ - uint32_t mib_attribute; /* +08 MIB attribute */ + uint32_t mib_status; /* +04 MIB Status */ + uint32_t mib_attribute; /* +08 MIB attribute */ - DPRINTK(3,"\n"); + 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 != 0) { /* in case of error */ - DPRINTK(1, "error :: attribute=%08X, status=%08X\n", mib_attribute, mib_status); + DPRINTK(1, "error :: attribute=%08X, status=%08X\n", + mib_attribute, mib_status); } switch (mib_attribute) { @@ -593,41 +640,46 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_ID: - if(!priv->wpa.wpa_enabled) + if (!priv->wpa.wpa_enabled) 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) + 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) + 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) + 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) + 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; case DOT11_PRIVACY_INVOKED: - if(!priv->wpa.rsn_enabled) + if (!priv->wpa.rsn_enabled) 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); + 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: @@ -643,49 +695,53 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) priv->mac_address_valid = 1; break; case DOT11_RSN_CONFIG_MULTICAST_CIPHER: - DPRINTK(2,"DOT11_RSN_CONFIG_MULTICAST_CIPHER:mib_status=%d\n",(int)mib_status); + 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); + 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); + 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); + 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)){ + 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)){ + 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); + 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); + 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); + 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); + 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 : + DPRINTK(2, "LOCAL_REGION:mib_status=%d\n", (int)mib_status); + default: break; } } @@ -693,14 +749,14 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) static void hostif_power_mngmt_confirm(struct ks_wlan_private *priv) { - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - if(priv->reg.powermgt > POWMGT_ACTIVE_MODE && - priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + if (priv->reg.powermgt > POWMGT_ACTIVE_MODE && + priv->reg.operation_mode == MODE_INFRASTRUCTURE) { atomic_set(&priv->psstatus.confirm_wait, 0); priv->dev_state = DEVICE_STATE_SLEEP; ks_wlan_hw_power_save(priv); - }else{ + } else { priv->dev_state = DEVICE_STATE_READY; } @@ -709,27 +765,28 @@ void hostif_power_mngmt_confirm(struct ks_wlan_private *priv) static void hostif_sleep_confirm(struct ks_wlan_private *priv) { - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - atomic_set(&priv->sleepstatus.doze_request,1); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + atomic_set(&priv->sleepstatus.doze_request, 1); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); } static void hostif_start_confirm(struct ks_wlan_private *priv) { #ifdef WPS - union iwreq_data wrqu; - wrqu.data.length = 0; - wrqu.data.flags = 0; - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ - memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); - DPRINTK(3,"IWEVENT: disconnect\n"); - wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); - } + union iwreq_data wrqu; + wrqu.data.length = 0; + wrqu.data.flags = 0; + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { + memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); + 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); + DPRINTK(3, " scan_ind_count=%d\n", priv->scan_ind_count); hostif_sme_enqueue(priv, SME_START_CONFIRM); } @@ -737,29 +794,31 @@ static void hostif_connect_indication(struct ks_wlan_private *priv) { unsigned short connect_code; - unsigned int tmp=0; - unsigned int old_status=priv->connect_status; - struct net_device *netdev=priv->net_dev; + unsigned int tmp = 0; + unsigned int old_status = priv->connect_status; + struct net_device *netdev = priv->net_dev; union iwreq_data wrqu0; 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)) + 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 */ + DPRINTK(3, "disconnect :: scan_ind_count=%d\n", + priv->scan_ind_count); 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); + DPRINTK(1, "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; @@ -767,25 +826,26 @@ void hostif_connect_indication(struct ks_wlan_private *priv) } get_current_ap(priv, (struct link_ap_info_t *)priv->rxp); - if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS && - (old_status & CONNECT_STATUS_MASK)==DISCONNECT_STATUS ){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS && + (old_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) { /* for power save */ atomic_set(&priv->psstatus.snooze_guard, 0); - atomic_set(&priv->psstatus.confirm_wait,0); + atomic_set(&priv->psstatus.confirm_wait, 0); } ks_wlan_do_power_save(priv); wrqu0.data.length = 0; wrqu0.data.flags = 0; wrqu0.ap_addr.sa_family = ARPHRD_ETHER; - if((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS && - (old_status & CONNECT_STATUS_MASK)==CONNECT_STATUS ){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS && + (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { memset(wrqu0.ap_addr.sa_data, '\0', ETH_ALEN); - DPRINTK(3,"IWEVENT: disconnect\n"); - DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); + DPRINTK(3, "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; + priv->scan_ind_count = 0; } static @@ -794,45 +854,52 @@ 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); + DPRINTK(3, "scan_ind_count = %d\n", priv->scan_ind_count); ap_info = (struct ap_info_t *)(priv->rxp); - if(priv->scan_ind_count!=0){ - for(i=0;iaplist.size;i++){ /* bssid check */ - if(!memcmp(&(ap_info->bssid[0]),&(priv->aplist.ap[i].bssid[0]),ETH_ALEN)){ - if(ap_info->frame_type == FRAME_TYPE_PROBE_RESP) - get_ap_information(priv,ap_info,&(priv->aplist.ap[i])); + if (priv->scan_ind_count != 0) { + for (i = 0; i < priv->aplist.size; i++) { /* bssid check */ + if (!memcmp + (&(ap_info->bssid[0]), + &(priv->aplist.ap[i].bssid[0]), ETH_ALEN)) { + if (ap_info->frame_type == + FRAME_TYPE_PROBE_RESP) + get_ap_information(priv, ap_info, + &(priv->aplist. + ap[i])); return; } } } priv->scan_ind_count++; - if(priv->scan_ind_count < LOCAL_APLIST_MAX+1){ - DPRINTK(4," 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])); + if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) { + DPRINTK(4, " 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); } - else{ - DPRINTK(4," count over :: scan_ind_count=%d\n", priv->scan_ind_count); - } - } static void hostif_stop_confirm(struct ks_wlan_private *priv) { - unsigned int tmp=0; - unsigned int old_status=priv->connect_status; - struct net_device *netdev=priv->net_dev; + unsigned int tmp = 0; + unsigned int old_status = priv->connect_status; + struct net_device *netdev = priv->net_dev; union iwreq_data wrqu0; - DPRINTK(3,"\n"); - if(priv->dev_state == DEVICE_STATE_SLEEP) + DPRINTK(3, "\n"); + if (priv->dev_state == DEVICE_STATE_SLEEP) priv->dev_state = DEVICE_STATE_READY; /* disconnect indication */ - if( (priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { netif_carrier_off(netdev); tmp = FORCE_DISCONNECT & priv->connect_status; priv->connect_status = tmp | DISCONNECT_STATUS; @@ -841,15 +908,17 @@ void hostif_stop_confirm(struct ks_wlan_private *priv) wrqu0.data.length = 0; wrqu0.data.flags = 0; wrqu0.ap_addr.sa_family = ARPHRD_ETHER; - if((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS && - (old_status & CONNECT_STATUS_MASK)==CONNECT_STATUS ){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == + DISCONNECT_STATUS + && (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { memset(wrqu0.ap_addr.sa_data, '\0', ETH_ALEN); - DPRINTK(3,"IWEVENT: disconnect\n"); + DPRINTK(3, "IWEVENT: disconnect\n"); printk("IWEVENT: disconnect\n"); - DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); + DPRINTK(3, "disconnect :: scan_ind_count=%d\n", + priv->scan_ind_count); wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL); } - priv->scan_ind_count=0; + priv->scan_ind_count = 0; } hostif_sme_enqueue(priv, SME_STOP_CONFIRM); @@ -858,8 +927,8 @@ 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 */ + DPRINTK(3, "\n"); + priv->infra_status = 0; /* infrastructure mode cancel */ hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); } @@ -868,18 +937,18 @@ static void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv) { uint16_t result_code; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); result_code = get_WORD(priv); - DPRINTK(3,"result code = %d\n",result_code); - priv->infra_status = 1; /* infrastructure mode set */ + DPRINTK(3, "result code = %d\n", result_code); + priv->infra_status = 1; /* infrastructure mode set */ hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); } static void hostif_adhoc_set_confirm(struct ks_wlan_private *priv) { - DPRINTK(3,"\n"); - priv->infra_status = 1; /* infrastructure mode set */ + DPRINTK(3, "\n"); + priv->infra_status = 1; /* infrastructure mode set */ hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); } @@ -897,33 +966,33 @@ 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"); + 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); + assoc_resp = (struct association_response_t *)(assoc_req + 1); + pb = (unsigned char *)(assoc_resp + 1); memset(&wrqu, 0, sizeof(wrqu)); - memcpy(pbuf,associnfo_leader0,sizeof(associnfo_leader0)-1); - wrqu.data.length += sizeof(associnfo_leader0)-1; - pbuf += sizeof(associnfo_leader0)-1; + memcpy(pbuf, associnfo_leader0, sizeof(associnfo_leader0) - 1); + wrqu.data.length += sizeof(associnfo_leader0) - 1; + pbuf += sizeof(associnfo_leader0) - 1; for (i = 0; i < assoc_req->reqIEs_size; i++) - pbuf += sprintf(pbuf, "%02x", *(pb+i)); - wrqu.data.length += (assoc_req->reqIEs_size)*2; + pbuf += sprintf(pbuf, "%02x", *(pb + i)); + wrqu.data.length += (assoc_req->reqIEs_size) * 2; - memcpy(pbuf,associnfo_leader1,sizeof(associnfo_leader1)-1); - wrqu.data.length += sizeof(associnfo_leader1)-1; - pbuf += sizeof(associnfo_leader1)-1; + memcpy(pbuf, associnfo_leader1, sizeof(associnfo_leader1) - 1); + wrqu.data.length += sizeof(associnfo_leader1) - 1; + pbuf += sizeof(associnfo_leader1) - 1; pb += assoc_req->reqIEs_size; for (i = 0; i < assoc_resp->respIEs_size; i++) - pbuf += sprintf(pbuf, "%02x", *(pb+i)); - wrqu.data.length += (assoc_resp->respIEs_size)*2; + pbuf += sprintf(pbuf, "%02x", *(pb + i)); + wrqu.data.length += (assoc_resp->respIEs_size) * 2; pbuf += sprintf(pbuf, ")"); wrqu.data.length += 1; - DPRINTK(3,"IWEVENT:ASSOCINFO\n"); + DPRINTK(3, "IWEVENT:ASSOCINFO\n"); wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); } @@ -934,28 +1003,29 @@ 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); + DPRINTK(2, "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"); + DPRINTK(3, "IWEVENT: SCAN CONFIRM\n"); wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); - priv->scan_ind_count=0; + priv->scan_ind_count = 0; } static void hostif_phy_information_confirm(struct ks_wlan_private *priv) { struct iw_statistics *wstats = &priv->wstats; - unsigned char rssi,signal,noise; + unsigned char rssi, signal, noise; unsigned char LinkSpeed; unsigned int TransmittedFrameCount, ReceivedFragmentCount; unsigned int FailedCount, FCSErrorCount; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); rssi = get_BYTE(priv); signal = get_BYTE(priv); noise = get_BYTE(priv); @@ -969,14 +1039,12 @@ void hostif_phy_information_confirm(struct ks_wlan_private *priv) priv->current_rate = (LinkSpeed & RATE_MASK); wstats->qual.qual = signal; wstats->qual.level = 256 - rssi; - wstats->qual.noise = 0; /* invalid noise value */ + wstats->qual.noise = 0; /* invalid noise value */ wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; - DPRINTK(3,"\n rssi=%u\n signal=%u\n LinkSpeed=%ux500Kbps\n \ + DPRINTK(3, "\n rssi=%u\n signal=%u\n LinkSpeed=%ux500Kbps\n \ TransmittedFrameCount=%u\n ReceivedFragmentCount=%u\n FailedCount=%u\n \ - FCSErrorCount=%u\n", - rssi,signal,LinkSpeed,TransmittedFrameCount, - ReceivedFragmentCount,FailedCount,FCSErrorCount); + FCSErrorCount=%u\n", rssi, signal, LinkSpeed, TransmittedFrameCount, ReceivedFragmentCount, FailedCount, FCSErrorCount); /* wake_up_interruptible_all(&priv->confirm_wait); */ complete(&priv->confirm_wait); @@ -985,18 +1053,17 @@ 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); + DPRINTK(3, "mic_failure=%u\n", priv->wpa.mic_failure.failure); hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM); } - static 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); @@ -1060,56 +1127,59 @@ void hostif_event_check(struct ks_wlan_private *priv) /* add event to hostt buffer */ priv->hostt.buff[priv->hostt.qtail] = event; - priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; + priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; } #define CHECK_ALINE(size) (size%4 ? (size+(4-(size%4))):size) int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) { - unsigned int packet_len=0; + unsigned int packet_len = 0; - unsigned char *buffer=NULL; - unsigned int length=0; + unsigned char *buffer = NULL; + unsigned int length = 0; struct hostif_data_request_t *pp; - unsigned char *p; - int result=0; + unsigned char *p; + int result = 0; unsigned short eth_proto; struct ether_hdr *eth_hdr; struct michel_mic_t michel_mic; - unsigned short keyinfo=0; + unsigned short keyinfo = 0; struct ieee802_1x_hdr *aa1x_hdr; struct wpa_eapol_key *eap_key; struct ethhdr *eth; packet_len = packet->len; if (packet_len > ETH_FRAME_LEN) { - DPRINTK(1,"bad length packet_len=%d \n", packet_len); + DPRINTK(1, "bad length packet_len=%d \n", packet_len); dev_kfree_skb(packet); return -1; } - if(((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS) || - (priv->connect_status & FORCE_DISCONNECT) || priv->wpa.mic_failure.stop){ - DPRINTK(3," DISCONNECT\n"); - if(netif_queue_stopped(priv->net_dev)) + if (((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_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(packet) + if (packet) dev_kfree_skb(packet); return 0; } /* for PowerSave */ - if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ /* power save wakeup */ - if(!netif_queue_stopped(priv->net_dev)) + if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { /* power save wakeup */ + if (!netif_queue_stopped(priv->net_dev)) netif_stop_queue(priv->net_dev); } DPRINTK(4, "skb_buff length=%d\n", packet_len); - pp = (struct hostif_data_request_t *)kmalloc(hif_align_size(sizeof(*pp)+6+packet_len+8),KS_WLAN_MEM_FLAG ); + pp = (struct hostif_data_request_t *) + kmalloc(hif_align_size(sizeof(*pp) + 6 + packet_len + 8), + KS_WLAN_MEM_FLAG); - if (pp==NULL) { + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); dev_kfree_skb(packet); return -2; @@ -1122,34 +1192,34 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) /* packet check */ eth = (struct ethhdr *)packet->data; - if (memcmp(&priv->eth_addr[0],eth->h_source, ETH_ALEN)){ + if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN)) { DPRINTK(1, "invalid mac address !!\n"); DPRINTK(1, "ethernet->h_source=%02X:%02X:%02X:%02X:%02X:%02X\n", - eth->h_source[0],eth->h_source[1],eth->h_source[2], - eth->h_source[3],eth->h_source[4],eth->h_source[5]); + eth->h_source[0], eth->h_source[1], eth->h_source[2], + eth->h_source[3], eth->h_source[4], eth->h_source[5]); return -3; } /* MAC address copy */ - memcpy(p, buffer, 12); /* DST/SRC MAC address */ + memcpy(p, buffer, 12); /* DST/SRC MAC address */ p += 12; buffer += 12; length -= 12; /* EtherType/Length check */ - if (*(buffer+1) + (*buffer << 8) > 1500) { + if (*(buffer + 1) + (*buffer << 8) > 1500) { /* ProtocolEAP = *(buffer+1) + (*buffer << 8); */ - /* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */ + /* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */ /* SAP/CTL/OUI(6 byte) add */ - *p++ = 0xAA; /* DSAP */ - *p++ = 0xAA; /* SSAP */ - *p++ = 0x03; /* CTL */ - *p++ = 0x00; /* OUI ("000000") */ - *p++ = 0x00; /* OUI ("000000") */ - *p++ = 0x00; /* OUI ("000000") */ + *p++ = 0xAA; /* DSAP */ + *p++ = 0xAA; /* SSAP */ + *p++ = 0x03; /* CTL */ + *p++ = 0x00; /* OUI ("000000") */ + *p++ = 0x00; /* OUI ("000000") */ + *p++ = 0x00; /* OUI ("000000") */ packet_len += 6; } else { - DPRINTK(4,"DIX\n"); - /* Length(2 byte) delete */ + DPRINTK(4, "DIX\n"); + /* Length(2 byte) delete */ buffer += 2; length -= 2; packet_len -= 2; @@ -1165,61 +1235,68 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) eth_proto = ntohs(eth_hdr->h_proto); /* for MIC FAILUER REPORT check */ - if(eth_proto == ETHER_PROTOCOL_TYPE_EAP && priv->wpa.mic_failure.failure>0){ - aa1x_hdr=(struct ieee802_1x_hdr *)(eth_hdr+1); - if(aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY){ - eap_key = (struct wpa_eapol_key *)(aa1x_hdr+1); - keyinfo=ntohs(eap_key->key_info); + if (eth_proto == ETHER_PROTOCOL_TYPE_EAP + && priv->wpa.mic_failure.failure > 0) { + aa1x_hdr = (struct ieee802_1x_hdr *)(eth_hdr + 1); + if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY) { + eap_key = (struct wpa_eapol_key *)(aa1x_hdr + 1); + keyinfo = ntohs(eap_key->key_info); } } - if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len){ - if(eth_proto == ETHER_PROTOCOL_TYPE_EAP && !(priv->wpa.key[1].key_len) && - !(priv->wpa.key[2].key_len) && !(priv->wpa.key[3].key_len)){ - pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); /* no encryption */ - } - else{ - if(priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP){ - MichaelMICFunction( &michel_mic, - (uint8_t*)priv->wpa.key[0].tx_mic_key, - (uint8_t*)&pp->data[0], - (int)packet_len, - (uint8_t)0, /* priority */ - (uint8_t*)michel_mic.Result ); + if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len) { + if (eth_proto == ETHER_PROTOCOL_TYPE_EAP + && !(priv->wpa.key[1].key_len) + && !(priv->wpa.key[2].key_len) + && !(priv->wpa.key[3].key_len)) { + pp->auth_type = cpu_to_le16((uint16_t) TYPE_AUTH); /* no encryption */ + } else { + if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) { + MichaelMICFunction(&michel_mic, (uint8_t *) priv->wpa.key[0].tx_mic_key, (uint8_t *) & pp->data[0], (int)packet_len, (uint8_t) 0, /* priority */ + (uint8_t *) michel_mic. + Result); memcpy(p, michel_mic.Result, 8); length += 8; packet_len += 8; p += 8; - pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); + pp->auth_type = + cpu_to_le16((uint16_t) TYPE_DATA); - }else if(priv->wpa.pairwise_suite == IW_AUTH_CIPHER_CCMP){ - pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); + } else if (priv->wpa.pairwise_suite == + IW_AUTH_CIPHER_CCMP) { + pp->auth_type = + cpu_to_le16((uint16_t) TYPE_DATA); } } - } - else{ - if(eth_proto == ETHER_PROTOCOL_TYPE_EAP) - pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); + } else { + if (eth_proto == ETHER_PROTOCOL_TYPE_EAP) + pp->auth_type = cpu_to_le16((uint16_t) TYPE_AUTH); else - pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); + pp->auth_type = cpu_to_le16((uint16_t) TYPE_DATA); } /* header value set */ - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size)+packet_len)); - pp->header.event = cpu_to_le16((uint16_t)HIF_DATA_REQ); + pp->header.size = + cpu_to_le16((uint16_t) + (sizeof(*pp) - sizeof(pp->header.size) + packet_len)); + pp->header.event = cpu_to_le16((uint16_t) HIF_DATA_REQ); /* tx request */ - result = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + packet_len), - (void *)send_packet_complete, (void *)priv, (void *)packet); + result = + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + packet_len), + (void *)send_packet_complete, (void *)priv, + (void *)packet); /* MIC FAILUER REPORT check */ - if(eth_proto == ETHER_PROTOCOL_TYPE_EAP && 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); + if (eth_proto == ETHER_PROTOCOL_TYPE_EAP + && 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); hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST); } - if(priv->wpa.mic_failure.failure==2) - priv->wpa.mic_failure.stop=1; + if (priv->wpa.mic_failure.failure == 2) + priv->wpa.mic_failure.stop = 1; } return result; @@ -1231,83 +1308,92 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) } }while(0) static -void hostif_mib_get_request( struct ks_wlan_private *priv, unsigned long mib_attribute) +void hostif_mib_get_request(struct ks_wlan_private *priv, + unsigned long mib_attribute) { struct hostif_mib_get_request_t *pp; DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_mib_get_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_mib_get_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_GET_REQ); - pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_MIB_GET_REQ); + pp->mib_attribute = cpu_to_le32((uint32_t) mib_attribute); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_mib_set_request( struct ks_wlan_private *priv, unsigned long mib_attribute, - unsigned short size, unsigned short type, - void *vp ) +void hostif_mib_set_request(struct ks_wlan_private *priv, + unsigned long mib_attribute, unsigned short size, + unsigned short type, void *vp) { struct hostif_mib_set_request_t *pp; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); if (priv->dev_state < DEVICE_STATE_BOOT) { - DPRINTK(3,"DeviceRemove\n"); + DPRINTK(3, "DeviceRemove\n"); return; } /* make primitive */ - pp = (struct hostif_mib_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)+size), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_mib_set_request_t *) + kmalloc(hif_align_size(sizeof(*pp) + size), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size)+size)); - pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_SET_REQ); - pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute); - pp->mib_value.size = cpu_to_le16((uint16_t)size); - pp->mib_value.type = cpu_to_le16((uint16_t)type); + pp->header.size = + cpu_to_le16((uint16_t) + (sizeof(*pp) - sizeof(pp->header.size) + size)); + pp->header.event = cpu_to_le16((uint16_t) HIF_MIB_SET_REQ); + pp->mib_attribute = cpu_to_le32((uint32_t) mib_attribute); + pp->mib_value.size = cpu_to_le16((uint16_t) size); + pp->mib_value.type = cpu_to_le16((uint16_t) type); memcpy(&pp->mib_value.body, vp, size); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL, + NULL); } static -void hostif_start_request( struct ks_wlan_private *priv, unsigned char mode ) +void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode) { struct hostif_start_request_t *pp; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_start_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_start_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_START_REQ); - pp->mode = cpu_to_le16((uint16_t)mode); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_START_REQ); + pp->mode = cpu_to_le16((uint16_t) mode); /* send to device request */ ps_confirm_wait_inc(priv); ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); priv->aplist.size = 0; - priv->scan_ind_count=0; + priv->scan_ind_count = 0; } static @@ -1316,35 +1402,38 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) struct hostif_ps_adhoc_set_request_t *pp; uint16_t capability; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_ps_adhoc_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_ps_adhoc_set_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } memset(pp, 0, sizeof(*pp)); - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_PS_ADH_SET_REQ); - 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->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_PS_ADH_SET_REQ); + 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); + 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) { + 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 &= ~(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 */ } - pp->capability = cpu_to_le16((uint16_t)capability); + pp->capability = cpu_to_le16((uint16_t) capability); /* send to device request */ ps_confirm_wait_inc(priv); @@ -1357,38 +1446,42 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv) struct hostif_infrastructure_set_request_t *pp; uint16_t capability; - DPRINTK(3, "ssid.size=%d \n",priv->reg.ssid.size); + DPRINTK(3, "ssid.size=%d \n", priv->reg.ssid.size); /* make primitive */ - pp = (struct hostif_infrastructure_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_infrastructure_set_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET_REQ); - 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->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_INFRA_SET_REQ); + 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); + 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) { + 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 */ + 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->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; @@ -1403,16 +1496,16 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv) 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){ + if (priv->reg.phy_type == D_11G_ONLY_MODE) { pp->channel_list.size = 13; - }else{ + } else { pp->channel_list.body[13] = 14; pp->channel_list.size = 14; } /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)),NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) @@ -1420,38 +1513,42 @@ void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) struct hostif_infrastructure_set2_request_t *pp; uint16_t capability; - DPRINTK(2, "ssid.size=%d \n",priv->reg.ssid.size); + DPRINTK(2, "ssid.size=%d \n", priv->reg.ssid.size); /* make primitive */ - pp = (struct hostif_infrastructure_set2_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_infrastructure_set2_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET2_REQ); - 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->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_INFRA_SET2_REQ); + 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); + 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) { + 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 */ + 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->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; @@ -1466,9 +1563,9 @@ void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) 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){ + if (priv->reg.phy_type == D_11G_ONLY_MODE) { pp->channel_list.size = 13; - }else{ + } else { pp->channel_list.body[13] = 14; pp->channel_list.size = 14; } @@ -1477,7 +1574,7 @@ void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)),NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static @@ -1489,38 +1586,41 @@ void hostif_adhoc_set_request(struct ks_wlan_private *priv) DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_adhoc_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_adhoc_set_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } memset(pp, 0, sizeof(*pp)); - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ); - 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->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_ADH_SET_REQ); + 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); + 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) { + 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 */ + 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->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, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static @@ -1532,33 +1632,36 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv) DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_adhoc_set2_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_adhoc_set2_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } memset(pp, 0, sizeof(*pp)); - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ); - 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->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_ADH_SET_REQ); + 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); + 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) { + 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 */ + 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->capability = cpu_to_le16((uint16_t) capability); pp->channel_list.body[0] = priv->reg.channel; pp->channel_list.size = 1; @@ -1566,130 +1669,146 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_stop_request( struct ks_wlan_private *priv ) +void hostif_stop_request(struct ks_wlan_private *priv) { struct hostif_stop_request_t *pp; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_stop_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_stop_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_STOP_REQ); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_phy_information_request( struct ks_wlan_private *priv ) +void hostif_phy_information_request(struct ks_wlan_private *priv) { struct hostif_phy_information_request_t *pp; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_phy_information_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_phy_information_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_PHY_INFO_REQ); - if(priv->reg.phy_info_timer){ - pp->type = cpu_to_le16((uint16_t)TIME_TYPE); - pp->time = cpu_to_le16((uint16_t)(priv->reg.phy_info_timer)); - }else{ - pp->type = cpu_to_le16((uint16_t)NORMAL_TYPE); - pp->time = cpu_to_le16((uint16_t)0); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_PHY_INFO_REQ); + if (priv->reg.phy_info_timer) { + pp->type = cpu_to_le16((uint16_t) TIME_TYPE); + pp->time = cpu_to_le16((uint16_t) (priv->reg.phy_info_timer)); + } else { + pp->type = cpu_to_le16((uint16_t) NORMAL_TYPE); + pp->time = cpu_to_le16((uint16_t) 0); } /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_power_mngmt_request( struct ks_wlan_private *priv, unsigned long mode, - unsigned long wake_up, unsigned long receiveDTIMs ) +void hostif_power_mngmt_request(struct ks_wlan_private *priv, + unsigned long mode, unsigned long wake_up, + unsigned long receiveDTIMs) { struct hostif_power_mngmt_request_t *pp; - DPRINTK(3,"mode=%lu wake_up=%lu receiveDTIMs=%lu\n",mode,wake_up,receiveDTIMs); + DPRINTK(3, "mode=%lu wake_up=%lu receiveDTIMs=%lu\n", mode, wake_up, + receiveDTIMs); /* make primitive */ - pp = (struct hostif_power_mngmt_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_power_mngmt_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_POWERMGT_REQ); - pp->mode = cpu_to_le32((uint32_t)mode); - pp->wake_up = cpu_to_le32((uint32_t)wake_up); - pp->receiveDTIMs = cpu_to_le32((uint32_t)receiveDTIMs); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_POWERMGT_REQ); + pp->mode = cpu_to_le32((uint32_t) mode); + pp->wake_up = cpu_to_le32((uint32_t) wake_up); + pp->receiveDTIMs = cpu_to_le32((uint32_t) receiveDTIMs); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_sleep_request( struct ks_wlan_private *priv, unsigned long mode) +void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode) { struct hostif_sleep_request_t *pp; - DPRINTK(3,"mode=%lu \n",mode); + DPRINTK(3, "mode=%lu \n", mode); - if(mode == SLP_SLEEP){ + if (mode == SLP_SLEEP) { /* make primitive */ - pp = (struct hostif_sleep_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_sleep_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_SLEEP_REQ); + pp->header.size = + cpu_to_le16((uint16_t) + (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_SLEEP_REQ); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); - }else if(mode == SLP_ACTIVE){ - atomic_set(&priv->sleepstatus.wakeup_request,1); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); - }else{ - DPRINTK(3,"invalid mode %ld \n", mode); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, + NULL); + } else if (mode == SLP_ACTIVE) { + atomic_set(&priv->sleepstatus.wakeup_request, 1); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); + } else { + DPRINTK(3, "invalid mode %ld \n", mode); return; } } - static -void hostif_bss_scan_request( struct ks_wlan_private *priv, unsigned long scan_type , uint8_t *scan_ssid, uint8_t scan_ssid_len) +void hostif_bss_scan_request(struct ks_wlan_private *priv, + unsigned long scan_type, uint8_t * scan_ssid, + uint8_t scan_ssid_len) { struct hostif_bss_scan_request_t *pp; - DPRINTK(2,"\n"); + DPRINTK(2, "\n"); /* make primitive */ - pp = (struct hostif_bss_scan_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_bss_scan_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_SCAN_REQ); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_SCAN_REQ); pp->scan_type = scan_type; - pp->ch_time_min = cpu_to_le32((uint32_t)110); /* default value */ - pp->ch_time_max = cpu_to_le32((uint32_t)130); /* default value */ + pp->ch_time_min = cpu_to_le32((uint32_t) 110); /* default value */ + pp->ch_time_max = cpu_to_le32((uint32_t) 130); /* default value */ pp->channel_list.body[0] = 1; pp->channel_list.body[1] = 8; pp->channel_list.body[2] = 2; @@ -1703,57 +1822,60 @@ void hostif_bss_scan_request( struct ks_wlan_private *priv, unsigned long scan_t 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){ + if (priv->reg.phy_type == D_11G_ONLY_MODE) { pp->channel_list.size = 13; - }else{ + } else { pp->channel_list.body[13] = 14; pp->channel_list.size = 14; } pp->ssid.size = 0; /* specified SSID SCAN */ - if(scan_ssid_len > 0 && scan_ssid_len <= 32){ + if (scan_ssid_len > 0 && scan_ssid_len <= 32) { pp->ssid.size = scan_ssid_len; memcpy(&pp->ssid.body[0], scan_ssid, scan_ssid_len); } - /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); priv->aplist.size = 0; - priv->scan_ind_count=0; + priv->scan_ind_count = 0; } static -void hostif_mic_failure_request( struct ks_wlan_private *priv, unsigned short failure_count, - unsigned short timer ) +void hostif_mic_failure_request(struct ks_wlan_private *priv, + unsigned short failure_count, + unsigned short timer) { struct hostif_mic_failure_request_t *pp; - DPRINTK(3,"count=%d :: timer=%d\n",failure_count,timer); + DPRINTK(3, "count=%d :: timer=%d\n", failure_count, timer); /* make primitive */ - pp = (struct hostif_mic_failure_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_mic_failure_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_MIC_FAILURE_REQ); - pp->failure_count = cpu_to_le16((uint16_t)failure_count); - pp->timer = cpu_to_le16((uint16_t)timer); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_MIC_FAILURE_REQ); + pp->failure_count = cpu_to_le16((uint16_t) failure_count); + pp->timer = cpu_to_le16((uint16_t) timer); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } /* Device I/O Recieve indicate */ -static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p, unsigned int size) +static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p, + unsigned int size) { if (priv->device_open_status) { - spin_lock(&priv->dev_read_lock); /* request spin lock */ + spin_lock(&priv->dev_read_lock); /* request spin lock */ priv->dev_data[atomic_read(&priv->rec_count)] = p; priv->dev_size[atomic_read(&priv->rec_count)] = size; @@ -1762,86 +1884,92 @@ static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p, unsign atomic_inc(&priv->event_count); } atomic_inc(&priv->rec_count); - if (atomic_read(&priv->rec_count)==DEVICE_STOCK_COUNT) + if (atomic_read(&priv->rec_count) == DEVICE_STOCK_COUNT) atomic_set(&priv->rec_count, 0); - wake_up_interruptible_all(&priv->devread_wait); + wake_up_interruptible_all(&priv->devread_wait); /* release spin lock */ spin_unlock(&priv->dev_read_lock); } } -void hostif_receive( struct ks_wlan_private *priv, unsigned char *p, unsigned int size ) +void hostif_receive(struct ks_wlan_private *priv, unsigned char *p, + unsigned int size) { - DPRINTK(4,"\n"); + 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 !! */ - hostif_event_check(priv); /* event check */ + if (get_WORD(priv) == priv->rx_size) { /* length check !! */ + hostif_event_check(priv); /* event check */ } } - static void hostif_sme_set_wep(struct ks_wlan_private *priv, int type) { uint32_t val; - switch(type){ + switch (type) { case SME_WEP_INDEX_REQUEST: - val = cpu_to_le32((uint32_t)(priv->reg.wep_index)); + val = cpu_to_le32((uint32_t) (priv->reg.wep_index)); hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; case SME_WEP_KEY1_REQUEST: - if(!priv->wpa.wpa_enabled) - hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1, - priv->reg.wep_key[0].size, MIB_VALUE_TYPE_OSTRING, - &priv->reg.wep_key[0].val[0] ); + if (!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, + DOT11_WEP_DEFAULT_KEY_VALUE1, + priv->reg.wep_key[0].size, + MIB_VALUE_TYPE_OSTRING, + &priv->reg.wep_key[0].val[0]); break; case SME_WEP_KEY2_REQUEST: - if(!priv->wpa.wpa_enabled) - hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2, - priv->reg.wep_key[1].size, MIB_VALUE_TYPE_OSTRING, + if (!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, + DOT11_WEP_DEFAULT_KEY_VALUE2, + priv->reg.wep_key[1].size, + MIB_VALUE_TYPE_OSTRING, &priv->reg.wep_key[1].val[0]); break; case SME_WEP_KEY3_REQUEST: - if(!priv->wpa.wpa_enabled) - hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3, - priv->reg.wep_key[2].size, MIB_VALUE_TYPE_OSTRING, - &priv->reg.wep_key[2].val[0] ); + if (!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, + DOT11_WEP_DEFAULT_KEY_VALUE3, + priv->reg.wep_key[2].size, + MIB_VALUE_TYPE_OSTRING, + &priv->reg.wep_key[2].val[0]); break; case SME_WEP_KEY4_REQUEST: - if(!priv->wpa.wpa_enabled) - hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4, - priv->reg.wep_key[3].size, MIB_VALUE_TYPE_OSTRING, + if (!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, + DOT11_WEP_DEFAULT_KEY_VALUE4, + priv->reg.wep_key[3].size, + MIB_VALUE_TYPE_OSTRING, &priv->reg.wep_key[3].val[0]); break; case SME_WEP_FLAG_REQUEST: - val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked)); + val = cpu_to_le32((uint32_t) (priv->reg.privacy_invoked)); hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED, - sizeof(val), MIB_VALUE_TYPE_BOOL, - &val ); + sizeof(val), MIB_VALUE_TYPE_BOOL, &val); break; } - return ; + return; } struct wpa_suite_t { unsigned short size; unsigned char suite[4][CIPHER_ID_LEN]; -} __attribute__((packed)); +} __attribute__ ((packed)); struct rsn_mode_t { uint32_t rsn_mode; uint16_t rsn_capability; -} __attribute__((packed)); +} __attribute__ ((packed)); static void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type) @@ -1850,140 +1978,172 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type) struct rsn_mode_t rsn_mode; uint32_t val; - memset(&wpa_suite,0,sizeof(wpa_suite)); + memset(&wpa_suite, 0, sizeof(wpa_suite)); - switch(type){ + switch (type) { case SME_RSN_UCAST_REQUEST: - wpa_suite.size=cpu_to_le16((uint16_t)1); - switch(priv->wpa.pairwise_suite){ + wpa_suite.size = cpu_to_le16((uint16_t) 1); + switch (priv->wpa.pairwise_suite) { case IW_AUTH_CIPHER_NONE: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_NONE,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_NONE,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_NONE, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_WEP40: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP40,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP40,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_TKIP: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_TKIP,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_TKIP,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_CCMP: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_CCMP,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_CCMP,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_WEP104: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP104,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP104,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN); break; } hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER, - sizeof(wpa_suite.size)+CIPHER_ID_LEN*wpa_suite.size, + sizeof(wpa_suite.size) + + CIPHER_ID_LEN * wpa_suite.size, MIB_VALUE_TYPE_OSTRING, &wpa_suite); break; case SME_RSN_MCAST_REQUEST: - switch(priv->wpa.group_suite){ + switch (priv->wpa.group_suite) { case IW_AUTH_CIPHER_NONE: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_NONE,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_NONE,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_NONE, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_WEP40: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP40,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP40,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_TKIP: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_TKIP,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_TKIP,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_CCMP: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_CCMP,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_CCMP,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_WEP104: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP104,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP104,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN); break; } hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER, CIPHER_ID_LEN, MIB_VALUE_TYPE_OSTRING, - &wpa_suite.suite[0][0] ); + &wpa_suite.suite[0][0]); break; case SME_RSN_AUTH_REQUEST: - wpa_suite.size=cpu_to_le16((uint16_t)1); - switch(priv->wpa.key_mgmt_suite){ + wpa_suite.size = cpu_to_le16((uint16_t) 1); + switch (priv->wpa.key_mgmt_suite) { case IW_AUTH_KEY_MGMT_802_1X: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_1X,KEY_MGMT_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA2_1X, KEY_MGMT_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_1X,KEY_MGMT_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA_1X, KEY_MGMT_ID_LEN); break; case IW_AUTH_KEY_MGMT_PSK: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_PSK,KEY_MGMT_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA2_PSK, KEY_MGMT_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_PSK,KEY_MGMT_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA_PSK, KEY_MGMT_ID_LEN); break; case 0: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_NONE,KEY_MGMT_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA2_NONE, KEY_MGMT_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_NONE,KEY_MGMT_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA_NONE, KEY_MGMT_ID_LEN); break; case 4: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_WPANONE,KEY_MGMT_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA2_WPANONE, + KEY_MGMT_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_WPANONE,KEY_MGMT_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA_WPANONE, + KEY_MGMT_ID_LEN); break; } hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE, - sizeof(wpa_suite.size)+KEY_MGMT_ID_LEN*wpa_suite.size, + sizeof(wpa_suite.size) + + KEY_MGMT_ID_LEN * wpa_suite.size, MIB_VALUE_TYPE_OSTRING, &wpa_suite); break; case SME_RSN_ENABLED_REQUEST: - val = cpu_to_le32((uint32_t)(priv->wpa.rsn_enabled)); + val = cpu_to_le32((uint32_t) (priv->wpa.rsn_enabled)); hostif_mib_set_request(priv, DOT11_RSN_ENABLED, - sizeof(val), MIB_VALUE_TYPE_BOOL, - &val ); + sizeof(val), MIB_VALUE_TYPE_BOOL, &val); break; case SME_RSN_MODE_REQUEST: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2){ - rsn_mode.rsn_mode = cpu_to_le32((uint32_t)RSN_MODE_WPA2); - rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0); - } - else if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA){ - rsn_mode.rsn_mode = cpu_to_le32((uint32_t)RSN_MODE_WPA); - rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0); - } - else{ - rsn_mode.rsn_mode = cpu_to_le32((uint32_t)RSN_MODE_NONE); - rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) { + rsn_mode.rsn_mode = + cpu_to_le32((uint32_t) RSN_MODE_WPA2); + rsn_mode.rsn_capability = cpu_to_le16((uint16_t) 0); + } else if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) { + rsn_mode.rsn_mode = + cpu_to_le32((uint32_t) RSN_MODE_WPA); + rsn_mode.rsn_capability = cpu_to_le16((uint16_t) 0); + } else { + rsn_mode.rsn_mode = + cpu_to_le32((uint32_t) RSN_MODE_NONE); + rsn_mode.rsn_capability = cpu_to_le16((uint16_t) 0); } - hostif_mib_set_request(priv, LOCAL_RSN_MODE,sizeof(rsn_mode), - MIB_VALUE_TYPE_OSTRING,&rsn_mode ); + hostif_mib_set_request(priv, LOCAL_RSN_MODE, sizeof(rsn_mode), + MIB_VALUE_TYPE_OSTRING, &rsn_mode); break; } @@ -1995,64 +2155,70 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv) { unsigned char rate_size; unsigned char rate_octet[RATE_SET_MAX_SIZE]; - int i=0; + int i = 0; - /* rate setting if rate segging is auto for changing phy_type (#94)*/ - if(priv->reg.tx_rate == TX_RATE_FULL_AUTO){ - if(priv->reg.phy_type == D_11B_ONLY_MODE){ + /* rate setting if rate segging is auto for changing phy_type (#94) */ + if (priv->reg.tx_rate == TX_RATE_FULL_AUTO) { + if (priv->reg.phy_type == D_11B_ONLY_MODE) { priv->reg.rate_set.body[3] = TX_RATE_11M; priv->reg.rate_set.body[2] = TX_RATE_5M; - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; priv->reg.rate_set.size = 4; - }else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ priv->reg.rate_set.body[11] = TX_RATE_54M; priv->reg.rate_set.body[10] = TX_RATE_48M; priv->reg.rate_set.body[9] = TX_RATE_36M; priv->reg.rate_set.body[8] = TX_RATE_18M; priv->reg.rate_set.body[7] = TX_RATE_9M; - priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; - priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; - priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; - priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; - priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE; + priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; priv->reg.rate_set.size = 12; } } /* rate mask by phy setting */ - if(priv->reg.phy_type == D_11B_ONLY_MODE){ - for(i=0;ireg.rate_set.size;i++){ - if(IS_11B_RATE(priv->reg.rate_set.body[i])){ - if((priv->reg.rate_set.body[i] & RATE_MASK) >= TX_RATE_5M) - rate_octet[i] = priv->reg.rate_set.body[i] & RATE_MASK ; + if (priv->reg.phy_type == D_11B_ONLY_MODE) { + for (i = 0; i < priv->reg.rate_set.size; i++) { + if (IS_11B_RATE(priv->reg.rate_set.body[i])) { + if ((priv->reg.rate_set.body[i] & RATE_MASK) >= + TX_RATE_5M) + rate_octet[i] = + priv->reg.rate_set. + body[i] & RATE_MASK; else - rate_octet[i] = priv->reg.rate_set.body[i]; - } - else + rate_octet[i] = + priv->reg.rate_set.body[i]; + } else break; } - }else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ - for(i=0;ireg.rate_set.size;i++){ - if(IS_11BG_RATE(priv->reg.rate_set.body[i])){ - if(IS_OFDM_EXT_RATE(priv->reg.rate_set.body[i])) - rate_octet[i] = priv->reg.rate_set.body[i] & RATE_MASK ; + } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + for (i = 0; i < priv->reg.rate_set.size; i++) { + if (IS_11BG_RATE(priv->reg.rate_set.body[i])) { + if (IS_OFDM_EXT_RATE + (priv->reg.rate_set.body[i])) + rate_octet[i] = + priv->reg.rate_set. + body[i] & RATE_MASK; else - rate_octet[i] = priv->reg.rate_set.body[i]; - } - else + rate_octet[i] = + priv->reg.rate_set.body[i]; + } else break; } } rate_size = i; - if(rate_size==0){ - if(priv->reg.phy_type == D_11G_ONLY_MODE) - rate_octet[0]=TX_RATE_6M | BASIC_RATE; + if (rate_size == 0) { + if (priv->reg.phy_type == D_11G_ONLY_MODE) + rate_octet[0] = TX_RATE_6M | BASIC_RATE; else - rate_octet[0]=TX_RATE_2M | BASIC_RATE; + rate_octet[0] = TX_RATE_2M | BASIC_RATE; rate_size = 1; } @@ -2060,84 +2226,93 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv) priv->reg.rate_set.size = rate_size; memcpy(&priv->reg.rate_set.body[0], &rate_octet[0], rate_size); - switch ( priv->reg.operation_mode ) { + switch (priv->reg.operation_mode) { case MODE_PSEUDO_ADHOC: /* Pseudo Ad-Hoc mode */ hostif_ps_adhoc_set_request(priv); break; case MODE_INFRASTRUCTURE: /* Infrastructure mode */ - if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) { + if (!is_valid_ether_addr((u8 *) priv->reg.bssid)) { hostif_infrastructure_set_request(priv); - } - else { + } else { hostif_infrastructure_set2_request(priv); - DPRINTK(2, "Infra bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", - priv->reg.bssid[0],priv->reg.bssid[1],priv->reg.bssid[2], - priv->reg.bssid[3],priv->reg.bssid[4],priv->reg.bssid[5]); + DPRINTK(2, + "Infra bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->reg.bssid[0], priv->reg.bssid[1], + priv->reg.bssid[2], priv->reg.bssid[3], + priv->reg.bssid[4], priv->reg.bssid[5]); } break; case MODE_ADHOC: /* IEEE802.11 Ad-Hoc mode */ - if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) { + if (!is_valid_ether_addr((u8 *) priv->reg.bssid)) { hostif_adhoc_set_request(priv); - } - else { + } else { hostif_adhoc_set2_request(priv); - DPRINTK(2, "Adhoc bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", - priv->reg.bssid[0],priv->reg.bssid[1],priv->reg.bssid[2], - priv->reg.bssid[3],priv->reg.bssid[4],priv->reg.bssid[5]); + DPRINTK(2, + "Adhoc bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->reg.bssid[0], priv->reg.bssid[1], + priv->reg.bssid[2], priv->reg.bssid[3], + priv->reg.bssid[4], priv->reg.bssid[5]); } break; default: break; } - return ; + return; } static void hostif_sme_multicast_set(struct ks_wlan_private *priv) { - struct net_device *dev = priv->net_dev; + struct net_device *dev = priv->net_dev; int mc_count; struct netdev_hw_addr *ha; - char set_address[NIC_MAX_MCAST_LIST*ETH_ALEN]; + char set_address[NIC_MAX_MCAST_LIST * ETH_ALEN]; unsigned long filter_type; int i = 0; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); spin_lock(&priv->multicast_spin); - memset(set_address, 0, NIC_MAX_MCAST_LIST*ETH_ALEN); - - if (dev->flags & IFF_PROMISC ){ - filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_PROMISC); - hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), - MIB_VALUE_TYPE_BOOL, &filter_type); - } - else if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) || (dev->flags & IFF_ALLMULTI)){ - filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCASTALL); - hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), - MIB_VALUE_TYPE_BOOL, &filter_type); - } - else { - if (priv->sme_i.sme_flag & SME_MULTICAST){ + memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN); + + if (dev->flags & IFF_PROMISC) { + filter_type = cpu_to_le32((uint32_t) MCAST_FILTER_PROMISC); + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, + sizeof(filter_type), MIB_VALUE_TYPE_BOOL, + &filter_type); + } else if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) + || (dev->flags & IFF_ALLMULTI)) { + filter_type = cpu_to_le32((uint32_t) MCAST_FILTER_MCASTALL); + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, + sizeof(filter_type), MIB_VALUE_TYPE_BOOL, + &filter_type); + } else { + if (priv->sme_i.sme_flag & SME_MULTICAST) { mc_count = netdev_mc_count(dev); netdev_for_each_mc_addr(ha, dev) { - memcpy(&set_address[i*ETH_ALEN], ha->addr, ETH_ALEN); + memcpy(&set_address[i * ETH_ALEN], ha->addr, + ETH_ALEN); i++; } priv->sme_i.sme_flag &= ~SME_MULTICAST; hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS, - (ETH_ALEN*mc_count), MIB_VALUE_TYPE_OSTRING, &set_address[0]); - }else { - filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCAST); + (ETH_ALEN * mc_count), + MIB_VALUE_TYPE_OSTRING, + &set_address[0]); + } else { + filter_type = + cpu_to_le32((uint32_t) MCAST_FILTER_MCAST); priv->sme_i.sme_flag |= SME_MULTICAST; - hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), - MIB_VALUE_TYPE_BOOL, &filter_type); + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, + sizeof(filter_type), + MIB_VALUE_TYPE_BOOL, + &filter_type); } } @@ -2148,17 +2323,17 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv) static void hostif_sme_powermgt_set(struct ks_wlan_private *priv) { - unsigned long mode,wake_up,receiveDTIMs ; + unsigned long mode, wake_up, receiveDTIMs; - DPRINTK(3,"\n"); - switch(priv->reg.powermgt){ + DPRINTK(3, "\n"); + switch (priv->reg.powermgt) { case POWMGT_ACTIVE_MODE: mode = POWER_ACTIVE; wake_up = 0; receiveDTIMs = 0; break; case POWMGT_SAVE1_MODE: - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) { mode = POWER_SAVE; wake_up = 0; receiveDTIMs = 0; @@ -2169,7 +2344,7 @@ void hostif_sme_powermgt_set(struct ks_wlan_private *priv) } break; case POWMGT_SAVE2_MODE: - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) { mode = POWER_SAVE; wake_up = 0; receiveDTIMs = 1; @@ -2193,8 +2368,8 @@ void hostif_sme_powermgt_set(struct ks_wlan_private *priv) static void hostif_sme_sleep_set(struct ks_wlan_private *priv) { - DPRINTK(3,"\n"); - switch(priv->sleep_mode){ + DPRINTK(3, "\n"); + switch (priv->sleep_mode) { case SLP_SLEEP: hostif_sleep_request(priv, priv->sleep_mode); break; @@ -2212,53 +2387,55 @@ static void hostif_sme_set_key(struct ks_wlan_private *priv, int type) { uint32_t val; - switch(type){ + switch (type) { case SME_SET_FLAG: - val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked)); + val = cpu_to_le32((uint32_t) (priv->reg.privacy_invoked)); hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED, - sizeof(val), MIB_VALUE_TYPE_BOOL, - &val ); + sizeof(val), MIB_VALUE_TYPE_BOOL, &val); break; case SME_SET_TXKEY: - val = cpu_to_le32((uint32_t)(priv->wpa.txkey)); + val = cpu_to_le32((uint32_t) (priv->wpa.txkey)); hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; case SME_SET_KEY1: hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1, - priv->wpa.key[0].key_len, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[0].key_val[0] ); + priv->wpa.key[0].key_len, + MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[0].key_val[0]); break; case SME_SET_KEY2: hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2, - priv->wpa.key[1].key_len, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[1].key_val[0] ); + priv->wpa.key[1].key_len, + MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[1].key_val[0]); break; case SME_SET_KEY3: hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3, - priv->wpa.key[2].key_len, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[2].key_val[0] ); + priv->wpa.key[2].key_len, + MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[2].key_val[0]); break; case SME_SET_KEY4: hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4, - priv->wpa.key[3].key_len, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[3].key_val[0] ); + priv->wpa.key[3].key_len, + MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[3].key_val[0]); break; case SME_SET_PMK_TSC: hostif_mib_set_request(priv, DOT11_PMK_TSC, WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[0].rx_seq[0] ); + &priv->wpa.key[0].rx_seq[0]); break; case SME_SET_GMK1_TSC: hostif_mib_set_request(priv, DOT11_GMK1_TSC, WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[1].rx_seq[0] ); + &priv->wpa.key[1].rx_seq[0]); break; case SME_SET_GMK2_TSC: hostif_mib_set_request(priv, DOT11_GMK2_TSC, WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[2].rx_seq[0] ); + &priv->wpa.key[2].rx_seq[0]); break; } return; @@ -2270,28 +2447,31 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv) struct pmk_cache_t { uint16_t size; struct { - uint8_t bssid[ETH_ALEN]; - uint8_t pmkid[IW_PMKID_LEN]; - } __attribute__((packed)) list[PMK_LIST_MAX]; - } __attribute__((packed)) pmkcache; + uint8_t bssid[ETH_ALEN]; + uint8_t pmkid[IW_PMKID_LEN]; + } __attribute__ ((packed)) list[PMK_LIST_MAX]; + } __attribute__ ((packed)) pmkcache; struct pmk_t *pmk; struct list_head *ptr; int i; - DPRINTK(4,"pmklist.size=%d\n",priv->pmklist.size); - i=0; - list_for_each(ptr, &priv->pmklist.head){ + DPRINTK(4, "pmklist.size=%d\n", priv->pmklist.size); + i = 0; + list_for_each(ptr, &priv->pmklist.head) { pmk = list_entry(ptr, struct pmk_t, list); - if(ibssid, ETH_ALEN); - memcpy(pmkcache.list[i].pmkid, pmk->pmkid, IW_PMKID_LEN); + memcpy(pmkcache.list[i].pmkid, pmk->pmkid, + IW_PMKID_LEN); i++; } } - pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size)); + pmkcache.size = cpu_to_le16((uint16_t) (priv->pmklist.size)); hostif_mib_set_request(priv, LOCAL_PMK, - sizeof(priv->pmklist.size)+(ETH_ALEN+IW_PMKID_LEN)*(priv->pmklist.size), - MIB_VALUE_TYPE_OSTRING,&pmkcache ); + sizeof(priv->pmklist.size) + (ETH_ALEN + + IW_PMKID_LEN) * + (priv->pmklist.size), MIB_VALUE_TYPE_OSTRING, + &pmkcache); } /* execute sme */ @@ -2300,10 +2480,10 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) { uint32_t val; - DPRINTK(3,"event=%d\n",event); + DPRINTK(3, "event=%d\n", event); switch (event) { case SME_START: - if ( priv->dev_state == DEVICE_STATE_BOOT ){ + if (priv->dev_state == DEVICE_STATE_BOOT) { hostif_mib_get_request(priv, DOT11_MAC_ADDRESS); } break; @@ -2312,10 +2492,12 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) break; case SME_MACADDRESS_SET_REQUEST: hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN, - MIB_VALUE_TYPE_OSTRING, &priv->eth_addr[0]); + MIB_VALUE_TYPE_OSTRING, + &priv->eth_addr[0]); break; case SME_BSS_SCAN_REQUEST: - hostif_bss_scan_request(priv, priv->reg.scan_type, priv->scan_ssid, priv->scan_ssid_len); + hostif_bss_scan_request(priv, priv->reg.scan_type, + priv->scan_ssid, priv->scan_ssid_len); break; case SME_POW_MNGMT_REQUEST: hostif_sme_powermgt_set(priv); @@ -2324,30 +2506,36 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) hostif_phy_information_request(priv); break; case SME_MIC_FAILURE_REQUEST: - if(priv->wpa.mic_failure.failure == 1){ - hostif_mic_failure_request(priv, priv->wpa.mic_failure.failure-1, 0); - }else if(priv->wpa.mic_failure.failure == 2){ - hostif_mic_failure_request(priv, priv->wpa.mic_failure.failure-1, - priv->wpa.mic_failure.counter); - }else - DPRINTK(4,"SME_MIC_FAILURE_REQUEST: failure count=%u error?\n", + if (priv->wpa.mic_failure.failure == 1) { + hostif_mic_failure_request(priv, + priv->wpa.mic_failure. + failure - 1, 0); + } else if (priv->wpa.mic_failure.failure == 2) { + hostif_mic_failure_request(priv, + 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); break; case SME_MIC_FAILURE_CONFIRM: - if(priv->wpa.mic_failure.failure == 2){ - if(priv->wpa.mic_failure.stop) + if (priv->wpa.mic_failure.failure == 2) { + if (priv->wpa.mic_failure.stop) priv->wpa.mic_failure.stop = 0; priv->wpa.mic_failure.failure = 0; - hostif_start_request( priv, priv->reg.operation_mode ); + hostif_start_request(priv, priv->reg.operation_mode); } break; case SME_GET_MAC_ADDRESS: - if ( priv->dev_state == DEVICE_STATE_BOOT ){ + if (priv->dev_state == DEVICE_STATE_BOOT) { hostif_mib_get_request(priv, DOT11_PRODUCT_VERSION); } break; case SME_GET_PRODUCT_VERSION: - if ( priv->dev_state == DEVICE_STATE_BOOT ){ + if (priv->dev_state == DEVICE_STATE_BOOT) { priv->dev_state = DEVICE_STATE_PREINIT; } break; @@ -2355,33 +2543,40 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) hostif_stop_request(priv); break; case SME_RTS_THRESHOLD_REQUEST: - val = cpu_to_le32((uint32_t)(priv->reg.rts)); + val = cpu_to_le32((uint32_t) (priv->reg.rts)); hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; case SME_FRAGMENTATION_THRESHOLD_REQUEST: - val = cpu_to_le32((uint32_t)(priv->reg.fragment)); + val = cpu_to_le32((uint32_t) (priv->reg.fragment)); hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; - case SME_WEP_INDEX_REQUEST: case SME_WEP_KEY1_REQUEST: - case SME_WEP_KEY2_REQUEST: case SME_WEP_KEY3_REQUEST: - case SME_WEP_KEY4_REQUEST: case SME_WEP_FLAG_REQUEST: - hostif_sme_set_wep(priv,event); + case SME_WEP_INDEX_REQUEST: + case SME_WEP_KEY1_REQUEST: + case SME_WEP_KEY2_REQUEST: + case SME_WEP_KEY3_REQUEST: + case SME_WEP_KEY4_REQUEST: + case SME_WEP_FLAG_REQUEST: + hostif_sme_set_wep(priv, event); break; - case SME_RSN_UCAST_REQUEST: case SME_RSN_MCAST_REQUEST: - case SME_RSN_AUTH_REQUEST: case SME_RSN_ENABLED_REQUEST: + case SME_RSN_UCAST_REQUEST: + case SME_RSN_MCAST_REQUEST: + case SME_RSN_AUTH_REQUEST: + case SME_RSN_ENABLED_REQUEST: case SME_RSN_MODE_REQUEST: - hostif_sme_set_rsn(priv,event); + hostif_sme_set_rsn(priv, event); break; - case SME_SET_FLAG: case SME_SET_TXKEY: - case SME_SET_KEY1: case SME_SET_KEY2: - case SME_SET_KEY3: case SME_SET_KEY4: - case SME_SET_PMK_TSC: case SME_SET_GMK1_TSC: + case SME_SET_FLAG: + case SME_SET_TXKEY: + case SME_SET_KEY1: + case SME_SET_KEY2: + case SME_SET_KEY3: + case SME_SET_KEY4: + case SME_SET_PMK_TSC: + case SME_SET_GMK1_TSC: case SME_SET_GMK2_TSC: - hostif_sme_set_key(priv,event); + hostif_sme_set_key(priv, event); break; case SME_SET_PMKSA: hostif_sme_set_pmksa(priv); @@ -2390,7 +2585,8 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) case SME_WPS_ENABLE_REQUEST: hostif_mib_set_request(priv, LOCAL_WPS_ENABLE, sizeof(priv->wps.wps_enabled), - MIB_VALUE_TYPE_INT, &priv->wps.wps_enabled ); + MIB_VALUE_TYPE_INT, + &priv->wps.wps_enabled); break; case SME_WPS_PROBE_REQUEST: hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ, @@ -2403,8 +2599,8 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) break; case SME_SET_GAIN: hostif_mib_set_request(priv, LOCAL_GAIN, - sizeof(priv->gain), MIB_VALUE_TYPE_OSTRING, - &priv->gain); + sizeof(priv->gain), + MIB_VALUE_TYPE_OSTRING, &priv->gain); break; case SME_GET_GAIN: hostif_mib_get_request(priv, LOCAL_GAIN); @@ -2414,13 +2610,13 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) hostif_mib_get_request(priv, LOCAL_EEPROM_SUM); break; case SME_START_REQUEST: - hostif_start_request( priv, priv->reg.operation_mode ); + hostif_start_request(priv, priv->reg.operation_mode); break; case SME_START_CONFIRM: /* for power save */ atomic_set(&priv->psstatus.snooze_guard, 0); - atomic_set(&priv->psstatus.confirm_wait,0); - if ( priv->dev_state == DEVICE_STATE_PREINIT ){ + atomic_set(&priv->psstatus.confirm_wait, 0); + if (priv->dev_state == DEVICE_STATE_PREINIT) { priv->dev_state = DEVICE_STATE_INIT; } /* wake_up_interruptible_all(&priv->confirm_wait); */ @@ -2430,10 +2626,9 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) hostif_sme_sleep_set(priv); break; case SME_SET_REGION: - val = cpu_to_le32((uint32_t)(priv->region)); + val = cpu_to_le32((uint32_t) (priv->region)); hostif_mib_set_request(priv, LOCAL_REGION, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; case SME_MULTICAST_CONFIRM: case SME_BSS_SCAN_CONFIRM: @@ -2442,11 +2637,16 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) case SME_STOP_CONFIRM: case SME_RTS_THRESHOLD_CONFIRM: case SME_FRAGMENTATION_THRESHOLD_CONFIRM: - case SME_WEP_INDEX_CONFIRM: case SME_WEP_KEY1_CONFIRM: - case SME_WEP_KEY2_CONFIRM: case SME_WEP_KEY3_CONFIRM: - case SME_WEP_KEY4_CONFIRM: case SME_WEP_FLAG_CONFIRM: - case SME_RSN_UCAST_CONFIRM: case SME_RSN_MCAST_CONFIRM: - case SME_RSN_AUTH_CONFIRM: case SME_RSN_ENABLED_CONFIRM: + case SME_WEP_INDEX_CONFIRM: + case SME_WEP_KEY1_CONFIRM: + case SME_WEP_KEY2_CONFIRM: + case SME_WEP_KEY3_CONFIRM: + case SME_WEP_KEY4_CONFIRM: + case SME_WEP_FLAG_CONFIRM: + case SME_RSN_UCAST_CONFIRM: + case SME_RSN_MCAST_CONFIRM: + case SME_RSN_AUTH_CONFIRM: + case SME_RSN_ENABLED_CONFIRM: case SME_RSN_MODE_CONFIRM: case SME_MODE_SET_CONFIRM: break; @@ -2457,18 +2657,21 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) } static -void hostif_sme_task( unsigned long dev ) +void hostif_sme_task(unsigned long dev) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - if(priv->dev_state >= DEVICE_STATE_BOOT){ - if (0 < cnt_smeqbody(priv) && priv->dev_state >= DEVICE_STATE_BOOT) { - hostif_sme_execute(priv, priv->sme_i.event_buff[priv->sme_i.qhead]); + if (priv->dev_state >= DEVICE_STATE_BOOT) { + if (0 < cnt_smeqbody(priv) + && priv->dev_state >= DEVICE_STATE_BOOT) { + hostif_sme_execute(priv, + priv->sme_i.event_buff[priv->sme_i. + qhead]); inc_smeqhead(priv); if (0 < cnt_smeqbody(priv)) - tasklet_schedule(&priv->sme_task); + tasklet_schedule(&priv->sme_task); } } return; @@ -2477,9 +2680,7 @@ 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"); - - + DPRINTK(3, "\n"); /* enqueue sme event */ if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) { @@ -2500,16 +2701,16 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event) } -int hostif_init( struct ks_wlan_private *priv ) +int hostif_init(struct ks_wlan_private *priv) { - int rc=0; + int rc = 0; int i; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - priv->aplist.size =0; - for(i=0;iaplist.ap[i]),0,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)); priv->infra_status = 0; priv->current_rate = 4; priv->connect_status = DISCONNECT_STATUS; @@ -2517,7 +2718,7 @@ int hostif_init( struct ks_wlan_private *priv ) spin_lock_init(&priv->multicast_spin); spin_lock_init(&priv->dev_read_lock); - init_waitqueue_head (&priv->devread_wait); + init_waitqueue_head(&priv->devread_wait); priv->dev_count = 0; atomic_set(&priv->event_count, 0); atomic_set(&priv->rec_count, 0); @@ -2539,7 +2740,7 @@ int hostif_init( struct ks_wlan_private *priv ) priv->wpa.mic_failure.stop = 0; memset(&(priv->pmklist), 0, sizeof(priv->pmklist)); INIT_LIST_HEAD(&priv->pmklist.head); - for(i=0;ipmklist.pmk[i].list); priv->sme_i.sme_status = SME_IDLE; @@ -2547,7 +2748,7 @@ int hostif_init( struct ks_wlan_private *priv ) #ifdef KS_WLAN_DEBUG priv->sme_i.max_event_count = 0; #endif - spin_lock_init(&priv->sme_i.sme_spin); + 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); @@ -2555,9 +2756,8 @@ int hostif_init( struct ks_wlan_private *priv ) return rc; } -void hostif_exit( struct ks_wlan_private *priv ) +void hostif_exit(struct ks_wlan_private *priv) { tasklet_kill(&priv->sme_task); return; } - -- 2.39.5