Deleted Added
full compact
if_iwn.c (220662) if_iwn.c (220667)
1/*-
2 * Copyright (c) 2007-2009
3 * Damien Bergamini <damien.bergamini@free.fr>
4 * Copyright (c) 2008
5 * Benjamin Close <benjsc@FreeBSD.org>
6 * Copyright (c) 2008 Sam Leffler, Errno Consulting
7 *
8 * Permission to use, copy, modify, and distribute this software for any

--- 10 unchanged lines hidden (view full) ---

19 */
20
21/*
22 * Driver for Intel WiFi Link 4965 and 1000/5000/6000 Series 802.11 network
23 * adapters.
24 */
25
26#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2007-2009
3 * Damien Bergamini <damien.bergamini@free.fr>
4 * Copyright (c) 2008
5 * Benjamin Close <benjsc@FreeBSD.org>
6 * Copyright (c) 2008 Sam Leffler, Errno Consulting
7 *
8 * Permission to use, copy, modify, and distribute this software for any

--- 10 unchanged lines hidden (view full) ---

19 */
20
21/*
22 * Driver for Intel WiFi Link 4965 and 1000/5000/6000 Series 802.11 network
23 * adapters.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sys/dev/iwn/if_iwn.c 220662 2011-04-15 17:10:52Z bschmidt $");
27__FBSDID("$FreeBSD: head/sys/dev/iwn/if_iwn.c 220667 2011-04-15 20:17:52Z bschmidt $");
28
29#include <sys/param.h>
30#include <sys/sockio.h>
31#include <sys/sysctl.h>
32#include <sys/mbuf.h>
33#include <sys/kernel.h>
34#include <sys/socket.h>
35#include <sys/systm.h>

--- 82 unchanged lines hidden (view full) ---

118#endif
119static void iwn_read_eeprom_channels(struct iwn_softc *, int,
120 uint32_t);
121static void iwn_read_eeprom_enhinfo(struct iwn_softc *);
122static struct ieee80211_node *iwn_node_alloc(struct ieee80211vap *,
123 const uint8_t mac[IEEE80211_ADDR_LEN]);
124static int iwn_media_change(struct ifnet *);
125static int iwn_newstate(struct ieee80211vap *, enum ieee80211_state, int);
28
29#include <sys/param.h>
30#include <sys/sockio.h>
31#include <sys/sysctl.h>
32#include <sys/mbuf.h>
33#include <sys/kernel.h>
34#include <sys/socket.h>
35#include <sys/systm.h>

--- 82 unchanged lines hidden (view full) ---

118#endif
119static void iwn_read_eeprom_channels(struct iwn_softc *, int,
120 uint32_t);
121static void iwn_read_eeprom_enhinfo(struct iwn_softc *);
122static struct ieee80211_node *iwn_node_alloc(struct ieee80211vap *,
123 const uint8_t mac[IEEE80211_ADDR_LEN]);
124static int iwn_media_change(struct ifnet *);
125static int iwn_newstate(struct ieee80211vap *, enum ieee80211_state, int);
126static void iwn_calib_timeout(void *);
126static void iwn_rx_phy(struct iwn_softc *, struct iwn_rx_desc *,
127 struct iwn_rx_data *);
127static void iwn_rx_phy(struct iwn_softc *, struct iwn_rx_desc *,
128 struct iwn_rx_data *);
128static void iwn_timer_timeout(void *);
129static void iwn_calib_reset(struct iwn_softc *);
130static void iwn_rx_done(struct iwn_softc *, struct iwn_rx_desc *,
131 struct iwn_rx_data *);
132#if 0 /* HT */
133static void iwn_rx_compressed_ba(struct iwn_softc *, struct iwn_rx_desc *,
134 struct iwn_rx_data *);
135#endif
136static void iwn_rx_statistics(struct iwn_softc *, struct iwn_rx_desc *,
137 struct iwn_rx_data *);

--- 18 unchanged lines hidden (view full) ---

