Skip to content

Commit 13a9930

Browse files
Wolfram Sanggregkh
Wolfram Sang
authored andcommitted
staging: ks7010: add driver from Nanonote extra-repository
See the TODO for details where this driver came from. Only a few minor changes were made to make the driver suitable for staging: * updated Kconfig help text and dependencies * added TODO * removed two __DATE__ and __TIME__ printouts to allow reproducible builds * added to staging main Kconfig + Makefile Tested on a Renesas Salvator-X board with a Spectec SDW-823 card. I could connect to a WPA-protected network. Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e3c9078 commit 13a9930

18 files changed

+9487
-0
lines changed

drivers/staging/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,6 @@ source "drivers/staging/most/Kconfig"
102102

103103
source "drivers/staging/i4l/Kconfig"
104104

105+
source "drivers/staging/ks7010/Kconfig"
106+
105107
endif # STAGING

drivers/staging/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/
4040
obj-$(CONFIG_WILC1000) += wilc1000/
4141
obj-$(CONFIG_MOST) += most/
4242
obj-$(CONFIG_ISDN_I4L) += i4l/
43+
obj-$(CONFIG_KS7010) += ks7010/

drivers/staging/ks7010/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
config KS7010
2+
tristate "KeyStream KS7010 SDIO support"
3+
depends on MMC && WIRELESS
4+
select WIRELESS_EXT
5+
select WEXT_PRIV
6+
help
7+
This is a driver for KeyStream KS7010 based SDIO WIFI cards. It is
8+
found on at least later Spectec SDW-821 (FCC-ID "S2Y-WLAN-11G-K" only,
9+
sadly not FCC-ID "S2Y-WLAN-11B-G") and Spectec SDW-823 microSD cards.

drivers/staging/ks7010/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
obj-$(CONFIG_KS7010) += ks7010.o
2+
3+
ccflags-y += -D_SDIO_ -DKS_WLAN_DEBUG=0
4+
ks7010-y := michael_mic.o ks_hostif.o ks_wlan_net.o ks_debug.o \
5+
ks7010_sdio.o ks7010_config.o

drivers/staging/ks7010/TODO

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
KS7010 Linux driver
2+
===================
3+
4+
This driver is based on source code from the Ben Nanonote extra repository [1]
5+
which is based on the original v007 release from Renesas [2]. Some more
6+
background info about the chipset can be found here [3] and here [4]. Thank
7+
you to all which already participated in cleaning up the driver so far!
8+
9+
[1] http://projects.qi-hardware.com/index.php/p/openwrt-packages/source/tree/master/ks7010/src
10+
[2] http://downloads.qi-hardware.com/software/ks7010_sdio_v007.tar.bz2
11+
[3] http://en.qi-hardware.com/wiki/Ben_NanoNote_Wi-Fi
12+
[4] https://wikidevi.com/wiki/Renesas
13+
14+
TODO
15+
----
16+
17+
First a few words what not to do (at least not blindly):
18+
19+
- don't be overly strict with the 80 char limit. Only if it REALLY makes the
20+
code more readable
21+
- No '#if 0/1' removal unless the surrounding code is understood and removal is
22+
really OK. There might be some hints hidden there.
23+
24+
Now the TODOs:
25+
26+
- fix codechecker warnings (checkpatch, sparse, smatch). But PLEASE make sure
27+
that you are not only silencing the warning but really fixing code. You
28+
should understand the change you submit.
29+
- drop using a config file and use an upstream technique for configuration
30+
- fix the 'card removal' event when card is inserted when booting
31+
- driver crashes when removing the card
32+
- check what other upstream wireless mechanisms can be used instead of the
33+
custom ones here
34+
35+
Please send any patches to:
36+
Greg Kroah-Hartman <[email protected]>
37+
Wolfram Sang <[email protected]>
38+
Linux Driver Project Developer List <[email protected]>

