~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to drivers/staging/ath6kl/os/linux/ar6000_drv.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 */
28
28
 
29
29
#include "ar6000_drv.h"
30
 
#ifdef ATH6K_CONFIG_CFG80211
31
30
#include "cfg80211.h"
32
 
#endif /* ATH6K_CONFIG_CFG80211 */
33
31
#include "htc.h"
34
32
#include "wmi_filter_linux.h"
35
33
#include "epping_test.h"
118
116
#endif
119
117
 
120
118
unsigned int processDot11Hdr = 0;
121
 
int bmienable = BMIENABLE_DEFAULT;
122
119
 
123
120
char ifname[IFNAMSIZ] = {0,};
124
121
 
134
131
unsigned int enableuartprint = ENABLEUARTPRINT_DEFAULT;
135
132
unsigned int logWmiRawMsgs = 0;
136
133
unsigned int enabletimerwar = 0;
 
134
unsigned int num_device = 1;
 
135
unsigned int regscanmode;
137
136
unsigned int fwmode = 1;
138
137
unsigned int mbox_yield_limit = 99;
139
138
unsigned int enablerssicompensation = 0;
148
147
unsigned int nohifscattersupport = NOHIFSCATTERSUPPORT_DEFAULT;
149
148
 
150
149
unsigned int setuphci = SETUPHCI_DEFAULT;
151
 
unsigned int setuphcipal = SETUPHCIPAL_DEFAULT;
152
150
unsigned int loghci = 0;
153
151
unsigned int setupbtdev = SETUPBTDEV_DEFAULT;
154
152
#ifndef EXPORT_HCI_BRIDGE_INTERFACE
156
154
unsigned int hciuartscale = HCIUARTSCALE_DEFAULT;
157
155
unsigned int hciuartstep = HCIUARTSTEP_DEFAULT;
158
156
#endif
159
 
#ifdef CONFIG_CHECKSUM_OFFLOAD
160
157
unsigned int csumOffload=0;
161
158
unsigned int csumOffloadTest=0;
162
 
#endif
163
159
unsigned int eppingtest=0;
 
160
unsigned int mac_addr_method;
 
161
unsigned int firmware_bridge;
164
162
 
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);
187
 
#endif
188
183
#ifdef CONFIG_HOST_TCMD_SUPPORT
189
184
module_param(testmode, uint, 0644);
190
185
#endif
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);
292
285
 
293
286
static void disconnect_timer_handler(unsigned long ptr);
294
287
 
295
288
void read_rssi_compensation_param(struct ar6_softc *ar);
296
289
 
297
 
    /* for android builds we call external APIs that handle firmware download and configuration */
298
 
#ifdef ANDROID_ENV
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
301
 
 * APIs */
302
 
extern void android_module_init(OSDRV_CALLBACKS *osdrvCallbacks);
303
 
extern void android_module_exit(void);
304
 
#endif
305
290
/*
306
291
 * HTC service connection handlers
307
292
 */
321
306
 
322
307
static HTC_SEND_FULL_ACTION ar6000_tx_queue_full(void *Context, struct htc_packet *pPacket);
323
308
 
324
 
#ifdef ATH_AR6K_11N_SUPPORT
325
309
static void ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num);
326
 
#endif
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);
329
312
 
346
329
static int
347
330
ar6000_sysfs_bmi_init(struct ar6_softc *ar);
348
331
 
349
 
/* HCI PAL callback function declarations */
350
 
int ar6k_setup_hci_pal(struct ar6_softc *ar);
351
332
void  ar6k_cleanup_hci_pal(struct ar6_softc *ar);
352
333
 
353
334
static void
362
343
 
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);
371
351
 
372
 
#ifdef USER_KEYS
373
352
static int ar6000_reinstall_keys(struct ar6_softc *ar,u8 key_op_ctrl);
374
 
#endif
375
353
 
376
354
#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
377
355
struct net_device *arApNetDev;
389
367
    .ndo_open               = ar6000_open,
390
368
    .ndo_stop               = ar6000_close,
391
369
    .ndo_get_stats          = ar6000_get_stats,
392
 
    .ndo_do_ioctl           = ar6000_ioctl,
393
370
    .ndo_start_xmit         = ar6000_data_tx,
394
371
    .ndo_set_multicast_list = ar6000_set_multicast_list,
395
372
};
612
589
    send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
613
590
                                     MAX_WIRELESS_EVENT_SIZE);
614
591
    while (send) {
615
 
        ar6000_send_event_to_app(ar, WMIX_DBGLOG_EVENTID, (u8 *)&buffer[sent], send);
616
592
        sent += send;
617
593
        send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
618
594
                                         MAX_WIRELESS_EVENT_SIZE);
631
607
ar6000_init_module(void)
632
608
{
633
609
    static int probed = 0;
634
 
    int status;
 
610
    int r;
635
611
    OSDRV_CALLBACKS osdrvCallbacks;
636
612
 
637
613
    a_module_debug_support_init();
664
640
    osdrvCallbacks.devicePowerChangeHandler = ar6000_power_change_ev;
665
641
#endif
666
642
 
667
 
    ar6000_pm_init();
668
 
 
669
 
#ifdef ANDROID_ENV
670
 
    android_module_init(&osdrvCallbacks);
671
 
#endif
672
 
 
673
643
#ifdef DEBUG
674
644
    /* Set the debug flags if specified at load time */
675
645
    if(debugflags != 0)
687
657
    memset(&aptcTR, 0, sizeof(APTC_TRAFFIC_RECORD));
688
658
#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
689
659
 
690
 
#ifdef CONFIG_HOST_GPIO_SUPPORT
691
 
    ar6000_gpio_init();
692
 
#endif /* CONFIG_HOST_GPIO_SUPPORT */
693
 
 
694
 
    status = HIFInit(&osdrvCallbacks);
695
 
    if (status)
696
 
        return -ENODEV;
 
660
    r = HIFInit(&osdrvCallbacks);
 
661
    if (r)
 
662
        return r;
697
663
 
698
664
    return 0;
699
665
}
723
689
 
724
690
    a_module_debug_support_cleanup();
725
691
 
726
 
    ar6000_pm_exit();
727
 
 
728
 
#ifdef ANDROID_ENV    
729
 
    android_module_exit();
730
 
#endif
731
 
 
732
692
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("ar6000_cleanup: success\n"));
733
693
}
734
694
 
769
729
}
770
730
#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
771
731
 
772
 
#ifdef ATH_AR6K_11N_SUPPORT
773
732
static void
774
733
ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num)
775
734
{
788
747
        A_PRINTF("%s(), allocation of netbuf failed", __func__);
789
748
    }
790
749
}
791
 
#endif
792
750
 
793
751
static struct bin_attribute bmi_attr = {
794
752
    .attr = {.name = "bmi", .mode = 0600},
894
852
    } \
895
853
} while(0)
896
854
 
897
 
