~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/staging/brcm80211/brcmfmac/dhd_common.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <linux/string.h>
18
18
#include <bcmdefs.h>
19
19
#include <linux/netdevice.h>
20
 
#include <osl.h>
21
20
#include <bcmutils.h>
22
 
#include <bcmendian.h>
23
21
#include <dngl_stats.h>
24
22
#include <dhd.h>
25
23
#include <dhd_bus.h>
37
35
u32 dhd_conn_status;
38
36
u32 dhd_conn_reason;
39
37
 
40
 
#define htod32(i) i
41
 
#define htod16(i) i
42
 
#define dtoh32(i) i
43
 
#define dtoh16(i) i
44
 
 
45
38
extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf,
46
39
                            uint len);
47
40
extern void dhd_ind_scan_confirm(void *h, bool status);
57
50
#error DHD_SDALIGN is not a power of 2!
58
51
#endif
59
52
 
60
 
#ifdef DHD_DEBUG
61
53
#define EPI_VERSION_STR         "4.218.248.5"
 
54
#ifdef DHD_DEBUG
62
55
const char dhd_version[] =
63
56
"Dongle Host Driver, version " EPI_VERSION_STR "\nCompiled on " __DATE__
64
57
" at " __TIME__;
196
189
        /* Add any bus info */
197
190
        dhd_bus_dump(dhdp, strbuf);
198
191
 
199
 
        return !strbuf->size ? BCME_BUFTOOSHORT : 0;
 
192
        return !strbuf->size ? -EOVERFLOW : 0;
200
193
}
201
194
 
202
195
static int
214
207
                goto exit;
215
208
 
216
209
        if (plen >= (int)sizeof(int_val))
217
 
                bcopy(params, &int_val, sizeof(int_val));
 
210
                memcpy(&int_val, params, sizeof(int_val));
218
211
 
219
212
        switch (actionid) {
220
213
        case IOV_GVAL(IOV_VERSION):
224
217
 
225
218
        case IOV_GVAL(IOV_MSGLEVEL):
226
219
                int_val = (s32) dhd_msg_level;
227
 
                bcopy(&int_val, arg, val_size);
 
220
                memcpy(arg, &int_val, val_size);
228
221
                break;
229
222
 
230
223
        case IOV_SVAL(IOV_MSGLEVEL):
232
225
                break;
233
226
 
234
227
        case IOV_GVAL(IOV_BCMERRORSTR):
235
 
                strncpy((char *)arg, bcmerrorstr(dhd_pub->bcmerror),
 
228
                strncpy((char *)arg, "bcm_error",
236
229
                        BCME_STRLEN);
237
230
                ((char *)arg)[BCME_STRLEN - 1] = 0x00;
238
231
                break;
239
232
 
240
233
        case IOV_GVAL(IOV_BCMERROR):
241
234
                int_val = (s32) dhd_pub->bcmerror;
242
 
                bcopy(&int_val, arg, val_size);
 
235
                memcpy(arg, &int_val, val_size);
243
236
                break;
244
237
 
245
238
        case IOV_GVAL(IOV_WDTICK):
246
239
                int_val = (s32) dhd_watchdog_ms;
247
 
                bcopy(&int_val, arg, val_size);
 
240
                memcpy(arg, &int_val, val_size);
248
241
                break;
249
242
 
250
243
        case IOV_SVAL(IOV_WDTICK):
251
244
                if (!dhd_pub->up) {
252
 
                        bcmerror = BCME_NOTUP;
 
245
                        bcmerror = -ENOLINK;
253
246
                        break;
254
247
                }
255
248
                dhd_os_wd_timer(dhd_pub, (uint) int_val);
262
255
#ifdef DHD_DEBUG
263
256
        case IOV_GVAL(IOV_DCONSOLE_POLL):
264
257
                int_val = (s32) dhd_console_ms;
265
 
                bcopy(&int_val, arg, val_size);
 
258
                memcpy(arg, &int_val, val_size);
266
259
                break;
267
260
 
268
261
        case IOV_SVAL(IOV_DCONSOLE_POLL):
290
283
 
291
284
        case IOV_GVAL(IOV_IOCTLTIMEOUT):{
292
285
                        int_val = (s32) dhd_os_get_ioctl_resp_timeout();
293
 
                        bcopy(&int_val, arg, sizeof(int_val));
 
286
                        memcpy(arg, &int_val, sizeof(int_val));
294
287
                        break;
295
288
                }
296
289
 
297
290
        case IOV_SVAL(IOV_IOCTLTIMEOUT):{
298
291
                        if (int_val <= 0)
299
 
                                bcmerror = BCME_BADARG;
 
292
                                bcmerror = -EINVAL;
300
293
                        else
301
294
                                dhd_os_set_ioctl_resp_timeout((unsigned int)
302
295
                                                              int_val);
304
297
                }
305
298
 
306
299
        default:
307
 
                bcmerror = BCME_UNSUPPORTED;
 
300
                bcmerror = -ENOTSUPP;
308
301
                break;
309
302
        }
310
303
 
312
305
        return bcmerror;
313
306
}
314
307
 
