1 //------------------------------------------------------------------------------
2 // Copyright (c) 2004-2010 Atheros Communications Inc.
3 // All rights reserved.
7 // Permission to use, copy, modify, and/or distribute this software for any
8 // purpose with or without fee is hereby granted, provided that the above
9 // copyright notice and this permission notice appear in all copies.
11 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 // Author(s): ="Atheros"
22 //------------------------------------------------------------------------------
25 * This driver is a pseudo ethernet driver to access the Atheros AR6000
29 #include "ar6000_drv.h"
32 #include "wmi_filter_linux.h"
33 #include "epping_test.h"
34 #include "wlan_config.h"
35 #include "ar3kconfig.h"
37 #include "AR6002/addrs.h"
40 /* LINUX_HACK_FUDGE_FACTOR -- this is used to provide a workaround for linux behavior. When
41 * the meta data was added to the header it was found that linux did not correctly provide
42 * enough headroom. However when more headroom was requested beyond what was truly needed
43 * Linux gave the requested headroom. Therefore to get the necessary headroom from Linux
44 * the driver requests more than is needed by the amount = LINUX_HACK_FUDGE_FACTOR */
45 #define LINUX_HACK_FUDGE_FACTOR 16
46 #define BDATA_BDADDR_OFFSET 28
48 u8 bcast_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
49 u8 null_mac
[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
53 #define ATH_DEBUG_DBG_LOG ATH_DEBUG_MAKE_MODULE_MASK(0)
54 #define ATH_DEBUG_WLAN_CONNECT ATH_DEBUG_MAKE_MODULE_MASK(1)
55 #define ATH_DEBUG_WLAN_SCAN ATH_DEBUG_MAKE_MODULE_MASK(2)
56 #define ATH_DEBUG_WLAN_TX ATH_DEBUG_MAKE_MODULE_MASK(3)
57 #define ATH_DEBUG_WLAN_RX ATH_DEBUG_MAKE_MODULE_MASK(4)
58 #define ATH_DEBUG_HTC_RAW ATH_DEBUG_MAKE_MODULE_MASK(5)
59 #define ATH_DEBUG_HCI_BRIDGE ATH_DEBUG_MAKE_MODULE_MASK(6)
61 static struct ath_debug_mask_description driver_debug_desc
[] = {
62 { ATH_DEBUG_DBG_LOG
, "Target Debug Logs"},
63 { ATH_DEBUG_WLAN_CONNECT
, "WLAN connect"},
64 { ATH_DEBUG_WLAN_SCAN
, "WLAN scan"},
65 { ATH_DEBUG_WLAN_TX
, "WLAN Tx"},
66 { ATH_DEBUG_WLAN_RX
, "WLAN Rx"},
67 { ATH_DEBUG_HTC_RAW
, "HTC Raw IF tracing"},
68 { ATH_DEBUG_HCI_BRIDGE
, "HCI Bridge Setup"},
69 { ATH_DEBUG_HCI_RECV
, "HCI Recv tracing"},
70 { ATH_DEBUG_HCI_DUMP
, "HCI Packet dumps"},
73 ATH_DEBUG_INSTANTIATE_MODULE_VAR(driver
,
75 "Linux Driver Interface",
76 ATH_DEBUG_MASK_DEFAULTS
| ATH_DEBUG_WLAN_SCAN
|
78 ATH_DEBUG_DESCRIPTION_COUNT(driver_debug_desc
),
84 #define IS_MAC_NULL(mac) (mac[0]==0 && mac[1]==0 && mac[2]==0 && mac[3]==0 && mac[4]==0 && mac[5]==0)
85 #define IS_MAC_BCAST(mac) (*mac==0xff)
87 #define DESCRIPTION "Driver to access the Atheros AR600x Device, version " __stringify(__VER_MAJOR_) "." __stringify(__VER_MINOR_) "." __stringify(__VER_PATCH_) "." __stringify(__BUILD_NUMBER_)
89 MODULE_AUTHOR("Atheros Communications, Inc.");
90 MODULE_DESCRIPTION(DESCRIPTION
);
91 MODULE_LICENSE("Dual BSD/GPL");
93 #ifndef REORG_APTC_HEURISTICS
94 #undef ADAPTIVE_POWER_THROUGHPUT_CONTROL
95 #endif /* REORG_APTC_HEURISTICS */
97 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
98 #define APTC_TRAFFIC_SAMPLING_INTERVAL 100 /* msec */
99 #define APTC_UPPER_THROUGHPUT_THRESHOLD 3000 /* Kbps */
100 #define APTC_LOWER_THROUGHPUT_THRESHOLD 2000 /* Kbps */
102 typedef struct aptc_traffic_record
{
104 struct timeval samplingTS
;
105 unsigned long bytesReceived
;
106 unsigned long bytesTransmitted
;
107 } APTC_TRAFFIC_RECORD
;
110 APTC_TRAFFIC_RECORD aptcTR
;
111 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
113 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
114 // callbacks registered by HCI transport driver
115 struct hci_transport_callbacks ar6kHciTransCallbacks
= { NULL
};
118 unsigned int processDot11Hdr
= 0;
120 char ifname
[IFNAMSIZ
] = {0,};
122 int wlaninitmode
= WLAN_INIT_MODE_DEFAULT
;
123 static bool bypasswmi
;
124 unsigned int debuglevel
= 0;
125 int tspecCompliance
= ATHEROS_COMPLIANCE
;
126 unsigned int busspeedlow
= 0;
127 unsigned int onebitmode
= 0;
128 unsigned int skipflash
= 0;
129 unsigned int wmitimeout
= 2;
130 unsigned int wlanNodeCaching
= 1;
131 unsigned int enableuartprint
= ENABLEUARTPRINT_DEFAULT
;
132 unsigned int logWmiRawMsgs
= 0;
133 unsigned int enabletimerwar
= 0;
134 unsigned int num_device
= 1;
135 unsigned int regscanmode
;
136 unsigned int fwmode
= 1;
137 unsigned int mbox_yield_limit
= 99;
138 unsigned int enablerssicompensation
= 0;
139 int reduce_credit_dribble
= 1 + HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF
;
140 int allow_trace_signal
= 0;
141 #ifdef CONFIG_HOST_TCMD_SUPPORT
142 unsigned int testmode
=0;
145 unsigned int irqprocmode
= HIF_DEVICE_IRQ_SYNC_ONLY
;//HIF_DEVICE_IRQ_ASYNC_SYNC;
146 unsigned int panic_on_assert
= 1;
147 unsigned int nohifscattersupport
= NOHIFSCATTERSUPPORT_DEFAULT
;
149 unsigned int setuphci
= SETUPHCI_DEFAULT
;
150 unsigned int loghci
= 0;
151 unsigned int setupbtdev
= SETUPBTDEV_DEFAULT
;
152 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
153 unsigned int ar3khcibaud
= AR3KHCIBAUD_DEFAULT
;
154 unsigned int hciuartscale
= HCIUARTSCALE_DEFAULT
;
155 unsigned int hciuartstep
= HCIUARTSTEP_DEFAULT
;
157 unsigned int csumOffload
=0;
158 unsigned int csumOffloadTest
=0;
159 unsigned int eppingtest
=0;
160 unsigned int mac_addr_method
;
161 unsigned int firmware_bridge
;
163 module_param_string(ifname
, ifname
, sizeof(ifname
), 0644);
164 module_param(wlaninitmode
, int, 0644);
165 module_param(bypasswmi
, bool, 0644);
166 module_param(debuglevel
, uint
, 0644);
167 module_param(tspecCompliance
, int, 0644);
168 module_param(onebitmode
, uint
, 0644);
169 module_param(busspeedlow
, uint
, 0644);
170 module_param(skipflash
, uint
, 0644);
171 module_param(wmitimeout
, uint
, 0644);
172 module_param(wlanNodeCaching
, uint
, 0644);
173 module_param(logWmiRawMsgs
, uint
, 0644);
174 module_param(enableuartprint
, uint
, 0644);
175 module_param(enabletimerwar
, uint
, 0644);
176 module_param(fwmode
, uint
, 0644);
177 module_param(mbox_yield_limit
, uint
, 0644);
178 module_param(reduce_credit_dribble
, int, 0644);
179 module_param(allow_trace_signal
, int, 0644);
180 module_param(enablerssicompensation
, uint
, 0644);
181 module_param(processDot11Hdr
, uint
, 0644);
182 module_param(csumOffload
, uint
, 0644);
183 #ifdef CONFIG_HOST_TCMD_SUPPORT
184 module_param(testmode
, uint
, 0644);
186 module_param(irqprocmode
, uint
, 0644);
187 module_param(nohifscattersupport
, uint
, 0644);
188 module_param(panic_on_assert
, uint
, 0644);
189 module_param(setuphci
, uint
, 0644);
190 module_param(loghci
, uint
, 0644);
191 module_param(setupbtdev
, uint
, 0644);
192 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
193 module_param(ar3khcibaud
, uint
, 0644);
194 module_param(hciuartscale
, uint
, 0644);
195 module_param(hciuartstep
, uint
, 0644);
197 module_param(eppingtest
, uint
, 0644);
199 /* in 2.6.10 and later this is now a pointer to a uint */
200 unsigned int _mboxnum
= HTC_MAILBOX_NUM_MAX
;
201 #define mboxnum &_mboxnum
204 u32 g_dbg_flags
= DBG_DEFAULTS
;
205 unsigned int debugflags
= 0;
207 unsigned int debughtc
= 0;
208 unsigned int debugbmi
= 0;
209 unsigned int debughif
= 0;
210 unsigned int txcreditsavailable
[HTC_MAILBOX_NUM_MAX
] = {0};
211 unsigned int txcreditsconsumed
[HTC_MAILBOX_NUM_MAX
] = {0};
212 unsigned int txcreditintrenable
[HTC_MAILBOX_NUM_MAX
] = {0};
213 unsigned int txcreditintrenableaggregate
[HTC_MAILBOX_NUM_MAX
] = {0};
214 module_param(debugflags
, uint
, 0644);
215 module_param(debugdriver
, int, 0644);
216 module_param(debughtc
, uint
, 0644);
217 module_param(debugbmi
, uint
, 0644);
218 module_param(debughif
, uint
, 0644);
219 module_param_array(txcreditsavailable
, uint
, mboxnum
, 0644);
220 module_param_array(txcreditsconsumed
, uint
, mboxnum
, 0644);
221 module_param_array(txcreditintrenable
, uint
, mboxnum
, 0644);
222 module_param_array(txcreditintrenableaggregate
, uint
, mboxnum
, 0644);
226 unsigned int resetok
= 1;
227 unsigned int tx_attempt
[HTC_MAILBOX_NUM_MAX
] = {0};
228 unsigned int tx_post
[HTC_MAILBOX_NUM_MAX
] = {0};
229 unsigned int tx_complete
[HTC_MAILBOX_NUM_MAX
] = {0};
230 unsigned int hifBusRequestNumMax
= 40;
231 unsigned int war23838_disabled
= 0;
232 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
233 unsigned int enableAPTCHeuristics
= 1;
234 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
235 module_param_array(tx_attempt
, uint
, mboxnum
, 0644);
236 module_param_array(tx_post
, uint
, mboxnum
, 0644);
237 module_param_array(tx_complete
, uint
, mboxnum
, 0644);
238 module_param(hifBusRequestNumMax
, uint
, 0644);
239 module_param(war23838_disabled
, uint
, 0644);
240 module_param(resetok
, uint
, 0644);
241 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
242 module_param(enableAPTCHeuristics
, uint
, 0644);
243 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
245 #ifdef BLOCK_TX_PATH_FLAG
247 module_param(blocktx
, int, 0644);
248 #endif /* BLOCK_TX_PATH_FLAG */
250 typedef struct user_rssi_compensation_t
{
262 } USER_RSSI_CPENSATION
;
264 static USER_RSSI_CPENSATION rssi_compensation_param
;
266 static s16 rssi_compensation_table
[96];
268 int reconnect_flag
= 0;
269 static ar6k_pal_config_t ar6k_pal_config_g
;
271 /* Function declarations */
272 static int ar6000_init_module(void);
273 static void ar6000_cleanup_module(void);
275 int ar6000_init(struct net_device
*dev
);
276 static int ar6000_open(struct net_device
*dev
);
277 static int ar6000_close(struct net_device
*dev
);
278 static void ar6000_init_control_info(struct ar6_softc
*ar
);
279 static int ar6000_data_tx(struct sk_buff
*skb
, struct net_device
*dev
);
281 void ar6000_destroy(struct net_device
*dev
, unsigned int unregister
);
282 static void ar6000_detect_error(unsigned long ptr
);
283 static void ar6000_set_multicast_list(struct net_device
*dev
);
284 static struct net_device_stats
*ar6000_get_stats(struct net_device
*dev
);
286 static void disconnect_timer_handler(unsigned long ptr
);
288 void read_rssi_compensation_param(struct ar6_softc
*ar
);
291 * HTC service connection handlers
293 static int ar6000_avail_ev(void *context
, void *hif_handle
);
295 static int ar6000_unavail_ev(void *context
, void *hif_handle
);
297 int ar6000_configure_target(struct ar6_softc
*ar
);
299 static void ar6000_target_failure(void *Instance
, int Status
);
301 static void ar6000_rx(void *Context
, struct htc_packet
*pPacket
);
303 static void ar6000_rx_refill(void *Context
,HTC_ENDPOINT_ID Endpoint
);
305 static void ar6000_tx_complete(void *Context
, struct htc_packet_queue
*pPackets
);
307 static HTC_SEND_FULL_ACTION
ar6000_tx_queue_full(void *Context
, struct htc_packet
*pPacket
);
309 static void ar6000_alloc_netbufs(A_NETBUF_QUEUE_T
*q
, u16 num
);
310 static void ar6000_deliver_frames_to_nw_stack(void * dev
, void *osbuf
);
311 //static void ar6000_deliver_frames_to_bt_stack(void * dev, void *osbuf);
313 static struct htc_packet
*ar6000_alloc_amsdu_rxbuf(void *Context
, HTC_ENDPOINT_ID Endpoint
, int Length
);
315 static void ar6000_refill_amsdu_rxbufs(struct ar6_softc
*ar
, int Count
);
317 static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc
*ar
);
320 ar6000_sysfs_bmi_read(struct file
*fp
, struct kobject
*kobj
,
321 struct bin_attribute
*bin_attr
,
322 char *buf
, loff_t pos
, size_t count
);
325 ar6000_sysfs_bmi_write(struct file
*fp
, struct kobject
*kobj
,
326 struct bin_attribute
*bin_attr
,
327 char *buf
, loff_t pos
, size_t count
);
330 ar6000_sysfs_bmi_init(struct ar6_softc
*ar
);
332 void ar6k_cleanup_hci_pal(struct ar6_softc
*ar
);
335 ar6000_sysfs_bmi_deinit(struct ar6_softc
*ar
);
338 ar6000_sysfs_bmi_get_config(struct ar6_softc
*ar
, u32 mode
);
344 struct net_device
*ar6000_devices
[MAX_AR6000
];
345 static int is_netdev_registered
;
346 DECLARE_WAIT_QUEUE_HEAD(arEvent
);
347 static void ar6000_cookie_init(struct ar6_softc
*ar
);
348 static void ar6000_cookie_cleanup(struct ar6_softc
*ar
);
349 static void ar6000_free_cookie(struct ar6_softc
*ar
, struct ar_cookie
* cookie
);
350 static struct ar_cookie
*ar6000_alloc_cookie(struct ar6_softc
*ar
);
352 static int ar6000_reinstall_keys(struct ar6_softc
*ar
,u8 key_op_ctrl
);
354 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
355 struct net_device
*arApNetDev
;
356 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
358 static struct ar_cookie s_ar_cookie_mem
[MAX_COOKIE_NUM
];
360 #define HOST_INTEREST_ITEM_ADDRESS(ar, item) \
361 (((ar)->arTargetType == TARGET_TYPE_AR6002) ? AR6002_HOST_INTEREST_ITEM_ADDRESS(item) : \
362 (((ar)->arTargetType == TARGET_TYPE_AR6003) ? AR6003_HOST_INTEREST_ITEM_ADDRESS(item) : 0))
365 static struct net_device_ops ar6000_netdev_ops
= {
367 .ndo_open
= ar6000_open
,
368 .ndo_stop
= ar6000_close
,
369 .ndo_get_stats
= ar6000_get_stats
,
370 .ndo_start_xmit
= ar6000_data_tx
,
371 .ndo_set_multicast_list
= ar6000_set_multicast_list
,
374 /* Debug log support */
377 * Flag to govern whether the debug logs should be parsed in the kernel
378 * or reported to the application.
380 #define REPORT_DEBUG_LOGS_TO_APP
383 ar6000_set_host_app_area(struct ar6_softc
*ar
)
386 struct host_app_area_s host_app_area
;
388 /* Fetch the address of the host_app_area_s instance in the host interest area */
389 address
= TARG_VTOP(ar
->arTargetType
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_app_host_interest
));
390 if (ar6000_ReadRegDiag(ar
->arHifDevice
, &address
, &data
) != 0) {
393 address
= TARG_VTOP(ar
->arTargetType
, data
);
394 host_app_area
.wmi_protocol_ver
= WMI_PROTOCOL_VERSION
;
395 if (ar6000_WriteDataDiag(ar
->arHifDevice
, address
,
396 (u8
*)&host_app_area
,
397 sizeof(struct host_app_area_s
)) != 0)
405 u32
dbglog_get_debug_hdr_ptr(struct ar6_softc
*ar
)
411 address
= TARG_VTOP(ar
->arTargetType
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_dbglog_hdr
));
412 if ((status
= ar6000_ReadDataDiag(ar
->arHifDevice
, address
,
413 (u8
*)¶m
, 4)) != 0)
422 * The dbglog module has been initialized. Its ok to access the relevant
423 * data stuctures over the diagnostic window.
426 ar6000_dbglog_init_done(struct ar6_softc
*ar
)
428 ar
->dbglog_init_done
= true;
431 u32
dbglog_get_debug_fragment(s8
*datap
, u32 len
, u32 limit
)
440 buffer
= (s32
*)datap
;
441 length
= (limit
>> 2);
446 while (count
< length
) {
447 numargs
= DBGLOG_GET_NUMARGS(buffer
[count
]);
448 fraglen
= (count
<< 2);
449 count
+= numargs
+ 1;
457 dbglog_parse_debug_logs(s8
*datap
, u32 len
)
468 buffer
= (s32
*)datap
;
470 while (count
< length
) {
471 debugid
= DBGLOG_GET_DBGID(buffer
[count
]);
472 moduleid
= DBGLOG_GET_MODULEID(buffer
[count
]);
473 numargs
= DBGLOG_GET_NUMARGS(buffer
[count
]);
474 timestamp
= DBGLOG_GET_TIMESTAMP(buffer
[count
]);
477 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("%d %d (%d)\n", moduleid
, debugid
, timestamp
));
481 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("%d %d (%d): 0x%x\n", moduleid
, debugid
,
482 timestamp
, buffer
[count
+1]));
486 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("%d %d (%d): 0x%x, 0x%x\n", moduleid
, debugid
,
487 timestamp
, buffer
[count
+1], buffer
[count
+2]));
491 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Invalid args: %d\n", numargs
));
493 count
+= numargs
+ 1;
498 ar6000_dbglog_get_debug_logs(struct ar6_softc
*ar
)
500 u32 data
[8]; /* Should be able to accommodate struct dbglog_buf_s */
507 if (!ar
->dbglog_init_done
) return A_ERROR
;
510 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
512 if (ar
->dbgLogFetchInProgress
) {
513 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
517 /* block out others */
518 ar
->dbgLogFetchInProgress
= true;
520 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
522 debug_hdr_ptr
= dbglog_get_debug_hdr_ptr(ar
);
523 printk("debug_hdr_ptr: 0x%x\n", debug_hdr_ptr
);
525 /* Get the contents of the ring buffer */
527 address
= TARG_VTOP(ar
->arTargetType
, debug_hdr_ptr
);
528 length
= 4 /* sizeof(dbuf) */ + 4 /* sizeof(dropped) */;
529 A_MEMZERO(data
, sizeof(data
));
530 ar6000_ReadDataDiag(ar
->arHifDevice
, address
, (u8
*)data
, length
);
531 address
= TARG_VTOP(ar
->arTargetType
, data
[0] /* dbuf */);
533 dropped
= data
[1]; /* dropped */
534 length
= 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */;
535 A_MEMZERO(data
, sizeof(data
));
536 ar6000_ReadDataDiag(ar
->arHifDevice
, address
, (u8
*)&data
, length
);
539 address
= TARG_VTOP(ar
->arTargetType
, data
[1] /* buffer*/);
540 length
= data
[3]; /* length */
541 if ((length
) && (length
<= data
[2] /* bufsize*/)) {
542 /* Rewind the index if it is about to overrun the buffer */
543 if (ar
->log_cnt
> (DBGLOG_HOST_LOG_BUFFER_SIZE
- length
)) {
546 if(0 != ar6000_ReadDataDiag(ar
->arHifDevice
, address
,
547 (u8
*)&ar
->log_buffer
[ar
->log_cnt
], length
))
551 ar6000_dbglog_event(ar
, dropped
, (s8
*)&ar
->log_buffer
[ar
->log_cnt
], length
);
552 ar
->log_cnt
+= length
;
554 AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG
,("Length: %d (Total size: %d)\n",
558 address
= TARG_VTOP(ar
->arTargetType
, data
[0] /* next */);
559 length
= 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */;
560 A_MEMZERO(data
, sizeof(data
));
561 if(0 != ar6000_ReadDataDiag(ar
->arHifDevice
, address
,
562 (u8
*)&data
, length
))
567 } while (address
!= firstbuf
);
570 ar
->dbgLogFetchInProgress
= false;
576 ar6000_dbglog_event(struct ar6_softc
*ar
, u32 dropped
,
577 s8
*buffer
, u32 length
)
579 #ifdef REPORT_DEBUG_LOGS_TO_APP
580 #define MAX_WIRELESS_EVENT_SIZE 252
582 * Break it up into chunks of MAX_WIRELESS_EVENT_SIZE bytes of messages.
583 * There seems to be a limitation on the length of message that could be
584 * transmitted to the user app via this mechanism.
589 send
= dbglog_get_debug_fragment(&buffer
[sent
], length
- sent
,
590 MAX_WIRELESS_EVENT_SIZE
);
593 send
= dbglog_get_debug_fragment(&buffer
[sent
], length
- sent
,
594 MAX_WIRELESS_EVENT_SIZE
);
597 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Dropped logs: 0x%x\nDebug info length: %d\n",
600 /* Interpret the debug logs */
601 dbglog_parse_debug_logs((s8
*)buffer
, length
);
602 #endif /* REPORT_DEBUG_LOGS_TO_APP */
607 ar6000_init_module(void)
609 static int probed
= 0;
611 OSDRV_CALLBACKS osdrvCallbacks
;
613 a_module_debug_support_init();
616 /* check for debug mask overrides */
618 ATH_DEBUG_SET_DEBUG_MASK(htc
,debughtc
);
621 ATH_DEBUG_SET_DEBUG_MASK(bmi
,debugbmi
);
624 ATH_DEBUG_SET_DEBUG_MASK(hif
,debughif
);
626 if (debugdriver
!= 0) {
627 ATH_DEBUG_SET_DEBUG_MASK(driver
,debugdriver
);
632 A_REGISTER_MODULE_DEBUG_INFO(driver
);
634 A_MEMZERO(&osdrvCallbacks
,sizeof(osdrvCallbacks
));
635 osdrvCallbacks
.deviceInsertedHandler
= ar6000_avail_ev
;
636 osdrvCallbacks
.deviceRemovedHandler
= ar6000_unavail_ev
;
638 osdrvCallbacks
.deviceSuspendHandler
= ar6000_suspend_ev
;
639 osdrvCallbacks
.deviceResumeHandler
= ar6000_resume_ev
;
640 osdrvCallbacks
.devicePowerChangeHandler
= ar6000_power_change_ev
;
644 /* Set the debug flags if specified at load time */
647 g_dbg_flags
= debugflags
;
656 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
657 memset(&aptcTR
, 0, sizeof(APTC_TRAFFIC_RECORD
));
658 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
660 r
= HIFInit(&osdrvCallbacks
);
668 ar6000_cleanup_module(void)
671 struct net_device
*ar6000_netdev
;
673 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
674 /* Delete the Adaptive Power Control timer */
675 if (timer_pending(&aptcTimer
)) {
676 del_timer_sync(&aptcTimer
);
678 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
680 for (i
=0; i
< MAX_AR6000
; i
++) {
681 if (ar6000_devices
[i
] != NULL
) {
682 ar6000_netdev
= ar6000_devices
[i
];
683 ar6000_devices
[i
] = NULL
;
684 ar6000_destroy(ar6000_netdev
, 1);
688 HIFShutDownDevice(NULL
);
690 a_module_debug_support_cleanup();
692 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("ar6000_cleanup: success\n"));
695 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
697 aptcTimerHandler(unsigned long arg
)
701 struct ar6_softc
*ar
;
704 ar
= (struct ar6_softc
*)arg
;
705 A_ASSERT(ar
!= NULL
);
706 A_ASSERT(!timer_pending(&aptcTimer
));
708 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
710 /* Get the number of bytes transferred */
711 numbytes
= aptcTR
.bytesTransmitted
+ aptcTR
.bytesReceived
;
712 aptcTR
.bytesTransmitted
= aptcTR
.bytesReceived
= 0;
714 /* Calculate and decide based on throughput thresholds */
715 throughput
= ((numbytes
* 8)/APTC_TRAFFIC_SAMPLING_INTERVAL
); /* Kbps */
716 if (throughput
< APTC_LOWER_THROUGHPUT_THRESHOLD
) {
717 /* Enable Sleep and delete the timer */
718 A_ASSERT(ar
->arWmiReady
== true);
719 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
720 status
= wmi_powermode_cmd(ar
->arWmi
, REC_POWER
);
721 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
722 A_ASSERT(status
== 0);
723 aptcTR
.timerScheduled
= false;
725 A_TIMEOUT_MS(&aptcTimer
, APTC_TRAFFIC_SAMPLING_INTERVAL
, 0);
728 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
730 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
733 ar6000_alloc_netbufs(A_NETBUF_QUEUE_T
*q
, u16 num
)
738 if((osbuf
= A_NETBUF_ALLOC(AR6000_BUFFER_SIZE
))) {
739 A_NETBUF_ENQUEUE(q
, osbuf
);
747 A_PRINTF("%s(), allocation of netbuf failed", __func__
);
751 static struct bin_attribute bmi_attr
= {
752 .attr
= {.name
= "bmi", .mode
= 0600},
753 .read
= ar6000_sysfs_bmi_read
,
754 .write
= ar6000_sysfs_bmi_write
,
758 ar6000_sysfs_bmi_read(struct file
*fp
, struct kobject
*kobj
,
759 struct bin_attribute
*bin_attr
,
760 char *buf
, loff_t pos
, size_t count
)
763 struct ar6_softc
*ar
;
764 struct hif_device_os_device_info
*osDevInfo
;
766 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Read %d bytes\n", (u32
)count
));
767 for (index
=0; index
< MAX_AR6000
; index
++) {
768 ar
= (struct ar6_softc
*)ar6k_priv(ar6000_devices
[index
]);
769 osDevInfo
= &ar
->osDevInfo
;
770 if (kobj
== (&(((struct device
*)osDevInfo
->pOSDevice
)->kobj
))) {
775 if (index
== MAX_AR6000
) return 0;
777 if ((BMIRawRead(ar
->arHifDevice
, (u8
*)buf
, count
, true)) != 0) {
785 ar6000_sysfs_bmi_write(struct file
*fp
, struct kobject
*kobj
,
786 struct bin_attribute
*bin_attr
,
787 char *buf
, loff_t pos
, size_t count
)
790 struct ar6_softc
*ar
;
791 struct hif_device_os_device_info
*osDevInfo
;
793 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Write %d bytes\n", (u32
)count
));
794 for (index
=0; index
< MAX_AR6000
; index
++) {
795 ar
= (struct ar6_softc
*)ar6k_priv(ar6000_devices
[index
]);
796 osDevInfo
= &ar
->osDevInfo
;
797 if (kobj
== (&(((struct device
*)osDevInfo
->pOSDevice
)->kobj
))) {
802 if (index
== MAX_AR6000
) return 0;
804 if ((BMIRawWrite(ar
->arHifDevice
, (u8
*)buf
, count
)) != 0) {
812 ar6000_sysfs_bmi_init(struct ar6_softc
*ar
)
816 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Creating sysfs entry\n"));
817 A_MEMZERO(&ar
->osDevInfo
, sizeof(struct hif_device_os_device_info
));
819 /* Get the underlying OS device */
820 status
= HIFConfigureDevice(ar
->arHifDevice
,
821 HIF_DEVICE_GET_OS_DEVICE
,
823 sizeof(struct hif_device_os_device_info
));
826 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI: Failed to get OS device info from HIF\n"));
830 /* Create a bmi entry in the sysfs filesystem */
831 if ((sysfs_create_bin_file(&(((struct device
*)ar
->osDevInfo
.pOSDevice
)->kobj
), &bmi_attr
)) < 0)
833 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMI: Failed to create entry for bmi in sysfs filesystem\n"));
841 ar6000_sysfs_bmi_deinit(struct ar6_softc
*ar
)
843 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Deleting sysfs entry\n"));
845 sysfs_remove_bin_file(&(((struct device
*)ar
->osDevInfo
.pOSDevice
)->kobj
), &bmi_attr
);
848 #define bmifn(fn) do { \
850 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__)); \
855 #ifdef SOFTMAC_FILE_USED
856 #define AR6002_MAC_ADDRESS_OFFSET 0x0A
857 #define AR6003_MAC_ADDRESS_OFFSET 0x16
859 void calculate_crc(u32 TargetType
, u8
*eeprom_data
)
867 if (TargetType
== TARGET_TYPE_AR6001
)
870 ptr_crc
= (u16
*)eeprom_data
;
872 else if (TargetType
== TARGET_TYPE_AR6003
)
875 ptr_crc
= (u16
*)((u8
*)eeprom_data
+ 0x04);
880 ptr_crc
= (u16
*)((u8
*)eeprom_data
+ 0x04);
887 // Recalculate new CRC
889 ptr16_eeprom
= (u16
*)eeprom_data
;
890 for (i
= 0;i
< eeprom_size
; i
+= 2)
892 checksum
= checksum
^ (*ptr16_eeprom
);
895 checksum
= 0xFFFF ^ checksum
;
900 ar6000_softmac_update(struct ar6_softc
*ar
, u8
*eeprom_data
, size_t size
)
902 const char *source
= "random generated";
903 const struct firmware
*softmac_entry
;
905 switch (ar
->arTargetType
) {
906 case TARGET_TYPE_AR6002
:
907 ptr_mac
= (u8
*)((u8
*)eeprom_data
+ AR6002_MAC_ADDRESS_OFFSET
);
909 case TARGET_TYPE_AR6003
:
910 ptr_mac
= (u8
*)((u8
*)eeprom_data
+ AR6003_MAC_ADDRESS_OFFSET
);
913 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Invalid Target Type\n"));
916 printk(KERN_DEBUG
"MAC from EEPROM %pM\n", ptr_mac
);
918 /* create a random MAC in case we cannot read file from system */
922 ptr_mac
[3] = random32() & 0xff;
923 ptr_mac
[4] = random32() & 0xff;
924 ptr_mac
[5] = random32() & 0xff;
925 if ((A_REQUEST_FIRMWARE(&softmac_entry
, "softmac", ((struct device
*)ar
->osDevInfo
.pOSDevice
))) == 0)
927 char *macbuf
= A_MALLOC_NOWAIT(softmac_entry
->size
+1);
929 unsigned int softmac
[6];
930 memcpy(macbuf
, softmac_entry
->data
, softmac_entry
->size
);
931 macbuf
[softmac_entry
->size
] = '\0';
932 if (sscanf(macbuf
, "%02x:%02x:%02x:%02x:%02x:%02x",
933 &softmac
[0], &softmac
[1], &softmac
[2],
934 &softmac
[3], &softmac
[4], &softmac
[5])==6) {
936 for (i
=0; i
<6; ++i
) {
937 ptr_mac
[i
] = softmac
[i
] & 0xff;
939 source
= "softmac file";
943 A_RELEASE_FIRMWARE(softmac_entry
);
945 printk(KERN_DEBUG
"MAC from %s %pM\n", source
, ptr_mac
);
946 calculate_crc(ar
->arTargetType
, eeprom_data
);
948 #endif /* SOFTMAC_FILE_USED */
951 ar6000_transfer_bin_file(struct ar6_softc
*ar
, AR6K_BIN_FILE file
, u32 address
, bool compressed
)
954 const char *filename
;
955 const struct firmware
*fw_entry
;
963 buf_len
= &ar
->fw_otp_len
;
964 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
965 filename
= AR6003_REV1_OTP_FILE
;
966 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
967 filename
= AR6003_REV2_OTP_FILE
;
968 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
969 filename
= AR6003_REV3_OTP_FILE
;
971 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
976 case AR6K_FIRMWARE_FILE
:
978 buf_len
= &ar
->fw_len
;
979 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
980 filename
= AR6003_REV1_FIRMWARE_FILE
;
981 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
982 filename
= AR6003_REV2_FIRMWARE_FILE
;
983 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
984 filename
= AR6003_REV3_FIRMWARE_FILE
;
986 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
992 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
993 filename
= AR6003_REV1_EPPING_FIRMWARE_FILE
;
994 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
995 filename
= AR6003_REV2_EPPING_FIRMWARE_FILE
;
996 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
997 filename
= AR6003_REV3_EPPING_FIRMWARE_FILE
;
999 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("eppingtest : unsupported firmware revision: %d\n",
1000 ar
->arVersion
.target_ver
));
1006 #ifdef CONFIG_HOST_TCMD_SUPPORT
1008 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1009 filename
= AR6003_REV1_TCMD_FIRMWARE_FILE
;
1010 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1011 filename
= AR6003_REV2_TCMD_FIRMWARE_FILE
;
1012 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
1013 filename
= AR6003_REV3_TCMD_FIRMWARE_FILE
;
1015 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1021 #ifdef HTC_RAW_INTERFACE
1022 if (!eppingtest
&& bypasswmi
) {
1023 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1024 filename
= AR6003_REV1_ART_FIRMWARE_FILE
;
1025 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1026 filename
= AR6003_REV2_ART_FIRMWARE_FILE
;
1028 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1036 case AR6K_PATCH_FILE
:
1037 buf
= &ar
->fw_patch
;
1038 buf_len
= &ar
->fw_patch_len
;
1039 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1040 filename
= AR6003_REV1_PATCH_FILE
;
1041 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1042 filename
= AR6003_REV2_PATCH_FILE
;
1043 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
1044 filename
= AR6003_REV3_PATCH_FILE
;
1046 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1051 case AR6K_BOARD_DATA_FILE
:
1053 buf_len
= &ar
->fw_data_len
;
1054 if (ar
->arVersion
.target_ver
== AR6003_REV1_VERSION
) {
1055 filename
= AR6003_REV1_BOARD_DATA_FILE
;
1056 } else if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1057 filename
= AR6003_REV2_BOARD_DATA_FILE
;
1058 } else if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
) {
1059 filename
= AR6003_REV3_BOARD_DATA_FILE
;
1061 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown firmware revision: %d\n", ar
->arVersion
.target_ver
));
1067 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Unknown file type: %d\n", file
));
1072 if ((A_REQUEST_FIRMWARE(&fw_entry
, filename
, ((struct device
*)ar
->osDevInfo
.pOSDevice
))) != 0) {
1073 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Failed to get %s\n", filename
));
1077 *buf
= kmemdup(fw_entry
->data
, fw_entry
->size
, GFP_KERNEL
);
1078 *buf_len
= fw_entry
->size
;
1079 A_RELEASE_FIRMWARE(fw_entry
);
1082 #ifdef SOFTMAC_FILE_USED
1083 if (file
==AR6K_BOARD_DATA_FILE
&& *buf_len
) {
1084 ar6000_softmac_update(ar
, *buf
, *buf_len
);
1089 fw_entry_size
= *buf_len
;
1091 /* Load extended board data for AR6003 */
1092 if ((file
==AR6K_BOARD_DATA_FILE
) && *buf
) {
1093 u32 board_ext_address
;
1094 u32 board_ext_data_size
;
1095 u32 board_data_size
;
1097 board_ext_data_size
= (((ar
)->arTargetType
== TARGET_TYPE_AR6002
) ? AR6002_BOARD_EXT_DATA_SZ
: \
1098 (((ar
)->arTargetType
== TARGET_TYPE_AR6003
) ? AR6003_BOARD_EXT_DATA_SZ
: 0));
1100 board_data_size
= (((ar
)->arTargetType
== TARGET_TYPE_AR6002
) ? AR6002_BOARD_DATA_SZ
: \
1101 (((ar
)->arTargetType
== TARGET_TYPE_AR6003
) ? AR6003_BOARD_DATA_SZ
: 0));
1103 /* Determine where in Target RAM to write Board Data */
1104 bmifn(BMIReadMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_ext_data
), (u8
*)&board_ext_address
, 4));
1105 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("Board extended Data download address: 0x%x\n", board_ext_address
));
1107 /* check whether the target has allocated memory for extended board data and file contains extended board data */
1108 if ((board_ext_address
) && (*buf_len
== (board_data_size
+ board_ext_data_size
))) {
1111 status
= BMIWriteMemory(ar
->arHifDevice
, board_ext_address
, (u8
*)(*buf
+ board_data_size
), board_ext_data_size
);
1114 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI operation failed: %d\n", __LINE__
));
1118 /* Record the fact that extended board Data IS initialized */
1119 param
= (board_ext_data_size
<< 16) | 1;
1120 bmifn(BMIWriteMemory(ar
->arHifDevice
,
1121 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_ext_data_config
),
1122 (unsigned char *)¶m
, 4));
1124 fw_entry_size
= board_data_size
;
1128 status
= BMIFastDownload(ar
->arHifDevice
, address
, *buf
, fw_entry_size
);
1130 status
= BMIWriteMemory(ar
->arHifDevice
, address
, *buf
, fw_entry_size
);
1134 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI operation failed: %d\n", __LINE__
));
1142 ar6000_update_bdaddr(struct ar6_softc
*ar
)
1145 if (setupbtdev
!= 0) {
1148 if (BMIReadMemory(ar
->arHifDevice
,
1149 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_data
), (u8
*)&address
, 4) != 0)
1151 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for hi_board_data failed\n"));
1155 if (BMIReadMemory(ar
->arHifDevice
, address
+ BDATA_BDADDR_OFFSET
, (u8
*)ar
->bdaddr
, 6) != 0)
1157 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for BD address failed\n"));
1160 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BDADDR 0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", ar
->bdaddr
[0],
1161 ar
->bdaddr
[1], ar
->bdaddr
[2], ar
->bdaddr
[3],
1162 ar
->bdaddr
[4], ar
->bdaddr
[5]));
1169 ar6000_sysfs_bmi_get_config(struct ar6_softc
*ar
, u32 mode
)
1171 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("BMI: Requesting device specific configuration\n"));
1173 if (mode
== WLAN_INIT_MODE_UDEV
) {
1175 const struct firmware
*fw_entry
;
1177 /* Get config using udev through a script in user space */
1178 sprintf(version
, "%2.2x", ar
->arVersion
.target_ver
);
1179 if ((A_REQUEST_FIRMWARE(&fw_entry
, version
, ((struct device
*)ar
->osDevInfo
.pOSDevice
))) != 0)
1181 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("BMI: Failure to get configuration for target version: %s\n", version
));
1185 A_RELEASE_FIRMWARE(fw_entry
);
1187 /* The config is contained within the driver itself */
1189 u32 param
, options
, sleep
, address
;
1191 /* Temporarily disable system sleep */
1192 address
= MBOX_BASE_ADDRESS
+ LOCAL_SCRATCH_ADDRESS
;
1193 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1195 param
|= AR6K_OPTION_SLEEP_DISABLE
;
1196 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1198 address
= RTC_BASE_ADDRESS
+ SYSTEM_SLEEP_ADDRESS
;
1199 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1201 param
|= WLAN_SYSTEM_SLEEP_DISABLE_SET(1);
1202 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1203 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("old options: %d, old sleep: %d\n", options
, sleep
));
1205 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1206 /* Program analog PLL register */
1207 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, ANALOG_INTF_BASE_ADDRESS
+ 0x284, 0xF9104001));
1208 /* Run at 80/88MHz by default */
1209 param
= CPU_CLOCK_STANDARD_SET(1);
1211 /* Run at 40/44MHz by default */
1212 param
= CPU_CLOCK_STANDARD_SET(0);
1214 address
= RTC_BASE_ADDRESS
+ CPU_CLOCK_ADDRESS
;
1215 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1218 if (ar
->arTargetType
== TARGET_TYPE_AR6002
) {
1219 bmifn(BMIReadMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_ext_clk_detected
), (u8
*)¶m
, 4));
1222 /* LPO_CAL.ENABLE = 1 if no external clk is detected */
1224 address
= RTC_BASE_ADDRESS
+ LPO_CAL_ADDRESS
;
1225 param
= LPO_CAL_ENABLE_SET(1);
1226 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1229 /* Venus2.0: Lower SDIO pad drive strength,
1230 * temporary WAR to avoid SDIO CRC error */
1231 if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1232 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("AR6K: Temporary WAR to avoid SDIO CRC error\n"));
1234 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN10_ADDRESS
;
1235 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1237 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN11_ADDRESS
;
1238 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1240 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN12_ADDRESS
;
1241 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1243 address
= GPIO_BASE_ADDRESS
+ GPIO_PIN13_ADDRESS
;
1244 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1247 #ifdef FORCE_INTERNAL_CLOCK
1248 /* Ignore external clock, if any, and force use of internal clock */
1249 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1250 /* hi_ext_clk_detected = 0 */
1252 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_ext_clk_detected
), (u8
*)¶m
, 4));
1254 /* CLOCK_CONTROL &= ~LF_CLK32 */
1255 address
= RTC_BASE_ADDRESS
+ CLOCK_CONTROL_ADDRESS
;
1256 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1257 param
&= (~CLOCK_CONTROL_LF_CLK32_SET(1));
1258 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1260 #endif /* FORCE_INTERNAL_CLOCK */
1262 /* Transfer Board Data from Target EEPROM to Target RAM */
1263 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1264 /* Determine where in Target RAM to write Board Data */
1265 bmifn(BMIReadMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_data
), (u8
*)&address
, 4));
1266 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("Board Data download address: 0x%x\n", address
));
1268 /* Write EEPROM data to Target RAM */
1269 if ((ar6000_transfer_bin_file(ar
, AR6K_BOARD_DATA_FILE
, address
, false)) != 0) {
1273 /* Record the fact that Board Data IS initialized */
1275 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_data_initialized
), (u8
*)¶m
, 4));
1277 /* Transfer One time Programmable data */
1278 AR6K_APP_LOAD_ADDRESS(address
, ar
->arVersion
.target_ver
);
1279 if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
)
1281 status
= ar6000_transfer_bin_file(ar
, AR6K_OTP_FILE
, address
, true);
1283 /* Execute the OTP code */
1285 AR6K_APP_START_OVERRIDE_ADDRESS(address
, ar
->arVersion
.target_ver
);
1286 bmifn(BMIExecute(ar
->arHifDevice
, address
, ¶m
));
1287 } else if (status
!= A_ENOENT
) {
1291 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Programming of board data for chip %d not supported\n", ar
->arTargetType
));
1295 /* Download Target firmware */
1296 AR6K_APP_LOAD_ADDRESS(address
, ar
->arVersion
.target_ver
);
1297 if (ar
->arVersion
.target_ver
== AR6003_REV3_VERSION
)
1299 if ((ar6000_transfer_bin_file(ar
, AR6K_FIRMWARE_FILE
, address
, true)) != 0) {
1303 /* Set starting address for firmware */
1304 AR6K_APP_START_OVERRIDE_ADDRESS(address
, ar
->arVersion
.target_ver
);
1305 bmifn(BMISetAppStart(ar
->arHifDevice
, address
));
1307 if(ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1308 AR6K_DATASET_PATCH_ADDRESS(address
, ar
->arVersion
.target_ver
);
1309 if ((ar6000_transfer_bin_file(ar
, AR6K_PATCH_FILE
,
1310 address
, false)) != 0)
1313 bmifn(BMIWriteMemory(ar
->arHifDevice
,
1314 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_dset_list_head
),
1315 (unsigned char *)¶m
, 4));
1318 /* Restore system sleep */
1319 address
= RTC_BASE_ADDRESS
+ SYSTEM_SLEEP_ADDRESS
;
1320 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, sleep
));
1322 address
= MBOX_BASE_ADDRESS
+ LOCAL_SCRATCH_ADDRESS
;
1323 param
= options
| 0x20;
1324 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1326 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1327 /* Configure GPIO AR6003 UART */
1328 #ifndef CONFIG_AR600x_DEBUG_UART_TX_PIN
1329 #define CONFIG_AR600x_DEBUG_UART_TX_PIN 8
1331 param
= CONFIG_AR600x_DEBUG_UART_TX_PIN
;
1332 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_dbg_uart_txpin
), (u8
*)¶m
, 4));
1334 #if (CONFIG_AR600x_DEBUG_UART_TX_PIN == 23)
1336 address
= GPIO_BASE_ADDRESS
+ CLOCK_GPIO_ADDRESS
;
1337 bmifn(BMIReadSOCRegister(ar
->arHifDevice
, address
, ¶m
));
1338 param
|= CLOCK_GPIO_BT_CLK_OUT_EN_SET(1);
1339 bmifn(BMIWriteSOCRegister(ar
->arHifDevice
, address
, param
));
1343 /* Configure GPIO for BT Reset */
1344 #ifdef ATH6KL_CONFIG_GPIO_BT_RESET
1345 #define CONFIG_AR600x_BT_RESET_PIN 0x16
1346 param
= CONFIG_AR600x_BT_RESET_PIN
;
1347 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_hci_uart_support_pins
), (u8
*)¶m
, 4));
1348 #endif /* ATH6KL_CONFIG_GPIO_BT_RESET */
1350 /* Configure UART flow control polarity */
1351 #ifndef CONFIG_ATH6KL_BT_UART_FC_POLARITY
1352 #define CONFIG_ATH6KL_BT_UART_FC_POLARITY 0
1355 #if (CONFIG_ATH6KL_BT_UART_FC_POLARITY == 1)
1356 if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1357 param
= ((CONFIG_ATH6KL_BT_UART_FC_POLARITY
<< 1) & 0x2);
1358 bmifn(BMIWriteMemory(ar
->arHifDevice
, HOST_INTEREST_ITEM_ADDRESS(ar
, hi_hci_uart_pwr_mgmt_params
), (u8
*)¶m
, 4));
1360 #endif /* CONFIG_ATH6KL_BT_UART_FC_POLARITY */
1363 #ifdef HTC_RAW_INTERFACE
1364 if (!eppingtest
&& bypasswmi
) {
1365 /* Don't run BMIDone for ART mode and force resetok=0 */
1369 #endif /* HTC_RAW_INTERFACE */
1376 ar6000_configure_target(struct ar6_softc
*ar
)
1379 if (enableuartprint
) {
1381 if (BMIWriteMemory(ar
->arHifDevice
,
1382 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_serial_enable
),
1386 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for enableuartprint failed \n"));
1389 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Serial console prints enabled\n"));
1392 /* Tell target which HTC version it is used*/
1393 param
= HTC_PROTOCOL_VERSION
;
1394 if (BMIWriteMemory(ar
->arHifDevice
,
1395 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_app_host_interest
),
1399 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for htc version failed \n"));
1403 #ifdef CONFIG_HOST_TCMD_SUPPORT
1405 ar
->arTargetMode
= AR6000_TCMD_MODE
;
1407 ar
->arTargetMode
= AR6000_WLAN_MODE
;
1410 if (enabletimerwar
) {
1413 if (BMIReadMemory(ar
->arHifDevice
,
1414 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1418 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for enabletimerwar failed \n"));
1422 param
|= HI_OPTION_TIMER_WAR
;
1424 if (BMIWriteMemory(ar
->arHifDevice
,
1425 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1429 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for enabletimerwar failed \n"));
1432 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Timer WAR enabled\n"));
1435 /* set the firmware mode to STA/IBSS/AP */
1439 if (BMIReadMemory(ar
->arHifDevice
,
1440 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1444 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for setting fwmode failed \n"));
1448 param
|= (num_device
<< HI_OPTION_NUM_DEV_SHIFT
);
1449 param
|= (fwmode
<< HI_OPTION_FW_MODE_SHIFT
);
1450 param
|= (mac_addr_method
<< HI_OPTION_MAC_ADDR_METHOD_SHIFT
);
1451 param
|= (firmware_bridge
<< HI_OPTION_FW_BRIDGE_SHIFT
);
1454 if (BMIWriteMemory(ar
->arHifDevice
,
1455 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1459 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for setting fwmode failed \n"));
1462 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Firmware mode set\n"));
1465 #ifdef ATH6KL_DISABLE_TARGET_DBGLOGS
1469 if (BMIReadMemory(ar
->arHifDevice
,
1470 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1474 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIReadMemory for disabling debug logs failed\n"));
1478 param
|= HI_OPTION_DISABLE_DBGLOG
;
1480 if (BMIWriteMemory(ar
->arHifDevice
,
1481 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_option_flag
),
1485 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BMIWriteMemory for HI_OPTION_DISABLE_DBGLOG\n"));
1488 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("Firmware mode set\n"));
1490 #endif /* ATH6KL_DISABLE_TARGET_DBGLOGS */
1493 * Hardcode the address use for the extended board data
1494 * Ideally this should be pre-allocate by the OS at boot time
1495 * But since it is a new feature and board data is loaded
1496 * at init time, we have to workaround this from host.
1497 * It is difficult to patch the firmware boot code,
1498 * but possible in theory.
1501 if (ar
->arTargetType
== TARGET_TYPE_AR6003
) {
1503 if (ar
->arVersion
.target_ver
== AR6003_REV2_VERSION
) {
1504 param
= AR6003_REV2_BOARD_EXT_DATA_ADDRESS
;
1505 ramReservedSz
= AR6003_REV2_RAM_RESERVE_SIZE
;
1507 param
= AR6003_REV3_BOARD_EXT_DATA_ADDRESS
;
1508 ramReservedSz
= AR6003_REV3_RAM_RESERVE_SIZE
;
1510 if (BMIWriteMemory(ar
->arHifDevice
,
1511 HOST_INTEREST_ITEM_ADDRESS(ar
, hi_board_ext_data
),
1512 (u8
*)¶m
, 4) != 0) {
1513 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
1514 ("BMIWriteMemory for "
1515 "hi_board_ext_data failed\n"));
1518 if (BMIWriteMemory(ar
->arHifDevice
,
1519 HOST_INTEREST_ITEM_ADDRESS(ar
,
1520 hi_end_RAM_reserve_sz
),
1521 (u8
*)&ramReservedSz
, 4) != 0) {
1522 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
1523 ("BMIWriteMemory for "
1524 "hi_end_RAM_reserve_sz failed\n"));
1529 /* since BMIInit is called in the driver layer, we have to set the block
1530 * size here for the target */
1532 if (ar6000_set_htc_params(ar
->arHifDevice
, ar
->arTargetType
,
1533 mbox_yield_limit
, 0)) {
1534 /* use default number of control buffers */
1538 if (setupbtdev
!= 0) {
1539 if (ar6000_set_hci_bridge_flags(ar
->arHifDevice
,
1549 init_netdev(struct net_device
*dev
, char *name
)
1551 dev
->netdev_ops
= &ar6000_netdev_ops
;
1552 dev
->watchdog_timeo
= AR6000_TX_TIMEOUT
;
1555 * We need the OS to provide us with more headroom in order to
1556 * perform dix to 802.3, WMI header encap, and the HTC header
1558 if (processDot11Hdr
) {
1559 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
;
1561 dev
->hard_header_len
= ETH_HLEN
+ sizeof(ATH_LLC_SNAP_HDR
) +
1562 sizeof(WMI_DATA_HDR
) + HTC_HEADER_LEN
+ WMI_MAX_TX_META_SZ
+ LINUX_HACK_FUDGE_FACTOR
;
1567 strcpy(dev
->name
, name
);
1570 #ifdef CONFIG_CHECKSUM_OFFLOAD
1572 dev
->features
|= NETIF_F_IP_CSUM
; /*advertise kernel capability to do TCP/UDP CSUM offload for IPV4*/
1579 static int __ath6kl_init_netdev(struct net_device
*dev
)
1584 r
= ar6000_init(dev
);
1588 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_avail: ar6000_init\n"));
1595 #ifdef HTC_RAW_INTERFACE
1596 static int ath6kl_init_netdev_wmi(struct net_device
*dev
)
1598 if (!eppingtest
&& bypasswmi
)
1601 return __ath6kl_init_netdev(dev
);
1604 static int ath6kl_init_netdev_wmi(struct net_device
*dev
)
1606 return __ath6kl_init_netdev(dev
);
1610 static int ath6kl_init_netdev(struct ar6_softc
*ar
)
1614 r
= ar6000_sysfs_bmi_get_config(ar
, wlaninitmode
);
1616 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
1618 "ar6000_sysfs_bmi_get_config failed\n"));
1622 return ath6kl_init_netdev_wmi(ar
->arNetDev
);
1626 * HTC Event handlers
1629 ar6000_avail_ev(void *context
, void *hif_handle
)
1632 struct net_device
*dev
;
1634 struct ar6_softc
*ar
;
1635 int device_index
= 0;
1636 struct htc_init_info htcInfo
;
1637 struct wireless_dev
*wdev
;
1639 struct hif_device_os_device_info osDevInfo
;
1641 memset(&osDevInfo
, 0, sizeof(osDevInfo
));
1642 if (HIFConfigureDevice(hif_handle
, HIF_DEVICE_GET_OS_DEVICE
,
1643 &osDevInfo
, sizeof(osDevInfo
))) {
1644 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s: Failed to get OS device instance\n", __func__
));
1648 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("ar6000_available\n"));
1650 for (i
=0; i
< MAX_AR6000
; i
++) {
1651 if (ar6000_devices
[i
] == NULL
) {
1656 if (i
== MAX_AR6000
) {
1657 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_available: max devices reached\n"));
1661 /* Save this. It gives a bit better readability especially since */
1662 /* we use another local "i" variable below. */
1665 wdev
= ar6k_cfg80211_init(osDevInfo
.pOSDevice
);
1667 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("%s: ar6k_cfg80211_init failed\n", __func__
));
1670 ar_netif
= wdev_priv(wdev
);
1672 if (ar_netif
== NULL
) {
1673 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("%s: Can't allocate ar6k priv memory\n", __func__
));
1677 A_MEMZERO(ar_netif
, sizeof(struct ar6_softc
));
1678 ar
= (struct ar6_softc
*)ar_netif
;
1681 wdev
->iftype
= NL80211_IFTYPE_STATION
;
1683 dev
= alloc_netdev_mq(0, "wlan%d", ether_setup
, 1);
1685 printk(KERN_CRIT
"AR6K: no memory for network device instance\n");
1686 ar6k_cfg80211_deinit(ar
);
1690 dev
->ieee80211_ptr
= wdev
;
1691 SET_NETDEV_DEV(dev
, wiphy_dev(wdev
->wiphy
));
1693 ar
->arNetworkType
= INFRA_NETWORK
;
1694 ar
->smeState
= SME_DISCONNECTED
;
1695 ar
->arAutoAuthStage
= AUTH_IDLE
;
1697 init_netdev(dev
, ifname
);
1701 ar
->arHifDevice
= hif_handle
;
1702 ar
->arWlanState
= WLAN_ENABLED
;
1703 ar
->arDeviceIndex
= device_index
;
1705 ar
->arWlanPowerState
= WLAN_POWER_STATE_ON
;
1706 ar
->arWlanOff
= false; /* We are in ON state */
1708 ar
->arWowState
= WLAN_WOW_STATE_NONE
;
1709 ar
->arBTOff
= true; /* BT chip assumed to be OFF */
1710 ar
->arBTSharing
= WLAN_CONFIG_BT_SHARING
;
1711 ar
->arWlanOffConfig
= WLAN_CONFIG_WLAN_OFF
;
1712 ar
->arSuspendConfig
= WLAN_CONFIG_PM_SUSPEND
;
1713 ar
->arWow2Config
= WLAN_CONFIG_PM_WOW2
;
1714 #endif /* CONFIG_PM */
1716 A_INIT_TIMER(&ar
->arHBChallengeResp
.timer
, ar6000_detect_error
, dev
);
1717 ar
->arHBChallengeResp
.seqNum
= 0;
1718 ar
->arHBChallengeResp
.outstanding
= false;
1719 ar
->arHBChallengeResp
.missCnt
= 0;
1720 ar
->arHBChallengeResp
.frequency
= AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT
;
1721 ar
->arHBChallengeResp
.missThres
= AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT
;
1723 ar6000_init_control_info(ar
);
1724 init_waitqueue_head(&arEvent
);
1725 sema_init(&ar
->arSem
, 1);
1726 ar
->bIsDestroyProgress
= false;
1728 INIT_HTC_PACKET_QUEUE(&ar
->amsdu_rx_buffer_queue
);
1730 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
1731 A_INIT_TIMER(&aptcTimer
, aptcTimerHandler
, ar
);
1732 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
1734 A_INIT_TIMER(&ar
->disconnect_timer
, disconnect_timer_handler
, dev
);
1738 ar6000_sysfs_bmi_init(ar
);
1741 struct bmi_target_info targ_info
;
1743 r
= BMIGetTargetInfo(ar
->arHifDevice
, &targ_info
);
1745 goto avail_ev_failed
;
1747 ar
->arVersion
.target_ver
= targ_info
.target_ver
;
1748 ar
->arTargetType
= targ_info
.target_type
;
1749 wdev
->wiphy
->hw_version
= targ_info
.target_ver
;
1752 r
= ar6000_configure_target(ar
);
1754 goto avail_ev_failed
;
1756 A_MEMZERO(&htcInfo
,sizeof(htcInfo
));
1757 htcInfo
.pContext
= ar
;
1758 htcInfo
.TargetFailure
= ar6000_target_failure
;
1760 ar
->arHtcTarget
= HTCCreate(ar
->arHifDevice
,&htcInfo
);
1762 if (!ar
->arHtcTarget
) {
1764 goto avail_ev_failed
;
1767 spin_lock_init(&ar
->arLock
);
1770 ar
->arWapiEnable
= 0;
1775 /*if external frame work is also needed, change and use an extended rxMetaVerion*/
1776 ar
->rxMetaVersion
=WMI_META_VERSION_2
;
1779 ar
->aggr_cntxt
= aggr_init(ar6000_alloc_netbufs
);
1780 if (!ar
->aggr_cntxt
) {
1781 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() Failed to initialize aggr.\n", __func__
));
1783 goto avail_ev_failed
;
1786 aggr_register_rx_dispatcher(ar
->aggr_cntxt
, (void *)dev
, ar6000_deliver_frames_to_nw_stack
);
1788 HIFClaimDevice(ar
->arHifDevice
, ar
);
1790 /* We only register the device in the global list if we succeed. */
1791 /* If the device is in the global list, it will be destroyed */
1792 /* when the module is unloaded. */
1793 ar6000_devices
[device_index
] = dev
;
1795 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("BMI enabled: %d\n", wlaninitmode
));
1796 if ((wlaninitmode
== WLAN_INIT_MODE_UDEV
) ||
1797 (wlaninitmode
== WLAN_INIT_MODE_DRV
)) {
1798 r
= ath6kl_init_netdev(ar
);
1800 goto avail_ev_failed
;
1803 /* This runs the init function if registered */
1804 r
= register_netdev(dev
);
1806 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_avail: register_netdev failed\n"));
1807 ar6000_destroy(dev
, 0);
1811 is_netdev_registered
= 1;
1813 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
1815 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
1816 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("ar6000_avail: name=%s hifdevice=0x%lx, dev=0x%lx (%d), ar=0x%lx\n",
1817 dev
->name
, (unsigned long)ar
->arHifDevice
, (unsigned long)dev
, device_index
,
1818 (unsigned long)ar
));
1822 ar6000_sysfs_bmi_deinit(ar
);
1827 static void ar6000_target_failure(void *Instance
, int Status
)
1829 struct ar6_softc
*ar
= (struct ar6_softc
*)Instance
;
1830 WMI_TARGET_ERROR_REPORT_EVENT errEvent
;
1831 static bool sip
= false;
1835 printk(KERN_ERR
"ar6000_target_failure: target asserted \n");
1837 if (timer_pending(&ar
->arHBChallengeResp
.timer
)) {
1838 A_UNTIMEOUT(&ar
->arHBChallengeResp
.timer
);
1841 /* try dumping target assertion information (if any) */
1842 ar6000_dump_target_assert_info(ar
->arHifDevice
,ar
->arTargetType
);
1845 * Fetch the logs from the target via the diagnostic
1848 ar6000_dbglog_get_debug_logs(ar
);
1850 /* Report the error only once */
1853 errEvent
.errorVal
= WMI_TARGET_COM_ERR
|
1854 WMI_TARGET_FATAL_ERR
;
1860 ar6000_unavail_ev(void *context
, void *hif_handle
)
1862 struct ar6_softc
*ar
= (struct ar6_softc
*)context
;
1863 /* NULL out it's entry in the global list */
1864 ar6000_devices
[ar
->arDeviceIndex
] = NULL
;
1865 ar6000_destroy(ar
->arNetDev
, 1);
1871 ar6000_restart_endpoint(struct net_device
*dev
)
1874 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
1878 if ( (status
=ar6000_configure_target(ar
))!= 0)
1880 if ( (status
=ar6000_sysfs_bmi_get_config(ar
, wlaninitmode
)) != 0)
1882 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n"));
1886 status
= (ar6000_init(dev
)==0) ? 0 : A_ERROR
;
1892 if (ar
->arSsidLen
&& ar
->arWlanState
== WLAN_ENABLED
) {
1893 ar6000_connect_to_ap(ar
);
1901 ar6000_devices
[ar
->arDeviceIndex
] = NULL
;
1902 ar6000_destroy(ar
->arNetDev
, 1);
1906 ar6000_stop_endpoint(struct net_device
*dev
, bool keepprofile
, bool getdbglogs
)
1908 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
1910 /* Stop the transmit queues */
1911 netif_stop_queue(dev
);
1913 /* Disable the target and the interrupts associated with it */
1914 if (ar
->arWmiReady
== true)
1918 bool disconnectIssued
;
1920 disconnectIssued
= (ar
->arConnected
) || (ar
->arConnectPending
);
1921 ar6000_disconnect(ar
);
1923 ar6000_init_profile_info(ar
);
1926 A_UNTIMEOUT(&ar
->disconnect_timer
);
1929 ar6000_dbglog_get_debug_logs(ar
);
1932 ar
->arWmiReady
= false;
1933 wmi_shutdown(ar
->arWmi
);
1934 ar
->arWmiEnabled
= false;
1937 * After wmi_shudown all WMI events will be dropped.
1938 * We need to cleanup the buffers allocated in AP mode
1939 * and give disconnect notification to stack, which usually
1940 * happens in the disconnect_event.
1941 * Simulate the disconnect_event by calling the function directly.
1942 * Sometimes disconnect_event will be received when the debug logs
1945 if (disconnectIssued
) {
1946 if(ar
->arNetworkType
& AP_NETWORK
) {
1947 ar6000_disconnect_event(ar
, DISCONNECT_CMD
, bcast_mac
, 0, NULL
, 0);
1949 ar6000_disconnect_event(ar
, DISCONNECT_CMD
, ar
->arBssid
, 0, NULL
, 0);
1952 ar
->user_savedkeys_stat
= USER_SAVEDKEYS_STAT_INIT
;
1953 ar
->user_key_ctrl
= 0;
1956 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("%s(): WMI stopped\n", __func__
));
1960 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("%s(): WMI not ready 0x%lx 0x%lx\n",
1961 __func__
, (unsigned long) ar
, (unsigned long) ar
->arWmi
));
1963 /* Shut down WMI if we have started it */
1964 if(ar
->arWmiEnabled
== true)
1966 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("%s(): Shut down WMI\n", __func__
));
1967 wmi_shutdown(ar
->arWmi
);
1968 ar
->arWmiEnabled
= false;
1973 if (ar
->arHtcTarget
!= NULL
) {
1974 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
1975 if (NULL
!= ar6kHciTransCallbacks
.cleanupTransport
) {
1976 ar6kHciTransCallbacks
.cleanupTransport(NULL
);
1979 // FIXME: workaround to reset BT's UART baud rate to default
1980 if (NULL
!= ar
->exitCallback
) {
1981 struct ar3k_config_info ar3kconfig
;
1984 A_MEMZERO(&ar3kconfig
,sizeof(ar3kconfig
));
1985 ar6000_set_default_ar3kconfig(ar
, (void *)&ar3kconfig
);
1986 status
= ar
->exitCallback(&ar3kconfig
);
1988 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Failed to reset AR3K baud rate! \n"));
1993 ar6000_cleanup_hci(ar
);
1995 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,(" Shutting down HTC .... \n"));
1997 HTCStop(ar
->arHtcTarget
);
2001 /* try to reset the device if we can
2002 * The driver may have been configure NOT to reset the target during
2003 * a debug session */
2004 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,(" Attempting to reset target on instance destroy.... \n"));
2005 if (ar
->arHifDevice
!= NULL
) {
2006 bool coldReset
= (ar
->arTargetType
== TARGET_TYPE_AR6003
) ? true: false;
2007 ar6000_reset_device(ar
->arHifDevice
, ar
->arTargetType
, true, coldReset
);
2010 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,(" Host does not want target reset. \n"));
2012 /* Done with cookies */
2013 ar6000_cookie_cleanup(ar
);
2015 /* cleanup any allocated AMSDU buffers */
2016 ar6000_cleanup_amsdu_rxbufs(ar
);
2019 * We need to differentiate between the surprise and planned removal of the
2020 * device because of the following consideration:
2021 * - In case of surprise removal, the hcd already frees up the pending
2022 * for the device and hence there is no need to unregister the function
2023 * driver inorder to get these requests. For planned removal, the function
2024 * driver has to explicitly unregister itself to have the hcd return all the
2025 * pending requests before the data structures for the devices are freed up.
2026 * Note that as per the current implementation, the function driver will
2027 * end up releasing all the devices since there is no API to selectively
2028 * release a particular device.
2029 * - Certain commands issued to the target can be skipped for surprise
2030 * removal since they will anyway not go through.
2033 ar6000_destroy(struct net_device
*dev
, unsigned int unregister
)
2035 struct ar6_softc
*ar
;
2037 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("+ar6000_destroy \n"));
2039 if((dev
== NULL
) || ((ar
= ar6k_priv(dev
)) == NULL
))
2041 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s(): Failed to get device structure.\n", __func__
));
2045 ar
->bIsDestroyProgress
= true;
2047 if (down_interruptible(&ar
->arSem
)) {
2048 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s(): down_interruptible failed \n", __func__
));
2052 if (ar
->arWlanPowerState
!= WLAN_POWER_STATE_CUT_PWR
) {
2053 /* only stop endpoint if we are not stop it in suspend_ev */
2054 ar6000_stop_endpoint(dev
, false, true);
2057 ar
->arWlanState
= WLAN_DISABLED
;
2058 if (ar
->arHtcTarget
!= NULL
) {
2060 HTCDestroy(ar
->arHtcTarget
);
2062 if (ar
->arHifDevice
!= NULL
) {
2063 /*release the device so we do not get called back on remove incase we
2064 * we're explicity destroyed by module unload */
2065 HIFReleaseDevice(ar
->arHifDevice
);
2066 HIFShutDownDevice(ar
->arHifDevice
);
2068 aggr_module_destroy(ar
->aggr_cntxt
);
2070 /* Done with cookies */
2071 ar6000_cookie_cleanup(ar
);
2073 /* cleanup any allocated AMSDU buffers */
2074 ar6000_cleanup_amsdu_rxbufs(ar
);
2076 ar6000_sysfs_bmi_deinit(ar
);
2081 /* Clear the tx counters */
2082 memset(tx_attempt
, 0, sizeof(tx_attempt
));
2083 memset(tx_post
, 0, sizeof(tx_post
));
2084 memset(tx_complete
, 0, sizeof(tx_complete
));
2086 #ifdef HTC_RAW_INTERFACE
2088 kfree(ar
->arRawHtc
);
2089 ar
->arRawHtc
= NULL
;
2092 /* Free up the device data structure */
2093 if (unregister
&& is_netdev_registered
) {
2094 unregister_netdev(dev
);
2095 is_netdev_registered
= 0;
2099 ar6k_cfg80211_deinit(ar
);
2101 #ifdef CONFIG_AP_VIRTUL_ADAPTER_SUPPORT
2102 ar6000_remove_ap_interface();
2103 #endif /*CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
2107 kfree(ar
->fw_patch
);
2110 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("-ar6000_destroy \n"));
2113 static void disconnect_timer_handler(unsigned long ptr
)
2115 struct net_device
*dev
= (struct net_device
*)ptr
;
2116 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2118 A_UNTIMEOUT(&ar
->disconnect_timer
);
2120 ar6000_init_profile_info(ar
);
2121 ar6000_disconnect(ar
);
2124 static void ar6000_detect_error(unsigned long ptr
)
2126 struct net_device
*dev
= (struct net_device
*)ptr
;
2127 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2128 WMI_TARGET_ERROR_REPORT_EVENT errEvent
;
2130 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
2132 if (ar
->arHBChallengeResp
.outstanding
) {
2133 ar
->arHBChallengeResp
.missCnt
++;
2135 ar
->arHBChallengeResp
.missCnt
= 0;
2138 if (ar
->arHBChallengeResp
.missCnt
> ar
->arHBChallengeResp
.missThres
) {
2139 /* Send Error Detect event to the application layer and do not reschedule the error detection module timer */
2140 ar
->arHBChallengeResp
.missCnt
= 0;
2141 ar
->arHBChallengeResp
.seqNum
= 0;
2142 errEvent
.errorVal
= WMI_TARGET_COM_ERR
| WMI_TARGET_FATAL_ERR
;
2143 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
2147 /* Generate the sequence number for the next challenge */
2148 ar
->arHBChallengeResp
.seqNum
++;
2149 ar
->arHBChallengeResp
.outstanding
= true;
2151 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
2153 /* Send the challenge on the control channel */
2154 if (wmi_get_challenge_resp_cmd(ar
->arWmi
, ar
->arHBChallengeResp
.seqNum
, DRV_HB_CHALLENGE
) != 0) {
2155 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to send heart beat challenge\n"));
2159 /* Reschedule the timer for the next challenge */
2160 A_TIMEOUT_MS(&ar
->arHBChallengeResp
.timer
, ar
->arHBChallengeResp
.frequency
* 1000, 0);
2163 void ar6000_init_profile_info(struct ar6_softc
*ar
)
2166 A_MEMZERO(ar
->arSsid
, sizeof(ar
->arSsid
));
2169 case HI_OPTION_FW_MODE_IBSS
:
2170 ar
->arNetworkType
= ar
->arNextMode
= ADHOC_NETWORK
;
2172 case HI_OPTION_FW_MODE_BSS_STA
:
2173 ar
->arNetworkType
= ar
->arNextMode
= INFRA_NETWORK
;
2175 case HI_OPTION_FW_MODE_AP
:
2176 ar
->arNetworkType
= ar
->arNextMode
= AP_NETWORK
;
2180 ar
->arDot11AuthMode
= OPEN_AUTH
;
2181 ar
->arAuthMode
= NONE_AUTH
;
2182 ar
->arPairwiseCrypto
= NONE_CRYPT
;
2183 ar
->arPairwiseCryptoLen
= 0;
2184 ar
->arGroupCrypto
= NONE_CRYPT
;
2185 ar
->arGroupCryptoLen
= 0;
2186 A_MEMZERO(ar
->arWepKeyList
, sizeof(ar
->arWepKeyList
));
2187 A_MEMZERO(ar
->arReqBssid
, sizeof(ar
->arReqBssid
));
2188 A_MEMZERO(ar
->arBssid
, sizeof(ar
->arBssid
));
2189 ar
->arBssChannel
= 0;
2193 ar6000_init_control_info(struct ar6_softc
*ar
)
2195 ar
->arWmiEnabled
= false;
2196 ar6000_init_profile_info(ar
);
2197 ar
->arDefTxKeyIndex
= 0;
2198 A_MEMZERO(ar
->arWepKeyList
, sizeof(ar
->arWepKeyList
));
2199 ar
->arChannelHint
= 0;
2200 ar
->arListenIntervalT
= A_DEFAULT_LISTEN_INTERVAL
;
2201 ar
->arListenIntervalB
= 0;
2202 ar
->arVersion
.host_ver
= AR6K_SW_VERSION
;
2205 ar
->arTxPwrSet
= false;
2207 ar
->arBeaconInterval
= 0;
2209 ar
->arMaxRetries
= 0;
2210 ar
->arWmmEnabled
= true;
2212 ar
->scan_triggered
= 0;
2213 A_MEMZERO(&ar
->scParams
, sizeof(ar
->scParams
));
2214 ar
->scParams
.shortScanRatio
= WMI_SHORTSCANRATIO_DEFAULT
;
2215 ar
->scParams
.scanCtrlFlags
= DEFAULT_SCAN_CTRL_FLAGS
;
2217 /* Initialize the AP mode state info */
2220 A_MEMZERO((u8
*)ar
->sta_list
, AP_MAX_NUM_STA
* sizeof(sta_t
));
2222 /* init the Mutexes */
2223 A_MUTEX_INIT(&ar
->mcastpsqLock
);
2225 /* Init the PS queues */
2226 for (ctr
=0; ctr
< AP_MAX_NUM_STA
; ctr
++) {
2227 A_MUTEX_INIT(&ar
->sta_list
[ctr
].psqLock
);
2228 A_NETBUF_QUEUE_INIT(&ar
->sta_list
[ctr
].psq
);
2231 ar
->ap_profile_flag
= 0;
2232 A_NETBUF_QUEUE_INIT(&ar
->mcastpsq
);
2234 memcpy(ar
->ap_country_code
, DEF_AP_COUNTRY_CODE
, 3);
2235 ar
->ap_wmode
= DEF_AP_WMODE_G
;
2236 ar
->ap_dtim_period
= DEF_AP_DTIM
;
2237 ar
->ap_beacon_interval
= DEF_BEACON_INTERVAL
;
2242 ar6000_open(struct net_device
*dev
)
2244 unsigned long flags
;
2245 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2247 spin_lock_irqsave(&ar
->arLock
, flags
);
2249 if(ar
->arWlanState
== WLAN_DISABLED
) {
2250 ar
->arWlanState
= WLAN_ENABLED
;
2253 if( ar
->arConnected
|| bypasswmi
) {
2254 netif_carrier_on(dev
);
2255 /* Wake up the queues */
2256 netif_wake_queue(dev
);
2259 netif_carrier_off(dev
);
2261 spin_unlock_irqrestore(&ar
->arLock
, flags
);
2266 ar6000_close(struct net_device
*dev
)
2268 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2269 netif_stop_queue(dev
);
2271 ar6000_disconnect(ar
);
2273 if(ar
->arWmiReady
== true) {
2274 if (wmi_scanparams_cmd(ar
->arWmi
, 0xFFFF, 0,
2275 0, 0, 0, 0, 0, 0, 0, 0) != 0) {
2278 ar
->arWlanState
= WLAN_DISABLED
;
2280 ar6k_cfg80211_scanComplete_event(ar
, A_ECANCELED
);
2285 /* connect to a service */
2286 static int ar6000_connectservice(struct ar6_softc
*ar
,
2287 struct htc_service_connect_req
*pConnect
,
2291 struct htc_service_connect_resp response
;
2295 A_MEMZERO(&response
,sizeof(response
));
2297 status
= HTCConnectService(ar
->arHtcTarget
,
2302 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" Failed to connect to %s service status:%d \n",
2306 switch (pConnect
->ServiceID
) {
2307 case WMI_CONTROL_SVC
:
2308 if (ar
->arWmiEnabled
) {
2309 /* set control endpoint for WMI use */
2310 wmi_set_control_ep(ar
->arWmi
, response
.Endpoint
);
2312 /* save EP for fast lookup */
2313 ar
->arControlEp
= response
.Endpoint
;
2315 case WMI_DATA_BE_SVC
:
2316 arSetAc2EndpointIDMap(ar
, WMM_AC_BE
, response
.Endpoint
);
2318 case WMI_DATA_BK_SVC
:
2319 arSetAc2EndpointIDMap(ar
, WMM_AC_BK
, response
.Endpoint
);
2321 case WMI_DATA_VI_SVC
:
2322 arSetAc2EndpointIDMap(ar
, WMM_AC_VI
, response
.Endpoint
);
2324 case WMI_DATA_VO_SVC
:
2325 arSetAc2EndpointIDMap(ar
, WMM_AC_VO
, response
.Endpoint
);
2328 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ServiceID not mapped %d\n", pConnect
->ServiceID
));
2338 void ar6000_TxDataCleanup(struct ar6_softc
*ar
)
2340 /* flush all the data (non-control) streams
2341 * we only flush packets that are tagged as data, we leave any control packets that
2342 * were in the TX queues alone */
2343 HTCFlushEndpoint(ar
->arHtcTarget
,
2344 arAc2EndpointID(ar
, WMM_AC_BE
),
2346 HTCFlushEndpoint(ar
->arHtcTarget
,
2347 arAc2EndpointID(ar
, WMM_AC_BK
),
2349 HTCFlushEndpoint(ar
->arHtcTarget
,
2350 arAc2EndpointID(ar
, WMM_AC_VI
),
2352 HTCFlushEndpoint(ar
->arHtcTarget
,
2353 arAc2EndpointID(ar
, WMM_AC_VO
),
2358 ar6000_ac2_endpoint_id ( void * devt
, u8 ac
)
2360 struct ar6_softc
*ar
= (struct ar6_softc
*) devt
;
2361 return(arAc2EndpointID(ar
, ac
));
2364 u8
ar6000_endpoint_id2_ac(void * devt
, HTC_ENDPOINT_ID ep
)
2366 struct ar6_softc
*ar
= (struct ar6_softc
*) devt
;
2367 return(arEndpoint2Ac(ar
, ep
));
2370 #if defined(CONFIG_ATH6KL_ENABLE_COEXISTENCE)
2371 static int ath6kl_config_btcoex_params(struct ar6_softc
*ar
)
2374 WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD sbcb_cmd
;
2375 WMI_SET_BTCOEX_FE_ANT_CMD sbfa_cmd
;
2377 /* Configure the type of BT collocated with WLAN */
2378 memset(&sbcb_cmd
, 0, sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD
));
2379 sbcb_cmd
.btcoexCoLocatedBTdev
= ATH6KL_BT_DEV
;
2381 r
= wmi_set_btcoex_colocated_bt_dev_cmd(ar
->arWmi
, &sbcb_cmd
);
2384 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2385 ("Unable to set collocated BT type\n"));
2389 /* Configure the type of BT collocated with WLAN */
2390 memset(&sbfa_cmd
, 0, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD
));
2392 sbfa_cmd
.btcoexFeAntType
= ATH6KL_BT_ANTENNA
;
2394 r
= wmi_set_btcoex_fe_ant_cmd(ar
->arWmi
, &sbfa_cmd
);
2396 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2397 ("Unable to set fornt end antenna configuration\n"));
2404 static int ath6kl_config_btcoex_params(struct ar6_softc
*ar
)
2408 #endif /* CONFIG_ATH6KL_ENABLE_COEXISTENCE */
2411 * This function applies WLAN specific configuration defined in wlan_config.h
2413 int ar6000_target_config_wlan_params(struct ar6_softc
*ar
)
2417 #ifdef CONFIG_HOST_TCMD_SUPPORT
2418 if (ar
->arTargetMode
!= AR6000_WLAN_MODE
) {
2421 #endif /* CONFIG_HOST_TCMD_SUPPORT */
2424 * configure the device for rx dot11 header rules 0,0 are the default values
2425 * therefore this command can be skipped if the inputs are 0,FALSE,FALSE.Required
2426 * if checksum offload is needed. Set RxMetaVersion to 2
2428 if ((wmi_set_rx_frame_format_cmd(ar
->arWmi
,ar
->rxMetaVersion
, processDot11Hdr
, processDot11Hdr
)) != 0) {
2429 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set the rx frame format.\n"));
2433 status
= ath6kl_config_btcoex_params(ar
);
2437 #if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
2438 if ((wmi_pmparams_cmd(ar
->arWmi
, 0, 1, 0, 0, 1, IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
)) != 0) {
2439 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set power save fail event policy\n"));
2444 #if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP
2445 if ((wmi_set_lpreamble_cmd(ar
->arWmi
, 0, WMI_DONOT_IGNORE_BARKER_IN_ERP
)) != 0) {
2446 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set barker preamble policy\n"));
2451 if ((wmi_set_keepalive_cmd(ar
->arWmi
, WLAN_CONFIG_KEEP_ALIVE_INTERVAL
)) != 0) {
2452 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set keep alive interval\n"));
2456 #if WLAN_CONFIG_DISABLE_11N
2458 WMI_SET_HT_CAP_CMD htCap
;
2460 memset(&htCap
, 0, sizeof(WMI_SET_HT_CAP_CMD
));
2462 if ((wmi_set_ht_cap_cmd(ar
->arWmi
, &htCap
)) != 0) {
2463 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set ht capabilities \n"));
2468 if ((wmi_set_ht_cap_cmd(ar
->arWmi
, &htCap
)) != 0) {
2469 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set ht capabilities \n"));
2473 #endif /* WLAN_CONFIG_DISABLE_11N */
2475 #ifdef ATH6K_CONFIG_OTA_MODE
2476 if ((wmi_powermode_cmd(ar
->arWmi
, MAX_PERF_POWER
)) != 0) {
2477 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set power mode \n"));
2482 if ((wmi_disctimeout_cmd(ar
->arWmi
, WLAN_CONFIG_DISCONNECT_TIMEOUT
)) != 0) {
2483 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set disconnect timeout \n"));
2487 #if WLAN_CONFIG_DISABLE_TX_BURSTING
2488 if ((wmi_set_wmm_txop(ar
->arWmi
, WMI_TXOP_DISABLED
)) != 0) {
2489 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set txop bursting \n"));
2497 /* This function does one time initialization for the lifetime of the device */
2498 int ar6000_init(struct net_device
*dev
)
2500 struct ar6_softc
*ar
;
2506 if((ar
= ar6k_priv(dev
)) == NULL
)
2511 if (wlaninitmode
== WLAN_INIT_MODE_USR
|| wlaninitmode
== WLAN_INIT_MODE_DRV
) {
2513 ar6000_update_bdaddr(ar
);
2515 if (enablerssicompensation
) {
2516 ar6000_copy_cust_data_from_target(ar
->arHifDevice
, ar
->arTargetType
);
2517 read_rssi_compensation_param(ar
);
2518 for (i
=-95; i
<=0; i
++) {
2519 rssi_compensation_table
[0-i
] = rssi_compensation_calc(ar
,i
);
2527 /* Do we need to finish the BMI phase */
2528 if ((wlaninitmode
== WLAN_INIT_MODE_USR
|| wlaninitmode
== WLAN_INIT_MODE_DRV
) &&
2529 (BMIDone(ar
->arHifDevice
) != 0))
2532 goto ar6000_init_done
;
2538 if (ar
->arVersion
.host_ver
!= ar
->arVersion
.target_ver
) {
2539 A_PRINTF("WARNING: Host version 0x%x does not match Target "
2541 ar
->arVersion
.host_ver
, ar
->arVersion
.target_ver
);
2545 /* Indicate that WMI is enabled (although not ready yet) */
2546 ar
->arWmiEnabled
= true;
2547 if ((ar
->arWmi
= wmi_init((void *) ar
)) == NULL
)
2549 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() Failed to initialize WMI.\n", __func__
));
2551 goto ar6000_init_done
;
2554 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() Got WMI @ 0x%lx.\n", __func__
,
2555 (unsigned long) ar
->arWmi
));
2559 struct htc_service_connect_req connect
;
2561 /* the reason we have to wait for the target here is that the driver layer
2562 * has to init BMI in order to set the host block size,
2564 status
= HTCWaitTarget(ar
->arHtcTarget
);
2570 A_MEMZERO(&connect
,sizeof(connect
));
2571 /* meta data is unused for now */
2572 connect
.pMetaData
= NULL
;
2573 connect
.MetaDataLength
= 0;
2574 /* these fields are the same for all service endpoints */
2575 connect
.EpCallbacks
.pContext
= ar
;
2576 connect
.EpCallbacks
.EpTxCompleteMultiple
= ar6000_tx_complete
;
2577 connect
.EpCallbacks
.EpRecv
= ar6000_rx
;
2578 connect
.EpCallbacks
.EpRecvRefill
= ar6000_rx_refill
;
2579 connect
.EpCallbacks
.EpSendFull
= ar6000_tx_queue_full
;
2580 /* set the max queue depth so that our ar6000_tx_queue_full handler gets called.
2581 * Linux has the peculiarity of not providing flow control between the
2582 * NIC and the network stack. There is no API to indicate that a TX packet
2583 * was sent which could provide some back pressure to the network stack.
2584 * Under linux you would have to wait till the network stack consumed all sk_buffs
2585 * before any back-flow kicked in. Which isn't very friendly.
2586 * So we have to manage this ourselves */
2587 connect
.MaxSendQueueDepth
= MAX_DEFAULT_SEND_QUEUE_DEPTH
;
2588 connect
.EpCallbacks
.RecvRefillWaterMark
= AR6000_MAX_RX_BUFFERS
/ 4; /* set to 25 % */
2589 if (0 == connect
.EpCallbacks
.RecvRefillWaterMark
) {
2590 connect
.EpCallbacks
.RecvRefillWaterMark
++;
2592 /* connect to control service */
2593 connect
.ServiceID
= WMI_CONTROL_SVC
;
2594 status
= ar6000_connectservice(ar
,
2601 connect
.LocalConnectionFlags
|= HTC_LOCAL_CONN_FLAGS_ENABLE_SEND_BUNDLE_PADDING
;
2602 /* limit the HTC message size on the send path, although we can receive A-MSDU frames of
2603 * 4K, we will only send ethernet-sized (802.3) frames on the send path. */
2604 connect
.MaxSendMsgSize
= WMI_MAX_TX_DATA_FRAME_LENGTH
;
2606 /* to reduce the amount of committed memory for larger A_MSDU frames, use the recv-alloc threshold
2607 * mechanism for larger packets */
2608 connect
.EpCallbacks
.RecvAllocThreshold
= AR6000_BUFFER_SIZE
;
2609 connect
.EpCallbacks
.EpRecvAllocThresh
= ar6000_alloc_amsdu_rxbuf
;
2611 /* for the remaining data services set the connection flag to reduce dribbling,
2612 * if configured to do so */
2613 if (reduce_credit_dribble
) {
2614 connect
.ConnectionFlags
|= HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE
;
2615 /* the credit dribble trigger threshold is (reduce_credit_dribble - 1) for a value
2617 connect
.ConnectionFlags
&= ~HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK
;
2618 connect
.ConnectionFlags
|=
2619 ((u16
)reduce_credit_dribble
- 1) & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK
;
2621 /* connect to best-effort service */
2622 connect
.ServiceID
= WMI_DATA_BE_SVC
;
2624 status
= ar6000_connectservice(ar
,
2631 /* connect to back-ground
2632 * map this to WMI LOW_PRI */
2633 connect
.ServiceID
= WMI_DATA_BK_SVC
;
2634 status
= ar6000_connectservice(ar
,
2641 /* connect to Video service, map this to
2643 connect
.ServiceID
= WMI_DATA_VI_SVC
;
2644 status
= ar6000_connectservice(ar
,
2651 /* connect to VO service, this is currently not
2652 * mapped to a WMI priority stream due to historical reasons.
2653 * WMI originally defined 3 priorities over 3 mailboxes
2654 * We can change this when WMI is reworked so that priorities are not
2655 * dependent on mailboxes */
2656 connect
.ServiceID
= WMI_DATA_VO_SVC
;
2657 status
= ar6000_connectservice(ar
,
2664 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_BE
) != 0);
2665 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_BK
) != 0);
2666 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_VI
) != 0);
2667 A_ASSERT(arAc2EndpointID(ar
,WMM_AC_VO
) != 0);
2669 /* setup access class priority mappings */
2670 ar
->arAcStreamPriMap
[WMM_AC_BK
] = 0; /* lowest */
2671 ar
->arAcStreamPriMap
[WMM_AC_BE
] = 1; /* */
2672 ar
->arAcStreamPriMap
[WMM_AC_VI
] = 2; /* */
2673 ar
->arAcStreamPriMap
[WMM_AC_VO
] = 3; /* highest */
2675 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
2676 if (setuphci
&& (NULL
!= ar6kHciTransCallbacks
.setupTransport
)) {
2677 struct hci_transport_misc_handles hciHandles
;
2679 hciHandles
.netDevice
= ar
->arNetDev
;
2680 hciHandles
.hifDevice
= ar
->arHifDevice
;
2681 hciHandles
.htcHandle
= ar
->arHtcTarget
;
2682 status
= (int)(ar6kHciTransCallbacks
.setupTransport(&hciHandles
));
2687 status
= ar6000_setup_hci(ar
);
2695 goto ar6000_init_done
;
2701 if (BMIReadMemory(ar
->arHifDevice
,
2702 HOST_INTEREST_ITEM_ADDRESS(ar
,
2706 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2707 ("BMIReadMemory forsetting "
2708 "regscanmode failed\n"));
2712 if (regscanmode
== 1)
2713 param
|= HI_OPTION_SKIP_REG_SCAN
;
2714 else if (regscanmode
== 2)
2715 param
|= HI_OPTION_INIT_REG_SCAN
;
2717 if (BMIWriteMemory(ar
->arHifDevice
,
2718 HOST_INTEREST_ITEM_ADDRESS(ar
,
2722 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,
2723 ("BMIWriteMemory forsetting "
2724 "regscanmode failed\n"));
2727 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("Regulatory scan mode set\n"));
2731 * give our connected endpoints some buffers
2734 ar6000_rx_refill(ar
, ar
->arControlEp
);
2735 ar6000_rx_refill(ar
, arAc2EndpointID(ar
,WMM_AC_BE
));
2738 * We will post the receive buffers only for SPE or endpoint ping testing so we are
2739 * making it conditional on the 'bypasswmi' flag.
2742 ar6000_rx_refill(ar
,arAc2EndpointID(ar
,WMM_AC_BK
));
2743 ar6000_rx_refill(ar
,arAc2EndpointID(ar
,WMM_AC_VI
));
2744 ar6000_rx_refill(ar
,arAc2EndpointID(ar
,WMM_AC_VO
));
2747 /* allocate some buffers that handle larger AMSDU frames */
2748 ar6000_refill_amsdu_rxbufs(ar
,AR6000_MAX_AMSDU_RX_BUFFERS
);
2750 /* setup credit distribution */
2751 ar6000_setup_credit_dist(ar
->arHtcTarget
, &ar
->arCreditStateInfo
);
2753 /* Since cookies are used for HTC transports, they should be */
2754 /* initialized prior to enabling HTC. */
2755 ar6000_cookie_init(ar
);
2758 status
= HTCStart(ar
->arHtcTarget
);
2761 if (ar
->arWmiEnabled
== true) {
2762 wmi_shutdown(ar
->arWmi
);
2763 ar
->arWmiEnabled
= false;
2766 ar6000_cookie_cleanup(ar
);
2768 goto ar6000_init_done
;
2772 /* Wait for Wmi event to be ready */
2773 timeleft
= wait_event_interruptible_timeout(arEvent
,
2774 (ar
->arWmiReady
== true), wmitimeout
* HZ
);
2776 if (ar
->arVersion
.abi_ver
!= AR6K_ABI_VERSION
) {
2777 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ABI Version mismatch: Host(0x%x), Target(0x%x)\n", AR6K_ABI_VERSION
, ar
->arVersion
.abi_ver
));
2778 #ifndef ATH6K_SKIP_ABI_VERSION_CHECK
2780 goto ar6000_init_done
;
2781 #endif /* ATH6K_SKIP_ABI_VERSION_CHECK */
2784 if(!timeleft
|| signal_pending(current
))
2786 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("WMI is not ready or wait was interrupted\n"));
2788 goto ar6000_init_done
;
2791 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() WMI is ready\n", __func__
));
2793 /* Communicate the wmi protocol verision to the target */
2794 if ((ar6000_set_host_app_area(ar
)) != 0) {
2795 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Unable to set the host app area\n"));
2797 ar6000_target_config_wlan_params(ar
);
2800 ar
->arNumDataEndPts
= 1;
2803 /* for tests like endpoint ping, the MAC address needs to be non-zero otherwise
2804 * the data path through a raw socket is disabled */
2805 dev
->dev_addr
[0] = 0x00;
2806 dev
->dev_addr
[1] = 0x01;
2807 dev
->dev_addr
[2] = 0x02;
2808 dev
->dev_addr
[3] = 0xAA;
2809 dev
->dev_addr
[4] = 0xBB;
2810 dev
->dev_addr
[5] = 0xCC;
2822 ar6000_bitrate_rx(void *devt
, s32 rateKbps
)
2824 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2826 ar
->arBitRate
= rateKbps
;
2831 ar6000_ratemask_rx(void *devt
, u32 ratemask
)
2833 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2835 ar
->arRateMask
= ratemask
;
2840 ar6000_txPwr_rx(void *devt
, u8 txPwr
)
2842 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2844 ar
->arTxPwr
= txPwr
;
2850 ar6000_channelList_rx(void *devt
, s8 numChan
, u16
*chanList
)
2852 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
2854 memcpy(ar
->arChannelList
, chanList
, numChan
* sizeof (u16
));
2855 ar
->arNumChannels
= numChan
;
2860 u8
ar6000_ibss_map_epid(struct sk_buff
*skb
, struct net_device
*dev
, u32
*mapNo
)
2862 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2864 ATH_MAC_HDR
*macHdr
;
2868 datap
= A_NETBUF_DATA(skb
);
2869 macHdr
= (ATH_MAC_HDR
*)(datap
+ sizeof(WMI_DATA_HDR
));
2870 if (IEEE80211_IS_MULTICAST(macHdr
->dstMac
)) {
2875 for (i
= 0; i
< ar
->arNodeNum
; i
++) {
2876 if (IEEE80211_ADDR_EQ(macHdr
->dstMac
, ar
->arNodeMap
[i
].macAddress
)) {
2878 ar
->arNodeMap
[i
].txPending
++;
2879 return ar
->arNodeMap
[i
].epId
;
2882 if ((eptMap
== -1) && !ar
->arNodeMap
[i
].txPending
) {
2888 eptMap
= ar
->arNodeNum
;
2890 A_ASSERT(ar
->arNodeNum
<= MAX_NODE_NUM
);
2893 memcpy(ar
->arNodeMap
[eptMap
].macAddress
, macHdr
->dstMac
, IEEE80211_ADDR_LEN
);
2895 for (i
= ENDPOINT_2
; i
<= ENDPOINT_5
; i
++) {
2896 if (!ar
->arTxPending
[i
]) {
2897 ar
->arNodeMap
[eptMap
].epId
= i
;
2900 // No free endpoint is available, start redistribution on the inuse endpoints.
2901 if (i
== ENDPOINT_5
) {
2902 ar
->arNodeMap
[eptMap
].epId
= ar
->arNexEpId
;
2904 if (ar
->arNexEpId
> ENDPOINT_5
) {
2905 ar
->arNexEpId
= ENDPOINT_2
;
2910 (*mapNo
) = eptMap
+ 1;
2911 ar
->arNodeMap
[eptMap
].txPending
++;
2913 return ar
->arNodeMap
[eptMap
].epId
;
2917 static void ar6000_dump_skb(struct sk_buff
*skb
)
2920 for (ch
= A_NETBUF_DATA(skb
);
2921 (unsigned long)ch
< ((unsigned long)A_NETBUF_DATA(skb
) +
2922 A_NETBUF_LEN(skb
)); ch
++)
2924 AR_DEBUG_PRINTF(ATH_DEBUG_WARN
,("%2.2x ", *ch
));
2926 AR_DEBUG_PRINTF(ATH_DEBUG_WARN
,("\n"));
2930 #ifdef HTC_TEST_SEND_PKTS
2931 static void DoHTCSendPktsTest(struct ar6_softc
*ar
, int MapNo
, HTC_ENDPOINT_ID eid
, struct sk_buff
*skb
);
2935 ar6000_data_tx(struct sk_buff
*skb
, struct net_device
*dev
)
2937 #define AC_NOT_MAPPED 99
2938 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
2939 u8 ac
= AC_NOT_MAPPED
;
2940 HTC_ENDPOINT_ID eid
= ENDPOINT_UNUSED
;
2943 struct ar_cookie
*cookie
;
2944 bool checkAdHocPsMapping
= false,bMoreData
= false;
2945 HTC_TX_TAG htc_tag
= AR6K_DATA_PKT_TAG
;
2946 u8 dot11Hdr
= processDot11Hdr
;
2948 if (ar
->arWowState
!= WLAN_WOW_STATE_NONE
) {
2952 #endif /* CONFIG_PM */
2954 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("ar6000_data_tx start - skb=0x%lx, data=0x%lx, len=0x%x\n",
2955 (unsigned long)skb
, (unsigned long)A_NETBUF_DATA(skb
),
2956 A_NETBUF_LEN(skb
)));
2958 /* If target is not associated */
2959 if( (!ar
->arConnected
&& !bypasswmi
)
2960 #ifdef CONFIG_HOST_TCMD_SUPPORT
2961 /* TCMD doesn't support any data, free the buf and return */
2962 || (ar
->arTargetMode
== AR6000_TCMD_MODE
)
2971 if (ar
->arWmiReady
== false && bypasswmi
== 0) {
2975 #ifdef BLOCK_TX_PATH_FLAG
2979 #endif /* BLOCK_TX_PATH_FLAG */
2981 /* AP mode Power save processing */
2982 /* If the dst STA is in sleep state, queue the pkt in its PS queue */
2984 if (ar
->arNetworkType
== AP_NETWORK
) {
2985 ATH_MAC_HDR
*datap
= (ATH_MAC_HDR
*)A_NETBUF_DATA(skb
);
2988 /* If the dstMac is a Multicast address & atleast one of the
2989 * associated STA is in PS mode, then queue the pkt to the
2992 if (IEEE80211_IS_MULTICAST(datap
->dstMac
)) {
2997 for (ctr
=0; ctr
<AP_MAX_NUM_STA
; ctr
++) {
2998 if (STA_IS_PWR_SLEEP((&ar
->sta_list
[ctr
]))) {
3004 /* If this transmit is not because of a Dtim Expiry q it */
3005 if (ar
->DTIMExpired
== false) {
3006 bool isMcastqEmpty
= false;
3008 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
3009 isMcastqEmpty
= A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
);
3010 A_NETBUF_ENQUEUE(&ar
->mcastpsq
, skb
);
3011 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
3013 /* If this is the first Mcast pkt getting queued
3014 * indicate to the target to set the BitmapControl LSB
3017 if (isMcastqEmpty
) {
3018 wmi_set_pvb_cmd(ar
->arWmi
, MCAST_AID
, 1);
3022 /* This transmit is because of Dtim expiry. Determine if
3023 * MoreData bit has to be set.
3025 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
3026 if(!A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
)) {
3029 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
3033 conn
= ieee80211_find_conn(ar
, datap
->dstMac
);
3035 if (STA_IS_PWR_SLEEP(conn
)) {
3036 /* If this transmit is not because of a PsPoll q it*/
3037 if (!STA_IS_PS_POLLED(conn
)) {
3038 bool isPsqEmpty
= false;
3039 /* Queue the frames if the STA is sleeping */
3040 A_MUTEX_LOCK(&conn
->psqLock
);
3041 isPsqEmpty
= A_NETBUF_QUEUE_EMPTY(&conn
->psq
);
3042 A_NETBUF_ENQUEUE(&conn
->psq
, skb
);
3043 A_MUTEX_UNLOCK(&conn
->psqLock
);
3045 /* If this is the first pkt getting queued
3046 * for this STA, update the PVB for this STA
3049 wmi_set_pvb_cmd(ar
->arWmi
, conn
->aid
, 1);
3054 /* This tx is because of a PsPoll. Determine if
3055 * MoreData bit has to be set
3057 A_MUTEX_LOCK(&conn
->psqLock
);
3058 if (!A_NETBUF_QUEUE_EMPTY(&conn
->psq
)) {
3061 A_MUTEX_UNLOCK(&conn
->psqLock
);
3066 /* non existent STA. drop the frame */
3073 if (ar
->arWmiEnabled
) {
3076 u8 csum
=skb
->ip_summed
;
3077 if(csumOffload
&& (csum
==CHECKSUM_PARTIAL
)){
3078 csumStart
= (skb
->head
+ skb
->csum_start
- skb_network_header(skb
) +
3079 sizeof(ATH_LLC_SNAP_HDR
));
3080 csumDest
=skb
->csum_offset
+csumStart
;
3082 if (A_NETBUF_HEADROOM(skb
) < dev
->hard_header_len
- LINUX_HACK_FUDGE_FACTOR
) {
3083 struct sk_buff
*newbuf
;
3086 * We really should have gotten enough headroom but sometimes
3087 * we still get packets with not enough headroom. Copy the packet.
3089 len
= A_NETBUF_LEN(skb
);
3090 newbuf
= A_NETBUF_ALLOC(len
);
3091 if (newbuf
== NULL
) {
3094 A_NETBUF_PUT(newbuf
, len
);
3095 memcpy(A_NETBUF_DATA(newbuf
), A_NETBUF_DATA(skb
), len
);
3098 /* fall through and assemble header */
3102 if (wmi_dot11_hdr_add(ar
->arWmi
,skb
,ar
->arNetworkType
) != 0) {
3103 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx-wmi_dot11_hdr_add failed\n"));
3107 if (wmi_dix_2_dot3(ar
->arWmi
, skb
) != 0) {
3108 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx - wmi_dix_2_dot3 failed\n"));
3112 if(csumOffload
&& (csum
==CHECKSUM_PARTIAL
)){
3113 WMI_TX_META_V2 metaV2
;
3114 metaV2
.csumStart
=csumStart
;
3115 metaV2
.csumDest
= csumDest
;
3116 metaV2
.csumFlags
= 0x1;/*instruct target to calculate checksum*/
3117 if (wmi_data_hdr_add(ar
->arWmi
, skb
, DATA_MSGTYPE
, bMoreData
, dot11Hdr
,
3118 WMI_META_VERSION_2
,&metaV2
) != 0) {
3119 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
3126 if (wmi_data_hdr_add(ar
->arWmi
, skb
, DATA_MSGTYPE
, bMoreData
, dot11Hdr
,0,NULL
) != 0) {
3127 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
3133 if ((ar
->arNetworkType
== ADHOC_NETWORK
) &&
3134 ar
->arIbssPsEnable
&& ar
->arConnected
) {
3135 /* flag to check adhoc mapping once we take the lock below: */
3136 checkAdHocPsMapping
= true;
3139 /* get the stream mapping */
3140 ac
= wmi_implicit_create_pstream(ar
->arWmi
, skb
, 0, ar
->arWmmEnabled
);
3144 EPPING_HEADER
*eppingHdr
;
3146 eppingHdr
= A_NETBUF_DATA(skb
);
3148 if (IS_EPPING_PACKET(eppingHdr
)) {
3149 /* the stream ID is mapped to an access class */
3150 ac
= eppingHdr
->StreamNo_h
;
3151 /* some EPPING packets cannot be dropped no matter what access class it was
3152 * sent on. We can change the packet tag to guarantee it will not get dropped */
3153 if (IS_EPING_PACKET_NO_DROP(eppingHdr
)) {
3154 htc_tag
= AR6K_CONTROL_PKT_TAG
;
3157 if (ac
== HCI_TRANSPORT_STREAM_NUM
) {
3158 /* pass this to HCI */
3159 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
3160 if (!hci_test_send(ar
,skb
)) {
3164 /* set AC to discard this skb */
3167 /* a quirk of linux, the payload of the frame is 32-bit aligned and thus the addition
3168 * of the HTC header will mis-align the start of the HTC frame, so we add some
3169 * padding which will be stripped off in the target */
3170 if (EPPING_ALIGNMENT_PAD
> 0) {
3171 A_NETBUF_PUSH(skb
, EPPING_ALIGNMENT_PAD
);
3176 /* not a ping packet, drop it */
3183 /* did we succeed ? */
3184 if ((ac
== AC_NOT_MAPPED
) && !checkAdHocPsMapping
) {
3185 /* cleanup and exit */
3187 AR6000_STAT_INC(ar
, tx_dropped
);
3188 AR6000_STAT_INC(ar
, tx_aborted_errors
);
3194 /* take the lock to protect driver data */
3195 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3199 if (checkAdHocPsMapping
) {
3200 eid
= ar6000_ibss_map_epid(skb
, dev
, &mapNo
);
3202 eid
= arAc2EndpointID (ar
, ac
);
3204 /* validate that the endpoint is connected */
3205 if (eid
== 0 || eid
== ENDPOINT_UNUSED
) {
3206 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" eid %d is NOT mapped!\n", eid
));
3209 /* allocate resource for this packet */
3210 cookie
= ar6000_alloc_cookie(ar
);
3212 if (cookie
!= NULL
) {
3213 /* update counts while the lock is held */
3214 ar
->arTxPending
[eid
]++;
3215 ar
->arTotalTxDataPending
++;
3220 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3222 if (cookie
!= NULL
) {
3223 cookie
->arc_bp
[0] = (unsigned long)skb
;
3224 cookie
->arc_bp
[1] = mapNo
;
3225 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
3233 if (debugdriver
>= 3) {
3234 ar6000_dump_skb(skb
);
3237 #ifdef HTC_TEST_SEND_PKTS
3238 DoHTCSendPktsTest(ar
,mapNo
,eid
,skb
);
3240 /* HTC interface is asynchronous, if this fails, cleanup will happen in
3241 * the ar6000_tx_complete callback */
3242 HTCSendPkt(ar
->arHtcTarget
, &cookie
->HtcPkt
);
3244 /* no packet to send, cleanup */
3246 AR6000_STAT_INC(ar
, tx_dropped
);
3247 AR6000_STAT_INC(ar
, tx_aborted_errors
);
3254 ar6000_acl_data_tx(struct sk_buff
*skb
, struct net_device
*dev
)
3256 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
3257 struct ar_cookie
*cookie
;
3258 HTC_ENDPOINT_ID eid
= ENDPOINT_UNUSED
;
3261 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3263 /* For now we send ACL on BE endpoint: We can also have a dedicated EP */
3264 eid
= arAc2EndpointID (ar
, 0);
3265 /* allocate resource for this packet */
3266 cookie
= ar6000_alloc_cookie(ar
);
3268 if (cookie
!= NULL
) {
3269 /* update counts while the lock is held */
3270 ar
->arTxPending
[eid
]++;
3271 ar
->arTotalTxDataPending
++;
3275 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3277 if (cookie
!= NULL
) {
3278 cookie
->arc_bp
[0] = (unsigned long)skb
;
3279 cookie
->arc_bp
[1] = 0;
3280 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
3287 /* HTC interface is asynchronous, if this fails, cleanup will happen in
3288 * the ar6000_tx_complete callback */
3289 HTCSendPkt(ar
->arHtcTarget
, &cookie
->HtcPkt
);
3291 /* no packet to send, cleanup */
3293 AR6000_STAT_INC(ar
, tx_dropped
);
3294 AR6000_STAT_INC(ar
, tx_aborted_errors
);
3300 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3302 tvsub(register struct timeval
*out
, register struct timeval
*in
)
3304 if((out
->tv_usec
-= in
->tv_usec
) < 0) {
3306 out
->tv_usec
+= 1000000;
3308 out
->tv_sec
-= in
->tv_sec
;
3312 applyAPTCHeuristics(struct ar6_softc
*ar
)
3320 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3322 if ((enableAPTCHeuristics
) && (!aptcTR
.timerScheduled
)) {
3323 do_gettimeofday(&ts
);
3324 tvsub(&ts
, &aptcTR
.samplingTS
);
3325 duration
= ts
.tv_sec
* 1000 + ts
.tv_usec
/ 1000; /* ms */
3326 numbytes
= aptcTR
.bytesTransmitted
+ aptcTR
.bytesReceived
;
3328 if (duration
> APTC_TRAFFIC_SAMPLING_INTERVAL
) {
3329 /* Initialize the time stamp and byte count */
3330 aptcTR
.bytesTransmitted
= aptcTR
.bytesReceived
= 0;
3331 do_gettimeofday(&aptcTR
.samplingTS
);
3333 /* Calculate and decide based on throughput thresholds */
3334 throughput
= ((numbytes
* 8) / duration
);
3335 if (throughput
> APTC_UPPER_THROUGHPUT_THRESHOLD
) {
3336 /* Disable Sleep and schedule a timer */
3337 A_ASSERT(ar
->arWmiReady
== true);
3338 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3339 status
= wmi_powermode_cmd(ar
->arWmi
, MAX_PERF_POWER
);
3340 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3341 A_TIMEOUT_MS(&aptcTimer
, APTC_TRAFFIC_SAMPLING_INTERVAL
, 0);
3342 aptcTR
.timerScheduled
= true;
3347 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3349 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3351 static HTC_SEND_FULL_ACTION
ar6000_tx_queue_full(void *Context
, struct htc_packet
*pPacket
)
3353 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3354 HTC_SEND_FULL_ACTION action
= HTC_SEND_FULL_KEEP
;
3355 bool stopNet
= false;
3356 HTC_ENDPOINT_ID Endpoint
= HTC_GET_ENDPOINT_FROM_PKT(pPacket
);
3363 if (HTC_GET_TAG_FROM_PKT(pPacket
) == AR6K_CONTROL_PKT_TAG
) {
3364 /* don't drop special control packets */
3368 accessClass
= arEndpoint2Ac(ar
,Endpoint
);
3369 /* for endpoint ping testing drop Best Effort and Background */
3370 if ((accessClass
== WMM_AC_BE
) || (accessClass
== WMM_AC_BK
)) {
3371 action
= HTC_SEND_FULL_DROP
;
3374 /* keep but stop the netqueues */
3380 if (Endpoint
== ar
->arControlEp
) {
3381 /* under normal WMI if this is getting full, then something is running rampant
3382 * the host should not be exhausting the WMI queue with too many commands
3383 * the only exception to this is during testing using endpointping */
3384 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3385 /* set flag to handle subsequent messages */
3386 ar
->arWMIControlEpFull
= true;
3387 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3388 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("WMI Control Endpoint is FULL!!! \n"));
3389 /* no need to stop the network */
3394 /* if we get here, we are dealing with data endpoints getting full */
3396 if (HTC_GET_TAG_FROM_PKT(pPacket
) == AR6K_CONTROL_PKT_TAG
) {
3397 /* don't drop control packets issued on ANY data endpoint */
3401 if (ar
->arNetworkType
== ADHOC_NETWORK
) {
3402 /* in adhoc mode, we cannot differentiate traffic priorities so there is no need to
3403 * continue, however we should stop the network */
3407 /* the last MAX_HI_COOKIE_NUM "batch" of cookies are reserved for the highest
3409 if (ar
->arAcStreamPriMap
[arEndpoint2Ac(ar
,Endpoint
)] < ar
->arHiAcStreamActivePri
&&
3410 ar
->arCookieCount
<= MAX_HI_COOKIE_NUM
) {
3411 /* this stream's priority is less than the highest active priority, we
3412 * give preference to the highest priority stream by directing
3413 * HTC to drop the packet that overflowed */
3414 action
= HTC_SEND_FULL_DROP
;
3415 /* since we are dropping packets, no need to stop the network */
3423 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3424 ar
->arNetQueueStopped
= true;
3425 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3426 /* one of the data endpoints queues is getting full..need to stop network stack
3427 * the queue will resume in ar6000_tx_complete() */
3428 netif_stop_queue(ar
->arNetDev
);
3436 ar6000_tx_complete(void *Context
, struct htc_packet_queue
*pPacketQueue
)
3438 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3441 struct ar_cookie
* ar_cookie
;
3442 HTC_ENDPOINT_ID eid
;
3443 bool wakeEvent
= false;
3444 struct sk_buff_head skb_queue
;
3445 struct htc_packet
*pPacket
;
3446 struct sk_buff
*pktSkb
;
3447 bool flushing
= false;
3449 skb_queue_head_init(&skb_queue
);
3451 /* lock the driver as we update internal state */
3452 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3454 /* reap completed packets */
3455 while (!HTC_QUEUE_EMPTY(pPacketQueue
)) {
3457 pPacket
= HTC_PACKET_DEQUEUE(pPacketQueue
);
3459 ar_cookie
= (struct ar_cookie
*)pPacket
->pPktContext
;
3460 A_ASSERT(ar_cookie
);
3462 status
= pPacket
->Status
;
3463 pktSkb
= (struct sk_buff
*)ar_cookie
->arc_bp
[0];
3464 eid
= pPacket
->Endpoint
;
3465 mapNo
= ar_cookie
->arc_bp
[1];
3468 A_ASSERT(pPacket
->pBuffer
== A_NETBUF_DATA(pktSkb
));
3470 /* add this to the list, use faster non-lock API */
3471 __skb_queue_tail(&skb_queue
,pktSkb
);
3474 A_ASSERT(pPacket
->ActualLength
== A_NETBUF_LEN(pktSkb
));
3477 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("ar6000_tx_complete skb=0x%lx data=0x%lx len=0x%x eid=%d ",
3478 (unsigned long)pktSkb
, (unsigned long)pPacket
->pBuffer
,
3479 pPacket
->ActualLength
,
3482 ar
->arTxPending
[eid
]--;
3484 if ((eid
!= ar
->arControlEp
) || bypasswmi
) {
3485 ar
->arTotalTxDataPending
--;
3488 if (eid
== ar
->arControlEp
)
3490 if (ar
->arWMIControlEpFull
) {
3491 /* since this packet completed, the WMI EP is no longer full */
3492 ar
->arWMIControlEpFull
= false;
3495 if (ar
->arTxPending
[eid
] == 0) {
3501 if (status
== A_ECANCELED
) {
3502 /* a packet was flushed */
3505 AR6000_STAT_INC(ar
, tx_errors
);
3506 if (status
!= A_NO_RESOURCE
) {
3507 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("%s() -TX ERROR, status: 0x%x\n", __func__
,
3511 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("OK\n"));
3513 AR6000_STAT_INC(ar
, tx_packets
);
3514 ar
->arNetStats
.tx_bytes
+= A_NETBUF_LEN(pktSkb
);
3515 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3516 aptcTR
.bytesTransmitted
+= a_netbuf_to_len(pktSkb
);
3517 applyAPTCHeuristics(ar
);
3518 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3521 // TODO this needs to be looked at
3522 if ((ar
->arNetworkType
== ADHOC_NETWORK
) && ar
->arIbssPsEnable
3523 && (eid
!= ar
->arControlEp
) && mapNo
)
3526 ar
->arNodeMap
[mapNo
].txPending
--;
3528 if (!ar
->arNodeMap
[mapNo
].txPending
&& (mapNo
== (ar
->arNodeNum
- 1))) {
3530 for (i
= ar
->arNodeNum
; i
> 0; i
--) {
3531 if (!ar
->arNodeMap
[i
- 1].txPending
) {
3532 A_MEMZERO(&ar
->arNodeMap
[i
- 1], sizeof(struct ar_node_mapping
));
3541 ar6000_free_cookie(ar
, ar_cookie
);
3543 if (ar
->arNetQueueStopped
) {
3544 ar
->arNetQueueStopped
= false;
3548 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3550 /* lock is released, we can freely call other kernel APIs */
3552 /* free all skbs in our local list */
3553 while (!skb_queue_empty(&skb_queue
)) {
3554 /* use non-lock version */
3555 pktSkb
= __skb_dequeue(&skb_queue
);
3556 A_NETBUF_FREE(pktSkb
);
3559 if ((ar
->arConnected
== true) || bypasswmi
) {
3561 /* don't wake the queue if we are flushing, other wise it will just
3562 * keep queueing packets, which will keep failing */
3563 netif_wake_queue(ar
->arNetDev
);
3574 ieee80211_find_conn(struct ar6_softc
*ar
, u8
*node_addr
)
3579 switch(ar
->arNetworkType
) {
3581 max_conn
= AP_MAX_NUM_STA
;
3588 for (i
= 0; i
< max_conn
; i
++) {
3589 if (IEEE80211_ADDR_EQ(node_addr
, ar
->sta_list
[i
].mac
)) {
3590 conn
= &ar
->sta_list
[i
];
3598 sta_t
*ieee80211_find_conn_for_aid(struct ar6_softc
*ar
, u8 aid
)
3603 for (ctr
= 0; ctr
< AP_MAX_NUM_STA
; ctr
++) {
3604 if (ar
->sta_list
[ctr
].aid
== aid
) {
3605 conn
= &ar
->sta_list
[ctr
];
3613 * Receive event handler. This is called by HTC when a packet is received
3617 ar6000_rx(void *Context
, struct htc_packet
*pPacket
)
3619 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3620 struct sk_buff
*skb
= (struct sk_buff
*)pPacket
->pPktContext
;
3622 u8 containsDot11Hdr
= 0;
3623 int status
= pPacket
->Status
;
3624 HTC_ENDPOINT_ID ept
= pPacket
->Endpoint
;
3626 A_ASSERT((status
) ||
3627 (pPacket
->pBuffer
== (A_NETBUF_DATA(skb
) + HTC_HEADER_LEN
)));
3629 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",
3630 (unsigned long)ar
, ept
, (unsigned long)skb
, (unsigned long)pPacket
->pBuffer
,
3631 pPacket
->ActualLength
, status
));
3633 if (status
!= A_ECANCELED
) {
3634 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("RX ERR (%d) \n",status
));
3638 /* take lock to protect buffer counts
3639 * and adaptive power throughput state */
3640 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
3643 AR6000_STAT_INC(ar
, rx_packets
);
3644 ar
->arNetStats
.rx_bytes
+= pPacket
->ActualLength
;
3645 #ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3646 aptcTR
.bytesReceived
+= a_netbuf_to_len(skb
);
3647 applyAPTCHeuristics(ar
);
3648 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3650 A_NETBUF_PUT(skb
, pPacket
->ActualLength
+ HTC_HEADER_LEN
);
3651 A_NETBUF_PULL(skb
, HTC_HEADER_LEN
);
3654 if (debugdriver
>= 2) {
3655 ar6000_dump_skb(skb
);
3660 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
3662 skb
->dev
= ar
->arNetDev
;
3664 AR6000_STAT_INC(ar
, rx_errors
);
3666 } else if (ar
->arWmiEnabled
== true) {
3667 if (ept
== ar
->arControlEp
) {
3669 * this is a wmi control msg
3672 ar6000_check_wow_status(ar
, skb
, true);
3673 #endif /* CONFIG_PM */
3674 wmi_control_rx(ar
->arWmi
, skb
);
3676 WMI_DATA_HDR
*dhdr
= (WMI_DATA_HDR
*)A_NETBUF_DATA(skb
);
3681 * This check can be removed if after a while we do not
3682 * see the warning. For now we leave it to ensure
3683 * we drop these frames accordingly in case the
3684 * target generates them for some reason. These
3685 * were used for an internal PAL but that's not
3686 * used or supported anymore. These frames should
3687 * not come up from the target.
3689 if (WARN_ON(WMI_DATA_HDR_GET_DATA_TYPE(dhdr
) ==
3690 WMI_DATA_HDR_DATA_TYPE_ACL
)) {
3691 AR6000_STAT_INC(ar
, rx_errors
);
3697 ar6000_check_wow_status(ar
, NULL
, false);
3698 #endif /* CONFIG_PM */
3700 * this is a wmi data packet
3704 if (processDot11Hdr
) {
3705 minHdrLen
= sizeof(WMI_DATA_HDR
) + sizeof(struct ieee80211_frame
) + sizeof(ATH_LLC_SNAP_HDR
);
3707 minHdrLen
= sizeof (WMI_DATA_HDR
) + sizeof(ATH_MAC_HDR
) +
3708 sizeof(ATH_LLC_SNAP_HDR
);
3711 /* In the case of AP mode we may receive NULL data frames
3712 * that do not have LLC hdr. They are 16 bytes in size.
3713 * Allow these frames in the AP mode.
3714 * ACL data frames don't follow ethernet frame bounds for
3717 if (ar
->arNetworkType
!= AP_NETWORK
&&
3718 ((pPacket
->ActualLength
< minHdrLen
) ||
3719 (pPacket
->ActualLength
> AR6000_MAX_RX_MESSAGE_SIZE
)))
3722 * packet is too short or too long
3724 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("TOO SHORT or TOO LONG\n"));
3725 AR6000_STAT_INC(ar
, rx_errors
);
3726 AR6000_STAT_INC(ar
, rx_length_errors
);
3733 /* Access RSSI values here */
3734 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("RSSI %d\n",
3735 ((WMI_DATA_HDR
*) A_NETBUF_DATA(skb
))->rssi
));
3737 /* Get the Power save state of the STA */
3738 if (ar
->arNetworkType
== AP_NETWORK
) {
3740 u8 psState
=0,prevPsState
;
3741 ATH_MAC_HDR
*datap
=NULL
;
3744 meta_type
= WMI_DATA_HDR_GET_META(dhdr
);
3746 psState
= (((WMI_DATA_HDR
*)A_NETBUF_DATA(skb
))->info
3747 >> WMI_DATA_HDR_PS_SHIFT
) & WMI_DATA_HDR_PS_MASK
;
3749 offset
= sizeof(WMI_DATA_HDR
);
3751 switch (meta_type
) {
3754 case WMI_META_VERSION_1
:
3755 offset
+= sizeof(WMI_RX_META_V1
);
3757 case WMI_META_VERSION_2
:
3758 offset
+= sizeof(WMI_RX_META_V2
);
3764 datap
= (ATH_MAC_HDR
*)(A_NETBUF_DATA(skb
)+offset
);
3765 conn
= ieee80211_find_conn(ar
, datap
->srcMac
);
3768 /* if there is a change in PS state of the STA,
3769 * take appropriate steps.
3770 * 1. If Sleep-->Awake, flush the psq for the STA
3771 * Clear the PVB for the STA.
3772 * 2. If Awake-->Sleep, Starting queueing frames
3775 prevPsState
= STA_IS_PWR_SLEEP(conn
);
3777 STA_SET_PWR_SLEEP(conn
);
3779 STA_CLR_PWR_SLEEP(conn
);
3782 if (prevPsState
^ STA_IS_PWR_SLEEP(conn
)) {
3784 if (!STA_IS_PWR_SLEEP(conn
)) {
3786 A_MUTEX_LOCK(&conn
->psqLock
);
3787 while (!A_NETBUF_QUEUE_EMPTY(&conn
->psq
)) {
3788 struct sk_buff
*skb
=NULL
;
3790 skb
= A_NETBUF_DEQUEUE(&conn
->psq
);
3791 A_MUTEX_UNLOCK(&conn
->psqLock
);
3792 ar6000_data_tx(skb
,ar
->arNetDev
);
3793 A_MUTEX_LOCK(&conn
->psqLock
);
3795 A_MUTEX_UNLOCK(&conn
->psqLock
);
3796 /* Clear the PVB for this STA */
3797 wmi_set_pvb_cmd(ar
->arWmi
, conn
->aid
, 0);
3801 /* This frame is from a STA that is not associated*/
3805 /* Drop NULL data frames here */
3806 if((pPacket
->ActualLength
< minHdrLen
) ||
3807 (pPacket
->ActualLength
> AR6000_MAX_RX_MESSAGE_SIZE
)) {
3813 is_amsdu
= WMI_DATA_HDR_IS_AMSDU(dhdr
) ? true : false;
3814 tid
= WMI_DATA_HDR_GET_UP(dhdr
);
3815 seq_no
= WMI_DATA_HDR_GET_SEQNO(dhdr
);
3816 meta_type
= WMI_DATA_HDR_GET_META(dhdr
);
3817 containsDot11Hdr
= WMI_DATA_HDR_GET_DOT11(dhdr
);
3819 wmi_data_hdr_remove(ar
->arWmi
, skb
);
3821 switch (meta_type
) {
3822 case WMI_META_VERSION_1
:
3824 WMI_RX_META_V1
*pMeta
= (WMI_RX_META_V1
*)A_NETBUF_DATA(skb
);
3825 A_PRINTF("META %d %d %d %d %x\n", pMeta
->status
, pMeta
->rix
, pMeta
->rssi
, pMeta
->channel
, pMeta
->flags
);
3826 A_NETBUF_PULL((void*)skb
, sizeof(WMI_RX_META_V1
));
3829 case WMI_META_VERSION_2
:
3831 WMI_RX_META_V2
*pMeta
= (WMI_RX_META_V2
*)A_NETBUF_DATA(skb
);
3832 if(pMeta
->csumFlags
& 0x1){
3833 skb
->ip_summed
=CHECKSUM_COMPLETE
;
3834 skb
->csum
=(pMeta
->csum
);
3836 A_NETBUF_PULL((void*)skb
, sizeof(WMI_RX_META_V2
));
3843 A_ASSERT(status
== 0);
3845 /* NWF: print the 802.11 hdr bytes */
3846 if(containsDot11Hdr
) {
3847 status
= wmi_dot11_hdr_remove(ar
->arWmi
,skb
);
3848 } else if(!is_amsdu
) {
3849 status
= wmi_dot3_2_dix(skb
);
3853 /* Drop frames that could not be processed (lack of memory, etc.) */
3858 if ((ar
->arNetDev
->flags
& IFF_UP
) == IFF_UP
) {
3859 if (ar
->arNetworkType
== AP_NETWORK
) {
3860 struct sk_buff
*skb1
= NULL
;
3863 datap
= (ATH_MAC_HDR
*)A_NETBUF_DATA(skb
);
3864 if (IEEE80211_IS_MULTICAST(datap
->dstMac
)) {
3865 /* Bcast/Mcast frames should be sent to the OS
3866 * stack as well as on the air.
3868 skb1
= skb_copy(skb
,GFP_ATOMIC
);
3870 /* Search for a connected STA with dstMac as
3871 * the Mac address. If found send the frame to
3872 * it on the air else send the frame up the
3876 conn
= ieee80211_find_conn(ar
, datap
->dstMac
);
3878 if (conn
&& ar
->intra_bss
) {
3881 } else if(conn
&& !ar
->intra_bss
) {
3887 ar6000_data_tx(skb1
, ar
->arNetDev
);
3891 aggr_process_recv_frm(ar
->aggr_cntxt
, tid
, seq_no
, is_amsdu
, (void **)&skb
);
3892 ar6000_deliver_frames_to_nw_stack((void *) ar
->arNetDev
, (void *)skb
);
3896 if (EPPING_ALIGNMENT_PAD
> 0) {
3897 A_NETBUF_PULL(skb
, EPPING_ALIGNMENT_PAD
);
3899 ar6000_deliver_frames_to_nw_stack((void *)ar
->arNetDev
, (void *)skb
);
3908 ar6000_deliver_frames_to_nw_stack(void *dev
, void *osbuf
)
3910 struct sk_buff
*skb
= (struct sk_buff
*)osbuf
;
3914 if ((skb
->dev
->flags
& IFF_UP
) == IFF_UP
) {
3916 ar6000_check_wow_status((struct ar6_softc
*)ar6k_priv(dev
), skb
, false);
3917 #endif /* CONFIG_PM */
3918 skb
->protocol
= eth_type_trans(skb
, skb
->dev
);
3920 * If this routine is called on a ISR (Hard IRQ) or DSR (Soft IRQ)
3921 * or tasklet use the netif_rx to deliver the packet to the stack
3922 * netif_rx will queue the packet onto the receive queue and mark
3923 * the softirq thread has a pending action to complete. Kernel will
3924 * schedule the softIrq kernel thread after processing the DSR.
3926 * If this routine is called on a process context, use netif_rx_ni
3927 * which will schedle the softIrq kernel thread after queuing the packet.
3929 if (in_interrupt()) {
3942 ar6000_deliver_frames_to_bt_stack(void *dev
, void *osbuf
)
3944 struct sk_buff
*skb
= (struct sk_buff
*)osbuf
;
3948 if ((skb
->dev
->flags
& IFF_UP
) == IFF_UP
) {
3949 skb
->protocol
= htons(ETH_P_CONTROL
);
3959 ar6000_rx_refill(void *Context
, HTC_ENDPOINT_ID Endpoint
)
3961 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
3964 int buffersToRefill
;
3965 struct htc_packet
*pPacket
;
3966 struct htc_packet_queue queue
;
3968 buffersToRefill
= (int)AR6000_MAX_RX_BUFFERS
-
3969 HTCGetNumRecvBuffers(ar
->arHtcTarget
, Endpoint
);
3971 if (buffersToRefill
<= 0) {
3972 /* fast return, nothing to fill */
3976 INIT_HTC_PACKET_QUEUE(&queue
);
3978 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX
,("ar6000_rx_refill: providing htc with %d buffers at eid=%d\n",
3979 buffersToRefill
, Endpoint
));
3981 for (RxBuffers
= 0; RxBuffers
< buffersToRefill
; RxBuffers
++) {
3982 osBuf
= A_NETBUF_ALLOC(AR6000_BUFFER_SIZE
);
3983 if (NULL
== osBuf
) {
3986 /* the HTC packet wrapper is at the head of the reserved area
3988 pPacket
= (struct htc_packet
*)(A_NETBUF_HEAD(osBuf
));
3989 /* set re-fill info */
3990 SET_HTC_PACKET_INFO_RX_REFILL(pPacket
,osBuf
,A_NETBUF_DATA(osBuf
),AR6000_BUFFER_SIZE
,Endpoint
);
3992 HTC_PACKET_ENQUEUE(&queue
,pPacket
);
3995 if (!HTC_QUEUE_EMPTY(&queue
)) {
3997 HTCAddReceivePktMultiple(ar
->arHtcTarget
, &queue
);
4002 /* clean up our amsdu buffer list */
4003 static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc
*ar
)
4005 struct htc_packet
*pPacket
;
4008 /* empty AMSDU buffer queue and free OS bufs */
4011 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
4012 pPacket
= HTC_PACKET_DEQUEUE(&ar
->amsdu_rx_buffer_queue
);
4013 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
4015 if (NULL
== pPacket
) {
4019 osBuf
= pPacket
->pPktContext
;
4020 if (NULL
== osBuf
) {
4025 A_NETBUF_FREE(osBuf
);
4031 /* refill the amsdu buffer list */
4032 static void ar6000_refill_amsdu_rxbufs(struct ar6_softc
*ar
, int Count
)
4034 struct htc_packet
*pPacket
;
4038 osBuf
= A_NETBUF_ALLOC(AR6000_AMSDU_BUFFER_SIZE
);
4039 if (NULL
== osBuf
) {
4042 /* the HTC packet wrapper is at the head of the reserved area
4044 pPacket
= (struct htc_packet
*)(A_NETBUF_HEAD(osBuf
));
4045 /* set re-fill info */
4046 SET_HTC_PACKET_INFO_RX_REFILL(pPacket
,osBuf
,A_NETBUF_DATA(osBuf
),AR6000_AMSDU_BUFFER_SIZE
,0);
4048 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
4049 /* put it in the list */
4050 HTC_PACKET_ENQUEUE(&ar
->amsdu_rx_buffer_queue
,pPacket
);
4051 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
4057 /* callback to allocate a large receive buffer for a pending packet. This function is called when
4058 * an HTC packet arrives whose length exceeds a threshold value
4060 * We use a pre-allocated list of buffers of maximum AMSDU size (4K). Under linux it is more optimal to
4061 * keep the allocation size the same to optimize cached-slab allocations.
4064 static struct htc_packet
*ar6000_alloc_amsdu_rxbuf(void *Context
, HTC_ENDPOINT_ID Endpoint
, int Length
)
4066 struct htc_packet
*pPacket
= NULL
;
4067 struct ar6_softc
*ar
= (struct ar6_softc
*)Context
;
4068 int refillCount
= 0;
4070 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX
,("ar6000_alloc_amsdu_rxbuf: eid=%d, Length:%d\n",Endpoint
,Length
));
4074 if (Length
<= AR6000_BUFFER_SIZE
) {
4075 /* shouldn't be getting called on normal sized packets */
4080 if (Length
> AR6000_AMSDU_BUFFER_SIZE
) {
4085 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
4086 /* allocate a packet from the list */
4087 pPacket
= HTC_PACKET_DEQUEUE(&ar
->amsdu_rx_buffer_queue
);
4088 /* see if we need to refill again */
4089 refillCount
= AR6000_MAX_AMSDU_RX_BUFFERS
- HTC_PACKET_QUEUE_DEPTH(&ar
->amsdu_rx_buffer_queue
);
4090 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
4092 if (NULL
== pPacket
) {
4095 /* set actual endpoint ID */
4096 pPacket
->Endpoint
= Endpoint
;
4100 if (refillCount
>= AR6000_AMSDU_REFILL_THRESHOLD
) {
4101 ar6000_refill_amsdu_rxbufs(ar
,refillCount
);
4108 ar6000_set_multicast_list(struct net_device
*dev
)
4110 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000: Multicast filter not supported\n"));
4113 static struct net_device_stats
*
4114 ar6000_get_stats(struct net_device
*dev
)
4116 struct ar6_softc
*ar
= (struct ar6_softc
*)ar6k_priv(dev
);
4117 return &ar
->arNetStats
;
4121 ar6000_ready_event(void *devt
, u8
*datap
, u8 phyCap
, u32 sw_ver
, u32 abi_ver
)
4123 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
4124 struct net_device
*dev
= ar
->arNetDev
;
4126 memcpy(dev
->dev_addr
, datap
, AR6000_ETH_ADDR_LEN
);
4127 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("mac address = %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
4128 dev
->dev_addr
[0], dev
->dev_addr
[1],
4129 dev
->dev_addr
[2], dev
->dev_addr
[3],
4130 dev
->dev_addr
[4], dev
->dev_addr
[5]));
4132 ar
->arPhyCapability
= phyCap
;
4133 ar
->arVersion
.wlan_ver
= sw_ver
;
4134 ar
->arVersion
.abi_ver
= abi_ver
;
4136 snprintf(ar
->wdev
->wiphy
->fw_version
, sizeof(ar
->wdev
->wiphy
->fw_version
),
4138 (ar
->arVersion
.wlan_ver
& 0xf0000000) >> 28,
4139 (ar
->arVersion
.wlan_ver
& 0x0f000000) >> 24,
4140 (ar
->arVersion
.wlan_ver
& 0x00ff0000) >> 16,
4141 (ar
->arVersion
.wlan_ver
& 0x0000ffff));
4143 /* Indicate to the waiting thread that the ready event was received */
4144 ar
->arWmiReady
= true;
4148 void ar6000_install_static_wep_keys(struct ar6_softc
*ar
)
4153 for (index
= WMI_MIN_KEY_INDEX
; index
<= WMI_MAX_KEY_INDEX
; index
++) {
4154 if (ar
->arWepKeyList
[index
].arKeyLen
) {
4155 keyUsage
= GROUP_USAGE
;
4156 if (index
== ar
->arDefTxKeyIndex
) {
4157 keyUsage
|= TX_USAGE
;
4159 wmi_addKey_cmd(ar
->arWmi
,
4163 ar
->arWepKeyList
[index
].arKeyLen
,
4165 ar
->arWepKeyList
[index
].arKey
, KEY_OP_INIT_VAL
, NULL
,
4172 add_new_sta(struct ar6_softc
*ar
, u8
*mac
, u16 aid
, u8
*wpaie
,
4173 u8 ielen
, u8 keymgmt
, u8 ucipher
, u8 auth
)
4177 memcpy(ar
->sta_list
[free_slot
].mac
, mac
, ATH_MAC_LEN
);
4178 memcpy(ar
->sta_list
[free_slot
].wpa_ie
, wpaie
, ielen
);
4179 ar
->sta_list
[free_slot
].aid
= aid
;
4180 ar
->sta_list
[free_slot
].keymgmt
= keymgmt
;
4181 ar
->sta_list
[free_slot
].ucipher
= ucipher
;
4182 ar
->sta_list
[free_slot
].auth
= auth
;
4183 ar
->sta_list_index
= ar
->sta_list_index
| (1 << free_slot
);
4184 ar
->arAPStats
.sta
[free_slot
].aid
= aid
;
4188 ar6000_connect_event(struct ar6_softc
*ar
, u16 channel
, u8
*bssid
,
4189 u16 listenInterval
, u16 beaconInterval
,
4190 NETWORK_TYPE networkType
, u8 beaconIeLen
,
4191 u8 assocReqLen
, u8 assocRespLen
,
4194 union iwreq_data wrqu
;
4195 int i
, beacon_ie_pos
, assoc_resp_ie_pos
, assoc_req_ie_pos
;
4196 static const char *tag1
= "ASSOCINFO(ReqIEs=";
4197 static const char *tag2
= "ASSOCRESPIE=";
4198 static const char *beaconIetag
= "BEACONIE=";
4199 char buf
[WMI_CONTROL_MSG_MAX_LEN
* 2 + strlen(tag1
) + 1];
4202 unsigned long flags
;
4203 struct ieee80211req_key
*ik
;
4204 CRYPTO_TYPE keyType
= NONE_CRYPT
;
4206 if(ar
->arNetworkType
& AP_NETWORK
) {
4207 struct net_device
*dev
= ar
->arNetDev
;
4208 if(memcmp(dev
->dev_addr
, bssid
, ATH_MAC_LEN
)==0) {
4209 ar
->arACS
= channel
;
4210 ik
= &ar
->ap_mode_bkey
;
4212 switch(ar
->arAuthMode
) {
4214 if(ar
->arPairwiseCrypto
== WEP_CRYPT
) {
4215 ar6000_install_static_wep_keys(ar
);
4218 else if(ar
->arPairwiseCrypto
== WAPI_CRYPT
) {
4219 ap_set_wapi_key(ar
, ik
);
4225 case (WPA_PSK_AUTH
|WPA2_PSK_AUTH
):
4226 switch (ik
->ik_type
) {
4227 case IEEE80211_CIPHER_TKIP
:
4228 keyType
= TKIP_CRYPT
;
4230 case IEEE80211_CIPHER_AES_CCM
:
4231 keyType
= AES_CRYPT
;
4236 wmi_addKey_cmd(ar
->arWmi
, ik
->ik_keyix
, keyType
, GROUP_USAGE
,
4237 ik
->ik_keylen
, (u8
*)&ik
->ik_keyrsc
,
4238 ik
->ik_keydata
, KEY_OP_INIT_VAL
, ik
->ik_macaddr
,
4244 ar
->arConnected
= true;
4248 A_PRINTF("NEW STA %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x \n "
4249 " AID=%d \n", bssid
[0], bssid
[1], bssid
[2],
4250 bssid
[3], bssid
[4], bssid
[5], channel
);
4251 switch ((listenInterval
>>8)&0xFF) {
4253 A_PRINTF("AUTH: OPEN\n");
4256 A_PRINTF("AUTH: SHARED\n");
4259 A_PRINTF("AUTH: Unknown\n");
4262 switch (listenInterval
&0xFF) {
4264 A_PRINTF("KeyMgmt: WPA-PSK\n");
4267 A_PRINTF("KeyMgmt: WPA2-PSK\n");
4270 A_PRINTF("KeyMgmt: NONE\n");
4273 switch (beaconInterval
) {
4275 A_PRINTF("Cipher: AES\n");
4278 A_PRINTF("Cipher: TKIP\n");
4281 A_PRINTF("Cipher: WEP\n");
4285 A_PRINTF("Cipher: WAPI\n");
4289 A_PRINTF("Cipher: NONE\n");
4293 add_new_sta(ar
, bssid
, channel
/*aid*/,
4294 assocInfo
/* WPA IE */, assocRespLen
/* IE len */,
4295 listenInterval
&0xFF /* Keymgmt */, beaconInterval
/* cipher */,
4296 (listenInterval
>>8)&0xFF /* auth alg */);
4298 /* Send event to application */
4299 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4300 memcpy(wrqu
.addr
.sa_data
, bssid
, ATH_MAC_LEN
);
4301 wireless_send_event(ar
->arNetDev
, IWEVREGISTERED
, &wrqu
, NULL
);
4302 /* In case the queue is stopped when we switch modes, this will
4305 netif_wake_queue(ar
->arNetDev
);
4309 ar6k_cfg80211_connect_event(ar
, channel
, bssid
,
4310 listenInterval
, beaconInterval
,
4311 networkType
, beaconIeLen
,
4312 assocReqLen
, assocRespLen
,
4315 memcpy(ar
->arBssid
, bssid
, sizeof(ar
->arBssid
));
4316 ar
->arBssChannel
= channel
;
4318 A_PRINTF("AR6000 connected event on freq %d ", channel
);
4319 A_PRINTF("with bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
4320 " listenInterval=%d, beaconInterval = %d, beaconIeLen = %d assocReqLen=%d"
4321 " assocRespLen =%d\n",
4322 bssid
[0], bssid
[1], bssid
[2],
4323 bssid
[3], bssid
[4], bssid
[5],
4324 listenInterval
, beaconInterval
,
4325 beaconIeLen
, assocReqLen
, assocRespLen
);
4326 if (networkType
& ADHOC_NETWORK
) {
4327 if (networkType
& ADHOC_CREATOR
) {
4328 A_PRINTF("Network: Adhoc (Creator)\n");
4330 A_PRINTF("Network: Adhoc (Joiner)\n");
4333 A_PRINTF("Network: Infrastructure\n");
4336 if ((ar
->arNetworkType
== INFRA_NETWORK
)) {
4337 wmi_listeninterval_cmd(ar
->arWmi
, ar
->arListenIntervalT
, ar
->arListenIntervalB
);
4340 if (beaconIeLen
&& (sizeof(buf
) > (9 + beaconIeLen
* 2))) {
4341 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nBeaconIEs= "));
4344 A_MEMZERO(buf
, sizeof(buf
));
4345 sprintf(buf
, "%s", beaconIetag
);
4347 for (i
= beacon_ie_pos
; i
< beacon_ie_pos
+ beaconIeLen
; i
++) {
4348 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4349 sprintf(pos
, "%2.2x", assocInfo
[i
]);
4352 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4354 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4355 wrqu
.data
.length
= strlen(buf
);
4356 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4359 if (assocRespLen
&& (sizeof(buf
) > (12 + (assocRespLen
* 2))))
4361 assoc_resp_ie_pos
= beaconIeLen
+ assocReqLen
+
4362 sizeof(u16
) + /* capinfo*/
4363 sizeof(u16
) + /* status Code */
4364 sizeof(u16
) ; /* associd */
4365 A_MEMZERO(buf
, sizeof(buf
));
4366 sprintf(buf
, "%s", tag2
);
4368 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nAssocRespIEs= "));
4370 * The Association Response Frame w.o. the WLAN header is delivered to
4371 * the host, so skip over to the IEs
4373 for (i
= assoc_resp_ie_pos
; i
< assoc_resp_ie_pos
+ assocRespLen
- 6; i
++)
4375 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4376 sprintf(pos
, "%2.2x", assocInfo
[i
]);
4379 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4381 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4382 wrqu
.data
.length
= strlen(buf
);
4383 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4386 if (assocReqLen
&& (sizeof(buf
) > (17 + (assocReqLen
* 2)))) {
4388 * assoc Request includes capability and listen interval. Skip these.
4390 assoc_req_ie_pos
= beaconIeLen
+
4391 sizeof(u16
) + /* capinfo*/
4392 sizeof(u16
); /* listen interval */
4394 A_MEMZERO(buf
, sizeof(buf
));
4395 sprintf(buf
, "%s", tag1
);
4397 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("AssocReqIEs= "));
4398 for (i
= assoc_req_ie_pos
; i
< assoc_req_ie_pos
+ assocReqLen
- 4; i
++) {
4399 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4400 sprintf(pos
, "%2.2x", assocInfo
[i
]);
4403 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4405 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4406 wrqu
.data
.length
= strlen(buf
);
4407 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4410 if (ar
->user_savedkeys_stat
== USER_SAVEDKEYS_STAT_RUN
&&
4411 ar
->user_saved_keys
.keyOk
== true)
4413 key_op_ctrl
= KEY_OP_VALID_MASK
& ~KEY_OP_INIT_TSC
;
4415 if (ar
->user_key_ctrl
& AR6000_USER_SETKEYS_RSC_UNCHANGED
) {
4416 key_op_ctrl
&= ~KEY_OP_INIT_RSC
;
4418 key_op_ctrl
|= KEY_OP_INIT_RSC
;
4420 ar6000_reinstall_keys(ar
, key_op_ctrl
);
4423 netif_wake_queue(ar
->arNetDev
);
4425 /* Update connect & link status atomically */
4426 spin_lock_irqsave(&ar
->arLock
, flags
);
4427 ar
->arConnected
= true;
4428 ar
->arConnectPending
= false;
4429 netif_carrier_on(ar
->arNetDev
);
4430 spin_unlock_irqrestore(&ar
->arLock
, flags
);
4431 /* reset the rx aggr state */
4432 aggr_reset_state(ar
->aggr_cntxt
);
4435 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4436 memcpy(wrqu
.addr
.sa_data
, bssid
, IEEE80211_ADDR_LEN
);
4437 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
4438 wireless_send_event(ar
->arNetDev
, SIOCGIWAP
, &wrqu
, NULL
);
4439 if ((ar
->arNetworkType
== ADHOC_NETWORK
) && ar
->arIbssPsEnable
) {
4440 A_MEMZERO(ar
->arNodeMap
, sizeof(ar
->arNodeMap
));
4442 ar
->arNexEpId
= ENDPOINT_2
;
4444 if (!ar
->arUserBssFilter
) {
4445 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
4450 void ar6000_set_numdataendpts(struct ar6_softc
*ar
, u32 num
)
4452 A_ASSERT(num
<= (HTC_MAILBOX_NUM_MAX
- 1));
4453 ar
->arNumDataEndPts
= num
;
4457 sta_cleanup(struct ar6_softc
*ar
, u8 i
)
4459 struct sk_buff
*skb
;
4461 /* empty the queued pkts in the PS queue if any */
4462 A_MUTEX_LOCK(&ar
->sta_list
[i
].psqLock
);
4463 while (!A_NETBUF_QUEUE_EMPTY(&ar
->sta_list
[i
].psq
)) {
4464 skb
= A_NETBUF_DEQUEUE(&ar
->sta_list
[i
].psq
);
4467 A_MUTEX_UNLOCK(&ar
->sta_list
[i
].psqLock
);
4469 /* Zero out the state fields */
4470 A_MEMZERO(&ar
->arAPStats
.sta
[ar
->sta_list
[i
].aid
-1], sizeof(WMI_PER_STA_STAT
));
4471 A_MEMZERO(&ar
->sta_list
[i
].mac
, ATH_MAC_LEN
);
4472 A_MEMZERO(&ar
->sta_list
[i
].wpa_ie
, IEEE80211_MAX_IE
);
4473 ar
->sta_list
[i
].aid
= 0;
4474 ar
->sta_list
[i
].flags
= 0;
4476 ar
->sta_list_index
= ar
->sta_list_index
& ~(1 << i
);
4480 u8
remove_sta(struct ar6_softc
*ar
, u8
*mac
, u16 reason
)
4484 if(IS_MAC_NULL(mac
)) {
4488 if(IS_MAC_BCAST(mac
)) {
4489 A_PRINTF("DEL ALL STA\n");
4490 for(i
=0; i
< AP_MAX_NUM_STA
; i
++) {
4491 if(!IS_MAC_NULL(ar
->sta_list
[i
].mac
)) {
4497 for(i
=0; i
< AP_MAX_NUM_STA
; i
++) {
4498 if(memcmp(ar
->sta_list
[i
].mac
, mac
, ATH_MAC_LEN
)==0) {
4499 A_PRINTF("DEL STA %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
4500 " aid=%d REASON=%d\n", mac
[0], mac
[1], mac
[2],
4501 mac
[3], mac
[4], mac
[5], ar
->sta_list
[i
].aid
, reason
);
4513 ar6000_disconnect_event(struct ar6_softc
*ar
, u8 reason
, u8
*bssid
,
4514 u8 assocRespLen
, u8
*assocInfo
, u16 protocolReasonStatus
)
4517 unsigned long flags
;
4518 union iwreq_data wrqu
;
4520 if(ar
->arNetworkType
& AP_NETWORK
) {
4521 union iwreq_data wrqu
;
4522 struct sk_buff
*skb
;
4524 if(!remove_sta(ar
, bssid
, protocolReasonStatus
)) {
4528 /* If there are no more associated STAs, empty the mcast PS q */
4529 if (ar
->sta_list_index
== 0) {
4530 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
4531 while (!A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
)) {
4532 skb
= A_NETBUF_DEQUEUE(&ar
->mcastpsq
);
4535 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
4537 /* Clear the LSB of the BitMapCtl field of the TIM IE */
4538 if (ar
->arWmiReady
) {
4539 wmi_set_pvb_cmd(ar
->arWmi
, MCAST_AID
, 0);
4543 if(!IS_MAC_BCAST(bssid
)) {
4544 /* Send event to application */
4545 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4546 memcpy(wrqu
.addr
.sa_data
, bssid
, ATH_MAC_LEN
);
4547 wireless_send_event(ar
->arNetDev
, IWEVEXPIRED
, &wrqu
, NULL
);
4550 ar
->arConnected
= false;
4554 ar6k_cfg80211_disconnect_event(ar
, reason
, bssid
,
4555 assocRespLen
, assocInfo
,
4556 protocolReasonStatus
);
4558 /* Send disconnect event to supplicant */
4559 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4560 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
4561 wireless_send_event(ar
->arNetDev
, SIOCGIWAP
, &wrqu
, NULL
);
4563 /* it is necessary to clear the host-side rx aggregation state */
4564 aggr_reset_state(ar
->aggr_cntxt
);
4566 A_UNTIMEOUT(&ar
->disconnect_timer
);
4568 A_PRINTF("AR6000 disconnected");
4569 if (bssid
[0] || bssid
[1] || bssid
[2] || bssid
[3] || bssid
[4] || bssid
[5]) {
4570 A_PRINTF(" from %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",
4571 bssid
[0], bssid
[1], bssid
[2], bssid
[3], bssid
[4], bssid
[5]);
4574 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nDisconnect Reason is %d", reason
));
4575 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nProtocol Reason/Status Code is %d", protocolReasonStatus
));
4576 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\nAssocResp Frame = %s",
4577 assocRespLen
? " " : "NULL"));
4578 for (i
= 0; i
< assocRespLen
; i
++) {
4580 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4582 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("%2.2x ", assocInfo
[i
]));
4584 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("\n"));
4586 * If the event is due to disconnect cmd from the host, only they the target
4587 * would stop trying to connect. Under any other condition, target would
4588 * keep trying to connect.
4591 if( reason
== DISCONNECT_CMD
)
4593 if ((!ar
->arUserBssFilter
) && (ar
->arWmiReady
)) {
4594 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
4597 ar
->arConnectPending
= true;
4598 if (((reason
== ASSOC_FAILED
) && (protocolReasonStatus
== 0x11)) ||
4599 ((reason
== ASSOC_FAILED
) && (protocolReasonStatus
== 0x0) && (reconnect_flag
== 1))) {
4600 ar
->arConnected
= true;
4605 if ((reason
== NO_NETWORK_AVAIL
) && (ar
->arWmiReady
))
4607 bss_t
*pWmiSsidnode
= NULL
;
4609 /* remove the current associated bssid node */
4610 wmi_free_node (ar
->arWmi
, bssid
);
4613 * In case any other same SSID nodes are present
4614 * remove it, since those nodes also not available now
4619 * Find the nodes based on SSID and remove it
4620 * NOTE :: This case will not work out for Hidden-SSID
4622 pWmiSsidnode
= wmi_find_Ssidnode (ar
->arWmi
, ar
->arSsid
, ar
->arSsidLen
, false, true);
4626 wmi_free_node (ar
->arWmi
, pWmiSsidnode
->ni_macaddr
);
4629 } while (pWmiSsidnode
);
4632 /* Update connect & link status atomically */
4633 spin_lock_irqsave(&ar
->arLock
, flags
);
4634 ar
->arConnected
= false;
4635 netif_carrier_off(ar
->arNetDev
);
4636 spin_unlock_irqrestore(&ar
->arLock
, flags
);
4638 if( (reason
!= CSERV_DISCONNECT
) || (reconnect_flag
!= 1) ) {
4642 if (reason
!= CSERV_DISCONNECT
)
4644 ar
->user_savedkeys_stat
= USER_SAVEDKEYS_STAT_INIT
;
4645 ar
->user_key_ctrl
= 0;
4648 netif_stop_queue(ar
->arNetDev
);
4649 A_MEMZERO(ar
->arBssid
, sizeof(ar
->arBssid
));
4650 ar
->arBssChannel
= 0;
4651 ar
->arBeaconInterval
= 0;
4653 ar6000_TxDataCleanup(ar
);
4657 ar6000_regDomain_event(struct ar6_softc
*ar
, u32 regCode
)
4659 A_PRINTF("AR6000 Reg Code = 0x%x\n", regCode
);
4660 ar
->arRegCode
= regCode
;
4664 ar6000_aggr_rcv_addba_req_evt(struct ar6_softc
*ar
, WMI_ADDBA_REQ_EVENT
*evt
)
4666 if(evt
->status
== 0) {
4667 aggr_recv_addba_req_evt(ar
->aggr_cntxt
, evt
->tid
, evt
->st_seq_no
, evt
->win_sz
);
4672 ar6000_aggr_rcv_addba_resp_evt(struct ar6_softc
*ar
, WMI_ADDBA_RESP_EVENT
*evt
)
4674 A_PRINTF("ADDBA RESP. tid %d status %d, sz %d\n", evt
->tid
, evt
->status
, evt
->amsdu_sz
);
4675 if(evt
->status
== 0) {
4680 ar6000_aggr_rcv_delba_req_evt(struct ar6_softc
*ar
, WMI_DELBA_EVENT
*evt
)
4682 aggr_recv_delba_req_evt(ar
->aggr_cntxt
, evt
->tid
);
4685 void register_pal_cb(ar6k_pal_config_t
*palConfig_p
)
4687 ar6k_pal_config_g
= *palConfig_p
;
4691 ar6000_hci_event_rcv_evt(struct ar6_softc
*ar
, WMI_HCI_EVENT
*cmd
)
4698 size
= cmd
->evt_buf_sz
+ 4;
4699 osbuf
= A_NETBUF_ALLOC(size
);
4700 if (osbuf
== NULL
) {
4702 A_PRINTF("Error in allocating netbuf \n");
4706 A_NETBUF_PUT(osbuf
, size
);
4707 buf
= (u8
*)A_NETBUF_DATA(osbuf
);
4708 /* First 2-bytes carry HCI event/ACL data type
4709 * the next 2 are free
4711 *((short *)buf
) = WMI_HCI_EVENT_EVENTID
;
4713 memcpy(buf
, cmd
->buf
, cmd
->evt_buf_sz
);
4715 ar6000_deliver_frames_to_nw_stack(ar
->arNetDev
, osbuf
);
4717 A_PRINTF_LOG("HCI Event From PAL <-- \n");
4718 for(i
= 0; i
< cmd
->evt_buf_sz
; i
++) {
4719 A_PRINTF_LOG("0x%02x ", cmd
->buf
[i
]);
4725 A_PRINTF_LOG("==================================\n");
4730 ar6000_neighborReport_event(struct ar6_softc
*ar
, int numAps
, WMI_NEIGHBOR_INFO
*info
)
4732 #if WIRELESS_EXT >= 18
4733 struct iw_pmkid_cand
*pmkcand
;
4734 #else /* WIRELESS_EXT >= 18 */
4735 static const char *tag
= "PRE-AUTH";
4737 #endif /* WIRELESS_EXT >= 18 */
4739 union iwreq_data wrqu
;
4742 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("AR6000 Neighbor Report Event\n"));
4743 for (i
=0; i
< numAps
; info
++, i
++) {
4744 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",
4745 info
->bssid
[0], info
->bssid
[1], info
->bssid
[2],
4746 info
->bssid
[3], info
->bssid
[4], info
->bssid
[5]));
4747 if (info
->bssFlags
& WMI_PREAUTH_CAPABLE_BSS
) {
4748 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("preauth-cap"));
4750 if (info
->bssFlags
& WMI_PMKID_VALID_BSS
) {
4751 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,(" pmkid-valid\n"));
4752 continue; /* we skip bss if the pmkid is already valid */
4754 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,("\n"));
4755 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4756 #if WIRELESS_EXT >= 18
4757 pmkcand
= A_MALLOC_NOWAIT(sizeof(struct iw_pmkid_cand
));
4758 A_MEMZERO(pmkcand
, sizeof(struct iw_pmkid_cand
));
4760 pmkcand
->flags
= info
->bssFlags
;
4761 memcpy(pmkcand
->bssid
.sa_data
, info
->bssid
, ATH_MAC_LEN
);
4762 wrqu
.data
.length
= sizeof(struct iw_pmkid_cand
);
4763 wireless_send_event(ar
->arNetDev
, IWEVPMKIDCAND
, &wrqu
, (char *)pmkcand
);
4765 #else /* WIRELESS_EXT >= 18 */
4766 snprintf(buf
, sizeof(buf
), "%s%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
4768 info
->bssid
[0], info
->bssid
[1], info
->bssid
[2],
4769 info
->bssid
[3], info
->bssid
[4], info
->bssid
[5],
4771 wrqu
.data
.length
= strlen(buf
);
4772 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4773 #endif /* WIRELESS_EXT >= 18 */
4778 ar6000_tkip_micerr_event(struct ar6_softc
*ar
, u8 keyid
, bool ismcast
)
4780 static const char *tag
= "MLME-MICHAELMICFAILURE.indication";
4782 union iwreq_data wrqu
;
4785 * For AP case, keyid will have aid of STA which sent pkt with
4786 * MIC error. Use this aid to get MAC & send it to hostapd.
4788 if (ar
->arNetworkType
== AP_NETWORK
) {
4789 sta_t
*s
= ieee80211_find_conn_for_aid(ar
, (keyid
>> 2));
4791 A_PRINTF("AP TKIP MIC error received from Invalid aid / STA not found =%d\n", keyid
);
4794 A_PRINTF("AP TKIP MIC error received from aid=%d\n", keyid
);
4795 snprintf(buf
,sizeof(buf
), "%s addr=%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
4796 tag
, s
->mac
[0],s
->mac
[1],s
->mac
[2],s
->mac
[3],s
->mac
[4],s
->mac
[5]);
4799 ar6k_cfg80211_tkip_micerr_event(ar
, keyid
, ismcast
);
4801 A_PRINTF("AR6000 TKIP MIC error received for keyid %d %scast\n",
4802 keyid
& 0x3, ismcast
? "multi": "uni");
4803 snprintf(buf
, sizeof(buf
), "%s(keyid=%d %sicast)", tag
, keyid
& 0x3,
4804 ismcast
? "mult" : "un");
4807 memset(&wrqu
, 0, sizeof(wrqu
));
4808 wrqu
.data
.length
= strlen(buf
);
4809 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
4813 ar6000_scanComplete_event(struct ar6_softc
*ar
, int status
)
4816 ar6k_cfg80211_scanComplete_event(ar
, status
);
4818 if (!ar
->arUserBssFilter
) {
4819 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
4821 if (ar
->scan_triggered
) {
4823 union iwreq_data wrqu
;
4824 A_MEMZERO(&wrqu
, sizeof(wrqu
));
4825 wireless_send_event(ar
->arNetDev
, SIOCGIWSCAN
, &wrqu
, NULL
);
4827 ar
->scan_triggered
= 0;
4830 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN
,( "AR6000 scan complete: %d\n", status
));
4834 ar6000_targetStats_event(struct ar6_softc
*ar
, u8
*ptr
, u32 len
)
4838 if(ar
->arNetworkType
== AP_NETWORK
) {
4839 WMI_AP_MODE_STAT
*p
= (WMI_AP_MODE_STAT
*)ptr
;
4840 WMI_AP_MODE_STAT
*ap
= &ar
->arAPStats
;
4842 if (len
< sizeof(*p
)) {
4846 for(ac
=0;ac
<AP_MAX_NUM_STA
;ac
++) {
4847 ap
->sta
[ac
].tx_bytes
+= p
->sta
[ac
].tx_bytes
;
4848 ap
->sta
[ac
].tx_pkts
+= p
->sta
[ac
].tx_pkts
;
4849 ap
->sta
[ac
].tx_error
+= p
->sta
[ac
].tx_error
;
4850 ap
->sta
[ac
].tx_discard
+= p
->sta
[ac
].tx_discard
;
4851 ap
->sta
[ac
].rx_bytes
+= p
->sta
[ac
].rx_bytes
;
4852 ap
->sta
[ac
].rx_pkts
+= p
->sta
[ac
].rx_pkts
;
4853 ap
->sta
[ac
].rx_error
+= p
->sta
[ac
].rx_error
;
4854 ap
->sta
[ac
].rx_discard
+= p
->sta
[ac
].rx_discard
;
4858 WMI_TARGET_STATS
*pTarget
= (WMI_TARGET_STATS
*)ptr
;
4859 TARGET_STATS
*pStats
= &ar
->arTargetStats
;
4861 if (len
< sizeof(*pTarget
)) {
4865 // Update the RSSI of the connected bss.
4866 if (ar
->arConnected
) {
4867 bss_t
*pConnBss
= NULL
;
4869 pConnBss
= wmi_find_node(ar
->arWmi
,ar
->arBssid
);
4872 pConnBss
->ni_rssi
= pTarget
->cservStats
.cs_aveBeacon_rssi
;
4873 pConnBss
->ni_snr
= pTarget
->cservStats
.cs_aveBeacon_snr
;
4874 wmi_node_return(ar
->arWmi
, pConnBss
);
4878 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("AR6000 updating target stats\n"));
4879 pStats
->tx_packets
+= pTarget
->txrxStats
.tx_stats
.tx_packets
;
4880 pStats
->tx_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_bytes
;
4881 pStats
->tx_unicast_pkts
+= pTarget
->txrxStats
.tx_stats
.tx_unicast_pkts
;
4882 pStats
->tx_unicast_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_unicast_bytes
;
4883 pStats
->tx_multicast_pkts
+= pTarget
->txrxStats
.tx_stats
.tx_multicast_pkts
;
4884 pStats
->tx_multicast_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_multicast_bytes
;
4885 pStats
->tx_broadcast_pkts
+= pTarget
->txrxStats
.tx_stats
.tx_broadcast_pkts
;
4886 pStats
->tx_broadcast_bytes
+= pTarget
->txrxStats
.tx_stats
.tx_broadcast_bytes
;
4887 pStats
->tx_rts_success_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_rts_success_cnt
;
4888 for(ac
= 0; ac
< WMM_NUM_AC
; ac
++)
4889 pStats
->tx_packet_per_ac
[ac
] += pTarget
->txrxStats
.tx_stats
.tx_packet_per_ac
[ac
];
4890 pStats
->tx_errors
+= pTarget
->txrxStats
.tx_stats
.tx_errors
;
4891 pStats
->tx_failed_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_failed_cnt
;
4892 pStats
->tx_retry_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_retry_cnt
;
4893 pStats
->tx_mult_retry_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_mult_retry_cnt
;
4894 pStats
->tx_rts_fail_cnt
+= pTarget
->txrxStats
.tx_stats
.tx_rts_fail_cnt
;
4895 pStats
->tx_unicast_rate
= wmi_get_rate(pTarget
->txrxStats
.tx_stats
.tx_unicast_rate
);
4897 pStats
->rx_packets
+= pTarget
->txrxStats
.rx_stats
.rx_packets
;
4898 pStats
->rx_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_bytes
;
4899 pStats
->rx_unicast_pkts
+= pTarget
->txrxStats
.rx_stats
.rx_unicast_pkts
;
4900 pStats
->rx_unicast_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_unicast_bytes
;
4901 pStats
->rx_multicast_pkts
+= pTarget
->txrxStats
.rx_stats
.rx_multicast_pkts
;
4902 pStats
->rx_multicast_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_multicast_bytes
;
4903 pStats
->rx_broadcast_pkts
+= pTarget
->txrxStats
.rx_stats
.rx_broadcast_pkts
;
4904 pStats
->rx_broadcast_bytes
+= pTarget
->txrxStats
.rx_stats
.rx_broadcast_bytes
;
4905 pStats
->rx_fragment_pkt
+= pTarget
->txrxStats
.rx_stats
.rx_fragment_pkt
;
4906 pStats
->rx_errors
+= pTarget
->txrxStats
.rx_stats
.rx_errors
;
4907 pStats
->rx_crcerr
+= pTarget
->txrxStats
.rx_stats
.rx_crcerr
;
4908 pStats
->rx_key_cache_miss
+= pTarget
->txrxStats
.rx_stats
.rx_key_cache_miss
;
4909 pStats
->rx_decrypt_err
+= pTarget
->txrxStats
.rx_stats
.rx_decrypt_err
;
4910 pStats
->rx_duplicate_frames
+= pTarget
->txrxStats
.rx_stats
.rx_duplicate_frames
;
4911 pStats
->rx_unicast_rate
= wmi_get_rate(pTarget
->txrxStats
.rx_stats
.rx_unicast_rate
);
4914 pStats
->tkip_local_mic_failure
4915 += pTarget
->txrxStats
.tkipCcmpStats
.tkip_local_mic_failure
;
4916 pStats
->tkip_counter_measures_invoked
4917 += pTarget
->txrxStats
.tkipCcmpStats
.tkip_counter_measures_invoked
;
4918 pStats
->tkip_replays
+= pTarget
->txrxStats
.tkipCcmpStats
.tkip_replays
;
4919 pStats
->tkip_format_errors
+= pTarget
->txrxStats
.tkipCcmpStats
.tkip_format_errors
;
4920 pStats
->ccmp_format_errors
+= pTarget
->txrxStats
.tkipCcmpStats
.ccmp_format_errors
;
4921 pStats
->ccmp_replays
+= pTarget
->txrxStats
.tkipCcmpStats
.ccmp_replays
;
4923 pStats
->power_save_failure_cnt
+= pTarget
->pmStats
.power_save_failure_cnt
;
4924 pStats
->noise_floor_calibation
= pTarget
->noise_floor_calibation
;
4926 pStats
->cs_bmiss_cnt
+= pTarget
->cservStats
.cs_bmiss_cnt
;
4927 pStats
->cs_lowRssi_cnt
+= pTarget
->cservStats
.cs_lowRssi_cnt
;
4928 pStats
->cs_connect_cnt
+= pTarget
->cservStats
.cs_connect_cnt
;
4929 pStats
->cs_disconnect_cnt
+= pTarget
->cservStats
.cs_disconnect_cnt
;
4930 pStats
->cs_aveBeacon_snr
= pTarget
->cservStats
.cs_aveBeacon_snr
;
4931 pStats
->cs_aveBeacon_rssi
= pTarget
->cservStats
.cs_aveBeacon_rssi
;
4933 if (enablerssicompensation
) {
4934 pStats
->cs_aveBeacon_rssi
=
4935 rssi_compensation_calc(ar
, pStats
->cs_aveBeacon_rssi
);
4937 pStats
->cs_lastRoam_msec
= pTarget
->cservStats
.cs_lastRoam_msec
;
4938 pStats
->cs_snr
= pTarget
->cservStats
.cs_snr
;
4939 pStats
->cs_rssi
= pTarget
->cservStats
.cs_rssi
;
4941 pStats
->lq_val
= pTarget
->lqVal
;
4943 pStats
->wow_num_pkts_dropped
+= pTarget
->wowStats
.wow_num_pkts_dropped
;
4944 pStats
->wow_num_host_pkt_wakeups
+= pTarget
->wowStats
.wow_num_host_pkt_wakeups
;
4945 pStats
->wow_num_host_event_wakeups
+= pTarget
->wowStats
.wow_num_host_event_wakeups
;
4946 pStats
->wow_num_events_discarded
+= pTarget
->wowStats
.wow_num_events_discarded
;
4947 pStats
->arp_received
+= pTarget
->arpStats
.arp_received
;
4948 pStats
->arp_matched
+= pTarget
->arpStats
.arp_matched
;
4949 pStats
->arp_replied
+= pTarget
->arpStats
.arp_replied
;
4951 if (ar
->statsUpdatePending
) {
4952 ar
->statsUpdatePending
= false;
4959 ar6000_rssiThreshold_event(struct ar6_softc
*ar
, WMI_RSSI_THRESHOLD_VAL newThreshold
, s16 rssi
)
4961 USER_RSSI_THOLD userRssiThold
;
4963 rssi
= rssi
+ SIGNAL_QUALITY_NOISE_FLOOR
;
4965 if (enablerssicompensation
) {
4966 rssi
= rssi_compensation_calc(ar
, rssi
);
4969 /* Send an event to the app */
4970 userRssiThold
.tag
= ar
->rssi_map
[newThreshold
].tag
;
4971 userRssiThold
.rssi
= rssi
;
4972 A_PRINTF("rssi Threshold range = %d tag = %d rssi = %d\n", newThreshold
,
4973 userRssiThold
.tag
, userRssiThold
.rssi
);
4978 ar6000_hbChallengeResp_event(struct ar6_softc
*ar
, u32 cookie
, u32 source
)
4980 if (source
!= APP_HB_CHALLENGE
) {
4981 /* This would ignore the replys that come in after their due time */
4982 if (cookie
== ar
->arHBChallengeResp
.seqNum
) {
4983 ar
->arHBChallengeResp
.outstanding
= false;
4990 ar6000_reportError_event(struct ar6_softc
*ar
, WMI_TARGET_ERROR_VAL errorVal
)
4992 static const char * const errString
[] = {
4993 [WMI_TARGET_PM_ERR_FAIL
] "WMI_TARGET_PM_ERR_FAIL",
4994 [WMI_TARGET_KEY_NOT_FOUND
] "WMI_TARGET_KEY_NOT_FOUND",
4995 [WMI_TARGET_DECRYPTION_ERR
] "WMI_TARGET_DECRYPTION_ERR",
4996 [WMI_TARGET_BMISS
] "WMI_TARGET_BMISS",
4997 [WMI_PSDISABLE_NODE_JOIN
] "WMI_PSDISABLE_NODE_JOIN"
5000 A_PRINTF("AR6000 Error on Target. Error = 0x%x\n", errorVal
);
5002 /* One error is reported at a time, and errorval is a bitmask */
5003 if(errorVal
& (errorVal
- 1))
5006 A_PRINTF("AR6000 Error type = ");
5009 case WMI_TARGET_PM_ERR_FAIL
:
5010 case WMI_TARGET_KEY_NOT_FOUND
:
5011 case WMI_TARGET_DECRYPTION_ERR
:
5012 case WMI_TARGET_BMISS
:
5013 case WMI_PSDISABLE_NODE_JOIN
:
5014 A_PRINTF("%s\n", errString
[errorVal
]);
5017 A_PRINTF("INVALID\n");
5025 ar6000_cac_event(struct ar6_softc
*ar
, u8 ac
, u8 cacIndication
,
5026 u8 statusCode
, u8
*tspecSuggestion
)
5028 WMM_TSPEC_IE
*tspecIe
;
5031 * This is the TSPEC IE suggestion from AP.
5032 * Suggestion provided by AP under some error
5033 * cases, could be helpful for the host app.
5034 * Check documentation.
5036 tspecIe
= (WMM_TSPEC_IE
*)tspecSuggestion
;
5039 * What do we do, if we get TSPEC rejection? One thought
5040 * that comes to mind is implictly delete the pstream...
5042 A_PRINTF("AR6000 CAC notification. "
5043 "AC = %d, cacIndication = 0x%x, statusCode = 0x%x\n",
5044 ac
, cacIndication
, statusCode
);
5048 ar6000_channel_change_event(struct ar6_softc
*ar
, u16 oldChannel
,
5051 A_PRINTF("Channel Change notification\nOld Channel: %d, New Channel: %d\n",
5052 oldChannel
, newChannel
);
5055 #define AR6000_PRINT_BSSID(_pBss) do { \
5056 A_PRINTF("%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ",\
5057 (_pBss)[0],(_pBss)[1],(_pBss)[2],(_pBss)[3],\
5058 (_pBss)[4],(_pBss)[5]); \
5062 ar6000_roam_tbl_event(struct ar6_softc
*ar
, WMI_TARGET_ROAM_TBL
*pTbl
)
5066 A_PRINTF("ROAM TABLE NO OF ENTRIES is %d ROAM MODE is %d\n",
5067 pTbl
->numEntries
, pTbl
->roamMode
);
5068 for (i
= 0; i
< pTbl
->numEntries
; i
++) {
5069 A_PRINTF("[%d]bssid %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x ", i
,
5070 pTbl
->bssRoamInfo
[i
].bssid
[0], pTbl
->bssRoamInfo
[i
].bssid
[1],
5071 pTbl
->bssRoamInfo
[i
].bssid
[2],
5072 pTbl
->bssRoamInfo
[i
].bssid
[3],
5073 pTbl
->bssRoamInfo
[i
].bssid
[4],
5074 pTbl
->bssRoamInfo
[i
].bssid
[5]);
5075 A_PRINTF("RSSI %d RSSIDT %d LAST RSSI %d UTIL %d ROAM_UTIL %d"
5077 pTbl
->bssRoamInfo
[i
].rssi
,
5078 pTbl
->bssRoamInfo
[i
].rssidt
,
5079 pTbl
->bssRoamInfo
[i
].last_rssi
,
5080 pTbl
->bssRoamInfo
[i
].util
,
5081 pTbl
->bssRoamInfo
[i
].roam_util
,
5082 pTbl
->bssRoamInfo
[i
].bias
);
5087 ar6000_wow_list_event(struct ar6_softc
*ar
, u8 num_filters
, WMI_GET_WOW_LIST_REPLY
*wow_reply
)
5091 /*Each event now contains exactly one filter, see bug 26613*/
5092 A_PRINTF("WOW pattern %d of %d patterns\n", wow_reply
->this_filter_num
, wow_reply
->num_filters
);
5093 A_PRINTF("wow mode = %s host mode = %s\n",
5094 (wow_reply
->wow_mode
== 0? "disabled":"enabled"),
5095 (wow_reply
->host_mode
== 1 ? "awake":"asleep"));
5098 /*If there are no patterns, the reply will only contain generic
5099 WoW information. Pattern information will exist only if there are
5100 patterns present. Bug 26716*/
5102 /* If this event contains pattern information, display it*/
5103 if (wow_reply
->this_filter_num
) {
5105 A_PRINTF("id=%d size=%d offset=%d\n",
5106 wow_reply
->wow_filters
[i
].wow_filter_id
,
5107 wow_reply
->wow_filters
[i
].wow_filter_size
,
5108 wow_reply
->wow_filters
[i
].wow_filter_offset
);
5109 A_PRINTF("wow pattern = ");
5110 for (j
=0; j
< wow_reply
->wow_filters
[i
].wow_filter_size
; j
++) {
5111 A_PRINTF("%2.2x",wow_reply
->wow_filters
[i
].wow_filter_pattern
[j
]);
5114 A_PRINTF("\nwow mask = ");
5115 for (j
=0; j
< wow_reply
->wow_filters
[i
].wow_filter_size
; j
++) {
5116 A_PRINTF("%2.2x",wow_reply
->wow_filters
[i
].wow_filter_mask
[j
]);
5123 * Report the Roaming related data collected on the target
5126 ar6000_display_roam_time(WMI_TARGET_ROAM_TIME
*p
)
5128 A_PRINTF("Disconnect Data : BSSID: ");
5129 AR6000_PRINT_BSSID(p
->disassoc_bssid
);
5130 A_PRINTF(" RSSI %d DISASSOC Time %d NO_TXRX_TIME %d\n",
5131 p
->disassoc_bss_rssi
,p
->disassoc_time
,
5133 A_PRINTF("Connect Data: BSSID: ");
5134 AR6000_PRINT_BSSID(p
->assoc_bssid
);
5135 A_PRINTF(" RSSI %d ASSOC Time %d TXRX_TIME %d\n",
5136 p
->assoc_bss_rssi
,p
->assoc_time
,
5137 p
->allow_txrx_time
);
5141 ar6000_roam_data_event(struct ar6_softc
*ar
, WMI_TARGET_ROAM_DATA
*p
)
5143 switch (p
->roamDataType
) {
5144 case ROAM_DATA_TIME
:
5145 ar6000_display_roam_time(&p
->u
.roamTime
);
5153 ar6000_bssInfo_event_rx(struct ar6_softc
*ar
, u8
*datap
, int len
)
5155 struct sk_buff
*skb
;
5156 WMI_BSS_INFO_HDR
*bih
= (WMI_BSS_INFO_HDR
*)datap
;
5159 if (!ar
->arMgmtFilter
) {
5162 if (((ar
->arMgmtFilter
& IEEE80211_FILTER_TYPE_BEACON
) &&
5163 (bih
->frameType
!= BEACON_FTYPE
)) ||
5164 ((ar
->arMgmtFilter
& IEEE80211_FILTER_TYPE_PROBE_RESP
) &&
5165 (bih
->frameType
!= PROBERESP_FTYPE
)))
5170 if ((skb
= A_NETBUF_ALLOC_RAW(len
)) != NULL
) {
5172 A_NETBUF_PUT(skb
, len
);
5173 memcpy(A_NETBUF_DATA(skb
), datap
, len
);
5174 skb
->dev
= ar
->arNetDev
;
5175 memcpy(skb_mac_header(skb
), A_NETBUF_DATA(skb
), 6);
5176 skb
->ip_summed
= CHECKSUM_NONE
;
5177 skb
->pkt_type
= PACKET_OTHERHOST
;
5178 skb
->protocol
= __constant_htons(0x0019);
5186 ar6000_control_tx(void *devt
, void *osbuf
, HTC_ENDPOINT_ID eid
)
5188 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
5190 struct ar_cookie
*cookie
= NULL
;
5193 if (ar
->arWowState
!= WLAN_WOW_STATE_NONE
) {
5194 A_NETBUF_FREE(osbuf
);
5197 #endif /* CONFIG_PM */
5198 /* take lock to protect ar6000_alloc_cookie() */
5199 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
5203 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX
,("ar_contrstatus = ol_tx: skb=0x%lx, len=0x%x eid =%d\n",
5204 (unsigned long)osbuf
, A_NETBUF_LEN(osbuf
), eid
));
5206 if (ar
->arWMIControlEpFull
&& (eid
== ar
->arControlEp
)) {
5207 /* control endpoint is full, don't allocate resources, we
5208 * are just going to drop this packet */
5210 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" WMI Control EP full, dropping packet : 0x%lX, len:%d \n",
5211 (unsigned long)osbuf
, A_NETBUF_LEN(osbuf
)));
5213 cookie
= ar6000_alloc_cookie(ar
);
5216 if (cookie
== NULL
) {
5217 status
= A_NO_MEMORY
;
5222 A_PRINTF("WMI cmd send, msgNo %d :", wmiSendCmdNum
);
5223 for(i
= 0; i
< a_netbuf_to_len(osbuf
); i
++)
5224 A_PRINTF("%x ", ((u8
*)a_netbuf_to_data(osbuf
))[i
]);
5232 if (cookie
!= NULL
) {
5233 /* got a structure to send it out on */
5234 ar
->arTxPending
[eid
]++;
5236 if (eid
!= ar
->arControlEp
) {
5237 ar
->arTotalTxDataPending
++;
5241 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
5243 if (cookie
!= NULL
) {
5244 cookie
->arc_bp
[0] = (unsigned long)osbuf
;
5245 cookie
->arc_bp
[1] = 0;
5246 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
5248 A_NETBUF_DATA(osbuf
),
5249 A_NETBUF_LEN(osbuf
),
5251 AR6K_CONTROL_PKT_TAG
);
5252 /* this interface is asynchronous, if there is an error, cleanup will happen in the
5253 * TX completion callback */
5254 HTCSendPkt(ar
->arHtcTarget
, &cookie
->HtcPkt
);
5259 A_NETBUF_FREE(osbuf
);
5264 /* indicate tx activity or inactivity on a WMI stream */
5265 void ar6000_indicate_tx_activity(void *devt
, u8 TrafficClass
, bool Active
)
5267 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
5268 HTC_ENDPOINT_ID eid
;
5271 if (ar
->arWmiEnabled
) {
5272 eid
= arAc2EndpointID(ar
, TrafficClass
);
5274 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
5276 ar
->arAcStreamActive
[TrafficClass
] = Active
;
5279 /* when a stream goes active, keep track of the active stream with the highest priority */
5281 if (ar
->arAcStreamPriMap
[TrafficClass
] > ar
->arHiAcStreamActivePri
) {
5282 /* set the new highest active priority */
5283 ar
->arHiAcStreamActivePri
= ar
->arAcStreamPriMap
[TrafficClass
];
5287 /* when a stream goes inactive, we may have to search for the next active stream
5288 * that is the highest priority */
5290 if (ar
->arHiAcStreamActivePri
== ar
->arAcStreamPriMap
[TrafficClass
]) {
5292 /* the highest priority stream just went inactive */
5294 /* reset and search for the "next" highest "active" priority stream */
5295 ar
->arHiAcStreamActivePri
= 0;
5296 for (i
= 0; i
< WMM_NUM_AC
; i
++) {
5297 if (ar
->arAcStreamActive
[i
]) {
5298 if (ar
->arAcStreamPriMap
[i
] > ar
->arHiAcStreamActivePri
) {
5299 /* set the new highest active priority */
5300 ar
->arHiAcStreamActivePri
= ar
->arAcStreamPriMap
[i
];
5307 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
5310 /* for mbox ping testing, the traffic class is mapped directly as a stream ID,
5311 * see handling of AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE in ioctl.c
5312 * convert the stream ID to a endpoint */
5313 eid
= arAc2EndpointID(ar
, TrafficClass
);
5316 /* notify HTC, this may cause credit distribution changes */
5318 HTCIndicateActivityChange(ar
->arHtcTarget
,
5325 ar6000_btcoex_config_event(struct ar6_softc
*ar
, u8
*ptr
, u32 len
)
5328 WMI_BTCOEX_CONFIG_EVENT
*pBtcoexConfig
= (WMI_BTCOEX_CONFIG_EVENT
*)ptr
;
5329 WMI_BTCOEX_CONFIG_EVENT
*pArbtcoexConfig
=&ar
->arBtcoexConfig
;
5331 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("AR6000 BTCOEX CONFIG EVENT \n"));
5333 A_PRINTF("received config event\n");
5334 pArbtcoexConfig
->btProfileType
= pBtcoexConfig
->btProfileType
;
5335 pArbtcoexConfig
->linkId
= pBtcoexConfig
->linkId
;
5337 switch (pBtcoexConfig
->btProfileType
) {
5338 case WMI_BTCOEX_BT_PROFILE_SCO
:
5339 memcpy(&pArbtcoexConfig
->info
.scoConfigCmd
, &pBtcoexConfig
->info
.scoConfigCmd
,
5340 sizeof(WMI_SET_BTCOEX_SCO_CONFIG_CMD
));
5342 case WMI_BTCOEX_BT_PROFILE_A2DP
:
5343 memcpy(&pArbtcoexConfig
->info
.a2dpConfigCmd
, &pBtcoexConfig
->info
.a2dpConfigCmd
,
5344 sizeof(WMI_SET_BTCOEX_A2DP_CONFIG_CMD
));
5346 case WMI_BTCOEX_BT_PROFILE_ACLCOEX
:
5347 memcpy(&pArbtcoexConfig
->info
.aclcoexConfig
, &pBtcoexConfig
->info
.aclcoexConfig
,
5348 sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD
));
5350 case WMI_BTCOEX_BT_PROFILE_INQUIRY_PAGE
:
5351 memcpy(&pArbtcoexConfig
->info
.btinquiryPageConfigCmd
, &pBtcoexConfig
->info
.btinquiryPageConfigCmd
,
5352 sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD
));
5355 if (ar
->statsUpdatePending
) {
5356 ar
->statsUpdatePending
= false;
5362 ar6000_btcoex_stats_event(struct ar6_softc
*ar
, u8
*ptr
, u32 len
)
5364 WMI_BTCOEX_STATS_EVENT
*pBtcoexStats
= (WMI_BTCOEX_STATS_EVENT
*)ptr
;
5366 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("AR6000 BTCOEX CONFIG EVENT \n"));
5368 memcpy(&ar
->arBtcoexStats
, pBtcoexStats
, sizeof(WMI_BTCOEX_STATS_EVENT
));
5370 if (ar
->statsUpdatePending
) {
5371 ar
->statsUpdatePending
= false;
5376 module_init(ar6000_init_module
);
5377 module_exit(ar6000_cleanup_module
);
5379 /* Init cookie queue */
5381 ar6000_cookie_init(struct ar6_softc
*ar
)
5385 ar
->arCookieList
= NULL
;
5386 ar
->arCookieCount
= 0;
5388 A_MEMZERO(s_ar_cookie_mem
, sizeof(s_ar_cookie_mem
));
5390 for (i
= 0; i
< MAX_COOKIE_NUM
; i
++) {
5391 ar6000_free_cookie(ar
, &s_ar_cookie_mem
[i
]);
5395 /* cleanup cookie queue */
5397 ar6000_cookie_cleanup(struct ar6_softc
*ar
)
5399 /* It is gone .... */
5400 ar
->arCookieList
= NULL
;
5401 ar
->arCookieCount
= 0;
5404 /* Init cookie queue */
5406 ar6000_free_cookie(struct ar6_softc
*ar
, struct ar_cookie
* cookie
)
5409 A_ASSERT(ar
!= NULL
);
5410 A_ASSERT(cookie
!= NULL
);
5412 cookie
->arc_list_next
= ar
->arCookieList
;
5413 ar
->arCookieList
= cookie
;
5414 ar
->arCookieCount
++;
5417 /* cleanup cookie queue */
5418 static struct ar_cookie
*
5419 ar6000_alloc_cookie(struct ar6_softc
*ar
)
5421 struct ar_cookie
*cookie
;
5423 cookie
= ar
->arCookieList
;
5426 ar
->arCookieList
= cookie
->arc_list_next
;
5427 ar
->arCookieCount
--;
5434 ar6000_tx_retry_err_event(void *devt
)
5436 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Tx retries reach maximum!\n"));
5440 ar6000_snrThresholdEvent_rx(void *devt
, WMI_SNR_THRESHOLD_VAL newThreshold
, u8 snr
)
5442 WMI_SNR_THRESHOLD_EVENT event
;
5444 event
.range
= newThreshold
;
5449 ar6000_lqThresholdEvent_rx(void *devt
, WMI_LQ_THRESHOLD_VAL newThreshold
, u8 lq
)
5451 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
,("lq threshold range %d, lq %d\n", newThreshold
, lq
));
5456 u32
a_copy_to_user(void *to
, const void *from
, u32 n
)
5458 return(copy_to_user(to
, from
, n
));
5461 u32
a_copy_from_user(void *to
, const void *from
, u32 n
)
5463 return(copy_from_user(to
, from
, n
));
5468 ar6000_get_driver_cfg(struct net_device
*dev
,
5477 case AR6000_DRIVER_CFG_GET_WLANNODECACHING
:
5478 *((u32
*)result
) = wlanNodeCaching
;
5480 case AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS
:
5481 *((u32
*)result
) = logWmiRawMsgs
;
5492 ar6000_keepalive_rx(void *devt
, u8 configured
)
5494 struct ar6_softc
*ar
= (struct ar6_softc
*)devt
;
5496 ar
->arKeepaliveConfigured
= configured
;
5501 ar6000_pmkid_list_event(void *devt
, u8 numPMKID
, WMI_PMKID
*pmkidList
,
5506 A_PRINTF("Number of Cached PMKIDs is %d\n", numPMKID
);
5508 for (i
= 0; i
< numPMKID
; i
++) {
5509 A_PRINTF("\nBSSID %d ", i
);
5510 for (j
= 0; j
< ATH_MAC_LEN
; j
++) {
5511 A_PRINTF("%2.2x", bssidList
[j
]);
5513 bssidList
+= (ATH_MAC_LEN
+ WMI_PMKID_LEN
);
5514 A_PRINTF("\nPMKID %d ", i
);
5515 for (j
= 0; j
< WMI_PMKID_LEN
; j
++) {
5516 A_PRINTF("%2.2x", pmkidList
->pmkid
[j
]);
5518 pmkidList
= (WMI_PMKID
*)((u8
*)pmkidList
+ ATH_MAC_LEN
+
5523 void ar6000_pspoll_event(struct ar6_softc
*ar
,u8 aid
)
5526 bool isPsqEmpty
= false;
5528 conn
= ieee80211_find_conn_for_aid(ar
, aid
);
5530 /* If the PS q for this STA is not empty, dequeue and send a pkt from
5531 * the head of the q. Also update the More data bit in the WMI_DATA_HDR
5532 * if there are more pkts for this STA in the PS q. If there are no more
5533 * pkts for this STA, update the PVB for this STA.
5535 A_MUTEX_LOCK(&conn
->psqLock
);
5536 isPsqEmpty
= A_NETBUF_QUEUE_EMPTY(&conn
->psq
);
5537 A_MUTEX_UNLOCK(&conn
->psqLock
);
5540 /* TODO:No buffered pkts for this STA. Send out a NULL data frame */
5542 struct sk_buff
*skb
= NULL
;
5544 A_MUTEX_LOCK(&conn
->psqLock
);
5545 skb
= A_NETBUF_DEQUEUE(&conn
->psq
);
5546 A_MUTEX_UNLOCK(&conn
->psqLock
);
5547 /* Set the STA flag to PSPolled, so that the frame will go out */
5548 STA_SET_PS_POLLED(conn
);
5549 ar6000_data_tx(skb
, ar
->arNetDev
);
5550 STA_CLR_PS_POLLED(conn
);
5552 /* Clear the PVB for this STA if the queue has become empty */
5553 A_MUTEX_LOCK(&conn
->psqLock
);
5554 isPsqEmpty
= A_NETBUF_QUEUE_EMPTY(&conn
->psq
);
5555 A_MUTEX_UNLOCK(&conn
->psqLock
);
5558 wmi_set_pvb_cmd(ar
->arWmi
, conn
->aid
, 0);
5563 void ar6000_dtimexpiry_event(struct ar6_softc
*ar
)
5565 bool isMcastQueued
= false;
5566 struct sk_buff
*skb
= NULL
;
5568 /* If there are no associated STAs, ignore the DTIM expiry event.
5569 * There can be potential race conditions where the last associated
5570 * STA may disconnect & before the host could clear the 'Indicate DTIM'
5571 * request to the firmware, the firmware would have just indicated a DTIM
5572 * expiry event. The race is between 'clear DTIM expiry cmd' going
5573 * from the host to the firmware & the DTIM expiry event happening from
5574 * the firmware to the host.
5576 if (ar
->sta_list_index
== 0) {
5580 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
5581 isMcastQueued
= A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
);
5582 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
5584 A_ASSERT(isMcastQueued
== false);
5586 /* Flush the mcast psq to the target */
5587 /* Set the STA flag to DTIMExpired, so that the frame will go out */
5588 ar
->DTIMExpired
= true;
5590 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
5591 while (!A_NETBUF_QUEUE_EMPTY(&ar
->mcastpsq
)) {
5592 skb
= A_NETBUF_DEQUEUE(&ar
->mcastpsq
);
5593 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
5595 ar6000_data_tx(skb
, ar
->arNetDev
);
5597 A_MUTEX_LOCK(&ar
->mcastpsqLock
);
5599 A_MUTEX_UNLOCK(&ar
->mcastpsqLock
);
5601 /* Reset the DTIMExpired flag back to 0 */
5602 ar
->DTIMExpired
= false;
5604 /* Clear the LSB of the BitMapCtl field of the TIM IE */
5605 wmi_set_pvb_cmd(ar
->arWmi
, MCAST_AID
, 0);
5609 read_rssi_compensation_param(struct ar6_softc
*ar
)
5613 //#define RSSICOMPENSATION_PRINT
5615 #ifdef RSSICOMPENSATION_PRINT
5617 cust_data_ptr
= ar6000_get_cust_data_buffer(ar
->arTargetType
);
5618 for (i
=0; i
<16; i
++) {
5619 A_PRINTF("cust_data_%d = %x \n", i
, *(u8
*)cust_data_ptr
);
5624 cust_data_ptr
= ar6000_get_cust_data_buffer(ar
->arTargetType
);
5626 rssi_compensation_param
.customerID
= *(u16
*)cust_data_ptr
& 0xffff;
5627 rssi_compensation_param
.enable
= *(u16
*)(cust_data_ptr
+2) & 0xffff;
5628 rssi_compensation_param
.bg_param_a
= *(u16
*)(cust_data_ptr
+4) & 0xffff;
5629 rssi_compensation_param
.bg_param_b
= *(u16
*)(cust_data_ptr
+6) & 0xffff;
5630 rssi_compensation_param
.a_param_a
= *(u16
*)(cust_data_ptr
+8) & 0xffff;
5631 rssi_compensation_param
.a_param_b
= *(u16
*)(cust_data_ptr
+10) &0xffff;
5632 rssi_compensation_param
.reserved
= *(u32
*)(cust_data_ptr
+12);
5634 #ifdef RSSICOMPENSATION_PRINT
5635 A_PRINTF("customerID = 0x%x \n", rssi_compensation_param
.customerID
);
5636 A_PRINTF("enable = 0x%x \n", rssi_compensation_param
.enable
);
5637 A_PRINTF("bg_param_a = 0x%x and %d \n", rssi_compensation_param
.bg_param_a
, rssi_compensation_param
.bg_param_a
);
5638 A_PRINTF("bg_param_b = 0x%x and %d \n", rssi_compensation_param
.bg_param_b
, rssi_compensation_param
.bg_param_b
);
5639 A_PRINTF("a_param_a = 0x%x and %d \n", rssi_compensation_param
.a_param_a
, rssi_compensation_param
.a_param_a
);
5640 A_PRINTF("a_param_b = 0x%x and %d \n", rssi_compensation_param
.a_param_b
, rssi_compensation_param
.a_param_b
);
5641 A_PRINTF("Last 4 bytes = 0x%x \n", rssi_compensation_param
.reserved
);
5644 if (rssi_compensation_param
.enable
!= 0x1) {
5645 rssi_compensation_param
.enable
= 0;
5651 s32
rssi_compensation_calc_tcmd(u32 freq
, s32 rssi
, u32 totalPkt
)
5656 if (rssi_compensation_param
.enable
)
5658 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11a\n"));
5659 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d, totalPkt = %d\n", rssi
,totalPkt
));
5660 rssi
= rssi
* rssi_compensation_param
.a_param_a
+ totalPkt
* rssi_compensation_param
.a_param_b
;
5661 rssi
= (rssi
-50) /100;
5662 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5667 if (rssi_compensation_param
.enable
)
5669 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11bg\n"));
5670 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d, totalPkt = %d\n", rssi
,totalPkt
));
5671 rssi
= rssi
* rssi_compensation_param
.bg_param_a
+ totalPkt
* rssi_compensation_param
.bg_param_b
;
5672 rssi
= (rssi
-50) /100;
5673 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5680 s16
rssi_compensation_calc(struct ar6_softc
*ar
, s16 rssi
)
5682 if (ar
->arBssChannel
> 5000)
5684 if (rssi_compensation_param
.enable
)
5686 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11a\n"));
5687 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d\n", rssi
));
5688 rssi
= rssi
* rssi_compensation_param
.a_param_a
+ rssi_compensation_param
.a_param_b
;
5689 rssi
= (rssi
-50) /100;
5690 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5695 if (rssi_compensation_param
.enable
)
5697 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11bg\n"));
5698 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before compensation = %d\n", rssi
));
5699 rssi
= rssi
* rssi_compensation_param
.bg_param_a
+ rssi_compensation_param
.bg_param_b
;
5700 rssi
= (rssi
-50) /100;
5701 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after compensation = %d\n", rssi
));
5708 s16
rssi_compensation_reverse_calc(struct ar6_softc
*ar
, s16 rssi
, bool Above
)
5712 if (ar
->arBssChannel
> 5000)
5714 if (rssi_compensation_param
.enable
)
5716 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11a\n"));
5717 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before rev compensation = %d\n", rssi
));
5719 rssi
= (rssi
- rssi_compensation_param
.a_param_b
) / rssi_compensation_param
.a_param_a
;
5720 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after rev compensation = %d\n", rssi
));
5725 if (rssi_compensation_param
.enable
)
5727 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, (">>> 11bg\n"));
5728 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi before rev compensation = %d\n", rssi
));
5731 for (i
=95; i
>=0; i
--) {
5732 if (rssi
<= rssi_compensation_table
[i
]) {
5738 for (i
=0; i
<=95; i
++) {
5739 if (rssi
>= rssi_compensation_table
[i
]) {
5745 AR_DEBUG_PRINTF(ATH_DEBUG_INFO
, ("rssi after rev compensation = %d\n", rssi
));
5753 void ap_wapi_rekey_event(struct ar6_softc
*ar
, u8 type
, u8
*mac
)
5755 union iwreq_data wrqu
;
5758 A_MEMZERO(buf
, sizeof(buf
));
5760 strcpy(buf
, "WAPI_REKEY");
5762 memcpy(&buf
[11], mac
, ATH_MAC_LEN
);
5764 A_MEMZERO(&wrqu
, sizeof(wrqu
));
5765 wrqu
.data
.length
= 10+1+ATH_MAC_LEN
;
5766 wireless_send_event(ar
->arNetDev
, IWEVCUSTOM
, &wrqu
, buf
);
5768 A_PRINTF("WAPI REKEY - %d - %02x:%02x\n", type
, mac
[4], mac
[5]);
5773 ar6000_reinstall_keys(struct ar6_softc
*ar
, u8 key_op_ctrl
)
5776 struct ieee80211req_key
*uik
= &ar
->user_saved_keys
.ucast_ik
;
5777 struct ieee80211req_key
*bik
= &ar
->user_saved_keys
.bcast_ik
;
5778 CRYPTO_TYPE keyType
= ar
->user_saved_keys
.keyType
;
5780 if (IEEE80211_CIPHER_CCKM_KRK
!= uik
->ik_type
) {
5781 if (NONE_CRYPT
== keyType
) {
5782 goto _reinstall_keys_out
;
5785 if (uik
->ik_keylen
) {
5786 status
= wmi_addKey_cmd(ar
->arWmi
, uik
->ik_keyix
,
5787 ar
->user_saved_keys
.keyType
, PAIRWISE_USAGE
,
5788 uik
->ik_keylen
, (u8
*)&uik
->ik_keyrsc
,
5789 uik
->ik_keydata
, key_op_ctrl
, uik
->ik_macaddr
, SYNC_BEFORE_WMIFLAG
);
5793 status
= wmi_add_krk_cmd(ar
->arWmi
, uik
->ik_keydata
);
5796 if (IEEE80211_CIPHER_CCKM_KRK
!= bik
->ik_type
) {
5797 if (NONE_CRYPT
== keyType
) {
5798 goto _reinstall_keys_out
;
5801 if (bik
->ik_keylen
) {
5802 status
= wmi_addKey_cmd(ar
->arWmi
, bik
->ik_keyix
,
5803 ar
->user_saved_keys
.keyType
, GROUP_USAGE
,
5804 bik
->ik_keylen
, (u8
*)&bik
->ik_keyrsc
,
5805 bik
->ik_keydata
, key_op_ctrl
, bik
->ik_macaddr
, NO_SYNC_WMIFLAG
);
5808 status
= wmi_add_krk_cmd(ar
->arWmi
, bik
->ik_keydata
);
5811 _reinstall_keys_out
:
5812 ar
->user_savedkeys_stat
= USER_SAVEDKEYS_STAT_INIT
;
5813 ar
->user_key_ctrl
= 0;
5820 ar6000_dset_open_req(
5838 ar6000_dset_data_req(
5850 ar6000_ap_mode_profile_commit(struct ar6_softc
*ar
)
5853 unsigned long flags
;
5855 /* No change in AP's profile configuration */
5856 if(ar
->ap_profile_flag
==0) {
5857 A_PRINTF("COMMIT: No change in profile!!!\n");
5861 if(!ar
->arSsidLen
) {
5862 A_PRINTF("SSID not set!!!\n");
5866 switch(ar
->arAuthMode
) {
5868 if((ar
->arPairwiseCrypto
!= NONE_CRYPT
) &&
5870 (ar
->arPairwiseCrypto
!= WAPI_CRYPT
) &&
5872 (ar
->arPairwiseCrypto
!= WEP_CRYPT
)) {
5873 A_PRINTF("Cipher not supported in AP mode Open auth\n");
5879 case (WPA_PSK_AUTH
|WPA2_PSK_AUTH
):
5882 A_PRINTF("This key mgmt type not supported in AP mode\n");
5886 /* Update the arNetworkType */
5887 ar
->arNetworkType
= ar
->arNextMode
;
5889 A_MEMZERO(&p
,sizeof(p
));
5890 p
.ssidLength
= ar
->arSsidLen
;
5891 memcpy(p
.ssid
,ar
->arSsid
,p
.ssidLength
);
5892 p
.channel
= ar
->arChannelHint
;
5893 p
.networkType
= ar
->arNetworkType
;
5895 p
.dot11AuthMode
= ar
->arDot11AuthMode
;
5896 p
.authMode
= ar
->arAuthMode
;
5897 p
.pairwiseCryptoType
= ar
->arPairwiseCrypto
;
5898 p
.pairwiseCryptoLen
= ar
->arPairwiseCryptoLen
;
5899 p
.groupCryptoType
= ar
->arGroupCrypto
;
5900 p
.groupCryptoLen
= ar
->arGroupCryptoLen
;
5901 p
.ctrl_flags
= ar
->arConnectCtrlFlags
;
5903 wmi_ap_profile_commit(ar
->arWmi
, &p
);
5904 spin_lock_irqsave(&ar
->arLock
, flags
);
5905 ar
->arConnected
= true;
5906 netif_carrier_on(ar
->arNetDev
);
5907 spin_unlock_irqrestore(&ar
->arLock
, flags
);
5908 ar
->ap_profile_flag
= 0;
5913 ar6000_connect_to_ap(struct ar6_softc
*ar
)
5915 /* The ssid length check prevents second "essid off" from the user,
5916 to be treated as a connect cmd. The second "essid off" is ignored.
5918 if((ar
->arWmiReady
== true) && (ar
->arSsidLen
> 0) && ar
->arNetworkType
!=AP_NETWORK
)
5921 if((ADHOC_NETWORK
!= ar
->arNetworkType
) &&
5922 (NONE_AUTH
==ar
->arAuthMode
) &&
5923 (WEP_CRYPT
==ar
->arPairwiseCrypto
)) {
5924 ar6000_install_static_wep_keys(ar
);
5927 if (!ar
->arUserBssFilter
) {
5928 if (wmi_bssfilter_cmd(ar
->arWmi
, ALL_BSS_FILTER
, 0) != 0) {
5933 if (ar
->arWapiEnable
) {
5934 ar
->arPairwiseCrypto
= WAPI_CRYPT
;
5935 ar
->arPairwiseCryptoLen
= 0;
5936 ar
->arGroupCrypto
= WAPI_CRYPT
;
5937 ar
->arGroupCryptoLen
= 0;
5938 ar
->arAuthMode
= NONE_AUTH
;
5939 ar
->arConnectCtrlFlags
|= CONNECT_IGNORE_WPAx_GROUP_CIPHER
;
5942 AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT
,("Connect called with authmode %d dot11 auth %d"\
5943 " PW crypto %d PW crypto Len %d GRP crypto %d"\
5944 " GRP crypto Len %d\n",
5945 ar
->arAuthMode
, ar
->arDot11AuthMode
,
5946 ar
->arPairwiseCrypto
, ar
->arPairwiseCryptoLen
,
5947 ar
->arGroupCrypto
, ar
->arGroupCryptoLen
));
5949 /* Set the listen interval into 1000TUs or more. This value will be indicated to Ap in the conn.
5950 later set it back locally at the STA to 100/1000 TUs depending on the power mode */
5951 if ((ar
->arNetworkType
== INFRA_NETWORK
)) {
5952 wmi_listeninterval_cmd(ar
->arWmi
, max(ar
->arListenIntervalT
, (u16
)A_MAX_WOW_LISTEN_INTERVAL
), 0);
5954 status
= wmi_connect_cmd(ar
->arWmi
, ar
->arNetworkType
,
5955 ar
->arDot11AuthMode
, ar
->arAuthMode
,
5956 ar
->arPairwiseCrypto
, ar
->arPairwiseCryptoLen
,
5957 ar
->arGroupCrypto
,ar
->arGroupCryptoLen
,
5958 ar
->arSsidLen
, ar
->arSsid
,
5959 ar
->arReqBssid
, ar
->arChannelHint
,
5960 ar
->arConnectCtrlFlags
);
5962 wmi_listeninterval_cmd(ar
->arWmi
, ar
->arListenIntervalT
, ar
->arListenIntervalB
);
5963 if (!ar
->arUserBssFilter
) {
5964 wmi_bssfilter_cmd(ar
->arWmi
, NONE_BSS_FILTER
, 0);
5969 if ((!(ar
->arConnectCtrlFlags
& CONNECT_DO_WPA_OFFLOAD
)) &&
5970 ((WPA_PSK_AUTH
== ar
->arAuthMode
) || (WPA2_PSK_AUTH
== ar
->arAuthMode
)))
5972 A_TIMEOUT_MS(&ar
->disconnect_timer
, A_DISCONNECT_TIMER_INTERVAL
, 0);
5975 ar
->arConnectCtrlFlags
&= ~CONNECT_DO_WPA_OFFLOAD
;
5977 ar
->arConnectPending
= true;
5984 ar6000_disconnect(struct ar6_softc
*ar
)
5986 if ((ar
->arConnected
== true) || (ar
->arConnectPending
== true)) {
5987 wmi_disconnect_cmd(ar
->arWmi
);
5989 * Disconnect cmd is issued, clear connectPending.
5990 * arConnected will be cleard in disconnect_event notification.
5992 ar
->arConnectPending
= false;
5999 ar6000_ap_mode_get_wpa_ie(struct ar6_softc
*ar
, struct ieee80211req_wpaie
*wpaie
)
6002 conn
= ieee80211_find_conn(ar
, wpaie
->wpa_macaddr
);
6004 A_MEMZERO(wpaie
->wpa_ie
, IEEE80211_MAX_IE
);
6005 A_MEMZERO(wpaie
->rsn_ie
, IEEE80211_MAX_IE
);
6008 memcpy(wpaie
->wpa_ie
, conn
->wpa_ie
, IEEE80211_MAX_IE
);
6015 is_iwioctl_allowed(u8 mode
, u16 cmd
)
6017 if(cmd
>= SIOCSIWCOMMIT
&& cmd
<= SIOCGIWPOWER
) {
6018 cmd
-= SIOCSIWCOMMIT
;
6019 if(sioctl_filter
[cmd
] == 0xFF) return 0;
6020 if(sioctl_filter
[cmd
] & mode
) return 0;
6021 } else if(cmd
>= SIOCIWFIRSTPRIV
&& cmd
<= (SIOCIWFIRSTPRIV
+30)) {
6022 cmd
-= SIOCIWFIRSTPRIV
;
6023 if(pioctl_filter
[cmd
] == 0xFF) return 0;
6024 if(pioctl_filter
[cmd
] & mode
) return 0;
6032 is_xioctl_allowed(u8 mode
, int cmd
)
6034 if(sizeof(xioctl_filter
)-1 < cmd
) {
6035 A_PRINTF("Filter for this cmd=%d not defined\n",cmd
);
6038 if(xioctl_filter
[cmd
] == 0xFF) return 0;
6039 if(xioctl_filter
[cmd
] & mode
) return 0;
6045 ap_set_wapi_key(struct ar6_softc
*ar
, void *ikey
)
6047 struct ieee80211req_key
*ik
= (struct ieee80211req_key
*)ikey
;
6048 KEY_USAGE keyUsage
= 0;
6051 if (memcmp(ik
->ik_macaddr
, bcast_mac
, IEEE80211_ADDR_LEN
) == 0) {
6052 keyUsage
= GROUP_USAGE
;
6054 keyUsage
= PAIRWISE_USAGE
;
6056 A_PRINTF("WAPI_KEY: Type:%d ix:%d mac:%02x:%02x len:%d\n",
6057 keyUsage
, ik
->ik_keyix
, ik
->ik_macaddr
[4], ik
->ik_macaddr
[5],
6060 status
= wmi_addKey_cmd(ar
->arWmi
, ik
->ik_keyix
, WAPI_CRYPT
, keyUsage
,
6061 ik
->ik_keylen
, (u8
*)&ik
->ik_keyrsc
,
6062 ik
->ik_keydata
, KEY_OP_INIT_VAL
, ik
->ik_macaddr
,
6072 void ar6000_peer_event(
6079 for (pos
=0;pos
<6;pos
++)
6080 printk("%02x: ",*(macAddr
+pos
));
6084 #ifdef HTC_TEST_SEND_PKTS
6085 #define HTC_TEST_DUPLICATE 8
6086 static void DoHTCSendPktsTest(struct ar6_softc
*ar
, int MapNo
, HTC_ENDPOINT_ID eid
, struct sk_buff
*dupskb
)
6088 struct ar_cookie
*cookie
;
6089 struct ar_cookie
*cookieArray
[HTC_TEST_DUPLICATE
];
6090 struct sk_buff
*new_skb
;
6093 struct htc_packet_queue pktQueue
;
6094 EPPING_HEADER
*eppingHdr
;
6096 eppingHdr
= A_NETBUF_DATA(dupskb
);
6098 if (eppingHdr
->Cmd_h
== EPPING_CMD_NO_ECHO
) {
6099 /* skip test if this is already a tx perf test */
6103 for (i
= 0; i
< HTC_TEST_DUPLICATE
; i
++,pkts
++) {
6104 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
6105 cookie
= ar6000_alloc_cookie(ar
);
6106 if (cookie
!= NULL
) {
6107 ar
->arTxPending
[eid
]++;
6108 ar
->arTotalTxDataPending
++;
6111 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
6113 if (NULL
== cookie
) {
6117 new_skb
= A_NETBUF_ALLOC(A_NETBUF_LEN(dupskb
));
6119 if (new_skb
== NULL
) {
6120 AR6000_SPIN_LOCK(&ar
->arLock
, 0);
6121 ar6000_free_cookie(ar
,cookie
);
6122 AR6000_SPIN_UNLOCK(&ar
->arLock
, 0);
6126 A_NETBUF_PUT_DATA(new_skb
, A_NETBUF_DATA(dupskb
), A_NETBUF_LEN(dupskb
));
6127 cookie
->arc_bp
[0] = (unsigned long)new_skb
;
6128 cookie
->arc_bp
[1] = MapNo
;
6129 SET_HTC_PACKET_INFO_TX(&cookie
->HtcPkt
,
6131 A_NETBUF_DATA(new_skb
),
6132 A_NETBUF_LEN(new_skb
),
6136 cookieArray
[i
] = cookie
;
6139 EPPING_HEADER
*pHdr
= (EPPING_HEADER
*)A_NETBUF_DATA(new_skb
);
6140 pHdr
->Cmd_h
= EPPING_CMD_NO_ECHO
; /* do not echo the packet */
6148 INIT_HTC_PACKET_QUEUE(&pktQueue
);
6150 for (i
= 0; i
< pkts
; i
++) {
6151 HTC_PACKET_ENQUEUE(&pktQueue
,&cookieArray
[i
]->HtcPkt
);
6154 HTCSendPktsMultiple(ar
->arHtcTarget
, &pktQueue
);
6159 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
6161 * Add support for adding and removing a virtual adapter for soft AP.
6162 * Some OS requires different adapters names for station and soft AP mode.
6163 * To support these requirement, create and destroy a netdevice instance
6164 * when the AP mode is operational. A full fledged support for virual device
6165 * is not implemented. Rather a virtual interface is created and is linked
6166 * with the existing physical device instance during the operation of the
6170 int ar6000_start_ap_interface(struct ar6_softc
*ar
)
6172 struct ar_virtual_interface
*arApDev
;
6174 /* Change net_device to point to AP instance */
6175 arApDev
= (struct ar_virtual_interface
*)ar
->arApDev
;
6176 ar
->arNetDev
= arApDev
->arNetDev
;
6181 int ar6000_stop_ap_interface(struct ar6_softc
*ar
)
6183 struct ar_virtual_interface
*arApDev
;
6185 /* Change net_device to point to sta instance */
6186 arApDev
= (struct ar_virtual_interface
*)ar
->arApDev
;
6188 ar
->arNetDev
= arApDev
->arStaNetDev
;
6195 int ar6000_create_ap_interface(struct ar6_softc
*ar
, char *ap_ifname
)
6197 struct net_device
*dev
;
6198 struct ar_virtual_interface
*arApDev
;
6200 dev
= alloc_etherdev(sizeof(struct ar_virtual_interface
));
6202 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_create_ap_interface: can't alloc etherdev\n"));
6207 init_netdev(dev
, ap_ifname
);
6208 dev
->priv_flags
&= ~IFF_TX_SKB_SHARING
;
6210 if (register_netdev(dev
)) {
6211 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_create_ap_interface: register_netdev failed\n"));
6215 arApDev
= netdev_priv(dev
);
6216 arApDev
->arDev
= ar
;
6217 arApDev
->arNetDev
= dev
;
6218 arApDev
->arStaNetDev
= ar
->arNetDev
;
6220 ar
->arApDev
= arApDev
;
6223 /* Copy the MAC address */
6224 memcpy(dev
->dev_addr
, ar
->arNetDev
->dev_addr
, AR6000_ETH_ADDR_LEN
);
6229 int ar6000_add_ap_interface(struct ar6_softc
*ar
, char *ap_ifname
)
6231 /* Interface already added, need not proceed further */
6232 if (ar
->arApDev
!= NULL
) {
6233 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("ar6000_add_ap_interface: interface already present \n"));
6237 if (ar6000_create_ap_interface(ar
, ap_ifname
) != 0) {
6241 A_PRINTF("Add AP interface %s \n",ap_ifname
);
6243 return ar6000_start_ap_interface(ar
);
6246 int ar6000_remove_ap_interface(struct ar6_softc
*ar
)
6249 ar6000_stop_ap_interface(ar
);
6251 unregister_netdev(arApNetDev
);
6252 free_netdev(apApNetDev
);
6254 A_PRINTF("Remove AP interface\n");
6262 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
6265 #ifdef EXPORT_HCI_BRIDGE_INTERFACE
6266 EXPORT_SYMBOL(setupbtdev
);