#ifdef INIT_MODE_DRV_ENABLED
898
 
 
899
855
#ifdef SOFTMAC_FILE_USED
900
856
#define AR6002_MAC_ADDRESS_OFFSET     0x0A
901
857
#define AR6003_MAC_ADDRESS_OFFSET     0x16
982
938
                }
983
939
                source = "softmac file";
984
940
            }
985
 
            A_FREE(macbuf);
 
941
            kfree(macbuf);
986
942
        }
987
943
        A_RELEASE_FIRMWARE(softmac_entry);
988
944
    }
998
954
    const char *filename;
999
955
    const struct firmware *fw_entry;
1000
956
    u32 fw_entry_size;
 
957
    u8 **buf;
 
958
    size_t *buf_len;
1001
959
 
1002
960
    switch (file) {
1003
961
        case AR6K_OTP_FILE:
 
962
                buf = &ar->fw_otp;
 
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;
1008
970
            } else {
1009
971
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1010
972
                return A_ERROR;
1012
974
            break;
1013
975
 
1014
976
        case AR6K_FIRMWARE_FILE:
 
977
                buf = &ar->fw;
 
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;
1019
985
            } else {
1020
986
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1021
987
                return A_ERROR;
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;
1030
998
                } else {
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;
1044
1014
                } else {
1045
1015
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1046
1016
                    return A_ERROR;
1064
1034
            break;
1065
1035
 
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;
1071
1045
            } else {
1072
1046
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1073
1047
                return A_ERROR;
1075
1049
            break;
1076
1050
 
1077
1051
        case AR6K_BOARD_DATA_FILE:
 
1052
                buf = &ar->fw_data;
 
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;
1082
1060
            } else {
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;
1091
1069
    }
1092
 
    if ((A_REQUEST_FIRMWARE(&fw_entry, filename, ((struct device *)ar->osDevInfo.pOSDevice))) != 0)
1093
 
    {
1094
 
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to get %s\n", filename));
1095
 
        return A_ENOENT;
 
1070
 
 
1071
    if (*buf == NULL) {
 
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));
 
1074
                    return A_ENOENT;
 
1075
            }
 
1076
 
 
1077
            *buf = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
 
1078
            *buf_len = fw_entry->size;
 
1079
            A_RELEASE_FIRMWARE(fw_entry);
1096
1080
    }
1097
1081
 
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);
1101
1085
    }
1102
1086
#endif 
1103
1087
 
1104
1088
 
1105
 
    fw_entry_size = fw_entry->size;
 
1089
    fw_entry_size = *buf_len;
1106
1090
 
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));
1122
1106
 
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))) {
1125
1109
            u32 param;
1126
1110
 
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);
1128
1112
 
1129
1113
            if (status) {
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;
1133
1116
            }
1134
1117
 
1135
1118
            /* Record the fact that extended board Data IS initialized */
1136
 
            param = 1;
1137
 
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data_initialized), (u8 *)&param, 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 *)&param, 4));
1138
1123
        }
1139
1124
        fw_entry_size = board_data_size;
1140
1125
    }
1141
1126
 
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);
1144
1129
    } else {
1145
 
        status = BMIWriteMemory(ar->arHifDevice, address, (u8 *)fw_entry->data, fw_entry_size);
 
1130
        status = BMIWriteMemory(ar->arHifDevice, address, *buf, fw_entry_size);
1146
1131
    }
1147
1132
 
1148
1133
    if (status) {
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;
1152
1136
    }
1153
 
    A_RELEASE_FIRMWARE(fw_entry);
 
1137
 
1154
1138
    return 0;
1155
1139
}
1156
 
#endif /* INIT_MODE_DRV_ENABLED */
1157
1140
 
1158
1141
int
1159
1142
ar6000_update_bdaddr(struct ar6_softc *ar)
1200
1183
        }
1201
1184
 
1202
1185
        A_RELEASE_FIRMWARE(fw_entry);
1203
 
#ifdef INIT_MODE_DRV_ENABLED
1204
1186
    } else {
1205
1187
        /* The config is contained within the driver itself */
1206
1188
        int status;
1293
1275
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data_initialized), (u8 *)&param, 4));
1294
1276
 
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)
 
1280
                  address = 0x1234;
1297
1281
            status = ar6000_transfer_bin_file(ar, AR6K_OTP_FILE, address, true);
1298
1282
            if (status == 0) {
1299
1283
                /* Execute the OTP code */
1309
1293
        }
1310
1294
 
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)
 
1298
                address = 0x1234;
1313
1299
        if ((ar6000_transfer_bin_file(ar, AR6K_FIRMWARE_FILE, address, true)) != 0) {
1314
1300
            return A_ERROR;
1315
1301
        }
1318
1304
        AR6K_APP_START_OVERRIDE_ADDRESS(address, ar->arVersion.target_ver);
1319
1305
        bmifn(BMISetAppStart(ar->arHifDevice, address));
1320
1306
 
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) {
1324
 
            return A_ERROR;
1325
 
        }
1326
 
 
1327
 
        param = address;
1328
 
        bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dset_list_head), (u8 *)&param, 4));
1329
 
 
1330
 
        if (ar->arTargetType == TARGET_TYPE_AR6003) {
1331
 
            if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1332
 
                /* Reserve 5.5K of RAM */
1333
 
                param = 5632;
1334
 
            } else { /* AR6003_REV2_VERSION */
1335
 
                /* Reserve 6.5K of RAM */
1336
 
                param = 6656;
1337
 
            }
1338
 
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_end_RAM_reserve_sz), (u8 *)&param, 4));
1339
 
        }
 
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)
 
1311
                        return A_ERROR;
 
1312
                param = address;
 
1313
                bmifn(BMIWriteMemory(ar->arHifDevice,
 
1314
                HOST_INTEREST_ITEM_ADDRESS(ar, hi_dset_list_head),
 
1315
                                           (unsigned char *)&param, 4));
 
1316
        }
1340
1317
 
1341
1318
        /* Restore system sleep */
1342
1319
        address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS;
1390
1367
            msleep(1000);
1391
1368
        }
1392
1369
#endif /* HTC_RAW_INTERFACE */
1393
 
 
1394
 
#endif /* INIT_MODE_DRV_ENABLED */
1395
1370
    }
1396
1371
 
1397
1372
    return 0;
1470
1445
            return A_ERROR;
1471
1446
        }
1472
1447
 
 
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);
 
1452
 
1474
1453
 
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.
1520
1499
     */
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),
1525
 
            (u8 *)&param,
1526
 
            4) != 0)
1527
 
        {
1528
 
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for hi_board_ext_data failed \n"));
1529
 
            return A_ERROR;
1530
 
        }
1531
 
    }
1532
1500
 
 
1501
        if (ar->arTargetType == TARGET_TYPE_AR6003) {
 
1502
                u32 ramReservedSz;
 
1503
                if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
 
1504
                        param = AR6003_REV2_BOARD_EXT_DATA_ADDRESS;
 
1505
                        ramReservedSz =  AR6003_REV2_RAM_RESERVE_SIZE;
 
1506
                } else {
 
1507
                        param = AR6003_REV3_BOARD_EXT_DATA_ADDRESS;
 
1508
                        ramReservedSz =  AR6003_REV3_RAM_RESERVE_SIZE;
 
1509
                }
 