315
 
/* Store the status of a connection attempt for later retrieval by an iovar */
316
 
void dhd_store_conn_status(u32 event, u32 status, u32 reason)
317
 
{
318
 
        /* Do not overwrite a WLC_E_PRUNE with a WLC_E_SET_SSID
319
 
         * because an encryption/rsn mismatch results in both events, and
320
 
         * the important information is in the WLC_E_PRUNE.
321
 
         */
322
 
        if (!(event == WLC_E_SET_SSID && status == WLC_E_STATUS_FAIL &&
323
 
              dhd_conn_event == WLC_E_PRUNE)) {
324
 
                dhd_conn_event = event;
325
 
                dhd_conn_status = status;
326
 
                dhd_conn_reason = reason;
327
 
        }
328
 
}
329
 
 
330
308
bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
331
309
                  int prec)
332
310
{
338
316
         * exceeding total queue length
339
317
         */
340
318
        if (!pktq_pfull(q, prec) && !pktq_full(q)) {
341
 
                pktq_penq(q, prec, pkt);
 
319
                bcm_pktq_penq(q, prec, pkt);
342
320
                return true;
343
321
        }
344
322
 
346
324
        if (pktq_pfull(q, prec))
347
325
                eprec = prec;
348
326
        else if (pktq_full(q)) {
349
 
                p = pktq_peek_tail(q, &eprec);
 
327
                p = bcm_pktq_peek_tail(q, &eprec);
350
328
                ASSERT(p);
351
329
                if (eprec > prec)
352
330
                        return false;
360
338
                if (eprec == prec && !discard_oldest)
361
339
                        return false;   /* refuse newer (incoming) packet */
362
340
                /* Evict packet according to discard policy */
363
 
                p = discard_oldest ? pktq_pdeq(q, eprec) : pktq_pdeq_tail(q,
364
 
                                                  eprec);
 
341
                p = discard_oldest ? bcm_pktq_pdeq(q, eprec) :
 
342
                        bcm_pktq_pdeq_tail(q, eprec);
365
343
                if (p == NULL) {
366
 
                        DHD_ERROR(("%s: pktq_penq() failed, oldest %d.",
 
344
                        DHD_ERROR(("%s: bcm_pktq_penq() failed, oldest %d.",
367
345
                                   __func__, discard_oldest));
368
346
                        ASSERT(p);
369
347
                }
370
348
 
371
 
                pkt_buf_free_skb(dhdp->osh, p, true);
 
349
                bcm_pkt_buf_free_skb(p);
372
350
        }
373
351
 
374
352
        /* Enqueue */
375
 
        p = pktq_penq(q, prec, pkt);
 
353
        p = bcm_pktq_penq(q, prec, pkt);
376
354
        if (p == NULL) {
377
 
                DHD_ERROR(("%s: pktq_penq() failed.", __func__));
 
355
                DHD_ERROR(("%s: bcm_pktq_penq() failed.", __func__));
378
356
                ASSERT(p);
379
357
        }
380
358
 
403
381
 
404
382
        vi = bcm_iovar_lookup(dhd_iovars, name);
405
383
        if (vi == NULL) {
406
 
                bcmerror = BCME_UNSUPPORTED;
 
384
                bcmerror = -ENOTSUPP;
407
385
                goto exit;
408
386
        }
409
387
 
442
420
        DHD_TRACE(("%s: Enter\n", __func__));
443
421
 
444
422
        if (!buf)
445
 
                return BCME_BADARG;
 
423
                return -EINVAL;
446
424
 
447
425
        switch (ioc->cmd) {
448
426
        case DHD_GET_MAGIC:
449
427
                if (buflen < sizeof(int))
450
 
                        bcmerror = BCME_BUFTOOSHORT;
 
428
                        bcmerror = -EOVERFLOW;
451
429
                else
452
430
                        *(int *)buf = DHD_IOCTL_MAGIC;
453
431
                break;
454
432
 
455
433
        case DHD_GET_VERSION:
456
434
                if (buflen < sizeof(int))
457
 
                        bcmerror = -BCME_BUFTOOSHORT;
 
435
                        bcmerror = -EOVERFLOW;
458
436
                else
459
437
                        *(int *)buf = DHD_IOCTL_VERSION;
460
438
                break;
470
448
                                ;
471
449
 
472
450
                        if (*arg) {
473
 
                                bcmerror = BCME_BUFTOOSHORT;
 
451
                                bcmerror = -EOVERFLOW;
474
452
                                break;
475
453
                        }
476
454
 
486
464
                                bcmerror =
487
465
                                    dhd_iovar_op(dhd_pub, buf, NULL, 0, arg,
488
466
                                                 arglen, IOV_SET);
489
 
                        if (bcmerror != BCME_UNSUPPORTED)
 
467
                        if (bcmerror != -ENOTSUPP)
490
468
                                break;
491
469
 
492
470
                        /* not in generic table, try protocol module */
498
476
                                bcmerror = dhd_prot_iovar_op(dhd_pub, buf,
499
477
                                                             NULL, 0, arg,
500
478
                                                             arglen, IOV_SET);
501
 
                        if (bcmerror != BCME_UNSUPPORTED)
 
479
                        if (bcmerror != -ENOTSUPP)
502
480
                                break;
503
481
 
504
482
                        /* if still not found, try bus module */
515
493
                }
516
494
 
517
495
        default:
518
 
                bcmerror = BCME_UNSUPPORTED;
 
496
                bcmerror = -ENOTSUPP;
519
497
        }
520
498
 
521
499
        return bcmerror;
592
570
                WLC_E_PFN_SCAN_COMPLETE, "SCAN_COMPLETE"}
593
571
        };
