Lines Matching +full:entry +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0-only
6 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
8 * Copyright (c) 2002-2005, Jouni Malinen <j@w1.fi>
11 * - there is currently no way of associating TX packets to correct wds device
24 * host and card memories. BAP0 accesses are protected with local->baplock
82 MODULE_PARM_DESC(dev_template, "Prefix for network device name (default: "
88 /* check WTERR events (Wait Time-out) in development versions */
153 regs->cmd = HFA384X_INW(HFA384X_CMD_OFF); in hfa384x_read_regs()
154 regs->evstat = HFA384X_INW(HFA384X_EVSTAT_OFF); in hfa384x_read_regs()
155 regs->offset0 = HFA384X_INW(HFA384X_OFFSET0_OFF); in hfa384x_read_regs()
156 regs->offset1 = HFA384X_INW(HFA384X_OFFSET1_OFF); in hfa384x_read_regs()
157 regs->swsupport0 = HFA384X_INW(HFA384X_SWSUPPORT0_OFF); in hfa384x_read_regs()
162 * __hostap_cmd_queue_free - Free Prism2 command queue entry (private)
164 * @entry: Prism2 command queue entry to be freed
165 * @del_req: request the entry to be removed
168 * Caller must have acquired local->cmdlock before calling this function.
171 struct hostap_cmd_queue *entry, in __hostap_cmd_queue_free() argument
175 entry->del_req = 1; in __hostap_cmd_queue_free()
176 if (!list_empty(&entry->list)) { in __hostap_cmd_queue_free()
177 list_del_init(&entry->list); in __hostap_cmd_queue_free()
178 local->cmd_queue_len--; in __hostap_cmd_queue_free()
182 if (refcount_dec_and_test(&entry->usecnt) && entry->del_req) in __hostap_cmd_queue_free()
183 kfree(entry); in __hostap_cmd_queue_free()
188 * hostap_cmd_queue_free - Free Prism2 command queue entry
190 * @entry: Prism2 command queue entry to be freed
191 * @del_req: request the entry to be removed
193 * Free a Prism2 command queue entry.
196 struct hostap_cmd_queue *entry, in hostap_cmd_queue_free() argument
201 spin_lock_irqsave(&local->cmdlock, flags); in hostap_cmd_queue_free()
202 __hostap_cmd_queue_free(local, entry, del_req); in hostap_cmd_queue_free()
203 spin_unlock_irqrestore(&local->cmdlock, flags); in hostap_cmd_queue_free()
208 * prism2_clear_cmd_queue - Free all pending Prism2 command queue entries
215 struct hostap_cmd_queue *entry; in prism2_clear_cmd_queue() local
217 spin_lock_irqsave(&local->cmdlock, flags); in prism2_clear_cmd_queue()
218 list_for_each_safe(ptr, n, &local->cmd_queue) { in prism2_clear_cmd_queue()
219 entry = list_entry(ptr, struct hostap_cmd_queue, list); in prism2_clear_cmd_queue()
220 refcount_inc(&entry->usecnt); in prism2_clear_cmd_queue()
221 printk(KERN_DEBUG "%s: removed pending cmd_queue entry " in prism2_clear_cmd_queue()
223 local->dev->name, entry->type, entry->cmd, in prism2_clear_cmd_queue()
224 entry->param0); in prism2_clear_cmd_queue()
225 __hostap_cmd_queue_free(local, entry, 1); in prism2_clear_cmd_queue()
227 if (local->cmd_queue_len) { in prism2_clear_cmd_queue()
231 "flush\n", local->dev->name, local->cmd_queue_len); in prism2_clear_cmd_queue()
232 local->cmd_queue_len = 0; in prism2_clear_cmd_queue()
234 spin_unlock_irqrestore(&local->cmdlock, flags); in prism2_clear_cmd_queue()
239 * hfa384x_cmd_issue - Issue a Prism2 command to the hardware
241 * @entry: Prism2 command queue entry to be issued
244 struct hostap_cmd_queue *entry) in hfa384x_cmd_issue() argument
253 local = iface->local; in hfa384x_cmd_issue()
255 if (local->func->card_present && !local->func->card_present(local)) in hfa384x_cmd_issue()
256 return -ENODEV; in hfa384x_cmd_issue()
258 if (entry->issued) { in hfa384x_cmd_issue()
259 printk(KERN_DEBUG "%s: driver bug - re-issuing command @%p\n", in hfa384x_cmd_issue()
260 dev->name, entry); in hfa384x_cmd_issue()
267 tries--; in hfa384x_cmd_issue()
274 "for %d usec\n", dev->name, in hfa384x_cmd_issue()
275 HFA384X_CMD_BUSY_TIMEOUT - tries); in hfa384x_cmd_issue()
281 printk(KERN_DEBUG "%s: hfa384x_cmd_issue - timeout - " in hfa384x_cmd_issue()
282 "reg=0x%04x\n", dev->name, reg); in hfa384x_cmd_issue()
283 return -ETIMEDOUT; in hfa384x_cmd_issue()
287 spin_lock_irqsave(&local->cmdlock, flags); in hfa384x_cmd_issue()
288 HFA384X_OUTW(entry->param0, HFA384X_PARAM0_OFF); in hfa384x_cmd_issue()
289 HFA384X_OUTW(entry->param1, HFA384X_PARAM1_OFF); in hfa384x_cmd_issue()
290 HFA384X_OUTW(entry->cmd, HFA384X_CMD_OFF); in hfa384x_cmd_issue()
291 entry->issued = 1; in hfa384x_cmd_issue()
292 spin_unlock_irqrestore(&local->cmdlock, flags); in hfa384x_cmd_issue()
299 * hfa384x_cmd - Issue a Prism2 command and wait (sleep) for completion
317 struct hostap_cmd_queue *entry; in hfa384x_cmd() local
321 local = iface->local; in hfa384x_cmd()
323 if (local->cmd_queue_len >= HOSTAP_CMD_QUEUE_MAX_LEN) { in hfa384x_cmd()
325 dev->name); in hfa384x_cmd()
326 return -1; in hfa384x_cmd()
330 return -EINTR; in hfa384x_cmd()
332 entry = kzalloc(sizeof(*entry), GFP_ATOMIC); in hfa384x_cmd()
333 if (entry == NULL) in hfa384x_cmd()
334 return -ENOMEM; in hfa384x_cmd()
336 refcount_set(&entry->usecnt, 1); in hfa384x_cmd()
337 entry->type = CMD_SLEEP; in hfa384x_cmd()
338 entry->cmd = cmd; in hfa384x_cmd()
339 entry->param0 = param0; in hfa384x_cmd()
341 entry->param1 = *param1; in hfa384x_cmd()
342 init_waitqueue_head(&entry->compl); in hfa384x_cmd()
346 add_wait_queue(&entry->compl, &wait); in hfa384x_cmd()
349 spin_lock_irqsave(&local->cmdlock, flags); in hfa384x_cmd()
350 issue = list_empty(&local->cmd_queue); in hfa384x_cmd()
352 entry->issuing = 1; in hfa384x_cmd()
353 list_add_tail(&entry->list, &local->cmd_queue); in hfa384x_cmd()
354 local->cmd_queue_len++; in hfa384x_cmd()
355 spin_unlock_irqrestore(&local->cmdlock, flags); in hfa384x_cmd()
362 err = -EINTR; in hfa384x_cmd()
365 if (hfa384x_cmd_issue(dev, entry)) in hfa384x_cmd()
366 err = -ETIMEDOUT; in hfa384x_cmd()
372 if (!err && entry->type != CMD_COMPLETED) { in hfa384x_cmd()
376 res = -1; in hfa384x_cmd()
379 err = -EINTR; in hfa384x_cmd()
385 * of time to avoid removing entry from the list before in hfa384x_cmd()
391 remove_wait_queue(&entry->compl, &wait); in hfa384x_cmd()
393 /* If entry->list is still in the list, it must be removed in hfa384x_cmd()
400 * If the entry is not in the list prism2_cmd_ev() has a local in hfa384x_cmd()
404 /* FIX: if the entry->list is in the list, it has not been completed in hfa384x_cmd()
407 * dereference.. it would probably be better to leave the entry in the in hfa384x_cmd()
410 spin_lock_irqsave(&local->cmdlock, flags); in hfa384x_cmd()
411 if (!list_empty(&entry->list)) { in hfa384x_cmd()
412 printk(KERN_DEBUG "%s: hfa384x_cmd: entry still in list? " in hfa384x_cmd()
413 "(entry=%p, type=%d, res=%d)\n", dev->name, entry, in hfa384x_cmd()
414 entry->type, res); in hfa384x_cmd()
415 list_del_init(&entry->list); in hfa384x_cmd()
416 local->cmd_queue_len--; in hfa384x_cmd()
418 spin_unlock_irqrestore(&local->cmdlock, flags); in hfa384x_cmd()
422 dev->name, err); in hfa384x_cmd()
427 if (entry->type != CMD_COMPLETED) { in hfa384x_cmd()
430 "completed (res=%d, entry=%p, type=%d, cmd=0x%04x, " in hfa384x_cmd()
431 "param0=0x%04x, EVSTAT=%04x INTEN=%04x)\n", dev->name, in hfa384x_cmd()
432 res, entry, entry->type, entry->cmd, entry->param0, reg, in hfa384x_cmd()
436 * interrupt was not delivered - probably an issue in hfa384x_cmd()
437 * with pcmcia-cs configuration. */ in hfa384x_cmd()
439 "seem to work\n", dev->name); in hfa384x_cmd()
442 res = -ETIMEDOUT; in hfa384x_cmd()
447 *resp0 = entry->resp0; in hfa384x_cmd()
449 if (entry->res) { in hfa384x_cmd()
452 dev->name, cmd, entry->res, entry->resp0); in hfa384x_cmd()
456 res = entry->res; in hfa384x_cmd()
458 hostap_cmd_queue_free(local, entry, 1); in hfa384x_cmd()
464 * hfa384x_cmd_callback - Issue a Prism2 command; callback when completed
487 struct hostap_cmd_queue *entry; in hfa384x_cmd_callback() local
490 local = iface->local; in hfa384x_cmd_callback()
492 if (local->cmd_queue_len >= HOSTAP_CMD_QUEUE_MAX_LEN + 2) { in hfa384x_cmd_callback()
494 dev->name); in hfa384x_cmd_callback()
495 return -1; in hfa384x_cmd_callback()
498 entry = kzalloc(sizeof(*entry), GFP_ATOMIC); in hfa384x_cmd_callback()
499 if (entry == NULL) in hfa384x_cmd_callback()
500 return -ENOMEM; in hfa384x_cmd_callback()
502 refcount_set(&entry->usecnt, 1); in hfa384x_cmd_callback()
503 entry->type = CMD_CALLBACK; in hfa384x_cmd_callback()
504 entry->cmd = cmd; in hfa384x_cmd_callback()
505 entry->param0 = param0; in hfa384x_cmd_callback()
506 entry->callback = callback; in hfa384x_cmd_callback()
507 entry->context = context; in hfa384x_cmd_callback()
509 spin_lock_irqsave(&local->cmdlock, flags); in hfa384x_cmd_callback()
510 issue = list_empty(&local->cmd_queue); in hfa384x_cmd_callback()
512 entry->issuing = 1; in hfa384x_cmd_callback()
513 list_add_tail(&entry->list, &local->cmd_queue); in hfa384x_cmd_callback()
514 local->cmd_queue_len++; in hfa384x_cmd_callback()
515 spin_unlock_irqrestore(&local->cmdlock, flags); in hfa384x_cmd_callback()
517 if (issue && hfa384x_cmd_issue(dev, entry)) in hfa384x_cmd_callback()
518 ret = -ETIMEDOUT; in hfa384x_cmd_callback()
522 hostap_cmd_queue_free(local, entry, ret); in hfa384x_cmd_callback()
529 * __hfa384x_cmd_no_wait - Issue a Prism2 command (private)
547 tries--; in __hfa384x_cmd_no_wait()
553 printk(KERN_DEBUG "%s: __hfa384x_cmd_no_wait(%d) - timeout - " in __hfa384x_cmd_no_wait()
554 "reg=0x%04x\n", dev->name, io_debug_num, reg); in __hfa384x_cmd_no_wait()
555 return -ETIMEDOUT; in __hfa384x_cmd_no_wait()
567 * hfa384x_cmd_wait - Issue a Prism2 command and busy wait for completion
589 tries--; in hfa384x_cmd_wait()
595 printk(KERN_DEBUG "%s: hfa384x_cmd_wait - timeout2 - " in hfa384x_cmd_wait()
596 "reg=0x%04x\n", dev->name, reg); in hfa384x_cmd_wait()
597 return -ETIMEDOUT; in hfa384x_cmd_wait()
606 dev->name, cmd, res); in hfa384x_cmd_wait()
617 * hfa384x_cmd_no_wait - Issue a Prism2 command; do not wait for completion
630 * prism2_cmd_ev - Prism2 command completion event handler
643 struct hostap_cmd_queue *entry = NULL; in prism2_cmd_ev() local
646 local = iface->local; in prism2_cmd_ev()
648 spin_lock(&local->cmdlock); in prism2_cmd_ev()
649 if (!list_empty(&local->cmd_queue)) { in prism2_cmd_ev()
650 entry = list_entry(local->cmd_queue.next, in prism2_cmd_ev()
652 refcount_inc(&entry->usecnt); in prism2_cmd_ev()
653 list_del_init(&entry->list); in prism2_cmd_ev()
654 local->cmd_queue_len--; in prism2_cmd_ev()
656 if (!entry->issued) { in prism2_cmd_ev()
658 "cmd not issued\n", dev->name); in prism2_cmd_ev()
659 __hostap_cmd_queue_free(local, entry, 1); in prism2_cmd_ev()
660 entry = NULL; in prism2_cmd_ev()
663 spin_unlock(&local->cmdlock); in prism2_cmd_ev()
665 if (!entry) { in prism2_cmd_ev()
668 "pending commands\n", dev->name); in prism2_cmd_ev()
672 entry->resp0 = HFA384X_INW(HFA384X_RESP0_OFF); in prism2_cmd_ev()
673 entry->res = (HFA384X_INW(HFA384X_STATUS_OFF) & in prism2_cmd_ev()
679 if (entry->type == CMD_SLEEP) { in prism2_cmd_ev()
680 entry->type = CMD_COMPLETED; in prism2_cmd_ev()
681 wake_up_interruptible(&entry->compl); in prism2_cmd_ev()
682 } else if (entry->type == CMD_CALLBACK) { in prism2_cmd_ev()
683 if (entry->callback) in prism2_cmd_ev()
684 entry->callback(dev, entry->context, entry->resp0, in prism2_cmd_ev()
685 entry->res); in prism2_cmd_ev()
688 dev->name, entry->type); in prism2_cmd_ev()
690 hostap_cmd_queue_free(local, entry, 1); in prism2_cmd_ev()
693 entry = NULL; in prism2_cmd_ev()
694 spin_lock(&local->cmdlock); in prism2_cmd_ev()
695 if (!list_empty(&local->cmd_queue)) { in prism2_cmd_ev()
696 entry = list_entry(local->cmd_queue.next, in prism2_cmd_ev()
698 if (entry->issuing) { in prism2_cmd_ev()
701 entry = NULL; in prism2_cmd_ev()
703 if (entry) in prism2_cmd_ev()
704 refcount_inc(&entry->usecnt); in prism2_cmd_ev()
706 spin_unlock(&local->cmdlock); in prism2_cmd_ev()
708 if (entry) { in prism2_cmd_ev()
710 * entry from cmd_queue */ in prism2_cmd_ev()
711 int res = hfa384x_cmd_issue(dev, entry); in prism2_cmd_ev()
712 spin_lock(&local->cmdlock); in prism2_cmd_ev()
713 __hostap_cmd_queue_free(local, entry, res); in prism2_cmd_ev()
714 spin_unlock(&local->cmdlock); in prism2_cmd_ev()
725 tries--; in hfa384x_wait_offset()
741 return -EINVAL; in hfa384x_setup_bap()
753 printk(KERN_DEBUG "%s: hfa384x_setup_bap - timeout before\n", in hfa384x_setup_bap()
754 dev->name); in hfa384x_setup_bap()
755 ret = -ETIMEDOUT; in hfa384x_setup_bap()
764 printk(KERN_DEBUG "%s: hfa384x_setup_bap - timeout after\n", in hfa384x_setup_bap()
765 dev->name); in hfa384x_setup_bap()
766 ret = -ETIMEDOUT; in hfa384x_setup_bap()
772 printk(KERN_DEBUG "%s: hfa384x_setup_bap - offset error " in hfa384x_setup_bap()
774 dev->name, bap, id, offset, HFA384X_INW(o_off)); in hfa384x_setup_bap()
775 ret = -EINVAL; in hfa384x_setup_bap()
793 local = iface->local; in hfa384x_get_rid()
795 if (local->no_pri) { in hfa384x_get_rid()
796 printk(KERN_DEBUG "%s: cannot get RID %04x (len=%d) - no PRI " in hfa384x_get_rid()
797 "f/w\n", dev->name, rid, len); in hfa384x_get_rid()
798 return -ENOTTY; /* Well.. not really correct, but return in hfa384x_get_rid()
802 if ((local->func->card_present && !local->func->card_present(local)) || in hfa384x_get_rid()
803 local->hw_downloading) in hfa384x_get_rid()
804 return -ENODEV; in hfa384x_get_rid()
806 res = mutex_lock_interruptible(&local->rid_bap_mtx); in hfa384x_get_rid()
814 dev->name, res, rid, len); in hfa384x_get_rid()
815 mutex_unlock(&local->rid_bap_mtx); in hfa384x_get_rid()
819 spin_lock_bh(&local->baplock); in hfa384x_get_rid()
831 res = -ENODATA; in hfa384x_get_rid()
835 rlen = (le16_to_cpu(rec.len) - 1) * 2; in hfa384x_get_rid()
837 printk(KERN_DEBUG "%s: hfa384x_get_rid - RID len mismatch: " in hfa384x_get_rid()
839 dev->name, rid, rlen, len); in hfa384x_get_rid()
840 res = -ENODATA; in hfa384x_get_rid()
846 spin_unlock_bh(&local->baplock); in hfa384x_get_rid()
847 mutex_unlock(&local->rid_bap_mtx); in hfa384x_get_rid()
850 if (res != -ENODATA) in hfa384x_get_rid()
852 "len=%d) - failed - res=%d\n", dev->name, rid, in hfa384x_get_rid()
854 if (res == -ETIMEDOUT) in hfa384x_get_rid()
871 local = iface->local; in hfa384x_set_rid()
873 if (local->no_pri) { in hfa384x_set_rid()
874 printk(KERN_DEBUG "%s: cannot set RID %04x (len=%d) - no PRI " in hfa384x_set_rid()
875 "f/w\n", dev->name, rid, len); in hfa384x_set_rid()
876 return -ENOTTY; /* Well.. not really correct, but return in hfa384x_set_rid()
880 if ((local->func->card_present && !local->func->card_present(local)) || in hfa384x_set_rid()
881 local->hw_downloading) in hfa384x_set_rid()
882 return -ENODEV; in hfa384x_set_rid()
888 res = mutex_lock_interruptible(&local->rid_bap_mtx); in hfa384x_set_rid()
892 spin_lock_bh(&local->baplock); in hfa384x_set_rid()
898 spin_unlock_bh(&local->baplock); in hfa384x_set_rid()
901 printk(KERN_DEBUG "%s: hfa384x_set_rid (rid=%04x, len=%d) - " in hfa384x_set_rid()
902 "failed - res=%d\n", dev->name, rid, len, res); in hfa384x_set_rid()
903 mutex_unlock(&local->rid_bap_mtx); in hfa384x_set_rid()
908 mutex_unlock(&local->rid_bap_mtx); in hfa384x_set_rid()
913 dev->name, res, rid, len); in hfa384x_set_rid()
915 if (res == -ETIMEDOUT) in hfa384x_set_rid()
968 dev->name, len); in hfa384x_allocate_fid()
977 printk("%s: fid allocate, len=%d - timeout\n", dev->name, len); in hfa384x_allocate_fid()
995 local = iface->local; in prism2_reset_port()
997 if (!local->dev_enabled) in prism2_reset_port()
1004 dev->name); in prism2_reset_port()
1010 "port\n", dev->name); in prism2_reset_port()
1016 if (local->fragm_threshold != 2346 && in prism2_reset_port()
1018 local->fragm_threshold)) { in prism2_reset_port()
1021 dev->name, local->fragm_threshold); in prism2_reset_port()
1039 local = iface->local; in prism2_get_version_info()
1041 if (local->no_pri) { in prism2_get_version_info()
1042 /* PRI f/w not yet available - cannot read RIDs */ in prism2_get_version_info()
1043 return -1; in prism2_get_version_info()
1047 return -1; in prism2_get_version_info()
1050 printk(KERN_INFO "%s: %s: id=0x%02x v%d.%d.%d\n", dev->name, txt, in prism2_get_version_info()
1065 local = iface->local; in prism2_setup_rids()
1069 if (!local->fw_ap) { in prism2_setup_rids()
1074 dev->name, tmp1); in prism2_setup_rids()
1081 if (local->iw_mode != IW_MODE_MASTER || local->essid[0] != '\0') { in prism2_setup_rids()
1083 local->essid); in prism2_setup_rids()
1085 printk("%s: AP own SSID setting failed\n", dev->name); in prism2_setup_rids()
1094 dev->name, PRISM2_DATA_MAXLEN); in prism2_setup_rids()
1099 printk("%s: Channel list read failed\n", dev->name); in prism2_setup_rids()
1100 ret = -EINVAL; in prism2_setup_rids()
1103 local->channel_mask = le16_to_cpu(tmp); in prism2_setup_rids()
1105 if (local->channel < 1 || local->channel > 14 || in prism2_setup_rids()
1106 !(local->channel_mask & (1 << (local->channel - 1)))) { in prism2_setup_rids()
1108 "(%d)!\n", dev->name, local->channel); in prism2_setup_rids()
1109 ret = -EBUSY; in prism2_setup_rids()
1113 ret = hostap_set_word(dev, HFA384X_RID_CNFOWNCHANNEL, local->channel); in prism2_setup_rids()
1116 dev->name, local->channel); in prism2_setup_rids()
1121 local->beacon_int); in prism2_setup_rids()
1124 dev->name, local->beacon_int); in prism2_setup_rids()
1126 if (ret == -ETIMEDOUT) in prism2_setup_rids()
1131 local->dtim_period); in prism2_setup_rids()
1134 dev->name, local->dtim_period); in prism2_setup_rids()
1136 if (ret == -ETIMEDOUT) in prism2_setup_rids()
1141 local->is_promisc); in prism2_setup_rids()
1144 dev->name, local->is_promisc); in prism2_setup_rids()
1146 if (!local->fw_ap) { in prism2_setup_rids()
1148 local->essid); in prism2_setup_rids()
1150 printk("%s: Desired SSID setting failed\n", dev->name); in prism2_setup_rids()
1158 if (local->tx_rate_control == 0) { in prism2_setup_rids()
1159 local->tx_rate_control = in prism2_setup_rids()
1165 if (local->basic_rates == 0) in prism2_setup_rids()
1166 local->basic_rates = HFA384X_RATES_1MBPS | HFA384X_RATES_2MBPS; in prism2_setup_rids()
1168 if (!local->fw_ap) { in prism2_setup_rids()
1170 local->tx_rate_control); in prism2_setup_rids()
1173 dev->name, local->tx_rate_control); in prism2_setup_rids()
1178 local->tx_rate_control); in prism2_setup_rids()
1181 dev->name, local->tx_rate_control); in prism2_setup_rids()
1185 local->basic_rates); in prism2_setup_rids()
1188 dev->name, local->basic_rates); in prism2_setup_rids()
1194 dev->name); in prism2_setup_rids()
1198 if (local->name_set) in prism2_setup_rids()
1200 local->name); in prism2_setup_rids()
1204 dev->name); in prism2_setup_rids()
1211 dev->name); in prism2_setup_rids()
1214 if (local->sta_fw_ver >= PRISM2_FW_VER(1,6,3) && in prism2_setup_rids()
1215 hostap_set_word(dev, HFA384X_RID_CNFENHSECURITY, local->enh_sec)) in prism2_setup_rids()
1217 dev->name, local->enh_sec); in prism2_setup_rids()
1219 /* 32-bit tallies were added in STA f/w 0.8.0, but they were apparently in prism2_setup_rids()
1221 * This has been fixed in 0.8.2, so enable 32-bit tallies only in prism2_setup_rids()
1222 * beginning with that firmware version. Another bug fix for 32-bit in prism2_setup_rids()
1223 * tallies in 1.4.0; should 16-bit tallies be used for some other in prism2_setup_rids()
1225 if (local->sta_fw_ver >= PRISM2_FW_VER(0,8,2)) { in prism2_setup_rids()
1228 "failed\n", dev->name); in prism2_setup_rids()
1229 local->tallies32 = 0; in prism2_setup_rids()
1231 local->tallies32 = 1; in prism2_setup_rids()
1233 local->tallies32 = 0; in prism2_setup_rids()
1238 local->fragm_threshold)) { in prism2_setup_rids()
1240 "failed\n", dev->name, local->fragm_threshold); in prism2_setup_rids()
1244 local->rts_threshold)) { in prism2_setup_rids()
1246 dev->name, local->rts_threshold); in prism2_setup_rids()
1249 if (local->manual_retry_count >= 0 && in prism2_setup_rids()
1251 local->manual_retry_count)) { in prism2_setup_rids()
1253 dev->name, local->manual_retry_count); in prism2_setup_rids()
1256 if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1) && in prism2_setup_rids()
1258 local->rssi_to_dBm = le16_to_cpu(tmp); in prism2_setup_rids()
1261 if (local->sta_fw_ver >= PRISM2_FW_VER(1,7,0) && local->wpa && in prism2_setup_rids()
1264 dev->name); in prism2_setup_rids()
1267 if (local->sta_fw_ver >= PRISM2_FW_VER(1,7,0) && local->generic_elem && in prism2_setup_rids()
1269 local->generic_elem, local->generic_elem_len)) { in prism2_setup_rids()
1271 dev->name); in prism2_setup_rids()
1289 local = iface->local; in prism2_hw_init()
1291 clear_bit(HOSTAP_BITS_TRANSMIT, &local->bits); in prism2_hw_init()
1297 printk(KERN_INFO "%s: first command failed - assuming card " in prism2_hw_init()
1305 printk(KERN_DEBUG "%s: init command completed too quickly - " in prism2_hw_init()
1306 "retrying\n", dev->name); in prism2_hw_init()
1318 "flash - card initialization not completed\n", in prism2_hw_init()
1320 local->no_pri = 1; in prism2_hw_init()
1322 if (local->sram_type == -1) in prism2_hw_init()
1323 local->sram_type = prism2_get_ram_size(local); in prism2_hw_init()
1327 local->no_pri = 0; in prism2_hw_init()
1329 (jiffies - start) * 1000 / HZ); in prism2_hw_init()
1342 local = iface->local; in prism2_hw_init2()
1345 kfree(local->pda); in prism2_hw_init2()
1346 if (local->no_pri) in prism2_hw_init2()
1347 local->pda = NULL; in prism2_hw_init2()
1349 local->pda = prism2_read_pda(dev); in prism2_hw_init2()
1363 if (initial || local->pri_only) { in prism2_hw_init2()
1374 "- only Primary f/w present\n", dev->name); in prism2_hw_init2()
1375 local->pri_only = 1; in prism2_hw_init2()
1378 local->pri_only = 0; in prism2_hw_init2()
1387 local->txfid_len = PRISM2_TXFID_LEN; in prism2_hw_init2()
1389 local->txfid[i] = hfa384x_allocate_fid(dev, local->txfid_len); in prism2_hw_init2()
1390 if (local->txfid[i] == 0xffff && local->txfid_len > 1600) { in prism2_hw_init2()
1391 local->txfid[i] = hfa384x_allocate_fid(dev, 1600); in prism2_hw_init2()
1392 if (local->txfid[i] != 0xffff) { in prism2_hw_init2()
1394 "(1600 bytes)\n", dev->name); in prism2_hw_init2()
1395 local->txfid_len = 1600; in prism2_hw_init2()
1398 if (local->txfid[i] == 0xffff) in prism2_hw_init2()
1400 local->intransmitfid[i] = PRISM2_TXFID_EMPTY; in prism2_hw_init2()
1414 dev->name); in prism2_hw_init2()
1417 list_for_each(ptr, &local->hostap_interfaces) { in prism2_hw_init2()
1419 eth_hw_addr_inherit(iface->dev, dev); in prism2_hw_init2()
1421 } else if (local->fw_ap) in prism2_hw_init2()
1430 if (!local->no_pri) in prism2_hw_init2()
1443 local = iface->local; in prism2_hw_enable()
1444 was_resetting = local->hw_resetting; in prism2_hw_enable()
1447 printk("%s: MAC port 0 enabling failed\n", dev->name); in prism2_hw_enable()
1451 local->hw_ready = 1; in prism2_hw_enable()
1452 local->hw_reset_tries = 0; in prism2_hw_enable()
1453 local->hw_resetting = 0; in prism2_hw_enable()
1456 /* at least D-Link DWL-650 seems to require additional port reset in prism2_hw_enable()
1460 printk("%s: MAC port 0 resetting failed\n", dev->name); in prism2_hw_enable()
1481 local = iface->local; in prism2_hw_config()
1483 if (local->hw_downloading) in prism2_hw_config()
1487 return local->no_pri ? 0 : 1; in prism2_hw_config()
1495 if (!local->pri_only && in prism2_hw_config()
1496 (initial == 0 || (initial == 2 && local->num_dev_open > 0))) { in prism2_hw_config()
1497 if (!local->dev_enabled) in prism2_hw_config()
1499 local->dev_enabled = 1; in prism2_hw_config()
1513 local = iface->local; in prism2_hw_shutdown()
1518 local->hw_ready = 0; in prism2_hw_shutdown()
1519 if (local->dev_enabled) in prism2_hw_shutdown()
1521 local->dev_enabled = 0; in prism2_hw_shutdown()
1523 if (local->func->card_present && !local->func->card_present(local)) { in prism2_hw_shutdown()
1525 "during shutdown\n", dev->name); in prism2_hw_shutdown()
1558 local = iface->local; in prism2_hw_reset()
1560 if (local->hw_downloading) in prism2_hw_reset()
1563 if (local->hw_resetting) { in prism2_hw_reset()
1564 printk(KERN_WARNING "%s: %s: already resetting card - " in prism2_hw_reset()
1565 "ignoring reset request\n", dev_info, dev->name); in prism2_hw_reset()
1569 local->hw_reset_tries++; in prism2_hw_reset()
1570 if (local->hw_reset_tries > 10) { in prism2_hw_reset()
1572 dev->name); in prism2_hw_reset()
1576 printk(KERN_WARNING "%s: %s: resetting card\n", dev_info, dev->name); in prism2_hw_reset()
1578 local->hw_resetting = 1; in prism2_hw_reset()
1579 if (local->func->cor_sreset) { in prism2_hw_reset()
1586 disable_irq(dev->irq); in prism2_hw_reset()
1587 local->func->cor_sreset(local); in prism2_hw_reset()
1588 enable_irq(dev->irq); in prism2_hw_reset()
1592 local->hw_resetting = 0; in prism2_hw_reset()
1595 if (local->dl_pri) { in prism2_hw_reset()
1597 "firmware\n", dev->name); in prism2_hw_reset()
1598 if (prism2_download_genesis(local, local->dl_pri) < 0) in prism2_hw_reset()
1600 dev->name); in prism2_hw_reset()
1603 if (local->dl_sec) { in prism2_hw_reset()
1605 "firmware\n", dev->name); in prism2_hw_reset()
1606 if (prism2_download_volatile(local, local->dl_sec) < 0) in prism2_hw_reset()
1608 dev->name); in prism2_hw_reset()
1618 schedule_work(&local->reset_queue); in prism2_schedule_reset()
1628 printk(KERN_DEBUG "%s: scheduled card reset\n", local->dev->name); in handle_reset_queue()
1629 prism2_hw_reset(local->dev); in handle_reset_queue()
1631 if (netif_queue_stopped(local->dev)) { in handle_reset_queue()
1635 if (local->intransmitfid[i] == PRISM2_TXFID_EMPTY) { in handle_reset_queue()
1638 netif_wake_queue(local->dev); in handle_reset_queue()
1650 spin_lock_irqsave(&local->txfidlock, flags); in prism2_get_txfid_idx()
1651 end = idx = local->next_txfid; in prism2_get_txfid_idx()
1653 if (local->intransmitfid[idx] == PRISM2_TXFID_EMPTY) { in prism2_get_txfid_idx()
1654 local->intransmitfid[idx] = PRISM2_TXFID_RESERVED; in prism2_get_txfid_idx()
1655 spin_unlock_irqrestore(&local->txfidlock, flags); in prism2_get_txfid_idx()
1662 spin_unlock_irqrestore(&local->txfidlock, flags); in prism2_get_txfid_idx()
1666 local->dev->stats.tx_dropped++; in prism2_get_txfid_idx()
1668 return -1; in prism2_get_txfid_idx()
1681 local = iface->local; in prism2_transmit_cb()
1684 printk(KERN_DEBUG "%s: prism2_transmit_cb - res=0x%02x\n", in prism2_transmit_cb()
1685 dev->name, res); in prism2_transmit_cb()
1691 "idx=%d\n", dev->name, idx); in prism2_transmit_cb()
1695 if (!test_and_clear_bit(HOSTAP_BITS_TRANSMIT, &local->bits)) { in prism2_transmit_cb()
1697 "with no pending transmit\n", dev->name); in prism2_transmit_cb()
1706 spin_lock(&local->txfidlock); in prism2_transmit_cb()
1710 local->intransmitfid[idx] = resp0; in prism2_transmit_cb()
1714 dev->name, idx, local->txfid[idx], in prism2_transmit_cb()
1715 resp0, local->intransmitfid[local->next_txfid]); in prism2_transmit_cb()
1720 local->next_txfid = idx; in prism2_transmit_cb()
1724 if (local->intransmitfid[idx] == PRISM2_TXFID_EMPTY) { in prism2_transmit_cb()
1725 spin_unlock(&local->txfidlock); in prism2_transmit_cb()
1731 } while (idx != local->next_txfid); in prism2_transmit_cb()
1732 spin_unlock(&local->txfidlock); in prism2_transmit_cb()
1748 local = iface->local; in prism2_transmit()
1754 if (test_and_set_bit(HOSTAP_BITS_TRANSMIT, &local->bits)) { in prism2_transmit()
1755 printk(KERN_DEBUG "%s: driver bug - prism2_transmit() called " in prism2_transmit()
1756 "when previous TX was pending\n", dev->name); in prism2_transmit()
1757 return -1; in prism2_transmit()
1767 local->txfid[idx], in prism2_transmit()
1772 "failed (res=%d)\n", dev->name, res); in prism2_transmit()
1773 dev->stats.tx_dropped++; in prism2_transmit()
1775 return -1; in prism2_transmit()
1796 int hdr_len, data_len, idx, res, ret = -1; in prism2_tx_80211()
1800 local = iface->local; in prism2_tx_80211()
1802 meta = (struct hostap_skb_tx_data *) skb->cb; in prism2_tx_80211()
1806 if ((local->func->card_present && !local->func->card_present(local)) || in prism2_tx_80211()
1807 !local->hw_ready || local->hw_downloading || local->pri_only) { in prism2_tx_80211()
1809 printk(KERN_DEBUG "%s: prism2_tx_80211: hw not ready -" in prism2_tx_80211()
1810 " skipping\n", dev->name); in prism2_tx_80211()
1817 /* skb->data starts with txdesc->frame_control */ in prism2_tx_80211()
1823 skb->len >= 30) { in prism2_tx_80211()
1830 tx_control = local->tx_control; in prism2_tx_80211()
1831 if (meta->tx_cb_idx) { in prism2_tx_80211()
1833 txdesc.sw_support = cpu_to_le32(meta->tx_cb_idx); in prism2_tx_80211()
1836 txdesc.tx_rate = meta->rate; in prism2_tx_80211()
1838 data_len = skb->len - hdr_len; in prism2_tx_80211()
1846 if (local->frame_dump & PRISM2_DUMP_TX_HDR) in prism2_tx_80211()
1847 hostap_dump_tx_header(dev->name, &txdesc); in prism2_tx_80211()
1849 spin_lock(&local->baplock); in prism2_tx_80211()
1850 res = hfa384x_setup_bap(dev, BAP0, local->txfid[idx], 0); in prism2_tx_80211()
1855 res = hfa384x_to_bap(dev, BAP0, skb->data + hdr_len, in prism2_tx_80211()
1856 skb->len - hdr_len); in prism2_tx_80211()
1857 spin_unlock(&local->baplock); in prism2_tx_80211()
1862 printk(KERN_DEBUG "%s: prism2_tx_80211 - to BAP0 failed\n", in prism2_tx_80211()
1863 dev->name); in prism2_tx_80211()
1864 local->intransmitfid[idx] = PRISM2_TXFID_EMPTY; in prism2_tx_80211()
1865 schedule_work(&local->reset_queue); in prism2_tx_80211()
1900 dev->name, i, reg, val, val2, val3); in prism2_read_fid_reg()
1907 "%04x (%04x %04x %04x)\n", dev->name, reg, val, val2, val3); in prism2_read_fid_reg()
1918 struct net_device *dev = local->dev; in prism2_rx()
1933 schedule_work(&local->reset_queue); in prism2_rx()
1940 spin_lock(&local->baplock); in prism2_rx()
1946 spin_unlock(&local->baplock); in prism2_rx()
1947 printk(KERN_DEBUG "%s: copy from BAP0 failed %d\n", dev->name, in prism2_rx()
1949 if (res == -ETIMEDOUT) { in prism2_rx()
1950 schedule_work(&local->reset_queue); in prism2_rx()
1962 * negative value, so allow also values 65522 .. 65534 (-14 .. -2) for in prism2_rx()
1965 if (macport == 7 && local->iw_mode == IW_MODE_MONITOR) { in prism2_rx()
1966 if (len >= (u16) -14) { in prism2_rx()
1967 hdr_len -= 65535 - len; in prism2_rx()
1968 hdr_len--; in prism2_rx()
1972 spin_unlock(&local->baplock); in prism2_rx()
1974 "length 0x%04x\n", dev->name, len); in prism2_rx()
1975 hostap_dump_rx_header(dev->name, &rxdesc); in prism2_rx()
1982 spin_unlock(&local->baplock); in prism2_rx()
1984 dev->name); in prism2_rx()
1987 skb->dev = dev; in prism2_rx()
1992 spin_unlock(&local->baplock); in prism2_rx()
1995 "frame data\n", dev->name); in prism2_rx()
1999 skb_queue_tail(&local->rx_list, skb); in prism2_rx()
2000 tasklet_schedule(&local->rx_tasklet); in prism2_rx()
2011 dev->stats.rx_dropped++; in prism2_rx()
2022 struct net_device *dev = skb->dev; in hostap_rx_skb()
2027 if (skb->len < sizeof(*rxdesc)) { in hostap_rx_skb()
2029 if (local->iw_mode == IW_MODE_MONITOR && in hostap_rx_skb()
2030 skb->len >= sizeof(*rxdesc) - 30) { in hostap_rx_skb()
2031 rx_hdrlen = skb->len; in hostap_rx_skb()
2038 rxdesc = (struct hfa384x_rx_frame *) skb->data; in hostap_rx_skb()
2040 if (local->frame_dump & PRISM2_DUMP_RX_HDR && in hostap_rx_skb()
2041 skb->len >= sizeof(*rxdesc)) in hostap_rx_skb()
2042 hostap_dump_rx_header(dev->name, rxdesc); in hostap_rx_skb()
2044 if (le16_to_cpu(rxdesc->status) & HFA384X_RX_STATUS_FCSERR && in hostap_rx_skb()
2045 (!local->monitor_allow_fcserr || in hostap_rx_skb()
2046 local->iw_mode != IW_MODE_MONITOR)) in hostap_rx_skb()
2049 if (skb->len > PRISM2_DATA_MAXLEN) { in hostap_rx_skb()
2051 dev->name, skb->len, PRISM2_DATA_MAXLEN); in hostap_rx_skb()
2055 stats.mac_time = le32_to_cpu(rxdesc->time); in hostap_rx_skb()
2056 stats.signal = rxdesc->signal - local->rssi_to_dBm; in hostap_rx_skb()
2057 stats.noise = rxdesc->silence - local->rssi_to_dBm; in hostap_rx_skb()
2058 stats.rate = rxdesc->rate; in hostap_rx_skb()
2061 hdrlen = hostap_80211_get_hdrlen(rxdesc->frame_control); in hostap_rx_skb()
2065 memmove(skb_pull(skb, rx_hdrlen - hdrlen), in hostap_rx_skb()
2066 &rxdesc->frame_control, hdrlen); in hostap_rx_skb()
2082 while ((skb = skb_dequeue(&local->rx_list)) != NULL) in hostap_rx_tasklet()
2096 local = iface->local; in prism2_alloc_ev()
2100 PDEBUG(DEBUG_FID, "FID: interrupt: ALLOC - fid=0x%04x\n", fid); in prism2_alloc_ev()
2102 spin_lock(&local->txfidlock); in prism2_alloc_ev()
2103 idx = local->next_alloc; in prism2_alloc_ev()
2106 if (local->txfid[idx] == fid) { in prism2_alloc_ev()
2111 if (local->intransmitfid[idx] == PRISM2_TXFID_EMPTY) in prism2_alloc_ev()
2114 if (local->intransmitfid[idx] == PRISM2_TXFID_RESERVED) in prism2_alloc_ev()
2118 local->intransmitfid[idx] = PRISM2_TXFID_EMPTY; in prism2_alloc_ev()
2120 local->next_alloc = idx >= PRISM2_TXFID_COUNT ? 0 : in prism2_alloc_ev()
2123 if (!test_bit(HOSTAP_BITS_TRANSMIT, &local->bits) && in prism2_alloc_ev()
2127 spin_unlock(&local->txfidlock); in prism2_alloc_ev()
2134 } while (idx != local->next_alloc); in prism2_alloc_ev()
2137 "read 0x%04x) for alloc event\n", dev->name, fid, in prism2_alloc_ev()
2141 printk(" %04x[%04x]", local->txfid[idx], in prism2_alloc_ev()
2142 local->intransmitfid[idx]); in prism2_alloc_ev()
2144 spin_unlock(&local->txfidlock); in prism2_alloc_ev()
2163 if (!ether_addr_equal(txdesc->addr2, local->dev->dev_addr)) { in hostap_tx_callback()
2164 printk(KERN_DEBUG "%s: TX callback - foreign frame\n", in hostap_tx_callback()
2165 local->dev->name); in hostap_tx_callback()
2169 sw_support = le32_to_cpu(txdesc->sw_support); in hostap_tx_callback()
2171 spin_lock(&local->lock); in hostap_tx_callback()
2172 cb = local->tx_callback; in hostap_tx_callback()
2173 while (cb != NULL && cb->idx != sw_support) in hostap_tx_callback()
2174 cb = cb->next; in hostap_tx_callback()
2175 spin_unlock(&local->lock); in hostap_tx_callback()
2179 local->dev->name, sw_support); in hostap_tx_callback()
2183 hdrlen = hostap_80211_get_hdrlen(txdesc->frame_control); in hostap_tx_callback()
2184 len = le16_to_cpu(txdesc->data_len); in hostap_tx_callback()
2188 "skb\n", local->dev->name); in hostap_tx_callback()
2192 skb_put_data(skb, (void *)&txdesc->frame_control, hdrlen); in hostap_tx_callback()
2196 skb->dev = local->dev; in hostap_tx_callback()
2199 cb->func(skb, ok, cb->data); in hostap_tx_callback()
2210 struct net_device *dev = local->dev; in hostap_tx_compl_read()
2214 PDEBUG(DEBUG_FID, "interrupt: TX (err=%d) - fid=0x%04x\n", fid, error); in hostap_tx_compl_read()
2216 spin_lock(&local->baplock); in hostap_tx_compl_read()
2221 PDEBUG(DEBUG_EXTRA, "%s: TX (err=%d) - fid=0x%04x - could not " in hostap_tx_compl_read()
2222 "read txdesc\n", dev->name, error, fid); in hostap_tx_compl_read()
2223 if (res == -ETIMEDOUT) { in hostap_tx_compl_read()
2224 schedule_work(&local->reset_queue); in hostap_tx_compl_read()
2226 ret = -1; in hostap_tx_compl_read()
2229 if (txdesc->sw_support) { in hostap_tx_compl_read()
2230 len = le16_to_cpu(txdesc->data_len); in hostap_tx_compl_read()
2236 "frame payload\n", dev->name); in hostap_tx_compl_read()
2239 ret = -1; in hostap_tx_compl_read()
2246 spin_unlock(&local->baplock); in hostap_tx_compl_read()
2255 struct net_device *dev = local->dev; in prism2_tx_ev()
2262 if (local->frame_dump & PRISM2_DUMP_TX_HDR) { in prism2_tx_ev()
2263 PDEBUG(DEBUG_EXTRA, "%s: TX - status=0x%04x " in prism2_tx_ev()
2266 dev->name, le16_to_cpu(txdesc.status), in prism2_tx_ev()
2287 while ((skb = skb_dequeue(&local->sta_tx_exc_list)) != NULL) { in hostap_sta_tx_exc_tasklet()
2289 (struct hfa384x_tx_frame *) skb->data; in hostap_sta_tx_exc_tasklet()
2291 if (skb->len >= sizeof(*txdesc)) { in hostap_sta_tx_exc_tasklet()
2294 int hdrlen = hostap_80211_get_hdrlen(txdesc->frame_control); in hostap_sta_tx_exc_tasklet()
2295 memmove(skb_pull(skb, sizeof(*txdesc) - hdrlen), in hostap_sta_tx_exc_tasklet()
2296 &txdesc->frame_control, hdrlen); in hostap_sta_tx_exc_tasklet()
2308 struct net_device *dev = local->dev; in prism2_txexc()
2314 show_dump = local->frame_dump & PRISM2_DUMP_TXEXC_HDR; in prism2_txexc()
2315 dev->stats.tx_errors++; in prism2_txexc()
2327 * Other errors means that *we* screwed up. - Jean II */ in prism2_txexc()
2339 if (local->iw_mode == IW_MODE_MASTER || in prism2_txexc()
2340 local->iw_mode == IW_MODE_REPEAT || in prism2_txexc()
2341 local->wds_type & HOSTAP_WDS_AP_CLIENT) { in prism2_txexc()
2346 skb_queue_tail(&local->sta_tx_exc_list, skb); in prism2_txexc()
2347 tasklet_schedule(&local->sta_tx_exc_tasklet); in prism2_txexc()
2358 PDEBUG(DEBUG_EXTRA, "%s: TXEXC - status=0x%04x (%s%s%s%s)" in prism2_txexc()
2360 dev->name, status, in prism2_txexc()
2389 while ((skb = skb_dequeue(&local->info_list)) != NULL) { in hostap_info_tasklet()
2399 struct net_device *dev = local->dev; in prism2_info()
2407 spin_lock(&local->baplock); in prism2_info()
2412 spin_unlock(&local->baplock); in prism2_info()
2415 if (res == -ETIMEDOUT) { in prism2_info()
2416 schedule_work(&local->reset_queue); in prism2_info()
2421 left = (le16_to_cpu(info.len) - 1) * 2; in prism2_info()
2427 spin_unlock(&local->baplock); in prism2_info()
2429 "length 0x%04x (type 0x%04x)\n", dev->name, in prism2_info()
2436 spin_unlock(&local->baplock); in prism2_info()
2438 "frame\n", dev->name); in prism2_info()
2445 spin_unlock(&local->baplock); in prism2_info()
2447 "len=0x%04x, type=0x%04x\n", dev->name, fid, in prism2_info()
2452 spin_unlock(&local->baplock); in prism2_info()
2454 skb_queue_tail(&local->info_list, skb); in prism2_info()
2455 tasklet_schedule(&local->info_tasklet); in prism2_info()
2466 struct net_device *dev = local->dev; in hostap_bap_tasklet()
2470 if (local->func->card_present && !local->func->card_present(local)) in hostap_bap_tasklet()
2473 set_bit(HOSTAP_BITS_BAP_TASKLET, &local->bits); in hostap_bap_tasklet()
2477 while (frames-- > 0) { in hostap_bap_tasklet()
2491 set_bit(HOSTAP_BITS_BAP_TASKLET2, &local->bits); in hostap_bap_tasklet()
2492 clear_bit(HOSTAP_BITS_BAP_TASKLET, &local->bits); in hostap_bap_tasklet()
2496 clear_bit(HOSTAP_BITS_BAP_TASKLET2, &local->bits); in hostap_bap_tasklet()
2505 PDEBUG(DEBUG_EXTRA, "%s: INFDROP event\n", dev->name); in prism2_infdrop()
2529 local = iface->local; in prism2_ev_tick()
2531 if (time_after(jiffies, local->last_tick_timer + 5 * HZ) && in prism2_ev_tick()
2532 local->last_tick_timer) { in prism2_ev_tick()
2538 dev->name, local->bits, evstat, inten); in prism2_ev_tick()
2540 local->sw_tick_stuck++; in prism2_ev_tick()
2544 "hang\n", dev->name); in prism2_ev_tick()
2557 * return 0x0000 in SWSUPPORT0 for unknown reason, but re-reading the in prism2_check_magic()
2565 struct net_device *dev = local->dev; in prism2_check_magic()
2568 if (!local->hw_ready) in prism2_check_magic()
2573 "%04X != %04X - card removed?\n", dev->name, in prism2_check_magic()
2578 printk(KERN_DEBUG "%s: interrupt - SWSUPPORT0=%04x " in prism2_check_magic()
2579 "MAGIC=%04x\n", dev->name, in prism2_check_magic()
2584 schedule_work(&local->reset_queue); in prism2_check_magic()
2602 local = iface->local; in prism2_interrupt()
2605 spin_lock(&local->irq_init_lock); in prism2_interrupt()
2606 if (!dev->base_addr) { in prism2_interrupt()
2609 dev->name); in prism2_interrupt()
2611 spin_unlock(&local->irq_init_lock); in prism2_interrupt()
2614 spin_unlock(&local->irq_init_lock); in prism2_interrupt()
2618 if (local->func->card_present && !local->func->card_present(local)) { in prism2_interrupt()
2621 dev->name); in prism2_interrupt()
2631 if (local->shutdown) in prism2_interrupt()
2635 dev->name); in prism2_interrupt()
2651 if (!local->hw_ready || local->hw_resetting || in prism2_interrupt()
2652 !local->dev_enabled) { in prism2_interrupt()
2658 if (local->dev_enabled && (ev & ~HFA384X_EV_TICK) && in prism2_interrupt()
2663 dev->name, ev, in prism2_interrupt()
2665 !local->hw_ready ? " (!hw_ready)" : "", in prism2_interrupt()
2666 local->hw_resetting ? in prism2_interrupt()
2668 !local->dev_enabled ? in prism2_interrupt()
2690 tasklet_schedule(&local->bap_tasklet); in prism2_interrupt()
2695 PDEBUG(DEBUG_EXTRA, "%s: WTERR event\n", dev->name); in prism2_interrupt()
2725 if (hfa384x_get_rid(local->dev, HFA384X_RID_STAID, in prism2_check_sta_fw_version()
2729 local->fw_ap = 0; in prism2_check_sta_fw_version()
2733 local->fw_ap = 1; in prism2_check_sta_fw_version()
2740 local->sta_fw_ver = PRISM2_FW_VER(major, minor, variant); in prism2_check_sta_fw_version()
2743 * firmware-based WEP encryption when using Host AP mode, so use in prism2_check_sta_fw_version()
2748 local->fw_encrypt_ok = local->sta_fw_ver >= PRISM2_FW_VER(1,4,9); in prism2_check_sta_fw_version()
2750 if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt && in prism2_check_sta_fw_version()
2751 !local->fw_encrypt_ok) { in prism2_check_sta_fw_version()
2752 printk(KERN_DEBUG "%s: defaulting to host-based encryption as " in prism2_check_sta_fw_version()
2754 local->dev->name); in prism2_check_sta_fw_version()
2755 local->host_encrypt = 1; in prism2_check_sta_fw_version()
2765 if (local->sta_fw_ver >= PRISM2_FW_VER(1,5,0)) in prism2_check_sta_fw_version()
2766 local->wds_type |= HOSTAP_WDS_STANDARD_FRAME; in prism2_check_sta_fw_version()
2770 local->dev->name); in prism2_check_sta_fw_version()
2773 hostap_check_sta_fw_version(local->ap, local->sta_fw_ver); in prism2_check_sta_fw_version()
2780 struct net_device *dev = local->dev; in hostap_passive_scan()
2783 if (local->passive_scan_interval <= 0) in hostap_passive_scan()
2786 if (local->passive_scan_state == PASSIVE_SCAN_LISTEN) { in hostap_passive_scan()
2791 * passive scanning when a host-generated frame is being in hostap_passive_scan()
2793 if (test_bit(HOSTAP_BITS_TRANSMIT, &local->bits)) { in hostap_passive_scan()
2795 "TX - delaying\n", dev->name); in hostap_passive_scan()
2796 local->passive_scan_timer.expires = jiffies + HZ / 10; in hostap_passive_scan()
2797 add_timer(&local->passive_scan_timer); in hostap_passive_scan()
2802 local->passive_scan_channel++; in hostap_passive_scan()
2803 if (local->passive_scan_channel > 14) in hostap_passive_scan()
2804 local->passive_scan_channel = 1; in hostap_passive_scan()
2805 max_tries--; in hostap_passive_scan()
2806 } while (!(local->channel_mask & in hostap_passive_scan()
2807 (1 << (local->passive_scan_channel - 1))) && in hostap_passive_scan()
2812 " found\n", dev->name); in hostap_passive_scan()
2817 dev->name, local->passive_scan_channel); in hostap_passive_scan()
2818 chan = local->passive_scan_channel; in hostap_passive_scan()
2819 local->passive_scan_state = PASSIVE_SCAN_WAIT; in hostap_passive_scan()
2820 local->passive_scan_timer.expires = jiffies + HZ / 10; in hostap_passive_scan()
2822 chan = local->channel; in hostap_passive_scan()
2823 local->passive_scan_state = PASSIVE_SCAN_LISTEN; in hostap_passive_scan()
2824 local->passive_scan_timer.expires = jiffies + in hostap_passive_scan()
2825 local->passive_scan_interval * HZ; in hostap_passive_scan()
2832 "failed\n", dev->name, chan); in hostap_passive_scan()
2834 add_timer(&local->passive_scan_timer); in hostap_passive_scan()
2844 prism2_update_comms_qual(local->dev); in handle_comms_qual_update()
2848 /* Software watchdog - called as a timer. Hardware interrupt (Tick event) is
2849 * used to monitor that local->last_tick_timer is being updated. If not,
2850 * interrupt busy-loop is assumed and driver tries to recover by masking out
2856 local->last_tick_timer = jiffies; in hostap_tick_timer()
2859 * more often during low load and when using 32-bit tallies. */ in hostap_tick_timer()
2861 !local->hw_downloading && local->hw_ready && in hostap_tick_timer()
2862 !local->hw_resetting && local->dev_enabled) { in hostap_tick_timer()
2863 hfa384x_cmd_callback(local->dev, HFA384X_CMDCODE_INQUIRE, in hostap_tick_timer()
2868 if ((local->last_comms_qual_update == 0 || in hostap_tick_timer()
2869 time_after(jiffies, local->last_comms_qual_update + 10 * HZ)) && in hostap_tick_timer()
2870 (local->iw_mode == IW_MODE_INFRA || in hostap_tick_timer()
2871 local->iw_mode == IW_MODE_ADHOC)) { in hostap_tick_timer()
2872 schedule_work(&local->comms_qual_update); in hostap_tick_timer()
2875 local->tick_timer.expires = jiffies + 2 * HZ; in hostap_tick_timer()
2876 add_timer(&local->tick_timer); in hostap_tick_timer()
2888 local_info_t *local = m->private; in prism2_registers_proc_show()
2891 seq_printf(m, #n "=%04x\n", hfa384x_read_reg(local->dev, HFA384X_##n##_OFF)) in prism2_registers_proc_show()
2955 local = iface->local; in prism2_set_tim()
2959 return -ENOMEM; in prism2_set_tim()
2961 new_entry->aid = aid; in prism2_set_tim()
2962 new_entry->set = set; in prism2_set_tim()
2964 spin_lock_bh(&local->set_tim_lock); in prism2_set_tim()
2965 list_for_each(ptr, &local->set_tim_list) { in prism2_set_tim()
2966 struct set_tim_data *entry = in prism2_set_tim() local
2968 if (entry->aid == aid) { in prism2_set_tim()
2971 local->dev->name, aid, entry->set, set); in prism2_set_tim()
2972 entry->set = set; in prism2_set_tim()
2979 list_add_tail(&new_entry->list, &local->set_tim_list); in prism2_set_tim()
2980 spin_unlock_bh(&local->set_tim_lock); in prism2_set_tim()
2982 schedule_work(&local->set_tim_queue); in prism2_set_tim()
2991 struct set_tim_data *entry; in handle_set_tim_queue() local
2995 entry = NULL; in handle_set_tim_queue()
2996 spin_lock_bh(&local->set_tim_lock); in handle_set_tim_queue()
2997 if (!list_empty(&local->set_tim_list)) { in handle_set_tim_queue()
2998 entry = list_entry(local->set_tim_list.next, in handle_set_tim_queue()
3000 list_del(&entry->list); in handle_set_tim_queue()
3002 spin_unlock_bh(&local->set_tim_lock); in handle_set_tim_queue()
3003 if (!entry) in handle_set_tim_queue()
3007 local->dev->name, entry->aid, entry->set); in handle_set_tim_queue()
3009 val = entry->aid; in handle_set_tim_queue()
3010 if (entry->set) in handle_set_tim_queue()
3012 if (hostap_set_word(local->dev, HFA384X_RID_CNFTIMCTRL, val)) { in handle_set_tim_queue()
3015 local->dev->name, entry->aid, entry->set); in handle_set_tim_queue()
3018 kfree(entry); in handle_set_tim_queue()
3027 list_for_each_safe(ptr, n, &local->set_tim_list) { in prism2_clear_set_tim_queue()
3028 struct set_tim_data *entry; in prism2_clear_set_tim_queue() local
3029 entry = list_entry(ptr, struct set_tim_data, list); in prism2_clear_set_tim_queue()
3030 list_del(&entry->list); in prism2_clear_set_tim_queue()
3031 kfree(entry); in prism2_clear_set_tim_queue()
3048 lockdep_set_class(&txq->_xmit_lock, in prism2_set_lockdep_class_one()
3054 lockdep_set_class(&dev->addr_list_lock, in prism2_set_lockdep_class()
3088 local->ap = (struct ap_data *) ((((long) (local + 1)) + 3) & ~3); in prism2_init_local_data()
3089 local->dev = iface->dev = dev; in prism2_init_local_data()
3090 iface->local = local; in prism2_init_local_data()
3091 iface->type = HOSTAP_INTERFACE_MASTER; in prism2_init_local_data()
3092 INIT_LIST_HEAD(&local->hostap_interfaces); in prism2_init_local_data()
3094 local->hw_module = THIS_MODULE; in prism2_init_local_data()
3097 local->io_debug_enabled = 1; in prism2_init_local_data()
3100 local->func = funcs; in prism2_init_local_data()
3101 local->func->cmd = hfa384x_cmd; in prism2_init_local_data()
3102 local->func->read_regs = hfa384x_read_regs; in prism2_init_local_data()
3103 local->func->get_rid = hfa384x_get_rid; in prism2_init_local_data()
3104 local->func->set_rid = hfa384x_set_rid; in prism2_init_local_data()
3105 local->func->hw_enable = prism2_hw_enable; in prism2_init_local_data()
3106 local->func->hw_config = prism2_hw_config; in prism2_init_local_data()
3107 local->func->hw_reset = prism2_hw_reset; in prism2_init_local_data()
3108 local->func->hw_shutdown = prism2_hw_shutdown; in prism2_init_local_data()
3109 local->func->reset_port = prism2_reset_port; in prism2_init_local_data()
3110 local->func->schedule_reset = prism2_schedule_reset; in prism2_init_local_data()
3112 local->func->read_aux_proc_ops = &prism2_download_aux_dump_proc_ops; in prism2_init_local_data()
3113 local->func->download = prism2_download; in prism2_init_local_data()
3115 local->func->tx = prism2_tx_80211; in prism2_init_local_data()
3116 local->func->set_tim = prism2_set_tim; in prism2_init_local_data()
3117 local->func->need_tx_headroom = 0; /* no need to add txdesc in in prism2_init_local_data()
3118 * skb->data (FIX: maybe for DMA bus in prism2_init_local_data()
3121 local->mtu = mtu; in prism2_init_local_data()
3123 rwlock_init(&local->iface_lock); in prism2_init_local_data()
3124 spin_lock_init(&local->txfidlock); in prism2_init_local_data()
3125 spin_lock_init(&local->cmdlock); in prism2_init_local_data()
3126 spin_lock_init(&local->baplock); in prism2_init_local_data()
3127 spin_lock_init(&local->lock); in prism2_init_local_data()
3128 spin_lock_init(&local->irq_init_lock); in prism2_init_local_data()
3129 mutex_init(&local->rid_bap_mtx); in prism2_init_local_data()
3133 local->card_idx = card_idx; in prism2_init_local_data()
3136 memcpy(local->essid, essid, in prism2_init_local_data()
3138 local->essid[MAX_SSID_LEN] = '\0'; in prism2_init_local_data()
3142 local->iw_mode = i; in prism2_init_local_data()
3146 local->iw_mode = IW_MODE_MASTER; in prism2_init_local_data()
3148 local->channel = GET_INT_PARM(channel, card_idx); in prism2_init_local_data()
3149 local->beacon_int = GET_INT_PARM(beacon_int, card_idx); in prism2_init_local_data()
3150 local->dtim_period = GET_INT_PARM(dtim_period, card_idx); in prism2_init_local_data()
3151 local->wds_max_connections = 16; in prism2_init_local_data()
3152 local->tx_control = HFA384X_TX_CTRL_FLAGS; in prism2_init_local_data()
3153 local->manual_retry_count = -1; in prism2_init_local_data()
3154 local->rts_threshold = 2347; in prism2_init_local_data()
3155 local->fragm_threshold = 2346; in prism2_init_local_data()
3156 local->rssi_to_dBm = 100; /* default; to be overriden by in prism2_init_local_data()
3158 local->auth_algs = PRISM2_AUTH_OPEN | PRISM2_AUTH_SHARED_KEY; in prism2_init_local_data()
3159 local->sram_type = -1; in prism2_init_local_data()
3160 local->scan_channel_mask = 0xffff; in prism2_init_local_data()
3161 local->monitor_type = PRISM2_MONITOR_RADIOTAP; in prism2_init_local_data()
3164 INIT_WORK(&local->reset_queue, handle_reset_queue); in prism2_init_local_data()
3165 INIT_WORK(&local->set_multicast_list_queue, in prism2_init_local_data()
3168 INIT_WORK(&local->set_tim_queue, handle_set_tim_queue); in prism2_init_local_data()
3169 INIT_LIST_HEAD(&local->set_tim_list); in prism2_init_local_data()
3170 spin_lock_init(&local->set_tim_lock); in prism2_init_local_data()
3172 INIT_WORK(&local->comms_qual_update, handle_comms_qual_update); in prism2_init_local_data()
3176 tasklet_setup(&local->bap_tasklet, hostap_bap_tasklet); in prism2_init_local_data()
3177 tasklet_setup(&local->info_tasklet, hostap_info_tasklet); in prism2_init_local_data()
3180 tasklet_setup(&local->rx_tasklet, hostap_rx_tasklet); in prism2_init_local_data()
3181 skb_queue_head_init(&local->rx_list); in prism2_init_local_data()
3183 tasklet_setup(&local->sta_tx_exc_tasklet, in prism2_init_local_data()
3185 skb_queue_head_init(&local->sta_tx_exc_list); in prism2_init_local_data()
3187 INIT_LIST_HEAD(&local->cmd_queue); in prism2_init_local_data()
3188 init_waitqueue_head(&local->hostscan_wq); in prism2_init_local_data()
3190 lib80211_crypt_info_init(&local->crypt_info, dev->name, &local->lock); in prism2_init_local_data()
3192 timer_setup(&local->passive_scan_timer, hostap_passive_scan, 0); in prism2_init_local_data()
3193 timer_setup(&local->tick_timer, hostap_tick_timer, 0); in prism2_init_local_data()
3194 local->tick_timer.expires = jiffies + 2 * HZ; in prism2_init_local_data()
3195 add_timer(&local->tick_timer); in prism2_init_local_data()
3197 INIT_LIST_HEAD(&local->bss_list); in prism2_init_local_data()
3201 dev->type = ARPHRD_IEEE80211; in prism2_init_local_data()
3202 dev->header_ops = &hostap_80211_ops; in prism2_init_local_data()
3217 printk(KERN_INFO "%s: Registered netdevice %s\n", dev_info, dev->name); in prism2_init_local_data()
3234 local = iface->local; in hostap_hw_ready()
3235 local->ddev = hostap_add_interface(local, HOSTAP_INTERFACE_MAIN, 0, in hostap_hw_ready()
3238 if (local->ddev) { in hostap_hw_ready()
3239 if (local->iw_mode == IW_MODE_INFRA || in hostap_hw_ready()
3240 local->iw_mode == IW_MODE_ADHOC) { in hostap_hw_ready()
3241 netif_carrier_off(local->dev); in hostap_hw_ready()
3242 netif_carrier_off(local->ddev); in hostap_hw_ready()
3246 proc_create_single_data("registers", 0, local->proc, in hostap_hw_ready()
3253 return -1; in hostap_hw_ready()
3269 local = iface->local; in prism2_free_local_data()
3272 list_for_each_safe(ptr, n, &local->hostap_interfaces) { in prism2_free_local_data()
3274 if (iface->type == HOSTAP_INTERFACE_MASTER) { in prism2_free_local_data()
3278 hostap_remove_interface(iface->dev, 0, 1); in prism2_free_local_data()
3281 unregister_netdev(local->dev); in prism2_free_local_data()
3283 flush_work(&local->reset_queue); in prism2_free_local_data()
3284 flush_work(&local->set_multicast_list_queue); in prism2_free_local_data()
3285 flush_work(&local->set_tim_queue); in prism2_free_local_data()
3287 flush_work(&local->info_queue); in prism2_free_local_data()
3289 flush_work(&local->comms_qual_update); in prism2_free_local_data()
3291 lib80211_crypt_info_free(&local->crypt_info); in prism2_free_local_data()
3293 if (timer_pending(&local->passive_scan_timer)) in prism2_free_local_data()
3294 del_timer(&local->passive_scan_timer); in prism2_free_local_data()
3296 if (timer_pending(&local->tick_timer)) in prism2_free_local_data()
3297 del_timer(&local->tick_timer); in prism2_free_local_data()
3301 skb_queue_purge(&local->info_list); in prism2_free_local_data()
3302 skb_queue_purge(&local->rx_list); in prism2_free_local_data()
3303 skb_queue_purge(&local->sta_tx_exc_list); in prism2_free_local_data()
3305 if (local->dev_enabled) in prism2_free_local_data()
3308 if (local->ap != NULL) in prism2_free_local_data()
3309 hostap_free_data(local->ap); in prism2_free_local_data()
3312 if (local->proc != NULL) in prism2_free_local_data()
3313 remove_proc_entry("registers", local->proc); in prism2_free_local_data()
3317 tx_cb = local->tx_callback; in prism2_free_local_data()
3320 tx_cb = tx_cb->next; in prism2_free_local_data()
3328 if (local->frag_cache[i].skb != NULL) in prism2_free_local_data()
3329 dev_kfree_skb(local->frag_cache[i].skb); in prism2_free_local_data()
3333 prism2_download_free_data(local->dl_pri); in prism2_free_local_data()
3334 prism2_download_free_data(local->dl_sec); in prism2_free_local_data()
3339 list_for_each_safe(ptr, n, &local->bss_list) { in prism2_free_local_data()
3345 kfree(local->pda); in prism2_free_local_data()
3346 kfree(local->last_scan_results); in prism2_free_local_data()
3347 kfree(local->generic_elem); in prism2_free_local_data()
3349 free_netdev(local->dev); in prism2_free_local_data()
3361 local = iface->local; in prism2_suspend()
3367 wireless_send_event(local->dev, SIOCGIWAP, &wrqu, NULL); in prism2_suspend()