1510
                if (BMIWriteMemory(ar->arHifDevice,
 
1511
                        HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data),
 
1512
                                                   (u8 *)&param, 4) != 0) {
 
1513
                                AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
 
1514
                                                ("BMIWriteMemory for "
 
1515
                                                 "hi_board_ext_data failed\n"));
 
1516
                                return A_ERROR;
 
1517
                }
 
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"));
 
1525
                        return A_ERROR;
 
1526
                }
 
1527
        }
1533
1528
 
1534
1529
        /* since BMIInit is called in the driver layer, we have to set the block
1535
1530
         * size here for the target */
1555
1550
{
1556
1551
    dev->netdev_ops = &ar6000_netdev_ops;
1557
1552
    dev->watchdog_timeo = AR6000_TX_TIMEOUT;
1558
 
    dev->wireless_handlers = &ath_iw_handler_def;
1559
 
 
1560
 
    ath_iw_handler_def.get_wireless_stats = ar6000_get_iwstats; /*Displayed via proc fs */
1561
1553
 
1562
1554
   /*
1563
1555
    * We need the OS to provide us with more headroom in order to
1575
1567
        strcpy(dev->name, name);
1576
1568
    }
1577
1569
 
1578
 
#ifdef SET_MODULE_OWNER
1579
 
    SET_MODULE_OWNER(dev);
1580
 
#endif
1581
 
 
1582
1570
#ifdef CONFIG_CHECKSUM_OFFLOAD
1583
1571
    if(csumOffload){
1584
1572
        dev->features |= NETIF_F_IP_CSUM; /*advertise kernel capability to do TCP/UDP CSUM offload for IPV4*/
1588
1576
    return;
1589
1577
}
1590
1578
 
 
1579
static int __ath6kl_init_netdev(struct net_device *dev)
 
1580
{
 
1581
        int r;
 
1582
 
 
1583
        rtnl_lock();
 
1584
        r = ar6000_init(dev);
 
1585
        rtnl_unlock();
 
1586
 
 
1587
        if (r) {
 
1588
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_init\n"));
 
1589
                return r;
 
1590
        }
 
1591
 
 
1592
        return 0;
 
1593
}
 
1594
 
 
1595
#ifdef HTC_RAW_INTERFACE
 
1596
static int ath6kl_init_netdev_wmi(struct net_device *dev)
 
1597
{
 
1598
        if (!eppingtest && bypasswmi)
 
1599
                return 0;
 
1600
 
 
1601
        return __ath6kl_init_netdev(dev);
 
1602
}
 
1603
#else
 
1604
static int ath6kl_init_netdev_wmi(struct net_device *dev)
 
1605
{
 
1606
        return __ath6kl_init_netdev(dev);
 
1607
}
 
1608
#endif
 
1609
 
 
1610
static int ath6kl_init_netdev(struct ar6_softc *ar)
 
1611
{
 
1612
        int r;
 
1613
 
 
1614
        r = ar6000_sysfs_bmi_get_config(ar, wlaninitmode);
 
1615
        if (r) {
 
1616
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
 
1617
                                ("ar6000_avail: "
 
1618
                                 "ar6000_sysfs_bmi_get_config failed\n"));
 
1619
                return r;
 
1620
        }
 
1621
 
 
1622
        return ath6kl_init_netdev_wmi(ar->arNetDev);
 
1623
}
 
1624
 
1591
1625
/*
1592
1626
 * HTC Event handlers
1593
1627
 */
1600
1634
    struct ar6_softc *ar;
1601
1635
    int device_index = 0;
1602
1636
    struct htc_init_info  htcInfo;
1603
 
#ifdef ATH6K_CONFIG_CFG80211
1604
1637
    struct wireless_dev *wdev;
1605
 
#endif /* ATH6K_CONFIG_CFG80211 */
1606
 
    int init_status = 0;
 
1638
    int r = 0;
1607
1639
    struct hif_device_os_device_info osDevInfo;
1608
1640
 
1609
1641
    memset(&osDevInfo, 0, sizeof(osDevInfo));
1630
1662
    /* we use another local "i" variable below.                      */
1631
1663
    device_index = i;
1632
1664
 
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;
1638
1669
    }
1639
1670
    ar_netif = wdev_priv(wdev);
1640
 
#else
1641
 
    dev = alloc_etherdev(sizeof(struct ar6_softc));
1642
 
    if (dev == NULL) {
1643
 
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_available: can't alloc etherdev\n"));
1644
 
        return A_ERROR;
1645
 
    }
1646
 
    ether_setup(dev);
1647
 
    ar_netif = ar6k_priv(dev);
1648
 
#endif /* ATH6K_CONFIG_CFG80211 */
1649
1671
 
1650
1672
    if (ar_netif == NULL) {
1651
1673
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Can't allocate ar6k priv memory\n", __func__));
1655
1677
    A_MEMZERO(ar_netif, sizeof(struct ar6_softc));
1656
1678
    ar = (struct ar6_softc *)ar_netif;
1657
1679
 
1658
 
#ifdef ATH6K_CONFIG_CFG80211
1659
1680
    ar->wdev = wdev;
1660
1681
    wdev->iftype = NL80211_IFTYPE_STATION;
1661
1682
 
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;
1675
1696
 
1676
1697
    init_netdev(dev, ifname);
1677
1698
 
1678
 
#ifdef SET_NETDEV_DEV
1679
 
    if (ar_netif) { 
1680
 
        SET_NETDEV_DEV(dev, osDevInfo.pOSDevice);
1681
 
    }
1682
 
#endif 
1683
1699
 
1684
1700
    ar->arNetDev             = dev;
1685
1701
    ar->arHifDevice          = hif_handle;
1719
1735
 
1720
1736
    BMIInit();
1721
1737
 
1722
 
    if (bmienable) {
1723
 
        ar6000_sysfs_bmi_init(ar);
1724
 
    }
 
1738
    ar6000_sysfs_bmi_init(ar);
1725
1739
 
1726
1740
    {
1727
1741
        struct bmi_target_info targ_info;
1728
1742
 
1729
 
        if (BMIGetTargetInfo(ar->arHifDevice, &targ_info) != 0) {
1730
 
            init_status = A_ERROR;
 
1743
        r = BMIGetTargetInfo(ar->arHifDevice, &targ_info);
 
1744
        if (r)
1731
1745
            goto avail_ev_failed;
1732
 
        }
1733
1746
 
1734
1747
        ar->arVersion.target_ver = targ_info.target_ver;
1735
1748
        ar->arTargetType = targ_info.target_type;
1736
 
 
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;
1743
 
        }
1744
 
 
1745
 
    }
1746
 
 
1747
 
    if (ar6000_configure_target(ar) != 0) {
1748
 
            init_status = A_ERROR;
1749
 
            goto avail_ev_failed;
1750
 
    }
 
1749
        wdev->wiphy->hw_version = targ_info.target_ver;
 
