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

« back to all changes in this revision

Viewing changes to drivers/staging/brcm80211/brcmfmac/wl_iw.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:
18
18
#include <linux/semaphore.h>
19
19
#include <bcmdefs.h>
20
20
#include <linux/netdevice.h>
21
 
#include <osl.h>
22
21
#include <wlioctl.h>
23
22
 
24
23
#include <bcmutils.h>
25
 
#include <bcmendian.h>
26
 
#include <proto/ethernet.h>
27
24
 
28
25
#include <linux/if_arp.h>
29
26
#include <asm/uaccess.h>
31
28
#include <dngl_stats.h>
32
29
#include <dhd.h>
33
30
#include <dhdioctl.h>
34
 
 
 
31
#include <linux/ieee80211.h>
35
32
typedef const struct si_pub si_t;
36
33
#include <wlioctl.h>
37
34
 
38
 
#include <proto/ethernet.h>
39
35
#include <dngl_stats.h>
40
36
#include <dhd.h>
41
37
 
72
68
 
73
69
#define MAX_WLIW_IOCTL_LEN 1024
74
70
 
75
 
#if defined(IL_BIGENDIAN)
76
 
#include <bcmendian.h>
77
 
#define htod32(i) (bcmswap32(i))
78
 
#define htod16(i) (bcmswap16(i))
79
 
#define dtoh32(i) (bcmswap32(i))
80
 
#define dtoh16(i) (bcmswap16(i))
81
 
#define htodchanspec(i) htod16(i)
82
 
#define dtohchanspec(i) dtoh16(i)
83
 
#else
84
 
#define htod32(i) i
85
 
#define htod16(i) i
86
 
#define dtoh32(i) i
87
 
#define dtoh16(i) i
88
 
#define htodchanspec(i) i
89
 
#define dtohchanspec(i) i
90
 
#endif
91
 
 
92
71
#ifdef CONFIG_WIRELESS_EXT
93
72
 
94
73
extern struct iw_statistics *dhd_get_wireless_stats(struct net_device *dev);
137
116
        int iscan_ex_param_size;
138
117
} iscan_info_t;
139
118
iscan_info_t *g_iscan;
 
119
 
 
120
static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
 
121
 
140
122
static void wl_iw_timerfunc(unsigned long data);
141
123
static void wl_iw_set_event_mask(struct net_device *dev);
142
124
static int wl_iw_iscan(iscan_info_t *iscan, wlc_ssid_t *ssid, u16 action);
158
140
 
159
141
static void swap_key_from_BE(wl_wsec_key_t *key)
160
142
{
161
 
        key->index = htod32(key->index);
162
 
        key->len = htod32(key->len);
163
 
        key->algo = htod32(key->algo);
164
 
        key->flags = htod32(key->flags);
165
 
        key->rxiv.hi = htod32(key->rxiv.hi);
166
 
        key->rxiv.lo = htod16(key->rxiv.lo);
167
 
        key->iv_initialized = htod32(key->iv_initialized);
 
143
        key->index = cpu_to_le32(key->index);
 
144
        key->len = cpu_to_le32(key->len);
 
145
        key->algo = cpu_to_le32(key->algo);
 
146
        key->flags = cpu_to_le32(key->flags);
 
147
        key->rxiv.hi = cpu_to_le32(key->rxiv.hi);
 
148
        key->rxiv.lo = cpu_to_le16(key->rxiv.lo);
 
149
        key->iv_initialized = cpu_to_le32(key->iv_initialized);
168
150
}
169
151
 
170
152
static void swap_key_to_BE(wl_wsec_key_t *key)
171
153
{
172
 
        key->index = dtoh32(key->index);
173
 
        key->len = dtoh32(key->len);
174
 
        key->algo = dtoh32(key->algo);
175
 
        key->flags = dtoh32(key->flags);
176
 
        key->rxiv.hi = dtoh32(key->rxiv.hi);
177
 
        key->rxiv.lo = dtoh16(key->rxiv.lo);
178
 
        key->iv_initialized = dtoh32(key->iv_initialized);
 
154
        key->index = le32_to_cpu(key->index);
 
155
        key->len = le32_to_cpu(key->len);
 
156
        key->algo = le32_to_cpu(key->algo);
 
157
        key->flags = le32_to_cpu(key->flags);
 
158
        key->rxiv.hi = le32_to_cpu(key->rxiv.hi);
 
159
        key->rxiv.lo = le16_to_cpu(key->rxiv.lo);
 
160
        key->iv_initialized = le32_to_cpu(key->iv_initialized);
179
161
}
180
162
 
181
163
static int dev_wlc_ioctl(struct net_device *dev, int cmd, void *arg, int len)
223
205
        char buf[WLC_IOCTL_SMLEN];
224
206
        uint len;
225
207
 
226
 
        val = htod32(val);
 
208
        val = cpu_to_le32(val);
227
209
        len = bcm_mkiovar(name, (char *)(&val), sizeof(val), buf, sizeof(buf));
228
210
        ASSERT(len);
229
211
 
288
270
            dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)ioctlbuf,
289
271
                          MAX_WLIW_IOCTL_LEN);
290
272
        if (!error)
291
 
                bcopy(ioctlbuf, buf, buflen);
 
273
                memcpy(buf, ioctlbuf, buflen);
292
274
 
293
275
        return error;
294
276
}
310
292
        ASSERT(len);
311
293
        error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)&var, len);
312
294
 
313
 
        *retval = dtoh32(var.val);
 
295
        *retval = le32_to_cpu(var.val);
314
296
 
315
297
        return error;
316
298
}
340
322
        if (error)
341
323
                return error;
342
324
 
343
 
        ssid.SSID_len = dtoh32(ssid.SSID_len);
 
325
        ssid.SSID_len = le32_to_cpu(ssid.SSID_len);
344
326
 
345
327
        if (!ssid.SSID_len)
346
328
                return 0;
392
374
 
393
375
                chan = wf_mhz2channel(fwrq->m, sf);
394
376
        }
395
 
        chan = htod32(chan);
 
377
        chan = cpu_to_le32(chan);
396
378
 
397
379
        error = dev_wlc_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan));
398
380
        if (error)
415
397
        if (error)
416
398
                return error;
417
399
 
418
 
        fwrq->m = dtoh32(ci.hw_channel);
419
 
        fwrq->e = dtoh32(0);
 
400
        fwrq->m = le32_to_cpu(ci.hw_channel);
 
401
        fwrq->e = le32_to_cpu(0);
420
402
        return 0;
421
403
}
422
404
 
441
423
        default:
442
424
                return -EINVAL;
443
425
        }
444
 
        infra = htod32(infra);
445
 
        ap = htod32(ap);
 
426
        infra = cpu_to_le32(infra);
 
427
        ap = cpu_to_le32(ap);
446
428
 
447
429
        error = dev_wlc_ioctl(dev, WLC_SET_INFRA, &infra, sizeof(infra));
448
430
        if (error)
471
453
        if (error)
472
454
                return error;
473
455
 
474
 
        infra = dtoh32(infra);
475
 
        ap = dtoh32(ap);
 
456
        infra = le32_to_cpu(infra);
 
457
        ap = le32_to_cpu(ap);
476
458
        *uwrq = infra ? ap ? IW_MODE_MASTER : IW_MODE_INFRA : IW_MODE_ADHOC;
477
459
 
478
460
        return 0;
488
470
        wl_rateset_t rateset;
489
471
        s8 *channels;
490
472
        int error, i, k;
491
 
        uint sf, ch;
 
473
        uint ch;
492
474
 
493
475
        int phytype;
494
476
        int bw_cap = 0, sgi_tx = 0, nmode = 0;
517
499
 
518
500
        range->min_nwid = range->max_nwid = 0;
519
501
 
520
 
        list->count = htod32(MAXCHANNEL);
 
502
        list->count = cpu_to_le32(MAXCHANNEL);
521
503
        error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels,
