diff options
Diffstat (limited to 'drivers/staging/vt6656')
-rw-r--r-- | drivers/staging/vt6656/ioctl.c | 704 | ||||
-rw-r--r-- | drivers/staging/vt6656/ioctl.h | 54 | ||||
-rw-r--r-- | drivers/staging/vt6656/upc.h | 162 |
3 files changed, 920 insertions, 0 deletions
diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c new file mode 100644 index 00000000000..cfe9c95d780 --- /dev/null +++ b/drivers/staging/vt6656/ioctl.c | |||
@@ -0,0 +1,704 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | * | ||
19 | * File: ioctl.c | ||
20 | * | ||
21 | * Purpose: private ioctl functions | ||
22 | * | ||
23 | * Author: Lyndon Chen | ||
24 | * | ||
25 | * Date: Auguest 20, 2003 | ||
26 | * | ||
27 | * Functions: | ||
28 | * | ||
29 | * Revision History: | ||
30 | * | ||
31 | */ | ||
32 | |||
33 | #include "ioctl.h" | ||
34 | #include "iocmd.h" | ||
35 | #include "mac.h" | ||
36 | #include "card.h" | ||
37 | #include "hostap.h" | ||
38 | #include "wpactl.h" | ||
39 | #include "control.h" | ||
40 | #include "rndis.h" | ||
41 | #include "rf.h" | ||
42 | |||
43 | /*--------------------- Static Definitions -------------------------*/ | ||
44 | |||
45 | /*--------------------- Static Classes ----------------------------*/ | ||
46 | |||
47 | /*--------------------- Static Variables --------------------------*/ | ||
48 | //static int msglevel =MSG_LEVEL_DEBUG; | ||
49 | static int msglevel =MSG_LEVEL_INFO; | ||
50 | |||
51 | SWPAResult wpa_Result; | ||
52 | |||
53 | /*--------------------- Static Functions --------------------------*/ | ||
54 | |||
55 | /*--------------------- Export Variables --------------------------*/ | ||
56 | |||
57 | int private_ioctl(PSDevice pDevice, struct ifreq *rq) { | ||
58 | |||
59 | PSCmdRequest pReq = (PSCmdRequest)rq; | ||
60 | PSMgmtObject pMgmt = &(pDevice->sMgmtObj); | ||
61 | int result = 0; | ||
62 | PWLAN_IE_SSID pItemSSID; | ||
63 | SCmdBSSJoin sJoinCmd; | ||
64 | SCmdZoneTypeSet sZoneTypeCmd; | ||
65 | SCmdScan sScanCmd; | ||
66 | SCmdStartAP sStartAPCmd; | ||
67 | SCmdSetWEP sWEPCmd; | ||
68 | SCmdValue sValue; | ||
69 | SBSSIDList sList; | ||
70 | SNodeList sNodeList; | ||
71 | PSBSSIDList pList; | ||
72 | PSNodeList pNodeList; | ||
73 | unsigned int cbListCount; | ||
74 | PKnownBSS pBSS; | ||
75 | PKnownNodeDB pNode; | ||
76 | unsigned int ii, jj; | ||
77 | SCmdLinkStatus sLinkStatus; | ||
78 | BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; | ||
79 | BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | ||
80 | DWORD dwKeyIndex= 0; | ||
81 | BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; | ||
82 | signed long ldBm; | ||
83 | |||
84 | pReq->wResult = 0; | ||
85 | |||
86 | switch(pReq->wCmdCode) { | ||
87 | |||
88 | case WLAN_CMD_BSS_SCAN: | ||
89 | |||
90 | if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) { | ||
91 | result = -EFAULT; | ||
92 | break; | ||
93 | } | ||
94 | |||
95 | pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; | ||
96 | if (pItemSSID->len != 0) { | ||
97 | memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); | ||
98 | memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); | ||
99 | } | ||
100 | spin_lock_irq(&pDevice->lock); | ||
101 | |||
102 | if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0) | ||
103 | BSSvClearBSSList((void *) pDevice, FALSE); | ||
104 | else | ||
105 | BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); | ||
106 | |||
107 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n"); | ||
108 | |||
109 | if (pItemSSID->len != 0) | ||
110 | bScheduleCommand((void *) pDevice, | ||
111 | WLAN_CMD_BSSID_SCAN, | ||
112 | abyScanSSID); | ||
113 | else | ||
114 | bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); | ||
115 | |||
116 | spin_unlock_irq(&pDevice->lock); | ||
117 | break; | ||
118 | |||
119 | case WLAN_CMD_ZONETYPE_SET: | ||
120 | //mike add :cann't support. | ||
121 | result=-EOPNOTSUPP; | ||
122 | break; | ||
123 | |||
124 | if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) { | ||
125 | result = -EFAULT; | ||
126 | break; | ||
127 | } | ||
128 | |||
129 | if(sZoneTypeCmd.bWrite==TRUE) { | ||
130 | //////write zonetype | ||
131 | if(sZoneTypeCmd.ZoneType == ZoneType_USA) { | ||
132 | //set to USA | ||
133 | printk("set_ZoneType:USA\n"); | ||
134 | } | ||
135 | else if(sZoneTypeCmd.ZoneType == ZoneType_Japan) { | ||
136 | //set to Japan | ||
137 | printk("set_ZoneType:Japan\n"); | ||
138 | } | ||
139 | else if(sZoneTypeCmd.ZoneType == ZoneType_Europe) { | ||
140 | //set to Europe | ||
141 | printk("set_ZoneType:Europe\n"); | ||
142 | } | ||
143 | } | ||
144 | else { | ||
145 | ///////read zonetype | ||
146 | BYTE zonetype=0; | ||
147 | |||
148 | |||
149 | if(zonetype == 0x00) { //USA | ||
150 | sZoneTypeCmd.ZoneType = ZoneType_USA; | ||
151 | } | ||
152 | else if(zonetype == 0x01) { //Japan | ||
153 | sZoneTypeCmd.ZoneType = ZoneType_Japan; | ||
154 | } | ||
155 | else if(zonetype == 0x02) { //Europe | ||
156 | sZoneTypeCmd.ZoneType = ZoneType_Europe; | ||
157 | } | ||
158 | else { //Unknown ZoneType | ||
159 | printk("Error:ZoneType[%x] Unknown ???\n",zonetype); | ||
160 | result = -EFAULT; | ||
161 | break; | ||
162 | } | ||
163 | if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) { | ||
164 | result = -EFAULT; | ||
165 | break; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | break; | ||
170 | |||
171 | case WLAN_CMD_BSS_JOIN: | ||
172 | |||
173 | if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) { | ||
174 | result = -EFAULT; | ||
175 | break; | ||
176 | } | ||
177 | |||
178 | pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; | ||
179 | memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); | ||
180 | memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); | ||
181 | if (sJoinCmd.wBSSType == ADHOC) { | ||
182 | pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; | ||
183 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n"); | ||
184 | } | ||
185 | else { | ||
186 | pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; | ||
187 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n"); | ||
188 | } | ||
189 | if (sJoinCmd.bPSEnable == TRUE) { | ||
190 | pDevice->ePSMode = WMAC_POWER_FAST; | ||
191 | // pDevice->ePSMode = WMAC_POWER_MAX; | ||
192 | pMgmt->wListenInterval = 2; | ||
193 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n"); | ||
194 | } | ||
195 | else { | ||
196 | pDevice->ePSMode = WMAC_POWER_CAM; | ||
197 | pMgmt->wListenInterval = 1; | ||
198 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n"); | ||
199 | } | ||
200 | |||
201 | if (sJoinCmd.bShareKeyAuth == TRUE){ | ||
202 | pMgmt->bShareKeyAlgorithm = TRUE; | ||
203 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n"); | ||
204 | } | ||
205 | else { | ||
206 | pMgmt->bShareKeyAlgorithm = FALSE; | ||
207 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n"); | ||
208 | } | ||
209 | pDevice->uChannel = sJoinCmd.uChannel; | ||
210 | netif_stop_queue(pDevice->dev); | ||
211 | spin_lock_irq(&pDevice->lock); | ||
212 | pMgmt->eCurrState = WMAC_STATE_IDLE; | ||
213 | bScheduleCommand((void *) pDevice, | ||
214 | WLAN_CMD_BSSID_SCAN, | ||
215 | pMgmt->abyDesireSSID); | ||
216 | bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); | ||
217 | spin_unlock_irq(&pDevice->lock); | ||
218 | break; | ||
219 | |||
220 | case WLAN_CMD_SET_WEP: | ||
221 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key. \n"); | ||
222 | memset(&sWEPCmd, 0 ,sizeof(SCmdSetWEP)); | ||
223 | if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) { | ||
224 | result = -EFAULT; | ||
225 | break; | ||
226 | } | ||
227 | if (sWEPCmd.bEnableWep != TRUE) { | ||
228 | int uu; | ||
229 | |||
230 | pDevice->bEncryptionEnable = FALSE; | ||
231 | pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; | ||
232 | spin_lock_irq(&pDevice->lock); | ||
233 | for (uu = 0; uu < MAX_KEY_TABLE; uu++) | ||
234 | MACvDisableKeyEntry(pDevice, uu); | ||
235 | spin_unlock_irq(&pDevice->lock); | ||
236 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n"); | ||
237 | break; | ||
238 | } | ||
239 | |||
240 | for (ii = 0; ii < WLAN_WEP_NKEYS; ii ++) { | ||
241 | if (sWEPCmd.bWepKeyAvailable[ii]) { | ||
242 | if (ii == sWEPCmd.byKeyIndex) | ||
243 | //2006-1207-01<Modify>by Einsn Liu | ||
244 | // dwKeyIndex|= (1 << 31); | ||
245 | dwKeyIndex=ii|(1 << 31); | ||
246 | else | ||
247 | dwKeyIndex = ii; | ||
248 | spin_lock_irq(&pDevice->lock); | ||
249 | KeybSetDefaultKey( pDevice, | ||
250 | &(pDevice->sKey), | ||
251 | dwKeyIndex, | ||
252 | sWEPCmd.auWepKeyLength[ii], | ||
253 | NULL, | ||
254 | (PBYTE)&sWEPCmd.abyWepKey[ii][0], | ||
255 | KEY_CTL_WEP | ||
256 | ); | ||
257 | spin_unlock_irq(&pDevice->lock); | ||
258 | |||
259 | } | ||
260 | } | ||
261 | pDevice->byKeyIndex = sWEPCmd.byKeyIndex; | ||
262 | pDevice->bTransmitKey = TRUE; | ||
263 | pDevice->bEncryptionEnable = TRUE; | ||
264 | pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; | ||
265 | |||
266 | break; | ||
267 | |||
268 | case WLAN_CMD_GET_LINK: | ||
269 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status. \n"); | ||
270 | |||
271 | memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1); | ||
272 | |||
273 | if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) | ||
274 | sLinkStatus.wBSSType = ADHOC; | ||
275 | else | ||
276 | sLinkStatus.wBSSType = INFRA; | ||
277 | |||
278 | if (pMgmt->eCurrState == WMAC_STATE_JOINTED) | ||
279 | sLinkStatus.byState = ADHOC_JOINTED; | ||
280 | else | ||
281 | sLinkStatus.byState = ADHOC_STARTED; | ||
282 | |||
283 | sLinkStatus.uChannel = pMgmt->uCurrChannel; | ||
284 | if (pDevice->bLinkPass == TRUE) { | ||
285 | sLinkStatus.bLink = TRUE; | ||
286 | pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; | ||
287 | memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len); | ||
288 | memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); | ||
289 | sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate; | ||
290 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success ! \n"); | ||
291 | } | ||
292 | else { | ||
293 | sLinkStatus.bLink = FALSE; | ||
294 | } | ||
295 | if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) { | ||
296 | result = -EFAULT; | ||
297 | break; | ||
298 | } | ||
299 | |||
300 | break; | ||
301 | |||
302 | case WLAN_CMD_GET_LISTLEN: | ||
303 | cbListCount = 0; | ||
304 | pBSS = &(pMgmt->sBSSList[0]); | ||
305 | for (ii = 0; ii < MAX_BSS_NUM; ii++) { | ||
306 | pBSS = &(pMgmt->sBSSList[ii]); | ||
307 | if (!pBSS->bActive) | ||
308 | continue; | ||
309 | cbListCount++; | ||
310 | } | ||
311 | sList.uItem = cbListCount; | ||
312 | if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) { | ||
313 | result = -EFAULT; | ||
314 | break; | ||
315 | } | ||
316 | pReq->wResult = 0; | ||
317 | break; | ||
318 | |||
319 | case WLAN_CMD_GET_LIST: | ||
320 | if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) { | ||
321 | result = -EFAULT; | ||
322 | break; | ||
323 | } | ||
324 | pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC); | ||
325 | if (pList == NULL) { | ||
326 | result = -ENOMEM; | ||
327 | break; | ||
328 | } | ||
329 | pList->uItem = sList.uItem; | ||
330 | pBSS = &(pMgmt->sBSSList[0]); | ||
331 | for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) { | ||
332 | pBSS = &(pMgmt->sBSSList[jj]); | ||
333 | if (pBSS->bActive) { | ||
334 | pList->sBSSIDList[ii].uChannel = pBSS->uChannel; | ||
335 | pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval; | ||
336 | pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; | ||
337 | RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm); | ||
338 | pList->sBSSIDList[ii].uRSSI = (unsigned int) ldBm; | ||
339 | // pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; | ||
340 | memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); | ||
341 | pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; | ||
342 | memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1); | ||
343 | memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len); | ||
344 | if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) { | ||
345 | pList->sBSSIDList[ii].byNetType = INFRA; | ||
346 | } | ||
347 | else { | ||
348 | pList->sBSSIDList[ii].byNetType = ADHOC; | ||
349 | } | ||
350 | if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) { | ||
351 | pList->sBSSIDList[ii].bWEPOn = TRUE; | ||
352 | } | ||
353 | else { | ||
354 | pList->sBSSIDList[ii].bWEPOn = FALSE; | ||
355 | } | ||
356 | ii ++; | ||
357 | if (ii >= pList->uItem) | ||
358 | break; | ||
359 | } | ||
360 | } | ||
361 | |||
362 | if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) { | ||
363 | result = -EFAULT; | ||
364 | break; | ||
365 | } | ||
366 | kfree(pList); | ||
367 | pReq->wResult = 0; | ||
368 | break; | ||
369 | |||
370 | case WLAN_CMD_GET_MIB: | ||
371 | if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) { | ||
372 | result = -EFAULT; | ||
373 | break; | ||
374 | } | ||
375 | break; | ||
376 | |||
377 | case WLAN_CMD_GET_STAT: | ||
378 | if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) { | ||
379 | result = -EFAULT; | ||
380 | break; | ||
381 | } | ||
382 | break; | ||
383 | case WLAN_CMD_STOP_MAC: | ||
384 | |||
385 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n"); | ||
386 | // Todo xxxxxx | ||
387 | netif_stop_queue(pDevice->dev); | ||
388 | spin_lock_irq(&pDevice->lock); | ||
389 | if (pDevice->bRadioOff == FALSE) { | ||
390 | CARDbRadioPowerOff(pDevice); | ||
391 | } | ||
392 | pDevice->bLinkPass = FALSE; | ||
393 | ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); | ||
394 | memset(pMgmt->abyCurrBSSID, 0, 6); | ||
395 | pMgmt->eCurrState = WMAC_STATE_IDLE; | ||
396 | // del_timer(&pDevice->sTimerCommand); | ||
397 | // del_timer(&pMgmt->sTimerSecondCallback); | ||
398 | pDevice->bCmdRunning = FALSE; | ||
399 | spin_unlock_irq(&pDevice->lock); | ||
400 | |||
401 | break; | ||
402 | |||
403 | case WLAN_CMD_START_MAC: | ||
404 | |||
405 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n"); | ||
406 | // Todo xxxxxxx | ||
407 | if (pDevice->bRadioOff == TRUE) | ||
408 | CARDbRadioPowerOn(pDevice); | ||
409 | break; | ||
410 | |||
411 | case WLAN_CMD_SET_HOSTAPD: | ||
412 | |||
413 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n"); | ||
414 | |||
415 | if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { | ||
416 | result = -EFAULT; | ||
417 | break; | ||
418 | } | ||
419 | if (sValue.dwValue == 1) { | ||
420 | if (vt6656_hostap_set_hostapd(pDevice, 1, 1) == 0){ | ||
421 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n"); | ||
422 | } | ||
423 | else { | ||
424 | result = -EFAULT; | ||
425 | break; | ||
426 | } | ||
427 | } | ||
428 | else { | ||
429 | vt6656_hostap_set_hostapd(pDevice, 0, 1); | ||
430 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n"); | ||
431 | } | ||
432 | |||
433 | break; | ||
434 | |||
435 | case WLAN_CMD_SET_HOSTAPD_STA: | ||
436 | |||
437 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n"); | ||
438 | |||
439 | break; | ||
440 | case WLAN_CMD_SET_802_1X: | ||
441 | |||
442 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n"); | ||
443 | if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { | ||
444 | result = -EFAULT; | ||
445 | break; | ||
446 | } | ||
447 | |||
448 | if (sValue.dwValue == 1) { | ||
449 | pDevice->bEnable8021x = TRUE; | ||
450 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n"); | ||
451 | } | ||
452 | else { | ||
453 | pDevice->bEnable8021x = FALSE; | ||
454 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n"); | ||
455 | } | ||
456 | |||
457 | break; | ||
458 | |||
459 | |||
460 | case WLAN_CMD_SET_HOST_WEP: | ||
461 | |||
462 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n"); | ||
463 | if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { | ||
464 | result = -EFAULT; | ||
465 | break; | ||
466 | } | ||
467 | |||
468 | if (sValue.dwValue == 1) { | ||
469 | pDevice->bEnableHostWEP = TRUE; | ||
470 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n"); | ||
471 | } | ||
472 | else { | ||
473 | pDevice->bEnableHostWEP = FALSE; | ||
474 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n"); | ||
475 | } | ||
476 | |||
477 | break; | ||
478 | |||
479 | case WLAN_CMD_SET_WPA: | ||
480 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n"); | ||
481 | |||
482 | if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { | ||
483 | result = -EFAULT; | ||
484 | break; | ||
485 | } | ||
486 | if (sValue.dwValue == 1) { | ||
487 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n"); | ||
488 | memcpy(pDevice->wpadev->dev_addr, | ||
489 | pDevice->dev->dev_addr, | ||
490 | ETH_ALEN); | ||
491 | pDevice->bWPADEVUp = TRUE; | ||
492 | } | ||
493 | else { | ||
494 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n"); | ||
495 | pDevice->bWPADEVUp = FALSE; | ||
496 | } | ||
497 | |||
498 | break; | ||
499 | |||
500 | case WLAN_CMD_AP_START: | ||
501 | |||
502 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n"); | ||
503 | if (pDevice->bRadioOff == TRUE) { | ||
504 | CARDbRadioPowerOn(pDevice); | ||
505 | add_timer(&pMgmt->sTimerSecondCallback); | ||
506 | } | ||
507 | if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) { | ||
508 | result = -EFAULT; | ||
509 | break; | ||
510 | } | ||
511 | |||
512 | if (sStartAPCmd.wBSSType == AP) { | ||
513 | pMgmt->eConfigMode = WMAC_CONFIG_AP; | ||
514 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n"); | ||
515 | } | ||
516 | else { | ||
517 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n"); | ||
518 | result = -EFAULT; | ||
519 | break; | ||
520 | } | ||
521 | |||
522 | |||
523 | if (sStartAPCmd.wBBPType == PHY80211g) { | ||
524 | pMgmt->byAPBBType = PHY_TYPE_11G; | ||
525 | } | ||
526 | else if (sStartAPCmd.wBBPType == PHY80211a) { | ||
527 | pMgmt->byAPBBType = PHY_TYPE_11A; | ||
528 | } | ||
529 | else { | ||
530 | pMgmt->byAPBBType = PHY_TYPE_11B; | ||
531 | } | ||
532 | |||
533 | pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; | ||
534 | memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); | ||
535 | memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); | ||
536 | |||
537 | if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14)) | ||
538 | pDevice->uChannel = sStartAPCmd.uChannel; | ||
539 | |||
540 | if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000)) | ||
541 | pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt; | ||
542 | else | ||
543 | pMgmt->wIBSSBeaconPeriod = 100; | ||
544 | |||
545 | if (sStartAPCmd.bShareKeyAuth == TRUE){ | ||
546 | pMgmt->bShareKeyAlgorithm = TRUE; | ||
547 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n"); | ||
548 | } | ||
549 | else { | ||
550 | pMgmt->bShareKeyAlgorithm = FALSE; | ||
551 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n"); | ||
552 | } | ||
553 | memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6); | ||
554 | |||
555 | if (sStartAPCmd.byBasicRate & BIT3) { | ||
556 | pMgmt->abyIBSSSuppRates[2] |= BIT7; | ||
557 | pMgmt->abyIBSSSuppRates[3] |= BIT7; | ||
558 | pMgmt->abyIBSSSuppRates[4] |= BIT7; | ||
559 | pMgmt->abyIBSSSuppRates[5] |= BIT7; | ||
560 | }else if (sStartAPCmd.byBasicRate & BIT2) { | ||
561 | pMgmt->abyIBSSSuppRates[2] |= BIT7; | ||
562 | pMgmt->abyIBSSSuppRates[3] |= BIT7; | ||
563 | pMgmt->abyIBSSSuppRates[4] |= BIT7; | ||
564 | }else if (sStartAPCmd.byBasicRate & BIT1) { | ||
565 | pMgmt->abyIBSSSuppRates[2] |= BIT7; | ||
566 | pMgmt->abyIBSSSuppRates[3] |= BIT7; | ||
567 | }else if (sStartAPCmd.byBasicRate & BIT1) { | ||
568 | pMgmt->abyIBSSSuppRates[2] |= BIT7; | ||
569 | }else { | ||
570 | //default 1,2M | ||
571 | pMgmt->abyIBSSSuppRates[2] |= BIT7; | ||
572 | pMgmt->abyIBSSSuppRates[3] |= BIT7; | ||
573 | } | ||
574 | |||
575 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n", | ||
576 | pMgmt->abyIBSSSuppRates[2], | ||
577 | pMgmt->abyIBSSSuppRates[3], | ||
578 | pMgmt->abyIBSSSuppRates[4], | ||
579 | pMgmt->abyIBSSSuppRates[5] | ||
580 | ); | ||
581 | |||
582 | netif_stop_queue(pDevice->dev); | ||
583 | spin_lock_irq(&pDevice->lock); | ||
584 | bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL); | ||
585 | spin_unlock_irq(&pDevice->lock); | ||
586 | break; | ||
587 | |||
588 | case WLAN_CMD_GET_NODE_CNT: | ||
589 | |||
590 | cbListCount = 0; | ||
591 | pNode = &(pMgmt->sNodeDBTable[0]); | ||
592 | for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { | ||
593 | pNode = &(pMgmt->sNodeDBTable[ii]); | ||
594 | if (!pNode->bActive) | ||
595 | continue; | ||
596 | cbListCount++; | ||
597 | } | ||
598 | |||
599 | sNodeList.uItem = cbListCount; | ||
600 | if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) { | ||
601 | result = -EFAULT; | ||
602 | break; | ||
603 | } | ||
604 | pReq->wResult = 0; | ||
605 | break; | ||
606 | |||
607 | case WLAN_CMD_GET_NODE_LIST: | ||
608 | |||
609 | if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) { | ||
610 | result = -EFAULT; | ||
611 | break; | ||
612 | } | ||
613 | pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); | ||
614 | if (pNodeList == NULL) { | ||
615 | result = -ENOMEM; | ||
616 | break; | ||
617 | } | ||
618 | pNodeList->uItem = sNodeList.uItem; | ||
619 | pNode = &(pMgmt->sNodeDBTable[0]); | ||
620 | for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) { | ||
621 | pNode = &(pMgmt->sNodeDBTable[ii]); | ||
622 | if (pNode->bActive) { | ||
623 | pNodeList->sNodeList[jj].wAID = pNode->wAID; | ||
624 | memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN); | ||
625 | pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate; | ||
626 | pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount; | ||
627 | pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt; | ||
628 | pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags; | ||
629 | pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable; | ||
630 | pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex; | ||
631 | pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength; | ||
632 | memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN); | ||
633 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", | ||
634 | pNodeList->sNodeList[jj].abyWepKey[0], | ||
635 | pNodeList->sNodeList[jj].abyWepKey[1], | ||
636 | pNodeList->sNodeList[jj].abyWepKey[2], | ||
637 | pNodeList->sNodeList[jj].abyWepKey[3], | ||
638 | pNodeList->sNodeList[jj].abyWepKey[4] | ||
639 | ); | ||
640 | pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback; | ||
641 | pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures; | ||
642 | pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts; | ||
643 | pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio; | ||
644 | jj ++; | ||
645 | if (jj >= pNodeList->uItem) | ||
646 | break; | ||
647 | } | ||
648 | } | ||
649 | if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { | ||
650 | result = -EFAULT; | ||
651 | break; | ||
652 | } | ||
653 | kfree(pNodeList); | ||
654 | pReq->wResult = 0; | ||
655 | break; | ||
656 | |||
657 | case 0xFF: | ||
658 | memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname)); | ||
659 | wpa_Result.proto = 0; | ||
660 | wpa_Result.key_mgmt = 0; | ||
661 | wpa_Result.eap_type = 0; | ||
662 | wpa_Result.authenticated = FALSE; | ||
663 | pDevice->fWPA_Authened = FALSE; | ||
664 | if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) { | ||
665 | result = -EFAULT; | ||
666 | break; | ||
667 | } | ||
668 | //DavidWang for some AP maybe good authenticate | ||
669 | if(wpa_Result.key_mgmt==0x20) | ||
670 | pMgmt->Cisco_cckm =1; | ||
671 | else | ||
672 | pMgmt->Cisco_cckm =0; | ||
673 | |||
674 | |||
675 | if(wpa_Result.authenticated==TRUE) { | ||
676 | { | ||
677 | union iwreq_data wrqu; | ||
678 | |||
679 | pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; | ||
680 | |||
681 | memset(&wrqu, 0, sizeof(wrqu)); | ||
682 | wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG; | ||
683 | wrqu.data.length =pItemSSID->len; | ||
684 | wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID); | ||
685 | } | ||
686 | pDevice->fWPA_Authened = TRUE; //is successful peer to wpa_Result.authenticated? | ||
687 | } | ||
688 | |||
689 | //printk("get private wpa_supplicant announce WPA SM\n"); | ||
690 | //printk("wpa-->ifname=%s\n",wpa_Result.ifname); | ||
691 | //printk("wpa-->proto=%d\n",wpa_Result.proto); | ||
692 | //printk("wpa-->key-mgmt=%d\n",wpa_Result.key_mgmt); | ||
693 | //printk("wpa-->eap_type=%d\n",wpa_Result.eap_type); | ||
694 | //printk("wpa-->authenticated is %s\n",(wpa_Result.authenticated==TRUE)?"TRUE":"FALSE"); | ||
695 | |||
696 | pReq->wResult = 0; | ||
697 | break; | ||
698 | |||
699 | default: | ||
700 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n"); | ||
701 | } | ||
702 | |||
703 | return result; | ||
704 | } | ||
diff --git a/drivers/staging/vt6656/ioctl.h b/drivers/staging/vt6656/ioctl.h new file mode 100644 index 00000000000..caa4ac963d9 --- /dev/null +++ b/drivers/staging/vt6656/ioctl.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | * | ||
19 | * File: hostap.h | ||
20 | * | ||
21 | * Purpose: | ||
22 | * | ||
23 | * Author: Lyndon Chen | ||
24 | * | ||
25 | * Date: May 21, 2003 | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | #ifndef __IOCTL_H__ | ||
30 | #define __IOCTL_H__ | ||
31 | |||
32 | #include "device.h" | ||
33 | |||
34 | /*--------------------- Export Definitions -------------------------*/ | ||
35 | |||
36 | |||
37 | /*--------------------- Export Classes ----------------------------*/ | ||
38 | |||
39 | /*--------------------- Export Variables --------------------------*/ | ||
40 | |||
41 | /*--------------------- Export Functions --------------------------*/ | ||
42 | |||
43 | int private_ioctl(PSDevice pDevice, struct ifreq *rq); | ||
44 | |||
45 | /* | ||
46 | void vConfigWEPKey ( | ||
47 | PSDevice pDevice, | ||
48 | DWORD dwKeyIndex, | ||
49 | PBYTE pbyKey, | ||
50 | unsigned long uKeyLength | ||
51 | ); | ||
52 | */ | ||
53 | |||
54 | #endif /* __IOCTL_H__ */ | ||
diff --git a/drivers/staging/vt6656/upc.h b/drivers/staging/vt6656/upc.h new file mode 100644 index 00000000000..b33aba4b12c --- /dev/null +++ b/drivers/staging/vt6656/upc.h | |||
@@ -0,0 +1,162 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | * | ||
19 | * File: upc.h | ||
20 | * | ||
21 | * Purpose: Macros to access device | ||
22 | * | ||
23 | * Author: Tevin Chen | ||
24 | * | ||
25 | * Date: Mar 17, 1997 | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | #ifndef __UPC_H__ | ||
30 | #define __UPC_H__ | ||
31 | |||
32 | #include "device.h" | ||
33 | #include "ttype.h" | ||
34 | |||
35 | /*--------------------- Export Definitions -------------------------*/ | ||
36 | |||
37 | |||
38 | // | ||
39 | // For IO mapped | ||
40 | // | ||
41 | |||
42 | #ifdef IO_MAP | ||
43 | |||
44 | #define VNSvInPortB(dwIOAddress, pbyData) { \ | ||
45 | *(pbyData) = inb(dwIOAddress); \ | ||
46 | } | ||
47 | |||
48 | |||
49 | #define VNSvInPortW(dwIOAddress, pwData) { \ | ||
50 | *(pwData) = inw(dwIOAddress); \ | ||
51 | } | ||
52 | |||
53 | #define VNSvInPortD(dwIOAddress, pdwData) { \ | ||
54 | *(pdwData) = inl(dwIOAddress); \ | ||
55 | } | ||
56 | |||
57 | |||
58 | #define VNSvOutPortB(dwIOAddress, byData) { \ | ||
59 | outb(byData, dwIOAddress); \ | ||
60 | } | ||
61 | |||
62 | |||
63 | #define VNSvOutPortW(dwIOAddress, wData) { \ | ||
64 | outw(wData, dwIOAddress); \ | ||
65 | } | ||
66 | |||
67 | #define VNSvOutPortD(dwIOAddress, dwData) { \ | ||
68 | outl(dwData, dwIOAddress); \ | ||
69 | } | ||
70 | |||
71 | #else | ||
72 | |||
73 | // | ||
74 | // For memory mapped IO | ||
75 | // | ||
76 | |||
77 | |||
78 | #define VNSvInPortB(dwIOAddress, pbyData) { \ | ||
79 | volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \ | ||
80 | *(pbyData) = readb(pbyAddr); \ | ||
81 | } | ||
82 | |||
83 | |||
84 | #define VNSvInPortW(dwIOAddress, pwData) { \ | ||
85 | volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \ | ||
86 | *(pwData) = readw(pwAddr); \ | ||
87 | } | ||
88 | |||
89 | #define VNSvInPortD(dwIOAddress, pdwData) { \ | ||
90 | volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \ | ||
91 | *(pdwData) = readl(pdwAddr); \ | ||
92 | } | ||
93 | |||
94 | |||
95 | #define VNSvOutPortB(dwIOAddress, byData) { \ | ||
96 | volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \ | ||
97 | writeb((BYTE)byData, pbyAddr); \ | ||
98 | } | ||
99 | |||
100 | |||
101 | #define VNSvOutPortW(dwIOAddress, wData) { \ | ||
102 | volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \ | ||
103 | writew((WORD)wData, pwAddr); \ | ||
104 | } | ||
105 | |||
106 | #define VNSvOutPortD(dwIOAddress, dwData) { \ | ||
107 | volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \ | ||
108 | writel((DWORD)dwData, pdwAddr); \ | ||
109 | } | ||
110 | |||
111 | #endif | ||
112 | |||
113 | |||
114 | // | ||
115 | // ALWAYS IO-Mapped IO when in 16-bit/32-bit environment | ||
116 | // | ||
117 | #define PCBvInPortB(dwIOAddress, pbyData) { \ | ||
118 | *(pbyData) = inb(dwIOAddress); \ | ||
119 | } | ||
120 | |||
121 | #define PCBvInPortW(dwIOAddress, pwData) { \ | ||
122 | *(pwData) = inw(dwIOAddress); \ | ||
123 | } | ||
124 | |||
125 | #define PCBvInPortD(dwIOAddress, pdwData) { \ | ||
126 | *(pdwData) = inl(dwIOAddress); \ | ||
127 | } | ||
128 | |||
129 | #define PCBvOutPortB(dwIOAddress, byData) { \ | ||
130 | outb(byData, dwIOAddress); \ | ||
131 | } | ||
132 | |||
133 | #define PCBvOutPortW(dwIOAddress, wData) { \ | ||
134 | outw(wData, dwIOAddress); \ | ||
135 | } | ||
136 | |||
137 | #define PCBvOutPortD(dwIOAddress, dwData) { \ | ||
138 | outl(dwData, dwIOAddress); \ | ||
139 | } | ||
140 | |||
141 | |||
142 | #define PCAvDelayByIO(uDelayUnit) { \ | ||
143 | BYTE byData; \ | ||
144 | unsigned long ii; \ | ||
145 | \ | ||
146 | if (uDelayUnit <= 50) { \ | ||
147 | udelay(uDelayUnit); \ | ||
148 | } \ | ||
149 | else { \ | ||
150 | for (ii = 0; ii < (uDelayUnit); ii++) \ | ||
151 | byData = inb(0x61); \ | ||
152 | } \ | ||
153 | } | ||
154 | |||
155 | |||
156 | /*--------------------- Export Classes ----------------------------*/ | ||
157 | |||
158 | /*--------------------- Export Variables --------------------------*/ | ||
159 | |||
160 | /*--------------------- Export Functions --------------------------*/ | ||
161 | |||
162 | #endif /* __UPC_H__ */ | ||