156#endif
157static uint8_t iwn_plcp_signal(int);
158static int iwn_tx_data(struct iwn_softc *, struct mbuf *,
159 struct ieee80211_node *, struct iwn_tx_ring *);
160static int iwn_raw_xmit(struct ieee80211_node *, struct mbuf *,
161 const struct ieee80211_bpf_params *);
162static void iwn_start(struct ifnet *);
163static void iwn_start_locked(struct ifnet *);
129static void iwn_rx_done(struct iwn_softc *, struct iwn_rx_desc *,
130 struct iwn_rx_data *);
131#if 0 /* HT */
132static void iwn_rx_compressed_ba(struct iwn_softc *, struct iwn_rx_desc *,
133 struct iwn_rx_data *);
134#endif
135static void iwn_rx_statistics(struct iwn_softc *, struct iwn_rx_desc *,
136 struct iwn_rx_data *);

--- 18 unchanged lines hidden (view full) ---

155#endif
156static uint8_t iwn_plcp_signal(int);
157static int iwn_tx_data(struct iwn_softc *, struct mbuf *,
158 struct ieee80211_node *, struct iwn_tx_ring *);
159static int iwn_raw_xmit(struct ieee80211_node *, struct mbuf *,
160 const struct ieee80211_bpf_params *);
161static void iwn_start(struct ifnet *);
162static void iwn_start_locked(struct ifnet *);
164static void iwn_watchdog(struct iwn_softc *sc);
163static void iwn_watchdog(void *);
165static int iwn_ioctl(struct ifnet *, u_long, caddr_t);
166static int iwn_cmd(struct iwn_softc *, int, const void *, int, int);
167static int iwn4965_add_node(struct iwn_softc *, struct iwn_node_info *,
168 int);
169static int iwn5000_add_node(struct iwn_softc *, struct iwn_node_info *,
170 int);
171static int iwn_set_link_quality(struct iwn_softc *, uint8_t, int);
172static int iwn_add_broadcast_node(struct iwn_softc *, int);

--- 297 unchanged lines hidden (view full) ---

470 RF_ACTIVE | RF_SHAREABLE);
471 if (sc->irq == NULL) {
472 device_printf(dev, "could not allocate interrupt resource\n");
473 error = ENOMEM;
474 goto fail;
475 }
476
477 IWN_LOCK_INIT(sc);
164static int iwn_ioctl(struct ifnet *, u_long, caddr_t);
165static int iwn_cmd(struct iwn_softc *, int, const void *, int, int);
166static int iwn4965_add_node(struct iwn_softc *, struct iwn_node_info *,
167 int);
168static int iwn5000_add_node(struct iwn_softc *, struct iwn_node_info *,
169 int);
170static int iwn_set_link_quality(struct iwn_softc *, uint8_t, int);
171static int iwn_add_broadcast_node(struct iwn_softc *, int);

--- 297 unchanged lines hidden (view full) ---