594
572
        uint event_type, flags, auth_type, datalen;
595
 
        event_type = ntoh32(event->event_type);
596
 
        flags = ntoh16(event->flags);
597
 
        status = ntoh32(event->status);
598
 
        reason = ntoh32(event->reason);
599
 
        auth_type = ntoh32(event->auth_type);
600
 
        datalen = ntoh32(event->datalen);
 
573
        event_type = be32_to_cpu(event->event_type);
 
574
        flags = be16_to_cpu(event->flags);
 
575
        status = be32_to_cpu(event->status);
 
576
        reason = be32_to_cpu(event->reason);
 
577
        auth_type = be32_to_cpu(event->auth_type);
 
578
        datalen = be32_to_cpu(event->datalen);
601
579
        /* debug dump of event messages */
602
 
        sprintf(eabuf, "%pM", event->addr.octet);
 
580
        sprintf(eabuf, "%pM", event->addr);
603
581
 
604
582
        event_name = "UNKNOWN";
605
583
        for (i = 0; i < ARRAY_SIZE(event_names); i++) {
608
586
        }
609
587
 
610
588
        DHD_EVENT(("EVENT: %s, event ID = %d\n", event_name, event_type));
 
589
        DHD_EVENT(("flags 0x%04x, status %d, reason %d, auth_type %d MAC %s\n",
 
590
                                flags, status, reason, auth_type, eabuf));
611
591
 
612
592
        if (flags & WLC_EVENT_MSG_LINK)
613
593
                link = true;
653
633
 
654
634
        case WLC_E_AUTH:
655
635
        case WLC_E_AUTH_IND:
656
 
                if (auth_type == DOT11_OPEN_SYSTEM)
 
636
                if (auth_type == WLAN_AUTH_OPEN)
657
637
                        auth_str = "Open System";
658
 
                else if (auth_type == DOT11_SHARED_KEY)
 
638
                else if (auth_type == WLAN_AUTH_SHARED_KEY)
659
639
                        auth_str = "Shared Key";