1750
    }
 
1751
 
 
1752
    r = ar6000_configure_target(ar);
 
1753
    if (r)
 
1754
            goto avail_ev_failed;
1751
1755
 
1752
1756
    A_MEMZERO(&htcInfo,sizeof(htcInfo));
1753
1757
    htcInfo.pContext = ar;
1755
1759
 
1756
1760
    ar->arHtcTarget = HTCCreate(ar->arHifDevice,&htcInfo);
1757
1761
 
1758
 
    if (ar->arHtcTarget == NULL) {
1759
 
        init_status = A_ERROR;
 
1762
    if (!ar->arHtcTarget) {
 
1763
        r = -ENOMEM;
1760
1764
        goto avail_ev_failed;
1761
1765
    }
1762
1766
 
1767
1771
#endif
1768
1772
 
1769
1773
 
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;
1774
1777
    }
1775
 
#endif
1776
1778
 
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;
 
1782
            r = -ENOMEM;
1781
1783
            goto avail_ev_failed;
1782
1784
    }
1783
1785
 
1784
1786
    aggr_register_rx_dispatcher(ar->aggr_cntxt, (void *)dev, ar6000_deliver_frames_to_nw_stack);
1785
 
#endif
1786
1787
 
1787
1788
    HIFClaimDevice(ar->arHifDevice, ar);
1788
1789
 
1791
1792
    /* when the module is unloaded.                                  */
1792
1793
    ar6000_devices[device_index] = dev;
1793
1794
 
1794
 
    /* Don't install the init function if BMI is requested */
1795
 
    if (!bmienable) {
1796
 
        ar6000_netdev_ops.ndo_init = ar6000_init;
1797
 
    } else {
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))
1801
 
        {
1802
 
            int status = 0;
1803
 
            do {
1804
 
                if ((status = ar6000_sysfs_bmi_get_config(ar, wlaninitmode)) != 0)
1805
 
                {
1806
 
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n"));
1807
 
                    break;
1808
 
                }
1809
 
#ifdef HTC_RAW_INTERFACE
1810
 
                if (!eppingtest && bypasswmi) {
1811
 
                    break; /* Don't call ar6000_init for ART */
1812
 
                }
1813
 
#endif 
1814
 
                rtnl_lock();
1815
 
                status = (ar6000_init(dev)==0) ? 0 : A_ERROR;
1816
 
                rtnl_unlock();
1817
 
                if (status) {
1818
 
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_init\n"));
1819
 
                }
1820
 
            } while (false);
1821
 
 
1822
 
            if (status) {
1823
 
                init_status = status;
1824
 
                goto avail_ev_failed;
1825
 
            }
1826
 
        }
 
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);
 
1799
        if (r)
 
1800
            goto avail_ev_failed;
1827
1801
    }
1828
1802
 
1829
1803
    /* This runs the init function if registered */
1830
 
    if (register_netdev(dev)) {
 
1804
    r = register_netdev(dev);
 
1805
    if (r) {
1831
1806
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: register_netdev failed\n"));
1832
1807
        ar6000_destroy(dev, 0);
1833
 
        return A_ERROR;
 
1808
        return r;
1834
1809
    }
1835
1810
 
1836
1811
        is_netdev_registered = 1;
1843
1818
                    (unsigned long)ar));
1844
1819
 
1845
1820
avail_ev_failed :
1846
 
    if (init_status) {
1847
 
        if (bmienable) { 
1848
 
            ar6000_sysfs_bmi_deinit(ar);  
1849
 
        }
1850
 
    }
 
1821
    if (r)
 
1822
        ar6000_sysfs_bmi_deinit(ar);  
1851
1823
 
1852
 
    return init_status;
 
1824
    return r;
1853
1825
}
1854
1826
 
1855
1827
static void ar6000_target_failure(void *Instance, int Status)
1880
1852
            sip = true;
1881
1853
            errEvent.errorVal = WMI_TARGET_COM_ERR |
1882
1854
                                WMI_TARGET_FATAL_ERR;
1883
 
            ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
1884
 
                                     (u8 *)&errEvent,
1885
 
                                     sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
1886
1855
        }
1887
1856
    }
1888
1857
}
1980
1949
                    ar6000_disconnect_event(ar, DISCONNECT_CMD, ar->arBssid, 0, NULL, 0);
1981
1950
                }
1982
1951
            }
1983
 
#ifdef USER_KEYS
1984
1952
            ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
1985
1953
            ar->user_key_ctrl      = 0;
1986
 
#endif
1987
1954
        }
1988
1955
 
1989
1956
         AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("%s(): WMI stopped\n", __func__));
2025
1992
        if (setuphci)
2026
1993
                ar6000_cleanup_hci(ar);
2027
1994
#endif
2028
 
#ifdef EXPORT_HCI_PAL_INTERFACE
2029
 
        if (setuphcipal && (NULL != ar6kHciPalCallbacks_g.cleanupTransport)) {
2030
 
           ar6kHciPalCallbacks_g.cleanupTransport(ar);
2031
 
        }
2032
 
#else
2033
 
                                /* cleanup hci pal driver data structures */
2034
 
        if(setuphcipal)
2035
 
          ar6k_cleanup_hci_pal(ar);
2036
 
#endif
2037
1995
        AR_DEBUG_PRINTF(ATH_DEBUG_INFO,(" Shutting down HTC .... \n"));
2038
1996
        /* stop HTC */
2039
1997
        HTCStop(ar->arHtcTarget);
2094
2052
    if (ar->arWlanPowerState != WLAN_POWER_STATE_CUT_PWR) {
2095
2053
        /* only stop endpoint if we are not stop it in suspend_ev */
2096
2054
        ar6000_stop_endpoint(dev, false, true);
2097
 
    } else {
2098
 
        /* clear up the platform power state before rmmod */
2099
 
        plat_setup_power(1,0);
2100
2055
    }
2101
2056
 
2102
2057
    ar->arWlanState = WLAN_DISABLED;
2110
2065
        HIFReleaseDevice(ar->arHifDevice);
2111
2066
        HIFShutDownDevice(ar->arHifDevice);
2112
2067
    }
2113
 
#ifdef ATH_AR6K_11N_SUPPORT
2114
2068
    aggr_module_destroy(ar->aggr_cntxt);
2115
 
#endif
2116
2069
 
2117
2070
       /* Done with cookies */
2118
2071
    ar6000_cookie_cleanup(ar);
2120
2073
        /* cleanup any allocated AMSDU buffers */
2121
2074
    ar6000_cleanup_amsdu_rxbufs(ar);
2122
2075
 
2123
 
    if (bmienable) {
2124
 
        ar6000_sysfs_bmi_deinit(ar);
2125
 
    }
 
2076
    ar6000_sysfs_bmi_deinit(ar);
2126
2077
 
2127
2078
    /* Cleanup BMI */
2128
2079
    BMICleanup();
2134
2085
 
