156
154
unsigned int hciuartscale = HCIUARTSCALE_DEFAULT;
157
155
unsigned int hciuartstep = HCIUARTSTEP_DEFAULT;
159
#ifdef CONFIG_CHECKSUM_OFFLOAD
160
157
unsigned int csumOffload=0;
161
158
unsigned int csumOffloadTest=0;
163
159
unsigned int eppingtest=0;
160
unsigned int mac_addr_method;
161
unsigned int firmware_bridge;
165
163
module_param_string(ifname, ifname, sizeof(ifname), 0644);
166
164
module_param(wlaninitmode, int, 0644);
167
module_param(bmienable, int, 0644);
168
165
module_param(bypasswmi, bool, 0644);
169
166
module_param(debuglevel, uint, 0644);
170
167
module_param(tspecCompliance, int, 0644);
182
179
module_param(allow_trace_signal, int, 0644);
183
180
module_param(enablerssicompensation, uint, 0644);
184
181
module_param(processDot11Hdr, uint, 0644);
185
#ifdef CONFIG_CHECKSUM_OFFLOAD
186
182
module_param(csumOffload, uint, 0644);
188
183
#ifdef CONFIG_HOST_TCMD_SUPPORT
189
184
module_param(testmode, uint, 0644);
192
187
module_param(nohifscattersupport, uint, 0644);
193
188
module_param(panic_on_assert, uint, 0644);
194
189
module_param(setuphci, uint, 0644);
195
module_param(setuphcipal, uint, 0644);
196
190
module_param(loghci, uint, 0644);
197
191
module_param(setupbtdev, uint, 0644);
198
192
#ifndef EXPORT_HCI_BRIDGE_INTERFACE
288
282
static void ar6000_detect_error(unsigned long ptr);
289
283
static void ar6000_set_multicast_list(struct net_device *dev);
290
284
static struct net_device_stats *ar6000_get_stats(struct net_device *dev);
291
static struct iw_statistics *ar6000_get_iwstats(struct net_device * dev);
293
286
static void disconnect_timer_handler(unsigned long ptr);
295
288
void read_rssi_compensation_param(struct ar6_softc *ar);
297
/* for android builds we call external APIs that handle firmware download and configuration */
299
/* !!!! Interim android support to make it easier to patch the default driver for
300
* android use. You must define an external source file ar6000_android.c that handles the following
302
extern void android_module_init(OSDRV_CALLBACKS *osdrvCallbacks);
303
extern void android_module_exit(void);
306
291
* HTC service connection handlers
322
307
static HTC_SEND_FULL_ACTION ar6000_tx_queue_full(void *Context, struct htc_packet *pPacket);
324
#ifdef ATH_AR6K_11N_SUPPORT
325
309
static void ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num);
327
310
static void ar6000_deliver_frames_to_nw_stack(void * dev, void *osbuf);
328
311
//static void ar6000_deliver_frames_to_bt_stack(void * dev, void *osbuf);
363
344
struct net_device *ar6000_devices[MAX_AR6000];
364
345
static int is_netdev_registered;
365
extern struct iw_handler_def ath_iw_handler_def;
366
346
DECLARE_WAIT_QUEUE_HEAD(arEvent);
367
347
static void ar6000_cookie_init(struct ar6_softc *ar);
368
348
static void ar6000_cookie_cleanup(struct ar6_softc *ar);
369
349
static void ar6000_free_cookie(struct ar6_softc *ar, struct ar_cookie * cookie);
370
350
static struct ar_cookie *ar6000_alloc_cookie(struct ar6_softc *ar);
373
352
static int ar6000_reinstall_keys(struct ar6_softc *ar,u8 key_op_ctrl);
376
354
#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
377
355
struct net_device *arApNetDev;
612
589
send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
613
590
MAX_WIRELESS_EVENT_SIZE);
615
ar6000_send_event_to_app(ar, WMIX_DBGLOG_EVENTID, (u8 *)&buffer[sent], send);
617
593
send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
618
594
MAX_WIRELESS_EVENT_SIZE);
998
954
const char *filename;
999
955
const struct firmware *fw_entry;
1000
956
u32 fw_entry_size;
1003
961
case AR6K_OTP_FILE:
963
buf_len = &ar->fw_otp_len;
1004
964
if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1005
965
filename = AR6003_REV1_OTP_FILE;
1006
966
} else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1007
967
filename = AR6003_REV2_OTP_FILE;
968
} else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
969
filename = AR6003_REV3_OTP_FILE;
1009
971
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1014
976
case AR6K_FIRMWARE_FILE:
978
buf_len = &ar->fw_len;
1015
979
if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1016
980
filename = AR6003_REV1_FIRMWARE_FILE;
1017
981
} else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1018
982
filename = AR6003_REV2_FIRMWARE_FILE;
983
} else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
984
filename = AR6003_REV3_FIRMWARE_FILE;
1020
986
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1027
993
filename = AR6003_REV1_EPPING_FIRMWARE_FILE;
1028
994
} else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1029
995
filename = AR6003_REV2_EPPING_FIRMWARE_FILE;
996
} else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
997
filename = AR6003_REV3_EPPING_FIRMWARE_FILE;
1031
999
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("eppingtest : unsupported firmware revision: %d\n",
1032
1000
ar->arVersion.target_ver));
1041
1009
filename = AR6003_REV1_TCMD_FIRMWARE_FILE;
1042
1010
} else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1043
1011
filename = AR6003_REV2_TCMD_FIRMWARE_FILE;
1012
} else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
1013
filename = AR6003_REV3_TCMD_FIRMWARE_FILE;
1045
1015
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1046
1016
return A_ERROR;
1066
1036
case AR6K_PATCH_FILE:
1037
buf = &ar->fw_patch;
1038
buf_len = &ar->fw_patch_len;
1067
1039
if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1068
1040
filename = AR6003_REV1_PATCH_FILE;
1069
1041
} else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1070
1042
filename = AR6003_REV2_PATCH_FILE;
1043
} else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
1044
filename = AR6003_REV3_PATCH_FILE;
1072
1046
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1073
1047
return A_ERROR;
1077
1051
case AR6K_BOARD_DATA_FILE:
1053
buf_len = &ar->fw_data_len;
1078
1054
if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1079
1055
filename = AR6003_REV1_BOARD_DATA_FILE;
1080
1056
} else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1081
1057
filename = AR6003_REV2_BOARD_DATA_FILE;
1058
} else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
1059
filename = AR6003_REV3_BOARD_DATA_FILE;
1083
1061
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1084
1062
return A_ERROR;
1089
1067
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown file type: %d\n", file));
1090
1068
return A_ERROR;
1092
if ((A_REQUEST_FIRMWARE(&fw_entry, filename, ((struct device *)ar->osDevInfo.pOSDevice))) != 0)
1094
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to get %s\n", filename));
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);
1098
1082
#ifdef SOFTMAC_FILE_USED
1099
if (file==AR6K_BOARD_DATA_FILE && fw_entry->data) {
1100
ar6000_softmac_update(ar, (u8 *)fw_entry->data, fw_entry->size);
1083
if (file==AR6K_BOARD_DATA_FILE && *buf_len) {
1084
ar6000_softmac_update(ar, *buf, *buf_len);
1105
fw_entry_size = fw_entry->size;
1089
fw_entry_size = *buf_len;
1107
1091
/* Load extended board data for AR6003 */
1108
if ((file==AR6K_BOARD_DATA_FILE) && (fw_entry->data)) {
1092
if ((file==AR6K_BOARD_DATA_FILE) && *buf) {
1109
1093
u32 board_ext_address;
1110
1094
u32 board_ext_data_size;
1111
1095
u32 board_data_size;
1121
1105
AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("Board extended Data download address: 0x%x\n", board_ext_address));
1123
1107
/* check whether the target has allocated memory for extended board data and file contains extended board data */
1124
if ((board_ext_address) && (fw_entry->size == (board_data_size + board_ext_data_size))) {
1108
if ((board_ext_address) && (*buf_len == (board_data_size + board_ext_data_size))) {
1127
status = BMIWriteMemory(ar->arHifDevice, board_ext_address, (u8 *)(fw_entry->data + board_data_size), board_ext_data_size);
1111
status = BMIWriteMemory(ar->arHifDevice, board_ext_address, (u8 *)(*buf + board_data_size), board_ext_data_size);
1130
1114
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__));
1131
A_RELEASE_FIRMWARE(fw_entry);
1132
1115
return A_ERROR;
1135
1118
/* Record the fact that extended board Data IS initialized */
1137
bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data_initialized), (u8 *)¶m, 4));
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));
1139
1124
fw_entry_size = board_data_size;
1142
1127
if (compressed) {
1143
status = BMIFastDownload(ar->arHifDevice, address, (u8 *)fw_entry->data, fw_entry_size);
1128
status = BMIFastDownload(ar->arHifDevice, address, *buf, fw_entry_size);
1145
status = BMIWriteMemory(ar->arHifDevice, address, (u8 *)fw_entry->data, fw_entry_size);
1130
status = BMIWriteMemory(ar->arHifDevice, address, *buf, fw_entry_size);
1149
1134
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__));
1150
A_RELEASE_FIRMWARE(fw_entry);
1151
1135
return A_ERROR;
1153
A_RELEASE_FIRMWARE(fw_entry);
1156
#endif /* INIT_MODE_DRV_ENABLED */
1159
1142
ar6000_update_bdaddr(struct ar6_softc *ar)
1293
1275
bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data_initialized), (u8 *)¶m, 4));
1295
1277
/* Transfer One time Programmable data */
1296
AR6K_DATA_DOWNLOAD_ADDRESS(address, ar->arVersion.target_ver);
1278
AR6K_APP_LOAD_ADDRESS(address, ar->arVersion.target_ver);
1279
if (ar->arVersion.target_ver == AR6003_REV3_VERSION)
1297
1281
status = ar6000_transfer_bin_file(ar, AR6K_OTP_FILE, address, true);
1298
1282
if (status == 0) {
1299
1283
/* Execute the OTP code */
1311
1295
/* Download Target firmware */
1312
AR6K_DATA_DOWNLOAD_ADDRESS(address, ar->arVersion.target_ver);
1296
AR6K_APP_LOAD_ADDRESS(address, ar->arVersion.target_ver);
1297
if (ar->arVersion.target_ver == AR6003_REV3_VERSION)
1313
1299
if ((ar6000_transfer_bin_file(ar, AR6K_FIRMWARE_FILE, address, true)) != 0) {
1314
1300
return A_ERROR;
1318
1304
AR6K_APP_START_OVERRIDE_ADDRESS(address, ar->arVersion.target_ver);
1319
1305
bmifn(BMISetAppStart(ar->arHifDevice, address));
1321
/* Apply the patches */
1322
AR6K_PATCH_DOWNLOAD_ADDRESS(address, ar->arVersion.target_ver);
1323
if ((ar6000_transfer_bin_file(ar, AR6K_PATCH_FILE, address, false)) != 0) {
1328
bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dset_list_head), (u8 *)¶m, 4));
1330
if (ar->arTargetType == TARGET_TYPE_AR6003) {
1331
if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1332
/* Reserve 5.5K of RAM */
1334
} else { /* AR6003_REV2_VERSION */
1335
/* Reserve 6.5K of RAM */
1338
bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_end_RAM_reserve_sz), (u8 *)¶m, 4));
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));
1341
1318
/* Restore system sleep */
1342
1319
address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS;
1470
1445
return A_ERROR;
1448
param |= (num_device << HI_OPTION_NUM_DEV_SHIFT);
1473
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);
1475
1454
if (BMIWriteMemory(ar->arHifDevice,
1476
1455
HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1518
1497
* It is difficult to patch the firmware boot code,
1519
1498
* but possible in theory.
1521
if (ar->arTargetType == TARGET_TYPE_AR6003) {
1522
param = AR6003_BOARD_EXT_DATA_ADDRESS;
1523
if (BMIWriteMemory(ar->arHifDevice,
1524
HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data),
1528
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for hi_board_ext_data failed \n"));
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"));
1534
1529
/* since BMIInit is called in the driver layer, we have to set the block
1535
1530
* size here for the target */
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);
1592
1626
* HTC Event handlers
1630
1662
/* we use another local "i" variable below. */
1631
1663
device_index = i;
1633
#ifdef ATH6K_CONFIG_CFG80211
1634
1665
wdev = ar6k_cfg80211_init(osDevInfo.pOSDevice);
1635
1666
if (IS_ERR(wdev)) {
1636
1667
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ar6k_cfg80211_init failed\n", __func__));
1637
1668
return A_ERROR;
1639
1670
ar_netif = wdev_priv(wdev);
1641
dev = alloc_etherdev(sizeof(struct ar6_softc));
1643
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_available: can't alloc etherdev\n"));
1647
ar_netif = ar6k_priv(dev);
1648
#endif /* ATH6K_CONFIG_CFG80211 */
1650
1672
if (ar_netif == NULL) {
1651
1673
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Can't allocate ar6k priv memory\n", __func__));
1671
1692
wdev->netdev = dev;
1672
1693
ar->arNetworkType = INFRA_NETWORK;
1673
1694
ar->smeState = SME_DISCONNECTED;
1674
#endif /* ATH6K_CONFIG_CFG80211 */
1695
ar->arAutoAuthStage = AUTH_IDLE;
1676
1697
init_netdev(dev, ifname);
1678
#ifdef SET_NETDEV_DEV
1680
SET_NETDEV_DEV(dev, osDevInfo.pOSDevice);
1684
1700
ar->arNetDev = dev;
1685
1701
ar->arHifDevice = hif_handle;
1723
ar6000_sysfs_bmi_init(ar);
1738
ar6000_sysfs_bmi_init(ar);
1727
1741
struct bmi_target_info targ_info;
1729
if (BMIGetTargetInfo(ar->arHifDevice, &targ_info) != 0) {
1730
init_status = A_ERROR;
1743
r = BMIGetTargetInfo(ar->arHifDevice, &targ_info);
1731
1745
goto avail_ev_failed;
1734
1747
ar->arVersion.target_ver = targ_info.target_ver;
1735
1748
ar->arTargetType = targ_info.target_type;
1737
/* do any target-specific preparation that can be done through BMI */
1738
if (ar6000_prepare_target(ar->arHifDevice,
1739
targ_info.target_type,
1740
targ_info.target_ver) != 0) {
1741
init_status = A_ERROR;
1742
goto avail_ev_failed;
1747
if (ar6000_configure_target(ar) != 0) {
1748
init_status = A_ERROR;
1749
goto avail_ev_failed;
1749
wdev->wiphy->hw_version = targ_info.target_ver;
1752
r = ar6000_configure_target(ar);
1754
goto avail_ev_failed;
1752
1756
A_MEMZERO(&htcInfo,sizeof(htcInfo));
1753
1757
htcInfo.pContext = ar;
1770
#ifdef CONFIG_CHECKSUM_OFFLOAD
1771
1774
if(csumOffload){
1772
1775
/*if external frame work is also needed, change and use an extended rxMetaVerion*/
1773
1776
ar->rxMetaVersion=WMI_META_VERSION_2;
1777
#ifdef ATH_AR6K_11N_SUPPORT
1778
if((ar->aggr_cntxt = aggr_init(ar6000_alloc_netbufs)) == NULL) {
1779
ar->aggr_cntxt = aggr_init(ar6000_alloc_netbufs);
1780
if (!ar->aggr_cntxt) {
1779
1781
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s() Failed to initialize aggr.\n", __func__));
1780
init_status = A_ERROR;
1781
1783
goto avail_ev_failed;
1784
1786
aggr_register_rx_dispatcher(ar->aggr_cntxt, (void *)dev, ar6000_deliver_frames_to_nw_stack);
1787
1788
HIFClaimDevice(ar->arHifDevice, ar);
1791
1792
/* when the module is unloaded. */
1792
1793
ar6000_devices[device_index] = dev;
1794
/* Don't install the init function if BMI is requested */
1796
ar6000_netdev_ops.ndo_init = ar6000_init;
1798
AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("BMI enabled: %d\n", wlaninitmode));
1799
if ((wlaninitmode == WLAN_INIT_MODE_UDEV) ||
1800
(wlaninitmode == WLAN_INIT_MODE_DRV))
1804
if ((status = ar6000_sysfs_bmi_get_config(ar, wlaninitmode)) != 0)
1806
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n"));
1809
#ifdef HTC_RAW_INTERFACE
1810
if (!eppingtest && bypasswmi) {
1811
break; /* Don't call ar6000_init for ART */
1815
status = (ar6000_init(dev)==0) ? 0 : A_ERROR;
1818
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_init\n"));
1823
init_status = status;
1824
goto avail_ev_failed;
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;
1829
1803
/* This runs the init function if registered */
1830
if (register_netdev(dev)) {
1804
r = register_netdev(dev);
1831
1806
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: register_netdev failed\n"));
1832
1807
ar6000_destroy(dev, 0);
1836
1811
is_netdev_registered = 1;
2026
1993
ar6000_cleanup_hci(ar);
2028
#ifdef EXPORT_HCI_PAL_INTERFACE
2029
if (setuphcipal && (NULL != ar6kHciPalCallbacks_g.cleanupTransport)) {
2030
ar6kHciPalCallbacks_g.cleanupTransport(ar);
2033
/* cleanup hci pal driver data structures */
2035
ar6k_cleanup_hci_pal(ar);
2037
1995
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,(" Shutting down HTC .... \n"));
2039
1997
HTCStop(ar->arHtcTarget);
2146
2097
free_netdev(dev);
2148
#ifdef ATH6K_CONFIG_CFG80211
2149
2099
ar6k_cfg80211_deinit(ar);
2150
#endif /* ATH6K_CONFIG_CFG80211 */
2152
2101
#ifdef CONFIG_AP_VIRTUL_ADAPTER_SUPPORT
2153
2102
ar6000_remove_ap_interface();
2154
2103
#endif /*CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
2107
kfree(ar->fw_patch);
2156
2110
AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("-ar6000_destroy \n"));
2422
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 */
2426
2411
* This function applies WLAN specific configuration defined in wlan_config.h
2428
2413
int ar6000_target_config_wlan_params(struct ar6_softc *ar)
2430
2415
int status = 0;
2431
#if defined(INIT_MODE_DRV_ENABLED) && defined(ENABLE_COEXISTENCE)
2432
WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD sbcb_cmd;
2433
WMI_SET_BTCOEX_FE_ANT_CMD sbfa_cmd;
2434
#endif /* INIT_MODE_DRV_ENABLED && ENABLE_COEXISTENCE */
2436
2417
#ifdef CONFIG_HOST_TCMD_SUPPORT
2437
2418
if (ar->arTargetMode != AR6000_WLAN_MODE) {
2449
2430
status = A_ERROR;
2452
#if defined(INIT_MODE_DRV_ENABLED) && defined(ENABLE_COEXISTENCE)
2453
/* Configure the type of BT collocated with WLAN */
2454
memset(&sbcb_cmd, 0, sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD));
2455
#ifdef CONFIG_AR600x_BT_QCOM
2456
sbcb_cmd.btcoexCoLocatedBTdev = 1;
2457
#elif defined(CONFIG_AR600x_BT_CSR)
2458
sbcb_cmd.btcoexCoLocatedBTdev = 2;
2459
#elif defined(CONFIG_AR600x_BT_AR3001)
2460
sbcb_cmd.btcoexCoLocatedBTdev = 3;
2462
#error Unsupported Bluetooth Type
2463
#endif /* Collocated Bluetooth Type */
2465
if ((wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &sbcb_cmd)) != 0) {
2466
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set collocated BT type\n"));
2470
/* Configure the type of BT collocated with WLAN */
2471
memset(&sbfa_cmd, 0, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD));
2472
#ifdef CONFIG_AR600x_DUAL_ANTENNA
2473
sbfa_cmd.btcoexFeAntType = 2;
2474
#elif defined(CONFIG_AR600x_SINGLE_ANTENNA)
2475
sbfa_cmd.btcoexFeAntType = 1;
2477
#error Unsupported Front-End Antenna Configuration
2478
#endif /* AR600x Front-End Antenna Configuration */
2480
if ((wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &sbfa_cmd)) != 0) {
2481
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set fornt end antenna configuration\n"));
2484
#endif /* INIT_MODE_DRV_ENABLED && ENABLE_COEXISTENCE */
2433
status = ath6kl_config_btcoex_params(ar);
2486
2437
#if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
2487
2438
if ((wmi_pmparams_cmd(ar->arWmi, 0, 1, 0, 0, 1, IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) {
2751
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"));
2755
2731
* give our connected endpoints some buffers
3704
3676
WMI_DATA_HDR *dhdr = (WMI_DATA_HDR *)A_NETBUF_DATA(skb);
3707
bool is_acl_data_frame;
3708
is_acl_data_frame = WMI_DATA_HDR_GET_DATA_TYPE(dhdr) == WMI_DATA_HDR_DATA_TYPE_ACL;
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);
3709
3696
#ifdef CONFIG_PM
3710
3697
ar6000_check_wow_status(ar, NULL, false);
3711
3698
#endif /* CONFIG_PM */
3875
if (is_acl_data_frame) {
3876
A_NETBUF_PUSH(skb, sizeof(int));
3877
*((short *)A_NETBUF_DATA(skb)) = WMI_ACL_DATA_EVENTID;
3878
/* send the data packet to PAL driver */
3879
if(ar6k_pal_config_g.fpar6k_pal_recv_pkt) {
3880
if((*ar6k_pal_config_g.fpar6k_pal_recv_pkt)(ar->hcipal_info, skb) == true)
3885
3858
if ((ar->arNetDev->flags & IFF_UP) == IFF_UP) {
3886
3859
if (ar->arNetworkType == AP_NETWORK) {
3887
3860
struct sk_buff *skb1 = NULL;
4146
4117
return &ar->arNetStats;
4149
static struct iw_statistics *
4150
ar6000_get_iwstats(struct net_device * dev)
4152
struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
4153
TARGET_STATS *pStats = &ar->arTargetStats;
4154
struct iw_statistics * pIwStats = &ar->arIwStats;
4157
if (ar->bIsDestroyProgress || ar->arWmiReady == false || ar->arWlanState == WLAN_DISABLED)
4159
pIwStats->status = 0;
4160
pIwStats->qual.qual = 0;
4161
pIwStats->qual.level =0;
4162
pIwStats->qual.noise = 0;
4163
pIwStats->discard.code =0;
4164
pIwStats->discard.retries=0;
4165
pIwStats->miss.beacon =0;
4170
* The in_atomic function is used to determine if the scheduling is
4171
* allowed in the current context or not. This was introduced in 2.6
4172
* From what I have read on the differences between 2.4 and 2.6, the
4173
* 2.4 kernel did not support preemption and so this check might not
4174
* be required for 2.4 kernels.
4178
wmi_get_stats_cmd(ar->arWmi);
4180
pIwStats->status = 1 ;
4181
pIwStats->qual.qual = pStats->cs_aveBeacon_rssi - 161;
4182
pIwStats->qual.level =pStats->cs_aveBeacon_rssi; /* noise is -95 dBm */
4183
pIwStats->qual.noise = pStats->noise_floor_calibation;
4184
pIwStats->discard.code = pStats->rx_decrypt_err;
4185
pIwStats->discard.retries = pStats->tx_retry_cnt;
4186
pIwStats->miss.beacon = pStats->cs_bmiss_cnt;
4191
rtnllocked = rtnl_is_locked();
4195
pIwStats->status = 0;
4197
if (down_interruptible(&ar->arSem)) {
4203
if (ar->bIsDestroyProgress || ar->arWlanState == WLAN_DISABLED) {
4207
ar->statsUpdatePending = true;
4209
if(wmi_get_stats_cmd(ar->arWmi) != 0) {
4213
wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
4214
if (signal_pending(current)) {
4215
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000 : WMI get stats timeout \n"));
4218
pIwStats->status = 1 ;
4219
pIwStats->qual.qual = pStats->cs_aveBeacon_rssi - 161;
4220
pIwStats->qual.level =pStats->cs_aveBeacon_rssi; /* noise is -95 dBm */
4221
pIwStats->qual.noise = pStats->noise_floor_calibation;
4222
pIwStats->discard.code = pStats->rx_decrypt_err;
4223
pIwStats->discard.retries = pStats->tx_retry_cnt;
4224
pIwStats->miss.beacon = pStats->cs_bmiss_cnt;
4237
4121
ar6000_ready_event(void *devt, u8 *datap, u8 phyCap, u32 sw_ver, u32 abi_ver)
4254
4138
wake_up(&arEvent);
4141
void ar6000_install_static_wep_keys(struct ar6_softc *ar)
4146
for (index = WMI_MIN_KEY_INDEX; index <= WMI_MAX_KEY_INDEX; index++) {
4147
if (ar->arWepKeyList[index].arKeyLen) {
4148
keyUsage = GROUP_USAGE;
4149
if (index == ar->arDefTxKeyIndex) {
4150
keyUsage |= TX_USAGE;
4152
wmi_addKey_cmd(ar->arWmi,
4156
ar->arWepKeyList[index].arKeyLen,
4158
ar->arWepKeyList[index].arKey, KEY_OP_INIT_VAL, NULL,
4258
4165
add_new_sta(struct ar6_softc *ar, u8 *mac, u16 aid, u8 *wpaie,
4259
4166
u8 ielen, u8 keymgmt, u8 ucipher, u8 auth)
4395
#ifdef ATH6K_CONFIG_CFG80211
4396
4302
ar6k_cfg80211_connect_event(ar, channel, bssid,
4397
4303
listenInterval, beaconInterval,
4398
4304
networkType, beaconIeLen,
4399
4305
assocReqLen, assocRespLen,
4401
#endif /* ATH6K_CONFIG_CFG80211 */
4403
4308
memcpy(ar->arBssid, bssid, sizeof(ar->arBssid));
4404
4309
ar->arBssChannel = channel;
4509
4413
ar6000_reinstall_keys(ar, key_op_ctrl);
4511
#endif /* USER_KEYS */
4513
4416
netif_wake_queue(ar->arNetDev);
4515
/* For CFG80211 the key configuration and the default key comes in after connect so no point in plumbing invalid keys */
4516
#ifndef ATH6K_CONFIG_CFG80211
4517
if ((networkType & ADHOC_NETWORK) &&
4518
(OPEN_AUTH == ar->arDot11AuthMode) &&
4519
(NONE_AUTH == ar->arAuthMode) &&
4520
(WEP_CRYPT == ar->arPairwiseCrypto))
4522
if (!ar->arConnected) {
4523
wmi_addKey_cmd(ar->arWmi,
4524
ar->arDefTxKeyIndex,
4526
GROUP_USAGE | TX_USAGE,
4527
ar->arWepKeyList[ar->arDefTxKeyIndex].arKeyLen,
4529
ar->arWepKeyList[ar->arDefTxKeyIndex].arKey, KEY_OP_INIT_VAL, NULL,
4533
#endif /* ATH6K_CONFIG_CFG80211 */
4535
4418
/* Update connect & link status atomically */
4536
4419
spin_lock_irqsave(&ar->arLock, flags);
4537
4420
ar->arConnected = true;
4828
4705
buf += sizeof(int);
4829
4706
memcpy(buf, cmd->buf, cmd->evt_buf_sz);
4831
if(ar6k_pal_config_g.fpar6k_pal_recv_pkt)
4833
/* pass the cmd packet to PAL driver */
4834
if((*ar6k_pal_config_g.fpar6k_pal_recv_pkt)(ar->hcipal_info, osbuf) == true)
4837
4708
ar6000_deliver_frames_to_nw_stack(ar->arNetDev, osbuf);
4839
4710
A_PRINTF_LOG("HCI Event From PAL <-- \n");
4883
4754
memcpy(pmkcand->bssid.sa_data, info->bssid, ATH_MAC_LEN);
4884
4755
wrqu.data.length = sizeof(struct iw_pmkid_cand);
4885
4756
wireless_send_event(ar->arNetDev, IWEVPMKIDCAND, &wrqu, (char *)pmkcand);
4887
4758
#else /* WIRELESS_EXT >= 18 */
4888
4759
snprintf(buf, sizeof(buf), "%s%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
4918
4789
tag, s->mac[0],s->mac[1],s->mac[2],s->mac[3],s->mac[4],s->mac[5]);
4921
#ifdef ATH6K_CONFIG_CFG80211
4922
4792
ar6k_cfg80211_tkip_micerr_event(ar, keyid, ismcast);
4923
#endif /* ATH6K_CONFIG_CFG80211 */
4925
4794
A_PRINTF("AR6000 TKIP MIC error received for keyid %d %scast\n",
4926
4795
keyid & 0x3, ismcast ? "multi": "uni");
4937
4806
ar6000_scanComplete_event(struct ar6_softc *ar, int status)
4940
#ifdef ATH6K_CONFIG_CFG80211
4941
4809
ar6k_cfg80211_scanComplete_event(ar, status);
4942
#endif /* ATH6K_CONFIG_CFG80211 */
4944
4811
if (!ar->arUserBssFilter) {
4945
4812
wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0);
5097
4964
userRssiThold.rssi = rssi;
5098
4965
A_PRINTF("rssi Threshold range = %d tag = %d rssi = %d\n", newThreshold,
5099
4966
userRssiThold.tag, userRssiThold.rssi);
5101
ar6000_send_event_to_app(ar, WMI_RSSI_THRESHOLD_EVENTID,(u8 *)&userRssiThold, sizeof(USER_RSSI_THOLD));
5106
4971
ar6000_hbChallengeResp_event(struct ar6_softc *ar, u32 cookie, u32 source)
5108
if (source == APP_HB_CHALLENGE) {
5109
/* Report it to the app in case it wants a positive acknowledgement */
5110
ar6000_send_event_to_app(ar, WMIX_HB_CHALLENGE_RESP_EVENTID,
5111
(u8 *)&cookie, sizeof(cookie));
4973
if (source != APP_HB_CHALLENGE) {
5113
4974
/* This would ignore the replys that come in after their due time */
5114
4975
if (cookie == ar->arHBChallengeResp.seqNum) {
5115
4976
ar->arHBChallengeResp.outstanding = false;
5565
#ifdef SEND_EVENT_TO_APP
5567
* This function is used to send event which come from taget to
5568
* the application. The buf which send to application is include
5569
* the event ID and event content.
5571
#define EVENT_ID_LEN 2
5572
void ar6000_send_event_to_app(struct ar6_softc *ar, u16 eventId,
5576
#if (WIRELESS_EXT >= 15)
5578
/* note: IWEVCUSTOM only exists in wireless extensions after version 15 */
5582
union iwreq_data wrqu;
5584
size = len + EVENT_ID_LEN;
5586
if (size > IW_CUSTOM_MAX) {
5587
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("WMI event ID : 0x%4.4X, len = %d too big for IWEVCUSTOM (max=%d) \n",
5588
eventId, size, IW_CUSTOM_MAX));
5592
buf = A_MALLOC_NOWAIT(size);
5594
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: failed to allocate %d bytes\n", __func__, size));
5598
A_MEMZERO(buf, size);
5599
memcpy(buf, &eventId, EVENT_ID_LEN);
5600
memcpy(buf+EVENT_ID_LEN, datap, len);
5602
//AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("event ID = %d,len = %d\n",*(u16 *)buf, size));
5603
A_MEMZERO(&wrqu, sizeof(wrqu));
5604
wrqu.data.length = size;
5605
wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
5613
* This function is used to send events larger than 256 bytes
5614
* to the application. The buf which is sent to application
5615
* includes the event ID and event content.
5617
void ar6000_send_generic_event_to_app(struct ar6_softc *ar, u16 eventId,
5621
#if (WIRELESS_EXT >= 18)
5623
/* IWEVGENIE exists in wireless extensions version 18 onwards */
5627
union iwreq_data wrqu;
5629
size = len + EVENT_ID_LEN;
5631
if (size > IW_GENERIC_IE_MAX) {
5632
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("WMI event ID : 0x%4.4X, len = %d too big for IWEVGENIE (max=%d) \n",
5633
eventId, size, IW_GENERIC_IE_MAX));
5637
buf = A_MALLOC_NOWAIT(size);
5639
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: failed to allocate %d bytes\n", __func__, size));
5643
A_MEMZERO(buf, size);
5644
memcpy(buf, &eventId, EVENT_ID_LEN);
5645
memcpy(buf+EVENT_ID_LEN, datap, len);
5647
A_MEMZERO(&wrqu, sizeof(wrqu));
5648
wrqu.data.length = size;
5649
wireless_send_event(ar->arNetDev, IWEVGENIE, &wrqu, buf);
5653
#endif /* (WIRELESS_EXT >= 18) */
5656
#endif /* SEND_EVENT_TO_APP */
5660
5427
ar6000_tx_retry_err_event(void *devt)
5666
5433
ar6000_snrThresholdEvent_rx(void *devt, WMI_SNR_THRESHOLD_VAL newThreshold, u8 snr)
5668
5435
WMI_SNR_THRESHOLD_EVENT event;
5669
struct ar6_softc *ar = (struct ar6_softc *)devt;
5671
5437
event.range = newThreshold;
5672
5438
event.snr = snr;
5674
ar6000_send_event_to_app(ar, WMI_SNR_THRESHOLD_EVENTID, (u8 *)&event,
5675
sizeof(WMI_SNR_THRESHOLD_EVENT));