mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-27 17:55:55 +02:00
add ks7010 drivers
Signed-off-by: Xiangfu Liu <xiangfu@sharism.cc>
This commit is contained in:
parent
f187a489f1
commit
137de867d2
40
package/ks7010/Makefile
Normal file
40
package/ks7010/Makefile
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
$(eval $(call KernelPackage,ks7010))
|
7
package/ks7010/src/Kconfig
Normal file
7
package/ks7010/src/Kconfig
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
config KS7010
|
||||||
|
tristate "KeyStream KS7010 SDIO support"
|
||||||
|
---help---
|
||||||
|
This is a driver for KS7010 Wi-Fi SDIO based SD cards.
|
||||||
|
This driver is tested for Ben NanoNote gadget from qi-hardware.com
|
||||||
|
|
||||||
|
Thanks to Renesas/KeyStream for their donation!
|
5
package/ks7010/src/Makefile
Normal file
5
package/ks7010/src/Makefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
obj-m += ks7010.o
|
||||||
|
|
||||||
|
ccflags-y += -D_SDIO_ -DKS_WLAN_DEBUG=0
|
||||||
|
ks7010-y := michael_mic.o ks_hostif.o ks_wlan_net.o ks_debug.o \
|
||||||
|
ks7010_sdio.o ks7010_config.o
|
136
package/ks7010/src/eap_packet.h
Normal file
136
package/ks7010/src/eap_packet.h
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* eap_packet.h
|
||||||
|
* $Id: eap_packet.h 991 2009-09-14 01:38:58Z sekine $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef EAP_PACKET_H
|
||||||
|
#define EAP_PACKET_H
|
||||||
|
|
||||||
|
#define WBIT(n) (1 << (n))
|
||||||
|
|
||||||
|
#ifndef ETH_ALEN
|
||||||
|
#define ETH_ALEN 6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct ether_hdr {
|
||||||
|
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
|
||||||
|
unsigned char h_source[ETH_ALEN]; /* source ether addr */
|
||||||
|
unsigned char h_dest_snap;
|
||||||
|
unsigned char h_source_snap;
|
||||||
|
unsigned char h_command;
|
||||||
|
unsigned char h_vendor_id[3];
|
||||||
|
unsigned short h_proto; /* packet type ID field */
|
||||||
|
#define ETHER_PROTOCOL_TYPE_EAP 0x888e
|
||||||
|
#define ETHER_PROTOCOL_TYPE_IP 0x0800
|
||||||
|
#define ETHER_PROTOCOL_TYPE_ARP 0x0806
|
||||||
|
/* followed by length octets of data */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct ieee802_1x_hdr {
|
||||||
|
unsigned char version;
|
||||||
|
unsigned char type;
|
||||||
|
unsigned short length;
|
||||||
|
/* followed by length octets of data */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
#define EAPOL_VERSION 2
|
||||||
|
|
||||||
|
enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
|
||||||
|
IEEE802_1X_TYPE_EAPOL_START = 1,
|
||||||
|
IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
|
||||||
|
IEEE802_1X_TYPE_EAPOL_KEY = 3,
|
||||||
|
IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
|
||||||
|
EAPOL_KEY_TYPE_WPA = 254 };
|
||||||
|
|
||||||
|
|
||||||
|
#define IEEE8021X_REPLAY_COUNTER_LEN 8
|
||||||
|
#define IEEE8021X_KEY_SIGN_LEN 16
|
||||||
|
#define IEEE8021X_KEY_IV_LEN 16
|
||||||
|
|
||||||
|
#define IEEE8021X_KEY_INDEX_FLAG 0x80
|
||||||
|
#define IEEE8021X_KEY_INDEX_MASK 0x03
|
||||||
|
|
||||||
|
struct ieee802_1x_eapol_key {
|
||||||
|
unsigned char type;
|
||||||
|
unsigned short key_length;
|
||||||
|
/* does not repeat within the life of the keying material used to
|
||||||
|
* encrypt the Key field; 64-bit NTP timestamp MAY be used here */
|
||||||
|
unsigned char replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
|
||||||
|
unsigned char key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
|
||||||
|
unsigned char key_index; /* key flag in the most significant bit:
|
||||||
|
* 0 = broadcast (default key),
|
||||||
|
* 1 = unicast (key mapping key); key index is in the
|
||||||
|
* 7 least significant bits */
|
||||||
|
/* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
|
||||||
|
* the key */
|
||||||
|
unsigned char key_signature[IEEE8021X_KEY_SIGN_LEN];
|
||||||
|
|
||||||
|
/* followed by key: if packet body length = 44 + key length, then the
|
||||||
|
* key field (of key_length bytes) contains the key in encrypted form;
|
||||||
|
* if packet body length = 44, key field is absent and key_length
|
||||||
|
* represents the number of least significant octets from
|
||||||
|
* MS-MPPE-Send-Key attribute to be used as the keying material;
|
||||||
|
* RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
#define WPA_NONCE_LEN 32
|
||||||
|
#define WPA_REPLAY_COUNTER_LEN 8
|
||||||
|
|
||||||
|
struct wpa_eapol_key {
|
||||||
|
unsigned char type;
|
||||||
|
unsigned short key_info;
|
||||||
|
unsigned short key_length;
|
||||||
|
unsigned char replay_counter[WPA_REPLAY_COUNTER_LEN];
|
||||||
|
unsigned char key_nonce[WPA_NONCE_LEN];
|
||||||
|
unsigned char key_iv[16];
|
||||||
|
unsigned char key_rsc[8];
|
||||||
|
unsigned char key_id[8]; /* Reserved in IEEE 802.11i/RSN */
|
||||||
|
unsigned char key_mic[16];
|
||||||
|
unsigned short key_data_length;
|
||||||
|
/* followed by key_data_length bytes of key_data */
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
#define WPA_KEY_INFO_TYPE_MASK (WBIT(0) | WBIT(1) | WBIT(2))
|
||||||
|
#define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 WBIT(0)
|
||||||
|
#define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES WBIT(1)
|
||||||
|
#define WPA_KEY_INFO_KEY_TYPE WBIT(3) /* 1 = Pairwise, 0 = Group key */
|
||||||
|
/* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */
|
||||||
|
#define WPA_KEY_INFO_KEY_INDEX_MASK (WBIT(4) | WBIT(5))
|
||||||
|
#define WPA_KEY_INFO_KEY_INDEX_SHIFT 4
|
||||||
|
#define WPA_KEY_INFO_INSTALL WBIT(6) /* pairwise */
|
||||||
|
#define WPA_KEY_INFO_TXRX WBIT(6) /* group */
|
||||||
|
#define WPA_KEY_INFO_ACK WBIT(7)
|
||||||
|
#define WPA_KEY_INFO_MIC WBIT(8)
|
||||||
|
#define WPA_KEY_INFO_SECURE WBIT(9)
|
||||||
|
#define WPA_KEY_INFO_ERROR WBIT(10)
|
||||||
|
#define WPA_KEY_INFO_REQUEST WBIT(11)
|
||||||
|
#define WPA_KEY_INFO_ENCR_KEY_DATA WBIT(12) /* IEEE 802.11i/RSN only */
|
||||||
|
|
||||||
|
#define WPA_CAPABILITY_PREAUTH WBIT(0)
|
||||||
|
|
||||||
|
#define GENERIC_INFO_ELEM 0xdd
|
||||||
|
#define RSN_INFO_ELEM 0x30
|
||||||
|
|
||||||
|
enum {
|
||||||
|
REASON_UNSPECIFIED = 1,
|
||||||
|
REASON_DEAUTH_LEAVING = 3,
|
||||||
|
REASON_INVALID_IE = 13,
|
||||||
|
REASON_MICHAEL_MIC_FAILURE = 14,
|
||||||
|
REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
|
||||||
|
REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
|
||||||
|
REASON_IE_IN_4WAY_DIFFERS = 17,
|
||||||
|
REASON_GROUP_CIPHER_NOT_VALID = 18,
|
||||||
|
REASON_PAIRWISE_CIPHER_NOT_VALID = 19,
|
||||||
|
REASON_AKMP_NOT_VALID = 20,
|
||||||
|
REASON_UNSUPPORTED_RSN_IE_VERSION = 21,
|
||||||
|
REASON_INVALID_RSN_IE_CAPAB = 22,
|
||||||
|
REASON_IEEE_802_1X_AUTH_FAILED = 23,
|
||||||
|
REASON_CIPHER_SUITE_REJECTED = 24
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* EAP_PACKET_H */
|
556
package/ks7010/src/ks7010_config.c
Normal file
556
package/ks7010/src/ks7010_config.c
Normal file
@ -0,0 +1,556 @@
|
|||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/mmc/sdio_func.h>
|
||||||
|
|
||||||
|
#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<key_length; i++) {
|
||||||
|
wep_key[i] = value[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wep_key_index < 0 || wep_key_index > 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<key_length; i++) {
|
||||||
|
wep_end[i] = value[i];
|
||||||
|
if (i % 2) {
|
||||||
|
/* Odd */
|
||||||
|
for (j=0x00; j<0x10; j++) {
|
||||||
|
if (j<0x0a) {
|
||||||
|
if (wep_end[i] == j+0x30)
|
||||||
|
wep_end[i] = j;
|
||||||
|
} else {
|
||||||
|
if ((wep_end[i] == j+0x37) | (wep_end[i] == j+0x57))
|
||||||
|
wep_end[i] = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Even */
|
||||||
|
for (j=0x00; j<0x10; j++) {
|
||||||
|
if (j<0x0a) {
|
||||||
|
if (wep_end[i] == j+0x30) {
|
||||||
|
wep_end[i] = j*16;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((wep_end[i] == j+0x37) | (wep_end[i] == j+0x57))
|
||||||
|
wep_end[i] = j*16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<key_length/2; i++) {
|
||||||
|
wep_end[i] = wep_end[i*2] + wep_end[(i*2)+1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wep_key_index < 0 || wep_key_index > 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 <linux/firmware.h>
|
||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
1269
package/ks7010/src/ks7010_sdio.c
Normal file
1269
package/ks7010/src/ks7010_sdio.c
Normal file
File diff suppressed because it is too large
Load Diff
165
package/ks7010/src/ks7010_sdio.h
Normal file
165
package/ks7010/src/ks7010_sdio.h
Normal file
@ -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 */
|
30
package/ks7010/src/ks_debug.c
Normal file
30
package/ks7010/src/ks_debug.c
Normal file
@ -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<length; i++) {
|
||||||
|
if (i % 16 == 0) printk("\n%04X-%04X:", i, i+15);
|
||||||
|
printk(" %02X", *(p+i));
|
||||||
|
}
|
||||||
|
printk("\n");
|
||||||
|
#endif
|
||||||
|
}
|
30
package/ks7010/src/ks_debug.h
Normal file
30
package/ks7010/src/ks_debug.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Driver for KeyStream 11b/g wireless LAN cards.
|
||||||
|
*
|
||||||
|
* ks_debug.h
|
||||||
|
* $Id: ks_debug.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _KS_DEBUG_H
|
||||||
|
#define _KS_DEBUG_H
|
||||||
|
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
|
||||||
|
|
||||||
|
#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 */
|
2655
package/ks7010/src/ks_hostif.c
Normal file
2655
package/ks7010/src/ks_hostif.c
Normal file
File diff suppressed because it is too large
Load Diff
648
package/ks7010/src/ks_hostif.h
Normal file
648
package/ks7010/src/ks_hostif.h
Normal file
@ -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_ */
|
540
package/ks7010/src/ks_wlan.h
Normal file
540
package/ks7010/src/ks_wlan.h
Normal file
@ -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 <linux/version.h>
|
||||||
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
|
||||||
|
#include <linux/config.h>
|
||||||
|
#endif
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
|
||||||
|
#include <linux/spinlock.h> /* spinlock_t */
|
||||||
|
#include <linux/sched.h> /* wait_queue_head_t */
|
||||||
|
#include <linux/types.h> /* pid_t */
|
||||||
|
#include <linux/netdevice.h> /* struct net_device_stats, struct sk_buff */
|
||||||
|
#include <linux/etherdevice.h>
|
||||||
|
#include <linux/wireless.h>
|
||||||
|
#include <asm/atomic.h> /* struct atmic_t */
|
||||||
|
#include <linux/timer.h> /* struct timer_list */
|
||||||
|
#include <linux/string.h>
|
||||||
|
#include <linux/completion.h> /* struct completion */
|
||||||
|
|
||||||
|
#include <asm/io.h>
|
||||||
|
|
||||||
|
/* Workqueue / task queue backwards compatibility stuff */
|
||||||
|
#if ((LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41)) || (defined _MVL31_) || (defined _CELF3_))
|
||||||
|
#include <linux/workqueue.h>
|
||||||
|
#else
|
||||||
|
#include <linux/tqueue.h>
|
||||||
|
#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 <len> 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 <linux/list.h>
|
||||||
|
#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 */
|
69
package/ks7010/src/ks_wlan_ioctl.h
Normal file
69
package/ks7010/src/ks_wlan_ioctl.h
Normal file
@ -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 <linux/wireless.h>
|
||||||
|
/* 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 <linux/netdevice.h>
|
||||||
|
|
||||||
|
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 */
|
3157
package/ks7010/src/ks_wlan_net.c
Normal file
3157
package/ks7010/src/ks_wlan_net.c
Normal file
File diff suppressed because it is too large
Load Diff
143
package/ks7010/src/michael_mic.c
Normal file
143
package/ks7010/src/michael_mic.c
Normal file
@ -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 <linux/types.h>
|
||||||
|
#include <linux/string.h>
|
||||||
|
#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 ) ;
|
||||||
|
}
|
29
package/ks7010/src/michael_mic.h
Normal file
29
package/ks7010/src/michael_mic.h
Normal file
@ -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 );
|
Loading…
Reference in New Issue
Block a user