2135
2086
#ifdef HTC_RAW_INTERFACE
2136
2087
    if (ar->arRawHtc) {
2137
 
        A_FREE(ar->arRawHtc);
 
2088
        kfree(ar->arRawHtc);
2138
2089
        ar->arRawHtc = NULL;
2139
2090
    }
2140
2091
#endif 
2145
2096
    }
2146
2097
    free_netdev(dev);
2147
2098
 
2148
 
#ifdef ATH6K_CONFIG_CFG80211
2149
2099
    ar6k_cfg80211_deinit(ar);
2150
 
#endif /* ATH6K_CONFIG_CFG80211 */
2151
2100
 
2152
2101
#ifdef CONFIG_AP_VIRTUL_ADAPTER_SUPPORT
2153
2102
    ar6000_remove_ap_interface();
2154
2103
#endif /*CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
2155
2104
 
 
2105
    kfree(ar->fw_otp);
 
2106
    kfree(ar->fw);
 
2107
    kfree(ar->fw_patch);
 
2108
    kfree(ar->fw_data);
 
2109
 
2156
2110
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("-ar6000_destroy \n"));
2157
2111
}
2158
2112
 
2187
2141
        ar->arHBChallengeResp.seqNum = 0;
2188
2142
        errEvent.errorVal = WMI_TARGET_COM_ERR | WMI_TARGET_FATAL_ERR;
2189
2143
        AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2190
 
        ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
2191
 
                                 (u8 *)&errEvent,
2192
 
                                 sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
2193
2144
        return;
2194
2145
    }
2195
2146
 
2295
2246
 
2296
2247
    spin_lock_irqsave(&ar->arLock, flags);
2297
2248
 
2298
 
#ifdef ATH6K_CONFIG_CFG80211
2299
2249
    if(ar->arWlanState == WLAN_DISABLED) {
2300
2250
        ar->arWlanState = WLAN_ENABLED;
2301
2251
    }
2302
 
#endif /* ATH6K_CONFIG_CFG80211 */
2303
2252
 
2304
2253
    if( ar->arConnected || bypasswmi) {
2305
2254
        netif_carrier_on(dev);
2316
2265
static int
2317
2266
ar6000_close(struct net_device *dev)
2318
2267
{
2319
 
#ifdef ATH6K_CONFIG_CFG80211
2320
2268
    struct ar6_softc    *ar = (struct ar6_softc *)ar6k_priv(dev);
2321
 
#endif /* ATH6K_CONFIG_CFG80211 */
2322
2269
    netif_stop_queue(dev);
2323
2270
 
2324
 
#ifdef ATH6K_CONFIG_CFG80211
2325
2271
    ar6000_disconnect(ar);
2326
2272
 
2327
2273
    if(ar->arWmiReady == true) {
2332
2278
        ar->arWlanState = WLAN_DISABLED;
2333
2279
    }
2334
2280
        ar6k_cfg80211_scanComplete_event(ar, A_ECANCELED);
2335
 
#endif /* ATH6K_CONFIG_CFG80211 */
2336
2281
 
2337
2282
    return 0;
2338
2283
}
2422
2367
    return(arEndpoint2Ac(ar, ep ));
2423
2368
}
2424
2369
 
 
2370
#if defined(CONFIG_ATH6KL_ENABLE_COEXISTENCE)
 
2371
static int ath6kl_config_btcoex_params(struct ar6_softc *ar)
 
2372
{
 
2373
        int r;
 
2374
        WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD sbcb_cmd;
 
2375
        WMI_SET_BTCOEX_FE_ANT_CMD sbfa_cmd;
 
2376
 
 
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;
 
2380
 
 
2381
        r = wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &sbcb_cmd);
 
2382
 
 
2383
        if (r) {
 
2384
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
 
2385
                                ("Unable to set collocated BT type\n"));
 
2386
                return r;
 
2387
        }
 
2388
 
 
2389
        /* Configure the type of BT collocated with WLAN */
 
2390
        memset(&sbfa_cmd, 0, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD));
 
2391
 
 
2392
        sbfa_cmd.btcoexFeAntType = ATH6KL_BT_ANTENNA;
 
2393
 
 
2394
        r = wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &sbfa_cmd);
 
2395
        if (r) {
 
2396
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
 
2397
                                ("Unable to set fornt end antenna configuration\n"));
 
2398
                return r;
 
2399
        }
 
2400
 
 
2401
        return 0;
 
2402
}
 
2403
#else
 
2404
static int ath6kl_config_btcoex_params(struct ar6_softc *ar)
 
2405
{
 
2406
        return 0;
 
2407
}
 
2408
#endif /* CONFIG_ATH6KL_ENABLE_COEXISTENCE */
 
2409
 
2425
2410
/*
2426
2411
 * This function applies WLAN specific configuration defined in wlan_config.h
2427
2412
 */
2428
2413
int ar6000_target_config_wlan_params(struct ar6_softc *ar)
2429
2414
{
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 */
2435
2416
 
2436
2417
#ifdef CONFIG_HOST_TCMD_SUPPORT
2437
2418
    if (ar->arTargetMode != AR6000_WLAN_MODE) {
2449
2430
        status = A_ERROR;
2450
2431
    }
2451
2432
 
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;
2461
 
#else
2462
 
#error Unsupported Bluetooth Type
2463
 
#endif /* Collocated Bluetooth Type */
2464
 
 
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"));
2467
 
        status = A_ERROR;
2468
 
    }
2469
 
 
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;
2476
 
#else
2477
 
#error Unsupported Front-End Antenna Configuration
2478
 
#endif /* AR600x Front-End Antenna Configuration */
2479
 
 
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"));
2482
 
        status = A_ERROR;
2483
 
    }
2484
 
#endif /* INIT_MODE_DRV_ENABLED && ENABLE_COEXISTENCE */
 
2433
    status = ath6kl_config_btcoex_params(ar);
 
2434
    if (status)
 
2435
        return status;
2485
2436
 
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) {
2736
2687
            status = ar6000_setup_hci(ar);
2737
2688
        }
2738
2689
#endif
2739
 
#ifdef EXPORT_HCI_PAL_INTERFACE
2740
 
        if (setuphcipal && (NULL != ar6kHciPalCallbacks_g.setupTransport))
2741
 
          status = ar6kHciPalCallbacks_g.setupTransport(ar);
2742
 
#else
2743
 
        if(setuphcipal)
2744
 
          status = ar6k_setup_hci_pal(ar);
2745
 
#endif
2746
2690
 
2747
2691
    } while (false);
2748
2692
 
2751
2695
        goto ar6000_init_done;
2752
2696
    }
2753
2697
 
 
2698
        if (regscanmode) {
 
2699
                u32 param;
 
2700
 
 
2701
                if (BMIReadMemory(ar->arHifDevice,
 
2702
                                  HOST_INTEREST_ITEM_ADDRESS(ar,
 
2703
                                                             hi_option_flag),
 
2704
                                                             (u8 *)&param,
 
2705
                                                             4) != 0) {
 
2706
                        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
 
2707
                                        ("BMIReadMemory forsetting "
 
2708
                                         "regscanmode failed\n"));
 
2709
                        return A_ERROR;
 
2710
                }
 