660
640
                else {
661
641
                        sprintf(err_msg, "AUTH unknown: %d", (int)auth_type);
754
734
                        memcpy(&hdr, buf, MSGTRACE_HDRLEN);
755
735
 
756
736
                        if (hdr.version != MSGTRACE_VERSION) {
757
 
                                printf
 
737
                                DHD_ERROR(
758
738
                                    ("\nMACEVENT: %s [unsupported version --> "
759
739
                                     "dhd version:%d dongle version:%d]\n",
760
 
                                     event_name, MSGTRACE_VERSION, hdr.version);
 
740
                                     event_name, MSGTRACE_VERSION, hdr.version)
 
741
                                );
761
742
                                /* Reset datalen to avoid display below */
762
743
                                datalen = 0;
763
744
                                break;
764
745
                        }
765
746
 
766
747
                        /* There are 2 bytes available at the end of data */
767
 
                        buf[MSGTRACE_HDRLEN + ntoh16(hdr.len)] = '\0';
 
748
                        buf[MSGTRACE_HDRLEN + be16_to_cpu(hdr.len)] = '\0';
768
749
 
769
 
                        if (ntoh32(hdr.discarded_bytes)
770
 
                            || ntoh32(hdr.discarded_printf)) {
771
 
                                printf
 
750
                        if (be32_to_cpu(hdr.discarded_bytes)
 
751
                            || be32_to_cpu(hdr.discarded_printf)) {
 
752
                                DHD_ERROR(
772
753
                                    ("\nWLC_E_TRACE: [Discarded traces in dongle -->"
773
754
                                     "discarded_bytes %d discarded_printf %d]\n",
774
 
                                     ntoh32(hdr.discarded_bytes),
775
 
                                     ntoh32(hdr.discarded_printf));
 
755
                                     be32_to_cpu(hdr.discarded_bytes),
 
756
                                     be32_to_cpu(hdr.discarded_printf)));
776
757
                        }
777
758
 
778
 
                        nblost = ntoh32(hdr.seqnum) - seqnum_prev - 1;
 
759
                        nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1;
779
760
                        if (nblost > 0) {
780
 
                                printf
 
761
                                DHD_ERROR(
781
762
                                    ("\nWLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n",
782
 
                                     ntoh32(hdr.seqnum), nblost);
 
763
                                     be32_to_cpu(hdr.seqnum), nblost));
783
764
                        }
784
 
                        seqnum_prev = ntoh32(hdr.seqnum);
 
765
                        seqnum_prev = be32_to_cpu(hdr.seqnum);
785
766
 
786
767
                        /* Display the trace buffer. Advance from \n to \n to
787
768
                         * avoid display big
790
771
                        p = (char *)&buf[MSGTRACE_HDRLEN];
791
772
                        while ((s = strstr(p, "\n")) != NULL) {
792
773
                                *s = '\0';
793
 
                                printf("%s\n", p);
 
774
                                printk(KERN_DEBUG"%s\n", p);
794
775
                                p = s + 1;
795
776
                        }
796
 
                        printf("%s\n", p);
 
777
                        printk(KERN_DEBUG "%s\n", p);
797
778
 
798
779
                        /* Reset datalen to avoid display below */
799
780
                        datalen = 0;
802
783
 
803
784
        case WLC_E_RSSI:
804
785
                DHD_EVENT(("MACEVENT: %s %d\n", event_name,
805
 
                           ntoh32(*((int *)event_data))));
 
786
                           be32_to_cpu(*((int *)event_data))));
806
787
                break;
807
788
 
808
789
        default:
836
817
 
837
818
        if (memcmp(BRCM_OUI, &pvt_data->bcm_hdr.oui[0], DOT11_OUI_LEN)) {
838
819
                DHD_ERROR(("%s: mismatched OUI, bailing\n", __func__));
839
 
                return BCME_ERROR;
 
820
                return -EBADE;
840
821
        }
841
822
 
842
823
        /* BRCM event pkt may be unaligned - use xxx_ua to load user_subtype. */
