| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_iwm.c,v 1.78 2018/01/21 18:12:37 christos Exp $ */ | | 1 | /* $NetBSD: if_iwm.c,v 1.79 2018/06/05 12:17:18 knakahara Exp $ */ |
2 | /* OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp */ | | 2 | /* OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp */ |
3 | #define IEEE80211_NO_HT | | 3 | #define IEEE80211_NO_HT |
4 | /* | | 4 | /* |
5 | * Copyright (c) 2014, 2016 genua gmbh <info@genua.de> | | 5 | * Copyright (c) 2014, 2016 genua gmbh <info@genua.de> |
6 | * Author: Stefan Sperling <stsp@openbsd.org> | | 6 | * Author: Stefan Sperling <stsp@openbsd.org> |
7 | * Copyright (c) 2014 Fixup Software Ltd. | | 7 | * Copyright (c) 2014 Fixup Software Ltd. |
8 | * | | 8 | * |
9 | * Permission to use, copy, modify, and distribute this software for any | | 9 | * Permission to use, copy, modify, and distribute this software for any |
10 | * purpose with or without fee is hereby granted, provided that the above | | 10 | * purpose with or without fee is hereby granted, provided that the above |
11 | * copyright notice and this permission notice appear in all copies. | | 11 | * copyright notice and this permission notice appear in all copies. |
12 | * | | 12 | * |
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| @@ -96,27 +96,27 @@ | | | @@ -96,27 +96,27 @@ |
96 | * purpose with or without fee is hereby granted, provided that the above | | 96 | * purpose with or without fee is hereby granted, provided that the above |
97 | * copyright notice and this permission notice appear in all copies. | | 97 | * copyright notice and this permission notice appear in all copies. |
98 | * | | 98 | * |
99 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 99 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
100 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 100 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
101 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 101 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
102 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 102 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
103 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 103 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
104 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 104 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
105 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 105 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
106 | */ | | 106 | */ |
107 | | | 107 | |
108 | #include <sys/cdefs.h> | | 108 | #include <sys/cdefs.h> |
109 | __KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.78 2018/01/21 18:12:37 christos Exp $"); | | 109 | __KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.79 2018/06/05 12:17:18 knakahara Exp $"); |
110 | | | 110 | |
111 | #include <sys/param.h> | | 111 | #include <sys/param.h> |
112 | #include <sys/conf.h> | | 112 | #include <sys/conf.h> |
113 | #include <sys/kernel.h> | | 113 | #include <sys/kernel.h> |
114 | #include <sys/kmem.h> | | 114 | #include <sys/kmem.h> |
115 | #include <sys/mbuf.h> | | 115 | #include <sys/mbuf.h> |
116 | #include <sys/mutex.h> | | 116 | #include <sys/mutex.h> |
117 | #include <sys/proc.h> | | 117 | #include <sys/proc.h> |
118 | #include <sys/socket.h> | | 118 | #include <sys/socket.h> |
119 | #include <sys/sockio.h> | | 119 | #include <sys/sockio.h> |
120 | #include <sys/sysctl.h> | | 120 | #include <sys/sysctl.h> |
121 | #include <sys/systm.h> | | 121 | #include <sys/systm.h> |
122 | | | 122 | |
| @@ -7719,26 +7719,27 @@ iwm_match(device_t parent, cfdata_t matc | | | @@ -7719,26 +7719,27 @@ iwm_match(device_t parent, cfdata_t matc |
7719 | return 0; | | 7719 | return 0; |
7720 | | | 7720 | |
7721 | for (size_t i = 0; i < __arraycount(iwm_devices); i++) | | 7721 | for (size_t i = 0; i < __arraycount(iwm_devices); i++) |
7722 | if (PCI_PRODUCT(pa->pa_id) == iwm_devices[i]) | | 7722 | if (PCI_PRODUCT(pa->pa_id) == iwm_devices[i]) |
7723 | return 1; | | 7723 | return 1; |
7724 | | | 7724 | |
7725 | return 0; | | 7725 | return 0; |
7726 | } | | 7726 | } |
7727 | | | 7727 | |
7728 | static int | | 7728 | static int |
7729 | iwm_preinit(struct iwm_softc *sc) | | 7729 | iwm_preinit(struct iwm_softc *sc) |
7730 | { | | 7730 | { |
7731 | struct ieee80211com *ic = &sc->sc_ic; | | 7731 | struct ieee80211com *ic = &sc->sc_ic; |
| | | 7732 | struct ifnet *ifp = IC2IFP(&sc->sc_ic);; |
7732 | int err; | | 7733 | int err; |
7733 | | | 7734 | |
7734 | if (ISSET(sc->sc_flags, IWM_FLAG_ATTACHED)) | | 7735 | if (ISSET(sc->sc_flags, IWM_FLAG_ATTACHED)) |
7735 | return 0; | | 7736 | return 0; |
7736 | | | 7737 | |
7737 | err = iwm_start_hw(sc); | | 7738 | err = iwm_start_hw(sc); |
7738 | if (err) { | | 7739 | if (err) { |
7739 | aprint_error_dev(sc->sc_dev, "could not initialize hardware\n"); | | 7740 | aprint_error_dev(sc->sc_dev, "could not initialize hardware\n"); |
7740 | return err; | | 7741 | return err; |
7741 | } | | 7742 | } |
7742 | | | 7743 | |
7743 | err = iwm_run_init_mvm_ucode(sc, 1); | | 7744 | err = iwm_run_init_mvm_ucode(sc, 1); |
7744 | iwm_stop_device(sc); | | 7745 | iwm_stop_device(sc); |
| @@ -7750,26 +7751,27 @@ iwm_preinit(struct iwm_softc *sc) | | | @@ -7750,26 +7751,27 @@ iwm_preinit(struct iwm_softc *sc) |
7750 | aprint_normal_dev(sc->sc_dev, "hw rev 0x%x, fw ver %s, address %s\n", | | 7751 | aprint_normal_dev(sc->sc_dev, "hw rev 0x%x, fw ver %s, address %s\n", |
7751 | sc->sc_hw_rev & IWM_CSR_HW_REV_TYPE_MSK, sc->sc_fwver, | | 7752 | sc->sc_hw_rev & IWM_CSR_HW_REV_TYPE_MSK, sc->sc_fwver, |
7752 | ether_sprintf(sc->sc_nvm.hw_addr)); | | 7753 | ether_sprintf(sc->sc_nvm.hw_addr)); |
7753 | | | 7754 | |
7754 | #ifndef IEEE80211_NO_HT | | 7755 | #ifndef IEEE80211_NO_HT |
7755 | if (sc->sc_nvm.sku_cap_11n_enable) | | 7756 | if (sc->sc_nvm.sku_cap_11n_enable) |
7756 | iwm_setup_ht_rates(sc); | | 7757 | iwm_setup_ht_rates(sc); |
7757 | #endif | | 7758 | #endif |
7758 | | | 7759 | |
7759 | /* not all hardware can do 5GHz band */ | | 7760 | /* not all hardware can do 5GHz band */ |
7760 | if (sc->sc_nvm.sku_cap_band_52GHz_enable) | | 7761 | if (sc->sc_nvm.sku_cap_band_52GHz_enable) |
7761 | ic->ic_sup_rates[IEEE80211_MODE_11A] = ieee80211_std_rateset_11a; | | 7762 | ic->ic_sup_rates[IEEE80211_MODE_11A] = ieee80211_std_rateset_11a; |
7762 | | | 7763 | |
| | | 7764 | ether_ifdetach(ifp); |
7763 | ieee80211_ifattach(ic); | | 7765 | ieee80211_ifattach(ic); |
7764 | | | 7766 | |
7765 | ic->ic_node_alloc = iwm_node_alloc; | | 7767 | ic->ic_node_alloc = iwm_node_alloc; |
7766 | | | 7768 | |
7767 | /* Override 802.11 state transition machine. */ | | 7769 | /* Override 802.11 state transition machine. */ |
7768 | sc->sc_newstate = ic->ic_newstate; | | 7770 | sc->sc_newstate = ic->ic_newstate; |
7769 | ic->ic_newstate = iwm_newstate; | | 7771 | ic->ic_newstate = iwm_newstate; |
7770 | ieee80211_media_init(ic, iwm_media_change, ieee80211_media_status); | | 7772 | ieee80211_media_init(ic, iwm_media_change, ieee80211_media_status); |
7771 | ieee80211_announce(ic); | | 7773 | ieee80211_announce(ic); |
7772 | | | 7774 | |
7773 | iwm_radiotap_attach(sc); | | 7775 | iwm_radiotap_attach(sc); |
7774 | | | 7776 | |
7775 | return 0; | | 7777 | return 0; |
| @@ -8123,27 +8125,27 @@ iwm_attach(device_t parent, device_t sel | | | @@ -8123,27 +8125,27 @@ iwm_attach(device_t parent, device_t sel |
8123 | ifp->if_watchdog = iwm_watchdog; | | 8125 | ifp->if_watchdog = iwm_watchdog; |
8124 | IFQ_SET_READY(&ifp->if_snd); | | 8126 | IFQ_SET_READY(&ifp->if_snd); |
8125 | memcpy(ifp->if_xname, DEVNAME(sc), IFNAMSIZ); | | 8127 | memcpy(ifp->if_xname, DEVNAME(sc), IFNAMSIZ); |
8126 | | | 8128 | |
8127 | err = if_initialize(ifp); | | 8129 | err = if_initialize(ifp); |
8128 | if (err != 0) { | | 8130 | if (err != 0) { |
8129 | aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", | | 8131 | aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", |
8130 | err); | | 8132 | err); |
8131 | goto fail6; | | 8133 | goto fail6; |
8132 | } | | 8134 | } |
8133 | #if 0 | | 8135 | #if 0 |
8134 | ieee80211_ifattach(ic); | | 8136 | ieee80211_ifattach(ic); |
8135 | #else | | 8137 | #else |
8136 | ether_ifattach(ifp, ic->ic_myaddr); /* XXX */ | | 8138 | ether_ifattach(ifp, NULL); /* XXX */ |
8137 | #endif | | 8139 | #endif |
8138 | /* Use common softint-based if_input */ | | 8140 | /* Use common softint-based if_input */ |
8139 | ifp->if_percpuq = if_percpuq_create(ifp); | | 8141 | ifp->if_percpuq = if_percpuq_create(ifp); |
8140 | if_register(ifp); | | 8142 | if_register(ifp); |
8141 | | | 8143 | |
8142 | callout_init(&sc->sc_calib_to, 0); | | 8144 | callout_init(&sc->sc_calib_to, 0); |
8143 | callout_setfunc(&sc->sc_calib_to, iwm_calib_timeout, sc); | | 8145 | callout_setfunc(&sc->sc_calib_to, iwm_calib_timeout, sc); |
8144 | callout_init(&sc->sc_led_blink_to, 0); | | 8146 | callout_init(&sc->sc_led_blink_to, 0); |
8145 | callout_setfunc(&sc->sc_led_blink_to, iwm_led_blink_timeout, sc); | | 8147 | callout_setfunc(&sc->sc_led_blink_to, iwm_led_blink_timeout, sc); |
8146 | #ifndef IEEE80211_NO_HT | | 8148 | #ifndef IEEE80211_NO_HT |
8147 | if (workqueue_create(&sc->sc_setratewq, "iwmsr", | | 8149 | if (workqueue_create(&sc->sc_setratewq, "iwmsr", |
8148 | iwm_setrates_task, sc, PRI_NONE, IPL_NET, 0)) | | 8150 | iwm_setrates_task, sc, PRI_NONE, IPL_NET, 0)) |
8149 | panic("%s: could not create workqueue: setrates", | | 8151 | panic("%s: could not create workqueue: setrates", |