Lines Matching +full:txs +full:- +full:delta

1 /*-
2 * Copyright (c) 2007-2009 Damien Bergamini <damien.bergamini@free.fr>
6 * Copyright (c) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
84 { 0x8086, IWN_DID_6x05_1, "Intel Centrino Advanced-N 6205" },
85 { 0x8086, IWN_DID_1000_1, "Intel Centrino Wireless-N 1000" },
86 { 0x8086, IWN_DID_1000_2, "Intel Centrino Wireless-N 1000" },
87 { 0x8086, IWN_DID_6x05_2, "Intel Centrino Advanced-N 6205" },
88 { 0x8086, IWN_DID_6050_1, "Intel Centrino Advanced-N + WiMAX 6250" },
89 { 0x8086, IWN_DID_6050_2, "Intel Centrino Advanced-N + WiMAX 6250" },
90 { 0x8086, IWN_DID_x030_1, "Intel Centrino Wireless-N 1030" },
91 { 0x8086, IWN_DID_x030_2, "Intel Centrino Wireless-N 1030" },
92 { 0x8086, IWN_DID_x030_3, "Intel Centrino Advanced-N 6230" },
93 { 0x8086, IWN_DID_x030_4, "Intel Centrino Advanced-N 6230" },
94 { 0x8086, IWN_DID_6150_1, "Intel Centrino Wireless-N + WiMAX 6150" },
95 { 0x8086, IWN_DID_6150_2, "Intel Centrino Wireless-N + WiMAX 6150" },
96 { 0x8086, IWN_DID_2x00_1, "Intel(R) Centrino(R) Wireless-N 2200 BGN" },
97 { 0x8086, IWN_DID_2x00_2, "Intel(R) Centrino(R) Wireless-N 2200 BGN" },
99 { 0x8086, IWN_DID_2x30_1, "Intel Centrino Wireless-N 2230" },
100 { 0x8086, IWN_DID_2x30_2, "Intel Centrino Wireless-N 2230" },
101 { 0x8086, IWN_DID_130_1, "Intel Centrino Wireless-N 130" },
102 { 0x8086, IWN_DID_130_2, "Intel Centrino Wireless-N 130" },
103 { 0x8086, IWN_DID_100_1, "Intel Centrino Wireless-N 100" },
104 { 0x8086, IWN_DID_100_2, "Intel Centrino Wireless-N 100" },
105 { 0x8086, IWN_DID_105_1, "Intel Centrino Wireless-N 105" },
106 { 0x8086, IWN_DID_105_2, "Intel Centrino Wireless-N 105" },
107 { 0x8086, IWN_DID_135_1, "Intel Centrino Wireless-N 135" },
108 { 0x8086, IWN_DID_135_2, "Intel Centrino Wireless-N 135" },
110 { 0x8086, IWN_DID_6x00_1, "Intel Centrino Ultimate-N 6300" },
111 { 0x8086, IWN_DID_6x00_2, "Intel Centrino Advanced-N 6200" },
119 { 0x8086, IWN_DID_6x00_3, "Intel Centrino Ultimate-N 6300" },
120 { 0x8086, IWN_DID_6x00_4, "Intel Centrino Advanced-N 6200" },
378 nitems(iwn_ident_table) - 1);
403 for (ident = iwn_ident_table; ident->name != NULL; ident++) { in iwn_probe()
404 if (pci_get_vendor(dev) == ident->vendor && in iwn_probe()
405 pci_get_device(dev) == ident->device) { in iwn_probe()
406 device_set_desc(dev, ident->name); in iwn_probe()
417 if (sc->hw_type == IWN_HW_REV_TYPE_5300) in iwn_is_3stream_device()
429 sc->sc_dev = dev; in iwn_attach()
432 error = resource_int_value(device_get_name(sc->sc_dev), in iwn_attach()
433 device_get_unit(sc->sc_dev), "debug", &(sc->sc_debug)); in iwn_attach()
435 sc->sc_debug = 0; in iwn_attach()
437 sc->sc_debug = 0; in iwn_attach()
440 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: begin\n",__func__); in iwn_attach()
446 error = pci_find_cap(dev, PCIY_EXPRESS, &sc->sc_cap_off); in iwn_attach()
452 /* Clear device-specific "PCI retry timeout" register (41h). */ in iwn_attach()
455 /* Enable bus-mastering. */ in iwn_attach()
459 sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in iwn_attach()
461 if (sc->mem == NULL) { in iwn_attach()
466 sc->sc_st = rman_get_bustag(sc->mem); in iwn_attach()
467 sc->sc_sh = rman_get_bushandle(sc->mem); in iwn_attach()
474 sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | in iwn_attach()
476 if (sc->irq == NULL) { in iwn_attach()
485 sc->hw_type = (IWN_READ(sc, IWN_HW_REV) >> IWN_HW_REV_TYPE_SHIFT) in iwn_attach()
487 sc->subdevice_id = pci_get_subdevice(dev); in iwn_attach()
493 if (sc->hw_type == IWN_HW_REV_TYPE_4965) in iwn_attach()
529 if (sc->hw_type != IWN_HW_REV_TYPE_4965 && in iwn_attach()
544 for (i = 0; i < sc->ntxqs; i++) { in iwn_attach()
545 if ((error = iwn_alloc_tx_ring(sc, &sc->txq[i], i)) != 0) { in iwn_attach()
554 if ((error = iwn_alloc_rx_ring(sc, &sc->rxq)) != 0) { in iwn_attach()
563 ic = &sc->sc_ic; in iwn_attach()
564 ic->ic_softc = sc; in iwn_attach()
565 ic->ic_name = device_get_nameunit(dev); in iwn_attach()
566 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ in iwn_attach()
567 ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */ in iwn_attach()
570 ic->ic_caps = in iwn_attach()
584 | IEEE80211_C_PMGT /* Station-side power mgmt */ in iwn_attach()
588 if ((error = iwn_read_eeprom(sc, ic->ic_macaddr)) != 0) { in iwn_attach()
595 sc->ntxchains = in iwn_attach()
596 ((sc->txchainmask >> 2) & 1) + in iwn_attach()
597 ((sc->txchainmask >> 1) & 1) + in iwn_attach()
598 ((sc->txchainmask >> 0) & 1); in iwn_attach()
599 sc->nrxchains = in iwn_attach()
600 ((sc->rxchainmask >> 2) & 1) + in iwn_attach()
601 ((sc->rxchainmask >> 1) & 1) + in iwn_attach()
602 ((sc->rxchainmask >> 0) & 1); in iwn_attach()
605 sc->ntxchains, sc->nrxchains, sc->eeprom_domain, in iwn_attach()
606 ic->ic_macaddr, ":"); in iwn_attach()
609 if (sc->sc_flags & IWN_FLAG_HAS_11N) { in iwn_attach()
610 ic->ic_rxstream = sc->nrxchains; in iwn_attach()
611 ic->ic_txstream = sc->ntxchains; in iwn_attach()
616 * it's not a 3-stream device. in iwn_attach()
619 if (ic->ic_rxstream > 2) in iwn_attach()
620 ic->ic_rxstream = 2; in iwn_attach()
621 if (ic->ic_txstream > 2) in iwn_attach()
622 ic->ic_txstream = 2; in iwn_attach()
625 ic->ic_htcaps = in iwn_attach()
633 | IEEE80211_HTCAP_MAXAMSDU_7935 /* max A-MSDU length */ in iwn_attach()
635 | IEEE80211_HTCAP_MAXAMSDU_3839 /* max A-MSDU length */ in iwn_attach()
640 | IEEE80211_HTC_AMPDU /* tx A-MPDU */ in iwn_attach()
642 | IEEE80211_HTC_AMSDU /* tx A-MSDU */ in iwn_attach()
648 ic->ic_vap_create = iwn_vap_create; in iwn_attach()
649 ic->ic_ioctl = iwn_ioctl; in iwn_attach()
650 ic->ic_parent = iwn_parent; in iwn_attach()
651 ic->ic_vap_delete = iwn_vap_delete; in iwn_attach()
652 ic->ic_transmit = iwn_transmit; in iwn_attach()
653 ic->ic_raw_xmit = iwn_raw_xmit; in iwn_attach()
654 ic->ic_node_alloc = iwn_node_alloc; in iwn_attach()
655 sc->sc_ampdu_rx_start = ic->ic_ampdu_rx_start; in iwn_attach()
656 ic->ic_ampdu_rx_start = iwn_ampdu_rx_start; in iwn_attach()
657 sc->sc_ampdu_rx_stop = ic->ic_ampdu_rx_stop; in iwn_attach()
658 ic->ic_ampdu_rx_stop = iwn_ampdu_rx_stop; in iwn_attach()
659 sc->sc_addba_request = ic->ic_addba_request; in iwn_attach()
660 ic->ic_addba_request = iwn_addba_request; in iwn_attach()
661 sc->sc_addba_response = ic->ic_addba_response; in iwn_attach()
662 ic->ic_addba_response = iwn_addba_response; in iwn_attach()
663 sc->sc_addba_stop = ic->ic_addba_stop; in iwn_attach()
664 ic->ic_addba_stop = iwn_ampdu_tx_stop; in iwn_attach()
665 ic->ic_newassoc = iwn_newassoc; in iwn_attach()
666 ic->ic_wme.wme_update = iwn_updateedca; in iwn_attach()
667 ic->ic_update_promisc = iwn_update_promisc; in iwn_attach()
668 ic->ic_update_mcast = iwn_update_mcast; in iwn_attach()
669 ic->ic_scan_start = iwn_scan_start; in iwn_attach()
670 ic->ic_scan_end = iwn_scan_end; in iwn_attach()
671 ic->ic_set_channel = iwn_set_channel; in iwn_attach()
672 ic->ic_scan_curchan = iwn_scan_curchan; in iwn_attach()
673 ic->ic_scan_mindwell = iwn_scan_mindwell; in iwn_attach()
674 ic->ic_getradiocaps = iwn_getradiocaps; in iwn_attach()
675 ic->ic_setregdomain = iwn_setregdomain; in iwn_attach()
679 callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0); in iwn_attach()
680 callout_init_mtx(&sc->scan_timeout, &sc->sc_mtx, 0); in iwn_attach()
681 callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0); in iwn_attach()
682 TASK_INIT(&sc->sc_rftoggle_task, 0, iwn_rftoggle_task, sc); in iwn_attach()
683 TASK_INIT(&sc->sc_panic_task, 0, iwn_panicked, sc); in iwn_attach()
684 TASK_INIT(&sc->sc_xmit_task, 0, iwn_xmit_task, sc); in iwn_attach()
686 mbufq_init(&sc->sc_xmit_queue, 1024); in iwn_attach()
688 sc->sc_tq = taskqueue_create("iwn_taskq", M_WAITOK, in iwn_attach()
689 taskqueue_thread_enqueue, &sc->sc_tq); in iwn_attach()
690 error = taskqueue_start_threads(&sc->sc_tq, 1, 0, "iwn_taskq"); in iwn_attach()
701 error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE, in iwn_attach()
702 NULL, iwn_intr, sc, &sc->sc_ih); in iwn_attach()
710 device_printf(sc->sc_dev, "%s: rx_stats=%d, rx_stats_bt=%d\n", in iwn_attach()
718 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_attach()
721 sc->sc_cdev = make_dev(&iwn_cdevsw, device_get_unit(dev), in iwn_attach()
723 if (sc->sc_cdev == NULL) { in iwn_attach()
726 sc->sc_cdev->si_drv1 = sc; in iwn_attach()
731 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end in error\n",__func__); in iwn_attach()
749 sc->base_params = &iwn4965_base_params; in iwn_config_specific()
750 sc->limits = &iwn4965_sensitivity_limits; in iwn_config_specific()
751 sc->fwname = "iwn4965fw"; in iwn_config_specific()
753 sc->txchainmask = IWN_ANT_AB; in iwn_config_specific()
754 sc->rxchainmask = IWN_ANT_ABC; in iwn_config_specific()
756 sc->sc_flags |= IWN_FLAG_BTCOEX; in iwn_config_specific()
761 switch(sc->subdevice_id) { in iwn_config_specific()
774 sc->limits = &iwn1000_sensitivity_limits; in iwn_config_specific()
775 sc->base_params = &iwn1000_base_params; in iwn_config_specific()
776 sc->fwname = "iwn1000fw"; in iwn_config_specific()
779 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
781 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
790 sc->fwname = "iwn6000fw"; in iwn_config_specific()
791 sc->limits = &iwn6000_sensitivity_limits; in iwn_config_specific()
792 switch(sc->subdevice_id) { in iwn_config_specific()
797 sc->base_params = &iwn_6000_base_params; in iwn_config_specific()
809 sc->base_params = &iwn_6000i_base_params; in iwn_config_specific()
810 sc->sc_flags |= IWN_FLAG_INTERNAL_PA; in iwn_config_specific()
811 sc->txchainmask = IWN_ANT_BC; in iwn_config_specific()
812 sc->rxchainmask = IWN_ANT_BC; in iwn_config_specific()
815 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
817 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
824 switch(sc->subdevice_id) { in iwn_config_specific()
844 sc->fwname = "iwn6000g2afw"; in iwn_config_specific()
845 sc->limits = &iwn6000_sensitivity_limits; in iwn_config_specific()
846 sc->base_params = &iwn_6000g2_base_params; in iwn_config_specific()
849 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
851 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
858 switch(sc->subdevice_id) { in iwn_config_specific()
864 sc->fwname = "iwn6000g2bfw"; in iwn_config_specific()
865 sc->limits = &iwn6235_sensitivity_limits; in iwn_config_specific()
866 sc->base_params = &iwn_6235_base_params; in iwn_config_specific()
869 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
871 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
878 switch(sc->subdevice_id) { in iwn_config_specific()
887 sc->fwname = "iwn6050fw"; in iwn_config_specific()
888 sc->txchainmask = IWN_ANT_AB; in iwn_config_specific()
889 sc->rxchainmask = IWN_ANT_AB; in iwn_config_specific()
890 sc->limits = &iwn6000_sensitivity_limits; in iwn_config_specific()
891 sc->base_params = &iwn_6050_base_params; in iwn_config_specific()
894 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
896 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
903 switch(sc->subdevice_id) { in iwn_config_specific()
912 sc->fwname = "iwn6050fw"; in iwn_config_specific()
913 sc->limits = &iwn6000_sensitivity_limits; in iwn_config_specific()
914 sc->base_params = &iwn_6150_base_params; in iwn_config_specific()
917 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
919 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
928 switch(sc->subdevice_id) { in iwn_config_specific()
951 sc->fwname = "iwn6000g2bfw"; in iwn_config_specific()
952 sc->limits = &iwn6000_sensitivity_limits; in iwn_config_specific()
953 sc->base_params = &iwn_6000g2b_base_params; in iwn_config_specific()
956 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
958 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
968 switch(sc->subdevice_id) { in iwn_config_specific()
977 sc->fwname = "iwn6000g2bfw"; in iwn_config_specific()
978 sc->limits = &iwn6000_sensitivity_limits; in iwn_config_specific()
979 sc->base_params = &iwn_6000g2b_base_params; in iwn_config_specific()
982 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
984 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
991 switch(sc->subdevice_id) { in iwn_config_specific()
998 sc->limits = &iwn1000_sensitivity_limits; in iwn_config_specific()
999 sc->base_params = &iwn1000_base_params; in iwn_config_specific()
1000 sc->fwname = "iwn100fw"; in iwn_config_specific()
1003 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
1005 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
1016 switch(sc->subdevice_id) { in iwn_config_specific()
1023 sc->limits = &iwn2030_sensitivity_limits; in iwn_config_specific()
1024 sc->base_params = &iwn2000_base_params; in iwn_config_specific()
1025 sc->fwname = "iwn105fw"; in iwn_config_specific()
1028 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
1030 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
1041 switch(sc->subdevice_id) { in iwn_config_specific()
1045 sc->limits = &iwn2030_sensitivity_limits; in iwn_config_specific()
1046 sc->base_params = &iwn2030_base_params; in iwn_config_specific()
1047 sc->fwname = "iwn135fw"; in iwn_config_specific()
1050 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
1052 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
1060 switch(sc->subdevice_id) { in iwn_config_specific()
1067 sc->limits = &iwn2030_sensitivity_limits; in iwn_config_specific()
1068 sc->base_params = &iwn2000_base_params; in iwn_config_specific()
1069 sc->fwname = "iwn2000fw"; in iwn_config_specific()
1072 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
1074 pid, sc->subdevice_id, sc->hw_type); in iwn_config_specific()
1081 switch(sc->subdevice_id) { in iwn_config_specific()
1090 sc->limits = &iwn2030_sensitivity_limits; in iwn_config_specific()
1091 sc->base_params = &iwn2030_base_params; in iwn_config_specific()
1092 sc->fwname = "iwn2030fw"; in iwn_config_specific()
1095 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
1097 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
1106 sc->limits = &iwn5000_sensitivity_limits; in iwn_config_specific()
1107 sc->base_params = &iwn5000_base_params; in iwn_config_specific()
1108 sc->fwname = "iwn5000fw"; in iwn_config_specific()
1109 switch(sc->subdevice_id) { in iwn_config_specific()
1123 sc->txchainmask = IWN_ANT_B; in iwn_config_specific()
1124 sc->rxchainmask = IWN_ANT_AB; in iwn_config_specific()
1133 sc->txchainmask = IWN_ANT_B; in iwn_config_specific()
1134 sc->rxchainmask = IWN_ANT_AB; in iwn_config_specific()
1143 sc->txchainmask = IWN_ANT_B; in iwn_config_specific()
1144 sc->rxchainmask = IWN_ANT_AB; in iwn_config_specific()
1159 sc->txchainmask = IWN_ANT_ABC; in iwn_config_specific()
1160 sc->rxchainmask = IWN_ANT_ABC; in iwn_config_specific()
1163 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
1165 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
1174 sc->limits = &iwn5000_sensitivity_limits; in iwn_config_specific()
1175 sc->base_params = &iwn5000_base_params; in iwn_config_specific()
1176 sc->fwname = "iwn5000fw"; in iwn_config_specific()
1177 switch(sc->subdevice_id) { in iwn_config_specific()
1182 sc->limits = &iwn5000_sensitivity_limits; in iwn_config_specific()
1183 sc->base_params = &iwn5000_base_params; in iwn_config_specific()
1184 sc->fwname = "iwn5000fw"; in iwn_config_specific()
1198 sc->limits = &iwn5000_sensitivity_limits; in iwn_config_specific()
1199 sc->fwname = "iwn5150fw"; in iwn_config_specific()
1200 sc->base_params = &iwn_5x50_base_params; in iwn_config_specific()
1203 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id :" in iwn_config_specific()
1205 sc->subdevice_id,sc->hw_type); in iwn_config_specific()
1210 device_printf(sc->sc_dev, "adapter type id : 0x%04x sub id : 0x%04x" in iwn_config_specific()
1211 "rev 0x%08x not supported (device)\n", pid, sc->subdevice_id, in iwn_config_specific()
1212 sc->hw_type); in iwn_config_specific()
1221 struct iwn_ops *ops = &sc->ops; in iwn4965_attach()
1223 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn4965_attach()
1225 ops->load_firmware = iwn4965_load_firmware; in iwn4965_attach()
1226 ops->read_eeprom = iwn4965_read_eeprom; in iwn4965_attach()
1227 ops->post_alive = iwn4965_post_alive; in iwn4965_attach()
1228 ops->nic_config = iwn4965_nic_config; in iwn4965_attach()
1229 ops->update_sched = iwn4965_update_sched; in iwn4965_attach()
1230 ops->get_temperature = iwn4965_get_temperature; in iwn4965_attach()
1231 ops->get_rssi = iwn4965_get_rssi; in iwn4965_attach()
1232 ops->set_txpower = iwn4965_set_txpower; in iwn4965_attach()
1233 ops->init_gains = iwn4965_init_gains; in iwn4965_attach()
1234 ops->set_gains = iwn4965_set_gains; in iwn4965_attach()
1235 ops->rxon_assoc = iwn4965_rxon_assoc; in iwn4965_attach()
1236 ops->add_node = iwn4965_add_node; in iwn4965_attach()
1237 ops->tx_done = iwn4965_tx_done; in iwn4965_attach()
1238 ops->ampdu_tx_start = iwn4965_ampdu_tx_start; in iwn4965_attach()
1239 ops->ampdu_tx_stop = iwn4965_ampdu_tx_stop; in iwn4965_attach()
1240 sc->ntxqs = IWN4965_NTXQUEUES; in iwn4965_attach()
1241 sc->firstaggqueue = IWN4965_FIRSTAGGQUEUE; in iwn4965_attach()
1242 sc->ndmachnls = IWN4965_NDMACHNLS; in iwn4965_attach()
1243 sc->broadcast_id = IWN4965_ID_BROADCAST; in iwn4965_attach()
1244 sc->rxonsz = IWN4965_RXONSZ; in iwn4965_attach()
1245 sc->schedsz = IWN4965_SCHEDSZ; in iwn4965_attach()
1246 sc->fw_text_maxsz = IWN4965_FW_TEXT_MAXSZ; in iwn4965_attach()
1247 sc->fw_data_maxsz = IWN4965_FW_DATA_MAXSZ; in iwn4965_attach()
1248 sc->fwsz = IWN4965_FWSZ; in iwn4965_attach()
1249 sc->sched_txfact_addr = IWN4965_SCHED_TXFACT; in iwn4965_attach()
1250 sc->limits = &iwn4965_sensitivity_limits; in iwn4965_attach()
1251 sc->fwname = "iwn4965fw"; in iwn4965_attach()
1253 sc->txchainmask = IWN_ANT_AB; in iwn4965_attach()
1254 sc->rxchainmask = IWN_ANT_ABC; in iwn4965_attach()
1256 sc->sc_flags |= IWN_FLAG_BTCOEX; in iwn4965_attach()
1264 struct iwn_ops *ops = &sc->ops; in iwn5000_attach()
1266 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn5000_attach()
1268 ops->load_firmware = iwn5000_load_firmware; in iwn5000_attach()
1269 ops->read_eeprom = iwn5000_read_eeprom; in iwn5000_attach()
1270 ops->post_alive = iwn5000_post_alive; in iwn5000_attach()
1271 ops->nic_config = iwn5000_nic_config; in iwn5000_attach()
1272 ops->update_sched = iwn5000_update_sched; in iwn5000_attach()
1273 ops->get_temperature = iwn5000_get_temperature; in iwn5000_attach()
1274 ops->get_rssi = iwn5000_get_rssi; in iwn5000_attach()
1275 ops->set_txpower = iwn5000_set_txpower; in iwn5000_attach()
1276 ops->init_gains = iwn5000_init_gains; in iwn5000_attach()
1277 ops->set_gains = iwn5000_set_gains; in iwn5000_attach()
1278 ops->rxon_assoc = iwn5000_rxon_assoc; in iwn5000_attach()
1279 ops->add_node = iwn5000_add_node; in iwn5000_attach()
1280 ops->tx_done = iwn5000_tx_done; in iwn5000_attach()
1281 ops->ampdu_tx_start = iwn5000_ampdu_tx_start; in iwn5000_attach()
1282 ops->ampdu_tx_stop = iwn5000_ampdu_tx_stop; in iwn5000_attach()
1283 sc->ntxqs = IWN5000_NTXQUEUES; in iwn5000_attach()
1284 sc->firstaggqueue = IWN5000_FIRSTAGGQUEUE; in iwn5000_attach()
1285 sc->ndmachnls = IWN5000_NDMACHNLS; in iwn5000_attach()
1286 sc->broadcast_id = IWN5000_ID_BROADCAST; in iwn5000_attach()
1287 sc->rxonsz = IWN5000_RXONSZ; in iwn5000_attach()
1288 sc->schedsz = IWN5000_SCHEDSZ; in iwn5000_attach()
1289 sc->fw_text_maxsz = IWN5000_FW_TEXT_MAXSZ; in iwn5000_attach()
1290 sc->fw_data_maxsz = IWN5000_FW_DATA_MAXSZ; in iwn5000_attach()
1291 sc->fwsz = IWN5000_FWSZ; in iwn5000_attach()
1292 sc->sched_txfact_addr = IWN5000_SCHED_TXFACT; in iwn5000_attach()
1293 sc->reset_noise_gain = IWN5000_PHY_CALIB_RESET_NOISE_GAIN; in iwn5000_attach()
1294 sc->noise_gain = IWN5000_PHY_CALIB_NOISE_GAIN; in iwn5000_attach()
1306 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_radiotap_attach()
1307 ieee80211_radiotap_attach(&sc->sc_ic, in iwn_radiotap_attach()
1308 &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), in iwn_radiotap_attach()
1310 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in iwn_radiotap_attach()
1312 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn_radiotap_attach()
1319 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); in iwn_sysctlattach()
1320 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); in iwn_sysctlattach()
1323 "debug", CTLFLAG_RW, &sc->sc_debug, sc->sc_debug, in iwn_sysctlattach()
1334 struct iwn_softc *sc = ic->ic_softc; in iwn_vap_create()
1338 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ in iwn_vap_create()
1342 vap = &ivp->iv_vap; in iwn_vap_create()
1344 ivp->ctx = IWN_RXON_BSS_CTX; in iwn_vap_create()
1345 vap->iv_bmissthreshold = 10; /* override default */ in iwn_vap_create()
1347 ivp->iv_newstate = vap->iv_newstate; in iwn_vap_create()
1348 vap->iv_newstate = iwn_newstate; in iwn_vap_create()
1349 sc->ivap[IWN_RXON_BSS_CTX] = vap; in iwn_vap_create()
1350 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K; in iwn_vap_create()
1351 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_4; /* 4uS */ in iwn_vap_create()
1357 ic->ic_opmode = opmode; in iwn_vap_create()
1378 while ((m = mbufq_dequeue(&sc->sc_xmit_queue)) != NULL) { in iwn_xmit_queue_drain()
1379 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in iwn_xmit_queue_drain()
1390 return (mbufq_enqueue(&sc->sc_xmit_queue, m)); in iwn_xmit_queue_enqueue()
1399 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_detach()
1401 if (sc->sc_ic.ic_softc != NULL) { in iwn_detach()
1409 taskqueue_drain_all(sc->sc_tq); in iwn_detach()
1410 taskqueue_free(sc->sc_tq); in iwn_detach()
1412 callout_drain(&sc->watchdog_to); in iwn_detach()
1413 callout_drain(&sc->scan_timeout); in iwn_detach()
1414 callout_drain(&sc->calib_to); in iwn_detach()
1415 ieee80211_ifdetach(&sc->sc_ic); in iwn_detach()
1419 if (sc->irq != NULL) { in iwn_detach()
1420 bus_teardown_intr(dev, sc->irq, sc->sc_ih); in iwn_detach()
1421 bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq), in iwn_detach()
1422 sc->irq); in iwn_detach()
1427 iwn_free_rx_ring(sc, &sc->rxq); in iwn_detach()
1428 for (qid = 0; qid < sc->ntxqs; qid++) in iwn_detach()
1429 iwn_free_tx_ring(sc, &sc->txq[qid]); in iwn_detach()
1432 if (sc->ict != NULL) in iwn_detach()
1436 if (sc->mem != NULL) in iwn_detach()
1438 rman_get_rid(sc->mem), sc->mem); in iwn_detach()
1440 if (sc->sc_cdev) { in iwn_detach()
1441 destroy_dev(sc->sc_cdev); in iwn_detach()
1442 sc->sc_cdev = NULL; in iwn_detach()
1445 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n", __func__); in iwn_detach()
1464 ieee80211_suspend_all(&sc->sc_ic); in iwn_suspend()
1473 /* Clear device-specific "PCI retry timeout" register (41h). */ in iwn_resume()
1476 ieee80211_resume_all(&sc->sc_ic); in iwn_resume()
1537 for (; count > 0; count--, data++, addr += 4) in iwn_prph_write_region_4()
1574 for (; count > 0; count--, addr += 4) in iwn_mem_read_region_4()
1582 for (; count > 0; count--, addr += 4) in iwn_mem_set_region_4()
1604 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end timeout\n", __func__); in iwn_eeprom_lock()
1624 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_init_otprom()
1638 if (sc->base_params->shadow_ram_support) { in iwn_init_otprom()
1651 if (! sc->base_params->shadow_ram_support) { in iwn_init_otprom()
1655 for (count = 0; count < sc->base_params->max_ll_items; in iwn_init_otprom()
1660 if (next == 0) /* End of linked-list. */ in iwn_init_otprom()
1665 if (count == 0 || count == sc->base_params->max_ll_items) in iwn_init_otprom()
1668 sc->prom_base = prev + 1; in iwn_init_otprom()
1671 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn_init_otprom()
1683 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_read_prom_data()
1685 addr += sc->prom_base; in iwn_read_prom_data()
1686 for (; count > 0; count -= 2, addr++) { in iwn_read_prom_data()
1695 device_printf(sc->sc_dev, in iwn_read_prom_data()
1699 if (sc->sc_flags & IWN_FLAG_HAS_OTPROM) { in iwn_read_prom_data()
1703 device_printf(sc->sc_dev, in iwn_read_prom_data()
1718 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn_read_prom_data()
1738 dma->tag = NULL; in iwn_dma_contig_alloc()
1739 dma->size = size; in iwn_dma_contig_alloc()
1741 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), alignment, in iwn_dma_contig_alloc()
1743 1, size, 0, NULL, NULL, &dma->tag); in iwn_dma_contig_alloc()
1747 error = bus_dmamem_alloc(dma->tag, (void **)&dma->vaddr, in iwn_dma_contig_alloc()
1748 BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &dma->map); in iwn_dma_contig_alloc()
1752 error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, size, in iwn_dma_contig_alloc()
1753 iwn_dma_map_addr, &dma->paddr, BUS_DMA_NOWAIT); in iwn_dma_contig_alloc()
1757 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); in iwn_dma_contig_alloc()
1760 *kvap = dma->vaddr; in iwn_dma_contig_alloc()
1771 if (dma->vaddr != NULL) { in iwn_dma_contig_free()
1772 bus_dmamap_sync(dma->tag, dma->map, in iwn_dma_contig_free()
1774 bus_dmamap_unload(dma->tag, dma->map); in iwn_dma_contig_free()
1775 bus_dmamem_free(dma->tag, dma->vaddr, dma->map); in iwn_dma_contig_free()
1776 dma->vaddr = NULL; in iwn_dma_contig_free()
1778 if (dma->tag != NULL) { in iwn_dma_contig_free()
1779 bus_dma_tag_destroy(dma->tag); in iwn_dma_contig_free()
1780 dma->tag = NULL; in iwn_dma_contig_free()
1788 return iwn_dma_contig_alloc(sc, &sc->sched_dma, (void **)&sc->sched, in iwn_alloc_sched()
1789 sc->schedsz, 1024); in iwn_alloc_sched()
1795 iwn_dma_contig_free(&sc->sched_dma); in iwn_free_sched()
1802 return iwn_dma_contig_alloc(sc, &sc->kw_dma, NULL, 4096, 4096); in iwn_alloc_kw()
1808 iwn_dma_contig_free(&sc->kw_dma); in iwn_free_kw()
1815 return iwn_dma_contig_alloc(sc, &sc->ict_dma, (void **)&sc->ict, in iwn_alloc_ict()
1822 iwn_dma_contig_free(&sc->ict_dma); in iwn_free_ict()
1828 /* Must be aligned on a 16-byte boundary. */ in iwn_alloc_fwmem()
1829 return iwn_dma_contig_alloc(sc, &sc->fw_dma, NULL, sc->fwsz, 16); in iwn_alloc_fwmem()
1835 iwn_dma_contig_free(&sc->fw_dma); in iwn_free_fwmem()
1844 ring->cur = 0; in iwn_alloc_rx_ring()
1846 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_alloc_rx_ring()
1848 /* Allocate RX descriptors (256-byte aligned). */ in iwn_alloc_rx_ring()
1850 error = iwn_dma_contig_alloc(sc, &ring->desc_dma, (void **)&ring->desc, in iwn_alloc_rx_ring()
1853 device_printf(sc->sc_dev, in iwn_alloc_rx_ring()
1859 /* Allocate RX status area (16-byte aligned). */ in iwn_alloc_rx_ring()
1860 error = iwn_dma_contig_alloc(sc, &ring->stat_dma, (void **)&ring->stat, in iwn_alloc_rx_ring()
1863 device_printf(sc->sc_dev, in iwn_alloc_rx_ring()
1870 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, in iwn_alloc_rx_ring()
1872 IWN_RBUF_SIZE, 1, IWN_RBUF_SIZE, 0, NULL, NULL, &ring->data_dmat); in iwn_alloc_rx_ring()
1874 device_printf(sc->sc_dev, in iwn_alloc_rx_ring()
1884 struct iwn_rx_data *data = &ring->data[i]; in iwn_alloc_rx_ring()
1887 error = bus_dmamap_create(ring->data_dmat, 0, &data->map); in iwn_alloc_rx_ring()
1889 device_printf(sc->sc_dev, in iwn_alloc_rx_ring()
1895 data->m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, in iwn_alloc_rx_ring()
1897 if (data->m == NULL) { in iwn_alloc_rx_ring()
1898 device_printf(sc->sc_dev, in iwn_alloc_rx_ring()
1904 error = bus_dmamap_load(ring->data_dmat, data->map, in iwn_alloc_rx_ring()
1905 mtod(data->m, void *), IWN_RBUF_SIZE, iwn_dma_map_addr, in iwn_alloc_rx_ring()
1908 device_printf(sc->sc_dev, in iwn_alloc_rx_ring()
1914 bus_dmamap_sync(ring->data_dmat, data->map, in iwn_alloc_rx_ring()
1917 /* Set physical address of RX buffer (256-byte aligned). */ in iwn_alloc_rx_ring()
1918 ring->desc[i] = htole32(paddr >> 8); in iwn_alloc_rx_ring()
1921 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, in iwn_alloc_rx_ring()
1924 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_alloc_rx_ring()
1930 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end in error\n",__func__); in iwn_alloc_rx_ring()
1940 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_reset_rx_ring()
1952 ring->cur = 0; in iwn_reset_rx_ring()
1953 sc->last_rx_valid = 0; in iwn_reset_rx_ring()
1961 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s \n", __func__); in iwn_free_rx_ring()
1963 iwn_dma_contig_free(&ring->desc_dma); in iwn_free_rx_ring()
1964 iwn_dma_contig_free(&ring->stat_dma); in iwn_free_rx_ring()
1967 struct iwn_rx_data *data = &ring->data[i]; in iwn_free_rx_ring()
1969 if (data->m != NULL) { in iwn_free_rx_ring()
1970 bus_dmamap_sync(ring->data_dmat, data->map, in iwn_free_rx_ring()
1972 bus_dmamap_unload(ring->data_dmat, data->map); in iwn_free_rx_ring()
1973 m_freem(data->m); in iwn_free_rx_ring()
1974 data->m = NULL; in iwn_free_rx_ring()
1976 if (data->map != NULL) in iwn_free_rx_ring()
1977 bus_dmamap_destroy(ring->data_dmat, data->map); in iwn_free_rx_ring()
1979 if (ring->data_dmat != NULL) { in iwn_free_rx_ring()
1980 bus_dma_tag_destroy(ring->data_dmat); in iwn_free_rx_ring()
1981 ring->data_dmat = NULL; in iwn_free_rx_ring()
1992 ring->qid = qid; in iwn_alloc_tx_ring()
1993 ring->queued = 0; in iwn_alloc_tx_ring()
1994 ring->cur = 0; in iwn_alloc_tx_ring()
1996 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_alloc_tx_ring()
1998 /* Allocate TX descriptors (256-byte aligned). */ in iwn_alloc_tx_ring()
2000 error = iwn_dma_contig_alloc(sc, &ring->desc_dma, (void **)&ring->desc, in iwn_alloc_tx_ring()
2003 device_printf(sc->sc_dev, in iwn_alloc_tx_ring()
2010 error = iwn_dma_contig_alloc(sc, &ring->cmd_dma, (void **)&ring->cmd, in iwn_alloc_tx_ring()
2013 device_printf(sc->sc_dev, in iwn_alloc_tx_ring()
2019 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, in iwn_alloc_tx_ring()
2021 IWN_MAX_SCATTER - 1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); in iwn_alloc_tx_ring()
2023 device_printf(sc->sc_dev, in iwn_alloc_tx_ring()
2029 paddr = ring->cmd_dma.paddr; in iwn_alloc_tx_ring()
2031 struct iwn_tx_data *data = &ring->data[i]; in iwn_alloc_tx_ring()
2033 data->cmd_paddr = paddr; in iwn_alloc_tx_ring()
2034 data->scratch_paddr = paddr + 12; in iwn_alloc_tx_ring()
2037 error = bus_dmamap_create(ring->data_dmat, 0, &data->map); in iwn_alloc_tx_ring()
2039 device_printf(sc->sc_dev, in iwn_alloc_tx_ring()
2046 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn_alloc_tx_ring()
2051 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end in error\n", __func__); in iwn_alloc_tx_ring()
2060 DPRINTF(sc, IWN_DEBUG_TRACE, "->doing %s \n", __func__); in iwn_reset_tx_ring()
2063 struct iwn_tx_data *data = &ring->data[i]; in iwn_reset_tx_ring()
2065 if (data->m != NULL) { in iwn_reset_tx_ring()
2066 bus_dmamap_sync(ring->data_dmat, data->map, in iwn_reset_tx_ring()
2068 bus_dmamap_unload(ring->data_dmat, data->map); in iwn_reset_tx_ring()
2069 m_freem(data->m); in iwn_reset_tx_ring()
2070 data->m = NULL; in iwn_reset_tx_ring()
2072 if (data->ni != NULL) { in iwn_reset_tx_ring()
2073 ieee80211_free_node(data->ni); in iwn_reset_tx_ring()
2074 data->ni = NULL; in iwn_reset_tx_ring()
2076 data->remapped = 0; in iwn_reset_tx_ring()
2077 data->long_retries = 0; in iwn_reset_tx_ring()
2080 memset(ring->desc, 0, ring->desc_dma.size); in iwn_reset_tx_ring()
2081 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, in iwn_reset_tx_ring()
2083 sc->qfullmsk &= ~(1 << ring->qid); in iwn_reset_tx_ring()
2084 ring->queued = 0; in iwn_reset_tx_ring()
2085 ring->cur = 0; in iwn_reset_tx_ring()
2093 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s \n", __func__); in iwn_free_tx_ring()
2095 iwn_dma_contig_free(&ring->desc_dma); in iwn_free_tx_ring()
2096 iwn_dma_contig_free(&ring->cmd_dma); in iwn_free_tx_ring()
2099 struct iwn_tx_data *data = &ring->data[i]; in iwn_free_tx_ring()
2101 if (data->m != NULL) { in iwn_free_tx_ring()
2102 bus_dmamap_sync(ring->data_dmat, data->map, in iwn_free_tx_ring()
2104 bus_dmamap_unload(ring->data_dmat, data->map); in iwn_free_tx_ring()
2105 m_freem(data->m); in iwn_free_tx_ring()
2107 if (data->map != NULL) in iwn_free_tx_ring()
2108 bus_dmamap_destroy(ring->data_dmat, data->map); in iwn_free_tx_ring()
2110 if (ring->data_dmat != NULL) { in iwn_free_tx_ring()
2111 bus_dma_tag_destroy(ring->data_dmat); in iwn_free_tx_ring()
2112 ring->data_dmat = NULL; in iwn_free_tx_ring()
2119 struct iwn_tx_ring *ring = &sc->txq[qid]; in iwn_check_tx_ring()
2121 KASSERT(ring->queued >= 0, ("%s: ring->queued (%d) for queue %d < 0!", in iwn_check_tx_ring()
2122 __func__, ring->queued, qid)); in iwn_check_tx_ring()
2124 if (qid >= sc->firstaggqueue) { in iwn_check_tx_ring()
2125 struct iwn_ops *ops = &sc->ops; in iwn_check_tx_ring()
2126 struct ieee80211_tx_ampdu *tap = sc->qid2tap[qid]; in iwn_check_tx_ring()
2128 if (ring->queued == 0 && !IEEE80211_AMPDU_RUNNING(tap)) { in iwn_check_tx_ring()
2129 uint16_t ssn = tap->txa_start & 0xfff; in iwn_check_tx_ring()
2130 uint8_t tid = tap->txa_tid; in iwn_check_tx_ring()
2131 int *res = tap->txa_private; in iwn_check_tx_ring()
2134 ops->ampdu_tx_stop(sc, qid, tid, ssn); in iwn_check_tx_ring()
2137 sc->qid2tap[qid] = NULL; in iwn_check_tx_ring()
2142 if (ring->queued < IWN_TX_RING_LOMARK) { in iwn_check_tx_ring()
2143 sc->qfullmsk &= ~(1 << qid); in iwn_check_tx_ring()
2145 if (ring->queued == 0) in iwn_check_tx_ring()
2146 sc->sc_tx_timer = 0; in iwn_check_tx_ring()
2148 sc->sc_tx_timer = 5; in iwn_check_tx_ring()
2159 memset(sc->ict, 0, IWN_ICT_SIZE); in iwn5000_ict_reset()
2160 sc->ict_cur = 0; in iwn5000_ict_reset()
2162 bus_dmamap_sync(sc->ict_dma.tag, sc->ict_dma.map, in iwn5000_ict_reset()
2168 IWN_DRAM_INT_TBL_WRAP_CHECK | sc->ict_dma.paddr >> 12); in iwn5000_ict_reset()
2171 sc->int_mask |= IWN_INT_RX_PERIODIC; in iwn5000_ict_reset()
2173 sc->sc_flags |= IWN_FLAG_USE_ICT; in iwn5000_ict_reset()
2175 /* Re-enable interrupts. */ in iwn5000_ict_reset()
2177 IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask); in iwn5000_ict_reset()
2183 struct iwn_ops *ops = &sc->ops; in iwn_read_eeprom()
2187 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_read_eeprom()
2190 if (sc->hw_type >= IWN_HW_REV_TYPE_1000 && in iwn_read_eeprom()
2192 sc->sc_flags |= IWN_FLAG_HAS_OTPROM; in iwn_read_eeprom()
2194 (sc->sc_flags & IWN_FLAG_HAS_OTPROM) ? "OTPROM" : "EEPROM"); in iwn_read_eeprom()
2198 device_printf(sc->sc_dev, in iwn_read_eeprom()
2205 device_printf(sc->sc_dev, "%s: bad ROM signature\n", __func__); in iwn_read_eeprom()
2209 device_printf(sc->sc_dev, "%s: could not lock ROM, error %d\n", in iwn_read_eeprom()
2213 if (sc->sc_flags & IWN_FLAG_HAS_OTPROM) { in iwn_read_eeprom()
2215 device_printf(sc->sc_dev, in iwn_read_eeprom()
2226 sc->sc_flags |= IWN_FLAG_HAS_11N; in iwn_read_eeprom()
2229 sc->rfcfg = le16toh(val); in iwn_read_eeprom()
2230 DPRINTF(sc, IWN_DEBUG_RESET, "radio config=0x%04x\n", sc->rfcfg); in iwn_read_eeprom()
2232 if (sc->txchainmask == 0) in iwn_read_eeprom()
2233 sc->txchainmask = IWN_RFCFG_TXANTMSK(sc->rfcfg); in iwn_read_eeprom()
2234 if (sc->rxchainmask == 0) in iwn_read_eeprom()
2235 sc->rxchainmask = IWN_RFCFG_RXANTMSK(sc->rfcfg); in iwn_read_eeprom()
2240 /* Read adapter-specific information from EEPROM. */ in iwn_read_eeprom()
2241 ops->read_eeprom(sc); in iwn_read_eeprom()
2247 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn_read_eeprom()
2259 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn4965_read_eeprom()
2262 iwn_read_prom_data(sc, IWN4965_EEPROM_DOMAIN, sc->eeprom_domain, 4); in iwn4965_read_eeprom()
2265 for (i = 0; i < IWN_NBANDS - 1; i++) { in iwn4965_read_eeprom()
2272 sc->maxpwr2GHz = val & 0xff; in iwn4965_read_eeprom()
2273 sc->maxpwr5GHz = val >> 8; in iwn4965_read_eeprom()
2275 if (sc->maxpwr5GHz < 20 || sc->maxpwr5GHz > 50) in iwn4965_read_eeprom()
2276 sc->maxpwr5GHz = 38; in iwn4965_read_eeprom()
2277 if (sc->maxpwr2GHz < 20 || sc->maxpwr2GHz > 50) in iwn4965_read_eeprom()
2278 sc->maxpwr2GHz = 38; in iwn4965_read_eeprom()
2280 sc->maxpwr2GHz, sc->maxpwr5GHz); in iwn4965_read_eeprom()
2283 iwn_read_prom_data(sc, IWN4965_EEPROM_BANDS, sc->bands, in iwn4965_read_eeprom()
2284 sizeof sc->bands); in iwn4965_read_eeprom()
2288 sc->eeprom_voltage = (int16_t)le16toh(val); in iwn4965_read_eeprom()
2290 sc->eeprom_voltage); in iwn4965_read_eeprom()
2294 if (sc->sc_debug & IWN_DEBUG_ANY) { in iwn4965_read_eeprom()
2295 for (i = 0; i < IWN_NBANDS - 1; i++) in iwn4965_read_eeprom()
2300 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn4965_read_eeprom()
2307 struct iwn4965_eeprom_band *band = &sc->bands[i]; in iwn4965_print_power_group()
2308 struct iwn4965_eeprom_chan_samples *chans = band->chans; in iwn4965_print_power_group()
2312 printf("chan lo=%d, chan hi=%d\n", band->lo, band->hi); in iwn4965_print_power_group()
2347 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn5000_read_eeprom()
2353 sc->eeprom_domain, 4); in iwn5000_read_eeprom()
2356 for (i = 0; i < IWN_NBANDS - 1; i++) { in iwn5000_read_eeprom()
2357 addr = base + sc->base_params->regulatory_bands[i]; in iwn5000_read_eeprom()
2362 if (sc->base_params->enhanced_TX_power) in iwn5000_read_eeprom()
2371 sc->calib_ver = hdr.version; in iwn5000_read_eeprom()
2373 if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_TEMP_OFFSETv2) { in iwn5000_read_eeprom()
2374 sc->eeprom_voltage = le16toh(hdr.volt); in iwn5000_read_eeprom()
2376 sc->eeprom_temp_high=le16toh(val); in iwn5000_read_eeprom()
2378 sc->eeprom_temp = le16toh(val); in iwn5000_read_eeprom()
2381 if (sc->hw_type == IWN_HW_REV_TYPE_5150) { in iwn5000_read_eeprom()
2384 sc->eeprom_temp = le16toh(val); in iwn5000_read_eeprom()
2387 sc->temp_off = sc->eeprom_temp - (volt / -5); in iwn5000_read_eeprom()
2389 sc->eeprom_temp, volt, sc->temp_off); in iwn5000_read_eeprom()
2393 &sc->eeprom_crystal, sizeof (uint32_t)); in iwn5000_read_eeprom()
2395 le32toh(sc->eeprom_crystal)); in iwn5000_read_eeprom()
2398 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn5000_read_eeprom()
2411 if ((channel->flags & IWN_EEPROM_CHAN_ACTIVE) == 0) in iwn_eeprom_channel_flags()
2413 if ((channel->flags & IWN_EEPROM_CHAN_IBSS) == 0) in iwn_eeprom_channel_flags()
2415 if (channel->flags & IWN_EEPROM_CHAN_RADAR) { in iwn_eeprom_channel_flags()
2428 struct iwn_eeprom_chan *channels = sc->eeprom_channels[n]; in iwn_read_eeprom_band()
2434 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_read_eeprom_band()
2440 if (sc->sc_flags & IWN_FLAG_HAS_11N) in iwn_read_eeprom_band()
2444 if (sc->sc_flags & IWN_FLAG_HAS_11N) in iwn_read_eeprom_band()
2448 for (i = 0; i < band->nchan; i++) { in iwn_read_eeprom_band()
2452 band->chan[i], channels[i].flags, in iwn_read_eeprom_band()
2457 chan = band->chan[i]; in iwn_read_eeprom_band()
2466 sc->maxpwr[chan] = channels[i].maxpwr; in iwn_read_eeprom_band()
2473 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn_read_eeprom_band()
2481 struct iwn_eeprom_chan *channels = sc->eeprom_channels[n]; in iwn_read_eeprom_ht40()
2486 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s start\n", __func__); in iwn_read_eeprom_ht40()
2488 if (!(sc->sc_flags & IWN_FLAG_HAS_11N)) { in iwn_read_eeprom_ht40()
2489 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end no 11n\n", __func__); in iwn_read_eeprom_ht40()
2493 for (i = 0; i < band->nchan; i++) { in iwn_read_eeprom_ht40()
2497 band->chan[i], channels[i].flags, in iwn_read_eeprom_ht40()
2502 chan = band->chan[i]; in iwn_read_eeprom_ht40()
2509 device_printf(sc->sc_dev, in iwn_read_eeprom_ht40()
2518 device_printf(sc->sc_dev, in iwn_read_eeprom_ht40()
2531 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn_read_eeprom_ht40()
2538 struct ieee80211com *ic = &sc->sc_ic; in iwn_read_eeprom_channels()
2540 iwn_read_prom_data(sc, addr, &sc->eeprom_channels[n], in iwn_read_eeprom_channels()
2544 iwn_read_eeprom_band(sc, n, IEEE80211_CHAN_MAX, &ic->ic_nchans, in iwn_read_eeprom_channels()
2545 ic->ic_channels); in iwn_read_eeprom_channels()
2547 iwn_read_eeprom_ht40(sc, n, IEEE80211_CHAN_MAX, &ic->ic_nchans, in iwn_read_eeprom_channels()
2548 ic->ic_channels); in iwn_read_eeprom_channels()
2550 ieee80211_sort_channels(ic->ic_channels, ic->ic_nchans); in iwn_read_eeprom_channels()
2561 chan = c->ic_extieee; in iwn_find_eeprom_channel()
2563 chan = c->ic_ieee; in iwn_find_eeprom_channel()
2566 return &sc->eeprom_channels[band][i]; in iwn_find_eeprom_channel()
2571 if (iwn_bands[j].chan[i] == c->ic_ieee && in iwn_find_eeprom_channel()
2573 return &sc->eeprom_channels[j][i]; in iwn_find_eeprom_channel()
2584 struct iwn_softc *sc = ic->ic_softc; in iwn_getradiocaps()
2590 for (i = 5; i < IWN_NBANDS - 1 && *nchans < maxchans; i++) in iwn_getradiocaps()
2601 struct iwn_softc *sc = ic->ic_softc; in iwn_setregdomain()
2611 __func__, c->ic_ieee, c->ic_freq, c->ic_flags); in iwn_setregdomain()
2614 c->ic_flags |= iwn_eeprom_channel_flags(channel); in iwn_setregdomain()
2624 struct ieee80211com *ic = &sc->sc_ic; in iwn_read_eeprom_enhinfo()
2631 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_read_eeprom_enhinfo()
2644 if (sc->txchainmask & IWN_ANT_A) in iwn_read_eeprom_enhinfo()
2646 if (sc->txchainmask & IWN_ANT_B) in iwn_read_eeprom_enhinfo()
2648 if (sc->txchainmask & IWN_ANT_C) in iwn_read_eeprom_enhinfo()
2650 if (sc->ntxchains == 2) in iwn_read_eeprom_enhinfo()
2652 else if (sc->ntxchains == 3) in iwn_read_eeprom_enhinfo()
2655 for (j = 0; j < ic->ic_nchans; j++) { in iwn_read_eeprom_enhinfo()
2656 c = &ic->ic_channels[j]; in iwn_read_eeprom_enhinfo()
2673 enhinfo[i].chan != c->ic_ieee) in iwn_read_eeprom_enhinfo()
2677 "channel %d(%x), maxpwr %d\n", c->ic_ieee, in iwn_read_eeprom_enhinfo()
2678 c->ic_flags, maxpwr / 2); in iwn_read_eeprom_enhinfo()
2679 c->ic_maxregpower = maxpwr / 2; in iwn_read_eeprom_enhinfo()
2680 c->ic_maxpower = maxpwr; in iwn_read_eeprom_enhinfo()
2684 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end\n", __func__); in iwn_read_eeprom_enhinfo()
2697 wn->id = IWN_ID_UNDEFINED; in iwn_node_alloc()
2699 return (&wn->ni); in iwn_node_alloc()
2746 return IWN_LSB(sc->txchainmask); in iwn_get_1stream_tx_antmask()
2769 /* Default - transmit on the other antennas */ in iwn_get_2stream_tx_antmask()
2770 tx = (sc->txchainmask & ~IWN_LSB(sc->txchainmask)); in iwn_get_2stream_tx_antmask()
2777 * If the NIC is a two-stream TX NIC, configure the TX mask to in iwn_get_2stream_tx_antmask()
2780 else if (sc->ntxchains == 2) in iwn_get_2stream_tx_antmask()
2781 tx = sc->txchainmask; in iwn_get_2stream_tx_antmask()
2799 struct ieee80211com *ic = ni->ni_ic; in iwn_rate_to_plcp()
2809 * Set the initial PLCP value to be between 0->31 for in iwn_rate_to_plcp()
2810 * MCS 0 -> MCS 31, then set the "I'm an MCS rate!" in iwn_rate_to_plcp()
2825 if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) { in iwn_rate_to_plcp()
2827 if (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40) in iwn_rate_to_plcp()
2829 } else if (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20) { in iwn_rate_to_plcp()
2838 plcp |= IWN_RFLAG_ANT(sc->txchainmask); in iwn_rate_to_plcp()
2845 * Set the initial PLCP - fine for both in iwn_rate_to_plcp()
2853 * to map the ridx -> phy table entry in iwn_rate_to_plcp()
2857 ridx = ieee80211_legacy_rate_lookup(ic->ic_rt, in iwn_rate_to_plcp()
2860 IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) in iwn_rate_to_plcp()
2886 struct ieee80211com *ic = vap->iv_ic; in iwn_newstate()
2887 struct iwn_softc *sc = ic->ic_softc; in iwn_newstate()
2890 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_newstate()
2892 DPRINTF(sc, IWN_DEBUG_STATE, "%s: %s -> %s\n", __func__, in iwn_newstate()
2893 ieee80211_state_name[vap->iv_state], ieee80211_state_name[nstate]); in iwn_newstate()
2897 callout_stop(&sc->calib_to); in iwn_newstate()
2899 sc->rxon = &sc->rx_on[IWN_RXON_BSS_CTX]; in iwn_newstate()
2903 if (vap->iv_state != IEEE80211_S_RUN) in iwn_newstate()
2907 if (vap->iv_state == IEEE80211_S_AUTH) in iwn_newstate()
2911 * !AUTH -> AUTH transition requires state reset to handle in iwn_newstate()
2914 sc->rxon->associd = 0; in iwn_newstate()
2915 sc->rxon->filter &= ~htole32(IWN_FILTER_BSS); in iwn_newstate()
2916 sc->calib.state = IWN_CALIB_STATE_INIT; in iwn_newstate()
2919 if (IEEE80211_IS_CHAN_PASSIVE(ic->ic_curchan)) in iwn_newstate()
2920 sc->sc_beacon_wait = 1; in iwn_newstate()
2923 device_printf(sc->sc_dev, in iwn_newstate()
2930 * RUN -> RUN transition; Just restart the timers. in iwn_newstate()
2932 if (vap->iv_state == IEEE80211_S_RUN) { in iwn_newstate()
2933 sc->calib_cnt = 0; in iwn_newstate()
2938 if (IEEE80211_IS_CHAN_PASSIVE(ic->ic_curchan)) in iwn_newstate()
2939 sc->sc_beacon_wait = 1; in iwn_newstate()
2942 * !RUN -> RUN requires setting the association id in iwn_newstate()
2947 device_printf(sc->sc_dev, in iwn_newstate()
2953 sc->calib.state = IWN_CALIB_STATE_INIT; in iwn_newstate()
2958 sc->sc_beacon_wait = 0; in iwn_newstate()
2968 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end in error\n", __func__); in iwn_newstate()
2972 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_newstate()
2974 return ivp->iv_newstate(vap, nstate, arg); in iwn_newstate()
2985 if (++sc->calib_cnt >= 120) { in iwn_calib_timeout()
2992 sc->calib_cnt = 0; in iwn_calib_timeout()
2994 callout_reset(&sc->calib_to, msecs_to_ticks(500), iwn_calib_timeout, in iwn_calib_timeout()
3010 memcpy(&sc->last_rx_stat, stat, sizeof (*stat)); in iwn_rx_phy()
3011 sc->last_rx_valid = 1; in iwn_rx_phy()
3022 struct iwn_ops *ops = &sc->ops; in iwn_rx_done()
3023 struct ieee80211com *ic = &sc->sc_ic; in iwn_rx_done()
3024 struct iwn_rx_ring *ring = &sc->rxq; in iwn_rx_done()
3034 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_rx_done()
3036 if (desc->type == IWN_MPDU_RX_DONE) { in iwn_rx_done()
3038 if (!sc->last_rx_valid) { in iwn_rx_done()
3043 stat = &sc->last_rx_stat; in iwn_rx_done()
3047 if (stat->cfg_phy_len > IWN_STAT_MAXLEN) { in iwn_rx_done()
3048 device_printf(sc->sc_dev, in iwn_rx_done()
3050 stat->cfg_phy_len); in iwn_rx_done()
3053 if (desc->type == IWN_MPDU_RX_DONE) { in iwn_rx_done()
3056 len = le16toh(mpdu->len); in iwn_rx_done()
3058 head = (caddr_t)(stat + 1) + stat->cfg_phy_len; in iwn_rx_done()
3059 len = le16toh(stat->len); in iwn_rx_done()
3068 counter_u64_add(ic->ic_ierrors, 1); in iwn_rx_done()
3075 counter_u64_add(ic->ic_ierrors, 1); in iwn_rx_done()
3083 counter_u64_add(ic->ic_ierrors, 1); in iwn_rx_done()
3086 bus_dmamap_unload(ring->data_dmat, data->map); in iwn_rx_done()
3088 error = bus_dmamap_load(ring->data_dmat, data->map, mtod(m1, void *), in iwn_rx_done()
3091 device_printf(sc->sc_dev, in iwn_rx_done()
3096 error = bus_dmamap_load(ring->data_dmat, data->map, in iwn_rx_done()
3097 mtod(data->m, void *), IWN_RBUF_SIZE, iwn_dma_map_addr, in iwn_rx_done()
3102 bus_dmamap_sync(ring->data_dmat, data->map, in iwn_rx_done()
3105 ring->desc[ring->cur] = htole32(paddr >> 8); in iwn_rx_done()
3106 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, in iwn_rx_done()
3108 counter_u64_add(ic->ic_ierrors, 1); in iwn_rx_done()
3112 bus_dmamap_sync(ring->data_dmat, data->map, in iwn_rx_done()
3115 m = data->m; in iwn_rx_done()
3116 data->m = m1; in iwn_rx_done()
3118 ring->desc[ring->cur] = htole32(paddr >> 8); in iwn_rx_done()
3119 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, in iwn_rx_done()
3123 m->m_data = head; in iwn_rx_done()
3124 m->m_pkthdr.len = m->m_len = len; in iwn_rx_done()
3132 nf = (ni != NULL && ni->ni_vap->iv_state == IEEE80211_S_RUN && in iwn_rx_done()
3133 (ic->ic_flags & IEEE80211_F_SCAN) == 0) ? sc->noise : -95; in iwn_rx_done()
3135 rssi = ops->get_rssi(sc, stat); in iwn_rx_done()
3138 struct iwn_rx_radiotap_header *tap = &sc->sc_rxtap; in iwn_rx_done()
3139 uint32_t rate = le32toh(stat->rate); in iwn_rx_done()
3141 tap->wr_flags = 0; in iwn_rx_done()
3142 if (stat->flags & htole16(IWN_STAT_FLAG_SHPREAMBLE)) in iwn_rx_done()
3143 tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; in iwn_rx_done()
3144 tap->wr_dbm_antsignal = (int8_t)rssi; in iwn_rx_done()
3145 tap->wr_dbm_antnoise = (int8_t)nf; in iwn_rx_done()
3146 tap->wr_tsft = stat->tstamp; in iwn_rx_done()
3148 tap->wr_rate = rate & IWN_RFLAG_RATE_MCS; in iwn_rx_done()
3149 tap->wr_rate |= IEEE80211_RATE_MCS; in iwn_rx_done()
3151 tap->wr_rate = plcp2rate(rate & IWN_RFLAG_RATE); in iwn_rx_done()
3158 if (sc->sc_beacon_wait) { in iwn_rx_done()
3160 /* NB: Re-assign wh */ in iwn_rx_done()
3162 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in iwn_rx_done()
3163 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; in iwn_rx_done()
3176 taskqueue_enqueue(sc->sc_tq, &sc->sc_xmit_task); in iwn_rx_done()
3184 if (ni->ni_flags & IEEE80211_NODE_HT) in iwn_rx_done()
3185 m->m_flags |= M_AMPDU; in iwn_rx_done()
3186 (void)ieee80211_input(ni, m, rssi - nf, nf); in iwn_rx_done()
3190 (void)ieee80211_input_all(ic, m, rssi - nf, nf); in iwn_rx_done()
3194 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_rx_done()
3202 struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs; in iwn_agg_tx_complete() local
3203 struct iwn_tx_data *data = &ring->data[idx]; in iwn_agg_tx_complete()
3208 KASSERT(data->ni != NULL, ("idx %d: no node", idx)); in iwn_agg_tx_complete()
3209 KASSERT(data->m != NULL, ("idx %d: no mbuf", idx)); in iwn_agg_tx_complete()
3212 bus_dmamap_sync(ring->data_dmat, data->map, in iwn_agg_tx_complete()
3214 bus_dmamap_unload(ring->data_dmat, data->map); in iwn_agg_tx_complete()
3215 m = data->m, data->m = NULL; in iwn_agg_tx_complete()
3216 ni = data->ni, data->ni = NULL; in iwn_agg_tx_complete()
3221 txs->flags = IEEE80211_RATECTL_STATUS_SHORT_RETRY | in iwn_agg_tx_complete()
3223 txs->long_retries = data->long_retries - 1; in iwn_agg_tx_complete()
3225 txs->flags = IEEE80211_RATECTL_STATUS_SHORT_RETRY; in iwn_agg_tx_complete()
3227 txs->short_retries = wn->agg[tid].short_retries; in iwn_agg_tx_complete()
3229 txs->status = IEEE80211_RATECTL_TX_SUCCESS; in iwn_agg_tx_complete()
3231 txs->status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED; in iwn_agg_tx_complete()
3233 wn->agg[tid].short_retries = 0; in iwn_agg_tx_complete()
3234 data->long_retries = 0; in iwn_agg_tx_complete()
3237 __func__, m, ni, idx, ring->qid); in iwn_agg_tx_complete()
3238 ieee80211_ratectl_tx_complete(ni, txs); in iwn_agg_tx_complete()
3256 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_rx_compressed_ba()
3258 qid = le16toh(ba->qid); in iwn_rx_compressed_ba()
3259 tap = sc->qid2tap[qid]; in iwn_rx_compressed_ba()
3260 ring = &sc->txq[qid]; in iwn_rx_compressed_ba()
3261 tid = tap->txa_tid; in iwn_rx_compressed_ba()
3262 wn = (void *)tap->txa_ni; in iwn_rx_compressed_ba()
3266 __func__, qid, tid, le16toh(ba->seq), le16toh(ba->ssn), in iwn_rx_compressed_ba()
3267 (uintmax_t)le64toh(ba->bitmap), (uintmax_t)wn->agg[tid].bitmap, in iwn_rx_compressed_ba()
3268 wn->agg[tid].startidx); in iwn_rx_compressed_ba()
3270 if (wn->agg[tid].bitmap == 0) in iwn_rx_compressed_ba()
3273 shift = wn->agg[tid].startidx - ((le16toh(ba->seq) >> 4) & 0xff); in iwn_rx_compressed_ba()
3274 if (shift <= -64) in iwn_rx_compressed_ba()
3281 * Yes, the rate control code doesn't know these are A-MPDU in iwn_rx_compressed_ba()
3284 bitmap = le64toh(ba->bitmap); in iwn_rx_compressed_ba()
3288 bitmap <<= -shift; in iwn_rx_compressed_ba()
3289 bitmap &= wn->agg[tid].bitmap; in iwn_rx_compressed_ba()
3290 wn->agg[tid].bitmap = 0; in iwn_rx_compressed_ba()
3292 for (i = wn->agg[tid].startidx; in iwn_rx_compressed_ba()
3298 data = &ring->data[i]; in iwn_rx_compressed_ba()
3299 if (__predict_false(data->m == NULL)) { in iwn_rx_compressed_ba()
3316 ring->queued -= tx_ok; in iwn_rx_compressed_ba()
3320 "->%s: end; %d ok\n",__func__, tx_ok); in iwn_rx_compressed_ba()
3331 int len, idx = -1; in iwn5000_rx_calib_results()
3333 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn5000_rx_calib_results()
3336 if (sc->sc_flags & IWN_FLAG_CALIB_DONE){ in iwn5000_rx_calib_results()
3338 "->%s received after calib done\n", __func__); in iwn5000_rx_calib_results()
3341 len = (le32toh(desc->len) & 0x3fff) - 4; in iwn5000_rx_calib_results()
3343 switch (calib->code) { in iwn5000_rx_calib_results()
3345 if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_DC) in iwn5000_rx_calib_results()
3349 if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_LO) in iwn5000_rx_calib_results()
3353 if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_TX_IQ) in iwn5000_rx_calib_results()
3357 if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_TX_IQ_PERIODIC) in iwn5000_rx_calib_results()
3361 if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_BASE_BAND) in iwn5000_rx_calib_results()
3365 if (idx == -1) /* Ignore other results. */ in iwn5000_rx_calib_results()
3369 if (sc->calibcmd[idx].buf != NULL) in iwn5000_rx_calib_results()
3370 free(sc->calibcmd[idx].buf, M_DEVBUF); in iwn5000_rx_calib_results()
3371 sc->calibcmd[idx].buf = malloc(len, M_DEVBUF, M_NOWAIT); in iwn5000_rx_calib_results()
3372 if (sc->calibcmd[idx].buf == NULL) { in iwn5000_rx_calib_results()
3375 calib->code); in iwn5000_rx_calib_results()
3379 "saving calibration result idx=%d, code=%d len=%d\n", idx, calib->code, len); in iwn5000_rx_calib_results()
3380 sc->calibcmd[idx].len = len; in iwn5000_rx_calib_results()
3381 memcpy(sc->calibcmd[idx].buf, calib, len); in iwn5000_rx_calib_results()
3392 * First - check whether the length is the bluetooth or normal. in iwn_stats_update()
3394 * If it's normal - just copy it and bump out. in iwn_stats_update()
3399 memcpy(&sc->last_stat, stats, sizeof(struct iwn_stats)); in iwn_stats_update()
3400 sc->last_stat_valid = 1; in iwn_stats_update()
3405 * If it's not the bluetooth size - log, then just copy. in iwn_stats_update()
3412 memcpy(&sc->last_stat, stats, sizeof(struct iwn_stats)); in iwn_stats_update()
3413 sc->last_stat_valid = 1; in iwn_stats_update()
3421 lstats = &sc->last_stat; in iwn_stats_update()
3424 lstats->flags = stats_bt->flags; in iwn_stats_update()
3426 memcpy(&lstats->rx.ofdm, &stats_bt->rx_bt.ofdm, in iwn_stats_update()
3428 memcpy(&lstats->rx.cck, &stats_bt->rx_bt.cck, in iwn_stats_update()
3430 memcpy(&lstats->rx.general, &stats_bt->rx_bt.general_bt.common, in iwn_stats_update()
3432 memcpy(&lstats->rx.ht, &stats_bt->rx_bt.ht, in iwn_stats_update()
3435 memcpy(&lstats->tx, &stats_bt->tx, in iwn_stats_update()
3438 memcpy(&lstats->general, &stats_bt->general, in iwn_stats_update()
3442 sc->last_stat_valid = 1; in iwn_stats_update()
3452 struct iwn_ops *ops = &sc->ops; in iwn_rx_statistics()
3453 struct ieee80211com *ic = &sc->sc_ic; in iwn_rx_statistics()
3454 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in iwn_rx_statistics()
3455 struct iwn_calib_state *calib = &sc->calib; in iwn_rx_statistics()
3460 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_rx_statistics()
3463 if (vap->iv_state != IEEE80211_S_RUN || in iwn_rx_statistics()
3464 (ic->ic_flags & IEEE80211_F_SCAN)){ in iwn_rx_statistics()
3465 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s received during calib\n", in iwn_rx_statistics()
3472 __func__, desc->type, le16toh(desc->len)); in iwn_rx_statistics()
3473 sc->calib_cnt = 0; /* Reset TX power calibration timeout. */ in iwn_rx_statistics()
3481 iwn_stats_update(sc, calib, stats, le16toh(desc->len)); in iwn_rx_statistics()
3486 lstats = &sc->last_stat; in iwn_rx_statistics()
3489 if (lstats->general.temp != sc->rawtemp) { in iwn_rx_statistics()
3491 sc->rawtemp = stats->general.temp; in iwn_rx_statistics()
3492 temp = ops->get_temperature(sc); in iwn_rx_statistics()
3497 if (sc->hw_type == IWN_HW_REV_TYPE_4965) in iwn_rx_statistics()
3501 if (desc->type != IWN_BEACON_STATISTICS) in iwn_rx_statistics()
3504 sc->noise = iwn_get_noise(&lstats->rx.general); in iwn_rx_statistics()
3505 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: noise %d\n", __func__, sc->noise); in iwn_rx_statistics()
3508 if (le32toh(lstats->rx.general.flags) != 1) { in iwn_rx_statistics()
3514 if (calib->state == IWN_CALIB_STATE_ASSOC) in iwn_rx_statistics()
3515 iwn_collect_noise(sc, &lstats->rx.general); in iwn_rx_statistics()
3516 else if (calib->state == IWN_CALIB_STATE_RUN) { in iwn_rx_statistics()
3517 iwn_tune_sensitivity(sc, &lstats->rx); in iwn_rx_statistics()
3525 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_rx_statistics()
3535 struct iwn_calib_state *calib = &sc->calib; in iwn_save_stats_counters()
3538 calib->bad_plcp_cck = le32toh(rs->rx.cck.bad_plcp); in iwn_save_stats_counters()
3539 calib->fa_cck = le32toh(rs->rx.cck.fa); in iwn_save_stats_counters()
3540 calib->bad_plcp_ht = le32toh(rs->rx.ht.bad_plcp); in iwn_save_stats_counters()
3541 calib->bad_plcp_ofdm = le32toh(rs->rx.ofdm.bad_plcp); in iwn_save_stats_counters()
3542 calib->fa_ofdm = le32toh(rs->rx.ofdm.fa); in iwn_save_stats_counters()
3545 sc->last_calib_ticks = ticks; in iwn_save_stats_counters()
3557 int qid = desc->qid & IWN_RX_DESC_QID_MSK; in iwn4965_tx_done()
3561 __func__, desc->qid, desc->idx, in iwn4965_tx_done()
3562 stat->rtsfailcnt, in iwn4965_tx_done()
3563 stat->ackfailcnt, in iwn4965_tx_done()
3564 stat->btkillcnt, in iwn4965_tx_done()
3565 stat->rate, le16toh(stat->duration), in iwn4965_tx_done()
3566 le32toh(stat->status)); in iwn4965_tx_done()
3568 if (qid >= sc->firstaggqueue && stat->nframes != 1) { in iwn4965_tx_done()
3569 iwn_ampdu_tx_done(sc, qid, stat->nframes, stat->rtsfailcnt, in iwn4965_tx_done()
3570 &stat->status); in iwn4965_tx_done()
3572 iwn_tx_done(sc, desc, stat->rtsfailcnt, stat->ackfailcnt, in iwn4965_tx_done()
3573 le32toh(stat->status) & 0xff); in iwn4965_tx_done()
3582 int qid = desc->qid & IWN_RX_DESC_QID_MSK; in iwn5000_tx_done()
3586 __func__, desc->qid, desc->idx, in iwn5000_tx_done()
3587 stat->rtsfailcnt, in iwn5000_tx_done()
3588 stat->ackfailcnt, in iwn5000_tx_done()
3589 stat->btkillcnt, in iwn5000_tx_done()
3590 stat->rate, le16toh(stat->duration), in iwn5000_tx_done()
3591 le32toh(stat->status)); in iwn5000_tx_done()
3595 iwn5000_reset_sched(sc, qid, desc->idx); in iwn5000_tx_done()
3598 if (qid >= sc->firstaggqueue && stat->nframes != 1) { in iwn5000_tx_done()
3599 iwn_ampdu_tx_done(sc, qid, stat->nframes, stat->rtsfailcnt, in iwn5000_tx_done()
3600 &stat->status); in iwn5000_tx_done()
3602 iwn_tx_done(sc, desc, stat->rtsfailcnt, stat->ackfailcnt, in iwn5000_tx_done()
3603 le16toh(stat->status) & 0xff); in iwn5000_tx_done()
3612 for (i = ring->read; i != ring->cur; i = (i + 1) % IWN_TX_RING_COUNT) { in iwn_adj_ampdu_ptr()
3613 struct iwn_tx_data *data = &ring->data[i]; in iwn_adj_ampdu_ptr()
3615 if (data->m != NULL) in iwn_adj_ampdu_ptr()
3618 data->remapped = 0; in iwn_adj_ampdu_ptr()
3621 ring->read = i; in iwn_adj_ampdu_ptr()
3625 * Adapter-independent backend for TX_DONE firmware notifications.
3631 struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs; in iwn_tx_done() local
3632 struct iwn_tx_ring *ring = &sc->txq[desc->qid & IWN_RX_DESC_QID_MSK]; in iwn_tx_done()
3633 struct iwn_tx_data *data = &ring->data[desc->idx]; in iwn_tx_done()
3637 if (__predict_false(data->m == NULL && in iwn_tx_done()
3638 ring->qid >= sc->firstaggqueue)) { in iwn_tx_done()
3643 __func__, ring->qid, desc->idx); in iwn_tx_done()
3647 KASSERT(data->ni != NULL, ("no node")); in iwn_tx_done()
3648 KASSERT(data->m != NULL, ("no mbuf")); in iwn_tx_done()
3650 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_tx_done()
3653 bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTWRITE); in iwn_tx_done()
3654 bus_dmamap_unload(ring->data_dmat, data->map); in iwn_tx_done()
3655 m = data->m, data->m = NULL; in iwn_tx_done()
3656 ni = data->ni, data->ni = NULL; in iwn_tx_done()
3658 data->long_retries = 0; in iwn_tx_done()
3660 if (ring->qid >= sc->firstaggqueue) in iwn_tx_done()
3664 * XXX f/w may hang (device timeout) when desc->idx - ring->read == 64 in iwn_tx_done()
3668 ring->queued--; in iwn_tx_done()
3669 iwn_check_tx_ring(sc, ring->qid); in iwn_tx_done()
3674 txs->flags = IEEE80211_RATECTL_STATUS_SHORT_RETRY | in iwn_tx_done()
3676 txs->short_retries = rtsfailcnt; in iwn_tx_done()
3677 txs->long_retries = ackfailcnt; in iwn_tx_done()
3679 txs->status = IEEE80211_RATECTL_TX_SUCCESS; in iwn_tx_done()
3683 txs->status = IEEE80211_RATECTL_TX_FAIL_SHORT; in iwn_tx_done()
3686 txs->status = IEEE80211_RATECTL_TX_FAIL_LONG; in iwn_tx_done()
3689 txs->status = IEEE80211_RATECTL_TX_FAIL_EXPIRED; in iwn_tx_done()
3692 txs->status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED; in iwn_tx_done()
3696 ieee80211_ratectl_tx_complete(ni, txs); in iwn_tx_done()
3713 ni->ni_vap->iv_state == IEEE80211_S_AUTH) in iwn_tx_done()
3719 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_tx_done()
3733 if (sc->sc_flags & IWN_FLAG_PAN_SUPPORT) in iwn_cmd_done()
3738 if ((desc->qid & IWN_RX_DESC_QID_MSK) != cmd_queue_num) in iwn_cmd_done()
3741 ring = &sc->txq[cmd_queue_num]; in iwn_cmd_done()
3742 data = &ring->data[desc->idx]; in iwn_cmd_done()
3745 if (data->m != NULL) { in iwn_cmd_done()
3746 bus_dmamap_sync(ring->data_dmat, data->map, in iwn_cmd_done()
3748 bus_dmamap_unload(ring->data_dmat, data->map); in iwn_cmd_done()
3749 m_freem(data->m); in iwn_cmd_done()
3750 data->m = NULL; in iwn_cmd_done()
3752 wakeup(&ring->desc[desc->idx]); in iwn_cmd_done()
3760 bit = idx - start; in iwn_ampdu_check_bitmap()
3763 shift = 0x100 - bit; in iwn_ampdu_check_bitmap()
3765 } else if (bit <= -64) in iwn_ampdu_check_bitmap()
3768 shift = -bit; in iwn_ampdu_check_bitmap()
3772 if (bit - shift >= 64) in iwn_ampdu_check_bitmap()
3775 return ((bitmap & (1ULL << (bit - shift))) != 0); in iwn_ampdu_check_bitmap()
3799 * For even 'seqno' % 4 != 0 overflow is cyclic (0 -> +1 -> 0).
3807 struct ieee80211com *ic = &sc->sc_ic; in iwn_ampdu_index_check()
3811 new_idx = idx - IWN_LONG_RETRY_LIMIT_LOG; in iwn_ampdu_index_check()
3820 data = &ring->data[new_idx]; in iwn_ampdu_index_check()
3821 if (data->long_retries > IWN_LONG_RETRY_LIMIT) { in iwn_ampdu_index_check()
3822 device_printf(sc->sc_dev, in iwn_ampdu_index_check()
3824 "resetting...\n", __func__, data->long_retries, in iwn_ampdu_index_check()
3825 ring->qid, new_idx); in iwn_ampdu_index_check()
3827 return (-1); in iwn_ampdu_index_check()
3834 data = &ring->data[new_idx]; in iwn_ampdu_index_check()
3835 diff = idx - new_idx; in iwn_ampdu_index_check()
3846 ((data->long_retries >= min_retries && in iwn_ampdu_index_check()
3847 data->long_retries < max_retries) || in iwn_ampdu_index_check()
3850 data->long_retries >= IWN_LONG_RETRY_FW_OVERFLOW))) { in iwn_ampdu_index_check()
3852 "%s: correcting index %d -> %d in queue %d" in iwn_ampdu_index_check()
3854 ring->qid, data->long_retries); in iwn_ampdu_index_check()
3868 struct iwn_tx_ring *ring = &sc->txq[qid]; in iwn_ampdu_tx_done()
3869 struct ieee80211_tx_ampdu *tap = sc->qid2tap[qid]; in iwn_ampdu_tx_done()
3870 struct iwn_node *wn = (void *)tap->txa_ni; in iwn_ampdu_tx_done()
3874 uint8_t tid = tap->txa_tid; in iwn_ampdu_tx_done()
3877 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_ampdu_tx_done()
3888 data = &ring->data[idx]; in iwn_ampdu_tx_done()
3889 if (data->remapped) { in iwn_ampdu_tx_done()
3891 if (idx == -1) { in iwn_ampdu_tx_done()
3897 data = &ring->data[idx]; in iwn_ampdu_tx_done()
3904 data->long_retries &= ~0x0f; in iwn_ampdu_tx_done()
3905 data->long_retries += IWN_AGG_TX_TRY_COUNT(status) + 1; in iwn_ampdu_tx_done()
3907 if (data->long_retries >= IWN_LONG_RETRY_FW_OVERFLOW) { in iwn_ampdu_tx_done()
3910 diff = data->long_retries / IWN_LONG_RETRY_FW_OVERFLOW; in iwn_ampdu_tx_done()
3917 ring->data[wrong_idx].remapped = 1; in iwn_ampdu_tx_done()
3922 * NB: count retries but postpone - it was not in iwn_ampdu_tx_done()
3928 bit = idx - start; in iwn_ampdu_tx_done()
3931 shift = 0x100 - bit; in iwn_ampdu_tx_done()
3933 } else if (bit <= -64) in iwn_ampdu_tx_done()
3936 shift = -bit; in iwn_ampdu_tx_done()
3942 wn->agg[tid].startidx = start; in iwn_ampdu_tx_done()
3943 wn->agg[tid].bitmap = bitmap; in iwn_ampdu_tx_done()
3944 wn->agg[tid].short_retries = rtsfailcnt; in iwn_ampdu_tx_done()
3949 i = ring->read; in iwn_ampdu_tx_done()
3952 i != wn->agg[tid].startidx; in iwn_ampdu_tx_done()
3954 data = &ring->data[i]; in iwn_ampdu_tx_done()
3955 data->remapped = 0; in iwn_ampdu_tx_done()
3956 if (data->m == NULL) in iwn_ampdu_tx_done()
3963 ring->read = wn->agg[tid].startidx; in iwn_ampdu_tx_done()
3964 ring->queued -= tx_err; in iwn_ampdu_tx_done()
3968 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_ampdu_tx_done()
3977 struct iwn_ops *ops = &sc->ops; in iwn_notif_intr()
3978 struct ieee80211com *ic = &sc->sc_ic; in iwn_notif_intr()
3979 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in iwn_notif_intr()
3983 bus_dmamap_sync(sc->rxq.stat_dma.tag, sc->rxq.stat_dma.map, in iwn_notif_intr()
3986 hw = le16toh(sc->rxq.stat->closed_count) & 0xfff; in iwn_notif_intr()
3987 while (sc->rxq.cur != hw) { in iwn_notif_intr()
3988 struct iwn_rx_data *data = &sc->rxq.data[sc->rxq.cur]; in iwn_notif_intr()
3991 bus_dmamap_sync(sc->rxq.data_dmat, data->map, in iwn_notif_intr()
3993 desc = mtod(data->m, struct iwn_rx_desc *); in iwn_notif_intr()
3997 __func__, sc->rxq.cur, desc->qid & IWN_RX_DESC_QID_MSK, in iwn_notif_intr()
3998 desc->idx, desc->flags, desc->type, in iwn_notif_intr()
3999 iwn_intr_str(desc->type), le16toh(desc->len)); in iwn_notif_intr()
4001 if (!(desc->qid & IWN_UNSOLICITED_RX_NOTIF)) /* Reply to a command. */ in iwn_notif_intr()
4004 switch (desc->type) { in iwn_notif_intr()
4014 is_stopped = (sc->sc_flags & IWN_FLAG_RUNNING) == 0; in iwn_notif_intr()
4027 ops->tx_done(sc, desc, data); in iwn_notif_intr()
4041 misses = le32toh(miss->consecutive); in iwn_notif_intr()
4045 misses, le32toh(miss->total)); in iwn_notif_intr()
4050 if (vap->iv_state == IEEE80211_S_RUN && in iwn_notif_intr()
4051 (ic->ic_flags & IEEE80211_F_SCAN) == 0) { in iwn_notif_intr()
4054 if (misses >= vap->iv_bmissthreshold) { in iwn_notif_intr()
4059 is_stopped = (sc->sc_flags & in iwn_notif_intr()
4075 "subtype=%x alive=%x\n", uc->major, uc->minor, in iwn_notif_intr()
4076 uc->subtype, le32toh(uc->valid)); in iwn_notif_intr()
4078 if (le32toh(uc->valid) != 1) { in iwn_notif_intr()
4079 device_printf(sc->sc_dev, in iwn_notif_intr()
4083 if (uc->subtype == IWN_UCODE_INIT) { in iwn_notif_intr()
4085 memcpy(&sc->ucode_info, uc, sizeof (*uc)); in iwn_notif_intr()
4088 sc->errptr = le32toh(uc->errptr); in iwn_notif_intr()
4111 __func__, scan->chan, le32toh(scan->status)); in iwn_notif_intr()
4122 scan->nchan, scan->status, scan->chan); in iwn_notif_intr()
4124 sc->sc_is_scanning = 0; in iwn_notif_intr()
4125 callout_stop(&sc->scan_timeout); in iwn_notif_intr()
4130 is_stopped = (sc->sc_flags & IWN_FLAG_RUNNING) == 0; in iwn_notif_intr()
4141 sc->sc_flags |= IWN_FLAG_CALIB_DONE; in iwn_notif_intr()
4146 sc->rxq.cur = (sc->rxq.cur + 1) % IWN_RX_RING_COUNT; in iwn_notif_intr()
4150 hw = (hw == 0) ? IWN_RX_RING_COUNT - 1 : hw - 1; in iwn_notif_intr()
4156 * from power-down sleep mode.
4163 DPRINTF(sc, IWN_DEBUG_RESET, "%s: ucode wakeup from power-down sleep\n", in iwn_wakeup_intr()
4167 IWN_WRITE(sc, IWN_FH_RX_WPTR, sc->rxq.cur & ~7); in iwn_wakeup_intr()
4168 for (qid = 0; qid < sc->ntxqs; qid++) { in iwn_wakeup_intr()
4169 struct iwn_tx_ring *ring = &sc->txq[qid]; in iwn_wakeup_intr()
4170 IWN_WRITE(sc, IWN_HBUS_TARG_WRPTR, qid << 8 | ring->cur); in iwn_wakeup_intr()
4178 struct ieee80211com *ic = &sc->sc_ic; in iwn_rftoggle_task()
4185 device_printf(sc->sc_dev, "RF switch: radio %s\n", in iwn_rftoggle_task()
4193 IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask); in iwn_rftoggle_task()
4213 sc->sc_flags &= ~IWN_FLAG_CALIB_DONE; in iwn_fatal_intr()
4216 if (sc->errptr < IWN_FW_DATA_BASE || in iwn_fatal_intr()
4217 sc->errptr + sizeof (dump) > in iwn_fatal_intr()
4218 IWN_FW_DATA_BASE + sc->fw_data_maxsz) { in iwn_fatal_intr()
4220 sc->errptr); in iwn_fatal_intr()
4228 iwn_mem_read_region_4(sc, sc->errptr, (uint32_t *)&dump, in iwn_fatal_intr()
4253 for (i = 0; i < sc->ntxqs; i++) { in iwn_fatal_intr()
4254 struct iwn_tx_ring *ring = &sc->txq[i]; in iwn_fatal_intr()
4255 printf(" tx ring %2d: qid=%-2d cur=%-3d queued=%-3d\n", in iwn_fatal_intr()
4256 i, ring->qid, ring->cur, ring->queued); in iwn_fatal_intr()
4258 printf(" rx ring: cur=%d\n", sc->rxq.cur); in iwn_fatal_intr()
4273 if (sc->sc_flags & IWN_FLAG_USE_ICT) { in iwn_intr()
4274 bus_dmamap_sync(sc->ict_dma.tag, sc->ict_dma.map, in iwn_intr()
4277 while (sc->ict[sc->ict_cur] != 0) { in iwn_intr()
4278 tmp |= sc->ict[sc->ict_cur]; in iwn_intr()
4279 sc->ict[sc->ict_cur] = 0; /* Acknowledge. */ in iwn_intr()
4280 sc->ict_cur = (sc->ict_cur + 1) % IWN_ICT_COUNT; in iwn_intr()
4306 if (!(sc->sc_flags & IWN_FLAG_USE_ICT)) in iwn_intr()
4310 taskqueue_enqueue(sc->sc_tq, &sc->sc_rftoggle_task); in iwn_intr()
4314 device_printf(sc->sc_dev, "%s: critical temperature reached!\n", in iwn_intr()
4318 device_printf(sc->sc_dev, "%s: fatal firmware error\n", in iwn_intr()
4326 taskqueue_enqueue(sc->sc_tq, &sc->sc_panic_task); in iwn_intr()
4331 if (sc->sc_flags & IWN_FLAG_USE_ICT) { in iwn_intr()
4346 if (sc->sc_flags & IWN_FLAG_USE_ICT) in iwn_intr()
4358 /* Re-enable interrupts. */ in iwn_intr()
4359 if (sc->sc_flags & IWN_FLAG_RUNNING) in iwn_intr()
4360 IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask); in iwn_intr()
4373 uint16_t *w = &sc->sched[qid * IWN4965_SCHED_COUNT + idx]; in iwn4965_update_sched()
4375 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_update_sched()
4378 bus_dmamap_sync(sc->sched_dma.tag, sc->sched_dma.map, in iwn4965_update_sched()
4382 bus_dmamap_sync(sc->sched_dma.tag, sc->sched_dma.map, in iwn4965_update_sched()
4391 uint16_t *w = &sc->sched[qid * IWN5000_SCHED_COUNT + idx]; in iwn5000_update_sched()
4393 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_update_sched()
4396 bus_dmamap_sync(sc->sched_dma.tag, sc->sched_dma.map, in iwn5000_update_sched()
4400 bus_dmamap_sync(sc->sched_dma.tag, sc->sched_dma.map, in iwn5000_update_sched()
4409 uint16_t *w = &sc->sched[qid * IWN5000_SCHED_COUNT + idx]; in iwn5000_reset_sched()
4411 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_reset_sched()
4414 bus_dmamap_sync(sc->sched_dma.tag, sc->sched_dma.map, in iwn5000_reset_sched()
4418 bus_dmamap_sync(sc->sched_dma.tag, sc->sched_dma.map, in iwn5000_reset_sched()
4434 struct ieee80211com *ic = vap->iv_ic; in iwn_check_rate_needs_protection()
4440 if (! IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) { in iwn_check_rate_needs_protection()
4447 if ((vap->iv_flags & IEEE80211_F_USEPROT) == 0) in iwn_check_rate_needs_protection()
4451 * If it's an 11n rate - no protection. in iwn_check_rate_needs_protection()
4462 if (ieee80211_rate2phytype(ic->ic_rt, rate) == IEEE80211_T_CCK) in iwn_check_rate_needs_protection()
4472 * return a value between 0 and IWN_MAX_TX_RETRIES-1 as an index into
4488 if (IEEE80211_IS_CHAN_HT(ni->ni_chan) && ni->ni_htrates.rs_nrates > 0) in iwn_tx_rate_to_linkq_offset()
4497 rs = (struct ieee80211_rateset *) &ni->ni_htrates; in iwn_tx_rate_to_linkq_offset()
4498 nr = ni->ni_htrates.rs_nrates; in iwn_tx_rate_to_linkq_offset()
4500 rs = &ni->ni_rates; in iwn_tx_rate_to_linkq_offset()
4501 nr = rs->rs_nrates; in iwn_tx_rate_to_linkq_offset()
4507 for (i = 0; i < nr && i < IWN_MAX_TX_RETRIES - 1 ; i++) { in iwn_tx_rate_to_linkq_offset()
4512 cmp_rate = rs->rs_rates[(nr - 1) - i]; in iwn_tx_rate_to_linkq_offset()
4530 return (IWN_MAX_TX_RETRIES - 1); in iwn_tx_rate_to_linkq_offset()
4536 const struct ieee80211_txparam *tp = ni->ni_txparms; in iwn_tx_data()
4537 struct ieee80211vap *vap = ni->ni_vap; in iwn_tx_data()
4538 struct ieee80211com *ic = ni->ni_ic; in iwn_tx_data()
4550 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_tx_data()
4555 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in iwn_tx_data()
4559 qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0]; in iwn_tx_data()
4569 (m->m_flags & M_EAPOL) != 0) in iwn_tx_data()
4570 rate = tp->mgmtrate; in iwn_tx_data()
4571 else if (IEEE80211_IS_MULTICAST(wh->i_addr1)) in iwn_tx_data()
4572 rate = tp->mcastrate; in iwn_tx_data()
4573 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) in iwn_tx_data()
4574 rate = tp->ucastrate; in iwn_tx_data()
4578 rate = ni->ni_txrate; in iwn_tx_data()
4583 * go to the normal non-aggregation queue, and have a NONQOS TID in iwn_tx_data()
4588 if (m->m_flags & M_AMPDU_MPDU) { in iwn_tx_data()
4589 struct ieee80211_tx_ampdu *tap = &ni->ni_tx_ampdu[ac]; in iwn_tx_data()
4594 ac = *(int *)tap->txa_private; in iwn_tx_data()
4598 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in iwn_tx_data()
4607 totlen = m->m_pkthdr.len; in iwn_tx_data()
4610 struct iwn_tx_radiotap_header *tap = &sc->sc_txtap; in iwn_tx_data()
4612 tap->wt_flags = 0; in iwn_tx_data()
4613 tap->wt_rate = rate; in iwn_tx_data()
4615 tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP; in iwn_tx_data()
4621 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { in iwn_tx_data()
4630 if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG) in iwn_tx_data()
4633 /* Check if frame must be protected using RTS/CTS or CTS-to-self. */ in iwn_tx_data()
4634 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { in iwn_tx_data()
4636 if (totlen + IEEE80211_CRC_LEN > vap->iv_rtsthreshold) { in iwn_tx_data()
4639 if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) in iwn_tx_data()
4641 else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) in iwn_tx_data()
4644 (ic->ic_htprotmode == IEEE80211_PROT_RTSCTS)) { in iwn_tx_data()
4651 if (sc->hw_type != IWN_HW_REV_TYPE_4965) { in iwn_tx_data()
4652 /* 5000 autoselects RTS/CTS or CTS-to-self. */ in iwn_tx_data()
4660 ring = &sc->txq[ac]; in iwn_tx_data()
4661 if (m->m_flags & M_AMPDU_MPDU) { in iwn_tx_data()
4662 uint16_t seqno = ni->ni_txseqs[tid]; in iwn_tx_data()
4664 if (ring->queued > IWN_TX_RING_COUNT / 2 && in iwn_tx_data()
4665 (ring->cur + 1) % IWN_TX_RING_COUNT == ring->read) { in iwn_tx_data()
4668 __func__, ring->queued, ac); in iwn_tx_data()
4679 if ((seqno % 256) != ring->cur) { in iwn_tx_data()
4680 device_printf(sc->sc_dev, in iwn_tx_data()
4686 ring->cur); in iwn_tx_data()
4689 ni->ni_txseqs[tid] &= ~0xff; in iwn_tx_data()
4690 ni->ni_txseqs[tid] += ring->cur; in iwn_tx_data()
4691 seqno = ni->ni_txseqs[tid]; in iwn_tx_data()
4694 *(uint16_t *)wh->i_seq = in iwn_tx_data()
4696 ni->ni_txseqs[tid]++; in iwn_tx_data()
4700 cmd = &ring->cmd[ring->cur]; in iwn_tx_data()
4701 tx = (struct iwn_cmd_data *)cmd->data; in iwn_tx_data()
4704 tx->scratch = 0; /* clear "scratch" area */ in iwn_tx_data()
4706 if (IEEE80211_IS_MULTICAST(wh->i_addr1) || in iwn_tx_data()
4708 tx->id = sc->broadcast_id; in iwn_tx_data()
4710 tx->id = wn->id; in iwn_tx_data()
4713 uint8_t subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; in iwn_tx_data()
4720 tx->timeout = htole16(3); in iwn_tx_data()
4722 tx->timeout = htole16(2); in iwn_tx_data()
4724 tx->timeout = htole16(0); in iwn_tx_data()
4726 if (tx->id == sc->broadcast_id) { in iwn_tx_data()
4728 tx->linkq = 0; in iwn_tx_data()
4730 tx->linkq = iwn_tx_rate_to_linkq_offset(sc, ni, rate); in iwn_tx_data()
4734 tx->tid = tid; in iwn_tx_data()
4735 tx->rts_ntries = 60; in iwn_tx_data()
4736 tx->data_ntries = 15; in iwn_tx_data()
4737 tx->lifetime = htole32(IWN_LIFETIME_INFINITE); in iwn_tx_data()
4738 tx->rate = iwn_rate_to_plcp(sc, ni, rate); in iwn_tx_data()
4739 tx->security = 0; in iwn_tx_data()
4740 tx->flags = htole32(flags); in iwn_tx_data()
4749 struct ieee80211vap *vap = ni->ni_vap; in iwn_tx_data_raw()
4758 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_tx_data_raw()
4763 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in iwn_tx_data_raw()
4765 ac = params->ibp_pri & 3; in iwn_tx_data_raw()
4768 rate = params->ibp_rate0; in iwn_tx_data_raw()
4771 if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0) in iwn_tx_data_raw()
4773 if (params->ibp_flags & IEEE80211_BPF_RTS) { in iwn_tx_data_raw()
4774 if (sc->hw_type != IWN_HW_REV_TYPE_4965) { in iwn_tx_data_raw()
4775 /* 5000 autoselects RTS/CTS or CTS-to-self. */ in iwn_tx_data_raw()
4781 if (params->ibp_flags & IEEE80211_BPF_CTS) { in iwn_tx_data_raw()
4782 if (sc->hw_type != IWN_HW_REV_TYPE_4965) { in iwn_tx_data_raw()
4783 /* 5000 autoselects RTS/CTS or CTS-to-self. */ in iwn_tx_data_raw()
4791 struct iwn_tx_radiotap_header *tap = &sc->sc_txtap; in iwn_tx_data_raw()
4793 tap->wt_flags = 0; in iwn_tx_data_raw()
4794 tap->wt_rate = rate; in iwn_tx_data_raw()
4799 ring = &sc->txq[ac]; in iwn_tx_data_raw()
4800 cmd = &ring->cmd[ring->cur]; in iwn_tx_data_raw()
4802 tx = (struct iwn_cmd_data *)cmd->data; in iwn_tx_data_raw()
4804 tx->scratch = 0; /* clear "scratch" area */ in iwn_tx_data_raw()
4807 uint8_t subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; in iwn_tx_data_raw()
4815 tx->timeout = htole16(3); in iwn_tx_data_raw()
4817 tx->timeout = htole16(2); in iwn_tx_data_raw()
4819 tx->timeout = htole16(0); in iwn_tx_data_raw()
4821 tx->tid = 0; in iwn_tx_data_raw()
4822 tx->id = sc->broadcast_id; in iwn_tx_data_raw()
4823 tx->rts_ntries = params->ibp_try1; in iwn_tx_data_raw()
4824 tx->data_ntries = params->ibp_try0; in iwn_tx_data_raw()
4825 tx->lifetime = htole32(IWN_LIFETIME_INFINITE); in iwn_tx_data_raw()
4826 tx->rate = iwn_rate_to_plcp(sc, ni, rate); in iwn_tx_data_raw()
4827 tx->security = 0; in iwn_tx_data_raw()
4828 tx->flags = htole32(flags); in iwn_tx_data_raw()
4831 tx->linkq = 0; in iwn_tx_data_raw()
4840 struct iwn_ops *ops = &sc->ops; in iwn_tx_cmd()
4853 totlen = m->m_pkthdr.len; in iwn_tx_cmd()
4855 desc = &ring->desc[ring->cur]; in iwn_tx_cmd()
4856 data = &ring->data[ring->cur]; in iwn_tx_cmd()
4858 if (__predict_false(data->m != NULL || data->ni != NULL)) { in iwn_tx_cmd()
4859 device_printf(sc->sc_dev, "%s: ni (%p) or m (%p) for idx %d " in iwn_tx_cmd()
4860 "in queue %d is not NULL!\n", __func__, data->ni, data->m, in iwn_tx_cmd()
4861 ring->cur, ring->qid); in iwn_tx_cmd()
4866 cmd = &ring->cmd[ring->cur]; in iwn_tx_cmd()
4867 cmd->code = IWN_CMD_TX_DATA; in iwn_tx_cmd()
4868 cmd->flags = 0; in iwn_tx_cmd()
4869 cmd->qid = ring->qid; in iwn_tx_cmd()
4870 cmd->idx = ring->cur; in iwn_tx_cmd()
4872 tx = (struct iwn_cmd_data *)cmd->data; in iwn_tx_cmd()
4873 tx->len = htole16(totlen); in iwn_tx_cmd()
4876 tx->loaddr = htole32(IWN_LOADDR(data->scratch_paddr)); in iwn_tx_cmd()
4877 tx->hiaddr = IWN_HIADDR(data->scratch_paddr); in iwn_tx_cmd()
4880 tx->flags |= htole32(IWN_TX_NEED_PADDING); in iwn_tx_cmd()
4881 pad = 4 - (hdrlen & 3); in iwn_tx_cmd()
4891 error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m, segs, in iwn_tx_cmd()
4895 device_printf(sc->sc_dev, in iwn_tx_cmd()
4900 m1 = m_collapse(m, M_NOWAIT, IWN_MAX_SCATTER - 1); in iwn_tx_cmd()
4902 device_printf(sc->sc_dev, in iwn_tx_cmd()
4908 error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m, in iwn_tx_cmd()
4916 device_printf(sc->sc_dev, in iwn_tx_cmd()
4919 if_inc_counter(ni->ni_vap->iv_ifp, in iwn_tx_cmd()
4927 data->m = m; in iwn_tx_cmd()
4928 data->ni = ni; in iwn_tx_cmd()
4932 __func__, ring->qid, ring->cur, totlen, nsegs, tx->rate); in iwn_tx_cmd()
4935 desc->nsegs = 1; in iwn_tx_cmd()
4936 if (m->m_len != 0) in iwn_tx_cmd()
4937 desc->nsegs += nsegs; in iwn_tx_cmd()
4939 desc->segs[0].addr = htole32(IWN_LOADDR(data->cmd_paddr)); in iwn_tx_cmd()
4940 desc->segs[0].len = htole16(IWN_HIADDR(data->cmd_paddr) | in iwn_tx_cmd()
4945 desc->segs[i].addr = htole32(IWN_LOADDR(seg->ds_addr)); in iwn_tx_cmd()
4946 desc->segs[i].len = htole16(IWN_HIADDR(seg->ds_addr) | in iwn_tx_cmd()
4947 seg->ds_len << 4); in iwn_tx_cmd()
4951 bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE); in iwn_tx_cmd()
4952 bus_dmamap_sync(ring->cmd_dma.tag, ring->cmd_dma.map, in iwn_tx_cmd()
4954 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, in iwn_tx_cmd()
4958 if (ring->qid >= sc->firstaggqueue) in iwn_tx_cmd()
4959 ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen); in iwn_tx_cmd()
4962 ring->cur = (ring->cur + 1) % IWN_TX_RING_COUNT; in iwn_tx_cmd()
4963 IWN_WRITE(sc, IWN_HBUS_TARG_WRPTR, ring->qid << 8 | ring->cur); in iwn_tx_cmd()
4966 if (++ring->queued > IWN_TX_RING_HIMARK) in iwn_tx_cmd()
4967 sc->qfullmsk |= 1 << ring->qid; in iwn_tx_cmd()
4969 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_tx_cmd()
4991 while ((m = mbufq_dequeue(&sc->sc_xmit_queue)) != NULL) { in iwn_xmit_task()
4993 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in iwn_xmit_task()
5009 if_inc_counter(ni->ni_vap->iv_ifp, in iwn_xmit_task()
5016 sc->sc_beacon_wait = 0; in iwn_xmit_task()
5021 * raw frame xmit - free node/reference if failed.
5027 struct ieee80211com *ic = ni->ni_ic; in iwn_raw_xmit()
5028 struct iwn_softc *sc = ic->ic_softc; in iwn_raw_xmit()
5031 DPRINTF(sc, IWN_DEBUG_XMIT | IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_raw_xmit()
5034 if ((sc->sc_flags & IWN_FLAG_RUNNING) == 0) { in iwn_raw_xmit()
5041 if (sc->sc_beacon_wait) { in iwn_raw_xmit()
5066 sc->sc_tx_timer = 5; in iwn_raw_xmit()
5072 DPRINTF(sc, IWN_DEBUG_TRACE | IWN_DEBUG_XMIT, "->%s: end\n",__func__); in iwn_raw_xmit()
5078 * transmit - don't free mbuf if failed; don't free node ref if failed.
5083 struct iwn_softc *sc = ic->ic_softc; in iwn_transmit()
5087 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in iwn_transmit()
5090 if ((sc->sc_flags & IWN_FLAG_RUNNING) == 0 || sc->sc_beacon_wait) { in iwn_transmit()
5095 if (sc->qfullmsk) { in iwn_transmit()
5102 sc->sc_tx_timer = 5; in iwn_transmit()
5111 struct ieee80211com *ic = &sc->sc_ic; in iwn_scan_timeout()
5121 struct ieee80211com *ic = &sc->sc_ic; in iwn_watchdog()
5125 KASSERT(sc->sc_flags & IWN_FLAG_RUNNING, ("not running")); in iwn_watchdog()
5127 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_watchdog()
5129 if (sc->sc_tx_timer > 0) { in iwn_watchdog()
5130 if (--sc->sc_tx_timer == 0) { in iwn_watchdog()
5136 callout_reset(&sc->watchdog_to, hz, iwn_watchdog, sc); in iwn_watchdog()
5158 struct iwn_softc *sc = dev->si_drv1; in iwn_cdev_ioctl()
5170 rc = copyout(&sc->last_stat, d->dst_addr, sizeof(struct iwn_stats)); in iwn_cdev_ioctl()
5175 memset(&sc->last_stat, 0, sizeof(struct iwn_stats)); in iwn_cdev_ioctl()
5195 struct iwn_softc *sc = ic->ic_softc; in iwn_parent()
5199 if (ic->ic_nrunning > 0) { in iwn_parent()
5208 taskqueue_enqueue(sc->sc_tq, &sc->sc_rftoggle_task); in iwn_parent()
5211 vap = TAILQ_FIRST(&ic->ic_vaps); in iwn_parent()
5235 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_cmd()
5240 if (sc->sc_flags & IWN_FLAG_PAN_SUPPORT) in iwn_cmd()
5245 ring = &sc->txq[cmd_queue_num]; in iwn_cmd()
5246 desc = &ring->desc[ring->cur]; in iwn_cmd()
5247 data = &ring->data[ring->cur]; in iwn_cmd()
5250 if (size > sizeof cmd->data) { in iwn_cmd()
5258 error = bus_dmamap_load(ring->data_dmat, data->map, cmd, in iwn_cmd()
5264 data->m = m; in iwn_cmd()
5266 cmd = &ring->cmd[ring->cur]; in iwn_cmd()
5267 paddr = data->cmd_paddr; in iwn_cmd()
5270 cmd->code = code; in iwn_cmd()
5271 cmd->flags = 0; in iwn_cmd()
5272 cmd->qid = ring->qid; in iwn_cmd()
5273 cmd->idx = ring->cur; in iwn_cmd()
5274 memcpy(cmd->data, buf, size); in iwn_cmd()
5276 desc->nsegs = 1; in iwn_cmd()
5277 desc->segs[0].addr = htole32(IWN_LOADDR(paddr)); in iwn_cmd()
5278 desc->segs[0].len = htole16(IWN_HIADDR(paddr) | totlen << 4); in iwn_cmd()
5281 __func__, iwn_intr_str(cmd->code), cmd->code, in iwn_cmd()
5282 cmd->flags, cmd->qid, cmd->idx); in iwn_cmd()
5284 if (size > sizeof cmd->data) { in iwn_cmd()
5285 bus_dmamap_sync(ring->data_dmat, data->map, in iwn_cmd()
5288 bus_dmamap_sync(ring->cmd_dma.tag, ring->cmd_dma.map, in iwn_cmd()
5291 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, in iwn_cmd()
5295 ring->cur = (ring->cur + 1) % IWN_TX_RING_COUNT; in iwn_cmd()
5296 IWN_WRITE(sc, IWN_HBUS_TARG_WRPTR, ring->qid << 8 | ring->cur); in iwn_cmd()
5298 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_cmd()
5300 return async ? 0 : msleep(desc, &sc->sc_mtx, PCATCH, "iwncmd", hz); in iwn_cmd()
5309 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_add_node()
5328 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_add_node()
5343 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_set_link_quality()
5346 linkq.id = wn->id; in iwn_set_link_quality()
5359 sc->ntxchains); in iwn_set_link_quality()
5366 if (IEEE80211_IS_CHAN_HT(ni->ni_chan) && ni->ni_htrates.rs_nrates > 0) { in iwn_set_link_quality()
5367 rs = (struct ieee80211_rateset *) &ni->ni_htrates; in iwn_set_link_quality()
5370 rs = &ni->ni_rates; in iwn_set_link_quality()
5374 /* Start at highest available bit-rate. */ in iwn_set_link_quality()
5379 txrate = ni->ni_htrates.rs_nrates - 1; in iwn_set_link_quality()
5381 txrate = rs->rs_nrates - 1; in iwn_set_link_quality()
5393 rate = IEEE80211_RATE_MCS | rs->rs_rates[txrate]; in iwn_set_link_quality()
5395 rate = IEEE80211_RV(rs->rs_rates[txrate]); in iwn_set_link_quality()
5397 /* Do rate -> PLCP config mapping */ in iwn_set_link_quality()
5415 * _are_ doing a dual-stream rate, set mimo to idx+1 (ie, in iwn_set_link_quality()
5416 * the next entry.) That way if the next entry is a non-MIMO in iwn_set_link_quality()
5423 /* Next retry at immediate lower bit-rate. */ in iwn_set_link_quality()
5425 txrate--; in iwn_set_link_quality()
5429 * all MIMO rates (eg 5300 doing MCS23-15) then yes, in iwn_set_link_quality()
5437 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_set_link_quality()
5443 * Broadcast node is used to send group-addressed and management frames.
5448 struct iwn_ops *ops = &sc->ops; in iwn_add_broadcast_node()
5449 struct ieee80211com *ic = &sc->sc_ic; in iwn_add_broadcast_node()
5455 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_add_broadcast_node()
5457 sc->rxon = &sc->rx_on[IWN_RXON_BSS_CTX]; in iwn_add_broadcast_node()
5461 node.id = sc->broadcast_id; in iwn_add_broadcast_node()
5463 if ((error = ops->add_node(sc, &node, async)) != 0) in iwn_add_broadcast_node()
5467 txant = IWN_LSB(sc->txchainmask); in iwn_add_broadcast_node()
5470 linkq.id = sc->broadcast_id; in iwn_add_broadcast_node()
5477 /* Use lowest mandatory bit-rate. */ in iwn_add_broadcast_node()
5479 if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) in iwn_add_broadcast_node()
5484 /* Use same bit-rate for all TX retries. */ in iwn_add_broadcast_node()
5489 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_add_broadcast_node()
5497 #define IWN_EXP2(x) ((1 << (x)) - 1) /* CWmin = 2^ECWmin - 1 */ in iwn_updateedca()
5498 struct iwn_softc *sc = ic->ic_softc; in iwn_updateedca()
5503 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_updateedca()
5513 cmd.ac[aci].aifsn = ac->wmep_aifsn; in iwn_updateedca()
5514 cmd.ac[aci].cwmin = htole16(IWN_EXP2(ac->wmep_logcwmin)); in iwn_updateedca()
5515 cmd.ac[aci].cwmax = htole16(IWN_EXP2(ac->wmep_logcwmax)); in iwn_updateedca()
5517 htole16(IEEE80211_TXOP_TO_US(ac->wmep_txopLimit)); in iwn_updateedca()
5525 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_updateedca()
5534 struct ieee80211com *ic = &sc->sc_ic; in iwn_set_promisc()
5538 if (ic->ic_promisc > 0 || ic->ic_opmode == IEEE80211_M_MONITOR) in iwn_set_promisc()
5539 sc->rxon->filter |= htole32(promisc_filter); in iwn_set_promisc()
5541 sc->rxon->filter &= ~htole32(promisc_filter); in iwn_set_promisc()
5547 struct iwn_softc *sc = ic->ic_softc; in iwn_update_promisc()
5550 if (ic->ic_opmode == IEEE80211_M_MONITOR) in iwn_update_promisc()
5554 if (!(sc->sc_flags & IWN_FLAG_RUNNING)) { in iwn_update_promisc()
5561 device_printf(sc->sc_dev, in iwn_update_promisc()
5579 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_set_led()
5583 if (sc->sc_is_scanning) in iwn_set_led()
5607 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_set_critical_temp()
5611 if (sc->hw_type == IWN_HW_REV_TYPE_5150) in iwn_set_critical_temp()
5612 temp = (IWN_CTOK(110) - sc->temp_off) * -5; in iwn_set_critical_temp()
5613 else if (sc->hw_type == IWN_HW_REV_TYPE_4965) in iwn_set_critical_temp()
5629 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_set_timing()
5632 memcpy(&cmd.tstamp, ni->ni_tstamp.data, sizeof (uint64_t)); in iwn_set_timing()
5633 cmd.bintval = htole16(ni->ni_intval); in iwn_set_timing()
5637 val = (uint64_t)ni->ni_intval * IEEE80211_DUR_TU; in iwn_set_timing()
5639 cmd.binitval = htole32((uint32_t)(val - mod)); in iwn_set_timing()
5642 ni->ni_intval, le64toh(cmd.tstamp), (uint32_t)(val - mod)); in iwn_set_timing()
5651 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_power_calibration()
5653 /* Adjust TX power if need be (delta >= 3 degC). */ in iwn4965_power_calibration()
5654 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: temperature %d->%d\n", in iwn4965_power_calibration()
5655 __func__, sc->temp, temp); in iwn4965_power_calibration()
5656 if (abs(temp - sc->temp) >= 3) { in iwn4965_power_calibration()
5658 sc->temp = temp; in iwn4965_power_calibration()
5671 /* Fixed-point arithmetic division using a n-bit fractional part. */ in iwn4965_set_txpower()
5676 ((y1) + fdivround(((int)(x) - (x1)) * ((y2) - (y1)), (x2) - (x1), n)) in iwn4965_set_txpower()
5679 struct iwn_ucode_info *uc = &sc->ucode_info; in iwn4965_set_txpower()
5687 sc->rxon = &sc->rx_on[IWN_RXON_BSS_CTX]; in iwn4965_set_txpower()
5689 chan = sc->rxon->chan; in iwn4965_set_txpower()
5690 is_chan_5ghz = (sc->rxon->flags & htole32(IWN_RXON_24GHZ)) == 0; in iwn4965_set_txpower()
5699 maxpwr = sc->maxpwr5GHz; in iwn4965_set_txpower()
5703 maxpwr = sc->maxpwr2GHz; in iwn4965_set_txpower()
5709 vdiff = ((int32_t)le32toh(uc->volt) - sc->eeprom_voltage) / 7; in iwn4965_set_txpower()
5716 __func__, vdiff, le32toh(uc->volt), sc->eeprom_voltage); in iwn4965_set_txpower()
5719 if (chan <= 20) /* 1-20 */ in iwn4965_set_txpower()
5721 else if (chan <= 43) /* 34-43 */ in iwn4965_set_txpower()
5723 else if (chan <= 70) /* 44-70 */ in iwn4965_set_txpower()
5725 else if (chan <= 124) /* 71-124 */ in iwn4965_set_txpower()
5727 else /* 125-200 */ in iwn4965_set_txpower()
5732 /* Get channel sub-band. */ in iwn4965_set_txpower()
5734 if (sc->bands[i].lo != 0 && in iwn4965_set_txpower()
5735 sc->bands[i].lo <= chan && chan <= sc->bands[i].hi) in iwn4965_set_txpower()
5737 if (i == IWN_NBANDS) /* Can't happen in real-life. */ in iwn4965_set_txpower()
5739 chans = sc->bands[i].chans; in iwn4965_set_txpower()
5741 "%s: chan %d sub-band=%d\n", __func__, chan, i); in iwn4965_set_txpower()
5761 tdiff = ((sc->temp - temp) * 2) / tdiv[grp]; in iwn4965_set_txpower()
5764 __func__, tdiff, sc->temp, temp); in iwn4965_set_txpower()
5767 /* Convert dBm to half-dBm. */ in iwn4965_set_txpower()
5768 maxchpwr = sc->maxpwr[chan] * 2; in iwn4965_set_txpower()
5770 maxchpwr -= 6; /* MIMO 2T: -3dB */ in iwn4965_set_txpower()
5776 pwr -= 15; /* OFDM48: -7.5dB */ in iwn4965_set_txpower()
5778 pwr -= 17; /* OFDM54: -8.5dB */ in iwn4965_set_txpower()
5780 pwr -= 20; /* OFDM60: -10dB */ in iwn4965_set_txpower()
5782 pwr -= 10; /* Others: -5dB */ in iwn4965_set_txpower()
5788 idx = gain - (pwr - power) - tdiff - vdiff; in iwn4965_set_txpower()
5790 idx += (int32_t)le32toh(uc->atten[grp][c]); in iwn4965_set_txpower()
5825 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_set_txpower()
5838 IWN_UCODE_API(sc->ucode_rev)); in iwn5000_set_txpower()
5839 if (IWN_UCODE_API(sc->ucode_rev) == 1) in iwn5000_set_txpower()
5852 struct iwn4965_rx_phystat *phy = (void *)stat->phybuf; in iwn4965_get_rssi()
5856 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_get_rssi()
5858 mask = (le16toh(phy->antenna) >> 4) & IWN_ANT_ABC; in iwn4965_get_rssi()
5859 agc = (le16toh(phy->agc) >> 7) & 0x7f; in iwn4965_get_rssi()
5863 rssi = MAX(rssi, phy->rssi[0]); in iwn4965_get_rssi()
5865 rssi = MAX(rssi, phy->rssi[2]); in iwn4965_get_rssi()
5867 rssi = MAX(rssi, phy->rssi[4]); in iwn4965_get_rssi()
5871 mask, phy->rssi[0], phy->rssi[2], phy->rssi[4], in iwn4965_get_rssi()
5872 rssi - agc - IWN_RSSI_TO_DBM); in iwn4965_get_rssi()
5873 return rssi - agc - IWN_RSSI_TO_DBM; in iwn4965_get_rssi()
5879 struct iwn5000_rx_phystat *phy = (void *)stat->phybuf; in iwn5000_get_rssi()
5883 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_get_rssi()
5885 agc = (le32toh(phy->agc) >> 9) & 0x7f; in iwn5000_get_rssi()
5887 rssi = MAX(le16toh(phy->rssi[0]) & 0xff, in iwn5000_get_rssi()
5888 le16toh(phy->rssi[1]) & 0xff); in iwn5000_get_rssi()
5889 rssi = MAX(le16toh(phy->rssi[2]) & 0xff, rssi); in iwn5000_get_rssi()
5893 phy->rssi[0], phy->rssi[1], phy->rssi[2], in iwn5000_get_rssi()
5894 rssi - agc - IWN_RSSI_TO_DBM); in iwn5000_get_rssi()
5895 return rssi - agc - IWN_RSSI_TO_DBM; in iwn5000_get_rssi()
5908 if ((noise = le32toh(stats->noise[i]) & 0xff) == 0) in iwn_get_noise()
5914 return (nbant == 0) ? -127 : (total / nbant) - 107; in iwn_get_noise()
5923 struct iwn_ucode_info *uc = &sc->ucode_info; in iwn4965_get_temperature()
5926 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_get_temperature()
5928 r1 = le32toh(uc->temp[0].chan20MHz); in iwn4965_get_temperature()
5929 r2 = le32toh(uc->temp[1].chan20MHz); in iwn4965_get_temperature()
5930 r3 = le32toh(uc->temp[2].chan20MHz); in iwn4965_get_temperature()
5931 r4 = le32toh(sc->rawtemp); in iwn4965_get_temperature()
5936 /* Sign-extend 23-bit R4 value to 32-bit. */ in iwn4965_get_temperature()
5937 r4 = ((r4 & 0xffffff) ^ 0x800000) - 0x800000; in iwn4965_get_temperature()
5939 temp = (259 * (r4 - r2)) / (r3 - r1); in iwn4965_get_temperature()
5952 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_get_temperature()
5958 temp = le32toh(sc->rawtemp); in iwn5000_get_temperature()
5959 if (sc->hw_type == IWN_HW_REV_TYPE_5150) { in iwn5000_get_temperature()
5960 temp = (temp / -5) + sc->temp_off; in iwn5000_get_temperature()
5972 struct iwn_ops *ops = &sc->ops; in iwn_init_sensitivity()
5973 struct iwn_calib_state *calib = &sc->calib; in iwn_init_sensitivity()
5977 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_init_sensitivity()
5981 calib->state = IWN_CALIB_STATE_INIT; in iwn_init_sensitivity()
5982 calib->cck_state = IWN_CCK_STATE_HIFA; in iwn_init_sensitivity()
5984 calib->ofdm_x1 = sc->limits->min_ofdm_x1; in iwn_init_sensitivity()
5985 calib->ofdm_mrc_x1 = sc->limits->min_ofdm_mrc_x1; in iwn_init_sensitivity()
5986 calib->ofdm_x4 = sc->limits->min_ofdm_x4; in iwn_init_sensitivity()
5987 calib->ofdm_mrc_x4 = sc->limits->min_ofdm_mrc_x4; in iwn_init_sensitivity()
5988 calib->cck_x4 = 125; in iwn_init_sensitivity()
5989 calib->cck_mrc_x4 = sc->limits->min_cck_mrc_x4; in iwn_init_sensitivity()
5990 calib->energy_cck = sc->limits->energy_cck; in iwn_init_sensitivity()
5997 if ((error = ops->init_gains(sc)) != 0) in iwn_init_sensitivity()
6016 struct iwn_ops *ops = &sc->ops; in iwn_collect_noise()
6017 struct iwn_calib_state *calib = &sc->calib; in iwn_collect_noise()
6018 struct ieee80211com *ic = &sc->sc_ic; in iwn_collect_noise()
6022 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_collect_noise()
6026 calib->rssi[i] += le32toh(stats->rssi[i]) & 0xff; in iwn_collect_noise()
6027 calib->noise[i] += le32toh(stats->noise[i]) & 0xff; in iwn_collect_noise()
6030 if (++calib->nbeacons < 20) in iwn_collect_noise()
6034 val = MAX(calib->rssi[0], calib->rssi[1]); in iwn_collect_noise()
6035 val = MAX(calib->rssi[2], val); in iwn_collect_noise()
6038 sc->chainmask = sc->rxchainmask; in iwn_collect_noise()
6040 if (val - calib->rssi[i] > 15 * 20) in iwn_collect_noise()
6041 sc->chainmask &= ~(1 << i); in iwn_collect_noise()
6044 __func__, sc->rxchainmask, sc->chainmask); in iwn_collect_noise()
6047 if ((sc->chainmask & sc->txchainmask) == 0) in iwn_collect_noise()
6048 sc->chainmask |= IWN_LSB(sc->txchainmask); in iwn_collect_noise()
6050 (void)ops->set_gains(sc); in iwn_collect_noise()
6051 calib->state = IWN_CALIB_STATE_RUN; in iwn_collect_noise()
6055 sc->rxon->rxchain = htole16(IWN_RXCHAIN_SEL(sc->chainmask)); in iwn_collect_noise()
6056 if (sc->sc_is_scanning) in iwn_collect_noise()
6057 device_printf(sc->sc_dev, in iwn_collect_noise()
6060 (void)iwn_cmd(sc, IWN_CMD_RXON, sc->rxon, sc->rxonsz, 1); in iwn_collect_noise()
6063 /* Enable power-saving mode if requested by user. */ in iwn_collect_noise()
6064 if (ic->ic_flags & IEEE80211_F_PMGTON) in iwn_collect_noise()
6067 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_collect_noise()
6076 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_init_gains()
6091 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_init_gains()
6094 cmd.code = sc->reset_noise_gain; in iwn5000_init_gains()
6105 struct iwn_calib_state *calib = &sc->calib; in iwn4965_set_gains()
6107 int i, delta, noise; in iwn4965_set_gains() local
6109 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_set_gains()
6114 if (sc->chainmask & (1 << i)) in iwn4965_set_gains()
6115 noise = MIN(calib->noise[i], noise); in iwn4965_set_gains()
6121 if (sc->chainmask & (1 << i)) { in iwn4965_set_gains()
6123 delta = (noise - (int32_t)calib->noise[i]) / 30; in iwn4965_set_gains()
6124 /* NB: delta <= 0 */ in iwn4965_set_gains()
6125 /* Limit to [-4.5dB,0]. */ in iwn4965_set_gains()
6126 cmd.gain[i] = MIN(abs(delta), 3); in iwn4965_set_gains()
6127 if (delta < 0) in iwn4965_set_gains()
6133 cmd.gain[0], cmd.gain[1], cmd.gain[2], sc->chainmask); in iwn4965_set_gains()
6140 struct iwn_calib_state *calib = &sc->calib; in iwn5000_set_gains()
6142 int i, ant, div, delta; in iwn5000_set_gains() local
6144 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_set_gains()
6147 div = (sc->hw_type == IWN_HW_REV_TYPE_6050) ? 20 : 30; in iwn5000_set_gains()
6150 cmd.code = sc->noise_gain; in iwn5000_set_gains()
6154 ant = IWN_LSB(sc->rxchainmask); in iwn5000_set_gains()
6157 if (sc->chainmask & (1 << i)) { in iwn5000_set_gains()
6158 /* The delta is relative to antenna "ant". */ in iwn5000_set_gains()
6159 delta = ((int32_t)calib->noise[ant] - in iwn5000_set_gains()
6160 (int32_t)calib->noise[i]) / div; in iwn5000_set_gains()
6161 /* Limit to [-4.5dB,+4.5dB]. */ in iwn5000_set_gains()
6162 cmd.gain[i - 1] = MIN(abs(delta), 3); in iwn5000_set_gains()
6163 if (delta < 0) in iwn5000_set_gains()
6164 cmd.gain[i - 1] |= 1 << 2; /* sign bit */ in iwn5000_set_gains()
6169 cmd.gain[0], cmd.gain[1], sc->chainmask); in iwn5000_set_gains()
6182 if ((val) < (max) - (inc)) \ in iwn_tune_sensitivity()
6191 (val) -= (dec); \ in iwn_tune_sensitivity()
6197 const struct iwn_sensitivity_limits *limits = sc->limits; in iwn_tune_sensitivity()
6198 struct iwn_calib_state *calib = &sc->calib; in iwn_tune_sensitivity()
6204 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_tune_sensitivity()
6207 if ((rxena = le32toh(stats->general.load)) == 0){ in iwn_tune_sensitivity()
6208 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end not so long\n", __func__); in iwn_tune_sensitivity()
6213 fa = le32toh(stats->ofdm.bad_plcp) - calib->bad_plcp_ofdm; in iwn_tune_sensitivity()
6214 fa += le32toh(stats->ofdm.fa) - calib->fa_ofdm; in iwn_tune_sensitivity()
6221 inc(calib->ofdm_x1, 1, limits->max_ofdm_x1); in iwn_tune_sensitivity()
6222 inc(calib->ofdm_mrc_x1, 1, limits->max_ofdm_mrc_x1); in iwn_tune_sensitivity()
6223 inc(calib->ofdm_x4, 1, limits->max_ofdm_x4); in iwn_tune_sensitivity()
6224 inc(calib->ofdm_mrc_x4, 1, limits->max_ofdm_mrc_x4); in iwn_tune_sensitivity()
6230 dec(calib->ofdm_x1, 1, limits->min_ofdm_x1); in iwn_tune_sensitivity()
6231 dec(calib->ofdm_mrc_x1, 1, limits->min_ofdm_mrc_x1); in iwn_tune_sensitivity()
6232 dec(calib->ofdm_x4, 1, limits->min_ofdm_x4); in iwn_tune_sensitivity()
6233 dec(calib->ofdm_mrc_x4, 1, limits->min_ofdm_mrc_x4); in iwn_tune_sensitivity()
6238 noise[i] = (le32toh(stats->general.noise[i]) >> 8) & 0xff; in iwn_tune_sensitivity()
6242 calib->noise_samples[calib->cur_noise_sample] = val; in iwn_tune_sensitivity()
6243 calib->cur_noise_sample = (calib->cur_noise_sample + 1) % 20; in iwn_tune_sensitivity()
6246 noise_ref = calib->noise_samples[0]; in iwn_tune_sensitivity()
6248 noise_ref = MAX(noise_ref, calib->noise_samples[i]); in iwn_tune_sensitivity()
6252 energy[i] = le32toh(stats->general.energy[i]); in iwn_tune_sensitivity()
6256 calib->energy_samples[calib->cur_energy_sample] = val; in iwn_tune_sensitivity()
6257 calib->cur_energy_sample = (calib->cur_energy_sample + 1) % 10; in iwn_tune_sensitivity()
6260 energy_min = calib->energy_samples[0]; in iwn_tune_sensitivity()
6262 energy_min = MAX(energy_min, calib->energy_samples[i]); in iwn_tune_sensitivity()
6266 fa = le32toh(stats->cck.bad_plcp) - calib->bad_plcp_cck; in iwn_tune_sensitivity()
6267 fa += le32toh(stats->cck.fa) - calib->fa_cck; in iwn_tune_sensitivity()
6274 calib->cck_state = IWN_CCK_STATE_HIFA; in iwn_tune_sensitivity()
6275 calib->low_fa = 0; in iwn_tune_sensitivity()
6277 if (calib->cck_x4 > 160) { in iwn_tune_sensitivity()
6278 calib->noise_ref = noise_ref; in iwn_tune_sensitivity()
6279 if (calib->energy_cck > 2) in iwn_tune_sensitivity()
6280 dec(calib->energy_cck, 2, energy_min); in iwn_tune_sensitivity()
6282 if (calib->cck_x4 < 160) { in iwn_tune_sensitivity()
6283 calib->cck_x4 = 161; in iwn_tune_sensitivity()
6286 inc(calib->cck_x4, 3, limits->max_cck_x4); in iwn_tune_sensitivity()
6288 inc(calib->cck_mrc_x4, 3, limits->max_cck_mrc_x4); in iwn_tune_sensitivity()
6294 calib->cck_state = IWN_CCK_STATE_LOFA; in iwn_tune_sensitivity()
6295 calib->low_fa++; in iwn_tune_sensitivity()
6297 if (calib->cck_state != IWN_CCK_STATE_INIT && in iwn_tune_sensitivity()
6298 (((int32_t)calib->noise_ref - (int32_t)noise_ref) > 2 || in iwn_tune_sensitivity()
6299 calib->low_fa > 100)) { in iwn_tune_sensitivity()
6300 inc(calib->energy_cck, 2, limits->min_energy_cck); in iwn_tune_sensitivity()
6301 dec(calib->cck_x4, 3, limits->min_cck_x4); in iwn_tune_sensitivity()
6302 dec(calib->cck_mrc_x4, 3, limits->min_cck_mrc_x4); in iwn_tune_sensitivity()
6308 calib->low_fa = 0; in iwn_tune_sensitivity()
6309 calib->noise_ref = noise_ref; in iwn_tune_sensitivity()
6311 if (calib->cck_state == IWN_CCK_STATE_HIFA) { in iwn_tune_sensitivity()
6313 dec(calib->energy_cck, 8, energy_min); in iwn_tune_sensitivity()
6315 calib->cck_state = IWN_CCK_STATE_INIT; in iwn_tune_sensitivity()
6321 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_tune_sensitivity()
6330 struct iwn_calib_state *calib = &sc->calib; in iwn_send_sensitivity()
6338 cmd.corr_ofdm_x1 = htole16(calib->ofdm_x1); in iwn_send_sensitivity()
6339 cmd.corr_ofdm_mrc_x1 = htole16(calib->ofdm_mrc_x1); in iwn_send_sensitivity()
6340 cmd.corr_ofdm_x4 = htole16(calib->ofdm_x4); in iwn_send_sensitivity()
6341 cmd.corr_ofdm_mrc_x4 = htole16(calib->ofdm_mrc_x4); in iwn_send_sensitivity()
6342 cmd.energy_ofdm = htole16(sc->limits->energy_ofdm); in iwn_send_sensitivity()
6345 cmd.corr_cck_x4 = htole16(calib->cck_x4); in iwn_send_sensitivity()
6346 cmd.corr_cck_mrc_x4 = htole16(calib->cck_mrc_x4); in iwn_send_sensitivity()
6347 cmd.energy_cck = htole16(calib->energy_cck); in iwn_send_sensitivity()
6350 cmd.corr_barker_mrc = htole16(sc->limits->barker_mrc); in iwn_send_sensitivity()
6354 calib->ofdm_x1, calib->ofdm_mrc_x1, calib->ofdm_x4, in iwn_send_sensitivity()
6355 calib->ofdm_mrc_x4, calib->cck_x4, in iwn_send_sensitivity()
6356 calib->cck_mrc_x4, calib->energy_cck); in iwn_send_sensitivity()
6358 if (!(sc->sc_flags & IWN_FLAG_ENH_SENS)) in iwn_send_sensitivity()
6382 struct iwn_calib_state *calib = &sc->calib; in iwn_check_rx_recovery()
6391 delta_cck = le32toh(rs->rx.cck.bad_plcp) - calib->bad_plcp_cck; in iwn_check_rx_recovery()
6392 delta_ofdm = le32toh(rs->rx.ofdm.bad_plcp) - calib->bad_plcp_ofdm; in iwn_check_rx_recovery()
6393 delta_ht = le32toh(rs->rx.ht.bad_plcp) - calib->bad_plcp_ht; in iwn_check_rx_recovery()
6396 * Calculate the delta in time between successive statistics in iwn_check_rx_recovery()
6401 * XXX go figure out what to do if ticks rolls over to -ve instead! in iwn_check_rx_recovery()
6402 * XXX go stab signed integer overflow undefined-ness in the face. in iwn_check_rx_recovery()
6405 delta_ticks = cur_ticks - sc->last_calib_ticks; in iwn_check_rx_recovery()
6423 thresh = sc->base_params->plcp_err_threshold * delta_msec; in iwn_check_rx_recovery()
6426 "%s: time delta: %d; cck=%d, ofdm=%d, ht=%d, total=%d, thresh=%d\n", in iwn_check_rx_recovery()
6441 * if ((delta * 100 / msecs) > threshold) in iwn_check_rx_recovery()
6488 reg = pci_read_config(sc->sc_dev, sc->sc_cap_off + PCIER_LINK_CTL, 4); in iwn_set_pslevel()
6491 cmd.rxtimeout = htole32(pmgt->rxtimeout * 1024); in iwn_set_pslevel()
6492 cmd.txtimeout = htole32(pmgt->txtimeout * 1024); in iwn_set_pslevel()
6498 skip_dtim = pmgt->skip_dtim; in iwn_set_pslevel()
6501 max = pmgt->intval[4]; in iwn_set_pslevel()
6502 if (max == (uint32_t)-1) in iwn_set_pslevel()
6509 cmd.intval[i] = htole32(MIN(max, pmgt->intval[i])); in iwn_set_pslevel()
6551 if (sc->base_params->bt_sco_disable) in iwn_send_advanced_btcoex()
6564 if (sc->base_params->bt_session_2) { in iwn_send_advanced_btcoex()
6657 htflags |= IWN_RXON_HT_PROTMODE(vap->iv_curhtprotmode); in iwn_get_rxon_ht_flags()
6660 switch (vap->iv_curhtprotmode) { in iwn_get_rxon_ht_flags()
6678 return ((sc->rxon->filter & htole32(IWN_FILTER_BSS)) != 0); in iwn_check_bss_filter()
6685 struct iwn_rxon *rxon = sc->rxon; in iwn4965_rxon_assoc()
6687 cmd.flags = rxon->flags; in iwn4965_rxon_assoc()
6688 cmd.filter = rxon->filter; in iwn4965_rxon_assoc()
6689 cmd.ofdm_mask = rxon->ofdm_mask; in iwn4965_rxon_assoc()
6690 cmd.cck_mask = rxon->cck_mask; in iwn4965_rxon_assoc()
6691 cmd.ht_single_mask = rxon->ht_single_mask; in iwn4965_rxon_assoc()
6692 cmd.ht_dual_mask = rxon->ht_dual_mask; in iwn4965_rxon_assoc()
6693 cmd.rxchain = rxon->rxchain; in iwn4965_rxon_assoc()
6703 struct iwn_rxon *rxon = sc->rxon; in iwn5000_rxon_assoc()
6705 cmd.flags = rxon->flags; in iwn5000_rxon_assoc()
6706 cmd.filter = rxon->filter; in iwn5000_rxon_assoc()
6707 cmd.ofdm_mask = rxon->ofdm_mask; in iwn5000_rxon_assoc()
6708 cmd.cck_mask = rxon->cck_mask; in iwn5000_rxon_assoc()
6710 cmd.ht_single_mask = rxon->ht_single_mask; in iwn5000_rxon_assoc()
6711 cmd.ht_dual_mask = rxon->ht_dual_mask; in iwn5000_rxon_assoc()
6712 cmd.ht_triple_mask = rxon->ht_triple_mask; in iwn5000_rxon_assoc()
6714 cmd.rxchain = rxon->rxchain; in iwn5000_rxon_assoc()
6715 cmd.acquisition = rxon->acquisition; in iwn5000_rxon_assoc()
6724 struct iwn_ops *ops = &sc->ops; in iwn_send_rxon()
6730 error = ops->rxon_assoc(sc, async); in iwn_send_rxon()
6732 device_printf(sc->sc_dev, in iwn_send_rxon()
6738 if (sc->sc_is_scanning) in iwn_send_rxon()
6739 device_printf(sc->sc_dev, in iwn_send_rxon()
6743 error = iwn_cmd(sc, IWN_CMD_RXON, sc->rxon, sc->rxonsz, async); in iwn_send_rxon()
6745 device_printf(sc->sc_dev, in iwn_send_rxon()
6757 device_printf(sc->sc_dev, in iwn_send_rxon()
6765 if ((error = ops->set_txpower(sc, async)) != 0) { in iwn_send_rxon()
6766 device_printf(sc->sc_dev, in iwn_send_rxon()
6778 struct ieee80211com *ic = &sc->sc_ic; in iwn_config()
6779 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in iwn_config()
6785 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_config()
6787 if ((sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_TEMP_OFFSET) in iwn_config()
6788 && (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_TEMP_OFFSETv2)) { in iwn_config()
6789 device_printf(sc->sc_dev,"%s: temp_offset and temp_offsetv2 are" in iwn_config()
6792 sc->base_params->calib_need, in iwn_config()
6799 if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_TEMP_OFFSET) { in iwn_config()
6802 device_printf(sc->sc_dev, in iwn_config()
6806 } else if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_TEMP_OFFSETv2) { in iwn_config()
6809 device_printf(sc->sc_dev, in iwn_config()
6816 if (sc->hw_type == IWN_HW_REV_TYPE_6050) { in iwn_config()
6820 device_printf(sc->sc_dev, in iwn_config()
6828 if (sc->hw_type != IWN_HW_REV_TYPE_4965 && in iwn_config()
6829 IWN_UCODE_API(sc->ucode_rev) > 1) { in iwn_config()
6830 txmask = htole32(sc->txchainmask); in iwn_config()
6836 device_printf(sc->sc_dev, in iwn_config()
6847 if (sc->base_params->bt_mode == IWN_BT_ADVANCED) in iwn_config()
6849 if (sc->base_params->bt_mode == IWN_BT_SIMPLE) in iwn_config()
6853 device_printf(sc->sc_dev, in iwn_config()
6860 sc->rxon = &sc->rx_on[IWN_RXON_BSS_CTX]; in iwn_config()
6861 memset(sc->rxon, 0, sizeof (struct iwn_rxon)); in iwn_config()
6862 macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; in iwn_config()
6863 IEEE80211_ADDR_COPY(sc->rxon->myaddr, macaddr); in iwn_config()
6864 IEEE80211_ADDR_COPY(sc->rxon->wlap, macaddr); in iwn_config()
6865 sc->rxon->chan = ieee80211_chan2ieee(ic, ic->ic_curchan); in iwn_config()
6866 sc->rxon->flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF); in iwn_config()
6867 if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) in iwn_config()
6868 sc->rxon->flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ); in iwn_config()
6870 sc->rxon->filter = htole32(IWN_FILTER_MULTICAST); in iwn_config()
6871 switch (ic->ic_opmode) { in iwn_config()
6873 sc->rxon->mode = IWN_MODE_STA; in iwn_config()
6876 sc->rxon->mode = IWN_MODE_MONITOR; in iwn_config()
6883 sc->rxon->cck_mask = 0x0f; /* not yet negotiated */ in iwn_config()
6884 sc->rxon->ofdm_mask = 0xff; /* not yet negotiated */ in iwn_config()
6885 sc->rxon->ht_single_mask = 0xff; in iwn_config()
6886 sc->rxon->ht_dual_mask = 0xff; in iwn_config()
6887 sc->rxon->ht_triple_mask = 0xff; in iwn_config()
6897 IWN_RXCHAIN_VALID(sc->rxchainmask) | in iwn_config()
6898 IWN_RXCHAIN_MIMO_COUNT(sc->nrxchains) | in iwn_config()
6899 IWN_RXCHAIN_IDLE_COUNT(sc->nrxchains); in iwn_config()
6900 sc->rxon->rxchain = htole16(rxchain); in iwn_config()
6904 sc->rxchainmask, in iwn_config()
6905 sc->nrxchains); in iwn_config()
6907 sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, vap, ic->ic_curchan)); in iwn_config()
6911 __func__, le32toh(sc->rxon->flags)); in iwn_config()
6913 device_printf(sc->sc_dev, "%s: could not send RXON\n", in iwn_config()
6919 device_printf(sc->sc_dev, in iwn_config()
6926 device_printf(sc->sc_dev, in iwn_config()
6931 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_config()
6959 struct ieee80211com *ic = &sc->sc_ic; in iwn_limit_dwell()
6964 if (! TAILQ_EMPTY(&ic->ic_vaps)) { in iwn_limit_dwell()
6965 vap = TAILQ_FIRST(&ic->ic_vaps); in iwn_limit_dwell()
6966 bintval = vap->iv_bss->ni_intval; in iwn_limit_dwell()
6970 * If it's non-zero, we should calculate the minimum of in iwn_limit_dwell()
7007 struct ieee80211com *ic = &sc->sc_ic; in iwn_scan()
7008 struct ieee80211_node *ni = vap->iv_bss; in iwn_scan()
7023 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_scan()
7029 if (sc->sc_is_scanning) { in iwn_scan()
7030 device_printf(sc->sc_dev, "%s: called whilst scanning!\n", in iwn_scan()
7036 c = ic->ic_curchan; in iwn_scan()
7038 sc->rxon = &sc->rx_on[IWN_RXON_BSS_CTX]; in iwn_scan()
7041 device_printf(sc->sc_dev, in iwn_scan()
7051 hdr->quiet_time = htole16(10); /* timeout in milliseconds */ in iwn_scan()
7052 hdr->quiet_threshold = htole16(1); /* min # of packets */ in iwn_scan()
7057 hdr->max_svc = htole32(250 * 1024); in iwn_scan()
7071 hdr->pause_svc = htole32(scan_service_time); in iwn_scan()
7075 IWN_RXCHAIN_VALID(sc->rxchainmask) | in iwn_scan()
7076 IWN_RXCHAIN_FORCE_MIMO_SEL(sc->rxchainmask) | in iwn_scan()
7079 sc->hw_type == IWN_HW_REV_TYPE_4965) { in iwn_scan()
7083 rxchain |= IWN_RXCHAIN_FORCE_SEL(sc->rxchainmask); in iwn_scan()
7084 hdr->rxchain = htole16(rxchain); in iwn_scan()
7085 hdr->filter = htole32(IWN_FILTER_MULTICAST | IWN_FILTER_BEACON); in iwn_scan()
7088 tx->flags = htole32(IWN_TX_AUTO_SEQ); in iwn_scan()
7089 tx->id = sc->broadcast_id; in iwn_scan()
7090 tx->lifetime = htole32(IWN_LIFETIME_INFINITE); in iwn_scan()
7094 tx->rate = htole32(0xd); in iwn_scan()
7095 rs = &ic->ic_sup_rates[IEEE80211_MODE_11A]; in iwn_scan()
7097 hdr->flags = htole32(IWN_RXON_24GHZ | IWN_RXON_AUTO); in iwn_scan()
7098 if (sc->hw_type == IWN_HW_REV_TYPE_4965 && in iwn_scan()
7099 sc->rxon->associd && sc->rxon->chan > 14) in iwn_scan()
7100 tx->rate = htole32(0xd); in iwn_scan()
7103 tx->rate = htole32(10 | IWN_RFLAG_CCK); in iwn_scan()
7105 rs = &ic->ic_sup_rates[IEEE80211_MODE_11G]; in iwn_scan()
7108 txant = IWN_LSB(sc->txchainmask); in iwn_scan()
7109 tx->rate |= htole32(IWN_RFLAG_ANT(txant)); in iwn_scan()
7124 if (ss->ss_ssid[0].len != 0) { in iwn_scan()
7126 essid[0].len = ss->ss_ssid[0].len; in iwn_scan()
7127 memcpy(essid[0].data, ss->ss_ssid[0].ssid, ss->ss_ssid[0].len); in iwn_scan()
7132 ss->ss_ssid[0].len, in iwn_scan()
7133 ss->ss_ssid[0].len, in iwn_scan()
7134 ss->ss_ssid[0].ssid); in iwn_scan()
7136 if (ss->ss_nssid > 0) in iwn_scan()
7145 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT | in iwn_scan()
7147 wh->i_fc[1] = IEEE80211_FC1_DIR_NODS; in iwn_scan()
7148 IEEE80211_ADDR_COPY(wh->i_addr1, if_getbroadcastaddr(vap->iv_ifp)); in iwn_scan()
7149 IEEE80211_ADDR_COPY(wh->i_addr2, if_getlladdr(vap->iv_ifp)); in iwn_scan()
7150 IEEE80211_ADDR_COPY(wh->i_addr3, if_getbroadcastaddr(vap->iv_ifp)); in iwn_scan()
7151 *(uint16_t *)&wh->i_dur[0] = 0; /* filled by HW */ in iwn_scan()
7152 *(uint16_t *)&wh->i_seq[0] = 0; /* filled by HW */ in iwn_scan()
7157 if (rs->rs_nrates > IEEE80211_RATE_SIZE) in iwn_scan()
7159 if (ic->ic_htcaps & IEEE80211_HTC_HT) in iwn_scan()
7163 tx->len = htole16(frm - (uint8_t *)wh); in iwn_scan()
7177 * sending out probes -- setting this to a huge value will in iwn_scan()
7193 if (sc->tlv_feature_flags & IWN_UCODE_TLV_FLAGS_NEWSCAN) in iwn_scan()
7194 hdr->crc_threshold = is_active ? in iwn_scan()
7197 hdr->crc_threshold = is_active ? in iwn_scan()
7201 chan->chan = htole16(ieee80211_chan2ieee(ic, c)); in iwn_scan()
7202 chan->flags = 0; in iwn_scan()
7203 if (ss->ss_nssid > 0) in iwn_scan()
7204 chan->flags |= htole32(IWN_CHAN_NPBREQS(1)); in iwn_scan()
7205 chan->dsp_gain = 0x6e; in iwn_scan()
7211 if (c->ic_flags & IEEE80211_CHAN_PASSIVE) in iwn_scan()
7212 chan->flags |= htole32(IWN_CHAN_PASSIVE); in iwn_scan()
7214 chan->flags |= htole32(IWN_CHAN_ACTIVE); in iwn_scan()
7220 dwell_active = iwn_get_active_dwell_time(sc, c, ss->ss_nssid); in iwn_scan()
7227 chan->active = htole16(dwell_active); in iwn_scan()
7228 chan->passive = htole16(dwell_passive); in iwn_scan()
7231 chan->rf_gain = 0x3b; in iwn_scan()
7233 chan->rf_gain = 0x28; in iwn_scan()
7239 chan->chan, chan->flags, chan->rf_gain, chan->dsp_gain, in iwn_scan()
7241 hdr->crc_threshold, is_active, ss->ss_nssid); in iwn_scan()
7243 hdr->nchan++; in iwn_scan()
7245 buflen = (uint8_t *)chan - buf; in iwn_scan()
7246 hdr->len = htole16(buflen); in iwn_scan()
7248 if (sc->sc_is_scanning) { in iwn_scan()
7249 device_printf(sc->sc_dev, in iwn_scan()
7253 sc->sc_is_scanning = 1; in iwn_scan()
7256 hdr->nchan); in iwn_scan()
7260 callout_reset(&sc->scan_timeout, 5*hz, iwn_scan_timeout, sc); in iwn_scan()
7262 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_scan()
7270 struct ieee80211com *ic = &sc->sc_ic; in iwn_auth()
7271 struct ieee80211_node *ni = vap->iv_bss; in iwn_auth()
7274 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_auth()
7276 sc->rxon = &sc->rx_on[IWN_RXON_BSS_CTX]; in iwn_auth()
7278 IEEE80211_ADDR_COPY(sc->rxon->bssid, ni->ni_bssid); in iwn_auth()
7279 sc->rxon->chan = ieee80211_chan2ieee(ic, ni->ni_chan); in iwn_auth()
7280 sc->rxon->flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF); in iwn_auth()
7281 if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) in iwn_auth()
7282 sc->rxon->flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ); in iwn_auth()
7288 if (IEEE80211_IS_CHAN_5GHZ(ni->ni_chan)) in iwn_auth()
7289 sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); in iwn_auth()
7290 else if (vap->iv_flags & IEEE80211_F_SHSLOT) in iwn_auth()
7291 sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); in iwn_auth()
7293 if (vap->iv_flags & IEEE80211_F_SHPREAMBLE) in iwn_auth()
7294 sc->rxon->flags |= htole32(IWN_RXON_SHPREAMBLE); in iwn_auth()
7295 if (IEEE80211_IS_CHAN_A(ni->ni_chan)) { in iwn_auth()
7296 sc->rxon->cck_mask = 0; in iwn_auth()
7297 sc->rxon->ofdm_mask = 0x15; in iwn_auth()
7298 } else if (IEEE80211_IS_CHAN_B(ni->ni_chan)) { in iwn_auth()
7299 sc->rxon->cck_mask = 0x03; in iwn_auth()
7300 sc->rxon->ofdm_mask = 0; in iwn_auth()
7303 sc->rxon->cck_mask = 0x03; in iwn_auth()
7304 sc->rxon->ofdm_mask = 0x15; in iwn_auth()
7308 sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, vap, ic->ic_curchan)); in iwn_auth()
7311 sc->rxon->chan, sc->rxon->flags, sc->rxon->cck_mask, in iwn_auth()
7312 sc->rxon->ofdm_mask); in iwn_auth()
7315 device_printf(sc->sc_dev, "%s: could not send RXON\n", in iwn_auth()
7320 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_auth()
7328 struct iwn_ops *ops = &sc->ops; in iwn_run()
7329 struct ieee80211com *ic = &sc->sc_ic; in iwn_run()
7330 struct ieee80211_node *ni = vap->iv_bss; in iwn_run()
7334 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_run()
7336 sc->rxon = &sc->rx_on[IWN_RXON_BSS_CTX]; in iwn_run()
7337 if (ic->ic_opmode == IEEE80211_M_MONITOR) { in iwn_run()
7343 device_printf(sc->sc_dev, in iwn_run()
7349 IEEE80211_ADDR_COPY(sc->rxon->bssid, ni->ni_bssid); in iwn_run()
7350 sc->rxon->associd = htole16(IEEE80211_AID(ni->ni_associd)); in iwn_run()
7351 sc->rxon->chan = ieee80211_chan2ieee(ic, ni->ni_chan); in iwn_run()
7352 sc->rxon->flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF); in iwn_run()
7353 if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) in iwn_run()
7354 sc->rxon->flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ); in iwn_run()
7356 /* As previously - short slot only on 5GHz */ in iwn_run()
7357 if (IEEE80211_IS_CHAN_5GHZ(ni->ni_chan)) in iwn_run()
7358 sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); in iwn_run()
7359 else if (vap->iv_flags & IEEE80211_F_SHSLOT) in iwn_run()
7360 sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); in iwn_run()
7362 if (vap->iv_flags & IEEE80211_F_SHPREAMBLE) in iwn_run()
7363 sc->rxon->flags |= htole32(IWN_RXON_SHPREAMBLE); in iwn_run()
7364 if (IEEE80211_IS_CHAN_A(ni->ni_chan)) { in iwn_run()
7365 sc->rxon->cck_mask = 0; in iwn_run()
7366 sc->rxon->ofdm_mask = 0x15; in iwn_run()
7367 } else if (IEEE80211_IS_CHAN_B(ni->ni_chan)) { in iwn_run()
7368 sc->rxon->cck_mask = 0x03; in iwn_run()
7369 sc->rxon->ofdm_mask = 0; in iwn_run()
7372 sc->rxon->cck_mask = 0x0f; in iwn_run()
7373 sc->rxon->ofdm_mask = 0x15; in iwn_run()
7376 sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, vap, ni->ni_chan)); in iwn_run()
7377 sc->rxon->filter |= htole32(IWN_FILTER_BSS); in iwn_run()
7379 sc->rxon->chan, le32toh(sc->rxon->flags), vap->iv_curhtprotmode); in iwn_run()
7382 device_printf(sc->sc_dev, "%s: could not send RXON\n", in iwn_run()
7388 ((struct iwn_node *)ni)->id = IWN_ID_BSS; in iwn_run()
7393 IEEE80211_ADDR_COPY(node.macaddr, ni->ni_macaddr); in iwn_run()
7395 if (IEEE80211_IS_CHAN_HT(ni->ni_chan)) { in iwn_run()
7396 switch (ni->ni_htcap & IEEE80211_HTCAP_SMPS) { in iwn_run()
7406 if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) in iwn_run()
7410 error = ops->add_node(sc, &node, 1); in iwn_run()
7412 device_printf(sc->sc_dev, in iwn_run()
7419 device_printf(sc->sc_dev, in iwn_run()
7426 device_printf(sc->sc_dev, in iwn_run()
7432 sc->calib.state = IWN_CALIB_STATE_ASSOC; in iwn_run()
7433 sc->calib_cnt = 0; in iwn_run()
7434 callout_reset(&sc->calib_to, msecs_to_ticks(500), iwn_calib_timeout, in iwn_run()
7440 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_run()
7453 struct iwn_softc *sc = ni->ni_ic->ic_softc; in iwn_ampdu_rx_start()
7454 struct iwn_ops *ops = &sc->ops; in iwn_ampdu_rx_start()
7461 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_ampdu_rx_start()
7466 if (wn->id == IWN_ID_UNDEFINED) in iwn_ampdu_rx_start()
7470 node.id = wn->id; in iwn_ampdu_rx_start()
7476 wn->id, tid, ssn); in iwn_ampdu_rx_start()
7477 error = ops->add_node(sc, &node, 1); in iwn_ampdu_rx_start()
7480 return sc->sc_ampdu_rx_start(ni, rap, baparamset, batimeout, baseqctl); in iwn_ampdu_rx_start()
7484 * This function is called by upper layer on teardown of an HT-immediate
7490 struct ieee80211com *ic = ni->ni_ic; in iwn_ampdu_rx_stop()
7491 struct iwn_softc *sc = ic->ic_softc; in iwn_ampdu_rx_stop()
7492 struct iwn_ops *ops = &sc->ops; in iwn_ampdu_rx_stop()
7497 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_ampdu_rx_stop()
7499 if (wn->id == IWN_ID_UNDEFINED) in iwn_ampdu_rx_stop()
7504 if (&ni->ni_rx_ampdu[tid] == rap) in iwn_ampdu_rx_stop()
7509 node.id = wn->id; in iwn_ampdu_rx_stop()
7513 DPRINTF(sc, IWN_DEBUG_RECV, "DELBA RA=%d TID=%d\n", wn->id, tid); in iwn_ampdu_rx_stop()
7514 (void)ops->add_node(sc, &node, 1); in iwn_ampdu_rx_stop()
7516 sc->sc_ampdu_rx_stop(ni, rap); in iwn_ampdu_rx_stop()
7523 struct iwn_softc *sc = ni->ni_ic->ic_softc; in iwn_addba_request()
7526 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_addba_request()
7528 for (qid = sc->firstaggqueue; qid < sc->ntxqs; qid++) { in iwn_addba_request()
7529 if (sc->qid2tap[qid] == NULL) in iwn_addba_request()
7532 if (qid == sc->ntxqs) { in iwn_addba_request()
7537 tap->txa_private = malloc(sizeof(int), M_DEVBUF, M_NOWAIT); in iwn_addba_request()
7538 if (tap->txa_private == NULL) { in iwn_addba_request()
7539 device_printf(sc->sc_dev, in iwn_addba_request()
7543 sc->qid2tap[qid] = tap; in iwn_addba_request()
7544 *(int *)tap->txa_private = qid; in iwn_addba_request()
7545 return sc->sc_addba_request(ni, tap, dialogtoken, baparamset, in iwn_addba_request()
7553 struct iwn_softc *sc = ni->ni_ic->ic_softc; in iwn_addba_response()
7554 int qid = *(int *)tap->txa_private; in iwn_addba_response()
7555 uint8_t tid = tap->txa_tid; in iwn_addba_response()
7558 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_addba_response()
7561 ni->ni_txseqs[tid] = tap->txa_start & 0xfff; in iwn_addba_response()
7562 ret = iwn_ampdu_tx_start(ni->ni_ic, ni, tid); in iwn_addba_response()
7566 sc->qid2tap[qid] = NULL; in iwn_addba_response()
7567 free(tap->txa_private, M_DEVBUF); in iwn_addba_response()
7568 tap->txa_private = NULL; in iwn_addba_response()
7570 return sc->sc_addba_response(ni, tap, code, baparamset, batimeout); in iwn_addba_response()
7581 struct ieee80211_tx_ampdu *tap = &ni->ni_tx_ampdu[tid]; in iwn_ampdu_tx_start()
7582 struct iwn_softc *sc = ni->ni_ic->ic_softc; in iwn_ampdu_tx_start()
7583 struct iwn_ops *ops = &sc->ops; in iwn_ampdu_tx_start()
7588 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_ampdu_tx_start()
7590 if (wn->id == IWN_ID_UNDEFINED) in iwn_ampdu_tx_start()
7594 wn->disable_tid &= ~(1 << tid); in iwn_ampdu_tx_start()
7596 node.id = wn->id; in iwn_ampdu_tx_start()
7599 node.disable_tid = htole16(wn->disable_tid); in iwn_ampdu_tx_start()
7600 error = ops->add_node(sc, &node, 1); in iwn_ampdu_tx_start()
7606 qid = *(int *)tap->txa_private; in iwn_ampdu_tx_start()
7608 __func__, wn->id, tid, tap->txa_start, qid); in iwn_ampdu_tx_start()
7609 ops->ampdu_tx_start(sc, ni, qid, tid, tap->txa_start & 0xfff); in iwn_ampdu_tx_start()
7619 struct iwn_softc *sc = ni->ni_ic->ic_softc; in iwn_ampdu_tx_stop()
7620 struct iwn_ops *ops = &sc->ops; in iwn_ampdu_tx_stop()
7621 uint8_t tid = tap->txa_tid; in iwn_ampdu_tx_stop()
7624 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_ampdu_tx_stop()
7626 sc->sc_addba_stop(ni, tap); in iwn_ampdu_tx_stop()
7628 if (tap->txa_private == NULL) in iwn_ampdu_tx_stop()
7631 qid = *(int *)tap->txa_private; in iwn_ampdu_tx_stop()
7632 if (sc->txq[qid].queued != 0) in iwn_ampdu_tx_stop()
7636 ops->ampdu_tx_stop(sc, qid, tid, tap->txa_start & 0xfff); in iwn_ampdu_tx_stop()
7638 sc->qid2tap[qid] = NULL; in iwn_ampdu_tx_stop()
7639 free(tap->txa_private, M_DEVBUF); in iwn_ampdu_tx_stop()
7640 tap->txa_private = NULL; in iwn_ampdu_tx_stop()
7649 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_ampdu_tx_start()
7656 iwn_mem_write_2(sc, sc->sched_base + IWN4965_SCHED_TRANS_TBL(qid), in iwn4965_ampdu_tx_start()
7657 wn->id << 4 | tid); in iwn4965_ampdu_tx_start()
7659 /* Enable chain-building mode for the queue. */ in iwn4965_ampdu_tx_start()
7663 sc->txq[qid].cur = sc->txq[qid].read = (ssn & 0xff); in iwn4965_ampdu_tx_start()
7668 iwn_mem_write(sc, sc->sched_base + IWN4965_SCHED_QUEUE_OFFSET(qid), in iwn4965_ampdu_tx_start()
7671 iwn_mem_write(sc, sc->sched_base + IWN4965_SCHED_QUEUE_OFFSET(qid) + 4, in iwn4965_ampdu_tx_start()
7686 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_ampdu_tx_stop()
7708 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_ampdu_tx_start()
7717 iwn_mem_write_2(sc, sc->sched_base + IWN5000_SCHED_TRANS_TBL(qid), in iwn5000_ampdu_tx_start()
7718 wn->id << 4 | tid); in iwn5000_ampdu_tx_start()
7720 /* Enable chain-building mode for the queue. */ in iwn5000_ampdu_tx_start()
7727 sc->txq[qid].cur = sc->txq[qid].read = (ssn & 0xff); in iwn5000_ampdu_tx_start()
7732 iwn_mem_write(sc, sc->sched_base + IWN5000_SCHED_QUEUE_OFFSET(qid) + 4, in iwn5000_ampdu_tx_start()
7746 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_ampdu_tx_stop()
7789 if (!(sc->sc_flags & IWN_FLAG_CALIB_DONE)) in iwn5000_query_calibration()
7790 error = msleep(sc, &sc->sc_mtx, PCATCH, "iwncal", 2 * hz); in iwn5000_query_calibration()
7804 if (!(sc->base_params->calib_need & (1<<idx))) { in iwn5000_send_calibration()
7810 if (sc->calibcmd[idx].buf == NULL) { in iwn5000_send_calibration()
7819 sc->calibcmd[idx].len); in iwn5000_send_calibration()
7820 error = iwn_cmd(sc, IWN_CMD_PHY_CALIB, sc->calibcmd[idx].buf, in iwn5000_send_calibration()
7821 sc->calibcmd[idx].len, 0); in iwn5000_send_calibration()
7823 device_printf(sc->sc_dev, in iwn5000_send_calibration()
7838 if (sc->hw_type == IWN_HW_REV_TYPE_6050) { in iwn5000_send_wimax_coex()
7868 cmd.cap_pin[0] = le32toh(sc->eeprom_crystal) & 0xff; in iwn5000_crystal_calib()
7869 cmd.cap_pin[1] = (le32toh(sc->eeprom_crystal) >> 16) & 0xff; in iwn5000_crystal_calib()
7884 if (sc->eeprom_temp != 0) in iwn5000_temp_offset_calib()
7885 cmd.offset = htole16(sc->eeprom_temp); in iwn5000_temp_offset_calib()
7902 if (sc->eeprom_temp != 0) { in iwn5000_temp_offset_calibv2()
7903 cmd.offset_low = htole16(sc->eeprom_temp); in iwn5000_temp_offset_calibv2()
7904 cmd.offset_high = htole16(sc->eeprom_temp_high); in iwn5000_temp_offset_calibv2()
7909 cmd.burnt_voltage_ref = htole16(sc->eeprom_voltage); in iwn5000_temp_offset_calibv2()
7932 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_post_alive()
7935 sc->sched_base = iwn_prph_read(sc, IWN_SCHED_SRAM_ADDR); in iwn4965_post_alive()
7936 iwn_mem_set_region_4(sc, sc->sched_base + IWN4965_SCHED_CTX_OFF, 0, in iwn4965_post_alive()
7940 iwn_prph_write(sc, IWN4965_SCHED_DRAM_ADDR, sc->sched_dma.paddr >> 10); in iwn4965_post_alive()
7952 iwn_mem_write(sc, sc->sched_base + in iwn4965_post_alive()
7955 iwn_mem_write(sc, sc->sched_base + in iwn4965_post_alive()
7962 /* Identify TX FIFO rings (0-7). */ in iwn4965_post_alive()
7984 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn5000_post_alive()
7990 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s end in error\n", __func__); in iwn5000_post_alive()
7995 sc->sched_base = iwn_prph_read(sc, IWN_SCHED_SRAM_ADDR); in iwn5000_post_alive()
7996 iwn_mem_set_region_4(sc, sc->sched_base + IWN5000_SCHED_CTX_OFF, 0, in iwn5000_post_alive()
8000 iwn_prph_write(sc, IWN5000_SCHED_DRAM_ADDR, sc->sched_dma.paddr >> 10); in iwn5000_post_alive()
8005 if (sc->sc_flags & IWN_FLAG_PAN_SUPPORT) in iwn5000_post_alive()
8015 iwn_mem_write(sc, sc->sched_base + in iwn5000_post_alive()
8018 iwn_mem_write(sc, sc->sched_base + in iwn5000_post_alive()
8025 /* Identify TX FIFO rings (0-7). */ in iwn5000_post_alive()
8029 if (sc->sc_flags & IWN_FLAG_PAN_SUPPORT) { in iwn5000_post_alive()
8049 device_printf(sc->sc_dev, in iwn5000_post_alive()
8054 if (sc->hw_type != IWN_HW_REV_TYPE_5150) { in iwn5000_post_alive()
8058 device_printf(sc->sc_dev, in iwn5000_post_alive()
8064 if (!(sc->sc_flags & IWN_FLAG_CALIB_DONE)) { in iwn5000_post_alive()
8067 device_printf(sc->sc_dev, in iwn5000_post_alive()
8083 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn5000_post_alive()
8121 device_printf(sc->sc_dev, "%s: could not load boot firmware\n", in iwn4965_load_bootcode()
8137 struct iwn_fw_info *fw = &sc->fw; in iwn4965_load_firmware()
8138 struct iwn_dma_info *dma = &sc->fw_dma; in iwn4965_load_firmware()
8141 /* Copy initialization sections into pre-allocated DMA-safe memory. */ in iwn4965_load_firmware()
8142 memcpy(dma->vaddr, fw->init.data, fw->init.datasz); in iwn4965_load_firmware()
8143 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); in iwn4965_load_firmware()
8144 memcpy(dma->vaddr + IWN4965_FW_DATA_MAXSZ, in iwn4965_load_firmware()
8145 fw->init.text, fw->init.textsz); in iwn4965_load_firmware()
8146 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); in iwn4965_load_firmware()
8151 iwn_prph_write(sc, IWN_BSM_DRAM_DATA_ADDR, dma->paddr >> 4); in iwn4965_load_firmware()
8152 iwn_prph_write(sc, IWN_BSM_DRAM_DATA_SIZE, fw->init.datasz); in iwn4965_load_firmware()
8154 (dma->paddr + IWN4965_FW_DATA_MAXSZ) >> 4); in iwn4965_load_firmware()
8155 iwn_prph_write(sc, IWN_BSM_DRAM_TEXT_SIZE, fw->init.textsz); in iwn4965_load_firmware()
8159 error = iwn4965_load_bootcode(sc, fw->boot.text, fw->boot.textsz); in iwn4965_load_firmware()
8161 device_printf(sc->sc_dev, "%s: could not load boot firmware\n", in iwn4965_load_firmware()
8169 if ((error = msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", hz)) != 0) { in iwn4965_load_firmware()
8170 device_printf(sc->sc_dev, in iwn4965_load_firmware()
8177 sc->rawtemp = sc->ucode_info.temp[3].chan20MHz; in iwn4965_load_firmware()
8178 sc->temp = iwn4965_get_temperature(sc); in iwn4965_load_firmware()
8180 /* Copy runtime sections into pre-allocated DMA-safe memory. */ in iwn4965_load_firmware()
8181 memcpy(dma->vaddr, fw->main.data, fw->main.datasz); in iwn4965_load_firmware()
8182 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); in iwn4965_load_firmware()
8183 memcpy(dma->vaddr + IWN4965_FW_DATA_MAXSZ, in iwn4965_load_firmware()
8184 fw->main.text, fw->main.textsz); in iwn4965_load_firmware()
8185 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); in iwn4965_load_firmware()
8190 iwn_prph_write(sc, IWN_BSM_DRAM_DATA_ADDR, dma->paddr >> 4); in iwn4965_load_firmware()
8191 iwn_prph_write(sc, IWN_BSM_DRAM_DATA_SIZE, fw->main.datasz); in iwn4965_load_firmware()
8193 (dma->paddr + IWN4965_FW_DATA_MAXSZ) >> 4); in iwn4965_load_firmware()
8195 IWN_FW_UPDATED | fw->main.textsz); in iwn4965_load_firmware()
8205 struct iwn_dma_info *dma = &sc->fw_dma; in iwn5000_load_firmware_section()
8208 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_load_firmware_section()
8210 /* Copy firmware section into pre-allocated DMA-safe memory. */ in iwn5000_load_firmware_section()
8211 memcpy(dma->vaddr, section, size); in iwn5000_load_firmware_section()
8212 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); in iwn5000_load_firmware_section()
8222 IWN_LOADDR(dma->paddr)); in iwn5000_load_firmware_section()
8224 IWN_HIADDR(dma->paddr) << 28 | size); in iwn5000_load_firmware_section()
8237 return msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", 5 * hz); in iwn5000_load_firmware_section()
8246 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_load_firmware()
8249 fw = (sc->sc_flags & IWN_FLAG_CALIB_DONE) ? in iwn5000_load_firmware()
8250 &sc->fw.main : &sc->fw.init; in iwn5000_load_firmware()
8253 fw->text, fw->textsz); in iwn5000_load_firmware()
8255 device_printf(sc->sc_dev, in iwn5000_load_firmware()
8261 fw->data, fw->datasz); in iwn5000_load_firmware()
8263 device_printf(sc->sc_dev, in iwn5000_load_firmware()
8284 ptr = (const uint32_t *)fw->data; in iwn_read_firmware_leg()
8287 sc->ucode_rev = rev; in iwn_read_firmware_leg()
8291 device_printf(sc->sc_dev, in iwn_read_firmware_leg()
8300 if (fw->size < hdrlen) { in iwn_read_firmware_leg()
8301 device_printf(sc->sc_dev, "%s: firmware too short: %zu bytes\n", in iwn_read_firmware_leg()
8302 __func__, fw->size); in iwn_read_firmware_leg()
8305 fw->main.textsz = le32toh(*ptr++); in iwn_read_firmware_leg()
8306 fw->main.datasz = le32toh(*ptr++); in iwn_read_firmware_leg()
8307 fw->init.textsz = le32toh(*ptr++); in iwn_read_firmware_leg()
8308 fw->init.datasz = le32toh(*ptr++); in iwn_read_firmware_leg()
8309 fw->boot.textsz = le32toh(*ptr++); in iwn_read_firmware_leg()
8312 if (fw->size < hdrlen + fw->main.textsz + fw->main.datasz + in iwn_read_firmware_leg()
8313 fw->init.textsz + fw->init.datasz + fw->boot.textsz) { in iwn_read_firmware_leg()
8314 device_printf(sc->sc_dev, "%s: firmware too short: %zu bytes\n", in iwn_read_firmware_leg()
8315 __func__, fw->size); in iwn_read_firmware_leg()
8320 fw->main.text = (const uint8_t *)ptr; in iwn_read_firmware_leg()
8321 fw->main.data = fw->main.text + fw->main.textsz; in iwn_read_firmware_leg()
8322 fw->init.text = fw->main.data + fw->main.datasz; in iwn_read_firmware_leg()
8323 fw->init.data = fw->init.text + fw->init.textsz; in iwn_read_firmware_leg()
8324 fw->boot.text = fw->init.data + fw->init.datasz; in iwn_read_firmware_leg()
8341 if (fw->size < sizeof (*hdr)) { in iwn_read_firmware_tlv()
8342 device_printf(sc->sc_dev, "%s: firmware too short: %zu bytes\n", in iwn_read_firmware_tlv()
8343 __func__, fw->size); in iwn_read_firmware_tlv()
8346 hdr = (const struct iwn_fw_tlv_hdr *)fw->data; in iwn_read_firmware_tlv()
8347 if (hdr->signature != htole32(IWN_FW_SIGNATURE)) { in iwn_read_firmware_tlv()
8348 device_printf(sc->sc_dev, "%s: bad firmware signature 0x%08x\n", in iwn_read_firmware_tlv()
8349 __func__, le32toh(hdr->signature)); in iwn_read_firmware_tlv()
8352 DPRINTF(sc, IWN_DEBUG_RESET, "FW: \"%.64s\", build 0x%x\n", hdr->descr, in iwn_read_firmware_tlv()
8353 le32toh(hdr->build)); in iwn_read_firmware_tlv()
8354 sc->ucode_rev = le32toh(hdr->rev); in iwn_read_firmware_tlv()
8360 altmask = le64toh(hdr->altmask); in iwn_read_firmware_tlv()
8362 alt--; /* Downgrade. */ in iwn_read_firmware_tlv()
8366 end = (const uint8_t *)(fw->data + fw->size); in iwn_read_firmware_tlv()
8368 /* Parse type-length-value fields. */ in iwn_read_firmware_tlv()
8371 len = le32toh(tlv->len); in iwn_read_firmware_tlv()
8375 device_printf(sc->sc_dev, in iwn_read_firmware_tlv()
8377 fw->size); in iwn_read_firmware_tlv()
8381 if (tlv->alt != 0 && tlv->alt != htole16(alt)) in iwn_read_firmware_tlv()
8384 switch (le16toh(tlv->type)) { in iwn_read_firmware_tlv()
8386 fw->main.text = ptr; in iwn_read_firmware_tlv()
8387 fw->main.textsz = len; in iwn_read_firmware_tlv()
8390 fw->main.data = ptr; in iwn_read_firmware_tlv()
8391 fw->main.datasz = len; in iwn_read_firmware_tlv()
8394 fw->init.text = ptr; in iwn_read_firmware_tlv()
8395 fw->init.textsz = len; in iwn_read_firmware_tlv()
8398 fw->init.data = ptr; in iwn_read_firmware_tlv()
8399 fw->init.datasz = len; in iwn_read_firmware_tlv()
8402 fw->boot.text = ptr; in iwn_read_firmware_tlv()
8403 fw->boot.textsz = len; in iwn_read_firmware_tlv()
8407 sc->sc_flags |= IWN_FLAG_ENH_SENS; in iwn_read_firmware_tlv()
8412 sc->reset_noise_gain = tmp; in iwn_read_firmware_tlv()
8413 sc->noise_gain = tmp + 1; in iwn_read_firmware_tlv()
8417 sc->sc_flags |= IWN_FLAG_PAN_SUPPORT; in iwn_read_firmware_tlv()
8426 sc->tlv_feature_flags = le32toh(*ptr); in iwn_read_firmware_tlv()
8430 sc->tlv_feature_flags); in iwn_read_firmware_tlv()
8443 le16toh(tlv->type)); in iwn_read_firmware_tlv()
8447 "TLV type %d not handled\n", le16toh(tlv->type)); in iwn_read_firmware_tlv()
8450 next: /* TLV fields are 32-bit aligned. */ in iwn_read_firmware_tlv()
8459 struct iwn_fw_info *fw = &sc->fw; in iwn_read_firmware()
8462 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_read_firmware()
8469 sc->fw_fp = firmware_get(sc->fwname); in iwn_read_firmware()
8470 if (sc->fw_fp == NULL) { in iwn_read_firmware()
8471 device_printf(sc->sc_dev, "%s: could not read firmware %s\n", in iwn_read_firmware()
8472 __func__, sc->fwname); in iwn_read_firmware()
8478 fw->size = sc->fw_fp->datasize; in iwn_read_firmware()
8479 fw->data = (const uint8_t *)sc->fw_fp->data; in iwn_read_firmware()
8480 if (fw->size < sizeof (uint32_t)) { in iwn_read_firmware()
8481 device_printf(sc->sc_dev, "%s: firmware too short: %zu bytes\n", in iwn_read_firmware()
8482 __func__, fw->size); in iwn_read_firmware()
8488 if (*(const uint32_t *)fw->data != 0) /* Legacy image. */ in iwn_read_firmware()
8493 device_printf(sc->sc_dev, in iwn_read_firmware()
8499 device_printf(sc->sc_dev, "%s: ucode rev=0x%08x\n", __func__, sc->ucode_rev); in iwn_read_firmware()
8502 if (fw->main.textsz > sc->fw_text_maxsz || in iwn_read_firmware()
8503 fw->main.datasz > sc->fw_data_maxsz || in iwn_read_firmware()
8504 fw->init.textsz > sc->fw_text_maxsz || in iwn_read_firmware()
8505 fw->init.datasz > sc->fw_data_maxsz || in iwn_read_firmware()
8506 fw->boot.textsz > IWN_FW_BOOT_TEXT_MAXSZ || in iwn_read_firmware()
8507 (fw->boot.textsz & 3) != 0) { in iwn_read_firmware()
8508 device_printf(sc->sc_dev, "%s: firmware sections too large\n", in iwn_read_firmware()
8524 firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); in iwn_unload_firmware()
8525 sc->fw_fp = NULL; in iwn_unload_firmware()
8542 device_printf(sc->sc_dev, in iwn_clock_wait()
8553 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_apm_init()
8567 reg = pci_read_config(sc->sc_dev, sc->sc_cap_off + PCIER_LINK_CTL, 4); in iwn_apm_init()
8568 /* Workaround for HW instability in PCIe L0->L0s->L1 transition. */ in iwn_apm_init()
8574 if (sc->base_params->pll_cfg_val) in iwn_apm_init()
8575 IWN_SETBITS(sc, IWN_ANA_PLL, sc->base_params->pll_cfg_val); in iwn_apm_init()
8583 if (sc->hw_type == IWN_HW_REV_TYPE_4965) { in iwn_apm_init()
8594 /* Disable L1-Active. */ in iwn_apm_init()
8613 device_printf(sc->sc_dev, "%s: timeout waiting for master\n", __func__); in iwn_apm_stop_master()
8631 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn4965_nic_config()
8633 if (IWN_RFCFG_TYPE(sc->rfcfg) == 1) { in iwn4965_nic_config()
8640 IWN_RFCFG_TYPE(sc->rfcfg) | in iwn4965_nic_config()
8641 IWN_RFCFG_STEP(sc->rfcfg) | in iwn4965_nic_config()
8642 IWN_RFCFG_DASH(sc->rfcfg)); in iwn4965_nic_config()
8655 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn5000_nic_config()
8657 if (IWN_RFCFG_TYPE(sc->rfcfg) < 3) { in iwn5000_nic_config()
8659 IWN_RFCFG_TYPE(sc->rfcfg) | in iwn5000_nic_config()
8660 IWN_RFCFG_STEP(sc->rfcfg) | in iwn5000_nic_config()
8661 IWN_RFCFG_DASH(sc->rfcfg)); in iwn5000_nic_config()
8670 if (sc->hw_type == IWN_HW_REV_TYPE_1000) { in iwn5000_nic_config()
8683 if (sc->sc_flags & IWN_FLAG_INTERNAL_PA) { in iwn5000_nic_config()
8687 if (sc->base_params->additional_nic_config && sc->calib_ver >= 6) { in iwn5000_nic_config()
8691 if (sc->base_params->additional_gp_drv_bit) in iwn5000_nic_config()
8693 sc->base_params->additional_gp_drv_bit); in iwn5000_nic_config()
8705 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_hw_prepare()
8741 struct iwn_ops *ops = &sc->ops; in iwn_hw_init()
8744 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_hw_init()
8750 device_printf(sc->sc_dev, in iwn_hw_init()
8762 /* Perform adapter-specific initialization. */ in iwn_hw_init()
8763 if ((error = ops->nic_config(sc)) != 0) in iwn_hw_init()
8771 /* Set physical address of RX ring (256-byte aligned). */ in iwn_hw_init()
8772 IWN_WRITE(sc, IWN_FH_RX_BASE, sc->rxq.desc_dma.paddr >> 8); in iwn_hw_init()
8773 /* Set physical address of RX status (16-byte aligned). */ in iwn_hw_init()
8774 IWN_WRITE(sc, IWN_FH_STATUS_WPTR, sc->rxq.stat_dma.paddr >> 4); in iwn_hw_init()
8784 IWN_WRITE(sc, IWN_FH_RX_WPTR, (IWN_RX_RING_COUNT - 1) & ~7); in iwn_hw_init()
8790 iwn_prph_write(sc, sc->sched_txfact_addr, 0); in iwn_hw_init()
8792 /* Set physical address of "keep warm" page (16-byte aligned). */ in iwn_hw_init()
8793 IWN_WRITE(sc, IWN_FH_KW_ADDR, sc->kw_dma.paddr >> 4); in iwn_hw_init()
8796 for (qid = 0; qid < sc->ntxqs; qid++) { in iwn_hw_init()
8797 struct iwn_tx_ring *txq = &sc->txq[qid]; in iwn_hw_init()
8799 /* Set physical address of TX ring (256-byte aligned). */ in iwn_hw_init()
8801 txq->desc_dma.paddr >> 8); in iwn_hw_init()
8806 for (chnl = 0; chnl < sc->ndmachnls; chnl++) { in iwn_hw_init()
8821 IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask); in iwn_hw_init()
8828 if (sc->base_params->shadow_reg_enable) in iwn_hw_init()
8831 if ((error = ops->load_firmware(sc)) != 0) { in iwn_hw_init()
8832 device_printf(sc->sc_dev, in iwn_hw_init()
8838 if ((error = msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", hz)) != 0) { in iwn_hw_init()
8839 device_printf(sc->sc_dev, in iwn_hw_init()
8844 /* Do post-firmware initialization. */ in iwn_hw_init()
8846 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_hw_init()
8848 return ops->post_alive(sc); in iwn_hw_init()
8856 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_hw_stop()
8864 sc->sc_flags &= ~IWN_FLAG_USE_ICT; in iwn_hw_stop()
8870 iwn_prph_write(sc, sc->sched_txfact_addr, 0); in iwn_hw_stop()
8874 for (chnl = 0; chnl < sc->ndmachnls; chnl++) { in iwn_hw_stop()
8887 iwn_reset_rx_ring(sc, &sc->rxq); in iwn_hw_stop()
8890 for (qid = 0; qid < sc->ntxqs; qid++) in iwn_hw_stop()
8891 iwn_reset_tx_ring(sc, &sc->txq[qid]); in iwn_hw_stop()
8907 struct ieee80211com *ic = &sc->sc_ic; in iwn_panicked()
8908 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in iwn_panicked()
8918 device_printf(sc->sc_dev, "%s: controller panicked, iv_state = %d; " in iwn_panicked()
8919 "restarting\n", __func__, vap->iv_state); in iwn_panicked()
8935 device_printf(sc->sc_dev, in iwn_panicked()
8939 if (vap->iv_state >= IEEE80211_S_AUTH && in iwn_panicked()
8941 device_printf(sc->sc_dev, in iwn_panicked()
8944 if (vap->iv_state >= IEEE80211_S_RUN && in iwn_panicked()
8946 device_printf(sc->sc_dev, in iwn_panicked()
8960 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__); in iwn_init_locked()
8964 if (sc->sc_flags & IWN_FLAG_RUNNING) in iwn_init_locked()
8967 sc->sc_flags |= IWN_FLAG_RUNNING; in iwn_init_locked()
8970 device_printf(sc->sc_dev, "%s: hardware not ready, error %d\n", in iwn_init_locked()
8976 sc->int_mask = IWN_INT_MASK_DEF; in iwn_init_locked()
8977 sc->sc_flags &= ~IWN_FLAG_USE_ICT; in iwn_init_locked()
8982 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_init_locked()
8989 device_printf(sc->sc_dev, in iwn_init_locked()
8999 device_printf(sc->sc_dev, in iwn_init_locked()
9007 device_printf(sc->sc_dev, in iwn_init_locked()
9013 callout_reset(&sc->watchdog_to, hz, iwn_watchdog, sc); in iwn_init_locked()
9016 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); in iwn_init_locked()
9023 DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end in error\n",__func__); in iwn_init_locked()
9025 return (-1); in iwn_init_locked()
9046 if (!(sc->sc_flags & IWN_FLAG_RUNNING)) in iwn_stop_locked()
9049 sc->sc_is_scanning = 0; in iwn_stop_locked()
9050 sc->sc_tx_timer = 0; in iwn_stop_locked()
9051 callout_stop(&sc->watchdog_to); in iwn_stop_locked()
9052 callout_stop(&sc->scan_timeout); in iwn_stop_locked()
9053 callout_stop(&sc->calib_to); in iwn_stop_locked()
9054 sc->sc_flags &= ~IWN_FLAG_RUNNING; in iwn_stop_locked()
9074 struct iwn_softc *sc = ic->ic_softc; in iwn_scan_start()
9088 struct iwn_softc *sc = ic->ic_softc; in iwn_scan_end()
9089 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in iwn_scan_end()
9092 if (vap->iv_state == IEEE80211_S_RUN) { in iwn_scan_end()
9105 struct iwn_softc *sc = ic->ic_softc; in iwn_set_channel()
9108 DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); in iwn_set_channel()
9115 if (ic->ic_opmode == IEEE80211_M_MONITOR) { in iwn_set_channel()
9118 device_printf(sc->sc_dev, in iwn_set_channel()
9130 struct ieee80211vap *vap = ss->ss_vap; in iwn_scan_curchan()
9131 struct ieee80211com *ic = vap->iv_ic; in iwn_scan_curchan()
9132 struct iwn_softc *sc = ic->ic_softc; in iwn_scan_curchan()
9136 error = iwn_scan(sc, vap, ss, ic->ic_curchan); in iwn_scan_curchan()