469 RF_ACTIVE | RF_SHAREABLE);
470 if (sc->irq == NULL) {
471 device_printf(dev, "could not allocate interrupt resource\n");
472 error = ENOMEM;
473 goto fail;
474 }
475
476 IWN_LOCK_INIT(sc);
478 callout_init_mtx(&sc->sc_timer_to, &sc->sc_mtx, 0);
479 TASK_INIT(&sc->sc_reinit_task, 0, iwn_hw_reset, sc );
480 TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc );
481 TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc );
482
483 /* Attach Hardware Abstraction Layer. */
484 hal = iwn_hal_attach(sc);
485 if (hal == NULL) {
486 error = ENXIO; /* XXX: Wrong error code? */

--- 176 unchanged lines hidden (view full) ---

663#if 0 /* HT */
664 ic->ic_ampdu_rx_start = iwn_ampdu_rx_start;
665 ic->ic_ampdu_rx_stop = iwn_ampdu_rx_stop;
666 ic->ic_ampdu_tx_start = iwn_ampdu_tx_start;
667 ic->ic_ampdu_tx_stop = iwn_ampdu_tx_stop;
668#endif
669
670 iwn_radiotap_attach(sc);
477 TASK_INIT(&sc->sc_reinit_task, 0, iwn_hw_reset, sc );
478 TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc );
479 TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc );
480
481 /* Attach Hardware Abstraction Layer. */
482 hal = iwn_hal_attach(sc);
483 if (hal == NULL) {
484 error = ENXIO; /* XXX: Wrong error code? */

--- 176 unchanged lines hidden (view full) ---

661#if 0 /* HT */
662 ic->ic_ampdu_rx_start = iwn_ampdu_rx_start;
663 ic->ic_ampdu_rx_stop = iwn_ampdu_rx_stop;
664 ic->ic_ampdu_tx_start = iwn_ampdu_tx_start;
665 ic->ic_ampdu_tx_stop = iwn_ampdu_tx_stop;
666#endif
667
668 iwn_radiotap_attach(sc);
669
670 callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0);
671 callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0);
672
671 iwn_sysctlattach(sc);
672
673 /*
674 * Hook our interrupt after all initialization is complete.
675 */
676 error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
677 NULL, iwn_intr, sc, &sc->sc_ih);
678 if (error != 0) {

--- 176 unchanged lines hidden (view full) ---

855 if (ifp != NULL) {
856 ic = ifp->if_l2com;
857
858 ieee80211_draintask(ic, &sc->sc_reinit_task);
859 ieee80211_draintask(ic, &sc->sc_radioon_task);
860 ieee80211_draintask(ic, &sc->sc_radiooff_task);
861
862 iwn_stop(sc);
673 iwn_sysctlattach(sc);
674
675 /*
676 * Hook our interrupt after all initialization is complete.
677 */
678 error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
679 NULL, iwn_intr, sc, &sc->sc_ih);
680 if (error != 0) {

--- 176 unchanged lines hidden (view full) ---

857 if (ifp != NULL) {
858 ic = ifp->if_l2com;
859
860 ieee80211_draintask(ic, &sc->sc_reinit_task);
861 ieee80211_draintask(ic, &sc->sc_radioon_task);
862 ieee80211_draintask(ic, &sc->sc_radiooff_task);
863
864 iwn_stop(sc);
863 callout_drain(&sc->sc_timer_to);
865 callout_drain(&sc->watchdog_to);
866 callout_drain(&sc->calib_to);
864 ieee80211_ifdetach(ic);
865 }
866
867 iwn5000_free_calib_results(sc);
868
869 /* Free DMA resources. */
870 iwn_free_rx_ring(sc, &sc->rxq);
871 if (sc->sc_hal != NULL)

--- 1065 unchanged lines hidden (view full) ---

1937 int error;
1938
1939 DPRINTF(sc, IWN_DEBUG_STATE, "%s: %s -> %s\n", __func__,
1940 ieee80211_state_name[vap->iv_state],
1941 ieee80211_state_name[nstate]);
1942
1943 IEEE80211_UNLOCK(ic);
1944 IWN_LOCK(sc);
867 ieee80211_ifdetach(ic);
868 }
869
870 iwn5000_free_calib_results(sc);
871
872 /* Free DMA resources. */
873 iwn_free_rx_ring(sc, &sc->rxq);
874 if (sc->sc_hal != NULL)

--- 1065 unchanged lines hidden (view full) ---

1940 int error;
1941
1942 DPRINTF(sc, IWN_DEBUG_STATE, "%s: %s -> %s\n", __func__,
1943 ieee80211_state_name[vap->iv_state],
1944 ieee80211_state_name[nstate]);
1945
1946 IEEE80211_UNLOCK(ic);
1947 IWN_LOCK(sc);
1945 callout_stop(&sc->sc_timer_to);
1948 callout_stop(&sc->calib_to);
1946
1947 switch (nstate) {
1948 case IEEE80211_S_ASSOC:
1949 if (vap->iv_state != IEEE80211_S_RUN)
1950 break;
1951 /* FALLTHROUGH */
1952 case IEEE80211_S_AUTH:
1953 if (vap->iv_state == IEEE80211_S_AUTH)
1954 break;
1955
1956 /*
1957 * !AUTH -> AUTH transition requires state reset to handle
1958 * reassociations correctly.
1959 */
1960 sc->rxon.associd = 0;
1961 sc->rxon.filter &= ~htole32(IWN_FILTER_BSS);
1949
1950 switch (nstate) {
1951 case IEEE80211_S_ASSOC:
1952 if (vap->iv_state != IEEE80211_S_RUN)
1953 break;
1954 /* FALLTHROUGH */
1955 case IEEE80211_S_AUTH:
1956 if (vap->iv_state == IEEE80211_S_AUTH)
1957 break;
1958
1959 /*
1960 * !AUTH -> AUTH transition requires state reset to handle
1961 * reassociations correctly.
1962 */
1963 sc->rxon.associd = 0;
1964 sc->rxon.filter &= ~htole32(IWN_FILTER_BSS);
1962 iwn_calib_reset(sc);
1965 sc->calib.state = IWN_CALIB_STATE_INIT;
1966
1963 error = iwn_auth(sc, vap);
1964 break;
1965
1966 case IEEE80211_S_RUN:
1967 /*
1968 * RUN -> RUN transition; Just restart the timers.
1969 */
1967 error = iwn_auth(sc, vap);
1968 break;
1969
1970 case IEEE80211_S_RUN:
1971 /*
1972 * RUN -> RUN transition; Just restart the timers.
1973 */
1970 if (vap->iv_state == IEEE80211_S_RUN &&
1971 vap->iv_opmode != IEEE80211_M_MONITOR) {
1972 iwn_calib_reset(sc);
1974 if (vap->iv_state == IEEE80211_S_RUN) {
1975 sc->calib_cnt = 0;
1973 break;
1974 }
1975
1976 /*
1977 * !RUN -> RUN requires setting the association id
1978 * which is done with a firmware cmd. We also defer
1979 * starting the timers until that work is done.
1980 */
1981 error = iwn_run(sc, vap);
1982 break;
1983
1976 break;
1977 }
1978
1979 /*
1980 * !RUN -> RUN requires setting the association id
1981 * which is done with a firmware cmd. We also defer
1982 * starting the timers until that work is done.
1983 */
1984 error = iwn_run(sc, vap);
1985 break;
1986
1987 case IEEE80211_S_INIT:
1988 sc->calib.state = IWN_CALIB_STATE_INIT;
1989 break;
1990
1984 default:
1985 break;
1986 }
1987 IWN_UNLOCK(sc);
1988 IEEE80211_LOCK(ic);
1989 return ivp->iv_newstate(vap, nstate, arg);
1990}
1991
1991 default:
1992 break;
1993 }
1994 IWN_UNLOCK(sc);
1995 IEEE80211_LOCK(ic);
1996 return ivp->iv_newstate(vap, nstate, arg);
1997}
1998
1999static void
2000iwn_calib_timeout(void *arg)
2001{
2002 struct iwn_softc *sc = arg;
2003
2004 IWN_LOCK_ASSERT(sc);
2005
2006 /* Force automatic TX power calibration every 60 secs. */
2007 if (++sc->calib_cnt >= 120) {
2008 uint32_t flags = 0;
2009
2010 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s\n",
2011 "sending request for statistics");
2012 (void)iwn_cmd(sc, IWN_CMD_GET_STATISTICS, &flags,
2013 sizeof flags, 1);
2014 sc->calib_cnt = 0;
2015 }
2016 callout_reset(&sc->calib_to, msecs_to_ticks(500), iwn_calib_timeout,
2017 sc);
2018}
2019
1992/*
1993 * Process an RX_PHY firmware notification. This is usually immediately
1994 * followed by an MPDU_RX_DONE notification.
1995 */
1996static void
1997iwn_rx_phy(struct iwn_softc *sc, struct iwn_rx_desc *desc,
1998 struct iwn_rx_data *data)
1999{
2000 struct iwn_rx_stat *stat = (struct iwn_rx_stat *)(desc + 1);
2001
2002 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: received PHY stats\n", __func__);
2003 bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
2004
2005 /* Save RX statistics, they will be used on MPDU_RX_DONE. */
2006 memcpy(&sc->last_rx_stat, stat, sizeof (*stat));
2007 sc->last_rx_valid = 1;
2008}
2009
2020/*
2021 * Process an RX_PHY firmware notification. This is usually immediately
2022 * followed by an MPDU_RX_DONE notification.
2023 */
2024static void
2025iwn_rx_phy(struct iwn_softc *sc, struct iwn_rx_desc *desc,
2026 struct iwn_rx_data *data)
2027{
2028 struct iwn_rx_stat *stat = (struct iwn_rx_stat *)(desc + 1);
2029
2030 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: received PHY stats\n", __func__);
2031 bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
2032
2033 /* Save RX statistics, they will be used on MPDU_RX_DONE. */
2034 memcpy(&sc->last_rx_stat, stat, sizeof (*stat));
2035 sc->last_rx_valid = 1;
2036}
2037
2010static void
2011iwn_timer_timeout(void *arg)
2012{
2013 struct iwn_softc *sc = arg;
2014 uint32_t flags = 0;
2015
2016 IWN_LOCK_ASSERT(sc);
2017
2018 if (sc->calib_cnt && --sc->calib_cnt == 0) {
2019 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s\n",
2020 "send statistics request");
2021 (void) iwn_cmd(sc, IWN_CMD_GET_STATISTICS, &flags,
2022 sizeof flags, 1);
2023 sc->calib_cnt = 60; /* do calibration every 60s */
2024 }
2025 iwn_watchdog(sc); /* NB: piggyback tx watchdog */
2026 callout_reset(&sc->sc_timer_to, hz, iwn_timer_timeout, sc);
2027}
2028
2029static void
2030iwn_calib_reset(struct iwn_softc *sc)
2031{
2032 callout_reset(&sc->sc_timer_to, hz, iwn_timer_timeout, sc);
2033 sc->calib_cnt = 60; /* do calibration every 60s */
2034}
2035
2036/*
2037 * Process an RX_DONE (4965AGN only) or MPDU_RX_DONE firmware notification.
2038 * Each MPDU_RX_DONE notification must be preceded by an RX_PHY one.
2039 */
2040static void
2041iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
2042 struct iwn_rx_data *data)
2043{

--- 173 unchanged lines hidden (view full) ---

2217
2218 /* Beacon stats are meaningful only when associated and not scanning. */
2219 if (vap->iv_state != IEEE80211_S_RUN ||
2220 (ic->ic_flags & IEEE80211_F_SCAN))
2221 return;
2222
2223 bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
2224 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: cmd %d\n", __func__, desc->type);
2038/*
2039 * Process an RX_DONE (4965AGN only) or MPDU_RX_DONE firmware notification.
2040 * Each MPDU_RX_DONE notification must be preceded by an RX_PHY one.
2041 */
2042static void
2043iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
2044 struct iwn_rx_data *data)
2045{

--- 173 unchanged lines hidden (view full) ---

2219
2220 /* Beacon stats are meaningful only when associated and not scanning. */
2221 if (vap->iv_state != IEEE80211_S_RUN ||
2222 (ic->ic_flags & IEEE80211_F_SCAN))
2223 return;
2224
2225 bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
2226 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: cmd %d\n", __func__, desc->type);
2225 iwn_calib_reset(sc); /* Reset TX power calibration timeout. */
2227 sc->calib_cnt = 0; /* Reset TX power calibration timeout. */
2226
2227 /* Test if temperature has changed. */
2228 if (stats->general.temp != sc->rawtemp) {
2229 /* Convert "raw" temperature to degC. */
2230 sc->rawtemp = stats->general.temp;
2231 temp = hal->get_temperature(sc);
2232 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: temperature %d\n",
2233 __func__, temp);

--- 1067 unchanged lines hidden (view full) ---

3301 */
3302 error = iwn_tx_data_raw(sc, m, ni, txq, params);
3303 }
3304 if (error != 0) {
3305 /* NB: m is reclaimed on tx failure */
3306 ieee80211_free_node(ni);
3307 ifp->if_oerrors++;
3308 }
2228
2229 /* Test if temperature has changed. */
2230 if (stats->general.temp != sc->rawtemp) {
2231 /* Convert "raw" temperature to degC. */
2232 sc->rawtemp = stats->general.temp;
2233 temp = hal->get_temperature(sc);
2234 DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: temperature %d\n",
2235 __func__, temp);

