~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
#define LINUX_HACK_FUDGE_FACTOR 16
48
48
#define BDATA_BDADDR_OFFSET     28
49
49
 
50
 
A_UINT8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
51
 
A_UINT8 null_mac[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
 
50
u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
51
u8 null_mac[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
52
52
 
53
53
#ifdef DEBUG
54
54
 
60
60
#define  ATH_DEBUG_HTC_RAW       ATH_DEBUG_MAKE_MODULE_MASK(5)
61
61
#define  ATH_DEBUG_HCI_BRIDGE    ATH_DEBUG_MAKE_MODULE_MASK(6)
62
62
 
63
 
static ATH_DEBUG_MASK_DESCRIPTION driver_debug_desc[] = {
 
63
static struct ath_debug_mask_description driver_debug_desc[] = {
64
64
    { ATH_DEBUG_DBG_LOG      , "Target Debug Logs"},
65
65
    { ATH_DEBUG_WLAN_CONNECT , "WLAN connect"},
66
66
    { ATH_DEBUG_WLAN_SCAN    , "WLAN scan"},
102
102
#define APTC_LOWER_THROUGHPUT_THRESHOLD    2000 /* Kbps */
103
103
 
104
104
typedef struct aptc_traffic_record {
105
 
    A_BOOL timerScheduled;
 
105
    bool timerScheduled;
106
106
    struct timeval samplingTS;
107
107
    unsigned long bytesReceived;
108
108
    unsigned long bytesTransmitted;
114
114
 
115
115
#ifdef EXPORT_HCI_BRIDGE_INTERFACE
116
116
// callbacks registered by HCI transport driver
117
 
HCI_TRANSPORT_CALLBACKS ar6kHciTransCallbacks = { NULL };
 
117
struct hci_transport_callbacks ar6kHciTransCallbacks = { NULL };
118
118
#endif
119
119
 
120
120
unsigned int processDot11Hdr = 0;
123
123
char ifname[IFNAMSIZ] = {0,};
124
124
 
125
125
int wlaninitmode = WLAN_INIT_MODE_DEFAULT;
126
 
unsigned int bypasswmi = 0;
 
126
static bool bypasswmi;
127
127
unsigned int debuglevel = 0;
128
128
int tspecCompliance = ATHEROS_COMPLIANCE;
129
129
unsigned int busspeedlow = 0;
165
165
module_param_string(ifname, ifname, sizeof(ifname), 0644);
166
166
module_param(wlaninitmode, int, 0644);
167
167
module_param(bmienable, int, 0644);
168
 
module_param(bypasswmi, uint, 0644);
 
168
module_param(bypasswmi, bool, 0644);
169
169
module_param(debuglevel, uint, 0644);
170
170
module_param(tspecCompliance, int, 0644);
171
171
module_param(onebitmode, uint, 0644);
207
207
#define mboxnum &_mboxnum
208
208
 
209
209
#ifdef DEBUG
210
 
A_UINT32 g_dbg_flags = DBG_DEFAULTS;
 
210
u32 g_dbg_flags = DBG_DEFAULTS;
211
211
unsigned int debugflags = 0;
212
212
int debugdriver = 0;
213
213
unsigned int debughtc = 0;
254
254
#endif /* BLOCK_TX_PATH_FLAG */
255
255
 
256
256
typedef struct user_rssi_compensation_t {
257
 
    A_UINT16         customerID;
 
257
    u16 customerID;
258
258
    union {
259
 
    A_UINT16         a_enable;
260
 
    A_UINT16         bg_enable;
261
 
    A_UINT16         enable;
 
259
    u16 a_enable;
 
260
    u16 bg_enable;
 
261
    u16 enable;
262
262
    };
263
 
    A_INT16          bg_param_a;
264
 
    A_INT16          bg_param_b;
265
 
    A_INT16          a_param_a;
266
 
    A_INT16          a_param_b;
267
 
    A_UINT32         reserved;
 
263
    s16 bg_param_a;
 
264
    s16 bg_param_b;
 
265
    s16 a_param_a;
 
266
    s16 a_param_b;
 
267
    u32 reserved;
268
268
} USER_RSSI_CPENSATION;
269
269
 
270
270
static USER_RSSI_CPENSATION rssi_compensation_param;
271
271
 
272
 
static A_INT16 rssi_compensation_table[96];
 
272
static s16 rssi_compensation_table[96];
273
273
 
274
274
int reconnect_flag = 0;
275
275
static ar6k_pal_config_t ar6k_pal_config_g;
281
281
int ar6000_init(struct net_device *dev);
282
282
static int ar6000_open(struct net_device *dev);
283
283
static int ar6000_close(struct net_device *dev);
284
 
static void ar6000_init_control_info(AR_SOFTC_T *ar);
 
284
static void ar6000_init_control_info(struct ar6_softc *ar);
285
285
static int ar6000_data_tx(struct sk_buff *skb, struct net_device *dev);
286
286
 
287
287
void ar6000_destroy(struct net_device *dev, unsigned int unregister);
292
292
 
293
293
static void disconnect_timer_handler(unsigned long ptr);
294
294
 
295
 
void read_rssi_compensation_param(AR_SOFTC_T *ar);
 
295
void read_rssi_compensation_param(struct ar6_softc *ar);
296
296
 
297
297
    /* for android builds we call external APIs that handle firmware download and configuration */
298
298
#ifdef ANDROID_ENV
305
305
/*
306
306
 * HTC service connection handlers
307
307
 */
308
 
static A_STATUS ar6000_avail_ev(void *context, void *hif_handle);
309
 
 
310
 
static A_STATUS ar6000_unavail_ev(void *context, void *hif_handle);
311
 
 
312
 
A_STATUS ar6000_configure_target(AR_SOFTC_T *ar);
313
 
 
314
 
static void ar6000_target_failure(void *Instance, A_STATUS Status);
315
 
 
316
 
static void ar6000_rx(void *Context, HTC_PACKET *pPacket);
 
308
static int ar6000_avail_ev(void *context, void *hif_handle);
 
309
 
 
310
static int ar6000_unavail_ev(void *context, void *hif_handle);
 
311
 
 
312
int ar6000_configure_target(struct ar6_softc *ar);
 
313
 
 
314
static void ar6000_target_failure(void *Instance, int Status);
 
315
 
 
316
static void ar6000_rx(void *Context, struct htc_packet *pPacket);
317
317
 
318
318
static void ar6000_rx_refill(void *Context,HTC_ENDPOINT_ID Endpoint);
319
319
 
320
 
static void ar6000_tx_complete(void *Context, HTC_PACKET_QUEUE *pPackets);
 
320
static void ar6000_tx_complete(void *Context, struct htc_packet_queue *pPackets);
321
321
 
322
 
static HTC_SEND_FULL_ACTION ar6000_tx_queue_full(void *Context, HTC_PACKET *pPacket);
 
322
static HTC_SEND_FULL_ACTION ar6000_tx_queue_full(void *Context, struct htc_packet *pPacket);
323
323
 
324
324
#ifdef ATH_AR6K_11N_SUPPORT
325
 
static void ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, A_UINT16 num);
 
325
static void ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num);
326
326
#endif
327
327
static void ar6000_deliver_frames_to_nw_stack(void * dev, void *osbuf);
328
328
//static void ar6000_deliver_frames_to_bt_stack(void * dev, void *osbuf);
329
329
 
330
 
static HTC_PACKET *ar6000_alloc_amsdu_rxbuf(void *Context, HTC_ENDPOINT_ID Endpoint, int Length);
331
 
 
332
 
static void ar6000_refill_amsdu_rxbufs(AR_SOFTC_T *ar, int Count);
333
 
 
334
 
static void ar6000_cleanup_amsdu_rxbufs(AR_SOFTC_T *ar);
 
330
static struct htc_packet *ar6000_alloc_amsdu_rxbuf(void *Context, HTC_ENDPOINT_ID Endpoint, int Length);
 
331
 
 
332
static void ar6000_refill_amsdu_rxbufs(struct ar6_softc *ar, int Count);
 
333
 
 
334
static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc *ar);
335
335
 
336
336
static ssize_t
337
337
ar6000_sysfs_bmi_read(struct file *fp, struct kobject *kobj,
343
343
                       struct bin_attribute *bin_attr,
344
344
                       char *buf, loff_t pos, size_t count);
345
345
 
346
 
static A_STATUS
347
 
ar6000_sysfs_bmi_init(AR_SOFTC_T *ar);
 
346
static int
 
347
ar6000_sysfs_bmi_init(struct ar6_softc *ar);
348
348
 
349
349
/* HCI PAL callback function declarations */
350
 
A_STATUS ar6k_setup_hci_pal(AR_SOFTC_T *ar);
351
 
void  ar6k_cleanup_hci_pal(AR_SOFTC_T *ar);
 
350
int ar6k_setup_hci_pal(struct ar6_softc *ar);
 
351
void  ar6k_cleanup_hci_pal(struct ar6_softc *ar);
352
352
 
353
353
static void
354
 
ar6000_sysfs_bmi_deinit(AR_SOFTC_T *ar);
 
354
ar6000_sysfs_bmi_deinit(struct ar6_softc *ar);
355
355
 
356
 
A_STATUS
357
 
ar6000_sysfs_bmi_get_config(AR_SOFTC_T *ar, A_UINT32 mode);
 
356
int
 
357
ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode);
358
358
 
359
359
/*
360
360
 * Static variables
364
364
static int is_netdev_registered;
365
365
extern struct iw_handler_def ath_iw_handler_def;
366
366
DECLARE_WAIT_QUEUE_HEAD(arEvent);
367
 
static void ar6000_cookie_init(AR_SOFTC_T *ar);
368
 
static void ar6000_cookie_cleanup(AR_SOFTC_T *ar);
369
 
static void ar6000_free_cookie(AR_SOFTC_T *ar, struct ar_cookie * cookie);
370
 
static struct ar_cookie *ar6000_alloc_cookie(AR_SOFTC_T *ar);
 
367
static void ar6000_cookie_init(struct ar6_softc *ar);
 
368
static void ar6000_cookie_cleanup(struct ar6_softc *ar);
 
369
static void ar6000_free_cookie(struct ar6_softc *ar, struct ar_cookie * cookie);
 
370
static struct ar_cookie *ar6000_alloc_cookie(struct ar6_softc *ar);
371
371
 
372
372
#ifdef USER_KEYS
373
 
static A_STATUS ar6000_reinstall_keys(AR_SOFTC_T *ar,A_UINT8 key_op_ctrl);
 
373
static int ar6000_reinstall_keys(struct ar6_softc *ar,u8 key_op_ctrl);
374
374
#endif
375
375
 
376
376
#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
402
402
 */
403
403
#define REPORT_DEBUG_LOGS_TO_APP
404
404
 
405
 
A_STATUS
406
 
ar6000_set_host_app_area(AR_SOFTC_T *ar)
 
405
int
 
406
ar6000_set_host_app_area(struct ar6_softc *ar)
407
407
{
408
 
    A_UINT32 address, data;
 
408
    u32 address, data;
409
409
    struct host_app_area_s host_app_area;
410
410
 
411
411
    /* Fetch the address of the host_app_area_s instance in the host interest area */
412
412
    address = TARG_VTOP(ar->arTargetType, HOST_INTEREST_ITEM_ADDRESS(ar, hi_app_host_interest));
413
 
    if (ar6000_ReadRegDiag(ar->arHifDevice, &address, &data) != A_OK) {
 
413
    if (ar6000_ReadRegDiag(ar->arHifDevice, &address, &data) != 0) {
414
414
        return A_ERROR;
415
415
    }
416
416
    address = TARG_VTOP(ar->arTargetType, data);
417
417
    host_app_area.wmi_protocol_ver = WMI_PROTOCOL_VERSION;
418
418
    if (ar6000_WriteDataDiag(ar->arHifDevice, address,
419
 
                             (A_UCHAR *)&host_app_area,
420
 
                             sizeof(struct host_app_area_s)) != A_OK)
 
419
                             (u8 *)&host_app_area,
 
420
                             sizeof(struct host_app_area_s)) != 0)
421
421
    {
422
422
        return A_ERROR;
423
423
    }
424
424
 
425
 
    return A_OK;
 
425
    return 0;
426
426
}
427
427
 
428
 
A_UINT32
429
 
dbglog_get_debug_hdr_ptr(AR_SOFTC_T *ar)
 
428
u32 dbglog_get_debug_hdr_ptr(struct ar6_softc *ar)
430
429
{
431
 
    A_UINT32 param;
432
 
    A_UINT32 address;
433
 
    A_STATUS status;
 
430
    u32 param;
 
431
    u32 address;
 
432
    int status;
434
433
 
435
434
    address = TARG_VTOP(ar->arTargetType, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dbglog_hdr));
436
435
    if ((status = ar6000_ReadDataDiag(ar->arHifDevice, address,
437
 
                                      (A_UCHAR *)&param, 4)) != A_OK)
 
436
                                      (u8 *)&param, 4)) != 0)
438
437
    {
439
438
        param = 0;
440
439
    }
447
446
 * data stuctures over the diagnostic window.
448
447
 */
449
448
void
450
 
ar6000_dbglog_init_done(AR_SOFTC_T *ar)
 
449
ar6000_dbglog_init_done(struct ar6_softc *ar)
451
450
{
452
 
    ar->dbglog_init_done = TRUE;
 
451
    ar->dbglog_init_done = true;
453
452
}
454
453
 
455
 
A_UINT32
456
 
dbglog_get_debug_fragment(A_INT8 *datap, A_UINT32 len, A_UINT32 limit)
 
454
u32 dbglog_get_debug_fragment(s8 *datap, u32 len, u32 limit)
457
455
{
458
 
    A_INT32 *buffer;
459
 
    A_UINT32 count;
460
 
    A_UINT32 numargs;
461
 
    A_UINT32 length;
462
 
    A_UINT32 fraglen;
 
456
    s32 *buffer;
 
457
    u32 count;
 
458
    u32 numargs;
 
459
    u32 length;
 
460
    u32 fraglen;
463
461
 
464
462
    count = fraglen = 0;
465
 
    buffer = (A_INT32 *)datap;
 
463
    buffer = (s32 *)datap;
466
464
    length = (limit >> 2);
467
465
 
468
466
    if (len <= limit) {
479
477
}
480
478
 
481
479
void
482
 
dbglog_parse_debug_logs(A_INT8 *datap, A_UINT32 len)
 
480
dbglog_parse_debug_logs(s8 *datap, u32 len)
483
481
{
484
 
    A_INT32 *buffer;
485
 
    A_UINT32 count;
486
 
    A_UINT32 timestamp;
487
 
    A_UINT32 debugid;
488
 
    A_UINT32 moduleid;
489
 
    A_UINT32 numargs;
490
 
    A_UINT32 length;
 
482
    s32 *buffer;
 
483
    u32 count;
 
484
    u32 timestamp;
 
485
    u32 debugid;
 
486
    u32 moduleid;
 
487
    u32 numargs;
 
488
    u32 length;
491
489
 
492
490
    count = 0;
493
 
    buffer = (A_INT32 *)datap;
 
491
    buffer = (s32 *)datap;
494
492
    length = (len >> 2);
495
493
    while (count < length) {
496
494
        debugid = DBGLOG_GET_DBGID(buffer[count]);
520
518
}
521
519
 
522
520
int
523
 
ar6000_dbglog_get_debug_logs(AR_SOFTC_T *ar)
 
521
ar6000_dbglog_get_debug_logs(struct ar6_softc *ar)
524
522
{
525
 
    A_UINT32 data[8]; /* Should be able to accomodate struct dbglog_buf_s */
526
 
    A_UINT32 address;
527
 
    A_UINT32 length;
528
 
    A_UINT32 dropped;
529
 
    A_UINT32 firstbuf;
530
 
    A_UINT32 debug_hdr_ptr;
 
523
    u32 data[8]; /* Should be able to accommodate struct dbglog_buf_s */
 
524
    u32 address;
 
525
    u32 length;
 
526
    u32 dropped;
 
527
    u32 firstbuf;
 
528
    u32 debug_hdr_ptr;
531
529
 
532
530
    if (!ar->dbglog_init_done) return A_ERROR;
533
531
 
540
538
    }
541
539
 
542
540
        /* block out others */
543
 
    ar->dbgLogFetchInProgress = TRUE;
 
541
    ar->dbgLogFetchInProgress = true;
544
542
 
545
543
    AR6000_SPIN_UNLOCK(&ar->arLock, 0);
546
544
 
552
550
        address = TARG_VTOP(ar->arTargetType, debug_hdr_ptr);
553
551
        length = 4 /* sizeof(dbuf) */ + 4 /* sizeof(dropped) */;
554
552
        A_MEMZERO(data, sizeof(data));
555
 
        ar6000_ReadDataDiag(ar->arHifDevice, address, (A_UCHAR *)data, length);
 
553
        ar6000_ReadDataDiag(ar->arHifDevice, address, (u8 *)data, length);
556
554
        address = TARG_VTOP(ar->arTargetType, data[0] /* dbuf */);
557
555
        firstbuf = address;
558
556
        dropped = data[1]; /* dropped */
559
557
        length = 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */;
560
558
        A_MEMZERO(data, sizeof(data));
561
 
        ar6000_ReadDataDiag(ar->arHifDevice, address, (A_UCHAR *)&data, length);
 
559
        ar6000_ReadDataDiag(ar->arHifDevice, address, (u8 *)&data, length);
562
560
 
563
561
        do {
564
562
            address = TARG_VTOP(ar->arTargetType, data[1] /* buffer*/);
568
566
                if (ar->log_cnt > (DBGLOG_HOST_LOG_BUFFER_SIZE - length)) {
569
567
                    ar->log_cnt = 0;
570
568
                }
571
 
                if(A_OK != ar6000_ReadDataDiag(ar->arHifDevice, address,
572
 
                                    (A_UCHAR *)&ar->log_buffer[ar->log_cnt], length))
 
569
                if(0 != ar6000_ReadDataDiag(ar->arHifDevice, address,
 
570
                                    (u8 *)&ar->log_buffer[ar->log_cnt], length))
573
571
                {
574
572
                    break;
575
573
                }
576
 
                ar6000_dbglog_event(ar, dropped, (A_INT8*)&ar->log_buffer[ar->log_cnt], length);
 
574
                ar6000_dbglog_event(ar, dropped, (s8 *)&ar->log_buffer[ar->log_cnt], length);
577
575
                ar->log_cnt += length;
578
576
            } else {
579
577
                AR_DEBUG_PRINTF(ATH_DEBUG_DBG_LOG,("Length: %d (Total size: %d)\n",
583
581
            address = TARG_VTOP(ar->arTargetType, data[0] /* next */);
584
582
            length = 4 /* sizeof(next) */ + 4 /* sizeof(buffer) */ + 4 /* sizeof(bufsize) */ + 4 /* sizeof(length) */ + 4 /* sizeof(count) */ + 4 /* sizeof(free) */;
585
583
            A_MEMZERO(data, sizeof(data));
586
 
            if(A_OK != ar6000_ReadDataDiag(ar->arHifDevice, address,
587
 
                                (A_UCHAR *)&data, length))
 
584
            if(0 != ar6000_ReadDataDiag(ar->arHifDevice, address,
 
585
                                (u8 *)&data, length))
588
586
            {
589
587
                break;
590
588
            }
592
590
        } while (address != firstbuf);
593
591
    }
594
592
 
595
 
    ar->dbgLogFetchInProgress = FALSE;
 
593
    ar->dbgLogFetchInProgress = false;
596
594
 
597
 
    return A_OK;
 
595
    return 0;
598
596
}
599
597
 
600
598
void
601
 
ar6000_dbglog_event(AR_SOFTC_T *ar, A_UINT32 dropped,
602
 
                    A_INT8 *buffer, A_UINT32 length)
 
599
ar6000_dbglog_event(struct ar6_softc *ar, u32 dropped,
 
600
                    s8 *buffer, u32 length)
603
601
{
604
602
#ifdef REPORT_DEBUG_LOGS_TO_APP
605
603
    #define MAX_WIRELESS_EVENT_SIZE 252
608
606
     * There seems to be a limitation on the length of message that could be
609
607
     * transmitted to the user app via this mechanism.
610
608
     */
611
 
    A_UINT32 send, sent;
 
609
    u32 send, sent;
612
610
 
613
611
    sent = 0;
614
612
    send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
615
613
                                     MAX_WIRELESS_EVENT_SIZE);
616
614
    while (send) {
617
 
        ar6000_send_event_to_app(ar, WMIX_DBGLOG_EVENTID, (A_UINT8*)&buffer[sent], send);
 
615
        ar6000_send_event_to_app(ar, WMIX_DBGLOG_EVENTID, (u8 *)&buffer[sent], send);
618
616
        sent += send;
619
617
        send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
620
618
                                         MAX_WIRELESS_EVENT_SIZE);
624
622
                    dropped, length));
625
623
 
626
624
    /* Interpret the debug logs */
627
 
    dbglog_parse_debug_logs((A_INT8*)buffer, length);
 
625
    dbglog_parse_debug_logs((s8 *)buffer, length);
628
626
#endif /* REPORT_DEBUG_LOGS_TO_APP */
629
627
}
630
628
 
633
631
ar6000_init_module(void)
634
632
{
635
633
    static int probed = 0;
636
 
    A_STATUS status;
 
634
    int status;
637
635
    OSDRV_CALLBACKS osdrvCallbacks;
638
636
 
639
637
    a_module_debug_support_init();
694
692
#endif /* CONFIG_HOST_GPIO_SUPPORT */
695
693
 
696
694
    status = HIFInit(&osdrvCallbacks);
697
 
    if(status != A_OK)
 
695
    if (status)
698
696
        return -ENODEV;
699
697
 
700
698
    return 0;
738
736
void
739
737
aptcTimerHandler(unsigned long arg)
740
738
{
741
 
    A_UINT32 numbytes;
742
 
    A_UINT32 throughput;
743
 
    AR_SOFTC_T *ar;
744
 
    A_STATUS status;
 
739
    u32 numbytes;
 
740
    u32 throughput;
 
741
    struct ar6_softc *ar;
 
742
    int status;
745
743
 
746
 
    ar = (AR_SOFTC_T *)arg;
 
744
    ar = (struct ar6_softc *)arg;
747
745
    A_ASSERT(ar != NULL);
748
746
    A_ASSERT(!timer_pending(&aptcTimer));
749
747
 
757
755
    throughput = ((numbytes * 8)/APTC_TRAFFIC_SAMPLING_INTERVAL); /* Kbps */
758
756
    if (throughput < APTC_LOWER_THROUGHPUT_THRESHOLD) {
759
757
        /* Enable Sleep and delete the timer */
760
 
        A_ASSERT(ar->arWmiReady == TRUE);
 
758
        A_ASSERT(ar->arWmiReady == true);
761
759
        AR6000_SPIN_UNLOCK(&ar->arLock, 0);
762
760
        status = wmi_powermode_cmd(ar->arWmi, REC_POWER);
763
761
        AR6000_SPIN_LOCK(&ar->arLock, 0);
764
 
        A_ASSERT(status == A_OK);
765
 
        aptcTR.timerScheduled = FALSE;
 
762
        A_ASSERT(status == 0);
 
763
        aptcTR.timerScheduled = false;
766
764
    } else {
767
765
        A_TIMEOUT_MS(&aptcTimer, APTC_TRAFFIC_SAMPLING_INTERVAL, 0);
768
766
    }
773
771
 
774
772
#ifdef ATH_AR6K_11N_SUPPORT
775
773
static void
776
 
ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, A_UINT16 num)
 
774
ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num)
777
775
{
778
776
    void * osbuf;
779
777
 
804
802
                      char *buf, loff_t pos, size_t count)