drivers/staging/ks7010/eap_packet.h

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
*
3+
* eap_packet.h
4+
* $Id: eap_packet.h 991 2009-09-14 01:38:58Z sekine $
5+
*
6+
*/
7+
#ifndef EAP_PACKET_H
8+
#define EAP_PACKET_H
9+
10+
#define WBIT(n) (1 << (n))
11+
12+
#ifndef ETH_ALEN
13+
#define ETH_ALEN 6
14+
#endif
15+
16+
struct ether_hdr {
17+
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
18+
unsigned char h_source[ETH_ALEN]; /* source ether addr */
19+
unsigned char h_dest_snap;
20+
unsigned char h_source_snap;
21+
unsigned char h_command;
22+
unsigned char h_vendor_id[3];
23+
unsigned short h_proto; /* packet type ID field */
24+
#define ETHER_PROTOCOL_TYPE_EAP 0x888e
25+
#define ETHER_PROTOCOL_TYPE_IP 0x0800
26+
#define ETHER_PROTOCOL_TYPE_ARP 0x0806
27+
/* followed by length octets of data */
28+
} __attribute__ ((packed));
29+
30+
struct ieee802_1x_hdr {
31+
unsigned char version;
32+
unsigned char type;
33+
unsigned short length;
34+
/* followed by length octets of data */
35+
} __attribute__ ((packed));
36+
37+
#define EAPOL_VERSION 2
38+
39+
enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
40+
IEEE802_1X_TYPE_EAPOL_START = 1,
41+
IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
42+
IEEE802_1X_TYPE_EAPOL_KEY = 3,
43+
IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4
44+
};
45+
46+
enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
47+
EAPOL_KEY_TYPE_WPA = 254 };
48+
49+
50+
#define IEEE8021X_REPLAY_COUNTER_LEN 8
51+
#define IEEE8021X_KEY_SIGN_LEN 16
52+
#define IEEE8021X_KEY_IV_LEN 16
53+
54+
#define IEEE8021X_KEY_INDEX_FLAG 0x80
55+
#define IEEE8021X_KEY_INDEX_MASK 0x03
56+
57+
struct ieee802_1x_eapol_key {
58+
unsigned char type;
59+
unsigned short key_length;
60+
/* does not repeat within the life of the keying material used to
61+
* encrypt the Key field; 64-bit NTP timestamp MAY be used here */
62+
unsigned char replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
63+
unsigned char key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
64+
unsigned char key_index; /* key flag in the most significant bit:
65+
* 0 = broadcast (default key),
66+
* 1 = unicast (key mapping key); key index is in the
67+
* 7 least significant bits */
68+
/* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
69+
* the key */
70+
unsigned char key_signature[IEEE8021X_KEY_SIGN_LEN];
71+
72+
/* followed by key: if packet body length = 44 + key length, then the
73+
* key field (of key_length bytes) contains the key in encrypted form;
74+
* if packet body length = 44, key field is absent and key_length
75+
* represents the number of least significant octets from
76+
* MS-MPPE-Send-Key attribute to be used as the keying material;
77+
* RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
78+
} __attribute__ ((packed));
79+
80+
81+
#define WPA_NONCE_LEN 32
82+
#define WPA_REPLAY_COUNTER_LEN 8
83+
84+
struct wpa_eapol_key {
85+
unsigned char type;
86+
unsigned short key_info;
87+
unsigned short key_length;
88+
unsigned char replay_counter[WPA_REPLAY_COUNTER_LEN];
89+
unsigned char key_nonce[WPA_NONCE_LEN];
90+
unsigned char key_iv[16];
91+
unsigned char key_rsc[8];
92+
unsigned char key_id[8]; /* Reserved in IEEE 802.11i/RSN */
93+
unsigned char key_mic[16];
94+
unsigned short key_data_length;
95+
/* followed by key_data_length bytes of key_data */
96+
} __attribute__ ((packed));
97+
98+
#define WPA_KEY_INFO_TYPE_MASK (WBIT(0) | WBIT(1) | WBIT(2))
99+
#define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 WBIT(0)
100+
#define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES WBIT(1)
101+
#define WPA_KEY_INFO_KEY_TYPE WBIT(3) /* 1 = Pairwise, 0 = Group key */
102+
/* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */
103+
#define WPA_KEY_INFO_KEY_INDEX_MASK (WBIT(4) | WBIT(5))
104+
#define WPA_KEY_INFO_KEY_INDEX_SHIFT 4
105+
#define WPA_KEY_INFO_INSTALL WBIT(6) /* pairwise */
106+
#define WPA_KEY_INFO_TXRX WBIT(6) /* group */
107+
#define WPA_KEY_INFO_ACK WBIT(7)
108+
#define WPA_KEY_INFO_MIC WBIT(8)
109+
#define WPA_KEY_INFO_SECURE WBIT(9)
110+
#define WPA_KEY_INFO_ERROR WBIT(10)
111+
#define WPA_KEY_INFO_REQUEST WBIT(11)
112+
#define WPA_KEY_INFO_ENCR_KEY_DATA WBIT(12) /* IEEE 802.11i/RSN only */
113+
114+
#define WPA_CAPABILITY_PREAUTH WBIT(0)
115+
116+
#define GENERIC_INFO_ELEM 0xdd
117+
#define RSN_INFO_ELEM 0x30
118+
119+
enum {
120+
REASON_UNSPECIFIED = 1,
121+
REASON_DEAUTH_LEAVING = 3,
122+
REASON_INVALID_IE = 13,
123+
REASON_MICHAEL_MIC_FAILURE = 14,
124+
REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
125+
REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
126+
REASON_IE_IN_4WAY_DIFFERS = 17,
127+
REASON_GROUP_CIPHER_NOT_VALID = 18,
128+
REASON_PAIRWISE_CIPHER_NOT_VALID = 19,
129+
REASON_AKMP_NOT_VALID = 20,
130+
REASON_UNSUPPORTED_RSN_IE_VERSION = 21,
131+
REASON_INVALID_RSN_IE_CAPAB = 22,
132+
REASON_IEEE_802_1X_AUTH_FAILED = 23,
133+
REASON_CIPHER_SUITE_REJECTED = 24
134+
};
135+
136+
#endif /* EAP_PACKET_H */

0 commit comments

Comments
 (0)