--- 1067 unchanged lines hidden (view full) ---

3303 */
3304 error = iwn_tx_data_raw(sc, m, ni, txq, params);
3305 }
3306 if (error != 0) {
3307 /* NB: m is reclaimed on tx failure */
3308 ieee80211_free_node(ni);
3309 ifp->if_oerrors++;
3310 }
3311 sc->sc_tx_timer = 5;
3312
3309 IWN_UNLOCK(sc);
3310 return error;
3311}
3312
3313static void
3314iwn_start(struct ifnet *ifp)
3315{
3316 struct iwn_softc *sc = ifp->if_softc;

--- 30 unchanged lines hidden (view full) ---

3347 ieee80211_free_node(ni);
3348 break;
3349 }
3350 sc->sc_tx_timer = 5;
3351 }
3352}
3353
3354static void
3313 IWN_UNLOCK(sc);
3314 return error;
3315}
3316
3317static void
3318iwn_start(struct ifnet *ifp)
3319{
3320 struct iwn_softc *sc = ifp->if_softc;

--- 30 unchanged lines hidden (view full) ---

3351 ieee80211_free_node(ni);
3352 break;
3353 }
3354 sc->sc_tx_timer = 5;
3355 }
3356}
3357
3358static void
3355iwn_watchdog(struct iwn_softc *sc)
3359iwn_watchdog(void *arg)
3356{
3360{
3357 if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) {
3358 struct ifnet *ifp = sc->sc_ifp;
3359 struct ieee80211com *ic = ifp->if_l2com;
3361 struct iwn_softc *sc = arg;
3362 struct ifnet *ifp = sc->sc_ifp;
3363 struct ieee80211com *ic = ifp->if_l2com;
3360
3364
3361 if_printf(ifp, "device timeout\n");
3362 ieee80211_runtask(ic, &sc->sc_reinit_task);
3365 IWN_LOCK_ASSERT(sc);
3366
3367 KASSERT(ifp->if_drv_flags & IFF_DRV_RUNNING, ("not running"));
3368
3369 if (sc->sc_tx_timer > 0 || counter == 50) {
3370 if (--sc->sc_tx_timer == 0 || counter == 50) {
3371 if_printf(ifp, "device timeout\n");
3372 ieee80211_runtask(ic, &sc->sc_reinit_task);
3373 return;
3374 }
3363 }
3375 }
3376 callout_reset(&sc->watchdog_to, hz, iwn_watchdog, sc);
3364}
3365
3366static int
3367iwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
3368{
3369 struct iwn_softc *sc = ifp->if_softc;
3370 struct ieee80211com *ic = ifp->if_l2com;
3371 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);

