3 * Copyright (c) 2004-2007 Atheros Communications Inc.
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;
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.
23 #include <linux/version.h>
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>
37 #include <linux/semaphore.h>
38 #include <linux/wireless.h>
39 #include <linux/module.h>
50 #include <ieee80211.h>
51 #include <ieee80211_ioctl.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
66 #include "targaddrs.h"
67 #include "dbglog_api.h"
68 #include "ar6000_diag.h"
69 #include "common_drv.h"
72 #define __dev_put(dev) dev_put(dev)
77 #define USER_SAVEDKEYS_STAT_INIT 0
78 #define USER_SAVEDKEYS_STAT_RUN 1
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
;
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
99 #define DBG_DEFAULTS (DBG_ERROR|DBG_WARNING)
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
;
107 #define AR_DEBUG_PRINTF(args...)
108 #define AR_DEBUG2_PRINTF(args...)
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
);
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
130 DRV_HB_CHALLENGE
= 0,
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
144 #define RAW_HTC_READ_BUFFERS_NUM 4
145 #define RAW_HTC_WRITE_BUFFERS_NUM 4
150 unsigned char data
[AR6000_BUFFER_SIZE
];
151 HTC_PACKET HTCPacket
;
154 #ifdef CONFIG_HOST_TCMD_SUPPORT
156 * add TCMD_MODE besides wmi and bypasswmi
157 * in TCMD_MODE, only few TCMD releated wmi commands
166 #endif /* CONFIG_HOST_TCMD_SUPPORT */
174 struct ar_node_mapping
{
175 A_UINT8 macAddress
[6];
181 A_UINT32 arc_bp
[2]; /* Must be first field */
182 HTC_PACKET HtcPkt
; /* HTC packet wrapper */
183 struct ar_cookie
*arc_list_next
;
186 struct ar_hb_chlng_resp
{
195 typedef struct ar6_softc
{
196 struct net_device
*arNetDev
; /* net_device pointer */
198 int arTxPending
[WMI_PRI_MAX_COUNT
];
199 int arTotalTxDataPending
;
200 A_UINT8 arNumDataEndPts
;
204 A_BOOL arRadioSwitch
;
205 HTC_HANDLE arHtcTarget
;
208 struct semaphore arSem
;
209 int arRxBuffers
[WMI_PRI_MAX_COUNT
];
212 A_UINT8 arNetworkType
;
213 A_UINT8 arDot11AuthMode
;
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];
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
;
232 struct net_device_stats arNetStats
;
233 struct iw_statistics arIwStats
;
234 A_INT8 arNumChannels
;
235 A_UINT16 arChannelList
[32];
237 A_BOOL statsUpdatePending
;
238 TARGET_STATS arTargetStats
;
240 A_UINT8 arPhyCapability
;
241 #ifdef CONFIG_HOST_TCMD_SUPPORT
242 A_UINT8 tcmdRxReport
;
243 A_UINT32 tcmdRxTotalPkt
;
246 A_UINT32 arTargetMode
;
248 AR6000_WLAN_STATE arWlanState
;
249 struct ar_node_mapping arNodeMap
[MAX_NODE_NUM
];
250 A_UINT8 arIbssPsEnable
;
253 struct ar_cookie
*arCookieList
;
256 A_UINT16 arBeaconInterval
;
257 A_BOOL arConnectPending
;
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
];
278 COMMON_CREDIT_STATE_INFO arCreditStateInfo
;
279 A_BOOL arWMIControlEpFull
;
280 A_BOOL dbgLogFetchInProgress
;
281 A_UCHAR log_buffer
[DBGLOG_HOST_LOG_BUFFER_SIZE
];
283 A_UINT32 dbglog_init_done
;
284 A_UINT32 arConnectCtrlFlags
;
285 A_UINT32 scan_complete
;
287 A_INT32 user_savedkeys_stat
;
288 A_UINT32 user_key_ctrl
;
289 struct USER_SAVEDKEYS user_saved_keys
;
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)]
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)]
307 struct ar_giwscan_param
{
313 #define AR6000_STAT_INC(ar, stat) (ar->arNetStats.stat++)
315 #define AR6000_SPIN_LOCK(lock, param) do { \
316 if (irqs_disabled()) { \
317 AR_DEBUG_PRINTF("IRQs disabled:AR6000_LOCK\n"); \
319 spin_lock_bh(lock); \
322 #define AR6000_SPIN_UNLOCK(lock, param) do { \
323 if (irqs_disabled()) { \
324 AR_DEBUG_PRINTF("IRQs disabled: AR6000_UNLOCK\n"); \
326 spin_unlock_bh(lock); \
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
);
339 #ifdef HTC_RAW_INTERFACE
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
);
354 #endif /* HTC_RAW_INTERFACE */
360 #endif /* _AR6000_H_ */