37
35
u32 dhd_conn_status;
38
36
u32 dhd_conn_reason;
45
38
extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf,
47
40
extern void dhd_ind_scan_confirm(void *h, bool status);
57
50
#error DHD_SDALIGN is not a power of 2!
61
53
#define EPI_VERSION_STR "4.218.248.5"
62
55
const char dhd_version[] =
63
56
"Dongle Host Driver, version " EPI_VERSION_STR "\nCompiled on " __DATE__
216
209
if (plen >= (int)sizeof(int_val))
217
bcopy(params, &int_val, sizeof(int_val));
210
memcpy(&int_val, params, sizeof(int_val));
219
212
switch (actionid) {
220
213
case IOV_GVAL(IOV_VERSION):
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);
230
223
case IOV_SVAL(IOV_MSGLEVEL):
234
227
case IOV_GVAL(IOV_BCMERRORSTR):
235
strncpy((char *)arg, bcmerrorstr(dhd_pub->bcmerror),
228
strncpy((char *)arg, "bcm_error",
237
230
((char *)arg)[BCME_STRLEN - 1] = 0x00;
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);
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);
250
243
case IOV_SVAL(IOV_WDTICK):
251
244
if (!dhd_pub->up) {
252
bcmerror = BCME_NOTUP;
255
248
dhd_os_wd_timer(dhd_pub, (uint) int_val);
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);
268
261
case IOV_SVAL(IOV_DCONSOLE_POLL):
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));
297
290
case IOV_SVAL(IOV_IOCTLTIMEOUT):{
298
291
if (int_val <= 0)
299
bcmerror = BCME_BADARG;
301
294
dhd_os_set_ioctl_resp_timeout((unsigned int)
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)
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.
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;
330
308
bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
338
316
* exceeding total queue length
340
318
if (!pktq_pfull(q, prec) && !pktq_full(q)) {
341
pktq_penq(q, prec, pkt);
319
bcm_pktq_penq(q, prec, pkt);
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,
341
p = discard_oldest ? bcm_pktq_pdeq(q, eprec) :
342
bcm_pktq_pdeq_tail(q, eprec);
366
DHD_ERROR(("%s: pktq_penq() failed, oldest %d.",
344
DHD_ERROR(("%s: bcm_pktq_penq() failed, oldest %d.",
367
345
__func__, discard_oldest));
371
pkt_buf_free_skb(dhdp->osh, p, true);
349
bcm_pkt_buf_free_skb(p);
375
p = pktq_penq(q, prec, pkt);
353
p = bcm_pktq_penq(q, prec, pkt);
377
DHD_ERROR(("%s: pktq_penq() failed.", __func__));
355
DHD_ERROR(("%s: bcm_pktq_penq() failed.", __func__));
442
420
DHD_TRACE(("%s: Enter\n", __func__));
447
425
switch (ioc->cmd) {
448
426
case DHD_GET_MAGIC:
449
427
if (buflen < sizeof(int))
450
bcmerror = BCME_BUFTOOSHORT;
428
bcmerror = -EOVERFLOW;
452
430
*(int *)buf = DHD_IOCTL_MAGIC;
455
433
case DHD_GET_VERSION:
456
434
if (buflen < sizeof(int))
457
bcmerror = -BCME_BUFTOOSHORT;
435
bcmerror = -EOVERFLOW;
459
437
*(int *)buf = DHD_IOCTL_VERSION;
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)
492
470
/* not in generic table, try protocol module */
498
476
bcmerror = dhd_prot_iovar_op(dhd_pub, buf,
500
478
arglen, IOV_SET);
501
if (bcmerror != BCME_UNSUPPORTED)
479
if (bcmerror != -ENOTSUPP)
504
482
/* if still not found, try bus module */
592
570
WLC_E_PFN_SCAN_COMPLETE, "SCAN_COMPLETE"}
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);
604
582
event_name = "UNKNOWN";
605
583
for (i = 0; i < ARRAY_SIZE(event_names); i++) {
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));
612
592
if (flags & WLC_EVENT_MSG_LINK)
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";
661
641
sprintf(err_msg, "AUTH unknown: %d", (int)auth_type);
754
734
memcpy(&hdr, buf, MSGTRACE_HDRLEN);
756
736
if (hdr.version != MSGTRACE_VERSION) {
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)
761
742
/* Reset datalen to avoid display below */
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';
769
if (ntoh32(hdr.discarded_bytes)
770
|| ntoh32(hdr.discarded_printf)) {
750
if (be32_to_cpu(hdr.discarded_bytes)
751
|| be32_to_cpu(hdr.discarded_printf)) {
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)));
778
nblost = ntoh32(hdr.seqnum) - seqnum_prev - 1;
759
nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1;
779
760
if (nblost > 0) {
781
762
("\nWLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n",
782
ntoh32(hdr.seqnum), nblost);
763
be32_to_cpu(hdr.seqnum), nblost));
784
seqnum_prev = ntoh32(hdr.seqnum);
765
seqnum_prev = be32_to_cpu(hdr.seqnum);
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) {
774
printk(KERN_DEBUG"%s\n", p);
777
printk(KERN_DEBUG "%s\n", p);
798
779
/* Reset datalen to avoid display below */
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__));
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__));
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));
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);
909
890
if (type == WLC_E_NDIS_LINK) {
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));
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));
923
904
wl_show_host_event(event, event_data);
924
905
#endif /* SHOW_EVENTS */
929
void wl_event_to_host_order(wl_event_msg_t *evt)
931
/* Event struct members passed from dongle to host are stored
933
* byte order. Convert all members to host-order.
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);
944
void print_buf(void *pbuf, int len, int bytes_per_line)
947
unsigned char *buf = pbuf;
949
if (bytes_per_line == 0)
950
bytes_per_line = len;
952
for (i = 0; i < len; i++) {
953
printf("%2.2x", *buf++);
955
if (j == bytes_per_line) {
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);
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);
1030
975
/* Parse enable/disable value. */
1031
enable_parm.enable = htod32(enable);
976
enable_parm.enable = enable;
1033
978
buf_len += sizeof(enable_parm);
1034
979
memcpy((char *)pkt_filterp, &enable_parm, sizeof(enable_parm));
1113
1057
pkt_filterp = (wl_pkt_filter_t *) (buf + str_len + 1);
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);
1118
1062
if (NULL == argv[++i]) {
1119
1063
DHD_ERROR(("Polarity not provided\n"));
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);
1126
1070
if (NULL == argv[++i]) {
1127
1071
DHD_ERROR(("Filter type not provided\n"));
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);
1134
1078
if (NULL == argv[++i]) {
1135
1079
DHD_ERROR(("Offset not provided\n"));
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);
1142
1086
if (NULL == argv[++i]) {
1143
1087
DHD_ERROR(("Bitmask not provided\n"));
1147
1091
/* Parse pattern filter mask. */
1149
htod32(wl_pattern_atoh
1150
(argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern));
1094
(argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern);
1152
1096
if (NULL == argv[++i]) {
1153
1097
DHD_ERROR(("Pattern not provided\n"));
1157
1101
/* Parse pattern filter pattern. */
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]);
1163
1107
if (mask_size != pattern_size) {
1164
1108
DHD_ERROR(("Mask and pattern not the same size\n"));
1254
1196
** firmware but unique per board mac address maybe provided by
1255
1197
** customer code
1257
ret = dhd_custom_get_mac_address(ea_addr.octet);
1199
ret = dhd_custom_get_mac_address(ea_addr);
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));
1478
1420
bi->BSSID.octet[2], bi->BSSID.octet[3],
1479
1421
bi->BSSID.octet[4], bi->BSSID.octet[5]));
1481
bi = (wl_bss_info_t *)((unsigned long)bi +
1482
dtoh32(bi->length));
1423
bi = (wl_bss_info_t *)((unsigned long)bi + bi->length);
1484
1425
iscan_cur = iscan_cur->next;
1543
1484
bi->BSSID.octet[5]));
1546
bi = (wl_bss_info_t *)((unsigned long)bi +
1487
bi = (wl_bss_info_t *)((unsigned long)
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 -
1493
results->buflen -= bi_new->length;
1557
dtoh32(bi_new->length);
1496
results->buflen -= bi_new->length;
1558
1497
results->count--;
1560
1499
for (j = i; j < results->count; j++) {
1677
1613
params.params.bss_type = DOT11_BSSTYPE_ANY;
1678
1614
params.params.scan_type = DOT11_SCANTYPE_ACTIVE;
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;
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;
1690
1626
bcm_mkiovar("iscan", (char *)¶ms, sizeof(wl_iscan_params_t), buf,
1691
1627
WLC_IOCTL_SMLEN);
1722
1658
results->count = 0;
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);
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;
1736
1672
dhd_iscan_unlock();
1854
1790
memset(&pfn_element, 0, sizeof(pfn_element));
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);
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;
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++) {
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;
1877
1813
memcpy((char *)pfn_element.ssid.SSID, ssids_local[i].SSID,
1878
1814
ssids_local[i].SSID_len);