843
 
        if (ntoh16_ua((void *)&pvt_data->bcm_hdr.usr_subtype) !=
 
824
        if (get_unaligned_be16(&pvt_data->bcm_hdr.usr_subtype) !=
844
825
            BCMILCP_BCM_SUBTYPE_EVENT) {
845
826
                DHD_ERROR(("%s: mismatched subtype, bailing\n", __func__));
846
 
                return BCME_ERROR;
 
827
                return -EBADE;
847
828
        }
848
829
 
849
830
        *data_ptr = &pvt_data[1];
852
833
        /* memcpy since BRCM event pkt may be unaligned. */
853
834
        memcpy(event, &pvt_data->event, sizeof(wl_event_msg_t));
854
835
 
855
 
        type = ntoh32_ua((void *)&event->event_type);
856
 
        flags = ntoh16_ua((void *)&event->flags);
857
 
        status = ntoh32_ua((void *)&event->status);
858
 
        evlen = ntoh32_ua((void *)&event->datalen) + sizeof(bcm_event_t);
 
836
        type = get_unaligned_be32(&event->event_type);
 
837
        flags = get_unaligned_be16(&event->flags);
 
838
        status = get_unaligned_be32(&event->status);
 
839
        evlen = get_unaligned_be32(&event->datalen) + sizeof(bcm_event_t);
859
840
 
860
841
        switch (type) {
861
842
        case WLC_E_IF:
868
849
                                if (ifevent->action == WLC_E_IF_ADD)
869
850
                                        dhd_add_if(dhd, ifevent->ifidx,
870
851
                                                   NULL, event->ifname,
871
 
                                                   pvt_data->eth.ether_dhost,
 
852
                                                   pvt_data->eth.h_dest,
872
853
                                                   ifevent->flags,
873
854
                                                   ifevent->bssidx);
874
855
                                else
909
890
                if (type == WLC_E_NDIS_LINK) {
910
891
                        u32 temp;
911
892
 
912
 
                        temp = ntoh32_ua((void *)&event->event_type);
 
893
                        temp = get_unaligned_be32(&event->event_type);
913
894
                        DHD_TRACE(("Converted to WLC_E_LINK type %d\n", temp));
914
895
 
915
 
                        temp = ntoh32(WLC_E_NDIS_LINK);
 
896
                        temp = be32_to_cpu(WLC_E_NDIS_LINK);
916
897
                        memcpy((void *)(&pvt_data->event.event_type), &temp,
917
898
                               sizeof(pvt_data->event.event_type));
918
899
                }
923
904
        wl_show_host_event(event, event_data);
924
905
#endif                          /* SHOW_EVENTS */
925
906
 
926
 
        return BCME_OK;
927
 
}
928
 
 
929
 
void wl_event_to_host_order(wl_event_msg_t *evt)
930
 
{
931
 
        /* Event struct members passed from dongle to host are stored
932
 
         * in network
933
 
         * byte order. Convert all members to host-order.
934
 
         */
935
 
        evt->event_type = ntoh32(evt->event_type);
936
 
        evt->flags = ntoh16(evt->flags);
937
 
        evt->status = ntoh32(evt->status);
938
 
        evt->reason = ntoh32(evt->reason);
939
 
        evt->auth_type = ntoh32(evt->auth_type);
940
 
        evt->datalen = ntoh32(evt->datalen);
941
 
        evt->version = ntoh16(evt->version);
942
 
}
943
 
 
944
 
void print_buf(void *pbuf, int len, int bytes_per_line)
945
 
{
946
 
        int i, j = 0;
947
 
        unsigned char *buf = pbuf;
948
 
 
949
 
        if (bytes_per_line == 0)
950
 
                bytes_per_line = len;
951
 
 
952
 
        for (i = 0; i < len; i++) {
953
 
                printf("%2.2x", *buf++);
954
 
                j++;
955
 
                if (j == bytes_per_line) {
956
 
                        printf("\n");
957
 
                        j = 0;
958
 
                } else {
959
 
                        printf(":");
960
 
                }
961
 
        }
962
 
        printf("\n");
 
907
        return 0;
963
908
}
964
909
 
965
910
/* Convert user's input in hex pattern to byte-size mask */
1025
970
        pkt_filterp = (wl_pkt_filter_enable_t *) (buf + str_len + 1);
1026
971
 
1027
972
        /* Parse packet filter id. */
1028
 
        enable_parm.id = htod32(simple_strtoul(argv[i], NULL, 0));
 
973
        enable_parm.id = simple_strtoul(argv[i], NULL, 0);
1029
974
 
1030
975
        /* Parse enable/disable value. */
1031
 
        enable_parm.enable = htod32(enable);
 
976
        enable_parm.enable = enable;
1032
977
 
1033
978
        buf_len += sizeof(enable_parm);
1034
979
        memcpy((char *)pkt_filterp, &enable_parm, sizeof(enable_parm));
1053
998
                           __func__, arg, rc));
