Merge branch 'ib-mfd-iio-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/lee...
[firefly-linux-kernel-4.4.55.git] / drivers / staging / vt6655 / iocmd.h
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: iocmd.h
20  *
21  * Purpose: Handles the viawget ioctl private interface functions
22  *
23  * Author: Lyndon Chen
24  *
25  * Date: May 8, 2002
26  *
27  */
28
29 #ifndef __IOCMD_H__
30 #define __IOCMD_H__
31
32 #include "ttype.h"
33
34 // ioctl Command code
35 #define MAGIC_CODE                       0x3142
36 #define IOCTL_CMD_TEST              (SIOCDEVPRIVATE + 0)
37 #define IOCTL_CMD_SET                       (SIOCDEVPRIVATE + 1)
38 #define IOCTL_CMD_HOSTAPD           (SIOCDEVPRIVATE + 2)
39 #define IOCTL_CMD_WPA               (SIOCDEVPRIVATE + 3)
40
41 typedef enum tagWMAC_CMD {
42         WLAN_CMD_BSS_SCAN,
43         WLAN_CMD_BSS_JOIN,
44         WLAN_CMD_DISASSOC,
45         WLAN_CMD_SET_WEP,
46         WLAN_CMD_GET_LINK,
47         WLAN_CMD_GET_LISTLEN,
48         WLAN_CMD_GET_LIST,
49         WLAN_CMD_GET_MIB,
50         WLAN_CMD_GET_STAT,
51         WLAN_CMD_STOP_MAC,
52         WLAN_CMD_START_MAC,
53         WLAN_CMD_AP_START,
54         WLAN_CMD_SET_HOSTAPD,
55         WLAN_CMD_SET_HOSTAPD_STA,
56         WLAN_CMD_SET_802_1X,
57         WLAN_CMD_SET_HOST_WEP,
58         WLAN_CMD_SET_WPA,
59         WLAN_CMD_GET_NODE_CNT,
60         WLAN_CMD_ZONETYPE_SET,
61         WLAN_CMD_GET_NODE_LIST
62 } WMAC_CMD, *PWMAC_CMD;
63
64 typedef enum tagWZONETYPE {
65         ZoneType_USA = 0,
66         ZoneType_Japan = 1,
67         ZoneType_Europe = 2
68 } WZONETYPE;
69
70 #define ADHOC   0
71 #define INFRA   1
72 #define BOTH    2
73 #define AP          3
74
75 #define ADHOC_STARTED      1
76 #define ADHOC_JOINTED      2
77
78 #define PHY80211a       0
79 #define PHY80211b       1
80 #define PHY80211g       2
81
82 #define SSID_ID                0
83 #define SSID_MAXLEN            32
84 #define BSSID_LEN              6
85 #define WEP_NKEYS              4
86 #define WEP_KEYMAXLEN          29
87 #define WEP_40BIT_LEN          5
88 #define WEP_104BIT_LEN         13
89 #define WEP_232BIT_LEN         16
90
91 // Ioctl interface structure
92 // Command structure
93 //
94 #pragma pack(1)
95 typedef struct tagSCmdRequest {
96         u8          name[16];
97         void __user *data;
98         u16         wResult;
99         u16     wCmdCode;
100 } SCmdRequest, *PSCmdRequest;
101
102 //
103 // Scan
104 //
105
106 typedef struct tagSCmdScan {
107         u8 ssid[SSID_MAXLEN + 2];
108 } SCmdScan, *PSCmdScan;
109
110 //
111 // BSS Join
112 //
113
114 typedef struct tagSCmdBSSJoin {
115         u16         wBSSType;
116         u16     wBBPType;
117         u8          ssid[SSID_MAXLEN + 2];
118         u32         uChannel;
119         bool bPSEnable;
120         bool bShareKeyAuth;
121 } SCmdBSSJoin, *PSCmdBSSJoin;
122
123 //
124 // Zonetype Setting
125 //
126
127 typedef struct tagSCmdZoneTypeSet {
128         bool bWrite;
129         WZONETYPE  ZoneType;
130 } SCmdZoneTypeSet, *PSCmdZoneTypeSet;
131
132 #ifdef WPA_SM_Transtatus
133 typedef struct tagSWPAResult {
134         char    ifname[100];
135         u8 proto;
136         u8 key_mgmt;
137         u8 eap_type;
138         bool authenticated;
139 } SWPAResult, *PSWPAResult;
140 #endif
141
142 typedef struct tagSCmdStartAP {
143         u16         wBSSType;
144         u16     wBBPType;
145         u8          ssid[SSID_MAXLEN + 2];
146         u32         uChannel;
147         u32     uBeaconInt;
148         bool bShareKeyAuth;
149         u8      byBasicRate;
150 } SCmdStartAP, *PSCmdStartAP;
151
152 typedef struct tagSCmdSetWEP {
153         bool bEnableWep;
154         u8      byKeyIndex;
155         u8      abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN];
156         bool bWepKeyAvailable[WEP_NKEYS];
157         u32     auWepKeyLength[WEP_NKEYS];
158 } SCmdSetWEP, *PSCmdSetWEP;
159
160 typedef struct tagSBSSIDItem {
161         u32         uChannel;
162         u8      abyBSSID[BSSID_LEN];
163         u8      abySSID[SSID_MAXLEN + 1];
164         u8      byNetType;
165         u16         wBeaconInterval;
166         u16         wCapInfo;        // for address of byNetType at align 4
167
168         bool bWEPOn;
169         u32     uRSSI;
170 } SBSSIDItem;
171
172 typedef struct tagSBSSIDList {
173         u32                 uItem;
174         SBSSIDItem      sBSSIDList[0];
175 } SBSSIDList, *PSBSSIDList;
176
177 typedef struct tagSCmdLinkStatus {
178         bool bLink;
179         u16   wBSSType;
180         u8      byState;
181         u8      abyBSSID[BSSID_LEN];
182         u8      abySSID[SSID_MAXLEN + 2];
183         u32     uChannel;
184         u32     uLinkRate;
185 } SCmdLinkStatus, *PSCmdLinkStatus;
186
187 //
188 // 802.11 counter
189 //
190 typedef struct tagSDot11MIBCount {
191         u32 TransmittedFragmentCount;
192         u32 MulticastTransmittedFrameCount;
193         u32 FailedCount;
194         u32 RetryCount;
195         u32 MultipleRetryCount;
196         u32 RTSSuccessCount;
197         u32 RTSFailureCount;
198         u32 ACKFailureCount;
199         u32 FrameDuplicateCount;
200         u32 ReceivedFragmentCount;
201         u32 MulticastReceivedFrameCount;
202         u32 FCSErrorCount;
203 } SDot11MIBCount, *PSDot11MIBCount;
204
205 //
206 // statistic counter
207 //
208 typedef struct tagSStatMIBCount {
209         //
210         // ISR status count
211         //
212         u32   dwIsrTx0OK;
213         u32   dwIsrTx1OK;
214         u32   dwIsrBeaconTxOK;
215         u32   dwIsrRxOK;
216         u32   dwIsrTBTTInt;
217         u32   dwIsrSTIMERInt;
218         u32   dwIsrUnrecoverableError;
219         u32   dwIsrSoftInterrupt;
220         u32   dwIsrRxNoBuf;
221
222         u32   dwIsrUnknown;
223
224         // RSR status count
225         //
226         u32   dwRsrFrmAlgnErr;
227         u32   dwRsrErr;
228         u32   dwRsrCRCErr;
229         u32   dwRsrCRCOk;
230         u32   dwRsrBSSIDOk;
231         u32   dwRsrADDROk;
232         u32   dwRsrICVOk;
233         u32   dwNewRsrShortPreamble;
234         u32   dwRsrLong;
235         u32   dwRsrRunt;
236
237         u32   dwRsrRxControl;
238         u32   dwRsrRxData;
239         u32   dwRsrRxManage;
240
241         u32   dwRsrRxPacket;
242         u32   dwRsrRxOctet;
243         u32   dwRsrBroadcast;
244         u32   dwRsrMulticast;
245         u32   dwRsrDirected;
246         // 64-bit OID
247         u32   ullRsrOK;
248
249         // for some optional OIDs (64 bits) and DMI support
250         u32   ullRxBroadcastBytes;
251         u32   ullRxMulticastBytes;
252         u32   ullRxDirectedBytes;
253         u32   ullRxBroadcastFrames;
254         u32   ullRxMulticastFrames;
255         u32   ullRxDirectedFrames;
256
257         u32   dwRsrRxFragment;
258         u32   dwRsrRxFrmLen64;
259         u32   dwRsrRxFrmLen65_127;
260         u32   dwRsrRxFrmLen128_255;
261         u32   dwRsrRxFrmLen256_511;
262         u32   dwRsrRxFrmLen512_1023;
263         u32   dwRsrRxFrmLen1024_1518;
264
265         // TSR0,1 status count
266         //
267         u32   dwTsrTotalRetry[2];        // total collision retry count
268         u32   dwTsrOnceRetry[2];         // this packet only occur one collision
269         u32   dwTsrMoreThanOnceRetry[2]; // this packet occur more than one collision
270         u32   dwTsrRetry[2];             // this packet has ever occur collision,
271         // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0)
272         u32   dwTsrACKData[2];
273         u32   dwTsrErr[2];
274         u32   dwAllTsrOK[2];
275         u32   dwTsrRetryTimeout[2];
276         u32   dwTsrTransmitTimeout[2];
277
278         u32   dwTsrTxPacket[2];
279         u32   dwTsrTxOctet[2];
280         u32   dwTsrBroadcast[2];
281         u32   dwTsrMulticast[2];
282         u32   dwTsrDirected[2];
283
284         // RD/TD count
285         u32   dwCntRxFrmLength;
286         u32   dwCntTxBufLength;
287
288         u8    abyCntRxPattern[16];
289         u8    abyCntTxPattern[16];
290
291         // Software check....
292         u32   dwCntRxDataErr;             // rx buffer data software compare CRC err count
293         u32   dwCntDecryptErr;            // rx buffer data software compare CRC err count
294         u32   dwCntRxICVErr;              // rx buffer data software compare CRC err count
295         u32    idxRxErrorDesc;             // index for rx data error RD
296
297         // 64-bit OID
298         u32   ullTsrOK[2];
299
300         // for some optional OIDs (64 bits) and DMI support
301         u32   ullTxBroadcastFrames[2];
302         u32   ullTxMulticastFrames[2];
303         u32   ullTxDirectedFrames[2];
304         u32   ullTxBroadcastBytes[2];
305         u32   ullTxMulticastBytes[2];
306         u32   ullTxDirectedBytes[2];
307 } SStatMIBCount, *PSStatMIBCount;
308
309 typedef struct tagSNodeItem {
310         // STA info
311         u16            wAID;
312         u8             abyMACAddr[6];
313         u16            wTxDataRate;
314         u16            wInActiveCount;
315         u16            wEnQueueCnt;
316         u16            wFlags;
317         bool bPWBitOn;
318         u8             byKeyIndex;
319         u16            wWepKeyLength;
320         u8            abyWepKey[WEP_KEYMAXLEN];
321         // Auto rate fallback vars
322         bool bIsInFallback;
323         u32            uTxFailures;
324         u32            uTxAttempts;
325         u16            wFailureRatio;
326 } SNodeItem;
327
328 typedef struct tagSNodeList {
329         u32                 uItem;
330         SNodeItem       sNodeList[0];
331 } SNodeList, *PSNodeList;
332
333 typedef struct tagSCmdValue {
334         u32 dwValue;
335 } SCmdValue,  *PSCmdValue;
336
337 //
338 // hostapd & viawget ioctl related
339 //
340
341 enum {
342         VIAWGET_HOSTAPD_FLUSH = 1,
343         VIAWGET_HOSTAPD_ADD_STA = 2,
344         VIAWGET_HOSTAPD_REMOVE_STA = 3,
345         VIAWGET_HOSTAPD_GET_INFO_STA = 4,
346         VIAWGET_HOSTAPD_SET_ENCRYPTION = 5,
347         VIAWGET_HOSTAPD_GET_ENCRYPTION = 6,
348         VIAWGET_HOSTAPD_SET_FLAGS_STA = 7,
349         VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR = 8,
350         VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT = 9,
351         VIAWGET_HOSTAPD_MLME = 10,
352         VIAWGET_HOSTAPD_SCAN_REQ = 11,
353         VIAWGET_HOSTAPD_STA_CLEAR_STATS = 12,
354 };
355
356 #define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN                         \
357         ((int)(&((struct viawget_hostapd_param *)0)->u.generic_elem.data))
358
359 // Maximum length for algorithm names (-1 for nul termination) used in ioctl()
360
361 struct viawget_hostapd_param {
362         u32 cmd;
363         u8 sta_addr[6];
364         union {
365                 struct {
366                         u16 aid;
367                         u16 capability;
368                         u8 tx_supp_rates;
369                 } add_sta;
370                 struct {
371                         u32 inactive_sec;
372                 } get_info_sta;
373                 struct {
374                         u8 alg;
375                         u32 flags;
376                         u32 err;
377                         u8 idx;
378                         u8 seq[8];
379                         u16 key_len;
380                         u8 key[0];
381                 } crypt;
382                 struct {
383                         u32 flags_and;
384                         u32 flags_or;
385                 } set_flags_sta;
386                 struct {
387                         u16 rid;
388                         u16 len;
389                         u8 data[0];
390                 } rid;
391                 struct {
392                         u8 len;
393                         u8 data[0];
394                 } generic_elem;
395                 struct {
396                         u16 cmd;
397                         u16 reason_code;
398                 } mlme;
399                 struct {
400                         u8 ssid_len;
401                         u8 ssid[32];
402                 } scan_req;
403         } u;
404 };
405
406 #pragma pack()
407
408 #endif //__IOCMD_H__