522
504
                                (MAXCHANNEL + 1) * 4);
523
505
        if (error) {
524
506
                kfree(channels);
525
507
                return error;
526
508
        }
527
 
        for (i = 0; i < dtoh32(list->count) && i < IW_MAX_FREQUENCIES; i++) {
528
 
                range->freq[i].i = dtoh32(list->element[i]);
529
 
 
530
 
                ch = dtoh32(list->element[i]);
531
 
                if (ch <= CH_MAX_2G_CHANNEL)
532
 
                        sf = WF_CHAN_FACTOR_2_4_G;
533
 
                else
534
 
                        sf = WF_CHAN_FACTOR_5_G;
535
 
 
536
 
                range->freq[i].m = wf_channel2mhz(ch, sf);
 
509
        for (i = 0; i < le32_to_cpu(list->count) && i < IW_MAX_FREQUENCIES;
 
510
             i++) {
 
511
                range->freq[i].i = le32_to_cpu(list->element[i]);
 
512
 
 
513
                ch = le32_to_cpu(list->element[i]);
 
514
                if (ch <= CH_MAX_2G_CHANNEL) {
 
515
                        range->freq[i].m = ieee80211_dsss_chan_to_freq(ch);
 
516
                } else {
 
517
                        range->freq[i].m = ieee80211_ofdm_chan_to_freq(
 
518
                                                WF_CHAN_FACTOR_5_G/2, ch);
 
519
                }
537
520
                range->freq[i].e = 6;
538
521
        }
539
522
        range->num_frequency = range->num_channels = i;
555
538
                kfree(channels);
556
539
                return error;
557
540
        }
558
 
        rateset.count = dtoh32(rateset.count);
 
541
        rateset.count = le32_to_cpu(rateset.count);
559
542
        range->num_bitrates = rateset.count;
560
543
        for (i = 0; i < rateset.count && i < IW_MAX_BITRATES; i++)
561
544
                range->bitrate[i] = (rateset.rates[i] & 0x7f) * 500000;
567
550
                dev_wlc_intvar_get(dev, "sgi_tx", &sgi_tx);
568
551
                dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci,
569
552
                              sizeof(channel_info_t));
570
 
                ci.hw_channel = dtoh32(ci.hw_channel);
 
553
                ci.hw_channel = le32_to_cpu(ci.hw_channel);
571
554
 
572
555
                if (bw_cap == 0 || (bw_cap == 2 && ci.hw_channel <= 14)) {
573
556
                        if (sgi_tx == 0)
593
576
                kfree(channels);
594
577
                return error;
595
578
        }
596
 
        i = dtoh32(i);
 
579
        i = le32_to_cpu(i);
597
580
        if (i == WLC_PHY_TYPE_A)
598
581
                range->throughput = 24000000;
599
582
        else
606
589
 
607
590
        range->max_encoding_tokens = DOT11_MAX_DEFAULT_KEYS;
608
591
        range->num_encoding_sizes = 4;
609
 
        range->encoding_size[0] = WEP1_KEY_SIZE;
610
 
        range->encoding_size[1] = WEP128_KEY_SIZE;
 
592
        range->encoding_size[0] = WLAN_KEY_LEN_WEP40;
 
593
        range->encoding_size[1] = WLAN_KEY_LEN_WEP104;
611
594
#if WIRELESS_EXT > 17
612
 
        range->encoding_size[2] = TKIP_KEY_SIZE;
 
595
        range->encoding_size[2] = WLAN_KEY_LEN_TKIP;
613
596
#else
614
597
        range->encoding_size[2] = 0;
615
598
#endif
616
 
        range->encoding_size[3] = AES_KEY_SIZE;
 
599
        range->encoding_size[3] = WLAN_KEY_LEN_AES_CMAC;
617
600
 
618
601
        range->min_pmp = 0;
619
602
        range->max_pmp = 0;
690
673
 
691
674
        iw->spy_num = min_t(int, ARRAY_SIZE(iw->spy_addr), dwrq->length);
692
675
        for (i = 0; i < iw->spy_num; i++)
693
 
                memcpy(&iw->spy_addr[i], addr[i].sa_data, ETH_ALEN);
 
676
                memcpy(iw->spy_addr[i], addr[i].sa_data, ETH_ALEN);
694
677
        memset(iw->spy_qual, 0, sizeof(iw->spy_qual));
695
678
 
696
679
        return 0;
712
695
 
713
696
        dwrq->length = iw->spy_num;
714
697
        for (i = 0; i < iw->spy_num; i++) {
715
 
                memcpy(addr[i].sa_data, &iw->spy_addr[i], ETH_ALEN);
 
698
                memcpy(addr[i].sa_data, iw->spy_addr[i], ETH_ALEN);
716
699
                addr[i].sa_family = AF_UNIX;
717
700
                memcpy(&qual[i], &iw->spy_qual[i], sizeof(struct iw_quality));
718
701
                iw->spy_qual[i].updated = 0;
745
728
                join_params->params.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK;
746
729
                join_params->params.chanspec_list[0] |= chanspec;
747
730
                join_params->params.chanspec_list[0] =
748
 
                    htodchanspec(join_params->params.chanspec_list[0]);
 
731
                    cpu_to_le16(join_params->params.chanspec_list[0]);
749
732
 
750
733
                join_params->params.chanspec_num =
751
 
                    htod32(join_params->params.chanspec_num);
 
734
                    cpu_to_le32(join_params->params.chanspec_num);
752
735
 
753
736
                WL_TRACE("%s  join_params->params.chanspec_list[0]= %X\n",
754
737
                         __func__, join_params->params.chanspec_list[0]);
784
767
        join_params_size = sizeof(join_params.ssid);
785
768
 
786
769
        memcpy(join_params.ssid.SSID, g_ssid.SSID, g_ssid.SSID_len);
787
 
        join_params.ssid.SSID_len = htod32(g_ssid.SSID_len);
 
770
        join_params.ssid.SSID_len = cpu_to_le32(g_ssid.SSID_len);
788
771
        memcpy(&join_params.params.bssid, awrq->sa_data, ETH_ALEN);
789
772
 
790
773
        WL_TRACE("%s  target_channel=%d\n",
840
823
        }
841
824
 
842
825
        scbval.val = mlme->reason_code;
843
 
        bcopy(&mlme->addr.sa_data, &scbval.ea, ETH_ALEN);
 
826
        memcpy(&scbval.ea, &mlme->addr.sa_data, ETH_ALEN);
844
827
 
845
828
        if (mlme->cmd == IW_MLME_DISASSOC) {
846
 
                scbval.val = htod32(scbval.val);
 
829
                scbval.val = cpu_to_le32(scbval.val);
847
830
                error =
848
831
                    dev_wlc_ioctl(dev, WLC_DISASSOC, &scbval,
849
832
                                  sizeof(scb_val_t));
850
833
        } else if (mlme->cmd == IW_MLME_DEAUTH) {
851
 
                scbval.val = htod32(scbval.val);
 
834
                scbval.val = cpu_to_le32(scbval.val);
852
835
                error =
853
836
                    dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON,
854
837
                                  &scbval, sizeof(scb_val_t));
879
862
        if (!extra)
880
863
                return -EINVAL;
881
864
 
882
 
        list = kmalloc(buflen, GFP_KERNEL);
 
865
        list = kzalloc(buflen, GFP_KERNEL);
883
866
        if (!list)
884
867
                return -ENOMEM;
885
 
        memset(list, 0, buflen);
886
 
        list->buflen = htod32(buflen);
 
868
        list->buflen = cpu_to_le32(buflen);
887
869
        error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, buflen);
888
870
        if (error) {
889
871
                WL_ERROR("%d: Scan results error %d\n", __LINE__, error);
890
872
                kfree(list);
891
873
                return error;
892
874
        }
893
 
        list->buflen = dtoh32(list->buflen);
894
 
        list->version = dtoh32(list->version);