1054
999
 
1055
1000
fail:
1056
 
        if (arg_org)
1057
 
                kfree(arg_org);
 
1001
        kfree(arg_org);
1058
1002
}
1059
1003
 
1060
1004
void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
1113
1057
        pkt_filterp = (wl_pkt_filter_t *) (buf + str_len + 1);
1114
1058
 
1115
1059
        /* Parse packet filter id. */
1116
 
        pkt_filter.id = htod32(simple_strtoul(argv[i], NULL, 0));
 
1060
        pkt_filter.id = simple_strtoul(argv[i], NULL, 0);
1117
1061
 
1118
1062
        if (NULL == argv[++i]) {
1119
1063
                DHD_ERROR(("Polarity not provided\n"));
1121
1065
        }
1122
1066
 
1123
1067
        /* Parse filter polarity. */
1124
 
        pkt_filter.negate_match = htod32(simple_strtoul(argv[i], NULL, 0));
 
1068
        pkt_filter.negate_match = simple_strtoul(argv[i], NULL, 0);
1125
1069
 
1126
1070
        if (NULL == argv[++i]) {
1127
1071
                DHD_ERROR(("Filter type not provided\n"));
1129
1073
        }
1130
1074
 
1131
1075
        /* Parse filter type. */
1132
 
        pkt_filter.type = htod32(simple_strtoul(argv[i], NULL, 0));
 
1076
        pkt_filter.type = simple_strtoul(argv[i], NULL, 0);
1133
1077
 
1134
1078
        if (NULL == argv[++i]) {
1135
1079
                DHD_ERROR(("Offset not provided\n"));
1137
1081
        }
1138
1082
 
1139
1083
        /* Parse pattern filter offset. */
1140
 
        pkt_filter.u.pattern.offset = htod32(simple_strtoul(argv[i], NULL, 0));
 
1084
        pkt_filter.u.pattern.offset = simple_strtoul(argv[i], NULL, 0);
1141
1085
 
1142
1086
        if (NULL == argv[++i]) {
1143
1087
                DHD_ERROR(("Bitmask not provided\n"));
1146
1090
 
1147
1091
        /* Parse pattern filter mask. */
1148
1092
        mask_size =
1149
 
            htod32(wl_pattern_atoh
1150
 
                   (argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern));
 
1093
            wl_pattern_atoh
 
1094
                   (argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern);
1151
1095
 
1152
1096
        if (NULL == argv[++i]) {
1153
1097
                DHD_ERROR(("Pattern not provided\n"));
1156
1100
 
1157
1101
        /* Parse pattern filter pattern. */
1158
1102
        pattern_size =
1159
 
            htod32(wl_pattern_atoh(argv[i],
 
1103
            wl_pattern_atoh(argv[i],
1160
1104
                                   (char *)&pkt_filterp->u.pattern.
1161
 
                                   mask_and_pattern[mask_size]));
 
1105
                                   mask_and_pattern[mask_size]);
1162
1106
 
1163
1107
        if (mask_size != pattern_size) {
1164
1108
                DHD_ERROR(("Mask and pattern not the same size\n"));
1189
1133
                           __func__, arg));
1190
1134
 
1191
1135
fail:
1192
 
        if (arg_org)
1193
 
                kfree(arg_org);
 
1136
        kfree(arg_org);
1194
1137
 
1195
 
        if (buf)
1196
 
                kfree(buf);
 
1138
        kfree(buf);
1197
1139
}
1198
1140
 
1199
1141
void dhd_arp_offload_set(dhd_pub_t *dhd, int arp_mode)
1242
1184
        int scan_unassoc_time = 40;
1243
1185
#ifdef GET_CUSTOM_MAC_ENABLE
1244
1186
        int ret = 0;
1245
 
        struct ether_addr ea_addr;
 
1187
        u8 ea_addr[ETH_ALEN];
1246
1188
#endif                          /* GET_CUSTOM_MAC_ENABLE */
1247
1189
 
1248
1190
        dhd_os_proto_block(dhd);