2711
 
 
2712
                if (regscanmode == 1)
 
2713
                        param |= HI_OPTION_SKIP_REG_SCAN;
 
2714
                else if (regscanmode == 2)
 
2715
                        param |= HI_OPTION_INIT_REG_SCAN;
 
2716
 
 
2717
                if (BMIWriteMemory(ar->arHifDevice,
 
2718
                                   HOST_INTEREST_ITEM_ADDRESS(ar,
 
2719
                                                              hi_option_flag),
 
2720
                                                              (u8 *)&param,
 
2721
                                                              4) != 0) {
 
2722
                        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
 
2723
                                        ("BMIWriteMemory forsetting "
 
2724
                                        "regscanmode failed\n"));
 
2725
                        return A_ERROR;
 
2726
                }
 
2727
                AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("Regulatory scan mode set\n"));
 
2728
        }
 
2729
 
2754
2730
    /*
2755
2731
     * give our connected endpoints some buffers
2756
2732
     */
3095
3071
        }
3096
3072
 
3097
3073
        if (ar->arWmiEnabled) {
3098
 
#ifdef CONFIG_CHECKSUM_OFFLOAD
3099
3074
        u8 csumStart=0;
3100
3075
        u8 csumDest=0;
3101
3076
        u8 csum=skb->ip_summed;
3104
3079
                         sizeof(ATH_LLC_SNAP_HDR));
3105
3080
            csumDest=skb->csum_offset+csumStart;
3106
3081
        }
3107
 
#endif
3108
3082
            if (A_NETBUF_HEADROOM(skb) < dev->hard_header_len - LINUX_HACK_FUDGE_FACTOR) {
3109
3083
                struct sk_buff  *newbuf;
3110
3084
 
3135
3109
                    break;
3136
3110
                }
3137
3111
            }
3138
 
#ifdef CONFIG_CHECKSUM_OFFLOAD
3139
3112
            if(csumOffload && (csum ==CHECKSUM_PARTIAL)){
3140
3113
                WMI_TX_META_V2  metaV2;
3141
3114
                metaV2.csumStart =csumStart;
3149
3122
 
3150
3123
            }
3151
3124
            else
3152
 
#endif
3153
3125
            {
3154
3126
                if (wmi_data_hdr_add(ar->arWmi, skb, DATA_MSGTYPE, bMoreData, dot11Hdr,0,NULL) != 0) {
3155
3127
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
3704
3676
                WMI_DATA_HDR *dhdr = (WMI_DATA_HDR *)A_NETBUF_DATA(skb);
3705
3677
                bool is_amsdu;
3706
3678
                u8 tid;
3707
 
                bool is_acl_data_frame;
3708
 
                is_acl_data_frame = WMI_DATA_HDR_GET_DATA_TYPE(dhdr) == WMI_DATA_HDR_DATA_TYPE_ACL;
 
3679
 
 
3680
                /*
 
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.
 
3688
                 */
 
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);
 
3692
                        A_NETBUF_FREE(skb);
 
3693
                        return;
 
3694
                }
 
3695
 
3709
3696
#ifdef CONFIG_PM 
3710
3697
                ar6000_check_wow_status(ar, NULL, false);
3711
3698
#endif /* CONFIG_PM */
3727
3714
                 * ACL data frames don't follow ethernet frame bounds for
3728
3715
                 * min length
3729
3716
                 */
3730
 
                if (ar->arNetworkType != AP_NETWORK &&  !is_acl_data_frame &&
 
3717
                if (ar->arNetworkType != AP_NETWORK &&
3731
3718
                    ((pPacket->ActualLength < minHdrLen) ||
3732
3719
                    (pPacket->ActualLength > AR6000_MAX_RX_MESSAGE_SIZE)))
3733
3720
                {
3767
3754
                            case WMI_META_VERSION_1:
3768
3755
                                offset += sizeof(WMI_RX_META_V1);
3769
3756
                                break;
3770
 
#ifdef CONFIG_CHECKSUM_OFFLOAD
3771
3757
                            case WMI_META_VERSION_2:
3772
3758
                                offset += sizeof(WMI_RX_META_V2);
3773
3759
                                break;
3774
 
#endif
3775
3760
                            default:
3776
3761
                                break;
3777
3762
                        }
3841
3826
                                A_NETBUF_PULL((void*)skb, sizeof(WMI_RX_META_V1));
3842
3827
                                break;
3843
3828
                            }
3844
 
#ifdef CONFIG_CHECKSUM_OFFLOAD
3845
3829
                        case WMI_META_VERSION_2:
3846
3830
                            {
3847
3831
                                WMI_RX_META_V2 *pMeta = (WMI_RX_META_V2 *)A_NETBUF_DATA(skb);
3852
3836
                                A_NETBUF_PULL((void*)skb, sizeof(WMI_RX_META_V2));
3853
3837
                                break;
3854
3838
                            }
3855
 
#endif
3856
3839
                        default:
3857
3840
                            break;
3858
3841
                    }
3862
3845
                    /* NWF: print the 802.11 hdr bytes */
3863
3846
                    if(containsDot11Hdr) {
3864
3847
                        status = wmi_dot11_hdr_remove(ar->arWmi,skb);
3865
 
                    } else if(!is_amsdu && !is_acl_data_frame) {
 
3848
                    } else if(!is_amsdu) {
3866
3849
                        status = wmi_dot3_2_dix(skb);
3867
3850
                    }
3868
3851
 
3872
3855
                        goto rx_done;
3873
3856
                    }
3874
3857
 
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)
3881
 
                                        goto rx_done;
3882
 
                        }
3883
 
                    }
3884
 
 
3885
3858
                    if ((ar->arNetDev->flags & IFF_UP) == IFF_UP) {
3886
3859
                        if (ar->arNetworkType == AP_NETWORK) {
3887
3860
                            struct sk_buff *skb1 = NULL;
3915
3888
                            }
3916
3889
                        }
3917
3890
                    }
3918
 
#ifdef ATH_AR6K_11N_SUPPORT
3919
3891
                    aggr_process_recv_frm(ar->aggr_cntxt, tid, seq_no, is_amsdu, (void **)&skb);
3920
 
#endif
3921
3892
                    ar6000_deliver_frames_to_nw_stack((void *) ar->arNetDev, (void *)skb);
3922
3893
                }
3923
3894
            }
4146
4117
    return &ar->arNetStats;
4147
4118
}
4148
4119
 
4149
 
static struct iw_statistics *
4150
 
ar6000_get_iwstats(struct net_device * dev)
4151
 
