From 159a6770f50420cbfd05c2069a6e5c3d5cefa238 Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Tue, 26 Apr 2011 11:06:33 +0800 Subject: [PATCH] new package: move kmod-ks7010 from openwrt to here --- ks7010/Makefile | 45 + ks7010/files/ks7010sd.rom | Bin 0 -> 79136 bytes ks7010/files/ks79xx.cfg | 116 ++ ks7010/src/Kconfig | 7 + ks7010/src/Makefile | 5 + ks7010/src/eap_packet.h | 136 ++ ks7010/src/ks7010_config.c | 556 +++++++ ks7010/src/ks7010_sdio.c | 1264 +++++++++++++++ ks7010/src/ks7010_sdio.h | 165 ++ ks7010/src/ks_debug.c | 30 + ks7010/src/ks_debug.h | 30 + ks7010/src/ks_hostif.c | 2655 ++++++++++++++++++++++++++++++ ks7010/src/ks_hostif.h | 648 ++++++++ ks7010/src/ks_wlan.h | 540 ++++++ ks7010/src/ks_wlan_ioctl.h | 69 + ks7010/src/ks_wlan_net.c | 3157 ++++++++++++++++++++++++++++++++++++ ks7010/src/michael_mic.c | 143 ++ ks7010/src/michael_mic.h | 29 + 18 files changed, 9595 insertions(+) create mode 100644 ks7010/Makefile create mode 100644 ks7010/files/ks7010sd.rom create mode 100644 ks7010/files/ks79xx.cfg create mode 100644 ks7010/src/Kconfig create mode 100644 ks7010/src/Makefile create mode 100644 ks7010/src/eap_packet.h create mode 100644 ks7010/src/ks7010_config.c create mode 100644 ks7010/src/ks7010_sdio.c create mode 100644 ks7010/src/ks7010_sdio.h create mode 100644 ks7010/src/ks_debug.c create mode 100644 ks7010/src/ks_debug.h create mode 100644 ks7010/src/ks_hostif.c create mode 100644 ks7010/src/ks_hostif.h create mode 100644 ks7010/src/ks_wlan.h create mode 100644 ks7010/src/ks_wlan_ioctl.h create mode 100644 ks7010/src/ks_wlan_net.c create mode 100644 ks7010/src/michael_mic.c create mode 100644 ks7010/src/michael_mic.h diff --git a/ks7010/Makefile b/ks7010/Makefile new file mode 100644 index 0000000..4a9c745 --- /dev/null +++ b/ks7010/Makefile @@ -0,0 +1,45 @@ +# +# Copyright (C) 2008 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=ks7010 +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/ks7010 + SUBMENU:=Wireless Drivers + TITLE:=ks7010 SDIO wireless card + DEPENDS:= + FILES:=$(PKG_BUILD_DIR)/ks7010.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,10,ks7010) +endef + +MAKE_OPTS:= \ + ARCH="$(LINUX_KARCH)" \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + SUBDIRS="$(PKG_BUILD_DIR)" + +define Build/Prepare + $(INSTALL_DIR) $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ +endef + +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +define KernelPackage/ks7010/install + $(INSTALL_DIR) $(1)/lib/firmware/ + $(CP) ./files/* $(1)/lib/firmware/ +endef + +$(eval $(call KernelPackage,ks7010)) diff --git a/ks7010/files/ks7010sd.rom b/ks7010/files/ks7010sd.rom new file mode 100644 index 0000000000000000000000000000000000000000..fccc4093912df97f28df5cf4c3aae346613dff69 GIT binary patch literal 79136 zcmb@v34B!5**|{nY?(}w$s`1vgbUu8uuQ_@Ob8HUaWca)lbuBb(RznPW?1BAK_`GR z0jv|iHYlwDTmotfYFp}ST71>MAnhxtZRZkbL9`v}61BG8*6K{Qx&QCEGf6|MeLug? z=N~+C&V9~u&pG#bp7WgNdCqY(A)oRH-$L*s)FW`y88QL!EePaa{wkNwv^(sa!?Aij zS6%MrIAU8<#JRT!%?*L|{wA)(ZlBIou50F&HZ`pCZAMOmu%*G*6xebPN1F;RFU=Jt z%li@WsSht8ejD-c5uZbR74a_-cOgEF_%wr%^VElg>v*3bb=NdpsI*^}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$Bw)RH%yvg0tjEcL?fF=UW8lrkCM&BOE7EpQGCq)FrnERi#3WLEt^MPOkz6O zU(0mx$Lf!De~bMz%0VWTzZ>%qm4{4v4+;MC{$$eokV*9*A)MZeOsbCn{OSG3qoH7 zL+In*Dt&wc(j>9tU^V+a)IfA`CZsuqG~~^q`|rXl`hF(6u^p#8A-W zYIZ)@(Cn%c8a#CkZaR5@ESbHrvEczkcCB95+_b(2`udX)f9?8)b +#include + +#include "ks_wlan.h" +#include "ks_hostif.h" +#include "ks_wlan_ioctl.h" +#include "ks_debug.h" + +static int wep_on_off; +#define WEP_OFF 0 +#define WEP_ON_64BIT 1 +#define WEP_ON_128BIT 2 + +static int wep_type; +#define WEP_KEY_CHARACTER 0 +#define WEP_KEY_HEX 1 + +static +void analyze_character_wep_key(struct ks_wlan_parameter *param, int wep_key_index, char *value) +{ + int i; + unsigned char wep_key[26], key_length; + + key_length = (wep_on_off == WEP_ON_64BIT) ? 5 : 13; + /* 64bit key_length = 5; 128bit key_length = 13; */ + + for (i=0; i 3) + return; + + param->wep_key[wep_key_index].size = key_length; + for (i=0; i<(param->wep_key[wep_key_index].size); i++) { + param->wep_key[wep_key_index].val[i] = wep_key[i]; + } +} + +static +void analyze_hex_wep_key(struct ks_wlan_parameter *param, int wep_key_index, char *value) +{ + unsigned char wep_end[26], i, j, key_length; + + key_length = (wep_on_off == WEP_ON_64BIT) ? 10 : 26; + /* 64bit key_length = 10; 128bit key_length = 26; */ + + for (i=0; i 3) + return ; + + param->wep_key[wep_key_index].size = key_length/2; + for (i=0; i<(param->wep_key[wep_key_index].size); i++) { + param->wep_key[wep_key_index].val[i] = wep_end[i]; + } + +} + +static +int rate_set_configuration(ks_wlan_private *priv, char *value) +{ + int rc=0; + + priv->reg.tx_rate = TX_RATE_FIXED; + priv->reg.rate_set.size = 1; + + switch(*value){ + case '1': /* 1M 11M 12M 18M */ + if(*(value+1) == '8'){ + priv->reg.rate_set.body[0] = TX_RATE_18M; + } + else if(*(value+1) == '2'){ + priv->reg.rate_set.body[0] = TX_RATE_12M|BASIC_RATE; + } + else if(*(value+1) == '1'){ + priv->reg.rate_set.body[0] = TX_RATE_11M|BASIC_RATE; + } + else{ + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + } + break; + case '2': /* 2M 24M */ + if(*(value+1) == '4'){ + priv->reg.rate_set.body[0] = TX_RATE_24M|BASIC_RATE; + } + else{ + priv->reg.rate_set.body[0] = TX_RATE_2M|BASIC_RATE; + } + break; + case '3': /* 36M */ + priv->reg.rate_set.body[0] = TX_RATE_36M; + break; + case '4': /* 48M */ + priv->reg.rate_set.body[0] = TX_RATE_48M; + break; + case '5': /* 5.5M 54M */ + if(*(value+1) == '4'){ + priv->reg.rate_set.body[0] = TX_RATE_54M; + } + else{ + priv->reg.rate_set.body[0] = TX_RATE_5M|BASIC_RATE; + } + break; + case '6': /* 6M */ + priv->reg.rate_set.body[0] = TX_RATE_6M|BASIC_RATE; + break; + case '9': /* 9M */ + priv->reg.rate_set.body[0] = TX_RATE_9M; + break; + case 'K': + priv->reg.rate_set.body[6] = TX_RATE_36M; + priv->reg.rate_set.body[5] = TX_RATE_18M; + priv->reg.rate_set.body[4] = TX_RATE_24M|BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_12M|BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_6M|BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_11M|BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_2M|BASIC_RATE; + priv->reg.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 7; + break; + default: + 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.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 12; + break; + } + return rc; +} + +#ifndef NO_FIRMWARE_CLASS +#include +#else +#define MAX_CONFIG_FILE_SIZE (1024*10) +#endif +int ks_wlan_read_config_file(ks_wlan_private *priv) +{ + struct { + const int key_len; + const char *key; + const char *val; + } cfg_tbl[] = { + {15,"BeaconLostCount", "20"}, /* 0 */ + {7,"Channel", "1"}, /* 1 */ + {17,"FragmentThreshold","2346"}, /* 2 */ + {13,"OperationMode","Infrastructure"}, /* 3 */ + {19,"PowerManagementMode","ACTIVE"}, /* 4 */ + {12,"RTSThreshold","2347"}, /* 5 */ + {4,"SSID","default"}, /* 6 */ + {6,"TxRate","Auto"}, /* 7 */ + {23,"AuthenticationAlgorithm",""}, /* 8 */ + {12,"WepKeyValue1",""}, /* 9 */ + {12,"WepKeyValue2",""}, /* 10 */ + {12,"WepKeyValue3",""}, /* 11 */ + {12,"WepKeyValue4",""}, /* 12 */ + {8,"WepIndex","1"}, /* 13 */ + {7,"WepType","STRING"}, /* 14 */ + {3,"Wep","OFF"}, /* 15 */ + {13,"PREAMBLE_TYPE","SHORT"}, /* 16 */ + {8,"ScanType","ACTIVE_SCAN"}, /* 17 */ + {8,"ROM_FILE", ROM_FILE}, /* 18 */ + {7,"PhyType", "BG_MODE"}, /* 19 */ + {7,"CtsMode", "FALSE"}, /* 20 */ + {19,"PhyInformationTimer", "0"}, /* 21 */ + {0,"",""}, + }; + +#ifndef NO_FIRMWARE_CLASS + const struct firmware *fw_entry; + struct device *dev = NULL; + int retval; +#else + struct file *srcf; + int nr_read ; + int retval; + char *cfg_buf=NULL; + int orgfsuid, orgfsgid; + mm_segment_t orgfs; +#endif + char cfg_file[]=CFG_FILE; + char *cur_p, *end_p; + char wk_buff[256], *wk_p; + + /* Initialize Variable */ + priv->reg.operation_mode = MODE_INFRASTRUCTURE; /* Infrastructure */ + priv->reg.channel = 10; /* 10 */ + memset(priv->reg.bssid, 0x0, ETH_ALEN); /* BSSID */ + priv->reg.ssid.body[0] = '\0'; /* SSID */ + priv->reg.ssid.size = 0; /* SSID size */ + priv->reg.tx_rate = TX_RATE_AUTO; /* TxRate Fully Auto */ + priv->reg.preamble = SHORT_PREAMBLE; /* Preamble = SHORT */ + priv->reg.powermgt = POWMGT_ACTIVE_MODE; /* POWMGT_ACTIVE_MODE */ + priv->reg.scan_type = ACTIVE_SCAN; /* Active */ + priv->reg.beacon_lost_count = 20; /* Beacon Lost Count */ + priv->reg.rts = 2347UL; /* RTS Threashold */ + priv->reg.fragment = 2346UL; /* Fragmentation Threashold */ + + strcpy(&priv->reg.rom_file[0], ROM_FILE); + + priv->skb = NULL; + + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; /* AuthenticationAlgorithm */ + + priv->reg.privacy_invoked = 0x00; /* WEP */ + priv->reg.wep_index=0; + memset(&priv->reg.wep_key[0],0,sizeof(priv->reg.wep_key[0])); + memset(&priv->reg.wep_key[1],0,sizeof(priv->reg.wep_key[0])); + memset(&priv->reg.wep_key[2],0,sizeof(priv->reg.wep_key[0])); + memset(&priv->reg.wep_key[3],0,sizeof(priv->reg.wep_key[0])); + + priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; + priv->reg.cts_mode = CTS_MODE_FALSE; + priv->reg.phy_info_timer = 0; + 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.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 12; + +#ifndef NO_FIRMWARE_CLASS +#if (defined _PCMCIA_) + dev = &priv->ks_wlan_hw.pcmcia_dev->dev; +#elif (defined _PCI_) + dev = &priv->ks_wlan_hw.pci_dev->dev; +#elif (defined _SDIO_) + dev = &priv->ks_wlan_hw.sdio_card->func->dev; +#endif + if((retval = request_firmware(&fw_entry, cfg_file, dev)) !=0 ){ + DPRINTK(1, "error request_firmware() file=%s ret=%d\n", cfg_file, retval); + return 1; + } + + DPRINTK(4, "success request_firmware() file=%s size=%d\n", cfg_file, fw_entry->size); + cur_p = fw_entry->data; + end_p = cur_p + fw_entry->size; +#else + orgfsuid=current->fsuid; + orgfsgid=current->fsgid; + orgfs=get_fs(); + set_fs(KERNEL_DS); + + srcf = filp_open(cfg_file, O_RDONLY, 0); + if (IS_ERR(srcf)) { + printk(KERN_ERR "error %ld opening %s\n", -PTR_ERR(srcf),cfg_file); + goto no_config_file; + } + + if (!(srcf->f_op && srcf->f_op->read)) { + printk(KERN_ERR "%s does not have a read method\n", cfg_file); + goto no_config_file; + } + + cfg_buf = (char *)kzalloc(MAX_CONFIG_FILE_SIZE, GFP_ATOMIC); + if (!cfg_buf) { + printk(KERN_ERR "%s does not read : out of memory \n", cfg_file); + goto no_config_file; + } + + nr_read = srcf->f_op->read(srcf, (unsigned char *)cfg_buf, MAX_CONFIG_FILE_SIZE, &srcf->f_pos); + + DPRINTK(1, "read retval=%d file=%s\n", nr_read, priv->reg.cfg_file); + retval=filp_close(srcf ,NULL); + if (retval) + DPRINTK(1, "error %d closing %s\n", -retval,priv->reg.cfg_file); + + if (nr_read < 1) { + printk(KERN_ERR "%s does not read : file is empty num=%d\n", cfg_file, nr_read); + goto no_config_file; + }else if(nr_read > MAX_CONFIG_FILE_SIZE){ + printk(KERN_ERR "%s does not read : file is too big \n", cfg_file); + goto no_config_file; + } + cur_p = cfg_buf; + end_p = cur_p + nr_read; +#endif + *end_p = '\0'; + + while (cur_p < end_p) { + int i, j, len; + + len = end_p - cur_p; + for (i=0; cfg_tbl[i].key_len != 0; i++) { + if (*cur_p == '#') { + break; + } + if (len < cfg_tbl[i].key_len) { + continue; + } + if (!strncmp(cfg_tbl[i].key, cur_p, cfg_tbl[i].key_len)) { + break; + } + } + if ((*cur_p == '#') || (cfg_tbl[i].key_len == 0)) { + while (*cur_p != '\n') { + if (cur_p >= end_p) { + break; + } + cur_p++; + } + cur_p++; + } else { + cur_p += cfg_tbl[i].key_len; + if (*cur_p != '=') { + while (*cur_p != '\n') { + if (cur_p >= end_p) { + break; + } + cur_p++; + } + continue; + } + cur_p++; + + for (j=0,wk_p=cur_p; *wk_p != '\n' && wk_p < end_p; j++,wk_p++) { + wk_buff[j] = *wk_p; + } + wk_buff[j] = '\0'; + cur_p = wk_p; + DPRINTK(4,"%s=%s\n",cfg_tbl[i].key, wk_buff); + wk_p = wk_buff; + + switch (i) { + case 0: /* "BeaconLostCount", "10" */ + priv->reg.beacon_lost_count = simple_strtol(wk_buff, NULL, 10); + break; + case 1: /* "Channel", "1" */ + priv->reg.channel = simple_strtol(wk_buff, NULL, 10); + break; + case 2: /* "FragmentThreshold","2346" */ + j = simple_strtol(wk_buff, NULL, 10); + priv->reg.fragment = (unsigned long)j; + break; + case 3: /* "OperationMode","Infrastructure" */ + switch (*wk_buff) { + case 'P': + priv->reg.operation_mode = MODE_PSEUDO_ADHOC; + break; + case 'I': + priv->reg.operation_mode = MODE_INFRASTRUCTURE; + break; + case '8': + priv->reg.operation_mode = MODE_ADHOC; + break; + default: + priv->reg.operation_mode = MODE_INFRASTRUCTURE; + } + break; + case 4: /* "PowerManagementMode","POWER_ACTIVE" */ + if (!strncmp(wk_buff, "SAVE1", 5)) { + priv->reg.powermgt = POWMGT_SAVE1_MODE; + } else if (!strncmp(wk_buff, "SAVE2", 5)){ + priv->reg.powermgt = POWMGT_SAVE2_MODE; + } else { + priv->reg.powermgt = POWMGT_ACTIVE_MODE; + } + break; + case 5: /* "RTSThreshold","2347" */ + j = simple_strtol(wk_buff, NULL, 10); + priv->reg.rts = (unsigned long)j; + break; + case 6: /* "SSID","" */ + if (*wk_p != '"') + break; + wk_p++; + for (j=0; *wk_p != '"'; j++) { + if (wk_p == '\0') { + break; + } + priv->reg.ssid.body[j] = *wk_p++; + } + priv->reg.ssid.body[j] = '\0'; + priv->reg.ssid.size = j; + wk_p++; + break; + case 7: /* "TxRate","Auto" */ + rate_set_configuration(priv, wk_p); + break; + case 8: /* "AuthenticationAlgorithm","OPEN_SYSTEM" */ + switch (*wk_p) { + case 'O': /* Authenticate System : Open System */ + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; + break; + case 'S': /* Authenticate System : Shared Key */ + priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; + break; + } + break; + case 9: /* "WepKeyValue1","" */ + case 10: /* "WepKeyValue2","" */ + case 11: /* "WepKeyValue3","" */ + case 12: /* "WepKeyValue4","" */ + if (wep_on_off != WEP_OFF) { + switch (wep_type) { + case WEP_KEY_CHARACTER: + analyze_character_wep_key(&priv->reg, (i-9), wk_p); + break; + case WEP_KEY_HEX: + analyze_hex_wep_key(&priv->reg, (i-9), wk_p); + break; + } + } + break; + case 13: /* "WepIndex","1"->0 (So, Zero Origin) */ + priv->reg.wep_index = simple_strtol(wk_buff, NULL, 10) - 1; + break; + case 14: /* "WepType","STRING" */ + if (!strncmp(wk_buff, "STRING", 6)) { + wep_type = WEP_KEY_CHARACTER; + } else { + wep_type = WEP_KEY_HEX; + } + break; + case 15: /* "Wep","OFF" */ + if (!strncmp(wk_buff, "OFF", 3)) { + priv->reg.privacy_invoked = 0x00; + wep_on_off = WEP_OFF; + } else { /* 64bit or 128bit */ + priv->reg.privacy_invoked = 0x01; + if (*wk_buff == '6') { /* 64bit */ + wep_on_off = WEP_ON_64BIT; + } else { /* 128bit */ + wep_on_off = WEP_ON_128BIT; + } + } + break; + case 16: /* "PREAMBLE_TYPE","LONG" */ + if (!strncmp(wk_buff, "SHORT", 5)) { + priv->reg.preamble = SHORT_PREAMBLE; + } else { /* "LONG" */ + priv->reg.preamble = LONG_PREAMBLE; + } + break; + case 17: /* "ScanType","ACTIVE_SCAN" */ + if (!strncmp(wk_buff, "PASSIVE_SCAN", 12)) { + priv->reg.scan_type = PASSIVE_SCAN; + } else { /* "ACTIVE_SCAN" */ + priv->reg.scan_type = ACTIVE_SCAN; + } + break; + case 18: // "ROM_FILE",ROMFILE + if (*wk_p != '"') + break; + wk_p++; + for (j=0; *wk_p != '"'; j++) { + if (wk_p == '\0') { + break; + } + priv->reg.rom_file[j] = *wk_p++; + } + priv->reg.rom_file[j] = '\0'; + wk_p++; + break; + case 19: /*"PhyType", "BG_MODE" */ + if (!strncmp(wk_buff, "B_MODE", 6)) { + priv->reg.phy_type = D_11B_ONLY_MODE; + } else if (!strncmp(wk_buff, "G_MODE", 6)) { + priv->reg.phy_type = D_11G_ONLY_MODE; + } else { + priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; + } + break; + case 20: /* "CtsMode", "FALSE" */ + if (!strncmp(wk_buff, "TRUE", 4)) { + priv->reg.cts_mode = CTS_MODE_TRUE; + } else { + priv->reg.cts_mode = CTS_MODE_FALSE; + } + break; + case 21: /* "PhyInformationTimer", "0" */ + j = simple_strtol(wk_buff, NULL, 10); + priv->reg.phy_info_timer = (uint16_t)j; + break; + default: + break; + } + if (cur_p >= end_p) { + break; + } + cur_p++; + } + + } +#ifndef NO_FIRMWARE_CLASS + release_firmware(fw_entry); +#else +no_config_file: + kfree(cfg_buf); + set_fs(orgfs); + current->fsuid=orgfsuid; + current->fsgid=orgfsgid; +#endif + + DPRINTK(3,"\n operation_mode = %d\n channel = %d\n ssid = %s\n tx_rate = %d\n \ + preamble = %d\n powermgt = %d\n scan_type = %d\n beacon_lost_count = %d\n rts = %d\n \ + fragment = %d\n privacy_invoked = %d\n wep_type = %d\n wep_on_off = %d\n wep_index = %d\n romfile = %s\n", + priv->reg.operation_mode,priv->reg.channel,&priv->reg.ssid.body[0],priv->reg.tx_rate, + priv->reg.preamble,priv->reg.powermgt,priv->reg.scan_type,priv->reg.beacon_lost_count, + priv->reg.rts,priv->reg.fragment,priv->reg.privacy_invoked,wep_type,wep_on_off,priv->reg.wep_index, + &priv->reg.rom_file[0] + ); + DPRINTK(3,"\n phy_type = %d\n cts_mode = %d\n tx_rate = %d\n phy_info_timer = %d\n", + priv->reg.phy_type,priv->reg.cts_mode,priv->reg.tx_rate,priv->reg.phy_info_timer ); + + return(0); +} + diff --git a/ks7010/src/ks7010_sdio.c b/ks7010/src/ks7010_sdio.c new file mode 100644 index 0000000..b8b3800 --- /dev/null +++ b/ks7010/src/ks7010_sdio.c @@ -0,0 +1,1264 @@ +/* + * Driver for KeyStream, KS7010 based SDIO cards. + * + * ks7010_sdio.c + * $Id: ks7010_sdio.c 996 2009-09-14 02:54:21Z sekine $ + * + * Copyright (C) 2006-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#include +#include +#include +#include + +#include "ks_wlan.h" +#include "ks_wlan_ioctl.h" +#include "ks_debug.h" +#include "ks_hostif.h" + +#include "ks7010_sdio.h" + +#define KS7010_FUNC_NUM 1 +#define KS7010_IO_BLOCK_SIZE 512 +#define KS7010_MAX_CLOCK 25000000 + +static int reg_net = 0; + +static const struct sdio_device_id if_sdio_ids[] = { + { SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010) }, + { SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010) }, + { /* all zero */ } +}; + +struct ks_sdio_model { + int model; + const char *firmware; +}; + +static struct ks_sdio_model ks_sdio_models[] = { + { + /* ks7010 */ + .model = 0x10, + .firmware = "ks7010sd.rom", + }, +}; + +static int ks7910_sdio_probe(struct sdio_func *function, const struct sdio_device_id *device); +static void ks7910_sdio_remove(struct sdio_func *function); +static void ks7010_rw_function(struct work_struct *work); +static int ks7010_sdio_read( ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length ); +static int ks7010_sdio_write( ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length ); +#ifdef NO_FIRMWARE_CLASS +static char *romfile = ROM_FILE; +module_param(romfile, charp, S_IRUGO); +#endif +/* macro */ + +#define inc_txqhead(priv) \ + ( priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE ) +#define inc_txqtail(priv) \ + ( priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE ) +#define cnt_txqbody(priv) \ + (((priv->tx_dev.qtail + TX_DEVICE_BUFF_SIZE) - (priv->tx_dev.qhead)) % TX_DEVICE_BUFF_SIZE ) + +#define inc_rxqhead(priv) \ + ( priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE ) +#define inc_rxqtail(priv) \ + ( priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE ) +#define cnt_rxqbody(priv) \ + (((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - (priv->rx_dev.qhead)) % RX_DEVICE_BUFF_SIZE ) + +void ks_wlan_hw_sleep_doze_request(ks_wlan_private *priv) +{ + unsigned char rw_data; + int retval; + + DPRINTK(4, "\n"); + + /* clear request */ + atomic_set(&priv->sleepstatus.doze_request,0); + + if( atomic_read(&priv->sleepstatus.status) == 0){ + rw_data = GCR_B_DOZE; + retval = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : GCR_B=%02X\n", rw_data); + goto out; + } + DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data); + DPRINTK(3,"sleep_mode=SLP_SLEEP\n"); + atomic_set(&priv->sleepstatus.status, 1); + priv->last_doze = jiffies; + } + else{ + DPRINTK(1,"sleep_mode=%d\n",priv->sleep_mode); + } + +out: + priv->sleep_mode = atomic_read(&priv->sleepstatus.status); + return; +} + +void ks_wlan_hw_sleep_wakeup_request(ks_wlan_private *priv) +{ + unsigned char rw_data; + int retval; + + DPRINTK(4, "\n"); + + /* clear request */ + atomic_set(&priv->sleepstatus.wakeup_request,0); + + if( atomic_read(&priv->sleepstatus.status) == 1){ + rw_data = WAKEUP_REQ; + retval = ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WAKEUP=%02X\n", rw_data); + goto out; + } + DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data); + atomic_set(&priv->sleepstatus.status, 0); + priv->last_wakeup = jiffies; + ++priv->wakeup_count; + } + else{ + DPRINTK(1,"sleep_mode=%d\n",priv->sleep_mode); + } + +out: + priv->sleep_mode = atomic_read(&priv->sleepstatus.status); + return; +} + + +void ks_wlan_hw_wakeup_request(ks_wlan_private *priv) +{ + unsigned char rw_data; + int retval; + + DPRINTK(4, "\n"); + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + rw_data = WAKEUP_REQ; + retval = ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WAKEUP=%02X\n", rw_data); + } + DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data); + priv->last_wakeup = jiffies; + ++priv->wakeup_count; + } + else{ + DPRINTK(1,"psstatus=%d\n",atomic_read(&priv->psstatus.status)); + } +} + +int _ks_wlan_hw_power_save(ks_wlan_private *priv) +{ + int rc=0; + unsigned char rw_data; + int retval; + + if(priv->reg.powermgt == POWMGT_ACTIVE_MODE) + return rc; + + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE && + (priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + + //DPRINTK(1,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status)); + if (priv->dev_state == DEVICE_STATE_SLEEP) { + switch(atomic_read(&priv->psstatus.status)){ + case PS_SNOOZE: /* 4 */ + break; + default: + DPRINTK(5,"\n\ + psstatus.status=%d\n\ + psstatus.confirm_wait=%d\n\ + psstatus.snooze_guard=%d\n\ + cnt_txqbody=%d\n", + atomic_read(&priv->psstatus.status), + atomic_read(&priv->psstatus.confirm_wait), + atomic_read(&priv->psstatus.snooze_guard), + cnt_txqbody(priv)); + + if(!atomic_read(&priv->psstatus.confirm_wait)&& + !atomic_read(&priv->psstatus.snooze_guard)&& + !cnt_txqbody(priv)){ + retval = ks7010_sdio_read(priv, INT_PENDING, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + break; + } + if(!rw_data){ + rw_data = GCR_B_DOZE; + retval = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : GCR_B=%02X\n", rw_data); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + break; + } + DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data); + atomic_set(&priv->psstatus.status, PS_SNOOZE); + DPRINTK(3,"psstatus.status=PS_SNOOZE\n"); + } + else{ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + } + } + else{ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + } + break; + } + } + + } + + return rc; +} + +int ks_wlan_hw_power_save(ks_wlan_private *priv) +{ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + return 0; +} + +static int ks7010_sdio_read(ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length) +{ + int rc = -1; + struct ks_sdio_card *card; + + card = priv->ks_wlan_hw.sdio_card; + + if (length == 1) /* CMD52 */ + *buffer = sdio_readb(card->func, address, &rc); + else /* CMD53 multi-block transfer */ + rc = sdio_memcpy_fromio(card->func, buffer, address, length); + + if(rc != 0){ + printk("sdio error erorr=%d size=%d\n", rc, length); + ++priv->sdio_error_count; + }else{ + priv->sdio_error_count=0; + } + + return rc; +} + +static int ks7010_sdio_write(ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length) +{ + int rc = -1; + struct ks_sdio_card *card; + + card = priv->ks_wlan_hw.sdio_card; + + if (length == 1) /* CMD52 */ + sdio_writeb(card->func, *buffer, (unsigned int) address, &rc); + else /* CMD53 */ + rc = sdio_memcpy_toio(card->func, (unsigned int) address, buffer, length); + + if(rc != 0){ + printk("sdio error erorr=%d size=%d\n", rc, length); + ++priv->sdio_error_count; + }else{ + priv->sdio_error_count=0; + } + + return rc; +} + +static int enqueue_txdev(ks_wlan_private *priv, unsigned char *p, unsigned long size, + void (*complete_handler)(void *arg1, void *arg2), + void *arg1, void *arg2 ) +{ + struct tx_device_buffer *sp; + + if (priv->dev_state < DEVICE_STATE_BOOT) { + kfree(p); + if (complete_handler != NULL) + (*complete_handler)(arg1, arg2); + return 1; + } + + if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) { + /* in case of buffer overflow */ + DPRINTK(1,"tx buffer overflow\n"); + kfree(p); + if (complete_handler != NULL) + (*complete_handler)(arg1, arg2); + return 1; + } + + sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qtail]; + sp->sendp = p; + sp->size = size; + sp->complete_handler = complete_handler; + sp->arg1 = arg1; + sp->arg2 = arg2; + inc_txqtail(priv); + + return 0; +} + +/* write data */ +static int write_to_device(ks_wlan_private *priv, unsigned char *buffer, unsigned long size ) +{ + int rc,retval; + unsigned char rw_data; + struct hostif_hdr *hdr; + hdr = (struct hostif_hdr *)buffer; + rc=0; + + DPRINTK(4,"size=%d\n", hdr->size); + if(hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event){ + DPRINTK(1,"unknown event=%04X\n",hdr->event); + return 0; + } + + retval = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size); + if(retval){ + DPRINTK(1, " write error : retval=%d\n", retval); + return -4; + } + + rw_data = WRITE_STATUS_BUSY; + retval = ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WRITE_STATUS=%02X\n", rw_data); + return -3; + } + + return 0; +} + +static void tx_device_task(void *dev) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev; + struct tx_device_buffer *sp; + int rc = 0; + + DPRINTK(4, "\n"); + if(cnt_txqbody(priv)>0 && atomic_read(&priv->psstatus.status) != PS_SNOOZE){ + sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; + if(priv->dev_state >= DEVICE_STATE_BOOT){ + rc = write_to_device(priv, sp->sendp, sp->size); + if(rc){ + DPRINTK(1, "write_to_device error !!(%d)\n", rc); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + return; + } + + } + kfree(sp->sendp); /* allocated memory free */ + if(sp->complete_handler != NULL) /* TX Complete */ + (*sp->complete_handler)(sp->arg1, sp->arg2); + inc_txqhead(priv); + + if(cnt_txqbody(priv)>0){ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + } + } + return; +} + +int ks_wlan_hw_tx( ks_wlan_private *priv, void *p, unsigned long size, + void (*complete_handler)(void *arg1, void *arg2), + void *arg1, void *arg2 ) +{ + int result=0; + struct hostif_hdr *hdr; + hdr = (struct hostif_hdr *)p; + + if(hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event){ + DPRINTK(1,"unknown event=%04X\n",hdr->event); + return 0; + } + + /* add event to hostt buffer */ + priv->hostt.buff[priv->hostt.qtail] = hdr->event; + priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; + + DPRINTK(4, "event=%04X\n",hdr->event); + spin_lock(&priv->tx_dev.tx_dev_lock); + result = enqueue_txdev(priv, p, size, complete_handler, arg1, arg2); + spin_unlock(&priv->tx_dev.tx_dev_lock); + + if(cnt_txqbody(priv)>0){ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + } + return result; +} + +static void rx_event_task(unsigned long dev) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev; + struct rx_device_buffer *rp; + + DPRINTK(4,"\n"); + + if(cnt_rxqbody(priv) > 0 && priv->dev_state >= DEVICE_STATE_BOOT){ + rp = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qhead]; + hostif_receive(priv, rp->data, rp->size); + inc_rxqhead(priv); + + if(cnt_rxqbody(priv) > 0){ + tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task); + } + } + + return; +} + +static void ks_wlan_hw_rx(void *dev, uint16_t size) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev; + int retval; + struct rx_device_buffer *rx_buffer; + struct hostif_hdr *hdr; + unsigned char read_status; + unsigned short event=0; + + DPRINTK(4,"\n"); + + /* receive data */ + if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE-1)) { + /* in case of buffer overflow */ + DPRINTK(1,"rx buffer overflow \n"); + goto error_out; + } + rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail]; + + retval = ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0], hif_align_size(size)); + if(retval){ + goto error_out; + } + + /* length check */ + if(size > 2046 || size == 0){ + + DPRINTK(5,"-INVAILED DATA dump\n"); + print_buffer(&rx_buffer->data[0],32); + + /* rx_status update */ + read_status = READ_STATUS_IDLE; + retval = ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); + if(retval){ + DPRINTK(1, " error : READ_STATUS=%02X\n", read_status); + } + goto error_out; + } + + hdr = (struct hostif_hdr *)&rx_buffer->data[0]; + rx_buffer->size = le16_to_cpu(hdr->size) + sizeof(hdr->size); + event = hdr->event; + inc_rxqtail(priv); + + /* read status update */ + read_status = READ_STATUS_IDLE; + retval = ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); + if(retval){ + DPRINTK(1, " error : READ_STATUS=%02X\n", read_status); + } + DPRINTK(4, "READ_STATUS=%02X\n", read_status); + + if(atomic_read(&priv->psstatus.confirm_wait)){ + if(IS_HIF_CONF(event)){ + DPRINTK(4, "IS_HIF_CONF true !!\n"); + atomic_dec(&priv->psstatus.confirm_wait); + } + } + + /* rx_event_task((void *)priv); */ + tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task); + +error_out: + return; +} + +static void ks7010_rw_function(struct work_struct *work) +{ + struct hw_info_t *hw; + struct ks_wlan_private *priv; + unsigned char rw_data; + int retval; + + hw = container_of(work, struct hw_info_t, rw_wq.work); + priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw); + + DPRINTK(4,"\n"); + + + /* wiat after DOZE */ + if(time_after(priv->last_doze + ((30*HZ)/1000), jiffies )){ + DPRINTK(4, "wait after DOZE \n"); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + return; + } + + /* wiat after WAKEUP */ + while(time_after(priv->last_wakeup + ((30*HZ)/1000), jiffies )){ + DPRINTK(4, "wait after WAKEUP \n"); +/* queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, + (priv->last_wakeup + ((30*HZ)/1000) - jiffies));*/ + printk("wake: %lu %lu\n", priv->last_wakeup + (30* HZ)/1000, jiffies); + msleep(30); + } + + sdio_claim_host(priv->ks_wlan_hw.sdio_card->func); + + /* power save wakeup */ + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + if(cnt_txqbody(priv)>0){ + ks_wlan_hw_wakeup_request(priv); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + } + goto err_out; + } + + /* sleep mode doze */ + if(atomic_read(&priv->sleepstatus.doze_request)==1){ + ks_wlan_hw_sleep_doze_request(priv); + goto err_out; + } + /* sleep mode wakeup */ + if(atomic_read(&priv->sleepstatus.wakeup_request)==1){ + ks_wlan_hw_sleep_wakeup_request(priv); + goto err_out; + } + + /* read (WriteStatus/ReadDataSize FN1:00_0014) */ + retval = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WSTATUS_RSIZE=%02X psstatus=%d\n", rw_data,atomic_read(&priv->psstatus.status)); + goto err_out; + } + DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data); + + if(rw_data&RSIZE_MASK){ /* Read schedule */ + ks_wlan_hw_rx((void *)priv, (uint16_t)(((rw_data&RSIZE_MASK)<<4))); + } + if((rw_data&WSTATUS_MASK)){ + tx_device_task((void *)priv); + } + _ks_wlan_hw_power_save(priv); + +err_out: + sdio_release_host(priv->ks_wlan_hw.sdio_card->func); + + return; +} + + + +static void ks_sdio_interrupt(struct sdio_func *func) +{ + int retval; + struct ks_sdio_card *card; + ks_wlan_private *priv; + unsigned char status, rsize, rw_data; + + card = sdio_get_drvdata(func); + priv = card->priv; + DPRINTK(4, "\n"); + + if(priv->dev_state >= DEVICE_STATE_BOOT){ + retval = ks7010_sdio_read(priv, INT_PENDING, &status, sizeof(status)); + if(retval){ + DPRINTK(1, "read INT_PENDING Failed!!(%d)\n",retval); + goto intr_out; + } + DPRINTK(4, "INT_PENDING=%02X\n", rw_data); + + /* schedule task for interrupt status */ + /* bit7 -> Write General Communication B register */ + /* read (General Communication B register) */ + /* bit5 -> Write Status Idle */ + /* bit2 -> Read Status Busy */ + if(status&INT_GCR_B || atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + retval = ks7010_sdio_read(priv, GCR_B, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : GCR_B=%02X\n", rw_data); + goto intr_out; + } + /* DPRINTK(1, "GCR_B=%02X\n", rw_data); */ + if(rw_data == GCR_B_ACTIVE){ + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + atomic_set(&priv->psstatus.status, PS_WAKEUP); + priv->wakeup_count=0; + } + complete(&priv->psstatus.wakeup_wait); + } + + + } + + do{ + /* read (WriteStatus/ReadDataSize FN1:00_0014) */ + retval = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n", rw_data); + goto intr_out; + } + DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data); + rsize=rw_data&RSIZE_MASK; + if(rsize){ /* Read schedule */ + ks_wlan_hw_rx((void *)priv, (uint16_t)(((rsize)<<4))); + } + if(rw_data&WSTATUS_MASK){ +#if 0 + if(status&INT_WRITE_STATUS && !cnt_txqbody(priv)){ + /* dummy write for interrupt clear */ + rw_data =0; + retval = ks7010_sdio_write(priv, DATA_WINDOW, &rw_data, sizeof(rw_data)); + if (retval) { + DPRINTK(1, "write DATA_WINDOW Failed!!(%d)\n",retval); + } + status &= ~INT_WRITE_STATUS; + } + else{ +#endif + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + if(cnt_txqbody(priv)){ + ks_wlan_hw_wakeup_request(priv); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq, 1); + return; + } + } + else{ + tx_device_task((void *)priv); + } +// } + } + }while(rsize); + } + +intr_out: + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + return; +} + +static int trx_device_init( ks_wlan_private *priv ) +{ + /* initialize values (tx) */ + priv->tx_dev.qtail = priv->tx_dev.qhead = 0; + + /* initialize values (rx) */ + priv->rx_dev.qtail = priv->rx_dev.qhead = 0; + + /* initialize spinLock (tx,rx) */ + spin_lock_init(&priv->tx_dev.tx_dev_lock); + spin_lock_init(&priv->rx_dev.rx_dev_lock); + + tasklet_init(&priv->ks_wlan_hw.rx_bh_task, rx_event_task, (unsigned long)priv); + + return 0; +} + +static void trx_device_exit( ks_wlan_private *priv ) +{ + struct tx_device_buffer *sp; + + /* tx buffer clear */ + while (cnt_txqbody(priv)>0) { + sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; + kfree(sp->sendp); /* allocated memory free */ + if (sp->complete_handler != NULL) /* TX Complete */ + (*sp->complete_handler)(sp->arg1, sp->arg2); + inc_txqhead(priv); + } + + tasklet_kill(&priv->ks_wlan_hw.rx_bh_task); + + return; +} +static int ks7010_sdio_update_index(ks_wlan_private *priv, u32 index) +{ + int rc=0; + int retval; + unsigned char *data_buf; + data_buf = NULL; + + data_buf = kmalloc(sizeof(u32), GFP_KERNEL); + if(!data_buf){ rc = 1; goto error_out; } + + memcpy(data_buf, &index, sizeof(index)); + retval = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index)); + if(retval){ rc = 2; goto error_out; } + + retval = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index)); + if(retval){ rc = 3; goto error_out; } +error_out: + if(data_buf) kfree(data_buf); + return rc; +} + +#define ROM_BUFF_SIZE (64*1024) +static int ks7010_sdio_data_compare(ks_wlan_private *priv, u32 address, + unsigned char *data, unsigned int size) +{ + int rc=0; + int retval; + unsigned char *read_buf; + read_buf = NULL; + read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); + if(!read_buf){ rc = 1; goto error_out; } + retval = ks7010_sdio_read(priv, address, read_buf, size); + if(retval){ rc = 2; goto error_out; } + retval = memcmp(data, read_buf, size); + + if(retval){ + DPRINTK(0, "data compare error (%d) \n",retval); rc = 3; goto error_out; + } +error_out: + if(read_buf) kfree(read_buf); + return rc; +} +#ifndef NO_FIRMWARE_CLASS +#include +#endif +static int ks79xx_upload_firmware(ks_wlan_private *priv, struct ks_sdio_card *card) +{ + unsigned int size, offset, n = 0; + unsigned char *rom_buf; + unsigned char rw_data =0; + int retval, rc=0; +#ifndef NO_FIRMWARE_CLASS + int length; + const struct firmware *fw_entry = NULL; +#else + int orgfsuid, orgfsgid; + struct file *srcf; + mm_segment_t orgfs; +#endif + + rom_buf = NULL; + + /* buffer allocate */ + rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); + if(!rom_buf){ rc = 3; goto error_out0; } + + + sdio_claim_host(card->func); + + /* Firmware running ? */ + retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); + if(rw_data == GCR_A_RUN){ + DPRINTK( 0, "MAC firmware running ...\n"); + rc = 0; + goto error_out0; + } + +#ifndef NO_FIRMWARE_CLASS + if(request_firmware(&fw_entry, priv->reg.rom_file, &priv->ks_wlan_hw.sdio_card->func->dev)!=0){ + DPRINTK(1,"error request_firmware() file=%s\n", priv->reg.rom_file); + return 1; + } + DPRINTK(4,"success request_firmware() file=%s size=%d\n", priv->reg.rom_file, fw_entry->size); + length = fw_entry->size; +#else + orgfsuid=current->fsuid; + orgfsgid=current->fsgid; + current->fsuid=current->fsgid=0; + orgfs=get_fs(); + set_fs(KERNEL_DS); + + srcf = filp_open(romfile, O_RDONLY, 0); + if (IS_ERR(srcf)) { + DPRINTK(1, "error %ld opening %s\n", -PTR_ERR(srcf),romfile); + rc = 1; + goto error_out1; + } + + if (!(srcf->f_op && srcf->f_op->read)) { + DPRINTK(1, "%s does not have a read method\n", romfile); + rc = 2; + goto error_out2; + } +#endif + + /* Load Program */ + n = 0; + do { +#ifndef NO_FIRMWARE_CLASS + if(length >= ROM_BUFF_SIZE){ + size = ROM_BUFF_SIZE; + length = length - ROM_BUFF_SIZE; + } + else{ + size=length; + length=0; + } + DPRINTK(4, "size = %d\n",size); + if(size == 0) break; + memcpy(rom_buf,fw_entry->data+n,size); +#else + /* The object must have a read method */ + size = srcf->f_op->read(srcf, rom_buf, ROM_BUFF_SIZE, &srcf->f_pos); + if (size < 0) { + DPRINTK(1, "Read %s error %d\n", priv->reg.rom_file, -retval); + rc = 5; + goto error_out2; + } + else if (size == 0) break; +#endif + /* Update write index */ + offset = n; + retval = ks7010_sdio_update_index(priv, KS7010_IRAM_ADDRESS+offset); + if(retval){ rc = 6; goto error_out1; } + + /* Write data */ + retval = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size); + if(retval){ rc = 8; goto error_out1; } + + /* compare */ + retval = ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size); + if(retval){ rc = 9; goto error_out1; } + n += size; + + }while(size); + + /* Remap request */ + rw_data = GCR_A_REMAP; + retval = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data)); + if(retval){ + rc = 11; + goto error_out1; + } + DPRINTK( 4, " REMAP Request : GCR_A=%02X\n", rw_data); + + /* Firmware running check */ + for (n = 0; n < 50; ++n) { + mdelay(10);/* wait_ms(10); */ + retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); + if(retval){ rc = 11; goto error_out1; } + if(rw_data == GCR_A_RUN) break; + } + DPRINTK(4, "firmware wakeup (%d)!!!!\n",n); + if ((50) <= n) { + DPRINTK(1, "firmware can't start\n"); + rc = 12; + goto error_out1; + } + + rc = 0; + +#ifdef NO_FIRMWARE_CLASS + error_out2: + retval=filp_close(srcf ,NULL); + if (retval) + DPRINTK(1, "error %d closing %s\n", -retval,priv->reg.rom_file); + + error_out1: + set_fs(orgfs); + current->fsuid=orgfsuid; + current->fsgid=orgfsgid; +#else + error_out1: + release_firmware(fw_entry); +#endif + error_out0: + sdio_release_host(card->func); + if(rom_buf) + kfree(rom_buf); + return rc; +} + +static void card_init_task(struct work_struct *work) +{ + struct hw_info_t *hw; + struct ks_wlan_private *priv; + + hw = container_of(work, struct hw_info_t, init_task); + priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw); + + DPRINTK(5,"\ncard_init_task()\n"); + + /* init_waitqueue_head(&priv->confirm_wait); */ + init_completion(&priv->confirm_wait); + + DPRINTK(5,"init_completion()\n"); + + /* get mac address & firmware version */ + hostif_sme_enqueue(priv, SME_START); + + DPRINTK(5,"hostif_sme_enqueu()\n"); + + if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,5*HZ)){ + DPRINTK(1,"wait time out!! SME_START\n"); + } + + if(priv->mac_address_valid && priv->version_size){ + priv->dev_state = DEVICE_STATE_PREINIT; + } + + hostif_sme_enqueue(priv, SME_GET_EEPROM_CKSUM); + + /* load initial wireless parameter */ + hostif_sme_enqueue(priv, SME_STOP_REQUEST); + + hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST); + hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST); + + hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST); + hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST); + hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST); + hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST); + hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST); + + hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); + hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST); + hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST); + hostif_sme_enqueue(priv, SME_START_REQUEST); + + if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,5*HZ)){ + DPRINTK(1,"wait time out!! wireless parameter set\n"); + } + + if(priv->dev_state >= DEVICE_STATE_PREINIT){ + DPRINTK(1, "DEVICE READY!!\n"); + priv->dev_state = DEVICE_STATE_READY; + reg_net = register_netdev (priv->net_dev); + DPRINTK(3, "register_netdev=%d\n",reg_net); + } + else { + DPRINTK(1, "dev_state=%d\n",priv->dev_state); + } +} + +static struct sdio_driver ks7010_sdio_driver = { + .name = "ks7910_sdio", + .id_table = if_sdio_ids, + .probe = ks7910_sdio_probe, + .remove = ks7910_sdio_remove, +}; + + +extern int ks_wlan_net_start(struct net_device *dev); +extern int ks_wlan_net_stop(struct net_device *dev); + +static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id *device) +{ + ks_wlan_private *priv; + struct ks_sdio_card *card; + struct net_device *netdev; + unsigned char rw_data; + int i=0, ret; + + DPRINTK(5, "ks7910_sdio_probe()\n"); + + priv = NULL; + netdev=NULL; + + + /* initilize ks_sdio_card */ + card = kzalloc(sizeof(struct ks_sdio_card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + card->func = func; + card->model = 0x10; + spin_lock_init(&card->lock); + + /* select model */ + for (i = 0;i < ARRAY_SIZE(ks_sdio_models);i++) { + if (card->model == ks_sdio_models[i].model) + break; + } + + if (i == ARRAY_SIZE(ks_sdio_models)) { + DPRINTK(5, "unkown card model 0x%x\n", card->model); + goto error; + } + + card->firmware = ks_sdio_models[i].firmware; + + + /*** Initialize SDIO ***/ + sdio_claim_host(func); + + /* bus setting */ + /* Issue config request to override clock rate */ + + /* function blocksize set */ + ret = sdio_set_block_size(func, KS7010_IO_BLOCK_SIZE); + DPRINTK(5, "multi_block=%d sdio_set_block_size()=%d %d\n", func->card->cccr.multi_block, func->cur_blksize, ret); + + /* Allocate the slot current */ + + /* function enable */ + ret = sdio_enable_func(func); + DPRINTK(5, "sdio_enable_func() %d\n", ret); + if (ret) + goto error_free_card; + + /* interrupt disable */ + sdio_writeb(func, 0, INT_ENABLE, &ret); + if (ret) + goto error_free_card; + sdio_writeb(func, 0xff, INT_PENDING, &ret); + if (ret) + goto error_disable_func; + + /* setup interrupt handler */ + ret = sdio_claim_irq(func, ks_sdio_interrupt); + if (ret) + goto error_disable_func; + + sdio_release_host(func); + + sdio_set_drvdata(func, card); + + DPRINTK(5, "class = 0x%X, vendor = 0x%X, " + "device = 0x%X\n", + func->class, func->vendor, func->device); + + + /* private memory allocate */ + netdev = alloc_etherdev(sizeof(*priv)); + if (netdev == NULL) { + printk (KERN_ERR "ks79xx : Unable to alloc new net device\n"); + goto error_release_irq; + } + if (dev_alloc_name(netdev, netdev->name) < 0) { + printk (KERN_ERR "ks79xx : Couldn't get name!\n"); + goto error_free_netdev; + } + + priv = netdev_priv(netdev); + + card->priv = priv; + SET_NETDEV_DEV(netdev, &card->func->dev); /* for create sysfs symlinks */ + + /* private memory initialize */ + priv->ks_wlan_hw.sdio_card = card; + init_completion(&priv->ks_wlan_hw.ks7010_sdio_wait); + priv->ks_wlan_hw.read_buf = NULL; + priv->ks_wlan_hw.read_buf = kmalloc(RX_DATA_SIZE, GFP_KERNEL); + if(!priv->ks_wlan_hw.read_buf){ + goto error_free_netdev; + } + priv->dev_state = DEVICE_STATE_PREBOOT; + priv->net_dev = netdev; + priv->firmware_version[0] = '\0'; + priv->version_size = 0; + priv->last_doze = jiffies; /* set current jiffies */ + priv->last_wakeup = jiffies; + memset(&priv->nstats, 0, sizeof(priv->nstats)); + memset(&priv->wstats, 0, sizeof(priv->wstats)); + + /* sleep mode */ + atomic_set(&priv->sleepstatus.doze_request,0); + atomic_set(&priv->sleepstatus.wakeup_request,0); + atomic_set(&priv->sleepstatus.wakeup_request,0); + + trx_device_init(priv); + hostif_init(priv); + ks_wlan_net_start(netdev); + + /* Read config file */ + ret = ks_wlan_read_config_file(priv); + if (ret) { + printk(KERN_ERR "ks79xx: read configuration file failed !! retern code = %d\n", ret); + goto error_free_read_buf; + } + + /* Upload firmware */ + ret = ks79xx_upload_firmware(priv, card); /* firmware load */ + if(ret){ + printk(KERN_ERR "ks79xx: firmware load failed !! retern code = %d\n", ret); + goto error_free_read_buf; + } + + /* interrupt setting */ + /* clear Interrupt status write (ARMtoSD_InterruptPending FN1:00_0024) */ + rw_data = 0xff; + sdio_claim_host(func); + ret = ks7010_sdio_write(priv, INT_PENDING, &rw_data, sizeof(rw_data)); + sdio_release_host(func); + if(ret){ + DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data); + } + DPRINTK(4, " clear Interrupt : INT_PENDING=%02X\n", rw_data); + + + /* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */ + rw_data = (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS); + sdio_claim_host(func); + ret = ks7010_sdio_write(priv, INT_ENABLE, &rw_data, sizeof(rw_data)); + sdio_release_host(func); + if(ret){ + DPRINTK(1, " error : INT_ENABLE=%02X\n", rw_data); + } + DPRINTK(4, " enable Interrupt : INT_ENABLE=%02X\n", rw_data); + priv->dev_state = DEVICE_STATE_BOOT; + + priv->ks_wlan_hw.ks7010sdio_wq = create_workqueue("ks7010sdio_wq"); + if(!priv->ks_wlan_hw.ks7010sdio_wq){ + DPRINTK(1, "create_workqueue failed !!\n"); + goto error_free_read_buf; + } + + priv->ks_wlan_hw.ks7010sdio_init = create_singlethread_workqueue("ks7010sdio_init"); + if(!priv->ks_wlan_hw.ks7010sdio_init){ + DPRINTK(1, "create_workqueue failed !!\n"); + goto error_free_sdio_wq; + } + + INIT_WORK(&priv->ks_wlan_hw.init_task, card_init_task); + INIT_DELAYED_WORK(&priv->ks_wlan_hw.rw_wq, ks7010_rw_function); + + queue_work(priv->ks_wlan_hw.ks7010sdio_init, &priv->ks_wlan_hw.init_task); + + return 0; + +error_free_sdio_wq: + flush_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); + destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); + priv->ks_wlan_hw.ks7010sdio_wq = NULL; +error_free_read_buf: + kfree(priv->ks_wlan_hw.read_buf); + priv->ks_wlan_hw.read_buf = NULL; +error_free_netdev: + free_netdev(priv->net_dev); + card->priv = NULL; +error_release_irq: + sdio_claim_host(func); + sdio_release_irq(func); +error_disable_func: + sdio_disable_func(func); +error_free_card: + sdio_release_host(func); + sdio_set_drvdata(func, NULL); + kfree(card); +error: + return -ENODEV; +} + +static void ks7910_sdio_remove(struct sdio_func *func) +{ + int ret; + struct ks_sdio_card *card; + struct ks_wlan_private *priv; + struct net_device *netdev; + DPRINTK(1, "ks7910_sdio_remove()\n"); + + card = sdio_get_drvdata(func); + + if(card == NULL) + return; + + DPRINTK(1, "priv = card->priv\n"); + priv = card->priv; + netdev = priv->net_dev; + if(priv){ + ks_wlan_net_stop(netdev); + DPRINTK(1, "ks_wlan_net_stop\n"); + + /* interrupt disable */ + sdio_claim_host(func); + sdio_writeb(func, 0, INT_ENABLE, &ret); + sdio_writeb(func, 0xff, INT_PENDING, &ret); + sdio_release_host(func); + DPRINTK(1, "interrupt disable\n"); + + /* send stop request to MAC */ + { + struct hostif_stop_request_t *pp; + pp = (struct hostif_stop_request_t *)kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL ); + if (pp==NULL) { + DPRINTK(3,"allocate memory failed..\n"); + return; /* to do goto ni suru*/ + } + 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); + + sdio_claim_host(func); + write_to_device(priv, (unsigned char *) pp, hif_align_size(sizeof(*pp))); + sdio_release_host(func); + kfree(pp); + } + DPRINTK(1, "STOP Req\n"); + + if(priv->ks_wlan_hw.ks7010sdio_wq){ + flush_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); + destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); + } + DPRINTK(1, "destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq);\n"); + + if(priv->ks_wlan_hw.ks7010sdio_init){ + flush_workqueue(priv->ks_wlan_hw.ks7010sdio_init); + destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_init); + } + DPRINTK(1, "destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_init);\n"); + + hostif_exit(priv); + DPRINTK(1, "hostif_exit\n"); + + if(!reg_net) + unregister_netdev(netdev); + DPRINTK(1, "unregister_netdev\n"); + + trx_device_exit(priv); + if(priv->ks_wlan_hw.read_buf){ + kfree(priv->ks_wlan_hw.read_buf); + } + free_netdev(priv->net_dev); + card->priv = NULL; + } + + sdio_claim_host(func); + sdio_release_irq(func); + DPRINTK(1, "sdio_release_irq()\n"); + sdio_disable_func(func); + DPRINTK(1, "sdio_disable_func()\n"); + sdio_release_host(func); + + sdio_set_drvdata(func, NULL); + + kfree(card); + DPRINTK(1, "kfree()\n"); + + + DPRINTK(5," Bye !!\n"); + return; +} + +static int __init ks7010_sdio_init( void ) +{ + int status; + printk(KERN_INFO "ks7010_sdio : %s %s\n" ,__DATE__,__TIME__); + + /* register with bus driver core */ + status = sdio_register_driver(&ks7010_sdio_driver); + if(status != 0){ + DPRINTK(1,"ks79xx_sdio : failed to register with bus driver, %d\n", status ); + } + return status; +} + +static void __exit ks7010_sdio_exit( void ) +{ + DPRINTK(5," \n"); + sdio_unregister_driver(&ks7010_sdio_driver); + return; +} + +module_init(ks7010_sdio_init); +module_exit(ks7010_sdio_exit); + +MODULE_AUTHOR("Qi-Hardware based on KeyStream driver"); +MODULE_DESCRIPTION("Driver for KeyStream, KS7010 based SDIO cards. "); +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif +MODULE_SUPPORTED_DEVICE("KS7910"); diff --git a/ks7010/src/ks7010_sdio.h b/ks7010/src/ks7010_sdio.h new file mode 100644 index 0000000..4d50c86 --- /dev/null +++ b/ks7010/src/ks7010_sdio.h @@ -0,0 +1,165 @@ +/* + * + * Driver for KeyStream, KS7010 based SDIO cards. + * + * ks7010_sdio.h + * $Id: ks7010_sdio.h 1019 2009-09-28 05:41:07Z sekine $ + * + * Copyright (C) 2006-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ +#ifndef _KS7010_SDIO_H +#define _KS7010_SDIO_H + +#ifdef DEVICE_ALIGNMENT +#undef DEVICE_ALIGNMENT +#endif +#define DEVICE_ALIGNMENT 32 + +/* SDIO KeyStream vendor and device */ +#define SDIO_VENDOR_ID_KS_CODE_A 0x005b +#define SDIO_VENDOR_ID_KS_CODE_B 0x0023 +#define SDIO_DEVICE_ID_KS_7010 0x7910 + +/* Read Status Register */ +#define READ_STATUS 0x000000 +#define READ_STATUS_BUSY 0 +#define READ_STATUS_IDLE 1 + +/* Read Index Register */ +#define READ_INDEX 0x000004 + +/* Read Data Size Register */ +#define READ_DATA_SIZE 0x000008 + +/* Write Status Register */ +#define WRITE_STATUS 0x00000C +#define WRITE_STATUS_BUSY 0 +#define WRITE_STATUS_IDLE 1 + +/* Write Index Register */ +#define WRITE_INDEX 0x000010 + +/* Write Status/Read Data Size Register + * for network packet (less than 2048 bytes data) + */ +#define WSTATUS_RSIZE 0x000014 +#define WSTATUS_MASK 0x80 /* Write Status Register value */ +#define RSIZE_MASK 0x7F /* Read Data Size Register value [10:4] */ + +/* ARM to SD interrupt Enable */ +#define INT_ENABLE 0x000020 +/* ARM to SD interrupt Pending */ +#define INT_PENDING 0x000024 + +#define INT_GCR_B (1<<7) +#define INT_GCR_A (1<<6) +#define INT_WRITE_STATUS (1<<5) +#define INT_WRITE_INDEX (1<<4) +#define INT_WRITE_SIZE (1<<3) +#define INT_READ_STATUS (1<<2) +#define INT_READ_INDEX (1<<1) +#define INT_READ_SIZE (1<<0) + +/* General Communication Register A */ +#define GCR_A 0x000028 +#define GCR_A_INIT 0 +#define GCR_A_REMAP 1 +#define GCR_A_RUN 2 + +/* General Communication Register B */ +#define GCR_B 0x00002C +#define GCR_B_ACTIVE 0 +#define GCR_B_DOZE 1 + +/* Wakeup Register */ +/* #define WAKEUP 0x008104 */ +/* #define WAKEUP_REQ 0x00 */ +#define WAKEUP 0x008018 +#define WAKEUP_REQ 0x5a + +/* AHB Data Window 0x010000-0x01FFFF */ +#define DATA_WINDOW 0x010000 +#define WINDOW_SIZE 64*1024 + +#define KS7010_IRAM_ADDRESS 0x06000000 + + +/* + * struct define + */ +struct hw_info_t { + struct ks_sdio_card *sdio_card; + struct completion ks7010_sdio_wait; + struct workqueue_struct *ks7010sdio_wq; + struct workqueue_struct *ks7010sdio_init; + struct work_struct init_task; + struct delayed_work rw_wq; + unsigned char *read_buf; + struct tasklet_struct rx_bh_task; +}; + +struct ks_sdio_packet { + struct ks_sdio_packet *next; + u16 nb; + u8 buffer[0] __attribute__((aligned(4))); +}; + + +struct ks_sdio_card { + struct sdio_func *func; + struct ks_wlan_private *priv; + int model; + const char *firmware; + spinlock_t lock; +}; + + + +/* Tx Device struct */ +#define TX_DEVICE_BUFF_SIZE 1024 + +struct tx_device_buffer { + unsigned char *sendp; /* pointer of send req data */ + unsigned int size; + void (*complete_handler)(void *arg1, void *arg2); + void *arg1; + void *arg2; +}; + +struct tx_device{ + struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE]; + unsigned int qhead; /* tx buffer queue first pointer */ + unsigned int qtail; /* tx buffer queue last pointer */ + spinlock_t tx_dev_lock; +}; + +/* Rx Device struct */ +#define RX_DATA_SIZE (2 + 2 + 2347 + 1) +#define RX_DEVICE_BUFF_SIZE 32 + +struct rx_device_buffer { + unsigned char data[RX_DATA_SIZE]; + unsigned int size; +}; + +struct rx_device{ + struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE]; + unsigned int qhead; /* rx buffer queue first pointer */ + unsigned int qtail; /* rx buffer queue last pointer */ + spinlock_t rx_dev_lock; +}; +#ifndef NO_FIRMWARE_CLASS +#define ROM_FILE "ks7010sd.rom" +#define CFG_FILE "ks79xx.cfg" +#else +#define ROM_FILE "/lib/firmware/ks7010sd.rom" +#define CFG_FILE "/lib/firmware/ks79xx.cfg" +#endif +#define KS_WLAN_DRIVER_VERSION_INFO "ks7010 sdio linux 007 ["__DATE__" "__TIME__"]" + +#endif /* _KS7010_SDIO_H */ diff --git a/ks7010/src/ks_debug.c b/ks7010/src/ks_debug.c new file mode 100644 index 0000000..009f5f6 --- /dev/null +++ b/ks7010/src/ks_debug.c @@ -0,0 +1,30 @@ +/* + * Driver for KeyStream 11b/g wireless LAN cards. + * + * ks_debug.c + * $Id: ks_debug.c 991 2009-09-14 01:38:58Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ +#include "ks_wlan.h" +#include "ks_debug.h" + +void print_buffer(unsigned char *p, int length) +{ +#ifdef KS_WLAN_DEBUG + int i; +#define HEX_OFFSET "\ + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F" + printk(HEX_OFFSET); + for (i=0; i + + +#ifdef KS_WLAN_DEBUG +#define DPRINTK(n, fmt, args...) \ + if (KS_WLAN_DEBUG>(n)) printk(KERN_NOTICE "%s: "fmt, __FUNCTION__, ## args) +#else +#define DPRINTK(n, fmt, args...) +#endif + +extern void print_buffer(unsigned char *p, int size); + +#endif /* _KS_DEBUG_H */ diff --git a/ks7010/src/ks_hostif.c b/ks7010/src/ks_hostif.c new file mode 100644 index 0000000..630bd19 --- /dev/null +++ b/ks7010/src/ks_hostif.c @@ -0,0 +1,2655 @@ +/* + * Driver for KeyStream wireless LAN cards. + * + * ks_hostif.c + * $Id: ks_hostif.c 996 2009-09-14 02:54:21Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#include "ks_wlan.h" +#include "ks_debug.h" +#include "ks_hostif.h" +#include "eap_packet.h" +#include "michael_mic.h" + +#include +#include + +/* Include Wireless Extension definition and check version */ +#ifndef WIRELESS_EXT +#include +#endif /* WIRELESS_EXT */ +#if WIRELESS_EXT > 12 +#include /* New driver API */ +#endif /* WIRELESS_EXT > 12 */ + +extern int ks_wlan_hw_tx(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(ks_wlan_private *priv); +extern int ks_wlan_hw_power_save(ks_wlan_private *priv); + +/* macro */ +#define inc_smeqhead(priv) \ + ( priv->sme_i.qhead = (priv->sme_i.qhead + 1) % SME_EVENT_BUFF_SIZE ) +#define inc_smeqtail(priv) \ + ( priv->sme_i.qtail = (priv->sme_i.qtail + 1) % SME_EVENT_BUFF_SIZE ) +#define cnt_smeqbody(priv) \ + (((priv->sme_i.qtail + SME_EVENT_BUFF_SIZE) - (priv->sme_i.qhead)) % SME_EVENT_BUFF_SIZE ) + +#define KS_WLAN_MEM_FLAG (GFP_ATOMIC) + +static +inline u8 get_BYTE(ks_wlan_private *priv) +{ + u8 data; + data = *(priv->rxp)++; + /* length check in advance ! */ + --(priv->rx_size); + return data; +} + +static +inline u16 get_WORD(ks_wlan_private *priv) +{ + u16 data; + data = (get_BYTE(priv) & 0xff); + data |= ((get_BYTE(priv) << 8) & 0xff00); + return data; +} + +static +inline u32 get_DWORD(ks_wlan_private *priv) +{ + u32 data; + data = (get_BYTE(priv) & 0xff); + data |= ((get_BYTE(priv) << 8) & 0x0000ff00); + data |= ((get_BYTE(priv) << 16) & 0x00ff0000); + data |= ((get_BYTE(priv) << 24) & 0xff000000); + return data; +} + +void ks_wlan_hw_wakeup_task(struct work_struct *work) +{ + 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){ + 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"); + schedule_work(&priv->ks_wlan_wakeup_task); + return; + } + } + else{ + DPRINTK(1,"ps_status=%d\n",ps_status); + } + + /* power save */ + if(atomic_read(&priv->sme_task.count) > 0){ + DPRINTK(4,"sme task enable.\n"); + tasklet_enable(&priv->sme_task); + } +} + +static +int ks_wlan_do_power_save(ks_wlan_private *priv) +{ + int rc=0; + + DPRINTK(4,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status)); + +#ifdef _SDIO_ + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + } + else{ + priv->dev_state = DEVICE_STATE_READY; + } +#else + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + switch(atomic_read(&priv->psstatus.status)){ + case PS_ACTIVE_SET: + case PS_WAKEUP: + case PS_SAVE_SET: + case PS_SNOOZE: + break; + case PS_CONF_WAIT: + atomic_set(&priv->psstatus.confirm_wait,0); + break; + case PS_NONE: + default: + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + break; + } + + } + else{ + switch(atomic_read(&priv->psstatus.status)){ + case PS_ACTIVE_SET: + case PS_WAKEUP: + case PS_SAVE_SET: + break; + case PS_CONF_WAIT: + atomic_set(&priv->psstatus.confirm_wait,0); + atomic_set(&priv->psstatus.status, PS_WAKEUP); + break; + case PS_SNOOZE: + ks_wlan_hw_power_save(priv); + break; + case PS_NONE: + default: + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + break; + } + } +#endif + return rc; +} + +static +int get_current_ap(ks_wlan_private *priv, struct link_ap_info_t *ap_info) +{ + struct local_ap_t *ap; +#if WIRELESS_EXT > 13 + union iwreq_data wrqu; + struct net_device *netdev=priv->net_dev; +#endif /* WIRELESS_EXT > 13 */ + int rc=0; + + DPRINTK(3,"\n"); + ap = &(priv->current_ap); + + 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); + /* essid */ + 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); + ap->rate_set.size = ap_info->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]), + ap_info->ext_rate_set.size); + ap->rate_set.size += ap_info->ext_rate_set.size; + } + /* channel */ + ap->channel = ap_info->ds_parameter.channel; + /* rssi */ + ap->rssi = ap_info->rssi; + /* sq */ + ap->sq = ap_info->sq; + /* noise */ + ap->noise = ap_info->noise; + /* capability */ + ap->capability = ap_info->capability; + /* rsn */ + 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){ + ap->rsn_ie.size = ap_info->rsn.size; + 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); + } + } + 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){ + ap->wpa_ie.size = ap_info->rsn.size; + 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); + } + } + else{ + ap->rsn_ie.id = 0; + ap->rsn_ie.size = 0; + ap->wpa_ie.id = 0; + ap->wpa_ie.size = 0; + } + +#if WIRELESS_EXT > 13 + wrqu.data.length = 0; + wrqu.data.flags = 0; + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + 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]); + wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL); + } +#endif + 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); + + + return rc; +} + +static +int get_ap_information(ks_wlan_private *priv, struct ap_info_t *ap_info, struct local_ap_t *ap) +{ + unsigned char *bp; + int bsize,offset; + int rc=0; + + DPRINTK(3,"\n"); + memset(ap,0,sizeof(struct local_ap_t)); + + /* bssid */ + memcpy(&(ap->bssid[0]),&(ap_info->bssid[0]),ETH_ALEN); + /* rssi */ + ap->rssi = ap_info->rssi; + /* sq */ + ap->sq = ap_info->sq; + /* noise */ + ap->noise = ap_info->noise; + /* capability */ + ap->capability = ap_info->capability; + /* channel */ + ap->channel = ap_info->ch_info; + + bp = &(ap_info->body[0]); + bsize = ap_info->body_size; + offset = 0; + + while(bsize > offset){ + /* DPRINTK(4, "Element ID=%d \n",*bp); */ + switch(*bp){ + case 0: /* ssid */ + if(*(bp+1) <= SSID_MAX_SIZE){ + ap->ssid.size = *(bp+1); + } + else { + DPRINTK(1, "size over :: ssid size=%d \n",*(bp+1)); + ap->ssid.size = SSID_MAX_SIZE; + } + memcpy(&(ap->ssid.body[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{ + DPRINTK(1, "size over :: rate size=%d \n", + (*(bp+1) + ap->rate_set.size)); + memcpy(&(ap->rate_set.body[ap->rate_set.size]),bp+2, + RATE_SET_MAX_SIZE - ap->rate_set.size); + ap->rate_set.size += (RATE_SET_MAX_SIZE - ap->rate_set.size); + } + break; + case 3: /* DS parameter */ + break; + 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)); + ap->rsn_ie.size = RSN_IE_BODY_MAX; + } + 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 */ + ap->wpa_ie.id = *bp; + if(*(bp+1) <= RSN_IE_BODY_MAX){ + ap->wpa_ie.size = *(bp+1); + }else{ + DPRINTK(1, "size over :: wpa size=%d \n",*(bp+1)); + ap->wpa_ie.size = RSN_IE_BODY_MAX; + } + memcpy(&(ap->wpa_ie.body[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 */ + break; + default: + 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 */ + } + + return rc; +} + +static +void hostif_data_indication(ks_wlan_private *priv) +{ + unsigned int rx_ind_size; /* indicate data size */ + struct sk_buff *skb; + unsigned short auth_type; + unsigned char temp[256]; + + unsigned char RecvMIC[8]; + char buf[128]; + struct ether_hdr *eth_hdr; + unsigned short eth_proto; + unsigned long now; + struct mic_failure_t *mic_failure; + struct ieee802_1x_hdr *aa1x_hdr; + struct wpa_eapol_key *eap_key; + struct michel_mic_t michel_mic; +#if WIRELESS_EXT > 14 + union iwreq_data wrqu; +#endif /* WIRELESS_EXT > 14 */ + + DPRINTK(3,"\n"); + + /* min length check */ + if (priv->rx_size <= ETH_HLEN) { + DPRINTK(3,"rx_size = %d\n", priv->rx_size); + priv->nstats.rx_errors++; + return; + } + + auth_type = get_WORD(priv); /* AuthType */ + get_WORD(priv); /* Reserve Area */ + + eth_hdr = (struct ether_hdr *)(priv->rxp); + eth_proto = ntohs(eth_hdr->h_proto); + DPRINTK(3,"ether protocol = %04X\n", eth_proto); + + /* source address check */ + if (!memcmp(&priv->eth_addr[0],eth_hdr->h_source, ETH_ALEN)){ + 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]); + 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"); + 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); + /* MIC save */ + 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(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; + } + 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; + } + priv->wpa.mic_failure.last_failure_time = now; +#if WIRELESS_EXT > 14 + /* needed parameters: count, keyid, key type, TSC */ + 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]); + memset(&wrqu, 0, sizeof(wrqu)); + wrqu.data.length = strlen(buf); + DPRINTK(4,"IWEVENT:MICHAELMICFAILURE\n"); + wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); +#endif /* WIRELESS_EXT > 14 */ + return; + } + } + } + } + + 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 */ + 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); + atomic_set(&priv->psstatus.snooze_guard, 1); + } + + /* rx indication */ + skb->dev = priv->net_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); + } else { + printk (KERN_WARNING"%s: Memory squeeze, dropping packet.\n",skb->dev->name); + priv->nstats.rx_dropped++; + } + break; + 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); + + 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); + + 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); + atomic_set(&priv->psstatus.snooze_guard, 1); + } + + /* rx indication */ + skb->dev = priv->net_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); + } else { + 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"); + priv->nstats.rx_errors++; + } +} + +static +void hostif_mib_get_confirm(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; + + 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 */ + + if (mib_status != 0) { + /* in case of error */ + 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"); + hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS); + memcpy(priv->eth_addr, priv->rxp, ETH_ALEN); + priv->mac_address_valid = 1; + dev->dev_addr[0] = priv->eth_addr[0]; + dev->dev_addr[1] = priv->eth_addr[1]; + dev->dev_addr[2] = priv->eth_addr[2]; + dev->dev_addr[3] = priv->eth_addr[3]; + dev->dev_addr[4] = priv->eth_addr[4]; + 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]); + break; + case DOT11_PRODUCT_VERSION: + /* firmware version */ + DPRINTK(3," mib_attribute=DOT11_PRODUCT_VERSION\n"); + priv->version_size = priv->rx_size; + memcpy(priv->firmware_version, priv->rxp, priv->rx_size); + priv->firmware_version[priv->rx_size] = '\0'; + 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); + break; + case LOCAL_EEPROM_SUM: + memcpy(&priv->eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum)); + DPRINTK(1, "eeprom_sum.type=%x, eeprom_sum.result=%x\n", priv->eeprom_sum.type, priv->eeprom_sum.result); + if(priv->eeprom_sum.type == 0){ + priv->eeprom_checksum = EEPROM_CHECKSUM_NONE; + }else if(priv->eeprom_sum.type == 1){ + if(priv->eeprom_sum.result == 0){ + priv->eeprom_checksum = EEPROM_NG; + printk("LOCAL_EEPROM_SUM NG\n"); + }else if(priv->eeprom_sum.result == 1){ + priv->eeprom_checksum = EEPROM_OK; + } + }else{ + printk("LOCAL_EEPROM_SUM error!\n"); + } + break; + default: + DPRINTK(1,"mib_attribute=%08x\n",(unsigned int)mib_attribute); + break; + } +} + +static +void hostif_mib_set_confirm(ks_wlan_private *priv) +{ + uint32_t mib_status; /* +04 MIB Status */ + uint32_t mib_attribute; /* +08 MIB attribute */ + + DPRINTK(3,"\n"); + + 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); + } + + switch (mib_attribute) { + case DOT11_RTS_THRESHOLD: + hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_CONFIRM); + break; + case DOT11_FRAGMENTATION_THRESHOLD: + hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_CONFIRM); + break; + case DOT11_WEP_DEFAULT_KEY_ID: + 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) + hostif_sme_enqueue(priv, SME_SET_PMK_TSC); + else + hostif_sme_enqueue(priv, SME_WEP_KEY1_CONFIRM); + break; + case DOT11_WEP_DEFAULT_KEY_VALUE2: + DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE2:mib_status=%d\n",(int)mib_status); + if(priv->wpa.rsn_enabled) + hostif_sme_enqueue(priv, SME_SET_GMK1_TSC); + else + hostif_sme_enqueue(priv, SME_WEP_KEY2_CONFIRM); + break; + case DOT11_WEP_DEFAULT_KEY_VALUE3: + DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE3:mib_status=%d\n",(int)mib_status); + if(priv->wpa.rsn_enabled) + hostif_sme_enqueue(priv, SME_SET_GMK2_TSC); + else + hostif_sme_enqueue(priv, SME_WEP_KEY3_CONFIRM); + break; + case DOT11_WEP_DEFAULT_KEY_VALUE4: + DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE4:mib_status=%d\n",(int)mib_status); + if(!priv->wpa.rsn_enabled) + hostif_sme_enqueue(priv, SME_WEP_KEY4_CONFIRM); + break; + case DOT11_PRIVACY_INVOKED: + 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); + hostif_sme_enqueue(priv, SME_RSN_ENABLED_CONFIRM); + break; + case LOCAL_RSN_MODE: + hostif_sme_enqueue(priv, SME_RSN_MODE_CONFIRM); + break; + case LOCAL_MULTICAST_ADDRESS: + hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST); + break; + case LOCAL_MULTICAST_FILTER: + hostif_sme_enqueue(priv, SME_MULTICAST_CONFIRM); + break; + case LOCAL_CURRENTADDRESS: + 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); + hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM); + break; + case DOT11_RSN_CONFIG_UNICAST_CIPHER: + DPRINTK(2,"DOT11_RSN_CONFIG_UNICAST_CIPHER:mib_status=%d\n",(int)mib_status); + hostif_sme_enqueue(priv, SME_RSN_UCAST_CONFIRM); + break; + case DOT11_RSN_CONFIG_AUTH_SUITE: + DPRINTK(2,"DOT11_RSN_CONFIG_AUTH_SUITE:mib_status=%d\n",(int)mib_status); + hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM); + break; + case DOT11_PMK_TSC: + DPRINTK(2,"DOT11_PMK_TSC:mib_status=%d\n",(int)mib_status); + break; + case DOT11_GMK1_TSC: + DPRINTK(2,"DOT11_GMK1_TSC:mib_status=%d\n",(int)mib_status); + if(atomic_read(&priv->psstatus.snooze_guard)){ + atomic_set(&priv->psstatus.snooze_guard, 0); + } + break; + case DOT11_GMK2_TSC: + DPRINTK(2,"DOT11_GMK2_TSC:mib_status=%d\n",(int)mib_status); + if(atomic_read(&priv->psstatus.snooze_guard)){ + atomic_set(&priv->psstatus.snooze_guard, 0); + } + break; + case LOCAL_PMK: + DPRINTK(2,"LOCAL_PMK:mib_status=%d\n",(int)mib_status); + break; + case LOCAL_GAIN: + DPRINTK(2,"LOCAL_GAIN:mib_status=%d\n",(int)mib_status); + break; +#ifdef WPS + case LOCAL_WPS_ENABLE: + DPRINTK(2,"LOCAL_WPS_ENABLE:mib_status=%d\n",(int)mib_status); + break; + case LOCAL_WPS_PROBE_REQ: + DPRINTK(2,"LOCAL_WPS_PROBE_REQ:mib_status=%d\n",(int)mib_status); + break; +#endif /* WPS */ + case LOCAL_REGION: + DPRINTK(2,"LOCAL_REGION:mib_status=%d\n",(int)mib_status); + default : + break; + } +} + +static +void hostif_power_mngmt_confirm(ks_wlan_private *priv) +{ + DPRINTK(3,"\n"); + + if(priv->reg.powermgt > POWMGT_ACTIVE_MODE && + priv->reg.operation_mode == MODE_INFRASTRUCTURE){ +#if !defined(_SDIO_) + atomic_set(&priv->psstatus.status,PS_SAVE_SET); +#endif + atomic_set(&priv->psstatus.confirm_wait, 0); + priv->dev_state = DEVICE_STATE_SLEEP; + ks_wlan_hw_power_save(priv); + }else{ + priv->dev_state = DEVICE_STATE_READY; +#if !defined(_SDIO_) + atomic_set(&priv->psstatus.status,PS_ACTIVE_SET); +#endif + } + +} + +static +void hostif_sleep_confirm(ks_wlan_private *priv) +{ + 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); +} + +static +void hostif_start_confirm(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); + } +#endif + DPRINTK(3," scan_ind_count=%d\n",priv->scan_ind_count); + hostif_sme_enqueue(priv, SME_START_CONFIRM); +} + +static +void hostif_connect_indication(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; +#if WIRELESS_EXT > 13 + union iwreq_data wrqu0; +#endif /* WIRELESS_EXT > 13 */ + connect_code = get_WORD(priv); + + switch(connect_code){ + case RESULT_CONNECT: /* connect */ + DPRINTK(3,"connect :: scan_ind_count=%d\n",priv->scan_ind_count); + if(!(priv->connect_status & FORCE_DISCONNECT)) + netif_carrier_on(netdev); + tmp = FORCE_DISCONNECT & priv->connect_status; + priv->connect_status = tmp + CONNECT_STATUS; + break; + case RESULT_DISCONNECT: /* disconnect */ + DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); + 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); + netif_carrier_off(netdev); + tmp = FORCE_DISCONNECT & priv->connect_status; + priv->connect_status = tmp + DISCONNECT_STATUS; + break; + } + + 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 ){ + /* for power save */ + atomic_set(&priv->psstatus.snooze_guard, 0); + atomic_set(&priv->psstatus.confirm_wait,0); +#if !defined(_SDIO_) + atomic_set(&priv->psstatus.status, PS_NONE); +#endif + } + ks_wlan_do_power_save(priv); + +#if WIRELESS_EXT > 13 + 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 ){ + 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); + wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL); + } +#endif /* WIRELESS_EXT > 13 */ + priv->scan_ind_count=0; +} + +static +void hostif_scan_indication(ks_wlan_private *priv) +{ + int i; + struct ap_info_t *ap_info; + + 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])); + 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])); + priv->aplist.size = priv->scan_ind_count; + } + else{ + DPRINTK(4," count over :: scan_ind_count=%d\n", priv->scan_ind_count); + } + + +} + +static +void hostif_stop_confirm(ks_wlan_private *priv) +{ + 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"); +#ifdef _SDIO_ + if(priv->dev_state == DEVICE_STATE_SLEEP) + priv->dev_state = DEVICE_STATE_READY; +#endif + + /* disconnect indication */ + 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; + printk("IWEVENT: disconnect\n"); + + 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 ){ + memset(wrqu0.ap_addr.sa_data, '\0', ETH_ALEN); + DPRINTK(3,"IWEVENT: disconnect\n"); + printk("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; + } + + hostif_sme_enqueue(priv, SME_STOP_CONFIRM); +} + +static +void hostif_ps_adhoc_set_confirm(ks_wlan_private *priv) +{ + DPRINTK(3,"\n"); + priv->infra_status = 0; /* infrastructure mode cancel */ + hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); + +} + +static +void hostif_infrastructure_set_confirm(ks_wlan_private *priv) +{ + uint16_t result_code; + DPRINTK(3,"\n"); + result_code = get_WORD(priv); + 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(ks_wlan_private *priv) +{ + DPRINTK(3,"\n"); + priv->infra_status = 1; /* infrastructure mode set */ + hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); +} + +static +void hostif_associate_indication(ks_wlan_private *priv) +{ +#if WIRELESS_EXT > 14 + struct association_request_t *assoc_req; + struct association_response_t *assoc_resp; + unsigned char *pb; + union iwreq_data wrqu; + char buf[IW_CUSTOM_MAX]; + char *pbuf = &buf[0]; + int i; + + static const char associnfo_leader0[] = "ASSOCINFO(ReqIEs="; + static const char associnfo_leader1[] = " RespIEs="; + + DPRINTK(3,"\n"); + assoc_req = (struct association_request_t *)(priv->rxp); + assoc_resp = (struct association_response_t *)(assoc_req+1); + pb = (unsigned char *)(assoc_resp+1); + + 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; + + for (i = 0; i < assoc_req->reqIEs_size; i++) + 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; + + 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, ")"); + wrqu.data.length += 1; + + DPRINTK(3,"IWEVENT:ASSOCINFO\n"); + wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); +#endif /* WIRELESS_EXT > 14 */ +} + +static +void hostif_bss_scan_confirm(ks_wlan_private *priv) +{ + unsigned int result_code; +#if WIRELESS_EXT > 13 + struct net_device *dev = priv->net_dev; + union iwreq_data wrqu; +#endif /* WIRELESS_EXT > 13 */ + result_code = get_DWORD(priv); + 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); + +#if WIRELESS_EXT > 13 + wrqu.data.length = 0; + wrqu.data.flags = 0; + DPRINTK(3,"IWEVENT: SCAN CONFIRM\n"); + wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); +#endif /* WIRELESS_EXT > 13 */ + priv->scan_ind_count=0; +} + +static +void hostif_phy_information_confirm(ks_wlan_private *priv) +{ + struct iw_statistics *wstats = &priv->wstats; + unsigned char rssi,signal,noise; + unsigned char LinkSpeed; + unsigned int TransmittedFrameCount, ReceivedFragmentCount; + unsigned int FailedCount, FCSErrorCount; + + DPRINTK(3,"\n"); + rssi = get_BYTE(priv); + signal = get_BYTE(priv); + noise = get_BYTE(priv); + LinkSpeed = get_BYTE(priv); + TransmittedFrameCount = get_DWORD(priv); + ReceivedFragmentCount = get_DWORD(priv); + FailedCount = get_DWORD(priv); + FCSErrorCount = get_DWORD(priv); + + DPRINTK(4, "phyinfo confirm rssi=%d signal=%d\n", rssi, signal); + priv->current_rate = (LinkSpeed & RATE_MASK); + wstats->qual.qual = signal; + wstats->qual.level = 256 - rssi; + wstats->qual.noise = 0; /* invalid noise value */ + wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; + + DPRINTK(3,"\n rssi=%u\n 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); + + /* wake_up_interruptible_all(&priv->confirm_wait); */ + complete(&priv->confirm_wait); +} + +static +void hostif_mic_failure_confirm(ks_wlan_private *priv) +{ + DPRINTK(3,"mic_failure=%u\n",priv->wpa.mic_failure.failure); + hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM); +} + + +static +void hostif_event_check(ks_wlan_private *priv) +{ + unsigned short event; + + DPRINTK(4, "\n"); + event = get_WORD(priv); /* get event */ + switch (event) { + case HIF_DATA_IND: + hostif_data_indication(priv); + break; + case HIF_MIB_GET_CONF: + hostif_mib_get_confirm(priv); + break; + case HIF_MIB_SET_CONF: + hostif_mib_set_confirm(priv); + break; + case HIF_POWERMGT_CONF: + hostif_power_mngmt_confirm(priv); + break; + case HIF_SLEEP_CONF: + hostif_sleep_confirm(priv); + break; + case HIF_START_CONF: + hostif_start_confirm(priv); + break; + case HIF_CONNECT_IND: + hostif_connect_indication(priv); + break; + case HIF_STOP_CONF: + hostif_stop_confirm(priv); + break; + case HIF_PS_ADH_SET_CONF: + hostif_ps_adhoc_set_confirm(priv); + break; + case HIF_INFRA_SET_CONF: + case HIF_INFRA_SET2_CONF: + hostif_infrastructure_set_confirm(priv); + break; + case HIF_ADH_SET_CONF: + case HIF_ADH_SET2_CONF: + hostif_adhoc_set_confirm(priv); + break; + case HIF_ASSOC_INFO_IND: + hostif_associate_indication(priv); + break; + case HIF_MIC_FAILURE_CONF: + hostif_mic_failure_confirm(priv); + break; + case HIF_SCAN_CONF: + hostif_bss_scan_confirm(priv); + break; + case HIF_PHY_INFO_CONF: + case HIF_PHY_INFO_IND: + hostif_phy_information_confirm(priv); + break; + case HIF_SCAN_IND: + hostif_scan_indication(priv); + break; + case HIF_AP_SET_CONF: + default: + //DPRINTK(1, "undefined event[%04X]\n", event); + printk("undefined event[%04X]\n", event); + /* wake_up_all(&priv->confirm_wait); */ + complete(&priv->confirm_wait); + break; + } + + /* add event to hostt buffer */ + priv->hostt.buff[priv->hostt.qtail] = event; + 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(ks_wlan_private *priv, struct sk_buff *packet) +{ + unsigned int packet_len=0; + + unsigned char *buffer=NULL; + unsigned int length=0; + struct hostif_data_request_t *pp; + 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; + 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); + 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)) + netif_wake_queue(priv->net_dev); + 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)) + netif_stop_queue(priv->net_dev); +#if !defined(_SDIO_) + schedule_work(&priv->ks_wlan_wakeup_task); +#endif + } + + 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 ); + + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + dev_kfree_skb(packet); + return -2; + } + + p = (unsigned char *)pp->data; + + buffer = packet->data; + length = packet->len; + + /* packet check */ + eth = (struct ethhdr *)packet->data; + 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]); + return -3; + } + + /* MAC address copy */ + memcpy(p, buffer, 12); /* DST/SRC MAC address */ + p += 12; + buffer += 12; + length -= 12; + /* EtherType/Length check */ + if (*(buffer+1) + (*buffer << 8) > 1500) { + /* ProtocolEAP = *(buffer+1) + (*buffer << 8); */ + /* 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") */ + packet_len += 6; + } else { + DPRINTK(4,"DIX\n"); + /* Length(2 byte) delete */ + buffer += 2; + length -= 2; + packet_len -= 2; + } + + /* pp->data copy */ + memcpy(p, buffer, length); + + p += length; + + /* for WPA */ + eth_hdr = (struct ether_hdr *)&pp->data[0]; + 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 (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); + + }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 + 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); + + /* tx request */ + 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); + hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST); + } + if(priv->wpa.mic_failure.failure==2) + priv->wpa.mic_failure.stop=1; + } + + return result; +} + +#if defined(_SPI_) +#define ps_confirm_wait_inc(priv) +#else +#define ps_confirm_wait_inc(priv) do{if(atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET){ \ + atomic_inc(&priv->psstatus.confirm_wait); \ + /* atomic_set(&priv->psstatus.status, PS_CONF_WAIT);*/ \ + } }while(0) +#endif + +static +void hostif_mib_get_request( 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"); + 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); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_mib_set_request( 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"); + + if (priv->dev_state < DEVICE_STATE_BOOT) { + 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) { + 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); + 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); +} + +static +void hostif_start_request( ks_wlan_private *priv, unsigned char mode ) +{ + struct hostif_start_request_t *pp; + + DPRINTK(3,"\n"); + + /* make primitive */ + 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); + + /* 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; +} + +static +void hostif_ps_adhoc_set_request(ks_wlan_private *priv) +{ + struct hostif_ps_adhoc_set_request_t *pp; + uint16_t capability; + + 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) { + 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->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM */ + } + 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); +} + +static +void hostif_infrastructure_set_request(ks_wlan_private *priv) +{ + struct hostif_infrastructure_set_request_t *pp; + uint16_t capability; + + 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) { + 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->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + pp->ssid.size = priv->reg.ssid.size; + memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + } + pp->capability = cpu_to_le16((uint16_t)capability); + pp->beacon_lost_count = cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); + pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); + + pp->channel_list.body[0] = 1; + pp->channel_list.body[1] = 8; + pp->channel_list.body[2] = 2; + pp->channel_list.body[3] = 9; + pp->channel_list.body[4] = 3; + pp->channel_list.body[5] = 10; + pp->channel_list.body[6] = 4; + pp->channel_list.body[7] = 11; + pp->channel_list.body[8] = 5; + pp->channel_list.body[9] = 12; + pp->channel_list.body[10] = 6; + pp->channel_list.body[11] = 13; + pp->channel_list.body[12] = 7; + if(priv->reg.phy_type == D_11G_ONLY_MODE){ + pp->channel_list.size = 13; + }else{ + pp->channel_list.body[13] = 14; + pp->channel_list.size = 14; + } + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)),NULL, NULL, NULL); +} + +void hostif_infrastructure_set2_request(ks_wlan_private *priv) +{ + struct hostif_infrastructure_set2_request_t *pp; + uint16_t capability; + + 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) { + 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->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + pp->ssid.size = priv->reg.ssid.size; + memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + } + pp->capability = cpu_to_le16((uint16_t)capability); + pp->beacon_lost_count = cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); + pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); + + pp->channel_list.body[0] = 1; + pp->channel_list.body[1] = 8; + pp->channel_list.body[2] = 2; + pp->channel_list.body[3] = 9; + pp->channel_list.body[4] = 3; + pp->channel_list.body[5] = 10; + pp->channel_list.body[6] = 4; + pp->channel_list.body[7] = 11; + pp->channel_list.body[8] = 5; + pp->channel_list.body[9] = 12; + pp->channel_list.body[10] = 6; + pp->channel_list.body[11] = 13; + pp->channel_list.body[12] = 7; + if(priv->reg.phy_type == D_11G_ONLY_MODE){ + pp->channel_list.size = 13; + }else{ + pp->channel_list.body[13] = 14; + pp->channel_list.size = 14; + } + + memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)),NULL, NULL, NULL); +} + +static +void hostif_adhoc_set_request(ks_wlan_private *priv) +{ + struct hostif_adhoc_set_request_t *pp; + uint16_t capability; + + 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) { + 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->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + pp->ssid.size = priv->reg.ssid.size; + memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + } + pp->capability = cpu_to_le16((uint16_t)capability); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_adhoc_set2_request(ks_wlan_private *priv) +{ + struct hostif_adhoc_set2_request_t *pp; + uint16_t capability; + + 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) { + 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->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + pp->ssid.size = priv->reg.ssid.size; + memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + } + pp->capability = cpu_to_le16((uint16_t)capability); + + pp->channel_list.body[0] = priv->reg.channel; + pp->channel_list.size = 1; + memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_stop_request( ks_wlan_private *priv ) +{ + struct hostif_stop_request_t *pp; + + 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"); + 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); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_phy_information_request( ks_wlan_private *priv ) +{ + struct hostif_phy_information_request_t *pp; + + 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) { + 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); + } + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_power_mngmt_request( 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); + /* 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"); + 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); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_sleep_request( ks_wlan_private *priv, unsigned long mode) +{ + struct hostif_sleep_request_t *pp; + + DPRINTK(3,"mode=%lu \n",mode); + + 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"); + 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); + + /* 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); + return; + } +} + + +static +void hostif_bss_scan_request( 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"); + /* 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"); + 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->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->channel_list.body[0] = 1; + pp->channel_list.body[1] = 8; + pp->channel_list.body[2] = 2; + pp->channel_list.body[3] = 9; + pp->channel_list.body[4] = 3; + pp->channel_list.body[5] = 10; + pp->channel_list.body[6] = 4; + pp->channel_list.body[7] = 11; + pp->channel_list.body[8] = 5; + pp->channel_list.body[9] = 12; + pp->channel_list.body[10] = 6; + pp->channel_list.body[11] = 13; + pp->channel_list.body[12] = 7; + if(priv->reg.phy_type == D_11G_ONLY_MODE){ + pp->channel_list.size = 13; + }else{ + pp->channel_list.body[13] = 14; + pp->channel_list.size = 14; + } + pp->ssid.size = 0; + + /* specified SSID SCAN */ + 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); + + priv->aplist.size = 0; + priv->scan_ind_count=0; +} + +static +void hostif_mic_failure_request( 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); + /* 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"); + 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); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +/* Device I/O Recieve indicate */ +static void devio_rec_ind(ks_wlan_private *priv, unsigned char *p, unsigned int size) +{ + if (priv->device_open_status) { + 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; + + if (atomic_read(&priv->event_count) != DEVICE_STOCK_COUNT) { + /* rx event count inc */ + atomic_inc(&priv->event_count); + } + atomic_inc(&priv->rec_count); + if (atomic_read(&priv->rec_count)==DEVICE_STOCK_COUNT) + atomic_set(&priv->rec_count, 0); + + wake_up_interruptible_all(&priv->devread_wait); + + /* release spin lock */ + spin_unlock(&priv->dev_read_lock); + } +} + +void hostif_receive( ks_wlan_private *priv, unsigned char *p, unsigned int size ) +{ + DPRINTK(4,"\n"); + + devio_rec_ind(priv, p, size); + + priv->rxp = p; + priv->rx_size = size; + + if (get_WORD(priv) == priv->rx_size) { /* length check !! */ + hostif_event_check(priv); /* event check */ + } +} + + +static +void hostif_sme_set_wep(ks_wlan_private *priv, int type) +{ + uint32_t val; + switch(type){ + case SME_WEP_INDEX_REQUEST: + 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 ); + 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] ); + 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, + &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] ); + 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, + &priv->reg.wep_key[3].val[0]); + break; + case SME_WEP_FLAG_REQUEST: + 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 ); + break; + } + + return ; +} + +struct wpa_suite_t { + unsigned short size; + unsigned char suite[4][CIPHER_ID_LEN]; +} __attribute__((packed)); + +struct rsn_mode_t { + uint32_t rsn_mode; + uint16_t rsn_capability; +} __attribute__((packed)); + +static +void hostif_sme_set_rsn(ks_wlan_private *priv, int type) +{ + struct wpa_suite_t wpa_suite; + struct rsn_mode_t rsn_mode; + uint32_t val; + + memset(&wpa_suite,0,sizeof(wpa_suite)); + + switch(type){ + case SME_RSN_UCAST_REQUEST: + 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); + else + 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); + else + 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); + else + 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); + else + 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); + else + 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, + MIB_VALUE_TYPE_OSTRING, &wpa_suite); + break; + case SME_RSN_MCAST_REQUEST: + 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); + else + 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); + else + 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); + else + 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); + else + 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); + else + 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] ); + break; + case SME_RSN_AUTH_REQUEST: + 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); + else + 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); + else + 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); + else + 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); + else + 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, + MIB_VALUE_TYPE_OSTRING, &wpa_suite); + break; + case SME_RSN_ENABLED_REQUEST: + 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 ); + 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); + } + hostif_mib_set_request(priv, LOCAL_RSN_MODE,sizeof(rsn_mode), + MIB_VALUE_TYPE_OSTRING,&rsn_mode ); + break; + + } + return; +} + +static +void hostif_sme_mode_setup(ks_wlan_private *priv) +{ + unsigned char rate_size; + unsigned char rate_octet[RATE_SET_MAX_SIZE]; + 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){ + 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.size = 4; + }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.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 ; + 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 + 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; + else + rate_octet[0]=TX_RATE_2M | BASIC_RATE; + rate_size = 1; + } + + /* rate set update */ + priv->reg.rate_set.size = rate_size; + memcpy(&priv->reg.rate_set.body[0], &rate_octet[0], rate_size); + + 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)) { + hostif_infrastructure_set_request(priv); + } + 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]); + } + break; + case MODE_ADHOC: + /* IEEE802.11 Ad-Hoc mode */ + if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) { + hostif_adhoc_set_request(priv); + } + 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]); + } + break; + default: + break; + } + + return ; +} + +static +void hostif_sme_multicast_set(ks_wlan_private *priv) +{ + + struct net_device *dev = priv->net_dev; + int mc_count; + struct dev_mc_list *mclist; + char set_address[NIC_MAX_MCAST_LIST*ETH_ALEN]; + unsigned long filter_type; + int i; + + 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 ((dev->mc_count > 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 = dev->mc_count; + for (i = 0, mclist = dev->mc_list; mclist && i < mc_count; i++, mclist = mclist->next) + memcpy(&set_address[i*ETH_ALEN], mclist->dmi_addr, ETH_ALEN); + 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); + priv->sme_i.sme_flag |= SME_MULTICAST; + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), + MIB_VALUE_TYPE_BOOL, &filter_type); + } + } + + spin_unlock(&priv->multicast_spin); + +} + +static +void hostif_sme_powermgt_set(ks_wlan_private *priv) +{ + unsigned long mode,wake_up,receiveDTIMs ; + + 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){ + mode = POWER_SAVE; + wake_up = 0; + receiveDTIMs = 0; + } else { + mode = POWER_ACTIVE; + wake_up = 0; + receiveDTIMs = 0; + } + break; + case POWMGT_SAVE2_MODE: + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + mode = POWER_SAVE; + wake_up = 0; + receiveDTIMs = 1; + } else { + mode = POWER_ACTIVE; + wake_up = 0; + receiveDTIMs = 0; + } + break; + default: + mode = POWER_ACTIVE; + wake_up = 0; + receiveDTIMs = 0; + break; + } + hostif_power_mngmt_request(priv, mode, wake_up, receiveDTIMs); + + return; +} + +static +void hostif_sme_sleep_set(ks_wlan_private *priv) +{ + DPRINTK(3,"\n"); + switch(priv->sleep_mode){ + case SLP_SLEEP: + hostif_sleep_request(priv, priv->sleep_mode); + break; + case SLP_ACTIVE: + hostif_sleep_request(priv, priv->sleep_mode); + break; + default: + break; + } + + return; +} + +static +void hostif_sme_set_key(ks_wlan_private *priv, int type) +{ + uint32_t val; + switch(type){ + case SME_SET_FLAG: + 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 ); + break; + case SME_SET_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 ); + 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] ); + 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] ); + 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] ); + 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] ); + 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] ); + 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] ); + 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] ); + break; + } + return; +} + +static +void hostif_sme_set_pmksa(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; + 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){ + pmk = list_entry(ptr, struct pmk_t, list); + if(ibssid, ETH_ALEN); + memcpy(pmkcache.list[i].pmkid, pmk->pmkid, IW_PMKID_LEN); + i++; + } + } + 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 ); +} + +/* execute sme */ +static +void hostif_sme_execute(ks_wlan_private *priv, int event) +{ + uint32_t val; + + DPRINTK(3,"event=%d\n",event); + switch (event) { + case SME_START: + if ( priv->dev_state == DEVICE_STATE_BOOT ){ + hostif_mib_get_request(priv, DOT11_MAC_ADDRESS); + } + break; + case SME_MULTICAST_REQUEST: + hostif_sme_multicast_set(priv); + break; + case SME_MACADDRESS_SET_REQUEST: + hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN, + 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); + break; + case SME_POW_MNGMT_REQUEST: + hostif_sme_powermgt_set(priv); + break; + case SME_PHY_INFO_REQUEST: + 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", + priv->wpa.mic_failure.failure); + break; + case SME_MIC_FAILURE_CONFIRM: + 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 ); + } + break; + case SME_GET_MAC_ADDRESS: + 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 ){ + priv->dev_state = DEVICE_STATE_PREINIT; + } + break; + case SME_STOP_REQUEST: + hostif_stop_request(priv); + break; + case SME_RTS_THRESHOLD_REQUEST: + val = cpu_to_le32((uint32_t)(priv->reg.rts)); + hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD, + sizeof(val), MIB_VALUE_TYPE_INT, + &val ); + break; + case SME_FRAGMENTATION_THRESHOLD_REQUEST: + val = cpu_to_le32((uint32_t)(priv->reg.fragment)); + hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD, + 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); + break; + 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); + 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_GMK2_TSC: + hostif_sme_set_key(priv,event); + break; + case SME_SET_PMKSA: + hostif_sme_set_pmksa(priv); + break; +#ifdef WPS + 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 ); + break; + case SME_WPS_PROBE_REQUEST: + hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ, + priv->wps.ielen, + MIB_VALUE_TYPE_OSTRING, priv->wps.ie); + break; +#endif /* WPS */ + case SME_MODE_SET_REQUEST: + hostif_sme_mode_setup(priv); + break; + case SME_SET_GAIN: + hostif_mib_set_request(priv, LOCAL_GAIN, + sizeof(priv->gain), MIB_VALUE_TYPE_OSTRING, + &priv->gain); + break; + case SME_GET_GAIN: + hostif_mib_get_request(priv, LOCAL_GAIN); + break; + case SME_GET_EEPROM_CKSUM: + priv->eeprom_checksum = EEPROM_FW_NOT_SUPPORT; /* initialize */ + hostif_mib_get_request(priv, LOCAL_EEPROM_SUM); + break; + case SME_START_REQUEST: + 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 !defined(_SDIO_) + atomic_set(&priv->psstatus.status, PS_NONE); +#endif + if ( priv->dev_state == DEVICE_STATE_PREINIT ){ + priv->dev_state = DEVICE_STATE_INIT; + } + /* wake_up_interruptible_all(&priv->confirm_wait); */ + complete(&priv->confirm_wait); + break; + case SME_SLEEP_REQUEST: + hostif_sme_sleep_set(priv); + break; + case SME_SET_REGION: + val = cpu_to_le32((uint32_t)(priv->region)); + hostif_mib_set_request(priv, LOCAL_REGION, + sizeof(val), MIB_VALUE_TYPE_INT, + &val ); + break; + case SME_MULTICAST_CONFIRM: + case SME_BSS_SCAN_CONFIRM: + case SME_POW_MNGMT_CONFIRM: + case SME_PHY_INFO_CONFIRM: + 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_RSN_MODE_CONFIRM: + case SME_MODE_SET_CONFIRM: + break; + case SME_TERMINATE: + default: + break; + } +} + +static +void hostif_sme_task( unsigned long dev ) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev; + + 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]); + inc_smeqhead(priv); + if (0 < cnt_smeqbody(priv)) + tasklet_schedule(&priv->sme_task); + } + } + return; +} + +/* send to Station Management Entity module */ +void hostif_sme_enqueue(ks_wlan_private *priv, unsigned short event) +{ + DPRINTK(3,"\n"); + +#if !defined(_SDIO_) + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE && event < SME_START_CONFIRM){ /* power save wakeup*/ + schedule_work(&priv->ks_wlan_wakeup_task); + if(atomic_read(&priv->sme_task.count) <= 0){ + /* schedule_work(&priv->ks_wlan_wakeup_task); */ + DPRINTK(4,"sme task disable.\n"); + tasklet_disable(&priv->sme_task); + } + } +#endif + + + /* enqueue sme event */ + if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) { + priv->sme_i.event_buff[priv->sme_i.qtail] = event; + inc_smeqtail(priv); + //DPRINTK(3,"inc_smeqtail \n"); +#ifdef KS_WLAN_DEBUG + if (priv->sme_i.max_event_count < cnt_smeqbody(priv)) + priv->sme_i.max_event_count = cnt_smeqbody(priv); +#endif /* KS_WLAN_DEBUG */ + } else { + /* in case of buffer overflow */ + //DPRINTK(2,"sme queue buffer overflow\n"); + printk("sme queue buffer overflow\n"); + } + + tasklet_schedule(&priv->sme_task); + +} + +int hostif_init( ks_wlan_private *priv ) +{ + int rc=0; + int i; + + DPRINTK(3,"\n"); + + priv->aplist.size =0; + for(i=0;iaplist.ap[i]),0,sizeof(struct local_ap_t)); + priv->infra_status = 0; + priv->current_rate = 4; + priv->connect_status = DISCONNECT_STATUS; + + spin_lock_init(&priv->multicast_spin); + + spin_lock_init(&priv->dev_read_lock); + init_waitqueue_head (&priv->devread_wait); + priv->dev_count = 0; + atomic_set(&priv->event_count, 0); + atomic_set(&priv->rec_count, 0); + + /* for power save */ + atomic_set(&priv->psstatus.status, PS_NONE); + atomic_set(&priv->psstatus.confirm_wait, 0); + atomic_set(&priv->psstatus.snooze_guard, 0); + /* init_waitqueue_head(&priv->psstatus.wakeup_wait); */ + init_completion(&priv->psstatus.wakeup_wait); + //INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task, (void *)priv); + INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task); + + /* WPA */ + memset(&(priv->wpa), 0, sizeof(priv->wpa)); + priv->wpa.rsn_enabled = 0; + priv->wpa.mic_failure.failure = 0; + priv->wpa.mic_failure.last_failure_time = 0; + priv->wpa.mic_failure.stop = 0; + memset(&(priv->pmklist), 0, sizeof(priv->pmklist)); + INIT_LIST_HEAD(&priv->pmklist.head); + for(i=0;ipmklist.pmk[i].list); + + priv->sme_i.sme_status = SME_IDLE; + priv->sme_i.qhead = priv->sme_i.qtail = 0; +#ifdef KS_WLAN_DEBUG + priv->sme_i.max_event_count = 0; +#endif + spin_lock_init(&priv->sme_i.sme_spin); + priv->sme_i.sme_flag = 0; + + tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv); + + return rc; +} + +void hostif_exit( ks_wlan_private *priv ) +{ + tasklet_kill(&priv->sme_task); + return; +} + diff --git a/ks7010/src/ks_hostif.h b/ks7010/src/ks_hostif.h new file mode 100644 index 0000000..24ebf1d --- /dev/null +++ b/ks7010/src/ks_hostif.h @@ -0,0 +1,648 @@ +/* + * Driver for KeyStream wireless LAN + * + * ks_hostif.h + * $Id: ks_hostif.h 994 2009-09-14 01:51:16Z sekine $ + * + * Copyright (c) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#ifndef _KS_HOSTIF_H_ +#define _KS_HOSTIF_H_ +/* + * HOST-MAC I/F events + */ +#define HIF_DATA_REQ 0xE001 +#define HIF_DATA_IND 0xE801 +#define HIF_MIB_GET_REQ 0xE002 +#define HIF_MIB_GET_CONF 0xE802 +#define HIF_MIB_SET_REQ 0xE003 +#define HIF_MIB_SET_CONF 0xE803 +#define HIF_POWERMGT_REQ 0xE004 +#define HIF_POWERMGT_CONF 0xE804 +#define HIF_START_REQ 0xE005 +#define HIF_START_CONF 0xE805 +#define HIF_CONNECT_IND 0xE806 +#define HIF_STOP_REQ 0xE006 +#define HIF_STOP_CONF 0xE807 +#define HIF_PS_ADH_SET_REQ 0xE007 +#define HIF_PS_ADH_SET_CONF 0xE808 +#define HIF_INFRA_SET_REQ 0xE008 +#define HIF_INFRA_SET_CONF 0xE809 +#define HIF_ADH_SET_REQ 0xE009 +#define HIF_ADH_SET_CONF 0xE80A +#define HIF_AP_SET_REQ 0xE00A +#define HIF_AP_SET_CONF 0xE80B +#define HIF_ASSOC_INFO_IND 0xE80C +#define HIF_MIC_FAILURE_REQ 0xE00B +#define HIF_MIC_FAILURE_CONF 0xE80D +#define HIF_SCAN_REQ 0xE00C +#define HIF_SCAN_CONF 0xE80E +#define HIF_PHY_INFO_REQ 0xE00D +#define HIF_PHY_INFO_CONF 0xE80F +#define HIF_SLEEP_REQ 0xE00E +#define HIF_SLEEP_CONF 0xE810 +#define HIF_PHY_INFO_IND 0xE811 +#define HIF_SCAN_IND 0xE812 +#define HIF_INFRA_SET2_REQ 0xE00F +#define HIF_INFRA_SET2_CONF 0xE813 +#define HIF_ADH_SET2_REQ 0xE010 +#define HIF_ADH_SET2_CONF 0xE814 + +#define HIF_REQ_MAX 0xE010 + +/* + * HOST-MAC I/F data structure + * Byte alignmet Little Endian + */ + +struct hostif_hdr { + uint16_t size; + uint16_t event; +} __attribute__((packed)); + +struct hostif_data_request_t { + struct hostif_hdr header; + uint16_t auth_type; +#define TYPE_DATA 0x0000 +#define TYPE_AUTH 0x0001 + uint16_t reserved; + uint8_t data[0]; +} __attribute__((packed)); + +struct hostif_data_indication_t { + struct hostif_hdr header; + uint16_t auth_type; +/* #define TYPE_DATA 0x0000 */ +#define TYPE_PMK1 0x0001 +#define TYPE_GMK1 0x0002 +#define TYPE_GMK2 0x0003 + uint16_t reserved; + uint8_t data[0]; +} __attribute__((packed)); + +#define CHANNEL_LIST_MAX_SIZE 14 +struct channel_list_t { + uint8_t size; + uint8_t body[CHANNEL_LIST_MAX_SIZE]; + uint8_t pad; +} __attribute__((packed)); + +/* MIB Attribute */ +#define DOT11_MAC_ADDRESS 0x21010100 /* MAC Address (R) */ +#define DOT11_PRODUCT_VERSION 0x31024100 /* FirmWare Version (R)*/ +#define DOT11_RTS_THRESHOLD 0x21020100 /* RTS Threshold (R/W) */ +#define DOT11_FRAGMENTATION_THRESHOLD 0x21050100 /* Fragment Threshold (R/W) */ +#define DOT11_PRIVACY_INVOKED 0x15010100 /* WEP ON/OFF (W) */ +#define DOT11_WEP_DEFAULT_KEY_ID 0x15020100 /* WEP Index (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE1 0x13020101 /* WEP Key#1(TKIP AES: PairwiseTemporalKey) (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE2 0x13020102 /* WEP Key#2(TKIP AES: GroupKey1) (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE3 0x13020103 /* WEP Key#3(TKIP AES: GroupKey2) (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE4 0x13020104 /* WEP Key#4 (W) */ +#define DOT11_WEP_LIST 0x13020100 /* WEP LIST */ +#define DOT11_DESIRED_SSID 0x11090100 /* SSID */ +#define DOT11_CURRENT_CHANNEL 0x45010100 /* channel set */ +#define DOT11_OPERATION_RATE_SET 0x11110100 /* rate set */ + +#define LOCAL_AP_SEARCH_INTEAVAL 0xF1010100 /* AP search interval (R/W) */ +#define LOCAL_CURRENTADDRESS 0xF1050100 /* MAC Adress change (W) */ +#define LOCAL_MULTICAST_ADDRESS 0xF1060100 /* Multicast Adress (W) */ +#define LOCAL_MULTICAST_FILTER 0xF1060200 /* Multicast Adress Filter enable/disable (W) */ +#define LOCAL_SEARCHED_AP_LIST 0xF1030100 /* AP list (R) */ +#define LOCAL_LINK_AP_STATUS 0xF1040100 /* Link AP status (R) */ +#define LOCAL_PACKET_STATISTICS 0xF1020100 /* tx,rx packets statistics */ +#define LOCAL_AP_SCAN_LIST_TYPE_SET 0xF1030200 /* AP_SCAN_LIST_TYPE */ + +#define DOT11_RSN_ENABLED 0x15070100 /* WPA enable/disable (W) */ +#define LOCAL_RSN_MODE 0x56010100 /* RSN mode WPA/WPA2 (W) */ +#define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100 /* GroupKeyCipherSuite (W) */ +#define DOT11_RSN_CONFIG_UNICAST_CIPHER 0x52020100 /* PairwiseKeyCipherSuite (W) */ +#define DOT11_RSN_CONFIG_AUTH_SUITE 0x53020100 /* AuthenticationKeyManagementSuite (W) */ +#define DOT11_RSN_CONFIG_VERSION 0x51020100 /* RSN version (W) */ +#define LOCAL_RSN_CONFIG_ALL 0x5F010100 /* RSN CONFIG ALL (W) */ +#define DOT11_PMK_TSC 0x55010100 /* PMK_TSC (W) */ +#define DOT11_GMK1_TSC 0x55010101 /* GMK1_TSC (W) */ +#define DOT11_GMK2_TSC 0x55010102 /* GMK2_TSC (W) */ +#define DOT11_GMK3_TSC 0x55010103 /* GMK3_TSC */ +#define LOCAL_PMK 0x58010100 /* Pairwise Master Key cache (W) */ + +#define LOCAL_REGION 0xF10A0100 /* Region setting */ + +#ifdef WPS +#define LOCAL_WPS_ENABLE 0xF10B0100 /* WiFi Protected Setup */ +#define LOCAL_WPS_PROBE_REQ 0xF10C0100 /* WPS Probe Request */ +#endif /* WPS */ + +#define LOCAL_GAIN 0xF10D0100 /* Carrer sense threshold for demo ato show */ +#define LOCAL_EEPROM_SUM 0xF10E0100 /* EEPROM checksum information */ + +struct hostif_mib_get_request_t { + struct hostif_hdr header; + uint32_t mib_attribute; +} __attribute__((packed)); + + +struct hostif_mib_value_t { + uint16_t size; + uint16_t type; +#define MIB_VALUE_TYPE_NULL 0 +#define MIB_VALUE_TYPE_INT 1 +#define MIB_VALUE_TYPE_BOOL 2 +#define MIB_VALUE_TYPE_COUNT32 3 +#define MIB_VALUE_TYPE_OSTRING 4 + uint8_t body[0]; +} __attribute__((packed)); + +struct hostif_mib_get_confirm_t { + struct hostif_hdr header; + uint32_t mib_status; +#define MIB_SUCCESS 0 +#define MIB_INVALID 1 +#define MIB_READ_ONLY 2 +#define MIB_WRITE_ONLY 3 + uint32_t mib_attribute; + struct hostif_mib_value_t mib_value; +} __attribute__((packed)); + +struct hostif_mib_set_request_t { + struct hostif_hdr header; + uint32_t mib_attribute; + struct hostif_mib_value_t mib_value; +} __attribute__((packed)); + +struct hostif_mib_set_confirm_t { + struct hostif_hdr header; + uint32_t mib_status; + uint32_t mib_attribute; +} __attribute__((packed)); + +struct hostif_power_mngmt_request_t { + struct hostif_hdr header; + uint32_t mode; +#define POWER_ACTIVE 1 +#define POWER_SAVE 2 + uint32_t wake_up; +#define SLEEP_FALSE 0 +#define SLEEP_TRUE 1 /* not used */ + uint32_t receiveDTIMs; +#define DTIM_FALSE 0 +#define DTIM_TRUE 1 +} __attribute__((packed)); + +/* power management mode */ +enum { + POWMGT_ACTIVE_MODE=0, + POWMGT_SAVE1_MODE, + POWMGT_SAVE2_MODE +}; + +#define RESULT_SUCCESS 0 +#define RESULT_INVALID_PARAMETERS 1 +#define RESULT_NOT_SUPPORTED 2 +/* #define RESULT_ALREADY_RUNNING 3 */ +#define RESULT_ALREADY_RUNNING 7 + +struct hostif_power_mngmt_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_start_request_t { + struct hostif_hdr header; + uint16_t mode; +#define MODE_PSEUDO_ADHOC 0 +#define MODE_INFRASTRUCTURE 1 +#define MODE_AP 2 /* not used */ +#define MODE_ADHOC 3 +} __attribute__((packed)); + +struct hostif_start_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +#define SSID_MAX_SIZE 32 +struct ssid_t { + uint8_t size; + uint8_t body[SSID_MAX_SIZE]; + uint8_t ssid_pad; +} __attribute__((packed)); + +#define RATE_SET_MAX_SIZE 16 +struct rate_set8_t { + uint8_t size; + uint8_t body[8]; + uint8_t rate_pad; +} __attribute__((packed)); + +struct FhParms_t { + uint16_t dwellTime; + uint8_t hopSet; + uint8_t hopPattern; + uint8_t hopIndex; +} __attribute__((packed)); + +struct DsParms_t { + uint8_t channel; +} __attribute__((packed)); + +struct CfParms_t { + uint8_t count; + uint8_t period; + uint16_t maxDuration; + uint16_t durRemaining; +} __attribute__((packed)); + +struct IbssParms_t { + uint16_t atimWindow; +} __attribute__((packed)); + + +struct rsn_t { + uint8_t size; +#define RSN_BODY_SIZE 64 + uint8_t body[RSN_BODY_SIZE]; +} __attribute__((packed)); + +struct ErpParams_t { + uint8_t erp_info; +} __attribute__((packed)); + +struct rate_set16_t{ + uint8_t size; + uint8_t body[16]; + uint8_t rate_pad; +} __attribute__((packed)); + +struct ap_info_t{ + uint8_t bssid[6]; /* +00 */ + uint8_t rssi; /* +06 */ + uint8_t sq; /* +07 */ + uint8_t noise; /* +08 */ + uint8_t pad0; /* +09 */ + uint16_t beacon_period; /* +10 */ + uint16_t capability; /* +12 */ +#define BSS_CAP_ESS (1<<0) +#define BSS_CAP_IBSS (1<<1) +#define BSS_CAP_CF_POLABLE (1<<2) +#define BSS_CAP_CF_POLL_REQ (1<<3) +#define BSS_CAP_PRIVACY (1<<4) +#define BSS_CAP_SHORT_PREAMBLE (1<<5) +#define BSS_CAP_PBCC (1<<6) +#define BSS_CAP_CHANNEL_AGILITY (1<<7) +#define BSS_CAP_SHORT_SLOT_TIME (1<<10) +#define BSS_CAP_DSSS_OFDM (1<<13) + uint8_t frame_type; /* +14 */ + uint8_t ch_info; /* +15 */ +#define FRAME_TYPE_BEACON 0x80 +#define FRAME_TYPE_PROBE_RESP 0x50 + uint16_t body_size; /* +16 */ + uint8_t body[1024]; /* +18 */ + /* +1032 */ +} __attribute__((packed)); + +struct link_ap_info_t{ + uint8_t bssid[6]; /* +00 */ + uint8_t rssi; /* +06 */ + uint8_t sq; /* +07 */ + uint8_t noise; /* +08 */ + uint8_t pad0; /* +09 */ + uint16_t beacon_period; /* +10 */ + uint16_t capability; /* +12 */ + struct rate_set8_t rate_set; /* +14 */ + struct FhParms_t fh_parameter; /* +24 */ + struct DsParms_t ds_parameter; /* +29 */ + struct CfParms_t cf_parameter; /* +30 */ + struct IbssParms_t ibss_parameter; /* +36 */ + struct ErpParams_t erp_parameter; /* +38 */ + uint8_t pad1; /* +39 */ + struct rate_set8_t ext_rate_set; /* +40 */ + uint8_t DTIM_period; /* +50 */ + uint8_t rsn_mode; /* +51 */ +#define RSN_MODE_NONE 0 +#define RSN_MODE_WPA 1 +#define RSN_MODE_WPA2 2 + struct { + uint8_t size; /* +52 */ + uint8_t body[128]; /* +53 */ + } __attribute__((packed)) rsn; +} __attribute__((packed)); + +struct hostif_connect_indication_t { + struct hostif_hdr header; + uint16_t connect_code; +#define RESULT_CONNECT 0 +#define RESULT_DISCONNECT 1 + struct link_ap_info_t link_ap_info; +} __attribute__((packed)); + +struct hostif_stop_request_t { + struct hostif_hdr header; +} __attribute__((packed)); + +struct hostif_stop_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_ps_adhoc_set_request_t { + struct hostif_hdr header; + uint16_t phy_type; +#define D_11B_ONLY_MODE 0 +#define D_11G_ONLY_MODE 1 +#define D_11BG_COMPATIBLE_MODE 2 +#define D_11A_ONLY_MODE 3 + uint16_t cts_mode; +#define CTS_MODE_FALSE 0 +#define CTS_MODE_TRUE 1 + uint16_t channel; + struct rate_set16_t rate_set; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t scan_type; +} __attribute__((packed)); + +struct hostif_ps_adhoc_set_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_infrastructure_set_request_t { + struct hostif_hdr header; + uint16_t phy_type; + uint16_t cts_mode; + struct rate_set16_t rate_set; + struct ssid_t ssid; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t beacon_lost_count; + uint16_t auth_type; +#define AUTH_TYPE_OPEN_SYSTEM 0 +#define AUTH_TYPE_SHARED_KEY 1 + struct channel_list_t channel_list; + uint16_t scan_type; +} __attribute__((packed)); + +struct hostif_infrastructure_set2_request_t { + struct hostif_hdr header; + uint16_t phy_type; + uint16_t cts_mode; + struct rate_set16_t rate_set; + struct ssid_t ssid; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t beacon_lost_count; + uint16_t auth_type; +#define AUTH_TYPE_OPEN_SYSTEM 0 +#define AUTH_TYPE_SHARED_KEY 1 + struct channel_list_t channel_list; + uint16_t scan_type; + uint8_t bssid[ETH_ALEN]; +} __attribute__((packed)); + + +struct hostif_infrastructure_set_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_adhoc_set_request_t { + struct hostif_hdr header; + uint16_t phy_type; + uint16_t cts_mode; + uint16_t channel; + struct rate_set16_t rate_set; + struct ssid_t ssid; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t scan_type; +} __attribute__((packed)); + +struct hostif_adhoc_set2_request_t { + struct hostif_hdr header; + uint16_t phy_type; + uint16_t cts_mode; + uint16_t reserved; + struct rate_set16_t rate_set; + struct ssid_t ssid; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t scan_type; + struct channel_list_t channel_list; + uint8_t bssid[ETH_ALEN]; +} __attribute__((packed)); + +struct hostif_adhoc_set_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + + +struct last_associate_t { + uint8_t type; + uint8_t status; +} __attribute__((packed)); + +struct association_request_t { + uint8_t type; +#define FRAME_TYPE_ASSOC_REQ 0x00 +#define FRAME_TYPE_REASSOC_REQ 0x20 + uint8_t pad; + uint16_t capability; + uint16_t listen_interval; + uint8_t ap_address[6]; + uint16_t reqIEs_size; +} __attribute__((packed)); + +struct association_response_t { + uint8_t type; +#define FRAME_TYPE_ASSOC_RESP 0x10 +#define FRAME_TYPE_REASSOC_RESP 0x30 + uint8_t pad; + uint16_t capability; + uint16_t status; + uint16_t association_id; + uint16_t respIEs_size; +} __attribute__((packed)); + +struct hostif_associate_indication_t { + struct hostif_hdr header; + struct association_request_t assoc_req; + struct association_response_t assoc_resp; + /* followed by (reqIEs_size + respIEs_size) octets of data */ + /* reqIEs data *//* respIEs data */ +} __attribute__((packed)); + +struct hostif_bss_scan_request_t { + struct hostif_hdr header; + uint8_t scan_type; +#define ACTIVE_SCAN 0 +#define PASSIVE_SCAN 1 + uint8_t pad[3]; + uint32_t ch_time_min; + uint32_t ch_time_max; + struct channel_list_t channel_list; + struct ssid_t ssid; +} __attribute__((packed)); + +struct hostif_bss_scan_confirm_t { + struct hostif_hdr header; + uint16_t result_code; + uint16_t reserved; +} __attribute__((packed)); + +struct hostif_phy_information_request_t { + struct hostif_hdr header; + uint16_t type; +#define NORMAL_TYPE 0 +#define TIME_TYPE 1 + uint16_t time; /* unit 100ms */ +} __attribute__((packed)); + +struct hostif_phy_information_confirm_t { + struct hostif_hdr header; + uint8_t rssi; + uint8_t sq; + uint8_t noise; + uint8_t link_speed; + uint32_t tx_frame; + uint32_t rx_frame; + uint32_t tx_error; + uint32_t rx_error; +} __attribute__((packed)); + +/* sleep mode */ +#define SLP_ACTIVE 0 +#define SLP_SLEEP 1 +struct hostif_sleep_request_t { + struct hostif_hdr header; +} __attribute__((packed)); + +struct hostif_sleep_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_mic_failure_request_t { + struct hostif_hdr header; + uint16_t failure_count; + uint16_t timer; +} __attribute__((packed)); + +struct hostif_mic_failure_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +#define BASIC_RATE 0x80 +#define RATE_MASK 0x7F + +#define TX_RATE_AUTO 0xff +#define TX_RATE_1M_FIXED 0 +#define TX_RATE_2M_FIXED 1 +#define TX_RATE_1_2M_AUTO 2 +#define TX_RATE_5M_FIXED 3 +#define TX_RATE_11M_FIXED 4 + +#define TX_RATE_FULL_AUTO 0 +#define TX_RATE_11_AUTO 1 +#define TX_RATE_11B_AUTO 2 +#define TX_RATE_11BG_AUTO 3 +#define TX_RATE_MANUAL_AUTO 4 +#define TX_RATE_FIXED 5 + +/* 11b rate */ +#define TX_RATE_1M (uint8_t)(10/5) /* 11b 11g basic rate */ +#define TX_RATE_2M (uint8_t)(20/5) /* 11b 11g basic rate */ +#define TX_RATE_5M (uint8_t)(55/5) /* 11g basic rate */ +#define TX_RATE_11M (uint8_t)(110/5) /* 11g basic rate */ + +/* 11g rate */ +#define TX_RATE_6M (uint8_t)(60/5) /* 11g basic rate */ +#define TX_RATE_12M (uint8_t)(120/5) /* 11g basic rate */ +#define TX_RATE_24M (uint8_t)(240/5) /* 11g basic rate */ +#define TX_RATE_9M (uint8_t)(90/5) +#define TX_RATE_18M (uint8_t)(180/5) +#define TX_RATE_36M (uint8_t)(360/5) +#define TX_RATE_48M (uint8_t)(480/5) +#define TX_RATE_54M (uint8_t)(540/5) + +#define IS_11B_RATE(A) (((A&RATE_MASK)==TX_RATE_1M)||((A&RATE_MASK)==TX_RATE_2M)||\ + ((A&RATE_MASK)==TX_RATE_5M)||((A&RATE_MASK)==TX_RATE_11M)) + +#define IS_OFDM_RATE(A) (((A&RATE_MASK)==TX_RATE_6M)||((A&RATE_MASK)==TX_RATE_12M)||\ + ((A&RATE_MASK)==TX_RATE_24M)||((A&RATE_MASK)==TX_RATE_9M)||\ + ((A&RATE_MASK)==TX_RATE_18M)||((A&RATE_MASK)==TX_RATE_36M)||\ + ((A&RATE_MASK)==TX_RATE_48M)||((A&RATE_MASK)==TX_RATE_54M)) + +#define IS_11BG_RATE(A) (IS_11B_RATE(A)||IS_OFDM_RATE(A)) + +#define IS_OFDM_EXT_RATE(A) (((A&RATE_MASK)==TX_RATE_9M)||((A&RATE_MASK)==TX_RATE_18M)||\ + ((A&RATE_MASK)==TX_RATE_36M)||((A&RATE_MASK)==TX_RATE_48M)||\ + ((A&RATE_MASK)==TX_RATE_54M)) + +enum { + CONNECT_STATUS=0, + DISCONNECT_STATUS +}; + +/* preamble type */ +enum { + LONG_PREAMBLE=0, + SHORT_PREAMBLE +}; + +/* multicast filter */ +#define MCAST_FILTER_MCAST 0 +#define MCAST_FILTER_MCASTALL 1 +#define MCAST_FILTER_PROMISC 2 + +#define NIC_MAX_MCAST_LIST 32 + +/* macro function */ +#define HIF_EVENT_MASK 0xE800 +#define IS_HIF_IND(_EVENT) ((_EVENT&HIF_EVENT_MASK)==0xE800 && \ + ((_EVENT&~HIF_EVENT_MASK)==0x0001 || \ + (_EVENT&~HIF_EVENT_MASK)==0x0006 || \ + (_EVENT&~HIF_EVENT_MASK)==0x000C || \ + (_EVENT&~HIF_EVENT_MASK)==0x0011 || \ + (_EVENT&~HIF_EVENT_MASK)==0x0012)) + +#define IS_HIF_CONF(_EVENT) ((_EVENT&HIF_EVENT_MASK)==0xE800 && \ + (_EVENT&~HIF_EVENT_MASK)>0x0000 && \ + (_EVENT&~HIF_EVENT_MASK)<0x0012 && \ + !IS_HIF_IND(_EVENT) ) + +#ifdef __KERNEL__ + +#include "ks_wlan.h" + +/* function prototype */ +extern int hostif_data_request( ks_wlan_private *priv, struct sk_buff *packet ); +extern void hostif_receive( ks_wlan_private *priv, unsigned char *p, unsigned int size ); +extern void hostif_sme_enqueue(ks_wlan_private *priv, uint16_t event); +extern int hostif_init( ks_wlan_private *priv ); +extern void hostif_exit( ks_wlan_private *priv ); + +static +inline int hif_align_size(int size) +{ +#ifdef KS_ATOM + if( size < 1024 ) + size = 1024; +#endif +#ifdef DEVICE_ALIGNMENT + return (size%DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT - (size % DEVICE_ALIGNMENT) : size; +#else + return size; +#endif +} + +#endif /* __KERNEL__ */ + +#endif /* _KS_HOSTIF_H_ */ diff --git a/ks7010/src/ks_wlan.h b/ks7010/src/ks_wlan.h new file mode 100644 index 0000000..90d36a5 --- /dev/null +++ b/ks7010/src/ks_wlan.h @@ -0,0 +1,540 @@ +/* + * Driver for KeyStream IEEE802.11 b/g wireless LAN cards. + * + * ks_wlan.h + * $Id: ks_wlan.h 994 2009-09-14 01:51:16Z sekine $ + * + * Copyright (C) 2006-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#ifndef _KS_WLAN_H +#define _KS_WLAN_H + +#define WPS + +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#include +#endif +#include +#include + +#include /* spinlock_t */ +#include /* wait_queue_head_t */ +#include /* pid_t */ +#include /* struct net_device_stats, struct sk_buff */ +#include +#include +#include /* struct atmic_t */ +#include /* struct timer_list */ +#include +#include /* struct completion */ + +#include + +/* Workqueue / task queue backwards compatibility stuff */ +#if ((LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41)) || (defined _MVL31_) || (defined _CELF3_)) +#include +#else +#include +#define work_struct tq_struct +#define INIT_WORK INIT_TQUEUE +#define schedule_work schedule_task +#endif + +/* Interrupt handler backwards compatibility stuff */ +/* +#ifndef IRQ_NONE +#define IRQ_NONE +#define IRQ_HANDLED +typedef void irqreturn_t; +#endif +*/ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) +#define free_netdev(x) kfree(x) +#define pci_name(x) x->slot_name +#endif + +#if (defined _PCMCIA_) +#include "pcmcia/ks7010_pcmcia.h" +#elif (defined _PCI_) +#include "pci/ks7010_pci.h" +#elif (defined _SDIO_) +#include "ks7010_sdio.h" +#elif (defined _SPI_) +#include "spi/ks7010_spi.h" +#else +#error not defined bus type ! +#endif + +struct ks_wlan_parameter { + uint8_t operation_mode; /* Operation Mode */ + uint8_t channel; /* Channel */ + uint8_t tx_rate; /* Transmit Rate */ + struct { + uint8_t size; + uint8_t body[16]; + } rate_set; + uint8_t bssid[ETH_ALEN]; /* BSSID */ + struct { + uint8_t size; + uint8_t body[32+1]; + } ssid; /* SSID */ + uint8_t preamble; /* Preamble */ + uint8_t powermgt; /* PowerManagementMode */ + uint32_t scan_type; /* AP List Scan Type */ +#define BEACON_LOST_COUNT_MIN 0 +#define BEACON_LOST_COUNT_MAX 65535 + uint32_t beacon_lost_count; /* Beacon Lost Count */ + uint32_t rts; /* RTS Threashold */ + uint32_t fragment; /* Fragmentation Threashold */ + uint32_t privacy_invoked; + uint32_t wep_index; + struct { + uint8_t size; + uint8_t val[13*2+1]; + } wep_key[4]; + uint16_t authenticate_type; + uint16_t phy_type; /* 11b/11g/11bg mode type*/ + uint16_t cts_mode; /* for 11g/11bg mode cts mode */ + uint16_t phy_info_timer; /* phy information timer */ + char rom_file[256]; +}; + +enum { + DEVICE_STATE_OFF = 0, /* this means hw_unavailable is != 0 */ + DEVICE_STATE_PREBOOT, /* we are in a pre-boot state (empty RAM) */ + DEVICE_STATE_BOOT, /* boot state (fw upload, run fw) */ + DEVICE_STATE_PREINIT, /* pre-init state */ + DEVICE_STATE_INIT, /* init state (restore MIB backup to device) */ + DEVICE_STATE_READY, /* driver&device are in operational state */ + DEVICE_STATE_SLEEP /* device in sleep mode */ +}; + +/* SME flag */ +#define SME_MODE_SET (1<<0) +#define SME_RTS (1<<1) +#define SME_FRAG (1<<2) +#define SME_WEP_FLAG (1<<3) +#define SME_WEP_INDEX (1<<4) +#define SME_WEP_VAL1 (1<<5) +#define SME_WEP_VAL2 (1<<6) +#define SME_WEP_VAL3 (1<<7) +#define SME_WEP_VAL4 (1<<8) +#define SME_WEP_VAL_MASK (SME_WEP_VAL1|SME_WEP_VAL2|SME_WEP_VAL3|SME_WEP_VAL4) +#define SME_RSN (1<<9) +#define SME_RSN_MULTICAST (1<<10) +#define SME_RSN_UNICAST (1<<11) +#define SME_RSN_AUTH (1<<12) + +#define SME_AP_SCAN (1<<13) +#define SME_MULTICAST (1<<14) + +/* SME Event */ +enum { + SME_START, + + SME_MULTICAST_REQUEST, + SME_MACADDRESS_SET_REQUEST, + SME_BSS_SCAN_REQUEST, + SME_SET_FLAG, + SME_SET_TXKEY, + SME_SET_KEY1, + SME_SET_KEY2, + SME_SET_KEY3, + SME_SET_KEY4, + SME_SET_PMK_TSC, + SME_SET_GMK1_TSC, + SME_SET_GMK2_TSC, + SME_SET_GMK3_TSC, + SME_SET_PMKSA, + SME_POW_MNGMT_REQUEST, + SME_PHY_INFO_REQUEST, + SME_MIC_FAILURE_REQUEST, + SME_GET_MAC_ADDRESS, + SME_GET_PRODUCT_VERSION, + SME_STOP_REQUEST, + SME_RTS_THRESHOLD_REQUEST, + SME_FRAGMENTATION_THRESHOLD_REQUEST, + SME_WEP_INDEX_REQUEST, + SME_WEP_KEY1_REQUEST, + SME_WEP_KEY2_REQUEST, + SME_WEP_KEY3_REQUEST, + SME_WEP_KEY4_REQUEST, + SME_WEP_FLAG_REQUEST, + SME_RSN_UCAST_REQUEST, + SME_RSN_MCAST_REQUEST, + SME_RSN_AUTH_REQUEST, + SME_RSN_ENABLED_REQUEST, + SME_RSN_MODE_REQUEST, +#ifdef WPS + SME_WPS_ENABLE_REQUEST, + SME_WPS_PROBE_REQUEST, +#endif + SME_SET_GAIN, + SME_GET_GAIN, + SME_SLEEP_REQUEST, + SME_SET_REGION, + SME_MODE_SET_REQUEST, + SME_START_REQUEST, + SME_GET_EEPROM_CKSUM, + + + SME_MIC_FAILURE_CONFIRM, + SME_START_CONFIRM, + + SME_MULTICAST_CONFIRM, + SME_BSS_SCAN_CONFIRM, + SME_GET_CURRENT_AP, + SME_POW_MNGMT_CONFIRM, + SME_PHY_INFO_CONFIRM, + SME_STOP_CONFIRM, + SME_RTS_THRESHOLD_CONFIRM, + SME_FRAGMENTATION_THRESHOLD_CONFIRM, + SME_WEP_INDEX_CONFIRM, + SME_WEP_KEY1_CONFIRM, + SME_WEP_KEY2_CONFIRM, + SME_WEP_KEY3_CONFIRM, + SME_WEP_KEY4_CONFIRM, + SME_WEP_FLAG_CONFIRM, + SME_RSN_UCAST_CONFIRM, + SME_RSN_MCAST_CONFIRM, + SME_RSN_AUTH_CONFIRM, + SME_RSN_ENABLED_CONFIRM, + SME_RSN_MODE_CONFIRM, + SME_MODE_SET_CONFIRM, + SME_SLEEP_CONFIRM, + + SME_RSN_SET_CONFIRM, + SME_WEP_SET_CONFIRM, + SME_TERMINATE, + + SME_EVENT_SIZE /* end */ +}; + +/* SME Status */ +enum { + SME_IDLE, + SME_SETUP, + SME_DISCONNECT, + SME_CONNECT +}; + +#define SME_EVENT_BUFF_SIZE 128 + +struct sme_info{ + int sme_status; + int event_buff[SME_EVENT_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; +#ifdef KS_WLAN_DEBUG + /* for debug */ + unsigned int max_event_count; +#endif + spinlock_t sme_spin; + unsigned long sme_flag; +}; + +struct hostt_t{ + int buff[SME_EVENT_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; +}; + +#define RSN_IE_BODY_MAX 64 +struct rsn_ie_t { + uint8_t id; /* 0xdd = WPA or 0x30 = RSN */ + uint8_t size; /* max ? 255 ? */ + uint8_t body[RSN_IE_BODY_MAX]; +} __attribute__((packed)); + +#ifdef WPS +#define WPS_IE_BODY_MAX 255 +struct wps_ie_t { + uint8_t id; /* 221 'dd 00 50 F2 04' */ + uint8_t size; /* max ? 255 ? */ + uint8_t body[WPS_IE_BODY_MAX]; +} __attribute__((packed)); +#endif /* WPS */ + +struct local_ap_t { + uint8_t bssid[6]; + uint8_t rssi; + uint8_t sq; + struct { + uint8_t size; + uint8_t body[32]; + uint8_t ssid_pad; + } ssid; + struct { + uint8_t size; + uint8_t body[16]; + uint8_t rate_pad; + } rate_set; + uint16_t capability; + uint8_t channel; + uint8_t noise; + struct rsn_ie_t wpa_ie; + struct rsn_ie_t rsn_ie; +#ifdef WPS + struct wps_ie_t wps_ie; +#endif /* WPS */ +}; + +#define LOCAL_APLIST_MAX 31 +#define LOCAL_CURRENT_AP LOCAL_APLIST_MAX +struct local_aplist_t { + int size; + struct local_ap_t ap[LOCAL_APLIST_MAX+1]; +}; + +struct local_gain_t{ + uint8_t TxMode; + uint8_t RxMode; + uint8_t TxGain; + uint8_t RxGain; +}; + +struct local_eeprom_sum_t{ + uint8_t type; + uint8_t result; +}; + +enum { + EEPROM_OK, + EEPROM_CHECKSUM_NONE, + EEPROM_FW_NOT_SUPPORT, + EEPROM_NG, +}; + + +/* Power Save Status */ +enum { + PS_NONE, + PS_ACTIVE_SET, + PS_SAVE_SET, + PS_CONF_WAIT, + PS_SNOOZE, + PS_WAKEUP +}; + +struct power_save_status_t { + atomic_t status; /* initialvalue 0 */ + struct completion wakeup_wait; + atomic_t confirm_wait; + atomic_t snooze_guard; +}; + +struct sleep_status_t { + atomic_t status; /* initialvalue 0 */ + atomic_t doze_request; + atomic_t wakeup_request; +}; + +/* WPA */ +struct scan_ext_t { + unsigned int flag; + char ssid[IW_ESSID_MAX_SIZE+1]; +}; + +enum { + CIPHER_NONE, + CIPHER_WEP40, + CIPHER_TKIP, + CIPHER_CCMP, + CIPHER_WEP104 +}; + +#define CIPHER_ID_WPA_NONE "\x00\x50\xf2\x00" +#define CIPHER_ID_WPA_WEP40 "\x00\x50\xf2\x01" +#define CIPHER_ID_WPA_TKIP "\x00\x50\xf2\x02" +#define CIPHER_ID_WPA_CCMP "\x00\x50\xf2\x04" +#define CIPHER_ID_WPA_WEP104 "\x00\x50\xf2\x05" + +#define CIPHER_ID_WPA2_NONE "\x00\x0f\xac\x00" +#define CIPHER_ID_WPA2_WEP40 "\x00\x0f\xac\x01" +#define CIPHER_ID_WPA2_TKIP "\x00\x0f\xac\x02" +#define CIPHER_ID_WPA2_CCMP "\x00\x0f\xac\x04" +#define CIPHER_ID_WPA2_WEP104 "\x00\x0f\xac\x05" + +#define CIPHER_ID_LEN 4 + +enum { + KEY_MGMT_802_1X, + KEY_MGMT_PSK, + KEY_MGMT_WPANONE, +}; + +#define KEY_MGMT_ID_WPA_NONE "\x00\x50\xf2\x00" +#define KEY_MGMT_ID_WPA_1X "\x00\x50\xf2\x01" +#define KEY_MGMT_ID_WPA_PSK "\x00\x50\xf2\x02" +#define KEY_MGMT_ID_WPA_WPANONE "\x00\x50\xf2\xff" + +#define KEY_MGMT_ID_WPA2_NONE "\x00\x0f\xac\x00" +#define KEY_MGMT_ID_WPA2_1X "\x00\x0f\xac\x01" +#define KEY_MGMT_ID_WPA2_PSK "\x00\x0f\xac\x02" +#define KEY_MGMT_ID_WPA2_WPANONE "\x00\x0f\xac\xff" + +#define KEY_MGMT_ID_LEN 4 + +#define MIC_KEY_SIZE 8 + +struct wpa_key_t { + uint32_t ext_flags; /* IW_ENCODE_EXT_xxx */ + uint8_t tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + uint8_t rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast + * (group) keys or unicast address for + * individual keys */ + uint16_t alg; + uint16_t key_len; /* WEP: 5 or 13, TKIP: 32, CCMP: 16 */ + uint8_t key_val[IW_ENCODING_TOKEN_MAX]; + uint8_t tx_mic_key[MIC_KEY_SIZE]; + uint8_t rx_mic_key[MIC_KEY_SIZE]; +}; +#define WPA_KEY_INDEX_MAX 4 +#define WPA_RX_SEQ_LEN 6 + +struct mic_failure_t { + uint16_t failure; /* MIC Failure counter 0 or 1 or 2 */ + uint16_t counter; /* 1sec counter 0-60 */ + uint32_t last_failure_time; + int stop; /* stop flag */ +}; + +struct wpa_status_t { + int wpa_enabled; + unsigned int rsn_enabled; + int version; + int pairwise_suite; /* unicast cipher */ + int group_suite; /* multicast cipher */ + int key_mgmt_suite; /* authentication key management suite */ + int auth_alg; + int txkey; + struct wpa_key_t key[WPA_KEY_INDEX_MAX]; + struct scan_ext_t scan_ext; + struct mic_failure_t mic_failure; +}; + +#include +#define PMK_LIST_MAX 8 +struct pmk_list_t { + uint16_t size; + struct list_head head; + struct pmk_t { + struct list_head list; + uint8_t bssid[ETH_ALEN]; + uint8_t pmkid[IW_PMKID_LEN]; + } pmk[PMK_LIST_MAX]; +}; + +#ifdef WPS +struct wps_status_t { + int wps_enabled; + int ielen; + uint8_t ie[255]; +}; +#endif /* WPS */ + +typedef struct ks_wlan_private{ + + struct hw_info_t ks_wlan_hw; /* hardware information */ + + struct net_device *net_dev; + int reg_net; /* register_netdev */ + struct net_device_stats nstats; + struct iw_statistics wstats; + + struct completion confirm_wait; + + /* trx device & sme */ + struct tx_device tx_dev; + struct rx_device rx_dev; + struct sme_info sme_i; + u8 *rxp; + unsigned int rx_size; + struct tasklet_struct sme_task; + struct work_struct ks_wlan_wakeup_task; + int scan_ind_count; + + unsigned char eth_addr[ETH_ALEN]; + + struct local_aplist_t aplist; + struct local_ap_t current_ap; + struct power_save_status_t psstatus; + struct sleep_status_t sleepstatus; + struct wpa_status_t wpa; + struct pmk_list_t pmklist; + /* wireless parameter */ + struct ks_wlan_parameter reg; + uint8_t current_rate; + + char nick[IW_ESSID_MAX_SIZE+1]; + + spinlock_t multicast_spin; + + spinlock_t dev_read_lock; + wait_queue_head_t devread_wait; + + unsigned int need_commit; /* for ioctl */ + + /* DeviceIoControl */ + int device_open_status; + atomic_t event_count; + atomic_t rec_count; + int dev_count; +#define DEVICE_STOCK_COUNT 20 + unsigned char *dev_data[DEVICE_STOCK_COUNT]; + int dev_size[DEVICE_STOCK_COUNT]; + + /* ioctl : IOCTL_FIRMWARE_VERSION */ + unsigned char firmware_version[128+1]; + int version_size; + + int mac_address_valid; /* Mac Address Status */ + + int dev_state; + + struct sk_buff *skb; + unsigned int cur_rx; /* Index into the Rx buffer of next Rx pkt. */ + /* spinlock_t lock; */ +#define FORCE_DISCONNECT 0x80000000 +#define CONNECT_STATUS_MASK 0x7FFFFFFF + uint32_t connect_status; /* connect status */ + int infra_status; /* Infractructure status */ + + uint8_t data_buff[0x1000]; + + uint8_t scan_ssid_len; + uint8_t scan_ssid[IW_ESSID_MAX_SIZE+1]; + struct local_gain_t gain; +#ifdef WPS + struct net_device *l2_dev; + int l2_fd; + struct wps_status_t wps; +#endif /* WPS */ + uint8_t sleep_mode; + + uint8_t region; + struct local_eeprom_sum_t eeprom_sum; + uint8_t eeprom_checksum; + + struct hostt_t hostt; + + unsigned long last_doze; + unsigned long last_wakeup; + + uint sdio_error_count; /* SDIO error */ + uint wakeup_count; /* for detect wakeup loop */ + +} ks_wlan_private; + + + +#endif /* _KS_WLAN_H */ diff --git a/ks7010/src/ks_wlan_ioctl.h b/ks7010/src/ks_wlan_ioctl.h new file mode 100644 index 0000000..e27f8fb --- /dev/null +++ b/ks7010/src/ks_wlan_ioctl.h @@ -0,0 +1,69 @@ +/* + * Driver for KeyStream 11b/g wireless LAN + * + * ks_wlan_ioctl.h + * $Id: ks_wlan_ioctl.h 996 2009-09-14 02:54:21Z sekine $ + * + * Copyright (c) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#ifndef _KS_WLAN_IOCTL_H +#define _KS_WLAN_IOCTL_H + +#include +/* The low order bit identify a SET (0) or a GET (1) ioctl. */ + +/* SIOCIWFIRSTPRIV+0 */ +#define KS_WLAN_GET_DRIVER_VERSION SIOCIWFIRSTPRIV+1 +/* SIOCIWFIRSTPRIV+2 */ +#define KS_WLAN_GET_FIRM_VERSION SIOCIWFIRSTPRIV+3 +#ifdef WPS +#define KS_WLAN_SET_WPS_ENABLE SIOCIWFIRSTPRIV+4 +#define KS_WLAN_GET_WPS_ENABLE SIOCIWFIRSTPRIV+5 +#define KS_WLAN_SET_WPS_PROBE_REQ SIOCIWFIRSTPRIV+6 +#endif +#define KS_WLAN_GET_EEPROM_CKSUM SIOCIWFIRSTPRIV+7 +#define KS_WLAN_SET_PREAMBLE SIOCIWFIRSTPRIV+8 +#define KS_WLAN_GET_PREAMBLE SIOCIWFIRSTPRIV+9 +#define KS_WLAN_SET_POWER_SAVE SIOCIWFIRSTPRIV+10 +#define KS_WLAN_GET_POWER_SAVE SIOCIWFIRSTPRIV+11 +#define KS_WLAN_SET_SCAN_TYPE SIOCIWFIRSTPRIV+12 +#define KS_WLAN_GET_SCAN_TYPE SIOCIWFIRSTPRIV+13 +#define KS_WLAN_SET_RX_GAIN SIOCIWFIRSTPRIV+14 +#define KS_WLAN_GET_RX_GAIN SIOCIWFIRSTPRIV+15 +#define KS_WLAN_HOSTT SIOCIWFIRSTPRIV+16 /* unused */ +//#define KS_WLAN_SET_REGION SIOCIWFIRSTPRIV+17 +#define KS_WLAN_SET_BEACON_LOST SIOCIWFIRSTPRIV+18 +#define KS_WLAN_GET_BEACON_LOST SIOCIWFIRSTPRIV+19 + +#define KS_WLAN_SET_TX_GAIN SIOCIWFIRSTPRIV+20 +#define KS_WLAN_GET_TX_GAIN SIOCIWFIRSTPRIV+21 + +/* for KS7010 */ +#define KS_WLAN_SET_PHY_TYPE SIOCIWFIRSTPRIV+22 +#define KS_WLAN_GET_PHY_TYPE SIOCIWFIRSTPRIV+23 +#define KS_WLAN_SET_CTS_MODE SIOCIWFIRSTPRIV+24 +#define KS_WLAN_GET_CTS_MODE SIOCIWFIRSTPRIV+25 +/* SIOCIWFIRSTPRIV+26 */ +/* SIOCIWFIRSTPRIV+27 */ +#define KS_WLAN_SET_SLEEP_MODE SIOCIWFIRSTPRIV+28 /* sleep mode */ +#define KS_WLAN_GET_SLEEP_MODE SIOCIWFIRSTPRIV+29 /* sleep mode */ +/* SIOCIWFIRSTPRIV+30 */ +/* SIOCIWFIRSTPRIV+31 */ + +#ifdef __KERNEL__ + +#include "ks_wlan.h" +#include + +extern int ks_wlan_read_config_file(ks_wlan_private *priv); +extern int ks_wlan_setup_parameter(ks_wlan_private *priv, unsigned int commit_flag); + +#endif /* __KERNEL__ */ + +#endif /* _KS_WLAN_IOCTL_H */ diff --git a/ks7010/src/ks_wlan_net.c b/ks7010/src/ks_wlan_net.c new file mode 100644 index 0000000..987526b --- /dev/null +++ b/ks7010/src/ks_wlan_net.c @@ -0,0 +1,3157 @@ +/* + * Driver for KeyStream 11b/g wireless LAN + * + * ks_wlan_net.c + * $Id: ks_wlan_net.c 1020 2009-09-28 05:48:31Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int wep_on_off; +#define WEP_OFF 0 +#define WEP_ON_64BIT 1 +#define WEP_ON_128BIT 2 + +#include "ks_wlan.h" +#include "ks_hostif.h" +#include "ks_wlan_ioctl.h" +#include "ks_debug.h" + +/* Include Wireless Extension definition and check version */ +#include +#define WIRELESS_SPY /* enable iwspy support */ +#include /* New driver API */ + +#ifdef WIRELESS_EXT +/* Frequency list (map channels to frequencies) */ +static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, + 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; + +/* A few details needed for WEP (Wireless Equivalent Privacy) */ +#define MAX_KEY_SIZE 13 /* 128 (?) bits */ +#define MIN_KEY_SIZE 5 /* 40 bits RC4 - WEP */ +typedef struct wep_key_t { + u16 len; + u8 key[16]; /* 40-bit and 104-bit keys */ +} wep_key_t; + +/* Backward compatibility */ +#ifndef IW_ENCODE_NOKEY +#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */ +#define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN) +#endif /* IW_ENCODE_NOKEY */ + +/* List of Wireless Handlers (new API) */ +static const struct iw_handler_def ks_wlan_handler_def; + +#define KSC_OPNOTSUPP /* Operation Not Support*/ + +#endif /* WIRELESS_EXT */ + +/* + * function prototypes + */ +extern int ks_wlan_hw_tx(ks_wlan_private *priv, void *p, unsigned long size, + void (*complete_handler)(void *arg1, void *arg2), + void *arg1, + void *arg2 ); +static int ks_wlan_open (struct net_device *dev); +static void ks_wlan_tx_timeout (struct net_device *dev); +static int ks_wlan_start_xmit (struct sk_buff *skb, struct net_device *dev); +static int ks_wlan_close (struct net_device *dev); +static void ks_wlan_set_multicast_list (struct net_device *dev); +static struct net_device_stats *ks_wlan_get_stats (struct net_device *dev); +static int ks_wlan_set_mac_address(struct net_device *dev, void *addr); +static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); + +static atomic_t update_phyinfo; +static struct timer_list update_phyinfo_timer; +static +int ks_wlan_update_phy_information(ks_wlan_private *priv) +{ + struct iw_statistics *wstats = &priv->wstats; + + DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); + + if (priv->dev_state < DEVICE_STATE_READY) { + return -1; /* not finished initialize */ + } + if(atomic_read(&update_phyinfo)) + return 1; + + /* The status */ + wstats->status = priv->reg.operation_mode; /* Operation mode */ + + /* Signal quality and co. But where is the noise level ??? */ + hostif_sme_enqueue(priv, SME_PHY_INFO_REQUEST); + + /* interruptible_sleep_on_timeout(&priv->confirm_wait, HZ/2); */ + if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,HZ/2)){ + DPRINTK(1,"wait time out!!\n"); + } + + atomic_inc(&update_phyinfo); + update_phyinfo_timer.expires = jiffies + HZ; /* 1sec */ + add_timer(&update_phyinfo_timer); + + return 0; +} + +static +void ks_wlan_update_phyinfo_timeout(unsigned long ptr) +{ + DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); + atomic_set(&update_phyinfo,0); +} + +int ks_wlan_setup_parameter(ks_wlan_private *priv, unsigned int commit_flag) +{ + DPRINTK(2,"\n"); + + hostif_sme_enqueue(priv, SME_STOP_REQUEST); + + if(commit_flag & SME_RTS) + hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST); + if(commit_flag & SME_FRAG) + hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST); + + if(commit_flag & SME_WEP_INDEX) + hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST); + if(commit_flag & SME_WEP_VAL1) + hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST); + if(commit_flag & SME_WEP_VAL2) + hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST); + if(commit_flag & SME_WEP_VAL3) + hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST); + if(commit_flag & SME_WEP_VAL4) + hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST); + if(commit_flag & SME_WEP_FLAG) + hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); + + if(commit_flag & SME_RSN){ + hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST); + hostif_sme_enqueue(priv, SME_RSN_MODE_REQUEST); + } + if(commit_flag & SME_RSN_MULTICAST) + hostif_sme_enqueue(priv, SME_RSN_MCAST_REQUEST); + if(commit_flag & SME_RSN_UNICAST) + hostif_sme_enqueue(priv, SME_RSN_UCAST_REQUEST); + if(commit_flag & SME_RSN_AUTH) + hostif_sme_enqueue(priv, SME_RSN_AUTH_REQUEST); + + hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST); + + hostif_sme_enqueue(priv, SME_START_REQUEST); + + return 0; +} + +#ifdef WIRELESS_EXT +/* + * Initial Wireless Extension code for Ks_Wlannet driver by : + * Jean Tourrilhes - HPL - 17 November 00 + * Conversion to new driver API by : + * Jean Tourrilhes - HPL - 26 March 02 + * Javier also did a good amount of work here, adding some new extensions + * and fixing my code. Let's just say that without him this code just + * would not work at all... - Jean II + */ + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get protocol name */ +static int ks_wlan_get_name(struct net_device *dev, struct iw_request_info *info, + char *cwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *) netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if (priv->dev_state < DEVICE_STATE_READY) { + strcpy(cwrq, "NOT READY!"); + } + else if(priv->reg.phy_type == D_11B_ONLY_MODE){ + strcpy(cwrq, "IEEE 802.11b"); + } + else if(priv->reg.phy_type == D_11G_ONLY_MODE){ + strcpy(cwrq, "IEEE 802.11g"); + } + else { + strcpy(cwrq, "IEEE 802.11b/g"); + } + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set frequency */ +static int ks_wlan_set_freq(struct net_device *dev, struct iw_request_info *info, + struct iw_freq *fwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int rc = -EINPROGRESS; /* Call commit handler */ + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* If setting by frequency, convert to a channel */ + if((fwrq->e == 1) && + (fwrq->m >= (int) 2.412e8) && + (fwrq->m <= (int) 2.487e8)) { + int f = fwrq->m / 100000; + int c = 0; + while((c < 14) && (f != frequency_list[c])) + c++; + /* Hack to fall through... */ + fwrq->e = 0; + fwrq->m = c + 1; + } + /* Setting by channel number */ + if((fwrq->m > 1000) || (fwrq->e > 0)) + rc = -EOPNOTSUPP; + else { + int channel = fwrq->m; + /* We should do a better check than that, + * based on the card capability !!! */ + if((channel < 1) || (channel > 14)) { + printk(KERN_DEBUG "%s: New channel value of %d is invalid!\n", dev->name, fwrq->m); + rc = -EINVAL; + } else { + /* Yes ! We can set it !!! */ + priv->reg.channel = (u8)(channel); + priv->need_commit |= SME_MODE_SET; + } + } + + return rc; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get frequency */ +static int ks_wlan_get_freq(struct net_device *dev, struct iw_request_info *info, + struct iw_freq *fwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int f; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + f = (int)priv->current_ap.channel; + } + else + f = (int)priv->reg.channel; + fwrq->m = frequency_list[f-1] * 100000; + fwrq->e = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set ESSID */ +static int ks_wlan_set_essid(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + size_t len; + + DPRINTK(2," %d\n", dwrq->flags); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Check if we asked for `any' */ + if(dwrq->flags == 0) { + /* Just send an empty SSID list */ + memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); + priv->reg.ssid.size = 0; + } else { +#if 1 + len = dwrq->length; + /* iwconfig uses nul termination in SSID.. */ + if (len > 0 && extra[len - 1] == '\0') + len--; + + /* Check the size of the string */ + if(len > IW_ESSID_MAX_SIZE) { + return -EINVAL; + } +#else + /* Check the size of the string */ + if(dwrq->length > IW_ESSID_MAX_SIZE+1) { + return -E2BIG ; + } +#endif + + /* Set the SSID */ + memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); + +#if 1 + memcpy(priv->reg.ssid.body, extra, len); + priv->reg.ssid.size = len; +#else + memcpy(priv->reg.ssid.body, extra, dwrq->length); + priv->reg.ssid.size = dwrq->length; +#endif + } + /* Write it to the card */ + priv->need_commit |= SME_MODE_SET; + +// return -EINPROGRESS; /* Call commit handler */ + ks_wlan_setup_parameter(priv, priv->need_commit); + priv->need_commit=0; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get ESSID */ +static int ks_wlan_get_essid(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Note : if dwrq->flags != 0, we should + * get the relevant SSID from the SSID list... */ + + if(priv->reg.ssid.size){ + /* Get the current SSID */ + memcpy(extra, priv->reg.ssid.body, priv->reg.ssid.size); +#if 0 + extra[priv->reg.ssid.size] = '\0'; +#endif + /* If none, we may want to get the one that was set */ + + /* Push it out ! */ +#if 1 + dwrq->length = priv->reg.ssid.size; +#else + dwrq->length = priv->reg.ssid.size+1; +#endif + dwrq->flags = 1; /* active */ + }else{ +#if 1 + dwrq->length = 0; +#else + extra[0] = '\0'; + dwrq->length = 1; +#endif + dwrq->flags = 0; /* ANY */ + } + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set AP address */ +static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, + struct sockaddr *ap_addr, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if (priv->reg.operation_mode == MODE_ADHOC || + priv->reg.operation_mode == MODE_INFRASTRUCTURE) { + memcpy(priv->reg.bssid, (u8 *)&ap_addr->sa_data, ETH_ALEN); + + if (is_valid_ether_addr((u8 *)priv->reg.bssid)) { + priv->need_commit |= SME_MODE_SET; + } + } + else { + memset(priv->reg.bssid, 0x0, ETH_ALEN); + return -EOPNOTSUPP; + } + + DPRINTK(2, "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]); + + /* Write it to the card */ + if (priv->need_commit) { + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ + } + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get AP address */ +static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, + struct sockaddr *awrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + memcpy(awrq->sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN); + } + else{ + memset(awrq->sa_data, 0, ETH_ALEN); + } + + awrq->sa_family = ARPHRD_ETHER; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Nickname */ +static int ks_wlan_set_nick(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Check the size of the string */ + if(dwrq->length > 16 + 1) { + return -E2BIG; + } + memset(priv->nick, 0, sizeof(priv->nick)); + memcpy(priv->nick, extra, dwrq->length); + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Nickname */ +static int ks_wlan_get_nick(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + strncpy(extra, priv->nick, 16); + extra[16] = '\0'; + dwrq->length = strlen(extra) + 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Bit-Rate */ +static int ks_wlan_set_rate(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int i = 0; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(priv->reg.phy_type == D_11B_ONLY_MODE){ + if(vwrq->fixed == 1) { + switch(vwrq->value){ + case 11000000: + case 5500000: + priv->reg.rate_set.body[0] = (uint8_t)(vwrq->value/500000); + break; + case 2000000: + case 1000000: + priv->reg.rate_set.body[0] = ((uint8_t)(vwrq->value/500000))|BASIC_RATE; + break; + default: + return -EINVAL; + } + priv->reg.tx_rate = TX_RATE_FIXED; + priv->reg.rate_set.size = 1; + }else{ /* vwrq->fixed == 0 */ + if(vwrq->value > 0){ + switch(vwrq->value){ + case 11000000: + priv->reg.rate_set.body[3] = TX_RATE_11M; i++; + case 5500000: + priv->reg.rate_set.body[2] = TX_RATE_5M; i++; + case 2000000: + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; i++; + case 1000000: + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; i++; + break; + default: + return -EINVAL; + } + priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; + priv->reg.rate_set.size = i; + }else{ + 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.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 4; + } + } + }else{ /* D_11B_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + if(vwrq->fixed == 1) { + switch(vwrq->value){ + case 54000000: + case 48000000: + case 36000000: + case 18000000: + case 9000000: + priv->reg.rate_set.body[0] = (uint8_t)(vwrq->value/500000); + break; + case 24000000: + case 12000000: + case 11000000: + case 6000000: + case 5500000: + case 2000000: + case 1000000: + priv->reg.rate_set.body[0] = ((uint8_t)(vwrq->value/500000))|BASIC_RATE; + break; + default: + return -EINVAL; + } + priv->reg.tx_rate = TX_RATE_FIXED; + priv->reg.rate_set.size = 1; + }else{ /* vwrq->fixed == 0 */ + if(vwrq->value > 0){ + switch(vwrq->value){ + case 54000000: + priv->reg.rate_set.body[11] = TX_RATE_54M; i++; + case 48000000: + priv->reg.rate_set.body[10] = TX_RATE_48M; i++; + case 36000000: + priv->reg.rate_set.body[9] = TX_RATE_36M; i++; + case 24000000: case 18000000: case 12000000: + case 11000000: case 9000000: case 6000000: + if(vwrq->value == 24000000){ + priv->reg.rate_set.body[8] = TX_RATE_18M; i++; + priv->reg.rate_set.body[7] = TX_RATE_9M; i++; + priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; i++; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; + }else if(vwrq->value == 18000000){ + priv->reg.rate_set.body[7] = TX_RATE_18M; i++; + priv->reg.rate_set.body[6] = TX_RATE_9M; i++; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; + }else if(vwrq->value == 12000000){ + priv->reg.rate_set.body[6] = TX_RATE_9M; i++; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; + }else if(vwrq->value == 11000000){ + priv->reg.rate_set.body[5] = TX_RATE_9M; i++; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; + }else if(vwrq->value == 9000000){ + priv->reg.rate_set.body[4] = TX_RATE_9M; i++; + priv->reg.rate_set.body[3] = TX_RATE_6M|BASIC_RATE; i++; + }else{ /* vwrq->value == 6000000 */ + priv->reg.rate_set.body[3] = TX_RATE_6M|BASIC_RATE; i++; + } + case 5500000: + priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; i++; + case 2000000: + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; i++; + case 1000000: + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; i++; + break; + default: + return -EINVAL; + } + priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; + priv->reg.rate_set.size = i; + }else{ + 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.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 12; + } + } + } + + priv->need_commit |= SME_MODE_SET; + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Bit-Rate */ +static int ks_wlan_get_rate(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2, "in_interrupt = %ld update_phyinfo = %d\n", + in_interrupt(),atomic_read(&update_phyinfo)); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(!atomic_read(&update_phyinfo)){ + ks_wlan_update_phy_information(priv); + } + vwrq->value = ((priv->current_rate) & RATE_MASK) * 500000; + if(priv->reg.tx_rate == TX_RATE_FIXED) + vwrq->fixed = 1; + else + vwrq->fixed = 0; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set RTS threshold */ +static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int rthr = vwrq->value; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(vwrq->disabled) + rthr = 2347; + if((rthr < 0) || (rthr > 2347)) { + return -EINVAL; + } + priv->reg.rts = rthr; + priv->need_commit |= SME_RTS; + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get RTS threshold */ +static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + vwrq->value = priv->reg.rts; + vwrq->disabled = (vwrq->value >= 2347); + vwrq->fixed = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Fragmentation threshold */ +static int ks_wlan_set_frag(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int fthr = vwrq->value; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(vwrq->disabled) + fthr = 2346; + if((fthr < 256) || (fthr > 2346)) { + return -EINVAL; + } + fthr &= ~0x1; /* Get an even value - is it really needed ??? */ + priv->reg.fragment = fthr; + priv->need_commit |= SME_FRAG; + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Fragmentation threshold */ +static int ks_wlan_get_frag(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + vwrq->value = priv->reg.fragment; + vwrq->disabled = (vwrq->value >= 2346); + vwrq->fixed = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Mode of Operation */ +static int ks_wlan_set_mode(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2,"mode=%d\n",*uwrq); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + switch(*uwrq) { + case IW_MODE_ADHOC: + priv->reg.operation_mode = MODE_ADHOC; + priv->need_commit |= SME_MODE_SET; + break; + case IW_MODE_INFRA: + priv->reg.operation_mode = MODE_INFRASTRUCTURE; + priv->need_commit |= SME_MODE_SET; + break; + case IW_MODE_AUTO: + case IW_MODE_MASTER: + case IW_MODE_REPEAT: + case IW_MODE_SECOND: + case IW_MODE_MONITOR: + default: + return -EINVAL; + } + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Mode of Operation */ +static int ks_wlan_get_mode(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* If not managed, assume it's ad-hoc */ + switch (priv->reg.operation_mode) { + case MODE_INFRASTRUCTURE: + *uwrq = IW_MODE_INFRA; + break; + case MODE_ADHOC: + *uwrq = IW_MODE_ADHOC; + break; + default: + *uwrq = IW_MODE_ADHOC; + } + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Encryption Key */ +static int ks_wlan_set_encode(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + wep_key_t key; + int index = (dwrq->flags & IW_ENCODE_INDEX); + int current_index = priv->reg.wep_index; + int i; + + DPRINTK(2,"flags=%04X\n",dwrq->flags); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* index check */ + if((index<0) || (index>4)) + return -EINVAL; + else if (index==0) + index = current_index; + else + index--; + + /* Is WEP supported ? */ + /* Basic checking: do we have a key to set ? */ + if (dwrq->length > 0) { + if (dwrq->length > MAX_KEY_SIZE) { /* Check the size of the key */ + return -EINVAL; + } + if (dwrq->length > MIN_KEY_SIZE) { /* Set the length */ + key.len = MAX_KEY_SIZE; + priv->reg.privacy_invoked = 0x01; + priv->need_commit |= SME_WEP_FLAG; + wep_on_off = WEP_ON_128BIT; + } else { + if (dwrq->length > 0) { + key.len = MIN_KEY_SIZE; + priv->reg.privacy_invoked = 0x01; + priv->need_commit |= SME_WEP_FLAG; + wep_on_off = WEP_ON_64BIT; + } else { /* Disable the key */ + key.len = 0; + } + } + /* Check if the key is not marked as invalid */ + if(!(dwrq->flags & IW_ENCODE_NOKEY)) { + /* Cleanup */ + memset(key.key, 0, MAX_KEY_SIZE); + /* Copy the key in the driver */ + if(copy_from_user(key.key,dwrq->pointer,dwrq->length)) { + key.len = 0; + return -EFAULT; + } + /* Send the key to the card */ + priv->reg.wep_key[index].size = key.len; + for (i=0; i<(priv->reg.wep_key[index].size); i++) { + priv->reg.wep_key[index].val[i] = key.key[i]; + } + priv->need_commit |= (SME_WEP_VAL1<reg.wep_index = index; + priv->need_commit |= SME_WEP_INDEX; + } + } else { + if(dwrq->flags & IW_ENCODE_DISABLED){ + priv->reg.wep_key[0].size = 0; + priv->reg.wep_key[1].size = 0; + priv->reg.wep_key[2].size = 0; + priv->reg.wep_key[3].size = 0; + priv->reg.privacy_invoked = 0x00; + if(priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY){ + priv->need_commit |= SME_MODE_SET; + } + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; + wep_on_off = WEP_OFF; + priv->need_commit |= SME_WEP_FLAG; + }else{ + /* Do we want to just set the transmit key index ? */ + if ((index>=0) && (index<4)) { + /* set_wep_key(priv, index, 0, 0, 1); xxx */ + if(priv->reg.wep_key[index].size){ + priv->reg.wep_index = index; + priv->need_commit |= SME_WEP_INDEX; + } + else + return -EINVAL; + } + } + } + + /* Commit the changes if needed */ + if(dwrq->flags & IW_ENCODE_MODE) + priv->need_commit |= SME_WEP_FLAG; + + if(dwrq->flags & IW_ENCODE_OPEN) { + if(priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY){ + priv->need_commit |= SME_MODE_SET; + } + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; + } else if(dwrq->flags & IW_ENCODE_RESTRICTED) { + if(priv->reg.authenticate_type == AUTH_TYPE_OPEN_SYSTEM){ + priv->need_commit |= SME_MODE_SET; + } + priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; + } + +// return -EINPROGRESS; /* Call commit handler */ + if(priv->need_commit){ + ks_wlan_setup_parameter(priv, priv->need_commit); + priv->need_commit=0; + } + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Encryption Key */ +static int ks_wlan_get_encode(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + char zeros[16]; + int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + dwrq->flags = IW_ENCODE_DISABLED; + + /* Check encryption mode */ + switch(priv->reg.authenticate_type) { + case AUTH_TYPE_OPEN_SYSTEM: + dwrq->flags = IW_ENCODE_OPEN; + break; + case AUTH_TYPE_SHARED_KEY: + dwrq->flags = IW_ENCODE_RESTRICTED; + break; + } + + memset(zeros,0, sizeof(zeros)); + + /* Which key do we want ? -1 -> tx index */ + if((index < 0) || (index >= 4)) + index = priv->reg.wep_index; + if (priv->reg.privacy_invoked){ + dwrq->flags &= ~IW_ENCODE_DISABLED; + /* dwrq->flags |= IW_ENCODE_NOKEY; */ + } + dwrq->flags |= index + 1; + DPRINTK(2,"encoding flag = 0x%04X\n",dwrq->flags); + /* Copy the key to the user buffer */ + if((index >= 0) && (index < 4)) + dwrq->length = priv->reg.wep_key[index].size; + if (dwrq->length > 16) { + dwrq->length=0; + } +#if 1 /* IW_ENCODE_NOKEY; */ + if (dwrq->length) { + if((index >= 0) && (index < 4)) + memcpy(extra,priv->reg.wep_key[index].val,dwrq->length); + } else + memcpy(extra,zeros,dwrq->length); +#endif + return 0; +} + +#ifndef KSC_OPNOTSUPP +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Tx-Power */ +static int ks_wlan_set_txpow(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + return -EOPNOTSUPP; /* Not Support */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Tx-Power */ +static int ks_wlan_get_txpow(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Not Support */ + vwrq->value = 0; + vwrq->disabled = (vwrq->value == 0); + vwrq->fixed = 1; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Retry limits */ +static int ks_wlan_set_retry(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + return -EOPNOTSUPP; /* Not Support */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Retry limits */ +static int ks_wlan_get_retry(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Not Support */ + vwrq->value = 0; + vwrq->disabled = (vwrq->value == 0); + vwrq->fixed = 1; + return 0; +} +#endif /* KSC_OPNOTSUPP */ + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get range info */ +static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_range *range = (struct iw_range *) extra; + int i,k; + + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + dwrq->length = sizeof(struct iw_range); + memset(range, 0, sizeof(*range)); + range->min_nwid = 0x0000; + range->max_nwid = 0x0000; + range->num_channels = 14; + /* Should be based on cap_rid.country to give only + * what the current card support */ + k = 0; + for(i = 0; i < 13; i++) { /* channel 1 -- 13*/ + range->freq[k].i = i + 1; /* List index */ + range->freq[k].m = frequency_list[i] * 100000; + range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ + } + range->num_frequency = k; + if(priv->reg.phy_type == D_11B_ONLY_MODE || + priv->reg.phy_type == D_11BG_COMPATIBLE_MODE){ /* channel 14 */ + range->freq[13].i = 14; /* List index */ + range->freq[13].m = frequency_list[13] * 100000; + range->freq[13].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ + range->num_frequency = 14; + } + + /* Hum... Should put the right values there */ + range->max_qual.qual = 100; + range->max_qual.level = 256 - 128; /* 0 dBm? */ + range->max_qual.noise = 256 - 128; + range->sensitivity = 1; + + if(priv->reg.phy_type == D_11B_ONLY_MODE){ + range->bitrate[0] = 1e6; + range->bitrate[1] = 2e6; + range->bitrate[2] = 5.5e6; + range->bitrate[3] = 11e6; + range->num_bitrates = 4; + } + else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + range->bitrate[0] = 1e6; + range->bitrate[1] = 2e6; + range->bitrate[2] = 5.5e6; + range->bitrate[3] = 11e6; + + range->bitrate[4] = 6e6; + range->bitrate[5] = 9e6; + range->bitrate[6] = 12e6; + if(IW_MAX_BITRATES < 9){ + range->bitrate[7] = 54e6; + range->num_bitrates = 8; + }else{ + range->bitrate[7] = 18e6; + range->bitrate[8] = 24e6; + range->bitrate[9] = 36e6; + range->bitrate[10] = 48e6; + range->bitrate[11] = 54e6; + + range->num_bitrates = 12; + } + } + + /* Set an indication of the max TCP throughput + * in bit/s that we can expect using this interface. + * May be use for QoS stuff... Jean II */ + if(i > 2) + range->throughput = 5000 * 1000; + else + range->throughput = 1500 * 1000; + + range->min_rts = 0; + range->max_rts = 2347; + range->min_frag = 256; + range->max_frag = 2346; + + range->encoding_size[0] = 5; /* WEP: RC4 40 bits */ + range->encoding_size[1] = 13; /* WEP: RC4 ~128 bits */ + range->num_encoding_sizes = 2; + range->max_encoding_tokens = 4; + + /* power management not support */ + range->pmp_flags = IW_POWER_ON; + range->pmt_flags = IW_POWER_ON; + range->pm_capa = 0; + + /* Transmit Power - values are in dBm( or mW) */ + range->txpower[0]=-256; + range->num_txpower = 1; + range->txpower_capa = IW_TXPOW_DBM; + /* range->txpower_capa = IW_TXPOW_MWATT; */ + + range->we_version_source = 21; + range->we_version_compiled = WIRELESS_EXT; + + range->retry_capa = IW_RETRY_ON; + range->retry_flags = IW_RETRY_ON; + range->r_time_flags = IW_RETRY_ON; + + /* Experimental measurements - boundary 11/5.5 Mb/s */ + /* Note : with or without the (local->rssi), results + * are somewhat different. - Jean II */ + range->avg_qual.qual = 50; + range->avg_qual.level = 186; /* -70 dBm */ + range->avg_qual.noise = 0; + +#if defined(WIRELESS_EXT) + /* Event capability (kernel + driver) */ + range->event_capa[0] = (IW_EVENT_CAPA_K_0 | + IW_EVENT_CAPA_MASK(SIOCGIWAP) | + IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); + range->event_capa[1] = IW_EVENT_CAPA_K_1; + range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVCUSTOM) | + IW_EVENT_CAPA_MASK(IWEVMICHAELMICFAILURE)); + + /* encode extension (WPA) capability */ + range->enc_capa = (IW_ENC_CAPA_WPA | + IW_ENC_CAPA_WPA2 | + IW_ENC_CAPA_CIPHER_TKIP | + IW_ENC_CAPA_CIPHER_CCMP); +#endif + return 0; +} + + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Power Management */ +static int ks_wlan_set_power(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + short enabled; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + enabled = vwrq->disabled ? 0 : 1; + if(enabled == 0 ){ /* 0 */ + priv->reg.powermgt = POWMGT_ACTIVE_MODE; + }else if(enabled){ /* 1 */ + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE1_MODE; + else + return -EINVAL; + }else if(enabled){ /* 2 */ + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE2_MODE; + else + return -EINVAL; + }else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Power Management */ +static int ks_wlan_get_power(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(priv->reg.powermgt > 0) + vwrq->disabled = 0; + else + vwrq->disabled = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get wirless statistics */ +static int ks_wlan_get_iwstats(struct net_device *dev, struct iw_request_info *info, + struct iw_quality *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + vwrq->qual = 0; /* not supported */ + vwrq->level = priv->wstats.qual.level; + vwrq->noise = 0; /* not supported */ + vwrq->updated = 0; + + return 0; +} + +#ifndef KSC_OPNOTSUPP +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Sensitivity */ +static int ks_wlan_set_sens(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + return -EOPNOTSUPP; /* Not Support */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Sensitivity */ +static int ks_wlan_get_sens(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + /* Not Support */ + vwrq->value = 0; + vwrq->disabled = (vwrq->value == 0); + vwrq->fixed = 1; + return 0; +} +#endif /* KSC_OPNOTSUPP */ + + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get AP List */ +/* Note : this is deprecated in favor of IWSCAN */ +static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct sockaddr *address = (struct sockaddr *) extra; + struct iw_quality qual[LOCAL_APLIST_MAX]; + + int i; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + for (i = 0; i < priv->aplist.size; i++) { + memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]), ETH_ALEN); + address[i].sa_family = ARPHRD_ETHER; + qual[i].level = 256 - priv->aplist.ap[i].rssi; + qual[i].qual = priv->aplist.ap[i].sq; + qual[i].noise = 0; /* invalid noise value */ + qual[i].updated = 7; + } + if (i){ + dwrq->flags = 1; /* Should be define'd */ + memcpy(extra + sizeof(struct sockaddr)*i, + &qual, sizeof(struct iw_quality)*i); + } + dwrq->length = i; + + return 0; +} + +#if defined(WIRELESS_EXT) +/*------------------------------------------------------------------*/ +/* Wireless Handler : Initiate Scan */ +static int ks_wlan_set_scan(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_scan_req *req = NULL; + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* specified SSID SCAN */ + if(wrqu->data.length == sizeof(struct iw_scan_req) && wrqu->data.flags & IW_SCAN_THIS_ESSID){ + req = (struct iw_scan_req *) extra; + priv->scan_ssid_len = req->essid_len; + memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len); + }else{ + priv->scan_ssid_len = 0; + } + + + priv->sme_i.sme_flag |= SME_AP_SCAN; + hostif_sme_enqueue(priv, SME_BSS_SCAN_REQUEST); + + /* At this point, just return to the user. */ + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Translate scan data returned from the card to a card independent + * format that the Wireless Tools will understand - Jean II + */ +static inline char *ks_wlan_translate_scan(struct net_device *dev, struct iw_request_info *info, char *current_ev, + char *end_buf, struct local_ap_t *ap) +{ + /* ks_wlan_private *priv = (ks_wlan_private *)dev->priv; */ + struct iw_event iwe; /* Temporary buffer */ + u16 capabilities; + char *current_val; /* For rates */ + int i; + static const char rsn_leader[] = "rsn_ie="; + static const char wpa_leader[] = "wpa_ie="; + char buf0[RSN_IE_BODY_MAX*2 + 30]; + char buf1[RSN_IE_BODY_MAX*2 + 30]; + char *pbuf; + /* First entry *MUST* be the AP MAC address */ + iwe.cmd = SIOCGIWAP; + iwe.u.ap_addr.sa_family = ARPHRD_ETHER; + memcpy(iwe.u.ap_addr.sa_data, ap->bssid, ETH_ALEN); + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); + + /* Other entries will be displayed in the order we give them */ + + /* Add the ESSID */ + iwe.u.data.length = ap->ssid.size; + if(iwe.u.data.length > 32) + iwe.u.data.length = 32; + iwe.cmd = SIOCGIWESSID; + iwe.u.data.flags = 1; + current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &(ap->ssid.body[0])); + + /* Add mode */ + iwe.cmd = SIOCGIWMODE; + capabilities = le16_to_cpu(ap->capability); + if(capabilities & (BSS_CAP_ESS | BSS_CAP_IBSS)) { + if(capabilities & BSS_CAP_ESS) + iwe.u.mode = IW_MODE_INFRA; + else + iwe.u.mode = IW_MODE_ADHOC; + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); + } + + /* Add frequency */ + iwe.cmd = SIOCGIWFREQ; + iwe.u.freq.m = ap->channel; + iwe.u.freq.m = frequency_list[iwe.u.freq.m-1] * 100000; + iwe.u.freq.e = 1; + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); + + /* Add quality statistics */ + iwe.cmd = IWEVQUAL; + iwe.u.qual.level = 256 - ap->rssi; + iwe.u.qual.qual = ap->sq; + iwe.u.qual.noise = 0; /* invalid noise value */ + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); + + /* Add encryption capability */ + iwe.cmd = SIOCGIWENCODE; + if(capabilities & BSS_CAP_PRIVACY) + iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; + else + iwe.u.data.flags = IW_ENCODE_DISABLED; + iwe.u.data.length = 0; + current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &(ap->ssid.body[0])); + + /* Rate : stuffing multiple values in a single event require a bit + * more of magic - Jean II */ + current_val = current_ev + IW_EV_LCP_LEN; + + iwe.cmd = SIOCGIWRATE; + /* Those two flags are ignored... */ + iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; + + /* Max 16 values */ + for(i = 0 ; i < 16 ; i++) { + /* NULL terminated */ + if(i >= ap->rate_set.size) + break; + /* Bit rate given in 500 kb/s units (+ 0x80) */ + iwe.u.bitrate.value = ((ap->rate_set.body[i] & 0x7f) * 500000); + /* Add new value to event */ + current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); + } + /* Check if we added any event */ + if((current_val - current_ev) > IW_EV_LCP_LEN) + current_ev = current_val; + +#define GENERIC_INFO_ELEM_ID 0xdd +#define RSN_INFO_ELEM_ID 0x30 + if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) { + pbuf = &buf0[0]; + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + memcpy(buf0,rsn_leader,sizeof(rsn_leader)-1); + iwe.u.data.length += sizeof(rsn_leader)-1; + pbuf += sizeof(rsn_leader)-1; + + pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.id); + pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.size); + iwe.u.data.length += 4; + + for (i = 0; i < ap->rsn_ie.size; i++) + pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.body[i]); + iwe.u.data.length += (ap->rsn_ie.size)*2; + + DPRINTK(4,"ap->rsn.size=%d\n",ap->rsn_ie.size); + + current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, &buf0[0]); + } + if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) { + pbuf = &buf1[0]; + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + memcpy(buf1,wpa_leader,sizeof(wpa_leader)-1); + iwe.u.data.length += sizeof(wpa_leader)-1; + pbuf += sizeof(wpa_leader)-1; + + pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.id); + pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.size); + iwe.u.data.length += 4; + + for (i = 0; i < ap->wpa_ie.size; i++) + pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.body[i]); + iwe.u.data.length += (ap->wpa_ie.size)*2; + + DPRINTK(4,"ap->rsn.size=%d\n",ap->wpa_ie.size); + DPRINTK(4,"iwe.u.data.length=%d\n",iwe.u.data.length); + + current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, &buf1[0]); + } + + /* The other data in the scan result are not really + * interesting, so for now drop it - Jean II */ + return current_ev; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : Read Scan Results */ +static int ks_wlan_get_scan(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int i; + char *current_ev = extra; + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(priv->sme_i.sme_flag & SME_AP_SCAN) { +DPRINTK(2,"flag AP_SCAN\n"); + return -EAGAIN; + } + + if(priv->aplist.size == 0) { + /* Client error, no scan results... + * The caller need to restart the scan. */ +DPRINTK(2,"aplist 0\n"); + return -ENODATA; + } +#if 0 + /* current connect ap */ + if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { + dwrq->length = 0; + return -E2BIG; + } + current_ev = ks_wlan_translate_scan(dev, current_ev, +// extra + IW_SCAN_MAX_DATA, + extra + dwrq->length, + &(priv->current_ap)); + } +#endif + /* Read and parse all entries */ + for(i=0; i < priv->aplist.size; i++) { + if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { + dwrq->length = 0; + return -E2BIG; + } + /* Translate to WE format this entry */ + current_ev = ks_wlan_translate_scan(dev, info, current_ev, +// extra + IW_SCAN_MAX_DATA, + extra + dwrq->length, + &(priv->aplist.ap[i])); + } + /* Length of data */ + dwrq->length = (current_ev - extra); + dwrq->flags = 0; + + return 0; +} +#endif /* WIRELESS_EXT */ + +/*------------------------------------------------------------------*/ +/* Commit handler : called after a bunch of SET operations */ +static int ks_wlan_config_commit(struct net_device *dev, struct iw_request_info *info, + void *zwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (!priv->need_commit) + return 0; + + ks_wlan_setup_parameter(priv, priv->need_commit); + priv->need_commit=0; + return 0; +} + +#ifdef WIRELESS_EXT +/*------------------------------------------------------------------*/ +/* Wireless handler : set association ie params */ +static int ks_wlan_set_genie(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2, "\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + return 0; +// return -EOPNOTSUPP; +} + +/*------------------------------------------------------------------*/ +/* Wireless handler : set authentication mode params */ +static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int index = (vwrq->flags & IW_AUTH_INDEX); + int value = vwrq->value; + + DPRINTK(2,"index=%d:value=%08X\n",index,value); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + switch(index){ + case IW_AUTH_WPA_VERSION: /* 0 */ + switch(value){ + case IW_AUTH_WPA_VERSION_DISABLED: + priv->wpa.version = value; + if(priv->wpa.rsn_enabled){ + priv->wpa.rsn_enabled = 0; + } + priv->need_commit |= SME_RSN; + break; + case IW_AUTH_WPA_VERSION_WPA: + case IW_AUTH_WPA_VERSION_WPA2: + priv->wpa.version = value; + if(!(priv->wpa.rsn_enabled)){ + priv->wpa.rsn_enabled = 1; + } + priv->need_commit |= SME_RSN; + break; + default: + return -EOPNOTSUPP; + } + break; + case IW_AUTH_CIPHER_PAIRWISE: /* 1 */ + switch(value){ + case IW_AUTH_CIPHER_NONE: + if(priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x00; + priv->need_commit |= SME_WEP_FLAG; + } + break; + case IW_AUTH_CIPHER_WEP40: + case IW_AUTH_CIPHER_TKIP: + case IW_AUTH_CIPHER_CCMP: + case IW_AUTH_CIPHER_WEP104: + if(!priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x01; + priv->need_commit |= SME_WEP_FLAG; + } + priv->wpa.pairwise_suite = value; + priv->need_commit |= SME_RSN_UNICAST; + break; + default: + return -EOPNOTSUPP; + } + break; + case IW_AUTH_CIPHER_GROUP: /* 2 */ + switch(value){ + case IW_AUTH_CIPHER_NONE: + if(priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x00; + priv->need_commit |= SME_WEP_FLAG; + } + break; + case IW_AUTH_CIPHER_WEP40: + case IW_AUTH_CIPHER_TKIP: + case IW_AUTH_CIPHER_CCMP: + case IW_AUTH_CIPHER_WEP104: + if(!priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x01; + priv->need_commit |= SME_WEP_FLAG; + } + priv->wpa.group_suite = value; + priv->need_commit |= SME_RSN_MULTICAST; + break; + default: + return -EOPNOTSUPP; + } + break; + case IW_AUTH_KEY_MGMT: /* 3 */ + switch(value){ + case IW_AUTH_KEY_MGMT_802_1X: + case IW_AUTH_KEY_MGMT_PSK: + case 0: /* NONE or 802_1X_NO_WPA */ + case 4: /* WPA_NONE */ + priv->wpa.key_mgmt_suite = value; + priv->need_commit |= SME_RSN_AUTH; + break; + default: + return -EOPNOTSUPP; + } + break; + case IW_AUTH_80211_AUTH_ALG: /* 6 */ + switch(value){ + case IW_AUTH_ALG_OPEN_SYSTEM: + priv->wpa.auth_alg = value; + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; + break; + case IW_AUTH_ALG_SHARED_KEY: + priv->wpa.auth_alg = value; + priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; + break; + case IW_AUTH_ALG_LEAP: + default: + return -EOPNOTSUPP; + } + priv->need_commit |= SME_MODE_SET; + break; + case IW_AUTH_WPA_ENABLED: /* 7 */ + priv->wpa.wpa_enabled = value; + break; + case IW_AUTH_PRIVACY_INVOKED: /* 10 */ + if((value && !priv->reg.privacy_invoked)|| + (!value && priv->reg.privacy_invoked)){ + priv->reg.privacy_invoked = value?0x01:0x00; + priv->need_commit |= SME_WEP_FLAG; + } + break; + case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* 4 */ + case IW_AUTH_TKIP_COUNTERMEASURES: /* 5 */ + case IW_AUTH_DROP_UNENCRYPTED: /* 8 */ + case IW_AUTH_ROAMING_CONTROL: /* 9 */ + default: + break; + } + + /* return -EINPROGRESS; */ + if(priv->need_commit){ + ks_wlan_setup_parameter(priv, priv->need_commit); + priv->need_commit=0; + } + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless handler : get authentication mode params */ +static int ks_wlan_get_auth_mode(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int index = (vwrq->flags & IW_AUTH_INDEX); + DPRINTK(2,"index=%d\n",index); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* WPA (not used ?? wpa_supplicant) */ + switch(index){ + case IW_AUTH_WPA_VERSION: + vwrq->value = priv->wpa.version; + break; + case IW_AUTH_CIPHER_PAIRWISE: + vwrq->value = priv->wpa.pairwise_suite; + break; + case IW_AUTH_CIPHER_GROUP: + vwrq->value = priv->wpa.group_suite; + break; + case IW_AUTH_KEY_MGMT: + vwrq->value = priv->wpa.key_mgmt_suite; + break; + case IW_AUTH_80211_AUTH_ALG: + vwrq->value = priv->wpa.auth_alg; + break; + case IW_AUTH_WPA_ENABLED: + vwrq->value = priv->wpa.rsn_enabled; + break; + case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* OK??? */ + case IW_AUTH_TKIP_COUNTERMEASURES: + case IW_AUTH_DROP_UNENCRYPTED: + default: + /* return -EOPNOTSUPP; */ + break; + } + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set encoding token & mode (WPA)*/ +static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_encode_ext *enc; + int index = dwrq->flags & IW_ENCODE_INDEX; + unsigned int commit=0; + + enc = (struct iw_encode_ext *)extra; + + DPRINTK(2,"flags=%04X:: ext_flags=%08X\n",dwrq->flags, enc->ext_flags); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(index<1||index>4) + return -EINVAL; + else + index--; + + if(dwrq->flags & IW_ENCODE_DISABLED){ + priv->wpa.key[index].key_len=0; + } + + if(enc){ + priv->wpa.key[index].ext_flags=enc->ext_flags; + if(enc->ext_flags&IW_ENCODE_EXT_SET_TX_KEY){ + priv->wpa.txkey=index; + commit |= SME_WEP_INDEX; + }else if(enc->ext_flags&IW_ENCODE_EXT_RX_SEQ_VALID){ + if(enc->rx_seq) + memcpy(&priv->wpa.key[index].rx_seq[0], + enc->rx_seq, IW_ENCODE_SEQ_MAX_SIZE); + else + return -EINVAL; + } + + memcpy(&priv->wpa.key[index].addr.sa_data[0], + &enc->addr.sa_data[0], ETH_ALEN); + + switch (enc->alg) { + case IW_ENCODE_ALG_NONE: + if(priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x00; + commit |= SME_WEP_FLAG; + } + priv->wpa.key[index].key_len = 0; + + break; + case IW_ENCODE_ALG_WEP: + case IW_ENCODE_ALG_CCMP: + if(!priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x01; + commit |= SME_WEP_FLAG; + } + if(enc->key && enc->key_len){ + memcpy(&priv->wpa.key[index].key_val[0], + &enc->key[0], enc->key_len); + priv->wpa.key[index].key_len = enc->key_len; + commit |= (SME_WEP_VAL1 << index); + } + break; + case IW_ENCODE_ALG_TKIP: + if(!priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x01; + commit |= SME_WEP_FLAG; + } + if(enc->key && enc->key_len == 32){ + memcpy(&priv->wpa.key[index].key_val[0], + &enc->key[0], enc->key_len-16); + priv->wpa.key[index].key_len = enc->key_len-16; + if(priv->wpa.key_mgmt_suite==4){ /* WPA_NONE */ + memcpy(&priv->wpa.key[index].tx_mic_key[0], + &enc->key[16],8); + memcpy(&priv->wpa.key[index].rx_mic_key[0], + &enc->key[16],8); + }else{ + memcpy(&priv->wpa.key[index].tx_mic_key[0], + &enc->key[16],8); + memcpy(&priv->wpa.key[index].rx_mic_key[0], + &enc->key[24],8); + } + commit |= (SME_WEP_VAL1 << index); + } + break; + default: + return -EINVAL; + } + priv->wpa.key[index].alg=enc->alg; + } + else + return -EINVAL; + + if(commit){ + if(commit&SME_WEP_INDEX) + hostif_sme_enqueue(priv, SME_SET_TXKEY); + if(commit&SME_WEP_VAL_MASK) + hostif_sme_enqueue(priv, SME_SET_KEY1+index); + if(commit&SME_WEP_FLAG) + hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); + } + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get encoding token & mode (WPA)*/ +static int ks_wlan_get_encode_ext(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* WPA (not used ?? wpa_supplicant) + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct iw_encode_ext *enc; + enc = (struct iw_encode_ext *)extra; + int index = dwrq->flags & IW_ENCODE_INDEX; + WPA (not used ?? wpa_supplicant) */ + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : PMKSA cache operation (WPA2) */ +static int ks_wlan_set_pmksa(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_pmksa *pmksa ; + int i; + struct pmk_t *pmk; + struct list_head *ptr; + + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(!extra){ + return -EINVAL; + } + pmksa = (struct iw_pmksa *)extra; + DPRINTK(2,"cmd=%d\n",pmksa->cmd); + + switch(pmksa->cmd){ + case IW_PMKSA_ADD: + if(list_empty(&priv->pmklist.head)){ /* new list */ + for(i=0;ipmklist.pmk[i]; + if(!memcmp("\x00\x00\x00\x00\x00\x00",pmk->bssid,ETH_ALEN)) + break; + } + memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); + memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); + list_add(&pmk->list,&priv->pmklist.head); + priv->pmklist.size++; + } + else { /* search cache data */ + list_for_each(ptr, &priv->pmklist.head){ + pmk = list_entry(ptr, struct pmk_t, list); + if(!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)){ /* match address! list move to head. */ + memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); + list_move(&pmk->list, &priv->pmklist.head); + break; + } + } + if(ptr == &priv->pmklist.head){ /* not find address. */ + if(PMK_LIST_MAX > priv->pmklist.size){ /* new cache data */ + for(i=0;ipmklist.pmk[i]; + if(!memcmp("\x00\x00\x00\x00\x00\x00",pmk->bssid,ETH_ALEN)) + break; + } + memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); + memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); + list_add(&pmk->list,&priv->pmklist.head); + priv->pmklist.size++; + } + else{ /* overwrite old cache data */ + pmk = list_entry(priv->pmklist.head.prev, struct pmk_t, list); + memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); + memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); + list_move(&pmk->list,&priv->pmklist.head); + } + } + } + break; + case IW_PMKSA_REMOVE: + if(list_empty(&priv->pmklist.head)){ /* list empty */ + return -EINVAL; + } + else{ /* search cache data */ + list_for_each(ptr, &priv->pmklist.head){ + pmk = list_entry(ptr, struct pmk_t, list); + if(!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)){ /* match address! list del. */ + memset(pmk->bssid, 0, ETH_ALEN); + memset(pmk->pmkid, 0, IW_PMKID_LEN); + list_del_init(&pmk->list); + break; + } + } + if(ptr == &priv->pmklist.head){ /* not find address. */ + return 0; + } + } + break; + case IW_PMKSA_FLUSH: + memset(&(priv->pmklist), 0, sizeof(priv->pmklist)); + INIT_LIST_HEAD(&priv->pmklist.head); + for(i=0;ipmklist.pmk[i].list); + break; + default: + return -EINVAL; + } + + hostif_sme_enqueue(priv, SME_SET_PMKSA); + return 0; +} + +static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev) +{ + + ks_wlan_private *priv = (ks_wlan_private *) netdev_priv(dev); + struct iw_statistics *wstats = &priv->wstats; + + if(!atomic_read(&update_phyinfo)){ + if (priv->dev_state < DEVICE_STATE_READY) + return NULL; /* not finished initialize */ + else + return wstats; + } + + /* Packets discarded in the wireless adapter due to wireless + * specific problems */ + wstats->discard.nwid = 0; /* Rx invalid nwid */ + wstats->discard.code = 0; /* Rx invalid crypt */ + wstats->discard.fragment = 0; /* Rx invalid frag */ + wstats->discard.retries = 0; /* Tx excessive retries */ + wstats->discard.misc = 0; /* Invalid misc */ + wstats->miss.beacon = 0; /* Missed beacon */ + + return wstats; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set stop request */ +static int ks_wlan_set_stop_request(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(!(*uwrq)) + return -EINVAL; + + hostif_sme_enqueue(priv, SME_STOP_REQUEST); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set MLME */ +#include +static int ks_wlan_set_mlme(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_mlme *mlme = (struct iw_mlme *)extra; + __u32 mode; + + DPRINTK(2, ":%d :%d\n", mlme->cmd, mlme->reason_code); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + switch (mlme->cmd) { + case IW_MLME_DEAUTH: + if (mlme->reason_code == WLAN_REASON_MIC_FAILURE) { + return 0; + } + case IW_MLME_DISASSOC: + mode = 1; + return ks_wlan_set_stop_request(dev, NULL, &mode, NULL); + default: + return -EOPNOTSUPP; /* Not Support */ + } +} +#endif /* WIRELESS_EXT */ + +/*------------------------------------------------------------------*/ +/* Private handler : get driver version */ +static int ks_wlan_get_driver_version(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + strcpy(extra, KS_WLAN_DRIVER_VERSION_INFO); + dwrq->length = strlen(KS_WLAN_DRIVER_VERSION_INFO)+1; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get firemware version */ +static int ks_wlan_get_firmware_version(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + strcpy(extra, &(priv->firmware_version[0])); + dwrq->length = priv->version_size+1; + return 0; +} + +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : set force disconnect status */ +static int ks_wlan_set_detach(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == CONNECT_STATUS){ /* 0 */ + priv->connect_status &= ~FORCE_DISCONNECT; + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) + netif_carrier_on(dev); + }else if(*uwrq == DISCONNECT_STATUS){ /* 1 */ + priv->connect_status |= FORCE_DISCONNECT; + netif_carrier_off(dev); + }else + return -EINVAL; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get force disconnect status */ +static int ks_wlan_get_detach(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = ((priv->connect_status & FORCE_DISCONNECT) ? 1 : 0 ); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get connect status */ +static int ks_wlan_get_connect(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = (priv->connect_status & CONNECT_STATUS_MASK); + return 0; +} +#endif + +/*------------------------------------------------------------------*/ +/* Private handler : set preamble */ +static int ks_wlan_set_preamble(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == LONG_PREAMBLE){ /* 0 */ + priv->reg.preamble = LONG_PREAMBLE; + }else if(*uwrq == SHORT_PREAMBLE){ /* 1 */ + priv->reg.preamble = SHORT_PREAMBLE; + }else + return -EINVAL; + + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ + +} + +/*------------------------------------------------------------------*/ +/* Private handler : get preamble */ +static int ks_wlan_get_preamble(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.preamble; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set power save mode */ +static int ks_wlan_set_powermgt(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == POWMGT_ACTIVE_MODE){ /* 0 */ + priv->reg.powermgt = POWMGT_ACTIVE_MODE; + }else if(*uwrq == POWMGT_SAVE1_MODE){ /* 1 */ + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE1_MODE; + else + return -EINVAL; + }else if(*uwrq == POWMGT_SAVE2_MODE){ /* 2 */ + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE2_MODE; + else + return -EINVAL; + }else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get power save made */ +static int ks_wlan_get_powermgt(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.powermgt; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set scan type */ +static int ks_wlan_set_scan_type(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == ACTIVE_SCAN){ /* 0 */ + priv->reg.scan_type = ACTIVE_SCAN; + }else if(*uwrq == PASSIVE_SCAN){ /* 1 */ + priv->reg.scan_type = PASSIVE_SCAN; + }else + return -EINVAL; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get scan type */ +static int ks_wlan_get_scan_type(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.scan_type; + return 0; +} +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : write raw data to device */ +static int ks_wlan_data_write(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + unsigned char *wbuff = NULL; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + wbuff = (unsigned char *)kmalloc(dwrq->length, GFP_ATOMIC); + if(!wbuff) + return -EFAULT; + memcpy(wbuff, extra, dwrq->length); + + /* write to device */ + ks_wlan_hw_tx( priv, wbuff, dwrq->length, NULL, NULL, NULL); + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : read raw data form device */ +static int ks_wlan_data_read(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + unsigned short read_length; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(!atomic_read(&priv->event_count)){ + if (priv->dev_state < DEVICE_STATE_BOOT) { /* Remove device */ + read_length = 4; + memset(extra,0xff,read_length); + dwrq->length = read_length; + return 0; + } + read_length = 0; + memset(extra,0,1); + dwrq->length = 0; + return 0; + } + + if(atomic_read(&priv->event_count)>0) + atomic_dec(&priv->event_count); + + spin_lock(&priv->dev_read_lock); /* request spin lock */ + + /* Copy length max size 0x07ff */ + if(priv->dev_size[priv->dev_count] > 2047) + read_length = 2047; + else + read_length = priv->dev_size[priv->dev_count]; + + /* Copy data */ + memcpy(extra, &(priv->dev_data[priv->dev_count][0]), read_length); + + spin_unlock(&priv->dev_read_lock); /* release spin lock */ + + /* Initialize */ + priv->dev_data[priv->dev_count] = 0; + priv->dev_size[priv->dev_count] = 0; + + priv->dev_count++; + if(priv->dev_count == DEVICE_STOCK_COUNT) + priv->dev_count=0; + + /* Set read size */ + dwrq->length = read_length; + + return 0; +} +#endif + +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : get wep string */ +#define WEP_ASCII_BUFF_SIZE (17+64*4+1) +static int ks_wlan_get_wep_ascii(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + int i,j,len=0; + char tmp[WEP_ASCII_BUFF_SIZE]; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + strcpy(tmp," WEP keys ASCII \n"); + len+=strlen(" WEP keys ASCII \n"); + + for(i=0;i<4;i++){ + strcpy(tmp+len,"\t["); + len+=strlen("\t["); + tmp[len] = '1'+i; + len++; + strcpy(tmp+len,"] "); + len+=strlen("] "); + if(priv->reg.wep_key[i].size){ + strcpy(tmp+len,(priv->reg.wep_key[i].size < 6 ? "(40bits) [" : "(104bits) [")); + len+=strlen((priv->reg.wep_key[i].size < 6 ? "(40bits) [" : "(104bits) [")); + for(j=0;jreg.wep_key[i].size;j++,len++) + tmp[len]=(isprint(priv->reg.wep_key[i].val[j]) ? priv->reg.wep_key[i].val[j] : ' '); + + strcpy(tmp+len,"]\n"); + len+=strlen("]\n"); + } + else{ + strcpy(tmp+len,"off\n"); + len+=strlen("off\n"); + } + } + + memcpy(extra, tmp, len); + dwrq->length = len+1; + return 0; +} +#endif + +/*------------------------------------------------------------------*/ +/* Private handler : set beacon lost count */ +static int ks_wlan_set_beacon_lost(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= BEACON_LOST_COUNT_MIN && + *uwrq <= BEACON_LOST_COUNT_MAX){ + priv->reg.beacon_lost_count = *uwrq; + }else + return -EINVAL; + + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ + } + else + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get beacon lost count */ +static int ks_wlan_get_beacon_lost(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.beacon_lost_count; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set phy type */ +static int ks_wlan_set_phy_type(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == D_11B_ONLY_MODE){ /* 0 */ + priv->reg.phy_type = D_11B_ONLY_MODE; + }else if(*uwrq == D_11G_ONLY_MODE){ /* 1 */ + priv->reg.phy_type = D_11G_ONLY_MODE; + }else if(*uwrq == D_11BG_COMPATIBLE_MODE){ /* 2 */ + priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; + }else + return -EINVAL; + + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Private handler : get phy type */ +static int ks_wlan_get_phy_type(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.phy_type; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set cts mode */ +static int ks_wlan_set_cts_mode(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == CTS_MODE_FALSE){ /* 0 */ + priv->reg.cts_mode = CTS_MODE_FALSE; + }else if(*uwrq == CTS_MODE_TRUE){ /* 1 */ + if(priv->reg.phy_type == D_11G_ONLY_MODE || + priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) + priv->reg.cts_mode = CTS_MODE_TRUE; + else + priv->reg.cts_mode = CTS_MODE_FALSE; + }else + return -EINVAL; + + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Private handler : get cts mode */ +static int ks_wlan_get_cts_mode(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.cts_mode; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set sleep mode */ +static int ks_wlan_set_sleep_mode(struct net_device *dev, + struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2,"\n"); + + if(*uwrq == SLP_SLEEP){ + priv->sleep_mode = *uwrq; + printk("SET_SLEEP_MODE %d\n", priv->sleep_mode); + + hostif_sme_enqueue(priv, SME_STOP_REQUEST); + hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); + + }else if(*uwrq == SLP_ACTIVE) { + priv->sleep_mode = *uwrq; + printk("SET_SLEEP_MODE %d\n", priv->sleep_mode); + hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); + }else{ + printk("SET_SLEEP_MODE %d errror\n", *uwrq); + return -EINVAL; + } + + return 0; +} +/*------------------------------------------------------------------*/ +/* Private handler : get sleep mode */ +static int ks_wlan_get_sleep_mode(struct net_device *dev, + struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2, "GET_SLEEP_MODE %d\n", priv->sleep_mode); + *uwrq = priv->sleep_mode; + + return 0; +} + +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : set phy information timer */ +static int ks_wlan_set_phy_information_timer(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= 0 && *uwrq <= 0xFFFF) /* 0-65535 */ + priv->reg.phy_info_timer = (uint16_t)*uwrq; + else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_PHY_INFO_REQUEST); + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get phy information timer */ +static int ks_wlan_get_phy_information_timer(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.phy_info_timer; + return 0; +} +#endif + +#ifdef WPS +/*------------------------------------------------------------------*/ +/* Private handler : set WPS enable */ +static int ks_wlan_set_wps_enable(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == 0 || *uwrq == 1) + priv->wps.wps_enabled = *uwrq; + else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_WPS_ENABLE_REQUEST); + + return 0; +} +/*------------------------------------------------------------------*/ +/* Private handler : get WPS enable */ +static int ks_wlan_get_wps_enable(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->wps.wps_enabled; + printk("return=%d\n", *uwrq); + + return 0; +} +/*------------------------------------------------------------------*/ +/* Private handler : set WPS probe req */ +static int ks_wlan_set_wps_probe_req(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + uint8_t *p = extra; + unsigned char len; + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + DPRINTK(2,"dwrq->length=%d\n", dwrq->length); + + /* length check */ + if(p[1] + 2 != dwrq->length || dwrq->length > 256 ){ + return -EINVAL; + } + + priv->wps.ielen = p[1] + 2 + 1; /* IE header + IE + sizeof(len) */ + len = p[1] + 2; /* IE header + IE */ + + memcpy(priv->wps.ie, &len, sizeof(len)); + p = memcpy(priv->wps.ie+1, p, len); + + DPRINTK(2,"%d(%#x): %02X %02X %02X %02X ... %02X %02X %02X\n", + priv->wps.ielen, priv->wps.ielen, p[0], p[1], p[2], p[3], + p[priv->wps.ielen-3], p[priv->wps.ielen-2], p[priv->wps.ielen-1]); + + hostif_sme_enqueue(priv, SME_WPS_PROBE_REQUEST); + + return 0; +} +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : get WPS probe req */ +static int ks_wlan_get_wps_probe_req(struct net_device *dev, + struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + return 0; +} +#endif +#endif /* WPS */ + +/*------------------------------------------------------------------*/ +/* Private handler : set tx gain control value */ +static int ks_wlan_set_tx_gain(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ + priv->gain.TxGain = (uint8_t)*uwrq; + else + return -EINVAL; + + if(priv->gain.TxGain < 0xFF) + priv->gain.TxMode = 1; + else + priv->gain.TxMode = 0; + + + hostif_sme_enqueue(priv, SME_SET_GAIN); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get tx gain control value */ +static int ks_wlan_get_tx_gain(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->gain.TxGain; + hostif_sme_enqueue(priv, SME_GET_GAIN); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set rx gain control value */ +static int ks_wlan_set_rx_gain(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ + priv->gain.RxGain = (uint8_t)*uwrq; + else + return -EINVAL; + + if(priv->gain.RxGain < 0xFF) + priv->gain.RxMode = 1; + else + priv->gain.RxMode = 0; + + hostif_sme_enqueue(priv, SME_SET_GAIN); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get rx gain control value */ +static int ks_wlan_get_rx_gain(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->gain.RxGain; + hostif_sme_enqueue(priv, SME_GET_GAIN); + return 0; +} +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : set region value */ +static int ks_wlan_set_region(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= 0x9 && *uwrq <= 0xF) /* 0x9-0xf */ + priv->region = (uint8_t)*uwrq; + else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_SET_REGION); + return 0; +} +#endif + +/*------------------------------------------------------------------*/ +/* Private handler : get eeprom checksum result */ +static int ks_wlan_get_eeprom_cksum(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + *uwrq = priv->eeprom_checksum; + return 0; +} + +static void print_hif_event(int event){ + + switch(event){ + case HIF_DATA_REQ : + printk("HIF_DATA_REQ\n"); + break; + case HIF_DATA_IND : + printk("HIF_DATA_IND\n"); + break; + case HIF_MIB_GET_REQ : + printk("HIF_MIB_GET_REQ\n"); + break; + case HIF_MIB_GET_CONF : + printk("HIF_MIB_GET_CONF\n"); + break; + case HIF_MIB_SET_REQ : + printk("HIF_MIB_SET_REQ\n"); + break; + case HIF_MIB_SET_CONF : + printk("HIF_MIB_SET_CONF\n"); + break; + case HIF_POWERMGT_REQ : + printk("HIF_POWERMGT_REQ\n"); + break; + case HIF_POWERMGT_CONF : + printk("HIF_POWERMGT_CONF\n"); + break; + case HIF_START_REQ : + printk("HIF_START_REQ\n"); + break; + case HIF_START_CONF : + printk("HIF_START_CONF\n"); + break; + case HIF_CONNECT_IND : + printk("HIF_CONNECT_IND\n"); + break; + case HIF_STOP_REQ : + printk("HIF_STOP_REQ\n"); + break; + case HIF_STOP_CONF : + printk("HIF_STOP_CONF\n"); + break; + case HIF_PS_ADH_SET_REQ : + printk("HIF_PS_ADH_SET_REQ\n"); + break; + case HIF_PS_ADH_SET_CONF: + printk("HIF_PS_ADH_SET_CONF\n"); + break; + case HIF_INFRA_SET_REQ : + printk("HIF_INFRA_SET_REQ\n"); + break; + case HIF_INFRA_SET_CONF : + printk("HIF_INFRA_SET_CONF\n"); + break; + case HIF_ADH_SET_REQ : + printk("HIF_ADH_SET_REQ\n"); + break; + case HIF_ADH_SET_CONF : + printk("HIF_ADH_SET_CONF\n"); + break; + case HIF_AP_SET_REQ : + printk("HIF_AP_SET_REQ\n"); + break; + case HIF_AP_SET_CONF : + printk("HIF_AP_SET_CONF\n"); + break; + case HIF_ASSOC_INFO_IND : + printk("HIF_ASSOC_INFO_IND\n"); + break; + case HIF_MIC_FAILURE_REQ: + printk("HIF_MIC_FAILURE_REQ\n"); + break; + case HIF_MIC_FAILURE_CONF : + printk("HIF_MIC_FAILURE_CONF\n"); + break; + case HIF_SCAN_REQ : + printk("HIF_SCAN_REQ\n"); + break; + case HIF_SCAN_CONF : + printk("HIF_SCAN_CONF\n"); + break; + case HIF_PHY_INFO_REQ : + printk("HIF_PHY_INFO_REQ\n"); + break; + case HIF_PHY_INFO_CONF : + printk("HIF_PHY_INFO_CONF\n"); + break; + case HIF_SLEEP_REQ : + printk("HIF_SLEEP_REQ\n"); + break; + case HIF_SLEEP_CONF : + printk("HIF_SLEEP_CONF\n"); + break; + case HIF_PHY_INFO_IND : + printk("HIF_PHY_INFO_IND\n"); + break; + case HIF_SCAN_IND : + printk("HIF_SCAN_IND\n"); + break; + case HIF_INFRA_SET2_REQ : + printk("HIF_INFRA_SET2_REQ\n"); + break; + case HIF_INFRA_SET2_CONF: + printk("HIF_INFRA_SET2_CONF\n"); + break; + case HIF_ADH_SET2_REQ : + printk("HIF_ADH_SET2_REQ\n"); + break; + case HIF_ADH_SET2_CONF : + printk("HIF_ADH_SET2_CONF\n"); + } +} + +/*------------------------------------------------------------------*/ +/* Private handler : get host command history */ +static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + int i,event; + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + for(i = 63; i >= 0; i--){ + event = priv->hostt.buff[(priv->hostt.qtail -1 -i)%SME_EVENT_BUFF_SIZE] ; + print_hif_event(event); + } + return 0; +} + +/* Structures to export the Wireless Handlers */ + +static const struct iw_priv_args ks_wlan_private_args[] = { +/*{ cmd, set_args, get_args, name[16] } */ + { KS_WLAN_GET_DRIVER_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "GetDriverVer" }, + { KS_WLAN_GET_FIRM_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "GetFirmwareVer" }, +#ifdef WPS + { KS_WLAN_SET_WPS_ENABLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetWPSEnable" }, + { KS_WLAN_GET_WPS_ENABLE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetW" }, + { KS_WLAN_SET_WPS_PROBE_REQ, IW_PRIV_TYPE_BYTE | 2047, IW_PRIV_TYPE_NONE, "SetWPSProbeReq" }, +#endif /* WPS */ + { KS_WLAN_SET_PREAMBLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPreamble" }, + { KS_WLAN_GET_PREAMBLE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPreamble" }, + { KS_WLAN_SET_POWER_SAVE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPowerSave" }, + { KS_WLAN_GET_POWER_SAVE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPowerSave" }, + { KS_WLAN_SET_SCAN_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetScanType" }, + { KS_WLAN_GET_SCAN_TYPE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetScanType" }, + { KS_WLAN_SET_RX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetRxGain" }, + { KS_WLAN_GET_RX_GAIN, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetRxGain" }, + { KS_WLAN_HOSTT, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "hostt" }, + { KS_WLAN_SET_BEACON_LOST, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetBeaconLost" }, + { KS_WLAN_GET_BEACON_LOST, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetBeaconLost" }, + { KS_WLAN_SET_SLEEP_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetSleepMode" }, + { KS_WLAN_GET_SLEEP_MODE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetSleepMode" }, + { KS_WLAN_SET_TX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetTxGain" }, + { KS_WLAN_GET_TX_GAIN, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetTxGain" }, + { KS_WLAN_SET_PHY_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPhyType" }, + { KS_WLAN_GET_PHY_TYPE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPhyType" }, + { KS_WLAN_SET_CTS_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetCtsMode" }, + { KS_WLAN_GET_CTS_MODE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetCtsMode" }, + { KS_WLAN_GET_EEPROM_CKSUM, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetChecksum" }, +}; +static const iw_handler ks_wlan_handler[] = +{ + (iw_handler) ks_wlan_config_commit, /* SIOCSIWCOMMIT */ + (iw_handler) ks_wlan_get_name, /* SIOCGIWNAME */ + (iw_handler) NULL, /* SIOCSIWNWID */ + (iw_handler) NULL, /* SIOCGIWNWID */ + (iw_handler) ks_wlan_set_freq, /* SIOCSIWFREQ */ + (iw_handler) ks_wlan_get_freq, /* SIOCGIWFREQ */ + (iw_handler) ks_wlan_set_mode, /* SIOCSIWMODE */ + (iw_handler) ks_wlan_get_mode, /* SIOCGIWMODE */ +#ifndef KSC_OPNOTSUPP + (iw_handler) ks_wlan_set_sens, /* SIOCSIWSENS */ + (iw_handler) ks_wlan_get_sens, /* SIOCGIWSENS */ +#else /* KSC_OPNOTSUPP */ + (iw_handler) NULL, /* SIOCSIWSENS */ + (iw_handler) NULL, /* SIOCGIWSENS */ +#endif /* KSC_OPNOTSUPP */ + (iw_handler) NULL, /* SIOCSIWRANGE */ + (iw_handler) ks_wlan_get_range, /* SIOCGIWRANGE */ + (iw_handler) NULL, /* SIOCSIWPRIV */ + (iw_handler) NULL, /* SIOCGIWPRIV */ + (iw_handler) NULL, /* SIOCSIWSTATS */ + (iw_handler) ks_wlan_get_iwstats, /* SIOCGIWSTATS */ + (iw_handler) NULL, /* SIOCSIWSPY */ + (iw_handler) NULL, /* SIOCGIWSPY */ + (iw_handler) NULL, /* SIOCSIWTHRSPY */ + (iw_handler) NULL, /* SIOCGIWTHRSPY */ + (iw_handler) ks_wlan_set_wap, /* SIOCSIWAP */ + (iw_handler) ks_wlan_get_wap, /* SIOCGIWAP */ +// (iw_handler) NULL, /* SIOCSIWMLME */ + (iw_handler) ks_wlan_set_mlme, /* SIOCSIWMLME */ + (iw_handler) ks_wlan_get_aplist, /* SIOCGIWAPLIST */ + (iw_handler) ks_wlan_set_scan, /* SIOCSIWSCAN */ + (iw_handler) ks_wlan_get_scan, /* SIOCGIWSCAN */ + (iw_handler) ks_wlan_set_essid, /* SIOCSIWESSID */ + (iw_handler) ks_wlan_get_essid, /* SIOCGIWESSID */ + (iw_handler) ks_wlan_set_nick, /* SIOCSIWNICKN */ + (iw_handler) ks_wlan_get_nick, /* SIOCGIWNICKN */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) ks_wlan_set_rate, /* SIOCSIWRATE */ + (iw_handler) ks_wlan_get_rate, /* SIOCGIWRATE */ + (iw_handler) ks_wlan_set_rts, /* SIOCSIWRTS */ + (iw_handler) ks_wlan_get_rts, /* SIOCGIWRTS */ + (iw_handler) ks_wlan_set_frag, /* SIOCSIWFRAG */ + (iw_handler) ks_wlan_get_frag, /* SIOCGIWFRAG */ +#ifndef KSC_OPNOTSUPP + (iw_handler) ks_wlan_set_txpow, /* SIOCSIWTXPOW */ + (iw_handler) ks_wlan_get_txpow, /* SIOCGIWTXPOW */ + (iw_handler) ks_wlan_set_retry, /* SIOCSIWRETRY */ + (iw_handler) ks_wlan_get_retry, /* SIOCGIWRETRY */ +#else /* KSC_OPNOTSUPP */ + (iw_handler) NULL, /* SIOCSIWTXPOW */ + (iw_handler) NULL, /* SIOCGIWTXPOW */ + (iw_handler) NULL, /* SIOCSIWRETRY */ + (iw_handler) NULL, /* SIOCGIWRETRY */ +#endif /* KSC_OPNOTSUPP */ + (iw_handler) ks_wlan_set_encode, /* SIOCSIWENCODE */ + (iw_handler) ks_wlan_get_encode, /* SIOCGIWENCODE */ + (iw_handler) ks_wlan_set_power, /* SIOCSIWPOWER */ + (iw_handler) ks_wlan_get_power, /* SIOCGIWPOWER */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* -- hole -- */ +// (iw_handler) NULL, /* SIOCSIWGENIE */ + (iw_handler) ks_wlan_set_genie, /* SIOCSIWGENIE */ + (iw_handler) NULL, /* SIOCGIWGENIE */ + (iw_handler) ks_wlan_set_auth_mode, /* SIOCSIWAUTH */ + (iw_handler) ks_wlan_get_auth_mode, /* SIOCGIWAUTH */ + (iw_handler) ks_wlan_set_encode_ext, /* SIOCSIWENCODEEXT */ + (iw_handler) ks_wlan_get_encode_ext, /* SIOCGIWENCODEEXT */ + (iw_handler) ks_wlan_set_pmksa, /* SIOCSIWPMKSA */ + (iw_handler) NULL, /* -- hole -- */ +}; + +/* private_handler */ +static const iw_handler ks_wlan_private_handler[] = +{ + (iw_handler) NULL, /* 0 */ + (iw_handler) ks_wlan_get_driver_version, /* 1 KS_WLAN_GET_DRIVER_VERSION */ + (iw_handler) NULL, /* 2 */ + (iw_handler) ks_wlan_get_firmware_version, /* 3 KS_WLAN_GET_FIRM_VERSION */ +#ifdef WPS + (iw_handler) ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */ + (iw_handler) ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */ + (iw_handler) ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */ +#else + (iw_handler) NULL, /* 4 */ + (iw_handler) NULL, /* 5 */ + (iw_handler) NULL, /* 6 */ +#endif /* WPS */ + + (iw_handler) ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */ + (iw_handler) ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */ + (iw_handler) ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */ + (iw_handler) ks_wlan_set_powermgt, /* 10 KS_WLAN_SET_POWER_SAVE */ + (iw_handler) ks_wlan_get_powermgt, /* 11 KS_WLAN_GET_POWER_SAVE */ + (iw_handler) ks_wlan_set_scan_type, /* 12 KS_WLAN_SET_SCAN_TYPE */ + (iw_handler) ks_wlan_get_scan_type, /* 13 KS_WLAN_GET_SCAN_TYPE */ + (iw_handler) ks_wlan_set_rx_gain, /* 14 KS_WLAN_SET_RX_GAIN */ + (iw_handler) ks_wlan_get_rx_gain, /* 15 KS_WLAN_GET_RX_GAIN */ + (iw_handler) ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */ + (iw_handler) NULL, /* 17 */ + (iw_handler) ks_wlan_set_beacon_lost, /* 18 KS_WLAN_SET_BECAN_LOST */ + (iw_handler) ks_wlan_get_beacon_lost, /* 19 KS_WLAN_GET_BECAN_LOST */ + (iw_handler) ks_wlan_set_tx_gain, /* 20 KS_WLAN_SET_TX_GAIN */ + (iw_handler) ks_wlan_get_tx_gain, /* 21 KS_WLAN_GET_TX_GAIN */ + (iw_handler) ks_wlan_set_phy_type, /* 22 KS_WLAN_SET_PHY_TYPE */ + (iw_handler) ks_wlan_get_phy_type, /* 23 KS_WLAN_GET_PHY_TYPE */ + (iw_handler) ks_wlan_set_cts_mode, /* 24 KS_WLAN_SET_CTS_MODE */ + (iw_handler) ks_wlan_get_cts_mode, /* 25 KS_WLAN_GET_CTS_MODE */ + (iw_handler) NULL, /* 26 */ + (iw_handler) NULL, /* 27 */ + (iw_handler) ks_wlan_set_sleep_mode, /* 28 KS_WLAN_SET_SLEEP_MODE */ + (iw_handler) ks_wlan_get_sleep_mode, /* 29 KS_WLAN_GET_SLEEP_MODE */ + (iw_handler) NULL, /* 30 */ + (iw_handler) NULL, /* 31 */ +}; + +static const struct iw_handler_def ks_wlan_handler_def = +{ + .num_standard = sizeof(ks_wlan_handler)/sizeof(iw_handler), + .num_private = sizeof(ks_wlan_private_handler)/sizeof(iw_handler), + .num_private_args = sizeof(ks_wlan_private_args)/sizeof(struct iw_priv_args), + .standard = (iw_handler *) ks_wlan_handler, + .private = (iw_handler *) ks_wlan_private_handler, + .private_args = (struct iw_priv_args *) ks_wlan_private_args, + .get_wireless_stats = ks_get_wireless_stats, +}; + +#endif /* WIRELESS_EXT */ + +static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; +#if defined(WIRELESS_EXT) + struct iwreq *wrq = (struct iwreq *) rq; +#endif /* WIRELESS_EXT */ + switch (cmd) { +#if defined(WIRELESS_EXT) + case SIOCIWFIRSTPRIV+20: /* KS_WLAN_SET_STOP_REQ */ + rc = ks_wlan_set_stop_request(dev, NULL, &(wrq->u.mode), NULL); + break; +#endif /* WIRELESS_EXT >17 */ + // All other calls are currently unsupported + default: + rc = -EOPNOTSUPP; + } + + DPRINTK(5,"return=%d\n",rc); + return rc; +} + + +static +struct net_device_stats *ks_wlan_get_stats(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + if (priv->dev_state < DEVICE_STATE_READY) { + return NULL; /* not finished initialize */ + } + + return &priv->nstats; +} + +static +int ks_wlan_set_mac_address(struct net_device *dev, void *addr) +{ + ks_wlan_private *priv = netdev_priv(dev); + struct sockaddr *mac_addr=(struct sockaddr *)addr; + if (netif_running(dev)) + return -EBUSY; + memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); + memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN); + + priv->mac_address_valid = 0; + hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST); + 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]); + return 0; +} + + +static +void ks_wlan_tx_timeout(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + DPRINTK(1,"head(%d) tail(%d)!!\n",priv->tx_dev.qhead, priv->tx_dev.qtail); + if(!netif_queue_stopped(dev)){ + netif_stop_queue(dev); + } + priv->nstats.tx_errors++; + netif_wake_queue(dev); + + return; +} + +static +int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + int rc = 0; + + DPRINTK(3,"in_interrupt()=%ld\n",in_interrupt()); + + if ( skb == NULL ) { + printk( KERN_ERR "ks_wlan: skb == NULL!!!\n" ); + return 0; + } + if (priv->dev_state < DEVICE_STATE_READY) { + dev_kfree_skb(skb); + return 0; /* not finished initialize */ + } + + if(netif_running(dev)) + netif_stop_queue(dev); + + rc = hostif_data_request(priv, skb); + dev->trans_start = jiffies; + + DPRINTK(4,"rc=%d\n",rc); + if (rc){ + rc=0; + } + + return rc; +} + +void send_packet_complete(void *arg1, void *arg2) +{ + ks_wlan_private *priv = (ks_wlan_private *)arg1; + struct sk_buff *packet = (struct sk_buff *)arg2; + + DPRINTK(3,"\n"); + + priv->nstats.tx_bytes += packet->len; + priv->nstats.tx_packets++; + + if(netif_queue_stopped(priv->net_dev)) + netif_wake_queue(priv->net_dev); + + if(packet){ + dev_kfree_skb(packet); + packet=NULL; + } + +} + +/* Set or clear the multicast filter for this adaptor. + This routine is not state sensitive and need not be SMP locked. */ +static +void ks_wlan_set_multicast_list(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + DPRINTK(4,"\n"); + if (priv->dev_state < DEVICE_STATE_READY) { + return ; /* not finished initialize */ + } + hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST); + + return; +} + +static +int ks_wlan_open(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + priv->cur_rx = 0; + + if(!priv->mac_address_valid){ + printk(KERN_ERR "ks_wlan : %s Not READY !!\n", dev->name); + return -EBUSY; + } + else + netif_start_queue (dev); + + return 0; +} + +static +int ks_wlan_close(struct net_device *dev) +{ + + netif_stop_queue (dev); + + DPRINTK(4, "%s: Shutting down ethercard, status was 0x%4.4x.\n", + dev->name, 0x00); + + return 0; +} + + +/* Operational parameters that usually are not changed. */ +/* Time in jiffies before concluding the transmitter is hung. */ +#define TX_TIMEOUT (3*HZ) +static const unsigned char dummy_addr[] = {0x00,0x0b,0xe3,0x00,0x00,0x00}; + +static const struct net_device_ops ks_wlan_netdev_ops = { + .ndo_start_xmit = ks_wlan_start_xmit, + .ndo_open = ks_wlan_open, + .ndo_stop = ks_wlan_close, + .ndo_do_ioctl = ks_wlan_netdev_ioctl, + .ndo_set_mac_address = ks_wlan_set_mac_address, + .ndo_get_stats = ks_wlan_get_stats, + .ndo_tx_timeout = ks_wlan_tx_timeout, + .ndo_set_multicast_list = ks_wlan_set_multicast_list, +}; + +int ks_wlan_net_start(struct net_device *dev) +{ + ks_wlan_private *priv; + /* int rc; */ + + priv = netdev_priv(dev); + priv->mac_address_valid = 0; + priv->need_commit = 0; + + priv->device_open_status = 1; + + /* phy information update timer */ + atomic_set(&update_phyinfo,0); + init_timer(&update_phyinfo_timer); + update_phyinfo_timer.function=ks_wlan_update_phyinfo_timeout; + update_phyinfo_timer.data = (unsigned long)priv; + + /* dummy address set */ + memcpy(priv->eth_addr, dummy_addr, ETH_ALEN); + dev->dev_addr[0] = priv->eth_addr[0]; + dev->dev_addr[1] = priv->eth_addr[1]; + dev->dev_addr[2] = priv->eth_addr[2]; + dev->dev_addr[3] = priv->eth_addr[3]; + dev->dev_addr[4] = priv->eth_addr[4]; + dev->dev_addr[5] = priv->eth_addr[5]; + dev->dev_addr[6] = 0x00; + dev->dev_addr[7] = 0x00; + + /* The ks_wlan-specific entries in the device structure. */ + dev->netdev_ops = &ks_wlan_netdev_ops; + dev->wireless_handlers = (struct iw_handler_def *)&ks_wlan_handler_def; + dev->watchdog_timeo = TX_TIMEOUT; + + netif_carrier_off(dev); + + return 0; +} + + +int ks_wlan_net_stop(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + int ret = 0; + priv->device_open_status = 0; + del_timer_sync(&update_phyinfo_timer); + + if(netif_running(dev)) + netif_stop_queue(dev); + + return ret; +} + +int ks_wlan_reset(struct net_device *dev) +{ + return 0; +} diff --git a/ks7010/src/michael_mic.c b/ks7010/src/michael_mic.c new file mode 100644 index 0000000..ec8769a --- /dev/null +++ b/ks7010/src/michael_mic.c @@ -0,0 +1,143 @@ +/* + * Driver for KeyStream wireless LAN + * + * michael_mic.c + * $Id: michael_mic.c 991 2009-09-14 01:38:58Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#include +#include +#include "michael_mic.h" + +// Rotation functions on 32 bit values +#define ROL32( A, n ) ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) ) +#define ROR32( A, n ) ROL32( (A), 32-(n) ) +// Convert from Byte[] to UInt32 in a portable way +#define getUInt32( A, B ) (uint32_t)(A[B+0] << 0) + (A[B+1] << 8) + (A[B+2] << 16) + (A[B+3] << 24) + +// Convert from UInt32 to Byte[] in a portable way +#define putUInt32( A, B, C ) A[B+0] = (uint8_t) (C & 0xff); \ + A[B+1] = (uint8_t) ((C>>8) & 0xff); \ + A[B+2] = (uint8_t) ((C>>16) & 0xff); \ + A[B+3] = (uint8_t) ((C>>24) & 0xff) + +// Reset the state to the empty message. +#define MichaelClear( A ) A->L = A->K0; \ + A->R = A->K1; \ + A->nBytesInM = 0; + +static +void MichaelInitializeFunction( struct michel_mic_t *Mic, uint8_t *key ) +{ + // Set the key + Mic->K0 = getUInt32( key , 0 ); + Mic->K1 = getUInt32( key , 4 ); + + //clear(); + MichaelClear(Mic); +} + +#define MichaelBlockFunction(L, R) \ +do{ \ + R ^= ROL32( L, 17 ); \ + L += R; \ + R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); \ + L += R; \ + R ^= ROL32( L, 3 ); \ + L += R; \ + R ^= ROR32( L, 2 ); \ + L += R; \ +}while(0) + + +static +void MichaelAppend( struct michel_mic_t *Mic, uint8_t *src, int nBytes ) +{ + int addlen ; + if (Mic->nBytesInM) { + addlen = 4 - Mic->nBytesInM; + if (addlen > nBytes) + addlen = nBytes; + memcpy(&Mic->M[Mic->nBytesInM], src, addlen); + Mic->nBytesInM += addlen; + src += addlen; + nBytes -= addlen; + + if (Mic->nBytesInM < 4) + return; + + Mic->L ^= getUInt32(Mic->M,0); + MichaelBlockFunction(Mic->L, Mic->R); + Mic->nBytesInM = 0; + } + + while(nBytes >= 4){ + Mic->L ^= getUInt32(src,0); + MichaelBlockFunction(Mic->L, Mic->R); + src += 4; + nBytes -= 4; + } + + if (nBytes > 0) { + Mic->nBytesInM = nBytes; + memcpy(Mic->M, src, nBytes); + } +} + +static +void MichaelGetMIC( struct michel_mic_t *Mic, uint8_t *dst ) +{ + uint8_t *data = Mic->M; + switch (Mic->nBytesInM) { + case 0: + Mic->L ^= 0x5a; + break; + case 1: + Mic->L ^= data[0] | 0x5a00; + break; + case 2: + Mic->L ^= data[0] | (data[1] << 8) | 0x5a0000; + break; + case 3: + Mic->L ^= data[0] | (data[1] << 8) | (data[2] << 16) | + 0x5a000000; + break; + } + MichaelBlockFunction(Mic->L, Mic->R); + MichaelBlockFunction(Mic->L, Mic->R); + // The appendByte function has already computed the result. + putUInt32( dst, 0, Mic->L ); + putUInt32( dst, 4, Mic->R ); + + // Reset to the empty message. + MichaelClear(Mic); +} + +void MichaelMICFunction( struct michel_mic_t *Mic, uint8_t *Key, + uint8_t *Data, int Len, uint8_t priority, + uint8_t *Result ) +{ + uint8_t pad_data[4] = {priority,0,0,0}; + // Compute the MIC value + /* + * IEEE802.11i page 47 + * Figure 43g TKIP MIC processing format + * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ + * |6 |6 |1 |3 |M |1 |1 |1 |1 |1 |1 |1 |1 | Octet + * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ + * |DA|SA|Priority|0 |Data|M0|M1|M2|M3|M4|M5|M6|M7| + * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ + */ + MichaelInitializeFunction( Mic, Key ) ; + MichaelAppend( Mic, (uint8_t*)Data, 12 ); /* |DA|SA| */ + MichaelAppend( Mic, pad_data, 4 ); /* |Priority|0|0|0| */ + MichaelAppend( Mic, (uint8_t*)(Data+12), Len -12 ); /* |Data| */ + MichaelGetMIC( Mic, Result ) ; +} diff --git a/ks7010/src/michael_mic.h b/ks7010/src/michael_mic.h new file mode 100644 index 0000000..f14f160 --- /dev/null +++ b/ks7010/src/michael_mic.h @@ -0,0 +1,29 @@ +/* + * Driver for KeyStream wireless LAN + * + * michael_mic.h + * $Id: michael_mic.h 991 2009-09-14 01:38:58Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +/* MichelMIC routine define */ +struct michel_mic_t { + uint32_t K0; // Key + uint32_t K1; // Key + uint32_t L; // Current state + uint32_t R; // Current state + uint8_t M[4]; // Message accumulator (single word) + int nBytesInM; // # bytes in M + uint8_t Result[8]; +}; + +extern +void MichaelMICFunction( struct michel_mic_t *Mic, uint8_t *Key, + uint8_t *Data, int Len, uint8_t priority, + uint8_t *Result );