1254
1196
         ** firmware but unique per board mac address maybe provided by
1255
1197
         ** customer code
1256
1198
         */
1257
 
        ret = dhd_custom_get_mac_address(ea_addr.octet);
 
1199
        ret = dhd_custom_get_mac_address(ea_addr);
1258
1200
        if (!ret) {
1259
 
                bcm_mkiovar("cur_etheraddr", (void *)&ea_addr, ETH_ALEN,
 
1201
                bcm_mkiovar("cur_etheraddr", (void *)ea_addr, ETH_ALEN,
1260
1202
                            buf, sizeof(buf));
1261
1203
                ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
1262
1204
                if (ret < 0) {
1478
1420
                                   bi->BSSID.octet[2], bi->BSSID.octet[3],
1479
1421
                                   bi->BSSID.octet[4], bi->BSSID.octet[5]));
1480
1422
 
1481
 
                        bi = (wl_bss_info_t *)((unsigned long)bi +
1482
 
                                                dtoh32(bi->length));
 
1423
                        bi = (wl_bss_info_t *)((unsigned long)bi + bi->length);
1483
1424
                }
1484
1425
                iscan_cur = iscan_cur->next;
1485
1426
                l++;
1543
1484
                                        bi->BSSID.octet[5]));
1544
1485
 
1545
1486
                                        bi_new = bi;
1546
 
                                        bi = (wl_bss_info_t *)((unsigned long)bi +
1547
 
                                                                dtoh32
1548
 
                                                                (bi->length));
 
1487
                                        bi = (wl_bss_info_t *)((unsigned long)
 
1488
                                                               bi + bi->length);
1549
1489
/*
1550
1490
                        if(bi && bi_new) {
1551
 
                                bcopy(bi, bi_new, results->buflen -
1552
 
                                dtoh32(bi_new->length));
1553
 
                                results->buflen -= dtoh32(bi_new->length);
 
1491
                                memcpy(bi_new, bi, results->buflen -
 
1492
                                bi_new->length);
 
1493
                                results->buflen -= bi_new->length;
1554
1494
                        }
1555
1495
*/
1556
 
                                        results->buflen -=
1557
 
                                            dtoh32(bi_new->length);
 
1496
                                        results->buflen -= bi_new->length;
1558
1497
                                        results->count--;
1559
1498
 
1560
1499
                                        for (j = i; j < results->count; j++) {
1570
1509
 
1571
1510
                                                        bi_next =
1572
1511
                                                            (wl_bss_info_t *)((unsigned long)bi +
1573
 
                                                                 dtoh32
1574
 
                                                                 (bi->length));
1575
 
                                                        bcopy(bi, bi_new,
1576
 
                                                              dtoh32
1577
 
                                                              (bi->length));
 
1512
                                                                 bi->length);
 
1513
                                                        memcpy(bi_new, bi,
 
1514
                                                              bi->length);
1578
1515
                                                        bi_new =
1579
1516
                                                            (wl_bss_info_t *)((unsigned long)bi_new +
1580
 
                                                                 dtoh32
1581
 
                                                                 (bi_new->
1582
 
                                                                  length));
 
1517
                                                                 bi_new->
 
1518
                                                                  length);
1583
1519
                                                        bi = bi_next;
1584
1520
                                                }
1585
1521
                                        }
1594
1530
                                        break;
1595
1531
                                }
1596
1532
                                bi = (wl_bss_info_t *)((unsigned long)bi +
1597
 
                                                        dtoh32(bi->length));
 
1533
                                                        bi->length);
1598
1534
                        }
1599
1535
                }
1600
1536
                iscan_cur = iscan_cur->next;
1648
1584
 
1649
1585
                dhd_iscan_delete_bss(dhdp, bi->BSSID.octet, iscan_cur);
1650
1586
 
1651
 
                bi = (wl_bss_info_t *)((unsigned long)bi + dtoh32(bi->length));
 
1587
                bi = (wl_bss_info_t *)((unsigned long)bi + bi->length);
1652
1588
        }
1653
1589
 
1654
1590
done:
1677
1613
        params.params.bss_type = DOT11_BSSTYPE_ANY;
1678
1614
        params.params.scan_type = DOT11_SCANTYPE_ACTIVE;
1679
1615
 
1680
 
        params.params.nprobes = htod32(-1);
