1 //------------------------------------------------------------------------------
2 // Copyright (c) 2004-2010 Atheros Communications Inc.
3 // All rights reserved.
7 // Permission to use, copy, modify, and/or distribute this software for any
8 // purpose with or without fee is hereby granted, provided that the above
9 // copyright notice and this permission notice appear in all copies.
11 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 // Author(s): ="Atheros"
22 //------------------------------------------------------------------------------
25 * This driver is a pseudo ethernet driver to access the Atheros AR6000
29 #include "ar6000_drv.h"
32 #include "wmi_filter_linux.h"
33 #include "epping_test.h"
34 #include "wlan_config.h"
35 #include "ar3kconfig.h"
37 #include "AR6002/addrs.h"
40 /* LINUX_HACK_FUDGE_FACTOR -- this is used to provide a workaround for linux behavior. When
41 * the meta data was added to the header it was found that linux did not correctly provide
42 * enough headroom. However when more headroom was requested beyond what was truly needed
43 * Linux gave the requested headroom. Therefore to get the necessary headroom from Linux
44 * the driver requests more than is needed by the amount = LINUX_HACK_FUDGE_FACTOR */
45 #define LINUX_HACK_FUDGE_FACTOR 16
46 #define BDATA_BDADDR_OFFSET 28
48 u8 bcast_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
49 u8 null_mac
[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
53 #define ATH_DEBUG_DBG_LOG ATH_DEBUG_MAKE_MODULE_MASK(0)
54 #define ATH_DEBUG_WLAN_CONNECT ATH_DEBUG_MAKE_MODULE_MASK(1)
55 #define ATH_DEBUG_WLAN_SCAN ATH_DEBUG_MAKE_MODULE_MASK(2)
56 #define ATH_DEBUG_WLAN_TX ATH_DEBUG_MAKE_MODULE_MASK(3)
57 #define ATH_DEBUG_WLAN_RX ATH_DEBUG_MAKE_MODULE_MASK(4)
58 #define ATH_DEBUG_HTC_RAW ATH_DEBUG_MAKE_MODULE_MASK(5)
59 #define ATH_DEBUG_HCI_BRIDGE ATH_DEBUG_MAKE_MODULE_MASK(6)
61 static struct ath_debug_mask_description driver_debug_desc
[] = {
62 { ATH_DEBUG_DBG_LOG
, "Target Debug Logs"},
63 { ATH_DEBUG_WLAN_CONNECT
, "WLAN connect"},
64 { ATH_DEBUG_WLAN_SCAN
, "WLAN scan"},
65 { ATH_DEBUG_WLAN_TX
, "WLAN Tx"},
66 { ATH_DEBUG_WLAN_RX
, "WLAN Rx"},
67 { ATH_DEBUG_HTC_RAW
, "HTC Raw IF tracing"},
68 { ATH_DEBUG_HCI_BRIDGE
, "HCI Bridge Setup"},
69 { ATH_DEBUG_HCI_RECV
, "HCI Recv tracing"},
70 { ATH_DEBUG_HCI_DUMP
, "HCI Packet dumps"},
73 ATH_DEBUG_INSTANTIATE_MODULE_VAR(driver
,
75 "Linux Driver Interface",
76 ATH_DEBUG_MASK_DEFAULTS
| ATH_DEBUG_WLAN_SCAN
|
78 ATH_DEBUG_DESCRIPTION_COUNT(driver_debug_desc
),
84 #define IS_MAC_NULL(mac) (mac[0]==0 && mac[1]==0 && mac[2]==0 && mac[3]==0 && mac[4]==0 && mac[5]==0)
85 #define IS_MAC_BCAST(mac) (*mac==0xff)
87 #define DESCRIPTION "Driver to access the Atheros AR600x Device, version " __stringify(__VER_MAJOR_) "." __stringify(__VER_MINOR_) "." __stringify(__VER_PATCH_) "." __stringify(__BUILD_NUMBER_)
89 MODULE_AUTHOR("Atheros Communications, Inc.");
90 MODULE_DESCRIPTION(DESCRIPTION
);
91 MODULE_LICENSE("Dual BSD/GPL");
93 #ifndef REORG_APTC_HEURISTICS
94 #undef ADAPTIVE_POWER_THROUGHPUT_CONTROL
95 #endif /* REORG_APTC_HEURISTICS */
97 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
98 #define APTC_TRAFFIC_SAMPLING_INTERVAL 100 /* msec */
99 #define APTC_UPPER_THROUGHPUT_THRESHOLD 3000 /* Kbps */
100 #define APTC_LOWER_THROUGHPUT_THRESHOLD 2000 /* Kbps */
102 typedef struct aptc_traffic_record
{
104 struct timeval samplingTS
;
105 unsigned long bytesReceived
;
106 unsigned long bytesTransmitted
;
107 } APTC_TRAFFIC_RECORD
;
110 APTC_TRAFFIC_RECORD aptcTR
;
111 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
113 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
114 // callbacks registered by HCI transport driver
115 struct hci_transport_callbacks ar6kHciTransCallbacks
= { NULL
};
118 unsigned int processDot11Hdr
= 0;
120 char ifname
[IFNAMSIZ
] = {0,};
122 int wlaninitmode
= WLAN_INIT_MODE_DEFAULT
;
123 static bool bypasswmi
;
124 unsigned int debuglevel
= 0;
125 int tspecCompliance
= ATHEROS_COMPLIANCE
;
126 unsigned int busspeedlow
= 0;
127 unsigned int onebitmode
= 0;
128 unsigned int skipflash
= 0;
129 unsigned int wmitimeout
= 2;
130 unsigned int wlanNodeCaching
= 1;
131 unsigned int enableuartprint
= ENABLEUARTPRINT_DEFAULT
;
132 unsigned int logWmiRawMsgs
= 0;
133 unsigned int enabletimerwar
= 0;
134 unsigned int num_device
= 1;
135 unsigned int regscanmode
;
136 unsigned int fwmode
= 1;
137 unsigned int mbox_yield_limit
= 99;
138 unsigned int enablerssicompensation
= 0;
139 int reduce_credit_dribble
= 1 + HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF
;
140 int allow_trace_signal
= 0;
141 #ifdef CONFIG_HOST_TCMD_SUPPORT
142 unsigned int testmode
=0;
145 unsigned int irqprocmode
= HIF_DEVICE_IRQ_SYNC_ONLY
;//HIF_DEVICE_IRQ_ASYNC_SYNC;
146 unsigned int panic_on_assert
= 1;
147 unsigned int nohifscattersupport
= NOHIFSCATTERSUPPORT_DEFAULT
;
149 unsigned int setuphci
= SETUPHCI_DEFAULT
;
150 unsigned int loghci
= 0;
151 unsigned int setupbtdev
= SETUPBTDEV_DEFAULT
;
152 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
153 unsigned int ar3khcibaud
= AR3KHCIBAUD_DEFAULT
;
154 unsigned int hciuartscale
= HCIUARTSCALE_DEFAULT
;
155 unsigned int hciuartstep
= HCIUARTSTEP_DEFAULT
;
157 unsigned int csumOffload
=0;
158 unsigned int csumOffloadTest
=0;
159 unsigned int eppingtest
=0;
160 unsigned int mac_addr_method
;
161 unsigned int firmware_bridge
;
163 module_param_string(ifname
, ifname
, sizeof(ifname
), 0644);
164 module_param(wlaninitmode
, int, 0644);
165 module_param(bypasswmi
, bool, 0644);
166 module_param(debuglevel
, uint
, 0644);
167 module_param(tspecCompliance
, int, 0644);
168 module_param(onebitmode
, uint
, 0644);
169 module_param(busspeedlow
, uint
, 0644);
170 module_param(skipflash
, uint
, 0644);
171 module_param(wmitimeout
, uint
, 0644);
172 module_param(wlanNodeCaching
, uint
, 0644);
173 module_param(logWmiRawMsgs
, uint
, 0644);
174 module_param(enableuartprint
, uint
, 0644);
175 module_param(enabletimerwar
, uint
, 0644);
176 module_param(fwmode
, uint
, 0644);
177 module_param(mbox_yield_limit
, uint
, 0644);
178 module_param(reduce_credit_dribble
, int, 0644);
179 module_param(allow_trace_signal
, int, 0644);
180 module_param(enablerssicompensation
, uint
, 0644);
181 module_param(processDot11Hdr
, uint
, 0644);
182 module_param(csumOffload
, uint
, 0644);
183 #ifdef CONFIG_HOST_TCMD_SUPPORT
184 module_param(testmode
, uint
, 0644);
186 module_param(irqprocmode
, uint
, 0644);
187 module_param(nohifscattersupport
, uint
, 0644);
188 module_param(panic_on_assert
, uint
, 0644);
189 module_param(setuphci
, uint
, 0644);
190 module_param(loghci
, uint
, 0644);
191 module_param(setupbtdev
, uint
, 0644);
192 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
193 module_param(ar3khcibaud
, uint
, 0644);
194 module_param(hciuartscale
, uint
, 0644);
195 module_param(hciuartstep
, uint
, 0644);
197 module_param(eppingtest
, uint
, 0644);
199 /* in 2.6.10 and later this is now a pointer to a uint */
200 unsigned int _mboxnum
= HTC_MAILBOX_NUM_MAX
;
201 #define mboxnum &_mboxnum
204 u32 g_dbg_flags
= DBG_DEFAULTS
;
205 unsigned int debugflags
= 0;
207 unsigned int debughtc
= 0;
208 unsigned int debugbmi
= 0;
209 unsigned int debughif
= 0;
210 unsigned int txcreditsavailable
[HTC_MAILBOX_NUM_MAX
] = {0};
211 unsigned int txcreditsconsumed
[HTC_MAILBOX_NUM_MAX
] = {0};
212 unsigned int txcreditintrenable
[HTC_MAILBOX_NUM_MAX
] = {0};
213 unsigned int txcreditintrenableaggregate
[HTC_MAILBOX_NUM_MAX
] = {0};
214 module_param(debugflags
, uint
, 0644);
215 module_param(debugdriver
, int, 0644);
216 module_param(debughtc
, uint
, 0644);
217 module_param(debugbmi
, uint
, 0644);
218 module_param(debughif
, uint
, 0644);
219 module_param_array(txcreditsavailable
, uint
, mboxnum
, 0644);
220 module_param_array(txcreditsconsumed
, uint
, mboxnum
, 0644);
221 module_param_array(txcreditintrenable
, uint
, mboxnum
, 0644);
222 module_param_array(txcreditintrenableaggregate
, uint
, mboxnum
, 0644);
226 unsigned int resetok
= 1;
227 unsigned int tx_attempt
[HTC_MAILBOX_NUM_MAX
] = {0};
228 unsigned int tx_post
[HTC_MAILBOX_NUM_MAX
] = {0};
229 unsigned int tx_complete
[HTC_MAILBOX_NUM_MAX
] = {0};
230 unsigned int hifBusRequestNumMax
= 40;
231 unsigned int war23838_disabled
= 0;
232 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
233 unsigned int enableAPTCHeuristics
= 1;
234 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
235 module_param_array(tx_attempt
, uint
, mboxnum
, 0644);
236 module_param_array(tx_post
, uint
, mboxnum
, 0644);
237 module_param_array(tx_complete
, uint
, mboxnum
, 0644);
238 module_param(hifBusRequestNumMax
, uint
, 0644);
239 module_param(war23838_disabled
, uint
, 0644);
240 module_param(resetok
, uint
, 0644);
241 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
242 module_param(enableAPTCHeuristics
, uint
, 0644);
243 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
245 #ifdef BLOCK_TX_PATH_FLAG
247 module_param(blocktx
, int, 0644);
248 #endif /* BLOCK_TX_PATH_FLAG */
250 typedef struct user_rssi_compensation_t
{
262 } USER_RSSI_CPENSATION
;
264 static USER_RSSI_CPENSATION rssi_compensation_param
;
266 static s16 rssi_compensation_table
[96];
268 int reconnect_flag
= 0;
269 static ar6k_pal_config_t ar6k_pal_config_g
;
271 /* Function declarations */
272 static int ar6000_init_module(void);
273 static void ar6000_cleanup_module(void);
275 int ar6000_init(struct net_device
*dev
);
276 static int ar6000_open(struct net_device
*dev
);
277 static int ar6000_close(struct net_device
*dev
);
278 static void ar6000_init_control_info(struct ar6_softc
*ar
);
279 static int ar6000_data_tx(struct sk_buff
*skb
, struct net_device
*dev
);
281 void ar6000_destroy(struct net_device
*dev
, unsigned int unregister
);
282 static void ar6000_detect_error(unsigned long ptr
);
283 static void ar6000_set_multicast_list(struct net_device
*dev
);
284 static struct net_device_stats
*ar6000_get_stats(struct net_device
*dev
);
286 static void disconnect_timer_handler(unsigned long ptr
);
288 void read_rssi_compensation_param(struct ar6_softc
*ar
);
291 * HTC service connection handlers
293 static int ar6000_avail_ev(void *context
, void *hif_handle
);
295 static int ar6000_unavail_ev(void *context
, void *hif_handle
);
297 int ar6000_configure_target(struct ar6_softc
*ar
);
299 static void ar6000_target_failure(void *Instance
, int Status
);
301 static void ar6000_rx(void *Context
, struct htc_packet
*pPacket
);
303 static void ar6000_rx_refill(void *Context
,HTC_ENDPOINT_ID Endpoint
);
305 static void ar6000_tx_complete(void *Context
, struct htc_packet_queue
*pPackets
);
307 static HTC_SEND_FULL_ACTION
ar6000_tx_queue_full(void *Context
, struct htc_packet
*pPacket
);
309 static void ar6000_alloc_netbufs(A_NETBUF_QUEUE_T
*q
, u16 num
);
310 static void ar6000_deliver_frames_to_nw_stack(void * dev
, void *osbuf
);
311 //static void ar6000_deliver_frames_to_bt_stack(void * dev, void *osbuf);
313 static struct htc_packet
*ar6000_alloc_amsdu_rxbuf(void *Context
, HTC_ENDPOINT_ID Endpoint
, int Length
);
315 static void ar6000_refill_amsdu_rxbufs(struct ar6_softc
*ar
, int Count
);
317 static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc
*ar
);
320 ar6000_sysfs_bmi_read(struct file
*fp
, struct kobject
*kobj
,
321 struct bin_attribute
*bin_attr
,
322 char *buf
, loff_t pos
, size_t count
);
325 ar6000_sysfs_bmi_write(struct file
*fp
, struct kobject
*kobj
,
326 struct bin_attribute
*bin_attr
,
327 char *buf
, loff_t pos
, size_t count
);
330 ar6000_sysfs_bmi_init(struct ar6_softc
*ar
);
332 void ar6k_cleanup_hci_pal(struct ar6_softc
*ar
);
335 ar6000_sysfs_bmi_deinit(struct ar6_softc
*ar
);
338 ar6000_sysfs_bmi_get_config(struct ar6_softc
*ar
, u32 mode
);
344 struct net_device
*ar6000_devices
[MAX_AR6000
];
345 static int is_netdev_registered
;
346 DECLARE_WAIT_QUEUE_HEAD(arEvent
);
347 static void ar6000_cookie_init(struct ar6_softc
*ar
);
348 static void ar6000_cookie_cleanup(struct ar6_softc
*ar
);
349 static void ar6000_free_cookie(struct ar6_softc
*ar
, struct ar_cookie
* cookie
);
350 static struct ar_cookie
*ar6000_alloc_cookie(struct ar6_softc
*ar
);
352 static int ar6000_reinstall_keys(struct ar6_softc
*ar
,u8 key_op_ctrl
);
354 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
355 struct net_device
*arApNetDev
;
356 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
358 static struct ar_cookie s_ar_cookie_mem
[MAX_COOKIE_NUM
];
360 #define HOST_INTEREST_ITEM_ADDRESS(ar, item) \
361 (((ar)->arTargetType == TARGET_TYPE_AR6002) ? AR6002_HOST_INTEREST_ITEM_ADDRESS(item) : \
362 (((ar)->arTargetType == TARGET_TYPE_AR6003) ? AR6003_HOST_INTEREST_ITEM_ADDRESS(item) : 0))
365 static struct net_device_ops ar6000_netdev_ops
= {
367 .ndo_open
= ar6000_open
,
368 .ndo_stop
= ar6000_close
,
369 .ndo_get_stats
= ar6000_get_stats
,
370 .ndo_start_xmit
= ar6000_data_tx
,
371 .ndo_set_multicast_list
= ar6000_set_multicast_list
,
374 /* Debug log support */
377 * Flag to govern whether the debug logs should be parsed in the kernel
378 * or reported to the application.
380 #define REPORT_DEBUG_LOGS_TO_APP
383 ar6000_set_host_app_area(struct ar6_softc
*ar
)
386 struct host_app_area_s host_app_area
;
388 /* Fetch the address of the host_app_area_s instance in the host interest area */
389 address
= TARG_VTOP(ar
->arTargetType
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_app_host_interest
));
390 if (ar6000_ReadRegDiag(ar
->arHifDevice
, &address
, &data
) != 0) {
393 address
= TARG_VTOP(ar
->arTargetType
, data
);
394 host_app_area
.wmi_protocol_ver
= WMI_PROTOCOL_VERSION
;
395 if (ar6000_WriteDataDiag(ar
->arHifDevice
, address
,
396 (u8
*)&host_app_area
,
397 sizeof(struct host_app_area_s
)) != 0)
405 u32
dbglog_get_debug_hdr_ptr(struct ar6_softc
*ar
)
411 address
= TARG_VTOP(ar
->arTargetType
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_dbglog_hdr
));
412 if ((status
= ar6000_ReadDataDiag(ar
->arHifDevice
, address
,
413 (u8
*)¶m
, 4)) != 0)
422 * The dbglog module has been initialized. Its ok to access the relevant
423 * data stuctures over the diagnostic window.
426 ar6000_dbglog_init_done(struct ar6_softc
*ar
)
428 ar
->dbglog_init_done
= true;
431 u32
dbglog_get_debug_fragment(s8
*datap
, u32 len
, u32 limit
)
440 buffer
= (s32
*)datap
;
441 length
= (limit
>> 2);
446 while (count
< length
) {
447 numargs
= DBGLOG_GET_NUMARGS(buffer
[count
]);
448 fraglen
= (count
<< 2);
449 count
+= numargs
+ 1;
457 dbglog_parse_debug_logs(s8
*datap
, u32 len
)
468 buffer
= (s32
*)datap
;
470 while (count
< length
) {
471 debugid
= DBGLOG_GET_DBGID(buffer
[count
]);
472 moduleid
= DBGLOG_GET_MODULEID(buffer
[count
]);
473 numargs
= DBGLOG_GET_NUMARGS(buffer
[count
]);
474 timestamp
= DBGLOG_GET_TIMESTAMP(buffer
[count
]);
477 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("%d %d (%d)\n", moduleid
, debugid
, timestamp
));
481 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("%d %d (%d): 0x%x\n", moduleid
, debugid
,
482 timestamp
, buffer
[count
+1]));
486 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("%d %d (%d): 0x%x, 0x%x\n", moduleid
, debugid
,
487 timestamp
, buffer
[count
+1], buffer
[count
+2]));
491 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Invalid args: %d\n", numargs
));
493 count
+= numargs
+ 1;
498 ar6000_dbglog_get_debug_logs(struct ar6_softc
*ar
)
500 u32 data
[8]; /* Should be able to accommodate struct dbglog_buf_s */
507 if (!ar
->dbglog_init_done
) return A_ERROR
;
510 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
512 if (ar
->dbgLogFetchInProgress
) {
513 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
517 /* block out others */
518 ar
->dbgLogFetchInProgress
= true;
520 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
522 debug_hdr_ptr
= dbglog_get_debug_hdr_ptr(ar
);
523 printk("debug_hdr_ptr: 0x%x\n", debug_hdr_ptr
);
525 /* Get the contents of the ring buffer */
527 address
= TARG_VTOP(ar
->arTargetType
, debug_hdr_ptr
);
528 length
= 4 /* sizeof(dbuf) */ + 4 /* sizeof(dropped) */;
529 A_MEMZERO(data
, sizeof(data
));
530 ar6000_ReadDataDiag(ar
->arHifDevice
, address
, (u8
*)data
, length
);
531 address
= TARG_VTOP(ar
->arTargetType
, data
[0] /* dbuf */);
533 dropped
= data
[1]; /* dropped */
534 length
= 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */;
535 A_MEMZERO(data
, sizeof(data
));
536 ar6000_ReadDataDiag(ar
->arHifDevice
, address
, (u8
*)&data
, length
);
539 address
= TARG_VTOP(ar
->arTargetType
, data
[1] /* buffer*/);
540 length
= data
[3]; /* length */
541 if ((length
) && (length
<= data
[2] /* bufsize*/)) {
542 /* Rewind the index if it is about to overrun the buffer */
543 if (ar
->log_cnt
> (DBGLOG_HOST_LOG_BUFFER_SIZE
- length
)) {
546 if(0 != ar6000_ReadDataDiag(ar
->arHifDevice
, address
,
547 (u8
*)&ar
->log_buffer
[ar
->log_cnt
], length
))
551 ar6000_dbglog_event(ar
, dropped
, (s8
*)&ar
->log_buffer
[ar
->log_cnt
], length
);
552 ar
->log_cnt
+= length
;
554 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("Length: %d (Total size: %d)\n",
558 address
= TARG_VTOP(ar
->arTargetType
, data
[0] /* next */);
559 length
= 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */;
560 A_MEMZERO(data
, sizeof(data
));
561 if(0 != ar6000_ReadDataDiag(ar
->arHifDevice
, address
,
562 (u8
*)&data
, length
))
567 } while (address
!= firstbuf
);
570 ar
->dbgLogFetchInProgress
= false;
576 ar6000_dbglog_event(struct ar6_softc
*ar
, u32 dropped
,
577 s8
*buffer
, u32 length
)
579 #ifdef REPORT_DEBUG_LOGS_TO_APP
580 #define MAX_WIRELESS_EVENT_SIZE 252
582 * Break it up into chunks of MAX_WIRELESS_EVENT_SIZE bytes of messages.
583 * There seems to be a limitation on the length of message that could be
584 * transmitted to the user app via this mechanism.
589 send
= dbglog_get_debug_fragment(&buffer
[sent
], length
- sent
,
590 MAX_WIRELESS_EVENT_SIZE
);
593 send
= dbglog_get_debug_fragment(&buffer
[sent
], length
- sent
,
594 MAX_WIRELESS_EVENT_SIZE
);
597 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Dropped logs: 0x%x\nDebug info length: %d\n",
600 /* Interpret the debug logs */
601 dbglog_parse_debug_logs((s8
*)buffer
, length
);
602 #endif /* REPORT_DEBUG_LOGS_TO_APP */
607 ar6000_init_module(void)
609 static int probed
= 0;
611 OSDRV_CALLBACKS osdrvCallbacks
;
613 a_module_debug_support_init();
616 /* check for debug mask overrides */
618 ATH_DEBUG_SET_DEBUG_MASK(htc
,debughtc
);
621 ATH_DEBUG_SET_DEBUG_MASK(bmi
,debugbmi
);
624 ATH_DEBUG_SET_DEBUG_MASK(hif
,debughif
);
626 if (debugdriver
!= 0) {
627 ATH_DEBUG_SET_DEBUG_MASK(driver
,debugdriver
);
632 A_REGISTER_MODULE_DEBUG_INFO(driver
);
634 A_MEMZERO(&osdrvCallbacks
,sizeof(osdrvCallbacks
));
635 osdrvCallbacks
.deviceInsertedHandler
= ar6000_avail_ev
;
636 osdrvCallbacks
.deviceRemovedHandler
= ar6000_unavail_ev
;
638 osdrvCallbacks
.deviceSuspendHandler
= ar6000_suspend_ev
;
639 osdrvCallbacks
.deviceResumeHandler
= ar6000_resume_ev
;
640 osdrvCallbacks
.devicePowerChangeHandler
= ar6000_power_change_ev
;
644 /* Set the debug flags if specified at load time */
647 g_dbg_flags
= debugflags
;
656 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
657 memset(&aptcTR
, 0, sizeof(APTC_TRAFFIC_RECORD
));
658 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
660 r
= HIFInit(&osdrvCallbacks
);
668 ar6000_cleanup_module(void)
671 struct net_device
*ar6000_netdev
;
673 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
674 /* Delete the Adaptive Power Control timer */
675 if (timer_pending(&aptcTimer
)) {
676 del_timer_sync(&aptcTimer
);
678 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
680 for (i
=0; i
< MAX_AR6000
; i
++) {
681 if (ar6000_devices
[i
] != NULL
) {
682 ar6000_netdev
= ar6000_devices
[i
];
683 ar6000_devices
[i
] = NULL
;
684 ar6000_destroy(ar6000_netdev
, 1);
688 HIFShutDownDevice(NULL
);
690 a_module_debug_support_cleanup();
692 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("ar6000_cleanup: success\n"));
695 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
697 aptcTimerHandler(unsigned long arg
)
701 struct ar6_softc
*ar
;
704 ar
= (struct ar6_softc
*)arg
;
705 A_ASSERT(ar
!= NULL
);
706 A_ASSERT(!timer_pending(&aptcTimer
));
708 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
710 /* Get the number of bytes transferred */
711 numbytes
= aptcTR
.bytesTransmitted
+ aptcTR
.bytesReceived
;
712 aptcTR
.bytesTransmitted
= aptcTR
.bytesReceived
= 0;
714 /* Calculate and decide based on throughput thresholds */
715 throughput
= ((numbytes
* 8)/APTC_TRAFFIC_SAMPLING_INTERVAL
); /* Kbps */
716 if (throughput
< APTC_LOWER_THROUGHPUT_THRESHOLD
) {
717 /* Enable Sleep and delete the timer */
718 A_ASSERT(ar
->arWmiReady
== true);
719 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
720 status
= wmi_powermode_cmd(ar
->arWmi
, REC_POWER
);
721 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
722 A_ASSERT(status
== 0);
723 aptcTR
.timerScheduled
= false;
725 A_TIMEOUT_MS(&aptcTimer
, APTC_TRAFFIC_SAMPLING_INTERVAL
, 0);
728 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
730 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
733 ar6000_alloc_netbufs(A_NETBUF_QUEUE_T
*q
, u16 num
)
738 if((osbuf
= A_NETBUF_ALLOC(AR6000_BUFFER_SIZE
))) {
739 A_NETBUF_ENQUEUE(q
, osbuf
);
747 A_PRINTF("%s(), allocation of netbuf failed", __func__
);
751 static struct bin_attribute bmi_attr
= {
752 .attr
= {.name
= "bmi", .mode
= 0600},
753 .read
= ar6000_sysfs_bmi_read
,
754 .write
= ar6000_sysfs_bmi_write
,
758 ar6000_sysfs_bmi_read(struct file
*fp
, struct kobject
*kobj
,
759 struct bin_attribute
*bin_attr
,
760 char *buf
, loff_t pos
, size_t count
)
763 struct ar6_softc
*ar
;
764 struct hif_device_os_device_info
*osDevInfo
;
766 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Read %d bytes\n", (u32
)count
));
767 for (index
=0; index
< MAX_AR6000
; index
++) {
768 ar
= (struct ar6_softc
*)ar6k_priv(ar6000_devices
[index
]);
769 osDevInfo
= &ar
->osDevInfo
;
770 if (kobj
== (&(((struct device
*)osDevInfo
->pOSDevice
)->kobj
))) {
775 if (index
== MAX_AR6000
) return 0;
777 if ((BMIRawRead(ar
->arHifDevice
, (u8
*)buf
, count
, true)) != 0) {
785 ar6000_sysfs_bmi_write(struct file
*fp
, struct kobject
*kobj
,
786 struct bin_attribute
*bin_attr
,
787 char *buf
, loff_t pos
, size_t count
)
790 struct ar6_softc
*ar
;
791 struct hif_device_os_device_info
*osDevInfo
;
793 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Write %d bytes\n", (u32
)count
));
794 for (index
=0; index
< MAX_AR6000
; index
++) {
795 ar
= (struct ar6_softc
*)ar6k_priv(ar6000_devices
[index
]);
796 osDevInfo
= &ar
->osDevInfo
;
797 if (kobj
== (&(((struct device
*)osDevInfo
->pOSDevice
)->kobj
))) {
802 if (index
== MAX_AR6000
) return 0;
804 if ((BMIRawWrite(ar
->arHifDevice
, (u8
*)buf
, count
)) != 0) {
812 ar6000_sysfs_bmi_init(struct ar6_softc
*ar
)
816 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Creating sysfs entry\n"));
817 A_MEMZERO(&ar
->osDevInfo
, sizeof(struct hif_device_os_device_info
));
819 /* Get the underlying OS device */
820 status
= HIFConfigureDevice(ar
->arHifDevice
,
821 HIF_DEVICE_GET_OS_DEVICE
,
823 sizeof(struct hif_device_os_device_info
));
826 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI: Failed to get OS device info from HIF\n"));
830 /* Create a bmi entry in the sysfs filesystem */
831 if ((sysfs_create_bin_file(&(((struct device
*)ar
->osDevInfo
.pOSDevice
)->kobj
), &bmi_attr
)) < 0)
833 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMI: Failed to create entry for bmi in sysfs filesystem\n"));
841 ar6000_sysfs_bmi_deinit(struct ar6_softc
*ar
)
843 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Deleting sysfs entry\n"));
845 sysfs_remove_bin_file(&(((struct device
*)ar
->osDevInfo
.pOSDevice
)->kobj
), &bmi_attr
);
848 #define bmifn(fn) do { \
850 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__)); \
855 #ifdef SOFTMAC_FILE_USED
856 #define AR6002_MAC_ADDRESS_OFFSET 0x0A
857 #define AR6003_MAC_ADDRESS_OFFSET 0x16
859 void calculate_crc(u32 TargetType
, u8
*eeprom_data
)
867 if (TargetType
== TARGET_TYPE_AR6001
)
870 ptr_crc
= (u16
*)eeprom_data
;
872 else if (TargetType
== TARGET_TYPE_AR6003
)
875 ptr_crc
= (u16
*)((u8
*)eeprom_data
+ 0x04);
880 ptr_crc
= (u16
*)((u8
*)eeprom_data
+ 0x04);
887 // Recalculate new CRC
889 ptr16_eeprom
= (u16
*)eeprom_data
;
890 for (i
= 0;i
< eeprom_size
; i
+= 2)
892 checksum
= checksum
^ (*ptr16_eeprom
);
895 checksum
= 0xFFFF ^ checksum
;
900 ar6000_softmac_update(struct ar6_softc
*ar
, u8
*eeprom_data
, size_t size
)
902 const char *source
= "random generated";
903 const struct firmware
*softmac_entry
;
905 switch (ar
->arTargetType
) {
906 case TARGET_TYPE_AR6002
:
907 ptr_mac
= (u8
*)((u8
*)eeprom_data
+ AR6002_MAC_ADDRESS_OFFSET
);
909 case TARGET_TYPE_AR6003
:
910 ptr_mac
= (u8
*)((u8
*)eeprom_data
+ AR6003_MAC_ADDRESS_OFFSET
);
913 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Invalid Target Type\n"));
916 printk(KERN_DEBUG
"MAC from EEPROM %pM\n", ptr_mac
);
918 /* create a random MAC in case we cannot read file from system */
922 ptr_mac
[3] = random32() & 0xff;
923 ptr_mac
[4] = random32() & 0xff;
924 ptr_mac
[5] = random32() & 0xff;
925 if ((A_REQUEST_FIRMWARE(&softmac_entry
, "softmac", ((struct device
*)ar
->osDevInfo
.pOSDevice
))) == 0)
927 char *macbuf
= A_MALLOC_NOWAIT(softmac_entry
->size
+1);
929 unsigned int softmac
[6];
930 memcpy(macbuf
, softmac_entry
->data
, softmac_entry
->size
);
931 macbuf
[softmac_entry
->size
] = '\0';
932 if (sscanf(macbuf
, "%02x:%02x:%02x:%02x:%02x:%02x",
933 &softmac
[0], &softmac
[1], &softmac
[2],
934 &softmac
[3], &softmac
[4], &softmac
[5])==6) {
936 for (i
=0; i
<6; ++i
) {
937 ptr_mac
[i
] = softmac
[i
] & 0xff;
939 source
= "softmac file";
943 A_RELEASE_FIRMWARE(softmac_entry
);
945 printk(KERN_DEBUG
"MAC from %s %pM\n", source
, ptr_mac
);
946 calculate_crc(ar
->arTargetType
, eeprom_data
);
948 #endif /* SOFTMAC_FILE_USED */
951 ar6000_transfer_bin_file(struct ar6_softc
*ar
, AR6K_BIN_FILE file
, u32 address
, bool compressed
)
954 const char *filename
;
955 const struct firmware
*fw_entry
;
960 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
961 filename
= AR6003_REV1_OTP_FILE
;
962 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
963 filename
= AR6003_REV2_OTP_FILE
;
964 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
965 filename
= AR6003_REV3_OTP_FILE
;
967 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
972 case AR6K_FIRMWARE_FILE
:
973 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
974 filename
= AR6003_REV1_FIRMWARE_FILE
;
975 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
976 filename
= AR6003_REV2_FIRMWARE_FILE
;
977 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
978 filename
= AR6003_REV3_FIRMWARE_FILE
;
980 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
986 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
987 filename
= AR6003_REV1_EPPING_FIRMWARE_FILE
;
988 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
989 filename
= AR6003_REV2_EPPING_FIRMWARE_FILE
;
990 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
991 filename
= AR6003_REV3_EPPING_FIRMWARE_FILE
;
993 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("eppingtest : unsupported firmware revision: %d\n",
994 ar
->arVersion
.target_ver
));
1000 #ifdef CONFIG_HOST_TCMD_SUPPORT
1002 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1003 filename
= AR6003_REV1_TCMD_FIRMWARE_FILE
;
1004 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1005 filename
= AR6003_REV2_TCMD_FIRMWARE_FILE
;
1006 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
1007 filename
= AR6003_REV3_TCMD_FIRMWARE_FILE
;
1009 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1015 #ifdef HTC_RAW_INTERFACE
1016 if (!eppingtest
&& bypasswmi
) {
1017 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1018 filename
= AR6003_REV1_ART_FIRMWARE_FILE
;
1019 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1020 filename
= AR6003_REV2_ART_FIRMWARE_FILE
;
1022 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1030 case AR6K_PATCH_FILE
:
1031 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1032 filename
= AR6003_REV1_PATCH_FILE
;
1033 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1034 filename
= AR6003_REV2_PATCH_FILE
;
1035 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
1036 filename
= AR6003_REV3_PATCH_FILE
;
1038 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1043 case AR6K_BOARD_DATA_FILE
:
1044 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1045 filename
= AR6003_REV1_BOARD_DATA_FILE
;
1046 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1047 filename
= AR6003_REV2_BOARD_DATA_FILE
;
1048 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
1049 filename
= AR6003_REV3_BOARD_DATA_FILE
;
1051 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1057 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown file type: %d\n", file
));
1060 if ((A_REQUEST_FIRMWARE(&fw_entry
, filename
, ((struct device
*)ar
->osDevInfo
.pOSDevice
))) != 0)
1062 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Failed to get %s\n", filename
));
1066 #ifdef SOFTMAC_FILE_USED
1067 if (file
==AR6K_BOARD_DATA_FILE
&& fw_entry
->data
) {
1068 ar6000_softmac_update(ar
, (u8
*)fw_entry
->data
, fw_entry
->size
);
1073 fw_entry_size
= fw_entry
->size
;
1075 /* Load extended board data for AR6003 */
1076 if ((file
==AR6K_BOARD_DATA_FILE
) && (fw_entry
->data
)) {
1077 u32 board_ext_address
;
1078 u32 board_ext_data_size
;
1079 u32 board_data_size
;
1081 board_ext_data_size
= (((ar
)->arTargetType
== TARGET_TYPE_AR6002
) ? AR6002_BOARD_EXT_DATA_SZ
: \
1082 (((ar
)->arTargetType
== TARGET_TYPE_AR6003
) ? AR6003_BOARD_EXT_DATA_SZ
: 0));
1084 board_data_size
= (((ar
)->arTargetType
== TARGET_TYPE_AR6002
) ? AR6002_BOARD_DATA_SZ
: \
1085 (((ar
)->arTargetType
== TARGET_TYPE_AR6003
) ? AR6003_BOARD_DATA_SZ
: 0));
1087 /* Determine where in Target RAM to write Board Data */
1088 bmifn(BMIReadMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_ext_data
), (u8
*)&board_ext_address
, 4));
1089 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("Board extended Data download address: 0x%x\n", board_ext_address
));
1091 /* check whether the target has allocated memory for extended board data and file contains extended board data */
1092 if ((board_ext_address
) && (fw_entry
->size
== (board_data_size
+ board_ext_data_size
))) {
1095 status
= BMIWriteMemory(ar
->arHifDevice
, board_ext_address
, (u8
*)(fw_entry
->data
+ board_data_size
), board_ext_data_size
);
1098 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI operation failed: %d\n", __LINE__
));
1099 A_RELEASE_FIRMWARE(fw_entry
);
1103 /* Record the fact that extended board Data IS initialized */
1104 param
= (board_ext_data_size
<< 16) | 1;
1105 bmifn(BMIWriteMemory(ar
->arHifDevice
,
1106 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_ext_data_config
),
1107 (unsigned char *)¶m
, 4));
1109 fw_entry_size
= board_data_size
;
1113 status
= BMIFastDownload(ar
->arHifDevice
, address
, (u8
*)fw_entry
->data
, fw_entry_size
);
1115 status
= BMIWriteMemory(ar
->arHifDevice
, address
, (u8
*)fw_entry
->data
, fw_entry_size
);
1119 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI operation failed: %d\n", __LINE__
));
1120 A_RELEASE_FIRMWARE(fw_entry
);
1123 A_RELEASE_FIRMWARE(fw_entry
);
1128 ar6000_update_bdaddr(struct ar6_softc
*ar
)
1131 if (setupbtdev
!= 0) {
1134 if (BMIReadMemory(ar
->arHifDevice
,
1135 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_data
), (u8
*)&address
, 4) != 0)
1137 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for hi_board_data failed\n"));
1141 if (BMIReadMemory(ar
->arHifDevice
, address
+ BDATA_BDADDR_OFFSET
, (u8
*)ar
->bdaddr
, 6) != 0)
1143 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for BD address failed\n"));
1146 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BDADDR 0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", ar
->bdaddr
[0],
1147 ar
->bdaddr
[1], ar
->bdaddr
[2], ar
->bdaddr
[3],
1148 ar
->bdaddr
[4], ar
->bdaddr
[5]));
1155 ar6000_sysfs_bmi_get_config(struct ar6_softc
*ar
, u32 mode
)
1157 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Requesting device specific configuration\n"));
1159 if (mode
== WLAN_INIT_MODE_UDEV
) {
1161 const struct firmware
*fw_entry
;
1163 /* Get config using udev through a script in user space */
1164 sprintf(version
, "%2.2x", ar
->arVersion
.target_ver
);
1165 if ((A_REQUEST_FIRMWARE(&fw_entry
, version
, ((struct device
*)ar
->osDevInfo
.pOSDevice
))) != 0)
1167 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI: Failure to get configuration for target version: %s\n", version
));
1171 A_RELEASE_FIRMWARE(fw_entry
);
1173 /* The config is contained within the driver itself */
1175 u32 param
, options
, sleep
, address
;
1177 /* Temporarily disable system sleep */
1178 address
= MBOX_BASE_ADDRESS
+ LOCAL_SCRATCH_ADDRESS
;
1179 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1181 param
|= AR6K_OPTION_SLEEP_DISABLE
;
1182 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1184 address
= RTC_BASE_ADDRESS
+ SYSTEM_SLEEP_ADDRESS
;
1185 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1187 param
|= WLAN_SYSTEM_SLEEP_DISABLE_SET(1);
1188 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1189 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("old options: %d, old sleep: %d\n", options
, sleep
));
1191 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1192 /* Program analog PLL register */
1193 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, ANALOG_INTF_BASE_ADDRESS
+ 0x284, 0xF9104001));
1194 /* Run at 80/88MHz by default */
1195 param
= CPU_CLOCK_STANDARD_SET(1);
1197 /* Run at 40/44MHz by default */
1198 param
= CPU_CLOCK_STANDARD_SET(0);
1200 address
= RTC_BASE_ADDRESS
+ CPU_CLOCK_ADDRESS
;
1201 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1204 if (ar
->arTargetType
== TARGET_TYPE_AR6002
) {
1205 bmifn(BMIReadMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_ext_clk_detected
), (u8
*)¶m
, 4));
1208 /* LPO_CAL.ENABLE = 1 if no external clk is detected */
1210 address
= RTC_BASE_ADDRESS
+ LPO_CAL_ADDRESS
;
1211 param
= LPO_CAL_ENABLE_SET(1);
1212 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1215 /* Venus2.0: Lower SDIO pad drive strength,
1216 * temporary WAR to avoid SDIO CRC error */
1217 if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1218 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("AR6K: Temporary WAR to avoid SDIO CRC error\n"));
1220 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN10_ADDRESS
;
1221 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1223 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN11_ADDRESS
;
1224 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1226 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN12_ADDRESS
;
1227 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1229 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN13_ADDRESS
;
1230 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1233 #ifdef FORCE_INTERNAL_CLOCK
1234 /* Ignore external clock, if any, and force use of internal clock */
1235 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1236 /* hi_ext_clk_detected = 0 */
1238 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_ext_clk_detected
), (u8
*)¶m
, 4));
1240 /* CLOCK_CONTROL &= ~LF_CLK32 */
1241 address
= RTC_BASE_ADDRESS
+ CLOCK_CONTROL_ADDRESS
;
1242 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1243 param
&= (~CLOCK_CONTROL_LF_CLK32_SET(1));
1244 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1246 #endif /* FORCE_INTERNAL_CLOCK */
1248 /* Transfer Board Data from Target EEPROM to Target RAM */
1249 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1250 /* Determine where in Target RAM to write Board Data */
1251 bmifn(BMIReadMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_data
), (u8
*)&address
, 4));
1252 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("Board Data download address: 0x%x\n", address
));
1254 /* Write EEPROM data to Target RAM */
1255 if ((ar6000_transfer_bin_file(ar
, AR6K_BOARD_DATA_FILE
, address
, false)) != 0) {
1259 /* Record the fact that Board Data IS initialized */
1261 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_data_initialized
), (u8
*)¶m
, 4));
1263 /* Transfer One time Programmable data */
1264 AR6K_APP_LOAD_ADDRESS(address
, ar
->arVersion
.target_ver
);
1265 if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
)
1267 status
= ar6000_transfer_bin_file(ar
, AR6K_OTP_FILE
, address
, true);
1269 /* Execute the OTP code */
1271 AR6K_APP_START_OVERRIDE_ADDRESS(address
, ar
->arVersion
.target_ver
);
1272 bmifn(BMIExecute(ar
->arHifDevice
, address
, ¶m
));
1273 } else if (status
!= A_ENOENT
) {
1277 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Programming of board data for chip %d not supported\n", ar
->arTargetType
));
1281 /* Download Target firmware */
1282 AR6K_APP_LOAD_ADDRESS(address
, ar
->arVersion
.target_ver
);
1283 if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
)
1285 if ((ar6000_transfer_bin_file(ar
, AR6K_FIRMWARE_FILE
, address
, true)) != 0) {
1289 /* Set starting address for firmware */
1290 AR6K_APP_START_OVERRIDE_ADDRESS(address
, ar
->arVersion
.target_ver
);
1291 bmifn(BMISetAppStart(ar
->arHifDevice
, address
));
1293 if(ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1294 AR6K_DATASET_PATCH_ADDRESS(address
, ar
->arVersion
.target_ver
);
1295 if ((ar6000_transfer_bin_file(ar
, AR6K_PATCH_FILE
,
1296 address
, false)) != 0)
1299 bmifn(BMIWriteMemory(ar
->arHifDevice
,
1300 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_dset_list_head
),
1301 (unsigned char *)¶m
, 4));
1304 /* Restore system sleep */
1305 address
= RTC_BASE_ADDRESS
+ SYSTEM_SLEEP_ADDRESS
;
1306 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, sleep
));
1308 address
= MBOX_BASE_ADDRESS
+ LOCAL_SCRATCH_ADDRESS
;
1309 param
= options
| 0x20;
1310 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1312 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1313 /* Configure GPIO AR6003 UART */
1314 #ifndef CONFIG_AR600x_DEBUG_UART_TX_PIN
1315 #define CONFIG_AR600x_DEBUG_UART_TX_PIN 8
1317 param
= CONFIG_AR600x_DEBUG_UART_TX_PIN
;
1318 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_dbg_uart_txpin
), (u8
*)¶m
, 4));
1320 #if (CONFIG_AR600x_DEBUG_UART_TX_PIN == 23)
1322 address
= GPIO_BASE_ADDRESS
+ CLOCK_GPIO_ADDRESS
;
1323 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1324 param
|= CLOCK_GPIO_BT_CLK_OUT_EN_SET(1);
1325 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1329 /* Configure GPIO for BT Reset */
1330 #ifdef ATH6KL_CONFIG_GPIO_BT_RESET
1331 #define CONFIG_AR600x_BT_RESET_PIN 0x16
1332 param
= CONFIG_AR600x_BT_RESET_PIN
;
1333 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_hci_uart_support_pins
), (u8
*)¶m
, 4));
1334 #endif /* ATH6KL_CONFIG_GPIO_BT_RESET */
1336 /* Configure UART flow control polarity */
1337 #ifndef CONFIG_ATH6KL_BT_UART_FC_POLARITY
1338 #define CONFIG_ATH6KL_BT_UART_FC_POLARITY 0
1341 #if (CONFIG_ATH6KL_BT_UART_FC_POLARITY == 1)
1342 if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1343 param
= ((CONFIG_ATH6KL_BT_UART_FC_POLARITY
<< 1) & 0x2);
1344 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_hci_uart_pwr_mgmt_params
), (u8
*)¶m
, 4));
1346 #endif /* CONFIG_ATH6KL_BT_UART_FC_POLARITY */
1349 #ifdef HTC_RAW_INTERFACE
1350 if (!eppingtest
&& bypasswmi
) {
1351 /* Don't run BMIDone for ART mode and force resetok=0 */
1355 #endif /* HTC_RAW_INTERFACE */
1362 ar6000_configure_target(struct ar6_softc
*ar
)
1365 if (enableuartprint
) {
1367 if (BMIWriteMemory(ar
->arHifDevice
,
1368 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_serial_enable
),
1372 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for enableuartprint failed \n"));
1375 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Serial console prints enabled\n"));
1378 /* Tell target which HTC version it is used*/
1379 param
= HTC_PROTOCOL_VERSION
;
1380 if (BMIWriteMemory(ar
->arHifDevice
,
1381 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_app_host_interest
),
1385 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for htc version failed \n"));
1389 #ifdef CONFIG_HOST_TCMD_SUPPORT
1391 ar
->arTargetMode
= AR6000_TCMD_MODE
;
1393 ar
->arTargetMode
= AR6000_WLAN_MODE
;
1396 if (enabletimerwar
) {
1399 if (BMIReadMemory(ar
->arHifDevice
,
1400 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1404 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for enabletimerwar failed \n"));
1408 param
|= HI_OPTION_TIMER_WAR
;
1410 if (BMIWriteMemory(ar
->arHifDevice
,
1411 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1415 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for enabletimerwar failed \n"));
1418 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Timer WAR enabled\n"));
1421 /* set the firmware mode to STA/IBSS/AP */
1425 if (BMIReadMemory(ar
->arHifDevice
,
1426 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1430 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for setting fwmode failed \n"));
1434 param
|= (num_device
<< HI_OPTION_NUM_DEV_SHIFT
);
1435 param
|= (fwmode
<< HI_OPTION_FW_MODE_SHIFT
);
1436 param
|= (mac_addr_method
<< HI_OPTION_MAC_ADDR_METHOD_SHIFT
);
1437 param
|= (firmware_bridge
<< HI_OPTION_FW_BRIDGE_SHIFT
);
1440 if (BMIWriteMemory(ar
->arHifDevice
,
1441 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1445 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for setting fwmode failed \n"));
1448 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Firmware mode set\n"));
1451 #ifdef ATH6KL_DISABLE_TARGET_DBGLOGS
1455 if (BMIReadMemory(ar
->arHifDevice
,
1456 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1460 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for disabling debug logs failed\n"));
1464 param
|= HI_OPTION_DISABLE_DBGLOG
;
1466 if (BMIWriteMemory(ar
->arHifDevice
,
1467 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1471 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for HI_OPTION_DISABLE_DBGLOG\n"));
1474 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Firmware mode set\n"));
1476 #endif /* ATH6KL_DISABLE_TARGET_DBGLOGS */
1479 * Hardcode the address use for the extended board data
1480 * Ideally this should be pre-allocate by the OS at boot time
1481 * But since it is a new feature and board data is loaded
1482 * at init time, we have to workaround this from host.
1483 * It is difficult to patch the firmware boot code,
1484 * but possible in theory.
1487 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1488 A_UINT32 ramReservedSz
;
1489 if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1490 param
= AR6003_REV2_BOARD_EXT_DATA_ADDRESS
;
1491 ramReservedSz
= AR6003_REV2_RAM_RESERVE_SIZE
;
1493 param
= AR6003_REV3_BOARD_EXT_DATA_ADDRESS
;
1494 ramReservedSz
= AR6003_REV3_RAM_RESERVE_SIZE
;
1496 if (BMIWriteMemory(ar
->arHifDevice
,
1497 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_ext_data
),
1498 (u8
*)¶m
, 4) != 0) {
1499 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
1500 ("BMIWriteMemory for "
1501 "hi_board_ext_data failed\n"));
1504 if (BMIWriteMemory(ar
->arHifDevice
,
1505 HOST_INTEREST_ITEM_ADDRESS(ar
,
1506 hi_end_RAM_reserve_sz
),
1507 (u8
*)&ramReservedSz
, 4) != 0) {
1508 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
1509 ("BMIWriteMemory for "
1510 "hi_end_RAM_reserve_sz failed\n"));
1515 /* since BMIInit is called in the driver layer, we have to set the block
1516 * size here for the target */
1518 if (ar6000_set_htc_params(ar
->arHifDevice
, ar
->arTargetType
,
1519 mbox_yield_limit
, 0)) {
1520 /* use default number of control buffers */
1524 if (setupbtdev
!= 0) {
1525 if (ar6000_set_hci_bridge_flags(ar
->arHifDevice
,
1535 init_netdev(struct net_device
*dev
, char *name
)
1537 dev
->netdev_ops
= &ar6000_netdev_ops
;
1538 dev
->watchdog_timeo
= AR6000_TX_TIMEOUT
;
1541 * We need the OS to provide us with more headroom in order to
1542 * perform dix to 802.3, WMI header encap, and the HTC header
1544 if (processDot11Hdr
) {
1545 dev
->hard_header_len
= sizeof(struct ieee80211_qosframe
) + sizeof(ATH_LLC_SNAP_HDR
) + sizeof(WMI_DATA_HDR
) + HTC_HEADER_LEN
+ WMI_MAX_TX_META_SZ
+ LINUX_HACK_FUDGE_FACTOR
;
1547 dev
->hard_header_len
= ETH_HLEN
+ sizeof(ATH_LLC_SNAP_HDR
) +
1548 sizeof(WMI_DATA_HDR
) + HTC_HEADER_LEN
+ WMI_MAX_TX_META_SZ
+ LINUX_HACK_FUDGE_FACTOR
;
1553 strcpy(dev
->name
, name
);
1556 #ifdef CONFIG_CHECKSUM_OFFLOAD
1558 dev
->features
|= NETIF_F_IP_CSUM
; /*advertise kernel capability to do TCP/UDP CSUM offload for IPV4*/
1565 static int __ath6kl_init_netdev(struct net_device
*dev
)
1570 r
= ar6000_init(dev
);
1574 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_avail: ar6000_init\n"));
1581 #ifdef HTC_RAW_INTERFACE
1582 static int ath6kl_init_netdev_wmi(struct net_device
*dev
)
1584 if (!eppingtest
&& bypasswmi
)
1587 return __ath6kl_init_netdev(dev
);
1590 static int ath6kl_init_netdev_wmi(struct net_device
*dev
)
1592 return __ath6kl_init_netdev(dev
);
1596 static int ath6kl_init_netdev(struct ar6_softc
*ar
)
1600 r
= ar6000_sysfs_bmi_get_config(ar
, wlaninitmode
);
1602 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
1604 "ar6000_sysfs_bmi_get_config failed\n"));
1608 return ath6kl_init_netdev_wmi(ar
->arNetDev
);
1612 * HTC Event handlers
1615 ar6000_avail_ev(void *context
, void *hif_handle
)
1618 struct net_device
*dev
;
1620 struct ar6_softc
*ar
;
1621 int device_index
= 0;
1622 struct htc_init_info htcInfo
;
1623 struct wireless_dev
*wdev
;
1625 struct hif_device_os_device_info osDevInfo
;
1627 memset(&osDevInfo
, 0, sizeof(osDevInfo
));
1628 if (HIFConfigureDevice(hif_handle
, HIF_DEVICE_GET_OS_DEVICE
,
1629 &osDevInfo
, sizeof(osDevInfo
))) {
1630 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s: Failed to get OS device instance\n", __func__
));
1634 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("ar6000_available\n"));
1636 for (i
=0; i
< MAX_AR6000
; i
++) {
1637 if (ar6000_devices
[i
] == NULL
) {
1642 if (i
== MAX_AR6000
) {
1643 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_available: max devices reached\n"));
1647 /* Save this. It gives a bit better readability especially since */
1648 /* we use another local "i" variable below. */
1651 wdev
= ar6k_cfg80211_init(osDevInfo
.pOSDevice
);
1653 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("%s: ar6k_cfg80211_init failed\n", __func__
));
1656 ar_netif
= wdev_priv(wdev
);
1658 if (ar_netif
== NULL
) {
1659 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("%s: Can't allocate ar6k priv memory\n", __func__
));
1663 A_MEMZERO(ar_netif
, sizeof(struct ar6_softc
));
1664 ar
= (struct ar6_softc
*)ar_netif
;
1667 wdev
->iftype
= NL80211_IFTYPE_STATION
;
1669 dev
= alloc_netdev_mq(0, "wlan%d", ether_setup
, 1);
1671 printk(KERN_CRIT
"AR6K: no memory for network device instance\n");
1672 ar6k_cfg80211_deinit(ar
);
1676 dev
->ieee80211_ptr
= wdev
;
1677 SET_NETDEV_DEV(dev
, wiphy_dev(wdev
->wiphy
));
1679 ar
->arNetworkType
= INFRA_NETWORK
;
1680 ar
->smeState
= SME_DISCONNECTED
;
1682 init_netdev(dev
, ifname
);
1686 ar
->arHifDevice
= hif_handle
;
1687 ar
->arWlanState
= WLAN_ENABLED
;
1688 ar
->arDeviceIndex
= device_index
;
1690 ar
->arWlanPowerState
= WLAN_POWER_STATE_ON
;
1691 ar
->arWlanOff
= false; /* We are in ON state */
1693 ar
->arWowState
= WLAN_WOW_STATE_NONE
;
1694 ar
->arBTOff
= true; /* BT chip assumed to be OFF */
1695 ar
->arBTSharing
= WLAN_CONFIG_BT_SHARING
;
1696 ar
->arWlanOffConfig
= WLAN_CONFIG_WLAN_OFF
;
1697 ar
->arSuspendConfig
= WLAN_CONFIG_PM_SUSPEND
;
1698 ar
->arWow2Config
= WLAN_CONFIG_PM_WOW2
;
1699 #endif /* CONFIG_PM */
1701 A_INIT_TIMER(&ar
->arHBChallengeResp
.timer
, ar6000_detect_error
, dev
);
1702 ar
->arHBChallengeResp
.seqNum
= 0;
1703 ar
->arHBChallengeResp
.outstanding
= false;
1704 ar
->arHBChallengeResp
.missCnt
= 0;
1705 ar
->arHBChallengeResp
.frequency
= AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT
;
1706 ar
->arHBChallengeResp
.missThres
= AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT
;
1708 ar6000_init_control_info(ar
);
1709 init_waitqueue_head(&arEvent
);
1710 sema_init(&ar
->arSem
, 1);
1711 ar
->bIsDestroyProgress
= false;
1713 INIT_HTC_PACKET_QUEUE(&ar
->amsdu_rx_buffer_queue
);
1715 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
1716 A_INIT_TIMER(&aptcTimer
, aptcTimerHandler
, ar
);
1717 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
1719 A_INIT_TIMER(&ar
->disconnect_timer
, disconnect_timer_handler
, dev
);
1723 ar6000_sysfs_bmi_init(ar
);
1726 struct bmi_target_info targ_info
;
1728 r
= BMIGetTargetInfo(ar
->arHifDevice
, &targ_info
);
1730 goto avail_ev_failed
;
1732 ar
->arVersion
.target_ver
= targ_info
.target_ver
;
1733 ar
->arTargetType
= targ_info
.target_type
;
1736 r
= ar6000_configure_target(ar
);
1738 goto avail_ev_failed
;
1740 A_MEMZERO(&htcInfo
,sizeof(htcInfo
));
1741 htcInfo
.pContext
= ar
;
1742 htcInfo
.TargetFailure
= ar6000_target_failure
;
1744 ar
->arHtcTarget
= HTCCreate(ar
->arHifDevice
,&htcInfo
);
1746 if (!ar
->arHtcTarget
) {
1748 goto avail_ev_failed
;
1751 spin_lock_init(&ar
->arLock
);
1754 ar
->arWapiEnable
= 0;
1759 /*if external frame work is also needed, change and use an extended rxMetaVerion*/
1760 ar
->rxMetaVersion
=WMI_META_VERSION_2
;
1763 ar
->aggr_cntxt
= aggr_init(ar6000_alloc_netbufs
);
1764 if (!ar
->aggr_cntxt
) {
1765 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() Failed to initialize aggr.\n", __func__
));
1767 goto avail_ev_failed
;
1770 aggr_register_rx_dispatcher(ar
->aggr_cntxt
, (void *)dev
, ar6000_deliver_frames_to_nw_stack
);
1772 HIFClaimDevice(ar
->arHifDevice
, ar
);
1774 /* We only register the device in the global list if we succeed. */
1775 /* If the device is in the global list, it will be destroyed */
1776 /* when the module is unloaded. */
1777 ar6000_devices
[device_index
] = dev
;
1779 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("BMI enabled: %d\n", wlaninitmode
));
1780 if ((wlaninitmode
== WLAN_INIT_MODE_UDEV
) ||
1781 (wlaninitmode
== WLAN_INIT_MODE_DRV
)) {
1782 r
= ath6kl_init_netdev(ar
);
1784 goto avail_ev_failed
;
1787 /* This runs the init function if registered */
1788 r
= register_netdev(dev
);
1790 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_avail: register_netdev failed\n"));
1791 ar6000_destroy(dev
, 0);
1795 is_netdev_registered
= 1;
1797 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
1799 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
1800 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("ar6000_avail: name=%s hifdevice=0x%lx, dev=0x%lx (%d), ar=0x%lx\n",
1801 dev
->name
, (unsigned long)ar
->arHifDevice
, (unsigned long)dev
, device_index
,
1802 (unsigned long)ar
));
1806 ar6000_sysfs_bmi_deinit(ar
);
1811 static void ar6000_target_failure(void *Instance
, int Status
)
1813 struct ar6_softc
*ar
= (struct ar6_softc
*)Instance
;
1814 WMI_TARGET_ERROR_REPORT_EVENT errEvent
;
1815 static bool sip
= false;
1819 printk(KERN_ERR
"ar6000_target_failure: target asserted \n");
1821 if (timer_pending(&ar
->arHBChallengeResp
.timer
)) {
1822 A_UNTIMEOUT(&ar
->arHBChallengeResp
.timer
);
1825 /* try dumping target assertion information (if any) */
1826 ar6000_dump_target_assert_info(ar
->arHifDevice
,ar
->arTargetType
);
1829 * Fetch the logs from the target via the diagnostic
1832 ar6000_dbglog_get_debug_logs(ar
);
1834 /* Report the error only once */
1837 errEvent
.errorVal
= WMI_TARGET_COM_ERR
|
1838 WMI_TARGET_FATAL_ERR
;
1844 ar6000_unavail_ev(void *context
, void *hif_handle
)
1846 struct ar6_softc
*ar
= (struct ar6_softc
*)context
;
1847 /* NULL out it's entry in the global list */
1848 ar6000_devices
[ar
->arDeviceIndex
] = NULL
;
1849 ar6000_destroy(ar
->arNetDev
, 1);
1855 ar6000_restart_endpoint(struct net_device
*dev
)
1858 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
1862 if ( (status
=ar6000_configure_target(ar
))!= 0)
1864 if ( (status
=ar6000_sysfs_bmi_get_config(ar
, wlaninitmode
)) != 0)
1866 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n"));
1870 status
= (ar6000_init(dev
)==0) ? 0 : A_ERROR
;
1876 if (ar
->arSsidLen
&& ar
->arWlanState
== WLAN_ENABLED
) {
1877 ar6000_connect_to_ap(ar
);
1885 ar6000_devices
[ar
->arDeviceIndex
] = NULL
;
1886 ar6000_destroy(ar
->arNetDev
, 1);
1890 ar6000_stop_endpoint(struct net_device
*dev
, bool keepprofile
, bool getdbglogs
)
1892 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
1894 /* Stop the transmit queues */
1895 netif_stop_queue(dev
);
1897 /* Disable the target and the interrupts associated with it */
1898 if (ar
->arWmiReady
== true)
1902 bool disconnectIssued
;
1904 disconnectIssued
= (ar
->arConnected
) || (ar
->arConnectPending
);
1905 ar6000_disconnect(ar
);
1907 ar6000_init_profile_info(ar
);
1910 A_UNTIMEOUT(&ar
->disconnect_timer
);
1913 ar6000_dbglog_get_debug_logs(ar
);
1916 ar
->arWmiReady
= false;
1917 wmi_shutdown(ar
->arWmi
);
1918 ar
->arWmiEnabled
= false;
1921 * After wmi_shudown all WMI events will be dropped.
1922 * We need to cleanup the buffers allocated in AP mode
1923 * and give disconnect notification to stack, which usually
1924 * happens in the disconnect_event.
1925 * Simulate the disconnect_event by calling the function directly.
1926 * Sometimes disconnect_event will be received when the debug logs
1929 if (disconnectIssued
) {
1930 if(ar
->arNetworkType
& AP_NETWORK
) {
1931 ar6000_disconnect_event(ar
, DISCONNECT_CMD
, bcast_mac
, 0, NULL
, 0);
1933 ar6000_disconnect_event(ar
, DISCONNECT_CMD
, ar
->arBssid
, 0, NULL
, 0);
1936 ar
->user_savedkeys_stat
= USER_SAVEDKEYS_STAT_INIT
;
1937 ar
->user_key_ctrl
= 0;
1940 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("%s(): WMI stopped\n", __func__
));
1944 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("%s(): WMI not ready 0x%lx 0x%lx\n",
1945 __func__
, (unsigned long) ar
, (unsigned long) ar
->arWmi
));
1947 /* Shut down WMI if we have started it */
1948 if(ar
->arWmiEnabled
== true)
1950 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("%s(): Shut down WMI\n", __func__
));
1951 wmi_shutdown(ar
->arWmi
);
1952 ar
->arWmiEnabled
= false;
1957 if (ar
->arHtcTarget
!= NULL
) {
1958 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
1959 if (NULL
!= ar6kHciTransCallbacks
.cleanupTransport
) {
1960 ar6kHciTransCallbacks
.cleanupTransport(NULL
);
1963 // FIXME: workaround to reset BT's UART baud rate to default
1964 if (NULL
!= ar
->exitCallback
) {
1965 struct ar3k_config_info ar3kconfig
;
1968 A_MEMZERO(&ar3kconfig
,sizeof(ar3kconfig
));
1969 ar6000_set_default_ar3kconfig(ar
, (void *)&ar3kconfig
);
1970 status
= ar
->exitCallback(&ar3kconfig
);
1972 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Failed to reset AR3K baud rate! \n"));
1977 ar6000_cleanup_hci(ar
);
1979 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,(" Shutting down HTC .... \n"));
1981 HTCStop(ar
->arHtcTarget
);
1985 /* try to reset the device if we can
1986 * The driver may have been configure NOT to reset the target during
1987 * a debug session */
1988 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,(" Attempting to reset target on instance destroy.... \n"));
1989 if (ar
->arHifDevice
!= NULL
) {
1990 bool coldReset
= (ar
->arTargetType
== TARGET_TYPE_AR6003
) ? true: false;
1991 ar6000_reset_device(ar
->arHifDevice
, ar
->arTargetType
, true, coldReset
);
1994 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,(" Host does not want target reset. \n"));
1996 /* Done with cookies */
1997 ar6000_cookie_cleanup(ar
);
1999 /* cleanup any allocated AMSDU buffers */
2000 ar6000_cleanup_amsdu_rxbufs(ar
);
2003 * We need to differentiate between the surprise and planned removal of the
2004 * device because of the following consideration:
2005 * - In case of surprise removal, the hcd already frees up the pending
2006 * for the device and hence there is no need to unregister the function
2007 * driver inorder to get these requests. For planned removal, the function
2008 * driver has to explicitly unregister itself to have the hcd return all the
2009 * pending requests before the data structures for the devices are freed up.
2010 * Note that as per the current implementation, the function driver will
2011 * end up releasing all the devices since there is no API to selectively
2012 * release a particular device.
2013 * - Certain commands issued to the target can be skipped for surprise
2014 * removal since they will anyway not go through.
2017 ar6000_destroy(struct net_device
*dev
, unsigned int unregister
)
2019 struct ar6_softc
*ar
;
2021 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("+ar6000_destroy \n"));
2023 if((dev
== NULL
) || ((ar
= ar6k_priv(dev
)) == NULL
))
2025 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s(): Failed to get device structure.\n", __func__
));
2029 ar
->bIsDestroyProgress
= true;
2031 if (down_interruptible(&ar
->arSem
)) {
2032 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s(): down_interruptible failed \n", __func__
));
2036 if (ar
->arWlanPowerState
!= WLAN_POWER_STATE_CUT_PWR
) {
2037 /* only stop endpoint if we are not stop it in suspend_ev */
2038 ar6000_stop_endpoint(dev
, false, true);
2041 ar
->arWlanState
= WLAN_DISABLED
;
2042 if (ar
->arHtcTarget
!= NULL
) {
2044 HTCDestroy(ar
->arHtcTarget
);
2046 if (ar
->arHifDevice
!= NULL
) {
2047 /*release the device so we do not get called back on remove incase we
2048 * we're explicity destroyed by module unload */
2049 HIFReleaseDevice(ar
->arHifDevice
);
2050 HIFShutDownDevice(ar
->arHifDevice
);
2052 aggr_module_destroy(ar
->aggr_cntxt
);
2054 /* Done with cookies */
2055 ar6000_cookie_cleanup(ar
);
2057 /* cleanup any allocated AMSDU buffers */
2058 ar6000_cleanup_amsdu_rxbufs(ar
);
2060 ar6000_sysfs_bmi_deinit(ar
);
2065 /* Clear the tx counters */
2066 memset(tx_attempt
, 0, sizeof(tx_attempt
));
2067 memset(tx_post
, 0, sizeof(tx_post
));
2068 memset(tx_complete
, 0, sizeof(tx_complete
));
2070 #ifdef HTC_RAW_INTERFACE
2072 kfree(ar
->arRawHtc
);
2073 ar
->arRawHtc
= NULL
;
2076 /* Free up the device data structure */
2077 if (unregister
&& is_netdev_registered
) {
2078 unregister_netdev(dev
);
2079 is_netdev_registered
= 0;
2083 ar6k_cfg80211_deinit(ar
);
2085 #ifdef CONFIG_AP_VIRTUL_ADAPTER_SUPPORT
2086 ar6000_remove_ap_interface();
2087 #endif /*CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
2089 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("-ar6000_destroy \n"));
2092 static void disconnect_timer_handler(unsigned long ptr
)
2094 struct net_device
*dev
= (struct net_device
*)ptr
;
2095 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2097 A_UNTIMEOUT(&ar
->disconnect_timer
);
2099 ar6000_init_profile_info(ar
);
2100 ar6000_disconnect(ar
);
2103 static void ar6000_detect_error(unsigned long ptr
)
2105 struct net_device
*dev
= (struct net_device
*)ptr
;
2106 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2107 WMI_TARGET_ERROR_REPORT_EVENT errEvent
;
2109 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
2111 if (ar
->arHBChallengeResp
.outstanding
) {
2112 ar
->arHBChallengeResp
.missCnt
++;
2114 ar
->arHBChallengeResp
.missCnt
= 0;
2117 if (ar
->arHBChallengeResp
.missCnt
> ar
->arHBChallengeResp
.missThres
) {
2118 /* Send Error Detect event to the application layer and do not reschedule the error detection module timer */
2119 ar
->arHBChallengeResp
.missCnt
= 0;
2120 ar
->arHBChallengeResp
.seqNum
= 0;
2121 errEvent
.errorVal
= WMI_TARGET_COM_ERR
| WMI_TARGET_FATAL_ERR
;
2122 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
2126 /* Generate the sequence number for the next challenge */
2127 ar
->arHBChallengeResp
.seqNum
++;
2128 ar
->arHBChallengeResp
.outstanding
= true;
2130 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
2132 /* Send the challenge on the control channel */
2133 if (wmi_get_challenge_resp_cmd(ar
->arWmi
, ar
->arHBChallengeResp
.seqNum
, DRV_HB_CHALLENGE
) != 0) {
2134 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to send heart beat challenge\n"));
2138 /* Reschedule the timer for the next challenge */
2139 A_TIMEOUT_MS(&ar
->arHBChallengeResp
.timer
, ar
->arHBChallengeResp
.frequency
* 1000, 0);
2142 void ar6000_init_profile_info(struct ar6_softc
*ar
)
2145 A_MEMZERO(ar
->arSsid
, sizeof(ar
->arSsid
));
2148 case HI_OPTION_FW_MODE_IBSS
:
2149 ar
->arNetworkType
= ar
->arNextMode
= ADHOC_NETWORK
;
2151 case HI_OPTION_FW_MODE_BSS_STA
:
2152 ar
->arNetworkType
= ar
->arNextMode
= INFRA_NETWORK
;
2154 case HI_OPTION_FW_MODE_AP
:
2155 ar
->arNetworkType
= ar
->arNextMode
= AP_NETWORK
;
2159 ar
->arDot11AuthMode
= OPEN_AUTH
;
2160 ar
->arAuthMode
= NONE_AUTH
;
2161 ar
->arPairwiseCrypto
= NONE_CRYPT
;
2162 ar
->arPairwiseCryptoLen
= 0;
2163 ar
->arGroupCrypto
= NONE_CRYPT
;
2164 ar
->arGroupCryptoLen
= 0;
2165 A_MEMZERO(ar
->arWepKeyList
, sizeof(ar
->arWepKeyList
));
2166 A_MEMZERO(ar
->arReqBssid
, sizeof(ar
->arReqBssid
));
2167 A_MEMZERO(ar
->arBssid
, sizeof(ar
->arBssid
));
2168 ar
->arBssChannel
= 0;
2172 ar6000_init_control_info(struct ar6_softc
*ar
)
2174 ar
->arWmiEnabled
= false;
2175 ar6000_init_profile_info(ar
);
2176 ar
->arDefTxKeyIndex
= 0;
2177 A_MEMZERO(ar
->arWepKeyList
, sizeof(ar
->arWepKeyList
));
2178 ar
->arChannelHint
= 0;
2179 ar
->arListenIntervalT
= A_DEFAULT_LISTEN_INTERVAL
;
2180 ar
->arListenIntervalB
= 0;
2181 ar
->arVersion
.host_ver
= AR6K_SW_VERSION
;
2184 ar
->arTxPwrSet
= false;
2186 ar
->arBeaconInterval
= 0;
2188 ar
->arMaxRetries
= 0;
2189 ar
->arWmmEnabled
= true;
2191 ar
->scan_triggered
= 0;
2192 A_MEMZERO(&ar
->scParams
, sizeof(ar
->scParams
));
2193 ar
->scParams
.shortScanRatio
= WMI_SHORTSCANRATIO_DEFAULT
;
2194 ar
->scParams
.scanCtrlFlags
= DEFAULT_SCAN_CTRL_FLAGS
;
2196 /* Initialize the AP mode state info */
2199 A_MEMZERO((u8
*)ar
->sta_list
, AP_MAX_NUM_STA
* sizeof(sta_t
));
2201 /* init the Mutexes */
2202 A_MUTEX_INIT(&ar
->mcastpsqLock
);
2204 /* Init the PS queues */
2205 for (ctr
=0; ctr
< AP_MAX_NUM_STA
; ctr
++) {
2206 A_MUTEX_INIT(&ar
->sta_list
[ctr
].psqLock
);
2207 A_NETBUF_QUEUE_INIT(&ar
->sta_list
[ctr
].psq
);
2210 ar
->ap_profile_flag
= 0;
2211 A_NETBUF_QUEUE_INIT(&ar
->mcastpsq
);
2213 memcpy(ar
->ap_country_code
, DEF_AP_COUNTRY_CODE
, 3);
2214 ar
->ap_wmode
= DEF_AP_WMODE_G
;
2215 ar
->ap_dtim_period
= DEF_AP_DTIM
;
2216 ar
->ap_beacon_interval
= DEF_BEACON_INTERVAL
;
2221 ar6000_open(struct net_device
*dev
)
2223 unsigned long flags
;
2224 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2226 spin_lock_irqsave(&ar
->arLock
, flags
);
2228 if(ar
->arWlanState
== WLAN_DISABLED
) {
2229 ar
->arWlanState
= WLAN_ENABLED
;
2232 if( ar
->arConnected
|| bypasswmi
) {
2233 netif_carrier_on(dev
);
2234 /* Wake up the queues */
2235 netif_wake_queue(dev
);
2238 netif_carrier_off(dev
);
2240 spin_unlock_irqrestore(&ar
->arLock
, flags
);
2245 ar6000_close(struct net_device
*dev
)
2247 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2248 netif_stop_queue(dev
);
2250 ar6000_disconnect(ar
);
2252 if(ar
->arWmiReady
== true) {
2253 if (wmi_scanparams_cmd(ar
->arWmi
, 0xFFFF, 0,
2254 0, 0, 0, 0, 0, 0, 0, 0) != 0) {
2257 ar
->arWlanState
= WLAN_DISABLED
;
2259 ar6k_cfg80211_scanComplete_event(ar
, A_ECANCELED
);
2264 /* connect to a service */
2265 static int ar6000_connectservice(struct ar6_softc
*ar
,
2266 struct htc_service_connect_req
*pConnect
,
2270 struct htc_service_connect_resp response
;
2274 A_MEMZERO(&response
,sizeof(response
));
2276 status
= HTCConnectService(ar
->arHtcTarget
,
2281 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" Failed to connect to %s service status:%d \n",
2285 switch (pConnect
->ServiceID
) {
2286 case WMI_CONTROL_SVC
:
2287 if (ar
->arWmiEnabled
) {
2288 /* set control endpoint for WMI use */
2289 wmi_set_control_ep(ar
->arWmi
, response
.Endpoint
);
2291 /* save EP for fast lookup */
2292 ar
->arControlEp
= response
.Endpoint
;
2294 case WMI_DATA_BE_SVC
:
2295 arSetAc2EndpointIDMap(ar
, WMM_AC_BE
, response
.Endpoint
);
2297 case WMI_DATA_BK_SVC
:
2298 arSetAc2EndpointIDMap(ar
, WMM_AC_BK
, response
.Endpoint
);
2300 case WMI_DATA_VI_SVC
:
2301 arSetAc2EndpointIDMap(ar
, WMM_AC_VI
, response
.Endpoint
);
2303 case WMI_DATA_VO_SVC
:
2304 arSetAc2EndpointIDMap(ar
, WMM_AC_VO
, response
.Endpoint
);
2307 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ServiceID not mapped %d\n", pConnect
->ServiceID
));
2317 void ar6000_TxDataCleanup(struct ar6_softc
*ar
)
2319 /* flush all the data (non-control) streams
2320 * we only flush packets that are tagged as data, we leave any control packets that
2321 * were in the TX queues alone */
2322 HTCFlushEndpoint(ar
->arHtcTarget
,
2323 arAc2EndpointID(ar
, WMM_AC_BE
),
2325 HTCFlushEndpoint(ar
->arHtcTarget
,
2326 arAc2EndpointID(ar
, WMM_AC_BK
),
2328 HTCFlushEndpoint(ar
->arHtcTarget
,
2329 arAc2EndpointID(ar
, WMM_AC_VI
),
2331 HTCFlushEndpoint(ar
->arHtcTarget
,
2332 arAc2EndpointID(ar
, WMM_AC_VO
),
2337 ar6000_ac2_endpoint_id ( void * devt
, u8 ac
)
2339 struct ar6_softc
*ar
= (struct ar6_softc
*) devt
;
2340 return(arAc2EndpointID(ar
, ac
));
2343 u8
ar6000_endpoint_id2_ac(void * devt
, HTC_ENDPOINT_ID ep
)
2345 struct ar6_softc
*ar
= (struct ar6_softc
*) devt
;
2346 return(arEndpoint2Ac(ar
, ep
));
2349 #if defined(CONFIG_ATH6KL_ENABLE_COEXISTENCE)
2350 static int ath6kl_config_btcoex_params(struct ar6_softc
*ar
)
2353 WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD sbcb_cmd
;
2354 WMI_SET_BTCOEX_FE_ANT_CMD sbfa_cmd
;
2356 /* Configure the type of BT collocated with WLAN */
2357 memset(&sbcb_cmd
, 0, sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD
));
2358 sbcb_cmd
.btcoexCoLocatedBTdev
= ATH6KL_BT_DEV
;
2360 r
= wmi_set_btcoex_colocated_bt_dev_cmd(ar
->arWmi
, &sbcb_cmd
);
2363 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2364 ("Unable to set collocated BT type\n"));
2368 /* Configure the type of BT collocated with WLAN */
2369 memset(&sbfa_cmd
, 0, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD
));
2371 sbfa_cmd
.btcoexFeAntType
= ATH6KL_BT_ANTENNA
;
2373 r
= wmi_set_btcoex_fe_ant_cmd(ar
->arWmi
, &sbfa_cmd
);
2375 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2376 ("Unable to set fornt end antenna configuration\n"));
2383 static int ath6kl_config_btcoex_params(struct ar6_softc
*ar
)
2387 #endif /* CONFIG_ATH6KL_ENABLE_COEXISTENCE */
2390 * This function applies WLAN specific configuration defined in wlan_config.h
2392 int ar6000_target_config_wlan_params(struct ar6_softc
*ar
)
2396 #ifdef CONFIG_HOST_TCMD_SUPPORT
2397 if (ar
->arTargetMode
!= AR6000_WLAN_MODE
) {
2400 #endif /* CONFIG_HOST_TCMD_SUPPORT */
2403 * configure the device for rx dot11 header rules 0,0 are the default values
2404 * therefore this command can be skipped if the inputs are 0,FALSE,FALSE.Required
2405 * if checksum offload is needed. Set RxMetaVersion to 2
2407 if ((wmi_set_rx_frame_format_cmd(ar
->arWmi
,ar
->rxMetaVersion
, processDot11Hdr
, processDot11Hdr
)) != 0) {
2408 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set the rx frame format.\n"));
2412 status
= ath6kl_config_btcoex_params(ar
);
2416 #if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
2417 if ((wmi_pmparams_cmd(ar
->arWmi
, 0, 1, 0, 0, 1, IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
)) != 0) {
2418 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set power save fail event policy\n"));
2423 #if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP
2424 if ((wmi_set_lpreamble_cmd(ar
->arWmi
, 0, WMI_DONOT_IGNORE_BARKER_IN_ERP
)) != 0) {
2425 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set barker preamble policy\n"));
2430 if ((wmi_set_keepalive_cmd(ar
->arWmi
, WLAN_CONFIG_KEEP_ALIVE_INTERVAL
)) != 0) {
2431 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set keep alive interval\n"));
2435 #if WLAN_CONFIG_DISABLE_11N
2437 WMI_SET_HT_CAP_CMD htCap
;
2439 memset(&htCap
, 0, sizeof(WMI_SET_HT_CAP_CMD
));
2441 if ((wmi_set_ht_cap_cmd(ar
->arWmi
, &htCap
)) != 0) {
2442 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set ht capabilities \n"));
2447 if ((wmi_set_ht_cap_cmd(ar
->arWmi
, &htCap
)) != 0) {
2448 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set ht capabilities \n"));
2452 #endif /* WLAN_CONFIG_DISABLE_11N */
2454 #ifdef ATH6K_CONFIG_OTA_MODE
2455 if ((wmi_powermode_cmd(ar
->arWmi
, MAX_PERF_POWER
)) != 0) {
2456 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set power mode \n"));
2461 if ((wmi_disctimeout_cmd(ar
->arWmi
, WLAN_CONFIG_DISCONNECT_TIMEOUT
)) != 0) {
2462 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set disconnect timeout \n"));
2466 #if WLAN_CONFIG_DISABLE_TX_BURSTING
2467 if ((wmi_set_wmm_txop(ar
->arWmi
, WMI_TXOP_DISABLED
)) != 0) {
2468 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set txop bursting \n"));
2476 /* This function does one time initialization for the lifetime of the device */
2477 int ar6000_init(struct net_device
*dev
)
2479 struct ar6_softc
*ar
;
2485 if((ar
= ar6k_priv(dev
)) == NULL
)
2490 if (wlaninitmode
== WLAN_INIT_MODE_USR
|| wlaninitmode
== WLAN_INIT_MODE_DRV
) {
2492 ar6000_update_bdaddr(ar
);
2494 if (enablerssicompensation
) {
2495 ar6000_copy_cust_data_from_target(ar
->arHifDevice
, ar
->arTargetType
);
2496 read_rssi_compensation_param(ar
);
2497 for (i
=-95; i
<=0; i
++) {
2498 rssi_compensation_table
[0-i
] = rssi_compensation_calc(ar
,i
);
2506 /* Do we need to finish the BMI phase */
2507 if ((wlaninitmode
== WLAN_INIT_MODE_USR
|| wlaninitmode
== WLAN_INIT_MODE_DRV
) &&
2508 (BMIDone(ar
->arHifDevice
) != 0))
2511 goto ar6000_init_done
;
2517 if (ar
->arVersion
.host_ver
!= ar
->arVersion
.target_ver
) {
2518 A_PRINTF("WARNING: Host version 0x%x does not match Target "
2520 ar
->arVersion
.host_ver
, ar
->arVersion
.target_ver
);
2524 /* Indicate that WMI is enabled (although not ready yet) */
2525 ar
->arWmiEnabled
= true;
2526 if ((ar
->arWmi
= wmi_init((void *) ar
)) == NULL
)
2528 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() Failed to initialize WMI.\n", __func__
));
2530 goto ar6000_init_done
;
2533 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() Got WMI @ 0x%lx.\n", __func__
,
2534 (unsigned long) ar
->arWmi
));
2538 struct htc_service_connect_req connect
;
2540 /* the reason we have to wait for the target here is that the driver layer
2541 * has to init BMI in order to set the host block size,
2543 status
= HTCWaitTarget(ar
->arHtcTarget
);
2549 A_MEMZERO(&connect
,sizeof(connect
));
2550 /* meta data is unused for now */
2551 connect
.pMetaData
= NULL
;
2552 connect
.MetaDataLength
= 0;
2553 /* these fields are the same for all service endpoints */
2554 connect
.EpCallbacks
.pContext
= ar
;
2555 connect
.EpCallbacks
.EpTxCompleteMultiple
= ar6000_tx_complete
;
2556 connect
.EpCallbacks
.EpRecv
= ar6000_rx
;
2557 connect
.EpCallbacks
.EpRecvRefill
= ar6000_rx_refill
;
2558 connect
.EpCallbacks
.EpSendFull
= ar6000_tx_queue_full
;
2559 /* set the max queue depth so that our ar6000_tx_queue_full handler gets called.
2560 * Linux has the peculiarity of not providing flow control between the
2561 * NIC and the network stack. There is no API to indicate that a TX packet
2562 * was sent which could provide some back pressure to the network stack.
2563 * Under linux you would have to wait till the network stack consumed all sk_buffs
2564 * before any back-flow kicked in. Which isn't very friendly.
2565 * So we have to manage this ourselves */
2566 connect
.MaxSendQueueDepth
= MAX_DEFAULT_SEND_QUEUE_DEPTH
;
2567 connect
.EpCallbacks
.RecvRefillWaterMark
= AR6000_MAX_RX_BUFFERS
/ 4; /* set to 25 % */
2568 if (0 == connect
.EpCallbacks
.RecvRefillWaterMark
) {
2569 connect
.EpCallbacks
.RecvRefillWaterMark
++;
2571 /* connect to control service */
2572 connect
.ServiceID
= WMI_CONTROL_SVC
;
2573 status
= ar6000_connectservice(ar
,
2580 connect
.LocalConnectionFlags
|= HTC_LOCAL_CONN_FLAGS_ENABLE_SEND_BUNDLE_PADDING
;
2581 /* limit the HTC message size on the send path, although we can receive A-MSDU frames of
2582 * 4K, we will only send ethernet-sized (802.3) frames on the send path. */
2583 connect
.MaxSendMsgSize
= WMI_MAX_TX_DATA_FRAME_LENGTH
;
2585 /* to reduce the amount of committed memory for larger A_MSDU frames, use the recv-alloc threshold
2586 * mechanism for larger packets */
2587 connect
.EpCallbacks
.RecvAllocThreshold
= AR6000_BUFFER_SIZE
;
2588 connect
.EpCallbacks
.EpRecvAllocThresh
= ar6000_alloc_amsdu_rxbuf
;
2590 /* for the remaining data services set the connection flag to reduce dribbling,
2591 * if configured to do so */
2592 if (reduce_credit_dribble
) {
2593 connect
.ConnectionFlags
|= HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE
;
2594 /* the credit dribble trigger threshold is (reduce_credit_dribble - 1) for a value
2596 connect
.ConnectionFlags
&= ~HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK
;
2597 connect
.ConnectionFlags
|=
2598 ((u16
)reduce_credit_dribble
- 1) & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK
;
2600 /* connect to best-effort service */
2601 connect
.ServiceID
= WMI_DATA_BE_SVC
;
2603 status
= ar6000_connectservice(ar
,
2610 /* connect to back-ground
2611 * map this to WMI LOW_PRI */
2612 connect
.ServiceID
= WMI_DATA_BK_SVC
;
2613 status
= ar6000_connectservice(ar
,
2620 /* connect to Video service, map this to
2622 connect
.ServiceID
= WMI_DATA_VI_SVC
;
2623 status
= ar6000_connectservice(ar
,
2630 /* connect to VO service, this is currently not
2631 * mapped to a WMI priority stream due to historical reasons.
2632 * WMI originally defined 3 priorities over 3 mailboxes
2633 * We can change this when WMI is reworked so that priorities are not
2634 * dependent on mailboxes */
2635 connect
.ServiceID
= WMI_DATA_VO_SVC
;
2636 status
= ar6000_connectservice(ar
,
2643 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_BE
) != 0);
2644 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_BK
) != 0);
2645 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_VI
) != 0);
2646 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_VO
) != 0);
2648 /* setup access class priority mappings */
2649 ar
->arAcStreamPriMap
[WMM_AC_BK
] = 0; /* lowest */
2650 ar
->arAcStreamPriMap
[WMM_AC_BE
] = 1; /* */
2651 ar
->arAcStreamPriMap
[WMM_AC_VI
] = 2; /* */
2652 ar
->arAcStreamPriMap
[WMM_AC_VO
] = 3; /* highest */
2654 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
2655 if (setuphci
&& (NULL
!= ar6kHciTransCallbacks
.setupTransport
)) {
2656 struct hci_transport_misc_handles hciHandles
;
2658 hciHandles
.netDevice
= ar
->arNetDev
;
2659 hciHandles
.hifDevice
= ar
->arHifDevice
;
2660 hciHandles
.htcHandle
= ar
->arHtcTarget
;
2661 status
= (int)(ar6kHciTransCallbacks
.setupTransport(&hciHandles
));
2666 status
= ar6000_setup_hci(ar
);
2674 goto ar6000_init_done
;
2680 if (BMIReadMemory(ar
->arHifDevice
,
2681 HOST_INTEREST_ITEM_ADDRESS(ar
,
2685 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2686 ("BMIReadMemory forsetting "
2687 "regscanmode failed\n"));
2691 if (regscanmode
== 1)
2692 param
|= HI_OPTION_SKIP_REG_SCAN
;
2693 else if (regscanmode
== 2)
2694 param
|= HI_OPTION_INIT_REG_SCAN
;
2696 if (BMIWriteMemory(ar
->arHifDevice
,
2697 HOST_INTEREST_ITEM_ADDRESS(ar
,
2701 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2702 ("BMIWriteMemory forsetting "
2703 "regscanmode failed\n"));
2706 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("Regulatory scan mode set\n"));
2710 * give our connected endpoints some buffers
2713 ar6000_rx_refill(ar
, ar
->arControlEp
);
2714 ar6000_rx_refill(ar
, arAc2EndpointID(ar
,WMM_AC_BE
));
2717 * We will post the receive buffers only for SPE or endpoint ping testing so we are
2718 * making it conditional on the 'bypasswmi' flag.
2721 ar6000_rx_refill(ar
,arAc2EndpointID(ar
,WMM_AC_BK
));
2722 ar6000_rx_refill(ar
,arAc2EndpointID(ar
,WMM_AC_VI
));
2723 ar6000_rx_refill(ar
,arAc2EndpointID(ar
,WMM_AC_VO
));
2726 /* allocate some buffers that handle larger AMSDU frames */
2727 ar6000_refill_amsdu_rxbufs(ar
,AR6000_MAX_AMSDU_RX_BUFFERS
);
2729 /* setup credit distribution */
2730 ar6000_setup_credit_dist(ar
->arHtcTarget
, &ar
->arCreditStateInfo
);
2732 /* Since cookies are used for HTC transports, they should be */
2733 /* initialized prior to enabling HTC. */
2734 ar6000_cookie_init(ar
);
2737 status
= HTCStart(ar
->arHtcTarget
);
2740 if (ar
->arWmiEnabled
== true) {
2741 wmi_shutdown(ar
->arWmi
);
2742 ar
->arWmiEnabled
= false;
2745 ar6000_cookie_cleanup(ar
);
2747 goto ar6000_init_done
;
2751 /* Wait for Wmi event to be ready */
2752 timeleft
= wait_event_interruptible_timeout(arEvent
,
2753 (ar
->arWmiReady
== true), wmitimeout
* HZ
);
2755 if (ar
->arVersion
.abi_ver
!= AR6K_ABI_VERSION
) {
2756 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ABI Version mismatch: Host(0x%x), Target(0x%x)\n", AR6K_ABI_VERSION
, ar
->arVersion
.abi_ver
));
2757 #ifndef ATH6K_SKIP_ABI_VERSION_CHECK
2759 goto ar6000_init_done
;
2760 #endif /* ATH6K_SKIP_ABI_VERSION_CHECK */
2763 if(!timeleft
|| signal_pending(current
))
2765 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("WMI is not ready or wait was interrupted\n"));
2767 goto ar6000_init_done
;
2770 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() WMI is ready\n", __func__
));
2772 /* Communicate the wmi protocol verision to the target */
2773 if ((ar6000_set_host_app_area(ar
)) != 0) {
2774 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set the host app area\n"));
2776 ar6000_target_config_wlan_params(ar
);
2779 ar
->arNumDataEndPts
= 1;
2782 /* for tests like endpoint ping, the MAC address needs to be non-zero otherwise
2783 * the data path through a raw socket is disabled */
2784 dev
->dev_addr
[0] = 0x00;
2785 dev
->dev_addr
[1] = 0x01;
2786 dev
->dev_addr
[2] = 0x02;
2787 dev
->dev_addr
[3] = 0xAA;
2788 dev
->dev_addr
[4] = 0xBB;
2789 dev
->dev_addr
[5] = 0xCC;
2801 ar6000_bitrate_rx(void *devt
, s32 rateKbps
)
2803 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2805 ar
->arBitRate
= rateKbps
;
2810 ar6000_ratemask_rx(void *devt
, u32 ratemask
)
2812 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2814 ar
->arRateMask
= ratemask
;
2819 ar6000_txPwr_rx(void *devt
, u8 txPwr
)
2821 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2823 ar
->arTxPwr
= txPwr
;
2829 ar6000_channelList_rx(void *devt
, s8 numChan
, u16
*chanList
)
2831 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2833 memcpy(ar
->arChannelList
, chanList
, numChan
* sizeof (u16
));
2834 ar
->arNumChannels
= numChan
;
2839 u8
ar6000_ibss_map_epid(struct sk_buff
*skb
, struct net_device
*dev
, u32
*mapNo
)
2841 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2843 ATH_MAC_HDR
*macHdr
;
2847 datap
= A_NETBUF_DATA(skb
);
2848 macHdr
= (ATH_MAC_HDR
*)(datap
+ sizeof(WMI_DATA_HDR
));
2849 if (IEEE80211_IS_MULTICAST(macHdr
->dstMac
)) {
2854 for (i
= 0; i
< ar
->arNodeNum
; i
++) {
2855 if (IEEE80211_ADDR_EQ(macHdr
->dstMac
, ar
->arNodeMap
[i
].macAddress
)) {
2857 ar
->arNodeMap
[i
].txPending
++;
2858 return ar
->arNodeMap
[i
].epId
;
2861 if ((eptMap
== -1) && !ar
->arNodeMap
[i
].txPending
) {
2867 eptMap
= ar
->arNodeNum
;
2869 A_ASSERT(ar
->arNodeNum
<= MAX_NODE_NUM
);
2872 memcpy(ar
->arNodeMap
[eptMap
].macAddress
, macHdr
->dstMac
, IEEE80211_ADDR_LEN
);
2874 for (i
= ENDPOINT_2
; i
<= ENDPOINT_5
; i
++) {
2875 if (!ar
->arTxPending
[i
]) {
2876 ar
->arNodeMap
[eptMap
].epId
= i
;
2879 // No free endpoint is available, start redistribution on the inuse endpoints.
2880 if (i
== ENDPOINT_5
) {
2881 ar
->arNodeMap
[eptMap
].epId
= ar
->arNexEpId
;
2883 if (ar
->arNexEpId
> ENDPOINT_5
) {
2884 ar
->arNexEpId
= ENDPOINT_2
;
2889 (*mapNo
) = eptMap
+ 1;
2890 ar
->arNodeMap
[eptMap
].txPending
++;
2892 return ar
->arNodeMap
[eptMap
].epId
;
2896 static void ar6000_dump_skb(struct sk_buff
*skb
)
2899 for (ch
= A_NETBUF_DATA(skb
);
2900 (unsigned long)ch
< ((unsigned long)A_NETBUF_DATA(skb
) +
2901 A_NETBUF_LEN(skb
)); ch
++)
2903 AR_DEBUG_PRINTF(ATH_DEBUG_WARN
,("%2.2x ", *ch
));
2905 AR_DEBUG_PRINTF(ATH_DEBUG_WARN
,("\n"));
2909 #ifdef HTC_TEST_SEND_PKTS
2910 static void DoHTCSendPktsTest(struct ar6_softc
*ar
, int MapNo
, HTC_ENDPOINT_ID eid
, struct sk_buff
*skb
);
2914 ar6000_data_tx(struct sk_buff
*skb
, struct net_device
*dev
)
2916 #define AC_NOT_MAPPED 99
2917 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2918 u8 ac
= AC_NOT_MAPPED
;
2919 HTC_ENDPOINT_ID eid
= ENDPOINT_UNUSED
;
2922 struct ar_cookie
*cookie
;
2923 bool checkAdHocPsMapping
= false,bMoreData
= false;
2924 HTC_TX_TAG htc_tag
= AR6K_DATA_PKT_TAG
;
2925 u8 dot11Hdr
= processDot11Hdr
;
2927 if (ar
->arWowState
!= WLAN_WOW_STATE_NONE
) {
2931 #endif /* CONFIG_PM */
2933 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("ar6000_data_tx start - skb=0x%lx, data=0x%lx, len=0x%x\n",
2934 (unsigned long)skb
, (unsigned long)A_NETBUF_DATA(skb
),
2935 A_NETBUF_LEN(skb
)));
2937 /* If target is not associated */
2938 if( (!ar
->arConnected
&& !bypasswmi
)
2939 #ifdef CONFIG_HOST_TCMD_SUPPORT
2940 /* TCMD doesn't support any data, free the buf and return */
2941 || (ar
->arTargetMode
== AR6000_TCMD_MODE
)
2950 if (ar
->arWmiReady
== false && bypasswmi
== 0) {
2954 #ifdef BLOCK_TX_PATH_FLAG
2958 #endif /* BLOCK_TX_PATH_FLAG */
2960 /* AP mode Power save processing */
2961 /* If the dst STA is in sleep state, queue the pkt in its PS queue */
2963 if (ar
->arNetworkType
== AP_NETWORK
) {
2964 ATH_MAC_HDR
*datap
= (ATH_MAC_HDR
*)A_NETBUF_DATA(skb
);
2967 /* If the dstMac is a Multicast address & atleast one of the
2968 * associated STA is in PS mode, then queue the pkt to the
2971 if (IEEE80211_IS_MULTICAST(datap
->dstMac
)) {
2976 for (ctr
=0; ctr
<AP_MAX_NUM_STA
; ctr
++) {
2977 if (STA_IS_PWR_SLEEP((&ar
->sta_list
[ctr
]))) {
2983 /* If this transmit is not because of a Dtim Expiry q it */
2984 if (ar
->DTIMExpired
== false) {
2985 bool isMcastqEmpty
= false;
2987 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
2988 isMcastqEmpty
= A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
);
2989 A_NETBUF_ENQUEUE(&ar
->mcastpsq
, skb
);
2990 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
2992 /* If this is the first Mcast pkt getting queued
2993 * indicate to the target to set the BitmapControl LSB
2996 if (isMcastqEmpty
) {
2997 wmi_set_pvb_cmd(ar
->arWmi
, MCAST_AID
, 1);
3001 /* This transmit is because of Dtim expiry. Determine if
3002 * MoreData bit has to be set.
3004 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
3005 if(!A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
)) {
3008 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
3012 conn
= ieee80211_find_conn(ar
, datap
->dstMac
);
3014 if (STA_IS_PWR_SLEEP(conn
)) {
3015 /* If this transmit is not because of a PsPoll q it*/
3016 if (!STA_IS_PS_POLLED(conn
)) {
3017 bool isPsqEmpty
= false;
3018 /* Queue the frames if the STA is sleeping */
3019 A_MUTEX_LOCK(&conn
->psqLock
);
3020 isPsqEmpty
= A_NETBUF_QUEUE_EMPTY(&conn
->psq
);
3021 A_NETBUF_ENQUEUE(&conn
->psq
, skb
);
3022 A_MUTEX_UNLOCK(&conn
->psqLock
);
3024 /* If this is the first pkt getting queued
3025 * for this STA, update the PVB for this STA
3028 wmi_set_pvb_cmd(ar
->arWmi
, conn
->aid
, 1);
3033 /* This tx is because of a PsPoll. Determine if
3034 * MoreData bit has to be set
3036 A_MUTEX_LOCK(&conn
->psqLock
);
3037 if (!A_NETBUF_QUEUE_EMPTY(&conn
->psq
)) {
3040 A_MUTEX_UNLOCK(&conn
->psqLock
);
3045 /* non existent STA. drop the frame */
3052 if (ar
->arWmiEnabled
) {
3055 u8 csum
=skb
->ip_summed
;
3056 if(csumOffload
&& (csum
==CHECKSUM_PARTIAL
)){
3057 csumStart
= (skb
->head
+ skb
->csum_start
- skb_network_header(skb
) +
3058 sizeof(ATH_LLC_SNAP_HDR
));
3059 csumDest
=skb
->csum_offset
+csumStart
;
3061 if (A_NETBUF_HEADROOM(skb
) < dev
->hard_header_len
- LINUX_HACK_FUDGE_FACTOR
) {
3062 struct sk_buff
*newbuf
;
3065 * We really should have gotten enough headroom but sometimes
3066 * we still get packets with not enough headroom. Copy the packet.
3068 len
= A_NETBUF_LEN(skb
);
3069 newbuf
= A_NETBUF_ALLOC(len
);
3070 if (newbuf
== NULL
) {
3073 A_NETBUF_PUT(newbuf
, len
);
3074 memcpy(A_NETBUF_DATA(newbuf
), A_NETBUF_DATA(skb
), len
);
3077 /* fall through and assemble header */
3081 if (wmi_dot11_hdr_add(ar
->arWmi
,skb
,ar
->arNetworkType
) != 0) {
3082 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx-wmi_dot11_hdr_add failed\n"));
3086 if (wmi_dix_2_dot3(ar
->arWmi
, skb
) != 0) {
3087 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx - wmi_dix_2_dot3 failed\n"));
3091 if(csumOffload
&& (csum
==CHECKSUM_PARTIAL
)){
3092 WMI_TX_META_V2 metaV2
;
3093 metaV2
.csumStart
=csumStart
;
3094 metaV2
.csumDest
= csumDest
;
3095 metaV2
.csumFlags
= 0x1;/*instruct target to calculate checksum*/
3096 if (wmi_data_hdr_add(ar
->arWmi
, skb
, DATA_MSGTYPE
, bMoreData
, dot11Hdr
,
3097 WMI_META_VERSION_2
,&metaV2
) != 0) {
3098 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
3105 if (wmi_data_hdr_add(ar
->arWmi
, skb
, DATA_MSGTYPE
, bMoreData
, dot11Hdr
,0,NULL
) != 0) {
3106 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
3112 if ((ar
->arNetworkType
== ADHOC_NETWORK
) &&
3113 ar
->arIbssPsEnable
&& ar
->arConnected
) {
3114 /* flag to check adhoc mapping once we take the lock below: */
3115 checkAdHocPsMapping
= true;
3118 /* get the stream mapping */
3119 ac
= wmi_implicit_create_pstream(ar
->arWmi
, skb
, 0, ar
->arWmmEnabled
);
3123 EPPING_HEADER
*eppingHdr
;
3125 eppingHdr
= A_NETBUF_DATA(skb
);
3127 if (IS_EPPING_PACKET(eppingHdr
)) {
3128 /* the stream ID is mapped to an access class */
3129 ac
= eppingHdr
->StreamNo_h
;
3130 /* some EPPING packets cannot be dropped no matter what access class it was
3131 * sent on. We can change the packet tag to guarantee it will not get dropped */
3132 if (IS_EPING_PACKET_NO_DROP(eppingHdr
)) {
3133 htc_tag
= AR6K_CONTROL_PKT_TAG
;
3136 if (ac
== HCI_TRANSPORT_STREAM_NUM
) {
3137 /* pass this to HCI */
3138 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
3139 if (!hci_test_send(ar
,skb
)) {
3143 /* set AC to discard this skb */
3146 /* a quirk of linux, the payload of the frame is 32-bit aligned and thus the addition
3147 * of the HTC header will mis-align the start of the HTC frame, so we add some
3148 * padding which will be stripped off in the target */
3149 if (EPPING_ALIGNMENT_PAD
> 0) {
3150 A_NETBUF_PUSH(skb
, EPPING_ALIGNMENT_PAD
);
3155 /* not a ping packet, drop it */
3162 /* did we succeed ? */
3163 if ((ac
== AC_NOT_MAPPED
) && !checkAdHocPsMapping
) {
3164 /* cleanup and exit */
3166 AR6000_STAT_INC(ar
, tx_dropped
);
3167 AR6000_STAT_INC(ar
, tx_aborted_errors
);
3173 /* take the lock to protect driver data */
3174 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3178 if (checkAdHocPsMapping
) {
3179 eid
= ar6000_ibss_map_epid(skb
, dev
, &mapNo
);
3181 eid
= arAc2EndpointID (ar
, ac
);
3183 /* validate that the endpoint is connected */
3184 if (eid
== 0 || eid
== ENDPOINT_UNUSED
) {
3185 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" eid %d is NOT mapped!\n", eid
));
3188 /* allocate resource for this packet */
3189 cookie
= ar6000_alloc_cookie(ar
);
3191 if (cookie
!= NULL
) {
3192 /* update counts while the lock is held */
3193 ar
->arTxPending
[eid
]++;
3194 ar
->arTotalTxDataPending
++;
3199 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3201 if (cookie
!= NULL
) {
3202 cookie
->arc_bp
[0] = (unsigned long)skb
;
3203 cookie
->arc_bp
[1] = mapNo
;
3204 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
3212 if (debugdriver
>= 3) {
3213 ar6000_dump_skb(skb
);
3216 #ifdef HTC_TEST_SEND_PKTS
3217 DoHTCSendPktsTest(ar
,mapNo
,eid
,skb
);
3219 /* HTC interface is asynchronous, if this fails, cleanup will happen in
3220 * the ar6000_tx_complete callback */
3221 HTCSendPkt(ar
->arHtcTarget
, &cookie
->HtcPkt
);
3223 /* no packet to send, cleanup */
3225 AR6000_STAT_INC(ar
, tx_dropped
);
3226 AR6000_STAT_INC(ar
, tx_aborted_errors
);
3233 ar6000_acl_data_tx(struct sk_buff
*skb
, struct net_device
*dev
)
3235 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
3236 struct ar_cookie
*cookie
;
3237 HTC_ENDPOINT_ID eid
= ENDPOINT_UNUSED
;
3240 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3242 /* For now we send ACL on BE endpoint: We can also have a dedicated EP */
3243 eid
= arAc2EndpointID (ar
, 0);
3244 /* allocate resource for this packet */
3245 cookie
= ar6000_alloc_cookie(ar
);
3247 if (cookie
!= NULL
) {
3248 /* update counts while the lock is held */
3249 ar
->arTxPending
[eid
]++;
3250 ar
->arTotalTxDataPending
++;
3254 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3256 if (cookie
!= NULL
) {
3257 cookie
->arc_bp
[0] = (unsigned long)skb
;
3258 cookie
->arc_bp
[1] = 0;
3259 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
3266 /* HTC interface is asynchronous, if this fails, cleanup will happen in
3267 * the ar6000_tx_complete callback */
3268 HTCSendPkt(ar
->arHtcTarget
, &cookie
->HtcPkt
);
3270 /* no packet to send, cleanup */
3272 AR6000_STAT_INC(ar
, tx_dropped
);
3273 AR6000_STAT_INC(ar
, tx_aborted_errors
);
3279 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3281 tvsub(register struct timeval
*out
, register struct timeval
*in
)
3283 if((out
->tv_usec
-= in
->tv_usec
) < 0) {
3285 out
->tv_usec
+= 1000000;
3287 out
->tv_sec
-= in
->tv_sec
;
3291 applyAPTCHeuristics(struct ar6_softc
*ar
)
3299 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3301 if ((enableAPTCHeuristics
) && (!aptcTR
.timerScheduled
)) {
3302 do_gettimeofday(&ts
);
3303 tvsub(&ts
, &aptcTR
.samplingTS
);
3304 duration
= ts
.tv_sec
* 1000 + ts
.tv_usec
/ 1000; /* ms */
3305 numbytes
= aptcTR
.bytesTransmitted
+ aptcTR
.bytesReceived
;
3307 if (duration
> APTC_TRAFFIC_SAMPLING_INTERVAL
) {
3308 /* Initialize the time stamp and byte count */
3309 aptcTR
.bytesTransmitted
= aptcTR
.bytesReceived
= 0;
3310 do_gettimeofday(&aptcTR
.samplingTS
);
3312 /* Calculate and decide based on throughput thresholds */
3313 throughput
= ((numbytes
* 8) / duration
);
3314 if (throughput
> APTC_UPPER_THROUGHPUT_THRESHOLD
) {
3315 /* Disable Sleep and schedule a timer */
3316 A_ASSERT(ar
->arWmiReady
== true);
3317 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3318 status
= wmi_powermode_cmd(ar
->arWmi
, MAX_PERF_POWER
);
3319 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3320 A_TIMEOUT_MS(&aptcTimer
, APTC_TRAFFIC_SAMPLING_INTERVAL
, 0);
3321 aptcTR
.timerScheduled
= true;
3326 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3328 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3330 static HTC_SEND_FULL_ACTION
ar6000_tx_queue_full(void *Context
, struct htc_packet
*pPacket
)
3332 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3333 HTC_SEND_FULL_ACTION action
= HTC_SEND_FULL_KEEP
;
3334 bool stopNet
= false;
3335 HTC_ENDPOINT_ID Endpoint
= HTC_GET_ENDPOINT_FROM_PKT(pPacket
);
3342 if (HTC_GET_TAG_FROM_PKT(pPacket
) == AR6K_CONTROL_PKT_TAG
) {
3343 /* don't drop special control packets */
3347 accessClass
= arEndpoint2Ac(ar
,Endpoint
);
3348 /* for endpoint ping testing drop Best Effort and Background */
3349 if ((accessClass
== WMM_AC_BE
) || (accessClass
== WMM_AC_BK
)) {
3350 action
= HTC_SEND_FULL_DROP
;
3353 /* keep but stop the netqueues */
3359 if (Endpoint
== ar
->arControlEp
) {
3360 /* under normal WMI if this is getting full, then something is running rampant
3361 * the host should not be exhausting the WMI queue with too many commands
3362 * the only exception to this is during testing using endpointping */
3363 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3364 /* set flag to handle subsequent messages */
3365 ar
->arWMIControlEpFull
= true;
3366 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3367 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("WMI Control Endpoint is FULL!!! \n"));
3368 /* no need to stop the network */
3373 /* if we get here, we are dealing with data endpoints getting full */
3375 if (HTC_GET_TAG_FROM_PKT(pPacket
) == AR6K_CONTROL_PKT_TAG
) {
3376 /* don't drop control packets issued on ANY data endpoint */
3380 if (ar
->arNetworkType
== ADHOC_NETWORK
) {
3381 /* in adhoc mode, we cannot differentiate traffic priorities so there is no need to
3382 * continue, however we should stop the network */
3386 /* the last MAX_HI_COOKIE_NUM "batch" of cookies are reserved for the highest
3388 if (ar
->arAcStreamPriMap
[arEndpoint2Ac(ar
,Endpoint
)] < ar
->arHiAcStreamActivePri
&&
3389 ar
->arCookieCount
<= MAX_HI_COOKIE_NUM
) {
3390 /* this stream's priority is less than the highest active priority, we
3391 * give preference to the highest priority stream by directing
3392 * HTC to drop the packet that overflowed */
3393 action
= HTC_SEND_FULL_DROP
;
3394 /* since we are dropping packets, no need to stop the network */
3402 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3403 ar
->arNetQueueStopped
= true;
3404 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3405 /* one of the data endpoints queues is getting full..need to stop network stack
3406 * the queue will resume in ar6000_tx_complete() */
3407 netif_stop_queue(ar
->arNetDev
);
3415 ar6000_tx_complete(void *Context
, struct htc_packet_queue
*pPacketQueue
)
3417 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3420 struct ar_cookie
* ar_cookie
;
3421 HTC_ENDPOINT_ID eid
;
3422 bool wakeEvent
= false;
3423 struct sk_buff_head skb_queue
;
3424 struct htc_packet
*pPacket
;
3425 struct sk_buff
*pktSkb
;
3426 bool flushing
= false;
3428 skb_queue_head_init(&skb_queue
);
3430 /* lock the driver as we update internal state */
3431 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3433 /* reap completed packets */
3434 while (!HTC_QUEUE_EMPTY(pPacketQueue
)) {
3436 pPacket
= HTC_PACKET_DEQUEUE(pPacketQueue
);
3438 ar_cookie
= (struct ar_cookie
*)pPacket
->pPktContext
;
3439 A_ASSERT(ar_cookie
);
3441 status
= pPacket
->Status
;
3442 pktSkb
= (struct sk_buff
*)ar_cookie
->arc_bp
[0];
3443 eid
= pPacket
->Endpoint
;
3444 mapNo
= ar_cookie
->arc_bp
[1];
3447 A_ASSERT(pPacket
->pBuffer
== A_NETBUF_DATA(pktSkb
));
3449 /* add this to the list, use faster non-lock API */
3450 __skb_queue_tail(&skb_queue
,pktSkb
);
3453 A_ASSERT(pPacket
->ActualLength
== A_NETBUF_LEN(pktSkb
));
3456 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("ar6000_tx_complete skb=0x%lx data=0x%lx len=0x%x eid=%d ",
3457 (unsigned long)pktSkb
, (unsigned long)pPacket
->pBuffer
,
3458 pPacket
->ActualLength
,
3461 ar
->arTxPending
[eid
]--;
3463 if ((eid
!= ar
->arControlEp
) || bypasswmi
) {
3464 ar
->arTotalTxDataPending
--;
3467 if (eid
== ar
->arControlEp
)
3469 if (ar
->arWMIControlEpFull
) {
3470 /* since this packet completed, the WMI EP is no longer full */
3471 ar
->arWMIControlEpFull
= false;
3474 if (ar
->arTxPending
[eid
] == 0) {
3480 if (status
== A_ECANCELED
) {
3481 /* a packet was flushed */
3484 AR6000_STAT_INC(ar
, tx_errors
);
3485 if (status
!= A_NO_RESOURCE
) {
3486 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() -TX ERROR, status: 0x%x\n", __func__
,
3490 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("OK\n"));
3492 AR6000_STAT_INC(ar
, tx_packets
);
3493 ar
->arNetStats
.tx_bytes
+= A_NETBUF_LEN(pktSkb
);
3494 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3495 aptcTR
.bytesTransmitted
+= a_netbuf_to_len(pktSkb
);
3496 applyAPTCHeuristics(ar
);
3497 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3500 // TODO this needs to be looked at
3501 if ((ar
->arNetworkType
== ADHOC_NETWORK
) && ar
->arIbssPsEnable
3502 && (eid
!= ar
->arControlEp
) && mapNo
)
3505 ar
->arNodeMap
[mapNo
].txPending
--;
3507 if (!ar
->arNodeMap
[mapNo
].txPending
&& (mapNo
== (ar
->arNodeNum
- 1))) {
3509 for (i
= ar
->arNodeNum
; i
> 0; i
--) {
3510 if (!ar
->arNodeMap
[i
- 1].txPending
) {
3511 A_MEMZERO(&ar
->arNodeMap
[i
- 1], sizeof(struct ar_node_mapping
));
3520 ar6000_free_cookie(ar
, ar_cookie
);
3522 if (ar
->arNetQueueStopped
) {
3523 ar
->arNetQueueStopped
= false;
3527 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3529 /* lock is released, we can freely call other kernel APIs */
3531 /* free all skbs in our local list */
3532 while (!skb_queue_empty(&skb_queue
)) {
3533 /* use non-lock version */
3534 pktSkb
= __skb_dequeue(&skb_queue
);
3535 A_NETBUF_FREE(pktSkb
);
3538 if ((ar
->arConnected
== true) || bypasswmi
) {
3540 /* don't wake the queue if we are flushing, other wise it will just
3541 * keep queueing packets, which will keep failing */
3542 netif_wake_queue(ar
->arNetDev
);
3553 ieee80211_find_conn(struct ar6_softc
*ar
, u8
*node_addr
)
3558 switch(ar
->arNetworkType
) {
3560 max_conn
= AP_MAX_NUM_STA
;
3567 for (i
= 0; i
< max_conn
; i
++) {
3568 if (IEEE80211_ADDR_EQ(node_addr
, ar
->sta_list
[i
].mac
)) {
3569 conn
= &ar
->sta_list
[i
];
3577 sta_t
*ieee80211_find_conn_for_aid(struct ar6_softc
*ar
, u8 aid
)
3582 for (ctr
= 0; ctr
< AP_MAX_NUM_STA
; ctr
++) {
3583 if (ar
->sta_list
[ctr
].aid
== aid
) {
3584 conn
= &ar
->sta_list
[ctr
];
3592 * Receive event handler. This is called by HTC when a packet is received
3596 ar6000_rx(void *Context
, struct htc_packet
*pPacket
)
3598 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3599 struct sk_buff
*skb
= (struct sk_buff
*)pPacket
->pPktContext
;
3601 u8 containsDot11Hdr
= 0;
3602 int status
= pPacket
->Status
;
3603 HTC_ENDPOINT_ID ept
= pPacket
->Endpoint
;
3605 A_ASSERT((status
) ||
3606 (pPacket
->pBuffer
== (A_NETBUF_DATA(skb
) + HTC_HEADER_LEN
)));
3608 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX
,("ar6000_rx ar=0x%lx eid=%d, skb=0x%lx, data=0x%lx, len=0x%x status:%d",
3609 (unsigned long)ar
, ept
, (unsigned long)skb
, (unsigned long)pPacket
->pBuffer
,
3610 pPacket
->ActualLength
, status
));
3612 if (status
!= A_ECANCELED
) {
3613 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("RX ERR (%d) \n",status
));
3617 /* take lock to protect buffer counts
3618 * and adaptive power throughput state */
3619 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3622 AR6000_STAT_INC(ar
, rx_packets
);
3623 ar
->arNetStats
.rx_bytes
+= pPacket
->ActualLength
;
3624 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3625 aptcTR
.bytesReceived
+= a_netbuf_to_len(skb
);
3626 applyAPTCHeuristics(ar
);
3627 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3629 A_NETBUF_PUT(skb
, pPacket
->ActualLength
+ HTC_HEADER_LEN
);
3630 A_NETBUF_PULL(skb
, HTC_HEADER_LEN
);
3633 if (debugdriver
>= 2) {
3634 ar6000_dump_skb(skb
);
3639 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3641 skb
->dev
= ar
->arNetDev
;
3643 AR6000_STAT_INC(ar
, rx_errors
);
3645 } else if (ar
->arWmiEnabled
== true) {
3646 if (ept
== ar
->arControlEp
) {
3648 * this is a wmi control msg
3651 ar6000_check_wow_status(ar
, skb
, true);
3652 #endif /* CONFIG_PM */
3653 wmi_control_rx(ar
->arWmi
, skb
);
3655 WMI_DATA_HDR
*dhdr
= (WMI_DATA_HDR
*)A_NETBUF_DATA(skb
);
3660 * This check can be removed if after a while we do not
3661 * see the warning. For now we leave it to ensure
3662 * we drop these frames accordingly in case the
3663 * target generates them for some reason. These
3664 * were used for an internal PAL but that's not
3665 * used or supported anymore. These frames should
3666 * not come up from the target.
3668 if (WARN_ON(WMI_DATA_HDR_GET_DATA_TYPE(dhdr
) ==
3669 WMI_DATA_HDR_DATA_TYPE_ACL
)) {
3670 AR6000_STAT_INC(ar
, rx_errors
);
3676 ar6000_check_wow_status(ar
, NULL
, false);
3677 #endif /* CONFIG_PM */
3679 * this is a wmi data packet
3683 if (processDot11Hdr
) {
3684 minHdrLen
= sizeof(WMI_DATA_HDR
) + sizeof(struct ieee80211_frame
) + sizeof(ATH_LLC_SNAP_HDR
);
3686 minHdrLen
= sizeof (WMI_DATA_HDR
) + sizeof(ATH_MAC_HDR
) +
3687 sizeof(ATH_LLC_SNAP_HDR
);
3690 /* In the case of AP mode we may receive NULL data frames
3691 * that do not have LLC hdr. They are 16 bytes in size.
3692 * Allow these frames in the AP mode.
3693 * ACL data frames don't follow ethernet frame bounds for
3696 if (ar
->arNetworkType
!= AP_NETWORK
&&
3697 ((pPacket
->ActualLength
< minHdrLen
) ||
3698 (pPacket
->ActualLength
> AR6000_MAX_RX_MESSAGE_SIZE
)))
3701 * packet is too short or too long
3703 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("TOO SHORT or TOO LONG\n"));
3704 AR6000_STAT_INC(ar
, rx_errors
);
3705 AR6000_STAT_INC(ar
, rx_length_errors
);
3712 /* Access RSSI values here */
3713 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("RSSI %d\n",
3714 ((WMI_DATA_HDR
*) A_NETBUF_DATA(skb
))->rssi
));
3716 /* Get the Power save state of the STA */
3717 if (ar
->arNetworkType
== AP_NETWORK
) {
3719 u8 psState
=0,prevPsState
;
3720 ATH_MAC_HDR
*datap
=NULL
;
3723 meta_type
= WMI_DATA_HDR_GET_META(dhdr
);
3725 psState
= (((WMI_DATA_HDR
*)A_NETBUF_DATA(skb
))->info
3726 >> WMI_DATA_HDR_PS_SHIFT
) & WMI_DATA_HDR_PS_MASK
;
3728 offset
= sizeof(WMI_DATA_HDR
);
3730 switch (meta_type
) {
3733 case WMI_META_VERSION_1
:
3734 offset
+= sizeof(WMI_RX_META_V1
);
3736 case WMI_META_VERSION_2
:
3737 offset
+= sizeof(WMI_RX_META_V2
);
3743 datap
= (ATH_MAC_HDR
*)(A_NETBUF_DATA(skb
)+offset
);
3744 conn
= ieee80211_find_conn(ar
, datap
->srcMac
);
3747 /* if there is a change in PS state of the STA,
3748 * take appropriate steps.
3749 * 1. If Sleep-->Awake, flush the psq for the STA
3750 * Clear the PVB for the STA.
3751 * 2. If Awake-->Sleep, Starting queueing frames
3754 prevPsState
= STA_IS_PWR_SLEEP(conn
);
3756 STA_SET_PWR_SLEEP(conn
);
3758 STA_CLR_PWR_SLEEP(conn
);
3761 if (prevPsState
^ STA_IS_PWR_SLEEP(conn
)) {
3763 if (!STA_IS_PWR_SLEEP(conn
)) {
3765 A_MUTEX_LOCK(&conn
->psqLock
);
3766 while (!A_NETBUF_QUEUE_EMPTY(&conn
->psq
)) {
3767 struct sk_buff
*skb
=NULL
;
3769 skb
= A_NETBUF_DEQUEUE(&conn
->psq
);
3770 A_MUTEX_UNLOCK(&conn
->psqLock
);
3771 ar6000_data_tx(skb
,ar
->arNetDev
);
3772 A_MUTEX_LOCK(&conn
->psqLock
);
3774 A_MUTEX_UNLOCK(&conn
->psqLock
);
3775 /* Clear the PVB for this STA */
3776 wmi_set_pvb_cmd(ar
->arWmi
, conn
->aid
, 0);
3780 /* This frame is from a STA that is not associated*/
3784 /* Drop NULL data frames here */
3785 if((pPacket
->ActualLength
< minHdrLen
) ||
3786 (pPacket
->ActualLength
> AR6000_MAX_RX_MESSAGE_SIZE
)) {
3792 is_amsdu
= WMI_DATA_HDR_IS_AMSDU(dhdr
) ? true : false;
3793 tid
= WMI_DATA_HDR_GET_UP(dhdr
);
3794 seq_no
= WMI_DATA_HDR_GET_SEQNO(dhdr
);
3795 meta_type
= WMI_DATA_HDR_GET_META(dhdr
);
3796 containsDot11Hdr
= WMI_DATA_HDR_GET_DOT11(dhdr
);
3798 wmi_data_hdr_remove(ar
->arWmi
, skb
);
3800 switch (meta_type
) {
3801 case WMI_META_VERSION_1
:
3803 WMI_RX_META_V1
*pMeta
= (WMI_RX_META_V1
*)A_NETBUF_DATA(skb
);
3804 A_PRINTF("META %d %d %d %d %x\n", pMeta
->status
, pMeta
->rix
, pMeta
->rssi
, pMeta
->channel
, pMeta
->flags
);
3805 A_NETBUF_PULL((void*)skb
, sizeof(WMI_RX_META_V1
));
3808 case WMI_META_VERSION_2
:
3810 WMI_RX_META_V2
*pMeta
= (WMI_RX_META_V2
*)A_NETBUF_DATA(skb
);
3811 if(pMeta
->csumFlags
& 0x1){
3812 skb
->ip_summed
=CHECKSUM_COMPLETE
;
3813 skb
->csum
=(pMeta
->csum
);
3815 A_NETBUF_PULL((void*)skb
, sizeof(WMI_RX_META_V2
));
3822 A_ASSERT(status
== 0);
3824 /* NWF: print the 802.11 hdr bytes */
3825 if(containsDot11Hdr
) {
3826 status
= wmi_dot11_hdr_remove(ar
->arWmi
,skb
);
3827 } else if(!is_amsdu
) {
3828 status
= wmi_dot3_2_dix(skb
);
3832 /* Drop frames that could not be processed (lack of memory, etc.) */
3837 if ((ar
->arNetDev
->flags
& IFF_UP
) == IFF_UP
) {
3838 if (ar
->arNetworkType
== AP_NETWORK
) {
3839 struct sk_buff
*skb1
= NULL
;
3842 datap
= (ATH_MAC_HDR
*)A_NETBUF_DATA(skb
);
3843 if (IEEE80211_IS_MULTICAST(datap
->dstMac
)) {
3844 /* Bcast/Mcast frames should be sent to the OS
3845 * stack as well as on the air.
3847 skb1
= skb_copy(skb
,GFP_ATOMIC
);
3849 /* Search for a connected STA with dstMac as
3850 * the Mac address. If found send the frame to
3851 * it on the air else send the frame up the
3855 conn
= ieee80211_find_conn(ar
, datap
->dstMac
);
3857 if (conn
&& ar
->intra_bss
) {
3860 } else if(conn
&& !ar
->intra_bss
) {
3866 ar6000_data_tx(skb1
, ar
->arNetDev
);
3870 aggr_process_recv_frm(ar
->aggr_cntxt
, tid
, seq_no
, is_amsdu
, (void **)&skb
);
3871 ar6000_deliver_frames_to_nw_stack((void *) ar
->arNetDev
, (void *)skb
);
3875 if (EPPING_ALIGNMENT_PAD
> 0) {
3876 A_NETBUF_PULL(skb
, EPPING_ALIGNMENT_PAD
);
3878 ar6000_deliver_frames_to_nw_stack((void *)ar
->arNetDev
, (void *)skb
);
3887 ar6000_deliver_frames_to_nw_stack(void *dev
, void *osbuf
)
3889 struct sk_buff
*skb
= (struct sk_buff
*)osbuf
;
3893 if ((skb
->dev
->flags
& IFF_UP
) == IFF_UP
) {
3895 ar6000_check_wow_status((struct ar6_softc
*)ar6k_priv(dev
), skb
, false);
3896 #endif /* CONFIG_PM */
3897 skb
->protocol
= eth_type_trans(skb
, skb
->dev
);
3899 * If this routine is called on a ISR (Hard IRQ) or DSR (Soft IRQ)
3900 * or tasklet use the netif_rx to deliver the packet to the stack
3901 * netif_rx will queue the packet onto the receive queue and mark
3902 * the softirq thread has a pending action to complete. Kernel will
3903 * schedule the softIrq kernel thread after processing the DSR.
3905 * If this routine is called on a process context, use netif_rx_ni
3906 * which will schedle the softIrq kernel thread after queuing the packet.
3908 if (in_interrupt()) {
3921 ar6000_deliver_frames_to_bt_stack(void *dev
, void *osbuf
)
3923 struct sk_buff
*skb
= (struct sk_buff
*)osbuf
;
3927 if ((skb
->dev
->flags
& IFF_UP
) == IFF_UP
) {
3928 skb
->protocol
= htons(ETH_P_CONTROL
);
3938 ar6000_rx_refill(void *Context
, HTC_ENDPOINT_ID Endpoint
)
3940 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3943 int buffersToRefill
;
3944 struct htc_packet
*pPacket
;
3945 struct htc_packet_queue queue
;
3947 buffersToRefill
= (int)AR6000_MAX_RX_BUFFERS
-
3948 HTCGetNumRecvBuffers(ar
->arHtcTarget
, Endpoint
);
3950 if (buffersToRefill
<= 0) {
3951 /* fast return, nothing to fill */
3955 INIT_HTC_PACKET_QUEUE(&queue
);
3957 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX
,("ar6000_rx_refill: providing htc with %d buffers at eid=%d\n",
3958 buffersToRefill
, Endpoint
));
3960 for (RxBuffers
= 0; RxBuffers
< buffersToRefill
; RxBuffers
++) {
3961 osBuf
= A_NETBUF_ALLOC(AR6000_BUFFER_SIZE
);
3962 if (NULL
== osBuf
) {
3965 /* the HTC packet wrapper is at the head of the reserved area
3967 pPacket
= (struct htc_packet
*)(A_NETBUF_HEAD(osBuf
));
3968 /* set re-fill info */
3969 SET_HTC_PACKET_INFO_RX_REFILL(pPacket
,osBuf
,A_NETBUF_DATA(osBuf
),AR6000_BUFFER_SIZE
,Endpoint
);
3971 HTC_PACKET_ENQUEUE(&queue
,pPacket
);
3974 if (!HTC_QUEUE_EMPTY(&queue
)) {
3976 HTCAddReceivePktMultiple(ar
->arHtcTarget
, &queue
);
3981 /* clean up our amsdu buffer list */
3982 static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc
*ar
)
3984 struct htc_packet
*pPacket
;
3987 /* empty AMSDU buffer queue and free OS bufs */
3990 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3991 pPacket
= HTC_PACKET_DEQUEUE(&ar
->amsdu_rx_buffer_queue
);
3992 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3994 if (NULL
== pPacket
) {
3998 osBuf
= pPacket
->pPktContext
;
3999 if (NULL
== osBuf
) {
4004 A_NETBUF_FREE(osBuf
);
4010 /* refill the amsdu buffer list */
4011 static void ar6000_refill_amsdu_rxbufs(struct ar6_softc
*ar
, int Count
)
4013 struct htc_packet
*pPacket
;
4017 osBuf
= A_NETBUF_ALLOC(AR6000_AMSDU_BUFFER_SIZE
);
4018 if (NULL
== osBuf
) {
4021 /* the HTC packet wrapper is at the head of the reserved area
4023 pPacket
= (struct htc_packet
*)(A_NETBUF_HEAD(osBuf
));
4024 /* set re-fill info */
4025 SET_HTC_PACKET_INFO_RX_REFILL(pPacket
,osBuf
,A_NETBUF_DATA(osBuf
),AR6000_AMSDU_BUFFER_SIZE
,0);
4027 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
4028 /* put it in the list */
4029 HTC_PACKET_ENQUEUE(&ar
->amsdu_rx_buffer_queue
,pPacket
);
4030 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
4036 /* callback to allocate a large receive buffer for a pending packet. This function is called when
4037 * an HTC packet arrives whose length exceeds a threshold value
4039 * We use a pre-allocated list of buffers of maximum AMSDU size (4K). Under linux it is more optimal to
4040 * keep the allocation size the same to optimize cached-slab allocations.
4043 static struct htc_packet
*ar6000_alloc_amsdu_rxbuf(void *Context
, HTC_ENDPOINT_ID Endpoint
, int Length
)
4045 struct htc_packet
*pPacket
= NULL
;
4046 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
4047 int refillCount
= 0;
4049 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX
,("ar6000_alloc_amsdu_rxbuf: eid=%d, Length:%d\n",Endpoint
,Length
));
4053 if (Length
<= AR6000_BUFFER_SIZE
) {
4054 /* shouldn't be getting called on normal sized packets */
4059 if (Length
> AR6000_AMSDU_BUFFER_SIZE
) {
4064 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
4065 /* allocate a packet from the list */
4066 pPacket
= HTC_PACKET_DEQUEUE(&ar
->amsdu_rx_buffer_queue
);
4067 /* see if we need to refill again */
4068 refillCount
= AR6000_MAX_AMSDU_RX_BUFFERS
- HTC_PACKET_QUEUE_DEPTH(&ar
->amsdu_rx_buffer_queue
);
4069 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
4071 if (NULL
== pPacket
) {
4074 /* set actual endpoint ID */
4075 pPacket
->Endpoint
= Endpoint
;
4079 if (refillCount
>= AR6000_AMSDU_REFILL_THRESHOLD
) {
4080 ar6000_refill_amsdu_rxbufs(ar
,refillCount
);
4087 ar6000_set_multicast_list(struct net_device
*dev
)
4089 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000: Multicast filter not supported\n"));
4092 static struct net_device_stats
*
4093 ar6000_get_stats(struct net_device
*dev
)
4095 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
4096 return &ar
->arNetStats
;
4100 ar6000_ready_event(void *devt
, u8
*datap
, u8 phyCap
, u32 sw_ver
, u32 abi_ver
)
4102 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
4103 struct net_device
*dev
= ar
->arNetDev
;
4105 memcpy(dev
->dev_addr
, datap
, AR6000_ETH_ADDR_LEN
);
4106 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("mac address = %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
4107 dev
->dev_addr
[0], dev
->dev_addr
[1],
4108 dev
->dev_addr
[2], dev
->dev_addr
[3],
4109 dev
->dev_addr
[4], dev
->dev_addr
[5]));
4111 ar
->arPhyCapability
= phyCap
;
4112 ar
->arVersion
.wlan_ver
= sw_ver
;
4113 ar
->arVersion
.abi_ver
= abi_ver
;
4115 /* Indicate to the waiting thread that the ready event was received */
4116 ar
->arWmiReady
= true;
4120 void ar6000_install_static_wep_keys(struct ar6_softc
*ar
)
4125 for (index
= WMI_MIN_KEY_INDEX
; index
<= WMI_MAX_KEY_INDEX
; index
++) {
4126 if (ar
->arWepKeyList
[index
].arKeyLen
) {
4127 keyUsage
= GROUP_USAGE
;
4128 if (index
== ar
->arDefTxKeyIndex
) {
4129 keyUsage
|= TX_USAGE
;
4131 wmi_addKey_cmd(ar
->arWmi
,
4135 ar
->arWepKeyList
[index
].arKeyLen
,
4137 ar
->arWepKeyList
[index
].arKey
, KEY_OP_INIT_VAL
, NULL
,
4144 add_new_sta(struct ar6_softc
*ar
, u8
*mac
, u16 aid
, u8
*wpaie
,
4145 u8 ielen
, u8 keymgmt
, u8 ucipher
, u8 auth
)
4149 memcpy(ar
->sta_list
[free_slot
].mac
, mac
, ATH_MAC_LEN
);
4150 memcpy(ar
->sta_list
[free_slot
].wpa_ie
, wpaie
, ielen
);
4151 ar
->sta_list
[free_slot
].aid
= aid
;
4152 ar
->sta_list
[free_slot
].keymgmt
= keymgmt
;
4153 ar
->sta_list
[free_slot
].ucipher
= ucipher
;
4154 ar
->sta_list
[free_slot
].auth
= auth
;
4155 ar
->sta_list_index
= ar
->sta_list_index
| (1 << free_slot
);
4156 ar
->arAPStats
.sta
[free_slot
].aid
= aid
;
4160 ar6000_connect_event(struct ar6_softc
*ar
, u16 channel
, u8
*bssid
,
4161 u16 listenInterval
, u16 beaconInterval
,
4162 NETWORK_TYPE networkType
, u8 beaconIeLen
,
4163 u8 assocReqLen
, u8 assocRespLen
,
4166 union iwreq_data wrqu
;
4167 int i
, beacon_ie_pos
, assoc_resp_ie_pos
, assoc_req_ie_pos
;
4168 static const char *tag1
= "ASSOCINFO(ReqIEs=";
4169 static const char *tag2
= "ASSOCRESPIE=";
4170 static const char *beaconIetag
= "BEACONIE=";
4171 char buf
[WMI_CONTROL_MSG_MAX_LEN
* 2 + strlen(tag1
) + 1];
4174 unsigned long flags
;
4175 struct ieee80211req_key
*ik
;
4176 CRYPTO_TYPE keyType
= NONE_CRYPT
;
4178 if(ar
->arNetworkType
& AP_NETWORK
) {
4179 struct net_device
*dev
= ar
->arNetDev
;
4180 if(memcmp(dev
->dev_addr
, bssid
, ATH_MAC_LEN
)==0) {
4181 ar
->arACS
= channel
;
4182 ik
= &ar
->ap_mode_bkey
;
4184 switch(ar
->arAuthMode
) {
4186 if(ar
->arPairwiseCrypto
== WEP_CRYPT
) {
4187 ar6000_install_static_wep_keys(ar
);
4190 else if(ar
->arPairwiseCrypto
== WAPI_CRYPT
) {
4191 ap_set_wapi_key(ar
, ik
);
4197 case (WPA_PSK_AUTH
|WPA2_PSK_AUTH
):
4198 switch (ik
->ik_type
) {
4199 case IEEE80211_CIPHER_TKIP
:
4200 keyType
= TKIP_CRYPT
;
4202 case IEEE80211_CIPHER_AES_CCM
:
4203 keyType
= AES_CRYPT
;
4208 wmi_addKey_cmd(ar
->arWmi
, ik
->ik_keyix
, keyType
, GROUP_USAGE
,
4209 ik
->ik_keylen
, (u8
*)&ik
->ik_keyrsc
,
4210 ik
->ik_keydata
, KEY_OP_INIT_VAL
, ik
->ik_macaddr
,
4216 ar
->arConnected
= true;
4220 A_PRINTF("NEW STA %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x \n "
4221 " AID=%d \n", bssid
[0], bssid
[1], bssid
[2],
4222 bssid
[3], bssid
[4], bssid
[5], channel
);
4223 switch ((listenInterval
>>8)&0xFF) {
4225 A_PRINTF("AUTH: OPEN\n");
4228 A_PRINTF("AUTH: SHARED\n");
4231 A_PRINTF("AUTH: Unknown\n");
4234 switch (listenInterval
&0xFF) {
4236 A_PRINTF("KeyMgmt: WPA-PSK\n");
4239 A_PRINTF("KeyMgmt: WPA2-PSK\n");
4242 A_PRINTF("KeyMgmt: NONE\n");
4245 switch (beaconInterval
) {
4247 A_PRINTF("Cipher: AES\n");
4250 A_PRINTF("Cipher: TKIP\n");
4253 A_PRINTF("Cipher: WEP\n");
4257 A_PRINTF("Cipher: WAPI\n");
4261 A_PRINTF("Cipher: NONE\n");
4265 add_new_sta(ar
, bssid
, channel
/*aid*/,
4266 assocInfo
/* WPA IE */, assocRespLen
/* IE len */,
4267 listenInterval
&0xFF /* Keymgmt */, beaconInterval
/* cipher */,
4268 (listenInterval
>>8)&0xFF /* auth alg */);
4270 /* Send event to application */
4271 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4272 memcpy(wrqu
.addr
.sa_data
, bssid
, ATH_MAC_LEN
);
4273 wireless_send_event(ar
->arNetDev
, IWEVREGISTERED
, &wrqu
, NULL
);
4274 /* In case the queue is stopped when we switch modes, this will
4277 netif_wake_queue(ar
->arNetDev
);
4281 ar6k_cfg80211_connect_event(ar
, channel
, bssid
,
4282 listenInterval
, beaconInterval
,
4283 networkType
, beaconIeLen
,
4284 assocReqLen
, assocRespLen
,
4287 memcpy(ar
->arBssid
, bssid
, sizeof(ar
->arBssid
));
4288 ar
->arBssChannel
= channel
;
4290 A_PRINTF("AR6000 connected event on freq %d ", channel
);
4291 A_PRINTF("with bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
4292 " listenInterval=%d, beaconInterval = %d, beaconIeLen = %d assocReqLen=%d"
4293 " assocRespLen =%d\n",
4294 bssid
[0], bssid
[1], bssid
[2],
4295 bssid
[3], bssid
[4], bssid
[5],
4296 listenInterval
, beaconInterval
,
4297 beaconIeLen
, assocReqLen
, assocRespLen
);
4298 if (networkType
& ADHOC_NETWORK
) {
4299 if (networkType
& ADHOC_CREATOR
) {
4300 A_PRINTF("Network: Adhoc (Creator)\n");
4302 A_PRINTF("Network: Adhoc (Joiner)\n");
4305 A_PRINTF("Network: Infrastructure\n");
4308 if ((ar
->arNetworkType
== INFRA_NETWORK
)) {
4309 wmi_listeninterval_cmd(ar
->arWmi
, ar
->arListenIntervalT
, ar
->arListenIntervalB
);
4312 if (beaconIeLen
&& (sizeof(buf
) > (9 + beaconIeLen
* 2))) {
4313 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nBeaconIEs= "));
4316 A_MEMZERO(buf
, sizeof(buf
));
4317 sprintf(buf
, "%s", beaconIetag
);
4319 for (i
= beacon_ie_pos
; i
< beacon_ie_pos
+ beaconIeLen
; i
++) {
4320 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4321 sprintf(pos
, "%2.2x", assocInfo
[i
]);
4324 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4326 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4327 wrqu
.data
.length
= strlen(buf
);
4328 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4331 if (assocRespLen
&& (sizeof(buf
) > (12 + (assocRespLen
* 2))))
4333 assoc_resp_ie_pos
= beaconIeLen
+ assocReqLen
+
4334 sizeof(u16
) + /* capinfo*/
4335 sizeof(u16
) + /* status Code */
4336 sizeof(u16
) ; /* associd */
4337 A_MEMZERO(buf
, sizeof(buf
));
4338 sprintf(buf
, "%s", tag2
);
4340 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nAssocRespIEs= "));
4342 * The Association Response Frame w.o. the WLAN header is delivered to
4343 * the host, so skip over to the IEs
4345 for (i
= assoc_resp_ie_pos
; i
< assoc_resp_ie_pos
+ assocRespLen
- 6; i
++)
4347 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4348 sprintf(pos
, "%2.2x", assocInfo
[i
]);
4351 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4353 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4354 wrqu
.data
.length
= strlen(buf
);
4355 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4358 if (assocReqLen
&& (sizeof(buf
) > (17 + (assocReqLen
* 2)))) {
4360 * assoc Request includes capability and listen interval. Skip these.
4362 assoc_req_ie_pos
= beaconIeLen
+
4363 sizeof(u16
) + /* capinfo*/
4364 sizeof(u16
); /* listen interval */
4366 A_MEMZERO(buf
, sizeof(buf
));
4367 sprintf(buf
, "%s", tag1
);
4369 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("AssocReqIEs= "));
4370 for (i
= assoc_req_ie_pos
; i
< assoc_req_ie_pos
+ assocReqLen
- 4; i
++) {
4371 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4372 sprintf(pos
, "%2.2x", assocInfo
[i
]);
4375 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4377 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4378 wrqu
.data
.length
= strlen(buf
);
4379 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4382 if (ar
->user_savedkeys_stat
== USER_SAVEDKEYS_STAT_RUN
&&
4383 ar
->user_saved_keys
.keyOk
== true)
4385 key_op_ctrl
= KEY_OP_VALID_MASK
& ~KEY_OP_INIT_TSC
;
4387 if (ar
->user_key_ctrl
& AR6000_USER_SETKEYS_RSC_UNCHANGED
) {
4388 key_op_ctrl
&= ~KEY_OP_INIT_RSC
;
4390 key_op_ctrl
|= KEY_OP_INIT_RSC
;
4392 ar6000_reinstall_keys(ar
, key_op_ctrl
);
4395 netif_wake_queue(ar
->arNetDev
);
4397 /* Update connect & link status atomically */
4398 spin_lock_irqsave(&ar
->arLock
, flags
);
4399 ar
->arConnected
= true;
4400 ar
->arConnectPending
= false;
4401 netif_carrier_on(ar
->arNetDev
);
4402 spin_unlock_irqrestore(&ar
->arLock
, flags
);
4403 /* reset the rx aggr state */
4404 aggr_reset_state(ar
->aggr_cntxt
);
4407 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4408 memcpy(wrqu
.addr
.sa_data
, bssid
, IEEE80211_ADDR_LEN
);
4409 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
4410 wireless_send_event(ar
->arNetDev
, SIOCGIWAP
, &wrqu
, NULL
);
4411 if ((ar
->arNetworkType
== ADHOC_NETWORK
) && ar
->arIbssPsEnable
) {
4412 A_MEMZERO(ar
->arNodeMap
, sizeof(ar
->arNodeMap
));
4414 ar
->arNexEpId
= ENDPOINT_2
;
4416 if (!ar
->arUserBssFilter
) {
4417 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
4422 void ar6000_set_numdataendpts(struct ar6_softc
*ar
, u32 num
)
4424 A_ASSERT(num
<= (HTC_MAILBOX_NUM_MAX
- 1));
4425 ar
->arNumDataEndPts
= num
;
4429 sta_cleanup(struct ar6_softc
*ar
, u8 i
)
4431 struct sk_buff
*skb
;
4433 /* empty the queued pkts in the PS queue if any */
4434 A_MUTEX_LOCK(&ar
->sta_list
[i
].psqLock
);
4435 while (!A_NETBUF_QUEUE_EMPTY(&ar
->sta_list
[i
].psq
)) {
4436 skb
= A_NETBUF_DEQUEUE(&ar
->sta_list
[i
].psq
);
4439 A_MUTEX_UNLOCK(&ar
->sta_list
[i
].psqLock
);
4441 /* Zero out the state fields */
4442 A_MEMZERO(&ar
->arAPStats
.sta
[ar
->sta_list
[i
].aid
-1], sizeof(WMI_PER_STA_STAT
));
4443 A_MEMZERO(&ar
->sta_list
[i
].mac
, ATH_MAC_LEN
);
4444 A_MEMZERO(&ar
->sta_list
[i
].wpa_ie
, IEEE80211_MAX_IE
);
4445 ar
->sta_list
[i
].aid
= 0;
4446 ar
->sta_list
[i
].flags
= 0;
4448 ar
->sta_list_index
= ar
->sta_list_index
& ~(1 << i
);
4452 u8
remove_sta(struct ar6_softc
*ar
, u8
*mac
, u16 reason
)
4456 if(IS_MAC_NULL(mac
)) {
4460 if(IS_MAC_BCAST(mac
)) {
4461 A_PRINTF("DEL ALL STA\n");
4462 for(i
=0; i
< AP_MAX_NUM_STA
; i
++) {
4463 if(!IS_MAC_NULL(ar
->sta_list
[i
].mac
)) {
4469 for(i
=0; i
< AP_MAX_NUM_STA
; i
++) {
4470 if(memcmp(ar
->sta_list
[i
].mac
, mac
, ATH_MAC_LEN
)==0) {
4471 A_PRINTF("DEL STA %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
4472 " aid=%d REASON=%d\n", mac
[0], mac
[1], mac
[2],
4473 mac
[3], mac
[4], mac
[5], ar
->sta_list
[i
].aid
, reason
);
4485 ar6000_disconnect_event(struct ar6_softc
*ar
, u8 reason
, u8
*bssid
,
4486 u8 assocRespLen
, u8
*assocInfo
, u16 protocolReasonStatus
)
4489 unsigned long flags
;
4490 union iwreq_data wrqu
;
4492 if(ar
->arNetworkType
& AP_NETWORK
) {
4493 union iwreq_data wrqu
;
4494 struct sk_buff
*skb
;
4496 if(!remove_sta(ar
, bssid
, protocolReasonStatus
)) {
4500 /* If there are no more associated STAs, empty the mcast PS q */
4501 if (ar
->sta_list_index
== 0) {
4502 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
4503 while (!A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
)) {
4504 skb
= A_NETBUF_DEQUEUE(&ar
->mcastpsq
);
4507 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
4509 /* Clear the LSB of the BitMapCtl field of the TIM IE */
4510 if (ar
->arWmiReady
) {
4511 wmi_set_pvb_cmd(ar
->arWmi
, MCAST_AID
, 0);
4515 if(!IS_MAC_BCAST(bssid
)) {
4516 /* Send event to application */
4517 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4518 memcpy(wrqu
.addr
.sa_data
, bssid
, ATH_MAC_LEN
);
4519 wireless_send_event(ar
->arNetDev
, IWEVEXPIRED
, &wrqu
, NULL
);
4522 ar
->arConnected
= false;
4526 ar6k_cfg80211_disconnect_event(ar
, reason
, bssid
,
4527 assocRespLen
, assocInfo
,
4528 protocolReasonStatus
);
4530 /* Send disconnect event to supplicant */
4531 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4532 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
4533 wireless_send_event(ar
->arNetDev
, SIOCGIWAP
, &wrqu
, NULL
);
4535 /* it is necessary to clear the host-side rx aggregation state */
4536 aggr_reset_state(ar
->aggr_cntxt
);
4538 A_UNTIMEOUT(&ar
->disconnect_timer
);
4540 A_PRINTF("AR6000 disconnected");
4541 if (bssid
[0] || bssid
[1] || bssid
[2] || bssid
[3] || bssid
[4] || bssid
[5]) {
4542 A_PRINTF(" from %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",
4543 bssid
[0], bssid
[1], bssid
[2], bssid
[3], bssid
[4], bssid
[5]);
4546 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nDisconnect Reason is %d", reason
));
4547 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nProtocol Reason/Status Code is %d", protocolReasonStatus
));
4548 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nAssocResp Frame = %s",
4549 assocRespLen
? " " : "NULL"));
4550 for (i
= 0; i
< assocRespLen
; i
++) {
4552 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4554 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4556 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4558 * If the event is due to disconnect cmd from the host, only they the target
4559 * would stop trying to connect. Under any other condition, target would
4560 * keep trying to connect.
4563 if( reason
== DISCONNECT_CMD
)
4565 if ((!ar
->arUserBssFilter
) && (ar
->arWmiReady
)) {
4566 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
4569 ar
->arConnectPending
= true;
4570 if (((reason
== ASSOC_FAILED
) && (protocolReasonStatus
== 0x11)) ||
4571 ((reason
== ASSOC_FAILED
) && (protocolReasonStatus
== 0x0) && (reconnect_flag
== 1))) {
4572 ar
->arConnected
= true;
4577 if ((reason
== NO_NETWORK_AVAIL
) && (ar
->arWmiReady
))
4579 bss_t
*pWmiSsidnode
= NULL
;
4581 /* remove the current associated bssid node */
4582 wmi_free_node (ar
->arWmi
, bssid
);
4585 * In case any other same SSID nodes are present
4586 * remove it, since those nodes also not available now
4591 * Find the nodes based on SSID and remove it
4592 * NOTE :: This case will not work out for Hidden-SSID
4594 pWmiSsidnode
= wmi_find_Ssidnode (ar
->arWmi
, ar
->arSsid
, ar
->arSsidLen
, false, true);
4598 wmi_free_node (ar
->arWmi
, pWmiSsidnode
->ni_macaddr
);
4601 } while (pWmiSsidnode
);
4604 /* Update connect & link status atomically */
4605 spin_lock_irqsave(&ar
->arLock
, flags
);
4606 ar
->arConnected
= false;
4607 netif_carrier_off(ar
->arNetDev
);
4608 spin_unlock_irqrestore(&ar
->arLock
, flags
);
4610 if( (reason
!= CSERV_DISCONNECT
) || (reconnect_flag
!= 1) ) {
4614 if (reason
!= CSERV_DISCONNECT
)
4616 ar
->user_savedkeys_stat
= USER_SAVEDKEYS_STAT_INIT
;
4617 ar
->user_key_ctrl
= 0;
4620 netif_stop_queue(ar
->arNetDev
);
4621 A_MEMZERO(ar
->arBssid
, sizeof(ar
->arBssid
));
4622 ar
->arBssChannel
= 0;
4623 ar
->arBeaconInterval
= 0;
4625 ar6000_TxDataCleanup(ar
);
4629 ar6000_regDomain_event(struct ar6_softc
*ar
, u32 regCode
)
4631 A_PRINTF("AR6000 Reg Code = 0x%x\n", regCode
);
4632 ar
->arRegCode
= regCode
;
4636 ar6000_aggr_rcv_addba_req_evt(struct ar6_softc
*ar
, WMI_ADDBA_REQ_EVENT
*evt
)
4638 if(evt
->status
== 0) {
4639 aggr_recv_addba_req_evt(ar
->aggr_cntxt
, evt
->tid
, evt
->st_seq_no
, evt
->win_sz
);
4644 ar6000_aggr_rcv_addba_resp_evt(struct ar6_softc
*ar
, WMI_ADDBA_RESP_EVENT
*evt
)
4646 A_PRINTF("ADDBA RESP. tid %d status %d, sz %d\n", evt
->tid
, evt
->status
, evt
->amsdu_sz
);
4647 if(evt
->status
== 0) {
4652 ar6000_aggr_rcv_delba_req_evt(struct ar6_softc
*ar
, WMI_DELBA_EVENT
*evt
)
4654 aggr_recv_delba_req_evt(ar
->aggr_cntxt
, evt
->tid
);
4657 void register_pal_cb(ar6k_pal_config_t
*palConfig_p
)
4659 ar6k_pal_config_g
= *palConfig_p
;
4663 ar6000_hci_event_rcv_evt(struct ar6_softc
*ar
, WMI_HCI_EVENT
*cmd
)
4670 size
= cmd
->evt_buf_sz
+ 4;
4671 osbuf
= A_NETBUF_ALLOC(size
);
4672 if (osbuf
== NULL
) {
4674 A_PRINTF("Error in allocating netbuf \n");
4678 A_NETBUF_PUT(osbuf
, size
);
4679 buf
= (u8
*)A_NETBUF_DATA(osbuf
);
4680 /* First 2-bytes carry HCI event/ACL data type
4681 * the next 2 are free
4683 *((short *)buf
) = WMI_HCI_EVENT_EVENTID
;
4685 memcpy(buf
, cmd
->buf
, cmd
->evt_buf_sz
);
4687 ar6000_deliver_frames_to_nw_stack(ar
->arNetDev
, osbuf
);
4689 A_PRINTF_LOG("HCI Event From PAL <-- \n");
4690 for(i
= 0; i
< cmd
->evt_buf_sz
; i
++) {
4691 A_PRINTF_LOG("0x%02x ", cmd
->buf
[i
]);
4697 A_PRINTF_LOG("==================================\n");
4702 ar6000_neighborReport_event(struct ar6_softc
*ar
, int numAps
, WMI_NEIGHBOR_INFO
*info
)
4704 #if WIRELESS_EXT >= 18
4705 struct iw_pmkid_cand
*pmkcand
;
4706 #else /* WIRELESS_EXT >= 18 */
4707 static const char *tag
= "PRE-AUTH";
4709 #endif /* WIRELESS_EXT >= 18 */
4711 union iwreq_data wrqu
;
4714 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("AR6000 Neighbor Report Event\n"));
4715 for (i
=0; i
< numAps
; info
++, i
++) {
4716 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",
4717 info
->bssid
[0], info
->bssid
[1], info
->bssid
[2],
4718 info
->bssid
[3], info
->bssid
[4], info
->bssid
[5]));
4719 if (info
->bssFlags
& WMI_PREAUTH_CAPABLE_BSS
) {
4720 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("preauth-cap"));
4722 if (info
->bssFlags
& WMI_PMKID_VALID_BSS
) {
4723 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,(" pmkid-valid\n"));
4724 continue; /* we skip bss if the pmkid is already valid */
4726 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("\n"));
4727 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4728 #if WIRELESS_EXT >= 18
4729 pmkcand
= A_MALLOC_NOWAIT(sizeof(struct iw_pmkid_cand
));
4730 A_MEMZERO(pmkcand
, sizeof(struct iw_pmkid_cand
));
4732 pmkcand
->flags
= info
->bssFlags
;
4733 memcpy(pmkcand
->bssid
.sa_data
, info
->bssid
, ATH_MAC_LEN
);
4734 wrqu
.data
.length
= sizeof(struct iw_pmkid_cand
);
4735 wireless_send_event(ar
->arNetDev
, IWEVPMKIDCAND
, &wrqu
, (char *)pmkcand
);
4737 #else /* WIRELESS_EXT >= 18 */
4738 snprintf(buf
, sizeof(buf
), "%s%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
4740 info
->bssid
[0], info
->bssid
[1], info
->bssid
[2],
4741 info
->bssid
[3], info
->bssid
[4], info
->bssid
[5],
4743 wrqu
.data
.length
= strlen(buf
);
4744 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4745 #endif /* WIRELESS_EXT >= 18 */
4750 ar6000_tkip_micerr_event(struct ar6_softc
*ar
, u8 keyid
, bool ismcast
)
4752 static const char *tag
= "MLME-MICHAELMICFAILURE.indication";
4754 union iwreq_data wrqu
;
4757 * For AP case, keyid will have aid of STA which sent pkt with
4758 * MIC error. Use this aid to get MAC & send it to hostapd.
4760 if (ar
->arNetworkType
== AP_NETWORK
) {
4761 sta_t
*s
= ieee80211_find_conn_for_aid(ar
, (keyid
>> 2));
4763 A_PRINTF("AP TKIP MIC error received from Invalid aid / STA not found =%d\n", keyid
);
4766 A_PRINTF("AP TKIP MIC error received from aid=%d\n", keyid
);
4767 snprintf(buf
,sizeof(buf
), "%s addr=%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
4768 tag
, s
->mac
[0],s
->mac
[1],s
->mac
[2],s
->mac
[3],s
->mac
[4],s
->mac
[5]);
4771 ar6k_cfg80211_tkip_micerr_event(ar
, keyid
, ismcast
);
4773 A_PRINTF("AR6000 TKIP MIC error received for keyid %d %scast\n",
4774 keyid
& 0x3, ismcast
? "multi": "uni");
4775 snprintf(buf
, sizeof(buf
), "%s(keyid=%d %sicast)", tag
, keyid
& 0x3,
4776 ismcast
? "mult" : "un");
4779 memset(&wrqu
, 0, sizeof(wrqu
));
4780 wrqu
.data
.length
= strlen(buf
);
4781 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4785 ar6000_scanComplete_event(struct ar6_softc
*ar
, int status
)
4788 ar6k_cfg80211_scanComplete_event(ar
, status
);
4790 if (!ar
->arUserBssFilter
) {
4791 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
4793 if (ar
->scan_triggered
) {
4795 union iwreq_data wrqu
;
4796 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4797 wireless_send_event(ar
->arNetDev
, SIOCGIWSCAN
, &wrqu
, NULL
);
4799 ar
->scan_triggered
= 0;
4802 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,( "AR6000 scan complete: %d\n", status
));
4806 ar6000_targetStats_event(struct ar6_softc
*ar
, u8
*ptr
, u32 len
)
4810 if(ar
->arNetworkType
== AP_NETWORK
) {
4811 WMI_AP_MODE_STAT
*p
= (WMI_AP_MODE_STAT
*)ptr
;
4812 WMI_AP_MODE_STAT
*ap
= &ar
->arAPStats
;
4814 if (len
< sizeof(*p
)) {
4818 for(ac
=0;ac
<AP_MAX_NUM_STA
;ac
++) {
4819 ap
->sta
[ac
].tx_bytes
+= p
->sta
[ac
].tx_bytes
;
4820 ap
->sta
[ac
].tx_pkts
+= p
->sta
[ac
].tx_pkts
;
4821 ap
->sta
[ac
].tx_error
+= p
->sta
[ac
].tx_error
;
4822 ap
->sta
[ac
].tx_discard
+= p
->sta
[ac
].tx_discard
;
4823 ap
->sta
[ac
].rx_bytes
+= p
->sta
[ac
].rx_bytes
;
4824 ap
->sta
[ac
].rx_pkts
+= p
->sta
[ac
].rx_pkts
;
4825 ap
->sta
[ac
].rx_error
+= p
->sta
[ac
].rx_error
;
4826 ap
->sta
[ac
].rx_discard
+= p
->sta
[ac
].rx_discard
;
4830 WMI_TARGET_STATS
*pTarget
= (WMI_TARGET_STATS
*)ptr
;
4831 TARGET_STATS
*pStats
= &ar
->arTargetStats
;
4833 if (len
< sizeof(*pTarget
)) {
4837 // Update the RSSI of the connected bss.
4838 if (ar
->arConnected
) {
4839 bss_t
*pConnBss
= NULL
;
4841 pConnBss
= wmi_find_node(ar
->arWmi
,ar
->arBssid
);
4844 pConnBss
->ni_rssi
= pTarget
->cservStats
.cs_aveBeacon_rssi
;
4845 pConnBss
->ni_snr
= pTarget
->cservStats
.cs_aveBeacon_snr
;
4846 wmi_node_return(ar
->arWmi
, pConnBss
);
4850 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("AR6000 updating target stats\n"));
4851 pStats
->tx_packets
+= pTarget
->txrxStats
.tx_stats
.tx_packets
;
4852 pStats
->tx_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_bytes
;
4853 pStats
->tx_unicast_pkts
+= pTarget
->txrxStats
.tx_stats
.tx_unicast_pkts
;
4854 pStats
->tx_unicast_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_unicast_bytes
;
4855 pStats
->tx_multicast_pkts
+= pTarget
->txrxStats
.tx_stats
.tx_multicast_pkts
;
4856 pStats
->tx_multicast_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_multicast_bytes
;
4857 pStats
->tx_broadcast_pkts
+= pTarget
->txrxStats
.tx_stats
.tx_broadcast_pkts
;
4858 pStats
->tx_broadcast_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_broadcast_bytes
;
4859 pStats
->tx_rts_success_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_rts_success_cnt
;
4860 for(ac
= 0; ac
< WMM_NUM_AC
; ac
++)
4861 pStats
->tx_packet_per_ac
[ac
] += pTarget
->txrxStats
.tx_stats
.tx_packet_per_ac
[ac
];
4862 pStats
->tx_errors
+= pTarget
->txrxStats
.tx_stats
.tx_errors
;
4863 pStats
->tx_failed_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_failed_cnt
;
4864 pStats
->tx_retry_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_retry_cnt
;
4865 pStats
->tx_mult_retry_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_mult_retry_cnt
;
4866 pStats
->tx_rts_fail_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_rts_fail_cnt
;
4867 pStats
->tx_unicast_rate
= wmi_get_rate(pTarget
->txrxStats
.tx_stats
.tx_unicast_rate
);
4869 pStats
->rx_packets
+= pTarget
->txrxStats
.rx_stats
.rx_packets
;
4870 pStats
->rx_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_bytes
;
4871 pStats
->rx_unicast_pkts
+= pTarget
->txrxStats
.rx_stats
.rx_unicast_pkts
;
4872 pStats
->rx_unicast_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_unicast_bytes
;
4873 pStats
->rx_multicast_pkts
+= pTarget
->txrxStats
.rx_stats
.rx_multicast_pkts
;
4874 pStats
->rx_multicast_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_multicast_bytes
;
4875 pStats
->rx_broadcast_pkts
+= pTarget
->txrxStats
.rx_stats
.rx_broadcast_pkts
;
4876 pStats
->rx_broadcast_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_broadcast_bytes
;
4877 pStats
->rx_fragment_pkt
+= pTarget
->txrxStats
.rx_stats
.rx_fragment_pkt
;
4878 pStats
->rx_errors
+= pTarget
->txrxStats
.rx_stats
.rx_errors
;
4879 pStats
->rx_crcerr
+= pTarget
->txrxStats
.rx_stats
.rx_crcerr
;
4880 pStats
->rx_key_cache_miss
+= pTarget
->txrxStats
.rx_stats
.rx_key_cache_miss
;
4881 pStats
->rx_decrypt_err
+= pTarget
->txrxStats
.rx_stats
.rx_decrypt_err
;
4882 pStats
->rx_duplicate_frames
+= pTarget
->txrxStats
.rx_stats
.rx_duplicate_frames
;
4883 pStats
->rx_unicast_rate
= wmi_get_rate(pTarget
->txrxStats
.rx_stats
.rx_unicast_rate
);
4886 pStats
->tkip_local_mic_failure
4887 += pTarget
->txrxStats
.tkipCcmpStats
.tkip_local_mic_failure
;
4888 pStats
->tkip_counter_measures_invoked
4889 += pTarget
->txrxStats
.tkipCcmpStats
.tkip_counter_measures_invoked
;
4890 pStats
->tkip_replays
+= pTarget
->txrxStats
.tkipCcmpStats
.tkip_replays
;
4891 pStats
->tkip_format_errors
+= pTarget
->txrxStats
.tkipCcmpStats
.tkip_format_errors
;
4892 pStats
->ccmp_format_errors
+= pTarget
->txrxStats
.tkipCcmpStats
.ccmp_format_errors
;
4893 pStats
->ccmp_replays
+= pTarget
->txrxStats
.tkipCcmpStats
.ccmp_replays
;
4895 pStats
->power_save_failure_cnt
+= pTarget
->pmStats
.power_save_failure_cnt
;
4896 pStats
->noise_floor_calibation
= pTarget
->noise_floor_calibation
;
4898 pStats
->cs_bmiss_cnt
+= pTarget
->cservStats
.cs_bmiss_cnt
;
4899 pStats
->cs_lowRssi_cnt
+= pTarget
->cservStats
.cs_lowRssi_cnt
;
4900 pStats
->cs_connect_cnt
+= pTarget
->cservStats
.cs_connect_cnt
;
4901 pStats
->cs_disconnect_cnt
+= pTarget
->cservStats
.cs_disconnect_cnt
;
4902 pStats
->cs_aveBeacon_snr
= pTarget
->cservStats
.cs_aveBeacon_snr
;
4903 pStats
->cs_aveBeacon_rssi
= pTarget
->cservStats
.cs_aveBeacon_rssi
;
4905 if (enablerssicompensation
) {
4906 pStats
->cs_aveBeacon_rssi
=
4907 rssi_compensation_calc(ar
, pStats
->cs_aveBeacon_rssi
);
4909 pStats
->cs_lastRoam_msec
= pTarget
->cservStats
.cs_lastRoam_msec
;
4910 pStats
->cs_snr
= pTarget
->cservStats
.cs_snr
;
4911 pStats
->cs_rssi
= pTarget
->cservStats
.cs_rssi
;
4913 pStats
->lq_val
= pTarget
->lqVal
;
4915 pStats
->wow_num_pkts_dropped
+= pTarget
->wowStats
.wow_num_pkts_dropped
;
4916 pStats
->wow_num_host_pkt_wakeups
+= pTarget
->wowStats
.wow_num_host_pkt_wakeups
;
4917 pStats
->wow_num_host_event_wakeups
+= pTarget
->wowStats
.wow_num_host_event_wakeups
;
4918 pStats
->wow_num_events_discarded
+= pTarget
->wowStats
.wow_num_events_discarded
;
4919 pStats
->arp_received
+= pTarget
->arpStats
.arp_received
;
4920 pStats
->arp_matched
+= pTarget
->arpStats
.arp_matched
;
4921 pStats
->arp_replied
+= pTarget
->arpStats
.arp_replied
;
4923 if (ar
->statsUpdatePending
) {
4924 ar
->statsUpdatePending
= false;
4931 ar6000_rssiThreshold_event(struct ar6_softc
*ar
, WMI_RSSI_THRESHOLD_VAL newThreshold
, s16 rssi
)
4933 USER_RSSI_THOLD userRssiThold
;
4935 rssi
= rssi
+ SIGNAL_QUALITY_NOISE_FLOOR
;
4937 if (enablerssicompensation
) {
4938 rssi
= rssi_compensation_calc(ar
, rssi
);
4941 /* Send an event to the app */
4942 userRssiThold
.tag
= ar
->rssi_map
[newThreshold
].tag
;
4943 userRssiThold
.rssi
= rssi
;
4944 A_PRINTF("rssi Threshold range = %d tag = %d rssi = %d\n", newThreshold
,
4945 userRssiThold
.tag
, userRssiThold
.rssi
);
4950 ar6000_hbChallengeResp_event(struct ar6_softc
*ar
, u32 cookie
, u32 source
)
4952 if (source
!= APP_HB_CHALLENGE
) {
4953 /* This would ignore the replys that come in after their due time */
4954 if (cookie
== ar
->arHBChallengeResp
.seqNum
) {
4955 ar
->arHBChallengeResp
.outstanding
= false;
4962 ar6000_reportError_event(struct ar6_softc
*ar
, WMI_TARGET_ERROR_VAL errorVal
)
4964 static const char * const errString
[] = {
4965 [WMI_TARGET_PM_ERR_FAIL
] "WMI_TARGET_PM_ERR_FAIL",
4966 [WMI_TARGET_KEY_NOT_FOUND
] "WMI_TARGET_KEY_NOT_FOUND",
4967 [WMI_TARGET_DECRYPTION_ERR
] "WMI_TARGET_DECRYPTION_ERR",
4968 [WMI_TARGET_BMISS
] "WMI_TARGET_BMISS",
4969 [WMI_PSDISABLE_NODE_JOIN
] "WMI_PSDISABLE_NODE_JOIN"
4972 A_PRINTF("AR6000 Error on Target. Error = 0x%x\n", errorVal
);
4974 /* One error is reported at a time, and errorval is a bitmask */
4975 if(errorVal
& (errorVal
- 1))
4978 A_PRINTF("AR6000 Error type = ");
4981 case WMI_TARGET_PM_ERR_FAIL
:
4982 case WMI_TARGET_KEY_NOT_FOUND
:
4983 case WMI_TARGET_DECRYPTION_ERR
:
4984 case WMI_TARGET_BMISS
:
4985 case WMI_PSDISABLE_NODE_JOIN
:
4986 A_PRINTF("%s\n", errString
[errorVal
]);
4989 A_PRINTF("INVALID\n");
4997 ar6000_cac_event(struct ar6_softc
*ar
, u8 ac
, u8 cacIndication
,
4998 u8 statusCode
, u8
*tspecSuggestion
)
5000 WMM_TSPEC_IE
*tspecIe
;
5003 * This is the TSPEC IE suggestion from AP.
5004 * Suggestion provided by AP under some error
5005 * cases, could be helpful for the host app.
5006 * Check documentation.
5008 tspecIe
= (WMM_TSPEC_IE
*)tspecSuggestion
;
5011 * What do we do, if we get TSPEC rejection? One thought
5012 * that comes to mind is implictly delete the pstream...
5014 A_PRINTF("AR6000 CAC notification. "
5015 "AC = %d, cacIndication = 0x%x, statusCode = 0x%x\n",
5016 ac
, cacIndication
, statusCode
);
5020 ar6000_channel_change_event(struct ar6_softc
*ar
, u16 oldChannel
,
5023 A_PRINTF("Channel Change notification\nOld Channel: %d, New Channel: %d\n",
5024 oldChannel
, newChannel
);
5027 #define AR6000_PRINT_BSSID(_pBss) do { \
5028 A_PRINTF("%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",\
5029 (_pBss)[0],(_pBss)[1],(_pBss)[2],(_pBss)[3],\
5030 (_pBss)[4],(_pBss)[5]); \
5034 ar6000_roam_tbl_event(struct ar6_softc
*ar
, WMI_TARGET_ROAM_TBL
*pTbl
)
5038 A_PRINTF("ROAM TABLE NO OF ENTRIES is %d ROAM MODE is %d\n",
5039 pTbl
->numEntries
, pTbl
->roamMode
);
5040 for (i
= 0; i
< pTbl
->numEntries
; i
++) {
5041 A_PRINTF("[%d]bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ", i
,
5042 pTbl
->bssRoamInfo
[i
].bssid
[0], pTbl
->bssRoamInfo
[i
].bssid
[1],
5043 pTbl
->bssRoamInfo
[i
].bssid
[2],
5044 pTbl
->bssRoamInfo
[i
].bssid
[3],
5045 pTbl
->bssRoamInfo
[i
].bssid
[4],
5046 pTbl
->bssRoamInfo
[i
].bssid
[5]);
5047 A_PRINTF("RSSI %d RSSIDT %d LAST RSSI %d UTIL %d ROAM_UTIL %d"
5049 pTbl
->bssRoamInfo
[i
].rssi
,
5050 pTbl
->bssRoamInfo
[i
].rssidt
,
5051 pTbl
->bssRoamInfo
[i
].last_rssi
,
5052 pTbl
->bssRoamInfo
[i
].util
,
5053 pTbl
->bssRoamInfo
[i
].roam_util
,
5054 pTbl
->bssRoamInfo
[i
].bias
);
5059 ar6000_wow_list_event(struct ar6_softc
*ar
, u8 num_filters
, WMI_GET_WOW_LIST_REPLY
*wow_reply
)
5063 /*Each event now contains exactly one filter, see bug 26613*/
5064 A_PRINTF("WOW pattern %d of %d patterns\n", wow_reply
->this_filter_num
, wow_reply
->num_filters
);
5065 A_PRINTF("wow mode = %s host mode = %s\n",
5066 (wow_reply
->wow_mode
== 0? "disabled":"enabled"),
5067 (wow_reply
->host_mode
== 1 ? "awake":"asleep"));
5070 /*If there are no patterns, the reply will only contain generic
5071 WoW information. Pattern information will exist only if there are
5072 patterns present. Bug 26716*/
5074 /* If this event contains pattern information, display it*/
5075 if (wow_reply
->this_filter_num
) {
5077 A_PRINTF("id=%d size=%d offset=%d\n",
5078 wow_reply
->wow_filters
[i
].wow_filter_id
,
5079 wow_reply
->wow_filters
[i
].wow_filter_size
,
5080 wow_reply
->wow_filters
[i
].wow_filter_offset
);
5081 A_PRINTF("wow pattern = ");
5082 for (j
=0; j
< wow_reply
->wow_filters
[i
].wow_filter_size
; j
++) {
5083 A_PRINTF("%2.2x",wow_reply
->wow_filters
[i
].wow_filter_pattern
[j
]);
5086 A_PRINTF("\nwow mask = ");
5087 for (j
=0; j
< wow_reply
->wow_filters
[i
].wow_filter_size
; j
++) {
5088 A_PRINTF("%2.2x",wow_reply
->wow_filters
[i
].wow_filter_mask
[j
]);
5095 * Report the Roaming related data collected on the target
5098 ar6000_display_roam_time(WMI_TARGET_ROAM_TIME
*p
)
5100 A_PRINTF("Disconnect Data : BSSID: ");
5101 AR6000_PRINT_BSSID(p
->disassoc_bssid
);
5102 A_PRINTF(" RSSI %d DISASSOC Time %d NO_TXRX_TIME %d\n",
5103 p
->disassoc_bss_rssi
,p
->disassoc_time
,
5105 A_PRINTF("Connect Data: BSSID: ");
5106 AR6000_PRINT_BSSID(p
->assoc_bssid
);
5107 A_PRINTF(" RSSI %d ASSOC Time %d TXRX_TIME %d\n",
5108 p
->assoc_bss_rssi
,p
->assoc_time
,
5109 p
->allow_txrx_time
);
5113 ar6000_roam_data_event(struct ar6_softc
*ar
, WMI_TARGET_ROAM_DATA
*p
)
5115 switch (p
->roamDataType
) {
5116 case ROAM_DATA_TIME
:
5117 ar6000_display_roam_time(&p
->u
.roamTime
);
5125 ar6000_bssInfo_event_rx(struct ar6_softc
*ar
, u8
*datap
, int len
)
5127 struct sk_buff
*skb
;
5128 WMI_BSS_INFO_HDR
*bih
= (WMI_BSS_INFO_HDR
*)datap
;
5131 if (!ar
->arMgmtFilter
) {
5134 if (((ar
->arMgmtFilter
& IEEE80211_FILTER_TYPE_BEACON
) &&
5135 (bih
->frameType
!= BEACON_FTYPE
)) ||
5136 ((ar
->arMgmtFilter
& IEEE80211_FILTER_TYPE_PROBE_RESP
) &&
5137 (bih
->frameType
!= PROBERESP_FTYPE
)))
5142 if ((skb
= A_NETBUF_ALLOC_RAW(len
)) != NULL
) {
5144 A_NETBUF_PUT(skb
, len
);
5145 memcpy(A_NETBUF_DATA(skb
), datap
, len
);
5146 skb
->dev
= ar
->arNetDev
;
5147 memcpy(skb_mac_header(skb
), A_NETBUF_DATA(skb
), 6);
5148 skb
->ip_summed
= CHECKSUM_NONE
;
5149 skb
->pkt_type
= PACKET_OTHERHOST
;
5150 skb
->protocol
= __constant_htons(0x0019);
5158 ar6000_control_tx(void *devt
, void *osbuf
, HTC_ENDPOINT_ID eid
)
5160 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
5162 struct ar_cookie
*cookie
= NULL
;
5165 if (ar
->arWowState
!= WLAN_WOW_STATE_NONE
) {
5166 A_NETBUF_FREE(osbuf
);
5169 #endif /* CONFIG_PM */
5170 /* take lock to protect ar6000_alloc_cookie() */
5171 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
5175 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("ar_contrstatus = ol_tx: skb=0x%lx, len=0x%x eid =%d\n",
5176 (unsigned long)osbuf
, A_NETBUF_LEN(osbuf
), eid
));
5178 if (ar
->arWMIControlEpFull
&& (eid
== ar
->arControlEp
)) {
5179 /* control endpoint is full, don't allocate resources, we
5180 * are just going to drop this packet */
5182 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" WMI Control EP full, dropping packet : 0x%lX, len:%d \n",
5183 (unsigned long)osbuf
, A_NETBUF_LEN(osbuf
)));
5185 cookie
= ar6000_alloc_cookie(ar
);
5188 if (cookie
== NULL
) {
5189 status
= A_NO_MEMORY
;
5194 A_PRINTF("WMI cmd send, msgNo %d :", wmiSendCmdNum
);
5195 for(i
= 0; i
< a_netbuf_to_len(osbuf
); i
++)
5196 A_PRINTF("%x ", ((u8
*)a_netbuf_to_data(osbuf
))[i
]);
5204 if (cookie
!= NULL
) {
5205 /* got a structure to send it out on */
5206 ar
->arTxPending
[eid
]++;
5208 if (eid
!= ar
->arControlEp
) {
5209 ar
->arTotalTxDataPending
++;
5213 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
5215 if (cookie
!= NULL
) {
5216 cookie
->arc_bp
[0] = (unsigned long)osbuf
;
5217 cookie
->arc_bp
[1] = 0;
5218 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
5220 A_NETBUF_DATA(osbuf
),
5221 A_NETBUF_LEN(osbuf
),
5223 AR6K_CONTROL_PKT_TAG
);
5224 /* this interface is asynchronous, if there is an error, cleanup will happen in the
5225 * TX completion callback */
5226 HTCSendPkt(ar
->arHtcTarget
, &cookie
->HtcPkt
);
5231 A_NETBUF_FREE(osbuf
);
5236 /* indicate tx activity or inactivity on a WMI stream */
5237 void ar6000_indicate_tx_activity(void *devt
, u8 TrafficClass
, bool Active
)
5239 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
5240 HTC_ENDPOINT_ID eid
;
5243 if (ar
->arWmiEnabled
) {
5244 eid
= arAc2EndpointID(ar
, TrafficClass
);
5246 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
5248 ar
->arAcStreamActive
[TrafficClass
] = Active
;
5251 /* when a stream goes active, keep track of the active stream with the highest priority */
5253 if (ar
->arAcStreamPriMap
[TrafficClass
] > ar
->arHiAcStreamActivePri
) {
5254 /* set the new highest active priority */
5255 ar
->arHiAcStreamActivePri
= ar
->arAcStreamPriMap
[TrafficClass
];
5259 /* when a stream goes inactive, we may have to search for the next active stream
5260 * that is the highest priority */
5262 if (ar
->arHiAcStreamActivePri
== ar
->arAcStreamPriMap
[TrafficClass
]) {
5264 /* the highest priority stream just went inactive */
5266 /* reset and search for the "next" highest "active" priority stream */
5267 ar
->arHiAcStreamActivePri
= 0;
5268 for (i
= 0; i
< WMM_NUM_AC
; i
++) {
5269 if (ar
->arAcStreamActive
[i
]) {
5270 if (ar
->arAcStreamPriMap
[i
] > ar
->arHiAcStreamActivePri
) {
5271 /* set the new highest active priority */
5272 ar
->arHiAcStreamActivePri
= ar
->arAcStreamPriMap
[i
];
5279 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
5282 /* for mbox ping testing, the traffic class is mapped directly as a stream ID,
5283 * see handling of AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE in ioctl.c
5284 * convert the stream ID to a endpoint */
5285 eid
= arAc2EndpointID(ar
, TrafficClass
);
5288 /* notify HTC, this may cause credit distribution changes */
5290 HTCIndicateActivityChange(ar
->arHtcTarget
,
5297 ar6000_btcoex_config_event(struct ar6_softc
*ar
, u8
*ptr
, u32 len
)
5300 WMI_BTCOEX_CONFIG_EVENT
*pBtcoexConfig
= (WMI_BTCOEX_CONFIG_EVENT
*)ptr
;
5301 WMI_BTCOEX_CONFIG_EVENT
*pArbtcoexConfig
=&ar
->arBtcoexConfig
;
5303 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("AR6000 BTCOEX CONFIG EVENT \n"));
5305 A_PRINTF("received config event\n");
5306 pArbtcoexConfig
->btProfileType
= pBtcoexConfig
->btProfileType
;
5307 pArbtcoexConfig
->linkId
= pBtcoexConfig
->linkId
;
5309 switch (pBtcoexConfig
->btProfileType
) {
5310 case WMI_BTCOEX_BT_PROFILE_SCO
:
5311 memcpy(&pArbtcoexConfig
->info
.scoConfigCmd
, &pBtcoexConfig
->info
.scoConfigCmd
,
5312 sizeof(WMI_SET_BTCOEX_SCO_CONFIG_CMD
));
5314 case WMI_BTCOEX_BT_PROFILE_A2DP
:
5315 memcpy(&pArbtcoexConfig
->info
.a2dpConfigCmd
, &pBtcoexConfig
->info
.a2dpConfigCmd
,
5316 sizeof(WMI_SET_BTCOEX_A2DP_CONFIG_CMD
));
5318 case WMI_BTCOEX_BT_PROFILE_ACLCOEX
:
5319 memcpy(&pArbtcoexConfig
->info
.aclcoexConfig
, &pBtcoexConfig
->info
.aclcoexConfig
,
5320 sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD
));
5322 case WMI_BTCOEX_BT_PROFILE_INQUIRY_PAGE
:
5323 memcpy(&pArbtcoexConfig
->info
.btinquiryPageConfigCmd
, &pBtcoexConfig
->info
.btinquiryPageConfigCmd
,
5324 sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD
));
5327 if (ar
->statsUpdatePending
) {
5328 ar
->statsUpdatePending
= false;
5334 ar6000_btcoex_stats_event(struct ar6_softc
*ar
, u8
*ptr
, u32 len
)
5336 WMI_BTCOEX_STATS_EVENT
*pBtcoexStats
= (WMI_BTCOEX_STATS_EVENT
*)ptr
;
5338 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("AR6000 BTCOEX CONFIG EVENT \n"));
5340 memcpy(&ar
->arBtcoexStats
, pBtcoexStats
, sizeof(WMI_BTCOEX_STATS_EVENT
));
5342 if (ar
->statsUpdatePending
) {
5343 ar
->statsUpdatePending
= false;
5348 module_init(ar6000_init_module
);
5349 module_exit(ar6000_cleanup_module
);
5351 /* Init cookie queue */
5353 ar6000_cookie_init(struct ar6_softc
*ar
)
5357 ar
->arCookieList
= NULL
;
5358 ar
->arCookieCount
= 0;
5360 A_MEMZERO(s_ar_cookie_mem
, sizeof(s_ar_cookie_mem
));
5362 for (i
= 0; i
< MAX_COOKIE_NUM
; i
++) {
5363 ar6000_free_cookie(ar
, &s_ar_cookie_mem
[i
]);
5367 /* cleanup cookie queue */
5369 ar6000_cookie_cleanup(struct ar6_softc
*ar
)
5371 /* It is gone .... */
5372 ar
->arCookieList
= NULL
;
5373 ar
->arCookieCount
= 0;
5376 /* Init cookie queue */
5378 ar6000_free_cookie(struct ar6_softc
*ar
, struct ar_cookie
* cookie
)
5381 A_ASSERT(ar
!= NULL
);
5382 A_ASSERT(cookie
!= NULL
);
5384 cookie
->arc_list_next
= ar
->arCookieList
;
5385 ar
->arCookieList
= cookie
;
5386 ar
->arCookieCount
++;
5389 /* cleanup cookie queue */
5390 static struct ar_cookie
*
5391 ar6000_alloc_cookie(struct ar6_softc
*ar
)
5393 struct ar_cookie
*cookie
;
5395 cookie
= ar
->arCookieList
;
5398 ar
->arCookieList
= cookie
->arc_list_next
;
5399 ar
->arCookieCount
--;
5406 ar6000_tx_retry_err_event(void *devt
)
5408 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Tx retries reach maximum!\n"));
5412 ar6000_snrThresholdEvent_rx(void *devt
, WMI_SNR_THRESHOLD_VAL newThreshold
, u8 snr
)
5414 WMI_SNR_THRESHOLD_EVENT event
;
5416 event
.range
= newThreshold
;
5421 ar6000_lqThresholdEvent_rx(void *devt
, WMI_LQ_THRESHOLD_VAL newThreshold
, u8 lq
)
5423 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("lq threshold range %d, lq %d\n", newThreshold
, lq
));
5428 u32
a_copy_to_user(void *to
, const void *from
, u32 n
)
5430 return(copy_to_user(to
, from
, n
));
5433 u32
a_copy_from_user(void *to
, const void *from
, u32 n
)
5435 return(copy_from_user(to
, from
, n
));
5440 ar6000_get_driver_cfg(struct net_device
*dev
,
5449 case AR6000_DRIVER_CFG_GET_WLANNODECACHING
:
5450 *((u32
*)result
) = wlanNodeCaching
;
5452 case AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS
:
5453 *((u32
*)result
) = logWmiRawMsgs
;
5464 ar6000_keepalive_rx(void *devt
, u8 configured
)
5466 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
5468 ar
->arKeepaliveConfigured
= configured
;
5473 ar6000_pmkid_list_event(void *devt
, u8 numPMKID
, WMI_PMKID
*pmkidList
,
5478 A_PRINTF("Number of Cached PMKIDs is %d\n", numPMKID
);
5480 for (i
= 0; i
< numPMKID
; i
++) {
5481 A_PRINTF("\nBSSID %d ", i
);
5482 for (j
= 0; j
< ATH_MAC_LEN
; j
++) {
5483 A_PRINTF("%2.2x", bssidList
[j
]);
5485 bssidList
+= (ATH_MAC_LEN
+ WMI_PMKID_LEN
);
5486 A_PRINTF("\nPMKID %d ", i
);
5487 for (j
= 0; j
< WMI_PMKID_LEN
; j
++) {
5488 A_PRINTF("%2.2x", pmkidList
->pmkid
[j
]);
5490 pmkidList
= (WMI_PMKID
*)((u8
*)pmkidList
+ ATH_MAC_LEN
+
5495 void ar6000_pspoll_event(struct ar6_softc
*ar
,u8 aid
)
5498 bool isPsqEmpty
= false;
5500 conn
= ieee80211_find_conn_for_aid(ar
, aid
);
5502 /* If the PS q for this STA is not empty, dequeue and send a pkt from
5503 * the head of the q. Also update the More data bit in the WMI_DATA_HDR
5504 * if there are more pkts for this STA in the PS q. If there are no more
5505 * pkts for this STA, update the PVB for this STA.
5507 A_MUTEX_LOCK(&conn
->psqLock
);
5508 isPsqEmpty
= A_NETBUF_QUEUE_EMPTY(&conn
->psq
);
5509 A_MUTEX_UNLOCK(&conn
->psqLock
);
5512 /* TODO:No buffered pkts for this STA. Send out a NULL data frame */
5514 struct sk_buff
*skb
= NULL
;
5516 A_MUTEX_LOCK(&conn
->psqLock
);
5517 skb
= A_NETBUF_DEQUEUE(&conn
->psq
);
5518 A_MUTEX_UNLOCK(&conn
->psqLock
);
5519 /* Set the STA flag to PSPolled, so that the frame will go out */
5520 STA_SET_PS_POLLED(conn
);
5521 ar6000_data_tx(skb
, ar
->arNetDev
);
5522 STA_CLR_PS_POLLED(conn
);
5524 /* Clear the PVB for this STA if the queue has become empty */
5525 A_MUTEX_LOCK(&conn
->psqLock
);
5526 isPsqEmpty
= A_NETBUF_QUEUE_EMPTY(&conn
->psq
);
5527 A_MUTEX_UNLOCK(&conn
->psqLock
);
5530 wmi_set_pvb_cmd(ar
->arWmi
, conn
->aid
, 0);
5535 void ar6000_dtimexpiry_event(struct ar6_softc
*ar
)
5537 bool isMcastQueued
= false;
5538 struct sk_buff
*skb
= NULL
;
5540 /* If there are no associated STAs, ignore the DTIM expiry event.
5541 * There can be potential race conditions where the last associated
5542 * STA may disconnect & before the host could clear the 'Indicate DTIM'
5543 * request to the firmware, the firmware would have just indicated a DTIM
5544 * expiry event. The race is between 'clear DTIM expiry cmd' going
5545 * from the host to the firmware & the DTIM expiry event happening from
5546 * the firmware to the host.
5548 if (ar
->sta_list_index
== 0) {
5552 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
5553 isMcastQueued
= A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
);
5554 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
5556 A_ASSERT(isMcastQueued
== false);
5558 /* Flush the mcast psq to the target */
5559 /* Set the STA flag to DTIMExpired, so that the frame will go out */
5560 ar
->DTIMExpired
= true;
5562 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
5563 while (!A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
)) {
5564 skb
= A_NETBUF_DEQUEUE(&ar
->mcastpsq
);
5565 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
5567 ar6000_data_tx(skb
, ar
->arNetDev
);
5569 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
5571 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
5573 /* Reset the DTIMExpired flag back to 0 */
5574 ar
->DTIMExpired
= false;
5576 /* Clear the LSB of the BitMapCtl field of the TIM IE */
5577 wmi_set_pvb_cmd(ar
->arWmi
, MCAST_AID
, 0);
5581 read_rssi_compensation_param(struct ar6_softc
*ar
)
5585 //#define RSSICOMPENSATION_PRINT
5587 #ifdef RSSICOMPENSATION_PRINT
5589 cust_data_ptr
= ar6000_get_cust_data_buffer(ar
->arTargetType
);
5590 for (i
=0; i
<16; i
++) {
5591 A_PRINTF("cust_data_%d = %x \n", i
, *(u8
*)cust_data_ptr
);
5596 cust_data_ptr
= ar6000_get_cust_data_buffer(ar
->arTargetType
);
5598 rssi_compensation_param
.customerID
= *(u16
*)cust_data_ptr
& 0xffff;
5599 rssi_compensation_param
.enable
= *(u16
*)(cust_data_ptr
+2) & 0xffff;
5600 rssi_compensation_param
.bg_param_a
= *(u16
*)(cust_data_ptr
+4) & 0xffff;
5601 rssi_compensation_param
.bg_param_b
= *(u16
*)(cust_data_ptr
+6) & 0xffff;
5602 rssi_compensation_param
.a_param_a
= *(u16
*)(cust_data_ptr
+8) & 0xffff;
5603 rssi_compensation_param
.a_param_b
= *(u16
*)(cust_data_ptr
+10) &0xffff;
5604 rssi_compensation_param
.reserved
= *(u32
*)(cust_data_ptr
+12);
5606 #ifdef RSSICOMPENSATION_PRINT
5607 A_PRINTF("customerID = 0x%x \n", rssi_compensation_param
.customerID
);
5608 A_PRINTF("enable = 0x%x \n", rssi_compensation_param
.enable
);
5609 A_PRINTF("bg_param_a = 0x%x and %d \n", rssi_compensation_param
.bg_param_a
, rssi_compensation_param
.bg_param_a
);
5610 A_PRINTF("bg_param_b = 0x%x and %d \n", rssi_compensation_param
.bg_param_b
, rssi_compensation_param
.bg_param_b
);
5611 A_PRINTF("a_param_a = 0x%x and %d \n", rssi_compensation_param
.a_param_a
, rssi_compensation_param
.a_param_a
);
5612 A_PRINTF("a_param_b = 0x%x and %d \n", rssi_compensation_param
.a_param_b
, rssi_compensation_param
.a_param_b
);
5613 A_PRINTF("Last 4 bytes = 0x%x \n", rssi_compensation_param
.reserved
);
5616 if (rssi_compensation_param
.enable
!= 0x1) {
5617 rssi_compensation_param
.enable
= 0;
5623 s32
rssi_compensation_calc_tcmd(u32 freq
, s32 rssi
, u32 totalPkt
)
5628 if (rssi_compensation_param
.enable
)
5630 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11a\n"));
5631 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d, totalPkt = %d\n", rssi
,totalPkt
));
5632 rssi
= rssi
* rssi_compensation_param
.a_param_a
+ totalPkt
* rssi_compensation_param
.a_param_b
;
5633 rssi
= (rssi
-50) /100;
5634 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5639 if (rssi_compensation_param
.enable
)
5641 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11bg\n"));
5642 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d, totalPkt = %d\n", rssi
,totalPkt
));
5643 rssi
= rssi
* rssi_compensation_param
.bg_param_a
+ totalPkt
* rssi_compensation_param
.bg_param_b
;
5644 rssi
= (rssi
-50) /100;
5645 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5652 s16
rssi_compensation_calc(struct ar6_softc
*ar
, s16 rssi
)
5654 if (ar
->arBssChannel
> 5000)
5656 if (rssi_compensation_param
.enable
)
5658 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11a\n"));
5659 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d\n", rssi
));
5660 rssi
= rssi
* rssi_compensation_param
.a_param_a
+ rssi_compensation_param
.a_param_b
;
5661 rssi
= (rssi
-50) /100;
5662 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5667 if (rssi_compensation_param
.enable
)
5669 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11bg\n"));
5670 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d\n", rssi
));
5671 rssi
= rssi
* rssi_compensation_param
.bg_param_a
+ rssi_compensation_param
.bg_param_b
;
5672 rssi
= (rssi
-50) /100;
5673 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5680 s16
rssi_compensation_reverse_calc(struct ar6_softc
*ar
, s16 rssi
, bool Above
)
5684 if (ar
->arBssChannel
> 5000)
5686 if (rssi_compensation_param
.enable
)
5688 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11a\n"));
5689 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before rev compensation = %d\n", rssi
));
5691 rssi
= (rssi
- rssi_compensation_param
.a_param_b
) / rssi_compensation_param
.a_param_a
;
5692 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after rev compensation = %d\n", rssi
));
5697 if (rssi_compensation_param
.enable
)
5699 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11bg\n"));
5700 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before rev compensation = %d\n", rssi
));
5703 for (i
=95; i
>=0; i
--) {
5704 if (rssi
<= rssi_compensation_table
[i
]) {
5710 for (i
=0; i
<=95; i
++) {
5711 if (rssi
>= rssi_compensation_table
[i
]) {
5717 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after rev compensation = %d\n", rssi
));
5725 void ap_wapi_rekey_event(struct ar6_softc
*ar
, u8 type
, u8
*mac
)
5727 union iwreq_data wrqu
;
5730 A_MEMZERO(buf
, sizeof(buf
));
5732 strcpy(buf
, "WAPI_REKEY");
5734 memcpy(&buf
[11], mac
, ATH_MAC_LEN
);
5736 A_MEMZERO(&wrqu
, sizeof(wrqu
));
5737 wrqu
.data
.length
= 10+1+ATH_MAC_LEN
;
5738 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
5740 A_PRINTF("WAPI REKEY - %d - %02x:%02x\n", type
, mac
[4], mac
[5]);
5745 ar6000_reinstall_keys(struct ar6_softc
*ar
, u8 key_op_ctrl
)
5748 struct ieee80211req_key
*uik
= &ar
->user_saved_keys
.ucast_ik
;
5749 struct ieee80211req_key
*bik
= &ar
->user_saved_keys
.bcast_ik
;
5750 CRYPTO_TYPE keyType
= ar
->user_saved_keys
.keyType
;
5752 if (IEEE80211_CIPHER_CCKM_KRK
!= uik
->ik_type
) {
5753 if (NONE_CRYPT
== keyType
) {
5754 goto _reinstall_keys_out
;
5757 if (uik
->ik_keylen
) {
5758 status
= wmi_addKey_cmd(ar
->arWmi
, uik
->ik_keyix
,
5759 ar
->user_saved_keys
.keyType
, PAIRWISE_USAGE
,
5760 uik
->ik_keylen
, (u8
*)&uik
->ik_keyrsc
,
5761 uik
->ik_keydata
, key_op_ctrl
, uik
->ik_macaddr
, SYNC_BEFORE_WMIFLAG
);
5765 status
= wmi_add_krk_cmd(ar
->arWmi
, uik
->ik_keydata
);
5768 if (IEEE80211_CIPHER_CCKM_KRK
!= bik
->ik_type
) {
5769 if (NONE_CRYPT
== keyType
) {
5770 goto _reinstall_keys_out
;
5773 if (bik
->ik_keylen
) {
5774 status
= wmi_addKey_cmd(ar
->arWmi
, bik
->ik_keyix
,
5775 ar
->user_saved_keys
.keyType
, GROUP_USAGE
,
5776 bik
->ik_keylen
, (u8
*)&bik
->ik_keyrsc
,
5777 bik
->ik_keydata
, key_op_ctrl
, bik
->ik_macaddr
, NO_SYNC_WMIFLAG
);
5780 status
= wmi_add_krk_cmd(ar
->arWmi
, bik
->ik_keydata
);
5783 _reinstall_keys_out
:
5784 ar
->user_savedkeys_stat
= USER_SAVEDKEYS_STAT_INIT
;
5785 ar
->user_key_ctrl
= 0;
5792 ar6000_dset_open_req(
5810 ar6000_dset_data_req(
5822 ar6000_ap_mode_profile_commit(struct ar6_softc
*ar
)
5825 unsigned long flags
;
5827 /* No change in AP's profile configuration */
5828 if(ar
->ap_profile_flag
==0) {
5829 A_PRINTF("COMMIT: No change in profile!!!\n");
5833 if(!ar
->arSsidLen
) {
5834 A_PRINTF("SSID not set!!!\n");
5838 switch(ar
->arAuthMode
) {
5840 if((ar
->arPairwiseCrypto
!= NONE_CRYPT
) &&
5842 (ar
->arPairwiseCrypto
!= WAPI_CRYPT
) &&
5844 (ar
->arPairwiseCrypto
!= WEP_CRYPT
)) {
5845 A_PRINTF("Cipher not supported in AP mode Open auth\n");
5851 case (WPA_PSK_AUTH
|WPA2_PSK_AUTH
):
5854 A_PRINTF("This key mgmt type not supported in AP mode\n");
5858 /* Update the arNetworkType */
5859 ar
->arNetworkType
= ar
->arNextMode
;
5861 A_MEMZERO(&p
,sizeof(p
));
5862 p
.ssidLength
= ar
->arSsidLen
;
5863 memcpy(p
.ssid
,ar
->arSsid
,p
.ssidLength
);
5864 p
.channel
= ar
->arChannelHint
;
5865 p
.networkType
= ar
->arNetworkType
;
5867 p
.dot11AuthMode
= ar
->arDot11AuthMode
;
5868 p
.authMode
= ar
->arAuthMode
;
5869 p
.pairwiseCryptoType
= ar
->arPairwiseCrypto
;
5870 p
.pairwiseCryptoLen
= ar
->arPairwiseCryptoLen
;
5871 p
.groupCryptoType
= ar
->arGroupCrypto
;
5872 p
.groupCryptoLen
= ar
->arGroupCryptoLen
;
5873 p
.ctrl_flags
= ar
->arConnectCtrlFlags
;
5875 wmi_ap_profile_commit(ar
->arWmi
, &p
);
5876 spin_lock_irqsave(&ar
->arLock
, flags
);
5877 ar
->arConnected
= true;
5878 netif_carrier_on(ar
->arNetDev
);
5879 spin_unlock_irqrestore(&ar
->arLock
, flags
);
5880 ar
->ap_profile_flag
= 0;
5885 ar6000_connect_to_ap(struct ar6_softc
*ar
)
5887 /* The ssid length check prevents second "essid off" from the user,
5888 to be treated as a connect cmd. The second "essid off" is ignored.
5890 if((ar
->arWmiReady
== true) && (ar
->arSsidLen
> 0) && ar
->arNetworkType
!=AP_NETWORK
)
5893 if((ADHOC_NETWORK
!= ar
->arNetworkType
) &&
5894 (NONE_AUTH
==ar
->arAuthMode
) &&
5895 (WEP_CRYPT
==ar
->arPairwiseCrypto
)) {
5896 ar6000_install_static_wep_keys(ar
);
5899 if (!ar
->arUserBssFilter
) {
5900 if (wmi_bssfilter_cmd(ar
->arWmi
, ALL_BSS_FILTER
, 0) != 0) {
5905 if (ar
->arWapiEnable
) {
5906 ar
->arPairwiseCrypto
= WAPI_CRYPT
;
5907 ar
->arPairwiseCryptoLen
= 0;
5908 ar
->arGroupCrypto
= WAPI_CRYPT
;
5909 ar
->arGroupCryptoLen
= 0;
5910 ar
->arAuthMode
= NONE_AUTH
;
5911 ar
->arConnectCtrlFlags
|= CONNECT_IGNORE_WPAx_GROUP_CIPHER
;
5914 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("Connect called with authmode %d dot11 auth %d"\
5915 " PW crypto %d PW crypto Len %d GRP crypto %d"\
5916 " GRP crypto Len %d\n",
5917 ar
->arAuthMode
, ar
->arDot11AuthMode
,
5918 ar
->arPairwiseCrypto
, ar
->arPairwiseCryptoLen
,
5919 ar
->arGroupCrypto
, ar
->arGroupCryptoLen
));
5921 /* Set the listen interval into 1000TUs or more. This value will be indicated to Ap in the conn.
5922 later set it back locally at the STA to 100/1000 TUs depending on the power mode */
5923 if ((ar
->arNetworkType
== INFRA_NETWORK
)) {
5924 wmi_listeninterval_cmd(ar
->arWmi
, max(ar
->arListenIntervalT
, (u16
)A_MAX_WOW_LISTEN_INTERVAL
), 0);
5926 status
= wmi_connect_cmd(ar
->arWmi
, ar
->arNetworkType
,
5927 ar
->arDot11AuthMode
, ar
->arAuthMode
,
5928 ar
->arPairwiseCrypto
, ar
->arPairwiseCryptoLen
,
5929 ar
->arGroupCrypto
,ar
->arGroupCryptoLen
,
5930 ar
->arSsidLen
, ar
->arSsid
,
5931 ar
->arReqBssid
, ar
->arChannelHint
,
5932 ar
->arConnectCtrlFlags
);
5934 wmi_listeninterval_cmd(ar
->arWmi
, ar
->arListenIntervalT
, ar
->arListenIntervalB
);
5935 if (!ar
->arUserBssFilter
) {
5936 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
5941 if ((!(ar
->arConnectCtrlFlags
& CONNECT_DO_WPA_OFFLOAD
)) &&
5942 ((WPA_PSK_AUTH
== ar
->arAuthMode
) || (WPA2_PSK_AUTH
== ar
->arAuthMode
)))
5944 A_TIMEOUT_MS(&ar
->disconnect_timer
, A_DISCONNECT_TIMER_INTERVAL
, 0);
5947 ar
->arConnectCtrlFlags
&= ~CONNECT_DO_WPA_OFFLOAD
;
5949 ar
->arConnectPending
= true;
5956 ar6000_disconnect(struct ar6_softc
*ar
)
5958 if ((ar
->arConnected
== true) || (ar
->arConnectPending
== true)) {
5959 wmi_disconnect_cmd(ar
->arWmi
);
5961 * Disconnect cmd is issued, clear connectPending.
5962 * arConnected will be cleard in disconnect_event notification.
5964 ar
->arConnectPending
= false;
5971 ar6000_ap_mode_get_wpa_ie(struct ar6_softc
*ar
, struct ieee80211req_wpaie
*wpaie
)
5974 conn
= ieee80211_find_conn(ar
, wpaie
->wpa_macaddr
);
5976 A_MEMZERO(wpaie
->wpa_ie
, IEEE80211_MAX_IE
);
5977 A_MEMZERO(wpaie
->rsn_ie
, IEEE80211_MAX_IE
);
5980 memcpy(wpaie
->wpa_ie
, conn
->wpa_ie
, IEEE80211_MAX_IE
);
5987 is_iwioctl_allowed(u8 mode
, u16 cmd
)
5989 if(cmd
>= SIOCSIWCOMMIT
&& cmd
<= SIOCGIWPOWER
) {
5990 cmd
-= SIOCSIWCOMMIT
;
5991 if(sioctl_filter
[cmd
] == 0xFF) return 0;
5992 if(sioctl_filter
[cmd
] & mode
) return 0;
5993 } else if(cmd
>= SIOCIWFIRSTPRIV
&& cmd
<= (SIOCIWFIRSTPRIV
+30)) {
5994 cmd
-= SIOCIWFIRSTPRIV
;
5995 if(pioctl_filter
[cmd
] == 0xFF) return 0;
5996 if(pioctl_filter
[cmd
] & mode
) return 0;
6004 is_xioctl_allowed(u8 mode
, int cmd
)
6006 if(sizeof(xioctl_filter
)-1 < cmd
) {
6007 A_PRINTF("Filter for this cmd=%d not defined\n",cmd
);
6010 if(xioctl_filter
[cmd
] == 0xFF) return 0;
6011 if(xioctl_filter
[cmd
] & mode
) return 0;
6017 ap_set_wapi_key(struct ar6_softc
*ar
, void *ikey
)
6019 struct ieee80211req_key
*ik
= (struct ieee80211req_key
*)ikey
;
6020 KEY_USAGE keyUsage
= 0;
6023 if (memcmp(ik
->ik_macaddr
, bcast_mac
, IEEE80211_ADDR_LEN
) == 0) {
6024 keyUsage
= GROUP_USAGE
;
6026 keyUsage
= PAIRWISE_USAGE
;
6028 A_PRINTF("WAPI_KEY: Type:%d ix:%d mac:%02x:%02x len:%d\n",
6029 keyUsage
, ik
->ik_keyix
, ik
->ik_macaddr
[4], ik
->ik_macaddr
[5],
6032 status
= wmi_addKey_cmd(ar
->arWmi
, ik
->ik_keyix
, WAPI_CRYPT
, keyUsage
,
6033 ik
->ik_keylen
, (u8
*)&ik
->ik_keyrsc
,
6034 ik
->ik_keydata
, KEY_OP_INIT_VAL
, ik
->ik_macaddr
,
6044 void ar6000_peer_event(
6051 for (pos
=0;pos
<6;pos
++)
6052 printk("%02x: ",*(macAddr
+pos
));
6056 #ifdef HTC_TEST_SEND_PKTS
6057 #define HTC_TEST_DUPLICATE 8
6058 static void DoHTCSendPktsTest(struct ar6_softc
*ar
, int MapNo
, HTC_ENDPOINT_ID eid
, struct sk_buff
*dupskb
)
6060 struct ar_cookie
*cookie
;
6061 struct ar_cookie
*cookieArray
[HTC_TEST_DUPLICATE
];
6062 struct sk_buff
*new_skb
;
6065 struct htc_packet_queue pktQueue
;
6066 EPPING_HEADER
*eppingHdr
;
6068 eppingHdr
= A_NETBUF_DATA(dupskb
);
6070 if (eppingHdr
->Cmd_h
== EPPING_CMD_NO_ECHO
) {
6071 /* skip test if this is already a tx perf test */
6075 for (i
= 0; i
< HTC_TEST_DUPLICATE
; i
++,pkts
++) {
6076 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
6077 cookie
= ar6000_alloc_cookie(ar
);
6078 if (cookie
!= NULL
) {
6079 ar
->arTxPending
[eid
]++;
6080 ar
->arTotalTxDataPending
++;
6083 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
6085 if (NULL
== cookie
) {
6089 new_skb
= A_NETBUF_ALLOC(A_NETBUF_LEN(dupskb
));
6091 if (new_skb
== NULL
) {
6092 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
6093 ar6000_free_cookie(ar
,cookie
);
6094 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
6098 A_NETBUF_PUT_DATA(new_skb
, A_NETBUF_DATA(dupskb
), A_NETBUF_LEN(dupskb
));
6099 cookie
->arc_bp
[0] = (unsigned long)new_skb
;
6100 cookie
->arc_bp
[1] = MapNo
;
6101 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
6103 A_NETBUF_DATA(new_skb
),
6104 A_NETBUF_LEN(new_skb
),
6108 cookieArray
[i
] = cookie
;
6111 EPPING_HEADER
*pHdr
= (EPPING_HEADER
*)A_NETBUF_DATA(new_skb
);
6112 pHdr
->Cmd_h
= EPPING_CMD_NO_ECHO
; /* do not echo the packet */
6120 INIT_HTC_PACKET_QUEUE(&pktQueue
);
6122 for (i
= 0; i
< pkts
; i
++) {
6123 HTC_PACKET_ENQUEUE(&pktQueue
,&cookieArray
[i
]->HtcPkt
);
6126 HTCSendPktsMultiple(ar
->arHtcTarget
, &pktQueue
);
6131 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
6133 * Add support for adding and removing a virtual adapter for soft AP.
6134 * Some OS requires different adapters names for station and soft AP mode.
6135 * To support these requirement, create and destroy a netdevice instance
6136 * when the AP mode is operational. A full fledged support for virual device
6137 * is not implemented. Rather a virtual interface is created and is linked
6138 * with the existing physical device instance during the operation of the
6142 int ar6000_start_ap_interface(struct ar6_softc
*ar
)
6144 struct ar_virtual_interface
*arApDev
;
6146 /* Change net_device to point to AP instance */
6147 arApDev
= (struct ar_virtual_interface
*)ar
->arApDev
;
6148 ar
->arNetDev
= arApDev
->arNetDev
;
6153 int ar6000_stop_ap_interface(struct ar6_softc
*ar
)
6155 struct ar_virtual_interface
*arApDev
;
6157 /* Change net_device to point to sta instance */
6158 arApDev
= (struct ar_virtual_interface
*)ar
->arApDev
;
6160 ar
->arNetDev
= arApDev
->arStaNetDev
;
6167 int ar6000_create_ap_interface(struct ar6_softc
*ar
, char *ap_ifname
)
6169 struct net_device
*dev
;
6170 struct ar_virtual_interface
*arApDev
;
6172 dev
= alloc_etherdev(sizeof(struct ar_virtual_interface
));
6174 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_create_ap_interface: can't alloc etherdev\n"));
6179 init_netdev(dev
, ap_ifname
);
6181 if (register_netdev(dev
)) {
6182 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_create_ap_interface: register_netdev failed\n"));
6186 arApDev
= netdev_priv(dev
);
6187 arApDev
->arDev
= ar
;
6188 arApDev
->arNetDev
= dev
;
6189 arApDev
->arStaNetDev
= ar
->arNetDev
;
6191 ar
->arApDev
= arApDev
;
6194 /* Copy the MAC address */
6195 memcpy(dev
->dev_addr
, ar
->arNetDev
->dev_addr
, AR6000_ETH_ADDR_LEN
);
6200 int ar6000_add_ap_interface(struct ar6_softc
*ar
, char *ap_ifname
)
6202 /* Interface already added, need not proceed further */
6203 if (ar
->arApDev
!= NULL
) {
6204 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_add_ap_interface: interface already present \n"));
6208 if (ar6000_create_ap_interface(ar
, ap_ifname
) != 0) {
6212 A_PRINTF("Add AP interface %s \n",ap_ifname
);
6214 return ar6000_start_ap_interface(ar
);
6217 int ar6000_remove_ap_interface(struct ar6_softc
*ar
)
6220 ar6000_stop_ap_interface(ar
);
6222 unregister_netdev(arApNetDev
);
6223 free_netdev(apApNetDev
);
6225 A_PRINTF("Remove AP interface\n");
6233 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
6236 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
6237 EXPORT_SYMBOL(setupbtdev
);