{
4152
 
    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
4153
 
    TARGET_STATS *pStats = &ar->arTargetStats;
4154
 
    struct iw_statistics * pIwStats = &ar->arIwStats;
4155
 
    int rtnllocked;
4156
 
 
4157
 
    if (ar->bIsDestroyProgress || ar->arWmiReady == false || ar->arWlanState == WLAN_DISABLED)
4158
 
    {
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;
4166
 
        return pIwStats;
4167
 
    }
4168
 
 
4169
 
    /*
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.
4175
 
     */
4176
 
    if (in_atomic())
4177
 
    {
4178
 
        wmi_get_stats_cmd(ar->arWmi);
4179
 
 
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;
4187
 
        return pIwStats;
4188
 
    }
4189
 
 
4190
 
    dev_hold(dev);   
4191
 
    rtnllocked = rtnl_is_locked();
4192
 
    if (rtnllocked) {
4193
 
        rtnl_unlock();
4194
 
    }
4195
 
    pIwStats->status = 0;
4196
 
 
4197
 
    if (down_interruptible(&ar->arSem)) {
4198
 
        goto err_exit;
4199
 
    }
4200
 
    
4201
 
    do {
4202
 
 
4203
 
        if (ar->bIsDestroyProgress || ar->arWlanState == WLAN_DISABLED) {
4204
 
            break;
4205
 
        }
4206
 
    
4207
 
        ar->statsUpdatePending = true;
4208
 
    
4209
 
        if(wmi_get_stats_cmd(ar->arWmi) != 0) {
4210
 
            break;
4211
 
        }
4212
 
    
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"));
4216
 
            break;
4217
 
        }
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;
4225
 
    } while (0);
4226
 
    up(&ar->arSem);
4227
 
 
4228
 
err_exit:
4229
 
    if (rtnllocked) {
4230
 
        rtnl_lock();
4231
 
    }
4232
 
    dev_put(dev);
4233
 
    return pIwStats;
4234
 
}
4235
 
 
4236
4120
void
4237
4121
ar6000_ready_event(void *devt, u8 *datap, u8 phyCap, u32 sw_ver, u32 abi_ver)
4238
4122
{
4254
4138
    wake_up(&arEvent);
4255
4139
}
4256
4140
 
 
4141
void ar6000_install_static_wep_keys(struct ar6_softc *ar)
 
4142
{
 
4143
    u8 index;
 
4144
    u8 keyUsage;
 
4145
 
 
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;
 
4151
            }
 
4152
            wmi_addKey_cmd(ar->arWmi,
 
4153
                           index,
 
4154
                           WEP_CRYPT,
 
4155
                           keyUsage,
 
4156
                           ar->arWepKeyList[index].arKeyLen,
 
4157
                           NULL,
 
4158
                           ar->arWepKeyList[index].arKey, KEY_OP_INIT_VAL, NULL,
 
4159
                           NO_SYNC_WMIFLAG);
 
4160
        }
 
4161
    }
 
4162
}
 
4163
 
4257
4164
void
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)
4344
4251
            default:
4345
4252
                A_PRINTF("AUTH: Unknown\n");
4346
4253
                break;
4347
 
        };
 
4254
        }
4348
4255
        switch (listenInterval&0xFF) {
4349
4256
            case WPA_PSK_AUTH:
4350
4257
                A_PRINTF("KeyMgmt: WPA-PSK\n");
4355
4262
            default:
4356
4263
                A_PRINTF("KeyMgmt: NONE\n");
4357
4264
                break;
4358
 
        };
 
4265
        }
4359
4266
        switch (beaconInterval) {
4360
4267
            case AES_CRYPT:
4361
4268
                A_PRINTF("Cipher: AES\n");
4374
4281
            default:
4375
4282
                A_PRINTF("Cipher: NONE\n");
4376
4283
                break;
4377
 
        };
 
4284
        }
4378
4285
 
4379
4286
        add_new_sta(ar, bssid, channel /*aid*/,
4380
4287
            assocInfo /* WPA IE */, assocRespLen /* IE len */,
4392
4299
        return;
4393
4300
    }
4394
4301
 
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,
4400
4306
                                assocInfo);
4401
 
#endif /* ATH6K_CONFIG_CFG80211 */
4402
4307
 
4403
4308
    memcpy(ar->arBssid, bssid, sizeof(ar->arBssid));
4404
4309
    ar->arBssChannel = channel;
4495
4400
        wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
4496
4401
    }
4497
4402
 
4498
 
#ifdef USER_KEYS
4499
4403
    if (ar->user_savedkeys_stat == USER_SAVEDKEYS_STAT_RUN &&
4500
4404
        ar->user_saved_keys.keyOk == true)
4501
4405
    {
4508
4412
        }
4509
4413
        ar6000_reinstall_keys(ar, key_op_ctrl);
4510
4414
    }
4511
 
#endif /* USER_KEYS */
4512
4415
 
4513
4416
    netif_wake_queue(ar->arNetDev);
4514
4417
 
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))
4521
 
    {
4522
 
        if (!ar->arConnected) {
4523
 
            wmi_addKey_cmd(ar->arWmi,
4524
 
                           ar->arDefTxKeyIndex,
4525
 
                           WEP_CRYPT,
4526
 
                           GROUP_USAGE | TX_USAGE,
4527
 
                           ar->arWepKeyList[ar->arDefTxKeyIndex].arKeyLen,
4528
 
                           NULL,
4529
 
                           ar->arWepKeyList[ar->arDefTxKeyIndex].arKey, KEY_OP_INIT_VAL, NULL,
4530
 
                           NO_SYNC_WMIFLAG);
4531
 
        }
4532
 
    }
4533
 
#endif /* ATH6K_CONFIG_CFG80211 */
4534
 
 
4535
4418
    /* Update connect & link status atomically */
4536
4419
    spin_lock_irqsave(&ar->arLock, flags);
4537
4420
    ar->arConnected  = true;
4661
4544
        return;
4662
4545
    }
4663
4546
 
4664
 
#ifdef ATH6K_CONFIG_CFG80211
4665
4547
    ar6k_cfg80211_disconnect_event(ar, reason, bssid,
4666
4548
                                   assocRespLen, assocInfo,
4667
4549
                                   protocolReasonStatus);
4668
 
#endif /* ATH6K_CONFIG_CFG80211 */
4669
4550
 
4670
4551
    /* Send disconnect event to supplicant */
4671
4552
    A_MEMZERO(&wrqu, sizeof(wrqu));
4751
4632
        reconnect_flag = 0;
4752
4633
    }
4753
4634
 
4754
 
#ifdef USER_KEYS
4755
4635
    if (reason != CSERV_DISCONNECT)
4756
4636
    {
4757
4637
        ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
4758
4638
        ar->user_key_ctrl      = 0;
4759
4639
    }
4760
 
#endif /* USER_KEYS */
4761
4640
 
4762
4641
    netif_stop_queue(ar->arNetDev);
4763
4642
    A_MEMZERO(ar->arBssid, sizeof(ar->arBssid));
4774
4653
    ar->arRegCode = regCode;
4775
4654
}
4776
4655
 
4777
 
