[kernel] generic-2.6/2.6.30: refresh patches
[openwrt.git] / target / linux / s3c24xx / files-2.6.30 / drivers / ar6000 / ar6000 / ar6000_drv.h
1 /*
2 *
3 * Copyright (c) 2004-2007 Atheros Communications Inc.
4 * All rights reserved.
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation;
10 *
11 * Software distributed under the License is distributed on an "AS
12 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13 * implied. See the License for the specific language governing
14 * rights and limitations under the License.
15 *
16 *
17 *
18 */
19
20 #ifndef _AR6000_H_
21 #define _AR6000_H_
22
23 #include <linux/version.h>
24
25
26 #include <linux/autoconf.h>
27 #include <linux/init.h>
28 #include <linux/kernel.h>
29 #include <linux/spinlock.h>
30 #include <linux/skbuff.h>
31 #include <linux/if_ether.h>
32 #include <linux/netdevice.h>
33 #include <linux/etherdevice.h>
34 #include <net/iw_handler.h>
35 #include <linux/if_arp.h>
36 #include <linux/ip.h>
37 #include <linux/semaphore.h>
38 #include <linux/wireless.h>
39 #include <linux/module.h>
40 #include <asm/io.h>
41
42 #include <a_config.h>
43 #include <athdefs.h>
44 #include "a_types.h"
45 #include "a_osapi.h"
46 #include "htc_api.h"
47 #include "wmi.h"
48 #include "a_drv.h"
49 #include "bmi.h"
50 #include <ieee80211.h>
51 #include <ieee80211_ioctl.h>
52 #include <wlan_api.h>
53 #include <wmi_api.h>
54 #include "gpio_api.h"
55 #include "gpio.h"
56 #include <host_version.h>
57 #include <linux/rtnetlink.h>
58 #include <linux/init.h>
59 #include <linux/moduleparam.h>
60 #include "AR6Khwreg.h"
61 #include "ar6000_api.h"
62 #ifdef CONFIG_HOST_TCMD_SUPPORT
63 #include <testcmd.h>
64 #endif
65
66 #include "targaddrs.h"
67 #include "dbglog_api.h"
68 #include "ar6000_diag.h"
69 #include "common_drv.h"
70
71 #ifndef __dev_put
72 #define __dev_put(dev) dev_put(dev)
73 #endif
74
75 #ifdef USER_KEYS
76
77 #define USER_SAVEDKEYS_STAT_INIT 0
78 #define USER_SAVEDKEYS_STAT_RUN 1
79
80 // TODO this needs to move into the AR_SOFTC struct
81 struct USER_SAVEDKEYS {
82 struct ieee80211req_key ucast_ik;
83 struct ieee80211req_key bcast_ik;
84 CRYPTO_TYPE keyType;
85 A_BOOL keyOk;
86 };
87 #endif
88
89 #define DBG_INFO 0x00000001
90 #define DBG_ERROR 0x00000002
91 #define DBG_WARNING 0x00000004
92 #define DBG_SDIO 0x00000008
93 #define DBG_HIF 0x00000010
94 #define DBG_HTC 0x00000020
95 #define DBG_WMI 0x00000040
96 #define DBG_WMI2 0x00000080
97 #define DBG_DRIVER 0x00000100
98
99 #define DBG_DEFAULTS (DBG_ERROR|DBG_WARNING)
100
101
102 #ifdef DEBUG
103 #define AR_DEBUG_PRINTF(args...) if (debugdriver) A_PRINTF(args);
104 #define AR_DEBUG2_PRINTF(args...) if (debugdriver >= 2) A_PRINTF(args);
105 extern int debugdriver;
106 #else
107 #define AR_DEBUG_PRINTF(args...)
108 #define AR_DEBUG2_PRINTF(args...)
109 #endif
110
111 A_STATUS ar6000_ReadRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
112 A_STATUS ar6000_WriteRegDiag(HIF_DEVICE *hifDevice, A_UINT32 *address, A_UINT32 *data);
113
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117
118 #define MAX_AR6000 1
119 #define AR6000_MAX_RX_BUFFERS 16
120 #define AR6000_BUFFER_SIZE 1664
121 #define AR6000_TX_TIMEOUT 10
122 #define AR6000_ETH_ADDR_LEN 6
123 #define AR6000_MAX_ENDPOINTS 4
124 #define MAX_NODE_NUM 15
125 #define MAX_COOKIE_NUM 150
126 #define AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT 1
127 #define AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT 1
128
129 enum {
130 DRV_HB_CHALLENGE = 0,
131 APP_HB_CHALLENGE
132 };
133
134 /* HTC RAW streams */
135 typedef enum _HTC_RAW_STREAM_ID {
136 HTC_RAW_STREAM_NOT_MAPPED = -1,
137 HTC_RAW_STREAM_0 = 0,
138 HTC_RAW_STREAM_1 = 1,
139 HTC_RAW_STREAM_2 = 2,
140 HTC_RAW_STREAM_3 = 3,
141 HTC_RAW_STREAM_NUM_MAX
142 } HTC_RAW_STREAM_ID;
143
144 #define RAW_HTC_READ_BUFFERS_NUM 4
145 #define RAW_HTC_WRITE_BUFFERS_NUM 4
146
147 typedef struct {
148 int currPtr;
149 int length;
150 unsigned char data[AR6000_BUFFER_SIZE];
151 HTC_PACKET HTCPacket;
152 } raw_htc_buffer;
153
154 #ifdef CONFIG_HOST_TCMD_SUPPORT
155 /*
156 * add TCMD_MODE besides wmi and bypasswmi
157 * in TCMD_MODE, only few TCMD releated wmi commands
158 * counld be hanlder
159 */
160 enum {
161 AR6000_WMI_MODE = 0,
162 AR6000_BYPASS_MODE,
163 AR6000_TCMD_MODE,
164 AR6000_WLAN_MODE
165 };
166 #endif /* CONFIG_HOST_TCMD_SUPPORT */
167
168 struct ar_wep_key {
169 A_UINT8 arKeyIndex;
170 A_UINT8 arKeyLen;
171 A_UINT8 arKey[64];
172 } ;
173
174 struct ar_node_mapping {
175 A_UINT8 macAddress[6];
176 A_UINT8 epId;
177 A_UINT8 txPending;
178 };
179
180 struct ar_cookie {
181 A_UINT32 arc_bp[2]; /* Must be first field */
182 HTC_PACKET HtcPkt; /* HTC packet wrapper */
183 struct ar_cookie *arc_list_next;
184 };
185
186 struct ar_hb_chlng_resp {
187 A_TIMER timer;
188 A_UINT32 frequency;
189 A_UINT32 seqNum;
190 A_BOOL outstanding;
191 A_UINT8 missCnt;
192 A_UINT8 missThres;
193 };
194
195 typedef struct ar6_softc {
196 struct net_device *arNetDev; /* net_device pointer */
197 void *arWmi;
198 int arTxPending[WMI_PRI_MAX_COUNT];
199 int arTotalTxDataPending;
200 A_UINT8 arNumDataEndPts;
201 A_BOOL arWmiEnabled;
202 A_BOOL arWmiReady;
203 A_BOOL arConnected;
204 A_BOOL arRadioSwitch;
205 HTC_HANDLE arHtcTarget;
206 void *arHifDevice;
207 spinlock_t arLock;
208 struct semaphore arSem;
209 int arRxBuffers[WMI_PRI_MAX_COUNT];
210 int arSsidLen;
211 u_char arSsid[32];
212 A_UINT8 arNetworkType;
213 A_UINT8 arDot11AuthMode;
214 A_UINT8 arAuthMode;
215 A_UINT8 arPairwiseCrypto;
216 A_UINT8 arPairwiseCryptoLen;
217 A_UINT8 arGroupCrypto;
218 A_UINT8 arGroupCryptoLen;
219 A_UINT8 arDefTxKeyIndex;
220 struct ar_wep_key arWepKeyList[WMI_MAX_KEY_INDEX + 1];
221 A_UINT8 arBssid[6];
222 A_UINT8 arReqBssid[6];
223 A_UINT16 arChannelHint;
224 A_UINT16 arBssChannel;
225 A_UINT16 arListenInterval;
226 struct ar6000_version arVersion;
227 A_UINT32 arTargetType;
228 A_INT8 arRssi;
229 A_UINT8 arTxPwr;
230 A_BOOL arTxPwrSet;
231 A_INT32 arBitRate;
232 struct net_device_stats arNetStats;
233 struct iw_statistics arIwStats;
234 A_INT8 arNumChannels;
235 A_UINT16 arChannelList[32];
236 A_UINT32 arRegCode;
237 A_BOOL statsUpdatePending;
238 TARGET_STATS arTargetStats;
239 A_INT8 arMaxRetries;
240 A_UINT8 arPhyCapability;
241 #ifdef CONFIG_HOST_TCMD_SUPPORT
242 A_UINT8 tcmdRxReport;
243 A_UINT32 tcmdRxTotalPkt;
244 A_INT32 tcmdRxRssi;
245 A_UINT32 tcmdPm;
246 A_UINT32 arTargetMode;
247 #endif
248 AR6000_WLAN_STATE arWlanState;
249 struct ar_node_mapping arNodeMap[MAX_NODE_NUM];
250 A_UINT8 arIbssPsEnable;
251 A_UINT8 arNodeNum;
252 A_UINT8 arNexEpId;
253 struct ar_cookie *arCookieList;
254 A_UINT16 arRateMask;
255 A_UINT8 arSkipScan;
256 A_UINT16 arBeaconInterval;
257 A_BOOL arConnectPending;
258 A_BOOL arWmmEnabled;
259 struct ar_hb_chlng_resp arHBChallengeResp;
260 A_UINT8 arKeepaliveConfigured;
261 A_UINT32 arMgmtFilter;
262 HTC_ENDPOINT_ID arWmi2EpMapping[WMI_PRI_MAX_COUNT];
263 WMI_PRI_STREAM_ID arEp2WmiMapping[ENDPOINT_MAX];
264 #ifdef HTC_RAW_INTERFACE
265 HTC_ENDPOINT_ID arRaw2EpMapping[HTC_RAW_STREAM_NUM_MAX];
266 HTC_RAW_STREAM_ID arEp2RawMapping[ENDPOINT_MAX];
267 struct semaphore raw_htc_read_sem[HTC_RAW_STREAM_NUM_MAX];
268 struct semaphore raw_htc_write_sem[HTC_RAW_STREAM_NUM_MAX];
269 wait_queue_head_t raw_htc_read_queue[HTC_RAW_STREAM_NUM_MAX];
270 wait_queue_head_t raw_htc_write_queue[HTC_RAW_STREAM_NUM_MAX];
271 raw_htc_buffer *raw_htc_read_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_READ_BUFFERS_NUM];
272 raw_htc_buffer *raw_htc_write_buffer[HTC_RAW_STREAM_NUM_MAX][RAW_HTC_WRITE_BUFFERS_NUM];
273 A_BOOL write_buffer_available[HTC_RAW_STREAM_NUM_MAX];
274 A_BOOL read_buffer_available[HTC_RAW_STREAM_NUM_MAX];
275 #endif
276 A_BOOL arRawIfInit;
277 int arDeviceIndex;
278 COMMON_CREDIT_STATE_INFO arCreditStateInfo;
279 A_BOOL arWMIControlEpFull;
280 A_BOOL dbgLogFetchInProgress;
281 A_UCHAR log_buffer[DBGLOG_HOST_LOG_BUFFER_SIZE];
282 A_UINT32 log_cnt;
283 A_UINT32 dbglog_init_done;
284 A_UINT32 arConnectCtrlFlags;
285 A_UINT32 scan_complete;
286 #ifdef USER_KEYS
287 A_INT32 user_savedkeys_stat;
288 A_UINT32 user_key_ctrl;
289 struct USER_SAVEDKEYS user_saved_keys;
290 #endif
291 } AR_SOFTC_T;
292
293
294 #define arWMIStream2EndpointID(ar,wmi) (ar)->arWmi2EpMapping[(wmi)]
295 #define arSetWMIStream2EndpointIDMap(ar,wmi,ep) \
296 { (ar)->arWmi2EpMapping[(wmi)] = (ep); \
297 (ar)->arEp2WmiMapping[(ep)] = (wmi); }
298 #define arEndpoint2WMIStreamID(ar,ep) (ar)->arEp2WmiMapping[(ep)]
299
300 #define arRawIfEnabled(ar) (ar)->arRawIfInit
301 #define arRawStream2EndpointID(ar,raw) (ar)->arRaw2EpMapping[(raw)]
302 #define arSetRawStream2EndpointIDMap(ar,raw,ep) \
303 { (ar)->arRaw2EpMapping[(raw)] = (ep); \
304 (ar)->arEp2RawMapping[(ep)] = (raw); }
305 #define arEndpoint2RawStreamID(ar,ep) (ar)->arEp2RawMapping[(ep)]
306
307 struct ar_giwscan_param {
308 char *current_ev;
309 char *end_buf;
310 A_BOOL firstPass;
311 };
312
313 #define AR6000_STAT_INC(ar, stat) (ar->arNetStats.stat++)
314
315 #define AR6000_SPIN_LOCK(lock, param) do { \
316 if (irqs_disabled()) { \
317 AR_DEBUG_PRINTF("IRQs disabled:AR6000_LOCK\n"); \
318 } \
319 spin_lock_bh(lock); \
320 } while (0)
321
322 #define AR6000_SPIN_UNLOCK(lock, param) do { \
323 if (irqs_disabled()) { \
324 AR_DEBUG_PRINTF("IRQs disabled: AR6000_UNLOCK\n"); \
325 } \
326 spin_unlock_bh(lock); \
327 } while (0)
328
329 int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
330 int ar6000_ioctl_dispatcher(struct net_device *dev, struct ifreq *rq, int cmd);
331 void ar6000_ioctl_iwsetup(struct iw_handler_def *def);
332 void ar6000_gpio_init(void);
333 void ar6000_init_profile_info(AR_SOFTC_T *ar);
334 void ar6000_install_static_wep_keys(AR_SOFTC_T *ar);
335 int ar6000_init(struct net_device *dev);
336 int ar6000_dbglog_get_debug_logs(AR_SOFTC_T *ar);
337 A_STATUS ar6000_SetHTCBlockSize(AR_SOFTC_T *ar);
338
339 #ifdef HTC_RAW_INTERFACE
340
341 #ifndef __user
342 #define __user
343 #endif
344
345 int ar6000_htc_raw_open(AR_SOFTC_T *ar);
346 int ar6000_htc_raw_close(AR_SOFTC_T *ar);
347 ssize_t ar6000_htc_raw_read(AR_SOFTC_T *ar,
348 HTC_RAW_STREAM_ID StreamID,
349 char __user *buffer, size_t count);
350 ssize_t ar6000_htc_raw_write(AR_SOFTC_T *ar,
351 HTC_RAW_STREAM_ID StreamID,
352 char __user *buffer, size_t count);
353
354 #endif /* HTC_RAW_INTERFACE */
355
356 #ifdef __cplusplus
357 }
358 #endif
359
360 #endif /* _AR6000_H_ */
This page took 0.06659 seconds and 5 git commands to generate.