--- 1383 unchanged lines hidden (view full) ---

4755iwn_auth(struct iwn_softc *sc, struct ieee80211vap *vap)
4756{
4757 const struct iwn_hal *hal = sc->sc_hal;
4758 struct ifnet *ifp = sc->sc_ifp;
4759 struct ieee80211com *ic = ifp->if_l2com;
4760 struct ieee80211_node *ni = vap->iv_bss;
4761 int error;
4762
3377}
3378
3379static int
3380iwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
3381{
3382 struct iwn_softc *sc = ifp->if_softc;
3383 struct ieee80211com *ic = ifp->if_l2com;
3384 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);

--- 1383 unchanged lines hidden (view full) ---

4768iwn_auth(struct iwn_softc *sc, struct ieee80211vap *vap)
4769{
4770 const struct iwn_hal *hal = sc->sc_hal;
4771 struct ifnet *ifp = sc->sc_ifp;
4772 struct ieee80211com *ic = ifp->if_l2com;
4773 struct ieee80211_node *ni = vap->iv_bss;
4774 int error;
4775
4763 sc->calib.state = IWN_CALIB_STATE_INIT;
4764
4765 /* Update adapter configuration. */
4766 IEEE80211_ADDR_COPY(sc->rxon.bssid, ni->ni_bssid);
4767 sc->rxon.chan = ieee80211_chan2ieee(ic, ni->ni_chan);
4768 sc->rxon.flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF);
4769 if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan))
4770 sc->rxon.flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ);
4771 if (ic->ic_flags & IEEE80211_F_SHSLOT)
4772 sc->rxon.flags |= htole32(IWN_RXON_SHSLOT);