805
803
{
806
804
    int index;
807
 
    AR_SOFTC_T *ar;
808
 
    HIF_DEVICE_OS_DEVICE_INFO   *osDevInfo;
 
805
    struct ar6_softc *ar;
 
806
    struct hif_device_os_device_info   *osDevInfo;
809
807
 
810
 
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Read %d bytes\n", (A_UINT32)count));
 
808
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Read %d bytes\n", (u32)count));
811
809
    for (index=0; index < MAX_AR6000; index++) {
812
 
        ar = (AR_SOFTC_T *)ar6k_priv(ar6000_devices[index]);
 
810
        ar = (struct ar6_softc *)ar6k_priv(ar6000_devices[index]);
813
811
        osDevInfo = &ar->osDevInfo;
814
812
        if (kobj == (&(((struct device *)osDevInfo->pOSDevice)->kobj))) {
815
813
            break;
818
816
 
819
817
    if (index == MAX_AR6000) return 0;
820
818
 
821
 
    if ((BMIRawRead(ar->arHifDevice, (A_UCHAR*)buf, count, TRUE)) != A_OK) {
 
819
    if ((BMIRawRead(ar->arHifDevice, (u8*)buf, count, true)) != 0) {
822
820
        return 0;
823
821
    }
824
822
 
831
829
                       char *buf, loff_t pos, size_t count)
832
830
{
833
831
    int index;
834
 
    AR_SOFTC_T *ar;
835
 
    HIF_DEVICE_OS_DEVICE_INFO   *osDevInfo;
 
832
    struct ar6_softc *ar;
 
833
    struct hif_device_os_device_info   *osDevInfo;
836
834
 
837
 
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Write %d bytes\n", (A_UINT32)count));
 
835
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Write %d bytes\n", (u32)count));
838
836
    for (index=0; index < MAX_AR6000; index++) {
839
 
        ar = (AR_SOFTC_T *)ar6k_priv(ar6000_devices[index]);
 
837
        ar = (struct ar6_softc *)ar6k_priv(ar6000_devices[index]);
840
838
        osDevInfo = &ar->osDevInfo;
841
839
        if (kobj == (&(((struct device *)osDevInfo->pOSDevice)->kobj))) {
842
840
            break;
845
843
 
846
844
    if (index == MAX_AR6000) return 0;
847
845
 
848
 
    if ((BMIRawWrite(ar->arHifDevice, (A_UCHAR*)buf, count)) != A_OK) {
 
846
    if ((BMIRawWrite(ar->arHifDevice, (u8*)buf, count)) != 0) {
849
847
        return 0;
850
848
    }
851
849
 
852
850
    return count;
853
851
}
854
852
 
855
 
static A_STATUS
856
 
ar6000_sysfs_bmi_init(AR_SOFTC_T *ar)
 
853
static int
 
854
ar6000_sysfs_bmi_init(struct ar6_softc *ar)
857
855
{
858
 
    A_STATUS status;
 
856
    int status;
859
857
 
860
858
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Creating sysfs entry\n"));
861
 
    A_MEMZERO(&ar->osDevInfo, sizeof(HIF_DEVICE_OS_DEVICE_INFO));
 
859
    A_MEMZERO(&ar->osDevInfo, sizeof(struct hif_device_os_device_info));
862
860
 
863
861
    /* Get the underlying OS device */
864
862
    status = HIFConfigureDevice(ar->arHifDevice,
865
863
                                HIF_DEVICE_GET_OS_DEVICE,
866
864
                                &ar->osDevInfo,
867
 
                                sizeof(HIF_DEVICE_OS_DEVICE_INFO));
 
865
                                sizeof(struct hif_device_os_device_info));
868
866
 
869
 
    if (A_FAILED(status)) {
 
867
    if (status) {
870
868
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI: Failed to get OS device info from HIF\n"));
871
869
        return A_ERROR;
872
870
    }
878
876
        return A_ERROR;
879
877
    }
880
878
 
881
 
    return A_OK;
 
879
    return 0;
882
880
}
883
881
 
884
882
static void
885
 
ar6000_sysfs_bmi_deinit(AR_SOFTC_T *ar)
 
883
ar6000_sysfs_bmi_deinit(struct ar6_softc *ar)
886
884
{
887
885
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Deleting sysfs entry\n"));
888
886
 
890
888
}
891
889
 
892
890
#define bmifn(fn) do { \
893
 
    if ((fn) < A_OK) { \
 
891
    if ((fn) < 0) { \
894
892
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__)); \
895
893
        return A_ERROR; \
896
894
    } \
902
900
#define AR6002_MAC_ADDRESS_OFFSET     0x0A
903
901
#define AR6003_MAC_ADDRESS_OFFSET     0x16
904
902
static
905
 
void calculate_crc(A_UINT32 TargetType, A_UCHAR *eeprom_data)
 
903
void calculate_crc(u32 TargetType, u8 *eeprom_data)
906
904
{
907
 
    A_UINT16        *ptr_crc;
908
 
    A_UINT16        *ptr16_eeprom;
909
 
    A_UINT16        checksum;
910
 
    A_UINT32        i;
911
 
    A_UINT32        eeprom_size;
 
905
    u16 *ptr_crc;
 
906
    u16 *ptr16_eeprom;
 
907
    u16 checksum;
 
908
    u32 i;
 
909
    u32 eeprom_size;
912
910
 
913
911
    if (TargetType == TARGET_TYPE_AR6001)
914
912
    {
915
913
        eeprom_size = 512;
916
 
        ptr_crc = (A_UINT16 *)eeprom_data;
 
914
        ptr_crc = (u16 *)eeprom_data;
917
915
    }
918
916
    else if (TargetType == TARGET_TYPE_AR6003)
919
917
    {
920
918
        eeprom_size = 1024;
921
 
        ptr_crc = (A_UINT16 *)((A_UCHAR *)eeprom_data + 0x04);
 
919
        ptr_crc = (u16 *)((u8 *)eeprom_data + 0x04);
922
920
    }
923
921
    else
924
922
    {
925
923
        eeprom_size = 768;
926
 
        ptr_crc = (A_UINT16 *)((A_UCHAR *)eeprom_data + 0x04);
 
924
        ptr_crc = (u16 *)((u8 *)eeprom_data + 0x04);
927
925
    }
928
926
 
929
927
 
932
930
 
933
931
    // Recalculate new CRC
934
932
    checksum = 0;
935
 
    ptr16_eeprom = (A_UINT16 *)eeprom_data;
 
933
    ptr16_eeprom = (u16 *)eeprom_data;
936
934
    for (i = 0;i < eeprom_size; i += 2)
937
935
    {
938
936
        checksum = checksum ^ (*ptr16_eeprom);
943
941
}
944
942
 
945
943
static void 
946
 
ar6000_softmac_update(AR_SOFTC_T *ar, A_UCHAR *eeprom_data, size_t size)
 
944
ar6000_softmac_update(struct ar6_softc *ar, u8 *eeprom_data, size_t size)
947
945
{
948
946
    const char *source = "random generated";
949
947
    const struct firmware *softmac_entry;
950
 
    A_UCHAR *ptr_mac;
 
948
    u8 *ptr_mac;
951
949
    switch (ar->arTargetType) {
952
950
    case TARGET_TYPE_AR6002:
953
 
        ptr_mac = (A_UINT8 *)((A_UCHAR *)eeprom_data + AR6002_MAC_ADDRESS_OFFSET);
 
951
        ptr_mac = (u8 *)((u8 *)eeprom_data + AR6002_MAC_ADDRESS_OFFSET);
954
952
        break;
955
953
    case TARGET_TYPE_AR6003:
956
 
        ptr_mac = (A_UINT8 *)((A_UCHAR *)eeprom_data + AR6003_MAC_ADDRESS_OFFSET);
 
954
        ptr_mac = (u8 *)((u8 *)eeprom_data + AR6003_MAC_ADDRESS_OFFSET);
957
955
        break;
958
956
    default:
959
957
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Invalid Target Type\n"));
970
968
    ptr_mac[5] = random32() & 0xff; 
971
969
    if ((A_REQUEST_FIRMWARE(&softmac_entry, "softmac", ((struct device *)ar->osDevInfo.pOSDevice))) == 0)
972
970
    {
973
 
        A_CHAR *macbuf = A_MALLOC_NOWAIT(softmac_entry->size+1);
 
971
        char *macbuf = A_MALLOC_NOWAIT(softmac_entry->size+1);
974
972
        if (macbuf) {            
975
973
            unsigned int softmac[6];
976
974
            memcpy(macbuf, softmac_entry->data, softmac_entry->size);
993
991
}
994
992
#endif /* SOFTMAC_FILE_USED */
995
993
 
996
 
static A_STATUS
997
 
ar6000_transfer_bin_file(AR_SOFTC_T *ar, AR6K_BIN_FILE file, A_UINT32 address, A_BOOL compressed)
 
994
static int
 
995
ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address, bool compressed)
998
996
{
999
 
    A_STATUS status;
 
997
    int status;
1000
998
    const char *filename;
1001
999
    const struct firmware *fw_entry;
1002
 
    A_UINT32 fw_entry_size;
 
1000
    u32 fw_entry_size;
1003
1001
 
1004
1002
    switch (file) {
1005
1003
        case AR6K_OTP_FILE:
1024
1022
            }
1025
1023
            
1026
1024
            if (eppingtest) {
1027
 
                bypasswmi = TRUE;    
 
1025
                bypasswmi = true;
1028
1026
                if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1029
1027
                    filename = AR6003_REV1_EPPING_FIRMWARE_FILE;
1030
1028
                } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1034
1032
                        ar->arVersion.target_ver));
1035
1033
                    return A_ERROR;
1036
1034
                }
1037
 
                compressed = 0;
 
1035
                compressed = false;
1038
1036
            }
1039
1037
            
1040
1038
#ifdef CONFIG_HOST_TCMD_SUPPORT
1047
1045
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1048
1046
                    return A_ERROR;
1049
1047
                }
1050
 
                compressed = 0;
 
1048
                compressed = false;
1051
1049
            }
1052
1050
#endif 
1053
1051
#ifdef HTC_RAW_INTERFACE
1060
1058
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
1061
1059
                    return A_ERROR;
1062
1060
                }
1063
 
                compressed = 0;                
 
1061
                compressed = false;
1064
1062
            }
1065
1063
#endif 
1066
1064
            break;
1099
1097
 
1100
1098
#ifdef SOFTMAC_FILE_USED
1101
1099
    if (file==AR6K_BOARD_DATA_FILE && fw_entry->data) {
1102
 
        ar6000_softmac_update(ar, (A_UCHAR *)fw_entry->data, fw_entry->size);
 
1100
        ar6000_softmac_update(ar, (u8 *)fw_entry->data, fw_entry->size);
1103
1101
    }
1104
1102
#endif 
1105
1103
 
1108
1106
 
1109
1107
    /* Load extended board data for AR6003 */
1110
1108
    if ((file==AR6K_BOARD_DATA_FILE) && (fw_entry->data)) {
1111
 
        A_UINT32 board_ext_address;
1112
 
        A_UINT32 board_ext_data_size;
1113
 
        A_UINT32 board_data_size;
 
1109
        u32 board_ext_address;
 
1110
        u32 board_ext_data_size;
 
1111
        u32 board_data_size;
1114
1112
 
1115
1113
        board_ext_data_size = (((ar)->arTargetType == TARGET_TYPE_AR6002) ? AR6002_BOARD_EXT_DATA_SZ : \
1116
1114
                               (((ar)->arTargetType == TARGET_TYPE_AR6003) ? AR6003_BOARD_EXT_DATA_SZ : 0));
1119
1117
                          (((ar)->arTargetType == TARGET_TYPE_AR6003) ? AR6003_BOARD_DATA_SZ : 0));
1120
1118
        
1121
1119
        /* Determine where in Target RAM to write Board Data */
1122
 
        bmifn(BMIReadMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data), (A_UCHAR *)&board_ext_address, 4));
 
1120
        bmifn(BMIReadMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data), (u8 *)&board_ext_address, 4));
1123
1121
        AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("Board extended Data download address: 0x%x\n", board_ext_address));
1124
1122
 
1125
1123
        /* check whether the target has allocated memory for extended board data and file contains extended board data */
1126
1124
        if ((board_ext_address) && (fw_entry->size == (board_data_size + board_ext_data_size))) {
1127
 
            A_UINT32 param;
1128
 
 
1129
 
            status = BMIWriteMemory(ar->arHifDevice, board_ext_address, (A_UCHAR *)(fw_entry->data + board_data_size), board_ext_data_size);
1130
 
 
1131
 
            if (status != A_OK) {
 
1125
            u32 param;
 
1126
 
 
1127
            status = BMIWriteMemory(ar->arHifDevice, board_ext_address, (u8 *)(fw_entry->data + board_data_size), board_ext_data_size);
 
1128
 
 
1129
            if (status) {
1132
1130
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__));
1133
1131
                A_RELEASE_FIRMWARE(fw_entry);
1134
1132
                return A_ERROR;
1136
1134
 
1137
1135
            /* Record the fact that extended board Data IS initialized */
1138
1136
            param = 1;
1139
 
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data_initialized), (A_UCHAR *)&param, 4));
 
1137
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data_initialized), (u8 *)&param, 4));
1140
1138
        }
1141
1139
        fw_entry_size = board_data_size;
1142
1140
    }
1143
1141
 
1144
1142
    if (compressed) {
1145
 
        status = BMIFastDownload(ar->arHifDevice, address, (A_UCHAR *)fw_entry->data, fw_entry_size);
 
1143
        status = BMIFastDownload(ar->arHifDevice, address, (u8 *)fw_entry->data, fw_entry_size);
1146
1144
    } else {
1147
 
        status = BMIWriteMemory(ar->arHifDevice, address, (A_UCHAR *)fw_entry->data, fw_entry_size);
 
1145
        status = BMIWriteMemory(ar->arHifDevice, address, (u8 *)fw_entry->data, fw_entry_size);
1148
1146
    }
1149
1147
 
1150
 
    if (status != A_OK) {
 
1148
    if (status) {
1151
1149
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__));
1152
1150
        A_RELEASE_FIRMWARE(fw_entry);
1153
1151
        return A_ERROR;
1154
1152
    }
1155
1153
    A_RELEASE_FIRMWARE(fw_entry);
1156
 
    return A_OK;
 
1154
    return 0;
1157
1155
}
1158
1156
#endif /* INIT_MODE_DRV_ENABLED */
1159
1157
 
1160
 
A_STATUS
1161
 
ar6000_update_bdaddr(AR_SOFTC_T *ar)
 
1158
int
 
1159
ar6000_update_bdaddr(struct ar6_softc *ar)
1162
1160
{
1163
1161
 
1164
1162
        if (setupbtdev != 0) {
1165
 
            A_UINT32 address;
 
1163
            u32 address;
1166
1164
 
1167
1165
           if (BMIReadMemory(ar->arHifDevice,
1168
 
                HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data), (A_UCHAR *)&address, 4) != A_OK)
 
1166
                HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data), (u8 *)&address, 4) != 0)
1169
1167
           {
1170
1168
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for hi_board_data failed\n"));
1171
1169
                return A_ERROR;
1172
1170
           }
1173
1171
 
1174
 
           if (BMIReadMemory(ar->arHifDevice, address + BDATA_BDADDR_OFFSET, (A_UCHAR *)ar->bdaddr, 6) != A_OK)
 
1172
           if (BMIReadMemory(ar->arHifDevice, address + BDATA_BDADDR_OFFSET, (u8 *)ar->bdaddr, 6) != 0)
1175
1173
           {
1176
1174
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for BD address failed\n"));
1177
1175
                return A_ERROR;
1181
1179
                                                                ar->bdaddr[4], ar->bdaddr[5]));
1182
1180
        }
1183
1181
 
1184
 
return A_OK;
 
1182
return 0;
1185
1183
}
1186
1184
 
1187
 
A_STATUS
1188
 
ar6000_sysfs_bmi_get_config(AR_SOFTC_T *ar, A_UINT32 mode)
 
1185
int
 
1186
ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode)
1189
1187
{
1190
1188
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("BMI: Requesting device specific configuration\n"));
1191
1189
 
1192
1190
    if (mode == WLAN_INIT_MODE_UDEV) {
1193
 
        A_CHAR version[16];
 
1191
        char version[16];
1194
1192
        const struct firmware *fw_entry;
1195
1193
 
1196
1194
        /* Get config using udev through a script in user space */
1205
1203
#ifdef INIT_MODE_DRV_ENABLED
1206
1204
    } else {
1207
1205
        /* The config is contained within the driver itself */
1208
 
        A_STATUS status;
1209
 
        A_UINT32 param, options, sleep, address;
 
1206
        int status;
 
1207
        u32 param, options, sleep, address;
1210
1208
 
1211
1209
        /* Temporarily disable system sleep */
1212
1210
        address = MBOX_BASE_ADDRESS + LOCAL_SCRATCH_ADDRESS;
1236
1234
 
1237
1235
        param = 0;
1238
1236
        if (ar->arTargetType == TARGET_TYPE_AR6002) {
1239
 
            bmifn(BMIReadMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_ext_clk_detected), (A_UCHAR *)&param, 4));
 
1237
            bmifn(BMIReadMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_ext_clk_detected), (u8 *)&param, 4));
1240
1238
        }
1241
1239
 
1242
1240
        /* LPO_CAL.ENABLE = 1 if no external clk is detected */
1269
1267
        if (ar->arTargetType == TARGET_TYPE_AR6003) {
1270
1268
            /* hi_ext_clk_detected = 0 */
1271
1269
            param = 0;
1272
 
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_ext_clk_detected), (A_UCHAR *)&param, 4));
 
1270
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_ext_clk_detected), (u8 *)&param, 4));
1273
1271
 
1274
1272
            /* CLOCK_CONTROL &= ~LF_CLK32 */
1275
1273
            address = RTC_BASE_ADDRESS + CLOCK_CONTROL_ADDRESS;
1282
1280
        /* Transfer Board Data from Target EEPROM to Target RAM */
1283
1281
        if (ar->arTargetType == TARGET_TYPE_AR6003) {
1284
1282
            /* Determine where in Target RAM to write Board Data */
1285
 
            bmifn(BMIReadMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data), (A_UCHAR *)&address, 4));
 
1283
            bmifn(BMIReadMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data), (u8 *)&address, 4));
1286
1284
            AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("Board Data download address: 0x%x\n", address));
1287
1285
 
1288
1286
            /* Write EEPROM data to Target RAM */
1289
 
            if ((ar6000_transfer_bin_file(ar, AR6K_BOARD_DATA_FILE, address, FALSE)) != A_OK) {
 
1287
            if ((ar6000_transfer_bin_file(ar, AR6K_BOARD_DATA_FILE, address, false)) != 0) {
1290
1288
                return A_ERROR;
1291
1289
            }
1292
1290
 
1293
1291
            /* Record the fact that Board Data IS initialized */
1294
1292
            param = 1;
1295
 
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data_initialized), (A_UCHAR *)&param, 4));
 
1293
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data_initialized), (u8 *)&param, 4));
1296
1294
 
1297
1295
            /* Transfer One time Programmable data */
1298
1296
            AR6K_DATA_DOWNLOAD_ADDRESS(address, ar->arVersion.target_ver);
1299
 
            status = ar6000_transfer_bin_file(ar, AR6K_OTP_FILE, address, TRUE);
1300
 
            if (status == A_OK) {
 
1297
            status = ar6000_transfer_bin_file(ar, AR6K_OTP_FILE, address, true);
 
1298
            if (status == 0) {
1301
1299
                /* Execute the OTP code */
1302
1300
                param = 0;
1303
1301
                AR6K_APP_START_OVERRIDE_ADDRESS(address, ar->arVersion.target_ver);
1312
1310
 
1313
1311
        /* Download Target firmware */
1314
1312
        AR6K_DATA_DOWNLOAD_ADDRESS(address, ar->arVersion.target_ver);
1315
 
        if ((ar6000_transfer_bin_file(ar, AR6K_FIRMWARE_FILE, address, TRUE)) != A_OK) {
 
1313
        if ((ar6000_transfer_bin_file(ar, AR6K_FIRMWARE_FILE, address, true)) != 0) {
1316
1314
            return A_ERROR;
1317
1315
        }
1318
1316
 
1322
1320
 
1323
1321
        /* Apply the patches */
1324
1322
        AR6K_PATCH_DOWNLOAD_ADDRESS(address, ar->arVersion.target_ver);
1325
 
        if ((ar6000_transfer_bin_file(ar, AR6K_PATCH_FILE, address, FALSE)) != A_OK) {
 
1323
        if ((ar6000_transfer_bin_file(ar, AR6K_PATCH_FILE, address, false)) != 0) {
1326
1324
            return A_ERROR;
1327
1325
        }
1328
1326
 
1329
1327
        param = address;
1330
 
        bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dset_list_head), (A_UCHAR *)&param, 4));
 
1328
        bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dset_list_head), (u8 *)&param, 4));
1331
1329
 
1332
1330
        if (ar->arTargetType == TARGET_TYPE_AR6003) {
1333
1331
            if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1337
1335
                /* Reserve 6.5K of RAM */
1338
1336
                param = 6656;
1339
1337
            }
1340
 
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_end_RAM_reserve_sz), (A_UCHAR *)&param, 4));
 
1338
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_end_RAM_reserve_sz), (u8 *)&param, 4));
1341
1339
        }
1342
1340
 
1343
1341
        /* Restore system sleep */
1354
1352
#define CONFIG_AR600x_DEBUG_UART_TX_PIN 8
1355
1353
#endif
1356
1354
            param = CONFIG_AR600x_DEBUG_UART_TX_PIN;
1357
 
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dbg_uart_txpin), (A_UCHAR *)&param, 4));
 
1355
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dbg_uart_txpin), (u8 *)&param, 4));
1358
1356
 
1359
1357
#if (CONFIG_AR600x_DEBUG_UART_TX_PIN == 23)
1360
1358
            {
1369
1367
#ifdef ATH6KL_CONFIG_GPIO_BT_RESET
1370
1368
#define CONFIG_AR600x_BT_RESET_PIN      0x16
1371
1369
            param = CONFIG_AR600x_BT_RESET_PIN;
1372
 
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_hci_uart_support_pins), (A_UCHAR *)&param, 4));
 
1370
            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_hci_uart_support_pins), (u8 *)&param, 4));
1373
1371
#endif /* ATH6KL_CONFIG_GPIO_BT_RESET */
1374
1372
 
1375
1373
            /* Configure UART flow control polarity */
1380
1378
#if (CONFIG_ATH6KL_BT_UART_FC_POLARITY == 1)
1381
1379
            if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1382
1380
                param = ((CONFIG_ATH6KL_BT_UART_FC_POLARITY << 1) & 0x2);
1383
 
                bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_hci_uart_pwr_mgmt_params), (A_UCHAR *)&param, 4));
 
1381
                bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_hci_uart_pwr_mgmt_params), (u8 *)&param, 4));
1384
1382
            }
1385
1383
#endif /* CONFIG_ATH6KL_BT_UART_FC_POLARITY */
1386
1384
        }
1396
1394
#endif /* INIT_MODE_DRV_ENABLED */
1397
1395
    }
1398
1396
 
1399
 
    return A_OK;
 
1397
    return 0;
1400
1398
}
1401
1399
 
1402
 
A_STATUS
1403
 
ar6000_configure_target(AR_SOFTC_T *ar)
 
1400
int
 
1401
ar6000_configure_target(struct ar6_softc *ar)
1404
1402
{
1405
 
    A_UINT32 param;
 
1403
    u32 param;
1406
1404
    if (enableuartprint) {
1407
1405
        param = 1;
1408
1406
        if (BMIWriteMemory(ar->arHifDevice,
1409
1407
                           HOST_INTEREST_ITEM_ADDRESS(ar, hi_serial_enable),
1410
 
                           (A_UCHAR *)&param,
1411
 
                           4)!= A_OK)
 
1408
                           (u8 *)&param,
 
1409
                           4)!= 0)
1412
1410
        {
1413
1411
             AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for enableuartprint failed \n"));
1414
1412
             return A_ERROR;
1420
1418
    param = HTC_PROTOCOL_VERSION;
1421
1419
    if (BMIWriteMemory(ar->arHifDevice,
1422
1420
                       HOST_INTEREST_ITEM_ADDRESS(ar, hi_app_host_interest),
1423
 
                       (A_UCHAR *)&param,
1424
 
                       4)!= A_OK)
 
1421
                       (u8 *)&param,
 
1422
                       4)!= 0)
1425
1423
    {
1426
1424
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for htc version failed \n"));
1427
1425
         return A_ERROR;
1435
1433
    }
1436
1434
#endif
1437
1435
    if (enabletimerwar) {
1438
 
        A_UINT32 param;
 
1436
        u32 param;
1439
1437
 
1440
1438
        if (BMIReadMemory(ar->arHifDevice,
1441
1439
            HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1442
 
            (A_UCHAR *)&param,
1443
 
            4)!= A_OK)
 
1440
            (u8 *)&param,
 
1441
            4)!= 0)
1444
1442
        {
1445
1443
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for enabletimerwar failed \n"));
1446
1444
            return A_ERROR;
1450
1448
 
1451
1449
        if (BMIWriteMemory(ar->arHifDevice,
1452
1450
            HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1453
 
            (A_UCHAR *)&param,
1454
 
            4) != A_OK)
 
1451
            (u8 *)&param,
 
1452
            4) != 0)
1455
1453
        {
1456
1454
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for enabletimerwar failed \n"));
1457
1455
            return A_ERROR;
1461
1459
 
1462
1460
    /* set the firmware mode to STA/IBSS/AP */
1463
1461
    {
1464
 
        A_UINT32 param;
 
1462
        u32 param;
1465
1463
 
1466
1464
        if (BMIReadMemory(ar->arHifDevice,
1467
1465
            HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1468
 
            (A_UCHAR *)&param,
1469
 
            4)!= A_OK)
 
1466
            (u8 *)&param,
 
1467
            4)!= 0)
1470
1468
        {
1471
1469
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for setting fwmode failed \n"));
1472
1470
            return A_ERROR;
1476
1474
 
1477
1475
        if (BMIWriteMemory(ar->arHifDevice,
1478
1476
            HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1479
 
            (A_UCHAR *)&param,
1480
 
            4) != A_OK)
 
1477
            (u8 *)&param,
 
1478
            4) != 0)
1481
1479
        {
1482
1480
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for setting fwmode failed \n"));
1483
1481
            return A_ERROR;
1487
1485
 
1488
1486
#ifdef ATH6KL_DISABLE_TARGET_DBGLOGS
1489
1487
    {
1490
 
        A_UINT32 param;
 
1488
        u32 param;
1491
1489
 
1492
1490
        if (BMIReadMemory(ar->arHifDevice,
1493
1491
            HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1494
 
            (A_UCHAR *)&param,
1495
 
            4)!= A_OK)
 
1492
            (u8 *)&param,
 
1493
            4)!= 0)
1496
1494
        {
1497
1495
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIReadMemory for disabling debug logs failed\n"));
1498
1496
            return A_ERROR;
1502
1500
 
1503
1501
        if (BMIWriteMemory(ar->arHifDevice,
1504
1502
            HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
1505
 
            (A_UCHAR *)&param,
1506
 
            4) != A_OK)
 
1503
            (u8 *)&param,
 
1504
            4) != 0)
1507
1505
        {
1508
1506
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for HI_OPTION_DISABLE_DBGLOG\n"));
1509
1507
            return A_ERROR;
1524
1522
        param = AR6003_BOARD_EXT_DATA_ADDRESS; 
1525
1523
        if (BMIWriteMemory(ar->arHifDevice,
1526
1524
            HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data),
1527
 
            (A_UCHAR *)&param,
1528
 
            4) != A_OK)
 
1525
            (u8 *)&param,
 
1526
            4) != 0)