1681
 
        params.params.active_time = htod32(-1);
1682
 
        params.params.passive_time = htod32(-1);
1683
 
        params.params.home_time = htod32(-1);
1684
 
        params.params.channel_num = htod32(0);
 
1616
        params.params.nprobes = -1;
 
1617
        params.params.active_time = -1;
 
1618
        params.params.passive_time = -1;
 
1619
        params.params.home_time = -1;
 
1620
        params.params.channel_num = 0;
1685
1621
 
1686
 
        params.version = htod32(ISCAN_REQ_VERSION);
1687
 
        params.action = htod16(action);
1688
 
        params.scan_duration = htod16(0);
 
1622
        params.version = ISCAN_REQ_VERSION;
 
1623
        params.action = action;
 
1624
        params.scan_duration = 0;
1689
1625
 
1690
1626
        bcm_mkiovar("iscan", (char *)&params, sizeof(wl_iscan_params_t), buf,
1691
1627
                    WLC_IOCTL_SMLEN);
1722
1658
        results->count = 0;
1723
1659
 
1724
1660
        memset(&list, 0, sizeof(list));
1725
 
        list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN);
 
1661
        list.results.buflen = WLC_IW_ISCAN_MAXLEN;
1726
1662
        bcm_mkiovar("iscanresults", (char *)&list, WL_ISCAN_RESULTS_FIXED_SIZE,
1727
1663
                    iscan_cur->iscan_buf, WLC_IW_ISCAN_MAXLEN);
1728
1664
        rc = dhd_wl_ioctl(dhdp, WLC_GET_VAR, iscan_cur->iscan_buf,
1729
1665
                          WLC_IW_ISCAN_MAXLEN);
1730
1666
 
1731
 
        results->buflen = dtoh32(results->buflen);
1732
 
        results->version = dtoh32(results->version);
1733
 
        *scan_count = results->count = dtoh32(results->count);
1734
 
        status = dtoh32(list_buf->status);
 
1667
        results->buflen = results->buflen;
 
1668
        results->version = results->version;
 
1669
        *scan_count = results->count = results->count;
 
1670
        status = list_buf->status;
1735
1671
 
1736
1672
        dhd_iscan_unlock();
1737
1673
 
1854
1790
        memset(&pfn_element, 0, sizeof(pfn_element));
1855
1791
 
1856
1792
        /* set pfn parameters */
1857
 
        pfn_param.version = htod32(PFN_VERSION);
1858
 
        pfn_param.flags = htod16((PFN_LIST_ORDER << SORT_CRITERIA_BIT));
 
1793
        pfn_param.version = PFN_VERSION;
 
1794
        pfn_param.flags = (PFN_LIST_ORDER << SORT_CRITERIA_BIT);
1859
1795
 
1860
1796
        /* set up pno scan fr */
1861
1797
        if (scan_fr != 0)
1862
 
                pfn_param.scan_freq = htod32(scan_fr);
 
1798
                pfn_param.scan_freq = scan_fr;
1863
1799
 
1864
1800
        bcm_mkiovar("pfn_set", (char *)&pfn_param, sizeof(pfn_param), iovbuf,
1865
1801
                    sizeof(iovbuf));
1868
1804
        /* set all pfn ssid */
1869
1805
        for (i = 0; i < nssid; i++) {
1870
1806
 
1871
 
                pfn_element.bss_type = htod32(DOT11_BSSTYPE_INFRASTRUCTURE);
1872
 
                pfn_element.auth = (DOT11_OPEN_SYSTEM);
1873
 
                pfn_element.wpa_auth = htod32(WPA_AUTH_PFN_ANY);
1874
 
                pfn_element.wsec = htod32(0);
1875
 
                pfn_element.infra = htod32(1);
 
1807
                pfn_element.bss_type = DOT11_BSSTYPE_INFRASTRUCTURE;
 
1808
                pfn_element.auth = WLAN_AUTH_OPEN;
 
1809
                pfn_element.wpa_auth = WPA_AUTH_PFN_ANY;
 
1810
                pfn_element.wsec = 0;
 
1811
                pfn_element.infra = 1;
1876
1812
 
1877
1813
                memcpy((char *)pfn_element.ssid.SSID, ssids_local[i].SSID,
1878
1814
                       ssids_local[i].SSID_len);