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 fwmode
= 1;
135 unsigned int mbox_yield_limit
= 99;
136 unsigned int enablerssicompensation
= 0;
137 int reduce_credit_dribble
= 1 + HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF
;
138 int allow_trace_signal
= 0;
139 #ifdef CONFIG_HOST_TCMD_SUPPORT
140 unsigned int testmode
=0;
143 unsigned int irqprocmode
= HIF_DEVICE_IRQ_SYNC_ONLY
;//HIF_DEVICE_IRQ_ASYNC_SYNC;
144 unsigned int panic_on_assert
= 1;
145 unsigned int nohifscattersupport
= NOHIFSCATTERSUPPORT_DEFAULT
;
147 unsigned int setuphci
= SETUPHCI_DEFAULT
;
148 unsigned int loghci
= 0;
149 unsigned int setupbtdev
= SETUPBTDEV_DEFAULT
;
150 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
151 unsigned int ar3khcibaud
= AR3KHCIBAUD_DEFAULT
;
152 unsigned int hciuartscale
= HCIUARTSCALE_DEFAULT
;
153 unsigned int hciuartstep
= HCIUARTSTEP_DEFAULT
;
155 unsigned int csumOffload
=0;
156 unsigned int csumOffloadTest
=0;
157 unsigned int eppingtest
=0;
159 module_param_string(ifname
, ifname
, sizeof(ifname
), 0644);
160 module_param(wlaninitmode
, int, 0644);
161 module_param(bypasswmi
, bool, 0644);
162 module_param(debuglevel
, uint
, 0644);
163 module_param(tspecCompliance
, int, 0644);
164 module_param(onebitmode
, uint
, 0644);
165 module_param(busspeedlow
, uint
, 0644);
166 module_param(skipflash
, uint
, 0644);
167 module_param(wmitimeout
, uint
, 0644);
168 module_param(wlanNodeCaching
, uint
, 0644);
169 module_param(logWmiRawMsgs
, uint
, 0644);
170 module_param(enableuartprint
, uint
, 0644);
171 module_param(enabletimerwar
, uint
, 0644);
172 module_param(fwmode
, uint
, 0644);
173 module_param(mbox_yield_limit
, uint
, 0644);
174 module_param(reduce_credit_dribble
, int, 0644);
175 module_param(allow_trace_signal
, int, 0644);
176 module_param(enablerssicompensation
, uint
, 0644);
177 module_param(processDot11Hdr
, uint
, 0644);
178 module_param(csumOffload
, uint
, 0644);
179 #ifdef CONFIG_HOST_TCMD_SUPPORT
180 module_param(testmode
, uint
, 0644);
182 module_param(irqprocmode
, uint
, 0644);
183 module_param(nohifscattersupport
, uint
, 0644);
184 module_param(panic_on_assert
, uint
, 0644);
185 module_param(setuphci
, uint
, 0644);
186 module_param(loghci
, uint
, 0644);
187 module_param(setupbtdev
, uint
, 0644);
188 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
189 module_param(ar3khcibaud
, uint
, 0644);
190 module_param(hciuartscale
, uint
, 0644);
191 module_param(hciuartstep
, uint
, 0644);
193 module_param(eppingtest
, uint
, 0644);
195 /* in 2.6.10 and later this is now a pointer to a uint */
196 unsigned int _mboxnum
= HTC_MAILBOX_NUM_MAX
;
197 #define mboxnum &_mboxnum
200 u32 g_dbg_flags
= DBG_DEFAULTS
;
201 unsigned int debugflags
= 0;
203 unsigned int debughtc
= 0;
204 unsigned int debugbmi
= 0;
205 unsigned int debughif
= 0;
206 unsigned int txcreditsavailable
[HTC_MAILBOX_NUM_MAX
] = {0};
207 unsigned int txcreditsconsumed
[HTC_MAILBOX_NUM_MAX
] = {0};
208 unsigned int txcreditintrenable
[HTC_MAILBOX_NUM_MAX
] = {0};
209 unsigned int txcreditintrenableaggregate
[HTC_MAILBOX_NUM_MAX
] = {0};
210 module_param(debugflags
, uint
, 0644);
211 module_param(debugdriver
, int, 0644);
212 module_param(debughtc
, uint
, 0644);
213 module_param(debugbmi
, uint
, 0644);
214 module_param(debughif
, uint
, 0644);
215 module_param_array(txcreditsavailable
, uint
, mboxnum
, 0644);
216 module_param_array(txcreditsconsumed
, uint
, mboxnum
, 0644);
217 module_param_array(txcreditintrenable
, uint
, mboxnum
, 0644);
218 module_param_array(txcreditintrenableaggregate
, uint
, mboxnum
, 0644);
222 unsigned int resetok
= 1;
223 unsigned int tx_attempt
[HTC_MAILBOX_NUM_MAX
] = {0};
224 unsigned int tx_post
[HTC_MAILBOX_NUM_MAX
] = {0};
225 unsigned int tx_complete
[HTC_MAILBOX_NUM_MAX
] = {0};
226 unsigned int hifBusRequestNumMax
= 40;
227 unsigned int war23838_disabled
= 0;
228 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
229 unsigned int enableAPTCHeuristics
= 1;
230 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
231 module_param_array(tx_attempt
, uint
, mboxnum
, 0644);
232 module_param_array(tx_post
, uint
, mboxnum
, 0644);
233 module_param_array(tx_complete
, uint
, mboxnum
, 0644);
234 module_param(hifBusRequestNumMax
, uint
, 0644);
235 module_param(war23838_disabled
, uint
, 0644);
236 module_param(resetok
, uint
, 0644);
237 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
238 module_param(enableAPTCHeuristics
, uint
, 0644);
239 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
241 #ifdef BLOCK_TX_PATH_FLAG
243 module_param(blocktx
, int, 0644);
244 #endif /* BLOCK_TX_PATH_FLAG */
246 typedef struct user_rssi_compensation_t
{
258 } USER_RSSI_CPENSATION
;
260 static USER_RSSI_CPENSATION rssi_compensation_param
;
262 static s16 rssi_compensation_table
[96];
264 int reconnect_flag
= 0;
265 static ar6k_pal_config_t ar6k_pal_config_g
;
267 /* Function declarations */
268 static int ar6000_init_module(void);
269 static void ar6000_cleanup_module(void);
271 int ar6000_init(struct net_device
*dev
);
272 static int ar6000_open(struct net_device
*dev
);
273 static int ar6000_close(struct net_device
*dev
);
274 static void ar6000_init_control_info(struct ar6_softc
*ar
);
275 static int ar6000_data_tx(struct sk_buff
*skb
, struct net_device
*dev
);
277 void ar6000_destroy(struct net_device
*dev
, unsigned int unregister
);
278 static void ar6000_detect_error(unsigned long ptr
);
279 static void ar6000_set_multicast_list(struct net_device
*dev
);
280 static struct net_device_stats
*ar6000_get_stats(struct net_device
*dev
);
282 static void disconnect_timer_handler(unsigned long ptr
);
284 void read_rssi_compensation_param(struct ar6_softc
*ar
);
287 * HTC service connection handlers
289 static int ar6000_avail_ev(void *context
, void *hif_handle
);
291 static int ar6000_unavail_ev(void *context
, void *hif_handle
);
293 int ar6000_configure_target(struct ar6_softc
*ar
);
295 static void ar6000_target_failure(void *Instance
, int Status
);
297 static void ar6000_rx(void *Context
, struct htc_packet
*pPacket
);
299 static void ar6000_rx_refill(void *Context
,HTC_ENDPOINT_ID Endpoint
);
301 static void ar6000_tx_complete(void *Context
, struct htc_packet_queue
*pPackets
);
303 static HTC_SEND_FULL_ACTION
ar6000_tx_queue_full(void *Context
, struct htc_packet
*pPacket
);
305 static void ar6000_alloc_netbufs(A_NETBUF_QUEUE_T
*q
, u16 num
);
306 static void ar6000_deliver_frames_to_nw_stack(void * dev
, void *osbuf
);
307 //static void ar6000_deliver_frames_to_bt_stack(void * dev, void *osbuf);
309 static struct htc_packet
*ar6000_alloc_amsdu_rxbuf(void *Context
, HTC_ENDPOINT_ID Endpoint
, int Length
);
311 static void ar6000_refill_amsdu_rxbufs(struct ar6_softc
*ar
, int Count
);
313 static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc
*ar
);
316 ar6000_sysfs_bmi_read(struct file
*fp
, struct kobject
*kobj
,
317 struct bin_attribute
*bin_attr
,
318 char *buf
, loff_t pos
, size_t count
);
321 ar6000_sysfs_bmi_write(struct file
*fp
, struct kobject
*kobj
,
322 struct bin_attribute
*bin_attr
,
323 char *buf
, loff_t pos
, size_t count
);
326 ar6000_sysfs_bmi_init(struct ar6_softc
*ar
);
328 void ar6k_cleanup_hci_pal(struct ar6_softc
*ar
);
331 ar6000_sysfs_bmi_deinit(struct ar6_softc
*ar
);
334 ar6000_sysfs_bmi_get_config(struct ar6_softc
*ar
, u32 mode
);
340 struct net_device
*ar6000_devices
[MAX_AR6000
];
341 static int is_netdev_registered
;
342 DECLARE_WAIT_QUEUE_HEAD(arEvent
);
343 static void ar6000_cookie_init(struct ar6_softc
*ar
);
344 static void ar6000_cookie_cleanup(struct ar6_softc
*ar
);
345 static void ar6000_free_cookie(struct ar6_softc
*ar
, struct ar_cookie
* cookie
);
346 static struct ar_cookie
*ar6000_alloc_cookie(struct ar6_softc
*ar
);
348 static int ar6000_reinstall_keys(struct ar6_softc
*ar
,u8 key_op_ctrl
);
350 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
351 struct net_device
*arApNetDev
;
352 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
354 static struct ar_cookie s_ar_cookie_mem
[MAX_COOKIE_NUM
];
356 #define HOST_INTEREST_ITEM_ADDRESS(ar, item) \
357 (((ar)->arTargetType == TARGET_TYPE_AR6002) ? AR6002_HOST_INTEREST_ITEM_ADDRESS(item) : \
358 (((ar)->arTargetType == TARGET_TYPE_AR6003) ? AR6003_HOST_INTEREST_ITEM_ADDRESS(item) : 0))
361 static struct net_device_ops ar6000_netdev_ops
= {
363 .ndo_open
= ar6000_open
,
364 .ndo_stop
= ar6000_close
,
365 .ndo_get_stats
= ar6000_get_stats
,
366 .ndo_start_xmit
= ar6000_data_tx
,
367 .ndo_set_multicast_list
= ar6000_set_multicast_list
,
370 /* Debug log support */
373 * Flag to govern whether the debug logs should be parsed in the kernel
374 * or reported to the application.
376 #define REPORT_DEBUG_LOGS_TO_APP
379 ar6000_set_host_app_area(struct ar6_softc
*ar
)
382 struct host_app_area_s host_app_area
;
384 /* Fetch the address of the host_app_area_s instance in the host interest area */
385 address
= TARG_VTOP(ar
->arTargetType
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_app_host_interest
));
386 if (ar6000_ReadRegDiag(ar
->arHifDevice
, &address
, &data
) != 0) {
389 address
= TARG_VTOP(ar
->arTargetType
, data
);
390 host_app_area
.wmi_protocol_ver
= WMI_PROTOCOL_VERSION
;
391 if (ar6000_WriteDataDiag(ar
->arHifDevice
, address
,
392 (u8
*)&host_app_area
,
393 sizeof(struct host_app_area_s
)) != 0)
401 u32
dbglog_get_debug_hdr_ptr(struct ar6_softc
*ar
)
407 address
= TARG_VTOP(ar
->arTargetType
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_dbglog_hdr
));
408 if ((status
= ar6000_ReadDataDiag(ar
->arHifDevice
, address
,
409 (u8
*)¶m
, 4)) != 0)
418 * The dbglog module has been initialized. Its ok to access the relevant
419 * data stuctures over the diagnostic window.
422 ar6000_dbglog_init_done(struct ar6_softc
*ar
)
424 ar
->dbglog_init_done
= true;
427 u32
dbglog_get_debug_fragment(s8
*datap
, u32 len
, u32 limit
)
436 buffer
= (s32
*)datap
;
437 length
= (limit
>> 2);
442 while (count
< length
) {
443 numargs
= DBGLOG_GET_NUMARGS(buffer
[count
]);
444 fraglen
= (count
<< 2);
445 count
+= numargs
+ 1;
453 dbglog_parse_debug_logs(s8
*datap
, u32 len
)
464 buffer
= (s32
*)datap
;
466 while (count
< length
) {
467 debugid
= DBGLOG_GET_DBGID(buffer
[count
]);
468 moduleid
= DBGLOG_GET_MODULEID(buffer
[count
]);
469 numargs
= DBGLOG_GET_NUMARGS(buffer
[count
]);
470 timestamp
= DBGLOG_GET_TIMESTAMP(buffer
[count
]);
473 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("%d %d (%d)\n", moduleid
, debugid
, timestamp
));
477 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("%d %d (%d): 0x%x\n", moduleid
, debugid
,
478 timestamp
, buffer
[count
+1]));
482 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("%d %d (%d): 0x%x, 0x%x\n", moduleid
, debugid
,
483 timestamp
, buffer
[count
+1], buffer
[count
+2]));
487 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Invalid args: %d\n", numargs
));
489 count
+= numargs
+ 1;
494 ar6000_dbglog_get_debug_logs(struct ar6_softc
*ar
)
496 u32 data
[8]; /* Should be able to accommodate struct dbglog_buf_s */
503 if (!ar
->dbglog_init_done
) return A_ERROR
;
506 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
508 if (ar
->dbgLogFetchInProgress
) {
509 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
513 /* block out others */
514 ar
->dbgLogFetchInProgress
= true;
516 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
518 debug_hdr_ptr
= dbglog_get_debug_hdr_ptr(ar
);
519 printk("debug_hdr_ptr: 0x%x\n", debug_hdr_ptr
);
521 /* Get the contents of the ring buffer */
523 address
= TARG_VTOP(ar
->arTargetType
, debug_hdr_ptr
);
524 length
= 4 /* sizeof(dbuf) */ + 4 /* sizeof(dropped) */;
525 A_MEMZERO(data
, sizeof(data
));
526 ar6000_ReadDataDiag(ar
->arHifDevice
, address
, (u8
*)data
, length
);
527 address
= TARG_VTOP(ar
->arTargetType
, data
[0] /* dbuf */);
529 dropped
= data
[1]; /* dropped */
530 length
= 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */;
531 A_MEMZERO(data
, sizeof(data
));
532 ar6000_ReadDataDiag(ar
->arHifDevice
, address
, (u8
*)&data
, length
);
535 address
= TARG_VTOP(ar
->arTargetType
, data
[1] /* buffer*/);
536 length
= data
[3]; /* length */
537 if ((length
) && (length
<= data
[2] /* bufsize*/)) {
538 /* Rewind the index if it is about to overrun the buffer */
539 if (ar
->log_cnt
> (DBGLOG_HOST_LOG_BUFFER_SIZE
- length
)) {
542 if(0 != ar6000_ReadDataDiag(ar
->arHifDevice
, address
,
543 (u8
*)&ar
->log_buffer
[ar
->log_cnt
], length
))
547 ar6000_dbglog_event(ar
, dropped
, (s8
*)&ar
->log_buffer
[ar
->log_cnt
], length
);
548 ar
->log_cnt
+= length
;
550 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("Length: %d (Total size: %d)\n",
554 address
= TARG_VTOP(ar
->arTargetType
, data
[0] /* next */);
555 length
= 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */;
556 A_MEMZERO(data
, sizeof(data
));
557 if(0 != ar6000_ReadDataDiag(ar
->arHifDevice
, address
,
558 (u8
*)&data
, length
))
563 } while (address
!= firstbuf
);
566 ar
->dbgLogFetchInProgress
= false;
572 ar6000_dbglog_event(struct ar6_softc
*ar
, u32 dropped
,
573 s8
*buffer
, u32 length
)
575 #ifdef REPORT_DEBUG_LOGS_TO_APP
576 #define MAX_WIRELESS_EVENT_SIZE 252
578 * Break it up into chunks of MAX_WIRELESS_EVENT_SIZE bytes of messages.
579 * There seems to be a limitation on the length of message that could be
580 * transmitted to the user app via this mechanism.
585 send
= dbglog_get_debug_fragment(&buffer
[sent
], length
- sent
,
586 MAX_WIRELESS_EVENT_SIZE
);
589 send
= dbglog_get_debug_fragment(&buffer
[sent
], length
- sent
,
590 MAX_WIRELESS_EVENT_SIZE
);
593 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Dropped logs: 0x%x\nDebug info length: %d\n",
596 /* Interpret the debug logs */
597 dbglog_parse_debug_logs((s8
*)buffer
, length
);
598 #endif /* REPORT_DEBUG_LOGS_TO_APP */
603 ar6000_init_module(void)
605 static int probed
= 0;
607 OSDRV_CALLBACKS osdrvCallbacks
;
609 a_module_debug_support_init();
612 /* check for debug mask overrides */
614 ATH_DEBUG_SET_DEBUG_MASK(htc
,debughtc
);
617 ATH_DEBUG_SET_DEBUG_MASK(bmi
,debugbmi
);
620 ATH_DEBUG_SET_DEBUG_MASK(hif
,debughif
);
622 if (debugdriver
!= 0) {
623 ATH_DEBUG_SET_DEBUG_MASK(driver
,debugdriver
);
628 A_REGISTER_MODULE_DEBUG_INFO(driver
);
630 A_MEMZERO(&osdrvCallbacks
,sizeof(osdrvCallbacks
));
631 osdrvCallbacks
.deviceInsertedHandler
= ar6000_avail_ev
;
632 osdrvCallbacks
.deviceRemovedHandler
= ar6000_unavail_ev
;
634 osdrvCallbacks
.deviceSuspendHandler
= ar6000_suspend_ev
;
635 osdrvCallbacks
.deviceResumeHandler
= ar6000_resume_ev
;
636 osdrvCallbacks
.devicePowerChangeHandler
= ar6000_power_change_ev
;
640 /* Set the debug flags if specified at load time */
643 g_dbg_flags
= debugflags
;
652 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
653 memset(&aptcTR
, 0, sizeof(APTC_TRAFFIC_RECORD
));
654 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
656 r
= HIFInit(&osdrvCallbacks
);
664 ar6000_cleanup_module(void)
667 struct net_device
*ar6000_netdev
;
669 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
670 /* Delete the Adaptive Power Control timer */
671 if (timer_pending(&aptcTimer
)) {
672 del_timer_sync(&aptcTimer
);
674 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
676 for (i
=0; i
< MAX_AR6000
; i
++) {
677 if (ar6000_devices
[i
] != NULL
) {
678 ar6000_netdev
= ar6000_devices
[i
];
679 ar6000_devices
[i
] = NULL
;
680 ar6000_destroy(ar6000_netdev
, 1);
684 HIFShutDownDevice(NULL
);
686 a_module_debug_support_cleanup();
688 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("ar6000_cleanup: success\n"));
691 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
693 aptcTimerHandler(unsigned long arg
)
697 struct ar6_softc
*ar
;
700 ar
= (struct ar6_softc
*)arg
;
701 A_ASSERT(ar
!= NULL
);
702 A_ASSERT(!timer_pending(&aptcTimer
));
704 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
706 /* Get the number of bytes transferred */
707 numbytes
= aptcTR
.bytesTransmitted
+ aptcTR
.bytesReceived
;
708 aptcTR
.bytesTransmitted
= aptcTR
.bytesReceived
= 0;
710 /* Calculate and decide based on throughput thresholds */
711 throughput
= ((numbytes
* 8)/APTC_TRAFFIC_SAMPLING_INTERVAL
); /* Kbps */
712 if (throughput
< APTC_LOWER_THROUGHPUT_THRESHOLD
) {
713 /* Enable Sleep and delete the timer */
714 A_ASSERT(ar
->arWmiReady
== true);
715 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
716 status
= wmi_powermode_cmd(ar
->arWmi
, REC_POWER
);
717 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
718 A_ASSERT(status
== 0);
719 aptcTR
.timerScheduled
= false;
721 A_TIMEOUT_MS(&aptcTimer
, APTC_TRAFFIC_SAMPLING_INTERVAL
, 0);
724 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
726 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
729 ar6000_alloc_netbufs(A_NETBUF_QUEUE_T
*q
, u16 num
)
734 if((osbuf
= A_NETBUF_ALLOC(AR6000_BUFFER_SIZE
))) {
735 A_NETBUF_ENQUEUE(q
, osbuf
);
743 A_PRINTF("%s(), allocation of netbuf failed", __func__
);
747 static struct bin_attribute bmi_attr
= {
748 .attr
= {.name
= "bmi", .mode
= 0600},
749 .read
= ar6000_sysfs_bmi_read
,
750 .write
= ar6000_sysfs_bmi_write
,
754 ar6000_sysfs_bmi_read(struct file
*fp
, struct kobject
*kobj
,
755 struct bin_attribute
*bin_attr
,
756 char *buf
, loff_t pos
, size_t count
)
759 struct ar6_softc
*ar
;
760 struct hif_device_os_device_info
*osDevInfo
;
762 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Read %d bytes\n", (u32
)count
));
763 for (index
=0; index
< MAX_AR6000
; index
++) {
764 ar
= (struct ar6_softc
*)ar6k_priv(ar6000_devices
[index
]);
765 osDevInfo
= &ar
->osDevInfo
;
766 if (kobj
== (&(((struct device
*)osDevInfo
->pOSDevice
)->kobj
))) {
771 if (index
== MAX_AR6000
) return 0;
773 if ((BMIRawRead(ar
->arHifDevice
, (u8
*)buf
, count
, true)) != 0) {
781 ar6000_sysfs_bmi_write(struct file
*fp
, struct kobject
*kobj
,
782 struct bin_attribute
*bin_attr
,
783 char *buf
, loff_t pos
, size_t count
)
786 struct ar6_softc
*ar
;
787 struct hif_device_os_device_info
*osDevInfo
;
789 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Write %d bytes\n", (u32
)count
));
790 for (index
=0; index
< MAX_AR6000
; index
++) {
791 ar
= (struct ar6_softc
*)ar6k_priv(ar6000_devices
[index
]);
792 osDevInfo
= &ar
->osDevInfo
;
793 if (kobj
== (&(((struct device
*)osDevInfo
->pOSDevice
)->kobj
))) {
798 if (index
== MAX_AR6000
) return 0;
800 if ((BMIRawWrite(ar
->arHifDevice
, (u8
*)buf
, count
)) != 0) {
808 ar6000_sysfs_bmi_init(struct ar6_softc
*ar
)
812 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Creating sysfs entry\n"));
813 A_MEMZERO(&ar
->osDevInfo
, sizeof(struct hif_device_os_device_info
));
815 /* Get the underlying OS device */
816 status
= HIFConfigureDevice(ar
->arHifDevice
,
817 HIF_DEVICE_GET_OS_DEVICE
,
819 sizeof(struct hif_device_os_device_info
));
822 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI: Failed to get OS device info from HIF\n"));
826 /* Create a bmi entry in the sysfs filesystem */
827 if ((sysfs_create_bin_file(&(((struct device
*)ar
->osDevInfo
.pOSDevice
)->kobj
), &bmi_attr
)) < 0)
829 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMI: Failed to create entry for bmi in sysfs filesystem\n"));
837 ar6000_sysfs_bmi_deinit(struct ar6_softc
*ar
)
839 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Deleting sysfs entry\n"));
841 sysfs_remove_bin_file(&(((struct device
*)ar
->osDevInfo
.pOSDevice
)->kobj
), &bmi_attr
);
844 #define bmifn(fn) do { \
846 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__)); \
851 #ifdef SOFTMAC_FILE_USED
852 #define AR6002_MAC_ADDRESS_OFFSET 0x0A
853 #define AR6003_MAC_ADDRESS_OFFSET 0x16
855 void calculate_crc(u32 TargetType
, u8
*eeprom_data
)
863 if (TargetType
== TARGET_TYPE_AR6001
)
866 ptr_crc
= (u16
*)eeprom_data
;
868 else if (TargetType
== TARGET_TYPE_AR6003
)
871 ptr_crc
= (u16
*)((u8
*)eeprom_data
+ 0x04);
876 ptr_crc
= (u16
*)((u8
*)eeprom_data
+ 0x04);
883 // Recalculate new CRC
885 ptr16_eeprom
= (u16
*)eeprom_data
;
886 for (i
= 0;i
< eeprom_size
; i
+= 2)
888 checksum
= checksum
^ (*ptr16_eeprom
);
891 checksum
= 0xFFFF ^ checksum
;
896 ar6000_softmac_update(struct ar6_softc
*ar
, u8
*eeprom_data
, size_t size
)
898 const char *source
= "random generated";
899 const struct firmware
*softmac_entry
;
901 switch (ar
->arTargetType
) {
902 case TARGET_TYPE_AR6002
:
903 ptr_mac
= (u8
*)((u8
*)eeprom_data
+ AR6002_MAC_ADDRESS_OFFSET
);
905 case TARGET_TYPE_AR6003
:
906 ptr_mac
= (u8
*)((u8
*)eeprom_data
+ AR6003_MAC_ADDRESS_OFFSET
);
909 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Invalid Target Type\n"));
912 printk(KERN_DEBUG
"MAC from EEPROM %pM\n", ptr_mac
);
914 /* create a random MAC in case we cannot read file from system */
918 ptr_mac
[3] = random32() & 0xff;
919 ptr_mac
[4] = random32() & 0xff;
920 ptr_mac
[5] = random32() & 0xff;
921 if ((A_REQUEST_FIRMWARE(&softmac_entry
, "softmac", ((struct device
*)ar
->osDevInfo
.pOSDevice
))) == 0)
923 char *macbuf
= A_MALLOC_NOWAIT(softmac_entry
->size
+1);
925 unsigned int softmac
[6];
926 memcpy(macbuf
, softmac_entry
->data
, softmac_entry
->size
);
927 macbuf
[softmac_entry
->size
] = '\0';
928 if (sscanf(macbuf
, "%02x:%02x:%02x:%02x:%02x:%02x",
929 &softmac
[0], &softmac
[1], &softmac
[2],
930 &softmac
[3], &softmac
[4], &softmac
[5])==6) {
932 for (i
=0; i
<6; ++i
) {
933 ptr_mac
[i
] = softmac
[i
] & 0xff;
935 source
= "softmac file";
939 A_RELEASE_FIRMWARE(softmac_entry
);
941 printk(KERN_DEBUG
"MAC from %s %pM\n", source
, ptr_mac
);
942 calculate_crc(ar
->arTargetType
, eeprom_data
);
944 #endif /* SOFTMAC_FILE_USED */
947 ar6000_transfer_bin_file(struct ar6_softc
*ar
, AR6K_BIN_FILE file
, u32 address
, bool compressed
)
950 const char *filename
;
951 const struct firmware
*fw_entry
;
956 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
957 filename
= AR6003_REV1_OTP_FILE
;
958 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
959 filename
= AR6003_REV2_OTP_FILE
;
961 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
966 case AR6K_FIRMWARE_FILE
:
967 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
968 filename
= AR6003_REV1_FIRMWARE_FILE
;
969 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
970 filename
= AR6003_REV2_FIRMWARE_FILE
;
972 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
978 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
979 filename
= AR6003_REV1_EPPING_FIRMWARE_FILE
;
980 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
981 filename
= AR6003_REV2_EPPING_FIRMWARE_FILE
;
983 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("eppingtest : unsupported firmware revision: %d\n",
984 ar
->arVersion
.target_ver
));
990 #ifdef CONFIG_HOST_TCMD_SUPPORT
992 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
993 filename
= AR6003_REV1_TCMD_FIRMWARE_FILE
;
994 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
995 filename
= AR6003_REV2_TCMD_FIRMWARE_FILE
;
997 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1003 #ifdef HTC_RAW_INTERFACE
1004 if (!eppingtest
&& bypasswmi
) {
1005 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1006 filename
= AR6003_REV1_ART_FIRMWARE_FILE
;
1007 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1008 filename
= AR6003_REV2_ART_FIRMWARE_FILE
;
1010 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1018 case AR6K_PATCH_FILE
:
1019 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1020 filename
= AR6003_REV1_PATCH_FILE
;
1021 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1022 filename
= AR6003_REV2_PATCH_FILE
;
1024 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1029 case AR6K_BOARD_DATA_FILE
:
1030 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1031 filename
= AR6003_REV1_BOARD_DATA_FILE
;
1032 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1033 filename
= AR6003_REV2_BOARD_DATA_FILE
;
1035 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1041 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown file type: %d\n", file
));
1044 if ((A_REQUEST_FIRMWARE(&fw_entry
, filename
, ((struct device
*)ar
->osDevInfo
.pOSDevice
))) != 0)
1046 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Failed to get %s\n", filename
));
1050 #ifdef SOFTMAC_FILE_USED
1051 if (file
==AR6K_BOARD_DATA_FILE
&& fw_entry
->data
) {
1052 ar6000_softmac_update(ar
, (u8
*)fw_entry
->data
, fw_entry
->size
);
1057 fw_entry_size
= fw_entry
->size
;
1059 /* Load extended board data for AR6003 */
1060 if ((file
==AR6K_BOARD_DATA_FILE
) && (fw_entry
->data
)) {
1061 u32 board_ext_address
;
1062 u32 board_ext_data_size
;
1063 u32 board_data_size
;
1065 board_ext_data_size
= (((ar
)->arTargetType
== TARGET_TYPE_AR6002
) ? AR6002_BOARD_EXT_DATA_SZ
: \
1066 (((ar
)->arTargetType
== TARGET_TYPE_AR6003
) ? AR6003_BOARD_EXT_DATA_SZ
: 0));
1068 board_data_size
= (((ar
)->arTargetType
== TARGET_TYPE_AR6002
) ? AR6002_BOARD_DATA_SZ
: \
1069 (((ar
)->arTargetType
== TARGET_TYPE_AR6003
) ? AR6003_BOARD_DATA_SZ
: 0));
1071 /* Determine where in Target RAM to write Board Data */
1072 bmifn(BMIReadMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_ext_data
), (u8
*)&board_ext_address
, 4));
1073 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("Board extended Data download address: 0x%x\n", board_ext_address
));
1075 /* check whether the target has allocated memory for extended board data and file contains extended board data */
1076 if ((board_ext_address
) && (fw_entry
->size
== (board_data_size
+ board_ext_data_size
))) {
1079 status
= BMIWriteMemory(ar
->arHifDevice
, board_ext_address
, (u8
*)(fw_entry
->data
+ board_data_size
), board_ext_data_size
);
1082 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI operation failed: %d\n", __LINE__
));
1083 A_RELEASE_FIRMWARE(fw_entry
);
1087 /* Record the fact that extended board Data IS initialized */
1089 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_ext_data_initialized
), (u8
*)¶m
, 4));
1091 fw_entry_size
= board_data_size
;
1095 status
= BMIFastDownload(ar
->arHifDevice
, address
, (u8
*)fw_entry
->data
, fw_entry_size
);
1097 status
= BMIWriteMemory(ar
->arHifDevice
, address
, (u8
*)fw_entry
->data
, fw_entry_size
);
1101 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI operation failed: %d\n", __LINE__
));
1102 A_RELEASE_FIRMWARE(fw_entry
);
1105 A_RELEASE_FIRMWARE(fw_entry
);
1110 ar6000_update_bdaddr(struct ar6_softc
*ar
)
1113 if (setupbtdev
!= 0) {
1116 if (BMIReadMemory(ar
->arHifDevice
,
1117 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_data
), (u8
*)&address
, 4) != 0)
1119 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for hi_board_data failed\n"));
1123 if (BMIReadMemory(ar
->arHifDevice
, address
+ BDATA_BDADDR_OFFSET
, (u8
*)ar
->bdaddr
, 6) != 0)
1125 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for BD address failed\n"));
1128 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BDADDR 0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", ar
->bdaddr
[0],
1129 ar
->bdaddr
[1], ar
->bdaddr
[2], ar
->bdaddr
[3],
1130 ar
->bdaddr
[4], ar
->bdaddr
[5]));
1137 ar6000_sysfs_bmi_get_config(struct ar6_softc
*ar
, u32 mode
)
1139 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Requesting device specific configuration\n"));
1141 if (mode
== WLAN_INIT_MODE_UDEV
) {
1143 const struct firmware
*fw_entry
;
1145 /* Get config using udev through a script in user space */
1146 sprintf(version
, "%2.2x", ar
->arVersion
.target_ver
);
1147 if ((A_REQUEST_FIRMWARE(&fw_entry
, version
, ((struct device
*)ar
->osDevInfo
.pOSDevice
))) != 0)
1149 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI: Failure to get configuration for target version: %s\n", version
));
1153 A_RELEASE_FIRMWARE(fw_entry
);
1155 /* The config is contained within the driver itself */
1157 u32 param
, options
, sleep
, address
;
1159 /* Temporarily disable system sleep */
1160 address
= MBOX_BASE_ADDRESS
+ LOCAL_SCRATCH_ADDRESS
;
1161 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1163 param
|= AR6K_OPTION_SLEEP_DISABLE
;
1164 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1166 address
= RTC_BASE_ADDRESS
+ SYSTEM_SLEEP_ADDRESS
;
1167 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1169 param
|= WLAN_SYSTEM_SLEEP_DISABLE_SET(1);
1170 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1171 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("old options: %d, old sleep: %d\n", options
, sleep
));
1173 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1174 /* Program analog PLL register */
1175 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, ANALOG_INTF_BASE_ADDRESS
+ 0x284, 0xF9104001));
1176 /* Run at 80/88MHz by default */
1177 param
= CPU_CLOCK_STANDARD_SET(1);
1179 /* Run at 40/44MHz by default */
1180 param
= CPU_CLOCK_STANDARD_SET(0);
1182 address
= RTC_BASE_ADDRESS
+ CPU_CLOCK_ADDRESS
;
1183 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1186 if (ar
->arTargetType
== TARGET_TYPE_AR6002
) {
1187 bmifn(BMIReadMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_ext_clk_detected
), (u8
*)¶m
, 4));
1190 /* LPO_CAL.ENABLE = 1 if no external clk is detected */
1192 address
= RTC_BASE_ADDRESS
+ LPO_CAL_ADDRESS
;
1193 param
= LPO_CAL_ENABLE_SET(1);
1194 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1197 /* Venus2.0: Lower SDIO pad drive strength,
1198 * temporary WAR to avoid SDIO CRC error */
1199 if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1200 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("AR6K: Temporary WAR to avoid SDIO CRC error\n"));
1202 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN10_ADDRESS
;
1203 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1205 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN11_ADDRESS
;
1206 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1208 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN12_ADDRESS
;
1209 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1211 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN13_ADDRESS
;
1212 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1215 #ifdef FORCE_INTERNAL_CLOCK
1216 /* Ignore external clock, if any, and force use of internal clock */
1217 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1218 /* hi_ext_clk_detected = 0 */
1220 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_ext_clk_detected
), (u8
*)¶m
, 4));
1222 /* CLOCK_CONTROL &= ~LF_CLK32 */
1223 address
= RTC_BASE_ADDRESS
+ CLOCK_CONTROL_ADDRESS
;
1224 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1225 param
&= (~CLOCK_CONTROL_LF_CLK32_SET(1));
1226 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1228 #endif /* FORCE_INTERNAL_CLOCK */
1230 /* Transfer Board Data from Target EEPROM to Target RAM */
1231 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1232 /* Determine where in Target RAM to write Board Data */
1233 bmifn(BMIReadMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_data
), (u8
*)&address
, 4));
1234 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("Board Data download address: 0x%x\n", address
));
1236 /* Write EEPROM data to Target RAM */
1237 if ((ar6000_transfer_bin_file(ar
, AR6K_BOARD_DATA_FILE
, address
, false)) != 0) {
1241 /* Record the fact that Board Data IS initialized */
1243 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_data_initialized
), (u8
*)¶m
, 4));
1245 /* Transfer One time Programmable data */
1246 AR6K_DATA_DOWNLOAD_ADDRESS(address
, ar
->arVersion
.target_ver
);
1247 status
= ar6000_transfer_bin_file(ar
, AR6K_OTP_FILE
, address
, true);
1249 /* Execute the OTP code */
1251 AR6K_APP_START_OVERRIDE_ADDRESS(address
, ar
->arVersion
.target_ver
);
1252 bmifn(BMIExecute(ar
->arHifDevice
, address
, ¶m
));
1253 } else if (status
!= A_ENOENT
) {
1257 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Programming of board data for chip %d not supported\n", ar
->arTargetType
));
1261 /* Download Target firmware */
1262 AR6K_DATA_DOWNLOAD_ADDRESS(address
, ar
->arVersion
.target_ver
);
1263 if ((ar6000_transfer_bin_file(ar
, AR6K_FIRMWARE_FILE
, address
, true)) != 0) {
1267 /* Set starting address for firmware */
1268 AR6K_APP_START_OVERRIDE_ADDRESS(address
, ar
->arVersion
.target_ver
);
1269 bmifn(BMISetAppStart(ar
->arHifDevice
, address
));
1271 /* Apply the patches */
1272 AR6K_PATCH_DOWNLOAD_ADDRESS(address
, ar
->arVersion
.target_ver
);
1273 if ((ar6000_transfer_bin_file(ar
, AR6K_PATCH_FILE
, address
, false)) != 0) {
1278 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_dset_list_head
), (u8
*)¶m
, 4));
1280 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1281 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1282 /* Reserve 5.5K of RAM */
1284 } else { /* AR6003_REV2_VERSION */
1285 /* Reserve 6.5K of RAM */
1288 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_end_RAM_reserve_sz
), (u8
*)¶m
, 4));
1291 /* Restore system sleep */
1292 address
= RTC_BASE_ADDRESS
+ SYSTEM_SLEEP_ADDRESS
;
1293 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, sleep
));
1295 address
= MBOX_BASE_ADDRESS
+ LOCAL_SCRATCH_ADDRESS
;
1296 param
= options
| 0x20;
1297 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1299 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1300 /* Configure GPIO AR6003 UART */
1301 #ifndef CONFIG_AR600x_DEBUG_UART_TX_PIN
1302 #define CONFIG_AR600x_DEBUG_UART_TX_PIN 8
1304 param
= CONFIG_AR600x_DEBUG_UART_TX_PIN
;
1305 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_dbg_uart_txpin
), (u8
*)¶m
, 4));
1307 #if (CONFIG_AR600x_DEBUG_UART_TX_PIN == 23)
1309 address
= GPIO_BASE_ADDRESS
+ CLOCK_GPIO_ADDRESS
;
1310 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1311 param
|= CLOCK_GPIO_BT_CLK_OUT_EN_SET(1);
1312 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1316 /* Configure GPIO for BT Reset */
1317 #ifdef ATH6KL_CONFIG_GPIO_BT_RESET
1318 #define CONFIG_AR600x_BT_RESET_PIN 0x16
1319 param
= CONFIG_AR600x_BT_RESET_PIN
;
1320 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_hci_uart_support_pins
), (u8
*)¶m
, 4));
1321 #endif /* ATH6KL_CONFIG_GPIO_BT_RESET */
1323 /* Configure UART flow control polarity */
1324 #ifndef CONFIG_ATH6KL_BT_UART_FC_POLARITY
1325 #define CONFIG_ATH6KL_BT_UART_FC_POLARITY 0
1328 #if (CONFIG_ATH6KL_BT_UART_FC_POLARITY == 1)
1329 if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1330 param
= ((CONFIG_ATH6KL_BT_UART_FC_POLARITY
<< 1) & 0x2);
1331 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_hci_uart_pwr_mgmt_params
), (u8
*)¶m
, 4));
1333 #endif /* CONFIG_ATH6KL_BT_UART_FC_POLARITY */
1336 #ifdef HTC_RAW_INTERFACE
1337 if (!eppingtest
&& bypasswmi
) {
1338 /* Don't run BMIDone for ART mode and force resetok=0 */
1342 #endif /* HTC_RAW_INTERFACE */
1349 ar6000_configure_target(struct ar6_softc
*ar
)
1352 if (enableuartprint
) {
1354 if (BMIWriteMemory(ar
->arHifDevice
,
1355 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_serial_enable
),
1359 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for enableuartprint failed \n"));
1362 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Serial console prints enabled\n"));
1365 /* Tell target which HTC version it is used*/
1366 param
= HTC_PROTOCOL_VERSION
;
1367 if (BMIWriteMemory(ar
->arHifDevice
,
1368 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_app_host_interest
),
1372 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for htc version failed \n"));
1376 #ifdef CONFIG_HOST_TCMD_SUPPORT
1378 ar
->arTargetMode
= AR6000_TCMD_MODE
;
1380 ar
->arTargetMode
= AR6000_WLAN_MODE
;
1383 if (enabletimerwar
) {
1386 if (BMIReadMemory(ar
->arHifDevice
,
1387 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1391 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for enabletimerwar failed \n"));
1395 param
|= HI_OPTION_TIMER_WAR
;
1397 if (BMIWriteMemory(ar
->arHifDevice
,
1398 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1402 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for enabletimerwar failed \n"));
1405 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Timer WAR enabled\n"));
1408 /* set the firmware mode to STA/IBSS/AP */
1412 if (BMIReadMemory(ar
->arHifDevice
,
1413 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1417 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for setting fwmode failed \n"));
1421 param
|= (fwmode
<< HI_OPTION_FW_MODE_SHIFT
);
1423 if (BMIWriteMemory(ar
->arHifDevice
,
1424 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1428 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for setting fwmode failed \n"));
1431 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Firmware mode set\n"));
1434 #ifdef ATH6KL_DISABLE_TARGET_DBGLOGS
1438 if (BMIReadMemory(ar
->arHifDevice
,
1439 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1443 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for disabling debug logs failed\n"));
1447 param
|= HI_OPTION_DISABLE_DBGLOG
;
1449 if (BMIWriteMemory(ar
->arHifDevice
,
1450 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1454 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for HI_OPTION_DISABLE_DBGLOG\n"));
1457 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Firmware mode set\n"));
1459 #endif /* ATH6KL_DISABLE_TARGET_DBGLOGS */
1462 * Hardcode the address use for the extended board data
1463 * Ideally this should be pre-allocate by the OS at boot time
1464 * But since it is a new feature and board data is loaded
1465 * at init time, we have to workaround this from host.
1466 * It is difficult to patch the firmware boot code,
1467 * but possible in theory.
1469 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1470 param
= AR6003_BOARD_EXT_DATA_ADDRESS
;
1471 if (BMIWriteMemory(ar
->arHifDevice
,
1472 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_ext_data
),
1476 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for hi_board_ext_data failed \n"));
1482 /* since BMIInit is called in the driver layer, we have to set the block
1483 * size here for the target */
1485 if (ar6000_set_htc_params(ar
->arHifDevice
, ar
->arTargetType
,
1486 mbox_yield_limit
, 0)) {
1487 /* use default number of control buffers */
1491 if (setupbtdev
!= 0) {
1492 if (ar6000_set_hci_bridge_flags(ar
->arHifDevice
,
1502 init_netdev(struct net_device
*dev
, char *name
)
1504 dev
->netdev_ops
= &ar6000_netdev_ops
;
1505 dev
->watchdog_timeo
= AR6000_TX_TIMEOUT
;
1508 * We need the OS to provide us with more headroom in order to
1509 * perform dix to 802.3, WMI header encap, and the HTC header
1511 if (processDot11Hdr
) {
1512 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
;
1514 dev
->hard_header_len
= ETH_HLEN
+ sizeof(ATH_LLC_SNAP_HDR
) +
1515 sizeof(WMI_DATA_HDR
) + HTC_HEADER_LEN
+ WMI_MAX_TX_META_SZ
+ LINUX_HACK_FUDGE_FACTOR
;
1520 strcpy(dev
->name
, name
);
1523 #ifdef CONFIG_CHECKSUM_OFFLOAD
1525 dev
->features
|= NETIF_F_IP_CSUM
; /*advertise kernel capability to do TCP/UDP CSUM offload for IPV4*/
1532 static int __ath6kl_init_netdev(struct net_device
*dev
)
1537 r
= ar6000_init(dev
);
1541 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_avail: ar6000_init\n"));
1548 #ifdef HTC_RAW_INTERFACE
1549 static int ath6kl_init_netdev_wmi(struct net_device
*dev
)
1551 if (!eppingtest
&& bypasswmi
)
1554 return __ath6kl_init_netdev(dev
);
1557 static int ath6kl_init_netdev_wmi(struct net_device
*dev
)
1559 return __ath6kl_init_netdev(dev
);
1563 static int ath6kl_init_netdev(struct ar6_softc
*ar
)
1567 r
= ar6000_sysfs_bmi_get_config(ar
, wlaninitmode
);
1569 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
1571 "ar6000_sysfs_bmi_get_config failed\n"));
1575 return ath6kl_init_netdev_wmi(ar
->arNetDev
);
1579 * HTC Event handlers
1582 ar6000_avail_ev(void *context
, void *hif_handle
)
1585 struct net_device
*dev
;
1587 struct ar6_softc
*ar
;
1588 int device_index
= 0;
1589 struct htc_init_info htcInfo
;
1590 struct wireless_dev
*wdev
;
1592 struct hif_device_os_device_info osDevInfo
;
1594 memset(&osDevInfo
, 0, sizeof(osDevInfo
));
1595 if (HIFConfigureDevice(hif_handle
, HIF_DEVICE_GET_OS_DEVICE
,
1596 &osDevInfo
, sizeof(osDevInfo
))) {
1597 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s: Failed to get OS device instance\n", __func__
));
1601 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("ar6000_available\n"));
1603 for (i
=0; i
< MAX_AR6000
; i
++) {
1604 if (ar6000_devices
[i
] == NULL
) {
1609 if (i
== MAX_AR6000
) {
1610 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_available: max devices reached\n"));
1614 /* Save this. It gives a bit better readability especially since */
1615 /* we use another local "i" variable below. */
1618 wdev
= ar6k_cfg80211_init(osDevInfo
.pOSDevice
);
1620 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("%s: ar6k_cfg80211_init failed\n", __func__
));
1623 ar_netif
= wdev_priv(wdev
);
1625 if (ar_netif
== NULL
) {
1626 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("%s: Can't allocate ar6k priv memory\n", __func__
));
1630 A_MEMZERO(ar_netif
, sizeof(struct ar6_softc
));
1631 ar
= (struct ar6_softc
*)ar_netif
;
1634 wdev
->iftype
= NL80211_IFTYPE_STATION
;
1636 dev
= alloc_netdev_mq(0, "wlan%d", ether_setup
, 1);
1638 printk(KERN_CRIT
"AR6K: no memory for network device instance\n");
1639 ar6k_cfg80211_deinit(ar
);
1643 dev
->ieee80211_ptr
= wdev
;
1644 SET_NETDEV_DEV(dev
, wiphy_dev(wdev
->wiphy
));
1646 ar
->arNetworkType
= INFRA_NETWORK
;
1647 ar
->smeState
= SME_DISCONNECTED
;
1649 init_netdev(dev
, ifname
);
1653 ar
->arHifDevice
= hif_handle
;
1654 ar
->arWlanState
= WLAN_ENABLED
;
1655 ar
->arDeviceIndex
= device_index
;
1657 ar
->arWlanPowerState
= WLAN_POWER_STATE_ON
;
1658 ar
->arWlanOff
= false; /* We are in ON state */
1660 ar
->arWowState
= WLAN_WOW_STATE_NONE
;
1661 ar
->arBTOff
= true; /* BT chip assumed to be OFF */
1662 ar
->arBTSharing
= WLAN_CONFIG_BT_SHARING
;
1663 ar
->arWlanOffConfig
= WLAN_CONFIG_WLAN_OFF
;
1664 ar
->arSuspendConfig
= WLAN_CONFIG_PM_SUSPEND
;
1665 ar
->arWow2Config
= WLAN_CONFIG_PM_WOW2
;
1666 #endif /* CONFIG_PM */
1668 A_INIT_TIMER(&ar
->arHBChallengeResp
.timer
, ar6000_detect_error
, dev
);
1669 ar
->arHBChallengeResp
.seqNum
= 0;
1670 ar
->arHBChallengeResp
.outstanding
= false;
1671 ar
->arHBChallengeResp
.missCnt
= 0;
1672 ar
->arHBChallengeResp
.frequency
= AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT
;
1673 ar
->arHBChallengeResp
.missThres
= AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT
;
1675 ar6000_init_control_info(ar
);
1676 init_waitqueue_head(&arEvent
);
1677 sema_init(&ar
->arSem
, 1);
1678 ar
->bIsDestroyProgress
= false;
1680 INIT_HTC_PACKET_QUEUE(&ar
->amsdu_rx_buffer_queue
);
1682 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
1683 A_INIT_TIMER(&aptcTimer
, aptcTimerHandler
, ar
);
1684 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
1686 A_INIT_TIMER(&ar
->disconnect_timer
, disconnect_timer_handler
, dev
);
1690 ar6000_sysfs_bmi_init(ar
);
1693 struct bmi_target_info targ_info
;
1695 r
= BMIGetTargetInfo(ar
->arHifDevice
, &targ_info
);
1697 goto avail_ev_failed
;
1699 ar
->arVersion
.target_ver
= targ_info
.target_ver
;
1700 ar
->arTargetType
= targ_info
.target_type
;
1703 r
= ar6000_configure_target(ar
);
1705 goto avail_ev_failed
;
1707 A_MEMZERO(&htcInfo
,sizeof(htcInfo
));
1708 htcInfo
.pContext
= ar
;
1709 htcInfo
.TargetFailure
= ar6000_target_failure
;
1711 ar
->arHtcTarget
= HTCCreate(ar
->arHifDevice
,&htcInfo
);
1713 if (!ar
->arHtcTarget
) {
1715 goto avail_ev_failed
;
1718 spin_lock_init(&ar
->arLock
);
1721 ar
->arWapiEnable
= 0;
1726 /*if external frame work is also needed, change and use an extended rxMetaVerion*/
1727 ar
->rxMetaVersion
=WMI_META_VERSION_2
;
1730 ar
->aggr_cntxt
= aggr_init(ar6000_alloc_netbufs
);
1731 if (!ar
->aggr_cntxt
) {
1732 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() Failed to initialize aggr.\n", __func__
));
1734 goto avail_ev_failed
;
1737 aggr_register_rx_dispatcher(ar
->aggr_cntxt
, (void *)dev
, ar6000_deliver_frames_to_nw_stack
);
1739 HIFClaimDevice(ar
->arHifDevice
, ar
);
1741 /* We only register the device in the global list if we succeed. */
1742 /* If the device is in the global list, it will be destroyed */
1743 /* when the module is unloaded. */
1744 ar6000_devices
[device_index
] = dev
;
1746 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("BMI enabled: %d\n", wlaninitmode
));
1747 if ((wlaninitmode
== WLAN_INIT_MODE_UDEV
) ||
1748 (wlaninitmode
== WLAN_INIT_MODE_DRV
)) {
1749 r
= ath6kl_init_netdev(ar
);
1751 goto avail_ev_failed
;
1754 /* This runs the init function if registered */
1755 r
= register_netdev(dev
);
1757 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_avail: register_netdev failed\n"));
1758 ar6000_destroy(dev
, 0);
1762 is_netdev_registered
= 1;
1764 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
1766 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
1767 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("ar6000_avail: name=%s hifdevice=0x%lx, dev=0x%lx (%d), ar=0x%lx\n",
1768 dev
->name
, (unsigned long)ar
->arHifDevice
, (unsigned long)dev
, device_index
,
1769 (unsigned long)ar
));
1773 ar6000_sysfs_bmi_deinit(ar
);
1778 static void ar6000_target_failure(void *Instance
, int Status
)
1780 struct ar6_softc
*ar
= (struct ar6_softc
*)Instance
;
1781 WMI_TARGET_ERROR_REPORT_EVENT errEvent
;
1782 static bool sip
= false;
1786 printk(KERN_ERR
"ar6000_target_failure: target asserted \n");
1788 if (timer_pending(&ar
->arHBChallengeResp
.timer
)) {
1789 A_UNTIMEOUT(&ar
->arHBChallengeResp
.timer
);
1792 /* try dumping target assertion information (if any) */
1793 ar6000_dump_target_assert_info(ar
->arHifDevice
,ar
->arTargetType
);
1796 * Fetch the logs from the target via the diagnostic
1799 ar6000_dbglog_get_debug_logs(ar
);
1801 /* Report the error only once */
1804 errEvent
.errorVal
= WMI_TARGET_COM_ERR
|
1805 WMI_TARGET_FATAL_ERR
;
1811 ar6000_unavail_ev(void *context
, void *hif_handle
)
1813 struct ar6_softc
*ar
= (struct ar6_softc
*)context
;
1814 /* NULL out it's entry in the global list */
1815 ar6000_devices
[ar
->arDeviceIndex
] = NULL
;
1816 ar6000_destroy(ar
->arNetDev
, 1);
1822 ar6000_restart_endpoint(struct net_device
*dev
)
1825 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
1829 if ( (status
=ar6000_configure_target(ar
))!= 0)
1831 if ( (status
=ar6000_sysfs_bmi_get_config(ar
, wlaninitmode
)) != 0)
1833 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n"));
1837 status
= (ar6000_init(dev
)==0) ? 0 : A_ERROR
;
1843 if (ar
->arSsidLen
&& ar
->arWlanState
== WLAN_ENABLED
) {
1844 ar6000_connect_to_ap(ar
);
1852 ar6000_devices
[ar
->arDeviceIndex
] = NULL
;
1853 ar6000_destroy(ar
->arNetDev
, 1);
1857 ar6000_stop_endpoint(struct net_device
*dev
, bool keepprofile
, bool getdbglogs
)
1859 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
1861 /* Stop the transmit queues */
1862 netif_stop_queue(dev
);
1864 /* Disable the target and the interrupts associated with it */
1865 if (ar
->arWmiReady
== true)
1869 bool disconnectIssued
;
1871 disconnectIssued
= (ar
->arConnected
) || (ar
->arConnectPending
);
1872 ar6000_disconnect(ar
);
1874 ar6000_init_profile_info(ar
);
1877 A_UNTIMEOUT(&ar
->disconnect_timer
);
1880 ar6000_dbglog_get_debug_logs(ar
);
1883 ar
->arWmiReady
= false;
1884 wmi_shutdown(ar
->arWmi
);
1885 ar
->arWmiEnabled
= false;
1888 * After wmi_shudown all WMI events will be dropped.
1889 * We need to cleanup the buffers allocated in AP mode
1890 * and give disconnect notification to stack, which usually
1891 * happens in the disconnect_event.
1892 * Simulate the disconnect_event by calling the function directly.
1893 * Sometimes disconnect_event will be received when the debug logs
1896 if (disconnectIssued
) {
1897 if(ar
->arNetworkType
& AP_NETWORK
) {
1898 ar6000_disconnect_event(ar
, DISCONNECT_CMD
, bcast_mac
, 0, NULL
, 0);
1900 ar6000_disconnect_event(ar
, DISCONNECT_CMD
, ar
->arBssid
, 0, NULL
, 0);
1903 ar
->user_savedkeys_stat
= USER_SAVEDKEYS_STAT_INIT
;
1904 ar
->user_key_ctrl
= 0;
1907 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("%s(): WMI stopped\n", __func__
));
1911 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("%s(): WMI not ready 0x%lx 0x%lx\n",
1912 __func__
, (unsigned long) ar
, (unsigned long) ar
->arWmi
));
1914 /* Shut down WMI if we have started it */
1915 if(ar
->arWmiEnabled
== true)
1917 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("%s(): Shut down WMI\n", __func__
));
1918 wmi_shutdown(ar
->arWmi
);
1919 ar
->arWmiEnabled
= false;
1924 if (ar
->arHtcTarget
!= NULL
) {
1925 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
1926 if (NULL
!= ar6kHciTransCallbacks
.cleanupTransport
) {
1927 ar6kHciTransCallbacks
.cleanupTransport(NULL
);
1930 // FIXME: workaround to reset BT's UART baud rate to default
1931 if (NULL
!= ar
->exitCallback
) {
1932 struct ar3k_config_info ar3kconfig
;
1935 A_MEMZERO(&ar3kconfig
,sizeof(ar3kconfig
));
1936 ar6000_set_default_ar3kconfig(ar
, (void *)&ar3kconfig
);
1937 status
= ar
->exitCallback(&ar3kconfig
);
1939 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Failed to reset AR3K baud rate! \n"));
1944 ar6000_cleanup_hci(ar
);
1946 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,(" Shutting down HTC .... \n"));
1948 HTCStop(ar
->arHtcTarget
);
1952 /* try to reset the device if we can
1953 * The driver may have been configure NOT to reset the target during
1954 * a debug session */
1955 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,(" Attempting to reset target on instance destroy.... \n"));
1956 if (ar
->arHifDevice
!= NULL
) {
1957 bool coldReset
= (ar
->arTargetType
== TARGET_TYPE_AR6003
) ? true: false;
1958 ar6000_reset_device(ar
->arHifDevice
, ar
->arTargetType
, true, coldReset
);
1961 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,(" Host does not want target reset. \n"));
1963 /* Done with cookies */
1964 ar6000_cookie_cleanup(ar
);
1966 /* cleanup any allocated AMSDU buffers */
1967 ar6000_cleanup_amsdu_rxbufs(ar
);
1970 * We need to differentiate between the surprise and planned removal of the
1971 * device because of the following consideration:
1972 * - In case of surprise removal, the hcd already frees up the pending
1973 * for the device and hence there is no need to unregister the function
1974 * driver inorder to get these requests. For planned removal, the function
1975 * driver has to explicitly unregister itself to have the hcd return all the
1976 * pending requests before the data structures for the devices are freed up.
1977 * Note that as per the current implementation, the function driver will
1978 * end up releasing all the devices since there is no API to selectively
1979 * release a particular device.
1980 * - Certain commands issued to the target can be skipped for surprise
1981 * removal since they will anyway not go through.
1984 ar6000_destroy(struct net_device
*dev
, unsigned int unregister
)
1986 struct ar6_softc
*ar
;
1988 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("+ar6000_destroy \n"));
1990 if((dev
== NULL
) || ((ar
= ar6k_priv(dev
)) == NULL
))
1992 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s(): Failed to get device structure.\n", __func__
));
1996 ar
->bIsDestroyProgress
= true;
1998 if (down_interruptible(&ar
->arSem
)) {
1999 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s(): down_interruptible failed \n", __func__
));
2003 if (ar
->arWlanPowerState
!= WLAN_POWER_STATE_CUT_PWR
) {
2004 /* only stop endpoint if we are not stop it in suspend_ev */
2005 ar6000_stop_endpoint(dev
, false, true);
2008 ar
->arWlanState
= WLAN_DISABLED
;
2009 if (ar
->arHtcTarget
!= NULL
) {
2011 HTCDestroy(ar
->arHtcTarget
);
2013 if (ar
->arHifDevice
!= NULL
) {
2014 /*release the device so we do not get called back on remove incase we
2015 * we're explicity destroyed by module unload */
2016 HIFReleaseDevice(ar
->arHifDevice
);
2017 HIFShutDownDevice(ar
->arHifDevice
);
2019 aggr_module_destroy(ar
->aggr_cntxt
);
2021 /* Done with cookies */
2022 ar6000_cookie_cleanup(ar
);
2024 /* cleanup any allocated AMSDU buffers */
2025 ar6000_cleanup_amsdu_rxbufs(ar
);
2027 ar6000_sysfs_bmi_deinit(ar
);
2032 /* Clear the tx counters */
2033 memset(tx_attempt
, 0, sizeof(tx_attempt
));
2034 memset(tx_post
, 0, sizeof(tx_post
));
2035 memset(tx_complete
, 0, sizeof(tx_complete
));
2037 #ifdef HTC_RAW_INTERFACE
2039 kfree(ar
->arRawHtc
);
2040 ar
->arRawHtc
= NULL
;
2043 /* Free up the device data structure */
2044 if (unregister
&& is_netdev_registered
) {
2045 unregister_netdev(dev
);
2046 is_netdev_registered
= 0;
2050 ar6k_cfg80211_deinit(ar
);
2052 #ifdef CONFIG_AP_VIRTUL_ADAPTER_SUPPORT
2053 ar6000_remove_ap_interface();
2054 #endif /*CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
2056 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("-ar6000_destroy \n"));
2059 static void disconnect_timer_handler(unsigned long ptr
)
2061 struct net_device
*dev
= (struct net_device
*)ptr
;
2062 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2064 A_UNTIMEOUT(&ar
->disconnect_timer
);
2066 ar6000_init_profile_info(ar
);
2067 ar6000_disconnect(ar
);
2070 static void ar6000_detect_error(unsigned long ptr
)
2072 struct net_device
*dev
= (struct net_device
*)ptr
;
2073 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2074 WMI_TARGET_ERROR_REPORT_EVENT errEvent
;
2076 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
2078 if (ar
->arHBChallengeResp
.outstanding
) {
2079 ar
->arHBChallengeResp
.missCnt
++;
2081 ar
->arHBChallengeResp
.missCnt
= 0;
2084 if (ar
->arHBChallengeResp
.missCnt
> ar
->arHBChallengeResp
.missThres
) {
2085 /* Send Error Detect event to the application layer and do not reschedule the error detection module timer */
2086 ar
->arHBChallengeResp
.missCnt
= 0;
2087 ar
->arHBChallengeResp
.seqNum
= 0;
2088 errEvent
.errorVal
= WMI_TARGET_COM_ERR
| WMI_TARGET_FATAL_ERR
;
2089 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
2093 /* Generate the sequence number for the next challenge */
2094 ar
->arHBChallengeResp
.seqNum
++;
2095 ar
->arHBChallengeResp
.outstanding
= true;
2097 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
2099 /* Send the challenge on the control channel */
2100 if (wmi_get_challenge_resp_cmd(ar
->arWmi
, ar
->arHBChallengeResp
.seqNum
, DRV_HB_CHALLENGE
) != 0) {
2101 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to send heart beat challenge\n"));
2105 /* Reschedule the timer for the next challenge */
2106 A_TIMEOUT_MS(&ar
->arHBChallengeResp
.timer
, ar
->arHBChallengeResp
.frequency
* 1000, 0);
2109 void ar6000_init_profile_info(struct ar6_softc
*ar
)
2112 A_MEMZERO(ar
->arSsid
, sizeof(ar
->arSsid
));
2115 case HI_OPTION_FW_MODE_IBSS
:
2116 ar
->arNetworkType
= ar
->arNextMode
= ADHOC_NETWORK
;
2118 case HI_OPTION_FW_MODE_BSS_STA
:
2119 ar
->arNetworkType
= ar
->arNextMode
= INFRA_NETWORK
;
2121 case HI_OPTION_FW_MODE_AP
:
2122 ar
->arNetworkType
= ar
->arNextMode
= AP_NETWORK
;
2126 ar
->arDot11AuthMode
= OPEN_AUTH
;
2127 ar
->arAuthMode
= NONE_AUTH
;
2128 ar
->arPairwiseCrypto
= NONE_CRYPT
;
2129 ar
->arPairwiseCryptoLen
= 0;
2130 ar
->arGroupCrypto
= NONE_CRYPT
;
2131 ar
->arGroupCryptoLen
= 0;
2132 A_MEMZERO(ar
->arWepKeyList
, sizeof(ar
->arWepKeyList
));
2133 A_MEMZERO(ar
->arReqBssid
, sizeof(ar
->arReqBssid
));
2134 A_MEMZERO(ar
->arBssid
, sizeof(ar
->arBssid
));
2135 ar
->arBssChannel
= 0;
2139 ar6000_init_control_info(struct ar6_softc
*ar
)
2141 ar
->arWmiEnabled
= false;
2142 ar6000_init_profile_info(ar
);
2143 ar
->arDefTxKeyIndex
= 0;
2144 A_MEMZERO(ar
->arWepKeyList
, sizeof(ar
->arWepKeyList
));
2145 ar
->arChannelHint
= 0;
2146 ar
->arListenIntervalT
= A_DEFAULT_LISTEN_INTERVAL
;
2147 ar
->arListenIntervalB
= 0;
2148 ar
->arVersion
.host_ver
= AR6K_SW_VERSION
;
2151 ar
->arTxPwrSet
= false;
2153 ar
->arBeaconInterval
= 0;
2155 ar
->arMaxRetries
= 0;
2156 ar
->arWmmEnabled
= true;
2158 ar
->scan_triggered
= 0;
2159 A_MEMZERO(&ar
->scParams
, sizeof(ar
->scParams
));
2160 ar
->scParams
.shortScanRatio
= WMI_SHORTSCANRATIO_DEFAULT
;
2161 ar
->scParams
.scanCtrlFlags
= DEFAULT_SCAN_CTRL_FLAGS
;
2163 /* Initialize the AP mode state info */
2166 A_MEMZERO((u8
*)ar
->sta_list
, AP_MAX_NUM_STA
* sizeof(sta_t
));
2168 /* init the Mutexes */
2169 A_MUTEX_INIT(&ar
->mcastpsqLock
);
2171 /* Init the PS queues */
2172 for (ctr
=0; ctr
< AP_MAX_NUM_STA
; ctr
++) {
2173 A_MUTEX_INIT(&ar
->sta_list
[ctr
].psqLock
);
2174 A_NETBUF_QUEUE_INIT(&ar
->sta_list
[ctr
].psq
);
2177 ar
->ap_profile_flag
= 0;
2178 A_NETBUF_QUEUE_INIT(&ar
->mcastpsq
);
2180 memcpy(ar
->ap_country_code
, DEF_AP_COUNTRY_CODE
, 3);
2181 ar
->ap_wmode
= DEF_AP_WMODE_G
;
2182 ar
->ap_dtim_period
= DEF_AP_DTIM
;
2183 ar
->ap_beacon_interval
= DEF_BEACON_INTERVAL
;
2188 ar6000_open(struct net_device
*dev
)
2190 unsigned long flags
;
2191 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2193 spin_lock_irqsave(&ar
->arLock
, flags
);
2195 if(ar
->arWlanState
== WLAN_DISABLED
) {
2196 ar
->arWlanState
= WLAN_ENABLED
;
2199 if( ar
->arConnected
|| bypasswmi
) {
2200 netif_carrier_on(dev
);
2201 /* Wake up the queues */
2202 netif_wake_queue(dev
);
2205 netif_carrier_off(dev
);
2207 spin_unlock_irqrestore(&ar
->arLock
, flags
);
2212 ar6000_close(struct net_device
*dev
)
2214 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2215 netif_stop_queue(dev
);
2217 ar6000_disconnect(ar
);
2219 if(ar
->arWmiReady
== true) {
2220 if (wmi_scanparams_cmd(ar
->arWmi
, 0xFFFF, 0,
2221 0, 0, 0, 0, 0, 0, 0, 0) != 0) {
2224 ar
->arWlanState
= WLAN_DISABLED
;
2226 ar6k_cfg80211_scanComplete_event(ar
, A_ECANCELED
);
2231 /* connect to a service */
2232 static int ar6000_connectservice(struct ar6_softc
*ar
,
2233 struct htc_service_connect_req
*pConnect
,
2237 struct htc_service_connect_resp response
;
2241 A_MEMZERO(&response
,sizeof(response
));
2243 status
= HTCConnectService(ar
->arHtcTarget
,
2248 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" Failed to connect to %s service status:%d \n",
2252 switch (pConnect
->ServiceID
) {
2253 case WMI_CONTROL_SVC
:
2254 if (ar
->arWmiEnabled
) {
2255 /* set control endpoint for WMI use */
2256 wmi_set_control_ep(ar
->arWmi
, response
.Endpoint
);
2258 /* save EP for fast lookup */
2259 ar
->arControlEp
= response
.Endpoint
;
2261 case WMI_DATA_BE_SVC
:
2262 arSetAc2EndpointIDMap(ar
, WMM_AC_BE
, response
.Endpoint
);
2264 case WMI_DATA_BK_SVC
:
2265 arSetAc2EndpointIDMap(ar
, WMM_AC_BK
, response
.Endpoint
);
2267 case WMI_DATA_VI_SVC
:
2268 arSetAc2EndpointIDMap(ar
, WMM_AC_VI
, response
.Endpoint
);
2270 case WMI_DATA_VO_SVC
:
2271 arSetAc2EndpointIDMap(ar
, WMM_AC_VO
, response
.Endpoint
);
2274 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ServiceID not mapped %d\n", pConnect
->ServiceID
));
2284 void ar6000_TxDataCleanup(struct ar6_softc
*ar
)
2286 /* flush all the data (non-control) streams
2287 * we only flush packets that are tagged as data, we leave any control packets that
2288 * were in the TX queues alone */
2289 HTCFlushEndpoint(ar
->arHtcTarget
,
2290 arAc2EndpointID(ar
, WMM_AC_BE
),
2292 HTCFlushEndpoint(ar
->arHtcTarget
,
2293 arAc2EndpointID(ar
, WMM_AC_BK
),
2295 HTCFlushEndpoint(ar
->arHtcTarget
,
2296 arAc2EndpointID(ar
, WMM_AC_VI
),
2298 HTCFlushEndpoint(ar
->arHtcTarget
,
2299 arAc2EndpointID(ar
, WMM_AC_VO
),
2304 ar6000_ac2_endpoint_id ( void * devt
, u8 ac
)
2306 struct ar6_softc
*ar
= (struct ar6_softc
*) devt
;
2307 return(arAc2EndpointID(ar
, ac
));
2310 u8
ar6000_endpoint_id2_ac(void * devt
, HTC_ENDPOINT_ID ep
)
2312 struct ar6_softc
*ar
= (struct ar6_softc
*) devt
;
2313 return(arEndpoint2Ac(ar
, ep
));
2316 #if defined(CONFIG_ATH6KL_ENABLE_COEXISTENCE)
2317 static int ath6kl_config_btcoex_params(struct ar6_softc
*ar
)
2320 WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD sbcb_cmd
;
2321 WMI_SET_BTCOEX_FE_ANT_CMD sbfa_cmd
;
2323 /* Configure the type of BT collocated with WLAN */
2324 memset(&sbcb_cmd
, 0, sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD
));
2325 sbcb_cmd
.btcoexCoLocatedBTdev
= ATH6KL_BT_DEV
;
2327 r
= wmi_set_btcoex_colocated_bt_dev_cmd(ar
->arWmi
, &sbcb_cmd
);
2330 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2331 ("Unable to set collocated BT type\n"));
2335 /* Configure the type of BT collocated with WLAN */
2336 memset(&sbfa_cmd
, 0, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD
));
2338 sbfa_cmd
.btcoexFeAntType
= ATH6KL_BT_ANTENNA
;
2340 r
= wmi_set_btcoex_fe_ant_cmd(ar
->arWmi
, &sbfa_cmd
);
2342 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2343 ("Unable to set fornt end antenna configuration\n"));
2350 static int ath6kl_config_btcoex_params(struct ar6_softc
*ar
)
2354 #endif /* CONFIG_ATH6KL_ENABLE_COEXISTENCE */
2357 * This function applies WLAN specific configuration defined in wlan_config.h
2359 int ar6000_target_config_wlan_params(struct ar6_softc
*ar
)
2363 #ifdef CONFIG_HOST_TCMD_SUPPORT
2364 if (ar
->arTargetMode
!= AR6000_WLAN_MODE
) {
2367 #endif /* CONFIG_HOST_TCMD_SUPPORT */
2370 * configure the device for rx dot11 header rules 0,0 are the default values
2371 * therefore this command can be skipped if the inputs are 0,FALSE,FALSE.Required
2372 * if checksum offload is needed. Set RxMetaVersion to 2
2374 if ((wmi_set_rx_frame_format_cmd(ar
->arWmi
,ar
->rxMetaVersion
, processDot11Hdr
, processDot11Hdr
)) != 0) {
2375 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set the rx frame format.\n"));
2379 status
= ath6kl_config_btcoex_params(ar
);
2383 #if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
2384 if ((wmi_pmparams_cmd(ar
->arWmi
, 0, 1, 0, 0, 1, IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
)) != 0) {
2385 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set power save fail event policy\n"));
2390 #if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP
2391 if ((wmi_set_lpreamble_cmd(ar
->arWmi
, 0, WMI_DONOT_IGNORE_BARKER_IN_ERP
)) != 0) {
2392 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set barker preamble policy\n"));
2397 if ((wmi_set_keepalive_cmd(ar
->arWmi
, WLAN_CONFIG_KEEP_ALIVE_INTERVAL
)) != 0) {
2398 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set keep alive interval\n"));
2402 #if WLAN_CONFIG_DISABLE_11N
2404 WMI_SET_HT_CAP_CMD htCap
;
2406 memset(&htCap
, 0, sizeof(WMI_SET_HT_CAP_CMD
));
2408 if ((wmi_set_ht_cap_cmd(ar
->arWmi
, &htCap
)) != 0) {
2409 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set ht capabilities \n"));
2414 if ((wmi_set_ht_cap_cmd(ar
->arWmi
, &htCap
)) != 0) {
2415 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set ht capabilities \n"));
2419 #endif /* WLAN_CONFIG_DISABLE_11N */
2421 #ifdef ATH6K_CONFIG_OTA_MODE
2422 if ((wmi_powermode_cmd(ar
->arWmi
, MAX_PERF_POWER
)) != 0) {
2423 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set power mode \n"));
2428 if ((wmi_disctimeout_cmd(ar
->arWmi
, WLAN_CONFIG_DISCONNECT_TIMEOUT
)) != 0) {
2429 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set disconnect timeout \n"));
2433 #if WLAN_CONFIG_DISABLE_TX_BURSTING
2434 if ((wmi_set_wmm_txop(ar
->arWmi
, WMI_TXOP_DISABLED
)) != 0) {
2435 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set txop bursting \n"));
2443 /* This function does one time initialization for the lifetime of the device */
2444 int ar6000_init(struct net_device
*dev
)
2446 struct ar6_softc
*ar
;
2452 if((ar
= ar6k_priv(dev
)) == NULL
)
2457 if (wlaninitmode
== WLAN_INIT_MODE_USR
|| wlaninitmode
== WLAN_INIT_MODE_DRV
) {
2459 ar6000_update_bdaddr(ar
);
2461 if (enablerssicompensation
) {
2462 ar6000_copy_cust_data_from_target(ar
->arHifDevice
, ar
->arTargetType
);
2463 read_rssi_compensation_param(ar
);
2464 for (i
=-95; i
<=0; i
++) {
2465 rssi_compensation_table
[0-i
] = rssi_compensation_calc(ar
,i
);
2473 /* Do we need to finish the BMI phase */
2474 if ((wlaninitmode
== WLAN_INIT_MODE_USR
|| wlaninitmode
== WLAN_INIT_MODE_DRV
) &&
2475 (BMIDone(ar
->arHifDevice
) != 0))
2478 goto ar6000_init_done
;
2484 if (ar
->arVersion
.host_ver
!= ar
->arVersion
.target_ver
) {
2485 A_PRINTF("WARNING: Host version 0x%x does not match Target "
2487 ar
->arVersion
.host_ver
, ar
->arVersion
.target_ver
);
2491 /* Indicate that WMI is enabled (although not ready yet) */
2492 ar
->arWmiEnabled
= true;
2493 if ((ar
->arWmi
= wmi_init((void *) ar
)) == NULL
)
2495 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() Failed to initialize WMI.\n", __func__
));
2497 goto ar6000_init_done
;
2500 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() Got WMI @ 0x%lx.\n", __func__
,
2501 (unsigned long) ar
->arWmi
));
2505 struct htc_service_connect_req connect
;
2507 /* the reason we have to wait for the target here is that the driver layer
2508 * has to init BMI in order to set the host block size,
2510 status
= HTCWaitTarget(ar
->arHtcTarget
);
2516 A_MEMZERO(&connect
,sizeof(connect
));
2517 /* meta data is unused for now */
2518 connect
.pMetaData
= NULL
;
2519 connect
.MetaDataLength
= 0;
2520 /* these fields are the same for all service endpoints */
2521 connect
.EpCallbacks
.pContext
= ar
;
2522 connect
.EpCallbacks
.EpTxCompleteMultiple
= ar6000_tx_complete
;
2523 connect
.EpCallbacks
.EpRecv
= ar6000_rx
;
2524 connect
.EpCallbacks
.EpRecvRefill
= ar6000_rx_refill
;
2525 connect
.EpCallbacks
.EpSendFull
= ar6000_tx_queue_full
;
2526 /* set the max queue depth so that our ar6000_tx_queue_full handler gets called.
2527 * Linux has the peculiarity of not providing flow control between the
2528 * NIC and the network stack. There is no API to indicate that a TX packet
2529 * was sent which could provide some back pressure to the network stack.
2530 * Under linux you would have to wait till the network stack consumed all sk_buffs
2531 * before any back-flow kicked in. Which isn't very friendly.
2532 * So we have to manage this ourselves */
2533 connect
.MaxSendQueueDepth
= MAX_DEFAULT_SEND_QUEUE_DEPTH
;
2534 connect
.EpCallbacks
.RecvRefillWaterMark
= AR6000_MAX_RX_BUFFERS
/ 4; /* set to 25 % */
2535 if (0 == connect
.EpCallbacks
.RecvRefillWaterMark
) {
2536 connect
.EpCallbacks
.RecvRefillWaterMark
++;
2538 /* connect to control service */
2539 connect
.ServiceID
= WMI_CONTROL_SVC
;
2540 status
= ar6000_connectservice(ar
,
2547 connect
.LocalConnectionFlags
|= HTC_LOCAL_CONN_FLAGS_ENABLE_SEND_BUNDLE_PADDING
;
2548 /* limit the HTC message size on the send path, although we can receive A-MSDU frames of
2549 * 4K, we will only send ethernet-sized (802.3) frames on the send path. */
2550 connect
.MaxSendMsgSize
= WMI_MAX_TX_DATA_FRAME_LENGTH
;
2552 /* to reduce the amount of committed memory for larger A_MSDU frames, use the recv-alloc threshold
2553 * mechanism for larger packets */
2554 connect
.EpCallbacks
.RecvAllocThreshold
= AR6000_BUFFER_SIZE
;
2555 connect
.EpCallbacks
.EpRecvAllocThresh
= ar6000_alloc_amsdu_rxbuf
;
2557 /* for the remaining data services set the connection flag to reduce dribbling,
2558 * if configured to do so */
2559 if (reduce_credit_dribble
) {
2560 connect
.ConnectionFlags
|= HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE
;
2561 /* the credit dribble trigger threshold is (reduce_credit_dribble - 1) for a value
2563 connect
.ConnectionFlags
&= ~HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK
;
2564 connect
.ConnectionFlags
|=
2565 ((u16
)reduce_credit_dribble
- 1) & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK
;
2567 /* connect to best-effort service */
2568 connect
.ServiceID
= WMI_DATA_BE_SVC
;
2570 status
= ar6000_connectservice(ar
,
2577 /* connect to back-ground
2578 * map this to WMI LOW_PRI */
2579 connect
.ServiceID
= WMI_DATA_BK_SVC
;
2580 status
= ar6000_connectservice(ar
,
2587 /* connect to Video service, map this to
2589 connect
.ServiceID
= WMI_DATA_VI_SVC
;
2590 status
= ar6000_connectservice(ar
,
2597 /* connect to VO service, this is currently not
2598 * mapped to a WMI priority stream due to historical reasons.
2599 * WMI originally defined 3 priorities over 3 mailboxes
2600 * We can change this when WMI is reworked so that priorities are not
2601 * dependent on mailboxes */
2602 connect
.ServiceID
= WMI_DATA_VO_SVC
;
2603 status
= ar6000_connectservice(ar
,
2610 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_BE
) != 0);
2611 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_BK
) != 0);
2612 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_VI
) != 0);
2613 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_VO
) != 0);
2615 /* setup access class priority mappings */
2616 ar
->arAcStreamPriMap
[WMM_AC_BK
] = 0; /* lowest */
2617 ar
->arAcStreamPriMap
[WMM_AC_BE
] = 1; /* */
2618 ar
->arAcStreamPriMap
[WMM_AC_VI
] = 2; /* */
2619 ar
->arAcStreamPriMap
[WMM_AC_VO
] = 3; /* highest */
2621 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
2622 if (setuphci
&& (NULL
!= ar6kHciTransCallbacks
.setupTransport
)) {
2623 struct hci_transport_misc_handles hciHandles
;
2625 hciHandles
.netDevice
= ar
->arNetDev
;
2626 hciHandles
.hifDevice
= ar
->arHifDevice
;
2627 hciHandles
.htcHandle
= ar
->arHtcTarget
;
2628 status
= (int)(ar6kHciTransCallbacks
.setupTransport(&hciHandles
));
2633 status
= ar6000_setup_hci(ar
);
2641 goto ar6000_init_done
;
2645 * give our connected endpoints some buffers
2648 ar6000_rx_refill(ar
, ar
->arControlEp
);
2649 ar6000_rx_refill(ar
, arAc2EndpointID(ar
,WMM_AC_BE
));
2652 * We will post the receive buffers only for SPE or endpoint ping testing so we are
2653 * making it conditional on the 'bypasswmi' flag.
2656 ar6000_rx_refill(ar
,arAc2EndpointID(ar
,WMM_AC_BK
));
2657 ar6000_rx_refill(ar
,arAc2EndpointID(ar
,WMM_AC_VI
));
2658 ar6000_rx_refill(ar
,arAc2EndpointID(ar
,WMM_AC_VO
));
2661 /* allocate some buffers that handle larger AMSDU frames */
2662 ar6000_refill_amsdu_rxbufs(ar
,AR6000_MAX_AMSDU_RX_BUFFERS
);
2664 /* setup credit distribution */
2665 ar6000_setup_credit_dist(ar
->arHtcTarget
, &ar
->arCreditStateInfo
);
2667 /* Since cookies are used for HTC transports, they should be */
2668 /* initialized prior to enabling HTC. */
2669 ar6000_cookie_init(ar
);
2672 status
= HTCStart(ar
->arHtcTarget
);
2675 if (ar
->arWmiEnabled
== true) {
2676 wmi_shutdown(ar
->arWmi
);
2677 ar
->arWmiEnabled
= false;
2680 ar6000_cookie_cleanup(ar
);
2682 goto ar6000_init_done
;
2686 /* Wait for Wmi event to be ready */
2687 timeleft
= wait_event_interruptible_timeout(arEvent
,
2688 (ar
->arWmiReady
== true), wmitimeout
* HZ
);
2690 if (ar
->arVersion
.abi_ver
!= AR6K_ABI_VERSION
) {
2691 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ABI Version mismatch: Host(0x%x), Target(0x%x)\n", AR6K_ABI_VERSION
, ar
->arVersion
.abi_ver
));
2692 #ifndef ATH6K_SKIP_ABI_VERSION_CHECK
2694 goto ar6000_init_done
;
2695 #endif /* ATH6K_SKIP_ABI_VERSION_CHECK */
2698 if(!timeleft
|| signal_pending(current
))
2700 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("WMI is not ready or wait was interrupted\n"));
2702 goto ar6000_init_done
;
2705 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() WMI is ready\n", __func__
));
2707 /* Communicate the wmi protocol verision to the target */
2708 if ((ar6000_set_host_app_area(ar
)) != 0) {
2709 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set the host app area\n"));
2711 ar6000_target_config_wlan_params(ar
);
2714 ar
->arNumDataEndPts
= 1;
2717 /* for tests like endpoint ping, the MAC address needs to be non-zero otherwise
2718 * the data path through a raw socket is disabled */
2719 dev
->dev_addr
[0] = 0x00;
2720 dev
->dev_addr
[1] = 0x01;
2721 dev
->dev_addr
[2] = 0x02;
2722 dev
->dev_addr
[3] = 0xAA;
2723 dev
->dev_addr
[4] = 0xBB;
2724 dev
->dev_addr
[5] = 0xCC;
2736 ar6000_bitrate_rx(void *devt
, s32 rateKbps
)
2738 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2740 ar
->arBitRate
= rateKbps
;
2745 ar6000_ratemask_rx(void *devt
, u32 ratemask
)
2747 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2749 ar
->arRateMask
= ratemask
;
2754 ar6000_txPwr_rx(void *devt
, u8 txPwr
)
2756 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2758 ar
->arTxPwr
= txPwr
;
2764 ar6000_channelList_rx(void *devt
, s8 numChan
, u16
*chanList
)
2766 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2768 memcpy(ar
->arChannelList
, chanList
, numChan
* sizeof (u16
));
2769 ar
->arNumChannels
= numChan
;
2774 u8
ar6000_ibss_map_epid(struct sk_buff
*skb
, struct net_device
*dev
, u32
*mapNo
)
2776 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2778 ATH_MAC_HDR
*macHdr
;
2782 datap
= A_NETBUF_DATA(skb
);
2783 macHdr
= (ATH_MAC_HDR
*)(datap
+ sizeof(WMI_DATA_HDR
));
2784 if (IEEE80211_IS_MULTICAST(macHdr
->dstMac
)) {
2789 for (i
= 0; i
< ar
->arNodeNum
; i
++) {
2790 if (IEEE80211_ADDR_EQ(macHdr
->dstMac
, ar
->arNodeMap
[i
].macAddress
)) {
2792 ar
->arNodeMap
[i
].txPending
++;
2793 return ar
->arNodeMap
[i
].epId
;
2796 if ((eptMap
== -1) && !ar
->arNodeMap
[i
].txPending
) {
2802 eptMap
= ar
->arNodeNum
;
2804 A_ASSERT(ar
->arNodeNum
<= MAX_NODE_NUM
);
2807 memcpy(ar
->arNodeMap
[eptMap
].macAddress
, macHdr
->dstMac
, IEEE80211_ADDR_LEN
);
2809 for (i
= ENDPOINT_2
; i
<= ENDPOINT_5
; i
++) {
2810 if (!ar
->arTxPending
[i
]) {
2811 ar
->arNodeMap
[eptMap
].epId
= i
;
2814 // No free endpoint is available, start redistribution on the inuse endpoints.
2815 if (i
== ENDPOINT_5
) {
2816 ar
->arNodeMap
[eptMap
].epId
= ar
->arNexEpId
;
2818 if (ar
->arNexEpId
> ENDPOINT_5
) {
2819 ar
->arNexEpId
= ENDPOINT_2
;
2824 (*mapNo
) = eptMap
+ 1;
2825 ar
->arNodeMap
[eptMap
].txPending
++;
2827 return ar
->arNodeMap
[eptMap
].epId
;
2831 static void ar6000_dump_skb(struct sk_buff
*skb
)
2834 for (ch
= A_NETBUF_DATA(skb
);
2835 (unsigned long)ch
< ((unsigned long)A_NETBUF_DATA(skb
) +
2836 A_NETBUF_LEN(skb
)); ch
++)
2838 AR_DEBUG_PRINTF(ATH_DEBUG_WARN
,("%2.2x ", *ch
));
2840 AR_DEBUG_PRINTF(ATH_DEBUG_WARN
,("\n"));
2844 #ifdef HTC_TEST_SEND_PKTS
2845 static void DoHTCSendPktsTest(struct ar6_softc
*ar
, int MapNo
, HTC_ENDPOINT_ID eid
, struct sk_buff
*skb
);
2849 ar6000_data_tx(struct sk_buff
*skb
, struct net_device
*dev
)
2851 #define AC_NOT_MAPPED 99
2852 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2853 u8 ac
= AC_NOT_MAPPED
;
2854 HTC_ENDPOINT_ID eid
= ENDPOINT_UNUSED
;
2857 struct ar_cookie
*cookie
;
2858 bool checkAdHocPsMapping
= false,bMoreData
= false;
2859 HTC_TX_TAG htc_tag
= AR6K_DATA_PKT_TAG
;
2860 u8 dot11Hdr
= processDot11Hdr
;
2862 if (ar
->arWowState
!= WLAN_WOW_STATE_NONE
) {
2866 #endif /* CONFIG_PM */
2868 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("ar6000_data_tx start - skb=0x%lx, data=0x%lx, len=0x%x\n",
2869 (unsigned long)skb
, (unsigned long)A_NETBUF_DATA(skb
),
2870 A_NETBUF_LEN(skb
)));
2872 /* If target is not associated */
2873 if( (!ar
->arConnected
&& !bypasswmi
)
2874 #ifdef CONFIG_HOST_TCMD_SUPPORT
2875 /* TCMD doesn't support any data, free the buf and return */
2876 || (ar
->arTargetMode
== AR6000_TCMD_MODE
)
2885 if (ar
->arWmiReady
== false && bypasswmi
== 0) {
2889 #ifdef BLOCK_TX_PATH_FLAG
2893 #endif /* BLOCK_TX_PATH_FLAG */
2895 /* AP mode Power save processing */
2896 /* If the dst STA is in sleep state, queue the pkt in its PS queue */
2898 if (ar
->arNetworkType
== AP_NETWORK
) {
2899 ATH_MAC_HDR
*datap
= (ATH_MAC_HDR
*)A_NETBUF_DATA(skb
);
2902 /* If the dstMac is a Multicast address & atleast one of the
2903 * associated STA is in PS mode, then queue the pkt to the
2906 if (IEEE80211_IS_MULTICAST(datap
->dstMac
)) {
2911 for (ctr
=0; ctr
<AP_MAX_NUM_STA
; ctr
++) {
2912 if (STA_IS_PWR_SLEEP((&ar
->sta_list
[ctr
]))) {
2918 /* If this transmit is not because of a Dtim Expiry q it */
2919 if (ar
->DTIMExpired
== false) {
2920 bool isMcastqEmpty
= false;
2922 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
2923 isMcastqEmpty
= A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
);
2924 A_NETBUF_ENQUEUE(&ar
->mcastpsq
, skb
);
2925 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
2927 /* If this is the first Mcast pkt getting queued
2928 * indicate to the target to set the BitmapControl LSB
2931 if (isMcastqEmpty
) {
2932 wmi_set_pvb_cmd(ar
->arWmi
, MCAST_AID
, 1);
2936 /* This transmit is because of Dtim expiry. Determine if
2937 * MoreData bit has to be set.
2939 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
2940 if(!A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
)) {
2943 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
2947 conn
= ieee80211_find_conn(ar
, datap
->dstMac
);
2949 if (STA_IS_PWR_SLEEP(conn
)) {
2950 /* If this transmit is not because of a PsPoll q it*/
2951 if (!STA_IS_PS_POLLED(conn
)) {
2952 bool isPsqEmpty
= false;
2953 /* Queue the frames if the STA is sleeping */
2954 A_MUTEX_LOCK(&conn
->psqLock
);
2955 isPsqEmpty
= A_NETBUF_QUEUE_EMPTY(&conn
->psq
);
2956 A_NETBUF_ENQUEUE(&conn
->psq
, skb
);
2957 A_MUTEX_UNLOCK(&conn
->psqLock
);
2959 /* If this is the first pkt getting queued
2960 * for this STA, update the PVB for this STA
2963 wmi_set_pvb_cmd(ar
->arWmi
, conn
->aid
, 1);
2968 /* This tx is because of a PsPoll. Determine if
2969 * MoreData bit has to be set
2971 A_MUTEX_LOCK(&conn
->psqLock
);
2972 if (!A_NETBUF_QUEUE_EMPTY(&conn
->psq
)) {
2975 A_MUTEX_UNLOCK(&conn
->psqLock
);
2980 /* non existent STA. drop the frame */
2987 if (ar
->arWmiEnabled
) {
2990 u8 csum
=skb
->ip_summed
;
2991 if(csumOffload
&& (csum
==CHECKSUM_PARTIAL
)){
2992 csumStart
= (skb
->head
+ skb
->csum_start
- skb_network_header(skb
) +
2993 sizeof(ATH_LLC_SNAP_HDR
));
2994 csumDest
=skb
->csum_offset
+csumStart
;
2996 if (A_NETBUF_HEADROOM(skb
) < dev
->hard_header_len
- LINUX_HACK_FUDGE_FACTOR
) {
2997 struct sk_buff
*newbuf
;
3000 * We really should have gotten enough headroom but sometimes
3001 * we still get packets with not enough headroom. Copy the packet.
3003 len
= A_NETBUF_LEN(skb
);
3004 newbuf
= A_NETBUF_ALLOC(len
);
3005 if (newbuf
== NULL
) {
3008 A_NETBUF_PUT(newbuf
, len
);
3009 memcpy(A_NETBUF_DATA(newbuf
), A_NETBUF_DATA(skb
), len
);
3012 /* fall through and assemble header */
3016 if (wmi_dot11_hdr_add(ar
->arWmi
,skb
,ar
->arNetworkType
) != 0) {
3017 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx-wmi_dot11_hdr_add failed\n"));
3021 if (wmi_dix_2_dot3(ar
->arWmi
, skb
) != 0) {
3022 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx - wmi_dix_2_dot3 failed\n"));
3026 if(csumOffload
&& (csum
==CHECKSUM_PARTIAL
)){
3027 WMI_TX_META_V2 metaV2
;
3028 metaV2
.csumStart
=csumStart
;
3029 metaV2
.csumDest
= csumDest
;
3030 metaV2
.csumFlags
= 0x1;/*instruct target to calculate checksum*/
3031 if (wmi_data_hdr_add(ar
->arWmi
, skb
, DATA_MSGTYPE
, bMoreData
, dot11Hdr
,
3032 WMI_META_VERSION_2
,&metaV2
) != 0) {
3033 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
3040 if (wmi_data_hdr_add(ar
->arWmi
, skb
, DATA_MSGTYPE
, bMoreData
, dot11Hdr
,0,NULL
) != 0) {
3041 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
3047 if ((ar
->arNetworkType
== ADHOC_NETWORK
) &&
3048 ar
->arIbssPsEnable
&& ar
->arConnected
) {
3049 /* flag to check adhoc mapping once we take the lock below: */
3050 checkAdHocPsMapping
= true;
3053 /* get the stream mapping */
3054 ac
= wmi_implicit_create_pstream(ar
->arWmi
, skb
, 0, ar
->arWmmEnabled
);
3058 EPPING_HEADER
*eppingHdr
;
3060 eppingHdr
= A_NETBUF_DATA(skb
);
3062 if (IS_EPPING_PACKET(eppingHdr
)) {
3063 /* the stream ID is mapped to an access class */
3064 ac
= eppingHdr
->StreamNo_h
;
3065 /* some EPPING packets cannot be dropped no matter what access class it was
3066 * sent on. We can change the packet tag to guarantee it will not get dropped */
3067 if (IS_EPING_PACKET_NO_DROP(eppingHdr
)) {
3068 htc_tag
= AR6K_CONTROL_PKT_TAG
;
3071 if (ac
== HCI_TRANSPORT_STREAM_NUM
) {
3072 /* pass this to HCI */
3073 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
3074 if (!hci_test_send(ar
,skb
)) {
3078 /* set AC to discard this skb */
3081 /* a quirk of linux, the payload of the frame is 32-bit aligned and thus the addition
3082 * of the HTC header will mis-align the start of the HTC frame, so we add some
3083 * padding which will be stripped off in the target */
3084 if (EPPING_ALIGNMENT_PAD
> 0) {
3085 A_NETBUF_PUSH(skb
, EPPING_ALIGNMENT_PAD
);
3090 /* not a ping packet, drop it */
3097 /* did we succeed ? */
3098 if ((ac
== AC_NOT_MAPPED
) && !checkAdHocPsMapping
) {
3099 /* cleanup and exit */
3101 AR6000_STAT_INC(ar
, tx_dropped
);
3102 AR6000_STAT_INC(ar
, tx_aborted_errors
);
3108 /* take the lock to protect driver data */
3109 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3113 if (checkAdHocPsMapping
) {
3114 eid
= ar6000_ibss_map_epid(skb
, dev
, &mapNo
);
3116 eid
= arAc2EndpointID (ar
, ac
);
3118 /* validate that the endpoint is connected */
3119 if (eid
== 0 || eid
== ENDPOINT_UNUSED
) {
3120 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" eid %d is NOT mapped!\n", eid
));
3123 /* allocate resource for this packet */
3124 cookie
= ar6000_alloc_cookie(ar
);
3126 if (cookie
!= NULL
) {
3127 /* update counts while the lock is held */
3128 ar
->arTxPending
[eid
]++;
3129 ar
->arTotalTxDataPending
++;
3134 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3136 if (cookie
!= NULL
) {
3137 cookie
->arc_bp
[0] = (unsigned long)skb
;
3138 cookie
->arc_bp
[1] = mapNo
;
3139 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
3147 if (debugdriver
>= 3) {
3148 ar6000_dump_skb(skb
);
3151 #ifdef HTC_TEST_SEND_PKTS
3152 DoHTCSendPktsTest(ar
,mapNo
,eid
,skb
);
3154 /* HTC interface is asynchronous, if this fails, cleanup will happen in
3155 * the ar6000_tx_complete callback */
3156 HTCSendPkt(ar
->arHtcTarget
, &cookie
->HtcPkt
);
3158 /* no packet to send, cleanup */
3160 AR6000_STAT_INC(ar
, tx_dropped
);
3161 AR6000_STAT_INC(ar
, tx_aborted_errors
);
3168 ar6000_acl_data_tx(struct sk_buff
*skb
, struct net_device
*dev
)
3170 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
3171 struct ar_cookie
*cookie
;
3172 HTC_ENDPOINT_ID eid
= ENDPOINT_UNUSED
;
3175 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3177 /* For now we send ACL on BE endpoint: We can also have a dedicated EP */
3178 eid
= arAc2EndpointID (ar
, 0);
3179 /* allocate resource for this packet */
3180 cookie
= ar6000_alloc_cookie(ar
);
3182 if (cookie
!= NULL
) {
3183 /* update counts while the lock is held */
3184 ar
->arTxPending
[eid
]++;
3185 ar
->arTotalTxDataPending
++;
3189 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3191 if (cookie
!= NULL
) {
3192 cookie
->arc_bp
[0] = (unsigned long)skb
;
3193 cookie
->arc_bp
[1] = 0;
3194 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
3201 /* HTC interface is asynchronous, if this fails, cleanup will happen in
3202 * the ar6000_tx_complete callback */
3203 HTCSendPkt(ar
->arHtcTarget
, &cookie
->HtcPkt
);
3205 /* no packet to send, cleanup */
3207 AR6000_STAT_INC(ar
, tx_dropped
);
3208 AR6000_STAT_INC(ar
, tx_aborted_errors
);
3214 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3216 tvsub(register struct timeval
*out
, register struct timeval
*in
)
3218 if((out
->tv_usec
-= in
->tv_usec
) < 0) {
3220 out
->tv_usec
+= 1000000;
3222 out
->tv_sec
-= in
->tv_sec
;
3226 applyAPTCHeuristics(struct ar6_softc
*ar
)
3234 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3236 if ((enableAPTCHeuristics
) && (!aptcTR
.timerScheduled
)) {
3237 do_gettimeofday(&ts
);
3238 tvsub(&ts
, &aptcTR
.samplingTS
);
3239 duration
= ts
.tv_sec
* 1000 + ts
.tv_usec
/ 1000; /* ms */
3240 numbytes
= aptcTR
.bytesTransmitted
+ aptcTR
.bytesReceived
;
3242 if (duration
> APTC_TRAFFIC_SAMPLING_INTERVAL
) {
3243 /* Initialize the time stamp and byte count */
3244 aptcTR
.bytesTransmitted
= aptcTR
.bytesReceived
= 0;
3245 do_gettimeofday(&aptcTR
.samplingTS
);
3247 /* Calculate and decide based on throughput thresholds */
3248 throughput
= ((numbytes
* 8) / duration
);
3249 if (throughput
> APTC_UPPER_THROUGHPUT_THRESHOLD
) {
3250 /* Disable Sleep and schedule a timer */
3251 A_ASSERT(ar
->arWmiReady
== true);
3252 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3253 status
= wmi_powermode_cmd(ar
->arWmi
, MAX_PERF_POWER
);
3254 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3255 A_TIMEOUT_MS(&aptcTimer
, APTC_TRAFFIC_SAMPLING_INTERVAL
, 0);
3256 aptcTR
.timerScheduled
= true;
3261 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3263 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3265 static HTC_SEND_FULL_ACTION
ar6000_tx_queue_full(void *Context
, struct htc_packet
*pPacket
)
3267 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3268 HTC_SEND_FULL_ACTION action
= HTC_SEND_FULL_KEEP
;
3269 bool stopNet
= false;
3270 HTC_ENDPOINT_ID Endpoint
= HTC_GET_ENDPOINT_FROM_PKT(pPacket
);
3277 if (HTC_GET_TAG_FROM_PKT(pPacket
) == AR6K_CONTROL_PKT_TAG
) {
3278 /* don't drop special control packets */
3282 accessClass
= arEndpoint2Ac(ar
,Endpoint
);
3283 /* for endpoint ping testing drop Best Effort and Background */
3284 if ((accessClass
== WMM_AC_BE
) || (accessClass
== WMM_AC_BK
)) {
3285 action
= HTC_SEND_FULL_DROP
;
3288 /* keep but stop the netqueues */
3294 if (Endpoint
== ar
->arControlEp
) {
3295 /* under normal WMI if this is getting full, then something is running rampant
3296 * the host should not be exhausting the WMI queue with too many commands
3297 * the only exception to this is during testing using endpointping */
3298 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3299 /* set flag to handle subsequent messages */
3300 ar
->arWMIControlEpFull
= true;
3301 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3302 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("WMI Control Endpoint is FULL!!! \n"));
3303 /* no need to stop the network */
3308 /* if we get here, we are dealing with data endpoints getting full */
3310 if (HTC_GET_TAG_FROM_PKT(pPacket
) == AR6K_CONTROL_PKT_TAG
) {
3311 /* don't drop control packets issued on ANY data endpoint */
3315 if (ar
->arNetworkType
== ADHOC_NETWORK
) {
3316 /* in adhoc mode, we cannot differentiate traffic priorities so there is no need to
3317 * continue, however we should stop the network */
3321 /* the last MAX_HI_COOKIE_NUM "batch" of cookies are reserved for the highest
3323 if (ar
->arAcStreamPriMap
[arEndpoint2Ac(ar
,Endpoint
)] < ar
->arHiAcStreamActivePri
&&
3324 ar
->arCookieCount
<= MAX_HI_COOKIE_NUM
) {
3325 /* this stream's priority is less than the highest active priority, we
3326 * give preference to the highest priority stream by directing
3327 * HTC to drop the packet that overflowed */
3328 action
= HTC_SEND_FULL_DROP
;
3329 /* since we are dropping packets, no need to stop the network */
3337 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3338 ar
->arNetQueueStopped
= true;
3339 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3340 /* one of the data endpoints queues is getting full..need to stop network stack
3341 * the queue will resume in ar6000_tx_complete() */
3342 netif_stop_queue(ar
->arNetDev
);
3350 ar6000_tx_complete(void *Context
, struct htc_packet_queue
*pPacketQueue
)
3352 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3355 struct ar_cookie
* ar_cookie
;
3356 HTC_ENDPOINT_ID eid
;
3357 bool wakeEvent
= false;
3358 struct sk_buff_head skb_queue
;
3359 struct htc_packet
*pPacket
;
3360 struct sk_buff
*pktSkb
;
3361 bool flushing
= false;
3363 skb_queue_head_init(&skb_queue
);
3365 /* lock the driver as we update internal state */
3366 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3368 /* reap completed packets */
3369 while (!HTC_QUEUE_EMPTY(pPacketQueue
)) {
3371 pPacket
= HTC_PACKET_DEQUEUE(pPacketQueue
);
3373 ar_cookie
= (struct ar_cookie
*)pPacket
->pPktContext
;
3374 A_ASSERT(ar_cookie
);
3376 status
= pPacket
->Status
;
3377 pktSkb
= (struct sk_buff
*)ar_cookie
->arc_bp
[0];
3378 eid
= pPacket
->Endpoint
;
3379 mapNo
= ar_cookie
->arc_bp
[1];
3382 A_ASSERT(pPacket
->pBuffer
== A_NETBUF_DATA(pktSkb
));
3384 /* add this to the list, use faster non-lock API */
3385 __skb_queue_tail(&skb_queue
,pktSkb
);
3388 A_ASSERT(pPacket
->ActualLength
== A_NETBUF_LEN(pktSkb
));
3391 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("ar6000_tx_complete skb=0x%lx data=0x%lx len=0x%x eid=%d ",
3392 (unsigned long)pktSkb
, (unsigned long)pPacket
->pBuffer
,
3393 pPacket
->ActualLength
,
3396 ar
->arTxPending
[eid
]--;
3398 if ((eid
!= ar
->arControlEp
) || bypasswmi
) {
3399 ar
->arTotalTxDataPending
--;
3402 if (eid
== ar
->arControlEp
)
3404 if (ar
->arWMIControlEpFull
) {
3405 /* since this packet completed, the WMI EP is no longer full */
3406 ar
->arWMIControlEpFull
= false;
3409 if (ar
->arTxPending
[eid
] == 0) {
3415 if (status
== A_ECANCELED
) {
3416 /* a packet was flushed */
3419 AR6000_STAT_INC(ar
, tx_errors
);
3420 if (status
!= A_NO_RESOURCE
) {
3421 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() -TX ERROR, status: 0x%x\n", __func__
,
3425 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("OK\n"));
3427 AR6000_STAT_INC(ar
, tx_packets
);
3428 ar
->arNetStats
.tx_bytes
+= A_NETBUF_LEN(pktSkb
);
3429 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3430 aptcTR
.bytesTransmitted
+= a_netbuf_to_len(pktSkb
);
3431 applyAPTCHeuristics(ar
);
3432 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3435 // TODO this needs to be looked at
3436 if ((ar
->arNetworkType
== ADHOC_NETWORK
) && ar
->arIbssPsEnable
3437 && (eid
!= ar
->arControlEp
) && mapNo
)
3440 ar
->arNodeMap
[mapNo
].txPending
--;
3442 if (!ar
->arNodeMap
[mapNo
].txPending
&& (mapNo
== (ar
->arNodeNum
- 1))) {
3444 for (i
= ar
->arNodeNum
; i
> 0; i
--) {
3445 if (!ar
->arNodeMap
[i
- 1].txPending
) {
3446 A_MEMZERO(&ar
->arNodeMap
[i
- 1], sizeof(struct ar_node_mapping
));
3455 ar6000_free_cookie(ar
, ar_cookie
);
3457 if (ar
->arNetQueueStopped
) {
3458 ar
->arNetQueueStopped
= false;
3462 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3464 /* lock is released, we can freely call other kernel APIs */
3466 /* free all skbs in our local list */
3467 while (!skb_queue_empty(&skb_queue
)) {
3468 /* use non-lock version */
3469 pktSkb
= __skb_dequeue(&skb_queue
);
3470 A_NETBUF_FREE(pktSkb
);
3473 if ((ar
->arConnected
== true) || bypasswmi
) {
3475 /* don't wake the queue if we are flushing, other wise it will just
3476 * keep queueing packets, which will keep failing */
3477 netif_wake_queue(ar
->arNetDev
);
3488 ieee80211_find_conn(struct ar6_softc
*ar
, u8
*node_addr
)
3493 switch(ar
->arNetworkType
) {
3495 max_conn
= AP_MAX_NUM_STA
;
3502 for (i
= 0; i
< max_conn
; i
++) {
3503 if (IEEE80211_ADDR_EQ(node_addr
, ar
->sta_list
[i
].mac
)) {
3504 conn
= &ar
->sta_list
[i
];
3512 sta_t
*ieee80211_find_conn_for_aid(struct ar6_softc
*ar
, u8 aid
)
3517 for (ctr
= 0; ctr
< AP_MAX_NUM_STA
; ctr
++) {
3518 if (ar
->sta_list
[ctr
].aid
== aid
) {
3519 conn
= &ar
->sta_list
[ctr
];
3527 * Receive event handler. This is called by HTC when a packet is received
3531 ar6000_rx(void *Context
, struct htc_packet
*pPacket
)
3533 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3534 struct sk_buff
*skb
= (struct sk_buff
*)pPacket
->pPktContext
;
3536 u8 containsDot11Hdr
= 0;
3537 int status
= pPacket
->Status
;
3538 HTC_ENDPOINT_ID ept
= pPacket
->Endpoint
;
3540 A_ASSERT((status
) ||
3541 (pPacket
->pBuffer
== (A_NETBUF_DATA(skb
) + HTC_HEADER_LEN
)));
3543 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",
3544 (unsigned long)ar
, ept
, (unsigned long)skb
, (unsigned long)pPacket
->pBuffer
,
3545 pPacket
->ActualLength
, status
));
3547 if (status
!= A_ECANCELED
) {
3548 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("RX ERR (%d) \n",status
));
3552 /* take lock to protect buffer counts
3553 * and adaptive power throughput state */
3554 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3557 AR6000_STAT_INC(ar
, rx_packets
);
3558 ar
->arNetStats
.rx_bytes
+= pPacket
->ActualLength
;
3559 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3560 aptcTR
.bytesReceived
+= a_netbuf_to_len(skb
);
3561 applyAPTCHeuristics(ar
);
3562 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3564 A_NETBUF_PUT(skb
, pPacket
->ActualLength
+ HTC_HEADER_LEN
);
3565 A_NETBUF_PULL(skb
, HTC_HEADER_LEN
);
3568 if (debugdriver
>= 2) {
3569 ar6000_dump_skb(skb
);
3574 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3576 skb
->dev
= ar
->arNetDev
;
3578 AR6000_STAT_INC(ar
, rx_errors
);
3580 } else if (ar
->arWmiEnabled
== true) {
3581 if (ept
== ar
->arControlEp
) {
3583 * this is a wmi control msg
3586 ar6000_check_wow_status(ar
, skb
, true);
3587 #endif /* CONFIG_PM */
3588 wmi_control_rx(ar
->arWmi
, skb
);
3590 WMI_DATA_HDR
*dhdr
= (WMI_DATA_HDR
*)A_NETBUF_DATA(skb
);
3595 * This check can be removed if after a while we do not
3596 * see the warning. For now we leave it to ensure
3597 * we drop these frames accordingly in case the
3598 * target generates them for some reason. These
3599 * were used for an internal PAL but that's not
3600 * used or supported anymore. These frames should
3601 * not come up from the target.
3603 if (WARN_ON(WMI_DATA_HDR_GET_DATA_TYPE(dhdr
) ==
3604 WMI_DATA_HDR_DATA_TYPE_ACL
)) {
3605 AR6000_STAT_INC(ar
, rx_errors
);
3611 ar6000_check_wow_status(ar
, NULL
, false);
3612 #endif /* CONFIG_PM */
3614 * this is a wmi data packet
3618 if (processDot11Hdr
) {
3619 minHdrLen
= sizeof(WMI_DATA_HDR
) + sizeof(struct ieee80211_frame
) + sizeof(ATH_LLC_SNAP_HDR
);
3621 minHdrLen
= sizeof (WMI_DATA_HDR
) + sizeof(ATH_MAC_HDR
) +
3622 sizeof(ATH_LLC_SNAP_HDR
);
3625 /* In the case of AP mode we may receive NULL data frames
3626 * that do not have LLC hdr. They are 16 bytes in size.
3627 * Allow these frames in the AP mode.
3628 * ACL data frames don't follow ethernet frame bounds for
3631 if (ar
->arNetworkType
!= AP_NETWORK
&&
3632 ((pPacket
->ActualLength
< minHdrLen
) ||
3633 (pPacket
->ActualLength
> AR6000_MAX_RX_MESSAGE_SIZE
)))
3636 * packet is too short or too long
3638 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("TOO SHORT or TOO LONG\n"));
3639 AR6000_STAT_INC(ar
, rx_errors
);
3640 AR6000_STAT_INC(ar
, rx_length_errors
);
3647 /* Access RSSI values here */
3648 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("RSSI %d\n",
3649 ((WMI_DATA_HDR
*) A_NETBUF_DATA(skb
))->rssi
));
3651 /* Get the Power save state of the STA */
3652 if (ar
->arNetworkType
== AP_NETWORK
) {
3654 u8 psState
=0,prevPsState
;
3655 ATH_MAC_HDR
*datap
=NULL
;
3658 meta_type
= WMI_DATA_HDR_GET_META(dhdr
);
3660 psState
= (((WMI_DATA_HDR
*)A_NETBUF_DATA(skb
))->info
3661 >> WMI_DATA_HDR_PS_SHIFT
) & WMI_DATA_HDR_PS_MASK
;
3663 offset
= sizeof(WMI_DATA_HDR
);
3665 switch (meta_type
) {
3668 case WMI_META_VERSION_1
:
3669 offset
+= sizeof(WMI_RX_META_V1
);
3671 case WMI_META_VERSION_2
:
3672 offset
+= sizeof(WMI_RX_META_V2
);
3678 datap
= (ATH_MAC_HDR
*)(A_NETBUF_DATA(skb
)+offset
);
3679 conn
= ieee80211_find_conn(ar
, datap
->srcMac
);
3682 /* if there is a change in PS state of the STA,
3683 * take appropriate steps.
3684 * 1. If Sleep-->Awake, flush the psq for the STA
3685 * Clear the PVB for the STA.
3686 * 2. If Awake-->Sleep, Starting queueing frames
3689 prevPsState
= STA_IS_PWR_SLEEP(conn
);
3691 STA_SET_PWR_SLEEP(conn
);
3693 STA_CLR_PWR_SLEEP(conn
);
3696 if (prevPsState
^ STA_IS_PWR_SLEEP(conn
)) {
3698 if (!STA_IS_PWR_SLEEP(conn
)) {
3700 A_MUTEX_LOCK(&conn
->psqLock
);
3701 while (!A_NETBUF_QUEUE_EMPTY(&conn
->psq
)) {
3702 struct sk_buff
*skb
=NULL
;
3704 skb
= A_NETBUF_DEQUEUE(&conn
->psq
);
3705 A_MUTEX_UNLOCK(&conn
->psqLock
);
3706 ar6000_data_tx(skb
,ar
->arNetDev
);
3707 A_MUTEX_LOCK(&conn
->psqLock
);
3709 A_MUTEX_UNLOCK(&conn
->psqLock
);
3710 /* Clear the PVB for this STA */
3711 wmi_set_pvb_cmd(ar
->arWmi
, conn
->aid
, 0);
3715 /* This frame is from a STA that is not associated*/
3719 /* Drop NULL data frames here */
3720 if((pPacket
->ActualLength
< minHdrLen
) ||
3721 (pPacket
->ActualLength
> AR6000_MAX_RX_MESSAGE_SIZE
)) {
3727 is_amsdu
= WMI_DATA_HDR_IS_AMSDU(dhdr
) ? true : false;
3728 tid
= WMI_DATA_HDR_GET_UP(dhdr
);
3729 seq_no
= WMI_DATA_HDR_GET_SEQNO(dhdr
);
3730 meta_type
= WMI_DATA_HDR_GET_META(dhdr
);
3731 containsDot11Hdr
= WMI_DATA_HDR_GET_DOT11(dhdr
);
3733 wmi_data_hdr_remove(ar
->arWmi
, skb
);
3735 switch (meta_type
) {
3736 case WMI_META_VERSION_1
:
3738 WMI_RX_META_V1
*pMeta
= (WMI_RX_META_V1
*)A_NETBUF_DATA(skb
);
3739 A_PRINTF("META %d %d %d %d %x\n", pMeta
->status
, pMeta
->rix
, pMeta
->rssi
, pMeta
->channel
, pMeta
->flags
);
3740 A_NETBUF_PULL((void*)skb
, sizeof(WMI_RX_META_V1
));
3743 case WMI_META_VERSION_2
:
3745 WMI_RX_META_V2
*pMeta
= (WMI_RX_META_V2
*)A_NETBUF_DATA(skb
);
3746 if(pMeta
->csumFlags
& 0x1){
3747 skb
->ip_summed
=CHECKSUM_COMPLETE
;
3748 skb
->csum
=(pMeta
->csum
);
3750 A_NETBUF_PULL((void*)skb
, sizeof(WMI_RX_META_V2
));
3757 A_ASSERT(status
== 0);
3759 /* NWF: print the 802.11 hdr bytes */
3760 if(containsDot11Hdr
) {
3761 status
= wmi_dot11_hdr_remove(ar
->arWmi
,skb
);
3762 } else if(!is_amsdu
) {
3763 status
= wmi_dot3_2_dix(skb
);
3767 /* Drop frames that could not be processed (lack of memory, etc.) */
3772 if ((ar
->arNetDev
->flags
& IFF_UP
) == IFF_UP
) {
3773 if (ar
->arNetworkType
== AP_NETWORK
) {
3774 struct sk_buff
*skb1
= NULL
;
3777 datap
= (ATH_MAC_HDR
*)A_NETBUF_DATA(skb
);
3778 if (IEEE80211_IS_MULTICAST(datap
->dstMac
)) {
3779 /* Bcast/Mcast frames should be sent to the OS
3780 * stack as well as on the air.
3782 skb1
= skb_copy(skb
,GFP_ATOMIC
);
3784 /* Search for a connected STA with dstMac as
3785 * the Mac address. If found send the frame to
3786 * it on the air else send the frame up the
3790 conn
= ieee80211_find_conn(ar
, datap
->dstMac
);
3792 if (conn
&& ar
->intra_bss
) {
3795 } else if(conn
&& !ar
->intra_bss
) {
3801 ar6000_data_tx(skb1
, ar
->arNetDev
);
3805 aggr_process_recv_frm(ar
->aggr_cntxt
, tid
, seq_no
, is_amsdu
, (void **)&skb
);
3806 ar6000_deliver_frames_to_nw_stack((void *) ar
->arNetDev
, (void *)skb
);
3810 if (EPPING_ALIGNMENT_PAD
> 0) {
3811 A_NETBUF_PULL(skb
, EPPING_ALIGNMENT_PAD
);
3813 ar6000_deliver_frames_to_nw_stack((void *)ar
->arNetDev
, (void *)skb
);
3822 ar6000_deliver_frames_to_nw_stack(void *dev
, void *osbuf
)
3824 struct sk_buff
*skb
= (struct sk_buff
*)osbuf
;
3828 if ((skb
->dev
->flags
& IFF_UP
) == IFF_UP
) {
3830 ar6000_check_wow_status((struct ar6_softc
*)ar6k_priv(dev
), skb
, false);
3831 #endif /* CONFIG_PM */
3832 skb
->protocol
= eth_type_trans(skb
, skb
->dev
);
3834 * If this routine is called on a ISR (Hard IRQ) or DSR (Soft IRQ)
3835 * or tasklet use the netif_rx to deliver the packet to the stack
3836 * netif_rx will queue the packet onto the receive queue and mark
3837 * the softirq thread has a pending action to complete. Kernel will
3838 * schedule the softIrq kernel thread after processing the DSR.
3840 * If this routine is called on a process context, use netif_rx_ni
3841 * which will schedle the softIrq kernel thread after queuing the packet.
3843 if (in_interrupt()) {
3856 ar6000_deliver_frames_to_bt_stack(void *dev
, void *osbuf
)
3858 struct sk_buff
*skb
= (struct sk_buff
*)osbuf
;
3862 if ((skb
->dev
->flags
& IFF_UP
) == IFF_UP
) {
3863 skb
->protocol
= htons(ETH_P_CONTROL
);
3873 ar6000_rx_refill(void *Context
, HTC_ENDPOINT_ID Endpoint
)
3875 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3878 int buffersToRefill
;
3879 struct htc_packet
*pPacket
;
3880 struct htc_packet_queue queue
;
3882 buffersToRefill
= (int)AR6000_MAX_RX_BUFFERS
-
3883 HTCGetNumRecvBuffers(ar
->arHtcTarget
, Endpoint
);
3885 if (buffersToRefill
<= 0) {
3886 /* fast return, nothing to fill */
3890 INIT_HTC_PACKET_QUEUE(&queue
);
3892 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX
,("ar6000_rx_refill: providing htc with %d buffers at eid=%d\n",
3893 buffersToRefill
, Endpoint
));
3895 for (RxBuffers
= 0; RxBuffers
< buffersToRefill
; RxBuffers
++) {
3896 osBuf
= A_NETBUF_ALLOC(AR6000_BUFFER_SIZE
);
3897 if (NULL
== osBuf
) {
3900 /* the HTC packet wrapper is at the head of the reserved area
3902 pPacket
= (struct htc_packet
*)(A_NETBUF_HEAD(osBuf
));
3903 /* set re-fill info */
3904 SET_HTC_PACKET_INFO_RX_REFILL(pPacket
,osBuf
,A_NETBUF_DATA(osBuf
),AR6000_BUFFER_SIZE
,Endpoint
);
3906 HTC_PACKET_ENQUEUE(&queue
,pPacket
);
3909 if (!HTC_QUEUE_EMPTY(&queue
)) {
3911 HTCAddReceivePktMultiple(ar
->arHtcTarget
, &queue
);
3916 /* clean up our amsdu buffer list */
3917 static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc
*ar
)
3919 struct htc_packet
*pPacket
;
3922 /* empty AMSDU buffer queue and free OS bufs */
3925 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3926 pPacket
= HTC_PACKET_DEQUEUE(&ar
->amsdu_rx_buffer_queue
);
3927 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3929 if (NULL
== pPacket
) {
3933 osBuf
= pPacket
->pPktContext
;
3934 if (NULL
== osBuf
) {
3939 A_NETBUF_FREE(osBuf
);
3945 /* refill the amsdu buffer list */
3946 static void ar6000_refill_amsdu_rxbufs(struct ar6_softc
*ar
, int Count
)
3948 struct htc_packet
*pPacket
;
3952 osBuf
= A_NETBUF_ALLOC(AR6000_AMSDU_BUFFER_SIZE
);
3953 if (NULL
== osBuf
) {
3956 /* the HTC packet wrapper is at the head of the reserved area
3958 pPacket
= (struct htc_packet
*)(A_NETBUF_HEAD(osBuf
));
3959 /* set re-fill info */
3960 SET_HTC_PACKET_INFO_RX_REFILL(pPacket
,osBuf
,A_NETBUF_DATA(osBuf
),AR6000_AMSDU_BUFFER_SIZE
,0);
3962 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3963 /* put it in the list */
3964 HTC_PACKET_ENQUEUE(&ar
->amsdu_rx_buffer_queue
,pPacket
);
3965 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3971 /* callback to allocate a large receive buffer for a pending packet. This function is called when
3972 * an HTC packet arrives whose length exceeds a threshold value
3974 * We use a pre-allocated list of buffers of maximum AMSDU size (4K). Under linux it is more optimal to
3975 * keep the allocation size the same to optimize cached-slab allocations.
3978 static struct htc_packet
*ar6000_alloc_amsdu_rxbuf(void *Context
, HTC_ENDPOINT_ID Endpoint
, int Length
)
3980 struct htc_packet
*pPacket
= NULL
;
3981 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3982 int refillCount
= 0;
3984 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX
,("ar6000_alloc_amsdu_rxbuf: eid=%d, Length:%d\n",Endpoint
,Length
));
3988 if (Length
<= AR6000_BUFFER_SIZE
) {
3989 /* shouldn't be getting called on normal sized packets */
3994 if (Length
> AR6000_AMSDU_BUFFER_SIZE
) {
3999 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
4000 /* allocate a packet from the list */
4001 pPacket
= HTC_PACKET_DEQUEUE(&ar
->amsdu_rx_buffer_queue
);
4002 /* see if we need to refill again */
4003 refillCount
= AR6000_MAX_AMSDU_RX_BUFFERS
- HTC_PACKET_QUEUE_DEPTH(&ar
->amsdu_rx_buffer_queue
);
4004 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
4006 if (NULL
== pPacket
) {
4009 /* set actual endpoint ID */
4010 pPacket
->Endpoint
= Endpoint
;
4014 if (refillCount
>= AR6000_AMSDU_REFILL_THRESHOLD
) {
4015 ar6000_refill_amsdu_rxbufs(ar
,refillCount
);
4022 ar6000_set_multicast_list(struct net_device
*dev
)
4024 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000: Multicast filter not supported\n"));
4027 static struct net_device_stats
*
4028 ar6000_get_stats(struct net_device
*dev
)
4030 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
4031 return &ar
->arNetStats
;
4035 ar6000_ready_event(void *devt
, u8
*datap
, u8 phyCap
, u32 sw_ver
, u32 abi_ver
)
4037 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
4038 struct net_device
*dev
= ar
->arNetDev
;
4040 memcpy(dev
->dev_addr
, datap
, AR6000_ETH_ADDR_LEN
);
4041 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("mac address = %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
4042 dev
->dev_addr
[0], dev
->dev_addr
[1],
4043 dev
->dev_addr
[2], dev
->dev_addr
[3],
4044 dev
->dev_addr
[4], dev
->dev_addr
[5]));
4046 ar
->arPhyCapability
= phyCap
;
4047 ar
->arVersion
.wlan_ver
= sw_ver
;
4048 ar
->arVersion
.abi_ver
= abi_ver
;
4050 /* Indicate to the waiting thread that the ready event was received */
4051 ar
->arWmiReady
= true;
4055 void ar6000_install_static_wep_keys(struct ar6_softc
*ar
)
4060 for (index
= WMI_MIN_KEY_INDEX
; index
<= WMI_MAX_KEY_INDEX
; index
++) {
4061 if (ar
->arWepKeyList
[index
].arKeyLen
) {
4062 keyUsage
= GROUP_USAGE
;
4063 if (index
== ar
->arDefTxKeyIndex
) {
4064 keyUsage
|= TX_USAGE
;
4066 wmi_addKey_cmd(ar
->arWmi
,
4070 ar
->arWepKeyList
[index
].arKeyLen
,
4072 ar
->arWepKeyList
[index
].arKey
, KEY_OP_INIT_VAL
, NULL
,
4079 add_new_sta(struct ar6_softc
*ar
, u8
*mac
, u16 aid
, u8
*wpaie
,
4080 u8 ielen
, u8 keymgmt
, u8 ucipher
, u8 auth
)
4084 memcpy(ar
->sta_list
[free_slot
].mac
, mac
, ATH_MAC_LEN
);
4085 memcpy(ar
->sta_list
[free_slot
].wpa_ie
, wpaie
, ielen
);
4086 ar
->sta_list
[free_slot
].aid
= aid
;
4087 ar
->sta_list
[free_slot
].keymgmt
= keymgmt
;
4088 ar
->sta_list
[free_slot
].ucipher
= ucipher
;
4089 ar
->sta_list
[free_slot
].auth
= auth
;
4090 ar
->sta_list_index
= ar
->sta_list_index
| (1 << free_slot
);
4091 ar
->arAPStats
.sta
[free_slot
].aid
= aid
;
4095 ar6000_connect_event(struct ar6_softc
*ar
, u16 channel
, u8
*bssid
,
4096 u16 listenInterval
, u16 beaconInterval
,
4097 NETWORK_TYPE networkType
, u8 beaconIeLen
,
4098 u8 assocReqLen
, u8 assocRespLen
,
4101 union iwreq_data wrqu
;
4102 int i
, beacon_ie_pos
, assoc_resp_ie_pos
, assoc_req_ie_pos
;
4103 static const char *tag1
= "ASSOCINFO(ReqIEs=";
4104 static const char *tag2
= "ASSOCRESPIE=";
4105 static const char *beaconIetag
= "BEACONIE=";
4106 char buf
[WMI_CONTROL_MSG_MAX_LEN
* 2 + strlen(tag1
) + 1];
4109 unsigned long flags
;
4110 struct ieee80211req_key
*ik
;
4111 CRYPTO_TYPE keyType
= NONE_CRYPT
;
4113 if(ar
->arNetworkType
& AP_NETWORK
) {
4114 struct net_device
*dev
= ar
->arNetDev
;
4115 if(memcmp(dev
->dev_addr
, bssid
, ATH_MAC_LEN
)==0) {
4116 ar
->arACS
= channel
;
4117 ik
= &ar
->ap_mode_bkey
;
4119 switch(ar
->arAuthMode
) {
4121 if(ar
->arPairwiseCrypto
== WEP_CRYPT
) {
4122 ar6000_install_static_wep_keys(ar
);
4125 else if(ar
->arPairwiseCrypto
== WAPI_CRYPT
) {
4126 ap_set_wapi_key(ar
, ik
);
4132 case (WPA_PSK_AUTH
|WPA2_PSK_AUTH
):
4133 switch (ik
->ik_type
) {
4134 case IEEE80211_CIPHER_TKIP
:
4135 keyType
= TKIP_CRYPT
;
4137 case IEEE80211_CIPHER_AES_CCM
:
4138 keyType
= AES_CRYPT
;
4143 wmi_addKey_cmd(ar
->arWmi
, ik
->ik_keyix
, keyType
, GROUP_USAGE
,
4144 ik
->ik_keylen
, (u8
*)&ik
->ik_keyrsc
,
4145 ik
->ik_keydata
, KEY_OP_INIT_VAL
, ik
->ik_macaddr
,
4151 ar
->arConnected
= true;
4155 A_PRINTF("NEW STA %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x \n "
4156 " AID=%d \n", bssid
[0], bssid
[1], bssid
[2],
4157 bssid
[3], bssid
[4], bssid
[5], channel
);
4158 switch ((listenInterval
>>8)&0xFF) {
4160 A_PRINTF("AUTH: OPEN\n");
4163 A_PRINTF("AUTH: SHARED\n");
4166 A_PRINTF("AUTH: Unknown\n");
4169 switch (listenInterval
&0xFF) {
4171 A_PRINTF("KeyMgmt: WPA-PSK\n");
4174 A_PRINTF("KeyMgmt: WPA2-PSK\n");
4177 A_PRINTF("KeyMgmt: NONE\n");
4180 switch (beaconInterval
) {
4182 A_PRINTF("Cipher: AES\n");
4185 A_PRINTF("Cipher: TKIP\n");
4188 A_PRINTF("Cipher: WEP\n");
4192 A_PRINTF("Cipher: WAPI\n");
4196 A_PRINTF("Cipher: NONE\n");
4200 add_new_sta(ar
, bssid
, channel
/*aid*/,
4201 assocInfo
/* WPA IE */, assocRespLen
/* IE len */,
4202 listenInterval
&0xFF /* Keymgmt */, beaconInterval
/* cipher */,
4203 (listenInterval
>>8)&0xFF /* auth alg */);
4205 /* Send event to application */
4206 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4207 memcpy(wrqu
.addr
.sa_data
, bssid
, ATH_MAC_LEN
);
4208 wireless_send_event(ar
->arNetDev
, IWEVREGISTERED
, &wrqu
, NULL
);
4209 /* In case the queue is stopped when we switch modes, this will
4212 netif_wake_queue(ar
->arNetDev
);
4216 ar6k_cfg80211_connect_event(ar
, channel
, bssid
,
4217 listenInterval
, beaconInterval
,
4218 networkType
, beaconIeLen
,
4219 assocReqLen
, assocRespLen
,
4222 memcpy(ar
->arBssid
, bssid
, sizeof(ar
->arBssid
));
4223 ar
->arBssChannel
= channel
;
4225 A_PRINTF("AR6000 connected event on freq %d ", channel
);
4226 A_PRINTF("with bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
4227 " listenInterval=%d, beaconInterval = %d, beaconIeLen = %d assocReqLen=%d"
4228 " assocRespLen =%d\n",
4229 bssid
[0], bssid
[1], bssid
[2],
4230 bssid
[3], bssid
[4], bssid
[5],
4231 listenInterval
, beaconInterval
,
4232 beaconIeLen
, assocReqLen
, assocRespLen
);
4233 if (networkType
& ADHOC_NETWORK
) {
4234 if (networkType
& ADHOC_CREATOR
) {
4235 A_PRINTF("Network: Adhoc (Creator)\n");
4237 A_PRINTF("Network: Adhoc (Joiner)\n");
4240 A_PRINTF("Network: Infrastructure\n");
4243 if ((ar
->arNetworkType
== INFRA_NETWORK
)) {
4244 wmi_listeninterval_cmd(ar
->arWmi
, ar
->arListenIntervalT
, ar
->arListenIntervalB
);
4247 if (beaconIeLen
&& (sizeof(buf
) > (9 + beaconIeLen
* 2))) {
4248 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nBeaconIEs= "));
4251 A_MEMZERO(buf
, sizeof(buf
));
4252 sprintf(buf
, "%s", beaconIetag
);
4254 for (i
= beacon_ie_pos
; i
< beacon_ie_pos
+ beaconIeLen
; i
++) {
4255 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4256 sprintf(pos
, "%2.2x", assocInfo
[i
]);
4259 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4261 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4262 wrqu
.data
.length
= strlen(buf
);
4263 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4266 if (assocRespLen
&& (sizeof(buf
) > (12 + (assocRespLen
* 2))))
4268 assoc_resp_ie_pos
= beaconIeLen
+ assocReqLen
+
4269 sizeof(u16
) + /* capinfo*/
4270 sizeof(u16
) + /* status Code */
4271 sizeof(u16
) ; /* associd */
4272 A_MEMZERO(buf
, sizeof(buf
));
4273 sprintf(buf
, "%s", tag2
);
4275 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nAssocRespIEs= "));
4277 * The Association Response Frame w.o. the WLAN header is delivered to
4278 * the host, so skip over to the IEs
4280 for (i
= assoc_resp_ie_pos
; i
< assoc_resp_ie_pos
+ assocRespLen
- 6; i
++)
4282 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4283 sprintf(pos
, "%2.2x", assocInfo
[i
]);
4286 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4288 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4289 wrqu
.data
.length
= strlen(buf
);
4290 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4293 if (assocReqLen
&& (sizeof(buf
) > (17 + (assocReqLen
* 2)))) {
4295 * assoc Request includes capability and listen interval. Skip these.
4297 assoc_req_ie_pos
= beaconIeLen
+
4298 sizeof(u16
) + /* capinfo*/
4299 sizeof(u16
); /* listen interval */
4301 A_MEMZERO(buf
, sizeof(buf
));
4302 sprintf(buf
, "%s", tag1
);
4304 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("AssocReqIEs= "));
4305 for (i
= assoc_req_ie_pos
; i
< assoc_req_ie_pos
+ assocReqLen
- 4; i
++) {
4306 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4307 sprintf(pos
, "%2.2x", assocInfo
[i
]);
4310 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4312 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4313 wrqu
.data
.length
= strlen(buf
);
4314 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4317 if (ar
->user_savedkeys_stat
== USER_SAVEDKEYS_STAT_RUN
&&
4318 ar
->user_saved_keys
.keyOk
== true)
4320 key_op_ctrl
= KEY_OP_VALID_MASK
& ~KEY_OP_INIT_TSC
;
4322 if (ar
->user_key_ctrl
& AR6000_USER_SETKEYS_RSC_UNCHANGED
) {
4323 key_op_ctrl
&= ~KEY_OP_INIT_RSC
;
4325 key_op_ctrl
|= KEY_OP_INIT_RSC
;
4327 ar6000_reinstall_keys(ar
, key_op_ctrl
);
4330 netif_wake_queue(ar
->arNetDev
);
4332 /* Update connect & link status atomically */
4333 spin_lock_irqsave(&ar
->arLock
, flags
);
4334 ar
->arConnected
= true;
4335 ar
->arConnectPending
= false;
4336 netif_carrier_on(ar
->arNetDev
);
4337 spin_unlock_irqrestore(&ar
->arLock
, flags
);
4338 /* reset the rx aggr state */
4339 aggr_reset_state(ar
->aggr_cntxt
);
4342 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4343 memcpy(wrqu
.addr
.sa_data
, bssid
, IEEE80211_ADDR_LEN
);
4344 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
4345 wireless_send_event(ar
->arNetDev
, SIOCGIWAP
, &wrqu
, NULL
);
4346 if ((ar
->arNetworkType
== ADHOC_NETWORK
) && ar
->arIbssPsEnable
) {
4347 A_MEMZERO(ar
->arNodeMap
, sizeof(ar
->arNodeMap
));
4349 ar
->arNexEpId
= ENDPOINT_2
;
4351 if (!ar
->arUserBssFilter
) {
4352 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
4357 void ar6000_set_numdataendpts(struct ar6_softc
*ar
, u32 num
)
4359 A_ASSERT(num
<= (HTC_MAILBOX_NUM_MAX
- 1));
4360 ar
->arNumDataEndPts
= num
;
4364 sta_cleanup(struct ar6_softc
*ar
, u8 i
)
4366 struct sk_buff
*skb
;
4368 /* empty the queued pkts in the PS queue if any */
4369 A_MUTEX_LOCK(&ar
->sta_list
[i
].psqLock
);
4370 while (!A_NETBUF_QUEUE_EMPTY(&ar
->sta_list
[i
].psq
)) {
4371 skb
= A_NETBUF_DEQUEUE(&ar
->sta_list
[i
].psq
);
4374 A_MUTEX_UNLOCK(&ar
->sta_list
[i
].psqLock
);
4376 /* Zero out the state fields */
4377 A_MEMZERO(&ar
->arAPStats
.sta
[ar
->sta_list
[i
].aid
-1], sizeof(WMI_PER_STA_STAT
));
4378 A_MEMZERO(&ar
->sta_list
[i
].mac
, ATH_MAC_LEN
);
4379 A_MEMZERO(&ar
->sta_list
[i
].wpa_ie
, IEEE80211_MAX_IE
);
4380 ar
->sta_list
[i
].aid
= 0;
4381 ar
->sta_list
[i
].flags
= 0;
4383 ar
->sta_list_index
= ar
->sta_list_index
& ~(1 << i
);
4387 u8
remove_sta(struct ar6_softc
*ar
, u8
*mac
, u16 reason
)
4391 if(IS_MAC_NULL(mac
)) {
4395 if(IS_MAC_BCAST(mac
)) {
4396 A_PRINTF("DEL ALL STA\n");
4397 for(i
=0; i
< AP_MAX_NUM_STA
; i
++) {
4398 if(!IS_MAC_NULL(ar
->sta_list
[i
].mac
)) {
4404 for(i
=0; i
< AP_MAX_NUM_STA
; i
++) {
4405 if(memcmp(ar
->sta_list
[i
].mac
, mac
, ATH_MAC_LEN
)==0) {
4406 A_PRINTF("DEL STA %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
4407 " aid=%d REASON=%d\n", mac
[0], mac
[1], mac
[2],
4408 mac
[3], mac
[4], mac
[5], ar
->sta_list
[i
].aid
, reason
);
4420 ar6000_disconnect_event(struct ar6_softc
*ar
, u8 reason
, u8
*bssid
,
4421 u8 assocRespLen
, u8
*assocInfo
, u16 protocolReasonStatus
)
4424 unsigned long flags
;
4425 union iwreq_data wrqu
;
4427 if(ar
->arNetworkType
& AP_NETWORK
) {
4428 union iwreq_data wrqu
;
4429 struct sk_buff
*skb
;
4431 if(!remove_sta(ar
, bssid
, protocolReasonStatus
)) {
4435 /* If there are no more associated STAs, empty the mcast PS q */
4436 if (ar
->sta_list_index
== 0) {
4437 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
4438 while (!A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
)) {
4439 skb
= A_NETBUF_DEQUEUE(&ar
->mcastpsq
);
4442 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
4444 /* Clear the LSB of the BitMapCtl field of the TIM IE */
4445 if (ar
->arWmiReady
) {
4446 wmi_set_pvb_cmd(ar
->arWmi
, MCAST_AID
, 0);
4450 if(!IS_MAC_BCAST(bssid
)) {
4451 /* Send event to application */
4452 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4453 memcpy(wrqu
.addr
.sa_data
, bssid
, ATH_MAC_LEN
);
4454 wireless_send_event(ar
->arNetDev
, IWEVEXPIRED
, &wrqu
, NULL
);
4457 ar
->arConnected
= false;
4461 ar6k_cfg80211_disconnect_event(ar
, reason
, bssid
,
4462 assocRespLen
, assocInfo
,
4463 protocolReasonStatus
);
4465 /* Send disconnect event to supplicant */
4466 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4467 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
4468 wireless_send_event(ar
->arNetDev
, SIOCGIWAP
, &wrqu
, NULL
);
4470 /* it is necessary to clear the host-side rx aggregation state */
4471 aggr_reset_state(ar
->aggr_cntxt
);
4473 A_UNTIMEOUT(&ar
->disconnect_timer
);
4475 A_PRINTF("AR6000 disconnected");
4476 if (bssid
[0] || bssid
[1] || bssid
[2] || bssid
[3] || bssid
[4] || bssid
[5]) {
4477 A_PRINTF(" from %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",
4478 bssid
[0], bssid
[1], bssid
[2], bssid
[3], bssid
[4], bssid
[5]);
4481 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nDisconnect Reason is %d", reason
));
4482 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nProtocol Reason/Status Code is %d", protocolReasonStatus
));
4483 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nAssocResp Frame = %s",
4484 assocRespLen
? " " : "NULL"));
4485 for (i
= 0; i
< assocRespLen
; i
++) {
4487 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4489 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4491 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4493 * If the event is due to disconnect cmd from the host, only they the target
4494 * would stop trying to connect. Under any other condition, target would
4495 * keep trying to connect.
4498 if( reason
== DISCONNECT_CMD
)
4500 if ((!ar
->arUserBssFilter
) && (ar
->arWmiReady
)) {
4501 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
4504 ar
->arConnectPending
= true;
4505 if (((reason
== ASSOC_FAILED
) && (protocolReasonStatus
== 0x11)) ||
4506 ((reason
== ASSOC_FAILED
) && (protocolReasonStatus
== 0x0) && (reconnect_flag
== 1))) {
4507 ar
->arConnected
= true;
4512 if ((reason
== NO_NETWORK_AVAIL
) && (ar
->arWmiReady
))
4514 bss_t
*pWmiSsidnode
= NULL
;
4516 /* remove the current associated bssid node */
4517 wmi_free_node (ar
->arWmi
, bssid
);
4520 * In case any other same SSID nodes are present
4521 * remove it, since those nodes also not available now
4526 * Find the nodes based on SSID and remove it
4527 * NOTE :: This case will not work out for Hidden-SSID
4529 pWmiSsidnode
= wmi_find_Ssidnode (ar
->arWmi
, ar
->arSsid
, ar
->arSsidLen
, false, true);
4533 wmi_free_node (ar
->arWmi
, pWmiSsidnode
->ni_macaddr
);
4536 } while (pWmiSsidnode
);
4539 /* Update connect & link status atomically */
4540 spin_lock_irqsave(&ar
->arLock
, flags
);
4541 ar
->arConnected
= false;
4542 netif_carrier_off(ar
->arNetDev
);
4543 spin_unlock_irqrestore(&ar
->arLock
, flags
);
4545 if( (reason
!= CSERV_DISCONNECT
) || (reconnect_flag
!= 1) ) {
4549 if (reason
!= CSERV_DISCONNECT
)
4551 ar
->user_savedkeys_stat
= USER_SAVEDKEYS_STAT_INIT
;
4552 ar
->user_key_ctrl
= 0;
4555 netif_stop_queue(ar
->arNetDev
);
4556 A_MEMZERO(ar
->arBssid
, sizeof(ar
->arBssid
));
4557 ar
->arBssChannel
= 0;
4558 ar
->arBeaconInterval
= 0;
4560 ar6000_TxDataCleanup(ar
);
4564 ar6000_regDomain_event(struct ar6_softc
*ar
, u32 regCode
)
4566 A_PRINTF("AR6000 Reg Code = 0x%x\n", regCode
);
4567 ar
->arRegCode
= regCode
;
4571 ar6000_aggr_rcv_addba_req_evt(struct ar6_softc
*ar
, WMI_ADDBA_REQ_EVENT
*evt
)
4573 if(evt
->status
== 0) {
4574 aggr_recv_addba_req_evt(ar
->aggr_cntxt
, evt
->tid
, evt
->st_seq_no
, evt
->win_sz
);
4579 ar6000_aggr_rcv_addba_resp_evt(struct ar6_softc
*ar
, WMI_ADDBA_RESP_EVENT
*evt
)
4581 A_PRINTF("ADDBA RESP. tid %d status %d, sz %d\n", evt
->tid
, evt
->status
, evt
->amsdu_sz
);
4582 if(evt
->status
== 0) {
4587 ar6000_aggr_rcv_delba_req_evt(struct ar6_softc
*ar
, WMI_DELBA_EVENT
*evt
)
4589 aggr_recv_delba_req_evt(ar
->aggr_cntxt
, evt
->tid
);
4592 void register_pal_cb(ar6k_pal_config_t
*palConfig_p
)
4594 ar6k_pal_config_g
= *palConfig_p
;
4598 ar6000_hci_event_rcv_evt(struct ar6_softc
*ar
, WMI_HCI_EVENT
*cmd
)
4605 size
= cmd
->evt_buf_sz
+ 4;
4606 osbuf
= A_NETBUF_ALLOC(size
);
4607 if (osbuf
== NULL
) {
4609 A_PRINTF("Error in allocating netbuf \n");
4613 A_NETBUF_PUT(osbuf
, size
);
4614 buf
= (u8
*)A_NETBUF_DATA(osbuf
);
4615 /* First 2-bytes carry HCI event/ACL data type
4616 * the next 2 are free
4618 *((short *)buf
) = WMI_HCI_EVENT_EVENTID
;
4620 memcpy(buf
, cmd
->buf
, cmd
->evt_buf_sz
);
4622 ar6000_deliver_frames_to_nw_stack(ar
->arNetDev
, osbuf
);
4624 A_PRINTF_LOG("HCI Event From PAL <-- \n");
4625 for(i
= 0; i
< cmd
->evt_buf_sz
; i
++) {
4626 A_PRINTF_LOG("0x%02x ", cmd
->buf
[i
]);
4632 A_PRINTF_LOG("==================================\n");
4637 ar6000_neighborReport_event(struct ar6_softc
*ar
, int numAps
, WMI_NEIGHBOR_INFO
*info
)
4639 #if WIRELESS_EXT >= 18
4640 struct iw_pmkid_cand
*pmkcand
;
4641 #else /* WIRELESS_EXT >= 18 */
4642 static const char *tag
= "PRE-AUTH";
4644 #endif /* WIRELESS_EXT >= 18 */
4646 union iwreq_data wrqu
;
4649 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("AR6000 Neighbor Report Event\n"));
4650 for (i
=0; i
< numAps
; info
++, i
++) {
4651 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",
4652 info
->bssid
[0], info
->bssid
[1], info
->bssid
[2],
4653 info
->bssid
[3], info
->bssid
[4], info
->bssid
[5]));
4654 if (info
->bssFlags
& WMI_PREAUTH_CAPABLE_BSS
) {
4655 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("preauth-cap"));
4657 if (info
->bssFlags
& WMI_PMKID_VALID_BSS
) {
4658 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,(" pmkid-valid\n"));
4659 continue; /* we skip bss if the pmkid is already valid */
4661 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("\n"));
4662 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4663 #if WIRELESS_EXT >= 18
4664 pmkcand
= A_MALLOC_NOWAIT(sizeof(struct iw_pmkid_cand
));
4665 A_MEMZERO(pmkcand
, sizeof(struct iw_pmkid_cand
));
4667 pmkcand
->flags
= info
->bssFlags
;
4668 memcpy(pmkcand
->bssid
.sa_data
, info
->bssid
, ATH_MAC_LEN
);
4669 wrqu
.data
.length
= sizeof(struct iw_pmkid_cand
);
4670 wireless_send_event(ar
->arNetDev
, IWEVPMKIDCAND
, &wrqu
, (char *)pmkcand
);
4672 #else /* WIRELESS_EXT >= 18 */
4673 snprintf(buf
, sizeof(buf
), "%s%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
4675 info
->bssid
[0], info
->bssid
[1], info
->bssid
[2],
4676 info
->bssid
[3], info
->bssid
[4], info
->bssid
[5],
4678 wrqu
.data
.length
= strlen(buf
);
4679 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4680 #endif /* WIRELESS_EXT >= 18 */
4685 ar6000_tkip_micerr_event(struct ar6_softc
*ar
, u8 keyid
, bool ismcast
)
4687 static const char *tag
= "MLME-MICHAELMICFAILURE.indication";
4689 union iwreq_data wrqu
;
4692 * For AP case, keyid will have aid of STA which sent pkt with
4693 * MIC error. Use this aid to get MAC & send it to hostapd.
4695 if (ar
->arNetworkType
== AP_NETWORK
) {
4696 sta_t
*s
= ieee80211_find_conn_for_aid(ar
, (keyid
>> 2));
4698 A_PRINTF("AP TKIP MIC error received from Invalid aid / STA not found =%d\n", keyid
);
4701 A_PRINTF("AP TKIP MIC error received from aid=%d\n", keyid
);
4702 snprintf(buf
,sizeof(buf
), "%s addr=%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
4703 tag
, s
->mac
[0],s
->mac
[1],s
->mac
[2],s
->mac
[3],s
->mac
[4],s
->mac
[5]);
4706 ar6k_cfg80211_tkip_micerr_event(ar
, keyid
, ismcast
);
4708 A_PRINTF("AR6000 TKIP MIC error received for keyid %d %scast\n",
4709 keyid
& 0x3, ismcast
? "multi": "uni");
4710 snprintf(buf
, sizeof(buf
), "%s(keyid=%d %sicast)", tag
, keyid
& 0x3,
4711 ismcast
? "mult" : "un");
4714 memset(&wrqu
, 0, sizeof(wrqu
));
4715 wrqu
.data
.length
= strlen(buf
);
4716 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4720 ar6000_scanComplete_event(struct ar6_softc
*ar
, int status
)
4723 ar6k_cfg80211_scanComplete_event(ar
, status
);
4725 if (!ar
->arUserBssFilter
) {
4726 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
4728 if (ar
->scan_triggered
) {
4730 union iwreq_data wrqu
;
4731 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4732 wireless_send_event(ar
->arNetDev
, SIOCGIWSCAN
, &wrqu
, NULL
);
4734 ar
->scan_triggered
= 0;
4737 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,( "AR6000 scan complete: %d\n", status
));
4741 ar6000_targetStats_event(struct ar6_softc
*ar
, u8
*ptr
, u32 len
)
4745 if(ar
->arNetworkType
== AP_NETWORK
) {
4746 WMI_AP_MODE_STAT
*p
= (WMI_AP_MODE_STAT
*)ptr
;
4747 WMI_AP_MODE_STAT
*ap
= &ar
->arAPStats
;
4749 if (len
< sizeof(*p
)) {
4753 for(ac
=0;ac
<AP_MAX_NUM_STA
;ac
++) {
4754 ap
->sta
[ac
].tx_bytes
+= p
->sta
[ac
].tx_bytes
;
4755 ap
->sta
[ac
].tx_pkts
+= p
->sta
[ac
].tx_pkts
;
4756 ap
->sta
[ac
].tx_error
+= p
->sta
[ac
].tx_error
;
4757 ap
->sta
[ac
].tx_discard
+= p
->sta
[ac
].tx_discard
;
4758 ap
->sta
[ac
].rx_bytes
+= p
->sta
[ac
].rx_bytes
;
4759 ap
->sta
[ac
].rx_pkts
+= p
->sta
[ac
].rx_pkts
;
4760 ap
->sta
[ac
].rx_error
+= p
->sta
[ac
].rx_error
;
4761 ap
->sta
[ac
].rx_discard
+= p
->sta
[ac
].rx_discard
;
4765 WMI_TARGET_STATS
*pTarget
= (WMI_TARGET_STATS
*)ptr
;
4766 TARGET_STATS
*pStats
= &ar
->arTargetStats
;
4768 if (len
< sizeof(*pTarget
)) {
4772 // Update the RSSI of the connected bss.
4773 if (ar
->arConnected
) {
4774 bss_t
*pConnBss
= NULL
;
4776 pConnBss
= wmi_find_node(ar
->arWmi
,ar
->arBssid
);
4779 pConnBss
->ni_rssi
= pTarget
->cservStats
.cs_aveBeacon_rssi
;
4780 pConnBss
->ni_snr
= pTarget
->cservStats
.cs_aveBeacon_snr
;
4781 wmi_node_return(ar
->arWmi
, pConnBss
);
4785 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("AR6000 updating target stats\n"));
4786 pStats
->tx_packets
+= pTarget
->txrxStats
.tx_stats
.tx_packets
;
4787 pStats
->tx_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_bytes
;
4788 pStats
->tx_unicast_pkts
+= pTarget
->txrxStats
.tx_stats
.tx_unicast_pkts
;
4789 pStats
->tx_unicast_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_unicast_bytes
;
4790 pStats
->tx_multicast_pkts
+= pTarget
->txrxStats
.tx_stats
.tx_multicast_pkts
;
4791 pStats
->tx_multicast_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_multicast_bytes
;
4792 pStats
->tx_broadcast_pkts
+= pTarget
->txrxStats
.tx_stats
.tx_broadcast_pkts
;
4793 pStats
->tx_broadcast_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_broadcast_bytes
;
4794 pStats
->tx_rts_success_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_rts_success_cnt
;
4795 for(ac
= 0; ac
< WMM_NUM_AC
; ac
++)
4796 pStats
->tx_packet_per_ac
[ac
] += pTarget
->txrxStats
.tx_stats
.tx_packet_per_ac
[ac
];
4797 pStats
->tx_errors
+= pTarget
->txrxStats
.tx_stats
.tx_errors
;
4798 pStats
->tx_failed_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_failed_cnt
;
4799 pStats
->tx_retry_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_retry_cnt
;
4800 pStats
->tx_mult_retry_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_mult_retry_cnt
;
4801 pStats
->tx_rts_fail_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_rts_fail_cnt
;
4802 pStats
->tx_unicast_rate
= wmi_get_rate(pTarget
->txrxStats
.tx_stats
.tx_unicast_rate
);
4804 pStats
->rx_packets
+= pTarget
->txrxStats
.rx_stats
.rx_packets
;
4805 pStats
->rx_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_bytes
;
4806 pStats
->rx_unicast_pkts
+= pTarget
->txrxStats
.rx_stats
.rx_unicast_pkts
;
4807 pStats
->rx_unicast_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_unicast_bytes
;
4808 pStats
->rx_multicast_pkts
+= pTarget
->txrxStats
.rx_stats
.rx_multicast_pkts
;
4809 pStats
->rx_multicast_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_multicast_bytes
;
4810 pStats
->rx_broadcast_pkts
+= pTarget
->txrxStats
.rx_stats
.rx_broadcast_pkts
;
4811 pStats
->rx_broadcast_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_broadcast_bytes
;
4812 pStats
->rx_fragment_pkt
+= pTarget
->txrxStats
.rx_stats
.rx_fragment_pkt
;
4813 pStats
->rx_errors
+= pTarget
->txrxStats
.rx_stats
.rx_errors
;
4814 pStats
->rx_crcerr
+= pTarget
->txrxStats
.rx_stats
.rx_crcerr
;
4815 pStats
->rx_key_cache_miss
+= pTarget
->txrxStats
.rx_stats
.rx_key_cache_miss
;
4816 pStats
->rx_decrypt_err
+= pTarget
->txrxStats
.rx_stats
.rx_decrypt_err
;
4817 pStats
->rx_duplicate_frames
+= pTarget
->txrxStats
.rx_stats
.rx_duplicate_frames
;
4818 pStats
->rx_unicast_rate
= wmi_get_rate(pTarget
->txrxStats
.rx_stats
.rx_unicast_rate
);
4821 pStats
->tkip_local_mic_failure
4822 += pTarget
->txrxStats
.tkipCcmpStats
.tkip_local_mic_failure
;
4823 pStats
->tkip_counter_measures_invoked
4824 += pTarget
->txrxStats
.tkipCcmpStats
.tkip_counter_measures_invoked
;
4825 pStats
->tkip_replays
+= pTarget
->txrxStats
.tkipCcmpStats
.tkip_replays
;
4826 pStats
->tkip_format_errors
+= pTarget
->txrxStats
.tkipCcmpStats
.tkip_format_errors
;
4827 pStats
->ccmp_format_errors
+= pTarget
->txrxStats
.tkipCcmpStats
.ccmp_format_errors
;
4828 pStats
->ccmp_replays
+= pTarget
->txrxStats
.tkipCcmpStats
.ccmp_replays
;
4830 pStats
->power_save_failure_cnt
+= pTarget
->pmStats
.power_save_failure_cnt
;
4831 pStats
->noise_floor_calibation
= pTarget
->noise_floor_calibation
;
4833 pStats
->cs_bmiss_cnt
+= pTarget
->cservStats
.cs_bmiss_cnt
;
4834 pStats
->cs_lowRssi_cnt
+= pTarget
->cservStats
.cs_lowRssi_cnt
;
4835 pStats
->cs_connect_cnt
+= pTarget
->cservStats
.cs_connect_cnt
;
4836 pStats
->cs_disconnect_cnt
+= pTarget
->cservStats
.cs_disconnect_cnt
;
4837 pStats
->cs_aveBeacon_snr
= pTarget
->cservStats
.cs_aveBeacon_snr
;
4838 pStats
->cs_aveBeacon_rssi
= pTarget
->cservStats
.cs_aveBeacon_rssi
;
4840 if (enablerssicompensation
) {
4841 pStats
->cs_aveBeacon_rssi
=
4842 rssi_compensation_calc(ar
, pStats
->cs_aveBeacon_rssi
);
4844 pStats
->cs_lastRoam_msec
= pTarget
->cservStats
.cs_lastRoam_msec
;
4845 pStats
->cs_snr
= pTarget
->cservStats
.cs_snr
;
4846 pStats
->cs_rssi
= pTarget
->cservStats
.cs_rssi
;
4848 pStats
->lq_val
= pTarget
->lqVal
;
4850 pStats
->wow_num_pkts_dropped
+= pTarget
->wowStats
.wow_num_pkts_dropped
;
4851 pStats
->wow_num_host_pkt_wakeups
+= pTarget
->wowStats
.wow_num_host_pkt_wakeups
;
4852 pStats
->wow_num_host_event_wakeups
+= pTarget
->wowStats
.wow_num_host_event_wakeups
;
4853 pStats
->wow_num_events_discarded
+= pTarget
->wowStats
.wow_num_events_discarded
;
4854 pStats
->arp_received
+= pTarget
->arpStats
.arp_received
;
4855 pStats
->arp_matched
+= pTarget
->arpStats
.arp_matched
;
4856 pStats
->arp_replied
+= pTarget
->arpStats
.arp_replied
;
4858 if (ar
->statsUpdatePending
) {
4859 ar
->statsUpdatePending
= false;
4866 ar6000_rssiThreshold_event(struct ar6_softc
*ar
, WMI_RSSI_THRESHOLD_VAL newThreshold
, s16 rssi
)
4868 USER_RSSI_THOLD userRssiThold
;
4870 rssi
= rssi
+ SIGNAL_QUALITY_NOISE_FLOOR
;
4872 if (enablerssicompensation
) {
4873 rssi
= rssi_compensation_calc(ar
, rssi
);
4876 /* Send an event to the app */
4877 userRssiThold
.tag
= ar
->rssi_map
[newThreshold
].tag
;
4878 userRssiThold
.rssi
= rssi
;
4879 A_PRINTF("rssi Threshold range = %d tag = %d rssi = %d\n", newThreshold
,
4880 userRssiThold
.tag
, userRssiThold
.rssi
);
4885 ar6000_hbChallengeResp_event(struct ar6_softc
*ar
, u32 cookie
, u32 source
)
4887 if (source
!= APP_HB_CHALLENGE
) {
4888 /* This would ignore the replys that come in after their due time */
4889 if (cookie
== ar
->arHBChallengeResp
.seqNum
) {
4890 ar
->arHBChallengeResp
.outstanding
= false;
4897 ar6000_reportError_event(struct ar6_softc
*ar
, WMI_TARGET_ERROR_VAL errorVal
)
4899 static const char * const errString
[] = {
4900 [WMI_TARGET_PM_ERR_FAIL
] "WMI_TARGET_PM_ERR_FAIL",
4901 [WMI_TARGET_KEY_NOT_FOUND
] "WMI_TARGET_KEY_NOT_FOUND",
4902 [WMI_TARGET_DECRYPTION_ERR
] "WMI_TARGET_DECRYPTION_ERR",
4903 [WMI_TARGET_BMISS
] "WMI_TARGET_BMISS",
4904 [WMI_PSDISABLE_NODE_JOIN
] "WMI_PSDISABLE_NODE_JOIN"
4907 A_PRINTF("AR6000 Error on Target. Error = 0x%x\n", errorVal
);
4909 /* One error is reported at a time, and errorval is a bitmask */
4910 if(errorVal
& (errorVal
- 1))
4913 A_PRINTF("AR6000 Error type = ");
4916 case WMI_TARGET_PM_ERR_FAIL
:
4917 case WMI_TARGET_KEY_NOT_FOUND
:
4918 case WMI_TARGET_DECRYPTION_ERR
:
4919 case WMI_TARGET_BMISS
:
4920 case WMI_PSDISABLE_NODE_JOIN
:
4921 A_PRINTF("%s\n", errString
[errorVal
]);
4924 A_PRINTF("INVALID\n");
4932 ar6000_cac_event(struct ar6_softc
*ar
, u8 ac
, u8 cacIndication
,
4933 u8 statusCode
, u8
*tspecSuggestion
)
4935 WMM_TSPEC_IE
*tspecIe
;
4938 * This is the TSPEC IE suggestion from AP.
4939 * Suggestion provided by AP under some error
4940 * cases, could be helpful for the host app.
4941 * Check documentation.
4943 tspecIe
= (WMM_TSPEC_IE
*)tspecSuggestion
;
4946 * What do we do, if we get TSPEC rejection? One thought
4947 * that comes to mind is implictly delete the pstream...
4949 A_PRINTF("AR6000 CAC notification. "
4950 "AC = %d, cacIndication = 0x%x, statusCode = 0x%x\n",
4951 ac
, cacIndication
, statusCode
);
4955 ar6000_channel_change_event(struct ar6_softc
*ar
, u16 oldChannel
,
4958 A_PRINTF("Channel Change notification\nOld Channel: %d, New Channel: %d\n",
4959 oldChannel
, newChannel
);
4962 #define AR6000_PRINT_BSSID(_pBss) do { \
4963 A_PRINTF("%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",\
4964 (_pBss)[0],(_pBss)[1],(_pBss)[2],(_pBss)[3],\
4965 (_pBss)[4],(_pBss)[5]); \
4969 ar6000_roam_tbl_event(struct ar6_softc
*ar
, WMI_TARGET_ROAM_TBL
*pTbl
)
4973 A_PRINTF("ROAM TABLE NO OF ENTRIES is %d ROAM MODE is %d\n",
4974 pTbl
->numEntries
, pTbl
->roamMode
);
4975 for (i
= 0; i
< pTbl
->numEntries
; i
++) {
4976 A_PRINTF("[%d]bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ", i
,
4977 pTbl
->bssRoamInfo
[i
].bssid
[0], pTbl
->bssRoamInfo
[i
].bssid
[1],
4978 pTbl
->bssRoamInfo
[i
].bssid
[2],
4979 pTbl
->bssRoamInfo
[i
].bssid
[3],
4980 pTbl
->bssRoamInfo
[i
].bssid
[4],
4981 pTbl
->bssRoamInfo
[i
].bssid
[5]);
4982 A_PRINTF("RSSI %d RSSIDT %d LAST RSSI %d UTIL %d ROAM_UTIL %d"
4984 pTbl
->bssRoamInfo
[i
].rssi
,
4985 pTbl
->bssRoamInfo
[i
].rssidt
,
4986 pTbl
->bssRoamInfo
[i
].last_rssi
,
4987 pTbl
->bssRoamInfo
[i
].util
,
4988 pTbl
->bssRoamInfo
[i
].roam_util
,
4989 pTbl
->bssRoamInfo
[i
].bias
);
4994 ar6000_wow_list_event(struct ar6_softc
*ar
, u8 num_filters
, WMI_GET_WOW_LIST_REPLY
*wow_reply
)
4998 /*Each event now contains exactly one filter, see bug 26613*/
4999 A_PRINTF("WOW pattern %d of %d patterns\n", wow_reply
->this_filter_num
, wow_reply
->num_filters
);
5000 A_PRINTF("wow mode = %s host mode = %s\n",
5001 (wow_reply
->wow_mode
== 0? "disabled":"enabled"),
5002 (wow_reply
->host_mode
== 1 ? "awake":"asleep"));
5005 /*If there are no patterns, the reply will only contain generic
5006 WoW information. Pattern information will exist only if there are
5007 patterns present. Bug 26716*/
5009 /* If this event contains pattern information, display it*/
5010 if (wow_reply
->this_filter_num
) {
5012 A_PRINTF("id=%d size=%d offset=%d\n",
5013 wow_reply
->wow_filters
[i
].wow_filter_id
,
5014 wow_reply
->wow_filters
[i
].wow_filter_size
,
5015 wow_reply
->wow_filters
[i
].wow_filter_offset
);
5016 A_PRINTF("wow pattern = ");
5017 for (j
=0; j
< wow_reply
->wow_filters
[i
].wow_filter_size
; j
++) {
5018 A_PRINTF("%2.2x",wow_reply
->wow_filters
[i
].wow_filter_pattern
[j
]);
5021 A_PRINTF("\nwow mask = ");
5022 for (j
=0; j
< wow_reply
->wow_filters
[i
].wow_filter_size
; j
++) {
5023 A_PRINTF("%2.2x",wow_reply
->wow_filters
[i
].wow_filter_mask
[j
]);
5030 * Report the Roaming related data collected on the target
5033 ar6000_display_roam_time(WMI_TARGET_ROAM_TIME
*p
)
5035 A_PRINTF("Disconnect Data : BSSID: ");
5036 AR6000_PRINT_BSSID(p
->disassoc_bssid
);
5037 A_PRINTF(" RSSI %d DISASSOC Time %d NO_TXRX_TIME %d\n",
5038 p
->disassoc_bss_rssi
,p
->disassoc_time
,
5040 A_PRINTF("Connect Data: BSSID: ");
5041 AR6000_PRINT_BSSID(p
->assoc_bssid
);
5042 A_PRINTF(" RSSI %d ASSOC Time %d TXRX_TIME %d\n",
5043 p
->assoc_bss_rssi
,p
->assoc_time
,
5044 p
->allow_txrx_time
);
5048 ar6000_roam_data_event(struct ar6_softc
*ar
, WMI_TARGET_ROAM_DATA
*p
)
5050 switch (p
->roamDataType
) {
5051 case ROAM_DATA_TIME
:
5052 ar6000_display_roam_time(&p
->u
.roamTime
);
5060 ar6000_bssInfo_event_rx(struct ar6_softc
*ar
, u8
*datap
, int len
)
5062 struct sk_buff
*skb
;
5063 WMI_BSS_INFO_HDR
*bih
= (WMI_BSS_INFO_HDR
*)datap
;
5066 if (!ar
->arMgmtFilter
) {
5069 if (((ar
->arMgmtFilter
& IEEE80211_FILTER_TYPE_BEACON
) &&
5070 (bih
->frameType
!= BEACON_FTYPE
)) ||
5071 ((ar
->arMgmtFilter
& IEEE80211_FILTER_TYPE_PROBE_RESP
) &&
5072 (bih
->frameType
!= PROBERESP_FTYPE
)))
5077 if ((skb
= A_NETBUF_ALLOC_RAW(len
)) != NULL
) {
5079 A_NETBUF_PUT(skb
, len
);
5080 memcpy(A_NETBUF_DATA(skb
), datap
, len
);
5081 skb
->dev
= ar
->arNetDev
;
5082 memcpy(skb_mac_header(skb
), A_NETBUF_DATA(skb
), 6);
5083 skb
->ip_summed
= CHECKSUM_NONE
;
5084 skb
->pkt_type
= PACKET_OTHERHOST
;
5085 skb
->protocol
= __constant_htons(0x0019);
5093 ar6000_control_tx(void *devt
, void *osbuf
, HTC_ENDPOINT_ID eid
)
5095 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
5097 struct ar_cookie
*cookie
= NULL
;
5100 if (ar
->arWowState
!= WLAN_WOW_STATE_NONE
) {
5101 A_NETBUF_FREE(osbuf
);
5104 #endif /* CONFIG_PM */
5105 /* take lock to protect ar6000_alloc_cookie() */
5106 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
5110 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("ar_contrstatus = ol_tx: skb=0x%lx, len=0x%x eid =%d\n",
5111 (unsigned long)osbuf
, A_NETBUF_LEN(osbuf
), eid
));
5113 if (ar
->arWMIControlEpFull
&& (eid
== ar
->arControlEp
)) {
5114 /* control endpoint is full, don't allocate resources, we
5115 * are just going to drop this packet */
5117 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" WMI Control EP full, dropping packet : 0x%lX, len:%d \n",
5118 (unsigned long)osbuf
, A_NETBUF_LEN(osbuf
)));
5120 cookie
= ar6000_alloc_cookie(ar
);
5123 if (cookie
== NULL
) {
5124 status
= A_NO_MEMORY
;
5129 A_PRINTF("WMI cmd send, msgNo %d :", wmiSendCmdNum
);
5130 for(i
= 0; i
< a_netbuf_to_len(osbuf
); i
++)
5131 A_PRINTF("%x ", ((u8
*)a_netbuf_to_data(osbuf
))[i
]);
5139 if (cookie
!= NULL
) {
5140 /* got a structure to send it out on */
5141 ar
->arTxPending
[eid
]++;
5143 if (eid
!= ar
->arControlEp
) {
5144 ar
->arTotalTxDataPending
++;
5148 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
5150 if (cookie
!= NULL
) {
5151 cookie
->arc_bp
[0] = (unsigned long)osbuf
;
5152 cookie
->arc_bp
[1] = 0;
5153 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
5155 A_NETBUF_DATA(osbuf
),
5156 A_NETBUF_LEN(osbuf
),
5158 AR6K_CONTROL_PKT_TAG
);
5159 /* this interface is asynchronous, if there is an error, cleanup will happen in the
5160 * TX completion callback */
5161 HTCSendPkt(ar
->arHtcTarget
, &cookie
->HtcPkt
);
5166 A_NETBUF_FREE(osbuf
);
5171 /* indicate tx activity or inactivity on a WMI stream */
5172 void ar6000_indicate_tx_activity(void *devt
, u8 TrafficClass
, bool Active
)
5174 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
5175 HTC_ENDPOINT_ID eid
;
5178 if (ar
->arWmiEnabled
) {
5179 eid
= arAc2EndpointID(ar
, TrafficClass
);
5181 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
5183 ar
->arAcStreamActive
[TrafficClass
] = Active
;
5186 /* when a stream goes active, keep track of the active stream with the highest priority */
5188 if (ar
->arAcStreamPriMap
[TrafficClass
] > ar
->arHiAcStreamActivePri
) {
5189 /* set the new highest active priority */
5190 ar
->arHiAcStreamActivePri
= ar
->arAcStreamPriMap
[TrafficClass
];
5194 /* when a stream goes inactive, we may have to search for the next active stream
5195 * that is the highest priority */
5197 if (ar
->arHiAcStreamActivePri
== ar
->arAcStreamPriMap
[TrafficClass
]) {
5199 /* the highest priority stream just went inactive */
5201 /* reset and search for the "next" highest "active" priority stream */
5202 ar
->arHiAcStreamActivePri
= 0;
5203 for (i
= 0; i
< WMM_NUM_AC
; i
++) {
5204 if (ar
->arAcStreamActive
[i
]) {
5205 if (ar
->arAcStreamPriMap
[i
] > ar
->arHiAcStreamActivePri
) {
5206 /* set the new highest active priority */
5207 ar
->arHiAcStreamActivePri
= ar
->arAcStreamPriMap
[i
];
5214 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
5217 /* for mbox ping testing, the traffic class is mapped directly as a stream ID,
5218 * see handling of AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE in ioctl.c
5219 * convert the stream ID to a endpoint */
5220 eid
= arAc2EndpointID(ar
, TrafficClass
);
5223 /* notify HTC, this may cause credit distribution changes */
5225 HTCIndicateActivityChange(ar
->arHtcTarget
,
5232 ar6000_btcoex_config_event(struct ar6_softc
*ar
, u8
*ptr
, u32 len
)
5235 WMI_BTCOEX_CONFIG_EVENT
*pBtcoexConfig
= (WMI_BTCOEX_CONFIG_EVENT
*)ptr
;
5236 WMI_BTCOEX_CONFIG_EVENT
*pArbtcoexConfig
=&ar
->arBtcoexConfig
;
5238 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("AR6000 BTCOEX CONFIG EVENT \n"));
5240 A_PRINTF("received config event\n");
5241 pArbtcoexConfig
->btProfileType
= pBtcoexConfig
->btProfileType
;
5242 pArbtcoexConfig
->linkId
= pBtcoexConfig
->linkId
;
5244 switch (pBtcoexConfig
->btProfileType
) {
5245 case WMI_BTCOEX_BT_PROFILE_SCO
:
5246 memcpy(&pArbtcoexConfig
->info
.scoConfigCmd
, &pBtcoexConfig
->info
.scoConfigCmd
,
5247 sizeof(WMI_SET_BTCOEX_SCO_CONFIG_CMD
));
5249 case WMI_BTCOEX_BT_PROFILE_A2DP
:
5250 memcpy(&pArbtcoexConfig
->info
.a2dpConfigCmd
, &pBtcoexConfig
->info
.a2dpConfigCmd
,
5251 sizeof(WMI_SET_BTCOEX_A2DP_CONFIG_CMD
));
5253 case WMI_BTCOEX_BT_PROFILE_ACLCOEX
:
5254 memcpy(&pArbtcoexConfig
->info
.aclcoexConfig
, &pBtcoexConfig
->info
.aclcoexConfig
,
5255 sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD
));
5257 case WMI_BTCOEX_BT_PROFILE_INQUIRY_PAGE
:
5258 memcpy(&pArbtcoexConfig
->info
.btinquiryPageConfigCmd
, &pBtcoexConfig
->info
.btinquiryPageConfigCmd
,
5259 sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD
));
5262 if (ar
->statsUpdatePending
) {
5263 ar
->statsUpdatePending
= false;
5269 ar6000_btcoex_stats_event(struct ar6_softc
*ar
, u8
*ptr
, u32 len
)
5271 WMI_BTCOEX_STATS_EVENT
*pBtcoexStats
= (WMI_BTCOEX_STATS_EVENT
*)ptr
;
5273 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("AR6000 BTCOEX CONFIG EVENT \n"));
5275 memcpy(&ar
->arBtcoexStats
, pBtcoexStats
, sizeof(WMI_BTCOEX_STATS_EVENT
));
5277 if (ar
->statsUpdatePending
) {
5278 ar
->statsUpdatePending
= false;
5283 module_init(ar6000_init_module
);
5284 module_exit(ar6000_cleanup_module
);
5286 /* Init cookie queue */
5288 ar6000_cookie_init(struct ar6_softc
*ar
)
5292 ar
->arCookieList
= NULL
;
5293 ar
->arCookieCount
= 0;
5295 A_MEMZERO(s_ar_cookie_mem
, sizeof(s_ar_cookie_mem
));
5297 for (i
= 0; i
< MAX_COOKIE_NUM
; i
++) {
5298 ar6000_free_cookie(ar
, &s_ar_cookie_mem
[i
]);
5302 /* cleanup cookie queue */
5304 ar6000_cookie_cleanup(struct ar6_softc
*ar
)
5306 /* It is gone .... */
5307 ar
->arCookieList
= NULL
;
5308 ar
->arCookieCount
= 0;
5311 /* Init cookie queue */
5313 ar6000_free_cookie(struct ar6_softc
*ar
, struct ar_cookie
* cookie
)
5316 A_ASSERT(ar
!= NULL
);
5317 A_ASSERT(cookie
!= NULL
);
5319 cookie
->arc_list_next
= ar
->arCookieList
;
5320 ar
->arCookieList
= cookie
;
5321 ar
->arCookieCount
++;
5324 /* cleanup cookie queue */
5325 static struct ar_cookie
*
5326 ar6000_alloc_cookie(struct ar6_softc
*ar
)
5328 struct ar_cookie
*cookie
;
5330 cookie
= ar
->arCookieList
;
5333 ar
->arCookieList
= cookie
->arc_list_next
;
5334 ar
->arCookieCount
--;
5341 ar6000_tx_retry_err_event(void *devt
)
5343 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Tx retries reach maximum!\n"));
5347 ar6000_snrThresholdEvent_rx(void *devt
, WMI_SNR_THRESHOLD_VAL newThreshold
, u8 snr
)
5349 WMI_SNR_THRESHOLD_EVENT event
;
5351 event
.range
= newThreshold
;
5356 ar6000_lqThresholdEvent_rx(void *devt
, WMI_LQ_THRESHOLD_VAL newThreshold
, u8 lq
)
5358 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("lq threshold range %d, lq %d\n", newThreshold
, lq
));
5363 u32
a_copy_to_user(void *to
, const void *from
, u32 n
)
5365 return(copy_to_user(to
, from
, n
));
5368 u32
a_copy_from_user(void *to
, const void *from
, u32 n
)
5370 return(copy_from_user(to
, from
, n
));
5375 ar6000_get_driver_cfg(struct net_device
*dev
,
5384 case AR6000_DRIVER_CFG_GET_WLANNODECACHING
:
5385 *((u32
*)result
) = wlanNodeCaching
;
5387 case AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS
:
5388 *((u32
*)result
) = logWmiRawMsgs
;
5399 ar6000_keepalive_rx(void *devt
, u8 configured
)
5401 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
5403 ar
->arKeepaliveConfigured
= configured
;
5408 ar6000_pmkid_list_event(void *devt
, u8 numPMKID
, WMI_PMKID
*pmkidList
,
5413 A_PRINTF("Number of Cached PMKIDs is %d\n", numPMKID
);
5415 for (i
= 0; i
< numPMKID
; i
++) {
5416 A_PRINTF("\nBSSID %d ", i
);
5417 for (j
= 0; j
< ATH_MAC_LEN
; j
++) {
5418 A_PRINTF("%2.2x", bssidList
[j
]);
5420 bssidList
+= (ATH_MAC_LEN
+ WMI_PMKID_LEN
);
5421 A_PRINTF("\nPMKID %d ", i
);
5422 for (j
= 0; j
< WMI_PMKID_LEN
; j
++) {
5423 A_PRINTF("%2.2x", pmkidList
->pmkid
[j
]);
5425 pmkidList
= (WMI_PMKID
*)((u8
*)pmkidList
+ ATH_MAC_LEN
+
5430 void ar6000_pspoll_event(struct ar6_softc
*ar
,u8 aid
)
5433 bool isPsqEmpty
= false;
5435 conn
= ieee80211_find_conn_for_aid(ar
, aid
);
5437 /* If the PS q for this STA is not empty, dequeue and send a pkt from
5438 * the head of the q. Also update the More data bit in the WMI_DATA_HDR
5439 * if there are more pkts for this STA in the PS q. If there are no more
5440 * pkts for this STA, update the PVB for this STA.
5442 A_MUTEX_LOCK(&conn
->psqLock
);
5443 isPsqEmpty
= A_NETBUF_QUEUE_EMPTY(&conn
->psq
);
5444 A_MUTEX_UNLOCK(&conn
->psqLock
);
5447 /* TODO:No buffered pkts for this STA. Send out a NULL data frame */
5449 struct sk_buff
*skb
= NULL
;
5451 A_MUTEX_LOCK(&conn
->psqLock
);
5452 skb
= A_NETBUF_DEQUEUE(&conn
->psq
);
5453 A_MUTEX_UNLOCK(&conn
->psqLock
);
5454 /* Set the STA flag to PSPolled, so that the frame will go out */
5455 STA_SET_PS_POLLED(conn
);
5456 ar6000_data_tx(skb
, ar
->arNetDev
);
5457 STA_CLR_PS_POLLED(conn
);
5459 /* Clear the PVB for this STA if the queue has become empty */
5460 A_MUTEX_LOCK(&conn
->psqLock
);
5461 isPsqEmpty
= A_NETBUF_QUEUE_EMPTY(&conn
->psq
);
5462 A_MUTEX_UNLOCK(&conn
->psqLock
);
5465 wmi_set_pvb_cmd(ar
->arWmi
, conn
->aid
, 0);
5470 void ar6000_dtimexpiry_event(struct ar6_softc
*ar
)
5472 bool isMcastQueued
= false;
5473 struct sk_buff
*skb
= NULL
;
5475 /* If there are no associated STAs, ignore the DTIM expiry event.
5476 * There can be potential race conditions where the last associated
5477 * STA may disconnect & before the host could clear the 'Indicate DTIM'
5478 * request to the firmware, the firmware would have just indicated a DTIM
5479 * expiry event. The race is between 'clear DTIM expiry cmd' going
5480 * from the host to the firmware & the DTIM expiry event happening from
5481 * the firmware to the host.
5483 if (ar
->sta_list_index
== 0) {
5487 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
5488 isMcastQueued
= A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
);
5489 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
5491 A_ASSERT(isMcastQueued
== false);
5493 /* Flush the mcast psq to the target */
5494 /* Set the STA flag to DTIMExpired, so that the frame will go out */
5495 ar
->DTIMExpired
= true;
5497 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
5498 while (!A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
)) {
5499 skb
= A_NETBUF_DEQUEUE(&ar
->mcastpsq
);
5500 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
5502 ar6000_data_tx(skb
, ar
->arNetDev
);
5504 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
5506 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
5508 /* Reset the DTIMExpired flag back to 0 */
5509 ar
->DTIMExpired
= false;
5511 /* Clear the LSB of the BitMapCtl field of the TIM IE */
5512 wmi_set_pvb_cmd(ar
->arWmi
, MCAST_AID
, 0);
5516 read_rssi_compensation_param(struct ar6_softc
*ar
)
5520 //#define RSSICOMPENSATION_PRINT
5522 #ifdef RSSICOMPENSATION_PRINT
5524 cust_data_ptr
= ar6000_get_cust_data_buffer(ar
->arTargetType
);
5525 for (i
=0; i
<16; i
++) {
5526 A_PRINTF("cust_data_%d = %x \n", i
, *(u8
*)cust_data_ptr
);
5531 cust_data_ptr
= ar6000_get_cust_data_buffer(ar
->arTargetType
);
5533 rssi_compensation_param
.customerID
= *(u16
*)cust_data_ptr
& 0xffff;
5534 rssi_compensation_param
.enable
= *(u16
*)(cust_data_ptr
+2) & 0xffff;
5535 rssi_compensation_param
.bg_param_a
= *(u16
*)(cust_data_ptr
+4) & 0xffff;
5536 rssi_compensation_param
.bg_param_b
= *(u16
*)(cust_data_ptr
+6) & 0xffff;
5537 rssi_compensation_param
.a_param_a
= *(u16
*)(cust_data_ptr
+8) & 0xffff;
5538 rssi_compensation_param
.a_param_b
= *(u16
*)(cust_data_ptr
+10) &0xffff;
5539 rssi_compensation_param
.reserved
= *(u32
*)(cust_data_ptr
+12);
5541 #ifdef RSSICOMPENSATION_PRINT
5542 A_PRINTF("customerID = 0x%x \n", rssi_compensation_param
.customerID
);
5543 A_PRINTF("enable = 0x%x \n", rssi_compensation_param
.enable
);
5544 A_PRINTF("bg_param_a = 0x%x and %d \n", rssi_compensation_param
.bg_param_a
, rssi_compensation_param
.bg_param_a
);
5545 A_PRINTF("bg_param_b = 0x%x and %d \n", rssi_compensation_param
.bg_param_b
, rssi_compensation_param
.bg_param_b
);
5546 A_PRINTF("a_param_a = 0x%x and %d \n", rssi_compensation_param
.a_param_a
, rssi_compensation_param
.a_param_a
);
5547 A_PRINTF("a_param_b = 0x%x and %d \n", rssi_compensation_param
.a_param_b
, rssi_compensation_param
.a_param_b
);
5548 A_PRINTF("Last 4 bytes = 0x%x \n", rssi_compensation_param
.reserved
);
5551 if (rssi_compensation_param
.enable
!= 0x1) {
5552 rssi_compensation_param
.enable
= 0;
5558 s32
rssi_compensation_calc_tcmd(u32 freq
, s32 rssi
, u32 totalPkt
)
5563 if (rssi_compensation_param
.enable
)
5565 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11a\n"));
5566 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d, totalPkt = %d\n", rssi
,totalPkt
));
5567 rssi
= rssi
* rssi_compensation_param
.a_param_a
+ totalPkt
* rssi_compensation_param
.a_param_b
;
5568 rssi
= (rssi
-50) /100;
5569 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5574 if (rssi_compensation_param
.enable
)
5576 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11bg\n"));
5577 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d, totalPkt = %d\n", rssi
,totalPkt
));
5578 rssi
= rssi
* rssi_compensation_param
.bg_param_a
+ totalPkt
* rssi_compensation_param
.bg_param_b
;
5579 rssi
= (rssi
-50) /100;
5580 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5587 s16
rssi_compensation_calc(struct ar6_softc
*ar
, s16 rssi
)
5589 if (ar
->arBssChannel
> 5000)
5591 if (rssi_compensation_param
.enable
)
5593 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11a\n"));
5594 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d\n", rssi
));
5595 rssi
= rssi
* rssi_compensation_param
.a_param_a
+ rssi_compensation_param
.a_param_b
;
5596 rssi
= (rssi
-50) /100;
5597 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5602 if (rssi_compensation_param
.enable
)
5604 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11bg\n"));
5605 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d\n", rssi
));
5606 rssi
= rssi
* rssi_compensation_param
.bg_param_a
+ rssi_compensation_param
.bg_param_b
;
5607 rssi
= (rssi
-50) /100;
5608 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5615 s16
rssi_compensation_reverse_calc(struct ar6_softc
*ar
, s16 rssi
, bool Above
)
5619 if (ar
->arBssChannel
> 5000)
5621 if (rssi_compensation_param
.enable
)
5623 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11a\n"));
5624 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before rev compensation = %d\n", rssi
));
5626 rssi
= (rssi
- rssi_compensation_param
.a_param_b
) / rssi_compensation_param
.a_param_a
;
5627 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after rev compensation = %d\n", rssi
));
5632 if (rssi_compensation_param
.enable
)
5634 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11bg\n"));
5635 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before rev compensation = %d\n", rssi
));
5638 for (i
=95; i
>=0; i
--) {
5639 if (rssi
<= rssi_compensation_table
[i
]) {
5645 for (i
=0; i
<=95; i
++) {
5646 if (rssi
>= rssi_compensation_table
[i
]) {
5652 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after rev compensation = %d\n", rssi
));
5660 void ap_wapi_rekey_event(struct ar6_softc
*ar
, u8 type
, u8
*mac
)
5662 union iwreq_data wrqu
;
5665 A_MEMZERO(buf
, sizeof(buf
));
5667 strcpy(buf
, "WAPI_REKEY");
5669 memcpy(&buf
[11], mac
, ATH_MAC_LEN
);
5671 A_MEMZERO(&wrqu
, sizeof(wrqu
));
5672 wrqu
.data
.length
= 10+1+ATH_MAC_LEN
;
5673 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
5675 A_PRINTF("WAPI REKEY - %d - %02x:%02x\n", type
, mac
[4], mac
[5]);
5680 ar6000_reinstall_keys(struct ar6_softc
*ar
, u8 key_op_ctrl
)
5683 struct ieee80211req_key
*uik
= &ar
->user_saved_keys
.ucast_ik
;
5684 struct ieee80211req_key
*bik
= &ar
->user_saved_keys
.bcast_ik
;
5685 CRYPTO_TYPE keyType
= ar
->user_saved_keys
.keyType
;
5687 if (IEEE80211_CIPHER_CCKM_KRK
!= uik
->ik_type
) {
5688 if (NONE_CRYPT
== keyType
) {
5689 goto _reinstall_keys_out
;
5692 if (uik
->ik_keylen
) {
5693 status
= wmi_addKey_cmd(ar
->arWmi
, uik
->ik_keyix
,
5694 ar
->user_saved_keys
.keyType
, PAIRWISE_USAGE
,
5695 uik
->ik_keylen
, (u8
*)&uik
->ik_keyrsc
,
5696 uik
->ik_keydata
, key_op_ctrl
, uik
->ik_macaddr
, SYNC_BEFORE_WMIFLAG
);
5700 status
= wmi_add_krk_cmd(ar
->arWmi
, uik
->ik_keydata
);
5703 if (IEEE80211_CIPHER_CCKM_KRK
!= bik
->ik_type
) {
5704 if (NONE_CRYPT
== keyType
) {
5705 goto _reinstall_keys_out
;
5708 if (bik
->ik_keylen
) {
5709 status
= wmi_addKey_cmd(ar
->arWmi
, bik
->ik_keyix
,
5710 ar
->user_saved_keys
.keyType
, GROUP_USAGE
,
5711 bik
->ik_keylen
, (u8
*)&bik
->ik_keyrsc
,
5712 bik
->ik_keydata
, key_op_ctrl
, bik
->ik_macaddr
, NO_SYNC_WMIFLAG
);
5715 status
= wmi_add_krk_cmd(ar
->arWmi
, bik
->ik_keydata
);
5718 _reinstall_keys_out
:
5719 ar
->user_savedkeys_stat
= USER_SAVEDKEYS_STAT_INIT
;
5720 ar
->user_key_ctrl
= 0;
5727 ar6000_dset_open_req(
5745 ar6000_dset_data_req(
5757 ar6000_ap_mode_profile_commit(struct ar6_softc
*ar
)
5760 unsigned long flags
;
5762 /* No change in AP's profile configuration */
5763 if(ar
->ap_profile_flag
==0) {
5764 A_PRINTF("COMMIT: No change in profile!!!\n");
5768 if(!ar
->arSsidLen
) {
5769 A_PRINTF("SSID not set!!!\n");
5773 switch(ar
->arAuthMode
) {
5775 if((ar
->arPairwiseCrypto
!= NONE_CRYPT
) &&
5777 (ar
->arPairwiseCrypto
!= WAPI_CRYPT
) &&
5779 (ar
->arPairwiseCrypto
!= WEP_CRYPT
)) {
5780 A_PRINTF("Cipher not supported in AP mode Open auth\n");
5786 case (WPA_PSK_AUTH
|WPA2_PSK_AUTH
):
5789 A_PRINTF("This key mgmt type not supported in AP mode\n");
5793 /* Update the arNetworkType */
5794 ar
->arNetworkType
= ar
->arNextMode
;
5796 A_MEMZERO(&p
,sizeof(p
));
5797 p
.ssidLength
= ar
->arSsidLen
;
5798 memcpy(p
.ssid
,ar
->arSsid
,p
.ssidLength
);
5799 p
.channel
= ar
->arChannelHint
;
5800 p
.networkType
= ar
->arNetworkType
;
5802 p
.dot11AuthMode
= ar
->arDot11AuthMode
;
5803 p
.authMode
= ar
->arAuthMode
;
5804 p
.pairwiseCryptoType
= ar
->arPairwiseCrypto
;
5805 p
.pairwiseCryptoLen
= ar
->arPairwiseCryptoLen
;
5806 p
.groupCryptoType
= ar
->arGroupCrypto
;
5807 p
.groupCryptoLen
= ar
->arGroupCryptoLen
;
5808 p
.ctrl_flags
= ar
->arConnectCtrlFlags
;
5810 wmi_ap_profile_commit(ar
->arWmi
, &p
);
5811 spin_lock_irqsave(&ar
->arLock
, flags
);
5812 ar
->arConnected
= true;
5813 netif_carrier_on(ar
->arNetDev
);
5814 spin_unlock_irqrestore(&ar
->arLock
, flags
);
5815 ar
->ap_profile_flag
= 0;
5820 ar6000_connect_to_ap(struct ar6_softc
*ar
)
5822 /* The ssid length check prevents second "essid off" from the user,
5823 to be treated as a connect cmd. The second "essid off" is ignored.
5825 if((ar
->arWmiReady
== true) && (ar
->arSsidLen
> 0) && ar
->arNetworkType
!=AP_NETWORK
)
5828 if((ADHOC_NETWORK
!= ar
->arNetworkType
) &&
5829 (NONE_AUTH
==ar
->arAuthMode
) &&
5830 (WEP_CRYPT
==ar
->arPairwiseCrypto
)) {
5831 ar6000_install_static_wep_keys(ar
);
5834 if (!ar
->arUserBssFilter
) {
5835 if (wmi_bssfilter_cmd(ar
->arWmi
, ALL_BSS_FILTER
, 0) != 0) {
5840 if (ar
->arWapiEnable
) {
5841 ar
->arPairwiseCrypto
= WAPI_CRYPT
;
5842 ar
->arPairwiseCryptoLen
= 0;
5843 ar
->arGroupCrypto
= WAPI_CRYPT
;
5844 ar
->arGroupCryptoLen
= 0;
5845 ar
->arAuthMode
= NONE_AUTH
;
5846 ar
->arConnectCtrlFlags
|= CONNECT_IGNORE_WPAx_GROUP_CIPHER
;
5849 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("Connect called with authmode %d dot11 auth %d"\
5850 " PW crypto %d PW crypto Len %d GRP crypto %d"\
5851 " GRP crypto Len %d\n",
5852 ar
->arAuthMode
, ar
->arDot11AuthMode
,
5853 ar
->arPairwiseCrypto
, ar
->arPairwiseCryptoLen
,
5854 ar
->arGroupCrypto
, ar
->arGroupCryptoLen
));
5856 /* Set the listen interval into 1000TUs or more. This value will be indicated to Ap in the conn.
5857 later set it back locally at the STA to 100/1000 TUs depending on the power mode */
5858 if ((ar
->arNetworkType
== INFRA_NETWORK
)) {
5859 wmi_listeninterval_cmd(ar
->arWmi
, max(ar
->arListenIntervalT
, (u16
)A_MAX_WOW_LISTEN_INTERVAL
), 0);
5861 status
= wmi_connect_cmd(ar
->arWmi
, ar
->arNetworkType
,
5862 ar
->arDot11AuthMode
, ar
->arAuthMode
,
5863 ar
->arPairwiseCrypto
, ar
->arPairwiseCryptoLen
,
5864 ar
->arGroupCrypto
,ar
->arGroupCryptoLen
,
5865 ar
->arSsidLen
, ar
->arSsid
,
5866 ar
->arReqBssid
, ar
->arChannelHint
,
5867 ar
->arConnectCtrlFlags
);
5869 wmi_listeninterval_cmd(ar
->arWmi
, ar
->arListenIntervalT
, ar
->arListenIntervalB
);
5870 if (!ar
->arUserBssFilter
) {
5871 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
5876 if ((!(ar
->arConnectCtrlFlags
& CONNECT_DO_WPA_OFFLOAD
)) &&
5877 ((WPA_PSK_AUTH
== ar
->arAuthMode
) || (WPA2_PSK_AUTH
== ar
->arAuthMode
)))
5879 A_TIMEOUT_MS(&ar
->disconnect_timer
, A_DISCONNECT_TIMER_INTERVAL
, 0);
5882 ar
->arConnectCtrlFlags
&= ~CONNECT_DO_WPA_OFFLOAD
;
5884 ar
->arConnectPending
= true;
5891 ar6000_disconnect(struct ar6_softc
*ar
)
5893 if ((ar
->arConnected
== true) || (ar
->arConnectPending
== true)) {
5894 wmi_disconnect_cmd(ar
->arWmi
);
5896 * Disconnect cmd is issued, clear connectPending.
5897 * arConnected will be cleard in disconnect_event notification.
5899 ar
->arConnectPending
= false;
5906 ar6000_ap_mode_get_wpa_ie(struct ar6_softc
*ar
, struct ieee80211req_wpaie
*wpaie
)
5909 conn
= ieee80211_find_conn(ar
, wpaie
->wpa_macaddr
);
5911 A_MEMZERO(wpaie
->wpa_ie
, IEEE80211_MAX_IE
);
5912 A_MEMZERO(wpaie
->rsn_ie
, IEEE80211_MAX_IE
);
5915 memcpy(wpaie
->wpa_ie
, conn
->wpa_ie
, IEEE80211_MAX_IE
);
5922 is_iwioctl_allowed(u8 mode
, u16 cmd
)
5924 if(cmd
>= SIOCSIWCOMMIT
&& cmd
<= SIOCGIWPOWER
) {
5925 cmd
-= SIOCSIWCOMMIT
;
5926 if(sioctl_filter
[cmd
] == 0xFF) return 0;
5927 if(sioctl_filter
[cmd
] & mode
) return 0;
5928 } else if(cmd
>= SIOCIWFIRSTPRIV
&& cmd
<= (SIOCIWFIRSTPRIV
+30)) {
5929 cmd
-= SIOCIWFIRSTPRIV
;
5930 if(pioctl_filter
[cmd
] == 0xFF) return 0;
5931 if(pioctl_filter
[cmd
] & mode
) return 0;
5939 is_xioctl_allowed(u8 mode
, int cmd
)
5941 if(sizeof(xioctl_filter
)-1 < cmd
) {
5942 A_PRINTF("Filter for this cmd=%d not defined\n",cmd
);
5945 if(xioctl_filter
[cmd
] == 0xFF) return 0;
5946 if(xioctl_filter
[cmd
] & mode
) return 0;
5952 ap_set_wapi_key(struct ar6_softc
*ar
, void *ikey
)
5954 struct ieee80211req_key
*ik
= (struct ieee80211req_key
*)ikey
;
5955 KEY_USAGE keyUsage
= 0;
5958 if (memcmp(ik
->ik_macaddr
, bcast_mac
, IEEE80211_ADDR_LEN
) == 0) {
5959 keyUsage
= GROUP_USAGE
;
5961 keyUsage
= PAIRWISE_USAGE
;
5963 A_PRINTF("WAPI_KEY: Type:%d ix:%d mac:%02x:%02x len:%d\n",
5964 keyUsage
, ik
->ik_keyix
, ik
->ik_macaddr
[4], ik
->ik_macaddr
[5],
5967 status
= wmi_addKey_cmd(ar
->arWmi
, ik
->ik_keyix
, WAPI_CRYPT
, keyUsage
,
5968 ik
->ik_keylen
, (u8
*)&ik
->ik_keyrsc
,
5969 ik
->ik_keydata
, KEY_OP_INIT_VAL
, ik
->ik_macaddr
,
5979 void ar6000_peer_event(
5986 for (pos
=0;pos
<6;pos
++)
5987 printk("%02x: ",*(macAddr
+pos
));
5991 #ifdef HTC_TEST_SEND_PKTS
5992 #define HTC_TEST_DUPLICATE 8
5993 static void DoHTCSendPktsTest(struct ar6_softc
*ar
, int MapNo
, HTC_ENDPOINT_ID eid
, struct sk_buff
*dupskb
)
5995 struct ar_cookie
*cookie
;
5996 struct ar_cookie
*cookieArray
[HTC_TEST_DUPLICATE
];
5997 struct sk_buff
*new_skb
;
6000 struct htc_packet_queue pktQueue
;
6001 EPPING_HEADER
*eppingHdr
;
6003 eppingHdr
= A_NETBUF_DATA(dupskb
);
6005 if (eppingHdr
->Cmd_h
== EPPING_CMD_NO_ECHO
) {
6006 /* skip test if this is already a tx perf test */
6010 for (i
= 0; i
< HTC_TEST_DUPLICATE
; i
++,pkts
++) {
6011 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
6012 cookie
= ar6000_alloc_cookie(ar
);
6013 if (cookie
!= NULL
) {
6014 ar
->arTxPending
[eid
]++;
6015 ar
->arTotalTxDataPending
++;
6018 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
6020 if (NULL
== cookie
) {
6024 new_skb
= A_NETBUF_ALLOC(A_NETBUF_LEN(dupskb
));
6026 if (new_skb
== NULL
) {
6027 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
6028 ar6000_free_cookie(ar
,cookie
);
6029 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
6033 A_NETBUF_PUT_DATA(new_skb
, A_NETBUF_DATA(dupskb
), A_NETBUF_LEN(dupskb
));
6034 cookie
->arc_bp
[0] = (unsigned long)new_skb
;
6035 cookie
->arc_bp
[1] = MapNo
;
6036 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
6038 A_NETBUF_DATA(new_skb
),
6039 A_NETBUF_LEN(new_skb
),
6043 cookieArray
[i
] = cookie
;
6046 EPPING_HEADER
*pHdr
= (EPPING_HEADER
*)A_NETBUF_DATA(new_skb
);
6047 pHdr
->Cmd_h
= EPPING_CMD_NO_ECHO
; /* do not echo the packet */
6055 INIT_HTC_PACKET_QUEUE(&pktQueue
);
6057 for (i
= 0; i
< pkts
; i
++) {
6058 HTC_PACKET_ENQUEUE(&pktQueue
,&cookieArray
[i
]->HtcPkt
);
6061 HTCSendPktsMultiple(ar
->arHtcTarget
, &pktQueue
);
6066 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
6068 * Add support for adding and removing a virtual adapter for soft AP.
6069 * Some OS requires different adapters names for station and soft AP mode.
6070 * To support these requirement, create and destroy a netdevice instance
6071 * when the AP mode is operational. A full fledged support for virual device
6072 * is not implemented. Rather a virtual interface is created and is linked
6073 * with the existing physical device instance during the operation of the
6077 int ar6000_start_ap_interface(struct ar6_softc
*ar
)
6079 struct ar_virtual_interface
*arApDev
;
6081 /* Change net_device to point to AP instance */
6082 arApDev
= (struct ar_virtual_interface
*)ar
->arApDev
;
6083 ar
->arNetDev
= arApDev
->arNetDev
;
6088 int ar6000_stop_ap_interface(struct ar6_softc
*ar
)
6090 struct ar_virtual_interface
*arApDev
;
6092 /* Change net_device to point to sta instance */
6093 arApDev
= (struct ar_virtual_interface
*)ar
->arApDev
;
6095 ar
->arNetDev
= arApDev
->arStaNetDev
;
6102 int ar6000_create_ap_interface(struct ar6_softc
*ar
, char *ap_ifname
)
6104 struct net_device
*dev
;
6105 struct ar_virtual_interface
*arApDev
;
6107 dev
= alloc_etherdev(sizeof(struct ar_virtual_interface
));
6109 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_create_ap_interface: can't alloc etherdev\n"));
6114 init_netdev(dev
, ap_ifname
);
6116 if (register_netdev(dev
)) {
6117 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_create_ap_interface: register_netdev failed\n"));
6121 arApDev
= netdev_priv(dev
);
6122 arApDev
->arDev
= ar
;
6123 arApDev
->arNetDev
= dev
;
6124 arApDev
->arStaNetDev
= ar
->arNetDev
;
6126 ar
->arApDev
= arApDev
;
6129 /* Copy the MAC address */
6130 memcpy(dev
->dev_addr
, ar
->arNetDev
->dev_addr
, AR6000_ETH_ADDR_LEN
);
6135 int ar6000_add_ap_interface(struct ar6_softc
*ar
, char *ap_ifname
)
6137 /* Interface already added, need not proceed further */
6138 if (ar
->arApDev
!= NULL
) {
6139 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_add_ap_interface: interface already present \n"));
6143 if (ar6000_create_ap_interface(ar
, ap_ifname
) != 0) {
6147 A_PRINTF("Add AP interface %s \n",ap_ifname
);
6149 return ar6000_start_ap_interface(ar
);
6152 int ar6000_remove_ap_interface(struct ar6_softc
*ar
)
6155 ar6000_stop_ap_interface(ar
);
6157 unregister_netdev(arApNetDev
);
6158 free_netdev(apApNetDev
);
6160 A_PRINTF("Remove AP interface\n");
6168 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
6171 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
6172 EXPORT_SYMBOL(setupbtdev
);