1529
1527
        {
1530
1528
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for hi_board_ext_data failed \n"));
1531
1529
            return A_ERROR;
1536
1534
        /* since BMIInit is called in the driver layer, we have to set the block
1537
1535
         * size here for the target */
1538
1536
 
1539
 
    if (A_FAILED(ar6000_set_htc_params(ar->arHifDevice,
1540
 
                                       ar->arTargetType,
1541
 
                                       mbox_yield_limit,
1542
 
                                       0 /* use default number of control buffers */
1543
 
                                       ))) {
 
1537
    if (ar6000_set_htc_params(ar->arHifDevice, ar->arTargetType,
 
1538
                              mbox_yield_limit, 0)) {
 
1539
                                /* use default number of control buffers */
1544
1540
        return A_ERROR;
1545
1541
    }
1546
1542
 
1547
1543
    if (setupbtdev != 0) {
1548
 
        if (A_FAILED(ar6000_set_hci_bridge_flags(ar->arHifDevice,
1549
 
                                                 ar->arTargetType,
1550
 
                                                 setupbtdev))) {
 
1544
        if (ar6000_set_hci_bridge_flags(ar->arHifDevice,
 
1545
                                        ar->arTargetType,
 
1546
                                        setupbtdev)) {
1551
1547
            return A_ERROR;
1552
1548
        }
1553
1549
    }
1554
 
    return A_OK;
 
1550
    return 0;
1555
1551
}
1556
1552
 
1557
1553
static void
1595
1591
/*
1596
1592
 * HTC Event handlers
1597
1593
 */
1598
 
static A_STATUS
 
1594
static int
1599
1595
ar6000_avail_ev(void *context, void *hif_handle)
1600
1596
{
1601
1597
    int i;
1602
1598
    struct net_device *dev;
1603
1599
    void *ar_netif;
1604
 
    AR_SOFTC_T *ar;
 
1600
    struct ar6_softc *ar;
1605
1601
    int device_index = 0;
1606
 
    HTC_INIT_INFO  htcInfo;
 
1602
    struct htc_init_info  htcInfo;
1607
1603
#ifdef ATH6K_CONFIG_CFG80211
1608
1604
    struct wireless_dev *wdev;
1609
1605
#endif /* ATH6K_CONFIG_CFG80211 */
1610
 
    A_STATUS init_status = A_OK;
 
1606
    int init_status = 0;
 
1607
    struct hif_device_os_device_info osDevInfo;
 
1608
 
 
1609
    memset(&osDevInfo, 0, sizeof(osDevInfo));
 
1610
    if (HIFConfigureDevice(hif_handle, HIF_DEVICE_GET_OS_DEVICE,
 
1611
        &osDevInfo, sizeof(osDevInfo))) {
 
1612
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: Failed to get OS device instance\n", __func__));
 
1613
        return A_ERROR;
 
1614
    }
1611
1615
 
1612
1616
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("ar6000_available\n"));
1613
1617
 
1627
1631
    device_index = i;
1628
1632
 
1629
1633
#ifdef ATH6K_CONFIG_CFG80211
1630
 
    wdev = ar6k_cfg80211_init(NULL);
 
1634
    wdev = ar6k_cfg80211_init(osDevInfo.pOSDevice);
1631
1635
    if (IS_ERR(wdev)) {
1632
1636
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ar6k_cfg80211_init failed\n", __func__));
1633
1637
        return A_ERROR;
1634
1638
    }
1635
1639
    ar_netif = wdev_priv(wdev);
1636
1640
#else
1637
 
    dev = alloc_etherdev(sizeof(AR_SOFTC_T));
 
1641
    dev = alloc_etherdev(sizeof(struct ar6_softc));
1638
1642
    if (dev == NULL) {
1639
1643
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_available: can't alloc etherdev\n"));
1640
1644
        return A_ERROR;
1648
1652
        return A_ERROR;
1649
1653
    }
1650
1654
 
1651
 
    A_MEMZERO(ar_netif, sizeof(AR_SOFTC_T));
1652
 
    ar = (AR_SOFTC_T *)ar_netif;
 
1655
    A_MEMZERO(ar_netif, sizeof(struct ar6_softc));
 
1656
    ar = (struct ar6_softc *)ar_netif;
1653
1657
 
1654
1658
#ifdef ATH6K_CONFIG_CFG80211
1655
1659
    ar->wdev = wdev;
1666
1670
    SET_NETDEV_DEV(dev, wiphy_dev(wdev->wiphy));
1667
1671
    wdev->netdev = dev;
1668
1672
    ar->arNetworkType = INFRA_NETWORK;
 
1673
    ar->smeState = SME_DISCONNECTED;
1669
1674
#endif /* ATH6K_CONFIG_CFG80211 */
1670
1675
 
1671
1676
    init_netdev(dev, ifname);
1672
1677
 
1673
1678
#ifdef SET_NETDEV_DEV
1674
1679
    if (ar_netif) { 
1675
 
        HIF_DEVICE_OS_DEVICE_INFO osDevInfo;
1676
 
        A_MEMZERO(&osDevInfo, sizeof(osDevInfo));
1677
 
        if ( A_SUCCESS( HIFConfigureDevice(hif_handle, HIF_DEVICE_GET_OS_DEVICE,
1678
 
                        &osDevInfo, sizeof(osDevInfo))) ) {
1679
 
            SET_NETDEV_DEV(dev, osDevInfo.pOSDevice);
1680
 
        }
 
1680
        SET_NETDEV_DEV(dev, osDevInfo.pOSDevice);
1681
1681
    }
1682
1682
#endif 
1683
1683
 
1687
1687
    ar->arDeviceIndex        = device_index;
1688
1688
 
1689
1689
    ar->arWlanPowerState     = WLAN_POWER_STATE_ON;
1690
 
    ar->arWlanOff            = FALSE;   /* We are in ON state */
 
1690
    ar->arWlanOff            = false;   /* We are in ON state */
1691
1691
#ifdef CONFIG_PM
1692
1692
    ar->arWowState           = WLAN_WOW_STATE_NONE;
1693
 
    ar->arBTOff              = TRUE;   /* BT chip assumed to be OFF */
 
1693
    ar->arBTOff              = true;   /* BT chip assumed to be OFF */
1694
1694
    ar->arBTSharing          = WLAN_CONFIG_BT_SHARING; 
1695
1695
    ar->arWlanOffConfig      = WLAN_CONFIG_WLAN_OFF;
1696
1696
    ar->arSuspendConfig      = WLAN_CONFIG_PM_SUSPEND;
1699
1699
 
1700
1700
    A_INIT_TIMER(&ar->arHBChallengeResp.timer, ar6000_detect_error, dev);
1701
1701
    ar->arHBChallengeResp.seqNum = 0;
1702
 
    ar->arHBChallengeResp.outstanding = FALSE;
 
1702
    ar->arHBChallengeResp.outstanding = false;
1703
1703
    ar->arHBChallengeResp.missCnt = 0;
1704
1704
    ar->arHBChallengeResp.frequency = AR6000_HB_CHALLENGE_RESP_FREQ_DEFAULT;
1705
1705
    ar->arHBChallengeResp.missThres = AR6000_HB_CHALLENGE_RESP_MISS_THRES_DEFAULT;
1707
1707
    ar6000_init_control_info(ar);
1708
1708
    init_waitqueue_head(&arEvent);
1709
1709
    sema_init(&ar->arSem, 1);
1710
 
    ar->bIsDestroyProgress = FALSE;
 
1710
    ar->bIsDestroyProgress = false;
1711
1711
 
1712
1712
    INIT_HTC_PACKET_QUEUE(&ar->amsdu_rx_buffer_queue);
1713
1713
 
1726
1726
    {
1727
1727
        struct bmi_target_info targ_info;
1728
1728
 
1729
 
        if (BMIGetTargetInfo(ar->arHifDevice, &targ_info) != A_OK) {
 
1729
        if (BMIGetTargetInfo(ar->arHifDevice, &targ_info) != 0) {
1730
1730
            init_status = A_ERROR;
1731
1731
            goto avail_ev_failed;
1732
1732
        }
1737
1737
            /* do any target-specific preparation that can be done through BMI */
1738
1738
        if (ar6000_prepare_target(ar->arHifDevice,
1739
1739
                                  targ_info.target_type,
1740
 
                                  targ_info.target_ver) != A_OK) {
 
1740
                                  targ_info.target_ver) != 0) {
1741
1741
            init_status = A_ERROR;
1742
1742
            goto avail_ev_failed;
1743
1743
        }
1744
1744
 
1745
1745
    }
1746
1746
 
1747
 
    if (ar6000_configure_target(ar) != A_OK) {
 
1747
    if (ar6000_configure_target(ar) != 0) {
1748
1748
            init_status = A_ERROR;
1749
1749
            goto avail_ev_failed;
1750
1750
    }
1799
1799
        if ((wlaninitmode == WLAN_INIT_MODE_UDEV) ||
1800
1800
            (wlaninitmode == WLAN_INIT_MODE_DRV))
1801
1801
        {
1802
 
            A_STATUS status = A_OK;
 
1802
            int status = 0;
1803
1803
            do {
1804
 
                if ((status = ar6000_sysfs_bmi_get_config(ar, wlaninitmode)) != A_OK)
 
1804
                if ((status = ar6000_sysfs_bmi_get_config(ar, wlaninitmode)) != 0)
1805
1805
                {
1806
1806
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n"));
1807
1807
                    break;
1808
1808
                }
1809
1809
#ifdef HTC_RAW_INTERFACE
1810
 
                break; /* Don't call ar6000_init for ART */
 
1810
                if (!eppingtest && bypasswmi) {
 
1811
                    break; /* Don't call ar6000_init for ART */
 
1812
                }
1811
1813
#endif 
1812
1814
                rtnl_lock();
1813
 
                status = (ar6000_init(dev)==0) ? A_OK : A_ERROR;
 
1815
                status = (ar6000_init(dev)==0) ? 0 : A_ERROR;
1814
1816
                rtnl_unlock();
1815
 
                if (status != A_OK) {
 
1817
                if (status) {
1816
1818
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_init\n"));
1817
1819
                }
1818
 
            } while (FALSE);
 
1820
            } while (false);
1819
1821
 
1820
 
            if (status != A_OK) {
 
1822
            if (status) {
1821
1823
                init_status = status;
1822
1824
                goto avail_ev_failed;
1823
1825
            }
1841
1843
                    (unsigned long)ar));
1842
1844
 
1843
1845
avail_ev_failed :
1844
 
    if (A_FAILED(init_status)) {
 
1846
    if (init_status) {
1845
1847
        if (bmienable) { 
1846
1848
            ar6000_sysfs_bmi_deinit(ar);  
1847
1849
        }
1850
1852
    return init_status;
1851
1853
}
1852
1854
 
1853
 
static void ar6000_target_failure(void *Instance, A_STATUS Status)
 
1855
static void ar6000_target_failure(void *Instance, int Status)
1854
1856
{
1855
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)Instance;
 
1857
    struct ar6_softc *ar = (struct ar6_softc *)Instance;
1856
1858
    WMI_TARGET_ERROR_REPORT_EVENT errEvent;
1857
 
    static A_BOOL sip = FALSE;
 
1859
    static bool sip = false;
1858
1860
 
1859
 
    if (Status != A_OK) {
 
1861
    if (Status != 0) {
1860
1862
 
1861
1863
        printk(KERN_ERR "ar6000_target_failure: target asserted \n");
1862
1864
 
1875
1877
 
1876
1878
        /* Report the error only once */
1877
1879
        if (!sip) {
1878
 
            sip = TRUE;
 
1880
            sip = true;
1879
1881
            errEvent.errorVal = WMI_TARGET_COM_ERR |
1880
1882
                                WMI_TARGET_FATAL_ERR;
1881
1883
            ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
1882
 
                                     (A_UINT8 *)&errEvent,
 
1884
                                     (u8 *)&errEvent,
1883
1885
                                     sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
1884
1886
        }
1885
1887
    }
1886
1888
}
1887
1889
 
1888
 
static A_STATUS
 
1890
static int
1889
1891
ar6000_unavail_ev(void *context, void *hif_handle)
1890
1892
{
1891
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)context;
 
1893
    struct ar6_softc *ar = (struct ar6_softc *)context;
1892
1894
        /* NULL out it's entry in the global list */
1893
1895
    ar6000_devices[ar->arDeviceIndex] = NULL;
1894
1896
    ar6000_destroy(ar->arNetDev, 1);
1895
1897
 
1896
 
    return A_OK;
 
1898
    return 0;
1897
1899
}
1898
1900
 
1899
1901
void
1900
1902
ar6000_restart_endpoint(struct net_device *dev)
1901
1903
{
1902
 
    A_STATUS status = A_OK;
1903
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
 
1904
    int status = 0;
 
1905
    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
1904
1906
 
1905
1907
    BMIInit();
1906
1908
    do {
1907
 
        if ( (status=ar6000_configure_target(ar))!=A_OK)
 
1909
        if ( (status=ar6000_configure_target(ar))!= 0)
1908
1910
            break;
1909
 
        if ( (status=ar6000_sysfs_bmi_get_config(ar, wlaninitmode)) != A_OK)
 
1911
        if ( (status=ar6000_sysfs_bmi_get_config(ar, wlaninitmode)) != 0)
1910
1912
        {
1911
1913
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n"));
1912
1914
            break;
1913
1915
        }
1914
1916
        rtnl_lock();
1915
 
        status = (ar6000_init(dev)==0) ? A_OK : A_ERROR;
 
1917
        status = (ar6000_init(dev)==0) ? 0 : A_ERROR;
1916
1918
        rtnl_unlock();
1917
1919
 
1918
 
        if (status!=A_OK) {
 
1920
        if (status) {
1919
1921
            break;
1920
1922
        }
1921
1923
        if (ar->arSsidLen && ar->arWlanState == WLAN_ENABLED) {
1923
1925
        }  
1924
1926
    } while (0);
1925
1927
 
1926
 
    if (status==A_OK) {
 
1928
    if (status== 0) {
1927
1929
        return;
1928
1930
    }
1929
1931
 
1932
1934
}
1933
1935
 
1934
1936
void
1935
 
ar6000_stop_endpoint(struct net_device *dev, A_BOOL keepprofile, A_BOOL getdbglogs)
 
1937
ar6000_stop_endpoint(struct net_device *dev, bool keepprofile, bool getdbglogs)
1936
1938
{
1937
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
 
1939
    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
1938
1940
 
1939
1941
    /* Stop the transmit queues */
1940
1942
    netif_stop_queue(dev);
1941
1943
 
1942
1944
    /* Disable the target and the interrupts associated with it */
1943
 
    if (ar->arWmiReady == TRUE)
 
1945
    if (ar->arWmiReady == true)
1944
1946
    {
1945
1947
        if (!bypasswmi)
1946
1948
        {
1947
 
            if (ar->arConnected == TRUE || ar->arConnectPending == TRUE)
1948
 
            {
1949
 
                AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("%s(): Disconnect\n", __func__));
1950
 
                if (!keepprofile) {
1951
 
                    AR6000_SPIN_LOCK(&ar->arLock, 0);
1952
 
                    ar6000_init_profile_info(ar);
1953
 
                    AR6000_SPIN_UNLOCK(&ar->arLock, 0);
1954
 
                }
1955
 
                wmi_disconnect_cmd(ar->arWmi);
 
1949
            bool disconnectIssued;
 
1950
 
 
1951
            disconnectIssued = (ar->arConnected) || (ar->arConnectPending);
 
1952
            ar6000_disconnect(ar);
 
1953
            if (!keepprofile) {
 
1954
                ar6000_init_profile_info(ar);
1956
1955
            }
1957
1956
 
1958
1957
            A_UNTIMEOUT(&ar->disconnect_timer);
1961
1960
                ar6000_dbglog_get_debug_logs(ar);
1962
1961
            }
1963
1962
 
1964
 
            ar->arWmiReady  = FALSE;
 
1963
            ar->arWmiReady  = false;
1965
1964
            wmi_shutdown(ar->arWmi);
1966
 
            ar->arWmiEnabled = FALSE;
 
1965
            ar->arWmiEnabled = false;
1967
1966
            ar->arWmi = NULL;
1968
1967
            /* 
1969
1968
             * After wmi_shudown all WMI events will be dropped.
1974
1973
             * Sometimes disconnect_event will be received when the debug logs 
1975
1974
             * are collected.
1976
1975
             */
1977
 
            if (ar->arConnected == TRUE || ar->arConnectPending == TRUE) {
 
1976
            if (disconnectIssued) {
1978
1977
                if(ar->arNetworkType & AP_NETWORK) {
1979
1978
                    ar6000_disconnect_event(ar, DISCONNECT_CMD, bcast_mac, 0, NULL, 0);
1980
1979
                } else {
1981
1980
                    ar6000_disconnect_event(ar, DISCONNECT_CMD, ar->arBssid, 0, NULL, 0);
1982
1981
                }
1983
 
                ar->arConnected = FALSE;
1984
 
                ar->arConnectPending = FALSE;
1985
1982
            }
1986
1983
#ifdef USER_KEYS
1987
1984
            ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
1997
1994
            __func__, (unsigned long) ar, (unsigned long) ar->arWmi));
1998
1995
 
1999
1996
        /* Shut down WMI if we have started it */
2000
 
        if(ar->arWmiEnabled == TRUE)
 
1997
        if(ar->arWmiEnabled == true)
2001
1998
        {
2002
1999
            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("%s(): Shut down WMI\n", __func__));
2003
2000
            wmi_shutdown(ar->arWmi);
2004
 
            ar->arWmiEnabled = FALSE;
 
2001
            ar->arWmiEnabled = false;
2005
2002
            ar->arWmi = NULL;
2006
2003
        }
2007
2004
    }
2014
2011
#else
2015
2012
        // FIXME: workaround to reset BT's UART baud rate to default
2016
2013
        if (NULL != ar->exitCallback) {
2017
 
            AR3K_CONFIG_INFO ar3kconfig;
2018
 
            A_STATUS status;
 
2014
            struct ar3k_config_info ar3kconfig;
 
2015
            int status;
2019
2016
 
2020
2017
            A_MEMZERO(&ar3kconfig,sizeof(ar3kconfig));
2021
2018
            ar6000_set_default_ar3kconfig(ar, (void *)&ar3kconfig);
2022
2019
            status = ar->exitCallback(&ar3kconfig);
2023
 
            if (A_OK != status) {
 
2020
            if (0 != status) {
2024
2021
                AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to reset AR3K baud rate! \n"));
2025
2022
            }
2026
2023
        }
2048
2045
         * a debug session */
2049
2046
        AR_DEBUG_PRINTF(ATH_DEBUG_INFO,(" Attempting to reset target on instance destroy.... \n"));
2050
2047
        if (ar->arHifDevice != NULL) {
2051
 
            A_BOOL coldReset = (ar->arTargetType == TARGET_TYPE_AR6003) ? TRUE: FALSE;
2052
 
            ar6000_reset_device(ar->arHifDevice, ar->arTargetType, TRUE, coldReset);
 
2048
            bool coldReset = (ar->arTargetType == TARGET_TYPE_AR6003) ? true: false;
 
2049
            ar6000_reset_device(ar->arHifDevice, ar->arTargetType, true, coldReset);
2053
2050
        }
2054
2051
    } else {
2055
2052
        AR_DEBUG_PRINTF(ATH_DEBUG_INFO,(" Host does not want target reset. \n"));
2056
2053
    }
2057
2054
       /* Done with cookies */
2058
2055
    ar6000_cookie_cleanup(ar);
 
2056
 
 
2057
    /* cleanup any allocated AMSDU buffers */
 
2058
    ar6000_cleanup_amsdu_rxbufs(ar);
2059
2059
}
2060
2060
/*
2061
2061
 * We need to differentiate between the surprise and planned removal of the
2063
2063
 * - In case of surprise removal, the hcd already frees up the pending
2064
2064
 *   for the device and hence there is no need to unregister the function
2065
2065
 *   driver inorder to get these requests. For planned removal, the function
2066
 
 *   driver has to explictly unregister itself to have the hcd return all the
 
2066
 *   driver has to explicitly unregister itself to have the hcd return all the
2067
2067
 *   pending requests before the data structures for the devices are freed up.
2068
2068
 *   Note that as per the current implementation, the function driver will
2069
2069
 *   end up releasing all the devices since there is no API to selectively
2074
2074
void
2075
2075
ar6000_destroy(struct net_device *dev, unsigned int unregister)
2076
2076
{
2077
 
    AR_SOFTC_T *ar;
 
2077
    struct ar6_softc *ar;
2078
2078
 
2079
2079
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("+ar6000_destroy \n"));
2080
2080
    
2084
2084
        return;
2085
2085
    }
2086
2086
 
2087
 
    ar->bIsDestroyProgress = TRUE;
 
2087
    ar->bIsDestroyProgress = true;
2088
2088
 
2089
2089
    if (down_interruptible(&ar->arSem)) {
2090
2090
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s(): down_interruptible failed \n", __func__));
2093
2093
 
2094
2094
    if (ar->arWlanPowerState != WLAN_POWER_STATE_CUT_PWR) {
2095
2095
        /* only stop endpoint if we are not stop it in suspend_ev */
2096
 
        ar6000_stop_endpoint(dev, FALSE, TRUE);
 
2096
        ar6000_stop_endpoint(dev, false, true);
2097
2097
    } else {
2098
2098
        /* clear up the platform power state before rmmod */
2099
2099
        plat_setup_power(1,0);
2159
2159
static void disconnect_timer_handler(unsigned long ptr)
2160
2160
{
2161
2161
    struct net_device *dev = (struct net_device *)ptr;
2162
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
 
2162
    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
2163
2163
 
2164
2164
    A_UNTIMEOUT(&ar->disconnect_timer);
2165
2165
 
2166
2166
    ar6000_init_profile_info(ar);
2167
 
    wmi_disconnect_cmd(ar->arWmi);
 
2167
    ar6000_disconnect(ar);
2168
2168
}
2169
2169
 
2170
2170
static void ar6000_detect_error(unsigned long ptr)
2171
2171
{
2172
2172
    struct net_device *dev = (struct net_device *)ptr;
2173
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
 
2173
    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
2174
2174
    WMI_TARGET_ERROR_REPORT_EVENT errEvent;
2175
2175
 
2176
2176
    AR6000_SPIN_LOCK(&ar->arLock, 0);
2188
2188
        errEvent.errorVal = WMI_TARGET_COM_ERR | WMI_TARGET_FATAL_ERR;
2189
2189
        AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2190
2190
        ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
2191
 
                                 (A_UINT8 *)&errEvent,
 
2191
                                 (u8 *)&errEvent,
2192
2192
                                 sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
2193
2193
        return;
2194
2194
    }
2195
2195
 
2196
2196
    /* Generate the sequence number for the next challenge */
2197
2197
    ar->arHBChallengeResp.seqNum++;
2198
 
    ar->arHBChallengeResp.outstanding = TRUE;
 
2198
    ar->arHBChallengeResp.outstanding = true;
2199
2199
 
2200
2200
    AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2201
2201
 
2202
2202
    /* Send the challenge on the control channel */
2203
 
    if (wmi_get_challenge_resp_cmd(ar->arWmi, ar->arHBChallengeResp.seqNum, DRV_HB_CHALLENGE) != A_OK) {
 
2203
    if (wmi_get_challenge_resp_cmd(ar->arWmi, ar->arHBChallengeResp.seqNum, DRV_HB_CHALLENGE) != 0) {
2204
2204
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to send heart beat challenge\n"));
2205
2205
    }
2206
2206
 
2209
2209
    A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);
2210
2210
}
2211
2211
 
2212
 
void ar6000_init_profile_info(AR_SOFTC_T *ar)
 
2212
void ar6000_init_profile_info(struct ar6_softc *ar)
2213
2213
{
2214
2214
    ar->arSsidLen            = 0;
2215
2215
    A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
2236
2236
    A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
2237
2237
    A_MEMZERO(ar->arBssid, sizeof(ar->arBssid));
2238
2238
    ar->arBssChannel = 0;
2239
 
    ar->arConnected = FALSE;
2240
2239
}
2241
2240
 
2242
2241
static void
2243
 
ar6000_init_control_info(AR_SOFTC_T *ar)
 
2242
ar6000_init_control_info(struct ar6_softc *ar)
2244
2243
{
2245
 
    ar->arWmiEnabled         = FALSE;
 
2244
    ar->arWmiEnabled         = false;
2246
2245
    ar6000_init_profile_info(ar);
2247
2246
    ar->arDefTxKeyIndex      = 0;
2248
2247
    A_MEMZERO(ar->arWepKeyList, sizeof(ar->arWepKeyList));
2252
2251
    ar->arVersion.host_ver   = AR6K_SW_VERSION;
2253
2252
    ar->arRssi               = 0;
2254
2253
    ar->arTxPwr              = 0;
2255
 
    ar->arTxPwrSet           = FALSE;
 
2254
    ar->arTxPwrSet           = false;
2256
2255
    ar->arSkipScan           = 0;
2257
2256
    ar->arBeaconInterval     = 0;
2258
2257
    ar->arBitRate            = 0;
2259
2258
    ar->arMaxRetries         = 0;
2260
 
    ar->arWmmEnabled         = TRUE;
 
2259
    ar->arWmmEnabled         = true;
2261
2260
    ar->intra_bss            = 1;
2262
2261
    ar->scan_triggered       = 0;
2263
2262
    A_MEMZERO(&ar->scParams, sizeof(ar->scParams));
2266
2265
 
2267
2266
    /* Initialize the AP mode state info */
2268
2267
    {
2269
 
        A_UINT8 ctr;
2270
 
        A_MEMZERO((A_UINT8 *)ar->sta_list, AP_MAX_NUM_STA * sizeof(sta_t));
 
2268
        u8 ctr;
 
2269
        A_MEMZERO((u8 *)ar->sta_list, AP_MAX_NUM_STA * sizeof(sta_t));
2271
2270
 
2272
2271
        /* init the Mutexes */
2273
2272
        A_MUTEX_INIT(&ar->mcastpsqLock);
2281
2280
        ar->ap_profile_flag = 0;
2282
2281
        A_NETBUF_QUEUE_INIT(&ar->mcastpsq);
2283
2282
 
2284
 
        A_MEMCPY(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3);
 
2283
        memcpy(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3);
2285
2284
        ar->ap_wmode = DEF_AP_WMODE_G;
2286
2285
        ar->ap_dtim_period = DEF_AP_DTIM;
2287
2286
        ar->ap_beacon_interval = DEF_BEACON_INTERVAL;
2292
2291
ar6000_open(struct net_device *dev)
2293
2292
{
2294
2293
    unsigned long  flags;
2295
 
    AR_SOFTC_T    *ar = (AR_SOFTC_T *)ar6k_priv(dev);
 
2294
    struct ar6_softc    *ar = (struct ar6_softc *)ar6k_priv(dev);
2296
2295
 
2297
2296
    spin_lock_irqsave(&ar->arLock, flags);
2298
2297
 
2318
2317
ar6000_close(struct net_device *dev)
2319
2318
{
2320
2319
#ifdef ATH6K_CONFIG_CFG80211
2321
 
    AR_SOFTC_T    *ar = (AR_SOFTC_T *)ar6k_priv(dev);
 
2320
    struct ar6_softc    *ar = (struct ar6_softc *)ar6k_priv(dev);
2322
2321
#endif /* ATH6K_CONFIG_CFG80211 */
2323
2322
    netif_stop_queue(dev);
2324
2323
 
2325
2324
#ifdef ATH6K_CONFIG_CFG80211
2326
 
    AR6000_SPIN_LOCK(&ar->arLock, 0);
2327
 
    if (ar->arConnected == TRUE || ar->arConnectPending == TRUE) {
2328
 
        AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2329
 
        wmi_disconnect_cmd(ar->arWmi);
2330
 
    } else {
2331
 
        AR6000_SPIN_UNLOCK(&ar->arLock, 0);
2332
 
    }
 
2325
    ar6000_disconnect(ar);
2333
2326
 
2334
 
    if(ar->arWmiReady == TRUE) {
 
2327
    if(ar->arWmiReady == true) {
2335
2328
        if (wmi_scanparams_cmd(ar->arWmi, 0xFFFF, 0,
2336
 
                               0, 0, 0, 0, 0, 0, 0, 0) != A_OK) {
 
2329
                               0, 0, 0, 0, 0, 0, 0, 0) != 0) {
2337
2330
            return -EIO;
2338
2331
        }
2339
2332
        ar->arWlanState = WLAN_DISABLED;
2340
2333
    }
 
2334
        ar6k_cfg80211_scanComplete_event(ar, A_ECANCELED);
2341
2335
#endif /* ATH6K_CONFIG_CFG80211 */
2342
2336
 
2343
2337
    return 0;
2344
2338
}
2345
2339
 
2346
2340
/* connect to a service */
2347
 
static A_STATUS ar6000_connectservice(AR_SOFTC_T               *ar,
2348
 
                                      HTC_SERVICE_CONNECT_REQ  *pConnect,
2349
 
                                      char                     *pDesc)
 
2341
static int ar6000_connectservice(struct ar6_softc               *ar,
 
2342
                                      struct htc_service_connect_req  *pConnect,
 
2343
                                      char *pDesc)
2350
2344
{
2351
 
    A_STATUS                 status;
2352
 
    HTC_SERVICE_CONNECT_RESP response;
 
2345
    int                 status;
 
2346
    struct htc_service_connect_resp response;
2353
2347
 
2354
2348
    do {
2355
2349
 
2359
2353
                                   pConnect,
2360
2354
                                   &response);
2361
2355
 
2362
 
        if (A_FAILED(status)) {
 
2356
        if (status) {
2363
2357
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" Failed to connect to %s service status:%d \n",
2364
2358
                              pDesc, status));
2365
2359
            break;
2391
2385
            break;
2392
2386
        }
2393
2387
 
2394
 
    } while (FALSE);
 
2388
    } while (false);
2395
2389
 
2396
2390
    return status;
2397
2391
}
2398
2392
 
2399
 
void ar6000_TxDataCleanup(AR_SOFTC_T *ar)
 
2393
void ar6000_TxDataCleanup(struct ar6_softc *ar)
2400
2394
{
2401
2395
        /* flush all the data (non-control) streams
2402
2396
         * we only flush packets that are tagged as data, we leave any control packets that
2416
2410
}
2417
2411
 
2418
2412
HTC_ENDPOINT_ID
2419
 
ar6000_ac2_endpoint_id ( void * devt, A_UINT8 ac)
 
2413
ar6000_ac2_endpoint_id ( void * devt, u8 ac)
2420
2414
{
2421
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *) devt;
 
2415
    struct ar6_softc *ar = (struct ar6_softc *) devt;
2422
2416
    return(arAc2EndpointID(ar, ac));
2423
2417
}
2424
2418
 
2425
 
A_UINT8
2426
 
ar6000_endpoint_id2_ac(void * devt, HTC_ENDPOINT_ID ep )
 
2419
u8 ar6000_endpoint_id2_ac(void * devt, HTC_ENDPOINT_ID ep )
2427
2420
{
2428
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *) devt;
 
2421
    struct ar6_softc *ar = (struct ar6_softc *) devt;
2429
2422
    return(arEndpoint2Ac(ar, ep ));
2430
2423
}
2431
2424
 
 
2425
/*
 
2426
 * This function applies WLAN specific configuration defined in wlan_config.h
 
2427
 */
 
2428
int ar6000_target_config_wlan_params(struct ar6_softc *ar)
 
2429
{
 
2430
    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
 
 
2436
#ifdef CONFIG_HOST_TCMD_SUPPORT
 
2437
    if (ar->arTargetMode != AR6000_WLAN_MODE) {
 
2438
        return 0;
 
2439
    }
 
2440
#endif /* CONFIG_HOST_TCMD_SUPPORT */
 
2441
 
 
2442
    /* 
 
2443
     * configure the device for rx dot11 header rules 0,0 are the default values
 
2444
     * therefore this command can be skipped if the inputs are 0,FALSE,FALSE.Required
 
2445
     * if checksum offload is needed. Set RxMetaVersion to 2
 
2446
     */
 
2447
    if ((wmi_set_rx_frame_format_cmd(ar->arWmi,ar->rxMetaVersion, processDot11Hdr, processDot11Hdr)) != 0) {
 
2448
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set the rx frame format.\n"));
 
2449
        status = A_ERROR;
 
2450
    }
 
2451
 
 
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 */
 
2485
 
 
2486
#if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
 
2487
    if ((wmi_pmparams_cmd(ar->arWmi, 0, 1, 0, 0, 1, IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) {
 
2488
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set power save fail event policy\n"));
 
2489
        status = A_ERROR;
 
2490
    }
 
2491
#endif
 
2492
 
 
2493
#if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP
 
2494
    if ((wmi_set_lpreamble_cmd(ar->arWmi, 0, WMI_DONOT_IGNORE_BARKER_IN_ERP)) != 0) {
 
2495
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set barker preamble policy\n"));
 
2496
        status = A_ERROR;
 
2497
    }
 
2498
#endif
 
2499
 
 
2500
    if ((wmi_set_keepalive_cmd(ar->arWmi, WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) != 0) {
 
2501
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set keep alive interval\n"));
 
2502
        status = A_ERROR;
 
2503
    }
 
2504
 
 
2505
#if WLAN_CONFIG_DISABLE_11N
 
2506
    {
 
2507
        WMI_SET_HT_CAP_CMD htCap;
 
2508
 
 
2509
        memset(&htCap, 0, sizeof(WMI_SET_HT_CAP_CMD));
 
2510
        htCap.band = 0;
 
2511
        if ((wmi_set_ht_cap_cmd(ar->arWmi, &htCap)) != 0) {
 
2512
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set ht capabilities \n"));
 
2513
            status = A_ERROR;
 
2514
        }
 
2515
 
 
2516
        htCap.band = 1;
 
2517
        if ((wmi_set_ht_cap_cmd(ar->arWmi, &htCap)) != 0) {
 
2518
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set ht capabilities \n"));
 
2519
            status = A_ERROR;
 
2520
        }
 
2521
    }
 
2522
#endif /* WLAN_CONFIG_DISABLE_11N */
 
2523
 
 
2524
#ifdef ATH6K_CONFIG_OTA_MODE
 
2525
    if ((wmi_powermode_cmd(ar->arWmi, MAX_PERF_POWER)) != 0) {
 
2526
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set power mode \n"));
 
2527
        status = A_ERROR;
 
2528
    }
 
2529
#endif
 
2530
 
 
2531
    if ((wmi_disctimeout_cmd(ar->arWmi, WLAN_CONFIG_DISCONNECT_TIMEOUT)) != 0) {
 
2532
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set disconnect timeout \n"));
 
2533
        status = A_ERROR;
 
2534
    }
 
2535
 
 
2536
#if WLAN_CONFIG_DISABLE_TX_BURSTING  
 
2537
    if ((wmi_set_wmm_txop(ar->arWmi, WMI_TXOP_DISABLED)) != 0) {
 
2538
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set txop bursting \n"));
 
2539
        status = A_ERROR;
 
2540
    }
 
2541
#endif 
 
2542
 
 
2543
    return status;
 
2544
}
 
2545
 
2432
2546
/* This function does one time initialization for the lifetime of the device */
2433
2547
int ar6000_init(struct net_device *dev)
2434
2548
{
2435
 
    AR_SOFTC_T *ar;
2436
 
    A_STATUS    status;
2437
 
    A_INT32     timeleft;
2438
 
    A_INT16     i;
 
2549
    struct ar6_softc *ar;
 
2550
    int    status;
 
2551
    s32 timeleft;
 
2552
    s16 i;
2439
2553
    int         ret = 0;
2440
 
#if defined(INIT_MODE_DRV_ENABLED) && defined(ENABLE_COEXISTENCE)
2441
 
    WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD sbcb_cmd;
2442
 
    WMI_SET_BTCOEX_FE_ANT_CMD sbfa_cmd;
2443
 
#endif /* INIT_MODE_DRV_ENABLED && ENABLE_COEXISTENCE */
2444
2554
 
2445
2555
    if((ar = ar6k_priv(dev)) == NULL)
2446
2556
    {
2465
2575
 
2466
2576
    /* Do we need to finish the BMI phase */
2467
2577
    if ((wlaninitmode == WLAN_INIT_MODE_USR || wlaninitmode == WLAN_INIT_MODE_DRV) && 
2468
 
        (BMIDone(ar->arHifDevice) != A_OK))
 
2578
        (BMIDone(ar->arHifDevice) != 0))
2469
2579
    {
2470
2580
        ret = -EIO;
2471
2581
        goto ar6000_init_done;
2482
2592
#endif
2483
2593
 
2484
2594
        /* Indicate that WMI is enabled (although not ready yet) */
2485
 
        ar->arWmiEnabled = TRUE;
 
2595
        ar->arWmiEnabled = true;
2486
2596
        if ((ar->arWmi = wmi_init((void *) ar)) == NULL)
2487
2597
        {
2488
2598
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s() Failed to initialize WMI.\n", __func__));
2495
2605
    }
2496
2606
 
2497
2607
    do {
2498
 
        HTC_SERVICE_CONNECT_REQ connect;
 
2608
        struct htc_service_connect_req connect;
2499
2609
 
2500
2610
            /* the reason we have to wait for the target here is that the driver layer
2501
2611
             * has to init BMI in order to set the host block size,
2502
2612
             */
2503
2613
        status = HTCWaitTarget(ar->arHtcTarget);
2504
2614
 
2505
 
        if (A_FAILED(status)) {
 
2615
        if (status) {
2506
2616
            break;
2507
2617
        }
2508
2618
 
2533
2643
        status = ar6000_connectservice(ar,
2534
2644
                                       &connect,
2535
2645
                                       "WMI CONTROL");
2536
 
        if (A_FAILED(status)) {
 
2646
        if (status) {
2537
2647
            break;
2538
2648
        }
2539
2649
 
2555
2665
             * of 0-3 */
2556
2666
            connect.ConnectionFlags &= ~HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK;
2557
2667
            connect.ConnectionFlags |=
2558
 
                        ((A_UINT16)reduce_credit_dribble - 1) & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK;
 
2668
                        ((u16)reduce_credit_dribble - 1) & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK;
2559
2669
        }
2560
2670
            /* connect to best-effort service */
2561
2671
        connect.ServiceID = WMI_DATA_BE_SVC;
2563
2673
        status = ar6000_connectservice(ar,
2564
2674
                                       &connect,
2565
2675
                                       "WMI DATA BE");
2566
 
        if (A_FAILED(status)) {
 
2676
        if (status) {
2567
2677
            break;
2568
2678
        }
2569
2679
 
2573
2683
        status = ar6000_connectservice(ar,
2574
2684
                                       &connect,
2575
2685
                                       "WMI DATA BK");
2576
 
        if (A_FAILED(status)) {
 
2686
        if (status) {
2577
2687
            break;
2578
2688
        }
2579
2689
 
2583
2693
        status = ar6000_connectservice(ar,
2584
2694
                                       &connect,
2585
2695
                                       "WMI DATA VI");
2586
 
        if (A_FAILED(status)) {
 
2696
        if (status) {
2587
2697
            break;
2588
2698
        }
2589
2699
 
2596
2706
        status = ar6000_connectservice(ar,
2597
2707
                                       &connect,
2598
2708
                                       "WMI DATA VO");
2599
 
        if (A_FAILED(status)) {
 
2709
        if (status) {
2600
2710
            break;
2601
2711
        }
2602
2712
 
2613
2723
 
2614
2724
#ifdef EXPORT_HCI_BRIDGE_INTERFACE
2615
2725
        if (setuphci && (NULL != ar6kHciTransCallbacks.setupTransport)) {
2616
 
            HCI_TRANSPORT_MISC_HANDLES hciHandles;
 
2726
            struct hci_transport_misc_handles hciHandles;
2617
2727
 
2618
2728
            hciHandles.netDevice = ar->arNetDev;
2619
2729
            hciHandles.hifDevice = ar->arHifDevice;
2620
2730
            hciHandles.htcHandle = ar->arHtcTarget;
2621
 
            status = (A_STATUS)(ar6kHciTransCallbacks.setupTransport(&hciHandles));
 
2731
            status = (int)(ar6kHciTransCallbacks.setupTransport(&hciHandles));
2622
2732
        }
2623
2733
#else
2624
2734
        if (setuphci) {
2634
2744
          status = ar6k_setup_hci_pal(ar);
2635
2745
#endif
2636
2746
 
2637
 
    } while (FALSE);
 
2747
    } while (false);
2638
2748
 
2639
 
    if (A_FAILED(status)) {
 
2749
    if (status) {
2640
2750
        ret = -EIO;
2641
2751
        goto ar6000_init_done;
2642
2752
    }
2671
2781
    /* start HTC */
2672
2782
    status = HTCStart(ar->arHtcTarget);
2673
2783
 
2674
 
    if (status != A_OK) {
2675
 
        if (ar->arWmiEnabled == TRUE) {
 
2784
    if (status) {
 
2785
        if (ar->arWmiEnabled == true) {
2676
2786
            wmi_shutdown(ar->arWmi);
2677
 
            ar->arWmiEnabled = FALSE;
 
2787
            ar->arWmiEnabled = false;
2678
2788
            ar->arWmi = NULL;
2679
2789
        }
2680
2790
        ar6000_cookie_cleanup(ar);
2685
2795
    if (!bypasswmi) {
2686
2796
        /* Wait for Wmi event to be ready */
2687
2797
        timeleft = wait_event_interruptible_timeout(arEvent,
2688
 
            (ar->arWmiReady == TRUE), wmitimeout * HZ);
 
2798
            (ar->arWmiReady == true), wmitimeout * HZ);
2689
2799
 
2690
2800
        if (ar->arVersion.abi_ver != AR6K_ABI_VERSION) {
2691
2801
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ABI Version mismatch: Host(0x%x), Target(0x%x)\n", AR6K_ABI_VERSION, ar->arVersion.abi_ver));
2705
2815
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s() WMI is ready\n", __func__));
2706
2816
 
2707
2817
        /* Communicate the wmi protocol verision to the target */
2708
 
        if ((ar6000_set_host_app_area(ar)) != A_OK) {
 
2818
        if ((ar6000_set_host_app_area(ar)) != 0) {
2709
2819
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set the host app area\n"));
2710
2820
        }
2711
 
 
2712
 
        /* configure the device for rx dot11 header rules 0,0 are the default values
2713
 
         * therefore this command can be skipped if the inputs are 0,FALSE,FALSE.Required
2714
 
         if checksum offload is needed. Set RxMetaVersion to 2*/
2715
 
        if ((wmi_set_rx_frame_format_cmd(ar->arWmi,ar->rxMetaVersion, processDot11Hdr, processDot11Hdr)) != A_OK) {
2716
 
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set the rx frame format.\n"));
2717
 
        }
2718
 
 
2719
 
#if defined(INIT_MODE_DRV_ENABLED) && defined(ENABLE_COEXISTENCE)
2720
 
        /* Configure the type of BT collocated with WLAN */
2721
 
        A_MEMZERO(&sbcb_cmd, sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD));
2722
 
#ifdef CONFIG_AR600x_BT_QCOM
2723
 
        sbcb_cmd.btcoexCoLocatedBTdev = 1;
2724
 
#elif defined(CONFIG_AR600x_BT_CSR)
2725
 
        sbcb_cmd.btcoexCoLocatedBTdev = 2;
2726
 
#elif defined(CONFIG_AR600x_BT_AR3001)
2727
 
        sbcb_cmd.btcoexCoLocatedBTdev = 3;
2728
 
#else
2729
 
#error Unsupported Bluetooth Type
2730
 
#endif /* Collocated Bluetooth Type */
2731
 
 
2732
 
        if ((wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &sbcb_cmd)) != A_OK)
2733
 
        {
2734
 
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set collocated BT type\n"));
2735
 
        }
2736
 
 
2737
 
        /* Configure the type of BT collocated with WLAN */
2738
 
        A_MEMZERO(&sbfa_cmd, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD));
2739
 
#ifdef CONFIG_AR600x_DUAL_ANTENNA
2740
 
        sbfa_cmd.btcoexFeAntType = 2;
2741
 
#elif defined(CONFIG_AR600x_SINGLE_ANTENNA)
2742
 
        sbfa_cmd.btcoexFeAntType = 1;
2743
 
#else
2744
 
#error Unsupported Front-End Antenna Configuration
2745
 
#endif /* AR600x Front-End Antenna Configuration */
2746
 
 
2747
 
        if ((wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &sbfa_cmd)) != A_OK) {
2748
 
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set fornt end antenna configuration\n"));
2749
 
        }
2750
 
#endif /* INIT_MODE_DRV_ENABLED && ENABLE_COEXISTENCE */
 
2821
        ar6000_target_config_wlan_params(ar);
2751
2822
    }
2752
2823
 
2753
2824
    ar->arNumDataEndPts = 1;
2772
2843
 
2773
2844
 
2774
2845
void
2775
 
ar6000_bitrate_rx(void *devt, A_INT32 rateKbps)
 
2846
ar6000_bitrate_rx(void *devt, s32 rateKbps)
2776
2847
{
2777
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
 
2848
    struct ar6_softc *ar = (struct ar6_softc *)devt;
2778
2849
 
2779
2850
    ar->arBitRate = rateKbps;
2780
2851
    wake_up(&arEvent);
2781
2852
}
2782
2853
 
2783
2854
void
2784
 
ar6000_ratemask_rx(void *devt, A_UINT32 ratemask)
 
2855
ar6000_ratemask_rx(void *devt, u32 ratemask)
2785
2856
{
2786
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
 
2857
    struct ar6_softc *ar = (struct ar6_softc *)devt;
2787
2858
 
2788
2859
    ar->arRateMask = ratemask;
2789
2860
    wake_up(&arEvent);
2790
2861
}
2791
2862
 
2792
2863
void
2793
 
ar6000_txPwr_rx(void *devt, A_UINT8 txPwr)
 
2864
ar6000_txPwr_rx(void *devt, u8 txPwr)
2794
2865
{
2795
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
 
2866
    struct ar6_softc *ar = (struct ar6_softc *)devt;
2796
2867
 
2797
2868
    ar->arTxPwr = txPwr;
2798
2869
    wake_up(&arEvent);
2800
2871
 
2801
2872
 
2802
2873
void
2803
 
ar6000_channelList_rx(void *devt, A_INT8 numChan, A_UINT16 *chanList)
 
2874
ar6000_channelList_rx(void *devt, s8 numChan, u16 *chanList)
2804
2875
{
2805
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
 
2876
    struct ar6_softc *ar = (struct ar6_softc *)devt;
2806
2877
 
2807
 
    A_MEMCPY(ar->arChannelList, chanList, numChan * sizeof (A_UINT16));
 
2878
    memcpy(ar->arChannelList, chanList, numChan * sizeof (u16));
2808
2879
    ar->arNumChannels = numChan;
2809
2880
 
2810
2881
    wake_up(&arEvent);
2811
2882
}
2812
2883
 
2813
 
A_UINT8
2814
 
ar6000_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, A_UINT32 * mapNo)
 
2884
u8 ar6000_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, u32 *mapNo)
2815
2885
{
2816
 
    AR_SOFTC_T      *ar = (AR_SOFTC_T *)ar6k_priv(dev);
2817
 
    A_UINT8         *datap;
 
2886
    struct ar6_softc      *ar = (struct ar6_softc *)ar6k_priv(dev);
 
2887
    u8 *datap;
2818
2888
    ATH_MAC_HDR     *macHdr;
2819
 
    A_UINT32         i, eptMap;
 
2889
    u32 i, eptMap;
2820
2890
 
2821
2891
    (*mapNo) = 0;
2822
2892
    datap = A_NETBUF_DATA(skb);
2844
2914
        A_ASSERT(ar->arNodeNum <= MAX_NODE_NUM);
2845
2915
    }
2846
2916
 
2847
 
    A_MEMCPY(ar->arNodeMap[eptMap].macAddress, macHdr->dstMac, IEEE80211_ADDR_LEN);
 
2917
    memcpy(ar->arNodeMap[eptMap].macAddress, macHdr->dstMac, IEEE80211_ADDR_LEN);
2848
2918
 
2849
2919
    for (i = ENDPOINT_2; i <= ENDPOINT_5; i ++) {
2850
2920
        if (!ar->arTxPending[i]) {
2882
2952
#endif
2883
2953
 
2884
2954
#ifdef HTC_TEST_SEND_PKTS
2885
 
static void DoHTCSendPktsTest(AR_SOFTC_T *ar, int MapNo, HTC_ENDPOINT_ID eid, struct sk_buff *skb);
 
2955
static void DoHTCSendPktsTest(struct ar6_softc *ar, int MapNo, HTC_ENDPOINT_ID eid, struct sk_buff *skb);
2886
2956
#endif
2887
2957
 
2888
2958
static int
2889
2959
ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)
2890
2960
{
2891
2961
#define AC_NOT_MAPPED   99
2892
 
    AR_SOFTC_T        *ar = (AR_SOFTC_T *)ar6k_priv(dev);
2893
 
    A_UINT8            ac = AC_NOT_MAPPED;
 
2962
    struct ar6_softc        *ar = (struct ar6_softc *)ar6k_priv(dev);
 
2963
    u8 ac = AC_NOT_MAPPED;
2894
2964
    HTC_ENDPOINT_ID    eid = ENDPOINT_UNUSED;
2895
 
    A_UINT32          mapNo = 0;
 
2965
    u32 mapNo = 0;
2896
2966
    int               len;
2897
2967
    struct ar_cookie *cookie;
2898
 
    A_BOOL            checkAdHocPsMapping = FALSE,bMoreData = FALSE;
 
2968
    bool            checkAdHocPsMapping = false,bMoreData = false;
2899
2969
    HTC_TX_TAG        htc_tag = AR6K_DATA_PKT_TAG;
2900
 
    A_UINT8           dot11Hdr = processDot11Hdr;
 
2970
    u8 dot11Hdr = processDot11Hdr;
2901
2971
#ifdef CONFIG_PM
2902
2972
    if (ar->arWowState != WLAN_WOW_STATE_NONE) {
2903
2973
        A_NETBUF_FREE(skb);
2912
2982
    /* If target is not associated */
2913
2983
    if( (!ar->arConnected && !bypasswmi)
2914
2984
#ifdef CONFIG_HOST_TCMD_SUPPORT
2915
 
     /* TCMD doesnt support any data, free the buf and return */
 
2985
     /* TCMD doesn't support any data, free the buf and return */
2916
2986
    || (ar->arTargetMode == AR6000_TCMD_MODE)
2917
2987
#endif
2918
2988
                                            ) {
2922
2992
 
2923
2993
    do {
2924
2994
 
2925
 
        if (ar->arWmiReady == FALSE && bypasswmi == 0) {
 
2995
        if (ar->arWmiReady == false && bypasswmi == 0) {
2926
2996
            break;
2927
2997
        }
2928
2998
 
2944
3014
             * mcastq
2945
3015
             */
2946
3016
            if (IEEE80211_IS_MULTICAST(datap->dstMac)) {
2947
 
                A_UINT8 ctr=0;
2948
 
                A_BOOL qMcast=FALSE;
 
3017
                u8 ctr=0;
 
3018
                bool qMcast=false;
2949
3019
 
2950
3020
 
2951
3021
                for (ctr=0; ctr<AP_MAX_NUM_STA; ctr++) {
2952
3022
                    if (STA_IS_PWR_SLEEP((&ar->sta_list[ctr]))) {
2953
 
                        qMcast = TRUE;
 
3023
                        qMcast = true;
2954
3024
                    }
2955
3025
                }
2956
3026
                if(qMcast) {
2957
3027
 
2958
3028
                    /* If this transmit is not because of a Dtim Expiry q it */
2959
 
                    if (ar->DTIMExpired == FALSE) {
2960
 
                        A_BOOL isMcastqEmpty = FALSE;
 
3029
                    if (ar->DTIMExpired == false) {
 
3030
                        bool isMcastqEmpty = false;
2961
3031
 
2962
3032
                        A_MUTEX_LOCK(&ar->mcastpsqLock);
2963
3033
                        isMcastqEmpty = A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq);
2978
3048
                      */
2979
3049
                         A_MUTEX_LOCK(&ar->mcastpsqLock);
2980
3050
                         if(!A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq)) {
2981
 
                             bMoreData = TRUE;
 
3051
                             bMoreData = true;
2982
3052
                         }
2983
3053
                         A_MUTEX_UNLOCK(&ar->mcastpsqLock);
2984
3054
                    }
2989
3059
                    if (STA_IS_PWR_SLEEP(conn)) {
2990
3060
                        /* If this transmit is not because of a PsPoll q it*/
2991
3061
                        if (!STA_IS_PS_POLLED(conn)) {
2992
 
                            A_BOOL isPsqEmpty = FALSE;
 
3062
                            bool isPsqEmpty = false;
2993
3063
                            /* Queue the frames if the STA is sleeping */
2994
3064
                            A_MUTEX_LOCK(&conn->psqLock);
2995
3065
                            isPsqEmpty = A_NETBUF_QUEUE_EMPTY(&conn->psq);
3010
3080
                          */
3011
3081
                             A_MUTEX_LOCK(&conn->psqLock);
3012
3082
                             if (!A_NETBUF_QUEUE_EMPTY(&conn->psq)) {
3013
 
                                 bMoreData = TRUE;
 
3083
                                 bMoreData = true;
3014
3084
                             }
3015
3085
                             A_MUTEX_UNLOCK(&conn->psqLock);
3016
3086
                         }
3026
3096
 
3027
3097
        if (ar->arWmiEnabled) {
3028
3098
#ifdef CONFIG_CHECKSUM_OFFLOAD
3029
 
        A_UINT8 csumStart=0;
3030
 
        A_UINT8 csumDest=0;
3031
 
        A_UINT8 csum=skb->ip_summed;
 
3099
        u8 csumStart=0;
 
3100
        u8 csumDest=0;
 
3101
        u8 csum=skb->ip_summed;
3032
3102
        if(csumOffload && (csum==CHECKSUM_PARTIAL)){
3033
3103
            csumStart = (skb->head + skb->csum_start - skb_network_header(skb) +
3034
3104
                         sizeof(ATH_LLC_SNAP_HDR));
3048
3118
                    break;
3049
3119
                }
3050
3120
                A_NETBUF_PUT(newbuf, len);
3051
 
                A_MEMCPY(A_NETBUF_DATA(newbuf), A_NETBUF_DATA(skb), len);
 
3121
                memcpy(A_NETBUF_DATA(newbuf), A_NETBUF_DATA(skb), len);
3052
3122
                A_NETBUF_FREE(skb);
3053
3123
                skb = newbuf;
3054
3124
                /* fall through and assemble header */
3055
3125
            }
3056
3126
 
3057
3127
            if (dot11Hdr) {
3058
 
                if (wmi_dot11_hdr_add(ar->arWmi,skb,ar->arNetworkType) != A_OK) {
 
3128
                if (wmi_dot11_hdr_add(ar->arWmi,skb,ar->arNetworkType) != 0) {
3059
3129
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx-wmi_dot11_hdr_add failed\n"));
3060
3130
                    break;
3061
3131
                }
3062
3132
            } else {
3063
 
                if (wmi_dix_2_dot3(ar->arWmi, skb) != A_OK) {
 
3133
                if (wmi_dix_2_dot3(ar->arWmi, skb) != 0) {
3064
3134
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx - wmi_dix_2_dot3 failed\n"));
3065
3135
                    break;
3066
3136
                }
3072
3142
                metaV2.csumDest = csumDest;
3073
3143
                metaV2.csumFlags = 0x1;/*instruct target to calculate checksum*/
3074
3144
                if (wmi_data_hdr_add(ar->arWmi, skb, DATA_MSGTYPE, bMoreData, dot11Hdr,
3075
 
                                        WMI_META_VERSION_2,&metaV2) != A_OK) {
 
3145
                                        WMI_META_VERSION_2,&metaV2) != 0) {
3076
3146
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
3077
3147
                    break;
3078
3148
                }
3081
3151
            else
3082
3152
#endif
3083
3153
            {
3084
 
                if (wmi_data_hdr_add(ar->arWmi, skb, DATA_MSGTYPE, bMoreData, dot11Hdr,0,NULL) != A_OK) {
 
3154
                if (wmi_data_hdr_add(ar->arWmi, skb, DATA_MSGTYPE, bMoreData, dot11Hdr,0,NULL) != 0) {
3085
3155
                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
3086
3156
                    break;
3087
3157
                }
3091
3161
            if ((ar->arNetworkType == ADHOC_NETWORK) &&
3092
3162
                ar->arIbssPsEnable && ar->arConnected) {
3093
3163
                    /* flag to check adhoc mapping once we take the lock below: */
3094
 
                checkAdHocPsMapping = TRUE;
 
3164
                checkAdHocPsMapping = true;
3095
3165
 
3096
3166
            } else {
3097
3167
                    /* get the stream mapping */
3115
3185
                if (ac == HCI_TRANSPORT_STREAM_NUM) {
3116
3186
                        /* pass this to HCI */
3117
3187
#ifndef EXPORT_HCI_BRIDGE_INTERFACE
3118
 
                    if (A_SUCCESS(hci_test_send(ar,skb))) {
 
3188
                    if (!hci_test_send(ar,skb)) {
3119
3189
                        return 0;
3120
3190
                    }
3121
3191
#endif
3136
3206
            }
3137
3207
        }
3138
3208
 
3139
 
    } while (FALSE);
 
3209
    } while (false);
3140
3210
 
3141
3211
        /* did we succeed ? */
3142
3212
    if ((ac == AC_NOT_MAPPED) && !checkAdHocPsMapping) {
3173
3243
            ar->arTotalTxDataPending++;
3174
3244
        }
3175
3245
 
3176
 
    } while (FALSE);
 
3246
    } while (false);
3177
3247
 
3178
3248
    AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3179
3249
 
3211
3281
int
3212
3282
ar6000_acl_data_tx(struct sk_buff *skb, struct net_device *dev)
3213
3283
{
3214
 
    AR_SOFTC_T        *ar = (AR_SOFTC_T *)ar6k_priv(dev);
 
3284
    struct ar6_softc        *ar = (struct ar6_softc *)ar6k_priv(dev);
3215
3285
    struct ar_cookie *cookie;
3216
3286
    HTC_ENDPOINT_ID    eid = ENDPOINT_UNUSED;
3217
3287
 
3267
3337
}
3268
3338
 
3269
3339
void
3270
 
applyAPTCHeuristics(AR_SOFTC_T *ar)
 
3340
applyAPTCHeuristics(struct ar6_softc *ar)
3271
3341
{
3272
 
    A_UINT32 duration;
3273
 
    A_UINT32 numbytes;
3274
 
    A_UINT32 throughput;
 
3342
    u32 duration;
 
3343
    u32 numbytes;
 
3344
    u32 throughput;
3275
3345
    struct timeval ts;
3276
 
    A_STATUS status;
 
3346
    int status;
3277
3347
 
3278
3348
    AR6000_SPIN_LOCK(&ar->arLock, 0);
3279
3349
 
3292
3362
            throughput = ((numbytes * 8) / duration);
3293
3363
            if (throughput > APTC_UPPER_THROUGHPUT_THRESHOLD) {
3294
3364
                /* Disable Sleep and schedule a timer */
3295
 
                A_ASSERT(ar->arWmiReady == TRUE);
 
3365
                A_ASSERT(ar->arWmiReady == true);
3296
3366
                AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3297
3367
                status = wmi_powermode_cmd(ar->arWmi, MAX_PERF_POWER);
3298
3368
                AR6000_SPIN_LOCK(&ar->arLock, 0);
3299
3369
                A_TIMEOUT_MS(&aptcTimer, APTC_TRAFFIC_SAMPLING_INTERVAL, 0);
3300
 
                aptcTR.timerScheduled = TRUE;
 
3370
                aptcTR.timerScheduled = true;
3301
3371
            }
3302
3372
        }
3303
3373
    }
3306
3376
}
3307
3377
#endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
3308
3378
 
3309
 
static HTC_SEND_FULL_ACTION ar6000_tx_queue_full(void *Context, HTC_PACKET *pPacket)
 
3379
static HTC_SEND_FULL_ACTION ar6000_tx_queue_full(void *Context, struct htc_packet *pPacket)
3310
3380
{
3311
 
    AR_SOFTC_T     *ar = (AR_SOFTC_T *)Context;
 
3381
    struct ar6_softc     *ar = (struct ar6_softc *)Context;
3312
3382
    HTC_SEND_FULL_ACTION    action = HTC_SEND_FULL_KEEP;
3313
 
    A_BOOL                  stopNet = FALSE;
 
3383
    bool                  stopNet = false;
3314
3384
    HTC_ENDPOINT_ID         Endpoint = HTC_GET_ENDPOINT_FROM_PKT(pPacket);
3315
3385
 
3316
3386
    do {
3327
3397
                /* for endpoint ping testing drop Best Effort and Background */
3328
3398
            if ((accessClass == WMM_AC_BE) || (accessClass == WMM_AC_BK)) {
3329
3399
                action = HTC_SEND_FULL_DROP;
3330
 
                stopNet = FALSE;
 
3400
                stopNet = false;
3331
3401
            } else {
3332
3402
                    /* keep but stop the netqueues */
3333
 
                stopNet = TRUE;
 
3403
                stopNet = true;
3334
3404
            }
3335
3405
            break;
3336
3406
        }
3341
3411
                 * the only exception to this is during testing using endpointping */
3342
3412
            AR6000_SPIN_LOCK(&ar->arLock, 0);
3343
3413
                /* set flag to handle subsequent messages */
3344
 
            ar->arWMIControlEpFull = TRUE;
 
3414
            ar->arWMIControlEpFull = true;
3345
3415
            AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3346
3416
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("WMI Control Endpoint is FULL!!! \n"));
3347
3417
                /* no need to stop the network */
3348
 
            stopNet = FALSE;
 
3418
            stopNet = false;
3349
3419
            break;
3350
3420
        }
3351
3421
 
3359
3429
        if (ar->arNetworkType == ADHOC_NETWORK) {
3360
3430
            /* in adhoc mode, we cannot differentiate traffic priorities so there is no need to
3361
3431
             * continue, however we should stop the network */
3362
 
            stopNet = TRUE;
 
3432
            stopNet = true;
3363
3433
            break;
3364
3434
        }
3365
3435
        /* the last MAX_HI_COOKIE_NUM "batch" of cookies are reserved for the highest
3371
3441
                 * HTC to drop the packet that overflowed */
3372
3442
            action = HTC_SEND_FULL_DROP;
3373
3443
                /* since we are dropping packets, no need to stop the network */
3374
 
            stopNet = FALSE;
 
3444
            stopNet = false;
3375
3445
            break;
3376
3446
        }
3377
3447
 
3378
 
    } while (FALSE);
 
3448
    } while (false);
3379
3449
 
3380
3450
    if (stopNet) {
3381
3451
        AR6000_SPIN_LOCK(&ar->arLock, 0);
3382
 
        ar->arNetQueueStopped = TRUE;
 
3452
        ar->arNetQueueStopped = true;
3383
3453
        AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3384
3454
        /* one of the data endpoints queues is getting full..need to stop network stack
3385
3455
         * the queue will resume in ar6000_tx_complete() */
3391
3461
 
3392
3462
 
3393
3463
static void
3394
 
ar6000_tx_complete(void *Context, HTC_PACKET_QUEUE *pPacketQueue)
 
3464
ar6000_tx_complete(void *Context, struct htc_packet_queue *pPacketQueue)
3395
3465
{
3396
 
    AR_SOFTC_T     *ar = (AR_SOFTC_T *)Context;
3397
 
    A_UINT32        mapNo = 0;
3398
 
    A_STATUS        status;
 
3466
    struct ar6_softc     *ar = (struct ar6_softc *)Context;
 
3467
    u32 mapNo = 0;
 
3468
    int        status;
3399
3469
    struct ar_cookie * ar_cookie;
3400
3470
    HTC_ENDPOINT_ID   eid;
3401
 
    A_BOOL          wakeEvent = FALSE;
 
3471
    bool          wakeEvent = false;
3402
3472
    struct sk_buff_head  skb_queue;
3403
 
    HTC_PACKET      *pPacket;
 
3473
    struct htc_packet      *pPacket;
3404
3474
    struct sk_buff  *pktSkb;
3405
 
    A_BOOL          flushing = FALSE;
 
3475
    bool          flushing = false;
3406
3476
 
3407
3477
    skb_queue_head_init(&skb_queue);
3408
3478
 
3428
3498
            /* add this to the list, use faster non-lock API */
3429
3499
        __skb_queue_tail(&skb_queue,pktSkb);
3430
3500
 
3431
 
        if (A_SUCCESS(status)) {
 
3501
        if (!status) {
3432
3502
            A_ASSERT(pPacket->ActualLength == A_NETBUF_LEN(pktSkb));
3433
3503
        }
3434
3504
 
3447
3517
        {
3448
3518
            if (ar->arWMIControlEpFull) {
3449
3519
                    /* since this packet completed, the WMI EP is no longer full */
3450
 
                ar->arWMIControlEpFull = FALSE;
 
3520
                ar->arWMIControlEpFull = false;
3451
3521
            }
3452
3522
 
3453
3523
            if (ar->arTxPending[eid] == 0) {
3454
 
                wakeEvent = TRUE;
 
3524
                wakeEvent = true;
3455
3525
            }
3456
3526
        }
3457
3527
 
3458
 
        if (A_FAILED(status)) {
 
3528
        if (status) {
3459
3529
            if (status == A_ECANCELED) {
3460
3530
                    /* a packet was flushed  */
3461
 
                flushing = TRUE;
 
3531
                flushing = true;
3462
3532
            }
3463
3533
            AR6000_STAT_INC(ar, tx_errors);
3464
3534
            if (status != A_NO_RESOURCE) {
3467
3537
            }
3468
3538
        } else {
3469
3539
            AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX,("OK\n"));
3470
 
            flushing = FALSE;
 
3540
            flushing = false;
3471
3541
            AR6000_STAT_INC(ar, tx_packets);
3472
3542
            ar->arNetStats.tx_bytes += A_NETBUF_LEN(pktSkb);
3473
3543
#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3484
3554
            ar->arNodeMap[mapNo].txPending --;
3485
3555
 
3486
3556
            if (!ar->arNodeMap[mapNo].txPending && (mapNo == (ar->arNodeNum - 1))) {
3487
 
                A_UINT32 i;
 
3557
                u32 i;
3488
3558
                for (i = ar->arNodeNum; i > 0; i --) {
3489
3559
                    if (!ar->arNodeMap[i - 1].txPending) {
3490
3560
                        A_MEMZERO(&ar->arNodeMap[i - 1], sizeof(struct ar_node_mapping));
3499
3569
        ar6000_free_cookie(ar, ar_cookie);
3500
3570
 
3501
3571
        if (ar->arNetQueueStopped) {
3502
 
            ar->arNetQueueStopped = FALSE;
 
3572
            ar->arNetQueueStopped = false;
3503
3573
        }
3504
3574
    }
3505
3575
 
3514
3584
        A_NETBUF_FREE(pktSkb);
3515
3585
    }
3516
3586
 
3517
 
    if ((ar->arConnected == TRUE) || (bypasswmi)) {
 
3587
    if ((ar->arConnected == true) || bypasswmi) {
3518
3588
        if (!flushing) {
3519
3589
                /* don't wake the queue if we are flushing, other wise it will just
3520
3590
                 * keep queueing packets, which will keep failing */
3529
3599
}
3530
3600
 
3531
3601
sta_t *
3532
 
ieee80211_find_conn(AR_SOFTC_T *ar, A_UINT8 *node_addr)
 
3602
ieee80211_find_conn(struct ar6_softc *ar, u8 *node_addr)
3533
3603
{
3534
3604
    sta_t *conn = NULL;
3535
 
    A_UINT8 i, max_conn;
 
3605
    u8 i, max_conn;
3536
3606
 
3537
3607
    switch(ar->arNetworkType) {
3538
3608
        case AP_NETWORK:
3553
3623
    return conn;
3554
3624
}
3555
3625
 
3556
 
sta_t *ieee80211_find_conn_for_aid(AR_SOFTC_T *ar, A_UINT8 aid)
 
3626
sta_t *ieee80211_find_conn_for_aid(struct ar6_softc *ar, u8 aid)
3557
3627
{
3558
3628
    sta_t *conn = NULL;
3559
 
    A_UINT8 ctr;
 
3629
    u8 ctr;
3560
3630
 
3561
3631
    for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) {
3562
3632
        if (ar->sta_list[ctr].aid == aid) {
3572
3642
 */
3573
3643
int pktcount;
3574
3644
static void
3575
 
ar6000_rx(void *Context, HTC_PACKET *pPacket)
 
3645
ar6000_rx(void *Context, struct htc_packet *pPacket)
3576
3646
{
3577
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)Context;
 
3647
    struct ar6_softc *ar = (struct ar6_softc *)Context;
3578
3648
    struct sk_buff *skb = (struct sk_buff *)pPacket->pPktContext;
3579
3649
    int minHdrLen;
3580
 
    A_UINT8 containsDot11Hdr = 0;
3581
 
    A_STATUS        status = pPacket->Status;
 
3650
    u8 containsDot11Hdr = 0;
 
3651
    int        status = pPacket->Status;
3582
3652
    HTC_ENDPOINT_ID   ept = pPacket->Endpoint;
3583
3653
 
3584
 
    A_ASSERT((status != A_OK) ||
 
3654
    A_ASSERT((status) ||
3585
3655
             (pPacket->pBuffer == (A_NETBUF_DATA(skb) + HTC_HEADER_LEN)));
3586
3656
 
3587
3657
    AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX,("ar6000_rx ar=0x%lx eid=%d, skb=0x%lx, data=0x%lx, len=0x%x status:%d",
3588
3658
                    (unsigned long)ar, ept, (unsigned long)skb, (unsigned long)pPacket->pBuffer,
3589
3659
                    pPacket->ActualLength, status));
3590
 
    if (status != A_OK) {
 
3660
    if (status) {
3591
3661
        if (status != A_ECANCELED) {
3592
3662
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("RX ERR (%d) \n",status));
3593
3663
        }
3597
3667
         * and adaptive power throughput state */
3598
3668
    AR6000_SPIN_LOCK(&ar->arLock, 0);
3599
3669
 
3600
 
    if (A_SUCCESS(status)) {
 
3670
    if (!status) {
3601
3671
        AR6000_STAT_INC(ar, rx_packets);
3602
3672
        ar->arNetStats.rx_bytes += pPacket->ActualLength;
3603
3673
#ifdef ADAPTIVE_POWER_THROUGHPUT_CONTROL
3618
3688
    AR6000_SPIN_UNLOCK(&ar->arLock, 0);
3619
3689
 
3620
3690
    skb->dev = ar->arNetDev;
3621
 
    if (status != A_OK) {
 
3691
    if (status) {
3622
3692
        AR6000_STAT_INC(ar, rx_errors);
3623
3693
        A_NETBUF_FREE(skb);
3624
 
    } else if (ar->arWmiEnabled == TRUE) {
 
3694
    } else if (ar->arWmiEnabled == true) {
3625
3695
        if (ept == ar->arControlEp) {
3626
3696
           /*
3627
3697
            * this is a wmi control msg
3628
3698
            */
3629
3699
#ifdef CONFIG_PM 
3630
 
            ar6000_check_wow_status(ar, skb, TRUE);
 
3700
            ar6000_check_wow_status(ar, skb, true);
3631
3701
#endif /* CONFIG_PM */
3632
3702
            wmi_control_rx(ar->arWmi, skb);
3633
3703
        } else {
3634
3704
                WMI_DATA_HDR *dhdr = (WMI_DATA_HDR *)A_NETBUF_DATA(skb);
3635
 
                A_UINT8 is_amsdu, tid, is_acl_data_frame;
 
3705
                bool is_amsdu;
 
3706
                u8 tid;
 
3707
                bool is_acl_data_frame;
3636
3708
                is_acl_data_frame = WMI_DATA_HDR_GET_DATA_TYPE(dhdr) == WMI_DATA_HDR_DATA_TYPE_ACL;
3637
3709
#ifdef CONFIG_PM 
3638
 
                ar6000_check_wow_status(ar, NULL, FALSE);
 
3710
                ar6000_check_wow_status(ar, NULL, false);
3639
3711
#endif /* CONFIG_PM */
3640
3712
                /*
3641
3713
                 * this is a wmi data packet
3667
3739
                    AR6000_STAT_INC(ar, rx_length_errors);
3668
3740
                    A_NETBUF_FREE(skb);
3669
3741
                } else {
3670
 
                    A_UINT16 seq_no;
3671
 
                    A_UINT8 meta_type;
 
3742
                    u16 seq_no;
 
3743
                    u8 meta_type;
3672
3744
 
3673
3745
#if 0
3674
3746
                    /* Access RSSI values here */
3678
3750
                    /* Get the Power save state of the STA */
3679
3751
                    if (ar->arNetworkType == AP_NETWORK) {
3680
3752
                        sta_t *conn = NULL;
3681
 
                        A_UINT8 psState=0,prevPsState;
 
3753
                        u8 psState=0,prevPsState;
3682
3754
                        ATH_MAC_HDR *datap=NULL;
3683
 
                        A_UINT16 offset;
 
3755
                        u16 offset;
3684
3756
 
3685
3757
                        meta_type = WMI_DATA_HDR_GET_META(dhdr);
3686
3758
 
3742
3814
                            }
3743
3815
                        } else {
3744
3816
                            /* This frame is from a STA that is not associated*/
3745
 
                            A_ASSERT(FALSE);
 
3817
                            A_ASSERT(false);
3746
3818
                        }
3747
3819
 
3748
3820
                        /* Drop NULL data frames here */
3753
3825
                        }
3754
3826
                    }
3755
3827
 
3756
 
                    is_amsdu = WMI_DATA_HDR_IS_AMSDU(dhdr);
 
3828
                    is_amsdu = WMI_DATA_HDR_IS_AMSDU(dhdr) ? true : false;
3757
3829
                    tid = WMI_DATA_HDR_GET_UP(dhdr);
3758
3830
                    seq_no = WMI_DATA_HDR_GET_SEQNO(dhdr);
3759
3831
                    meta_type = WMI_DATA_HDR_GET_META(dhdr);
3785
3857
                            break;
3786
3858
                    }
3787
3859
 
3788
 
                    A_ASSERT(status == A_OK);
 
3860
                    A_ASSERT(status == 0);
3789
3861
 
3790
3862
                    /* NWF: print the 802.11 hdr bytes */
3791
3863
                    if(containsDot11Hdr) {
3794
3866
                        status = wmi_dot3_2_dix(skb);
3795
3867
                    }
3796
3868
 
3797
 
                    if (status != A_OK) {
 
3869
                    if (status) {
3798
3870
                        /* Drop frames that could not be processed (lack of memory, etc.) */
3799
3871
                        A_NETBUF_FREE(skb);
3800
3872
                        goto rx_done;
3805
3877
                        *((short *)A_NETBUF_DATA(skb)) = WMI_ACL_DATA_EVENTID;
3806
3878
                        /* send the data packet to PAL driver */
3807
3879
                        if(ar6k_pal_config_g.fpar6k_pal_recv_pkt) {
3808
 
                                if((*ar6k_pal_config_g.fpar6k_pal_recv_pkt)(ar->hcipal_info, skb) == TRUE)
 
3880
                                if((*ar6k_pal_config_g.fpar6k_pal_recv_pkt)(ar->hcipal_info, skb) == true)
3809
3881
                                        goto rx_done;
3810
3882
                        }
3811
3883
                    }
3870
3942
        skb->dev = dev;
3871
3943
        if ((skb->dev->flags & IFF_UP) == IFF_UP) {
3872
3944
#ifdef CONFIG_PM 
3873
 
            ar6000_check_wow_status((AR_SOFTC_T *)ar6k_priv(dev), skb, FALSE);   
 
3945
            ar6000_check_wow_status((struct ar6_softc *)ar6k_priv(dev), skb, false);
3874
3946
#endif /* CONFIG_PM */
3875
3947
            skb->protocol = eth_type_trans(skb, skb->dev);
3876
3948
        /*
3915
3987
static void
3916
3988
ar6000_rx_refill(void *Context, HTC_ENDPOINT_ID Endpoint)
3917
3989
{
3918
 
    AR_SOFTC_T  *ar = (AR_SOFTC_T *)Context;
 
3990
    struct ar6_softc  *ar = (struct ar6_softc *)Context;
3919
3991
    void        *osBuf;
3920
3992
    int         RxBuffers;
3921
3993
    int         buffersToRefill;
3922
 
    HTC_PACKET  *pPacket;
3923
 
    HTC_PACKET_QUEUE queue;
 
3994
    struct htc_packet  *pPacket;
 
3995
    struct htc_packet_queue queue;
3924
3996
 
3925
3997
    buffersToRefill = (int)AR6000_MAX_RX_BUFFERS -
3926
3998
                                    HTCGetNumRecvBuffers(ar->arHtcTarget, Endpoint);
3942
4014
        }
3943
4015
            /* the HTC packet wrapper is at the head of the reserved area
3944
4016
             * in the skb */
3945
 
        pPacket = (HTC_PACKET *)(A_NETBUF_HEAD(osBuf));
 
4017
        pPacket = (struct htc_packet *)(A_NETBUF_HEAD(osBuf));
3946
4018
            /* set re-fill info */
3947
4019
        SET_HTC_PACKET_INFO_RX_REFILL(pPacket,osBuf,A_NETBUF_DATA(osBuf),AR6000_BUFFER_SIZE,Endpoint);
3948
4020
            /* add to queue */
3957
4029
}
3958
4030
 
3959
4031
  /* clean up our amsdu buffer list */
3960
 
static void ar6000_cleanup_amsdu_rxbufs(AR_SOFTC_T *ar)
 
4032
static void ar6000_cleanup_amsdu_rxbufs(struct ar6_softc *ar)
3961
4033
{
3962
 
    HTC_PACKET  *pPacket;
 
4034
    struct htc_packet  *pPacket;
3963
4035
    void        *osBuf;
3964
4036
 
3965
4037
        /* empty AMSDU buffer queue and free OS bufs */
3966
 
    while (TRUE) {
 
4038
    while (true) {
3967
4039
 
3968
4040
        AR6000_SPIN_LOCK(&ar->arLock, 0);
3969
4041
        pPacket = HTC_PACKET_DEQUEUE(&ar->amsdu_rx_buffer_queue);
3975
4047
 
3976
4048
        osBuf = pPacket->pPktContext;
3977
4049
        if (NULL == osBuf) {
3978
 
            A_ASSERT(FALSE);
 
4050
            A_ASSERT(false);
3979
4051
            break;
3980
4052
        }
3981
4053
 
3986
4058
 
3987
4059
 
3988
4060
    /* refill the amsdu buffer list */
3989
 
static void ar6000_refill_amsdu_rxbufs(AR_SOFTC_T *ar, int Count)
 
4061
static void ar6000_refill_amsdu_rxbufs(struct ar6_softc *ar, int Count)
3990
4062
{
3991
 
    HTC_PACKET  *pPacket;
 
4063
    struct htc_packet  *pPacket;
3992
4064
    void        *osBuf;
3993
4065
 
3994
4066
    while (Count > 0) {
3998
4070
        }
3999
4071
            /* the HTC packet wrapper is at the head of the reserved area
4000
4072
             * in the skb */
4001
 
        pPacket = (HTC_PACKET *)(A_NETBUF_HEAD(osBuf));
 
4073
        pPacket = (struct htc_packet *)(A_NETBUF_HEAD(osBuf));
4002
4074
            /* set re-fill info */
4003
4075
        SET_HTC_PACKET_INFO_RX_REFILL(pPacket,osBuf,A_NETBUF_DATA(osBuf),AR6000_AMSDU_BUFFER_SIZE,0);
4004
4076
 
4018
4090
     * keep the allocation size the same to optimize cached-slab allocations.
4019
4091
     *
4020
4092
     * */
4021
 
static HTC_PACKET *ar6000_alloc_amsdu_rxbuf(void *Context, HTC_ENDPOINT_ID Endpoint, int Length)
 
4093
static struct htc_packet *ar6000_alloc_amsdu_rxbuf(void *Context, HTC_ENDPOINT_ID Endpoint, int Length)
4022
4094
{
4023
 
    HTC_PACKET  *pPacket = NULL;
4024
 
    AR_SOFTC_T  *ar = (AR_SOFTC_T *)Context;
 
4095
    struct htc_packet  *pPacket = NULL;
 
4096
    struct ar6_softc  *ar = (struct ar6_softc *)Context;
4025
4097
    int         refillCount = 0;
4026
4098
 
4027
4099
    AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_RX,("ar6000_alloc_amsdu_rxbuf: eid=%d, Length:%d\n",Endpoint,Length));
4030
4102
 
4031
4103
        if (Length <= AR6000_BUFFER_SIZE) {
4032
4104
                /* shouldn't be getting called on normal sized packets */
4033
 
            A_ASSERT(FALSE);
 
4105
            A_ASSERT(false);
4034
4106
            break;
4035
4107
        }
4036
4108
 
4037
4109
        if (Length > AR6000_AMSDU_BUFFER_SIZE) {
4038
 
            A_ASSERT(FALSE);
 
4110
            A_ASSERT(false);
4039
4111
            break;
4040
4112
        }
4041
4113
 
4052
4124
            /* set actual endpoint ID */
4053
4125
        pPacket->Endpoint = Endpoint;
4054
4126
 
4055
 
    } while (FALSE);
 
4127
    } while (false);
4056
4128
 
4057
4129
    if (refillCount >= AR6000_AMSDU_REFILL_THRESHOLD) {
4058
4130
        ar6000_refill_amsdu_rxbufs(ar,refillCount);
4070
4142
static struct net_device_stats *
4071
4143
ar6000_get_stats(struct net_device *dev)
4072
4144
{
4073
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
 
4145
    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
4074
4146
    return &ar->arNetStats;
4075
4147
}
4076
4148
 
4077
4149
static struct iw_statistics *
4078
4150
ar6000_get_iwstats(struct net_device * dev)
4079
4151
{
4080
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(dev);
 
4152
    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
4081
4153
    TARGET_STATS *pStats = &ar->arTargetStats;
4082
4154
    struct iw_statistics * pIwStats = &ar->arIwStats;
4083
4155
    int rtnllocked;
4084
4156
 
4085
 
    if (ar->bIsDestroyProgress || ar->arWmiReady == FALSE || ar->arWlanState == WLAN_DISABLED)
 
4157
    if (ar->bIsDestroyProgress || ar->arWmiReady == false || ar->arWlanState == WLAN_DISABLED)
4086
4158
    {
4087
4159
        pIwStats->status = 0;
4088
4160
        pIwStats->qual.qual = 0;
4132
4204
            break;
4133
4205
        }
4134
4206
    
4135
 
        ar->statsUpdatePending = TRUE;
 
4207
        ar->statsUpdatePending = true;
4136
4208
    
4137
 
        if(wmi_get_stats_cmd(ar->arWmi) != A_OK) {
 
4209
        if(wmi_get_stats_cmd(ar->arWmi) != 0) {
4138
4210
            break;
4139
4211
        }
4140
4212
    
4141
 
        wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == FALSE, wmitimeout * HZ);
 
4213
        wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
4142
4214
        if (signal_pending(current)) {
4143
4215
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000 : WMI get stats timeout \n"));
4144
4216
            break;
4162
4234
}
4163
4235
 
4164
4236
void
4165
 
ar6000_ready_event(void *devt, A_UINT8 *datap, A_UINT8 phyCap, A_UINT32 sw_ver, A_UINT32 abi_ver)
 
4237
ar6000_ready_event(void *devt, u8 *datap, u8 phyCap, u32 sw_ver, u32 abi_ver)
4166
4238
{
4167
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
 
4239
    struct ar6_softc *ar = (struct ar6_softc *)devt;
4168
4240
    struct net_device *dev = ar->arNetDev;
4169
4241
 
4170
 
    A_MEMCPY(dev->dev_addr, datap, AR6000_ETH_ADDR_LEN);
 
4242
    memcpy(dev->dev_addr, datap, AR6000_ETH_ADDR_LEN);
4171
4243
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("mac address = %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
4172
4244
        dev->dev_addr[0], dev->dev_addr[1],
4173
4245
        dev->dev_addr[2], dev->dev_addr[3],
4178
4250
    ar->arVersion.abi_ver = abi_ver;
4179
4251
 
4180
4252
    /* Indicate to the waiting thread that the ready event was received */
4181
 
    ar->arWmiReady = TRUE;
 
4253
    ar->arWmiReady = true;
4182
4254
    wake_up(&arEvent);
4183
 
 
4184
 
#if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
4185
 
    wmi_pmparams_cmd(ar->arWmi, 0, 1, 0, 0, 1, IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN);
4186
 
#endif
4187
 
#if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP
4188
 
    wmi_set_lpreamble_cmd(ar->arWmi, 0, WMI_DONOT_IGNORE_BARKER_IN_ERP);
4189
 
#endif
4190
 
    wmi_set_keepalive_cmd(ar->arWmi, WLAN_CONFIG_KEEP_ALIVE_INTERVAL);
4191
 
#if WLAN_CONFIG_DISABLE_11N
4192
 
    {
4193
 
        WMI_SET_HT_CAP_CMD htCap;
4194
 
 
4195
 
        A_MEMZERO(&htCap, sizeof(WMI_SET_HT_CAP_CMD));
4196
 
        htCap.band = 0;
4197
 
        wmi_set_ht_cap_cmd(ar->arWmi, &htCap);
4198
 
 
4199
 
        htCap.band = 1;
4200
 
        wmi_set_ht_cap_cmd(ar->arWmi, &htCap);
4201
 
    }
4202
 
#endif /* WLAN_CONFIG_DISABLE_11N */
4203
 
 
4204
 
#ifdef ATH6K_CONFIG_OTA_MODE
4205
 
    wmi_powermode_cmd(ar->arWmi, MAX_PERF_POWER);
4206
 
#endif
4207
 
    wmi_disctimeout_cmd(ar->arWmi, WLAN_CONFIG_DISCONNECT_TIMEOUT);
4208
4255
}
4209
4256
 
4210
4257
void
4211
 
add_new_sta(AR_SOFTC_T *ar, A_UINT8 *mac, A_UINT16 aid, A_UINT8 *wpaie,
4212
 
            A_UINT8 ielen, A_UINT8 keymgmt, A_UINT8 ucipher, A_UINT8 auth)
 
4258
add_new_sta(struct ar6_softc *ar, u8 *mac, u16 aid, u8 *wpaie,
 
4259
            u8 ielen, u8 keymgmt, u8 ucipher, u8 auth)
4213
4260
{
4214
 
    A_UINT8    free_slot=aid-1;
 
4261
    u8 free_slot=aid-1;
4215
4262
 
4216
 
        A_MEMCPY(ar->sta_list[free_slot].mac, mac, ATH_MAC_LEN);
4217
 
        A_MEMCPY(ar->sta_list[free_slot].wpa_ie, wpaie, ielen);
 
4263
        memcpy(ar->sta_list[free_slot].mac, mac, ATH_MAC_LEN);
 
4264
        memcpy(ar->sta_list[free_slot].wpa_ie, wpaie, ielen);
4218
4265
        ar->sta_list[free_slot].aid = aid;
4219
4266
        ar->sta_list[free_slot].keymgmt = keymgmt;
4220
4267
        ar->sta_list[free_slot].ucipher = ucipher;
4224
4271
}
4225
4272
 
4226
4273
void
4227
 
ar6000_connect_event(AR_SOFTC_T *ar, A_UINT16 channel, A_UINT8 *bssid,
4228
 
                     A_UINT16 listenInterval, A_UINT16 beaconInterval,
4229
 
                     NETWORK_TYPE networkType, A_UINT8 beaconIeLen,
4230
 
                     A_UINT8 assocReqLen, A_UINT8 assocRespLen,
4231
 
                     A_UINT8 *assocInfo)
 
4274
ar6000_connect_event(struct ar6_softc *ar, u16 channel, u8 *bssid,
 
4275
                     u16 listenInterval, u16 beaconInterval,
 
4276
                     NETWORK_TYPE networkType, u8 beaconIeLen,
 
4277
                     u8 assocReqLen, u8 assocRespLen,
 
4278
                     u8 *assocInfo)
4232
4279
{
4233
4280
    union iwreq_data wrqu;
4234
4281
    int i, beacon_ie_pos, assoc_resp_ie_pos, assoc_req_ie_pos;
4237
4284
    static const char *beaconIetag = "BEACONIE=";
4238
4285
    char buf[WMI_CONTROL_MSG_MAX_LEN * 2 + strlen(tag1) + 1];
4239
4286
    char *pos;
4240
 
    A_UINT8 key_op_ctrl;
 
4287
    u8 key_op_ctrl;
4241
4288
    unsigned long flags;
4242
4289
    struct ieee80211req_key *ik;
4243
4290
    CRYPTO_TYPE keyType = NONE_CRYPT;
4244
4291
 
4245
4292
    if(ar->arNetworkType & AP_NETWORK) {
4246
4293
        struct net_device *dev = ar->arNetDev;
4247
 
        if(A_MEMCMP(dev->dev_addr, bssid, ATH_MAC_LEN)==0) {
 
4294
        if(memcmp(dev->dev_addr, bssid, ATH_MAC_LEN)==0) {
4248
4295
            ar->arACS = channel;
4249
4296
            ik = &ar->ap_mode_bkey;
4250
4297
 
4273
4320
                       goto skip_key;
4274
4321
                }
4275
4322
                wmi_addKey_cmd(ar->arWmi, ik->ik_keyix, keyType, GROUP_USAGE,
4276
 
                                ik->ik_keylen, (A_UINT8 *)&ik->ik_keyrsc,
 
4323
                                ik->ik_keylen, (u8 *)&ik->ik_keyrsc,
4277
4324
                                ik->ik_keydata, KEY_OP_INIT_VAL, ik->ik_macaddr,
4278
4325
                                SYNC_BOTH_WMIFLAG);
4279
4326
 
4280
4327
                break;
4281
4328
            }
4282
4329
skip_key:
4283
 
            ar->arConnected  = TRUE;
 
4330
            ar->arConnected  = true;
4284
4331
            return;
4285
4332
        }
4286
4333
 
4336
4383
 
4337
4384
        /* Send event to application */
4338
4385
        A_MEMZERO(&wrqu, sizeof(wrqu));
4339
 
        A_MEMCPY(wrqu.addr.sa_data, bssid, ATH_MAC_LEN);
 
4386
        memcpy(wrqu.addr.sa_data, bssid, ATH_MAC_LEN);
4340
4387
        wireless_send_event(ar->arNetDev, IWEVREGISTERED, &wrqu, NULL);
4341
4388
        /* In case the queue is stopped when we switch modes, this will
4342
4389
         * wake it up
4353
4400
                                assocInfo);
4354
4401
#endif /* ATH6K_CONFIG_CFG80211 */
4355
4402
 
4356
 
    A_MEMCPY(ar->arBssid, bssid, sizeof(ar->arBssid));
 
4403
    memcpy(ar->arBssid, bssid, sizeof(ar->arBssid));
4357
4404
    ar->arBssChannel = channel;
4358
4405
 
4359
4406
    A_PRINTF("AR6000 connected event on freq %d ", channel);
4400
4447
    if (assocRespLen && (sizeof(buf) > (12 + (assocRespLen * 2))))
4401
4448
    {
4402
4449
        assoc_resp_ie_pos = beaconIeLen + assocReqLen +
4403
 
                            sizeof(A_UINT16)  +  /* capinfo*/
4404
 
                            sizeof(A_UINT16)  +  /* status Code */
4405
 
                            sizeof(A_UINT16)  ;  /* associd */
 
4450
                            sizeof(u16)  +  /* capinfo*/
 
4451
                            sizeof(u16)  +  /* status Code */
 
4452
                            sizeof(u16)  ;  /* associd */
4406
4453
        A_MEMZERO(buf, sizeof(buf));
4407
4454
        sprintf(buf, "%s", tag2);
4408
4455
        pos = buf + 12;
4429
4476
         * assoc Request includes capability and listen interval. Skip these.
4430
4477
         */
4431
4478
        assoc_req_ie_pos =  beaconIeLen +
4432
 
                            sizeof(A_UINT16)  +  /* capinfo*/
4433
 
                            sizeof(A_UINT16);    /* listen interval */
 
4479
                            sizeof(u16)  +  /* capinfo*/
 
4480
                            sizeof(u16);    /* listen interval */
4434
4481
 
4435
4482
        A_MEMZERO(buf, sizeof(buf));
4436
4483
        sprintf(buf, "%s", tag1);
4450
4497
 
4451
4498
#ifdef USER_KEYS
4452
4499
    if (ar->user_savedkeys_stat == USER_SAVEDKEYS_STAT_RUN &&
4453
 
        ar->user_saved_keys.keyOk == TRUE)
 
4500
        ar->user_saved_keys.keyOk == true)
4454
4501
    {
4455
4502
        key_op_ctrl = KEY_OP_VALID_MASK & ~KEY_OP_INIT_TSC;
4456
4503
 
4487
4534
 
4488
4535
    /* Update connect & link status atomically */
4489
4536
    spin_lock_irqsave(&ar->arLock, flags);
4490
 
    ar->arConnected  = TRUE;
4491
 
    ar->arConnectPending = FALSE;
 
4537
    ar->arConnected  = true;
 
4538
    ar->arConnectPending = false;
4492
4539
    netif_carrier_on(ar->arNetDev);
4493
4540
    spin_unlock_irqrestore(&ar->arLock, flags);
4494
4541
    /* reset the rx aggr state */
4496
4543
    reconnect_flag = 0;
4497
4544
 
4498
4545
    A_MEMZERO(&wrqu, sizeof(wrqu));
4499
 
    A_MEMCPY(wrqu.addr.sa_data, bssid, IEEE80211_ADDR_LEN);
 
4546
    memcpy(wrqu.addr.sa_data, bssid, IEEE80211_ADDR_LEN);
4500
4547
    wrqu.addr.sa_family = ARPHRD_ETHER;
4501
4548
    wireless_send_event(ar->arNetDev, SIOCGIWAP, &wrqu, NULL);
4502
4549
    if ((ar->arNetworkType == ADHOC_NETWORK) && ar->arIbssPsEnable) {
4510
4557
 
4511
4558
}
4512
4559
 
4513
 
void ar6000_set_numdataendpts(AR_SOFTC_T *ar, A_UINT32 num)
 
4560
void ar6000_set_numdataendpts(struct ar6_softc *ar, u32 num)
4514
4561
{
4515
4562
    A_ASSERT(num <= (HTC_MAILBOX_NUM_MAX - 1));
4516
4563
    ar->arNumDataEndPts = num;
4517
4564
}
4518
4565
 
4519
4566
void
4520
 
sta_cleanup(AR_SOFTC_T *ar, A_UINT8 i)
 
4567
sta_cleanup(struct ar6_softc *ar, u8 i)
4521
4568
{
4522
4569
    struct sk_buff *skb;
4523
4570
 
4540
4587
 
4541
4588
}
4542
4589
 
4543
 
A_UINT8
4544
 
remove_sta(AR_SOFTC_T *ar, A_UINT8 *mac, A_UINT16 reason)
 
4590
u8 remove_sta(struct ar6_softc *ar, u8 *mac, u16 reason)
4545
4591
{
4546
 
    A_UINT8 i, removed=0;
 
4592
    u8 i, removed=0;
4547
4593
 
4548
4594
    if(IS_MAC_NULL(mac)) {
4549
4595
        return removed;
4559
4605
        }
4560
4606
    } else {
4561
4607
        for(i=0; i < AP_MAX_NUM_STA; i++) {
4562
 
            if(A_MEMCMP(ar->sta_list[i].mac, mac, ATH_MAC_LEN)==0) {
 
4608
            if(memcmp(ar->sta_list[i].mac, mac, ATH_MAC_LEN)==0) {
4563
4609
                A_PRINTF("DEL STA %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
4564
4610
                " aid=%d REASON=%d\n", mac[0], mac[1], mac[2],
4565
4611
                 mac[3], mac[4], mac[5], ar->sta_list[i].aid, reason);
4574
4620
}
4575
4621
 
4576
4622
void
4577
 
ar6000_disconnect_event(AR_SOFTC_T *ar, A_UINT8 reason, A_UINT8 *bssid,
4578
 
                        A_UINT8 assocRespLen, A_UINT8 *assocInfo, A_UINT16 protocolReasonStatus)
 
4623
ar6000_disconnect_event(struct ar6_softc *ar, u8 reason, u8 *bssid,
 
4624
                        u8 assocRespLen, u8 *assocInfo, u16 protocolReasonStatus)
4579
4625
{
4580
 
    A_UINT8 i;
 
4626
    u8 i;
4581
4627
    unsigned long flags;
4582
4628
    union iwreq_data wrqu;
4583
4629
 
4607
4653
        if(!IS_MAC_BCAST(bssid)) {
4608
4654
            /* Send event to application */
4609
4655
            A_MEMZERO(&wrqu, sizeof(wrqu));
4610
 
            A_MEMCPY(wrqu.addr.sa_data, bssid, ATH_MAC_LEN);
 
4656
            memcpy(wrqu.addr.sa_data, bssid, ATH_MAC_LEN);
4611
4657
            wireless_send_event(ar->arNetDev, IWEVEXPIRED, &wrqu, NULL);
4612
4658
        }
 
4659
 
 
4660
        ar->arConnected = false;
4613
4661
        return;
4614
4662
    }
4615
4663
 
4654
4702
     */
4655
4703
    if( reason == DISCONNECT_CMD)
4656
4704
    {
4657
 
        ar->arConnectPending = FALSE;
4658
4705
        if ((!ar->arUserBssFilter) && (ar->arWmiReady)) {
4659
4706
            wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0);
4660
4707
        }
4661
4708
    } else {
4662
 
        ar->arConnectPending = TRUE;
 
4709
        ar->arConnectPending = true;
4663
4710
        if (((reason == ASSOC_FAILED) && (protocolReasonStatus == 0x11)) ||
4664
4711
            ((reason == ASSOC_FAILED) && (protocolReasonStatus == 0x0) && (reconnect_flag == 1))) {
4665
 
            ar->arConnected = TRUE;
 
4712
            ar->arConnected = true;
4666
4713
            return;
4667
4714
        }
4668
4715
    }
4684
4731
             * Find the nodes based on SSID and remove it
4685
4732
             * NOTE :: This case will not work out for Hidden-SSID
4686
4733
             */
4687
 
            pWmiSsidnode = wmi_find_Ssidnode (ar->arWmi, ar->arSsid, ar->arSsidLen, FALSE, TRUE);
 
4734
            pWmiSsidnode = wmi_find_Ssidnode (ar->arWmi, ar->arSsid, ar->arSsidLen, false, true);
4688
4735
 
4689
4736
            if (pWmiSsidnode)
4690
4737
            {
4696
4743
 
4697
4744
    /* Update connect & link status atomically */
4698
4745
    spin_lock_irqsave(&ar->arLock, flags);
4699
 
    ar->arConnected = FALSE;
 
4746
    ar->arConnected = false;
4700
4747
    netif_carrier_off(ar->arNetDev);
4701
4748
    spin_unlock_irqrestore(&ar->arLock, flags);
4702
4749
 
4721
4768
}
4722
4769
 
4723
4770
void
4724
 
ar6000_regDomain_event(AR_SOFTC_T *ar, A_UINT32 regCode)
 
4771
ar6000_regDomain_event(struct ar6_softc *ar, u32 regCode)
4725
4772
{
4726
4773
    A_PRINTF("AR6000 Reg Code = 0x%x\n", regCode);
4727
4774
    ar->arRegCode = regCode;
4729
4776
 
4730
4777
#ifdef ATH_AR6K_11N_SUPPORT
4731
4778
void
4732
 
ar6000_aggr_rcv_addba_req_evt(AR_SOFTC_T *ar, WMI_ADDBA_REQ_EVENT *evt)
 
4779
ar6000_aggr_rcv_addba_req_evt(struct ar6_softc *ar, WMI_ADDBA_REQ_EVENT *evt)
4733
4780
{
4734
4781
    if(evt->status == 0) {
4735
4782
        aggr_recv_addba_req_evt(ar->aggr_cntxt, evt->tid, evt->st_seq_no, evt->win_sz);
4737
4784
}
4738
4785
 
4739
4786
void
4740
 
ar6000_aggr_rcv_addba_resp_evt(AR_SOFTC_T *ar, WMI_ADDBA_RESP_EVENT *evt)
 
4787
ar6000_aggr_rcv_addba_resp_evt(struct ar6_softc *ar, WMI_ADDBA_RESP_EVENT *evt)
4741
4788
{
4742
4789
    A_PRINTF("ADDBA RESP. tid %d status %d, sz %d\n", evt->tid, evt->status, evt->amsdu_sz);
4743
4790
    if(evt->status == 0) {
4745
4792
}
4746
4793
 
4747
4794
void
4748
 
ar6000_aggr_rcv_delba_req_evt(AR_SOFTC_T *ar, WMI_DELBA_EVENT *evt)
 
4795
ar6000_aggr_rcv_delba_req_evt(struct ar6_softc *ar, WMI_DELBA_EVENT *evt)
4749
4796
{
4750
4797
    aggr_recv_delba_req_evt(ar->aggr_cntxt, evt->tid);
4751
4798
}
4760
4807
ar6000_hci_event_rcv_evt(struct ar6_softc *ar, WMI_HCI_EVENT *cmd)
4761
4808
{
4762
4809
    void *osbuf = NULL;
4763
 
    A_INT8 i;
4764
 
    A_UINT8 size, *buf;
4765
 
    A_STATUS ret = A_OK;
 
4810
    s8 i;
 
4811
    u8 size, *buf;
 
4812
    int ret = 0;
4766
4813
 
4767
4814
    size = cmd->evt_buf_sz + 4;
4768
4815
    osbuf = A_NETBUF_ALLOC(size);
4773
4820
    }
4774
4821
 
4775
4822
    A_NETBUF_PUT(osbuf, size);
4776
 
    buf = (A_UINT8 *)A_NETBUF_DATA(osbuf);
 
4823
    buf = (u8 *)A_NETBUF_DATA(osbuf);
4777
4824
    /* First 2-bytes carry HCI event/ACL data type
4778
4825
     * the next 2 are free
4779
4826
     */
4780
4827
    *((short *)buf) = WMI_HCI_EVENT_EVENTID;
4781
4828
    buf += sizeof(int);
4782
 
    A_MEMCPY(buf, cmd->buf, cmd->evt_buf_sz);
 
4829
    memcpy(buf, cmd->buf, cmd->evt_buf_sz);
4783
4830
 
4784
4831
    if(ar6k_pal_config_g.fpar6k_pal_recv_pkt)
4785
4832
    {
4786
4833
      /* pass the cmd packet to PAL driver */
4787
 
      if((*ar6k_pal_config_g.fpar6k_pal_recv_pkt)(ar->hcipal_info, osbuf) == TRUE)
 
4834
      if((*ar6k_pal_config_g.fpar6k_pal_recv_pkt)(ar->hcipal_info, osbuf) == true)
4788
4835
        return;
4789
4836
    }
4790
4837
    ar6000_deliver_frames_to_nw_stack(ar->arNetDev, osbuf);
4802
4849
}
4803
4850
 
4804
4851
void
4805
 
ar6000_neighborReport_event(AR_SOFTC_T *ar, int numAps, WMI_NEIGHBOR_INFO *info)
 
4852
ar6000_neighborReport_event(struct ar6_softc *ar, int numAps, WMI_NEIGHBOR_INFO *info)
4806
4853
{
4807
4854
#if WIRELESS_EXT >= 18
4808
4855
    struct iw_pmkid_cand *pmkcand;
4833
4880
        A_MEMZERO(pmkcand, sizeof(struct iw_pmkid_cand));
4834
4881
        pmkcand->index = i;
4835
4882
        pmkcand->flags = info->bssFlags;
4836
 
        A_MEMCPY(pmkcand->bssid.sa_data, info->bssid, ATH_MAC_LEN);
 
4883
        memcpy(pmkcand->bssid.sa_data, info->bssid, ATH_MAC_LEN);
4837
4884
        wrqu.data.length = sizeof(struct iw_pmkid_cand);
4838
4885
        wireless_send_event(ar->arNetDev, IWEVPMKIDCAND, &wrqu, (char *)pmkcand);
4839
4886
        A_FREE(pmkcand);
4850
4897
}
4851
4898
 
4852
4899
void
4853
 
ar6000_tkip_micerr_event(AR_SOFTC_T *ar, A_UINT8 keyid, A_BOOL ismcast)
 
4900
ar6000_tkip_micerr_event(struct ar6_softc *ar, u8 keyid, bool ismcast)
4854
4901
{
4855
4902
    static const char *tag = "MLME-MICHAELMICFAILURE.indication";
4856
4903
    char buf[128];
4887
4934
}
4888
4935
 
4889
4936
void
4890
 
ar6000_scanComplete_event(AR_SOFTC_T *ar, A_STATUS status)
 
4937
ar6000_scanComplete_event(struct ar6_softc *ar, int status)
4891
4938
{
4892
4939
 
4893
4940
#ifdef ATH6K_CONFIG_CFG80211
4898
4945
        wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0);
4899
4946
    }
4900
4947
    if (ar->scan_triggered) {
4901
 
        if (status==A_OK) {
 
4948
        if (status== 0) {
4902
4949
            union iwreq_data wrqu;
4903
4950
            A_MEMZERO(&wrqu, sizeof(wrqu));
4904
4951
            wireless_send_event(ar->arNetDev, SIOCGIWSCAN, &wrqu, NULL);
4910
4957
}
4911
4958
 
4912
4959
void
4913
 
ar6000_targetStats_event(AR_SOFTC_T *ar,  A_UINT8 *ptr, A_UINT32 len)
 
4960
ar6000_targetStats_event(struct ar6_softc *ar,  u8 *ptr, u32 len)
4914
4961
{
4915
 
    A_UINT8 ac;
 
4962
    u8 ac;
4916
4963
 
4917
4964
    if(ar->arNetworkType == AP_NETWORK) {
4918
4965
        WMI_AP_MODE_STAT *p = (WMI_AP_MODE_STAT *)ptr;
5028
5075
        pStats->arp_replied  += pTarget->arpStats.arp_replied;
5029
5076
 
5030
5077
        if (ar->statsUpdatePending) {
5031
 
            ar->statsUpdatePending = FALSE;
 
5078
            ar->statsUpdatePending = false;
5032
5079
            wake_up(&arEvent);
5033
5080
        }
5034
5081
    }
5035
5082
}
5036
5083
 
5037
5084
void
5038
 
ar6000_rssiThreshold_event(AR_SOFTC_T *ar,  WMI_RSSI_THRESHOLD_VAL newThreshold, A_INT16 rssi)
 
5085
ar6000_rssiThreshold_event(struct ar6_softc *ar,  WMI_RSSI_THRESHOLD_VAL newThreshold, s16 rssi)
5039
5086
{
5040
5087
    USER_RSSI_THOLD userRssiThold;
5041
5088
 
5051
5098
    A_PRINTF("rssi Threshold range = %d tag = %d  rssi = %d\n", newThreshold,
5052
5099
             userRssiThold.tag, userRssiThold.rssi);
5053
5100
 
5054
 
    ar6000_send_event_to_app(ar, WMI_RSSI_THRESHOLD_EVENTID,(A_UINT8 *)&userRssiThold, sizeof(USER_RSSI_THOLD));
 
5101
    ar6000_send_event_to_app(ar, WMI_RSSI_THRESHOLD_EVENTID,(u8 *)&userRssiThold, sizeof(USER_RSSI_THOLD));
5055
5102
}
5056
5103
 
5057
5104
 
5058
5105
void
5059
 
ar6000_hbChallengeResp_event(AR_SOFTC_T *ar, A_UINT32 cookie, A_UINT32 source)
 
5106
ar6000_hbChallengeResp_event(struct ar6_softc *ar, u32 cookie, u32 source)
5060
5107
{
5061
5108
    if (source == APP_HB_CHALLENGE) {
5062
5109
        /* Report it to the app in case it wants a positive acknowledgement */
5063
5110
        ar6000_send_event_to_app(ar, WMIX_HB_CHALLENGE_RESP_EVENTID,
5064
 
                                 (A_UINT8 *)&cookie, sizeof(cookie));
 
5111
                                 (u8 *)&cookie, sizeof(cookie));
5065
5112
    } else {
5066
5113
        /* This would ignore the replys that come in after their due time */
5067
5114
        if (cookie == ar->arHBChallengeResp.seqNum) {
5068
 
            ar->arHBChallengeResp.outstanding = FALSE;
 
5115
            ar->arHBChallengeResp.outstanding = false;
5069
5116
        }
5070
5117
    }
5071
5118
}
5072
5119
 
5073
5120
 
5074
5121
void
5075
 
ar6000_reportError_event(AR_SOFTC_T *ar, WMI_TARGET_ERROR_VAL errorVal)
 
5122
ar6000_reportError_event(struct ar6_softc *ar, WMI_TARGET_ERROR_VAL errorVal)
5076
5123
{
5077
5124
        static const char * const errString[] = {
5078
5125
                [WMI_TARGET_PM_ERR_FAIL]    "WMI_TARGET_PM_ERR_FAIL",
5107
5154
 
5108
5155
 
5109
5156
void
5110
 
ar6000_cac_event(AR_SOFTC_T *ar, A_UINT8 ac, A_UINT8 cacIndication,
5111
 
                 A_UINT8 statusCode, A_UINT8 *tspecSuggestion)
 
5157
ar6000_cac_event(struct ar6_softc *ar, u8 ac, u8 cacIndication,
 
5158
                 u8 statusCode, u8 *tspecSuggestion)
5112
5159
{
5113
5160
    WMM_TSPEC_IE    *tspecIe;
5114
5161
 
5130
5177
}
5131
5178
 
5132
5179
void
5133
 
ar6000_channel_change_event(AR_SOFTC_T *ar, A_UINT16 oldChannel,
5134
 
                            A_UINT16 newChannel)
 
5180
ar6000_channel_change_event(struct ar6_softc *ar, u16 oldChannel,
 
5181
                            u16 newChannel)
5135
5182
{
5136
5183
    A_PRINTF("Channel Change notification\nOld Channel: %d, New Channel: %d\n",
5137
5184
             oldChannel, newChannel);
5144
5191
} while(0)
5145
5192
 
5146
5193
void
5147
 
ar6000_roam_tbl_event(AR_SOFTC_T *ar, WMI_TARGET_ROAM_TBL *pTbl)
 
5194
ar6000_roam_tbl_event(struct ar6_softc *ar, WMI_TARGET_ROAM_TBL *pTbl)
5148
5195
{
5149
 
    A_UINT8 i;
 
5196
    u8 i;
5150
5197
 
5151
5198
    A_PRINTF("ROAM TABLE NO OF ENTRIES is %d ROAM MODE is %d\n",
5152
5199
              pTbl->numEntries, pTbl->roamMode);
5169
5216
}
5170
5217
 
5171
5218
void
5172
 
ar6000_wow_list_event(struct ar6_softc *ar, A_UINT8 num_filters, WMI_GET_WOW_LIST_REPLY *wow_reply)
 
5219
ar6000_wow_list_event(struct ar6_softc *ar, u8 num_filters, WMI_GET_WOW_LIST_REPLY *wow_reply)
5173
5220
{
5174
 
    A_UINT8 i,j;
 
5221
    u8 i,j;
5175
5222
 
5176
5223
    /*Each event now contains exactly one filter, see bug 26613*/
5177
5224
    A_PRINTF("WOW pattern %d of %d patterns\n", wow_reply->this_filter_num,                 wow_reply->num_filters);
5223
5270
}
5224
5271
 
5225
5272
void
5226
 
ar6000_roam_data_event(AR_SOFTC_T *ar, WMI_TARGET_ROAM_DATA *p)
 
5273
ar6000_roam_data_event(struct ar6_softc *ar, WMI_TARGET_ROAM_DATA *p)
5227
5274
{
5228
5275
    switch (p->roamDataType) {
5229
5276
        case ROAM_DATA_TIME:
5235
5282
}
5236
5283
 
5237
5284
void
5238
 
ar6000_bssInfo_event_rx(AR_SOFTC_T *ar, A_UINT8 *datap, int len)
 
5285
ar6000_bssInfo_event_rx(struct ar6_softc *ar, u8 *datap, int len)
5239
5286
{
5240
5287
    struct sk_buff *skb;
5241
5288
    WMI_BSS_INFO_HDR *bih = (WMI_BSS_INFO_HDR *)datap;
5255
5302
    if ((skb = A_NETBUF_ALLOC_RAW(len)) != NULL) {
5256
5303
 
5257
5304
        A_NETBUF_PUT(skb, len);
5258
 
        A_MEMCPY(A_NETBUF_DATA(skb), datap, len);
 
5305
        memcpy(A_NETBUF_DATA(skb), datap, len);
5259
5306
        skb->dev = ar->arNetDev;
5260
 
        A_MEMCPY(skb_mac_header(skb), A_NETBUF_DATA(skb), 6);
 
5307
        memcpy(skb_mac_header(skb), A_NETBUF_DATA(skb), 6);
5261
5308
        skb->ip_summed = CHECKSUM_NONE;
5262
5309
        skb->pkt_type = PACKET_OTHERHOST;
5263
5310
        skb->protocol = __constant_htons(0x0019);
5265
5312
    }
5266
5313
}
5267
5314
 
5268
 
A_UINT32 wmiSendCmdNum;
 
5315
u32 wmiSendCmdNum;
5269
5316
 
5270
 
A_STATUS
 
5317
int
5271
5318
ar6000_control_tx(void *devt, void *osbuf, HTC_ENDPOINT_ID eid)
5272
5319
{
5273
 
    AR_SOFTC_T       *ar = (AR_SOFTC_T *)devt;
5274
 
    A_STATUS         status = A_OK;
 
5320
    struct ar6_softc       *ar = (struct ar6_softc *)devt;
 
5321
    int         status = 0;
5275
5322
    struct ar_cookie *cookie = NULL;
5276
5323
    int i;
5277
5324
#ifdef CONFIG_PM
5306
5353
        if(logWmiRawMsgs) {
5307
5354
            A_PRINTF("WMI cmd send, msgNo %d :", wmiSendCmdNum);
5308
5355
            for(i = 0; i < a_netbuf_to_len(osbuf); i++)
5309
 
                A_PRINTF("%x ", ((A_UINT8 *)a_netbuf_to_data(osbuf))[i]);
 
5356
                A_PRINTF("%x ", ((u8 *)a_netbuf_to_data(osbuf))[i]);
5310
5357
            A_PRINTF("\n");
5311
5358
        }
5312
5359
 
5313
5360
        wmiSendCmdNum++;
5314
5361
 
5315
 
    } while (FALSE);
 
5362
    } while (false);
5316
5363
 
5317
5364
    if (cookie != NULL) {
5318
5365
            /* got a structure to send it out on */
5337
5384
            /* this interface is asynchronous, if there is an error, cleanup will happen in the
5338
5385
             * TX completion callback */
5339
5386
        HTCSendPkt(ar->arHtcTarget, &cookie->HtcPkt);
5340
 
        status = A_OK;
 
5387
        status = 0;
5341
5388
    }
5342
5389
 
5343
 
    if (status != A_OK) {
 
5390
    if (status) {
5344
5391
        A_NETBUF_FREE(osbuf);
5345
5392
    }
5346
5393
    return status;
5347
5394
}
5348
5395
 
5349
5396
/* indicate tx activity or inactivity on a WMI stream */
5350
 
void ar6000_indicate_tx_activity(void *devt, A_UINT8 TrafficClass, A_BOOL Active)
 
5397
void ar6000_indicate_tx_activity(void *devt, u8 TrafficClass, bool Active)
5351
5398
{
5352
 
    AR_SOFTC_T  *ar = (AR_SOFTC_T *)devt;
 
5399
    struct ar6_softc  *ar = (struct ar6_softc *)devt;
5353
5400
    HTC_ENDPOINT_ID eid ;
5354
5401
    int i;
5355
5402
 
5407
5454
}
5408
5455
 
5409
5456
void
5410
 
ar6000_btcoex_config_event(struct ar6_softc *ar,  A_UINT8 *ptr, A_UINT32 len)
 
5457
ar6000_btcoex_config_event(struct ar6_softc *ar,  u8 *ptr, u32 len)
5411
5458
{
5412
5459
 
5413
5460
    WMI_BTCOEX_CONFIG_EVENT *pBtcoexConfig = (WMI_BTCOEX_CONFIG_EVENT *)ptr;
5421
5468
 
5422
5469
    switch (pBtcoexConfig->btProfileType) {
5423
5470
        case WMI_BTCOEX_BT_PROFILE_SCO:
5424
 
            A_MEMCPY(&pArbtcoexConfig->info.scoConfigCmd, &pBtcoexConfig->info.scoConfigCmd,
 
5471
            memcpy(&pArbtcoexConfig->info.scoConfigCmd, &pBtcoexConfig->info.scoConfigCmd,
5425
5472
                                        sizeof(WMI_SET_BTCOEX_SCO_CONFIG_CMD));
5426
5473
            break;
5427
5474
        case WMI_BTCOEX_BT_PROFILE_A2DP:
5428
 
            A_MEMCPY(&pArbtcoexConfig->info.a2dpConfigCmd, &pBtcoexConfig->info.a2dpConfigCmd,
 
5475
            memcpy(&pArbtcoexConfig->info.a2dpConfigCmd, &pBtcoexConfig->info.a2dpConfigCmd,
5429
5476
                                        sizeof(WMI_SET_BTCOEX_A2DP_CONFIG_CMD));
5430
5477
            break;
5431
5478
        case WMI_BTCOEX_BT_PROFILE_ACLCOEX:
5432
 
            A_MEMCPY(&pArbtcoexConfig->info.aclcoexConfig, &pBtcoexConfig->info.aclcoexConfig,
 
5479
            memcpy(&pArbtcoexConfig->info.aclcoexConfig, &pBtcoexConfig->info.aclcoexConfig,
5433
5480
                                        sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD));
5434
5481
            break;
5435
5482
        case WMI_BTCOEX_BT_PROFILE_INQUIRY_PAGE:
5436
 
           A_MEMCPY(&pArbtcoexConfig->info.btinquiryPageConfigCmd, &pBtcoexConfig->info.btinquiryPageConfigCmd,
 
5483
           memcpy(&pArbtcoexConfig->info.btinquiryPageConfigCmd, &pBtcoexConfig->info.btinquiryPageConfigCmd,
5437
5484
                                        sizeof(WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD));
5438
5485
            break;
5439
5486
    }
5440
5487
    if (ar->statsUpdatePending) {
5441
 
         ar->statsUpdatePending = FALSE;
 
5488
         ar->statsUpdatePending = false;
5442
5489
          wake_up(&arEvent);
5443
5490
    }
5444
5491
}
5445
5492
 
5446
5493
void
5447
 
ar6000_btcoex_stats_event(struct ar6_softc *ar,  A_UINT8 *ptr, A_UINT32 len)
 
5494
ar6000_btcoex_stats_event(struct ar6_softc *ar,  u8 *ptr, u32 len)
5448
5495
{
5449
5496
    WMI_BTCOEX_STATS_EVENT *pBtcoexStats = (WMI_BTCOEX_STATS_EVENT *)ptr;
5450
5497
 
5451
5498
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("AR6000 BTCOEX CONFIG EVENT \n"));
5452
5499
 
5453
 
    A_MEMCPY(&ar->arBtcoexStats, pBtcoexStats, sizeof(WMI_BTCOEX_STATS_EVENT));
 
5500
    memcpy(&ar->arBtcoexStats, pBtcoexStats, sizeof(WMI_BTCOEX_STATS_EVENT));
5454
5501
 
5455
5502
    if (ar->statsUpdatePending) {
5456
 
         ar->statsUpdatePending = FALSE;
 
5503
         ar->statsUpdatePending = false;
5457
5504
        wake_up(&arEvent);
5458
5505
    }
5459
5506
 
5463
5510
 
5464
5511
/* Init cookie queue */
5465
5512
static void
5466
 
ar6000_cookie_init(AR_SOFTC_T *ar)
 
5513
ar6000_cookie_init(struct ar6_softc *ar)
5467
5514
{
5468
 
    A_UINT32    i;
 
5515
    u32 i;
5469
5516
 
5470
5517
    ar->arCookieList = NULL;
5471
5518
    ar->arCookieCount = 0;
5479
5526
 
5480
5527
/* cleanup cookie queue */
5481
5528
static void
5482
 
ar6000_cookie_cleanup(AR_SOFTC_T *ar)
 
5529
ar6000_cookie_cleanup(struct ar6_softc *ar)
5483
5530
{
5484
5531
    /* It is gone .... */
5485
5532
    ar->arCookieList = NULL;
5488
5535
 
5489
5536
/* Init cookie queue */
5490
5537
static void
5491
 
ar6000_free_cookie(AR_SOFTC_T *ar, struct ar_cookie * cookie)
 
5538
ar6000_free_cookie(struct ar6_softc *ar, struct ar_cookie * cookie)
5492
5539
{
5493
5540
    /* Insert first */
5494
5541
    A_ASSERT(ar != NULL);
5501
5548
 
5502
5549
/* cleanup cookie queue */
5503
5550
static struct ar_cookie *
5504
 
ar6000_alloc_cookie(AR_SOFTC_T  *ar)
 
5551
ar6000_alloc_cookie(struct ar6_softc  *ar)
5505
5552
{
5506
5553
    struct ar_cookie   *cookie;
5507
5554
 
5522
5569
 * the event ID and event content.
5523
5570
 */
5524
5571
#define EVENT_ID_LEN   2
5525
 
void ar6000_send_event_to_app(AR_SOFTC_T *ar, A_UINT16 eventId,
5526
 
                              A_UINT8 *datap, int len)
 
5572
void ar6000_send_event_to_app(struct ar6_softc *ar, u16 eventId,
 
5573
                              u8 *datap, int len)
5527
5574
{
5528
5575
 
5529
5576
#if (WIRELESS_EXT >= 15)
5531
5578
/* note: IWEVCUSTOM only exists in wireless extensions after version 15 */
5532
5579
 
5533
5580
    char *buf;
5534
 
    A_UINT16 size;
 
5581
    u16 size;
5535
5582
    union iwreq_data wrqu;
5536
5583
 
5537
5584
    size = len + EVENT_ID_LEN;
5549
5596
    }
5550
5597
 
5551
5598
    A_MEMZERO(buf, size);
5552
 
    A_MEMCPY(buf, &eventId, EVENT_ID_LEN);
5553
 
    A_MEMCPY(buf+EVENT_ID_LEN, datap, len);
 
5599
    memcpy(buf, &eventId, EVENT_ID_LEN);
 
5600
    memcpy(buf+EVENT_ID_LEN, datap, len);
5554
5601
 
5555
 
    //AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("event ID = %d,len = %d\n",*(A_UINT16*)buf, size));
 
5602
    //AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("event ID = %d,len = %d\n",*(u16 *)buf, size));
5556
5603
    A_MEMZERO(&wrqu, sizeof(wrqu));
5557
5604
    wrqu.data.length = size;
5558
5605
    wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
5567
5614
 * to the application. The buf which is sent to application
5568
5615
 * includes the event ID and event content.
5569
5616
 */
5570
 
void ar6000_send_generic_event_to_app(AR_SOFTC_T *ar, A_UINT16 eventId,
5571
 
                                      A_UINT8 *datap, int len)
 
5617
void ar6000_send_generic_event_to_app(struct ar6_softc *ar, u16 eventId,
 
5618
                                      u8 *datap, int len)
5572
5619
{
5573
5620
 
5574
5621
#if (WIRELESS_EXT >= 18)
5576
5623
/* IWEVGENIE exists in wireless extensions version 18 onwards */
5577
5624
 
5578
5625
    char *buf;
5579
 
    A_UINT16 size;
 
5626
    u16 size;
5580
5627
    union iwreq_data wrqu;
5581
5628
 
5582
5629
    size = len + EVENT_ID_LEN;
5594
5641
    }
5595
5642
 
5596
5643
    A_MEMZERO(buf, size);
5597
 
    A_MEMCPY(buf, &eventId, EVENT_ID_LEN);
5598
 
    A_MEMCPY(buf+EVENT_ID_LEN, datap, len);
 
5644
    memcpy(buf, &eventId, EVENT_ID_LEN);
 
5645
    memcpy(buf+EVENT_ID_LEN, datap, len);
5599
5646
 
5600
5647
    A_MEMZERO(&wrqu, sizeof(wrqu));
5601
5648
    wrqu.data.length = size;
5616
5663
}
5617
5664
 
5618
5665
void
5619
 
ar6000_snrThresholdEvent_rx(void *devt, WMI_SNR_THRESHOLD_VAL newThreshold, A_UINT8 snr)
 
5666
ar6000_snrThresholdEvent_rx(void *devt, WMI_SNR_THRESHOLD_VAL newThreshold, u8 snr)
5620
5667
{
5621
5668
    WMI_SNR_THRESHOLD_EVENT event;
5622
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
 
5669
    struct ar6_softc *ar = (struct ar6_softc *)devt;
5623
5670
 
5624
5671
    event.range = newThreshold;
5625
5672
    event.snr = snr;
5626
5673
 
5627
 
    ar6000_send_event_to_app(ar, WMI_SNR_THRESHOLD_EVENTID, (A_UINT8 *)&event,
 
5674
    ar6000_send_event_to_app(ar, WMI_SNR_THRESHOLD_EVENTID, (u8 *)&event,
5628
5675
                             sizeof(WMI_SNR_THRESHOLD_EVENT));
5629
5676
}
5630
5677
 
5631
5678
void
5632
 
ar6000_lqThresholdEvent_rx(void *devt, WMI_LQ_THRESHOLD_VAL newThreshold, A_UINT8 lq)
 
5679
ar6000_lqThresholdEvent_rx(void *devt, WMI_LQ_THRESHOLD_VAL newThreshold, u8 lq)
5633
5680
{
5634
5681
    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("lq threshold range %d, lq %d\n", newThreshold, lq));
5635
5682
}
5636
5683
 
5637
5684
 
5638
5685
 
5639
 
A_UINT32
5640
 
a_copy_to_user(void *to, const void *from, A_UINT32 n)
 
5686
u32 a_copy_to_user(void *to, const void *from, u32 n)
5641
5687
{
5642
5688
    return(copy_to_user(to, from, n));
5643
5689
}
5644
5690
 
5645
 
A_UINT32
5646
 
a_copy_from_user(void *to, const void *from, A_UINT32 n)
 
5691
u32 a_copy_from_user(void *to, const void *from, u32 n)
5647
5692
{
5648
5693
    return(copy_from_user(to, from, n));
5649
5694
}
5650
5695
 
5651
5696
 
5652
 
A_STATUS
 
5697
int
5653
5698
ar6000_get_driver_cfg(struct net_device *dev,
5654
 
                        A_UINT16 cfgParam,
 
5699
                        u16 cfgParam,
5655
5700
                        void *result)
5656
5701
{
5657
5702
 
5658
 
    A_STATUS    ret = 0;
 
5703
    int    ret = 0;
5659
5704
 
5660
5705
    switch(cfgParam)
5661
5706
    {
5662
5707
        case AR6000_DRIVER_CFG_GET_WLANNODECACHING:
5663
 
           *((A_UINT32 *)result) = wlanNodeCaching;
 
5708
           *((u32 *)result) = wlanNodeCaching;
5664
5709
           break;
5665
5710
        case AR6000_DRIVER_CFG_LOG_RAW_WMI_MSGS:
5666
 
           *((A_UINT32 *)result) = logWmiRawMsgs;
 
5711
           *((u32 *)result) = logWmiRawMsgs;
5667
5712
            break;
5668
5713
        default:
5669
5714
           ret = EINVAL;
5674
5719
}
5675
5720
 
5676
5721
void
5677
 
ar6000_keepalive_rx(void *devt, A_UINT8 configured)
 
5722
ar6000_keepalive_rx(void *devt, u8 configured)
5678
5723
{
5679
 
    AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;
 
5724
    struct ar6_softc *ar = (struct ar6_softc *)devt;
5680
5725
 
5681
5726
    ar->arKeepaliveConfigured = configured;
5682
5727
    wake_up(&arEvent);
5683
5728
}
5684
5729
 
5685
5730
void
5686
 
ar6000_pmkid_list_event(void *devt, A_UINT8 numPMKID, WMI_PMKID *pmkidList,
5687
 
                        A_UINT8 *bssidList)
 
5731
ar6000_pmkid_list_event(void *devt, u8 numPMKID, WMI_PMKID *pmkidList,
 
5732
                        u8 *bssidList)
5688
5733
{
5689
 
    A_UINT8 i, j;
 
5734
    u8 i, j;
5690
5735
 
5691
5736
    A_PRINTF("Number of Cached PMKIDs is %d\n", numPMKID);
5692
5737
 
5700
5745
            for (j = 0; j < WMI_PMKID_LEN; j++) {
5701
5746
                A_PRINTF("%2.2x", pmkidList->pmkid[j]);
5702
5747
            }
5703
 
        pmkidList = (WMI_PMKID *)((A_UINT8 *)pmkidList + ATH_MAC_LEN +
 
5748
        pmkidList = (WMI_PMKID *)((u8 *)pmkidList + ATH_MAC_LEN +
5704
5749
                                  WMI_PMKID_LEN);
5705
5750
    }
5706
5751
}
5707
5752
 
5708
 
void ar6000_pspoll_event(AR_SOFTC_T *ar,A_UINT8 aid)
 
5753
void ar6000_pspoll_event(struct ar6_softc *ar,u8 aid)
5709
5754
{
5710
5755
    sta_t *conn=NULL;
5711
 
    A_BOOL isPsqEmpty = FALSE;
 
5756
    bool isPsqEmpty = false;
5712
5757
 
5713
5758
    conn = ieee80211_find_conn_for_aid(ar, aid);
5714
5759
 
5745
5790
    }
5746
5791
}
5747
5792
 
5748
 
void ar6000_dtimexpiry_event(AR_SOFTC_T *ar)
 
5793
void ar6000_dtimexpiry_event(struct ar6_softc *ar)
5749
5794
{
5750
 
    A_BOOL isMcastQueued = FALSE;
 
5795
    bool isMcastQueued = false;
5751
5796
    struct sk_buff *skb = NULL;
5752
5797
 
5753
5798
    /* If there are no associated STAs, ignore the DTIM expiry event.
5766
5811
    isMcastQueued = A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq);
5767
5812
    A_MUTEX_UNLOCK(&ar->mcastpsqLock);
5768
5813
 
5769
 
    A_ASSERT(isMcastQueued == FALSE);
 
5814
    A_ASSERT(isMcastQueued == false);
5770
5815
 
5771
5816
    /* Flush the mcast psq to the target */
5772
5817
    /* Set the STA flag to DTIMExpired, so that the frame will go out */
5773
 
    ar->DTIMExpired = TRUE;
 
5818
    ar->DTIMExpired = true;
5774
5819
 
5775
5820
    A_MUTEX_LOCK(&ar->mcastpsqLock);
5776
5821
    while (!A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq)) {
5784
5829
    A_MUTEX_UNLOCK(&ar->mcastpsqLock);
5785
5830
 
5786
5831
    /* Reset the DTIMExpired flag back to 0 */
5787
 
    ar->DTIMExpired = FALSE;
 
5832
    ar->DTIMExpired = false;
5788
5833
 
5789
5834
    /* Clear the LSB of the BitMapCtl field of the TIM IE */
5790
5835
    wmi_set_pvb_cmd(ar->arWmi, MCAST_AID, 0);
5791
5836
}
5792
5837
 
5793
5838
void
5794
 
read_rssi_compensation_param(AR_SOFTC_T *ar)
 
5839
read_rssi_compensation_param(struct ar6_softc *ar)
5795
5840
{
5796
 
    A_UINT8 *cust_data_ptr;
 
5841
    u8 *cust_data_ptr;
5797
5842
 
5798
5843
//#define RSSICOMPENSATION_PRINT
5799
5844
 
5800
5845
#ifdef RSSICOMPENSATION_PRINT
5801
 
    A_INT16 i;
 
5846
    s16 i;
5802
5847
    cust_data_ptr = ar6000_get_cust_data_buffer(ar->arTargetType);
5803
5848
    for (i=0; i<16; i++) {
5804
 
        A_PRINTF("cust_data_%d = %x \n", i, *(A_UINT8 *)cust_data_ptr);
 
5849
        A_PRINTF("cust_data_%d = %x \n", i, *(u8 *)cust_data_ptr);
5805
5850
        cust_data_ptr += 1;
5806
5851
    }
5807
5852
#endif
5808
5853
 
5809
5854
    cust_data_ptr = ar6000_get_cust_data_buffer(ar->arTargetType);
5810
5855
 
5811
 
    rssi_compensation_param.customerID = *(A_UINT16 *)cust_data_ptr & 0xffff;
5812
 
    rssi_compensation_param.enable = *(A_UINT16 *)(cust_data_ptr+2) & 0xffff;
5813
 
    rssi_compensation_param.bg_param_a = *(A_UINT16 *)(cust_data_ptr+4) & 0xffff;
5814
 
    rssi_compensation_param.bg_param_b = *(A_UINT16 *)(cust_data_ptr+6) & 0xffff;
5815
 
    rssi_compensation_param.a_param_a = *(A_UINT16 *)(cust_data_ptr+8) & 0xffff;
5816
 
    rssi_compensation_param.a_param_b = *(A_UINT16 *)(cust_data_ptr+10) &0xffff;
5817
 
    rssi_compensation_param.reserved = *(A_UINT32 *)(cust_data_ptr+12);
 
5856
    rssi_compensation_param.customerID = *(u16 *)cust_data_ptr & 0xffff;
 
5857
    rssi_compensation_param.enable = *(u16 *)(cust_data_ptr+2) & 0xffff;
 
5858
    rssi_compensation_param.bg_param_a = *(u16 *)(cust_data_ptr+4) & 0xffff;
 
5859
    rssi_compensation_param.bg_param_b = *(u16 *)(cust_data_ptr+6) & 0xffff;
 
5860
    rssi_compensation_param.a_param_a = *(u16 *)(cust_data_ptr+8) & 0xffff;
 
5861
    rssi_compensation_param.a_param_b = *(u16 *)(cust_data_ptr+10) &0xffff;
 
5862
    rssi_compensation_param.reserved = *(u32 *)(cust_data_ptr+12);
5818
5863
 
5819
5864
#ifdef RSSICOMPENSATION_PRINT
5820
5865
    A_PRINTF("customerID = 0x%x \n", rssi_compensation_param.customerID);
5833
5878
   return;
5834
5879
}
5835
5880
 
5836
 
A_INT32
5837
 
rssi_compensation_calc_tcmd(A_UINT32 freq, A_INT32 rssi, A_UINT32 totalPkt)
 
5881
s32 rssi_compensation_calc_tcmd(u32 freq, s32 rssi, u32 totalPkt)
5838
5882
{
5839
5883
 
5840
5884
    if (freq > 5000)
5863
5907
    return rssi;
5864
5908
}
5865
5909
 
5866
 
A_INT16
5867
 
rssi_compensation_calc(AR_SOFTC_T *ar, A_INT16 rssi)
 
5910
s16 rssi_compensation_calc(struct ar6_softc *ar, s16 rssi)
5868
5911
{
5869
5912
    if (ar->arBssChannel > 5000)
5870
5913
    {
5892
5935
    return rssi;
5893
5936
}
5894
5937
 
5895
 
A_INT16
5896
 
rssi_compensation_reverse_calc(AR_SOFTC_T *ar, A_INT16 rssi, A_BOOL Above)
 
5938
s16 rssi_compensation_reverse_calc(struct ar6_softc *ar, s16 rssi, bool Above)
5897
5939
{
5898
 
    A_INT16 i;
 
5940
    s16 i;
5899
5941
 
5900
5942
    if (ar->arBssChannel > 5000)
5901
5943
    {
5938
5980
}
5939
5981
 
5940
5982
#ifdef WAPI_ENABLE
5941
 
void ap_wapi_rekey_event(AR_SOFTC_T *ar, A_UINT8 type, A_UINT8 *mac)
 
5983
void ap_wapi_rekey_event(struct ar6_softc *ar, u8 type, u8 *mac)
5942
5984
{
5943
5985
    union iwreq_data wrqu;
5944
 
    A_CHAR buf[20];
 
5986
    char buf[20];
5945
5987
 
5946
5988
    A_MEMZERO(buf, sizeof(buf));
5947
5989
 
5948
5990
    strcpy(buf, "WAPI_REKEY");
5949
5991
    buf[10] = type;
5950
 
    A_MEMCPY(&buf[11], mac, ATH_MAC_LEN);
 
5992
    memcpy(&buf[11], mac, ATH_MAC_LEN);
5951
5993
 
5952
5994
    A_MEMZERO(&wrqu, sizeof(wrqu));
5953
5995
    wrqu.data.length = 10+1+ATH_MAC_LEN;
5958
6000
#endif
5959
6001
 
5960
6002
#ifdef USER_KEYS
5961
 
static A_STATUS
 
6003
static int
5962
6004
 
5963
 
ar6000_reinstall_keys(AR_SOFTC_T *ar, A_UINT8 key_op_ctrl)
 
6005
ar6000_reinstall_keys(struct ar6_softc *ar, u8 key_op_ctrl)
5964
6006
{
5965
 
    A_STATUS status = A_OK;
 
6007
    int status = 0;
5966
6008
    struct ieee80211req_key *uik = &ar->user_saved_keys.ucast_ik;
5967
6009
    struct ieee80211req_key *bik = &ar->user_saved_keys.bcast_ik;
5968
6010
    CRYPTO_TYPE  keyType = ar->user_saved_keys.keyType;
5975
6017
        if (uik->ik_keylen) {
5976
6018
            status = wmi_addKey_cmd(ar->arWmi, uik->ik_keyix,
5977
6019
                    ar->user_saved_keys.keyType, PAIRWISE_USAGE,
5978
 
                    uik->ik_keylen, (A_UINT8 *)&uik->ik_keyrsc,
 
6020
                    uik->ik_keylen, (u8 *)&uik->ik_keyrsc,
5979
6021
                    uik->ik_keydata, key_op_ctrl, uik->ik_macaddr, SYNC_BEFORE_WMIFLAG);
5980
6022
        }
5981
6023
 
5991
6033
        if (bik->ik_keylen) {
5992
6034
            status = wmi_addKey_cmd(ar->arWmi, bik->ik_keyix,
5993
6035
                    ar->user_saved_keys.keyType, GROUP_USAGE,
5994
 
                    bik->ik_keylen, (A_UINT8 *)&bik->ik_keyrsc,
 
6036
                    bik->ik_keylen, (u8 *)&bik->ik_keyrsc,
5995
6037
                    bik->ik_keydata, key_op_ctrl, bik->ik_macaddr, NO_SYNC_WMIFLAG);
5996
6038
        }
5997
6039
    } else {
6010
6052
void
6011
6053
ar6000_dset_open_req(
6012
6054
    void *context,
6013
 
    A_UINT32 id,
6014
 
    A_UINT32 targHandle,
6015
 
    A_UINT32 targReplyFn,
6016
 
    A_UINT32 targReplyArg)
 
6055
    u32 id,
 
6056
    u32 targHandle,
 
6057
    u32 targReplyFn,
 
6058
    u32 targReplyArg)
6017
6059
{
6018
6060
}
6019
6061
 
6020
6062
void
6021
6063
ar6000_dset_close(
6022
6064
    void *context,
6023
 
    A_UINT32 access_cookie)
 
6065
    u32 access_cookie)
6024
6066
{
6025
6067
    return;
6026
6068
}
6028
6070
void
6029
6071
ar6000_dset_data_req(
6030
6072
   void *context,
6031
 
   A_UINT32 accessCookie,
6032
 
   A_UINT32 offset,
6033
 
   A_UINT32 length,
6034
 
   A_UINT32 targBuf,
6035
 
   A_UINT32 targReplyFn,
6036
 
   A_UINT32 targReplyArg)
 
6073
   u32 accessCookie,
 
6074
   u32 offset,
 
6075
   u32 length,
 
6076
   u32 targBuf,
 
6077
   u32 targReplyFn,
 
6078
   u32 targReplyArg)
6037
6079
{
6038
6080
}
6039
6081
 
6079
6121
 
6080
6122
    A_MEMZERO(&p,sizeof(p));
6081
6123
    p.ssidLength = ar->arSsidLen;
6082
 
    A_MEMCPY(p.ssid,ar->arSsid,p.ssidLength);
 
6124
    memcpy(p.ssid,ar->arSsid,p.ssidLength);
6083
6125
    p.channel = ar->arChannelHint;
6084
6126
    p.networkType = ar->arNetworkType;
6085
6127
 
6091
6133
    p.groupCryptoLen = ar->arGroupCryptoLen;
6092
6134
    p.ctrl_flags = ar->arConnectCtrlFlags;
6093
6135
 
6094
 
    ar->arConnected = FALSE;
6095
 
 
6096
6136
    wmi_ap_profile_commit(ar->arWmi, &p);
6097
6137
    spin_lock_irqsave(&ar->arLock, flags);
6098
 
    ar->arConnected  = TRUE;
 
6138
    ar->arConnected  = true;
6099
6139
    netif_carrier_on(ar->arNetDev);
6100
6140
    spin_unlock_irqrestore(&ar->arLock, flags);
6101
6141
    ar->ap_profile_flag = 0;
6102
6142
    return 0;
6103
6143
}
6104
6144
 
6105
 
A_STATUS
 
6145
int
6106
6146
ar6000_connect_to_ap(struct ar6_softc *ar)
6107
6147
{
6108
6148
    /* The ssid length check prevents second "essid off" from the user,
6109
6149
       to be treated as a connect cmd. The second "essid off" is ignored.
6110
6150
    */
6111
 
    if((ar->arWmiReady == TRUE) && (ar->arSsidLen > 0) && ar->arNetworkType!=AP_NETWORK)
 
6151
    if((ar->arWmiReady == true) && (ar->arSsidLen > 0) && ar->arNetworkType!=AP_NETWORK)
6112
6152
    {
6113
 
        A_STATUS status;
 
6153
        int status;
6114
6154
        if((ADHOC_NETWORK != ar->arNetworkType) &&
6115
6155
           (NONE_AUTH==ar->arAuthMode)          &&
6116
6156
           (WEP_CRYPT==ar->arPairwiseCrypto)) {
6118
6158
        }
6119
6159
 
6120
6160
        if (!ar->arUserBssFilter) {
6121
 
            if (wmi_bssfilter_cmd(ar->arWmi, ALL_BSS_FILTER, 0) != A_OK) {
 
6161
            if (wmi_bssfilter_cmd(ar->arWmi, ALL_BSS_FILTER, 0) != 0) {
6122
6162
                return -EIO;
6123
6163
            }
6124
6164
        }
6142
6182
        /* Set the listen interval into 1000TUs or more. This value will be indicated to Ap in the conn.
6143
6183
           later set it back locally at the STA to 100/1000 TUs depending on the power mode */
6144
6184
        if ((ar->arNetworkType == INFRA_NETWORK)) {
6145
 
            wmi_listeninterval_cmd(ar->arWmi, max(ar->arListenIntervalT, (A_UINT16)A_MAX_WOW_LISTEN_INTERVAL), 0);
 
6185
            wmi_listeninterval_cmd(ar->arWmi, max(ar->arListenIntervalT, (u16)A_MAX_WOW_LISTEN_INTERVAL), 0);
6146
6186
        }
6147
6187
        status = wmi_connect_cmd(ar->arWmi, ar->arNetworkType,
6148
6188
                                 ar->arDot11AuthMode, ar->arAuthMode,
6151
6191
                                 ar->arSsidLen, ar->arSsid,
6152
6192
                                 ar->arReqBssid, ar->arChannelHint,
6153
6193
                                 ar->arConnectCtrlFlags);
6154
 
        if (status != A_OK) {
 
6194
        if (status) {
6155
6195
            wmi_listeninterval_cmd(ar->arWmi, ar->arListenIntervalT, ar->arListenIntervalB);
6156
6196
            if (!ar->arUserBssFilter) {
6157
6197
                wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0);
6167
6207
 
6168
6208
        ar->arConnectCtrlFlags &= ~CONNECT_DO_WPA_OFFLOAD;
6169
6209
        
6170
 
        ar->arConnectPending = TRUE;
 
6210
        ar->arConnectPending = true;
6171
6211
        return status;    
6172
6212
    }
6173
6213
    return A_ERROR;
6174
6214
}
6175
6215
 
6176
 
A_STATUS
 
6216
int
 
6217
ar6000_disconnect(struct ar6_softc *ar)
 
6218
{
 
6219
    if ((ar->arConnected == true) || (ar->arConnectPending == true)) {
 
6220
        wmi_disconnect_cmd(ar->arWmi);
 
6221
        /* 
 
6222
         * Disconnect cmd is issued, clear connectPending.
 
6223
         * arConnected will be cleard in disconnect_event notification.
 
6224
         */
 
6225
        ar->arConnectPending = false;
 
6226
    }
 
6227
 
 
6228
    return 0;
 
6229
}
 
6230
 
 
6231
int
6177
6232
ar6000_ap_mode_get_wpa_ie(struct ar6_softc *ar, struct ieee80211req_wpaie *wpaie)
6178
6233
{
6179
6234
    sta_t *conn = NULL;
6183
6238
    A_MEMZERO(wpaie->rsn_ie, IEEE80211_MAX_IE);
6184
6239
 
6185
6240
    if(conn) {
6186
 
        A_MEMCPY(wpaie->wpa_ie, conn->wpa_ie, IEEE80211_MAX_IE);
 
6241
        memcpy(wpaie->wpa_ie, conn->wpa_ie, IEEE80211_MAX_IE);
6187
6242
    }
6188
6243
 
6189
6244
    return 0;
6190
6245
}
6191
6246
 
6192
 
A_STATUS
6193
 
is_iwioctl_allowed(A_UINT8 mode, A_UINT16 cmd)
 
6247
int
 
6248
is_iwioctl_allowed(u8 mode, u16 cmd)
6194
6249
{
6195
6250
    if(cmd >= SIOCSIWCOMMIT && cmd <= SIOCGIWPOWER) {
6196
6251
        cmd -= SIOCSIWCOMMIT;
6197
 
        if(sioctl_filter[cmd] == 0xFF) return A_OK;
6198
 
        if(sioctl_filter[cmd] & mode) return A_OK;
 
6252
        if(sioctl_filter[cmd] == 0xFF) return 0;
 
6253
        if(sioctl_filter[cmd] & mode) return 0;
6199
6254
    } else if(cmd >= SIOCIWFIRSTPRIV && cmd <= (SIOCIWFIRSTPRIV+30)) {
6200
6255
        cmd -= SIOCIWFIRSTPRIV;
6201
 
        if(pioctl_filter[cmd] == 0xFF) return A_OK;
6202
 
        if(pioctl_filter[cmd] & mode) return A_OK;
 
6256
        if(pioctl_filter[cmd] == 0xFF) return 0;
 
6257
        if(pioctl_filter[cmd] & mode) return 0;
6203
6258
    } else {
6204
6259
        return A_ERROR;
6205
6260
    }
6206
6261
    return A_ENOTSUP;
6207
6262
}
6208
6263
 
6209
 
A_STATUS
6210
 
is_xioctl_allowed(A_UINT8 mode, int cmd)
 
6264
int
 
6265
is_xioctl_allowed(u8 mode, int cmd)
6211
6266
{
6212
6267
    if(sizeof(xioctl_filter)-1 < cmd) {
6213
6268
        A_PRINTF("Filter for this cmd=%d not defined\n",cmd);
6214
6269
        return 0;
6215
6270
    }
6216
 
    if(xioctl_filter[cmd] == 0xFF) return A_OK;
6217
 
    if(xioctl_filter[cmd] & mode) return A_OK;
 
6271
    if(xioctl_filter[cmd] == 0xFF) return 0;
 
6272
    if(xioctl_filter[cmd] & mode) return 0;
6218
6273
    return A_ERROR;
6219
6274
}
6220
6275
 
6224
6279
{
6225
6280
    struct ieee80211req_key *ik = (struct ieee80211req_key *)ikey;
6226
6281
    KEY_USAGE   keyUsage = 0;
6227
 
    A_STATUS    status;
 
6282
    int    status;
6228
6283
 
6229
 
    if (A_MEMCMP(ik->ik_macaddr, bcast_mac, IEEE80211_ADDR_LEN) == 0) {
 
6284
    if (memcmp(ik->ik_macaddr, bcast_mac, IEEE80211_ADDR_LEN) == 0) {
6230
6285
        keyUsage = GROUP_USAGE;
6231
6286
    } else {
6232
6287
        keyUsage = PAIRWISE_USAGE;
6236
6291
        ik->ik_keylen);
6237
6292
 
6238
6293
    status = wmi_addKey_cmd(ar->arWmi, ik->ik_keyix, WAPI_CRYPT, keyUsage,
6239
 
                            ik->ik_keylen, (A_UINT8 *)&ik->ik_keyrsc,
 
6294
                            ik->ik_keylen, (u8 *)&ik->ik_keyrsc,
6240
6295
                            ik->ik_keydata, KEY_OP_INIT_VAL, ik->ik_macaddr,
6241
6296
                            SYNC_BOTH_WMIFLAG);
6242
6297
 
6243
 
    if (A_OK != status) {
 
6298
    if (0 != status) {
6244
6299
        return -EIO;
6245
6300
    }
6246
6301
    return 0;
6249
6304
 
6250
6305
void ar6000_peer_event(
6251
6306
    void *context,
6252
 
    A_UINT8 eventCode,
6253
 
    A_UINT8 *macAddr)
 
6307
    u8 eventCode,
 
6308
    u8 *macAddr)
6254
6309
{
6255
 
    A_UINT8 pos;
 
6310
    u8 pos;
6256
6311
 
6257
6312
    for (pos=0;pos<6;pos++)
6258
6313
        printk("%02x: ",*(macAddr+pos));
6261
6316
 
6262
6317
#ifdef HTC_TEST_SEND_PKTS
6263
6318
#define HTC_TEST_DUPLICATE 8
6264
 
static void DoHTCSendPktsTest(AR_SOFTC_T *ar, int MapNo, HTC_ENDPOINT_ID eid, struct sk_buff *dupskb)
 
6319
static void DoHTCSendPktsTest(struct ar6_softc *ar, int MapNo, HTC_ENDPOINT_ID eid, struct sk_buff *dupskb)
6265
6320
{
6266
6321
    struct ar_cookie *cookie;
6267
6322
    struct ar_cookie *cookieArray[HTC_TEST_DUPLICATE];
6268
6323
    struct sk_buff   *new_skb;
6269
6324
    int    i;
6270
6325
    int    pkts = 0;
6271
 
    HTC_PACKET_QUEUE pktQueue;
 
6326
    struct htc_packet_queue pktQueue;
6272
6327
    EPPING_HEADER    *eppingHdr;
6273
6328
 
6274
6329
    eppingHdr = A_NETBUF_DATA(dupskb);
6338
6393
/*
6339
6394
 * Add support for adding and removing a virtual adapter for soft AP.
6340
6395
 * Some OS requires different adapters names for station and soft AP mode.
6341
 
 * To support these requirement, create and destory a netdevice  instance
 
6396
 * To support these requirement, create and destroy a netdevice  instance
6342
6397
 * when the AP mode is operational. A full fledged support for virual device
6343
6398
 * is not implemented. Rather a virtual interface is created and is linked
6344
6399
 * with the existing physical device instance during the operation of the 
6345
6400
 * AP mode.
6346
6401
 */
6347
6402
 
6348
 
A_STATUS ar6000_start_ap_interface(AR_SOFTC_T *ar)
 
6403
int ar6000_start_ap_interface(struct ar6_softc *ar)
6349
6404
{
6350
 
    AR_VIRTUAL_INTERFACE_T *arApDev;
 
6405
    struct ar_virtual_interface *arApDev;
6351
6406
 
6352
6407
    /* Change net_device to point to AP instance */
6353
 
    arApDev = (AR_VIRTUAL_INTERFACE_T *)ar->arApDev;
 
6408
    arApDev = (struct ar_virtual_interface *)ar->arApDev;
6354
6409
    ar->arNetDev = arApDev->arNetDev;
6355
6410
 
6356
 
    return A_OK;
 
6411
    return 0;
6357
6412
}
6358
6413
 
6359
 
A_STATUS ar6000_stop_ap_interface(AR_SOFTC_T *ar)
 
6414
int ar6000_stop_ap_interface(struct ar6_softc *ar)
6360
6415
{
6361
 
    AR_VIRTUAL_INTERFACE_T *arApDev;
 
6416
    struct ar_virtual_interface *arApDev;
6362
6417
 
6363
6418
    /* Change net_device to point to sta instance */
6364
 
    arApDev = (AR_VIRTUAL_INTERFACE_T *)ar->arApDev;
 
6419
    arApDev = (struct ar_virtual_interface *)ar->arApDev;
6365
6420
    if (arApDev) {
6366
6421
        ar->arNetDev = arApDev->arStaNetDev;
6367
6422
    }
6368
6423
 
6369
 
    return A_OK;
 
6424
    return 0;
6370
6425
}
6371
6426
 
6372
6427
 
6373
 
A_STATUS ar6000_create_ap_interface(AR_SOFTC_T *ar, char *ap_ifname) 
 
6428
int ar6000_create_ap_interface(struct ar6_softc *ar, char *ap_ifname)
6374
6429
{
6375
6430
    struct net_device *dev;
6376
 
    AR_VIRTUAL_INTERFACE_T *arApDev;
 
6431
    struct ar_virtual_interface *arApDev;
6377
6432
 
6378
 
    dev = alloc_etherdev(sizeof(AR_VIRTUAL_INTERFACE_T));
 
6433
    dev = alloc_etherdev(sizeof(struct ar_virtual_interface));
6379
6434
    if (dev == NULL) {
6380
6435
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_create_ap_interface: can't alloc etherdev\n"));
6381
6436
        return A_ERROR;
6398
6453
    arApNetDev = dev;
6399
6454
 
6400
6455
    /* Copy the MAC address */
6401
 
    A_MEMCPY(dev->dev_addr, ar->arNetDev->dev_addr, AR6000_ETH_ADDR_LEN);
 
6456
    memcpy(dev->dev_addr, ar->arNetDev->dev_addr, AR6000_ETH_ADDR_LEN);
6402
6457
 
6403
 
    return A_OK;
 
6458
    return 0;
6404
6459
}
6405
6460
 
6406
 
A_STATUS ar6000_add_ap_interface(AR_SOFTC_T *ar, char *ap_ifname) 
 
6461
int ar6000_add_ap_interface(struct ar6_softc *ar, char *ap_ifname)
6407
6462
{
6408
6463
    /* Interface already added, need not proceed further */
6409
6464
    if (ar->arApDev != NULL) {
6410
6465
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_add_ap_interface: interface already present \n"));
6411
 
        return A_OK;
 
6466
        return 0;
6412
6467
    }
6413
6468
 
6414
 
    if (ar6000_create_ap_interface(ar, ap_ifname) != A_OK) {
 
6469
    if (ar6000_create_ap_interface(ar, ap_ifname) != 0) {
6415
6470
        return A_ERROR;
6416
6471
    }
6417
6472
 
6420
6475
    return ar6000_start_ap_interface(ar);
6421
6476
}
6422
6477
 
6423
 
A_STATUS ar6000_remove_ap_interface(AR_SOFTC_T *ar)
 
6478
int ar6000_remove_ap_interface(struct ar6_softc *ar)
6424
6479
{
6425
6480
    if (arApNetDev) {
6426
6481
        ar6000_stop_ap_interface(ar);
6434
6489
    arApNetDev = NULL;
6435
6490
 
6436
6491
    
6437
 
    return A_OK;
 
6492
    return 0;
6438
6493
}
6439
6494
#endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
6440
6495