#ifdef ATH_AR6K_11N_SUPPORT
4778
4656
void
4779
4657
ar6000_aggr_rcv_addba_req_evt(struct ar6_softc *ar, WMI_ADDBA_REQ_EVENT *evt)
4780
4658
{
4796
4674
{
4797
4675
    aggr_recv_delba_req_evt(ar->aggr_cntxt, evt->tid);
4798
4676
}
4799
 
#endif
4800
4677
 
4801
4678
void register_pal_cb(ar6k_pal_config_t *palConfig_p)
4802
4679
{
4828
4705
    buf += sizeof(int);
4829
4706
    memcpy(buf, cmd->buf, cmd->evt_buf_sz);
4830
4707
 
4831
 
    if(ar6k_pal_config_g.fpar6k_pal_recv_pkt)
4832
 
    {
4833
 
      /* pass the cmd packet to PAL driver */
4834
 
      if((*ar6k_pal_config_g.fpar6k_pal_recv_pkt)(ar->hcipal_info, osbuf) == true)
4835
 
        return;
4836
 
    }
4837
4708
    ar6000_deliver_frames_to_nw_stack(ar->arNetDev, osbuf);
4838
4709
    if(loghci) {
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);
4886
 
        A_FREE(pmkcand);
 
4757
        kfree(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",
4889
4760
                 tag,
4918
4789
            tag, s->mac[0],s->mac[1],s->mac[2],s->mac[3],s->mac[4],s->mac[5]);
4919
4790
    } else {
4920
4791
 
4921
 
#ifdef ATH6K_CONFIG_CFG80211
4922
4792
    ar6k_cfg80211_tkip_micerr_event(ar, keyid, ismcast);
4923
 
#endif /* ATH6K_CONFIG_CFG80211 */
4924
4793
 
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)
4938
4807
{
4939
4808
 
4940
 
#ifdef ATH6K_CONFIG_CFG80211
4941
4809
    ar6k_cfg80211_scanComplete_event(ar, status);
4942
 
#endif /* ATH6K_CONFIG_CFG80211 */
4943
4810
 
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);
5100
 
 
5101
 
    ar6000_send_event_to_app(ar, WMI_RSSI_THRESHOLD_EVENTID,(u8 *)&userRssiThold, sizeof(USER_RSSI_THOLD));
5102
4967
}
5103
4968
 
5104
4969
 
5105
4970
void
5106
4971
ar6000_hbChallengeResp_event(struct ar6_softc *ar, u32 cookie, u32 source)
5107
4972
{
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));
5112
 
    } else {
 
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;
5562
5423
    return cookie;
5563
5424
}
5564
5425
 
5565
 
#ifdef SEND_EVENT_TO_APP
5566
 
/*
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.
5570
 
 */
5571
 
#define EVENT_ID_LEN   2
5572
 
void ar6000_send_event_to_app(struct ar6_softc *ar, u16 eventId,
5573
 
                              u8 *datap, int len)
5574
 
{
5575
 
 
5576
 
#if (WIRELESS_EXT >= 15)
5577
 
 
5578
 
/* note: IWEVCUSTOM only exists in wireless extensions after version 15 */
5579
 
 
5580
 
    char *buf;
5581
 
    u16 size;
5582
 
    union iwreq_data wrqu;
5583
 
 
5584
 
    size = len + EVENT_ID_LEN;
5585
 
 
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));
5589
 
        return;
5590
 
    }
5591
 
 
5592
 
    buf = A_MALLOC_NOWAIT(size);
5593
 
    if (NULL == buf){
5594
 
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: failed to allocate %d bytes\n", __func__, size));
5595
 
        return;
5596
 
    }
5597
 
 
5598
 
    A_MEMZERO(buf, size);
5599
 
    memcpy(buf, &eventId, EVENT_ID_LEN);
5600
 
    memcpy(buf+EVENT_ID_LEN, datap, len);
5601
 
 
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);
5606
 
    A_FREE(buf);
5607
 
#endif
5608
 
 
5609
 
 
5610
 
}
5611
 
 
5612
 
/*
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.
5616
 
 */
5617
 
void ar6000_send_generic_event_to_app(struct ar6_softc *ar, u16 eventId,
5618
 
                                      u8 *datap, int len)
5619
 
{
5620
 
 
5621
 
#if (WIRELESS_EXT >= 18)
5622
 
 
5623
 
/* IWEVGENIE exists in wireless extensions version 18 onwards */
5624
 
 
5625
 
    char *buf;
5626
 
    u16 size;
5627
 
    union iwreq_data wrqu;
5628
 
 
5629
 
    size = len + EVENT_ID_LEN;
5630
 
 
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));
5634
 
        return;
5635
 
    }
5636
 
 
5637
 
    buf = A_MALLOC_NOWAIT(size);
5638
 
    if (NULL == buf){
5639
 
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: failed to allocate %d bytes\n", __func__, size));
5640
 
        return;
5641
 
    }
5642
 
 
5643
 
    A_MEMZERO(buf, size);
5644
 
    memcpy(buf, &eventId, EVENT_ID_LEN);
5645
 
    memcpy(buf+EVENT_ID_LEN, datap, len);
5646
 
 
5647
 
    A_MEMZERO(&wrqu, sizeof(wrqu));
5648
 
    wrqu.data.length = size;
5649
 
    wireless_send_event(ar->arNetDev, IWEVGENIE, &wrqu, buf);
5650
 
 
5651
 
    A_FREE(buf);
5652
 
 
5653
 
#endif /* (WIRELESS_EXT >= 18) */
5654
 
 
5655
 
}
5656
 
#endif /* SEND_EVENT_TO_APP */
5657
 
 
5658
 
 
5659
5426
void
5660
5427
ar6000_tx_retry_err_event(void *devt)
5661
5428
{
5666
5433
ar6000_snrThresholdEvent_rx(void *devt, WMI_SNR_THRESHOLD_VAL newThreshold, u8 snr)
5667
5434
{
5668
5435
    WMI_SNR_THRESHOLD_EVENT event;
5669
 
    struct ar6_softc *ar = (struct ar6_softc *)devt;
5670
5436
 
5671
5437
    event.range = newThreshold;
5672
5438
    event.snr = snr;
5673
 
 
5674
 
    ar6000_send_event_to_app(ar, WMI_SNR_THRESHOLD_EVENTID, (u8 *)&event,
5675
 
                             sizeof(WMI_SNR_THRESHOLD_EVENT));
5676
5439
}
5677
5440
 
5678
5441
void
5999
5762
}
6000
5763
#endif
6001
5764
 
6002
 
#ifdef USER_KEYS
6003
5765
static int
6004
 
 
6005
5766
ar6000_reinstall_keys(struct ar6_softc *ar, u8 key_op_ctrl)
6006
5767
{
6007
5768
    int status = 0;
6046
5807
 
6047
5808
    return status;
6048
5809
}
6049
 
#endif /* USER_KEYS */
6050
5810
 
6051
5811
 
6052
5812
void
6438
6198
    
6439
6199
    ether_setup(dev);
6440
6200
    init_netdev(dev, ap_ifname);
 
6201
    dev->priv_flags &= ~IFF_TX_SKB_SHARING;
6441
6202
 
6442
6203
    if (register_netdev(dev)) {
6443
6204
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_create_ap_interface: register_netdev failed\n"));