895
 
        list->count = dtoh32(list->count);
 
875
        list->buflen = le32_to_cpu(list->buflen);
 
876
        list->version = le32_to_cpu(list->version);
 
877
        list->count = le32_to_cpu(list->count);
896
878
        if (list->version != WL_BSS_INFO_VERSION) {
897
879
                WL_ERROR("%s : list->version %d != WL_BSS_INFO_VERSION\n",
898
880
                         __func__, list->version);
903
885
        for (i = 0, dwrq->length = 0;
904
886
             i < list->count && dwrq->length < IW_MAX_AP; i++) {
905
887
                bi = bi ? (wl_bss_info_t *) ((unsigned long)bi +
906
 
                                             dtoh32(bi->length)) : list->
 
888
                                             le32_to_cpu(bi->length)) : list->
907
889
                    bss_info;
908
 
                ASSERT(((unsigned long)bi + dtoh32(bi->length)) <=
 
890
                ASSERT(((unsigned long)bi + le32_to_cpu(bi->length)) <=
909
891
                       ((unsigned long)list + buflen));
910
892
 
911
 
                if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
 
893
                if (!(le16_to_cpu(bi->capability) & WLAN_CAPABILITY_ESS))
912
894
                        continue;
913
895
 
914
896
                memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETH_ALEN);
915
897
                addr[dwrq->length].sa_family = ARPHRD_ETHER;
916
 
                qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
917
 
                qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
 
898
                qual[dwrq->length].qual = rssi_to_qual(le16_to_cpu(bi->RSSI));
 
899
                qual[dwrq->length].level = 0x100 + le16_to_cpu(bi->RSSI);
918
900
                qual[dwrq->length].noise = 0x100 + bi->phy_noise;
919
901
 
920
902
#if WIRELESS_EXT > 18
975
957
                for (i = 0, dwrq->length = 0;
976
958
                     i < list->count && dwrq->length < IW_MAX_AP; i++) {
977
959
                        bi = bi ? (wl_bss_info_t *) ((unsigned long)bi +
978
 
                                                     dtoh32(bi->length)) :
 
960
                                                     le32_to_cpu(bi->length)) :
979
961
                            list->bss_info;
980
 
                        ASSERT(((unsigned long)bi + dtoh32(bi->length)) <=
 
962
                        ASSERT(((unsigned long)bi + le32_to_cpu(bi->length)) <=
981
963
                               ((unsigned long)list + WLC_IW_ISCAN_MAXLEN));
982
964
 
983
 
                        if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
 
965
                        if (!(le16_to_cpu(bi->capability) &
 
966
                              WLAN_CAPABILITY_ESS))
984
967
                                continue;
985
968
 
986
969
                        memcpy(addr[dwrq->length].sa_data, &bi->BSSID,
987
970
                               ETH_ALEN);
988
971
                        addr[dwrq->length].sa_family = ARPHRD_ETHER;
989
972
                        qual[dwrq->length].qual =
990
 
                            rssi_to_qual(dtoh16(bi->RSSI));
991
 
                        qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
 
973
                            rssi_to_qual(le16_to_cpu(bi->RSSI));
 
974
                        qual[dwrq->length].level = 0x100 +
 
975
                                                        le16_to_cpu(bi->RSSI);
992
976
                        qual[dwrq->length].noise = 0x100 + bi->phy_noise;
993
977
 
994
978
#if WIRELESS_EXT > 18
1015
999
{
1016
1000
        int err = 0;
1017
1001
 
1018
 
        memcpy(&params->bssid, &ether_bcast, ETH_ALEN);
 
1002
        memcpy(params->bssid, ether_bcast, ETH_ALEN);
1019
1003
        params->bss_type = DOT11_BSSTYPE_ANY;
1020
1004
        params->scan_type = 0;
1021
1005
        params->nprobes = -1;
1024
1008
        params->home_time = -1;
1025
1009
        params->channel_num = 0;
1026
1010
 
1027
 
        params->nprobes = htod32(params->nprobes);
1028
 
        params->active_time = htod32(params->active_time);
1029
 
        params->passive_time = htod32(params->passive_time);
1030
 
        params->home_time = htod32(params->home_time);
 
1011
        params->nprobes = cpu_to_le32(params->nprobes);
 
1012
        params->active_time = cpu_to_le32(params->active_time);
 
1013
        params->passive_time = cpu_to_le32(params->passive_time);
 
1014
        params->home_time = cpu_to_le32(params->home_time);
1031
1015
        if (ssid && ssid->SSID_len)
1032
1016
                memcpy(&params->ssid, ssid, sizeof(wlc_ssid_t));
1033
1017
 
1038
1022
{
1039
1023
        int err = 0;
1040
1024
 
1041
 
        iscan->iscan_ex_params_p->version = htod32(ISCAN_REQ_VERSION);
1042
 
        iscan->iscan_ex_params_p->action = htod16(action);
1043
 
        iscan->iscan_ex_params_p->scan_duration = htod16(0);
 
1025
        iscan->iscan_ex_params_p->version = cpu_to_le32(ISCAN_REQ_VERSION);
 
1026
        iscan->iscan_ex_params_p->action = cpu_to_le16(action);
 
1027
        iscan->iscan_ex_params_p->scan_duration = cpu_to_le16(0);
1044
1028
 
1045
1029
        WL_SCAN("%s : nprobes=%d\n",
1046
1030
                __func__, iscan->iscan_ex_params_p->params.nprobes);
1077
1061
        char iovbuf[WL_EVENTING_MASK_LEN + 12];
1078
1062
 
1079
1063
        dev_iw_iovar_getbuf(dev, "event_msgs", "", 0, iovbuf, sizeof(iovbuf));
1080
 
        bcopy(iovbuf, eventmask, WL_EVENTING_MASK_LEN);
 
1064
        memcpy(eventmask, iovbuf, WL_EVENTING_MASK_LEN);
1081
1065
        setbit(eventmask, WLC_E_SCAN_COMPLETE);
1082
1066
        dev_iw_iovar_setbuf(dev, "event_msgs", eventmask, WL_EVENTING_MASK_LEN,
1083
1067
                            iovbuf, sizeof(iovbuf));
1124
1108
        results->count = 0;
1125
1109
 
1126
1110
        memset(&list, 0, sizeof(list));
1127
 
        list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN);
 
1111
        list.results.buflen = cpu_to_le32(WLC_IW_ISCAN_MAXLEN);
1128
1112
        res = dev_iw_iovar_getbuf(iscan->dev,
1129
1113
                                  "iscanresults",
1130
1114
                                  &list,
1131
1115
                                  WL_ISCAN_RESULTS_FIXED_SIZE,
1132
1116
                                  buf->iscan_buf, WLC_IW_ISCAN_MAXLEN);
1133
1117
        if (res == 0) {
1134
 
                results->buflen = dtoh32(results->buflen);
1135
 
                results->version = dtoh32(results->version);
1136
 
                results->count = dtoh32(results->count);
 
1118
                results->buflen = le32_to_cpu(results->buflen);
 
1119
                results->version = le32_to_cpu(results->version);
 
1120
                results->count = le32_to_cpu(results->count);
1137
1121
                WL_TRACE("results->count = %d\n", results->count);
1138
1122
                WL_TRACE("results->buflen = %d\n", results->buflen);
1139
 
                status = dtoh32(list_buf->status);
 
1123
                status = le32_to_cpu(list_buf->status);
1140
1124
        } else {
1141
1125
                WL_ERROR("%s returns error %d\n", __func__, res);
1142
1126
                status = WL_SCAN_RESULTS_NO_MEM;
1283
1267
                                memcpy(g_specific_ssid.SSID, req->essid,
1284
1268
                                       g_specific_ssid.SSID_len);
1285
1269
                                g_specific_ssid.SSID_len =
1286
 
                                    htod32(g_specific_ssid.SSID_len);
 
1270
                                    cpu_to_le32(g_specific_ssid.SSID_len);
1287
1271
                                g_scan_specified_ssid = 1;
1288
1272
                                WL_TRACE("### Specific scan ssid=%s len=%d\n",
1289
1273
                                         g_specific_ssid.SSID,
1367
1351
        if (g_scan_specified_ssid) {
1368
1352
                WL_TRACE("%s Specific SCAN already running ignoring BC scan\n",
1369
1353
                         __func__);
1370
 
                return EBUSY;
 
1354
                return -EBUSY;
1371
1355
        }
1372
1356
 
1373
1357
        memset(&ssid, 0, sizeof(ssid));
1379
1363
                        ssid.SSID_len = min_t(size_t, sizeof(ssid.SSID),
1380
1364
                                                req->essid_len);
1381
1365
                        memcpy(ssid.SSID, req->essid, ssid.SSID_len);
1382
 
                        ssid.SSID_len = htod32(ssid.SSID_len);
 
1366
                        ssid.SSID_len = cpu_to_le32(ssid.SSID_len);
1383
1367
                } else {
1384
1368
                        g_scan_specified_ssid = 0;
1385
1369
 
1505
1489
                }
1506
1490
 
1507
1491
                bi = bi ? (wl_bss_info_t *)((unsigned long)bi +
1508
 
                                             dtoh32(bi->length)) : list->
 
1492
                                             le32_to_cpu(bi->length)) : list->
1509
1493
                    bss_info;
1510
1494
 
1511
1495
                WL_TRACE("%s : %s\n", __func__, bi->SSID);
1516
1500
                event =
1517
1501
                    IWE_STREAM_ADD_EVENT(info, event, end, &iwe,
1518
1502
                                         IW_EV_ADDR_LEN);
1519
 
                iwe.u.data.length = dtoh32(bi->SSID_len);
 
1503
                iwe.u.data.length = le32_to_cpu(bi->SSID_len);
1520
1504
                iwe.cmd = SIOCGIWESSID;
1521
1505
                iwe.u.data.flags = 1;
1522
1506
                event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
1523
1507
 
1524
 
                if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
 
1508
                if (le16_to_cpu(bi->capability) & (WLAN_CAPABILITY_ESS |
 
1509
                    WLAN_CAPABILITY_IBSS)) {
1525
1510
                        iwe.cmd = SIOCGIWMODE;
1526
 
                        if (dtoh16(bi->capability) & DOT11_CAP_ESS)
 
1511
                        if (le16_to_cpu(bi->capability) & WLAN_CAPABILITY_ESS)
1527
1512
                                iwe.u.mode = IW_MODE_INFRA;
1528
1513
                        else
1529
1514
                                iwe.u.mode = IW_MODE_ADHOC;
1533
1518
                }
1534
1519
 
1535
1520
                iwe.cmd = SIOCGIWFREQ;
1536
 
                iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
1537
 
                                              CHSPEC_CHANNEL(bi->chanspec) <=
1538
 
                                              CH_MAX_2G_CHANNEL ?
1539
 
                                              WF_CHAN_FACTOR_2_4_G :
1540
 
                                              WF_CHAN_FACTOR_5_G);
 
1521
 
 
1522
                if (CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL)
 
1523
                        iwe.u.freq.m = ieee80211_dsss_chan_to_freq(
 
1524
                                                CHSPEC_CHANNEL(bi->chanspec));
 
1525
                else
 
1526
                        iwe.u.freq.m = ieee80211_ofdm_chan_to_freq(
 
1527
                                                WF_CHAN_FACTOR_5_G/2,
 
1528
                                                CHSPEC_CHANNEL(bi->chanspec));
 
1529
 
1541
1530
                iwe.u.freq.e = 6;
1542
1531
                event =
1543
1532
                    IWE_STREAM_ADD_EVENT(info, event, end, &iwe,
1544
1533
                                         IW_EV_FREQ_LEN);
1545
1534
 
1546
1535
                iwe.cmd = IWEVQUAL;
1547
 
                iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
1548
 
                iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
 
1536
                iwe.u.qual.qual = rssi_to_qual(le16_to_cpu(bi->RSSI));
 
1537
                iwe.u.qual.level = 0x100 + le16_to_cpu(bi->RSSI);
1549
1538
                iwe.u.qual.noise = 0x100 + bi->phy_noise;
1550
1539
                event =
1551
1540
                    IWE_STREAM_ADD_EVENT(info, event, end, &iwe,
1554
1543
                wl_iw_handle_scanresults_ies(&event, end, info, bi);
1555
1544
 
1556
1545
                iwe.cmd = SIOCGIWENCODE;
1557
 
                if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
 
1546
                if (le16_to_cpu(bi->capability) & WLAN_CAPABILITY_PRIVACY)
1558
1547
                        iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1559
1548
                else
1560
1549
                        iwe.u.data.flags = IW_ENCODE_DISABLED;
1621
1610
        error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci));
1622
1611
        if (error)
1623
1612
                return error;
1624
 
        ci.scan_channel = dtoh32(ci.scan_channel);
 
1613
        ci.scan_channel = le32_to_cpu(ci.scan_channel);
1625
1614
        if (ci.scan_channel)
1626
1615
                return -EAGAIN;
1627
1616
 
1636
1625
        }