--- 176 unchanged lines hidden (view full) ---

4949 device_printf(sc->sc_dev,
4950 "%s: could not set sensitivity, error %d\n",
4951 __func__, error);
4952 return error;
4953 }
4954
4955 /* Start periodic calibration timer. */
4956 sc->calib.state = IWN_CALIB_STATE_ASSOC;
4776 /* Update adapter configuration. */
4777 IEEE80211_ADDR_COPY(sc->rxon.bssid, ni->ni_bssid);
4778 sc->rxon.chan = ieee80211_chan2ieee(ic, ni->ni_chan);
4779 sc->rxon.flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF);
4780 if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan))
4781 sc->rxon.flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ);
4782 if (ic->ic_flags & IEEE80211_F_SHSLOT)
4783 sc->rxon.flags |= htole32(IWN_RXON_SHSLOT);

--- 176 unchanged lines hidden (view full) ---

4960 device_printf(sc->sc_dev,
4961 "%s: could not set sensitivity, error %d\n",
4962 __func__, error);
4963 return error;
4964 }
4965
4966 /* Start periodic calibration timer. */
4967 sc->calib.state = IWN_CALIB_STATE_ASSOC;
4957 iwn_calib_reset(sc);
4968 sc->calib_cnt = 0;
4969 callout_reset(&sc->calib_to, msecs_to_ticks(500), iwn_calib_timeout,
4970 sc);
4958
4959 /* Link LED always on while associated. */
4960 iwn_set_led(sc, IWN_LED_LINK, 0, 1);
4961
4962 return 0;
4963#undef MS
4964}
4965