1637
1626
 
1638
1627
        memset(list, 0, len);
1639
 
        list->buflen = htod32(len);
 
1628
        list->buflen = cpu_to_le32(len);
1640
1629
        error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, len);
1641
1630
        if (error) {
1642
1631
                WL_ERROR("%s: %s : Scan_results ERROR %d\n",
1648
1637
                }
1649
1638
                return 0;
1650
1639
        }
1651
 
        list->buflen = dtoh32(list->buflen);
1652
 
        list->version = dtoh32(list->version);
1653
 
        list->count = dtoh32(list->count);
 
1640
        list->buflen = le32_to_cpu(list->buflen);
 
1641
        list->version = le32_to_cpu(list->version);
 
1642
        list->count = le32_to_cpu(list->count);
1654
1643
 
1655
1644
        if (list->version != WL_BSS_INFO_VERSION) {
1656
1645
                WL_ERROR("%s : list->version %d != WL_BSS_INFO_VERSION\n",
1770
1759
                for (ii = 0; ii < list->count && apcnt < IW_MAX_AP;
1771
1760
                     apcnt++, ii++) {
1772
1761
                        bi = bi ? (wl_bss_info_t *)((unsigned long)bi +
1773
 
                                                     dtoh32(bi->length)) :
 
1762
                                                     le32_to_cpu(bi->length)) :
1774
1763
                            list->bss_info;
1775
 
                        ASSERT(((unsigned long)bi + dtoh32(bi->length)) <=
 
1764
                        ASSERT(((unsigned long)bi + le32_to_cpu(bi->length)) <=
1776
1765
                               ((unsigned long)list + WLC_IW_ISCAN_MAXLEN));
1777
1766
 
1778
1767
                        if (event + ETH_ALEN + bi->SSID_len +
1787
1776
                            IWE_STREAM_ADD_EVENT(info, event, end, &iwe,
1788
1777
                                                 IW_EV_ADDR_LEN);
1789
1778
 
1790
 
                        iwe.u.data.length = dtoh32(bi->SSID_len);
 
1779
                        iwe.u.data.length = le32_to_cpu(bi->SSID_len);
1791
1780
                        iwe.cmd = SIOCGIWESSID;
1792
1781
                        iwe.u.data.flags = 1;
1793
1782
                        event =
1794
1783
                            IWE_STREAM_ADD_POINT(info, event, end, &iwe,
1795
1784
                                                 bi->SSID);
1796
1785
 
1797
 
                        if (dtoh16(bi->capability) &
1798
 
                            (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
 
1786
                        if (le16_to_cpu(bi->capability) &
 
1787
                            (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) {
1799
1788
                                iwe.cmd = SIOCGIWMODE;
1800
 
                                if (dtoh16(bi->capability) & DOT11_CAP_ESS)
 
1789
                                if (le16_to_cpu(bi->capability) &
 
1790
                                    WLAN_CAPABILITY_ESS)
1801
1791
                                        iwe.u.mode = IW_MODE_INFRA;
1802
1792
                                else
1803
1793
                                        iwe.u.mode = IW_MODE_ADHOC;
1810
1800
                        channel =
1811
1801
                            (bi->ctl_ch ==
1812
1802
                             0) ? CHSPEC_CHANNEL(bi->chanspec) : bi->ctl_ch;
1813
 
                        iwe.u.freq.m =
1814
 
                            wf_channel2mhz(channel,
1815
 
                                           channel <=
1816
 
                                           CH_MAX_2G_CHANNEL ?
1817
 
                                           WF_CHAN_FACTOR_2_4_G :
1818
 
                                           WF_CHAN_FACTOR_5_G);
 
1803
 
 
1804
                        if (channel <= CH_MAX_2G_CHANNEL)
 
1805
                                iwe.u.freq.m =
 
1806
                                        ieee80211_dsss_chan_to_freq(channel);
 
1807
                        else
 
1808
                                iwe.u.freq.m = ieee80211_ofdm_chan_to_freq(
 
1809
                                                        WF_CHAN_FACTOR_5_G/2,
 
1810
                                                        channel);
 
1811
 
1819
1812
                        iwe.u.freq.e = 6;
1820
1813
                        event =
1821
1814
                            IWE_STREAM_ADD_EVENT(info, event, end, &iwe,
1822
1815
                                                 IW_EV_FREQ_LEN);
1823
1816
 
1824
1817
                        iwe.cmd = IWEVQUAL;
1825
 
                        iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
1826
 
                        iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
 
1818
                        iwe.u.qual.qual = rssi_to_qual(le16_to_cpu(bi->RSSI));
 
1819
                        iwe.u.qual.level = 0x100 + le16_to_cpu(bi->RSSI);
1827
1820
                        iwe.u.qual.noise = 0x100 + bi->phy_noise;
1828
1821
                        event =
1829
1822
                            IWE_STREAM_ADD_EVENT(info, event, end, &iwe,
1832
1825
                        wl_iw_handle_scanresults_ies(&event, end, info, bi);
1833
1826
 
1834
1827
                        iwe.cmd = SIOCGIWENCODE;
1835
 
                        if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
 
1828
                        if (le16_to_cpu(bi->capability) &
 
1829
                            WLAN_CAPABILITY_PRIVACY)
1836
1830
                                iwe.u.data.flags =
1837
1831
                                    IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1838
1832
                        else
1912
1906
        } else {
1913
1907
                g_ssid.SSID_len = 0;
1914
1908
        }
1915
 
        g_ssid.SSID_len = htod32(g_ssid.SSID_len);
 
1909
        g_ssid.SSID_len = cpu_to_le32(g_ssid.SSID_len);
1916
1910
 
1917
1911
        memset(&join_params, 0, sizeof(join_params));
1918
1912
        join_params_size = sizeof(join_params.ssid);
1919
1913
 
1920
1914
        memcpy(&join_params.ssid.SSID, g_ssid.SSID, g_ssid.SSID_len);
1921
 
        join_params.ssid.SSID_len = htod32(g_ssid.SSID_len);
1922
 
        memcpy(&join_params.params.bssid, &ether_bcast, ETH_ALEN);
 
1915
        join_params.ssid.SSID_len = cpu_to_le32(g_ssid.SSID_len);
 
1916
        memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN);
1923
1917
 
1924
1918
        wl_iw_ch_to_chanspec(g_wl_iw_params.target_channel, &join_params,
1925
1919
                             &join_params_size);
1955
1949
                return error;
1956
1950
        }
1957
1951
 
1958
 
        ssid.SSID_len = dtoh32(ssid.SSID_len);
 
1952
        ssid.SSID_len = le32_to_cpu(ssid.SSID_len);
1959
1953
 
1960
1954
        memcpy(extra, ssid.SSID, ssid.SSID_len);
1961
1955
 
2017
2011
        if (error)
2018
2012
                return error;
2019
2013
 
2020
 
        rateset.count = dtoh32(rateset.count);
 
2014
        rateset.count = le32_to_cpu(rateset.count);
2021
2015
 
2022
2016
        if (vwrq->value < 0)
2023
2017
                rate = rateset.rates[rateset.count - 1] & 0x7f;
2042
2036
                for (i = 0; i < rateset.count; i++)
2043
2037
                        if ((rateset.rates[i] & 0x7f) > rate)
2044
2038
                                break;
2045
 
                rateset.count = htod32(i);
 
2039
                rateset.count = cpu_to_le32(i);
2046
2040
 
2047
2041
                error = dev_wlc_ioctl(dev, WLC_SET_RATESET, &rateset,
2048
2042
                                        sizeof(rateset));
2064
2058
        error = dev_wlc_ioctl(dev, WLC_GET_RATE, &rate, sizeof(rate));
2065
2059
        if (error)
2066
2060
                return error;
2067
 
        rate = dtoh32(rate);
 
2061
        rate = le32_to_cpu(rate);
2068
2062
        vwrq->value = rate * 500000;
2069
2063
 
2070
2064
        return 0;
2164
2158
        disable = vwrq->disabled ? WL_RADIO_SW_DISABLE : 0;
2165
2159
        disable += WL_RADIO_SW_DISABLE << 16;
2166
2160
 
2167
 
        disable = htod32(disable);
 
2161
        disable = cpu_to_le32(disable);
2168
2162
        error = dev_wlc_ioctl(dev, WLC_SET_RADIO, &disable, sizeof(disable));
2169
2163
        if (error)
2170
2164
                return error;
2206
2200
        if (error)
2207
2201
                return error;
2208
2202
 
2209
 
        disable = dtoh32(disable);
 
2203
        disable = le32_to_cpu(disable);
2210
2204
        result = (u8) (txpwrdbm & ~WL_TXPWR_OVERRIDE);
2211
2205
        vwrq->value = (s32) bcm_qdbm_to_mw(result);
2212
2206
        vwrq->fixed = 0;
2241
2235
                if ((vwrq->flags & IW_RETRY_MAX)
2242
2236
                    || !(vwrq->flags & IW_RETRY_MIN)) {
2243
2237
#endif
2244
 
                        lrl = htod32(vwrq->value);
 
2238
                        lrl = cpu_to_le32(vwrq->value);
2245
2239
                        error = dev_wlc_ioctl(dev, WLC_SET_LRL, &lrl,
2246
2240
                                                sizeof(lrl));
2247
2241
                        if (error)
2256
2250
                if ((vwrq->flags & IW_RETRY_MIN)
2257
2251
                    || !(vwrq->flags & IW_RETRY_MAX)) {
2258
2252
#endif
2259
 
                        srl = htod32(vwrq->value);
 
2253
                        srl = cpu_to_le32(vwrq->value);
2260
2254
                        error = dev_wlc_ioctl(dev, WLC_SET_SRL, &srl,
2261
2255
                                                sizeof(srl));
2262
2256
                        if (error)
2288
2282
        if (error)
2289
2283
                return error;
2290
2284
 
2291
 
        lrl = dtoh32(lrl);
2292
 
        srl = dtoh32(srl);
 
2285
        lrl = le32_to_cpu(lrl);
 
2286
        srl = le32_to_cpu(srl);
2293
2287
 
2294
2288
        if (vwrq->flags & IW_RETRY_MAX) {
2295
2289
                vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
2320
2314
        if ((dwrq->flags & IW_ENCODE_INDEX) == 0) {
2321
2315
                for (key.index = 0; key.index < DOT11_MAX_DEFAULT_KEYS;
2322
2316
                     key.index++) {
2323
 
                        val = htod32(key.index);
 
2317
                        val = cpu_to_le32(key.index);
2324
2318
                        error = dev_wlc_ioctl(dev, WLC_GET_KEY_PRIMARY, &val,
2325
2319
                                                sizeof(val));
2326
2320
                        if (error)
2327
2321
                                return error;
2328
 
                        val = dtoh32(val);
 
2322
                        val = le32_to_cpu(val);
2329
2323
                        if (val)
2330
2324
                                break;
2331
2325
                }
2338
2332
        }
2339
2333
 
2340
2334
        if (!extra || !dwrq->length || (dwrq->flags & IW_ENCODE_NOKEY)) {
2341
 
                val = htod32(key.index);
 
2335
                val = cpu_to_le32(key.index);
2342
2336
                error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY, &val,
2343
2337
                                        sizeof(val));
2344
2338
                if (error)
2353
2347
 
2354
2348
                key.flags = WL_PRIMARY_KEY;
2355
2349
                switch (key.len) {
2356
 
                case WEP1_KEY_SIZE:
 
2350
                case WLAN_KEY_LEN_WEP40:
2357
2351
                        key.algo = CRYPTO_ALGO_WEP1;
2358
2352
                        break;
2359
 
                case WEP128_KEY_SIZE:
 
2353
                case WLAN_KEY_LEN_WEP104:
2360
2354
                        key.algo = CRYPTO_ALGO_WEP128;
2361
2355
                        break;
2362
 
                case TKIP_KEY_SIZE:
 
2356
                case WLAN_KEY_LEN_TKIP:
2363
2357
                        key.algo = CRYPTO_ALGO_TKIP;
2364
2358
                        break;
2365
 
                case AES_KEY_SIZE:
 
2359
                case WLAN_KEY_LEN_AES_CMAC:
2366
2360
                        key.algo = CRYPTO_ALGO_AES_CCM;
2367
2361
                        break;
2368
2362
                default:
2389
2383
                return error;
2390
2384
 
2391
2385
        val = (dwrq->flags & IW_ENCODE_RESTRICTED) ? 1 : 0;
2392
 
        val = htod32(val);
 
2386
        val = cpu_to_le32(val);
2393
2387
        error = dev_wlc_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val));
2394
2388
        if (error)
2395
2389
                return error;
2417
2411
                                                sizeof(val));
2418
2412
                        if (error)
2419
2413
                                return error;
2420
 
                        val = dtoh32(val);
 
2414
                        val = le32_to_cpu(val);
2421
2415
                        if (val)
2422
2416
                                break;
2423
2417
                }
2437
2431
 
2438
2432
        swap_key_to_BE(&key);
2439
2433
 
2440
 
        wsec = dtoh32(wsec);
2441
 
        auth = dtoh32(auth);
2442
 
        dwrq->length = min_t(u16, DOT11_MAX_KEY_SIZE, key.len);
 
2434
        wsec = le32_to_cpu(wsec);
 
2435
        auth = le32_to_cpu(auth);
 
2436
        dwrq->length = min_t(u16, WLAN_MAX_KEY_LEN, key.len);
2443
2437
 
2444
2438
        dwrq->flags = key.index + 1;
2445
2439
        if (!(wsec & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED)))
2465
2459
 
2466
2460
        pm = vwrq->disabled ? PM_OFF : PM_MAX;
2467
2461
 
2468
 
        pm = htod32(pm);
 
2462
        pm = cpu_to_le32(pm);
2469
2463
        error = dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
2470
2464
        if (error)
2471
2465
                return error;
2486
2480
        if (error)
2487
2481
                return error;
2488
2482
 
2489
 
        pm = dtoh32(pm);
 
2483
        pm = le32_to_cpu(pm);
2490
2484
        vwrq->disabled = pm ? 0 : 1;
2491
2485
        vwrq->flags = IW_POWER_ALL_R;
2492
2486
 
2545
2539
        key.len = iwe->key_len;
2546
2540
 
2547
2541
        if (!is_multicast_ether_addr(iwe->addr.sa_data))
2548
 
                bcopy((void *)&iwe->addr.sa_data, (char *)&key.ea,
2549
 
                      ETH_ALEN);
 
2542
                memcpy(&key.ea, &iwe->addr.sa_data, ETH_ALEN);
2550
2543
 
2551
2544
        if (key.len == 0) {
2552
2545
                if (iwe->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
2553
2546
                        WL_WSEC("Changing the the primary Key to %d\n",
2554
2547
                                key.index);
2555
 
                        key.index = htod32(key.index);
 
2548
                        key.index = cpu_to_le32(key.index);
2556
2549
                        error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY,
2557
2550
                                              &key.index, sizeof(key.index));
2558
2551
                        if (error)
2571
2564
                        key.flags = WL_PRIMARY_KEY;
2572
2565
                }
2573
2566
 
2574
 
                bcopy((void *)iwe->key, key.data, iwe->key_len);
 
2567
                memcpy(key.data, iwe->key, iwe->key_len);
2575
2568
 
2576
2569
                if (iwe->alg == IW_ENCODE_ALG_TKIP) {
2577
2570
                        u8 keybuf[8];
2578
 
                        bcopy(&key.data[24], keybuf, sizeof(keybuf));
2579
 
                        bcopy(&key.data[16], &key.data[24], sizeof(keybuf));
2580
 
                        bcopy(keybuf, &key.data[16], sizeof(keybuf));
 
2571
                        memcpy(keybuf, &key.data[24], sizeof(keybuf));
 
2572
                        memcpy(&key.data[24], &key.data[16], sizeof(keybuf));
 
2573
                        memcpy(&key.data[16], keybuf, sizeof(keybuf));
2581
2574
                }
2582
2575
 
2583
2576
                if (iwe->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
2594
2587
                        key.algo = CRYPTO_ALGO_OFF;
2595
2588
                        break;
2596
2589
                case IW_ENCODE_ALG_WEP:
2597
 
                        if (iwe->key_len == WEP1_KEY_SIZE)
 
2590
                        if (iwe->key_len == WLAN_KEY_LEN_WEP40)
2598
2591
                                key.algo = CRYPTO_ALGO_WEP1;
2599
2592
                        else
2600
2593
                                key.algo = CRYPTO_ALGO_WEP128;
2651
2644
                        uint j;
2652
2645
                        pmkidptr = &pmkid;
2653
2646
 
2654
 
                        bcopy(&iwpmksa->bssid.sa_data[0],
2655
 
                              &pmkidptr->pmkid[0].BSSID, ETH_ALEN);
2656
 
                        bcopy(&iwpmksa->pmkid[0], &pmkidptr->pmkid[0].PMKID,
2657
 
                              WPA2_PMKID_LEN);
 
2647
                        memcpy(&pmkidptr->pmkid[0].BSSID,
 
2648
                               &iwpmksa->bssid.sa_data[0],
 
2649
                               ETH_ALEN);
 
2650
                        memcpy(&pmkidptr->pmkid[0].PMKID,
 
2651
                               &iwpmksa->pmkid[0],
 
2652
                               WLAN_PMKID_LEN);
2658
2653
 
2659
 
                        WL_WSEC("wl_iw_set_pmksa:IW_PMKSA_REMOVE:PMKID: %pM = ",
2660
 
                                &pmkidptr->pmkid[0].BSSID);
2661
 
                        for (j = 0; j < WPA2_PMKID_LEN; j++)
 
2654
                        WL_WSEC("wl_iw_set_pmksa:IW_PMKSA_REMOVE:PMKID: "
 
2655
                                "%pM = ", &pmkidptr->pmkid[0].BSSID);
 
2656
                        for (j = 0; j < WLAN_PMKID_LEN; j++)
2662
2657
                                WL_WSEC("%02x ", pmkidptr->pmkid[0].PMKID[j]);
2663
2658
                        WL_WSEC("\n");
2664
2659
                }
2673
2668
                    && (i < pmkid_list.pmkids.npmkid)) {
2674
2669
                        memset(&pmkid_list.pmkids.pmkid[i], 0, sizeof(pmkid_t));
2675
2670
                        for (; i < (pmkid_list.pmkids.npmkid - 1); i++) {
2676
 
                                bcopy(&pmkid_list.pmkids.pmkid[i + 1].BSSID,
2677
 
                                      &pmkid_list.pmkids.pmkid[i].BSSID,
2678
 
                                      ETH_ALEN);
2679
 
                                bcopy(&pmkid_list.pmkids.pmkid[i + 1].PMKID,
2680
 
                                      &pmkid_list.pmkids.pmkid[i].PMKID,
2681
 
                                      WPA2_PMKID_LEN);
 
2671
                                memcpy(&pmkid_list.pmkids.pmkid[i].BSSID,
 
2672
                                       &pmkid_list.pmkids.pmkid[i + 1].BSSID,
 
2673
                                       ETH_ALEN);
 
2674
                                memcpy(&pmkid_list.pmkids.pmkid[i].PMKID,
 
2675
                                       &pmkid_list.pmkids.pmkid[i + 1].PMKID,
 
2676
                                       WLAN_PMKID_LEN);
2682
2677
                        }
2683
2678
                        pmkid_list.pmkids.npmkid--;
2684
2679
                } else
2692
2687
                             &pmkid_list.pmkids.pmkid[i].BSSID, ETH_ALEN))
2693
2688
                                break;
2694
2689
                if (i < MAXPMKID) {
2695
 
                        bcopy(&iwpmksa->bssid.sa_data[0],
2696
 
                              &pmkid_list.pmkids.pmkid[i].BSSID,
2697
 
                              ETH_ALEN);
2698
 
                        bcopy(&iwpmksa->pmkid[0],
2699
 
                              &pmkid_list.pmkids.pmkid[i].PMKID,
2700
 
                              WPA2_PMKID_LEN);
 
2690
                        memcpy(&pmkid_list.pmkids.pmkid[i].BSSID,
 
2691
                               &iwpmksa->bssid.sa_data[0],
 
2692
                               ETH_ALEN);
 
2693
                        memcpy(&pmkid_list.pmkids.pmkid[i].PMKID,
 
2694
                               &iwpmksa->pmkid[0],
 
2695
                               WLAN_PMKID_LEN);
2701
2696
                        if (i == pmkid_list.pmkids.npmkid)
2702
2697
                                pmkid_list.pmkids.npmkid++;
2703
2698
                } else
2708
2703
                        k = pmkid_list.pmkids.npmkid;
2709
2704
                        WL_WSEC("wl_iw_set_pmksa,IW_PMKSA_ADD - PMKID: %pM = ",
2710
2705
                                &pmkid_list.pmkids.pmkid[k].BSSID);
2711
 
                        for (j = 0; j < WPA2_PMKID_LEN; j++)
 
2706
                        for (j = 0; j < WLAN_PMKID_LEN; j++)
2712
2707
                                WL_WSEC("%02x ",
2713
2708
                                        pmkid_list.pmkids.pmkid[k].PMKID[j]);
2714
2709
                        WL_WSEC("\n");
2720
2715
                uint j;
2721
2716
                WL_WSEC("PMKID[%d]: %pM = ",
2722
2717
                        i, &pmkid_list.pmkids.pmkid[i].BSSID);
2723
 
                for (j = 0; j < WPA2_PMKID_LEN; j++)
 
2718
                for (j = 0; j < WLAN_PMKID_LEN; j++)
2724
2719
                        WL_WSEC("%02x ", pmkid_list.pmkids.pmkid[i].PMKID[j]);
2725
2720
                WL_WSEC("\n");
2726
2721
        }
3342
3337
static bool
3343
3338
wl_iw_check_conn_fail(wl_event_msg_t *e, char *stringBuf, uint buflen)
3344
3339
{
3345
 
        u32 event = ntoh32(e->event_type);
3346
 
        u32 status = ntoh32(e->status);
3347
 
        u32 reason = ntoh32(e->reason);
 
3340
        u32 event = be32_to_cpu(e->event_type);
 
3341
        u32 status = be32_to_cpu(e->status);
 
3342
        u32 reason = be32_to_cpu(e->reason);
3348
3343
 
3349
3344
        if (wl_iw_conn_status_str(event, status, reason, stringBuf, buflen)) {
3350
3345
                return true;
3363
3358
        union iwreq_data wrqu;
3364
3359
        char extra[IW_CUSTOM_MAX + 1];
3365
3360
        int cmd = 0;
3366
 
        u32 event_type = ntoh32(e->event_type);
3367
 
        u16 flags = ntoh16(e->flags);
3368
 
        u32 datalen = ntoh32(e->datalen);
3369
 
        u32 status = ntoh32(e->status);
 
3361
        u32 event_type = be32_to_cpu(e->event_type);
 
3362
        u16 flags = be16_to_cpu(e->flags);
 
3363
        u32 datalen = be32_to_cpu(e->datalen);
 
3364
        u32 status = be32_to_cpu(e->status);
3370
3365
        wl_iw_t *iw;
3371
3366
        u32 toto;
3372
3367
        memset(&wrqu, 0, sizeof(wrqu));
3409
3404
                if (!(flags & WLC_EVENT_MSG_LINK)) {
3410
3405
                        memset(wrqu.addr.sa_data, 0, ETH_ALEN);
3411
3406
                        memset(&extra, 0, ETH_ALEN);
3412
 
                        WAKE_LOCK_TIMEOUT(iw->pub, WAKE_LOCK_LINK_DOWN_TMOUT,
3413
 
                                          20 * HZ);
3414
3407
                } else {
3415
3408
                        memcpy(wrqu.addr.sa_data, &e->addr, ETH_ALEN);
3416
3409
                        WL_TRACE("Link UP\n");
3436
3429
                        wrqu.data.length = sizeof(status) + 1;
3437
3430
                        extra[0] = WLC_E_ACTION_FRAME_COMPLETE;
3438
3431
                        memcpy(&extra[1], &status, sizeof(status));
3439
 
                        printf("wl_iw_event status %d PacketId %d\n", status,
3440
 
                               toto);
3441
 
                        printf("WLC_E_ACTION_FRAME_COMPLETE len %d\n",
3442
 
                               wrqu.data.length);
 
3432
                        WL_TRACE("wl_iw_event status %d PacketId %d\n", status,
 
3433
                                 toto);
 
3434
                        WL_TRACE("WLC_E_ACTION_FRAME_COMPLETE len %d\n",
 
3435
                                 wrqu.data.length);
3443
3436
                }
3444
3437
                break;
3445
3438
#endif                          /* WIRELESS_EXT > 14 */
3471
3464
 
3472
3465
                                cmd = IWEVPMKIDCAND;
3473
3466
                                pmkcandlist = data;
3474
 
                                count =
3475
 
                                    ntoh32_ua((u8 *) &
3476
 
                                              pmkcandlist->npmkid_cand);
 
3467
                                count = get_unaligned_be32(&pmkcandlist->
 
3468
                                                           npmkid_cand);
3477
3469
                                ASSERT(count >= 0);
3478
3470
                                wrqu.data.length = sizeof(struct iw_pmkid_cand);
3479
3471
                                pmkidcand = pmkcandlist->pmkid_cand;
3483
3475
                                        if (pmkidcand->preauth)
3484
3476
                                                iwpmkidcand->flags |=
3485
3477
                                                    IW_PMKID_CAND_PREAUTH;
3486
 
                                        bcopy(&pmkidcand->BSSID,
3487
 
                                              &iwpmkidcand->bssid.sa_data,
3488
 
                                              ETH_ALEN);
 
3478
                                        memcpy(&iwpmkidcand->bssid.sa_data,
 
3479
                                               &pmkidcand->BSSID,
 
3480
                                               ETH_ALEN);
3489
3481
#ifndef SANDGATE2G
3490
3482
                                        wireless_send_event(dev, cmd, &wrqu,
3491
3483
                                                            extra);
3523
3515
                        WL_ERROR("%s Event WLC_E_PFN_NET_FOUND, send %s up : find %s len=%d\n",
3524
3516
                                 __func__, PNO_EVENT_UP,
3525
3517
                                 ssid->SSID, ssid->SSID_len);
3526
 
                        WAKE_LOCK_TIMEOUT(iw->pub, WAKE_LOCK_PNO_FIND_TMOUT,
3527
 
                                          20 * HZ);
3528
3518
                        cmd = IWEVCUSTOM;
3529
3519
                        memset(&wrqu, 0, sizeof(wrqu));
3530
3520
                        strcpy(extra, PNO_EVENT_UP);
3562
3552
wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats)
3563
3553
{
3564
3554
        int res = 0;
3565
 
        wl_cnt_t cnt;
 
3555
        struct wl_cnt cnt;
3566
3556
        int phy_noise;
3567
3557
        int rssi;
3568
3558
        scb_val_t scb_val;
3573
3563
        if (res)
3574
3564
                goto done;
3575
3565
 
3576
 
        phy_noise = dtoh32(phy_noise);
 
3566
        phy_noise = le32_to_cpu(phy_noise);
3577
3567
        WL_TRACE("wl_iw_get_wireless_stats phy noise=%d\n", phy_noise);
3578
3568
 
3579
3569
        memset(&scb_val, 0, sizeof(scb_val_t));
3581
3571
        if (res)
3582
3572
                goto done;
3583
3573
 
3584
 
        rssi = dtoh32(scb_val.val);
 
3574
        rssi = le32_to_cpu(scb_val.val);
3585
3575
        WL_TRACE("wl_iw_get_wireless_stats rssi=%d\n", rssi);
3586
3576
        if (rssi <= WL_IW_RSSI_NO_SIGNAL)
3587
3577
                wstats->qual.qual = 0;
3605
3595
#endif
3606
3596
 
3607
3597
#if WIRELESS_EXT > 11
3608
 
        WL_TRACE("wl_iw_get_wireless_stats counters=%zu\n", sizeof(wl_cnt_t));
 
3598
        WL_TRACE("wl_iw_get_wireless_stats counters=%zu\n",
 
3599
                 sizeof(struct wl_cnt));
3609
3600
 
3610
 
        memset(&cnt, 0, sizeof(wl_cnt_t));
 
3601
        memset(&cnt, 0, sizeof(struct wl_cnt));
3611
3602
        res =
3612
 
            dev_wlc_bufvar_get(dev, "counters", (char *)&cnt, sizeof(wl_cnt_t));
 
3603
            dev_wlc_bufvar_get(dev, "counters", (char *)&cnt,
 
3604
                               sizeof(struct wl_cnt));
3613
3605
        if (res) {
3614
3606
                WL_ERROR("wl_iw_get_wireless_stats counters failed error=%d\n",
3615
3607
                         res);
3616
3608
                goto done;
3617
3609
        }
3618
3610
 
3619
 
        cnt.version = dtoh16(cnt.version);
 
3611
        cnt.version = le16_to_cpu(cnt.version);
3620
3612
        if (cnt.version != WL_CNT_T_VERSION) {
3621
 
                WL_TRACE("\tIncorrect version of counters struct: expected %d; got %d\n",
 
3613
                WL_TRACE("\tIncorrect counter version: expected %d; got %d\n",
3622
3614
                         WL_CNT_T_VERSION, cnt.version);
3623
3615
                goto done;
3624
3616
        }
3625
3617
 
3626
3618
        wstats->discard.nwid = 0;
3627
 
        wstats->discard.code = dtoh32(cnt.rxundec);
3628
 
        wstats->discard.fragment = dtoh32(cnt.rxfragerr);
3629
 
        wstats->discard.retries = dtoh32(cnt.txfail);
3630
 
        wstats->discard.misc = dtoh32(cnt.rxrunt) + dtoh32(cnt.rxgiant);
 
3619
        wstats->discard.code = le32_to_cpu(cnt.rxundec);
 
3620
        wstats->discard.fragment = le32_to_cpu(cnt.rxfragerr);
 
3621
        wstats->discard.retries = le32_to_cpu(cnt.txfail);
 
3622
        wstats->discard.misc = le32_to_cpu(cnt.rxrunt) +
 
3623
                le32_to_cpu(cnt.rxgiant);
3631
3624
        wstats->miss.beacon = 0;
3632
3625
 
3633
3626
        WL_TRACE("wl_iw_get_wireless_stats counters txframe=%d txbyte=%d\n",
3634
 
                 dtoh32(cnt.txframe), dtoh32(cnt.txbyte));
 
3627
                 le32_to_cpu(cnt.txframe), le32_to_cpu(cnt.txbyte));
3635
3628
        WL_TRACE("wl_iw_get_wireless_stats counters rxfrmtoolong=%d\n",
3636
 
                  dtoh32(cnt.rxfrmtoolong));
 
3629
                  le32_to_cpu(cnt.rxfrmtoolong));
3637
3630
        WL_TRACE("wl_iw_get_wireless_stats counters rxbadplcp=%d\n",
3638
 
                  dtoh32(cnt.rxbadplcp));
 
3631
                  le32_to_cpu(cnt.rxbadplcp));
3639
3632
        WL_TRACE("wl_iw_get_wireless_stats counters rxundec=%d\n",
3640
 
                  dtoh32(cnt.rxundec));
 
3633
                  le32_to_cpu(cnt.rxundec));