--- 1435 unchanged lines hidden (view full) ---

6401 "%s: could not configure device, error %d\n",
6402 __func__, error);
6403 goto fail;
6404 }
6405
6406 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
6407 ifp->if_drv_flags |= IFF_DRV_RUNNING;
6408
4971
4972 /* Link LED always on while associated. */
4973 iwn_set_led(sc, IWN_LED_LINK, 0, 1);
4974
4975 return 0;
4976#undef MS
4977}
4978

--- 1435 unchanged lines hidden (view full) ---

6414 "%s: could not configure device, error %d\n",
6415 __func__, error);
6416 goto fail;
6417 }
6418
6419 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
6420 ifp->if_drv_flags |= IFF_DRV_RUNNING;
6421
6422 callout_reset(&sc->watchdog_to, hz, iwn_watchdog, sc);
6409 return;
6410
6411fail:
6412 iwn_stop_locked(sc);
6413}
6414
6415static void
6416iwn_init(void *arg)

--- 13 unchanged lines hidden (view full) ---

6430static void
6431iwn_stop_locked(struct iwn_softc *sc)
6432{
6433 struct ifnet *ifp = sc->sc_ifp;
6434
6435 IWN_LOCK_ASSERT(sc);
6436
6437 sc->sc_tx_timer = 0;
6423 return;
6424
6425fail:
6426 iwn_stop_locked(sc);
6427}
6428
6429static void
6430iwn_init(void *arg)

--- 13 unchanged lines hidden (view full) ---

6444static void
6445iwn_stop_locked(struct iwn_softc *sc)
6446{
6447 struct ifnet *ifp = sc->sc_ifp;
6448
6449 IWN_LOCK_ASSERT(sc);
6450
6451 sc->sc_tx_timer = 0;
6438 callout_stop(&sc->sc_timer_to);
6452 callout_stop(&sc->watchdog_to);
6453 callout_stop(&sc->calib_to);
6439 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
6440
6441 /* Power OFF hardware. */
6442 iwn_hw_stop(sc);
6443}
6444
6445static void
6446iwn_stop(struct iwn_softc *sc)

--- 296 unchanged lines hidden ---
6454 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
6455
6456 /* Power OFF hardware. */
6457 iwn_hw_stop(sc);
6458}
6459
6460static void
6461iwn_stop(struct iwn_softc *sc)

--- 296 unchanged lines hidden ---