3641
3634
        WL_TRACE("wl_iw_get_wireless_stats counters rxfragerr=%d\n",
3642
 
                  dtoh32(cnt.rxfragerr));
 
3635
                  le32_to_cpu(cnt.rxfragerr));
3643
3636
        WL_TRACE("wl_iw_get_wireless_stats counters txfail=%d\n",
3644
 
                  dtoh32(cnt.txfail));
 
3637
                  le32_to_cpu(cnt.txfail));
3645
3638
        WL_TRACE("wl_iw_get_wireless_stats counters rxrunt=%d\n",
3646
 
                  dtoh32(cnt.rxrunt));
 
3639
                  le32_to_cpu(cnt.rxrunt));
3647
3640
        WL_TRACE("wl_iw_get_wireless_stats counters rxgiant=%d\n",
3648
 
                  dtoh32(cnt.rxgiant));
 
3641
                  le32_to_cpu(cnt.rxgiant));
3649
3642
#endif                          /* WIRELESS_EXT > 11 */
3650
3643
 
3651
3644
done:
3673
3666
        params_size =
3674
3667
            (WL_SCAN_PARAMS_FIXED_SIZE + offsetof(wl_iscan_params_t, params));
3675
3668
#endif
3676
 
        iscan = kmalloc(sizeof(iscan_info_t), GFP_KERNEL);
 
3669
        iscan = kzalloc(sizeof(iscan_info_t), GFP_KERNEL);
3677
3670
 
3678
3671
        if (!iscan)
3679
3672
                return -ENOMEM;
3680
 
        memset(iscan, 0, sizeof(iscan_info_t));
3681
3673
 
3682
3674
        iscan->iscan_ex_params_p = kmalloc(params_size, GFP_KERNEL);
3683
3675
        if (!iscan->iscan_ex_params_p)
3711
3703
        priv_dev = dev;
3712
3704
        MUTEX_LOCK_SOFTAP_SET_INIT(iw->pub);
3713
3705
#endif
3714
 
        g_scan = kmalloc(G_SCAN_RESULTS, GFP_KERNEL);
 
3706
        g_scan = kzalloc(G_SCAN_RESULTS, GFP_KERNEL);
3715
3707
        if (!g_scan)
3716
3708
                return -ENOMEM;
3717
3709
 
3718
 
        memset(g_scan, 0, G_SCAN_RESULTS);
3719
3710
        g_scan_specified_ssid = 0;
3720
3711
 
3721
3712
        return 0;